@appwrite.io/console 1.7.0 → 1.9.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 (73) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/sdk.js +330 -27
  3. package/dist/cjs/sdk.js.map +1 -1
  4. package/dist/esm/sdk.js +331 -28
  5. package/dist/esm/sdk.js.map +1 -1
  6. package/dist/iife/sdk.js +330 -27
  7. package/docs/examples/databases/decrement-document-attribute.md +18 -0
  8. package/docs/examples/databases/increment-document-attribute.md +18 -0
  9. package/docs/examples/databases/upsert-document.md +17 -0
  10. package/docs/examples/databases/upsert-documents.md +1 -1
  11. package/docs/examples/domains/create-record-a-a-a-a.md +1 -1
  12. package/docs/examples/domains/create-record-a.md +1 -1
  13. package/docs/examples/domains/create-record-alias.md +1 -1
  14. package/docs/examples/domains/create-record-c-a-a.md +1 -1
  15. package/docs/examples/domains/create-record-c-n-a-m-e.md +1 -1
  16. package/docs/examples/domains/create-record-h-t-t-p-s.md +1 -1
  17. package/docs/examples/domains/create-record-m-x.md +1 -1
  18. package/docs/examples/domains/create-record-n-s.md +1 -1
  19. package/docs/examples/domains/create-record-s-r-v.md +1 -1
  20. package/docs/examples/domains/create-record-t-x-t.md +1 -1
  21. package/docs/examples/domains/update-record-a-a-a-a.md +1 -1
  22. package/docs/examples/domains/update-record-a.md +1 -1
  23. package/docs/examples/domains/update-record-alias.md +1 -1
  24. package/docs/examples/domains/update-record-c-a-a.md +1 -1
  25. package/docs/examples/domains/update-record-c-n-a-m-e.md +1 -1
  26. package/docs/examples/domains/update-record-h-t-t-p-s.md +1 -1
  27. package/docs/examples/domains/update-record-m-x.md +1 -1
  28. package/docs/examples/domains/update-record-n-s.md +1 -1
  29. package/docs/examples/domains/update-record-s-r-v.md +1 -1
  30. package/docs/examples/domains/update-record-t-x-t.md +1 -1
  31. package/docs/examples/functions/create.md +1 -5
  32. package/docs/examples/health/{get-queue-stats-usage-dump.md → get-queue-billing-project-aggregation.md} +2 -2
  33. package/docs/examples/health/{get-queue-billing-aggregation.md → get-queue-billing-team-aggregation.md} +1 -1
  34. package/docs/examples/organizations/cancel-downgrade.md +13 -0
  35. package/docs/examples/organizations/estimation-create-organization.md +16 -0
  36. package/docs/examples/organizations/estimation-delete-organization.md +13 -0
  37. package/docs/examples/organizations/estimation-update-plan.md +16 -0
  38. package/docs/examples/organizations/get-usage.md +1 -1
  39. package/docs/examples/organizations/validate-payment.md +14 -0
  40. package/docs/examples/proxy/create-redirect-rule.md +4 -2
  41. package/package.json +1 -1
  42. package/src/client.ts +9 -5
  43. package/src/enums/build-runtime.ts +2 -0
  44. package/src/enums/image-format.ts +1 -0
  45. package/src/enums/proxy-resource-type.ts +4 -0
  46. package/src/enums/runtime.ts +2 -0
  47. package/src/index.ts +1 -0
  48. package/src/models.ts +284 -2
  49. package/src/services/databases.ts +141 -1
  50. package/src/services/functions.ts +1 -17
  51. package/src/services/health.ts +28 -3
  52. package/src/services/organizations.ts +197 -0
  53. package/src/services/proxy.ts +16 -1
  54. package/src/services/tokens.ts +1 -1
  55. package/types/enums/build-runtime.d.ts +3 -1
  56. package/types/enums/image-format.d.ts +2 -1
  57. package/types/enums/proxy-resource-type.d.ts +4 -0
  58. package/types/enums/runtime.d.ts +3 -1
  59. package/types/index.d.ts +1 -0
  60. package/types/models.d.ts +284 -2
  61. package/types/services/databases.d.ts +39 -1
  62. package/types/services/functions.d.ts +1 -5
  63. package/types/services/health.d.ts +10 -2
  64. package/types/services/organizations.d.ts +57 -0
  65. package/types/services/proxy.d.ts +4 -1
  66. package/types/services/tokens.d.ts +1 -1
  67. package/docs/examples/functions/create-build.md +0 -15
  68. package/docs/examples/functions/get-function-usage.md +0 -14
  69. package/docs/examples/functions/update-deployment-build.md +0 -14
  70. package/docs/examples/functions/update-deployment.md +0 -14
  71. package/docs/examples/proxy/create-rule.md +0 -15
  72. package/src/enums/resource-type.ts +0 -4
  73. package/types/enums/resource-type.d.ts +0 -4
@@ -10,7 +10,7 @@ const result = await domains.createRecordNS(
10
10
  '<DOMAIN_ID>', // domainId
11
11
  '<NAME>', // name
12
12
  '<VALUE>', // value
13
- null, // ttl
13
+ 1, // ttl
14
14
  '<COMMENT>' // comment (optional)
15
15
  );
16
16
 
@@ -10,7 +10,7 @@ const result = await domains.createRecordSRV(
10
10
  '<DOMAIN_ID>', // domainId
11
11
  '<NAME>', // name
12
12
  '<VALUE>', // value
13
- null, // ttl
13
+ 1, // ttl
14
14
  null, // priority
15
15
  null, // weight
16
16
  null, // port
@@ -9,7 +9,7 @@ const domains = new Domains(client);
9
9
  const result = await domains.createRecordTXT(
10
10
  '<DOMAIN_ID>', // domainId
11
11
  '<NAME>', // name
12
- null, // ttl
12
+ 1, // ttl
13
13
  '<VALUE>', // value (optional)
14
14
  '<COMMENT>' // comment (optional)
15
15
  );
@@ -11,7 +11,7 @@ const result = await domains.updateRecordAAAA(
11
11
  '<RECORD_ID>', // recordId
12
12
  '<NAME>', // name
13
13
  '', // value
14
- null, // ttl
14
+ 1, // ttl
15
15
  '<COMMENT>' // comment (optional)
16
16
  );
17
17
 
@@ -11,7 +11,7 @@ const result = await domains.updateRecordA(
11
11
  '<RECORD_ID>', // recordId
12
12
  '<NAME>', // name
13
13
  '', // value
14
- null, // ttl
14
+ 1, // ttl
15
15
  '<COMMENT>' // comment (optional)
16
16
  );
17
17
 
@@ -11,7 +11,7 @@ const result = await domains.updateRecordAlias(
11
11
  '<RECORD_ID>', // recordId
12
12
  '<NAME>', // name
13
13
  '<VALUE>', // value
14
- null, // ttl
14
+ 1, // ttl
15
15
  '<COMMENT>' // comment (optional)
16
16
  );
17
17
 
@@ -11,7 +11,7 @@ const result = await domains.updateRecordCAA(
11
11
  '<RECORD_ID>', // recordId
12
12
  '<NAME>', // name
13
13
  '<VALUE>', // value
14
- null, // ttl
14
+ 1, // ttl
15
15
  '<COMMENT>' // comment (optional)
16
16
  );
17
17
 
@@ -11,7 +11,7 @@ const result = await domains.updateRecordCNAME(
11
11
  '<RECORD_ID>', // recordId
12
12
  '<NAME>', // name
13
13
  '<VALUE>', // value
14
- null, // ttl
14
+ 1, // ttl
15
15
  '<COMMENT>' // comment (optional)
16
16
  );
17
17
 
@@ -11,7 +11,7 @@ const result = await domains.updateRecordHTTPS(
11
11
  '<RECORD_ID>', // recordId
12
12
  '<NAME>', // name
13
13
  '<VALUE>', // value
14
- null, // ttl
14
+ 1, // ttl
15
15
  '<COMMENT>' // comment (optional)
16
16
  );
17
17
 
@@ -11,7 +11,7 @@ const result = await domains.updateRecordMX(
11
11
  '<RECORD_ID>', // recordId
12
12
  '<NAME>', // name
13
13
  '<VALUE>', // value
14
- null, // ttl
14
+ 1, // ttl
15
15
  null, // priority
16
16
  '<COMMENT>' // comment (optional)
17
17
  );
@@ -11,7 +11,7 @@ const result = await domains.updateRecordNS(
11
11
  '<RECORD_ID>', // recordId
12
12
  '<NAME>', // name
13
13
  '<VALUE>', // value
14
- null, // ttl
14
+ 1, // ttl
15
15
  '<COMMENT>' // comment (optional)
16
16
  );
17
17
 
@@ -11,7 +11,7 @@ const result = await domains.updateRecordSRV(
11
11
  '<RECORD_ID>', // recordId
12
12
  '<NAME>', // name
13
13
  '<VALUE>', // value
14
- null, // ttl
14
+ 1, // ttl
15
15
  null, // priority
16
16
  null, // weight
17
17
  null, // port
@@ -11,7 +11,7 @@ const result = await domains.updateRecordTXT(
11
11
  '<RECORD_ID>', // recordId
12
12
  '<NAME>', // name
13
13
  '<VALUE>', // value
14
- null, // ttl
14
+ 1, // ttl
15
15
  '<COMMENT>' // comment (optional)
16
16
  );
17
17
 
@@ -24,11 +24,7 @@ const result = await functions.create(
24
24
  '<PROVIDER_BRANCH>', // providerBranch (optional)
25
25
  false, // providerSilentMode (optional)
26
26
  '<PROVIDER_ROOT_DIRECTORY>', // providerRootDirectory (optional)
27
- '', // specification (optional)
28
- '<TEMPLATE_REPOSITORY>', // templateRepository (optional)
29
- '<TEMPLATE_OWNER>', // templateOwner (optional)
30
- '<TEMPLATE_ROOT_DIRECTORY>', // templateRootDirectory (optional)
31
- '<TEMPLATE_VERSION>' // templateVersion (optional)
27
+ '' // specification (optional)
32
28
  );
33
29
 
34
30
  console.log(result);
@@ -1,12 +1,12 @@
1
1
  import { Client, Health } from "@appwrite.io/console";
2
2
 
3
3
  const client = new Client()
4
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
4
+ .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5
5
  .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
6
 
7
7
  const health = new Health(client);
8
8
 
9
- const result = await health.getQueueStatsUsageDump(
9
+ const result = await health.getQueueBillingProjectAggregation(
10
10
  null // threshold (optional)
11
11
  );
12
12
 
@@ -6,7 +6,7 @@ const client = new Client()
6
6
 
7
7
  const health = new Health(client);
8
8
 
9
- const result = await health.getQueueBillingAggregation(
9
+ const result = await health.getQueueBillingTeamAggregation(
10
10
  null // threshold (optional)
11
11
  );
12
12
 
@@ -0,0 +1,13 @@
1
+ import { Client, Organizations } from "@appwrite.io/console";
2
+
3
+ const client = new Client()
4
+ .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
+
7
+ const organizations = new Organizations(client);
8
+
9
+ const result = await organizations.cancelDowngrade(
10
+ '<ORGANIZATION_ID>' // organizationId
11
+ );
12
+
13
+ console.log(result);
@@ -0,0 +1,16 @@
1
+ import { Client, Organizations, } from "@appwrite.io/console";
2
+
3
+ const client = new Client()
4
+ .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
+
7
+ const organizations = new Organizations(client);
8
+
9
+ const result = await organizations.estimationCreateOrganization(
10
+ .Tier0, // billingPlan
11
+ '<PAYMENT_METHOD_ID>', // paymentMethodId (optional)
12
+ [], // invites (optional)
13
+ '<COUPON_ID>' // couponId (optional)
14
+ );
15
+
16
+ console.log(result);
@@ -0,0 +1,13 @@
1
+ import { Client, Organizations } from "@appwrite.io/console";
2
+
3
+ const client = new Client()
4
+ .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
+
7
+ const organizations = new Organizations(client);
8
+
9
+ const result = await organizations.estimationDeleteOrganization(
10
+ '<ORGANIZATION_ID>' // organizationId
11
+ );
12
+
13
+ console.log(result);
@@ -0,0 +1,16 @@
1
+ import { Client, Organizations, } from "@appwrite.io/console";
2
+
3
+ const client = new Client()
4
+ .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
+
7
+ const organizations = new Organizations(client);
8
+
9
+ const result = await organizations.estimationUpdatePlan(
10
+ '<ORGANIZATION_ID>', // organizationId
11
+ .Tier0, // billingPlan
12
+ [], // invites (optional)
13
+ '<COUPON_ID>' // couponId (optional)
14
+ );
15
+
16
+ console.log(result);
@@ -1,7 +1,7 @@
1
1
  import { Client, Organizations } from "@appwrite.io/console";
2
2
 
3
3
  const client = new Client()
4
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
4
+ .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5
5
  .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
6
 
7
7
  const organizations = new Organizations(client);
@@ -0,0 +1,14 @@
1
+ import { Client, Organizations } from "@appwrite.io/console";
2
+
3
+ const client = new Client()
4
+ .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
+
7
+ const organizations = new Organizations(client);
8
+
9
+ const result = await organizations.validatePayment(
10
+ '<ORGANIZATION_ID>', // organizationId
11
+ [] // invites (optional)
12
+ );
13
+
14
+ console.log(result);
@@ -1,4 +1,4 @@
1
- import { Client, Proxy, } from "@appwrite.io/console";
1
+ import { Client, Proxy, , ProxyResourceType } from "@appwrite.io/console";
2
2
 
3
3
  const client = new Client()
4
4
  .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
@@ -9,7 +9,9 @@ const proxy = new Proxy(client);
9
9
  const result = await proxy.createRedirectRule(
10
10
  '', // domain
11
11
  'https://example.com', // url
12
- .MovedPermanently301 // statusCode
12
+ .MovedPermanently301, // statusCode
13
+ '<RESOURCE_ID>', // resourceId
14
+ ProxyResourceType.Site // resourceType
13
15
  );
14
16
 
15
17
  console.log(result);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@appwrite.io/console",
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": "1.7.0",
5
+ "version": "1.9.0",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "dist/cjs/sdk.js",
8
8
  "exports": {
package/src/client.ts CHANGED
@@ -316,7 +316,7 @@ class Client {
316
316
  'x-sdk-name': 'Console',
317
317
  'x-sdk-platform': 'console',
318
318
  'x-sdk-language': 'web',
319
- 'x-sdk-version': '1.7.0',
319
+ 'x-sdk-version': '1.9.0',
320
320
  'X-Appwrite-Response-Format': '1.7.0',
321
321
  };
322
322
 
@@ -636,9 +636,12 @@ class Client {
636
636
  let options: RequestInit = {
637
637
  method,
638
638
  headers,
639
- credentials: 'include',
640
639
  };
641
640
 
641
+ if (headers['X-Appwrite-Dev-Key'] === undefined) {
642
+ options.credentials = 'include';
643
+ }
644
+
642
645
  if (method === 'GET') {
643
646
  for (const [key, value] of Object.entries(Client.flatten(params))) {
644
647
  url.searchParams.append(key, value);
@@ -674,9 +677,9 @@ class Client {
674
677
  }
675
678
 
676
679
  async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) {
677
- const file = Object.values(originalPayload).find((value) => value instanceof File);
680
+ const [fileParam, file] = Object.entries(originalPayload).find(([_, value]) => value instanceof File) ?? [];
678
681
 
679
- if (!file) {
682
+ if (!file || !fileParam) {
680
683
  throw new Error('File not found in payload');
681
684
  }
682
685
 
@@ -696,7 +699,8 @@ class Client {
696
699
  headers['content-range'] = `bytes ${start}-${end-1}/${file.size}`;
697
700
  const chunk = file.slice(start, end);
698
701
 
699
- let payload = { ...originalPayload, file: new File([chunk], file.name)};
702
+ let payload = { ...originalPayload };
703
+ payload[fileParam] = new File([chunk], file.name);
700
704
 
701
705
  response = await this.call(method, url, headers, payload);
702
706
 
@@ -33,6 +33,7 @@ export enum BuildRuntime {
33
33
  Dart31 = 'dart-3.1',
34
34
  Dart33 = 'dart-3.3',
35
35
  Dart35 = 'dart-3.5',
36
+ Dart38 = 'dart-3.8',
36
37
  Dotnet60 = 'dotnet-6.0',
37
38
  Dotnet70 = 'dotnet-7.0',
38
39
  Dotnet80 = 'dotnet-8.0',
@@ -59,4 +60,5 @@ export enum BuildRuntime {
59
60
  Flutter324 = 'flutter-3.24',
60
61
  Flutter327 = 'flutter-3.27',
61
62
  Flutter329 = 'flutter-3.29',
63
+ Flutter332 = 'flutter-3.32',
62
64
  }
@@ -5,4 +5,5 @@ export enum ImageFormat {
5
5
  Webp = 'webp',
6
6
  Heic = 'heic',
7
7
  Avif = 'avif',
8
+ Gif = 'gif',
8
9
  }
@@ -0,0 +1,4 @@
1
+ export enum ProxyResourceType {
2
+ Site = 'site',
3
+ Function = 'function',
4
+ }
@@ -33,6 +33,7 @@ export enum Runtime {
33
33
  Dart31 = 'dart-3.1',
34
34
  Dart33 = 'dart-3.3',
35
35
  Dart35 = 'dart-3.5',
36
+ Dart38 = 'dart-3.8',
36
37
  Dotnet60 = 'dotnet-6.0',
37
38
  Dotnet70 = 'dotnet-7.0',
38
39
  Dotnet80 = 'dotnet-8.0',
@@ -59,4 +60,5 @@ export enum Runtime {
59
60
  Flutter324 = 'flutter-3.24',
60
61
  Flutter327 = 'flutter-3.27',
61
62
  Flutter329 = 'flutter-3.29',
63
+ Flutter332 = 'flutter-3.32',
62
64
  }
package/src/index.ts CHANGED
@@ -66,6 +66,7 @@ export { EmailTemplateLocale } from './enums/email-template-locale';
66
66
  export { SmsTemplateType } from './enums/sms-template-type';
67
67
  export { SmsTemplateLocale } from './enums/sms-template-locale';
68
68
  export { StatusCode } from './enums/status-code';
69
+ export { ProxyResourceType } from './enums/proxy-resource-type';
69
70
  export { Framework } from './enums/framework';
70
71
  export { BuildRuntime } from './enums/build-runtime';
71
72
  export { Adapter } from './enums/adapter';