appwrite-cli 4.2.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/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.js +61 -74
- package/lib/commands/account.js +550 -196
- package/lib/commands/assistant.js +42 -7
- package/lib/commands/avatars.js +197 -81
- package/lib/commands/console.js +42 -3
- package/lib/commands/databases.js +981 -552
- package/lib/commands/functions.js +561 -291
- package/lib/commands/graphql.js +58 -11
- package/lib/commands/health.js +325 -68
- 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 +422 -207
- package/lib/commands/teams.js +279 -103
- package/lib/commands/users.js +550 -262
- package/lib/commands/vcs.js +186 -53
- package/package.json +9 -9
- package/scoop/appwrite.json +3 -3
package/lib/commands/project.js
CHANGED
|
@@ -9,147 +9,242 @@ 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 project = new Command("project").description(commandDescriptions['project']).configureHelp({
|
|
14
39
|
helpWidth: process.stdout.columns || 80
|
|
15
40
|
})
|
|
16
41
|
|
|
17
|
-
|
|
18
|
-
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {Object} ProjectGetUsageRequestParams
|
|
44
|
+
* @property {string} range Date range.
|
|
45
|
+
* @property {boolean} parseOutput
|
|
46
|
+
* @property {libClient | undefined} sdk
|
|
47
|
+
*/
|
|
19
48
|
|
|
49
|
+
/**
|
|
50
|
+
* @param {ProjectGetUsageRequestParams} params
|
|
51
|
+
*/
|
|
52
|
+
const projectGetUsage = async ({ range, parseOutput = true, sdk = undefined}) => {
|
|
20
53
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
54
|
+
|
|
21
55
|
let apiPath = '/project/usage';
|
|
22
56
|
let payload = {};
|
|
23
|
-
|
|
24
|
-
/** Query Params */
|
|
25
57
|
if (typeof range !== 'undefined') {
|
|
26
58
|
payload['range'] = range;
|
|
27
59
|
}
|
|
60
|
+
|
|
61
|
+
|
|
28
62
|
let response = undefined;
|
|
63
|
+
|
|
29
64
|
response = await client.call('get', apiPath, {
|
|
30
65
|
'content-type': 'application/json',
|
|
31
66
|
}, payload);
|
|
67
|
+
|
|
32
68
|
|
|
33
69
|
if (parseOutput) {
|
|
34
70
|
parse(response)
|
|
35
71
|
success()
|
|
36
72
|
}
|
|
73
|
+
|
|
37
74
|
return response;
|
|
38
75
|
}
|
|
39
76
|
|
|
40
|
-
|
|
77
|
+
/**
|
|
78
|
+
* @typedef {Object} ProjectListVariablesRequestParams
|
|
79
|
+
* @property {boolean} parseOutput
|
|
80
|
+
* @property {libClient | undefined} sdk
|
|
81
|
+
*/
|
|
41
82
|
|
|
83
|
+
/**
|
|
84
|
+
* @param {ProjectListVariablesRequestParams} params
|
|
85
|
+
*/
|
|
86
|
+
const projectListVariables = async ({ parseOutput = true, sdk = undefined}) => {
|
|
42
87
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
88
|
+
|
|
43
89
|
let apiPath = '/project/variables';
|
|
44
90
|
let payload = {};
|
|
91
|
+
|
|
92
|
+
|
|
45
93
|
let response = undefined;
|
|
94
|
+
|
|
46
95
|
response = await client.call('get', apiPath, {
|
|
47
96
|
'content-type': 'application/json',
|
|
48
97
|
}, payload);
|
|
98
|
+
|
|
49
99
|
|
|
50
100
|
if (parseOutput) {
|
|
51
101
|
parse(response)
|
|
52
102
|
success()
|
|
53
103
|
}
|
|
104
|
+
|
|
54
105
|
return response;
|
|
55
106
|
}
|
|
56
107
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
108
|
+
/**
|
|
109
|
+
* @typedef {Object} ProjectCreateVariableRequestParams
|
|
110
|
+
* @property {string} key Variable key. Max length: 255 chars.
|
|
111
|
+
* @property {string} value Variable value. Max length: 8192 chars.
|
|
112
|
+
* @property {boolean} parseOutput
|
|
113
|
+
* @property {libClient | undefined} sdk
|
|
114
|
+
*/
|
|
60
115
|
|
|
116
|
+
/**
|
|
117
|
+
* @param {ProjectCreateVariableRequestParams} params
|
|
118
|
+
*/
|
|
119
|
+
const projectCreateVariable = async ({ key, value, parseOutput = true, sdk = undefined}) => {
|
|
61
120
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
121
|
+
|
|
62
122
|
let apiPath = '/project/variables';
|
|
63
123
|
let payload = {};
|
|
64
|
-
|
|
65
|
-
/** Body Params */
|
|
66
|
-
|
|
67
124
|
if (typeof key !== 'undefined') {
|
|
68
125
|
payload['key'] = key;
|
|
69
126
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
127
|
if (typeof value !== 'undefined') {
|
|
73
128
|
payload['value'] = value;
|
|
74
129
|
}
|
|
75
130
|
|
|
131
|
+
|
|
76
132
|
let response = undefined;
|
|
133
|
+
|
|
77
134
|
response = await client.call('post', apiPath, {
|
|
78
135
|
'content-type': 'application/json',
|
|
79
136
|
}, payload);
|
|
137
|
+
|
|
80
138
|
|
|
81
139
|
if (parseOutput) {
|
|
82
140
|
parse(response)
|
|
83
141
|
success()
|
|
84
142
|
}
|
|
143
|
+
|
|
85
144
|
return response;
|
|
86
145
|
}
|
|
87
146
|
|
|
88
|
-
|
|
89
|
-
|
|
147
|
+
/**
|
|
148
|
+
* @typedef {Object} ProjectGetVariableRequestParams
|
|
149
|
+
* @property {string} variableId Variable unique ID.
|
|
150
|
+
* @property {boolean} parseOutput
|
|
151
|
+
* @property {libClient | undefined} sdk
|
|
152
|
+
*/
|
|
90
153
|
|
|
154
|
+
/**
|
|
155
|
+
* @param {ProjectGetVariableRequestParams} params
|
|
156
|
+
*/
|
|
157
|
+
const projectGetVariable = async ({ variableId, parseOutput = true, sdk = undefined}) => {
|
|
91
158
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
159
|
+
|
|
92
160
|
let apiPath = '/project/variables/{variableId}'.replace('{variableId}', variableId);
|
|
93
161
|
let payload = {};
|
|
162
|
+
|
|
163
|
+
|
|
94
164
|
let response = undefined;
|
|
165
|
+
|
|
95
166
|
response = await client.call('get', apiPath, {
|
|
96
167
|
'content-type': 'application/json',
|
|
97
168
|
}, payload);
|
|
169
|
+
|
|
98
170
|
|
|
99
171
|
if (parseOutput) {
|
|
100
172
|
parse(response)
|
|
101
173
|
success()
|
|
102
174
|
}
|
|
175
|
+
|
|
103
176
|
return response;
|
|
104
177
|
}
|
|
105
178
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
179
|
+
/**
|
|
180
|
+
* @typedef {Object} ProjectUpdateVariableRequestParams
|
|
181
|
+
* @property {string} variableId Variable unique ID.
|
|
182
|
+
* @property {string} key Variable key. Max length: 255 chars.
|
|
183
|
+
* @property {string} value Variable value. Max length: 8192 chars.
|
|
184
|
+
* @property {boolean} parseOutput
|
|
185
|
+
* @property {libClient | undefined} sdk
|
|
186
|
+
*/
|
|
110
187
|
|
|
188
|
+
/**
|
|
189
|
+
* @param {ProjectUpdateVariableRequestParams} params
|
|
190
|
+
*/
|
|
191
|
+
const projectUpdateVariable = async ({ variableId, key, value, parseOutput = true, sdk = undefined}) => {
|
|
111
192
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
193
|
+
|
|
112
194
|
let apiPath = '/project/variables/{variableId}'.replace('{variableId}', variableId);
|
|
113
195
|
let payload = {};
|
|
114
|
-
|
|
115
|
-
/** Body Params */
|
|
116
|
-
|
|
117
196
|
if (typeof key !== 'undefined') {
|
|
118
197
|
payload['key'] = key;
|
|
119
198
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
199
|
if (typeof value !== 'undefined') {
|
|
123
200
|
payload['value'] = value;
|
|
124
201
|
}
|
|
125
202
|
|
|
203
|
+
|
|
126
204
|
let response = undefined;
|
|
205
|
+
|
|
127
206
|
response = await client.call('put', apiPath, {
|
|
128
207
|
'content-type': 'application/json',
|
|
129
208
|
}, payload);
|
|
209
|
+
|
|
130
210
|
|
|
131
211
|
if (parseOutput) {
|
|
132
212
|
parse(response)
|
|
133
213
|
success()
|
|
134
214
|
}
|
|
215
|
+
|
|
135
216
|
return response;
|
|
136
217
|
}
|
|
137
218
|
|
|
138
|
-
|
|
139
|
-
|
|
219
|
+
/**
|
|
220
|
+
* @typedef {Object} ProjectDeleteVariableRequestParams
|
|
221
|
+
* @property {string} variableId Variable unique ID.
|
|
222
|
+
* @property {boolean} parseOutput
|
|
223
|
+
* @property {libClient | undefined} sdk
|
|
224
|
+
*/
|
|
140
225
|
|
|
226
|
+
/**
|
|
227
|
+
* @param {ProjectDeleteVariableRequestParams} params
|
|
228
|
+
*/
|
|
229
|
+
const projectDeleteVariable = async ({ variableId, parseOutput = true, sdk = undefined}) => {
|
|
141
230
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
231
|
+
|
|
142
232
|
let apiPath = '/project/variables/{variableId}'.replace('{variableId}', variableId);
|
|
143
233
|
let payload = {};
|
|
234
|
+
|
|
235
|
+
|
|
144
236
|
let response = undefined;
|
|
237
|
+
|
|
145
238
|
response = await client.call('delete', apiPath, {
|
|
146
239
|
'content-type': 'application/json',
|
|
147
240
|
}, payload);
|
|
241
|
+
|
|
148
242
|
|
|
149
243
|
if (parseOutput) {
|
|
150
244
|
parse(response)
|
|
151
245
|
success()
|
|
152
246
|
}
|
|
247
|
+
|
|
153
248
|
return response;
|
|
154
249
|
}
|
|
155
250
|
|
|
@@ -195,10 +290,10 @@ project
|
|
|
195
290
|
|
|
196
291
|
module.exports = {
|
|
197
292
|
project,
|
|
198
|
-
projectGetUsage,
|
|
199
|
-
projectListVariables,
|
|
200
|
-
projectCreateVariable,
|
|
201
|
-
projectGetVariable,
|
|
202
|
-
projectUpdateVariable,
|
|
203
|
-
projectDeleteVariable
|
|
204
|
-
};
|
|
293
|
+
projectGetUsage,
|
|
294
|
+
projectListVariables,
|
|
295
|
+
projectCreateVariable,
|
|
296
|
+
projectGetVariable,
|
|
297
|
+
projectUpdateVariable,
|
|
298
|
+
projectDeleteVariable
|
|
299
|
+
};
|