gip-remote 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.
@@ -0,0 +1,442 @@
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
+ // @gip/repos
15
+ const encoding0 = {
16
+ preencode(state, m) {
17
+ c.string.preencode(state, m.name)
18
+ c.buffer.preencode(state, m.key)
19
+ state.end++ // flags are fixed size
20
+
21
+ if (m.description) c.string.preencode(state, m.description)
22
+ if (m.lastPushed) c.uint.preencode(state, m.lastPushed)
23
+ },
24
+ encode(state, m) {
25
+ const flags = (m.description ? 1 : 0) | (m.lastPushed ? 2 : 0)
26
+
27
+ c.string.encode(state, m.name)
28
+ c.buffer.encode(state, m.key)
29
+ c.uint8.encode(state, flags)
30
+
31
+ if (m.description) c.string.encode(state, m.description)
32
+ if (m.lastPushed) c.uint.encode(state, m.lastPushed)
33
+ },
34
+ decode(state) {
35
+ const r0 = c.string.decode(state)
36
+ const r1 = c.buffer.decode(state)
37
+ const flags = c.uint8.decode(state)
38
+
39
+ return {
40
+ name: r0,
41
+ key: r1,
42
+ description: (flags & 1) !== 0 ? c.string.decode(state) : null,
43
+ lastPushed: (flags & 2) !== 0 ? c.uint.decode(state) : 0
44
+ }
45
+ }
46
+ }
47
+
48
+ // @gip/branches.objects
49
+ const encoding1_6 = c.array(c.string)
50
+
51
+ // @gip/branches
52
+ const encoding1 = {
53
+ preencode(state, m) {
54
+ c.string.preencode(state, m.name)
55
+ c.string.preencode(state, m.commitOid)
56
+ c.string.preencode(state, m.treeOid)
57
+ state.end++ // flags are fixed size
58
+
59
+ if (m.author) c.string.preencode(state, m.author)
60
+ if (m.message) c.string.preencode(state, m.message)
61
+ if (m.timestamp) c.uint.preencode(state, m.timestamp)
62
+ if (m.objects) encoding1_6.preencode(state, m.objects)
63
+ },
64
+ encode(state, m) {
65
+ const flags =
66
+ (m.author ? 1 : 0) | (m.message ? 2 : 0) | (m.timestamp ? 4 : 0) | (m.objects ? 8 : 0)
67
+
68
+ c.string.encode(state, m.name)
69
+ c.string.encode(state, m.commitOid)
70
+ c.string.encode(state, m.treeOid)
71
+ c.uint8.encode(state, flags)
72
+
73
+ if (m.author) c.string.encode(state, m.author)
74
+ if (m.message) c.string.encode(state, m.message)
75
+ if (m.timestamp) c.uint.encode(state, m.timestamp)
76
+ if (m.objects) encoding1_6.encode(state, m.objects)
77
+ },
78
+ decode(state) {
79
+ const r0 = c.string.decode(state)
80
+ const r1 = c.string.decode(state)
81
+ const r2 = c.string.decode(state)
82
+ const flags = c.uint8.decode(state)
83
+
84
+ return {
85
+ name: r0,
86
+ commitOid: r1,
87
+ treeOid: r2,
88
+ author: (flags & 1) !== 0 ? c.string.decode(state) : null,
89
+ message: (flags & 2) !== 0 ? c.string.decode(state) : null,
90
+ timestamp: (flags & 4) !== 0 ? c.uint.decode(state) : 0,
91
+ objects: (flags & 8) !== 0 ? encoding1_6.decode(state) : null
92
+ }
93
+ }
94
+ }
95
+
96
+ // @gip/files
97
+ const encoding2 = {
98
+ preencode(state, m) {
99
+ c.string.preencode(state, m.branch)
100
+ c.string.preencode(state, m.path)
101
+ c.string.preencode(state, m.oid)
102
+ c.string.preencode(state, m.mode)
103
+ c.uint.preencode(state, m.size)
104
+ state.end++ // flags are fixed size
105
+
106
+ if (m.author) c.string.preencode(state, m.author)
107
+ if (m.message) c.string.preencode(state, m.message)
108
+ if (m.timestamp) c.uint.preencode(state, m.timestamp)
109
+ },
110
+ encode(state, m) {
111
+ const flags = (m.author ? 1 : 0) | (m.message ? 2 : 0) | (m.timestamp ? 4 : 0)
112
+
113
+ c.string.encode(state, m.branch)
114
+ c.string.encode(state, m.path)
115
+ c.string.encode(state, m.oid)
116
+ c.string.encode(state, m.mode)
117
+ c.uint.encode(state, m.size)
118
+ c.uint8.encode(state, flags)
119
+
120
+ if (m.author) c.string.encode(state, m.author)
121
+ if (m.message) c.string.encode(state, m.message)
122
+ if (m.timestamp) c.uint.encode(state, m.timestamp)
123
+ },
124
+ decode(state) {
125
+ const r0 = c.string.decode(state)
126
+ const r1 = c.string.decode(state)
127
+ const r2 = c.string.decode(state)
128
+ const r3 = c.string.decode(state)
129
+ const r4 = c.uint.decode(state)
130
+ const flags = c.uint8.decode(state)
131
+
132
+ return {
133
+ branch: r0,
134
+ path: r1,
135
+ oid: r2,
136
+ mode: r3,
137
+ size: r4,
138
+ author: (flags & 1) !== 0 ? c.string.decode(state) : null,
139
+ message: (flags & 2) !== 0 ? c.string.decode(state) : null,
140
+ timestamp: (flags & 4) !== 0 ? c.uint.decode(state) : 0
141
+ }
142
+ }
143
+ }
144
+
145
+ const encoding3_enum = {
146
+ blob: 'blob',
147
+ tree: 'tree',
148
+ commit: 'commit',
149
+ tag: 'tag'
150
+ }
151
+
152
+ // @gip/object-type enum
153
+ const encoding3 = {
154
+ preencode(state, m) {
155
+ state.end++ // max enum is 4 so always one byte
156
+ },
157
+ encode(state, m) {
158
+ switch (m) {
159
+ case 'blob':
160
+ c.uint.encode(state, 1)
161
+ break
162
+ case 'tree':
163
+ c.uint.encode(state, 2)
164
+ break
165
+ case 'commit':
166
+ c.uint.encode(state, 3)
167
+ break
168
+ case 'tag':
169
+ c.uint.encode(state, 4)
170
+ break
171
+ default:
172
+ throw new Error('Unknown enum')
173
+ }
174
+ },
175
+ decode(state) {
176
+ switch (c.uint.decode(state)) {
177
+ case 1:
178
+ return 'blob'
179
+ case 2:
180
+ return 'tree'
181
+ case 3:
182
+ return 'commit'
183
+ case 4:
184
+ return 'tag'
185
+ default:
186
+ return null
187
+ }
188
+ }
189
+ }
190
+
191
+ // @gip/objects
192
+ const encoding4 = {
193
+ preencode(state, m) {
194
+ c.string.preencode(state, m.oid)
195
+ encoding3.preencode(state, m.type)
196
+ c.uint.preencode(state, m.size)
197
+ c.buffer.preencode(state, m.data)
198
+ },
199
+ encode(state, m) {
200
+ c.string.encode(state, m.oid)
201
+ encoding3.encode(state, m.type)
202
+ c.uint.encode(state, m.size)
203
+ c.buffer.encode(state, m.data)
204
+ },
205
+ decode(state) {
206
+ const r0 = c.string.decode(state)
207
+ const r1 = encoding3.decode(state)
208
+ const r2 = c.uint.decode(state)
209
+ const r3 = c.buffer.decode(state)
210
+
211
+ return {
212
+ oid: r0,
213
+ type: r1,
214
+ size: r2,
215
+ data: r3
216
+ }
217
+ }
218
+ }
219
+
220
+ // @gip/repos/hyperdb#0
221
+ const encoding5 = {
222
+ preencode(state, m) {
223
+ c.buffer.preencode(state, m.key)
224
+ state.end++ // flags are fixed size
225
+
226
+ if (m.description) c.string.preencode(state, m.description)
227
+ if (m.lastPushed) c.uint.preencode(state, m.lastPushed)
228
+ },
229
+ encode(state, m) {
230
+ const flags = (m.description ? 1 : 0) | (m.lastPushed ? 2 : 0)
231
+
232
+ c.buffer.encode(state, m.key)
233
+ c.uint8.encode(state, flags)
234
+
235
+ if (m.description) c.string.encode(state, m.description)
236
+ if (m.lastPushed) c.uint.encode(state, m.lastPushed)
237
+ },
238
+ decode(state) {
239
+ const r1 = c.buffer.decode(state)
240
+ const flags = c.uint8.decode(state)
241
+
242
+ return {
243
+ name: null,
244
+ key: r1,
245
+ description: (flags & 1) !== 0 ? c.string.decode(state) : null,
246
+ lastPushed: (flags & 2) !== 0 ? c.uint.decode(state) : 0
247
+ }
248
+ }
249
+ }
250
+
251
+ // @gip/branches/hyperdb#1.objects
252
+ const encoding6_6 = encoding1_6
253
+
254
+ // @gip/branches/hyperdb#1
255
+ const encoding6 = {
256
+ preencode(state, m) {
257
+ c.string.preencode(state, m.commitOid)
258
+ c.string.preencode(state, m.treeOid)
259
+ state.end++ // flags are fixed size
260
+
261
+ if (m.author) c.string.preencode(state, m.author)
262
+ if (m.message) c.string.preencode(state, m.message)
263
+ if (m.timestamp) c.uint.preencode(state, m.timestamp)
264
+ if (m.objects) encoding6_6.preencode(state, m.objects)
265
+ },
266
+ encode(state, m) {
267
+ const flags =
268
+ (m.author ? 1 : 0) | (m.message ? 2 : 0) | (m.timestamp ? 4 : 0) | (m.objects ? 8 : 0)
269
+
270
+ c.string.encode(state, m.commitOid)
271
+ c.string.encode(state, m.treeOid)
272
+ c.uint8.encode(state, flags)
273
+
274
+ if (m.author) c.string.encode(state, m.author)
275
+ if (m.message) c.string.encode(state, m.message)
276
+ if (m.timestamp) c.uint.encode(state, m.timestamp)
277
+ if (m.objects) encoding6_6.encode(state, m.objects)
278
+ },
279
+ decode(state) {
280
+ const r1 = c.string.decode(state)
281
+ const r2 = c.string.decode(state)
282
+ const flags = c.uint8.decode(state)
283
+
284
+ return {
285
+ name: null,
286
+ commitOid: r1,
287
+ treeOid: r2,
288
+ author: (flags & 1) !== 0 ? c.string.decode(state) : null,
289
+ message: (flags & 2) !== 0 ? c.string.decode(state) : null,
290
+ timestamp: (flags & 4) !== 0 ? c.uint.decode(state) : 0,
291
+ objects: (flags & 8) !== 0 ? encoding6_6.decode(state) : null
292
+ }
293
+ }
294
+ }
295
+
296
+ // @gip/files/hyperdb#2
297
+ const encoding7 = {
298
+ preencode(state, m) {
299
+ c.string.preencode(state, m.oid)
300
+ c.string.preencode(state, m.mode)
301
+ c.uint.preencode(state, m.size)
302
+ state.end++ // flags are fixed size
303
+
304
+ if (m.author) c.string.preencode(state, m.author)
305
+ if (m.message) c.string.preencode(state, m.message)
306
+ if (m.timestamp) c.uint.preencode(state, m.timestamp)
307
+ },
308
+ encode(state, m) {
309
+ const flags = (m.author ? 1 : 0) | (m.message ? 2 : 0) | (m.timestamp ? 4 : 0)
310
+
311
+ c.string.encode(state, m.oid)
312
+ c.string.encode(state, m.mode)
313
+ c.uint.encode(state, m.size)
314
+ c.uint8.encode(state, flags)
315
+
316
+ if (m.author) c.string.encode(state, m.author)
317
+ if (m.message) c.string.encode(state, m.message)
318
+ if (m.timestamp) c.uint.encode(state, m.timestamp)
319
+ },
320
+ decode(state) {
321
+ const r2 = c.string.decode(state)
322
+ const r3 = c.string.decode(state)
323
+ const r4 = c.uint.decode(state)
324
+ const flags = c.uint8.decode(state)
325
+
326
+ return {
327
+ branch: null,
328
+ path: null,
329
+ oid: r2,
330
+ mode: r3,
331
+ size: r4,
332
+ author: (flags & 1) !== 0 ? c.string.decode(state) : null,
333
+ message: (flags & 2) !== 0 ? c.string.decode(state) : null,
334
+ timestamp: (flags & 4) !== 0 ? c.uint.decode(state) : 0
335
+ }
336
+ }
337
+ }
338
+
339
+ // @gip/objects/hyperdb#3
340
+ const encoding8 = {
341
+ preencode(state, m) {
342
+ encoding3.preencode(state, m.type)
343
+ c.uint.preencode(state, m.size)
344
+ c.buffer.preencode(state, m.data)
345
+ },
346
+ encode(state, m) {
347
+ encoding3.encode(state, m.type)
348
+ c.uint.encode(state, m.size)
349
+ c.buffer.encode(state, m.data)
350
+ },
351
+ decode(state) {
352
+ const r1 = encoding3.decode(state)
353
+ const r2 = c.uint.decode(state)
354
+ const r3 = c.buffer.decode(state)
355
+
356
+ return {
357
+ oid: null,
358
+ type: r1,
359
+ size: r2,
360
+ data: r3
361
+ }
362
+ }
363
+ }
364
+
365
+ function setVersion(v) {
366
+ version = v
367
+ }
368
+
369
+ function encode(name, value, v = VERSION) {
370
+ version = v
371
+ return c.encode(getEncoding(name), value)
372
+ }
373
+
374
+ function decode(name, buffer, v = VERSION) {
375
+ version = v
376
+ return c.decode(getEncoding(name), buffer)
377
+ }
378
+
379
+ function getEnum(name) {
380
+ switch (name) {
381
+ case '@gip/object-type':
382
+ return encoding3_enum
383
+ default:
384
+ throw new Error('Enum not found ' + name)
385
+ }
386
+ }
387
+
388
+ function getEncoding(name) {
389
+ switch (name) {
390
+ case '@gip/repos':
391
+ return encoding0
392
+ case '@gip/branches':
393
+ return encoding1
394
+ case '@gip/files':
395
+ return encoding2
396
+ case '@gip/object-type':
397
+ return encoding3
398
+ case '@gip/objects':
399
+ return encoding4
400
+ case '@gip/repos/hyperdb#0':
401
+ return encoding5
402
+ case '@gip/branches/hyperdb#1':
403
+ return encoding6
404
+ case '@gip/files/hyperdb#2':
405
+ return encoding7
406
+ case '@gip/objects/hyperdb#3':
407
+ return encoding8
408
+ default:
409
+ throw new Error('Encoder not found ' + name)
410
+ }
411
+ }
412
+
413
+ function getStruct(name, v = VERSION) {
414
+ const enc = getEncoding(name)
415
+ return {
416
+ preencode(state, m) {
417
+ version = v
418
+ enc.preencode(state, m)
419
+ },
420
+ encode(state, m) {
421
+ version = v
422
+ enc.encode(state, m)
423
+ },
424
+ decode(state) {
425
+ version = v
426
+ return enc.decode(state)
427
+ }
428
+ }
429
+ }
430
+
431
+ const resolveStruct = getStruct // compat
432
+
433
+ module.exports = {
434
+ resolveStruct,
435
+ getStruct,
436
+ getEnum,
437
+ getEncoding,
438
+ encode,
439
+ decode,
440
+ setVersion,
441
+ version
442
+ }
@@ -0,0 +1,289 @@
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
+ // @gip/repos
15
+ const encoding0 = {
16
+ preencode(state, m) {
17
+ c.string.preencode(state, m.name)
18
+ c.buffer.preencode(state, m.key)
19
+ state.end++ // flags are fixed size
20
+
21
+ if (m.description) c.string.preencode(state, m.description)
22
+ if (m.lastPushed) c.uint.preencode(state, m.lastPushed)
23
+ },
24
+ encode(state, m) {
25
+ const flags = (m.description ? 1 : 0) | (m.lastPushed ? 2 : 0)
26
+
27
+ c.string.encode(state, m.name)
28
+ c.buffer.encode(state, m.key)
29
+ c.uint8.encode(state, flags)
30
+
31
+ if (m.description) c.string.encode(state, m.description)
32
+ if (m.lastPushed) c.uint.encode(state, m.lastPushed)
33
+ },
34
+ decode(state) {
35
+ const r0 = c.string.decode(state)
36
+ const r1 = c.buffer.decode(state)
37
+ const flags = c.uint8.decode(state)
38
+
39
+ return {
40
+ name: r0,
41
+ key: r1,
42
+ description: (flags & 1) !== 0 ? c.string.decode(state) : null,
43
+ lastPushed: (flags & 2) !== 0 ? c.uint.decode(state) : 0
44
+ }
45
+ }
46
+ }
47
+
48
+ // @gip/branches.objects
49
+ const encoding1_6 = c.array(c.string)
50
+
51
+ // @gip/branches
52
+ const encoding1 = {
53
+ preencode(state, m) {
54
+ c.string.preencode(state, m.name)
55
+ c.string.preencode(state, m.commitOid)
56
+ c.string.preencode(state, m.treeOid)
57
+ state.end++ // flags are fixed size
58
+
59
+ if (m.author) c.string.preencode(state, m.author)
60
+ if (m.message) c.string.preencode(state, m.message)
61
+ if (m.timestamp) c.uint.preencode(state, m.timestamp)
62
+ if (m.objects) encoding1_6.preencode(state, m.objects)
63
+ },
64
+ encode(state, m) {
65
+ const flags =
66
+ (m.author ? 1 : 0) | (m.message ? 2 : 0) | (m.timestamp ? 4 : 0) | (m.objects ? 8 : 0)
67
+
68
+ c.string.encode(state, m.name)
69
+ c.string.encode(state, m.commitOid)
70
+ c.string.encode(state, m.treeOid)
71
+ c.uint8.encode(state, flags)
72
+
73
+ if (m.author) c.string.encode(state, m.author)
74
+ if (m.message) c.string.encode(state, m.message)
75
+ if (m.timestamp) c.uint.encode(state, m.timestamp)
76
+ if (m.objects) encoding1_6.encode(state, m.objects)
77
+ },
78
+ decode(state) {
79
+ const r0 = c.string.decode(state)
80
+ const r1 = c.string.decode(state)
81
+ const r2 = c.string.decode(state)
82
+ const flags = c.uint8.decode(state)
83
+
84
+ return {
85
+ name: r0,
86
+ commitOid: r1,
87
+ treeOid: r2,
88
+ author: (flags & 1) !== 0 ? c.string.decode(state) : null,
89
+ message: (flags & 2) !== 0 ? c.string.decode(state) : null,
90
+ timestamp: (flags & 4) !== 0 ? c.uint.decode(state) : 0,
91
+ objects: (flags & 8) !== 0 ? encoding1_6.decode(state) : null
92
+ }
93
+ }
94
+ }
95
+
96
+ // @gip/files
97
+ const encoding2 = {
98
+ preencode(state, m) {
99
+ c.string.preencode(state, m.branch)
100
+ c.string.preencode(state, m.path)
101
+ c.string.preencode(state, m.oid)
102
+ c.string.preencode(state, m.mode)
103
+ c.uint.preencode(state, m.size)
104
+ state.end++ // flags are fixed size
105
+
106
+ if (m.author) c.string.preencode(state, m.author)
107
+ if (m.message) c.string.preencode(state, m.message)
108
+ if (m.timestamp) c.uint.preencode(state, m.timestamp)
109
+ },
110
+ encode(state, m) {
111
+ const flags = (m.author ? 1 : 0) | (m.message ? 2 : 0) | (m.timestamp ? 4 : 0)
112
+
113
+ c.string.encode(state, m.branch)
114
+ c.string.encode(state, m.path)
115
+ c.string.encode(state, m.oid)
116
+ c.string.encode(state, m.mode)
117
+ c.uint.encode(state, m.size)
118
+ c.uint8.encode(state, flags)
119
+
120
+ if (m.author) c.string.encode(state, m.author)
121
+ if (m.message) c.string.encode(state, m.message)
122
+ if (m.timestamp) c.uint.encode(state, m.timestamp)
123
+ },
124
+ decode(state) {
125
+ const r0 = c.string.decode(state)
126
+ const r1 = c.string.decode(state)
127
+ const r2 = c.string.decode(state)
128
+ const r3 = c.string.decode(state)
129
+ const r4 = c.uint.decode(state)
130
+ const flags = c.uint8.decode(state)
131
+
132
+ return {
133
+ branch: r0,
134
+ path: r1,
135
+ oid: r2,
136
+ mode: r3,
137
+ size: r4,
138
+ author: (flags & 1) !== 0 ? c.string.decode(state) : null,
139
+ message: (flags & 2) !== 0 ? c.string.decode(state) : null,
140
+ timestamp: (flags & 4) !== 0 ? c.uint.decode(state) : 0
141
+ }
142
+ }
143
+ }
144
+
145
+ const encoding3_enum = {
146
+ blob: 'blob',
147
+ tree: 'tree',
148
+ commit: 'commit',
149
+ tag: 'tag'
150
+ }
151
+
152
+ // @gip/object-type enum
153
+ const encoding3 = {
154
+ preencode(state, m) {
155
+ state.end++ // max enum is 4 so always one byte
156
+ },
157
+ encode(state, m) {
158
+ switch (m) {
159
+ case 'blob':
160
+ c.uint.encode(state, 1)
161
+ break
162
+ case 'tree':
163
+ c.uint.encode(state, 2)
164
+ break
165
+ case 'commit':
166
+ c.uint.encode(state, 3)
167
+ break
168
+ case 'tag':
169
+ c.uint.encode(state, 4)
170
+ break
171
+ default:
172
+ throw new Error('Unknown enum')
173
+ }
174
+ },
175
+ decode(state) {
176
+ switch (c.uint.decode(state)) {
177
+ case 1:
178
+ return 'blob'
179
+ case 2:
180
+ return 'tree'
181
+ case 3:
182
+ return 'commit'
183
+ case 4:
184
+ return 'tag'
185
+ default:
186
+ return null
187
+ }
188
+ }
189
+ }
190
+
191
+ // @gip/objects
192
+ const encoding4 = {
193
+ preencode(state, m) {
194
+ c.string.preencode(state, m.oid)
195
+ encoding3.preencode(state, m.type)
196
+ c.uint.preencode(state, m.size)
197
+ c.buffer.preencode(state, m.data)
198
+ },
199
+ encode(state, m) {
200
+ c.string.encode(state, m.oid)
201
+ encoding3.encode(state, m.type)
202
+ c.uint.encode(state, m.size)
203
+ c.buffer.encode(state, m.data)
204
+ },
205
+ decode(state) {
206
+ const r0 = c.string.decode(state)
207
+ const r1 = encoding3.decode(state)
208
+ const r2 = c.uint.decode(state)
209
+ const r3 = c.buffer.decode(state)
210
+
211
+ return {
212
+ oid: r0,
213
+ type: r1,
214
+ size: r2,
215
+ data: r3
216
+ }
217
+ }
218
+ }
219
+
220
+ function setVersion(v) {
221
+ version = v
222
+ }
223
+
224
+ function encode(name, value, v = VERSION) {
225
+ version = v
226
+ return c.encode(getEncoding(name), value)
227
+ }
228
+
229
+ function decode(name, buffer, v = VERSION) {
230
+ version = v
231
+ return c.decode(getEncoding(name), buffer)
232
+ }
233
+
234
+ function getEnum(name) {
235
+ switch (name) {
236
+ case '@gip/object-type':
237
+ return encoding3_enum
238
+ default:
239
+ throw new Error('Enum not found ' + name)
240
+ }
241
+ }
242
+
243
+ function getEncoding(name) {
244
+ switch (name) {
245
+ case '@gip/repos':
246
+ return encoding0
247
+ case '@gip/branches':
248
+ return encoding1
249
+ case '@gip/files':
250
+ return encoding2
251
+ case '@gip/object-type':
252
+ return encoding3
253
+ case '@gip/objects':
254
+ return encoding4
255
+ default:
256
+ throw new Error('Encoder not found ' + name)
257
+ }
258
+ }
259
+
260
+ function getStruct(name, v = VERSION) {
261
+ const enc = getEncoding(name)
262
+ return {
263
+ preencode(state, m) {
264
+ version = v
265
+ enc.preencode(state, m)
266
+ },
267
+ encode(state, m) {
268
+ version = v
269
+ enc.encode(state, m)
270
+ },
271
+ decode(state) {
272
+ version = v
273
+ return enc.decode(state)
274
+ }
275
+ }
276
+ }
277
+
278
+ const resolveStruct = getStruct // compat
279
+
280
+ module.exports = {
281
+ resolveStruct,
282
+ getStruct,
283
+ getEnum,
284
+ getEncoding,
285
+ encode,
286
+ decode,
287
+ setVersion,
288
+ version
289
+ }