global: big snapshot

This commit is contained in:
nym21
2026-01-09 20:00:20 +01:00
parent cb0abc324e
commit 426d7797a3
442 changed files with 17952 additions and 20071 deletions
+1 -1
View File
@@ -199,7 +199,7 @@ fn resolve_branch_patterns(
for (child_name, child_node) in children {
let (rust_type, json_type, indexes, child_fields) = match child_node {
TreeNode::Leaf(leaf) => (
leaf.value_type().to_string(),
leaf.kind().to_string(),
schema_to_json_type(&leaf.schema),
leaf.indexes().clone(),
Vec::new(),
+2 -2
View File
@@ -35,7 +35,7 @@ pub fn get_node_fields(
.map(|(name, node)| {
let (rust_type, json_type, indexes) = match node {
TreeNode::Leaf(leaf) => (
leaf.value_type().to_string(),
leaf.kind().to_string(),
schema_to_json_type(&leaf.schema),
leaf.indexes().clone(),
),
@@ -228,7 +228,7 @@ pub fn get_fields_with_child_info(
.map(|(name, node)| {
let (rust_type, json_type, indexes, child_fields) = match node {
TreeNode::Leaf(leaf) => (
leaf.value_type().to_string(),
leaf.kind().to_string(),
schema_to_json_type(&leaf.schema),
leaf.indexes().clone(),
None,
@@ -107,7 +107,11 @@ pub fn generate_main_client(
let pattern_lookup = metadata.pattern_lookup();
writeln!(output, "/**").unwrap();
writeln!(output, " * Main BRK client with catalog tree and API methods").unwrap();
writeln!(
output,
" * Main BRK client with catalog tree and API methods"
)
.unwrap();
writeln!(output, " * @extends BrkClientBase").unwrap();
writeln!(output, " */").unwrap();
writeln!(output, "class BrkClient extends BrkClientBase {{").unwrap();
@@ -136,53 +140,6 @@ pub fn generate_main_client(
generate_api_methods(output, endpoints);
// Instance method: mergeMetricPatterns
writeln!(output, r#"
/**
* Merge multiple MetricPatterns into a single pattern.
* Throws if any two patterns have overlapping indexes.
* @template T
* @param {{...MetricPattern<T>}} patterns - The patterns to merge
* @returns {{MetricPattern<T>}} A new merged pattern
*/
mergeMetricPatterns(...patterns) {{
if (patterns.length === 0) {{
throw new BrkError('mergeMetricPatterns requires at least one pattern');
}}
if (patterns.length === 1) {{
return patterns[0];
}}
const seenIndexes = /** @type {{Map<Index, string>}} */ (new Map());
const mergedBy = /** @type {{Partial<Record<Index, MetricEndpoint<T>>>}} */ ({{}});
for (const pattern of patterns) {{
for (const index of pattern.indexes()) {{
const existing = seenIndexes.get(index);
if (existing !== undefined) {{
throw new BrkError(`Index '${{index}}' exists in both '${{existing}}' and '${{pattern.name}}'`);
}}
seenIndexes.set(index, pattern.name);
Object.defineProperty(mergedBy, index, {{
get() {{ return pattern.get(index); }},
enumerable: true,
configurable: true,
}});
}}
}}
const allIndexes = /** @type {{Index[]}} */ ([...seenIndexes.keys()]);
const firstName = patterns[0].name;
return {{
name: firstName,
by: mergedBy,
indexes() {{ return allIndexes; }},
get(index) {{ return mergedBy[index]; }},
}};
}}
"#).unwrap();
writeln!(output, "}}\n").unwrap();
writeln!(output, "export {{ BrkClient, BrkError }};").unwrap();
@@ -216,7 +173,11 @@ fn generate_tree_initializer(
writeln!(
output,
"{}{}: create{}(this, '{}'){}",
indent_str, field_name, accessor.name, leaf.name(), comma
indent_str,
field_name,
accessor.name,
leaf.name(),
comma
)
.unwrap();
}
@@ -123,17 +123,24 @@ fn endpoint_to_method_name(endpoint: &Endpoint) -> String {
fn build_method_params(endpoint: &Endpoint) -> String {
let mut params = Vec::new();
// Path params are always required
for param in &endpoint.path_params {
let safe_name = escape_python_keyword(&param.name);
let py_type = js_type_to_python(&param.param_type);
params.push(format!(", {}: {}", safe_name, py_type));
}
// Required query params must come before optional ones (Python syntax requirement)
for param in &endpoint.query_params {
let safe_name = escape_python_keyword(&param.name);
let py_type = js_type_to_python(&param.param_type);
if param.required {
let safe_name = escape_python_keyword(&param.name);
let py_type = js_type_to_python(&param.param_type);
params.push(format!(", {}: {}", safe_name, py_type));
} else {
}
}
for param in &endpoint.query_params {
if !param.required {
let safe_name = escape_python_keyword(&param.name);
let py_type = js_type_to_python(&param.param_type);
params.push(format!(", {}: Optional[{}] = None", safe_name, py_type));
}
}
+1 -1
View File
@@ -142,7 +142,7 @@ fn collect_leaf_type_schemas(node: &TreeNode, schemas: &mut TypeSchemas) {
collect_schema_definitions(&leaf.schema, schemas);
// Get the type name for this leaf
let type_name = extract_inner_type(leaf.value_type());
let type_name = extract_inner_type(leaf.kind());
if let Entry::Vacant(e) = schemas.entry(type_name) {
// Unwrap single-element allOf