gip-remote 1.2.1 → 1.2.3
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.d.ts +47 -7
- package/index.js +4 -2
- package/lib/drive.js +19 -10
- package/package.json +1 -1
- package/schema/hyperdb/db.json +7 -20
- package/schema/hyperdb/index.js +63 -74
- package/schema/hyperdb/messages.js +5 -4
- package/schema/hyperschema/index.js +5 -4
package/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Readable } from 'streamx'
|
|
2
2
|
|
|
3
3
|
interface RemoteOpts {
|
|
4
|
-
name?: string
|
|
5
|
-
store: any
|
|
6
|
-
swarm: any
|
|
7
|
-
key?: Buffer
|
|
8
4
|
timeout?: number
|
|
9
|
-
blind?:
|
|
5
|
+
blind?: any
|
|
10
6
|
}
|
|
11
7
|
|
|
8
|
+
type RemoteLink =
|
|
9
|
+
| string
|
|
10
|
+
| { name: string; key?: Buffer }
|
|
11
|
+
| { drive: { key: Buffer }; pathname?: string }
|
|
12
|
+
|
|
12
13
|
interface GitObject {
|
|
13
14
|
oid: string
|
|
14
15
|
type: string
|
|
@@ -19,6 +20,7 @@ interface GitObject {
|
|
|
19
20
|
interface Ref {
|
|
20
21
|
ref: string
|
|
21
22
|
oid: string
|
|
23
|
+
symref?: string
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
interface RefObject extends GitObject {
|
|
@@ -26,13 +28,14 @@ interface RefObject extends GitObject {
|
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
declare class Remote {
|
|
29
|
-
constructor(
|
|
31
|
+
constructor(store: any, link: RemoteLink, opts?: RemoteOpts)
|
|
30
32
|
|
|
31
33
|
readonly name: string
|
|
32
34
|
readonly core: any
|
|
33
35
|
readonly key: Buffer
|
|
34
36
|
readonly discoveryKey: Buffer
|
|
35
37
|
readonly availablePeers: number
|
|
38
|
+
readonly url: string
|
|
36
39
|
|
|
37
40
|
ready(): Promise<void>
|
|
38
41
|
close(): Promise<void>
|
|
@@ -42,11 +45,20 @@ declare class Remote {
|
|
|
42
45
|
commitOid: string,
|
|
43
46
|
objects: Map<string, { type: string; size: number; data: Buffer }>
|
|
44
47
|
): Promise<void>
|
|
48
|
+
|
|
49
|
+
getHead(): Promise<string | null>
|
|
50
|
+
setHead(branch: string): Promise<void>
|
|
51
|
+
|
|
45
52
|
getAllRefs(): Promise<Ref[]>
|
|
46
53
|
getBranchRef(branch: string): Promise<Ref | null>
|
|
54
|
+
deleteBranch(branchName: string): Promise<boolean>
|
|
55
|
+
|
|
47
56
|
getObject(oid: string): Promise<GitObject | null>
|
|
48
57
|
getRefObjects(commitOid: string, onLoad?: (size: number) => void): Promise<RefObject[]>
|
|
58
|
+
|
|
49
59
|
toDrive(branch: string): Promise<RemoteDrive | null>
|
|
60
|
+
|
|
61
|
+
update(): Promise<void>
|
|
50
62
|
waitForPeers(): Promise<void>
|
|
51
63
|
}
|
|
52
64
|
|
|
@@ -73,6 +85,22 @@ declare class RemoteDrive {
|
|
|
73
85
|
mirror(out: any, opts?: any): any
|
|
74
86
|
}
|
|
75
87
|
|
|
88
|
+
interface ParsedGitPearLink {
|
|
89
|
+
protocol: string
|
|
90
|
+
origin: string
|
|
91
|
+
pathname?: string
|
|
92
|
+
drive: {
|
|
93
|
+
key: Buffer
|
|
94
|
+
length: number
|
|
95
|
+
fork?: number | null
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
declare const GitPearLink: {
|
|
100
|
+
parse(link: string): ParsedGitPearLink
|
|
101
|
+
serialize(o: ParsedGitPearLink): string
|
|
102
|
+
}
|
|
103
|
+
|
|
76
104
|
interface ToDiskOpts {
|
|
77
105
|
gitDir: string
|
|
78
106
|
objects: Array<{ type: string; id: string; size: number; data: Buffer }>
|
|
@@ -107,4 +135,16 @@ declare function walkTree(
|
|
|
107
135
|
prefix: string
|
|
108
136
|
): FileEntry[]
|
|
109
137
|
|
|
110
|
-
export { Remote, RemoteDrive, toDisk, parseCommit, walkTree }
|
|
138
|
+
export { Remote, RemoteDrive, GitPearLink, toDisk, parseCommit, walkTree }
|
|
139
|
+
export type {
|
|
140
|
+
RemoteOpts,
|
|
141
|
+
RemoteLink,
|
|
142
|
+
GitObject,
|
|
143
|
+
Ref,
|
|
144
|
+
RefObject,
|
|
145
|
+
DriveEntry,
|
|
146
|
+
ParsedGitPearLink,
|
|
147
|
+
ToDiskOpts,
|
|
148
|
+
Commit,
|
|
149
|
+
FileEntry
|
|
150
|
+
}
|
package/index.js
CHANGED
|
@@ -31,7 +31,8 @@ class Remote extends ReadyResource {
|
|
|
31
31
|
config = this._link
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
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
|
-
|
|
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/lib/drive.js
CHANGED
|
@@ -26,15 +26,7 @@ class RemoteDrive extends ReadyResource {
|
|
|
26
26
|
})
|
|
27
27
|
if (!record) return null
|
|
28
28
|
|
|
29
|
-
return
|
|
30
|
-
key,
|
|
31
|
-
value: {
|
|
32
|
-
executable: record.mode === '100755',
|
|
33
|
-
linkname: null,
|
|
34
|
-
blob: { byteLength: record.size },
|
|
35
|
-
metadata: null
|
|
36
|
-
}
|
|
37
|
-
}
|
|
29
|
+
return toEntry(key, record)
|
|
38
30
|
}
|
|
39
31
|
|
|
40
32
|
async get(nameOrEntry) {
|
|
@@ -89,7 +81,7 @@ class RemoteDrive extends ReadyResource {
|
|
|
89
81
|
try {
|
|
90
82
|
for await (const record of stream) {
|
|
91
83
|
if (ignore && ignore(record.path)) continue
|
|
92
|
-
this.push(record.path)
|
|
84
|
+
this.push(toEntry(record.path, record))
|
|
93
85
|
}
|
|
94
86
|
this.push(null)
|
|
95
87
|
cb(null)
|
|
@@ -130,4 +122,21 @@ class RemoteDrive extends ReadyResource {
|
|
|
130
122
|
}
|
|
131
123
|
}
|
|
132
124
|
|
|
125
|
+
function toEntry(key, record) {
|
|
126
|
+
return {
|
|
127
|
+
key,
|
|
128
|
+
value: {
|
|
129
|
+
executable: record.mode === '100755',
|
|
130
|
+
linkname: null,
|
|
131
|
+
blob: {
|
|
132
|
+
blockOffset: 0,
|
|
133
|
+
blockLength: 0,
|
|
134
|
+
byteOffset: 0,
|
|
135
|
+
byteLength: record.size
|
|
136
|
+
},
|
|
137
|
+
metadata: null
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
133
142
|
module.exports = RemoteDrive
|
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",
|
|
@@ -92,4 +79,4 @@
|
|
|
92
79
|
"trigger": null
|
|
93
80
|
}
|
|
94
81
|
]
|
|
95
|
-
}
|
|
82
|
+
}
|
package/schema/hyperdb/index.js
CHANGED
|
@@ -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
|
|
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)
|
|
@@ -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
|
|
395
|
+
function resolveCollection(name) {
|
|
415
396
|
switch (name) {
|
|
416
|
-
case '@gip/repos':
|
|
417
|
-
|
|
418
|
-
case '@gip/
|
|
419
|
-
|
|
420
|
-
case '@gip/
|
|
421
|
-
|
|
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
|
|
412
|
+
function resolveIndex(name) {
|
|
426
413
|
switch (name) {
|
|
427
|
-
case '@gip/files-by-branch':
|
|
428
|
-
|
|
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
|
|
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
|
}
|
|
@@ -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
|
}
|