@milaboratories/pl-model-common 1.25.1 → 1.25.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/author_marker.d.ts +9 -6
- package/dist/base32_encode.cjs +40 -46
- package/dist/base32_encode.cjs.map +1 -1
- package/dist/base32_encode.js +40 -45
- package/dist/base32_encode.js.map +1 -1
- package/dist/base64.cjs +5 -4
- package/dist/base64.cjs.map +1 -1
- package/dist/base64.d.ts +10 -6
- package/dist/base64.js +5 -3
- package/dist/base64.js.map +1 -1
- package/dist/block_state.d.ts +21 -23
- package/dist/bmodel/block_config.cjs +9 -10
- package/dist/bmodel/block_config.cjs.map +1 -1
- package/dist/bmodel/block_config.d.ts +53 -72
- package/dist/bmodel/block_config.js +9 -9
- package/dist/bmodel/block_config.js.map +1 -1
- package/dist/bmodel/code.cjs +7 -6
- package/dist/bmodel/code.cjs.map +1 -1
- package/dist/bmodel/code.d.ts +17 -13
- package/dist/bmodel/code.js +6 -4
- package/dist/bmodel/code.js.map +1 -1
- package/dist/bmodel/container.d.ts +46 -44
- package/dist/bmodel/index.cjs +3 -0
- package/dist/bmodel/index.d.ts +5 -6
- package/dist/bmodel/index.js +3 -0
- package/dist/bmodel/normalization.cjs +90 -106
- package/dist/bmodel/normalization.cjs.map +1 -1
- package/dist/bmodel/normalization.d.ts +7 -3
- package/dist/bmodel/normalization.js +90 -105
- package/dist/bmodel/normalization.js.map +1 -1
- package/dist/bmodel/types.d.ts +4 -1
- package/dist/branding.d.ts +5 -5
- package/dist/common_types.d.ts +19 -15
- package/dist/driver_kit.d.ts +25 -17
- package/dist/drivers/ChunkedStreamReader.cjs +168 -203
- package/dist/drivers/ChunkedStreamReader.cjs.map +1 -1
- package/dist/drivers/ChunkedStreamReader.d.ts +104 -100
- package/dist/drivers/ChunkedStreamReader.js +168 -202
- package/dist/drivers/ChunkedStreamReader.js.map +1 -1
- package/dist/drivers/blob.cjs +15 -17
- package/dist/drivers/blob.cjs.map +1 -1
- package/dist/drivers/blob.d.ts +35 -35
- package/dist/drivers/blob.js +14 -15
- package/dist/drivers/blob.js.map +1 -1
- package/dist/drivers/index.cjs +18 -0
- package/dist/drivers/index.d.ts +29 -9
- package/dist/drivers/index.js +18 -0
- package/dist/drivers/interfaces.d.ts +17 -14
- package/dist/drivers/log.cjs +4 -3
- package/dist/drivers/log.cjs.map +1 -1
- package/dist/drivers/log.d.ts +52 -49
- package/dist/drivers/log.js +4 -2
- package/dist/drivers/log.js.map +1 -1
- package/dist/drivers/ls.cjs +16 -19
- package/dist/drivers/ls.cjs.map +1 -1
- package/dist/drivers/ls.d.ts +73 -76
- package/dist/drivers/ls.js +16 -17
- package/dist/drivers/ls.js.map +1 -1
- package/dist/drivers/pframe/column_filter.d.ts +19 -15
- package/dist/drivers/pframe/data_info.cjs +201 -252
- package/dist/drivers/pframe/data_info.cjs.map +1 -1
- package/dist/drivers/pframe/data_info.d.ts +84 -109
- package/dist/drivers/pframe/data_info.js +201 -250
- package/dist/drivers/pframe/data_info.js.map +1 -1
- package/dist/drivers/pframe/data_types.cjs +38 -63
- package/dist/drivers/pframe/data_types.cjs.map +1 -1
- package/dist/drivers/pframe/data_types.d.ts +91 -93
- package/dist/drivers/pframe/data_types.js +38 -61
- package/dist/drivers/pframe/data_types.js.map +1 -1
- package/dist/drivers/pframe/driver.cjs +7 -0
- package/dist/drivers/pframe/driver.cjs.map +1 -0
- package/dist/drivers/pframe/driver.d.ts +50 -45
- package/dist/drivers/pframe/driver.js +6 -0
- package/dist/drivers/pframe/driver.js.map +1 -0
- package/dist/drivers/pframe/filter_spec.d.ts +127 -123
- package/dist/drivers/pframe/find_columns.d.ts +21 -17
- package/dist/drivers/pframe/index.cjs +15 -0
- package/dist/drivers/pframe/index.d.ts +23 -16
- package/dist/drivers/pframe/index.js +15 -0
- package/dist/drivers/pframe/linker_columns.cjs +184 -238
- package/dist/drivers/pframe/linker_columns.cjs.map +1 -1
- package/dist/drivers/pframe/linker_columns.d.ts +45 -38
- package/dist/drivers/pframe/linker_columns.js +184 -236
- package/dist/drivers/pframe/linker_columns.js.map +1 -1
- package/dist/drivers/pframe/pframe.d.ts +26 -21
- package/dist/drivers/pframe/query/index.cjs +1 -0
- package/dist/drivers/pframe/query/index.d.ts +3 -4
- package/dist/drivers/pframe/query/index.js +1 -0
- package/dist/drivers/pframe/query/query_common.d.ts +205 -247
- package/dist/drivers/pframe/query/query_data.d.ts +25 -23
- package/dist/drivers/pframe/query/query_spec.d.ts +30 -29
- package/dist/drivers/pframe/query/utils.cjs +164 -183
- package/dist/drivers/pframe/query/utils.cjs.map +1 -1
- package/dist/drivers/pframe/query/utils.d.ts +13 -12
- package/dist/drivers/pframe/query/utils.js +164 -181
- package/dist/drivers/pframe/query/utils.js.map +1 -1
- package/dist/drivers/pframe/spec/anchored.cjs +178 -216
- package/dist/drivers/pframe/spec/anchored.cjs.map +1 -1
- package/dist/drivers/pframe/spec/anchored.d.ts +53 -49
- package/dist/drivers/pframe/spec/anchored.js +176 -214
- package/dist/drivers/pframe/spec/anchored.js.map +1 -1
- package/dist/drivers/pframe/spec/filtered_column.cjs +8 -7
- package/dist/drivers/pframe/spec/filtered_column.cjs.map +1 -1
- package/dist/drivers/pframe/spec/filtered_column.d.ts +20 -17
- package/dist/drivers/pframe/spec/filtered_column.js +8 -6
- package/dist/drivers/pframe/spec/filtered_column.js.map +1 -1
- package/dist/drivers/pframe/spec/ids.cjs +16 -14
- package/dist/drivers/pframe/spec/ids.cjs.map +1 -1
- package/dist/drivers/pframe/spec/ids.d.ts +13 -8
- package/dist/drivers/pframe/spec/ids.js +14 -12
- package/dist/drivers/pframe/spec/ids.js.map +1 -1
- package/dist/drivers/pframe/spec/index.cjs +6 -0
- package/dist/drivers/pframe/spec/index.d.ts +6 -7
- package/dist/drivers/pframe/spec/index.js +6 -0
- package/dist/drivers/pframe/spec/native_id.cjs +16 -16
- package/dist/drivers/pframe/spec/native_id.cjs.map +1 -1
- package/dist/drivers/pframe/spec/native_id.d.ts +9 -4
- package/dist/drivers/pframe/spec/native_id.js +13 -13
- package/dist/drivers/pframe/spec/native_id.js.map +1 -1
- package/dist/drivers/pframe/spec/selectors.cjs +72 -112
- package/dist/drivers/pframe/spec/selectors.cjs.map +1 -1
- package/dist/drivers/pframe/spec/selectors.d.ts +99 -94
- package/dist/drivers/pframe/spec/selectors.js +72 -110
- package/dist/drivers/pframe/spec/selectors.js.map +1 -1
- package/dist/drivers/pframe/spec/spec.cjs +282 -324
- package/dist/drivers/pframe/spec/spec.cjs.map +1 -1
- package/dist/drivers/pframe/spec/spec.d.ts +263 -272
- package/dist/drivers/pframe/spec/spec.js +281 -322
- package/dist/drivers/pframe/spec/spec.js.map +1 -1
- package/dist/drivers/pframe/table.d.ts +28 -24
- package/dist/drivers/pframe/table_calculate.cjs +117 -147
- package/dist/drivers/pframe/table_calculate.cjs.map +1 -1
- package/dist/drivers/pframe/table_calculate.d.ts +219 -220
- package/dist/drivers/pframe/table_calculate.js +117 -145
- package/dist/drivers/pframe/table_calculate.js.map +1 -1
- package/dist/drivers/pframe/table_common.cjs +13 -14
- package/dist/drivers/pframe/table_common.cjs.map +1 -1
- package/dist/drivers/pframe/table_common.d.ts +24 -19
- package/dist/drivers/pframe/table_common.js +13 -13
- package/dist/drivers/pframe/table_common.js.map +1 -1
- package/dist/drivers/pframe/unique_values.d.ts +23 -18
- package/dist/drivers/upload.d.ts +21 -18
- package/dist/drivers/urls.cjs +5 -6
- package/dist/drivers/urls.cjs.map +1 -1
- package/dist/drivers/urls.d.ts +12 -9
- package/dist/drivers/urls.js +5 -5
- package/dist/drivers/urls.js.map +1 -1
- package/dist/errors.cjs +65 -86
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +36 -33
- package/dist/errors.js +65 -85
- package/dist/errors.js.map +1 -1
- package/dist/flags/block_flags.cjs +7 -6
- package/dist/flags/block_flags.cjs.map +1 -1
- package/dist/flags/block_flags.d.ts +12 -8
- package/dist/flags/block_flags.js +7 -5
- package/dist/flags/block_flags.js.map +1 -1
- package/dist/flags/flag_utils.cjs +69 -108
- package/dist/flags/flag_utils.cjs.map +1 -1
- package/dist/flags/flag_utils.d.ts +40 -42
- package/dist/flags/flag_utils.js +70 -107
- package/dist/flags/flag_utils.js.map +1 -1
- package/dist/flags/type_utils.d.ts +12 -11
- package/dist/httpAuth.cjs +16 -20
- package/dist/httpAuth.cjs.map +1 -1
- package/dist/httpAuth.d.ts +10 -7
- package/dist/httpAuth.js +16 -19
- package/dist/httpAuth.js.map +1 -1
- package/dist/index.cjs +176 -179
- package/dist/index.d.ts +58 -20
- package/dist/index.js +37 -34
- package/dist/json.cjs +10 -8
- package/dist/json.cjs.map +1 -1
- package/dist/json.d.ts +18 -18
- package/dist/json.js +8 -6
- package/dist/json.js.map +1 -1
- package/dist/navigation.cjs +3 -2
- package/dist/navigation.cjs.map +1 -1
- package/dist/navigation.d.ts +18 -21
- package/dist/navigation.js +3 -1
- package/dist/navigation.js.map +1 -1
- package/dist/plid.cjs +16 -20
- package/dist/plid.cjs.map +1 -1
- package/dist/plid.d.ts +11 -7
- package/dist/plid.js +15 -18
- package/dist/plid.js.map +1 -1
- package/dist/pool/entry.d.ts +11 -11
- package/dist/pool/index.d.ts +3 -4
- package/dist/pool/query.cjs +21 -43
- package/dist/pool/query.cjs.map +1 -1
- package/dist/pool/query.d.ts +25 -20
- package/dist/pool/query.js +20 -40
- package/dist/pool/query.js.map +1 -1
- package/dist/pool/spec.cjs +40 -47
- package/dist/pool/spec.cjs.map +1 -1
- package/dist/pool/spec.d.ts +33 -31
- package/dist/pool/spec.js +40 -45
- package/dist/pool/spec.js.map +1 -1
- package/dist/ref.cjs +51 -71
- package/dist/ref.cjs.map +1 -1
- package/dist/ref.d.ts +36 -33
- package/dist/ref.js +50 -69
- package/dist/ref.js.map +1 -1
- package/dist/utag.d.ts +18 -14
- package/dist/util.cjs +8 -7
- package/dist/util.cjs.map +1 -1
- package/dist/util.d.ts +5 -2
- package/dist/util.js +8 -6
- package/dist/util.js.map +1 -1
- package/dist/value_or_error.cjs +7 -3
- package/dist/value_or_error.cjs.map +1 -1
- package/dist/value_or_error.d.ts +9 -6
- package/dist/value_or_error.js +7 -2
- package/dist/value_or_error.js.map +1 -1
- package/package.json +6 -6
- package/src/flags/block_flags.ts +2 -1
- package/src/flags/flag_utils.ts +0 -22
- package/dist/author_marker.d.ts.map +0 -1
- package/dist/base32_encode.d.ts +0 -8
- package/dist/base32_encode.d.ts.map +0 -1
- package/dist/base64.d.ts.map +0 -1
- package/dist/block_state.d.ts.map +0 -1
- package/dist/bmodel/block_config.d.ts.map +0 -1
- package/dist/bmodel/code.d.ts.map +0 -1
- package/dist/bmodel/container.d.ts.map +0 -1
- package/dist/bmodel/index.d.ts.map +0 -1
- package/dist/bmodel/normalization.d.ts.map +0 -1
- package/dist/bmodel/types.d.ts.map +0 -1
- package/dist/branding.d.ts.map +0 -1
- package/dist/common_types.d.ts.map +0 -1
- package/dist/driver_kit.d.ts.map +0 -1
- package/dist/drivers/ChunkedStreamReader.d.ts.map +0 -1
- package/dist/drivers/blob.d.ts.map +0 -1
- package/dist/drivers/index.d.ts.map +0 -1
- package/dist/drivers/interfaces.d.ts.map +0 -1
- package/dist/drivers/log.d.ts.map +0 -1
- package/dist/drivers/ls.d.ts.map +0 -1
- package/dist/drivers/pframe/column_filter.d.ts.map +0 -1
- package/dist/drivers/pframe/data_info.d.ts.map +0 -1
- package/dist/drivers/pframe/data_types.d.ts.map +0 -1
- package/dist/drivers/pframe/driver.d.ts.map +0 -1
- package/dist/drivers/pframe/filter_spec.d.ts.map +0 -1
- package/dist/drivers/pframe/find_columns.d.ts.map +0 -1
- package/dist/drivers/pframe/index.d.ts.map +0 -1
- package/dist/drivers/pframe/linker_columns.d.ts.map +0 -1
- package/dist/drivers/pframe/pframe.d.ts.map +0 -1
- package/dist/drivers/pframe/query/index.d.ts.map +0 -1
- package/dist/drivers/pframe/query/query_common.d.ts.map +0 -1
- package/dist/drivers/pframe/query/query_data.d.ts.map +0 -1
- package/dist/drivers/pframe/query/query_spec.d.ts.map +0 -1
- package/dist/drivers/pframe/query/utils.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/anchored.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/filtered_column.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/ids.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/index.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/native_id.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/selectors.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/spec.d.ts.map +0 -1
- package/dist/drivers/pframe/table.d.ts.map +0 -1
- package/dist/drivers/pframe/table_calculate.d.ts.map +0 -1
- package/dist/drivers/pframe/table_common.d.ts.map +0 -1
- package/dist/drivers/pframe/type_util.d.ts +0 -5
- package/dist/drivers/pframe/type_util.d.ts.map +0 -1
- package/dist/drivers/pframe/unique_values.d.ts.map +0 -1
- package/dist/drivers/upload.d.ts.map +0 -1
- package/dist/drivers/urls.d.ts.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/flags/block_flags.d.ts.map +0 -1
- package/dist/flags/flag_utils.d.ts.map +0 -1
- package/dist/flags/index.d.ts +0 -4
- package/dist/flags/index.d.ts.map +0 -1
- package/dist/flags/type_utils.d.ts.map +0 -1
- package/dist/httpAuth.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/json.d.ts.map +0 -1
- package/dist/navigation.d.ts.map +0 -1
- package/dist/plid.d.ts.map +0 -1
- package/dist/pool/entry.d.ts.map +0 -1
- package/dist/pool/index.d.ts.map +0 -1
- package/dist/pool/query.d.ts.map +0 -1
- package/dist/pool/spec.d.ts.map +0 -1
- package/dist/ref.d.ts.map +0 -1
- package/dist/utag.d.ts.map +0 -1
- package/dist/util.d.ts.map +0 -1
- package/dist/value_or_error.d.ts.map +0 -1
package/dist/pool/query.js
CHANGED
|
@@ -1,47 +1,27 @@
|
|
|
1
|
-
import { isPColumnSpec } from
|
|
1
|
+
import { isPColumnSpec } from "./spec.js";
|
|
2
2
|
|
|
3
|
+
//#region src/pool/query.ts
|
|
3
4
|
function assertNever(x) {
|
|
4
|
-
|
|
5
|
+
throw new Error("Unexpected object: " + x);
|
|
5
6
|
}
|
|
6
7
|
function executePSpecPredicate(predicate, spec) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
}
|
|
8
|
+
switch (predicate.type) {
|
|
9
|
+
case "and":
|
|
10
|
+
for (const operator of predicate.operands) if (!executePSpecPredicate(operator, spec)) return false;
|
|
11
|
+
return true;
|
|
12
|
+
case "or":
|
|
13
|
+
for (const operator of predicate.operands) if (executePSpecPredicate(operator, spec)) return true;
|
|
14
|
+
return false;
|
|
15
|
+
case "not": return !executePSpecPredicate(predicate.operand, spec);
|
|
16
|
+
case "name": return isPColumnSpec(spec) && spec.name === predicate.name;
|
|
17
|
+
case "name_pattern": return isPColumnSpec(spec) && Boolean(spec.name.match(predicate.pattern));
|
|
18
|
+
case "annotation": return isPColumnSpec(spec) && spec.annotations !== void 0 && spec.annotations[predicate.annotation] === predicate.value;
|
|
19
|
+
case "annotation_pattern": return isPColumnSpec(spec) && spec.annotations !== void 0 && spec.annotations[predicate.annotation] !== void 0 && Boolean(spec.annotations[predicate.annotation].match(predicate.pattern));
|
|
20
|
+
case "has_axes": return isPColumnSpec(spec) && predicate.axes.every((matcher) => spec.axesSpec.some((axisSpec) => (matcher.type === void 0 || matcher.type === axisSpec.type) && (matcher.name === void 0 || matcher.name === axisSpec.name) && (matcher.domain === void 0 || Object.keys(matcher.domain).length === 0 || axisSpec.domain !== void 0 && Object.entries(matcher.domain).every(([domain, domainValue]) => axisSpec.domain[domain] === domainValue))));
|
|
21
|
+
default: assertNever(predicate);
|
|
22
|
+
}
|
|
44
23
|
}
|
|
45
24
|
|
|
25
|
+
//#endregion
|
|
46
26
|
export { executePSpecPredicate };
|
|
47
|
-
//# sourceMappingURL=query.js.map
|
|
27
|
+
//# sourceMappingURL=query.js.map
|
package/dist/pool/query.js.map
CHANGED
|
@@ -1 +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(predicate: PSpecPredicate, spec: PObjectSpec): 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]) => axisSpec.domain![domain] === domainValue,\n ))),\n ),\n )\n );\n default:\n assertNever(predicate);\n }\n}\n"],"
|
|
1
|
+
{"version":3,"file":"query.js","names":[],"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(predicate: PSpecPredicate, spec: PObjectSpec): 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]) => axisSpec.domain![domain] === domainValue,\n ))),\n ),\n )\n );\n default:\n assertNever(predicate);\n }\n}\n"],"mappings":";;;AAoCA,SAAS,YAAY,GAAiB;AACpC,OAAM,IAAI,MAAM,wBAAwB,EAAE;;AAG5C,SAAgB,sBAAsB,WAA2B,MAA4B;AAC3F,SAAQ,UAAU,MAAlB;EACE,KAAK;AACH,QAAK,MAAM,YAAY,UAAU,SAC/B,KAAI,CAAC,sBAAsB,UAAU,KAAK,CAAE,QAAO;AACrD,UAAO;EACT,KAAK;AACH,QAAK,MAAM,YAAY,UAAU,SAC/B,KAAI,sBAAsB,UAAU,KAAK,CAAE,QAAO;AACpD,UAAO;EACT,KAAK,MACH,QAAO,CAAC,sBAAsB,UAAU,SAAS,KAAK;EACxD,KAAK,OACH,QAAO,cAAc,KAAK,IAAI,KAAK,SAAS,UAAU;EACxD,KAAK,eACH,QAAO,cAAc,KAAK,IAAI,QAAQ,KAAK,KAAK,MAAM,UAAU,QAAQ,CAAC;EAC3E,KAAK,aACH,QACE,cAAc,KAAK,IACnB,KAAK,gBAAgB,UACrB,KAAK,YAAY,UAAU,gBAAgB,UAAU;EAEzD,KAAK,qBACH,QACE,cAAc,KAAK,IACnB,KAAK,gBAAgB,UACrB,KAAK,YAAY,UAAU,gBAAgB,UAC3C,QAAQ,KAAK,YAAY,UAAU,YAAY,MAAM,UAAU,QAAQ,CAAC;EAE5E,KAAK,WACH,QACE,cAAc,KAAK,IACnB,UAAU,KAAK,OAAO,YACpB,KAAK,SAAS,MACX,cACE,QAAQ,SAAS,UAAa,QAAQ,SAAS,SAAS,UACxD,QAAQ,SAAS,UAAa,QAAQ,SAAS,SAAS,UACxD,QAAQ,WAAW,UAClB,OAAO,KAAK,QAAQ,OAAO,CAAC,WAAW,KACtC,SAAS,WAAW,UACnB,OAAO,QAAQ,QAAQ,OAAO,CAAC,OAC5B,CAAC,QAAQ,iBAAiB,SAAS,OAAQ,YAAY,YACzD,EACR,CACF;EAEL,QACE,aAAY,UAAU"}
|
package/dist/pool/spec.cjs
CHANGED
|
@@ -1,65 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var util = require('../util.cjs');
|
|
1
|
+
const require_util = require('../util.cjs');
|
|
4
2
|
|
|
3
|
+
//#region src/pool/spec.ts
|
|
5
4
|
function isPColumnSpec(spec) {
|
|
6
|
-
|
|
5
|
+
return spec.kind === "PColumn";
|
|
7
6
|
}
|
|
8
7
|
function isPColumn(obj) {
|
|
9
|
-
|
|
8
|
+
return isPColumnSpec(obj.spec);
|
|
10
9
|
}
|
|
11
10
|
function isPColumnSpecResult(r) {
|
|
12
|
-
|
|
11
|
+
return isPColumnSpec(r.obj);
|
|
13
12
|
}
|
|
14
13
|
function isPColumnResult(r) {
|
|
15
|
-
|
|
14
|
+
return isPColumnSpec(r.obj.spec);
|
|
16
15
|
}
|
|
17
16
|
function ensurePColumn(obj) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return obj;
|
|
17
|
+
if (!isPColumn(obj)) throw new Error(`not a PColumn (kind = ${obj.spec.kind})`);
|
|
18
|
+
return obj;
|
|
21
19
|
}
|
|
22
20
|
function mapPObjectData(pObj, cb) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
data: cb(typeof pObj.data === "function" ? pObj.data() : pObj.data),
|
|
28
|
-
};
|
|
21
|
+
return pObj === void 0 ? void 0 : {
|
|
22
|
+
...pObj,
|
|
23
|
+
data: cb(typeof pObj.data === "function" ? pObj.data() : pObj.data)
|
|
24
|
+
};
|
|
29
25
|
}
|
|
30
26
|
function extractAllColumns(entry) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
addAllColumns(entry);
|
|
60
|
-
return [...columns.values()];
|
|
27
|
+
const columns = /* @__PURE__ */ new Map();
|
|
28
|
+
const addAllColumns = (entry) => {
|
|
29
|
+
switch (entry.type) {
|
|
30
|
+
case "column":
|
|
31
|
+
columns.set(entry.column.id, entry.column);
|
|
32
|
+
return;
|
|
33
|
+
case "slicedColumn":
|
|
34
|
+
columns.set(entry.column.id, entry.column);
|
|
35
|
+
return;
|
|
36
|
+
case "artificialColumn":
|
|
37
|
+
columns.set(entry.column.id, entry.column);
|
|
38
|
+
return;
|
|
39
|
+
case "inlineColumn": return;
|
|
40
|
+
case "full":
|
|
41
|
+
case "inner":
|
|
42
|
+
for (const e of entry.entries) addAllColumns(e);
|
|
43
|
+
return;
|
|
44
|
+
case "outer":
|
|
45
|
+
addAllColumns(entry.primary);
|
|
46
|
+
for (const e of entry.secondary) addAllColumns(e);
|
|
47
|
+
return;
|
|
48
|
+
default: require_util.assertNever(entry);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
addAllColumns(entry);
|
|
52
|
+
return [...columns.values()];
|
|
61
53
|
}
|
|
62
54
|
|
|
55
|
+
//#endregion
|
|
63
56
|
exports.ensurePColumn = ensurePColumn;
|
|
64
57
|
exports.extractAllColumns = extractAllColumns;
|
|
65
58
|
exports.isPColumn = isPColumn;
|
|
@@ -67,4 +60,4 @@ exports.isPColumnResult = isPColumnResult;
|
|
|
67
60
|
exports.isPColumnSpec = isPColumnSpec;
|
|
68
61
|
exports.isPColumnSpecResult = isPColumnSpecResult;
|
|
69
62
|
exports.mapPObjectData = mapPObjectData;
|
|
70
|
-
//# sourceMappingURL=spec.cjs.map
|
|
63
|
+
//# sourceMappingURL=spec.cjs.map
|
package/dist/pool/spec.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec.cjs","sources":["../../src/pool/spec.ts"],"sourcesContent":["import type { Branded } from \"../branding\";\nimport type { JoinEntry, PColumn, PColumnLazy, 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 type 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>(\n pObj: PColumn<D1> | PColumnLazy<D1>,\n cb: (d: D1) => D2,\n): PColumn<D2>;\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(typeof pObj.data === \"function\" ? pObj.data() : 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 \"artificialColumn\":\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"],"
|
|
1
|
+
{"version":3,"file":"spec.cjs","names":[],"sources":["../../src/pool/spec.ts"],"sourcesContent":["import type { Branded } from \"../branding\";\nimport type { JoinEntry, PColumn, PColumnLazy, 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 type 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>(\n pObj: PColumn<D1> | PColumnLazy<D1>,\n cb: (d: D1) => D2,\n): PColumn<D2>;\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(typeof pObj.data === \"function\" ? pObj.data() : 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 \"artificialColumn\":\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"],"mappings":";;;AAuCA,SAAgB,cAAc,MAAwC;AACpE,QAAO,KAAK,SAAS;;AAGvB,SAAgB,UAAa,KAAoC;AAC/D,QAAO,cAAc,IAAI,KAAK;;AAGhC,SAAgB,oBACd,GACmC;AACnC,QAAO,cAAc,EAAE,IAAI;;AAG7B,SAAgB,gBACd,GACkC;AAClC,QAAO,cAAc,EAAE,IAAI,KAAK;;AAGlC,SAAgB,cAAiB,KAA6B;AAC5D,KAAI,CAAC,UAAU,IAAI,CAAE,OAAM,IAAI,MAAM,yBAAyB,IAAI,KAAK,KAAK,GAAG;AAC/E,QAAO;;AAiBT,SAAgB,eACd,MACA,IACyB;AACzB,QAAO,SAAS,SACZ,SACA;EACE,GAAG;EACH,MAAM,GAAG,OAAO,KAAK,SAAS,aAAa,KAAK,MAAM,GAAG,KAAK,KAAK;EACpE;;AAGP,SAAgB,kBAAqB,OAA4C;CAC/E,MAAM,0BAAU,IAAI,KAA4B;CAChD,MAAM,iBAAiB,UAAiC;AACtD,UAAQ,MAAM,MAAd;GACE,KAAK;AACH,YAAQ,IAAI,MAAM,OAAO,IAAI,MAAM,OAAO;AAC1C;GACF,KAAK;AACH,YAAQ,IAAI,MAAM,OAAO,IAAI,MAAM,OAAO;AAC1C;GACF,KAAK;AACH,YAAQ,IAAI,MAAM,OAAO,IAAI,MAAM,OAAO;AAC1C;GACF,KAAK,eACH;GACF,KAAK;GACL,KAAK;AACH,SAAK,MAAM,KAAK,MAAM,QAAS,eAAc,EAAE;AAC/C;GACF,KAAK;AACH,kBAAc,MAAM,QAAQ;AAC5B,SAAK,MAAM,KAAK,MAAM,UAAW,eAAc,EAAE;AACjD;GACF,QACE,0BAAY,MAAM;;;AAGxB,eAAc,MAAM;AACpB,QAAO,CAAC,GAAG,QAAQ,QAAQ,CAAC"}
|
package/dist/pool/spec.d.ts
CHANGED
|
@@ -1,41 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { Branded } from "../branding.js";
|
|
2
|
+
import { ResultPoolEntry } from "./entry.js";
|
|
3
|
+
import { PColumn, PColumnLazy, PColumnSpec } from "../drivers/pframe/spec/spec.js";
|
|
4
|
+
import { JoinEntry } from "../drivers/pframe/table_calculate.js";
|
|
5
|
+
import "../drivers/index.js";
|
|
6
|
+
|
|
7
|
+
//#region src/pool/spec.d.ts
|
|
4
8
|
/** Any object exported into the result pool by the block always have spec attached to it */
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/** Domain is a set of key-value pairs that can be used to identify the object */
|
|
11
|
-
readonly domain?: Record<string, string>;
|
|
12
|
-
/** Additional information attached to the object */
|
|
13
|
-
readonly annotations?: Record<string, string>;
|
|
9
|
+
type PObjectSpec = {
|
|
10
|
+
/** PObject kind discriminator */readonly kind: string; /** Name is common part of PObject identity */
|
|
11
|
+
readonly name: string; /** Domain is a set of key-value pairs that can be used to identify the object */
|
|
12
|
+
readonly domain?: Record<string, string>; /** Additional information attached to the object */
|
|
13
|
+
readonly annotations?: Record<string, string>;
|
|
14
14
|
};
|
|
15
15
|
/** Stable PObject id */
|
|
16
|
-
|
|
16
|
+
type PObjectId = Branded<string, "PColumnId">;
|
|
17
17
|
/**
|
|
18
18
|
* Full PObject representation.
|
|
19
19
|
*
|
|
20
20
|
* @template Data type of the object referencing or describing the "data" part of the PObject
|
|
21
21
|
* */
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
interface PObject<Data> {
|
|
23
|
+
/** Fully rendered PObjects are assigned a stable identifier. */
|
|
24
|
+
readonly id: PObjectId;
|
|
25
|
+
/** PObject spec, allowing it to be found among other PObjects */
|
|
26
|
+
readonly spec: PObjectSpec;
|
|
27
|
+
/** A handle to data object */
|
|
28
|
+
readonly data: Data;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
declare function isPColumnSpec(spec: PObjectSpec): spec is PColumnSpec;
|
|
31
|
+
declare function isPColumn<T>(obj: PObject<T>): obj is PColumn<T>;
|
|
32
|
+
declare function isPColumnSpecResult(r: ResultPoolEntry<PObjectSpec>): r is ResultPoolEntry<PColumnSpec>;
|
|
33
|
+
declare function isPColumnResult<T>(r: ResultPoolEntry<PObject<T>>): r is ResultPoolEntry<PColumn<T>>;
|
|
34
|
+
declare function ensurePColumn<T>(obj: PObject<T>): PColumn<T>;
|
|
35
|
+
declare function mapPObjectData<D1, D2>(pObj: PColumn<D1> | PColumnLazy<D1>, cb: (d: D1) => D2): PColumn<D2>;
|
|
36
|
+
declare function mapPObjectData<D1, D2>(pObj: PColumn<D1>, cb: (d: D1) => D2): PColumn<D2>;
|
|
37
|
+
declare function mapPObjectData<D1, D2>(pObj: PColumn<D1> | undefined, cb: (d: D1) => D2): PColumn<D2> | undefined;
|
|
38
|
+
declare function mapPObjectData<D1, D2>(pObj: PObject<D1>, cb: (d: D1) => D2): PObject<D2>;
|
|
39
|
+
declare function mapPObjectData<D1, D2>(pObj: PObject<D1> | undefined, cb: (d: D1) => D2): PObject<D2> | undefined;
|
|
40
|
+
declare function extractAllColumns<D>(entry: JoinEntry<PColumn<D>>): PColumn<D>[];
|
|
41
|
+
//#endregion
|
|
42
|
+
export { PObject, PObjectId, PObjectSpec, ensurePColumn, extractAllColumns, isPColumn, isPColumnResult, isPColumnSpec, isPColumnSpecResult, mapPObjectData };
|
|
41
43
|
//# sourceMappingURL=spec.d.ts.map
|
package/dist/pool/spec.js
CHANGED
|
@@ -1,62 +1,57 @@
|
|
|
1
|
-
import { assertNever } from
|
|
1
|
+
import { assertNever } from "../util.js";
|
|
2
2
|
|
|
3
|
+
//#region src/pool/spec.ts
|
|
3
4
|
function isPColumnSpec(spec) {
|
|
4
|
-
|
|
5
|
+
return spec.kind === "PColumn";
|
|
5
6
|
}
|
|
6
7
|
function isPColumn(obj) {
|
|
7
|
-
|
|
8
|
+
return isPColumnSpec(obj.spec);
|
|
8
9
|
}
|
|
9
10
|
function isPColumnSpecResult(r) {
|
|
10
|
-
|
|
11
|
+
return isPColumnSpec(r.obj);
|
|
11
12
|
}
|
|
12
13
|
function isPColumnResult(r) {
|
|
13
|
-
|
|
14
|
+
return isPColumnSpec(r.obj.spec);
|
|
14
15
|
}
|
|
15
16
|
function ensurePColumn(obj) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return obj;
|
|
17
|
+
if (!isPColumn(obj)) throw new Error(`not a PColumn (kind = ${obj.spec.kind})`);
|
|
18
|
+
return obj;
|
|
19
19
|
}
|
|
20
20
|
function mapPObjectData(pObj, cb) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
data: cb(typeof pObj.data === "function" ? pObj.data() : pObj.data),
|
|
26
|
-
};
|
|
21
|
+
return pObj === void 0 ? void 0 : {
|
|
22
|
+
...pObj,
|
|
23
|
+
data: cb(typeof pObj.data === "function" ? pObj.data() : pObj.data)
|
|
24
|
+
};
|
|
27
25
|
}
|
|
28
26
|
function extractAllColumns(entry) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
addAllColumns(entry);
|
|
58
|
-
return [...columns.values()];
|
|
27
|
+
const columns = /* @__PURE__ */ new Map();
|
|
28
|
+
const addAllColumns = (entry) => {
|
|
29
|
+
switch (entry.type) {
|
|
30
|
+
case "column":
|
|
31
|
+
columns.set(entry.column.id, entry.column);
|
|
32
|
+
return;
|
|
33
|
+
case "slicedColumn":
|
|
34
|
+
columns.set(entry.column.id, entry.column);
|
|
35
|
+
return;
|
|
36
|
+
case "artificialColumn":
|
|
37
|
+
columns.set(entry.column.id, entry.column);
|
|
38
|
+
return;
|
|
39
|
+
case "inlineColumn": return;
|
|
40
|
+
case "full":
|
|
41
|
+
case "inner":
|
|
42
|
+
for (const e of entry.entries) addAllColumns(e);
|
|
43
|
+
return;
|
|
44
|
+
case "outer":
|
|
45
|
+
addAllColumns(entry.primary);
|
|
46
|
+
for (const e of entry.secondary) addAllColumns(e);
|
|
47
|
+
return;
|
|
48
|
+
default: assertNever(entry);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
addAllColumns(entry);
|
|
52
|
+
return [...columns.values()];
|
|
59
53
|
}
|
|
60
54
|
|
|
55
|
+
//#endregion
|
|
61
56
|
export { ensurePColumn, extractAllColumns, isPColumn, isPColumnResult, isPColumnSpec, isPColumnSpecResult, mapPObjectData };
|
|
62
|
-
//# sourceMappingURL=spec.js.map
|
|
57
|
+
//# sourceMappingURL=spec.js.map
|
package/dist/pool/spec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec.js","sources":["../../src/pool/spec.ts"],"sourcesContent":["import type { Branded } from \"../branding\";\nimport type { JoinEntry, PColumn, PColumnLazy, 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 type 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>(\n pObj: PColumn<D1> | PColumnLazy<D1>,\n cb: (d: D1) => D2,\n): PColumn<D2>;\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(typeof pObj.data === \"function\" ? pObj.data() : 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 \"artificialColumn\":\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"],"
|
|
1
|
+
{"version":3,"file":"spec.js","names":[],"sources":["../../src/pool/spec.ts"],"sourcesContent":["import type { Branded } from \"../branding\";\nimport type { JoinEntry, PColumn, PColumnLazy, 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 type 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>(\n pObj: PColumn<D1> | PColumnLazy<D1>,\n cb: (d: D1) => D2,\n): PColumn<D2>;\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(typeof pObj.data === \"function\" ? pObj.data() : 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 \"artificialColumn\":\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"],"mappings":";;;AAuCA,SAAgB,cAAc,MAAwC;AACpE,QAAO,KAAK,SAAS;;AAGvB,SAAgB,UAAa,KAAoC;AAC/D,QAAO,cAAc,IAAI,KAAK;;AAGhC,SAAgB,oBACd,GACmC;AACnC,QAAO,cAAc,EAAE,IAAI;;AAG7B,SAAgB,gBACd,GACkC;AAClC,QAAO,cAAc,EAAE,IAAI,KAAK;;AAGlC,SAAgB,cAAiB,KAA6B;AAC5D,KAAI,CAAC,UAAU,IAAI,CAAE,OAAM,IAAI,MAAM,yBAAyB,IAAI,KAAK,KAAK,GAAG;AAC/E,QAAO;;AAiBT,SAAgB,eACd,MACA,IACyB;AACzB,QAAO,SAAS,SACZ,SACA;EACE,GAAG;EACH,MAAM,GAAG,OAAO,KAAK,SAAS,aAAa,KAAK,MAAM,GAAG,KAAK,KAAK;EACpE;;AAGP,SAAgB,kBAAqB,OAA4C;CAC/E,MAAM,0BAAU,IAAI,KAA4B;CAChD,MAAM,iBAAiB,UAAiC;AACtD,UAAQ,MAAM,MAAd;GACE,KAAK;AACH,YAAQ,IAAI,MAAM,OAAO,IAAI,MAAM,OAAO;AAC1C;GACF,KAAK;AACH,YAAQ,IAAI,MAAM,OAAO,IAAI,MAAM,OAAO;AAC1C;GACF,KAAK;AACH,YAAQ,IAAI,MAAM,OAAO,IAAI,MAAM,OAAO;AAC1C;GACF,KAAK,eACH;GACF,KAAK;GACL,KAAK;AACH,SAAK,MAAM,KAAK,MAAM,QAAS,eAAc,EAAE;AAC/C;GACF,KAAK;AACH,kBAAc,MAAM,QAAQ;AAC5B,SAAK,MAAM,KAAK,MAAM,UAAW,eAAc,EAAE;AACjD;GACF,QACE,aAAY,MAAM;;;AAGxB,eAAc,MAAM;AACpB,QAAO,CAAC,GAAG,QAAQ,QAAQ,CAAC"}
|
package/dist/ref.cjs
CHANGED
|
@@ -1,90 +1,70 @@
|
|
|
1
|
-
|
|
1
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
let zod = require("zod");
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
blockId: zod.z.string().describe("Upstream block id"),
|
|
11
|
-
name: zod.z.string().describe("Name of the output provided to the upstream block's output context"),
|
|
12
|
-
requireEnrichments: zod.z
|
|
13
|
-
.literal(true)
|
|
14
|
-
.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();
|
|
4
|
+
//#region src/ref.ts
|
|
5
|
+
const PlRef = zod.z.object({
|
|
6
|
+
__isRef: zod.z.literal(true).describe("Crucial marker for the block dependency tree reconstruction"),
|
|
7
|
+
blockId: zod.z.string().describe("Upstream block id"),
|
|
8
|
+
name: zod.z.string().describe("Name of the output provided to the upstream block's output context"),
|
|
9
|
+
requireEnrichments: zod.z.literal(true).optional().describe("True if current block that stores this reference in its args, may need enrichments for the references value originating from the blocks in between current and referenced block")
|
|
10
|
+
}).describe("Universal reference type, allowing to set block connections. It is crucial that {@link __isRef} is present and equal to true, internal logic relies on this marker to build block dependency trees.").readonly();
|
|
22
11
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
* Type guard to check if a value is a PlRef.
|
|
13
|
+
*
|
|
14
|
+
* @param value - The value to check.
|
|
15
|
+
* @returns True if the value is a PlRef, false otherwise.
|
|
16
|
+
*/
|
|
28
17
|
function isPlRef(value) {
|
|
29
|
-
|
|
30
|
-
value !== null &&
|
|
31
|
-
"__isRef" in value &&
|
|
32
|
-
value.__isRef === true &&
|
|
33
|
-
"blockId" in value &&
|
|
34
|
-
"name" in value);
|
|
18
|
+
return typeof value === "object" && value !== null && "__isRef" in value && value.__isRef === true && "blockId" in value && "name" in value;
|
|
35
19
|
}
|
|
36
20
|
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
21
|
+
* Creates a PlRef with the given blockId and name.
|
|
22
|
+
*
|
|
23
|
+
* @param blockId - The blockId of the reference.
|
|
24
|
+
* @param name - The name of the reference.
|
|
25
|
+
* @param requireEnrichments - Whether the reference requires enrichments.
|
|
26
|
+
*/
|
|
43
27
|
function createPlRef(blockId, name, requireEnrichments = false) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
name,
|
|
56
|
-
};
|
|
28
|
+
if (requireEnrichments) return {
|
|
29
|
+
__isRef: true,
|
|
30
|
+
blockId,
|
|
31
|
+
name,
|
|
32
|
+
requireEnrichments: true
|
|
33
|
+
};
|
|
34
|
+
else return {
|
|
35
|
+
__isRef: true,
|
|
36
|
+
blockId,
|
|
37
|
+
name
|
|
38
|
+
};
|
|
57
39
|
}
|
|
58
40
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
41
|
+
* Creates a new PlRef based on an existing one, explicitly setting (default) or removing the
|
|
42
|
+
* requireEnrichments property.
|
|
43
|
+
*
|
|
44
|
+
* @param ref - The original PlRef object.
|
|
45
|
+
* @param requireEnrichments - If true, the `requireEnrichments: true` property is added
|
|
46
|
+
* to the returned PlRef. If false, the `requireEnrichments` property is removed. Defaults to true.
|
|
47
|
+
* @returns A new PlRef object with the `requireEnrichments` property set or removed accordingly.
|
|
48
|
+
*/
|
|
67
49
|
function withEnrichments(ref, requireEnrichments = true) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
50
|
+
if (requireEnrichments) return {
|
|
51
|
+
...ref,
|
|
52
|
+
requireEnrichments: true
|
|
53
|
+
};
|
|
54
|
+
else {
|
|
55
|
+
const { requireEnrichments: _, ...rest } = ref;
|
|
56
|
+
return rest;
|
|
57
|
+
}
|
|
77
58
|
}
|
|
78
59
|
/** Compare two PlRefs and returns true if they are qual */
|
|
79
60
|
function plRefsEqual(ref1, ref2, ignoreEnrichments = false) {
|
|
80
|
-
|
|
81
|
-
ref1.name === ref2.name &&
|
|
82
|
-
(ignoreEnrichments || ref1.requireEnrichments === ref2.requireEnrichments));
|
|
61
|
+
return ref1.blockId === ref2.blockId && ref1.name === ref2.name && (ignoreEnrichments || ref1.requireEnrichments === ref2.requireEnrichments);
|
|
83
62
|
}
|
|
84
63
|
|
|
64
|
+
//#endregion
|
|
85
65
|
exports.PlRef = PlRef;
|
|
86
66
|
exports.createPlRef = createPlRef;
|
|
87
67
|
exports.isPlRef = isPlRef;
|
|
88
68
|
exports.plRefsEqual = plRefsEqual;
|
|
89
69
|
exports.withEnrichments = withEnrichments;
|
|
90
|
-
//# sourceMappingURL=ref.cjs.map
|
|
70
|
+
//# sourceMappingURL=ref.cjs.map
|