Skip to content

Commit 7d38dce

Browse files
authored
Merge pull request #184 from appwrite/dev
chore: regenerate
2 parents c2c9a5c + 52cd8e4 commit 7d38dce

22 files changed

+270
-124
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Change Log
22

3+
## 8.3.0
4+
5+
* **Feat:** Add support for `appwrite.config.json` file
6+
* All new projects will be initialized with this configuration file
7+
* Resolves bundler conflicts (e.g., Vite) that incorrectly interpret `.json` files as library imports
8+
* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service
9+
* Type generation fixes:
10+
* Fix relationships using the relatedCollection's id instead of name
11+
* Update auto generated comment to show relative path instead of absolute path
12+
13+
> **Note:** The existing `appwrite.json` file remains fully supported for backward compatibility
14+
315
## 8.2.2
416

517
* Fix object comparison logic when pushing settings

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using
2929

3030
```sh
3131
$ appwrite -v
32-
8.2.2
32+
8.3.0
3333
```
3434

3535
### Install using prebuilt binaries
@@ -60,7 +60,7 @@ $ scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/sc
6060
Once the installation completes, you can verify your install using
6161
```
6262
$ appwrite -v
63-
8.2.2
63+
8.3.0
6464
```
6565

6666
## Getting Started
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
appwrite databases decrementDocumentAttribute \
2+
--databaseId <DATABASE_ID> \
3+
--collectionId <COLLECTION_ID> \
4+
--documentId <DOCUMENT_ID> \
5+
--attribute '' \
6+
7+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
appwrite databases incrementDocumentAttribute \
2+
--databaseId <DATABASE_ID> \
3+
--collectionId <COLLECTION_ID> \
4+
--documentId <DOCUMENT_ID> \
5+
--attribute '' \
6+
7+

install.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# You can use "View source" of this page to see the full script.
1414

1515
# REPO
16-
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/8.2.2/appwrite-cli-win-x64.exe"
17-
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/8.2.2/appwrite-cli-win-arm64.exe"
16+
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/8.3.0/appwrite-cli-win-x64.exe"
17+
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/8.3.0/appwrite-cli-win-arm64.exe"
1818

1919
$APPWRITE_BINARY_NAME = "appwrite.exe"
2020

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ printSuccess() {
9797
downloadBinary() {
9898
echo "[2/4] Downloading executable for $OS ($ARCH) ..."
9999

100-
GITHUB_LATEST_VERSION="8.2.2"
100+
GITHUB_LATEST_VERSION="8.3.0"
101101
GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
102102
GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"
103103

lib/client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class Client {
1616
'x-sdk-name': 'Command Line',
1717
'x-sdk-platform': 'console',
1818
'x-sdk-language': 'cli',
19-
'x-sdk-version': '8.2.2',
20-
'user-agent' : `AppwriteCLI/8.2.2 (${os.type()} ${os.version()}; ${os.arch()})`,
19+
'x-sdk-version': '8.3.0',
20+
'user-agent' : `AppwriteCLI/8.3.0 (${os.type()} ${os.version()}; ${os.arch()})`,
2121
'X-Appwrite-Response-Format' : '1.7.0',
2222
};
2323
}

lib/commands/databases.js

Lines changed: 109 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1990,6 +1990,90 @@ const databasesListDocumentLogs = async ({databaseId,collectionId,documentId,que
19901990

19911991
}
19921992

1993+
/**
1994+
* @typedef {Object} DatabasesDecrementDocumentAttributeRequestParams
1995+
* @property {string} databaseId Database ID.
1996+
* @property {string} collectionId Collection ID.
1997+
* @property {string} documentId Document ID.
1998+
* @property {string} attribute Attribute key.
1999+
* @property {number} value Value to decrement the attribute by. The value must be a number.
2000+
* @property {number} min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.
2001+
* @property {boolean} overrideForCli
2002+
* @property {boolean} parseOutput
2003+
* @property {libClient | undefined} sdk
2004+
*/
2005+
2006+
/**
2007+
* @param {DatabasesDecrementDocumentAttributeRequestParams} params
2008+
*/
2009+
const databasesDecrementDocumentAttribute = async ({databaseId,collectionId,documentId,attribute,value,min,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
2010+
let client = !sdk ? await sdkForProject() :
2011+
sdk;
2012+
let apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId).replace('{attribute}', attribute);
2013+
let payload = {};
2014+
if (typeof value !== 'undefined') {
2015+
payload['value'] = value;
2016+
}
2017+
if (typeof min !== 'undefined') {
2018+
payload['min'] = min;
2019+
}
2020+
2021+
let response = undefined;
2022+
2023+
response = await client.call('patch', apiPath, {
2024+
'content-type': 'application/json',
2025+
}, payload);
2026+
2027+
if (parseOutput) {
2028+
parse(response)
2029+
}
2030+
2031+
return response;
2032+
2033+
}
2034+
2035+
/**
2036+
* @typedef {Object} DatabasesIncrementDocumentAttributeRequestParams
2037+
* @property {string} databaseId Database ID.
2038+
* @property {string} collectionId Collection ID.
2039+
* @property {string} documentId Document ID.
2040+
* @property {string} attribute Attribute key.
2041+
* @property {number} value Value to increment the attribute by. The value must be a number.
2042+
* @property {number} max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.
2043+
* @property {boolean} overrideForCli
2044+
* @property {boolean} parseOutput
2045+
* @property {libClient | undefined} sdk
2046+
*/
2047+
2048+
/**
2049+
* @param {DatabasesIncrementDocumentAttributeRequestParams} params
2050+
*/
2051+
const databasesIncrementDocumentAttribute = async ({databaseId,collectionId,documentId,attribute,value,max,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
2052+
let client = !sdk ? await sdkForProject() :
2053+
sdk;
2054+
let apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId).replace('{attribute}', attribute);
2055+
let payload = {};
2056+
if (typeof value !== 'undefined') {
2057+
payload['value'] = value;
2058+
}
2059+
if (typeof max !== 'undefined') {
2060+
payload['max'] = max;
2061+
}
2062+
2063+
let response = undefined;
2064+
2065+
response = await client.call('patch', apiPath, {
2066+
'content-type': 'application/json',
2067+
}, payload);
2068+
2069+
if (parseOutput) {
2070+
parse(response)
2071+
}
2072+
2073+
return response;
2074+
2075+
}
2076+
19932077
/**
19942078
* @typedef {Object} DatabasesListIndexesRequestParams
19952079
* @property {string} databaseId Database ID.
@@ -2668,7 +2752,7 @@ databases
26682752

26692753
databases
26702754
.command(`upsert-documents`)
2671-
.description(`**WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console.`)
2755+
.description(`**WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. `)
26722756
.requiredOption(`--database-id <database-id>`, `Database ID.`)
26732757
.requiredOption(`--collection-id <collection-id>`, `Collection ID.`)
26742758
.requiredOption(`--documents [documents...]`, `Array of document data as JSON objects. May contain partial documents.`)
@@ -2738,6 +2822,28 @@ databases
27382822
.option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset`)
27392823
.action(actionRunner(databasesListDocumentLogs))
27402824

2825+
databases
2826+
.command(`decrement-document-attribute`)
2827+
.description(`Decrement a specific attribute of a document by a given value.`)
2828+
.requiredOption(`--database-id <database-id>`, `Database ID.`)
2829+
.requiredOption(`--collection-id <collection-id>`, `Collection ID.`)
2830+
.requiredOption(`--document-id <document-id>`, `Document ID.`)
2831+
.requiredOption(`--attribute <attribute>`, `Attribute key.`)
2832+
.option(`--value <value>`, `Value to decrement the attribute by. The value must be a number.`, parseInteger)
2833+
.option(`--min <min>`, `Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.`, parseInteger)
2834+
.action(actionRunner(databasesDecrementDocumentAttribute))
2835+
2836+
databases
2837+
.command(`increment-document-attribute`)
2838+
.description(`Increment a specific attribute of a document by a given value.`)
2839+
.requiredOption(`--database-id <database-id>`, `Database ID.`)
2840+
.requiredOption(`--collection-id <collection-id>`, `Collection ID.`)
2841+
.requiredOption(`--document-id <document-id>`, `Document ID.`)
2842+
.requiredOption(`--attribute <attribute>`, `Attribute key.`)
2843+
.option(`--value <value>`, `Value to increment the attribute by. The value must be a number.`, parseInteger)
2844+
.option(`--max <max>`, `Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.`, parseInteger)
2845+
.action(actionRunner(databasesIncrementDocumentAttribute))
2846+
27412847
databases
27422848
.command(`list-indexes`)
27432849
.description(`List indexes in the collection.`)
@@ -2853,6 +2959,8 @@ module.exports = {
28532959
databasesUpdateDocument,
28542960
databasesDeleteDocument,
28552961
databasesListDocumentLogs,
2962+
databasesDecrementDocumentAttribute,
2963+
databasesIncrementDocumentAttribute,
28562964
databasesListIndexes,
28572965
databasesCreateIndex,
28582966
databasesGetIndex,

lib/commands/types.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const path = require("path");
44
const { LanguageMeta, detectLanguage } = require("../type-generation/languages/language");
55
const { Command, Option, Argument } = require("commander");
66
const { localConfig } = require("../config");
7-
const { success, log, actionRunner } = require("../parser");
7+
const { success, log, warn, actionRunner } = require("../parser");
88
const { PHP } = require("../type-generation/languages/php");
99
const { TypeScript } = require("../type-generation/languages/typescript");
1010
const { Kotlin } = require("../type-generation/languages/kotlin");
@@ -71,7 +71,7 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language, strict})
7171
}
7272

7373
if (strict) {
74-
log(`Strict mode enabled: Field names will be converted to follow ${language} conventions`);
74+
warn(`Strict mode enabled: Field names will be converted to follow ${language} conventions`);
7575
}
7676

7777
const meta = createLanguageMeta(language);
@@ -97,13 +97,10 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language, strict})
9797
fs.mkdirSync(outputDirectory, { recursive: true });
9898
}
9999

100-
if (!fs.existsSync("appwrite.json")) {
101-
throw new Error("appwrite.json not found in current directory");
102-
}
103-
104100
const collections = localConfig.getCollections();
105101
if (collections.length === 0) {
106-
throw new Error("No collections found in appwrite.json");
102+
const configFileName = path.basename(localConfig.path);
103+
throw new Error(`No collections found in configuration. Make sure ${configFileName} exists and contains collections.`);
107104
}
108105

109106
log(`Found ${collections.length} collections: ${collections.map(c => c.name).join(", ")}`);
@@ -118,7 +115,7 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language, strict})
118115
collections,
119116
strict,
120117
...templateHelpers,
121-
getType: meta.getType
118+
getType: meta.getType,
122119
});
123120

124121
const destination = singleFileDestination || path.join(outputDirectory, meta.getFileName());
@@ -128,10 +125,11 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language, strict})
128125
} else {
129126
for (const collection of collections) {
130127
const content = templater({
128+
collections,
131129
collection,
132130
strict,
133131
...templateHelpers,
134-
getType: meta.getType
132+
getType: meta.getType,
135133
});
136134

137135
const destination = path.join(outputDirectory, meta.getFileName(collection));

lib/commands/users.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ const usersUpdateStatus = async ({userId,status,parseOutput = true, overrideForC
13611361
/**
13621362
* @typedef {Object} UsersListTargetsRequestParams
13631363
* @property {string} userId User ID.
1364-
* @property {string[]} queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels
1364+
* @property {string[]} queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, providerId, identifier, providerType
13651365
* @property {boolean} overrideForCli
13661366
* @property {boolean} parseOutput
13671367
* @property {libClient | undefined} sdk
@@ -1927,7 +1927,7 @@ users
19271927
.command(`list-targets`)
19281928
.description(`List the messaging targets that are associated with a user.`)
19291929
.requiredOption(`--user-id <user-id>`, `User ID.`)
1930-
.option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels`)
1930+
.option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, providerId, identifier, providerType`)
19311931
.action(actionRunner(usersListTargets))
19321932

19331933
users

0 commit comments

Comments
 (0)