appwrite-cli 13.6.0 → 14.0.0

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 (92) hide show
  1. package/.github/workflows/ci.yml +66 -0
  2. package/CHANGELOG.md +14 -0
  3. package/README.md +2 -2
  4. package/cli.ts +3 -3
  5. package/dist/bundle-win-arm64.mjs +608 -310
  6. package/dist/cli.cjs +608 -310
  7. package/dist/index.cjs +354 -183
  8. package/dist/index.js +354 -183
  9. package/dist/lib/commands/config-validations.d.ts +1 -1
  10. package/dist/lib/commands/config-validations.d.ts.map +1 -1
  11. package/dist/lib/commands/errors.d.ts +4 -4
  12. package/dist/lib/commands/errors.d.ts.map +1 -1
  13. package/dist/lib/commands/generate.d.ts +2 -0
  14. package/dist/lib/commands/generate.d.ts.map +1 -1
  15. package/dist/lib/commands/generators/base.d.ts +25 -2
  16. package/dist/lib/commands/generators/base.d.ts.map +1 -1
  17. package/dist/lib/commands/generators/index.d.ts +1 -1
  18. package/dist/lib/commands/generators/index.d.ts.map +1 -1
  19. package/dist/lib/commands/generators/typescript/databases.d.ts +2 -2
  20. package/dist/lib/commands/generators/typescript/databases.d.ts.map +1 -1
  21. package/dist/lib/commands/generic.d.ts.map +1 -1
  22. package/dist/lib/commands/init.d.ts.map +1 -1
  23. package/dist/lib/commands/run.d.ts.map +1 -1
  24. package/dist/lib/commands/types.d.ts.map +1 -1
  25. package/dist/lib/commands/update.d.ts.map +1 -1
  26. package/dist/lib/commands/utils/change-approval.d.ts +3 -3
  27. package/dist/lib/commands/utils/change-approval.d.ts.map +1 -1
  28. package/dist/lib/commands/utils/database-sync.d.ts.map +1 -1
  29. package/dist/lib/commands/utils/deployment.d.ts +16 -4
  30. package/dist/lib/commands/utils/deployment.d.ts.map +1 -1
  31. package/dist/lib/commands/utils/pools.d.ts.map +1 -1
  32. package/dist/lib/constants.d.ts +1 -1
  33. package/dist/lib/emulation/docker.d.ts.map +1 -1
  34. package/dist/lib/json.d.ts +1 -1
  35. package/dist/lib/json.d.ts.map +1 -1
  36. package/dist/lib/paginate.d.ts +5 -6
  37. package/dist/lib/paginate.d.ts.map +1 -1
  38. package/dist/lib/parser.d.ts +5 -4
  39. package/dist/lib/parser.d.ts.map +1 -1
  40. package/dist/lib/spinner.d.ts +1 -1
  41. package/dist/lib/spinner.d.ts.map +1 -1
  42. package/dist/lib/utils.d.ts +6 -1
  43. package/dist/lib/utils.d.ts.map +1 -1
  44. package/dist/lib/validations.d.ts +1 -1
  45. package/dist/lib/validations.d.ts.map +1 -1
  46. package/docs/examples/projects/update-status.md +5 -0
  47. package/docs/examples/sites/create-deployment.md +1 -2
  48. package/eslint.config.js +45 -0
  49. package/install.ps1 +2 -2
  50. package/install.sh +1 -1
  51. package/lib/client.ts +3 -3
  52. package/lib/commands/config-validations.ts +1 -1
  53. package/lib/commands/config.ts +2 -2
  54. package/lib/commands/errors.ts +2 -2
  55. package/lib/commands/generate.ts +23 -8
  56. package/lib/commands/generators/base.ts +33 -2
  57. package/lib/commands/generators/index.ts +1 -0
  58. package/lib/commands/generators/typescript/databases.ts +31 -21
  59. package/lib/commands/generators/typescript/templates/databases.ts.hbs +16 -16
  60. package/lib/commands/generic.ts +21 -16
  61. package/lib/commands/init.ts +147 -61
  62. package/lib/commands/pull.ts +1 -1
  63. package/lib/commands/push.ts +19 -19
  64. package/lib/commands/run.ts +15 -9
  65. package/lib/commands/services/account.ts +1 -1
  66. package/lib/commands/services/databases.ts +20 -19
  67. package/lib/commands/services/health.ts +13 -0
  68. package/lib/commands/services/messaging.ts +1 -1
  69. package/lib/commands/services/projects.ts +25 -0
  70. package/lib/commands/services/sites.ts +8 -3
  71. package/lib/commands/services/tables-db.ts +3 -2
  72. package/lib/commands/services/teams.ts +2 -2
  73. package/lib/commands/types.ts +18 -8
  74. package/lib/commands/update.ts +24 -16
  75. package/lib/commands/utils/attributes.ts +6 -6
  76. package/lib/commands/utils/change-approval.ts +26 -19
  77. package/lib/commands/utils/database-sync.ts +58 -18
  78. package/lib/commands/utils/deployment.ts +22 -5
  79. package/lib/commands/utils/pools.ts +11 -5
  80. package/lib/config.ts +1 -1
  81. package/lib/constants.ts +1 -1
  82. package/lib/emulation/docker.ts +5 -6
  83. package/lib/emulation/utils.ts +2 -2
  84. package/lib/json.ts +15 -7
  85. package/lib/paginate.ts +30 -20
  86. package/lib/parser.ts +46 -15
  87. package/lib/questions.ts +38 -38
  88. package/lib/spinner.ts +5 -1
  89. package/lib/utils.ts +15 -3
  90. package/lib/validations.ts +1 -1
  91. package/package.json +8 -2
  92. package/scoop/appwrite.config.json +3 -3
package/dist/cli.cjs CHANGED
@@ -2354,7 +2354,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2354
2354
  }
2355
2355
  return positiveOption || option2;
2356
2356
  };
2357
- const getErrorMessage = (option2) => {
2357
+ const getErrorMessage2 = (option2) => {
2358
2358
  const bestOption = findBestOptionFromValue(option2);
2359
2359
  const optionKey = bestOption.attributeName();
2360
2360
  const source = this.getOptionValueSource(optionKey);
@@ -2363,7 +2363,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2363
2363
  }
2364
2364
  return `option '${bestOption.flags}'`;
2365
2365
  };
2366
- const message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`;
2366
+ const message = `error: ${getErrorMessage2(option)} cannot be used with ${getErrorMessage2(conflictingOption)}`;
2367
2367
  this.error(message, { code: "commander.conflictingOption" });
2368
2368
  }
2369
2369
  /**
@@ -4309,9 +4309,9 @@ var require_source = __commonJS({
4309
4309
  }
4310
4310
  });
4311
4311
 
4312
- // node_modules/escape-string-regexp/index.js
4312
+ // node_modules/figures/node_modules/escape-string-regexp/index.js
4313
4313
  var require_escape_string_regexp = __commonJS({
4314
- "node_modules/escape-string-regexp/index.js"(exports2, module2) {
4314
+ "node_modules/figures/node_modules/escape-string-regexp/index.js"(exports2, module2) {
4315
4315
  "use strict";
4316
4316
  var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
4317
4317
  module2.exports = function(str) {
@@ -21956,9 +21956,9 @@ var require_stream_duplex = __commonJS({
21956
21956
  }
21957
21957
  });
21958
21958
 
21959
- // node_modules/string_decoder/node_modules/safe-buffer/index.js
21959
+ // node_modules/safe-buffer/index.js
21960
21960
  var require_safe_buffer = __commonJS({
21961
- "node_modules/string_decoder/node_modules/safe-buffer/index.js"(exports2, module2) {
21961
+ "node_modules/safe-buffer/index.js"(exports2, module2) {
21962
21962
  var buffer = require("buffer");
21963
21963
  var Buffer2 = buffer.Buffer;
21964
21964
  function copyProps(src, dst) {
@@ -61207,6 +61207,20 @@ var require_lodash = __commonJS({
61207
61207
  }
61208
61208
  });
61209
61209
 
61210
+ // node_modules/inquirer-search-list/node_modules/chalk/node_modules/escape-string-regexp/index.js
61211
+ var require_escape_string_regexp2 = __commonJS({
61212
+ "node_modules/inquirer-search-list/node_modules/chalk/node_modules/escape-string-regexp/index.js"(exports2, module2) {
61213
+ "use strict";
61214
+ var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
61215
+ module2.exports = function(str) {
61216
+ if (typeof str !== "string") {
61217
+ throw new TypeError("Expected a string");
61218
+ }
61219
+ return str.replace(matchOperatorsRe, "\\$&");
61220
+ };
61221
+ }
61222
+ });
61223
+
61210
61224
  // node_modules/inquirer-search-list/node_modules/chalk/node_modules/ansi-styles/node_modules/color-convert/node_modules/color-name/index.js
61211
61225
  var require_color_name2 = __commonJS({
61212
61226
  "node_modules/inquirer-search-list/node_modules/chalk/node_modules/ansi-styles/node_modules/color-convert/node_modules/color-name/index.js"(exports2, module2) {
@@ -62573,7 +62587,7 @@ var require_templates2 = __commonJS({
62573
62587
  var require_chalk = __commonJS({
62574
62588
  "node_modules/inquirer-search-list/node_modules/chalk/index.js"(exports2, module2) {
62575
62589
  "use strict";
62576
- var escapeStringRegexp = require_escape_string_regexp();
62590
+ var escapeStringRegexp = require_escape_string_regexp2();
62577
62591
  var ansiStyles = require_ansi_styles2();
62578
62592
  var stdoutColor = require_supports_color2().stdout;
62579
62593
  var template = require_templates2();
@@ -62736,11 +62750,25 @@ var require_chalk = __commonJS({
62736
62750
  }
62737
62751
  });
62738
62752
 
62753
+ // node_modules/inquirer-search-list/node_modules/figures/node_modules/escape-string-regexp/index.js
62754
+ var require_escape_string_regexp3 = __commonJS({
62755
+ "node_modules/inquirer-search-list/node_modules/figures/node_modules/escape-string-regexp/index.js"(exports2, module2) {
62756
+ "use strict";
62757
+ var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
62758
+ module2.exports = function(str) {
62759
+ if (typeof str !== "string") {
62760
+ throw new TypeError("Expected a string");
62761
+ }
62762
+ return str.replace(matchOperatorsRe, "\\$&");
62763
+ };
62764
+ }
62765
+ });
62766
+
62739
62767
  // node_modules/inquirer-search-list/node_modules/figures/index.js
62740
62768
  var require_figures2 = __commonJS({
62741
62769
  "node_modules/inquirer-search-list/node_modules/figures/index.js"(exports2, module2) {
62742
62770
  "use strict";
62743
- var escapeStringRegexp = require_escape_string_regexp();
62771
+ var escapeStringRegexp = require_escape_string_regexp3();
62744
62772
  var platform = process.platform;
62745
62773
  var main = {
62746
62774
  tick: "\u2714",
@@ -82336,9 +82364,9 @@ var require_is_glob = __commonJS({
82336
82364
  }
82337
82365
  });
82338
82366
 
82339
- // node_modules/glob-parent/index.js
82367
+ // node_modules/chokidar/node_modules/glob-parent/index.js
82340
82368
  var require_glob_parent = __commonJS({
82341
- "node_modules/glob-parent/index.js"(exports2, module2) {
82369
+ "node_modules/chokidar/node_modules/glob-parent/index.js"(exports2, module2) {
82342
82370
  "use strict";
82343
82371
  var isGlob = require_is_glob();
82344
82372
  var pathPosixDirname = require("path").posix.dirname;
@@ -92061,7 +92089,7 @@ var package_default = {
92061
92089
  type: "module",
92062
92090
  homepage: "https://appwrite.io/support",
92063
92091
  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",
92064
- version: "13.6.0",
92092
+ version: "14.0.0",
92065
92093
  license: "BSD-3-Clause",
92066
92094
  main: "dist/index.cjs",
92067
92095
  module: "dist/index.js",
@@ -92092,6 +92120,7 @@ var package_default = {
92092
92120
  "build:lib:esm": "esbuild index.ts --bundle --platform=node --target=node18 --format=esm --loader:.hbs=text --outfile=dist/index.js",
92093
92121
  "build:lib:cjs": "esbuild index.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --outfile=dist/index.cjs",
92094
92122
  "build:cli": "esbuild cli.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:fsevents --outfile=dist/cli.cjs",
92123
+ lint: "eslint .",
92095
92124
  format: 'prettier --write "**/*.{js,ts,json,md}"',
92096
92125
  generate: "tsx scripts/generate-commands.ts",
92097
92126
  prepublishOnly: "npm run build",
@@ -92104,7 +92133,7 @@ var package_default = {
92104
92133
  "windows-arm64": "esbuild cli.ts --bundle --loader:.hbs=text --platform=node --target=node18 --format=esm --external:fsevents --outfile=dist/bundle-win-arm64.mjs && pkg dist/bundle-win-arm64.mjs -t node18-win-arm64 -o build/appwrite-cli-win-arm64.exe"
92105
92134
  },
92106
92135
  dependencies: {
92107
- "@appwrite.io/console": "^3.1.0",
92136
+ "@appwrite.io/console": "^4.0.0",
92108
92137
  chalk: "4.1.2",
92109
92138
  chokidar: "^3.6.0",
92110
92139
  "cli-progress": "^3.12.0",
@@ -92123,7 +92152,12 @@ var package_default = {
92123
92152
  zod: "^4.3.5"
92124
92153
  },
92125
92154
  devDependencies: {
92155
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
92156
+ "@typescript-eslint/parser": "^8.0.0",
92126
92157
  "@types/bun": "^1.3.5",
92158
+ eslint: "^9.0.0",
92159
+ "eslint-plugin-unused-imports": "^4.0.0",
92160
+ "typescript-eslint": "^8.0.0",
92127
92161
  "@types/cli-progress": "^3.11.5",
92128
92162
  "@types/inquirer": "^8.2.10",
92129
92163
  "@types/json-bigint": "^1.0.4",
@@ -106046,7 +106080,7 @@ var int64Schema = external_exports.preprocess(
106046
106080
  const valueOfResult = val.valueOf();
106047
106081
  const bigIntVal = BigInt(valueOfResult);
106048
106082
  return bigIntVal;
106049
- } catch (e) {
106083
+ } catch (_e) {
106050
106084
  return void 0;
106051
106085
  }
106052
106086
  }
@@ -106056,7 +106090,7 @@ var int64Schema = external_exports.preprocess(
106056
106090
  if (typeof val === "string") {
106057
106091
  try {
106058
106092
  return BigInt(val);
106059
- } catch (e) {
106093
+ } catch (_e) {
106060
106094
  return void 0;
106061
106095
  }
106062
106096
  }
@@ -106338,7 +106372,7 @@ var import_undici = __toESM(require_undici(), 1);
106338
106372
  // lib/constants.ts
106339
106373
  var SDK_TITLE = "Appwrite";
106340
106374
  var SDK_TITLE_LOWER = "appwrite";
106341
- var SDK_VERSION = "13.6.0";
106375
+ var SDK_VERSION = "14.0.0";
106342
106376
  var SDK_NAME = "Command Line";
106343
106377
  var SDK_PLATFORM = "console";
106344
106378
  var SDK_LANGUAGE = "cli";
@@ -106390,6 +106424,12 @@ var createSettingsObject = (project2) => {
106390
106424
  }
106391
106425
  };
106392
106426
  };
106427
+ var getErrorMessage = (error49) => {
106428
+ if (error49 instanceof Error) {
106429
+ return error49.message;
106430
+ }
106431
+ return String(error49);
106432
+ };
106393
106433
  async function getLatestVersion() {
106394
106434
  try {
106395
106435
  const response = await (0, import_undici.fetch)(NPM_REGISTRY_URL);
@@ -106420,7 +106460,7 @@ function getAllFiles(folder) {
106420
106460
  let stats;
106421
106461
  try {
106422
106462
  stats = import_fs.default.statSync(pathAbsolute);
106423
- } catch (error49) {
106463
+ } catch (_error) {
106424
106464
  continue;
106425
106465
  }
106426
106466
  if (stats.isDirectory()) {
@@ -106465,7 +106505,7 @@ function systemHasCommand(command) {
106465
106505
  return true;
106466
106506
  }
106467
106507
  var checkDeployConditions = (localConfig2) => {
106468
- if (Object.keys(localConfig2.data).length === 0) {
106508
+ if (localConfig2.keys().length === 0) {
106469
106509
  throw new Error(
106470
106510
  "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."
106471
106511
  );
@@ -106613,7 +106653,7 @@ var Config = class {
106613
106653
  try {
106614
106654
  const file2 = import_fs2.default.readFileSync(this.path).toString();
106615
106655
  this.data = JSONBig.parse(file2);
106616
- } catch (e) {
106656
+ } catch (_e) {
106617
106657
  this.data = {};
106618
106658
  }
106619
106659
  }
@@ -107371,7 +107411,7 @@ var Client = class _Client {
107371
107411
  "x-sdk-name": "Console",
107372
107412
  "x-sdk-platform": "console",
107373
107413
  "x-sdk-language": "web",
107374
- "x-sdk-version": "3.1.0",
107414
+ "x-sdk-version": "4.0.0",
107375
107415
  "X-Appwrite-Response-Format": "1.8.0"
107376
107416
  };
107377
107417
  this.realtime = {
@@ -112493,6 +112533,47 @@ var Databases = class {
112493
112533
  };
112494
112534
  return this.client.call("post", uri, apiHeaders, payload);
112495
112535
  }
112536
+ updateRelationshipAttribute(paramsOrFirst, ...rest) {
112537
+ let params;
112538
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
112539
+ params = paramsOrFirst || {};
112540
+ } else {
112541
+ params = {
112542
+ databaseId: paramsOrFirst,
112543
+ collectionId: rest[0],
112544
+ key: rest[1],
112545
+ onDelete: rest[2],
112546
+ newKey: rest[3]
112547
+ };
112548
+ }
112549
+ const databaseId = params.databaseId;
112550
+ const collectionId = params.collectionId;
112551
+ const key = params.key;
112552
+ const onDelete = params.onDelete;
112553
+ const newKey = params.newKey;
112554
+ if (typeof databaseId === "undefined") {
112555
+ throw new AppwriteException('Missing required parameter: "databaseId"');
112556
+ }
112557
+ if (typeof collectionId === "undefined") {
112558
+ throw new AppwriteException('Missing required parameter: "collectionId"');
112559
+ }
112560
+ if (typeof key === "undefined") {
112561
+ throw new AppwriteException('Missing required parameter: "key"');
112562
+ }
112563
+ const apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{key}", key);
112564
+ const payload = {};
112565
+ if (typeof onDelete !== "undefined") {
112566
+ payload["onDelete"] = onDelete;
112567
+ }
112568
+ if (typeof newKey !== "undefined") {
112569
+ payload["newKey"] = newKey;
112570
+ }
112571
+ const uri = new URL(this.client.config.endpoint + apiPath);
112572
+ const apiHeaders = {
112573
+ "content-type": "application/json"
112574
+ };
112575
+ return this.client.call("patch", uri, apiHeaders, payload);
112576
+ }
112496
112577
  createStringAttribute(paramsOrFirst, ...rest) {
112497
112578
  let params;
112498
112579
  if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
@@ -113010,47 +113091,6 @@ var Databases = class {
113010
113091
  };
113011
113092
  return this.client.call("delete", uri, apiHeaders, payload);
113012
113093
  }
113013
- updateRelationshipAttribute(paramsOrFirst, ...rest) {
113014
- let params;
113015
- if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
113016
- params = paramsOrFirst || {};
113017
- } else {
113018
- params = {
113019
- databaseId: paramsOrFirst,
113020
- collectionId: rest[0],
113021
- key: rest[1],
113022
- onDelete: rest[2],
113023
- newKey: rest[3]
113024
- };
113025
- }
113026
- const databaseId = params.databaseId;
113027
- const collectionId = params.collectionId;
113028
- const key = params.key;
113029
- const onDelete = params.onDelete;
113030
- const newKey = params.newKey;
113031
- if (typeof databaseId === "undefined") {
113032
- throw new AppwriteException('Missing required parameter: "databaseId"');
113033
- }
113034
- if (typeof collectionId === "undefined") {
113035
- throw new AppwriteException('Missing required parameter: "collectionId"');
113036
- }
113037
- if (typeof key === "undefined") {
113038
- throw new AppwriteException('Missing required parameter: "key"');
113039
- }
113040
- const apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{key}", key);
113041
- const payload = {};
113042
- if (typeof onDelete !== "undefined") {
113043
- payload["onDelete"] = onDelete;
113044
- }
113045
- if (typeof newKey !== "undefined") {
113046
- payload["newKey"] = newKey;
113047
- }
113048
- const uri = new URL(this.client.config.endpoint + apiPath);
113049
- const apiHeaders = {
113050
- "content-type": "application/json"
113051
- };
113052
- return this.client.call("patch", uri, apiHeaders, payload);
113053
- }
113054
113094
  listDocuments(paramsOrFirst, ...rest) {
113055
113095
  let params;
113056
113096
  if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
@@ -113061,7 +113101,8 @@ var Databases = class {
113061
113101
  collectionId: rest[0],
113062
113102
  queries: rest[1],
113063
113103
  transactionId: rest[2],
113064
- total: rest[3]
113104
+ total: rest[3],
113105
+ ttl: rest[4]
113065
113106
  };
113066
113107
  }
113067
113108
  const databaseId = params.databaseId;
@@ -113069,6 +113110,7 @@ var Databases = class {
113069
113110
  const queries = params.queries;
113070
113111
  const transactionId = params.transactionId;
113071
113112
  const total = params.total;
113113
+ const ttl = params.ttl;
113072
113114
  if (typeof databaseId === "undefined") {
113073
113115
  throw new AppwriteException('Missing required parameter: "databaseId"');
113074
113116
  }
@@ -113086,6 +113128,9 @@ var Databases = class {
113086
113128
  if (typeof total !== "undefined") {
113087
113129
  payload["total"] = total;
113088
113130
  }
113131
+ if (typeof ttl !== "undefined") {
113132
+ payload["ttl"] = ttl;
113133
+ }
113089
113134
  const uri = new URL(this.client.config.endpoint + apiPath);
113090
113135
  const apiHeaders = {};
113091
113136
  return this.client.call("get", uri, apiHeaders, payload);
@@ -115051,6 +115096,30 @@ var Health = class {
115051
115096
  const apiHeaders = {};
115052
115097
  return this.client.call("get", uri, apiHeaders, payload);
115053
115098
  }
115099
+ getConsolePausing(paramsOrFirst, ...rest) {
115100
+ let params;
115101
+ if (!paramsOrFirst || paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
115102
+ params = paramsOrFirst || {};
115103
+ } else {
115104
+ params = {
115105
+ threshold: paramsOrFirst,
115106
+ inactivityDays: rest[0]
115107
+ };
115108
+ }
115109
+ const threshold = params.threshold;
115110
+ const inactivityDays = params.inactivityDays;
115111
+ const apiPath = "/health/console-pausing";
115112
+ const payload = {};
115113
+ if (typeof threshold !== "undefined") {
115114
+ payload["threshold"] = threshold;
115115
+ }
115116
+ if (typeof inactivityDays !== "undefined") {
115117
+ payload["inactivityDays"] = inactivityDays;
115118
+ }
115119
+ const uri = new URL(this.client.config.endpoint + apiPath);
115120
+ const apiHeaders = {};
115121
+ return this.client.call("get", uri, apiHeaders, payload);
115122
+ }
115054
115123
  /**
115055
115124
  * Check the Appwrite database servers are up and connection is successful.
115056
115125
  *
@@ -121136,6 +121205,27 @@ var Projects = class {
121136
121205
  };
121137
121206
  return this.client.call("patch", uri, apiHeaders, payload);
121138
121207
  }
121208
+ updateConsoleAccess(paramsOrFirst) {
121209
+ let params;
121210
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
121211
+ params = paramsOrFirst || {};
121212
+ } else {
121213
+ params = {
121214
+ projectId: paramsOrFirst
121215
+ };
121216
+ }
121217
+ const projectId = params.projectId;
121218
+ if (typeof projectId === "undefined") {
121219
+ throw new AppwriteException('Missing required parameter: "projectId"');
121220
+ }
121221
+ const apiPath = "/projects/{projectId}/console-access".replace("{projectId}", projectId);
121222
+ const payload = {};
121223
+ const uri = new URL(this.client.config.endpoint + apiPath);
121224
+ const apiHeaders = {
121225
+ "content-type": "application/json"
121226
+ };
121227
+ return this.client.call("patch", uri, apiHeaders, payload);
121228
+ }
121139
121229
  listDevKeys(paramsOrFirst, ...rest) {
121140
121230
  let params;
121141
121231
  if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
@@ -122212,6 +122302,35 @@ var Projects = class {
122212
122302
  };
122213
122303
  return this.client.call("post", uri, apiHeaders, payload);
122214
122304
  }
122305
+ updateStatus(paramsOrFirst, ...rest) {
122306
+ let params;
122307
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
122308
+ params = paramsOrFirst || {};
122309
+ } else {
122310
+ params = {
122311
+ projectId: paramsOrFirst,
122312
+ status: rest[0]
122313
+ };
122314
+ }
122315
+ const projectId = params.projectId;
122316
+ const status = params.status;
122317
+ if (typeof projectId === "undefined") {
122318
+ throw new AppwriteException('Missing required parameter: "projectId"');
122319
+ }
122320
+ if (typeof status === "undefined") {
122321
+ throw new AppwriteException('Missing required parameter: "status"');
122322
+ }
122323
+ const apiPath = "/projects/{projectId}/status".replace("{projectId}", projectId);
122324
+ const payload = {};
122325
+ if (typeof status !== "undefined") {
122326
+ payload["status"] = status;
122327
+ }
122328
+ const uri = new URL(this.client.config.endpoint + apiPath);
122329
+ const apiHeaders = {
122330
+ "content-type": "application/json"
122331
+ };
122332
+ return this.client.call("patch", uri, apiHeaders, payload);
122333
+ }
122215
122334
  updateTeam(paramsOrFirst, ...rest) {
122216
122335
  let params;
122217
122336
  if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
@@ -123526,28 +123645,25 @@ var Sites = class {
123526
123645
  params = {
123527
123646
  siteId: paramsOrFirst,
123528
123647
  code: rest[0],
123529
- activate: rest[1],
123530
- installCommand: rest[2],
123531
- buildCommand: rest[3],
123532
- outputDirectory: rest[4]
123648
+ installCommand: rest[1],
123649
+ buildCommand: rest[2],
123650
+ outputDirectory: rest[3],
123651
+ activate: rest[4]
123533
123652
  };
123534
123653
  onProgress = rest[5];
123535
123654
  }
123536
123655
  const siteId = params.siteId;
123537
123656
  const code = params.code;
123538
- const activate = params.activate;
123539
123657
  const installCommand = params.installCommand;
123540
123658
  const buildCommand = params.buildCommand;
123541
123659
  const outputDirectory = params.outputDirectory;
123660
+ const activate = params.activate;
123542
123661
  if (typeof siteId === "undefined") {
123543
123662
  throw new AppwriteException('Missing required parameter: "siteId"');
123544
123663
  }
123545
123664
  if (typeof code === "undefined") {
123546
123665
  throw new AppwriteException('Missing required parameter: "code"');
123547
123666
  }
123548
- if (typeof activate === "undefined") {
123549
- throw new AppwriteException('Missing required parameter: "activate"');
123550
- }
123551
123667
  const apiPath = "/sites/{siteId}/deployments".replace("{siteId}", siteId);
123552
123668
  const payload = {};
123553
123669
  if (typeof installCommand !== "undefined") {
@@ -127285,7 +127401,8 @@ var TablesDB = class {
127285
127401
  tableId: rest[0],
127286
127402
  queries: rest[1],
127287
127403
  transactionId: rest[2],
127288
- total: rest[3]
127404
+ total: rest[3],
127405
+ ttl: rest[4]
127289
127406
  };
127290
127407
  }
127291
127408
  const databaseId = params.databaseId;
@@ -127293,6 +127410,7 @@ var TablesDB = class {
127293
127410
  const queries = params.queries;
127294
127411
  const transactionId = params.transactionId;
127295
127412
  const total = params.total;
127413
+ const ttl = params.ttl;
127296
127414
  if (typeof databaseId === "undefined") {
127297
127415
  throw new AppwriteException('Missing required parameter: "databaseId"');
127298
127416
  }
@@ -127310,6 +127428,9 @@ var TablesDB = class {
127310
127428
  if (typeof total !== "undefined") {
127311
127429
  payload["total"] = total;
127312
127430
  }
127431
+ if (typeof ttl !== "undefined") {
127432
+ payload["ttl"] = ttl;
127433
+ }
127313
127434
  const uri = new URL(this.client.config.endpoint + apiPath);
127314
127435
  const apiHeaders = {};
127315
127436
  return this.client.call("get", uri, apiHeaders, payload);
@@ -131576,20 +131697,69 @@ var SmtpEncryption;
131576
131697
  SmtpEncryption2["Ssl"] = "ssl";
131577
131698
  SmtpEncryption2["Tls"] = "tls";
131578
131699
  })(SmtpEncryption || (SmtpEncryption = {}));
131579
- var Resources;
131580
- (function(Resources2) {
131581
- Resources2["User"] = "user";
131582
- Resources2["Database"] = "database";
131583
- Resources2["Table"] = "table";
131584
- Resources2["Column"] = "column";
131585
- Resources2["Index"] = "index";
131586
- Resources2["Row"] = "row";
131587
- Resources2["Document"] = "document";
131588
- Resources2["Attribute"] = "attribute";
131589
- Resources2["Collection"] = "collection";
131590
- Resources2["Bucket"] = "bucket";
131591
- Resources2["File"] = "file";
131592
- })(Resources || (Resources = {}));
131700
+ var AppwriteMigrationResource;
131701
+ (function(AppwriteMigrationResource2) {
131702
+ AppwriteMigrationResource2["User"] = "user";
131703
+ AppwriteMigrationResource2["Team"] = "team";
131704
+ AppwriteMigrationResource2["Membership"] = "membership";
131705
+ AppwriteMigrationResource2["Database"] = "database";
131706
+ AppwriteMigrationResource2["Table"] = "table";
131707
+ AppwriteMigrationResource2["Column"] = "column";
131708
+ AppwriteMigrationResource2["Index"] = "index";
131709
+ AppwriteMigrationResource2["Row"] = "row";
131710
+ AppwriteMigrationResource2["Document"] = "document";
131711
+ AppwriteMigrationResource2["Attribute"] = "attribute";
131712
+ AppwriteMigrationResource2["Collection"] = "collection";
131713
+ AppwriteMigrationResource2["Bucket"] = "bucket";
131714
+ AppwriteMigrationResource2["File"] = "file";
131715
+ AppwriteMigrationResource2["Function"] = "function";
131716
+ AppwriteMigrationResource2["Deployment"] = "deployment";
131717
+ AppwriteMigrationResource2["Environmentvariable"] = "environment-variable";
131718
+ AppwriteMigrationResource2["Site"] = "site";
131719
+ AppwriteMigrationResource2["Sitedeployment"] = "site-deployment";
131720
+ AppwriteMigrationResource2["Sitevariable"] = "site-variable";
131721
+ })(AppwriteMigrationResource || (AppwriteMigrationResource = {}));
131722
+ var FirebaseMigrationResource;
131723
+ (function(FirebaseMigrationResource2) {
131724
+ FirebaseMigrationResource2["User"] = "user";
131725
+ FirebaseMigrationResource2["Database"] = "database";
131726
+ FirebaseMigrationResource2["Table"] = "table";
131727
+ FirebaseMigrationResource2["Column"] = "column";
131728
+ FirebaseMigrationResource2["Row"] = "row";
131729
+ FirebaseMigrationResource2["Document"] = "document";
131730
+ FirebaseMigrationResource2["Attribute"] = "attribute";
131731
+ FirebaseMigrationResource2["Collection"] = "collection";
131732
+ FirebaseMigrationResource2["Bucket"] = "bucket";
131733
+ FirebaseMigrationResource2["File"] = "file";
131734
+ })(FirebaseMigrationResource || (FirebaseMigrationResource = {}));
131735
+ var NHostMigrationResource;
131736
+ (function(NHostMigrationResource2) {
131737
+ NHostMigrationResource2["User"] = "user";
131738
+ NHostMigrationResource2["Database"] = "database";
131739
+ NHostMigrationResource2["Table"] = "table";
131740
+ NHostMigrationResource2["Column"] = "column";
131741
+ NHostMigrationResource2["Index"] = "index";
131742
+ NHostMigrationResource2["Row"] = "row";
131743
+ NHostMigrationResource2["Document"] = "document";
131744
+ NHostMigrationResource2["Attribute"] = "attribute";
131745
+ NHostMigrationResource2["Collection"] = "collection";
131746
+ NHostMigrationResource2["Bucket"] = "bucket";
131747
+ NHostMigrationResource2["File"] = "file";
131748
+ })(NHostMigrationResource || (NHostMigrationResource = {}));
131749
+ var SupabaseMigrationResource;
131750
+ (function(SupabaseMigrationResource2) {
131751
+ SupabaseMigrationResource2["User"] = "user";
131752
+ SupabaseMigrationResource2["Database"] = "database";
131753
+ SupabaseMigrationResource2["Table"] = "table";
131754
+ SupabaseMigrationResource2["Column"] = "column";
131755
+ SupabaseMigrationResource2["Index"] = "index";
131756
+ SupabaseMigrationResource2["Row"] = "row";
131757
+ SupabaseMigrationResource2["Document"] = "document";
131758
+ SupabaseMigrationResource2["Attribute"] = "attribute";
131759
+ SupabaseMigrationResource2["Collection"] = "collection";
131760
+ SupabaseMigrationResource2["Bucket"] = "bucket";
131761
+ SupabaseMigrationResource2["File"] = "file";
131762
+ })(SupabaseMigrationResource || (SupabaseMigrationResource = {}));
131593
131763
  var ProjectUsageRange;
131594
131764
  (function(ProjectUsageRange2) {
131595
131765
  ProjectUsageRange2["OneHour"] = "1h";
@@ -131666,6 +131836,10 @@ var SMTPSecure;
131666
131836
  SMTPSecure2["Tls"] = "tls";
131667
131837
  SMTPSecure2["Ssl"] = "ssl";
131668
131838
  })(SMTPSecure || (SMTPSecure = {}));
131839
+ var Status;
131840
+ (function(Status2) {
131841
+ Status2["Active"] = "active";
131842
+ })(Status || (Status = {}));
131669
131843
  var EmailTemplateType;
131670
131844
  (function(EmailTemplateType2) {
131671
131845
  EmailTemplateType2["Verification"] = "verification";
@@ -132225,6 +132399,17 @@ var BillingPlanGroup;
132225
132399
  BillingPlanGroup2["Pro"] = "pro";
132226
132400
  BillingPlanGroup2["Scale"] = "scale";
132227
132401
  })(BillingPlanGroup || (BillingPlanGroup = {}));
132402
+ var DomainTransferStatusStatus;
132403
+ (function(DomainTransferStatusStatus2) {
132404
+ DomainTransferStatusStatus2["Transferrable"] = "transferrable";
132405
+ DomainTransferStatusStatus2["NotTransferrable"] = "not_transferrable";
132406
+ DomainTransferStatusStatus2["PendingOwner"] = "pending_owner";
132407
+ DomainTransferStatusStatus2["PendingAdmin"] = "pending_admin";
132408
+ DomainTransferStatusStatus2["PendingRegistry"] = "pending_registry";
132409
+ DomainTransferStatusStatus2["Completed"] = "completed";
132410
+ DomainTransferStatusStatus2["Cancelled"] = "cancelled";
132411
+ DomainTransferStatusStatus2["ServiceUnavailable"] = "service_unavailable";
132412
+ })(DomainTransferStatusStatus || (DomainTransferStatusStatus = {}));
132228
132413
 
132229
132414
  // lib/parser.ts
132230
132415
  var { description } = package_default;
@@ -132237,6 +132422,22 @@ var cliConfig = {
132237
132422
  report: false,
132238
132423
  reportData: {}
132239
132424
  };
132425
+ var toJsonObject = (value) => {
132426
+ if (value && typeof value === "object" && !Array.isArray(value)) {
132427
+ return value;
132428
+ }
132429
+ return null;
132430
+ };
132431
+ var extractReportCommandArgs = (value) => {
132432
+ if (!value || typeof value !== "object") {
132433
+ return [];
132434
+ }
132435
+ const reportData = value;
132436
+ if (!Array.isArray(reportData.data?.args)) {
132437
+ return [];
132438
+ }
132439
+ return reportData.data.args;
132440
+ };
132240
132441
  var parse3 = (data) => {
132241
132442
  if (cliConfig.json) {
132242
132443
  drawJSON(data);
@@ -132257,7 +132458,8 @@ var parse3 = (data) => {
132257
132458
  console.log(`${import_chalk.default.yellow.bold(key)} : ${data[key]}`);
132258
132459
  } else {
132259
132460
  console.log(`${import_chalk.default.yellow.bold.underline(key)}`);
132260
- drawTable([data[key]]);
132461
+ const tableRow = toJsonObject(data[key]) ?? {};
132462
+ drawTable([tableRow]);
132261
132463
  }
132262
132464
  } else {
132263
132465
  console.log(`${import_chalk.default.yellow.bold(key)} : ${data[key]}`);
@@ -132269,9 +132471,7 @@ var drawTable = (data) => {
132269
132471
  console.log("[]");
132270
132472
  return;
132271
132473
  }
132272
- const rows = data.map(
132273
- (item) => item && typeof item === "object" && !Array.isArray(item) ? item : {}
132274
- );
132474
+ const rows = data.map((item) => toJsonObject(item) ?? {});
132275
132475
  const obj = rows.reduce((res, item) => ({ ...res, ...item }), {});
132276
132476
  const keys = Object.keys(obj);
132277
132477
  if (keys.length === 0) {
@@ -132314,7 +132514,7 @@ var drawTable = (data) => {
132314
132514
  } else if (typeof row[key] === "object") {
132315
132515
  rowValues.push(JSON.stringify(row[key]));
132316
132516
  } else {
132317
- rowValues.push(row[key]);
132517
+ rowValues.push(String(row[key]));
132318
132518
  }
132319
132519
  }
132320
132520
  table.push(rowValues);
@@ -132326,7 +132526,7 @@ var drawJSON = (data) => {
132326
132526
  };
132327
132527
  var parseError = (err) => {
132328
132528
  if (cliConfig.report) {
132329
- (async () => {
132529
+ void (async () => {
132330
132530
  let appwriteVersion = "unknown";
132331
132531
  const endpoint = globalConfig2.getEndpoint();
132332
132532
  try {
@@ -132339,7 +132539,8 @@ var parseError = (err) => {
132339
132539
  } catch {
132340
132540
  }
132341
132541
  const version4 = SDK_VERSION;
132342
- const stepsToReproduce = `Running \`${EXECUTABLE_NAME} ${cliConfig.reportData.data.args.join(" ")}\``;
132542
+ const commandArgs = extractReportCommandArgs(cliConfig.reportData);
132543
+ const stepsToReproduce = `Running \`${EXECUTABLE_NAME} ${commandArgs.join(" ")}\``;
132343
132544
  const yourEnvironment = `CLI version: ${version4}
132344
132545
  Operation System: ${import_os2.default.type()}
132345
132546
  Appwrite version: ${appwriteVersion}
@@ -132391,7 +132592,7 @@ var actionRunner = (fn) => {
132391
132592
  error48(`The '--all' and '--id' flags cannot be used together.`);
132392
132593
  process.exit(1);
132393
132594
  }
132394
- return fn(...args).catch(parseError);
132595
+ return fn(...args).then(() => void 0).catch(parseError);
132395
132596
  };
132396
132597
  };
132397
132598
  var parseInteger = (value) => {
@@ -132577,19 +132778,22 @@ async function paginate(action, args = {}, limit = 100, wrapper = "", queries =
132577
132778
  ]
132578
132779
  });
132579
132780
  if (wrapper === "") {
132580
- if (response.length === 0) {
132781
+ const listResponse = response;
132782
+ if (listResponse.length === 0) {
132581
132783
  break;
132582
132784
  }
132583
- results = results.concat(response);
132785
+ results = results.concat(listResponse);
132584
132786
  } else {
132585
- if (response[wrapper].length === 0) {
132787
+ const wrappedResponse = response;
132788
+ const wrappedResults = wrappedResponse[wrapper] ?? [];
132789
+ if (wrappedResults.length === 0) {
132790
+ break;
132791
+ }
132792
+ results = results.concat(wrappedResults);
132793
+ total = wrappedResponse.total;
132794
+ if (results.length >= total) {
132586
132795
  break;
132587
132796
  }
132588
- results = results.concat(response[wrapper]);
132589
- }
132590
- total = response.total;
132591
- if (results.length >= total) {
132592
- break;
132593
132797
  }
132594
132798
  pageNumber++;
132595
132799
  }
@@ -132776,7 +132980,7 @@ var questionsInitProject = [
132776
132980
  name: "organization",
132777
132981
  message: "Choose your organization",
132778
132982
  choices: async () => {
132779
- let client2 = await sdkForConsole(true);
132983
+ const client2 = await sdkForConsole(true);
132780
132984
  const { teams: teams2 } = isCloud() ? await paginate(
132781
132985
  async (opts = {}) => (await getOrganizationsService(opts.sdk)).list(),
132782
132986
  { sdk: client2 },
@@ -132788,7 +132992,7 @@ var questionsInitProject = [
132788
132992
  100,
132789
132993
  "teams"
132790
132994
  );
132791
- let choices = teams2.map((team, idx) => {
132995
+ const choices = teams2.map((team, _idx) => {
132792
132996
  return {
132793
132997
  name: `${team.name} (${team["$id"]})`,
132794
132998
  value: team["$id"]
@@ -132837,7 +133041,7 @@ var questionsInitProject = [
132837
133041
  "projects",
132838
133042
  queries
132839
133043
  );
132840
- let choices = projects2.map((project2) => {
133044
+ const choices = projects2.map((project2) => {
132841
133045
  return {
132842
133046
  name: `${project2.name} (${project2["$id"]})`,
132843
133047
  value: {
@@ -132858,13 +133062,13 @@ var questionsInitProject = [
132858
133062
  name: "region",
132859
133063
  message: `Select your ${SDK_TITLE} Cloud region`,
132860
133064
  choices: async () => {
132861
- let client2 = await sdkForConsole(true);
133065
+ const client2 = await sdkForConsole(true);
132862
133066
  const endpoint = globalConfig2.getEndpoint() || DEFAULT_ENDPOINT;
132863
- let response = await client2.call(
133067
+ const response = await client2.call(
132864
133068
  "GET",
132865
133069
  new URL(endpoint + "/console/regions")
132866
133070
  );
132867
- let regions = response.regions || [];
133071
+ const regions = response.regions || [];
132868
133072
  if (!regions.length) {
132869
133073
  throw new Error(
132870
133074
  "No regions found. Please check your network or Appwrite Cloud availability."
@@ -133006,9 +133210,9 @@ var questionsCreateFunction = [
133006
133210
  name: "runtime",
133007
133211
  message: "What runtime would you like to use?",
133008
133212
  choices: async () => {
133009
- let response = await (await getFunctionsService()).listRuntimes();
133010
- let runtimes = response["runtimes"];
133011
- let choices = runtimes.map((runtime, idx) => {
133213
+ const response = await (await getFunctionsService()).listRuntimes();
133214
+ const runtimes = response["runtimes"];
133215
+ const choices = runtimes.map((runtime, _idx) => {
133012
133216
  return {
133013
133217
  name: `${runtime.name} (${runtime["$id"]})`,
133014
133218
  value: {
@@ -133028,9 +133232,9 @@ var questionsCreateFunction = [
133028
133232
  name: "specification",
133029
133233
  message: "What specification would you like to use?",
133030
133234
  choices: async () => {
133031
- let response = await (await getFunctionsService()).listSpecifications();
133032
- let specifications = response["specifications"];
133033
- let choices = specifications.map((spec, idx) => {
133235
+ const response = await (await getFunctionsService()).listSpecifications();
133236
+ const specifications = response["specifications"];
133237
+ const choices = specifications.map((spec, _idx) => {
133034
133238
  return {
133035
133239
  name: `${spec.cpus} CPU, ${spec.memory}MB RAM`,
133036
133240
  value: spec.slug,
@@ -133107,7 +133311,7 @@ var questionsCreateCollection = [
133107
133311
  message: "Choose the collection database",
133108
133312
  choices: async () => {
133109
133313
  const databases2 = localConfig.getDatabases();
133110
- let choices = databases2.map((database, idx) => {
133314
+ const choices = databases2.map((database, _idx) => {
133111
133315
  return {
133112
133316
  name: `${database.name} (${database.$id})`,
133113
133317
  value: database.$id
@@ -133171,7 +133375,7 @@ var questionsCreateTable = [
133171
133375
  message: "Choose the table database",
133172
133376
  choices: async () => {
133173
133377
  const databases2 = localConfig.getTablesDBs();
133174
- let choices = databases2.map((database, idx) => {
133378
+ const choices = databases2.map((database, _idx) => {
133175
133379
  return {
133176
133380
  name: `${database.name} (${database.$id})`,
133177
133381
  value: database.$id
@@ -133305,9 +133509,9 @@ var questionGetEndpoint = [
133305
133509
  if (!value) {
133306
133510
  return "Please enter a valid endpoint.";
133307
133511
  }
133308
- let client2 = new Client().setEndpoint(value);
133512
+ const client2 = new Client().setEndpoint(value);
133309
133513
  try {
133310
- let response = await client2.call(
133514
+ const response = await client2.call(
133311
133515
  "get",
133312
133516
  new URL(value + "/health/version")
133313
133517
  );
@@ -133316,7 +133520,7 @@ var questionGetEndpoint = [
133316
133520
  } else {
133317
133521
  throw new Error();
133318
133522
  }
133319
- } catch (error49) {
133523
+ } catch (_error) {
133320
133524
  return "Invalid endpoint or your Appwrite server is not running as expected.";
133321
133525
  }
133322
133526
  }
@@ -133394,9 +133598,9 @@ var questionsPushSites = [
133394
133598
  validate: (value) => validateRequired("site", value),
133395
133599
  when: () => localConfig.getSites().length > 0,
133396
133600
  choices: () => {
133397
- let sites2 = localConfig.getSites();
133601
+ const sites2 = localConfig.getSites();
133398
133602
  checkDeployConditions(localConfig);
133399
- let choices = sites2.map((site, idx) => {
133603
+ const choices = sites2.map((site, _idx) => {
133400
133604
  return {
133401
133605
  name: `${site.name} (${site.$id})`,
133402
133606
  value: site.$id
@@ -133414,9 +133618,9 @@ var questionsPushFunctions = [
133414
133618
  validate: (value) => validateRequired("function", value),
133415
133619
  when: () => localConfig.getFunctions().length > 0,
133416
133620
  choices: () => {
133417
- let functions2 = localConfig.getFunctions();
133621
+ const functions2 = localConfig.getFunctions();
133418
133622
  checkDeployConditions(localConfig);
133419
- let choices = functions2.map((func, idx) => {
133623
+ const choices = functions2.map((func, _idx) => {
133420
133624
  return {
133421
133625
  name: `${func.name} (${func.$id})`,
133422
133626
  value: func.$id
@@ -133434,7 +133638,7 @@ var questionsPushCollections = [
133434
133638
  validate: (value) => validateRequired("collection", value),
133435
133639
  when: () => localConfig.getCollections().length > 0,
133436
133640
  choices: () => {
133437
- let collections = localConfig.getCollections();
133641
+ const collections = localConfig.getCollections();
133438
133642
  checkDeployConditions(localConfig);
133439
133643
  return collections.map((collection) => {
133440
133644
  return {
@@ -133453,7 +133657,7 @@ var questionsPushTables = [
133453
133657
  validate: (value) => validateRequired("table", value),
133454
133658
  when: () => localConfig.getTables().length > 0,
133455
133659
  choices: () => {
133456
- let tables = localConfig.getTables();
133660
+ const tables = localConfig.getTables();
133457
133661
  checkDeployConditions(localConfig);
133458
133662
  return tables.map((table) => {
133459
133663
  return {
@@ -133486,7 +133690,7 @@ var questionsPushBuckets = [
133486
133690
  validate: (value) => validateRequired("bucket", value),
133487
133691
  when: () => localConfig.getBuckets().length > 0,
133488
133692
  choices: () => {
133489
- let buckets = localConfig.getBuckets();
133693
+ const buckets = localConfig.getBuckets();
133490
133694
  checkDeployConditions(localConfig);
133491
133695
  return buckets.map((bucket) => {
133492
133696
  return {
@@ -133505,7 +133709,7 @@ var questionsPushMessagingTopics = [
133505
133709
  validate: (value) => validateRequired("topics", value),
133506
133710
  when: () => localConfig.getMessagingTopics().length > 0,
133507
133711
  choices: () => {
133508
- let topics = localConfig.getMessagingTopics();
133712
+ const topics = localConfig.getMessagingTopics();
133509
133713
  return topics.map((topic) => {
133510
133714
  return {
133511
133715
  name: `${topic.name} (${topic["$id"]})`,
@@ -133536,7 +133740,7 @@ var questionsPushTeams = [
133536
133740
  validate: (value) => validateRequired("team", value),
133537
133741
  when: () => localConfig.getTeams().length > 0,
133538
133742
  choices: () => {
133539
- let teams2 = localConfig.getTeams();
133743
+ const teams2 = localConfig.getTeams();
133540
133744
  checkDeployConditions(localConfig);
133541
133745
  return teams2.map((team) => {
133542
133746
  return {
@@ -133553,7 +133757,7 @@ var questionsListFactors = [
133553
133757
  name: "factor",
133554
133758
  message: "Your account is protected by multi-factor authentication. Please choose one for verification.",
133555
133759
  choices: async () => {
133556
- let client2 = await sdkForConsole(false);
133760
+ const client2 = await sdkForConsole(false);
133557
133761
  const accountClient2 = new Account(client2);
133558
133762
  const factors = await accountClient2.listMfaFactors();
133559
133763
  const choices = [
@@ -133598,13 +133802,13 @@ var questionsRunFunctions = [
133598
133802
  message: "Which function would you like to develop locally?",
133599
133803
  validate: (value) => validateRequired("function", value),
133600
133804
  choices: () => {
133601
- let functions2 = localConfig.getFunctions();
133805
+ const functions2 = localConfig.getFunctions();
133602
133806
  if (functions2.length === 0) {
133603
133807
  throw new Error(
133604
133808
  `No functions found. Use '${EXECUTABLE_NAME} pull functions' to synchronize existing one, or use '${EXECUTABLE_NAME} init function' to create a new one.`
133605
133809
  );
133606
133810
  }
133607
- let choices = functions2.map((func, idx) => {
133811
+ const choices = functions2.map((func, _idx) => {
133608
133812
  return {
133609
133813
  name: `${func.name} (${func.$id})`,
133610
133814
  value: func.$id
@@ -133632,9 +133836,9 @@ var questionsCreateSite = [
133632
133836
  name: "framework",
133633
133837
  message: "What framework would you like to use?",
133634
133838
  choices: async () => {
133635
- let response = await (await getSitesService()).listFrameworks();
133636
- let frameworks = response["frameworks"];
133637
- let choices = frameworks.map((framework) => {
133839
+ const response = await (await getSitesService()).listFrameworks();
133840
+ const frameworks = response["frameworks"];
133841
+ const choices = frameworks.map((framework) => {
133638
133842
  return {
133639
133843
  name: `${framework.name} (${framework.key})`,
133640
133844
  value: framework
@@ -133648,9 +133852,9 @@ var questionsCreateSite = [
133648
133852
  name: "specification",
133649
133853
  message: "What specification would you like to use?",
133650
133854
  choices: async () => {
133651
- let response = await (await getSitesService()).listSpecifications();
133652
- let specifications = response["specifications"];
133653
- let choices = specifications.map((spec) => {
133855
+ const response = await (await getSitesService()).listSpecifications();
133856
+ const specifications = response["specifications"];
133857
+ const choices = specifications.map((spec) => {
133654
133858
  return {
133655
133859
  name: `${spec.cpus} CPU, ${spec.memory}MB RAM`,
133656
133860
  value: spec.slug,
@@ -133834,7 +134038,7 @@ var Client3 = class _Client {
133834
134038
  let json3 = void 0;
133835
134039
  try {
133836
134040
  json3 = JSON.parse(text2);
133837
- } catch (error49) {
134041
+ } catch (_error) {
133838
134042
  throw new AppwriteException(text2, response.status, "", text2);
133839
134043
  }
133840
134044
  if (path16 !== "/account" && json3.code === 401 && json3.type === "user_more_factors_required") {
@@ -133868,7 +134072,7 @@ var Client3 = class _Client {
133868
134072
  let json2 = void 0;
133869
134073
  try {
133870
134074
  json2 = JSONBig.parse(text);
133871
- } catch (error49) {
134075
+ } catch (_error) {
133872
134076
  return text;
133873
134077
  }
133874
134078
  return json2;
@@ -133939,11 +134143,11 @@ var completeMfaLogin = async ({
133939
134143
  };
133940
134144
  var deleteServerSession = async (sessionId) => {
133941
134145
  try {
133942
- let client2 = await sdkForConsole();
133943
- let accountClient2 = new Account(client2);
134146
+ const client2 = await sdkForConsole();
134147
+ const accountClient2 = new Account(client2);
133944
134148
  await accountClient2.deleteSession(sessionId);
133945
134149
  return true;
133946
- } catch (e) {
134150
+ } catch (_e) {
133947
134151
  return false;
133948
134152
  }
133949
134153
  };
@@ -134028,7 +134232,7 @@ var loginCommand = async ({
134028
134232
  globalConfig2.setEndpoint(configEndpoint);
134029
134233
  globalConfig2.setEmail(answers.email);
134030
134234
  const legacyClient = createLegacyConsoleClient(configEndpoint);
134031
- let client2 = await sdkForConsole(false);
134235
+ const client2 = await sdkForConsole(false);
134032
134236
  let accountClient2 = new Account(client2);
134033
134237
  let account2;
134034
134238
  try {
@@ -134078,8 +134282,8 @@ var whoami = new Command("whoami").description(commandDescriptions["whoami"]).ac
134078
134282
  error48("No user is signed in. To sign in, run 'appwrite login'");
134079
134283
  return;
134080
134284
  }
134081
- let client2 = await sdkForConsole(false);
134082
- let accountClient2 = new Account(client2);
134285
+ const client2 = await sdkForConsole(false);
134286
+ const accountClient2 = new Account(client2);
134083
134287
  let account2;
134084
134288
  try {
134085
134289
  account2 = await accountClient2.get();
@@ -134203,7 +134407,7 @@ var client = new Command("client").description(commandDescriptions["client"]).co
134203
134407
  const tail = cookieValue.length > 8 ? cookieValue.slice(-8) : cookieValue || "********";
134204
134408
  maskedCookie = `${cookieName}=...${tail}`;
134205
134409
  }
134206
- let config2 = {
134410
+ const config2 = {
134207
134411
  endpoint: globalConfig2.getEndpoint(),
134208
134412
  key: maskedKey,
134209
134413
  cookie: maskedCookie,
@@ -134216,16 +134420,16 @@ var client = new Command("client").description(commandDescriptions["client"]).co
134216
134420
  if (endpoint !== void 0) {
134217
134421
  try {
134218
134422
  const id = id_default2.unique();
134219
- let url2 = new URL(endpoint);
134423
+ const url2 = new URL(endpoint);
134220
134424
  if (url2.protocol !== "http:" && url2.protocol !== "https:") {
134221
134425
  throw new Error();
134222
134426
  }
134223
- let clientInstance = new Client().setEndpoint(endpoint);
134427
+ const clientInstance = new Client().setEndpoint(endpoint);
134224
134428
  clientInstance.setProject("console");
134225
134429
  if (selfSigned || globalConfig2.getSelfSigned()) {
134226
134430
  clientInstance.setSelfSigned(true);
134227
134431
  }
134228
- let response = await clientInstance.call(
134432
+ const response = await clientInstance.call(
134229
134433
  "GET",
134230
134434
  new URL(endpoint + "/health/version")
134231
134435
  );
@@ -134376,6 +134580,9 @@ async function downloadDeploymentCode(params) {
134376
134580
  {},
134377
134581
  "arrayBuffer"
134378
134582
  );
134583
+ if (!(downloadBuffer instanceof ArrayBuffer)) {
134584
+ throw new Error("Failed to download deployment archive as ArrayBuffer.");
134585
+ }
134379
134586
  try {
134380
134587
  import_fs3.default.writeFileSync(compressedFileName, Buffer.from(downloadBuffer));
134381
134588
  } catch (err) {
@@ -134454,7 +134661,7 @@ var getConfirmation = async () => {
134454
134661
  }
134455
134662
  return answers2.changes;
134456
134663
  }
134457
- let answers = await import_inquirer2.default.prompt(questionPushChanges);
134664
+ const answers = await import_inquirer2.default.prompt(questionPushChanges);
134458
134665
  if (answers.changes !== "YES" && answers.changes !== "NO") {
134459
134666
  answers.changes = await fixConfirmation();
134460
134667
  }
@@ -134504,7 +134711,7 @@ var approveChanges = async (resource, resourceGetFunction, keys, resourceName, r
134504
134711
  options[secondResourceName] = localResource[secondId];
134505
134712
  }
134506
134713
  const remoteResource = await resourceGetFunction(options);
134507
- for (let [key, value] of Object.entries(
134714
+ for (const [key, value] of Object.entries(
134508
134715
  whitelistKeys(remoteResource, keys)
134509
134716
  )) {
134510
134717
  if (skipKeys.includes(key)) {
@@ -134513,28 +134720,30 @@ var approveChanges = async (resource, resourceGetFunction, keys, resourceName, r
134513
134720
  if (isEmpty(value) && isEmpty(localResource[key])) {
134514
134721
  continue;
134515
134722
  }
134516
- if (Array.isArray(value) && Array.isArray(localResource[key])) {
134517
- if (JSON.stringify(value) !== JSON.stringify(localResource[key])) {
134723
+ const localValue = localResource[key];
134724
+ if (Array.isArray(value) && Array.isArray(localValue)) {
134725
+ if (JSON.stringify(value) !== JSON.stringify(localValue)) {
134518
134726
  changes.push({
134519
134727
  id: localResource["$id"],
134520
134728
  key,
134521
134729
  remote: import_chalk4.default.red(value.join("\n")),
134522
- local: import_chalk4.default.green(localResource[key].join("\n"))
134730
+ local: import_chalk4.default.green(
134731
+ localValue.map((entry) => String(entry)).join("\n")
134732
+ )
134523
134733
  });
134524
134734
  }
134525
- } else if (value !== localResource[key]) {
134735
+ } else if (value !== localValue) {
134526
134736
  changes.push({
134527
134737
  id: localResource["$id"],
134528
134738
  key,
134529
- remote: import_chalk4.default.red(value),
134530
- local: import_chalk4.default.green(localResource[key])
134739
+ remote: import_chalk4.default.red(String(value ?? "")),
134740
+ local: import_chalk4.default.green(String(localValue ?? ""))
134531
134741
  });
134532
134742
  }
134533
134743
  }
134534
134744
  } catch (e) {
134535
- if (Number(e.code) !== 404) {
134536
- throw e;
134537
- }
134745
+ const isNotFound = e instanceof AppwriteException && Number(e.code) === 404;
134746
+ if (!isNotFound) throw e;
134538
134747
  }
134539
134748
  })
134540
134749
  );
@@ -135057,7 +135266,7 @@ var pullResources = async ({
135057
135266
  delete actions.collections;
135058
135267
  }
135059
135268
  if (cliConfig.all) {
135060
- for (let action of Object.values(actions)) {
135269
+ for (const action of Object.values(actions)) {
135061
135270
  cliConfig.all = true;
135062
135271
  await action({ returnOnZero: true });
135063
135272
  }
@@ -135296,7 +135505,6 @@ var initProject = async ({
135296
135505
  projectId,
135297
135506
  projectName
135298
135507
  } = {}) => {
135299
- let response = {};
135300
135508
  try {
135301
135509
  if (globalConfig2.getEndpoint() === "" || globalConfig2.getCookie() === "") {
135302
135510
  throw new Error(
@@ -135306,33 +135514,39 @@ var initProject = async ({
135306
135514
  const client2 = await sdkForConsole();
135307
135515
  const accountClient2 = new Account(client2);
135308
135516
  await accountClient2.get();
135309
- } catch (e) {
135517
+ } catch (_e) {
135310
135518
  error48(
135311
135519
  `Error Session not found. Please run '${EXECUTABLE_NAME} login' to create a session`
135312
135520
  );
135313
135521
  process.exit(1);
135314
135522
  }
135315
- let answers = {};
135523
+ let answers;
135316
135524
  if (!organizationId && !projectId && !projectName) {
135317
135525
  answers = await import_inquirer4.default.prompt(questionsInitProject);
135318
135526
  if (answers.override === false) {
135319
135527
  process.exit(1);
135320
135528
  }
135321
135529
  } else {
135322
- answers.start = "existing";
135323
- answers.project = {};
135324
- answers.organization = {};
135325
- answers.organization = organizationId ?? (await import_inquirer4.default.prompt([questionsInitProject[2]])).organization;
135326
- answers.project.name = projectName ?? (await import_inquirer4.default.prompt([questionsInitProject[3]])).project;
135327
- answers.project = projectId ?? (await import_inquirer4.default.prompt([questionsInitProject[4]])).id;
135530
+ const selectedOrganization = organizationId ?? (await import_inquirer4.default.prompt([questionsInitProject[2]])).organization;
135531
+ const selectedProjectName = projectName ?? (await import_inquirer4.default.prompt([questionsInitProject[3]])).project;
135532
+ const selectedProjectId = projectId ?? (await import_inquirer4.default.prompt([questionsInitProject[4]])).id;
135533
+ answers = {
135534
+ start: "existing",
135535
+ project: selectedProjectId,
135536
+ organization: selectedOrganization
135537
+ };
135328
135538
  try {
135329
135539
  const projectsService = await getProjectsService();
135330
- await projectsService.get(projectId);
135540
+ const existingProject = await projectsService.get(selectedProjectId);
135541
+ answers.project = existingProject;
135331
135542
  } catch (e) {
135332
- if (e.code === 404) {
135333
- answers.start = "new";
135334
- answers.id = answers.project;
135335
- answers.project = answers.project.name;
135543
+ if (e instanceof AppwriteException && e.code === 404) {
135544
+ answers = {
135545
+ start: "new",
135546
+ id: selectedProjectId,
135547
+ project: selectedProjectName,
135548
+ organization: selectedOrganization
135549
+ };
135336
135550
  } else {
135337
135551
  throw e;
135338
135552
  }
@@ -135341,10 +135555,26 @@ var initProject = async ({
135341
135555
  localConfig.clear();
135342
135556
  const url2 = new URL(DEFAULT_ENDPOINT);
135343
135557
  if (answers.start === "new") {
135558
+ let projectIdToCreate;
135559
+ let projectNameToCreate;
135560
+ switch (typeof answers.project) {
135561
+ case "string":
135562
+ projectIdToCreate = answers.id ?? answers.project;
135563
+ projectNameToCreate = answers.project;
135564
+ break;
135565
+ case "object":
135566
+ projectIdToCreate = answers.id ?? answers.project.$id;
135567
+ projectNameToCreate = answers.project.name ?? answers.project.$id;
135568
+ break;
135569
+ default:
135570
+ projectIdToCreate = answers.id;
135571
+ projectNameToCreate = "";
135572
+ break;
135573
+ }
135344
135574
  const projectsService = await getProjectsService();
135345
- response = await projectsService.create(
135346
- answers.id,
135347
- answers.project,
135575
+ const response = await projectsService.create(
135576
+ projectIdToCreate,
135577
+ projectNameToCreate,
135348
135578
  answers.organization,
135349
135579
  answers.region
135350
135580
  );
@@ -135355,10 +135585,22 @@ var initProject = async ({
135355
135585
  );
135356
135586
  }
135357
135587
  } else {
135358
- localConfig.setProject(answers.project["$id"]);
135359
- if (isCloud()) {
135588
+ let selectedProject;
135589
+ switch (typeof answers.project) {
135590
+ case "string":
135591
+ selectedProject = { $id: answers.project };
135592
+ break;
135593
+ case "object":
135594
+ selectedProject = answers.project;
135595
+ break;
135596
+ default:
135597
+ selectedProject = { $id: "" };
135598
+ break;
135599
+ }
135600
+ localConfig.setProject(selectedProject.$id);
135601
+ if (isCloud() && selectedProject.region) {
135360
135602
  localConfig.setEndpoint(
135361
- `https://${answers.project["region"]}.${url2.host}${url2.pathname}`
135603
+ `https://${selectedProject.region}.${url2.host}${url2.pathname}`
135362
135604
  );
135363
135605
  }
135364
135606
  }
@@ -135366,8 +135608,10 @@ var initProject = async ({
135366
135608
  `Project successfully ${answers.start === "existing" ? "linked" : "created"}. Details are now stored in appwrite.config.json file.`
135367
135609
  );
135368
135610
  if (answers.start === "existing") {
135369
- answers = await import_inquirer4.default.prompt(questionsInitProjectAutopull);
135370
- if (answers.autopull) {
135611
+ const autopullAnswers = await import_inquirer4.default.prompt(
135612
+ questionsInitProjectAutopull
135613
+ );
135614
+ if (autopullAnswers.autopull) {
135371
135615
  cliConfig.all = true;
135372
135616
  cliConfig.force = true;
135373
135617
  await pullResources({
@@ -135507,7 +135751,6 @@ var initFunction = async () => {
135507
135751
  import_fs5.default.mkdirSync(functionDir, { mode: 511 });
135508
135752
  import_fs5.default.mkdirSync(templatesDir, { mode: 511 });
135509
135753
  const repo = "https://github.com/appwrite/templates";
135510
- const api = `https://api.github.com/repos/appwrite/templates/contents/${answers.runtime.name}`;
135511
135754
  let selected = { template: "starter" };
135512
135755
  const sparse = (selected ? `${answers.runtime.name}/${selected.template}` : answers.runtime.name).toLowerCase();
135513
135756
  let gitInitCommands = `git clone --single-branch --depth 1 --sparse ${repo} .`;
@@ -135526,17 +135769,18 @@ var initFunction = async () => {
135526
135769
  cwd: templatesDir
135527
135770
  });
135528
135771
  } catch (err) {
135529
- if (err.message.includes("error: unknown option")) {
135772
+ const errorMessage = err instanceof Error ? err.message : String(err);
135773
+ if (errorMessage.includes("error: unknown option")) {
135530
135774
  throw new Error(
135531
- `${err.message}
135775
+ `${errorMessage}
135532
135776
 
135533
135777
  Suggestion: Try updating your git to the latest version, then trying to run this command again.`
135534
135778
  );
135535
- } else if (err.message.includes(
135779
+ } else if (errorMessage.includes(
135536
135780
  "is not recognized as an internal or external command,"
135537
- ) || err.message.includes("command not found")) {
135781
+ ) || errorMessage.includes("command not found")) {
135538
135782
  throw new Error(
135539
- `${err.message}
135783
+ `${errorMessage}
135540
135784
 
135541
135785
  Suggestion: It appears that git is not installed, try installing git then trying to run this command again.`
135542
135786
  );
@@ -135558,9 +135802,9 @@ Suggestion: It appears that git is not installed, try installing git then trying
135558
135802
  }
135559
135803
  }
135560
135804
  const copyRecursiveSync = (src, dest) => {
135561
- let exists = import_fs5.default.existsSync(src);
135562
- let stats = exists && import_fs5.default.statSync(src);
135563
- let isDirectory = exists && stats && stats.isDirectory();
135805
+ const exists = import_fs5.default.existsSync(src);
135806
+ const stats = exists && import_fs5.default.statSync(src);
135807
+ const isDirectory = exists && stats && stats.isDirectory();
135564
135808
  if (isDirectory) {
135565
135809
  if (!import_fs5.default.existsSync(dest)) {
135566
135810
  import_fs5.default.mkdirSync(dest);
@@ -135588,7 +135832,7 @@ Suggestion: It appears that git is not installed, try installing git then trying
135588
135832
  newReadmeFile[0] = `# ${answers.name}`;
135589
135833
  newReadmeFile.splice(1, 2);
135590
135834
  import_fs5.default.writeFileSync(readmePath, newReadmeFile.join("\n"));
135591
- let data = {
135835
+ const data = {
135592
135836
  $id: functionId,
135593
135837
  name: answers.name,
135594
135838
  runtime: answers.runtime.id,
@@ -135644,14 +135888,15 @@ var initSite = async () => {
135644
135888
  }
135645
135889
  templateDetails = response.templates[0];
135646
135890
  } catch (err) {
135891
+ const errorMessage = err instanceof Error ? err.message : String(err);
135647
135892
  throw new Error(
135648
- `Failed to fetch template for framework ${answers.framework.key}: ${err.message}`
135893
+ `Failed to fetch template for framework ${answers.framework.key}: ${errorMessage}`
135649
135894
  );
135650
135895
  }
135651
135896
  import_fs5.default.mkdirSync(siteDir, { mode: 511 });
135652
135897
  import_fs5.default.mkdirSync(templatesDir, { mode: 511 });
135653
135898
  const repo = `https://github.com/${templateDetails.providerOwner}/${templateDetails.providerRepositoryId}`;
135654
- let selected = {
135899
+ const selected = {
135655
135900
  template: templateDetails.frameworks[0].providerRootDirectory
135656
135901
  };
135657
135902
  let dirSetupCommands = "";
@@ -135676,12 +135921,12 @@ var initSite = async () => {
135676
135921
  git config remote.origin.tagopt --no-tags
135677
135922
  `.trim();
135678
135923
  }
135679
- let windowsGitCloneCommands = `
135924
+ const windowsGitCloneCommands = `
135680
135925
  $tag = (git ls-remote --tags origin "${templateDetails.providerVersion}" | Select-Object -Last 1) -replace '.*refs/tags/', ''
135681
135926
  git fetch --depth=1 origin "refs/tags/$tag"
135682
135927
  git checkout FETCH_HEAD
135683
135928
  `.trim();
135684
- let unixGitCloneCommands = `
135929
+ const unixGitCloneCommands = `
135685
135930
  git fetch --depth=1 origin refs/tags/$(git ls-remote --tags origin "${templateDetails.providerVersion}" | tail -n 1 | awk -F '/' '{print $3}')
135686
135931
  git checkout FETCH_HEAD
135687
135932
  `.trim();
@@ -135699,17 +135944,18 @@ var initSite = async () => {
135699
135944
  shell: usedShell
135700
135945
  });
135701
135946
  } catch (err) {
135702
- if (err.message.includes("error: unknown option")) {
135947
+ const errorMessage = err instanceof Error ? err.message : String(err);
135948
+ if (errorMessage.includes("error: unknown option")) {
135703
135949
  throw new Error(
135704
- `${err.message}
135950
+ `${errorMessage}
135705
135951
 
135706
135952
  Suggestion: Try updating your git to the latest version, then trying to run this command again.`
135707
135953
  );
135708
- } else if (err.message.includes(
135954
+ } else if (errorMessage.includes(
135709
135955
  "is not recognized as an internal or external command,"
135710
- ) || err.message.includes("command not found")) {
135956
+ ) || errorMessage.includes("command not found")) {
135711
135957
  throw new Error(
135712
- `${err.message}
135958
+ `${errorMessage}
135713
135959
 
135714
135960
  Suggestion: It appears that git is not installed, try installing git then trying to run this command again.`
135715
135961
  );
@@ -135730,24 +135976,22 @@ Suggestion: It appears that git is not installed, try installing git then trying
135730
135976
  newReadmeFile[0] = `# ${answers.name}`;
135731
135977
  newReadmeFile.splice(1, 2);
135732
135978
  import_fs5.default.writeFileSync(readmePath, newReadmeFile.join("\n"));
135733
- let vars = (templateDetails.variables ?? []).map((variable) => {
135734
- let value = variable.value;
135979
+ const vars = {};
135980
+ for (const variable of templateDetails.variables ?? []) {
135981
+ let value = variable.value ?? "";
135735
135982
  const replacements = {
135736
135983
  "{apiEndpoint}": globalConfig2.getEndpoint(),
135737
- "{projectId}": localConfig.getProject().projectId,
135738
- "{projectName}": localConfig.getProject().projectName
135984
+ "{projectId}": localConfig.getProject().projectId ?? "",
135985
+ "{projectName}": localConfig.getProject().projectName ?? ""
135739
135986
  };
135740
135987
  for (const placeholder in replacements) {
135741
- if (value?.includes(placeholder)) {
135988
+ if (value.includes(placeholder)) {
135742
135989
  value = value.replace(placeholder, replacements[placeholder]);
135743
135990
  }
135744
135991
  }
135745
- return {
135746
- key: variable.name,
135747
- value
135748
- };
135749
- });
135750
- let data = {
135992
+ vars[variable.name] = value;
135993
+ }
135994
+ const data = {
135751
135995
  $id: siteId,
135752
135996
  name: answers.name,
135753
135997
  framework: answers.framework.key,
@@ -137214,12 +137458,10 @@ var typesCommand = actionRunner(
137214
137458
  log(`Directory: ${outputDirectory} does not exist, creating...`);
137215
137459
  import_fs9.default.mkdirSync(outputDirectory, { recursive: true });
137216
137460
  }
137217
- let tables = localConfig.getTables();
137461
+ const tables = localConfig.getTables();
137218
137462
  let collections = [];
137219
- let dataSource = "tables";
137220
137463
  if (tables.length === 0) {
137221
137464
  collections = localConfig.getCollections();
137222
- dataSource = "collections";
137223
137465
  if (collections.length === 0) {
137224
137466
  const configFileName = import_path9.default.basename(localConfig.path);
137225
137467
  throw new Error(
@@ -137674,9 +137916,8 @@ async function dockerStart(func, variables, port) {
137674
137916
  try {
137675
137917
  await waitUntilPortOpen(port);
137676
137918
  } catch (err) {
137677
- error48(
137678
- "Failed to start function with error: " + (err.message ? err.message : err.toString())
137679
- );
137919
+ const message = err instanceof Error ? err.message : String(err);
137920
+ error48(`Failed to start function with error: ${message}`);
137680
137921
  return;
137681
137922
  }
137682
137923
  success2(`Visit http://localhost:${port}/ to execute your function.`);
@@ -137843,7 +138084,7 @@ var runFunction = async ({
137843
138084
  });
137844
138085
  } catch (err) {
137845
138086
  warn(
137846
- "Remote variables not fetched. Production environment variables will not be available. Reason: " + err.message
138087
+ "Remote variables not fetched. Production environment variables will not be available. Reason: " + getErrorMessage(err)
137847
138088
  );
137848
138089
  }
137849
138090
  }
@@ -137867,7 +138108,7 @@ var runFunction = async ({
137867
138108
  await JwtManager.setup(userId, func.scopes ?? []);
137868
138109
  } catch (err) {
137869
138110
  warn(
137870
- "Dynamic API key not generated. Header x-appwrite-key will not be set. Reason: " + err.message
138111
+ "Dynamic API key not generated. Header x-appwrite-key will not be set. Reason: " + getErrorMessage(err)
137871
138112
  );
137872
138113
  }
137873
138114
  const headers = {};
@@ -138367,7 +138608,7 @@ var Spinner = class _Spinner {
138367
138608
  static stop() {
138368
138609
  _Spinner.updatesBar.stop();
138369
138610
  }
138370
- static formatter(options, params, payload) {
138611
+ static formatter(_options, _params, payload) {
138371
138612
  const status = payload.status.padEnd(12);
138372
138613
  const middle = `${payload.resource} (${payload.id})`.padEnd(40);
138373
138614
  let prefix = import_chalk8.default.cyan(payload.prefix ?? "\u29D7");
@@ -138452,7 +138693,7 @@ var Pools = class {
138452
138693
  return true;
138453
138694
  }
138454
138695
  if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
138455
- let steps = Math.max(1, Math.ceil(Number(total) / this.STEP_SIZE));
138696
+ const steps = Math.max(1, Math.ceil(Number(total) / this.STEP_SIZE));
138456
138697
  if (steps > 1 && iteration === 1) {
138457
138698
  this.pollMaxDebounces *= steps;
138458
138699
  log(
@@ -138478,7 +138719,7 @@ var Pools = class {
138478
138719
  return true;
138479
138720
  }
138480
138721
  if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
138481
- let steps = Math.max(1, Math.ceil(Number(total) / this.STEP_SIZE));
138722
+ const steps = Math.max(1, Math.ceil(Number(total) / this.STEP_SIZE));
138482
138723
  if (steps > 1 && iteration === 1) {
138483
138724
  this.pollMaxDebounces *= steps;
138484
138725
  log(
@@ -138494,7 +138735,10 @@ var Pools = class {
138494
138735
  return false;
138495
138736
  }
138496
138737
  if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
138497
- let steps = Math.max(1, Math.ceil(attributeKeys.length / this.STEP_SIZE));
138738
+ const steps = Math.max(
138739
+ 1,
138740
+ Math.ceil(attributeKeys.length / this.STEP_SIZE)
138741
+ );
138498
138742
  if (steps > 1 && iteration === 1) {
138499
138743
  this.pollMaxDebounces *= steps;
138500
138744
  log(
@@ -138537,7 +138781,10 @@ var Pools = class {
138537
138781
  return false;
138538
138782
  }
138539
138783
  if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
138540
- let steps = Math.max(1, Math.ceil(attributeKeys.length / this.STEP_SIZE));
138784
+ const steps = Math.max(
138785
+ 1,
138786
+ Math.ceil(attributeKeys.length / this.STEP_SIZE)
138787
+ );
138541
138788
  if (steps > 1 && iteration === 1) {
138542
138789
  this.pollMaxDebounces *= steps;
138543
138790
  log(
@@ -138586,7 +138833,7 @@ var Pools = class {
138586
138833
  return false;
138587
138834
  }
138588
138835
  if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
138589
- let steps = Math.max(1, Math.ceil(indexKeys.length / this.STEP_SIZE));
138836
+ const steps = Math.max(1, Math.ceil(indexKeys.length / this.STEP_SIZE));
138590
138837
  if (steps > 1 && iteration === 1) {
138591
138838
  this.pollMaxDebounces *= steps;
138592
138839
  log(
@@ -138679,7 +138926,7 @@ var Attributes = class {
138679
138926
  }
138680
138927
  return answers2.changes;
138681
138928
  }
138682
- let answers = await import_inquirer6.default.prompt(questionPushChanges2);
138929
+ const answers = await import_inquirer6.default.prompt(questionPushChanges2);
138683
138930
  if (answers.changes !== "YES" && answers.changes !== "NO") {
138684
138931
  answers.changes = await fixConfirmation();
138685
138932
  }
@@ -138722,8 +138969,8 @@ var Attributes = class {
138722
138969
  const keyName = `${import_chalk9.default.yellow(local.key)} in ${collection.name} (${collection["$id"]})`;
138723
138970
  const action = import_chalk9.default.cyan(recreating ? "recreating" : "changing");
138724
138971
  let reason = "";
138725
- let attribute = recreating ? remote : local;
138726
- for (let key of Object.keys(remote)) {
138972
+ const attribute = recreating ? remote : local;
138973
+ for (const key of Object.keys(remote)) {
138727
138974
  if (!KeysAttributes.has(key)) {
138728
138975
  continue;
138729
138976
  }
@@ -139233,7 +139480,7 @@ var Attributes = class {
139233
139480
  createIndexes = async (indexes, collection) => {
139234
139481
  log(`Creating indexes ...`);
139235
139482
  const databasesService = await getDatabasesService(this.client);
139236
- for (let index of indexes) {
139483
+ for (const index of indexes) {
139237
139484
  await databasesService.createIndex({
139238
139485
  databaseId: collection["databaseId"],
139239
139486
  collectionId: collection["$id"],
@@ -139257,7 +139504,7 @@ var Attributes = class {
139257
139504
  };
139258
139505
  createAttributes = async (attributes, collection) => {
139259
139506
  log(`Creating attributes ...`);
139260
- for (let attribute of attributes) {
139507
+ for (const attribute of attributes) {
139261
139508
  if (attribute.side !== "child") {
139262
139509
  await this.createAttribute(
139263
139510
  collection["databaseId"],
@@ -139281,7 +139528,7 @@ var Attributes = class {
139281
139528
  };
139282
139529
  createColumns = async (columns, table) => {
139283
139530
  log(`Creating columns ...`);
139284
- for (let column of columns) {
139531
+ for (const column of columns) {
139285
139532
  if (column.side !== "child") {
139286
139533
  await this.createAttribute(table["databaseId"], table["$id"], column);
139287
139534
  }
@@ -139303,18 +139550,37 @@ var Attributes = class {
139303
139550
 
139304
139551
  // lib/commands/utils/database-sync.ts
139305
139552
  var import_chalk10 = __toESM(require_source(), 1);
139553
+ var isTablesDBResource = (value) => {
139554
+ if (!value || typeof value !== "object") {
139555
+ return false;
139556
+ }
139557
+ return "$id" in value && typeof value.$id === "string" && "name" in value && typeof value.name === "string" && "enabled" in value && typeof value.enabled === "boolean";
139558
+ };
139559
+ var getSyncErrorMessage = (err) => {
139560
+ if (err instanceof AppwriteException) {
139561
+ return err.message;
139562
+ }
139563
+ if (err instanceof Error) {
139564
+ return err.message;
139565
+ }
139566
+ return String(err);
139567
+ };
139306
139568
  var checkAndApplyTablesDBChanges = async () => {
139307
139569
  log("Checking for tablesDB changes ...");
139308
139570
  const localTablesDBs = localConfig.getTablesDBs();
139309
- const { databases: remoteTablesDBs } = await paginate(
139571
+ const paginatedResult = await paginate(
139310
139572
  async (args) => {
139311
139573
  const tablesDBService = await getTablesDBService();
139312
- return await tablesDBService.list(args.queries || []);
139574
+ const queries = Array.isArray(args.queries) ? args.queries.filter(
139575
+ (query) => typeof query === "string"
139576
+ ) : [];
139577
+ return await tablesDBService.list(queries);
139313
139578
  },
139314
139579
  {},
139315
139580
  100,
139316
139581
  "databases"
139317
139582
  );
139583
+ const remoteTablesDBs = Array.isArray(paginatedResult.databases) ? paginatedResult.databases.filter(isTablesDBResource) : [];
139318
139584
  if (localTablesDBs.length === 0 && remoteTablesDBs.length === 0) {
139319
139585
  return { applied: false, resyncNeeded: false };
139320
139586
  }
@@ -139336,9 +139602,7 @@ var checkAndApplyTablesDBChanges = async () => {
139336
139602
  }
139337
139603
  }
139338
139604
  for (const localDB of localTablesDBs) {
139339
- const remoteDB = remoteTablesDBs.find(
139340
- (db) => db.$id === localDB.$id
139341
- );
139605
+ const remoteDB = remoteTablesDBs.find((db) => db.$id === localDB.$id);
139342
139606
  if (!remoteDB) {
139343
139607
  toCreate.push(localDB);
139344
139608
  changes.push({
@@ -139405,7 +139669,7 @@ var checkAndApplyTablesDBChanges = async () => {
139405
139669
  needsResync = true;
139406
139670
  } catch (e) {
139407
139671
  error48(
139408
- `Failed to delete database ${db.name} ( ${db.$id} ): ${e.message}`
139672
+ `Failed to delete database ${db.name} ( ${db.$id} ): ${getSyncErrorMessage(e)}`
139409
139673
  );
139410
139674
  throw new Error(
139411
139675
  `Database sync failed during deletion of ${db.$id}. Some changes may have been applied.`
@@ -139420,7 +139684,7 @@ var checkAndApplyTablesDBChanges = async () => {
139420
139684
  success2(`Created ${db.name} ( ${db.$id} )`);
139421
139685
  } catch (e) {
139422
139686
  error48(
139423
- `Failed to create database ${db.name} ( ${db.$id} ): ${e.message}`
139687
+ `Failed to create database ${db.name} ( ${db.$id} ): ${getSyncErrorMessage(e)}`
139424
139688
  );
139425
139689
  throw new Error(
139426
139690
  `Database sync failed during creation of ${db.$id}. Some changes may have been applied.`
@@ -139435,7 +139699,7 @@ var checkAndApplyTablesDBChanges = async () => {
139435
139699
  success2(`Updated ${db.name} ( ${db.$id} )`);
139436
139700
  } catch (e) {
139437
139701
  error48(
139438
- `Failed to update database ${db.name} ( ${db.$id} ): ${e.message}`
139702
+ `Failed to update database ${db.name} ( ${db.$id} ): ${getSyncErrorMessage(e)}`
139439
139703
  );
139440
139704
  throw new Error(
139441
139705
  `Database sync failed during update of ${db.$id}. Some changes may have been applied.`
@@ -139669,7 +139933,7 @@ var Push = class {
139669
139933
  }
139670
139934
  if (settings.services) {
139671
139935
  this.log("Applying service statuses ...");
139672
- for (let [service, status] of Object.entries(settings.services)) {
139936
+ for (const [service, status] of Object.entries(settings.services)) {
139673
139937
  await projectsService.updateServiceStatus({
139674
139938
  projectId,
139675
139939
  service,
@@ -139715,7 +139979,7 @@ var Push = class {
139715
139979
  }
139716
139980
  if (settings.auth.methods) {
139717
139981
  this.log("Applying auth methods statuses ...");
139718
- for (let [method, status] of Object.entries(settings.auth.methods)) {
139982
+ for (const [method, status] of Object.entries(settings.auth.methods)) {
139719
139983
  await projectsService.updateAuthStatus({
139720
139984
  projectId,
139721
139985
  method,
@@ -140019,7 +140283,7 @@ var Push = class {
140019
140283
  ([key, value]) => ({ key, value })
140020
140284
  );
140021
140285
  }
140022
- } catch (error49) {
140286
+ } catch (_error) {
140023
140287
  envVariables = [];
140024
140288
  }
140025
140289
  await Promise.all(
@@ -140316,7 +140580,7 @@ var Push = class {
140316
140580
  ([key, value]) => ({ key, value })
140317
140581
  );
140318
140582
  }
140319
- } catch (error49) {
140583
+ } catch (_error) {
140320
140584
  envVariables = [];
140321
140585
  }
140322
140586
  await Promise.all(
@@ -140483,7 +140747,7 @@ var Push = class {
140483
140747
  skipConfirmation,
140484
140748
  this.projectClient
140485
140749
  );
140486
- let tablesChanged = /* @__PURE__ */ new Set();
140750
+ const tablesChanged = /* @__PURE__ */ new Set();
140487
140751
  const errors = [];
140488
140752
  await Promise.all(
140489
140753
  tables.map(async (table) => {
@@ -140537,7 +140801,7 @@ var Push = class {
140537
140801
  }
140538
140802
  })
140539
140803
  );
140540
- for (let table of tables) {
140804
+ for (const table of tables) {
140541
140805
  let columns = table.columns;
140542
140806
  let indexes = table.indexes;
140543
140807
  let hadChanges = false;
@@ -140816,7 +141080,7 @@ var pushSettings = async () => {
140816
141080
  checkDeployConditions(localConfig);
140817
141081
  try {
140818
141082
  const projectsService = await getProjectsService();
140819
- let response = await projectsService.get(
141083
+ const response = await projectsService.get(
140820
141084
  localConfig.getProject().projectId
140821
141085
  );
140822
141086
  const remoteSettings = createSettingsObject(response);
@@ -140849,7 +141113,7 @@ var pushSettings = async () => {
140849
141113
  return;
140850
141114
  }
140851
141115
  }
140852
- } catch (e) {
141116
+ } catch (_e) {
140853
141117
  }
140854
141118
  try {
140855
141119
  log("Pushing project settings ...");
@@ -140899,7 +141163,7 @@ var pushSite = async ({
140899
141163
  );
140900
141164
  return;
140901
141165
  }
140902
- let sites2 = siteIds.map((id) => {
141166
+ const sites2 = siteIds.map((id) => {
140903
141167
  const sites3 = localConfig.getSites();
140904
141168
  const site = sites3.find((s) => s.$id === id);
140905
141169
  if (!site) {
@@ -140908,7 +141172,7 @@ var pushSite = async ({
140908
141172
  return site;
140909
141173
  });
140910
141174
  log("Validating sites ...");
140911
- for (let site of sites2) {
141175
+ for (const site of sites2) {
140912
141176
  if (!site.buildCommand) {
140913
141177
  log(`Site ${site.name} is missing build command.`);
140914
141178
  const answers = await import_inquirer7.default.prompt(questionsGetEntrypoint);
@@ -141019,7 +141283,7 @@ var pushFunction = async ({
141019
141283
  );
141020
141284
  return;
141021
141285
  }
141022
- let functions2 = functionIds.map((id) => {
141286
+ const functions2 = functionIds.map((id) => {
141023
141287
  const functions3 = localConfig.getFunctions();
141024
141288
  const func = functions3.find((f) => f.$id === id);
141025
141289
  if (!func) {
@@ -141028,7 +141292,7 @@ var pushFunction = async ({
141028
141292
  return func;
141029
141293
  });
141030
141294
  log("Validating functions ...");
141031
- for (let func of functions2) {
141295
+ for (const func of functions2) {
141032
141296
  if (!func.entrypoint) {
141033
141297
  log(`Function ${func.name} is missing an entrypoint.`);
141034
141298
  const answers = await import_inquirer7.default.prompt(questionsGetEntrypoint);
@@ -141169,7 +141433,7 @@ var pushTable = async ({
141169
141433
  });
141170
141434
  }
141171
141435
  }
141172
- } catch (e) {
141436
+ } catch (_e) {
141173
141437
  }
141174
141438
  }
141175
141439
  if (tablesToDelete.length > 0) {
@@ -141316,7 +141580,7 @@ var pushCollection = async () => {
141316
141580
  }
141317
141581
  };
141318
141582
  var pushBucket = async () => {
141319
- let bucketIds = [];
141583
+ const bucketIds = [];
141320
141584
  const configBuckets = localConfig.getBuckets();
141321
141585
  if (cliConfig.all) {
141322
141586
  checkDeployConditions(localConfig);
@@ -141335,7 +141599,7 @@ var pushBucket = async () => {
141335
141599
  );
141336
141600
  return;
141337
141601
  }
141338
- let buckets = [];
141602
+ const buckets = [];
141339
141603
  for (const bucketId of bucketIds) {
141340
141604
  const idBuckets = configBuckets.filter((b) => b.$id === bucketId);
141341
141605
  buckets.push(...idBuckets);
@@ -141366,7 +141630,7 @@ var pushBucket = async () => {
141366
141630
  }
141367
141631
  };
141368
141632
  var pushTeam = async () => {
141369
- let teamIds = [];
141633
+ const teamIds = [];
141370
141634
  const configTeams = localConfig.getTeams();
141371
141635
  if (cliConfig.all) {
141372
141636
  checkDeployConditions(localConfig);
@@ -141385,7 +141649,7 @@ var pushTeam = async () => {
141385
141649
  );
141386
141650
  return;
141387
141651
  }
141388
- let teams2 = [];
141652
+ const teams2 = [];
141389
141653
  for (const teamId of teamIds) {
141390
141654
  const idTeams = configTeams.filter((t) => t.$id === teamId);
141391
141655
  teams2.push(...idTeams);
@@ -141416,7 +141680,7 @@ var pushTeam = async () => {
141416
141680
  }
141417
141681
  };
141418
141682
  var pushMessagingTopic = async () => {
141419
- let topicsIds = [];
141683
+ const topicsIds = [];
141420
141684
  const configTopics = localConfig.getMessagingTopics();
141421
141685
  if (cliConfig.all) {
141422
141686
  checkDeployConditions(localConfig);
@@ -141435,7 +141699,7 @@ var pushMessagingTopic = async () => {
141435
141699
  );
141436
141700
  return;
141437
141701
  }
141438
- let topics = [];
141702
+ const topics = [];
141439
141703
  for (const topicId of topicsIds) {
141440
141704
  const idTopic = configTopics.filter((b) => b.$id === topicId);
141441
141705
  topics.push(...idTopic);
@@ -141511,7 +141775,7 @@ var isInstalledViaNpm = () => {
141511
141775
  return true;
141512
141776
  }
141513
141777
  return false;
141514
- } catch (e) {
141778
+ } catch (_e) {
141515
141779
  return false;
141516
141780
  }
141517
141781
  };
@@ -141519,7 +141783,7 @@ var isInstalledViaHomebrew = () => {
141519
141783
  try {
141520
141784
  const scriptPath = process.argv[1];
141521
141785
  return scriptPath.includes("/opt/homebrew/") || scriptPath.includes("/usr/local/Cellar/");
141522
- } catch (e) {
141786
+ } catch (_e) {
141523
141787
  return false;
141524
141788
  }
141525
141789
  };
@@ -141549,13 +141813,14 @@ var updateViaNpm = async () => {
141549
141813
  success2("Updated to latest version via npm!");
141550
141814
  hint("Run 'appwrite --version' to verify the new version.");
141551
141815
  } catch (e) {
141552
- if (e.message.includes("EEXIST") || e.message.includes("file already exists")) {
141816
+ const message = getErrorMessage(e);
141817
+ if (message.includes("EEXIST") || message.includes("file already exists")) {
141553
141818
  console.log("");
141554
141819
  success2("Latest version is already installed via npm!");
141555
141820
  hint("The CLI is up to date. Run 'appwrite --version' to verify.");
141556
141821
  } else {
141557
141822
  console.log("");
141558
- error48(`Failed to update via npm: ${e.message}`);
141823
+ error48(`Failed to update via npm: ${message}`);
141559
141824
  hint(`Try running: npm install -g ${NPM_PACKAGE_NAME}@latest --force`);
141560
141825
  }
141561
141826
  }
@@ -141567,13 +141832,14 @@ var updateViaHomebrew = async () => {
141567
141832
  success2("Updated to latest version via Homebrew!");
141568
141833
  hint("Run 'appwrite --version' to verify the new version.");
141569
141834
  } catch (e) {
141570
- if (e.message.includes("already installed") || e.message.includes("up-to-date")) {
141835
+ const message = getErrorMessage(e);
141836
+ if (message.includes("already installed") || message.includes("up-to-date")) {
141571
141837
  console.log("");
141572
141838
  success2("Latest version is already installed via Homebrew!");
141573
141839
  hint("The CLI is up to date. Run 'appwrite --version' to verify.");
141574
141840
  } else {
141575
141841
  console.log("");
141576
- error48(`Failed to update via Homebrew: ${e.message}`);
141842
+ error48(`Failed to update via Homebrew: ${message}`);
141577
141843
  hint("Try running: brew upgrade appwrite");
141578
141844
  }
141579
141845
  }
@@ -141648,8 +141914,9 @@ var updateCli = async ({ manual } = {}) => {
141648
141914
  await chooseUpdateMethod(latestVersion);
141649
141915
  }
141650
141916
  } catch (e) {
141917
+ const message = getErrorMessage(e);
141651
141918
  console.log("");
141652
- error48(`Failed to check for updates: ${e.message}`);
141919
+ error48(`Failed to check for updates: ${message}`);
141653
141920
  hint(`You can manually check for updates at: ${GITHUB_RELEASES_URL}`);
141654
141921
  }
141655
141922
  };
@@ -141822,7 +142089,7 @@ var BaseDatabasesGenerator = class {
141822
142089
  var types_ts_default = "import { type Models } from '{{appwriteDep}}';\n\n{{{ENUMS}}}{{{TYPES}}}\ndeclare const __roleStringBrand: unique symbol;\nexport type RoleString = string & { readonly [__roleStringBrand]: never };\n\nexport type RoleBuilder = {\n any: () => RoleString;\n user: (userId: string, status?: string) => RoleString;\n users: (status?: string) => RoleString;\n guests: () => RoleString;\n team: (teamId: string, role?: string) => RoleString;\n member: (memberId: string) => RoleString;\n label: (label: string) => RoleString;\n}\n\nexport type PermissionBuilder = {\n read: (role: RoleString) => string;\n write: (role: RoleString) => string;\n create: (role: RoleString) => string;\n update: (role: RoleString) => string;\n delete: (role: RoleString) => string;\n}\n\nexport type PermissionCallback = (permission: PermissionBuilder, role: RoleBuilder) => string[];\n\nexport type QueryValue = string | number | boolean;\n\nexport type ExtractQueryValue<T> = T extends (infer U)[]\n ? U extends QueryValue ? U : never\n : T extends QueryValue | null ? NonNullable<T> : never;\n\nexport type QueryableKeys<T> = {\n [K in keyof T]: ExtractQueryValue<T[K]> extends never ? never : K;\n}[keyof T];\n\nexport type QueryBuilder<T> = {\n equal: <K extends QueryableKeys<T>>(field: K, value: ExtractQueryValue<T[K]>) => string;\n notEqual: <K extends QueryableKeys<T>>(field: K, value: ExtractQueryValue<T[K]>) => string;\n lessThan: <K extends QueryableKeys<T>>(field: K, value: ExtractQueryValue<T[K]>) => string;\n lessThanEqual: <K extends QueryableKeys<T>>(field: K, value: ExtractQueryValue<T[K]>) => string;\n greaterThan: <K extends QueryableKeys<T>>(field: K, value: ExtractQueryValue<T[K]>) => string;\n greaterThanEqual: <K extends QueryableKeys<T>>(field: K, value: ExtractQueryValue<T[K]>) => string;\n contains: <K extends QueryableKeys<T>>(field: K, value: ExtractQueryValue<T[K]>) => string;\n search: <K extends QueryableKeys<T>>(field: K, value: string) => string;\n isNull: <K extends QueryableKeys<T>>(field: K) => string;\n isNotNull: <K extends QueryableKeys<T>>(field: K) => string;\n startsWith: <K extends QueryableKeys<T>>(field: K, value: string) => string;\n endsWith: <K extends QueryableKeys<T>>(field: K, value: string) => string;\n between: <K extends QueryableKeys<T>>(field: K, start: ExtractQueryValue<T[K]>, end: ExtractQueryValue<T[K]>) => string;\n select: <K extends keyof T>(fields: K[]) => string;\n orderAsc: <K extends keyof T>(field: K) => string;\n orderDesc: <K extends keyof T>(field: K) => string;\n limit: (value: number) => string;\n offset: (value: number) => string;\n cursorAfter: (documentId: string) => string;\n cursorBefore: (documentId: string) => string;\n or: (...queries: string[]) => string;\n and: (...queries: string[]) => string;\n}\n\nexport type DatabaseId = {{{databaseIdType}}};\n\n{{{DATABASE_TABLES_TYPE}}}\n";
141823
142090
 
141824
142091
  // lib/commands/generators/typescript/templates/databases.ts.hbs
141825
- var databases_ts_default = 'import { Client, TablesDB, ID, Query, type Models, Permission, Role } from \'{{appwriteDep}}\';\nimport type { DatabaseHandle, DatabaseId, DatabaseTableMap, DatabaseTables, QueryBuilder, PermissionBuilder, RoleBuilder, RoleString } from \'./types{{importExt}}\';\n{{#if supportsServerSide}}\nimport { PROJECT_ID, ENDPOINT, API_KEY } from \'./constants{{importExt}}\';\n{{else}}\nimport { PROJECT_ID, ENDPOINT } from \'./constants{{importExt}}\';\n{{/if}}\n\nconst createQueryBuilder = <T>(): QueryBuilder<T> => ({\n equal: (field, value) => Query.equal(String(field), value as any),\n notEqual: (field, value) => Query.notEqual(String(field), value as any),\n lessThan: (field, value) => Query.lessThan(String(field), value as any),\n lessThanEqual: (field, value) => Query.lessThanEqual(String(field), value as any),\n greaterThan: (field, value) => Query.greaterThan(String(field), value as any),\n greaterThanEqual: (field, value) => Query.greaterThanEqual(String(field), value as any),\n contains: (field, value) => Query.contains(String(field), value as any),\n search: (field, value) => Query.search(String(field), value),\n isNull: (field) => Query.isNull(String(field)),\n isNotNull: (field) => Query.isNotNull(String(field)),\n startsWith: (field, value) => Query.startsWith(String(field), value),\n endsWith: (field, value) => Query.endsWith(String(field), value),\n between: (field, start, end) => Query.between(String(field), start as any, end as any),\n select: (fields) => Query.select(fields.map(String)),\n orderAsc: (field) => Query.orderAsc(String(field)),\n orderDesc: (field) => Query.orderDesc(String(field)),\n limit: (value) => Query.limit(value),\n offset: (value) => Query.offset(value),\n cursorAfter: (documentId) => Query.cursorAfter(documentId),\n cursorBefore: (documentId) => Query.cursorBefore(documentId),\n or: (...queries) => Query.or(queries),\n and: (...queries) => Query.and(queries),\n});\n\n{{{TABLE_ID_MAP}}}\n\n{{{TABLES_WITH_RELATIONSHIPS}}}\n\nconst roleBuilder: RoleBuilder = {\n any: () => Role.any() as RoleString,\n user: (userId, status?) => Role.user(userId, status) as RoleString,\n users: (status?) => Role.users(status) as RoleString,\n guests: () => Role.guests() as RoleString,\n team: (teamId, role?) => Role.team(teamId, role) as RoleString,\n member: (memberId) => Role.member(memberId) as RoleString,\n label: (label) => Role.label(label) as RoleString,\n};\n\nconst permissionBuilder: PermissionBuilder = {\n read: (role) => Permission.read(role),\n write: (role) => Permission.write(role),\n create: (role) => Permission.create(role),\n update: (role) => Permission.update(role),\n delete: (role) => Permission.delete(role),\n};\n\nconst resolvePermissions = (callback?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]): string[] | undefined =>\n callback?.(permissionBuilder, roleBuilder);\n\nfunction createTableApi<T extends Models.Row>(\n tablesDB: TablesDB,\n databaseId: string,\n tableId: string,\n) {\n return {\n create: (data: any, options?: { rowId?: string; permissions?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]; transactionId?: string }) =>\n tablesDB.createRow<T>({\n databaseId,\n tableId,\n rowId: options?.rowId ?? ID.unique(),\n data,\n permissions: resolvePermissions(options?.permissions),\n transactionId: options?.transactionId,\n }),\n get: (id: string) =>\n tablesDB.getRow<T>({\n databaseId,\n tableId,\n rowId: id,\n }),\n update: (id: string, data: any, options?: { permissions?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]; transactionId?: string }) =>\n tablesDB.updateRow<T>({\n databaseId,\n tableId,\n rowId: id,\n data,\n ...(options?.permissions ? { permissions: resolvePermissions(options.permissions) } : {}),\n transactionId: options?.transactionId,\n }),\n delete: async (id: string, options?: { transactionId?: string }) => {\n await tablesDB.deleteRow({\n databaseId,\n tableId,\n rowId: id,\n transactionId: options?.transactionId,\n });\n },\n list: (options?: { queries?: (q: any) => string[] }) =>\n tablesDB.listRows<T>({\n databaseId,\n tableId,\n queries: options?.queries?.(createQueryBuilder<T>()),\n }),{{{BULK_METHODS}}}\n };\n}\n\n{{{BULK_CHECK}}}\nconst hasOwn = (obj: unknown, key: string): boolean =>\n obj != null && Object.prototype.hasOwnProperty.call(obj, key);\n\nfunction createDatabaseHandle<D extends DatabaseId>(\n tablesDB: TablesDB,\n databaseId: D,\n): DatabaseHandle<D> {\n const tableApiCache = new Map<string, unknown>();\n const dbMap = tableIdMap[databaseId];\n\n return {\n use: <T extends keyof DatabaseTableMap[D] & string>(tableId: T): DatabaseTableMap[D][T] => {\n if (!hasOwn(dbMap, tableId)) {\n throw new Error(`Unknown table "${tableId}" in database "${databaseId}"`);\n }\n\n if (!tableApiCache.has(tableId)) {\n const resolvedTableId = dbMap[tableId];\n const api = createTableApi(tablesDB, databaseId, resolvedTableId);\n {{{BULK_REMOVAL}}}\n tableApiCache.set(tableId, api);\n }\n return tableApiCache.get(tableId) as DatabaseTableMap[D][T];\n },\n{{#if supportsServerSide}}\n create: (tableId: string, name: string, options?: { permissions?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]; rowSecurity?: boolean; enabled?: boolean; columns?: any[]; indexes?: any[] }) =>\n tablesDB.createTable({\n databaseId,\n tableId,\n name,\n permissions: resolvePermissions(options?.permissions),\n rowSecurity: options?.rowSecurity,\n enabled: options?.enabled,\n columns: options?.columns,\n indexes: options?.indexes,\n }),\n update: (tableId: string, options?: { name?: string; permissions?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]; rowSecurity?: boolean; enabled?: boolean }) => {\n if (!hasOwn(dbMap, tableId)) {\n throw new Error(`Unknown table "${tableId}" in database "${databaseId}"`);\n }\n const resolvedTableId = dbMap[tableId];\n return tablesDB.updateTable({\n databaseId,\n tableId: resolvedTableId,\n name: options?.name ?? tableId, // TODO: remove this fallback once fixed in other SDKs\n permissions: resolvePermissions(options?.permissions),\n rowSecurity: options?.rowSecurity,\n enabled: options?.enabled,\n });\n },\n delete: async (tableId: string) => {\n if (!hasOwn(dbMap, tableId)) {\n throw new Error(`Unknown table "${tableId}" in database "${databaseId}"`);\n }\n const resolvedTableId = dbMap[tableId];\n await tablesDB.deleteTable({\n databaseId,\n tableId: resolvedTableId,\n });\n },\n{{/if}}\n };\n}\n\nfunction createDatabasesApi(tablesDB: TablesDB): DatabaseTables {\n const dbCache = new Map<DatabaseId, ReturnType<typeof createDatabaseHandle>>();\n\n return {\n use: (databaseId: DatabaseId) => {\n if (!hasOwn(tableIdMap, databaseId)) {\n throw new Error(`Unknown database "${databaseId}"`);\n }\n\n if (!dbCache.has(databaseId)) {\n dbCache.set(databaseId, createDatabaseHandle(tablesDB, databaseId));\n }\n return dbCache.get(databaseId);\n },\n{{#if supportsServerSide}}\n create: (databaseId: string, name: string, options?: { enabled?: boolean }) =>\n tablesDB.create({\n databaseId,\n name,\n enabled: options?.enabled,\n }),\n update: (databaseId: DatabaseId, options?: { name?: string; enabled?: boolean }) => {\n return tablesDB.update({\n databaseId,\n name: options?.name ?? databaseId,\n enabled: options?.enabled,\n });\n },\n delete: async (databaseId: DatabaseId) => {\n await tablesDB.delete({\n databaseId,\n });\n },\n{{/if}}\n } as DatabaseTables;\n}\n\n// Initialize client\nconst client = new Client()\n .setEndpoint(ENDPOINT)\n .setProject(PROJECT_ID){{#if supportsServerSide}}\n .setKey(API_KEY){{/if}};\n\nconst tablesDB = new TablesDB(client);\n\nexport const databases: DatabaseTables = createDatabasesApi(tablesDB);\n';
142092
+ var databases_ts_default = 'import { Client, TablesDB, ID, Query, type Models, Permission, Role } from \'{{appwriteDep}}\';\nimport type { DatabaseHandle, DatabaseId, DatabaseTableMap, DatabaseTables, QueryBuilder, QueryValue, PermissionBuilder, RoleBuilder, RoleString } from \'./types{{importExt}}\';\n{{#if supportsServerSide}}\nimport { PROJECT_ID, ENDPOINT, API_KEY } from \'./constants{{importExt}}\';\n{{else}}\nimport { PROJECT_ID, ENDPOINT } from \'./constants{{importExt}}\';\n{{/if}}\n\nconst createQueryBuilder = <T>(): QueryBuilder<T> => ({\n equal: (field, value) => Query.equal(String(field), value as QueryValue),\n notEqual: (field, value) => Query.notEqual(String(field), value as QueryValue),\n lessThan: (field, value) => Query.lessThan(String(field), value as QueryValue),\n lessThanEqual: (field, value) => Query.lessThanEqual(String(field), value as QueryValue),\n greaterThan: (field, value) => Query.greaterThan(String(field), value as QueryValue),\n greaterThanEqual: (field, value) => Query.greaterThanEqual(String(field), value as QueryValue),\n contains: (field, value) => Query.contains(String(field), value as string | QueryValue[]),\n search: (field, value) => Query.search(String(field), value),\n isNull: (field) => Query.isNull(String(field)),\n isNotNull: (field) => Query.isNotNull(String(field)),\n startsWith: (field, value) => Query.startsWith(String(field), value),\n endsWith: (field, value) => Query.endsWith(String(field), value),\n between: (field, start, end) => Query.between(String(field), start as string | number, end as string | number),\n select: (fields) => Query.select(fields.map(String)),\n orderAsc: (field) => Query.orderAsc(String(field)),\n orderDesc: (field) => Query.orderDesc(String(field)),\n limit: (value) => Query.limit(value),\n offset: (value) => Query.offset(value),\n cursorAfter: (documentId) => Query.cursorAfter(documentId),\n cursorBefore: (documentId) => Query.cursorBefore(documentId),\n or: (...queries) => Query.or(queries),\n and: (...queries) => Query.and(queries),\n});\n\n{{{TABLE_ID_MAP}}}\n\n{{{TABLES_WITH_RELATIONSHIPS}}}\n\nconst roleBuilder: RoleBuilder = {\n any: () => Role.any() as RoleString,\n user: (userId, status?) => Role.user(userId, status) as RoleString,\n users: (status?) => Role.users(status) as RoleString,\n guests: () => Role.guests() as RoleString,\n team: (teamId, role?) => Role.team(teamId, role) as RoleString,\n member: (memberId) => Role.member(memberId) as RoleString,\n label: (label) => Role.label(label) as RoleString,\n};\n\nconst permissionBuilder: PermissionBuilder = {\n read: (role) => Permission.read(role),\n write: (role) => Permission.write(role),\n create: (role) => Permission.create(role),\n update: (role) => Permission.update(role),\n delete: (role) => Permission.delete(role),\n};\n\nconst resolvePermissions = (callback?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]): string[] | undefined =>\n callback?.(permissionBuilder, roleBuilder);\n\nfunction createTableApi<T extends Models.Row>(\n tablesDB: TablesDB,\n databaseId: string,\n tableId: string,\n) {\n return {\n create: (data: Omit<T, keyof Models.Row>, options?: { rowId?: string; permissions?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]; transactionId?: string }) =>\n tablesDB.createRow<T>({\n databaseId,\n tableId,\n rowId: options?.rowId ?? ID.unique(),\n data: data as T extends Models.DefaultRow ? Partial<Models.Row> & Record<string, unknown> : Partial<Models.Row> & Omit<T, keyof Models.Row>,\n permissions: resolvePermissions(options?.permissions),\n transactionId: options?.transactionId,\n }),\n get: (id: string) =>\n tablesDB.getRow<T>({\n databaseId,\n tableId,\n rowId: id,\n }),\n update: (id: string, data: Partial<Omit<T, keyof Models.Row>>, options?: { permissions?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]; transactionId?: string }) =>\n tablesDB.updateRow<T>({\n databaseId,\n tableId,\n rowId: id,\n data: data as T extends Models.DefaultRow ? Partial<Models.Row> & Record<string, unknown> : Partial<Models.Row> & Partial<Omit<T, keyof Models.Row>>,\n ...(options?.permissions ? { permissions: resolvePermissions(options.permissions) } : {}),\n transactionId: options?.transactionId,\n }),\n delete: async (id: string, options?: { transactionId?: string }) => {\n await tablesDB.deleteRow({\n databaseId,\n tableId,\n rowId: id,\n transactionId: options?.transactionId,\n });\n },\n list: (options?: { queries?: (q: QueryBuilder<T>) => string[] }) =>\n tablesDB.listRows<T>({\n databaseId,\n tableId,\n queries: options?.queries?.(createQueryBuilder<T>()),\n }),{{{BULK_METHODS}}}\n };\n}\n\n{{{BULK_CHECK}}}\nconst hasOwn = (obj: unknown, key: string): boolean =>\n obj != null && Object.prototype.hasOwnProperty.call(obj, key);\n\nfunction createDatabaseHandle<D extends DatabaseId>(\n tablesDB: TablesDB,\n databaseId: D,\n): DatabaseHandle<D> {\n const tableApiCache = new Map<string, unknown>();\n const dbMap = tableIdMap[databaseId];\n\n return {\n use: <T extends keyof DatabaseTableMap[D] & string>(tableId: T): DatabaseTableMap[D][T] => {\n if (!hasOwn(dbMap, tableId)) {\n throw new Error(`Unknown table "${tableId}" in database "${databaseId}"`);\n }\n\n if (!tableApiCache.has(tableId)) {\n const resolvedTableId = dbMap[tableId];\n const api = createTableApi(tablesDB, databaseId, resolvedTableId);\n {{{BULK_REMOVAL}}}\n tableApiCache.set(tableId, api);\n }\n return tableApiCache.get(tableId) as DatabaseTableMap[D][T];\n },\n{{#if supportsServerSide}}\n create: (tableId: string, name: string, options?: { permissions?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; indexes?: object[] }) =>\n tablesDB.createTable({\n databaseId,\n tableId,\n name,\n permissions: resolvePermissions(options?.permissions),\n rowSecurity: options?.rowSecurity,\n enabled: options?.enabled,\n columns: options?.columns,\n indexes: options?.indexes,\n }),\n update: (tableId: string, options?: { name?: string; permissions?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]; rowSecurity?: boolean; enabled?: boolean }) => {\n if (!hasOwn(dbMap, tableId)) {\n throw new Error(`Unknown table "${tableId}" in database "${databaseId}"`);\n }\n const resolvedTableId = dbMap[tableId];\n return tablesDB.updateTable({\n databaseId,\n tableId: resolvedTableId,\n name: options?.name,\n permissions: resolvePermissions(options?.permissions),\n rowSecurity: options?.rowSecurity,\n enabled: options?.enabled,\n });\n },\n delete: async (tableId: string) => {\n if (!hasOwn(dbMap, tableId)) {\n throw new Error(`Unknown table "${tableId}" in database "${databaseId}"`);\n }\n const resolvedTableId = dbMap[tableId];\n await tablesDB.deleteTable({\n databaseId,\n tableId: resolvedTableId,\n });\n },\n{{/if}}\n };\n}\n\nfunction createDatabasesApi(tablesDB: TablesDB): DatabaseTables {\n const dbCache = new Map<DatabaseId, ReturnType<typeof createDatabaseHandle>>();\n\n return {\n use: (databaseId: DatabaseId) => {\n if (!hasOwn(tableIdMap, databaseId)) {\n throw new Error(`Unknown database "${databaseId}"`);\n }\n\n if (!dbCache.has(databaseId)) {\n dbCache.set(databaseId, createDatabaseHandle(tablesDB, databaseId));\n }\n return dbCache.get(databaseId);\n },\n{{#if supportsServerSide}}\n create: (databaseId: string, name: string, options?: { enabled?: boolean }) =>\n tablesDB.create({\n databaseId,\n name,\n enabled: options?.enabled,\n }),\n update: (databaseId: DatabaseId, options?: { name?: string; enabled?: boolean }) => {\n return tablesDB.update({\n databaseId,\n name: options?.name ?? databaseId,\n enabled: options?.enabled,\n });\n },\n delete: async (databaseId: DatabaseId) => {\n await tablesDB.delete({\n databaseId,\n });\n },\n{{/if}}\n } as DatabaseTables;\n}\n\n// Initialize client\nconst client = new Client()\n .setEndpoint(ENDPOINT)\n .setProject(PROJECT_ID){{#if supportsServerSide}}\n .setKey(API_KEY){{/if}};\n\nconst tablesDB = new TablesDB(client);\n\nexport const databases: DatabaseTables = createDatabasesApi(tablesDB);\n';
141826
142093
 
141827
142094
  // lib/commands/generators/typescript/templates/index.ts.hbs
141828
142095
  var index_ts_default = '/**\n * {{sdkTitle}} Generated SDK\n *\n * This file is auto-generated. Do not edit manually.\n * Re-run `{{executableName}} generate` to regenerate.\n */\n\nexport { databases } from "./databases{{importExt}}";\nexport * from "./types{{importExt}}";\n';
@@ -141989,7 +142256,7 @@ ${dbReturnTypes}
141989
142256
 
141990
142257
  export type DatabaseHandle<D extends DatabaseId> = {
141991
142258
  use: <T extends keyof DatabaseTableMap[D] & string>(tableId: T) => DatabaseTableMap[D][T];
141992
- ${supportsServerSide ? ` create: (tableId: string, name: string, options?: { permissions?: ${PERMISSION_CALLBACK_INLINE}; rowSecurity?: boolean; enabled?: boolean; columns?: any[]; indexes?: any[] }) => Promise<Models.Table>;
142259
+ ${supportsServerSide ? ` create: (tableId: string, name: string, options?: { permissions?: ${PERMISSION_CALLBACK_INLINE}; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; indexes?: object[] }) => Promise<Models.Table>;
141993
142260
  update: <T extends keyof DatabaseTableMap[D] & string>(tableId: T, options?: { name?: string; permissions?: ${PERMISSION_CALLBACK_INLINE}; rowSecurity?: boolean; enabled?: boolean }) => Promise<Models.Table>;
141994
142261
  delete: <T extends keyof DatabaseTableMap[D] & string>(tableId: T) => Promise<void>;` : ""}
141995
142262
  };
@@ -142001,12 +142268,11 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
142001
142268
  delete: <D extends DatabaseId>(databaseId: D) => Promise<void>;` : ""}
142002
142269
  };`;
142003
142270
  }
142004
- generateTypesFile(config2) {
142271
+ generateTypesFile(config2, appwriteDep) {
142005
142272
  const entities = config2.tables?.length ? config2.tables : config2.collections;
142006
142273
  if (!entities || entities.length === 0) {
142007
142274
  return "// No tables or collections found in configuration\n";
142008
142275
  }
142009
- const appwriteDep = getAppwriteDependency();
142010
142276
  const enums = this.generateEnums(entities);
142011
142277
  const types2 = entities.map((entity) => this.generateTableType(entity, entities)).join("\n\n");
142012
142278
  const entitiesByDb = this.groupEntitiesByDb(entities);
@@ -142056,26 +142322,26 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
142056
142322
  generateBulkMethods(supportsBulk) {
142057
142323
  if (!supportsBulk) return "";
142058
142324
  return `
142059
- createMany: (rows: any[], options?: { transactionId?: string }) =>
142325
+ createMany: (rows: object[], options?: { transactionId?: string }) =>
142060
142326
  tablesDB.createRows({
142061
142327
  databaseId,
142062
142328
  tableId,
142063
142329
  rows,
142064
142330
  transactionId: options?.transactionId,
142065
142331
  }),
142066
- updateMany: (data: any, options?: { queries?: (q: any) => string[]; transactionId?: string }) =>
142332
+ updateMany: (data: object, options?: { queries?: (q: QueryBuilder<T>) => string[]; transactionId?: string }) =>
142067
142333
  tablesDB.updateRows({
142068
142334
  databaseId,
142069
142335
  tableId,
142070
142336
  data,
142071
- queries: options?.queries?.(createQueryBuilder()),
142337
+ queries: options?.queries?.(createQueryBuilder<T>()),
142072
142338
  transactionId: options?.transactionId,
142073
142339
  }),
142074
- deleteMany: (options?: { queries?: (q: any) => string[]; transactionId?: string }) =>
142340
+ deleteMany: (options?: { queries?: (q: QueryBuilder<T>) => string[]; transactionId?: string }) =>
142075
142341
  tablesDB.deleteRows({
142076
142342
  databaseId,
142077
142343
  tableId,
142078
- queries: options?.queries?.(createQueryBuilder()),
142344
+ queries: options?.queries?.(createQueryBuilder<T>()),
142079
142345
  transactionId: options?.transactionId,
142080
142346
  }),`;
142081
142347
  }
@@ -142089,18 +142355,17 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
142089
142355
  return `
142090
142356
  // Remove bulk methods for tables with relationships
142091
142357
  if (!hasBulkMethods(databaseId, tableId)) {
142092
- delete (api as any).createMany;
142093
- delete (api as any).updateMany;
142094
- delete (api as any).deleteMany;
142358
+ delete (api as Record<string, unknown>).createMany;
142359
+ delete (api as Record<string, unknown>).updateMany;
142360
+ delete (api as Record<string, unknown>).deleteMany;
142095
142361
  }`;
142096
142362
  }
142097
- generateDatabasesFile(config2, importExt) {
142363
+ generateDatabasesFile(config2, importExt, appwriteDep) {
142098
142364
  const entities = config2.tables?.length ? config2.tables : config2.collections;
142099
142365
  if (!entities || entities.length === 0) {
142100
142366
  return "// No tables or collections found in configuration\n";
142101
142367
  }
142102
142368
  const entitiesByDb = this.groupEntitiesByDb(entities);
142103
- const appwriteDep = getAppwriteDependency();
142104
142369
  const supportsServerSide = supportsServerSideMethods(
142105
142370
  appwriteDep,
142106
142371
  this.serverSideOverride
@@ -142123,8 +142388,7 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
142123
142388
  importExt
142124
142389
  });
142125
142390
  }
142126
- generateConstantsFile(config2) {
142127
- const appwriteDep = getAppwriteDependency();
142391
+ generateConstantsFile(config2, appwriteDep) {
142128
142392
  const supportsServerSide = supportsServerSideMethods(
142129
142393
  appwriteDep,
142130
142394
  this.serverSideOverride
@@ -142136,11 +142400,12 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
142136
142400
  requiresApiKey: supportsServerSide
142137
142401
  });
142138
142402
  }
142139
- async generate(config2) {
142403
+ async generate(config2, options) {
142140
142404
  if (!config2.projectId) {
142141
142405
  throw new Error("Project ID is required in configuration");
142142
142406
  }
142143
- const importExt = detectImportExtension();
142407
+ const appwriteDep = options?.appwriteImportSource ?? getAppwriteDependency();
142408
+ const importExt = options?.importExtension ?? detectImportExtension();
142144
142409
  const hasEntities = config2.tables && config2.tables.length > 0 || config2.collections && config2.collections.length > 0;
142145
142410
  if (!hasEntities) {
142146
142411
  console.log(
@@ -142150,14 +142415,14 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
142150
142415
  dbContent: "// No tables or collections found in configuration\n",
142151
142416
  typesContent: "// No tables or collections found in configuration\n",
142152
142417
  indexContent: this.generateIndexFile(importExt),
142153
- constantsContent: this.generateConstantsFile(config2)
142418
+ constantsContent: this.generateConstantsFile(config2, appwriteDep)
142154
142419
  };
142155
142420
  }
142156
142421
  return {
142157
- dbContent: this.generateDatabasesFile(config2, importExt),
142158
- typesContent: this.generateTypesFile(config2),
142422
+ dbContent: this.generateDatabasesFile(config2, importExt, appwriteDep),
142423
+ typesContent: this.generateTypesFile(config2, appwriteDep),
142159
142424
  indexContent: this.generateIndexFile(importExt),
142160
- constantsContent: this.generateConstantsFile(config2)
142425
+ constantsContent: this.generateConstantsFile(config2, appwriteDep)
142161
142426
  };
142162
142427
  }
142163
142428
  };
@@ -142238,8 +142503,9 @@ var generateAction = async (options) => {
142238
142503
  }
142239
142504
  } catch (err) {
142240
142505
  const supported = getSupportedLanguages().join(", ");
142506
+ const message = err instanceof Error ? err.message : String(err);
142241
142507
  error48(
142242
- `${err.message}
142508
+ `${message}
142243
142509
  Use --language to specify the target language. Supported: ${supported}`
142244
142510
  );
142245
142511
  process.exit(1);
@@ -142263,7 +142529,10 @@ Use --language to specify the target language. Supported: ${supported}`
142263
142529
  `Generating type-safe ${detectedLanguage} SDK to ${absoluteOutputDir}...`
142264
142530
  );
142265
142531
  try {
142266
- const result = await generator.generate(config2);
142532
+ const result = await generator.generate(config2, {
142533
+ appwriteImportSource: options.appwriteImportSource,
142534
+ importExtension: options.importExtension
142535
+ });
142267
142536
  await generator.writeFiles(absoluteOutputDir, result);
142268
142537
  const generatedFiles = generator.getGeneratedFilePaths(result);
142269
142538
  success2(`Generated files:`);
@@ -142275,7 +142544,7 @@ Use --language to specify the target language. Supported: ${supported}`
142275
142544
  const firstEntity = entities?.[0];
142276
142545
  const dbId = firstEntity?.databaseId ?? "databaseId";
142277
142546
  const tableName = firstEntity?.name ?? "tableName";
142278
- const importExt = detectImportExtension();
142547
+ const importExt = options.importExtension ?? detectImportExtension();
142279
142548
  console.log("");
142280
142549
  log(`Import the generated SDK in your project:`);
142281
142550
  console.log(
@@ -142294,7 +142563,8 @@ Use --language to specify the target language. Supported: ${supported}`
142294
142563
  );
142295
142564
  }
142296
142565
  } catch (err) {
142297
- error48(`Failed to generate SDK: ${err.message}`);
142566
+ const message = err instanceof Error ? err.message : String(err);
142567
+ error48(`Failed to generate SDK: ${message}`);
142298
142568
  process.exit(1);
142299
142569
  }
142300
142570
  };
@@ -142311,6 +142581,12 @@ var generate = new Command("generate").description(
142311
142581
  "--server <mode>",
142312
142582
  "Override server-side generation (auto|true|false)",
142313
142583
  "auto"
142584
+ ).option(
142585
+ "--appwrite-import-source <source>",
142586
+ "Override Appwrite import source in generated files (e.g. node-appwrite, appwrite, @appwrite.io/console). Auto-detected from package.json/deno.json if not provided."
142587
+ ).option(
142588
+ "--import-extension <ext>",
142589
+ 'Override import file extension in generated files (.js for ESM, empty string for CJS). Auto-detected from package.json "type" field if not provided.'
142314
142590
  ).addHelpText(
142315
142591
  "after",
142316
142592
  `
@@ -142414,7 +142690,7 @@ account.command(`create-jwt`).description(`Use this endpoint to create a JSON We
142414
142690
  async ({ duration: duration3 }) => parse3(await (await getAccountClient()).createJWT(duration3))
142415
142691
  )
142416
142692
  );
142417
- account.command(`list-keys`).description(`Get a list of all API keys from the current account. `).option(
142693
+ account.command(`list-keys`).description(`Get a list of all API keys from the current account.`).option(
142418
142694
  `--total [value]`,
142419
142695
  `When set to false, the total count returned will be 0 and will not be calculated.`,
142420
142696
  (value) => value === void 0 ? true : parseBool(value)
@@ -142992,7 +143268,7 @@ databases.command(`list-attributes`).description(`List attributes in the collect
142992
143268
  )
142993
143269
  );
142994
143270
  databases.command(`create-boolean-attribute`).description(`Create a boolean attribute.
142995
- `).requiredOption(`--database-id <database-id>`, `Database ID.`).requiredOption(`--collection-id <collection-id>`, `Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).`).requiredOption(`--key <key>`, `Attribute Key.`).requiredOption(`--required <required>`, `Is attribute required?`, parseBool).option(
143271
+ `).requiredOption(`--database-id <database-id>`, `Database ID.`).requiredOption(`--collection-id <collection-id>`, `Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).`).requiredOption(`--key <key>`, `Attribute Key.`).requiredOption(`--required <required>`, `Is attribute required?`, parseBool).option(
142996
143272
  `--xdefault [value]`,
142997
143273
  `Default value for attribute when not provided. Cannot be set when attribute is required.`,
142998
143274
  (value) => value === void 0 ? true : parseBool(value)
@@ -143184,6 +143460,12 @@ databases.command(`create-relationship-attribute`).description(`Create relations
143184
143460
  async ({ databaseId, collectionId, relatedCollectionId, type, twoWay, key, twoWayKey, onDelete }) => parse3(await (await getDatabasesClient()).createRelationshipAttribute(databaseId, collectionId, relatedCollectionId, type, twoWay, key, twoWayKey, onDelete))
143185
143461
  )
143186
143462
  );
143463
+ databases.command(`update-relationship-attribute`).description(`Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes).
143464
+ `).requiredOption(`--database-id <database-id>`, `Database ID.`).requiredOption(`--collection-id <collection-id>`, `Collection ID.`).requiredOption(`--key <key>`, `Attribute Key.`).option(`--on-delete <on-delete>`, `Constraints option`).option(`--new-key <new-key>`, `New Attribute Key.`).action(
143465
+ actionRunner(
143466
+ async ({ databaseId, collectionId, key, onDelete, newKey }) => parse3(await (await getDatabasesClient()).updateRelationshipAttribute(databaseId, collectionId, key, onDelete, newKey))
143467
+ )
143468
+ );
143187
143469
  databases.command(`create-string-attribute`).description(`Create a string attribute.
143188
143470
  `).requiredOption(`--database-id <database-id>`, `Database ID.`).requiredOption(`--collection-id <collection-id>`, `Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).`).requiredOption(`--key <key>`, `Attribute Key.`).requiredOption(`--size <size>`, `Attribute size for text attributes, in number of characters.`, parseInteger).requiredOption(`--required <required>`, `Is attribute required?`, parseBool).option(`--xdefault <xdefault>`, `Default value for attribute when not provided. Cannot be set when attribute is required.`).option(
143189
143471
  `--array [value]`,
@@ -143270,19 +143552,13 @@ databases.command(`delete-attribute`).description(`Deletes an attribute.`).requi
143270
143552
  async ({ databaseId, collectionId, key }) => parse3(await (await getDatabasesClient()).deleteAttribute(databaseId, collectionId, key))
143271
143553
  )
143272
143554
  );
143273
- databases.command(`update-relationship-attribute`).description(`Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes).
143274
- `).requiredOption(`--database-id <database-id>`, `Database ID.`).requiredOption(`--collection-id <collection-id>`, `Collection ID.`).requiredOption(`--key <key>`, `Attribute Key.`).option(`--on-delete <on-delete>`, `Constraints option`).option(`--new-key <new-key>`, `New Attribute Key.`).action(
143275
- actionRunner(
143276
- async ({ databaseId, collectionId, key, onDelete, newKey }) => parse3(await (await getDatabasesClient()).updateRelationshipAttribute(databaseId, collectionId, key, onDelete, newKey))
143277
- )
143278
- );
143279
143555
  databases.command(`list-documents`).description(`Get a list of all the user's documents in a given collection. You can use the query params to filter your results.`).requiredOption(`--database-id <database-id>`, `Database ID.`).requiredOption(`--collection-id <collection-id>`, `Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).`).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.`).option(`--transaction-id <transaction-id>`, `Transaction ID to read uncommitted changes within the transaction.`).option(
143280
143556
  `--total [value]`,
143281
143557
  `When set to false, the total count returned will be 0 and will not be calculated.`,
143282
143558
  (value) => value === void 0 ? true : parseBool(value)
143283
- ).action(
143559
+ ).option(`--ttl <ttl>`, `TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours).`, parseInteger).action(
143284
143560
  actionRunner(
143285
- async ({ databaseId, collectionId, queries, transactionId, total }) => parse3(await (await getDatabasesClient()).listDocuments(databaseId, collectionId, queries, transactionId, total))
143561
+ async ({ databaseId, collectionId, queries, transactionId, total, ttl }) => parse3(await (await getDatabasesClient()).listDocuments(databaseId, collectionId, queries, transactionId, total, ttl))
143286
143562
  )
143287
143563
  );
143288
143564
  databases.command(`create-document`).description(`Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console.`).requiredOption(`--database-id <database-id>`, `Database ID.`).requiredOption(`--collection-id <collection-id>`, `Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents.`).requiredOption(`--document-id <document-id>`, `Document ID. Choose a custom ID or generate a random ID with \`ID.unique()\`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`).requiredOption(`--data <data>`, `Document data as JSON object.`).option(`--permissions [permissions...]`, `An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).`).option(`--transaction-id <transaction-id>`, `Transaction ID for staging the operation.`).action(
@@ -143685,6 +143961,12 @@ health.command(`get-certificate`).description(`Get the SSL certificate for a dom
143685
143961
  async ({ domain: domain2 }) => parse3(await (await getHealthClient()).getCertificate(domain2))
143686
143962
  )
143687
143963
  );
143964
+ health.command(`get-console-pausing`).description(`Get console pausing health status. Monitors projects approaching the pause threshold to detect potential issues with console access tracking.
143965
+ `).option(`--threshold <threshold>`, `Percentage threshold of projects approaching pause. When hit (equal or higher), endpoint returns server error. Default value is 10.`, parseInteger).option(`--inactivity-days <inactivity-days>`, `Number of days of inactivity before a project is paused. Should match the plan's projectInactivityDays setting. Default value is 7.`, parseInteger).action(
143966
+ actionRunner(
143967
+ async ({ threshold, inactivityDays }) => parse3(await (await getHealthClient()).getConsolePausing(threshold, inactivityDays))
143968
+ )
143969
+ );
143688
143970
  health.command(`get-db`).description(`Check the Appwrite database servers are up and connection is successful.`).action(
143689
143971
  actionRunner(
143690
143972
  async () => parse3(await (await getHealthClient()).getDB())
@@ -144293,7 +144575,7 @@ messaging.command(`list-topic-logs`).description(`Get the topic activity logs li
144293
144575
  async ({ topicId, queries, total }) => parse3(await (await getMessagingClient()).listTopicLogs(topicId, queries, total))
144294
144576
  )
144295
144577
  );
144296
- messaging.command(`list-subscribers`).description(`Get a list of all subscribers from the current Appwrite project.`).requiredOption(`--topic-id <topic-id>`, `Topic ID. The topic ID subscribed to.`).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, provider, type, enabled`).option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`).option(
144578
+ messaging.command(`list-subscribers`).description(`Get a list of all subscribers from the current Appwrite project.`).requiredOption(`--topic-id <topic-id>`, `Topic ID. The topic ID subscribed to.`).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: targetId, topicId, userId, providerType`).option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`).option(
144297
144579
  `--total [value]`,
144298
144580
  `When set to false, the total count returned will be 0 and will not be calculated.`,
144299
144581
  (value) => value === void 0 ? true : parseBool(value)
@@ -144575,6 +144857,12 @@ projects.command(`update-auth-status`).description(`Update the status of a speci
144575
144857
  async ({ projectId, method, status }) => parse3(await (await getProjectsClient()).updateAuthStatus(projectId, method, status))
144576
144858
  )
144577
144859
  );
144860
+ projects.command(`update-console-access`).description(`Record console access to a project. This endpoint updates the last accessed timestamp for the project to track console activity.
144861
+ `).requiredOption(`--project-id <project-id>`, `Project ID`).action(
144862
+ actionRunner(
144863
+ async ({ projectId }) => parse3(await (await getProjectsClient()).updateConsoleAccess(projectId))
144864
+ )
144865
+ );
144578
144866
  projects.command(`list-dev-keys`).description(`List all the project's dev keys. Dev keys are project specific and allow you to bypass rate limits and get better error logging during development.'`).requiredOption(`--project-id <project-id>`, `Project unique ID.`).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: accessedAt, expire`).action(
144579
144867
  actionRunner(
144580
144868
  async ({ projectId, queries }) => parse3(await (await getProjectsClient()).listDevKeys(projectId, queries))
@@ -144720,6 +145008,12 @@ projects.command(`create-smtp-test`).description(`Send a test email to verify SM
144720
145008
  async ({ projectId, emails, senderName, senderEmail, host, replyTo, port, username, password, secure }) => parse3(await (await getProjectsClient()).createSmtpTest(projectId, emails, senderName, senderEmail, host, replyTo, port, username, password, secure))
144721
145009
  )
144722
145010
  );
145011
+ projects.command(`update-status`).description(`Update the status of a project. Can be used to archive/restore projects, and to restore paused projects. When restoring a paused project, the console fingerprint header must be provided and the project must not be blocked for any reason other than inactivity.
145012
+ `).requiredOption(`--project-id <project-id>`, `Project ID`).requiredOption(`--status <status>`, `New status for the project`).action(
145013
+ actionRunner(
145014
+ async ({ projectId, status }) => parse3(await (await getProjectsClient()).updateStatus(projectId, status))
145015
+ )
145016
+ );
144723
145017
  projects.command(`update-team`).description(`Update the team ID of a project allowing for it to be transferred to another team.`).requiredOption(`--project-id <project-id>`, `Project unique ID.`).requiredOption(`--team-id <team-id>`, `Team ID of the team to transfer project to.`).action(
144724
145018
  actionRunner(
144725
145019
  async ({ projectId, teamId }) => parse3(await (await getProjectsClient()).updateTeam(projectId, teamId))
@@ -144960,9 +145254,13 @@ sites.command(`list-deployments`).description(`Get a list of all the site's code
144960
145254
  async ({ siteId, queries, search, total }) => parse3(await (await getSitesClient()).listDeployments(siteId, queries, search, total))
144961
145255
  )
144962
145256
  );
144963
- sites.command(`create-deployment`).description(`Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you'll need to update the site's deployment to use your new deployment ID.`).requiredOption(`--site-id <site-id>`, `Site ID.`).requiredOption(`--code <code>`, `Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.`).requiredOption(`--activate <activate>`, `Automatically activate the deployment when it is finished building.`, parseBool).option(`--install-command <install-command>`, `Install Commands.`).option(`--build-command <build-command>`, `Build Commands.`).option(`--output-directory <output-directory>`, `Output Directory.`).action(
145257
+ sites.command(`create-deployment`).description(`Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you'll need to update the site's deployment to use your new deployment ID.`).requiredOption(`--site-id <site-id>`, `Site ID.`).requiredOption(`--code <code>`, `Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.`).option(`--install-command <install-command>`, `Install Commands.`).option(`--build-command <build-command>`, `Build Commands.`).option(`--output-directory <output-directory>`, `Output Directory.`).option(
145258
+ `--activate [value]`,
145259
+ `Automatically activate the deployment when it is finished building.`,
145260
+ (value) => value === void 0 ? true : parseBool(value)
145261
+ ).action(
144964
145262
  actionRunner(
144965
- async ({ siteId, code, activate, installCommand, buildCommand, outputDirectory }) => parse3(await (await getSitesClient()).createDeployment(siteId, code, activate, installCommand, buildCommand, outputDirectory))
145263
+ async ({ siteId, code, installCommand, buildCommand, outputDirectory, activate }) => parse3(await (await getSitesClient()).createDeployment(siteId, code, installCommand, buildCommand, outputDirectory, activate))
144966
145264
  )
144967
145265
  );
144968
145266
  sites.command(`create-duplicate-deployment`).description(`Create a new build for an existing site deployment. This endpoint allows you to rebuild a deployment with the updated site configuration, including its commands and output directory if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build.`).requiredOption(`--site-id <site-id>`, `Site ID.`).requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`).action(
@@ -145705,9 +146003,9 @@ tablesDB.command(`list-rows`).description(`Get a list of all the user's rows in
145705
146003
  `--total [value]`,
145706
146004
  `When set to false, the total count returned will be 0 and will not be calculated.`,
145707
146005
  (value) => value === void 0 ? true : parseBool(value)
145708
- ).action(
146006
+ ).option(`--ttl <ttl>`, `TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours).`, parseInteger).action(
145709
146007
  actionRunner(
145710
- async ({ databaseId, tableId, queries, transactionId, total }) => parse3(await (await getTablesDBClient()).listRows(databaseId, tableId, queries, transactionId, total))
146008
+ async ({ databaseId, tableId, queries, transactionId, total, ttl }) => parse3(await (await getTablesDBClient()).listRows(databaseId, tableId, queries, transactionId, total, ttl))
145711
146009
  )
145712
146010
  );
145713
146011
  tablesDB.command(`create-row`).description(`Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console.`).requiredOption(`--database-id <database-id>`, `Database ID.`).requiredOption(`--table-id <table-id>`, `Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows.`).requiredOption(`--row-id <row-id>`, `Row ID. Choose a custom ID or generate a random ID with \`ID.unique()\`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`).requiredOption(`--data <data>`, `Row data as JSON object.`).option(`--permissions [permissions...]`, `An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).`).option(`--transaction-id <transaction-id>`, `Transaction ID for staging the operation.`).action(
@@ -145848,7 +146146,7 @@ You only need to provide one of a user ID, email, or phone number. Appwrite will
145848
146146
  Use the \`url\` parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) endpoint to allow the user to accept the invitation to the team.
145849
146147
 
145850
146148
  Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console.
145851
- `).requiredOption(`--team-id <team-id>`, `Team ID.`).requiredOption(`--roles [roles...]`, `Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.`).option(`--email <email>`, `Email of the new team member.`).option(`--user-id <user-id>`, `ID of the user to be added to a team.`).option(`--phone <phone>`, `Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.`).option(`--url <url>`, `URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.`).option(`--name <name>`, `Name of the new team member. Max length: 128 chars.`).action(
146149
+ `).requiredOption(`--team-id <team-id>`, `Team ID.`).requiredOption(`--roles [roles...]`, `Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long.`).option(`--email <email>`, `Email of the new team member.`).option(`--user-id <user-id>`, `ID of the user to be added to a team.`).option(`--phone <phone>`, `Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.`).option(`--url <url>`, `URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.`).option(`--name <name>`, `Name of the new team member. Max length: 128 chars.`).action(
145852
146150
  actionRunner(
145853
146151
  async ({ teamId, roles, email: email3, userId, phone, url: url2, name }) => parse3(await (await getTeamsClient()).createMembership(teamId, roles, email3, userId, phone, url2, name))
145854
146152
  )
@@ -145859,7 +146157,7 @@ teams.command(`get-membership`).description(`Get a team member by the membership
145859
146157
  )
145860
146158
  );
145861
146159
  teams.command(`update-membership`).description(`Modify the roles of a team member. Only team members with the owner role have access to this endpoint. Learn more about [roles and permissions](https://appwrite.io/docs/permissions).
145862
- `).requiredOption(`--team-id <team-id>`, `Team ID.`).requiredOption(`--membership-id <membership-id>`, `Membership ID.`).requiredOption(`--roles [roles...]`, `An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.`).action(
146160
+ `).requiredOption(`--team-id <team-id>`, `Team ID.`).requiredOption(`--membership-id <membership-id>`, `Membership ID.`).requiredOption(`--roles [roles...]`, `An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long.`).action(
145863
146161
  actionRunner(
145864
146162
  async ({ teamId, membershipId, roles }) => parse3(await (await getTeamsClient()).updateMembership(teamId, membershipId, roles))
145865
146163
  )
@@ -146282,12 +146580,12 @@ async function checkVersion() {
146282
146580
  } else {
146283
146581
  process.stdout.write(import_chalk13.default.blue("\n\u{1F680} You are running a pre-release or development version.") + "\n");
146284
146582
  }
146285
- } catch (error49) {
146583
+ } catch (_error) {
146286
146584
  process.stdout.write(import_chalk13.default.gray("\n(Unable to check for updates)") + "\n");
146287
146585
  }
146288
146586
  }
146289
146587
  if (process.argv.includes("-v") || process.argv.includes("--version")) {
146290
- (async () => {
146588
+ void (async () => {
146291
146589
  await checkVersion();
146292
146590
  process.exit(0);
146293
146591
  })();