@appwrite.io/console 18.1.0 → 18.3.0-rc.1

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 (44) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/sdk.js +1876 -259
  3. package/dist/cjs/sdk.js.map +1 -1
  4. package/dist/esm/sdk.js +1872 -257
  5. package/dist/esm/sdk.js.map +1 -1
  6. package/dist/iife/sdk.js +6294 -4654
  7. package/package.json +2 -2
  8. package/types/client.d.ts +4 -1
  9. package/types/enums/analytics-dimension.d.ts +24 -0
  10. package/types/enums/analytics-interval.d.ts +6 -0
  11. package/types/enums/build-runtime.d.ts +3 -0
  12. package/types/enums/o-auth-provider.d.ts +1 -0
  13. package/types/enums/project-key-scopes.d.ts +4 -1
  14. package/types/enums/project-o-auth-provider-id.d.ts +1 -0
  15. package/types/enums/proxy-rule-deployment-resource-type.d.ts +2 -1
  16. package/types/enums/query-suggestion-resource.d.ts +1 -0
  17. package/types/enums/runtime.d.ts +3 -0
  18. package/types/enums/usage-event-dimension.d.ts +9 -0
  19. package/types/enums/usage-event-metric.d.ts +4 -0
  20. package/types/enums/usage-gauge-metric.d.ts +1 -0
  21. package/types/index.d.ts +5 -0
  22. package/types/models.d.ts +285 -15
  23. package/types/services/account.d.ts +37 -10
  24. package/types/services/analytics-tracking.d.ts +211 -0
  25. package/types/services/analytics.d.ts +254 -0
  26. package/types/services/avatars.d.ts +33 -5
  27. package/types/services/console.d.ts +39 -3
  28. package/types/services/databases.d.ts +4 -1
  29. package/types/services/documents-db.d.ts +4 -1
  30. package/types/services/functions.d.ts +17 -2
  31. package/types/services/locale.d.ts +91 -7
  32. package/types/services/messaging.d.ts +40 -34
  33. package/types/services/notifications.d.ts +4 -1
  34. package/types/services/project.d.ts +29 -4
  35. package/types/services/proxy.d.ts +4 -0
  36. package/types/services/push.d.ts +26 -4
  37. package/types/services/sites.d.ts +21 -3
  38. package/types/services/tables-db.d.ts +4 -1
  39. package/types/services/teams.d.ts +2 -2
  40. package/types/services/usage.d.ts +4 -4
  41. package/types/services/vcs.d.ts +12 -3
  42. package/types/services/vectors-db.d.ts +4 -1
  43. package/types/services/webhooks.d.ts +2 -2
  44. package/types/service.d.ts +0 -11
package/dist/cjs/sdk.js CHANGED
@@ -1,8 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var JSONbigModule = require('json-bigint');
4
- var buffer = require('buffer');
5
- var mqtt = require('mqtt');
6
4
 
7
5
  /******************************************************************************
8
6
  Copyright (c) Microsoft Corporation.
@@ -671,7 +669,7 @@ class Client {
671
669
  'x-sdk-name': 'Console',
672
670
  'x-sdk-platform': 'console',
673
671
  'x-sdk-language': 'web',
674
- 'x-sdk-version': '18.1.0',
672
+ 'x-sdk-version': '18.3.0-rc.1',
675
673
  'X-Appwrite-Response-Format': '2.3.0',
676
674
  };
677
675
  this.realtime = {
@@ -938,7 +936,10 @@ class Client {
938
936
  *
939
937
  * A stable client id for the AppwritePush service. The broker keys its
940
938
  * offline-replay cursor on this id, so pass a stable value to resume replay across
941
- * reloads/restarts. Defaults to a per-connection id when unset.
939
+ * reloads/restarts. Defaults, when unset, to one per user and tab: stable across reloads of
940
+ * the tab, different in every other tab, and distinct for each connection open at the same
941
+ * time, so no two connections take over each other's session. An explicit id shared by
942
+ * several tabs or connections makes them do that.
942
943
  *
943
944
  * @param {string} pushClientId
944
945
  *
@@ -1521,29 +1522,6 @@ class Client {
1521
1522
  }
1522
1523
  Client.CHUNK_SIZE = 1024 * 1024 * 5;
1523
1524
 
1524
- class Service {
1525
- constructor(client) {
1526
- this.client = client;
1527
- }
1528
- static flatten(data, prefix = '') {
1529
- let output = {};
1530
- for (const [key, value] of Object.entries(data)) {
1531
- const finalKey = prefix ? prefix + '[' + key + ']' : key;
1532
- if (Array.isArray(value)) {
1533
- output = Object.assign(Object.assign({}, output), Service.flatten(value, finalKey));
1534
- }
1535
- else {
1536
- output[finalKey] = value;
1537
- }
1538
- }
1539
- return output;
1540
- }
1541
- }
1542
- /**
1543
- * The size for chunked uploads in bytes.
1544
- */
1545
- Service.CHUNK_SIZE = 5 * 1024 * 1024; // 5MB
1546
-
1547
1525
  class Account {
1548
1526
  constructor(client) {
1549
1527
  this.client = client;
@@ -3354,15 +3332,25 @@ class Account {
3354
3332
  };
3355
3333
  return this.client.call('put', uri, apiHeaders, apiPayload);
3356
3334
  }
3357
- /**
3358
- * Get the list of active sessions across different devices for the currently logged in user.
3359
- *
3360
- * @throws {AppwriteException}
3361
- * @returns {Promise<Models.SessionList>}
3362
- */
3363
- listSessions() {
3335
+ listSessions(paramsOrFirst) {
3336
+ let params;
3337
+ if (typeof paramsOrFirst === 'undefined' ||
3338
+ (paramsOrFirst &&
3339
+ typeof paramsOrFirst === 'object' &&
3340
+ !Array.isArray(paramsOrFirst))) {
3341
+ params = (paramsOrFirst || {});
3342
+ }
3343
+ else {
3344
+ params = {
3345
+ total: paramsOrFirst,
3346
+ };
3347
+ }
3348
+ const total = params.total;
3364
3349
  const apiPath = '/account/sessions';
3365
3350
  const apiPayload = {};
3351
+ if (typeof total !== 'undefined') {
3352
+ apiPayload['total'] = total;
3353
+ }
3366
3354
  const uri = new URL(this.client.config.endpoint + apiPath);
3367
3355
  const apiHeaders = {
3368
3356
  'X-Appwrite-Project': this.client.config.project,
@@ -3370,15 +3358,25 @@ class Account {
3370
3358
  };
3371
3359
  return this.client.call('get', uri, apiHeaders, apiPayload);
3372
3360
  }
3373
- /**
3374
- * Delete all sessions from the user account and remove any sessions cookies from the end client.
3375
- *
3376
- * @throws {AppwriteException}
3377
- * @returns {Promise<{}>}
3378
- */
3379
- deleteSessions() {
3361
+ deleteSessions(paramsOrFirst) {
3362
+ let params;
3363
+ if (typeof paramsOrFirst === 'undefined' ||
3364
+ (paramsOrFirst &&
3365
+ typeof paramsOrFirst === 'object' &&
3366
+ !Array.isArray(paramsOrFirst))) {
3367
+ params = (paramsOrFirst || {});
3368
+ }
3369
+ else {
3370
+ params = {
3371
+ current: paramsOrFirst,
3372
+ };
3373
+ }
3374
+ const current = params.current;
3380
3375
  const apiPath = '/account/sessions';
3381
3376
  const apiPayload = {};
3377
+ if (typeof current !== 'undefined') {
3378
+ apiPayload['current'] = current;
3379
+ }
3382
3380
  const uri = new URL(this.client.config.endpoint + apiPath);
3383
3381
  const apiHeaders = {
3384
3382
  'X-Appwrite-Project': this.client.config.project,
@@ -3415,10 +3413,12 @@ class Account {
3415
3413
  params = {
3416
3414
  email: paramsOrFirst,
3417
3415
  password: rest[0],
3416
+ duration: rest[1],
3418
3417
  };
3419
3418
  }
3420
3419
  const email = params.email;
3421
3420
  const password = params.password;
3421
+ const duration = params.duration;
3422
3422
  if (typeof email === 'undefined') {
3423
3423
  throw new AppwriteException('Missing required parameter: "email"');
3424
3424
  }
@@ -3433,6 +3433,9 @@ class Account {
3433
3433
  if (typeof password !== 'undefined') {
3434
3434
  apiPayload['password'] = password;
3435
3435
  }
3436
+ if (typeof duration !== 'undefined') {
3437
+ apiPayload['duration'] = duration;
3438
+ }
3436
3439
  const uri = new URL(this.client.config.endpoint + apiPath);
3437
3440
  const apiHeaders = {
3438
3441
  'X-Appwrite-Project': this.client.config.project,
@@ -3580,7 +3583,7 @@ class Account {
3580
3583
  }
3581
3584
  const uri = new URL(this.client.config.endpoint + apiPath);
3582
3585
  apiPayload['project'] = this.client.config.project;
3583
- for (const [key, value] of Object.entries(Service.flatten(apiPayload))) {
3586
+ for (const [key, value] of Object.entries(Client.flatten(apiPayload))) {
3584
3587
  uri.searchParams.append(key, value);
3585
3588
  }
3586
3589
  if (typeof window !== 'undefined' && (window === null || window === void 0 ? void 0 : window.location)) {
@@ -3989,7 +3992,7 @@ class Account {
3989
3992
  }
3990
3993
  const uri = new URL(this.client.config.endpoint + apiPath);
3991
3994
  apiPayload['project'] = this.client.config.project;
3992
- for (const [key, value] of Object.entries(Service.flatten(apiPayload))) {
3995
+ for (const [key, value] of Object.entries(Client.flatten(apiPayload))) {
3993
3996
  uri.searchParams.append(key, value);
3994
3997
  }
3995
3998
  if (typeof window !== 'undefined' && (window === null || window === void 0 ? void 0 : window.location)) {
@@ -4557,6 +4560,369 @@ class Affiliates {
4557
4560
  }
4558
4561
  }
4559
4562
 
4563
+ class Analytics {
4564
+ constructor(client) {
4565
+ this.client = client;
4566
+ }
4567
+ listProperties(paramsOrFirst, ...rest) {
4568
+ let params;
4569
+ if ((typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
4570
+ (paramsOrFirst &&
4571
+ typeof paramsOrFirst === 'object' &&
4572
+ !Array.isArray(paramsOrFirst))) {
4573
+ params = (paramsOrFirst || {});
4574
+ }
4575
+ else {
4576
+ params = {
4577
+ queries: paramsOrFirst,
4578
+ search: rest[0],
4579
+ total: rest[1],
4580
+ };
4581
+ }
4582
+ const queries = params.queries;
4583
+ const search = params.search;
4584
+ const total = params.total;
4585
+ const apiPath = '/analytics/properties';
4586
+ const apiPayload = {};
4587
+ if (typeof queries !== 'undefined') {
4588
+ apiPayload['queries'] = queries;
4589
+ }
4590
+ if (typeof search !== 'undefined') {
4591
+ apiPayload['search'] = search;
4592
+ }
4593
+ if (typeof total !== 'undefined') {
4594
+ apiPayload['total'] = total;
4595
+ }
4596
+ const uri = new URL(this.client.config.endpoint + apiPath);
4597
+ const apiHeaders = {
4598
+ 'X-Appwrite-Project': this.client.config.project,
4599
+ accept: 'application/json',
4600
+ };
4601
+ return this.client.call('get', uri, apiHeaders, apiPayload);
4602
+ }
4603
+ createProperty(paramsOrFirst, ...rest) {
4604
+ let params;
4605
+ if (paramsOrFirst &&
4606
+ typeof paramsOrFirst === 'object' &&
4607
+ !Array.isArray(paramsOrFirst)) {
4608
+ params = (paramsOrFirst || {});
4609
+ }
4610
+ else {
4611
+ params = {
4612
+ propertyId: paramsOrFirst,
4613
+ name: rest[0],
4614
+ domain: rest[1],
4615
+ timezone: rest[2],
4616
+ enabled: rest[3],
4617
+ xpublic: rest[4],
4618
+ allowedOrigins: rest[5],
4619
+ };
4620
+ }
4621
+ const propertyId = params.propertyId;
4622
+ const name = params.name;
4623
+ const domain = params.domain;
4624
+ const timezone = params.timezone;
4625
+ const enabled = params.enabled;
4626
+ const xpublic = params.xpublic;
4627
+ const allowedOrigins = params.allowedOrigins;
4628
+ if (typeof propertyId === 'undefined') {
4629
+ throw new AppwriteException('Missing required parameter: "propertyId"');
4630
+ }
4631
+ if (typeof name === 'undefined') {
4632
+ throw new AppwriteException('Missing required parameter: "name"');
4633
+ }
4634
+ const apiPath = '/analytics/properties';
4635
+ const apiPayload = {};
4636
+ if (typeof propertyId !== 'undefined') {
4637
+ apiPayload['propertyId'] = propertyId;
4638
+ }
4639
+ if (typeof name !== 'undefined') {
4640
+ apiPayload['name'] = name;
4641
+ }
4642
+ if (typeof domain !== 'undefined') {
4643
+ apiPayload['domain'] = domain;
4644
+ }
4645
+ if (typeof timezone !== 'undefined') {
4646
+ apiPayload['timezone'] = timezone;
4647
+ }
4648
+ if (typeof enabled !== 'undefined') {
4649
+ apiPayload['enabled'] = enabled;
4650
+ }
4651
+ if (typeof xpublic !== 'undefined') {
4652
+ apiPayload['public'] = xpublic;
4653
+ }
4654
+ if (typeof allowedOrigins !== 'undefined') {
4655
+ apiPayload['allowedOrigins'] = allowedOrigins;
4656
+ }
4657
+ const uri = new URL(this.client.config.endpoint + apiPath);
4658
+ const apiHeaders = {
4659
+ 'X-Appwrite-Project': this.client.config.project,
4660
+ 'content-type': 'application/json',
4661
+ accept: 'application/json',
4662
+ };
4663
+ return this.client.call('post', uri, apiHeaders, apiPayload);
4664
+ }
4665
+ getProperty(paramsOrFirst) {
4666
+ let params;
4667
+ if (paramsOrFirst &&
4668
+ typeof paramsOrFirst === 'object' &&
4669
+ !Array.isArray(paramsOrFirst)) {
4670
+ params = (paramsOrFirst || {});
4671
+ }
4672
+ else {
4673
+ params = {
4674
+ propertyId: paramsOrFirst,
4675
+ };
4676
+ }
4677
+ const propertyId = params.propertyId;
4678
+ if (typeof propertyId === 'undefined' || propertyId === '') {
4679
+ throw new AppwriteException('Missing required parameter: "propertyId"');
4680
+ }
4681
+ const apiPath = '/analytics/properties/{propertyId}'.replace('{propertyId}', encodeURIComponent(String(propertyId)));
4682
+ const apiPayload = {};
4683
+ const uri = new URL(this.client.config.endpoint + apiPath);
4684
+ const apiHeaders = {
4685
+ 'X-Appwrite-Project': this.client.config.project,
4686
+ accept: 'application/json',
4687
+ };
4688
+ return this.client.call('get', uri, apiHeaders, apiPayload);
4689
+ }
4690
+ updateProperty(paramsOrFirst, ...rest) {
4691
+ let params;
4692
+ if (paramsOrFirst &&
4693
+ typeof paramsOrFirst === 'object' &&
4694
+ !Array.isArray(paramsOrFirst)) {
4695
+ params = (paramsOrFirst || {});
4696
+ }
4697
+ else {
4698
+ params = {
4699
+ propertyId: paramsOrFirst,
4700
+ name: rest[0],
4701
+ domain: rest[1],
4702
+ timezone: rest[2],
4703
+ enabled: rest[3],
4704
+ xpublic: rest[4],
4705
+ allowedOrigins: rest[5],
4706
+ };
4707
+ }
4708
+ const propertyId = params.propertyId;
4709
+ const name = params.name;
4710
+ const domain = params.domain;
4711
+ const timezone = params.timezone;
4712
+ const enabled = params.enabled;
4713
+ const xpublic = params.xpublic;
4714
+ const allowedOrigins = params.allowedOrigins;
4715
+ if (typeof propertyId === 'undefined' || propertyId === '') {
4716
+ throw new AppwriteException('Missing required parameter: "propertyId"');
4717
+ }
4718
+ const apiPath = '/analytics/properties/{propertyId}'.replace('{propertyId}', encodeURIComponent(String(propertyId)));
4719
+ const apiPayload = {};
4720
+ if (typeof name !== 'undefined') {
4721
+ apiPayload['name'] = name;
4722
+ }
4723
+ if (typeof domain !== 'undefined') {
4724
+ apiPayload['domain'] = domain;
4725
+ }
4726
+ if (typeof timezone !== 'undefined') {
4727
+ apiPayload['timezone'] = timezone;
4728
+ }
4729
+ if (typeof enabled !== 'undefined') {
4730
+ apiPayload['enabled'] = enabled;
4731
+ }
4732
+ if (typeof xpublic !== 'undefined') {
4733
+ apiPayload['public'] = xpublic;
4734
+ }
4735
+ if (typeof allowedOrigins !== 'undefined') {
4736
+ apiPayload['allowedOrigins'] = allowedOrigins;
4737
+ }
4738
+ const uri = new URL(this.client.config.endpoint + apiPath);
4739
+ const apiHeaders = {
4740
+ 'X-Appwrite-Project': this.client.config.project,
4741
+ 'content-type': 'application/json',
4742
+ accept: 'application/json',
4743
+ };
4744
+ return this.client.call('patch', uri, apiHeaders, apiPayload);
4745
+ }
4746
+ deleteProperty(paramsOrFirst) {
4747
+ let params;
4748
+ if (paramsOrFirst &&
4749
+ typeof paramsOrFirst === 'object' &&
4750
+ !Array.isArray(paramsOrFirst)) {
4751
+ params = (paramsOrFirst || {});
4752
+ }
4753
+ else {
4754
+ params = {
4755
+ propertyId: paramsOrFirst,
4756
+ };
4757
+ }
4758
+ const propertyId = params.propertyId;
4759
+ if (typeof propertyId === 'undefined' || propertyId === '') {
4760
+ throw new AppwriteException('Missing required parameter: "propertyId"');
4761
+ }
4762
+ const apiPath = '/analytics/properties/{propertyId}'.replace('{propertyId}', encodeURIComponent(String(propertyId)));
4763
+ const apiPayload = {};
4764
+ const uri = new URL(this.client.config.endpoint + apiPath);
4765
+ const apiHeaders = {
4766
+ 'X-Appwrite-Project': this.client.config.project,
4767
+ 'content-type': 'application/json',
4768
+ accept: 'application/json',
4769
+ };
4770
+ return this.client.call('delete', uri, apiHeaders, apiPayload);
4771
+ }
4772
+ createEvent(paramsOrFirst, ...rest) {
4773
+ let params;
4774
+ if (paramsOrFirst &&
4775
+ typeof paramsOrFirst === 'object' &&
4776
+ !Array.isArray(paramsOrFirst)) {
4777
+ params = (paramsOrFirst || {});
4778
+ }
4779
+ else {
4780
+ params = {
4781
+ propertyId: paramsOrFirst,
4782
+ name: rest[0],
4783
+ url: rest[1],
4784
+ domain: rest[2],
4785
+ referrer: rest[3],
4786
+ screenWidth: rest[4],
4787
+ sessionHash: rest[5],
4788
+ scrollDepth: rest[6],
4789
+ engagementTime: rest[7],
4790
+ props: rest[8],
4791
+ userId: rest[9],
4792
+ ip: rest[10],
4793
+ userAgent: rest[11],
4794
+ };
4795
+ }
4796
+ const propertyId = params.propertyId;
4797
+ const name = params.name;
4798
+ const url = params.url;
4799
+ const domain = params.domain;
4800
+ const referrer = params.referrer;
4801
+ const screenWidth = params.screenWidth;
4802
+ const sessionHash = params.sessionHash;
4803
+ const scrollDepth = params.scrollDepth;
4804
+ const engagementTime = params.engagementTime;
4805
+ const props = params.props;
4806
+ const userId = params.userId;
4807
+ const ip = params.ip;
4808
+ const userAgent = params.userAgent;
4809
+ if (typeof propertyId === 'undefined' || propertyId === '') {
4810
+ throw new AppwriteException('Missing required parameter: "propertyId"');
4811
+ }
4812
+ if (typeof name === 'undefined') {
4813
+ throw new AppwriteException('Missing required parameter: "name"');
4814
+ }
4815
+ if (typeof url === 'undefined') {
4816
+ throw new AppwriteException('Missing required parameter: "url"');
4817
+ }
4818
+ const apiPath = '/analytics/properties/{propertyId}/events'.replace('{propertyId}', encodeURIComponent(String(propertyId)));
4819
+ const apiPayload = {};
4820
+ if (typeof name !== 'undefined') {
4821
+ apiPayload['name'] = name;
4822
+ }
4823
+ if (typeof url !== 'undefined') {
4824
+ apiPayload['url'] = url;
4825
+ }
4826
+ if (typeof domain !== 'undefined') {
4827
+ apiPayload['domain'] = domain;
4828
+ }
4829
+ if (typeof referrer !== 'undefined') {
4830
+ apiPayload['referrer'] = referrer;
4831
+ }
4832
+ if (typeof screenWidth !== 'undefined') {
4833
+ apiPayload['screenWidth'] = screenWidth;
4834
+ }
4835
+ if (typeof sessionHash !== 'undefined') {
4836
+ apiPayload['sessionHash'] = sessionHash;
4837
+ }
4838
+ if (typeof scrollDepth !== 'undefined') {
4839
+ apiPayload['scrollDepth'] = scrollDepth;
4840
+ }
4841
+ if (typeof engagementTime !== 'undefined') {
4842
+ apiPayload['engagementTime'] = engagementTime;
4843
+ }
4844
+ if (typeof props !== 'undefined') {
4845
+ apiPayload['props'] = props;
4846
+ }
4847
+ if (typeof userId !== 'undefined') {
4848
+ apiPayload['userId'] = userId;
4849
+ }
4850
+ if (typeof ip !== 'undefined') {
4851
+ apiPayload['ip'] = ip;
4852
+ }
4853
+ if (typeof userAgent !== 'undefined') {
4854
+ apiPayload['userAgent'] = userAgent;
4855
+ }
4856
+ const uri = new URL(this.client.config.endpoint + apiPath);
4857
+ const apiHeaders = {
4858
+ 'X-Appwrite-Project': this.client.config.project,
4859
+ 'content-type': 'application/json',
4860
+ accept: 'application/json',
4861
+ };
4862
+ return this.client.call('post', uri, apiHeaders, apiPayload);
4863
+ }
4864
+ listMetrics(paramsOrFirst, ...rest) {
4865
+ let params;
4866
+ if (paramsOrFirst &&
4867
+ typeof paramsOrFirst === 'object' &&
4868
+ !Array.isArray(paramsOrFirst)) {
4869
+ params = (paramsOrFirst || {});
4870
+ }
4871
+ else {
4872
+ params = {
4873
+ propertyId: paramsOrFirst,
4874
+ queries: rest[0],
4875
+ interval: rest[1],
4876
+ dimensions: rest[2],
4877
+ dateRange: rest[3],
4878
+ startAt: rest[4],
4879
+ endAt: rest[5],
4880
+ limit: rest[6],
4881
+ };
4882
+ }
4883
+ const propertyId = params.propertyId;
4884
+ const queries = params.queries;
4885
+ const interval = params.interval;
4886
+ const dimensions = params.dimensions;
4887
+ const dateRange = params.dateRange;
4888
+ const startAt = params.startAt;
4889
+ const endAt = params.endAt;
4890
+ const limit = params.limit;
4891
+ if (typeof propertyId === 'undefined' || propertyId === '') {
4892
+ throw new AppwriteException('Missing required parameter: "propertyId"');
4893
+ }
4894
+ const apiPath = '/analytics/properties/{propertyId}/metrics'.replace('{propertyId}', encodeURIComponent(String(propertyId)));
4895
+ const apiPayload = {};
4896
+ if (typeof queries !== 'undefined') {
4897
+ apiPayload['queries'] = queries;
4898
+ }
4899
+ if (typeof interval !== 'undefined') {
4900
+ apiPayload['interval'] = interval;
4901
+ }
4902
+ if (typeof dimensions !== 'undefined') {
4903
+ apiPayload['dimensions'] = dimensions;
4904
+ }
4905
+ if (typeof dateRange !== 'undefined') {
4906
+ apiPayload['dateRange'] = dateRange;
4907
+ }
4908
+ if (typeof startAt !== 'undefined') {
4909
+ apiPayload['startAt'] = startAt;
4910
+ }
4911
+ if (typeof endAt !== 'undefined') {
4912
+ apiPayload['endAt'] = endAt;
4913
+ }
4914
+ if (typeof limit !== 'undefined') {
4915
+ apiPayload['limit'] = limit;
4916
+ }
4917
+ const uri = new URL(this.client.config.endpoint + apiPath);
4918
+ const apiHeaders = {
4919
+ 'X-Appwrite-Project': this.client.config.project,
4920
+ accept: 'application/json',
4921
+ };
4922
+ return this.client.call('get', uri, apiHeaders, apiPayload);
4923
+ }
4924
+ }
4925
+
4560
4926
  class Apps {
4561
4927
  constructor(client) {
4562
4928
  this.client = client;
@@ -5449,7 +5815,7 @@ class Avatars {
5449
5815
  const uri = new URL(this.client.config.endpoint + apiPath);
5450
5816
  apiPayload['project'] = this.client.config.project;
5451
5817
  apiPayload['impersonateuserid'] = this.client.config.impersonateuserid;
5452
- for (const [key, value] of Object.entries(Service.flatten(apiPayload))) {
5818
+ for (const [key, value] of Object.entries(Client.flatten(apiPayload))) {
5453
5819
  uri.searchParams.append(key, value);
5454
5820
  }
5455
5821
  return uri.toString();
@@ -5494,7 +5860,7 @@ class Avatars {
5494
5860
  const uri = new URL(this.client.config.endpoint + apiPath);
5495
5861
  apiPayload['project'] = this.client.config.project;
5496
5862
  apiPayload['impersonateuserid'] = this.client.config.impersonateuserid;
5497
- for (const [key, value] of Object.entries(Service.flatten(apiPayload))) {
5863
+ for (const [key, value] of Object.entries(Client.flatten(apiPayload))) {
5498
5864
  uri.searchParams.append(key, value);
5499
5865
  }
5500
5866
  return uri.toString();
@@ -5523,7 +5889,7 @@ class Avatars {
5523
5889
  const uri = new URL(this.client.config.endpoint + apiPath);
5524
5890
  apiPayload['project'] = this.client.config.project;
5525
5891
  apiPayload['impersonateuserid'] = this.client.config.impersonateuserid;
5526
- for (const [key, value] of Object.entries(Service.flatten(apiPayload))) {
5892
+ for (const [key, value] of Object.entries(Client.flatten(apiPayload))) {
5527
5893
  uri.searchParams.append(key, value);
5528
5894
  }
5529
5895
  return uri.toString();
@@ -5568,7 +5934,7 @@ class Avatars {
5568
5934
  const uri = new URL(this.client.config.endpoint + apiPath);
5569
5935
  apiPayload['project'] = this.client.config.project;
5570
5936
  apiPayload['impersonateuserid'] = this.client.config.impersonateuserid;
5571
- for (const [key, value] of Object.entries(Service.flatten(apiPayload))) {
5937
+ for (const [key, value] of Object.entries(Client.flatten(apiPayload))) {
5572
5938
  uri.searchParams.append(key, value);
5573
5939
  }
5574
5940
  return uri.toString();
@@ -5607,7 +5973,7 @@ class Avatars {
5607
5973
  const uri = new URL(this.client.config.endpoint + apiPath);
5608
5974
  apiPayload['project'] = this.client.config.project;
5609
5975
  apiPayload['impersonateuserid'] = this.client.config.impersonateuserid;
5610
- for (const [key, value] of Object.entries(Service.flatten(apiPayload))) {
5976
+ for (const [key, value] of Object.entries(Client.flatten(apiPayload))) {
5611
5977
  uri.searchParams.append(key, value);
5612
5978
  }
5613
5979
  return uri.toString();
@@ -5649,7 +6015,7 @@ class Avatars {
5649
6015
  const uri = new URL(this.client.config.endpoint + apiPath);
5650
6016
  apiPayload['project'] = this.client.config.project;
5651
6017
  apiPayload['impersonateuserid'] = this.client.config.impersonateuserid;
5652
- for (const [key, value] of Object.entries(Service.flatten(apiPayload))) {
6018
+ for (const [key, value] of Object.entries(Client.flatten(apiPayload))) {
5653
6019
  uri.searchParams.append(key, value);
5654
6020
  }
5655
6021
  return uri.toString();
@@ -5711,11 +6077,61 @@ class Avatars {
5711
6077
  const uri = new URL(this.client.config.endpoint + apiPath);
5712
6078
  apiPayload['project'] = this.client.config.project;
5713
6079
  apiPayload['impersonateuserid'] = this.client.config.impersonateuserid;
5714
- for (const [key, value] of Object.entries(Service.flatten(apiPayload))) {
6080
+ for (const [key, value] of Object.entries(Client.flatten(apiPayload))) {
5715
6081
  uri.searchParams.append(key, value);
5716
6082
  }
5717
6083
  return uri.toString();
5718
6084
  }
6085
+ updatePhoto(paramsOrFirst, ...rest) {
6086
+ let params;
6087
+ let onProgress;
6088
+ if (paramsOrFirst &&
6089
+ typeof paramsOrFirst === 'object' &&
6090
+ !Array.isArray(paramsOrFirst) &&
6091
+ ('file' in paramsOrFirst || 'onProgress' in paramsOrFirst)) {
6092
+ params = (paramsOrFirst || {});
6093
+ onProgress = paramsOrFirst === null || paramsOrFirst === void 0 ? void 0 : paramsOrFirst.onProgress;
6094
+ }
6095
+ else {
6096
+ params = {
6097
+ file: paramsOrFirst,
6098
+ };
6099
+ onProgress = rest[0];
6100
+ }
6101
+ const file = params.file;
6102
+ if (typeof file === 'undefined') {
6103
+ throw new AppwriteException('Missing required parameter: "file"');
6104
+ }
6105
+ const apiPath = '/avatars/photo';
6106
+ const apiPayload = {};
6107
+ if (typeof file !== 'undefined') {
6108
+ apiPayload['file'] = file;
6109
+ }
6110
+ const uri = new URL(this.client.config.endpoint + apiPath);
6111
+ const apiHeaders = {
6112
+ 'X-Appwrite-Project': this.client.config.project,
6113
+ 'content-type': 'multipart/form-data',
6114
+ accept: 'application/json',
6115
+ };
6116
+ return this.client.chunkedUpload('put', uri, apiHeaders, apiPayload, onProgress);
6117
+ }
6118
+ /**
6119
+ * Delete the profile photo of the currently authenticated user and store the built-in static placeholder in its place. The placeholder is the user's photo from then on, so it takes priority over every other photo source — OAuth2 identity photos, Gravatar, Libravatar, and initials — until a new photo is uploaded with avatars.updatePhoto.
6120
+ *
6121
+ * @throws {AppwriteException}
6122
+ * @returns {Promise<{}>}
6123
+ */
6124
+ deletePhoto() {
6125
+ const apiPath = '/avatars/photo';
6126
+ const apiPayload = {};
6127
+ const uri = new URL(this.client.config.endpoint + apiPath);
6128
+ const apiHeaders = {
6129
+ 'X-Appwrite-Project': this.client.config.project,
6130
+ 'content-type': 'application/json',
6131
+ accept: 'application/json',
6132
+ };
6133
+ return this.client.call('delete', uri, apiHeaders, apiPayload);
6134
+ }
5719
6135
  getQR(paramsOrFirst, ...rest) {
5720
6136
  let params;
5721
6137
  if (paramsOrFirst &&
@@ -5755,7 +6171,7 @@ class Avatars {
5755
6171
  const uri = new URL(this.client.config.endpoint + apiPath);
5756
6172
  apiPayload['project'] = this.client.config.project;
5757
6173
  apiPayload['impersonateuserid'] = this.client.config.impersonateuserid;
5758
- for (const [key, value] of Object.entries(Service.flatten(apiPayload))) {
6174
+ for (const [key, value] of Object.entries(Client.flatten(apiPayload))) {
5759
6175
  uri.searchParams.append(key, value);
5760
6176
  }
5761
6177
  return uri.toString();
@@ -5879,7 +6295,7 @@ class Avatars {
5879
6295
  const uri = new URL(this.client.config.endpoint + apiPath);
5880
6296
  apiPayload['project'] = this.client.config.project;
5881
6297
  apiPayload['impersonateuserid'] = this.client.config.impersonateuserid;
5882
- for (const [key, value] of Object.entries(Service.flatten(apiPayload))) {
6298
+ for (const [key, value] of Object.entries(Client.flatten(apiPayload))) {
5883
6299
  uri.searchParams.append(key, value);
5884
6300
  }
5885
6301
  return uri.toString();
@@ -6418,15 +6834,25 @@ class Console {
6418
6834
  };
6419
6835
  return this.client.call('get', uri, apiHeaders, apiPayload);
6420
6836
  }
6421
- /**
6422
- * List all OAuth2 providers supported by the Appwrite server, along with the parameters required to configure each provider. The response excludes mock providers but includes sandbox providers.
6423
- *
6424
- * @throws {AppwriteException}
6425
- * @returns {Promise<Models.ConsoleOAuth2ProviderList>}
6426
- */
6427
- listOAuth2Providers() {
6837
+ listOAuth2Providers(paramsOrFirst) {
6838
+ let params;
6839
+ if (typeof paramsOrFirst === 'undefined' ||
6840
+ (paramsOrFirst &&
6841
+ typeof paramsOrFirst === 'object' &&
6842
+ !Array.isArray(paramsOrFirst))) {
6843
+ params = (paramsOrFirst || {});
6844
+ }
6845
+ else {
6846
+ params = {
6847
+ total: paramsOrFirst,
6848
+ };
6849
+ }
6850
+ const total = params.total;
6428
6851
  const apiPath = '/console/oauth2-providers';
6429
6852
  const apiPayload = {};
6853
+ if (typeof total !== 'undefined') {
6854
+ apiPayload['total'] = total;
6855
+ }
6430
6856
  const uri = new URL(this.client.config.endpoint + apiPath);
6431
6857
  const apiHeaders = {
6432
6858
  'X-Appwrite-Project': this.client.config.project,
@@ -6606,15 +7032,25 @@ class Console {
6606
7032
  };
6607
7033
  return this.client.call('get', uri, apiHeaders, apiPayload);
6608
7034
  }
6609
- /**
6610
- * List all scopes available for organization API keys, along with a description for each scope.
6611
- *
6612
- * @throws {AppwriteException}
6613
- * @returns {Promise<Models.ConsoleKeyScopeList>}
6614
- */
6615
- listOrganizationScopes() {
7035
+ listOrganizationScopes(paramsOrFirst) {
7036
+ let params;
7037
+ if (typeof paramsOrFirst === 'undefined' ||
7038
+ (paramsOrFirst &&
7039
+ typeof paramsOrFirst === 'object' &&
7040
+ !Array.isArray(paramsOrFirst))) {
7041
+ params = (paramsOrFirst || {});
7042
+ }
7043
+ else {
7044
+ params = {
7045
+ total: paramsOrFirst,
7046
+ };
7047
+ }
7048
+ const total = params.total;
6616
7049
  const apiPath = '/console/scopes/organization';
6617
7050
  const apiPayload = {};
7051
+ if (typeof total !== 'undefined') {
7052
+ apiPayload['total'] = total;
7053
+ }
6618
7054
  const uri = new URL(this.client.config.endpoint + apiPath);
6619
7055
  const apiHeaders = {
6620
7056
  'X-Appwrite-Project': this.client.config.project,
@@ -6622,15 +7058,25 @@ class Console {
6622
7058
  };
6623
7059
  return this.client.call('get', uri, apiHeaders, apiPayload);
6624
7060
  }
6625
- /**
6626
- * List all scopes available for project API keys, along with a description for each scope.
6627
- *
6628
- * @throws {AppwriteException}
6629
- * @returns {Promise<Models.ConsoleKeyScopeList>}
6630
- */
6631
- listProjectScopes() {
7061
+ listProjectScopes(paramsOrFirst) {
7062
+ let params;
7063
+ if (typeof paramsOrFirst === 'undefined' ||
7064
+ (paramsOrFirst &&
7065
+ typeof paramsOrFirst === 'object' &&
7066
+ !Array.isArray(paramsOrFirst))) {
7067
+ params = (paramsOrFirst || {});
7068
+ }
7069
+ else {
7070
+ params = {
7071
+ total: paramsOrFirst,
7072
+ };
7073
+ }
7074
+ const total = params.total;
6632
7075
  const apiPath = '/console/scopes/project';
6633
7076
  const apiPayload = {};
7077
+ if (typeof total !== 'undefined') {
7078
+ apiPayload['total'] = total;
7079
+ }
6634
7080
  const uri = new URL(this.client.config.endpoint + apiPath);
6635
7081
  const apiHeaders = {
6636
7082
  'X-Appwrite-Project': this.client.config.project,
@@ -6963,9 +7409,9 @@ class Databases {
6963
7409
  };
6964
7410
  return this.client.call('post', uri, apiHeaders, apiPayload);
6965
7411
  }
6966
- listTransactions(paramsOrFirst) {
7412
+ listTransactions(paramsOrFirst, ...rest) {
6967
7413
  let params;
6968
- if (typeof paramsOrFirst === 'undefined' ||
7414
+ if ((typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
6969
7415
  (paramsOrFirst &&
6970
7416
  typeof paramsOrFirst === 'object' &&
6971
7417
  !Array.isArray(paramsOrFirst))) {
@@ -6974,14 +7420,19 @@ class Databases {
6974
7420
  else {
6975
7421
  params = {
6976
7422
  queries: paramsOrFirst,
7423
+ total: rest[0],
6977
7424
  };
6978
7425
  }
6979
7426
  const queries = params.queries;
7427
+ const total = params.total;
6980
7428
  const apiPath = '/databases/transactions';
6981
7429
  const apiPayload = {};
6982
7430
  if (typeof queries !== 'undefined') {
6983
7431
  apiPayload['queries'] = queries;
6984
7432
  }
7433
+ if (typeof total !== 'undefined') {
7434
+ apiPayload['total'] = total;
7435
+ }
6985
7436
  const uri = new URL(this.client.config.endpoint + apiPath);
6986
7437
  const apiHeaders = {
6987
7438
  'X-Appwrite-Project': this.client.config.project,
@@ -10724,9 +11175,9 @@ class DocumentsDB {
10724
11175
  };
10725
11176
  return this.client.call('get', uri, apiHeaders, apiPayload);
10726
11177
  }
10727
- listTransactions(paramsOrFirst) {
11178
+ listTransactions(paramsOrFirst, ...rest) {
10728
11179
  let params;
10729
- if (typeof paramsOrFirst === 'undefined' ||
11180
+ if ((typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
10730
11181
  (paramsOrFirst &&
10731
11182
  typeof paramsOrFirst === 'object' &&
10732
11183
  !Array.isArray(paramsOrFirst))) {
@@ -10735,14 +11186,19 @@ class DocumentsDB {
10735
11186
  else {
10736
11187
  params = {
10737
11188
  queries: paramsOrFirst,
11189
+ total: rest[0],
10738
11190
  };
10739
11191
  }
10740
11192
  const queries = params.queries;
11193
+ const total = params.total;
10741
11194
  const apiPath = '/documentsdb/transactions';
10742
11195
  const apiPayload = {};
10743
11196
  if (typeof queries !== 'undefined') {
10744
11197
  apiPayload['queries'] = queries;
10745
11198
  }
11199
+ if (typeof total !== 'undefined') {
11200
+ apiPayload['total'] = total;
11201
+ }
10746
11202
  const uri = new URL(this.client.config.endpoint + apiPath);
10747
11203
  const apiHeaders = {
10748
11204
  'X-Appwrite-Project': this.client.config.project,
@@ -14708,15 +15164,25 @@ class Functions {
14708
15164
  };
14709
15165
  return this.client.call('post', uri, apiHeaders, apiPayload);
14710
15166
  }
14711
- /**
14712
- * Get a list of all runtimes that are currently active on your instance.
14713
- *
14714
- * @throws {AppwriteException}
14715
- * @returns {Promise<Models.RuntimeList>}
14716
- */
14717
- listRuntimes() {
15167
+ listRuntimes(paramsOrFirst) {
15168
+ let params;
15169
+ if (typeof paramsOrFirst === 'undefined' ||
15170
+ (paramsOrFirst &&
15171
+ typeof paramsOrFirst === 'object' &&
15172
+ !Array.isArray(paramsOrFirst))) {
15173
+ params = (paramsOrFirst || {});
15174
+ }
15175
+ else {
15176
+ params = {
15177
+ total: paramsOrFirst,
15178
+ };
15179
+ }
15180
+ const total = params.total;
14718
15181
  const apiPath = '/functions/runtimes';
14719
15182
  const apiPayload = {};
15183
+ if (typeof total !== 'undefined') {
15184
+ apiPayload['total'] = total;
15185
+ }
14720
15186
  const uri = new URL(this.client.config.endpoint + apiPath);
14721
15187
  const apiHeaders = {
14722
15188
  'X-Appwrite-Project': this.client.config.project,
@@ -14724,9 +15190,9 @@ class Functions {
14724
15190
  };
14725
15191
  return this.client.call('get', uri, apiHeaders, apiPayload);
14726
15192
  }
14727
- listSpecifications(paramsOrFirst) {
15193
+ listSpecifications(paramsOrFirst, ...rest) {
14728
15194
  let params;
14729
- if (typeof paramsOrFirst === 'undefined' ||
15195
+ if ((typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
14730
15196
  (paramsOrFirst &&
14731
15197
  typeof paramsOrFirst === 'object' &&
14732
15198
  !Array.isArray(paramsOrFirst))) {
@@ -14735,14 +15201,19 @@ class Functions {
14735
15201
  else {
14736
15202
  params = {
14737
15203
  type: paramsOrFirst,
15204
+ total: rest[0],
14738
15205
  };
14739
15206
  }
14740
15207
  const type = params.type;
15208
+ const total = params.total;
14741
15209
  const apiPath = '/functions/specifications';
14742
15210
  const apiPayload = {};
14743
15211
  if (typeof type !== 'undefined') {
14744
15212
  apiPayload['type'] = type;
14745
15213
  }
15214
+ if (typeof total !== 'undefined') {
15215
+ apiPayload['total'] = total;
15216
+ }
14746
15217
  const uri = new URL(this.client.config.endpoint + apiPath);
14747
15218
  const apiHeaders = {
14748
15219
  'X-Appwrite-Project': this.client.config.project,
@@ -15400,7 +15871,7 @@ class Functions {
15400
15871
  const uri = new URL(this.client.config.endpoint + apiPath);
15401
15872
  apiPayload['project'] = this.client.config.project;
15402
15873
  apiPayload['impersonateuserid'] = this.client.config.impersonateuserid;
15403
- for (const [key, value] of Object.entries(Service.flatten(apiPayload))) {
15874
+ for (const [key, value] of Object.entries(Client.flatten(apiPayload))) {
15404
15875
  uri.searchParams.append(key, value);
15405
15876
  }
15406
15877
  return uri.toString();
@@ -16054,15 +16525,25 @@ class Locale {
16054
16525
  };
16055
16526
  return this.client.call('get', uri, apiHeaders, apiPayload);
16056
16527
  }
16057
- /**
16058
- * List of all locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
16059
- *
16060
- * @throws {AppwriteException}
16061
- * @returns {Promise<Models.LocaleCodeList>}
16062
- */
16063
- listCodes() {
16528
+ listCodes(paramsOrFirst) {
16529
+ let params;
16530
+ if (typeof paramsOrFirst === 'undefined' ||
16531
+ (paramsOrFirst &&
16532
+ typeof paramsOrFirst === 'object' &&
16533
+ !Array.isArray(paramsOrFirst))) {
16534
+ params = (paramsOrFirst || {});
16535
+ }
16536
+ else {
16537
+ params = {
16538
+ total: paramsOrFirst,
16539
+ };
16540
+ }
16541
+ const total = params.total;
16064
16542
  const apiPath = '/locale/codes';
16065
16543
  const apiPayload = {};
16544
+ if (typeof total !== 'undefined') {
16545
+ apiPayload['total'] = total;
16546
+ }
16066
16547
  const uri = new URL(this.client.config.endpoint + apiPath);
16067
16548
  const apiHeaders = {
16068
16549
  'X-Appwrite-Project': this.client.config.project,
@@ -16070,15 +16551,25 @@ class Locale {
16070
16551
  };
16071
16552
  return this.client.call('get', uri, apiHeaders, apiPayload);
16072
16553
  }
16073
- /**
16074
- * List of all continents. You can use the locale header to get the data in a supported language.
16075
- *
16076
- * @throws {AppwriteException}
16077
- * @returns {Promise<Models.ContinentList>}
16078
- */
16079
- listContinents() {
16554
+ listContinents(paramsOrFirst) {
16555
+ let params;
16556
+ if (typeof paramsOrFirst === 'undefined' ||
16557
+ (paramsOrFirst &&
16558
+ typeof paramsOrFirst === 'object' &&
16559
+ !Array.isArray(paramsOrFirst))) {
16560
+ params = (paramsOrFirst || {});
16561
+ }
16562
+ else {
16563
+ params = {
16564
+ total: paramsOrFirst,
16565
+ };
16566
+ }
16567
+ const total = params.total;
16080
16568
  const apiPath = '/locale/continents';
16081
16569
  const apiPayload = {};
16570
+ if (typeof total !== 'undefined') {
16571
+ apiPayload['total'] = total;
16572
+ }
16082
16573
  const uri = new URL(this.client.config.endpoint + apiPath);
16083
16574
  const apiHeaders = {
16084
16575
  'X-Appwrite-Project': this.client.config.project,
@@ -16086,15 +16577,25 @@ class Locale {
16086
16577
  };
16087
16578
  return this.client.call('get', uri, apiHeaders, apiPayload);
16088
16579
  }
16089
- /**
16090
- * List of all countries. You can use the locale header to get the data in a supported language.
16091
- *
16092
- * @throws {AppwriteException}
16093
- * @returns {Promise<Models.CountryList>}
16094
- */
16095
- listCountries() {
16580
+ listCountries(paramsOrFirst) {
16581
+ let params;
16582
+ if (typeof paramsOrFirst === 'undefined' ||
16583
+ (paramsOrFirst &&
16584
+ typeof paramsOrFirst === 'object' &&
16585
+ !Array.isArray(paramsOrFirst))) {
16586
+ params = (paramsOrFirst || {});
16587
+ }
16588
+ else {
16589
+ params = {
16590
+ total: paramsOrFirst,
16591
+ };
16592
+ }
16593
+ const total = params.total;
16096
16594
  const apiPath = '/locale/countries';
16097
16595
  const apiPayload = {};
16596
+ if (typeof total !== 'undefined') {
16597
+ apiPayload['total'] = total;
16598
+ }
16098
16599
  const uri = new URL(this.client.config.endpoint + apiPath);
16099
16600
  const apiHeaders = {
16100
16601
  'X-Appwrite-Project': this.client.config.project,
@@ -16102,15 +16603,25 @@ class Locale {
16102
16603
  };
16103
16604
  return this.client.call('get', uri, apiHeaders, apiPayload);
16104
16605
  }
16105
- /**
16106
- * List of all countries that are currently members of the EU. You can use the locale header to get the data in a supported language.
16107
- *
16108
- * @throws {AppwriteException}
16109
- * @returns {Promise<Models.CountryList>}
16110
- */
16111
- listCountriesEU() {
16606
+ listCountriesEU(paramsOrFirst) {
16607
+ let params;
16608
+ if (typeof paramsOrFirst === 'undefined' ||
16609
+ (paramsOrFirst &&
16610
+ typeof paramsOrFirst === 'object' &&
16611
+ !Array.isArray(paramsOrFirst))) {
16612
+ params = (paramsOrFirst || {});
16613
+ }
16614
+ else {
16615
+ params = {
16616
+ total: paramsOrFirst,
16617
+ };
16618
+ }
16619
+ const total = params.total;
16112
16620
  const apiPath = '/locale/countries/eu';
16113
16621
  const apiPayload = {};
16622
+ if (typeof total !== 'undefined') {
16623
+ apiPayload['total'] = total;
16624
+ }
16114
16625
  const uri = new URL(this.client.config.endpoint + apiPath);
16115
16626
  const apiHeaders = {
16116
16627
  'X-Appwrite-Project': this.client.config.project,
@@ -16118,15 +16629,25 @@ class Locale {
16118
16629
  };
16119
16630
  return this.client.call('get', uri, apiHeaders, apiPayload);
16120
16631
  }
16121
- /**
16122
- * List of all countries phone codes. You can use the locale header to get the data in a supported language.
16123
- *
16124
- * @throws {AppwriteException}
16125
- * @returns {Promise<Models.PhoneList>}
16126
- */
16127
- listCountriesPhones() {
16632
+ listCountriesPhones(paramsOrFirst) {
16633
+ let params;
16634
+ if (typeof paramsOrFirst === 'undefined' ||
16635
+ (paramsOrFirst &&
16636
+ typeof paramsOrFirst === 'object' &&
16637
+ !Array.isArray(paramsOrFirst))) {
16638
+ params = (paramsOrFirst || {});
16639
+ }
16640
+ else {
16641
+ params = {
16642
+ total: paramsOrFirst,
16643
+ };
16644
+ }
16645
+ const total = params.total;
16128
16646
  const apiPath = '/locale/countries/phones';
16129
16647
  const apiPayload = {};
16648
+ if (typeof total !== 'undefined') {
16649
+ apiPayload['total'] = total;
16650
+ }
16130
16651
  const uri = new URL(this.client.config.endpoint + apiPath);
16131
16652
  const apiHeaders = {
16132
16653
  'X-Appwrite-Project': this.client.config.project,
@@ -16134,15 +16655,25 @@ class Locale {
16134
16655
  };
16135
16656
  return this.client.call('get', uri, apiHeaders, apiPayload);
16136
16657
  }
16137
- /**
16138
- * List of all currencies, including currency symbol, name, plural, and decimal digits for all major and minor currencies. You can use the locale header to get the data in a supported language.
16139
- *
16140
- * @throws {AppwriteException}
16141
- * @returns {Promise<Models.CurrencyList>}
16142
- */
16143
- listCurrencies() {
16658
+ listCurrencies(paramsOrFirst) {
16659
+ let params;
16660
+ if (typeof paramsOrFirst === 'undefined' ||
16661
+ (paramsOrFirst &&
16662
+ typeof paramsOrFirst === 'object' &&
16663
+ !Array.isArray(paramsOrFirst))) {
16664
+ params = (paramsOrFirst || {});
16665
+ }
16666
+ else {
16667
+ params = {
16668
+ total: paramsOrFirst,
16669
+ };
16670
+ }
16671
+ const total = params.total;
16144
16672
  const apiPath = '/locale/currencies';
16145
16673
  const apiPayload = {};
16674
+ if (typeof total !== 'undefined') {
16675
+ apiPayload['total'] = total;
16676
+ }
16146
16677
  const uri = new URL(this.client.config.endpoint + apiPath);
16147
16678
  const apiHeaders = {
16148
16679
  'X-Appwrite-Project': this.client.config.project,
@@ -16150,15 +16681,25 @@ class Locale {
16150
16681
  };
16151
16682
  return this.client.call('get', uri, apiHeaders, apiPayload);
16152
16683
  }
16153
- /**
16154
- * List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language.
16155
- *
16156
- * @throws {AppwriteException}
16157
- * @returns {Promise<Models.LanguageList>}
16158
- */
16159
- listLanguages() {
16684
+ listLanguages(paramsOrFirst) {
16685
+ let params;
16686
+ if (typeof paramsOrFirst === 'undefined' ||
16687
+ (paramsOrFirst &&
16688
+ typeof paramsOrFirst === 'object' &&
16689
+ !Array.isArray(paramsOrFirst))) {
16690
+ params = (paramsOrFirst || {});
16691
+ }
16692
+ else {
16693
+ params = {
16694
+ total: paramsOrFirst,
16695
+ };
16696
+ }
16697
+ const total = params.total;
16160
16698
  const apiPath = '/locale/languages';
16161
16699
  const apiPayload = {};
16700
+ if (typeof total !== 'undefined') {
16701
+ apiPayload['total'] = total;
16702
+ }
16162
16703
  const uri = new URL(this.client.config.endpoint + apiPath);
16163
16704
  const apiHeaders = {
16164
16705
  'X-Appwrite-Project': this.client.config.project,
@@ -16592,40 +17133,46 @@ class Messaging {
16592
17133
  else {
16593
17134
  params = {
16594
17135
  messageId: paramsOrFirst,
16595
- topics: rest[0],
16596
- users: rest[1],
16597
- targets: rest[2],
16598
- subject: rest[3],
16599
- content: rest[4],
16600
- draft: rest[5],
16601
- html: rest[6],
16602
- cc: rest[7],
16603
- bcc: rest[8],
16604
- replyToEmail: rest[9],
16605
- replyToName: rest[10],
16606
- scheduledAt: rest[11],
16607
- attachments: rest[12],
17136
+ subject: rest[0],
17137
+ content: rest[1],
17138
+ topics: rest[2],
17139
+ users: rest[3],
17140
+ targets: rest[4],
17141
+ cc: rest[5],
17142
+ bcc: rest[6],
17143
+ attachments: rest[7],
17144
+ replyToEmail: rest[8],
17145
+ replyToName: rest[9],
17146
+ draft: rest[10],
17147
+ html: rest[11],
17148
+ scheduledAt: rest[12],
16608
17149
  };
16609
17150
  }
16610
17151
  const messageId = params.messageId;
17152
+ const subject = params.subject;
17153
+ const content = params.content;
16611
17154
  const topics = params.topics;
16612
17155
  const users = params.users;
16613
17156
  const targets = params.targets;
16614
- const subject = params.subject;
16615
- const content = params.content;
16616
- const draft = params.draft;
16617
- const html = params.html;
16618
17157
  const cc = params.cc;
16619
17158
  const bcc = params.bcc;
17159
+ const attachments = params.attachments;
16620
17160
  const replyToEmail = params.replyToEmail;
16621
17161
  const replyToName = params.replyToName;
17162
+ const draft = params.draft;
17163
+ const html = params.html;
16622
17164
  const scheduledAt = params.scheduledAt;
16623
- const attachments = params.attachments;
16624
17165
  if (typeof messageId === 'undefined' || messageId === '') {
16625
17166
  throw new AppwriteException('Missing required parameter: "messageId"');
16626
17167
  }
16627
17168
  const apiPath = '/messaging/messages/email/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId)));
16628
17169
  const apiPayload = {};
17170
+ if (typeof subject !== 'undefined') {
17171
+ apiPayload['subject'] = subject;
17172
+ }
17173
+ if (typeof content !== 'undefined') {
17174
+ apiPayload['content'] = content;
17175
+ }
16629
17176
  if (typeof topics !== 'undefined') {
16630
17177
  apiPayload['topics'] = topics;
16631
17178
  }
@@ -16635,36 +17182,30 @@ class Messaging {
16635
17182
  if (typeof targets !== 'undefined') {
16636
17183
  apiPayload['targets'] = targets;
16637
17184
  }
16638
- if (typeof subject !== 'undefined') {
16639
- apiPayload['subject'] = subject;
16640
- }
16641
- if (typeof content !== 'undefined') {
16642
- apiPayload['content'] = content;
16643
- }
16644
- if (typeof draft !== 'undefined') {
16645
- apiPayload['draft'] = draft;
16646
- }
16647
- if (typeof html !== 'undefined') {
16648
- apiPayload['html'] = html;
16649
- }
16650
17185
  if (typeof cc !== 'undefined') {
16651
17186
  apiPayload['cc'] = cc;
16652
17187
  }
16653
17188
  if (typeof bcc !== 'undefined') {
16654
17189
  apiPayload['bcc'] = bcc;
16655
17190
  }
17191
+ if (typeof attachments !== 'undefined') {
17192
+ apiPayload['attachments'] = attachments;
17193
+ }
16656
17194
  if (typeof replyToEmail !== 'undefined') {
16657
17195
  apiPayload['replyToEmail'] = replyToEmail;
16658
17196
  }
16659
17197
  if (typeof replyToName !== 'undefined') {
16660
17198
  apiPayload['replyToName'] = replyToName;
16661
17199
  }
17200
+ if (typeof draft !== 'undefined') {
17201
+ apiPayload['draft'] = draft;
17202
+ }
17203
+ if (typeof html !== 'undefined') {
17204
+ apiPayload['html'] = html;
17205
+ }
16662
17206
  if (typeof scheduledAt !== 'undefined') {
16663
17207
  apiPayload['scheduledAt'] = scheduledAt;
16664
17208
  }
16665
- if (typeof attachments !== 'undefined') {
16666
- apiPayload['attachments'] = attachments;
16667
- }
16668
17209
  const uri = new URL(this.client.config.endpoint + apiPath);
16669
17210
  const apiHeaders = {
16670
17211
  'X-Appwrite-Project': this.client.config.project,
@@ -16701,6 +17242,7 @@ class Messaging {
16701
17242
  contentAvailable: rest[15],
16702
17243
  critical: rest[16],
16703
17244
  priority: rest[17],
17245
+ channelId: rest[18],
16704
17246
  };
16705
17247
  }
16706
17248
  const messageId = params.messageId;
@@ -16722,6 +17264,7 @@ class Messaging {
16722
17264
  const contentAvailable = params.contentAvailable;
16723
17265
  const critical = params.critical;
16724
17266
  const priority = params.priority;
17267
+ const channelId = params.channelId;
16725
17268
  if (typeof messageId === 'undefined') {
16726
17269
  throw new AppwriteException('Missing required parameter: "messageId"');
16727
17270
  }
@@ -16784,6 +17327,9 @@ class Messaging {
16784
17327
  if (typeof priority !== 'undefined') {
16785
17328
  apiPayload['priority'] = priority;
16786
17329
  }
17330
+ if (typeof channelId !== 'undefined') {
17331
+ apiPayload['channelId'] = channelId;
17332
+ }
16787
17333
  const uri = new URL(this.client.config.endpoint + apiPath);
16788
17334
  const apiHeaders = {
16789
17335
  'X-Appwrite-Project': this.client.config.project,
@@ -16802,11 +17348,11 @@ class Messaging {
16802
17348
  else {
16803
17349
  params = {
16804
17350
  messageId: paramsOrFirst,
16805
- topics: rest[0],
16806
- users: rest[1],
16807
- targets: rest[2],
16808
- title: rest[3],
16809
- body: rest[4],
17351
+ title: rest[0],
17352
+ body: rest[1],
17353
+ topics: rest[2],
17354
+ users: rest[3],
17355
+ targets: rest[4],
16810
17356
  data: rest[5],
16811
17357
  action: rest[6],
16812
17358
  image: rest[7],
@@ -16820,14 +17366,15 @@ class Messaging {
16820
17366
  contentAvailable: rest[15],
16821
17367
  critical: rest[16],
16822
17368
  priority: rest[17],
17369
+ channelId: rest[18],
16823
17370
  };
16824
17371
  }
16825
17372
  const messageId = params.messageId;
17373
+ const title = params.title;
17374
+ const body = params.body;
16826
17375
  const topics = params.topics;
16827
17376
  const users = params.users;
16828
17377
  const targets = params.targets;
16829
- const title = params.title;
16830
- const body = params.body;
16831
17378
  const data = params.data;
16832
17379
  const action = params.action;
16833
17380
  const image = params.image;
@@ -16841,11 +17388,18 @@ class Messaging {
16841
17388
  const contentAvailable = params.contentAvailable;
16842
17389
  const critical = params.critical;
16843
17390
  const priority = params.priority;
17391
+ const channelId = params.channelId;
16844
17392
  if (typeof messageId === 'undefined' || messageId === '') {
16845
17393
  throw new AppwriteException('Missing required parameter: "messageId"');
16846
17394
  }
16847
17395
  const apiPath = '/messaging/messages/push/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId)));
16848
17396
  const apiPayload = {};
17397
+ if (typeof title !== 'undefined') {
17398
+ apiPayload['title'] = title;
17399
+ }
17400
+ if (typeof body !== 'undefined') {
17401
+ apiPayload['body'] = body;
17402
+ }
16849
17403
  if (typeof topics !== 'undefined') {
16850
17404
  apiPayload['topics'] = topics;
16851
17405
  }
@@ -16855,12 +17409,6 @@ class Messaging {
16855
17409
  if (typeof targets !== 'undefined') {
16856
17410
  apiPayload['targets'] = targets;
16857
17411
  }
16858
- if (typeof title !== 'undefined') {
16859
- apiPayload['title'] = title;
16860
- }
16861
- if (typeof body !== 'undefined') {
16862
- apiPayload['body'] = body;
16863
- }
16864
17412
  if (typeof data !== 'undefined') {
16865
17413
  apiPayload['data'] = data;
16866
17414
  }
@@ -16900,6 +17448,9 @@ class Messaging {
16900
17448
  if (typeof priority !== 'undefined') {
16901
17449
  apiPayload['priority'] = priority;
16902
17450
  }
17451
+ if (typeof channelId !== 'undefined') {
17452
+ apiPayload['channelId'] = channelId;
17453
+ }
16903
17454
  const uri = new URL(this.client.config.endpoint + apiPath);
16904
17455
  const apiHeaders = {
16905
17456
  'X-Appwrite-Project': this.client.config.project,
@@ -17042,19 +17593,19 @@ class Messaging {
17042
17593
  else {
17043
17594
  params = {
17044
17595
  messageId: paramsOrFirst,
17045
- topics: rest[0],
17046
- users: rest[1],
17047
- targets: rest[2],
17048
- content: rest[3],
17596
+ content: rest[0],
17597
+ topics: rest[1],
17598
+ users: rest[2],
17599
+ targets: rest[3],
17049
17600
  draft: rest[4],
17050
17601
  scheduledAt: rest[5],
17051
17602
  };
17052
17603
  }
17053
17604
  const messageId = params.messageId;
17605
+ const content = params.content;
17054
17606
  const topics = params.topics;
17055
17607
  const users = params.users;
17056
17608
  const targets = params.targets;
17057
- const content = params.content;
17058
17609
  const draft = params.draft;
17059
17610
  const scheduledAt = params.scheduledAt;
17060
17611
  if (typeof messageId === 'undefined' || messageId === '') {
@@ -17062,6 +17613,9 @@ class Messaging {
17062
17613
  }
17063
17614
  const apiPath = '/messaging/messages/sms/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId)));
17064
17615
  const apiPayload = {};
17616
+ if (typeof content !== 'undefined') {
17617
+ apiPayload['content'] = content;
17618
+ }
17065
17619
  if (typeof topics !== 'undefined') {
17066
17620
  apiPayload['topics'] = topics;
17067
17621
  }
@@ -17071,9 +17625,6 @@ class Messaging {
17071
17625
  if (typeof targets !== 'undefined') {
17072
17626
  apiPayload['targets'] = targets;
17073
17627
  }
17074
- if (typeof content !== 'undefined') {
17075
- apiPayload['content'] = content;
17076
- }
17077
17628
  if (typeof draft !== 'undefined') {
17078
17629
  apiPayload['draft'] = draft;
17079
17630
  }
@@ -17098,19 +17649,19 @@ class Messaging {
17098
17649
  else {
17099
17650
  params = {
17100
17651
  messageId: paramsOrFirst,
17101
- topics: rest[0],
17102
- users: rest[1],
17103
- targets: rest[2],
17104
- content: rest[3],
17652
+ content: rest[0],
17653
+ topics: rest[1],
17654
+ users: rest[2],
17655
+ targets: rest[3],
17105
17656
  draft: rest[4],
17106
17657
  scheduledAt: rest[5],
17107
17658
  };
17108
17659
  }
17109
17660
  const messageId = params.messageId;
17661
+ const content = params.content;
17110
17662
  const topics = params.topics;
17111
17663
  const users = params.users;
17112
17664
  const targets = params.targets;
17113
- const content = params.content;
17114
17665
  const draft = params.draft;
17115
17666
  const scheduledAt = params.scheduledAt;
17116
17667
  if (typeof messageId === 'undefined' || messageId === '') {
@@ -17118,6 +17669,9 @@ class Messaging {
17118
17669
  }
17119
17670
  const apiPath = '/messaging/messages/sms/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId)));
17120
17671
  const apiPayload = {};
17672
+ if (typeof content !== 'undefined') {
17673
+ apiPayload['content'] = content;
17674
+ }
17121
17675
  if (typeof topics !== 'undefined') {
17122
17676
  apiPayload['topics'] = topics;
17123
17677
  }
@@ -17127,9 +17681,6 @@ class Messaging {
17127
17681
  if (typeof targets !== 'undefined') {
17128
17682
  apiPayload['targets'] = targets;
17129
17683
  }
17130
- if (typeof content !== 'undefined') {
17131
- apiPayload['content'] = content;
17132
- }
17133
17684
  if (typeof draft !== 'undefined') {
17134
17685
  apiPayload['draft'] = draft;
17135
17686
  }
@@ -23201,9 +23752,9 @@ class Notifications {
23201
23752
  constructor(client) {
23202
23753
  this.client = client;
23203
23754
  }
23204
- list(paramsOrFirst) {
23755
+ list(paramsOrFirst, ...rest) {
23205
23756
  let params;
23206
- if (typeof paramsOrFirst === 'undefined' ||
23757
+ if ((typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
23207
23758
  (paramsOrFirst &&
23208
23759
  typeof paramsOrFirst === 'object' &&
23209
23760
  !Array.isArray(paramsOrFirst))) {
@@ -23212,14 +23763,19 @@ class Notifications {
23212
23763
  else {
23213
23764
  params = {
23214
23765
  queries: paramsOrFirst,
23766
+ total: rest[0],
23215
23767
  };
23216
23768
  }
23217
23769
  const queries = params.queries;
23770
+ const total = params.total;
23218
23771
  const apiPath = '/notifications';
23219
23772
  const apiPayload = {};
23220
23773
  if (typeof queries !== 'undefined') {
23221
23774
  apiPayload['queries'] = queries;
23222
23775
  }
23776
+ if (typeof total !== 'undefined') {
23777
+ apiPayload['total'] = total;
23778
+ }
23223
23779
  const uri = new URL(this.client.config.endpoint + apiPath);
23224
23780
  const apiHeaders = {
23225
23781
  'X-Appwrite-Project': this.client.config.project,
@@ -25954,7 +26510,7 @@ class Organizations {
25954
26510
  const uri = new URL(this.client.config.endpoint + apiPath);
25955
26511
  apiPayload['project'] = this.client.config.project;
25956
26512
  apiPayload['impersonateuserid'] = this.client.config.impersonateuserid;
25957
- for (const [key, value] of Object.entries(Service.flatten(apiPayload))) {
26513
+ for (const [key, value] of Object.entries(Client.flatten(apiPayload))) {
25958
26514
  uri.searchParams.append(key, value);
25959
26515
  }
25960
26516
  return uri.toString();
@@ -26061,7 +26617,7 @@ class Organizations {
26061
26617
  const uri = new URL(this.client.config.endpoint + apiPath);
26062
26618
  apiPayload['project'] = this.client.config.project;
26063
26619
  apiPayload['impersonateuserid'] = this.client.config.impersonateuserid;
26064
- for (const [key, value] of Object.entries(Service.flatten(apiPayload))) {
26620
+ for (const [key, value] of Object.entries(Client.flatten(apiPayload))) {
26065
26621
  uri.searchParams.append(key, value);
26066
26622
  }
26067
26623
  return uri.toString();
@@ -30509,6 +31065,43 @@ class Project {
30509
31065
  };
30510
31066
  return this.client.call('patch', uri, apiHeaders, apiPayload);
30511
31067
  }
31068
+ updateOAuth2Webflow(paramsOrFirst, ...rest) {
31069
+ let params;
31070
+ if ((typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
31071
+ (paramsOrFirst &&
31072
+ typeof paramsOrFirst === 'object' &&
31073
+ !Array.isArray(paramsOrFirst))) {
31074
+ params = (paramsOrFirst || {});
31075
+ }
31076
+ else {
31077
+ params = {
31078
+ clientId: paramsOrFirst,
31079
+ clientSecret: rest[0],
31080
+ enabled: rest[1],
31081
+ };
31082
+ }
31083
+ const clientId = params.clientId;
31084
+ const clientSecret = params.clientSecret;
31085
+ const enabled = params.enabled;
31086
+ const apiPath = '/project/oauth2/webflow';
31087
+ const apiPayload = {};
31088
+ if (typeof clientId !== 'undefined') {
31089
+ apiPayload['clientId'] = clientId;
31090
+ }
31091
+ if (typeof clientSecret !== 'undefined') {
31092
+ apiPayload['clientSecret'] = clientSecret;
31093
+ }
31094
+ if (typeof enabled !== 'undefined') {
31095
+ apiPayload['enabled'] = enabled;
31096
+ }
31097
+ const uri = new URL(this.client.config.endpoint + apiPath);
31098
+ const apiHeaders = {
31099
+ 'X-Appwrite-Project': this.client.config.project,
31100
+ 'content-type': 'application/json',
31101
+ accept: 'application/json',
31102
+ };
31103
+ return this.client.call('patch', uri, apiHeaders, apiPayload);
31104
+ }
30512
31105
  updateOAuth2WordPress(paramsOrFirst, ...rest) {
30513
31106
  let params;
30514
31107
  if ((typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
@@ -33491,15 +34084,25 @@ class Sites {
33491
34084
  };
33492
34085
  return this.client.call('post', uri, apiHeaders, apiPayload);
33493
34086
  }
33494
- /**
33495
- * Get a list of all frameworks that are currently available on the server instance.
33496
- *
33497
- * @throws {AppwriteException}
33498
- * @returns {Promise<Models.FrameworkList>}
33499
- */
33500
- listFrameworks() {
34087
+ listFrameworks(paramsOrFirst) {
34088
+ let params;
34089
+ if (typeof paramsOrFirst === 'undefined' ||
34090
+ (paramsOrFirst &&
34091
+ typeof paramsOrFirst === 'object' &&
34092
+ !Array.isArray(paramsOrFirst))) {
34093
+ params = (paramsOrFirst || {});
34094
+ }
34095
+ else {
34096
+ params = {
34097
+ total: paramsOrFirst,
34098
+ };
34099
+ }
34100
+ const total = params.total;
33501
34101
  const apiPath = '/sites/frameworks';
33502
34102
  const apiPayload = {};
34103
+ if (typeof total !== 'undefined') {
34104
+ apiPayload['total'] = total;
34105
+ }
33503
34106
  const uri = new URL(this.client.config.endpoint + apiPath);
33504
34107
  const apiHeaders = {
33505
34108
  'X-Appwrite-Project': this.client.config.project,
@@ -33507,9 +34110,9 @@ class Sites {
33507
34110
  };
33508
34111
  return this.client.call('get', uri, apiHeaders, apiPayload);
33509
34112
  }
33510
- listSpecifications(paramsOrFirst) {
34113
+ listSpecifications(paramsOrFirst, ...rest) {
33511
34114
  let params;
33512
- if (typeof paramsOrFirst === 'undefined' ||
34115
+ if ((typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
33513
34116
  (paramsOrFirst &&
33514
34117
  typeof paramsOrFirst === 'object' &&
33515
34118
  !Array.isArray(paramsOrFirst))) {
@@ -33518,14 +34121,19 @@ class Sites {
33518
34121
  else {
33519
34122
  params = {
33520
34123
  type: paramsOrFirst,
34124
+ total: rest[0],
33521
34125
  };
33522
34126
  }
33523
34127
  const type = params.type;
34128
+ const total = params.total;
33524
34129
  const apiPath = '/sites/specifications';
33525
34130
  const apiPayload = {};
33526
34131
  if (typeof type !== 'undefined') {
33527
34132
  apiPayload['type'] = type;
33528
34133
  }
34134
+ if (typeof total !== 'undefined') {
34135
+ apiPayload['total'] = total;
34136
+ }
33529
34137
  const uri = new URL(this.client.config.endpoint + apiPath);
33530
34138
  const apiHeaders = {
33531
34139
  'X-Appwrite-Project': this.client.config.project,
@@ -33542,7 +34150,8 @@ class Sites {
33542
34150
  ('frameworks' in paramsOrFirst ||
33543
34151
  'useCases' in paramsOrFirst ||
33544
34152
  'limit' in paramsOrFirst ||
33545
- 'offset' in paramsOrFirst))) {
34153
+ 'offset' in paramsOrFirst ||
34154
+ 'total' in paramsOrFirst))) {
33546
34155
  params = (paramsOrFirst || {});
33547
34156
  }
33548
34157
  else {
@@ -33551,12 +34160,14 @@ class Sites {
33551
34160
  useCases: rest[0],
33552
34161
  limit: rest[1],
33553
34162
  offset: rest[2],
34163
+ total: rest[3],
33554
34164
  };
33555
34165
  }
33556
34166
  const frameworks = params.frameworks;
33557
34167
  const useCases = params.useCases;
33558
34168
  const limit = params.limit;
33559
34169
  const offset = params.offset;
34170
+ const total = params.total;
33560
34171
  const apiPath = '/sites/templates';
33561
34172
  const apiPayload = {};
33562
34173
  if (typeof frameworks !== 'undefined') {
@@ -33571,6 +34182,9 @@ class Sites {
33571
34182
  if (typeof offset !== 'undefined') {
33572
34183
  apiPayload['offset'] = offset;
33573
34184
  }
34185
+ if (typeof total !== 'undefined') {
34186
+ apiPayload['total'] = total;
34187
+ }
33574
34188
  const uri = new URL(this.client.config.endpoint + apiPath);
33575
34189
  const apiHeaders = {
33576
34190
  'X-Appwrite-Project': this.client.config.project,
@@ -34187,7 +34801,7 @@ class Sites {
34187
34801
  const uri = new URL(this.client.config.endpoint + apiPath);
34188
34802
  apiPayload['project'] = this.client.config.project;
34189
34803
  apiPayload['impersonateuserid'] = this.client.config.impersonateuserid;
34190
- for (const [key, value] of Object.entries(Service.flatten(apiPayload))) {
34804
+ for (const [key, value] of Object.entries(Client.flatten(apiPayload))) {
34191
34805
  uri.searchParams.append(key, value);
34192
34806
  }
34193
34807
  return uri.toString();
@@ -35018,7 +35632,7 @@ class Storage {
35018
35632
  const uri = new URL(this.client.config.endpoint + apiPath);
35019
35633
  apiPayload['project'] = this.client.config.project;
35020
35634
  apiPayload['impersonateuserid'] = this.client.config.impersonateuserid;
35021
- for (const [key, value] of Object.entries(Service.flatten(apiPayload))) {
35635
+ for (const [key, value] of Object.entries(Client.flatten(apiPayload))) {
35022
35636
  uri.searchParams.append(key, value);
35023
35637
  }
35024
35638
  return uri.toString();
@@ -35111,7 +35725,7 @@ class Storage {
35111
35725
  const uri = new URL(this.client.config.endpoint + apiPath);
35112
35726
  apiPayload['project'] = this.client.config.project;
35113
35727
  apiPayload['impersonateuserid'] = this.client.config.impersonateuserid;
35114
- for (const [key, value] of Object.entries(Service.flatten(apiPayload))) {
35728
+ for (const [key, value] of Object.entries(Client.flatten(apiPayload))) {
35115
35729
  uri.searchParams.append(key, value);
35116
35730
  }
35117
35731
  return uri.toString();
@@ -35149,7 +35763,7 @@ class Storage {
35149
35763
  const uri = new URL(this.client.config.endpoint + apiPath);
35150
35764
  apiPayload['project'] = this.client.config.project;
35151
35765
  apiPayload['impersonateuserid'] = this.client.config.impersonateuserid;
35152
- for (const [key, value] of Object.entries(Service.flatten(apiPayload))) {
35766
+ for (const [key, value] of Object.entries(Client.flatten(apiPayload))) {
35153
35767
  uri.searchParams.append(key, value);
35154
35768
  }
35155
35769
  return uri.toString();
@@ -35269,9 +35883,9 @@ class TablesDB {
35269
35883
  };
35270
35884
  return this.client.call('get', uri, apiHeaders, apiPayload);
35271
35885
  }
35272
- listTransactions(paramsOrFirst) {
35886
+ listTransactions(paramsOrFirst, ...rest) {
35273
35887
  let params;
35274
- if (typeof paramsOrFirst === 'undefined' ||
35888
+ if ((typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
35275
35889
  (paramsOrFirst &&
35276
35890
  typeof paramsOrFirst === 'object' &&
35277
35891
  !Array.isArray(paramsOrFirst))) {
@@ -35280,14 +35894,19 @@ class TablesDB {
35280
35894
  else {
35281
35895
  params = {
35282
35896
  queries: paramsOrFirst,
35897
+ total: rest[0],
35283
35898
  };
35284
35899
  }
35285
35900
  const queries = params.queries;
35901
+ const total = params.total;
35286
35902
  const apiPath = '/tablesdb/transactions';
35287
35903
  const apiPayload = {};
35288
35904
  if (typeof queries !== 'undefined') {
35289
35905
  apiPayload['queries'] = queries;
35290
35906
  }
35907
+ if (typeof total !== 'undefined') {
35908
+ apiPayload['total'] = total;
35909
+ }
35291
35910
  const uri = new URL(this.client.config.endpoint + apiPath);
35292
35911
  const apiHeaders = {
35293
35912
  'X-Appwrite-Project': this.client.config.project,
@@ -42109,12 +42728,14 @@ class Vcs {
42109
42728
  type: rest[0],
42110
42729
  search: rest[1],
42111
42730
  queries: rest[2],
42731
+ total: rest[3],
42112
42732
  };
42113
42733
  }
42114
42734
  const installationId = params.installationId;
42115
42735
  const type = params.type;
42116
42736
  const search = params.search;
42117
42737
  const queries = params.queries;
42738
+ const total = params.total;
42118
42739
  if (typeof installationId === 'undefined' || installationId === '') {
42119
42740
  throw new AppwriteException('Missing required parameter: "installationId"');
42120
42741
  }
@@ -42132,6 +42753,9 @@ class Vcs {
42132
42753
  if (typeof queries !== 'undefined') {
42133
42754
  apiPayload['queries'] = queries;
42134
42755
  }
42756
+ if (typeof total !== 'undefined') {
42757
+ apiPayload['total'] = total;
42758
+ }
42135
42759
  const uri = new URL(this.client.config.endpoint + apiPath);
42136
42760
  const apiHeaders = {
42137
42761
  'X-Appwrite-Project': this.client.config.project,
@@ -42232,12 +42856,14 @@ class Vcs {
42232
42856
  providerRepositoryId: rest[0],
42233
42857
  search: rest[1],
42234
42858
  queries: rest[2],
42859
+ total: rest[3],
42235
42860
  };
42236
42861
  }
42237
42862
  const installationId = params.installationId;
42238
42863
  const providerRepositoryId = params.providerRepositoryId;
42239
42864
  const search = params.search;
42240
42865
  const queries = params.queries;
42866
+ const total = params.total;
42241
42867
  if (typeof installationId === 'undefined' || installationId === '') {
42242
42868
  throw new AppwriteException('Missing required parameter: "installationId"');
42243
42869
  }
@@ -42255,6 +42881,9 @@ class Vcs {
42255
42881
  if (typeof queries !== 'undefined') {
42256
42882
  apiPayload['queries'] = queries;
42257
42883
  }
42884
+ if (typeof total !== 'undefined') {
42885
+ apiPayload['total'] = total;
42886
+ }
42258
42887
  const uri = new URL(this.client.config.endpoint + apiPath);
42259
42888
  const apiHeaders = {
42260
42889
  'X-Appwrite-Project': this.client.config.project,
@@ -42445,11 +43074,13 @@ class Vcs {
42445
43074
  installationId: paramsOrFirst,
42446
43075
  search: rest[0],
42447
43076
  queries: rest[1],
43077
+ total: rest[2],
42448
43078
  };
42449
43079
  }
42450
43080
  const installationId = params.installationId;
42451
43081
  const search = params.search;
42452
43082
  const queries = params.queries;
43083
+ const total = params.total;
42453
43084
  if (typeof installationId === 'undefined' || installationId === '') {
42454
43085
  throw new AppwriteException('Missing required parameter: "installationId"');
42455
43086
  }
@@ -42461,6 +43092,9 @@ class Vcs {
42461
43092
  if (typeof queries !== 'undefined') {
42462
43093
  apiPayload['queries'] = queries;
42463
43094
  }
43095
+ if (typeof total !== 'undefined') {
43096
+ apiPayload['total'] = total;
43097
+ }
42464
43098
  const uri = new URL(this.client.config.endpoint + apiPath);
42465
43099
  const apiHeaders = {
42466
43100
  'X-Appwrite-Project': this.client.config.project,
@@ -42578,9 +43212,9 @@ class VectorsDB {
42578
43212
  };
42579
43213
  return this.client.call('get', uri, apiHeaders, apiPayload);
42580
43214
  }
42581
- listTransactions(paramsOrFirst) {
43215
+ listTransactions(paramsOrFirst, ...rest) {
42582
43216
  let params;
42583
- if (typeof paramsOrFirst === 'undefined' ||
43217
+ if ((typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
42584
43218
  (paramsOrFirst &&
42585
43219
  typeof paramsOrFirst === 'object' &&
42586
43220
  !Array.isArray(paramsOrFirst))) {
@@ -42589,14 +43223,19 @@ class VectorsDB {
42589
43223
  else {
42590
43224
  params = {
42591
43225
  queries: paramsOrFirst,
43226
+ total: rest[0],
42592
43227
  };
42593
43228
  }
42594
43229
  const queries = params.queries;
43230
+ const total = params.total;
42595
43231
  const apiPath = '/vectorsdb/transactions';
42596
43232
  const apiPayload = {};
42597
43233
  if (typeof queries !== 'undefined') {
42598
43234
  apiPayload['queries'] = queries;
42599
43235
  }
43236
+ if (typeof total !== 'undefined') {
43237
+ apiPayload['total'] = total;
43238
+ }
42600
43239
  const uri = new URL(this.client.config.endpoint + apiPath);
42601
43240
  const apiHeaders = {
42602
43241
  'X-Appwrite-Project': this.client.config.project,
@@ -45658,6 +46297,27 @@ class Realtime {
45658
46297
  }
45659
46298
  }
45660
46299
 
46300
+ const TAB_ID_KEY = 'appwrite-push-client-id';
46301
+ // Loaded on first connect, so an app that never uses Push does not bundle mqtt.js.
46302
+ let transport = null;
46303
+ function loadTransport() {
46304
+ if (!transport) {
46305
+ transport = Promise.all([import('mqtt'), import('buffer')]).then(
46306
+ // The browser build of mqtt.js (dist/mqtt.esm.js) exports only a default.
46307
+ ([mqtt, buffer]) => {
46308
+ var _a;
46309
+ return ({
46310
+ connect: ((_a = mqtt.default) !== null && _a !== void 0 ? _a : mqtt).connect,
46311
+ Buffer: buffer.Buffer,
46312
+ });
46313
+ });
46314
+ // A failed load must not poison later connects.
46315
+ transport.catch(() => {
46316
+ transport = null;
46317
+ });
46318
+ }
46319
+ return transport;
46320
+ }
45661
46321
  // Fixed connection tuning — not exposed as options.
45662
46322
  const KEEP_ALIVE_SECONDS = 60;
45663
46323
  const RECONNECT_PERIOD_MS = 2000;
@@ -45682,11 +46342,13 @@ const RECONNECT_PERIOD_MS = 2000;
45682
46342
  * );
45683
46343
  * // sub.update({ background: true }); sub.unsubscribe();
45684
46344
  */
45685
- class Push extends Service {
46345
+ class Push {
45686
46346
  constructor(client) {
45687
- super(client);
45688
46347
  this.mqtt = null;
45689
46348
  this.connecting = null;
46349
+ this.Buffer = null;
46350
+ /** Bumped by close(), so a connect still loading mqtt.js knows to stop. */
46351
+ this.generation = 0;
45690
46352
  /** Set once the first CONNACK lands, so 'connect' events after are reconnects. */
45691
46353
  this.everConnected = false;
45692
46354
  /** Errors already handed to onError, so one failure is reported once. */
@@ -45698,11 +46360,20 @@ class Push extends Service {
45698
46360
  // Local id -> subscription state. The id is never sent to the broker; it only lets
45699
46361
  // the same topic carry more than one callback (each with its own options).
45700
46362
  /**
45701
- * The client id when the credential names no user (and none was set): random, but kept for
45702
- * this instance so reconnects resume the same broker session.
46363
+ * This tab's part of the default client id when the tab has none yet (see claimTabId):
46364
+ * random, but kept for this instance so reconnects resume the same broker session.
45703
46365
  */
45704
46366
  this.fallbackClientId = randomId();
46367
+ /** The default client id claimed for this instance's connection, released on close(). */
46368
+ this.tabId = '';
46369
+ /** In-flight claim of {@link tabId}, memoized per generation: a credential switch (same
46370
+ * generation) shares the one claim; a close/reopen (new generation) chains a fresh claim. */
46371
+ this.tabIdClaim = null;
46372
+ this.tabIdClaimGeneration = -1;
46373
+ this.connectedKey = '';
46374
+ this.connectionEpoch = 0;
45705
46375
  this.subscriptions = new Map();
46376
+ this.client = client;
45706
46377
  }
45707
46378
  // The broker subscription for a filter uses the highest QoS any local subscription on
45708
46379
  // it wants, so a QoS-0 subscription never downgrades a QoS-1 one sharing the filter.
@@ -45802,7 +46473,17 @@ class Push extends Service {
45802
46473
  if (background) {
45803
46474
  this.requestNotificationPermission();
45804
46475
  }
45805
- const client = yield this.connect();
46476
+ let client;
46477
+ try {
46478
+ client = yield this.connect();
46479
+ }
46480
+ catch (err) {
46481
+ if (err instanceof SupersededError) {
46482
+ return this.subscribeWith(topicsOrCallback, callbackOrOptions, topicOptions);
46483
+ }
46484
+ throw err;
46485
+ }
46486
+ const epoch = this.connectionEpoch;
45806
46487
  const ids = [];
45807
46488
  const acks = [];
45808
46489
  for (const topic of topicList) {
@@ -45861,6 +46542,12 @@ class Push extends Service {
45861
46542
  yield Promise.all(acks);
45862
46543
  }
45863
46544
  catch (err) {
46545
+ if (epoch !== this.connectionEpoch) {
46546
+ for (const id of ids) {
46547
+ this.subscriptions.delete(id);
46548
+ }
46549
+ return this.subscribeWith(topicsOrCallback, callbackOrOptions, topicOptions);
46550
+ }
45864
46551
  unsubscribe();
45865
46552
  throw err;
45866
46553
  }
@@ -45921,7 +46608,14 @@ class Push extends Service {
45921
46608
  this.mqtt.end(true);
45922
46609
  this.mqtt = null;
45923
46610
  }
46611
+ if (this.tabId !== '') {
46612
+ releaseTabId(this.tabId);
46613
+ this.tabId = '';
46614
+ }
45924
46615
  this.connecting = null;
46616
+ // Bumping the generation ends the current claim: one still in flight releases its id when
46617
+ // it resolves, and the next open() chains a fresh claim after it (see claimClientId).
46618
+ this.generation++;
45925
46619
  this.everConnected = false;
45926
46620
  this.subscriptions.clear();
45927
46621
  }
@@ -45946,19 +46640,62 @@ class Push extends Service {
45946
46640
  }
45947
46641
  // --- internals ---
45948
46642
  connect() {
45949
- if (this.mqtt) {
46643
+ var _a;
46644
+ if ((this.mqtt || this.connecting) &&
46645
+ this.connectedKey !== this.credentialKey()) {
46646
+ this.connectionEpoch++;
46647
+ (_a = this.mqtt) === null || _a === void 0 ? void 0 : _a.end(true);
46648
+ this.mqtt = null;
46649
+ this.connecting = null;
46650
+ this.everConnected = this.subscriptions.size > 0;
46651
+ }
46652
+ if (this.mqtt && !this.connecting) {
45950
46653
  return Promise.resolve(this.mqtt);
45951
46654
  }
45952
46655
  if (!this.connecting) {
45953
- this.connecting = this.open();
46656
+ const connecting = this.open();
46657
+ this.connecting = connecting;
45954
46658
  // A failed open must not poison future attempts — clear the cached
45955
46659
  // in-flight promise so a later subscribe/publish can retry.
45956
- this.connecting.catch(() => {
45957
- this.connecting = null;
46660
+ connecting.catch(() => {
46661
+ if (this.connecting === connecting) {
46662
+ this.connecting = null;
46663
+ }
45958
46664
  });
45959
46665
  }
45960
46666
  return this.connecting.then(() => this.mqtt);
45961
46667
  }
46668
+ credential() {
46669
+ if (this.client.config.jwt) {
46670
+ return {
46671
+ authMethod: 'appwrite-jwt',
46672
+ credential: this.client.config.jwt,
46673
+ };
46674
+ }
46675
+ if (this.client.config.session) {
46676
+ return {
46677
+ authMethod: 'appwrite-session',
46678
+ credential: this.client.config.session,
46679
+ };
46680
+ }
46681
+ throw new Error('No credential set on the client; call Client.setJWT() or Client.setSession() first.');
46682
+ }
46683
+ credentialKey() {
46684
+ var _a, _b;
46685
+ try {
46686
+ const { authMethod, credential } = this.credential();
46687
+ return [
46688
+ this.endpointUrl(),
46689
+ (_a = this.client.config.project) !== null && _a !== void 0 ? _a : '',
46690
+ (_b = this.client.config.pushClientId) !== null && _b !== void 0 ? _b : '',
46691
+ authMethod,
46692
+ credential,
46693
+ ].join('|');
46694
+ }
46695
+ catch (_c) {
46696
+ return '';
46697
+ }
46698
+ }
45962
46699
  endpointUrl() {
45963
46700
  // The push endpoint set on the client (Client.setPushEndpoint) wins.
45964
46701
  if (this.client.config.endpointPush !== '') {
@@ -45976,35 +46713,76 @@ class Push extends Service {
45976
46713
  ? wsEndpoint
45977
46714
  : `${wsEndpoint.slice(0, at + separator.length)}push.${wsEndpoint.slice(at + separator.length)}`;
45978
46715
  }
46716
+ /**
46717
+ * Claim this connection's default client id, memoized per generation. A credential switch (same
46718
+ * generation) shares the one claim, so concurrent open() calls never each claim. A close/reopen
46719
+ * (a new generation) chains a fresh claim after the previous one has settled and released its
46720
+ * id, so the reopened connection can take the tab's stored id back rather than a fallback. A
46721
+ * claim that resolves after its generation has ended releases its id instead of keeping it, so
46722
+ * a stale open connects with nothing reserved and the stored id is never stranded.
46723
+ */
46724
+ claimClientId() {
46725
+ var _a;
46726
+ const generation = this.generation;
46727
+ if (this.tabIdClaim === null ||
46728
+ this.tabIdClaimGeneration !== generation) {
46729
+ const previous = (_a = this.tabIdClaim) !== null && _a !== void 0 ? _a : Promise.resolve('');
46730
+ this.tabIdClaimGeneration = generation;
46731
+ const claim = previous
46732
+ .catch(() => '')
46733
+ .then(() => claimTabId(this.fallbackClientId))
46734
+ .then((id) => {
46735
+ if (this.generation !== generation) {
46736
+ releaseTabId(id);
46737
+ return '';
46738
+ }
46739
+ this.tabId = id;
46740
+ return id;
46741
+ });
46742
+ this.tabIdClaim = claim;
46743
+ return claim;
46744
+ }
46745
+ return this.tabIdClaim;
46746
+ }
45979
46747
  open() {
45980
46748
  return __awaiter(this, void 0, void 0, function* () {
45981
46749
  var _a;
45982
- // Read the credential set on the client (via Client.setJWT / setSession).
45983
- let authMethod;
45984
- let credential;
45985
- if (this.client.config.jwt) {
45986
- authMethod = 'appwrite-jwt';
45987
- credential = this.client.config.jwt;
45988
- }
45989
- else if (this.client.config.session) {
45990
- authMethod = 'appwrite-session';
45991
- credential = this.client.config.session;
45992
- }
45993
- else {
45994
- throw new Error('No credential set on the client; call Client.setJWT() or Client.setSession() first.');
45995
- }
46750
+ const { authMethod, credential } = this.credential();
46751
+ this.connectedKey = this.credentialKey();
46752
+ const epoch = this.connectionEpoch;
46753
+ const generation = this.generation;
45996
46754
  const project = (_a = this.client.config.project) !== null && _a !== void 0 ? _a : '';
45997
46755
  // Client id, when the app did not set one with Client.setPushClientId(). Unlike the
45998
46756
  // native SDKs (which send an empty id and let the broker derive a stable one), mqtt.js
45999
- // rejects an empty id with clean start off, so derive a stable per-user id here from the
46000
- // credential this connection authenticates with: the JWT's userId, or the session's user
46001
- // id. A stable id keeps the broker's replay cursor resuming across reloads. The
46002
- // credential itself is never used as the id.
46757
+ // rejects an empty id with clean start off, so derive one per user and tab from the
46758
+ // credential this connection authenticates with (the JWT's userId, or the session's user
46759
+ // id) and an id kept in the tab's sessionStorage. It stays the same across reloads, so
46760
+ // the broker's replay cursor resumes, and differs between tabs and browsers, so two of
46761
+ // them do not take over each other's session. The credential itself is never used.
46762
+ const userId = authMethod === 'appwrite-jwt'
46763
+ ? userIdFromJwt(credential)
46764
+ : userIdFromSession(credential);
46765
+ // Claim once per instance (memoized) and reuse it across reconnects and credential
46766
+ // switches, so concurrent open() calls never each claim and strand the tab's stored id.
46767
+ // Concurrent instances still get distinct ids. If close() ran while the claim was pending
46768
+ // this open is stale, so stop before connecting (the claim releases its own id).
46769
+ if (!this.client.config.pushClientId) {
46770
+ yield this.claimClientId();
46771
+ if (generation !== this.generation) {
46772
+ throw new Error('Push was closed while connecting.');
46773
+ }
46774
+ }
46775
+ const tabId = this.tabId;
46003
46776
  const clientId = this.client.config.pushClientId ||
46004
- (authMethod === 'appwrite-jwt'
46005
- ? userIdFromJwt(credential)
46006
- : userIdFromSession(credential)) ||
46007
- this.fallbackClientId;
46777
+ (userId ? `${userId}-${tabId}` : tabId);
46778
+ const { connect, Buffer } = yield loadTransport();
46779
+ if (generation !== this.generation) {
46780
+ throw new Error('Push was closed while connecting.');
46781
+ }
46782
+ if (epoch !== this.connectionEpoch) {
46783
+ throw new SupersededError();
46784
+ }
46785
+ this.Buffer = Buffer;
46008
46786
  const options = {
46009
46787
  clientId,
46010
46788
  protocolVersion: 5,
@@ -46015,11 +46793,11 @@ class Push extends Service {
46015
46793
  // Enhanced auth carried in CONNECT properties.
46016
46794
  properties: {
46017
46795
  authenticationMethod: authMethod,
46018
- authenticationData: buffer.Buffer.from(credential),
46796
+ authenticationData: Buffer.from(credential),
46019
46797
  userProperties: { projectId: project },
46020
46798
  },
46021
46799
  };
46022
- const client = mqtt.connect(this.endpointUrl(), options);
46800
+ const client = connect(this.endpointUrl(), options);
46023
46801
  this.mqtt = client;
46024
46802
  client.on('message', (_topic, _payload, packet) => {
46025
46803
  this.dispatch(packet).catch((err) => this.report(err));
@@ -46051,6 +46829,9 @@ class Push extends Service {
46051
46829
  }
46052
46830
  });
46053
46831
  client.on('error', (err) => {
46832
+ if (epoch !== this.connectionEpoch) {
46833
+ return;
46834
+ }
46054
46835
  const error = this.connectError(err, refusedReason);
46055
46836
  // While the first connect is pending its caller receives the error (and reports it
46056
46837
  // through fail()); afterwards, e.g. on reconnect, report it here.
@@ -46069,6 +46850,10 @@ class Push extends Service {
46069
46850
  const onConnect = (packet) => {
46070
46851
  var _a, _b;
46071
46852
  cleanup();
46853
+ if (epoch !== this.connectionEpoch) {
46854
+ reject(new SupersededError());
46855
+ return;
46856
+ }
46072
46857
  const rc = (_b = (_a = packet.reasonCode) !== null && _a !== void 0 ? _a : packet.returnCode) !== null && _b !== void 0 ? _b : 0;
46073
46858
  if (rc !== 0) {
46074
46859
  this.close();
@@ -46080,16 +46865,30 @@ class Push extends Service {
46080
46865
  };
46081
46866
  const onError = (err) => {
46082
46867
  cleanup();
46868
+ if (epoch !== this.connectionEpoch) {
46869
+ reject(new SupersededError());
46870
+ return;
46871
+ }
46083
46872
  this.close();
46084
46873
  reject(this.connectError(err, refusedReason));
46085
46874
  };
46875
+ const onClose = () => {
46876
+ if (epoch !== this.connectionEpoch) {
46877
+ cleanup();
46878
+ reject(new SupersededError());
46879
+ }
46880
+ };
46086
46881
  const cleanup = () => {
46087
- this.opening = false;
46882
+ if (epoch === this.connectionEpoch) {
46883
+ this.opening = false;
46884
+ }
46088
46885
  client.removeListener('connect', onConnect);
46089
46886
  client.removeListener('error', onError);
46887
+ client.removeListener('close', onClose);
46090
46888
  };
46091
46889
  client.on('connect', onConnect);
46092
46890
  client.on('error', onError);
46891
+ client.on('close', onClose);
46093
46892
  client.connect();
46094
46893
  });
46095
46894
  });
@@ -46111,9 +46910,10 @@ class Push extends Service {
46111
46910
  /** Fan a delivered packet out to every subscription whose filter matches. */
46112
46911
  dispatch(packet) {
46113
46912
  return __awaiter(this, void 0, void 0, function* () {
46114
- const payload = buffer.Buffer.isBuffer(packet.payload)
46913
+ const Buffer = this.Buffer;
46914
+ const payload = Buffer.isBuffer(packet.payload)
46115
46915
  ? packet.payload
46116
- : buffer.Buffer.from(packet.payload);
46916
+ : Buffer.from(packet.payload);
46117
46917
  const message = {
46118
46918
  topic: packet.topic.toString(),
46119
46919
  data: new TextDecoder().decode(payload),
@@ -46154,6 +46954,11 @@ class Push extends Service {
46154
46954
  }
46155
46955
  }
46156
46956
  }
46957
+ class SupersededError extends Error {
46958
+ constructor() {
46959
+ super('The push connection was superseded');
46960
+ }
46961
+ }
46157
46962
  /** Normalize anything thrown or passed to an error handler into an `Error`. */
46158
46963
  function toError(error) {
46159
46964
  return error instanceof Error ? error : new Error(String(error));
@@ -46172,8 +46977,7 @@ function userIdFromJwt(jwt) {
46172
46977
  return '';
46173
46978
  }
46174
46979
  try {
46175
- const json = buffer.Buffer.from(parts[1].replace(/-/g, '+').replace(/_/g, '/'), 'base64').toString('utf-8');
46176
- const payload = JSON.parse(json);
46980
+ const payload = JSON.parse(decodeBase64(parts[1].replace(/-/g, '+').replace(/_/g, '/')));
46177
46981
  return typeof payload.userId === 'string' ? payload.userId : '';
46178
46982
  }
46179
46983
  catch (_a) {
@@ -46189,13 +46993,99 @@ function userIdFromSession(session) {
46189
46993
  return '';
46190
46994
  }
46191
46995
  try {
46192
- const payload = JSON.parse(buffer.Buffer.from(session, 'base64').toString('utf-8'));
46996
+ const payload = JSON.parse(decodeBase64(session));
46193
46997
  return typeof payload.id === 'string' ? payload.id : '';
46194
46998
  }
46195
46999
  catch (_a) {
46196
47000
  return '';
46197
47001
  }
46198
47002
  }
47003
+ /** Ids in use by live connections in this page, so two Push instances never share a client id. */
47004
+ const claimedTabIds = new Set();
47005
+ /** The tab's stored id, resolved and locked once per page (see claimStoredTabId). */
47006
+ let storedTabIdClaim = null;
47007
+ /**
47008
+ * A default client id for one Push connection in this page. The first connection alive takes the
47009
+ * tab's stored id (kept in sessionStorage and locked for the page's lifetime, so it stays the same
47010
+ * across reloads and the broker's replay cursor resumes). Any connection alive at the same time
47011
+ * takes a distinct locked id instead, so simultaneous Push instances never share a client id and
47012
+ * so cannot take over each other's broker session. `fallback` is this instance's own random id.
47013
+ */
47014
+ function claimTabId(fallback) {
47015
+ return __awaiter(this, void 0, void 0, function* () {
47016
+ const stored = yield claimStoredTabId(fallback);
47017
+ if (stored !== '' && !claimedTabIds.has(stored)) {
47018
+ claimedTabIds.add(stored);
47019
+ return stored;
47020
+ }
47021
+ // The tab's id is taken by another live connection here: take a distinct, locked id without
47022
+ // touching the tab's stored cursor.
47023
+ let id = fallback;
47024
+ while (claimedTabIds.has(id)) {
47025
+ id = randomId();
47026
+ }
47027
+ const locks = typeof navigator === 'undefined' ? undefined : navigator.locks;
47028
+ if (locks) {
47029
+ yield holdTabId(locks, id);
47030
+ }
47031
+ claimedTabIds.add(id);
47032
+ return id;
47033
+ });
47034
+ }
47035
+ /** Free an id when its connection closes, so a later connection can reuse it (e.g. the stored id). */
47036
+ function releaseTabId(id) {
47037
+ claimedTabIds.delete(id);
47038
+ }
47039
+ /**
47040
+ * The tab's stored id, resolved and locked once per page: the value in sessionStorage when a lock
47041
+ * on it is free (this tab owns it), else a fresh id that is locked and stored. Without Web Locks
47042
+ * (or when locking fails) a copied id cannot be told apart from another tab's, so the page uses a
47043
+ * fresh id and leaves sessionStorage alone. '' when sessionStorage cannot be read, so the caller
47044
+ * falls back to its own id.
47045
+ */
47046
+ function claimStoredTabId(fallback) {
47047
+ storedTabIdClaim !== null && storedTabIdClaim !== void 0 ? storedTabIdClaim : (storedTabIdClaim = (() => __awaiter(this, void 0, void 0, function* () {
47048
+ const locks = typeof navigator === 'undefined' ? undefined : navigator.locks;
47049
+ if (!locks) {
47050
+ return fallback;
47051
+ }
47052
+ let stored;
47053
+ try {
47054
+ stored = window.sessionStorage.getItem(TAB_ID_KEY);
47055
+ }
47056
+ catch (_a) {
47057
+ return '';
47058
+ }
47059
+ if (stored && (yield holdTabId(locks, stored))) {
47060
+ return stored;
47061
+ }
47062
+ if (!(yield holdTabId(locks, fallback))) {
47063
+ return fallback;
47064
+ }
47065
+ try {
47066
+ window.sessionStorage.setItem(TAB_ID_KEY, fallback);
47067
+ }
47068
+ catch (_b) {
47069
+ // Not persisted, but still usable as this page's stored id for this session.
47070
+ }
47071
+ return fallback;
47072
+ }))());
47073
+ return storedTabIdClaim;
47074
+ }
47075
+ function holdTabId(locks, id) {
47076
+ return new Promise((resolve) => {
47077
+ locks
47078
+ .request(`${TAB_ID_KEY}:${id}`, { ifAvailable: true }, (lock) => {
47079
+ resolve(lock !== null);
47080
+ return lock ? new Promise(() => { }) : undefined;
47081
+ })
47082
+ .catch(() => resolve(false));
47083
+ });
47084
+ }
47085
+ /** Base64 to UTF-8 text without `buffer`, which only loads once Push connects. */
47086
+ function decodeBase64(value) {
47087
+ return new TextDecoder().decode(Uint8Array.from(atob(value), (char) => char.charCodeAt(0)));
47088
+ }
46199
47089
  /** A hex id, uuid4-like enough for a client-generated client id suffix. */
46200
47090
  function randomId() {
46201
47091
  let out = '';
@@ -46223,6 +47113,670 @@ function matches(filter, topic) {
46223
47113
  return filterParts.length === topicParts.length;
46224
47114
  }
46225
47115
 
47116
+ /**
47117
+ * Analytics auto-tracking helpers.
47118
+ *
47119
+ * These are hand-written companions to the generated `Analytics` service.
47120
+ * The generated service exposes `createEvent(params)` for arbitrary events;
47121
+ * this module wires up common auto-tracking behaviours (pageviews, outbound
47122
+ * links, downloads, scroll depth, active engagement) on top of it.
47123
+ *
47124
+ * The tracking helpers accept a plain event-emitter function so they do not
47125
+ * hard-couple to the generated `Analytics` class. The emitter adapts this
47126
+ * module's option shape to `createEvent`: `url` is required there, and `props`
47127
+ * is a flat alternating key/value list rather than an object.
47128
+ *
47129
+ * ```ts
47130
+ * const analytics = new Analytics(client);
47131
+ * const tracking = new AnalyticsTracking(
47132
+ * (name, options) => analytics.createEvent({
47133
+ * propertyId: options?.propertyId ?? '<PROPERTY_ID>',
47134
+ * name,
47135
+ * url: options?.url ?? window.location.href,
47136
+ * referrer: options?.referrer,
47137
+ * scrollDepth: options?.scrollDepth,
47138
+ * engagementTime: options?.engagementTime,
47139
+ * props: Object.entries(options?.props ?? {}).flatMap(
47140
+ * ([key, value]) => [key, String(value)],
47141
+ * ),
47142
+ * }),
47143
+ * { propertyId: '<PROPERTY_ID>' }
47144
+ * );
47145
+ * tracking.enableAllAutoTracking();
47146
+ * ```
47147
+ *
47148
+ * `propertyId` is optional: when set it is merged into the options of every
47149
+ * emitted event, so an emitter that forwards `options.propertyId` (as above)
47150
+ * picks it up instead of every caller hand-rolling it into the closure.
47151
+ * Per-event `propertyId` always wins over the configured default.
47152
+ *
47153
+ * All helpers respect `navigator.doNotTrack === '1'` by default; opt out with
47154
+ * `respectDoNotTrack: false` in the constructor options.
47155
+ *
47156
+ * Engagement time follows Plausible's model: rather than one total at unload,
47157
+ * a delta is emitted at every natural checkpoint of the visit (tab hidden, SPA
47158
+ * route change, unload). See `enableAutoEngagementTime` for details.
47159
+ *
47160
+ * Auto-emitted event names follow `snake_case` + lowercase (`pageview`,
47161
+ * `outbound_link`, `file_download`, `screen_view`, etc.). Any prop keys use
47162
+ * camelCase to match the endpoint's parameter naming. Callers can pass any
47163
+ * custom event name; the auto-track methods only own the events they emit
47164
+ * themselves.
47165
+ */
47166
+ const DEFAULT_DOWNLOAD_EXTENSIONS = [
47167
+ 'pdf',
47168
+ 'zip',
47169
+ 'rar',
47170
+ '7z',
47171
+ 'tar',
47172
+ 'gz',
47173
+ 'csv',
47174
+ 'tsv',
47175
+ 'xls',
47176
+ 'xlsx',
47177
+ 'doc',
47178
+ 'docx',
47179
+ 'ppt',
47180
+ 'pptx',
47181
+ 'dmg',
47182
+ 'exe',
47183
+ 'msi',
47184
+ 'pkg',
47185
+ 'deb',
47186
+ 'rpm',
47187
+ 'apk',
47188
+ 'mp3',
47189
+ 'wav',
47190
+ 'flac',
47191
+ 'mp4',
47192
+ 'mov',
47193
+ 'avi',
47194
+ 'mkv',
47195
+ 'webm',
47196
+ ];
47197
+ /**
47198
+ * Two-part public suffixes common enough to matter for outbound-link detection.
47199
+ * See `rootDomain()` for why this is a short list rather than the Public Suffix
47200
+ * List.
47201
+ */
47202
+ const MULTI_PART_SUFFIXES = new Set([
47203
+ 'co.uk',
47204
+ 'org.uk',
47205
+ 'ac.uk',
47206
+ 'gov.uk',
47207
+ 'me.uk',
47208
+ 'net.uk',
47209
+ 'sch.uk',
47210
+ 'co.jp',
47211
+ 'ne.jp',
47212
+ 'or.jp',
47213
+ 'ac.jp',
47214
+ 'go.jp',
47215
+ 'com.au',
47216
+ 'net.au',
47217
+ 'org.au',
47218
+ 'edu.au',
47219
+ 'gov.au',
47220
+ 'com.br',
47221
+ 'net.br',
47222
+ 'org.br',
47223
+ 'com.cn',
47224
+ 'net.cn',
47225
+ 'org.cn',
47226
+ 'gov.cn',
47227
+ 'co.in',
47228
+ 'net.in',
47229
+ 'org.in',
47230
+ 'co.nz',
47231
+ 'net.nz',
47232
+ 'org.nz',
47233
+ 'co.za',
47234
+ 'org.za',
47235
+ 'com.mx',
47236
+ 'com.ar',
47237
+ 'com.co',
47238
+ 'com.pe',
47239
+ 'com.tr',
47240
+ 'com.tw',
47241
+ 'com.sg',
47242
+ 'com.hk',
47243
+ 'com.my',
47244
+ 'com.ph',
47245
+ 'com.vn',
47246
+ 'co.kr',
47247
+ 'co.il',
47248
+ 'co.id',
47249
+ 'co.th',
47250
+ 'com.ua',
47251
+ 'com.pl',
47252
+ 'com.es',
47253
+ ]);
47254
+ const SCROLL_DEPTH_THROTTLE_MS = 200;
47255
+ class AnalyticsTracking {
47256
+ constructor(emit, options = {}) {
47257
+ this.pageviewCleanups = [];
47258
+ this.scrollCleanups = [];
47259
+ this.engagementCleanups = [];
47260
+ this.maxScrollDepth = 0;
47261
+ this.scrollTicking = false;
47262
+ this.lastScrollReport = 0;
47263
+ this.engagementStart = 0;
47264
+ this.engagementAccumulatedMs = 0;
47265
+ this.engagementActive = false;
47266
+ this.emit = emit;
47267
+ this.respectDoNotTrack = options.respectDoNotTrack !== false;
47268
+ this.propertyId = options.propertyId;
47269
+ }
47270
+ /**
47271
+ * Enable the opinionated default auto-tracking set: pageviews, outbound
47272
+ * links, scroll depth and active engagement time. Downloads must be opted
47273
+ * into separately via `enableAutoDownloadTracking()` because the extension
47274
+ * list is application-specific.
47275
+ */
47276
+ enableAllAutoTracking() {
47277
+ this.enableAutoPageviews();
47278
+ this.enableAutoOutboundTracking();
47279
+ this.enableAutoScrollDepth();
47280
+ this.enableAutoEngagementTime();
47281
+ }
47282
+ /**
47283
+ * Track an event manually. Respects the DNT setting and swallows emitter
47284
+ * exceptions so tracking failures never surface to the host page.
47285
+ */
47286
+ track(name, options) {
47287
+ if (!this.canTrack()) {
47288
+ return;
47289
+ }
47290
+ try {
47291
+ this.emit(name, this.withPropertyId(options));
47292
+ }
47293
+ catch (error) {
47294
+ console.warn('AnalyticsTracking: emitter threw', error);
47295
+ }
47296
+ }
47297
+ /**
47298
+ * Convenience wrapper for pageview-shaped events.
47299
+ */
47300
+ pageview(url, referrer) {
47301
+ this.track('pageview', {
47302
+ url: url !== null && url !== void 0 ? url : this.currentPageUrl(),
47303
+ referrer: referrer !== null && referrer !== void 0 ? referrer : (typeof document !== 'undefined'
47304
+ ? document.referrer
47305
+ : undefined),
47306
+ });
47307
+ }
47308
+ /**
47309
+ * Enable SPA-aware pageview tracking. Fires an initial pageview on
47310
+ * enable, then again on every `pushState`, `replaceState`, `popstate`
47311
+ * or hashchange. Idempotent — repeat calls no-op.
47312
+ */
47313
+ enableAutoPageviews() {
47314
+ if (this.pageviewCleanups.length > 0) {
47315
+ return;
47316
+ }
47317
+ if (typeof window === 'undefined' || typeof history === 'undefined') {
47318
+ return;
47319
+ }
47320
+ this.currentPath = this.currentPageUrl();
47321
+ this.pageview();
47322
+ const handleNavigation = () => {
47323
+ const nextPath = this.currentPageUrl();
47324
+ if (nextPath === this.currentPath) {
47325
+ return;
47326
+ }
47327
+ const previous = this.currentPath;
47328
+ this.currentPath = nextPath;
47329
+ this.flushScrollDepth(previous);
47330
+ this.flushEngagement(previous);
47331
+ this.pageview(nextPath);
47332
+ // flushEngagement no longer auto-restarts the timer (see its
47333
+ // implementation note re: bfcache). SPA navigation stays on the
47334
+ // same document, so restart engagement tracking for the new
47335
+ // route as long as the tab is visible.
47336
+ if (this.engagementCleanups.length > 0 &&
47337
+ (typeof document === 'undefined' ||
47338
+ document.visibilityState !== 'hidden')) {
47339
+ this.startEngagement();
47340
+ }
47341
+ };
47342
+ const originalPushState = history.pushState.bind(history);
47343
+ const originalReplaceState = history.replaceState.bind(history);
47344
+ // Our wrappers stay reachable after cleanup whenever another library
47345
+ // patched on top of ours, so they have to be switchable off rather than
47346
+ // merely unreferenced.
47347
+ let patchActive = true;
47348
+ const patchedPushState = (data, unused, url) => {
47349
+ originalPushState(data, unused, url);
47350
+ if (patchActive) {
47351
+ handleNavigation();
47352
+ }
47353
+ };
47354
+ const patchedReplaceState = (data, unused, url) => {
47355
+ originalReplaceState(data, unused, url);
47356
+ if (patchActive) {
47357
+ handleNavigation();
47358
+ }
47359
+ };
47360
+ history.pushState = patchedPushState;
47361
+ history.replaceState = patchedReplaceState;
47362
+ const popstateHandler = () => handleNavigation();
47363
+ const hashchangeHandler = () => handleNavigation();
47364
+ window.addEventListener('popstate', popstateHandler);
47365
+ window.addEventListener('hashchange', hashchangeHandler);
47366
+ this.pageviewCleanups.push(() => {
47367
+ // Only unwind our own patch. A router (Next.js App Router, React
47368
+ // Router, …) that patched these after us owns the current value,
47369
+ // and assigning our saved reference back would silently throw its
47370
+ // wrapper away. In that case ours stays in the chain, which is why
47371
+ // `patchActive` exists: the wrapper keeps delegating to the original
47372
+ // but stops reporting.
47373
+ patchActive = false;
47374
+ if (history.pushState === patchedPushState) {
47375
+ history.pushState = originalPushState;
47376
+ }
47377
+ if (history.replaceState === patchedReplaceState) {
47378
+ history.replaceState = originalReplaceState;
47379
+ }
47380
+ window.removeEventListener('popstate', popstateHandler);
47381
+ window.removeEventListener('hashchange', hashchangeHandler);
47382
+ });
47383
+ }
47384
+ /**
47385
+ * Disable auto-pageview tracking installed by `enableAutoPageviews`.
47386
+ * Safe to call when auto-pageviews were never enabled.
47387
+ */
47388
+ disableAutoPageviews() {
47389
+ for (const cleanup of this.pageviewCleanups) {
47390
+ cleanup();
47391
+ }
47392
+ this.pageviewCleanups = [];
47393
+ }
47394
+ /**
47395
+ * Enable click-based outbound link tracking. Detects anchor clicks that
47396
+ * navigate to a different origin and fires an `outbound_link` event
47397
+ * (with `hostname` and `href` props) before the browser navigates.
47398
+ */
47399
+ enableAutoOutboundTracking(options = {}) {
47400
+ if (this.outboundCleanup) {
47401
+ return;
47402
+ }
47403
+ if (typeof document === 'undefined') {
47404
+ return;
47405
+ }
47406
+ const includeSubdomains = options.includeSubdomains === true;
47407
+ const clickHandler = (event) => {
47408
+ const anchor = this.findAnchor(event.target);
47409
+ if (!anchor || !anchor.href) {
47410
+ return;
47411
+ }
47412
+ const target = this.parseUrl(anchor.href);
47413
+ if (!target || !this.isExternal(target, includeSubdomains)) {
47414
+ return;
47415
+ }
47416
+ this.track('outbound_link', {
47417
+ url: target.href,
47418
+ props: { hostname: target.hostname, href: target.href },
47419
+ });
47420
+ };
47421
+ document.addEventListener('click', clickHandler, { capture: true });
47422
+ this.outboundCleanup = () => document.removeEventListener('click', clickHandler, {
47423
+ capture: true,
47424
+ });
47425
+ }
47426
+ /**
47427
+ * Disable outbound-link tracking installed by `enableAutoOutboundTracking`.
47428
+ * Safe to call when auto-outbound was never enabled.
47429
+ */
47430
+ disableAutoOutboundTracking() {
47431
+ if (this.outboundCleanup) {
47432
+ this.outboundCleanup();
47433
+ this.outboundCleanup = undefined;
47434
+ }
47435
+ }
47436
+ /**
47437
+ * Enable click-based download tracking. Detects anchor clicks that point
47438
+ * at a file whose extension appears in the configured list and fires a
47439
+ * `file_download` event with `filename`, `extension` and `href` props.
47440
+ */
47441
+ enableAutoDownloadTracking(options = {}) {
47442
+ var _a;
47443
+ if (this.downloadCleanup) {
47444
+ return;
47445
+ }
47446
+ if (typeof document === 'undefined') {
47447
+ return;
47448
+ }
47449
+ const extensions = ((_a = options.extensions) !== null && _a !== void 0 ? _a : DEFAULT_DOWNLOAD_EXTENSIONS).map((ext) => ext.toLowerCase().replace(/^\./, ''));
47450
+ const extensionSet = new Set(extensions);
47451
+ const clickHandler = (event) => {
47452
+ var _a, _b;
47453
+ const anchor = this.findAnchor(event.target);
47454
+ if (!anchor || !anchor.href) {
47455
+ return;
47456
+ }
47457
+ const url = this.parseUrl(anchor.href);
47458
+ if (!url) {
47459
+ return;
47460
+ }
47461
+ const filename = (_a = url.pathname.split('/').pop()) !== null && _a !== void 0 ? _a : '';
47462
+ const extension = filename.includes('.')
47463
+ ? (_b = filename.split('.').pop()) === null || _b === void 0 ? void 0 : _b.toLowerCase()
47464
+ : undefined;
47465
+ if (!extension || !extensionSet.has(extension)) {
47466
+ return;
47467
+ }
47468
+ this.track('file_download', {
47469
+ url: url.href,
47470
+ props: { filename, extension, href: url.href },
47471
+ });
47472
+ };
47473
+ document.addEventListener('click', clickHandler, { capture: true });
47474
+ this.downloadCleanup = () => document.removeEventListener('click', clickHandler, {
47475
+ capture: true,
47476
+ });
47477
+ }
47478
+ /**
47479
+ * Disable file-download tracking installed by `enableAutoDownloadTracking`.
47480
+ * Safe to call when auto-download was never enabled.
47481
+ */
47482
+ disableAutoDownloadTracking() {
47483
+ if (this.downloadCleanup) {
47484
+ this.downloadCleanup();
47485
+ this.downloadCleanup = undefined;
47486
+ }
47487
+ }
47488
+ /**
47489
+ * Enable passive scroll-depth tracking. Records the maximum percent of the
47490
+ * document scrolled and reports it on `beforeunload` and on SPA route
47491
+ * changes. Uses a throttled passive listener so it is safe on hot paths.
47492
+ */
47493
+ enableAutoScrollDepth() {
47494
+ if (this.scrollCleanups.length > 0) {
47495
+ return;
47496
+ }
47497
+ if (typeof window === 'undefined' || typeof document === 'undefined') {
47498
+ return;
47499
+ }
47500
+ this.maxScrollDepth = 0;
47501
+ this.lastScrollReport = 0;
47502
+ const scrollHandler = () => {
47503
+ if (this.scrollTicking) {
47504
+ return;
47505
+ }
47506
+ this.scrollTicking = true;
47507
+ window.requestAnimationFrame(() => {
47508
+ const now = Date.now();
47509
+ if (now - this.lastScrollReport < SCROLL_DEPTH_THROTTLE_MS) {
47510
+ this.scrollTicking = false;
47511
+ return;
47512
+ }
47513
+ this.lastScrollReport = now;
47514
+ const depth = this.computeScrollDepth();
47515
+ if (depth > this.maxScrollDepth) {
47516
+ this.maxScrollDepth = depth;
47517
+ }
47518
+ this.scrollTicking = false;
47519
+ });
47520
+ };
47521
+ const unloadHandler = () => {
47522
+ this.flushScrollDepth(this.currentPageUrl());
47523
+ };
47524
+ window.addEventListener('scroll', scrollHandler, { passive: true });
47525
+ window.addEventListener('beforeunload', unloadHandler);
47526
+ window.addEventListener('pagehide', unloadHandler);
47527
+ this.scrollCleanups.push(() => {
47528
+ window.removeEventListener('scroll', scrollHandler);
47529
+ window.removeEventListener('beforeunload', unloadHandler);
47530
+ window.removeEventListener('pagehide', unloadHandler);
47531
+ });
47532
+ }
47533
+ /**
47534
+ * Disable scroll-depth tracking installed by `enableAutoScrollDepth`. Safe
47535
+ * to call when auto-scroll-depth was never enabled. Any accumulated depth
47536
+ * for the current page is dropped.
47537
+ */
47538
+ disableAutoScrollDepth() {
47539
+ for (const cleanup of this.scrollCleanups) {
47540
+ cleanup();
47541
+ }
47542
+ this.scrollCleanups = [];
47543
+ this.maxScrollDepth = 0;
47544
+ this.scrollTicking = false;
47545
+ this.lastScrollReport = 0;
47546
+ }
47547
+ /**
47548
+ * Enable active engagement-time tracking. Counts time the tab is visible
47549
+ * and uses `visibilitychange` to exclude background time.
47550
+ *
47551
+ * Delivery follows Plausible's model rather than a single total at the
47552
+ * end of the visit: an `engagement_time` event is emitted at every natural
47553
+ * checkpoint — the tab going hidden, an SPA route change, and finally
47554
+ * `beforeunload`/`pagehide`. Unload is kept only as a best-effort last
47555
+ * flush; it is the least reliable moment to send anything (browsers
47556
+ * routinely cancel in-flight requests there, and `sendBeacon` cannot set
47557
+ * the `X-Appwrite-Project` header the endpoint requires), so it must never
47558
+ * be the only delivery.
47559
+ *
47560
+ * Each event carries a **delta** — the seconds accrued since the previous
47561
+ * flush, not a running total — so the values are additive per session and
47562
+ * a lost event costs only its own slice.
47563
+ *
47564
+ * There is deliberately no periodic ping. The cadence is driven by
47565
+ * navigation and tab switches, so request volume tracks what the visitor
47566
+ * actually does instead of multiplying with time on page.
47567
+ */
47568
+ enableAutoEngagementTime() {
47569
+ if (this.engagementCleanups.length > 0) {
47570
+ return;
47571
+ }
47572
+ if (typeof window === 'undefined' || typeof document === 'undefined') {
47573
+ return;
47574
+ }
47575
+ this.engagementAccumulatedMs = 0;
47576
+ // Do not start the clock for a tab that is already hidden (prerender,
47577
+ // background tab restore); `visibilitychange` starts it when it is
47578
+ // actually looked at.
47579
+ if (document.visibilityState !== 'hidden') {
47580
+ this.startEngagement();
47581
+ }
47582
+ const visibilityHandler = () => {
47583
+ if (document.visibilityState === 'hidden') {
47584
+ // Flush, don't just pause. The page is still fully alive here,
47585
+ // which makes this the most reliable delivery point in the
47586
+ // whole visit — and it is the same moment Plausible reports on.
47587
+ this.flushEngagement(this.currentPageUrl());
47588
+ }
47589
+ else if (document.visibilityState === 'visible') {
47590
+ this.startEngagement();
47591
+ }
47592
+ };
47593
+ const unloadHandler = () => {
47594
+ this.flushEngagement(this.currentPageUrl());
47595
+ };
47596
+ const pageshowHandler = (event) => {
47597
+ // When the page is restored from the back-forward cache the
47598
+ // engagement timer is in a stopped state (flushEngagement paused
47599
+ // it on pagehide and does not auto-restart). Kick off a fresh
47600
+ // engagementStart so bfcache dwell time is not billed as
47601
+ // engagement.
47602
+ if (event.persisted) {
47603
+ this.startEngagement();
47604
+ }
47605
+ };
47606
+ document.addEventListener('visibilitychange', visibilityHandler);
47607
+ window.addEventListener('beforeunload', unloadHandler);
47608
+ window.addEventListener('pagehide', unloadHandler);
47609
+ window.addEventListener('pageshow', pageshowHandler);
47610
+ this.engagementCleanups.push(() => {
47611
+ document.removeEventListener('visibilitychange', visibilityHandler);
47612
+ window.removeEventListener('beforeunload', unloadHandler);
47613
+ window.removeEventListener('pagehide', unloadHandler);
47614
+ window.removeEventListener('pageshow', pageshowHandler);
47615
+ });
47616
+ }
47617
+ /**
47618
+ * Disable engagement-time tracking installed by `enableAutoEngagementTime`.
47619
+ * Safe to call when auto-engagement was never enabled. Any accumulated
47620
+ * engagement time is dropped without being emitted.
47621
+ */
47622
+ disableAutoEngagementTime() {
47623
+ for (const cleanup of this.engagementCleanups) {
47624
+ cleanup();
47625
+ }
47626
+ this.engagementCleanups = [];
47627
+ this.engagementActive = false;
47628
+ this.engagementAccumulatedMs = 0;
47629
+ this.engagementStart = 0;
47630
+ }
47631
+ /**
47632
+ * Merge the configured `propertyId` into an event's options. Returns the
47633
+ * caller's object untouched when no default is configured (or the event
47634
+ * already carries one), so emitters written against the pre-`propertyId`
47635
+ * shape keep receiving exactly what they received before.
47636
+ */
47637
+ withPropertyId(options) {
47638
+ if (this.propertyId === undefined ||
47639
+ (options === null || options === void 0 ? void 0 : options.propertyId) !== undefined) {
47640
+ return options;
47641
+ }
47642
+ return Object.assign(Object.assign({}, (options !== null && options !== void 0 ? options : {})), { propertyId: this.propertyId });
47643
+ }
47644
+ canTrack() {
47645
+ if (!this.respectDoNotTrack) {
47646
+ return true;
47647
+ }
47648
+ if (typeof navigator === 'undefined') {
47649
+ return true;
47650
+ }
47651
+ return navigator.doNotTrack !== '1';
47652
+ }
47653
+ currentPageUrl() {
47654
+ if (typeof window === 'undefined' || !window.location) {
47655
+ return '';
47656
+ }
47657
+ return window.location.href;
47658
+ }
47659
+ findAnchor(target) {
47660
+ let node = target;
47661
+ while (node) {
47662
+ if (node.tagName === 'A') {
47663
+ return node;
47664
+ }
47665
+ node = node.parentNode;
47666
+ }
47667
+ return null;
47668
+ }
47669
+ parseUrl(href) {
47670
+ try {
47671
+ return new URL(href, window.location.href);
47672
+ }
47673
+ catch (_a) {
47674
+ return null;
47675
+ }
47676
+ }
47677
+ isExternal(target, includeSubdomains) {
47678
+ if (target.protocol !== 'http:' && target.protocol !== 'https:') {
47679
+ return false;
47680
+ }
47681
+ if (target.hostname === window.location.hostname) {
47682
+ return false;
47683
+ }
47684
+ if (includeSubdomains) {
47685
+ return true;
47686
+ }
47687
+ const root = this.rootDomain(window.location.hostname);
47688
+ return this.rootDomain(target.hostname) !== root;
47689
+ }
47690
+ rootDomain(hostname) {
47691
+ const parts = hostname.split('.');
47692
+ if (parts.length <= 2) {
47693
+ return hostname;
47694
+ }
47695
+ // Taking the last two labels is wrong wherever the registry sells names
47696
+ // one level down: `shop.example.co.uk` and `google.co.uk` both reduce to
47697
+ // `co.uk`, so every outbound click between two `.co.uk` sites looks
47698
+ // internal and is dropped. Take three labels after a known two-part
47699
+ // suffix instead.
47700
+ //
47701
+ // This is a heuristic, not the Public Suffix List — the full list is
47702
+ // orders of magnitude larger than this whole file, and a tracking
47703
+ // snippet cannot carry it. Sites on a suffix that is missing here can
47704
+ // pass `includeSubdomains: true` to treat every other host as outbound.
47705
+ const suffix = parts.slice(-2).join('.');
47706
+ if (parts.length > 2 && MULTI_PART_SUFFIXES.has(suffix)) {
47707
+ return parts.slice(-3).join('.');
47708
+ }
47709
+ return suffix;
47710
+ }
47711
+ computeScrollDepth() {
47712
+ const scrollTop = window.scrollY || document.documentElement.scrollTop;
47713
+ const viewport = window.innerHeight || document.documentElement.clientHeight;
47714
+ const total = document.documentElement.scrollHeight;
47715
+ if (total <= viewport) {
47716
+ return 100;
47717
+ }
47718
+ const depth = Math.round(((scrollTop + viewport) / total) * 100);
47719
+ return Math.max(0, Math.min(100, depth));
47720
+ }
47721
+ flushScrollDepth(url) {
47722
+ if (this.scrollCleanups.length === 0) {
47723
+ return;
47724
+ }
47725
+ if (this.maxScrollDepth <= 0) {
47726
+ return;
47727
+ }
47728
+ this.track('scroll_depth', {
47729
+ url,
47730
+ scrollDepth: this.maxScrollDepth,
47731
+ });
47732
+ this.maxScrollDepth = 0;
47733
+ }
47734
+ startEngagement() {
47735
+ if (this.engagementActive) {
47736
+ return;
47737
+ }
47738
+ this.engagementActive = true;
47739
+ this.engagementStart = Date.now();
47740
+ }
47741
+ pauseEngagement() {
47742
+ if (!this.engagementActive) {
47743
+ return;
47744
+ }
47745
+ this.engagementActive = false;
47746
+ this.engagementAccumulatedMs += Date.now() - this.engagementStart;
47747
+ }
47748
+ flushEngagement(url) {
47749
+ if (this.engagementCleanups.length === 0) {
47750
+ return;
47751
+ }
47752
+ this.pauseEngagement();
47753
+ // Deltas, not a running total: emit only what accrued since the last
47754
+ // flush. `floor` plus keeping the sub-second remainder in the
47755
+ // accumulator is what makes repeated flushes safe — nothing is emitted
47756
+ // twice, and a visit chopped into many short segments does not lose a
47757
+ // fraction of a second to rounding on every one of them.
47758
+ const seconds = Math.floor(this.engagementAccumulatedMs / 1000);
47759
+ if (seconds > 0) {
47760
+ // Deduct before emitting so a synchronous emitter that re-enters
47761
+ // (or throws) can never bill the same seconds again.
47762
+ this.engagementAccumulatedMs -= seconds * 1000;
47763
+ this.track('engagement_time', {
47764
+ url,
47765
+ engagementTime: seconds,
47766
+ });
47767
+ }
47768
+ // NOTE: intentionally do NOT call startEngagement() here. flushEngagement
47769
+ // runs on `pagehide`, which is also the last hook before the browser
47770
+ // may freeze the page into the back-forward cache. Auto-restarting
47771
+ // would snapshot engagementStart just before the freeze; the next
47772
+ // pauseEngagement (after bfcache restore) would then bill the entire
47773
+ // bfcache dwell as active engagement. Restart is driven by explicit
47774
+ // resume signals: `pageshow` (with `persisted === true`),
47775
+ // `visibilitychange` back to visible, or the SPA navigation flow in
47776
+ // `enableAutoPageviews`.
47777
+ }
47778
+ }
47779
+
46226
47780
  /**
46227
47781
  * Helper class to generate permission strings for resources.
46228
47782
  */
@@ -46919,6 +48473,7 @@ exports.OAuthProvider = void 0;
46919
48473
  OAuthProvider["Tradeshift"] = "tradeshift";
46920
48474
  OAuthProvider["TradeshiftBox"] = "tradeshiftBox";
46921
48475
  OAuthProvider["Twitch"] = "twitch";
48476
+ OAuthProvider["Webflow"] = "webflow";
46922
48477
  OAuthProvider["Wordpress"] = "wordpress";
46923
48478
  OAuthProvider["X"] = "x";
46924
48479
  OAuthProvider["Yahoo"] = "yahoo";
@@ -46928,6 +48483,40 @@ exports.OAuthProvider = void 0;
46928
48483
  OAuthProvider["Zoom"] = "zoom";
46929
48484
  })(exports.OAuthProvider || (exports.OAuthProvider = {}));
46930
48485
 
48486
+ exports.AnalyticsInterval = void 0;
48487
+ (function (AnalyticsInterval) {
48488
+ AnalyticsInterval["OneHour"] = "1h";
48489
+ AnalyticsInterval["OneDay"] = "1d";
48490
+ AnalyticsInterval["OneWeek"] = "1w";
48491
+ AnalyticsInterval["OneMonth"] = "1m";
48492
+ })(exports.AnalyticsInterval || (exports.AnalyticsInterval = {}));
48493
+
48494
+ exports.AnalyticsDimension = void 0;
48495
+ (function (AnalyticsDimension) {
48496
+ AnalyticsDimension["Country"] = "country";
48497
+ AnalyticsDimension["Region"] = "region";
48498
+ AnalyticsDimension["City"] = "city";
48499
+ AnalyticsDimension["Browser"] = "browser";
48500
+ AnalyticsDimension["OperatingSystem"] = "operatingSystem";
48501
+ AnalyticsDimension["Device"] = "device";
48502
+ AnalyticsDimension["ScreenSize"] = "screenSize";
48503
+ AnalyticsDimension["ReferrerSource"] = "referrerSource";
48504
+ AnalyticsDimension["Channel"] = "channel";
48505
+ AnalyticsDimension["UtmSource"] = "utmSource";
48506
+ AnalyticsDimension["UtmMedium"] = "utmMedium";
48507
+ AnalyticsDimension["UtmCampaign"] = "utmCampaign";
48508
+ AnalyticsDimension["UtmContent"] = "utmContent";
48509
+ AnalyticsDimension["UtmTerm"] = "utmTerm";
48510
+ AnalyticsDimension["Page"] = "page";
48511
+ AnalyticsDimension["Hostname"] = "hostname";
48512
+ AnalyticsDimension["EntryPage"] = "entryPage";
48513
+ AnalyticsDimension["ExitPage"] = "exitPage";
48514
+ AnalyticsDimension["TrafficType"] = "trafficType";
48515
+ AnalyticsDimension["BotName"] = "botName";
48516
+ AnalyticsDimension["BotCategory"] = "botCategory";
48517
+ AnalyticsDimension["EventName"] = "eventName";
48518
+ })(exports.AnalyticsDimension || (exports.AnalyticsDimension = {}));
48519
+
46931
48520
  exports.Browser = void 0;
46932
48521
  (function (Browser) {
46933
48522
  Browser["AvantBrowser"] = "aa";
@@ -47743,6 +49332,7 @@ exports.QuerySuggestionResource = void 0;
47743
49332
  QuerySuggestionResource["ResourceTokens"] = "resourcetokens";
47744
49333
  QuerySuggestionResource["Transactions"] = "transactions";
47745
49334
  QuerySuggestionResource["TransactionLogs"] = "transactionlogs";
49335
+ QuerySuggestionResource["AnalyticsProperties"] = "analyticsproperties";
47746
49336
  QuerySuggestionResource["DedicatedDatabases"] = "dedicateddatabases";
47747
49337
  QuerySuggestionResource["DedicatedDatabaseConfigs"] = "dedicateddatabaseconfigs";
47748
49338
  QuerySuggestionResource["DedicatedDatabaseRuntimes"] = "dedicateddatabaseruntimes";
@@ -47990,6 +49580,9 @@ exports.Runtime = void 0;
47990
49580
  Runtime["Pythonml311"] = "python-ml-3.11";
47991
49581
  Runtime["Pythonml312"] = "python-ml-3.12";
47992
49582
  Runtime["Pythonml313"] = "python-ml-3.13";
49583
+ Runtime["Deno121"] = "deno-1.21";
49584
+ Runtime["Deno124"] = "deno-1.24";
49585
+ Runtime["Deno135"] = "deno-1.35";
47993
49586
  Runtime["Deno140"] = "deno-1.40";
47994
49587
  Runtime["Deno146"] = "deno-1.46";
47995
49588
  Runtime["Deno20"] = "deno-2.0";
@@ -48147,6 +49740,7 @@ exports.ProjectKeyScopes = void 0;
48147
49740
  ProjectKeyScopes["WebhooksWrite"] = "webhooks.write";
48148
49741
  ProjectKeyScopes["LocaleRead"] = "locale.read";
48149
49742
  ProjectKeyScopes["AvatarsRead"] = "avatars.read";
49743
+ ProjectKeyScopes["AvatarsWrite"] = "avatars.write";
48150
49744
  ProjectKeyScopes["HealthRead"] = "health.read";
48151
49745
  ProjectKeyScopes["AssistantRead"] = "assistant.read";
48152
49746
  ProjectKeyScopes["MigrationsRead"] = "migrations.read";
@@ -48179,6 +49773,8 @@ exports.ProjectKeyScopes = void 0;
48179
49773
  ProjectKeyScopes["Oauth2Read"] = "oauth2.read";
48180
49774
  ProjectKeyScopes["Oauth2Write"] = "oauth2.write";
48181
49775
  ProjectKeyScopes["Oauth2Introspect"] = "oauth2.introspect";
49776
+ ProjectKeyScopes["AnalyticsRead"] = "analytics.read";
49777
+ ProjectKeyScopes["AnalyticsWrite"] = "analytics.write";
48182
49778
  })(exports.ProjectKeyScopes || (exports.ProjectKeyScopes = {}));
48183
49779
 
48184
49780
  exports.FunctionTemplateUseCase = void 0;
@@ -48541,6 +50137,7 @@ exports.ProjectOAuthProviderId = void 0;
48541
50137
  ProjectOAuthProviderId["Tradeshift"] = "tradeshift";
48542
50138
  ProjectOAuthProviderId["TradeshiftBox"] = "tradeshiftBox";
48543
50139
  ProjectOAuthProviderId["Twitch"] = "twitch";
50140
+ ProjectOAuthProviderId["Webflow"] = "webflow";
48544
50141
  ProjectOAuthProviderId["Wordpress"] = "wordpress";
48545
50142
  ProjectOAuthProviderId["X"] = "x";
48546
50143
  ProjectOAuthProviderId["Yahoo"] = "yahoo";
@@ -48694,6 +50291,9 @@ exports.BuildRuntime = void 0;
48694
50291
  BuildRuntime["Pythonml311"] = "python-ml-3.11";
48695
50292
  BuildRuntime["Pythonml312"] = "python-ml-3.12";
48696
50293
  BuildRuntime["Pythonml313"] = "python-ml-3.13";
50294
+ BuildRuntime["Deno121"] = "deno-1.21";
50295
+ BuildRuntime["Deno124"] = "deno-1.24";
50296
+ BuildRuntime["Deno135"] = "deno-1.35";
48697
50297
  BuildRuntime["Deno140"] = "deno-1.40";
48698
50298
  BuildRuntime["Deno146"] = "deno-1.46";
48699
50299
  BuildRuntime["Deno20"] = "deno-2.0";
@@ -48809,6 +50409,9 @@ exports.TablesDBIndexType = void 0;
48809
50409
 
48810
50410
  exports.UsageEventMetric = void 0;
48811
50411
  (function (UsageEventMetric) {
50412
+ UsageEventMetric["AnalyticsEvents"] = "analytics.events";
50413
+ UsageEventMetric["AnalyticsPageviews"] = "analytics.pageviews";
50414
+ UsageEventMetric["AnalyticsBotsEvents"] = "analytics.bots.events";
48812
50415
  UsageEventMetric["NetworkRequests"] = "network.requests";
48813
50416
  UsageEventMetric["NetworkInbound"] = "network.inbound";
48814
50417
  UsageEventMetric["NetworkOutbound"] = "network.outbound";
@@ -48816,6 +50419,7 @@ exports.UsageEventMetric = void 0;
48816
50419
  UsageEventMetric["WebhooksEventsFailed"] = "webhooks.events.failed";
48817
50420
  UsageEventMetric["AuthMethodPhone"] = "auth.method.phone";
48818
50421
  UsageEventMetric["MessagesSent"] = "messages.sent";
50422
+ UsageEventMetric["MessagesFailed"] = "messages.failed";
48819
50423
  UsageEventMetric["MessagesSmsSent"] = "messages.sms.sent";
48820
50424
  UsageEventMetric["Executions"] = "executions";
48821
50425
  UsageEventMetric["ExecutionsCompute"] = "executions.compute";
@@ -48894,6 +50498,15 @@ exports.UsageEventDimension = void 0;
48894
50498
  UsageEventDimension["SdkVersion"] = "sdkVersion";
48895
50499
  UsageEventDimension["TeamId"] = "teamId";
48896
50500
  UsageEventDimension["ResourceId"] = "resourceId";
50501
+ UsageEventDimension["Protocol"] = "protocol";
50502
+ UsageEventDimension["QueryKeys"] = "queryKeys";
50503
+ UsageEventDimension["Accept"] = "accept";
50504
+ UsageEventDimension["AcceptLanguage"] = "acceptLanguage";
50505
+ UsageEventDimension["PostalCode"] = "postalCode";
50506
+ UsageEventDimension["Latitude"] = "latitude";
50507
+ UsageEventDimension["Longitude"] = "longitude";
50508
+ UsageEventDimension["TimeZone"] = "timeZone";
50509
+ UsageEventDimension["WeatherCode"] = "weatherCode";
48897
50510
  UsageEventDimension["Isp"] = "isp";
48898
50511
  UsageEventDimension["AutonomousSystemNumber"] = "autonomousSystemNumber";
48899
50512
  UsageEventDimension["AutonomousSystemOrganization"] = "autonomousSystemOrganization";
@@ -48916,6 +50529,7 @@ exports.UsageOrderDirection = void 0;
48916
50529
 
48917
50530
  exports.UsageGaugeMetric = void 0;
48918
50531
  (function (UsageGaugeMetric) {
50532
+ UsageGaugeMetric["AnalyticsProperties"] = "analytics.properties";
48919
50533
  UsageGaugeMetric["Teams"] = "teams";
48920
50534
  UsageGaugeMetric["Users"] = "users";
48921
50535
  UsageGaugeMetric["Messages"] = "messages";
@@ -49191,6 +50805,7 @@ exports.ProxyRuleDeploymentResourceType = void 0;
49191
50805
  (function (ProxyRuleDeploymentResourceType) {
49192
50806
  ProxyRuleDeploymentResourceType["Function"] = "function";
49193
50807
  ProxyRuleDeploymentResourceType["Site"] = "site";
50808
+ ProxyRuleDeploymentResourceType["DedicatedDatabase"] = "dedicatedDatabase";
49194
50809
  })(exports.ProxyRuleDeploymentResourceType || (exports.ProxyRuleDeploymentResourceType = {}));
49195
50810
 
49196
50811
  exports.ProxyRuleStatus = void 0;
@@ -49250,6 +50865,8 @@ exports.Account = Account;
49250
50865
  exports.Activities = Activities;
49251
50866
  exports.Advisor = Advisor;
49252
50867
  exports.Affiliates = Affiliates;
50868
+ exports.Analytics = Analytics;
50869
+ exports.AnalyticsTracking = AnalyticsTracking;
49253
50870
  exports.Apps = Apps;
49254
50871
  exports.AppwriteException = AppwriteException;
49255
50872
  exports.Assistant = Assistant;