rqlite-js 2.5.7 → 2.6.0
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/README.md +174 -155
- package/lib/api/backup/index.js +46 -46
- package/lib/api/backup/index.js.map +1 -1
- package/lib/api/backup/test.unit.js +45 -0
- package/lib/api/backup/test.unit.js.map +1 -0
- package/lib/api/backup-formats.js +16 -0
- package/lib/api/backup-formats.js.map +1 -0
- package/lib/api/client/index.js +63 -42
- package/lib/api/client/index.js.map +1 -1
- package/lib/api/client/test.unit.js +53 -0
- package/lib/api/client/test.unit.js.map +1 -0
- package/lib/api/consistency-levels.js +30 -0
- package/lib/api/consistency-levels.js.map +1 -0
- package/lib/api/data/index.js +50 -72
- package/lib/api/data/index.js.map +1 -1
- package/lib/api/data/test.unit.js +98 -0
- package/lib/api/data/test.unit.js.map +1 -0
- package/lib/api/paths.js +33 -0
- package/lib/api/paths.js.map +1 -0
- package/lib/api/query-params.js +43 -0
- package/lib/api/query-params.js.map +1 -0
- package/lib/api/results/data-result-error.js +39 -10
- package/lib/api/results/data-result-error.js.map +1 -1
- package/lib/api/results/data-result.js +57 -51
- package/lib/api/results/data-result.js.map +1 -1
- package/lib/api/results/data-results.js +50 -30
- package/lib/api/results/data-results.js.map +1 -1
- package/lib/api/results/index.js +1 -1
- package/lib/api/results/result-fields.js +47 -0
- package/lib/api/results/result-fields.js.map +1 -0
- package/lib/api/results/test.unit.js +238 -0
- package/lib/api/results/test.unit.js.map +1 -0
- package/lib/api/status/index.js +40 -28
- package/lib/api/status/index.js.map +1 -1
- package/lib/api/status/test.unit.js +57 -0
- package/lib/api/status/test.unit.js.map +1 -0
- package/lib/http-request/auth-keys.js +15 -0
- package/lib/http-request/auth-keys.js.map +1 -0
- package/lib/http-request/http-headers.js +20 -0
- package/lib/http-request/http-headers.js.map +1 -0
- package/lib/http-request/index.js +291 -271
- package/lib/http-request/index.js.map +1 -1
- package/lib/http-request/test.unit.js +560 -0
- package/lib/http-request/test.unit.js.map +1 -0
- package/lib/index.js +23 -4
- package/lib/index.js.map +1 -1
- package/lib/test/api-data-execute-nock.js +142 -0
- package/lib/test/api-data-execute-nock.js.map +1 -0
- package/lib/test/api-data-query-nock.js +210 -0
- package/lib/test/api-data-query-nock.js.map +1 -0
- package/lib/test/backups/backup-nock.js +29 -0
- package/lib/test/backups/backup-nock.js.map +1 -0
- package/lib/test/backups/restore-nock.js +30 -0
- package/lib/test/backups/restore-nock.js.map +1 -0
- package/lib/test/env.js +15 -0
- package/lib/test/env.js.map +1 -0
- package/lib/test/unit/index.unit.js +27 -0
- package/lib/test/unit/index.unit.js.map +1 -0
- package/lib/test.integration.js +238 -0
- package/lib/test.integration.js.map +1 -0
- package/package.json +33 -23
- package/.eslintrc +0 -20
- package/.travis.yml +0 -24
- package/es6/api/backup/index.js +0 -71
- package/es6/api/client/index.js +0 -83
- package/es6/api/data/index.js +0 -129
- package/es6/api/results/data-result-error.js +0 -32
- package/es6/api/results/data-result.js +0 -134
- package/es6/api/results/data-results.js +0 -121
- package/es6/api/results/index.js +0 -7
- package/es6/api/status/index.js +0 -54
- package/es6/http-request/content-types.js +0 -4
- package/es6/http-request/errors.js +0 -16
- package/es6/http-request/http-methods.js +0 -39
- package/es6/http-request/index.js +0 -743
- package/es6/http-request/retryable.js +0 -41
- package/es6/index.js +0 -19
- package/jsconfig.json +0 -19
package/README.md
CHANGED
|
@@ -1,215 +1,234 @@
|
|
|
1
|
-
# rqlite-js
|
|
2
|
-
|
|
1
|
+
# rqlite-js · [](https://www.npmjs.com/package/rqlite-js) · [](https://github.com/rqlite/rqlite-js/actions/workflows/ci.yml)
|
|
2
|
+
|
|
3
|
+
A promise-based client library for [rqlite](https://rqlite.io), the lightweight, distributed database built on SQLite. Clients mirror the HTTP API endpoints (`/db/query`, `/db/execute`, `/db/backup`, `/status`). This package does not generate SQL—use your own SQL strings or another SQL builder.
|
|
4
|
+
|
|
5
|
+
**Requirements:** Node.js `>= 18`. CI tests Node 18–24 on `ubuntu-latest`; Docker integrations use Node 24. Tested against **rqlite 10.x** (Docker image `rqlite/rqlite:10.6.6`).
|
|
6
|
+
|
|
7
|
+
See the official docs:
|
|
8
|
+
|
|
9
|
+
- [Accessing rqlite (HTTP API)](https://rqlite.io/docs/api/api/)
|
|
10
|
+
- [Read consistency](https://rqlite.io/docs/api/read-consistency/)
|
|
11
|
+
- [Backup and restore](https://rqlite.io/docs/guides/backup/)
|
|
12
|
+
- [Monitoring / status](https://rqlite.io/docs/guides/monitoring-rqlite/)
|
|
3
13
|
|
|
4
14
|
## Features
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
15
|
+
|
|
16
|
+
- Follow 301/302 redirects from followers to the leader
|
|
17
|
+
- Round-robin host balancing for non-leader reads
|
|
18
|
+
- HTTP keepalive via `http` / `https` agents
|
|
19
|
+
- Unit and Docker integration tests
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install rqlite-js
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick start
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
import { DataApiClient } from 'rqlite-js'
|
|
31
|
+
|
|
32
|
+
const dataApiClient = new DataApiClient('http://localhost:4001')
|
|
33
|
+
|
|
34
|
+
await dataApiClient.execute('CREATE TABLE IF NOT EXISTS foo (id INTEGER NOT NULL PRIMARY KEY, name TEXT)')
|
|
35
|
+
const insert = await dataApiClient.execute('INSERT INTO foo(name) VALUES("fiona")')
|
|
36
|
+
if (insert.hasError()) {
|
|
37
|
+
throw insert.getFirstError()
|
|
38
|
+
}
|
|
39
|
+
const id = insert.get(0).getLastInsertId()
|
|
40
|
+
const select = await dataApiClient.query(`SELECT id, name FROM foo WHERE id=${id}`)
|
|
41
|
+
console.log(select.get(0).toObject()) // { id: 1, name: 'fiona' }
|
|
42
|
+
```
|
|
9
43
|
|
|
10
44
|
## DataApiClient
|
|
11
|
-
The data API client will allow you to access the [data API endpoints](https://github.com/rqlite/rqlite/blob/master/DOC/DATA_API.md) of RQLite such as `query` and `execute`. All data methods will return a DataResults instance which is an array of DataResult instances. The DataResult instances are designed to abstract working with the response body from RQLite data endpoints. If you want to work with the raw HTTP response instead of using the DataResults the options accept a raw options which can be set to true. This is covered in the examples below.
|
|
12
45
|
|
|
13
|
-
|
|
14
|
-
The follow methods are available on the DataApiClient including their method signatures. Both the query and execute methods return a DataResults instance which provides methods for handling the RQLite response body states. In the case of a query there will only ever be one result in the DataResults.
|
|
46
|
+
Access the [data API](https://rqlite.io/docs/api/api/) (`query` / `execute`). By default methods return a `DataResults` instance. Pass `{ raw: true }` to get `{ status, body }` instead.
|
|
15
47
|
|
|
16
|
-
|
|
17
|
-
* DataApiClient.execute(sql, options) - Multiple SQL statments
|
|
48
|
+
### Methods
|
|
18
49
|
|
|
19
|
-
|
|
50
|
+
- `query(sql, options)` — read via HTTP GET (or POST when `sql` is an array)
|
|
51
|
+
- `execute(sql, options)` — write via HTTP POST (`sql` may be a string or string array)
|
|
20
52
|
|
|
21
|
-
###
|
|
22
|
-
The code sample shows how you would connect to a rqlite server and create a table.
|
|
53
|
+
### Create table
|
|
23
54
|
|
|
24
55
|
```javascript
|
|
25
56
|
import { DataApiClient } from 'rqlite-js'
|
|
26
57
|
|
|
27
58
|
const dataApiClient = new DataApiClient('http://localhost:4001')
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const error = dataResults.getFirstError()
|
|
36
|
-
console.error(error, 'rqlite create tables results contained an error.')
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
// We are successful and have results to use from our SQL query.
|
|
40
|
-
console.log(dataResults.toString(), 'Checkout the rqlite results as a JSON string.')
|
|
41
|
-
console.log(dataResults.toArray(), 'Checkout the rqlite results as plain javascript array for app use.')
|
|
42
|
-
console.log(dataResults.get(0).toString(), 'Checkout just the first rqlite result as a JSON string.')
|
|
43
|
-
|
|
44
|
-
// Lets get the same query as a raw HTTP response
|
|
45
|
-
const { statusCode, body } = await dataApiClient.execute(sql, { raw: true })
|
|
46
|
-
console.log(body, 'HTTP reponse body.')
|
|
47
|
-
console.log(statusCode, 'HTTP response code.')
|
|
48
|
-
} catch (e) {
|
|
49
|
-
console.error(e, 'The HTTP client got an HTTP error, there must be something else going on.')
|
|
59
|
+
const dataResults = await dataApiClient.execute(
|
|
60
|
+
'CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name TEXT)',
|
|
61
|
+
)
|
|
62
|
+
if (dataResults.hasError()) {
|
|
63
|
+
console.error(dataResults.getFirstError())
|
|
64
|
+
} else {
|
|
65
|
+
console.log(dataResults.toArray())
|
|
50
66
|
}
|
|
67
|
+
|
|
68
|
+
// Raw HTTP response shape from this client:
|
|
69
|
+
const { status, body } = await dataApiClient.execute(
|
|
70
|
+
'CREATE TABLE IF NOT EXISTS bar (id INTEGER NOT NULL PRIMARY KEY)',
|
|
71
|
+
{ raw: true },
|
|
72
|
+
)
|
|
73
|
+
console.log(status, body)
|
|
51
74
|
```
|
|
52
75
|
|
|
53
|
-
###
|
|
54
|
-
The code sample shows how would connect to a rqlite server insert a row then select the row.
|
|
76
|
+
### Insert, select, update
|
|
55
77
|
|
|
56
78
|
```javascript
|
|
57
79
|
import { DataApiClient } from 'rqlite-js'
|
|
58
80
|
|
|
59
81
|
const dataApiClient = new DataApiClient('http://localhost:4001')
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
let dataResults = await dataApiClient.execute('INSERT INTO foo(name) VALUES(\"fiona\")')
|
|
65
|
-
if (dataResults.hasError()) {
|
|
66
|
-
const error = dataResults.getFirstError()
|
|
67
|
-
console.error(error, 'rqlite insert results contained an error.')
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
const id = dataResults.get(0).getLastInsertId()
|
|
71
|
-
console.log(id, 'The id of the inserted row')
|
|
72
|
-
dataResults = await dataApiClient.query(`SELECT name FROM foo WHERE id="${id}"`)
|
|
73
|
-
if (dataResults.hasError()) {
|
|
74
|
-
const error = dataResults.getFirstError()
|
|
75
|
-
console.error(error, 'rqlite select results contained an error.')
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
console.log(dataResults.get(0).get('name'), 'The value for the name field which should equal fiona')
|
|
79
|
-
console.log(dataResults.get(0).toObject(), 'rqlitejs results are great, but I just want to work with a plain js object maybe to send back in my api')
|
|
80
|
-
console.log(dataResults.get(0).get('id'), 'This is just the id of the first result.')
|
|
81
|
-
dataResults = await dataApiClient.execute(`UPDATE foo SET name="justin" WHERE name="fiona"`)
|
|
82
|
-
if (dataResults.hasError()) {
|
|
83
|
-
const error = dataResults.getFirstError()
|
|
84
|
-
console.error(error, 'rqlite select results contained an error.')
|
|
85
|
-
return
|
|
86
|
-
}
|
|
87
|
-
const rowsAffected = dataResults.get(0).getRowsAffected()
|
|
88
|
-
console.log(rowsAffected, 'The number of rows updated for each update query which should be 1 for the first row')
|
|
89
|
-
dataResults = await dataApiClient.query(`SELECT name FROM foo WHERE id="${id}"`)
|
|
90
|
-
if (dataResults.hasError()) {
|
|
91
|
-
const error = dataResults.getFirstError()
|
|
92
|
-
console.error(error, 'rqlite select results contained an error.')
|
|
93
|
-
return
|
|
94
|
-
}
|
|
95
|
-
console.log(dataResults.get(0).get('name'), 'The value for the name field which should now equal justin')
|
|
96
|
-
} catch (e) {
|
|
97
|
-
console.error(e, 'The HTTP client got an HTTP error, there must be something else going on.')
|
|
82
|
+
|
|
83
|
+
let dataResults = await dataApiClient.execute('INSERT INTO foo(name) VALUES("fiona")')
|
|
84
|
+
if (dataResults.hasError()) {
|
|
85
|
+
throw dataResults.getFirstError()
|
|
98
86
|
}
|
|
87
|
+
const id = dataResults.get(0).getLastInsertId()
|
|
88
|
+
|
|
89
|
+
dataResults = await dataApiClient.query(`SELECT id, name FROM foo WHERE id=${id}`)
|
|
90
|
+
console.log(dataResults.get(0).get('name')) // fiona
|
|
91
|
+
console.log(dataResults.get(0).toObject()) // { id: 1, name: 'fiona' }
|
|
92
|
+
|
|
93
|
+
dataResults = await dataApiClient.execute('UPDATE foo SET name="justin" WHERE name="fiona"')
|
|
94
|
+
console.log(dataResults.get(0).getRowsAffected()) // 1
|
|
99
95
|
```
|
|
100
96
|
|
|
101
|
-
###
|
|
102
|
-
|
|
97
|
+
### Transactions (rqlite v5+)
|
|
98
|
+
|
|
99
|
+
Use `{ atomic: true }` for a single transaction ([API docs](https://rqlite.io/docs/api/api/)). Legacy `{ transaction: true }` remains for older rqlite v4 servers.
|
|
103
100
|
|
|
104
101
|
```javascript
|
|
105
102
|
import { DataApiClient } from 'rqlite-js'
|
|
106
103
|
|
|
107
104
|
const dataApiClient = new DataApiClient('http://localhost:4001')
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
]
|
|
116
|
-
const dataResults = await dataApiClient.execute(sql, { transaction: true })
|
|
117
|
-
if (dataResults.hasError()) {
|
|
118
|
-
const error = dataResults.getFirstError()
|
|
119
|
-
console.error(error, 'rqlite insert results contained an error.')
|
|
120
|
-
return
|
|
121
|
-
}
|
|
122
|
-
console.log(dataResults.get(0).getLastInsertId(), 'The id for the first insert is in index 0 last_insert_id')
|
|
123
|
-
console.log(dataResults.get(1).getLastInsertId(), 'The id for the second insert is in index 1 last_insert_id')
|
|
124
|
-
} catch (e) {
|
|
125
|
-
console.error(e, 'The HTTP client got an HTTP error, there must be something else going on.')
|
|
105
|
+
const sql = [
|
|
106
|
+
'INSERT INTO foo(name) VALUES("fiona")',
|
|
107
|
+
'INSERT INTO foo(name) VALUES("justin")',
|
|
108
|
+
]
|
|
109
|
+
const dataResults = await dataApiClient.execute(sql, { atomic: true })
|
|
110
|
+
if (dataResults.hasError()) {
|
|
111
|
+
throw dataResults.getFirstError()
|
|
126
112
|
}
|
|
113
|
+
console.log(dataResults.get(0).getLastInsertId())
|
|
114
|
+
console.log(dataResults.get(1).getLastInsertId())
|
|
127
115
|
```
|
|
128
116
|
|
|
129
|
-
###
|
|
130
|
-
The code sample shows how would connect to a rqlite and run multiple select queries with [strong consistency](https://github.com/rqlite/rqlite/blob/master/DOC/CONSISTENCY.md).
|
|
117
|
+
### Consistency
|
|
131
118
|
|
|
132
119
|
```javascript
|
|
133
|
-
import { DataApiClient } from 'rqlite-js'
|
|
120
|
+
import { DataApiClient, CONSISTENCY_LEVEL_STRONG } from 'rqlite-js'
|
|
134
121
|
|
|
135
122
|
const dataApiClient = new DataApiClient('http://localhost:4001')
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
123
|
+
const dataResults = await dataApiClient.query(
|
|
124
|
+
'SELECT name FROM foo WHERE id=1',
|
|
125
|
+
{ level: CONSISTENCY_LEVEL_STRONG },
|
|
126
|
+
)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
See [read consistency](https://rqlite.io/docs/api/read-consistency/) for `none`, `weak`, `strong`, and `linearizable`.
|
|
130
|
+
|
|
131
|
+
### Errors (`error` and `error_v2`)
|
|
132
|
+
|
|
133
|
+
Failed statements still use the legacy `error` string. On rqlite v10+, structured `error_v2` is also exposed:
|
|
134
|
+
|
|
135
|
+
```javascript
|
|
136
|
+
const dataResults = await dataApiClient.execute('INSERT INTO nonsense')
|
|
137
|
+
if (dataResults.hasError()) {
|
|
138
|
+
const err = dataResults.getFirstError()
|
|
139
|
+
console.error(err.message)
|
|
140
|
+
console.error(err.getErrorV2()) // { message, sqlite: { code, extended_code } } when present
|
|
141
|
+
console.error(err.toObject())
|
|
151
142
|
}
|
|
152
143
|
```
|
|
144
|
+
|
|
153
145
|
### Authentication
|
|
154
|
-
Authentication can be set using the authentication property on the DataApiClient options.
|
|
155
146
|
|
|
156
147
|
```javascript
|
|
157
148
|
import { DataApiClient } from 'rqlite-js'
|
|
158
149
|
|
|
159
|
-
const username = 'rqliteUsername'
|
|
160
|
-
const password = 'rqlitePassword'
|
|
161
150
|
const dataApiClient = new DataApiClient('http://localhost:4001', {
|
|
162
|
-
authentication: {
|
|
151
|
+
authentication: {
|
|
152
|
+
username: 'rqliteUsername',
|
|
153
|
+
password: 'rqlitePassword',
|
|
154
|
+
},
|
|
163
155
|
})
|
|
164
|
-
try {
|
|
165
|
-
const sql = [
|
|
166
|
-
'SELECT name FROM foo WHERE id="1"',
|
|
167
|
-
'SELECT id FROM bar WHERE name="test"',
|
|
168
|
-
]
|
|
169
|
-
const dataResults = await dataApiClient.query(sql, { level: 'strong' })
|
|
170
|
-
if (dataResults.hasError()) {
|
|
171
|
-
const error = dataResults.getFirstError()
|
|
172
|
-
console.error(error, 'rqlite insert results contained an error.')
|
|
173
|
-
return
|
|
174
|
-
}
|
|
175
|
-
console.log(dataResults.get(0).toString(), 'The results for the first select are in index 0')
|
|
176
|
-
console.log(dataResults.get(1).toString(), 'The results for the second select are in index 1')
|
|
177
|
-
} catch (e) {
|
|
178
|
-
console.error(e, 'The HTTP client got an HTTP error, there must be something else going on.')
|
|
179
|
-
}
|
|
180
156
|
```
|
|
181
157
|
|
|
182
|
-
### Client options
|
|
183
|
-
Multiple hosts can be provided using the construtor for the data api client. For greater performance when making http requests it is often useful to provide an http and https agent to the client through options.
|
|
158
|
+
### Client options (hosts, agents, retries)
|
|
184
159
|
|
|
185
160
|
```javascript
|
|
186
|
-
import { DataApiClient } from 'rqlite-js'
|
|
187
161
|
import http from 'http'
|
|
188
162
|
import https from 'https'
|
|
163
|
+
import { DataApiClient } from 'rqlite-js'
|
|
189
164
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
})
|
|
165
|
+
const dataApiClient = new DataApiClient(
|
|
166
|
+
['http://localhost:4001', 'http://localhost:4002', 'http://localhost:4003'],
|
|
167
|
+
{
|
|
168
|
+
httpAgent: new http.Agent({ keepAlive: true }),
|
|
169
|
+
httpsAgent: new https.Agent({ keepAlive: true }),
|
|
170
|
+
// Optional retry customization:
|
|
171
|
+
retryableStatusCodes: new Set([408, 429, 500, 502, 503, 504]),
|
|
172
|
+
retryableErrorCodes: new Set(['ECONNRESET', 'ETIMEDOUT']),
|
|
173
|
+
retryableHttpMethods: new Set(['GET', 'POST']),
|
|
174
|
+
retries: 0, // disable retries
|
|
175
|
+
},
|
|
176
|
+
)
|
|
195
177
|
```
|
|
196
178
|
|
|
197
|
-
|
|
198
|
-
|
|
179
|
+
Hosts may also be a comma-separated string: `'http://localhost:4001,http://localhost:4002'`.
|
|
180
|
+
|
|
181
|
+
## StatusApiClient
|
|
199
182
|
|
|
200
183
|
```javascript
|
|
201
|
-
import {
|
|
202
|
-
|
|
203
|
-
|
|
184
|
+
import { StatusApiClient } from 'rqlite-js'
|
|
185
|
+
|
|
186
|
+
const statusApiClient = new StatusApiClient('http://localhost:4001')
|
|
187
|
+
const { status, body } = await statusApiClient.status()
|
|
188
|
+
console.log(status, body.store?.ready)
|
|
204
189
|
|
|
205
|
-
//
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
retryableHttpMethods: Set(['GET']), // Only retry GET requests
|
|
210
|
-
retries: 0, // Manually disable all retry logic
|
|
190
|
+
// One status call per configured host:
|
|
191
|
+
const all = await statusApiClient.statusAllHosts()
|
|
192
|
+
all.forEach(({ host, response }) => {
|
|
193
|
+
console.log(host, response.body?.store?.ready)
|
|
211
194
|
})
|
|
212
195
|
```
|
|
213
196
|
|
|
214
|
-
|
|
215
|
-
|
|
197
|
+
See [Monitoring rqlite](https://rqlite.io/docs/guides/monitoring-rqlite/).
|
|
198
|
+
|
|
199
|
+
## BackupApiClient
|
|
200
|
+
|
|
201
|
+
```javascript
|
|
202
|
+
import { BackupApiClient, BACKUP_DATA_FORMAT_SQL } from 'rqlite-js'
|
|
203
|
+
|
|
204
|
+
const backupApiClient = new BackupApiClient('http://localhost:4001')
|
|
205
|
+
|
|
206
|
+
// Binary SQLite backup stream (default):
|
|
207
|
+
const backupStream = await backupApiClient.backup()
|
|
208
|
+
|
|
209
|
+
// SQL text backup:
|
|
210
|
+
const sqlStream = await backupApiClient.backup(BACKUP_DATA_FORMAT_SQL)
|
|
211
|
+
|
|
212
|
+
// Restore from SQL buffer/string:
|
|
213
|
+
await backupApiClient.load(
|
|
214
|
+
Buffer.from('CREATE TABLE foo (id INTEGER PRIMARY KEY);'),
|
|
215
|
+
BACKUP_DATA_FORMAT_SQL,
|
|
216
|
+
)
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
See [Backup and restore](https://rqlite.io/docs/guides/backup/).
|
|
220
|
+
|
|
221
|
+
## Releases
|
|
222
|
+
|
|
223
|
+
Versions and `CHANGELOG.md` are managed with [release-please](https://github.com/googleapis/release-please). Merging the release PR creates a GitHub Release; the publish workflow re-runs the full test suite (including Docker integrations) then runs [`npm stage publish`](https://docs.npmjs.com/staged-publishing/) via [trusted publishing](https://docs.npmjs.com/trusted-publishers/) (OIDC). A maintainer must then approve the staged version with 2FA on npmjs.com (or `npm stage approve <id>`) before it goes live.
|
|
224
|
+
|
|
225
|
+
**Local quality gate (required before commit/push/publish):**
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
npm run verify # lint, type-check, unit, build, compiled unit
|
|
229
|
+
npm run verify:integrations # Docker + rqlite 10.6.6 integrations
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Contributing / testing
|
|
233
|
+
|
|
234
|
+
See [docs/test/README.md](docs/test/README.md).
|
package/lib/api/backup/index.js
CHANGED
|
@@ -1,30 +1,24 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports, "__esModule", { value: true });exports
|
|
1
|
+
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports, "__esModule", { value: true });Object.defineProperty(exports, "BACKUP_DATA_FORMAT_DUMP", { enumerable: true, get: function () {return _backupFormats.BACKUP_DATA_FORMAT_DUMP;} });Object.defineProperty(exports, "BACKUP_DATA_FORMAT_SQL", { enumerable: true, get: function () {return _backupFormats.BACKUP_DATA_FORMAT_SQL;} });Object.defineProperty(exports, "PATH_BACKUP", { enumerable: true, get: function () {return _paths.PATH_BACKUP;} });Object.defineProperty(exports, "PATH_LOAD", { enumerable: true, get: function () {return _paths.PATH_LOAD;} });exports.default = void 0;
|
|
2
|
+
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
var _httpRequest = _interopRequireDefault(require("../../http-request"));
|
|
6
|
-
var _contentTypes = require("../../http-request/content-types");
|
|
7
|
-
* Backup api client to perform RQLite back and load operations
|
|
8
|
-
* @module api/backup
|
|
9
|
-
*/ /**
|
|
10
|
-
* The RQLite load api path
|
|
11
|
-
*/const PATH_LOAD = exports.PATH_LOAD = '/db/load';
|
|
7
|
+
var _contentTypes = require("../../http-request/content-types");
|
|
12
8
|
|
|
13
|
-
/**
|
|
14
|
-
* The RQLite backup api path
|
|
15
|
-
*/
|
|
16
|
-
const PATH_BACKUP = exports.PATH_BACKUP = '/db/backup';
|
|
17
9
|
|
|
18
|
-
/**
|
|
19
|
-
* Use plain SQL dump as the back up format
|
|
20
|
-
*/
|
|
21
|
-
const BACKUP_DATA_FORMAT_SQL = exports.BACKUP_DATA_FORMAT_SQL = 'sql';
|
|
22
10
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const BACKUP_DATA_FORMAT_DUMP = exports.BACKUP_DATA_FORMAT_DUMP = 'dump';
|
|
11
|
+
var _httpHeaders = require("../../http-request/http-headers");
|
|
12
|
+
|
|
13
|
+
|
|
27
14
|
|
|
15
|
+
var _paths = require("../paths");
|
|
16
|
+
var _backupFormats = require("../backup-formats");
|
|
17
|
+
var _queryParams = require("../query-params"); /**
|
|
18
|
+
* Backup api client to perform RQLite back and load operations
|
|
19
|
+
* @module api/backup
|
|
20
|
+
* @see https://rqlite.io/docs/guides/backup/
|
|
21
|
+
*/
|
|
28
22
|
/**
|
|
29
23
|
* Backup api client to perform RQLite back up and load operations
|
|
30
24
|
*/
|
|
@@ -32,41 +26,47 @@ class BackupApiClient extends _httpRequest.default {
|
|
|
32
26
|
/**
|
|
33
27
|
* Perform a SQL dump backup from the RQLite server
|
|
34
28
|
* @param {String} [format=BACKUP_DATA_FORMAT_DUMP] The backup data format
|
|
35
|
-
* @returns {
|
|
29
|
+
* @returns {Promise<*>} The response stream
|
|
30
|
+
* @see https://rqlite.io/docs/guides/backup/
|
|
31
|
+
* @see module:api/backup-formats
|
|
36
32
|
*/
|
|
37
|
-
backup(format = BACKUP_DATA_FORMAT_DUMP) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
33
|
+
async backup(format = _backupFormats.BACKUP_DATA_FORMAT_DUMP) {
|
|
34
|
+
return super.get({
|
|
35
|
+
headers: {
|
|
36
|
+
// Always sends application/octet-stream from the server in RQLite v4.x
|
|
37
|
+
[_httpHeaders.HTTP_HEADER_ACCEPT]: _contentTypes.CONTENT_TYPE_APPLICATION_OCTET_STREAM
|
|
38
|
+
},
|
|
39
|
+
query: {
|
|
40
|
+
[_queryParams.QUERY_PARAM_FMT]: format === _backupFormats.BACKUP_DATA_FORMAT_SQL ? format : undefined
|
|
41
|
+
},
|
|
42
|
+
json: false,
|
|
43
|
+
stream: true,
|
|
44
|
+
uri: _paths.PATH_BACKUP,
|
|
45
|
+
useLeader: true
|
|
46
|
+
});
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
/**
|
|
53
50
|
* Perform a SQL restore by sending data the RQLite server
|
|
54
51
|
* @param {Buffer|String} data The data to be loaded
|
|
55
52
|
* @param {String} [format=BACKUP_DATA_FORMAT_SQL] The backup data format
|
|
56
|
-
* @returns {
|
|
53
|
+
* @returns {Promise<*>} The response stream
|
|
54
|
+
* @see https://rqlite.io/docs/guides/backup/
|
|
55
|
+
* @see module:api/backup-formats
|
|
57
56
|
*/
|
|
58
|
-
load(data, format = BACKUP_DATA_FORMAT_SQL) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
async load(data, format = _backupFormats.BACKUP_DATA_FORMAT_SQL) {
|
|
58
|
+
return super.post({
|
|
59
|
+
body: data,
|
|
60
|
+
headers: {
|
|
61
|
+
[_httpHeaders.HTTP_HEADER_CONTENT_TYPE]: format === _backupFormats.BACKUP_DATA_FORMAT_SQL ?
|
|
62
|
+
_contentTypes.CONTENT_TYPE_TEXT_PLAIN :
|
|
63
|
+
_contentTypes.CONTENT_TYPE_APPLICATION_OCTET_STREAM
|
|
64
|
+
},
|
|
65
|
+
json: false,
|
|
66
|
+
stream: true,
|
|
67
|
+
uri: _paths.PATH_LOAD,
|
|
68
|
+
useLeader: true
|
|
69
|
+
});
|
|
70
70
|
}
|
|
71
71
|
}exports.default = BackupApiClient;
|
|
72
72
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_httpRequest","_interopRequireDefault","require","_contentTypes","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_httpRequest","_interopRequireDefault","require","_contentTypes","_httpHeaders","_paths","_backupFormats","_queryParams","BackupApiClient","HttpRequest","backup","format","BACKUP_DATA_FORMAT_DUMP","get","headers","HTTP_HEADER_ACCEPT","CONTENT_TYPE_APPLICATION_OCTET_STREAM","query","QUERY_PARAM_FMT","BACKUP_DATA_FORMAT_SQL","undefined","json","stream","uri","PATH_BACKUP","useLeader","load","data","post","body","HTTP_HEADER_CONTENT_TYPE","CONTENT_TYPE_TEXT_PLAIN","PATH_LOAD","exports","default"],"sources":["../../../es6/api/backup/index.js"],"sourcesContent":["/**\n * Backup api client to perform RQLite back and load operations\n * @module api/backup\n * @see https://rqlite.io/docs/guides/backup/\n */\nimport HttpRequest from '../../http-request'\nimport {\n CONTENT_TYPE_APPLICATION_OCTET_STREAM,\n CONTENT_TYPE_TEXT_PLAIN,\n} from '../../http-request/content-types'\nimport {\n HTTP_HEADER_ACCEPT,\n HTTP_HEADER_CONTENT_TYPE,\n} from '../../http-request/http-headers'\nimport { PATH_BACKUP, PATH_LOAD } from '../paths'\nimport { BACKUP_DATA_FORMAT_DUMP, BACKUP_DATA_FORMAT_SQL } from '../backup-formats'\nimport { QUERY_PARAM_FMT } from '../query-params'\n\nexport { PATH_LOAD, PATH_BACKUP } from '../paths'\nexport { BACKUP_DATA_FORMAT_SQL, BACKUP_DATA_FORMAT_DUMP } from '../backup-formats'\n\n/**\n * Backup api client to perform RQLite back up and load operations\n */\nexport default class BackupApiClient extends HttpRequest {\n /**\n * Perform a SQL dump backup from the RQLite server\n * @param {String} [format=BACKUP_DATA_FORMAT_DUMP] The backup data format\n * @returns {Promise<*>} The response stream\n * @see https://rqlite.io/docs/guides/backup/\n * @see module:api/backup-formats\n */\n async backup (format = BACKUP_DATA_FORMAT_DUMP) {\n return super.get({\n headers: {\n // Always sends application/octet-stream from the server in RQLite v4.x\n [HTTP_HEADER_ACCEPT]: CONTENT_TYPE_APPLICATION_OCTET_STREAM,\n },\n query: {\n [QUERY_PARAM_FMT]: format === BACKUP_DATA_FORMAT_SQL ? format : undefined,\n },\n json: false,\n stream: true,\n uri: PATH_BACKUP,\n useLeader: true,\n })\n }\n\n /**\n * Perform a SQL restore by sending data the RQLite server\n * @param {Buffer|String} data The data to be loaded\n * @param {String} [format=BACKUP_DATA_FORMAT_SQL] The backup data format\n * @returns {Promise<*>} The response stream\n * @see https://rqlite.io/docs/guides/backup/\n * @see module:api/backup-formats\n */\n async load (data, format = BACKUP_DATA_FORMAT_SQL) {\n return super.post({\n body: data,\n headers: {\n [HTTP_HEADER_CONTENT_TYPE]: format === BACKUP_DATA_FORMAT_SQL\n ? CONTENT_TYPE_TEXT_PLAIN\n : CONTENT_TYPE_APPLICATION_OCTET_STREAM,\n },\n json: false,\n stream: true,\n uri: PATH_LOAD,\n useLeader: true,\n })\n }\n}\n"],"mappings":";;;;;AAKA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;;;;AAIA,IAAAE,YAAA,GAAAF,OAAA;;;;AAIA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA,oBAAiD,CAhBjD;AACA;AACA;AACA;AACA;AAiBA;AACA;AACA;AACe,MAAMM,eAAe,SAASC,oBAAW,CAAC;EACvD;AACF;AACA;AACA;AACA;AACA;AACA;EACE,MAAMC,MAAMA,CAAEC,MAAM,GAAGC,sCAAuB,EAAE;IAC9C,OAAO,KAAK,CAACC,GAAG,CAAC;MACfC,OAAO,EAAE;QACP;QACA,CAACC,+BAAkB,GAAGC;MACxB,CAAC;MACDC,KAAK,EAAE;QACL,CAACC,4BAAe,GAAGP,MAAM,KAAKQ,qCAAsB,GAAGR,MAAM,GAAGS;MAClE,CAAC;MACDC,IAAI,EAAE,KAAK;MACXC,MAAM,EAAE,IAAI;MACZC,GAAG,EAAEC,kBAAW;MAChBC,SAAS,EAAE;IACb,CAAC,CAAC;EACJ;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,MAAMC,IAAIA,CAAEC,IAAI,EAAEhB,MAAM,GAAGQ,qCAAsB,EAAE;IACjD,OAAO,KAAK,CAACS,IAAI,CAAC;MAChBC,IAAI,EAAEF,IAAI;MACVb,OAAO,EAAE;QACP,CAACgB,qCAAwB,GAAGnB,MAAM,KAAKQ,qCAAsB;QACzDY,qCAAuB;QACvBf;MACN,CAAC;MACDK,IAAI,EAAE,KAAK;MACXC,MAAM,EAAE,IAAI;MACZC,GAAG,EAAES,gBAAS;MACdP,SAAS,EAAE;IACb,CAAC,CAAC;EACJ;AACF,CAACQ,OAAA,CAAAC,OAAA,GAAA1B,eAAA","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";var _chai = require("chai");
|
|
2
|
+
var _backupNock = require("../../test/backups/backup-nock");
|
|
3
|
+
var _restoreNock = require("../../test/backups/restore-nock");
|
|
4
|
+
var _ = _interopRequireWildcard(require("."));var cache;function _interopRequireWildcard(e, t) {if (!t && e && e.__esModule) return e;var r,c,a = Object.defineProperty,n = { __proto__: null, default: e };if (Object(e) !== e) return n;if (cache || "function" != typeof WeakMap || (cache = new WeakMap()), cache) {if (cache.has(e)) return cache.get(e);cache.set(e, n);}for (c in e) "default" !== c && {}.hasOwnProperty.call(e, c) && ((r = a && Object.getOwnPropertyDescriptor(e, c)) && (r.get || r.set) ? a(n, c, r) : n[c] = e[c]);return n;}
|
|
5
|
+
|
|
6
|
+
const HOST = 'http://www.rqlite.com:4001';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Capture the stream data and resolve a promise with the parsed JSON
|
|
10
|
+
*/
|
|
11
|
+
function handleRequestStreamAsPromise(request) {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
let result = Buffer.from('');
|
|
14
|
+
request.
|
|
15
|
+
on('data', (data) => {
|
|
16
|
+
result = Buffer.concat([result, data]);
|
|
17
|
+
}).
|
|
18
|
+
on('end', () => resolve(result)).
|
|
19
|
+
on('error', reject);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
describe('api backup', () => {
|
|
24
|
+
describe('backupApiClient.backup()', () => {
|
|
25
|
+
it(`should call ${HOST}${_.PATH_BACKUP} endpoint using HTTP GET`, async () => {
|
|
26
|
+
const backupApiClient = new _.default(HOST);
|
|
27
|
+
const scope = (0, _backupNock.backupSuccess)({ url: HOST, path: _.PATH_BACKUP });
|
|
28
|
+
const request = await backupApiClient.backup();
|
|
29
|
+
const result = await handleRequestStreamAsPromise(request);
|
|
30
|
+
_chai.assert.isTrue(scope.isDone(), 'http request captured by nock');
|
|
31
|
+
_chai.assert.equal(result, _backupNock.BACKUP_SUCCESS_RESPONSE);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
describe('backupApiClient.load()', () => {
|
|
35
|
+
it(`should call ${HOST}${_.PATH_LOAD} endpoint using HTTP POST`, async () => {
|
|
36
|
+
const backupApiClient = new _.default(HOST);
|
|
37
|
+
const scope = (0, _restoreNock.restoreSuccess)({ url: HOST, path: _.PATH_LOAD, body: _backupNock.BACKUP_SUCCESS_RESPONSE });
|
|
38
|
+
const request = await backupApiClient.load(_backupNock.BACKUP_SUCCESS_RESPONSE);
|
|
39
|
+
const result = await handleRequestStreamAsPromise(request);
|
|
40
|
+
_chai.assert.isTrue(scope.isDone(), 'http request captured by nock');
|
|
41
|
+
_chai.assert.deepEqual(JSON.parse(result.toString()), _restoreNock.RESTORE_SUCCESS_RESPONSE);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=test.unit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.unit.js","names":["_chai","require","_backupNock","_restoreNock","_","_interopRequireWildcard","cache","e","t","__esModule","r","c","a","Object","defineProperty","n","__proto__","default","WeakMap","has","get","set","hasOwnProperty","call","getOwnPropertyDescriptor","HOST","handleRequestStreamAsPromise","request","Promise","resolve","reject","result","Buffer","from","on","data","concat","describe","it","PATH_BACKUP","backupApiClient","BackupApiClient","scope","backupSuccess","url","path","backup","assert","isTrue","isDone","equal","BACKUP_SUCCESS_RESPONSE","PATH_LOAD","restoreSuccess","body","load","deepEqual","JSON","parse","toString","RESTORE_SUCCESS_RESPONSE"],"sources":["../../../es6/api/backup/test.unit.js"],"sourcesContent":["import { assert } from 'chai'\nimport { backupSuccess, BACKUP_SUCCESS_RESPONSE } from '../../test/backups/backup-nock'\nimport { restoreSuccess, RESTORE_SUCCESS_RESPONSE } from '../../test/backups/restore-nock'\nimport BackupApiClient, { PATH_BACKUP, PATH_LOAD } from '.'\n\nconst HOST = 'http://www.rqlite.com:4001'\n\n/**\n * Capture the stream data and resolve a promise with the parsed JSON\n */\nfunction handleRequestStreamAsPromise (request) {\n return new Promise((resolve, reject) => {\n let result = Buffer.from('')\n request\n .on('data', (data) => {\n result = Buffer.concat([result, data])\n })\n .on('end', () => resolve(result))\n .on('error', reject)\n })\n}\n\ndescribe('api backup', () => {\n describe('backupApiClient.backup()', () => {\n it(`should call ${HOST}${PATH_BACKUP} endpoint using HTTP GET`, async () => {\n const backupApiClient = new BackupApiClient(HOST)\n const scope = backupSuccess({ url: HOST, path: PATH_BACKUP })\n const request = await backupApiClient.backup()\n const result = await handleRequestStreamAsPromise(request)\n assert.isTrue(scope.isDone(), 'http request captured by nock')\n assert.equal(result, BACKUP_SUCCESS_RESPONSE)\n })\n })\n describe('backupApiClient.load()', () => {\n it(`should call ${HOST}${PATH_LOAD} endpoint using HTTP POST`, async () => {\n const backupApiClient = new BackupApiClient(HOST)\n const scope = restoreSuccess({ url: HOST, path: PATH_LOAD, body: BACKUP_SUCCESS_RESPONSE })\n const request = await backupApiClient.load(BACKUP_SUCCESS_RESPONSE)\n const result = await handleRequestStreamAsPromise(request)\n assert.isTrue(scope.isDone(), 'http request captured by nock')\n assert.deepEqual(JSON.parse(result.toString()), RESTORE_SUCCESS_RESPONSE)\n })\n })\n})\n"],"mappings":"aAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,CAAA,GAAAC,uBAAA,CAAAJ,OAAA,OAA2D,IAAAK,KAAA,UAAAD,wBAAAE,CAAA,EAAAC,CAAA,QAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAE,UAAA,SAAAF,CAAA,KAAAG,CAAA,CAAAC,CAAA,CAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,CAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,OAAAM,MAAA,CAAAN,CAAA,MAAAA,CAAA,SAAAQ,CAAA,KAAAT,KAAA,yBAAAY,OAAA,KAAAZ,KAAA,OAAAY,OAAA,KAAAZ,KAAA,OAAAA,KAAA,CAAAa,GAAA,CAAAZ,CAAA,UAAAD,KAAA,CAAAc,GAAA,CAAAb,CAAA,CAAAD,CAAA,MAAAe,GAAA,CAAAd,CAAA,EAAAQ,CAAA,QAAAJ,CAAA,IAAAJ,CAAA,gBAAAI,CAAA,OAAAW,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAI,CAAA,OAAAD,CAAA,GAAAE,CAAA,IAAAC,MAAA,CAAAW,wBAAA,CAAAjB,CAAA,EAAAI,CAAA,OAAAD,CAAA,CAAAU,GAAA,IAAAV,CAAA,CAAAW,GAAA,IAAAT,CAAA,CAAAG,CAAA,EAAAJ,CAAA,EAAAD,CAAA,IAAAK,CAAA,CAAAJ,CAAA,IAAAJ,CAAA,CAAAI,CAAA,UAAAI,CAAA;;AAE3D,MAAMU,IAAI,GAAG,4BAA4B;;AAEzC;AACA;AACA;AACA,SAASC,4BAA4BA,CAAEC,OAAO,EAAE;EAC9C,OAAO,IAAIC,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;IACtC,IAAIC,MAAM,GAAGC,MAAM,CAACC,IAAI,CAAC,EAAE,CAAC;IAC5BN,OAAO;IACJO,EAAE,CAAC,MAAM,EAAE,CAACC,IAAI,KAAK;MACpBJ,MAAM,GAAGC,MAAM,CAACI,MAAM,CAAC,CAACL,MAAM,EAAEI,IAAI,CAAC,CAAC;IACxC,CAAC,CAAC;IACDD,EAAE,CAAC,KAAK,EAAE,MAAML,OAAO,CAACE,MAAM,CAAC,CAAC;IAChCG,EAAE,CAAC,OAAO,EAAEJ,MAAM,CAAC;EACxB,CAAC,CAAC;AACJ;;AAEAO,QAAQ,CAAC,YAAY,EAAE,MAAM;EAC3BA,QAAQ,CAAC,0BAA0B,EAAE,MAAM;IACzCC,EAAE,CAAC,eAAeb,IAAI,GAAGc,aAAW,0BAA0B,EAAE,YAAY;MAC1E,MAAMC,eAAe,GAAG,IAAIC,SAAe,CAAChB,IAAI,CAAC;MACjD,MAAMiB,KAAK,GAAG,IAAAC,yBAAa,EAAC,EAAEC,GAAG,EAAEnB,IAAI,EAAEoB,IAAI,EAAEN,aAAW,CAAC,CAAC,CAAC;MAC7D,MAAMZ,OAAO,GAAG,MAAMa,eAAe,CAACM,MAAM,CAAC,CAAC;MAC9C,MAAMf,MAAM,GAAG,MAAML,4BAA4B,CAACC,OAAO,CAAC;MAC1DoB,YAAM,CAACC,MAAM,CAACN,KAAK,CAACO,MAAM,CAAC,CAAC,EAAE,+BAA+B,CAAC;MAC9DF,YAAM,CAACG,KAAK,CAACnB,MAAM,EAAEoB,mCAAuB,CAAC;IAC/C,CAAC,CAAC;EACJ,CAAC,CAAC;EACFd,QAAQ,CAAC,wBAAwB,EAAE,MAAM;IACvCC,EAAE,CAAC,eAAeb,IAAI,GAAG2B,WAAS,2BAA2B,EAAE,YAAY;MACzE,MAAMZ,eAAe,GAAG,IAAIC,SAAe,CAAChB,IAAI,CAAC;MACjD,MAAMiB,KAAK,GAAG,IAAAW,2BAAc,EAAC,EAAET,GAAG,EAAEnB,IAAI,EAAEoB,IAAI,EAAEO,WAAS,EAAEE,IAAI,EAAEH,mCAAuB,CAAC,CAAC,CAAC;MAC3F,MAAMxB,OAAO,GAAG,MAAMa,eAAe,CAACe,IAAI,CAACJ,mCAAuB,CAAC;MACnE,MAAMpB,MAAM,GAAG,MAAML,4BAA4B,CAACC,OAAO,CAAC;MAC1DoB,YAAM,CAACC,MAAM,CAACN,KAAK,CAACO,MAAM,CAAC,CAAC,EAAE,+BAA+B,CAAC;MAC9DF,YAAM,CAACS,SAAS,CAACC,IAAI,CAACC,KAAK,CAAC3B,MAAM,CAAC4B,QAAQ,CAAC,CAAC,CAAC,EAAEC,qCAAwB,CAAC;IAC3E,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.BACKUP_DATA_FORMAT_SQL = exports.BACKUP_DATA_FORMAT_DUMP = void 0; /**
|
|
2
|
+
* RQLite backup data format constants
|
|
3
|
+
* @module api/backup-formats
|
|
4
|
+
* @see https://rqlite.io/docs/guides/backup/
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Use plain SQL dump as the back up format
|
|
9
|
+
*/
|
|
10
|
+
const BACKUP_DATA_FORMAT_SQL = exports.BACKUP_DATA_FORMAT_SQL = 'sql';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Use sqlite3 dump as the back up format (default binary backup)
|
|
14
|
+
*/
|
|
15
|
+
const BACKUP_DATA_FORMAT_DUMP = exports.BACKUP_DATA_FORMAT_DUMP = 'dump';
|
|
16
|
+
//# sourceMappingURL=backup-formats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backup-formats.js","names":["BACKUP_DATA_FORMAT_SQL","exports","BACKUP_DATA_FORMAT_DUMP"],"sources":["../../es6/api/backup-formats.js"],"sourcesContent":["/**\n * RQLite backup data format constants\n * @module api/backup-formats\n * @see https://rqlite.io/docs/guides/backup/\n */\n\n/**\n * Use plain SQL dump as the back up format\n */\nexport const BACKUP_DATA_FORMAT_SQL = 'sql'\n\n/**\n * Use sqlite3 dump as the back up format (default binary backup)\n */\nexport const BACKUP_DATA_FORMAT_DUMP = 'dump'\n"],"mappings":"sJAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG,KAAK;;AAE3C;AACA;AACA;AACO,MAAME,uBAAuB,GAAAD,OAAA,CAAAC,uBAAA,GAAG,MAAM","ignoreList":[]}
|