@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.
Files changed (236) hide show
  1. package/dist/author_marker.d.ts +0 -1
  2. package/dist/base32_encode.cjs +56 -0
  3. package/dist/base32_encode.cjs.map +1 -0
  4. package/dist/base32_encode.d.ts +0 -1
  5. package/dist/base32_encode.js +54 -0
  6. package/dist/base32_encode.js.map +1 -0
  7. package/dist/block_state.d.ts +0 -1
  8. package/dist/bmodel/block_config.cjs +15 -0
  9. package/dist/bmodel/block_config.cjs.map +1 -0
  10. package/dist/bmodel/block_config.d.ts +0 -1
  11. package/dist/bmodel/block_config.js +13 -0
  12. package/dist/bmodel/block_config.js.map +1 -0
  13. package/dist/bmodel/code.d.ts +0 -1
  14. package/dist/bmodel/container.d.ts +0 -1
  15. package/dist/bmodel/index.d.ts +0 -1
  16. package/dist/bmodel/normalization.cjs +86 -0
  17. package/dist/bmodel/normalization.cjs.map +1 -0
  18. package/dist/bmodel/normalization.d.ts +0 -1
  19. package/dist/bmodel/normalization.js +84 -0
  20. package/dist/bmodel/normalization.js.map +1 -0
  21. package/dist/bmodel/types.d.ts +0 -1
  22. package/dist/branding.d.ts +0 -1
  23. package/dist/common_types.d.ts +0 -1
  24. package/dist/driver_kit.d.ts +0 -1
  25. package/dist/drivers/blob.cjs +27 -0
  26. package/dist/drivers/blob.cjs.map +1 -0
  27. package/dist/drivers/blob.d.ts +0 -1
  28. package/dist/drivers/blob.js +23 -0
  29. package/dist/drivers/blob.js.map +1 -0
  30. package/dist/drivers/index.d.ts +0 -1
  31. package/dist/drivers/interfaces.d.ts +0 -1
  32. package/dist/drivers/log.cjs +9 -0
  33. package/dist/drivers/log.cjs.map +1 -0
  34. package/dist/drivers/log.d.ts +0 -1
  35. package/dist/drivers/log.js +7 -0
  36. package/dist/drivers/log.js.map +1 -0
  37. package/dist/drivers/ls.cjs +39 -0
  38. package/dist/drivers/ls.cjs.map +1 -0
  39. package/dist/drivers/ls.d.ts +0 -1
  40. package/dist/drivers/ls.js +34 -0
  41. package/dist/drivers/ls.js.map +1 -0
  42. package/dist/drivers/pframe/column_filter.d.ts +0 -1
  43. package/dist/drivers/pframe/data_info.cjs +275 -0
  44. package/dist/drivers/pframe/data_info.cjs.map +1 -0
  45. package/dist/drivers/pframe/data_info.d.ts +0 -1
  46. package/dist/drivers/pframe/data_info.js +266 -0
  47. package/dist/drivers/pframe/data_info.js.map +1 -0
  48. package/dist/drivers/pframe/data_types.cjs +91 -0
  49. package/dist/drivers/pframe/data_types.cjs.map +1 -0
  50. package/dist/drivers/pframe/data_types.d.ts +0 -1
  51. package/dist/drivers/pframe/data_types.js +83 -0
  52. package/dist/drivers/pframe/data_types.js.map +1 -0
  53. package/dist/drivers/pframe/driver.d.ts +0 -1
  54. package/dist/drivers/pframe/find_columns.d.ts +0 -1
  55. package/dist/drivers/pframe/index.d.ts +0 -1
  56. package/dist/drivers/pframe/linker_columns.cjs +218 -0
  57. package/dist/drivers/pframe/linker_columns.cjs.map +1 -0
  58. package/dist/drivers/pframe/linker_columns.d.ts +0 -1
  59. package/dist/drivers/pframe/linker_columns.js +216 -0
  60. package/dist/drivers/pframe/linker_columns.js.map +1 -0
  61. package/dist/drivers/pframe/pframe.d.ts +0 -1
  62. package/dist/drivers/pframe/spec/anchored.cjs +234 -0
  63. package/dist/drivers/pframe/spec/anchored.cjs.map +1 -0
  64. package/dist/drivers/pframe/spec/anchored.d.ts +0 -1
  65. package/dist/drivers/pframe/spec/anchored.js +231 -0
  66. package/dist/drivers/pframe/spec/anchored.js.map +1 -0
  67. package/dist/drivers/pframe/spec/filtered_column.cjs +13 -0
  68. package/dist/drivers/pframe/spec/filtered_column.cjs.map +1 -0
  69. package/dist/drivers/pframe/spec/filtered_column.d.ts +0 -1
  70. package/dist/drivers/pframe/spec/filtered_column.js +11 -0
  71. package/dist/drivers/pframe/spec/filtered_column.js.map +1 -0
  72. package/dist/drivers/pframe/spec/ids.cjs +24 -0
  73. package/dist/drivers/pframe/spec/ids.cjs.map +1 -0
  74. package/dist/drivers/pframe/spec/ids.d.ts +0 -1
  75. package/dist/drivers/pframe/spec/ids.js +21 -0
  76. package/dist/drivers/pframe/spec/ids.js.map +1 -0
  77. package/dist/drivers/pframe/spec/index.d.ts +0 -1
  78. package/dist/drivers/pframe/spec/native_id.cjs +20 -0
  79. package/dist/drivers/pframe/spec/native_id.cjs.map +1 -0
  80. package/dist/drivers/pframe/spec/native_id.d.ts +0 -1
  81. package/dist/drivers/pframe/spec/native_id.js +18 -0
  82. package/dist/drivers/pframe/spec/native_id.js.map +1 -0
  83. package/dist/drivers/pframe/spec/selectors.cjs +120 -0
  84. package/dist/drivers/pframe/spec/selectors.cjs.map +1 -0
  85. package/dist/drivers/pframe/spec/selectors.d.ts +0 -1
  86. package/dist/drivers/pframe/spec/selectors.js +116 -0
  87. package/dist/drivers/pframe/spec/selectors.js.map +1 -0
  88. package/dist/drivers/pframe/spec/spec.cjs +361 -0
  89. package/dist/drivers/pframe/spec/spec.cjs.map +1 -0
  90. package/dist/drivers/pframe/spec/spec.d.ts +0 -1
  91. package/dist/drivers/pframe/spec/spec.js +332 -0
  92. package/dist/drivers/pframe/spec/spec.js.map +1 -0
  93. package/dist/drivers/pframe/table.d.ts +0 -1
  94. package/dist/drivers/pframe/table_calculate.cjs +43 -0
  95. package/dist/drivers/pframe/table_calculate.cjs.map +1 -0
  96. package/dist/drivers/pframe/table_calculate.d.ts +0 -1
  97. package/dist/drivers/pframe/table_calculate.js +40 -0
  98. package/dist/drivers/pframe/table_calculate.js.map +1 -0
  99. package/dist/drivers/pframe/table_common.cjs +19 -0
  100. package/dist/drivers/pframe/table_common.cjs.map +1 -0
  101. package/dist/drivers/pframe/table_common.d.ts +0 -1
  102. package/dist/drivers/pframe/table_common.js +17 -0
  103. package/dist/drivers/pframe/table_common.js.map +1 -0
  104. package/dist/drivers/pframe/type_util.d.ts +0 -1
  105. package/dist/drivers/pframe/unique_values.d.ts +0 -1
  106. package/dist/drivers/upload.d.ts +0 -1
  107. package/dist/drivers/urls.cjs +14 -0
  108. package/dist/drivers/urls.cjs.map +1 -0
  109. package/dist/drivers/urls.d.ts +0 -1
  110. package/dist/drivers/urls.js +11 -0
  111. package/dist/drivers/urls.js.map +1 -0
  112. package/dist/errors.cjs +141 -0
  113. package/dist/errors.cjs.map +1 -0
  114. package/dist/errors.d.ts +0 -1
  115. package/dist/errors.js +121 -0
  116. package/dist/errors.js.map +1 -0
  117. package/dist/flags/block_flags.cjs +8 -0
  118. package/dist/flags/block_flags.cjs.map +1 -0
  119. package/dist/flags/block_flags.d.ts +0 -1
  120. package/dist/flags/block_flags.js +5 -0
  121. package/dist/flags/block_flags.js.map +1 -0
  122. package/dist/flags/flag_utils.cjs +100 -0
  123. package/dist/flags/flag_utils.cjs.map +1 -0
  124. package/dist/flags/flag_utils.d.ts +0 -1
  125. package/dist/flags/flag_utils.js +94 -0
  126. package/dist/flags/flag_utils.js.map +1 -0
  127. package/dist/flags/index.d.ts +0 -1
  128. package/dist/flags/type_utils.d.ts +0 -1
  129. package/dist/index.cjs +151 -0
  130. package/dist/index.cjs.map +1 -0
  131. package/dist/index.d.ts +10 -12
  132. package/dist/index.js +27 -1
  133. package/dist/index.js.map +1 -1
  134. package/dist/json.cjs +18 -0
  135. package/dist/json.cjs.map +1 -0
  136. package/dist/json.d.ts +0 -1
  137. package/dist/json.js +14 -0
  138. package/dist/json.js.map +1 -0
  139. package/dist/navigation.cjs +6 -0
  140. package/dist/navigation.cjs.map +1 -0
  141. package/dist/navigation.d.ts +0 -1
  142. package/dist/navigation.js +4 -0
  143. package/dist/navigation.js.map +1 -0
  144. package/dist/plid.cjs +37 -0
  145. package/dist/plid.cjs.map +1 -0
  146. package/dist/plid.d.ts +0 -1
  147. package/dist/plid.js +30 -0
  148. package/dist/plid.js.map +1 -0
  149. package/dist/pool/entry.d.ts +0 -1
  150. package/dist/pool/index.d.ts +0 -1
  151. package/dist/pool/query.cjs +49 -0
  152. package/dist/pool/query.cjs.map +1 -0
  153. package/dist/pool/query.d.ts +0 -1
  154. package/dist/pool/query.js +47 -0
  155. package/dist/pool/query.js.map +1 -0
  156. package/dist/pool/spec.cjs +67 -0
  157. package/dist/pool/spec.cjs.map +1 -0
  158. package/dist/pool/spec.d.ts +0 -1
  159. package/dist/pool/spec.js +59 -0
  160. package/dist/pool/spec.js.map +1 -0
  161. package/dist/ref.cjs +88 -0
  162. package/dist/ref.cjs.map +1 -0
  163. package/dist/ref.d.ts +0 -1
  164. package/dist/ref.js +82 -0
  165. package/dist/ref.js.map +1 -0
  166. package/dist/utag.d.ts +0 -1
  167. package/dist/util.cjs +8 -0
  168. package/dist/util.cjs.map +1 -0
  169. package/dist/util.d.ts +0 -1
  170. package/dist/util.js +6 -0
  171. package/dist/util.js.map +1 -0
  172. package/dist/value_or_error.cjs +8 -0
  173. package/dist/value_or_error.cjs.map +1 -0
  174. package/dist/value_or_error.d.ts +0 -1
  175. package/dist/value_or_error.js +6 -0
  176. package/dist/value_or_error.js.map +1 -0
  177. package/package.json +13 -11
  178. package/src/index.ts +10 -11
  179. package/dist/author_marker.d.ts.map +0 -1
  180. package/dist/base32_encode.d.ts.map +0 -1
  181. package/dist/block_state.d.ts.map +0 -1
  182. package/dist/bmodel/block_config.d.ts.map +0 -1
  183. package/dist/bmodel/code.d.ts.map +0 -1
  184. package/dist/bmodel/container.d.ts.map +0 -1
  185. package/dist/bmodel/index.d.ts.map +0 -1
  186. package/dist/bmodel/normalization.d.ts.map +0 -1
  187. package/dist/bmodel/types.d.ts.map +0 -1
  188. package/dist/branding.d.ts.map +0 -1
  189. package/dist/common_types.d.ts.map +0 -1
  190. package/dist/driver_kit.d.ts.map +0 -1
  191. package/dist/drivers/blob.d.ts.map +0 -1
  192. package/dist/drivers/index.d.ts.map +0 -1
  193. package/dist/drivers/interfaces.d.ts.map +0 -1
  194. package/dist/drivers/log.d.ts.map +0 -1
  195. package/dist/drivers/ls.d.ts.map +0 -1
  196. package/dist/drivers/pframe/column_filter.d.ts.map +0 -1
  197. package/dist/drivers/pframe/data_info.d.ts.map +0 -1
  198. package/dist/drivers/pframe/data_types.d.ts.map +0 -1
  199. package/dist/drivers/pframe/driver.d.ts.map +0 -1
  200. package/dist/drivers/pframe/find_columns.d.ts.map +0 -1
  201. package/dist/drivers/pframe/index.d.ts.map +0 -1
  202. package/dist/drivers/pframe/linker_columns.d.ts.map +0 -1
  203. package/dist/drivers/pframe/pframe.d.ts.map +0 -1
  204. package/dist/drivers/pframe/spec/anchored.d.ts.map +0 -1
  205. package/dist/drivers/pframe/spec/filtered_column.d.ts.map +0 -1
  206. package/dist/drivers/pframe/spec/ids.d.ts.map +0 -1
  207. package/dist/drivers/pframe/spec/index.d.ts.map +0 -1
  208. package/dist/drivers/pframe/spec/native_id.d.ts.map +0 -1
  209. package/dist/drivers/pframe/spec/selectors.d.ts.map +0 -1
  210. package/dist/drivers/pframe/spec/spec.d.ts.map +0 -1
  211. package/dist/drivers/pframe/table.d.ts.map +0 -1
  212. package/dist/drivers/pframe/table_calculate.d.ts.map +0 -1
  213. package/dist/drivers/pframe/table_common.d.ts.map +0 -1
  214. package/dist/drivers/pframe/type_util.d.ts.map +0 -1
  215. package/dist/drivers/pframe/unique_values.d.ts.map +0 -1
  216. package/dist/drivers/upload.d.ts.map +0 -1
  217. package/dist/drivers/urls.d.ts.map +0 -1
  218. package/dist/errors.d.ts.map +0 -1
  219. package/dist/flags/block_flags.d.ts.map +0 -1
  220. package/dist/flags/flag_utils.d.ts.map +0 -1
  221. package/dist/flags/index.d.ts.map +0 -1
  222. package/dist/flags/type_utils.d.ts.map +0 -1
  223. package/dist/index.d.ts.map +0 -1
  224. package/dist/index.mjs +0 -1587
  225. package/dist/index.mjs.map +0 -1
  226. package/dist/json.d.ts.map +0 -1
  227. package/dist/navigation.d.ts.map +0 -1
  228. package/dist/plid.d.ts.map +0 -1
  229. package/dist/pool/entry.d.ts.map +0 -1
  230. package/dist/pool/index.d.ts.map +0 -1
  231. package/dist/pool/query.d.ts.map +0 -1
  232. package/dist/pool/spec.d.ts.map +0 -1
  233. package/dist/ref.d.ts.map +0 -1
  234. package/dist/utag.d.ts.map +0 -1
  235. package/dist/util.d.ts.map +0 -1
  236. package/dist/value_or_error.d.ts.map +0 -1
@@ -0,0 +1,332 @@
1
+ import { ensureError } from '../../../errors.js';
2
+ import { canonicalizeJson } from '../../../json.js';
3
+ import { z } from 'zod';
4
+
5
+ const ValueType = {
6
+ Int: 'Int',
7
+ Long: 'Long',
8
+ Float: 'Float',
9
+ Double: 'Double',
10
+ String: 'String',
11
+ Bytes: 'Bytes',
12
+ };
13
+ function readMetadata(metadata, key) {
14
+ return metadata?.[key];
15
+ }
16
+ function readMetadataJsonOrThrow(metadata, metadataJson, key, methodNameInError = 'readMetadataJsonOrThrow') {
17
+ const json = readMetadata(metadata, key);
18
+ if (json === undefined)
19
+ return undefined;
20
+ const schema = metadataJson[key];
21
+ try {
22
+ const value = JSON.parse(json);
23
+ return schema.parse(value);
24
+ }
25
+ catch (error) {
26
+ throw new Error(`${methodNameInError} failed, `
27
+ + `key: ${String(key)}, `
28
+ + `value: ${json}, `
29
+ + `error: ${ensureError(error)}`);
30
+ }
31
+ }
32
+ function readMetadataJson(metadata, metadataJson, key) {
33
+ try {
34
+ return readMetadataJsonOrThrow(metadata, metadataJson, key);
35
+ }
36
+ catch {
37
+ return undefined; // treat invalid values as unset
38
+ }
39
+ }
40
+ /// Well-known domains
41
+ const Domain = {
42
+ Alphabet: 'pl7.app/alphabet',
43
+ BlockId: 'pl7.app/blockId',
44
+ };
45
+ const DomainJson = {};
46
+ /// Helper function for reading plain domain values
47
+ function readDomain(spec, key) {
48
+ return readMetadata(spec?.domain, key);
49
+ }
50
+ /// Helper function for reading json-encoded domain values, throws on JSON parsing error
51
+ function readDomainJsonOrThrow(spec, key) {
52
+ return readMetadataJsonOrThrow(spec?.domain, DomainJson, key, 'readDomainJsonOrThrow');
53
+ }
54
+ /// Helper function for reading json-encoded domain values, returns undefined on JSON parsing error
55
+ function readDomainJson(spec, key) {
56
+ return readMetadataJson(spec?.domain, DomainJson, key);
57
+ }
58
+ /// Well-known annotations
59
+ const Annotation = {
60
+ Alphabet: 'pl7.app/alphabet',
61
+ DiscreteValues: 'pl7.app/discreteValues',
62
+ Format: 'pl7.app/format',
63
+ Graph: {
64
+ IsVirtual: 'pl7.app/graph/isVirtual',
65
+ },
66
+ HideDataFromUi: 'pl7.app/hideDataFromUi',
67
+ IsLinkerColumn: 'pl7.app/isLinkerColumn',
68
+ Label: 'pl7.app/label',
69
+ Max: 'pl7.app/max',
70
+ Min: 'pl7.app/min',
71
+ Parents: 'pl7.app/parents',
72
+ Sequence: {
73
+ Annotation: {
74
+ Mapping: 'pl7.app/sequence/annotation/mapping',
75
+ },
76
+ IsAnnotation: 'pl7.app/sequence/isAnnotation',
77
+ },
78
+ Table: {
79
+ FontFamily: 'pl7.app/table/fontFamily',
80
+ OrderPriority: 'pl7.app/table/orderPriority',
81
+ Visibility: 'pl7.app/table/visibility',
82
+ },
83
+ Trace: 'pl7.app/trace',
84
+ };
85
+ const AxisSpec = z.object({
86
+ type: z.nativeEnum(ValueType),
87
+ name: z.string(),
88
+ domain: z.record(z.string(), z.string()).optional(),
89
+ annotations: z.record(z.string(), z.string()).optional(),
90
+ parentAxes: z.array(z.number()).optional(),
91
+ }).passthrough();
92
+ const AnnotationJson = {
93
+ [Annotation.DiscreteValues]: z.array(z.string()).or(z.array(z.number())),
94
+ [Annotation.Graph.IsVirtual]: z.boolean(),
95
+ [Annotation.HideDataFromUi]: z.boolean(),
96
+ [Annotation.IsLinkerColumn]: z.boolean(),
97
+ [Annotation.Max]: z.number(),
98
+ [Annotation.Min]: z.number(),
99
+ [Annotation.Parents]: z.array(AxisSpec),
100
+ [Annotation.Sequence.Annotation.Mapping]: z.record(z.string(), z.string()),
101
+ [Annotation.Sequence.IsAnnotation]: z.boolean(),
102
+ [Annotation.Table.OrderPriority]: z.number(),
103
+ [Annotation.Trace]: z.record(z.string(), z.unknown()),
104
+ };
105
+ /// Helper function for reading plain annotation values
106
+ function readAnnotation(spec, key) {
107
+ return readMetadata(spec?.annotations, key);
108
+ }
109
+ /// Helper function for reading json-encoded annotation values, throws on JSON parsing error
110
+ function readAnnotationJsonOrThrow(spec, key) {
111
+ return readMetadataJsonOrThrow(spec?.annotations, AnnotationJson, key, 'readAnnotationJsonOrThrow');
112
+ }
113
+ /// Helper function for reading json-encoded annotation values, returns undefined on JSON parsing error
114
+ function readAnnotationJson(spec, key) {
115
+ return readMetadataJson(spec?.annotations, AnnotationJson, key);
116
+ }
117
+ function makeAxisTree(axis) {
118
+ return { axis, children: [] };
119
+ }
120
+ /** Build tree by axis parents annotations */
121
+ function getAxesTree(rootAxis) {
122
+ const root = makeAxisTree(rootAxis);
123
+ let nodesQ = [root];
124
+ while (nodesQ.length) {
125
+ const nextNodes = [];
126
+ for (const node of nodesQ) {
127
+ node.children = node.axis.parentAxesSpec.map(makeAxisTree);
128
+ nextNodes.push(...node.children);
129
+ }
130
+ nodesQ = nextNodes;
131
+ }
132
+ return root;
133
+ }
134
+ /** Get set of canonicalized axisIds from axisTree */
135
+ function getSetFromAxisTree(tree) {
136
+ const set = new Set([canonicalizeJson(getAxisId(tree.axis))]);
137
+ let nodesQ = [tree];
138
+ while (nodesQ.length) {
139
+ const nextNodes = [];
140
+ for (const node of nodesQ) {
141
+ for (const parent of node.children) {
142
+ set.add(canonicalizeJson(getAxisId(parent.axis)));
143
+ nextNodes.push(parent);
144
+ }
145
+ }
146
+ nodesQ = nextNodes;
147
+ }
148
+ return set;
149
+ }
150
+ /** Get array of axisSpecs from axisTree */
151
+ function getArrayFromAxisTree(tree) {
152
+ const res = [tree.axis];
153
+ let nodesQ = [tree];
154
+ while (nodesQ.length) {
155
+ const nextNodes = [];
156
+ for (const node of nodesQ) {
157
+ for (const parent of node.children) {
158
+ res.push(parent.axis);
159
+ nextNodes.push(parent);
160
+ }
161
+ }
162
+ nodesQ = nextNodes;
163
+ }
164
+ return res;
165
+ }
166
+ function canonicalizeAxisWithParents(axis) {
167
+ return canonicalizeJson(getArrayFromAxisTree(getAxesTree(axis)).map(getAxisId));
168
+ }
169
+ function normalizingAxesComparator(axis1, axis2) {
170
+ if (axis1.name !== axis2.name) {
171
+ return axis1.name < axis2.name ? 1 : -1;
172
+ }
173
+ if (axis1.type !== axis2.type) {
174
+ return axis1.type < axis2.type ? 1 : -1;
175
+ }
176
+ const domain1 = canonicalizeJson(axis1.domain ?? {});
177
+ const domain2 = canonicalizeJson(axis2.domain ?? {});
178
+ if (domain1 !== domain2) {
179
+ return domain1 < domain2 ? 1 : -1;
180
+ }
181
+ const parents1 = canonicalizeAxisWithParents(axis1);
182
+ const parents2 = canonicalizeAxisWithParents(axis2);
183
+ if (parents1 !== parents2) {
184
+ return parents1 < parents2 ? 1 : -1;
185
+ }
186
+ const annotation1 = canonicalizeJson(axis1.annotations ?? {});
187
+ const annotation2 = canonicalizeJson(axis2.annotations ?? {});
188
+ if (annotation1 !== annotation2) {
189
+ return annotation1 < annotation2 ? 1 : -1;
190
+ }
191
+ return 0;
192
+ }
193
+ function parseParentsFromAnnotations(axis) {
194
+ const parentsList = readAnnotationJson(axis, Annotation.Parents);
195
+ if (parentsList === undefined) {
196
+ return [];
197
+ }
198
+ return parentsList;
199
+ }
200
+ function sortParentsDeep(axisSpec) {
201
+ axisSpec.parentAxesSpec.forEach(sortParentsDeep);
202
+ axisSpec.parentAxesSpec.sort(normalizingAxesComparator);
203
+ }
204
+ function hasCycleOfParents(axisSpec) {
205
+ const root = makeAxisTree(axisSpec);
206
+ let nodesQ = [root];
207
+ const ancestors = new Set(canonicalizeJson(getAxisId(axisSpec)));
208
+ while (nodesQ.length) {
209
+ const nextNodes = [];
210
+ const levelIds = new Set();
211
+ for (const node of nodesQ) {
212
+ node.children = node.axis.parentAxesSpec.map(makeAxisTree);
213
+ for (const child of node.children) {
214
+ const childId = canonicalizeJson(getAxisId(child.axis));
215
+ if (!levelIds.has(childId)) {
216
+ nextNodes.push(child);
217
+ levelIds.add(childId);
218
+ if (ancestors.has(childId)) {
219
+ return true;
220
+ }
221
+ ancestors.add(childId);
222
+ }
223
+ }
224
+ }
225
+ nodesQ = nextNodes;
226
+ }
227
+ return false;
228
+ }
229
+ /** Create list of normalized axisSpec (parents are in array of specs, not indexes) */
230
+ function getNormalizedAxesList(axes) {
231
+ if (!axes.length) {
232
+ return [];
233
+ }
234
+ const modifiedAxes = axes.map((axis) => {
235
+ const { parentAxes: _, ...copiedRest } = axis;
236
+ return { ...copiedRest, annotations: { ...copiedRest.annotations }, parentAxesSpec: [] };
237
+ });
238
+ axes.forEach((axis, idx) => {
239
+ const modifiedAxis = modifiedAxes[idx];
240
+ if (axis.parentAxes) { // if we have parents by indexes then take from the list
241
+ modifiedAxis.parentAxesSpec = axis.parentAxes.map((idx) => modifiedAxes[idx]);
242
+ }
243
+ else { // else try to parse from annotation and normalize recursively
244
+ modifiedAxis.parentAxesSpec = getNormalizedAxesList(parseParentsFromAnnotations(axis));
245
+ delete modifiedAxis.annotations?.[Annotation.Parents];
246
+ }
247
+ });
248
+ if (modifiedAxes.some(hasCycleOfParents)) { // Axes list is broken
249
+ modifiedAxes.forEach((axis) => {
250
+ axis.parentAxesSpec = [];
251
+ });
252
+ }
253
+ else {
254
+ modifiedAxes.forEach((axis) => {
255
+ sortParentsDeep(axis);
256
+ });
257
+ }
258
+ return modifiedAxes;
259
+ }
260
+ /** Create list of regular axisSpec from normalized (parents are indexes, inside of current axes list) */
261
+ function getDenormalizedAxesList(axesSpec) {
262
+ const idsList = axesSpec.map((axisSpec) => canonicalizeJson(getAxisId(axisSpec)));
263
+ return axesSpec.map((axisSpec) => {
264
+ const parentsIds = axisSpec.parentAxesSpec.map((axisSpec) => canonicalizeJson(getAxisId(axisSpec)));
265
+ const parentIdxs = parentsIds.map((id) => idsList.indexOf(id));
266
+ const { parentAxesSpec: _, ...copiedRest } = axisSpec;
267
+ if (parentIdxs.length) {
268
+ return { ...copiedRest, parentAxes: parentIdxs };
269
+ }
270
+ return copiedRest;
271
+ });
272
+ }
273
+ /// Well-known column names
274
+ const PColumnName = {
275
+ Label: 'pl7.app/label',
276
+ Table: {
277
+ RowSelection: 'pl7.app/table/row-selection',
278
+ },
279
+ };
280
+ function getPColumnSpecId(spec) {
281
+ return {
282
+ kind: spec.kind,
283
+ valueType: spec.valueType,
284
+ name: spec.name,
285
+ domain: spec.domain,
286
+ parentAxes: spec.parentAxes,
287
+ axesId: getAxesId(spec.axesSpec),
288
+ };
289
+ }
290
+ /** Get column id and spec from a column */
291
+ function getColumnIdAndSpec(column) {
292
+ return {
293
+ columnId: column.id,
294
+ spec: column.spec,
295
+ };
296
+ }
297
+ /** Extracts axis ids from axis spec */
298
+ function getAxisId(spec) {
299
+ const { type, name, domain } = spec;
300
+ const result = { type, name };
301
+ if (domain && Object.entries(domain).length > 0) {
302
+ Object.assign(result, { domain });
303
+ }
304
+ return result;
305
+ }
306
+ /** Extracts axes ids from axes spec array from column spec */
307
+ function getAxesId(spec) {
308
+ return spec.map(getAxisId);
309
+ }
310
+ /** Canonicalizes axis id */
311
+ function canonicalizeAxisId(id) {
312
+ return canonicalizeJson(getAxisId(id));
313
+ }
314
+ /** Returns true if all domains from query are found in target */
315
+ function matchDomain(query, target) {
316
+ if (query === undefined)
317
+ return target === undefined;
318
+ if (target === undefined)
319
+ return true;
320
+ for (const k in target) {
321
+ if (query[k] !== target[k])
322
+ return false;
323
+ }
324
+ return true;
325
+ }
326
+ /** Returns whether "match" axis id is compatible with the "query" */
327
+ function matchAxisId(query, target) {
328
+ return query.name === target.name && matchDomain(query.domain, target.domain);
329
+ }
330
+
331
+ export { Annotation, AnnotationJson, AxisSpec, Domain, DomainJson, PColumnName, ValueType, canonicalizeAxisId, canonicalizeAxisWithParents, getArrayFromAxisTree, getAxesId, getAxesTree, getAxisId, getColumnIdAndSpec, getDenormalizedAxesList, getNormalizedAxesList, getPColumnSpecId, getSetFromAxisTree, matchAxisId, readAnnotation, readAnnotationJson, readAnnotationJsonOrThrow, readDomain, readDomainJson, readDomainJsonOrThrow, readMetadata, readMetadataJson, readMetadataJsonOrThrow };
332
+ //# sourceMappingURL=spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec.js","sources":["../../../../src/drivers/pframe/spec/spec.ts"],"sourcesContent":["import { ensureError } from '../../../errors';\nimport {\n canonicalizeJson,\n type CanonicalizedJson,\n type StringifiedJson,\n} from '../../../json';\nimport type {\n PObject,\n PObjectId,\n PObjectSpec,\n} from '../../../pool';\nimport { z } from 'zod';\n\ntype Expect<T extends true> = T;\ntype Equal<X, Y> =\n (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;\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\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> ? z.ZodType<U> : 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} as const;\n\nexport type Domain = Metadata & Partial<{\n [Domain.Alphabet]: 'nucleotide' | 'aminoacid' | string;\n [Domain.BlockId]: 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 Alphabet: 'pl7.app/alphabet',\n DiscreteValues: 'pl7.app/discreteValues',\n Format: 'pl7.app/format',\n Graph: {\n IsVirtual: 'pl7.app/graph/isVirtual',\n },\n HideDataFromUi: 'pl7.app/hideDataFromUi',\n IsLinkerColumn: 'pl7.app/isLinkerColumn',\n Label: 'pl7.app/label',\n Max: 'pl7.app/max',\n Min: 'pl7.app/min',\n Parents: 'pl7.app/parents',\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 },\n Trace: 'pl7.app/trace',\n} as const;\n\nexport type Annotation = Metadata & Partial<{\n [Annotation.Alphabet]: 'nucleotide' | 'aminoacid' | string;\n [Annotation.DiscreteValues]: StringifiedJson<number[]> | StringifiedJson<string[]>;\n [Annotation.Format]: string;\n [Annotation.Graph.IsVirtual]: StringifiedJson<boolean>;\n [Annotation.HideDataFromUi]: StringifiedJson<boolean>;\n [Annotation.IsLinkerColumn]: StringifiedJson<boolean>;\n [Annotation.Label]: string;\n [Annotation.Max]: StringifiedJson<number>;\n [Annotation.Min]: StringifiedJson<number>;\n [Annotation.Parents]: StringifiedJson<AxisSpec[]>;\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.Trace]: StringifiedJson<Record<string, unknown>>;\n}>;\n\nexport 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();\ntype _test = Expect<Equal<\n Readonly<z.infer<typeof AxisSpec>>,\n Readonly<AxisSpec & Record<string, unknown>>\n>>;\n\nexport type AnnotationJson = MetadataJson<Annotation>;\nexport const AnnotationJson: AnnotationJson = {\n [Annotation.DiscreteValues]: z.array(z.string()).or(z.array(z.number())),\n [Annotation.Graph.IsVirtual]: z.boolean(),\n [Annotation.HideDataFromUi]: z.boolean(),\n [Annotation.IsLinkerColumn]: z.boolean(),\n [Annotation.Max]: z.number(),\n [Annotation.Min]: z.number(),\n [Annotation.Parents]: z.array(AxisSpec),\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.record(z.string(), z.unknown()),\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>(spec?.annotations, AnnotationJson, key, 'readAnnotationJsonOrThrow');\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\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 interface AxisSpec {\n /** Type of the axis value. Should not use non-key types like float or double. */\n readonly type: ValueType;\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 /** 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(axis1: AxisSpecNormalized, axis2: AxisSpecNormalized): 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 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) {\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) { // if we have parents by indexes then take from the list\n modifiedAxis.parentAxesSpec = axis.parentAxes.map((idx) => modifiedAxes[idx]);\n } else { // else try to parse from annotation and normalize recursively\n modifiedAxis.parentAxesSpec = getNormalizedAxesList(parseParentsFromAnnotations(axis));\n delete modifiedAxis.annotations?.[Annotation.Parents];\n }\n });\n\n if (modifiedAxes.some(hasCycleOfParents)) { // 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((axisSpec) => canonicalizeJson(getAxisId(axisSpec)));\n return axesSpec.map((axisSpec) => {\n const parentsIds = axisSpec.parentAxesSpec.map((axisSpec) => canonicalizeJson(getAxisId(axisSpec)));\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/** 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} as const;\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 interface PUniversalColumnSpec extends 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 /** 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 interface PDataColumnSpec extends 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 /** 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 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\n/** Information returned by {@link PFrame.listColumns} method */\nexport interface PColumnInfo extends PColumnIdAndSpec {\n /** True if data was associated with this PColumn */\n readonly hasData: boolean;\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: ValueType;\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\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 } = spec;\n const result = { type, name };\n if (domain && Object.entries(domain).length > 0) {\n Object.assign(result, { domain });\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 query.name === target.name && matchDomain(query.domain, target.domain);\n}\n"],"names":[],"mappings":";;;;AAiBO,MAAM,SAAS,GAAG;AACvB,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,KAAK,EAAE,OAAO;AACd,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,KAAK,EAAE,OAAO;;AAQV,SAAU,YAAY,CAC1B,QAA8B,EAC9B,GAAM,EAAA;AAEN,IAAA,OAAQ,QAA0B,GAAG,GAAG,CAAC;AAC3C;AAOM,SAAU,uBAAuB,CACrC,QAA8B,EAC9B,YAA6B,EAC7B,GAAM,EACN,iBAAA,GAA4B,yBAAyB,EAAA;IAErD,MAAM,IAAI,GAAG,YAAY,CAAO,QAAQ,EAAE,GAAG,CAAC;IAC9C,IAAI,IAAI,KAAK,SAAS;AAAE,QAAA,OAAO,SAAS;AAExC,IAAA,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC;AAChC,IAAA,IAAI;QACF,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;AAC9B,QAAA,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;IAC5B;IAAE,OAAO,KAAc,EAAE;AACvB,QAAA,MAAM,IAAI,KAAK,CACb,CAAA,EAAG,iBAAiB,CAAA,SAAA;AAClB,cAAA,CAAA,KAAA,EAAQ,MAAM,CAAC,GAAG,CAAC,CAAA,EAAA;AACnB,cAAA,CAAA,OAAA,EAAU,IAAI,CAAA,EAAA;AACd,cAAA,CAAA,OAAA,EAAU,WAAW,CA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AS;AAAE,QAAA,OAAO,IAAI;AACrC,IAAA,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE;QACtB,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC;AAAE,YAAA,OAAO,KAAK;IAC1C;AACA,IAAA,OAAO,IAAI;AACb;AAEA;AACM,SAAU,WAAW,CAAC,KAAa,EAAE,MAAc,EAAA;AACvD,IAAA,OAAO,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,IAAI,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;AAC/E;;;;"}
@@ -26,4 +26,3 @@ export interface PTable {
26
26
  * */
27
27
  getData(columnIndices: number[], range?: TableRange): Promise<PTableVector[]>;
28
28
  }
29
- //# sourceMappingURL=table.d.ts.map
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+
3
+ var util = require('../../util.cjs');
4
+
5
+ function mapPTableDef(def, cb) {
6
+ return { ...def, src: mapJoinEntry(def.src, cb) };
7
+ }
8
+ function mapJoinEntry(entry, cb) {
9
+ switch (entry.type) {
10
+ case 'column':
11
+ return {
12
+ type: 'column',
13
+ column: cb(entry.column),
14
+ };
15
+ case 'slicedColumn':
16
+ return {
17
+ type: 'slicedColumn',
18
+ column: cb(entry.column),
19
+ newId: entry.newId,
20
+ axisFilters: entry.axisFilters,
21
+ };
22
+ case 'inlineColumn':
23
+ return entry;
24
+ case 'inner':
25
+ case 'full':
26
+ return {
27
+ type: entry.type,
28
+ entries: entry.entries.map((col) => mapJoinEntry(col, cb)),
29
+ };
30
+ case 'outer':
31
+ return {
32
+ type: 'outer',
33
+ primary: mapJoinEntry(entry.primary, cb),
34
+ secondary: entry.secondary.map((col) => mapJoinEntry(col, cb)),
35
+ };
36
+ default:
37
+ util.assertNever(entry);
38
+ }
39
+ }
40
+
41
+ exports.mapJoinEntry = mapJoinEntry;
42
+ exports.mapPTableDef = mapPTableDef;
43
+ //# sourceMappingURL=table_calculate.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table_calculate.cjs","sources":["../../../src/drivers/pframe/table_calculate.ts"],"sourcesContent":["import type { PTableColumnId, PTableColumnSpec } from './table_common';\nimport type { PTableVector } from './data_types';\nimport type { PObjectId } from '../../pool';\nimport { assertNever } from '../../util';\nimport type { PColumn } from './spec/spec';\nimport type { PColumnValues } from './data_info';\n\n/** Defines a terminal column node in the join request tree */\nexport interface ColumnJoinEntry<Col> {\n /** Node type discriminator */\n readonly type: 'column';\n\n /** Local column */\n readonly column: Col;\n}\n\n/**\n * Axis filter slicing target axis from column axes.\n * If the axis has parents or is a parent, slicing cannot be applied (an error will be thrown).\n * */\nexport interface ConstantAxisFilter {\n /** Filter type discriminator */\n readonly type: 'constant';\n\n /** Index of axis to slice (zero-based) */\n readonly axisIndex: number;\n\n /** Equality filter reference value, see {@link SingleValueEqualPredicate} */\n readonly constant: string | number;\n}\n\n/** Defines a terminal column node in the join request tree */\nexport interface SlicedColumnJoinEntry<Col> {\n /** Node type discriminator */\n readonly type: 'slicedColumn';\n\n /** Local column */\n readonly column: Col;\n\n /** New column id */\n readonly newId: PObjectId;\n\n /** Non-empty list of axis filters */\n readonly axisFilters: ConstantAxisFilter[];\n}\n\n/** Defines a terminal column node in the join request tree */\nexport interface InlineColumnJoinEntry {\n /** Node type discriminator */\n readonly type: 'inlineColumn';\n\n /** Column definition */\n readonly column: PColumn<PColumnValues>;\n}\n\n/**\n * Defines a join request tree node that will output only records present in\n * all child nodes ({@link entries}).\n * */\nexport interface InnerJoin<Col> {\n /** Node type discriminator */\n readonly type: 'inner';\n\n /** Child nodes to be inner joined */\n readonly entries: JoinEntry<Col>[];\n}\n\n/**\n * Defines a join request tree node that will output all records present at\n * least in one of the child nodes ({@link entries}), values for those PColumns\n * that lacks corresponding combinations of axis values will be marked as absent,\n * see {@link PTableVector.absent}.\n * */\nexport interface FullJoin<Col> {\n /** Node type discriminator */\n readonly type: 'full';\n\n /** Child nodes to be fully outer joined */\n readonly entries: JoinEntry<Col>[];\n}\n\n/**\n * Defines a join request tree node that will output all records present in\n * {@link primary} child node, and records from the {@link secondary} nodes will\n * be added to the output only if present, values for those PColumns from the\n * {@link secondary} list, that lacks corresponding combinations of axis values\n * will be marked as absent, see {@link PTableVector.absent}.\n *\n * This node can be thought as a chain of SQL LEFT JOIN operations starting from\n * the {@link primary} node and adding {@link secondary} nodes one by one.\n * */\nexport interface OuterJoin<Col> {\n /** Node type discriminator */\n readonly type: 'outer';\n\n /** Primes the join operation. Left part of LEFT JOIN. */\n readonly primary: JoinEntry<Col>;\n\n /** Driven nodes, giving their values only if primary node have corresponding\n * nodes. Right parts of LEFT JOIN chain. */\n readonly secondary: JoinEntry<Col>[];\n}\n\n/**\n * Base type of all join request tree nodes. Join request tree allows to combine\n * information from multiple PColumns into a PTable. Correlation between records\n * is performed by looking for records with the same values in common axis between\n * the PColumns. Common axis are those axis which have equal {@link AxisId} derived\n * from the columns axes spec.\n * */\nexport type JoinEntry<Col> =\n | ColumnJoinEntry<Col>\n | SlicedColumnJoinEntry<Col>\n | InlineColumnJoinEntry\n | InnerJoin<Col>\n | FullJoin<Col>\n | OuterJoin<Col>;\n\n/** Container representing whole data stored in specific PTable column. */\nexport interface FullPTableColumnData {\n /** Unified spec */\n readonly spec: PTableColumnSpec;\n\n /** Data */\n readonly data: PTableVector;\n}\n\nexport interface SingleValueIsNAPredicate {\n /** Comparison operator */\n readonly operator: 'IsNA';\n}\n\nexport interface SingleValueEqualPredicate {\n /** Comparison operator */\n readonly operator: 'Equal';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueInSetPredicate {\n /** Comparison operator */\n readonly operator: 'InSet';\n\n /** Reference values, NA values will not match */\n readonly references: (string | number)[];\n}\n\nexport interface SingleValueIEqualPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: 'IEqual';\n\n /** Reference value, NA values will not match */\n readonly reference: string;\n}\n\nexport interface SingleValueLessPredicate {\n /** Comparison operator */\n readonly operator: 'Less';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueLessOrEqualPredicate {\n /** Comparison operator */\n readonly operator: 'LessOrEqual';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueGreaterPredicate {\n /** Comparison operator */\n readonly operator: 'Greater';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueGreaterOrEqualPredicate {\n /** Comparison operator */\n readonly operator: 'GreaterOrEqual';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueStringContainsPredicate {\n /** Comparison operator */\n readonly operator: 'StringContains';\n\n /** Reference substring, NA values are skipped */\n readonly substring: string;\n}\n\nexport interface SingleValueStringIContainsPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: 'StringIContains';\n\n /** Reference substring, NA values are skipped */\n readonly substring: string;\n}\n\nexport interface SingleValueMatchesPredicate {\n /** Comparison operator */\n readonly operator: 'Matches';\n\n /** Regular expression, NA values are skipped */\n readonly regex: string;\n}\n\nexport interface SingleValueStringContainsFuzzyPredicate {\n /** Comparison operator */\n readonly operator: 'StringContainsFuzzy';\n\n /** Reference value, NA values are skipped */\n readonly reference: string;\n\n /**\n * Integer specifying the upper bound of edit distance between\n * reference and actual value.\n * When {@link substitutionsOnly} is not defined or set to false\n * Levenshtein distance is used (substitutions and indels)\n * @see https://en.wikipedia.org/wiki/Levenshtein_distance\n * When {@link substitutionsOnly} is set to true\n * Hamming distance is used (substitutions only)\n * @see https://en.wikipedia.org/wiki/Hamming_distance\n */\n readonly maxEdits: number;\n\n /** Changes the type of edit distance in {@link maxEdits} */\n readonly substitutionsOnly?: boolean;\n\n /**\n * Some character in {@link reference} that will match any\n * single character in searched text.\n */\n readonly wildcard?: string;\n}\n\nexport interface SingleValueStringIContainsFuzzyPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: 'StringIContainsFuzzy';\n\n /** Reference value, NA values are skipped */\n readonly reference: string;\n\n /**\n * Integer specifying the upper bound of edit distance between\n * reference and actual value.\n * When {@link substitutionsOnly} is not defined or set to false\n * Levenshtein distance is used (substitutions and indels)\n * @see https://en.wikipedia.org/wiki/Levenshtein_distance\n * When {@link substitutionsOnly} is set to true\n * Hamming distance is used (substitutions only)\n * @see https://en.wikipedia.org/wiki/Hamming_distance\n */\n readonly maxEdits: number;\n\n /** Changes the type of edit distance in {@link maxEdits} */\n readonly substitutionsOnly?: boolean;\n\n /**\n * Some character in {@link reference} that will match any\n * single character in searched text.\n */\n readonly wildcard?: string;\n}\n\nexport interface SingleValueNotPredicateV2 {\n /** Comparison operator */\n readonly operator: 'Not';\n\n /** Operand to negate */\n readonly operand: SingleValuePredicateV2;\n}\n\nexport interface SingleValueAndPredicateV2 {\n /** Comparison operator */\n readonly operator: 'And';\n\n /** Operands to combine */\n readonly operands: SingleValuePredicateV2[];\n}\n\nexport interface SingleValueOrPredicateV2 {\n /** Comparison operator */\n readonly operator: 'Or';\n\n /** Operands to combine */\n readonly operands: SingleValuePredicateV2[];\n}\n\n/** Filtering predicate for a single axis or column value */\nexport type SingleValuePredicateV2 =\n | SingleValueIsNAPredicate\n | SingleValueEqualPredicate\n | SingleValueInSetPredicate\n | SingleValueLessPredicate\n | SingleValueLessOrEqualPredicate\n | SingleValueGreaterPredicate\n | SingleValueGreaterOrEqualPredicate\n | SingleValueStringContainsPredicate\n | SingleValueMatchesPredicate\n | SingleValueStringContainsFuzzyPredicate\n | SingleValueNotPredicateV2\n | SingleValueAndPredicateV2\n | SingleValueOrPredicateV2\n | SingleValueIEqualPredicate\n | SingleValueStringIContainsPredicate\n | SingleValueStringIContainsFuzzyPredicate;\n\n/**\n * Filter PTable records based on specific axis or column value. If this is an\n * axis value filter and the axis is part of a partitioning key in some of the\n * source PColumns, the filter will be pushed down to those columns, so only\n * specific partitions will be retrieved from the remote storage.\n * */\nexport interface PTableRecordSingleValueFilterV2 {\n /** Filter type discriminator */\n readonly type: 'bySingleColumnV2';\n\n /** Target axis selector to examine values from */\n readonly column: PTableColumnId;\n\n /** Value predicate */\n readonly predicate: SingleValuePredicateV2;\n}\n\n/** Generic PTable records filter */\nexport type PTableRecordFilter = PTableRecordSingleValueFilterV2;\n\n/** Sorting parameters for a PTable. */\nexport type PTableSorting = {\n /** Unified column identifier */\n readonly column: PTableColumnId;\n\n /** Sorting order */\n readonly ascending: boolean;\n\n /** Sorting in respect to NA and absent values */\n readonly naAndAbsentAreLeastValues: boolean;\n};\n\n/** Information required to instantiate a PTable. */\nexport interface PTableDef<Col> {\n /** Join tree to populate the PTable */\n readonly src: JoinEntry<Col>;\n\n /** Partition filters */\n readonly partitionFilters: PTableRecordFilter[];\n\n /** Record filters */\n readonly filters: PTableRecordFilter[];\n\n /** Table sorting */\n readonly sorting: PTableSorting[];\n}\n\n/** Request to create and retrieve entirety of data of PTable. */\nexport type CalculateTableDataRequest<Col> = {\n /** Join tree to populate the PTable */\n readonly src: JoinEntry<Col>;\n\n /** Record filters */\n readonly filters: PTableRecordFilter[];\n\n /** Table sorting */\n readonly sorting: PTableSorting[];\n};\n\n/** Response for {@link CalculateTableDataRequest} */\nexport type CalculateTableDataResponse = FullPTableColumnData[];\n\nexport function mapPTableDef<C1, C2>(\n def: PTableDef<C1>,\n cb: (c: C1) => C2,\n): PTableDef<C2> {\n return { ...def, src: mapJoinEntry(def.src, cb) };\n}\n\nexport function mapJoinEntry<C1, C2>(\n entry: JoinEntry<C1>,\n cb: (c: C1) => C2,\n): JoinEntry<C2> {\n switch (entry.type) {\n case 'column':\n return {\n type: 'column',\n column: cb(entry.column),\n };\n case 'slicedColumn':\n return {\n type: 'slicedColumn',\n column: cb(entry.column),\n newId: entry.newId,\n axisFilters: entry.axisFilters,\n };\n case 'inlineColumn':\n return entry;\n case 'inner':\n case 'full':\n return {\n type: entry.type,\n entries: entry.entries.map((col) => mapJoinEntry(col, cb)),\n };\n case 'outer':\n return {\n type: 'outer',\n primary: mapJoinEntry(entry.primary, cb),\n secondary: entry.secondary.map((col) => mapJoinEntry(col, cb)),\n };\n default:\n assertNever(entry);\n }\n}\n"],"names":["assertNever"],"mappings":";;;;AAuXM,SAAU,YAAY,CAC1B,GAAkB,EAClB,EAAiB,EAAA;AAEjB,IAAA,OAAO,EAAE,GAAG,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE;AACnD;AAEM,SAAU,YAAY,CAC1B,KAAoB,EACpB,EAAiB,EAAA;AAEjB,IAAA,QAAQ,KAAK,CAAC,IAAI;AAChB,QAAA,KAAK,QAAQ;YACX,OAAO;AACL,gBAAA,IAAI,EAAE,QAAQ;AACd,gBAAA,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;aACzB;AACH,QAAA,KAAK,cAAc;YACjB,OAAO;AACL,gBAAA,IAAI,EAAE,cAAc;AACpB,gBAAA,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;gBACxB,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,WAAW,EAAE,KAAK,CAAC,WAAW;aAC/B;AACH,QAAA,KAAK,cAAc;AACjB,YAAA,OAAO,KAAK;AACd,QAAA,KAAK,OAAO;AACZ,QAAA,KAAK,MAAM;YACT,OAAO;gBACL,IAAI,EAAE,KAAK,CAAC,IAAI;AAChB,gBAAA,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,YAAY,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;aAC3D;AACH,QAAA,KAAK,OAAO;YACV,OAAO;AACL,gBAAA,IAAI,EAAE,OAAO;gBACb,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;AACxC,gBAAA,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,YAAY,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;aAC/D;AACH,QAAA;YACEA,gBAAW,CAAC,KAAK,CAAC;;AAExB;;;;;"}
@@ -277,4 +277,3 @@ export type CalculateTableDataRequest<Col> = {
277
277
  export type CalculateTableDataResponse = FullPTableColumnData[];
278
278
  export declare function mapPTableDef<C1, C2>(def: PTableDef<C1>, cb: (c: C1) => C2): PTableDef<C2>;
279
279
  export declare function mapJoinEntry<C1, C2>(entry: JoinEntry<C1>, cb: (c: C1) => C2): JoinEntry<C2>;
280
- //# sourceMappingURL=table_calculate.d.ts.map
@@ -0,0 +1,40 @@
1
+ import { assertNever } from '../../util.js';
2
+
3
+ function mapPTableDef(def, cb) {
4
+ return { ...def, src: mapJoinEntry(def.src, cb) };
5
+ }
6
+ function mapJoinEntry(entry, cb) {
7
+ switch (entry.type) {
8
+ case 'column':
9
+ return {
10
+ type: 'column',
11
+ column: cb(entry.column),
12
+ };
13
+ case 'slicedColumn':
14
+ return {
15
+ type: 'slicedColumn',
16
+ column: cb(entry.column),
17
+ newId: entry.newId,
18
+ axisFilters: entry.axisFilters,
19
+ };
20
+ case 'inlineColumn':
21
+ return entry;
22
+ case 'inner':
23
+ case 'full':
24
+ return {
25
+ type: entry.type,
26
+ entries: entry.entries.map((col) => mapJoinEntry(col, cb)),
27
+ };
28
+ case 'outer':
29
+ return {
30
+ type: 'outer',
31
+ primary: mapJoinEntry(entry.primary, cb),
32
+ secondary: entry.secondary.map((col) => mapJoinEntry(col, cb)),
33
+ };
34
+ default:
35
+ assertNever(entry);
36
+ }
37
+ }
38
+
39
+ export { mapJoinEntry, mapPTableDef };
40
+ //# sourceMappingURL=table_calculate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table_calculate.js","sources":["../../../src/drivers/pframe/table_calculate.ts"],"sourcesContent":["import type { PTableColumnId, PTableColumnSpec } from './table_common';\nimport type { PTableVector } from './data_types';\nimport type { PObjectId } from '../../pool';\nimport { assertNever } from '../../util';\nimport type { PColumn } from './spec/spec';\nimport type { PColumnValues } from './data_info';\n\n/** Defines a terminal column node in the join request tree */\nexport interface ColumnJoinEntry<Col> {\n /** Node type discriminator */\n readonly type: 'column';\n\n /** Local column */\n readonly column: Col;\n}\n\n/**\n * Axis filter slicing target axis from column axes.\n * If the axis has parents or is a parent, slicing cannot be applied (an error will be thrown).\n * */\nexport interface ConstantAxisFilter {\n /** Filter type discriminator */\n readonly type: 'constant';\n\n /** Index of axis to slice (zero-based) */\n readonly axisIndex: number;\n\n /** Equality filter reference value, see {@link SingleValueEqualPredicate} */\n readonly constant: string | number;\n}\n\n/** Defines a terminal column node in the join request tree */\nexport interface SlicedColumnJoinEntry<Col> {\n /** Node type discriminator */\n readonly type: 'slicedColumn';\n\n /** Local column */\n readonly column: Col;\n\n /** New column id */\n readonly newId: PObjectId;\n\n /** Non-empty list of axis filters */\n readonly axisFilters: ConstantAxisFilter[];\n}\n\n/** Defines a terminal column node in the join request tree */\nexport interface InlineColumnJoinEntry {\n /** Node type discriminator */\n readonly type: 'inlineColumn';\n\n /** Column definition */\n readonly column: PColumn<PColumnValues>;\n}\n\n/**\n * Defines a join request tree node that will output only records present in\n * all child nodes ({@link entries}).\n * */\nexport interface InnerJoin<Col> {\n /** Node type discriminator */\n readonly type: 'inner';\n\n /** Child nodes to be inner joined */\n readonly entries: JoinEntry<Col>[];\n}\n\n/**\n * Defines a join request tree node that will output all records present at\n * least in one of the child nodes ({@link entries}), values for those PColumns\n * that lacks corresponding combinations of axis values will be marked as absent,\n * see {@link PTableVector.absent}.\n * */\nexport interface FullJoin<Col> {\n /** Node type discriminator */\n readonly type: 'full';\n\n /** Child nodes to be fully outer joined */\n readonly entries: JoinEntry<Col>[];\n}\n\n/**\n * Defines a join request tree node that will output all records present in\n * {@link primary} child node, and records from the {@link secondary} nodes will\n * be added to the output only if present, values for those PColumns from the\n * {@link secondary} list, that lacks corresponding combinations of axis values\n * will be marked as absent, see {@link PTableVector.absent}.\n *\n * This node can be thought as a chain of SQL LEFT JOIN operations starting from\n * the {@link primary} node and adding {@link secondary} nodes one by one.\n * */\nexport interface OuterJoin<Col> {\n /** Node type discriminator */\n readonly type: 'outer';\n\n /** Primes the join operation. Left part of LEFT JOIN. */\n readonly primary: JoinEntry<Col>;\n\n /** Driven nodes, giving their values only if primary node have corresponding\n * nodes. Right parts of LEFT JOIN chain. */\n readonly secondary: JoinEntry<Col>[];\n}\n\n/**\n * Base type of all join request tree nodes. Join request tree allows to combine\n * information from multiple PColumns into a PTable. Correlation between records\n * is performed by looking for records with the same values in common axis between\n * the PColumns. Common axis are those axis which have equal {@link AxisId} derived\n * from the columns axes spec.\n * */\nexport type JoinEntry<Col> =\n | ColumnJoinEntry<Col>\n | SlicedColumnJoinEntry<Col>\n | InlineColumnJoinEntry\n | InnerJoin<Col>\n | FullJoin<Col>\n | OuterJoin<Col>;\n\n/** Container representing whole data stored in specific PTable column. */\nexport interface FullPTableColumnData {\n /** Unified spec */\n readonly spec: PTableColumnSpec;\n\n /** Data */\n readonly data: PTableVector;\n}\n\nexport interface SingleValueIsNAPredicate {\n /** Comparison operator */\n readonly operator: 'IsNA';\n}\n\nexport interface SingleValueEqualPredicate {\n /** Comparison operator */\n readonly operator: 'Equal';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueInSetPredicate {\n /** Comparison operator */\n readonly operator: 'InSet';\n\n /** Reference values, NA values will not match */\n readonly references: (string | number)[];\n}\n\nexport interface SingleValueIEqualPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: 'IEqual';\n\n /** Reference value, NA values will not match */\n readonly reference: string;\n}\n\nexport interface SingleValueLessPredicate {\n /** Comparison operator */\n readonly operator: 'Less';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueLessOrEqualPredicate {\n /** Comparison operator */\n readonly operator: 'LessOrEqual';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueGreaterPredicate {\n /** Comparison operator */\n readonly operator: 'Greater';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueGreaterOrEqualPredicate {\n /** Comparison operator */\n readonly operator: 'GreaterOrEqual';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueStringContainsPredicate {\n /** Comparison operator */\n readonly operator: 'StringContains';\n\n /** Reference substring, NA values are skipped */\n readonly substring: string;\n}\n\nexport interface SingleValueStringIContainsPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: 'StringIContains';\n\n /** Reference substring, NA values are skipped */\n readonly substring: string;\n}\n\nexport interface SingleValueMatchesPredicate {\n /** Comparison operator */\n readonly operator: 'Matches';\n\n /** Regular expression, NA values are skipped */\n readonly regex: string;\n}\n\nexport interface SingleValueStringContainsFuzzyPredicate {\n /** Comparison operator */\n readonly operator: 'StringContainsFuzzy';\n\n /** Reference value, NA values are skipped */\n readonly reference: string;\n\n /**\n * Integer specifying the upper bound of edit distance between\n * reference and actual value.\n * When {@link substitutionsOnly} is not defined or set to false\n * Levenshtein distance is used (substitutions and indels)\n * @see https://en.wikipedia.org/wiki/Levenshtein_distance\n * When {@link substitutionsOnly} is set to true\n * Hamming distance is used (substitutions only)\n * @see https://en.wikipedia.org/wiki/Hamming_distance\n */\n readonly maxEdits: number;\n\n /** Changes the type of edit distance in {@link maxEdits} */\n readonly substitutionsOnly?: boolean;\n\n /**\n * Some character in {@link reference} that will match any\n * single character in searched text.\n */\n readonly wildcard?: string;\n}\n\nexport interface SingleValueStringIContainsFuzzyPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: 'StringIContainsFuzzy';\n\n /** Reference value, NA values are skipped */\n readonly reference: string;\n\n /**\n * Integer specifying the upper bound of edit distance between\n * reference and actual value.\n * When {@link substitutionsOnly} is not defined or set to false\n * Levenshtein distance is used (substitutions and indels)\n * @see https://en.wikipedia.org/wiki/Levenshtein_distance\n * When {@link substitutionsOnly} is set to true\n * Hamming distance is used (substitutions only)\n * @see https://en.wikipedia.org/wiki/Hamming_distance\n */\n readonly maxEdits: number;\n\n /** Changes the type of edit distance in {@link maxEdits} */\n readonly substitutionsOnly?: boolean;\n\n /**\n * Some character in {@link reference} that will match any\n * single character in searched text.\n */\n readonly wildcard?: string;\n}\n\nexport interface SingleValueNotPredicateV2 {\n /** Comparison operator */\n readonly operator: 'Not';\n\n /** Operand to negate */\n readonly operand: SingleValuePredicateV2;\n}\n\nexport interface SingleValueAndPredicateV2 {\n /** Comparison operator */\n readonly operator: 'And';\n\n /** Operands to combine */\n readonly operands: SingleValuePredicateV2[];\n}\n\nexport interface SingleValueOrPredicateV2 {\n /** Comparison operator */\n readonly operator: 'Or';\n\n /** Operands to combine */\n readonly operands: SingleValuePredicateV2[];\n}\n\n/** Filtering predicate for a single axis or column value */\nexport type SingleValuePredicateV2 =\n | SingleValueIsNAPredicate\n | SingleValueEqualPredicate\n | SingleValueInSetPredicate\n | SingleValueLessPredicate\n | SingleValueLessOrEqualPredicate\n | SingleValueGreaterPredicate\n | SingleValueGreaterOrEqualPredicate\n | SingleValueStringContainsPredicate\n | SingleValueMatchesPredicate\n | SingleValueStringContainsFuzzyPredicate\n | SingleValueNotPredicateV2\n | SingleValueAndPredicateV2\n | SingleValueOrPredicateV2\n | SingleValueIEqualPredicate\n | SingleValueStringIContainsPredicate\n | SingleValueStringIContainsFuzzyPredicate;\n\n/**\n * Filter PTable records based on specific axis or column value. If this is an\n * axis value filter and the axis is part of a partitioning key in some of the\n * source PColumns, the filter will be pushed down to those columns, so only\n * specific partitions will be retrieved from the remote storage.\n * */\nexport interface PTableRecordSingleValueFilterV2 {\n /** Filter type discriminator */\n readonly type: 'bySingleColumnV2';\n\n /** Target axis selector to examine values from */\n readonly column: PTableColumnId;\n\n /** Value predicate */\n readonly predicate: SingleValuePredicateV2;\n}\n\n/** Generic PTable records filter */\nexport type PTableRecordFilter = PTableRecordSingleValueFilterV2;\n\n/** Sorting parameters for a PTable. */\nexport type PTableSorting = {\n /** Unified column identifier */\n readonly column: PTableColumnId;\n\n /** Sorting order */\n readonly ascending: boolean;\n\n /** Sorting in respect to NA and absent values */\n readonly naAndAbsentAreLeastValues: boolean;\n};\n\n/** Information required to instantiate a PTable. */\nexport interface PTableDef<Col> {\n /** Join tree to populate the PTable */\n readonly src: JoinEntry<Col>;\n\n /** Partition filters */\n readonly partitionFilters: PTableRecordFilter[];\n\n /** Record filters */\n readonly filters: PTableRecordFilter[];\n\n /** Table sorting */\n readonly sorting: PTableSorting[];\n}\n\n/** Request to create and retrieve entirety of data of PTable. */\nexport type CalculateTableDataRequest<Col> = {\n /** Join tree to populate the PTable */\n readonly src: JoinEntry<Col>;\n\n /** Record filters */\n readonly filters: PTableRecordFilter[];\n\n /** Table sorting */\n readonly sorting: PTableSorting[];\n};\n\n/** Response for {@link CalculateTableDataRequest} */\nexport type CalculateTableDataResponse = FullPTableColumnData[];\n\nexport function mapPTableDef<C1, C2>(\n def: PTableDef<C1>,\n cb: (c: C1) => C2,\n): PTableDef<C2> {\n return { ...def, src: mapJoinEntry(def.src, cb) };\n}\n\nexport function mapJoinEntry<C1, C2>(\n entry: JoinEntry<C1>,\n cb: (c: C1) => C2,\n): JoinEntry<C2> {\n switch (entry.type) {\n case 'column':\n return {\n type: 'column',\n column: cb(entry.column),\n };\n case 'slicedColumn':\n return {\n type: 'slicedColumn',\n column: cb(entry.column),\n newId: entry.newId,\n axisFilters: entry.axisFilters,\n };\n case 'inlineColumn':\n return entry;\n case 'inner':\n case 'full':\n return {\n type: entry.type,\n entries: entry.entries.map((col) => mapJoinEntry(col, cb)),\n };\n case 'outer':\n return {\n type: 'outer',\n primary: mapJoinEntry(entry.primary, cb),\n secondary: entry.secondary.map((col) => mapJoinEntry(col, cb)),\n };\n default:\n assertNever(entry);\n }\n}\n"],"names":[],"mappings":";;AAuXM,SAAU,YAAY,CAC1B,GAAkB,EAClB,EAAiB,EAAA;AAEjB,IAAA,OAAO,EAAE,GAAG,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE;AACnD;AAEM,SAAU,YAAY,CAC1B,KAAoB,EACpB,EAAiB,EAAA;AAEjB,IAAA,QAAQ,KAAK,CAAC,IAAI;AAChB,QAAA,KAAK,QAAQ;YACX,OAAO;AACL,gBAAA,IAAI,EAAE,QAAQ;AACd,gBAAA,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;aACzB;AACH,QAAA,KAAK,cAAc;YACjB,OAAO;AACL,gBAAA,IAAI,EAAE,cAAc;AACpB,gBAAA,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;gBACxB,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,WAAW,EAAE,KAAK,CAAC,WAAW;aAC/B;AACH,QAAA,KAAK,cAAc;AACjB,YAAA,OAAO,KAAK;AACd,QAAA,KAAK,OAAO;AACZ,QAAA,KAAK,MAAM;YACT,OAAO;gBACL,IAAI,EAAE,KAAK,CAAC,IAAI;AAChB,gBAAA,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,YAAY,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;aAC3D;AACH,QAAA,KAAK,OAAO;YACV,OAAO;AACL,gBAAA,IAAI,EAAE,OAAO;gBACb,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;AACxC,gBAAA,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,YAAY,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;aAC/D;AACH,QAAA;YACE,WAAW,CAAC,KAAK,CAAC;;AAExB;;;;"}
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ function getPTableColumnId(spec) {
4
+ switch (spec.type) {
5
+ case 'axis':
6
+ return {
7
+ type: 'axis',
8
+ id: spec.id,
9
+ };
10
+ case 'column':
11
+ return {
12
+ type: 'column',
13
+ id: spec.id,
14
+ };
15
+ }
16
+ }
17
+
18
+ exports.getPTableColumnId = getPTableColumnId;
19
+ //# sourceMappingURL=table_common.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table_common.cjs","sources":["../../../src/drivers/pframe/table_common.ts"],"sourcesContent":["import type { PObjectId } from '../../pool';\nimport type { AxisId, AxisSpec, PColumnSpec } from './spec/spec';\n\nexport type PTableColumnSpecAxis = {\n type: 'axis';\n id: AxisId;\n spec: AxisSpec;\n};\n\nexport type PTableColumnSpecColumn = {\n type: 'column';\n id: PObjectId;\n spec: PColumnSpec;\n};\n\n/** Unified spec object for axes and columns */\nexport type PTableColumnSpec = PTableColumnSpecAxis | PTableColumnSpecColumn;\n\nexport type PTableColumnIdAxis = {\n type: 'axis';\n id: AxisId;\n};\n\nexport type PTableColumnIdColumn = {\n type: 'column';\n id: PObjectId;\n};\n\n/** Unified PTable column identifier */\nexport type PTableColumnId = PTableColumnIdAxis | PTableColumnIdColumn;\n\nexport function getPTableColumnId(spec: PTableColumnSpec): PTableColumnId {\n switch (spec.type) {\n case 'axis':\n return {\n type: 'axis',\n id: spec.id,\n };\n case 'column':\n return {\n type: 'column',\n id: spec.id,\n };\n }\n}\n"],"names":[],"mappings":";;AA+BM,SAAU,iBAAiB,CAAC,IAAsB,EAAA;AACtD,IAAA,QAAQ,IAAI,CAAC,IAAI;AACf,QAAA,KAAK,MAAM;YACT,OAAO;AACL,gBAAA,IAAI,EAAE,MAAM;gBACZ,EAAE,EAAE,IAAI,CAAC,EAAE;aACZ;AACH,QAAA,KAAK,QAAQ;YACX,OAAO;AACL,gBAAA,IAAI,EAAE,QAAQ;gBACd,EAAE,EAAE,IAAI,CAAC,EAAE;aACZ;;AAEP;;;;"}
@@ -23,4 +23,3 @@ export type PTableColumnIdColumn = {
23
23
  /** Unified PTable column identifier */
24
24
  export type PTableColumnId = PTableColumnIdAxis | PTableColumnIdColumn;
25
25
  export declare function getPTableColumnId(spec: PTableColumnSpec): PTableColumnId;
26
- //# sourceMappingURL=table_common.d.ts.map
@@ -0,0 +1,17 @@
1
+ function getPTableColumnId(spec) {
2
+ switch (spec.type) {
3
+ case 'axis':
4
+ return {
5
+ type: 'axis',
6
+ id: spec.id,
7
+ };
8
+ case 'column':
9
+ return {
10
+ type: 'column',
11
+ id: spec.id,
12
+ };
13
+ }
14
+ }
15
+
16
+ export { getPTableColumnId };
17
+ //# sourceMappingURL=table_common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table_common.js","sources":["../../../src/drivers/pframe/table_common.ts"],"sourcesContent":["import type { PObjectId } from '../../pool';\nimport type { AxisId, AxisSpec, PColumnSpec } from './spec/spec';\n\nexport type PTableColumnSpecAxis = {\n type: 'axis';\n id: AxisId;\n spec: AxisSpec;\n};\n\nexport type PTableColumnSpecColumn = {\n type: 'column';\n id: PObjectId;\n spec: PColumnSpec;\n};\n\n/** Unified spec object for axes and columns */\nexport type PTableColumnSpec = PTableColumnSpecAxis | PTableColumnSpecColumn;\n\nexport type PTableColumnIdAxis = {\n type: 'axis';\n id: AxisId;\n};\n\nexport type PTableColumnIdColumn = {\n type: 'column';\n id: PObjectId;\n};\n\n/** Unified PTable column identifier */\nexport type PTableColumnId = PTableColumnIdAxis | PTableColumnIdColumn;\n\nexport function getPTableColumnId(spec: PTableColumnSpec): PTableColumnId {\n switch (spec.type) {\n case 'axis':\n return {\n type: 'axis',\n id: spec.id,\n };\n case 'column':\n return {\n type: 'column',\n id: spec.id,\n };\n }\n}\n"],"names":[],"mappings":"AA+BM,SAAU,iBAAiB,CAAC,IAAsB,EAAA;AACtD,IAAA,QAAQ,IAAI,CAAC,IAAI;AACf,QAAA,KAAK,MAAM;YACT,OAAO;AACL,gBAAA,IAAI,EAAE,MAAM;gBACZ,EAAE,EAAE,IAAI,CAAC,EAAE;aACZ;AACH,QAAA,KAAK,QAAQ;YACX,OAAO;AACL,gBAAA,IAAI,EAAE,QAAQ;gBACd,EAAE,EAAE,IAAI,CAAC,EAAE;aACZ;;AAEP;;;;"}
@@ -2,4 +2,3 @@ export type AddParameters<TParameters extends [...args: any], TFunction extends
2
2
  export type AddParameterToAllMethods<Interface, TParameters extends [...args: any]> = {
3
3
  [Field in keyof Interface]: Interface[Field] extends (...args: any) => any ? AddParameters<TParameters, Interface[Field]> : Interface[Field];
4
4
  };
5
- //# sourceMappingURL=type_util.d.ts.map
@@ -19,4 +19,3 @@ export interface UniqueValuesResponse {
19
19
  /** True if limit was reached and response contain non-exhaustive list of values. */
20
20
  readonly overflow: boolean;
21
21
  }
22
- //# sourceMappingURL=unique_values.d.ts.map
@@ -19,4 +19,3 @@ export interface ImportStatus {
19
19
  readonly bytesProcessed?: number;
20
20
  readonly bytesTotal?: number;
21
21
  }
22
- //# sourceMappingURL=upload.d.ts.map