appwrite-cli 13.5.0 → 13.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +2 -2
- package/cli.ts +7 -5
- package/dist/bundle-win-arm64.mjs +988 -258
- package/dist/cli.cjs +988 -258
- package/dist/index.cjs +183 -112
- package/dist/index.js +183 -112
- 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/schema.d.ts.map +1 -1
- package/dist/lib/commands/services/activities.d.ts +3 -0
- package/dist/lib/commands/services/activities.d.ts.map +1 -0
- package/dist/lib/commands/services/backups.d.ts +3 -0
- package/dist/lib/commands/services/backups.d.ts.map +1 -0
- 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/docs/examples/account/create-key.md +5 -0
- package/docs/examples/account/delete-key.md +4 -0
- package/docs/examples/account/get-key.md +4 -0
- package/docs/examples/account/list-keys.md +3 -0
- package/docs/examples/account/update-key.md +6 -0
- package/docs/examples/activities/get-event.md +4 -0
- package/docs/examples/activities/list-events.md +3 -0
- package/docs/examples/backups/create-archive.md +4 -0
- package/docs/examples/backups/create-policy.md +7 -0
- package/docs/examples/backups/create-restoration.md +5 -0
- package/docs/examples/backups/delete-archive.md +4 -0
- package/docs/examples/backups/delete-policy.md +4 -0
- package/docs/examples/backups/get-archive.md +4 -0
- package/docs/examples/backups/get-policy.md +4 -0
- package/docs/examples/backups/get-restoration.md +4 -0
- package/docs/examples/backups/list-archives.md +3 -0
- package/docs/examples/backups/list-policies.md +3 -0
- package/docs/examples/backups/list-restorations.md +3 -0
- package/docs/examples/backups/update-policy.md +4 -0
- 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/schema.ts +1 -3
- package/lib/commands/services/account.ts +234 -0
- package/lib/commands/services/activities.ts +51 -0
- package/lib/commands/services/backups.ts +184 -0
- package/lib/commands/services/health.ts +55 -0
- package/lib/commands/services/projects.ts +1 -1
- package/lib/commands/services/storage.ts +2 -2
- 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 +21 -8
- 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 +8 -2
- package/scoop/appwrite.config.json +3 -3
- package/dist/lib/commands/services/console.d.ts +0 -3
- package/dist/lib/commands/services/console.d.ts.map +0 -1
- package/docs/examples/console/get-resource.md +0 -5
- package/docs/examples/console/variables.md +0 -3
- package/lib/commands/services/console.ts +0 -49
package/dist/index.js
CHANGED
|
@@ -1939,9 +1939,9 @@ var require_source = __commonJS({
|
|
|
1939
1939
|
}
|
|
1940
1940
|
});
|
|
1941
1941
|
|
|
1942
|
-
// node_modules/escape-string-regexp/index.js
|
|
1942
|
+
// node_modules/figures/node_modules/escape-string-regexp/index.js
|
|
1943
1943
|
var require_escape_string_regexp = __commonJS({
|
|
1944
|
-
"node_modules/escape-string-regexp/index.js"(exports, module) {
|
|
1944
|
+
"node_modules/figures/node_modules/escape-string-regexp/index.js"(exports, module) {
|
|
1945
1945
|
"use strict";
|
|
1946
1946
|
var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
|
|
1947
1947
|
module.exports = function(str) {
|
|
@@ -19605,6 +19605,7 @@ var require_safe_buffer = __commonJS({
|
|
|
19605
19605
|
function SafeBuffer(arg, encodingOrOffset, length) {
|
|
19606
19606
|
return Buffer2(arg, encodingOrOffset, length);
|
|
19607
19607
|
}
|
|
19608
|
+
SafeBuffer.prototype = Object.create(Buffer2.prototype);
|
|
19608
19609
|
copyProps(Buffer2, SafeBuffer);
|
|
19609
19610
|
SafeBuffer.from = function(arg, encodingOrOffset, length) {
|
|
19610
19611
|
if (typeof arg === "number") {
|
|
@@ -69356,7 +69357,7 @@ var id_default = ID;
|
|
|
69356
69357
|
// lib/constants.ts
|
|
69357
69358
|
var SDK_TITLE = "Appwrite";
|
|
69358
69359
|
var SDK_TITLE_LOWER = "appwrite";
|
|
69359
|
-
var SDK_VERSION = "13.
|
|
69360
|
+
var SDK_VERSION = "13.6.1";
|
|
69360
69361
|
var SDK_LOGO = "\n _ _ _ ___ __ _____\n /_\\ _ __ _ ____ ___ __(_) |_ ___ / __\\ / / \\_ \\\n //_\\\\| '_ \\| '_ \\ \\ /\\ / / '__| | __/ _ \\ / / / / / /\\/\n / _ \\ |_) | |_) \\ V V /| | | | || __/ / /___/ /___/\\/ /_\n \\_/ \\_/ .__/| .__/ \\_/\\_/ |_| |_|\\__\\___| \\____/\\____/\\____/\n |_| |_|\n\n";
|
|
69361
69362
|
var EXECUTABLE_NAME = "appwrite";
|
|
69362
69363
|
var NPM_PACKAGE_NAME = "appwrite-cli";
|
|
@@ -83264,7 +83265,7 @@ var int64Schema = external_exports.preprocess(
|
|
|
83264
83265
|
const valueOfResult = val.valueOf();
|
|
83265
83266
|
const bigIntVal = BigInt(valueOfResult);
|
|
83266
83267
|
return bigIntVal;
|
|
83267
|
-
} catch (
|
|
83268
|
+
} catch (_e) {
|
|
83268
83269
|
return void 0;
|
|
83269
83270
|
}
|
|
83270
83271
|
}
|
|
@@ -83274,7 +83275,7 @@ var int64Schema = external_exports.preprocess(
|
|
|
83274
83275
|
if (typeof val === "string") {
|
|
83275
83276
|
try {
|
|
83276
83277
|
return BigInt(val);
|
|
83277
|
-
} catch (
|
|
83278
|
+
} catch (_e) {
|
|
83278
83279
|
return void 0;
|
|
83279
83280
|
}
|
|
83280
83281
|
}
|
|
@@ -83588,7 +83589,7 @@ var createSettingsObject = (project) => {
|
|
|
83588
83589
|
};
|
|
83589
83590
|
};
|
|
83590
83591
|
var checkDeployConditions = (localConfig2) => {
|
|
83591
|
-
if (
|
|
83592
|
+
if (localConfig2.keys().length === 0) {
|
|
83592
83593
|
throw new Error(
|
|
83593
83594
|
"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."
|
|
83594
83595
|
);
|
|
@@ -83624,6 +83625,8 @@ var JSONbigParser = (0, import_json_bigint.default)({ storeAsString: false });
|
|
|
83624
83625
|
var JSONbigSerializer = (0, import_json_bigint.default)({ useNativeBigInt: true });
|
|
83625
83626
|
var MAX_SAFE = BigInt(Number.MAX_SAFE_INTEGER);
|
|
83626
83627
|
var MIN_SAFE = BigInt(Number.MIN_SAFE_INTEGER);
|
|
83628
|
+
var MAX_INT64 = BigInt("9223372036854775807");
|
|
83629
|
+
var MIN_INT64 = BigInt("-9223372036854775808");
|
|
83627
83630
|
function isBigNumber(value) {
|
|
83628
83631
|
return value !== null && typeof value === "object" && value._isBigNumber === true && typeof value.isInteger === "function" && typeof value.toFixed === "function" && typeof value.toNumber === "function";
|
|
83629
83632
|
}
|
|
@@ -83635,7 +83638,10 @@ function reviver(_key, value) {
|
|
|
83635
83638
|
if (bi >= MIN_SAFE && bi <= MAX_SAFE) {
|
|
83636
83639
|
return Number(str);
|
|
83637
83640
|
}
|
|
83638
|
-
|
|
83641
|
+
if (bi >= MIN_INT64 && bi <= MAX_INT64) {
|
|
83642
|
+
return bi;
|
|
83643
|
+
}
|
|
83644
|
+
return value.toNumber();
|
|
83639
83645
|
}
|
|
83640
83646
|
return value.toNumber();
|
|
83641
83647
|
}
|
|
@@ -83731,7 +83737,7 @@ var Config = class {
|
|
|
83731
83737
|
try {
|
|
83732
83738
|
const file2 = fs.readFileSync(this.path).toString();
|
|
83733
83739
|
this.data = JSONBig.parse(file2);
|
|
83734
|
-
} catch (
|
|
83740
|
+
} catch (_e) {
|
|
83735
83741
|
this.data = {};
|
|
83736
83742
|
}
|
|
83737
83743
|
}
|
|
@@ -84642,7 +84648,7 @@ var Spinner = class _Spinner {
|
|
|
84642
84648
|
static stop() {
|
|
84643
84649
|
_Spinner.updatesBar.stop();
|
|
84644
84650
|
}
|
|
84645
|
-
static formatter(
|
|
84651
|
+
static formatter(_options, _params, payload) {
|
|
84646
84652
|
const status = payload.status.padEnd(12);
|
|
84647
84653
|
const middle = `${payload.resource} (${payload.id})`.padEnd(40);
|
|
84648
84654
|
let prefix = import_chalk.default.cyan(payload.prefix ?? "\u29D7");
|
|
@@ -84713,19 +84719,22 @@ async function paginate(action, args = {}, limit = 100, wrapper = "", queries =
|
|
|
84713
84719
|
]
|
|
84714
84720
|
});
|
|
84715
84721
|
if (wrapper === "") {
|
|
84716
|
-
|
|
84722
|
+
const listResponse = response;
|
|
84723
|
+
if (listResponse.length === 0) {
|
|
84717
84724
|
break;
|
|
84718
84725
|
}
|
|
84719
|
-
results = results.concat(
|
|
84726
|
+
results = results.concat(listResponse);
|
|
84720
84727
|
} else {
|
|
84721
|
-
|
|
84728
|
+
const wrappedResponse = response;
|
|
84729
|
+
const wrappedResults = wrappedResponse[wrapper] ?? [];
|
|
84730
|
+
if (wrappedResults.length === 0) {
|
|
84731
|
+
break;
|
|
84732
|
+
}
|
|
84733
|
+
results = results.concat(wrappedResults);
|
|
84734
|
+
total = wrappedResponse.total;
|
|
84735
|
+
if (results.length >= total) {
|
|
84722
84736
|
break;
|
|
84723
84737
|
}
|
|
84724
|
-
results = results.concat(response[wrapper]);
|
|
84725
|
-
}
|
|
84726
|
-
total = response.total;
|
|
84727
|
-
if (results.length >= total) {
|
|
84728
|
-
break;
|
|
84729
84738
|
}
|
|
84730
84739
|
pageNumber++;
|
|
84731
84740
|
}
|
|
@@ -84834,6 +84843,8 @@ Query.cursorBefore = (documentId) => new Query("cursorBefore", void 0, documentI
|
|
|
84834
84843
|
Query.limit = (limit) => new Query("limit", void 0, limit).toString();
|
|
84835
84844
|
Query.offset = (offset) => new Query("offset", void 0, offset).toString();
|
|
84836
84845
|
Query.contains = (attribute, value) => new Query("contains", attribute, value).toString();
|
|
84846
|
+
Query.containsAny = (attribute, value) => new Query("containsAny", attribute, value).toString();
|
|
84847
|
+
Query.containsAll = (attribute, value) => new Query("containsAll", attribute, value).toString();
|
|
84837
84848
|
Query.notContains = (attribute, value) => new Query("notContains", attribute, value).toString();
|
|
84838
84849
|
Query.notSearch = (attribute, value) => new Query("notSearch", attribute, value).toString();
|
|
84839
84850
|
Query.notBetween = (attribute, start, end) => new Query("notBetween", attribute, [start, end]).toString();
|
|
@@ -84864,6 +84875,8 @@ var JSONbigParser2 = (0, import_json_bigint2.default)({ storeAsString: false });
|
|
|
84864
84875
|
var JSONbigSerializer2 = (0, import_json_bigint2.default)({ useNativeBigInt: true });
|
|
84865
84876
|
var MAX_SAFE2 = BigInt(Number.MAX_SAFE_INTEGER);
|
|
84866
84877
|
var MIN_SAFE2 = BigInt(Number.MIN_SAFE_INTEGER);
|
|
84878
|
+
var MAX_INT642 = BigInt("9223372036854775807");
|
|
84879
|
+
var MIN_INT642 = BigInt("-9223372036854775808");
|
|
84867
84880
|
function isBigNumber2(value) {
|
|
84868
84881
|
return value !== null && typeof value === "object" && value._isBigNumber === true && typeof value.isInteger === "function" && typeof value.toFixed === "function" && typeof value.toNumber === "function";
|
|
84869
84882
|
}
|
|
@@ -84875,7 +84888,10 @@ function reviver2(_key, value) {
|
|
|
84875
84888
|
if (bi >= MIN_SAFE2 && bi <= MAX_SAFE2) {
|
|
84876
84889
|
return Number(str);
|
|
84877
84890
|
}
|
|
84878
|
-
|
|
84891
|
+
if (bi >= MIN_INT642 && bi <= MAX_INT642) {
|
|
84892
|
+
return bi;
|
|
84893
|
+
}
|
|
84894
|
+
return value.toNumber();
|
|
84879
84895
|
}
|
|
84880
84896
|
return value.toNumber();
|
|
84881
84897
|
}
|
|
@@ -84922,7 +84938,7 @@ var Client = class _Client {
|
|
|
84922
84938
|
"x-sdk-name": "Console",
|
|
84923
84939
|
"x-sdk-platform": "console",
|
|
84924
84940
|
"x-sdk-language": "web",
|
|
84925
|
-
"x-sdk-version": "3.
|
|
84941
|
+
"x-sdk-version": "3.1.0",
|
|
84926
84942
|
"X-Appwrite-Response-Format": "1.8.0"
|
|
84927
84943
|
};
|
|
84928
84944
|
this.realtime = {
|
|
@@ -94000,21 +94016,26 @@ var Organizations = class {
|
|
|
94000
94016
|
const apiHeaders = {};
|
|
94001
94017
|
return this.client.call("get", uri, apiHeaders, payload);
|
|
94002
94018
|
}
|
|
94003
|
-
getScopes(paramsOrFirst) {
|
|
94019
|
+
getScopes(paramsOrFirst, ...rest) {
|
|
94004
94020
|
let params;
|
|
94005
94021
|
if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
|
|
94006
94022
|
params = paramsOrFirst || {};
|
|
94007
94023
|
} else {
|
|
94008
94024
|
params = {
|
|
94009
|
-
organizationId: paramsOrFirst
|
|
94025
|
+
organizationId: paramsOrFirst,
|
|
94026
|
+
projectId: rest[0]
|
|
94010
94027
|
};
|
|
94011
94028
|
}
|
|
94012
94029
|
const organizationId = params.organizationId;
|
|
94030
|
+
const projectId = params.projectId;
|
|
94013
94031
|
if (typeof organizationId === "undefined") {
|
|
94014
94032
|
throw new AppwriteException('Missing required parameter: "organizationId"');
|
|
94015
94033
|
}
|
|
94016
94034
|
const apiPath = "/organizations/{organizationId}/roles".replace("{organizationId}", organizationId);
|
|
94017
94035
|
const payload = {};
|
|
94036
|
+
if (typeof projectId !== "undefined") {
|
|
94037
|
+
payload["projectId"] = projectId;
|
|
94038
|
+
}
|
|
94018
94039
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
94019
94040
|
const apiHeaders = {};
|
|
94020
94041
|
return this.client.call("get", uri, apiHeaders, payload);
|
|
@@ -103958,7 +103979,7 @@ var package_default = {
|
|
|
103958
103979
|
type: "module",
|
|
103959
103980
|
homepage: "https://appwrite.io/support",
|
|
103960
103981
|
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",
|
|
103961
|
-
version: "13.
|
|
103982
|
+
version: "13.6.1",
|
|
103962
103983
|
license: "BSD-3-Clause",
|
|
103963
103984
|
main: "dist/index.cjs",
|
|
103964
103985
|
module: "dist/index.js",
|
|
@@ -103989,6 +104010,7 @@ var package_default = {
|
|
|
103989
104010
|
"build:lib:esm": "esbuild index.ts --bundle --platform=node --target=node18 --format=esm --loader:.hbs=text --outfile=dist/index.js",
|
|
103990
104011
|
"build:lib:cjs": "esbuild index.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --outfile=dist/index.cjs",
|
|
103991
104012
|
"build:cli": "esbuild cli.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:fsevents --outfile=dist/cli.cjs",
|
|
104013
|
+
lint: "eslint .",
|
|
103992
104014
|
format: 'prettier --write "**/*.{js,ts,json,md}"',
|
|
103993
104015
|
generate: "tsx scripts/generate-commands.ts",
|
|
103994
104016
|
prepublishOnly: "npm run build",
|
|
@@ -104001,7 +104023,7 @@ var package_default = {
|
|
|
104001
104023
|
"windows-arm64": "esbuild cli.ts --bundle --loader:.hbs=text --platform=node --target=node18 --format=esm --external:fsevents --outfile=dist/bundle-win-arm64.mjs && pkg dist/bundle-win-arm64.mjs -t node18-win-arm64 -o build/appwrite-cli-win-arm64.exe"
|
|
104002
104024
|
},
|
|
104003
104025
|
dependencies: {
|
|
104004
|
-
"@appwrite.io/console": "^3.
|
|
104026
|
+
"@appwrite.io/console": "^3.1.0",
|
|
104005
104027
|
chalk: "4.1.2",
|
|
104006
104028
|
chokidar: "^3.6.0",
|
|
104007
104029
|
"cli-progress": "^3.12.0",
|
|
@@ -104020,7 +104042,12 @@ var package_default = {
|
|
|
104020
104042
|
zod: "^4.3.5"
|
|
104021
104043
|
},
|
|
104022
104044
|
devDependencies: {
|
|
104045
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
104046
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
104023
104047
|
"@types/bun": "^1.3.5",
|
|
104048
|
+
eslint: "^9.0.0",
|
|
104049
|
+
"eslint-plugin-unused-imports": "^4.0.0",
|
|
104050
|
+
"typescript-eslint": "^8.0.0",
|
|
104024
104051
|
"@types/cli-progress": "^3.11.5",
|
|
104025
104052
|
"@types/inquirer": "^8.2.10",
|
|
104026
104053
|
"@types/json-bigint": "^1.0.4",
|
|
@@ -104052,14 +104079,28 @@ var cliConfig = {
|
|
|
104052
104079
|
report: false,
|
|
104053
104080
|
reportData: {}
|
|
104054
104081
|
};
|
|
104082
|
+
var toJsonObject = (value) => {
|
|
104083
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
104084
|
+
return value;
|
|
104085
|
+
}
|
|
104086
|
+
return null;
|
|
104087
|
+
};
|
|
104088
|
+
var extractReportCommandArgs = (value) => {
|
|
104089
|
+
if (!value || typeof value !== "object") {
|
|
104090
|
+
return [];
|
|
104091
|
+
}
|
|
104092
|
+
const reportData = value;
|
|
104093
|
+
if (!Array.isArray(reportData.data?.args)) {
|
|
104094
|
+
return [];
|
|
104095
|
+
}
|
|
104096
|
+
return reportData.data.args;
|
|
104097
|
+
};
|
|
104055
104098
|
var drawTable = (data) => {
|
|
104056
104099
|
if (data.length == 0) {
|
|
104057
104100
|
console.log("[]");
|
|
104058
104101
|
return;
|
|
104059
104102
|
}
|
|
104060
|
-
const rows = data.map(
|
|
104061
|
-
(item) => item && typeof item === "object" && !Array.isArray(item) ? item : {}
|
|
104062
|
-
);
|
|
104103
|
+
const rows = data.map((item) => toJsonObject(item) ?? {});
|
|
104063
104104
|
const obj = rows.reduce((res, item) => ({ ...res, ...item }), {});
|
|
104064
104105
|
const keys = Object.keys(obj);
|
|
104065
104106
|
if (keys.length === 0) {
|
|
@@ -104102,7 +104143,7 @@ var drawTable = (data) => {
|
|
|
104102
104143
|
} else if (typeof row[key] === "object") {
|
|
104103
104144
|
rowValues.push(JSON.stringify(row[key]));
|
|
104104
104145
|
} else {
|
|
104105
|
-
rowValues.push(row[key]);
|
|
104146
|
+
rowValues.push(String(row[key]));
|
|
104106
104147
|
}
|
|
104107
104148
|
}
|
|
104108
104149
|
table.push(rowValues);
|
|
@@ -104114,7 +104155,7 @@ var drawJSON = (data) => {
|
|
|
104114
104155
|
};
|
|
104115
104156
|
var parseError = (err) => {
|
|
104116
104157
|
if (cliConfig.report) {
|
|
104117
|
-
(async () => {
|
|
104158
|
+
void (async () => {
|
|
104118
104159
|
let appwriteVersion = "unknown";
|
|
104119
104160
|
const endpoint = globalConfig2.getEndpoint();
|
|
104120
104161
|
try {
|
|
@@ -104127,7 +104168,8 @@ var parseError = (err) => {
|
|
|
104127
104168
|
} catch {
|
|
104128
104169
|
}
|
|
104129
104170
|
const version2 = SDK_VERSION;
|
|
104130
|
-
const
|
|
104171
|
+
const commandArgs = extractReportCommandArgs(cliConfig.reportData);
|
|
104172
|
+
const stepsToReproduce = `Running \`${EXECUTABLE_NAME} ${commandArgs.join(" ")}\``;
|
|
104131
104173
|
const yourEnvironment = `CLI version: ${version2}
|
|
104132
104174
|
Operation System: ${os2.type()}
|
|
104133
104175
|
Appwrite version: ${appwriteVersion}
|
|
@@ -104179,7 +104221,7 @@ var actionRunner = (fn) => {
|
|
|
104179
104221
|
error48(`The '--all' and '--id' flags cannot be used together.`);
|
|
104180
104222
|
process.exit(1);
|
|
104181
104223
|
}
|
|
104182
|
-
return fn(...args).catch(parseError);
|
|
104224
|
+
return fn(...args).then(() => void 0).catch(parseError);
|
|
104183
104225
|
};
|
|
104184
104226
|
};
|
|
104185
104227
|
var log = (message) => {
|
|
@@ -104292,6 +104334,9 @@ async function downloadDeploymentCode(params) {
|
|
|
104292
104334
|
{},
|
|
104293
104335
|
"arrayBuffer"
|
|
104294
104336
|
);
|
|
104337
|
+
if (!(downloadBuffer instanceof ArrayBuffer)) {
|
|
104338
|
+
throw new Error("Failed to download deployment archive as ArrayBuffer.");
|
|
104339
|
+
}
|
|
104295
104340
|
try {
|
|
104296
104341
|
fs2.writeFileSync(compressedFileName, Buffer.from(downloadBuffer));
|
|
104297
104342
|
} catch (err) {
|
|
@@ -104503,7 +104548,7 @@ var questionsInitProject = [
|
|
|
104503
104548
|
name: "organization",
|
|
104504
104549
|
message: "Choose your organization",
|
|
104505
104550
|
choices: async () => {
|
|
104506
|
-
|
|
104551
|
+
const client = await sdkForConsole(true);
|
|
104507
104552
|
const { teams } = isCloud() ? await paginate(
|
|
104508
104553
|
async (opts = {}) => (await getOrganizationsService(opts.sdk)).list(),
|
|
104509
104554
|
{ sdk: client },
|
|
@@ -104515,7 +104560,7 @@ var questionsInitProject = [
|
|
|
104515
104560
|
100,
|
|
104516
104561
|
"teams"
|
|
104517
104562
|
);
|
|
104518
|
-
|
|
104563
|
+
const choices = teams.map((team, _idx) => {
|
|
104519
104564
|
return {
|
|
104520
104565
|
name: `${team.name} (${team["$id"]})`,
|
|
104521
104566
|
value: team["$id"]
|
|
@@ -104564,7 +104609,7 @@ var questionsInitProject = [
|
|
|
104564
104609
|
"projects",
|
|
104565
104610
|
queries
|
|
104566
104611
|
);
|
|
104567
|
-
|
|
104612
|
+
const choices = projects.map((project) => {
|
|
104568
104613
|
return {
|
|
104569
104614
|
name: `${project.name} (${project["$id"]})`,
|
|
104570
104615
|
value: {
|
|
@@ -104585,13 +104630,13 @@ var questionsInitProject = [
|
|
|
104585
104630
|
name: "region",
|
|
104586
104631
|
message: `Select your ${SDK_TITLE} Cloud region`,
|
|
104587
104632
|
choices: async () => {
|
|
104588
|
-
|
|
104633
|
+
const client = await sdkForConsole(true);
|
|
104589
104634
|
const endpoint = globalConfig2.getEndpoint() || DEFAULT_ENDPOINT;
|
|
104590
|
-
|
|
104635
|
+
const response = await client.call(
|
|
104591
104636
|
"GET",
|
|
104592
104637
|
new URL(endpoint + "/console/regions")
|
|
104593
104638
|
);
|
|
104594
|
-
|
|
104639
|
+
const regions = response.regions || [];
|
|
104595
104640
|
if (!regions.length) {
|
|
104596
104641
|
throw new Error(
|
|
104597
104642
|
"No regions found. Please check your network or Appwrite Cloud availability."
|
|
@@ -104718,9 +104763,9 @@ var questionGetEndpoint = [
|
|
|
104718
104763
|
if (!value) {
|
|
104719
104764
|
return "Please enter a valid endpoint.";
|
|
104720
104765
|
}
|
|
104721
|
-
|
|
104766
|
+
const client = new Client().setEndpoint(value);
|
|
104722
104767
|
try {
|
|
104723
|
-
|
|
104768
|
+
const response = await client.call(
|
|
104724
104769
|
"get",
|
|
104725
104770
|
new URL(value + "/health/version")
|
|
104726
104771
|
);
|
|
@@ -104729,7 +104774,7 @@ var questionGetEndpoint = [
|
|
|
104729
104774
|
} else {
|
|
104730
104775
|
throw new Error();
|
|
104731
104776
|
}
|
|
104732
|
-
} catch (
|
|
104777
|
+
} catch (_error) {
|
|
104733
104778
|
return "Invalid endpoint or your Appwrite server is not running as expected.";
|
|
104734
104779
|
}
|
|
104735
104780
|
}
|
|
@@ -104765,9 +104810,9 @@ var questionsPushSites = [
|
|
|
104765
104810
|
validate: (value) => validateRequired("site", value),
|
|
104766
104811
|
when: () => localConfig.getSites().length > 0,
|
|
104767
104812
|
choices: () => {
|
|
104768
|
-
|
|
104813
|
+
const sites = localConfig.getSites();
|
|
104769
104814
|
checkDeployConditions(localConfig);
|
|
104770
|
-
|
|
104815
|
+
const choices = sites.map((site, _idx) => {
|
|
104771
104816
|
return {
|
|
104772
104817
|
name: `${site.name} (${site.$id})`,
|
|
104773
104818
|
value: site.$id
|
|
@@ -104785,9 +104830,9 @@ var questionsPushFunctions = [
|
|
|
104785
104830
|
validate: (value) => validateRequired("function", value),
|
|
104786
104831
|
when: () => localConfig.getFunctions().length > 0,
|
|
104787
104832
|
choices: () => {
|
|
104788
|
-
|
|
104833
|
+
const functions = localConfig.getFunctions();
|
|
104789
104834
|
checkDeployConditions(localConfig);
|
|
104790
|
-
|
|
104835
|
+
const choices = functions.map((func, _idx) => {
|
|
104791
104836
|
return {
|
|
104792
104837
|
name: `${func.name} (${func.$id})`,
|
|
104793
104838
|
value: func.$id
|
|
@@ -104805,7 +104850,7 @@ var questionsPushCollections = [
|
|
|
104805
104850
|
validate: (value) => validateRequired("collection", value),
|
|
104806
104851
|
when: () => localConfig.getCollections().length > 0,
|
|
104807
104852
|
choices: () => {
|
|
104808
|
-
|
|
104853
|
+
const collections = localConfig.getCollections();
|
|
104809
104854
|
checkDeployConditions(localConfig);
|
|
104810
104855
|
return collections.map((collection) => {
|
|
104811
104856
|
return {
|
|
@@ -104824,7 +104869,7 @@ var questionsPushTables = [
|
|
|
104824
104869
|
validate: (value) => validateRequired("table", value),
|
|
104825
104870
|
when: () => localConfig.getTables().length > 0,
|
|
104826
104871
|
choices: () => {
|
|
104827
|
-
|
|
104872
|
+
const tables = localConfig.getTables();
|
|
104828
104873
|
checkDeployConditions(localConfig);
|
|
104829
104874
|
return tables.map((table) => {
|
|
104830
104875
|
return {
|
|
@@ -104857,7 +104902,7 @@ var questionsPushBuckets = [
|
|
|
104857
104902
|
validate: (value) => validateRequired("bucket", value),
|
|
104858
104903
|
when: () => localConfig.getBuckets().length > 0,
|
|
104859
104904
|
choices: () => {
|
|
104860
|
-
|
|
104905
|
+
const buckets = localConfig.getBuckets();
|
|
104861
104906
|
checkDeployConditions(localConfig);
|
|
104862
104907
|
return buckets.map((bucket) => {
|
|
104863
104908
|
return {
|
|
@@ -104876,7 +104921,7 @@ var questionsPushMessagingTopics = [
|
|
|
104876
104921
|
validate: (value) => validateRequired("topics", value),
|
|
104877
104922
|
when: () => localConfig.getMessagingTopics().length > 0,
|
|
104878
104923
|
choices: () => {
|
|
104879
|
-
|
|
104924
|
+
const topics = localConfig.getMessagingTopics();
|
|
104880
104925
|
return topics.map((topic) => {
|
|
104881
104926
|
return {
|
|
104882
104927
|
name: `${topic.name} (${topic["$id"]})`,
|
|
@@ -104907,7 +104952,7 @@ var questionsPushTeams = [
|
|
|
104907
104952
|
validate: (value) => validateRequired("team", value),
|
|
104908
104953
|
when: () => localConfig.getTeams().length > 0,
|
|
104909
104954
|
choices: () => {
|
|
104910
|
-
|
|
104955
|
+
const teams = localConfig.getTeams();
|
|
104911
104956
|
checkDeployConditions(localConfig);
|
|
104912
104957
|
return teams.map((team) => {
|
|
104913
104958
|
return {
|
|
@@ -104949,7 +104994,7 @@ var Pools = class {
|
|
|
104949
104994
|
return true;
|
|
104950
104995
|
}
|
|
104951
104996
|
if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
|
|
104952
|
-
|
|
104997
|
+
const steps = Math.max(1, Math.ceil(Number(total) / this.STEP_SIZE));
|
|
104953
104998
|
if (steps > 1 && iteration === 1) {
|
|
104954
104999
|
this.pollMaxDebounces *= steps;
|
|
104955
105000
|
log(
|
|
@@ -104975,7 +105020,7 @@ var Pools = class {
|
|
|
104975
105020
|
return true;
|
|
104976
105021
|
}
|
|
104977
105022
|
if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
|
|
104978
|
-
|
|
105023
|
+
const steps = Math.max(1, Math.ceil(Number(total) / this.STEP_SIZE));
|
|
104979
105024
|
if (steps > 1 && iteration === 1) {
|
|
104980
105025
|
this.pollMaxDebounces *= steps;
|
|
104981
105026
|
log(
|
|
@@ -104991,7 +105036,10 @@ var Pools = class {
|
|
|
104991
105036
|
return false;
|
|
104992
105037
|
}
|
|
104993
105038
|
if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
|
|
104994
|
-
|
|
105039
|
+
const steps = Math.max(
|
|
105040
|
+
1,
|
|
105041
|
+
Math.ceil(attributeKeys.length / this.STEP_SIZE)
|
|
105042
|
+
);
|
|
104995
105043
|
if (steps > 1 && iteration === 1) {
|
|
104996
105044
|
this.pollMaxDebounces *= steps;
|
|
104997
105045
|
log(
|
|
@@ -105034,7 +105082,10 @@ var Pools = class {
|
|
|
105034
105082
|
return false;
|
|
105035
105083
|
}
|
|
105036
105084
|
if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
|
|
105037
|
-
|
|
105085
|
+
const steps = Math.max(
|
|
105086
|
+
1,
|
|
105087
|
+
Math.ceil(attributeKeys.length / this.STEP_SIZE)
|
|
105088
|
+
);
|
|
105038
105089
|
if (steps > 1 && iteration === 1) {
|
|
105039
105090
|
this.pollMaxDebounces *= steps;
|
|
105040
105091
|
log(
|
|
@@ -105083,7 +105134,7 @@ var Pools = class {
|
|
|
105083
105134
|
return false;
|
|
105084
105135
|
}
|
|
105085
105136
|
if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
|
|
105086
|
-
|
|
105137
|
+
const steps = Math.max(1, Math.ceil(indexKeys.length / this.STEP_SIZE));
|
|
105087
105138
|
if (steps > 1 && iteration === 1) {
|
|
105088
105139
|
this.pollMaxDebounces *= steps;
|
|
105089
105140
|
log(
|
|
@@ -105176,7 +105227,7 @@ var Attributes = class {
|
|
|
105176
105227
|
}
|
|
105177
105228
|
return answers2.changes;
|
|
105178
105229
|
}
|
|
105179
|
-
|
|
105230
|
+
const answers = await import_inquirer.default.prompt(questionPushChanges2);
|
|
105180
105231
|
if (answers.changes !== "YES" && answers.changes !== "NO") {
|
|
105181
105232
|
answers.changes = await fixConfirmation();
|
|
105182
105233
|
}
|
|
@@ -105219,8 +105270,8 @@ var Attributes = class {
|
|
|
105219
105270
|
const keyName = `${import_chalk4.default.yellow(local.key)} in ${collection.name} (${collection["$id"]})`;
|
|
105220
105271
|
const action = import_chalk4.default.cyan(recreating ? "recreating" : "changing");
|
|
105221
105272
|
let reason = "";
|
|
105222
|
-
|
|
105223
|
-
for (
|
|
105273
|
+
const attribute = recreating ? remote : local;
|
|
105274
|
+
for (const key of Object.keys(remote)) {
|
|
105224
105275
|
if (!KeysAttributes.has(key)) {
|
|
105225
105276
|
continue;
|
|
105226
105277
|
}
|
|
@@ -105730,7 +105781,7 @@ var Attributes = class {
|
|
|
105730
105781
|
createIndexes = async (indexes, collection) => {
|
|
105731
105782
|
log(`Creating indexes ...`);
|
|
105732
105783
|
const databasesService = await getDatabasesService(this.client);
|
|
105733
|
-
for (
|
|
105784
|
+
for (const index of indexes) {
|
|
105734
105785
|
await databasesService.createIndex({
|
|
105735
105786
|
databaseId: collection["databaseId"],
|
|
105736
105787
|
collectionId: collection["$id"],
|
|
@@ -105754,7 +105805,7 @@ var Attributes = class {
|
|
|
105754
105805
|
};
|
|
105755
105806
|
createAttributes = async (attributes, collection) => {
|
|
105756
105807
|
log(`Creating attributes ...`);
|
|
105757
|
-
for (
|
|
105808
|
+
for (const attribute of attributes) {
|
|
105758
105809
|
if (attribute.side !== "child") {
|
|
105759
105810
|
await this.createAttribute(
|
|
105760
105811
|
collection["databaseId"],
|
|
@@ -105778,7 +105829,7 @@ var Attributes = class {
|
|
|
105778
105829
|
};
|
|
105779
105830
|
createColumns = async (columns, table) => {
|
|
105780
105831
|
log(`Creating columns ...`);
|
|
105781
|
-
for (
|
|
105832
|
+
for (const column of columns) {
|
|
105782
105833
|
if (column.side !== "child") {
|
|
105783
105834
|
await this.createAttribute(table["databaseId"], table["$id"], column);
|
|
105784
105835
|
}
|
|
@@ -105813,7 +105864,7 @@ var getConfirmation = async () => {
|
|
|
105813
105864
|
}
|
|
105814
105865
|
return answers2.changes;
|
|
105815
105866
|
}
|
|
105816
|
-
|
|
105867
|
+
const answers = await import_inquirer2.default.prompt(questionPushChanges);
|
|
105817
105868
|
if (answers.changes !== "YES" && answers.changes !== "NO") {
|
|
105818
105869
|
answers.changes = await fixConfirmation();
|
|
105819
105870
|
}
|
|
@@ -105863,7 +105914,7 @@ var approveChanges = async (resource, resourceGetFunction, keys, resourceName, r
|
|
|
105863
105914
|
options[secondResourceName] = localResource[secondId];
|
|
105864
105915
|
}
|
|
105865
105916
|
const remoteResource = await resourceGetFunction(options);
|
|
105866
|
-
for (
|
|
105917
|
+
for (const [key, value] of Object.entries(
|
|
105867
105918
|
whitelistKeys(remoteResource, keys)
|
|
105868
105919
|
)) {
|
|
105869
105920
|
if (skipKeys.includes(key)) {
|
|
@@ -105872,28 +105923,30 @@ var approveChanges = async (resource, resourceGetFunction, keys, resourceName, r
|
|
|
105872
105923
|
if (isEmpty(value) && isEmpty(localResource[key])) {
|
|
105873
105924
|
continue;
|
|
105874
105925
|
}
|
|
105875
|
-
|
|
105876
|
-
|
|
105926
|
+
const localValue = localResource[key];
|
|
105927
|
+
if (Array.isArray(value) && Array.isArray(localValue)) {
|
|
105928
|
+
if (JSON.stringify(value) !== JSON.stringify(localValue)) {
|
|
105877
105929
|
changes.push({
|
|
105878
105930
|
id: localResource["$id"],
|
|
105879
105931
|
key,
|
|
105880
105932
|
remote: import_chalk5.default.red(value.join("\n")),
|
|
105881
|
-
local: import_chalk5.default.green(
|
|
105933
|
+
local: import_chalk5.default.green(
|
|
105934
|
+
localValue.map((entry) => String(entry)).join("\n")
|
|
105935
|
+
)
|
|
105882
105936
|
});
|
|
105883
105937
|
}
|
|
105884
|
-
} else if (value !==
|
|
105938
|
+
} else if (value !== localValue) {
|
|
105885
105939
|
changes.push({
|
|
105886
105940
|
id: localResource["$id"],
|
|
105887
105941
|
key,
|
|
105888
|
-
remote: import_chalk5.default.red(value),
|
|
105889
|
-
local: import_chalk5.default.green(
|
|
105942
|
+
remote: import_chalk5.default.red(String(value ?? "")),
|
|
105943
|
+
local: import_chalk5.default.green(String(localValue ?? ""))
|
|
105890
105944
|
});
|
|
105891
105945
|
}
|
|
105892
105946
|
}
|
|
105893
105947
|
} catch (e) {
|
|
105894
|
-
|
|
105895
|
-
|
|
105896
|
-
}
|
|
105948
|
+
const isNotFound = e instanceof AppwriteException && Number(e.code) === 404;
|
|
105949
|
+
if (!isNotFound) throw e;
|
|
105897
105950
|
}
|
|
105898
105951
|
})
|
|
105899
105952
|
);
|
|
@@ -105910,18 +105963,37 @@ var approveChanges = async (resource, resourceGetFunction, keys, resourceName, r
|
|
|
105910
105963
|
|
|
105911
105964
|
// lib/commands/utils/database-sync.ts
|
|
105912
105965
|
var import_chalk6 = __toESM(require_source(), 1);
|
|
105966
|
+
var isTablesDBResource = (value) => {
|
|
105967
|
+
if (!value || typeof value !== "object") {
|
|
105968
|
+
return false;
|
|
105969
|
+
}
|
|
105970
|
+
return "$id" in value && typeof value.$id === "string" && "name" in value && typeof value.name === "string" && "enabled" in value && typeof value.enabled === "boolean";
|
|
105971
|
+
};
|
|
105972
|
+
var getSyncErrorMessage = (err) => {
|
|
105973
|
+
if (err instanceof AppwriteException) {
|
|
105974
|
+
return err.message;
|
|
105975
|
+
}
|
|
105976
|
+
if (err instanceof Error) {
|
|
105977
|
+
return err.message;
|
|
105978
|
+
}
|
|
105979
|
+
return String(err);
|
|
105980
|
+
};
|
|
105913
105981
|
var checkAndApplyTablesDBChanges = async () => {
|
|
105914
105982
|
log("Checking for tablesDB changes ...");
|
|
105915
105983
|
const localTablesDBs = localConfig.getTablesDBs();
|
|
105916
|
-
const
|
|
105984
|
+
const paginatedResult = await paginate(
|
|
105917
105985
|
async (args) => {
|
|
105918
105986
|
const tablesDBService = await getTablesDBService();
|
|
105919
|
-
|
|
105987
|
+
const queries = Array.isArray(args.queries) ? args.queries.filter(
|
|
105988
|
+
(query) => typeof query === "string"
|
|
105989
|
+
) : [];
|
|
105990
|
+
return await tablesDBService.list(queries);
|
|
105920
105991
|
},
|
|
105921
105992
|
{},
|
|
105922
105993
|
100,
|
|
105923
105994
|
"databases"
|
|
105924
105995
|
);
|
|
105996
|
+
const remoteTablesDBs = Array.isArray(paginatedResult.databases) ? paginatedResult.databases.filter(isTablesDBResource) : [];
|
|
105925
105997
|
if (localTablesDBs.length === 0 && remoteTablesDBs.length === 0) {
|
|
105926
105998
|
return { applied: false, resyncNeeded: false };
|
|
105927
105999
|
}
|
|
@@ -105943,9 +106015,7 @@ var checkAndApplyTablesDBChanges = async () => {
|
|
|
105943
106015
|
}
|
|
105944
106016
|
}
|
|
105945
106017
|
for (const localDB of localTablesDBs) {
|
|
105946
|
-
const remoteDB = remoteTablesDBs.find(
|
|
105947
|
-
(db) => db.$id === localDB.$id
|
|
105948
|
-
);
|
|
106018
|
+
const remoteDB = remoteTablesDBs.find((db) => db.$id === localDB.$id);
|
|
105949
106019
|
if (!remoteDB) {
|
|
105950
106020
|
toCreate.push(localDB);
|
|
105951
106021
|
changes.push({
|
|
@@ -106012,7 +106082,7 @@ var checkAndApplyTablesDBChanges = async () => {
|
|
|
106012
106082
|
needsResync = true;
|
|
106013
106083
|
} catch (e) {
|
|
106014
106084
|
error48(
|
|
106015
|
-
`Failed to delete database ${db.name} ( ${db.$id} ): ${e
|
|
106085
|
+
`Failed to delete database ${db.name} ( ${db.$id} ): ${getSyncErrorMessage(e)}`
|
|
106016
106086
|
);
|
|
106017
106087
|
throw new Error(
|
|
106018
106088
|
`Database sync failed during deletion of ${db.$id}. Some changes may have been applied.`
|
|
@@ -106027,7 +106097,7 @@ var checkAndApplyTablesDBChanges = async () => {
|
|
|
106027
106097
|
success2(`Created ${db.name} ( ${db.$id} )`);
|
|
106028
106098
|
} catch (e) {
|
|
106029
106099
|
error48(
|
|
106030
|
-
`Failed to create database ${db.name} ( ${db.$id} ): ${e
|
|
106100
|
+
`Failed to create database ${db.name} ( ${db.$id} ): ${getSyncErrorMessage(e)}`
|
|
106031
106101
|
);
|
|
106032
106102
|
throw new Error(
|
|
106033
106103
|
`Database sync failed during creation of ${db.$id}. Some changes may have been applied.`
|
|
@@ -106042,7 +106112,7 @@ var checkAndApplyTablesDBChanges = async () => {
|
|
|
106042
106112
|
success2(`Updated ${db.name} ( ${db.$id} )`);
|
|
106043
106113
|
} catch (e) {
|
|
106044
106114
|
error48(
|
|
106045
|
-
`Failed to update database ${db.name} ( ${db.$id} ): ${e
|
|
106115
|
+
`Failed to update database ${db.name} ( ${db.$id} ): ${getSyncErrorMessage(e)}`
|
|
106046
106116
|
);
|
|
106047
106117
|
throw new Error(
|
|
106048
106118
|
`Database sync failed during update of ${db.$id}. Some changes may have been applied.`
|
|
@@ -106276,7 +106346,7 @@ var Push = class {
|
|
|
106276
106346
|
}
|
|
106277
106347
|
if (settings.services) {
|
|
106278
106348
|
this.log("Applying service statuses ...");
|
|
106279
|
-
for (
|
|
106349
|
+
for (const [service, status] of Object.entries(settings.services)) {
|
|
106280
106350
|
await projectsService.updateServiceStatus({
|
|
106281
106351
|
projectId,
|
|
106282
106352
|
service,
|
|
@@ -106322,7 +106392,7 @@ var Push = class {
|
|
|
106322
106392
|
}
|
|
106323
106393
|
if (settings.auth.methods) {
|
|
106324
106394
|
this.log("Applying auth methods statuses ...");
|
|
106325
|
-
for (
|
|
106395
|
+
for (const [method, status] of Object.entries(settings.auth.methods)) {
|
|
106326
106396
|
await projectsService.updateAuthStatus({
|
|
106327
106397
|
projectId,
|
|
106328
106398
|
method,
|
|
@@ -106626,7 +106696,7 @@ var Push = class {
|
|
|
106626
106696
|
([key, value]) => ({ key, value })
|
|
106627
106697
|
);
|
|
106628
106698
|
}
|
|
106629
|
-
} catch (
|
|
106699
|
+
} catch (_error) {
|
|
106630
106700
|
envVariables = [];
|
|
106631
106701
|
}
|
|
106632
106702
|
await Promise.all(
|
|
@@ -106923,7 +106993,7 @@ var Push = class {
|
|
|
106923
106993
|
([key, value]) => ({ key, value })
|
|
106924
106994
|
);
|
|
106925
106995
|
}
|
|
106926
|
-
} catch (
|
|
106996
|
+
} catch (_error) {
|
|
106927
106997
|
envVariables = [];
|
|
106928
106998
|
}
|
|
106929
106999
|
await Promise.all(
|
|
@@ -107090,7 +107160,7 @@ var Push = class {
|
|
|
107090
107160
|
skipConfirmation,
|
|
107091
107161
|
this.projectClient
|
|
107092
107162
|
);
|
|
107093
|
-
|
|
107163
|
+
const tablesChanged = /* @__PURE__ */ new Set();
|
|
107094
107164
|
const errors = [];
|
|
107095
107165
|
await Promise.all(
|
|
107096
107166
|
tables.map(async (table) => {
|
|
@@ -107144,7 +107214,7 @@ var Push = class {
|
|
|
107144
107214
|
}
|
|
107145
107215
|
})
|
|
107146
107216
|
);
|
|
107147
|
-
for (
|
|
107217
|
+
for (const table of tables) {
|
|
107148
107218
|
let columns = table.columns;
|
|
107149
107219
|
let indexes = table.indexes;
|
|
107150
107220
|
let hadChanges = false;
|
|
@@ -107423,7 +107493,7 @@ var pushSettings = async () => {
|
|
|
107423
107493
|
checkDeployConditions(localConfig);
|
|
107424
107494
|
try {
|
|
107425
107495
|
const projectsService = await getProjectsService();
|
|
107426
|
-
|
|
107496
|
+
const response = await projectsService.get(
|
|
107427
107497
|
localConfig.getProject().projectId
|
|
107428
107498
|
);
|
|
107429
107499
|
const remoteSettings = createSettingsObject(response);
|
|
@@ -107456,7 +107526,7 @@ var pushSettings = async () => {
|
|
|
107456
107526
|
return;
|
|
107457
107527
|
}
|
|
107458
107528
|
}
|
|
107459
|
-
} catch (
|
|
107529
|
+
} catch (_e) {
|
|
107460
107530
|
}
|
|
107461
107531
|
try {
|
|
107462
107532
|
log("Pushing project settings ...");
|
|
@@ -107506,7 +107576,7 @@ var pushSite = async ({
|
|
|
107506
107576
|
);
|
|
107507
107577
|
return;
|
|
107508
107578
|
}
|
|
107509
|
-
|
|
107579
|
+
const sites = siteIds.map((id) => {
|
|
107510
107580
|
const sites2 = localConfig.getSites();
|
|
107511
107581
|
const site = sites2.find((s) => s.$id === id);
|
|
107512
107582
|
if (!site) {
|
|
@@ -107515,7 +107585,7 @@ var pushSite = async ({
|
|
|
107515
107585
|
return site;
|
|
107516
107586
|
});
|
|
107517
107587
|
log("Validating sites ...");
|
|
107518
|
-
for (
|
|
107588
|
+
for (const site of sites) {
|
|
107519
107589
|
if (!site.buildCommand) {
|
|
107520
107590
|
log(`Site ${site.name} is missing build command.`);
|
|
107521
107591
|
const answers = await import_inquirer3.default.prompt(questionsGetEntrypoint);
|
|
@@ -107626,7 +107696,7 @@ var pushFunction = async ({
|
|
|
107626
107696
|
);
|
|
107627
107697
|
return;
|
|
107628
107698
|
}
|
|
107629
|
-
|
|
107699
|
+
const functions = functionIds.map((id) => {
|
|
107630
107700
|
const functions2 = localConfig.getFunctions();
|
|
107631
107701
|
const func = functions2.find((f) => f.$id === id);
|
|
107632
107702
|
if (!func) {
|
|
@@ -107635,7 +107705,7 @@ var pushFunction = async ({
|
|
|
107635
107705
|
return func;
|
|
107636
107706
|
});
|
|
107637
107707
|
log("Validating functions ...");
|
|
107638
|
-
for (
|
|
107708
|
+
for (const func of functions) {
|
|
107639
107709
|
if (!func.entrypoint) {
|
|
107640
107710
|
log(`Function ${func.name} is missing an entrypoint.`);
|
|
107641
107711
|
const answers = await import_inquirer3.default.prompt(questionsGetEntrypoint);
|
|
@@ -107776,7 +107846,7 @@ var pushTable = async ({
|
|
|
107776
107846
|
});
|
|
107777
107847
|
}
|
|
107778
107848
|
}
|
|
107779
|
-
} catch (
|
|
107849
|
+
} catch (_e) {
|
|
107780
107850
|
}
|
|
107781
107851
|
}
|
|
107782
107852
|
if (tablesToDelete.length > 0) {
|
|
@@ -107923,7 +107993,7 @@ var pushCollection = async () => {
|
|
|
107923
107993
|
}
|
|
107924
107994
|
};
|
|
107925
107995
|
var pushBucket = async () => {
|
|
107926
|
-
|
|
107996
|
+
const bucketIds = [];
|
|
107927
107997
|
const configBuckets = localConfig.getBuckets();
|
|
107928
107998
|
if (cliConfig.all) {
|
|
107929
107999
|
checkDeployConditions(localConfig);
|
|
@@ -107942,7 +108012,7 @@ var pushBucket = async () => {
|
|
|
107942
108012
|
);
|
|
107943
108013
|
return;
|
|
107944
108014
|
}
|
|
107945
|
-
|
|
108015
|
+
const buckets = [];
|
|
107946
108016
|
for (const bucketId of bucketIds) {
|
|
107947
108017
|
const idBuckets = configBuckets.filter((b) => b.$id === bucketId);
|
|
107948
108018
|
buckets.push(...idBuckets);
|
|
@@ -107973,7 +108043,7 @@ var pushBucket = async () => {
|
|
|
107973
108043
|
}
|
|
107974
108044
|
};
|
|
107975
108045
|
var pushTeam = async () => {
|
|
107976
|
-
|
|
108046
|
+
const teamIds = [];
|
|
107977
108047
|
const configTeams = localConfig.getTeams();
|
|
107978
108048
|
if (cliConfig.all) {
|
|
107979
108049
|
checkDeployConditions(localConfig);
|
|
@@ -107992,7 +108062,7 @@ var pushTeam = async () => {
|
|
|
107992
108062
|
);
|
|
107993
108063
|
return;
|
|
107994
108064
|
}
|
|
107995
|
-
|
|
108065
|
+
const teams = [];
|
|
107996
108066
|
for (const teamId of teamIds) {
|
|
107997
108067
|
const idTeams = configTeams.filter((t) => t.$id === teamId);
|
|
107998
108068
|
teams.push(...idTeams);
|
|
@@ -108023,7 +108093,7 @@ var pushTeam = async () => {
|
|
|
108023
108093
|
}
|
|
108024
108094
|
};
|
|
108025
108095
|
var pushMessagingTopic = async () => {
|
|
108026
|
-
|
|
108096
|
+
const topicsIds = [];
|
|
108027
108097
|
const configTopics = localConfig.getMessagingTopics();
|
|
108028
108098
|
if (cliConfig.all) {
|
|
108029
108099
|
checkDeployConditions(localConfig);
|
|
@@ -108042,7 +108112,7 @@ var pushMessagingTopic = async () => {
|
|
|
108042
108112
|
);
|
|
108043
108113
|
return;
|
|
108044
108114
|
}
|
|
108045
|
-
|
|
108115
|
+
const topics = [];
|
|
108046
108116
|
for (const topicId of topicsIds) {
|
|
108047
108117
|
const idTopic = configTopics.filter((b) => b.$id === topicId);
|
|
108048
108118
|
topics.push(...idTopic);
|
|
@@ -108626,7 +108696,7 @@ var pullResources = async ({
|
|
|
108626
108696
|
delete actions.collections;
|
|
108627
108697
|
}
|
|
108628
108698
|
if (cliConfig.all) {
|
|
108629
|
-
for (
|
|
108699
|
+
for (const action of Object.values(actions)) {
|
|
108630
108700
|
cliConfig.all = true;
|
|
108631
108701
|
await action({ returnOnZero: true });
|
|
108632
108702
|
}
|
|
@@ -108844,7 +108914,6 @@ pull.command("team").alias("teams").description("Pull your Appwrite teams").acti
|
|
|
108844
108914
|
pull.command("topic").alias("topics").description("Pull your Appwrite messaging topics").action(actionRunner(pullMessagingTopic));
|
|
108845
108915
|
|
|
108846
108916
|
// lib/commands/schema.ts
|
|
108847
|
-
var import_json_bigint3 = __toESM(require_json_bigint(), 1);
|
|
108848
108917
|
import * as fs7 from "fs";
|
|
108849
108918
|
import * as path6 from "path";
|
|
108850
108919
|
|
|
@@ -109145,7 +109214,7 @@ var BaseDatabasesGenerator = class {
|
|
|
109145
109214
|
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";
|
|
109146
109215
|
|
|
109147
109216
|
// lib/commands/generators/typescript/templates/databases.ts.hbs
|
|
109148
|
-
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';
|
|
109217
|
+
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';
|
|
109149
109218
|
|
|
109150
109219
|
// lib/commands/generators/typescript/templates/index.ts.hbs
|
|
109151
109220
|
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';
|
|
@@ -109312,7 +109381,7 @@ ${dbReturnTypes}
|
|
|
109312
109381
|
|
|
109313
109382
|
export type DatabaseHandle<D extends DatabaseId> = {
|
|
109314
109383
|
use: <T extends keyof DatabaseTableMap[D] & string>(tableId: T) => DatabaseTableMap[D][T];
|
|
109315
|
-
${supportsServerSide ? ` create: (tableId: string, name: string, options?: { permissions?: ${PERMISSION_CALLBACK_INLINE}; rowSecurity?: boolean; enabled?: boolean; columns?:
|
|
109384
|
+
${supportsServerSide ? ` create: (tableId: string, name: string, options?: { permissions?: ${PERMISSION_CALLBACK_INLINE}; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; indexes?: object[] }) => Promise<Models.Table>;
|
|
109316
109385
|
update: <T extends keyof DatabaseTableMap[D] & string>(tableId: T, options?: { name?: string; permissions?: ${PERMISSION_CALLBACK_INLINE}; rowSecurity?: boolean; enabled?: boolean }) => Promise<Models.Table>;
|
|
109317
109386
|
delete: <T extends keyof DatabaseTableMap[D] & string>(tableId: T) => Promise<void>;` : ""}
|
|
109318
109387
|
};
|
|
@@ -109379,26 +109448,26 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
|
|
|
109379
109448
|
generateBulkMethods(supportsBulk) {
|
|
109380
109449
|
if (!supportsBulk) return "";
|
|
109381
109450
|
return `
|
|
109382
|
-
createMany: (rows:
|
|
109451
|
+
createMany: (rows: object[], options?: { transactionId?: string }) =>
|
|
109383
109452
|
tablesDB.createRows({
|
|
109384
109453
|
databaseId,
|
|
109385
109454
|
tableId,
|
|
109386
109455
|
rows,
|
|
109387
109456
|
transactionId: options?.transactionId,
|
|
109388
109457
|
}),
|
|
109389
|
-
updateMany: (data:
|
|
109458
|
+
updateMany: (data: object, options?: { queries?: (q: QueryBuilder<T>) => string[]; transactionId?: string }) =>
|
|
109390
109459
|
tablesDB.updateRows({
|
|
109391
109460
|
databaseId,
|
|
109392
109461
|
tableId,
|
|
109393
109462
|
data,
|
|
109394
|
-
queries: options?.queries?.(createQueryBuilder()),
|
|
109463
|
+
queries: options?.queries?.(createQueryBuilder<T>()),
|
|
109395
109464
|
transactionId: options?.transactionId,
|
|
109396
109465
|
}),
|
|
109397
|
-
deleteMany: (options?: { queries?: (q:
|
|
109466
|
+
deleteMany: (options?: { queries?: (q: QueryBuilder<T>) => string[]; transactionId?: string }) =>
|
|
109398
109467
|
tablesDB.deleteRows({
|
|
109399
109468
|
databaseId,
|
|
109400
109469
|
tableId,
|
|
109401
|
-
queries: options?.queries?.(createQueryBuilder()),
|
|
109470
|
+
queries: options?.queries?.(createQueryBuilder<T>()),
|
|
109402
109471
|
transactionId: options?.transactionId,
|
|
109403
109472
|
}),`;
|
|
109404
109473
|
}
|
|
@@ -109412,9 +109481,9 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
|
|
|
109412
109481
|
return `
|
|
109413
109482
|
// Remove bulk methods for tables with relationships
|
|
109414
109483
|
if (!hasBulkMethods(databaseId, tableId)) {
|
|
109415
|
-
delete (api as
|
|
109416
|
-
delete (api as
|
|
109417
|
-
delete (api as
|
|
109484
|
+
delete (api as Record<string, unknown>).createMany;
|
|
109485
|
+
delete (api as Record<string, unknown>).updateMany;
|
|
109486
|
+
delete (api as Record<string, unknown>).deleteMany;
|
|
109418
109487
|
}`;
|
|
109419
109488
|
}
|
|
109420
109489
|
generateDatabasesFile(config2, importExt) {
|
|
@@ -109486,7 +109555,6 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
|
|
|
109486
109555
|
};
|
|
109487
109556
|
|
|
109488
109557
|
// lib/commands/schema.ts
|
|
109489
|
-
var JSONBig2 = (0, import_json_bigint3.default)({ useNativeBigInt: true });
|
|
109490
109558
|
var Schema = class {
|
|
109491
109559
|
pullCommand;
|
|
109492
109560
|
pushCommand;
|
|
@@ -109559,7 +109627,7 @@ var Schema = class {
|
|
|
109559
109627
|
* @returns The configuration object.
|
|
109560
109628
|
*/
|
|
109561
109629
|
read(path7) {
|
|
109562
|
-
return
|
|
109630
|
+
return JSONBig.parse(fs7.readFileSync(path7, "utf8"));
|
|
109563
109631
|
}
|
|
109564
109632
|
/**
|
|
109565
109633
|
* Writes the configuration object to a file.
|
|
@@ -109570,7 +109638,7 @@ var Schema = class {
|
|
|
109570
109638
|
*/
|
|
109571
109639
|
write(config2, filePath) {
|
|
109572
109640
|
const resolvedPath = path6.resolve(filePath);
|
|
109573
|
-
const content =
|
|
109641
|
+
const content = JSONBig.stringify(config2, null, 4);
|
|
109574
109642
|
fs7.writeFileSync(resolvedPath, content);
|
|
109575
109643
|
}
|
|
109576
109644
|
};
|
|
@@ -109597,6 +109665,9 @@ export {
|
|
|
109597
109665
|
};
|
|
109598
109666
|
/*! Bundled license information:
|
|
109599
109667
|
|
|
109668
|
+
safe-buffer/index.js:
|
|
109669
|
+
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
109670
|
+
|
|
109600
109671
|
undici/lib/fetch/body.js:
|
|
109601
109672
|
(*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> *)
|
|
109602
109673
|
|