appwrite-cli 13.5.0 → 13.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +2 -2
  3. package/cli.ts +7 -5
  4. package/dist/bundle-win-arm64.mjs +988 -258
  5. package/dist/cli.cjs +988 -258
  6. package/dist/index.cjs +183 -112
  7. package/dist/index.js +183 -112
  8. package/dist/lib/commands/config-validations.d.ts +1 -1
  9. package/dist/lib/commands/config-validations.d.ts.map +1 -1
  10. package/dist/lib/commands/errors.d.ts +4 -4
  11. package/dist/lib/commands/errors.d.ts.map +1 -1
  12. package/dist/lib/commands/generate.d.ts.map +1 -1
  13. package/dist/lib/commands/generators/base.d.ts +5 -0
  14. package/dist/lib/commands/generators/base.d.ts.map +1 -1
  15. package/dist/lib/commands/generic.d.ts.map +1 -1
  16. package/dist/lib/commands/init.d.ts.map +1 -1
  17. package/dist/lib/commands/run.d.ts.map +1 -1
  18. package/dist/lib/commands/schema.d.ts.map +1 -1
  19. package/dist/lib/commands/services/activities.d.ts +3 -0
  20. package/dist/lib/commands/services/activities.d.ts.map +1 -0
  21. package/dist/lib/commands/services/backups.d.ts +3 -0
  22. package/dist/lib/commands/services/backups.d.ts.map +1 -0
  23. package/dist/lib/commands/types.d.ts.map +1 -1
  24. package/dist/lib/commands/update.d.ts.map +1 -1
  25. package/dist/lib/commands/utils/change-approval.d.ts +3 -3
  26. package/dist/lib/commands/utils/change-approval.d.ts.map +1 -1
  27. package/dist/lib/commands/utils/database-sync.d.ts.map +1 -1
  28. package/dist/lib/commands/utils/deployment.d.ts +16 -4
  29. package/dist/lib/commands/utils/deployment.d.ts.map +1 -1
  30. package/dist/lib/commands/utils/pools.d.ts.map +1 -1
  31. package/dist/lib/constants.d.ts +1 -1
  32. package/dist/lib/emulation/docker.d.ts.map +1 -1
  33. package/dist/lib/json.d.ts +1 -1
  34. package/dist/lib/json.d.ts.map +1 -1
  35. package/dist/lib/paginate.d.ts +5 -6
  36. package/dist/lib/paginate.d.ts.map +1 -1
  37. package/dist/lib/parser.d.ts +5 -4
  38. package/dist/lib/parser.d.ts.map +1 -1
  39. package/dist/lib/spinner.d.ts +1 -1
  40. package/dist/lib/spinner.d.ts.map +1 -1
  41. package/dist/lib/utils.d.ts +6 -1
  42. package/dist/lib/utils.d.ts.map +1 -1
  43. package/dist/lib/validations.d.ts +1 -1
  44. package/dist/lib/validations.d.ts.map +1 -1
  45. package/docs/examples/account/create-key.md +5 -0
  46. package/docs/examples/account/delete-key.md +4 -0
  47. package/docs/examples/account/get-key.md +4 -0
  48. package/docs/examples/account/list-keys.md +3 -0
  49. package/docs/examples/account/update-key.md +6 -0
  50. package/docs/examples/activities/get-event.md +4 -0
  51. package/docs/examples/activities/list-events.md +3 -0
  52. package/docs/examples/backups/create-archive.md +4 -0
  53. package/docs/examples/backups/create-policy.md +7 -0
  54. package/docs/examples/backups/create-restoration.md +5 -0
  55. package/docs/examples/backups/delete-archive.md +4 -0
  56. package/docs/examples/backups/delete-policy.md +4 -0
  57. package/docs/examples/backups/get-archive.md +4 -0
  58. package/docs/examples/backups/get-policy.md +4 -0
  59. package/docs/examples/backups/get-restoration.md +4 -0
  60. package/docs/examples/backups/list-archives.md +3 -0
  61. package/docs/examples/backups/list-policies.md +3 -0
  62. package/docs/examples/backups/list-restorations.md +3 -0
  63. package/docs/examples/backups/update-policy.md +4 -0
  64. package/eslint.config.js +45 -0
  65. package/install.ps1 +2 -2
  66. package/install.sh +1 -1
  67. package/lib/client.ts +3 -3
  68. package/lib/commands/config-validations.ts +1 -1
  69. package/lib/commands/config.ts +2 -2
  70. package/lib/commands/errors.ts +2 -2
  71. package/lib/commands/generate.ts +8 -6
  72. package/lib/commands/generators/base.ts +6 -0
  73. package/lib/commands/generators/typescript/databases.ts +9 -9
  74. package/lib/commands/generators/typescript/templates/databases.ts.hbs +16 -16
  75. package/lib/commands/generic.ts +21 -16
  76. package/lib/commands/init.ts +147 -61
  77. package/lib/commands/pull.ts +1 -1
  78. package/lib/commands/push.ts +19 -19
  79. package/lib/commands/run.ts +15 -9
  80. package/lib/commands/schema.ts +1 -3
  81. package/lib/commands/services/account.ts +234 -0
  82. package/lib/commands/services/activities.ts +51 -0
  83. package/lib/commands/services/backups.ts +184 -0
  84. package/lib/commands/services/health.ts +55 -0
  85. package/lib/commands/services/projects.ts +1 -1
  86. package/lib/commands/services/storage.ts +2 -2
  87. package/lib/commands/types.ts +18 -8
  88. package/lib/commands/update.ts +24 -16
  89. package/lib/commands/utils/attributes.ts +6 -6
  90. package/lib/commands/utils/change-approval.ts +26 -19
  91. package/lib/commands/utils/database-sync.ts +58 -18
  92. package/lib/commands/utils/deployment.ts +22 -5
  93. package/lib/commands/utils/pools.ts +11 -5
  94. package/lib/config.ts +1 -1
  95. package/lib/constants.ts +1 -1
  96. package/lib/emulation/docker.ts +5 -6
  97. package/lib/emulation/utils.ts +2 -2
  98. package/lib/json.ts +21 -8
  99. package/lib/paginate.ts +30 -20
  100. package/lib/parser.ts +46 -15
  101. package/lib/questions.ts +38 -38
  102. package/lib/spinner.ts +5 -1
  103. package/lib/utils.ts +15 -3
  104. package/lib/validations.ts +1 -1
  105. package/package.json +8 -2
  106. package/scoop/appwrite.config.json +3 -3
  107. package/dist/lib/commands/services/console.d.ts +0 -3
  108. package/dist/lib/commands/services/console.d.ts.map +0 -1
  109. package/docs/examples/console/get-resource.md +0 -5
  110. package/docs/examples/console/variables.md +0 -3
  111. package/lib/commands/services/console.ts +0 -49
package/dist/index.cjs CHANGED
@@ -1934,9 +1934,9 @@ var require_source = __commonJS({
1934
1934
  }
1935
1935
  });
1936
1936
 
1937
- // node_modules/escape-string-regexp/index.js
1937
+ // node_modules/figures/node_modules/escape-string-regexp/index.js
1938
1938
  var require_escape_string_regexp = __commonJS({
1939
- "node_modules/escape-string-regexp/index.js"(exports2, module2) {
1939
+ "node_modules/figures/node_modules/escape-string-regexp/index.js"(exports2, module2) {
1940
1940
  "use strict";
1941
1941
  var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
1942
1942
  module2.exports = function(str) {
@@ -19600,6 +19600,7 @@ var require_safe_buffer = __commonJS({
19600
19600
  function SafeBuffer(arg, encodingOrOffset, length) {
19601
19601
  return Buffer2(arg, encodingOrOffset, length);
19602
19602
  }
19603
+ SafeBuffer.prototype = Object.create(Buffer2.prototype);
19603
19604
  copyProps(Buffer2, SafeBuffer);
19604
19605
  SafeBuffer.from = function(arg, encodingOrOffset, length) {
19605
19606
  if (typeof arg === "number") {
@@ -69376,7 +69377,7 @@ var id_default = ID;
69376
69377
  // lib/constants.ts
69377
69378
  var SDK_TITLE = "Appwrite";
69378
69379
  var SDK_TITLE_LOWER = "appwrite";
69379
- var SDK_VERSION = "13.5.0";
69380
+ var SDK_VERSION = "13.6.1";
69380
69381
  var SDK_LOGO = "\n _ _ _ ___ __ _____\n /_\\ _ __ _ ____ ___ __(_) |_ ___ / __\\ / / \\_ \\\n //_\\\\| '_ \\| '_ \\ \\ /\\ / / '__| | __/ _ \\ / / / / / /\\/\n / _ \\ |_) | |_) \\ V V /| | | | || __/ / /___/ /___/\\/ /_\n \\_/ \\_/ .__/| .__/ \\_/\\_/ |_| |_|\\__\\___| \\____/\\____/\\____/\n |_| |_|\n\n";
69381
69382
  var EXECUTABLE_NAME = "appwrite";
69382
69383
  var NPM_PACKAGE_NAME = "appwrite-cli";
@@ -83284,7 +83285,7 @@ var int64Schema = external_exports.preprocess(
83284
83285
  const valueOfResult = val.valueOf();
83285
83286
  const bigIntVal = BigInt(valueOfResult);
83286
83287
  return bigIntVal;
83287
- } catch (e) {
83288
+ } catch (_e) {
83288
83289
  return void 0;
83289
83290
  }
83290
83291
  }
@@ -83294,7 +83295,7 @@ var int64Schema = external_exports.preprocess(
83294
83295
  if (typeof val === "string") {
83295
83296
  try {
83296
83297
  return BigInt(val);
83297
- } catch (e) {
83298
+ } catch (_e) {
83298
83299
  return void 0;
83299
83300
  }
83300
83301
  }
@@ -83608,7 +83609,7 @@ var createSettingsObject = (project) => {
83608
83609
  };
83609
83610
  };
83610
83611
  var checkDeployConditions = (localConfig2) => {
83611
- if (Object.keys(localConfig2.data).length === 0) {
83612
+ if (localConfig2.keys().length === 0) {
83612
83613
  throw new Error(
83613
83614
  "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."
83614
83615
  );
@@ -83644,6 +83645,8 @@ var JSONbigParser = (0, import_json_bigint.default)({ storeAsString: false });
83644
83645
  var JSONbigSerializer = (0, import_json_bigint.default)({ useNativeBigInt: true });
83645
83646
  var MAX_SAFE = BigInt(Number.MAX_SAFE_INTEGER);
83646
83647
  var MIN_SAFE = BigInt(Number.MIN_SAFE_INTEGER);
83648
+ var MAX_INT64 = BigInt("9223372036854775807");
83649
+ var MIN_INT64 = BigInt("-9223372036854775808");
83647
83650
  function isBigNumber(value) {
83648
83651
  return value !== null && typeof value === "object" && value._isBigNumber === true && typeof value.isInteger === "function" && typeof value.toFixed === "function" && typeof value.toNumber === "function";
83649
83652
  }
@@ -83655,7 +83658,10 @@ function reviver(_key, value) {
83655
83658
  if (bi >= MIN_SAFE && bi <= MAX_SAFE) {
83656
83659
  return Number(str);
83657
83660
  }
83658
- return bi;
83661
+ if (bi >= MIN_INT64 && bi <= MAX_INT64) {
83662
+ return bi;
83663
+ }
83664
+ return value.toNumber();
83659
83665
  }
83660
83666
  return value.toNumber();
83661
83667
  }
@@ -83751,7 +83757,7 @@ var Config = class {
83751
83757
  try {
83752
83758
  const file2 = import_fs.default.readFileSync(this.path).toString();
83753
83759
  this.data = JSONBig.parse(file2);
83754
- } catch (e) {
83760
+ } catch (_e) {
83755
83761
  this.data = {};
83756
83762
  }
83757
83763
  }
@@ -84662,7 +84668,7 @@ var Spinner = class _Spinner {
84662
84668
  static stop() {
84663
84669
  _Spinner.updatesBar.stop();
84664
84670
  }
84665
- static formatter(options, params, payload) {
84671
+ static formatter(_options, _params, payload) {
84666
84672
  const status = payload.status.padEnd(12);
84667
84673
  const middle = `${payload.resource} (${payload.id})`.padEnd(40);
84668
84674
  let prefix = import_chalk.default.cyan(payload.prefix ?? "\u29D7");
@@ -84733,19 +84739,22 @@ async function paginate(action, args = {}, limit = 100, wrapper = "", queries =
84733
84739
  ]
84734
84740
  });
84735
84741
  if (wrapper === "") {
84736
- if (response.length === 0) {
84742
+ const listResponse = response;
84743
+ if (listResponse.length === 0) {
84737
84744
  break;
84738
84745
  }
84739
- results = results.concat(response);
84746
+ results = results.concat(listResponse);
84740
84747
  } else {
84741
- if (response[wrapper].length === 0) {
84748
+ const wrappedResponse = response;
84749
+ const wrappedResults = wrappedResponse[wrapper] ?? [];
84750
+ if (wrappedResults.length === 0) {
84751
+ break;
84752
+ }
84753
+ results = results.concat(wrappedResults);
84754
+ total = wrappedResponse.total;
84755
+ if (results.length >= total) {
84742
84756
  break;
84743
84757
  }
84744
- results = results.concat(response[wrapper]);
84745
- }
84746
- total = response.total;
84747
- if (results.length >= total) {
84748
- break;
84749
84758
  }
84750
84759
  pageNumber++;
84751
84760
  }
@@ -84854,6 +84863,8 @@ Query.cursorBefore = (documentId) => new Query("cursorBefore", void 0, documentI
84854
84863
  Query.limit = (limit) => new Query("limit", void 0, limit).toString();
84855
84864
  Query.offset = (offset) => new Query("offset", void 0, offset).toString();
84856
84865
  Query.contains = (attribute, value) => new Query("contains", attribute, value).toString();
84866
+ Query.containsAny = (attribute, value) => new Query("containsAny", attribute, value).toString();
84867
+ Query.containsAll = (attribute, value) => new Query("containsAll", attribute, value).toString();
84857
84868
  Query.notContains = (attribute, value) => new Query("notContains", attribute, value).toString();
84858
84869
  Query.notSearch = (attribute, value) => new Query("notSearch", attribute, value).toString();
84859
84870
  Query.notBetween = (attribute, start, end) => new Query("notBetween", attribute, [start, end]).toString();
@@ -84884,6 +84895,8 @@ var JSONbigParser2 = (0, import_json_bigint2.default)({ storeAsString: false });
84884
84895
  var JSONbigSerializer2 = (0, import_json_bigint2.default)({ useNativeBigInt: true });
84885
84896
  var MAX_SAFE2 = BigInt(Number.MAX_SAFE_INTEGER);
84886
84897
  var MIN_SAFE2 = BigInt(Number.MIN_SAFE_INTEGER);
84898
+ var MAX_INT642 = BigInt("9223372036854775807");
84899
+ var MIN_INT642 = BigInt("-9223372036854775808");
84887
84900
  function isBigNumber2(value) {
84888
84901
  return value !== null && typeof value === "object" && value._isBigNumber === true && typeof value.isInteger === "function" && typeof value.toFixed === "function" && typeof value.toNumber === "function";
84889
84902
  }
@@ -84895,7 +84908,10 @@ function reviver2(_key, value) {
84895
84908
  if (bi >= MIN_SAFE2 && bi <= MAX_SAFE2) {
84896
84909
  return Number(str);
84897
84910
  }
84898
- return bi;
84911
+ if (bi >= MIN_INT642 && bi <= MAX_INT642) {
84912
+ return bi;
84913
+ }
84914
+ return value.toNumber();
84899
84915
  }
84900
84916
  return value.toNumber();
84901
84917
  }
@@ -84942,7 +84958,7 @@ var Client = class _Client {
84942
84958
  "x-sdk-name": "Console",
84943
84959
  "x-sdk-platform": "console",
84944
84960
  "x-sdk-language": "web",
84945
- "x-sdk-version": "3.0.0",
84961
+ "x-sdk-version": "3.1.0",
84946
84962
  "X-Appwrite-Response-Format": "1.8.0"
84947
84963
  };
84948
84964
  this.realtime = {
@@ -94020,21 +94036,26 @@ var Organizations = class {
94020
94036
  const apiHeaders = {};
94021
94037
  return this.client.call("get", uri, apiHeaders, payload);
94022
94038
  }
94023
- getScopes(paramsOrFirst) {
94039
+ getScopes(paramsOrFirst, ...rest) {
94024
94040
  let params;
94025
94041
  if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
94026
94042
  params = paramsOrFirst || {};
94027
94043
  } else {
94028
94044
  params = {
94029
- organizationId: paramsOrFirst
94045
+ organizationId: paramsOrFirst,
94046
+ projectId: rest[0]
94030
94047
  };
94031
94048
  }
94032
94049
  const organizationId = params.organizationId;
94050
+ const projectId = params.projectId;
94033
94051
  if (typeof organizationId === "undefined") {
94034
94052
  throw new AppwriteException('Missing required parameter: "organizationId"');
94035
94053
  }
94036
94054
  const apiPath = "/organizations/{organizationId}/roles".replace("{organizationId}", organizationId);
94037
94055
  const payload = {};
94056
+ if (typeof projectId !== "undefined") {
94057
+ payload["projectId"] = projectId;
94058
+ }
94038
94059
  const uri = new URL(this.client.config.endpoint + apiPath);
94039
94060
  const apiHeaders = {};
94040
94061
  return this.client.call("get", uri, apiHeaders, payload);
@@ -103978,7 +103999,7 @@ var package_default = {
103978
103999
  type: "module",
103979
104000
  homepage: "https://appwrite.io/support",
103980
104001
  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",
103981
- version: "13.5.0",
104002
+ version: "13.6.1",
103982
104003
  license: "BSD-3-Clause",
103983
104004
  main: "dist/index.cjs",
103984
104005
  module: "dist/index.js",
@@ -104009,6 +104030,7 @@ var package_default = {
104009
104030
  "build:lib:esm": "esbuild index.ts --bundle --platform=node --target=node18 --format=esm --loader:.hbs=text --outfile=dist/index.js",
104010
104031
  "build:lib:cjs": "esbuild index.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --outfile=dist/index.cjs",
104011
104032
  "build:cli": "esbuild cli.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:fsevents --outfile=dist/cli.cjs",
104033
+ lint: "eslint .",
104012
104034
  format: 'prettier --write "**/*.{js,ts,json,md}"',
104013
104035
  generate: "tsx scripts/generate-commands.ts",
104014
104036
  prepublishOnly: "npm run build",
@@ -104021,7 +104043,7 @@ var package_default = {
104021
104043
  "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"
104022
104044
  },
104023
104045
  dependencies: {
104024
- "@appwrite.io/console": "^3.0.0",
104046
+ "@appwrite.io/console": "^3.1.0",
104025
104047
  chalk: "4.1.2",
104026
104048
  chokidar: "^3.6.0",
104027
104049
  "cli-progress": "^3.12.0",
@@ -104040,7 +104062,12 @@ var package_default = {
104040
104062
  zod: "^4.3.5"
104041
104063
  },
104042
104064
  devDependencies: {
104065
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
104066
+ "@typescript-eslint/parser": "^8.0.0",
104043
104067
  "@types/bun": "^1.3.5",
104068
+ eslint: "^9.0.0",
104069
+ "eslint-plugin-unused-imports": "^4.0.0",
104070
+ "typescript-eslint": "^8.0.0",
104044
104071
  "@types/cli-progress": "^3.11.5",
104045
104072
  "@types/inquirer": "^8.2.10",
104046
104073
  "@types/json-bigint": "^1.0.4",
@@ -104072,14 +104099,28 @@ var cliConfig = {
104072
104099
  report: false,
104073
104100
  reportData: {}
104074
104101
  };
104102
+ var toJsonObject = (value) => {
104103
+ if (value && typeof value === "object" && !Array.isArray(value)) {
104104
+ return value;
104105
+ }
104106
+ return null;
104107
+ };
104108
+ var extractReportCommandArgs = (value) => {
104109
+ if (!value || typeof value !== "object") {
104110
+ return [];
104111
+ }
104112
+ const reportData = value;
104113
+ if (!Array.isArray(reportData.data?.args)) {
104114
+ return [];
104115
+ }
104116
+ return reportData.data.args;
104117
+ };
104075
104118
  var drawTable = (data) => {
104076
104119
  if (data.length == 0) {
104077
104120
  console.log("[]");
104078
104121
  return;
104079
104122
  }
104080
- const rows = data.map(
104081
- (item) => item && typeof item === "object" && !Array.isArray(item) ? item : {}
104082
- );
104123
+ const rows = data.map((item) => toJsonObject(item) ?? {});
104083
104124
  const obj = rows.reduce((res, item) => ({ ...res, ...item }), {});
104084
104125
  const keys = Object.keys(obj);
104085
104126
  if (keys.length === 0) {
@@ -104122,7 +104163,7 @@ var drawTable = (data) => {
104122
104163
  } else if (typeof row[key] === "object") {
104123
104164
  rowValues.push(JSON.stringify(row[key]));
104124
104165
  } else {
104125
- rowValues.push(row[key]);
104166
+ rowValues.push(String(row[key]));
104126
104167
  }
104127
104168
  }
104128
104169
  table.push(rowValues);
@@ -104134,7 +104175,7 @@ var drawJSON = (data) => {
104134
104175
  };
104135
104176
  var parseError = (err) => {
104136
104177
  if (cliConfig.report) {
104137
- (async () => {
104178
+ void (async () => {
104138
104179
  let appwriteVersion = "unknown";
104139
104180
  const endpoint = globalConfig2.getEndpoint();
104140
104181
  try {
@@ -104147,7 +104188,8 @@ var parseError = (err) => {
104147
104188
  } catch {
104148
104189
  }
104149
104190
  const version2 = SDK_VERSION;
104150
- const stepsToReproduce = `Running \`${EXECUTABLE_NAME} ${cliConfig.reportData.data.args.join(" ")}\``;
104191
+ const commandArgs = extractReportCommandArgs(cliConfig.reportData);
104192
+ const stepsToReproduce = `Running \`${EXECUTABLE_NAME} ${commandArgs.join(" ")}\``;
104151
104193
  const yourEnvironment = `CLI version: ${version2}
104152
104194
  Operation System: ${import_os2.default.type()}
104153
104195
  Appwrite version: ${appwriteVersion}
@@ -104199,7 +104241,7 @@ var actionRunner = (fn) => {
104199
104241
  error48(`The '--all' and '--id' flags cannot be used together.`);
104200
104242
  process.exit(1);
104201
104243
  }
104202
- return fn(...args).catch(parseError);
104244
+ return fn(...args).then(() => void 0).catch(parseError);
104203
104245
  };
104204
104246
  };
104205
104247
  var log = (message) => {
@@ -104312,6 +104354,9 @@ async function downloadDeploymentCode(params) {
104312
104354
  {},
104313
104355
  "arrayBuffer"
104314
104356
  );
104357
+ if (!(downloadBuffer instanceof ArrayBuffer)) {
104358
+ throw new Error("Failed to download deployment archive as ArrayBuffer.");
104359
+ }
104315
104360
  try {
104316
104361
  import_fs2.default.writeFileSync(compressedFileName, Buffer.from(downloadBuffer));
104317
104362
  } catch (err) {
@@ -104523,7 +104568,7 @@ var questionsInitProject = [
104523
104568
  name: "organization",
104524
104569
  message: "Choose your organization",
104525
104570
  choices: async () => {
104526
- let client = await sdkForConsole(true);
104571
+ const client = await sdkForConsole(true);
104527
104572
  const { teams } = isCloud() ? await paginate(
104528
104573
  async (opts = {}) => (await getOrganizationsService(opts.sdk)).list(),
104529
104574
  { sdk: client },
@@ -104535,7 +104580,7 @@ var questionsInitProject = [
104535
104580
  100,
104536
104581
  "teams"
104537
104582
  );
104538
- let choices = teams.map((team, idx) => {
104583
+ const choices = teams.map((team, _idx) => {
104539
104584
  return {
104540
104585
  name: `${team.name} (${team["$id"]})`,
104541
104586
  value: team["$id"]
@@ -104584,7 +104629,7 @@ var questionsInitProject = [
104584
104629
  "projects",
104585
104630
  queries
104586
104631
  );
104587
- let choices = projects.map((project) => {
104632
+ const choices = projects.map((project) => {
104588
104633
  return {
104589
104634
  name: `${project.name} (${project["$id"]})`,
104590
104635
  value: {
@@ -104605,13 +104650,13 @@ var questionsInitProject = [
104605
104650
  name: "region",
104606
104651
  message: `Select your ${SDK_TITLE} Cloud region`,
104607
104652
  choices: async () => {
104608
- let client = await sdkForConsole(true);
104653
+ const client = await sdkForConsole(true);
104609
104654
  const endpoint = globalConfig2.getEndpoint() || DEFAULT_ENDPOINT;
104610
- let response = await client.call(
104655
+ const response = await client.call(
104611
104656
  "GET",
104612
104657
  new URL(endpoint + "/console/regions")
104613
104658
  );
104614
- let regions = response.regions || [];
104659
+ const regions = response.regions || [];
104615
104660
  if (!regions.length) {
104616
104661
  throw new Error(
104617
104662
  "No regions found. Please check your network or Appwrite Cloud availability."
@@ -104738,9 +104783,9 @@ var questionGetEndpoint = [
104738
104783
  if (!value) {
104739
104784
  return "Please enter a valid endpoint.";
104740
104785
  }
104741
- let client = new Client().setEndpoint(value);
104786
+ const client = new Client().setEndpoint(value);
104742
104787
  try {
104743
- let response = await client.call(
104788
+ const response = await client.call(
104744
104789
  "get",
104745
104790
  new URL(value + "/health/version")
104746
104791
  );
@@ -104749,7 +104794,7 @@ var questionGetEndpoint = [
104749
104794
  } else {
104750
104795
  throw new Error();
104751
104796
  }
104752
- } catch (error49) {
104797
+ } catch (_error) {
104753
104798
  return "Invalid endpoint or your Appwrite server is not running as expected.";
104754
104799
  }
104755
104800
  }
@@ -104785,9 +104830,9 @@ var questionsPushSites = [
104785
104830
  validate: (value) => validateRequired("site", value),
104786
104831
  when: () => localConfig.getSites().length > 0,
104787
104832
  choices: () => {
104788
- let sites = localConfig.getSites();
104833
+ const sites = localConfig.getSites();
104789
104834
  checkDeployConditions(localConfig);
104790
- let choices = sites.map((site, idx) => {
104835
+ const choices = sites.map((site, _idx) => {
104791
104836
  return {
104792
104837
  name: `${site.name} (${site.$id})`,
104793
104838
  value: site.$id
@@ -104805,9 +104850,9 @@ var questionsPushFunctions = [
104805
104850
  validate: (value) => validateRequired("function", value),
104806
104851
  when: () => localConfig.getFunctions().length > 0,
104807
104852
  choices: () => {
104808
- let functions = localConfig.getFunctions();
104853
+ const functions = localConfig.getFunctions();
104809
104854
  checkDeployConditions(localConfig);
104810
- let choices = functions.map((func, idx) => {
104855
+ const choices = functions.map((func, _idx) => {
104811
104856
  return {
104812
104857
  name: `${func.name} (${func.$id})`,
104813
104858
  value: func.$id
@@ -104825,7 +104870,7 @@ var questionsPushCollections = [
104825
104870
  validate: (value) => validateRequired("collection", value),
104826
104871
  when: () => localConfig.getCollections().length > 0,
104827
104872
  choices: () => {
104828
- let collections = localConfig.getCollections();
104873
+ const collections = localConfig.getCollections();
104829
104874
  checkDeployConditions(localConfig);
104830
104875
  return collections.map((collection) => {
104831
104876
  return {
@@ -104844,7 +104889,7 @@ var questionsPushTables = [
104844
104889
  validate: (value) => validateRequired("table", value),
104845
104890
  when: () => localConfig.getTables().length > 0,
104846
104891
  choices: () => {
104847
- let tables = localConfig.getTables();
104892
+ const tables = localConfig.getTables();
104848
104893
  checkDeployConditions(localConfig);
104849
104894
  return tables.map((table) => {
104850
104895
  return {
@@ -104877,7 +104922,7 @@ var questionsPushBuckets = [
104877
104922
  validate: (value) => validateRequired("bucket", value),
104878
104923
  when: () => localConfig.getBuckets().length > 0,
104879
104924
  choices: () => {
104880
- let buckets = localConfig.getBuckets();
104925
+ const buckets = localConfig.getBuckets();
104881
104926
  checkDeployConditions(localConfig);
104882
104927
  return buckets.map((bucket) => {
104883
104928
  return {
@@ -104896,7 +104941,7 @@ var questionsPushMessagingTopics = [
104896
104941
  validate: (value) => validateRequired("topics", value),
104897
104942
  when: () => localConfig.getMessagingTopics().length > 0,
104898
104943
  choices: () => {
104899
- let topics = localConfig.getMessagingTopics();
104944
+ const topics = localConfig.getMessagingTopics();
104900
104945
  return topics.map((topic) => {
104901
104946
  return {
104902
104947
  name: `${topic.name} (${topic["$id"]})`,
@@ -104927,7 +104972,7 @@ var questionsPushTeams = [
104927
104972
  validate: (value) => validateRequired("team", value),
104928
104973
  when: () => localConfig.getTeams().length > 0,
104929
104974
  choices: () => {
104930
- let teams = localConfig.getTeams();
104975
+ const teams = localConfig.getTeams();
104931
104976
  checkDeployConditions(localConfig);
104932
104977
  return teams.map((team) => {
104933
104978
  return {
@@ -104969,7 +105014,7 @@ var Pools = class {
104969
105014
  return true;
104970
105015
  }
104971
105016
  if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
104972
- let steps = Math.max(1, Math.ceil(Number(total) / this.STEP_SIZE));
105017
+ const steps = Math.max(1, Math.ceil(Number(total) / this.STEP_SIZE));
104973
105018
  if (steps > 1 && iteration === 1) {
104974
105019
  this.pollMaxDebounces *= steps;
104975
105020
  log(
@@ -104995,7 +105040,7 @@ var Pools = class {
104995
105040
  return true;
104996
105041
  }
104997
105042
  if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
104998
- let steps = Math.max(1, Math.ceil(Number(total) / this.STEP_SIZE));
105043
+ const steps = Math.max(1, Math.ceil(Number(total) / this.STEP_SIZE));
104999
105044
  if (steps > 1 && iteration === 1) {
105000
105045
  this.pollMaxDebounces *= steps;
105001
105046
  log(
@@ -105011,7 +105056,10 @@ var Pools = class {
105011
105056
  return false;
105012
105057
  }
105013
105058
  if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
105014
- let steps = Math.max(1, Math.ceil(attributeKeys.length / this.STEP_SIZE));
105059
+ const steps = Math.max(
105060
+ 1,
105061
+ Math.ceil(attributeKeys.length / this.STEP_SIZE)
105062
+ );
105015
105063
  if (steps > 1 && iteration === 1) {
105016
105064
  this.pollMaxDebounces *= steps;
105017
105065
  log(
@@ -105054,7 +105102,10 @@ var Pools = class {
105054
105102
  return false;
105055
105103
  }
105056
105104
  if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
105057
- let steps = Math.max(1, Math.ceil(attributeKeys.length / this.STEP_SIZE));
105105
+ const steps = Math.max(
105106
+ 1,
105107
+ Math.ceil(attributeKeys.length / this.STEP_SIZE)
105108
+ );
105058
105109
  if (steps > 1 && iteration === 1) {
105059
105110
  this.pollMaxDebounces *= steps;
105060
105111
  log(
@@ -105103,7 +105154,7 @@ var Pools = class {
105103
105154
  return false;
105104
105155
  }
105105
105156
  if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
105106
- let steps = Math.max(1, Math.ceil(indexKeys.length / this.STEP_SIZE));
105157
+ const steps = Math.max(1, Math.ceil(indexKeys.length / this.STEP_SIZE));
105107
105158
  if (steps > 1 && iteration === 1) {
105108
105159
  this.pollMaxDebounces *= steps;
105109
105160
  log(
@@ -105196,7 +105247,7 @@ var Attributes = class {
105196
105247
  }
105197
105248
  return answers2.changes;
105198
105249
  }
105199
- let answers = await import_inquirer.default.prompt(questionPushChanges2);
105250
+ const answers = await import_inquirer.default.prompt(questionPushChanges2);
105200
105251
  if (answers.changes !== "YES" && answers.changes !== "NO") {
105201
105252
  answers.changes = await fixConfirmation();
105202
105253
  }
@@ -105239,8 +105290,8 @@ var Attributes = class {
105239
105290
  const keyName = `${import_chalk4.default.yellow(local.key)} in ${collection.name} (${collection["$id"]})`;
105240
105291
  const action = import_chalk4.default.cyan(recreating ? "recreating" : "changing");
105241
105292
  let reason = "";
105242
- let attribute = recreating ? remote : local;
105243
- for (let key of Object.keys(remote)) {
105293
+ const attribute = recreating ? remote : local;
105294
+ for (const key of Object.keys(remote)) {
105244
105295
  if (!KeysAttributes.has(key)) {
105245
105296
  continue;
105246
105297
  }
@@ -105750,7 +105801,7 @@ var Attributes = class {
105750
105801
  createIndexes = async (indexes, collection) => {
105751
105802
  log(`Creating indexes ...`);
105752
105803
  const databasesService = await getDatabasesService(this.client);
105753
- for (let index of indexes) {
105804
+ for (const index of indexes) {
105754
105805
  await databasesService.createIndex({
105755
105806
  databaseId: collection["databaseId"],
105756
105807
  collectionId: collection["$id"],
@@ -105774,7 +105825,7 @@ var Attributes = class {
105774
105825
  };
105775
105826
  createAttributes = async (attributes, collection) => {
105776
105827
  log(`Creating attributes ...`);
105777
- for (let attribute of attributes) {
105828
+ for (const attribute of attributes) {
105778
105829
  if (attribute.side !== "child") {
105779
105830
  await this.createAttribute(
105780
105831
  collection["databaseId"],
@@ -105798,7 +105849,7 @@ var Attributes = class {
105798
105849
  };
105799
105850
  createColumns = async (columns, table) => {
105800
105851
  log(`Creating columns ...`);
105801
- for (let column of columns) {
105852
+ for (const column of columns) {
105802
105853
  if (column.side !== "child") {
105803
105854
  await this.createAttribute(table["databaseId"], table["$id"], column);
105804
105855
  }
@@ -105833,7 +105884,7 @@ var getConfirmation = async () => {
105833
105884
  }
105834
105885
  return answers2.changes;
105835
105886
  }
105836
- let answers = await import_inquirer2.default.prompt(questionPushChanges);
105887
+ const answers = await import_inquirer2.default.prompt(questionPushChanges);
105837
105888
  if (answers.changes !== "YES" && answers.changes !== "NO") {
105838
105889
  answers.changes = await fixConfirmation();
105839
105890
  }
@@ -105883,7 +105934,7 @@ var approveChanges = async (resource, resourceGetFunction, keys, resourceName, r
105883
105934
  options[secondResourceName] = localResource[secondId];
105884
105935
  }
105885
105936
  const remoteResource = await resourceGetFunction(options);
105886
- for (let [key, value] of Object.entries(
105937
+ for (const [key, value] of Object.entries(
105887
105938
  whitelistKeys(remoteResource, keys)
105888
105939
  )) {
105889
105940
  if (skipKeys.includes(key)) {
@@ -105892,28 +105943,30 @@ var approveChanges = async (resource, resourceGetFunction, keys, resourceName, r
105892
105943
  if (isEmpty(value) && isEmpty(localResource[key])) {
105893
105944
  continue;
105894
105945
  }
105895
- if (Array.isArray(value) && Array.isArray(localResource[key])) {
105896
- if (JSON.stringify(value) !== JSON.stringify(localResource[key])) {
105946
+ const localValue = localResource[key];
105947
+ if (Array.isArray(value) && Array.isArray(localValue)) {
105948
+ if (JSON.stringify(value) !== JSON.stringify(localValue)) {
105897
105949
  changes.push({
105898
105950
  id: localResource["$id"],
105899
105951
  key,
105900
105952
  remote: import_chalk5.default.red(value.join("\n")),
105901
- local: import_chalk5.default.green(localResource[key].join("\n"))
105953
+ local: import_chalk5.default.green(
105954
+ localValue.map((entry) => String(entry)).join("\n")
105955
+ )
105902
105956
  });
105903
105957
  }
105904
- } else if (value !== localResource[key]) {
105958
+ } else if (value !== localValue) {
105905
105959
  changes.push({
105906
105960
  id: localResource["$id"],
105907
105961
  key,
105908
- remote: import_chalk5.default.red(value),
105909
- local: import_chalk5.default.green(localResource[key])
105962
+ remote: import_chalk5.default.red(String(value ?? "")),
105963
+ local: import_chalk5.default.green(String(localValue ?? ""))
105910
105964
  });
105911
105965
  }
105912
105966
  }
105913
105967
  } catch (e) {
105914
- if (Number(e.code) !== 404) {
105915
- throw e;
105916
- }
105968
+ const isNotFound = e instanceof AppwriteException && Number(e.code) === 404;
105969
+ if (!isNotFound) throw e;
105917
105970
  }
105918
105971
  })
105919
105972
  );
@@ -105930,18 +105983,37 @@ var approveChanges = async (resource, resourceGetFunction, keys, resourceName, r
105930
105983
 
105931
105984
  // lib/commands/utils/database-sync.ts
105932
105985
  var import_chalk6 = __toESM(require_source(), 1);
105986
+ var isTablesDBResource = (value) => {
105987
+ if (!value || typeof value !== "object") {
105988
+ return false;
105989
+ }
105990
+ return "$id" in value && typeof value.$id === "string" && "name" in value && typeof value.name === "string" && "enabled" in value && typeof value.enabled === "boolean";
105991
+ };
105992
+ var getSyncErrorMessage = (err) => {
105993
+ if (err instanceof AppwriteException) {
105994
+ return err.message;
105995
+ }
105996
+ if (err instanceof Error) {
105997
+ return err.message;
105998
+ }
105999
+ return String(err);
106000
+ };
105933
106001
  var checkAndApplyTablesDBChanges = async () => {
105934
106002
  log("Checking for tablesDB changes ...");
105935
106003
  const localTablesDBs = localConfig.getTablesDBs();
105936
- const { databases: remoteTablesDBs } = await paginate(
106004
+ const paginatedResult = await paginate(
105937
106005
  async (args) => {
105938
106006
  const tablesDBService = await getTablesDBService();
105939
- return await tablesDBService.list(args.queries || []);
106007
+ const queries = Array.isArray(args.queries) ? args.queries.filter(
106008
+ (query) => typeof query === "string"
106009
+ ) : [];
106010
+ return await tablesDBService.list(queries);
105940
106011
  },
105941
106012
  {},
105942
106013
  100,
105943
106014
  "databases"
105944
106015
  );
106016
+ const remoteTablesDBs = Array.isArray(paginatedResult.databases) ? paginatedResult.databases.filter(isTablesDBResource) : [];
105945
106017
  if (localTablesDBs.length === 0 && remoteTablesDBs.length === 0) {
105946
106018
  return { applied: false, resyncNeeded: false };
105947
106019
  }
@@ -105963,9 +106035,7 @@ var checkAndApplyTablesDBChanges = async () => {
105963
106035
  }
105964
106036
  }
105965
106037
  for (const localDB of localTablesDBs) {
105966
- const remoteDB = remoteTablesDBs.find(
105967
- (db) => db.$id === localDB.$id
105968
- );
106038
+ const remoteDB = remoteTablesDBs.find((db) => db.$id === localDB.$id);
105969
106039
  if (!remoteDB) {
105970
106040
  toCreate.push(localDB);
105971
106041
  changes.push({
@@ -106032,7 +106102,7 @@ var checkAndApplyTablesDBChanges = async () => {
106032
106102
  needsResync = true;
106033
106103
  } catch (e) {
106034
106104
  error48(
106035
- `Failed to delete database ${db.name} ( ${db.$id} ): ${e.message}`
106105
+ `Failed to delete database ${db.name} ( ${db.$id} ): ${getSyncErrorMessage(e)}`
106036
106106
  );
106037
106107
  throw new Error(
106038
106108
  `Database sync failed during deletion of ${db.$id}. Some changes may have been applied.`
@@ -106047,7 +106117,7 @@ var checkAndApplyTablesDBChanges = async () => {
106047
106117
  success2(`Created ${db.name} ( ${db.$id} )`);
106048
106118
  } catch (e) {
106049
106119
  error48(
106050
- `Failed to create database ${db.name} ( ${db.$id} ): ${e.message}`
106120
+ `Failed to create database ${db.name} ( ${db.$id} ): ${getSyncErrorMessage(e)}`
106051
106121
  );
106052
106122
  throw new Error(
106053
106123
  `Database sync failed during creation of ${db.$id}. Some changes may have been applied.`
@@ -106062,7 +106132,7 @@ var checkAndApplyTablesDBChanges = async () => {
106062
106132
  success2(`Updated ${db.name} ( ${db.$id} )`);
106063
106133
  } catch (e) {
106064
106134
  error48(
106065
- `Failed to update database ${db.name} ( ${db.$id} ): ${e.message}`
106135
+ `Failed to update database ${db.name} ( ${db.$id} ): ${getSyncErrorMessage(e)}`
106066
106136
  );
106067
106137
  throw new Error(
106068
106138
  `Database sync failed during update of ${db.$id}. Some changes may have been applied.`
@@ -106296,7 +106366,7 @@ var Push = class {
106296
106366
  }
106297
106367
  if (settings.services) {
106298
106368
  this.log("Applying service statuses ...");
106299
- for (let [service, status] of Object.entries(settings.services)) {
106369
+ for (const [service, status] of Object.entries(settings.services)) {
106300
106370
  await projectsService.updateServiceStatus({
106301
106371
  projectId,
106302
106372
  service,
@@ -106342,7 +106412,7 @@ var Push = class {
106342
106412
  }
106343
106413
  if (settings.auth.methods) {
106344
106414
  this.log("Applying auth methods statuses ...");
106345
- for (let [method, status] of Object.entries(settings.auth.methods)) {
106415
+ for (const [method, status] of Object.entries(settings.auth.methods)) {
106346
106416
  await projectsService.updateAuthStatus({
106347
106417
  projectId,
106348
106418
  method,
@@ -106646,7 +106716,7 @@ var Push = class {
106646
106716
  ([key, value]) => ({ key, value })
106647
106717
  );
106648
106718
  }
106649
- } catch (error49) {
106719
+ } catch (_error) {
106650
106720
  envVariables = [];
106651
106721
  }
106652
106722
  await Promise.all(
@@ -106943,7 +107013,7 @@ var Push = class {
106943
107013
  ([key, value]) => ({ key, value })
106944
107014
  );
106945
107015
  }
106946
- } catch (error49) {
107016
+ } catch (_error) {
106947
107017
  envVariables = [];
106948
107018
  }
106949
107019
  await Promise.all(
@@ -107110,7 +107180,7 @@ var Push = class {
107110
107180
  skipConfirmation,
107111
107181
  this.projectClient
107112
107182
  );
107113
- let tablesChanged = /* @__PURE__ */ new Set();
107183
+ const tablesChanged = /* @__PURE__ */ new Set();
107114
107184
  const errors = [];
107115
107185
  await Promise.all(
107116
107186
  tables.map(async (table) => {
@@ -107164,7 +107234,7 @@ var Push = class {
107164
107234
  }
107165
107235
  })
107166
107236
  );
107167
- for (let table of tables) {
107237
+ for (const table of tables) {
107168
107238
  let columns = table.columns;
107169
107239
  let indexes = table.indexes;
107170
107240
  let hadChanges = false;
@@ -107443,7 +107513,7 @@ var pushSettings = async () => {
107443
107513
  checkDeployConditions(localConfig);
107444
107514
  try {
107445
107515
  const projectsService = await getProjectsService();
107446
- let response = await projectsService.get(
107516
+ const response = await projectsService.get(
107447
107517
  localConfig.getProject().projectId
107448
107518
  );
107449
107519
  const remoteSettings = createSettingsObject(response);
@@ -107476,7 +107546,7 @@ var pushSettings = async () => {
107476
107546
  return;
107477
107547
  }
107478
107548
  }
107479
- } catch (e) {
107549
+ } catch (_e) {
107480
107550
  }
107481
107551
  try {
107482
107552
  log("Pushing project settings ...");
@@ -107526,7 +107596,7 @@ var pushSite = async ({
107526
107596
  );
107527
107597
  return;
107528
107598
  }
107529
- let sites = siteIds.map((id) => {
107599
+ const sites = siteIds.map((id) => {
107530
107600
  const sites2 = localConfig.getSites();
107531
107601
  const site = sites2.find((s) => s.$id === id);
107532
107602
  if (!site) {
@@ -107535,7 +107605,7 @@ var pushSite = async ({
107535
107605
  return site;
107536
107606
  });
107537
107607
  log("Validating sites ...");
107538
- for (let site of sites) {
107608
+ for (const site of sites) {
107539
107609
  if (!site.buildCommand) {
107540
107610
  log(`Site ${site.name} is missing build command.`);
107541
107611
  const answers = await import_inquirer3.default.prompt(questionsGetEntrypoint);
@@ -107646,7 +107716,7 @@ var pushFunction = async ({
107646
107716
  );
107647
107717
  return;
107648
107718
  }
107649
- let functions = functionIds.map((id) => {
107719
+ const functions = functionIds.map((id) => {
107650
107720
  const functions2 = localConfig.getFunctions();
107651
107721
  const func = functions2.find((f) => f.$id === id);
107652
107722
  if (!func) {
@@ -107655,7 +107725,7 @@ var pushFunction = async ({
107655
107725
  return func;
107656
107726
  });
107657
107727
  log("Validating functions ...");
107658
- for (let func of functions) {
107728
+ for (const func of functions) {
107659
107729
  if (!func.entrypoint) {
107660
107730
  log(`Function ${func.name} is missing an entrypoint.`);
107661
107731
  const answers = await import_inquirer3.default.prompt(questionsGetEntrypoint);
@@ -107796,7 +107866,7 @@ var pushTable = async ({
107796
107866
  });
107797
107867
  }
107798
107868
  }
107799
- } catch (e) {
107869
+ } catch (_e) {
107800
107870
  }
107801
107871
  }
107802
107872
  if (tablesToDelete.length > 0) {
@@ -107943,7 +108013,7 @@ var pushCollection = async () => {
107943
108013
  }
107944
108014
  };
107945
108015
  var pushBucket = async () => {
107946
- let bucketIds = [];
108016
+ const bucketIds = [];
107947
108017
  const configBuckets = localConfig.getBuckets();
107948
108018
  if (cliConfig.all) {
107949
108019
  checkDeployConditions(localConfig);
@@ -107962,7 +108032,7 @@ var pushBucket = async () => {
107962
108032
  );
107963
108033
  return;
107964
108034
  }
107965
- let buckets = [];
108035
+ const buckets = [];
107966
108036
  for (const bucketId of bucketIds) {
107967
108037
  const idBuckets = configBuckets.filter((b) => b.$id === bucketId);
107968
108038
  buckets.push(...idBuckets);
@@ -107993,7 +108063,7 @@ var pushBucket = async () => {
107993
108063
  }
107994
108064
  };
107995
108065
  var pushTeam = async () => {
107996
- let teamIds = [];
108066
+ const teamIds = [];
107997
108067
  const configTeams = localConfig.getTeams();
107998
108068
  if (cliConfig.all) {
107999
108069
  checkDeployConditions(localConfig);
@@ -108012,7 +108082,7 @@ var pushTeam = async () => {
108012
108082
  );
108013
108083
  return;
108014
108084
  }
108015
- let teams = [];
108085
+ const teams = [];
108016
108086
  for (const teamId of teamIds) {
108017
108087
  const idTeams = configTeams.filter((t) => t.$id === teamId);
108018
108088
  teams.push(...idTeams);
@@ -108043,7 +108113,7 @@ var pushTeam = async () => {
108043
108113
  }
108044
108114
  };
108045
108115
  var pushMessagingTopic = async () => {
108046
- let topicsIds = [];
108116
+ const topicsIds = [];
108047
108117
  const configTopics = localConfig.getMessagingTopics();
108048
108118
  if (cliConfig.all) {
108049
108119
  checkDeployConditions(localConfig);
@@ -108062,7 +108132,7 @@ var pushMessagingTopic = async () => {
108062
108132
  );
108063
108133
  return;
108064
108134
  }
108065
- let topics = [];
108135
+ const topics = [];
108066
108136
  for (const topicId of topicsIds) {
108067
108137
  const idTopic = configTopics.filter((b) => b.$id === topicId);
108068
108138
  topics.push(...idTopic);
@@ -108646,7 +108716,7 @@ var pullResources = async ({
108646
108716
  delete actions.collections;
108647
108717
  }
108648
108718
  if (cliConfig.all) {
108649
- for (let action of Object.values(actions)) {
108719
+ for (const action of Object.values(actions)) {
108650
108720
  cliConfig.all = true;
108651
108721
  await action({ returnOnZero: true });
108652
108722
  }
@@ -108864,7 +108934,6 @@ pull.command("team").alias("teams").description("Pull your Appwrite teams").acti
108864
108934
  pull.command("topic").alias("topics").description("Pull your Appwrite messaging topics").action(actionRunner(pullMessagingTopic));
108865
108935
 
108866
108936
  // lib/commands/schema.ts
108867
- var import_json_bigint3 = __toESM(require_json_bigint(), 1);
108868
108937
  var fs7 = __toESM(require("fs"), 1);
108869
108938
  var path6 = __toESM(require("path"), 1);
108870
108939
 
@@ -109165,7 +109234,7 @@ var BaseDatabasesGenerator = class {
109165
109234
  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";
109166
109235
 
109167
109236
  // lib/commands/generators/typescript/templates/databases.ts.hbs
109168
- 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';
109237
+ 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';
109169
109238
 
109170
109239
  // lib/commands/generators/typescript/templates/index.ts.hbs
109171
109240
  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';
@@ -109332,7 +109401,7 @@ ${dbReturnTypes}
109332
109401
 
109333
109402
  export type DatabaseHandle<D extends DatabaseId> = {
109334
109403
  use: <T extends keyof DatabaseTableMap[D] & string>(tableId: T) => DatabaseTableMap[D][T];
109335
- ${supportsServerSide ? ` create: (tableId: string, name: string, options?: { permissions?: ${PERMISSION_CALLBACK_INLINE}; rowSecurity?: boolean; enabled?: boolean; columns?: any[]; indexes?: any[] }) => Promise<Models.Table>;
109404
+ ${supportsServerSide ? ` create: (tableId: string, name: string, options?: { permissions?: ${PERMISSION_CALLBACK_INLINE}; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; indexes?: object[] }) => Promise<Models.Table>;
109336
109405
  update: <T extends keyof DatabaseTableMap[D] & string>(tableId: T, options?: { name?: string; permissions?: ${PERMISSION_CALLBACK_INLINE}; rowSecurity?: boolean; enabled?: boolean }) => Promise<Models.Table>;
109337
109406
  delete: <T extends keyof DatabaseTableMap[D] & string>(tableId: T) => Promise<void>;` : ""}
109338
109407
  };
@@ -109399,26 +109468,26 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
109399
109468
  generateBulkMethods(supportsBulk) {
109400
109469
  if (!supportsBulk) return "";
109401
109470
  return `
109402
- createMany: (rows: any[], options?: { transactionId?: string }) =>
109471
+ createMany: (rows: object[], options?: { transactionId?: string }) =>
109403
109472
  tablesDB.createRows({
109404
109473
  databaseId,
109405
109474
  tableId,
109406
109475
  rows,
109407
109476
  transactionId: options?.transactionId,
109408
109477
  }),
109409
- updateMany: (data: any, options?: { queries?: (q: any) => string[]; transactionId?: string }) =>
109478
+ updateMany: (data: object, options?: { queries?: (q: QueryBuilder<T>) => string[]; transactionId?: string }) =>
109410
109479
  tablesDB.updateRows({
109411
109480
  databaseId,
109412
109481
  tableId,
109413
109482
  data,
109414
- queries: options?.queries?.(createQueryBuilder()),
109483
+ queries: options?.queries?.(createQueryBuilder<T>()),
109415
109484
  transactionId: options?.transactionId,
109416
109485
  }),
109417
- deleteMany: (options?: { queries?: (q: any) => string[]; transactionId?: string }) =>
109486
+ deleteMany: (options?: { queries?: (q: QueryBuilder<T>) => string[]; transactionId?: string }) =>
109418
109487
  tablesDB.deleteRows({
109419
109488
  databaseId,
109420
109489
  tableId,
109421
- queries: options?.queries?.(createQueryBuilder()),
109490
+ queries: options?.queries?.(createQueryBuilder<T>()),
109422
109491
  transactionId: options?.transactionId,
109423
109492
  }),`;
109424
109493
  }
@@ -109432,9 +109501,9 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
109432
109501
  return `
109433
109502
  // Remove bulk methods for tables with relationships
109434
109503
  if (!hasBulkMethods(databaseId, tableId)) {
109435
- delete (api as any).createMany;
109436
- delete (api as any).updateMany;
109437
- delete (api as any).deleteMany;
109504
+ delete (api as Record<string, unknown>).createMany;
109505
+ delete (api as Record<string, unknown>).updateMany;
109506
+ delete (api as Record<string, unknown>).deleteMany;
109438
109507
  }`;
109439
109508
  }
109440
109509
  generateDatabasesFile(config2, importExt) {
@@ -109506,7 +109575,6 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
109506
109575
  };
109507
109576
 
109508
109577
  // lib/commands/schema.ts
109509
- var JSONBig2 = (0, import_json_bigint3.default)({ useNativeBigInt: true });
109510
109578
  var Schema = class {
109511
109579
  pullCommand;
109512
109580
  pushCommand;
@@ -109579,7 +109647,7 @@ var Schema = class {
109579
109647
  * @returns The configuration object.
109580
109648
  */
109581
109649
  read(path7) {
109582
- return JSONBig2.parse(fs7.readFileSync(path7, "utf8"));
109650
+ return JSONBig.parse(fs7.readFileSync(path7, "utf8"));
109583
109651
  }
109584
109652
  /**
109585
109653
  * Writes the configuration object to a file.
@@ -109590,7 +109658,7 @@ var Schema = class {
109590
109658
  */
109591
109659
  write(config2, filePath) {
109592
109660
  const resolvedPath = path6.resolve(filePath);
109593
- const content = JSONBig2.stringify(config2, null, 4);
109661
+ const content = JSONBig.stringify(config2, null, 4);
109594
109662
  fs7.writeFileSync(resolvedPath, content);
109595
109663
  }
109596
109664
  };
@@ -109618,6 +109686,9 @@ var Schema = class {
109618
109686
  });
109619
109687
  /*! Bundled license information:
109620
109688
 
109689
+ safe-buffer/index.js:
109690
+ (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
109691
+
109621
109692
  undici/lib/fetch/body.js:
109622
109693
  (*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> *)
109623
109694