appwrite-cli 10.0.0 → 10.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
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
+
3
10
  ## 10.0.0
4
11
 
5
12
  * **Breaking:** Removed Avatars CLI command and all related subcommands; corresponding examples deleted
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
- 10.0.0
32
+ 10.0.1
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
- 10.0.0
63
+ 10.0.1
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/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"
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="10.0.0"
100
+ GITHUB_LATEST_VERSION="10.0.1"
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': '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()})`,
21
21
  'X-Appwrite-Response-Format' : '1.8.0',
22
22
  };
23
23
  }
@@ -1234,7 +1234,7 @@ const projectsListPlatforms = async ({projectId,parseOutput = true, overrideForC
1234
1234
  /**
1235
1235
  * @typedef {Object} ProjectsCreatePlatformRequestParams
1236
1236
  * @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.
1238
1238
  * @property {string} name Platform name. Max length: 128 chars.
1239
1239
  * @property {string} key Package name for Android or bundle ID for iOS or macOS. Max length: 256 chars.
1240
1240
  * @property {string} store App store or Google Play store ID. Max length: 256 chars.
@@ -2354,7 +2354,7 @@ projects
2354
2354
  .command(`create-platform`)
2355
2355
  .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.`)
2356
2356
  .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.`)
2358
2358
  .requiredOption(`--name <name>`, `Platform name. Max length: 128 chars.`)
2359
2359
  .option(`--key <key>`, `Package name for Android or bundle ID for iOS or macOS. Max length: 256 chars.`)
2360
2360
  .option(`--store <store>`, `App store or Google Play store ID. Max length: 256 chars.`)
@@ -358,7 +358,7 @@ const pullTable = async () => {
358
358
  });
359
359
  if (fetchResponse["databases"].length <= 0) {
360
360
  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.`);
362
362
  return;
363
363
  }
364
364
 
@@ -398,7 +398,7 @@ const pullTable = async () => {
398
398
  }
399
399
  }
400
400
 
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.`);
402
402
  }
403
403
 
404
404
  const pullBucket = async () => {
@@ -50,10 +50,12 @@ const {
50
50
  databasesUpdateCollection
51
51
  } = require("./databases");
52
52
  const {
53
+ tablesDBCreate,
53
54
  tablesDBGet,
55
+ tablesDBUpdate,
56
+ tablesDBCreateTable,
54
57
  tablesDBGetTable,
55
- tablesDBUpdateTable,
56
- tablesDBCreateTable
58
+ tablesDBUpdateTable
57
59
  } = require("./tables-db");
58
60
  const {
59
61
  storageGetBucket, storageUpdateBucket, storageCreateBucket
@@ -548,7 +550,7 @@ const createAttribute = (databaseId, collectionId, attribute) => {
548
550
  return databasesCreateRelationshipAttribute({
549
551
  databaseId,
550
552
  collectionId,
551
- relatedCollectionId: attribute.relatedCollection,
553
+ relatedCollectionId: attribute.relatedTable ?? attribute.relatedCollection,
552
554
  type: attribute.relationType,
553
555
  twoWay: attribute.twoWay,
554
556
  key: attribute.key,
@@ -667,7 +669,7 @@ const updateAttribute = (databaseId, collectionId, attribute) => {
667
669
  return databasesUpdateRelationshipAttribute({
668
670
  databaseId,
669
671
  collectionId,
670
- relatedCollectionId: attribute.relatedCollection,
672
+ relatedCollectionId: attribute.relatedTable ?? attribute.relatedCollection,
671
673
  type: attribute.relationType,
672
674
  twoWay: attribute.twoWay,
673
675
  key: attribute.key,
@@ -881,7 +883,7 @@ const createIndexes = async (indexes, collection) => {
881
883
  collectionId: collection['$id'],
882
884
  key: index.key,
883
885
  type: index.type,
884
- attributes: index.attributes,
886
+ attributes: index.columns ?? index.attributes,
885
887
  orders: index.orders,
886
888
  parseOutput: false
887
889
  });
@@ -1730,7 +1732,7 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
1730
1732
 
1731
1733
  const databases = Array.from(new Set(tables.map(table => table['databaseId'])));
1732
1734
 
1733
- // Parallel db actions
1735
+ // Parallel tablesDB actions
1734
1736
  await Promise.all(databases.map(async (databaseId) => {
1735
1737
  const localDatabase = localConfig.getTablesDB(databaseId);
1736
1738
 
@@ -1741,7 +1743,7 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
1741
1743
  });
1742
1744
 
1743
1745
  if (database.name !== (localDatabase.name ?? databaseId)) {
1744
- await databasesUpdate({
1746
+ await tablesDBUpdate({
1745
1747
  databaseId: databaseId,
1746
1748
  name: localDatabase.name ?? databaseId,
1747
1749
  parseOutput: false
@@ -1752,7 +1754,7 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
1752
1754
  } catch (err) {
1753
1755
  log(`Database ${databaseId} not found. Creating it now ...`);
1754
1756
 
1755
- await databasesCreate({
1757
+ await tablesDBCreate({
1756
1758
  databaseId: databaseId,
1757
1759
  name: localDatabase.name ?? databaseId,
1758
1760
  parseOutput: false,
@@ -1761,10 +1763,12 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
1761
1763
  }));
1762
1764
 
1763
1765
 
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'))) {
1765
1767
  return;
1766
1768
  }
1767
- // Parallel collection actions
1769
+ let tablesChanged = new Set();
1770
+
1771
+ // Parallel tables actions
1768
1772
  await Promise.all(tables.map(async (table) => {
1769
1773
  try {
1770
1774
  const remoteTable = await tablesDBGetTable({
@@ -1773,15 +1777,23 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
1773
1777
  parseOutput: false,
1774
1778
  });
1775
1779
 
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) {
1777
1786
  await tablesDBUpdateTable({
1778
1787
  databaseId: table['databaseId'],
1779
1788
  tableId: table['$id'],
1780
1789
  name: table.name,
1781
- parseOutput: false
1790
+ parseOutput: false,
1791
+ rowSecurity: table.rowSecurity,
1792
+ permissions: table['$permissions']
1782
1793
  })
1783
1794
 
1784
- success(`Updated ${table.name} ( ${table['$id']} ) name`);
1795
+ success(`Updated ${table.name} ( ${table['$id']} ) - ${changes.join(', ')}`);
1796
+ tablesChanged.add(table['$id']);
1785
1797
  }
1786
1798
  table.remoteVersion = remoteTable;
1787
1799
 
@@ -1794,16 +1806,19 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
1794
1806
  databaseId: table['databaseId'],
1795
1807
  tableId: table['$id'],
1796
1808
  name: table.name,
1797
- documentSecurity: table.documentSecurity,
1809
+ rowSecurity: table.rowSecurity,
1798
1810
  permissions: table['$permissions'],
1799
1811
  parseOutput: false
1800
1812
  })
1813
+
1814
+ success(`Created ${table.name} ( ${table['$id']} )`);
1815
+ tablesChanged.add(table['$id']);
1801
1816
  } else {
1802
1817
  throw e;
1803
1818
  }
1804
1819
  }
1805
1820
  }))
1806
- let numberOfTables = 0;
1821
+
1807
1822
  // Serialize attribute actions
1808
1823
  for (let table of tables) {
1809
1824
  let columns = table.columns;
@@ -1831,11 +1846,11 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
1831
1846
  } catch (e) {
1832
1847
  throw e;
1833
1848
  }
1834
- numberOfTables++;
1849
+ tablesChanged.add(table['$id']);
1835
1850
  success(`Successfully pushed ${table.name} ( ${table['$id']} )`);
1836
1851
  }
1837
1852
 
1838
- success(`Successfully pushed ${numberOfTables} tables`);
1853
+ success(`Successfully pushed ${tablesChanged.size} tables`);
1839
1854
  }
1840
1855
 
1841
1856
  const pushCollection = async ({ returnOnZero, attempts } = { returnOnZero: false }) => {
package/lib/config.js CHANGED
@@ -9,7 +9,7 @@ const KeysSite = new Set(["path", "$id", "name", "enabled", "logging", "timeout"
9
9
  const KeysFunction = new Set(["path", "$id", "execute", "name", "enabled", "logging", "runtime", "specification", "scopes", "events", "schedule", "timeout", "entrypoint", "commands", "vars"]);
10
10
  const KeysDatabase = new Set(["$id", "name", "enabled"]);
11
11
  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"]);
13
13
  const KeysStorage = new Set(["$id", "$permissions", "fileSecurity", "name", "enabled", "maximumFileSize", "allowedFileExtensions", "compression", "encryption", "antivirus"]);
14
14
  const KeysTopics = new Set(["$id", "name", "subscribe"]);
15
15
  const KeysTeams = new Set(["$id", "name"]);
@@ -62,12 +62,13 @@ const KeysColumns = new Set([
62
62
  "onDelete",
63
63
  "side",
64
64
  // Indexes
65
- "attributes",
65
+ "columns",
66
66
  "orders",
67
67
  // Strings
68
68
  "encrypt",
69
69
  ]);
70
70
  const KeyIndexes = new Set(["key", "type", "status", "attributes", "orders"]);
71
+ const KeyIndexesColumns = new Set(["key", "type", "status", "columns", "orders"]);
71
72
 
72
73
  function whitelistKeys(value, keys, nestedKeys = {}) {
73
74
  if (Array.isArray(value)) {
@@ -404,7 +405,7 @@ class Local extends Config {
404
405
  addTable(props) {
405
406
  props = whitelistKeys(props, KeysTable, {
406
407
  columns: KeysColumns,
407
- indexes: KeyIndexes
408
+ indexes: KeyIndexesColumns
408
409
  });
409
410
 
410
411
  if (!this.has("tables")) {
package/lib/parser.js CHANGED
@@ -122,7 +122,7 @@ const parseError = (err) => {
122
122
  } catch {
123
123
  }
124
124
 
125
- const version = '10.0.0';
125
+ const version = '10.0.1';
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
 
@@ -83,104 +83,101 @@ class Dart extends LanguageMeta {
83
83
  }
84
84
 
85
85
  getTemplate() {
86
- return `<% for (const attribute of collection.attributes) { -%>
87
- <% if (attribute.type === 'relationship') { -%>
88
- import '<%- toSnakeCase(collections.find(c => c.$id === attribute.relatedCollection).name) %>.dart';
89
-
90
- <% } -%>
91
- <% } -%>
92
- /// This file is auto-generated by the Appwrite CLI.
93
- /// You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
94
-
95
- <% for (const attribute of collection.attributes) { -%>
96
- <% if (attribute.format === 'enum') { -%>
86
+ return `// This file is auto-generated by the Appwrite CLI.
87
+ // You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
88
+ <% const __relatedImportsSeen = new Set();
89
+ const sortedAttributes = collection.attributes.slice().sort((a, b) => {
90
+ if (a.required === b.required) return 0;
91
+ return a.required ? -1 : 1;
92
+ }); -%>
93
+ <% const __attrs = sortedAttributes; -%>
94
+ <% for (const attribute of __attrs) { -%>
95
+ <% if (attribute.type === '${AttributeType.RELATIONSHIP}') { -%>
96
+ <% const related = collections.find(c => c.$id === attribute.relatedCollection); -%>
97
+ <% if (related && !__relatedImportsSeen.has(toSnakeCase(related.name))) { -%>
98
+ import '<%- toSnakeCase(related.name) %>.dart';
99
+ <% __relatedImportsSeen.add(toSnakeCase(related.name)); -%>
100
+ <% } -%>
101
+ <% } -%>
102
+ <% } -%>
103
+
104
+ <% for (const attribute of __attrs) { -%>
105
+ <% if (attribute.format === '${AttributeType.ENUM}') { -%>
97
106
  enum <%- toPascalCase(attribute.key) %> {
98
107
  <% for (const [index, element] of Object.entries(attribute.elements)) { -%>
99
- <%- strict ? toCamelCase(element) : element %><% if (index < attribute.elements.length - 1) { %>,<% } %>
108
+ <%- strict ? toCamelCase(element) : element %><% if (index < attribute.elements.length - 1) { -%>,<% } %>
100
109
  <% } -%>
101
110
  }
102
111
 
103
112
  <% } -%>
104
113
  <% } -%>
105
114
  class <%= toPascalCase(collection.name) %> {
106
- <% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
115
+ <% for (const [index, attribute] of Object.entries(__attrs)) { -%>
107
116
  <%- getType(attribute, collections) %> <%= strict ? toCamelCase(attribute.key) : attribute.key %>;
108
117
  <% } -%>
109
118
 
110
119
  <%= toPascalCase(collection.name) %>({
111
- <% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
112
- <% if (attribute.required) { %>required <% } %>this.<%= strict ? toCamelCase(attribute.key) : attribute.key %><% if (index < collection.attributes.length - 1) { %>,<% } %>
120
+ <% for (const [index, attribute] of Object.entries(__attrs)) { -%>
121
+ <% if (attribute.required) { %>required <% } %>this.<%= strict ? toCamelCase(attribute.key) : attribute.key %><% if (index < __attrs.length - 1) { -%>,<% } %>
113
122
  <% } -%>
114
123
  });
115
124
 
116
125
  factory <%= toPascalCase(collection.name) %>.fromMap(Map<String, dynamic> map) {
117
126
  return <%= toPascalCase(collection.name) %>(
118
- <% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
119
- <%= strict ? toCamelCase(attribute.key) : attribute.key %>: <% if (attribute.type === 'string' || attribute.type === 'email' || attribute.type === 'datetime') { -%>
120
- <% if (attribute.format === 'enum') { -%>
127
+ <% for (const [index, attribute] of Object.entries(__attrs)) { -%>
128
+ <%= strict ? toCamelCase(attribute.key) : attribute.key %>: <% if (attribute.type === '${AttributeType.STRING}' || attribute.type === '${AttributeType.EMAIL}' || attribute.type === '${AttributeType.DATETIME}') { -%>
129
+ <% if (attribute.format === '${AttributeType.ENUM}') { -%>
121
130
  <% if (attribute.array) { -%>
122
- (map['<%= attribute.key %>'] as List<dynamic>?)?.map((e) => <%- toPascalCase(attribute.key) %>.values.firstWhere((element) => element.name == e)).toList()<% if (!attribute.required) { %> ?? []<% } -%>
123
- <% } else { -%>
131
+ (map['<%= attribute.key %>'] as List<dynamic>?)?.map((e) => <%- toPascalCase(attribute.key) %>.values.firstWhere((element) => element.name == e)).toList()<% } else { -%>
124
132
  <% if (!attribute.required) { -%>
125
133
  map['<%= attribute.key %>'] != null ? <%- toPascalCase(attribute.key) %>.values.where((e) => e.name == map['<%= attribute.key %>']).firstOrNull : null<% } else { -%>
126
134
  <%- toPascalCase(attribute.key) %>.values.firstWhere((e) => e.name == map['<%= attribute.key %>'])<% } -%>
127
135
  <% } -%>
128
136
  <% } else { -%>
129
137
  <% if (attribute.array) { -%>
130
- List<String>.from(map['<%= attribute.key %>'] ?? [])<% if (!attribute.required) { %> ?? []<% } -%>
131
- <% } else { -%>
132
- map['<%= attribute.key %>']<% if (!attribute.required) { %>?<% } %>.toString()<% if (!attribute.required) { %> ?? null<% } -%>
138
+ List<String>.from(map['<%= attribute.key %>'] ?? [])<% } else { -%>
139
+ map['<%= attribute.key %>']<% if (!attribute.required) { %>?<% } %>.toString()<% } -%>
133
140
  <% } -%>
134
- <% } -%>
135
- <% } else if (attribute.type === 'integer') { -%>
141
+ <% } else if (attribute.type === '${AttributeType.INTEGER}') { -%>
136
142
  <% if (attribute.array) { -%>
137
- List<int>.from(map['<%= attribute.key %>'] ?? [])<% if (!attribute.required) { %> ?? []<% } -%>
138
- <% } else { -%>
139
- map['<%= attribute.key %>']<% if (!attribute.required) { %> ?? null<% } -%>
140
- <% } -%>
141
- <% } else if (attribute.type === 'float') { -%>
143
+ List<int>.from(map['<%= attribute.key %>'] ?? [])<% } else { -%>
144
+ map['<%= attribute.key %>']<% } -%>
145
+ <% } else if (attribute.type === '${AttributeType.FLOAT}') { -%>
142
146
  <% if (attribute.array) { -%>
143
- List<double>.from(map['<%= attribute.key %>'] ?? [])<% if (!attribute.required) { %> ?? []<% } -%>
144
- <% } else { -%>
145
- map['<%= attribute.key %>']<% if (!attribute.required) { %> ?? null<% } -%>
146
- <% } -%>
147
- <% } else if (attribute.type === 'boolean') { -%>
147
+ List<double>.from(map['<%= attribute.key %>'] ?? [])<% } else { -%>
148
+ map['<%= attribute.key %>']<% } -%>
149
+ <% } else if (attribute.type === '${AttributeType.BOOLEAN}') { -%>
148
150
  <% if (attribute.array) { -%>
149
- List<bool>.from(map['<%= attribute.key %>'] ?? [])<% if (!attribute.required) { %> ?? []<% } -%>
150
- <% } else { -%>
151
- map['<%= attribute.key %>']<% if (!attribute.required) { %> ?? null<% } -%>
152
- <% } -%>
153
- <% } else if (attribute.type === 'relationship') { -%>
151
+ List<bool>.from(map['<%= attribute.key %>'] ?? [])<% } else { -%>
152
+ map['<%= attribute.key %>']<% } -%>
153
+ <% } else if (attribute.type === '${AttributeType.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(collections.find(c => c.$id === attribute.relatedCollection).name) %>.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()
156
156
  <% } else { -%>
157
157
  <% if (!attribute.required) { -%>
158
158
  map['<%= attribute.key %>'] != null ? <%- toPascalCase(collections.find(c => c.$id === attribute.relatedCollection).name) %>.fromMap(map['<%= attribute.key %>']) : null<% } else { -%>
159
159
  <%- toPascalCase(collections.find(c => c.$id === attribute.relatedCollection).name) %>.fromMap(map['<%= attribute.key %>'])<% } -%>
160
160
  <% } -%>
161
- <% } -%><% if (index < collection.attributes.length - 1) { %>,<% } %>
161
+ <% } -%><% if (index < __attrs.length - 1) { -%>,<% } %>
162
162
  <% } -%>
163
163
  );
164
164
  }
165
165
 
166
166
  Map<String, dynamic> toMap() {
167
167
  return {
168
- <% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
169
- "<%= attribute.key %>": <% if (attribute.type === 'relationship') { -%>
168
+ <% for (const [index, attribute] of Object.entries(__attrs)) { -%>
169
+ '<%= attribute.key %>': <% if (attribute.type === '${AttributeType.RELATIONSHIP}') { -%>
170
170
  <% if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') { -%>
171
- <%= strict ? toCamelCase(attribute.key) : attribute.key %><% if (!attribute.required) { %>?<% } %>.map((e) => e.toMap()).toList()<% if (!attribute.required) { %> ?? []<% } -%>
171
+ <%= strict ? toCamelCase(attribute.key) : attribute.key %><% if (!attribute.required) { %>?<% } %>.map((e) => e.toMap()).toList()
172
172
  <% } else { -%>
173
- <%= strict ? toCamelCase(attribute.key) : attribute.key %><% if (!attribute.required) { %>?<% } %>.toMap()<% if (!attribute.required) { %> ?? {}<% } -%>
174
- <% } -%>
175
- <% } else if (attribute.format === 'enum') { -%>
173
+ <%= strict ? toCamelCase(attribute.key) : attribute.key %><% if (!attribute.required) { %>?<% } %>.toMap()<% } -%>
174
+ <% } else if (attribute.format === '${AttributeType.ENUM}') { -%>
176
175
  <% if (attribute.array) { -%>
177
- <%= strict ? toCamelCase(attribute.key) : attribute.key %><% if (!attribute.required) { %>?<% } %>.map((e) => e.name).toList()<% if (!attribute.required) { %> ?? []<% } -%>
178
- <% } else { -%>
179
- <%= strict ? toCamelCase(attribute.key) : attribute.key %><% if (!attribute.required) { %>?<% } %>.name<% if (!attribute.required) { %> ?? null<% } -%>
180
- <% } -%>
176
+ <%= strict ? toCamelCase(attribute.key) : attribute.key %><% if (!attribute.required) { %>?<% } %>.map((e) => e.name).toList()<% } else { -%>
177
+ <%= strict ? toCamelCase(attribute.key) : attribute.key %><% if (!attribute.required) { %>?<% } %>.name<% } -%>
181
178
  <% } else { -%>
182
179
  <%= strict ? toCamelCase(attribute.key) : attribute.key -%>
183
- <% } -%><% if (index < collection.attributes.length - 1) { %>,<% } %>
180
+ <% } -%><% if (index < __attrs.length - 1) { -%>,<% } %>
184
181
  <% } -%>
185
182
  };
186
183
  }
@@ -69,7 +69,7 @@ class TypeScript extends LanguageMeta {
69
69
  }
70
70
 
71
71
  getTemplate() {
72
- return `import { type Models } from '${this._getAppwriteDependency()}';
72
+ return `import type { Models } from '${this._getAppwriteDependency()}';
73
73
 
74
74
  // This file is auto-generated by the Appwrite CLI.
75
75
  // You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
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": "10.0.0",
5
+ "version": "10.0.1",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "index.js",
8
8
  "bin": {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json",
3
- "version": "10.0.0",
3
+ "version": "10.0.1",
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/10.0.0/appwrite-cli-win-x64.exe",
9
+ "url": "https://github.com/appwrite/sdk-for-cli/releases/download/10.0.1/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/10.0.0/appwrite-cli-win-arm64.exe",
18
+ "url": "https://github.com/appwrite/sdk-for-cli/releases/download/10.0.1/appwrite-cli-win-arm64.exe",
19
19
  "bin": [
20
20
  [
21
21
  "appwrite-cli-win-arm64.exe",