@peerbit/native-backbone 0.1.0

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.
@@ -0,0 +1,791 @@
1
+ use js_sys::{Array, Uint8Array};
2
+ use wasm_bindgen::prelude::*;
3
+
4
+ use crate::append_tx::{
5
+ committed_entry_facts_to_row, compact_committed_entry_facts_trim_hashes_to_row,
6
+ };
7
+ use crate::documents::{
8
+ document_context_facts_to_row, document_index_append_commit,
9
+ document_index_cached_projection_append_commit,
10
+ document_index_cached_projection_plain_put_payload_append_commit, DocumentIndexAppendCommit,
11
+ };
12
+ use crate::js_interop::{optional_bytes_from_js, optional_usize_from_js, strings_to_array};
13
+ use crate::NativePeerbitBackbone;
14
+
15
+ #[wasm_bindgen]
16
+ impl NativePeerbitBackbone {
17
+ #[allow(clippy::too_many_arguments)]
18
+ pub fn prepare_plain_entry_commit_facts(
19
+ &mut self,
20
+ wall_time: u64,
21
+ logical: u32,
22
+ gid: String,
23
+ next: Array,
24
+ entry_type: u8,
25
+ meta_data: JsValue,
26
+ payload_data: Uint8Array,
27
+ trim_length_to: JsValue,
28
+ ) -> Result<Array, JsValue> {
29
+ let trim_length_to = optional_usize_from_js(trim_length_to, "trimLengthTo")?;
30
+ let has_no_next = next.length() == 0;
31
+ match (has_no_next, trim_length_to) {
32
+ (true, Some(trim_length_to)) => self
33
+ .log
34
+ .prepare_entry_v0_plain_entry_commit_no_next_facts_trim_and_put_with_builder(
35
+ &self.builder,
36
+ &mut self.blocks,
37
+ wall_time,
38
+ logical,
39
+ gid,
40
+ entry_type,
41
+ meta_data,
42
+ payload_data,
43
+ trim_length_to,
44
+ ),
45
+ (true, None) => self
46
+ .log
47
+ .prepare_entry_v0_plain_entry_commit_no_next_facts_and_put_with_builder(
48
+ &self.builder,
49
+ &mut self.blocks,
50
+ wall_time,
51
+ logical,
52
+ gid,
53
+ entry_type,
54
+ meta_data,
55
+ payload_data,
56
+ ),
57
+ (false, Some(trim_length_to)) => self
58
+ .log
59
+ .prepare_entry_v0_plain_entry_commit_facts_trim_and_put_with_builder(
60
+ &self.builder,
61
+ &mut self.blocks,
62
+ wall_time,
63
+ logical,
64
+ gid,
65
+ next,
66
+ entry_type,
67
+ meta_data,
68
+ payload_data,
69
+ trim_length_to,
70
+ ),
71
+ (false, None) => self
72
+ .log
73
+ .prepare_entry_v0_plain_entry_commit_facts_and_put_with_builder(
74
+ &self.builder,
75
+ &mut self.blocks,
76
+ wall_time,
77
+ logical,
78
+ gid,
79
+ next,
80
+ entry_type,
81
+ meta_data,
82
+ payload_data,
83
+ ),
84
+ }
85
+ }
86
+
87
+ #[allow(clippy::too_many_arguments)]
88
+ pub fn prepare_plain_entry_commit_facts_document_index(
89
+ &mut self,
90
+ wall_time: u64,
91
+ logical: u32,
92
+ gid: String,
93
+ next: Array,
94
+ entry_type: u8,
95
+ meta_data: JsValue,
96
+ payload_data: Uint8Array,
97
+ trim_length_to: JsValue,
98
+ document_key: String,
99
+ document_value_prefix_bytes: Vec<u8>,
100
+ document_existing_created: String,
101
+ document_byte_element_index_limit: usize,
102
+ document_delete_trimmed_heads: bool,
103
+ document_projection_plan: JsValue,
104
+ document_projection_encoded_document: JsValue,
105
+ document_projection_signer: JsValue,
106
+ ) -> Result<Array, JsValue> {
107
+ let document_gid = gid.clone();
108
+ let payload_size = payload_data.length();
109
+ let document_index_commit = document_index_append_commit(
110
+ document_key,
111
+ document_value_prefix_bytes,
112
+ document_existing_created,
113
+ document_byte_element_index_limit,
114
+ document_delete_trimmed_heads,
115
+ document_projection_plan,
116
+ document_projection_encoded_document,
117
+ document_projection_signer,
118
+ )?;
119
+ let row = self.prepare_plain_entry_commit_facts(
120
+ wall_time,
121
+ logical,
122
+ gid,
123
+ next,
124
+ entry_type,
125
+ meta_data,
126
+ payload_data,
127
+ trim_length_to,
128
+ )?;
129
+ self.put_document_index_for_facts_row(
130
+ &row,
131
+ document_index_commit,
132
+ wall_time,
133
+ &document_gid,
134
+ payload_size,
135
+ )?;
136
+ Ok(row)
137
+ }
138
+
139
+ #[allow(clippy::too_many_arguments)]
140
+ pub fn prepare_plain_entry_commit_facts_document_index_cached_plan(
141
+ &mut self,
142
+ wall_time: u64,
143
+ logical: u32,
144
+ gid: String,
145
+ next: Array,
146
+ entry_type: u8,
147
+ meta_data: JsValue,
148
+ payload_data: Uint8Array,
149
+ trim_length_to: JsValue,
150
+ document_key: String,
151
+ document_existing_created: String,
152
+ document_byte_element_index_limit: usize,
153
+ document_delete_trimmed_heads: bool,
154
+ document_projection_plan_id: u32,
155
+ document_projection_encoded_document: JsValue,
156
+ document_projection_signer: JsValue,
157
+ ) -> Result<Array, JsValue> {
158
+ let document_gid = gid.clone();
159
+ let payload_size = payload_data.length();
160
+ let document_index_commit = document_index_cached_projection_append_commit(
161
+ document_key,
162
+ document_existing_created,
163
+ document_byte_element_index_limit,
164
+ document_delete_trimmed_heads,
165
+ document_projection_plan_id,
166
+ document_projection_encoded_document,
167
+ document_projection_signer,
168
+ )?;
169
+ let row = self.prepare_plain_entry_commit_facts(
170
+ wall_time,
171
+ logical,
172
+ gid,
173
+ next,
174
+ entry_type,
175
+ meta_data,
176
+ payload_data,
177
+ trim_length_to,
178
+ )?;
179
+ self.put_document_index_for_facts_row(
180
+ &row,
181
+ document_index_commit,
182
+ wall_time,
183
+ &document_gid,
184
+ payload_size,
185
+ )?;
186
+ Ok(row)
187
+ }
188
+
189
+ #[allow(clippy::too_many_arguments)]
190
+ pub fn prepare_plain_entry_commit_no_next_facts_document_index_compact(
191
+ &mut self,
192
+ wall_time: u64,
193
+ logical: u32,
194
+ gid: String,
195
+ entry_type: u8,
196
+ meta_data: JsValue,
197
+ payload_data: Uint8Array,
198
+ document_key: String,
199
+ document_value_prefix_bytes: Vec<u8>,
200
+ document_existing_created: String,
201
+ document_byte_element_index_limit: usize,
202
+ document_delete_trimmed_heads: bool,
203
+ document_projection_plan: JsValue,
204
+ document_projection_encoded_document: JsValue,
205
+ document_projection_signer: JsValue,
206
+ ) -> Result<Array, JsValue> {
207
+ let document_gid = gid.clone();
208
+ let payload_size = payload_data.length();
209
+ let document_index_commit = document_index_append_commit(
210
+ document_key,
211
+ document_value_prefix_bytes,
212
+ document_existing_created,
213
+ document_byte_element_index_limit,
214
+ document_delete_trimmed_heads,
215
+ document_projection_plan,
216
+ document_projection_encoded_document,
217
+ document_projection_signer,
218
+ )?;
219
+ self.prepare_plain_entry_commit_no_next_document_index_compact(
220
+ wall_time,
221
+ logical,
222
+ gid,
223
+ entry_type,
224
+ meta_data,
225
+ payload_data,
226
+ document_gid,
227
+ payload_size,
228
+ document_index_commit,
229
+ )
230
+ }
231
+
232
+ #[allow(clippy::too_many_arguments)]
233
+ pub fn prepare_plain_entry_commit_no_next_facts_document_index_cached_plan_compact(
234
+ &mut self,
235
+ wall_time: u64,
236
+ logical: u32,
237
+ gid: String,
238
+ entry_type: u8,
239
+ meta_data: JsValue,
240
+ payload_data: Uint8Array,
241
+ document_key: String,
242
+ document_existing_created: String,
243
+ document_byte_element_index_limit: usize,
244
+ document_delete_trimmed_heads: bool,
245
+ document_projection_plan_id: u32,
246
+ document_projection_encoded_document: JsValue,
247
+ document_projection_signer: JsValue,
248
+ ) -> Result<Array, JsValue> {
249
+ let document_gid = gid.clone();
250
+ let payload_size = payload_data.length();
251
+ let document_index_commit = document_index_cached_projection_append_commit(
252
+ document_key,
253
+ document_existing_created,
254
+ document_byte_element_index_limit,
255
+ document_delete_trimmed_heads,
256
+ document_projection_plan_id,
257
+ document_projection_encoded_document,
258
+ document_projection_signer,
259
+ )?;
260
+ self.prepare_plain_entry_commit_no_next_document_index_compact(
261
+ wall_time,
262
+ logical,
263
+ gid,
264
+ entry_type,
265
+ meta_data,
266
+ payload_data,
267
+ document_gid,
268
+ payload_size,
269
+ document_index_commit,
270
+ )
271
+ }
272
+
273
+ #[allow(clippy::too_many_arguments)]
274
+ pub fn prepare_plain_entry_commit_no_next_facts_document_index_cached_plan_compact_plain_put_payload(
275
+ &mut self,
276
+ wall_time: u64,
277
+ logical: u32,
278
+ gid: String,
279
+ entry_type: u8,
280
+ meta_data: JsValue,
281
+ payload_data: Uint8Array,
282
+ document_key: String,
283
+ document_existing_created: String,
284
+ document_byte_element_index_limit: usize,
285
+ document_delete_trimmed_heads: bool,
286
+ document_projection_plan_id: u32,
287
+ document_projection_signer: JsValue,
288
+ ) -> Result<Array, JsValue> {
289
+ let document_gid = gid.clone();
290
+ let payload_size = payload_data.length();
291
+ let payload_data = payload_data.to_vec();
292
+ let document_index_commit =
293
+ document_index_cached_projection_plain_put_payload_append_commit(
294
+ document_key,
295
+ document_existing_created,
296
+ document_byte_element_index_limit,
297
+ document_delete_trimmed_heads,
298
+ document_projection_plan_id,
299
+ document_projection_signer,
300
+ )?;
301
+ let entry_facts = self
302
+ .log
303
+ .prepare_entry_v0_plain_entry_commit_no_next_facts_core_profiled_and_put_with_builder_borrowed(
304
+ &self.builder,
305
+ &mut self.blocks,
306
+ wall_time,
307
+ logical,
308
+ gid,
309
+ entry_type,
310
+ optional_bytes_from_js(meta_data),
311
+ &payload_data,
312
+ None,
313
+ )?;
314
+ self.put_document_index_for_append_with_plain_put_payload(
315
+ Some(document_index_commit),
316
+ wall_time,
317
+ &entry_facts.hash,
318
+ &document_gid,
319
+ payload_size,
320
+ Some(&payload_data),
321
+ )?;
322
+ Ok(committed_entry_facts_to_row(&entry_facts, false))
323
+ }
324
+
325
+ #[allow(clippy::too_many_arguments)]
326
+ pub fn prepare_plain_entry_commit_no_next_facts_document_index_trim_hashes(
327
+ &mut self,
328
+ wall_time: u64,
329
+ logical: u32,
330
+ gid: String,
331
+ entry_type: u8,
332
+ meta_data: JsValue,
333
+ payload_data: Uint8Array,
334
+ trim_length_to: usize,
335
+ document_key: String,
336
+ document_value_prefix_bytes: Vec<u8>,
337
+ document_existing_created: String,
338
+ document_byte_element_index_limit: usize,
339
+ document_delete_trimmed_heads: bool,
340
+ document_projection_plan: JsValue,
341
+ document_projection_encoded_document: JsValue,
342
+ document_projection_signer: JsValue,
343
+ ) -> Result<Array, JsValue> {
344
+ let document_gid = gid.clone();
345
+ let payload_size = payload_data.length();
346
+ let document_index_commit = document_index_append_commit(
347
+ document_key,
348
+ document_value_prefix_bytes,
349
+ document_existing_created,
350
+ document_byte_element_index_limit,
351
+ document_delete_trimmed_heads,
352
+ document_projection_plan,
353
+ document_projection_encoded_document,
354
+ document_projection_signer,
355
+ )?;
356
+ self.prepare_plain_entry_commit_no_next_document_index_compact_trim_hashes(
357
+ wall_time,
358
+ logical,
359
+ gid,
360
+ entry_type,
361
+ meta_data,
362
+ payload_data,
363
+ trim_length_to,
364
+ document_gid,
365
+ payload_size,
366
+ document_index_commit,
367
+ false,
368
+ )
369
+ }
370
+
371
+ #[allow(clippy::too_many_arguments)]
372
+ pub fn prepare_plain_entry_commit_no_next_facts_document_index_compact_trim_hashes(
373
+ &mut self,
374
+ wall_time: u64,
375
+ logical: u32,
376
+ gid: String,
377
+ entry_type: u8,
378
+ meta_data: JsValue,
379
+ payload_data: Uint8Array,
380
+ trim_length_to: usize,
381
+ document_key: String,
382
+ document_value_prefix_bytes: Vec<u8>,
383
+ document_existing_created: String,
384
+ document_byte_element_index_limit: usize,
385
+ document_delete_trimmed_heads: bool,
386
+ document_projection_plan: JsValue,
387
+ document_projection_encoded_document: JsValue,
388
+ document_projection_signer: JsValue,
389
+ ) -> Result<Array, JsValue> {
390
+ let document_gid = gid.clone();
391
+ let payload_size = payload_data.length();
392
+ let document_index_commit = document_index_append_commit(
393
+ document_key,
394
+ document_value_prefix_bytes,
395
+ document_existing_created,
396
+ document_byte_element_index_limit,
397
+ document_delete_trimmed_heads,
398
+ document_projection_plan,
399
+ document_projection_encoded_document,
400
+ document_projection_signer,
401
+ )?;
402
+ self.prepare_plain_entry_commit_no_next_document_index_compact_trim_hashes(
403
+ wall_time,
404
+ logical,
405
+ gid,
406
+ entry_type,
407
+ meta_data,
408
+ payload_data,
409
+ trim_length_to,
410
+ document_gid,
411
+ payload_size,
412
+ document_index_commit,
413
+ true,
414
+ )
415
+ }
416
+
417
+ #[allow(clippy::too_many_arguments)]
418
+ pub fn prepare_plain_entry_commit_no_next_facts_document_index_cached_plan_trim_hashes(
419
+ &mut self,
420
+ wall_time: u64,
421
+ logical: u32,
422
+ gid: String,
423
+ entry_type: u8,
424
+ meta_data: JsValue,
425
+ payload_data: Uint8Array,
426
+ trim_length_to: usize,
427
+ document_key: String,
428
+ document_existing_created: String,
429
+ document_byte_element_index_limit: usize,
430
+ document_delete_trimmed_heads: bool,
431
+ document_projection_plan_id: u32,
432
+ document_projection_encoded_document: JsValue,
433
+ document_projection_signer: JsValue,
434
+ ) -> Result<Array, JsValue> {
435
+ let document_gid = gid.clone();
436
+ let payload_size = payload_data.length();
437
+ let document_index_commit = document_index_cached_projection_append_commit(
438
+ document_key,
439
+ document_existing_created,
440
+ document_byte_element_index_limit,
441
+ document_delete_trimmed_heads,
442
+ document_projection_plan_id,
443
+ document_projection_encoded_document,
444
+ document_projection_signer,
445
+ )?;
446
+ self.prepare_plain_entry_commit_no_next_document_index_compact_trim_hashes(
447
+ wall_time,
448
+ logical,
449
+ gid,
450
+ entry_type,
451
+ meta_data,
452
+ payload_data,
453
+ trim_length_to,
454
+ document_gid,
455
+ payload_size,
456
+ document_index_commit,
457
+ false,
458
+ )
459
+ }
460
+
461
+ #[allow(clippy::too_many_arguments)]
462
+ pub fn prepare_plain_entry_commit_latest_facts_document_index_trim_hashes(
463
+ &mut self,
464
+ wall_time: u64,
465
+ logical: u32,
466
+ fallback_gid: String,
467
+ entry_type: u8,
468
+ meta_data: JsValue,
469
+ payload_data: Uint8Array,
470
+ trim_length_to: JsValue,
471
+ document_key: String,
472
+ document_value_prefix_bytes: Vec<u8>,
473
+ document_byte_element_index_limit: usize,
474
+ document_delete_trimmed_heads: bool,
475
+ document_projection_plan: JsValue,
476
+ document_projection_encoded_document: JsValue,
477
+ document_projection_signer: JsValue,
478
+ ) -> Result<Array, JsValue> {
479
+ let document_index_commit = document_index_append_commit(
480
+ document_key,
481
+ document_value_prefix_bytes,
482
+ String::new(),
483
+ document_byte_element_index_limit,
484
+ document_delete_trimmed_heads,
485
+ document_projection_plan,
486
+ document_projection_encoded_document,
487
+ document_projection_signer,
488
+ )?;
489
+ self.prepare_plain_entry_commit_latest_document_index_trim_hashes_inner(
490
+ wall_time,
491
+ logical,
492
+ fallback_gid,
493
+ entry_type,
494
+ meta_data,
495
+ payload_data,
496
+ trim_length_to,
497
+ document_index_commit,
498
+ )
499
+ }
500
+
501
+ #[allow(clippy::too_many_arguments)]
502
+ pub fn prepare_plain_entry_commit_latest_facts_document_index_cached_plan_trim_hashes(
503
+ &mut self,
504
+ wall_time: u64,
505
+ logical: u32,
506
+ fallback_gid: String,
507
+ entry_type: u8,
508
+ meta_data: JsValue,
509
+ payload_data: Uint8Array,
510
+ trim_length_to: JsValue,
511
+ document_key: String,
512
+ document_byte_element_index_limit: usize,
513
+ document_delete_trimmed_heads: bool,
514
+ document_projection_plan_id: u32,
515
+ document_projection_encoded_document: JsValue,
516
+ document_projection_signer: JsValue,
517
+ ) -> Result<Array, JsValue> {
518
+ let document_index_commit = document_index_cached_projection_append_commit(
519
+ document_key,
520
+ String::new(),
521
+ document_byte_element_index_limit,
522
+ document_delete_trimmed_heads,
523
+ document_projection_plan_id,
524
+ document_projection_encoded_document,
525
+ document_projection_signer,
526
+ )?;
527
+ self.prepare_plain_entry_commit_latest_document_index_trim_hashes_inner(
528
+ wall_time,
529
+ logical,
530
+ fallback_gid,
531
+ entry_type,
532
+ meta_data,
533
+ payload_data,
534
+ trim_length_to,
535
+ document_index_commit,
536
+ )
537
+ }
538
+
539
+ #[allow(clippy::too_many_arguments)]
540
+ pub fn prepare_plain_entry_commit_no_next_facts_document_index_cached_plan_compact_trim_hashes(
541
+ &mut self,
542
+ wall_time: u64,
543
+ logical: u32,
544
+ gid: String,
545
+ entry_type: u8,
546
+ meta_data: JsValue,
547
+ payload_data: Uint8Array,
548
+ trim_length_to: usize,
549
+ document_key: String,
550
+ document_existing_created: String,
551
+ document_byte_element_index_limit: usize,
552
+ document_delete_trimmed_heads: bool,
553
+ document_projection_plan_id: u32,
554
+ document_projection_encoded_document: JsValue,
555
+ document_projection_signer: JsValue,
556
+ ) -> Result<Array, JsValue> {
557
+ let document_gid = gid.clone();
558
+ let payload_size = payload_data.length();
559
+ let document_index_commit = document_index_cached_projection_append_commit(
560
+ document_key,
561
+ document_existing_created,
562
+ document_byte_element_index_limit,
563
+ document_delete_trimmed_heads,
564
+ document_projection_plan_id,
565
+ document_projection_encoded_document,
566
+ document_projection_signer,
567
+ )?;
568
+ self.prepare_plain_entry_commit_no_next_document_index_compact_trim_hashes(
569
+ wall_time,
570
+ logical,
571
+ gid,
572
+ entry_type,
573
+ meta_data,
574
+ payload_data,
575
+ trim_length_to,
576
+ document_gid,
577
+ payload_size,
578
+ document_index_commit,
579
+ true,
580
+ )
581
+ }
582
+
583
+ #[allow(clippy::too_many_arguments)]
584
+ pub fn prepare_plain_entry_commit_no_next_facts_document_index_cached_plan_compact_trim_hashes_plain_put_payload(
585
+ &mut self,
586
+ wall_time: u64,
587
+ logical: u32,
588
+ gid: String,
589
+ entry_type: u8,
590
+ meta_data: JsValue,
591
+ payload_data: Uint8Array,
592
+ trim_length_to: usize,
593
+ document_key: String,
594
+ document_existing_created: String,
595
+ document_byte_element_index_limit: usize,
596
+ document_delete_trimmed_heads: bool,
597
+ document_projection_plan_id: u32,
598
+ document_projection_signer: JsValue,
599
+ ) -> Result<Array, JsValue> {
600
+ let document_gid = gid.clone();
601
+ let payload_size = payload_data.length();
602
+ let payload_data = payload_data.to_vec();
603
+ let document_index_commit =
604
+ document_index_cached_projection_plain_put_payload_append_commit(
605
+ document_key,
606
+ document_existing_created,
607
+ document_byte_element_index_limit,
608
+ document_delete_trimmed_heads,
609
+ document_projection_plan_id,
610
+ document_projection_signer,
611
+ )?;
612
+ let delete_trimmed_document_heads = document_index_commit.delete_trimmed_heads;
613
+ let (entry_facts, trim_hashes) = self
614
+ .log
615
+ .prepare_entry_v0_plain_entry_commit_no_next_facts_core_profiled_and_put_with_builder_trim_hashes_borrowed(
616
+ &self.builder,
617
+ &mut self.blocks,
618
+ wall_time,
619
+ logical,
620
+ gid,
621
+ entry_type,
622
+ optional_bytes_from_js(meta_data),
623
+ &payload_data,
624
+ trim_length_to,
625
+ None,
626
+ )?;
627
+ self.put_document_index_for_append_with_plain_put_payload(
628
+ Some(document_index_commit),
629
+ wall_time,
630
+ &entry_facts.hash,
631
+ &document_gid,
632
+ payload_size,
633
+ Some(&payload_data),
634
+ )?;
635
+ let document_trimmed_heads_processed = delete_trimmed_document_heads
636
+ && self.delete_documents_by_context_heads_profiled(&trim_hashes);
637
+ Ok(compact_committed_entry_facts_trim_hashes_to_row(
638
+ &entry_facts,
639
+ trim_hashes,
640
+ document_trimmed_heads_processed,
641
+ ))
642
+ }
643
+ }
644
+
645
+ impl NativePeerbitBackbone {
646
+ #[allow(clippy::too_many_arguments)]
647
+ fn prepare_plain_entry_commit_no_next_document_index_compact(
648
+ &mut self,
649
+ wall_time: u64,
650
+ logical: u32,
651
+ gid: String,
652
+ entry_type: u8,
653
+ meta_data: JsValue,
654
+ payload_data: Uint8Array,
655
+ document_gid: String,
656
+ payload_size: u32,
657
+ document_index_commit: DocumentIndexAppendCommit,
658
+ ) -> Result<Array, JsValue> {
659
+ let entry_facts = self
660
+ .log
661
+ .prepare_entry_v0_plain_entry_commit_no_next_facts_core_profiled_and_put_with_builder(
662
+ &self.builder,
663
+ &mut self.blocks,
664
+ wall_time,
665
+ logical,
666
+ gid,
667
+ entry_type,
668
+ optional_bytes_from_js(meta_data),
669
+ payload_data.to_vec(),
670
+ None,
671
+ )?;
672
+ self.put_document_index_for_append(
673
+ Some(document_index_commit),
674
+ wall_time,
675
+ &entry_facts.hash,
676
+ &document_gid,
677
+ payload_size,
678
+ )?;
679
+ Ok(committed_entry_facts_to_row(&entry_facts, false))
680
+ }
681
+
682
+ #[allow(clippy::too_many_arguments)]
683
+ fn prepare_plain_entry_commit_no_next_document_index_compact_trim_hashes(
684
+ &mut self,
685
+ wall_time: u64,
686
+ logical: u32,
687
+ gid: String,
688
+ entry_type: u8,
689
+ meta_data: JsValue,
690
+ payload_data: Uint8Array,
691
+ trim_length_to: usize,
692
+ document_gid: String,
693
+ payload_size: u32,
694
+ document_index_commit: DocumentIndexAppendCommit,
695
+ compact_row: bool,
696
+ ) -> Result<Array, JsValue> {
697
+ let delete_trimmed_document_heads = document_index_commit.delete_trimmed_heads;
698
+ let (entry_facts, trim_hashes) = self
699
+ .log
700
+ .prepare_entry_v0_plain_entry_commit_no_next_facts_core_profiled_and_put_with_builder_trim_hashes(
701
+ &self.builder,
702
+ &mut self.blocks,
703
+ wall_time,
704
+ logical,
705
+ gid,
706
+ entry_type,
707
+ optional_bytes_from_js(meta_data),
708
+ payload_data.to_vec(),
709
+ trim_length_to,
710
+ None,
711
+ )?;
712
+ self.put_document_index_for_append(
713
+ Some(document_index_commit),
714
+ wall_time,
715
+ &entry_facts.hash,
716
+ &document_gid,
717
+ payload_size,
718
+ )?;
719
+ let document_trimmed_heads_processed = delete_trimmed_document_heads
720
+ && self.delete_documents_by_context_heads_profiled(&trim_hashes);
721
+ if compact_row {
722
+ return Ok(compact_committed_entry_facts_trim_hashes_to_row(
723
+ &entry_facts,
724
+ trim_hashes,
725
+ document_trimmed_heads_processed,
726
+ ));
727
+ }
728
+ let out = Array::new();
729
+ out.push(&committed_entry_facts_to_row(&entry_facts, false));
730
+ out.push(&strings_to_array(trim_hashes));
731
+ out.push(&JsValue::from_bool(document_trimmed_heads_processed));
732
+ Ok(out)
733
+ }
734
+
735
+ #[allow(clippy::too_many_arguments)]
736
+ fn prepare_plain_entry_commit_latest_document_index_trim_hashes_inner(
737
+ &mut self,
738
+ wall_time: u64,
739
+ logical: u32,
740
+ fallback_gid: String,
741
+ entry_type: u8,
742
+ meta_data: JsValue,
743
+ payload_data: Uint8Array,
744
+ trim_length_to: JsValue,
745
+ mut document_index_commit: DocumentIndexAppendCommit,
746
+ ) -> Result<Array, JsValue> {
747
+ let trim_length_to = optional_usize_from_js(trim_length_to, "trimLengthTo")?;
748
+ let (previous_context, gid, next_hashes) =
749
+ self.resolve_latest_document_append_context(&mut document_index_commit, fallback_gid)?;
750
+ let delete_trimmed_document_heads = document_index_commit.delete_trimmed_heads;
751
+ let payload_size = payload_data.length();
752
+ let (entry_facts, trim_hashes) = self
753
+ .log
754
+ .prepare_entry_v0_plain_entry_commit_facts_core_profiled_and_put_with_builder_trim_hashes(
755
+ &self.builder,
756
+ &mut self.blocks,
757
+ wall_time,
758
+ logical,
759
+ gid.clone(),
760
+ next_hashes,
761
+ entry_type,
762
+ optional_bytes_from_js(meta_data),
763
+ payload_data.to_vec(),
764
+ trim_length_to,
765
+ None,
766
+ )?;
767
+ self.put_document_index_for_append(
768
+ Some(document_index_commit),
769
+ wall_time,
770
+ &entry_facts.hash,
771
+ &gid,
772
+ payload_size,
773
+ )?;
774
+ let document_trimmed_heads_processed = delete_trimmed_document_heads
775
+ && self.delete_documents_by_context_heads_profiled(&trim_hashes);
776
+ let out = Array::new();
777
+ out.push(&committed_entry_facts_to_row(
778
+ &entry_facts,
779
+ !entry_facts.next.is_empty(),
780
+ ));
781
+ out.push(&strings_to_array(trim_hashes));
782
+ out.push(&JsValue::from_bool(document_trimmed_heads_processed));
783
+ out.push(
784
+ &previous_context
785
+ .as_ref()
786
+ .map(|context| document_context_facts_to_row(context).into())
787
+ .unwrap_or(JsValue::UNDEFINED),
788
+ );
789
+ Ok(out)
790
+ }
791
+ }