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
@@ -2360,7 +2360,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2360
2360
  }
2361
2361
  return positiveOption || option2;
2362
2362
  };
2363
- const getErrorMessage = (option2) => {
2363
+ const getErrorMessage2 = (option2) => {
2364
2364
  const bestOption = findBestOptionFromValue(option2);
2365
2365
  const optionKey = bestOption.attributeName();
2366
2366
  const source = this.getOptionValueSource(optionKey);
@@ -2369,7 +2369,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2369
2369
  }
2370
2370
  return `option '${bestOption.flags}'`;
2371
2371
  };
2372
- const message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`;
2372
+ const message = `error: ${getErrorMessage2(option)} cannot be used with ${getErrorMessage2(conflictingOption)}`;
2373
2373
  this.error(message, { code: "commander.conflictingOption" });
2374
2374
  }
2375
2375
  /**
@@ -4315,9 +4315,9 @@ var require_source = __commonJS({
4315
4315
  }
4316
4316
  });
4317
4317
 
4318
- // node_modules/escape-string-regexp/index.js
4318
+ // node_modules/figures/node_modules/escape-string-regexp/index.js
4319
4319
  var require_escape_string_regexp = __commonJS({
4320
- "node_modules/escape-string-regexp/index.js"(exports, module) {
4320
+ "node_modules/figures/node_modules/escape-string-regexp/index.js"(exports, module) {
4321
4321
  "use strict";
4322
4322
  var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
4323
4323
  module.exports = function(str) {
@@ -21962,9 +21962,9 @@ var require_stream_duplex = __commonJS({
21962
21962
  }
21963
21963
  });
21964
21964
 
21965
- // node_modules/string_decoder/node_modules/safe-buffer/index.js
21965
+ // node_modules/safe-buffer/index.js
21966
21966
  var require_safe_buffer = __commonJS({
21967
- "node_modules/string_decoder/node_modules/safe-buffer/index.js"(exports, module) {
21967
+ "node_modules/safe-buffer/index.js"(exports, module) {
21968
21968
  var buffer = __require("buffer");
21969
21969
  var Buffer2 = buffer.Buffer;
21970
21970
  function copyProps(src, dst) {
@@ -61213,6 +61213,20 @@ var require_lodash = __commonJS({
61213
61213
  }
61214
61214
  });
61215
61215
 
61216
+ // node_modules/inquirer-search-list/node_modules/chalk/node_modules/escape-string-regexp/index.js
61217
+ var require_escape_string_regexp2 = __commonJS({
61218
+ "node_modules/inquirer-search-list/node_modules/chalk/node_modules/escape-string-regexp/index.js"(exports, module) {
61219
+ "use strict";
61220
+ var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
61221
+ module.exports = function(str) {
61222
+ if (typeof str !== "string") {
61223
+ throw new TypeError("Expected a string");
61224
+ }
61225
+ return str.replace(matchOperatorsRe, "\\$&");
61226
+ };
61227
+ }
61228
+ });
61229
+
61216
61230
  // node_modules/inquirer-search-list/node_modules/chalk/node_modules/ansi-styles/node_modules/color-convert/node_modules/color-name/index.js
61217
61231
  var require_color_name2 = __commonJS({
61218
61232
  "node_modules/inquirer-search-list/node_modules/chalk/node_modules/ansi-styles/node_modules/color-convert/node_modules/color-name/index.js"(exports, module) {
@@ -62579,7 +62593,7 @@ var require_templates2 = __commonJS({
62579
62593
  var require_chalk = __commonJS({
62580
62594
  "node_modules/inquirer-search-list/node_modules/chalk/index.js"(exports, module) {
62581
62595
  "use strict";
62582
- var escapeStringRegexp = require_escape_string_regexp();
62596
+ var escapeStringRegexp = require_escape_string_regexp2();
62583
62597
  var ansiStyles = require_ansi_styles2();
62584
62598
  var stdoutColor = require_supports_color2().stdout;
62585
62599
  var template = require_templates2();
@@ -62742,11 +62756,25 @@ var require_chalk = __commonJS({
62742
62756
  }
62743
62757
  });
62744
62758
 
62759
+ // node_modules/inquirer-search-list/node_modules/figures/node_modules/escape-string-regexp/index.js
62760
+ var require_escape_string_regexp3 = __commonJS({
62761
+ "node_modules/inquirer-search-list/node_modules/figures/node_modules/escape-string-regexp/index.js"(exports, module) {
62762
+ "use strict";
62763
+ var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
62764
+ module.exports = function(str) {
62765
+ if (typeof str !== "string") {
62766
+ throw new TypeError("Expected a string");
62767
+ }
62768
+ return str.replace(matchOperatorsRe, "\\$&");
62769
+ };
62770
+ }
62771
+ });
62772
+
62745
62773
  // node_modules/inquirer-search-list/node_modules/figures/index.js
62746
62774
  var require_figures2 = __commonJS({
62747
62775
  "node_modules/inquirer-search-list/node_modules/figures/index.js"(exports, module) {
62748
62776
  "use strict";
62749
- var escapeStringRegexp = require_escape_string_regexp();
62777
+ var escapeStringRegexp = require_escape_string_regexp3();
62750
62778
  var platform = process.platform;
62751
62779
  var main = {
62752
62780
  tick: "\u2714",
@@ -82342,9 +82370,9 @@ var require_is_glob = __commonJS({
82342
82370
  }
82343
82371
  });
82344
82372
 
82345
- // node_modules/glob-parent/index.js
82373
+ // node_modules/chokidar/node_modules/glob-parent/index.js
82346
82374
  var require_glob_parent = __commonJS({
82347
- "node_modules/glob-parent/index.js"(exports, module) {
82375
+ "node_modules/chokidar/node_modules/glob-parent/index.js"(exports, module) {
82348
82376
  "use strict";
82349
82377
  var isGlob = require_is_glob();
82350
82378
  var pathPosixDirname = __require("path").posix.dirname;
@@ -92067,7 +92095,7 @@ var package_default = {
92067
92095
  type: "module",
92068
92096
  homepage: "https://appwrite.io/support",
92069
92097
  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",
92070
- version: "13.6.0",
92098
+ version: "14.0.0",
92071
92099
  license: "BSD-3-Clause",
92072
92100
  main: "dist/index.cjs",
92073
92101
  module: "dist/index.js",
@@ -92098,6 +92126,7 @@ var package_default = {
92098
92126
  "build:lib:esm": "esbuild index.ts --bundle --platform=node --target=node18 --format=esm --loader:.hbs=text --outfile=dist/index.js",
92099
92127
  "build:lib:cjs": "esbuild index.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --outfile=dist/index.cjs",
92100
92128
  "build:cli": "esbuild cli.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:fsevents --outfile=dist/cli.cjs",
92129
+ lint: "eslint .",
92101
92130
  format: 'prettier --write "**/*.{js,ts,json,md}"',
92102
92131
  generate: "tsx scripts/generate-commands.ts",
92103
92132
  prepublishOnly: "npm run build",
@@ -92110,7 +92139,7 @@ var package_default = {
92110
92139
  "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"
92111
92140
  },
92112
92141
  dependencies: {
92113
- "@appwrite.io/console": "^3.1.0",
92142
+ "@appwrite.io/console": "^4.0.0",
92114
92143
  chalk: "4.1.2",
92115
92144
  chokidar: "^3.6.0",
92116
92145
  "cli-progress": "^3.12.0",
@@ -92129,7 +92158,12 @@ var package_default = {
92129
92158
  zod: "^4.3.5"
92130
92159
  },
92131
92160
  devDependencies: {
92161
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
92162
+ "@typescript-eslint/parser": "^8.0.0",
92132
92163
  "@types/bun": "^1.3.5",
92164
+ eslint: "^9.0.0",
92165
+ "eslint-plugin-unused-imports": "^4.0.0",
92166
+ "typescript-eslint": "^8.0.0",
92133
92167
  "@types/cli-progress": "^3.11.5",
92134
92168
  "@types/inquirer": "^8.2.10",
92135
92169
  "@types/json-bigint": "^1.0.4",
@@ -106052,7 +106086,7 @@ var int64Schema = external_exports.preprocess(
106052
106086
  const valueOfResult = val.valueOf();
106053
106087
  const bigIntVal = BigInt(valueOfResult);
106054
106088
  return bigIntVal;
106055
- } catch (e) {
106089
+ } catch (_e) {
106056
106090
  return void 0;
106057
106091
  }
106058
106092
  }
@@ -106062,7 +106096,7 @@ var int64Schema = external_exports.preprocess(
106062
106096
  if (typeof val === "string") {
106063
106097
  try {
106064
106098
  return BigInt(val);
106065
- } catch (e) {
106099
+ } catch (_e) {
106066
106100
  return void 0;
106067
106101
  }
106068
106102
  }
@@ -106344,7 +106378,7 @@ import childProcess from "child_process";
106344
106378
  // lib/constants.ts
106345
106379
  var SDK_TITLE = "Appwrite";
106346
106380
  var SDK_TITLE_LOWER = "appwrite";
106347
- var SDK_VERSION = "13.6.0";
106381
+ var SDK_VERSION = "14.0.0";
106348
106382
  var SDK_NAME = "Command Line";
106349
106383
  var SDK_PLATFORM = "console";
106350
106384
  var SDK_LANGUAGE = "cli";
@@ -106396,6 +106430,12 @@ var createSettingsObject = (project2) => {
106396
106430
  }
106397
106431
  };
106398
106432
  };
106433
+ var getErrorMessage = (error49) => {
106434
+ if (error49 instanceof Error) {
106435
+ return error49.message;
106436
+ }
106437
+ return String(error49);
106438
+ };
106399
106439
  async function getLatestVersion() {
106400
106440
  try {
106401
106441
  const response = await (0, import_undici.fetch)(NPM_REGISTRY_URL);
@@ -106426,7 +106466,7 @@ function getAllFiles(folder) {
106426
106466
  let stats;
106427
106467
  try {
106428
106468
  stats = fs.statSync(pathAbsolute);
106429
- } catch (error49) {
106469
+ } catch (_error) {
106430
106470
  continue;
106431
106471
  }
106432
106472
  if (stats.isDirectory()) {
@@ -106471,7 +106511,7 @@ function systemHasCommand(command) {
106471
106511
  return true;
106472
106512
  }
106473
106513
  var checkDeployConditions = (localConfig2) => {
106474
- if (Object.keys(localConfig2.data).length === 0) {
106514
+ if (localConfig2.keys().length === 0) {
106475
106515
  throw new Error(
106476
106516
  "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."
106477
106517
  );
@@ -106619,7 +106659,7 @@ var Config = class {
106619
106659
  try {
106620
106660
  const file2 = fs2.readFileSync(this.path).toString();
106621
106661
  this.data = JSONBig.parse(file2);
106622
- } catch (e) {
106662
+ } catch (_e) {
106623
106663
  this.data = {};
106624
106664
  }
106625
106665
  }
@@ -107377,7 +107417,7 @@ var Client = class _Client {
107377
107417
  "x-sdk-name": "Console",
107378
107418
  "x-sdk-platform": "console",
107379
107419
  "x-sdk-language": "web",
107380
- "x-sdk-version": "3.1.0",
107420
+ "x-sdk-version": "4.0.0",
107381
107421
  "X-Appwrite-Response-Format": "1.8.0"
107382
107422
  };
107383
107423
  this.realtime = {
@@ -112499,6 +112539,47 @@ var Databases = class {
112499
112539
  };
112500
112540
  return this.client.call("post", uri, apiHeaders, payload);
112501
112541
  }
112542
+ updateRelationshipAttribute(paramsOrFirst, ...rest) {
112543
+ let params;
112544
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
112545
+ params = paramsOrFirst || {};
112546
+ } else {
112547
+ params = {
112548
+ databaseId: paramsOrFirst,
112549
+ collectionId: rest[0],
112550
+ key: rest[1],
112551
+ onDelete: rest[2],
112552
+ newKey: rest[3]
112553
+ };
112554
+ }
112555
+ const databaseId = params.databaseId;
112556
+ const collectionId = params.collectionId;
112557
+ const key = params.key;
112558
+ const onDelete = params.onDelete;
112559
+ const newKey = params.newKey;
112560
+ if (typeof databaseId === "undefined") {
112561
+ throw new AppwriteException('Missing required parameter: "databaseId"');
112562
+ }
112563
+ if (typeof collectionId === "undefined") {
112564
+ throw new AppwriteException('Missing required parameter: "collectionId"');
112565
+ }
112566
+ if (typeof key === "undefined") {
112567
+ throw new AppwriteException('Missing required parameter: "key"');
112568
+ }
112569
+ const apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{key}", key);
112570
+ const payload = {};
112571
+ if (typeof onDelete !== "undefined") {
112572
+ payload["onDelete"] = onDelete;
112573
+ }
112574
+ if (typeof newKey !== "undefined") {
112575
+ payload["newKey"] = newKey;
112576
+ }
112577
+ const uri = new URL(this.client.config.endpoint + apiPath);
112578
+ const apiHeaders = {
112579
+ "content-type": "application/json"
112580
+ };
112581
+ return this.client.call("patch", uri, apiHeaders, payload);
112582
+ }
112502
112583
  createStringAttribute(paramsOrFirst, ...rest) {
112503
112584
  let params;
112504
112585
  if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
@@ -113016,47 +113097,6 @@ var Databases = class {
113016
113097
  };
113017
113098
  return this.client.call("delete", uri, apiHeaders, payload);
113018
113099
  }
113019
- updateRelationshipAttribute(paramsOrFirst, ...rest) {
113020
- let params;
113021
- if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
113022
- params = paramsOrFirst || {};
113023
- } else {
113024
- params = {
113025
- databaseId: paramsOrFirst,
113026
- collectionId: rest[0],
113027
- key: rest[1],
113028
- onDelete: rest[2],
113029
- newKey: rest[3]
113030
- };
113031
- }
113032
- const databaseId = params.databaseId;
113033
- const collectionId = params.collectionId;
113034
- const key = params.key;
113035
- const onDelete = params.onDelete;
113036
- const newKey = params.newKey;
113037
- if (typeof databaseId === "undefined") {
113038
- throw new AppwriteException('Missing required parameter: "databaseId"');
113039
- }
113040
- if (typeof collectionId === "undefined") {
113041
- throw new AppwriteException('Missing required parameter: "collectionId"');
113042
- }
113043
- if (typeof key === "undefined") {
113044
- throw new AppwriteException('Missing required parameter: "key"');
113045
- }
113046
- const apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{key}", key);
113047
- const payload = {};
113048
- if (typeof onDelete !== "undefined") {
113049
- payload["onDelete"] = onDelete;
113050
- }
113051
- if (typeof newKey !== "undefined") {
113052
- payload["newKey"] = newKey;
113053
- }
113054
- const uri = new URL(this.client.config.endpoint + apiPath);
113055
- const apiHeaders = {
113056
- "content-type": "application/json"
113057
- };
113058
- return this.client.call("patch", uri, apiHeaders, payload);
113059
- }
113060
113100
  listDocuments(paramsOrFirst, ...rest) {
113061
113101
  let params;
113062
113102
  if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
@@ -113067,7 +113107,8 @@ var Databases = class {
113067
113107
  collectionId: rest[0],
113068
113108
  queries: rest[1],
113069
113109
  transactionId: rest[2],
113070
- total: rest[3]
113110
+ total: rest[3],
113111
+ ttl: rest[4]
113071
113112
  };
113072
113113
  }
113073
113114
  const databaseId = params.databaseId;
@@ -113075,6 +113116,7 @@ var Databases = class {
113075
113116
  const queries = params.queries;
113076
113117
  const transactionId = params.transactionId;
113077
113118
  const total = params.total;
113119
+ const ttl = params.ttl;
113078
113120
  if (typeof databaseId === "undefined") {
113079
113121
  throw new AppwriteException('Missing required parameter: "databaseId"');
113080
113122
  }
@@ -113092,6 +113134,9 @@ var Databases = class {
113092
113134
  if (typeof total !== "undefined") {
113093
113135
  payload["total"] = total;
113094
113136
  }
113137
+ if (typeof ttl !== "undefined") {
113138
+ payload["ttl"] = ttl;
113139
+ }
113095
113140
  const uri = new URL(this.client.config.endpoint + apiPath);
113096
113141
  const apiHeaders = {};
113097
113142
  return this.client.call("get", uri, apiHeaders, payload);
@@ -115057,6 +115102,30 @@ var Health = class {
115057
115102
  const apiHeaders = {};
115058
115103
  return this.client.call("get", uri, apiHeaders, payload);
115059
115104
  }
115105
+ getConsolePausing(paramsOrFirst, ...rest) {
115106
+ let params;
115107
+ if (!paramsOrFirst || paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
115108
+ params = paramsOrFirst || {};
115109
+ } else {
115110
+ params = {
115111
+ threshold: paramsOrFirst,
115112
+ inactivityDays: rest[0]
115113
+ };
115114
+ }
115115
+ const threshold = params.threshold;
115116
+ const inactivityDays = params.inactivityDays;
115117
+ const apiPath = "/health/console-pausing";
115118
+ const payload = {};
115119
+ if (typeof threshold !== "undefined") {
115120
+ payload["threshold"] = threshold;
115121
+ }
115122
+ if (typeof inactivityDays !== "undefined") {
115123
+ payload["inactivityDays"] = inactivityDays;
115124
+ }
115125
+ const uri = new URL(this.client.config.endpoint + apiPath);
115126
+ const apiHeaders = {};
115127
+ return this.client.call("get", uri, apiHeaders, payload);
115128
+ }
115060
115129
  /**
115061
115130
  * Check the Appwrite database servers are up and connection is successful.
115062
115131
  *
@@ -121142,6 +121211,27 @@ var Projects = class {
121142
121211
  };
121143
121212
  return this.client.call("patch", uri, apiHeaders, payload);
121144
121213
  }
121214
+ updateConsoleAccess(paramsOrFirst) {
121215
+ let params;
121216
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
121217
+ params = paramsOrFirst || {};
121218
+ } else {
121219
+ params = {
121220
+ projectId: paramsOrFirst
121221
+ };
121222
+ }
121223
+ const projectId = params.projectId;
121224
+ if (typeof projectId === "undefined") {
121225
+ throw new AppwriteException('Missing required parameter: "projectId"');
121226
+ }
121227
+ const apiPath = "/projects/{projectId}/console-access".replace("{projectId}", projectId);
121228
+ const payload = {};
121229
+ const uri = new URL(this.client.config.endpoint + apiPath);
121230
+ const apiHeaders = {
121231
+ "content-type": "application/json"
121232
+ };
121233
+ return this.client.call("patch", uri, apiHeaders, payload);
121234
+ }
121145
121235
  listDevKeys(paramsOrFirst, ...rest) {
121146
121236
  let params;
121147
121237
  if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
@@ -122218,6 +122308,35 @@ var Projects = class {
122218
122308
  };
122219
122309
  return this.client.call("post", uri, apiHeaders, payload);
122220
122310
  }
122311
+ updateStatus(paramsOrFirst, ...rest) {
122312
+ let params;
122313
+ if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
122314
+ params = paramsOrFirst || {};
122315
+ } else {
122316
+ params = {
122317
+ projectId: paramsOrFirst,
122318
+ status: rest[0]
122319
+ };
122320
+ }
122321
+ const projectId = params.projectId;
122322
+ const status = params.status;
122323
+ if (typeof projectId === "undefined") {
122324
+ throw new AppwriteException('Missing required parameter: "projectId"');
122325
+ }
122326
+ if (typeof status === "undefined") {
122327
+ throw new AppwriteException('Missing required parameter: "status"');
122328
+ }
122329
+ const apiPath = "/projects/{projectId}/status".replace("{projectId}", projectId);
122330
+ const payload = {};
122331
+ if (typeof status !== "undefined") {
122332
+ payload["status"] = status;
122333
+ }
122334
+ const uri = new URL(this.client.config.endpoint + apiPath);
122335
+ const apiHeaders = {
122336
+ "content-type": "application/json"
122337
+ };
122338
+ return this.client.call("patch", uri, apiHeaders, payload);
122339
+ }
122221
122340
  updateTeam(paramsOrFirst, ...rest) {
122222
122341
  let params;
122223
122342
  if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
@@ -123532,28 +123651,25 @@ var Sites = class {
123532
123651
  params = {
123533
123652
  siteId: paramsOrFirst,
123534
123653
  code: rest[0],
123535
- activate: rest[1],
123536
- installCommand: rest[2],
123537
- buildCommand: rest[3],
123538
- outputDirectory: rest[4]
123654
+ installCommand: rest[1],
123655
+ buildCommand: rest[2],
123656
+ outputDirectory: rest[3],
123657
+ activate: rest[4]
123539
123658
  };
123540
123659
  onProgress = rest[5];
123541
123660
  }
123542
123661
  const siteId = params.siteId;
123543
123662
  const code = params.code;
123544
- const activate = params.activate;
123545
123663
  const installCommand = params.installCommand;
123546
123664
  const buildCommand = params.buildCommand;
123547
123665
  const outputDirectory = params.outputDirectory;
123666
+ const activate = params.activate;
123548
123667
  if (typeof siteId === "undefined") {
123549
123668
  throw new AppwriteException('Missing required parameter: "siteId"');
123550
123669
  }
123551
123670
  if (typeof code === "undefined") {
123552
123671
  throw new AppwriteException('Missing required parameter: "code"');
123553
123672
  }
123554
- if (typeof activate === "undefined") {
123555
- throw new AppwriteException('Missing required parameter: "activate"');
123556
- }
123557
123673
  const apiPath = "/sites/{siteId}/deployments".replace("{siteId}", siteId);
123558
123674
  const payload = {};
123559
123675
  if (typeof installCommand !== "undefined") {
@@ -127291,7 +127407,8 @@ var TablesDB = class {
127291
127407
  tableId: rest[0],
127292
127408
  queries: rest[1],
127293
127409
  transactionId: rest[2],
127294
- total: rest[3]
127410
+ total: rest[3],
127411
+ ttl: rest[4]
127295
127412
  };
127296
127413
  }
127297
127414
  const databaseId = params.databaseId;
@@ -127299,6 +127416,7 @@ var TablesDB = class {
127299
127416
  const queries = params.queries;
127300
127417
  const transactionId = params.transactionId;
127301
127418
  const total = params.total;
127419
+ const ttl = params.ttl;
127302
127420
  if (typeof databaseId === "undefined") {
127303
127421
  throw new AppwriteException('Missing required parameter: "databaseId"');
127304
127422
  }
@@ -127316,6 +127434,9 @@ var TablesDB = class {
127316
127434
  if (typeof total !== "undefined") {
127317
127435
  payload["total"] = total;
127318
127436
  }
127437
+ if (typeof ttl !== "undefined") {
127438
+ payload["ttl"] = ttl;
127439
+ }
127319
127440
  const uri = new URL(this.client.config.endpoint + apiPath);
127320
127441
  const apiHeaders = {};
127321
127442
  return this.client.call("get", uri, apiHeaders, payload);
@@ -131582,20 +131703,69 @@ var SmtpEncryption;
131582
131703
  SmtpEncryption2["Ssl"] = "ssl";
131583
131704
  SmtpEncryption2["Tls"] = "tls";
131584
131705
  })(SmtpEncryption || (SmtpEncryption = {}));
131585
- var Resources;
131586
- (function(Resources2) {
131587
- Resources2["User"] = "user";
131588
- Resources2["Database"] = "database";
131589
- Resources2["Table"] = "table";
131590
- Resources2["Column"] = "column";
131591
- Resources2["Index"] = "index";
131592
- Resources2["Row"] = "row";
131593
- Resources2["Document"] = "document";
131594
- Resources2["Attribute"] = "attribute";
131595
- Resources2["Collection"] = "collection";
131596
- Resources2["Bucket"] = "bucket";
131597
- Resources2["File"] = "file";
131598
- })(Resources || (Resources = {}));
131706
+ var AppwriteMigrationResource;
131707
+ (function(AppwriteMigrationResource2) {
131708
+ AppwriteMigrationResource2["User"] = "user";
131709
+ AppwriteMigrationResource2["Team"] = "team";
131710
+ AppwriteMigrationResource2["Membership"] = "membership";
131711
+ AppwriteMigrationResource2["Database"] = "database";
131712
+ AppwriteMigrationResource2["Table"] = "table";
131713
+ AppwriteMigrationResource2["Column"] = "column";
131714
+ AppwriteMigrationResource2["Index"] = "index";
131715
+ AppwriteMigrationResource2["Row"] = "row";
131716
+ AppwriteMigrationResource2["Document"] = "document";
131717
+ AppwriteMigrationResource2["Attribute"] = "attribute";
131718
+ AppwriteMigrationResource2["Collection"] = "collection";
131719
+ AppwriteMigrationResource2["Bucket"] = "bucket";
131720
+ AppwriteMigrationResource2["File"] = "file";
131721
+ AppwriteMigrationResource2["Function"] = "function";
131722
+ AppwriteMigrationResource2["Deployment"] = "deployment";
131723
+ AppwriteMigrationResource2["Environmentvariable"] = "environment-variable";
131724
+ AppwriteMigrationResource2["Site"] = "site";
131725
+ AppwriteMigrationResource2["Sitedeployment"] = "site-deployment";
131726
+ AppwriteMigrationResource2["Sitevariable"] = "site-variable";
131727
+ })(AppwriteMigrationResource || (AppwriteMigrationResource = {}));
131728
+ var FirebaseMigrationResource;
131729
+ (function(FirebaseMigrationResource2) {
131730
+ FirebaseMigrationResource2["User"] = "user";
131731
+ FirebaseMigrationResource2["Database"] = "database";
131732
+ FirebaseMigrationResource2["Table"] = "table";
131733
+ FirebaseMigrationResource2["Column"] = "column";
131734
+ FirebaseMigrationResource2["Row"] = "row";
131735
+ FirebaseMigrationResource2["Document"] = "document";
131736
+ FirebaseMigrationResource2["Attribute"] = "attribute";
131737
+ FirebaseMigrationResource2["Collection"] = "collection";
131738
+ FirebaseMigrationResource2["Bucket"] = "bucket";
131739
+ FirebaseMigrationResource2["File"] = "file";
131740
+ })(FirebaseMigrationResource || (FirebaseMigrationResource = {}));
131741
+ var NHostMigrationResource;
131742
+ (function(NHostMigrationResource2) {
131743
+ NHostMigrationResource2["User"] = "user";
131744
+ NHostMigrationResource2["Database"] = "database";
131745
+ NHostMigrationResource2["Table"] = "table";
131746
+ NHostMigrationResource2["Column"] = "column";
131747
+ NHostMigrationResource2["Index"] = "index";
131748
+ NHostMigrationResource2["Row"] = "row";
131749
+ NHostMigrationResource2["Document"] = "document";
131750
+ NHostMigrationResource2["Attribute"] = "attribute";
131751
+ NHostMigrationResource2["Collection"] = "collection";
131752
+ NHostMigrationResource2["Bucket"] = "bucket";
131753
+ NHostMigrationResource2["File"] = "file";
131754
+ })(NHostMigrationResource || (NHostMigrationResource = {}));
131755
+ var SupabaseMigrationResource;
131756
+ (function(SupabaseMigrationResource2) {
131757
+ SupabaseMigrationResource2["User"] = "user";
131758
+ SupabaseMigrationResource2["Database"] = "database";
131759
+ SupabaseMigrationResource2["Table"] = "table";
131760
+ SupabaseMigrationResource2["Column"] = "column";
131761
+ SupabaseMigrationResource2["Index"] = "index";
131762
+ SupabaseMigrationResource2["Row"] = "row";
131763
+ SupabaseMigrationResource2["Document"] = "document";
131764
+ SupabaseMigrationResource2["Attribute"] = "attribute";
131765
+ SupabaseMigrationResource2["Collection"] = "collection";
131766
+ SupabaseMigrationResource2["Bucket"] = "bucket";
131767
+ SupabaseMigrationResource2["File"] = "file";
131768
+ })(SupabaseMigrationResource || (SupabaseMigrationResource = {}));
131599
131769
  var ProjectUsageRange;
131600
131770
  (function(ProjectUsageRange2) {
131601
131771
  ProjectUsageRange2["OneHour"] = "1h";
@@ -131672,6 +131842,10 @@ var SMTPSecure;
131672
131842
  SMTPSecure2["Tls"] = "tls";
131673
131843
  SMTPSecure2["Ssl"] = "ssl";
131674
131844
  })(SMTPSecure || (SMTPSecure = {}));
131845
+ var Status;
131846
+ (function(Status2) {
131847
+ Status2["Active"] = "active";
131848
+ })(Status || (Status = {}));
131675
131849
  var EmailTemplateType;
131676
131850
  (function(EmailTemplateType2) {
131677
131851
  EmailTemplateType2["Verification"] = "verification";
@@ -132231,6 +132405,17 @@ var BillingPlanGroup;
132231
132405
  BillingPlanGroup2["Pro"] = "pro";
132232
132406
  BillingPlanGroup2["Scale"] = "scale";
132233
132407
  })(BillingPlanGroup || (BillingPlanGroup = {}));
132408
+ var DomainTransferStatusStatus;
132409
+ (function(DomainTransferStatusStatus2) {
132410
+ DomainTransferStatusStatus2["Transferrable"] = "transferrable";
132411
+ DomainTransferStatusStatus2["NotTransferrable"] = "not_transferrable";
132412
+ DomainTransferStatusStatus2["PendingOwner"] = "pending_owner";
132413
+ DomainTransferStatusStatus2["PendingAdmin"] = "pending_admin";
132414
+ DomainTransferStatusStatus2["PendingRegistry"] = "pending_registry";
132415
+ DomainTransferStatusStatus2["Completed"] = "completed";
132416
+ DomainTransferStatusStatus2["Cancelled"] = "cancelled";
132417
+ DomainTransferStatusStatus2["ServiceUnavailable"] = "service_unavailable";
132418
+ })(DomainTransferStatusStatus || (DomainTransferStatusStatus = {}));
132234
132419
 
132235
132420
  // lib/parser.ts
132236
132421
  var { description } = package_default;
@@ -132243,6 +132428,22 @@ var cliConfig = {
132243
132428
  report: false,
132244
132429
  reportData: {}
132245
132430
  };
132431
+ var toJsonObject = (value) => {
132432
+ if (value && typeof value === "object" && !Array.isArray(value)) {
132433
+ return value;
132434
+ }
132435
+ return null;
132436
+ };
132437
+ var extractReportCommandArgs = (value) => {
132438
+ if (!value || typeof value !== "object") {
132439
+ return [];
132440
+ }
132441
+ const reportData = value;
132442
+ if (!Array.isArray(reportData.data?.args)) {
132443
+ return [];
132444
+ }
132445
+ return reportData.data.args;
132446
+ };
132246
132447
  var parse3 = (data) => {
132247
132448
  if (cliConfig.json) {
132248
132449
  drawJSON(data);
@@ -132263,7 +132464,8 @@ var parse3 = (data) => {
132263
132464
  console.log(`${import_chalk.default.yellow.bold(key)} : ${data[key]}`);
132264
132465
  } else {
132265
132466
  console.log(`${import_chalk.default.yellow.bold.underline(key)}`);
132266
- drawTable([data[key]]);
132467
+ const tableRow = toJsonObject(data[key]) ?? {};
132468
+ drawTable([tableRow]);
132267
132469
  }
132268
132470
  } else {
132269
132471
  console.log(`${import_chalk.default.yellow.bold(key)} : ${data[key]}`);
@@ -132275,9 +132477,7 @@ var drawTable = (data) => {
132275
132477
  console.log("[]");
132276
132478
  return;
132277
132479
  }
132278
- const rows = data.map(
132279
- (item) => item && typeof item === "object" && !Array.isArray(item) ? item : {}
132280
- );
132480
+ const rows = data.map((item) => toJsonObject(item) ?? {});
132281
132481
  const obj = rows.reduce((res, item) => ({ ...res, ...item }), {});
132282
132482
  const keys = Object.keys(obj);
132283
132483
  if (keys.length === 0) {
@@ -132320,7 +132520,7 @@ var drawTable = (data) => {
132320
132520
  } else if (typeof row[key] === "object") {
132321
132521
  rowValues.push(JSON.stringify(row[key]));
132322
132522
  } else {
132323
- rowValues.push(row[key]);
132523
+ rowValues.push(String(row[key]));
132324
132524
  }
132325
132525
  }
132326
132526
  table.push(rowValues);
@@ -132332,7 +132532,7 @@ var drawJSON = (data) => {
132332
132532
  };
132333
132533
  var parseError = (err) => {
132334
132534
  if (cliConfig.report) {
132335
- (async () => {
132535
+ void (async () => {
132336
132536
  let appwriteVersion = "unknown";
132337
132537
  const endpoint = globalConfig2.getEndpoint();
132338
132538
  try {
@@ -132345,7 +132545,8 @@ var parseError = (err) => {
132345
132545
  } catch {
132346
132546
  }
132347
132547
  const version4 = SDK_VERSION;
132348
- const stepsToReproduce = `Running \`${EXECUTABLE_NAME} ${cliConfig.reportData.data.args.join(" ")}\``;
132548
+ const commandArgs = extractReportCommandArgs(cliConfig.reportData);
132549
+ const stepsToReproduce = `Running \`${EXECUTABLE_NAME} ${commandArgs.join(" ")}\``;
132349
132550
  const yourEnvironment = `CLI version: ${version4}
132350
132551
  Operation System: ${os2.type()}
132351
132552
  Appwrite version: ${appwriteVersion}
@@ -132397,7 +132598,7 @@ var actionRunner = (fn) => {
132397
132598
  error48(`The '--all' and '--id' flags cannot be used together.`);
132398
132599
  process.exit(1);
132399
132600
  }
132400
- return fn(...args).catch(parseError);
132601
+ return fn(...args).then(() => void 0).catch(parseError);
132401
132602
  };
132402
132603
  };
132403
132604
  var parseInteger = (value) => {
@@ -132583,19 +132784,22 @@ async function paginate(action, args = {}, limit = 100, wrapper = "", queries =
132583
132784
  ]
132584
132785
  });
132585
132786
  if (wrapper === "") {
132586
- if (response.length === 0) {
132787
+ const listResponse = response;
132788
+ if (listResponse.length === 0) {
132587
132789
  break;
132588
132790
  }
132589
- results = results.concat(response);
132791
+ results = results.concat(listResponse);
132590
132792
  } else {
132591
- if (response[wrapper].length === 0) {
132793
+ const wrappedResponse = response;
132794
+ const wrappedResults = wrappedResponse[wrapper] ?? [];
132795
+ if (wrappedResults.length === 0) {
132796
+ break;
132797
+ }
132798
+ results = results.concat(wrappedResults);
132799
+ total = wrappedResponse.total;
132800
+ if (results.length >= total) {
132592
132801
  break;
132593
132802
  }
132594
- results = results.concat(response[wrapper]);
132595
- }
132596
- total = response.total;
132597
- if (results.length >= total) {
132598
- break;
132599
132803
  }
132600
132804
  pageNumber++;
132601
132805
  }
@@ -132782,7 +132986,7 @@ var questionsInitProject = [
132782
132986
  name: "organization",
132783
132987
  message: "Choose your organization",
132784
132988
  choices: async () => {
132785
- let client2 = await sdkForConsole(true);
132989
+ const client2 = await sdkForConsole(true);
132786
132990
  const { teams: teams2 } = isCloud() ? await paginate(
132787
132991
  async (opts = {}) => (await getOrganizationsService(opts.sdk)).list(),
132788
132992
  { sdk: client2 },
@@ -132794,7 +132998,7 @@ var questionsInitProject = [
132794
132998
  100,
132795
132999
  "teams"
132796
133000
  );
132797
- let choices = teams2.map((team, idx) => {
133001
+ const choices = teams2.map((team, _idx) => {
132798
133002
  return {
132799
133003
  name: `${team.name} (${team["$id"]})`,
132800
133004
  value: team["$id"]
@@ -132843,7 +133047,7 @@ var questionsInitProject = [
132843
133047
  "projects",
132844
133048
  queries
132845
133049
  );
132846
- let choices = projects2.map((project2) => {
133050
+ const choices = projects2.map((project2) => {
132847
133051
  return {
132848
133052
  name: `${project2.name} (${project2["$id"]})`,
132849
133053
  value: {
@@ -132864,13 +133068,13 @@ var questionsInitProject = [
132864
133068
  name: "region",
132865
133069
  message: `Select your ${SDK_TITLE} Cloud region`,
132866
133070
  choices: async () => {
132867
- let client2 = await sdkForConsole(true);
133071
+ const client2 = await sdkForConsole(true);
132868
133072
  const endpoint = globalConfig2.getEndpoint() || DEFAULT_ENDPOINT;
132869
- let response = await client2.call(
133073
+ const response = await client2.call(
132870
133074
  "GET",
132871
133075
  new URL(endpoint + "/console/regions")
132872
133076
  );
132873
- let regions = response.regions || [];
133077
+ const regions = response.regions || [];
132874
133078
  if (!regions.length) {
132875
133079
  throw new Error(
132876
133080
  "No regions found. Please check your network or Appwrite Cloud availability."
@@ -133012,9 +133216,9 @@ var questionsCreateFunction = [
133012
133216
  name: "runtime",
133013
133217
  message: "What runtime would you like to use?",
133014
133218
  choices: async () => {
133015
- let response = await (await getFunctionsService()).listRuntimes();
133016
- let runtimes = response["runtimes"];
133017
- let choices = runtimes.map((runtime, idx) => {
133219
+ const response = await (await getFunctionsService()).listRuntimes();
133220
+ const runtimes = response["runtimes"];
133221
+ const choices = runtimes.map((runtime, _idx) => {
133018
133222
  return {
133019
133223
  name: `${runtime.name} (${runtime["$id"]})`,
133020
133224
  value: {
@@ -133034,9 +133238,9 @@ var questionsCreateFunction = [
133034
133238
  name: "specification",
133035
133239
  message: "What specification would you like to use?",
133036
133240
  choices: async () => {
133037
- let response = await (await getFunctionsService()).listSpecifications();
133038
- let specifications = response["specifications"];
133039
- let choices = specifications.map((spec, idx) => {
133241
+ const response = await (await getFunctionsService()).listSpecifications();
133242
+ const specifications = response["specifications"];
133243
+ const choices = specifications.map((spec, _idx) => {
133040
133244
  return {
133041
133245
  name: `${spec.cpus} CPU, ${spec.memory}MB RAM`,
133042
133246
  value: spec.slug,
@@ -133113,7 +133317,7 @@ var questionsCreateCollection = [
133113
133317
  message: "Choose the collection database",
133114
133318
  choices: async () => {
133115
133319
  const databases2 = localConfig.getDatabases();
133116
- let choices = databases2.map((database, idx) => {
133320
+ const choices = databases2.map((database, _idx) => {
133117
133321
  return {
133118
133322
  name: `${database.name} (${database.$id})`,
133119
133323
  value: database.$id
@@ -133177,7 +133381,7 @@ var questionsCreateTable = [
133177
133381
  message: "Choose the table database",
133178
133382
  choices: async () => {
133179
133383
  const databases2 = localConfig.getTablesDBs();
133180
- let choices = databases2.map((database, idx) => {
133384
+ const choices = databases2.map((database, _idx) => {
133181
133385
  return {
133182
133386
  name: `${database.name} (${database.$id})`,
133183
133387
  value: database.$id
@@ -133311,9 +133515,9 @@ var questionGetEndpoint = [
133311
133515
  if (!value) {
133312
133516
  return "Please enter a valid endpoint.";
133313
133517
  }
133314
- let client2 = new Client().setEndpoint(value);
133518
+ const client2 = new Client().setEndpoint(value);
133315
133519
  try {
133316
- let response = await client2.call(
133520
+ const response = await client2.call(
133317
133521
  "get",
133318
133522
  new URL(value + "/health/version")
133319
133523
  );
@@ -133322,7 +133526,7 @@ var questionGetEndpoint = [
133322
133526
  } else {
133323
133527
  throw new Error();
133324
133528
  }
133325
- } catch (error49) {
133529
+ } catch (_error) {
133326
133530
  return "Invalid endpoint or your Appwrite server is not running as expected.";
133327
133531
  }
133328
133532
  }
@@ -133400,9 +133604,9 @@ var questionsPushSites = [
133400
133604
  validate: (value) => validateRequired("site", value),
133401
133605
  when: () => localConfig.getSites().length > 0,
133402
133606
  choices: () => {
133403
- let sites2 = localConfig.getSites();
133607
+ const sites2 = localConfig.getSites();
133404
133608
  checkDeployConditions(localConfig);
133405
- let choices = sites2.map((site, idx) => {
133609
+ const choices = sites2.map((site, _idx) => {
133406
133610
  return {
133407
133611
  name: `${site.name} (${site.$id})`,
133408
133612
  value: site.$id
@@ -133420,9 +133624,9 @@ var questionsPushFunctions = [
133420
133624
  validate: (value) => validateRequired("function", value),
133421
133625
  when: () => localConfig.getFunctions().length > 0,
133422
133626
  choices: () => {
133423
- let functions2 = localConfig.getFunctions();
133627
+ const functions2 = localConfig.getFunctions();
133424
133628
  checkDeployConditions(localConfig);
133425
- let choices = functions2.map((func, idx) => {
133629
+ const choices = functions2.map((func, _idx) => {
133426
133630
  return {
133427
133631
  name: `${func.name} (${func.$id})`,
133428
133632
  value: func.$id
@@ -133440,7 +133644,7 @@ var questionsPushCollections = [
133440
133644
  validate: (value) => validateRequired("collection", value),
133441
133645
  when: () => localConfig.getCollections().length > 0,
133442
133646
  choices: () => {
133443
- let collections = localConfig.getCollections();
133647
+ const collections = localConfig.getCollections();
133444
133648
  checkDeployConditions(localConfig);
133445
133649
  return collections.map((collection) => {
133446
133650
  return {
@@ -133459,7 +133663,7 @@ var questionsPushTables = [
133459
133663
  validate: (value) => validateRequired("table", value),
133460
133664
  when: () => localConfig.getTables().length > 0,
133461
133665
  choices: () => {
133462
- let tables = localConfig.getTables();
133666
+ const tables = localConfig.getTables();
133463
133667
  checkDeployConditions(localConfig);
133464
133668
  return tables.map((table) => {
133465
133669
  return {
@@ -133492,7 +133696,7 @@ var questionsPushBuckets = [
133492
133696
  validate: (value) => validateRequired("bucket", value),
133493
133697
  when: () => localConfig.getBuckets().length > 0,
133494
133698
  choices: () => {
133495
- let buckets = localConfig.getBuckets();
133699
+ const buckets = localConfig.getBuckets();
133496
133700
  checkDeployConditions(localConfig);
133497
133701
  return buckets.map((bucket) => {
133498
133702
  return {
@@ -133511,7 +133715,7 @@ var questionsPushMessagingTopics = [
133511
133715
  validate: (value) => validateRequired("topics", value),
133512
133716
  when: () => localConfig.getMessagingTopics().length > 0,
133513
133717
  choices: () => {
133514
- let topics = localConfig.getMessagingTopics();
133718
+ const topics = localConfig.getMessagingTopics();
133515
133719
  return topics.map((topic) => {
133516
133720
  return {
133517
133721
  name: `${topic.name} (${topic["$id"]})`,
@@ -133542,7 +133746,7 @@ var questionsPushTeams = [
133542
133746
  validate: (value) => validateRequired("team", value),
133543
133747
  when: () => localConfig.getTeams().length > 0,
133544
133748
  choices: () => {
133545
- let teams2 = localConfig.getTeams();
133749
+ const teams2 = localConfig.getTeams();
133546
133750
  checkDeployConditions(localConfig);
133547
133751
  return teams2.map((team) => {
133548
133752
  return {
@@ -133559,7 +133763,7 @@ var questionsListFactors = [
133559
133763
  name: "factor",
133560
133764
  message: "Your account is protected by multi-factor authentication. Please choose one for verification.",
133561
133765
  choices: async () => {
133562
- let client2 = await sdkForConsole(false);
133766
+ const client2 = await sdkForConsole(false);
133563
133767
  const accountClient2 = new Account(client2);
133564
133768
  const factors = await accountClient2.listMfaFactors();
133565
133769
  const choices = [
@@ -133604,13 +133808,13 @@ var questionsRunFunctions = [
133604
133808
  message: "Which function would you like to develop locally?",
133605
133809
  validate: (value) => validateRequired("function", value),
133606
133810
  choices: () => {
133607
- let functions2 = localConfig.getFunctions();
133811
+ const functions2 = localConfig.getFunctions();
133608
133812
  if (functions2.length === 0) {
133609
133813
  throw new Error(
133610
133814
  `No functions found. Use '${EXECUTABLE_NAME} pull functions' to synchronize existing one, or use '${EXECUTABLE_NAME} init function' to create a new one.`
133611
133815
  );
133612
133816
  }
133613
- let choices = functions2.map((func, idx) => {
133817
+ const choices = functions2.map((func, _idx) => {
133614
133818
  return {
133615
133819
  name: `${func.name} (${func.$id})`,
133616
133820
  value: func.$id
@@ -133638,9 +133842,9 @@ var questionsCreateSite = [
133638
133842
  name: "framework",
133639
133843
  message: "What framework would you like to use?",
133640
133844
  choices: async () => {
133641
- let response = await (await getSitesService()).listFrameworks();
133642
- let frameworks = response["frameworks"];
133643
- let choices = frameworks.map((framework) => {
133845
+ const response = await (await getSitesService()).listFrameworks();
133846
+ const frameworks = response["frameworks"];
133847
+ const choices = frameworks.map((framework) => {
133644
133848
  return {
133645
133849
  name: `${framework.name} (${framework.key})`,
133646
133850
  value: framework
@@ -133654,9 +133858,9 @@ var questionsCreateSite = [
133654
133858
  name: "specification",
133655
133859
  message: "What specification would you like to use?",
133656
133860
  choices: async () => {
133657
- let response = await (await getSitesService()).listSpecifications();
133658
- let specifications = response["specifications"];
133659
- let choices = specifications.map((spec) => {
133861
+ const response = await (await getSitesService()).listSpecifications();
133862
+ const specifications = response["specifications"];
133863
+ const choices = specifications.map((spec) => {
133660
133864
  return {
133661
133865
  name: `${spec.cpus} CPU, ${spec.memory}MB RAM`,
133662
133866
  value: spec.slug,
@@ -133840,7 +134044,7 @@ var Client3 = class _Client {
133840
134044
  let json3 = void 0;
133841
134045
  try {
133842
134046
  json3 = JSON.parse(text2);
133843
- } catch (error49) {
134047
+ } catch (_error) {
133844
134048
  throw new AppwriteException(text2, response.status, "", text2);
133845
134049
  }
133846
134050
  if (path16 !== "/account" && json3.code === 401 && json3.type === "user_more_factors_required") {
@@ -133874,7 +134078,7 @@ var Client3 = class _Client {
133874
134078
  let json2 = void 0;
133875
134079
  try {
133876
134080
  json2 = JSONBig.parse(text);
133877
- } catch (error49) {
134081
+ } catch (_error) {
133878
134082
  return text;
133879
134083
  }
133880
134084
  return json2;
@@ -133945,11 +134149,11 @@ var completeMfaLogin = async ({
133945
134149
  };
133946
134150
  var deleteServerSession = async (sessionId) => {
133947
134151
  try {
133948
- let client2 = await sdkForConsole();
133949
- let accountClient2 = new Account(client2);
134152
+ const client2 = await sdkForConsole();
134153
+ const accountClient2 = new Account(client2);
133950
134154
  await accountClient2.deleteSession(sessionId);
133951
134155
  return true;
133952
- } catch (e) {
134156
+ } catch (_e) {
133953
134157
  return false;
133954
134158
  }
133955
134159
  };
@@ -134034,7 +134238,7 @@ var loginCommand = async ({
134034
134238
  globalConfig2.setEndpoint(configEndpoint);
134035
134239
  globalConfig2.setEmail(answers.email);
134036
134240
  const legacyClient = createLegacyConsoleClient(configEndpoint);
134037
- let client2 = await sdkForConsole(false);
134241
+ const client2 = await sdkForConsole(false);
134038
134242
  let accountClient2 = new Account(client2);
134039
134243
  let account2;
134040
134244
  try {
@@ -134084,8 +134288,8 @@ var whoami = new Command("whoami").description(commandDescriptions["whoami"]).ac
134084
134288
  error48("No user is signed in. To sign in, run 'appwrite login'");
134085
134289
  return;
134086
134290
  }
134087
- let client2 = await sdkForConsole(false);
134088
- let accountClient2 = new Account(client2);
134291
+ const client2 = await sdkForConsole(false);
134292
+ const accountClient2 = new Account(client2);
134089
134293
  let account2;
134090
134294
  try {
134091
134295
  account2 = await accountClient2.get();
@@ -134209,7 +134413,7 @@ var client = new Command("client").description(commandDescriptions["client"]).co
134209
134413
  const tail = cookieValue.length > 8 ? cookieValue.slice(-8) : cookieValue || "********";
134210
134414
  maskedCookie = `${cookieName}=...${tail}`;
134211
134415
  }
134212
- let config2 = {
134416
+ const config2 = {
134213
134417
  endpoint: globalConfig2.getEndpoint(),
134214
134418
  key: maskedKey,
134215
134419
  cookie: maskedCookie,
@@ -134222,16 +134426,16 @@ var client = new Command("client").description(commandDescriptions["client"]).co
134222
134426
  if (endpoint !== void 0) {
134223
134427
  try {
134224
134428
  const id = id_default2.unique();
134225
- let url2 = new URL(endpoint);
134429
+ const url2 = new URL(endpoint);
134226
134430
  if (url2.protocol !== "http:" && url2.protocol !== "https:") {
134227
134431
  throw new Error();
134228
134432
  }
134229
- let clientInstance = new Client().setEndpoint(endpoint);
134433
+ const clientInstance = new Client().setEndpoint(endpoint);
134230
134434
  clientInstance.setProject("console");
134231
134435
  if (selfSigned || globalConfig2.getSelfSigned()) {
134232
134436
  clientInstance.setSelfSigned(true);
134233
134437
  }
134234
- let response = await clientInstance.call(
134438
+ const response = await clientInstance.call(
134235
134439
  "GET",
134236
134440
  new URL(endpoint + "/health/version")
134237
134441
  );
@@ -134382,6 +134586,9 @@ async function downloadDeploymentCode(params) {
134382
134586
  {},
134383
134587
  "arrayBuffer"
134384
134588
  );
134589
+ if (!(downloadBuffer instanceof ArrayBuffer)) {
134590
+ throw new Error("Failed to download deployment archive as ArrayBuffer.");
134591
+ }
134385
134592
  try {
134386
134593
  fs3.writeFileSync(compressedFileName, Buffer.from(downloadBuffer));
134387
134594
  } catch (err) {
@@ -134460,7 +134667,7 @@ var getConfirmation = async () => {
134460
134667
  }
134461
134668
  return answers2.changes;
134462
134669
  }
134463
- let answers = await import_inquirer2.default.prompt(questionPushChanges);
134670
+ const answers = await import_inquirer2.default.prompt(questionPushChanges);
134464
134671
  if (answers.changes !== "YES" && answers.changes !== "NO") {
134465
134672
  answers.changes = await fixConfirmation();
134466
134673
  }
@@ -134510,7 +134717,7 @@ var approveChanges = async (resource, resourceGetFunction, keys, resourceName, r
134510
134717
  options[secondResourceName] = localResource[secondId];
134511
134718
  }
134512
134719
  const remoteResource = await resourceGetFunction(options);
134513
- for (let [key, value] of Object.entries(
134720
+ for (const [key, value] of Object.entries(
134514
134721
  whitelistKeys(remoteResource, keys)
134515
134722
  )) {
134516
134723
  if (skipKeys.includes(key)) {
@@ -134519,28 +134726,30 @@ var approveChanges = async (resource, resourceGetFunction, keys, resourceName, r
134519
134726
  if (isEmpty(value) && isEmpty(localResource[key])) {
134520
134727
  continue;
134521
134728
  }
134522
- if (Array.isArray(value) && Array.isArray(localResource[key])) {
134523
- if (JSON.stringify(value) !== JSON.stringify(localResource[key])) {
134729
+ const localValue = localResource[key];
134730
+ if (Array.isArray(value) && Array.isArray(localValue)) {
134731
+ if (JSON.stringify(value) !== JSON.stringify(localValue)) {
134524
134732
  changes.push({
134525
134733
  id: localResource["$id"],
134526
134734
  key,
134527
134735
  remote: import_chalk4.default.red(value.join("\n")),
134528
- local: import_chalk4.default.green(localResource[key].join("\n"))
134736
+ local: import_chalk4.default.green(
134737
+ localValue.map((entry) => String(entry)).join("\n")
134738
+ )
134529
134739
  });
134530
134740
  }
134531
- } else if (value !== localResource[key]) {
134741
+ } else if (value !== localValue) {
134532
134742
  changes.push({
134533
134743
  id: localResource["$id"],
134534
134744
  key,
134535
- remote: import_chalk4.default.red(value),
134536
- local: import_chalk4.default.green(localResource[key])
134745
+ remote: import_chalk4.default.red(String(value ?? "")),
134746
+ local: import_chalk4.default.green(String(localValue ?? ""))
134537
134747
  });
134538
134748
  }
134539
134749
  }
134540
134750
  } catch (e) {
134541
- if (Number(e.code) !== 404) {
134542
- throw e;
134543
- }
134751
+ const isNotFound = e instanceof AppwriteException && Number(e.code) === 404;
134752
+ if (!isNotFound) throw e;
134544
134753
  }
134545
134754
  })
134546
134755
  );
@@ -135063,7 +135272,7 @@ var pullResources = async ({
135063
135272
  delete actions.collections;
135064
135273
  }
135065
135274
  if (cliConfig.all) {
135066
- for (let action of Object.values(actions)) {
135275
+ for (const action of Object.values(actions)) {
135067
135276
  cliConfig.all = true;
135068
135277
  await action({ returnOnZero: true });
135069
135278
  }
@@ -135302,7 +135511,6 @@ var initProject = async ({
135302
135511
  projectId,
135303
135512
  projectName
135304
135513
  } = {}) => {
135305
- let response = {};
135306
135514
  try {
135307
135515
  if (globalConfig2.getEndpoint() === "" || globalConfig2.getCookie() === "") {
135308
135516
  throw new Error(
@@ -135312,33 +135520,39 @@ var initProject = async ({
135312
135520
  const client2 = await sdkForConsole();
135313
135521
  const accountClient2 = new Account(client2);
135314
135522
  await accountClient2.get();
135315
- } catch (e) {
135523
+ } catch (_e) {
135316
135524
  error48(
135317
135525
  `Error Session not found. Please run '${EXECUTABLE_NAME} login' to create a session`
135318
135526
  );
135319
135527
  process.exit(1);
135320
135528
  }
135321
- let answers = {};
135529
+ let answers;
135322
135530
  if (!organizationId && !projectId && !projectName) {
135323
135531
  answers = await import_inquirer4.default.prompt(questionsInitProject);
135324
135532
  if (answers.override === false) {
135325
135533
  process.exit(1);
135326
135534
  }
135327
135535
  } else {
135328
- answers.start = "existing";
135329
- answers.project = {};
135330
- answers.organization = {};
135331
- answers.organization = organizationId ?? (await import_inquirer4.default.prompt([questionsInitProject[2]])).organization;
135332
- answers.project.name = projectName ?? (await import_inquirer4.default.prompt([questionsInitProject[3]])).project;
135333
- answers.project = projectId ?? (await import_inquirer4.default.prompt([questionsInitProject[4]])).id;
135536
+ const selectedOrganization = organizationId ?? (await import_inquirer4.default.prompt([questionsInitProject[2]])).organization;
135537
+ const selectedProjectName = projectName ?? (await import_inquirer4.default.prompt([questionsInitProject[3]])).project;
135538
+ const selectedProjectId = projectId ?? (await import_inquirer4.default.prompt([questionsInitProject[4]])).id;
135539
+ answers = {
135540
+ start: "existing",
135541
+ project: selectedProjectId,
135542
+ organization: selectedOrganization
135543
+ };
135334
135544
  try {
135335
135545
  const projectsService = await getProjectsService();
135336
- await projectsService.get(projectId);
135546
+ const existingProject = await projectsService.get(selectedProjectId);
135547
+ answers.project = existingProject;
135337
135548
  } catch (e) {
135338
- if (e.code === 404) {
135339
- answers.start = "new";
135340
- answers.id = answers.project;
135341
- answers.project = answers.project.name;
135549
+ if (e instanceof AppwriteException && e.code === 404) {
135550
+ answers = {
135551
+ start: "new",
135552
+ id: selectedProjectId,
135553
+ project: selectedProjectName,
135554
+ organization: selectedOrganization
135555
+ };
135342
135556
  } else {
135343
135557
  throw e;
135344
135558
  }
@@ -135347,10 +135561,26 @@ var initProject = async ({
135347
135561
  localConfig.clear();
135348
135562
  const url2 = new URL(DEFAULT_ENDPOINT);
135349
135563
  if (answers.start === "new") {
135564
+ let projectIdToCreate;
135565
+ let projectNameToCreate;
135566
+ switch (typeof answers.project) {
135567
+ case "string":
135568
+ projectIdToCreate = answers.id ?? answers.project;
135569
+ projectNameToCreate = answers.project;
135570
+ break;
135571
+ case "object":
135572
+ projectIdToCreate = answers.id ?? answers.project.$id;
135573
+ projectNameToCreate = answers.project.name ?? answers.project.$id;
135574
+ break;
135575
+ default:
135576
+ projectIdToCreate = answers.id;
135577
+ projectNameToCreate = "";
135578
+ break;
135579
+ }
135350
135580
  const projectsService = await getProjectsService();
135351
- response = await projectsService.create(
135352
- answers.id,
135353
- answers.project,
135581
+ const response = await projectsService.create(
135582
+ projectIdToCreate,
135583
+ projectNameToCreate,
135354
135584
  answers.organization,
135355
135585
  answers.region
135356
135586
  );
@@ -135361,10 +135591,22 @@ var initProject = async ({
135361
135591
  );
135362
135592
  }
135363
135593
  } else {
135364
- localConfig.setProject(answers.project["$id"]);
135365
- if (isCloud()) {
135594
+ let selectedProject;
135595
+ switch (typeof answers.project) {
135596
+ case "string":
135597
+ selectedProject = { $id: answers.project };
135598
+ break;
135599
+ case "object":
135600
+ selectedProject = answers.project;
135601
+ break;
135602
+ default:
135603
+ selectedProject = { $id: "" };
135604
+ break;
135605
+ }
135606
+ localConfig.setProject(selectedProject.$id);
135607
+ if (isCloud() && selectedProject.region) {
135366
135608
  localConfig.setEndpoint(
135367
- `https://${answers.project["region"]}.${url2.host}${url2.pathname}`
135609
+ `https://${selectedProject.region}.${url2.host}${url2.pathname}`
135368
135610
  );
135369
135611
  }
135370
135612
  }
@@ -135372,8 +135614,10 @@ var initProject = async ({
135372
135614
  `Project successfully ${answers.start === "existing" ? "linked" : "created"}. Details are now stored in appwrite.config.json file.`
135373
135615
  );
135374
135616
  if (answers.start === "existing") {
135375
- answers = await import_inquirer4.default.prompt(questionsInitProjectAutopull);
135376
- if (answers.autopull) {
135617
+ const autopullAnswers = await import_inquirer4.default.prompt(
135618
+ questionsInitProjectAutopull
135619
+ );
135620
+ if (autopullAnswers.autopull) {
135377
135621
  cliConfig.all = true;
135378
135622
  cliConfig.force = true;
135379
135623
  await pullResources({
@@ -135513,7 +135757,6 @@ var initFunction = async () => {
135513
135757
  fs5.mkdirSync(functionDir, { mode: 511 });
135514
135758
  fs5.mkdirSync(templatesDir, { mode: 511 });
135515
135759
  const repo = "https://github.com/appwrite/templates";
135516
- const api = `https://api.github.com/repos/appwrite/templates/contents/${answers.runtime.name}`;
135517
135760
  let selected = { template: "starter" };
135518
135761
  const sparse = (selected ? `${answers.runtime.name}/${selected.template}` : answers.runtime.name).toLowerCase();
135519
135762
  let gitInitCommands = `git clone --single-branch --depth 1 --sparse ${repo} .`;
@@ -135532,17 +135775,18 @@ var initFunction = async () => {
135532
135775
  cwd: templatesDir
135533
135776
  });
135534
135777
  } catch (err) {
135535
- if (err.message.includes("error: unknown option")) {
135778
+ const errorMessage = err instanceof Error ? err.message : String(err);
135779
+ if (errorMessage.includes("error: unknown option")) {
135536
135780
  throw new Error(
135537
- `${err.message}
135781
+ `${errorMessage}
135538
135782
 
135539
135783
  Suggestion: Try updating your git to the latest version, then trying to run this command again.`
135540
135784
  );
135541
- } else if (err.message.includes(
135785
+ } else if (errorMessage.includes(
135542
135786
  "is not recognized as an internal or external command,"
135543
- ) || err.message.includes("command not found")) {
135787
+ ) || errorMessage.includes("command not found")) {
135544
135788
  throw new Error(
135545
- `${err.message}
135789
+ `${errorMessage}
135546
135790
 
135547
135791
  Suggestion: It appears that git is not installed, try installing git then trying to run this command again.`
135548
135792
  );
@@ -135564,9 +135808,9 @@ Suggestion: It appears that git is not installed, try installing git then trying
135564
135808
  }
135565
135809
  }
135566
135810
  const copyRecursiveSync = (src, dest) => {
135567
- let exists = fs5.existsSync(src);
135568
- let stats = exists && fs5.statSync(src);
135569
- let isDirectory = exists && stats && stats.isDirectory();
135811
+ const exists = fs5.existsSync(src);
135812
+ const stats = exists && fs5.statSync(src);
135813
+ const isDirectory = exists && stats && stats.isDirectory();
135570
135814
  if (isDirectory) {
135571
135815
  if (!fs5.existsSync(dest)) {
135572
135816
  fs5.mkdirSync(dest);
@@ -135594,7 +135838,7 @@ Suggestion: It appears that git is not installed, try installing git then trying
135594
135838
  newReadmeFile[0] = `# ${answers.name}`;
135595
135839
  newReadmeFile.splice(1, 2);
135596
135840
  fs5.writeFileSync(readmePath, newReadmeFile.join("\n"));
135597
- let data = {
135841
+ const data = {
135598
135842
  $id: functionId,
135599
135843
  name: answers.name,
135600
135844
  runtime: answers.runtime.id,
@@ -135650,14 +135894,15 @@ var initSite = async () => {
135650
135894
  }
135651
135895
  templateDetails = response.templates[0];
135652
135896
  } catch (err) {
135897
+ const errorMessage = err instanceof Error ? err.message : String(err);
135653
135898
  throw new Error(
135654
- `Failed to fetch template for framework ${answers.framework.key}: ${err.message}`
135899
+ `Failed to fetch template for framework ${answers.framework.key}: ${errorMessage}`
135655
135900
  );
135656
135901
  }
135657
135902
  fs5.mkdirSync(siteDir, { mode: 511 });
135658
135903
  fs5.mkdirSync(templatesDir, { mode: 511 });
135659
135904
  const repo = `https://github.com/${templateDetails.providerOwner}/${templateDetails.providerRepositoryId}`;
135660
- let selected = {
135905
+ const selected = {
135661
135906
  template: templateDetails.frameworks[0].providerRootDirectory
135662
135907
  };
135663
135908
  let dirSetupCommands = "";
@@ -135682,12 +135927,12 @@ var initSite = async () => {
135682
135927
  git config remote.origin.tagopt --no-tags
135683
135928
  `.trim();
135684
135929
  }
135685
- let windowsGitCloneCommands = `
135930
+ const windowsGitCloneCommands = `
135686
135931
  $tag = (git ls-remote --tags origin "${templateDetails.providerVersion}" | Select-Object -Last 1) -replace '.*refs/tags/', ''
135687
135932
  git fetch --depth=1 origin "refs/tags/$tag"
135688
135933
  git checkout FETCH_HEAD
135689
135934
  `.trim();
135690
- let unixGitCloneCommands = `
135935
+ const unixGitCloneCommands = `
135691
135936
  git fetch --depth=1 origin refs/tags/$(git ls-remote --tags origin "${templateDetails.providerVersion}" | tail -n 1 | awk -F '/' '{print $3}')
135692
135937
  git checkout FETCH_HEAD
135693
135938
  `.trim();
@@ -135705,17 +135950,18 @@ var initSite = async () => {
135705
135950
  shell: usedShell
135706
135951
  });
135707
135952
  } catch (err) {
135708
- if (err.message.includes("error: unknown option")) {
135953
+ const errorMessage = err instanceof Error ? err.message : String(err);
135954
+ if (errorMessage.includes("error: unknown option")) {
135709
135955
  throw new Error(
135710
- `${err.message}
135956
+ `${errorMessage}
135711
135957
 
135712
135958
  Suggestion: Try updating your git to the latest version, then trying to run this command again.`
135713
135959
  );
135714
- } else if (err.message.includes(
135960
+ } else if (errorMessage.includes(
135715
135961
  "is not recognized as an internal or external command,"
135716
- ) || err.message.includes("command not found")) {
135962
+ ) || errorMessage.includes("command not found")) {
135717
135963
  throw new Error(
135718
- `${err.message}
135964
+ `${errorMessage}
135719
135965
 
135720
135966
  Suggestion: It appears that git is not installed, try installing git then trying to run this command again.`
135721
135967
  );
@@ -135736,24 +135982,22 @@ Suggestion: It appears that git is not installed, try installing git then trying
135736
135982
  newReadmeFile[0] = `# ${answers.name}`;
135737
135983
  newReadmeFile.splice(1, 2);
135738
135984
  fs5.writeFileSync(readmePath, newReadmeFile.join("\n"));
135739
- let vars = (templateDetails.variables ?? []).map((variable) => {
135740
- let value = variable.value;
135985
+ const vars = {};
135986
+ for (const variable of templateDetails.variables ?? []) {
135987
+ let value = variable.value ?? "";
135741
135988
  const replacements = {
135742
135989
  "{apiEndpoint}": globalConfig2.getEndpoint(),
135743
- "{projectId}": localConfig.getProject().projectId,
135744
- "{projectName}": localConfig.getProject().projectName
135990
+ "{projectId}": localConfig.getProject().projectId ?? "",
135991
+ "{projectName}": localConfig.getProject().projectName ?? ""
135745
135992
  };
135746
135993
  for (const placeholder in replacements) {
135747
- if (value?.includes(placeholder)) {
135994
+ if (value.includes(placeholder)) {
135748
135995
  value = value.replace(placeholder, replacements[placeholder]);
135749
135996
  }
135750
135997
  }
135751
- return {
135752
- key: variable.name,
135753
- value
135754
- };
135755
- });
135756
- let data = {
135998
+ vars[variable.name] = value;
135999
+ }
136000
+ const data = {
135757
136001
  $id: siteId,
135758
136002
  name: answers.name,
135759
136003
  framework: answers.framework.key,
@@ -137220,12 +137464,10 @@ var typesCommand = actionRunner(
137220
137464
  log(`Directory: ${outputDirectory} does not exist, creating...`);
137221
137465
  fs10.mkdirSync(outputDirectory, { recursive: true });
137222
137466
  }
137223
- let tables = localConfig.getTables();
137467
+ const tables = localConfig.getTables();
137224
137468
  let collections = [];
137225
- let dataSource = "tables";
137226
137469
  if (tables.length === 0) {
137227
137470
  collections = localConfig.getCollections();
137228
- dataSource = "collections";
137229
137471
  if (collections.length === 0) {
137230
137472
  const configFileName = path9.basename(localConfig.path);
137231
137473
  throw new Error(
@@ -137680,9 +137922,8 @@ async function dockerStart(func, variables, port) {
137680
137922
  try {
137681
137923
  await waitUntilPortOpen(port);
137682
137924
  } catch (err) {
137683
- error48(
137684
- "Failed to start function with error: " + (err.message ? err.message : err.toString())
137685
- );
137925
+ const message = err instanceof Error ? err.message : String(err);
137926
+ error48(`Failed to start function with error: ${message}`);
137686
137927
  return;
137687
137928
  }
137688
137929
  success2(`Visit http://localhost:${port}/ to execute your function.`);
@@ -137849,7 +138090,7 @@ var runFunction = async ({
137849
138090
  });
137850
138091
  } catch (err) {
137851
138092
  warn(
137852
- "Remote variables not fetched. Production environment variables will not be available. Reason: " + err.message
138093
+ "Remote variables not fetched. Production environment variables will not be available. Reason: " + getErrorMessage(err)
137853
138094
  );
137854
138095
  }
137855
138096
  }
@@ -137873,7 +138114,7 @@ var runFunction = async ({
137873
138114
  await JwtManager.setup(userId, func.scopes ?? []);
137874
138115
  } catch (err) {
137875
138116
  warn(
137876
- "Dynamic API key not generated. Header x-appwrite-key will not be set. Reason: " + err.message
138117
+ "Dynamic API key not generated. Header x-appwrite-key will not be set. Reason: " + getErrorMessage(err)
137877
138118
  );
137878
138119
  }
137879
138120
  const headers = {};
@@ -138373,7 +138614,7 @@ var Spinner = class _Spinner {
138373
138614
  static stop() {
138374
138615
  _Spinner.updatesBar.stop();
138375
138616
  }
138376
- static formatter(options, params, payload) {
138617
+ static formatter(_options, _params, payload) {
138377
138618
  const status = payload.status.padEnd(12);
138378
138619
  const middle = `${payload.resource} (${payload.id})`.padEnd(40);
138379
138620
  let prefix = import_chalk8.default.cyan(payload.prefix ?? "\u29D7");
@@ -138458,7 +138699,7 @@ var Pools = class {
138458
138699
  return true;
138459
138700
  }
138460
138701
  if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
138461
- let steps = Math.max(1, Math.ceil(Number(total) / this.STEP_SIZE));
138702
+ const steps = Math.max(1, Math.ceil(Number(total) / this.STEP_SIZE));
138462
138703
  if (steps > 1 && iteration === 1) {
138463
138704
  this.pollMaxDebounces *= steps;
138464
138705
  log(
@@ -138484,7 +138725,7 @@ var Pools = class {
138484
138725
  return true;
138485
138726
  }
138486
138727
  if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
138487
- let steps = Math.max(1, Math.ceil(Number(total) / this.STEP_SIZE));
138728
+ const steps = Math.max(1, Math.ceil(Number(total) / this.STEP_SIZE));
138488
138729
  if (steps > 1 && iteration === 1) {
138489
138730
  this.pollMaxDebounces *= steps;
138490
138731
  log(
@@ -138500,7 +138741,10 @@ var Pools = class {
138500
138741
  return false;
138501
138742
  }
138502
138743
  if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
138503
- let steps = Math.max(1, Math.ceil(attributeKeys.length / this.STEP_SIZE));
138744
+ const steps = Math.max(
138745
+ 1,
138746
+ Math.ceil(attributeKeys.length / this.STEP_SIZE)
138747
+ );
138504
138748
  if (steps > 1 && iteration === 1) {
138505
138749
  this.pollMaxDebounces *= steps;
138506
138750
  log(
@@ -138543,7 +138787,10 @@ var Pools = class {
138543
138787
  return false;
138544
138788
  }
138545
138789
  if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
138546
- let steps = Math.max(1, Math.ceil(attributeKeys.length / this.STEP_SIZE));
138790
+ const steps = Math.max(
138791
+ 1,
138792
+ Math.ceil(attributeKeys.length / this.STEP_SIZE)
138793
+ );
138547
138794
  if (steps > 1 && iteration === 1) {
138548
138795
  this.pollMaxDebounces *= steps;
138549
138796
  log(
@@ -138592,7 +138839,7 @@ var Pools = class {
138592
138839
  return false;
138593
138840
  }
138594
138841
  if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
138595
- let steps = Math.max(1, Math.ceil(indexKeys.length / this.STEP_SIZE));
138842
+ const steps = Math.max(1, Math.ceil(indexKeys.length / this.STEP_SIZE));
138596
138843
  if (steps > 1 && iteration === 1) {
138597
138844
  this.pollMaxDebounces *= steps;
138598
138845
  log(
@@ -138685,7 +138932,7 @@ var Attributes = class {
138685
138932
  }
138686
138933
  return answers2.changes;
138687
138934
  }
138688
- let answers = await import_inquirer6.default.prompt(questionPushChanges2);
138935
+ const answers = await import_inquirer6.default.prompt(questionPushChanges2);
138689
138936
  if (answers.changes !== "YES" && answers.changes !== "NO") {
138690
138937
  answers.changes = await fixConfirmation();
138691
138938
  }
@@ -138728,8 +138975,8 @@ var Attributes = class {
138728
138975
  const keyName = `${import_chalk9.default.yellow(local.key)} in ${collection.name} (${collection["$id"]})`;
138729
138976
  const action = import_chalk9.default.cyan(recreating ? "recreating" : "changing");
138730
138977
  let reason = "";
138731
- let attribute = recreating ? remote : local;
138732
- for (let key of Object.keys(remote)) {
138978
+ const attribute = recreating ? remote : local;
138979
+ for (const key of Object.keys(remote)) {
138733
138980
  if (!KeysAttributes.has(key)) {
138734
138981
  continue;
138735
138982
  }
@@ -139239,7 +139486,7 @@ var Attributes = class {
139239
139486
  createIndexes = async (indexes, collection) => {
139240
139487
  log(`Creating indexes ...`);
139241
139488
  const databasesService = await getDatabasesService(this.client);
139242
- for (let index of indexes) {
139489
+ for (const index of indexes) {
139243
139490
  await databasesService.createIndex({
139244
139491
  databaseId: collection["databaseId"],
139245
139492
  collectionId: collection["$id"],
@@ -139263,7 +139510,7 @@ var Attributes = class {
139263
139510
  };
139264
139511
  createAttributes = async (attributes, collection) => {
139265
139512
  log(`Creating attributes ...`);
139266
- for (let attribute of attributes) {
139513
+ for (const attribute of attributes) {
139267
139514
  if (attribute.side !== "child") {
139268
139515
  await this.createAttribute(
139269
139516
  collection["databaseId"],
@@ -139287,7 +139534,7 @@ var Attributes = class {
139287
139534
  };
139288
139535
  createColumns = async (columns, table) => {
139289
139536
  log(`Creating columns ...`);
139290
- for (let column of columns) {
139537
+ for (const column of columns) {
139291
139538
  if (column.side !== "child") {
139292
139539
  await this.createAttribute(table["databaseId"], table["$id"], column);
139293
139540
  }
@@ -139309,18 +139556,37 @@ var Attributes = class {
139309
139556
 
139310
139557
  // lib/commands/utils/database-sync.ts
139311
139558
  var import_chalk10 = __toESM(require_source(), 1);
139559
+ var isTablesDBResource = (value) => {
139560
+ if (!value || typeof value !== "object") {
139561
+ return false;
139562
+ }
139563
+ return "$id" in value && typeof value.$id === "string" && "name" in value && typeof value.name === "string" && "enabled" in value && typeof value.enabled === "boolean";
139564
+ };
139565
+ var getSyncErrorMessage = (err) => {
139566
+ if (err instanceof AppwriteException) {
139567
+ return err.message;
139568
+ }
139569
+ if (err instanceof Error) {
139570
+ return err.message;
139571
+ }
139572
+ return String(err);
139573
+ };
139312
139574
  var checkAndApplyTablesDBChanges = async () => {
139313
139575
  log("Checking for tablesDB changes ...");
139314
139576
  const localTablesDBs = localConfig.getTablesDBs();
139315
- const { databases: remoteTablesDBs } = await paginate(
139577
+ const paginatedResult = await paginate(
139316
139578
  async (args) => {
139317
139579
  const tablesDBService = await getTablesDBService();
139318
- return await tablesDBService.list(args.queries || []);
139580
+ const queries = Array.isArray(args.queries) ? args.queries.filter(
139581
+ (query) => typeof query === "string"
139582
+ ) : [];
139583
+ return await tablesDBService.list(queries);
139319
139584
  },
139320
139585
  {},
139321
139586
  100,
139322
139587
  "databases"
139323
139588
  );
139589
+ const remoteTablesDBs = Array.isArray(paginatedResult.databases) ? paginatedResult.databases.filter(isTablesDBResource) : [];
139324
139590
  if (localTablesDBs.length === 0 && remoteTablesDBs.length === 0) {
139325
139591
  return { applied: false, resyncNeeded: false };
139326
139592
  }
@@ -139342,9 +139608,7 @@ var checkAndApplyTablesDBChanges = async () => {
139342
139608
  }
139343
139609
  }
139344
139610
  for (const localDB of localTablesDBs) {
139345
- const remoteDB = remoteTablesDBs.find(
139346
- (db) => db.$id === localDB.$id
139347
- );
139611
+ const remoteDB = remoteTablesDBs.find((db) => db.$id === localDB.$id);
139348
139612
  if (!remoteDB) {
139349
139613
  toCreate.push(localDB);
139350
139614
  changes.push({
@@ -139411,7 +139675,7 @@ var checkAndApplyTablesDBChanges = async () => {
139411
139675
  needsResync = true;
139412
139676
  } catch (e) {
139413
139677
  error48(
139414
- `Failed to delete database ${db.name} ( ${db.$id} ): ${e.message}`
139678
+ `Failed to delete database ${db.name} ( ${db.$id} ): ${getSyncErrorMessage(e)}`
139415
139679
  );
139416
139680
  throw new Error(
139417
139681
  `Database sync failed during deletion of ${db.$id}. Some changes may have been applied.`
@@ -139426,7 +139690,7 @@ var checkAndApplyTablesDBChanges = async () => {
139426
139690
  success2(`Created ${db.name} ( ${db.$id} )`);
139427
139691
  } catch (e) {
139428
139692
  error48(
139429
- `Failed to create database ${db.name} ( ${db.$id} ): ${e.message}`
139693
+ `Failed to create database ${db.name} ( ${db.$id} ): ${getSyncErrorMessage(e)}`
139430
139694
  );
139431
139695
  throw new Error(
139432
139696
  `Database sync failed during creation of ${db.$id}. Some changes may have been applied.`
@@ -139441,7 +139705,7 @@ var checkAndApplyTablesDBChanges = async () => {
139441
139705
  success2(`Updated ${db.name} ( ${db.$id} )`);
139442
139706
  } catch (e) {
139443
139707
  error48(
139444
- `Failed to update database ${db.name} ( ${db.$id} ): ${e.message}`
139708
+ `Failed to update database ${db.name} ( ${db.$id} ): ${getSyncErrorMessage(e)}`
139445
139709
  );
139446
139710
  throw new Error(
139447
139711
  `Database sync failed during update of ${db.$id}. Some changes may have been applied.`
@@ -139675,7 +139939,7 @@ var Push = class {
139675
139939
  }
139676
139940
  if (settings.services) {
139677
139941
  this.log("Applying service statuses ...");
139678
- for (let [service, status] of Object.entries(settings.services)) {
139942
+ for (const [service, status] of Object.entries(settings.services)) {
139679
139943
  await projectsService.updateServiceStatus({
139680
139944
  projectId,
139681
139945
  service,
@@ -139721,7 +139985,7 @@ var Push = class {
139721
139985
  }
139722
139986
  if (settings.auth.methods) {
139723
139987
  this.log("Applying auth methods statuses ...");
139724
- for (let [method, status] of Object.entries(settings.auth.methods)) {
139988
+ for (const [method, status] of Object.entries(settings.auth.methods)) {
139725
139989
  await projectsService.updateAuthStatus({
139726
139990
  projectId,
139727
139991
  method,
@@ -140025,7 +140289,7 @@ var Push = class {
140025
140289
  ([key, value]) => ({ key, value })
140026
140290
  );
140027
140291
  }
140028
- } catch (error49) {
140292
+ } catch (_error) {
140029
140293
  envVariables = [];
140030
140294
  }
140031
140295
  await Promise.all(
@@ -140322,7 +140586,7 @@ var Push = class {
140322
140586
  ([key, value]) => ({ key, value })
140323
140587
  );
140324
140588
  }
140325
- } catch (error49) {
140589
+ } catch (_error) {
140326
140590
  envVariables = [];
140327
140591
  }
140328
140592
  await Promise.all(
@@ -140489,7 +140753,7 @@ var Push = class {
140489
140753
  skipConfirmation,
140490
140754
  this.projectClient
140491
140755
  );
140492
- let tablesChanged = /* @__PURE__ */ new Set();
140756
+ const tablesChanged = /* @__PURE__ */ new Set();
140493
140757
  const errors = [];
140494
140758
  await Promise.all(
140495
140759
  tables.map(async (table) => {
@@ -140543,7 +140807,7 @@ var Push = class {
140543
140807
  }
140544
140808
  })
140545
140809
  );
140546
- for (let table of tables) {
140810
+ for (const table of tables) {
140547
140811
  let columns = table.columns;
140548
140812
  let indexes = table.indexes;
140549
140813
  let hadChanges = false;
@@ -140822,7 +141086,7 @@ var pushSettings = async () => {
140822
141086
  checkDeployConditions(localConfig);
140823
141087
  try {
140824
141088
  const projectsService = await getProjectsService();
140825
- let response = await projectsService.get(
141089
+ const response = await projectsService.get(
140826
141090
  localConfig.getProject().projectId
140827
141091
  );
140828
141092
  const remoteSettings = createSettingsObject(response);
@@ -140855,7 +141119,7 @@ var pushSettings = async () => {
140855
141119
  return;
140856
141120
  }
140857
141121
  }
140858
- } catch (e) {
141122
+ } catch (_e) {
140859
141123
  }
140860
141124
  try {
140861
141125
  log("Pushing project settings ...");
@@ -140905,7 +141169,7 @@ var pushSite = async ({
140905
141169
  );
140906
141170
  return;
140907
141171
  }
140908
- let sites2 = siteIds.map((id) => {
141172
+ const sites2 = siteIds.map((id) => {
140909
141173
  const sites3 = localConfig.getSites();
140910
141174
  const site = sites3.find((s) => s.$id === id);
140911
141175
  if (!site) {
@@ -140914,7 +141178,7 @@ var pushSite = async ({
140914
141178
  return site;
140915
141179
  });
140916
141180
  log("Validating sites ...");
140917
- for (let site of sites2) {
141181
+ for (const site of sites2) {
140918
141182
  if (!site.buildCommand) {
140919
141183
  log(`Site ${site.name} is missing build command.`);
140920
141184
  const answers = await import_inquirer7.default.prompt(questionsGetEntrypoint);
@@ -141025,7 +141289,7 @@ var pushFunction = async ({
141025
141289
  );
141026
141290
  return;
141027
141291
  }
141028
- let functions2 = functionIds.map((id) => {
141292
+ const functions2 = functionIds.map((id) => {
141029
141293
  const functions3 = localConfig.getFunctions();
141030
141294
  const func = functions3.find((f) => f.$id === id);
141031
141295
  if (!func) {
@@ -141034,7 +141298,7 @@ var pushFunction = async ({
141034
141298
  return func;
141035
141299
  });
141036
141300
  log("Validating functions ...");
141037
- for (let func of functions2) {
141301
+ for (const func of functions2) {
141038
141302
  if (!func.entrypoint) {
141039
141303
  log(`Function ${func.name} is missing an entrypoint.`);
141040
141304
  const answers = await import_inquirer7.default.prompt(questionsGetEntrypoint);
@@ -141175,7 +141439,7 @@ var pushTable = async ({
141175
141439
  });
141176
141440
  }
141177
141441
  }
141178
- } catch (e) {
141442
+ } catch (_e) {
141179
141443
  }
141180
141444
  }
141181
141445
  if (tablesToDelete.length > 0) {
@@ -141322,7 +141586,7 @@ var pushCollection = async () => {
141322
141586
  }
141323
141587
  };
141324
141588
  var pushBucket = async () => {
141325
- let bucketIds = [];
141589
+ const bucketIds = [];
141326
141590
  const configBuckets = localConfig.getBuckets();
141327
141591
  if (cliConfig.all) {
141328
141592
  checkDeployConditions(localConfig);
@@ -141341,7 +141605,7 @@ var pushBucket = async () => {
141341
141605
  );
141342
141606
  return;
141343
141607
  }
141344
- let buckets = [];
141608
+ const buckets = [];
141345
141609
  for (const bucketId of bucketIds) {
141346
141610
  const idBuckets = configBuckets.filter((b) => b.$id === bucketId);
141347
141611
  buckets.push(...idBuckets);
@@ -141372,7 +141636,7 @@ var pushBucket = async () => {
141372
141636
  }
141373
141637
  };
141374
141638
  var pushTeam = async () => {
141375
- let teamIds = [];
141639
+ const teamIds = [];
141376
141640
  const configTeams = localConfig.getTeams();
141377
141641
  if (cliConfig.all) {
141378
141642
  checkDeployConditions(localConfig);
@@ -141391,7 +141655,7 @@ var pushTeam = async () => {
141391
141655
  );
141392
141656
  return;
141393
141657
  }
141394
- let teams2 = [];
141658
+ const teams2 = [];
141395
141659
  for (const teamId of teamIds) {
141396
141660
  const idTeams = configTeams.filter((t) => t.$id === teamId);
141397
141661
  teams2.push(...idTeams);
@@ -141422,7 +141686,7 @@ var pushTeam = async () => {
141422
141686
  }
141423
141687
  };
141424
141688
  var pushMessagingTopic = async () => {
141425
- let topicsIds = [];
141689
+ const topicsIds = [];
141426
141690
  const configTopics = localConfig.getMessagingTopics();
141427
141691
  if (cliConfig.all) {
141428
141692
  checkDeployConditions(localConfig);
@@ -141441,7 +141705,7 @@ var pushMessagingTopic = async () => {
141441
141705
  );
141442
141706
  return;
141443
141707
  }
141444
- let topics = [];
141708
+ const topics = [];
141445
141709
  for (const topicId of topicsIds) {
141446
141710
  const idTopic = configTopics.filter((b) => b.$id === topicId);
141447
141711
  topics.push(...idTopic);
@@ -141517,7 +141781,7 @@ var isInstalledViaNpm = () => {
141517
141781
  return true;
141518
141782
  }
141519
141783
  return false;
141520
- } catch (e) {
141784
+ } catch (_e) {
141521
141785
  return false;
141522
141786
  }
141523
141787
  };
@@ -141525,7 +141789,7 @@ var isInstalledViaHomebrew = () => {
141525
141789
  try {
141526
141790
  const scriptPath = process.argv[1];
141527
141791
  return scriptPath.includes("/opt/homebrew/") || scriptPath.includes("/usr/local/Cellar/");
141528
- } catch (e) {
141792
+ } catch (_e) {
141529
141793
  return false;
141530
141794
  }
141531
141795
  };
@@ -141555,13 +141819,14 @@ var updateViaNpm = async () => {
141555
141819
  success2("Updated to latest version via npm!");
141556
141820
  hint("Run 'appwrite --version' to verify the new version.");
141557
141821
  } catch (e) {
141558
- if (e.message.includes("EEXIST") || e.message.includes("file already exists")) {
141822
+ const message = getErrorMessage(e);
141823
+ if (message.includes("EEXIST") || message.includes("file already exists")) {
141559
141824
  console.log("");
141560
141825
  success2("Latest version is already installed via npm!");
141561
141826
  hint("The CLI is up to date. Run 'appwrite --version' to verify.");
141562
141827
  } else {
141563
141828
  console.log("");
141564
- error48(`Failed to update via npm: ${e.message}`);
141829
+ error48(`Failed to update via npm: ${message}`);
141565
141830
  hint(`Try running: npm install -g ${NPM_PACKAGE_NAME}@latest --force`);
141566
141831
  }
141567
141832
  }
@@ -141573,13 +141838,14 @@ var updateViaHomebrew = async () => {
141573
141838
  success2("Updated to latest version via Homebrew!");
141574
141839
  hint("Run 'appwrite --version' to verify the new version.");
141575
141840
  } catch (e) {
141576
- if (e.message.includes("already installed") || e.message.includes("up-to-date")) {
141841
+ const message = getErrorMessage(e);
141842
+ if (message.includes("already installed") || message.includes("up-to-date")) {
141577
141843
  console.log("");
141578
141844
  success2("Latest version is already installed via Homebrew!");
141579
141845
  hint("The CLI is up to date. Run 'appwrite --version' to verify.");
141580
141846
  } else {
141581
141847
  console.log("");
141582
- error48(`Failed to update via Homebrew: ${e.message}`);
141848
+ error48(`Failed to update via Homebrew: ${message}`);
141583
141849
  hint("Try running: brew upgrade appwrite");
141584
141850
  }
141585
141851
  }
@@ -141654,8 +141920,9 @@ var updateCli = async ({ manual } = {}) => {
141654
141920
  await chooseUpdateMethod(latestVersion);
141655
141921
  }
141656
141922
  } catch (e) {
141923
+ const message = getErrorMessage(e);
141657
141924
  console.log("");
141658
- error48(`Failed to check for updates: ${e.message}`);
141925
+ error48(`Failed to check for updates: ${message}`);
141659
141926
  hint(`You can manually check for updates at: ${GITHUB_RELEASES_URL}`);
141660
141927
  }
141661
141928
  };
@@ -141828,7 +142095,7 @@ var BaseDatabasesGenerator = class {
141828
142095
  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";
141829
142096
 
141830
142097
  // lib/commands/generators/typescript/templates/databases.ts.hbs
141831
- 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';
142098
+ 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';
141832
142099
 
141833
142100
  // lib/commands/generators/typescript/templates/index.ts.hbs
141834
142101
  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';
@@ -141995,7 +142262,7 @@ ${dbReturnTypes}
141995
142262
 
141996
142263
  export type DatabaseHandle<D extends DatabaseId> = {
141997
142264
  use: <T extends keyof DatabaseTableMap[D] & string>(tableId: T) => DatabaseTableMap[D][T];
141998
- ${supportsServerSide ? ` create: (tableId: string, name: string, options?: { permissions?: ${PERMISSION_CALLBACK_INLINE}; rowSecurity?: boolean; enabled?: boolean; columns?: any[]; indexes?: any[] }) => Promise<Models.Table>;
142265
+ ${supportsServerSide ? ` create: (tableId: string, name: string, options?: { permissions?: ${PERMISSION_CALLBACK_INLINE}; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; indexes?: object[] }) => Promise<Models.Table>;
141999
142266
  update: <T extends keyof DatabaseTableMap[D] & string>(tableId: T, options?: { name?: string; permissions?: ${PERMISSION_CALLBACK_INLINE}; rowSecurity?: boolean; enabled?: boolean }) => Promise<Models.Table>;
142000
142267
  delete: <T extends keyof DatabaseTableMap[D] & string>(tableId: T) => Promise<void>;` : ""}
142001
142268
  };
@@ -142007,12 +142274,11 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
142007
142274
  delete: <D extends DatabaseId>(databaseId: D) => Promise<void>;` : ""}
142008
142275
  };`;
142009
142276
  }
142010
- generateTypesFile(config2) {
142277
+ generateTypesFile(config2, appwriteDep) {
142011
142278
  const entities = config2.tables?.length ? config2.tables : config2.collections;
142012
142279
  if (!entities || entities.length === 0) {
142013
142280
  return "// No tables or collections found in configuration\n";
142014
142281
  }
142015
- const appwriteDep = getAppwriteDependency();
142016
142282
  const enums = this.generateEnums(entities);
142017
142283
  const types2 = entities.map((entity) => this.generateTableType(entity, entities)).join("\n\n");
142018
142284
  const entitiesByDb = this.groupEntitiesByDb(entities);
@@ -142062,26 +142328,26 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
142062
142328
  generateBulkMethods(supportsBulk) {
142063
142329
  if (!supportsBulk) return "";
142064
142330
  return `
142065
- createMany: (rows: any[], options?: { transactionId?: string }) =>
142331
+ createMany: (rows: object[], options?: { transactionId?: string }) =>
142066
142332
  tablesDB.createRows({
142067
142333
  databaseId,
142068
142334
  tableId,
142069
142335
  rows,
142070
142336
  transactionId: options?.transactionId,
142071
142337
  }),
142072
- updateMany: (data: any, options?: { queries?: (q: any) => string[]; transactionId?: string }) =>
142338
+ updateMany: (data: object, options?: { queries?: (q: QueryBuilder<T>) => string[]; transactionId?: string }) =>
142073
142339
  tablesDB.updateRows({
142074
142340
  databaseId,
142075
142341
  tableId,
142076
142342
  data,
142077
- queries: options?.queries?.(createQueryBuilder()),
142343
+ queries: options?.queries?.(createQueryBuilder<T>()),
142078
142344
  transactionId: options?.transactionId,
142079
142345
  }),
142080
- deleteMany: (options?: { queries?: (q: any) => string[]; transactionId?: string }) =>
142346
+ deleteMany: (options?: { queries?: (q: QueryBuilder<T>) => string[]; transactionId?: string }) =>
142081
142347
  tablesDB.deleteRows({
142082
142348
  databaseId,
142083
142349
  tableId,
142084
- queries: options?.queries?.(createQueryBuilder()),
142350
+ queries: options?.queries?.(createQueryBuilder<T>()),
142085
142351
  transactionId: options?.transactionId,
142086
142352
  }),`;
142087
142353
  }
@@ -142095,18 +142361,17 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
142095
142361
  return `
142096
142362
  // Remove bulk methods for tables with relationships
142097
142363
  if (!hasBulkMethods(databaseId, tableId)) {
142098
- delete (api as any).createMany;
142099
- delete (api as any).updateMany;
142100
- delete (api as any).deleteMany;
142364
+ delete (api as Record<string, unknown>).createMany;
142365
+ delete (api as Record<string, unknown>).updateMany;
142366
+ delete (api as Record<string, unknown>).deleteMany;
142101
142367
  }`;
142102
142368
  }
142103
- generateDatabasesFile(config2, importExt) {
142369
+ generateDatabasesFile(config2, importExt, appwriteDep) {
142104
142370
  const entities = config2.tables?.length ? config2.tables : config2.collections;
142105
142371
  if (!entities || entities.length === 0) {
142106
142372
  return "// No tables or collections found in configuration\n";
142107
142373
  }
142108
142374
  const entitiesByDb = this.groupEntitiesByDb(entities);
142109
- const appwriteDep = getAppwriteDependency();
142110
142375
  const supportsServerSide = supportsServerSideMethods(
142111
142376
  appwriteDep,
142112
142377
  this.serverSideOverride
@@ -142129,8 +142394,7 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
142129
142394
  importExt
142130
142395
  });
142131
142396
  }
142132
- generateConstantsFile(config2) {
142133
- const appwriteDep = getAppwriteDependency();
142397
+ generateConstantsFile(config2, appwriteDep) {
142134
142398
  const supportsServerSide = supportsServerSideMethods(
142135
142399
  appwriteDep,
142136
142400
  this.serverSideOverride
@@ -142142,11 +142406,12 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
142142
142406
  requiresApiKey: supportsServerSide
142143
142407
  });
142144
142408
  }
142145
- async generate(config2) {
142409
+ async generate(config2, options) {
142146
142410
  if (!config2.projectId) {
142147
142411
  throw new Error("Project ID is required in configuration");
142148
142412
  }
142149
- const importExt = detectImportExtension();
142413
+ const appwriteDep = options?.appwriteImportSource ?? getAppwriteDependency();
142414
+ const importExt = options?.importExtension ?? detectImportExtension();
142150
142415
  const hasEntities = config2.tables && config2.tables.length > 0 || config2.collections && config2.collections.length > 0;
142151
142416
  if (!hasEntities) {
142152
142417
  console.log(
@@ -142156,14 +142421,14 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
142156
142421
  dbContent: "// No tables or collections found in configuration\n",
142157
142422
  typesContent: "// No tables or collections found in configuration\n",
142158
142423
  indexContent: this.generateIndexFile(importExt),
142159
- constantsContent: this.generateConstantsFile(config2)
142424
+ constantsContent: this.generateConstantsFile(config2, appwriteDep)
142160
142425
  };
142161
142426
  }
142162
142427
  return {
142163
- dbContent: this.generateDatabasesFile(config2, importExt),
142164
- typesContent: this.generateTypesFile(config2),
142428
+ dbContent: this.generateDatabasesFile(config2, importExt, appwriteDep),
142429
+ typesContent: this.generateTypesFile(config2, appwriteDep),
142165
142430
  indexContent: this.generateIndexFile(importExt),
142166
- constantsContent: this.generateConstantsFile(config2)
142431
+ constantsContent: this.generateConstantsFile(config2, appwriteDep)
142167
142432
  };
142168
142433
  }
142169
142434
  };
@@ -142244,8 +142509,9 @@ var generateAction = async (options) => {
142244
142509
  }
142245
142510
  } catch (err) {
142246
142511
  const supported = getSupportedLanguages().join(", ");
142512
+ const message = err instanceof Error ? err.message : String(err);
142247
142513
  error48(
142248
- `${err.message}
142514
+ `${message}
142249
142515
  Use --language to specify the target language. Supported: ${supported}`
142250
142516
  );
142251
142517
  process.exit(1);
@@ -142269,7 +142535,10 @@ Use --language to specify the target language. Supported: ${supported}`
142269
142535
  `Generating type-safe ${detectedLanguage} SDK to ${absoluteOutputDir}...`
142270
142536
  );
142271
142537
  try {
142272
- const result = await generator.generate(config2);
142538
+ const result = await generator.generate(config2, {
142539
+ appwriteImportSource: options.appwriteImportSource,
142540
+ importExtension: options.importExtension
142541
+ });
142273
142542
  await generator.writeFiles(absoluteOutputDir, result);
142274
142543
  const generatedFiles = generator.getGeneratedFilePaths(result);
142275
142544
  success2(`Generated files:`);
@@ -142281,7 +142550,7 @@ Use --language to specify the target language. Supported: ${supported}`
142281
142550
  const firstEntity = entities?.[0];
142282
142551
  const dbId = firstEntity?.databaseId ?? "databaseId";
142283
142552
  const tableName = firstEntity?.name ?? "tableName";
142284
- const importExt = detectImportExtension();
142553
+ const importExt = options.importExtension ?? detectImportExtension();
142285
142554
  console.log("");
142286
142555
  log(`Import the generated SDK in your project:`);
142287
142556
  console.log(
@@ -142300,7 +142569,8 @@ Use --language to specify the target language. Supported: ${supported}`
142300
142569
  );
142301
142570
  }
142302
142571
  } catch (err) {
142303
- error48(`Failed to generate SDK: ${err.message}`);
142572
+ const message = err instanceof Error ? err.message : String(err);
142573
+ error48(`Failed to generate SDK: ${message}`);
142304
142574
  process.exit(1);
142305
142575
  }
142306
142576
  };
@@ -142317,6 +142587,12 @@ var generate = new Command("generate").description(
142317
142587
  "--server <mode>",
142318
142588
  "Override server-side generation (auto|true|false)",
142319
142589
  "auto"
142590
+ ).option(
142591
+ "--appwrite-import-source <source>",
142592
+ "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."
142593
+ ).option(
142594
+ "--import-extension <ext>",
142595
+ 'Override import file extension in generated files (.js for ESM, empty string for CJS). Auto-detected from package.json "type" field if not provided.'
142320
142596
  ).addHelpText(
142321
142597
  "after",
142322
142598
  `
@@ -142420,7 +142696,7 @@ account.command(`create-jwt`).description(`Use this endpoint to create a JSON We
142420
142696
  async ({ duration: duration3 }) => parse3(await (await getAccountClient()).createJWT(duration3))
142421
142697
  )
142422
142698
  );
142423
- account.command(`list-keys`).description(`Get a list of all API keys from the current account. `).option(
142699
+ account.command(`list-keys`).description(`Get a list of all API keys from the current account.`).option(
142424
142700
  `--total [value]`,
142425
142701
  `When set to false, the total count returned will be 0 and will not be calculated.`,
142426
142702
  (value) => value === void 0 ? true : parseBool(value)
@@ -142998,7 +143274,7 @@ databases.command(`list-attributes`).description(`List attributes in the collect
142998
143274
  )
142999
143275
  );
143000
143276
  databases.command(`create-boolean-attribute`).description(`Create a boolean attribute.
143001
- `).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(
143277
+ `).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(
143002
143278
  `--xdefault [value]`,
143003
143279
  `Default value for attribute when not provided. Cannot be set when attribute is required.`,
143004
143280
  (value) => value === void 0 ? true : parseBool(value)
@@ -143190,6 +143466,12 @@ databases.command(`create-relationship-attribute`).description(`Create relations
143190
143466
  async ({ databaseId, collectionId, relatedCollectionId, type, twoWay, key, twoWayKey, onDelete }) => parse3(await (await getDatabasesClient()).createRelationshipAttribute(databaseId, collectionId, relatedCollectionId, type, twoWay, key, twoWayKey, onDelete))
143191
143467
  )
143192
143468
  );
143469
+ databases.command(`update-relationship-attribute`).description(`Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes).
143470
+ `).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(
143471
+ actionRunner(
143472
+ async ({ databaseId, collectionId, key, onDelete, newKey }) => parse3(await (await getDatabasesClient()).updateRelationshipAttribute(databaseId, collectionId, key, onDelete, newKey))
143473
+ )
143474
+ );
143193
143475
  databases.command(`create-string-attribute`).description(`Create a string attribute.
143194
143476
  `).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(
143195
143477
  `--array [value]`,
@@ -143276,19 +143558,13 @@ databases.command(`delete-attribute`).description(`Deletes an attribute.`).requi
143276
143558
  async ({ databaseId, collectionId, key }) => parse3(await (await getDatabasesClient()).deleteAttribute(databaseId, collectionId, key))
143277
143559
  )
143278
143560
  );
143279
- databases.command(`update-relationship-attribute`).description(`Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes).
143280
- `).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(
143281
- actionRunner(
143282
- async ({ databaseId, collectionId, key, onDelete, newKey }) => parse3(await (await getDatabasesClient()).updateRelationshipAttribute(databaseId, collectionId, key, onDelete, newKey))
143283
- )
143284
- );
143285
143561
  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(
143286
143562
  `--total [value]`,
143287
143563
  `When set to false, the total count returned will be 0 and will not be calculated.`,
143288
143564
  (value) => value === void 0 ? true : parseBool(value)
143289
- ).action(
143565
+ ).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(
143290
143566
  actionRunner(
143291
- async ({ databaseId, collectionId, queries, transactionId, total }) => parse3(await (await getDatabasesClient()).listDocuments(databaseId, collectionId, queries, transactionId, total))
143567
+ async ({ databaseId, collectionId, queries, transactionId, total, ttl }) => parse3(await (await getDatabasesClient()).listDocuments(databaseId, collectionId, queries, transactionId, total, ttl))
143292
143568
  )
143293
143569
  );
143294
143570
  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(
@@ -143691,6 +143967,12 @@ health.command(`get-certificate`).description(`Get the SSL certificate for a dom
143691
143967
  async ({ domain: domain2 }) => parse3(await (await getHealthClient()).getCertificate(domain2))
143692
143968
  )
143693
143969
  );
143970
+ 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.
143971
+ `).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(
143972
+ actionRunner(
143973
+ async ({ threshold, inactivityDays }) => parse3(await (await getHealthClient()).getConsolePausing(threshold, inactivityDays))
143974
+ )
143975
+ );
143694
143976
  health.command(`get-db`).description(`Check the Appwrite database servers are up and connection is successful.`).action(
143695
143977
  actionRunner(
143696
143978
  async () => parse3(await (await getHealthClient()).getDB())
@@ -144299,7 +144581,7 @@ messaging.command(`list-topic-logs`).description(`Get the topic activity logs li
144299
144581
  async ({ topicId, queries, total }) => parse3(await (await getMessagingClient()).listTopicLogs(topicId, queries, total))
144300
144582
  )
144301
144583
  );
144302
- 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(
144584
+ 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(
144303
144585
  `--total [value]`,
144304
144586
  `When set to false, the total count returned will be 0 and will not be calculated.`,
144305
144587
  (value) => value === void 0 ? true : parseBool(value)
@@ -144581,6 +144863,12 @@ projects.command(`update-auth-status`).description(`Update the status of a speci
144581
144863
  async ({ projectId, method, status }) => parse3(await (await getProjectsClient()).updateAuthStatus(projectId, method, status))
144582
144864
  )
144583
144865
  );
144866
+ 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.
144867
+ `).requiredOption(`--project-id <project-id>`, `Project ID`).action(
144868
+ actionRunner(
144869
+ async ({ projectId }) => parse3(await (await getProjectsClient()).updateConsoleAccess(projectId))
144870
+ )
144871
+ );
144584
144872
  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(
144585
144873
  actionRunner(
144586
144874
  async ({ projectId, queries }) => parse3(await (await getProjectsClient()).listDevKeys(projectId, queries))
@@ -144726,6 +145014,12 @@ projects.command(`create-smtp-test`).description(`Send a test email to verify SM
144726
145014
  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))
144727
145015
  )
144728
145016
  );
145017
+ 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.
145018
+ `).requiredOption(`--project-id <project-id>`, `Project ID`).requiredOption(`--status <status>`, `New status for the project`).action(
145019
+ actionRunner(
145020
+ async ({ projectId, status }) => parse3(await (await getProjectsClient()).updateStatus(projectId, status))
145021
+ )
145022
+ );
144729
145023
  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(
144730
145024
  actionRunner(
144731
145025
  async ({ projectId, teamId }) => parse3(await (await getProjectsClient()).updateTeam(projectId, teamId))
@@ -144966,9 +145260,13 @@ sites.command(`list-deployments`).description(`Get a list of all the site's code
144966
145260
  async ({ siteId, queries, search, total }) => parse3(await (await getSitesClient()).listDeployments(siteId, queries, search, total))
144967
145261
  )
144968
145262
  );
144969
- 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(
145263
+ 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(
145264
+ `--activate [value]`,
145265
+ `Automatically activate the deployment when it is finished building.`,
145266
+ (value) => value === void 0 ? true : parseBool(value)
145267
+ ).action(
144970
145268
  actionRunner(
144971
- async ({ siteId, code, activate, installCommand, buildCommand, outputDirectory }) => parse3(await (await getSitesClient()).createDeployment(siteId, code, activate, installCommand, buildCommand, outputDirectory))
145269
+ async ({ siteId, code, installCommand, buildCommand, outputDirectory, activate }) => parse3(await (await getSitesClient()).createDeployment(siteId, code, installCommand, buildCommand, outputDirectory, activate))
144972
145270
  )
144973
145271
  );
144974
145272
  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(
@@ -145711,9 +146009,9 @@ tablesDB.command(`list-rows`).description(`Get a list of all the user's rows in
145711
146009
  `--total [value]`,
145712
146010
  `When set to false, the total count returned will be 0 and will not be calculated.`,
145713
146011
  (value) => value === void 0 ? true : parseBool(value)
145714
- ).action(
146012
+ ).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(
145715
146013
  actionRunner(
145716
- async ({ databaseId, tableId, queries, transactionId, total }) => parse3(await (await getTablesDBClient()).listRows(databaseId, tableId, queries, transactionId, total))
146014
+ async ({ databaseId, tableId, queries, transactionId, total, ttl }) => parse3(await (await getTablesDBClient()).listRows(databaseId, tableId, queries, transactionId, total, ttl))
145717
146015
  )
145718
146016
  );
145719
146017
  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(
@@ -145854,7 +146152,7 @@ You only need to provide one of a user ID, email, or phone number. Appwrite will
145854
146152
  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.
145855
146153
 
145856
146154
  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.
145857
- `).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(
146155
+ `).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(
145858
146156
  actionRunner(
145859
146157
  async ({ teamId, roles, email: email3, userId, phone, url: url2, name }) => parse3(await (await getTeamsClient()).createMembership(teamId, roles, email3, userId, phone, url2, name))
145860
146158
  )
@@ -145865,7 +146163,7 @@ teams.command(`get-membership`).description(`Get a team member by the membership
145865
146163
  )
145866
146164
  );
145867
146165
  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).
145868
- `).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(
146166
+ `).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(
145869
146167
  actionRunner(
145870
146168
  async ({ teamId, membershipId, roles }) => parse3(await (await getTeamsClient()).updateMembership(teamId, membershipId, roles))
145871
146169
  )
@@ -146288,12 +146586,12 @@ async function checkVersion() {
146288
146586
  } else {
146289
146587
  process.stdout.write(import_chalk13.default.blue("\n\u{1F680} You are running a pre-release or development version.") + "\n");
146290
146588
  }
146291
- } catch (error49) {
146589
+ } catch (_error) {
146292
146590
  process.stdout.write(import_chalk13.default.gray("\n(Unable to check for updates)") + "\n");
146293
146591
  }
146294
146592
  }
146295
146593
  if (process.argv.includes("-v") || process.argv.includes("--version")) {
146296
- (async () => {
146594
+ void (async () => {
146297
146595
  await checkVersion();
146298
146596
  process.exit(0);
146299
146597
  })();