@platforma-sdk/model 1.24.11 → 1.26.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/components/PlDataTable.d.ts +4 -4
- package/dist/components/PlDataTable.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1004 -660
- package/dist/index.mjs.map +1 -1
- package/dist/render/api.d.ts +65 -21
- package/dist/render/api.d.ts.map +1 -1
- package/dist/render/internal.d.ts +4 -3
- package/dist/render/internal.d.ts.map +1 -1
- package/dist/render/split_selectors.d.ts +14 -0
- package/dist/render/split_selectors.d.ts.map +1 -0
- package/dist/render/util/axis_filtering.d.ts +14 -0
- package/dist/render/util/axis_filtering.d.ts.map +1 -0
- package/dist/render/util/index.d.ts +2 -1
- package/dist/render/util/index.d.ts.map +1 -1
- package/dist/render/util/label.d.ts +7 -1
- package/dist/render/util/label.d.ts.map +1 -1
- package/dist/render/util/{resource_map.d.ts → pcolumn_data.d.ts} +12 -2
- package/dist/render/util/pcolumn_data.d.ts.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/PlDataTable.ts +6 -5
- package/src/render/api.ts +425 -126
- package/src/render/internal.ts +4 -2
- package/src/render/split_selectors.ts +15 -0
- package/src/render/util/axis_filtering.ts +120 -0
- package/src/render/util/index.ts +2 -1
- package/src/render/util/label.ts +31 -3
- package/src/render/util/pcolumn_data.ts +387 -0
- package/dist/render/util/resource_map.d.ts.map +0 -1
- package/src/render/util/resource_map.ts +0 -208
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import type { TreeNodeAccessor } from '../accessor';
|
|
2
|
-
|
|
3
|
-
const PCD_PREFIX = 'PColumnData/';
|
|
4
|
-
|
|
5
|
-
export const RT_RESOURCE_MAP = PCD_PREFIX + 'ResourceMap';
|
|
6
|
-
export const RT_RESOURCE_MAP_PARTITIONED = PCD_PREFIX + 'Partitioned/ResourceMap';
|
|
7
|
-
|
|
8
|
-
export const RT_JSON_PARTITIONED = PCD_PREFIX + 'JsonPartitioned';
|
|
9
|
-
export const RT_BINARY_PARTITIONED = PCD_PREFIX + 'BinaryPartitioned';
|
|
10
|
-
|
|
11
|
-
const PCD_SUP_PREFIX = PCD_PREFIX + 'Partitioned/';
|
|
12
|
-
export const RT_JSON_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'JsonPartitioned';
|
|
13
|
-
export const RT_BINARY_SUPER_PARTITIONED = PCD_SUP_PREFIX + 'BinaryPartitioned';
|
|
14
|
-
|
|
15
|
-
export type PColumnKey = (string | number)[];
|
|
16
|
-
|
|
17
|
-
export type PColumnResourceMapEntry<T> = {
|
|
18
|
-
key: PColumnKey;
|
|
19
|
-
value: T;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type PColumnResourceMapData<T> = {
|
|
23
|
-
isComplete: boolean;
|
|
24
|
-
data: PColumnResourceMapEntry<T>[];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
function populateResourceMapData<T>(
|
|
28
|
-
acc: TreeNodeAccessor | undefined,
|
|
29
|
-
resourceParser: (acc: TreeNodeAccessor) => T | undefined,
|
|
30
|
-
data: PColumnResourceMapEntry<T | undefined>[],
|
|
31
|
-
keyPrefix: PColumnKey = [],
|
|
32
|
-
addEntriesWithNoData: boolean,
|
|
33
|
-
): boolean {
|
|
34
|
-
if (acc === undefined) return false;
|
|
35
|
-
switch (acc.resourceType.name) {
|
|
36
|
-
case RT_RESOURCE_MAP: {
|
|
37
|
-
let isComplete = acc.getInputsLocked();
|
|
38
|
-
for (const keyStr of acc.listInputFields()) {
|
|
39
|
-
const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });
|
|
40
|
-
const key = [...keyPrefix, ...JSON.parse(keyStr)] as PColumnKey;
|
|
41
|
-
const converted = value === undefined ? undefined : resourceParser(value);
|
|
42
|
-
if (converted === undefined) isComplete = false;
|
|
43
|
-
if (converted !== undefined || addEntriesWithNoData) data.push({ key, value: converted });
|
|
44
|
-
}
|
|
45
|
-
return isComplete;
|
|
46
|
-
}
|
|
47
|
-
case RT_RESOURCE_MAP_PARTITIONED: {
|
|
48
|
-
let isComplete = acc.getInputsLocked();
|
|
49
|
-
for (const keyStr of acc.listInputFields()) {
|
|
50
|
-
const value = acc.resolve({ field: keyStr, assertFieldType: 'Input' });
|
|
51
|
-
if (value === undefined) isComplete = false;
|
|
52
|
-
else {
|
|
53
|
-
const key = [...keyPrefix, ...JSON.parse(keyStr)] as PColumnKey;
|
|
54
|
-
const populateResult = populateResourceMapData(
|
|
55
|
-
value,
|
|
56
|
-
resourceParser,
|
|
57
|
-
data,
|
|
58
|
-
key,
|
|
59
|
-
addEntriesWithNoData,
|
|
60
|
-
);
|
|
61
|
-
isComplete = isComplete && populateResult;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return isComplete;
|
|
65
|
-
}
|
|
66
|
-
default:
|
|
67
|
-
throw new Error(`Unknown resource type: ${acc.resourceType.name}`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function parseResourceMap<T>(
|
|
72
|
-
acc: TreeNodeAccessor | undefined,
|
|
73
|
-
resourceParser: (acc: TreeNodeAccessor) => T | undefined,
|
|
74
|
-
addEntriesWithNoData: false
|
|
75
|
-
): PColumnResourceMapData<NonNullable<T>>;
|
|
76
|
-
export function parseResourceMap<T>(
|
|
77
|
-
acc: TreeNodeAccessor | undefined,
|
|
78
|
-
resourceParser: (acc: TreeNodeAccessor) => T | undefined,
|
|
79
|
-
addEntriesWithNoData: true
|
|
80
|
-
): PColumnResourceMapData<T | undefined>;
|
|
81
|
-
export function parseResourceMap<T>(
|
|
82
|
-
acc: TreeNodeAccessor | undefined,
|
|
83
|
-
resourceParser: (acc: TreeNodeAccessor) => T | undefined,
|
|
84
|
-
addEntriesWithNoData: boolean = false,
|
|
85
|
-
): PColumnResourceMapData<T | undefined> {
|
|
86
|
-
const data: PColumnResourceMapEntry<T | undefined>[] = [];
|
|
87
|
-
const isComplete = populateResourceMapData(acc, resourceParser, data, [], addEntriesWithNoData);
|
|
88
|
-
return { isComplete, data };
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export type PColumnKeyList = {
|
|
92
|
-
/** array of keys */
|
|
93
|
-
data: PColumnKey[];
|
|
94
|
-
/** length of partition key */
|
|
95
|
-
keyLength: number;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const removeIndexSuffix = (keyStr: string): string | undefined => {
|
|
99
|
-
if (keyStr.endsWith('.index')) {
|
|
100
|
-
return undefined;
|
|
101
|
-
} else if (keyStr.endsWith('.values')) {
|
|
102
|
-
return keyStr.substring(0, keyStr.length - 7);
|
|
103
|
-
} else {
|
|
104
|
-
throw Error(`key must ends on .index/.values for binary p-column, got: ${keyStr}`);
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
// @TODO define a class with various resource map operations
|
|
109
|
-
/** Returns a list of all partition keys appeared in the p-column */
|
|
110
|
-
export function getPartitionKeysList(
|
|
111
|
-
acc: TreeNodeAccessor | undefined,
|
|
112
|
-
): PColumnKeyList | undefined {
|
|
113
|
-
if (!acc) return undefined;
|
|
114
|
-
|
|
115
|
-
const rt = acc.resourceType.name;
|
|
116
|
-
const meta = acc.getDataAsJson<Record<string, number>>();
|
|
117
|
-
const data: PColumnKey[] = [];
|
|
118
|
-
|
|
119
|
-
let keyLength = 0;
|
|
120
|
-
// @TODO validate meta shape
|
|
121
|
-
switch (rt) {
|
|
122
|
-
case RT_RESOURCE_MAP:
|
|
123
|
-
keyLength = meta['keyLength'];
|
|
124
|
-
break;
|
|
125
|
-
|
|
126
|
-
case RT_RESOURCE_MAP_PARTITIONED:
|
|
127
|
-
keyLength = meta['partitionKeyLength'] + meta['keyLength'];
|
|
128
|
-
break;
|
|
129
|
-
|
|
130
|
-
case RT_JSON_PARTITIONED:
|
|
131
|
-
case RT_BINARY_PARTITIONED:
|
|
132
|
-
keyLength = meta['partitionKeyLength'];
|
|
133
|
-
break;
|
|
134
|
-
|
|
135
|
-
case RT_BINARY_SUPER_PARTITIONED:
|
|
136
|
-
case RT_JSON_SUPER_PARTITIONED:
|
|
137
|
-
keyLength = meta['superPartitionKeyLength'] + meta['partitionKeyLength'];
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
switch (rt) {
|
|
142
|
-
case RT_RESOURCE_MAP:
|
|
143
|
-
case RT_JSON_PARTITIONED:
|
|
144
|
-
case RT_BINARY_PARTITIONED:
|
|
145
|
-
for (let keyStr of acc.listInputFields()) {
|
|
146
|
-
if (rt === RT_BINARY_PARTITIONED) {
|
|
147
|
-
const k = removeIndexSuffix(keyStr);
|
|
148
|
-
if (!k) continue;
|
|
149
|
-
else keyStr = k;
|
|
150
|
-
}
|
|
151
|
-
const key = [...JSON.parse(keyStr)] as PColumnKey;
|
|
152
|
-
data.push(key);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
break;
|
|
156
|
-
|
|
157
|
-
case RT_RESOURCE_MAP_PARTITIONED:
|
|
158
|
-
case RT_BINARY_SUPER_PARTITIONED:
|
|
159
|
-
case RT_JSON_SUPER_PARTITIONED:
|
|
160
|
-
for (const supKeyStr of acc.listInputFields()) {
|
|
161
|
-
const keyPrefix = [...JSON.parse(supKeyStr)] as PColumnKey;
|
|
162
|
-
|
|
163
|
-
const value = acc.resolve({ field: supKeyStr, assertFieldType: 'Input' });
|
|
164
|
-
if (value !== undefined) {
|
|
165
|
-
for (let keyStr of value.listInputFields()) {
|
|
166
|
-
if (rt === RT_BINARY_SUPER_PARTITIONED) {
|
|
167
|
-
const k = removeIndexSuffix(keyStr);
|
|
168
|
-
if (!k) continue;
|
|
169
|
-
else keyStr = k;
|
|
170
|
-
}
|
|
171
|
-
const key = [...keyPrefix, ...JSON.parse(keyStr)] as PColumnKey;
|
|
172
|
-
data.push(key);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return { data, keyLength };
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/** Returns an array of unique partition keys for each column: the i-th element in the resulting 2d array contains all unique values of i-th partition axis. */
|
|
183
|
-
// @TODO define a class with various resource map operations
|
|
184
|
-
export function getUniquePartitionKeys(
|
|
185
|
-
acc: TreeNodeAccessor | undefined,
|
|
186
|
-
): (string | number)[][] | undefined {
|
|
187
|
-
const list = getPartitionKeysList(acc);
|
|
188
|
-
if (!list) return undefined;
|
|
189
|
-
|
|
190
|
-
const { data, keyLength } = list;
|
|
191
|
-
|
|
192
|
-
const result: Set<string | number>[] = [];
|
|
193
|
-
|
|
194
|
-
for (let i = 0; i < keyLength; ++i) {
|
|
195
|
-
result.push(new Set());
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
for (const l of data) {
|
|
199
|
-
if (l.length !== keyLength) {
|
|
200
|
-
throw new Error('key length does not match partition length');
|
|
201
|
-
}
|
|
202
|
-
for (let i = 0; i < keyLength; ++i) {
|
|
203
|
-
result[i].add(l[i]);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
return result.map((s) => Array.from(s.values()));
|
|
208
|
-
}
|