appwrite-cli 9.1.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.
@@ -1185,7 +1185,7 @@ const tablesDBUpdateIpColumn = async ({databaseId,tableId,key,required,xdefault,
1185
1185
  * @property {string} tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
1186
1186
  * @property {string} key Column Key.
1187
1187
  * @property {boolean} required Is column required?
1188
- * @property {string} xdefault Default value for column when not provided, as JSON string. Cannot be set when column is required.
1188
+ * @property {any[]} xdefault Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required.
1189
1189
  * @property {boolean} overrideForCli
1190
1190
  * @property {boolean} parseOutput
1191
1191
  * @property {libClient | undefined} sdk
@@ -1205,6 +1205,7 @@ const tablesDBCreateLineColumn = async ({databaseId,tableId,key,required,xdefaul
1205
1205
  if (typeof required !== 'undefined') {
1206
1206
  payload['required'] = required;
1207
1207
  }
1208
+ xdefault = xdefault === true ? [] : xdefault;
1208
1209
  if (typeof xdefault !== 'undefined') {
1209
1210
  payload['default'] = xdefault;
1210
1211
  }
@@ -1228,7 +1229,7 @@ const tablesDBCreateLineColumn = async ({databaseId,tableId,key,required,xdefaul
1228
1229
  * @property {string} tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
1229
1230
  * @property {string} key Column Key.
1230
1231
  * @property {boolean} required Is column required?
1231
- * @property {string} xdefault Default value for column when not provided, as JSON string. Cannot be set when column is required.
1232
+ * @property {any[]} xdefault Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required.
1232
1233
  * @property {string} newKey New Column Key.
1233
1234
  * @property {boolean} overrideForCli
1234
1235
  * @property {boolean} parseOutput
@@ -1246,6 +1247,7 @@ const tablesDBUpdateLineColumn = async ({databaseId,tableId,key,required,xdefaul
1246
1247
  if (typeof required !== 'undefined') {
1247
1248
  payload['required'] = required;
1248
1249
  }
1250
+ xdefault = xdefault === true ? [] : xdefault;
1249
1251
  if (typeof xdefault !== 'undefined') {
1250
1252
  payload['default'] = xdefault;
1251
1253
  }
@@ -1272,7 +1274,7 @@ const tablesDBUpdateLineColumn = async ({databaseId,tableId,key,required,xdefaul
1272
1274
  * @property {string} tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
1273
1275
  * @property {string} key Column Key.
1274
1276
  * @property {boolean} required Is column required?
1275
- * @property {string} xdefault Default value for column when not provided, as JSON string. Cannot be set when column is required.
1277
+ * @property {any[]} xdefault Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required.
1276
1278
  * @property {boolean} overrideForCli
1277
1279
  * @property {boolean} parseOutput
1278
1280
  * @property {libClient | undefined} sdk
@@ -1292,6 +1294,7 @@ const tablesDBCreatePointColumn = async ({databaseId,tableId,key,required,xdefau
1292
1294
  if (typeof required !== 'undefined') {
1293
1295
  payload['required'] = required;
1294
1296
  }
1297
+ xdefault = xdefault === true ? [] : xdefault;
1295
1298
  if (typeof xdefault !== 'undefined') {
1296
1299
  payload['default'] = xdefault;
1297
1300
  }
@@ -1315,7 +1318,7 @@ const tablesDBCreatePointColumn = async ({databaseId,tableId,key,required,xdefau
1315
1318
  * @property {string} tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
1316
1319
  * @property {string} key Column Key.
1317
1320
  * @property {boolean} required Is column required?
1318
- * @property {string} xdefault Default value for column when not provided, as JSON string. Cannot be set when column is required.
1321
+ * @property {any[]} xdefault Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required.
1319
1322
  * @property {string} newKey New Column Key.
1320
1323
  * @property {boolean} overrideForCli
1321
1324
  * @property {boolean} parseOutput
@@ -1333,6 +1336,7 @@ const tablesDBUpdatePointColumn = async ({databaseId,tableId,key,required,xdefau
1333
1336
  if (typeof required !== 'undefined') {
1334
1337
  payload['required'] = required;
1335
1338
  }
1339
+ xdefault = xdefault === true ? [] : xdefault;
1336
1340
  if (typeof xdefault !== 'undefined') {
1337
1341
  payload['default'] = xdefault;
1338
1342
  }
@@ -1359,7 +1363,7 @@ const tablesDBUpdatePointColumn = async ({databaseId,tableId,key,required,xdefau
1359
1363
  * @property {string} tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
1360
1364
  * @property {string} key Column Key.
1361
1365
  * @property {boolean} required Is column required?
1362
- * @property {string} xdefault Default value for column when not provided, as JSON string. Cannot be set when column is required.
1366
+ * @property {any[]} xdefault Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required.
1363
1367
  * @property {boolean} overrideForCli
1364
1368
  * @property {boolean} parseOutput
1365
1369
  * @property {libClient | undefined} sdk
@@ -1379,6 +1383,7 @@ const tablesDBCreatePolygonColumn = async ({databaseId,tableId,key,required,xdef
1379
1383
  if (typeof required !== 'undefined') {
1380
1384
  payload['required'] = required;
1381
1385
  }
1386
+ xdefault = xdefault === true ? [] : xdefault;
1382
1387
  if (typeof xdefault !== 'undefined') {
1383
1388
  payload['default'] = xdefault;
1384
1389
  }
@@ -1402,7 +1407,7 @@ const tablesDBCreatePolygonColumn = async ({databaseId,tableId,key,required,xdef
1402
1407
  * @property {string} tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
1403
1408
  * @property {string} key Column Key.
1404
1409
  * @property {boolean} required Is column required?
1405
- * @property {string} xdefault Default value for column when not provided, as JSON string. Cannot be set when column is required.
1410
+ * @property {any[]} xdefault Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required.
1406
1411
  * @property {string} newKey New Column Key.
1407
1412
  * @property {boolean} overrideForCli
1408
1413
  * @property {boolean} parseOutput
@@ -1420,6 +1425,7 @@ const tablesDBUpdatePolygonColumn = async ({databaseId,tableId,key,required,xdef
1420
1425
  if (typeof required !== 'undefined') {
1421
1426
  payload['required'] = required;
1422
1427
  }
1428
+ xdefault = xdefault === true ? [] : xdefault;
1423
1429
  if (typeof xdefault !== 'undefined') {
1424
1430
  payload['default'] = xdefault;
1425
1431
  }
@@ -2075,7 +2081,7 @@ const tablesDBCreateRow = async ({databaseId,tableId,rowId,data,permissions,pars
2075
2081
  * @typedef {Object} TablesDBCreateRowsRequestParams
2076
2082
  * @property {string} databaseId Database ID.
2077
2083
  * @property {string} tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows.
2078
- * @property {object[]} rows Array of documents data as JSON objects.
2084
+ * @property {object[]} rows Array of rows data as JSON objects.
2079
2085
  * @property {boolean} overrideForCli
2080
2086
  * @property {boolean} parseOutput
2081
2087
  * @property {libClient | undefined} sdk
@@ -2829,64 +2835,64 @@ tablesDB
2829
2835
 
2830
2836
  tablesDB
2831
2837
  .command(`create-line-column`)
2832
- .description(`Create a geometric line attribute.`)
2838
+ .description(`Create a geometric line column.`)
2833
2839
  .requiredOption(`--database-id <database-id>`, `Database ID.`)
2834
2840
  .requiredOption(`--table-id <table-id>`, `Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).`)
2835
2841
  .requiredOption(`--key <key>`, `Column Key.`)
2836
2842
  .requiredOption(`--required [value]`, `Is column required?`, (value) => value === undefined ? true : parseBool(value))
2837
- .option(`--xdefault <xdefault>`, `Default value for column when not provided, as JSON string. Cannot be set when column is required.`)
2843
+ .option(`--xdefault <xdefault>`, `Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required.`)
2838
2844
  .action(actionRunner(tablesDBCreateLineColumn))
2839
2845
 
2840
2846
  tablesDB
2841
2847
  .command(`update-line-column`)
2842
- .description(`Update a line column. Changing the 'default' value will not update already existing documents.`)
2848
+ .description(`Update a line column. Changing the 'default' value will not update already existing rows.`)
2843
2849
  .requiredOption(`--database-id <database-id>`, `Database ID.`)
2844
2850
  .requiredOption(`--table-id <table-id>`, `Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).`)
2845
2851
  .requiredOption(`--key <key>`, `Column Key.`)
2846
2852
  .requiredOption(`--required [value]`, `Is column required?`, (value) => value === undefined ? true : parseBool(value))
2847
- .option(`--xdefault <xdefault>`, `Default value for column when not provided, as JSON string. Cannot be set when column is required.`)
2853
+ .option(`--xdefault <xdefault>`, `Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required.`)
2848
2854
  .option(`--new-key <new-key>`, `New Column Key.`)
2849
2855
  .action(actionRunner(tablesDBUpdateLineColumn))
2850
2856
 
2851
2857
  tablesDB
2852
2858
  .command(`create-point-column`)
2853
- .description(`Create a geometric point attribute.`)
2859
+ .description(`Create a geometric point column.`)
2854
2860
  .requiredOption(`--database-id <database-id>`, `Database ID.`)
2855
2861
  .requiredOption(`--table-id <table-id>`, `Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).`)
2856
2862
  .requiredOption(`--key <key>`, `Column Key.`)
2857
2863
  .requiredOption(`--required [value]`, `Is column required?`, (value) => value === undefined ? true : parseBool(value))
2858
- .option(`--xdefault <xdefault>`, `Default value for column when not provided, as JSON string. Cannot be set when column is required.`)
2864
+ .option(`--xdefault <xdefault>`, `Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required.`)
2859
2865
  .action(actionRunner(tablesDBCreatePointColumn))
2860
2866
 
2861
2867
  tablesDB
2862
2868
  .command(`update-point-column`)
2863
- .description(`Update a point column. Changing the 'default' value will not update already existing documents.`)
2869
+ .description(`Update a point column. Changing the 'default' value will not update already existing rows.`)
2864
2870
  .requiredOption(`--database-id <database-id>`, `Database ID.`)
2865
2871
  .requiredOption(`--table-id <table-id>`, `Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).`)
2866
2872
  .requiredOption(`--key <key>`, `Column Key.`)
2867
2873
  .requiredOption(`--required [value]`, `Is column required?`, (value) => value === undefined ? true : parseBool(value))
2868
- .option(`--xdefault <xdefault>`, `Default value for column when not provided, as JSON string. Cannot be set when column is required.`)
2874
+ .option(`--xdefault <xdefault>`, `Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required.`)
2869
2875
  .option(`--new-key <new-key>`, `New Column Key.`)
2870
2876
  .action(actionRunner(tablesDBUpdatePointColumn))
2871
2877
 
2872
2878
  tablesDB
2873
2879
  .command(`create-polygon-column`)
2874
- .description(`Create a geometric polygon attribute.`)
2880
+ .description(`Create a geometric polygon column.`)
2875
2881
  .requiredOption(`--database-id <database-id>`, `Database ID.`)
2876
2882
  .requiredOption(`--table-id <table-id>`, `Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).`)
2877
2883
  .requiredOption(`--key <key>`, `Column Key.`)
2878
2884
  .requiredOption(`--required [value]`, `Is column required?`, (value) => value === undefined ? true : parseBool(value))
2879
- .option(`--xdefault <xdefault>`, `Default value for column when not provided, as JSON string. Cannot be set when column is required.`)
2885
+ .option(`--xdefault <xdefault>`, `Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required.`)
2880
2886
  .action(actionRunner(tablesDBCreatePolygonColumn))
2881
2887
 
2882
2888
  tablesDB
2883
2889
  .command(`update-polygon-column`)
2884
- .description(`Update a polygon column. Changing the 'default' value will not update already existing documents.`)
2890
+ .description(`Update a polygon column. Changing the 'default' value will not update already existing rows.`)
2885
2891
  .requiredOption(`--database-id <database-id>`, `Database ID.`)
2886
2892
  .requiredOption(`--table-id <table-id>`, `Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).`)
2887
2893
  .requiredOption(`--key <key>`, `Column Key.`)
2888
2894
  .requiredOption(`--required [value]`, `Is column required?`, (value) => value === undefined ? true : parseBool(value))
2889
- .option(`--xdefault <xdefault>`, `Default value for column when not provided, as JSON string. Cannot be set when column is required.`)
2895
+ .option(`--xdefault <xdefault>`, `Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required.`)
2890
2896
  .option(`--new-key <new-key>`, `New Column Key.`)
2891
2897
  .action(actionRunner(tablesDBUpdatePolygonColumn))
2892
2898
 
@@ -3047,7 +3053,7 @@ tablesDB
3047
3053
  .description(`Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console.`)
3048
3054
  .requiredOption(`--database-id <database-id>`, `Database ID.`)
3049
3055
  .requiredOption(`--table-id <table-id>`, `Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows.`)
3050
- .requiredOption(`--rows [rows...]`, `Array of documents data as JSON objects.`)
3056
+ .requiredOption(`--rows [rows...]`, `Array of rows data as JSON objects.`)
3051
3057
  .action(actionRunner(tablesDBCreateRows))
3052
3058
 
3053
3059
  tablesDB
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 = '9.1.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
 
@@ -205,7 +205,8 @@ const commandDescriptions = {
205
205
  "account": `The account command allows you to authenticate and manage a user account.`,
206
206
  "graphql": `The graphql command allows you to query and mutate any resource type on your Appwrite server.`,
207
207
  "avatars": `The avatars command aims to help you complete everyday tasks related to your app image, icons, and avatars.`,
208
- "databases": `The databases command allows you to create structured collections of documents and query and filter lists of documents.`,
208
+ "databases": `(Legacy) The databases command allows you to create structured collections of documents and query and filter lists of documents.`,
209
+ 'tables-db': `The tables-db command allows you to create structured tables of columns and query and filter lists of rows.`,
209
210
  "init": `The init command provides a convenient wrapper for creating and initializing projects, functions, collections, buckets, teams, and messaging-topics in Appwrite.`,
210
211
  "push": `The push command provides a convenient wrapper for pushing your functions, collections, buckets, teams, and messaging-topics.`,
211
212
  "run": `The run command allows you to run the project locally to allow easy development and quick debugging.`,
@@ -218,6 +219,8 @@ const commandDescriptions = {
218
219
  "teams": `The teams command allows you to group users of your project to enable them to share read and write access to your project resources.`,
219
220
  "update": `The update command allows you to update the Appwrite CLI to the latest version.`,
220
221
  "users": `The users command allows you to manage your project users.`,
222
+ "projects": `The projects command allows you to manage your projects, add platforms, manage API keys, Dev Keys etc.`,
223
+ "project": `The project command allows you to manage project related resources like usage, variables, etc.`,
221
224
  "client": `The client command allows you to configure your CLI`,
222
225
  "login": `The login command allows you to authenticate and manage a user account.`,
223
226
  "logout": `The logout command allows you to log out of your Appwrite account.`,
@@ -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(' ')}\`.
@@ -90,7 +90,9 @@ export enum <%- toPascalCase(attribute.key) %> {
90
90
  <% for (const [index, collection] of Object.entries(collections)) { -%>
91
91
  export type <%- toPascalCase(collection.name) %> = Models.Row & {
92
92
  <% for (const attribute of collection.attributes) { -%>
93
- <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute, collections) %>;
93
+ <% const propertyName = strict ? toCamelCase(attribute.key) : attribute.key; -%>
94
+ <% const isValidIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(propertyName); -%>
95
+ <% if (isValidIdentifier) { %><%- propertyName %><% } else { %>"<%- propertyName %>"<% } %>: <%- getType(attribute, collections) %>;
94
96
  <% } -%>
95
97
  }<% if (index < collections.length - 1) { %>
96
98
  <% } %>
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": "9.1.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": "9.1.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/9.1.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/9.1.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",
@@ -1,2 +0,0 @@
1
- appwrite avatars get-browser \
2
- --code aa
@@ -1,2 +0,0 @@
1
- appwrite avatars get-credit-card \
2
- --code amex
@@ -1,2 +0,0 @@
1
- appwrite avatars get-favicon \
2
- --url https://example.com
@@ -1,2 +0,0 @@
1
- appwrite avatars get-flag \
2
- --code af
@@ -1,2 +0,0 @@
1
- appwrite avatars get-image \
2
- --url https://example.com
@@ -1 +0,0 @@
1
- appwrite avatars get-initials
@@ -1,2 +0,0 @@
1
- appwrite avatars get-qr \
2
- --text <TEXT>