@appwrite.io/console 2.1.0 → 2.1.2

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 (46) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +2 -2
  3. package/dist/cjs/sdk.js +153 -22
  4. package/dist/cjs/sdk.js.map +1 -1
  5. package/dist/esm/sdk.js +150 -23
  6. package/dist/esm/sdk.js.map +1 -1
  7. package/dist/iife/sdk.js +3910 -22
  8. package/docs/examples/domains/list-suggestions.md +18 -0
  9. package/docs/examples/health/get-queue-audits.md +13 -0
  10. package/docs/examples/organizations/create.md +2 -2
  11. package/docs/examples/organizations/estimation-create-organization.md +2 -2
  12. package/docs/examples/organizations/estimation-update-plan.md +2 -2
  13. package/docs/examples/organizations/update-plan.md +2 -2
  14. package/docs/examples/projects/update-labels.md +14 -0
  15. package/package.json +7 -1
  16. package/rollup.config.js +40 -24
  17. package/src/client.ts +20 -10
  18. package/src/enums/billing-plan.ts +17 -0
  19. package/src/enums/filter-type.ts +4 -0
  20. package/src/enums/name.ts +1 -0
  21. package/src/enums/o-auth-provider.ts +0 -2
  22. package/src/index.ts +2 -0
  23. package/src/models.ts +129 -59
  24. package/src/query.ts +14 -11
  25. package/src/services/databases.ts +30 -30
  26. package/src/services/domains.ts +91 -0
  27. package/src/services/health.ts +55 -6
  28. package/src/services/organizations.ts +37 -36
  29. package/src/services/projects.ts +65 -2
  30. package/src/services/storage.ts +4 -4
  31. package/src/services/tables-db.ts +30 -30
  32. package/types/client.d.ts +8 -1
  33. package/types/enums/billing-plan.d.ts +17 -0
  34. package/types/enums/filter-type.d.ts +4 -0
  35. package/types/enums/name.d.ts +1 -0
  36. package/types/enums/o-auth-provider.d.ts +0 -2
  37. package/types/index.d.ts +2 -0
  38. package/types/models.d.ts +126 -59
  39. package/types/query.d.ts +8 -8
  40. package/types/services/databases.d.ts +20 -20
  41. package/types/services/domains.d.ts +35 -0
  42. package/types/services/health.d.ts +23 -6
  43. package/types/services/organizations.d.ts +17 -16
  44. package/types/services/projects.d.ts +24 -2
  45. package/types/services/storage.d.ts +4 -4
  46. package/types/services/tables-db.d.ts +20 -20
@@ -0,0 +1,18 @@
1
+ import { Client, Domains, FilterType } 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 domains = new Domains(client);
8
+
9
+ const result = await domains.listSuggestions({
10
+ query: '<QUERY>',
11
+ tlds: [], // optional
12
+ limit: null, // optional
13
+ filterType: FilterType.Premium, // optional
14
+ priceMax: null, // optional
15
+ priceMin: null // optional
16
+ });
17
+
18
+ console.log(result);
@@ -0,0 +1,13 @@
1
+ import { Client, Health } 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 health = new Health(client);
8
+
9
+ const result = await health.getQueueAudits({
10
+ threshold: null // optional
11
+ });
12
+
13
+ console.log(result);
@@ -1,4 +1,4 @@
1
- import { Client, Organizations, Platform } from "@appwrite.io/console";
1
+ import { Client, Organizations, BillingPlan, Platform } 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,7 @@ const organizations = new Organizations(client);
9
9
  const result = await organizations.create({
10
10
  organizationId: '<ORGANIZATION_ID>',
11
11
  name: '<NAME>',
12
- billingPlan: 'tier-0',
12
+ billingPlan: BillingPlan.Tier0,
13
13
  paymentMethodId: '<PAYMENT_METHOD_ID>', // optional
14
14
  billingAddressId: '<BILLING_ADDRESS_ID>', // optional
15
15
  invites: [], // optional
@@ -1,4 +1,4 @@
1
- import { Client, Organizations, Platform } from "@appwrite.io/console";
1
+ import { Client, Organizations, BillingPlan, Platform } from "@appwrite.io/console";
2
2
 
3
3
  const client = new Client()
4
4
  .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
@@ -7,7 +7,7 @@ const client = new Client()
7
7
  const organizations = new Organizations(client);
8
8
 
9
9
  const result = await organizations.estimationCreateOrganization({
10
- billingPlan: 'tier-0',
10
+ billingPlan: BillingPlan.Tier0,
11
11
  paymentMethodId: '<PAYMENT_METHOD_ID>', // optional
12
12
  invites: [], // optional
13
13
  couponId: '<COUPON_ID>', // optional
@@ -1,4 +1,4 @@
1
- import { Client, Organizations } from "@appwrite.io/console";
1
+ import { Client, Organizations, BillingPlan } from "@appwrite.io/console";
2
2
 
3
3
  const client = new Client()
4
4
  .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
@@ -8,7 +8,7 @@ const organizations = new Organizations(client);
8
8
 
9
9
  const result = await organizations.estimationUpdatePlan({
10
10
  organizationId: '<ORGANIZATION_ID>',
11
- billingPlan: 'tier-0',
11
+ billingPlan: BillingPlan.Tier0,
12
12
  invites: [], // optional
13
13
  couponId: '<COUPON_ID>' // optional
14
14
  });
@@ -1,4 +1,4 @@
1
- import { Client, Organizations } from "@appwrite.io/console";
1
+ import { Client, Organizations, BillingPlan } from "@appwrite.io/console";
2
2
 
3
3
  const client = new Client()
4
4
  .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
@@ -8,7 +8,7 @@ const organizations = new Organizations(client);
8
8
 
9
9
  const result = await organizations.updatePlan({
10
10
  organizationId: '<ORGANIZATION_ID>',
11
- billingPlan: 'tier-0',
11
+ billingPlan: BillingPlan.Tier0,
12
12
  paymentMethodId: '<PAYMENT_METHOD_ID>', // optional
13
13
  billingAddressId: '<BILLING_ADDRESS_ID>', // optional
14
14
  invites: [], // optional
@@ -0,0 +1,14 @@
1
+ import { Client, Projects } 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 projects = new Projects(client);
8
+
9
+ const result = await projects.updateLabels({
10
+ projectId: '<PROJECT_ID>',
11
+ labels: []
12
+ });
13
+
14
+ 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 abstracts and simplifies complex and repetitive development tasks behind a very simple REST API",
5
- "version": "2.1.0",
5
+ "version": "2.1.2",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "dist/cjs/sdk.js",
8
8
  "exports": {
@@ -24,8 +24,14 @@
24
24
  "build:types": "tsc --declaration --emitDeclarationOnly --outDir types",
25
25
  "build:libs": "rollup -c"
26
26
  },
27
+ "dependencies": {
28
+ "json-bigint": "1.0.0"
29
+ },
27
30
  "devDependencies": {
31
+ "@rollup/plugin-commonjs": "22.0.0",
32
+ "@rollup/plugin-node-resolve": "13.3.0",
28
33
  "@rollup/plugin-typescript": "8.3.2",
34
+ "@types/json-bigint": "1.0.4",
29
35
  "playwright": "1.56.1",
30
36
  "rollup": "2.79.2",
31
37
  "serve-handler": "6.1.0",
package/rollup.config.js CHANGED
@@ -1,27 +1,43 @@
1
1
  import pkg from "./package.json";
2
2
  import typescript from "@rollup/plugin-typescript";
3
+ import resolve from "@rollup/plugin-node-resolve";
4
+ import commonjs from "@rollup/plugin-commonjs";
3
5
 
4
- export default {
5
- external: Object.keys(pkg.dependencies ?? {}),
6
- input: "src/index.ts",
7
- plugins: [typescript()],
8
- output: [
9
- {
10
- format: "cjs",
11
- file: pkg.main,
12
- esModule: false,
13
- sourcemap: true,
14
- },
15
- {
16
- format: "es",
17
- file: pkg.module,
18
- sourcemap: true,
19
- },
20
- {
21
- format: "iife",
22
- file: pkg.jsdelivr,
23
- name: "Appwrite",
24
- extend: true,
25
- },
26
- ],
27
- };
6
+ const external = Object.keys(pkg.dependencies ?? {});
7
+
8
+ export default [
9
+ {
10
+ input: "src/index.ts",
11
+ external,
12
+ plugins: [typescript()],
13
+ output: [
14
+ {
15
+ format: "cjs",
16
+ file: pkg.main,
17
+ esModule: false,
18
+ sourcemap: true,
19
+ },
20
+ {
21
+ format: "es",
22
+ file: pkg.module,
23
+ sourcemap: true,
24
+ },
25
+ ],
26
+ },
27
+ {
28
+ input: "src/index.ts",
29
+ plugins: [
30
+ resolve({ browser: true }),
31
+ commonjs(),
32
+ typescript()
33
+ ],
34
+ output: [
35
+ {
36
+ format: "iife",
37
+ file: pkg.jsdelivr,
38
+ name: "Appwrite",
39
+ extend: true,
40
+ },
41
+ ],
42
+ }
43
+ ];
package/src/client.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { Models } from './models';
2
+ import JSONbigModule from 'json-bigint';
3
+ const JSONbig = JSONbigModule({ useNativeBigInt: true });
2
4
 
3
5
  /**
4
6
  * Payload type representing a key-value pair with string keys and any values.
@@ -303,12 +305,18 @@ class Client {
303
305
  config: {
304
306
  endpoint: string;
305
307
  endpointRealtime: string;
308
+ project: string;
309
+ key: string;
310
+ jwt: string;
311
+ locale: string;
312
+ mode: string;
313
+ cookie: string;
314
+ platform: string;
306
315
  selfSigned: boolean;
307
- [key: string]: string | boolean | undefined;
316
+ session?: string;
308
317
  } = {
309
318
  endpoint: 'https://cloud.appwrite.io/v1',
310
319
  endpointRealtime: '',
311
- selfSigned: false,
312
320
  project: '',
313
321
  key: '',
314
322
  jwt: '',
@@ -316,6 +324,8 @@ class Client {
316
324
  mode: '',
317
325
  cookie: '',
318
326
  platform: '',
327
+ selfSigned: false,
328
+ session: undefined,
319
329
  };
320
330
  /**
321
331
  * Custom headers for API requests.
@@ -324,7 +334,7 @@ class Client {
324
334
  'x-sdk-name': 'Console',
325
335
  'x-sdk-platform': 'console',
326
336
  'x-sdk-language': 'web',
327
- 'x-sdk-version': '2.1.0',
337
+ 'x-sdk-version': '2.1.2',
328
338
  'X-Appwrite-Response-Format': '1.8.0',
329
339
  };
330
340
 
@@ -514,7 +524,7 @@ class Client {
514
524
  }
515
525
 
516
526
  this.realtime.heartbeat = window?.setInterval(() => {
517
- this.realtime.socket?.send(JSON.stringify({
527
+ this.realtime.socket?.send(JSONbig.stringify({
518
528
  type: 'ping'
519
529
  }));
520
530
  }, 20_000);
@@ -580,19 +590,19 @@ class Client {
580
590
  },
581
591
  onMessage: (event) => {
582
592
  try {
583
- const message: RealtimeResponse = JSON.parse(event.data);
593
+ const message: RealtimeResponse = JSONbig.parse(event.data);
584
594
  this.realtime.lastMessage = message;
585
595
  switch (message.type) {
586
596
  case 'connected':
587
597
  let session = this.config.session;
588
598
  if (!session) {
589
- const cookie = JSON.parse(window.localStorage.getItem('cookieFallback') ?? '{}');
599
+ const cookie = JSONbig.parse(window.localStorage.getItem('cookieFallback') ?? '{}');
590
600
  session = cookie?.[`a_session_${this.config.project}`];
591
601
  }
592
602
 
593
603
  const messageData = <RealtimeResponseConnected>message.data;
594
604
  if (session && !messageData.user) {
595
- this.realtime.socket?.send(JSON.stringify(<RealtimeRequest>{
605
+ this.realtime.socket?.send(JSONbig.stringify(<RealtimeRequest>{
596
606
  type: 'authentication',
597
607
  data: {
598
608
  session
@@ -713,7 +723,7 @@ class Client {
713
723
  } else {
714
724
  switch (headers['content-type']) {
715
725
  case 'application/json':
716
- options.body = JSON.stringify(params);
726
+ options.body = JSONbig.stringify(params);
717
727
  break;
718
728
 
719
729
  case 'multipart/form-data':
@@ -815,7 +825,7 @@ class Client {
815
825
  }
816
826
 
817
827
  if (response.headers.get('content-type')?.includes('application/json')) {
818
- data = await response.json();
828
+ data = JSONbig.parse(await response.text());
819
829
  } else if (responseType === 'arrayBuffer') {
820
830
  data = await response.arrayBuffer();
821
831
  } else {
@@ -827,7 +837,7 @@ class Client {
827
837
  if (400 <= response.status) {
828
838
  let responseText = '';
829
839
  if (response.headers.get('content-type')?.includes('application/json') || responseType === 'arrayBuffer') {
830
- responseText = JSON.stringify(data);
840
+ responseText = JSONbig.stringify(data);
831
841
  } else {
832
842
  responseText = data?.message;
833
843
  }
@@ -0,0 +1,17 @@
1
+ export enum BillingPlan {
2
+ Tier0 = 'tier-0',
3
+ Tier1 = 'tier-1',
4
+ Tier2 = 'tier-2',
5
+ Imaginetier0 = 'imagine-tier-0',
6
+ Imaginetier1 = 'imagine-tier-1',
7
+ Imaginetier150 = 'imagine-tier-1-50',
8
+ Imaginetier1100 = 'imagine-tier-1-100',
9
+ Imaginetier1200 = 'imagine-tier-1-200',
10
+ Imaginetier1290 = 'imagine-tier-1-290',
11
+ Imaginetier1480 = 'imagine-tier-1-480',
12
+ Imaginetier1700 = 'imagine-tier-1-700',
13
+ Imaginetier1900 = 'imagine-tier-1-900',
14
+ Imaginetier11100 = 'imagine-tier-1-1100',
15
+ Imaginetier11650 = 'imagine-tier-1-1650',
16
+ Imaginetier12200 = 'imagine-tier-1-2200',
17
+ }
@@ -0,0 +1,4 @@
1
+ export enum FilterType {
2
+ Premium = 'premium',
3
+ Suggestion = 'suggestion',
4
+ }
package/src/enums/name.ts CHANGED
@@ -9,6 +9,7 @@ export enum Name {
9
9
  V1webhooks = 'v1-webhooks',
10
10
  V1certificates = 'v1-certificates',
11
11
  V1builds = 'v1-builds',
12
+ V1screenshots = 'v1-screenshots',
12
13
  V1messaging = 'v1-messaging',
13
14
  V1migrations = 'v1-migrations',
14
15
  }
@@ -38,8 +38,6 @@ export enum OAuthProvider {
38
38
  Yandex = 'yandex',
39
39
  Zoho = 'zoho',
40
40
  Zoom = 'zoom',
41
- Mock = 'mock',
42
- Mockunverified = 'mock-unverified',
43
41
  GithubImagine = 'githubImagine',
44
42
  GoogleImagine = 'googleImagine',
45
43
  }
package/src/index.ts CHANGED
@@ -52,6 +52,7 @@ export { UsageRange } from './enums/usage-range';
52
52
  export { RelationshipType } from './enums/relationship-type';
53
53
  export { RelationMutate } from './enums/relation-mutate';
54
54
  export { IndexType } from './enums/index-type';
55
+ export { FilterType } from './enums/filter-type';
55
56
  export { Runtime } from './enums/runtime';
56
57
  export { TemplateReferenceType } from './enums/template-reference-type';
57
58
  export { VCSReferenceType } from './enums/vcs-reference-type';
@@ -60,6 +61,7 @@ export { ExecutionMethod } from './enums/execution-method';
60
61
  export { Name } from './enums/name';
61
62
  export { MessagePriority } from './enums/message-priority';
62
63
  export { SmtpEncryption } from './enums/smtp-encryption';
64
+ export { BillingPlan } from './enums/billing-plan';
63
65
  export { ProjectUsageRange } from './enums/project-usage-range';
64
66
  export { Region } from './enums/region';
65
67
  export { Api } from './enums/api';