gip-remote 1.2.1 → 1.2.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.
package/index.js CHANGED
@@ -31,7 +31,8 @@ class Remote extends ReadyResource {
31
31
  config = this._link
32
32
  }
33
33
 
34
- const bee = new Hyperbee(store, config, { autoUpdate: true })
34
+ config.autoUpdate = true
35
+ const bee = new Hyperbee(store, config)
35
36
  this._db = HyperDB.bee2(bee, def, { autoUpdate: true })
36
37
 
37
38
  this._timeout = opts.timeout || 240_000
@@ -67,7 +68,8 @@ class Remote extends ReadyResource {
67
68
  }
68
69
 
69
70
  get url() {
70
- return `git+pear://${z32.encode(this.key)}/${this.name}`
71
+ const head = this._db.db.head()
72
+ return `git+pear://0.${head.length}.${z32.encode(head.key)}/${this.name}`
71
73
  }
72
74
 
73
75
  // --- Objects ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gip-remote",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Git+Pear remote DB for handling git data",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -12,9 +12,7 @@
12
12
  "indexes": [],
13
13
  "schema": "@gip/repos",
14
14
  "derived": false,
15
- "key": [
16
- "name"
17
- ],
15
+ "key": ["name"],
18
16
  "trigger": null
19
17
  },
20
18
  {
@@ -27,9 +25,7 @@
27
25
  "indexes": [],
28
26
  "schema": "@gip/branches",
29
27
  "derived": false,
30
- "key": [
31
- "name"
32
- ],
28
+ "key": ["name"],
33
29
  "trigger": null
34
30
  },
35
31
  {
@@ -39,15 +35,10 @@
39
35
  "type": 1,
40
36
  "version": 1,
41
37
  "versionField": null,
42
- "indexes": [
43
- "@gip/files-by-branch"
44
- ],
38
+ "indexes": ["@gip/files-by-branch"],
45
39
  "schema": "@gip/files",
46
40
  "derived": false,
47
- "key": [
48
- "branch",
49
- "path"
50
- ],
41
+ "key": ["branch", "path"],
51
42
  "trigger": null
52
43
  },
53
44
  {
@@ -60,9 +51,7 @@
60
51
  "indexes": [],
61
52
  "schema": "@gip/objects",
62
53
  "derived": false,
63
- "key": [
64
- "oid"
65
- ],
54
+ "key": ["oid"],
66
55
  "trigger": null
67
56
  },
68
57
  {
@@ -74,9 +63,7 @@
74
63
  "collection": "@gip/files",
75
64
  "unique": false,
76
65
  "deprecated": false,
77
- "key": [
78
- "branch"
79
- ]
66
+ "key": ["branch"]
80
67
  },
81
68
  {
82
69
  "name": "head",
@@ -92,4 +79,4 @@
92
79
  "trigger": null
93
80
  }
94
81
  ]
95
- }
82
+ }
@@ -7,11 +7,9 @@ const { version, getEncoding, setVersion } = require('./messages.js')
7
7
  const versions = { schema: version, db: 2 }
8
8
 
9
9
  // '@gip/repos' collection key
10
- const collection0_key = new IndexEncoder([
11
- IndexEncoder.STRING
12
- ], { prefix: 0 })
10
+ const collection0_key = new IndexEncoder([IndexEncoder.STRING], { prefix: 0 })
13
11
 
14
- function collection0_indexify (record) {
12
+ function collection0_indexify(record) {
15
13
  const a = record.name
16
14
  return a === undefined ? [] : [a]
17
15
  }
@@ -20,7 +18,7 @@ function collection0_indexify (record) {
20
18
  const collection0_enc = getEncoding('@gip/repos/hyperdb#0')
21
19
 
22
20
  // '@gip/repos' reconstruction function
23
- function collection0_reconstruct (schemaVersion, keyBuf, valueBuf) {
21
+ function collection0_reconstruct(schemaVersion, keyBuf, valueBuf) {
24
22
  const key = collection0_key.decode(keyBuf)
25
23
  setVersion(schemaVersion)
26
24
  const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
@@ -32,7 +30,7 @@ function collection0_reconstruct (schemaVersion, keyBuf, valueBuf) {
32
30
  return record
33
31
  }
34
32
  // '@gip/repos' key reconstruction function
35
- function collection0_reconstruct_key (keyBuf) {
33
+ function collection0_reconstruct_key(keyBuf) {
36
34
  const key = collection0_key.decode(keyBuf)
37
35
  return {
38
36
  name: key[0]
@@ -44,11 +42,11 @@ const collection0 = {
44
42
  name: '@gip/repos',
45
43
  id: 0,
46
44
  version: 1,
47
- encodeKey (record) {
45
+ encodeKey(record) {
48
46
  const key = [record.name]
49
47
  return collection0_key.encode(key)
50
48
  },
51
- encodeKeyRange ({ gt, lt, gte, lte } = {}) {
49
+ encodeKeyRange({ gt, lt, gte, lte } = {}) {
52
50
  return collection0_key.encodeRange({
53
51
  gt: gt ? collection0_indexify(gt) : null,
54
52
  lt: lt ? collection0_indexify(lt) : null,
@@ -56,7 +54,7 @@ const collection0 = {
56
54
  lte: lte ? collection0_indexify(lte) : null
57
55
  })
58
56
  },
59
- encodeValue (schemaVersion, collectionVersion, record) {
57
+ encodeValue(schemaVersion, collectionVersion, record) {
60
58
  setVersion(schemaVersion)
61
59
  const state = { start: 0, end: 2, buffer: null }
62
60
  collection0_enc.preencode(state, record)
@@ -74,11 +72,9 @@ const collection0 = {
74
72
  }
75
73
 
76
74
  // '@gip/branches' collection key
77
- const collection1_key = new IndexEncoder([
78
- IndexEncoder.STRING
79
- ], { prefix: 1 })
75
+ const collection1_key = new IndexEncoder([IndexEncoder.STRING], { prefix: 1 })
80
76
 
81
- function collection1_indexify (record) {
77
+ function collection1_indexify(record) {
82
78
  const a = record.name
83
79
  return a === undefined ? [] : [a]
84
80
  }
@@ -87,7 +83,7 @@ function collection1_indexify (record) {
87
83
  const collection1_enc = getEncoding('@gip/branches/hyperdb#1')
88
84
 
89
85
  // '@gip/branches' reconstruction function
90
- function collection1_reconstruct (schemaVersion, keyBuf, valueBuf) {
86
+ function collection1_reconstruct(schemaVersion, keyBuf, valueBuf) {
91
87
  const key = collection1_key.decode(keyBuf)
92
88
  setVersion(schemaVersion)
93
89
  const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
@@ -99,7 +95,7 @@ function collection1_reconstruct (schemaVersion, keyBuf, valueBuf) {
99
95
  return record
100
96
  }
101
97
  // '@gip/branches' key reconstruction function
102
- function collection1_reconstruct_key (keyBuf) {
98
+ function collection1_reconstruct_key(keyBuf) {
103
99
  const key = collection1_key.decode(keyBuf)
104
100
  return {
105
101
  name: key[0]
@@ -111,11 +107,11 @@ const collection1 = {
111
107
  name: '@gip/branches',
112
108
  id: 1,
113
109
  version: 1,
114
- encodeKey (record) {
110
+ encodeKey(record) {
115
111
  const key = [record.name]
116
112
  return collection1_key.encode(key)
117
113
  },
118
- encodeKeyRange ({ gt, lt, gte, lte } = {}) {
114
+ encodeKeyRange({ gt, lt, gte, lte } = {}) {
119
115
  return collection1_key.encodeRange({
120
116
  gt: gt ? collection1_indexify(gt) : null,
121
117
  lt: lt ? collection1_indexify(lt) : null,
@@ -123,7 +119,7 @@ const collection1 = {
123
119
  lte: lte ? collection1_indexify(lte) : null
124
120
  })
125
121
  },
126
- encodeValue (schemaVersion, collectionVersion, record) {
122
+ encodeValue(schemaVersion, collectionVersion, record) {
127
123
  setVersion(schemaVersion)
128
124
  const state = { start: 0, end: 2, buffer: null }
129
125
  collection1_enc.preencode(state, record)
@@ -141,12 +137,9 @@ const collection1 = {
141
137
  }
142
138
 
143
139
  // '@gip/files' collection key
144
- const collection2_key = new IndexEncoder([
145
- IndexEncoder.STRING,
146
- IndexEncoder.STRING
147
- ], { prefix: 2 })
140
+ const collection2_key = new IndexEncoder([IndexEncoder.STRING, IndexEncoder.STRING], { prefix: 2 })
148
141
 
149
- function collection2_indexify (record) {
142
+ function collection2_indexify(record) {
150
143
  const arr = []
151
144
 
152
145
  const a0 = record.branch
@@ -164,7 +157,7 @@ function collection2_indexify (record) {
164
157
  const collection2_enc = getEncoding('@gip/files/hyperdb#2')
165
158
 
166
159
  // '@gip/files' reconstruction function
167
- function collection2_reconstruct (schemaVersion, keyBuf, valueBuf) {
160
+ function collection2_reconstruct(schemaVersion, keyBuf, valueBuf) {
168
161
  const key = collection2_key.decode(keyBuf)
169
162
  setVersion(schemaVersion)
170
163
  const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
@@ -177,7 +170,7 @@ function collection2_reconstruct (schemaVersion, keyBuf, valueBuf) {
177
170
  return record
178
171
  }
179
172
  // '@gip/files' key reconstruction function
180
- function collection2_reconstruct_key (keyBuf) {
173
+ function collection2_reconstruct_key(keyBuf) {
181
174
  const key = collection2_key.decode(keyBuf)
182
175
  return {
183
176
  branch: key[0],
@@ -190,11 +183,11 @@ const collection2 = {
190
183
  name: '@gip/files',
191
184
  id: 2,
192
185
  version: 1,
193
- encodeKey (record) {
186
+ encodeKey(record) {
194
187
  const key = [record.branch, record.path]
195
188
  return collection2_key.encode(key)
196
189
  },
197
- encodeKeyRange ({ gt, lt, gte, lte } = {}) {
190
+ encodeKeyRange({ gt, lt, gte, lte } = {}) {
198
191
  return collection2_key.encodeRange({
199
192
  gt: gt ? collection2_indexify(gt) : null,
200
193
  lt: lt ? collection2_indexify(lt) : null,
@@ -202,7 +195,7 @@ const collection2 = {
202
195
  lte: lte ? collection2_indexify(lte) : null
203
196
  })
204
197
  },
205
- encodeValue (schemaVersion, collectionVersion, record) {
198
+ encodeValue(schemaVersion, collectionVersion, record) {
206
199
  setVersion(schemaVersion)
207
200
  const state = { start: 0, end: 2, buffer: null }
208
201
  collection2_enc.preencode(state, record)
@@ -220,11 +213,9 @@ const collection2 = {
220
213
  }
221
214
 
222
215
  // '@gip/objects' collection key
223
- const collection3_key = new IndexEncoder([
224
- IndexEncoder.STRING
225
- ], { prefix: 3 })
216
+ const collection3_key = new IndexEncoder([IndexEncoder.STRING], { prefix: 3 })
226
217
 
227
- function collection3_indexify (record) {
218
+ function collection3_indexify(record) {
228
219
  const a = record.oid
229
220
  return a === undefined ? [] : [a]
230
221
  }
@@ -233,7 +224,7 @@ function collection3_indexify (record) {
233
224
  const collection3_enc = getEncoding('@gip/objects/hyperdb#3')
234
225
 
235
226
  // '@gip/objects' reconstruction function
236
- function collection3_reconstruct (schemaVersion, keyBuf, valueBuf) {
227
+ function collection3_reconstruct(schemaVersion, keyBuf, valueBuf) {
237
228
  const key = collection3_key.decode(keyBuf)
238
229
  setVersion(schemaVersion)
239
230
  const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
@@ -245,7 +236,7 @@ function collection3_reconstruct (schemaVersion, keyBuf, valueBuf) {
245
236
  return record
246
237
  }
247
238
  // '@gip/objects' key reconstruction function
248
- function collection3_reconstruct_key (keyBuf) {
239
+ function collection3_reconstruct_key(keyBuf) {
249
240
  const key = collection3_key.decode(keyBuf)
250
241
  return {
251
242
  oid: key[0]
@@ -257,11 +248,11 @@ const collection3 = {
257
248
  name: '@gip/objects',
258
249
  id: 3,
259
250
  version: 1,
260
- encodeKey (record) {
251
+ encodeKey(record) {
261
252
  const key = [record.oid]
262
253
  return collection3_key.encode(key)
263
254
  },
264
- encodeKeyRange ({ gt, lt, gte, lte } = {}) {
255
+ encodeKeyRange({ gt, lt, gte, lte } = {}) {
265
256
  return collection3_key.encodeRange({
266
257
  gt: gt ? collection3_indexify(gt) : null,
267
258
  lt: lt ? collection3_indexify(lt) : null,
@@ -269,7 +260,7 @@ const collection3 = {
269
260
  lte: lte ? collection3_indexify(lte) : null
270
261
  })
271
262
  },
272
- encodeValue (schemaVersion, collectionVersion, record) {
263
+ encodeValue(schemaVersion, collectionVersion, record) {
273
264
  setVersion(schemaVersion)
274
265
  const state = { start: 0, end: 2, buffer: null }
275
266
  collection3_enc.preencode(state, record)
@@ -287,13 +278,12 @@ const collection3 = {
287
278
  }
288
279
 
289
280
  // '@gip/files-by-branch' collection key
290
- const index4_key = new IndexEncoder([
291
- IndexEncoder.STRING,
292
- IndexEncoder.STRING,
293
- IndexEncoder.STRING
294
- ], { prefix: 4 })
281
+ const index4_key = new IndexEncoder(
282
+ [IndexEncoder.STRING, IndexEncoder.STRING, IndexEncoder.STRING],
283
+ { prefix: 4 }
284
+ )
295
285
 
296
- function index4_indexify (record) {
286
+ function index4_indexify(record) {
297
287
  const arr = []
298
288
 
299
289
  const a0 = record.branch
@@ -316,10 +306,10 @@ const index4 = {
316
306
  name: '@gip/files-by-branch',
317
307
  version: 1,
318
308
  id: 4,
319
- encodeKey (record) {
309
+ encodeKey(record) {
320
310
  return index4_key.encode(index4_indexify(record))
321
311
  },
322
- encodeKeyRange ({ gt, lt, gte, lte } = {}) {
312
+ encodeKeyRange({ gt, lt, gte, lte } = {}) {
323
313
  return index4_key.encodeRange({
324
314
  gt: gt ? index4_indexify(gt) : null,
325
315
  lt: lt ? index4_indexify(lt) : null,
@@ -328,7 +318,7 @@ const index4 = {
328
318
  })
329
319
  },
330
320
  encodeValue: (record) => index4.collection.encodeKey(record),
331
- encodeIndexKeys (record, context) {
321
+ encodeIndexKeys(record, context) {
332
322
  return [index4_key.encode([record.branch, record.branch, record.path])]
333
323
  },
334
324
  reconstruct: (keyBuf, valueBuf) => valueBuf,
@@ -338,10 +328,9 @@ const index4 = {
338
328
  collection2.indexes.push(index4)
339
329
 
340
330
  // '@gip/head' collection key
341
- const collection5_key = new IndexEncoder([
342
- ], { prefix: 5 })
331
+ const collection5_key = new IndexEncoder([], { prefix: 5 })
343
332
 
344
- function collection5_indexify (record) {
333
+ function collection5_indexify(record) {
345
334
  return []
346
335
  }
347
336
 
@@ -349,7 +338,7 @@ function collection5_indexify (record) {
349
338
  const collection5_enc = getEncoding('@gip/head')
350
339
 
351
340
  // '@gip/head' reconstruction function
352
- function collection5_reconstruct (schemaVersion, keyBuf, valueBuf) {
341
+ function collection5_reconstruct(schemaVersion, keyBuf, valueBuf) {
353
342
  setVersion(schemaVersion)
354
343
  const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
355
344
  const type = c.uint.decode(state)
@@ -359,7 +348,7 @@ function collection5_reconstruct (schemaVersion, keyBuf, valueBuf) {
359
348
  return record
360
349
  }
361
350
  // '@gip/head' key reconstruction function
362
- function collection5_reconstruct_key (keyBuf) {
351
+ function collection5_reconstruct_key(keyBuf) {
363
352
  return {}
364
353
  }
365
354
 
@@ -368,11 +357,11 @@ const collection5 = {
368
357
  name: '@gip/head',
369
358
  id: 5,
370
359
  version: 2,
371
- encodeKey (record) {
360
+ encodeKey(record) {
372
361
  const key = []
373
362
  return collection5_key.encode(key)
374
363
  },
375
- encodeKeyRange ({ gt, lt, gte, lte } = {}) {
364
+ encodeKeyRange({ gt, lt, gte, lte } = {}) {
376
365
  return collection5_key.encodeRange({
377
366
  gt: gt ? collection5_indexify(gt) : null,
378
367
  lt: lt ? collection5_indexify(lt) : null,
@@ -380,7 +369,7 @@ const collection5 = {
380
369
  lte: lte ? collection5_indexify(lte) : null
381
370
  })
382
371
  },
383
- encodeValue (schemaVersion, collectionVersion, record) {
372
+ encodeValue(schemaVersion, collectionVersion, record) {
384
373
  setVersion(schemaVersion)
385
374
  const state = { start: 0, end: 2, buffer: null }
386
375
  collection5_enc.preencode(state, record)
@@ -397,34 +386,34 @@ const collection5 = {
397
386
  decodedVersion: 0
398
387
  }
399
388
 
400
- const collections = [
401
- collection0,
402
- collection1,
403
- collection2,
404
- collection3,
405
- collection5
406
- ]
389
+ const collections = [collection0, collection1, collection2, collection3, collection5]
407
390
 
408
- const indexes = [
409
- index4
410
- ]
391
+ const indexes = [index4]
411
392
 
412
393
  module.exports = { versions, collections, indexes, resolveCollection, resolveIndex }
413
394
 
414
- function resolveCollection (name) {
395
+ function resolveCollection(name) {
415
396
  switch (name) {
416
- case '@gip/repos': return collection0
417
- case '@gip/branches': return collection1
418
- case '@gip/files': return collection2
419
- case '@gip/objects': return collection3
420
- case '@gip/head': return collection5
421
- default: return null
397
+ case '@gip/repos':
398
+ return collection0
399
+ case '@gip/branches':
400
+ return collection1
401
+ case '@gip/files':
402
+ return collection2
403
+ case '@gip/objects':
404
+ return collection3
405
+ case '@gip/head':
406
+ return collection5
407
+ default:
408
+ return null
422
409
  }
423
410
  }
424
411
 
425
- function resolveIndex (name) {
412
+ function resolveIndex(name) {
426
413
  switch (name) {
427
- case '@gip/files-by-branch': return index4
428
- default: return null
414
+ case '@gip/files-by-branch':
415
+ return index4
416
+ default:
417
+ return null
429
418
  }
430
419
  }
@@ -151,10 +151,10 @@ const encoding3_enum = {
151
151
 
152
152
  // @gip/object-type enum
153
153
  const encoding3 = {
154
- preencode (state, m) {
154
+ preencode(state, m) {
155
155
  state.end++ // max enum is 4 so always one byte
156
156
  },
157
- encode (state, m) {
157
+ encode(state, m) {
158
158
  switch (m) {
159
159
  case 'blob':
160
160
  c.uint.encode(state, 1)
@@ -172,7 +172,7 @@ const encoding3 = {
172
172
  throw new Error('Unknown enum')
173
173
  }
174
174
  },
175
- decode (state) {
175
+ decode(state) {
176
176
  switch (c.uint.decode(state)) {
177
177
  case 1:
178
178
  return 'blob'
@@ -182,7 +182,8 @@ const encoding3 = {
182
182
  return 'commit'
183
183
  case 4:
184
184
  return 'tag'
185
- default: return null
185
+ default:
186
+ return null
186
187
  }
187
188
  }
188
189
  }
@@ -151,10 +151,10 @@ const encoding3_enum = {
151
151
 
152
152
  // @gip/object-type enum
153
153
  const encoding3 = {
154
- preencode (state, m) {
154
+ preencode(state, m) {
155
155
  state.end++ // max enum is 4 so always one byte
156
156
  },
157
- encode (state, m) {
157
+ encode(state, m) {
158
158
  switch (m) {
159
159
  case 'blob':
160
160
  c.uint.encode(state, 1)
@@ -172,7 +172,7 @@ const encoding3 = {
172
172
  throw new Error('Unknown enum')
173
173
  }
174
174
  },
175
- decode (state) {
175
+ decode(state) {
176
176
  switch (c.uint.decode(state)) {
177
177
  case 1:
178
178
  return 'blob'
@@ -182,7 +182,8 @@ const encoding3 = {
182
182
  return 'commit'
183
183
  case 4:
184
184
  return 'tag'
185
- default: return null
185
+ default:
186
+ return null
186
187
  }
187
188
  }
188
189
  }