appwrite-cli 17.1.0 → 17.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.
Files changed (56) hide show
  1. package/.github/workflows/ci.yml +1 -1
  2. package/.github/workflows/publish.yml +1 -1
  3. package/CHANGELOG.md +14 -0
  4. package/README.md +2 -2
  5. package/bun.lock +783 -0
  6. package/cli.ts +14 -2
  7. package/dist/bundle-win-arm64.mjs +1137 -733
  8. package/dist/cli.cjs +1137 -733
  9. package/dist/index.cjs +193 -79
  10. package/dist/index.js +193 -79
  11. package/dist/lib/client.d.ts +9 -0
  12. package/dist/lib/client.d.ts.map +1 -1
  13. package/dist/lib/commands/init.d.ts.map +1 -1
  14. package/dist/lib/constants.d.ts +1 -1
  15. package/dist/lib/emulation/docker.d.ts.map +1 -1
  16. package/dist/lib/parser.d.ts.map +1 -1
  17. package/dist/lib/questions.d.ts.map +1 -1
  18. package/dist/lib/types.d.ts +2 -0
  19. package/dist/lib/types.d.ts.map +1 -1
  20. package/dist/lib/utils.d.ts +12 -0
  21. package/dist/lib/utils.d.ts.map +1 -1
  22. package/install.ps1 +2 -2
  23. package/install.sh +1 -1
  24. package/lib/client.ts +12 -0
  25. package/lib/commands/init.ts +109 -2
  26. package/lib/commands/services/account.ts +110 -55
  27. package/lib/commands/services/activities.ts +4 -2
  28. package/lib/commands/services/backups.ts +24 -12
  29. package/lib/commands/services/databases.ts +150 -75
  30. package/lib/commands/services/functions.ts +60 -30
  31. package/lib/commands/services/graphql.ts +4 -2
  32. package/lib/commands/services/health.ts +46 -23
  33. package/lib/commands/services/locale.ts +16 -8
  34. package/lib/commands/services/messaging.ts +96 -48
  35. package/lib/commands/services/migrations.ts +28 -14
  36. package/lib/commands/services/organizations.ts +76 -38
  37. package/lib/commands/services/project.ts +12 -6
  38. package/lib/commands/services/projects.ts +103 -51
  39. package/lib/commands/services/proxy.ts +16 -8
  40. package/lib/commands/services/sites.ts +58 -29
  41. package/lib/commands/services/storage.ts +30 -15
  42. package/lib/commands/services/tables-db.ts +148 -74
  43. package/lib/commands/services/teams.ts +28 -14
  44. package/lib/commands/services/tokens.ts +10 -5
  45. package/lib/commands/services/users.ts +88 -44
  46. package/lib/commands/services/vcs.ts +20 -10
  47. package/lib/commands/services/webhooks.ts +12 -6
  48. package/lib/constants.ts +1 -1
  49. package/lib/emulation/docker.ts +1 -0
  50. package/lib/parser.ts +279 -122
  51. package/lib/questions.ts +8 -3
  52. package/lib/sdks.ts +0 -1
  53. package/lib/types.ts +2 -0
  54. package/lib/utils.ts +234 -0
  55. package/package.json +1 -1
  56. package/scoop/appwrite.config.json +3 -3
package/dist/index.cjs CHANGED
@@ -19581,9 +19581,9 @@ var require_stream_duplex = __commonJS({
19581
19581
  }
19582
19582
  });
19583
19583
 
19584
- // node_modules/string_decoder/node_modules/safe-buffer/index.js
19584
+ // node_modules/safe-buffer/index.js
19585
19585
  var require_safe_buffer = __commonJS({
19586
- "node_modules/string_decoder/node_modules/safe-buffer/index.js"(exports2, module2) {
19586
+ "node_modules/safe-buffer/index.js"(exports2, module2) {
19587
19587
  var buffer = require("buffer");
19588
19588
  var Buffer2 = buffer.Buffer;
19589
19589
  function copyProps(src, dst) {
@@ -19600,6 +19600,7 @@ var require_safe_buffer = __commonJS({
19600
19600
  function SafeBuffer(arg, encodingOrOffset, length) {
19601
19601
  return Buffer2(arg, encodingOrOffset, length);
19602
19602
  }
19603
+ SafeBuffer.prototype = Object.create(Buffer2.prototype);
19603
19604
  copyProps(Buffer2, SafeBuffer);
19604
19605
  SafeBuffer.from = function(arg, encodingOrOffset, length) {
19605
19606
  if (typeof arg === "number") {
@@ -62789,7 +62790,7 @@ var id_default = ID;
62789
62790
  // lib/constants.ts
62790
62791
  var SDK_TITLE = "Appwrite";
62791
62792
  var SDK_TITLE_LOWER = "appwrite";
62792
- var SDK_VERSION = "17.1.0";
62793
+ var SDK_VERSION = "17.2.1";
62793
62794
  var SDK_LOGO = "\n _ _ _ ___ __ _____\n /_\\ _ __ _ ____ ___ __(_) |_ ___ / __\\ / / \\_ \\\n //_\\\\| '_ \\| '_ \\ \\ /\\ / / '__| | __/ _ \\ / / / / / /\\/\n / _ \\ |_) | |_) \\ V V /| | | | || __/ / /___/ /___/\\/ /_\n \\_/ \\_/ .__/| .__/ \\_/\\_/ |_| |_|\\__\\___| \\____/\\____/\\____/\n |_| |_|\n\n";
62794
62795
  var EXECUTABLE_NAME = "appwrite";
62795
62796
  var NPM_PACKAGE_NAME = "appwrite-cli";
@@ -100336,7 +100337,7 @@ var package_default = {
100336
100337
  type: "module",
100337
100338
  homepage: "https://appwrite.io/support",
100338
100339
  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",
100339
- version: "17.1.0",
100340
+ version: "17.2.1",
100340
100341
  license: "BSD-3-Clause",
100341
100342
  main: "dist/index.cjs",
100342
100343
  module: "dist/index.js",
@@ -100434,12 +100435,28 @@ var cliConfig = {
100434
100435
  verbose: false,
100435
100436
  json: false,
100436
100437
  raw: false,
100438
+ showSecrets: false,
100437
100439
  force: false,
100438
100440
  all: false,
100439
100441
  ids: [],
100440
100442
  report: false,
100441
- reportData: {}
100443
+ reportData: {},
100444
+ displayFields: []
100442
100445
  };
100446
+ var HIDDEN_VALUE = "[hidden]";
100447
+ var SENSITIVE_KEYS = /* @__PURE__ */ new Set([
100448
+ "secret",
100449
+ "apikey",
100450
+ "accesstoken",
100451
+ "refreshtoken",
100452
+ "password",
100453
+ "jwt",
100454
+ "clientsecret",
100455
+ "secretkey",
100456
+ "sessionsecret"
100457
+ ]);
100458
+ var renderDepth = 0;
100459
+ var redactionApplied = false;
100443
100460
  var toJsonObject = (value) => {
100444
100461
  if (value && typeof value === "object" && !Array.isArray(value)) {
100445
100462
  return value;
@@ -100456,6 +100473,89 @@ var extractReportCommandArgs = (value) => {
100456
100473
  }
100457
100474
  return reportData.data.args;
100458
100475
  };
100476
+ var beginRender = () => {
100477
+ if (renderDepth === 0) {
100478
+ redactionApplied = false;
100479
+ }
100480
+ renderDepth++;
100481
+ };
100482
+ var endRender = () => {
100483
+ renderDepth = Math.max(0, renderDepth - 1);
100484
+ if (renderDepth === 0 && redactionApplied && !cliConfig.showSecrets) {
100485
+ const message = "Sensitive values were redacted. Pass --show-secrets to display them.";
100486
+ if (cliConfig.json || cliConfig.raw) {
100487
+ console.error(`${import_chalk2.default.cyan.bold("\u2665 Hint:")} ${import_chalk2.default.cyan(message)}`);
100488
+ } else {
100489
+ hint(message);
100490
+ }
100491
+ }
100492
+ };
100493
+ var withRender = (callback) => {
100494
+ beginRender();
100495
+ try {
100496
+ return callback();
100497
+ } finally {
100498
+ endRender();
100499
+ }
100500
+ };
100501
+ var isSensitiveKey = (key) => {
100502
+ const normalizedKey = key.toLowerCase().replace(/[^a-z0-9]/g, "");
100503
+ return SENSITIVE_KEYS.has(normalizedKey);
100504
+ };
100505
+ var maskSensitiveString = (value) => {
100506
+ if (value.length <= 16) {
100507
+ return HIDDEN_VALUE;
100508
+ }
100509
+ const separatorIndex = value.indexOf("_");
100510
+ if (separatorIndex > 0 && separatorIndex < value.length - 9) {
100511
+ const prefix = value.slice(0, separatorIndex + 1);
100512
+ const tail = value.slice(-4);
100513
+ return `${prefix}${HIDDEN_VALUE}${tail}`;
100514
+ }
100515
+ return `${HIDDEN_VALUE}${value.slice(-4)}`;
100516
+ };
100517
+ var maskSensitiveData = (value, key) => {
100518
+ if (key && isSensitiveKey(key) && !cliConfig.showSecrets) {
100519
+ redactionApplied = true;
100520
+ if (typeof value === "string") {
100521
+ return maskSensitiveString(value);
100522
+ }
100523
+ if (value == null) {
100524
+ return value;
100525
+ }
100526
+ return HIDDEN_VALUE;
100527
+ }
100528
+ if (Array.isArray(value)) {
100529
+ return value.map((item) => maskSensitiveData(item));
100530
+ }
100531
+ if (value && typeof value === "object") {
100532
+ if (value?.constructor?.name === "BigNumber") {
100533
+ return String(value);
100534
+ }
100535
+ const result = {};
100536
+ for (const childKey of Object.keys(value)) {
100537
+ const childValue = value[childKey];
100538
+ if (typeof childValue === "function") continue;
100539
+ result[childKey] = maskSensitiveData(childValue, childKey);
100540
+ }
100541
+ return result;
100542
+ }
100543
+ return value;
100544
+ };
100545
+ var applyDisplayFilter = (rows) => {
100546
+ if (cliConfig.displayFields.length === 0) {
100547
+ return rows;
100548
+ }
100549
+ return rows.map((row) => {
100550
+ const filtered = {};
100551
+ for (const key of cliConfig.displayFields) {
100552
+ if (Object.prototype.hasOwnProperty.call(row, key)) {
100553
+ filtered[key] = row[key];
100554
+ }
100555
+ }
100556
+ return Object.keys(filtered).length > 0 ? filtered : row;
100557
+ });
100558
+ };
100459
100559
  var MAX_COL_WIDTH = 40;
100460
100560
  var formatCellValue = (value) => {
100461
100561
  if (value == null) return "-";
@@ -100476,87 +100576,97 @@ var formatCellValue = (value) => {
100476
100576
  return str;
100477
100577
  };
100478
100578
  var drawTable = (data) => {
100479
- if (data.length == 0) {
100480
- console.log("[]");
100481
- return;
100482
- }
100483
- const rows = data.map((item) => toJsonObject(item) ?? {});
100484
- const obj = rows.reduce((res, item) => ({ ...res, ...item }), {});
100485
- const allKeys = Object.keys(obj);
100486
- if (allKeys.length === 0) {
100487
- drawJSON(data);
100488
- return;
100489
- }
100490
- const maxColumns = 6;
100491
- if (allKeys.length > maxColumns) {
100492
- const rowEntries = rows.map((row) => {
100493
- const entries = [];
100494
- for (const key of Object.keys(row)) {
100495
- const value = row[key];
100496
- if (typeof value === "function") continue;
100497
- if (value == null) continue;
100498
- if (value?.constructor?.name === "BigNumber") {
100579
+ withRender(() => {
100580
+ if (data.length == 0) {
100581
+ console.log("[]");
100582
+ return;
100583
+ }
100584
+ const rows = applyDisplayFilter(
100585
+ data.map((item) => {
100586
+ const maskedItem = maskSensitiveData(item);
100587
+ return toJsonObject(maskedItem) ?? {};
100588
+ })
100589
+ );
100590
+ const obj = rows.reduce((res, item) => ({ ...res, ...item }), {});
100591
+ const allKeys = Object.keys(obj);
100592
+ if (allKeys.length === 0) {
100593
+ drawJSON(data);
100594
+ return;
100595
+ }
100596
+ const maxColumns = 6;
100597
+ if (allKeys.length > maxColumns) {
100598
+ const rowEntries = rows.map((row) => {
100599
+ const entries = [];
100600
+ for (const key of Object.keys(row)) {
100601
+ const value = row[key];
100602
+ if (typeof value === "function") continue;
100603
+ if (value == null) continue;
100604
+ if (value?.constructor?.name === "BigNumber") {
100605
+ entries.push([key, String(value)]);
100606
+ continue;
100607
+ }
100608
+ if (typeof value === "object") continue;
100609
+ if (typeof value === "string" && value.trim() === "") continue;
100499
100610
  entries.push([key, String(value)]);
100500
- continue;
100501
100611
  }
100502
- if (typeof value === "object") continue;
100503
- if (typeof value === "string" && value.trim() === "") continue;
100504
- entries.push([key, String(value)]);
100612
+ return entries;
100613
+ });
100614
+ const flatEntries = rowEntries.flat();
100615
+ if (flatEntries.length === 0) {
100616
+ drawJSON(data);
100617
+ return;
100505
100618
  }
100506
- return entries;
100507
- });
100508
- const flatEntries = rowEntries.flat();
100509
- if (flatEntries.length === 0) {
100510
- drawJSON(data);
100619
+ const maxKeyLen = Math.max(...flatEntries.map(([key]) => key.length));
100620
+ const separatorLen = Math.min(
100621
+ maxKeyLen + 2 + MAX_COL_WIDTH,
100622
+ process.stdout.columns || 80
100623
+ );
100624
+ rowEntries.forEach((entries, idx) => {
100625
+ if (idx > 0) console.log(import_chalk2.default.cyan("\u2500".repeat(separatorLen)));
100626
+ for (const [key, value] of entries) {
100627
+ const paddedKey = key.padEnd(maxKeyLen);
100628
+ console.log(`${import_chalk2.default.yellow.bold(paddedKey)} ${value}`);
100629
+ }
100630
+ });
100511
100631
  return;
100512
100632
  }
100513
- const maxKeyLen = Math.max(...flatEntries.map(([key]) => key.length));
100514
- const separatorLen = Math.min(maxKeyLen + 2 + MAX_COL_WIDTH, process.stdout.columns || 80);
100515
- rowEntries.forEach((entries, idx) => {
100516
- if (idx > 0) console.log(import_chalk2.default.cyan("\u2500".repeat(separatorLen)));
100517
- for (const [key, value] of entries) {
100518
- const paddedKey = key.padEnd(maxKeyLen);
100519
- console.log(`${import_chalk2.default.yellow.bold(paddedKey)} ${value}`);
100633
+ const columns = allKeys;
100634
+ const def = allKeys.reduce((result, key) => {
100635
+ result[key] = "-";
100636
+ return result;
100637
+ }, {});
100638
+ const normalizedData = rows.map((item) => ({ ...def, ...item }));
100639
+ const table = new import_cli_table3.default({
100640
+ head: columns.map((c) => import_chalk2.default.cyan.italic.bold(c)),
100641
+ colWidths: columns.map(() => null),
100642
+ wordWrap: false,
100643
+ chars: {
100644
+ "top": " ",
100645
+ "top-mid": " ",
100646
+ "top-left": " ",
100647
+ "top-right": " ",
100648
+ "bottom": " ",
100649
+ "bottom-mid": " ",
100650
+ "bottom-left": " ",
100651
+ "bottom-right": " ",
100652
+ "left": " ",
100653
+ "left-mid": " ",
100654
+ "mid": import_chalk2.default.cyan("\u2500"),
100655
+ "mid-mid": import_chalk2.default.cyan("\u253C"),
100656
+ "right": " ",
100657
+ "right-mid": " ",
100658
+ "middle": import_chalk2.default.cyan("\u2502")
100520
100659
  }
100521
100660
  });
100522
- return;
100523
- }
100524
- const columns = allKeys;
100525
- const def = allKeys.reduce((result, key) => {
100526
- result[key] = "-";
100527
- return result;
100528
- }, {});
100529
- const normalizedData = rows.map((item) => ({ ...def, ...item }));
100530
- const table = new import_cli_table3.default({
100531
- head: columns.map((c) => import_chalk2.default.cyan.italic.bold(c)),
100532
- colWidths: columns.map(() => null),
100533
- wordWrap: false,
100534
- chars: {
100535
- top: " ",
100536
- "top-mid": " ",
100537
- "top-left": " ",
100538
- "top-right": " ",
100539
- bottom: " ",
100540
- "bottom-mid": " ",
100541
- "bottom-left": " ",
100542
- "bottom-right": " ",
100543
- left: " ",
100544
- "left-mid": " ",
100545
- mid: import_chalk2.default.cyan("\u2500"),
100546
- "mid-mid": import_chalk2.default.cyan("\u253C"),
100547
- right: " ",
100548
- "right-mid": " ",
100549
- middle: import_chalk2.default.cyan("\u2502")
100550
- }
100551
- });
100552
- normalizedData.forEach((row) => {
100553
- const rowValues = [];
100554
- for (const key of columns) {
100555
- rowValues.push(formatCellValue(row[key]));
100556
- }
100557
- table.push(rowValues);
100661
+ normalizedData.forEach((row) => {
100662
+ const rowValues = [];
100663
+ for (const key of columns) {
100664
+ rowValues.push(formatCellValue(row[key]));
100665
+ }
100666
+ table.push(rowValues);
100667
+ });
100668
+ console.log(table.toString());
100558
100669
  });
100559
- console.log(table.toString());
100560
100670
  };
100561
100671
  var drawJSON = (data) => {
100562
100672
  console.log(JSON.stringify(data, null, 2));
@@ -100658,7 +100768,7 @@ var commandDescriptions = {
100658
100768
  avatars: `The avatars command aims to help you complete everyday tasks related to your app image, icons, and avatars.`,
100659
100769
  databases: `(Legacy) The databases command allows you to create structured collections of documents and query and filter lists of documents.`,
100660
100770
  "tables-db": `The tables-db command allows you to create structured tables of columns and query and filter lists of rows.`,
100661
- init: `The init command provides a convenient wrapper for creating and initializing projects, functions, collections, buckets, teams, and messaging-topics in ${SDK_TITLE}.`,
100771
+ init: `The init command provides a convenient wrapper for creating and initializing projects, functions, collections, buckets, teams, messaging-topics, and agent skills in ${SDK_TITLE}.`,
100662
100772
  push: `The push command provides a convenient wrapper for pushing your functions, collections, buckets, teams, and messaging-topics.`,
100663
100773
  run: `The run command allows you to run the project locally to allow easy development and quick debugging.`,
100664
100774
  functions: `The functions command allows you to view, create, and manage your Cloud Functions.`,
@@ -101071,6 +101181,7 @@ var questionsInitProject = [
101071
101181
  }));
101072
101182
  },
101073
101183
  when: (answer) => {
101184
+ if (!whenOverride(answer)) return false;
101074
101185
  if (answer.start === "existing") return false;
101075
101186
  return isCloud();
101076
101187
  }
@@ -106123,6 +106234,9 @@ var Schema = class {
106123
106234
  });
106124
106235
  /*! Bundled license information:
106125
106236
 
106237
+ safe-buffer/index.js:
106238
+ (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
106239
+
106126
106240
  undici/lib/fetch/body.js:
106127
106241
  (*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> *)
106128
106242