appwrite-cli 13.6.0 → 14.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +66 -0
- package/CHANGELOG.md +14 -0
- package/README.md +2 -2
- package/cli.ts +3 -3
- package/dist/bundle-win-arm64.mjs +608 -310
- package/dist/cli.cjs +608 -310
- package/dist/index.cjs +354 -183
- package/dist/index.js +354 -183
- 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 +2 -0
- package/dist/lib/commands/generate.d.ts.map +1 -1
- package/dist/lib/commands/generators/base.d.ts +25 -2
- package/dist/lib/commands/generators/base.d.ts.map +1 -1
- package/dist/lib/commands/generators/index.d.ts +1 -1
- package/dist/lib/commands/generators/index.d.ts.map +1 -1
- package/dist/lib/commands/generators/typescript/databases.d.ts +2 -2
- package/dist/lib/commands/generators/typescript/databases.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/docs/examples/projects/update-status.md +5 -0
- package/docs/examples/sites/create-deployment.md +1 -2
- 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 +23 -8
- package/lib/commands/generators/base.ts +33 -2
- package/lib/commands/generators/index.ts +1 -0
- package/lib/commands/generators/typescript/databases.ts +31 -21
- 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/services/account.ts +1 -1
- package/lib/commands/services/databases.ts +20 -19
- package/lib/commands/services/health.ts +13 -0
- package/lib/commands/services/messaging.ts +1 -1
- package/lib/commands/services/projects.ts +25 -0
- package/lib/commands/services/sites.ts +8 -3
- package/lib/commands/services/tables-db.ts +3 -2
- package/lib/commands/services/teams.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 +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 +8 -2
- package/scoop/appwrite.config.json +3 -3
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) {
|
|
@@ -19586,9 +19586,9 @@ var require_stream_duplex = __commonJS({
|
|
|
19586
19586
|
}
|
|
19587
19587
|
});
|
|
19588
19588
|
|
|
19589
|
-
// node_modules/
|
|
19589
|
+
// node_modules/safe-buffer/index.js
|
|
19590
19590
|
var require_safe_buffer = __commonJS({
|
|
19591
|
-
"node_modules/
|
|
19591
|
+
"node_modules/safe-buffer/index.js"(exports, module) {
|
|
19592
19592
|
var buffer = __require("buffer");
|
|
19593
19593
|
var Buffer2 = buffer.Buffer;
|
|
19594
19594
|
function copyProps(src, dst) {
|
|
@@ -69357,7 +69357,7 @@ var id_default = ID;
|
|
|
69357
69357
|
// lib/constants.ts
|
|
69358
69358
|
var SDK_TITLE = "Appwrite";
|
|
69359
69359
|
var SDK_TITLE_LOWER = "appwrite";
|
|
69360
|
-
var SDK_VERSION = "
|
|
69360
|
+
var SDK_VERSION = "14.0.0";
|
|
69361
69361
|
var SDK_LOGO = "\n _ _ _ ___ __ _____\n /_\\ _ __ _ ____ ___ __(_) |_ ___ / __\\ / / \\_ \\\n //_\\\\| '_ \\| '_ \\ \\ /\\ / / '__| | __/ _ \\ / / / / / /\\/\n / _ \\ |_) | |_) \\ V V /| | | | || __/ / /___/ /___/\\/ /_\n \\_/ \\_/ .__/| .__/ \\_/\\_/ |_| |_|\\__\\___| \\____/\\____/\\____/\n |_| |_|\n\n";
|
|
69362
69362
|
var EXECUTABLE_NAME = "appwrite";
|
|
69363
69363
|
var NPM_PACKAGE_NAME = "appwrite-cli";
|
|
@@ -83265,7 +83265,7 @@ var int64Schema = external_exports.preprocess(
|
|
|
83265
83265
|
const valueOfResult = val.valueOf();
|
|
83266
83266
|
const bigIntVal = BigInt(valueOfResult);
|
|
83267
83267
|
return bigIntVal;
|
|
83268
|
-
} catch (
|
|
83268
|
+
} catch (_e) {
|
|
83269
83269
|
return void 0;
|
|
83270
83270
|
}
|
|
83271
83271
|
}
|
|
@@ -83275,7 +83275,7 @@ var int64Schema = external_exports.preprocess(
|
|
|
83275
83275
|
if (typeof val === "string") {
|
|
83276
83276
|
try {
|
|
83277
83277
|
return BigInt(val);
|
|
83278
|
-
} catch (
|
|
83278
|
+
} catch (_e) {
|
|
83279
83279
|
return void 0;
|
|
83280
83280
|
}
|
|
83281
83281
|
}
|
|
@@ -83589,7 +83589,7 @@ var createSettingsObject = (project) => {
|
|
|
83589
83589
|
};
|
|
83590
83590
|
};
|
|
83591
83591
|
var checkDeployConditions = (localConfig2) => {
|
|
83592
|
-
if (
|
|
83592
|
+
if (localConfig2.keys().length === 0) {
|
|
83593
83593
|
throw new Error(
|
|
83594
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."
|
|
83595
83595
|
);
|
|
@@ -83737,7 +83737,7 @@ var Config = class {
|
|
|
83737
83737
|
try {
|
|
83738
83738
|
const file2 = fs.readFileSync(this.path).toString();
|
|
83739
83739
|
this.data = JSONBig.parse(file2);
|
|
83740
|
-
} catch (
|
|
83740
|
+
} catch (_e) {
|
|
83741
83741
|
this.data = {};
|
|
83742
83742
|
}
|
|
83743
83743
|
}
|
|
@@ -84648,7 +84648,7 @@ var Spinner = class _Spinner {
|
|
|
84648
84648
|
static stop() {
|
|
84649
84649
|
_Spinner.updatesBar.stop();
|
|
84650
84650
|
}
|
|
84651
|
-
static formatter(
|
|
84651
|
+
static formatter(_options, _params, payload) {
|
|
84652
84652
|
const status = payload.status.padEnd(12);
|
|
84653
84653
|
const middle = `${payload.resource} (${payload.id})`.padEnd(40);
|
|
84654
84654
|
let prefix = import_chalk.default.cyan(payload.prefix ?? "\u29D7");
|
|
@@ -84719,19 +84719,22 @@ async function paginate(action, args = {}, limit = 100, wrapper = "", queries =
|
|
|
84719
84719
|
]
|
|
84720
84720
|
});
|
|
84721
84721
|
if (wrapper === "") {
|
|
84722
|
-
|
|
84722
|
+
const listResponse = response;
|
|
84723
|
+
if (listResponse.length === 0) {
|
|
84723
84724
|
break;
|
|
84724
84725
|
}
|
|
84725
|
-
results = results.concat(
|
|
84726
|
+
results = results.concat(listResponse);
|
|
84726
84727
|
} else {
|
|
84727
|
-
|
|
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) {
|
|
84728
84736
|
break;
|
|
84729
84737
|
}
|
|
84730
|
-
results = results.concat(response[wrapper]);
|
|
84731
|
-
}
|
|
84732
|
-
total = response.total;
|
|
84733
|
-
if (results.length >= total) {
|
|
84734
|
-
break;
|
|
84735
84738
|
}
|
|
84736
84739
|
pageNumber++;
|
|
84737
84740
|
}
|
|
@@ -84935,7 +84938,7 @@ var Client = class _Client {
|
|
|
84935
84938
|
"x-sdk-name": "Console",
|
|
84936
84939
|
"x-sdk-platform": "console",
|
|
84937
84940
|
"x-sdk-language": "web",
|
|
84938
|
-
"x-sdk-version": "
|
|
84941
|
+
"x-sdk-version": "4.0.0",
|
|
84939
84942
|
"X-Appwrite-Response-Format": "1.8.0"
|
|
84940
84943
|
};
|
|
84941
84944
|
this.realtime = {
|
|
@@ -87673,6 +87676,47 @@ var Databases = class {
|
|
|
87673
87676
|
};
|
|
87674
87677
|
return this.client.call("post", uri, apiHeaders, payload);
|
|
87675
87678
|
}
|
|
87679
|
+
updateRelationshipAttribute(paramsOrFirst, ...rest) {
|
|
87680
|
+
let params;
|
|
87681
|
+
if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
|
|
87682
|
+
params = paramsOrFirst || {};
|
|
87683
|
+
} else {
|
|
87684
|
+
params = {
|
|
87685
|
+
databaseId: paramsOrFirst,
|
|
87686
|
+
collectionId: rest[0],
|
|
87687
|
+
key: rest[1],
|
|
87688
|
+
onDelete: rest[2],
|
|
87689
|
+
newKey: rest[3]
|
|
87690
|
+
};
|
|
87691
|
+
}
|
|
87692
|
+
const databaseId = params.databaseId;
|
|
87693
|
+
const collectionId = params.collectionId;
|
|
87694
|
+
const key = params.key;
|
|
87695
|
+
const onDelete = params.onDelete;
|
|
87696
|
+
const newKey = params.newKey;
|
|
87697
|
+
if (typeof databaseId === "undefined") {
|
|
87698
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
87699
|
+
}
|
|
87700
|
+
if (typeof collectionId === "undefined") {
|
|
87701
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
87702
|
+
}
|
|
87703
|
+
if (typeof key === "undefined") {
|
|
87704
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
87705
|
+
}
|
|
87706
|
+
const apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{key}", key);
|
|
87707
|
+
const payload = {};
|
|
87708
|
+
if (typeof onDelete !== "undefined") {
|
|
87709
|
+
payload["onDelete"] = onDelete;
|
|
87710
|
+
}
|
|
87711
|
+
if (typeof newKey !== "undefined") {
|
|
87712
|
+
payload["newKey"] = newKey;
|
|
87713
|
+
}
|
|
87714
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
87715
|
+
const apiHeaders = {
|
|
87716
|
+
"content-type": "application/json"
|
|
87717
|
+
};
|
|
87718
|
+
return this.client.call("patch", uri, apiHeaders, payload);
|
|
87719
|
+
}
|
|
87676
87720
|
createStringAttribute(paramsOrFirst, ...rest) {
|
|
87677
87721
|
let params;
|
|
87678
87722
|
if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
|
|
@@ -88190,47 +88234,6 @@ var Databases = class {
|
|
|
88190
88234
|
};
|
|
88191
88235
|
return this.client.call("delete", uri, apiHeaders, payload);
|
|
88192
88236
|
}
|
|
88193
|
-
updateRelationshipAttribute(paramsOrFirst, ...rest) {
|
|
88194
|
-
let params;
|
|
88195
|
-
if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
|
|
88196
|
-
params = paramsOrFirst || {};
|
|
88197
|
-
} else {
|
|
88198
|
-
params = {
|
|
88199
|
-
databaseId: paramsOrFirst,
|
|
88200
|
-
collectionId: rest[0],
|
|
88201
|
-
key: rest[1],
|
|
88202
|
-
onDelete: rest[2],
|
|
88203
|
-
newKey: rest[3]
|
|
88204
|
-
};
|
|
88205
|
-
}
|
|
88206
|
-
const databaseId = params.databaseId;
|
|
88207
|
-
const collectionId = params.collectionId;
|
|
88208
|
-
const key = params.key;
|
|
88209
|
-
const onDelete = params.onDelete;
|
|
88210
|
-
const newKey = params.newKey;
|
|
88211
|
-
if (typeof databaseId === "undefined") {
|
|
88212
|
-
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
88213
|
-
}
|
|
88214
|
-
if (typeof collectionId === "undefined") {
|
|
88215
|
-
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
88216
|
-
}
|
|
88217
|
-
if (typeof key === "undefined") {
|
|
88218
|
-
throw new AppwriteException('Missing required parameter: "key"');
|
|
88219
|
-
}
|
|
88220
|
-
const apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{key}", key);
|
|
88221
|
-
const payload = {};
|
|
88222
|
-
if (typeof onDelete !== "undefined") {
|
|
88223
|
-
payload["onDelete"] = onDelete;
|
|
88224
|
-
}
|
|
88225
|
-
if (typeof newKey !== "undefined") {
|
|
88226
|
-
payload["newKey"] = newKey;
|
|
88227
|
-
}
|
|
88228
|
-
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
88229
|
-
const apiHeaders = {
|
|
88230
|
-
"content-type": "application/json"
|
|
88231
|
-
};
|
|
88232
|
-
return this.client.call("patch", uri, apiHeaders, payload);
|
|
88233
|
-
}
|
|
88234
88237
|
listDocuments(paramsOrFirst, ...rest) {
|
|
88235
88238
|
let params;
|
|
88236
88239
|
if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
|
|
@@ -88241,7 +88244,8 @@ var Databases = class {
|
|
|
88241
88244
|
collectionId: rest[0],
|
|
88242
88245
|
queries: rest[1],
|
|
88243
88246
|
transactionId: rest[2],
|
|
88244
|
-
total: rest[3]
|
|
88247
|
+
total: rest[3],
|
|
88248
|
+
ttl: rest[4]
|
|
88245
88249
|
};
|
|
88246
88250
|
}
|
|
88247
88251
|
const databaseId = params.databaseId;
|
|
@@ -88249,6 +88253,7 @@ var Databases = class {
|
|
|
88249
88253
|
const queries = params.queries;
|
|
88250
88254
|
const transactionId = params.transactionId;
|
|
88251
88255
|
const total = params.total;
|
|
88256
|
+
const ttl = params.ttl;
|
|
88252
88257
|
if (typeof databaseId === "undefined") {
|
|
88253
88258
|
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
88254
88259
|
}
|
|
@@ -88266,6 +88271,9 @@ var Databases = class {
|
|
|
88266
88271
|
if (typeof total !== "undefined") {
|
|
88267
88272
|
payload["total"] = total;
|
|
88268
88273
|
}
|
|
88274
|
+
if (typeof ttl !== "undefined") {
|
|
88275
|
+
payload["ttl"] = ttl;
|
|
88276
|
+
}
|
|
88269
88277
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
88270
88278
|
const apiHeaders = {};
|
|
88271
88279
|
return this.client.call("get", uri, apiHeaders, payload);
|
|
@@ -94831,6 +94839,27 @@ var Projects = class {
|
|
|
94831
94839
|
};
|
|
94832
94840
|
return this.client.call("patch", uri, apiHeaders, payload);
|
|
94833
94841
|
}
|
|
94842
|
+
updateConsoleAccess(paramsOrFirst) {
|
|
94843
|
+
let params;
|
|
94844
|
+
if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
|
|
94845
|
+
params = paramsOrFirst || {};
|
|
94846
|
+
} else {
|
|
94847
|
+
params = {
|
|
94848
|
+
projectId: paramsOrFirst
|
|
94849
|
+
};
|
|
94850
|
+
}
|
|
94851
|
+
const projectId = params.projectId;
|
|
94852
|
+
if (typeof projectId === "undefined") {
|
|
94853
|
+
throw new AppwriteException('Missing required parameter: "projectId"');
|
|
94854
|
+
}
|
|
94855
|
+
const apiPath = "/projects/{projectId}/console-access".replace("{projectId}", projectId);
|
|
94856
|
+
const payload = {};
|
|
94857
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
94858
|
+
const apiHeaders = {
|
|
94859
|
+
"content-type": "application/json"
|
|
94860
|
+
};
|
|
94861
|
+
return this.client.call("patch", uri, apiHeaders, payload);
|
|
94862
|
+
}
|
|
94834
94863
|
listDevKeys(paramsOrFirst, ...rest) {
|
|
94835
94864
|
let params;
|
|
94836
94865
|
if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
|
|
@@ -95907,6 +95936,35 @@ var Projects = class {
|
|
|
95907
95936
|
};
|
|
95908
95937
|
return this.client.call("post", uri, apiHeaders, payload);
|
|
95909
95938
|
}
|
|
95939
|
+
updateStatus(paramsOrFirst, ...rest) {
|
|
95940
|
+
let params;
|
|
95941
|
+
if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
|
|
95942
|
+
params = paramsOrFirst || {};
|
|
95943
|
+
} else {
|
|
95944
|
+
params = {
|
|
95945
|
+
projectId: paramsOrFirst,
|
|
95946
|
+
status: rest[0]
|
|
95947
|
+
};
|
|
95948
|
+
}
|
|
95949
|
+
const projectId = params.projectId;
|
|
95950
|
+
const status = params.status;
|
|
95951
|
+
if (typeof projectId === "undefined") {
|
|
95952
|
+
throw new AppwriteException('Missing required parameter: "projectId"');
|
|
95953
|
+
}
|
|
95954
|
+
if (typeof status === "undefined") {
|
|
95955
|
+
throw new AppwriteException('Missing required parameter: "status"');
|
|
95956
|
+
}
|
|
95957
|
+
const apiPath = "/projects/{projectId}/status".replace("{projectId}", projectId);
|
|
95958
|
+
const payload = {};
|
|
95959
|
+
if (typeof status !== "undefined") {
|
|
95960
|
+
payload["status"] = status;
|
|
95961
|
+
}
|
|
95962
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
95963
|
+
const apiHeaders = {
|
|
95964
|
+
"content-type": "application/json"
|
|
95965
|
+
};
|
|
95966
|
+
return this.client.call("patch", uri, apiHeaders, payload);
|
|
95967
|
+
}
|
|
95910
95968
|
updateTeam(paramsOrFirst, ...rest) {
|
|
95911
95969
|
let params;
|
|
95912
95970
|
if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
|
|
@@ -97221,28 +97279,25 @@ var Sites = class {
|
|
|
97221
97279
|
params = {
|
|
97222
97280
|
siteId: paramsOrFirst,
|
|
97223
97281
|
code: rest[0],
|
|
97224
|
-
|
|
97225
|
-
|
|
97226
|
-
|
|
97227
|
-
|
|
97282
|
+
installCommand: rest[1],
|
|
97283
|
+
buildCommand: rest[2],
|
|
97284
|
+
outputDirectory: rest[3],
|
|
97285
|
+
activate: rest[4]
|
|
97228
97286
|
};
|
|
97229
97287
|
onProgress = rest[5];
|
|
97230
97288
|
}
|
|
97231
97289
|
const siteId = params.siteId;
|
|
97232
97290
|
const code = params.code;
|
|
97233
|
-
const activate = params.activate;
|
|
97234
97291
|
const installCommand = params.installCommand;
|
|
97235
97292
|
const buildCommand = params.buildCommand;
|
|
97236
97293
|
const outputDirectory = params.outputDirectory;
|
|
97294
|
+
const activate = params.activate;
|
|
97237
97295
|
if (typeof siteId === "undefined") {
|
|
97238
97296
|
throw new AppwriteException('Missing required parameter: "siteId"');
|
|
97239
97297
|
}
|
|
97240
97298
|
if (typeof code === "undefined") {
|
|
97241
97299
|
throw new AppwriteException('Missing required parameter: "code"');
|
|
97242
97300
|
}
|
|
97243
|
-
if (typeof activate === "undefined") {
|
|
97244
|
-
throw new AppwriteException('Missing required parameter: "activate"');
|
|
97245
|
-
}
|
|
97246
97301
|
const apiPath = "/sites/{siteId}/deployments".replace("{siteId}", siteId);
|
|
97247
97302
|
const payload = {};
|
|
97248
97303
|
if (typeof installCommand !== "undefined") {
|
|
@@ -100980,7 +101035,8 @@ var TablesDB = class {
|
|
|
100980
101035
|
tableId: rest[0],
|
|
100981
101036
|
queries: rest[1],
|
|
100982
101037
|
transactionId: rest[2],
|
|
100983
|
-
total: rest[3]
|
|
101038
|
+
total: rest[3],
|
|
101039
|
+
ttl: rest[4]
|
|
100984
101040
|
};
|
|
100985
101041
|
}
|
|
100986
101042
|
const databaseId = params.databaseId;
|
|
@@ -100988,6 +101044,7 @@ var TablesDB = class {
|
|
|
100988
101044
|
const queries = params.queries;
|
|
100989
101045
|
const transactionId = params.transactionId;
|
|
100990
101046
|
const total = params.total;
|
|
101047
|
+
const ttl = params.ttl;
|
|
100991
101048
|
if (typeof databaseId === "undefined") {
|
|
100992
101049
|
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
100993
101050
|
}
|
|
@@ -101005,6 +101062,9 @@ var TablesDB = class {
|
|
|
101005
101062
|
if (typeof total !== "undefined") {
|
|
101006
101063
|
payload["total"] = total;
|
|
101007
101064
|
}
|
|
101065
|
+
if (typeof ttl !== "undefined") {
|
|
101066
|
+
payload["ttl"] = ttl;
|
|
101067
|
+
}
|
|
101008
101068
|
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
101009
101069
|
const apiHeaders = {};
|
|
101010
101070
|
return this.client.call("get", uri, apiHeaders, payload);
|
|
@@ -103316,20 +103376,69 @@ var SmtpEncryption;
|
|
|
103316
103376
|
SmtpEncryption2["Ssl"] = "ssl";
|
|
103317
103377
|
SmtpEncryption2["Tls"] = "tls";
|
|
103318
103378
|
})(SmtpEncryption || (SmtpEncryption = {}));
|
|
103319
|
-
var
|
|
103320
|
-
(function(
|
|
103321
|
-
|
|
103322
|
-
|
|
103323
|
-
|
|
103324
|
-
|
|
103325
|
-
|
|
103326
|
-
|
|
103327
|
-
|
|
103328
|
-
|
|
103329
|
-
|
|
103330
|
-
|
|
103331
|
-
|
|
103332
|
-
|
|
103379
|
+
var AppwriteMigrationResource;
|
|
103380
|
+
(function(AppwriteMigrationResource2) {
|
|
103381
|
+
AppwriteMigrationResource2["User"] = "user";
|
|
103382
|
+
AppwriteMigrationResource2["Team"] = "team";
|
|
103383
|
+
AppwriteMigrationResource2["Membership"] = "membership";
|
|
103384
|
+
AppwriteMigrationResource2["Database"] = "database";
|
|
103385
|
+
AppwriteMigrationResource2["Table"] = "table";
|
|
103386
|
+
AppwriteMigrationResource2["Column"] = "column";
|
|
103387
|
+
AppwriteMigrationResource2["Index"] = "index";
|
|
103388
|
+
AppwriteMigrationResource2["Row"] = "row";
|
|
103389
|
+
AppwriteMigrationResource2["Document"] = "document";
|
|
103390
|
+
AppwriteMigrationResource2["Attribute"] = "attribute";
|
|
103391
|
+
AppwriteMigrationResource2["Collection"] = "collection";
|
|
103392
|
+
AppwriteMigrationResource2["Bucket"] = "bucket";
|
|
103393
|
+
AppwriteMigrationResource2["File"] = "file";
|
|
103394
|
+
AppwriteMigrationResource2["Function"] = "function";
|
|
103395
|
+
AppwriteMigrationResource2["Deployment"] = "deployment";
|
|
103396
|
+
AppwriteMigrationResource2["Environmentvariable"] = "environment-variable";
|
|
103397
|
+
AppwriteMigrationResource2["Site"] = "site";
|
|
103398
|
+
AppwriteMigrationResource2["Sitedeployment"] = "site-deployment";
|
|
103399
|
+
AppwriteMigrationResource2["Sitevariable"] = "site-variable";
|
|
103400
|
+
})(AppwriteMigrationResource || (AppwriteMigrationResource = {}));
|
|
103401
|
+
var FirebaseMigrationResource;
|
|
103402
|
+
(function(FirebaseMigrationResource2) {
|
|
103403
|
+
FirebaseMigrationResource2["User"] = "user";
|
|
103404
|
+
FirebaseMigrationResource2["Database"] = "database";
|
|
103405
|
+
FirebaseMigrationResource2["Table"] = "table";
|
|
103406
|
+
FirebaseMigrationResource2["Column"] = "column";
|
|
103407
|
+
FirebaseMigrationResource2["Row"] = "row";
|
|
103408
|
+
FirebaseMigrationResource2["Document"] = "document";
|
|
103409
|
+
FirebaseMigrationResource2["Attribute"] = "attribute";
|
|
103410
|
+
FirebaseMigrationResource2["Collection"] = "collection";
|
|
103411
|
+
FirebaseMigrationResource2["Bucket"] = "bucket";
|
|
103412
|
+
FirebaseMigrationResource2["File"] = "file";
|
|
103413
|
+
})(FirebaseMigrationResource || (FirebaseMigrationResource = {}));
|
|
103414
|
+
var NHostMigrationResource;
|
|
103415
|
+
(function(NHostMigrationResource2) {
|
|
103416
|
+
NHostMigrationResource2["User"] = "user";
|
|
103417
|
+
NHostMigrationResource2["Database"] = "database";
|
|
103418
|
+
NHostMigrationResource2["Table"] = "table";
|
|
103419
|
+
NHostMigrationResource2["Column"] = "column";
|
|
103420
|
+
NHostMigrationResource2["Index"] = "index";
|
|
103421
|
+
NHostMigrationResource2["Row"] = "row";
|
|
103422
|
+
NHostMigrationResource2["Document"] = "document";
|
|
103423
|
+
NHostMigrationResource2["Attribute"] = "attribute";
|
|
103424
|
+
NHostMigrationResource2["Collection"] = "collection";
|
|
103425
|
+
NHostMigrationResource2["Bucket"] = "bucket";
|
|
103426
|
+
NHostMigrationResource2["File"] = "file";
|
|
103427
|
+
})(NHostMigrationResource || (NHostMigrationResource = {}));
|
|
103428
|
+
var SupabaseMigrationResource;
|
|
103429
|
+
(function(SupabaseMigrationResource2) {
|
|
103430
|
+
SupabaseMigrationResource2["User"] = "user";
|
|
103431
|
+
SupabaseMigrationResource2["Database"] = "database";
|
|
103432
|
+
SupabaseMigrationResource2["Table"] = "table";
|
|
103433
|
+
SupabaseMigrationResource2["Column"] = "column";
|
|
103434
|
+
SupabaseMigrationResource2["Index"] = "index";
|
|
103435
|
+
SupabaseMigrationResource2["Row"] = "row";
|
|
103436
|
+
SupabaseMigrationResource2["Document"] = "document";
|
|
103437
|
+
SupabaseMigrationResource2["Attribute"] = "attribute";
|
|
103438
|
+
SupabaseMigrationResource2["Collection"] = "collection";
|
|
103439
|
+
SupabaseMigrationResource2["Bucket"] = "bucket";
|
|
103440
|
+
SupabaseMigrationResource2["File"] = "file";
|
|
103441
|
+
})(SupabaseMigrationResource || (SupabaseMigrationResource = {}));
|
|
103333
103442
|
var ProjectUsageRange;
|
|
103334
103443
|
(function(ProjectUsageRange2) {
|
|
103335
103444
|
ProjectUsageRange2["OneHour"] = "1h";
|
|
@@ -103406,6 +103515,10 @@ var SMTPSecure;
|
|
|
103406
103515
|
SMTPSecure2["Tls"] = "tls";
|
|
103407
103516
|
SMTPSecure2["Ssl"] = "ssl";
|
|
103408
103517
|
})(SMTPSecure || (SMTPSecure = {}));
|
|
103518
|
+
var Status;
|
|
103519
|
+
(function(Status2) {
|
|
103520
|
+
Status2["Active"] = "active";
|
|
103521
|
+
})(Status || (Status = {}));
|
|
103409
103522
|
var EmailTemplateType;
|
|
103410
103523
|
(function(EmailTemplateType2) {
|
|
103411
103524
|
EmailTemplateType2["Verification"] = "verification";
|
|
@@ -103965,6 +104078,17 @@ var BillingPlanGroup;
|
|
|
103965
104078
|
BillingPlanGroup2["Pro"] = "pro";
|
|
103966
104079
|
BillingPlanGroup2["Scale"] = "scale";
|
|
103967
104080
|
})(BillingPlanGroup || (BillingPlanGroup = {}));
|
|
104081
|
+
var DomainTransferStatusStatus;
|
|
104082
|
+
(function(DomainTransferStatusStatus2) {
|
|
104083
|
+
DomainTransferStatusStatus2["Transferrable"] = "transferrable";
|
|
104084
|
+
DomainTransferStatusStatus2["NotTransferrable"] = "not_transferrable";
|
|
104085
|
+
DomainTransferStatusStatus2["PendingOwner"] = "pending_owner";
|
|
104086
|
+
DomainTransferStatusStatus2["PendingAdmin"] = "pending_admin";
|
|
104087
|
+
DomainTransferStatusStatus2["PendingRegistry"] = "pending_registry";
|
|
104088
|
+
DomainTransferStatusStatus2["Completed"] = "completed";
|
|
104089
|
+
DomainTransferStatusStatus2["Cancelled"] = "cancelled";
|
|
104090
|
+
DomainTransferStatusStatus2["ServiceUnavailable"] = "service_unavailable";
|
|
104091
|
+
})(DomainTransferStatusStatus || (DomainTransferStatusStatus = {}));
|
|
103968
104092
|
|
|
103969
104093
|
// lib/parser.ts
|
|
103970
104094
|
var import_chalk2 = __toESM(require_source(), 1);
|
|
@@ -103976,7 +104100,7 @@ var package_default = {
|
|
|
103976
104100
|
type: "module",
|
|
103977
104101
|
homepage: "https://appwrite.io/support",
|
|
103978
104102
|
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",
|
|
103979
|
-
version: "
|
|
104103
|
+
version: "14.0.0",
|
|
103980
104104
|
license: "BSD-3-Clause",
|
|
103981
104105
|
main: "dist/index.cjs",
|
|
103982
104106
|
module: "dist/index.js",
|
|
@@ -104007,6 +104131,7 @@ var package_default = {
|
|
|
104007
104131
|
"build:lib:esm": "esbuild index.ts --bundle --platform=node --target=node18 --format=esm --loader:.hbs=text --outfile=dist/index.js",
|
|
104008
104132
|
"build:lib:cjs": "esbuild index.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --outfile=dist/index.cjs",
|
|
104009
104133
|
"build:cli": "esbuild cli.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:fsevents --outfile=dist/cli.cjs",
|
|
104134
|
+
lint: "eslint .",
|
|
104010
104135
|
format: 'prettier --write "**/*.{js,ts,json,md}"',
|
|
104011
104136
|
generate: "tsx scripts/generate-commands.ts",
|
|
104012
104137
|
prepublishOnly: "npm run build",
|
|
@@ -104019,7 +104144,7 @@ var package_default = {
|
|
|
104019
104144
|
"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"
|
|
104020
104145
|
},
|
|
104021
104146
|
dependencies: {
|
|
104022
|
-
"@appwrite.io/console": "^
|
|
104147
|
+
"@appwrite.io/console": "^4.0.0",
|
|
104023
104148
|
chalk: "4.1.2",
|
|
104024
104149
|
chokidar: "^3.6.0",
|
|
104025
104150
|
"cli-progress": "^3.12.0",
|
|
@@ -104038,7 +104163,12 @@ var package_default = {
|
|
|
104038
104163
|
zod: "^4.3.5"
|
|
104039
104164
|
},
|
|
104040
104165
|
devDependencies: {
|
|
104166
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
104167
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
104041
104168
|
"@types/bun": "^1.3.5",
|
|
104169
|
+
eslint: "^9.0.0",
|
|
104170
|
+
"eslint-plugin-unused-imports": "^4.0.0",
|
|
104171
|
+
"typescript-eslint": "^8.0.0",
|
|
104042
104172
|
"@types/cli-progress": "^3.11.5",
|
|
104043
104173
|
"@types/inquirer": "^8.2.10",
|
|
104044
104174
|
"@types/json-bigint": "^1.0.4",
|
|
@@ -104070,14 +104200,28 @@ var cliConfig = {
|
|
|
104070
104200
|
report: false,
|
|
104071
104201
|
reportData: {}
|
|
104072
104202
|
};
|
|
104203
|
+
var toJsonObject = (value) => {
|
|
104204
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
104205
|
+
return value;
|
|
104206
|
+
}
|
|
104207
|
+
return null;
|
|
104208
|
+
};
|
|
104209
|
+
var extractReportCommandArgs = (value) => {
|
|
104210
|
+
if (!value || typeof value !== "object") {
|
|
104211
|
+
return [];
|
|
104212
|
+
}
|
|
104213
|
+
const reportData = value;
|
|
104214
|
+
if (!Array.isArray(reportData.data?.args)) {
|
|
104215
|
+
return [];
|
|
104216
|
+
}
|
|
104217
|
+
return reportData.data.args;
|
|
104218
|
+
};
|
|
104073
104219
|
var drawTable = (data) => {
|
|
104074
104220
|
if (data.length == 0) {
|
|
104075
104221
|
console.log("[]");
|
|
104076
104222
|
return;
|
|
104077
104223
|
}
|
|
104078
|
-
const rows = data.map(
|
|
104079
|
-
(item) => item && typeof item === "object" && !Array.isArray(item) ? item : {}
|
|
104080
|
-
);
|
|
104224
|
+
const rows = data.map((item) => toJsonObject(item) ?? {});
|
|
104081
104225
|
const obj = rows.reduce((res, item) => ({ ...res, ...item }), {});
|
|
104082
104226
|
const keys = Object.keys(obj);
|
|
104083
104227
|
if (keys.length === 0) {
|
|
@@ -104120,7 +104264,7 @@ var drawTable = (data) => {
|
|
|
104120
104264
|
} else if (typeof row[key] === "object") {
|
|
104121
104265
|
rowValues.push(JSON.stringify(row[key]));
|
|
104122
104266
|
} else {
|
|
104123
|
-
rowValues.push(row[key]);
|
|
104267
|
+
rowValues.push(String(row[key]));
|
|
104124
104268
|
}
|
|
104125
104269
|
}
|
|
104126
104270
|
table.push(rowValues);
|
|
@@ -104132,7 +104276,7 @@ var drawJSON = (data) => {
|
|
|
104132
104276
|
};
|
|
104133
104277
|
var parseError = (err) => {
|
|
104134
104278
|
if (cliConfig.report) {
|
|
104135
|
-
(async () => {
|
|
104279
|
+
void (async () => {
|
|
104136
104280
|
let appwriteVersion = "unknown";
|
|
104137
104281
|
const endpoint = globalConfig2.getEndpoint();
|
|
104138
104282
|
try {
|
|
@@ -104145,7 +104289,8 @@ var parseError = (err) => {
|
|
|
104145
104289
|
} catch {
|
|
104146
104290
|
}
|
|
104147
104291
|
const version2 = SDK_VERSION;
|
|
104148
|
-
const
|
|
104292
|
+
const commandArgs = extractReportCommandArgs(cliConfig.reportData);
|
|
104293
|
+
const stepsToReproduce = `Running \`${EXECUTABLE_NAME} ${commandArgs.join(" ")}\``;
|
|
104149
104294
|
const yourEnvironment = `CLI version: ${version2}
|
|
104150
104295
|
Operation System: ${os2.type()}
|
|
104151
104296
|
Appwrite version: ${appwriteVersion}
|
|
@@ -104197,7 +104342,7 @@ var actionRunner = (fn) => {
|
|
|
104197
104342
|
error48(`The '--all' and '--id' flags cannot be used together.`);
|
|
104198
104343
|
process.exit(1);
|
|
104199
104344
|
}
|
|
104200
|
-
return fn(...args).catch(parseError);
|
|
104345
|
+
return fn(...args).then(() => void 0).catch(parseError);
|
|
104201
104346
|
};
|
|
104202
104347
|
};
|
|
104203
104348
|
var log = (message) => {
|
|
@@ -104310,6 +104455,9 @@ async function downloadDeploymentCode(params) {
|
|
|
104310
104455
|
{},
|
|
104311
104456
|
"arrayBuffer"
|
|
104312
104457
|
);
|
|
104458
|
+
if (!(downloadBuffer instanceof ArrayBuffer)) {
|
|
104459
|
+
throw new Error("Failed to download deployment archive as ArrayBuffer.");
|
|
104460
|
+
}
|
|
104313
104461
|
try {
|
|
104314
104462
|
fs2.writeFileSync(compressedFileName, Buffer.from(downloadBuffer));
|
|
104315
104463
|
} catch (err) {
|
|
@@ -104521,7 +104669,7 @@ var questionsInitProject = [
|
|
|
104521
104669
|
name: "organization",
|
|
104522
104670
|
message: "Choose your organization",
|
|
104523
104671
|
choices: async () => {
|
|
104524
|
-
|
|
104672
|
+
const client = await sdkForConsole(true);
|
|
104525
104673
|
const { teams } = isCloud() ? await paginate(
|
|
104526
104674
|
async (opts = {}) => (await getOrganizationsService(opts.sdk)).list(),
|
|
104527
104675
|
{ sdk: client },
|
|
@@ -104533,7 +104681,7 @@ var questionsInitProject = [
|
|
|
104533
104681
|
100,
|
|
104534
104682
|
"teams"
|
|
104535
104683
|
);
|
|
104536
|
-
|
|
104684
|
+
const choices = teams.map((team, _idx) => {
|
|
104537
104685
|
return {
|
|
104538
104686
|
name: `${team.name} (${team["$id"]})`,
|
|
104539
104687
|
value: team["$id"]
|
|
@@ -104582,7 +104730,7 @@ var questionsInitProject = [
|
|
|
104582
104730
|
"projects",
|
|
104583
104731
|
queries
|
|
104584
104732
|
);
|
|
104585
|
-
|
|
104733
|
+
const choices = projects.map((project) => {
|
|
104586
104734
|
return {
|
|
104587
104735
|
name: `${project.name} (${project["$id"]})`,
|
|
104588
104736
|
value: {
|
|
@@ -104603,13 +104751,13 @@ var questionsInitProject = [
|
|
|
104603
104751
|
name: "region",
|
|
104604
104752
|
message: `Select your ${SDK_TITLE} Cloud region`,
|
|
104605
104753
|
choices: async () => {
|
|
104606
|
-
|
|
104754
|
+
const client = await sdkForConsole(true);
|
|
104607
104755
|
const endpoint = globalConfig2.getEndpoint() || DEFAULT_ENDPOINT;
|
|
104608
|
-
|
|
104756
|
+
const response = await client.call(
|
|
104609
104757
|
"GET",
|
|
104610
104758
|
new URL(endpoint + "/console/regions")
|
|
104611
104759
|
);
|
|
104612
|
-
|
|
104760
|
+
const regions = response.regions || [];
|
|
104613
104761
|
if (!regions.length) {
|
|
104614
104762
|
throw new Error(
|
|
104615
104763
|
"No regions found. Please check your network or Appwrite Cloud availability."
|
|
@@ -104736,9 +104884,9 @@ var questionGetEndpoint = [
|
|
|
104736
104884
|
if (!value) {
|
|
104737
104885
|
return "Please enter a valid endpoint.";
|
|
104738
104886
|
}
|
|
104739
|
-
|
|
104887
|
+
const client = new Client().setEndpoint(value);
|
|
104740
104888
|
try {
|
|
104741
|
-
|
|
104889
|
+
const response = await client.call(
|
|
104742
104890
|
"get",
|
|
104743
104891
|
new URL(value + "/health/version")
|
|
104744
104892
|
);
|
|
@@ -104747,7 +104895,7 @@ var questionGetEndpoint = [
|
|
|
104747
104895
|
} else {
|
|
104748
104896
|
throw new Error();
|
|
104749
104897
|
}
|
|
104750
|
-
} catch (
|
|
104898
|
+
} catch (_error) {
|
|
104751
104899
|
return "Invalid endpoint or your Appwrite server is not running as expected.";
|
|
104752
104900
|
}
|
|
104753
104901
|
}
|
|
@@ -104783,9 +104931,9 @@ var questionsPushSites = [
|
|
|
104783
104931
|
validate: (value) => validateRequired("site", value),
|
|
104784
104932
|
when: () => localConfig.getSites().length > 0,
|
|
104785
104933
|
choices: () => {
|
|
104786
|
-
|
|
104934
|
+
const sites = localConfig.getSites();
|
|
104787
104935
|
checkDeployConditions(localConfig);
|
|
104788
|
-
|
|
104936
|
+
const choices = sites.map((site, _idx) => {
|
|
104789
104937
|
return {
|
|
104790
104938
|
name: `${site.name} (${site.$id})`,
|
|
104791
104939
|
value: site.$id
|
|
@@ -104803,9 +104951,9 @@ var questionsPushFunctions = [
|
|
|
104803
104951
|
validate: (value) => validateRequired("function", value),
|
|
104804
104952
|
when: () => localConfig.getFunctions().length > 0,
|
|
104805
104953
|
choices: () => {
|
|
104806
|
-
|
|
104954
|
+
const functions = localConfig.getFunctions();
|
|
104807
104955
|
checkDeployConditions(localConfig);
|
|
104808
|
-
|
|
104956
|
+
const choices = functions.map((func, _idx) => {
|
|
104809
104957
|
return {
|
|
104810
104958
|
name: `${func.name} (${func.$id})`,
|
|
104811
104959
|
value: func.$id
|
|
@@ -104823,7 +104971,7 @@ var questionsPushCollections = [
|
|
|
104823
104971
|
validate: (value) => validateRequired("collection", value),
|
|
104824
104972
|
when: () => localConfig.getCollections().length > 0,
|
|
104825
104973
|
choices: () => {
|
|
104826
|
-
|
|
104974
|
+
const collections = localConfig.getCollections();
|
|
104827
104975
|
checkDeployConditions(localConfig);
|
|
104828
104976
|
return collections.map((collection) => {
|
|
104829
104977
|
return {
|
|
@@ -104842,7 +104990,7 @@ var questionsPushTables = [
|
|
|
104842
104990
|
validate: (value) => validateRequired("table", value),
|
|
104843
104991
|
when: () => localConfig.getTables().length > 0,
|
|
104844
104992
|
choices: () => {
|
|
104845
|
-
|
|
104993
|
+
const tables = localConfig.getTables();
|
|
104846
104994
|
checkDeployConditions(localConfig);
|
|
104847
104995
|
return tables.map((table) => {
|
|
104848
104996
|
return {
|
|
@@ -104875,7 +105023,7 @@ var questionsPushBuckets = [
|
|
|
104875
105023
|
validate: (value) => validateRequired("bucket", value),
|
|
104876
105024
|
when: () => localConfig.getBuckets().length > 0,
|
|
104877
105025
|
choices: () => {
|
|
104878
|
-
|
|
105026
|
+
const buckets = localConfig.getBuckets();
|
|
104879
105027
|
checkDeployConditions(localConfig);
|
|
104880
105028
|
return buckets.map((bucket) => {
|
|
104881
105029
|
return {
|
|
@@ -104894,7 +105042,7 @@ var questionsPushMessagingTopics = [
|
|
|
104894
105042
|
validate: (value) => validateRequired("topics", value),
|
|
104895
105043
|
when: () => localConfig.getMessagingTopics().length > 0,
|
|
104896
105044
|
choices: () => {
|
|
104897
|
-
|
|
105045
|
+
const topics = localConfig.getMessagingTopics();
|
|
104898
105046
|
return topics.map((topic) => {
|
|
104899
105047
|
return {
|
|
104900
105048
|
name: `${topic.name} (${topic["$id"]})`,
|
|
@@ -104925,7 +105073,7 @@ var questionsPushTeams = [
|
|
|
104925
105073
|
validate: (value) => validateRequired("team", value),
|
|
104926
105074
|
when: () => localConfig.getTeams().length > 0,
|
|
104927
105075
|
choices: () => {
|
|
104928
|
-
|
|
105076
|
+
const teams = localConfig.getTeams();
|
|
104929
105077
|
checkDeployConditions(localConfig);
|
|
104930
105078
|
return teams.map((team) => {
|
|
104931
105079
|
return {
|
|
@@ -104967,7 +105115,7 @@ var Pools = class {
|
|
|
104967
105115
|
return true;
|
|
104968
105116
|
}
|
|
104969
105117
|
if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
|
|
104970
|
-
|
|
105118
|
+
const steps = Math.max(1, Math.ceil(Number(total) / this.STEP_SIZE));
|
|
104971
105119
|
if (steps > 1 && iteration === 1) {
|
|
104972
105120
|
this.pollMaxDebounces *= steps;
|
|
104973
105121
|
log(
|
|
@@ -104993,7 +105141,7 @@ var Pools = class {
|
|
|
104993
105141
|
return true;
|
|
104994
105142
|
}
|
|
104995
105143
|
if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
|
|
104996
|
-
|
|
105144
|
+
const steps = Math.max(1, Math.ceil(Number(total) / this.STEP_SIZE));
|
|
104997
105145
|
if (steps > 1 && iteration === 1) {
|
|
104998
105146
|
this.pollMaxDebounces *= steps;
|
|
104999
105147
|
log(
|
|
@@ -105009,7 +105157,10 @@ var Pools = class {
|
|
|
105009
105157
|
return false;
|
|
105010
105158
|
}
|
|
105011
105159
|
if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
|
|
105012
|
-
|
|
105160
|
+
const steps = Math.max(
|
|
105161
|
+
1,
|
|
105162
|
+
Math.ceil(attributeKeys.length / this.STEP_SIZE)
|
|
105163
|
+
);
|
|
105013
105164
|
if (steps > 1 && iteration === 1) {
|
|
105014
105165
|
this.pollMaxDebounces *= steps;
|
|
105015
105166
|
log(
|
|
@@ -105052,7 +105203,10 @@ var Pools = class {
|
|
|
105052
105203
|
return false;
|
|
105053
105204
|
}
|
|
105054
105205
|
if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
|
|
105055
|
-
|
|
105206
|
+
const steps = Math.max(
|
|
105207
|
+
1,
|
|
105208
|
+
Math.ceil(attributeKeys.length / this.STEP_SIZE)
|
|
105209
|
+
);
|
|
105056
105210
|
if (steps > 1 && iteration === 1) {
|
|
105057
105211
|
this.pollMaxDebounces *= steps;
|
|
105058
105212
|
log(
|
|
@@ -105101,7 +105255,7 @@ var Pools = class {
|
|
|
105101
105255
|
return false;
|
|
105102
105256
|
}
|
|
105103
105257
|
if (this.pollMaxDebounces === this.POLL_DEFAULT_VALUE) {
|
|
105104
|
-
|
|
105258
|
+
const steps = Math.max(1, Math.ceil(indexKeys.length / this.STEP_SIZE));
|
|
105105
105259
|
if (steps > 1 && iteration === 1) {
|
|
105106
105260
|
this.pollMaxDebounces *= steps;
|
|
105107
105261
|
log(
|
|
@@ -105194,7 +105348,7 @@ var Attributes = class {
|
|
|
105194
105348
|
}
|
|
105195
105349
|
return answers2.changes;
|
|
105196
105350
|
}
|
|
105197
|
-
|
|
105351
|
+
const answers = await import_inquirer.default.prompt(questionPushChanges2);
|
|
105198
105352
|
if (answers.changes !== "YES" && answers.changes !== "NO") {
|
|
105199
105353
|
answers.changes = await fixConfirmation();
|
|
105200
105354
|
}
|
|
@@ -105237,8 +105391,8 @@ var Attributes = class {
|
|
|
105237
105391
|
const keyName = `${import_chalk4.default.yellow(local.key)} in ${collection.name} (${collection["$id"]})`;
|
|
105238
105392
|
const action = import_chalk4.default.cyan(recreating ? "recreating" : "changing");
|
|
105239
105393
|
let reason = "";
|
|
105240
|
-
|
|
105241
|
-
for (
|
|
105394
|
+
const attribute = recreating ? remote : local;
|
|
105395
|
+
for (const key of Object.keys(remote)) {
|
|
105242
105396
|
if (!KeysAttributes.has(key)) {
|
|
105243
105397
|
continue;
|
|
105244
105398
|
}
|
|
@@ -105748,7 +105902,7 @@ var Attributes = class {
|
|
|
105748
105902
|
createIndexes = async (indexes, collection) => {
|
|
105749
105903
|
log(`Creating indexes ...`);
|
|
105750
105904
|
const databasesService = await getDatabasesService(this.client);
|
|
105751
|
-
for (
|
|
105905
|
+
for (const index of indexes) {
|
|
105752
105906
|
await databasesService.createIndex({
|
|
105753
105907
|
databaseId: collection["databaseId"],
|
|
105754
105908
|
collectionId: collection["$id"],
|
|
@@ -105772,7 +105926,7 @@ var Attributes = class {
|
|
|
105772
105926
|
};
|
|
105773
105927
|
createAttributes = async (attributes, collection) => {
|
|
105774
105928
|
log(`Creating attributes ...`);
|
|
105775
|
-
for (
|
|
105929
|
+
for (const attribute of attributes) {
|
|
105776
105930
|
if (attribute.side !== "child") {
|
|
105777
105931
|
await this.createAttribute(
|
|
105778
105932
|
collection["databaseId"],
|
|
@@ -105796,7 +105950,7 @@ var Attributes = class {
|
|
|
105796
105950
|
};
|
|
105797
105951
|
createColumns = async (columns, table) => {
|
|
105798
105952
|
log(`Creating columns ...`);
|
|
105799
|
-
for (
|
|
105953
|
+
for (const column of columns) {
|
|
105800
105954
|
if (column.side !== "child") {
|
|
105801
105955
|
await this.createAttribute(table["databaseId"], table["$id"], column);
|
|
105802
105956
|
}
|
|
@@ -105831,7 +105985,7 @@ var getConfirmation = async () => {
|
|
|
105831
105985
|
}
|
|
105832
105986
|
return answers2.changes;
|
|
105833
105987
|
}
|
|
105834
|
-
|
|
105988
|
+
const answers = await import_inquirer2.default.prompt(questionPushChanges);
|
|
105835
105989
|
if (answers.changes !== "YES" && answers.changes !== "NO") {
|
|
105836
105990
|
answers.changes = await fixConfirmation();
|
|
105837
105991
|
}
|
|
@@ -105881,7 +106035,7 @@ var approveChanges = async (resource, resourceGetFunction, keys, resourceName, r
|
|
|
105881
106035
|
options[secondResourceName] = localResource[secondId];
|
|
105882
106036
|
}
|
|
105883
106037
|
const remoteResource = await resourceGetFunction(options);
|
|
105884
|
-
for (
|
|
106038
|
+
for (const [key, value] of Object.entries(
|
|
105885
106039
|
whitelistKeys(remoteResource, keys)
|
|
105886
106040
|
)) {
|
|
105887
106041
|
if (skipKeys.includes(key)) {
|
|
@@ -105890,28 +106044,30 @@ var approveChanges = async (resource, resourceGetFunction, keys, resourceName, r
|
|
|
105890
106044
|
if (isEmpty(value) && isEmpty(localResource[key])) {
|
|
105891
106045
|
continue;
|
|
105892
106046
|
}
|
|
105893
|
-
|
|
105894
|
-
|
|
106047
|
+
const localValue = localResource[key];
|
|
106048
|
+
if (Array.isArray(value) && Array.isArray(localValue)) {
|
|
106049
|
+
if (JSON.stringify(value) !== JSON.stringify(localValue)) {
|
|
105895
106050
|
changes.push({
|
|
105896
106051
|
id: localResource["$id"],
|
|
105897
106052
|
key,
|
|
105898
106053
|
remote: import_chalk5.default.red(value.join("\n")),
|
|
105899
|
-
local: import_chalk5.default.green(
|
|
106054
|
+
local: import_chalk5.default.green(
|
|
106055
|
+
localValue.map((entry) => String(entry)).join("\n")
|
|
106056
|
+
)
|
|
105900
106057
|
});
|
|
105901
106058
|
}
|
|
105902
|
-
} else if (value !==
|
|
106059
|
+
} else if (value !== localValue) {
|
|
105903
106060
|
changes.push({
|
|
105904
106061
|
id: localResource["$id"],
|
|
105905
106062
|
key,
|
|
105906
|
-
remote: import_chalk5.default.red(value),
|
|
105907
|
-
local: import_chalk5.default.green(
|
|
106063
|
+
remote: import_chalk5.default.red(String(value ?? "")),
|
|
106064
|
+
local: import_chalk5.default.green(String(localValue ?? ""))
|
|
105908
106065
|
});
|
|
105909
106066
|
}
|
|
105910
106067
|
}
|
|
105911
106068
|
} catch (e) {
|
|
105912
|
-
|
|
105913
|
-
|
|
105914
|
-
}
|
|
106069
|
+
const isNotFound = e instanceof AppwriteException && Number(e.code) === 404;
|
|
106070
|
+
if (!isNotFound) throw e;
|
|
105915
106071
|
}
|
|
105916
106072
|
})
|
|
105917
106073
|
);
|
|
@@ -105928,18 +106084,37 @@ var approveChanges = async (resource, resourceGetFunction, keys, resourceName, r
|
|
|
105928
106084
|
|
|
105929
106085
|
// lib/commands/utils/database-sync.ts
|
|
105930
106086
|
var import_chalk6 = __toESM(require_source(), 1);
|
|
106087
|
+
var isTablesDBResource = (value) => {
|
|
106088
|
+
if (!value || typeof value !== "object") {
|
|
106089
|
+
return false;
|
|
106090
|
+
}
|
|
106091
|
+
return "$id" in value && typeof value.$id === "string" && "name" in value && typeof value.name === "string" && "enabled" in value && typeof value.enabled === "boolean";
|
|
106092
|
+
};
|
|
106093
|
+
var getSyncErrorMessage = (err) => {
|
|
106094
|
+
if (err instanceof AppwriteException) {
|
|
106095
|
+
return err.message;
|
|
106096
|
+
}
|
|
106097
|
+
if (err instanceof Error) {
|
|
106098
|
+
return err.message;
|
|
106099
|
+
}
|
|
106100
|
+
return String(err);
|
|
106101
|
+
};
|
|
105931
106102
|
var checkAndApplyTablesDBChanges = async () => {
|
|
105932
106103
|
log("Checking for tablesDB changes ...");
|
|
105933
106104
|
const localTablesDBs = localConfig.getTablesDBs();
|
|
105934
|
-
const
|
|
106105
|
+
const paginatedResult = await paginate(
|
|
105935
106106
|
async (args) => {
|
|
105936
106107
|
const tablesDBService = await getTablesDBService();
|
|
105937
|
-
|
|
106108
|
+
const queries = Array.isArray(args.queries) ? args.queries.filter(
|
|
106109
|
+
(query) => typeof query === "string"
|
|
106110
|
+
) : [];
|
|
106111
|
+
return await tablesDBService.list(queries);
|
|
105938
106112
|
},
|
|
105939
106113
|
{},
|
|
105940
106114
|
100,
|
|
105941
106115
|
"databases"
|
|
105942
106116
|
);
|
|
106117
|
+
const remoteTablesDBs = Array.isArray(paginatedResult.databases) ? paginatedResult.databases.filter(isTablesDBResource) : [];
|
|
105943
106118
|
if (localTablesDBs.length === 0 && remoteTablesDBs.length === 0) {
|
|
105944
106119
|
return { applied: false, resyncNeeded: false };
|
|
105945
106120
|
}
|
|
@@ -105961,9 +106136,7 @@ var checkAndApplyTablesDBChanges = async () => {
|
|
|
105961
106136
|
}
|
|
105962
106137
|
}
|
|
105963
106138
|
for (const localDB of localTablesDBs) {
|
|
105964
|
-
const remoteDB = remoteTablesDBs.find(
|
|
105965
|
-
(db) => db.$id === localDB.$id
|
|
105966
|
-
);
|
|
106139
|
+
const remoteDB = remoteTablesDBs.find((db) => db.$id === localDB.$id);
|
|
105967
106140
|
if (!remoteDB) {
|
|
105968
106141
|
toCreate.push(localDB);
|
|
105969
106142
|
changes.push({
|
|
@@ -106030,7 +106203,7 @@ var checkAndApplyTablesDBChanges = async () => {
|
|
|
106030
106203
|
needsResync = true;
|
|
106031
106204
|
} catch (e) {
|
|
106032
106205
|
error48(
|
|
106033
|
-
`Failed to delete database ${db.name} ( ${db.$id} ): ${e
|
|
106206
|
+
`Failed to delete database ${db.name} ( ${db.$id} ): ${getSyncErrorMessage(e)}`
|
|
106034
106207
|
);
|
|
106035
106208
|
throw new Error(
|
|
106036
106209
|
`Database sync failed during deletion of ${db.$id}. Some changes may have been applied.`
|
|
@@ -106045,7 +106218,7 @@ var checkAndApplyTablesDBChanges = async () => {
|
|
|
106045
106218
|
success2(`Created ${db.name} ( ${db.$id} )`);
|
|
106046
106219
|
} catch (e) {
|
|
106047
106220
|
error48(
|
|
106048
|
-
`Failed to create database ${db.name} ( ${db.$id} ): ${e
|
|
106221
|
+
`Failed to create database ${db.name} ( ${db.$id} ): ${getSyncErrorMessage(e)}`
|
|
106049
106222
|
);
|
|
106050
106223
|
throw new Error(
|
|
106051
106224
|
`Database sync failed during creation of ${db.$id}. Some changes may have been applied.`
|
|
@@ -106060,7 +106233,7 @@ var checkAndApplyTablesDBChanges = async () => {
|
|
|
106060
106233
|
success2(`Updated ${db.name} ( ${db.$id} )`);
|
|
106061
106234
|
} catch (e) {
|
|
106062
106235
|
error48(
|
|
106063
|
-
`Failed to update database ${db.name} ( ${db.$id} ): ${e
|
|
106236
|
+
`Failed to update database ${db.name} ( ${db.$id} ): ${getSyncErrorMessage(e)}`
|
|
106064
106237
|
);
|
|
106065
106238
|
throw new Error(
|
|
106066
106239
|
`Database sync failed during update of ${db.$id}. Some changes may have been applied.`
|
|
@@ -106294,7 +106467,7 @@ var Push = class {
|
|
|
106294
106467
|
}
|
|
106295
106468
|
if (settings.services) {
|
|
106296
106469
|
this.log("Applying service statuses ...");
|
|
106297
|
-
for (
|
|
106470
|
+
for (const [service, status] of Object.entries(settings.services)) {
|
|
106298
106471
|
await projectsService.updateServiceStatus({
|
|
106299
106472
|
projectId,
|
|
106300
106473
|
service,
|
|
@@ -106340,7 +106513,7 @@ var Push = class {
|
|
|
106340
106513
|
}
|
|
106341
106514
|
if (settings.auth.methods) {
|
|
106342
106515
|
this.log("Applying auth methods statuses ...");
|
|
106343
|
-
for (
|
|
106516
|
+
for (const [method, status] of Object.entries(settings.auth.methods)) {
|
|
106344
106517
|
await projectsService.updateAuthStatus({
|
|
106345
106518
|
projectId,
|
|
106346
106519
|
method,
|
|
@@ -106644,7 +106817,7 @@ var Push = class {
|
|
|
106644
106817
|
([key, value]) => ({ key, value })
|
|
106645
106818
|
);
|
|
106646
106819
|
}
|
|
106647
|
-
} catch (
|
|
106820
|
+
} catch (_error) {
|
|
106648
106821
|
envVariables = [];
|
|
106649
106822
|
}
|
|
106650
106823
|
await Promise.all(
|
|
@@ -106941,7 +107114,7 @@ var Push = class {
|
|
|
106941
107114
|
([key, value]) => ({ key, value })
|
|
106942
107115
|
);
|
|
106943
107116
|
}
|
|
106944
|
-
} catch (
|
|
107117
|
+
} catch (_error) {
|
|
106945
107118
|
envVariables = [];
|
|
106946
107119
|
}
|
|
106947
107120
|
await Promise.all(
|
|
@@ -107108,7 +107281,7 @@ var Push = class {
|
|
|
107108
107281
|
skipConfirmation,
|
|
107109
107282
|
this.projectClient
|
|
107110
107283
|
);
|
|
107111
|
-
|
|
107284
|
+
const tablesChanged = /* @__PURE__ */ new Set();
|
|
107112
107285
|
const errors = [];
|
|
107113
107286
|
await Promise.all(
|
|
107114
107287
|
tables.map(async (table) => {
|
|
@@ -107162,7 +107335,7 @@ var Push = class {
|
|
|
107162
107335
|
}
|
|
107163
107336
|
})
|
|
107164
107337
|
);
|
|
107165
|
-
for (
|
|
107338
|
+
for (const table of tables) {
|
|
107166
107339
|
let columns = table.columns;
|
|
107167
107340
|
let indexes = table.indexes;
|
|
107168
107341
|
let hadChanges = false;
|
|
@@ -107441,7 +107614,7 @@ var pushSettings = async () => {
|
|
|
107441
107614
|
checkDeployConditions(localConfig);
|
|
107442
107615
|
try {
|
|
107443
107616
|
const projectsService = await getProjectsService();
|
|
107444
|
-
|
|
107617
|
+
const response = await projectsService.get(
|
|
107445
107618
|
localConfig.getProject().projectId
|
|
107446
107619
|
);
|
|
107447
107620
|
const remoteSettings = createSettingsObject(response);
|
|
@@ -107474,7 +107647,7 @@ var pushSettings = async () => {
|
|
|
107474
107647
|
return;
|
|
107475
107648
|
}
|
|
107476
107649
|
}
|
|
107477
|
-
} catch (
|
|
107650
|
+
} catch (_e) {
|
|
107478
107651
|
}
|
|
107479
107652
|
try {
|
|
107480
107653
|
log("Pushing project settings ...");
|
|
@@ -107524,7 +107697,7 @@ var pushSite = async ({
|
|
|
107524
107697
|
);
|
|
107525
107698
|
return;
|
|
107526
107699
|
}
|
|
107527
|
-
|
|
107700
|
+
const sites = siteIds.map((id) => {
|
|
107528
107701
|
const sites2 = localConfig.getSites();
|
|
107529
107702
|
const site = sites2.find((s) => s.$id === id);
|
|
107530
107703
|
if (!site) {
|
|
@@ -107533,7 +107706,7 @@ var pushSite = async ({
|
|
|
107533
107706
|
return site;
|
|
107534
107707
|
});
|
|
107535
107708
|
log("Validating sites ...");
|
|
107536
|
-
for (
|
|
107709
|
+
for (const site of sites) {
|
|
107537
107710
|
if (!site.buildCommand) {
|
|
107538
107711
|
log(`Site ${site.name} is missing build command.`);
|
|
107539
107712
|
const answers = await import_inquirer3.default.prompt(questionsGetEntrypoint);
|
|
@@ -107644,7 +107817,7 @@ var pushFunction = async ({
|
|
|
107644
107817
|
);
|
|
107645
107818
|
return;
|
|
107646
107819
|
}
|
|
107647
|
-
|
|
107820
|
+
const functions = functionIds.map((id) => {
|
|
107648
107821
|
const functions2 = localConfig.getFunctions();
|
|
107649
107822
|
const func = functions2.find((f) => f.$id === id);
|
|
107650
107823
|
if (!func) {
|
|
@@ -107653,7 +107826,7 @@ var pushFunction = async ({
|
|
|
107653
107826
|
return func;
|
|
107654
107827
|
});
|
|
107655
107828
|
log("Validating functions ...");
|
|
107656
|
-
for (
|
|
107829
|
+
for (const func of functions) {
|
|
107657
107830
|
if (!func.entrypoint) {
|
|
107658
107831
|
log(`Function ${func.name} is missing an entrypoint.`);
|
|
107659
107832
|
const answers = await import_inquirer3.default.prompt(questionsGetEntrypoint);
|
|
@@ -107794,7 +107967,7 @@ var pushTable = async ({
|
|
|
107794
107967
|
});
|
|
107795
107968
|
}
|
|
107796
107969
|
}
|
|
107797
|
-
} catch (
|
|
107970
|
+
} catch (_e) {
|
|
107798
107971
|
}
|
|
107799
107972
|
}
|
|
107800
107973
|
if (tablesToDelete.length > 0) {
|
|
@@ -107941,7 +108114,7 @@ var pushCollection = async () => {
|
|
|
107941
108114
|
}
|
|
107942
108115
|
};
|
|
107943
108116
|
var pushBucket = async () => {
|
|
107944
|
-
|
|
108117
|
+
const bucketIds = [];
|
|
107945
108118
|
const configBuckets = localConfig.getBuckets();
|
|
107946
108119
|
if (cliConfig.all) {
|
|
107947
108120
|
checkDeployConditions(localConfig);
|
|
@@ -107960,7 +108133,7 @@ var pushBucket = async () => {
|
|
|
107960
108133
|
);
|
|
107961
108134
|
return;
|
|
107962
108135
|
}
|
|
107963
|
-
|
|
108136
|
+
const buckets = [];
|
|
107964
108137
|
for (const bucketId of bucketIds) {
|
|
107965
108138
|
const idBuckets = configBuckets.filter((b) => b.$id === bucketId);
|
|
107966
108139
|
buckets.push(...idBuckets);
|
|
@@ -107991,7 +108164,7 @@ var pushBucket = async () => {
|
|
|
107991
108164
|
}
|
|
107992
108165
|
};
|
|
107993
108166
|
var pushTeam = async () => {
|
|
107994
|
-
|
|
108167
|
+
const teamIds = [];
|
|
107995
108168
|
const configTeams = localConfig.getTeams();
|
|
107996
108169
|
if (cliConfig.all) {
|
|
107997
108170
|
checkDeployConditions(localConfig);
|
|
@@ -108010,7 +108183,7 @@ var pushTeam = async () => {
|
|
|
108010
108183
|
);
|
|
108011
108184
|
return;
|
|
108012
108185
|
}
|
|
108013
|
-
|
|
108186
|
+
const teams = [];
|
|
108014
108187
|
for (const teamId of teamIds) {
|
|
108015
108188
|
const idTeams = configTeams.filter((t) => t.$id === teamId);
|
|
108016
108189
|
teams.push(...idTeams);
|
|
@@ -108041,7 +108214,7 @@ var pushTeam = async () => {
|
|
|
108041
108214
|
}
|
|
108042
108215
|
};
|
|
108043
108216
|
var pushMessagingTopic = async () => {
|
|
108044
|
-
|
|
108217
|
+
const topicsIds = [];
|
|
108045
108218
|
const configTopics = localConfig.getMessagingTopics();
|
|
108046
108219
|
if (cliConfig.all) {
|
|
108047
108220
|
checkDeployConditions(localConfig);
|
|
@@ -108060,7 +108233,7 @@ var pushMessagingTopic = async () => {
|
|
|
108060
108233
|
);
|
|
108061
108234
|
return;
|
|
108062
108235
|
}
|
|
108063
|
-
|
|
108236
|
+
const topics = [];
|
|
108064
108237
|
for (const topicId of topicsIds) {
|
|
108065
108238
|
const idTopic = configTopics.filter((b) => b.$id === topicId);
|
|
108066
108239
|
topics.push(...idTopic);
|
|
@@ -108644,7 +108817,7 @@ var pullResources = async ({
|
|
|
108644
108817
|
delete actions.collections;
|
|
108645
108818
|
}
|
|
108646
108819
|
if (cliConfig.all) {
|
|
108647
|
-
for (
|
|
108820
|
+
for (const action of Object.values(actions)) {
|
|
108648
108821
|
cliConfig.all = true;
|
|
108649
108822
|
await action({ returnOnZero: true });
|
|
108650
108823
|
}
|
|
@@ -109162,7 +109335,7 @@ var BaseDatabasesGenerator = class {
|
|
|
109162
109335
|
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";
|
|
109163
109336
|
|
|
109164
109337
|
// lib/commands/generators/typescript/templates/databases.ts.hbs
|
|
109165
|
-
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';
|
|
109338
|
+
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';
|
|
109166
109339
|
|
|
109167
109340
|
// lib/commands/generators/typescript/templates/index.ts.hbs
|
|
109168
109341
|
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';
|
|
@@ -109329,7 +109502,7 @@ ${dbReturnTypes}
|
|
|
109329
109502
|
|
|
109330
109503
|
export type DatabaseHandle<D extends DatabaseId> = {
|
|
109331
109504
|
use: <T extends keyof DatabaseTableMap[D] & string>(tableId: T) => DatabaseTableMap[D][T];
|
|
109332
|
-
${supportsServerSide ? ` create: (tableId: string, name: string, options?: { permissions?: ${PERMISSION_CALLBACK_INLINE}; rowSecurity?: boolean; enabled?: boolean; columns?:
|
|
109505
|
+
${supportsServerSide ? ` create: (tableId: string, name: string, options?: { permissions?: ${PERMISSION_CALLBACK_INLINE}; rowSecurity?: boolean; enabled?: boolean; columns?: object[]; indexes?: object[] }) => Promise<Models.Table>;
|
|
109333
109506
|
update: <T extends keyof DatabaseTableMap[D] & string>(tableId: T, options?: { name?: string; permissions?: ${PERMISSION_CALLBACK_INLINE}; rowSecurity?: boolean; enabled?: boolean }) => Promise<Models.Table>;
|
|
109334
109507
|
delete: <T extends keyof DatabaseTableMap[D] & string>(tableId: T) => Promise<void>;` : ""}
|
|
109335
109508
|
};
|
|
@@ -109341,12 +109514,11 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
|
|
|
109341
109514
|
delete: <D extends DatabaseId>(databaseId: D) => Promise<void>;` : ""}
|
|
109342
109515
|
};`;
|
|
109343
109516
|
}
|
|
109344
|
-
generateTypesFile(config2) {
|
|
109517
|
+
generateTypesFile(config2, appwriteDep) {
|
|
109345
109518
|
const entities = config2.tables?.length ? config2.tables : config2.collections;
|
|
109346
109519
|
if (!entities || entities.length === 0) {
|
|
109347
109520
|
return "// No tables or collections found in configuration\n";
|
|
109348
109521
|
}
|
|
109349
|
-
const appwriteDep = getAppwriteDependency();
|
|
109350
109522
|
const enums = this.generateEnums(entities);
|
|
109351
109523
|
const types = entities.map((entity) => this.generateTableType(entity, entities)).join("\n\n");
|
|
109352
109524
|
const entitiesByDb = this.groupEntitiesByDb(entities);
|
|
@@ -109396,26 +109568,26 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
|
|
|
109396
109568
|
generateBulkMethods(supportsBulk) {
|
|
109397
109569
|
if (!supportsBulk) return "";
|
|
109398
109570
|
return `
|
|
109399
|
-
createMany: (rows:
|
|
109571
|
+
createMany: (rows: object[], options?: { transactionId?: string }) =>
|
|
109400
109572
|
tablesDB.createRows({
|
|
109401
109573
|
databaseId,
|
|
109402
109574
|
tableId,
|
|
109403
109575
|
rows,
|
|
109404
109576
|
transactionId: options?.transactionId,
|
|
109405
109577
|
}),
|
|
109406
|
-
updateMany: (data:
|
|
109578
|
+
updateMany: (data: object, options?: { queries?: (q: QueryBuilder<T>) => string[]; transactionId?: string }) =>
|
|
109407
109579
|
tablesDB.updateRows({
|
|
109408
109580
|
databaseId,
|
|
109409
109581
|
tableId,
|
|
109410
109582
|
data,
|
|
109411
|
-
queries: options?.queries?.(createQueryBuilder()),
|
|
109583
|
+
queries: options?.queries?.(createQueryBuilder<T>()),
|
|
109412
109584
|
transactionId: options?.transactionId,
|
|
109413
109585
|
}),
|
|
109414
|
-
deleteMany: (options?: { queries?: (q:
|
|
109586
|
+
deleteMany: (options?: { queries?: (q: QueryBuilder<T>) => string[]; transactionId?: string }) =>
|
|
109415
109587
|
tablesDB.deleteRows({
|
|
109416
109588
|
databaseId,
|
|
109417
109589
|
tableId,
|
|
109418
|
-
queries: options?.queries?.(createQueryBuilder()),
|
|
109590
|
+
queries: options?.queries?.(createQueryBuilder<T>()),
|
|
109419
109591
|
transactionId: options?.transactionId,
|
|
109420
109592
|
}),`;
|
|
109421
109593
|
}
|
|
@@ -109429,18 +109601,17 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
|
|
|
109429
109601
|
return `
|
|
109430
109602
|
// Remove bulk methods for tables with relationships
|
|
109431
109603
|
if (!hasBulkMethods(databaseId, tableId)) {
|
|
109432
|
-
delete (api as
|
|
109433
|
-
delete (api as
|
|
109434
|
-
delete (api as
|
|
109604
|
+
delete (api as Record<string, unknown>).createMany;
|
|
109605
|
+
delete (api as Record<string, unknown>).updateMany;
|
|
109606
|
+
delete (api as Record<string, unknown>).deleteMany;
|
|
109435
109607
|
}`;
|
|
109436
109608
|
}
|
|
109437
|
-
generateDatabasesFile(config2, importExt) {
|
|
109609
|
+
generateDatabasesFile(config2, importExt, appwriteDep) {
|
|
109438
109610
|
const entities = config2.tables?.length ? config2.tables : config2.collections;
|
|
109439
109611
|
if (!entities || entities.length === 0) {
|
|
109440
109612
|
return "// No tables or collections found in configuration\n";
|
|
109441
109613
|
}
|
|
109442
109614
|
const entitiesByDb = this.groupEntitiesByDb(entities);
|
|
109443
|
-
const appwriteDep = getAppwriteDependency();
|
|
109444
109615
|
const supportsServerSide = supportsServerSideMethods(
|
|
109445
109616
|
appwriteDep,
|
|
109446
109617
|
this.serverSideOverride
|
|
@@ -109463,8 +109634,7 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
|
|
|
109463
109634
|
importExt
|
|
109464
109635
|
});
|
|
109465
109636
|
}
|
|
109466
|
-
generateConstantsFile(config2) {
|
|
109467
|
-
const appwriteDep = getAppwriteDependency();
|
|
109637
|
+
generateConstantsFile(config2, appwriteDep) {
|
|
109468
109638
|
const supportsServerSide = supportsServerSideMethods(
|
|
109469
109639
|
appwriteDep,
|
|
109470
109640
|
this.serverSideOverride
|
|
@@ -109476,11 +109646,12 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
|
|
|
109476
109646
|
requiresApiKey: supportsServerSide
|
|
109477
109647
|
});
|
|
109478
109648
|
}
|
|
109479
|
-
async generate(config2) {
|
|
109649
|
+
async generate(config2, options) {
|
|
109480
109650
|
if (!config2.projectId) {
|
|
109481
109651
|
throw new Error("Project ID is required in configuration");
|
|
109482
109652
|
}
|
|
109483
|
-
const
|
|
109653
|
+
const appwriteDep = options?.appwriteImportSource ?? getAppwriteDependency();
|
|
109654
|
+
const importExt = options?.importExtension ?? detectImportExtension();
|
|
109484
109655
|
const hasEntities = config2.tables && config2.tables.length > 0 || config2.collections && config2.collections.length > 0;
|
|
109485
109656
|
if (!hasEntities) {
|
|
109486
109657
|
console.log(
|
|
@@ -109490,14 +109661,14 @@ ${supportsServerSide ? ` create: (databaseId: string, name: string, options?: {
|
|
|
109490
109661
|
dbContent: "// No tables or collections found in configuration\n",
|
|
109491
109662
|
typesContent: "// No tables or collections found in configuration\n",
|
|
109492
109663
|
indexContent: this.generateIndexFile(importExt),
|
|
109493
|
-
constantsContent: this.generateConstantsFile(config2)
|
|
109664
|
+
constantsContent: this.generateConstantsFile(config2, appwriteDep)
|
|
109494
109665
|
};
|
|
109495
109666
|
}
|
|
109496
109667
|
return {
|
|
109497
|
-
dbContent: this.generateDatabasesFile(config2, importExt),
|
|
109498
|
-
typesContent: this.generateTypesFile(config2),
|
|
109668
|
+
dbContent: this.generateDatabasesFile(config2, importExt, appwriteDep),
|
|
109669
|
+
typesContent: this.generateTypesFile(config2, appwriteDep),
|
|
109499
109670
|
indexContent: this.generateIndexFile(importExt),
|
|
109500
|
-
constantsContent: this.generateConstantsFile(config2)
|
|
109671
|
+
constantsContent: this.generateConstantsFile(config2, appwriteDep)
|
|
109501
109672
|
};
|
|
109502
109673
|
}
|
|
109503
109674
|
};
|