@appwrite.io/console 1.5.1 → 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 (66) hide show
  1. package/README.md +4 -4
  2. package/dist/cjs/sdk.js +7714 -9758
  3. package/dist/cjs/sdk.js.map +1 -1
  4. package/dist/esm/sdk.js +7714 -9758
  5. package/dist/esm/sdk.js.map +1 -1
  6. package/dist/iife/sdk.js +7714 -9758
  7. package/docs/examples/databases/update-float-attribute.md +2 -2
  8. package/docs/examples/databases/update-integer-attribute.md +2 -2
  9. package/docs/examples/health/{get-queue-usage-count.md → get-queue-stats-resources.md} +1 -1
  10. package/docs/examples/health/{get-queue-usage-dump.md → get-queue-stats-usage-dump.md} +1 -1
  11. package/docs/examples/organizations/create.md +5 -1
  12. package/docs/examples/organizations/update-plan.md +5 -1
  13. package/docs/examples/organizations/validate-invoice.md +14 -0
  14. package/package.json +1 -1
  15. package/src/client.ts +21 -4
  16. package/src/enums/credit-card.ts +1 -0
  17. package/src/enums/name.ts +3 -2
  18. package/src/enums/o-auth-provider.ts +1 -0
  19. package/src/enums/runtime.ts +3 -0
  20. package/src/models.ts +202 -5
  21. package/src/services/account.ts +126 -430
  22. package/src/services/assistant.ts +2 -7
  23. package/src/services/avatars.ts +7 -21
  24. package/src/services/backups.ts +24 -84
  25. package/src/services/console.ts +14 -49
  26. package/src/services/databases.ts +99 -350
  27. package/src/services/functions.ts +55 -192
  28. package/src/services/graphql.ts +4 -14
  29. package/src/services/health.ts +55 -207
  30. package/src/services/locale.ts +16 -56
  31. package/src/services/messaging.ts +92 -322
  32. package/src/services/migrations.ts +24 -84
  33. package/src/services/organizations.ts +118 -196
  34. package/src/services/project.ts +12 -42
  35. package/src/services/projects.ts +92 -322
  36. package/src/services/proxy.ts +10 -35
  37. package/src/services/storage.ts +27 -93
  38. package/src/services/teams.ts +28 -98
  39. package/src/services/users.ts +86 -301
  40. package/src/services/vcs.ts +20 -70
  41. package/types/enums/credit-card.d.ts +2 -1
  42. package/types/enums/name.d.ts +3 -2
  43. package/types/enums/o-auth-provider.d.ts +1 -0
  44. package/types/enums/runtime.d.ts +3 -0
  45. package/types/models.d.ts +202 -5
  46. package/types/services/account.d.ts +4 -128
  47. package/types/services/assistant.d.ts +0 -2
  48. package/types/services/avatars.d.ts +0 -14
  49. package/types/services/backups.d.ts +0 -24
  50. package/types/services/console.d.ts +0 -14
  51. package/types/services/databases.d.ts +5 -100
  52. package/types/services/functions.d.ts +0 -56
  53. package/types/services/graphql.d.ts +0 -4
  54. package/types/services/health.d.ts +5 -64
  55. package/types/services/locale.d.ts +0 -16
  56. package/types/services/messaging.d.ts +0 -92
  57. package/types/services/migrations.d.ts +0 -24
  58. package/types/services/organizations.d.ts +21 -60
  59. package/types/services/project.d.ts +0 -12
  60. package/types/services/projects.d.ts +0 -92
  61. package/types/services/proxy.d.ts +0 -10
  62. package/types/services/storage.d.ts +0 -30
  63. package/types/services/teams.d.ts +0 -28
  64. package/types/services/users.d.ts +0 -86
  65. package/types/services/vcs.d.ts +0 -20
  66. package/docs/examples/health/get-queue.md +0 -11
@@ -11,9 +11,9 @@ const result = await databases.updateFloatAttribute(
11
11
  '<COLLECTION_ID>', // collectionId
12
12
  '', // key
13
13
  false, // required
14
- null, // min
15
- null, // max
16
14
  null, // default
15
+ null, // min (optional)
16
+ null, // max (optional)
17
17
  '' // newKey (optional)
18
18
  );
19
19
 
@@ -11,9 +11,9 @@ const result = await databases.updateIntegerAttribute(
11
11
  '<COLLECTION_ID>', // collectionId
12
12
  '', // key
13
13
  false, // required
14
- null, // min
15
- null, // max
16
14
  null, // default
15
+ null, // min (optional)
16
+ null, // max (optional)
17
17
  '' // newKey (optional)
18
18
  );
19
19
 
@@ -6,7 +6,7 @@ const client = new Client()
6
6
 
7
7
  const health = new Health(client);
8
8
 
9
- const result = await health.getQueueUsageCount(
9
+ const result = await health.getQueueStatsResources(
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.getQueueUsageDump(
9
+ const result = await health.getQueueStatsUsageDump(
10
10
  null // threshold (optional)
11
11
  );
12
12
 
@@ -11,7 +11,11 @@ const result = await organizations.create(
11
11
  '<NAME>', // name
12
12
  .Tier0, // billingPlan
13
13
  '<PAYMENT_METHOD_ID>', // paymentMethodId (optional)
14
- '<BILLING_ADDRESS_ID>' // billingAddressId (optional)
14
+ '<BILLING_ADDRESS_ID>', // billingAddressId (optional)
15
+ [], // invites (optional)
16
+ '<COUPON_ID>', // couponId (optional)
17
+ '<TAX_ID>', // taxId (optional)
18
+ 0 // budget (optional)
15
19
  );
16
20
 
17
21
  console.log(result);
@@ -10,7 +10,11 @@ const result = await organizations.updatePlan(
10
10
  '<ORGANIZATION_ID>', // organizationId
11
11
  .Tier0, // billingPlan
12
12
  '<PAYMENT_METHOD_ID>', // paymentMethodId (optional)
13
- '<BILLING_ADDRESS_ID>' // billingAddressId (optional)
13
+ '<BILLING_ADDRESS_ID>', // billingAddressId (optional)
14
+ [], // invites (optional)
15
+ '<COUPON_ID>', // couponId (optional)
16
+ '<TAX_ID>', // taxId (optional)
17
+ 0 // budget (optional)
14
18
  );
15
19
 
16
20
  console.log(result);
@@ -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.1",
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.1',
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');
@@ -15,4 +15,5 @@ export enum CreditCard {
15
15
  Visa = 'visa',
16
16
  MIR = 'mir',
17
17
  Maestro = 'maestro',
18
+ Rupay = 'rupay',
18
19
  }
package/src/enums/name.ts CHANGED
@@ -4,8 +4,9 @@ export enum Name {
4
4
  V1audits = 'v1-audits',
5
5
  V1mails = 'v1-mails',
6
6
  V1functions = 'v1-functions',
7
- V1usage = 'v1-usage',
8
- V1usagedump = 'v1-usage-dump',
7
+ V1statsresources = 'v1-stats-resources',
8
+ V1statsusage = 'v1-stats-usage',
9
+ V1statsusagedump = 'v1-stats-usage-dump',
9
10
  V1webhooks = 'v1-webhooks',
10
11
  V1certificates = 'v1-certificates',
11
12
  V1builds = 'v1-builds',
@@ -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',
@@ -20,6 +20,9 @@ export enum Runtime {
20
20
  Python311 = 'python-3.11',
21
21
  Python312 = 'python-3.12',
22
22
  Pythonml311 = 'python-ml-3.11',
23
+ Deno121 = 'deno-1.21',
24
+ Deno124 = 'deno-1.24',
25
+ Deno135 = 'deno-1.35',
23
26
  Deno140 = 'deno-1.40',
24
27
  Deno146 = 'deno-1.46',
25
28
  Deno20 = 'deno-2.0',
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
@@ -3316,6 +3316,14 @@ export namespace Models {
3316
3316
  * Aggregated number of bucket storage files (in bytes) per period.
3317
3317
  */
3318
3318
  storage: Metric[];
3319
+ /**
3320
+ * Aggregated number of files transformations per period.
3321
+ */
3322
+ imageTransformations: Metric[];
3323
+ /**
3324
+ * Total aggregated number of files transformations.
3325
+ */
3326
+ imageTransformationsTotal: number;
3319
3327
  }
3320
3328
  /**
3321
3329
  * UsageFunctions
@@ -3607,6 +3615,14 @@ export namespace Models {
3607
3615
  * An array of aggregated number of database writes.
3608
3616
  */
3609
3617
  databasesWrites: Metric[];
3618
+ /**
3619
+ * An array of aggregated number of image transformations.
3620
+ */
3621
+ imageTransformations: Metric[];
3622
+ /**
3623
+ * Total aggregated number of image transformations.
3624
+ */
3625
+ imageTransformationsTotal: number;
3610
3626
  }
3611
3627
  /**
3612
3628
  * Headers
@@ -4254,6 +4270,10 @@ export namespace Models {
4254
4270
  * Additional realtime usage cost
4255
4271
  */
4256
4272
  additionalRealtimeAmount: number;
4273
+ /**
4274
+ * Billing plan
4275
+ */
4276
+ plan: string;
4257
4277
  /**
4258
4278
  * Aggregated amount
4259
4279
  */
@@ -4320,6 +4340,10 @@ export namespace Models {
4320
4340
  * Region ID
4321
4341
  */
4322
4342
  $id: string;
4343
+ /**
4344
+ * User ID
4345
+ */
4346
+ userId: string;
4323
4347
  /**
4324
4348
  * Street address
4325
4349
  */
@@ -4357,6 +4381,10 @@ export namespace Models {
4357
4381
  * Plan name
4358
4382
  */
4359
4383
  name: string;
4384
+ /**
4385
+ * Plan description
4386
+ */
4387
+ desc: string;
4360
4388
  /**
4361
4389
  * Plan order
4362
4390
  */
@@ -4377,6 +4405,10 @@ export namespace Models {
4377
4405
  * Storage
4378
4406
  */
4379
4407
  storage: number;
4408
+ /**
4409
+ * Image Transformations
4410
+ */
4411
+ imageTransformations: number;
4380
4412
  /**
4381
4413
  * Members
4382
4414
  */
@@ -4428,7 +4460,11 @@ export namespace Models {
4428
4460
  /**
4429
4461
  * Additional resources
4430
4462
  */
4431
- addons: AdditionalResource;
4463
+ usage: UsageBillingPlan;
4464
+ /**
4465
+ * Addons
4466
+ */
4467
+ addons: BillingPlanAddon;
4432
4468
  /**
4433
4469
  * Custom SMTP
4434
4470
  */
@@ -4465,6 +4501,10 @@ export namespace Models {
4465
4501
  * Does plan support mock numbers
4466
4502
  */
4467
4503
  supportsMockNumbers: boolean;
4504
+ /**
4505
+ * Does plan support credit
4506
+ */
4507
+ supportsCredits: boolean;
4468
4508
  /**
4469
4509
  * Does plan support backup policies.
4470
4510
  */
@@ -4474,6 +4514,77 @@ export namespace Models {
4474
4514
  */
4475
4515
  backupPolicies: number;
4476
4516
  }
4517
+ /**
4518
+ * BillingPlanAddon
4519
+ */
4520
+ export type BillingPlanAddon = {
4521
+ /**
4522
+ * Addon seats
4523
+ */
4524
+ seats: BillingPlanAddonDetails;
4525
+ }
4526
+ /**
4527
+ * BillingPlanAddonDetails
4528
+ */
4529
+ export type BillingPlanAddonDetails = {
4530
+ /**
4531
+ * Is the addon supported in the plan?
4532
+ */
4533
+ supported: boolean;
4534
+ /**
4535
+ * Addon limit
4536
+ */
4537
+ limit: number;
4538
+ /**
4539
+ * Addon type
4540
+ */
4541
+ type: string;
4542
+ /**
4543
+ * Price currency
4544
+ */
4545
+ currency: string;
4546
+ /**
4547
+ * Price
4548
+ */
4549
+ price: number;
4550
+ /**
4551
+ * Resource value
4552
+ */
4553
+ value: number;
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
+ }
4477
4588
  /**
4478
4589
  * Campaign
4479
4590
  */
@@ -4559,6 +4670,10 @@ export namespace Models {
4559
4670
  * Status of the coupon. Can be one of `disabled`, `active` or `expired`.
4560
4671
  */
4561
4672
  status: string;
4673
+ /**
4674
+ * If the coupon is only valid for new organizations or not.
4675
+ */
4676
+ onlyNewOrgs: boolean;
4562
4677
  }
4563
4678
  /**
4564
4679
  * Credit
@@ -4661,7 +4776,7 @@ export namespace Models {
4661
4776
  /**
4662
4777
  * Usage breakdown per resource
4663
4778
  */
4664
- usage: object;
4779
+ usage: UsageInvoice[];
4665
4780
  /**
4666
4781
  * Invoice Amount
4667
4782
  */
@@ -4787,6 +4902,10 @@ export namespace Models {
4787
4902
  * Current active aggregation id.
4788
4903
  */
4789
4904
  billingAggregationId: string;
4905
+ /**
4906
+ * Current active aggregation id.
4907
+ */
4908
+ billingInvoiceId: string;
4790
4909
  /**
4791
4910
  * Default payment method.
4792
4911
  */
@@ -4799,6 +4918,14 @@ export namespace Models {
4799
4918
  * Backup payment method.
4800
4919
  */
4801
4920
  backupPaymentMethodId: string;
4921
+ /**
4922
+ * Team status.
4923
+ */
4924
+ status: string;
4925
+ /**
4926
+ * Remarks on team status.
4927
+ */
4928
+ remarks: string;
4802
4929
  /**
4803
4930
  * Organization agreements
4804
4931
  */
@@ -4822,7 +4949,7 @@ export namespace Models {
4822
4949
  /**
4823
4950
  * Billing limits reached
4824
4951
  */
4825
- billingLimits: object;
4952
+ billingLimits: BillingLimits;
4826
4953
  /**
4827
4954
  * Billing plan downgrade
4828
4955
  */
@@ -5098,6 +5225,14 @@ export namespace Models {
5098
5225
  * Aggregated stats for database writes.
5099
5226
  */
5100
5227
  databasesWrites: Metric[];
5228
+ /**
5229
+ * Aggregated stats for file transformations.
5230
+ */
5231
+ imageTransformations: Metric[];
5232
+ /**
5233
+ * Aggregated stats for total file transformations.
5234
+ */
5235
+ imageTransformationsTotal: number;
5101
5236
  /**
5102
5237
  * Aggregated stats for total users.
5103
5238
  */
@@ -5200,6 +5335,68 @@ export namespace Models {
5200
5335
  */
5201
5336
  authPhoneEstimate: number;
5202
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
+ }
5203
5400
  /**
5204
5401
  * Aggregation team list
5205
5402
  */