appwrite-cli 13.0.0 → 13.0.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/CHANGELOG.md +5 -0
- package/README.md +3 -3
- package/dist/bundle.cjs +49824 -48429
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/lib/client.js +3 -4
- package/dist/lib/client.js.map +1 -1
- package/dist/lib/commands/config.d.ts +90 -1
- package/dist/lib/commands/config.d.ts.map +1 -1
- package/dist/lib/commands/config.js +5 -4
- package/dist/lib/commands/config.js.map +1 -1
- package/dist/lib/commands/pull.d.ts.map +1 -1
- package/dist/lib/commands/pull.js +15 -9
- package/dist/lib/commands/pull.js.map +1 -1
- package/dist/lib/commands/push.d.ts.map +1 -1
- package/dist/lib/commands/push.js +8 -5
- package/dist/lib/commands/push.js.map +1 -1
- package/dist/lib/commands/services/projects.js +7 -1
- package/dist/lib/commands/services/projects.js.map +1 -1
- package/dist/lib/commands/services/storage.js +2 -2
- package/dist/lib/commands/services/storage.js.map +1 -1
- package/dist/lib/commands/utils/attributes.d.ts +5 -2
- package/dist/lib/commands/utils/attributes.d.ts.map +1 -1
- package/dist/lib/commands/utils/attributes.js +16 -7
- package/dist/lib/commands/utils/attributes.js.map +1 -1
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +9 -10
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/constants.d.ts +1 -1
- package/dist/lib/constants.js +1 -1
- package/dist/lib/json.d.ts +8 -0
- package/dist/lib/json.d.ts.map +1 -0
- package/dist/lib/json.js +25 -0
- package/dist/lib/json.js.map +1 -0
- package/dist/lib/utils.d.ts +10 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +19 -177
- package/dist/lib/utils.js.map +1 -1
- package/dist/package.json +3 -2
- package/docs/examples/projects/update-labels.md +3 -0
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.ts +3 -5
- package/lib/commands/config.ts +36 -32
- package/lib/commands/pull.ts +30 -9
- package/lib/commands/push.ts +9 -5
- package/lib/commands/services/projects.ts +13 -1
- package/lib/commands/services/storage.ts +2 -2
- package/lib/commands/utils/attributes.ts +19 -8
- package/lib/config.ts +9 -11
- package/lib/constants.ts +1 -1
- package/lib/json.ts +28 -0
- package/lib/utils.ts +25 -232
- package/package.json +3 -2
- package/scoop/appwrite.config.json +3 -3
package/dist/lib/utils.js
CHANGED
|
@@ -2,9 +2,8 @@ import fs from "fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import net from "net";
|
|
4
4
|
import childProcess from "child_process";
|
|
5
|
-
import chalk from "chalk";
|
|
6
5
|
import { fetch } from "undici";
|
|
7
|
-
import {
|
|
6
|
+
import { globalConfig } from "./config.js";
|
|
8
7
|
import { NPM_REGISTRY_URL, DEFAULT_ENDPOINT } from "./constants.js";
|
|
9
8
|
export const createSettingsObject = (project) => {
|
|
10
9
|
return {
|
|
@@ -141,184 +140,27 @@ export const checkDeployConditions = (localConfig) => {
|
|
|
141
140
|
throw new Error("No appwrite.config.json file found in the current directory. Please run this command again in the folder containing your appwrite.config.json file, or run 'appwrite init project' to link current directory to an Appwrite project.");
|
|
142
141
|
}
|
|
143
142
|
};
|
|
144
|
-
export function showConsoleLink(serviceName, action, ...ids) {
|
|
145
|
-
const projectId = localConfig.getProject().projectId;
|
|
146
|
-
const url = new URL(globalConfig.getEndpoint().replace("/v1", "/console"));
|
|
147
|
-
url.pathname += `/project-${projectId}`;
|
|
148
|
-
action = action.toLowerCase();
|
|
149
|
-
switch (serviceName) {
|
|
150
|
-
case "account":
|
|
151
|
-
url.pathname = url.pathname.replace(`/project-${projectId}`, "");
|
|
152
|
-
url.pathname += getAccountPath(action);
|
|
153
|
-
break;
|
|
154
|
-
case "databases":
|
|
155
|
-
url.pathname += getDatabasePath(action, ids);
|
|
156
|
-
break;
|
|
157
|
-
case "functions":
|
|
158
|
-
url.pathname += getFunctionsPath(action, ids);
|
|
159
|
-
break;
|
|
160
|
-
case "messaging":
|
|
161
|
-
url.pathname += getMessagingPath(action, ids);
|
|
162
|
-
break;
|
|
163
|
-
case "projects":
|
|
164
|
-
url.pathname = url.pathname.replace(`/project-${projectId}`, "");
|
|
165
|
-
url.pathname += getProjectsPath(action, ids);
|
|
166
|
-
break;
|
|
167
|
-
case "storage":
|
|
168
|
-
url.pathname += getBucketsPath(action, ids);
|
|
169
|
-
break;
|
|
170
|
-
case "teams":
|
|
171
|
-
url.pathname += getTeamsPath(action, ids);
|
|
172
|
-
break;
|
|
173
|
-
case "organizations":
|
|
174
|
-
url.pathname += getOrganizationsPath(action, ids);
|
|
175
|
-
break;
|
|
176
|
-
case "users":
|
|
177
|
-
url.pathname += getUsersPath(action, ids);
|
|
178
|
-
break;
|
|
179
|
-
default:
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
console.log(`${chalk.green.bold("✓ Success:")} ${chalk.green(url.toString())}`);
|
|
183
|
-
}
|
|
184
|
-
function getAccountPath(action) {
|
|
185
|
-
let path = "/account";
|
|
186
|
-
if (action === "listsessions") {
|
|
187
|
-
path += "/sessions";
|
|
188
|
-
}
|
|
189
|
-
return path;
|
|
190
|
-
}
|
|
191
|
-
function getDatabasePath(action, ids) {
|
|
192
|
-
let path = "/databases";
|
|
193
|
-
if ([
|
|
194
|
-
"get",
|
|
195
|
-
"listcollections",
|
|
196
|
-
"getcollection",
|
|
197
|
-
"listattributes",
|
|
198
|
-
"listdocuments",
|
|
199
|
-
"getdocument",
|
|
200
|
-
"listindexes",
|
|
201
|
-
"getdatabaseusage",
|
|
202
|
-
].includes(action)) {
|
|
203
|
-
path += `/database-${ids[0]}`;
|
|
204
|
-
}
|
|
205
|
-
if (action === "getdatabaseusage") {
|
|
206
|
-
path += `/usage`;
|
|
207
|
-
}
|
|
208
|
-
if ([
|
|
209
|
-
"getcollection",
|
|
210
|
-
"listattributes",
|
|
211
|
-
"listdocuments",
|
|
212
|
-
"getdocument",
|
|
213
|
-
"listindexes",
|
|
214
|
-
].includes(action)) {
|
|
215
|
-
path += `/collection-${ids[1]}`;
|
|
216
|
-
}
|
|
217
|
-
if (action === "listattributes") {
|
|
218
|
-
path += "/attributes";
|
|
219
|
-
}
|
|
220
|
-
if (action === "listindexes") {
|
|
221
|
-
path += "/indexes";
|
|
222
|
-
}
|
|
223
|
-
if (action === "getdocument") {
|
|
224
|
-
path += `/document-${ids[2]}`;
|
|
225
|
-
}
|
|
226
|
-
return path;
|
|
227
|
-
}
|
|
228
|
-
function getFunctionsPath(action, ids) {
|
|
229
|
-
let path = "/functions";
|
|
230
|
-
if (action !== "list") {
|
|
231
|
-
path += `/function-${ids[0]}`;
|
|
232
|
-
}
|
|
233
|
-
if (action === "getdeployment") {
|
|
234
|
-
path += `/deployment-${ids[1]}`;
|
|
235
|
-
}
|
|
236
|
-
if (action === "getexecution" || action === "listexecution") {
|
|
237
|
-
path += `/executions`;
|
|
238
|
-
}
|
|
239
|
-
if (action === "getfunctionusage") {
|
|
240
|
-
path += `/usage`;
|
|
241
|
-
}
|
|
242
|
-
return path;
|
|
243
|
-
}
|
|
244
|
-
function getMessagingPath(action, ids) {
|
|
245
|
-
let path = "/messaging";
|
|
246
|
-
if (["getmessage", "listmessagelogs"].includes(action)) {
|
|
247
|
-
path += `/message-${ids[0]}`;
|
|
248
|
-
}
|
|
249
|
-
if (["listproviders", "getprovider"].includes(action)) {
|
|
250
|
-
path += `/providers`;
|
|
251
|
-
}
|
|
252
|
-
if (action === "getprovider") {
|
|
253
|
-
path += `/provider-${ids[0]}`;
|
|
254
|
-
}
|
|
255
|
-
if (["listtopics", "gettopic"].includes(action)) {
|
|
256
|
-
path += `/topics`;
|
|
257
|
-
}
|
|
258
|
-
if (action === "gettopic") {
|
|
259
|
-
path += `/topic-${ids[0]}`;
|
|
260
|
-
}
|
|
261
|
-
return path;
|
|
262
|
-
}
|
|
263
|
-
function getProjectsPath(action, ids) {
|
|
264
|
-
let path = "";
|
|
265
|
-
if (action !== "list") {
|
|
266
|
-
path += `/project-${ids[0]}`;
|
|
267
|
-
}
|
|
268
|
-
if (["listkeys", "getkey"].includes(action)) {
|
|
269
|
-
path += "/overview/keys";
|
|
270
|
-
}
|
|
271
|
-
if (["listplatforms", "getplatform"].includes(action)) {
|
|
272
|
-
path += "/overview/platforms";
|
|
273
|
-
}
|
|
274
|
-
if (["listwebhooks", "getwebhook"].includes(action)) {
|
|
275
|
-
path += "/settings/webhooks";
|
|
276
|
-
}
|
|
277
|
-
if (["getplatform", "getkey", "getwebhook"].includes(action)) {
|
|
278
|
-
path += `/${ids[1]}`;
|
|
279
|
-
}
|
|
280
|
-
return path;
|
|
281
|
-
}
|
|
282
|
-
function getBucketsPath(action, ids) {
|
|
283
|
-
let path = "/storage";
|
|
284
|
-
if (action !== "listbuckets") {
|
|
285
|
-
path += `/bucket-${ids[0]}`;
|
|
286
|
-
}
|
|
287
|
-
if (action === "getbucketusage") {
|
|
288
|
-
path += `/usage`;
|
|
289
|
-
}
|
|
290
|
-
if (action === "getfile") {
|
|
291
|
-
path += `/file-${ids[1]}`;
|
|
292
|
-
}
|
|
293
|
-
return path;
|
|
294
|
-
}
|
|
295
|
-
function getTeamsPath(action, ids) {
|
|
296
|
-
let path = "/auth/teams";
|
|
297
|
-
if (action !== "list") {
|
|
298
|
-
path += `/team-${ids[0]}`;
|
|
299
|
-
}
|
|
300
|
-
return path;
|
|
301
|
-
}
|
|
302
|
-
function getOrganizationsPath(action, ids) {
|
|
303
|
-
let path = `/organization-${ids[0]}`;
|
|
304
|
-
if (action === "list") {
|
|
305
|
-
path = "/account/organizations";
|
|
306
|
-
}
|
|
307
|
-
return path;
|
|
308
|
-
}
|
|
309
|
-
function getUsersPath(action, ids) {
|
|
310
|
-
let path = "/auth";
|
|
311
|
-
if (action !== "list") {
|
|
312
|
-
path += `/user-${ids[0]}`;
|
|
313
|
-
}
|
|
314
|
-
if (action === "listsessions") {
|
|
315
|
-
path += "sessions";
|
|
316
|
-
}
|
|
317
|
-
return path;
|
|
318
|
-
}
|
|
319
143
|
export function isCloud() {
|
|
320
144
|
const endpoint = globalConfig.getEndpoint() || DEFAULT_ENDPOINT;
|
|
321
145
|
const hostname = new URL(endpoint).hostname;
|
|
322
146
|
return hostname.endsWith("appwrite.io");
|
|
323
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Filters an object to only include fields defined in a Zod object schema.
|
|
150
|
+
* Uses the schema's shape to determine allowed keys.
|
|
151
|
+
*
|
|
152
|
+
* @param data - The data to filter
|
|
153
|
+
* @param schema - A Zod object schema with a shape property
|
|
154
|
+
* @returns The filtered data with only schema-defined fields
|
|
155
|
+
*/
|
|
156
|
+
export function filterBySchema(data, schema) {
|
|
157
|
+
const allowedKeys = Object.keys(schema.shape);
|
|
158
|
+
const result = {};
|
|
159
|
+
for (const key of allowedKeys) {
|
|
160
|
+
if (key in data) {
|
|
161
|
+
result[key] = data[key];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
324
166
|
//# sourceMappingURL=utils.js.map
|
package/dist/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,YAAY,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,YAAY,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAG/B,OAAO,EAAe,YAAY,EAAE,MAAM,aAAa,CAAC;AAExD,O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U,cAAc,CAC5B,IAA6B,EAC7B,MAAS;IAET,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;YAChB,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,OAAO,MAAoB,CAAC;AAC9B,CAAC"}
|
package/dist/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"homepage": "https://appwrite.io/support",
|
|
5
5
|
"description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API",
|
|
6
|
-
"version": "13.0.
|
|
6
|
+
"version": "13.0.1",
|
|
7
7
|
"license": "BSD-3-Clause",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"types": "dist/index.d.ts",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"windows-arm64": "bun run build && esbuild dist/cli.js --bundle --platform=node --format=cjs --outfile=dist/bundle.cjs --external:@appwrite.io/console --external:fsevents && pkg dist/bundle.cjs -t node18-win-arm64 -o build/appwrite-cli-win-arm64.exe"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@appwrite.io/console": "^2.1.
|
|
31
|
+
"@appwrite.io/console": "^2.1.3",
|
|
32
|
+
"bignumber.js": "^9.0.0",
|
|
32
33
|
"chalk": "4.1.2",
|
|
33
34
|
"chokidar": "^3.6.0",
|
|
34
35
|
"cli-progress": "^3.12.0",
|
package/install.ps1
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
# You can use "View source" of this page to see the full script.
|
|
14
14
|
|
|
15
15
|
# REPO
|
|
16
|
-
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/13.0.
|
|
17
|
-
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/13.0.
|
|
16
|
+
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/13.0.1/appwrite-cli-win-x64.exe"
|
|
17
|
+
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/13.0.1/appwrite-cli-win-arm64.exe"
|
|
18
18
|
|
|
19
19
|
$APPWRITE_BINARY_NAME = "appwrite.exe"
|
|
20
20
|
|
package/install.sh
CHANGED
|
@@ -96,7 +96,7 @@ printSuccess() {
|
|
|
96
96
|
downloadBinary() {
|
|
97
97
|
echo "[2/4] Downloading executable for $OS ($ARCH) ..."
|
|
98
98
|
|
|
99
|
-
GITHUB_LATEST_VERSION="13.0.
|
|
99
|
+
GITHUB_LATEST_VERSION="13.0.1"
|
|
100
100
|
GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
|
|
101
101
|
GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"
|
|
102
102
|
|
package/lib/client.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import os from "os";
|
|
2
2
|
import { fetch, FormData, Agent } from "undici";
|
|
3
|
-
import JSONbig from "json-bigint";
|
|
4
3
|
import { AppwriteException } from "@appwrite.io/console";
|
|
5
4
|
import { globalConfig } from "./config.js";
|
|
5
|
+
import { JSONBig } from "./json.js";
|
|
6
6
|
import chalk from "chalk";
|
|
7
7
|
import type {
|
|
8
8
|
Headers,
|
|
@@ -19,8 +19,6 @@ import {
|
|
|
19
19
|
SDK_TITLE,
|
|
20
20
|
} from "./constants.js";
|
|
21
21
|
|
|
22
|
-
const JSONBigInt = JSONbig({ useNativeBigInt: true });
|
|
23
|
-
|
|
24
22
|
class Client {
|
|
25
23
|
private endpoint: string;
|
|
26
24
|
private headers: Headers;
|
|
@@ -199,7 +197,7 @@ class Client {
|
|
|
199
197
|
|
|
200
198
|
body = formData;
|
|
201
199
|
} else {
|
|
202
|
-
body =
|
|
200
|
+
body = JSONBig.stringify(params);
|
|
203
201
|
}
|
|
204
202
|
|
|
205
203
|
let response: Awaited<ReturnType<typeof fetch>> | undefined = undefined;
|
|
@@ -266,7 +264,7 @@ class Client {
|
|
|
266
264
|
const text = await response.text();
|
|
267
265
|
let json: T | undefined = undefined;
|
|
268
266
|
try {
|
|
269
|
-
json =
|
|
267
|
+
json = JSONBig.parse(text);
|
|
270
268
|
} catch (error) {
|
|
271
269
|
return text as T;
|
|
272
270
|
}
|
package/lib/commands/config.ts
CHANGED
|
@@ -333,6 +333,7 @@ const CollectionSchema = z
|
|
|
333
333
|
// ============================================================================
|
|
334
334
|
|
|
335
335
|
const ColumnSchema = AttributeSchema;
|
|
336
|
+
const ColumnSchemaBase = AttributeSchemaBase;
|
|
336
337
|
|
|
337
338
|
const IndexTableSchema = z
|
|
338
339
|
.object({
|
|
@@ -344,7 +345,7 @@ const IndexTableSchema = z
|
|
|
344
345
|
})
|
|
345
346
|
.strict();
|
|
346
347
|
|
|
347
|
-
const
|
|
348
|
+
const TablesDBSchemaBase = z
|
|
348
349
|
.object({
|
|
349
350
|
$id: z.string(),
|
|
350
351
|
$permissions: z.array(z.string()).optional(),
|
|
@@ -355,40 +356,41 @@ const TablesDBSchema = z
|
|
|
355
356
|
columns: z.array(ColumnSchema).optional(),
|
|
356
357
|
indexes: z.array(IndexTableSchema).optional(),
|
|
357
358
|
})
|
|
358
|
-
.strict()
|
|
359
|
-
.superRefine((data, ctx) => {
|
|
360
|
-
if (data.columns && data.columns.length > 0) {
|
|
361
|
-
const seenKeys = new Set<string>();
|
|
359
|
+
.strict();
|
|
362
360
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
code: z.ZodIssueCode.custom,
|
|
367
|
-
message: `Column with the key '${col.key}' already exists. Column keys must be unique, try again with a different key.`,
|
|
368
|
-
path: ["columns", index, "key"],
|
|
369
|
-
});
|
|
370
|
-
} else {
|
|
371
|
-
seenKeys.add(col.key);
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
}
|
|
361
|
+
const TablesDBSchema = TablesDBSchemaBase.superRefine((data, ctx) => {
|
|
362
|
+
if (data.columns && data.columns.length > 0) {
|
|
363
|
+
const seenKeys = new Set<string>();
|
|
375
364
|
|
|
376
|
-
|
|
377
|
-
|
|
365
|
+
data.columns.forEach((col, index) => {
|
|
366
|
+
if (seenKeys.has(col.key)) {
|
|
367
|
+
ctx.addIssue({
|
|
368
|
+
code: z.ZodIssueCode.custom,
|
|
369
|
+
message: `Column with the key '${col.key}' already exists. Column keys must be unique, try again with a different key.`,
|
|
370
|
+
path: ["columns", index, "key"],
|
|
371
|
+
});
|
|
372
|
+
} else {
|
|
373
|
+
seenKeys.add(col.key);
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
}
|
|
378
377
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
|
|
378
|
+
if (data.indexes && data.indexes.length > 0) {
|
|
379
|
+
const seenKeys = new Set<string>();
|
|
380
|
+
|
|
381
|
+
data.indexes.forEach((index, indexPos) => {
|
|
382
|
+
if (seenKeys.has(index.key)) {
|
|
383
|
+
ctx.addIssue({
|
|
384
|
+
code: z.ZodIssueCode.custom,
|
|
385
|
+
message: `Index with the key '${index.key}' already exists. Index keys must be unique, try again with a different key.`,
|
|
386
|
+
path: ["indexes", indexPos, "key"],
|
|
387
|
+
});
|
|
388
|
+
} else {
|
|
389
|
+
seenKeys.add(index.key);
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
});
|
|
392
394
|
|
|
393
395
|
// ============================================================================
|
|
394
396
|
// Topics
|
|
@@ -491,7 +493,9 @@ export {
|
|
|
491
493
|
|
|
492
494
|
/** Tables */
|
|
493
495
|
TablesDBSchema,
|
|
496
|
+
TablesDBSchemaBase,
|
|
494
497
|
ColumnSchema,
|
|
498
|
+
ColumnSchemaBase,
|
|
495
499
|
IndexTableSchema,
|
|
496
500
|
|
|
497
501
|
/** Topics */
|
package/lib/commands/pull.ts
CHANGED
|
@@ -37,7 +37,14 @@ import {
|
|
|
37
37
|
commandDescriptions,
|
|
38
38
|
} from "../parser.js";
|
|
39
39
|
import type { ConfigType } from "./config.js";
|
|
40
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
DatabaseSchema,
|
|
42
|
+
TablesDBSchemaBase,
|
|
43
|
+
ColumnSchemaBase,
|
|
44
|
+
BucketSchema,
|
|
45
|
+
TopicSchema,
|
|
46
|
+
} from "./config.js";
|
|
47
|
+
import { createSettingsObject, filterBySchema } from "../utils.js";
|
|
41
48
|
import { ProjectNotInitializedError } from "./errors.js";
|
|
42
49
|
import type { SettingsType, FunctionType, SiteType } from "./config.js";
|
|
43
50
|
import { downloadDeploymentCode } from "./utils/deployment.js";
|
|
@@ -523,7 +530,7 @@ export class Pull {
|
|
|
523
530
|
this.log(
|
|
524
531
|
`Pulling all tables from ${chalk.bold(database.name)} database ...`,
|
|
525
532
|
);
|
|
526
|
-
allDatabases.push(database);
|
|
533
|
+
allDatabases.push(filterBySchema(database, DatabaseSchema));
|
|
527
534
|
|
|
528
535
|
const { tables } = await paginate(
|
|
529
536
|
async () => new TablesDB(this.projectClient).listTables(database.$id),
|
|
@@ -533,10 +540,14 @@ export class Pull {
|
|
|
533
540
|
);
|
|
534
541
|
|
|
535
542
|
for (const table of tables) {
|
|
543
|
+
// Filter columns to only include schema-defined fields
|
|
544
|
+
const filteredColumns = table.columns?.map((col: any) =>
|
|
545
|
+
filterBySchema(col, ColumnSchemaBase),
|
|
546
|
+
);
|
|
547
|
+
|
|
536
548
|
allTables.push({
|
|
537
|
-
...table,
|
|
538
|
-
|
|
539
|
-
$updatedAt: undefined,
|
|
549
|
+
...filterBySchema(table, TablesDBSchemaBase),
|
|
550
|
+
columns: filteredColumns || [],
|
|
540
551
|
});
|
|
541
552
|
}
|
|
542
553
|
}
|
|
@@ -576,13 +587,18 @@ export class Pull {
|
|
|
576
587
|
"buckets",
|
|
577
588
|
);
|
|
578
589
|
|
|
590
|
+
const filteredBuckets: any[] = [];
|
|
591
|
+
|
|
579
592
|
for (const bucket of buckets) {
|
|
580
593
|
this.log(`Pulling bucket ${chalk.bold(bucket.name)} ...`);
|
|
594
|
+
filteredBuckets.push(filterBySchema(bucket, BucketSchema));
|
|
581
595
|
}
|
|
582
596
|
|
|
583
|
-
this.success(
|
|
597
|
+
this.success(
|
|
598
|
+
`Successfully pulled ${chalk.bold(filteredBuckets.length)} buckets.`,
|
|
599
|
+
);
|
|
584
600
|
|
|
585
|
-
return
|
|
601
|
+
return filteredBuckets;
|
|
586
602
|
}
|
|
587
603
|
|
|
588
604
|
/**
|
|
@@ -644,13 +660,18 @@ export class Pull {
|
|
|
644
660
|
"topics",
|
|
645
661
|
);
|
|
646
662
|
|
|
663
|
+
const filteredTopics: any[] = [];
|
|
664
|
+
|
|
647
665
|
for (const topic of topics) {
|
|
648
666
|
this.log(`Pulling topic ${chalk.bold(topic.name)} ...`);
|
|
667
|
+
filteredTopics.push(filterBySchema(topic, TopicSchema));
|
|
649
668
|
}
|
|
650
669
|
|
|
651
|
-
this.success(
|
|
670
|
+
this.success(
|
|
671
|
+
`Successfully pulled ${chalk.bold(filteredTopics.length)} topics.`,
|
|
672
|
+
);
|
|
652
673
|
|
|
653
|
-
return
|
|
674
|
+
return filteredTopics;
|
|
654
675
|
}
|
|
655
676
|
}
|
|
656
677
|
|
package/lib/commands/push.ts
CHANGED
|
@@ -1414,24 +1414,28 @@ export class Push {
|
|
|
1414
1414
|
for (let table of tables) {
|
|
1415
1415
|
let columns = table.columns;
|
|
1416
1416
|
let indexes = table.indexes;
|
|
1417
|
+
let hadChanges = false;
|
|
1417
1418
|
|
|
1418
1419
|
if (table.isExisted) {
|
|
1419
|
-
|
|
1420
|
+
const columnsResult = await attributes.attributesToCreate(
|
|
1420
1421
|
table.remoteVersion.columns,
|
|
1421
1422
|
table.columns,
|
|
1422
1423
|
table as Collection,
|
|
1423
1424
|
);
|
|
1424
|
-
|
|
1425
|
+
const indexesResult = await attributes.attributesToCreate(
|
|
1425
1426
|
table.remoteVersion.indexes,
|
|
1426
1427
|
table.indexes,
|
|
1427
1428
|
table as Collection,
|
|
1428
1429
|
true,
|
|
1429
1430
|
);
|
|
1430
1431
|
|
|
1432
|
+
columns = columnsResult.attributes;
|
|
1433
|
+
indexes = indexesResult.attributes;
|
|
1434
|
+
hadChanges = columnsResult.hasChanges || indexesResult.hasChanges;
|
|
1435
|
+
|
|
1431
1436
|
if (
|
|
1432
|
-
|
|
1437
|
+
!hadChanges &&
|
|
1433
1438
|
columns.length <= 0 &&
|
|
1434
|
-
Array.isArray(indexes) &&
|
|
1435
1439
|
indexes.length <= 0
|
|
1436
1440
|
) {
|
|
1437
1441
|
continue;
|
|
@@ -2193,7 +2197,7 @@ const pushTable = async ({
|
|
|
2193
2197
|
const { successfullyPushed, errors } = result;
|
|
2194
2198
|
|
|
2195
2199
|
if (successfullyPushed === 0) {
|
|
2196
|
-
|
|
2200
|
+
warn("No tables were pushed.");
|
|
2197
2201
|
} else {
|
|
2198
2202
|
success(`Successfully pushed ${successfullyPushed} tables.`);
|
|
2199
2203
|
}
|
|
@@ -42,7 +42,7 @@ export const projects = new Command("projects")
|
|
|
42
42
|
projects
|
|
43
43
|
.command(`list`)
|
|
44
44
|
.description(`Get a list of all projects. You can use the query params to filter your results. `)
|
|
45
|
-
.option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId`)
|
|
45
|
+
.option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search`)
|
|
46
46
|
.option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
|
|
47
47
|
.option(
|
|
48
48
|
`--total [value]`,
|
|
@@ -429,6 +429,18 @@ projects
|
|
|
429
429
|
),
|
|
430
430
|
);
|
|
431
431
|
|
|
432
|
+
projects
|
|
433
|
+
.command(`update-labels`)
|
|
434
|
+
.description(`Update the project labels by its unique ID. Labels can be used to easily filter projects in an organization.`)
|
|
435
|
+
.requiredOption(`--project-id <project-id>`, `Project unique ID.`)
|
|
436
|
+
.requiredOption(`--labels [labels...]`, `Array of project labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long.`)
|
|
437
|
+
.action(
|
|
438
|
+
actionRunner(
|
|
439
|
+
async ({ projectId, labels }) =>
|
|
440
|
+
parse(await (await getProjectsClient()).updateLabels(projectId, labels)),
|
|
441
|
+
),
|
|
442
|
+
);
|
|
443
|
+
|
|
432
444
|
projects
|
|
433
445
|
.command(`update-o-auth-2`)
|
|
434
446
|
.description(`Update the OAuth2 provider configurations. Use this endpoint to set up or update the OAuth2 provider credentials or enable/disable providers. `)
|
|
@@ -71,7 +71,7 @@ storage
|
|
|
71
71
|
)
|
|
72
72
|
.option(`--maximum-file-size <maximum-file-size>`, `Maximum file size allowed in bytes. Maximum allowed value is 30MB.`, parseInteger)
|
|
73
73
|
.option(`--allowed-file-extensions [allowed-file-extensions...]`, `Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.`)
|
|
74
|
-
.option(`--compression <compression>`, `Compression algorithm
|
|
74
|
+
.option(`--compression <compression>`, `Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled`)
|
|
75
75
|
.option(
|
|
76
76
|
`--encryption [value]`,
|
|
77
77
|
`Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled`,
|
|
@@ -128,7 +128,7 @@ storage
|
|
|
128
128
|
)
|
|
129
129
|
.option(`--maximum-file-size <maximum-file-size>`, `Maximum file size allowed in bytes. Maximum allowed value is 30MB.`, parseInteger)
|
|
130
130
|
.option(`--allowed-file-extensions [allowed-file-extensions...]`, `Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.`)
|
|
131
|
-
.option(`--compression <compression>`, `Compression algorithm
|
|
131
|
+
.option(`--compression <compression>`, `Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled`)
|
|
132
132
|
.option(
|
|
133
133
|
`--encryption [value]`,
|
|
134
134
|
`Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled`,
|