gip-remote 1.2.4 → 1.2.5
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 +23 -2
- package/package.json +1 -1
- package/schema/hyperdb/db.json +8 -23
- package/schema/hyperdb/index.js +72 -85
- package/schema/hyperdb/messages.js +21 -20
- package/schema/hyperschema/index.js +13 -12
package/index.js
CHANGED
|
@@ -182,7 +182,9 @@ class Remote extends ReadyResource {
|
|
|
182
182
|
if (!obj) throw new Error('Object not found: ' + resolvedOid)
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
if (obj.type !== 'commit')
|
|
185
|
+
if (obj.type !== 'commit') {
|
|
186
|
+
throw new Error('Expected commit, got ' + obj.type + ': ' + resolvedOid)
|
|
187
|
+
}
|
|
186
188
|
|
|
187
189
|
const commit = parseCommit(obj.data)
|
|
188
190
|
if (!commit.tree) throw new Error('Commit has no tree: ' + resolvedOid)
|
|
@@ -190,7 +192,26 @@ class Remote extends ReadyResource {
|
|
|
190
192
|
// 3. Walk tree to enumerate files
|
|
191
193
|
const files = walkTree(objects, commit.tree, '')
|
|
192
194
|
|
|
193
|
-
//
|
|
195
|
+
// 4a. Reconcile deletions — remove file records whose paths no longer
|
|
196
|
+
// exist in the new tree. Without this, files removed in a commit
|
|
197
|
+
// would persist in the index forever (only `deleteBranch` cleans
|
|
198
|
+
// them up, and only on full branch deletion). The drive view would
|
|
199
|
+
// keep showing ghost files; consumers iterating @gip/files would
|
|
200
|
+
// emit stale entries.
|
|
201
|
+
//
|
|
202
|
+
// We rebuild the new path set first, then sweep the existing
|
|
203
|
+
// records — O(N) in the size of the indexed tree, same order as
|
|
204
|
+
// the insert step that follows.
|
|
205
|
+
const newPaths = new Set(files.map((f) => f.path))
|
|
206
|
+
const existingFiles = this._db.find('@gip/files', { branch: refName })
|
|
207
|
+
for await (const file of existingFiles) {
|
|
208
|
+
if (!newPaths.has(file.path)) {
|
|
209
|
+
await this._db.delete('@gip/files', { branch: refName, path: file.path })
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// 4b. Insert file records (idempotent w.r.t. (branch, path) — acts as
|
|
214
|
+
// upsert for paths whose blob/mode/metadata changed).
|
|
194
215
|
for (const file of files) {
|
|
195
216
|
await this._db.insert('@gip/files', {
|
|
196
217
|
branch: refName,
|
package/package.json
CHANGED
package/schema/hyperdb/db.json
CHANGED
|
@@ -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",
|
|
@@ -101,10 +88,8 @@
|
|
|
101
88
|
"indexes": [],
|
|
102
89
|
"schema": "@gip/tags",
|
|
103
90
|
"derived": false,
|
|
104
|
-
"key": [
|
|
105
|
-
"name"
|
|
106
|
-
],
|
|
91
|
+
"key": ["name"],
|
|
107
92
|
"trigger": null
|
|
108
93
|
}
|
|
109
94
|
]
|
|
110
|
-
}
|
|
95
|
+
}
|
package/schema/hyperdb/index.js
CHANGED
|
@@ -7,11 +7,9 @@ const { version, getEncoding, setVersion } = require('./messages.js')
|
|
|
7
7
|
const versions = { schema: version, db: 3 }
|
|
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
|
|
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
|
|
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
|
|
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
|
|
45
|
+
encodeKey(record) {
|
|
48
46
|
const key = [record.name]
|
|
49
47
|
return collection0_key.encode(key)
|
|
50
48
|
},
|
|
51
|
-
encodeKeyRange
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
110
|
+
encodeKey(record) {
|
|
115
111
|
const key = [record.name]
|
|
116
112
|
return collection1_key.encode(key)
|
|
117
113
|
},
|
|
118
|
-
encodeKeyRange
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
186
|
+
encodeKey(record) {
|
|
194
187
|
const key = [record.branch, record.path]
|
|
195
188
|
return collection2_key.encode(key)
|
|
196
189
|
},
|
|
197
|
-
encodeKeyRange
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
251
|
+
encodeKey(record) {
|
|
261
252
|
const key = [record.oid]
|
|
262
253
|
return collection3_key.encode(key)
|
|
263
254
|
},
|
|
264
|
-
encodeKeyRange
|
|
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
|
|
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
|
-
|
|
293
|
-
|
|
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
|
|
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
|
|
309
|
+
encodeKey(record) {
|
|
320
310
|
return index4_key.encode(index4_indexify(record))
|
|
321
311
|
},
|
|
322
|
-
encodeKeyRange
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
360
|
+
encodeKey(record) {
|
|
372
361
|
const key = []
|
|
373
362
|
return collection5_key.encode(key)
|
|
374
363
|
},
|
|
375
|
-
encodeKeyRange
|
|
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
|
|
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)
|
|
@@ -398,11 +387,9 @@ const collection5 = {
|
|
|
398
387
|
}
|
|
399
388
|
|
|
400
389
|
// '@gip/tags' collection key
|
|
401
|
-
const collection6_key = new IndexEncoder([
|
|
402
|
-
IndexEncoder.STRING
|
|
403
|
-
], { prefix: 6 })
|
|
390
|
+
const collection6_key = new IndexEncoder([IndexEncoder.STRING], { prefix: 6 })
|
|
404
391
|
|
|
405
|
-
function collection6_indexify
|
|
392
|
+
function collection6_indexify(record) {
|
|
406
393
|
const a = record.name
|
|
407
394
|
return a === undefined ? [] : [a]
|
|
408
395
|
}
|
|
@@ -411,7 +398,7 @@ function collection6_indexify (record) {
|
|
|
411
398
|
const collection6_enc = getEncoding('@gip/tags/hyperdb#6')
|
|
412
399
|
|
|
413
400
|
// '@gip/tags' reconstruction function
|
|
414
|
-
function collection6_reconstruct
|
|
401
|
+
function collection6_reconstruct(schemaVersion, keyBuf, valueBuf) {
|
|
415
402
|
const key = collection6_key.decode(keyBuf)
|
|
416
403
|
setVersion(schemaVersion)
|
|
417
404
|
const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
|
|
@@ -423,7 +410,7 @@ function collection6_reconstruct (schemaVersion, keyBuf, valueBuf) {
|
|
|
423
410
|
return record
|
|
424
411
|
}
|
|
425
412
|
// '@gip/tags' key reconstruction function
|
|
426
|
-
function collection6_reconstruct_key
|
|
413
|
+
function collection6_reconstruct_key(keyBuf) {
|
|
427
414
|
const key = collection6_key.decode(keyBuf)
|
|
428
415
|
return {
|
|
429
416
|
name: key[0]
|
|
@@ -435,11 +422,11 @@ const collection6 = {
|
|
|
435
422
|
name: '@gip/tags',
|
|
436
423
|
id: 6,
|
|
437
424
|
version: 3,
|
|
438
|
-
encodeKey
|
|
425
|
+
encodeKey(record) {
|
|
439
426
|
const key = [record.name]
|
|
440
427
|
return collection6_key.encode(key)
|
|
441
428
|
},
|
|
442
|
-
encodeKeyRange
|
|
429
|
+
encodeKeyRange({ gt, lt, gte, lte } = {}) {
|
|
443
430
|
return collection6_key.encodeRange({
|
|
444
431
|
gt: gt ? collection6_indexify(gt) : null,
|
|
445
432
|
lt: lt ? collection6_indexify(lt) : null,
|
|
@@ -447,7 +434,7 @@ const collection6 = {
|
|
|
447
434
|
lte: lte ? collection6_indexify(lte) : null
|
|
448
435
|
})
|
|
449
436
|
},
|
|
450
|
-
encodeValue
|
|
437
|
+
encodeValue(schemaVersion, collectionVersion, record) {
|
|
451
438
|
setVersion(schemaVersion)
|
|
452
439
|
const state = { start: 0, end: 2, buffer: null }
|
|
453
440
|
collection6_enc.preencode(state, record)
|
|
@@ -464,36 +451,36 @@ const collection6 = {
|
|
|
464
451
|
decodedVersion: 0
|
|
465
452
|
}
|
|
466
453
|
|
|
467
|
-
const collections = [
|
|
468
|
-
collection0,
|
|
469
|
-
collection1,
|
|
470
|
-
collection2,
|
|
471
|
-
collection3,
|
|
472
|
-
collection5,
|
|
473
|
-
collection6
|
|
474
|
-
]
|
|
454
|
+
const collections = [collection0, collection1, collection2, collection3, collection5, collection6]
|
|
475
455
|
|
|
476
|
-
const indexes = [
|
|
477
|
-
index4
|
|
478
|
-
]
|
|
456
|
+
const indexes = [index4]
|
|
479
457
|
|
|
480
458
|
module.exports = { versions, collections, indexes, resolveCollection, resolveIndex }
|
|
481
459
|
|
|
482
|
-
function resolveCollection
|
|
460
|
+
function resolveCollection(name) {
|
|
483
461
|
switch (name) {
|
|
484
|
-
case '@gip/repos':
|
|
485
|
-
|
|
486
|
-
case '@gip/
|
|
487
|
-
|
|
488
|
-
case '@gip/
|
|
489
|
-
|
|
490
|
-
|
|
462
|
+
case '@gip/repos':
|
|
463
|
+
return collection0
|
|
464
|
+
case '@gip/branches':
|
|
465
|
+
return collection1
|
|
466
|
+
case '@gip/files':
|
|
467
|
+
return collection2
|
|
468
|
+
case '@gip/objects':
|
|
469
|
+
return collection3
|
|
470
|
+
case '@gip/head':
|
|
471
|
+
return collection5
|
|
472
|
+
case '@gip/tags':
|
|
473
|
+
return collection6
|
|
474
|
+
default:
|
|
475
|
+
return null
|
|
491
476
|
}
|
|
492
477
|
}
|
|
493
478
|
|
|
494
|
-
function resolveIndex
|
|
479
|
+
function resolveIndex(name) {
|
|
495
480
|
switch (name) {
|
|
496
|
-
case '@gip/files-by-branch':
|
|
497
|
-
|
|
481
|
+
case '@gip/files-by-branch':
|
|
482
|
+
return index4
|
|
483
|
+
default:
|
|
484
|
+
return null
|
|
498
485
|
}
|
|
499
486
|
}
|
|
@@ -151,10 +151,10 @@ const encoding3_enum = {
|
|
|
151
151
|
|
|
152
152
|
// @gip/object-type enum
|
|
153
153
|
const encoding3 = {
|
|
154
|
-
preencode
|
|
154
|
+
preencode(state, m) {
|
|
155
155
|
state.end++ // max enum is 4 so always one byte
|
|
156
156
|
},
|
|
157
|
-
encode
|
|
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
|
|
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:
|
|
185
|
+
default:
|
|
186
|
+
return null
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
189
|
}
|
|
@@ -252,10 +253,10 @@ const encoding6 = {
|
|
|
252
253
|
},
|
|
253
254
|
encode(state, m) {
|
|
254
255
|
const flags =
|
|
255
|
-
(
|
|
256
|
-
(
|
|
257
|
-
(
|
|
258
|
-
(
|
|
256
|
+
(version >= 3 && m.tagger ? 1 : 0) |
|
|
257
|
+
(version >= 3 && m.message ? 2 : 0) |
|
|
258
|
+
(version >= 3 && m.timestamp ? 4 : 0) |
|
|
259
|
+
(version >= 3 && m.objects ? 8 : 0)
|
|
259
260
|
|
|
260
261
|
c.string.encode(state, m.name)
|
|
261
262
|
c.string.encode(state, m.oid)
|
|
@@ -280,10 +281,10 @@ const encoding6 = {
|
|
|
280
281
|
oid: r1,
|
|
281
282
|
commitOid: r2,
|
|
282
283
|
treeOid: r3,
|
|
283
|
-
tagger:
|
|
284
|
-
message:
|
|
285
|
-
timestamp:
|
|
286
|
-
objects:
|
|
284
|
+
tagger: version >= 3 && (flags & 1) !== 0 ? c.string.decode(state) : null,
|
|
285
|
+
message: version >= 3 && (flags & 2) !== 0 ? c.string.decode(state) : null,
|
|
286
|
+
timestamp: version >= 3 && (flags & 4) !== 0 ? c.uint.decode(state) : 0,
|
|
287
|
+
objects: version >= 3 && (flags & 8) !== 0 ? encoding6_7.decode(state) : null
|
|
287
288
|
}
|
|
288
289
|
}
|
|
289
290
|
}
|
|
@@ -451,10 +452,10 @@ const encoding11 = {
|
|
|
451
452
|
},
|
|
452
453
|
encode(state, m) {
|
|
453
454
|
const flags =
|
|
454
|
-
(
|
|
455
|
-
(
|
|
456
|
-
(
|
|
457
|
-
(
|
|
455
|
+
(version >= 3 && m.tagger ? 1 : 0) |
|
|
456
|
+
(version >= 3 && m.message ? 2 : 0) |
|
|
457
|
+
(version >= 3 && m.timestamp ? 4 : 0) |
|
|
458
|
+
(version >= 3 && m.objects ? 8 : 0)
|
|
458
459
|
|
|
459
460
|
c.string.encode(state, m.oid)
|
|
460
461
|
c.string.encode(state, m.commitOid)
|
|
@@ -477,10 +478,10 @@ const encoding11 = {
|
|
|
477
478
|
oid: r1,
|
|
478
479
|
commitOid: r2,
|
|
479
480
|
treeOid: r3,
|
|
480
|
-
tagger:
|
|
481
|
-
message:
|
|
482
|
-
timestamp:
|
|
483
|
-
objects:
|
|
481
|
+
tagger: version >= 3 && (flags & 1) !== 0 ? c.string.decode(state) : null,
|
|
482
|
+
message: version >= 3 && (flags & 2) !== 0 ? c.string.decode(state) : null,
|
|
483
|
+
timestamp: version >= 3 && (flags & 4) !== 0 ? c.uint.decode(state) : 0,
|
|
484
|
+
objects: version >= 3 && (flags & 8) !== 0 ? encoding11_7.decode(state) : null
|
|
484
485
|
}
|
|
485
486
|
}
|
|
486
487
|
}
|
|
@@ -151,10 +151,10 @@ const encoding3_enum = {
|
|
|
151
151
|
|
|
152
152
|
// @gip/object-type enum
|
|
153
153
|
const encoding3 = {
|
|
154
|
-
preencode
|
|
154
|
+
preencode(state, m) {
|
|
155
155
|
state.end++ // max enum is 4 so always one byte
|
|
156
156
|
},
|
|
157
|
-
encode
|
|
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
|
|
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:
|
|
185
|
+
default:
|
|
186
|
+
return null
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
189
|
}
|
|
@@ -252,10 +253,10 @@ const encoding6 = {
|
|
|
252
253
|
},
|
|
253
254
|
encode(state, m) {
|
|
254
255
|
const flags =
|
|
255
|
-
(
|
|
256
|
-
(
|
|
257
|
-
(
|
|
258
|
-
(
|
|
256
|
+
(version >= 3 && m.tagger ? 1 : 0) |
|
|
257
|
+
(version >= 3 && m.message ? 2 : 0) |
|
|
258
|
+
(version >= 3 && m.timestamp ? 4 : 0) |
|
|
259
|
+
(version >= 3 && m.objects ? 8 : 0)
|
|
259
260
|
|
|
260
261
|
c.string.encode(state, m.name)
|
|
261
262
|
c.string.encode(state, m.oid)
|
|
@@ -280,10 +281,10 @@ const encoding6 = {
|
|
|
280
281
|
oid: r1,
|
|
281
282
|
commitOid: r2,
|
|
282
283
|
treeOid: r3,
|
|
283
|
-
tagger:
|
|
284
|
-
message:
|
|
285
|
-
timestamp:
|
|
286
|
-
objects:
|
|
284
|
+
tagger: version >= 3 && (flags & 1) !== 0 ? c.string.decode(state) : null,
|
|
285
|
+
message: version >= 3 && (flags & 2) !== 0 ? c.string.decode(state) : null,
|
|
286
|
+
timestamp: version >= 3 && (flags & 4) !== 0 ? c.uint.decode(state) : 0,
|
|
287
|
+
objects: version >= 3 && (flags & 8) !== 0 ? encoding6_7.decode(state) : null
|
|
287
288
|
}
|
|
288
289
|
}
|
|
289
290
|
}
|