Skip to content

Commit ac18baf

Browse files
authored
Merge pull request #201 from appwrite/dev
feat: Command Line SDK update for version 10.0.1
2 parents 09587bb + f962455 commit ac18baf

File tree

14 files changed

+110
-90
lines changed

14 files changed

+110
-90
lines changed

CHANGELOG.md

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

3+
## 10.0.1
4+
5+
* Fix CLI Dart model generation issues
6+
* Fix row permissions and security sync
7+
* Fix error when pushing columns with relationships
8+
* Fix resource name from attributes to columns for TablesDB indexes
9+
310
## 10.0.0
411

512
* **Breaking:** Removed Avatars CLI command and all related subcommands; corresponding examples deleted

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-
10.0.0
32+
10.0.1
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-
10.0.0
63+
10.0.1
6464
```
6565

6666
## Getting Started

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/10.0.0/appwrite-cli-win-x64.exe"
17-
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/10.0.0/appwrite-cli-win-arm64.exe"
16+
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/10.0.1/appwrite-cli-win-x64.exe"
17+
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/10.0.1/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="10.0.0"
100+
GITHUB_LATEST_VERSION="10.0.1"
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': '10.0.0',
20-
'user-agent' : `AppwriteCLI/10.0.0 (${os.type()} ${os.version()}; ${os.arch()})`,
19+
'x-sdk-version': '10.0.1',
20+
'user-agent' : `AppwriteCLI/10.0.1 (${os.type()} ${os.version()}; ${os.arch()})`,
2121
'X-Appwrite-Response-Format' : '1.8.0',
2222
};
2323
}

lib/commands/projects.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ const projectsListPlatforms = async ({projectId,parseOutput = true, overrideForC
12341234
/**
12351235
* @typedef {Object} ProjectsCreatePlatformRequestParams
12361236
* @property {string} projectId Project unique ID.
1237-
* @property {PlatformType} type Platform type.
1237+
* @property {PlatformType} type Platform type. Possible values are: web, flutter-web, flutter-ios, flutter-android, flutter-linux, flutter-macos, flutter-windows, apple-ios, apple-macos, apple-watchos, apple-tvos, android, unity, react-native-ios, react-native-android.
12381238
* @property {string} name Platform name. Max length: 128 chars.
12391239
* @property {string} key Package name for Android or bundle ID for iOS or macOS. Max length: 256 chars.
12401240
* @property {string} store App store or Google Play store ID. Max length: 256 chars.
@@ -2354,7 +2354,7 @@ projects
23542354
.command(`create-platform`)
23552355
.description(`Create a new platform for your project. Use this endpoint to register a new platform where your users will run your application which will interact with the Appwrite API.`)
23562356
.requiredOption(`--project-id <project-id>`, `Project unique ID.`)
2357-
.requiredOption(`--type <type>`, `Platform type.`)
2357+
.requiredOption(`--type <type>`, `Platform type. Possible values are: web, flutter-web, flutter-ios, flutter-android, flutter-linux, flutter-macos, flutter-windows, apple-ios, apple-macos, apple-watchos, apple-tvos, android, unity, react-native-ios, react-native-android.`)
23582358
.requiredOption(`--name <name>`, `Platform name. Max length: 128 chars.`)
23592359
.option(`--key <key>`, `Package name for Android or bundle ID for iOS or macOS. Max length: 256 chars.`)
23602360
.option(`--store <store>`, `App store or Google Play store ID. Max length: 256 chars.`)

lib/commands/pull.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ const pullTable = async () => {
358358
});
359359
if (fetchResponse["databases"].length <= 0) {
360360
log("No tables found.");
361-
success(`Successfully pulled ${chalk.bold(totalTables)} tables from ${chalk.bold(totalTablesDBs)} tables databases.`);
361+
success(`Successfully pulled ${chalk.bold(totalTables)} tables from ${chalk.bold(totalTablesDBs)} tableDBs.`);
362362
return;
363363
}
364364

@@ -398,7 +398,7 @@ const pullTable = async () => {
398398
}
399399
}
400400

401-
success(`Successfully pulled ${chalk.bold(totalTables)} tables from ${chalk.bold(totalTablesDBs)} tables databases.`);
401+
success(`Successfully pulled ${chalk.bold(totalTables)} tables from ${chalk.bold(totalTablesDBs)} tableDBs.`);
402402
}
403403

404404
const pullBucket = async () => {

lib/commands/push.js

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ const {
5050
databasesUpdateCollection
5151
} = require("./databases");
5252
const {
53+
tablesDBCreate,
5354
tablesDBGet,
55+
tablesDBUpdate,
56+
tablesDBCreateTable,
5457
tablesDBGetTable,
55-
tablesDBUpdateTable,
56-
tablesDBCreateTable
58+
tablesDBUpdateTable
5759
} = require("./tables-db");
5860
const {
5961
storageGetBucket, storageUpdateBucket, storageCreateBucket
@@ -548,7 +550,7 @@ const createAttribute = (databaseId, collectionId, attribute) => {
548550
return databasesCreateRelationshipAttribute({
549551
databaseId,
550552
collectionId,
551-
relatedCollectionId: attribute.relatedCollection,
553+
relatedCollectionId: attribute.relatedTable ?? attribute.relatedCollection,
552554
type: attribute.relationType,
553555
twoWay: attribute.twoWay,
554556
key: attribute.key,
@@ -667,7 +669,7 @@ const updateAttribute = (databaseId, collectionId, attribute) => {
667669
return databasesUpdateRelationshipAttribute({
668670
databaseId,
669671
collectionId,
670-
relatedCollectionId: attribute.relatedCollection,
672+
relatedCollectionId: attribute.relatedTable ?? attribute.relatedCollection,
671673
type: attribute.relationType,
672674
twoWay: attribute.twoWay,
673675
key: attribute.key,
@@ -881,7 +883,7 @@ const createIndexes = async (indexes, collection) => {
881883
collectionId: collection['$id'],
882884
key: index.key,
883885
type: index.type,
884-
attributes: index.attributes,
886+
attributes: index.columns ?? index.attributes,
885887
orders: index.orders,
886888
parseOutput: false
887889
});
@@ -1730,7 +1732,7 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
17301732

17311733
const databases = Array.from(new Set(tables.map(table => table['databaseId'])));
17321734

1733-
// Parallel db actions
1735+
// Parallel tablesDB actions
17341736
await Promise.all(databases.map(async (databaseId) => {
17351737
const localDatabase = localConfig.getTablesDB(databaseId);
17361738

@@ -1741,7 +1743,7 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
17411743
});
17421744

17431745
if (database.name !== (localDatabase.name ?? databaseId)) {
1744-
await databasesUpdate({
1746+
await tablesDBUpdate({
17451747
databaseId: databaseId,
17461748
name: localDatabase.name ?? databaseId,
17471749
parseOutput: false
@@ -1752,7 +1754,7 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
17521754
} catch (err) {
17531755
log(`Database ${databaseId} not found. Creating it now ...`);
17541756

1755-
await databasesCreate({
1757+
await tablesDBCreate({
17561758
databaseId: databaseId,
17571759
name: localDatabase.name ?? databaseId,
17581760
parseOutput: false,
@@ -1761,10 +1763,12 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
17611763
}));
17621764

17631765

1764-
if (!(await approveChanges(tables, tablesDBGetTable, KeysTable, 'tableId', 'tables', ['columns', 'indexes'], 'databaseId', 'databaseId',))) {
1766+
if (!(await approveChanges(tables, tablesDBGetTable, KeysTable, 'tableId', 'tables', ['columns', 'indexes'], 'databaseId', 'databaseId'))) {
17651767
return;
17661768
}
1767-
// Parallel collection actions
1769+
let tablesChanged = new Set();
1770+
1771+
// Parallel tables actions
17681772
await Promise.all(tables.map(async (table) => {
17691773
try {
17701774
const remoteTable = await tablesDBGetTable({
@@ -1773,15 +1777,23 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
17731777
parseOutput: false,
17741778
});
17751779

1776-
if (remoteTable.name !== table.name) {
1780+
const changes = [];
1781+
if (remoteTable.name !== table.name) changes.push('name');
1782+
if (remoteTable.rowSecurity !== table.rowSecurity) changes.push('rowSecurity');
1783+
if (JSON.stringify(remoteTable['$permissions']) !== JSON.stringify(table['$permissions'])) changes.push('permissions');
1784+
1785+
if (changes.length > 0) {
17771786
await tablesDBUpdateTable({
17781787
databaseId: table['databaseId'],
17791788
tableId: table['$id'],
17801789
name: table.name,
1781-
parseOutput: false
1790+
parseOutput: false,
1791+
rowSecurity: table.rowSecurity,
1792+
permissions: table['$permissions']
17821793
})
17831794

1784-
success(`Updated ${table.name} ( ${table['$id']} ) name`);
1795+
success(`Updated ${table.name} ( ${table['$id']} ) - ${changes.join(', ')}`);
1796+
tablesChanged.add(table['$id']);
17851797
}
17861798
table.remoteVersion = remoteTable;
17871799

@@ -1794,16 +1806,19 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
17941806
databaseId: table['databaseId'],
17951807
tableId: table['$id'],
17961808
name: table.name,
1797-
documentSecurity: table.documentSecurity,
1809+
rowSecurity: table.rowSecurity,
17981810
permissions: table['$permissions'],
17991811
parseOutput: false
18001812
})
1813+
1814+
success(`Created ${table.name} ( ${table['$id']} )`);
1815+
tablesChanged.add(table['$id']);
18011816
} else {
18021817
throw e;
18031818
}
18041819
}
18051820
}))
1806-
let numberOfTables = 0;
1821+
18071822
// Serialize attribute actions
18081823
for (let table of tables) {
18091824
let columns = table.columns;
@@ -1831,11 +1846,11 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
18311846
} catch (e) {
18321847
throw e;
18331848
}
1834-
numberOfTables++;
1849+
tablesChanged.add(table['$id']);
18351850
success(`Successfully pushed ${table.name} ( ${table['$id']} )`);
18361851
}
18371852

1838-
success(`Successfully pushed ${numberOfTables} tables`);
1853+
success(`Successfully pushed ${tablesChanged.size} tables`);
18391854
}
18401855

18411856
const pushCollection = async ({ returnOnZero, attempts } = { returnOnZero: false }) => {

lib/config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const KeysSite = new Set(["path", "$id", "name", "enabled", "logging", "timeout"
99
const KeysFunction = new Set(["path", "$id", "execute", "name", "enabled", "logging", "runtime", "specification", "scopes", "events", "schedule", "timeout", "entrypoint", "commands", "vars"]);
1010
const KeysDatabase = new Set(["$id", "name", "enabled"]);
1111
const KeysCollection = new Set(["$id", "$permissions", "databaseId", "name", "enabled", "documentSecurity", "attributes", "indexes"]);
12-
const KeysTable = new Set(["$id", "$permissions", "databaseId", "name", "enabled", "documentSecurity", "columns", "indexes"]);
12+
const KeysTable = new Set(["$id", "$permissions", "databaseId", "name", "enabled", "rowSecurity", "columns", "indexes"]);
1313
const KeysStorage = new Set(["$id", "$permissions", "fileSecurity", "name", "enabled", "maximumFileSize", "allowedFileExtensions", "compression", "encryption", "antivirus"]);
1414
const KeysTopics = new Set(["$id", "name", "subscribe"]);
1515
const KeysTeams = new Set(["$id", "name"]);
@@ -62,12 +62,13 @@ const KeysColumns = new Set([
6262
"onDelete",
6363
"side",
6464
// Indexes
65-
"attributes",
65+
"columns",
6666
"orders",
6767
// Strings
6868
"encrypt",
6969
]);
7070
const KeyIndexes = new Set(["key", "type", "status", "attributes", "orders"]);
71+
const KeyIndexesColumns = new Set(["key", "type", "status", "columns", "orders"]);
7172

7273
function whitelistKeys(value, keys, nestedKeys = {}) {
7374
if (Array.isArray(value)) {
@@ -404,7 +405,7 @@ class Local extends Config {
404405
addTable(props) {
405406
props = whitelistKeys(props, KeysTable, {
406407
columns: KeysColumns,
407-
indexes: KeyIndexes
408+
indexes: KeyIndexesColumns
408409
});
409410

410411
if (!this.has("tables")) {

lib/parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ const parseError = (err) => {
122122
} catch {
123123
}
124124

125-
const version = '10.0.0';
125+
const version = '10.0.1';
126126
const stepsToReproduce = `Running \`appwrite ${cliConfig.reportData.data.args.join(' ')}\``;
127127
const yourEnvironment = `CLI version: ${version}\nOperation System: ${os.type()}\nAppwrite version: ${appwriteVersion}\nIs Cloud: ${isCloud()}`;
128128

0 commit comments

Comments
 (0)