@milaboratories/pl-model-common 1.19.7 → 1.19.8
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 +0 -1
- package/dist/base32_encode.cjs +56 -0
- package/dist/base32_encode.cjs.map +1 -0
- package/dist/base32_encode.d.ts +0 -1
- package/dist/base32_encode.js +54 -0
- package/dist/base32_encode.js.map +1 -0
- package/dist/block_state.d.ts +0 -1
- package/dist/bmodel/block_config.cjs +15 -0
- package/dist/bmodel/block_config.cjs.map +1 -0
- package/dist/bmodel/block_config.d.ts +0 -1
- package/dist/bmodel/block_config.js +13 -0
- package/dist/bmodel/block_config.js.map +1 -0
- package/dist/bmodel/code.d.ts +0 -1
- package/dist/bmodel/container.d.ts +0 -1
- package/dist/bmodel/index.d.ts +0 -1
- package/dist/bmodel/normalization.cjs +86 -0
- package/dist/bmodel/normalization.cjs.map +1 -0
- package/dist/bmodel/normalization.d.ts +0 -1
- package/dist/bmodel/normalization.js +84 -0
- package/dist/bmodel/normalization.js.map +1 -0
- package/dist/bmodel/types.d.ts +0 -1
- package/dist/branding.d.ts +0 -1
- package/dist/common_types.d.ts +0 -1
- package/dist/driver_kit.d.ts +0 -1
- package/dist/drivers/blob.cjs +27 -0
- package/dist/drivers/blob.cjs.map +1 -0
- package/dist/drivers/blob.d.ts +0 -1
- package/dist/drivers/blob.js +23 -0
- package/dist/drivers/blob.js.map +1 -0
- package/dist/drivers/index.d.ts +0 -1
- package/dist/drivers/interfaces.d.ts +0 -1
- package/dist/drivers/log.cjs +9 -0
- package/dist/drivers/log.cjs.map +1 -0
- package/dist/drivers/log.d.ts +0 -1
- package/dist/drivers/log.js +7 -0
- package/dist/drivers/log.js.map +1 -0
- package/dist/drivers/ls.cjs +39 -0
- package/dist/drivers/ls.cjs.map +1 -0
- package/dist/drivers/ls.d.ts +0 -1
- package/dist/drivers/ls.js +34 -0
- package/dist/drivers/ls.js.map +1 -0
- package/dist/drivers/pframe/column_filter.d.ts +0 -1
- package/dist/drivers/pframe/data_info.cjs +275 -0
- package/dist/drivers/pframe/data_info.cjs.map +1 -0
- package/dist/drivers/pframe/data_info.d.ts +0 -1
- package/dist/drivers/pframe/data_info.js +266 -0
- package/dist/drivers/pframe/data_info.js.map +1 -0
- package/dist/drivers/pframe/data_types.cjs +91 -0
- package/dist/drivers/pframe/data_types.cjs.map +1 -0
- package/dist/drivers/pframe/data_types.d.ts +0 -1
- package/dist/drivers/pframe/data_types.js +83 -0
- package/dist/drivers/pframe/data_types.js.map +1 -0
- package/dist/drivers/pframe/driver.d.ts +0 -1
- package/dist/drivers/pframe/find_columns.d.ts +0 -1
- package/dist/drivers/pframe/index.d.ts +0 -1
- package/dist/drivers/pframe/linker_columns.cjs +218 -0
- package/dist/drivers/pframe/linker_columns.cjs.map +1 -0
- package/dist/drivers/pframe/linker_columns.d.ts +0 -1
- package/dist/drivers/pframe/linker_columns.js +216 -0
- package/dist/drivers/pframe/linker_columns.js.map +1 -0
- package/dist/drivers/pframe/pframe.d.ts +0 -1
- package/dist/drivers/pframe/spec/anchored.cjs +234 -0
- package/dist/drivers/pframe/spec/anchored.cjs.map +1 -0
- package/dist/drivers/pframe/spec/anchored.d.ts +0 -1
- package/dist/drivers/pframe/spec/anchored.js +231 -0
- package/dist/drivers/pframe/spec/anchored.js.map +1 -0
- package/dist/drivers/pframe/spec/filtered_column.cjs +13 -0
- package/dist/drivers/pframe/spec/filtered_column.cjs.map +1 -0
- package/dist/drivers/pframe/spec/filtered_column.d.ts +0 -1
- package/dist/drivers/pframe/spec/filtered_column.js +11 -0
- package/dist/drivers/pframe/spec/filtered_column.js.map +1 -0
- package/dist/drivers/pframe/spec/ids.cjs +24 -0
- package/dist/drivers/pframe/spec/ids.cjs.map +1 -0
- package/dist/drivers/pframe/spec/ids.d.ts +0 -1
- package/dist/drivers/pframe/spec/ids.js +21 -0
- package/dist/drivers/pframe/spec/ids.js.map +1 -0
- package/dist/drivers/pframe/spec/index.d.ts +0 -1
- package/dist/drivers/pframe/spec/native_id.cjs +20 -0
- package/dist/drivers/pframe/spec/native_id.cjs.map +1 -0
- package/dist/drivers/pframe/spec/native_id.d.ts +0 -1
- package/dist/drivers/pframe/spec/native_id.js +18 -0
- package/dist/drivers/pframe/spec/native_id.js.map +1 -0
- package/dist/drivers/pframe/spec/selectors.cjs +120 -0
- package/dist/drivers/pframe/spec/selectors.cjs.map +1 -0
- package/dist/drivers/pframe/spec/selectors.d.ts +0 -1
- package/dist/drivers/pframe/spec/selectors.js +116 -0
- package/dist/drivers/pframe/spec/selectors.js.map +1 -0
- package/dist/drivers/pframe/spec/spec.cjs +361 -0
- package/dist/drivers/pframe/spec/spec.cjs.map +1 -0
- package/dist/drivers/pframe/spec/spec.d.ts +0 -1
- package/dist/drivers/pframe/spec/spec.js +332 -0
- package/dist/drivers/pframe/spec/spec.js.map +1 -0
- package/dist/drivers/pframe/table.d.ts +0 -1
- package/dist/drivers/pframe/table_calculate.cjs +43 -0
- package/dist/drivers/pframe/table_calculate.cjs.map +1 -0
- package/dist/drivers/pframe/table_calculate.d.ts +0 -1
- package/dist/drivers/pframe/table_calculate.js +40 -0
- package/dist/drivers/pframe/table_calculate.js.map +1 -0
- package/dist/drivers/pframe/table_common.cjs +19 -0
- package/dist/drivers/pframe/table_common.cjs.map +1 -0
- package/dist/drivers/pframe/table_common.d.ts +0 -1
- package/dist/drivers/pframe/table_common.js +17 -0
- package/dist/drivers/pframe/table_common.js.map +1 -0
- package/dist/drivers/pframe/type_util.d.ts +0 -1
- package/dist/drivers/pframe/unique_values.d.ts +0 -1
- package/dist/drivers/upload.d.ts +0 -1
- package/dist/drivers/urls.cjs +14 -0
- package/dist/drivers/urls.cjs.map +1 -0
- package/dist/drivers/urls.d.ts +0 -1
- package/dist/drivers/urls.js +11 -0
- package/dist/drivers/urls.js.map +1 -0
- package/dist/errors.cjs +141 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.ts +0 -1
- package/dist/errors.js +121 -0
- package/dist/errors.js.map +1 -0
- package/dist/flags/block_flags.cjs +8 -0
- package/dist/flags/block_flags.cjs.map +1 -0
- package/dist/flags/block_flags.d.ts +0 -1
- package/dist/flags/block_flags.js +5 -0
- package/dist/flags/block_flags.js.map +1 -0
- package/dist/flags/flag_utils.cjs +100 -0
- package/dist/flags/flag_utils.cjs.map +1 -0
- package/dist/flags/flag_utils.d.ts +0 -1
- package/dist/flags/flag_utils.js +94 -0
- package/dist/flags/flag_utils.js.map +1 -0
- package/dist/flags/index.d.ts +0 -1
- package/dist/flags/type_utils.d.ts +0 -1
- package/dist/index.cjs +151 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +10 -12
- package/dist/index.js +27 -1
- package/dist/index.js.map +1 -1
- package/dist/json.cjs +18 -0
- package/dist/json.cjs.map +1 -0
- package/dist/json.d.ts +0 -1
- package/dist/json.js +14 -0
- package/dist/json.js.map +1 -0
- package/dist/navigation.cjs +6 -0
- package/dist/navigation.cjs.map +1 -0
- package/dist/navigation.d.ts +0 -1
- package/dist/navigation.js +4 -0
- package/dist/navigation.js.map +1 -0
- package/dist/plid.cjs +37 -0
- package/dist/plid.cjs.map +1 -0
- package/dist/plid.d.ts +0 -1
- package/dist/plid.js +30 -0
- package/dist/plid.js.map +1 -0
- package/dist/pool/entry.d.ts +0 -1
- package/dist/pool/index.d.ts +0 -1
- package/dist/pool/query.cjs +49 -0
- package/dist/pool/query.cjs.map +1 -0
- package/dist/pool/query.d.ts +0 -1
- package/dist/pool/query.js +47 -0
- package/dist/pool/query.js.map +1 -0
- package/dist/pool/spec.cjs +67 -0
- package/dist/pool/spec.cjs.map +1 -0
- package/dist/pool/spec.d.ts +0 -1
- package/dist/pool/spec.js +59 -0
- package/dist/pool/spec.js.map +1 -0
- package/dist/ref.cjs +88 -0
- package/dist/ref.cjs.map +1 -0
- package/dist/ref.d.ts +0 -1
- package/dist/ref.js +82 -0
- package/dist/ref.js.map +1 -0
- package/dist/utag.d.ts +0 -1
- package/dist/util.cjs +8 -0
- package/dist/util.cjs.map +1 -0
- package/dist/util.d.ts +0 -1
- package/dist/util.js +6 -0
- package/dist/util.js.map +1 -0
- package/dist/value_or_error.cjs +8 -0
- package/dist/value_or_error.cjs.map +1 -0
- package/dist/value_or_error.d.ts +0 -1
- package/dist/value_or_error.js +6 -0
- package/dist/value_or_error.js.map +1 -0
- package/package.json +13 -11
- package/src/index.ts +10 -11
- package/dist/author_marker.d.ts.map +0 -1
- package/dist/base32_encode.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/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/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/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.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.map +0 -1
- package/dist/flags/type_utils.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.mjs +0 -1587
- package/dist/index.mjs.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
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import canonicalize from 'canonicalize';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Canonically serializes a {@link UniversalPColumnId} to a string.
|
|
5
|
+
* @param id - The column identifier to serialize
|
|
6
|
+
* @returns The canonically serialized string
|
|
7
|
+
*/
|
|
8
|
+
function stringifyColumnId(id) {
|
|
9
|
+
return canonicalize(id);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Parses a canonically serialized {@link UniversalPColumnId} from a string.
|
|
13
|
+
* @param str - The string to parse
|
|
14
|
+
* @returns The parsed column identifier
|
|
15
|
+
*/
|
|
16
|
+
function parseColumnId(str) {
|
|
17
|
+
return JSON.parse(str);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { parseColumnId, stringifyColumnId };
|
|
21
|
+
//# sourceMappingURL=ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.js","sources":["../../../../src/drivers/pframe/spec/ids.ts"],"sourcesContent":["import type { Branded } from '../../../branding';\nimport type { AnchoredPColumnId } from './selectors';\nimport type { FilteredPColumnId } from './filtered_column';\nimport canonicalize from 'canonicalize';\nimport type { PObjectId } from '../../../pool';\n/**\n * Universal column identifier optionally anchored and optionally filtered.\n */\nexport type UniversalPColumnId = AnchoredPColumnId | FilteredPColumnId;\n\n/**\n * Canonically serialized {@link UniversalPColumnId}.\n */\nexport type SUniversalPColumnId = Branded<PObjectId, 'SUniversalPColumnId', '__pl_model_brand_2__'>;\n\n/**\n * Canonically serializes a {@link UniversalPColumnId} to a string.\n * @param id - The column identifier to serialize\n * @returns The canonically serialized string\n */\nexport function stringifyColumnId(id: UniversalPColumnId): SUniversalPColumnId {\n return canonicalize(id)! as SUniversalPColumnId;\n}\n\n/**\n * Parses a canonically serialized {@link UniversalPColumnId} from a string.\n * @param str - The string to parse\n * @returns The parsed column identifier\n */\nexport function parseColumnId(str: SUniversalPColumnId): UniversalPColumnId {\n return JSON.parse(str) as UniversalPColumnId;\n}\n"],"names":[],"mappings":";;AAeA;;;;AAIG;AACG,SAAU,iBAAiB,CAAC,EAAsB,EAAA;AACtD,IAAA,OAAO,YAAY,CAAC,EAAE,CAAyB;AACjD;AAEA;;;;AAIG;AACG,SAAU,aAAa,CAAC,GAAwB,EAAA;AACpD,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAuB;AAC9C;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var spec = require('../../../pool/spec.cjs');
|
|
4
|
+
var spec$1 = require('./spec.cjs');
|
|
5
|
+
var canonicalize = require('canonicalize');
|
|
6
|
+
|
|
7
|
+
function deriveNativeId(spec$2) {
|
|
8
|
+
const result = {
|
|
9
|
+
kind: spec$2.kind,
|
|
10
|
+
name: spec$2.name,
|
|
11
|
+
};
|
|
12
|
+
if (spec$2.domain !== undefined)
|
|
13
|
+
result.domain = spec$2.domain;
|
|
14
|
+
if (spec.isPColumnSpec(spec$2))
|
|
15
|
+
result.axesSpec = spec$1.getAxesId(spec$2.axesSpec);
|
|
16
|
+
return canonicalize(result);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.deriveNativeId = deriveNativeId;
|
|
20
|
+
//# sourceMappingURL=native_id.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native_id.cjs","sources":["../../../../src/drivers/pframe/spec/native_id.ts"],"sourcesContent":["import type { Branded } from '../../../branding';\nimport { isPColumnSpec, type PObjectSpec } from '../../../pool';\nimport { getAxesId } from './spec';\nimport canonicalize from 'canonicalize';\nexport type NativePObjectId = Branded<string, 'NativePObjectId'>;\n\nexport function deriveNativeId(spec: PObjectSpec): NativePObjectId {\n const result: Record<string, unknown> = {\n kind: spec.kind,\n name: spec.name,\n };\n if (spec.domain !== undefined)\n result.domain = spec.domain;\n if (isPColumnSpec(spec))\n result.axesSpec = getAxesId(spec.axesSpec);\n return canonicalize(result) as NativePObjectId;\n}\n"],"names":["spec","isPColumnSpec","getAxesId"],"mappings":";;;;;;AAMM,SAAU,cAAc,CAACA,MAAiB,EAAA;AAC9C,IAAA,MAAM,MAAM,GAA4B;QACtC,IAAI,EAAEA,MAAI,CAAC,IAAI;QACf,IAAI,EAAEA,MAAI,CAAC,IAAI;KAChB;AACD,IAAA,IAAIA,MAAI,CAAC,MAAM,KAAK,SAAS;AAC3B,QAAA,MAAM,CAAC,MAAM,GAAGA,MAAI,CAAC,MAAM;IAC7B,IAAIC,kBAAa,CAACD,MAAI,CAAC;QACrB,MAAM,CAAC,QAAQ,GAAGE,gBAAS,CAACF,MAAI,CAAC,QAAQ,CAAC;AAC5C,IAAA,OAAO,YAAY,CAAC,MAAM,CAAoB;AAChD;;;;"}
|
|
@@ -2,4 +2,3 @@ import { Branded } from '../../../branding';
|
|
|
2
2
|
import { PObjectSpec } from '../../../pool';
|
|
3
3
|
export type NativePObjectId = Branded<string, 'NativePObjectId'>;
|
|
4
4
|
export declare function deriveNativeId(spec: PObjectSpec): NativePObjectId;
|
|
5
|
-
//# sourceMappingURL=native_id.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { isPColumnSpec } from '../../../pool/spec.js';
|
|
2
|
+
import { getAxesId } from './spec.js';
|
|
3
|
+
import canonicalize from 'canonicalize';
|
|
4
|
+
|
|
5
|
+
function deriveNativeId(spec) {
|
|
6
|
+
const result = {
|
|
7
|
+
kind: spec.kind,
|
|
8
|
+
name: spec.name,
|
|
9
|
+
};
|
|
10
|
+
if (spec.domain !== undefined)
|
|
11
|
+
result.domain = spec.domain;
|
|
12
|
+
if (isPColumnSpec(spec))
|
|
13
|
+
result.axesSpec = getAxesId(spec.axesSpec);
|
|
14
|
+
return canonicalize(result);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { deriveNativeId };
|
|
18
|
+
//# sourceMappingURL=native_id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native_id.js","sources":["../../../../src/drivers/pframe/spec/native_id.ts"],"sourcesContent":["import type { Branded } from '../../../branding';\nimport { isPColumnSpec, type PObjectSpec } from '../../../pool';\nimport { getAxesId } from './spec';\nimport canonicalize from 'canonicalize';\nexport type NativePObjectId = Branded<string, 'NativePObjectId'>;\n\nexport function deriveNativeId(spec: PObjectSpec): NativePObjectId {\n const result: Record<string, unknown> = {\n kind: spec.kind,\n name: spec.name,\n };\n if (spec.domain !== undefined)\n result.domain = spec.domain;\n if (isPColumnSpec(spec))\n result.axesSpec = getAxesId(spec.axesSpec);\n return canonicalize(result) as NativePObjectId;\n}\n"],"names":[],"mappings":";;;;AAMM,SAAU,cAAc,CAAC,IAAiB,EAAA;AAC9C,IAAA,MAAM,MAAM,GAA4B;QACtC,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB;AACD,IAAA,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;AAC3B,QAAA,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM;IAC7B,IAAI,aAAa,CAAC,IAAI,CAAC;QACrB,MAAM,CAAC,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC;AAC5C,IAAA,OAAO,YAAY,CAAC,MAAM,CAAoB;AAChD;;;;"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var spec$1 = require('../../../pool/spec.cjs');
|
|
4
|
+
var spec = require('./spec.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Determines if an axis ID matches an axis selector.
|
|
8
|
+
*
|
|
9
|
+
* @param selector - The selector with criteria to match against
|
|
10
|
+
* @param axis - The AxisId to check against the selector
|
|
11
|
+
* @returns true if the AxisId matches all specified criteria in the selector, false otherwise
|
|
12
|
+
*/
|
|
13
|
+
function matchAxis(selector, axis) {
|
|
14
|
+
// Match name if specified
|
|
15
|
+
if (selector.name !== undefined && selector.name !== axis.name)
|
|
16
|
+
return false;
|
|
17
|
+
// Match type if specified
|
|
18
|
+
if (selector.type !== undefined) {
|
|
19
|
+
if (Array.isArray(selector.type)) {
|
|
20
|
+
if (!selector.type.includes(axis.type))
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
else if (selector.type !== axis.type) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// Match domain if specified - using existing logic from matchAxisId
|
|
28
|
+
if (selector.domain !== undefined) {
|
|
29
|
+
const axisDomain = axis.domain || {};
|
|
30
|
+
for (const [key, value] of Object.entries(selector.domain))
|
|
31
|
+
if (axisDomain[key] !== value)
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Determines if a given PColumnSpec matches a selector.
|
|
38
|
+
*
|
|
39
|
+
* @param pcolumn - The PColumnSpec to check against the selector
|
|
40
|
+
* @param selector - The selector criteria to match against
|
|
41
|
+
* @returns true if the PColumnSpec matches all criteria in the selector, false otherwise
|
|
42
|
+
*/
|
|
43
|
+
function matchPColumn(pcolumn, selector) {
|
|
44
|
+
// Match name if specified
|
|
45
|
+
if (selector.name !== undefined && pcolumn.name !== selector.name)
|
|
46
|
+
return false;
|
|
47
|
+
// Match name pattern if specified
|
|
48
|
+
if (selector.namePattern !== undefined && !new RegExp(selector.namePattern).test(pcolumn.name))
|
|
49
|
+
return false;
|
|
50
|
+
// Match type if specified
|
|
51
|
+
if (selector.type !== undefined) {
|
|
52
|
+
if (Array.isArray(selector.type)) {
|
|
53
|
+
if (!selector.type.includes(pcolumn.valueType))
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
else if (selector.type !== pcolumn.valueType) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// Match domain if specified
|
|
61
|
+
if (selector.domain !== undefined) {
|
|
62
|
+
const columnDomain = pcolumn.domain || {};
|
|
63
|
+
for (const [key, value] of Object.entries(selector.domain))
|
|
64
|
+
if (columnDomain[key] !== value)
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
// Match axes if specified
|
|
68
|
+
if (selector.axes !== undefined) {
|
|
69
|
+
const pcolumnAxes = pcolumn.axesSpec.map(spec.getAxisId);
|
|
70
|
+
if (selector.partialAxesMatch) {
|
|
71
|
+
// For partial matching, all selector axes must match at least one column axis
|
|
72
|
+
for (const selectorAxis of selector.axes)
|
|
73
|
+
if (!pcolumnAxes.some((columnAxis) => matchAxis(selectorAxis, columnAxis)))
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
// For exact matching, column must have the same number of axes and all must match
|
|
78
|
+
if (pcolumnAxes.length !== selector.axes.length)
|
|
79
|
+
return false;
|
|
80
|
+
// Each selector axis must match a corresponding column axis
|
|
81
|
+
for (let i = 0; i < selector.axes.length; i++)
|
|
82
|
+
if (!matchAxis(selector.axes[i], pcolumnAxes[i]))
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Match annotations if specified
|
|
87
|
+
if (selector.annotations !== undefined) {
|
|
88
|
+
const columnAnnotations = pcolumn.annotations || {};
|
|
89
|
+
for (const [key, value] of Object.entries(selector.annotations))
|
|
90
|
+
if (columnAnnotations[key] !== value)
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
// Match annotation patterns if specified
|
|
94
|
+
if (selector.annotationPatterns !== undefined) {
|
|
95
|
+
const columnAnnotations = pcolumn.annotations || {};
|
|
96
|
+
for (const [key, pattern] of Object.entries(selector.annotationPatterns)) {
|
|
97
|
+
const value = columnAnnotations[key];
|
|
98
|
+
if (value === undefined || !new RegExp(pattern).test(value))
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Convert a predicate or array of selectors to a single predicate function
|
|
106
|
+
* @param predicateOrSelectors - Either a function that takes a PColumnSpec and returns a boolean,
|
|
107
|
+
* or an array of PColumnSelectors, or a single PColumnSelector
|
|
108
|
+
* @returns A function that takes a PColumnSpec and returns a boolean
|
|
109
|
+
*/
|
|
110
|
+
function selectorsToPredicate(predicateOrSelectors) {
|
|
111
|
+
if (Array.isArray(predicateOrSelectors))
|
|
112
|
+
return (spec) => predicateOrSelectors.some((selector) => spec$1.isPColumnSpec(spec) && matchPColumn(spec, selector));
|
|
113
|
+
else
|
|
114
|
+
return (spec) => spec$1.isPColumnSpec(spec) && matchPColumn(spec, predicateOrSelectors);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
exports.matchAxis = matchAxis;
|
|
118
|
+
exports.matchPColumn = matchPColumn;
|
|
119
|
+
exports.selectorsToPredicate = selectorsToPredicate;
|
|
120
|
+
//# sourceMappingURL=selectors.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectors.cjs","sources":["../../../../src/drivers/pframe/spec/selectors.ts"],"sourcesContent":["import { isPColumnSpec, type PObjectSpec } from '../../../pool';\nimport type { AxisId, 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/**\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 * 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)\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(axis.type))\n 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)\n 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)\n 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))\n 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)\n 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)))\n 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)\n 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]))\n 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)\n 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))\n 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(predicateOrSelectors: PColumnSelector | PColumnSelector[]): ((spec: PObjectSpec) => boolean) {\n if (Array.isArray(predicateOrSelectors))\n return (spec) => predicateOrSelectors.some((selector) => isPColumnSpec(spec) && matchPColumn(spec, selector));\n else\n return (spec) => isP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AC,IAAI,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;;AAE7G,QAAA,OAAO,CAAC,IAAI,KAAKA,oBAAa,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,IAAI,EAAE,oBAAoB,CAAC;AACpF;;;;;;"}
|
|
@@ -162,4 +162,3 @@ export declare function matchPColumn(pcolumn: PColumnSpec, selector: PColumnSele
|
|
|
162
162
|
* @returns A function that takes a PColumnSpec and returns a boolean
|
|
163
163
|
*/
|
|
164
164
|
export declare function selectorsToPredicate(predicateOrSelectors: PColumnSelector | PColumnSelector[]): ((spec: PObjectSpec) => boolean);
|
|
165
|
-
//# sourceMappingURL=selectors.d.ts.map
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { isPColumnSpec } from '../../../pool/spec.js';
|
|
2
|
+
import { getAxisId } from './spec.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Determines if an axis ID matches an axis selector.
|
|
6
|
+
*
|
|
7
|
+
* @param selector - The selector with criteria to match against
|
|
8
|
+
* @param axis - The AxisId to check against the selector
|
|
9
|
+
* @returns true if the AxisId matches all specified criteria in the selector, false otherwise
|
|
10
|
+
*/
|
|
11
|
+
function matchAxis(selector, axis) {
|
|
12
|
+
// Match name if specified
|
|
13
|
+
if (selector.name !== undefined && selector.name !== axis.name)
|
|
14
|
+
return false;
|
|
15
|
+
// Match type if specified
|
|
16
|
+
if (selector.type !== undefined) {
|
|
17
|
+
if (Array.isArray(selector.type)) {
|
|
18
|
+
if (!selector.type.includes(axis.type))
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
else if (selector.type !== axis.type) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// Match domain if specified - using existing logic from matchAxisId
|
|
26
|
+
if (selector.domain !== undefined) {
|
|
27
|
+
const axisDomain = axis.domain || {};
|
|
28
|
+
for (const [key, value] of Object.entries(selector.domain))
|
|
29
|
+
if (axisDomain[key] !== value)
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Determines if a given PColumnSpec matches a selector.
|
|
36
|
+
*
|
|
37
|
+
* @param pcolumn - The PColumnSpec to check against the selector
|
|
38
|
+
* @param selector - The selector criteria to match against
|
|
39
|
+
* @returns true if the PColumnSpec matches all criteria in the selector, false otherwise
|
|
40
|
+
*/
|
|
41
|
+
function matchPColumn(pcolumn, selector) {
|
|
42
|
+
// Match name if specified
|
|
43
|
+
if (selector.name !== undefined && pcolumn.name !== selector.name)
|
|
44
|
+
return false;
|
|
45
|
+
// Match name pattern if specified
|
|
46
|
+
if (selector.namePattern !== undefined && !new RegExp(selector.namePattern).test(pcolumn.name))
|
|
47
|
+
return false;
|
|
48
|
+
// Match type if specified
|
|
49
|
+
if (selector.type !== undefined) {
|
|
50
|
+
if (Array.isArray(selector.type)) {
|
|
51
|
+
if (!selector.type.includes(pcolumn.valueType))
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
else if (selector.type !== pcolumn.valueType) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Match domain if specified
|
|
59
|
+
if (selector.domain !== undefined) {
|
|
60
|
+
const columnDomain = pcolumn.domain || {};
|
|
61
|
+
for (const [key, value] of Object.entries(selector.domain))
|
|
62
|
+
if (columnDomain[key] !== value)
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
// Match axes if specified
|
|
66
|
+
if (selector.axes !== undefined) {
|
|
67
|
+
const pcolumnAxes = pcolumn.axesSpec.map(getAxisId);
|
|
68
|
+
if (selector.partialAxesMatch) {
|
|
69
|
+
// For partial matching, all selector axes must match at least one column axis
|
|
70
|
+
for (const selectorAxis of selector.axes)
|
|
71
|
+
if (!pcolumnAxes.some((columnAxis) => matchAxis(selectorAxis, columnAxis)))
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
// For exact matching, column must have the same number of axes and all must match
|
|
76
|
+
if (pcolumnAxes.length !== selector.axes.length)
|
|
77
|
+
return false;
|
|
78
|
+
// Each selector axis must match a corresponding column axis
|
|
79
|
+
for (let i = 0; i < selector.axes.length; i++)
|
|
80
|
+
if (!matchAxis(selector.axes[i], pcolumnAxes[i]))
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Match annotations if specified
|
|
85
|
+
if (selector.annotations !== undefined) {
|
|
86
|
+
const columnAnnotations = pcolumn.annotations || {};
|
|
87
|
+
for (const [key, value] of Object.entries(selector.annotations))
|
|
88
|
+
if (columnAnnotations[key] !== value)
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
// Match annotation patterns if specified
|
|
92
|
+
if (selector.annotationPatterns !== undefined) {
|
|
93
|
+
const columnAnnotations = pcolumn.annotations || {};
|
|
94
|
+
for (const [key, pattern] of Object.entries(selector.annotationPatterns)) {
|
|
95
|
+
const value = columnAnnotations[key];
|
|
96
|
+
if (value === undefined || !new RegExp(pattern).test(value))
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Convert a predicate or array of selectors to a single predicate function
|
|
104
|
+
* @param predicateOrSelectors - Either a function that takes a PColumnSpec and returns a boolean,
|
|
105
|
+
* or an array of PColumnSelectors, or a single PColumnSelector
|
|
106
|
+
* @returns A function that takes a PColumnSpec and returns a boolean
|
|
107
|
+
*/
|
|
108
|
+
function selectorsToPredicate(predicateOrSelectors) {
|
|
109
|
+
if (Array.isArray(predicateOrSelectors))
|
|
110
|
+
return (spec) => predicateOrSelectors.some((selector) => isPColumnSpec(spec) && matchPColumn(spec, selector));
|
|
111
|
+
else
|
|
112
|
+
return (spec) => isPColumnSpec(spec) && matchPColumn(spec, predicateOrSelectors);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { matchAxis, matchPColumn, selectorsToPredicate };
|
|
116
|
+
//# sourceMappingURL=selectors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectors.js","sources":["../../../../src/drivers/pframe/spec/selectors.ts"],"sourcesContent":["import { isPColumnSpec, type PObjectSpec } from '../../../pool';\nimport type { AxisId, 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/**\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 * 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)\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(axis.type))\n 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)\n 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)\n 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))\n 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)\n 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)))\n 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)\n 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]))\n 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)\n 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))\n 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(predicateOrSelectors: PColumnSelector | PColumnSelector[]): ((spec: PObjectSpec) => boolean) {\n if (Array.isArray(predicateOrSelectors))\n return (spec) => predicateOrSelectors.some((selector) => isPColumnSpec(spec) && matchPColumn(spec, selector));\n else\n return (spec) => isPColumnSpec(spec) && matchPColumn(spec, predicateOrSelectors);\n}\n"],"names":[],"mappings":";;;AAkJA;;;;;;AAMG;AACG,SAAU,SAAS,CAAC,QAAsB,EAAE,IAAY,EAAA;;AAE5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