@milaboratories/pl-model-common 1.19.7 → 1.19.9

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 (238) 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/drivers/pframe/type_util.ts +1 -0
  179. package/src/flags/type_utils.ts +1 -0
  180. package/src/index.ts +10 -11
  181. package/dist/author_marker.d.ts.map +0 -1
  182. package/dist/base32_encode.d.ts.map +0 -1
  183. package/dist/block_state.d.ts.map +0 -1
  184. package/dist/bmodel/block_config.d.ts.map +0 -1
  185. package/dist/bmodel/code.d.ts.map +0 -1
  186. package/dist/bmodel/container.d.ts.map +0 -1
  187. package/dist/bmodel/index.d.ts.map +0 -1
  188. package/dist/bmodel/normalization.d.ts.map +0 -1
  189. package/dist/bmodel/types.d.ts.map +0 -1
  190. package/dist/branding.d.ts.map +0 -1
  191. package/dist/common_types.d.ts.map +0 -1
  192. package/dist/driver_kit.d.ts.map +0 -1
  193. package/dist/drivers/blob.d.ts.map +0 -1
  194. package/dist/drivers/index.d.ts.map +0 -1
  195. package/dist/drivers/interfaces.d.ts.map +0 -1
  196. package/dist/drivers/log.d.ts.map +0 -1
  197. package/dist/drivers/ls.d.ts.map +0 -1
  198. package/dist/drivers/pframe/column_filter.d.ts.map +0 -1
  199. package/dist/drivers/pframe/data_info.d.ts.map +0 -1
  200. package/dist/drivers/pframe/data_types.d.ts.map +0 -1
  201. package/dist/drivers/pframe/driver.d.ts.map +0 -1
  202. package/dist/drivers/pframe/find_columns.d.ts.map +0 -1
  203. package/dist/drivers/pframe/index.d.ts.map +0 -1
  204. package/dist/drivers/pframe/linker_columns.d.ts.map +0 -1
  205. package/dist/drivers/pframe/pframe.d.ts.map +0 -1
  206. package/dist/drivers/pframe/spec/anchored.d.ts.map +0 -1
  207. package/dist/drivers/pframe/spec/filtered_column.d.ts.map +0 -1
  208. package/dist/drivers/pframe/spec/ids.d.ts.map +0 -1
  209. package/dist/drivers/pframe/spec/index.d.ts.map +0 -1
  210. package/dist/drivers/pframe/spec/native_id.d.ts.map +0 -1
  211. package/dist/drivers/pframe/spec/selectors.d.ts.map +0 -1
  212. package/dist/drivers/pframe/spec/spec.d.ts.map +0 -1
  213. package/dist/drivers/pframe/table.d.ts.map +0 -1
  214. package/dist/drivers/pframe/table_calculate.d.ts.map +0 -1
  215. package/dist/drivers/pframe/table_common.d.ts.map +0 -1
  216. package/dist/drivers/pframe/type_util.d.ts.map +0 -1
  217. package/dist/drivers/pframe/unique_values.d.ts.map +0 -1
  218. package/dist/drivers/upload.d.ts.map +0 -1
  219. package/dist/drivers/urls.d.ts.map +0 -1
  220. package/dist/errors.d.ts.map +0 -1
  221. package/dist/flags/block_flags.d.ts.map +0 -1
  222. package/dist/flags/flag_utils.d.ts.map +0 -1
  223. package/dist/flags/index.d.ts.map +0 -1
  224. package/dist/flags/type_utils.d.ts.map +0 -1
  225. package/dist/index.d.ts.map +0 -1
  226. package/dist/index.mjs +0 -1587
  227. package/dist/index.mjs.map +0 -1
  228. package/dist/json.d.ts.map +0 -1
  229. package/dist/navigation.d.ts.map +0 -1
  230. package/dist/plid.d.ts.map +0 -1
  231. package/dist/pool/entry.d.ts.map +0 -1
  232. package/dist/pool/index.d.ts.map +0 -1
  233. package/dist/pool/query.d.ts.map +0 -1
  234. package/dist/pool/spec.d.ts.map +0 -1
  235. package/dist/ref.d.ts.map +0 -1
  236. package/dist/utag.d.ts.map +0 -1
  237. package/dist/util.d.ts.map +0 -1
  238. package/dist/value_or_error.d.ts.map +0 -1
package/dist/plid.d.ts CHANGED
@@ -8,4 +8,3 @@ export type PlId = z.infer<typeof PlId>;
8
8
  export declare function uniquePlId(): PlId;
9
9
  export declare function plId(bytes: Uint8Array): PlId;
10
10
  export declare function digestPlId(data: string): Promise<PlId>;
11
- //# sourceMappingURL=plid.d.ts.map
package/dist/plid.js ADDED
@@ -0,0 +1,30 @@
1
+ import { z } from 'zod';
2
+ import { base32Encode } from './base32_encode.js';
3
+
4
+ /** Number of raw bytes in the PlId. */
5
+ const PlIdBytes = 15;
6
+ /** Characters in string representation */
7
+ const PlIdLength = 24; // = 15 bytes * 8 bits / 5 bits per char in base32
8
+ const PlId = z
9
+ .string()
10
+ .length(PlIdLength)
11
+ .regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/) // RFC4648
12
+ .brand('PlId');
13
+ function uniquePlId() {
14
+ const data = new Uint8Array(PlIdBytes);
15
+ crypto.getRandomValues(data);
16
+ return PlId.parse(base32Encode(data, 'RFC4648'));
17
+ }
18
+ function plId(bytes) {
19
+ if (bytes.length !== PlIdBytes)
20
+ throw new Error(`Wrong number of bytes: ${bytes.length}`);
21
+ return PlId.parse(base32Encode(bytes, 'RFC4648'));
22
+ }
23
+ async function digestPlId(data) {
24
+ const encoder = new TextEncoder();
25
+ const bytes = await crypto.subtle.digest('SHA-256', encoder.encode(data));
26
+ return plId(new Uint8Array(bytes.slice(0, 15)));
27
+ }
28
+
29
+ export { PlId, PlIdBytes, PlIdLength, digestPlId, plId, uniquePlId };
30
+ //# sourceMappingURL=plid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plid.js","sources":["../src/plid.ts"],"sourcesContent":["import { z } from 'zod';\nimport { base32Encode } from './base32_encode';\n\n/** Number of raw bytes in the PlId. */\nexport const PlIdBytes = 15;\n/** Characters in string representation */\nexport const PlIdLength = 24; // = 15 bytes * 8 bits / 5 bits per char in base32\n\nexport const PlId = z\n .string()\n .length(PlIdLength)\n .regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/) // RFC4648\n .brand('PlId');\nexport type PlId = z.infer<typeof PlId>;\n\nexport function uniquePlId(): PlId {\n const data = new Uint8Array(PlIdBytes);\n crypto.getRandomValues(data);\n return PlId.parse(base32Encode(data, 'RFC4648'));\n}\n\nexport function plId(bytes: Uint8Array): PlId {\n if (bytes.length !== PlIdBytes) throw new Error(`Wrong number of bytes: ${bytes.length}`);\n return PlId.parse(base32Encode(bytes, 'RFC4648'));\n}\n\nexport async function digestPlId(data: string): Promise<PlId> {\n const encoder = new TextEncoder();\n const bytes = await crypto.subtle.digest('SHA-256', encoder.encode(data));\n return plId(new Uint8Array(bytes.slice(0, 15)));\n}\n"],"names":[],"mappings":";;;AAGA;AACO,MAAM,SAAS,GAAG;AACzB;AACO,MAAM,UAAU,GAAG,GAAG;AAEtB,MAAM,IAAI,GAAG;AACjB,KAAA,MAAM;KACN,MAAM,CAAC,UAAU;AACjB,KAAA,KAAK,CAAC,oCAAoC,CAAC;KAC3C,KAAK,CAAC,MAAM;SAGC,UAAU,GAAA;AACxB,IAAA,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC;AACtC,IAAA,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC;IAC5B,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AAClD;AAEM,SAAU,IAAI,CAAC,KAAiB,EAAA;AACpC,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,CAAA,uBAAA,EAA0B,KAAK,CAAC,MAAM,CAAA,CAAE,CAAC;IACzF,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AACnD;AAEO,eAAe,UAAU,CAAC,IAAY,EAAA;AAC3C,IAAA,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE;AACjC,IAAA,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACzE,IAAA,OAAO,IAAI,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AACjD;;;;"}
@@ -13,4 +13,3 @@ export type ResultCollection<O> = {
13
13
  /** False means that current collection is not fully loaded due to some computations still taking place */
14
14
  readonly isComplete: boolean;
15
15
  };
16
- //# sourceMappingURL=entry.d.ts.map
@@ -1,4 +1,3 @@
1
1
  export * from './entry';
2
2
  export * from './spec';
3
3
  export * from './query';
4
- //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ var spec = require('./spec.cjs');
4
+
5
+ function assertNever(x) {
6
+ throw new Error('Unexpected object: ' + x); // This is ok, because this is a possible runtime error
7
+ }
8
+ function executePSpecPredicate(predicate, spec$1) {
9
+ switch (predicate.type) {
10
+ case 'and':
11
+ for (const operator of predicate.operands)
12
+ if (!executePSpecPredicate(operator, spec$1))
13
+ return false;
14
+ return true;
15
+ case 'or':
16
+ for (const operator of predicate.operands)
17
+ if (executePSpecPredicate(operator, spec$1))
18
+ return true;
19
+ return false;
20
+ case 'not':
21
+ return !executePSpecPredicate(predicate.operand, spec$1);
22
+ case 'name':
23
+ return spec.isPColumnSpec(spec$1) && spec$1.name === predicate.name;
24
+ case 'name_pattern':
25
+ return spec.isPColumnSpec(spec$1) && Boolean(spec$1.name.match(predicate.pattern));
26
+ case 'annotation':
27
+ return (spec.isPColumnSpec(spec$1)
28
+ && spec$1.annotations !== undefined
29
+ && spec$1.annotations[predicate.annotation] === predicate.value);
30
+ case 'annotation_pattern':
31
+ return (spec.isPColumnSpec(spec$1)
32
+ && spec$1.annotations !== undefined
33
+ && spec$1.annotations[predicate.annotation] !== undefined
34
+ && Boolean(spec$1.annotations[predicate.annotation].match(predicate.pattern)));
35
+ case 'has_axes':
36
+ return (spec.isPColumnSpec(spec$1)
37
+ && predicate.axes.every((matcher) => spec$1.axesSpec.some((axisSpec) => (matcher.type === undefined || matcher.type === axisSpec.type)
38
+ && (matcher.name === undefined || matcher.name === axisSpec.name)
39
+ && (matcher.domain === undefined
40
+ || Object.keys(matcher.domain).length === 0
41
+ || (axisSpec.domain !== undefined
42
+ && Object.entries(matcher.domain).every(([domain, domainValue]) => axisSpec.domain[domain] === domainValue))))));
43
+ default:
44
+ assertNever(predicate);
45
+ }
46
+ }
47
+
48
+ exports.executePSpecPredicate = executePSpecPredicate;
49
+ //# sourceMappingURL=query.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.cjs","sources":["../../src/pool/query.ts"],"sourcesContent":["import type { AxisId } from '../drivers';\nimport type { PObjectSpec } from './spec';\nimport { isPColumnSpec } from './spec';\n\nexport type PSpecPredicate =\n | {\n type: 'and' | 'or';\n operands: PSpecPredicate[];\n }\n | {\n type: 'not';\n operand: PSpecPredicate;\n }\n | {\n type: 'name';\n name: string;\n }\n | {\n type: 'name_pattern';\n pattern: string;\n }\n | {\n type: 'annotation';\n annotation: string;\n value: string;\n }\n | {\n type: 'annotation_pattern';\n annotation: string;\n pattern: string;\n }\n | {\n type: 'has_axes';\n axes: Partial<AxisId>[];\n };\n\nfunction assertNever(x: never): never {\n throw new Error('Unexpected object: ' + x); // This is ok, because this is a possible runtime error\n}\n\nexport function executePSpecPredicate(\n predicate: PSpecPredicate,\n spec: PObjectSpec,\n): boolean {\n switch (predicate.type) {\n case 'and':\n for (const operator of predicate.operands)\n if (!executePSpecPredicate(operator, spec)) return false;\n return true;\n case 'or':\n for (const operator of predicate.operands)\n if (executePSpecPredicate(operator, spec)) return true;\n return false;\n case 'not':\n return !executePSpecPredicate(predicate.operand, spec);\n case 'name':\n return isPColumnSpec(spec) && spec.name === predicate.name;\n case 'name_pattern':\n return isPColumnSpec(spec) && Boolean(spec.name.match(predicate.pattern));\n case 'annotation':\n return (\n isPColumnSpec(spec)\n && spec.annotations !== undefined\n && spec.annotations[predicate.annotation] === predicate.value\n );\n case 'annotation_pattern':\n return (\n isPColumnSpec(spec)\n && spec.annotations !== undefined\n && spec.annotations[predicate.annotation] !== undefined\n && Boolean(spec.annotations[predicate.annotation].match(predicate.pattern))\n );\n case 'has_axes':\n return (\n isPColumnSpec(spec)\n && predicate.axes.every((matcher) =>\n spec.axesSpec.some(\n (axisSpec) =>\n (matcher.type === undefined || matcher.type === axisSpec.type)\n && (matcher.name === undefined || matcher.name === axisSpec.name)\n && (matcher.domain === undefined\n || Object.keys(matcher.domain).length === 0\n || (axisSpec.domain !== undefined\n && Object.entries(matcher.domain).every(\n ([domain, domainValue]) =>\n axisSpec.domain![domain] === domainValue,\n ))),\n ),\n )\n );\n default:\n assertNever(predicate);\n }\n}\n"],"names":["spec","isPColumnSpec"],"mappings":";;;;AAoCA,SAAS,WAAW,CAAC,CAAQ,EAAA;IAC3B,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC;AAC7C;AAEM,SAAU,qBAAqB,CACnC,SAAyB,EACzBA,MAAiB,EAAA;AAEjB,IAAA,QAAQ,SAAS,CAAC,IAAI;AACpB,QAAA,KAAK,KAAK;AACR,YAAA,KAAK,MAAM,QAAQ,IAAI,SAAS,CAAC,QAAQ;AACvC,gBAAA,IAAI,CAAC,qBAAqB,CAAC,QAAQ,EAAEA,MAAI,CAAC;AAAE,oBAAA,OAAO,KAAK;AAC1D,YAAA,OAAO,IAAI;AACb,QAAA,KAAK,IAAI;AACP,YAAA,KAAK,MAAM,QAAQ,IAA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wBAAC,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI;AAC7D,wBAAC,OAAO,CAAC,MAAM,KAAK;2BAClB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK;AACvC,4BAAC,QAAQ,CAAC,MAAM,KAAK;AACnB,+BAAA,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CACrC,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,KACpB,QAAQ,CAAC,MAAO,CAAC,MAAM,CAAC,KAAK,WAAW,CAC3C,CAAC,CAAC,CACV,CACF;AAEL,QAAA;YACE,WAAW,CAAC,SAAS,CAAC;;AAE5B;;;;"}
@@ -25,4 +25,3 @@ export type PSpecPredicate = {
25
25
  axes: Partial<AxisId>[];
26
26
  };
27
27
  export declare function executePSpecPredicate(predicate: PSpecPredicate, spec: PObjectSpec): boolean;
28
- //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1,47 @@
1
+ import { isPColumnSpec } from './spec.js';
2
+
3
+ function assertNever(x) {
4
+ throw new Error('Unexpected object: ' + x); // This is ok, because this is a possible runtime error
5
+ }
6
+ function executePSpecPredicate(predicate, spec) {
7
+ switch (predicate.type) {
8
+ case 'and':
9
+ for (const operator of predicate.operands)
10
+ if (!executePSpecPredicate(operator, spec))
11
+ return false;
12
+ return true;
13
+ case 'or':
14
+ for (const operator of predicate.operands)
15
+ if (executePSpecPredicate(operator, spec))
16
+ return true;
17
+ return false;
18
+ case 'not':
19
+ return !executePSpecPredicate(predicate.operand, spec);
20
+ case 'name':
21
+ return isPColumnSpec(spec) && spec.name === predicate.name;
22
+ case 'name_pattern':
23
+ return isPColumnSpec(spec) && Boolean(spec.name.match(predicate.pattern));
24
+ case 'annotation':
25
+ return (isPColumnSpec(spec)
26
+ && spec.annotations !== undefined
27
+ && spec.annotations[predicate.annotation] === predicate.value);
28
+ case 'annotation_pattern':
29
+ return (isPColumnSpec(spec)
30
+ && spec.annotations !== undefined
31
+ && spec.annotations[predicate.annotation] !== undefined
32
+ && Boolean(spec.annotations[predicate.annotation].match(predicate.pattern)));
33
+ case 'has_axes':
34
+ return (isPColumnSpec(spec)
35
+ && predicate.axes.every((matcher) => spec.axesSpec.some((axisSpec) => (matcher.type === undefined || matcher.type === axisSpec.type)
36
+ && (matcher.name === undefined || matcher.name === axisSpec.name)
37
+ && (matcher.domain === undefined
38
+ || Object.keys(matcher.domain).length === 0
39
+ || (axisSpec.domain !== undefined
40
+ && Object.entries(matcher.domain).every(([domain, domainValue]) => axisSpec.domain[domain] === domainValue))))));
41
+ default:
42
+ assertNever(predicate);
43
+ }
44
+ }
45
+
46
+ export { executePSpecPredicate };
47
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","sources":["../../src/pool/query.ts"],"sourcesContent":["import type { AxisId } from '../drivers';\nimport type { PObjectSpec } from './spec';\nimport { isPColumnSpec } from './spec';\n\nexport type PSpecPredicate =\n | {\n type: 'and' | 'or';\n operands: PSpecPredicate[];\n }\n | {\n type: 'not';\n operand: PSpecPredicate;\n }\n | {\n type: 'name';\n name: string;\n }\n | {\n type: 'name_pattern';\n pattern: string;\n }\n | {\n type: 'annotation';\n annotation: string;\n value: string;\n }\n | {\n type: 'annotation_pattern';\n annotation: string;\n pattern: string;\n }\n | {\n type: 'has_axes';\n axes: Partial<AxisId>[];\n };\n\nfunction assertNever(x: never): never {\n throw new Error('Unexpected object: ' + x); // This is ok, because this is a possible runtime error\n}\n\nexport function executePSpecPredicate(\n predicate: PSpecPredicate,\n spec: PObjectSpec,\n): boolean {\n switch (predicate.type) {\n case 'and':\n for (const operator of predicate.operands)\n if (!executePSpecPredicate(operator, spec)) return false;\n return true;\n case 'or':\n for (const operator of predicate.operands)\n if (executePSpecPredicate(operator, spec)) return true;\n return false;\n case 'not':\n return !executePSpecPredicate(predicate.operand, spec);\n case 'name':\n return isPColumnSpec(spec) && spec.name === predicate.name;\n case 'name_pattern':\n return isPColumnSpec(spec) && Boolean(spec.name.match(predicate.pattern));\n case 'annotation':\n return (\n isPColumnSpec(spec)\n && spec.annotations !== undefined\n && spec.annotations[predicate.annotation] === predicate.value\n );\n case 'annotation_pattern':\n return (\n isPColumnSpec(spec)\n && spec.annotations !== undefined\n && spec.annotations[predicate.annotation] !== undefined\n && Boolean(spec.annotations[predicate.annotation].match(predicate.pattern))\n );\n case 'has_axes':\n return (\n isPColumnSpec(spec)\n && predicate.axes.every((matcher) =>\n spec.axesSpec.some(\n (axisSpec) =>\n (matcher.type === undefined || matcher.type === axisSpec.type)\n && (matcher.name === undefined || matcher.name === axisSpec.name)\n && (matcher.domain === undefined\n || Object.keys(matcher.domain).length === 0\n || (axisSpec.domain !== undefined\n && Object.entries(matcher.domain).every(\n ([domain, domainValue]) =>\n axisSpec.domain![domain] === domainValue,\n ))),\n ),\n )\n );\n default:\n assertNever(predicate);\n }\n}\n"],"names":[],"mappings":";;AAoCA,SAAS,WAAW,CAAC,CAAQ,EAAA;IAC3B,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC;AAC7C;AAEM,SAAU,qBAAqB,CACnC,SAAyB,EACzB,IAAiB,EAAA;AAEjB,IAAA,QAAQ,SAAS,CAAC,IAAI;AACpB,QAAA,KAAK,KAAK;AACR,YAAA,KAAK,MAAM,QAAQ,IAAI,SAAS,CAAC,QAAQ;AACvC,gBAAA,IAAI,CAAC,qBAAqB,CAAC,QAAQ,EAAE,IAAI,CAAC;AAAE,oBAAA,OAAO,KAAK;AAC1D,YAAA,OAAO,IAAI;AACb,QAAA,KAAK,IAAI;AACP,YAAA,KAAK,MAAM,QAAQ,IAAI,SAAS,CAAC,QAAQ;AACvC,gBAAA,IAAI,qBAAqB,CAAC,QAAQ,EAAE,IAAI,CAAC;AAAE,oBAAA,OAAO,IAAI;AACxD,YAAA,OAAO,KAAK;AACd,QAAA,KA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AC,MAAM,CAAC,CAAC,MAAM,KAAK;AACvC,4BAAC,QAAQ,CAAC,MAAM,KAAK;AACnB,+BAAA,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CACrC,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,KACpB,QAAQ,CAAC,MAAO,CAAC,MAAM,CAAC,KAAK,WAAW,CAC3C,CAAC,CAAC,CACV,CACF;AAEL,QAAA;YACE,WAAW,CAAC,SAAS,CAAC;;AAE5B;;;;"}
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+
3
+ var util = require('../util.cjs');
4
+
5
+ function isPColumnSpec(spec) {
6
+ return spec.kind === 'PColumn';
7
+ }
8
+ function isPColumn(obj) {
9
+ return isPColumnSpec(obj.spec);
10
+ }
11
+ function isPColumnSpecResult(r) {
12
+ return isPColumnSpec(r.obj);
13
+ }
14
+ function isPColumnResult(r) {
15
+ return isPColumnSpec(r.obj.spec);
16
+ }
17
+ function ensurePColumn(obj) {
18
+ if (!isPColumn(obj))
19
+ throw new Error(`not a PColumn (kind = ${obj.spec.kind})`);
20
+ return obj;
21
+ }
22
+ function mapPObjectData(pObj, cb) {
23
+ return pObj === undefined
24
+ ? undefined
25
+ : {
26
+ ...pObj,
27
+ data: cb(pObj.data),
28
+ };
29
+ }
30
+ function extractAllColumns(entry) {
31
+ const columns = new Map();
32
+ const addAllColumns = (entry) => {
33
+ switch (entry.type) {
34
+ case 'column':
35
+ columns.set(entry.column.id, entry.column);
36
+ return;
37
+ case 'slicedColumn':
38
+ columns.set(entry.column.id, entry.column);
39
+ return;
40
+ case 'inlineColumn':
41
+ return;
42
+ case 'full':
43
+ case 'inner':
44
+ for (const e of entry.entries)
45
+ addAllColumns(e);
46
+ return;
47
+ case 'outer':
48
+ addAllColumns(entry.primary);
49
+ for (const e of entry.secondary)
50
+ addAllColumns(e);
51
+ return;
52
+ default:
53
+ util.assertNever(entry);
54
+ }
55
+ };
56
+ addAllColumns(entry);
57
+ return [...columns.values()];
58
+ }
59
+
60
+ exports.ensurePColumn = ensurePColumn;
61
+ exports.extractAllColumns = extractAllColumns;
62
+ exports.isPColumn = isPColumn;
63
+ exports.isPColumnResult = isPColumnResult;
64
+ exports.isPColumnSpec = isPColumnSpec;
65
+ exports.isPColumnSpecResult = isPColumnSpecResult;
66
+ exports.mapPObjectData = mapPObjectData;
67
+ //# sourceMappingURL=spec.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec.cjs","sources":["../../src/pool/spec.ts"],"sourcesContent":["import type { Branded } from '../branding';\nimport type { JoinEntry, PColumn, PColumnSpec } from '../drivers';\nimport { assertNever } from '../util';\nimport type { ResultPoolEntry } from './entry';\n\n/** Any object exported into the result pool by the block always have spec attached to it */\nexport interface PObjectSpec {\n /** PObject kind discriminator */\n readonly kind: string;\n\n /** Name is common part of PObject identity */\n readonly name: string;\n\n /** Domain is a set of key-value pairs that can be used to identify the object */\n readonly domain?: Record<string, string>;\n\n /** Additional information attached to the object */\n readonly annotations?: Record<string, string>;\n}\n\n/** Stable PObject id */\nexport type PObjectId = Branded<string, 'PColumnId'>;\n\n/**\n * Full PObject representation.\n *\n * @template Data type of the object referencing or describing the \"data\" part of the PObject\n * */\nexport interface PObject<Data> {\n /** Fully rendered PObjects are assigned a stable identifier. */\n readonly id: PObjectId;\n\n /** PObject spec, allowing it to be found among other PObjects */\n readonly spec: PObjectSpec;\n\n /** A handle to data object */\n readonly data: Data;\n}\n\nexport function isPColumnSpec(spec: PObjectSpec): spec is PColumnSpec {\n return spec.kind === 'PColumn';\n}\n\nexport function isPColumn<T>(obj: PObject<T>): obj is PColumn<T> {\n return isPColumnSpec(obj.spec);\n}\n\nexport function isPColumnSpecResult(\n r: ResultPoolEntry<PObjectSpec>,\n): r is ResultPoolEntry<PColumnSpec> {\n return isPColumnSpec(r.obj);\n}\n\nexport function isPColumnResult<T>(\n r: ResultPoolEntry<PObject<T>>,\n): r is ResultPoolEntry<PColumn<T>> {\n return isPColumnSpec(r.obj.spec);\n}\n\nexport function ensurePColumn<T>(obj: PObject<T>): PColumn<T> {\n if (!isPColumn(obj)) throw new Error(`not a PColumn (kind = ${obj.spec.kind})`);\n return obj;\n}\n\nexport function mapPObjectData<D1, D2>(pObj: PColumn<D1>, cb: (d: D1) => D2): PColumn<D2>;\nexport function mapPObjectData<D1, D2>(\n pObj: PColumn<D1> | undefined,\n cb: (d: D1) => D2\n): PColumn<D2> | undefined;\nexport function mapPObjectData<D1, D2>(pObj: PObject<D1>, cb: (d: D1) => D2): PObject<D2>;\nexport function mapPObjectData<D1, D2>(\n pObj: PObject<D1> | undefined,\n cb: (d: D1) => D2\n): PObject<D2> | undefined;\nexport function mapPObjectData<D1, D2>(\n pObj: PObject<D1> | undefined,\n cb: (d: D1) => D2,\n): PObject<D2> | undefined {\n return pObj === undefined\n ? undefined\n : {\n ...pObj,\n data: cb(pObj.data),\n };\n}\n\nexport function extractAllColumns<D>(entry: JoinEntry<PColumn<D>>): PColumn<D>[] {\n const columns = new Map<PObjectId, PColumn<D>>();\n const addAllColumns = (entry: JoinEntry<PColumn<D>>) => {\n switch (entry.type) {\n case 'column':\n columns.set(entry.column.id, entry.column);\n return;\n case 'slicedColumn':\n columns.set(entry.column.id, entry.column);\n return;\n case 'inlineColumn':\n return;\n case 'full':\n case 'inner':\n for (const e of entry.entries) addAllColumns(e);\n return;\n case 'outer':\n addAllColumns(entry.primary);\n for (const e of entry.secondary) addAllColumns(e);\n return;\n default:\n assertNever(entry);\n }\n };\n addAllColumns(entry);\n return [...columns.values()];\n}\n"],"names":["assertNever"],"mappings":";;;;AAuCM,SAAU,aAAa,CAAC,IAAiB,EAAA;AAC7C,IAAA,OAAO,IAAI,CAAC,IAAI,KAAK,SAAS;AAChC;AAEM,SAAU,SAAS,CAAI,GAAe,EAAA;AAC1C,IAAA,OAAO,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC;AAChC;AAEM,SAAU,mBAAmB,CACjC,CAA+B,EAAA;AAE/B,I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CAAC,OAAO,CAAC;AAC5B,gBAAA,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS;oBAAE,aAAa,CAAC,CAAC,CAAC;gBACjD;AACF,YAAA;gBACEA,gBAAW,CAAC,KAAK,CAAC;;AAExB,IAAA,CAAC;IACD,aAAa,CAAC,KAAK,CAAC;AACpB,IAAA,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;AAC9B;;;;;;;;;;"}
@@ -37,4 +37,3 @@ export declare function mapPObjectData<D1, D2>(pObj: PColumn<D1> | undefined, cb
37
37
  export declare function mapPObjectData<D1, D2>(pObj: PObject<D1>, cb: (d: D1) => D2): PObject<D2>;
38
38
  export declare function mapPObjectData<D1, D2>(pObj: PObject<D1> | undefined, cb: (d: D1) => D2): PObject<D2> | undefined;
39
39
  export declare function extractAllColumns<D>(entry: JoinEntry<PColumn<D>>): PColumn<D>[];
40
- //# sourceMappingURL=spec.d.ts.map
@@ -0,0 +1,59 @@
1
+ import { assertNever } from '../util.js';
2
+
3
+ function isPColumnSpec(spec) {
4
+ return spec.kind === 'PColumn';
5
+ }
6
+ function isPColumn(obj) {
7
+ return isPColumnSpec(obj.spec);
8
+ }
9
+ function isPColumnSpecResult(r) {
10
+ return isPColumnSpec(r.obj);
11
+ }
12
+ function isPColumnResult(r) {
13
+ return isPColumnSpec(r.obj.spec);
14
+ }
15
+ function ensurePColumn(obj) {
16
+ if (!isPColumn(obj))
17
+ throw new Error(`not a PColumn (kind = ${obj.spec.kind})`);
18
+ return obj;
19
+ }
20
+ function mapPObjectData(pObj, cb) {
21
+ return pObj === undefined
22
+ ? undefined
23
+ : {
24
+ ...pObj,
25
+ data: cb(pObj.data),
26
+ };
27
+ }
28
+ function extractAllColumns(entry) {
29
+ const columns = new Map();
30
+ const addAllColumns = (entry) => {
31
+ switch (entry.type) {
32
+ case 'column':
33
+ columns.set(entry.column.id, entry.column);
34
+ return;
35
+ case 'slicedColumn':
36
+ columns.set(entry.column.id, entry.column);
37
+ return;
38
+ case 'inlineColumn':
39
+ return;
40
+ case 'full':
41
+ case 'inner':
42
+ for (const e of entry.entries)
43
+ addAllColumns(e);
44
+ return;
45
+ case 'outer':
46
+ addAllColumns(entry.primary);
47
+ for (const e of entry.secondary)
48
+ addAllColumns(e);
49
+ return;
50
+ default:
51
+ assertNever(entry);
52
+ }
53
+ };
54
+ addAllColumns(entry);
55
+ return [...columns.values()];
56
+ }
57
+
58
+ export { ensurePColumn, extractAllColumns, isPColumn, isPColumnResult, isPColumnSpec, isPColumnSpecResult, mapPObjectData };
59
+ //# sourceMappingURL=spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec.js","sources":["../../src/pool/spec.ts"],"sourcesContent":["import type { Branded } from '../branding';\nimport type { JoinEntry, PColumn, PColumnSpec } from '../drivers';\nimport { assertNever } from '../util';\nimport type { ResultPoolEntry } from './entry';\n\n/** Any object exported into the result pool by the block always have spec attached to it */\nexport interface PObjectSpec {\n /** PObject kind discriminator */\n readonly kind: string;\n\n /** Name is common part of PObject identity */\n readonly name: string;\n\n /** Domain is a set of key-value pairs that can be used to identify the object */\n readonly domain?: Record<string, string>;\n\n /** Additional information attached to the object */\n readonly annotations?: Record<string, string>;\n}\n\n/** Stable PObject id */\nexport type PObjectId = Branded<string, 'PColumnId'>;\n\n/**\n * Full PObject representation.\n *\n * @template Data type of the object referencing or describing the \"data\" part of the PObject\n * */\nexport interface PObject<Data> {\n /** Fully rendered PObjects are assigned a stable identifier. */\n readonly id: PObjectId;\n\n /** PObject spec, allowing it to be found among other PObjects */\n readonly spec: PObjectSpec;\n\n /** A handle to data object */\n readonly data: Data;\n}\n\nexport function isPColumnSpec(spec: PObjectSpec): spec is PColumnSpec {\n return spec.kind === 'PColumn';\n}\n\nexport function isPColumn<T>(obj: PObject<T>): obj is PColumn<T> {\n return isPColumnSpec(obj.spec);\n}\n\nexport function isPColumnSpecResult(\n r: ResultPoolEntry<PObjectSpec>,\n): r is ResultPoolEntry<PColumnSpec> {\n return isPColumnSpec(r.obj);\n}\n\nexport function isPColumnResult<T>(\n r: ResultPoolEntry<PObject<T>>,\n): r is ResultPoolEntry<PColumn<T>> {\n return isPColumnSpec(r.obj.spec);\n}\n\nexport function ensurePColumn<T>(obj: PObject<T>): PColumn<T> {\n if (!isPColumn(obj)) throw new Error(`not a PColumn (kind = ${obj.spec.kind})`);\n return obj;\n}\n\nexport function mapPObjectData<D1, D2>(pObj: PColumn<D1>, cb: (d: D1) => D2): PColumn<D2>;\nexport function mapPObjectData<D1, D2>(\n pObj: PColumn<D1> | undefined,\n cb: (d: D1) => D2\n): PColumn<D2> | undefined;\nexport function mapPObjectData<D1, D2>(pObj: PObject<D1>, cb: (d: D1) => D2): PObject<D2>;\nexport function mapPObjectData<D1, D2>(\n pObj: PObject<D1> | undefined,\n cb: (d: D1) => D2\n): PObject<D2> | undefined;\nexport function mapPObjectData<D1, D2>(\n pObj: PObject<D1> | undefined,\n cb: (d: D1) => D2,\n): PObject<D2> | undefined {\n return pObj === undefined\n ? undefined\n : {\n ...pObj,\n data: cb(pObj.data),\n };\n}\n\nexport function extractAllColumns<D>(entry: JoinEntry<PColumn<D>>): PColumn<D>[] {\n const columns = new Map<PObjectId, PColumn<D>>();\n const addAllColumns = (entry: JoinEntry<PColumn<D>>) => {\n switch (entry.type) {\n case 'column':\n columns.set(entry.column.id, entry.column);\n return;\n case 'slicedColumn':\n columns.set(entry.column.id, entry.column);\n return;\n case 'inlineColumn':\n return;\n case 'full':\n case 'inner':\n for (const e of entry.entries) addAllColumns(e);\n return;\n case 'outer':\n addAllColumns(entry.primary);\n for (const e of entry.secondary) addAllColumns(e);\n return;\n default:\n assertNever(entry);\n }\n };\n addAllColumns(entry);\n return [...columns.values()];\n}\n"],"names":[],"mappings":";;AAuCM,SAAU,aAAa,CAAC,IAAiB,EAAA;AAC7C,IAAA,OAAO,IAAI,CAAC,IAAI,KAAK,SAAS;AAChC;AAEM,SAAU,SAAS,CAAI,GAAe,EAAA;AAC1C,I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C,OAAO;oBAAE,aAAa,CAAC,CAAC,CAAC;gBAC/C;AACF,YAAA,KAAK,OAAO;AACV,gBAAA,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC;AAC5B,gBAAA,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS;oBAAE,aAAa,CAAC,CAAC,CAAC;gBACjD;AACF,YAAA;gBACE,WAAW,CAAC,KAAK,CAAC;;AAExB,IAAA,CAAC;IACD,aAAa,CAAC,KAAK,CAAC;AACpB,IAAA,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;AAC9B;;;;"}
package/dist/ref.cjs ADDED
@@ -0,0 +1,88 @@
1
+ 'use strict';
2
+
3
+ var zod = require('zod');
4
+
5
+ const PlRef = zod.z
6
+ .object({
7
+ __isRef: zod.z
8
+ .literal(true)
9
+ .describe('Crucial marker for the block dependency tree reconstruction'),
10
+ blockId: zod.z.string()
11
+ .describe('Upstream block id'),
12
+ name: zod.z.string()
13
+ .describe('Name of the output provided to the upstream block\'s output context'),
14
+ requireEnrichments: zod.z.literal(true).optional()
15
+ .describe('True if current block that stores this reference in its args, may need enrichments '
16
+ + 'for the references value originating from the blocks in between current and referenced block'),
17
+ })
18
+ .describe('Universal reference type, allowing to set block connections. It is crucial that '
19
+ + '{@link __isRef} is present and equal to true, internal logic relies on this marker '
20
+ + 'to build block dependency trees.')
21
+ .readonly();
22
+ /**
23
+ * Type guard to check if a value is a PlRef.
24
+ *
25
+ * @param value - The value to check.
26
+ * @returns True if the value is a PlRef, false otherwise.
27
+ */
28
+ function isPlRef(value) {
29
+ return (typeof value === 'object'
30
+ && value !== null
31
+ && '__isRef' in value
32
+ && value.__isRef === true
33
+ && 'blockId' in value
34
+ && 'name' in value);
35
+ }
36
+ /**
37
+ * Creates a PlRef with the given blockId and name.
38
+ *
39
+ * @param blockId - The blockId of the reference.
40
+ * @param name - The name of the reference.
41
+ * @param requireEnrichments - Whether the reference requires enrichments.
42
+ */
43
+ function createPlRef(blockId, name, requireEnrichments = false) {
44
+ if (requireEnrichments)
45
+ return {
46
+ __isRef: true,
47
+ blockId,
48
+ name,
49
+ requireEnrichments: true,
50
+ };
51
+ else
52
+ return {
53
+ __isRef: true,
54
+ blockId,
55
+ name,
56
+ };
57
+ }
58
+ /**
59
+ * Creates a new PlRef based on an existing one, explicitly setting (default) or removing the
60
+ * requireEnrichments property.
61
+ *
62
+ * @param ref - The original PlRef object.
63
+ * @param requireEnrichments - If true, the `requireEnrichments: true` property is added
64
+ * to the returned PlRef. If false, the `requireEnrichments` property is removed. Defaults to true.
65
+ * @returns A new PlRef object with the `requireEnrichments` property set or removed accordingly.
66
+ */
67
+ function withEnrichments(ref, requireEnrichments = true) {
68
+ if (requireEnrichments)
69
+ return {
70
+ ...ref,
71
+ requireEnrichments: true,
72
+ };
73
+ else {
74
+ const { requireEnrichments: _, ...rest } = ref;
75
+ return rest;
76
+ }
77
+ }
78
+ /** Compare two PlRefs and returns true if they are qual */
79
+ function plRefsEqual(ref1, ref2, ignoreEnrichments = false) {
80
+ return ref1.blockId === ref2.blockId && ref1.name === ref2.name && (ignoreEnrichments || ref1.requireEnrichments === ref2.requireEnrichments);
81
+ }
82
+
83
+ exports.PlRef = PlRef;
84
+ exports.createPlRef = createPlRef;
85
+ exports.isPlRef = isPlRef;
86
+ exports.plRefsEqual = plRefsEqual;
87
+ exports.withEnrichments = withEnrichments;
88
+ //# sourceMappingURL=ref.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref.cjs","sources":["../src/ref.ts"],"sourcesContent":["import { z } from 'zod';\n\nexport const PlRef = z\n .object({\n __isRef: z\n .literal(true)\n .describe('Crucial marker for the block dependency tree reconstruction'),\n blockId: z.string()\n .describe('Upstream block id'),\n name: z.string()\n .describe('Name of the output provided to the upstream block\\'s output context'),\n requireEnrichments: z.literal(true).optional()\n .describe('True if current block that stores this reference in its args, may need enrichments '\n + 'for the references value originating from the blocks in between current and referenced block'),\n })\n .describe(\n 'Universal reference type, allowing to set block connections. It is crucial that '\n + '{@link __isRef} is present and equal to true, internal logic relies on this marker '\n + 'to build block dependency trees.',\n )\n .readonly();\nexport type PlRef = z.infer<typeof PlRef>;\n/** @deprecated use {@link PlRef} */\nexport type Ref = PlRef;\n\n/**\n * Type guard to check if a value is a PlRef.\n *\n * @param value - The value to check.\n * @returns True if the value is a PlRef, false otherwise.\n */\nexport function isPlRef(value: unknown): value is PlRef {\n return (\n typeof value === 'object'\n && value !== null\n && '__isRef' in value\n && (value as { __isRef: unknown }).__isRef === true\n && 'blockId' in value\n && 'name' in value\n );\n}\n\n/** Standard way how to communicate possible connections given specific\n * requirements for incoming data. */\nexport type Option = {\n /** Fully rendered reference to be assigned for the intended field in block's\n * args */\n readonly ref: PlRef;\n\n /** Label to be present for the user in i.e. drop-down list */\n readonly label: string;\n};\n\n/**\n * Creates a PlRef with the given blockId and name.\n *\n * @param blockId - The blockId of the reference.\n * @param name - The name of the reference.\n * @param requireEnrichments - Whether the reference requires enrichments.\n */\nexport function createPlRef(blockId: string, name: string, requireEnrichments: boolean = false) {\n if (requireEnrichments)\n return {\n __isRef: true,\n blockId,\n name,\n requireEnrichments: true,\n };\n else\n return {\n __isRef: true,\n blockId,\n name,\n };\n}\n\n/**\n * Creates a new PlRef based on an existing one, explicitly setting (default) or removing the\n * requireEnrichments property.\n *\n * @param ref - The original PlRef object.\n * @param requireEnrichments - If true, the `requireEnrichments: true` property is added\n * to the returned PlRef. If false, the `requireEnrichments` property is removed. Defaults to true.\n * @returns A new PlRef object with the `requireEnrichments` property set or removed accordingly.\n */\nexport function withEnrichments(ref: PlRef, requireEnrichments: boolean = true): PlRef {\n if (requireEnrichments)\n return {\n ...ref,\n requireEnrichments: true,\n };\n else {\n const { requireEnrichments: _, ...rest } = ref;\n return rest;\n }\n}\n\n/** Compare two PlRefs and returns true if they are qual */\nexport function plRefsEqual(ref1: PlRef, ref2: PlRef, ignoreEnrichments: boolean = false) {\n return ref1.blockId === ref2.blockId && ref1.name === ref2.name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MAAM,EAAE,kBAAkB,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG;AAC9C,QAAA,OAAO,IAAI;IACb;AACF;AAEA;AACM,SAAU,WAAW,CAAC,IAAW,EAAE,IAAW,EAAE,oBAA6B,KAAK,EAAA;IACtF,OAAO,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,iBAAiB,IAAI,IAAI,CAAC,kBAAkB,KAAK,IAAI,CAAC,kBAAkB,CAAC;AAC/I;;;;;;;;"}
package/dist/ref.d.ts CHANGED
@@ -64,4 +64,3 @@ export declare function createPlRef(blockId: string, name: string, requireEnrich
64
64
  export declare function withEnrichments(ref: PlRef, requireEnrichments?: boolean): PlRef;
65
65
  /** Compare two PlRefs and returns true if they are qual */
66
66
  export declare function plRefsEqual(ref1: PlRef, ref2: PlRef, ignoreEnrichments?: boolean): boolean;
67
- //# sourceMappingURL=ref.d.ts.map
package/dist/ref.js ADDED
@@ -0,0 +1,82 @@
1
+ import { z } from 'zod';
2
+
3
+ const PlRef = z
4
+ .object({
5
+ __isRef: z
6
+ .literal(true)
7
+ .describe('Crucial marker for the block dependency tree reconstruction'),
8
+ blockId: z.string()
9
+ .describe('Upstream block id'),
10
+ name: z.string()
11
+ .describe('Name of the output provided to the upstream block\'s output context'),
12
+ requireEnrichments: z.literal(true).optional()
13
+ .describe('True if current block that stores this reference in its args, may need enrichments '
14
+ + 'for the references value originating from the blocks in between current and referenced block'),
15
+ })
16
+ .describe('Universal reference type, allowing to set block connections. It is crucial that '
17
+ + '{@link __isRef} is present and equal to true, internal logic relies on this marker '
18
+ + 'to build block dependency trees.')
19
+ .readonly();
20
+ /**
21
+ * Type guard to check if a value is a PlRef.
22
+ *
23
+ * @param value - The value to check.
24
+ * @returns True if the value is a PlRef, false otherwise.
25
+ */
26
+ function isPlRef(value) {
27
+ return (typeof value === 'object'
28
+ && value !== null
29
+ && '__isRef' in value
30
+ && value.__isRef === true
31
+ && 'blockId' in value
32
+ && 'name' in value);
33
+ }
34
+ /**
35
+ * Creates a PlRef with the given blockId and name.
36
+ *
37
+ * @param blockId - The blockId of the reference.
38
+ * @param name - The name of the reference.
39
+ * @param requireEnrichments - Whether the reference requires enrichments.
40
+ */
41
+ function createPlRef(blockId, name, requireEnrichments = false) {
42
+ if (requireEnrichments)
43
+ return {
44
+ __isRef: true,
45
+ blockId,
46
+ name,
47
+ requireEnrichments: true,
48
+ };
49
+ else
50
+ return {
51
+ __isRef: true,
52
+ blockId,
53
+ name,
54
+ };
55
+ }
56
+ /**
57
+ * Creates a new PlRef based on an existing one, explicitly setting (default) or removing the
58
+ * requireEnrichments property.
59
+ *
60
+ * @param ref - The original PlRef object.
61
+ * @param requireEnrichments - If true, the `requireEnrichments: true` property is added
62
+ * to the returned PlRef. If false, the `requireEnrichments` property is removed. Defaults to true.
63
+ * @returns A new PlRef object with the `requireEnrichments` property set or removed accordingly.
64
+ */
65
+ function withEnrichments(ref, requireEnrichments = true) {
66
+ if (requireEnrichments)
67
+ return {
68
+ ...ref,
69
+ requireEnrichments: true,
70
+ };
71
+ else {
72
+ const { requireEnrichments: _, ...rest } = ref;
73
+ return rest;
74
+ }
75
+ }
76
+ /** Compare two PlRefs and returns true if they are qual */
77
+ function plRefsEqual(ref1, ref2, ignoreEnrichments = false) {
78
+ return ref1.blockId === ref2.blockId && ref1.name === ref2.name && (ignoreEnrichments || ref1.requireEnrichments === ref2.requireEnrichments);
79
+ }
80
+
81
+ export { PlRef, createPlRef, isPlRef, plRefsEqual, withEnrichments };
82
+ //# sourceMappingURL=ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref.js","sources":["../src/ref.ts"],"sourcesContent":["import { z } from 'zod';\n\nexport const PlRef = z\n .object({\n __isRef: z\n .literal(true)\n .describe('Crucial marker for the block dependency tree reconstruction'),\n blockId: z.string()\n .describe('Upstream block id'),\n name: z.string()\n .describe('Name of the output provided to the upstream block\\'s output context'),\n requireEnrichments: z.literal(true).optional()\n .describe('True if current block that stores this reference in its args, may need enrichments '\n + 'for the references value originating from the blocks in between current and referenced block'),\n })\n .describe(\n 'Universal reference type, allowing to set block connections. It is crucial that '\n + '{@link __isRef} is present and equal to true, internal logic relies on this marker '\n + 'to build block dependency trees.',\n )\n .readonly();\nexport type PlRef = z.infer<typeof PlRef>;\n/** @deprecated use {@link PlRef} */\nexport type Ref = PlRef;\n\n/**\n * Type guard to check if a value is a PlRef.\n *\n * @param value - The value to check.\n * @returns True if the value is a PlRef, false otherwise.\n */\nexport function isPlRef(value: unknown): value is PlRef {\n return (\n typeof value === 'object'\n && value !== null\n && '__isRef' in value\n && (value as { __isRef: unknown }).__isRef === true\n && 'blockId' in value\n && 'name' in value\n );\n}\n\n/** Standard way how to communicate possible connections given specific\n * requirements for incoming data. */\nexport type Option = {\n /** Fully rendered reference to be assigned for the intended field in block's\n * args */\n readonly ref: PlRef;\n\n /** Label to be present for the user in i.e. drop-down list */\n readonly label: string;\n};\n\n/**\n * Creates a PlRef with the given blockId and name.\n *\n * @param blockId - The blockId of the reference.\n * @param name - The name of the reference.\n * @param requireEnrichments - Whether the reference requires enrichments.\n */\nexport function createPlRef(blockId: string, name: string, requireEnrichments: boolean = false) {\n if (requireEnrichments)\n return {\n __isRef: true,\n blockId,\n name,\n requireEnrichments: true,\n };\n else\n return {\n __isRef: true,\n blockId,\n name,\n };\n}\n\n/**\n * Creates a new PlRef based on an existing one, explicitly setting (default) or removing the\n * requireEnrichments property.\n *\n * @param ref - The original PlRef object.\n * @param requireEnrichments - If true, the `requireEnrichments: true` property is added\n * to the returned PlRef. If false, the `requireEnrichments` property is removed. Defaults to true.\n * @returns A new PlRef object with the `requireEnrichments` property set or removed accordingly.\n */\nexport function withEnrichments(ref: PlRef, requireEnrichments: boolean = true): PlRef {\n if (requireEnrichments)\n return {\n ...ref,\n requireEnrichments: true,\n };\n else {\n const { requireEnrichments: _, ...rest } = ref;\n return rest;\n }\n}\n\n/** Compare two PlRefs and returns true if they are qual */\nexport function plRefsEqual(ref1: PlRef, ref2: PlRef, ignoreEnrichments: boolean = false) {\n return ref1.blockId === ref2.blockId && ref1.name === ref2.name && (ignoreEnrichments || ref1.requireEnrichments === ref2.requireEnrichments);\n}\n"],"names":[],"mappings":";;AAEO,MAAM,KAAK,GAAG;AAClB,KAAA,MAAM,CAAC;AACN,IAAA,OAAO,EAAE;SACN,OAAO,CAAC,IAAI;SACZ,QAAQ,CAAC,6DAA6D,CAAC;AAC1E,IAAA,OAAO,EAAE,CAAC,CAAC,MAAM;SACd,QAAQ,CAAC,mBAAmB,CAAC;AAChC,IAAA,IAAI,EAAE,CAAC,CAAC,MAAM;SACX,QAAQ,CAAC,qEAAqE,CAAC;IAClF,kBAAkB,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ;AACzC,SAAA,QAAQ,CAAC;AACN,UAAA,8FAA8F,CAAC;CACtG;AACA,KAAA,QAAQ,CACP;MACE;AACA,MAAA,kCAAkC;AAErC,KAAA,QAAQ;AAKX;;;;;AAKG;AACG,SAAU,OAAO,CAAC,KAAc,EAAA;AACpC,IAAA,QACE,OAAO,KAAK,KAAK;AACd,WAAA,KAAK,KAAK;AACV,WAAA,SAAS,IAAI;WACZ,KAA8B,CAAC,OAAO,KAAK;AAC5C,WAAA,SAAS,IAAI;WACb,MAAM,IAAI,KAAK;AAEtB;AAaA;;;;;;AAMG;AACG,SAAU,WAAW,CAAC,OAAe,EAAE,IAAY,EAAE,qBAA8B,KAAK,EAAA;AAC5F,IAAA,IAAI,kBAAkB;QACpB,OAAO;AACL,YAAA,OAAO,EAAE,IAAI;YACb,OAAO;YACP,IAAI;AACJ,YAAA,kBAAkB,EAAE,IAAI;SACzB;;QAED,OAAO;AACL,YAAA,OAAO,EAAE,IAAI;YACb,OAAO;YACP,IAAI;SACL;AACL;AAEA;;;;;;;;AAQG;SACa,eAAe,CAAC,GAAU,EAAE,qBAA8B,IAAI,EAAA;AAC5E,IAAA,IAAI,kBAAkB;QACpB,OAAO;AACL,YAAA,GAAG,GAAG;AACN,YAAA,kBAAkB,EAAE,IAAI;SACzB;SACE;QACH,MAAM,EAAE,kBAAkB,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG;AAC9C,QAAA,OAAO,IAAI;IACb;AACF;AAEA;AACM,SAAU,WAAW,CAAC,IAAW,EAAE,IAAW,EAAE,oBAA6B,KAAK,EAAA;IACtF,OAAO,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,iBAAiB,IAAI,IAAI,CAAC,kBAAkB,KAAK,IAAI,CAAC,kBAAkB,CAAC;AAC/I;;;;"}
package/dist/utag.d.ts CHANGED
@@ -15,4 +15,3 @@ export interface ValueWithUTag<V> {
15
15
  export interface ValueWithUTagAndAuthor<V> extends ValueWithUTag<V> {
16
16
  readonly author?: AuthorMarker;
17
17
  }
18
- //# sourceMappingURL=utag.d.ts.map
package/dist/util.cjs ADDED
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ function assertNever(x) {
4
+ throw new Error('Unexpected object: ' + x); // This is ok, because this is a possible runtime error
5
+ }
6
+
7
+ exports.assertNever = assertNever;
8
+ //# sourceMappingURL=util.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.cjs","sources":["../src/util.ts"],"sourcesContent":["export function assertNever(x: never): never {\n throw new Error('Unexpected object: ' + x); // This is ok, because this is a possible runtime error\n}\n"],"names":[],"mappings":";;AAAM,SAAU,WAAW,CAAC,CAAQ,EAAA;IAClC,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC;AAC7C;;;;"}
package/dist/util.d.ts CHANGED
@@ -1,2 +1 @@
1
1
  export declare function assertNever(x: never): never;
2
- //# sourceMappingURL=util.d.ts.map
package/dist/util.js ADDED
@@ -0,0 +1,6 @@
1
+ function assertNever(x) {
2
+ throw new Error('Unexpected object: ' + x); // This is ok, because this is a possible runtime error
3
+ }
4
+
5
+ export { assertNever };
6
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sources":["../src/util.ts"],"sourcesContent":["export function assertNever(x: never): never {\n throw new Error('Unexpected object: ' + x); // This is ok, because this is a possible runtime error\n}\n"],"names":[],"mappings":"AAAM,SAAU,WAAW,CAAC,CAAQ,EAAA;IAClC,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC;AAC7C;;;;"}
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ function mapValueInVOE(voe, cb) {
4
+ return voe.ok ? { ok: true, value: cb(voe.value) } : voe;
5
+ }
6
+
7
+ exports.mapValueInVOE = mapValueInVOE;
8
+ //# sourceMappingURL=value_or_error.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value_or_error.cjs","sources":["../src/value_or_error.ts"],"sourcesContent":["export type ValueOrError<V, E> =\n | {\n ok: true;\n value: V;\n }\n | {\n ok: false;\n error: E;\n };\n\nexport function mapValueInVOE<V1, V2, E>(\n voe: ValueOrError<V1, E>,\n cb: (value: V1) => V2,\n): ValueOrError<V2, E> {\n return voe.ok ? { ok: true, value: cb(voe.value) } : voe;\n}\n"],"names":[],"mappings":";;AAUM,SAAU,aAAa,CAC3B,GAAwB,EACxB,EAAqB,EAAA;IAErB,OAAO,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,GAAG;AAC1D;;;;"}
@@ -6,4 +6,3 @@ export type ValueOrError<V, E> = {
6
6
  error: E;
7
7
  };
8
8
  export declare function mapValueInVOE<V1, V2, E>(voe: ValueOrError<V1, E>, cb: (value: V1) => V2): ValueOrError<V2, E>;
9
- //# sourceMappingURL=value_or_error.d.ts.map
@@ -0,0 +1,6 @@
1
+ function mapValueInVOE(voe, cb) {
2
+ return voe.ok ? { ok: true, value: cb(voe.value) } : voe;
3
+ }
4
+
5
+ export { mapValueInVOE };
6
+ //# sourceMappingURL=value_or_error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value_or_error.js","sources":["../src/value_or_error.ts"],"sourcesContent":["export type ValueOrError<V, E> =\n | {\n ok: true;\n value: V;\n }\n | {\n ok: false;\n error: E;\n };\n\nexport function mapValueInVOE<V1, V2, E>(\n voe: ValueOrError<V1, E>,\n cb: (value: V1) => V2,\n): ValueOrError<V2, E> {\n return voe.ok ? { ok: true, value: cb(voe.value) } : voe;\n}\n"],"names":[],"mappings":"AAUM,SAAU,aAAa,CAC3B,GAAwB,EACxB,EAAqB,EAAA;IAErB,OAAO,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,GAAG;AAC1D;;;;"}