@milaboratories/pl-model-common 1.48.0 → 1.49.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/author_marker.d.ts +1 -2
- package/dist/author_marker.d.ts.map +1 -1
- package/dist/base64.d.ts +4 -6
- package/dist/base64.d.ts.map +1 -1
- package/dist/block_state.d.ts +13 -9
- package/dist/block_state.d.ts.map +1 -1
- package/dist/bmodel/block_config.d.ts +51 -29
- package/dist/bmodel/block_config.d.ts.map +1 -1
- package/dist/bmodel/block_kind_ref.d.ts +4 -6
- package/dist/bmodel/block_kind_ref.d.ts.map +1 -1
- package/dist/bmodel/code.d.ts +4 -5
- package/dist/bmodel/code.d.ts.map +1 -1
- package/dist/bmodel/container.d.ts +5 -5
- package/dist/bmodel/container.d.ts.map +1 -1
- package/dist/bmodel/normalization.d.ts +1 -3
- package/dist/bmodel/normalization.d.ts.map +1 -1
- package/dist/bmodel/types.d.ts +1 -2
- package/dist/bmodel/types.d.ts.map +1 -1
- package/dist/branding.d.ts +2 -3
- package/dist/branding.d.ts.map +1 -1
- package/dist/columns/accessor_traversal.d.ts +6 -8
- package/dist/columns/accessor_traversal.d.ts.map +1 -1
- package/dist/columns/column_registry.d.ts +2 -3
- package/dist/columns/column_registry.d.ts.map +1 -1
- package/dist/columns/column_selector.d.ts +9 -9
- package/dist/columns/column_selector.d.ts.map +1 -1
- package/dist/columns/dedup.d.ts +1 -3
- package/dist/columns/dedup.d.ts.map +1 -1
- package/dist/columns/providers.d.ts +3 -4
- package/dist/columns/providers.d.ts.map +1 -1
- package/dist/columns/types.d.ts +12 -9
- package/dist/columns/types.d.ts.map +1 -1
- package/dist/common_types.d.ts +4 -6
- package/dist/common_types.d.ts.map +1 -1
- package/dist/dialog/index.d.ts +4 -5
- package/dist/dialog/index.d.ts.map +1 -1
- package/dist/driver_kit.d.ts +2 -2
- package/dist/driver_kit.d.ts.map +1 -1
- package/dist/drivers/ChunkedStreamReader.d.ts +3 -5
- package/dist/drivers/ChunkedStreamReader.d.ts.map +1 -1
- package/dist/drivers/blob.d.ts +36 -25
- package/dist/drivers/blob.d.ts.map +1 -1
- package/dist/drivers/columns/columns_collection_driver.d.ts +6 -7
- package/dist/drivers/columns/columns_collection_driver.d.ts.map +1 -1
- package/dist/drivers/columns/discover_columns_options.d.ts +9 -8
- package/dist/drivers/columns/discover_columns_options.d.ts.map +1 -1
- package/dist/drivers/index.cjs +1 -0
- package/dist/drivers/index.d.ts +4 -2
- package/dist/drivers/index.js +2 -2
- package/dist/drivers/interfaces.d.ts +2 -3
- package/dist/drivers/interfaces.d.ts.map +1 -1
- package/dist/drivers/log.d.ts +26 -28
- package/dist/drivers/log.d.ts.map +1 -1
- package/dist/drivers/ls.d.ts +37 -27
- package/dist/drivers/ls.d.ts.map +1 -1
- package/dist/drivers/pframe/column_filter.d.ts +1 -3
- package/dist/drivers/pframe/column_filter.d.ts.map +1 -1
- package/dist/drivers/pframe/data_info.d.ts +77 -50
- package/dist/drivers/pframe/data_info.d.ts.map +1 -1
- package/dist/drivers/pframe/data_types.d.ts +50 -45
- package/dist/drivers/pframe/data_types.d.ts.map +1 -1
- package/dist/drivers/pframe/driver.d.ts +5 -5
- package/dist/drivers/pframe/driver.d.ts.map +1 -1
- package/dist/drivers/pframe/filter_spec.d.ts +10 -12
- package/dist/drivers/pframe/filter_spec.d.ts.map +1 -1
- package/dist/drivers/pframe/find_columns.d.ts +2 -4
- package/dist/drivers/pframe/find_columns.d.ts.map +1 -1
- package/dist/drivers/pframe/index.cjs +1 -0
- package/dist/drivers/pframe/index.d.ts +4 -2
- package/dist/drivers/pframe/index.js +2 -2
- package/dist/drivers/pframe/linker_columns.d.ts +4 -10
- package/dist/drivers/pframe/linker_columns.d.ts.map +1 -1
- package/dist/drivers/pframe/pframe.d.ts +3 -3
- package/dist/drivers/pframe/pframe.d.ts.map +1 -1
- package/dist/drivers/pframe/query/query_common.d.ts +52 -46
- package/dist/drivers/pframe/query/query_common.d.ts.map +1 -1
- package/dist/drivers/pframe/query/query_data.d.ts +26 -21
- package/dist/drivers/pframe/query/query_data.d.ts.map +1 -1
- package/dist/drivers/pframe/query/query_spec.d.ts +22 -19
- package/dist/drivers/pframe/query/query_spec.d.ts.map +1 -1
- package/dist/drivers/pframe/query/utils.d.ts +15 -11
- package/dist/drivers/pframe/query/utils.d.ts.map +1 -1
- package/dist/drivers/pframe/spec/anchored.d.ts +3 -5
- package/dist/drivers/pframe/spec/anchored.d.ts.map +1 -1
- package/dist/drivers/pframe/spec/discovered_column.d.ts +10 -11
- package/dist/drivers/pframe/spec/discovered_column.d.ts.map +1 -1
- package/dist/drivers/pframe/spec/filtered_column.d.ts +17 -18
- package/dist/drivers/pframe/spec/filtered_column.d.ts.map +1 -1
- package/dist/drivers/pframe/spec/ids.d.ts +16 -16
- package/dist/drivers/pframe/spec/ids.d.ts.map +1 -1
- package/dist/drivers/pframe/spec/index.cjs +1 -0
- package/dist/drivers/pframe/spec/index.d.ts +2 -2
- package/dist/drivers/pframe/spec/index.js +2 -2
- package/dist/drivers/pframe/spec/native_id.d.ts +3 -3
- package/dist/drivers/pframe/spec/native_id.d.ts.map +1 -1
- package/dist/drivers/pframe/spec/overridden.d.ts +14 -16
- package/dist/drivers/pframe/spec/overridden.d.ts.map +1 -1
- package/dist/drivers/pframe/spec/selectors.d.ts +22 -22
- package/dist/drivers/pframe/spec/selectors.d.ts.map +1 -1
- package/dist/drivers/pframe/spec/spec.cjs +31 -0
- package/dist/drivers/pframe/spec/spec.cjs.map +1 -1
- package/dist/drivers/pframe/spec/spec.d.ts +94 -70
- package/dist/drivers/pframe/spec/spec.d.ts.map +1 -1
- package/dist/drivers/pframe/spec/spec.js +31 -1
- package/dist/drivers/pframe/spec/spec.js.map +1 -1
- package/dist/drivers/pframe/spec_driver.d.ts +30 -25
- package/dist/drivers/pframe/spec_driver.d.ts.map +1 -1
- package/dist/drivers/pframe/table.d.ts +1 -3
- package/dist/drivers/pframe/table.d.ts.map +1 -1
- package/dist/drivers/pframe/table_calculate.d.ts +55 -46
- package/dist/drivers/pframe/table_calculate.d.ts.map +1 -1
- package/dist/drivers/pframe/table_common.d.ts +9 -10
- package/dist/drivers/pframe/table_common.d.ts.map +1 -1
- package/dist/drivers/pframe/unique_values.d.ts +3 -3
- package/dist/drivers/pframe/unique_values.d.ts.map +1 -1
- package/dist/drivers/upload.d.ts +2 -3
- package/dist/drivers/upload.d.ts.map +1 -1
- package/dist/drivers/urls.d.ts +7 -8
- package/dist/drivers/urls.d.ts.map +1 -1
- package/dist/errors.d.ts +35 -36
- package/dist/errors.d.ts.map +1 -1
- package/dist/flags/block_flags.cjs.map +1 -1
- package/dist/flags/block_flags.d.ts +7 -7
- package/dist/flags/block_flags.d.ts.map +1 -1
- package/dist/flags/block_flags.js.map +1 -1
- package/dist/flags/flag_utils.d.ts +6 -8
- package/dist/flags/flag_utils.d.ts.map +1 -1
- package/dist/flags/type_utils.d.ts +6 -7
- package/dist/flags/type_utils.d.ts.map +1 -1
- package/dist/httpAuth.d.ts +4 -5
- package/dist/httpAuth.d.ts.map +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +9 -2
- package/dist/index.js +2 -2
- package/dist/json.d.ts +11 -12
- package/dist/json.d.ts.map +1 -1
- package/dist/navigation.d.ts +16 -11
- package/dist/navigation.d.ts.map +1 -1
- package/dist/plid.d.ts +7 -9
- package/dist/plid.d.ts.map +1 -1
- package/dist/pool/entry.d.ts +8 -6
- package/dist/pool/entry.d.ts.map +1 -1
- package/dist/pool/query.d.ts +3 -4
- package/dist/pool/query.d.ts.map +1 -1
- package/dist/pool/spec.d.ts +33 -30
- package/dist/pool/spec.d.ts.map +1 -1
- package/dist/pool_entry.d.ts +2 -3
- package/dist/pool_entry.d.ts.map +1 -1
- package/dist/project_id.d.ts +1 -3
- package/dist/project_id.d.ts.map +1 -1
- package/dist/ref.d.ts +22 -23
- package/dist/ref.d.ts.map +1 -1
- package/dist/resource_types.d.ts +2 -3
- package/dist/resource_types.d.ts.map +1 -1
- package/dist/services/node_service_handlers.d.ts +1 -3
- package/dist/services/node_service_handlers.d.ts.map +1 -1
- package/dist/services/service_capabilities.d.ts +7 -9
- package/dist/services/service_capabilities.d.ts.map +1 -1
- package/dist/services/service_declarations.d.ts +2 -2
- package/dist/services/service_declarations.d.ts.map +1 -1
- package/dist/services/service_injectors.d.ts +7 -8
- package/dist/services/service_injectors.d.ts.map +1 -1
- package/dist/services/service_registry.d.ts +2 -4
- package/dist/services/service_registry.d.ts.map +1 -1
- package/dist/services/service_types.d.ts +24 -26
- package/dist/services/service_types.d.ts.map +1 -1
- package/dist/template/kind_selector.d.ts +9 -11
- package/dist/template/kind_selector.d.ts.map +1 -1
- package/dist/template/project_template_v1.d.ts +22 -20
- package/dist/template/project_template_v1.d.ts.map +1 -1
- package/dist/template/template_ref_form.d.ts +6 -5
- package/dist/template/template_ref_form.d.ts.map +1 -1
- package/dist/template/template_relocate.cjs +24 -3
- package/dist/template/template_relocate.cjs.map +1 -1
- package/dist/template/template_relocate.d.ts +8 -4
- package/dist/template/template_relocate.d.ts.map +1 -1
- package/dist/template/template_relocate.js +24 -3
- package/dist/template/template_relocate.js.map +1 -1
- package/dist/utag.d.ts +2 -4
- package/dist/utag.d.ts.map +1 -1
- package/dist/util.d.ts +2 -3
- package/dist/util.d.ts.map +1 -1
- package/dist/value_or_error.d.ts +2 -3
- package/dist/value_or_error.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/drivers/pframe/spec/spec.ts +31 -0
- package/src/flags/block_flags.ts +1 -1
- package/src/template/template_relocate.test.ts +57 -0
- package/src/template/template_relocate.ts +32 -4
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AxisId, AxisValueType, Domain, PColumnSpec, ValueType } from "./spec.js";
|
|
2
2
|
import { MultiColumnSelector } from "../spec_driver.js";
|
|
3
3
|
import { PObjectSpec } from "../../../pool/spec.js";
|
|
4
|
+
import "../../../pool/index.js";
|
|
4
5
|
//#region src/drivers/pframe/spec/selectors.d.ts
|
|
5
6
|
/**
|
|
6
7
|
* Defines a pattern for matching axes within the PFrame data model.
|
|
@@ -19,7 +20,7 @@ import { PObjectSpec } from "../../../pool/spec.js";
|
|
|
19
20
|
* stricter matching semantics (StringMatcher-based) and a unified approach
|
|
20
21
|
* to working with columns, including domain and annotation matching.
|
|
21
22
|
*/
|
|
22
|
-
interface LegacyAxisSelector {
|
|
23
|
+
export interface LegacyAxisSelector {
|
|
23
24
|
/**
|
|
24
25
|
* Optional value type to match against.
|
|
25
26
|
* When specified, only axes with this exact type will match.
|
|
@@ -47,7 +48,7 @@ interface LegacyAxisSelector {
|
|
|
47
48
|
contextDomain?: Record<string, string>;
|
|
48
49
|
}
|
|
49
50
|
/** Single axis selector */
|
|
50
|
-
interface SingleAxisSelector {
|
|
51
|
+
export interface SingleAxisSelector {
|
|
51
52
|
/** Axis name (required) */
|
|
52
53
|
name: string;
|
|
53
54
|
/** Axis type (optional) */
|
|
@@ -60,7 +61,7 @@ interface SingleAxisSelector {
|
|
|
60
61
|
parentAxes?: SingleAxisSelector[];
|
|
61
62
|
}
|
|
62
63
|
/** Qualification applied to a single axis to make it compatible during integration. */
|
|
63
|
-
interface AxisQualification {
|
|
64
|
+
export interface AxisQualification {
|
|
64
65
|
/** Axis selector identifying which axis is qualified. */
|
|
65
66
|
readonly axis: SingleAxisSelector;
|
|
66
67
|
/** Additional context domain entries applied to the axis. */
|
|
@@ -70,7 +71,7 @@ interface AxisQualification {
|
|
|
70
71
|
* Reference to an axis by its numerical index within the anchor column's axes array
|
|
71
72
|
* Format: [anchorId, axisIndex]
|
|
72
73
|
*/
|
|
73
|
-
type AnchorAxisRefByIdx = {
|
|
74
|
+
export type AnchorAxisRefByIdx = {
|
|
74
75
|
anchor: string;
|
|
75
76
|
idx: number;
|
|
76
77
|
};
|
|
@@ -78,7 +79,7 @@ type AnchorAxisRefByIdx = {
|
|
|
78
79
|
* Reference to an axis by its name within the anchor column
|
|
79
80
|
* Format: [anchorId, axisName]
|
|
80
81
|
*/
|
|
81
|
-
type AnchorAxisRefByName = {
|
|
82
|
+
export type AnchorAxisRefByName = {
|
|
82
83
|
anchor: string;
|
|
83
84
|
name: string;
|
|
84
85
|
};
|
|
@@ -86,41 +87,41 @@ type AnchorAxisRefByName = {
|
|
|
86
87
|
* Reference to an axis using an AxisId matcher within the anchor
|
|
87
88
|
* Format: [anchorId, axisMatcher]
|
|
88
89
|
*/
|
|
89
|
-
type AnchorAxisRefByMatcher = {
|
|
90
|
+
export type AnchorAxisRefByMatcher = {
|
|
90
91
|
anchor: string;
|
|
91
92
|
id: AxisId;
|
|
92
93
|
};
|
|
93
94
|
/**
|
|
94
95
|
* Basic anchor axis reference that can be either by index or a direct AxisId
|
|
95
96
|
*/
|
|
96
|
-
type AnchorAxisIdOrRefBasic = AnchorAxisRefByIdx | AxisId;
|
|
97
|
+
export type AnchorAxisIdOrRefBasic = AnchorAxisRefByIdx | AxisId;
|
|
97
98
|
/** Union of all possible ways to reference an axis in an anchored context */
|
|
98
|
-
type AnchorAxisRef = AnchorAxisRefByIdx | AnchorAxisRefByName | AnchorAxisRefByMatcher;
|
|
99
|
+
export type AnchorAxisRef = AnchorAxisRefByIdx | AnchorAxisRefByName | AnchorAxisRefByMatcher;
|
|
99
100
|
/** Reference to a domain value through an anchor */
|
|
100
|
-
type AnchorDomainRef = {
|
|
101
|
+
export type AnchorDomainRef = {
|
|
101
102
|
anchor: string;
|
|
102
103
|
};
|
|
103
104
|
/**
|
|
104
105
|
* Domain value that can be either a direct string value or a reference to a domain through an anchor
|
|
105
106
|
* Used to establish domain context that can be resolved relative to other anchored columns
|
|
106
107
|
*/
|
|
107
|
-
type ADomain = string | AnchorDomainRef;
|
|
108
|
+
export type ADomain = string | AnchorDomainRef;
|
|
108
109
|
/**
|
|
109
110
|
* Axis identifier that can be either a direct AxisId or a reference to an axis through an anchor
|
|
110
111
|
* Allows referring to axes in a way that can be resolved in different contexts
|
|
111
112
|
*/
|
|
112
|
-
type AAxisSelector = LegacyAxisSelector | AnchorAxisRef;
|
|
113
|
+
export type AAxisSelector = LegacyAxisSelector | AnchorAxisRef;
|
|
113
114
|
/**
|
|
114
115
|
* Match resolution strategy for PColumns
|
|
115
116
|
* Specifies how to handle when multiple columns match the criteria
|
|
116
117
|
* (default is "expectSingle")
|
|
117
118
|
*/
|
|
118
|
-
type AnchoredColumnMatchStrategy = "expectSingle" | "expectMultiple" | "takeFirst";
|
|
119
|
+
export type AnchoredColumnMatchStrategy = "expectSingle" | "expectMultiple" | "takeFirst";
|
|
119
120
|
/**
|
|
120
121
|
* Matcher for PColumns in an anchored context
|
|
121
122
|
* Supports partial matching on axes, allowing for flexible column discovery
|
|
122
123
|
*/
|
|
123
|
-
interface AnchoredPColumnSelector {
|
|
124
|
+
export interface AnchoredPColumnSelector {
|
|
124
125
|
/** Optional name of the column to match; can't be used together with namePattern */
|
|
125
126
|
name?: string;
|
|
126
127
|
/** Optional regexp pattern for column name matching; can't be used together with name */
|
|
@@ -151,7 +152,7 @@ interface AnchoredPColumnSelector {
|
|
|
151
152
|
/**
|
|
152
153
|
* Matcher for PColumns in a non-anchored context
|
|
153
154
|
*/
|
|
154
|
-
interface PColumnSelector extends AnchoredPColumnSelector {
|
|
155
|
+
export interface PColumnSelector extends AnchoredPColumnSelector {
|
|
155
156
|
domainAnchor?: never;
|
|
156
157
|
domain?: Record<string, string>;
|
|
157
158
|
contextDomainAnchor?: never;
|
|
@@ -163,7 +164,7 @@ interface PColumnSelector extends AnchoredPColumnSelector {
|
|
|
163
164
|
* Unlike APColumnMatcher, this requires exact matches on domain and axes
|
|
164
165
|
* @deprecated This is part of the legacy column matching API. The new Columns API (see sdk/model/src/columns/) now handles column and axis
|
|
165
166
|
*/
|
|
166
|
-
interface AnchoredPColumnId extends AnchoredPColumnSelector {
|
|
167
|
+
export interface AnchoredPColumnId extends AnchoredPColumnSelector {
|
|
167
168
|
/** Name is required for exact column identification */
|
|
168
169
|
name: string;
|
|
169
170
|
/** No namePattern in ID */
|
|
@@ -186,7 +187,7 @@ interface AnchoredPColumnId extends AnchoredPColumnSelector {
|
|
|
186
187
|
* @param id - The value to check
|
|
187
188
|
* @returns True if the value is an anchored column identifier, false otherwise
|
|
188
189
|
*/
|
|
189
|
-
declare function isAnchoredPColumnId(id: unknown): id is AnchoredPColumnId;
|
|
190
|
+
export declare function isAnchoredPColumnId(id: unknown): id is AnchoredPColumnId;
|
|
190
191
|
/**
|
|
191
192
|
* Determines if an axis ID matches an axis selector.
|
|
192
193
|
*
|
|
@@ -194,7 +195,7 @@ declare function isAnchoredPColumnId(id: unknown): id is AnchoredPColumnId;
|
|
|
194
195
|
* @param axis - The AxisId to check against the selector
|
|
195
196
|
* @returns true if the AxisId matches all specified criteria in the selector, false otherwise
|
|
196
197
|
*/
|
|
197
|
-
declare function matchAxis(selector: LegacyAxisSelector, axis: AxisId): boolean;
|
|
198
|
+
export declare function matchAxis(selector: LegacyAxisSelector, axis: AxisId): boolean;
|
|
198
199
|
/**
|
|
199
200
|
* Determines if a given PColumnSpec matches a selector.
|
|
200
201
|
*
|
|
@@ -202,21 +203,20 @@ declare function matchAxis(selector: LegacyAxisSelector, axis: AxisId): boolean;
|
|
|
202
203
|
* @param selector - The selector criteria to match against
|
|
203
204
|
* @returns true if the PColumnSpec matches all criteria in the selector, false otherwise
|
|
204
205
|
*/
|
|
205
|
-
declare function matchPColumn(pcolumn: PColumnSpec, selector: PColumnSelector): boolean;
|
|
206
|
+
export declare function matchPColumn(pcolumn: PColumnSpec, selector: PColumnSelector): boolean;
|
|
206
207
|
/**
|
|
207
208
|
* Convert a predicate or array of selectors to a single predicate function
|
|
208
209
|
* @param predicateOrSelectors - Either a function that takes a PColumnSpec and returns a boolean,
|
|
209
210
|
* or an array of PColumnSelectors, or a single PColumnSelector
|
|
210
211
|
* @returns A function that takes a PColumnSpec and returns a boolean
|
|
211
212
|
*/
|
|
212
|
-
declare function legacyColumnSelectorsToPredicate(predicateOrSelectors: PColumnSelector | PColumnSelector[]): (spec: PObjectSpec) => boolean;
|
|
213
|
+
export declare function legacyColumnSelectorsToPredicate(predicateOrSelectors: PColumnSelector | PColumnSelector[]): (spec: PObjectSpec) => boolean;
|
|
213
214
|
/** Match a {@link PColumnSpec} against a {@link MultiColumnSelector}. */
|
|
214
|
-
declare function matchMultiColumnSelector(spec: PColumnSpec, selector: MultiColumnSelector): boolean;
|
|
215
|
+
export declare function matchMultiColumnSelector(spec: PColumnSpec, selector: MultiColumnSelector): boolean;
|
|
215
216
|
/**
|
|
216
217
|
* Convert a {@link MultiColumnSelector} (or array; selectors OR-ed) to a predicate.
|
|
217
218
|
* Non-PColumn specs always return false.
|
|
218
219
|
*/
|
|
219
|
-
declare function multiColumnSelectorsToPredicate(selectors: MultiColumnSelector | MultiColumnSelector[]): (spec: PObjectSpec) => boolean;
|
|
220
|
+
export declare function multiColumnSelectorsToPredicate(selectors: MultiColumnSelector | MultiColumnSelector[]): (spec: PObjectSpec) => boolean;
|
|
220
221
|
//#endregion
|
|
221
|
-
export { AAxisSelector, ADomain, AnchorAxisIdOrRefBasic, AnchorAxisRef, AnchorAxisRefByIdx, AnchorAxisRefByMatcher, AnchorAxisRefByName, AnchorDomainRef, AnchoredColumnMatchStrategy, AnchoredPColumnId, AnchoredPColumnSelector, AxisQualification, LegacyAxisSelector, PColumnSelector, SingleAxisSelector, isAnchoredPColumnId, legacyColumnSelectorsToPredicate, matchAxis, matchMultiColumnSelector, matchPColumn, multiColumnSelectorsToPredicate };
|
|
222
222
|
//# sourceMappingURL=selectors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.d.ts","names":[],"sources":["../../../../src/drivers/pframe/spec/selectors.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"selectors.d.ts","names":[],"sources":["../../../../src/drivers/pframe/spec/selectors.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;iBA2BiB;;;;;;;EAOf,OAAO,YAAY;;;;;EAMnB;;;;;;;EAQA,SAAS;;;;;;EAOT,gBAAgB;;;iBAID;;EAEf;;EAEA,OAAO;;EAEP,SAAS;;EAET,gBAAgB;;EAEhB,aAAa;;;iBAIE;;WAEN,MAAM;;WAEN,eAAe;;;;;;YAOd;EAAuB;EAAgB;;;;;;YAMvC;EAAwB;EAAgB;;;;;;YAMxC;EAA2B;EAAgB,IAAI;;;;;YAK/C,yBAAyB,qBAAqB;;YAG9C,gBAAgB,qBAAqB,sBAAsB;;YAG3D;EAAoB;;;;;;YAMpB,mBAAmB;;;;;YAKnB,gBAAgB,qBAAqB;;;;;;YAOrC;;;;;iBAMK;;EAEf;;EAEA;;EAEA,OAAO,YAAY;;EAEnB;;;EAGA,SAAS,eAAe;;EAExB;;;EAGA,gBAAgB,eAAe;;EAE/B,OAAO;;EAEP;;EAEA,cAAc;;EAEd,qBAAqB;;EAErB,gBAAgB;;;;;iBAMD,wBAAwB;EACvC;EACA,SAAS;EACT;EACA,gBAAgB;EAChB,OAAO;;;;;;;iBAQQ,0BAA0B;;EAEzC;;EAEA;;EAEA;;EAEA,MAAM;;EAEN;;EAEA;;EAEA;;EAEA;;;;;;;wBAQc,oBAAoB,cAAc,MAAM;;;;;;;;wBAYxC,UAAU,UAAU,oBAAoB,MAAM;;;;;;;;wBAqC9C,aAAa,SAAS,aAAa,UAAU;;;;;;;wBA0E7C,iCACd,sBAAsB,kBAAkB,qBACtC,MAAM;;wBAmCM,yBACd,MAAM,aACN,UAAU;;;;;wBAkCI,gCACd,WAAW,sBAAsB,yBAC/B,MAAM"}
|
|
@@ -39,6 +39,36 @@ const Domain = {
|
|
|
39
39
|
ScClonotypeChain: { Index: "pl7.app/vdj/scClonotypeChain/index" }
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Domain keys whose value is the id of a block, rather than a qualifier of the data.
|
|
44
|
+
*
|
|
45
|
+
* Applying a template repoints these at the blocks of the project being built: an axis a block
|
|
46
|
+
* produced names that block in its domain, so an axis left naming the exported-from project
|
|
47
|
+
* resolves to nothing. Listing the keys is what makes that safe — a template's entry ids are
|
|
48
|
+
* arbitrary non-empty strings, so a hand-written template may name an entry `closest`, and a
|
|
49
|
+
* qualifier that happens to read `closest` must not be mistaken for a reference to it.
|
|
50
|
+
*
|
|
51
|
+
* A key absent from here is simply left alone, which is the behaviour from before relocation
|
|
52
|
+
* reached domains at all. Adding one is therefore safe; omitting one costs only that a template
|
|
53
|
+
* carrying it applies still pointing at the project it came from.
|
|
54
|
+
*/
|
|
55
|
+
const BlockScopedDomain = /* @__PURE__ */ new Set([
|
|
56
|
+
"pl7.app/blockId",
|
|
57
|
+
"pl7.app/block",
|
|
58
|
+
"pl7.app/redefined-by",
|
|
59
|
+
"pl7.app/annotationRunId",
|
|
60
|
+
"pl7.app/clonotypeAnnotationRunId",
|
|
61
|
+
"pl7.app/clustering/blockId",
|
|
62
|
+
"pl7.app/umap/blockId",
|
|
63
|
+
"pl7.app/peptide/extractionRunId",
|
|
64
|
+
"pl7.app/repertoire/extractionRunId",
|
|
65
|
+
"pl7.app/antibodyVariantDesigner/designRunId",
|
|
66
|
+
"pl7.app/vdj/clonotypingRunId",
|
|
67
|
+
"pl7.app/vdj/clustering/blockId",
|
|
68
|
+
"pl7.app/vdj/integration/blockId",
|
|
69
|
+
"pl7.app/vdj/spatiotemporalAnalysis/blockId",
|
|
70
|
+
"pl7.app/vdj/libraryId"
|
|
71
|
+
]);
|
|
42
72
|
const DomainJson = {};
|
|
43
73
|
function readDomain(spec, key) {
|
|
44
74
|
return readMetadata(spec?.domain, key);
|
|
@@ -390,6 +420,7 @@ function isAxisId(id) {
|
|
|
390
420
|
//#endregion
|
|
391
421
|
exports.Annotation = Annotation;
|
|
392
422
|
exports.AnnotationJson = AnnotationJson;
|
|
423
|
+
exports.BlockScopedDomain = BlockScopedDomain;
|
|
393
424
|
exports.Domain = Domain;
|
|
394
425
|
exports.DomainJson = DomainJson;
|
|
395
426
|
exports.PAxisName = PAxisName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec.cjs","names":["ensureError","z","canonicalizeJson"],"sources":["../../../../src/drivers/pframe/spec/spec.ts"],"sourcesContent":["import { ensureError } from \"../../../errors\";\nimport { canonicalizeJson, type CanonicalizedJson, type StringifiedJson } from \"../../../json\";\nimport type { PObject, PObjectId, PObjectSpec } from \"../../../pool\";\nimport { z } from \"zod\";\n\nexport const ValueType = {\n Int: \"Int\",\n Long: \"Long\",\n Float: \"Float\",\n Double: \"Double\",\n String: \"String\",\n Bytes: \"Bytes\",\n} as const;\n\nexport type AxisValueType = Extract<ValueType, \"Int\" | \"Long\" | \"String\">;\nexport type ColumnValueType = ValueType;\n\n/** PFrame columns and axes within them may store one of these types. */\nexport type ValueType = (typeof ValueType)[keyof typeof ValueType];\n\nexport type Metadata = Record<string, string>;\n\nexport function readMetadata<U extends Metadata, T extends keyof U = keyof U>(\n metadata: Metadata | undefined,\n key: T,\n): U[T] | undefined {\n return (metadata as U | undefined)?.[key];\n}\n\ntype MetadataJsonImpl<M> = {\n [P in keyof M as M[P] extends StringifiedJson ? P : never]: M[P] extends StringifiedJson<infer U>\n ? z.ZodType<U>\n : never;\n};\nexport type MetadataJson<M> = MetadataJsonImpl<Required<M>>;\n\nexport function readMetadataJsonOrThrow<M extends Metadata, T extends keyof MetadataJson<M>>(\n metadata: Metadata | undefined,\n metadataJson: MetadataJson<M>,\n key: T,\n methodNameInError: string = \"readMetadataJsonOrThrow\",\n): z.infer<MetadataJson<M>[T]> | undefined {\n const json = readMetadata<M, T>(metadata, key);\n if (json === undefined) return undefined;\n\n const schema = metadataJson[key];\n try {\n const value = JSON.parse(json);\n return schema.parse(value);\n } catch (error: unknown) {\n throw new Error(\n `${methodNameInError} failed, ` +\n `key: ${String(key)}, ` +\n `value: ${json}, ` +\n `error: ${ensureError(error)}`,\n );\n }\n}\n\nexport function readMetadataJson<M extends Metadata, T extends keyof MetadataJson<M>>(\n metadata: Metadata | undefined,\n metadataJson: MetadataJson<M>,\n key: T,\n): z.infer<MetadataJson<M>[T]> | undefined {\n try {\n return readMetadataJsonOrThrow(metadata, metadataJson, key);\n } catch {\n return undefined; // treat invalid values as unset\n }\n}\n\n/// Well-known domains\nexport const Domain = {\n Alphabet: \"pl7.app/alphabet\",\n BlockId: \"pl7.app/blockId\",\n VDJ: {\n Clustering: {\n BlockId: \"pl7.app/vdj/clustering/blockId\",\n },\n ScClonotypeChain: {\n Index: \"pl7.app/vdj/scClonotypeChain/index\",\n },\n },\n} as const;\n\nexport type Domain = Metadata &\n Partial<{\n [Domain.Alphabet]: \"nucleotide\" | \"aminoacid\" | (string & {});\n [Domain.BlockId]: string;\n [Domain.VDJ.ScClonotypeChain.Index]: \"primary\" | \"secondary\" | (string & {});\n }>;\n\nexport type DomainJson = MetadataJson<Domain>;\nexport const DomainJson: DomainJson = {};\n\n/// Helper function for reading plain domain values\nexport function readDomain<T extends keyof Domain>(\n spec: { domain?: Metadata | undefined } | undefined,\n key: T,\n): Domain[T] | undefined {\n return readMetadata<Domain, T>(spec?.domain, key);\n}\n\n/// Helper function for reading json-encoded domain values, throws on JSON parsing error\nexport function readDomainJsonOrThrow<T extends keyof DomainJson>(\n spec: { domain?: Metadata | undefined } | undefined,\n key: T,\n): z.infer<DomainJson[T]> | undefined {\n return readMetadataJsonOrThrow<Domain, T>(spec?.domain, DomainJson, key, \"readDomainJsonOrThrow\");\n}\n\n/// Helper function for reading json-encoded domain values, returns undefined on JSON parsing error\nexport function readDomainJson<T extends keyof DomainJson>(\n spec: { domain?: Metadata | undefined } | undefined,\n key: T,\n): z.infer<DomainJson[T]> | undefined {\n return readMetadataJson<Domain, T>(spec?.domain, DomainJson, key);\n}\n\n/// Well-known annotations\nexport const Annotation = {\n AxisNature: \"pl7.app/axisNature\",\n Alphabet: \"pl7.app/alphabet\",\n Description: \"pl7.app/description\",\n DataStatus: \"pl7.app/dataStatus\",\n DiscreteValues: \"pl7.app/discreteValues\",\n Format: \"pl7.app/format\",\n Graph: {\n Axis: {\n HighCardinality: \"pl7.app/graph/axis/highCardinality\",\n LowerLimit: \"pl7.app/graph/axis/lowerLimit\",\n SymmetricRange: \"pl7.app/graph/axis/symmetricRange\",\n UpperLimit: \"pl7.app/graph/axis/upperLimit\",\n },\n IsDenseAxis: \"pl7.app/graph/isDenseAxis\",\n IsVirtual: \"pl7.app/graph/isVirtual\",\n Palette: \"pl7.app/graph/palette\",\n Thresholds: \"pl7.app/graph/thresholds\",\n TreatAbsentValuesAs: \"pl7.app/graph/treatAbsentValuesAs\",\n },\n HideDataFromUi: \"pl7.app/hideDataFromUi\",\n HideDataFromGraphs: \"pl7.app/hideDataFromGraphs\",\n IsDiscreteFilter: \"pl7.app/isDiscreteFilter\",\n IsAnchor: \"pl7.app/isAnchor\",\n IsLinkerColumn: \"pl7.app/isLinkerColumn\",\n IsScore: \"pl7.app/isScore\",\n IsSubset: \"pl7.app/isSubset\",\n Label: \"pl7.app/label\",\n LinkLabel: \"pl7.app/linkLabel\",\n Max: \"pl7.app/max\",\n Min: \"pl7.app/min\",\n MultipliesBy: \"pl7.app/multipliesBy\",\n Parents: \"pl7.app/parents\",\n Score: {\n DefaultCutoff: \"pl7.app/score/defaultCutoff\",\n RankingOrder: \"pl7.app/score/rankingOrder\",\n },\n Sequence: {\n Annotation: {\n Mapping: \"pl7.app/sequence/annotation/mapping\",\n },\n IsAnnotation: \"pl7.app/sequence/isAnnotation\",\n },\n Table: {\n FontFamily: \"pl7.app/table/fontFamily\",\n OrderPriority: \"pl7.app/table/orderPriority\",\n Visibility: \"pl7.app/table/visibility\",\n Info: \"pl7.app/table/info\",\n },\n Trace: \"pl7.app/trace\",\n VDJ: {\n IsAssemblingFeature: \"pl7.app/vdj/isAssemblingFeature\",\n IsMainSequence: \"pl7.app/vdj/isMainSequence\",\n },\n} as const;\n\nexport type AnnotationDataStatus =\n | \"missing\"\n | \"resolving\"\n | \"absent\"\n | \"computing\"\n | \"ready\"\n | \"error\";\n\nexport type Annotation = Metadata &\n Partial<{\n [Annotation.Alphabet]: \"nucleotide\" | \"aminoacid\" | (string & {});\n [Annotation.AxisNature]: \"homogeneous\" | \"heterogeneous\" | \"scaleCompatible\" | (string & {});\n [Annotation.Description]: string;\n [Annotation.DataStatus]: AnnotationDataStatus;\n [Annotation.DiscreteValues]: StringifiedJson<number[]> | StringifiedJson<string[]>;\n [Annotation.Format]: string;\n [Annotation.Graph.Axis.HighCardinality]: StringifiedJson<boolean>;\n [Annotation.Graph.Axis.LowerLimit]: StringifiedJson<number>;\n [Annotation.Graph.Axis.SymmetricRange]: StringifiedJson<boolean>;\n [Annotation.Graph.Axis.UpperLimit]: StringifiedJson<number>;\n [Annotation.Graph.IsDenseAxis]: StringifiedJson<boolean>;\n [Annotation.Graph.IsVirtual]: StringifiedJson<boolean>;\n [Annotation.Graph.Palette]: StringifiedJson<{ mapping: Record<string, number>; name: string }>;\n [Annotation.Graph.Thresholds]: StringifiedJson<\n { columnId: { valueType: ValueType; name: string }; value: number }[]\n >;\n [Annotation.Graph.TreatAbsentValuesAs]: StringifiedJson<number>;\n [Annotation.HideDataFromGraphs]: StringifiedJson<boolean>;\n [Annotation.HideDataFromUi]: StringifiedJson<boolean>;\n [Annotation.IsDiscreteFilter]: StringifiedJson<boolean>;\n [Annotation.IsLinkerColumn]: StringifiedJson<boolean>;\n [Annotation.IsSubset]: StringifiedJson<boolean>;\n [Annotation.Label]: string;\n [Annotation.Max]: StringifiedJson<number>;\n [Annotation.Min]: StringifiedJson<number>;\n [Annotation.MultipliesBy]: StringifiedJson<AxisSpec[\"name\"][]>;\n [Annotation.Parents]: StringifiedJson<AxisSpec[\"name\"][]>;\n [Annotation.Sequence.Annotation.Mapping]: StringifiedJson<Record<string, string>>;\n [Annotation.Sequence.IsAnnotation]: StringifiedJson<boolean>;\n [Annotation.Table.FontFamily]: string;\n [Annotation.Table.OrderPriority]: StringifiedJson<number>;\n [Annotation.Table.Visibility]: \"hidden\" | \"optional\" | (string & {});\n [Annotation.Table.Info]: string;\n [Annotation.Trace]: StringifiedJson<Trace>;\n [Annotation.VDJ.IsAssemblingFeature]: StringifiedJson<boolean>;\n }>;\n\n/// One step in a column's derivation lineage. Only `type` and `label` are part\n/// of the typed public surface; writers may add fields (e.g. `id`, `importance`)\n/// passed through opaquely as `unknown`, accessed via explicit narrowing.\nconst TraceEntrySchema = z\n .object({\n type: z.string(),\n label: z.string(),\n })\n .catchall(z.unknown());\n\nexport type TraceEntry = z.infer<typeof TraceEntrySchema>;\n\nexport type Trace = TraceEntry[];\n\n// export const AxisSpec = z.object({\n// type: z.nativeEnum(ValueType),\n// name: z.string(),\n// domain: z.record(z.string(), z.string()).optional(),\n// annotations: z.record(z.string(), z.string()).optional(),\n// parentAxes: z.array(z.number()).optional(),\n// }).passthrough();\n//\n// type Expect<T extends true> = T;\n// type Equal<X, Y> =\n// (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;\n//\n// type _test = Expect<Equal<\n// Readonly<z.infer<typeof AxisSpec>>,\n// Readonly<AxisSpec & Record<string, unknown>>\n// >>;\n\nexport type AnnotationJson = MetadataJson<Annotation>;\n\nconst ValueTypeSchema = z.enum([\"Int\", \"Long\", \"Float\", \"Double\", \"String\"] as const);\nexport const AnnotationJson: AnnotationJson = {\n [Annotation.DiscreteValues]: z.array(z.string()).or(z.array(z.number())),\n [Annotation.Graph.Axis.HighCardinality]: z.boolean(),\n [Annotation.Graph.Axis.LowerLimit]: z.number(),\n [Annotation.Graph.Axis.UpperLimit]: z.number(),\n [Annotation.Graph.Axis.SymmetricRange]: z.boolean(),\n [Annotation.Graph.IsDenseAxis]: z.boolean(),\n [Annotation.Graph.Palette]: z.object({ mapping: z.record(z.number()), name: z.string() }),\n [Annotation.Graph.Thresholds]: z.array(\n z.object({\n columnId: z.object({ valueType: ValueTypeSchema, name: z.string() }),\n value: z.number(),\n }),\n ),\n [Annotation.Graph.TreatAbsentValuesAs]: z.number(),\n [Annotation.Graph.IsVirtual]: z.boolean(),\n [Annotation.HideDataFromUi]: z.boolean(),\n [Annotation.HideDataFromGraphs]: z.boolean(),\n [Annotation.IsDiscreteFilter]: z.boolean(),\n [Annotation.IsLinkerColumn]: z.boolean(),\n [Annotation.IsSubset]: z.boolean(),\n [Annotation.Max]: z.number(),\n [Annotation.Min]: z.number(),\n [Annotation.MultipliesBy]: z.array(z.string()),\n [Annotation.Parents]: z.array(z.string()),\n [Annotation.Sequence.Annotation.Mapping]: z.record(z.string(), z.string()),\n [Annotation.Sequence.IsAnnotation]: z.boolean(),\n [Annotation.Table.OrderPriority]: z.number(),\n [Annotation.Trace]: z.array(TraceEntrySchema),\n [Annotation.VDJ.IsAssemblingFeature]: z.boolean(),\n};\n\n/// Helper function for reading plain annotation values\nexport function readAnnotation<T extends keyof Annotation>(\n spec: { annotations?: Metadata | undefined } | undefined,\n key: T,\n): Annotation[T] | undefined {\n return readMetadata<Annotation, T>(spec?.annotations, key);\n}\n\n/// Helper function for reading json-encoded annotation values, throws on JSON parsing error\nexport function readAnnotationJsonOrThrow<T extends keyof AnnotationJson>(\n spec: { annotations?: Metadata | undefined } | undefined,\n key: T,\n): z.infer<AnnotationJson[T]> | undefined {\n return readMetadataJsonOrThrow<Annotation, T>(\n spec?.annotations,\n AnnotationJson,\n key,\n \"readAnnotationJsonOrThrow\",\n );\n}\n\n/// Helper function for reading json-encoded annotation values, returns undefined on JSON parsing error\nexport function readAnnotationJson<T extends keyof AnnotationJson>(\n spec: { annotations?: Metadata | undefined } | undefined,\n key: T,\n): z.infer<AnnotationJson[T]> | undefined {\n return readMetadataJson<Annotation, T>(spec?.annotations, AnnotationJson, key);\n}\n\nexport function isLinkerColumn(column: PColumnSpec): boolean {\n return !!readAnnotationJson(column, Annotation.IsLinkerColumn);\n}\n\n/**\n * Specification of an individual axis.\n *\n * Each axis is a part of a composite key that addresses data inside the PColumn.\n *\n * Each record inside a PColumn is addressed by a unique tuple of values set for\n * all the axes specified in the column spec.\n */\nexport type AxisSpec = {\n /** Type of the axis value. Should not use non-key types like float or double. */\n readonly type: AxisValueType;\n\n /** Name of the axis */\n readonly name: string;\n\n /** Adds auxiliary information to the axis name, type and parents to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n\n /** Context domain provides additional axis identity that is matched\n * by kinship rules (subset/superset/overlap) rather than exact equality */\n readonly contextDomain?: Record<string, string>;\n\n /** Any additional information attached to the axis that does not affect its\n * identifier */\n readonly annotations?: Record<string, string>;\n\n /**\n * Parent axes provide contextual grouping for the axis in question, establishing\n * a hierarchy where the current axis is dependent on one or more axes for its\n * full definition and meaning. For instance, in a data structure where each\n * \"container\" axis may contain multiple \"item\" axes, the `item` axis would\n * list the index of the `container` axis in this field to denote its dependency.\n *\n * This means that the identity or significance of the `item` axis is only\n * interpretable when combined with its parent `container` axis. An `item` axis\n * index by itself may be non-unique and only gains uniqueness within the context\n * of its parent `container`. Therefore, the `parentAxes` field is essential for\n * mapping these relationships and ensuring data coherence across nested or\n * multi-level data models.\n *\n * A list of zero-based indices of parent axes in the overall axes specification\n * from the column spec. Each index corresponds to the position of a parent axis\n * in the list that defines the structure of the data model.\n */\n readonly parentAxes?: number[];\n};\n\n/** Parents are specs, not indexes; normalized axis can be used considering its parents independently from column */\nexport interface AxisSpecNormalized extends Omit<AxisSpec, \"parentAxes\"> {\n parentAxesSpec: AxisSpecNormalized[];\n}\n\n/** Tree: axis is a root, its parents are children */\nexport type AxisTree = {\n axis: AxisSpecNormalized;\n children: AxisTree[]; // parents\n};\n\nfunction makeAxisTree(axis: AxisSpecNormalized): AxisTree {\n return { axis, children: [] };\n}\n\n/** Build tree by axis parents annotations */\nexport function getAxesTree(rootAxis: AxisSpecNormalized): AxisTree {\n const root = makeAxisTree(rootAxis);\n let nodesQ = [root];\n while (nodesQ.length) {\n const nextNodes: AxisTree[] = [];\n for (const node of nodesQ) {\n node.children = node.axis.parentAxesSpec.map(makeAxisTree);\n nextNodes.push(...node.children);\n }\n nodesQ = nextNodes;\n }\n return root;\n}\n\n/** Get set of canonicalized axisIds from axisTree */\nexport function getSetFromAxisTree(tree: AxisTree): Set<CanonicalizedJson<AxisId>> {\n const set = new Set([canonicalizeJson(getAxisId(tree.axis))]);\n let nodesQ = [tree];\n while (nodesQ.length) {\n const nextNodes = [];\n for (const node of nodesQ) {\n for (const parent of node.children) {\n set.add(canonicalizeJson(getAxisId(parent.axis)));\n nextNodes.push(parent);\n }\n }\n nodesQ = nextNodes;\n }\n return set;\n}\n\n/** Get array of axisSpecs from axisTree */\nexport function getArrayFromAxisTree(tree: AxisTree): AxisSpecNormalized[] {\n const res = [tree.axis];\n let nodesQ = [tree];\n while (nodesQ.length) {\n const nextNodes = [];\n for (const node of nodesQ) {\n for (const parent of node.children) {\n res.push(parent.axis);\n nextNodes.push(parent);\n }\n }\n nodesQ = nextNodes;\n }\n return res;\n}\n\nexport function canonicalizeAxisWithParents(axis: AxisSpecNormalized) {\n return canonicalizeJson(getArrayFromAxisTree(getAxesTree(axis)).map(getAxisId));\n}\n\nfunction normalizingAxesComparator(\n axis1: AxisSpecNormalized,\n axis2: AxisSpecNormalized,\n): 1 | -1 | 0 {\n if (axis1.name !== axis2.name) {\n return axis1.name < axis2.name ? 1 : -1;\n }\n if (axis1.type !== axis2.type) {\n return axis1.type < axis2.type ? 1 : -1;\n }\n const domain1 = canonicalizeJson(axis1.domain ?? {});\n const domain2 = canonicalizeJson(axis2.domain ?? {});\n if (domain1 !== domain2) {\n return domain1 < domain2 ? 1 : -1;\n }\n\n const contextDomain1 = canonicalizeJson(axis1.contextDomain ?? {});\n const contextDomain2 = canonicalizeJson(axis2.contextDomain ?? {});\n if (contextDomain1 !== contextDomain2) {\n return contextDomain1 < contextDomain2 ? 1 : -1;\n }\n\n const parents1 = canonicalizeAxisWithParents(axis1);\n const parents2 = canonicalizeAxisWithParents(axis2);\n\n if (parents1 !== parents2) {\n return parents1 < parents2 ? 1 : -1;\n }\n\n const annotation1 = canonicalizeJson(axis1.annotations ?? {});\n const annotation2 = canonicalizeJson(axis2.annotations ?? {});\n if (annotation1 !== annotation2) {\n return annotation1 < annotation2 ? 1 : -1;\n }\n return 0;\n}\n\nfunction parseParentsFromAnnotations(axis: AxisSpec) {\n const parentsList = readAnnotationJson(axis, Annotation.Parents);\n if (parentsList === undefined) {\n return [];\n }\n return parentsList;\n}\n\nfunction sortParentsDeep(axisSpec: AxisSpecNormalized) {\n axisSpec.parentAxesSpec.forEach(sortParentsDeep);\n axisSpec.parentAxesSpec.sort(normalizingAxesComparator);\n}\n\nfunction hasCycleOfParents(axisSpec: AxisSpecNormalized) {\n const root = makeAxisTree(axisSpec);\n let nodesQ = [root];\n const ancestors = new Set(canonicalizeJson(getAxisId(axisSpec)));\n while (nodesQ.length) {\n const nextNodes: AxisTree[] = [];\n const levelIds = new Set<CanonicalizedJson<AxisId>>();\n for (const node of nodesQ) {\n node.children = node.axis.parentAxesSpec.map(makeAxisTree);\n for (const child of node.children) {\n const childId = canonicalizeJson(getAxisId(child.axis));\n if (!levelIds.has(childId)) {\n nextNodes.push(child);\n levelIds.add(childId);\n if (ancestors.has(childId)) {\n return true;\n }\n ancestors.add(childId);\n }\n }\n }\n nodesQ = nextNodes;\n }\n return false;\n}\n\n/** Create list of normalized axisSpec (parents are in array of specs, not indexes) */\nexport function getNormalizedAxesList(axes: AxisSpec[]): AxisSpecNormalized[] {\n if (axes.length === 0) {\n return [];\n }\n const modifiedAxes: AxisSpecNormalized[] = axes.map((axis) => {\n const { parentAxes: _, ...copiedRest } = axis;\n return { ...copiedRest, annotations: { ...copiedRest.annotations }, parentAxesSpec: [] };\n });\n\n axes.forEach((axis, idx) => {\n const modifiedAxis = modifiedAxes[idx];\n if (axis.parentAxes) {\n // if we have parents by indexes then take from the list\n modifiedAxis.parentAxesSpec = axis.parentAxes.map((idx) => modifiedAxes[idx]);\n } else {\n // else try to parse from annotation name\n const parents = parseParentsFromAnnotations(axis).map((name) =>\n modifiedAxes.find((axis) => axis.name === name),\n );\n modifiedAxis.parentAxesSpec = parents.some((p) => p === undefined)\n ? []\n : (parents as AxisSpecNormalized[]);\n }\n });\n\n if (modifiedAxes.some(hasCycleOfParents)) {\n // Axes list is broken\n modifiedAxes.forEach((axis) => {\n axis.parentAxesSpec = [];\n });\n } else {\n modifiedAxes.forEach((axis) => {\n sortParentsDeep(axis);\n });\n }\n\n return modifiedAxes;\n}\n\n/** Create list of regular axisSpec from normalized (parents are indexes, inside of current axes list) */\nexport function getDenormalizedAxesList(axesSpec: AxisSpecNormalized[]): AxisSpec[] {\n const idsList = axesSpec.map(canonicalizeAxisId);\n return axesSpec.map((axisSpec) => {\n const parentsIds = axisSpec.parentAxesSpec.map(canonicalizeAxisId);\n const parentIdxs = parentsIds.map((id) => idsList.indexOf(id));\n const { parentAxesSpec: _, ...copiedRest } = axisSpec;\n if (parentIdxs.length) {\n return { ...copiedRest, parentAxes: parentIdxs } as AxisSpec;\n }\n return copiedRest;\n });\n}\n\n/**\n * Resolve annotation-based parents (`pl7.app/parents`) to numeric `parentAxes`\n * on a column spec. Returns the spec unchanged if all axes already use numeric\n * indices or have no parent annotations.\n */\nexport function resolveAnnotationParents(spec: PColumnSpec): PColumnSpec {\n const hasAnnotationParents = spec.axesSpec.some(\n (axis) => !!readAnnotationJson(axis, Annotation.Parents),\n );\n if (!hasAnnotationParents) return spec;\n\n const normalized = getNormalizedAxesList(spec.axesSpec);\n const denormalized = getDenormalizedAxesList(normalized);\n return { ...spec, axesSpec: denormalized };\n}\n\n/** Common type representing spec for all the axes in a column */\nexport type AxesSpec = AxisSpec[];\n\n/// Well-known column names\nexport const PColumnName = {\n Label: \"pl7.app/label\",\n Table: {\n RowSelection: \"pl7.app/table/row-selection\",\n },\n VDJ: {\n LeadSelection: \"pl7.app/vdj/lead-selection\",\n RankingOrder: \"pl7.app/vdj/ranking-order\",\n Sequence: \"pl7.app/vdj/sequence\",\n },\n} as const;\n\n/// Well-known axis names\nexport const PAxisName = {\n SampleId: \"pl7.app/sampleId\",\n VDJ: {\n Assay: {\n SequenceId: \"pl7.app/vdj/assay/sequenceId\",\n },\n ClusterId: \"pl7.app/vdj/clusterId\",\n ClonotypeKey: \"pl7.app/vdj/clonotypeKey\",\n ScClonotypeKey: \"pl7.app/vdj/scClonotypeKey\",\n },\n} as const;\n\nexport function isLabelColumn(column: PColumnSpec) {\n return column.axesSpec.length === 1 && column.name === PColumnName.Label;\n}\n\n/**\n * Full column specification including all axes specs and specs of the column\n * itself.\n *\n * A PColumn in its essence represents a mapping from a fixed size, explicitly\n * typed tuple to an explicitly typed value.\n *\n * (axis1Value1, axis2Value1, ...) -> columnValue\n *\n * Each element in tuple correspond to the axis having the same index in axesSpec.\n */\nexport type PUniversalColumnSpec = PObjectSpec & {\n /** Defines specific type of BObject, the most generic type of unit of\n * information in Platforma Project. */\n readonly kind: \"PColumn\";\n\n /** Type of column values */\n readonly valueType: string;\n\n /** Column name */\n readonly name: string;\n\n /** Adds auxiliary information to the axis name, type and parents to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n\n /** Context domain provides additional column identity that is matched\n * by kinship rules (subset/superset/overlap) rather than exact equality */\n readonly contextDomain?: Record<string, string>;\n\n /** Any additional information attached to the column that does not affect its\n * identifier */\n readonly annotations?: Record<string, string>;\n\n /** A list of zero-based indices of parent axes from the {@link axesSpec} array. */\n readonly parentAxes?: number[];\n\n /** Axes specifications */\n readonly axesSpec: AxesSpec;\n};\n\n/**\n * Specification of a data column.\n *\n * Data column is a specialized type of PColumn that stores only simple values (strings and numbers)\n * addressed by multiple keys. This is in contrast to other PColumn variants that can store more complex\n * values like files or other abstract data types. Data columns are optimized for storing and processing\n * basic tabular data.\n */\nexport type PDataColumnSpec = PUniversalColumnSpec & {\n /** Type of column values */\n readonly valueType: ValueType;\n};\n\n// @todo: change this to PUniversalColumnSpec\nexport type PColumnSpec = PDataColumnSpec;\n\n/** Unique PColumnSpec identifier */\nexport type PColumnSpecId = {\n /** Defines specific type of BObject, the most generic type of unit of\n * information in Platforma Project. */\n readonly kind: \"PColumn\";\n\n /** Type of column values */\n readonly valueType: ValueType;\n\n /** Column name */\n readonly name: string;\n\n /** Adds auxiliary information to the axis name, type and parents to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n\n /** Context domain provides additional column identity that is matched\n * by kinship rules (subset/superset/overlap) rather than exact equality */\n readonly contextDomain?: Record<string, string>;\n\n /** A list of zero-based indices of parent axes from the {@link axesSpec} array. */\n readonly parentAxes?: number[];\n\n /** Axes id */\n readonly axesId: AxesId;\n};\n\nexport function getPColumnSpecId(spec: PColumnSpec): PColumnSpecId {\n return {\n kind: spec.kind,\n valueType: spec.valueType,\n name: spec.name,\n domain: spec.domain,\n contextDomain: spec.contextDomain,\n parentAxes: spec.parentAxes,\n axesId: getAxesId(spec.axesSpec),\n };\n}\n\nexport interface PColumn<Data> extends PObject<Data> {\n /** PColumn spec, allowing it to be found among other PObjects */\n readonly spec: PColumnSpec;\n}\n\n/** Columns in a PFrame also have internal identifier, this object represents\n * combination of specs and such id */\nexport interface PColumnIdAndSpec {\n /** Internal column id within the PFrame */\n readonly columnId: PObjectId;\n\n /** Column spec */\n readonly spec: PColumnSpec;\n}\n\n/** Get column id and spec from a column */\nexport function getColumnIdAndSpec<Data>(column: PColumn<Data>): PColumnIdAndSpec {\n return {\n columnId: column.id,\n spec: column.spec,\n };\n}\n\nexport interface AxisId {\n /** Type of the axis or column value. For an axis should not use non-key\n * types like float or double. */\n readonly type: AxisValueType;\n\n /** Name of the axis or column */\n readonly name: string;\n\n /** Adds auxiliary information to the axis or column name and type to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n\n /** Context domain provides additional axis identity that is matched\n * by kinship rules (subset/superset/overlap) rather than exact equality */\n readonly contextDomain?: Record<string, string>;\n}\n\n/** Array of axis ids */\nexport type AxesId = AxisId[];\n\n/** Extracts axis ids from axis spec */\nexport function getAxisId(spec: AxisSpec): AxisId {\n const { type, name, domain, contextDomain } = spec;\n const result: AxisId = { type, name };\n if (domain && Object.entries(domain).length > 0) {\n Object.assign(result, { domain });\n }\n if (contextDomain && Object.entries(contextDomain).length > 0) {\n Object.assign(result, { contextDomain });\n }\n return result;\n}\n\n/** Extracts axes ids from axes spec array from column spec */\nexport function getAxesId(spec: AxesSpec): AxesId {\n return spec.map(getAxisId);\n}\n\n/** Canonicalizes axis id */\nexport function canonicalizeAxisId(id: AxisId): CanonicalizedJson<AxisId> {\n return canonicalizeJson(getAxisId(id));\n}\n\n/** Returns true if all domains from query are found in target */\nfunction matchDomain(query?: Record<string, string>, target?: Record<string, string>) {\n if (query === undefined) return target === undefined;\n if (target === undefined) return true;\n for (const k in target) {\n if (query[k] !== target[k]) return false;\n }\n return true;\n}\n\n/** Returns whether \"match\" axis id is compatible with the \"query\" */\nexport function matchAxisId(query: AxisId, target: AxisId): boolean {\n return (\n query.name === target.name &&\n matchDomain(query.domain, target.domain) &&\n matchDomain(query.contextDomain, target.contextDomain)\n );\n}\n\nexport function getTypeFromPColumnOrAxisSpec(spec: PColumnSpec | AxisSpec): ValueType {\n return \"valueType\" in spec ? spec.valueType : spec.type;\n}\n\nexport function isAxisId(id: unknown): id is AxisId {\n return typeof id === \"object\" && id !== null && \"name\" in id && \"type\" in id;\n}\n"],"mappings":";;;;AAKA,MAAa,YAAY;CACvB,KAAK;CACL,MAAM;CACN,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,OAAO;AACT;AAUA,SAAgB,aACd,UACA,KACkB;CAClB,OAAQ,WAA6B;AACvC;AASA,SAAgB,wBACd,UACA,cACA,KACA,oBAA4B,2BACa;CACzC,MAAM,OAAO,aAAmB,UAAU,GAAG;CAC7C,IAAI,SAAS,KAAA,GAAW,OAAO,KAAA;CAE/B,MAAM,SAAS,aAAa;CAC5B,IAAI;EACF,MAAM,QAAQ,KAAK,MAAM,IAAI;EAC7B,OAAO,OAAO,MAAM,KAAK;CAC3B,SAAS,OAAgB;EACvB,MAAM,IAAI,MACR,GAAG,kBAAkB,gBACX,OAAO,GAAG,EAAE,WACV,KAAK,WACLA,eAAAA,YAAY,KAAK,GAC/B;CACF;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ACjC,KAAK,MAAM,KAAK,QACd,IAAI,MAAM,OAAO,OAAO,IAAI,OAAO;CAErC,OAAO;AACT;;AAGA,SAAgB,YAAY,OAAe,QAAyB;CAClE,OACE,MAAM,SAAS,OAAO,QACtB,YAAY,MAAM,QAAQ,OAAO,MAAM,KACvC,YAAY,MAAM,eAAe,OAAO,aAAa;AAEzD;AAEA,SAAgB,6BAA6B,MAAyC;CACpF,OAAO,eAAe,OAAO,KAAK,YAAY,KAAK;AACrD;AAEA,SAAgB,SAAS,IAA2B;CAClD,OAAO,OAAO,OAAO,YAAY,OAAO,QAAQ,UAAU,MAAM,UAAU;AAC5E"}
|
|
1
|
+
{"version":3,"file":"spec.cjs","names":["ensureError","z","canonicalizeJson"],"sources":["../../../../src/drivers/pframe/spec/spec.ts"],"sourcesContent":["import { ensureError } from \"../../../errors\";\nimport { canonicalizeJson, type CanonicalizedJson, type StringifiedJson } from \"../../../json\";\nimport type { PObject, PObjectId, PObjectSpec } from \"../../../pool\";\nimport { z } from \"zod\";\n\nexport const ValueType = {\n Int: \"Int\",\n Long: \"Long\",\n Float: \"Float\",\n Double: \"Double\",\n String: \"String\",\n Bytes: \"Bytes\",\n} as const;\n\nexport type AxisValueType = Extract<ValueType, \"Int\" | \"Long\" | \"String\">;\nexport type ColumnValueType = ValueType;\n\n/** PFrame columns and axes within them may store one of these types. */\nexport type ValueType = (typeof ValueType)[keyof typeof ValueType];\n\nexport type Metadata = Record<string, string>;\n\nexport function readMetadata<U extends Metadata, T extends keyof U = keyof U>(\n metadata: Metadata | undefined,\n key: T,\n): U[T] | undefined {\n return (metadata as U | undefined)?.[key];\n}\n\ntype MetadataJsonImpl<M> = {\n [P in keyof M as M[P] extends StringifiedJson ? P : never]: M[P] extends StringifiedJson<infer U>\n ? z.ZodType<U>\n : never;\n};\nexport type MetadataJson<M> = MetadataJsonImpl<Required<M>>;\n\nexport function readMetadataJsonOrThrow<M extends Metadata, T extends keyof MetadataJson<M>>(\n metadata: Metadata | undefined,\n metadataJson: MetadataJson<M>,\n key: T,\n methodNameInError: string = \"readMetadataJsonOrThrow\",\n): z.infer<MetadataJson<M>[T]> | undefined {\n const json = readMetadata<M, T>(metadata, key);\n if (json === undefined) return undefined;\n\n const schema = metadataJson[key];\n try {\n const value = JSON.parse(json);\n return schema.parse(value);\n } catch (error: unknown) {\n throw new Error(\n `${methodNameInError} failed, ` +\n `key: ${String(key)}, ` +\n `value: ${json}, ` +\n `error: ${ensureError(error)}`,\n );\n }\n}\n\nexport function readMetadataJson<M extends Metadata, T extends keyof MetadataJson<M>>(\n metadata: Metadata | undefined,\n metadataJson: MetadataJson<M>,\n key: T,\n): z.infer<MetadataJson<M>[T]> | undefined {\n try {\n return readMetadataJsonOrThrow(metadata, metadataJson, key);\n } catch {\n return undefined; // treat invalid values as unset\n }\n}\n\n/// Well-known domains\nexport const Domain = {\n Alphabet: \"pl7.app/alphabet\",\n BlockId: \"pl7.app/blockId\",\n VDJ: {\n Clustering: {\n BlockId: \"pl7.app/vdj/clustering/blockId\",\n },\n ScClonotypeChain: {\n Index: \"pl7.app/vdj/scClonotypeChain/index\",\n },\n },\n} as const;\n\n/**\n * Domain keys whose value is the id of a block, rather than a qualifier of the data.\n *\n * Applying a template repoints these at the blocks of the project being built: an axis a block\n * produced names that block in its domain, so an axis left naming the exported-from project\n * resolves to nothing. Listing the keys is what makes that safe — a template's entry ids are\n * arbitrary non-empty strings, so a hand-written template may name an entry `closest`, and a\n * qualifier that happens to read `closest` must not be mistaken for a reference to it.\n *\n * A key absent from here is simply left alone, which is the behaviour from before relocation\n * reached domains at all. Adding one is therefore safe; omitting one costs only that a template\n * carrying it applies still pointing at the project it came from.\n */\nexport const BlockScopedDomain: ReadonlySet<string> = new Set<string>([\n \"pl7.app/blockId\",\n \"pl7.app/block\",\n \"pl7.app/redefined-by\",\n \"pl7.app/annotationRunId\",\n \"pl7.app/clonotypeAnnotationRunId\",\n \"pl7.app/clustering/blockId\",\n \"pl7.app/umap/blockId\",\n \"pl7.app/peptide/extractionRunId\",\n \"pl7.app/repertoire/extractionRunId\",\n \"pl7.app/antibodyVariantDesigner/designRunId\",\n \"pl7.app/vdj/clonotypingRunId\",\n \"pl7.app/vdj/clustering/blockId\",\n \"pl7.app/vdj/integration/blockId\",\n \"pl7.app/vdj/spatiotemporalAnalysis/blockId\",\n \"pl7.app/vdj/libraryId\",\n]);\n\nexport type Domain = Metadata &\n Partial<{\n [Domain.Alphabet]: \"nucleotide\" | \"aminoacid\" | (string & {});\n [Domain.BlockId]: string;\n [Domain.VDJ.ScClonotypeChain.Index]: \"primary\" | \"secondary\" | (string & {});\n }>;\n\nexport type DomainJson = MetadataJson<Domain>;\nexport const DomainJson: DomainJson = {};\n\n/// Helper function for reading plain domain values\nexport function readDomain<T extends keyof Domain>(\n spec: { domain?: Metadata | undefined } | undefined,\n key: T,\n): Domain[T] | undefined {\n return readMetadata<Domain, T>(spec?.domain, key);\n}\n\n/// Helper function for reading json-encoded domain values, throws on JSON parsing error\nexport function readDomainJsonOrThrow<T extends keyof DomainJson>(\n spec: { domain?: Metadata | undefined } | undefined,\n key: T,\n): z.infer<DomainJson[T]> | undefined {\n return readMetadataJsonOrThrow<Domain, T>(spec?.domain, DomainJson, key, \"readDomainJsonOrThrow\");\n}\n\n/// Helper function for reading json-encoded domain values, returns undefined on JSON parsing error\nexport function readDomainJson<T extends keyof DomainJson>(\n spec: { domain?: Metadata | undefined } | undefined,\n key: T,\n): z.infer<DomainJson[T]> | undefined {\n return readMetadataJson<Domain, T>(spec?.domain, DomainJson, key);\n}\n\n/// Well-known annotations\nexport const Annotation = {\n AxisNature: \"pl7.app/axisNature\",\n Alphabet: \"pl7.app/alphabet\",\n Description: \"pl7.app/description\",\n DataStatus: \"pl7.app/dataStatus\",\n DiscreteValues: \"pl7.app/discreteValues\",\n Format: \"pl7.app/format\",\n Graph: {\n Axis: {\n HighCardinality: \"pl7.app/graph/axis/highCardinality\",\n LowerLimit: \"pl7.app/graph/axis/lowerLimit\",\n SymmetricRange: \"pl7.app/graph/axis/symmetricRange\",\n UpperLimit: \"pl7.app/graph/axis/upperLimit\",\n },\n IsDenseAxis: \"pl7.app/graph/isDenseAxis\",\n IsVirtual: \"pl7.app/graph/isVirtual\",\n Palette: \"pl7.app/graph/palette\",\n Thresholds: \"pl7.app/graph/thresholds\",\n TreatAbsentValuesAs: \"pl7.app/graph/treatAbsentValuesAs\",\n },\n HideDataFromUi: \"pl7.app/hideDataFromUi\",\n HideDataFromGraphs: \"pl7.app/hideDataFromGraphs\",\n IsDiscreteFilter: \"pl7.app/isDiscreteFilter\",\n IsAnchor: \"pl7.app/isAnchor\",\n IsLinkerColumn: \"pl7.app/isLinkerColumn\",\n IsScore: \"pl7.app/isScore\",\n IsSubset: \"pl7.app/isSubset\",\n Label: \"pl7.app/label\",\n LinkLabel: \"pl7.app/linkLabel\",\n Max: \"pl7.app/max\",\n Min: \"pl7.app/min\",\n MultipliesBy: \"pl7.app/multipliesBy\",\n Parents: \"pl7.app/parents\",\n Score: {\n DefaultCutoff: \"pl7.app/score/defaultCutoff\",\n RankingOrder: \"pl7.app/score/rankingOrder\",\n },\n Sequence: {\n Annotation: {\n Mapping: \"pl7.app/sequence/annotation/mapping\",\n },\n IsAnnotation: \"pl7.app/sequence/isAnnotation\",\n },\n Table: {\n FontFamily: \"pl7.app/table/fontFamily\",\n OrderPriority: \"pl7.app/table/orderPriority\",\n Visibility: \"pl7.app/table/visibility\",\n Info: \"pl7.app/table/info\",\n },\n Trace: \"pl7.app/trace\",\n VDJ: {\n IsAssemblingFeature: \"pl7.app/vdj/isAssemblingFeature\",\n IsMainSequence: \"pl7.app/vdj/isMainSequence\",\n },\n} as const;\n\nexport type AnnotationDataStatus =\n | \"missing\"\n | \"resolving\"\n | \"absent\"\n | \"computing\"\n | \"ready\"\n | \"error\";\n\nexport type Annotation = Metadata &\n Partial<{\n [Annotation.Alphabet]: \"nucleotide\" | \"aminoacid\" | (string & {});\n [Annotation.AxisNature]: \"homogeneous\" | \"heterogeneous\" | \"scaleCompatible\" | (string & {});\n [Annotation.Description]: string;\n [Annotation.DataStatus]: AnnotationDataStatus;\n [Annotation.DiscreteValues]: StringifiedJson<number[]> | StringifiedJson<string[]>;\n [Annotation.Format]: string;\n [Annotation.Graph.Axis.HighCardinality]: StringifiedJson<boolean>;\n [Annotation.Graph.Axis.LowerLimit]: StringifiedJson<number>;\n [Annotation.Graph.Axis.SymmetricRange]: StringifiedJson<boolean>;\n [Annotation.Graph.Axis.UpperLimit]: StringifiedJson<number>;\n [Annotation.Graph.IsDenseAxis]: StringifiedJson<boolean>;\n [Annotation.Graph.IsVirtual]: StringifiedJson<boolean>;\n [Annotation.Graph.Palette]: StringifiedJson<{ mapping: Record<string, number>; name: string }>;\n [Annotation.Graph.Thresholds]: StringifiedJson<\n { columnId: { valueType: ValueType; name: string }; value: number }[]\n >;\n [Annotation.Graph.TreatAbsentValuesAs]: StringifiedJson<number>;\n [Annotation.HideDataFromGraphs]: StringifiedJson<boolean>;\n [Annotation.HideDataFromUi]: StringifiedJson<boolean>;\n [Annotation.IsDiscreteFilter]: StringifiedJson<boolean>;\n [Annotation.IsLinkerColumn]: StringifiedJson<boolean>;\n [Annotation.IsSubset]: StringifiedJson<boolean>;\n [Annotation.Label]: string;\n [Annotation.Max]: StringifiedJson<number>;\n [Annotation.Min]: StringifiedJson<number>;\n [Annotation.MultipliesBy]: StringifiedJson<AxisSpec[\"name\"][]>;\n [Annotation.Parents]: StringifiedJson<AxisSpec[\"name\"][]>;\n [Annotation.Sequence.Annotation.Mapping]: StringifiedJson<Record<string, string>>;\n [Annotation.Sequence.IsAnnotation]: StringifiedJson<boolean>;\n [Annotation.Table.FontFamily]: string;\n [Annotation.Table.OrderPriority]: StringifiedJson<number>;\n [Annotation.Table.Visibility]: \"hidden\" | \"optional\" | (string & {});\n [Annotation.Table.Info]: string;\n [Annotation.Trace]: StringifiedJson<Trace>;\n [Annotation.VDJ.IsAssemblingFeature]: StringifiedJson<boolean>;\n }>;\n\n/// One step in a column's derivation lineage. Only `type` and `label` are part\n/// of the typed public surface; writers may add fields (e.g. `id`, `importance`)\n/// passed through opaquely as `unknown`, accessed via explicit narrowing.\nconst TraceEntrySchema = z\n .object({\n type: z.string(),\n label: z.string(),\n })\n .catchall(z.unknown());\n\nexport type TraceEntry = z.infer<typeof TraceEntrySchema>;\n\nexport type Trace = TraceEntry[];\n\n// export const AxisSpec = z.object({\n// type: z.nativeEnum(ValueType),\n// name: z.string(),\n// domain: z.record(z.string(), z.string()).optional(),\n// annotations: z.record(z.string(), z.string()).optional(),\n// parentAxes: z.array(z.number()).optional(),\n// }).passthrough();\n//\n// type Expect<T extends true> = T;\n// type Equal<X, Y> =\n// (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;\n//\n// type _test = Expect<Equal<\n// Readonly<z.infer<typeof AxisSpec>>,\n// Readonly<AxisSpec & Record<string, unknown>>\n// >>;\n\nexport type AnnotationJson = MetadataJson<Annotation>;\n\nconst ValueTypeSchema = z.enum([\"Int\", \"Long\", \"Float\", \"Double\", \"String\"] as const);\nexport const AnnotationJson: AnnotationJson = {\n [Annotation.DiscreteValues]: z.array(z.string()).or(z.array(z.number())),\n [Annotation.Graph.Axis.HighCardinality]: z.boolean(),\n [Annotation.Graph.Axis.LowerLimit]: z.number(),\n [Annotation.Graph.Axis.UpperLimit]: z.number(),\n [Annotation.Graph.Axis.SymmetricRange]: z.boolean(),\n [Annotation.Graph.IsDenseAxis]: z.boolean(),\n [Annotation.Graph.Palette]: z.object({ mapping: z.record(z.number()), name: z.string() }),\n [Annotation.Graph.Thresholds]: z.array(\n z.object({\n columnId: z.object({ valueType: ValueTypeSchema, name: z.string() }),\n value: z.number(),\n }),\n ),\n [Annotation.Graph.TreatAbsentValuesAs]: z.number(),\n [Annotation.Graph.IsVirtual]: z.boolean(),\n [Annotation.HideDataFromUi]: z.boolean(),\n [Annotation.HideDataFromGraphs]: z.boolean(),\n [Annotation.IsDiscreteFilter]: z.boolean(),\n [Annotation.IsLinkerColumn]: z.boolean(),\n [Annotation.IsSubset]: z.boolean(),\n [Annotation.Max]: z.number(),\n [Annotation.Min]: z.number(),\n [Annotation.MultipliesBy]: z.array(z.string()),\n [Annotation.Parents]: z.array(z.string()),\n [Annotation.Sequence.Annotation.Mapping]: z.record(z.string(), z.string()),\n [Annotation.Sequence.IsAnnotation]: z.boolean(),\n [Annotation.Table.OrderPriority]: z.number(),\n [Annotation.Trace]: z.array(TraceEntrySchema),\n [Annotation.VDJ.IsAssemblingFeature]: z.boolean(),\n};\n\n/// Helper function for reading plain annotation values\nexport function readAnnotation<T extends keyof Annotation>(\n spec: { annotations?: Metadata | undefined } | undefined,\n key: T,\n): Annotation[T] | undefined {\n return readMetadata<Annotation, T>(spec?.annotations, key);\n}\n\n/// Helper function for reading json-encoded annotation values, throws on JSON parsing error\nexport function readAnnotationJsonOrThrow<T extends keyof AnnotationJson>(\n spec: { annotations?: Metadata | undefined } | undefined,\n key: T,\n): z.infer<AnnotationJson[T]> | undefined {\n return readMetadataJsonOrThrow<Annotation, T>(\n spec?.annotations,\n AnnotationJson,\n key,\n \"readAnnotationJsonOrThrow\",\n );\n}\n\n/// Helper function for reading json-encoded annotation values, returns undefined on JSON parsing error\nexport function readAnnotationJson<T extends keyof AnnotationJson>(\n spec: { annotations?: Metadata | undefined } | undefined,\n key: T,\n): z.infer<AnnotationJson[T]> | undefined {\n return readMetadataJson<Annotation, T>(spec?.annotations, AnnotationJson, key);\n}\n\nexport function isLinkerColumn(column: PColumnSpec): boolean {\n return !!readAnnotationJson(column, Annotation.IsLinkerColumn);\n}\n\n/**\n * Specification of an individual axis.\n *\n * Each axis is a part of a composite key that addresses data inside the PColumn.\n *\n * Each record inside a PColumn is addressed by a unique tuple of values set for\n * all the axes specified in the column spec.\n */\nexport type AxisSpec = {\n /** Type of the axis value. Should not use non-key types like float or double. */\n readonly type: AxisValueType;\n\n /** Name of the axis */\n readonly name: string;\n\n /** Adds auxiliary information to the axis name, type and parents to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n\n /** Context domain provides additional axis identity that is matched\n * by kinship rules (subset/superset/overlap) rather than exact equality */\n readonly contextDomain?: Record<string, string>;\n\n /** Any additional information attached to the axis that does not affect its\n * identifier */\n readonly annotations?: Record<string, string>;\n\n /**\n * Parent axes provide contextual grouping for the axis in question, establishing\n * a hierarchy where the current axis is dependent on one or more axes for its\n * full definition and meaning. For instance, in a data structure where each\n * \"container\" axis may contain multiple \"item\" axes, the `item` axis would\n * list the index of the `container` axis in this field to denote its dependency.\n *\n * This means that the identity or significance of the `item` axis is only\n * interpretable when combined with its parent `container` axis. An `item` axis\n * index by itself may be non-unique and only gains uniqueness within the context\n * of its parent `container`. Therefore, the `parentAxes` field is essential for\n * mapping these relationships and ensuring data coherence across nested or\n * multi-level data models.\n *\n * A list of zero-based indices of parent axes in the overall axes specification\n * from the column spec. Each index corresponds to the position of a parent axis\n * in the list that defines the structure of the data model.\n */\n readonly parentAxes?: number[];\n};\n\n/** Parents are specs, not indexes; normalized axis can be used considering its parents independently from column */\nexport interface AxisSpecNormalized extends Omit<AxisSpec, \"parentAxes\"> {\n parentAxesSpec: AxisSpecNormalized[];\n}\n\n/** Tree: axis is a root, its parents are children */\nexport type AxisTree = {\n axis: AxisSpecNormalized;\n children: AxisTree[]; // parents\n};\n\nfunction makeAxisTree(axis: AxisSpecNormalized): AxisTree {\n return { axis, children: [] };\n}\n\n/** Build tree by axis parents annotations */\nexport function getAxesTree(rootAxis: AxisSpecNormalized): AxisTree {\n const root = makeAxisTree(rootAxis);\n let nodesQ = [root];\n while (nodesQ.length) {\n const nextNodes: AxisTree[] = [];\n for (const node of nodesQ) {\n node.children = node.axis.parentAxesSpec.map(makeAxisTree);\n nextNodes.push(...node.children);\n }\n nodesQ = nextNodes;\n }\n return root;\n}\n\n/** Get set of canonicalized axisIds from axisTree */\nexport function getSetFromAxisTree(tree: AxisTree): Set<CanonicalizedJson<AxisId>> {\n const set = new Set([canonicalizeJson(getAxisId(tree.axis))]);\n let nodesQ = [tree];\n while (nodesQ.length) {\n const nextNodes = [];\n for (const node of nodesQ) {\n for (const parent of node.children) {\n set.add(canonicalizeJson(getAxisId(parent.axis)));\n nextNodes.push(parent);\n }\n }\n nodesQ = nextNodes;\n }\n return set;\n}\n\n/** Get array of axisSpecs from axisTree */\nexport function getArrayFromAxisTree(tree: AxisTree): AxisSpecNormalized[] {\n const res = [tree.axis];\n let nodesQ = [tree];\n while (nodesQ.length) {\n const nextNodes = [];\n for (const node of nodesQ) {\n for (const parent of node.children) {\n res.push(parent.axis);\n nextNodes.push(parent);\n }\n }\n nodesQ = nextNodes;\n }\n return res;\n}\n\nexport function canonicalizeAxisWithParents(axis: AxisSpecNormalized) {\n return canonicalizeJson(getArrayFromAxisTree(getAxesTree(axis)).map(getAxisId));\n}\n\nfunction normalizingAxesComparator(\n axis1: AxisSpecNormalized,\n axis2: AxisSpecNormalized,\n): 1 | -1 | 0 {\n if (axis1.name !== axis2.name) {\n return axis1.name < axis2.name ? 1 : -1;\n }\n if (axis1.type !== axis2.type) {\n return axis1.type < axis2.type ? 1 : -1;\n }\n const domain1 = canonicalizeJson(axis1.domain ?? {});\n const domain2 = canonicalizeJson(axis2.domain ?? {});\n if (domain1 !== domain2) {\n return domain1 < domain2 ? 1 : -1;\n }\n\n const contextDomain1 = canonicalizeJson(axis1.contextDomain ?? {});\n const contextDomain2 = canonicalizeJson(axis2.contextDomain ?? {});\n if (contextDomain1 !== contextDomain2) {\n return contextDomain1 < contextDomain2 ? 1 : -1;\n }\n\n const parents1 = canonicalizeAxisWithParents(axis1);\n const parents2 = canonicalizeAxisWithParents(axis2);\n\n if (parents1 !== parents2) {\n return parents1 < parents2 ? 1 : -1;\n }\n\n const annotation1 = canonicalizeJson(axis1.annotations ?? {});\n const annotation2 = canonicalizeJson(axis2.annotations ?? {});\n if (annotation1 !== annotation2) {\n return annotation1 < annotation2 ? 1 : -1;\n }\n return 0;\n}\n\nfunction parseParentsFromAnnotations(axis: AxisSpec) {\n const parentsList = readAnnotationJson(axis, Annotation.Parents);\n if (parentsList === undefined) {\n return [];\n }\n return parentsList;\n}\n\nfunction sortParentsDeep(axisSpec: AxisSpecNormalized) {\n axisSpec.parentAxesSpec.forEach(sortParentsDeep);\n axisSpec.parentAxesSpec.sort(normalizingAxesComparator);\n}\n\nfunction hasCycleOfParents(axisSpec: AxisSpecNormalized) {\n const root = makeAxisTree(axisSpec);\n let nodesQ = [root];\n const ancestors = new Set(canonicalizeJson(getAxisId(axisSpec)));\n while (nodesQ.length) {\n const nextNodes: AxisTree[] = [];\n const levelIds = new Set<CanonicalizedJson<AxisId>>();\n for (const node of nodesQ) {\n node.children = node.axis.parentAxesSpec.map(makeAxisTree);\n for (const child of node.children) {\n const childId = canonicalizeJson(getAxisId(child.axis));\n if (!levelIds.has(childId)) {\n nextNodes.push(child);\n levelIds.add(childId);\n if (ancestors.has(childId)) {\n return true;\n }\n ancestors.add(childId);\n }\n }\n }\n nodesQ = nextNodes;\n }\n return false;\n}\n\n/** Create list of normalized axisSpec (parents are in array of specs, not indexes) */\nexport function getNormalizedAxesList(axes: AxisSpec[]): AxisSpecNormalized[] {\n if (axes.length === 0) {\n return [];\n }\n const modifiedAxes: AxisSpecNormalized[] = axes.map((axis) => {\n const { parentAxes: _, ...copiedRest } = axis;\n return { ...copiedRest, annotations: { ...copiedRest.annotations }, parentAxesSpec: [] };\n });\n\n axes.forEach((axis, idx) => {\n const modifiedAxis = modifiedAxes[idx];\n if (axis.parentAxes) {\n // if we have parents by indexes then take from the list\n modifiedAxis.parentAxesSpec = axis.parentAxes.map((idx) => modifiedAxes[idx]);\n } else {\n // else try to parse from annotation name\n const parents = parseParentsFromAnnotations(axis).map((name) =>\n modifiedAxes.find((axis) => axis.name === name),\n );\n modifiedAxis.parentAxesSpec = parents.some((p) => p === undefined)\n ? []\n : (parents as AxisSpecNormalized[]);\n }\n });\n\n if (modifiedAxes.some(hasCycleOfParents)) {\n // Axes list is broken\n modifiedAxes.forEach((axis) => {\n axis.parentAxesSpec = [];\n });\n } else {\n modifiedAxes.forEach((axis) => {\n sortParentsDeep(axis);\n });\n }\n\n return modifiedAxes;\n}\n\n/** Create list of regular axisSpec from normalized (parents are indexes, inside of current axes list) */\nexport function getDenormalizedAxesList(axesSpec: AxisSpecNormalized[]): AxisSpec[] {\n const idsList = axesSpec.map(canonicalizeAxisId);\n return axesSpec.map((axisSpec) => {\n const parentsIds = axisSpec.parentAxesSpec.map(canonicalizeAxisId);\n const parentIdxs = parentsIds.map((id) => idsList.indexOf(id));\n const { parentAxesSpec: _, ...copiedRest } = axisSpec;\n if (parentIdxs.length) {\n return { ...copiedRest, parentAxes: parentIdxs } as AxisSpec;\n }\n return copiedRest;\n });\n}\n\n/**\n * Resolve annotation-based parents (`pl7.app/parents`) to numeric `parentAxes`\n * on a column spec. Returns the spec unchanged if all axes already use numeric\n * indices or have no parent annotations.\n */\nexport function resolveAnnotationParents(spec: PColumnSpec): PColumnSpec {\n const hasAnnotationParents = spec.axesSpec.some(\n (axis) => !!readAnnotationJson(axis, Annotation.Parents),\n );\n if (!hasAnnotationParents) return spec;\n\n const normalized = getNormalizedAxesList(spec.axesSpec);\n const denormalized = getDenormalizedAxesList(normalized);\n return { ...spec, axesSpec: denormalized };\n}\n\n/** Common type representing spec for all the axes in a column */\nexport type AxesSpec = AxisSpec[];\n\n/// Well-known column names\nexport const PColumnName = {\n Label: \"pl7.app/label\",\n Table: {\n RowSelection: \"pl7.app/table/row-selection\",\n },\n VDJ: {\n LeadSelection: \"pl7.app/vdj/lead-selection\",\n RankingOrder: \"pl7.app/vdj/ranking-order\",\n Sequence: \"pl7.app/vdj/sequence\",\n },\n} as const;\n\n/// Well-known axis names\nexport const PAxisName = {\n SampleId: \"pl7.app/sampleId\",\n VDJ: {\n Assay: {\n SequenceId: \"pl7.app/vdj/assay/sequenceId\",\n },\n ClusterId: \"pl7.app/vdj/clusterId\",\n ClonotypeKey: \"pl7.app/vdj/clonotypeKey\",\n ScClonotypeKey: \"pl7.app/vdj/scClonotypeKey\",\n },\n} as const;\n\nexport function isLabelColumn(column: PColumnSpec) {\n return column.axesSpec.length === 1 && column.name === PColumnName.Label;\n}\n\n/**\n * Full column specification including all axes specs and specs of the column\n * itself.\n *\n * A PColumn in its essence represents a mapping from a fixed size, explicitly\n * typed tuple to an explicitly typed value.\n *\n * (axis1Value1, axis2Value1, ...) -> columnValue\n *\n * Each element in tuple correspond to the axis having the same index in axesSpec.\n */\nexport type PUniversalColumnSpec = PObjectSpec & {\n /** Defines specific type of BObject, the most generic type of unit of\n * information in Platforma Project. */\n readonly kind: \"PColumn\";\n\n /** Type of column values */\n readonly valueType: string;\n\n /** Column name */\n readonly name: string;\n\n /** Adds auxiliary information to the axis name, type and parents to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n\n /** Context domain provides additional column identity that is matched\n * by kinship rules (subset/superset/overlap) rather than exact equality */\n readonly contextDomain?: Record<string, string>;\n\n /** Any additional information attached to the column that does not affect its\n * identifier */\n readonly annotations?: Record<string, string>;\n\n /** A list of zero-based indices of parent axes from the {@link axesSpec} array. */\n readonly parentAxes?: number[];\n\n /** Axes specifications */\n readonly axesSpec: AxesSpec;\n};\n\n/**\n * Specification of a data column.\n *\n * Data column is a specialized type of PColumn that stores only simple values (strings and numbers)\n * addressed by multiple keys. This is in contrast to other PColumn variants that can store more complex\n * values like files or other abstract data types. Data columns are optimized for storing and processing\n * basic tabular data.\n */\nexport type PDataColumnSpec = PUniversalColumnSpec & {\n /** Type of column values */\n readonly valueType: ValueType;\n};\n\n// @todo: change this to PUniversalColumnSpec\nexport type PColumnSpec = PDataColumnSpec;\n\n/** Unique PColumnSpec identifier */\nexport type PColumnSpecId = {\n /** Defines specific type of BObject, the most generic type of unit of\n * information in Platforma Project. */\n readonly kind: \"PColumn\";\n\n /** Type of column values */\n readonly valueType: ValueType;\n\n /** Column name */\n readonly name: string;\n\n /** Adds auxiliary information to the axis name, type and parents to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n\n /** Context domain provides additional column identity that is matched\n * by kinship rules (subset/superset/overlap) rather than exact equality */\n readonly contextDomain?: Record<string, string>;\n\n /** A list of zero-based indices of parent axes from the {@link axesSpec} array. */\n readonly parentAxes?: number[];\n\n /** Axes id */\n readonly axesId: AxesId;\n};\n\nexport function getPColumnSpecId(spec: PColumnSpec): PColumnSpecId {\n return {\n kind: spec.kind,\n valueType: spec.valueType,\n name: spec.name,\n domain: spec.domain,\n contextDomain: spec.contextDomain,\n parentAxes: spec.parentAxes,\n axesId: getAxesId(spec.axesSpec),\n };\n}\n\nexport interface PColumn<Data> extends PObject<Data> {\n /** PColumn spec, allowing it to be found among other PObjects */\n readonly spec: PColumnSpec;\n}\n\n/** Columns in a PFrame also have internal identifier, this object represents\n * combination of specs and such id */\nexport interface PColumnIdAndSpec {\n /** Internal column id within the PFrame */\n readonly columnId: PObjectId;\n\n /** Column spec */\n readonly spec: PColumnSpec;\n}\n\n/** Get column id and spec from a column */\nexport function getColumnIdAndSpec<Data>(column: PColumn<Data>): PColumnIdAndSpec {\n return {\n columnId: column.id,\n spec: column.spec,\n };\n}\n\nexport interface AxisId {\n /** Type of the axis or column value. For an axis should not use non-key\n * types like float or double. */\n readonly type: AxisValueType;\n\n /** Name of the axis or column */\n readonly name: string;\n\n /** Adds auxiliary information to the axis or column name and type to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n\n /** Context domain provides additional axis identity that is matched\n * by kinship rules (subset/superset/overlap) rather than exact equality */\n readonly contextDomain?: Record<string, string>;\n}\n\n/** Array of axis ids */\nexport type AxesId = AxisId[];\n\n/** Extracts axis ids from axis spec */\nexport function getAxisId(spec: AxisSpec): AxisId {\n const { type, name, domain, contextDomain } = spec;\n const result: AxisId = { type, name };\n if (domain && Object.entries(domain).length > 0) {\n Object.assign(result, { domain });\n }\n if (contextDomain && Object.entries(contextDomain).length > 0) {\n Object.assign(result, { contextDomain });\n }\n return result;\n}\n\n/** Extracts axes ids from axes spec array from column spec */\nexport function getAxesId(spec: AxesSpec): AxesId {\n return spec.map(getAxisId);\n}\n\n/** Canonicalizes axis id */\nexport function canonicalizeAxisId(id: AxisId): CanonicalizedJson<AxisId> {\n return canonicalizeJson(getAxisId(id));\n}\n\n/** Returns true if all domains from query are found in target */\nfunction matchDomain(query?: Record<string, string>, target?: Record<string, string>) {\n if (query === undefined) return target === undefined;\n if (target === undefined) return true;\n for (const k in target) {\n if (query[k] !== target[k]) return false;\n }\n return true;\n}\n\n/** Returns whether \"match\" axis id is compatible with the \"query\" */\nexport function matchAxisId(query: AxisId, target: AxisId): boolean {\n return (\n query.name === target.name &&\n matchDomain(query.domain, target.domain) &&\n matchDomain(query.contextDomain, target.contextDomain)\n );\n}\n\nexport function getTypeFromPColumnOrAxisSpec(spec: PColumnSpec | AxisSpec): ValueType {\n return \"valueType\" in spec ? spec.valueType : spec.type;\n}\n\nexport function isAxisId(id: unknown): id is AxisId {\n return typeof id === \"object\" && id !== null && \"name\" in id && \"type\" in id;\n}\n"],"mappings":";;;;AAKA,MAAa,YAAY;CACvB,KAAK;CACL,MAAM;CACN,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,OAAO;AACT;AAUA,SAAgB,aACd,UACA,KACkB;CAClB,OAAQ,WAA6B;AACvC;AASA,SAAgB,wBACd,UACA,cACA,KACA,oBAA4B,2BACa;CACzC,MAAM,OAAO,aAAmB,UAAU,GAAG;CAC7C,IAAI,SAAS,KAAA,GAAW,OAAO,KAAA;CAE/B,MAAM,SAAS,aAAa;CAC5B,IAAI;EACF,MAAM,QAAQ,KAAK,MAAM,IAAI;EAC7B,OAAO,OAAO,MAAM,KAAK;CAC3B,SAAS,OAAgB;EACvB,MAAM,IAAI,MACR,GAAG,kBAAkB,gBACX,OAAO,GAAG,EAAE,WACV,KAAK,WACLA,eAAAA,YAAY,KAAK,GAC/B;CACF;AACF;AAEA,SAAgB,iBACd,UACA,cACA,KACyC;CACzC,IAAI;EACF,OAAO,wBAAwB,UAAU,cAAc,GAAG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