@milaboratories/pl-model-common 1.26.1 → 1.28.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.
@@ -0,0 +1,155 @@
1
+ import type { Branded } from "@milaboratories/helpers";
2
+ import type {
3
+ ValueType,
4
+ SingleAxisSelector,
5
+ AxisSpec,
6
+ PColumnIdAndSpec,
7
+ PColumnSpec,
8
+ } from "./pframe";
9
+
10
+ // --- Discover columns types (duplicated from middle-layer internal_api) ---
11
+
12
+ /** Matches a string value either exactly or by regex pattern */
13
+ export type StringMatcher = { type: "exact"; value: string } | { type: "regex"; value: string };
14
+
15
+ /** Map of key to array of string matchers (OR-ed per key, AND-ed across keys) */
16
+ export type MatcherMap = Record<string, StringMatcher[]>;
17
+
18
+ /** Selector for matching axes by various criteria */
19
+ export interface MultiAxisSelector {
20
+ /** Match any of the axis types listed here */
21
+ readonly type?: ValueType[];
22
+ /** Match any of the axis names listed here */
23
+ readonly name?: StringMatcher[];
24
+ /** Match requires all the domains listed here */
25
+ readonly domain?: MatcherMap;
26
+ /** Match requires all the context domains listed here */
27
+ readonly contextDomain?: MatcherMap;
28
+ /** Match requires all the annotations listed here */
29
+ readonly annotations?: MatcherMap;
30
+ }
31
+
32
+ /** Column selector for discover columns request, matching columns by various criteria.
33
+ * Multiple selectors are OR-ed: a column matches if it satisfies any selector. */
34
+ export interface MultiColumnSelector {
35
+ /** Match any of the value types listed here */
36
+ readonly type?: ValueType[];
37
+ /** Match any of the names listed here */
38
+ readonly name?: StringMatcher[];
39
+ /** Match requires all the domains listed here */
40
+ readonly domain?: MatcherMap;
41
+ /** Match requires all the context domains listed here */
42
+ readonly contextDomain?: MatcherMap;
43
+ /** Match requires all the annotations listed here */
44
+ readonly annotations?: MatcherMap;
45
+ /** Match any of the axis selectors listed here */
46
+ readonly axes?: MultiAxisSelector[];
47
+ /** When true (default), allows matching if only a subset of axes match */
48
+ readonly partialAxesMatch?: boolean;
49
+ }
50
+
51
+ /** Qualification applied to a single axis to make it compatible during integration. */
52
+ export interface AxisQualification {
53
+ /** Axis selector identifying which axis is qualified. */
54
+ readonly axis: SingleAxisSelector;
55
+ /** Additional context domain entries applied to the axis. */
56
+ readonly contextDomain: Record<string, string>;
57
+ }
58
+
59
+ /** Qualifications needed for both query (already-integrated) columns and the hit column. */
60
+ export interface ColumnAxesWithQualifications {
61
+ /** Already integrated (query) columns with their qualifications. */
62
+ axesSpec: AxisSpec[];
63
+ /** Qualifications for each already integrated (query) column. */
64
+ qualifications: AxisQualification[];
65
+ }
66
+
67
+ /** Fine-grained constraints controlling axes matching and qualification behavior */
68
+ export interface DiscoverColumnsConstraints {
69
+ /** Allow source (query) axes that have no match in the hit column */
70
+ allowFloatingSourceAxes: boolean;
71
+ /** Allow hit column axes that have no match in the source (query) */
72
+ allowFloatingHitAxes: boolean;
73
+ /** Allow source (query) axes to be qualified (contextDomain extended) */
74
+ allowSourceQualifications: boolean;
75
+ /** Allow hit column axes to be qualified (contextDomain extended) */
76
+ allowHitQualifications: boolean;
77
+ }
78
+
79
+ /** Request for discovering columns compatible with a given axes integration */
80
+ export interface DiscoverColumnsRequest {
81
+ /** Column filters (OR-ed); empty array matches all columns */
82
+ columnFilter?: MultiColumnSelector[];
83
+ /** Already integrated axes with qualifications */
84
+ axes: ColumnAxesWithQualifications[];
85
+ /** Constraints controlling axes matching and qualification behavior */
86
+ constraints: DiscoverColumnsConstraints;
87
+ }
88
+
89
+ /** Linker step: traversal through a linker column */
90
+ export interface DiscoverColumnsLinkerStep {
91
+ type: "linker";
92
+ /** The linker column traversed in this step */
93
+ linker: PColumnIdAndSpec;
94
+ /** Axis qualifications produced when matching the linker's many-side axes */
95
+ qualifications: AxisQualification[];
96
+ }
97
+
98
+ /** A step traversed during path-based column discovery. Discriminated by `type`. */
99
+ export type DiscoverColumnsStepInfo = DiscoverColumnsLinkerStep;
100
+
101
+ /** Qualifications info for a discover columns response mapping variant */
102
+ export interface DiscoverColumnsResponseQualifications {
103
+ /** Qualifications for each query (already-integrated) column set */
104
+ forQueries: AxisQualification[][];
105
+ /** Qualifications for the hit column */
106
+ forHit: AxisQualification[];
107
+ }
108
+
109
+ /** A single mapping variant describing how a hit column can be integrated */
110
+ export interface DiscoverColumnsMappingVariant {
111
+ /** Full qualifications needed for integration */
112
+ qualifications: DiscoverColumnsResponseQualifications;
113
+ /** Distinctive (minimal) qualifications needed for integration */
114
+ distinctiveQualifications: DiscoverColumnsResponseQualifications;
115
+ }
116
+
117
+ /** A single hit in the discover columns response */
118
+ export interface DiscoverColumnsResponseHit {
119
+ /** The column that was found compatible */
120
+ hit: PColumnIdAndSpec;
121
+ /** Possible ways to integrate this column with the existing set */
122
+ mappingVariants: DiscoverColumnsMappingVariant[];
123
+ }
124
+
125
+ /** Response from discover columns */
126
+ export interface DiscoverColumnsResponse {
127
+ /** Columns that could be integrated and possible ways to integrate them */
128
+ hits: DiscoverColumnsResponseHit[];
129
+ }
130
+
131
+ // --- Spec driver ---
132
+
133
+ /** Handle to a spec-only PFrame (no data, synchronous operations). */
134
+ export type SpecFrameHandle = Branded<string, "SpecFrameHandle">;
135
+
136
+ /**
137
+ * Synchronous driver for spec-level PFrame operations.
138
+ *
139
+ * Unlike the async PFrameDriver (which works with data), this driver
140
+ * operates on column specifications only. All methods are synchronous
141
+ * because the underlying WASM PFrame computes results immediately.
142
+ */
143
+ export interface PSpecDriver {
144
+ /** Create a spec-only PFrame from column specs. Returns a handle. */
145
+ createSpecFrame(specs: Record<string, PColumnSpec>): SpecFrameHandle;
146
+
147
+ /** Discover columns compatible with given axes integration. */
148
+ specFrameDiscoverColumns(
149
+ handle: SpecFrameHandle,
150
+ request: DiscoverColumnsRequest,
151
+ ): DiscoverColumnsResponse;
152
+
153
+ /** Dispose a spec frame, freeing WASM resources. */
154
+ disposeSpecFrame(handle: SpecFrameHandle): void;
155
+ }
package/src/index.ts CHANGED
@@ -17,3 +17,4 @@ export * from "./value_or_error";
17
17
  export * from "./base64";
18
18
  export * from "./util";
19
19
  export * from "./httpAuth";
20
+ export * from "./resource_types";
@@ -0,0 +1,47 @@
1
+ /** Well-known resource type names used across the platform. */
2
+ export const ResourceTypeName = {
3
+ StreamManager: "StreamManager",
4
+ StdMap: "StdMap",
5
+ StdMapSlash: "std/map",
6
+ EphStdMap: "EphStdMap",
7
+ PFrame: "PFrame",
8
+ ParquetChunk: "ParquetChunk",
9
+ BContext: "BContext",
10
+ BlockPackCustom: "BlockPackCustom",
11
+ BinaryMap: "BinaryMap",
12
+ BinaryValue: "BinaryValue",
13
+ BlobMap: "BlobMap",
14
+ BResolveSingle: "BResolveSingle",
15
+ BResolveSingleNoResult: "BResolveSingleNoResult",
16
+ BQueryResult: "BQueryResult",
17
+ TengoTemplate: "TengoTemplate",
18
+ TengoLib: "TengoLib",
19
+ SoftwareInfo: "SoftwareInfo",
20
+ Dummy: "Dummy",
21
+ JsonResourceError: "json/resourceError",
22
+ JsonObject: "json/object",
23
+ JsonGzObject: "json-gz/object",
24
+ JsonString: "json/string",
25
+ JsonArray: "json/array",
26
+ JsonNumber: "json/number",
27
+ BContextEnd: "BContextEnd",
28
+ FrontendFromUrl: "Frontend/FromUrl",
29
+ FrontendFromFolder: "Frontend/FromFolder",
30
+ BObjectSpec: "BObjectSpec",
31
+ Blob: "Blob",
32
+ Null: "Null",
33
+ Binary: "binary",
34
+ LSProvider: "LSProvider",
35
+ UserProject: "UserProject",
36
+ Projects: "Projects",
37
+ ClientRoot: "ClientRoot",
38
+ } as const;
39
+
40
+ /** Resource type name prefix constants. */
41
+ export const ResourceTypePrefix = {
42
+ Blob: "Blob/",
43
+ BlobUpload: "BlobUpload/",
44
+ BlobIndex: "BlobIndex/",
45
+ PColumnData: "PColumnData/",
46
+ StreamWorkdir: "StreamWorkdir/",
47
+ } as const;