appwrite-cli 13.2.1 → 13.3.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +2 -2
  3. package/dist/bundle-win-arm64.mjs +311 -81
  4. package/dist/cli.cjs +311 -81
  5. package/dist/index.js +119 -18
  6. package/dist/lib/commands/config-validations.d.ts +1 -1
  7. package/dist/lib/commands/config.d.ts +24 -0
  8. package/dist/lib/commands/config.d.ts.map +1 -1
  9. package/dist/lib/commands/generate.d.ts.map +1 -1
  10. package/dist/lib/commands/generators/typescript/databases.d.ts.map +1 -1
  11. package/dist/lib/commands/generic.d.ts +2 -4
  12. package/dist/lib/commands/generic.d.ts.map +1 -1
  13. package/dist/lib/commands/utils/attributes.d.ts.map +1 -1
  14. package/dist/lib/constants.d.ts +1 -1
  15. package/dist/lib/questions.d.ts +1 -0
  16. package/dist/lib/questions.d.ts.map +1 -1
  17. package/dist/lib/shared/typescript-type-utils.d.ts +5 -0
  18. package/dist/lib/shared/typescript-type-utils.d.ts.map +1 -1
  19. package/dist/lib/type-generation/attribute.d.ts +4 -0
  20. package/dist/lib/type-generation/attribute.d.ts.map +1 -1
  21. package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -1
  22. package/dist/lib/type-generation/languages/dart.d.ts.map +1 -1
  23. package/dist/lib/type-generation/languages/java.d.ts.map +1 -1
  24. package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -1
  25. package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -1
  26. package/dist/lib/type-generation/languages/php.d.ts.map +1 -1
  27. package/dist/lib/type-generation/languages/swift.d.ts.map +1 -1
  28. package/install.ps1 +2 -2
  29. package/install.sh +1 -1
  30. package/lib/commands/config-validations.ts +3 -3
  31. package/lib/commands/config.ts +10 -2
  32. package/lib/commands/generate.ts +4 -2
  33. package/lib/commands/generators/typescript/databases.ts +9 -5
  34. package/lib/commands/generators/typescript/templates/databases.ts.hbs +3 -3
  35. package/lib/commands/generators/typescript/templates/index.ts.hbs +2 -2
  36. package/lib/commands/generic.ts +211 -76
  37. package/lib/commands/push.ts +1 -1
  38. package/lib/commands/utils/attributes.ts +70 -0
  39. package/lib/config.ts +4 -4
  40. package/lib/constants.ts +1 -1
  41. package/lib/questions.ts +3 -1
  42. package/lib/shared/typescript-type-utils.ts +30 -0
  43. package/lib/type-generation/attribute.ts +4 -0
  44. package/lib/type-generation/languages/csharp.ts +6 -2
  45. package/lib/type-generation/languages/dart.ts +5 -1
  46. package/lib/type-generation/languages/java.ts +4 -0
  47. package/lib/type-generation/languages/javascript.ts +4 -0
  48. package/lib/type-generation/languages/kotlin.ts +4 -0
  49. package/lib/type-generation/languages/php.ts +4 -0
  50. package/lib/type-generation/languages/swift.ts +8 -4
  51. package/package.json +1 -1
  52. package/scoop/appwrite.config.json +3 -3
package/lib/questions.ts CHANGED
@@ -28,6 +28,7 @@ interface Choice {
28
28
  value: any;
29
29
  disabled?: boolean | string;
30
30
  current?: boolean;
31
+ short?: string;
31
32
  }
32
33
 
33
34
  interface Question {
@@ -752,7 +753,7 @@ export const questionsLogin: Question[] = [
752
753
  when: (answers: Answers) => answers.method !== "select",
753
754
  },
754
755
  {
755
- type: "search-list",
756
+ type: "list",
756
757
  name: "accountId",
757
758
  message: "Select an account to use",
758
759
  choices() {
@@ -772,6 +773,7 @@ export const questionsLogin: Question[] = [
772
773
  data.push({
773
774
  current: current === session.id,
774
775
  value: session.id,
776
+ short: `${session.email} (${session.endpoint})`,
775
777
  name: `${session.email.padEnd(longestEmail)} ${current === session.id ? chalk.green.bold("current") : " ".repeat(6)} ${session.endpoint}`,
776
778
  });
777
779
  }
@@ -37,6 +37,10 @@ export function getTypeScriptType(
37
37
 
38
38
  switch (attribute.type) {
39
39
  case "string":
40
+ case "text":
41
+ case "varchar":
42
+ case "mediumtext":
43
+ case "longtext":
40
44
  case "datetime":
41
45
  type = "string";
42
46
  if (attribute.format === "enum") {
@@ -145,6 +149,32 @@ export function getAppwriteDependency(): string {
145
149
  return "appwrite";
146
150
  }
147
151
 
152
+ /**
153
+ * Detects whether the user's project uses native ESM.
154
+ * Returns ".js" for ESM projects (package.json "type": "module" or Deno), "" for non-ESM projects.
155
+ */
156
+ export function detectImportExtension(cwd: string = process.cwd()): string {
157
+ try {
158
+ const pkgPath = path.resolve(cwd, "package.json");
159
+ if (fs.existsSync(pkgPath)) {
160
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
161
+ if (pkg.type === "module") {
162
+ return ".js";
163
+ }
164
+ }
165
+
166
+ if (
167
+ fs.existsSync(path.resolve(cwd, "deno.json")) ||
168
+ fs.existsSync(path.resolve(cwd, "deno.jsonc"))
169
+ ) {
170
+ return ".ts";
171
+ }
172
+ } catch {
173
+ // Fall through to default
174
+ }
175
+ return "";
176
+ }
177
+
148
178
  /**
149
179
  * Checks if the Appwrite dependency supports server-side methods.
150
180
  *
@@ -1,5 +1,9 @@
1
1
  export const AttributeType = {
2
2
  STRING: "string",
3
+ TEXT: "text",
4
+ VARCHAR: "varchar",
5
+ MEDIUMTEXT: "mediumtext",
6
+ LONGTEXT: "longtext",
3
7
  INTEGER: "integer",
4
8
  FLOAT: "double",
5
9
  BOOLEAN: "boolean",
@@ -10,6 +10,10 @@ export class CSharp extends LanguageMeta {
10
10
  let type = "";
11
11
  switch (attribute.type) {
12
12
  case AttributeType.STRING:
13
+ case AttributeType.TEXT:
14
+ case AttributeType.VARCHAR:
15
+ case AttributeType.MEDIUMTEXT:
16
+ case AttributeType.LONGTEXT:
13
17
  case AttributeType.DATETIME:
14
18
  type = "string";
15
19
  if (attribute.format === AttributeType.ENUM) {
@@ -126,7 +130,7 @@ public class <%= toPascalCase(collection.name) %>
126
130
  }
127
131
  // ARRAY TYPES
128
132
  } else if (attribute.array) {
129
- if (attribute.type === 'string' || attribute.type === 'datetime' || attribute.type === 'email') {
133
+ if (['string', 'text', 'varchar', 'mediumtext', 'longtext', 'datetime', 'email'].includes(attribute.type)) {
130
134
  -%>((IEnumerable<object>)map["<%- attribute.key %>"]).Select(x => x?.ToString())<%- attribute.required ? '.Where(x => x != null)' : '' %>.ToList()!<%
131
135
  } else if (attribute.type === 'integer') {
132
136
  -%>((IEnumerable<object>)map["<%- attribute.key %>"]).Select(x => <%- !attribute.required ? 'x == null ? (long?)null : ' : '' %>Convert.ToInt64(x)).ToList()<%
@@ -142,7 +146,7 @@ public class <%= toPascalCase(collection.name) %>
142
146
  -%><%- !attribute.required ? 'map["' + attribute.key + '"] == null ? null : ' : '' %>Convert.ToDouble(map["<%- attribute.key %>"])<%
143
147
  } else if (attribute.type === 'boolean') {
144
148
  -%>(<%- getType(attribute, collections, collection.name) %>)map["<%- attribute.key %>"]<%
145
- } else if (attribute.type === 'string' || attribute.type === 'datetime' || attribute.type === 'email') {
149
+ } else if (['string', 'text', 'varchar', 'mediumtext', 'longtext', 'datetime', 'email'].includes(attribute.type)) {
146
150
  -%>map["<%- attribute.key %>"]<%- !attribute.required ? '?' : '' %>.ToString()<%- attribute.required ? '!' : ''%><%
147
151
  } else {
148
152
  -%>default<%
@@ -72,6 +72,10 @@ export class Dart extends LanguageMeta {
72
72
  let type = "";
73
73
  switch (attribute.type) {
74
74
  case AttributeType.STRING:
75
+ case AttributeType.TEXT:
76
+ case AttributeType.VARCHAR:
77
+ case AttributeType.MEDIUMTEXT:
78
+ case AttributeType.LONGTEXT:
75
79
  case AttributeType.DATETIME:
76
80
  type = "String";
77
81
  if (attribute.format === AttributeType.ENUM) {
@@ -193,7 +197,7 @@ class <%= toPascalCase(collection.name) %> {
193
197
  factory <%= toPascalCase(collection.name) %>.fromMap(Map<String, dynamic> map) {
194
198
  return <%= toPascalCase(collection.name) %>(<% if (__attrs.length > 0) { %>
195
199
  <% for (const [index, attribute] of Object.entries(__attrs)) { -%>
196
- <%= strict ? toCamelCase(attribute.key) : attribute.key %>: <% if (attribute.type === '${AttributeType.STRING}' || attribute.type === '${AttributeType.EMAIL}' || attribute.type === '${AttributeType.DATETIME}') { -%>
200
+ <%= strict ? toCamelCase(attribute.key) : attribute.key %>: <% if (['${AttributeType.STRING}', '${AttributeType.TEXT}', '${AttributeType.VARCHAR}', '${AttributeType.MEDIUMTEXT}', '${AttributeType.LONGTEXT}', '${AttributeType.EMAIL}', '${AttributeType.DATETIME}'].includes(attribute.type)) { -%>
197
201
  <% if (attribute.format === '${AttributeType.ENUM}') { -%>
198
202
  <% if (attribute.array) { -%>
199
203
  (map['<%= attribute.key %>'] as List<dynamic>?)?.map((e) => <%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %>.values.firstWhere((element) => element.value == e)).toList()<% } else { -%>
@@ -10,6 +10,10 @@ export class Java extends LanguageMeta {
10
10
  let type = "";
11
11
  switch (attribute.type) {
12
12
  case AttributeType.STRING:
13
+ case AttributeType.TEXT:
14
+ case AttributeType.VARCHAR:
15
+ case AttributeType.MEDIUMTEXT:
16
+ case AttributeType.LONGTEXT:
13
17
  case AttributeType.DATETIME:
14
18
  type = "String";
15
19
  if (attribute.format === AttributeType.ENUM) {
@@ -8,6 +8,10 @@ export class JavaScript extends LanguageMeta {
8
8
  let type = "";
9
9
  switch (attribute.type) {
10
10
  case AttributeType.STRING:
11
+ case AttributeType.TEXT:
12
+ case AttributeType.VARCHAR:
13
+ case AttributeType.MEDIUMTEXT:
14
+ case AttributeType.LONGTEXT:
11
15
  case AttributeType.DATETIME:
12
16
  type = "string";
13
17
  if (attribute.format === AttributeType.ENUM) {
@@ -10,6 +10,10 @@ export class Kotlin extends LanguageMeta {
10
10
  let type = "";
11
11
  switch (attribute.type) {
12
12
  case AttributeType.STRING:
13
+ case AttributeType.TEXT:
14
+ case AttributeType.VARCHAR:
15
+ case AttributeType.MEDIUMTEXT:
16
+ case AttributeType.LONGTEXT:
13
17
  case AttributeType.DATETIME:
14
18
  type = "String";
15
19
  if (attribute.format === AttributeType.ENUM) {
@@ -13,6 +13,10 @@ export class PHP extends LanguageMeta {
13
13
  let type = "";
14
14
  switch (attribute.type) {
15
15
  case AttributeType.STRING:
16
+ case AttributeType.TEXT:
17
+ case AttributeType.VARCHAR:
18
+ case AttributeType.MEDIUMTEXT:
19
+ case AttributeType.LONGTEXT:
16
20
  case AttributeType.DATETIME:
17
21
  type = "string";
18
22
  if (attribute.format === AttributeType.ENUM) {
@@ -10,6 +10,10 @@ export class Swift extends LanguageMeta {
10
10
  let type = "";
11
11
  switch (attribute.type) {
12
12
  case AttributeType.STRING:
13
+ case AttributeType.TEXT:
14
+ case AttributeType.VARCHAR:
15
+ case AttributeType.MEDIUMTEXT:
16
+ case AttributeType.LONGTEXT:
13
17
  case AttributeType.DATETIME:
14
18
  type = "String";
15
19
  if (attribute.format === AttributeType.ENUM) {
@@ -129,7 +133,7 @@ public class <%- toPascalCase(collection.name) %>: Codable {
129
133
  <% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
130
134
  <% if (attribute.type === 'relationship') { -%>
131
135
  "<%- attribute.key %>": <%- strict ? toCamelCase(attribute.key) : attribute.key %> as Any<% if (index < collection.attributes.length - 1) { %>,<% } %>
132
- <% } else if (attribute.array && attribute.type !== 'string' && attribute.type !== 'integer' && attribute.type !== 'float' && attribute.type !== 'boolean') { -%>
136
+ <% } else if (attribute.array && !['string', 'text', 'varchar', 'mediumtext', 'longtext', 'integer', 'float', 'boolean'].includes(attribute.type)) { -%>
133
137
  "<%- attribute.key %>": <%- strict ? toCamelCase(attribute.key) : attribute.key %>?.map { $0.toMap() } as Any<% if (index < collection.attributes.length - 1) { %>,<% } %>
134
138
  <% } else { -%>
135
139
  "<%- attribute.key %>": <%- strict ? toCamelCase(attribute.key) : attribute.key %> as Any<% if (index < collection.attributes.length - 1) { %>,<% } %>
@@ -145,7 +149,7 @@ public class <%- toPascalCase(collection.name) %>: Codable {
145
149
  <% const relationshipType = getType(attribute, collections, collection.name).replace('?', ''); -%>
146
150
  <%- strict ? toCamelCase(attribute.key) : attribute.key %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> <%- relationshipType %><% if (index < collection.attributes.length - 1) { %>,<% } %>
147
151
  <% } else if (attribute.array) { -%>
148
- <% if (attribute.type === 'string') { -%>
152
+ <% if (['string', 'text', 'varchar', 'mediumtext', 'longtext'].includes(attribute.type)) { -%>
149
153
  <%- strict ? toCamelCase(attribute.key) : attribute.key %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> [String]<% if (index < collection.attributes.length - 1) { %>,<% } %>
150
154
  <% } else if (attribute.type === 'integer') { -%>
151
155
  <%- strict ? toCamelCase(attribute.key) : attribute.key %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> [Int]<% if (index < collection.attributes.length - 1) { %>,<% } %>
@@ -157,9 +161,9 @@ public class <%- toPascalCase(collection.name) %>: Codable {
157
161
  <%- strict ? toCamelCase(attribute.key) : attribute.key %>: (map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> [[String: Any]])<% if (!attribute.required) { %>?<% } %>.map { <%- toPascalCase(attribute.type) %>.from(map: $0) }<% if (index < collection.attributes.length - 1) { %>,<% } %>
158
162
  <% } -%>
159
163
  <% } else { -%>
160
- <% if ((attribute.type === 'string' || attribute.type === 'email' || attribute.type === 'datetime') && attribute.format !== 'enum') { -%>
164
+ <% if (['string', 'text', 'varchar', 'mediumtext', 'longtext', 'email', 'datetime'].includes(attribute.type) && attribute.format !== 'enum') { -%>
161
165
  <%- strict ? toCamelCase(attribute.key) : attribute.key %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> String<% if (index < collection.attributes.length - 1) { %>,<% } %>
162
- <% } else if (attribute.type === 'string' && attribute.format === 'enum') { -%>
166
+ <% } else if (['string', 'text', 'varchar', 'mediumtext', 'longtext'].includes(attribute.type) && attribute.format === 'enum') { -%>
163
167
  <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %>(rawValue: map["<%- attribute.key %>"] as! String)!<% if (index < collection.attributes.length - 1) { %>,<% } %>
164
168
  <% } else if (attribute.type === 'integer') { -%>
165
169
  <%- strict ? toCamelCase(attribute.key) : attribute.key %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> Int<% if (index < collection.attributes.length - 1) { %>,<% } %>
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "homepage": "https://appwrite.io/support",
5
5
  "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API",
6
- "version": "13.2.1",
6
+ "version": "13.3.1",
7
7
  "license": "BSD-3-Clause",
8
8
  "main": "dist/index.js",
9
9
  "types": "dist/index.d.ts",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json",
3
- "version": "13.2.1",
3
+ "version": "13.3.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/13.2.1/appwrite-cli-win-x64.exe",
9
+ "url": "https://github.com/appwrite/sdk-for-cli/releases/download/13.3.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/13.2.1/appwrite-cli-win-arm64.exe",
18
+ "url": "https://github.com/appwrite/sdk-for-cli/releases/download/13.3.1/appwrite-cli-win-arm64.exe",
19
19
  "bin": [
20
20
  [
21
21
  "appwrite-cli-win-arm64.exe",