appwrite-cli 8.2.2 → 8.3.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/CHANGELOG.md +12 -0
- package/README.md +2 -2
- package/docs/examples/databases/decrement-document-attribute.md +7 -0
- package/docs/examples/databases/increment-document-attribute.md +7 -0
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.js +2 -2
- package/lib/commands/databases.js +109 -1
- package/lib/commands/types.js +7 -9
- package/lib/commands/users.js +2 -2
- package/lib/commands/vcs.js +1 -1
- package/lib/config.js +26 -14
- package/lib/parser.js +1 -1
- package/lib/type-generation/languages/dart.js +13 -13
- package/lib/type-generation/languages/java.js +13 -13
- package/lib/type-generation/languages/javascript.js +14 -14
- package/lib/type-generation/languages/kotlin.js +11 -10
- package/lib/type-generation/languages/php.js +15 -14
- package/lib/type-generation/languages/swift.js +13 -13
- package/lib/type-generation/languages/typescript.js +8 -8
- package/package.json +1 -1
- package/scoop/appwrite.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
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
|
+
|
|
3
15
|
## 8.2.2
|
|
4
16
|
|
|
5
17
|
* Fix object comparison logic when pushing settings
|
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using
|
|
|
29
29
|
|
|
30
30
|
```sh
|
|
31
31
|
$ appwrite -v
|
|
32
|
-
8.
|
|
32
|
+
8.3.0
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
### Install using prebuilt binaries
|
|
@@ -60,7 +60,7 @@ $ scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/sc
|
|
|
60
60
|
Once the installation completes, you can verify your install using
|
|
61
61
|
```
|
|
62
62
|
$ appwrite -v
|
|
63
|
-
8.
|
|
63
|
+
8.3.0
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
## Getting Started
|
package/install.ps1
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
# You can use "View source" of this page to see the full script.
|
|
14
14
|
|
|
15
15
|
# REPO
|
|
16
|
-
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/8.
|
|
17
|
-
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/8.
|
|
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"
|
|
18
18
|
|
|
19
19
|
$APPWRITE_BINARY_NAME = "appwrite.exe"
|
|
20
20
|
|
package/install.sh
CHANGED
|
@@ -97,7 +97,7 @@ printSuccess() {
|
|
|
97
97
|
downloadBinary() {
|
|
98
98
|
echo "[2/4] Downloading executable for $OS ($ARCH) ..."
|
|
99
99
|
|
|
100
|
-
GITHUB_LATEST_VERSION="8.
|
|
100
|
+
GITHUB_LATEST_VERSION="8.3.0"
|
|
101
101
|
GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
|
|
102
102
|
GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"
|
|
103
103
|
|
package/lib/client.js
CHANGED
|
@@ -16,8 +16,8 @@ class Client {
|
|
|
16
16
|
'x-sdk-name': 'Command Line',
|
|
17
17
|
'x-sdk-platform': 'console',
|
|
18
18
|
'x-sdk-language': 'cli',
|
|
19
|
-
'x-sdk-version': '8.
|
|
20
|
-
'user-agent' : `AppwriteCLI/8.
|
|
19
|
+
'x-sdk-version': '8.3.0',
|
|
20
|
+
'user-agent' : `AppwriteCLI/8.3.0 (${os.type()} ${os.version()}; ${os.arch()})`,
|
|
21
21
|
'X-Appwrite-Response-Format' : '1.7.0',
|
|
22
22
|
};
|
|
23
23
|
}
|
|
@@ -1990,6 +1990,90 @@ const databasesListDocumentLogs = async ({databaseId,collectionId,documentId,que
|
|
|
1990
1990
|
|
|
1991
1991
|
}
|
|
1992
1992
|
|
|
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
|
+
|
|
1993
2077
|
/**
|
|
1994
2078
|
* @typedef {Object} DatabasesListIndexesRequestParams
|
|
1995
2079
|
* @property {string} databaseId Database ID.
|
|
@@ -2668,7 +2752,7 @@ databases
|
|
|
2668
2752
|
|
|
2669
2753
|
databases
|
|
2670
2754
|
.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. `)
|
|
2672
2756
|
.requiredOption(`--database-id <database-id>`, `Database ID.`)
|
|
2673
2757
|
.requiredOption(`--collection-id <collection-id>`, `Collection ID.`)
|
|
2674
2758
|
.requiredOption(`--documents [documents...]`, `Array of document data as JSON objects. May contain partial documents.`)
|
|
@@ -2738,6 +2822,28 @@ databases
|
|
|
2738
2822
|
.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`)
|
|
2739
2823
|
.action(actionRunner(databasesListDocumentLogs))
|
|
2740
2824
|
|
|
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
|
+
|
|
2741
2847
|
databases
|
|
2742
2848
|
.command(`list-indexes`)
|
|
2743
2849
|
.description(`List indexes in the collection.`)
|
|
@@ -2853,6 +2959,8 @@ module.exports = {
|
|
|
2853
2959
|
databasesUpdateDocument,
|
|
2854
2960
|
databasesDeleteDocument,
|
|
2855
2961
|
databasesListDocumentLogs,
|
|
2962
|
+
databasesDecrementDocumentAttribute,
|
|
2963
|
+
databasesIncrementDocumentAttribute,
|
|
2856
2964
|
databasesListIndexes,
|
|
2857
2965
|
databasesCreateIndex,
|
|
2858
2966
|
databasesGetIndex,
|
package/lib/commands/types.js
CHANGED
|
@@ -4,7 +4,7 @@ const path = require("path");
|
|
|
4
4
|
const { LanguageMeta, detectLanguage } = require("../type-generation/languages/language");
|
|
5
5
|
const { Command, Option, Argument } = require("commander");
|
|
6
6
|
const { localConfig } = require("../config");
|
|
7
|
-
const { success, log, actionRunner } = require("../parser");
|
|
7
|
+
const { success, log, warn, actionRunner } = require("../parser");
|
|
8
8
|
const { PHP } = require("../type-generation/languages/php");
|
|
9
9
|
const { TypeScript } = require("../type-generation/languages/typescript");
|
|
10
10
|
const { Kotlin } = require("../type-generation/languages/kotlin");
|
|
@@ -71,7 +71,7 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language, strict})
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
if (strict) {
|
|
74
|
-
|
|
74
|
+
warn(`Strict mode enabled: Field names will be converted to follow ${language} conventions`);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
const meta = createLanguageMeta(language);
|
|
@@ -97,13 +97,10 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language, strict})
|
|
|
97
97
|
fs.mkdirSync(outputDirectory, { recursive: true });
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
if (!fs.existsSync("appwrite.json")) {
|
|
101
|
-
throw new Error("appwrite.json not found in current directory");
|
|
102
|
-
}
|
|
103
|
-
|
|
104
100
|
const collections = localConfig.getCollections();
|
|
105
101
|
if (collections.length === 0) {
|
|
106
|
-
|
|
102
|
+
const configFileName = path.basename(localConfig.path);
|
|
103
|
+
throw new Error(`No collections found in configuration. Make sure ${configFileName} exists and contains collections.`);
|
|
107
104
|
}
|
|
108
105
|
|
|
109
106
|
log(`Found ${collections.length} collections: ${collections.map(c => c.name).join(", ")}`);
|
|
@@ -118,7 +115,7 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language, strict})
|
|
|
118
115
|
collections,
|
|
119
116
|
strict,
|
|
120
117
|
...templateHelpers,
|
|
121
|
-
getType: meta.getType
|
|
118
|
+
getType: meta.getType,
|
|
122
119
|
});
|
|
123
120
|
|
|
124
121
|
const destination = singleFileDestination || path.join(outputDirectory, meta.getFileName());
|
|
@@ -128,10 +125,11 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language, strict})
|
|
|
128
125
|
} else {
|
|
129
126
|
for (const collection of collections) {
|
|
130
127
|
const content = templater({
|
|
128
|
+
collections,
|
|
131
129
|
collection,
|
|
132
130
|
strict,
|
|
133
131
|
...templateHelpers,
|
|
134
|
-
getType: meta.getType
|
|
132
|
+
getType: meta.getType,
|
|
135
133
|
});
|
|
136
134
|
|
|
137
135
|
const destination = path.join(outputDirectory, meta.getFileName(collection));
|
package/lib/commands/users.js
CHANGED
|
@@ -1361,7 +1361,7 @@ const usersUpdateStatus = async ({userId,status,parseOutput = true, overrideForC
|
|
|
1361
1361
|
/**
|
|
1362
1362
|
* @typedef {Object} UsersListTargetsRequestParams
|
|
1363
1363
|
* @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:
|
|
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
|
|
1365
1365
|
* @property {boolean} overrideForCli
|
|
1366
1366
|
* @property {boolean} parseOutput
|
|
1367
1367
|
* @property {libClient | undefined} sdk
|
|
@@ -1927,7 +1927,7 @@ users
|
|
|
1927
1927
|
.command(`list-targets`)
|
|
1928
1928
|
.description(`List the messaging targets that are associated with a user.`)
|
|
1929
1929
|
.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:
|
|
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`)
|
|
1931
1931
|
.action(actionRunner(usersListTargets))
|
|
1932
1932
|
|
|
1933
1933
|
users
|
package/lib/commands/vcs.js
CHANGED
|
@@ -435,7 +435,7 @@ vcs
|
|
|
435
435
|
|
|
436
436
|
vcs
|
|
437
437
|
.command(`get-repository-contents`)
|
|
438
|
-
.description(`Get a list of files and directories from a GitHub repository connected to your project. This endpoint returns the contents of a specified repository path, including file names, sizes, and whether each item is a file or directory. The GitHub installation must be properly configured and the repository must be accessible through your installation for this endpoint to work
|
|
438
|
+
.description(`Get a list of files and directories from a GitHub repository connected to your project. This endpoint returns the contents of a specified repository path, including file names, sizes, and whether each item is a file or directory. The GitHub installation must be properly configured and the repository must be accessible through your installation for this endpoint to work.`)
|
|
439
439
|
.requiredOption(`--installation-id <installation-id>`, `Installation Id`)
|
|
440
440
|
.requiredOption(`--provider-repository-id <provider-repository-id>`, `Repository Id`)
|
|
441
441
|
.option(`--provider-root-directory <provider-root-directory>`, `Path to get contents of nested directory`)
|
package/lib/config.js
CHANGED
|
@@ -125,27 +125,39 @@ class Config {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
class Local extends Config {
|
|
128
|
-
static CONFIG_FILE_PATH = "appwrite.json";
|
|
128
|
+
static CONFIG_FILE_PATH = "appwrite.config.json";
|
|
129
|
+
static CONFIG_FILE_PATH_LEGACY = "appwrite.json";
|
|
129
130
|
configDirectoryPath = ""
|
|
130
131
|
|
|
131
|
-
constructor(path = Local.CONFIG_FILE_PATH) {
|
|
132
|
+
constructor(path = Local.CONFIG_FILE_PATH, legacyPath = Local.CONFIG_FILE_PATH_LEGACY) {
|
|
133
|
+
let absolutePath = Local.findConfigFile(path) || Local.findConfigFile(legacyPath);
|
|
134
|
+
|
|
135
|
+
if (!absolutePath) {
|
|
136
|
+
absolutePath = `${process.cwd()}/${path}`;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
super(absolutePath);
|
|
140
|
+
this.configDirectoryPath = _path.dirname(absolutePath);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
static findConfigFile(filename) {
|
|
132
144
|
let currentPath = process.cwd();
|
|
133
|
-
let absolutePath = `${currentPath}/${path}`;
|
|
134
145
|
|
|
135
146
|
while (true) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
147
|
+
const filePath = `${currentPath}/${filename}`;
|
|
148
|
+
|
|
149
|
+
if (fs.existsSync(filePath)) {
|
|
150
|
+
return filePath;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const parentDirectory = _path.dirname(currentPath);
|
|
154
|
+
if (parentDirectory === currentPath) {
|
|
155
|
+
break;
|
|
145
156
|
}
|
|
157
|
+
currentPath = parentDirectory;
|
|
146
158
|
}
|
|
147
|
-
|
|
148
|
-
|
|
159
|
+
|
|
160
|
+
return null;
|
|
149
161
|
}
|
|
150
162
|
|
|
151
163
|
getDirname() {
|
package/lib/parser.js
CHANGED
|
@@ -122,7 +122,7 @@ const parseError = (err) => {
|
|
|
122
122
|
} catch {
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
const version = '8.
|
|
125
|
+
const version = '8.3.0';
|
|
126
126
|
const stepsToReproduce = `Running \`appwrite ${cliConfig.reportData.data.args.join(' ')}\``;
|
|
127
127
|
const yourEnvironment = `CLI version: ${version}\nOperation System: ${os.type()}\nAppwrite version: ${appwriteVersion}\nIs Cloud: ${isCloud()}`;
|
|
128
128
|
|
|
@@ -6,7 +6,7 @@ const path = require('path');
|
|
|
6
6
|
|
|
7
7
|
class Dart extends LanguageMeta {
|
|
8
8
|
getPackageName() {
|
|
9
|
-
const pubspecPath = path.join(
|
|
9
|
+
const pubspecPath = path.join(process.cwd(), 'pubspec.yaml');
|
|
10
10
|
if (fs.existsSync(pubspecPath)) {
|
|
11
11
|
const pubspecContent = fs.readFileSync(pubspecPath, 'utf8');
|
|
12
12
|
const lines = pubspecContent.split('\n');
|
|
@@ -40,7 +40,7 @@ class Dart extends LanguageMeta {
|
|
|
40
40
|
return 'appwrite';
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
getType(attribute) {
|
|
43
|
+
getType(attribute, collections) {
|
|
44
44
|
let type = "";
|
|
45
45
|
switch (attribute.type) {
|
|
46
46
|
case AttributeType.STRING:
|
|
@@ -61,7 +61,11 @@ class Dart extends LanguageMeta {
|
|
|
61
61
|
type = "bool";
|
|
62
62
|
break;
|
|
63
63
|
case AttributeType.RELATIONSHIP:
|
|
64
|
-
|
|
64
|
+
const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
|
|
65
|
+
if (!relatedCollection) {
|
|
66
|
+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
|
|
67
|
+
}
|
|
68
|
+
type = LanguageMeta.toPascalCase(relatedCollection.name);
|
|
65
69
|
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
|
|
66
70
|
type = `List<${type}>`;
|
|
67
71
|
}
|
|
@@ -78,19 +82,15 @@ class Dart extends LanguageMeta {
|
|
|
78
82
|
return type;
|
|
79
83
|
}
|
|
80
84
|
|
|
81
|
-
getCurrentDirectory() {
|
|
82
|
-
return process.cwd();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
85
|
getTemplate() {
|
|
86
86
|
return `<% for (const attribute of collection.attributes) { -%>
|
|
87
87
|
<% if (attribute.type === 'relationship') { -%>
|
|
88
|
-
import '<%- toSnakeCase(attribute.relatedCollection) %>.dart';
|
|
88
|
+
import '<%- toSnakeCase(collections.find(c => c.$id === attribute.relatedCollection).name) %>.dart';
|
|
89
89
|
|
|
90
90
|
<% } -%>
|
|
91
91
|
<% } -%>
|
|
92
92
|
/// This file is auto-generated by the Appwrite CLI.
|
|
93
|
-
/// You can regenerate it by running \`appwrite
|
|
93
|
+
/// You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
|
|
94
94
|
|
|
95
95
|
<% for (const attribute of collection.attributes) { -%>
|
|
96
96
|
<% if (attribute.format === 'enum') { -%>
|
|
@@ -104,7 +104,7 @@ enum <%- toPascalCase(attribute.key) %> {
|
|
|
104
104
|
<% } -%>
|
|
105
105
|
class <%= toPascalCase(collection.name) %> {
|
|
106
106
|
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
|
|
107
|
-
<%- getType(attribute) %> <%= strict ? toCamelCase(attribute.key) : attribute.key %>;
|
|
107
|
+
<%- getType(attribute, collections) %> <%= strict ? toCamelCase(attribute.key) : attribute.key %>;
|
|
108
108
|
<% } -%>
|
|
109
109
|
|
|
110
110
|
<%= toPascalCase(collection.name) %>({
|
|
@@ -152,11 +152,11 @@ map['<%= attribute.key %>']<% if (!attribute.required) { %> ?? null<% } -%>
|
|
|
152
152
|
<% } -%>
|
|
153
153
|
<% } else if (attribute.type === 'relationship') { -%>
|
|
154
154
|
<% if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') { -%>
|
|
155
|
-
(map['<%= attribute.key %>'] as List<dynamic>?)?.map((e) => <%- toPascalCase(attribute.relatedCollection) %>.fromMap(e)).toList()<% if (!attribute.required) { %> ?? []<% } -%>
|
|
155
|
+
(map['<%= attribute.key %>'] as List<dynamic>?)?.map((e) => <%- toPascalCase(collections.find(c => c.$id === attribute.relatedCollection).name) %>.fromMap(e)).toList()<% if (!attribute.required) { %> ?? []<% } -%>
|
|
156
156
|
<% } else { -%>
|
|
157
157
|
<% if (!attribute.required) { -%>
|
|
158
|
-
map['<%= attribute.key %>'] != null ? <%- toPascalCase(attribute.relatedCollection) %>.fromMap(map['<%= attribute.key %>']) : null<% } else { -%>
|
|
159
|
-
<%- toPascalCase(attribute.relatedCollection) %>.fromMap(map['<%= attribute.key %>'])<% } -%>
|
|
158
|
+
map['<%= attribute.key %>'] != null ? <%- toPascalCase(collections.find(c => c.$id === attribute.relatedCollection).name) %>.fromMap(map['<%= attribute.key %>']) : null<% } else { -%>
|
|
159
|
+
<%- toPascalCase(collections.find(c => c.$id === attribute.relatedCollection).name) %>.fromMap(map['<%= attribute.key %>'])<% } -%>
|
|
160
160
|
<% } -%>
|
|
161
161
|
<% } -%><% if (index < collection.attributes.length - 1) { %>,<% } %>
|
|
162
162
|
<% } -%>
|
|
@@ -3,7 +3,7 @@ const { AttributeType } = require('../attribute');
|
|
|
3
3
|
const { LanguageMeta } = require("./language");
|
|
4
4
|
|
|
5
5
|
class Java extends LanguageMeta {
|
|
6
|
-
getType(attribute) {
|
|
6
|
+
getType(attribute, collections) {
|
|
7
7
|
let type = "";
|
|
8
8
|
switch (attribute.type) {
|
|
9
9
|
case AttributeType.STRING:
|
|
@@ -24,7 +24,11 @@ class Java extends LanguageMeta {
|
|
|
24
24
|
type = "boolean";
|
|
25
25
|
break;
|
|
26
26
|
case AttributeType.RELATIONSHIP:
|
|
27
|
-
|
|
27
|
+
const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
|
|
28
|
+
if (!relatedCollection) {
|
|
29
|
+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
|
|
30
|
+
}
|
|
31
|
+
type = LanguageMeta.toPascalCase(relatedCollection.name);
|
|
28
32
|
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
|
|
29
33
|
type = "List<" + type + ">";
|
|
30
34
|
}
|
|
@@ -38,25 +42,21 @@ class Java extends LanguageMeta {
|
|
|
38
42
|
return type;
|
|
39
43
|
}
|
|
40
44
|
|
|
41
|
-
getCurrentDirectory() {
|
|
42
|
-
return process.cwd();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
45
|
getTemplate() {
|
|
46
46
|
return `package io.appwrite.models;
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* This file is auto-generated by the Appwrite CLI.
|
|
50
|
-
* You can regenerate it by running \`appwrite
|
|
50
|
+
* You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
|
|
51
51
|
*/
|
|
52
52
|
|
|
53
53
|
import java.util.Objects;
|
|
54
54
|
<% for (const attribute of collection.attributes) { -%>
|
|
55
55
|
<% if (attribute.type === 'relationship') { -%>
|
|
56
|
-
import io.appwrite.models.<%- toPascalCase(attribute.relatedCollection) %>;
|
|
57
|
-
|
|
56
|
+
import io.appwrite.models.<%- toPascalCase(collections.find(c => c.$id === attribute.relatedCollection).name) %>;
|
|
58
57
|
<% } -%>
|
|
59
58
|
<% } -%>
|
|
59
|
+
|
|
60
60
|
public class <%- toPascalCase(collection.name) %> {
|
|
61
61
|
<% for (const attribute of collection.attributes) { -%>
|
|
62
62
|
<% if (attribute.format === 'enum') { -%>
|
|
@@ -70,7 +70,7 @@ public class <%- toPascalCase(collection.name) %> {
|
|
|
70
70
|
<% } -%>
|
|
71
71
|
<% } -%>
|
|
72
72
|
<% for (const attribute of collection.attributes) { -%>
|
|
73
|
-
private <%- getType(attribute) %> <%- strict ? toCamelCase(attribute.key) : attribute.key %>;
|
|
73
|
+
private <%- getType(attribute, collections) %> <%- strict ? toCamelCase(attribute.key) : attribute.key %>;
|
|
74
74
|
<% } -%>
|
|
75
75
|
|
|
76
76
|
public <%- toPascalCase(collection.name) %>() {
|
|
@@ -78,7 +78,7 @@ public class <%- toPascalCase(collection.name) %> {
|
|
|
78
78
|
|
|
79
79
|
public <%- toPascalCase(collection.name) %>(
|
|
80
80
|
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
|
|
81
|
-
<%- getType(attribute) %> <%= strict ? toCamelCase(attribute.key) : attribute.key %><%- index < collection.attributes.length - 1 ? ',' : '' %>
|
|
81
|
+
<%- getType(attribute, collections) %> <%= strict ? toCamelCase(attribute.key) : attribute.key %><%- index < collection.attributes.length - 1 ? ',' : '' %>
|
|
82
82
|
<% } -%>
|
|
83
83
|
) {
|
|
84
84
|
<% for (const attribute of collection.attributes) { -%>
|
|
@@ -87,11 +87,11 @@ public class <%- toPascalCase(collection.name) %> {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
<% for (const attribute of collection.attributes) { -%>
|
|
90
|
-
public <%- getType(attribute) %> get<%- toPascalCase(attribute.key) %>() {
|
|
90
|
+
public <%- getType(attribute, collections) %> get<%- toPascalCase(attribute.key) %>() {
|
|
91
91
|
return <%= strict ? toCamelCase(attribute.key) : attribute.key %>;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
public void set<%- toPascalCase(attribute.key) %>(<%- getType(attribute) %> <%= strict ? toCamelCase(attribute.key) : attribute.key %>) {
|
|
94
|
+
public void set<%- toPascalCase(attribute.key) %>(<%- getType(attribute, collections) %> <%= strict ? toCamelCase(attribute.key) : attribute.key %>) {
|
|
95
95
|
this.<%= strict ? toCamelCase(attribute.key) : attribute.key %> = <%= strict ? toCamelCase(attribute.key) : attribute.key %>;
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -6,7 +6,7 @@ const { AttributeType } = require('../attribute');
|
|
|
6
6
|
const { LanguageMeta } = require("./language");
|
|
7
7
|
|
|
8
8
|
class JavaScript extends LanguageMeta {
|
|
9
|
-
getType(attribute) {
|
|
9
|
+
getType(attribute, collections) {
|
|
10
10
|
let type = ""
|
|
11
11
|
switch (attribute.type) {
|
|
12
12
|
case AttributeType.STRING:
|
|
@@ -29,7 +29,11 @@ class JavaScript extends LanguageMeta {
|
|
|
29
29
|
type = "boolean";
|
|
30
30
|
break;
|
|
31
31
|
case AttributeType.RELATIONSHIP:
|
|
32
|
-
|
|
32
|
+
const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
|
|
33
|
+
if (!relatedCollection) {
|
|
34
|
+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
|
|
35
|
+
}
|
|
36
|
+
type = LanguageMeta.toPascalCase(relatedCollection.name);
|
|
33
37
|
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
|
|
34
38
|
type = `${type}[]`;
|
|
35
39
|
}
|
|
@@ -60,19 +64,14 @@ class JavaScript extends LanguageMeta {
|
|
|
60
64
|
return "appwrite";
|
|
61
65
|
}
|
|
62
66
|
|
|
63
|
-
getCurrentDirectory() {
|
|
64
|
-
return process.cwd();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
67
|
getTemplate() {
|
|
68
|
-
return
|
|
69
|
-
// This file is auto-generated by the Appwrite CLI.
|
|
70
|
-
// You can regenerate it by running \`appwrite types -l js ${this.getCurrentDirectory()}\`.
|
|
71
|
-
|
|
72
|
-
/**
|
|
68
|
+
return `/**
|
|
73
69
|
* @typedef {import('${this._getAppwriteDependency()}').Models.Document} Document
|
|
74
70
|
*/
|
|
75
71
|
|
|
72
|
+
// This file is auto-generated by the Appwrite CLI.
|
|
73
|
+
// You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
|
|
74
|
+
|
|
76
75
|
<% for (const collection of collections) { -%>
|
|
77
76
|
<% for (const attribute of collection.attributes) { -%>
|
|
78
77
|
<% if (attribute.format === 'enum') { -%>
|
|
@@ -83,14 +82,15 @@ class JavaScript extends LanguageMeta {
|
|
|
83
82
|
<% } -%>
|
|
84
83
|
<% } -%>
|
|
85
84
|
<% } -%>
|
|
86
|
-
<% for (const collection of collections) { %>/**
|
|
85
|
+
<% for (const [index, collection] of Object.entries(collections)) { %>/**
|
|
87
86
|
* @typedef {Document & {
|
|
88
87
|
<% for (const attribute of collection.attributes) { -%>
|
|
89
|
-
* <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute) %>;
|
|
88
|
+
* <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute, collections) %>;
|
|
90
89
|
<% } -%>
|
|
91
90
|
* }} <%- toPascalCase(collection.name) %>
|
|
92
91
|
*/
|
|
93
|
-
|
|
92
|
+
<% if (index < collections.length - 1) { %>
|
|
93
|
+
<% } -%>
|
|
94
94
|
<% } %>`;
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -3,7 +3,7 @@ const { AttributeType } = require('../attribute');
|
|
|
3
3
|
const { LanguageMeta } = require("./language");
|
|
4
4
|
|
|
5
5
|
class Kotlin extends LanguageMeta {
|
|
6
|
-
getType(attribute) {
|
|
6
|
+
getType(attribute, collections) {
|
|
7
7
|
let type = "";
|
|
8
8
|
switch (attribute.type) {
|
|
9
9
|
case AttributeType.STRING:
|
|
@@ -24,7 +24,11 @@ class Kotlin extends LanguageMeta {
|
|
|
24
24
|
type = "Boolean";
|
|
25
25
|
break;
|
|
26
26
|
case AttributeType.RELATIONSHIP:
|
|
27
|
-
|
|
27
|
+
const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
|
|
28
|
+
if (!relatedCollection) {
|
|
29
|
+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
|
|
30
|
+
}
|
|
31
|
+
type = LanguageMeta.toPascalCase(relatedCollection.name);
|
|
28
32
|
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
|
|
29
33
|
type = `List<${type}>`;
|
|
30
34
|
}
|
|
@@ -41,22 +45,18 @@ class Kotlin extends LanguageMeta {
|
|
|
41
45
|
return type;
|
|
42
46
|
}
|
|
43
47
|
|
|
44
|
-
getCurrentDirectory() {
|
|
45
|
-
return process.cwd();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
48
|
getTemplate() {
|
|
49
49
|
return `package io.appwrite.models
|
|
50
50
|
|
|
51
51
|
<% for (const attribute of collection.attributes) { -%>
|
|
52
52
|
<% if (attribute.type === 'relationship') { -%>
|
|
53
|
-
import <%- toPascalCase(attribute.relatedCollection) %>
|
|
53
|
+
import <%- toPascalCase(collections.find(c => c.$id === attribute.relatedCollection).name) %>
|
|
54
54
|
|
|
55
55
|
<% } -%>
|
|
56
56
|
<% } -%>
|
|
57
57
|
/**
|
|
58
58
|
* This file is auto-generated by the Appwrite CLI.
|
|
59
|
-
* You can regenerate it by running \`appwrite
|
|
59
|
+
* You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
|
|
60
60
|
*/
|
|
61
61
|
|
|
62
62
|
<% for (const attribute of collection.attributes) { -%>
|
|
@@ -71,9 +71,10 @@ enum class <%- toPascalCase(attribute.key) %> {
|
|
|
71
71
|
<% } -%>
|
|
72
72
|
data class <%- toPascalCase(collection.name) %>(
|
|
73
73
|
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
|
|
74
|
-
val <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute) %><% if (index < collection.attributes.length - 1) { %>,<% } %>
|
|
74
|
+
val <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute, collections) %><% if (index < collection.attributes.length - 1) { %>,<% } %>
|
|
75
75
|
<% } -%>
|
|
76
|
-
)
|
|
76
|
+
)
|
|
77
|
+
`;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
getFileName(collection) {
|
|
@@ -3,7 +3,7 @@ const { AttributeType } = require('../attribute');
|
|
|
3
3
|
const { LanguageMeta } = require("./language");
|
|
4
4
|
|
|
5
5
|
class PHP extends LanguageMeta {
|
|
6
|
-
getType(attribute) {
|
|
6
|
+
getType(attribute, collections) {
|
|
7
7
|
if (attribute.array) {
|
|
8
8
|
return "array";
|
|
9
9
|
}
|
|
@@ -27,7 +27,11 @@ class PHP extends LanguageMeta {
|
|
|
27
27
|
type = "bool";
|
|
28
28
|
break;
|
|
29
29
|
case AttributeType.RELATIONSHIP:
|
|
30
|
-
|
|
30
|
+
const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
|
|
31
|
+
if (!relatedCollection) {
|
|
32
|
+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
|
|
33
|
+
}
|
|
34
|
+
type = LanguageMeta.toPascalCase(relatedCollection.name);
|
|
31
35
|
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
|
|
32
36
|
type = "array";
|
|
33
37
|
}
|
|
@@ -41,20 +45,16 @@ class PHP extends LanguageMeta {
|
|
|
41
45
|
return type;
|
|
42
46
|
}
|
|
43
47
|
|
|
44
|
-
getCurrentDirectory() {
|
|
45
|
-
return process.cwd();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
48
|
getTemplate() {
|
|
49
49
|
return `<?php
|
|
50
50
|
namespace Appwrite\\Models;
|
|
51
51
|
|
|
52
52
|
// This file is auto-generated by the Appwrite CLI.
|
|
53
|
-
// You can regenerate it by running \`appwrite
|
|
53
|
+
// You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
|
|
54
54
|
|
|
55
55
|
<% for (const attribute of collection.attributes) { -%>
|
|
56
56
|
<% if (attribute.type === 'relationship' && !(attribute.relationType === 'manyToMany') && !(attribute.relationType === 'oneToMany' && attribute.side === 'parent')) { -%>
|
|
57
|
-
use Appwrite\\Models\\<%- toPascalCase(attribute.relatedCollection) %>;
|
|
57
|
+
use Appwrite\\Models\\<%- toPascalCase(collections.find(c => c.$id === attribute.relatedCollection).name) %>;
|
|
58
58
|
|
|
59
59
|
<% } -%>
|
|
60
60
|
<% } -%>
|
|
@@ -70,15 +70,15 @@ enum <%- toPascalCase(attribute.key) %>: string {
|
|
|
70
70
|
<% } -%>
|
|
71
71
|
class <%- toPascalCase(collection.name) %> {
|
|
72
72
|
<% for (const attribute of collection.attributes ){ -%>
|
|
73
|
-
private <%- getType(attribute) %> $<%- strict ? toCamelCase(attribute.key) : attribute.key %>;
|
|
73
|
+
private <%- getType(attribute, collections) %> $<%- strict ? toCamelCase(attribute.key) : attribute.key %>;
|
|
74
74
|
<% } -%>
|
|
75
75
|
|
|
76
76
|
public function __construct(
|
|
77
77
|
<% for (const attribute of collection.attributes ){ -%>
|
|
78
78
|
<% if (attribute.required) { -%>
|
|
79
|
-
<%- getType(attribute).replace('|null', '') %> $<%- strict ? toCamelCase(attribute.key) : attribute.key %><% if (collection.attributes.indexOf(attribute) < collection.attributes.length - 1) { %>,<% } %>
|
|
79
|
+
<%- getType(attribute, collections).replace('|null', '') %> $<%- strict ? toCamelCase(attribute.key) : attribute.key %><% if (collection.attributes.indexOf(attribute) < collection.attributes.length - 1) { %>,<% } %>
|
|
80
80
|
<% } else { -%>
|
|
81
|
-
?<%- getType(attribute).replace('|null', '') %> $<%- strict ? toCamelCase(attribute.key) : attribute.key %> = null<% if (collection.attributes.indexOf(attribute) < collection.attributes.length - 1) { %>,<% } %>
|
|
81
|
+
?<%- getType(attribute, collections).replace('|null', '') %> $<%- strict ? toCamelCase(attribute.key) : attribute.key %> = null<% if (collection.attributes.indexOf(attribute) < collection.attributes.length - 1) { %>,<% } %>
|
|
82
82
|
<% } -%>
|
|
83
83
|
<% } -%>
|
|
84
84
|
) {
|
|
@@ -88,17 +88,18 @@ class <%- toPascalCase(collection.name) %> {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
|
|
91
|
-
public function get<%- toPascalCase(attribute.key) %>(): <%- getType(attribute) %> {
|
|
91
|
+
public function get<%- toPascalCase(attribute.key) %>(): <%- getType(attribute, collections) %> {
|
|
92
92
|
return $this-><%- strict ? toCamelCase(attribute.key) : attribute.key %>;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
public function set<%- toPascalCase(attribute.key) %>(<%- getType(attribute) %> $<%- strict ? toCamelCase(attribute.key) : attribute.key %>): void {
|
|
95
|
+
public function set<%- toPascalCase(attribute.key) %>(<%- getType(attribute, collections) %> $<%- strict ? toCamelCase(attribute.key) : attribute.key %>): void {
|
|
96
96
|
$this-><%- strict ? toCamelCase(attribute.key) : attribute.key %> = $<%- strict ? toCamelCase(attribute.key) : attribute.key %>;
|
|
97
97
|
}
|
|
98
98
|
<% if (index < collection.attributes.length - 1) { %>
|
|
99
99
|
<% } -%>
|
|
100
100
|
<% } -%>
|
|
101
|
-
}
|
|
101
|
+
}
|
|
102
|
+
`;
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
getFileName(collection) {
|
|
@@ -3,7 +3,7 @@ const { AttributeType } = require('../attribute');
|
|
|
3
3
|
const { LanguageMeta } = require("./language");
|
|
4
4
|
|
|
5
5
|
class Swift extends LanguageMeta {
|
|
6
|
-
getType(attribute) {
|
|
6
|
+
getType(attribute, collections) {
|
|
7
7
|
let type = "";
|
|
8
8
|
switch (attribute.type) {
|
|
9
9
|
case AttributeType.STRING:
|
|
@@ -24,7 +24,11 @@ class Swift extends LanguageMeta {
|
|
|
24
24
|
type = "Bool";
|
|
25
25
|
break;
|
|
26
26
|
case AttributeType.RELATIONSHIP:
|
|
27
|
-
|
|
27
|
+
const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
|
|
28
|
+
if (!relatedCollection) {
|
|
29
|
+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
|
|
30
|
+
}
|
|
31
|
+
type = LanguageMeta.toPascalCase(relatedCollection.name);
|
|
28
32
|
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
|
|
29
33
|
type = `[${type}]`;
|
|
30
34
|
}
|
|
@@ -41,15 +45,11 @@ class Swift extends LanguageMeta {
|
|
|
41
45
|
return type;
|
|
42
46
|
}
|
|
43
47
|
|
|
44
|
-
getCurrentDirectory() {
|
|
45
|
-
return process.cwd();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
48
|
getTemplate() {
|
|
49
49
|
return `import Foundation
|
|
50
50
|
|
|
51
51
|
/// This file is auto-generated by the Appwrite CLI.
|
|
52
|
-
/// You can regenerate it by running \`appwrite
|
|
52
|
+
/// You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
|
|
53
53
|
|
|
54
54
|
<% for (const attribute of collection.attributes) { -%>
|
|
55
55
|
<% if (attribute.format === 'enum') { -%>
|
|
@@ -63,7 +63,7 @@ public enum <%- toPascalCase(attribute.key) %>: String, Codable, CaseIterable {
|
|
|
63
63
|
<% } -%>
|
|
64
64
|
public class <%- toPascalCase(collection.name) %>: Codable {
|
|
65
65
|
<% for (const attribute of collection.attributes) { -%>
|
|
66
|
-
public let <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute) %>
|
|
66
|
+
public let <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute, collections) %>
|
|
67
67
|
<% } %>
|
|
68
68
|
enum CodingKeys: String, CodingKey {
|
|
69
69
|
<% for (const attribute of collection.attributes) { -%>
|
|
@@ -73,7 +73,7 @@ public class <%- toPascalCase(collection.name) %>: Codable {
|
|
|
73
73
|
|
|
74
74
|
public init(
|
|
75
75
|
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
|
|
76
|
-
<%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute) %><% if (index < collection.attributes.length - 1) { %>,<% } %>
|
|
76
|
+
<%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute, collections) %><% if (index < collection.attributes.length - 1) { %>,<% } %>
|
|
77
77
|
<% } -%>
|
|
78
78
|
) {
|
|
79
79
|
<% for (const attribute of collection.attributes) { -%>
|
|
@@ -86,9 +86,9 @@ public class <%- toPascalCase(collection.name) %>: Codable {
|
|
|
86
86
|
|
|
87
87
|
<% for (const attribute of collection.attributes) { -%>
|
|
88
88
|
<% if (!(!attribute.required && attribute.default === null)) { -%>
|
|
89
|
-
self.<%- strict ? toCamelCase(attribute.key) : attribute.key %> = try container.decode(<%- getType(attribute).replace('?', '') %>.self, forKey: .<%- strict ? toCamelCase(attribute.key) : attribute.key %>)
|
|
89
|
+
self.<%- strict ? toCamelCase(attribute.key) : attribute.key %> = try container.decode(<%- getType(attribute, collections).replace('?', '') %>.self, forKey: .<%- strict ? toCamelCase(attribute.key) : attribute.key %>)
|
|
90
90
|
<% } else { -%>
|
|
91
|
-
self.<%- strict ? toCamelCase(attribute.key) : attribute.key %> = try container.decodeIfPresent(<%- getType(attribute).replace('?', '') %>.self, forKey: .<%- strict ? toCamelCase(attribute.key) : attribute.key %>)
|
|
91
|
+
self.<%- strict ? toCamelCase(attribute.key) : attribute.key %> = try container.decodeIfPresent(<%- getType(attribute, collections).replace('?', '') %>.self, forKey: .<%- strict ? toCamelCase(attribute.key) : attribute.key %>)
|
|
92
92
|
<% } -%>
|
|
93
93
|
<% } -%>
|
|
94
94
|
}
|
|
@@ -124,9 +124,9 @@ public class <%- toPascalCase(collection.name) %>: Codable {
|
|
|
124
124
|
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
|
|
125
125
|
<% if (attribute.type === 'relationship') { -%>
|
|
126
126
|
<% if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') { -%>
|
|
127
|
-
<%- strict ? toCamelCase(attribute.key) : attribute.key %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> [<%- toPascalCase(attribute.relatedCollection) %>]<% if (index < collection.attributes.length - 1) { %>,<% } %>
|
|
127
|
+
<%- strict ? toCamelCase(attribute.key) : attribute.key %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> [<%- toPascalCase(collections.find(c => c.$id === attribute.relatedCollection).name) %>]<% if (index < collection.attributes.length - 1) { %>,<% } %>
|
|
128
128
|
<% } else { -%>
|
|
129
|
-
<%- strict ? toCamelCase(attribute.key) : attribute.key %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> <%- toPascalCase(attribute.relatedCollection) %><% if (index < collection.attributes.length - 1) { %>,<% } %>
|
|
129
|
+
<%- strict ? toCamelCase(attribute.key) : attribute.key %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> <%- toPascalCase(collections.find(c => c.$id === attribute.relatedCollection).name) %><% if (index < collection.attributes.length - 1) { %>,<% } %>
|
|
130
130
|
<% } -%>
|
|
131
131
|
<% } else if (attribute.array) { -%>
|
|
132
132
|
<% if (attribute.type === 'string') { -%>
|
|
@@ -6,7 +6,7 @@ const { AttributeType } = require('../attribute');
|
|
|
6
6
|
const { LanguageMeta } = require("./language");
|
|
7
7
|
|
|
8
8
|
class TypeScript extends LanguageMeta {
|
|
9
|
-
getType(attribute) {
|
|
9
|
+
getType(attribute, collections) {
|
|
10
10
|
let type = ""
|
|
11
11
|
switch (attribute.type) {
|
|
12
12
|
case AttributeType.STRING:
|
|
@@ -29,7 +29,11 @@ class TypeScript extends LanguageMeta {
|
|
|
29
29
|
type = "boolean";
|
|
30
30
|
break;
|
|
31
31
|
case AttributeType.RELATIONSHIP:
|
|
32
|
-
|
|
32
|
+
const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
|
|
33
|
+
if (!relatedCollection) {
|
|
34
|
+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
|
|
35
|
+
}
|
|
36
|
+
type = LanguageMeta.toPascalCase(relatedCollection.name);
|
|
33
37
|
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
|
|
34
38
|
type = `${type}[]`;
|
|
35
39
|
}
|
|
@@ -64,15 +68,11 @@ class TypeScript extends LanguageMeta {
|
|
|
64
68
|
return "appwrite";
|
|
65
69
|
}
|
|
66
70
|
|
|
67
|
-
getCurrentDirectory() {
|
|
68
|
-
return process.cwd();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
71
|
getTemplate() {
|
|
72
72
|
return `import { type Models } from '${this._getAppwriteDependency()}';
|
|
73
73
|
|
|
74
74
|
// This file is auto-generated by the Appwrite CLI.
|
|
75
|
-
// You can regenerate it by running \`appwrite
|
|
75
|
+
// You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
|
|
76
76
|
|
|
77
77
|
<% for (const collection of collections) { -%>
|
|
78
78
|
<% for (const attribute of collection.attributes) { -%>
|
|
@@ -90,7 +90,7 @@ export enum <%- toPascalCase(attribute.key) %> {
|
|
|
90
90
|
<% for (const [index, collection] of Object.entries(collections)) { -%>
|
|
91
91
|
export type <%- toPascalCase(collection.name) %> = Models.Document & {
|
|
92
92
|
<% for (const attribute of collection.attributes) { -%>
|
|
93
|
-
<%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute) %>;
|
|
93
|
+
<%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute, collections) %>;
|
|
94
94
|
<% } -%>
|
|
95
95
|
}<% if (index < collections.length - 1) { %>
|
|
96
96
|
<% } %>
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "appwrite-cli",
|
|
3
3
|
"homepage": "https://appwrite.io/support",
|
|
4
4
|
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
|
|
5
|
-
"version": "8.
|
|
5
|
+
"version": "8.3.0",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"bin": {
|
package/scoop/appwrite.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.0",
|
|
4
4
|
"description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.",
|
|
5
5
|
"homepage": "https://github.com/appwrite/sdk-for-cli",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"architecture": {
|
|
8
8
|
"64bit": {
|
|
9
|
-
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/8.
|
|
9
|
+
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/8.3.0/appwrite-cli-win-x64.exe",
|
|
10
10
|
"bin": [
|
|
11
11
|
[
|
|
12
12
|
"appwrite-cli-win-x64.exe",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
]
|
|
16
16
|
},
|
|
17
17
|
"arm64": {
|
|
18
|
-
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/8.
|
|
18
|
+
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/8.3.0/appwrite-cli-win-arm64.exe",
|
|
19
19
|
"bin": [
|
|
20
20
|
[
|
|
21
21
|
"appwrite-cli-win-arm64.exe",
|