@peerbit/native-backbone 0.2.9 → 0.2.11

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.
@@ -2,7 +2,7 @@ use js_sys::{Array, Uint8Array};
2
2
  use peerbit_shared_log_rust::commit_local_append_for_gid_compact_core;
3
3
  use wasm_bindgen::prelude::*;
4
4
 
5
- use crate::append_tx::coordinate_plan_to_row;
5
+ use crate::append_tx::{coordinate_plan_to_row, push_trim_gid_extension};
6
6
  use crate::documents::{
7
7
  document_context_facts_to_row, document_index_append_commit, DocumentIndexAppendCommit,
8
8
  };
@@ -473,10 +473,11 @@ impl NativePeerbitBackbone {
473
473
  let previous_document_context = document_index_commit
474
474
  .as_ref()
475
475
  .and_then(|commit| commit.previous_context.clone());
476
+ let mut committed_trim_gids = None;
476
477
  let (entry_row, trim_rows, trim_hashes, hash, digest, meta_bytes) = if commit_blocks {
477
478
  let (meta_data, payload_data) =
478
479
  self.copy_append_inputs_profiled(meta_data, &payload_data)?;
479
- let (entry_facts, trim_hashes, entry_row, trim_rows) = self
480
+ let (entry_facts, trim_hashes, trim_gids, entry_row, trim_rows) = self
480
481
  .prepare_committed_log_append_rows_profiled(
481
482
  wall_time,
482
483
  logical,
@@ -488,6 +489,7 @@ impl NativePeerbitBackbone {
488
489
  trim_length_to,
489
490
  resolve_trimmed_entries,
490
491
  )?;
492
+ committed_trim_gids = Some(trim_gids);
491
493
  (
492
494
  entry_row,
493
495
  trim_rows,
@@ -549,6 +551,13 @@ impl NativePeerbitBackbone {
549
551
  let meta_bytes = bytes_field(&row, 4, "storage entry meta bytes")?;
550
552
  (row, Array::new(), Vec::new(), hash, digest, meta_bytes)
551
553
  };
554
+ let trim_gids = match committed_trim_gids {
555
+ Some(trim_gids) => trim_gids,
556
+ None => trim_rows
557
+ .iter()
558
+ .map(|row| string_field(&array_from_value(row, "trim row")?, 1, "trim gid"))
559
+ .collect::<Result<Vec<_>, _>>()?,
560
+ };
552
561
 
553
562
  let hash_number = self.hash_number_profiled(&digest)?;
554
563
  let document_hash = hash.clone();
@@ -612,6 +621,7 @@ impl NativePeerbitBackbone {
612
621
  .map(|context| document_context_facts_to_row(context).into())
613
622
  .unwrap_or(JsValue::UNDEFINED),
614
623
  );
624
+ push_trim_gid_extension(&out, trim_gids);
615
625
  if let Some(started) = result_row_started {
616
626
  self.append_profile.result_row_ms += crate::time::now_ms() - started;
617
627
  }