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/proxy.js
CHANGED
|
@@ -9,126 +9,211 @@ 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 proxy = new Command("proxy").description(commandDescriptions['proxy']).configureHelp({
|
|
14
39
|
helpWidth: process.stdout.columns || 80
|
|
15
40
|
})
|
|
16
41
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {Object} ProxyListRulesRequestParams
|
|
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: domain, resourceType, resourceId, url
|
|
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
|
+
*/
|
|
20
49
|
|
|
50
|
+
/**
|
|
51
|
+
* @param {ProxyListRulesRequestParams} params
|
|
52
|
+
*/
|
|
53
|
+
const proxyListRules = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
|
|
21
54
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
55
|
+
|
|
22
56
|
let apiPath = '/proxy/rules';
|
|
23
57
|
let payload = {};
|
|
24
|
-
|
|
25
|
-
/** Query Params */
|
|
26
58
|
if (typeof queries !== 'undefined') {
|
|
27
59
|
payload['queries'] = queries;
|
|
28
60
|
}
|
|
29
61
|
if (typeof search !== 'undefined') {
|
|
30
62
|
payload['search'] = search;
|
|
31
63
|
}
|
|
64
|
+
|
|
65
|
+
|
|
32
66
|
let response = undefined;
|
|
67
|
+
|
|
33
68
|
response = await client.call('get', apiPath, {
|
|
34
69
|
'content-type': 'application/json',
|
|
35
70
|
}, payload);
|
|
71
|
+
|
|
36
72
|
|
|
37
73
|
if (parseOutput) {
|
|
38
74
|
parse(response)
|
|
39
75
|
success()
|
|
40
76
|
}
|
|
77
|
+
|
|
41
78
|
return response;
|
|
42
79
|
}
|
|
43
80
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
81
|
+
/**
|
|
82
|
+
* @typedef {Object} ProxyCreateRuleRequestParams
|
|
83
|
+
* @property {string} domain Domain name.
|
|
84
|
+
* @property {string} resourceType Action definition for the rule. Possible values are "api", "function"
|
|
85
|
+
* @property {string} resourceId ID of resource for the action type. If resourceType is "api", leave empty. If resourceType is "function", provide ID of the function.
|
|
86
|
+
* @property {boolean} parseOutput
|
|
87
|
+
* @property {libClient | undefined} sdk
|
|
88
|
+
*/
|
|
48
89
|
|
|
90
|
+
/**
|
|
91
|
+
* @param {ProxyCreateRuleRequestParams} params
|
|
92
|
+
*/
|
|
93
|
+
const proxyCreateRule = async ({ domain, resourceType, resourceId, parseOutput = true, sdk = undefined}) => {
|
|
49
94
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
95
|
+
|
|
50
96
|
let apiPath = '/proxy/rules';
|
|
51
97
|
let payload = {};
|
|
52
|
-
|
|
53
|
-
/** Body Params */
|
|
54
|
-
|
|
55
98
|
if (typeof domain !== 'undefined') {
|
|
56
99
|
payload['domain'] = domain;
|
|
57
100
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
101
|
if (typeof resourceType !== 'undefined') {
|
|
61
102
|
payload['resourceType'] = resourceType;
|
|
62
103
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
104
|
if (typeof resourceId !== 'undefined') {
|
|
66
105
|
payload['resourceId'] = resourceId;
|
|
67
106
|
}
|
|
68
107
|
|
|
108
|
+
|
|
69
109
|
let response = undefined;
|
|
110
|
+
|
|
70
111
|
response = await client.call('post', apiPath, {
|
|
71
112
|
'content-type': 'application/json',
|
|
72
113
|
}, payload);
|
|
114
|
+
|
|
73
115
|
|
|
74
116
|
if (parseOutput) {
|
|
75
117
|
parse(response)
|
|
76
118
|
success()
|
|
77
119
|
}
|
|
120
|
+
|
|
78
121
|
return response;
|
|
79
122
|
}
|
|
80
123
|
|
|
81
|
-
|
|
82
|
-
|
|
124
|
+
/**
|
|
125
|
+
* @typedef {Object} ProxyGetRuleRequestParams
|
|
126
|
+
* @property {string} ruleId Rule ID.
|
|
127
|
+
* @property {boolean} parseOutput
|
|
128
|
+
* @property {libClient | undefined} sdk
|
|
129
|
+
*/
|
|
83
130
|
|
|
131
|
+
/**
|
|
132
|
+
* @param {ProxyGetRuleRequestParams} params
|
|
133
|
+
*/
|
|
134
|
+
const proxyGetRule = async ({ ruleId, parseOutput = true, sdk = undefined}) => {
|
|
84
135
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
136
|
+
|
|
85
137
|
let apiPath = '/proxy/rules/{ruleId}'.replace('{ruleId}', ruleId);
|
|
86
138
|
let payload = {};
|
|
139
|
+
|
|
140
|
+
|
|
87
141
|
let response = undefined;
|
|
142
|
+
|
|
88
143
|
response = await client.call('get', apiPath, {
|
|
89
144
|
'content-type': 'application/json',
|
|
90
145
|
}, payload);
|
|
146
|
+
|
|
91
147
|
|
|
92
148
|
if (parseOutput) {
|
|
93
149
|
parse(response)
|
|
94
150
|
success()
|
|
95
151
|
}
|
|
152
|
+
|
|
96
153
|
return response;
|
|
97
154
|
}
|
|
98
155
|
|
|
99
|
-
|
|
100
|
-
|
|
156
|
+
/**
|
|
157
|
+
* @typedef {Object} ProxyDeleteRuleRequestParams
|
|
158
|
+
* @property {string} ruleId Rule ID.
|
|
159
|
+
* @property {boolean} parseOutput
|
|
160
|
+
* @property {libClient | undefined} sdk
|
|
161
|
+
*/
|
|
101
162
|
|
|
163
|
+
/**
|
|
164
|
+
* @param {ProxyDeleteRuleRequestParams} params
|
|
165
|
+
*/
|
|
166
|
+
const proxyDeleteRule = async ({ ruleId, parseOutput = true, sdk = undefined}) => {
|
|
102
167
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
168
|
+
|
|
103
169
|
let apiPath = '/proxy/rules/{ruleId}'.replace('{ruleId}', ruleId);
|
|
104
170
|
let payload = {};
|
|
171
|
+
|
|
172
|
+
|
|
105
173
|
let response = undefined;
|
|
174
|
+
|
|
106
175
|
response = await client.call('delete', apiPath, {
|
|
107
176
|
'content-type': 'application/json',
|
|
108
177
|
}, payload);
|
|
178
|
+
|
|
109
179
|
|
|
110
180
|
if (parseOutput) {
|
|
111
181
|
parse(response)
|
|
112
182
|
success()
|
|
113
183
|
}
|
|
184
|
+
|
|
114
185
|
return response;
|
|
115
186
|
}
|
|
116
187
|
|
|
117
|
-
|
|
118
|
-
|
|
188
|
+
/**
|
|
189
|
+
* @typedef {Object} ProxyUpdateRuleVerificationRequestParams
|
|
190
|
+
* @property {string} ruleId Rule ID.
|
|
191
|
+
* @property {boolean} parseOutput
|
|
192
|
+
* @property {libClient | undefined} sdk
|
|
193
|
+
*/
|
|
119
194
|
|
|
195
|
+
/**
|
|
196
|
+
* @param {ProxyUpdateRuleVerificationRequestParams} params
|
|
197
|
+
*/
|
|
198
|
+
const proxyUpdateRuleVerification = async ({ ruleId, parseOutput = true, sdk = undefined}) => {
|
|
120
199
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
200
|
+
|
|
121
201
|
let apiPath = '/proxy/rules/{ruleId}/verification'.replace('{ruleId}', ruleId);
|
|
122
202
|
let payload = {};
|
|
203
|
+
|
|
204
|
+
|
|
123
205
|
let response = undefined;
|
|
206
|
+
|
|
124
207
|
response = await client.call('patch', apiPath, {
|
|
125
208
|
'content-type': 'application/json',
|
|
126
209
|
}, payload);
|
|
210
|
+
|
|
127
211
|
|
|
128
212
|
if (parseOutput) {
|
|
129
213
|
parse(response)
|
|
130
214
|
success()
|
|
131
215
|
}
|
|
216
|
+
|
|
132
217
|
return response;
|
|
133
218
|
}
|
|
134
219
|
|
|
@@ -169,9 +254,9 @@ proxy
|
|
|
169
254
|
|
|
170
255
|
module.exports = {
|
|
171
256
|
proxy,
|
|
172
|
-
proxyListRules,
|
|
173
|
-
proxyCreateRule,
|
|
174
|
-
proxyGetRule,
|
|
175
|
-
proxyDeleteRule,
|
|
176
|
-
proxyUpdateRuleVerification
|
|
177
|
-
};
|
|
257
|
+
proxyListRules,
|
|
258
|
+
proxyCreateRule,
|
|
259
|
+
proxyGetRule,
|
|
260
|
+
proxyDeleteRule,
|
|
261
|
+
proxyUpdateRuleVerification
|
|
262
|
+
};
|