chirag-appwrite-cli 0.1.0 → 0.1.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 (96) hide show
  1. package/appwrite.config.json +420 -0
  2. package/docs/examples/databases/list-usage.md +2 -0
  3. package/docs/examples/projects/update-session-invalidation.md +3 -0
  4. package/docs/examples/tables/create-boolean-column.md +7 -0
  5. package/docs/examples/tables/create-datetime-column.md +7 -0
  6. package/docs/examples/tables/create-email-column.md +7 -0
  7. package/docs/examples/tables/create-enum-column.md +8 -0
  8. package/docs/examples/tables/create-float-column.md +9 -0
  9. package/docs/examples/tables/create-index.md +8 -0
  10. package/docs/examples/tables/create-integer-column.md +9 -0
  11. package/docs/examples/tables/create-ip-column.md +7 -0
  12. package/docs/examples/tables/create-relationship-column.md +9 -0
  13. package/docs/examples/tables/create-row.md +6 -0
  14. package/docs/examples/tables/create-rows.md +4 -0
  15. package/docs/examples/tables/create-string-column.md +9 -0
  16. package/docs/examples/tables/create-url-column.md +7 -0
  17. package/docs/examples/tables/create.md +7 -0
  18. package/docs/examples/tables/decrement-row-column.md +7 -0
  19. package/docs/examples/tables/delete-column.md +4 -0
  20. package/docs/examples/tables/delete-index.md +4 -0
  21. package/docs/examples/tables/delete-row.md +4 -0
  22. package/docs/examples/tables/delete-rows.md +4 -0
  23. package/docs/examples/tables/delete.md +3 -0
  24. package/docs/examples/tables/get-column.md +4 -0
  25. package/docs/examples/tables/get-index.md +4 -0
  26. package/docs/examples/tables/get-row.md +5 -0
  27. package/docs/examples/tables/get-usage.md +4 -0
  28. package/docs/examples/tables/get.md +3 -0
  29. package/docs/examples/tables/increment-row-column.md +7 -0
  30. package/docs/examples/tables/list-columns.md +4 -0
  31. package/docs/examples/tables/list-indexes.md +4 -0
  32. package/docs/examples/tables/list-logs.md +4 -0
  33. package/docs/examples/tables/list-row-logs.md +5 -0
  34. package/docs/examples/tables/list-rows.md +4 -0
  35. package/docs/examples/tables/list.md +4 -0
  36. package/docs/examples/tables/update-boolean-column.md +7 -0
  37. package/docs/examples/tables/update-datetime-column.md +7 -0
  38. package/docs/examples/tables/update-email-column.md +7 -0
  39. package/docs/examples/tables/update-enum-column.md +8 -0
  40. package/docs/examples/tables/update-float-column.md +9 -0
  41. package/docs/examples/tables/update-integer-column.md +9 -0
  42. package/docs/examples/tables/update-ip-column.md +7 -0
  43. package/docs/examples/tables/update-relationship-column.md +6 -0
  44. package/docs/examples/tables/update-row.md +6 -0
  45. package/docs/examples/tables/update-rows.md +5 -0
  46. package/docs/examples/tables/update-string-column.md +8 -0
  47. package/docs/examples/tables/update-url-column.md +7 -0
  48. package/docs/examples/tables/update.md +7 -0
  49. package/docs/examples/tables/upsert-row.md +4 -0
  50. package/docs/examples/tables/upsert-rows.md +3 -0
  51. package/generate/appwrite.d.ts +43 -6
  52. package/generate/appwrite.db.ts +75 -0
  53. package/lib/client-generation/languages/typescript.js +65 -0
  54. package/lib/commands/account.js +1 -1
  55. package/lib/commands/avatars.js +1 -1
  56. package/lib/commands/console.js +1 -1
  57. package/lib/commands/databases.js +2 -2
  58. package/lib/commands/functions.js +1 -1
  59. package/lib/commands/graphql.js +1 -1
  60. package/lib/commands/health.js +1 -1
  61. package/lib/commands/locale.js +1 -1
  62. package/lib/commands/messaging.js +1 -1
  63. package/lib/commands/migrations.js +1 -1
  64. package/lib/commands/project.js +1 -1
  65. package/lib/commands/projects.js +1 -1
  66. package/lib/commands/proxy.js +1 -1
  67. package/lib/commands/sites.js +1 -1
  68. package/lib/commands/storage.js +1 -1
  69. package/lib/commands/tables.js +2607 -0
  70. package/lib/commands/teams.js +1 -1
  71. package/lib/commands/tokens.js +1 -1
  72. package/lib/commands/types.js +45 -10
  73. package/lib/commands/users.js +1 -1
  74. package/lib/commands/vcs.js +2 -2
  75. package/lib/config.js +26 -14
  76. package/lib/type-generation/languages/dart.js +13 -13
  77. package/lib/type-generation/languages/java.js +13 -13
  78. package/lib/type-generation/languages/javascript.js +14 -14
  79. package/lib/type-generation/languages/kotlin.js +11 -10
  80. package/lib/type-generation/languages/php.js +15 -14
  81. package/lib/type-generation/languages/swift.js +13 -13
  82. package/lib/type-generation/languages/typescript.js +4 -1
  83. package/package.json +1 -1
  84. package/appwrite.json +0 -164
  85. /package/sites/{JavaScript starter → JavaScript starter2}/.env.example +0 -0
  86. /package/sites/{JavaScript starter → JavaScript starter2}/LICENSE +0 -0
  87. /package/sites/{JavaScript starter → JavaScript starter2}/images/appwrite.svg +0 -0
  88. /package/sites/{JavaScript starter → JavaScript starter2}/images/javascript.svg +0 -0
  89. /package/sites/{JavaScript starter → JavaScript starter2}/index.html +0 -0
  90. /package/sites/{JavaScript starter → JavaScript starter2}/lib/appwrite.js +0 -0
  91. /package/sites/{JavaScript starter → JavaScript starter2}/package-lock.json +0 -0
  92. /package/sites/{JavaScript starter → JavaScript starter2}/package.json +0 -0
  93. /package/sites/{JavaScript starter → JavaScript starter2}/readme.md +0 -0
  94. /package/sites/{JavaScript starter → JavaScript starter2}/src/javascript.svg +0 -0
  95. /package/sites/{JavaScript starter → JavaScript starter2}/style/app.css +0 -0
  96. /package/sites/{JavaScript starter → JavaScript starter2}/vite.config.js +0 -0
@@ -3,7 +3,7 @@ const { AttributeType } = require('../attribute');
3
3
  const { LanguageMeta } = require("./language");
4
4
 
5
5
  class Swift extends LanguageMeta {
6
- getType(attribute) {
6
+ getType(attribute, collections) {
7
7
  let type = "";
8
8
  switch (attribute.type) {
9
9
  case AttributeType.STRING:
@@ -24,7 +24,11 @@ class Swift extends LanguageMeta {
24
24
  type = "Bool";
25
25
  break;
26
26
  case AttributeType.RELATIONSHIP:
27
- type = LanguageMeta.toPascalCase(attribute.relatedCollection);
27
+ const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
28
+ if (!relatedCollection) {
29
+ throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
30
+ }
31
+ type = LanguageMeta.toPascalCase(relatedCollection.name);
28
32
  if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
29
33
  type = `[${type}]`;
30
34
  }
@@ -41,15 +45,11 @@ class Swift extends LanguageMeta {
41
45
  return type;
42
46
  }
43
47
 
44
- getCurrentDirectory() {
45
- return process.cwd();
46
- }
47
-
48
48
  getTemplate() {
49
49
  return `import Foundation
50
50
 
51
51
  /// This file is auto-generated by the Appwrite CLI.
52
- /// You can regenerate it by running \`appwrite types -l <%- strict ? '--strict ' : '' %>swift <%- path %>\`.
52
+ /// You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
53
53
 
54
54
  <% for (const attribute of collection.attributes) { -%>
55
55
  <% if (attribute.format === 'enum') { -%>
@@ -63,7 +63,7 @@ public enum <%- toPascalCase(attribute.key) %>: String, Codable, CaseIterable {
63
63
  <% } -%>
64
64
  public class <%- toPascalCase(collection.name) %>: Codable {
65
65
  <% for (const attribute of collection.attributes) { -%>
66
- public let <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute) %>
66
+ public let <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute, collections) %>
67
67
  <% } %>
68
68
  enum CodingKeys: String, CodingKey {
69
69
  <% for (const attribute of collection.attributes) { -%>
@@ -73,7 +73,7 @@ public class <%- toPascalCase(collection.name) %>: Codable {
73
73
 
74
74
  public init(
75
75
  <% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
76
- <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute) %><% if (index < collection.attributes.length - 1) { %>,<% } %>
76
+ <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute, collections) %><% if (index < collection.attributes.length - 1) { %>,<% } %>
77
77
  <% } -%>
78
78
  ) {
79
79
  <% for (const attribute of collection.attributes) { -%>
@@ -86,9 +86,9 @@ public class <%- toPascalCase(collection.name) %>: Codable {
86
86
 
87
87
  <% for (const attribute of collection.attributes) { -%>
88
88
  <% if (!(!attribute.required && attribute.default === null)) { -%>
89
- self.<%- strict ? toCamelCase(attribute.key) : attribute.key %> = try container.decode(<%- getType(attribute).replace('?', '') %>.self, forKey: .<%- strict ? toCamelCase(attribute.key) : attribute.key %>)
89
+ self.<%- strict ? toCamelCase(attribute.key) : attribute.key %> = try container.decode(<%- getType(attribute, collections).replace('?', '') %>.self, forKey: .<%- strict ? toCamelCase(attribute.key) : attribute.key %>)
90
90
  <% } else { -%>
91
- self.<%- strict ? toCamelCase(attribute.key) : attribute.key %> = try container.decodeIfPresent(<%- getType(attribute).replace('?', '') %>.self, forKey: .<%- strict ? toCamelCase(attribute.key) : attribute.key %>)
91
+ self.<%- strict ? toCamelCase(attribute.key) : attribute.key %> = try container.decodeIfPresent(<%- getType(attribute, collections).replace('?', '') %>.self, forKey: .<%- strict ? toCamelCase(attribute.key) : attribute.key %>)
92
92
  <% } -%>
93
93
  <% } -%>
94
94
  }
@@ -124,9 +124,9 @@ public class <%- toPascalCase(collection.name) %>: Codable {
124
124
  <% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
125
125
  <% if (attribute.type === 'relationship') { -%>
126
126
  <% if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') { -%>
127
- <%- strict ? toCamelCase(attribute.key) : attribute.key %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> [<%- toPascalCase(attribute.relatedCollection) %>]<% if (index < collection.attributes.length - 1) { %>,<% } %>
127
+ <%- strict ? toCamelCase(attribute.key) : attribute.key %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> [<%- toPascalCase(collections.find(c => c.$id === attribute.relatedCollection).name) %>]<% if (index < collection.attributes.length - 1) { %>,<% } %>
128
128
  <% } else { -%>
129
- <%- strict ? toCamelCase(attribute.key) : attribute.key %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> <%- toPascalCase(attribute.relatedCollection) %><% if (index < collection.attributes.length - 1) { %>,<% } %>
129
+ <%- strict ? toCamelCase(attribute.key) : attribute.key %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> <%- toPascalCase(collections.find(c => c.$id === attribute.relatedCollection).name) %><% if (index < collection.attributes.length - 1) { %>,<% } %>
130
130
  <% } -%>
131
131
  <% } else if (attribute.array) { -%>
132
132
  <% if (attribute.type === 'string') { -%>
@@ -30,6 +30,9 @@ class TypeScript extends LanguageMeta {
30
30
  break;
31
31
  case AttributeType.RELATIONSHIP:
32
32
  const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
33
+ if (!relatedCollection) {
34
+ throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
35
+ }
33
36
  type = LanguageMeta.toPascalCase(relatedCollection.name);
34
37
  if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
35
38
  type = `${type}[]`;
@@ -69,7 +72,7 @@ class TypeScript extends LanguageMeta {
69
72
  return `import { type Models } from '${this._getAppwriteDependency()}';
70
73
 
71
74
  // This file is auto-generated by the Appwrite CLI.
72
- // You can regenerate it by running \`appwrite types -l <%- strict ? '--strict ' : '' %>ts <%- path %>\`.
75
+ // You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
73
76
 
74
77
  <% for (const collection of collections) { -%>
75
78
  <% for (const attribute of collection.attributes) { -%>
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "chirag-appwrite-cli",
3
3
  "homepage": "https://appwrite.io/support",
4
4
  "description": "Repo short description goes here",
5
- "version": "0.1.0",
5
+ "version": "0.1.1",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "index.js",
8
8
  "bin": {
package/appwrite.json DELETED
@@ -1,164 +0,0 @@
1
- {
2
- "projectId": "6839a26e003262977966",
3
- "endpoint": "https://fra.cloud.appwrite.io/v1",
4
- "projectName": "6839a26e003262977966",
5
- "settings": {
6
- "services": {
7
- "account": true,
8
- "avatars": true,
9
- "databases": true,
10
- "locale": true,
11
- "health": true,
12
- "storage": true,
13
- "teams": true,
14
- "users": true,
15
- "sites": true,
16
- "functions": true,
17
- "graphql": true,
18
- "messaging": true
19
- },
20
- "auth": {
21
- "methods": {
22
- "jwt": true,
23
- "phone": true,
24
- "invites": true,
25
- "anonymous": true,
26
- "email-otp": true,
27
- "magic-url": true,
28
- "email-password": true
29
- },
30
- "security": {
31
- "duration": 31536000,
32
- "limit": 0,
33
- "sessionsLimit": 10,
34
- "passwordHistory": 0,
35
- "passwordDictionary": false,
36
- "personalDataCheck": false,
37
- "sessionAlerts": false,
38
- "mockNumbers": []
39
- }
40
- }
41
- },
42
- "databases": [
43
- {
44
- "$id": "testing",
45
- "name": "testing",
46
- "enabled": true
47
- }
48
- ],
49
- "collections": [
50
- {
51
- "$id": "687cad390034a29d00ca",
52
- "$permissions": [
53
- "create(\"any\")",
54
- "read(\"any\")",
55
- "update(\"any\")",
56
- "delete(\"any\")"
57
- ],
58
- "databaseId": "687cad33002ad8d6c2d9",
59
- "name": "sprites",
60
- "enabled": true,
61
- "documentSecurity": false,
62
- "attributes": [
63
- {
64
- "key": "title",
65
- "type": "string",
66
- "required": true,
67
- "array": false,
68
- "size": 25,
69
- "default": null,
70
- "encrypt": false
71
- },
72
- {
73
- "key": "data",
74
- "type": "string",
75
- "required": true,
76
- "array": false,
77
- "size": 64,
78
- "default": null,
79
- "encrypt": false
80
- },
81
- {
82
- "key": "category_id",
83
- "type": "relationship",
84
- "required": false,
85
- "array": false,
86
- "relatedCollection": "687cc6a30016f0c53718",
87
- "relationType": "manyToOne",
88
- "twoWay": false,
89
- "twoWayKey": "687cc797002f3b978bd3",
90
- "onDelete": "cascade",
91
- "side": "parent"
92
- }
93
- ],
94
- "indexes": [
95
- {
96
- "key": "data",
97
- "type": "unique",
98
- "status": "available",
99
- "attributes": [
100
- "data"
101
- ],
102
- "orders": [
103
- "ASC"
104
- ]
105
- }
106
- ]
107
- },
108
- {
109
- "$id": "687cc6a30016f0c53718",
110
- "$permissions": [],
111
- "databaseId": "687cad33002ad8d6c2d9",
112
- "name": "categories",
113
- "enabled": true,
114
- "documentSecurity": false,
115
- "attributes": [
116
- {
117
- "key": "title",
118
- "type": "string",
119
- "required": true,
120
- "array": false,
121
- "size": 25,
122
- "default": null,
123
- "encrypt": false
124
- }
125
- ],
126
- "indexes": [
127
- {
128
- "key": "title",
129
- "type": "unique",
130
- "status": "available",
131
- "attributes": [
132
- "title"
133
- ],
134
- "orders": [
135
- "ASC"
136
- ]
137
- }
138
- ]
139
- },
140
- {
141
- "$id": "687cc9ef0019f871c76b",
142
- "$permissions": [],
143
- "databaseId": "687cad33002ad8d6c2d9",
144
- "name": "validated_sprites",
145
- "enabled": true,
146
- "documentSecurity": false,
147
- "attributes": [
148
- {
149
- "key": "sprite_id",
150
- "type": "relationship",
151
- "required": false,
152
- "array": false,
153
- "relatedCollection": "687cad390034a29d00ca",
154
- "relationType": "oneToOne",
155
- "twoWay": false,
156
- "twoWayKey": "687cca0c00021e8cead3",
157
- "onDelete": "cascade",
158
- "side": "parent"
159
- }
160
- ],
161
- "indexes": []
162
- }
163
- ]
164
- }