appwrite-cli 4.2.0 → 4.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/LICENSE.md +1 -1
- package/README.md +3 -3
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.js +66 -74
- package/lib/commands/account.js +458 -199
- package/lib/commands/assistant.js +40 -10
- package/lib/commands/avatars.js +171 -71
- package/lib/commands/console.js +40 -6
- package/lib/commands/databases.js +838 -555
- package/lib/commands/functions.js +493 -288
- package/lib/commands/generic.js +0 -1
- package/lib/commands/graphql.js +53 -14
- package/lib/commands/health.js +272 -71
- package/lib/commands/locale.js +131 -20
- package/lib/commands/migrations.js +282 -151
- package/lib/commands/project.js +111 -36
- package/lib/commands/projects.js +670 -415
- package/lib/commands/proxy.js +100 -32
- package/lib/commands/storage.js +374 -204
- package/lib/commands/teams.js +239 -107
- package/lib/commands/users.js +465 -266
- package/lib/commands/vcs.js +161 -57
- package/package.json +9 -9
- package/scoop/appwrite.json +3 -3
|
@@ -9,93 +9,134 @@ const { Command } = require('commander');
|
|
|
9
9
|
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
11
|
const { localConfig, globalConfig } = require("../config");
|
|
12
|
+
const { File } = require('undici');
|
|
13
|
+
const { ReadableStream } = require('stream/web');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {fs.ReadStream} readStream
|
|
17
|
+
* @returns {ReadableStream}
|
|
18
|
+
*/
|
|
19
|
+
function convertReadStreamToReadableStream(readStream) {
|
|
20
|
+
return new ReadableStream({
|
|
21
|
+
start(controller) {
|
|
22
|
+
readStream.on("data", (chunk) => {
|
|
23
|
+
controller.enqueue(chunk);
|
|
24
|
+
});
|
|
25
|
+
readStream.on("end", () => {
|
|
26
|
+
controller.close();
|
|
27
|
+
});
|
|
28
|
+
readStream.on("error", (err) => {
|
|
29
|
+
controller.error(err);
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
cancel() {
|
|
33
|
+
readStream.destroy();
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
12
37
|
|
|
13
38
|
const migrations = new Command("migrations").description(commandDescriptions['migrations']).configureHelp({
|
|
14
39
|
helpWidth: process.stdout.columns || 80
|
|
15
|
-
|
|
16
|
-
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {Object} MigrationsListRequestParams
|
|
44
|
+
* @property {string} queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: status, stage, source, resources, statusCounters, resourceData, errors
|
|
45
|
+
* @property {string} search Search term to filter your list results. Max length: 256 chars.
|
|
46
|
+
* @property {boolean} parseOutput
|
|
47
|
+
* @property {libClient | undefined} sdk
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @param {MigrationsListRequestParams} params
|
|
52
|
+
*/
|
|
17
53
|
const migrationsList = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
|
|
18
|
-
/* @param {string} queries */
|
|
19
|
-
/* @param {string} search */
|
|
20
|
-
|
|
21
54
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
22
55
|
let apiPath = '/migrations';
|
|
23
56
|
let payload = {};
|
|
24
|
-
|
|
25
|
-
/** Query Params */
|
|
26
57
|
if (typeof queries !== 'undefined') {
|
|
27
58
|
payload['queries'] = queries;
|
|
28
59
|
}
|
|
29
60
|
if (typeof search !== 'undefined') {
|
|
30
61
|
payload['search'] = search;
|
|
31
62
|
}
|
|
63
|
+
|
|
32
64
|
let response = undefined;
|
|
65
|
+
|
|
33
66
|
response = await client.call('get', apiPath, {
|
|
34
67
|
'content-type': 'application/json',
|
|
35
68
|
}, payload);
|
|
36
|
-
|
|
69
|
+
|
|
37
70
|
if (parseOutput) {
|
|
38
71
|
parse(response)
|
|
39
72
|
success()
|
|
40
73
|
}
|
|
74
|
+
|
|
41
75
|
return response;
|
|
42
76
|
}
|
|
43
77
|
|
|
78
|
+
/**
|
|
79
|
+
* @typedef {Object} MigrationsCreateAppwriteMigrationRequestParams
|
|
80
|
+
* @property {string[]} resources List of resources to migrate
|
|
81
|
+
* @property {string} endpoint Source's Appwrite Endpoint
|
|
82
|
+
* @property {string} projectId Source's Project ID
|
|
83
|
+
* @property {string} apiKey Source's API Key
|
|
84
|
+
* @property {boolean} parseOutput
|
|
85
|
+
* @property {libClient | undefined} sdk
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @param {MigrationsCreateAppwriteMigrationRequestParams} params
|
|
90
|
+
*/
|
|
44
91
|
const migrationsCreateAppwriteMigration = async ({ resources, endpoint, projectId, apiKey, parseOutput = true, sdk = undefined}) => {
|
|
45
|
-
/* @param {string[]} resources */
|
|
46
|
-
/* @param {string} endpoint */
|
|
47
|
-
/* @param {string} projectId */
|
|
48
|
-
/* @param {string} apiKey */
|
|
49
|
-
|
|
50
92
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
51
93
|
let apiPath = '/migrations/appwrite';
|
|
52
94
|
let payload = {};
|
|
53
|
-
|
|
54
|
-
/** Body Params */
|
|
55
95
|
resources = resources === true ? [] : resources;
|
|
56
|
-
|
|
57
96
|
if (typeof resources !== 'undefined') {
|
|
58
97
|
payload['resources'] = resources;
|
|
59
98
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
99
|
if (typeof endpoint !== 'undefined') {
|
|
63
100
|
payload['endpoint'] = endpoint;
|
|
64
101
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
102
|
if (typeof projectId !== 'undefined') {
|
|
68
103
|
payload['projectId'] = projectId;
|
|
69
104
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
105
|
if (typeof apiKey !== 'undefined') {
|
|
73
106
|
payload['apiKey'] = apiKey;
|
|
74
107
|
}
|
|
75
108
|
|
|
76
109
|
let response = undefined;
|
|
110
|
+
|
|
77
111
|
response = await client.call('post', apiPath, {
|
|
78
112
|
'content-type': 'application/json',
|
|
79
113
|
}, payload);
|
|
80
|
-
|
|
114
|
+
|
|
81
115
|
if (parseOutput) {
|
|
82
116
|
parse(response)
|
|
83
117
|
success()
|
|
84
118
|
}
|
|
119
|
+
|
|
85
120
|
return response;
|
|
86
121
|
}
|
|
87
122
|
|
|
123
|
+
/**
|
|
124
|
+
* @typedef {Object} MigrationsGetAppwriteReportRequestParams
|
|
125
|
+
* @property {string[]} resources List of resources to migrate
|
|
126
|
+
* @property {string} endpoint Source's Appwrite Endpoint
|
|
127
|
+
* @property {string} projectID Source's Project ID
|
|
128
|
+
* @property {string} key Source's API Key
|
|
129
|
+
* @property {boolean} parseOutput
|
|
130
|
+
* @property {libClient | undefined} sdk
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @param {MigrationsGetAppwriteReportRequestParams} params
|
|
135
|
+
*/
|
|
88
136
|
const migrationsGetAppwriteReport = async ({ resources, endpoint, projectID, key, parseOutput = true, sdk = undefined}) => {
|
|
89
|
-
/* @param {string[]} resources */
|
|
90
|
-
/* @param {string} endpoint */
|
|
91
|
-
/* @param {string} projectID */
|
|
92
|
-
/* @param {string} key */
|
|
93
|
-
|
|
94
137
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
95
138
|
let apiPath = '/migrations/appwrite/report';
|
|
96
139
|
let payload = {};
|
|
97
|
-
|
|
98
|
-
/** Query Params */
|
|
99
140
|
if (typeof resources !== 'undefined') {
|
|
100
141
|
payload['resources'] = resources;
|
|
101
142
|
}
|
|
@@ -108,253 +149,305 @@ const migrationsGetAppwriteReport = async ({ resources, endpoint, projectID, key
|
|
|
108
149
|
if (typeof key !== 'undefined') {
|
|
109
150
|
payload['key'] = key;
|
|
110
151
|
}
|
|
152
|
+
|
|
111
153
|
let response = undefined;
|
|
154
|
+
|
|
112
155
|
response = await client.call('get', apiPath, {
|
|
113
156
|
'content-type': 'application/json',
|
|
114
157
|
}, payload);
|
|
115
|
-
|
|
158
|
+
|
|
116
159
|
if (parseOutput) {
|
|
117
160
|
parse(response)
|
|
118
161
|
success()
|
|
119
162
|
}
|
|
163
|
+
|
|
120
164
|
return response;
|
|
121
165
|
}
|
|
122
166
|
|
|
167
|
+
/**
|
|
168
|
+
* @typedef {Object} MigrationsCreateFirebaseMigrationRequestParams
|
|
169
|
+
* @property {string[]} resources List of resources to migrate
|
|
170
|
+
* @property {string} serviceAccount JSON of the Firebase service account credentials
|
|
171
|
+
* @property {boolean} parseOutput
|
|
172
|
+
* @property {libClient | undefined} sdk
|
|
173
|
+
*/
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @param {MigrationsCreateFirebaseMigrationRequestParams} params
|
|
177
|
+
*/
|
|
123
178
|
const migrationsCreateFirebaseMigration = async ({ resources, serviceAccount, parseOutput = true, sdk = undefined}) => {
|
|
124
|
-
/* @param {string[]} resources */
|
|
125
|
-
/* @param {string} serviceAccount */
|
|
126
|
-
|
|
127
179
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
128
180
|
let apiPath = '/migrations/firebase';
|
|
129
181
|
let payload = {};
|
|
130
|
-
|
|
131
|
-
/** Body Params */
|
|
132
182
|
resources = resources === true ? [] : resources;
|
|
133
|
-
|
|
134
183
|
if (typeof resources !== 'undefined') {
|
|
135
184
|
payload['resources'] = resources;
|
|
136
185
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
186
|
if (typeof serviceAccount !== 'undefined') {
|
|
140
187
|
payload['serviceAccount'] = serviceAccount;
|
|
141
188
|
}
|
|
142
189
|
|
|
143
190
|
let response = undefined;
|
|
191
|
+
|
|
144
192
|
response = await client.call('post', apiPath, {
|
|
145
193
|
'content-type': 'application/json',
|
|
146
194
|
}, payload);
|
|
147
|
-
|
|
195
|
+
|
|
148
196
|
if (parseOutput) {
|
|
149
197
|
parse(response)
|
|
150
198
|
success()
|
|
151
199
|
}
|
|
200
|
+
|
|
152
201
|
return response;
|
|
153
202
|
}
|
|
154
203
|
|
|
155
|
-
|
|
204
|
+
/**
|
|
205
|
+
* @typedef {Object} MigrationsDeleteFirebaseAuthRequestParams
|
|
206
|
+
* @property {boolean} parseOutput
|
|
207
|
+
* @property {libClient | undefined} sdk
|
|
208
|
+
*/
|
|
156
209
|
|
|
210
|
+
/**
|
|
211
|
+
* @param {MigrationsDeleteFirebaseAuthRequestParams} params
|
|
212
|
+
*/
|
|
213
|
+
const migrationsDeleteFirebaseAuth = async ({ parseOutput = true, sdk = undefined}) => {
|
|
157
214
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
158
215
|
let apiPath = '/migrations/firebase/deauthorize';
|
|
159
216
|
let payload = {};
|
|
217
|
+
|
|
160
218
|
let response = undefined;
|
|
219
|
+
|
|
161
220
|
response = await client.call('get', apiPath, {
|
|
162
221
|
'content-type': 'application/json',
|
|
163
222
|
}, payload);
|
|
164
|
-
|
|
223
|
+
|
|
165
224
|
if (parseOutput) {
|
|
166
225
|
parse(response)
|
|
167
226
|
success()
|
|
168
227
|
}
|
|
228
|
+
|
|
169
229
|
return response;
|
|
170
230
|
}
|
|
171
231
|
|
|
232
|
+
/**
|
|
233
|
+
* @typedef {Object} MigrationsCreateFirebaseOAuthMigrationRequestParams
|
|
234
|
+
* @property {string[]} resources List of resources to migrate
|
|
235
|
+
* @property {string} projectId Project ID of the Firebase Project
|
|
236
|
+
* @property {boolean} parseOutput
|
|
237
|
+
* @property {libClient | undefined} sdk
|
|
238
|
+
*/
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* @param {MigrationsCreateFirebaseOAuthMigrationRequestParams} params
|
|
242
|
+
*/
|
|
172
243
|
const migrationsCreateFirebaseOAuthMigration = async ({ resources, projectId, parseOutput = true, sdk = undefined}) => {
|
|
173
|
-
/* @param {string[]} resources */
|
|
174
|
-
/* @param {string} projectId */
|
|
175
|
-
|
|
176
244
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
177
245
|
let apiPath = '/migrations/firebase/oauth';
|
|
178
246
|
let payload = {};
|
|
179
|
-
|
|
180
|
-
/** Body Params */
|
|
181
247
|
resources = resources === true ? [] : resources;
|
|
182
|
-
|
|
183
248
|
if (typeof resources !== 'undefined') {
|
|
184
249
|
payload['resources'] = resources;
|
|
185
250
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
251
|
if (typeof projectId !== 'undefined') {
|
|
189
252
|
payload['projectId'] = projectId;
|
|
190
253
|
}
|
|
191
254
|
|
|
192
255
|
let response = undefined;
|
|
256
|
+
|
|
193
257
|
response = await client.call('post', apiPath, {
|
|
194
258
|
'content-type': 'application/json',
|
|
195
259
|
}, payload);
|
|
196
|
-
|
|
260
|
+
|
|
197
261
|
if (parseOutput) {
|
|
198
262
|
parse(response)
|
|
199
263
|
success()
|
|
200
264
|
}
|
|
265
|
+
|
|
201
266
|
return response;
|
|
202
267
|
}
|
|
203
268
|
|
|
204
|
-
|
|
269
|
+
/**
|
|
270
|
+
* @typedef {Object} MigrationsListFirebaseProjectsRequestParams
|
|
271
|
+
* @property {boolean} parseOutput
|
|
272
|
+
* @property {libClient | undefined} sdk
|
|
273
|
+
*/
|
|
205
274
|
|
|
275
|
+
/**
|
|
276
|
+
* @param {MigrationsListFirebaseProjectsRequestParams} params
|
|
277
|
+
*/
|
|
278
|
+
const migrationsListFirebaseProjects = async ({ parseOutput = true, sdk = undefined}) => {
|
|
206
279
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
207
280
|
let apiPath = '/migrations/firebase/projects';
|
|
208
281
|
let payload = {};
|
|
282
|
+
|
|
209
283
|
let response = undefined;
|
|
284
|
+
|
|
210
285
|
response = await client.call('get', apiPath, {
|
|
211
286
|
'content-type': 'application/json',
|
|
212
287
|
}, payload);
|
|
213
|
-
|
|
288
|
+
|
|
214
289
|
if (parseOutput) {
|
|
215
290
|
parse(response)
|
|
216
291
|
success()
|
|
217
292
|
}
|
|
293
|
+
|
|
218
294
|
return response;
|
|
219
295
|
}
|
|
220
296
|
|
|
297
|
+
/**
|
|
298
|
+
* @typedef {Object} MigrationsGetFirebaseReportRequestParams
|
|
299
|
+
* @property {string[]} resources List of resources to migrate
|
|
300
|
+
* @property {string} serviceAccount JSON of the Firebase service account credentials
|
|
301
|
+
* @property {boolean} parseOutput
|
|
302
|
+
* @property {libClient | undefined} sdk
|
|
303
|
+
*/
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* @param {MigrationsGetFirebaseReportRequestParams} params
|
|
307
|
+
*/
|
|
221
308
|
const migrationsGetFirebaseReport = async ({ resources, serviceAccount, parseOutput = true, sdk = undefined}) => {
|
|
222
|
-
/* @param {string[]} resources */
|
|
223
|
-
/* @param {string} serviceAccount */
|
|
224
|
-
|
|
225
309
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
226
310
|
let apiPath = '/migrations/firebase/report';
|
|
227
311
|
let payload = {};
|
|
228
|
-
|
|
229
|
-
/** Query Params */
|
|
230
312
|
if (typeof resources !== 'undefined') {
|
|
231
313
|
payload['resources'] = resources;
|
|
232
314
|
}
|
|
233
315
|
if (typeof serviceAccount !== 'undefined') {
|
|
234
316
|
payload['serviceAccount'] = serviceAccount;
|
|
235
317
|
}
|
|
318
|
+
|
|
236
319
|
let response = undefined;
|
|
320
|
+
|
|
237
321
|
response = await client.call('get', apiPath, {
|
|
238
322
|
'content-type': 'application/json',
|
|
239
323
|
}, payload);
|
|
240
|
-
|
|
324
|
+
|
|
241
325
|
if (parseOutput) {
|
|
242
326
|
parse(response)
|
|
243
327
|
success()
|
|
244
328
|
}
|
|
329
|
+
|
|
245
330
|
return response;
|
|
246
331
|
}
|
|
247
332
|
|
|
333
|
+
/**
|
|
334
|
+
* @typedef {Object} MigrationsGetFirebaseReportOAuthRequestParams
|
|
335
|
+
* @property {string[]} resources List of resources to migrate
|
|
336
|
+
* @property {string} projectId Project ID
|
|
337
|
+
* @property {boolean} parseOutput
|
|
338
|
+
* @property {libClient | undefined} sdk
|
|
339
|
+
*/
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* @param {MigrationsGetFirebaseReportOAuthRequestParams} params
|
|
343
|
+
*/
|
|
248
344
|
const migrationsGetFirebaseReportOAuth = async ({ resources, projectId, parseOutput = true, sdk = undefined}) => {
|
|
249
|
-
/* @param {string[]} resources */
|
|
250
|
-
/* @param {string} projectId */
|
|
251
|
-
|
|
252
345
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
253
346
|
let apiPath = '/migrations/firebase/report/oauth';
|
|
254
347
|
let payload = {};
|
|
255
|
-
|
|
256
|
-
/** Query Params */
|
|
257
348
|
if (typeof resources !== 'undefined') {
|
|
258
349
|
payload['resources'] = resources;
|
|
259
350
|
}
|
|
260
351
|
if (typeof projectId !== 'undefined') {
|
|
261
352
|
payload['projectId'] = projectId;
|
|
262
353
|
}
|
|
354
|
+
|
|
263
355
|
let response = undefined;
|
|
356
|
+
|
|
264
357
|
response = await client.call('get', apiPath, {
|
|
265
358
|
'content-type': 'application/json',
|
|
266
359
|
}, payload);
|
|
267
|
-
|
|
360
|
+
|
|
268
361
|
if (parseOutput) {
|
|
269
362
|
parse(response)
|
|
270
363
|
success()
|
|
271
364
|
}
|
|
365
|
+
|
|
272
366
|
return response;
|
|
273
367
|
}
|
|
274
368
|
|
|
369
|
+
/**
|
|
370
|
+
* @typedef {Object} MigrationsCreateNHostMigrationRequestParams
|
|
371
|
+
* @property {string[]} resources List of resources to migrate
|
|
372
|
+
* @property {string} subdomain Source's Subdomain
|
|
373
|
+
* @property {string} region Source's Region
|
|
374
|
+
* @property {string} adminSecret Source's Admin Secret
|
|
375
|
+
* @property {string} database Source's Database Name
|
|
376
|
+
* @property {string} username Source's Database Username
|
|
377
|
+
* @property {string} password Source's Database Password
|
|
378
|
+
* @property {number} port Source's Database Port
|
|
379
|
+
* @property {boolean} parseOutput
|
|
380
|
+
* @property {libClient | undefined} sdk
|
|
381
|
+
*/
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* @param {MigrationsCreateNHostMigrationRequestParams} params
|
|
385
|
+
*/
|
|
275
386
|
const migrationsCreateNHostMigration = async ({ resources, subdomain, region, adminSecret, database, username, password, port, parseOutput = true, sdk = undefined}) => {
|
|
276
|
-
/* @param {string[]} resources */
|
|
277
|
-
/* @param {string} subdomain */
|
|
278
|
-
/* @param {string} region */
|
|
279
|
-
/* @param {string} adminSecret */
|
|
280
|
-
/* @param {string} database */
|
|
281
|
-
/* @param {string} username */
|
|
282
|
-
/* @param {string} password */
|
|
283
|
-
/* @param {number} port */
|
|
284
|
-
|
|
285
387
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
286
388
|
let apiPath = '/migrations/nhost';
|
|
287
389
|
let payload = {};
|
|
288
|
-
|
|
289
|
-
/** Body Params */
|
|
290
390
|
resources = resources === true ? [] : resources;
|
|
291
|
-
|
|
292
391
|
if (typeof resources !== 'undefined') {
|
|
293
392
|
payload['resources'] = resources;
|
|
294
393
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
394
|
if (typeof subdomain !== 'undefined') {
|
|
298
395
|
payload['subdomain'] = subdomain;
|
|
299
396
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
397
|
if (typeof region !== 'undefined') {
|
|
303
398
|
payload['region'] = region;
|
|
304
399
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
400
|
if (typeof adminSecret !== 'undefined') {
|
|
308
401
|
payload['adminSecret'] = adminSecret;
|
|
309
402
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
403
|
if (typeof database !== 'undefined') {
|
|
313
404
|
payload['database'] = database;
|
|
314
405
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
406
|
if (typeof username !== 'undefined') {
|
|
318
407
|
payload['username'] = username;
|
|
319
408
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
409
|
if (typeof password !== 'undefined') {
|
|
323
410
|
payload['password'] = password;
|
|
324
411
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
412
|
if (typeof port !== 'undefined') {
|
|
328
413
|
payload['port'] = port;
|
|
329
414
|
}
|
|
330
415
|
|
|
331
416
|
let response = undefined;
|
|
417
|
+
|
|
332
418
|
response = await client.call('post', apiPath, {
|
|
333
419
|
'content-type': 'application/json',
|
|
334
420
|
}, payload);
|
|
335
|
-
|
|
421
|
+
|
|
336
422
|
if (parseOutput) {
|
|
337
423
|
parse(response)
|
|
338
424
|
success()
|
|
339
425
|
}
|
|
426
|
+
|
|
340
427
|
return response;
|
|
341
428
|
}
|
|
342
429
|
|
|
430
|
+
/**
|
|
431
|
+
* @typedef {Object} MigrationsGetNHostReportRequestParams
|
|
432
|
+
* @property {string[]} resources List of resources to migrate.
|
|
433
|
+
* @property {string} subdomain Source's Subdomain.
|
|
434
|
+
* @property {string} region Source's Region.
|
|
435
|
+
* @property {string} adminSecret Source's Admin Secret.
|
|
436
|
+
* @property {string} database Source's Database Name.
|
|
437
|
+
* @property {string} username Source's Database Username.
|
|
438
|
+
* @property {string} password Source's Database Password.
|
|
439
|
+
* @property {number} port Source's Database Port.
|
|
440
|
+
* @property {boolean} parseOutput
|
|
441
|
+
* @property {libClient | undefined} sdk
|
|
442
|
+
*/
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* @param {MigrationsGetNHostReportRequestParams} params
|
|
446
|
+
*/
|
|
343
447
|
const migrationsGetNHostReport = async ({ resources, subdomain, region, adminSecret, database, username, password, port, parseOutput = true, sdk = undefined}) => {
|
|
344
|
-
/* @param {string[]} resources */
|
|
345
|
-
/* @param {string} subdomain */
|
|
346
|
-
/* @param {string} region */
|
|
347
|
-
/* @param {string} adminSecret */
|
|
348
|
-
/* @param {string} database */
|
|
349
|
-
/* @param {string} username */
|
|
350
|
-
/* @param {string} password */
|
|
351
|
-
/* @param {number} port */
|
|
352
|
-
|
|
353
448
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
354
449
|
let apiPath = '/migrations/nhost/report';
|
|
355
450
|
let payload = {};
|
|
356
|
-
|
|
357
|
-
/** Query Params */
|
|
358
451
|
if (typeof resources !== 'undefined') {
|
|
359
452
|
payload['resources'] = resources;
|
|
360
453
|
}
|
|
@@ -379,94 +472,98 @@ const migrationsGetNHostReport = async ({ resources, subdomain, region, adminSec
|
|
|
379
472
|
if (typeof port !== 'undefined') {
|
|
380
473
|
payload['port'] = port;
|
|
381
474
|
}
|
|
475
|
+
|
|
382
476
|
let response = undefined;
|
|
477
|
+
|
|
383
478
|
response = await client.call('get', apiPath, {
|
|
384
479
|
'content-type': 'application/json',
|
|
385
480
|
}, payload);
|
|
386
|
-
|
|
481
|
+
|
|
387
482
|
if (parseOutput) {
|
|
388
483
|
parse(response)
|
|
389
484
|
success()
|
|
390
485
|
}
|
|
486
|
+
|
|
391
487
|
return response;
|
|
392
488
|
}
|
|
393
489
|
|
|
490
|
+
/**
|
|
491
|
+
* @typedef {Object} MigrationsCreateSupabaseMigrationRequestParams
|
|
492
|
+
* @property {string[]} resources List of resources to migrate
|
|
493
|
+
* @property {string} endpoint Source's Supabase Endpoint
|
|
494
|
+
* @property {string} apiKey Source's API Key
|
|
495
|
+
* @property {string} databaseHost Source's Database Host
|
|
496
|
+
* @property {string} username Source's Database Username
|
|
497
|
+
* @property {string} password Source's Database Password
|
|
498
|
+
* @property {number} port Source's Database Port
|
|
499
|
+
* @property {boolean} parseOutput
|
|
500
|
+
* @property {libClient | undefined} sdk
|
|
501
|
+
*/
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* @param {MigrationsCreateSupabaseMigrationRequestParams} params
|
|
505
|
+
*/
|
|
394
506
|
const migrationsCreateSupabaseMigration = async ({ resources, endpoint, apiKey, databaseHost, username, password, port, parseOutput = true, sdk = undefined}) => {
|
|
395
|
-
/* @param {string[]} resources */
|
|
396
|
-
/* @param {string} endpoint */
|
|
397
|
-
/* @param {string} apiKey */
|
|
398
|
-
/* @param {string} databaseHost */
|
|
399
|
-
/* @param {string} username */
|
|
400
|
-
/* @param {string} password */
|
|
401
|
-
/* @param {number} port */
|
|
402
|
-
|
|
403
507
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
404
508
|
let apiPath = '/migrations/supabase';
|
|
405
509
|
let payload = {};
|
|
406
|
-
|
|
407
|
-
/** Body Params */
|
|
408
510
|
resources = resources === true ? [] : resources;
|
|
409
|
-
|
|
410
511
|
if (typeof resources !== 'undefined') {
|
|
411
512
|
payload['resources'] = resources;
|
|
412
513
|
}
|
|
413
|
-
|
|
414
|
-
|
|
415
514
|
if (typeof endpoint !== 'undefined') {
|
|
416
515
|
payload['endpoint'] = endpoint;
|
|
417
516
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
517
|
if (typeof apiKey !== 'undefined') {
|
|
421
518
|
payload['apiKey'] = apiKey;
|
|
422
519
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
520
|
if (typeof databaseHost !== 'undefined') {
|
|
426
521
|
payload['databaseHost'] = databaseHost;
|
|
427
522
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
523
|
if (typeof username !== 'undefined') {
|
|
431
524
|
payload['username'] = username;
|
|
432
525
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
526
|
if (typeof password !== 'undefined') {
|
|
436
527
|
payload['password'] = password;
|
|
437
528
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
529
|
if (typeof port !== 'undefined') {
|
|
441
530
|
payload['port'] = port;
|
|
442
531
|
}
|
|
443
532
|
|
|
444
533
|
let response = undefined;
|
|
534
|
+
|
|
445
535
|
response = await client.call('post', apiPath, {
|
|
446
536
|
'content-type': 'application/json',
|
|
447
537
|
}, payload);
|
|
448
|
-
|
|
538
|
+
|
|
449
539
|
if (parseOutput) {
|
|
450
540
|
parse(response)
|
|
451
541
|
success()
|
|
452
542
|
}
|
|
543
|
+
|
|
453
544
|
return response;
|
|
454
545
|
}
|
|
455
546
|
|
|
547
|
+
/**
|
|
548
|
+
* @typedef {Object} MigrationsGetSupabaseReportRequestParams
|
|
549
|
+
* @property {string[]} resources List of resources to migrate
|
|
550
|
+
* @property {string} endpoint Source's Supabase Endpoint.
|
|
551
|
+
* @property {string} apiKey Source's API Key.
|
|
552
|
+
* @property {string} databaseHost Source's Database Host.
|
|
553
|
+
* @property {string} username Source's Database Username.
|
|
554
|
+
* @property {string} password Source's Database Password.
|
|
555
|
+
* @property {number} port Source's Database Port.
|
|
556
|
+
* @property {boolean} parseOutput
|
|
557
|
+
* @property {libClient | undefined} sdk
|
|
558
|
+
*/
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* @param {MigrationsGetSupabaseReportRequestParams} params
|
|
562
|
+
*/
|
|
456
563
|
const migrationsGetSupabaseReport = async ({ resources, endpoint, apiKey, databaseHost, username, password, port, parseOutput = true, sdk = undefined}) => {
|
|
457
|
-
/* @param {string[]} resources */
|
|
458
|
-
/* @param {string} endpoint */
|
|
459
|
-
/* @param {string} apiKey */
|
|
460
|
-
/* @param {string} databaseHost */
|
|
461
|
-
/* @param {string} username */
|
|
462
|
-
/* @param {string} password */
|
|
463
|
-
/* @param {number} port */
|
|
464
|
-
|
|
465
564
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
466
565
|
let apiPath = '/migrations/supabase/report';
|
|
467
566
|
let payload = {};
|
|
468
|
-
|
|
469
|
-
/** Query Params */
|
|
470
567
|
if (typeof resources !== 'undefined') {
|
|
471
568
|
payload['resources'] = resources;
|
|
472
569
|
}
|
|
@@ -488,73 +585,108 @@ const migrationsGetSupabaseReport = async ({ resources, endpoint, apiKey, databa
|
|
|
488
585
|
if (typeof port !== 'undefined') {
|
|
489
586
|
payload['port'] = port;
|
|
490
587
|
}
|
|
588
|
+
|
|
491
589
|
let response = undefined;
|
|
590
|
+
|
|
492
591
|
response = await client.call('get', apiPath, {
|
|
493
592
|
'content-type': 'application/json',
|
|
494
593
|
}, payload);
|
|
495
|
-
|
|
594
|
+
|
|
496
595
|
if (parseOutput) {
|
|
497
596
|
parse(response)
|
|
498
597
|
success()
|
|
499
598
|
}
|
|
599
|
+
|
|
500
600
|
return response;
|
|
501
601
|
}
|
|
502
602
|
|
|
503
|
-
|
|
504
|
-
|
|
603
|
+
/**
|
|
604
|
+
* @typedef {Object} MigrationsGetRequestParams
|
|
605
|
+
* @property {string} migrationId Migration unique ID.
|
|
606
|
+
* @property {boolean} parseOutput
|
|
607
|
+
* @property {libClient | undefined} sdk
|
|
608
|
+
*/
|
|
505
609
|
|
|
610
|
+
/**
|
|
611
|
+
* @param {MigrationsGetRequestParams} params
|
|
612
|
+
*/
|
|
613
|
+
const migrationsGet = async ({ migrationId, parseOutput = true, sdk = undefined}) => {
|
|
506
614
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
507
615
|
let apiPath = '/migrations/{migrationId}'.replace('{migrationId}', migrationId);
|
|
508
616
|
let payload = {};
|
|
617
|
+
|
|
509
618
|
let response = undefined;
|
|
619
|
+
|
|
510
620
|
response = await client.call('get', apiPath, {
|
|
511
621
|
'content-type': 'application/json',
|
|
512
622
|
}, payload);
|
|
513
|
-
|
|
623
|
+
|
|
514
624
|
if (parseOutput) {
|
|
515
625
|
parse(response)
|
|
516
626
|
success()
|
|
517
627
|
}
|
|
628
|
+
|
|
518
629
|
return response;
|
|
519
630
|
}
|
|
520
631
|
|
|
521
|
-
|
|
522
|
-
|
|
632
|
+
/**
|
|
633
|
+
* @typedef {Object} MigrationsRetryRequestParams
|
|
634
|
+
* @property {string} migrationId Migration unique ID.
|
|
635
|
+
* @property {boolean} parseOutput
|
|
636
|
+
* @property {libClient | undefined} sdk
|
|
637
|
+
*/
|
|
523
638
|
|
|
639
|
+
/**
|
|
640
|
+
* @param {MigrationsRetryRequestParams} params
|
|
641
|
+
*/
|
|
642
|
+
const migrationsRetry = async ({ migrationId, parseOutput = true, sdk = undefined}) => {
|
|
524
643
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
525
644
|
let apiPath = '/migrations/{migrationId}'.replace('{migrationId}', migrationId);
|
|
526
645
|
let payload = {};
|
|
646
|
+
|
|
527
647
|
let response = undefined;
|
|
648
|
+
|
|
528
649
|
response = await client.call('patch', apiPath, {
|
|
529
650
|
'content-type': 'application/json',
|
|
530
651
|
}, payload);
|
|
531
|
-
|
|
652
|
+
|
|
532
653
|
if (parseOutput) {
|
|
533
654
|
parse(response)
|
|
534
655
|
success()
|
|
535
656
|
}
|
|
657
|
+
|
|
536
658
|
return response;
|
|
537
659
|
}
|
|
538
660
|
|
|
539
|
-
|
|
540
|
-
|
|
661
|
+
/**
|
|
662
|
+
* @typedef {Object} MigrationsDeleteRequestParams
|
|
663
|
+
* @property {string} migrationId Migration ID.
|
|
664
|
+
* @property {boolean} parseOutput
|
|
665
|
+
* @property {libClient | undefined} sdk
|
|
666
|
+
*/
|
|
541
667
|
|
|
668
|
+
/**
|
|
669
|
+
* @param {MigrationsDeleteRequestParams} params
|
|
670
|
+
*/
|
|
671
|
+
const migrationsDelete = async ({ migrationId, parseOutput = true, sdk = undefined}) => {
|
|
542
672
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
543
673
|
let apiPath = '/migrations/{migrationId}'.replace('{migrationId}', migrationId);
|
|
544
674
|
let payload = {};
|
|
675
|
+
|
|
545
676
|
let response = undefined;
|
|
677
|
+
|
|
546
678
|
response = await client.call('delete', apiPath, {
|
|
547
679
|
'content-type': 'application/json',
|
|
548
680
|
}, payload);
|
|
549
|
-
|
|
681
|
+
|
|
550
682
|
if (parseOutput) {
|
|
551
683
|
parse(response)
|
|
552
684
|
success()
|
|
553
685
|
}
|
|
686
|
+
|
|
554
687
|
return response;
|
|
555
688
|
}
|
|
556
689
|
|
|
557
|
-
|
|
558
690
|
migrations
|
|
559
691
|
.command(`list`)
|
|
560
692
|
.description(``)
|
|
@@ -686,7 +818,6 @@ migrations
|
|
|
686
818
|
.requiredOption(`--migrationId <migrationId>`, `Migration ID.`)
|
|
687
819
|
.action(actionRunner(migrationsDelete))
|
|
688
820
|
|
|
689
|
-
|
|
690
821
|
module.exports = {
|
|
691
822
|
migrations,
|
|
692
823
|
migrationsList,
|
|
@@ -705,4 +836,4 @@ module.exports = {
|
|
|
705
836
|
migrationsGet,
|
|
706
837
|
migrationsRetry,
|
|
707
838
|
migrationsDelete
|
|
708
|
-
};
|
|
839
|
+
};
|