appwrite-cli 4.1.0 → 4.2.1
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/docs/examples/health/get-queue-builds.md +2 -0
- package/docs/examples/health/get-queue-certificates.md +2 -1
- package/docs/examples/health/get-queue-databases.md +3 -0
- package/docs/examples/health/get-queue-deletes.md +2 -0
- package/docs/examples/health/get-queue-functions.md +2 -1
- package/docs/examples/health/get-queue-logs.md +2 -1
- package/docs/examples/health/get-queue-mails.md +2 -0
- package/docs/examples/health/get-queue-messaging.md +2 -0
- package/docs/examples/health/get-queue-migrations.md +2 -0
- package/docs/examples/health/get-queue-webhooks.md +2 -1
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.js +61 -74
- package/lib/commands/account.js +564 -210
- package/lib/commands/assistant.js +42 -7
- package/lib/commands/avatars.js +199 -83
- package/lib/commands/console.js +42 -3
- package/lib/commands/databases.js +991 -562
- package/lib/commands/deploy.js +170 -99
- package/lib/commands/functions.js +564 -294
- package/lib/commands/graphql.js +58 -11
- package/lib/commands/health.js +496 -26
- package/lib/commands/init.js +11 -23
- package/lib/commands/locale.js +154 -17
- package/lib/commands/migrations.js +328 -147
- package/lib/commands/project.js +128 -33
- package/lib/commands/projects.js +788 -411
- package/lib/commands/proxy.js +113 -28
- package/lib/commands/storage.js +438 -223
- package/lib/commands/teams.js +284 -108
- package/lib/commands/users.js +559 -271
- package/lib/commands/vcs.js +186 -53
- package/lib/paginate.js +51 -0
- package/lib/questions.js +7 -10
- package/package.json +9 -9
- package/scoop/appwrite.json +3 -3
package/lib/commands/init.js
CHANGED
|
@@ -10,6 +10,7 @@ const { databasesGet, databasesListCollections, databasesList } = require("./dat
|
|
|
10
10
|
const { storageListBuckets } = require("./storage");
|
|
11
11
|
const { sdkForConsole } = require("../sdks");
|
|
12
12
|
const { localConfig } = require("../config");
|
|
13
|
+
const { paginate } = require("../paginate");
|
|
13
14
|
const { questionsInitProject, questionsInitFunction, questionsInitCollection } = require("../questions");
|
|
14
15
|
const { success, log, actionRunner, commandDescriptions } = require("../parser");
|
|
15
16
|
|
|
@@ -24,11 +25,11 @@ const init = new Command("init")
|
|
|
24
25
|
|
|
25
26
|
const initProject = async () => {
|
|
26
27
|
let response = {}
|
|
27
|
-
|
|
28
|
+
const answers = await inquirer.prompt(questionsInitProject)
|
|
28
29
|
if (!answers.project) process.exit(1)
|
|
29
30
|
|
|
30
31
|
let sdk = await sdkForConsole();
|
|
31
|
-
if (answers.start
|
|
32
|
+
if (answers.start === "new") {
|
|
32
33
|
response = await teamsCreate({
|
|
33
34
|
teamId: 'unique()',
|
|
34
35
|
name: answers.project,
|
|
@@ -53,8 +54,8 @@ const initProject = async () => {
|
|
|
53
54
|
|
|
54
55
|
const initFunction = async () => {
|
|
55
56
|
// TODO: Add CI/CD support (ID, name, runtime)
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
const answers = await inquirer.prompt(questionsInitFunction)
|
|
58
|
+
const functionFolder = path.join(process.cwd(), 'functions');
|
|
58
59
|
|
|
59
60
|
if (!fs.existsSync(functionFolder)) {
|
|
60
61
|
fs.mkdirSync(functionFolder, {
|
|
@@ -92,7 +93,7 @@ const initFunction = async () => {
|
|
|
92
93
|
let gitPullCommands = `git sparse-checkout add ${answers.runtime.id}`;
|
|
93
94
|
|
|
94
95
|
/* Force use CMD as powershell does not support && */
|
|
95
|
-
if (process.platform
|
|
96
|
+
if (process.platform === 'win32') {
|
|
96
97
|
gitInitCommands = 'cmd /c "' + gitInitCommands + '"';
|
|
97
98
|
gitPullCommands = 'cmd /c "' + gitPullCommands + '"';
|
|
98
99
|
}
|
|
@@ -187,15 +188,12 @@ const initCollection = async ({ all, databaseId } = {}) => {
|
|
|
187
188
|
|
|
188
189
|
localConfig.addDatabase(database);
|
|
189
190
|
|
|
190
|
-
|
|
191
|
-
let response = await databasesListCollections({
|
|
191
|
+
const { collections, total } = await paginate(databasesListCollections, {
|
|
192
192
|
databaseId,
|
|
193
|
-
queries: ['limit(100)'],
|
|
194
193
|
parseOutput: false
|
|
195
|
-
})
|
|
194
|
+
}, 100, 'collections');
|
|
196
195
|
|
|
197
|
-
|
|
198
|
-
log(`Found ${collections.length} collections`);
|
|
196
|
+
log(`Found ${total} collections`);
|
|
199
197
|
|
|
200
198
|
collections.forEach(async collection => {
|
|
201
199
|
log(`Fetching ${collection.name} ...`);
|
|
@@ -211,13 +209,8 @@ const initCollection = async ({ all, databaseId } = {}) => {
|
|
|
211
209
|
}
|
|
212
210
|
|
|
213
211
|
const initBucket = async () => {
|
|
214
|
-
|
|
215
|
-
let response = await storageListBuckets({
|
|
216
|
-
queries: ['limit(100)'],
|
|
217
|
-
parseOutput: false
|
|
218
|
-
})
|
|
212
|
+
const { buckets } = await paginate(storageListBuckets, { parseOutput: false }, 100, 'buckets');
|
|
219
213
|
|
|
220
|
-
let buckets = response.buckets;
|
|
221
214
|
log(`Found ${buckets.length} buckets`);
|
|
222
215
|
|
|
223
216
|
buckets.forEach(async bucket => {
|
|
@@ -229,13 +222,8 @@ const initBucket = async () => {
|
|
|
229
222
|
}
|
|
230
223
|
|
|
231
224
|
const initTeam = async () => {
|
|
232
|
-
|
|
233
|
-
let response = await teamsList({
|
|
234
|
-
queries: ['limit(100)'],
|
|
235
|
-
parseOutput: false
|
|
236
|
-
})
|
|
225
|
+
const { teams } = await paginate(teamsList, { parseOutput: false }, 100, 'teams');
|
|
237
226
|
|
|
238
|
-
let teams = response.teams;
|
|
239
227
|
log(`Found ${teams.length} teams`);
|
|
240
228
|
|
|
241
229
|
teams.forEach(async team => {
|
package/lib/commands/locale.js
CHANGED
|
@@ -9,144 +9,281 @@ 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 locale = new Command("locale").description(commandDescriptions['locale']).configureHelp({
|
|
14
39
|
helpWidth: process.stdout.columns || 80
|
|
15
40
|
})
|
|
16
41
|
|
|
17
|
-
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {Object} LocaleGetRequestParams
|
|
44
|
+
* @property {boolean} parseOutput
|
|
45
|
+
* @property {libClient | undefined} sdk
|
|
46
|
+
*/
|
|
18
47
|
|
|
48
|
+
/**
|
|
49
|
+
* @param {LocaleGetRequestParams} params
|
|
50
|
+
*/
|
|
51
|
+
const localeGet = async ({ parseOutput = true, sdk = undefined}) => {
|
|
19
52
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
53
|
+
|
|
20
54
|
let apiPath = '/locale';
|
|
21
55
|
let payload = {};
|
|
56
|
+
|
|
57
|
+
|
|
22
58
|
let response = undefined;
|
|
59
|
+
|
|
23
60
|
response = await client.call('get', apiPath, {
|
|
24
61
|
'content-type': 'application/json',
|
|
25
62
|
}, payload);
|
|
63
|
+
|
|
26
64
|
|
|
27
65
|
if (parseOutput) {
|
|
28
66
|
parse(response)
|
|
29
67
|
success()
|
|
30
68
|
}
|
|
69
|
+
|
|
31
70
|
return response;
|
|
32
71
|
}
|
|
33
72
|
|
|
34
|
-
|
|
73
|
+
/**
|
|
74
|
+
* @typedef {Object} LocaleListCodesRequestParams
|
|
75
|
+
* @property {boolean} parseOutput
|
|
76
|
+
* @property {libClient | undefined} sdk
|
|
77
|
+
*/
|
|
35
78
|
|
|
79
|
+
/**
|
|
80
|
+
* @param {LocaleListCodesRequestParams} params
|
|
81
|
+
*/
|
|
82
|
+
const localeListCodes = async ({ parseOutput = true, sdk = undefined}) => {
|
|
36
83
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
84
|
+
|
|
37
85
|
let apiPath = '/locale/codes';
|
|
38
86
|
let payload = {};
|
|
87
|
+
|
|
88
|
+
|
|
39
89
|
let response = undefined;
|
|
90
|
+
|
|
40
91
|
response = await client.call('get', apiPath, {
|
|
41
92
|
'content-type': 'application/json',
|
|
42
93
|
}, payload);
|
|
94
|
+
|
|
43
95
|
|
|
44
96
|
if (parseOutput) {
|
|
45
97
|
parse(response)
|
|
46
98
|
success()
|
|
47
99
|
}
|
|
100
|
+
|
|
48
101
|
return response;
|
|
49
102
|
}
|
|
50
103
|
|
|
51
|
-
|
|
104
|
+
/**
|
|
105
|
+
* @typedef {Object} LocaleListContinentsRequestParams
|
|
106
|
+
* @property {boolean} parseOutput
|
|
107
|
+
* @property {libClient | undefined} sdk
|
|
108
|
+
*/
|
|
52
109
|
|
|
110
|
+
/**
|
|
111
|
+
* @param {LocaleListContinentsRequestParams} params
|
|
112
|
+
*/
|
|
113
|
+
const localeListContinents = async ({ parseOutput = true, sdk = undefined}) => {
|
|
53
114
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
115
|
+
|
|
54
116
|
let apiPath = '/locale/continents';
|
|
55
117
|
let payload = {};
|
|
118
|
+
|
|
119
|
+
|
|
56
120
|
let response = undefined;
|
|
121
|
+
|
|
57
122
|
response = await client.call('get', apiPath, {
|
|
58
123
|
'content-type': 'application/json',
|
|
59
124
|
}, payload);
|
|
125
|
+
|
|
60
126
|
|
|
61
127
|
if (parseOutput) {
|
|
62
128
|
parse(response)
|
|
63
129
|
success()
|
|
64
130
|
}
|
|
131
|
+
|
|
65
132
|
return response;
|
|
66
133
|
}
|
|
67
134
|
|
|
68
|
-
|
|
135
|
+
/**
|
|
136
|
+
* @typedef {Object} LocaleListCountriesRequestParams
|
|
137
|
+
* @property {boolean} parseOutput
|
|
138
|
+
* @property {libClient | undefined} sdk
|
|
139
|
+
*/
|
|
69
140
|
|
|
141
|
+
/**
|
|
142
|
+
* @param {LocaleListCountriesRequestParams} params
|
|
143
|
+
*/
|
|
144
|
+
const localeListCountries = async ({ parseOutput = true, sdk = undefined}) => {
|
|
70
145
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
146
|
+
|
|
71
147
|
let apiPath = '/locale/countries';
|
|
72
148
|
let payload = {};
|
|
149
|
+
|
|
150
|
+
|
|
73
151
|
let response = undefined;
|
|
152
|
+
|
|
74
153
|
response = await client.call('get', apiPath, {
|
|
75
154
|
'content-type': 'application/json',
|
|
76
155
|
}, payload);
|
|
156
|
+
|
|
77
157
|
|
|
78
158
|
if (parseOutput) {
|
|
79
159
|
parse(response)
|
|
80
160
|
success()
|
|
81
161
|
}
|
|
162
|
+
|
|
82
163
|
return response;
|
|
83
164
|
}
|
|
84
165
|
|
|
85
|
-
|
|
166
|
+
/**
|
|
167
|
+
* @typedef {Object} LocaleListCountriesEURequestParams
|
|
168
|
+
* @property {boolean} parseOutput
|
|
169
|
+
* @property {libClient | undefined} sdk
|
|
170
|
+
*/
|
|
86
171
|
|
|
172
|
+
/**
|
|
173
|
+
* @param {LocaleListCountriesEURequestParams} params
|
|
174
|
+
*/
|
|
175
|
+
const localeListCountriesEU = async ({ parseOutput = true, sdk = undefined}) => {
|
|
87
176
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
177
|
+
|
|
88
178
|
let apiPath = '/locale/countries/eu';
|
|
89
179
|
let payload = {};
|
|
180
|
+
|
|
181
|
+
|
|
90
182
|
let response = undefined;
|
|
183
|
+
|
|
91
184
|
response = await client.call('get', apiPath, {
|
|
92
185
|
'content-type': 'application/json',
|
|
93
186
|
}, payload);
|
|
187
|
+
|
|
94
188
|
|
|
95
189
|
if (parseOutput) {
|
|
96
190
|
parse(response)
|
|
97
191
|
success()
|
|
98
192
|
}
|
|
193
|
+
|
|
99
194
|
return response;
|
|
100
195
|
}
|
|
101
196
|
|
|
102
|
-
|
|
197
|
+
/**
|
|
198
|
+
* @typedef {Object} LocaleListCountriesPhonesRequestParams
|
|
199
|
+
* @property {boolean} parseOutput
|
|
200
|
+
* @property {libClient | undefined} sdk
|
|
201
|
+
*/
|
|
103
202
|
|
|
203
|
+
/**
|
|
204
|
+
* @param {LocaleListCountriesPhonesRequestParams} params
|
|
205
|
+
*/
|
|
206
|
+
const localeListCountriesPhones = async ({ parseOutput = true, sdk = undefined}) => {
|
|
104
207
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
208
|
+
|
|
105
209
|
let apiPath = '/locale/countries/phones';
|
|
106
210
|
let payload = {};
|
|
211
|
+
|
|
212
|
+
|
|
107
213
|
let response = undefined;
|
|
214
|
+
|
|
108
215
|
response = await client.call('get', apiPath, {
|
|
109
216
|
'content-type': 'application/json',
|
|
110
217
|
}, payload);
|
|
218
|
+
|
|
111
219
|
|
|
112
220
|
if (parseOutput) {
|
|
113
221
|
parse(response)
|
|
114
222
|
success()
|
|
115
223
|
}
|
|
224
|
+
|
|
116
225
|
return response;
|
|
117
226
|
}
|
|
118
227
|
|
|
119
|
-
|
|
228
|
+
/**
|
|
229
|
+
* @typedef {Object} LocaleListCurrenciesRequestParams
|
|
230
|
+
* @property {boolean} parseOutput
|
|
231
|
+
* @property {libClient | undefined} sdk
|
|
232
|
+
*/
|
|
120
233
|
|
|
234
|
+
/**
|
|
235
|
+
* @param {LocaleListCurrenciesRequestParams} params
|
|
236
|
+
*/
|
|
237
|
+
const localeListCurrencies = async ({ parseOutput = true, sdk = undefined}) => {
|
|
121
238
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
239
|
+
|
|
122
240
|
let apiPath = '/locale/currencies';
|
|
123
241
|
let payload = {};
|
|
242
|
+
|
|
243
|
+
|
|
124
244
|
let response = undefined;
|
|
245
|
+
|
|
125
246
|
response = await client.call('get', apiPath, {
|
|
126
247
|
'content-type': 'application/json',
|
|
127
248
|
}, payload);
|
|
249
|
+
|
|
128
250
|
|
|
129
251
|
if (parseOutput) {
|
|
130
252
|
parse(response)
|
|
131
253
|
success()
|
|
132
254
|
}
|
|
255
|
+
|
|
133
256
|
return response;
|
|
134
257
|
}
|
|
135
258
|
|
|
136
|
-
|
|
259
|
+
/**
|
|
260
|
+
* @typedef {Object} LocaleListLanguagesRequestParams
|
|
261
|
+
* @property {boolean} parseOutput
|
|
262
|
+
* @property {libClient | undefined} sdk
|
|
263
|
+
*/
|
|
137
264
|
|
|
265
|
+
/**
|
|
266
|
+
* @param {LocaleListLanguagesRequestParams} params
|
|
267
|
+
*/
|
|
268
|
+
const localeListLanguages = async ({ parseOutput = true, sdk = undefined}) => {
|
|
138
269
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
270
|
+
|
|
139
271
|
let apiPath = '/locale/languages';
|
|
140
272
|
let payload = {};
|
|
273
|
+
|
|
274
|
+
|
|
141
275
|
let response = undefined;
|
|
276
|
+
|
|
142
277
|
response = await client.call('get', apiPath, {
|
|
143
278
|
'content-type': 'application/json',
|
|
144
279
|
}, payload);
|
|
280
|
+
|
|
145
281
|
|
|
146
282
|
if (parseOutput) {
|
|
147
283
|
parse(response)
|
|
148
284
|
success()
|
|
149
285
|
}
|
|
286
|
+
|
|
150
287
|
return response;
|
|
151
288
|
}
|
|
152
289
|
|
|
@@ -194,12 +331,12 @@ locale
|
|
|
194
331
|
|
|
195
332
|
module.exports = {
|
|
196
333
|
locale,
|
|
197
|
-
localeGet,
|
|
198
|
-
localeListCodes,
|
|
199
|
-
localeListContinents,
|
|
200
|
-
localeListCountries,
|
|
201
|
-
localeListCountriesEU,
|
|
202
|
-
localeListCountriesPhones,
|
|
203
|
-
localeListCurrencies,
|
|
204
|
-
localeListLanguages
|
|
205
|
-
};
|
|
334
|
+
localeGet,
|
|
335
|
+
localeListCodes,
|
|
336
|
+
localeListContinents,
|
|
337
|
+
localeListCountries,
|
|
338
|
+
localeListCountriesEU,
|
|
339
|
+
localeListCountriesPhones,
|
|
340
|
+
localeListCurrencies,
|
|
341
|
+
localeListLanguages
|
|
342
|
+
};
|