autobee 1.0.0 → 1.0.2

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.
@@ -1,644 +0,0 @@
1
- // This file is autogenerated by the hyperschema compiler
2
- // Schema Version: 1
3
- /* eslint-disable camelcase */
4
- /* eslint-disable quotes */
5
- /* eslint-disable space-before-function-paren */
6
-
7
- const { c } = require('hyperschema/runtime')
8
-
9
- const VERSION = 1
10
-
11
- // eslint-disable-next-line no-unused-vars
12
- let version = VERSION
13
-
14
- // @autobee/system-info
15
- const encoding0 = {
16
- preencode(state, m) {
17
- c.uint.preencode(state, m.version)
18
- c.uint.preencode(state, m.timestamp)
19
- c.uint.preencode(state, m.flushes)
20
- encoding2.preencode(state, m.view)
21
- encoding0_4.preencode(state, m.heads)
22
- state.end++ // max flag is 1 so always one byte
23
-
24
- if (m.indexers) encoding0_5.preencode(state, m.indexers)
25
- },
26
- encode(state, m) {
27
- const flags = m.indexers ? 1 : 0
28
-
29
- c.uint.encode(state, m.version)
30
- c.uint.encode(state, m.timestamp)
31
- c.uint.encode(state, m.flushes)
32
- encoding2.encode(state, m.view)
33
- encoding0_4.encode(state, m.heads)
34
- c.uint.encode(state, flags)
35
-
36
- if (m.indexers) encoding0_5.encode(state, m.indexers)
37
- },
38
- decode(state) {
39
- const r0 = c.uint.decode(state)
40
- const r1 = c.uint.decode(state)
41
- const r2 = c.uint.decode(state)
42
- const r3 = encoding2.decode(state)
43
- const r4 = encoding0_4.decode(state)
44
- const flags = c.uint.decode(state)
45
-
46
- return {
47
- version: r0,
48
- timestamp: r1,
49
- flushes: r2,
50
- view: r3,
51
- heads: r4,
52
- indexers: (flags & 1) !== 0 ? encoding0_5.decode(state) : null
53
- }
54
- }
55
- }
56
-
57
- // @autobee/system-writer
58
- const encoding1 = {
59
- preencode(state, m) {
60
- c.uint.preencode(state, m.length)
61
- state.end++ // max flag is 4 so always one byte
62
- },
63
- encode(state, m) {
64
- const flags = (m.isIndexer ? 1 : 0) | (m.isRemoved ? 2 : 0) | (m.isOplog ? 4 : 0)
65
-
66
- c.uint.encode(state, m.length)
67
- c.uint.encode(state, flags)
68
- },
69
- decode(state) {
70
- const r0 = c.uint.decode(state)
71
- const flags = c.uint.decode(state)
72
-
73
- return {
74
- length: r0,
75
- isIndexer: (flags & 1) !== 0,
76
- isRemoved: (flags & 2) !== 0,
77
- isOplog: (flags & 4) !== 0
78
- }
79
- }
80
- }
81
-
82
- // @autobee/link
83
- const encoding2 = {
84
- preencode(state, m) {
85
- c.fixed32.preencode(state, m.key)
86
- c.uint.preencode(state, m.length)
87
- },
88
- encode(state, m) {
89
- c.fixed32.encode(state, m.key)
90
- c.uint.encode(state, m.length)
91
- },
92
- decode(state) {
93
- const r0 = c.fixed32.decode(state)
94
- const r1 = c.uint.decode(state)
95
-
96
- return {
97
- key: r0,
98
- length: r1
99
- }
100
- }
101
- }
102
-
103
- // @autobee/batch
104
- const encoding3 = {
105
- preencode(state, m) {
106
- c.uint.preencode(state, m.start)
107
- c.uint.preencode(state, m.end)
108
- },
109
- encode(state, m) {
110
- c.uint.encode(state, m.start)
111
- c.uint.encode(state, m.end)
112
- },
113
- decode(state) {
114
- const r0 = c.uint.decode(state)
115
- const r1 = c.uint.decode(state)
116
-
117
- return {
118
- start: r0,
119
- end: r1
120
- }
121
- }
122
- }
123
-
124
- // @autobee/views
125
- const encoding4 = {
126
- preencode(state, m) {
127
- encoding2.preencode(state, m.system)
128
- c.uint.preencode(state, m.flushes)
129
- state.end++ // flags are fixed size
130
-
131
- if (m.view) encoding2.preencode(state, m.view)
132
- },
133
- encode(state, m) {
134
- const flags = m.view ? 1 : 0
135
-
136
- encoding2.encode(state, m.system)
137
- c.uint.encode(state, m.flushes)
138
- c.uint8.encode(state, flags)
139
-
140
- if (m.view) encoding2.encode(state, m.view)
141
- },
142
- decode(state) {
143
- const r0 = encoding2.decode(state)
144
- const r1 = c.uint.decode(state)
145
- const flags = c.uint8.decode(state)
146
-
147
- return {
148
- system: r0,
149
- flushes: r1,
150
- view: (flags & 1) !== 0 ? encoding2.decode(state) : null
151
- }
152
- }
153
- }
154
-
155
- // @autobee/views (inline)
156
- const encoding4_inline = {
157
- preencode(state, m) {
158
- encoding2.preencode(state, m.system)
159
- c.uint.preencode(state, m.flushes)
160
-
161
- if (m.view) encoding2.preencode(state, m.view)
162
- },
163
- encode(state, m) {
164
- encoding2.encode(state, m.system)
165
- c.uint.encode(state, m.flushes)
166
-
167
- if (m.view) encoding2.encode(state, m.view)
168
- },
169
- decode(state, inlining) {
170
- const r0 = encoding2.decode(state)
171
- const r1 = c.uint.decode(state)
172
- const flags = inlining
173
-
174
- return {
175
- system: r0,
176
- flushes: r1,
177
- view: (flags & 1) !== 0 ? encoding2.decode(state) : null
178
- }
179
- }
180
- }
181
-
182
- // @autobee/oplog-message-v3
183
- const encoding5 = {
184
- preencode(state, m) {
185
- c.uint.preencode(state, m.timestamp)
186
- encoding5_1.preencode(state, m.links)
187
- state.end++ // max flag is 16 so always one byte
188
-
189
- if (m.batch) encoding3.preencode(state, m.batch)
190
- if (m.views) encoding4_inline.preencode(state, m.views)
191
- if (m.value) c.buffer.preencode(state, m.value)
192
- },
193
- encode(state, m) {
194
- let flags = (m.batch ? 1 : 0) | (m.views ? 2 : 0) | (m.optimistic ? 8 : 0) | (m.value ? 16 : 0)
195
- if (m.views) {
196
- flags |= m.views.view ? 4 : 0
197
- }
198
-
199
- c.uint.encode(state, m.timestamp)
200
- encoding5_1.encode(state, m.links)
201
- c.uint.encode(state, flags)
202
-
203
- if (m.batch) encoding3.encode(state, m.batch)
204
- if (m.views) encoding4_inline.encode(state, m.views)
205
- if (m.value) c.buffer.encode(state, m.value)
206
- },
207
- decode(state) {
208
- const v = c.uint.decode(state)
209
- const r0 = c.uint.decode(state)
210
- const r1 = encoding5_1.decode(state)
211
- const flags = c.uint.decode(state)
212
-
213
- return {
214
- version: v,
215
- timestamp: r0,
216
- links: r1,
217
- batch: (flags & 1) !== 0 ? encoding3.decode(state) : null,
218
- views: (flags & 2) !== 0 ? encoding4_inline.decode(state, flags >>> 2) : null,
219
- optimistic: (flags & 8) !== 0,
220
- value: (flags & 16) !== 0 ? c.buffer.decode(state) : null
221
- }
222
- }
223
- }
224
-
225
- // @autobase-compat/checkout
226
- const encoding6 = encoding2
227
-
228
- // @autobase-compat/clock
229
- const encoding7 = c.array(encoding6)
230
-
231
- // @autobase-compat/index-checkpoint
232
- const encoding8 = {
233
- preencode(state, m) {
234
- c.fixed64.preencode(state, m.signature)
235
- c.uint.preencode(state, m.length)
236
- },
237
- encode(state, m) {
238
- c.fixed64.encode(state, m.signature)
239
- c.uint.encode(state, m.length)
240
- },
241
- decode(state) {
242
- const r0 = c.fixed64.decode(state)
243
- const r1 = c.uint.decode(state)
244
-
245
- return {
246
- signature: r0,
247
- length: r1
248
- }
249
- }
250
- }
251
-
252
- // @autobase-compat/checkpointer
253
- const encoding9 = {
254
- preencode(state, m) {
255
- state.end++ // flags are fixed size
256
-
257
- if (m.checkpointer) c.uint.preencode(state, m.checkpointer)
258
- if (m.checkpoint) encoding8.preencode(state, m.checkpoint)
259
- },
260
- encode(state, m) {
261
- const flags = (m.checkpointer ? 1 : 0) | (m.checkpoint ? 2 : 0)
262
-
263
- c.uint8.encode(state, flags)
264
-
265
- if (m.checkpointer) c.uint.encode(state, m.checkpointer)
266
- if (m.checkpoint) encoding8.encode(state, m.checkpoint)
267
- },
268
- decode(state) {
269
- const flags = c.uint8.decode(state)
270
-
271
- return {
272
- checkpointer: (flags & 1) !== 0 ? c.uint.decode(state) : 0,
273
- checkpoint: (flags & 2) !== 0 ? encoding8.decode(state) : null
274
- }
275
- }
276
- }
277
-
278
- // @autobase-compat/checkpoint.user
279
- const encoding10_2 = c.array(encoding9)
280
-
281
- // @autobase-compat/checkpoint
282
- const encoding10 = {
283
- preencode(state, m) {
284
- state.end++ // max flag is 4 so always one byte
285
-
286
- if (m.system) encoding9.preencode(state, m.system)
287
- if (m.encryption) encoding9.preencode(state, m.encryption)
288
- if (m.user) encoding10_2.preencode(state, m.user)
289
- },
290
- encode(state, m) {
291
- const flags = (m.system ? 1 : 0) | (m.encryption ? 2 : 0) | (m.user ? 4 : 0)
292
-
293
- c.uint.encode(state, flags)
294
-
295
- if (m.system) encoding9.encode(state, m.system)
296
- if (m.encryption) encoding9.encode(state, m.encryption)
297
- if (m.user) encoding10_2.encode(state, m.user)
298
- },
299
- decode(state) {
300
- const flags = c.uint.decode(state)
301
-
302
- return {
303
- system: (flags & 1) !== 0 ? encoding9.decode(state) : null,
304
- encryption: (flags & 2) !== 0 ? encoding9.decode(state) : null,
305
- user: (flags & 4) !== 0 ? encoding10_2.decode(state) : null
306
- }
307
- }
308
- }
309
-
310
- // @autobase-compat/digest
311
- const encoding11 = {
312
- preencode(state, m) {
313
- state.end++ // max flag is 2 so always one byte
314
-
315
- if (m.pointer) c.uint.preencode(state, m.pointer)
316
- if (m.key) c.fixed32.preencode(state, m.key)
317
- },
318
- encode(state, m) {
319
- const flags = (m.pointer ? 1 : 0) | (m.key ? 2 : 0)
320
-
321
- c.uint.encode(state, flags)
322
-
323
- if (m.pointer) c.uint.encode(state, m.pointer)
324
- if (m.key) c.fixed32.encode(state, m.key)
325
- },
326
- decode(state) {
327
- const flags = c.uint.decode(state)
328
-
329
- return {
330
- pointer: (flags & 1) !== 0 ? c.uint.decode(state) : 0,
331
- key: (flags & 2) !== 0 ? c.fixed32.decode(state) : null
332
- }
333
- }
334
- }
335
-
336
- // @autobase-compat/node
337
- const encoding12 = {
338
- preencode(state, m) {
339
- encoding7.preencode(state, m.heads)
340
- c.uint.preencode(state, m.batch)
341
- c.buffer.preencode(state, m.value)
342
- },
343
- encode(state, m) {
344
- encoding7.encode(state, m.heads)
345
- c.uint.encode(state, m.batch)
346
- c.buffer.encode(state, m.value)
347
- },
348
- decode(state) {
349
- const r0 = encoding7.decode(state)
350
- const r1 = c.uint.decode(state)
351
- const r2 = c.buffer.decode(state)
352
-
353
- return {
354
- heads: r0,
355
- batch: r1,
356
- value: r2
357
- }
358
- }
359
- }
360
-
361
- // @autobase-compat/user-view-trace.blocks
362
- const encoding13_1 = c.array(c.uint)
363
-
364
- // @autobase-compat/user-view-trace
365
- const encoding13 = {
366
- preencode(state, m) {
367
- c.uint.preencode(state, m.view)
368
- encoding13_1.preencode(state, m.blocks)
369
- },
370
- encode(state, m) {
371
- c.uint.encode(state, m.view)
372
- encoding13_1.encode(state, m.blocks)
373
- },
374
- decode(state) {
375
- const r0 = c.uint.decode(state)
376
- const r1 = encoding13_1.decode(state)
377
-
378
- return {
379
- view: r0,
380
- blocks: r1
381
- }
382
- }
383
- }
384
-
385
- // @autobase-compat/trace.system
386
- const encoding14_0 = encoding13_1
387
- // @autobase-compat/trace.encryption
388
- const encoding14_1 = encoding13_1
389
- // @autobase-compat/trace.user
390
- const encoding14_2 = c.array(encoding13)
391
-
392
- // @autobase-compat/trace
393
- const encoding14 = {
394
- preencode(state, m) {
395
- encoding14_0.preencode(state, m.system)
396
- encoding14_1.preencode(state, m.encryption)
397
- encoding14_2.preencode(state, m.user)
398
- },
399
- encode(state, m) {
400
- encoding14_0.encode(state, m.system)
401
- encoding14_1.encode(state, m.encryption)
402
- encoding14_2.encode(state, m.user)
403
- },
404
- decode(state) {
405
- const r0 = encoding14_0.decode(state)
406
- const r1 = encoding14_1.decode(state)
407
- const r2 = encoding14_2.decode(state)
408
-
409
- return {
410
- system: r0,
411
- encryption: r1,
412
- user: r2
413
- }
414
- }
415
- }
416
-
417
- // @autobase-compat/oplog-message-v2.checkpoint
418
- const encoding15_1 = c.frame(encoding10)
419
- // @autobase-compat/oplog-message-v2.digest
420
- const encoding15_2 = c.frame(encoding11)
421
- // @autobase-compat/oplog-message-v2.trace
422
- const encoding15_4 = c.frame(encoding14)
423
-
424
- // @autobase-compat/oplog-message-v2
425
- const encoding15 = {
426
- preencode(state, m) {
427
- encoding12.preencode(state, m.node)
428
- state.end++ // max flag is 8 so always one byte
429
-
430
- if (m.checkpoint) encoding15_1.preencode(state, m.checkpoint)
431
- if (m.digest) encoding15_2.preencode(state, m.digest)
432
- if (m.trace) encoding15_4.preencode(state, m.trace)
433
- },
434
- encode(state, m) {
435
- const flags =
436
- (m.checkpoint ? 1 : 0) | (m.digest ? 2 : 0) | (m.optimistic ? 4 : 0) | (m.trace ? 8 : 0)
437
-
438
- encoding12.encode(state, m.node)
439
- c.uint.encode(state, flags)
440
-
441
- if (m.checkpoint) encoding15_1.encode(state, m.checkpoint)
442
- if (m.digest) encoding15_2.encode(state, m.digest)
443
- if (m.trace) encoding15_4.encode(state, m.trace)
444
- },
445
- decode(state) {
446
- const v = c.uint.decode(state)
447
- const r0 = encoding12.decode(state)
448
- const flags = c.uint.decode(state)
449
-
450
- return {
451
- version: v,
452
- node: r0,
453
- checkpoint: (flags & 1) !== 0 ? encoding15_1.decode(state) : null,
454
- digest: (flags & 2) !== 0 ? encoding15_2.decode(state) : null,
455
- optimistic: (flags & 4) !== 0,
456
- trace: (flags & 8) !== 0 ? encoding15_4.decode(state) : null
457
- }
458
- }
459
- }
460
-
461
- // @autobee/oplog
462
- const encoding16 = {
463
- preencode(state, m) {
464
- c.uint.preencode(state, m.version)
465
- switch (m.version) {
466
- case 0:
467
- case 1:
468
- case 2:
469
- encoding15.preencode(state, m)
470
- break
471
- case 3:
472
- encoding5.preencode(state, m)
473
- break
474
- default:
475
- throw new Error('Unsupported version')
476
- }
477
- },
478
- encode(state, m) {
479
- c.uint.encode(state, m.version)
480
- switch (m.version) {
481
- case 0:
482
- case 1:
483
- case 2:
484
- encoding15.encode(state, m)
485
- break
486
- case 3:
487
- encoding5.encode(state, m)
488
- break
489
- default:
490
- throw new Error('Unsupported version')
491
- }
492
- },
493
- decode(state) {
494
- const start = state.start
495
- const v = c.uint.decode(state)
496
- state.start = start
497
- switch (v) {
498
- case 0:
499
- case 1:
500
- case 2: {
501
- const decoded = encoding15.decode(state)
502
- return decoded
503
- }
504
- case 3: {
505
- const decoded = encoding5.decode(state)
506
- return decoded
507
- }
508
- default:
509
- throw new Error('Unsupported version')
510
- }
511
- }
512
- }
513
-
514
- // @autobee/manifest-data
515
- const encoding17 = {
516
- preencode(state, m) {
517
- c.uint.preencode(state, m.version)
518
- state.end++ // max flag is 2 so always one byte
519
-
520
- if (m.legacyBlocks) c.uint.preencode(state, m.legacyBlocks)
521
- if (m.namespace) c.fixed32.preencode(state, m.namespace)
522
- },
523
- encode(state, m) {
524
- const flags = (m.legacyBlocks ? 1 : 0) | (m.namespace ? 2 : 0)
525
-
526
- c.uint.encode(state, m.version)
527
- c.uint.encode(state, flags)
528
-
529
- if (m.legacyBlocks) c.uint.encode(state, m.legacyBlocks)
530
- if (m.namespace) c.fixed32.encode(state, m.namespace)
531
- },
532
- decode(state) {
533
- const r0 = c.uint.decode(state)
534
- const flags = c.uint.decode(state)
535
-
536
- return {
537
- version: r0,
538
- legacyBlocks: (flags & 1) !== 0 ? c.uint.decode(state) : 0,
539
- namespace: (flags & 2) !== 0 ? c.fixed32.decode(state) : null
540
- }
541
- }
542
- }
543
-
544
- // @autobee/system-info.heads, deferred due to recusive use
545
- const encoding0_4 = c.array(encoding2)
546
- // @autobee/system-info.indexers, deferred due to recusive use
547
- const encoding0_5 = encoding0_4
548
- // @autobee/oplog-message-v3.links, deferred due to recusive use
549
- const encoding5_1 = encoding0_4
550
-
551
- function setVersion(v) {
552
- version = v
553
- }
554
-
555
- function encode(name, value, v = VERSION) {
556
- version = v
557
- return c.encode(getEncoding(name), value)
558
- }
559
-
560
- function decode(name, buffer, v = VERSION) {
561
- version = v
562
- return c.decode(getEncoding(name), buffer)
563
- }
564
-
565
- function getEnum(name) {
566
- switch (name) {
567
- default:
568
- throw new Error('Enum not found ' + name)
569
- }
570
- }
571
-
572
- function getEncoding(name) {
573
- switch (name) {
574
- case '@autobee/system-info':
575
- return encoding0
576
- case '@autobee/system-writer':
577
- return encoding1
578
- case '@autobee/link':
579
- return encoding2
580
- case '@autobee/batch':
581
- return encoding3
582
- case '@autobee/views':
583
- return encoding4
584
- case '@autobee/oplog-message-v3':
585
- return encoding5
586
- case '@autobase-compat/checkout':
587
- return encoding6
588
- case '@autobase-compat/clock':
589
- return encoding7
590
- case '@autobase-compat/index-checkpoint':
591
- return encoding8
592
- case '@autobase-compat/checkpointer':
593
- return encoding9
594
- case '@autobase-compat/checkpoint':
595
- return encoding10
596
- case '@autobase-compat/digest':
597
- return encoding11
598
- case '@autobase-compat/node':
599
- return encoding12
600
- case '@autobase-compat/user-view-trace':
601
- return encoding13
602
- case '@autobase-compat/trace':
603
- return encoding14
604
- case '@autobase-compat/oplog-message-v2':
605
- return encoding15
606
- case '@autobee/oplog':
607
- return encoding16
608
- case '@autobee/manifest-data':
609
- return encoding17
610
- default:
611
- throw new Error('Encoder not found ' + name)
612
- }
613
- }
614
-
615
- function getStruct(name, v = VERSION) {
616
- const enc = getEncoding(name)
617
- return {
618
- preencode(state, m) {
619
- version = v
620
- enc.preencode(state, m)
621
- },
622
- encode(state, m) {
623
- version = v
624
- enc.encode(state, m)
625
- },
626
- decode(state) {
627
- version = v
628
- return enc.decode(state)
629
- }
630
- }
631
- }
632
-
633
- const resolveStruct = getStruct // compat
634
-
635
- module.exports = {
636
- resolveStruct,
637
- getStruct,
638
- getEnum,
639
- getEncoding,
640
- encode,
641
- decode,
642
- setVersion,
643
- version
644
- }