Skip to main content

ic_query_cli/presentation/ic/
mod.rs

1//! Module: ic
2//!
3//! Responsibility: render IC Dashboard reports as human-facing text.
4//! Does not own: REST calls, report construction, JSON serialization, or command output.
5//! Boundary: keeps raw values intact in JSON while making nullable text fields readable.
6
7use crate::presentation::text_value::table;
8use crate::presentation::text_value::{field, json_scalar_text};
9use ic_host_text::escape::terminal_text;
10use ic_host_text::table::Alignment;
11
12use crate::presentation::human_quantity::decimal_cycle_rate_text;
13use crate::presentation::text_value::optional_text;
14use crate::presentation::text_value::optional_u64_text;
15use crate::presentation::text_value::text_or_dash;
16use crate::presentation::text_value::truncate_text;
17use crate::presentation::text_value::yes_no;
18use ic_query::ic::IcBoundaryNodeDataCentersReport;
19use ic_query::ic::IcCanisterCountReport;
20use ic_query::ic::IcCanisterFilters;
21use ic_query::ic::IcCanisterPageReport;
22use ic_query::ic::IcCanisterReport;
23use ic_query::ic::IcDailyStatsReport;
24use ic_query::ic::IcDashboardReportProvenance;
25use ic_query::ic::IcIcrcAccountInfoReport;
26use ic_query::ic::IcIcrcAccountListReport;
27use ic_query::ic::IcIcrcHolderListReport;
28use ic_query::ic::IcIcrcIndexedCountReport;
29use ic_query::ic::IcIcrcTokenValueReport;
30use ic_query::ic::IcIcrcTotalSupplyReport;
31use ic_query::ic::IcMetricKind;
32use ic_query::ic::IcMetricReport;
33use ic_query::ic::IcNodeProviderRewardHistoryReport;
34use ic_query::ic::IcNodeProviderRewardInfoReport;
35use ic_query::ic::IcNodeProviderRewardListReport;
36use ic_query::ic::IcReplicaVersionInfoReport;
37use ic_query::ic::IcReplicaVersionListReport;
38
39const IC_REPLICA_VERSION_TITLE_TEXT_LIMIT: usize = 80;
40const IC_REPLICA_VERSION_SUMMARY_TEXT_LIMIT: usize = 240;
41
42pub(crate) fn dashboard_provenance_lines(provenance: &IcDashboardReportProvenance) -> Vec<String> {
43    crate::presentation::text_value::report_fields!(provenance;
44        schema_version,
45        network,
46        authority,
47        source_endpoint,
48        fetched_at,
49        fetched_by,
50        certified = yes_no(provenance.certified),
51        point_in_time_guaranteed = yes_no(provenance.point_in_time_guaranteed),
52    )
53    .into()
54}
55
56fn query_window_lines(start_unix_secs: u64, end_unix_secs: u64) -> [String; 2] {
57    [
58        field("start_unix_secs", &(start_unix_secs)),
59        field("end_unix_secs", &(end_unix_secs)),
60    ]
61}
62
63fn series_query_lines(start_unix_secs: u64, end_unix_secs: u64, step_secs: u32) -> [String; 3] {
64    let [start, end] = query_window_lines(start_unix_secs, end_unix_secs);
65    [start, end, field("step_secs", &(step_secs))]
66}
67
68/// Render one official boundary-node data-center report as human-facing text.
69#[must_use]
70pub fn ic_boundary_node_data_centers_report_text(
71    report: &IcBoundaryNodeDataCentersReport,
72) -> String {
73    let mut lines = dashboard_provenance_lines(&report.provenance);
74    lines.extend(crate::presentation::text_value::report_fields!(report;
75        data_center_count = report.rows.len(),
76        total_node_count,
77    ));
78
79    if !report.rows.is_empty() {
80        lines.push(String::new());
81        lines.push("boundary_node_data_centers:".to_string());
82        lines.extend(report.rows.iter().map(|row| {
83            format!(
84                "  {}  name={}  owner={}  region={}  latitude={}  longitude={}  nodes={}",
85                terminal_text(&row.dc_id),
86                terminal_text(&row.name),
87                terminal_text(&row.owner),
88                terminal_text(&row.region),
89                terminal_text(&row.latitude),
90                terminal_text(&row.longitude),
91                terminal_text(&row.total_nodes),
92            )
93        }));
94    }
95    lines.join("\n")
96}
97
98/// Render one bounded official Dashboard daily-statistics report as human-facing text.
99#[must_use]
100pub fn ic_daily_stats_report_text(report: &IcDailyStatsReport) -> String {
101    let mut lines = dashboard_provenance_lines(&report.provenance);
102    lines.extend(query_window_lines(
103        report.query.start_unix_secs,
104        report.query.end_unix_secs,
105    ));
106    lines.extend([field("returned_day_count", &(report.rows.len()))]);
107
108    if !report.rows.is_empty() {
109        lines.push(String::new());
110        lines.push("daily_stats:".to_string());
111        lines.extend(report.rows.iter().map(|row| {
112            format!(
113                "  {}  timestamp={}  avg_total={}  avg_update={}  avg_query={}  max_total={}  max_update={}  max_query={}  blocks_avg={}",
114                terminal_text(&row.day),
115                row.timestamp_unix_secs,
116                terminal_text(&row.average_transactions_per_second),
117                terminal_text(&row.average_update_transactions_per_second),
118                terminal_text(&row.average_query_transactions_per_second),
119                terminal_text(&row.max_total_transactions_per_second),
120                terminal_text(&row.max_update_transactions_per_second),
121                terminal_text(&row.max_query_transactions_per_second),
122                terminal_text(&row.blocks_per_second_average),
123            )
124        }));
125    }
126    lines.join("\n")
127}
128
129/// Render one bounded official Dashboard node-provider reward page as human-facing text.
130#[must_use]
131pub fn ic_node_provider_reward_list_report_text(report: &IcNodeProviderRewardListReport) -> String {
132    let mut lines = dashboard_provenance_lines(&report.provenance);
133    lines.extend(crate::presentation::text_value::report_fields!(report;
134        limit = report.query.limit,
135        offset = report.query.offset,
136        requested_max_reward_index = optional_u64_text(report.query.max_reward_index),
137        resolved_max_reward_index,
138        total_reward_records,
139        returned_count = report.rows.len(),
140        next_offset_hint = optional_u64_text(report.next_offset_hint),
141        pages_may_overlap = yes_no(report.pages_may_overlap),
142    ));
143
144    if !report.rows.is_empty() {
145        lines.push(String::new());
146        lines.push(table(
147            &[
148                "ID",
149                "PROVIDER",
150                "AMOUNT_E8S",
151                "MODE",
152                "REWARDED_AT",
153                "PROPOSAL",
154            ],
155            &report
156                .rows
157                .iter()
158                .map(|row| {
159                    [
160                        row.reward_id.to_string(),
161                        row.node_provider_id.clone(),
162                        row.amount_e8s.to_string(),
163                        row.reward_mode.clone(),
164                        row.reward_timestamp_unix_secs.to_string(),
165                        optional_u64_text(row.proposal_id),
166                    ]
167                })
168                .collect::<Vec<_>>(),
169            &[
170                Alignment::Right,
171                Alignment::Left,
172                Alignment::Right,
173                Alignment::Left,
174                Alignment::Right,
175                Alignment::Right,
176            ],
177        ));
178    }
179    lines.join("\n")
180}
181
182/// Render one exact official Dashboard node-provider reward report as human-facing text.
183#[must_use]
184pub fn ic_node_provider_reward_info_report_text(report: &IcNodeProviderRewardInfoReport) -> String {
185    let reward = &report.reward;
186    let details = serde_json::to_string(&reward.details).unwrap_or_else(|_| "{}".to_string());
187    let mut lines = dashboard_provenance_lines(&report.provenance);
188    lines.extend(crate::presentation::text_value::report_fields!(reward;
189        reward_id,
190        node_provider_id,
191        amount_e8s,
192        reward_mode,
193        reward_timestamp_unix_secs,
194        dashboard_updated_at,
195        proposal_id = optional_u64_text(reward.proposal_id),
196        registry_version = optional_u64_text(reward.registry_version),
197        maximum_node_provider_rewards_e8s = optional_u64_text(reward.maximum_node_provider_rewards_e8s),
198        minimum_xdr_permyriad_per_icp = optional_u64_text(reward.minimum_xdr_permyriad_per_icp),
199        xdr_timestamp_unix_secs = optional_u64_text(reward.xdr_conversion_rate.timestamp_unix_secs),
200        xdr_permyriad_per_icp = optional_u64_text(reward.xdr_conversion_rate.xdr_permyriad_per_icp),
201        details = details,
202    ));
203    lines.join("\n")
204}
205
206/// Render one bounded official Dashboard node-provider reward history as human-facing text.
207#[must_use]
208pub fn ic_node_provider_reward_history_report_text(
209    report: &IcNodeProviderRewardHistoryReport,
210) -> String {
211    let mut lines = dashboard_provenance_lines(&report.provenance);
212    lines.extend(series_query_lines(
213        report.query.start_unix_secs,
214        report.query.end_unix_secs,
215        report.query.step_secs,
216    ));
217    lines.extend(crate::presentation::text_value::report_fields!(report;
218        requested_observation_limit,
219        returned_observation_count = report.observations.len(),
220    ));
221
222    if !report.observations.is_empty() {
223        lines.push(String::new());
224        lines.push(table(
225            &["TIMESTAMP", "AMOUNT_E8S"],
226            &report
227                .observations
228                .iter()
229                .map(|observation| {
230                    [
231                        observation.timestamp_unix_secs.to_string(),
232                        observation.amount_e8s.to_string(),
233                    ]
234                })
235                .collect::<Vec<_>>(),
236            &[Alignment::Right; 2],
237        ));
238    }
239    lines.join("\n")
240}
241
242/// Render one bounded official Dashboard replica-version page as human-facing text.
243#[must_use]
244pub fn ic_replica_version_list_report_text(report: &IcReplicaVersionListReport) -> String {
245    let mut lines = dashboard_provenance_lines(&report.provenance);
246    lines.extend(crate::presentation::text_value::report_fields!(report;
247        limit = report.query.limit,
248        offset = report.query.offset,
249        requested_max_proposal_index = optional_u64_text(report.query.max_proposal_index),
250        resolved_max_proposal_index,
251        total_proposals,
252        returned_count = report.rows.len(),
253        next_offset = optional_u64_text(report.next_offset),
254    ));
255
256    if !report.rows.is_empty() {
257        lines.push(String::new());
258        lines.push(table(
259            &[
260                "VERSION",
261                "STATUS",
262                "PROPOSAL",
263                "EXECUTED_AT",
264                "SUBNETS",
265                "TITLE",
266            ],
267            &report
268                .rows
269                .iter()
270                .map(|row| {
271                    [
272                        row.replica_version_id.clone(),
273                        row.status.to_string(),
274                        row.proposal_id.to_string(),
275                        row.executed_timestamp_seconds.to_string(),
276                        row.subnets.len().to_string(),
277                        truncate_text(&row.title, IC_REPLICA_VERSION_TITLE_TEXT_LIMIT),
278                    ]
279                })
280                .collect::<Vec<_>>(),
281            &[
282                Alignment::Left,
283                Alignment::Left,
284                Alignment::Right,
285                Alignment::Right,
286                Alignment::Right,
287                Alignment::Left,
288            ],
289        ));
290    }
291    lines.join("\n")
292}
293
294/// Render one exact official Dashboard replica-version report as human-facing text.
295#[must_use]
296pub fn ic_replica_version_info_report_text(report: &IcReplicaVersionInfoReport) -> String {
297    let mut lines = dashboard_provenance_lines(&report.provenance);
298    lines.extend(crate::presentation::text_value::report_fields!(report;
299        replica_version_id = report.release.replica_version_id,
300        proposal_id = report.release.proposal_id,
301        executed_timestamp_seconds = report.release.executed_timestamp_seconds,
302        title = text_or_dash(&report.release.title),
303        url = text_or_dash(&report.release.url),
304        subnet_count = report.release.subnets.len(),
305        summary = truncate_text(
306                &report.release.summary,
307                IC_REPLICA_VERSION_SUMMARY_TEXT_LIMIT,
308            ),
309    ));
310
311    if !report.release.subnets.is_empty() {
312        lines.push(String::new());
313        lines.push("subnet_rollouts:".to_string());
314        lines.extend(report.release.subnets.iter().map(|subnet| {
315            format!(
316                "  {}  proposal={}  executed_at={}",
317                subnet.subnet_id, subnet.proposal_id, subnet.executed_timestamp_seconds
318            )
319        }));
320    }
321    lines.join("\n")
322}
323
324/// Render one bounded official Dashboard metric report as human-facing text.
325#[must_use]
326pub fn ic_metric_report_text(report: &IcMetricReport) -> String {
327    let mut lines = dashboard_provenance_lines(&report.provenance);
328    lines.extend([field("metric", &(report.query.metric))]);
329    lines.extend(series_query_lines(
330        report.query.start_unix_secs,
331        report.query.end_unix_secs,
332        report.query.step_secs,
333    ));
334    lines.extend(crate::presentation::text_value::report_fields!(report;
335        returned_series_count = report.series.len(),
336        returned_observation_count = report.series.iter().map(|series| series.observations.len()).sum::<usize>(),
337    ));
338
339    for series in &report.series {
340        lines.push(String::new());
341        lines.push(format!("{}:", terminal_text(&series.name)));
342        lines.extend(series.observations.iter().map(|observation| {
343            format!(
344                "  {}  {}",
345                observation.timestamp_unix_secs,
346                metric_observation_text(report.query.metric, &observation.value)
347            )
348        }));
349    }
350    lines.join("\n")
351}
352
353/// Render one official ICRC indexed-count report as human-facing text.
354#[must_use]
355pub fn icrc_indexed_count_report_text(report: &IcIcrcIndexedCountReport) -> String {
356    let mut lines = dashboard_provenance_lines(&report.provenance);
357    lines.extend(crate::presentation::text_value::report_fields!(report;
358        ledger_canister_id,
359        kind,
360        total,
361    ));
362    lines.join("\n")
363}
364
365/// Render one bounded official ICRC account-index page as human-facing text.
366#[must_use]
367pub fn icrc_account_list_report_text(report: &IcIcrcAccountListReport) -> String {
368    let mut lines = dashboard_provenance_lines(&report.provenance);
369    lines.extend(crate::presentation::text_value::report_fields!(report;
370        ledger_canister_id,
371        owner = optional_text(report.query.owner.as_ref()),
372    ));
373    append_cursor_page_lines(
374        &mut lines,
375        report.query.sort_by.as_api_value(),
376        report.query.limit,
377        report.rows.len(),
378        report.previous_cursor.as_ref(),
379        report.next_cursor.as_ref(),
380    );
381
382    if !report.rows.is_empty() {
383        lines.push(String::new());
384        lines.push("accounts:".to_string());
385        let rows = report
386            .rows
387            .iter()
388            .map(|row| {
389                [
390                    row.account_id.clone(),
391                    row.owner.clone(),
392                    row.balance_base_units.clone(),
393                    row.total_transactions.to_string(),
394                    row.created_at_unix_secs.to_string(),
395                    row.latest_transaction_index.to_string(),
396                ]
397            })
398            .collect::<Vec<_>>();
399        lines.push(table(
400            &[
401                "ACCOUNT ID",
402                "OWNER",
403                "BALANCE",
404                "TXS",
405                "CREATED",
406                "LATEST TX",
407            ],
408            &rows,
409            &[
410                Alignment::Left,
411                Alignment::Left,
412                Alignment::Right,
413                Alignment::Right,
414                Alignment::Right,
415                Alignment::Right,
416            ],
417        ));
418    }
419    lines.join("\n")
420}
421
422/// Render one exact official ICRC account record as human-facing text.
423#[must_use]
424pub fn icrc_account_info_report_text(report: &IcIcrcAccountInfoReport) -> String {
425    let account = &report.account;
426    let mut lines = dashboard_provenance_lines(&report.provenance);
427    lines.extend(crate::presentation::text_value::report_fields!(account;
428        account_id,
429        owner,
430        subaccount,
431        balance_base_units,
432        total_transactions,
433        created_at_unix_secs,
434        created_at_subsec_nanos,
435        ledger_canister_id,
436        latest_transaction_index,
437        dashboard_updated_at,
438        active_fee_collector = yes_no(account.active_fee_collector),
439        fee_collector_block_range_count = account.fee_collector_block_ranges.len(),
440    ));
441    lines.join("\n")
442}
443
444/// Render one bounded official ICRC holder-index page as human-facing text.
445#[must_use]
446pub fn icrc_holder_list_report_text(report: &IcIcrcHolderListReport) -> String {
447    let mut lines = dashboard_provenance_lines(&report.provenance);
448    lines.extend([field("ledger_canister_id", &report.ledger_canister_id)]);
449    append_cursor_page_lines(
450        &mut lines,
451        report.query.sort_by.as_api_value(),
452        report.query.limit,
453        report.rows.len(),
454        report.previous_cursor.as_ref(),
455        report.next_cursor.as_ref(),
456    );
457
458    if !report.rows.is_empty() {
459        lines.push(String::new());
460        lines.push("holders:".to_string());
461        let rows = report
462            .rows
463            .iter()
464            .map(|row| {
465                [
466                    row.principal.clone(),
467                    row.balance_base_units.clone(),
468                    row.total_transactions.to_string(),
469                    json_scalar_text(&row.percentage),
470                    json_scalar_text(&row.value_usd),
471                    row.created_at_unix_secs.to_string(),
472                ]
473            })
474            .collect::<Vec<_>>();
475        lines.push(table(
476            &[
477                "PRINCIPAL",
478                "BALANCE",
479                "TXS",
480                "PERCENT",
481                "VALUE USD",
482                "CREATED",
483            ],
484            &rows,
485            &[
486                Alignment::Left,
487                Alignment::Right,
488                Alignment::Right,
489                Alignment::Right,
490                Alignment::Right,
491                Alignment::Right,
492            ],
493        ));
494    }
495    lines.join("\n")
496}
497
498/// Render one bounded official ICRC token-value series as human-facing text.
499#[must_use]
500pub fn icrc_token_value_report_text(report: &IcIcrcTokenValueReport) -> String {
501    let mut lines = dashboard_provenance_lines(&report.provenance);
502    lines.extend([field("ledger_canister_id", &report.ledger_canister_id)]);
503    lines.extend(query_window_lines(
504        report.query.start_unix_secs,
505        report.query.end_unix_secs,
506    ));
507    lines.extend(crate::presentation::text_value::report_fields!(report;
508        limit = report.query.limit,
509        returned_row_count = report.rows.len(),
510        limit_reached = yes_no(report.limit_reached),
511    ));
512
513    if !report.rows.is_empty() {
514        lines.push(String::new());
515        lines.push("token_values:".to_string());
516        lines.extend(report.rows.iter().map(|row| {
517            format!(
518                "  {}  price={}  volume_24h={}  price_usd={}  volume_24h_usd={}  source={}  source_url={}",
519                row.timestamp_unix_secs,
520                optional_text(row.price.as_ref()),
521                optional_text(row.volume_24h.as_ref()),
522                optional_text(row.price_usd.as_ref()),
523                optional_text(row.volume_24h_usd.as_ref()),
524                optional_text(row.source.as_ref()),
525                optional_text(row.source_url.as_ref()),
526            )
527        }));
528    }
529    lines.join("\n")
530}
531
532/// Render one bounded official ICRC total-supply series as human-facing text.
533#[must_use]
534pub fn icrc_total_supply_report_text(report: &IcIcrcTotalSupplyReport) -> String {
535    let mut lines = dashboard_provenance_lines(&report.provenance);
536    lines.extend([field("ledger_canister_id", &report.ledger_canister_id)]);
537    lines.extend(series_query_lines(
538        report.query.start_unix_secs,
539        report.query.end_unix_secs,
540        report.query.step_secs,
541    ));
542    lines.extend(crate::presentation::text_value::report_fields!(report;
543        requested_observation_limit,
544        returned_observation_count = report.observations.len(),
545    ));
546
547    if !report.observations.is_empty() {
548        lines.push(String::new());
549        lines.push("total_supply_base_units:".to_string());
550        lines.extend(report.observations.iter().map(|observation| {
551            format!(
552                "  {}  {}",
553                observation.timestamp_unix_secs,
554                terminal_text(&observation.total_supply_base_units)
555            )
556        }));
557    }
558    lines.join("\n")
559}
560
561fn metric_observation_text(metric: IcMetricKind, value: &str) -> String {
562    if metric == IcMetricKind::CycleBurnRate {
563        decimal_cycle_rate_text(value)
564    } else {
565        terminal_text(value).into_owned()
566    }
567}
568
569/// Render one official Dashboard canister report as human-facing text.
570#[must_use]
571pub fn ic_canister_report_text(report: &IcCanisterReport) -> String {
572    let data = &report.data;
573    let mut lines = dashboard_provenance_lines(&report.provenance);
574    lines.extend(crate::presentation::text_value::report_fields!(data;
575        canister_id,
576        dashboard_id,
577        name = text_or_dash(&data.name),
578        canister_type = data.canister_type.as_deref().map_or_else(|| "-".to_string(), text_or_dash),
579        subnet_id,
580        controller_count = data.controllers.len(),
581        language = text_or_dash(&data.language),
582        module_hash = text_or_dash(&data.module_hash),
583        dashboard_updated_at,
584        upgrade_history_available = yes_no(data.upgrades.is_some()),
585        upgrade_count = data.upgrades.as_ref().map(Vec::len).map_or_else(|| "-".to_string(), |count| count.to_string()),
586    ));
587
588    if !data.controllers.is_empty() {
589        lines.push(String::new());
590        lines.push("controllers:".to_string());
591        lines.extend(
592            data.controllers
593                .iter()
594                .map(|controller| format!("  {controller}")),
595        );
596    }
597
598    if let Some(latest) = data.upgrades.as_ref().and_then(|upgrades| upgrades.first()) {
599        lines.push(String::new());
600        lines.push("latest_upgrade:".to_string());
601        lines.push(field("  proposal_id", &(latest.proposal_id)));
602        lines.push(field(
603            "  executed_timestamp_seconds",
604            &(latest.executed_timestamp_seconds),
605        ));
606        lines.push(field("  module_hash", &(latest.module_hash)));
607    }
608
609    lines.join("\n")
610}
611
612/// Render one official Dashboard canister-count report as human-facing text.
613#[must_use]
614pub fn ic_canister_count_report_text(report: &IcCanisterCountReport) -> String {
615    let mut lines = dashboard_provenance_lines(&report.provenance);
616    lines.push(field("total", &(report.total)));
617    append_filters(&mut lines, &report.filters);
618    lines.join("\n")
619}
620
621/// Render one bounded official Dashboard canister page as human-facing text.
622#[must_use]
623pub fn ic_canister_page_report_text(report: &IcCanisterPageReport) -> String {
624    let mut lines = dashboard_provenance_lines(&report.provenance);
625    lines.extend(crate::presentation::text_value::report_fields!(report;
626        returned_count = report.rows.len(),
627        requested_limit,
628        after = report.after.as_deref().map_or("-", |value| value),
629        before = report.before.as_deref().map_or("-", |value| value),
630        previous_cursor = report.previous_cursor.as_deref().map_or("-", |value| value),
631        next_cursor = report.next_cursor.as_deref().map_or("-", |value| value),
632    ));
633    append_filters(&mut lines, &report.filters);
634
635    if !report.rows.is_empty() {
636        lines.push(String::new());
637        lines.push("canisters:".to_string());
638        lines.extend(report.rows.iter().map(|row| {
639            format!(
640                "  {}  name={}  type={}  subnet={}  controllers={}  language={}  updated={}",
641                row.canister_id,
642                text_or_dash(&row.name),
643                row.canister_type
644                    .as_deref()
645                    .map_or_else(|| "-".to_string(), text_or_dash),
646                row.subnet_id,
647                row.controllers.len(),
648                text_or_dash(&row.language),
649                terminal_text(&row.dashboard_updated_at),
650            )
651        }));
652    }
653    lines.join("\n")
654}
655
656fn append_filters(lines: &mut Vec<String>, filters: &IcCanisterFilters) {
657    if let Some(has_name) = filters.has_name {
658        lines.push(field("filter.has_name", &(yes_no(has_name))));
659    }
660    if let Some(subnet_id) = filters.subnet_id.as_deref() {
661        lines.push(field("filter.subnet_id", &(subnet_id)));
662    }
663    if let Some(controller_id) = filters.controller_id.as_deref() {
664        lines.push(field("filter.controller_id", &(controller_id)));
665    }
666    if !filters.languages.is_empty() {
667        lines.push(field(
668            "filter.languages",
669            &(filters
670                .languages
671                .iter()
672                .map(|value| terminal_text(value))
673                .collect::<Vec<_>>()
674                .join(",")),
675        ));
676    }
677    if !filters.canister_types.is_empty() {
678        lines.push(field(
679            "filter.canister_types",
680            &(filters
681                .canister_types
682                .iter()
683                .map(|value| terminal_text(value))
684                .collect::<Vec<_>>()
685                .join(",")),
686        ));
687    }
688    if let Some(query) = filters.query.as_deref() {
689        lines.push(field("filter.query", &(query)));
690    }
691}
692
693fn append_cursor_page_lines(
694    lines: &mut Vec<String>,
695    sort_by: &str,
696    limit: u16,
697    returned_count: usize,
698    previous_cursor: Option<&String>,
699    next_cursor: Option<&String>,
700) {
701    lines.extend([
702        field("sort_by", &(sort_by)),
703        field("limit", &(limit)),
704        field("returned_count", &(returned_count)),
705        field("previous_cursor", &(optional_text(previous_cursor))),
706        field("next_cursor", &(optional_text(next_cursor))),
707    ]);
708}
709
710mod api_boundary_node;
711pub use api_boundary_node::*;
712
713mod node_status;
714pub use node_status::*;