@appwrite.io/console 1.5.2 → 1.6.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 (53) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/sdk.js +7673 -9723
  3. package/dist/cjs/sdk.js.map +1 -1
  4. package/dist/esm/sdk.js +7673 -9723
  5. package/dist/esm/sdk.js.map +1 -1
  6. package/dist/iife/sdk.js +7673 -9723
  7. package/docs/examples/organizations/validate-invoice.md +14 -0
  8. package/package.json +1 -1
  9. package/src/client.ts +21 -4
  10. package/src/enums/o-auth-provider.ts +1 -0
  11. package/src/models.ts +118 -6
  12. package/src/services/account.ts +126 -430
  13. package/src/services/assistant.ts +2 -7
  14. package/src/services/avatars.ts +7 -21
  15. package/src/services/backups.ts +24 -84
  16. package/src/services/console.ts +14 -49
  17. package/src/services/databases.ts +96 -336
  18. package/src/services/functions.ts +55 -192
  19. package/src/services/graphql.ts +4 -14
  20. package/src/services/health.ts +50 -175
  21. package/src/services/locale.ts +16 -56
  22. package/src/services/messaging.ts +92 -322
  23. package/src/services/migrations.ts +24 -84
  24. package/src/services/organizations.ts +86 -196
  25. package/src/services/project.ts +12 -42
  26. package/src/services/projects.ts +92 -322
  27. package/src/services/proxy.ts +10 -35
  28. package/src/services/storage.ts +27 -93
  29. package/src/services/teams.ts +28 -98
  30. package/src/services/users.ts +86 -301
  31. package/src/services/vcs.ts +20 -70
  32. package/types/enums/o-auth-provider.d.ts +1 -0
  33. package/types/models.d.ts +118 -6
  34. package/types/services/account.d.ts +4 -128
  35. package/types/services/assistant.d.ts +0 -2
  36. package/types/services/avatars.d.ts +0 -14
  37. package/types/services/backups.d.ts +0 -24
  38. package/types/services/console.d.ts +0 -14
  39. package/types/services/databases.d.ts +0 -96
  40. package/types/services/functions.d.ts +0 -56
  41. package/types/services/graphql.d.ts +0 -4
  42. package/types/services/health.d.ts +0 -50
  43. package/types/services/locale.d.ts +0 -16
  44. package/types/services/messaging.d.ts +0 -92
  45. package/types/services/migrations.d.ts +0 -24
  46. package/types/services/organizations.d.ts +11 -58
  47. package/types/services/project.d.ts +0 -12
  48. package/types/services/projects.d.ts +0 -92
  49. package/types/services/proxy.d.ts +0 -10
  50. package/types/services/storage.d.ts +0 -30
  51. package/types/services/teams.d.ts +0 -28
  52. package/types/services/users.d.ts +0 -86
  53. package/types/services/vcs.d.ts +0 -20
@@ -0,0 +1,14 @@
1
+ import { Client, Organizations } from "@appwrite.io/console";
2
+
3
+ const client = new Client()
4
+ .setEndpoint('https://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.validateInvoice(
10
+ '<ORGANIZATION_ID>', // organizationId
11
+ '<INVOICE_ID>' // invoiceId
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 abstract and simplify complex and repetitive development tasks behind a very simple REST API",
5
- "version": "1.5.2",
5
+ "version": "1.6.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.5.2',
319
+ 'x-sdk-version': '1.6.0',
320
320
  'X-Appwrite-Response-Format': '1.6.0',
321
321
  };
322
322
 
@@ -330,8 +330,12 @@ class Client {
330
330
  * @returns {this}
331
331
  */
332
332
  setEndpoint(endpoint: string): this {
333
+ if (!endpoint.startsWith('http://') && !endpoint.startsWith('https://')) {
334
+ throw new AppwriteException('Invalid endpoint URL: ' + endpoint);
335
+ }
336
+
333
337
  this.config.endpoint = endpoint;
334
- this.config.endpointRealtime = this.config.endpointRealtime || this.config.endpoint.replace('https://', 'wss://').replace('http://', 'ws://');
338
+ this.config.endpointRealtime = endpoint.replace('https://', 'wss://').replace('http://', 'ws://');
335
339
 
336
340
  return this;
337
341
  }
@@ -344,8 +348,11 @@ class Client {
344
348
  * @returns {this}
345
349
  */
346
350
  setEndpointRealtime(endpointRealtime: string): this {
347
- this.config.endpointRealtime = endpointRealtime;
351
+ if (!endpointRealtime.startsWith('ws://') && !endpointRealtime.startsWith('wss://')) {
352
+ throw new AppwriteException('Invalid realtime endpoint URL: ' + endpointRealtime);
353
+ }
348
354
 
355
+ this.config.endpointRealtime = endpointRealtime;
349
356
  return this;
350
357
  }
351
358
 
@@ -669,6 +676,10 @@ class Client {
669
676
  async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) {
670
677
  const file = Object.values(originalPayload).find((value) => value instanceof File);
671
678
 
679
+ if (!file) {
680
+ throw new Error('File not found in payload');
681
+ }
682
+
672
683
  if (file.size <= Client.CHUNK_SIZE) {
673
684
  return await this.call(method, url, headers, originalPayload);
674
685
  }
@@ -736,7 +747,13 @@ class Client {
736
747
  }
737
748
 
738
749
  if (400 <= response.status) {
739
- throw new AppwriteException(data?.message, response.status, data?.type, data);
750
+ let responseText = '';
751
+ if (response.headers.get('content-type')?.includes('application/json') || responseType === 'arrayBuffer') {
752
+ responseText = JSON.stringify(data);
753
+ } else {
754
+ responseText = data?.message;
755
+ }
756
+ throw new AppwriteException(data?.message, response.status, data?.type, responseText);
740
757
  }
741
758
 
742
759
  const cookieFallback = response.headers.get('X-Fallback-Cookies');
@@ -13,6 +13,7 @@ export enum OAuthProvider {
13
13
  Dropbox = 'dropbox',
14
14
  Etsy = 'etsy',
15
15
  Facebook = 'facebook',
16
+ Figma = 'figma',
16
17
  Github = 'github',
17
18
  Gitlab = 'gitlab',
18
19
  Google = 'google',
package/src/models.ts CHANGED
@@ -594,7 +594,7 @@ export namespace Models {
594
594
  /**
595
595
  * Collection attributes.
596
596
  */
597
- attributes: string[];
597
+ attributes: (Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributeString)[];
598
598
  /**
599
599
  * Collection indexes.
600
600
  */
@@ -611,7 +611,7 @@ export namespace Models {
611
611
  /**
612
612
  * List of attributes.
613
613
  */
614
- attributes: string[];
614
+ attributes: (Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributeString)[];
615
615
  }
616
616
  /**
617
617
  * AttributeString
@@ -4340,6 +4340,10 @@ export namespace Models {
4340
4340
  * Region ID
4341
4341
  */
4342
4342
  $id: string;
4343
+ /**
4344
+ * User ID
4345
+ */
4346
+ userId: string;
4343
4347
  /**
4344
4348
  * Street address
4345
4349
  */
@@ -4456,11 +4460,11 @@ export namespace Models {
4456
4460
  /**
4457
4461
  * Additional resources
4458
4462
  */
4459
- usage: AdditionalResource[];
4463
+ usage: UsageBillingPlan;
4460
4464
  /**
4461
4465
  * Addons
4462
4466
  */
4463
- addons: BillingPlanAddon[];
4467
+ addons: BillingPlanAddon;
4464
4468
  /**
4465
4469
  * Custom SMTP
4466
4470
  */
@@ -4514,6 +4518,15 @@ export namespace Models {
4514
4518
  * BillingPlanAddon
4515
4519
  */
4516
4520
  export type BillingPlanAddon = {
4521
+ /**
4522
+ * Addon seats
4523
+ */
4524
+ seats: BillingPlanAddonDetails;
4525
+ }
4526
+ /**
4527
+ * BillingPlanAddonDetails
4528
+ */
4529
+ export type BillingPlanAddonDetails = {
4517
4530
  /**
4518
4531
  * Is the addon supported in the plan?
4519
4532
  */
@@ -4539,6 +4552,39 @@ export namespace Models {
4539
4552
  */
4540
4553
  value: number;
4541
4554
  }
4555
+ /**
4556
+ * BillingLimits
4557
+ */
4558
+ export type BillingLimits = {
4559
+ /**
4560
+ * Bandwidth limit
4561
+ */
4562
+ bandwidth: number;
4563
+ /**
4564
+ * Storage limit
4565
+ */
4566
+ storage: number;
4567
+ /**
4568
+ * Users limit
4569
+ */
4570
+ users: number;
4571
+ /**
4572
+ * Executions limit
4573
+ */
4574
+ executions: number;
4575
+ /**
4576
+ * GBHours limit
4577
+ */
4578
+ GBHours: number;
4579
+ /**
4580
+ * Image transformations limit
4581
+ */
4582
+ imageTransformations: number;
4583
+ /**
4584
+ * Auth phone limit
4585
+ */
4586
+ authPhone: number;
4587
+ }
4542
4588
  /**
4543
4589
  * Campaign
4544
4590
  */
@@ -4624,6 +4670,10 @@ export namespace Models {
4624
4670
  * Status of the coupon. Can be one of `disabled`, `active` or `expired`.
4625
4671
  */
4626
4672
  status: string;
4673
+ /**
4674
+ * If the coupon is only valid for new organizations or not.
4675
+ */
4676
+ onlyNewOrgs: boolean;
4627
4677
  }
4628
4678
  /**
4629
4679
  * Credit
@@ -4726,7 +4776,7 @@ export namespace Models {
4726
4776
  /**
4727
4777
  * Usage breakdown per resource
4728
4778
  */
4729
- usage: object;
4779
+ usage: UsageInvoice[];
4730
4780
  /**
4731
4781
  * Invoice Amount
4732
4782
  */
@@ -4899,7 +4949,7 @@ export namespace Models {
4899
4949
  /**
4900
4950
  * Billing limits reached
4901
4951
  */
4902
- billingLimits: object;
4952
+ billingLimits: BillingLimits;
4903
4953
  /**
4904
4954
  * Billing plan downgrade
4905
4955
  */
@@ -5285,6 +5335,68 @@ export namespace Models {
5285
5335
  */
5286
5336
  authPhoneEstimate: number;
5287
5337
  }
5338
+ /**
5339
+ * UsageInvoice
5340
+ */
5341
+ export type UsageInvoice = {
5342
+ /**
5343
+ * Invoice name
5344
+ */
5345
+ name: string;
5346
+ /**
5347
+ * Invoice value
5348
+ */
5349
+ value: number;
5350
+ /**
5351
+ * Invoice amount
5352
+ */
5353
+ amount: number;
5354
+ /**
5355
+ * Invoice rate
5356
+ */
5357
+ rate: number;
5358
+ /**
5359
+ * Invoice description
5360
+ */
5361
+ desc: string;
5362
+ }
5363
+ /**
5364
+ * usageBillingPlan
5365
+ */
5366
+ export type UsageBillingPlan = {
5367
+ /**
5368
+ * Bandwidth additional resources
5369
+ */
5370
+ bandwidth: AdditionalResource;
5371
+ /**
5372
+ * Executions additional resources
5373
+ */
5374
+ executions: AdditionalResource;
5375
+ /**
5376
+ * Member additional resources
5377
+ */
5378
+ member: AdditionalResource;
5379
+ /**
5380
+ * Realtime additional resources
5381
+ */
5382
+ realtime: AdditionalResource;
5383
+ /**
5384
+ * Storage additional resources
5385
+ */
5386
+ storage: AdditionalResource;
5387
+ /**
5388
+ * User additional resources
5389
+ */
5390
+ users: AdditionalResource;
5391
+ /**
5392
+ * GBHour additional resources
5393
+ */
5394
+ GBHours: AdditionalResource;
5395
+ /**
5396
+ * Image transformation additional resources
5397
+ */
5398
+ imageTransformations: AdditionalResource;
5399
+ }
5288
5400
  /**
5289
5401
  * Aggregation team list
5290
5402
  */