@appwrite.io/console 1.8.0 → 1.10.0

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 (105) hide show
  1. package/.github/workflows/publish.yml +1 -1
  2. package/CHANGELOG.md +45 -6
  3. package/README.md +82 -2
  4. package/dist/cjs/sdk.js +532 -200
  5. package/dist/cjs/sdk.js.map +1 -1
  6. package/dist/esm/sdk.js +533 -201
  7. package/dist/esm/sdk.js.map +1 -1
  8. package/dist/iife/sdk.js +532 -200
  9. package/docs/examples/databases/create-document.md +1 -3
  10. package/docs/examples/databases/create-documents.md +1 -1
  11. package/docs/examples/databases/decrement-document-attribute.md +18 -0
  12. package/docs/examples/databases/increment-document-attribute.md +18 -0
  13. package/docs/examples/databases/upsert-documents.md +1 -1
  14. package/docs/examples/domains/create-record-a-a-a-a.md +1 -1
  15. package/docs/examples/domains/create-record-a.md +1 -1
  16. package/docs/examples/domains/create-record-alias.md +1 -1
  17. package/docs/examples/domains/create-record-c-a-a.md +1 -1
  18. package/docs/examples/domains/create-record-c-n-a-m-e.md +1 -1
  19. package/docs/examples/domains/create-record-h-t-t-p-s.md +1 -1
  20. package/docs/examples/domains/create-record-m-x.md +1 -1
  21. package/docs/examples/domains/create-record-n-s.md +1 -1
  22. package/docs/examples/domains/create-record-s-r-v.md +1 -1
  23. package/docs/examples/domains/create-record-t-x-t.md +1 -1
  24. package/docs/examples/domains/update-record-a-a-a-a.md +1 -1
  25. package/docs/examples/domains/update-record-a.md +1 -1
  26. package/docs/examples/domains/update-record-alias.md +1 -1
  27. package/docs/examples/domains/update-record-c-a-a.md +1 -1
  28. package/docs/examples/domains/update-record-c-n-a-m-e.md +1 -1
  29. package/docs/examples/domains/update-record-h-t-t-p-s.md +1 -1
  30. package/docs/examples/domains/update-record-m-x.md +1 -1
  31. package/docs/examples/domains/update-record-n-s.md +1 -1
  32. package/docs/examples/domains/update-record-s-r-v.md +1 -1
  33. package/docs/examples/domains/update-record-t-x-t.md +1 -1
  34. package/docs/examples/functions/create-execution.md +1 -1
  35. package/docs/examples/health/{get-queue-stats-usage-dump.md → get-queue-billing-project-aggregation.md} +2 -2
  36. package/docs/examples/health/{get-queue-billing-aggregation.md → get-queue-billing-team-aggregation.md} +1 -1
  37. package/docs/examples/organizations/cancel-downgrade.md +13 -0
  38. package/docs/examples/organizations/estimation-create-organization.md +16 -0
  39. package/docs/examples/organizations/estimation-delete-organization.md +13 -0
  40. package/docs/examples/organizations/estimation-update-plan.md +16 -0
  41. package/docs/examples/organizations/get-available-credits.md +13 -0
  42. package/docs/examples/organizations/get-usage.md +1 -1
  43. package/docs/examples/organizations/update-projects.md +14 -0
  44. package/docs/examples/organizations/validate-payment.md +14 -0
  45. package/docs/examples/proxy/create-redirect-rule.md +4 -2
  46. package/docs/examples/vcs/get-repository-contents.md +2 -1
  47. package/package.json +1 -1
  48. package/src/client.ts +5 -4
  49. package/src/enums/build-runtime.ts +2 -0
  50. package/src/enums/image-format.ts +1 -0
  51. package/src/enums/proxy-resource-type.ts +4 -0
  52. package/src/enums/runtime.ts +2 -0
  53. package/src/index.ts +1 -0
  54. package/src/models.ts +513 -11
  55. package/src/services/account.ts +97 -36
  56. package/src/services/avatars.ts +26 -20
  57. package/src/services/backups.ts +11 -0
  58. package/src/services/console.ts +8 -1
  59. package/src/services/databases.ts +190 -31
  60. package/src/services/domains.ts +111 -69
  61. package/src/services/functions.ts +37 -8
  62. package/src/services/graphql.ts +1 -0
  63. package/src/services/health.ts +54 -4
  64. package/src/services/locale.ts +9 -2
  65. package/src/services/messaging.ts +53 -8
  66. package/src/services/migrations.ts +12 -0
  67. package/src/services/organizations.ts +301 -14
  68. package/src/services/project.ts +5 -0
  69. package/src/services/projects.ts +50 -0
  70. package/src/services/proxy.ts +23 -1
  71. package/src/services/sites.ts +32 -4
  72. package/src/services/storage.ts +23 -9
  73. package/src/services/teams.ts +30 -17
  74. package/src/services/tokens.ts +4 -0
  75. package/src/services/users.ts +69 -27
  76. package/src/services/vcs.ts +16 -4
  77. package/types/enums/build-runtime.d.ts +3 -1
  78. package/types/enums/image-format.d.ts +2 -1
  79. package/types/enums/proxy-resource-type.d.ts +4 -0
  80. package/types/enums/runtime.d.ts +3 -1
  81. package/types/index.d.ts +1 -0
  82. package/types/models.d.ts +494 -188
  83. package/types/services/account.d.ts +36 -36
  84. package/types/services/avatars.d.ts +20 -20
  85. package/types/services/console.d.ts +1 -1
  86. package/types/services/databases.d.ts +67 -31
  87. package/types/services/domains.d.ts +69 -69
  88. package/types/services/functions.d.ts +8 -8
  89. package/types/services/health.d.ts +11 -3
  90. package/types/services/locale.d.ts +2 -2
  91. package/types/services/messaging.d.ts +8 -8
  92. package/types/services/organizations.d.ts +88 -14
  93. package/types/services/proxy.d.ts +4 -1
  94. package/types/services/sites.d.ts +4 -4
  95. package/types/services/storage.d.ts +9 -9
  96. package/types/services/teams.d.ts +17 -17
  97. package/types/services/users.d.ts +27 -27
  98. package/types/services/vcs.d.ts +4 -4
  99. package/docs/examples/functions/create-build.md +0 -15
  100. package/docs/examples/functions/get-function-usage.md +0 -14
  101. package/docs/examples/functions/update-deployment-build.md +0 -14
  102. package/docs/examples/functions/update-deployment.md +0 -14
  103. package/docs/examples/proxy/create-rule.md +0 -15
  104. package/src/enums/resource-type.ts +0 -4
  105. package/types/enums/resource-type.d.ts +0 -4
@@ -39,4 +39,4 @@ jobs:
39
39
  - name: Publish
40
40
  run: npm publish --tag ${{ steps.release_tag.outputs.tag }}
41
41
  env:
42
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
42
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_NO_ORG }}
package/CHANGELOG.md CHANGED
@@ -1,9 +1,48 @@
1
1
  # Change Log
2
2
 
3
- ## 18.0.0
3
+ ## 1.10.0
4
4
 
5
- * Add `<REGION>` to doc examples due to the new multi region endpoints
6
- * Remove `Gif` from ImageFormat enum
7
- * Remove `search` param from `listExecutions` method
8
- * Add `token` param to `getFilePreview` and `getFileView` for File tokens usage
9
- * Improve CORS error catching in `client.call` method
5
+ * Fix autocompletion not working for `Document` model even when generic is passed
6
+ * Add `getAvailableCredits` and `updateProjects` methods to `Organizations` service
7
+ * Allow internal attributes to be passed in `data` parameter of `createDocument`, `updateDocument` etc. methods
8
+ * Formatting changes
9
+
10
+ ## 1.9.0
11
+
12
+ * Add `1.8.x` support
13
+
14
+ ## 1.8.0
15
+
16
+ * Add encrypt to string attribute model
17
+ * Add upsert document method
18
+ * Add max deployment size and max build size plan attributes
19
+ * Remove `templateRepository`, `templateOwner`, `templateRootDirectory`, `templateVersion` from `functions.create`
20
+
21
+ ## 1.7.0
22
+
23
+ * Update docs to use `https://<REGION>.cloud.appwrite.io/v1` instead of `https://cloud.appwrite.io/v1`
24
+ * Add `1.7.x` support
25
+
26
+ ## 1.6.0
27
+
28
+ * Updates checking and then setting of cloud and realtime endpoint.
29
+ * Remove unnecessary asyncs and awaits.
30
+ * Adds and fixes lot of the billing related models and return types.
31
+ * Fixes typing for attributes type in Collection class.
32
+ * Removes method.title for multiplexing of endpoints.
33
+ * Removes unnecessary adding of project to payload.
34
+ * Ensures AppwriteException's "response" attribute is always string
35
+ * Adds check for file not found in chuckedUpload method
36
+ * Adds figma oauth adapter
37
+
38
+ ## 1.5.2
39
+
40
+ * Adds image transformations usages to project, bucket and org. usages.
41
+
42
+ ## 1.5.1
43
+
44
+ * Add some model vars that were left out and were required for DB read & writes.
45
+
46
+ ## 1.5.0
47
+
48
+ * Adds support for `databasesReadsTotal` and `databasesWritesTotal` attributes
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Appwrite Console SDK
2
2
 
3
3
  ![License](https://img.shields.io/github/license/appwrite/sdk-for-console.svg?style=flat-square)
4
- ![Version](https://img.shields.io/badge/api%20version-1.7.2-blue.svg?style=flat-square)
4
+ ![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square)
5
5
  [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
6
6
  [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
7
7
  [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
@@ -33,18 +33,20 @@ import { Client, Account } from "@appwrite.io/console";
33
33
  To install with a CDN (content delivery network) add the following scripts to the bottom of your <body> tag, but before you use any Appwrite services:
34
34
 
35
35
  ```html
36
- <script src="https://cdn.jsdelivr.net/npm/@appwrite.io/console@1.8.0"></script>
36
+ <script src="https://cdn.jsdelivr.net/npm/@appwrite.io/console@1.10.0"></script>
37
37
  ```
38
38
 
39
39
 
40
40
  ## Getting Started
41
41
 
42
42
  ### Add your Web Platform
43
+
43
44
  For you to init your SDK and interact with Appwrite services you need to add a web platform to your project. To add a new platform, go to your Appwrite console, choose the project you created in the step before and click the 'Add Platform' button.
44
45
 
45
46
  From the options, choose to add a **Web** platform and add your client app hostname. By adding your hostname to your project platform you are allowing cross-domain communication between your project and the Appwrite API.
46
47
 
47
48
  ### Init your SDK
49
+
48
50
  Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page.
49
51
 
50
52
  ```js
@@ -58,6 +60,7 @@ client
58
60
  ```
59
61
 
60
62
  ### Make Your First Request
63
+
61
64
  Once your SDK object is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section.
62
65
 
63
66
  ```js
@@ -74,6 +77,7 @@ account.create(ID.unique(), "email@example.com", "password", "Walter O'Brien")
74
77
  ```
75
78
 
76
79
  ### Full Example
80
+
77
81
  ```js
78
82
  // Init your Web SDK
79
83
  const client = new Client();
@@ -94,7 +98,83 @@ account.create(ID.unique(), "email@example.com", "password", "Walter O'Brien")
94
98
  });
95
99
  ```
96
100
 
101
+ ### Type Safety with Models
102
+
103
+ The Appwrite Web SDK provides type safety when working with database documents through generic methods. Methods like `listDocuments`, `getDocument`, and others accept a generic type parameter that allows you to specify your custom model type for full type safety.
104
+
105
+ **TypeScript:**
106
+ ```typescript
107
+ interface Book {
108
+ name: string;
109
+ author: string;
110
+ releaseYear?: string;
111
+ category?: string;
112
+ genre?: string[];
113
+ isCheckedOut: boolean;
114
+ }
115
+
116
+ const databases = new Databases(client);
117
+
118
+ try {
119
+ const documents = await databases.listDocuments<Book>(
120
+ 'your-database-id',
121
+ 'your-collection-id'
122
+ );
123
+
124
+ documents.documents.forEach(book => {
125
+ console.log(`Book: ${book.name} by ${book.author}`); // Now you have full type safety
126
+ });
127
+ } catch (error) {
128
+ console.error('Appwrite error:', error);
129
+ }
130
+ ```
131
+
132
+ **JavaScript (with JSDoc for type hints):**
133
+ ```javascript
134
+ /**
135
+ * @typedef {Object} Book
136
+ * @property {string} name
137
+ * @property {string} author
138
+ * @property {string} [releaseYear]
139
+ * @property {string} [category]
140
+ * @property {string[]} [genre]
141
+ * @property {boolean} isCheckedOut
142
+ */
143
+
144
+ const databases = new Databases(client);
145
+
146
+ try {
147
+ /** @type {Models.DocumentList<Book>} */
148
+ const documents = await databases.listDocuments(
149
+ 'your-database-id',
150
+ 'your-collection-id'
151
+ );
152
+
153
+ documents.documents.forEach(book => {
154
+ console.log(`Book: ${book.name} by ${book.author}`); // Type hints available in IDE
155
+ });
156
+ } catch (error) {
157
+ console.error('Appwrite error:', error);
158
+ }
159
+ ```
160
+
161
+ **Tip**: You can use the `appwrite types` command to automatically generate TypeScript interfaces based on your Appwrite database schema. Learn more about [type generation](https://appwrite.io/docs/products/databases/type-generation).
162
+
163
+ ### Error Handling
164
+
165
+ The Appwrite Web SDK raises an `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching the exception and present the `message` to the user or handle it yourself based on the provided error information. Below is an example.
166
+
167
+ ```javascript
168
+ try {
169
+ const user = await account.create(ID.unique(), "email@example.com", "password", "Walter O'Brien");
170
+ console.log('User created:', user);
171
+ } catch (error) {
172
+ console.error('Appwrite error:', error.message);
173
+ }
174
+ ```
175
+
97
176
  ### Learn more
177
+
98
178
  You can use the following resources to learn more and get help
99
179
  - 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-web)
100
180
  - 📜 [Appwrite Docs](https://appwrite.io/docs)