appwrite-cli 13.6.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.
- package/CHANGELOG.md +4 -0
- package/README.md +2 -2
- package/cli.ts +3 -3
- package/dist/bundle-win-arm64.mjs +336 -212
- package/dist/cli.cjs +336 -212
- package/dist/index.cjs +156 -104
- package/dist/index.js +156 -104
- package/dist/lib/commands/config-validations.d.ts +1 -1
- package/dist/lib/commands/config-validations.d.ts.map +1 -1
- package/dist/lib/commands/errors.d.ts +4 -4
- package/dist/lib/commands/errors.d.ts.map +1 -1
- package/dist/lib/commands/generate.d.ts.map +1 -1
- package/dist/lib/commands/generators/base.d.ts +5 -0
- package/dist/lib/commands/generators/base.d.ts.map +1 -1
- package/dist/lib/commands/generic.d.ts.map +1 -1
- package/dist/lib/commands/init.d.ts.map +1 -1
- package/dist/lib/commands/run.d.ts.map +1 -1
- package/dist/lib/commands/types.d.ts.map +1 -1
- package/dist/lib/commands/update.d.ts.map +1 -1
- package/dist/lib/commands/utils/change-approval.d.ts +3 -3
- package/dist/lib/commands/utils/change-approval.d.ts.map +1 -1
- package/dist/lib/commands/utils/database-sync.d.ts.map +1 -1
- package/dist/lib/commands/utils/deployment.d.ts +16 -4
- package/dist/lib/commands/utils/deployment.d.ts.map +1 -1
- package/dist/lib/commands/utils/pools.d.ts.map +1 -1
- package/dist/lib/constants.d.ts +1 -1
- package/dist/lib/emulation/docker.d.ts.map +1 -1
- package/dist/lib/json.d.ts +1 -1
- package/dist/lib/json.d.ts.map +1 -1
- package/dist/lib/paginate.d.ts +5 -6
- package/dist/lib/paginate.d.ts.map +1 -1
- package/dist/lib/parser.d.ts +5 -4
- package/dist/lib/parser.d.ts.map +1 -1
- package/dist/lib/spinner.d.ts +1 -1
- package/dist/lib/spinner.d.ts.map +1 -1
- package/dist/lib/utils.d.ts +6 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/validations.d.ts +1 -1
- package/dist/lib/validations.d.ts.map +1 -1
- package/eslint.config.js +45 -0
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.ts +3 -3
- package/lib/commands/config-validations.ts +1 -1
- package/lib/commands/config.ts +2 -2
- package/lib/commands/errors.ts +2 -2
- package/lib/commands/generate.ts +8 -6
- package/lib/commands/generators/base.ts +6 -0
- package/lib/commands/generators/typescript/databases.ts +9 -9
- package/lib/commands/generators/typescript/templates/databases.ts.hbs +16 -16
- package/lib/commands/generic.ts +21 -16
- package/lib/commands/init.ts +147 -61
- package/lib/commands/pull.ts +1 -1
- package/lib/commands/push.ts +19 -19
- package/lib/commands/run.ts +15 -9
- package/lib/commands/types.ts +18 -8
- package/lib/commands/update.ts +24 -16
- package/lib/commands/utils/attributes.ts +6 -6
- package/lib/commands/utils/change-approval.ts +26 -19
- package/lib/commands/utils/database-sync.ts +58 -18
- package/lib/commands/utils/deployment.ts +22 -5
- package/lib/commands/utils/pools.ts +11 -5
- package/lib/config.ts +1 -1
- package/lib/constants.ts +1 -1
- package/lib/emulation/docker.ts +5 -6
- package/lib/emulation/utils.ts +2 -2
- package/lib/json.ts +15 -7
- package/lib/paginate.ts +30 -20
- package/lib/parser.ts +46 -15
- package/lib/questions.ts +38 -38
- package/lib/spinner.ts +5 -1
- package/lib/utils.ts +15 -3
- package/lib/validations.ts +1 -1
- package/package.json +7 -1
- package/scoop/appwrite.config.json +3 -3
package/dist/cli.cjs
CHANGED
|
@@ -2354,7 +2354,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2354
2354
|
}
|
|
2355
2355
|
return positiveOption || option2;
|
|
2356
2356
|
};
|
|
2357
|
-
const
|
|
2357
|
+
const getErrorMessage2 = (option2) => {
|
|
2358
2358
|
const bestOption = findBestOptionFromValue(option2);
|
|
2359
2359
|
const optionKey = bestOption.attributeName();
|
|
2360
2360
|
const source = this.getOptionValueSource(optionKey);
|
|
@@ -2363,7 +2363,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2363
2363
|
}
|
|
2364
2364
|
return `option '${bestOption.flags}'`;
|
|
2365
2365
|
};
|
|
2366
|
-
const message = `error: ${
|
|
2366
|
+
const message = `error: ${getErrorMessage2(option)} cannot be used with ${getErrorMessage2(conflictingOption)}`;
|
|
2367
2367
|
this.error(message, { code: "commander.conflictingOption" });
|
|
2368
2368
|
}
|
|
2369
2369
|
/**
|
|
@@ -4309,9 +4309,9 @@ var require_source = __commonJS({
|
|
|
4309
4309
|
}
|
|
4310
4310
|
});
|
|
4311
4311
|
|
|
4312
|
-
// node_modules/escape-string-regexp/index.js
|
|
4312
|
+
// node_modules/figures/node_modules/escape-string-regexp/index.js
|
|
4313
4313
|
var require_escape_string_regexp = __commonJS({
|
|
4314
|
-
"node_modules/escape-string-regexp/index.js"(exports2, module2) {
|
|
4314
|
+
"node_modules/figures/node_modules/escape-string-regexp/index.js"(exports2, module2) {
|
|
4315
4315
|
"use strict";
|
|
4316
4316
|
var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
|
|
4317
4317
|
module2.exports = function(str) {
|
|
@@ -21956,9 +21956,9 @@ var require_stream_duplex = __commonJS({
|
|
|
21956
21956
|
}
|
|
21957
21957
|
});
|
|
21958
21958
|
|
|
21959
|
-
// node_modules/
|
|
21959
|
+
// node_modules/safe-buffer/index.js
|
|
21960
21960
|
var require_safe_buffer = __commonJS({
|
|
21961
|
-
"node_modules/
|
|
21961
|
+
"node_modules/safe-buffer/index.js"(exports2, module2) {
|
|
21962
21962
|
var buffer = require("buffer");
|
|
21963
21963
|
var Buffer2 = buffer.Buffer;
|
|
21964
21964
|
function copyProps(src, dst) {
|
|
@@ -61207,6 +61207,20 @@ var require_lodash = __commonJS({
|
|
|
61207
61207
|
}
|
|
61208
61208
|
});
|
|
61209
61209
|
|
|
61210
|
+
// node_modules/inquirer-search-list/node_modules/chalk/node_modules/escape-string-regexp/index.js
|
|
61211
|
+
var require_escape_string_regexp2 = __commonJS({
|
|
61212
|
+
"node_modules/inquirer-search-list/node_modules/chalk/node_modules/escape-string-regexp/index.js"(exports2, module2) {
|
|
61213
|
+
"use strict";
|
|
61214
|
+
var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
|
|
61215
|
+
module2.exports = function(str) {
|
|
61216
|
+
if (typeof str !== "string") {
|
|
61217
|
+
throw new TypeError("Expected a string");
|
|
61218
|
+
}
|
|
61219
|
+
return str.replace(matchOperatorsRe, "\\$&");
|
|
61220
|
+
};
|
|
61221
|
+
}
|
|
61222
|
+
});
|
|
61223
|
+
|
|
61210
61224
|
// node_modules/inquirer-search-list/node_modules/chalk/node_modules/ansi-styles/node_modules/color-convert/node_modules/color-name/index.js
|
|
61211
61225
|
var require_color_name2 = __commonJS({
|
|
61212
61226
|
"node_modules/inquirer-search-list/node_modules/chalk/node_modules/ansi-styles/node_modules/color-convert/node_modules/color-name/index.js"(exports2, module2) {
|
|
@@ -62573,7 +62587,7 @@ var require_templates2 = __commonJS({
|
|
|
62573
62587
|
var require_chalk = __commonJS({
|
|
62574
62588
|
"node_modules/inquirer-search-list/node_modules/chalk/index.js"(exports2, module2) {
|
|
62575
62589
|
"use strict";
|
|
62576
|
-
var escapeStringRegexp =
|
|
62590
|
+
var escapeStringRegexp = require_escape_string_regexp2();
|
|
62577
62591
|
var ansiStyles = require_ansi_styles2();
|
|
62578
62592
|
var stdoutColor = require_supports_color2().stdout;
|
|
62579
62593
|
var template = require_templates2();
|
|
@@ -62736,11 +62750,25 @@ var require_chalk = __commonJS({
|
|
|
62736
62750
|
}
|
|
62737
62751
|
});
|
|
62738
62752
|
|
|
62753
|
+
// node_modules/inquirer-search-list/node_modules/figures/node_modules/escape-string-regexp/index.js
|
|
62754
|
+
var require_escape_string_regexp3 = __commonJS({
|
|
62755
|
+
"node_modules/inquirer-search-list/node_modules/figures/node_modules/escape-string-regexp/index.js"(exports2, module2) {
|
|
62756
|
+
"use strict";
|
|
62757
|
+
var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
|
|
62758
|
+
module2.exports = function(str) {
|
|
62759
|
+
if (typeof str !== "string") {
|
|
62760
|
+
throw new TypeError("Expected a string");
|
|
62761
|
+
}
|
|
62762
|
+
return str.replace(matchOperatorsRe, "\\$&");
|
|
62763
|
+
};
|
|
62764
|
+
}
|
|
62765
|
+
});
|
|
62766
|
+
|
|
62739
62767
|
// node_modules/inquirer-search-list/node_modules/figures/index.js
|
|
62740
62768
|
var require_figures2 = __commonJS({
|
|
62741
62769
|
"node_modules/inquirer-search-list/node_modules/figures/index.js"(exports2, module2) {
|
|
62742
62770
|
"use strict";
|
|
62743
|
-
var escapeStringRegexp =
|
|
62771
|
+
var escapeStringRegexp = require_escape_string_regexp3();
|
|
62744
62772
|
var platform = process.platform;
|
|
62745
62773
|
var main = {
|
|
62746
62774
|
tick: "\u2714",
|
|
@@ -82336,9 +82364,9 @@ var require_is_glob = __commonJS({
|
|
|
82336
82364
|
}
|
|
82337
82365
|
});
|
|
82338
82366
|
|
|
82339
|
-
// node_modules/glob-parent/index.js
|
|
82367
|
+
// node_modules/chokidar/node_modules/glob-parent/index.js
|
|
82340
82368
|
var require_glob_parent = __commonJS({
|
|
82341
|
-
"node_modules/glob-parent/index.js"(exports2, module2) {
|
|
82369
|
+
"node_modules/chokidar/node_modules/glob-parent/index.js"(exports2, module2) {
|
|
82342
82370
|
"use strict";
|
|
82343
82371
|
var isGlob = require_is_glob();
|
|
82344
82372
|
var pathPosixDirname = require("path").posix.dirname;
|
|
@@ -92061,7 +92089,7 @@ var package_default = {
|
|
|
92061
92089
|
type: "module",
|
|
92062
92090
|
homepage: "https://appwrite.io/support",
|
|
92063
92091
|
description: "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API",
|
|
92064
|
-
version: "13.6.
|
|
92092
|
+
version: "13.6.1",
|
|
92065
92093
|
license: "BSD-3-Clause",
|
|
92066
92094
|
main: "dist/index.cjs",
|
|
92067
92095
|
module: "dist/index.js",
|
|
@@ -92092,6 +92120,7 @@ var package_default = {
|
|
|
92092
92120
|
"build:lib:esm": "esbuild index.ts --bundle --platform=node --target=node18 --format=esm --loader:.hbs=text --outfile=dist/index.js",
|
|
92093
92121
|
"build:lib:cjs": "esbuild index.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --outfile=dist/index.cjs",
|
|
92094
92122
|
"build:cli": "esbuild cli.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:fsevents --outfile=dist/cli.cjs",
|
|
92123
|
+
lint: "eslint .",
|
|
92095
92124
|
format: 'prettier --write "**/*.{js,ts,json,md}"',
|
|
92096
92125
|
generate: "tsx scripts/generate-commands.ts",
|
|
92097
92126
|
prepublishOnly: "npm run build",
|
|
@@ -92123,7 +92152,12 @@ var package_default = {
|
|
|
92123
92152
|
zod: "^4.3.5"
|
|
92124
92153
|
},
|
|
92125
92154
|
devDependencies: {
|
|
92155
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
92156
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
92126
92157
|
"@types/bun": "^1.3.5",
|
|
92158
|
+
eslint: "^9.0.0",
|
|
92159
|
+
"eslint-plugin-unused-imports": "^4.0.0",
|
|
92160
|
+
"typescript-eslint": "^8.0.0",
|
|
92127
92161
|
"@types/cli-progress": "^3.11.5",
|
|
92128
92162
|
"@types/inquirer": "^8.2.10",
|
|
92129
92163
|
"@types/json-bigint": "^1.0.4",
|
|
@@ -106046,7 +106080,7 @@ var int64Schema = external_exports.preprocess(
|
|
|
106046
106080
|
const valueOfResult = val.valueOf();
|
|
106047
106081
|
const bigIntVal = BigInt(valueOfResult);
|
|
106048
106082
|
return bigIntVal;
|
|
106049
|
-
} catch (
|
|
106083
|
+
} catch (_e) {
|
|
106050
106084
|
return void 0;
|
|
106051
106085
|
}
|
|
106052
106086
|
}
|
|
@@ -106056,7 +106090,7 @@ var int64Schema = external_exports.preprocess(
|
|
|
106056
106090
|
if (typeof val === "string") {
|
|
106057
106091
|
try {
|
|
106058
106092
|
return BigInt(val);
|
|
106059
|
-
} catch (
|
|
106093
|
+
} catch (_e) {
|
|
106060
106094
|
return void 0;
|
|
106061
106095
|
}
|
|
106062
106096
|
}
|
|
@@ -106338,7 +106372,7 @@ var import_undici = __toESM(require_undici(), 1);
|
|
|
106338
106372
|
// lib/constants.ts
|
|
106339
106373
|
var SDK_TITLE = "Appwrite";
|
|
106340
106374
|
var SDK_TITLE_LOWER = "appwrite";
|
|
106341
|
-
var SDK_VERSION = "13.6.
|
|
106375
|
+
var SDK_VERSION = "13.6.1";
|
|
106342
106376
|
var SDK_NAME = "Command Line";
|
|
106343
106377
|
var SDK_PLATFORM = "console";
|
|
106344
106378
|
var SDK_LANGUAGE = "cli";
|
|
@@ -106390,6 +106424,12 @@ var createSettingsObject = (project2) => {
|
|
|
106390
106424
|
}
|
|
106391
106425
|
};
|
|
106392
106426
|
};
|
|
106427
|
+
var getErrorMessage = (error49) => {
|
|
106428
|
+
if (error49 instanceof Error) {
|
|
106429
|
+
return error49.message;
|
|
106430
|
+
}
|
|
106431
|
+
return String(error49);
|
|
106432
|
+
};
|
|
106393
106433
|
async function getLatestVersion() {
|
|
106394
106434
|
try {
|
|
106395
106435
|
const response = await (0, import_undici.fetch)(NPM_REGISTRY_URL);
|
|
@@ -106420,7 +106460,7 @@ function getAllFiles(folder) {
|
|
|
106420
106460
|
let stats;
|
|
106421
106461
|
try {
|
|
106422
106462
|
stats = import_fs.default.statSync(pathAbsolute);
|
|
106423
|
-
} catch (
|
|
106463
|
+
} catch (_error) {
|
|
106424
106464
|
continue;
|
|
106425
106465
|
}
|
|
106426
106466
|
if (stats.isDirectory()) {
|
|
@@ -106465,7 +106505,7 @@ function systemHasCommand(command) {
|
|
|
106465
106505
|
return true;
|
|
106466
106506
|
}
|
|
106467
106507
|
var checkDeployConditions = (localConfig2) => {
|
|
106468
|
-
if (
|
|
106508
|
+
if (localConfig2.keys().length === 0) {
|
|
106469
106509
|
throw new Error(
|
|
106470
106510
|
"No appwrite.config.json file found in the current directory. Please run this command again in the folder containing your appwrite.config.json file, or run 'appwrite init project' to link current directory to an Appwrite project."
|
|
106471
106511
|
);
|
|
@@ -106613,7 +106653,7 @@ var Config = class {
|
|
|
106613
106653
|
try {
|
|
106614
106654
|
const file2 = import_fs2.default.readFileSync(this.path).toString();
|
|
106615
106655
|
this.data = JSONBig.parse(file2);
|
|
106616
|
-
} catch (
|
|
106656
|
+
} catch (_e) {
|
|
106617
106657
|
this.data = {};
|
|
106618
106658
|
}
|
|
106619
106659
|
}
|
|
@@ -132237,6 +132277,22 @@ var cliConfig = {
|
|
|
132237
132277
|
report: false,
|
|
132238
132278
|
reportData: {}
|
|
132239
132279
|
};
|
|
132280
|
+
var toJsonObject = (value) => {
|
|
132281
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
132282
|
+
return value;
|
|
132283
|
+
}
|
|
132284
|
+
return null;
|
|
132285
|
+
};
|
|
132286
|
+
var extractReportCommandArgs = (value) => {
|
|
132287
|
+
if (!value || typeof value !== "object") {
|
|
132288
|
+
return [];
|
|
132289
|
+
}
|
|
132290
|
+
const reportData = value;
|
|
132291
|
+
if (!Array.isArray(reportData.data?.args)) {
|
|
132292
|
+
return [];
|
|
132293
|
+
}
|
|
132294
|
+
return reportData.data.args;
|
|
132295
|
+
};
|
|
132240
132296
|
var parse3 = (data) => {
|
|
132241
132297
|
if (cliConfig.json) {
|
|
132242
132298
|
drawJSON(data);
|
|
@@ -132257,7 +132313,8 @@ var parse3 = (data) => {
|
|
|
132257
132313
|
console.log(`${import_chalk.default.yellow.bold(key)} : ${data[key]}`);
|
|
132258
132314
|
} else {
|
|
132259
132315
|
console.log(`${import_chalk.default.yellow.bold.underline(key)}`);
|
|
132260
|
-
|
|
132316
|
+
const tableRow = toJsonObject(data[key]) ?? {};
|
|
132317
|
+
drawTable([tableRow]);
|
|
132261
132318
|
}
|
|
132262
132319
|
} else {
|
|
132263
132320
|
console.log(`${import_chalk.default.yellow.bold(key)} : ${data[key]}`);
|
|
@@ -132269,9 +132326,7 @@ var drawTable = (data) => {
|
|
|
132269
132326
|
console.log("[]");
|
|
132270
132327
|
return;
|
|
132271
132328
|
}
|
|
132272
|
-
const rows = data.map(
|
|
132273
|
-
(item) => item && typeof item === "object" && !Array.isArray(item) ? item : {}
|
|
132274
|
-
);
|
|
132329
|
+
const rows = data.map((item) => toJsonObject(item) ?? {});
|
|
132275
132330
|
const obj = rows.reduce((res, item) => ({ ...res, ...item }), {});
|
|
132276
132331
|
const keys = Object.keys(obj);
|
|
132277
132332
|
if (keys.length === 0) {
|
|
@@ -132314,7 +132369,7 @@ var drawTable = (data) => {
|
|
|
132314
132369
|
} else if (typeof row[key] === "object") {
|
|
132315
132370
|
rowValues.push(JSON.stringify(row[key]));
|
|
132316
132371
|
} else {
|
|
132317
|
-
rowValues.push(row[key]);
|
|
132372
|
+
rowValues.push(String(row[key]));
|
|
132318
132373
|
}
|
|
132319
132374
|
}
|
|
132320
132375
|
table.push(rowValues);
|
|
@@ -132326,7 +132381,7 @@ var drawJSON = (data) => {
|
|
|
132326
132381
|
};
|
|
132327
132382
|
var parseError = (err) => {
|
|
132328
132383
|
if (cliConfig.report) {
|
|
132329
|
-
(async () => {
|
|
132384
|
+
void (async () => {
|
|
132330
132385
|
let appwriteVersion = "unknown";
|
|
132331
132386
|
const endpoint = globalConfig2.getEndpoint();
|
|
132332
132387
|
try {
|
|
@@ -132339,7 +132394,8 @@ var parseError = (err) => {
|
|
|
132339
132394
|
} catch {
|
|
132340
132395
|
}
|
|
132341
132396
|
const version4 = SDK_VERSION;
|
|
132342
|
-
const
|
|
132397
|
+
const commandArgs = extractReportCommandArgs(cliConfig.reportData);
|
|
132398
|
+
const stepsToReproduce = `Running \`${EXECUTABLE_NAME} ${commandArgs.join(" ")}\``;
|
|
132343
132399
|
const yourEnvironment = `CLI version: ${version4}
|
|
132344
132400
|
Operation System: ${import_os2.default.type()}
|
|
132345
132401
|
Appwrite version: ${appwriteVersion}
|
|
@@ -132391,7 +132447,7 @@ var actionRunner = (fn) => {
|
|
|
132391
132447
|
error48(`The '--all' and '--id' flags cannot be used together.`);
|
|
132392
132448
|
process.exit(1);
|
|
132393
132449
|
}
|
|
132394
|
-
return fn(...args).catch(parseError);
|
|
132450
|
+
return fn(...args).then(() => void 0).catch(parseError);
|
|
132395
132451
|
};
|
|
132396
132452
|
};
|
|
132397
132453
|
var parseInteger = (value) => {
|
|
@@ -132577,19 +132633,22 @@ async function paginate(action, args = {}, limit = 100, wrapper = "", queries =
|
|
|
132577
132633
|
]
|
|
132578
132634
|
});
|
|
132579
132635
|
if (wrapper === "") {
|
|
132580
|
-
|
|
132636
|
+
const listResponse = response;
|
|
132637
|
+
if (listResponse.length === 0) {
|
|
132581
132638
|
break;
|
|
132582
132639
|
}
|
|
132583
|
-
results = results.concat(
|
|
132640
|
+
results = results.concat(listResponse);
|
|
132584
132641
|
} else {
|
|
132585
|
-
|
|
132642
|
+
const wrappedResponse = response;
|
|
132643
|
+
const wrappedResults = wrappedResponse[wrapper] ?? [];
|
|
132644
|
+
if (wrappedResults.length === 0) {
|
|
132645
|
+
break;
|
|
132646
|
+
}
|
|
132647
|
+
results = results.concat(wrappedResults);
|
|
132648
|
+
total = wrappedResponse.total;
|
|
132649
|
+
if (results.length >= total) {
|
|
132586
132650
|
break;
|
|
132587
132651
|
}
|
|
132588
|
-
results = results.concat(response[wrapper]);
|
|
132589
|
-
}
|
|
132590
|
-
total = response.total;
|
|
132591
|
-
if (results.length >= total) {
|
|
132592
|
-
break;
|
|
132593
132652
|
}
|
|
132594
132653
|
pageNumber++;
|
|
132595
132654
|
}
|
|
@@ -132776,7 +132835,7 @@ var questionsInitProject = [
|
|
|
132776
132835
|
name: "organization",
|
|
132777
132836
|
message: "Choose your organization",
|
|
132778
132837
|
choices: async () => {
|
|
132779
|
-
|
|
132838
|
+
const client2 = await sdkForConsole(true);
|
|
132780
132839
|
const { teams: teams2 } = isCloud() ? await paginate(
|
|
132781
132840
|
async (opts = {}) => (await getOrganizationsService(opts.sdk)).list(),
|
|
132782
132841
|
{ sdk: client2 },
|
|
@@ -132788,7 +132847,7 @@ var questionsInitProject = [
|
|
|
132788
132847
|
100,
|
|
132789
132848
|
"teams"
|
|
132790
132849
|
);
|
|
132791
|
-
|
|
132850
|
+
const choices = teams2.map((team, _idx) => {
|
|
132792
132851
|
return {
|
|
132793
132852
|
name: `${team.name} (${team["$id"]})`,
|
|
132794
132853
|
value: team["$id"]
|
|
@@ -132837,7 +132896,7 @@ var questionsInitProject = [
|
|
|
132837
132896
|
"projects",
|
|
132838
132897
|
queries
|
|
132839
132898
|
);
|
|
132840
|
-
|
|
132899
|
+
const choices = projects2.map((project2) => {
|
|
132841
132900
|
return {
|
|
132842
132901
|
name: `${project2.name} (${project2["$id"]})`,
|
|
132843
132902
|
value: {
|
|
@@ -132858,13 +132917,13 @@ var questionsInitProject = [
|
|
|
132858
132917
|
name: "region",
|
|
132859
132918
|
message: `Select your ${SDK_TITLE} Cloud region`,
|
|
132860
132919
|
choices: async () => {
|
|
132861
|
-
|
|
132920
|
+
const client2 = await sdkForConsole(true);
|
|
132862
132921
|
const endpoint = globalConfig2.getEndpoint() || DEFAULT_ENDPOINT;
|
|
132863
|
-
|
|
132922
|
+
const response = await client2.call(
|
|
132864
132923
|
"GET",
|
|
132865
132924
|
new URL(endpoint + "/console/regions")
|
|
132866
132925
|
);
|
|
132867
|
-
|
|
132926
|
+
const regions = response.regions || [];
|
|
132868
132927
|
if (!regions.length) {
|
|
132869
132928
|
throw new Error(
|
|
132870
132929
|
"No regions found. Please check your network or Appwrite Cloud availability."
|
|
@@ -133006,9 +133065,9 @@ var questionsCreateFunction = [
|
|
|
133006
133065
|
name: "runtime",
|
|
133007
133066
|
message: "What runtime would you like to use?",
|
|
133008
133067
|
choices: async () => {
|
|
133009
|
-
|
|
133010
|
-
|
|
133011
|
-
|
|
133068
|
+
const response = await (await getFunctionsService()).listRuntimes();
|
|
133069
|
+
const runtimes = response["runtimes"];
|
|
133070
|
+
const choices = runtimes.map((runtime, _idx) => {
|
|
133012
133071
|
return {
|
|
133013
133072
|
name: `${runtime.name} (${runtime["$id"]})`,
|
|
133014
133073
|
value: {
|
|
@@ -133028,9 +133087,9 @@ var questionsCreateFunction = [
|
|
|
133028
133087
|
name: "specification",
|
|
133029
133088
|
message: "What specification would you like to use?",
|
|
133030
133089
|
choices: async () => {
|
|
133031
|
-
|
|
133032
|
-
|
|
133033
|
-
|
|
133090
|
+
const response = await (await getFunctionsService()).listSpecifications();
|
|
133091
|
+
const specifications = response["specifications"];
|
|
133092
|
+
const choices = specifications.map((spec, _idx) => {
|
|
133034
133093
|
return {
|
|
133035
133094
|
name: `${spec.cpus} CPU, ${spec.memory}MB RAM`,
|
|
133036
133095
|
value: spec.slug,
|
|
@@ -133107,7 +133166,7 @@ var questionsCreateCollection = [
|
|
|
133107
133166
|
message: "Choose the collection database",
|
|
133108
133167
|
choices: async () => {
|
|
133109
133168
|
const databases2 = localConfig.getDatabases();
|
|
133110
|
-
|
|
133169
|
+
const choices = databases2.map((database, _idx) => {
|
|
133111
133170
|
return {
|
|
133112
133171
|
name: `${database.name} (${database.$id})`,
|
|
133113
133172
|
value: database.$id
|
|
@@ -133171,7 +133230,7 @@ var questionsCreateTable = [
|
|
|
133171
133230
|
message: "Choose the table database",
|
|
133172
133231
|
choices: async () => {
|
|
133173
133232
|
const databases2 = localConfig.getTablesDBs();
|
|
133174
|
-
|
|
133233
|
+
const choices = databases2.map((database, _idx) => {
|
|
133175
133234
|
return {
|
|
133176
133235
|
name: `${database.name} (${database.$id})`,
|
|
133177
133236
|
value: database.$id
|
|
@@ -133305,9 +133364,9 @@ var questionGetEndpoint = [
|
|
|
133305
133364
|
if (!value) {
|
|
133306
133365
|
return "Please enter a valid endpoint.";
|
|
133307
133366
|
}
|
|
133308
|
-
|
|
133367
|
+
const client2 = new Client().setEndpoint(value);
|
|
133309
133368
|
try {
|
|
133310
|
-
|
|
133369
|
+
const response = await client2.call(
|
|
133311
133370
|
"get",
|
|
133312
133371
|
new URL(value + "/health/version")
|
|
133313
133372
|
);
|
|
@@ -133316,7 +133375,7 @@ var questionGetEndpoint = [
|
|
|
133316
133375
|
} else {
|
|
133317
133376
|
throw new Error();
|
|
133318
133377
|
}
|
|
133319
|
-
} catch (
|
|
133378
|
+
} catch (_error) {
|
|
133320
133379
|
return "Invalid endpoint or your Appwrite server is not running as expected.";
|
|
133321
133380
|
}
|
|
133322
133381
|
}
|
|
@@ -133394,9 +133453,9 @@ var questionsPushSites = [
|
|
|
133394
133453
|
validate: (value) => validateRequired("site", value),
|
|
133395
133454
|
when: () => localConfig.getSites().length > 0,
|
|
133396
133455
|
choices: () => {
|
|
133397
|
-
|
|
133456
|
+
const sites2 = localConfig.getSites();
|
|
133398
133457
|
checkDeployConditions(localConfig);
|
|
133399
|
-
|
|
133458
|
+
const choices = sites2.map((site, _idx) => {
|
|
133400
133459
|
return {
|
|
133401
133460
|
name: `${site.name} (${site.$id})`,
|
|
133402
133461
|
value: site.$id
|
|
@@ -133414,9 +133473,9 @@ var questionsPushFunctions = [
|
|
|
133414
133473
|
validate: (value) => validateRequired("function", value),
|
|
133415
133474
|
when: () => localConfig.getFunctions().length > 0,
|
|
133416
133475
|
choices: () => {
|
|
133417
|
-
|
|
133476
|
+
const functions2 = localConfig.getFunctions();
|
|
133418
133477
|
checkDeployConditions(localConfig);
|
|
133419
|
-
|
|
133478
|
+
const choices = functions2.map((func, _idx) => {
|
|
133420
133479
|
return {
|
|
133421
133480
|
name: `${func.name} (${func.$id})`,
|
|
133422
133481
|
value: func.$id
|
|
@@ -133434,7 +133493,7 @@ var questionsPushCollections = [
|
|
|
133434
133493
|
validate: (value) => validateRequired("collection", value),
|
|
133435
133494
|
when: () => localConfig.getCollections().length > 0,
|
|
133436
133495
|
choices: () => {
|
|
133437
|
-
|
|
133496
|
+
const collections = localConfig.getCollections();
|
|
133438
133497
|
checkDeployConditions(localConfig);
|
|
133439
133498
|
return collections.map((collection) => {
|
|
133440
133499
|
return {
|
|
@@ -133453,7 +133512,7 @@ var questionsPushTables = [
|
|
|
133453
133512
|
validate: (value) => validateRequired("table", value),
|
|
133454
133513
|
when: () => localConfig.getTables().length > 0,
|
|
133455
133514
|
choices: () => {
|
|
133456
|
-
|
|
133515
|
+
const tables = localConfig.getTables();
|
|
133457
133516
|
checkDeployConditions(localConfig);
|
|
133458
133517
|
return tables.map((table) => {
|
|
133459
133518
|
return {
|
|
@@ -133486,7 +133545,7 @@ var questionsPushBuckets = [
|
|
|
133486
133545
|
validate: (value) => validateRequired("bucket", value),
|
|
133487
133546
|
when: () => localConfig.getBuckets().length > 0,
|
|
133488
133547
|
choices: () => {
|
|
133489
|
-
|
|
133548
|
+
const buckets = localConfig.getBuckets();
|
|
133490
133549
|
checkDeployConditions(localConfig);
|
|
133491
133550
|
return buckets.map((bucket) => {
|
|
133492
133551
|
return {
|
|
@@ -133505,7 +133564,7 @@ var questionsPushMessagingTopics = [
|
|
|
133505
133564
|
validate: (value) => validateRequired("topics", value),
|
|
133506
133565
|
when: () => localConfig.getMessagingTopics().length > 0,
|
|
133507
133566
|
choices: () => {
|
|
133508
|
-
|
|
133567
|
+
const topics = localConfig.getMessagingTopics();
|
|
133509
133568
|
return topics.map((topic) => {
|
|
133510
133569
|
return {
|
|
133511
133570
|
name: `${topic.name} (${topic["$id"]})`,
|
|
@@ -133536,7 +133595,7 @@ var questionsPushTeams = [
|
|
|
133536
133595
|
validate: (value) => validateRequired("team", value),
|
|
133537
133596
|
when: () => localConfig.getTeams().length > 0,
|
|
133538
133597
|
choices: () => {
|
|
133539
|
-
|
|
133598
|
+
const teams2 = localConfig.getTeams();
|
|
133540
133599
|
checkDeployConditions(localConfig);
|
|
133541
133600
|
return teams2.map((team) => {
|
|
133542
133601
|
return {
|
|
@@ -133553,7 +133612,7 @@ var questionsListFactors = [
|
|
|
133553
133612
|
name: "factor",
|
|
133554
133613
|
message: "Your account is protected by multi-factor authentication. Please choose one for verification.",
|
|
133555
133614
|
choices: async () => {
|
|
133556
|
-
|
|
133615
|
+
const client2 = await sdkForConsole(false);
|
|
133557
133616
|
const accountClient2 = new Account(client2);
|
|
133558
133617
|
const factors = await accountClient2.listMfaFactors();
|
|
133559
133618
|
const choices = [
|
|
@@ -133598,13 +133657,13 @@ var questionsRunFunctions = [
|
|
|
133598
133657
|
message: "Which function would you like to develop locally?",
|
|
133599
133658
|
validate: (value) => validateRequired("function", value),
|
|
133600
133659
|
choices: () => {
|
|
133601
|
-
|
|
133660
|
+
const functions2 = localConfig.getFunctions();
|
|
133602
133661
|
if (functions2.length === 0) {
|
|
133603
133662
|
throw new Error(
|
|
133604
133663
|
`No functions found. Use '${EXECUTABLE_NAME} pull functions' to synchronize existing one, or use '${EXECUTABLE_NAME} init function' to create a new one.`
|
|
133605
133664
|
);
|
|
133606
133665
|
}
|
|
133607
|
-
|
|
133666
|
+
const choices = functions2.map((func, _idx) => {
|
|
133608
133667
|
return {
|
|
133609
133668
|
name: `${func.name} (${func.$id})`,
|
|
133610
133669
|
value: func.$id
|
|
@@ -133632,9 +133691,9 @@ var questionsCreateSite = [
|
|
|
133632
133691
|
name: "framework",
|
|
133633
133692
|
message: "What framework would you like to use?",
|
|
133634
133693
|
choices: async () => {
|
|
133635
|
-
|
|
133636
|
-
|
|
133637
|
-
|
|
133694
|
+
const response = await (await getSitesService()).listFrameworks();
|
|
133695
|
+
const frameworks = response["frameworks"];
|
|
133696
|
+
const choices = frameworks.map((framework) => {
|
|
133638
133697
|
return {
|
|
133639
133698
|
name: `${framework.name} (${framework.key})`,
|
|
133640
133699
|
value: framework
|
|
@@ -133648,9 +133707,9 @@ var questionsCreateSite = [
|
|
|
133648
133707
|
name: "specification",
|
|
133649
133708
|
message: "What specification would you like to use?",
|
|
133650
133709
|
choices: async () => {
|
|
133651
|
-
|
|
133652
|
-
|
|
133653
|
-
|
|
133710
|
+
const response = await (await getSitesService()).listSpecifications();
|
|
133711
|
+
const specifications = response["specifications"];
|
|
133712
|
+
const choices = specifications.map((spec) => {
|
|
133654
133713
|
return {
|
|
133655
133714
|
name: `${spec.cpus} CPU, ${spec.memory}MB RAM`,
|
|
133656
133715
|
value: spec.slug,
|
|
@@ -133834,7 +133893,7 @@ var Client3 = class _Client {
|
|
|
133834
133893
|
let json3 = void 0;
|
|
133835
133894
|
try {
|
|
133836
133895
|
json3 = JSON.parse(text2);
|
|
133837
|
-
} catch (
|
|
133896
|
+
} catch (_error) {
|
|
133838
133897
|
throw new AppwriteException(text2, response.status, "", text2);
|
|
133839
133898
|
}
|
|
133840
133899
|
if (path16 !== "/account" && json3.code === 401 && json3.type === "user_more_factors_required") {
|
|
@@ -133868,7 +133927,7 @@ var Client3 = class _Client {
|
|
|
133868
133927
|
let json2 = void 0;
|
|
133869
133928
|
try {
|
|
133870
133929
|
json2 = JSONBig.parse(text);
|
|
133871
|
-
} catch (
|
|
133930
|
+
} catch (_error) {
|
|
133872
133931
|
return text;
|
|
133873
133932
|
}
|
|
133874
133933
|
return json2;
|
|
@@ -133939,11 +133998,11 @@ var completeMfaLogin = async ({
|
|
|
133939
133998
|
};
|
|
133940
133999
|
var deleteServerSession = async (sessionId) => {
|
|
133941
134000
|
try {
|
|
133942
|
-
|
|
133943
|
-
|
|
134001
|
+
const client2 = await sdkForConsole();
|
|
134002
|
+
const accountClient2 = new Account(client2);
|
|
133944
134003
|
await accountClient2.deleteSession(sessionId);
|
|
133945
134004
|
return true;
|
|
133946
|
-
} catch (
|
|
134005
|
+
} catch (_e) {
|
|
133947
134006
|
return false;
|
|
133948
134007
|
}
|
|
133949
134008
|
};
|
|
@@ -134028,7 +134087,7 @@ var loginCommand = async ({
|
|
|
134028
134087
|
globalConfig2.setEndpoint(configEndpoint);
|
|
134029
134088
|
globalConfig2.setEmail(answers.email);
|
|
134030
134089
|
const legacyClient = createLegacyConsoleClient(configEndpoint);
|
|
134031
|
-
|
|
134090
|
+
const client2 = await sdkForConsole(false);
|
|
134032
134091
|
let accountClient2 = new Account(client2);
|
|
134033
134092
|
let account2;
|
|
134034
134093
|
try {
|
|
@@ -134078,8 +134137,8 @@ var whoami = new Command("whoami").description(commandDescriptions["whoami"]).ac
|
|
|
134078
134137
|
error48("No user is signed in. To sign in, run 'appwrite login'");
|
|
134079
134138
|
return;
|
|
134080
134139
|
}
|
|
134081
|
-
|
|
134082
|
-
|
|
134140
|
+
const client2 = await sdkForConsole(false);
|
|
134141
|
+
const accountClient2 = new Account(client2);
|
|
134083
134142
|
let account2;
|
|
134084
134143
|
try {
|
|
134085
134144
|
account2 = await accountClient2.get();
|
|
@@ -134203,7 +134262,7 @@ var client = new Command("client").description(commandDescriptions["client"]).co
|
|
|
134203
134262
|
const tail = cookieValue.length > 8 ? cookieValue.slice(-8) : cookieValue || "********";
|
|
134204
134263
|
maskedCookie = `${cookieName}=...${tail}`;
|
|
134205
134264
|
}
|
|
134206
|
-
|
|
134265
|
+
const config2 = {
|
|
134207
134266
|
endpoint: globalConfig2.getEndpoint(),
|
|
134208
134267
|
key: maskedKey,
|
|
134209
134268
|
cookie: maskedCookie,
|
|
@@ -134216,16 +134275,16 @@ var client = new Command("client").description(commandDescriptions["client"]).co
|
|
|
134216
134275
|
if (endpoint !== void 0) {
|
|
134217
134276
|
try {
|
|
134218
134277
|
const id = id_default2.unique();
|
|
134219
|
-
|
|
134278
|
+
const url2 = new URL(endpoint);
|
|
134220
134279
|
if (url2.protocol !== "http:" && url2.protocol !== "https:") {
|
|
134221
134280
|
throw new Error();
|
|
134222
134281
|
}
|
|
134223
|
-
|
|
134282
|
+
const clientInstance = new Client().setEndpoint(endpoint);
|
|
134224
134283
|
clientInstance.setProject("console");
|
|
134225
134284
|
if (selfSigned || globalConfig2.getSelfSigned()) {
|
|
134226
134285
|
clientInstance.setSelfSigned(true);
|
|
134227
134286
|
}
|
|
134228
|
-
|
|
134287
|
+
const response = await clientInstance.call(
|
|
134229
134288
|
"GET",
|
|
134230
134289
|
new URL(endpoint + "/health/version")
|
|
134231
134290
|
);
|
|
@@ -134376,6 +134435,9 @@ async function downloadDeploymentCode(params) {
|
|
|
134376
134435
|
{},
|
|
134377
134436
|
"arrayBuffer"
|
|
134378
134437
|
);
|
|
134438
|
+
if (!(downloadBuffer instanceof ArrayBuffer)) {
|
|
134439
|
+
throw new Error("Failed to download deployment archive as ArrayBuffer.");
|
|
134440
|
+
}
|
|
134379
134441
|
try {
|
|
134380
134442
|
import_fs3.default.writeFileSync(compressedFileName, Buffer.from(downloadBuffer));
|
|
134381
134443
|
} catch (err) {
|
|
@@ -134454,7 +134516,7 @@ var getConfirmation = async () => {
|
|
|
134454
134516
|
}
|
|
134455
134517
|
return answers2.changes;
|
|
134456
134518
|
}
|
|
134457
|
-
|
|
134519
|
+
const answers = await import_inquirer2.default.prompt(questionPushChanges);
|
|
134458
134520
|
if (answers.changes !== "YES" && answers.changes !== "NO") {
|
|
134459
134521
|
answers.changes = await fixConfirmation();
|
|
134460
134522
|
}
|
|
@@ -134504,7 +134566,7 @@ var approveChanges = async (resource, resourceGetFunction, keys, resourceName, r
|
|
|
134504
134566
|
options[secondResourceName] = localResource[secondId];
|
|
134505
134567
|
}
|
|
134506
134568
|
const remoteResource = await resourceGetFunction(options);
|
|
134507
|
-
for (
|
|
134569
|
+
for (const [key, value] of Object.entries(
|
|
134508
134570
|
whitelistKeys(remoteResource, keys)
|
|
134509
134571
|
)) {
|
|
134510
134572
|
if (skipKeys.includes(key)) {
|
|
@@ -134513,28 +134575,30 @@ var approveChanges = async (resource, resourceGetFunction, keys, resourceName, r
|
|
|
134513
134575
|
if (isEmpty(value) && isEmpty(localResource[key])) {
|
|
134514
134576
|
continue;
|
|
134515
134577
|
}
|
|
134516
|
-
|
|
134517
|
-
|
|
134578
|
+
const localValue = localResource[key];
|
|
134579
|
+
if (Array.isArray(value) && Array.isArray(localValue)) {
|
|
134580
|
+
if (JSON.stringify(value) !== JSON.stringify(localValue)) {
|
|
134518
134581
|
changes.push({
|
|
134519
134582
|
id: localResource["$id"],
|
|
134520
134583
|
key,
|
|
134521
134584
|
remote: import_chalk4.default.red(value.join("\n")),
|
|
134522
|
-
local: import_chalk4.default.green(
|
|
134585
|
+
local: import_chalk4.default.green(
|
|
134586
|
+
localValue.map((entry) => String(entry)).join("\n")
|
|
134587
|
+
)
|
|
134523
134588
|
});
|
|
134524
134589
|
}
|
|
134525
|
-
} else if (value !==
|
|
134590
|
+
} else if (value !== localValue) {
|
|
134526
134591
|
changes.push({
|
|
134527
134592
|
id: localResource["$id"],
|
|
134528
134593
|
key,
|
|
134529
|
-
remote: import_chalk4.default.red(value),
|
|
134530
|
-
local: import_chalk4.default.green(
|
|
134594
|
+
remote: import_chalk4.default.red(String(value ?? "")),
|
|
134595
|
+
local: import_chalk4.default.green(String(localValue ?? ""))
|
|
134531
134596
|
});
|
|
134532
134597
|
}
|
|
134533
134598
|
}
|
|
134534
134599
|
} catch (e) {
|
|
134535
|
-
|
|
134536
|
-
|
|
134537
|
-
}
|
|
134600
|
+
const isNotFound = e instanceof AppwriteException && Number(e.code) === 404;
|
|
134601
|
+
if (!isNotFound) throw e;
|
|
134538
134602
|
}
|
|
134539
134603
|
})
|
|
134540
134604
|
);
|
|
@@ -135057,7 +135121,7 @@ var pullResources = async ({
|
|
|
135057
135121
|
delete actions.collections;
|
|
135058
135122
|
}
|
|
135059
135123
|
if (cliConfig.all) {
|
|
135060
|
-
for (
|
|
135124
|
+
for (const action of Object.values(actions)) {
|
|
135061
135125
|
cliConfig.all = true;
|
|
135062
135126
|
await action({ returnOnZero: true });
|
|
135063
135127
|
}
|
|
@@ -135296,7 +135360,6 @@ var initProject = async ({
|
|
|
135296
135360
|
projectId,
|
|
135297
135361
|
projectName
|
|
135298
135362
|
} = {}) => {
|
|
135299
|
-
let response = {};
|
|
135300
135363
|
try {
|
|
135301
135364
|
if (globalConfig2.getEndpoint() === "" || globalConfig2.getCookie() === "") {
|
|
135302
135365
|
throw new Error(
|
|
@@ -135306,33 +135369,39 @@ var initProject = async ({
|
|
|
135306
135369
|
const client2 = await sdkForConsole();
|
|
135307
135370
|
const accountClient2 = new Account(client2);
|
|
135308
135371
|
await accountClient2.get();
|
|
135309
|
-
} catch (
|
|
135372
|
+
} catch (_e) {
|
|
135310
135373
|
error48(
|
|
135311
135374
|
`Error Session not found. Please run '${EXECUTABLE_NAME} login' to create a session`
|
|
135312
135375
|
);
|
|
135313
135376
|
process.exit(1);
|
|
135314
135377
|
}
|
|
135315
|
-
let answers
|
|
135378
|
+
let answers;
|
|
135316
135379
|
if (!organizationId && !projectId && !projectName) {
|
|
135317
135380
|
answers = await import_inquirer4.default.prompt(questionsInitProject);
|
|
135318
135381
|
if (answers.override === false) {
|
|
135319
135382
|
process.exit(1);
|
|
135320
135383
|
}
|
|
135321
135384
|
} else {
|
|
135322
|
-
|
|
135323
|
-
|
|
135324
|
-
|
|
135325
|
-
answers
|
|
135326
|
-
|
|
135327
|
-
|
|
135385
|
+
const selectedOrganization = organizationId ?? (await import_inquirer4.default.prompt([questionsInitProject[2]])).organization;
|
|
135386
|
+
const selectedProjectName = projectName ?? (await import_inquirer4.default.prompt([questionsInitProject[3]])).project;
|
|
135387
|
+
const selectedProjectId = projectId ?? (await import_inquirer4.default.prompt([questionsInitProject[4]])).id;
|
|
135388
|
+
answers = {
|
|
135389
|
+
start: "existing",
|
|
135390
|
+
project: selectedProjectId,
|
|
135391
|
+
organization: selectedOrganization
|
|
135392
|
+
};
|
|
135328
135393
|
try {
|
|
135329
135394
|
const projectsService = await getProjectsService();
|
|
135330
|
-
await projectsService.get(
|
|
135395
|
+
const existingProject = await projectsService.get(selectedProjectId);
|
|
135396
|
+
answers.project = existingProject;
|
|
135331
135397
|
} catch (e) {
|
|
135332
|
-
if (e.code === 404) {
|
|
135333
|
-
answers
|
|
135334
|
-
|
|
135335
|
-
|
|
135398
|
+
if (e instanceof AppwriteException && e.code === 404) {
|
|
135399
|
+
answers = {
|
|
135400
|
+
start: "new",
|
|
135401
|
+
id: selectedProjectId,
|
|
135402
|
+
project: selectedProjectName,
|
|
135403
|
+
organization: selectedOrganization
|
|
135404
|
+
};
|
|
135336
135405
|
} else {
|
|
135337
135406
|
throw e;
|
|
135338
135407
|
}
|
|
@@ -135341,10 +135410,26 @@ var initProject = async ({
|
|
|
135341
135410
|
localConfig.clear();
|
|
135342
135411
|
const url2 = new URL(DEFAULT_ENDPOINT);
|
|
135343
135412
|
if (answers.start === "new") {
|
|
135413
|
+
let projectIdToCreate;
|
|
135414
|
+
let projectNameToCreate;
|
|
135415
|
+
switch (typeof answers.project) {
|
|
135416
|
+
case "string":
|
|
135417
|
+
projectIdToCreate = answers.id ?? answers.project;
|
|
135418
|
+
projectNameToCreate = answers.project;
|
|
135419
|
+
break;
|
|
135420
|
+
case "object":
|
|
135421
|
+
projectIdToCreate = answers.id ?? answers.project.$id;
|
|
135422
|
+
projectNameToCreate = answers.project.name ?? answers.project.$id;
|
|
135423
|
+
break;
|
|
135424
|
+
default:
|
|
135425
|
+
projectIdToCreate = answers.id;
|
|
135426
|
+
projectNameToCreate = "";
|
|
135427
|
+
break;
|
|
135428
|
+
}
|
|
135344
135429
|
const projectsService = await getProjectsService();
|
|
135345
|
-
response = await projectsService.create(
|
|
135346
|
-
|
|
135347
|
-
|
|
135430
|
+
const response = await projectsService.create(
|
|
135431
|
+
projectIdToCreate,
|
|
135432
|
+
projectNameToCreate,
|
|
135348
135433
|
answers.organization,
|
|
135349
135434
|
answers.region
|
|
135350
135435
|
);
|
|
@@ -135355,10 +135440,22 @@ var initProject = async ({
|
|
|
135355
135440
|
);
|
|
135356
135441
|
}
|
|
135357
135442
|
} else {
|
|
135358
|
-
|
|
135359
|
-
|
|
135443
|
+
let selectedProject;
|
|
135444
|
+
switch (typeof answers.project) {
|
|
135445
|
+
case "string":
|
|
135446
|
+
selectedProject = { $id: answers.project };
|
|
135447
|
+
break;
|
|
135448
|
+
case "object":
|
|
135449
|
+
selectedProject = answers.project;
|
|
135450
|
+
break;
|
|
135451
|
+
default:
|
|
135452
|
+
selectedProject = { $id: "" };
|
|
135453
|
+
break;
|
|
135454
|
+
}
|
|
135455
|
+
localConfig.setProject(selectedProject.$id);
|
|
135456
|
+
if (isCloud() && selectedProject.region) {
|
|
135360
135457
|
localConfig.setEndpoint(
|
|
135361
|
-
`https://${
|
|
135458
|
+
`https://${selectedProject.region}.${url2.host}${url2.pathname}`
|
|
135362
135459
|
);
|
|
135363
135460
|
}
|
|
135364
135461
|
}
|
|
@@ -135366,8 +135463,10 @@ var initProject = async ({
|
|
|
135366
135463
|
`Project successfully ${answers.start === "existing" ? "linked" : "created"}. Details are now stored in appwrite.config.json file.`
|
|
135367
135464
|
);
|
|
135368
135465
|
if (answers.start === "existing") {
|
|
135369
|
-
|
|
135370
|
-
|
|
135466
|
+
const autopullAnswers = await import_inquirer4.default.prompt(
|
|
135467
|
+
questionsInitProjectAutopull
|
|
135468
|
+
);
|
|
135469
|
+
if (autopullAnswers.autopull) {
|
|
135371
135470
|
cliConfig.all = true;
|
|
135372
135471
|
cliConfig.force = true;
|
|
135373
135472
|
await pullResources({
|
|
@@ -135507,7 +135606,6 @@ var initFunction = async () => {
|
|
|
135507
135606
|
import_fs5.default.mkdirSync(functionDir, { mode: 511 });
|
|
135508
135607
|
import_fs5.default.mkdirSync(templatesDir, { mode: 511 });
|
|
135509
135608
|
const repo = "https://github.com/appwrite/templates";
|
|
135510
|
-
const api = `https://api.github.com/repos/appwrite/templates/contents/${answers.runtime.name}`;
|
|
135511
135609
|
let selected = { template: "starter" };
|
|
135512
135610
|
const sparse = (selected ? `${answers.runtime.name}/${selected.template}` : answers.runtime.name).toLowerCase();
|
|
135513
135611
|
let gitInitCommands = `git clone --single-branch --depth 1 --sparse ${repo} .`;
|
|
@@ -135526,17 +135624,18 @@ var initFunction = async () => {
|
|
|
135526
135624
|
cwd: templatesDir
|
|
135527
135625
|
});
|
|
135528
135626
|
} catch (err) {
|
|
135529
|
-
|
|
135627
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
135628
|
+
if (errorMessage.includes("error: unknown option")) {
|
|
135530
135629
|
throw new Error(
|
|
135531
|
-
`${
|
|
135630
|
+
`${errorMessage}
|
|
135532
135631
|
|
|
135533
135632
|
Suggestion: Try updating your git to the latest version, then trying to run this command again.`
|
|
135534
135633
|
);
|
|
135535
|
-
} else if (
|
|
135634
|
+
} else if (errorMessage.includes(
|
|
135536
135635
|
"is not recognized as an internal or external command,"
|
|
135537
|
-
) ||
|
|
135636
|
+
) || errorMessage.includes("command not found")) {
|
|
135538
135637
|
throw new Error(
|
|
135539
|
-
`${
|
|
135638
|
+
`${errorMessage}
|
|
135540
135639
|
|
|
135541
135640
|
Suggestion: It appears that git is not installed, try installing git then trying to run this command again.`
|
|
135542
135641
|
);
|
|
@@ -135558,9 +135657,9 @@ Suggestion: It appears that git is not installed, try installing git then trying
|
|
|
135558
135657
|
}
|
|
135559
135658
|
}
|
|
135560
135659
|
const copyRecursiveSync = (src, dest) => {
|
|
135561
|
-
|
|
135562
|
-
|
|
135563
|
-
|
|
135660
|
+
const exists = import_fs5.default.existsSync(src);
|
|
135661
|
+
const stats = exists && import_fs5.default.statSync(src);
|
|
135662
|
+
const isDirectory = exists && stats && stats.isDirectory();
|
|
135564
135663
|
if (isDirectory) {
|
|
135565
135664
|
if (!import_fs5.default.existsSync(dest)) {
|
|
135566
135665
|
import_fs5.default.mkdirSync(dest);
|
|
@@ -135588,7 +135687,7 @@ Suggestion: It appears that git is not installed, try installing git then trying
|
|
|
135588
135687
|
newReadmeFile[0] = `# ${answers.name}`;
|
|
135589
135688
|
newReadmeFile.splice(1, 2);
|
|
135590
135689
|
import_fs5.default.writeFileSync(readmePath, newReadmeFile.join("\n"));
|
|
135591
|
-
|
|
135690
|
+
const data = {
|
|
135592
135691
|
$id: functionId,
|
|
135593
135692
|
name: answers.name,
|
|
135594
135693
|
runtime: answers.runtime.id,
|
|
@@ -135644,14 +135743,15 @@ var initSite = async () => {
|
|
|
135644
135743
|
}
|
|
135645
135744
|
templateDetails = response.templates[0];
|
|
135646
135745
|
} catch (err) {
|
|
135746
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
135647
135747
|
throw new Error(
|
|
135648
|
-
`Failed to fetch template for framework ${answers.framework.key}: ${
|
|
135748
|
+
`Failed to fetch template for framework ${answers.framework.key}: ${errorMessage}`
|
|
135649
135749
|
);
|
|
135650
135750
|
}
|
|
135651
135751
|
import_fs5.default.mkdirSync(siteDir, { mode: 511 });
|
|
135652
135752
|
import_fs5.default.mkdirSync(templatesDir, { mode: 511 });
|
|
135653
135753
|
const repo = `https://github.com/${templateDetails.providerOwner}/${templateDetails.providerRepositoryId}`;
|
|
135654
|
-
|
|
135754
|
+
const selected = {
|
|
135655
135755
|
template: templateDetails.frameworks[0].providerRootDirectory
|
|
135656
135756
|
};
|
|
135657
135757
|
let dirSetupCommands = "";
|
|
@@ -135676,12 +135776,12 @@ var initSite = async () => {
|
|
|
135676
135776
|
git config remote.origin.tagopt --no-tags
|
|
135677
135777
|
`.trim();
|
|
135678
135778
|
}
|
|
135679
|
-
|
|
135779
|
+
const windowsGitCloneCommands = `
|
|
135680
135780
|
$tag = (git ls-remote --tags origin "${templateDetails.providerVersion}" | Select-Object -Last 1) -replace '.*refs/tags/', ''
|
|
135681
135781
|
git fetch --depth=1 origin "refs/tags/$tag"
|
|
135682
135782
|
git checkout FETCH_HEAD
|
|
135683
135783
|
`.trim();
|
|
135684
|
-
|
|
135784
|
+
const unixGitCloneCommands = `
|
|
135685
135785
|
git fetch --depth=1 origin refs/tags/$(git ls-remote --tags origin "${templateDetails.providerVersion}" | tail -n 1 | awk -F '/' '{print $3}')
|
|
135686
135786
|
git checkout FETCH_HEAD
|
|
135687
135787
|
`.trim();
|
|
@@ -135699,17 +135799,18 @@ var initSite = async () => {
|
|
|
135699
135799
|
shell: usedShell
|
|
135700
135800
|
});
|
|
135701
135801
|
} catch (err) {
|
|
135702
|
-
|
|
135802
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
135803
|
+
if (errorMessage.includes("error: unknown option")) {
|
|
135703
135804
|
throw new Error(
|
|
135704
|
-
`${
|
|
135805
|
+
`${errorMessage}
|
|
135705
135806
|
|
|
135706
135807
|
Suggestion: Try updating your git to the latest version, then trying to run this command again.`
|
|
135707
135808
|
);
|
|
135708
|
-
} else if (
|
|
135809
|
+
} else if (errorMessage.includes(
|
|
135709
135810
|
"is not recognized as an internal or external command,"
|
|
135710
|
-
) ||
|
|
135811
|
+
) || errorMessage.includes("command not found")) {
|
|
135711
135812
|
throw new Error(
|
|
135712
|
-
`${
|
|
135813
|
+
`${errorMessage}
|
|
135713
135814
|
|
|
135714
135815
|
Suggestion: It appears that git is not installed, try installing git then trying to run this command again.`
|
|
135715
135816
|
);
|
|
@@ -135730,24 +135831,22 @@ Suggestion: It appears that git is not installed, try installing git then trying
|
|
|
135730
135831
|
newReadmeFile[0] = `# ${answers.name}`;
|
|
135731
135832
|
newReadmeFile.splice(1, 2);
|
|
135732
135833
|
import_fs5.default.writeFileSync(readmePath, newReadmeFile.join("\n"));
|
|
135733
|
-
|
|
135734
|
-
|
|
135834
|
+
const vars = {};
|
|
135835
|
+
for (const variable of templateDetails.variables ?? []) {
|
|
135836
|
+
let value = variable.value ?? "";
|
|
135735
135837
|
const replacements = {
|
|
135736
135838
|
"{apiEndpoint}": globalConfig2.getEndpoint(),
|
|
135737
|
-
"{projectId}": localConfig.getProject().projectId,
|
|
135738
|
-
"{projectName}": localConfig.getProject().projectName
|
|
135839
|
+
"{projectId}": localConfig.getProject().projectId ?? "",
|
|
135840
|
+
"{projectName}": localConfig.getProject().projectName ?? ""
|
|
135739
135841
|
};
|
|
135740
135842
|
for (const placeholder in replacements) {
|
|
135741
|
-
if (value
|
|
135843
|
+
if (value.includes(placeholder)) {
|
|
135742
135844
|
value = value.replace(placeholder, replacements[placeholder]);
|
|
135743
135845
|
}
|
|
135744
135846
|
}
|
|
135745
|
-
|
|
135746
|
-
|
|
135747
|
-
|
|
135748
|
-
};
|
|
135749
|
-
});
|
|
135750
|
-
let data = {
|
|
135847
|
+
vars[variable.name] = value;
|
|
135848
|
+
}
|
|
135849
|
+
const data = {
|
|
135751
135850
|
$id: siteId,
|
|
135752
135851
|
name: answers.name,
|
|
135753
135852
|
framework: answers.framework.key,
|
|
@@ -137214,12 +137313,10 @@ var typesCommand = actionRunner(
|
|
|
137214
137313
|
log(`Directory: ${outputDirectory} does not exist, creating...`);
|
|
137215
137314
|
import_fs9.default.mkdirSync(outputDirectory, { recursive: true });
|
|
137216
137315
|
}
|
|
137217
|
-
|
|
137316
|
+
const tables = localConfig.getTables();
|
|
137218
137317
|
let collections = [];
|
|
137219
|
-
let dataSource = "tables";
|
|
137220
137318
|
if (tables.length === 0) {
|
|
137221
137319
|
collections = localConfig.getCollections();
|
|
137222
|
-
dataSource = "collections";
|
|
137223
137320
|
if (collections.length === 0) {
|
|
137224
137321
|
const configFileName = import_path9.default.basename(localConfig.path);
|
|
137225
137322
|
throw new Error(
|
|
@@ -137674,9 +137771,8 @@ async function dockerStart(func, variables, port) {
|
|
|
137674
137771
|
try {
|
|
137675
137772
|
await waitUntilPortOpen(port);
|
|
137676
137773
|
} catch (err) {
|
|
137677
|
-
|
|
137678
|
-
|
|
137679
|
-
);
|
|
137774
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
137775
|
+
error48(`Failed to start function with error: ${message}`);
|
|
137680
137776
|
return;
|
|
137681
137777
|
}
|
|
137682
137778
|
success2(`Visit http://localhost:${port}/ to execute your function.`);
|
|
@@ -137843,7 +137939,7 @@ var runFunction = async ({
|
|
|
137843
137939
|
});
|
|
137844
137940
|
} catch (err) {
|
|
137845
137941
|
warn(
|
|
137846
|
-
"Remote variables not fetched. Production environment variables will not be available. Reason: " + err
|
|
137942
|
+
"Remote variables not fetched. Production environment variables will not be available. Reason: " + getErrorMessage(err)
|
|
137847
137943
|
);
|
|
137848
137944
|
}
|
|
137849
137945
|
}
|
|
@@ -137867,7 +137963,7 @@ var runFunction = async ({
|
|
|
137867
137963
|
await JwtManager.setup(userId, func.scopes ?? []);
|
|
137868
137964
|
} catch (err) {
|
|
137869
137965
|
warn(
|
|
137870
|
-
"Dynamic API key not generated. Header x-appwrite-key will not be set. Reason: " + err
|
|
137966
|
+
"Dynamic API key not generated. Header x-appwrite-key will not be set. Reason: " + getErrorMessage(err)
|
|
137871
137967
|
);
|
|
137872
137968
|
}
|
|
137873
137969
|
const headers = {};
|
|
@@ -138367,7 +138463,7 @@ var Spinner = class _Spinner {
|
|
|
138367
138463
|
static stop() {
|
|
138368
138464
|
_Spinner.updatesBar.stop();
|
|
138369
138465
|
}
|
|
138370
|
-
static formatter(
|
|
138466
|
+
static formatter(_options, _params, payload) {
|
|
138371
138467
|
const status = payload.status.padEnd(12);
|
|
138372
138468
|
const middle = `${payload.resource} (${payload.id})`.padEnd(40);
|
|
138373
138469
|
let prefix = import_chalk8.default.cyan(payload.prefix ?? "\u29D7");
|
|
@@ -138452,7 +138548,7 @@ var Pools = class {
|
|
|
138452
138548
|
return true;
|
|
138453
138549
|
}
|
|
138454
138550
|
if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
|
|
138455
|
-
|
|
138551
|
+
const steps = Math.max(1, Math.ceil(Number(total) / this.STEP_SIZE));
|
|
138456
138552
|
if (steps > 1 && iteration === 1) {
|
|
138457
138553
|
this.pollMaxDebounces *= steps;
|
|
138458
138554
|
log(
|
|
@@ -138478,7 +138574,7 @@ var Pools = class {
|
|
|
138478
138574
|
return true;
|
|
138479
138575
|
}
|
|
138480
138576
|
if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
|
|
138481
|
-
|
|
138577
|
+
const steps = Math.max(1, Math.ceil(Number(total) / this.STEP_SIZE));
|
|
138482
138578
|
if (steps > 1 && iteration === 1) {
|
|
138483
138579
|
this.pollMaxDebounces *= steps;
|
|
138484
138580
|
log(
|
|
@@ -138494,7 +138590,10 @@ var Pools = class {
|
|
|
138494
138590
|
return false;
|
|
138495
138591
|
}
|
|
138496
138592
|
if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
|
|
138497
|
-
|
|
138593
|
+
const steps = Math.max(
|
|
138594
|
+
1,
|
|
138595
|
+
Math.ceil(attributeKeys.length / this.STEP_SIZE)
|
|
138596
|
+
);
|
|
138498
138597
|
if (steps > 1 && iteration === 1) {
|
|
138499
138598
|
this.pollMaxDebounces *= steps;
|
|
138500
138599
|
log(
|
|
@@ -138537,7 +138636,10 @@ var Pools = class {
|
|
|
138537
138636
|
return false;
|
|
138538
138637
|
}
|
|
138539
138638
|
if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
|
|
138540
|
-
|
|
138639
|
+
const steps = Math.max(
|
|
138640
|
+
1,
|
|
138641
|
+
Math.ceil(attributeKeys.length / this.STEP_SIZE)
|
|
138642
|
+
);
|
|
138541
138643
|
if (steps > 1 && iteration === 1) {
|
|
138542
138644
|
this.pollMaxDebounces *= steps;
|
|
138543
138645
|
log(
|
|
@@ -138586,7 +138688,7 @@ var Pools = class {
|
|
|
138586
138688
|
return false;
|
|
138587
138689
|
}
|
|
138588
138690
|
if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
|
|
138589
|
-
|
|
138691
|
+
const steps = Math.max(1, Math.ceil(indexKeys.length / this.STEP_SIZE));
|
|
138590
138692
|
if (steps > 1 && iteration === 1) {
|
|
138591
138693
|
this.pollMaxDebounces *= steps;
|
|
138592
138694
|
log(
|
|
@@ -138679,7 +138781,7 @@ var Attributes = class {
|
|
|
138679
138781
|
}
|
|
138680
138782
|
return answers2.changes;
|
|
138681
138783
|
}
|
|
138682
|
-
|
|
138784
|
+
const answers = await import_inquirer6.default.prompt(questionPushChanges2);
|
|
138683
138785
|
if (answers.changes !== "YES" && answers.changes !== "NO") {
|
|
138684
138786
|
answers.changes = await fixConfirmation();
|
|
138685
138787
|
}
|
|
@@ -138722,8 +138824,8 @@ var Attributes = class {
|
|
|
138722
138824
|
const keyName = `${import_chalk9.default.yellow(local.key)} in ${collection.name} (${collection["$id"]})`;
|
|
138723
138825
|
const action = import_chalk9.default.cyan(recreating ? "recreating" : "changing");
|
|
138724
138826
|
let reason = "";
|
|
138725
|
-
|
|
138726
|
-
for (
|
|
138827
|
+
const attribute = recreating ? remote : local;
|
|
138828
|
+
for (const key of Object.keys(remote)) {
|
|
138727
138829
|
if (!KeysAttributes.has(key)) {
|
|
138728
138830
|
continue;
|
|
138729
138831
|
}
|
|
@@ -139233,7 +139335,7 @@ var Attributes = class {
|
|
|
139233
139335
|
createIndexes = async (indexes, collection) => {
|
|
139234
139336
|
log(`Creating indexes ...`);
|
|
139235
139337
|
const databasesService = await getDatabasesService(this.client);
|
|
139236
|
-
for (
|
|
139338
|
+
for (const index of indexes) {
|
|
139237
139339
|
await databasesService.createIndex({
|
|
139238
139340
|
databaseId: collection["databaseId"],
|
|
139239
139341
|
collectionId: collection["$id"],
|
|
@@ -139257,7 +139359,7 @@ var Attributes = class {
|
|
|
139257
139359
|
};
|
|
139258
139360
|
createAttributes = async (attributes, collection) => {
|
|
139259
139361
|
log(`Creating attributes ...`);
|
|
139260
|
-
for (
|
|
139362
|
+
for (const attribute of attributes) {
|
|
139261
139363
|
if (attribute.side !== "child") {
|
|
139262
139364
|
await this.createAttribute(
|
|
139263
139365
|
collection["databaseId"],
|
|
@@ -139281,7 +139383,7 @@ var Attributes = class {
|
|
|
139281
139383
|
};
|
|
139282
139384
|
createColumns = async (columns, table) => {
|
|
139283
139385
|
log(`Creating columns ...`);
|
|
139284
|
-
for (
|
|
139386
|
+
for (const column of columns) {
|
|
139285
139387
|
if (column.side !== "child") {
|
|
139286
139388
|
await this.createAttribute(table["databaseId"], table["$id"], column);
|
|
139287
139389
|
}
|
|
@@ -139303,18 +139405,37 @@ var Attributes = class {
|
|
|
139303
139405
|
|
|
139304
139406
|
// lib/commands/utils/database-sync.ts
|
|
139305
139407
|
var import_chalk10 = __toESM(require_source(), 1);
|
|
139408
|
+
var isTablesDBResource = (value) => {
|
|
139409
|
+
if (!value || typeof value !== "object") {
|
|
139410
|
+
return false;
|
|
139411
|
+
}
|
|
139412
|
+
return "$id" in value && typeof value.$id === "string" && "name" in value && typeof value.name === "string" && "enabled" in value && typeof value.enabled === "boolean";
|
|
139413
|
+
};
|
|
139414
|
+
var getSyncErrorMessage = (err) => {
|
|
139415
|
+
if (err instanceof AppwriteException) {
|
|
139416
|
+
return err.message;
|
|
139417
|
+
}
|
|
139418
|
+
if (err instanceof Error) {
|
|
139419
|
+
return err.message;
|
|
139420
|
+
}
|
|
139421
|
+
return String(err);
|
|
139422
|
+
};
|
|
139306
139423
|
var checkAndApplyTablesDBChanges = async () => {
|
|
139307
139424
|
log("Checking for tablesDB changes ...");
|
|
139308
139425
|
const localTablesDBs = localConfig.getTablesDBs();
|
|
139309
|
-
const
|
|
139426
|
+
const paginatedResult = await paginate(
|
|
139310
139427
|
async (args) => {
|
|
139311
139428
|
const tablesDBService = await getTablesDBService();
|
|
139312
|
-
|
|
139429
|
+
const queries = Array.isArray(args.queries) ? args.queries.filter(
|
|
139430
|
+
(query) => typeof query === "string"
|
|
139431
|
+
) : [];
|
|
139432
|
+
return await tablesDBService.list(queries);
|
|
139313
139433
|
},
|
|
139314
139434
|
{},
|
|
139315
139435
|
100,
|
|
139316
139436
|
"databases"
|
|
139317
139437
|
);
|
|
139438
|
+
const remoteTablesDBs = Array.isArray(paginatedResult.databases) ? paginatedResult.databases.filter(isTablesDBResource) : [];
|
|
139318
139439
|
if (localTablesDBs.length === 0 && remoteTablesDBs.length === 0) {
|
|
139319
139440
|
return { applied: false, resyncNeeded: false };
|
|
139320
139441
|
}
|
|
@@ -139336,9 +139457,7 @@ var checkAndApplyTablesDBChanges = async () => {
|
|
|
139336
139457
|
}
|
|
139337
139458
|
}
|
|
139338
139459
|
for (const localDB of localTablesDBs) {
|
|
139339
|
-
const remoteDB = remoteTablesDBs.find(
|
|
139340
|
-
(db) => db.$id === localDB.$id
|
|
139341
|
-
);
|
|
139460
|
+
const remoteDB = remoteTablesDBs.find((db) => db.$id === localDB.$id);
|
|
139342
139461
|
if (!remoteDB) {
|
|
139343
139462
|
toCreate.push(localDB);
|
|
139344
139463
|
changes.push({
|
|
@@ -139405,7 +139524,7 @@ var checkAndApplyTablesDBChanges = async () => {
|
|
|
139405
139524
|
needsResync = true;
|
|
139406
139525
|
} catch (e) {
|
|
139407
139526
|
error48(
|
|
139408
|
-
`Failed to delete database ${db.name} ( ${db.$id} ): ${e
|
|
139527
|
+
`Failed to delete database ${db.name} ( ${db.$id} ): ${getSyncErrorMessage(e)}`
|
|
139409
139528
|
);
|
|
139410
139529
|
throw new Error(
|
|
139411
139530
|
`Database sync failed during deletion of ${db.$id}. Some changes may have been applied.`
|
|
@@ -139420,7 +139539,7 @@ var checkAndApplyTablesDBChanges = async () => {
|
|
|
139420
139539
|
success2(`Created ${db.name} ( ${db.$id} )`);
|
|
139421
139540
|
} catch (e) {
|
|
139422
139541
|
error48(
|
|
139423
|
-
`Failed to create database ${db.name} ( ${db.$id} ): ${e
|
|
139542
|
+
`Failed to create database ${db.name} ( ${db.$id} ): ${getSyncErrorMessage(e)}`
|
|
139424
139543
|
);
|
|
139425
139544
|
throw new Error(
|
|
139426
139545
|
`Database sync failed during creation of ${db.$id}. Some changes may have been applied.`
|
|
@@ -139435,7 +139554,7 @@ var checkAndApplyTablesDBChanges = async () => {
|
|
|
139435
139554
|
success2(`Updated ${db.name} ( ${db.$id} )`);
|
|
139436
139555
|
} catch (e) {
|
|
139437
139556
|
error48(
|
|
139438
|
-
`Failed to update database ${db.name} ( ${db.$id} ): ${e
|
|
139557
|
+
`Failed to update database ${db.name} ( ${db.$id} ): ${getSyncErrorMessage(e)}`
|
|
139439
139558
|
);
|
|
139440
139559
|
throw new Error(
|
|
139441
139560
|
`Database sync failed during update of ${db.$id}. Some changes may have been applied.`
|
|
@@ -139669,7 +139788,7 @@ var Push = class {
|
|
|
139669
139788
|
}
|
|
139670
139789
|
if (settings.services) {
|
|
139671
139790
|
this.log("Applying service statuses ...");
|
|
139672
|
-
for (
|
|
139791
|
+
for (const [service, status] of Object.entries(settings.services)) {
|
|
139673
139792
|
await projectsService.updateServiceStatus({
|
|
139674
139793
|
projectId,
|
|
139675
139794
|
service,
|
|
@@ -139715,7 +139834,7 @@ var Push = class {
|
|
|
139715
139834
|
}
|
|
139716
139835
|
if (settings.auth.methods) {
|
|
139717
139836
|
this.log("Applying auth methods statuses ...");
|
|
139718
|
-
for (
|
|
139837
|
+
for (const [method, status] of Object.entries(settings.auth.methods)) {
|
|
139719
139838
|
await projectsService.updateAuthStatus({
|
|
139720
139839
|
projectId,
|
|
139721
139840
|
method,
|
|
@@ -140019,7 +140138,7 @@ var Push = class {
|
|
|
140019
140138
|
([key, value]) => ({ key, value })
|
|
140020
140139
|
);
|
|
140021
140140
|
}
|
|
140022
|
-
} catch (
|
|
140141
|
+
} catch (_error) {
|
|
140023
140142
|
envVariables = [];
|
|
140024
140143
|
}
|
|
140025
140144
|
await Promise.all(
|
|
@@ -140316,7 +140435,7 @@ var Push = class {
|
|
|
140316
140435
|
([key, value]) => ({ key, value })
|
|
140317
140436
|
);
|
|
140318
140437
|
}
|
|
140319
|
-
} catch (
|
|
140438
|
+
} catch (_error) {
|
|
140320
140439
|
envVariables = [];
|
|
140321
140440
|
}
|
|
140322
140441
|
await Promise.all(
|
|
@@ -140483,7 +140602,7 @@ var Push = class {
|
|
|
140483
140602
|
skipConfirmation,
|
|
140484
140603
|
this.projectClient
|
|
140485
140604
|
);
|
|
140486
|
-
|
|
140605
|
+
const tablesChanged = /* @__PURE__ */ new Set();
|
|
140487
140606
|
const errors = [];
|
|
140488
140607
|
await Promise.all(
|
|
140489
140608
|
tables.map(async (table) => {
|
|
@@ -140537,7 +140656,7 @@ var Push = class {
|
|
|
140537
140656
|
}
|
|
140538
140657
|
})
|
|
140539
140658
|
);
|
|
140540
|
-
for (
|
|
140659
|
+
for (const table of tables) {
|
|
140541
140660
|
let columns = table.columns;
|
|
140542
140661
|
let indexes = table.indexes;
|
|
140543
140662
|
let hadChanges = false;
|
|
@@ -140816,7 +140935,7 @@ var pushSettings = async () => {
|
|
|
140816
140935
|
checkDeployConditions(localConfig);
|
|
140817
140936
|
try {
|
|
140818
140937
|
const projectsService = await getProjectsService();
|
|
140819
|
-
|
|
140938
|
+
const response = await projectsService.get(
|
|
140820
140939
|
localConfig.getProject().projectId
|
|
140821
140940
|
);
|
|
140822
140941
|
const remoteSettings = createSettingsObject(response);
|
|
@@ -140849,7 +140968,7 @@ var pushSettings = async () => {
|
|
|
140849
140968
|
return;
|
|
140850
140969
|
}
|
|
140851
140970
|
}
|
|
140852
|
-
} catch (
|
|
140971
|
+
} catch (_e) {
|
|
140853
140972
|
}
|
|
140854
140973
|
try {
|
|
140855
140974
|
log("Pushing project settings ...");
|
|
@@ -140899,7 +141018,7 @@ var pushSite = async ({
|
|
|
140899
141018
|
);
|
|
140900
141019
|
return;
|
|
140901
141020
|
}
|
|
140902
|
-
|
|
141021
|
+
const sites2 = siteIds.map((id) => {
|
|
140903
141022
|
const sites3 = localConfig.getSites();
|
|
140904
141023
|
const site = sites3.find((s) => s.$id === id);
|
|
140905
141024
|
if (!site) {
|
|
@@ -140908,7 +141027,7 @@ var pushSite = async ({
|
|
|
140908
141027
|
return site;
|
|
140909
141028
|
});
|
|
140910
141029
|
log("Validating sites ...");
|
|
140911
|
-
for (
|
|
141030
|
+
for (const site of sites2) {
|
|
140912
141031
|
if (!site.buildCommand) {
|
|
140913
141032
|
log(`Site ${site.name} is missing build command.`);
|
|
140914
141033
|
const answers = await import_inquirer7.default.prompt(questionsGetEntrypoint);
|
|
@@ -141019,7 +141138,7 @@ var pushFunction = async ({
|
|
|
141019
141138
|
);
|
|
141020
141139
|
return;
|
|
141021
141140
|
}
|
|
141022
|
-
|
|
141141
|
+
const functions2 = functionIds.map((id) => {
|
|
141023
141142
|
const functions3 = localConfig.getFunctions();
|
|
141024
141143
|
const func = functions3.find((f) => f.$id === id);
|
|
141025
141144
|
if (!func) {
|
|
@@ -141028,7 +141147,7 @@ var pushFunction = async ({
|
|
|
141028
141147
|
return func;
|
|
141029
141148
|
});
|
|
141030
141149
|
log("Validating functions ...");
|
|
141031
|
-
for (
|
|
141150
|
+
for (const func of functions2) {
|
|
141032
141151
|
if (!func.entrypoint) {
|
|
141033
141152
|
log(`Function ${func.name} is missing an entrypoint.`);
|
|
141034
141153
|
const answers = await import_inquirer7.default.prompt(questionsGetEntrypoint);
|
|
@@ -141169,7 +141288,7 @@ var pushTable = async ({
|
|
|
141169
141288
|
});
|
|
141170
141289
|
}
|
|
141171
141290
|
}
|
|
141172
|
-
} catch (
|
|
141291
|
+
} catch (_e) {
|
|
141173
141292
|
}
|
|
141174
141293
|
}
|
|
141175
141294
|
if (tablesToDelete.length > 0) {
|
|
@@ -141316,7 +141435,7 @@ var pushCollection = async () => {
|
|
|
141316
141435
|
}
|
|
141317
141436
|
};
|
|
141318
141437
|
var pushBucket = async () => {
|
|
141319
|
-
|
|
141438
|
+
const bucketIds = [];
|
|
141320
141439
|
const configBuckets = localConfig.getBuckets();
|
|
141321
141440
|
if (cliConfig.all) {
|
|
141322
141441
|
checkDeployConditions(localConfig);
|
|
@@ -141335,7 +141454,7 @@ var pushBucket = async () => {
|
|
|
141335
141454
|
);
|
|
141336
141455
|
return;
|
|
141337
141456
|
}
|
|
141338
|
-
|
|
141457
|
+
const buckets = [];
|
|
141339
141458
|
for (const bucketId of bucketIds) {
|
|
141340
141459
|
const idBuckets = configBuckets.filter((b) => b.$id === bucketId);
|
|
141341
141460
|
buckets.push(...idBuckets);
|
|
@@ -141366,7 +141485,7 @@ var pushBucket = async () => {
|
|
|
141366
141485
|
}
|
|
141367
141486
|
};
|
|
141368
141487
|
var pushTeam = async () => {
|
|
141369
|
-
|
|
141488
|
+
const teamIds = [];
|
|
141370
141489
|
const configTeams = localConfig.getTeams();
|
|
141371
141490
|
if (cliConfig.all) {
|
|
141372
141491
|
checkDeployConditions(localConfig);
|
|
@@ -141385,7 +141504,7 @@ var pushTeam = async () => {
|
|
|
141385
141504
|
);
|
|
141386
141505
|
return;
|
|
141387
141506
|
}
|
|
141388
|
-
|
|
141507
|
+
const teams2 = [];
|
|
141389
141508
|
for (const teamId of teamIds) {
|
|
141390
141509
|
const idTeams = configTeams.filter((t) => t.$id === teamId);
|
|
141391
141510
|
teams2.push(...idTeams);
|
|
@@ -141416,7 +141535,7 @@ var pushTeam = async () => {
|
|
|
141416
141535
|
}
|
|
141417
141536
|
};
|
|
141418
141537
|
var pushMessagingTopic = async () => {
|
|
141419
|
-
|
|
141538
|
+
const topicsIds = [];
|
|
141420
141539
|
const configTopics = localConfig.getMessagingTopics();
|
|
141421
141540
|
if (cliConfig.all) {
|
|
141422
141541
|
checkDeployConditions(localConfig);
|
|
@@ -141435,7 +141554,7 @@ var pushMessagingTopic = async () => {
|
|
|
141435
141554
|
);
|
|
141436
141555
|
return;
|
|
141437
141556
|
}
|
|
141438
|
-
|
|
141557
|
+
const topics = [];
|
|
141439
141558
|
for (const topicId of topicsIds) {
|
|
141440
141559
|
const idTopic = configTopics.filter((b) => b.$id === topicId);
|
|
141441
141560
|
topics.push(...idTopic);
|
|
@@ -141511,7 +141630,7 @@ var isInstalledViaNpm = () => {
|
|
|
141511
141630
|
return true;
|
|
141512
141631
|
}
|
|
141513
141632
|
return false;
|
|
141514
|
-
} catch (
|
|
141633
|
+
} catch (_e) {
|
|
141515
141634
|
return false;
|
|
141516
141635
|
}
|
|
141517
141636
|
};
|
|
@@ -141519,7 +141638,7 @@ var isInstalledViaHomebrew = () => {
|
|
|
141519
141638
|
try {
|
|
141520
141639
|
const scriptPath = process.argv[1];
|
|
141521
141640
|
return scriptPath.includes("/opt/homebrew/") || scriptPath.includes("/usr/local/Cellar/");
|
|
141522
|
-
} catch (
|
|
141641
|
+
} catch (_e) {
|
|
141523
141642
|
return false;
|
|
141524
141643
|
}
|
|
141525
141644
|
};
|
|
@@ -141549,13 +141668,14 @@ var updateViaNpm = async () => {
|
|
|
141549
141668
|
success2("Updated to latest version via npm!");
|
|
141550
141669
|
hint("Run 'appwrite --version' to verify the new version.");
|
|
141551
141670
|
} catch (e) {
|
|
141552
|
-
|
|
141671
|
+
const message = getErrorMessage(e);
|
|
141672
|
+
if (message.includes("EEXIST") || message.includes("file already exists")) {
|
|
141553
141673
|
console.log("");
|
|
141554
141674
|
success2("Latest version is already installed via npm!");
|
|
141555
141675
|
hint("The CLI is up to date. Run 'appwrite --version' to verify.");
|
|
141556
141676
|
} else {
|
|
141557
141677
|
console.log("");
|
|
141558
|
-
error48(`Failed to update via npm: ${
|
|
141678
|
+
error48(`Failed to update via npm: ${message}`);
|
|
141559
141679
|
hint(`Try running: npm install -g ${NPM_PACKAGE_NAME}@latest --force`);
|
|
141560
141680
|
}
|
|
141561
141681
|
}
|
|
@@ -141567,13 +141687,14 @@ var updateViaHomebrew = async () => {
|
|
|
141567
141687
|
success2("Updated to latest version via Homebrew!");
|
|
141568
141688
|
hint("Run 'appwrite --version' to verify the new version.");
|
|
141569
141689
|
} catch (e) {
|
|
141570
|
-
|
|
141690
|
+
const message = getErrorMessage(e);
|
|
141691
|
+
if (message.includes("already installed") || message.includes("up-to-date")) {
|
|
141571
141692
|
console.log("");
|
|
141572
141693
|
success2("Latest version is already installed via Homebrew!");
|
|
141573
141694
|
hint("The CLI is up to date. Run 'appwrite --version' to verify.");
|
|
141574
141695
|
} else {
|
|
141575
141696
|
console.log("");
|
|
141576
|
-
error48(`Failed to update via Homebrew: ${
|
|
141697
|
+
error48(`Failed to update via Homebrew: ${message}`);
|
|
141577
141698
|
hint("Try running: brew upgrade appwrite");
|
|
141578
141699
|
}
|
|
141579
141700
|
}
|
|
@@ -141648,8 +141769,9 @@ var updateCli = async ({ manual } = {}) => {
|
|
|
141648
141769
|
await chooseUpdateMethod(latestVersion);
|
|
141649
141770
|
}
|
|
141650
141771
|
} catch (e) {
|
|
141772
|
+
const message = getErrorMessage(e);
|
|
141651
141773
|
console.log("");
|
|
141652
|
-
error48(`Failed to check for updates: ${
|
|
141774
|
+
error48(`Failed to check for updates: ${message}`);
|
|
141653
141775
|
hint(`You can manually check for updates at: ${GITHUB_RELEASES_URL}`);
|
|
141654
141776
|
}
|
|
141655
141777
|
};
|
|
@@ -141822,7 +141944,7 @@ var BaseDatabasesGenerator = class {
|
|
|
141822
141944
|
var types_ts_default = "import { type Models } from '{{appwriteDep}}';\n\n{{{ENUMS}}}{{{TYPES}}}\ndeclare const __roleStringBrand: unique symbol;\nexport type RoleString = string & { readonly [__roleStringBrand]: never };\n\nexport type RoleBuilder = {\n any: () => RoleString;\n user: (userId: string, status?: string) => RoleString;\n users: (status?: string) => RoleString;\n guests: () => RoleString;\n team: (teamId: string, role?: string) => RoleString;\n member: (memberId: string) => RoleString;\n label: (label: string) => RoleString;\n}\n\nexport type PermissionBuilder = {\n read: (role: RoleString) => string;\n write: (role: RoleString) => string;\n create: (role: RoleString) => string;\n update: (role: RoleString) => string;\n delete: (role: RoleString) => string;\n}\n\nexport type PermissionCallback = (permission: PermissionBuilder, role: RoleBuilder) => string[];\n\nexport type QueryValue = string | number | boolean;\n\nexport type ExtractQueryValue<T> = T extends (infer U)[]\n ? U extends QueryValue ? U : never\n : T extends QueryValue | null ? NonNullable<T> : never;\n\nexport type QueryableKeys<T> = {\n [K in keyof T]: ExtractQueryValue<T[K]> extends never ? never : K;\n}[keyof T];\n\nexport type QueryBuilder<T> = {\n equal: <K extends QueryableKeys<T>>(field: K, value: ExtractQueryValue<T[K]>) => string;\n notEqual: <K extends QueryableKeys<T>>(field: K, value: ExtractQueryValue<T[K]>) => string;\n lessThan: <K extends QueryableKeys<T>>(field: K, value: ExtractQueryValue<T[K]>) => string;\n lessThanEqual: <K extends QueryableKeys<T>>(field: K, value: ExtractQueryValue<T[K]>) => string;\n greaterThan: <K extends QueryableKeys<T>>(field: K, value: ExtractQueryValue<T[K]>) => string;\n greaterThanEqual: <K extends QueryableKeys<T>>(field: K, value: ExtractQueryValue<T[K]>) => string;\n contains: <K extends QueryableKeys<T>>(field: K, value: ExtractQueryValue<T[K]>) => string;\n search: <K extends QueryableKeys<T>>(field: K, value: string) => string;\n isNull: <K extends QueryableKeys<T>>(field: K) => string;\n isNotNull: <K extends QueryableKeys<T>>(field: K) => string;\n startsWith: <K extends QueryableKeys<T>>(field: K, value: string) => string;\n endsWith: <K extends QueryableKeys<T>>(field: K, value: string) => string;\n between: <K extends QueryableKeys<T>>(field: K, start: ExtractQueryValue<T[K]>, end: ExtractQueryValue<T[K]>) => string;\n select: <K extends keyof T>(fields: K[]) => string;\n orderAsc: <K extends keyof T>(field: K) => string;\n orderDesc: <K extends keyof T>(field: K) => string;\n limit: (value: number) => string;\n offset: (value: number) => string;\n cursorAfter: (documentId: string) => string;\n cursorBefore: (documentId: string) => string;\n or: (...queries: string[]) => string;\n and: (...queries: string[]) => string;\n}\n\nexport type DatabaseId = {{{databaseIdType}}};\n\n{{{DATABASE_TABLES_TYPE}}}\n";
|
|
141823
141945
|
|
|
141824
141946
|
// lib/commands/generators/typescript/templates/databases.ts.hbs
|
|
141825
|
-
var databases_ts_default = 'import { Client, TablesDB, ID, Query, type Models, Permission, Role } from \'{{appwriteDep}}\';\nimport type { DatabaseHandle, DatabaseId, DatabaseTableMap, DatabaseTables, QueryBuilder, PermissionBuilder, RoleBuilder, RoleString } from \'./types{{importExt}}\';\n{{#if supportsServerSide}}\nimport { PROJECT_ID, ENDPOINT, API_KEY } from \'./constants{{importExt}}\';\n{{else}}\nimport { PROJECT_ID, ENDPOINT } from \'./constants{{importExt}}\';\n{{/if}}\n\nconst createQueryBuilder = <T>(): QueryBuilder<T> => ({\n equal: (field, value) => Query.equal(String(field), value as any),\n notEqual: (field, value) => Query.notEqual(String(field), value as any),\n lessThan: (field, value) => Query.lessThan(String(field), value as any),\n lessThanEqual: (field, value) => Query.lessThanEqual(String(field), value as any),\n greaterThan: (field, value) => Query.greaterThan(String(field), value as any),\n greaterThanEqual: (field, value) => Query.greaterThanEqual(String(field), value as any),\n contains: (field, value) => Query.contains(String(field), value as any),\n search: (field, value) => Query.search(String(field), value),\n isNull: (field) => Query.isNull(String(field)),\n isNotNull: (field) => Query.isNotNull(String(field)),\n startsWith: (field, value) => Query.startsWith(String(field), value),\n endsWith: (field, value) => Query.endsWith(String(field), value),\n between: (field, start, end) => Query.between(String(field), start as any, end as any),\n select: (fields) => Query.select(fields.map(String)),\n orderAsc: (field) => Query.orderAsc(String(field)),\n orderDesc: (field) => Query.orderDesc(String(field)),\n limit: (value) => Query.limit(value),\n offset: (value) => Query.offset(value),\n cursorAfter: (documentId) => Query.cursorAfter(documentId),\n cursorBefore: (documentId) => Query.cursorBefore(documentId),\n or: (...queries) => Query.or(queries),\n and: (...queries) => Query.and(queries),\n});\n\n{{{TABLE_ID_MAP}}}\n\n{{{TABLES_WITH_RELATIONSHIPS}}}\n\nconst roleBuilder: RoleBuilder = {\n any: () => Role.any() as RoleString,\n user: (userId, status?) => Role.user(userId, status) as RoleString,\n users: (status?) => Role.users(status) as RoleString,\n guests: () => Role.guests() as RoleString,\n team: (teamId, role?) => Role.team(teamId, role) as RoleString,\n member: (memberId) => Role.member(memberId) as RoleString,\n label: (label) => Role.label(label) as RoleString,\n};\n\nconst permissionBuilder: PermissionBuilder = {\n read: (role) => Permission.read(role),\n write: (role) => Permission.write(role),\n create: (role) => Permission.create(role),\n update: (role) => Permission.update(role),\n delete: (role) => Permission.delete(role),\n};\n\nconst resolvePermissions = (callback?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]): string[] | undefined =>\n callback?.(permissionBuilder, roleBuilder);\n\nfunction createTableApi<T extends Models.Row>(\n tablesDB: TablesDB,\n databaseId: string,\n tableId: string,\n) {\n return {\n create: (data: any, options?: { rowId?: string; permissions?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]; transactionId?: string }) =>\n tablesDB.createRow<T>({\n databaseId,\n tableId,\n rowId: options?.rowId ?? ID.unique(),\n data,\n permissions: resolvePermissions(options?.permissions),\n transactionId: options?.transactionId,\n }),\n get: (id: string) =>\n tablesDB.getRow<T>({\n databaseId,\n tableId,\n rowId: id,\n }),\n update: (id: string, data: any, options?: { permissions?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]; transactionId?: string }) =>\n tablesDB.updateRow<T>({\n databaseId,\n tableId,\n rowId: id,\n data,\n ...(options?.permissions ? { permissions: resolvePermissions(options.permissions) } : {}),\n transactionId: options?.transactionId,\n }),\n delete: async (id: string, options?: { transactionId?: string }) => {\n await tablesDB.deleteRow({\n databaseId,\n tableId,\n rowId: id,\n transactionId: options?.transactionId,\n });\n },\n list: (options?: { queries?: (q: any) => string[] }) =>\n tablesDB.listRows<T>({\n databaseId,\n tableId,\n queries: options?.queries?.(createQueryBuilder<T>()),\n }),{{{BULK_METHODS}}}\n };\n}\n\n{{{BULK_CHECK}}}\nconst hasOwn = (obj: unknown, key: string): boolean =>\n obj != null && Object.prototype.hasOwnProperty.call(obj, key);\n\nfunction createDatabaseHandle<D extends DatabaseId>(\n tablesDB: TablesDB,\n databaseId: D,\n): DatabaseHandle<D> {\n const tableApiCache = new Map<string, unknown>();\n const dbMap = tableIdMap[databaseId];\n\n return {\n use: <T extends keyof DatabaseTableMap[D] & string>(tableId: T): DatabaseTableMap[D][T] => {\n if (!hasOwn(dbMap, tableId)) {\n throw new Error(`Unknown table "${tableId}" in database "${databaseId}"`);\n }\n\n if (!tableApiCache.has(tableId)) {\n const resolvedTableId = dbMap[tableId];\n const api = createTableApi(tablesDB, databaseId, resolvedTableId);\n {{{BULK_REMOVAL}}}\n tableApiCache.set(tableId, api);\n }\n return tableApiCache.get(tableId) as DatabaseTableMap[D][T];\n },\n{{#if supportsServerSide}}\n create: (tableId: string, name: string, options?: { permissions?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]; rowSecurity?: boolean; enabled?: boolean; columns?: any[]; indexes?: any[] }) =>\n tablesDB.createTable({\n databaseId,\n tableId,\n name,\n permissions: resolvePermissions(options?.permissions),\n rowSecurity: options?.rowSecurity,\n enabled: options?.enabled,\n columns: options?.columns,\n indexes: options?.indexes,\n }),\n update: (tableId: string, options?: { name?: string; permissions?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]; rowSecurity?: boolean; enabled?: boolean }) => {\n if (!hasOwn(dbMap, tableId)) {\n throw new Error(`Unknown table "${tableId}" in database "${databaseId}"`);\n }\n const resolvedTableId = dbMap[tableId];\n return tablesDB.updateTable({\n databaseId,\n tableId: resolvedTableId,\n name: options?.name ?? tableId, // TODO: remove this fallback once fixed in other SDKs\n permissions: resolvePermissions(options?.permissions),\n rowSecurity: options?.rowSecurity,\n enabled: options?.enabled,\n });\n },\n delete: async (tableId: string) => {\n if (!hasOwn(dbMap, tableId)) {\n throw new Error(`Unknown table "${tableId}" in database "${databaseId}"`);\n }\n const resolvedTableId = dbMap[tableId];\n await tablesDB.deleteTable({\n databaseId,\n tableId: resolvedTableId,\n });\n },\n{{/if}}\n };\n}\n\nfunction createDatabasesApi(tablesDB: TablesDB): DatabaseTables {\n const dbCache = new Map<DatabaseId, ReturnType<typeof createDatabaseHandle>>();\n\n return {\n use: (databaseId: DatabaseId) => {\n if (!hasOwn(tableIdMap, databaseId)) {\n throw new Error(`Unknown database "${databaseId}"`);\n }\n\n if (!dbCache.has(databaseId)) {\n dbCache.set(databaseId, createDatabaseHandle(tablesDB, databaseId));\n }\n return dbCache.get(databaseId);\n },\n{{#if supportsServerSide}}\n create: (databaseId: string, name: string, options?: { enabled?: boolean }) =>\n tablesDB.create({\n databaseId,\n name,\n enabled: options?.enabled,\n }),\n update: (databaseId: DatabaseId, options?: { name?: string; enabled?: boolean }) => {\n return tablesDB.update({\n databaseId,\n name: options?.name ?? databaseId,\n enabled: options?.enabled,\n });\n },\n delete: async (databaseId: DatabaseId) => {\n await tablesDB.delete({\n databaseId,\n });\n },\n{{/if}}\n } as DatabaseTables;\n}\n\n// Initialize client\nconst client = new Client()\n .setEndpoint(ENDPOINT)\n .setProject(PROJECT_ID){{#if supportsServerSide}}\n .setKey(API_KEY){{/if}};\n\nconst tablesDB = new TablesDB(client);\n\nexport const databases: DatabaseTables = createDatabasesApi(tablesDB);\n';
|
|
141947
|
+
var databases_ts_default = 'import { Client, TablesDB, ID, Query, type Models, Permission, Role } from \'{{appwriteDep}}\';\nimport type { DatabaseHandle, DatabaseId, DatabaseTableMap, DatabaseTables, QueryBuilder, QueryValue, PermissionBuilder, RoleBuilder, RoleString } from \'./types{{importExt}}\';\n{{#if supportsServerSide}}\nimport { PROJECT_ID, ENDPOINT, API_KEY } from \'./constants{{importExt}}\';\n{{else}}\nimport { PROJECT_ID, ENDPOINT } from \'./constants{{importExt}}\';\n{{/if}}\n\nconst createQueryBuilder = <T>(): QueryBuilder<T> => ({\n equal: (field, value) => Query.equal(String(field), value as QueryValue),\n notEqual: (field, value) => Query.notEqual(String(field), value as QueryValue),\n lessThan: (field, value) => Query.lessThan(String(field), value as QueryValue),\n lessThanEqual: (field, value) => Query.lessThanEqual(String(field), value as QueryValue),\n greaterThan: (field, value) => Query.greaterThan(String(field), value as QueryValue),\n greaterThanEqual: (field, value) => Query.greaterThanEqual(String(field), value as QueryValue),\n contains: (field, value) => Query.contains(String(field), value as string | QueryValue[]),\n search: (field, value) => Query.search(String(field), value),\n isNull: (field) => Query.isNull(String(field)),\n isNotNull: (field) => Query.isNotNull(String(field)),\n startsWith: (field, value) => Query.startsWith(String(field), value),\n endsWith: (field, value) => Query.endsWith(String(field), value),\n between: (field, start, end) => Query.between(String(field), start as string | number, end as string | number),\n select: (fields) => Query.select(fields.map(String)),\n orderAsc: (field) => Query.orderAsc(String(field)),\n orderDesc: (field) => Query.orderDesc(String(field)),\n limit: (value) => Query.limit(value),\n offset: (value) => Query.offset(value),\n cursorAfter: (documentId) => Query.cursorAfter(documentId),\n cursorBefore: (documentId) => Query.cursorBefore(documentId),\n or: (...queries) => Query.or(queries),\n and: (...queries) => Query.and(queries),\n});\n\n{{{TABLE_ID_MAP}}}\n\n{{{TABLES_WITH_RELATIONSHIPS}}}\n\nconst roleBuilder: RoleBuilder = {\n any: () => Role.any() as RoleString,\n user: (userId, status?) => Role.user(userId, status) as RoleString,\n users: (status?) => Role.users(status) as RoleString,\n guests: () => Role.guests() as RoleString,\n team: (teamId, role?) => Role.team(teamId, role) as RoleString,\n member: (memberId) => Role.member(memberId) as RoleString,\n label: (label) => Role.label(label) as RoleString,\n};\n\nconst permissionBuilder: PermissionBuilder = {\n read: (role) => Permission.read(role),\n write: (role) => Permission.write(role),\n create: (role) => Permission.create(role),\n update: (role) => Permission.update(role),\n delete: (role) => Permission.delete(role),\n};\n\nconst resolvePermissions = (callback?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]): string[] | undefined =>\n callback?.(permissionBuilder, roleBuilder);\n\nfunction createTableApi<T extends Models.Row>(\n tablesDB: TablesDB,\n databaseId: string,\n tableId: string,\n) {\n return {\n create: (data: Omit<T, keyof Models.Row>, options?: { rowId?: string; permissions?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]; transactionId?: string }) =>\n tablesDB.createRow<T>({\n databaseId,\n tableId,\n rowId: options?.rowId ?? ID.unique(),\n data: data as T extends Models.DefaultRow ? Partial<Models.Row> & Record<string, unknown> : Partial<Models.Row> & Omit<T, keyof Models.Row>,\n permissions: resolvePermissions(options?.permissions),\n transactionId: options?.transactionId,\n }),\n get: (id: string) =>\n tablesDB.getRow<T>({\n databaseId,\n tableId,\n rowId: id,\n }),\n update: (id: string, data: Partial<Omit<T, keyof Models.Row>>, options?: { permissions?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]; transactionId?: string }) =>\n tablesDB.updateRow<T>({\n databaseId,\n tableId,\n rowId: id,\n data: data as T extends Models.DefaultRow ? Partial<Models.Row> & Record<string, unknown> : Partial<Models.Row> & Partial<Omit<T, keyof Models.Row>>,\n ...(options?.permissions ? { permissions: resolvePermissions(options.permissions) } : {}),\n transactionId: options?.transactionId,\n }),\n delete: async (id: string, options?: { transactionId?: string }) => {\n await tablesDB.deleteRow({\n databaseId,\n tableId,\n rowId: id,\n transactionId: options?.transactionId,\n });\n },\n list: (options?: { queries?: (q: QueryBuilder<T>) => string[] }) =>\n tablesDB.listRows<T>({\n databaseId,\n tableId,\n queries: options?.queries?.(createQueryBuilder<T>()),\n }),{{{BULK_METHODS}}}\n };\n}\n\n{{{BULK_CHECK}}}\nconst hasOwn = (obj: unknown, key: string): boolean =>\n obj != null && Object.prototype.hasOwnProperty.call(obj, key);\n\nfunction createDatabaseHandle<D extends DatabaseId>(\n tablesDB: TablesDB,\n databaseId: D,\n): DatabaseHandle<D> {\n const tableApiCache = new Map<string, unknown>();\n const dbMap = tableIdMap[databaseId];\n\n return {\n use: <T extends keyof DatabaseTableMap[D] & string>(tableId: T): DatabaseTableMap[D][T] => {\n if (!hasOwn(dbMap, tableId)) {\n throw new Error(`Unknown table "${tableId}" in database "${databaseId}"`);\n }\n\n if (!tableApiCache.has(tableId)) {\n const resolvedTableId = dbMap[tableId];\n const api = createTableApi(tablesDB, databaseId, resolvedTableId);\n {{{BULK_REMOVAL}}}\n tableApiCache.set(tableId, api);\n }\n return tableApiCache.get(tableId) as DatabaseTableMap[D][T];\n },\n{{#if supportsServerSide}}\n create: (tableId: string, name: string, options?: { permissions?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; indexes?: object[] }) =>\n tablesDB.createTable({\n databaseId,\n tableId,\n name,\n permissions: resolvePermissions(options?.permissions),\n rowSecurity: options?.rowSecurity,\n enabled: options?.enabled,\n columns: options?.columns,\n indexes: options?.indexes,\n }),\n update: (tableId: string, options?: { name?: string; permissions?: (permission: { read: (role: RoleString) => string; write: (role: RoleString) => string; create: (role: RoleString) => string; update: (role: RoleString) => string; delete: (role: RoleString) => string }, role: { any: () => RoleString; user: (userId: string, status?: string) => RoleString; users: (status?: string) => RoleString; guests: () => RoleString; team: (teamId: string, role?: string) => RoleString; member: (memberId: string) => RoleString; label: (label: string) => RoleString }) => string[]; rowSecurity?: boolean; enabled?: boolean }) => {\n if (!hasOwn(dbMap, tableId)) {\n throw new Error(`Unknown table "${tableId}" in database "${databaseId}"`);\n }\n const resolvedTableId = dbMap[tableId];\n return tablesDB.updateTable({\n databaseId,\n tableId: resolvedTableId,\n name: options?.name,\n permissions: resolvePermissions(options?.permissions),\n rowSecurity: options?.rowSecurity,\n enabled: options?.enabled,\n });\n },\n delete: async (tableId: string) => {\n if (!hasOwn(dbMap, tableId)) {\n throw new Error(`Unknown table "${tableId}" in database "${databaseId}"`);\n }\n const resolvedTableId = dbMap[tableId];\n await tablesDB.deleteTable({\n databaseId,\n tableId: resolvedTableId,\n });\n },\n{{/if}}\n };\n}\n\nfunction createDatabasesApi(tablesDB: TablesDB): DatabaseTables {\n const dbCache = new Map<DatabaseId, ReturnType<typeof createDatabaseHandle>>();\n\n return {\n use: (databaseId: DatabaseId) => {\n if (!hasOwn(tableIdMap, databaseId)) {\n throw new Error(`Unknown database "${databaseId}"`);\n }\n\n if (!dbCache.has(databaseId)) {\n dbCache.set(databaseId, createDatabaseHandle(tablesDB, databaseId));\n }\n return dbCache.get(databaseId);\n },\n{{#if supportsServerSide}}\n create: (databaseId: string, name: string, options?: { enabled?: boolean }) =>\n tablesDB.create({\n databaseId,\n name,\n enabled: options?.enabled,\n }),\n update: (databaseId: DatabaseId, options?: { name?: string; enabled?: boolean }) => {\n return tablesDB.update({\n databaseId,\n name: options?.name ?? databaseId,\n enabled: options?.enabled,\n });\n },\n delete: async (databaseId: DatabaseId) => {\n await tablesDB.delete({\n databaseId,\n });\n },\n{{/if}}\n } as DatabaseTables;\n}\n\n// Initialize client\nconst client = new Client()\n .setEndpoint(ENDPOINT)\n .setProject(PROJECT_ID){{#if supportsServerSide}}\n .setKey(API_KEY){{/if}};\n\nconst tablesDB = new TablesDB(client);\n\nexport const databases: DatabaseTables = createDatabasesApi(tablesDB);\n';
|
|
141826
141948
|
|
|
141827
141949
|
// lib/commands/generators/typescript/templates/index.ts.hbs
|
|
141828
141950
|
var index_ts_default = '/**\n * {{sdkTitle}} Generated SDK\n *\n * This file is auto-generated. Do not edit manually.\n * Re-run `{{executableName}} generate` to regenerate.\n */\n\nexport { databases } from "./databases{{importExt}}";\nexport * from "./types{{importExt}}";\n';
|
|
@@ -141989,7 +142111,7 @@ ${dbReturnTypes}
|
|
|
141989
142111
|
|
|
141990
142112
|
export type DatabaseHandle<D extends DatabaseId> = {
|
|
141991
142113
|
use: <T extends keyof DatabaseTableMap[D] & string>(tableId: T) => DatabaseTableMap[D][T];
|
|
141992
|
-
${supportsServerSide ? ` create: (tableId: string, name: string, options?: { permissions?: ${PERMISSION_CALLBACK_INLINE}; rowSecurity?: boolean; enabled?: boolean; columns?:
|
|
142114
|
+
${supportsServerSide ? ` create: (tableId: string, name: string, options?: { permissions?: ${PERMISSION_CALLBACK_INLINE}; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; indexes?: object[] }) => Promise<Models.Table>;
|
|
141993
142115
|
update: <T extends keyof DatabaseTableMap[D] & string>(tableId: T, options?: { name?: string; permissions?: ${PERMISSION_CALLBACK_INLINE}; rowSecurity?: boolean; enabled?: boolean }) => Promise<Models.Table>;
|
|
141994
142116
|
delete: <T extends keyof DatabaseTableMap[D] & string>(tableId: T) => Promise<void>;` : ""}
|
|
141995
142117
|
};
|
|
@@ -142056,26 +142178,26 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
|
|
|
142056
142178
|
generateBulkMethods(supportsBulk) {
|
|
142057
142179
|
if (!supportsBulk) return "";
|
|
142058
142180
|
return `
|
|
142059
|
-
createMany: (rows:
|
|
142181
|
+
createMany: (rows: object[], options?: { transactionId?: string }) =>
|
|
142060
142182
|
tablesDB.createRows({
|
|
142061
142183
|
databaseId,
|
|
142062
142184
|
tableId,
|
|
142063
142185
|
rows,
|
|
142064
142186
|
transactionId: options?.transactionId,
|
|
142065
142187
|
}),
|
|
142066
|
-
updateMany: (data:
|
|
142188
|
+
updateMany: (data: object, options?: { queries?: (q: QueryBuilder<T>) => string[]; transactionId?: string }) =>
|
|
142067
142189
|
tablesDB.updateRows({
|
|
142068
142190
|
databaseId,
|
|
142069
142191
|
tableId,
|
|
142070
142192
|
data,
|
|
142071
|
-
queries: options?.queries?.(createQueryBuilder()),
|
|
142193
|
+
queries: options?.queries?.(createQueryBuilder<T>()),
|
|
142072
142194
|
transactionId: options?.transactionId,
|
|
142073
142195
|
}),
|
|
142074
|
-
deleteMany: (options?: { queries?: (q:
|
|
142196
|
+
deleteMany: (options?: { queries?: (q: QueryBuilder<T>) => string[]; transactionId?: string }) =>
|
|
142075
142197
|
tablesDB.deleteRows({
|
|
142076
142198
|
databaseId,
|
|
142077
142199
|
tableId,
|
|
142078
|
-
queries: options?.queries?.(createQueryBuilder()),
|
|
142200
|
+
queries: options?.queries?.(createQueryBuilder<T>()),
|
|
142079
142201
|
transactionId: options?.transactionId,
|
|
142080
142202
|
}),`;
|
|
142081
142203
|
}
|
|
@@ -142089,9 +142211,9 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
|
|
|
142089
142211
|
return `
|
|
142090
142212
|
// Remove bulk methods for tables with relationships
|
|
142091
142213
|
if (!hasBulkMethods(databaseId, tableId)) {
|
|
142092
|
-
delete (api as
|
|
142093
|
-
delete (api as
|
|
142094
|
-
delete (api as
|
|
142214
|
+
delete (api as Record<string, unknown>).createMany;
|
|
142215
|
+
delete (api as Record<string, unknown>).updateMany;
|
|
142216
|
+
delete (api as Record<string, unknown>).deleteMany;
|
|
142095
142217
|
}`;
|
|
142096
142218
|
}
|
|
142097
142219
|
generateDatabasesFile(config2, importExt) {
|
|
@@ -142238,8 +142360,9 @@ var generateAction = async (options) => {
|
|
|
142238
142360
|
}
|
|
142239
142361
|
} catch (err) {
|
|
142240
142362
|
const supported = getSupportedLanguages().join(", ");
|
|
142363
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
142241
142364
|
error48(
|
|
142242
|
-
`${
|
|
142365
|
+
`${message}
|
|
142243
142366
|
Use --language to specify the target language. Supported: ${supported}`
|
|
142244
142367
|
);
|
|
142245
142368
|
process.exit(1);
|
|
@@ -142294,7 +142417,8 @@ Use --language to specify the target language. Supported: ${supported}`
|
|
|
142294
142417
|
);
|
|
142295
142418
|
}
|
|
142296
142419
|
} catch (err) {
|
|
142297
|
-
|
|
142420
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
142421
|
+
error48(`Failed to generate SDK: ${message}`);
|
|
142298
142422
|
process.exit(1);
|
|
142299
142423
|
}
|
|
142300
142424
|
};
|
|
@@ -146282,12 +146406,12 @@ async function checkVersion() {
|
|
|
146282
146406
|
} else {
|
|
146283
146407
|
process.stdout.write(import_chalk13.default.blue("\n\u{1F680} You are running a pre-release or development version.") + "\n");
|
|
146284
146408
|
}
|
|
146285
|
-
} catch (
|
|
146409
|
+
} catch (_error) {
|
|
146286
146410
|
process.stdout.write(import_chalk13.default.gray("\n(Unable to check for updates)") + "\n");
|
|
146287
146411
|
}
|
|
146288
146412
|
}
|
|
146289
146413
|
if (process.argv.includes("-v") || process.argv.includes("--version")) {
|
|
146290
|
-
(async () => {
|
|
146414
|
+
void (async () => {
|
|
146291
146415
|
await checkVersion();
|
|
146292
146416
|
process.exit(0);
|
|
146293
146417
|
})();
|