@appwrite.io/console 18.1.0 → 18.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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.2.0',
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
  *
@@ -3354,15 +3355,25 @@ class Account {
3354
3355
  };
3355
3356
  return this.client.call('put', uri, apiHeaders, apiPayload);
3356
3357
  }
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() {
3358
+ listSessions(paramsOrFirst) {
3359
+ let params;
3360
+ if (typeof paramsOrFirst === 'undefined' ||
3361
+ (paramsOrFirst &&
3362
+ typeof paramsOrFirst === 'object' &&
3363
+ !Array.isArray(paramsOrFirst))) {
3364
+ params = (paramsOrFirst || {});
3365
+ }
3366
+ else {
3367
+ params = {
3368
+ total: paramsOrFirst,
3369
+ };
3370
+ }
3371
+ const total = params.total;
3364
3372
  const apiPath = '/account/sessions';
3365
3373
  const apiPayload = {};
3374
+ if (typeof total !== 'undefined') {
3375
+ apiPayload['total'] = total;
3376
+ }
3366
3377
  const uri = new URL(this.client.config.endpoint + apiPath);
3367
3378
  const apiHeaders = {
3368
3379
  'X-Appwrite-Project': this.client.config.project,
@@ -3370,15 +3381,25 @@ class Account {
3370
3381
  };
3371
3382
  return this.client.call('get', uri, apiHeaders, apiPayload);
3372
3383
  }
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() {
3384
+ deleteSessions(paramsOrFirst) {
3385
+ let params;
3386
+ if (typeof paramsOrFirst === 'undefined' ||
3387
+ (paramsOrFirst &&
3388
+ typeof paramsOrFirst === 'object' &&
3389
+ !Array.isArray(paramsOrFirst))) {
3390
+ params = (paramsOrFirst || {});
3391
+ }
3392
+ else {
3393
+ params = {
3394
+ current: paramsOrFirst,
3395
+ };
3396
+ }
3397
+ const current = params.current;
3380
3398
  const apiPath = '/account/sessions';
3381
3399
  const apiPayload = {};
3400
+ if (typeof current !== 'undefined') {
3401
+ apiPayload['current'] = current;
3402
+ }
3382
3403
  const uri = new URL(this.client.config.endpoint + apiPath);
3383
3404
  const apiHeaders = {
3384
3405
  'X-Appwrite-Project': this.client.config.project,
@@ -3415,10 +3436,12 @@ class Account {
3415
3436
  params = {
3416
3437
  email: paramsOrFirst,
3417
3438
  password: rest[0],
3439
+ duration: rest[1],
3418
3440
  };
3419
3441
  }
3420
3442
  const email = params.email;
3421
3443
  const password = params.password;
3444
+ const duration = params.duration;
3422
3445
  if (typeof email === 'undefined') {
3423
3446
  throw new AppwriteException('Missing required parameter: "email"');
3424
3447
  }
@@ -3433,6 +3456,9 @@ class Account {
3433
3456
  if (typeof password !== 'undefined') {
3434
3457
  apiPayload['password'] = password;
3435
3458
  }
3459
+ if (typeof duration !== 'undefined') {
3460
+ apiPayload['duration'] = duration;
3461
+ }
3436
3462
  const uri = new URL(this.client.config.endpoint + apiPath);
3437
3463
  const apiHeaders = {
3438
3464
  'X-Appwrite-Project': this.client.config.project,
@@ -5716,6 +5742,56 @@ class Avatars {
5716
5742
  }
5717
5743
  return uri.toString();
5718
5744
  }
5745
+ updatePhoto(paramsOrFirst, ...rest) {
5746
+ let params;
5747
+ let onProgress;
5748
+ if (paramsOrFirst &&
5749
+ typeof paramsOrFirst === 'object' &&
5750
+ !Array.isArray(paramsOrFirst) &&
5751
+ ('file' in paramsOrFirst || 'onProgress' in paramsOrFirst)) {
5752
+ params = (paramsOrFirst || {});
5753
+ onProgress = paramsOrFirst === null || paramsOrFirst === void 0 ? void 0 : paramsOrFirst.onProgress;
5754
+ }
5755
+ else {
5756
+ params = {
5757
+ file: paramsOrFirst,
5758
+ };
5759
+ onProgress = rest[0];
5760
+ }
5761
+ const file = params.file;
5762
+ if (typeof file === 'undefined') {
5763
+ throw new AppwriteException('Missing required parameter: "file"');
5764
+ }
5765
+ const apiPath = '/avatars/photo';
5766
+ const apiPayload = {};
5767
+ if (typeof file !== 'undefined') {
5768
+ apiPayload['file'] = file;
5769
+ }
5770
+ const uri = new URL(this.client.config.endpoint + apiPath);
5771
+ const apiHeaders = {
5772
+ 'X-Appwrite-Project': this.client.config.project,
5773
+ 'content-type': 'multipart/form-data',
5774
+ accept: 'application/json',
5775
+ };
5776
+ return this.client.chunkedUpload('put', uri, apiHeaders, apiPayload, onProgress);
5777
+ }
5778
+ /**
5779
+ * 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.
5780
+ *
5781
+ * @throws {AppwriteException}
5782
+ * @returns {Promise<{}>}
5783
+ */
5784
+ deletePhoto() {
5785
+ const apiPath = '/avatars/photo';
5786
+ const apiPayload = {};
5787
+ const uri = new URL(this.client.config.endpoint + apiPath);
5788
+ const apiHeaders = {
5789
+ 'X-Appwrite-Project': this.client.config.project,
5790
+ 'content-type': 'application/json',
5791
+ accept: 'application/json',
5792
+ };
5793
+ return this.client.call('delete', uri, apiHeaders, apiPayload);
5794
+ }
5719
5795
  getQR(paramsOrFirst, ...rest) {
5720
5796
  let params;
5721
5797
  if (paramsOrFirst &&
@@ -6418,15 +6494,25 @@ class Console {
6418
6494
  };
6419
6495
  return this.client.call('get', uri, apiHeaders, apiPayload);
6420
6496
  }
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() {
6497
+ listOAuth2Providers(paramsOrFirst) {
6498
+ let params;
6499
+ if (typeof paramsOrFirst === 'undefined' ||
6500
+ (paramsOrFirst &&
6501
+ typeof paramsOrFirst === 'object' &&
6502
+ !Array.isArray(paramsOrFirst))) {
6503
+ params = (paramsOrFirst || {});
6504
+ }
6505
+ else {
6506
+ params = {
6507
+ total: paramsOrFirst,
6508
+ };
6509
+ }
6510
+ const total = params.total;
6428
6511
  const apiPath = '/console/oauth2-providers';
6429
6512
  const apiPayload = {};
6513
+ if (typeof total !== 'undefined') {
6514
+ apiPayload['total'] = total;
6515
+ }
6430
6516
  const uri = new URL(this.client.config.endpoint + apiPath);
6431
6517
  const apiHeaders = {
6432
6518
  'X-Appwrite-Project': this.client.config.project,
@@ -6606,15 +6692,25 @@ class Console {
6606
6692
  };
6607
6693
  return this.client.call('get', uri, apiHeaders, apiPayload);
6608
6694
  }
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() {
6695
+ listOrganizationScopes(paramsOrFirst) {
6696
+ let params;
6697
+ if (typeof paramsOrFirst === 'undefined' ||
6698
+ (paramsOrFirst &&
6699
+ typeof paramsOrFirst === 'object' &&
6700
+ !Array.isArray(paramsOrFirst))) {
6701
+ params = (paramsOrFirst || {});
6702
+ }
6703
+ else {
6704
+ params = {
6705
+ total: paramsOrFirst,
6706
+ };
6707
+ }
6708
+ const total = params.total;
6616
6709
  const apiPath = '/console/scopes/organization';
6617
6710
  const apiPayload = {};
6711
+ if (typeof total !== 'undefined') {
6712
+ apiPayload['total'] = total;
6713
+ }
6618
6714
  const uri = new URL(this.client.config.endpoint + apiPath);
6619
6715
  const apiHeaders = {
6620
6716
  'X-Appwrite-Project': this.client.config.project,
@@ -6622,15 +6718,25 @@ class Console {
6622
6718
  };
6623
6719
  return this.client.call('get', uri, apiHeaders, apiPayload);
6624
6720
  }
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() {
6721
+ listProjectScopes(paramsOrFirst) {
6722
+ let params;
6723
+ if (typeof paramsOrFirst === 'undefined' ||
6724
+ (paramsOrFirst &&
6725
+ typeof paramsOrFirst === 'object' &&
6726
+ !Array.isArray(paramsOrFirst))) {
6727
+ params = (paramsOrFirst || {});
6728
+ }
6729
+ else {
6730
+ params = {
6731
+ total: paramsOrFirst,
6732
+ };
6733
+ }
6734
+ const total = params.total;
6632
6735
  const apiPath = '/console/scopes/project';
6633
6736
  const apiPayload = {};
6737
+ if (typeof total !== 'undefined') {
6738
+ apiPayload['total'] = total;
6739
+ }
6634
6740
  const uri = new URL(this.client.config.endpoint + apiPath);
6635
6741
  const apiHeaders = {
6636
6742
  'X-Appwrite-Project': this.client.config.project,
@@ -6963,9 +7069,9 @@ class Databases {
6963
7069
  };
6964
7070
  return this.client.call('post', uri, apiHeaders, apiPayload);
6965
7071
  }
6966
- listTransactions(paramsOrFirst) {
7072
+ listTransactions(paramsOrFirst, ...rest) {
6967
7073
  let params;
6968
- if (typeof paramsOrFirst === 'undefined' ||
7074
+ if ((typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
6969
7075
  (paramsOrFirst &&
6970
7076
  typeof paramsOrFirst === 'object' &&
6971
7077
  !Array.isArray(paramsOrFirst))) {
@@ -6974,14 +7080,19 @@ class Databases {
6974
7080
  else {
6975
7081
  params = {
6976
7082
  queries: paramsOrFirst,
7083
+ total: rest[0],
6977
7084
  };
6978
7085
  }
6979
7086
  const queries = params.queries;
7087
+ const total = params.total;
6980
7088
  const apiPath = '/databases/transactions';
6981
7089
  const apiPayload = {};
6982
7090
  if (typeof queries !== 'undefined') {
6983
7091
  apiPayload['queries'] = queries;
6984
7092
  }
7093
+ if (typeof total !== 'undefined') {
7094
+ apiPayload['total'] = total;
7095
+ }
6985
7096
  const uri = new URL(this.client.config.endpoint + apiPath);
6986
7097
  const apiHeaders = {
6987
7098
  'X-Appwrite-Project': this.client.config.project,
@@ -10724,9 +10835,9 @@ class DocumentsDB {
10724
10835
  };
10725
10836
  return this.client.call('get', uri, apiHeaders, apiPayload);
10726
10837
  }
10727
- listTransactions(paramsOrFirst) {
10838
+ listTransactions(paramsOrFirst, ...rest) {
10728
10839
  let params;
10729
- if (typeof paramsOrFirst === 'undefined' ||
10840
+ if ((typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
10730
10841
  (paramsOrFirst &&
10731
10842
  typeof paramsOrFirst === 'object' &&
10732
10843
  !Array.isArray(paramsOrFirst))) {
@@ -10735,14 +10846,19 @@ class DocumentsDB {
10735
10846
  else {
10736
10847
  params = {
10737
10848
  queries: paramsOrFirst,
10849
+ total: rest[0],
10738
10850
  };
10739
10851
  }
10740
10852
  const queries = params.queries;
10853
+ const total = params.total;
10741
10854
  const apiPath = '/documentsdb/transactions';
10742
10855
  const apiPayload = {};
10743
10856
  if (typeof queries !== 'undefined') {
10744
10857
  apiPayload['queries'] = queries;
10745
10858
  }
10859
+ if (typeof total !== 'undefined') {
10860
+ apiPayload['total'] = total;
10861
+ }
10746
10862
  const uri = new URL(this.client.config.endpoint + apiPath);
10747
10863
  const apiHeaders = {
10748
10864
  'X-Appwrite-Project': this.client.config.project,
@@ -14708,15 +14824,25 @@ class Functions {
14708
14824
  };
14709
14825
  return this.client.call('post', uri, apiHeaders, apiPayload);
14710
14826
  }
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() {
14827
+ listRuntimes(paramsOrFirst) {
14828
+ let params;
14829
+ if (typeof paramsOrFirst === 'undefined' ||
14830
+ (paramsOrFirst &&
14831
+ typeof paramsOrFirst === 'object' &&
14832
+ !Array.isArray(paramsOrFirst))) {
14833
+ params = (paramsOrFirst || {});
14834
+ }
14835
+ else {
14836
+ params = {
14837
+ total: paramsOrFirst,
14838
+ };
14839
+ }
14840
+ const total = params.total;
14718
14841
  const apiPath = '/functions/runtimes';
14719
14842
  const apiPayload = {};
14843
+ if (typeof total !== 'undefined') {
14844
+ apiPayload['total'] = total;
14845
+ }
14720
14846
  const uri = new URL(this.client.config.endpoint + apiPath);
14721
14847
  const apiHeaders = {
14722
14848
  'X-Appwrite-Project': this.client.config.project,
@@ -14724,9 +14850,9 @@ class Functions {
14724
14850
  };
14725
14851
  return this.client.call('get', uri, apiHeaders, apiPayload);
14726
14852
  }
14727
- listSpecifications(paramsOrFirst) {
14853
+ listSpecifications(paramsOrFirst, ...rest) {
14728
14854
  let params;
14729
- if (typeof paramsOrFirst === 'undefined' ||
14855
+ if ((typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
14730
14856
  (paramsOrFirst &&
14731
14857
  typeof paramsOrFirst === 'object' &&
14732
14858
  !Array.isArray(paramsOrFirst))) {
@@ -14735,14 +14861,19 @@ class Functions {
14735
14861
  else {
14736
14862
  params = {
14737
14863
  type: paramsOrFirst,
14864
+ total: rest[0],
14738
14865
  };
14739
14866
  }
14740
14867
  const type = params.type;
14868
+ const total = params.total;
14741
14869
  const apiPath = '/functions/specifications';
14742
14870
  const apiPayload = {};
14743
14871
  if (typeof type !== 'undefined') {
14744
14872
  apiPayload['type'] = type;
14745
14873
  }
14874
+ if (typeof total !== 'undefined') {
14875
+ apiPayload['total'] = total;
14876
+ }
14746
14877
  const uri = new URL(this.client.config.endpoint + apiPath);
14747
14878
  const apiHeaders = {
14748
14879
  'X-Appwrite-Project': this.client.config.project,
@@ -16054,15 +16185,25 @@ class Locale {
16054
16185
  };
16055
16186
  return this.client.call('get', uri, apiHeaders, apiPayload);
16056
16187
  }
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() {
16188
+ listCodes(paramsOrFirst) {
16189
+ let params;
16190
+ if (typeof paramsOrFirst === 'undefined' ||
16191
+ (paramsOrFirst &&
16192
+ typeof paramsOrFirst === 'object' &&
16193
+ !Array.isArray(paramsOrFirst))) {
16194
+ params = (paramsOrFirst || {});
16195
+ }
16196
+ else {
16197
+ params = {
16198
+ total: paramsOrFirst,
16199
+ };
16200
+ }
16201
+ const total = params.total;
16064
16202
  const apiPath = '/locale/codes';
16065
16203
  const apiPayload = {};
16204
+ if (typeof total !== 'undefined') {
16205
+ apiPayload['total'] = total;
16206
+ }
16066
16207
  const uri = new URL(this.client.config.endpoint + apiPath);
16067
16208
  const apiHeaders = {
16068
16209
  'X-Appwrite-Project': this.client.config.project,
@@ -16070,15 +16211,25 @@ class Locale {
16070
16211
  };
16071
16212
  return this.client.call('get', uri, apiHeaders, apiPayload);
16072
16213
  }
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() {
16214
+ listContinents(paramsOrFirst) {
16215
+ let params;
16216
+ if (typeof paramsOrFirst === 'undefined' ||
16217
+ (paramsOrFirst &&
16218
+ typeof paramsOrFirst === 'object' &&
16219
+ !Array.isArray(paramsOrFirst))) {
16220
+ params = (paramsOrFirst || {});
16221
+ }
16222
+ else {
16223
+ params = {
16224
+ total: paramsOrFirst,
16225
+ };
16226
+ }
16227
+ const total = params.total;
16080
16228
  const apiPath = '/locale/continents';
16081
16229
  const apiPayload = {};
16230
+ if (typeof total !== 'undefined') {
16231
+ apiPayload['total'] = total;
16232
+ }
16082
16233
  const uri = new URL(this.client.config.endpoint + apiPath);
16083
16234
  const apiHeaders = {
16084
16235
  'X-Appwrite-Project': this.client.config.project,
@@ -16086,15 +16237,25 @@ class Locale {
16086
16237
  };
16087
16238
  return this.client.call('get', uri, apiHeaders, apiPayload);
16088
16239
  }
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() {
16240
+ listCountries(paramsOrFirst) {
16241
+ let params;
16242
+ if (typeof paramsOrFirst === 'undefined' ||
16243
+ (paramsOrFirst &&
16244
+ typeof paramsOrFirst === 'object' &&
16245
+ !Array.isArray(paramsOrFirst))) {
16246
+ params = (paramsOrFirst || {});
16247
+ }
16248
+ else {
16249
+ params = {
16250
+ total: paramsOrFirst,
16251
+ };
16252
+ }
16253
+ const total = params.total;
16096
16254
  const apiPath = '/locale/countries';
16097
16255
  const apiPayload = {};
16256
+ if (typeof total !== 'undefined') {
16257
+ apiPayload['total'] = total;
16258
+ }
16098
16259
  const uri = new URL(this.client.config.endpoint + apiPath);
16099
16260
  const apiHeaders = {
16100
16261
  'X-Appwrite-Project': this.client.config.project,
@@ -16102,15 +16263,25 @@ class Locale {
16102
16263
  };
16103
16264
  return this.client.call('get', uri, apiHeaders, apiPayload);
16104
16265
  }
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() {
16266
+ listCountriesEU(paramsOrFirst) {
16267
+ let params;
16268
+ if (typeof paramsOrFirst === 'undefined' ||
16269
+ (paramsOrFirst &&
16270
+ typeof paramsOrFirst === 'object' &&
16271
+ !Array.isArray(paramsOrFirst))) {
16272
+ params = (paramsOrFirst || {});
16273
+ }
16274
+ else {
16275
+ params = {
16276
+ total: paramsOrFirst,
16277
+ };
16278
+ }
16279
+ const total = params.total;
16112
16280
  const apiPath = '/locale/countries/eu';
16113
16281
  const apiPayload = {};
16282
+ if (typeof total !== 'undefined') {
16283
+ apiPayload['total'] = total;
16284
+ }
16114
16285
  const uri = new URL(this.client.config.endpoint + apiPath);
16115
16286
  const apiHeaders = {
16116
16287
  'X-Appwrite-Project': this.client.config.project,
@@ -16118,15 +16289,25 @@ class Locale {
16118
16289
  };
16119
16290
  return this.client.call('get', uri, apiHeaders, apiPayload);
16120
16291
  }
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() {
16292
+ listCountriesPhones(paramsOrFirst) {
16293
+ let params;
16294
+ if (typeof paramsOrFirst === 'undefined' ||
16295
+ (paramsOrFirst &&
16296
+ typeof paramsOrFirst === 'object' &&
16297
+ !Array.isArray(paramsOrFirst))) {
16298
+ params = (paramsOrFirst || {});
16299
+ }
16300
+ else {
16301
+ params = {
16302
+ total: paramsOrFirst,
16303
+ };
16304
+ }
16305
+ const total = params.total;
16128
16306
  const apiPath = '/locale/countries/phones';
16129
16307
  const apiPayload = {};
16308
+ if (typeof total !== 'undefined') {
16309
+ apiPayload['total'] = total;
16310
+ }
16130
16311
  const uri = new URL(this.client.config.endpoint + apiPath);
16131
16312
  const apiHeaders = {
16132
16313
  'X-Appwrite-Project': this.client.config.project,
@@ -16134,15 +16315,25 @@ class Locale {
16134
16315
  };
16135
16316
  return this.client.call('get', uri, apiHeaders, apiPayload);
16136
16317
  }
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() {
16318
+ listCurrencies(paramsOrFirst) {
16319
+ let params;
16320
+ if (typeof paramsOrFirst === 'undefined' ||
16321
+ (paramsOrFirst &&
16322
+ typeof paramsOrFirst === 'object' &&
16323
+ !Array.isArray(paramsOrFirst))) {
16324
+ params = (paramsOrFirst || {});
16325
+ }
16326
+ else {
16327
+ params = {
16328
+ total: paramsOrFirst,
16329
+ };
16330
+ }
16331
+ const total = params.total;
16144
16332
  const apiPath = '/locale/currencies';
16145
16333
  const apiPayload = {};
16334
+ if (typeof total !== 'undefined') {
16335
+ apiPayload['total'] = total;
16336
+ }
16146
16337
  const uri = new URL(this.client.config.endpoint + apiPath);
16147
16338
  const apiHeaders = {
16148
16339
  'X-Appwrite-Project': this.client.config.project,
@@ -16150,15 +16341,25 @@ class Locale {
16150
16341
  };
16151
16342
  return this.client.call('get', uri, apiHeaders, apiPayload);
16152
16343
  }
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() {
16344
+ listLanguages(paramsOrFirst) {
16345
+ let params;
16346
+ if (typeof paramsOrFirst === 'undefined' ||
16347
+ (paramsOrFirst &&
16348
+ typeof paramsOrFirst === 'object' &&
16349
+ !Array.isArray(paramsOrFirst))) {
16350
+ params = (paramsOrFirst || {});
16351
+ }
16352
+ else {
16353
+ params = {
16354
+ total: paramsOrFirst,
16355
+ };
16356
+ }
16357
+ const total = params.total;
16160
16358
  const apiPath = '/locale/languages';
16161
16359
  const apiPayload = {};
16360
+ if (typeof total !== 'undefined') {
16361
+ apiPayload['total'] = total;
16362
+ }
16162
16363
  const uri = new URL(this.client.config.endpoint + apiPath);
16163
16364
  const apiHeaders = {
16164
16365
  'X-Appwrite-Project': this.client.config.project,
@@ -16592,40 +16793,46 @@ class Messaging {
16592
16793
  else {
16593
16794
  params = {
16594
16795
  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],
16796
+ subject: rest[0],
16797
+ content: rest[1],
16798
+ topics: rest[2],
16799
+ users: rest[3],
16800
+ targets: rest[4],
16801
+ cc: rest[5],
16802
+ bcc: rest[6],
16803
+ attachments: rest[7],
16804
+ replyToEmail: rest[8],
16805
+ replyToName: rest[9],
16806
+ draft: rest[10],
16807
+ html: rest[11],
16808
+ scheduledAt: rest[12],
16608
16809
  };
16609
16810
  }
16610
16811
  const messageId = params.messageId;
16812
+ const subject = params.subject;
16813
+ const content = params.content;
16611
16814
  const topics = params.topics;
16612
16815
  const users = params.users;
16613
16816
  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
16817
  const cc = params.cc;
16619
16818
  const bcc = params.bcc;
16819
+ const attachments = params.attachments;
16620
16820
  const replyToEmail = params.replyToEmail;
16621
16821
  const replyToName = params.replyToName;
16822
+ const draft = params.draft;
16823
+ const html = params.html;
16622
16824
  const scheduledAt = params.scheduledAt;
16623
- const attachments = params.attachments;
16624
16825
  if (typeof messageId === 'undefined' || messageId === '') {
16625
16826
  throw new AppwriteException('Missing required parameter: "messageId"');
16626
16827
  }
16627
16828
  const apiPath = '/messaging/messages/email/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId)));
16628
16829
  const apiPayload = {};
16830
+ if (typeof subject !== 'undefined') {
16831
+ apiPayload['subject'] = subject;
16832
+ }
16833
+ if (typeof content !== 'undefined') {
16834
+ apiPayload['content'] = content;
16835
+ }
16629
16836
  if (typeof topics !== 'undefined') {
16630
16837
  apiPayload['topics'] = topics;
16631
16838
  }
@@ -16635,36 +16842,30 @@ class Messaging {
16635
16842
  if (typeof targets !== 'undefined') {
16636
16843
  apiPayload['targets'] = targets;
16637
16844
  }
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
16845
  if (typeof cc !== 'undefined') {
16651
16846
  apiPayload['cc'] = cc;
16652
16847
  }
16653
16848
  if (typeof bcc !== 'undefined') {
16654
16849
  apiPayload['bcc'] = bcc;
16655
16850
  }
16851
+ if (typeof attachments !== 'undefined') {
16852
+ apiPayload['attachments'] = attachments;
16853
+ }
16656
16854
  if (typeof replyToEmail !== 'undefined') {
16657
16855
  apiPayload['replyToEmail'] = replyToEmail;
16658
16856
  }
16659
16857
  if (typeof replyToName !== 'undefined') {
16660
16858
  apiPayload['replyToName'] = replyToName;
16661
16859
  }
16860
+ if (typeof draft !== 'undefined') {
16861
+ apiPayload['draft'] = draft;
16862
+ }
16863
+ if (typeof html !== 'undefined') {
16864
+ apiPayload['html'] = html;
16865
+ }
16662
16866
  if (typeof scheduledAt !== 'undefined') {
16663
16867
  apiPayload['scheduledAt'] = scheduledAt;
16664
16868
  }
16665
- if (typeof attachments !== 'undefined') {
16666
- apiPayload['attachments'] = attachments;
16667
- }
16668
16869
  const uri = new URL(this.client.config.endpoint + apiPath);
16669
16870
  const apiHeaders = {
16670
16871
  'X-Appwrite-Project': this.client.config.project,
@@ -16701,6 +16902,7 @@ class Messaging {
16701
16902
  contentAvailable: rest[15],
16702
16903
  critical: rest[16],
16703
16904
  priority: rest[17],
16905
+ channelId: rest[18],
16704
16906
  };
16705
16907
  }
16706
16908
  const messageId = params.messageId;
@@ -16722,6 +16924,7 @@ class Messaging {
16722
16924
  const contentAvailable = params.contentAvailable;
16723
16925
  const critical = params.critical;
16724
16926
  const priority = params.priority;
16927
+ const channelId = params.channelId;
16725
16928
  if (typeof messageId === 'undefined') {
16726
16929
  throw new AppwriteException('Missing required parameter: "messageId"');
16727
16930
  }
@@ -16784,6 +16987,9 @@ class Messaging {
16784
16987
  if (typeof priority !== 'undefined') {
16785
16988
  apiPayload['priority'] = priority;
16786
16989
  }
16990
+ if (typeof channelId !== 'undefined') {
16991
+ apiPayload['channelId'] = channelId;
16992
+ }
16787
16993
  const uri = new URL(this.client.config.endpoint + apiPath);
16788
16994
  const apiHeaders = {
16789
16995
  'X-Appwrite-Project': this.client.config.project,
@@ -16802,11 +17008,11 @@ class Messaging {
16802
17008
  else {
16803
17009
  params = {
16804
17010
  messageId: paramsOrFirst,
16805
- topics: rest[0],
16806
- users: rest[1],
16807
- targets: rest[2],
16808
- title: rest[3],
16809
- body: rest[4],
17011
+ title: rest[0],
17012
+ body: rest[1],
17013
+ topics: rest[2],
17014
+ users: rest[3],
17015
+ targets: rest[4],
16810
17016
  data: rest[5],
16811
17017
  action: rest[6],
16812
17018
  image: rest[7],
@@ -16820,14 +17026,15 @@ class Messaging {
16820
17026
  contentAvailable: rest[15],
16821
17027
  critical: rest[16],
16822
17028
  priority: rest[17],
17029
+ channelId: rest[18],
16823
17030
  };
16824
17031
  }
16825
17032
  const messageId = params.messageId;
17033
+ const title = params.title;
17034
+ const body = params.body;
16826
17035
  const topics = params.topics;
16827
17036
  const users = params.users;
16828
17037
  const targets = params.targets;
16829
- const title = params.title;
16830
- const body = params.body;
16831
17038
  const data = params.data;
16832
17039
  const action = params.action;
16833
17040
  const image = params.image;
@@ -16841,11 +17048,18 @@ class Messaging {
16841
17048
  const contentAvailable = params.contentAvailable;
16842
17049
  const critical = params.critical;
16843
17050
  const priority = params.priority;
17051
+ const channelId = params.channelId;
16844
17052
  if (typeof messageId === 'undefined' || messageId === '') {
16845
17053
  throw new AppwriteException('Missing required parameter: "messageId"');
16846
17054
  }
16847
17055
  const apiPath = '/messaging/messages/push/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId)));
16848
17056
  const apiPayload = {};
17057
+ if (typeof title !== 'undefined') {
17058
+ apiPayload['title'] = title;
17059
+ }
17060
+ if (typeof body !== 'undefined') {
17061
+ apiPayload['body'] = body;
17062
+ }
16849
17063
  if (typeof topics !== 'undefined') {
16850
17064
  apiPayload['topics'] = topics;
16851
17065
  }
@@ -16855,12 +17069,6 @@ class Messaging {
16855
17069
  if (typeof targets !== 'undefined') {
16856
17070
  apiPayload['targets'] = targets;
16857
17071
  }
16858
- if (typeof title !== 'undefined') {
16859
- apiPayload['title'] = title;
16860
- }
16861
- if (typeof body !== 'undefined') {
16862
- apiPayload['body'] = body;
16863
- }
16864
17072
  if (typeof data !== 'undefined') {
16865
17073
  apiPayload['data'] = data;
16866
17074
  }
@@ -16900,6 +17108,9 @@ class Messaging {
16900
17108
  if (typeof priority !== 'undefined') {
16901
17109
  apiPayload['priority'] = priority;
16902
17110
  }
17111
+ if (typeof channelId !== 'undefined') {
17112
+ apiPayload['channelId'] = channelId;
17113
+ }
16903
17114
  const uri = new URL(this.client.config.endpoint + apiPath);
16904
17115
  const apiHeaders = {
16905
17116
  'X-Appwrite-Project': this.client.config.project,
@@ -16995,17 +17206,73 @@ class Messaging {
16995
17206
  const targets = params.targets;
16996
17207
  const draft = params.draft;
16997
17208
  const scheduledAt = params.scheduledAt;
16998
- if (typeof messageId === 'undefined') {
17209
+ if (typeof messageId === 'undefined') {
17210
+ throw new AppwriteException('Missing required parameter: "messageId"');
17211
+ }
17212
+ if (typeof content === 'undefined') {
17213
+ throw new AppwriteException('Missing required parameter: "content"');
17214
+ }
17215
+ const apiPath = '/messaging/messages/sms';
17216
+ const apiPayload = {};
17217
+ if (typeof messageId !== 'undefined') {
17218
+ apiPayload['messageId'] = messageId;
17219
+ }
17220
+ if (typeof content !== 'undefined') {
17221
+ apiPayload['content'] = content;
17222
+ }
17223
+ if (typeof topics !== 'undefined') {
17224
+ apiPayload['topics'] = topics;
17225
+ }
17226
+ if (typeof users !== 'undefined') {
17227
+ apiPayload['users'] = users;
17228
+ }
17229
+ if (typeof targets !== 'undefined') {
17230
+ apiPayload['targets'] = targets;
17231
+ }
17232
+ if (typeof draft !== 'undefined') {
17233
+ apiPayload['draft'] = draft;
17234
+ }
17235
+ if (typeof scheduledAt !== 'undefined') {
17236
+ apiPayload['scheduledAt'] = scheduledAt;
17237
+ }
17238
+ const uri = new URL(this.client.config.endpoint + apiPath);
17239
+ const apiHeaders = {
17240
+ 'X-Appwrite-Project': this.client.config.project,
17241
+ 'content-type': 'application/json',
17242
+ accept: 'application/json',
17243
+ };
17244
+ return this.client.call('post', uri, apiHeaders, apiPayload);
17245
+ }
17246
+ updateSms(paramsOrFirst, ...rest) {
17247
+ let params;
17248
+ if (paramsOrFirst &&
17249
+ typeof paramsOrFirst === 'object' &&
17250
+ !Array.isArray(paramsOrFirst)) {
17251
+ params = (paramsOrFirst || {});
17252
+ }
17253
+ else {
17254
+ params = {
17255
+ messageId: paramsOrFirst,
17256
+ content: rest[0],
17257
+ topics: rest[1],
17258
+ users: rest[2],
17259
+ targets: rest[3],
17260
+ draft: rest[4],
17261
+ scheduledAt: rest[5],
17262
+ };
17263
+ }
17264
+ const messageId = params.messageId;
17265
+ const content = params.content;
17266
+ const topics = params.topics;
17267
+ const users = params.users;
17268
+ const targets = params.targets;
17269
+ const draft = params.draft;
17270
+ const scheduledAt = params.scheduledAt;
17271
+ if (typeof messageId === 'undefined' || messageId === '') {
16999
17272
  throw new AppwriteException('Missing required parameter: "messageId"');
17000
17273
  }
17001
- if (typeof content === 'undefined') {
17002
- throw new AppwriteException('Missing required parameter: "content"');
17003
- }
17004
- const apiPath = '/messaging/messages/sms';
17274
+ const apiPath = '/messaging/messages/sms/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId)));
17005
17275
  const apiPayload = {};
17006
- if (typeof messageId !== 'undefined') {
17007
- apiPayload['messageId'] = messageId;
17008
- }
17009
17276
  if (typeof content !== 'undefined') {
17010
17277
  apiPayload['content'] = content;
17011
17278
  }
@@ -17030,9 +17297,9 @@ class Messaging {
17030
17297
  'content-type': 'application/json',
17031
17298
  accept: 'application/json',
17032
17299
  };
17033
- return this.client.call('post', uri, apiHeaders, apiPayload);
17300
+ return this.client.call('patch', uri, apiHeaders, apiPayload);
17034
17301
  }
17035
- updateSms(paramsOrFirst, ...rest) {
17302
+ updateSMS(paramsOrFirst, ...rest) {
17036
17303
  let params;
17037
17304
  if (paramsOrFirst &&
17038
17305
  typeof paramsOrFirst === 'object' &&
@@ -17042,19 +17309,19 @@ class Messaging {
17042
17309
  else {
17043
17310
  params = {
17044
17311
  messageId: paramsOrFirst,
17045
- topics: rest[0],
17046
- users: rest[1],
17047
- targets: rest[2],
17048
- content: rest[3],
17312
+ content: rest[0],
17313
+ topics: rest[1],
17314
+ users: rest[2],
17315
+ targets: rest[3],
17049
17316
  draft: rest[4],
17050
17317
  scheduledAt: rest[5],
17051
17318
  };
17052
17319
  }
17053
17320
  const messageId = params.messageId;
17321
+ const content = params.content;
17054
17322
  const topics = params.topics;
17055
17323
  const users = params.users;
17056
17324
  const targets = params.targets;
17057
- const content = params.content;
17058
17325
  const draft = params.draft;
17059
17326
  const scheduledAt = params.scheduledAt;
17060
17327
  if (typeof messageId === 'undefined' || messageId === '') {
@@ -17062,62 +17329,9 @@ class Messaging {
17062
17329
  }
17063
17330
  const apiPath = '/messaging/messages/sms/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId)));
17064
17331
  const apiPayload = {};
17065
- if (typeof topics !== 'undefined') {
17066
- apiPayload['topics'] = topics;
17067
- }
17068
- if (typeof users !== 'undefined') {
17069
- apiPayload['users'] = users;
17070
- }
17071
- if (typeof targets !== 'undefined') {
17072
- apiPayload['targets'] = targets;
17073
- }
17074
17332
  if (typeof content !== 'undefined') {
17075
17333
  apiPayload['content'] = content;
17076
17334
  }
17077
- if (typeof draft !== 'undefined') {
17078
- apiPayload['draft'] = draft;
17079
- }
17080
- if (typeof scheduledAt !== 'undefined') {
17081
- apiPayload['scheduledAt'] = scheduledAt;
17082
- }
17083
- const uri = new URL(this.client.config.endpoint + apiPath);
17084
- const apiHeaders = {
17085
- 'X-Appwrite-Project': this.client.config.project,
17086
- 'content-type': 'application/json',
17087
- accept: 'application/json',
17088
- };
17089
- return this.client.call('patch', uri, apiHeaders, apiPayload);
17090
- }
17091
- updateSMS(paramsOrFirst, ...rest) {
17092
- let params;
17093
- if (paramsOrFirst &&
17094
- typeof paramsOrFirst === 'object' &&
17095
- !Array.isArray(paramsOrFirst)) {
17096
- params = (paramsOrFirst || {});
17097
- }
17098
- else {
17099
- params = {
17100
- messageId: paramsOrFirst,
17101
- topics: rest[0],
17102
- users: rest[1],
17103
- targets: rest[2],
17104
- content: rest[3],
17105
- draft: rest[4],
17106
- scheduledAt: rest[5],
17107
- };
17108
- }
17109
- const messageId = params.messageId;
17110
- const topics = params.topics;
17111
- const users = params.users;
17112
- const targets = params.targets;
17113
- const content = params.content;
17114
- const draft = params.draft;
17115
- const scheduledAt = params.scheduledAt;
17116
- if (typeof messageId === 'undefined' || messageId === '') {
17117
- throw new AppwriteException('Missing required parameter: "messageId"');
17118
- }
17119
- const apiPath = '/messaging/messages/sms/{messageId}'.replace('{messageId}', encodeURIComponent(String(messageId)));
17120
- const apiPayload = {};
17121
17335
  if (typeof topics !== 'undefined') {
17122
17336
  apiPayload['topics'] = topics;
17123
17337
  }
@@ -17127,9 +17341,6 @@ class Messaging {
17127
17341
  if (typeof targets !== 'undefined') {
17128
17342
  apiPayload['targets'] = targets;
17129
17343
  }
17130
- if (typeof content !== 'undefined') {
17131
- apiPayload['content'] = content;
17132
- }
17133
17344
  if (typeof draft !== 'undefined') {
17134
17345
  apiPayload['draft'] = draft;
17135
17346
  }
@@ -23201,9 +23412,9 @@ class Notifications {
23201
23412
  constructor(client) {
23202
23413
  this.client = client;
23203
23414
  }
23204
- list(paramsOrFirst) {
23415
+ list(paramsOrFirst, ...rest) {
23205
23416
  let params;
23206
- if (typeof paramsOrFirst === 'undefined' ||
23417
+ if ((typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
23207
23418
  (paramsOrFirst &&
23208
23419
  typeof paramsOrFirst === 'object' &&
23209
23420
  !Array.isArray(paramsOrFirst))) {
@@ -23212,14 +23423,19 @@ class Notifications {
23212
23423
  else {
23213
23424
  params = {
23214
23425
  queries: paramsOrFirst,
23426
+ total: rest[0],
23215
23427
  };
23216
23428
  }
23217
23429
  const queries = params.queries;
23430
+ const total = params.total;
23218
23431
  const apiPath = '/notifications';
23219
23432
  const apiPayload = {};
23220
23433
  if (typeof queries !== 'undefined') {
23221
23434
  apiPayload['queries'] = queries;
23222
23435
  }
23436
+ if (typeof total !== 'undefined') {
23437
+ apiPayload['total'] = total;
23438
+ }
23223
23439
  const uri = new URL(this.client.config.endpoint + apiPath);
23224
23440
  const apiHeaders = {
23225
23441
  'X-Appwrite-Project': this.client.config.project,
@@ -30509,6 +30725,43 @@ class Project {
30509
30725
  };
30510
30726
  return this.client.call('patch', uri, apiHeaders, apiPayload);
30511
30727
  }
30728
+ updateOAuth2Webflow(paramsOrFirst, ...rest) {
30729
+ let params;
30730
+ if ((typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
30731
+ (paramsOrFirst &&
30732
+ typeof paramsOrFirst === 'object' &&
30733
+ !Array.isArray(paramsOrFirst))) {
30734
+ params = (paramsOrFirst || {});
30735
+ }
30736
+ else {
30737
+ params = {
30738
+ clientId: paramsOrFirst,
30739
+ clientSecret: rest[0],
30740
+ enabled: rest[1],
30741
+ };
30742
+ }
30743
+ const clientId = params.clientId;
30744
+ const clientSecret = params.clientSecret;
30745
+ const enabled = params.enabled;
30746
+ const apiPath = '/project/oauth2/webflow';
30747
+ const apiPayload = {};
30748
+ if (typeof clientId !== 'undefined') {
30749
+ apiPayload['clientId'] = clientId;
30750
+ }
30751
+ if (typeof clientSecret !== 'undefined') {
30752
+ apiPayload['clientSecret'] = clientSecret;
30753
+ }
30754
+ if (typeof enabled !== 'undefined') {
30755
+ apiPayload['enabled'] = enabled;
30756
+ }
30757
+ const uri = new URL(this.client.config.endpoint + apiPath);
30758
+ const apiHeaders = {
30759
+ 'X-Appwrite-Project': this.client.config.project,
30760
+ 'content-type': 'application/json',
30761
+ accept: 'application/json',
30762
+ };
30763
+ return this.client.call('patch', uri, apiHeaders, apiPayload);
30764
+ }
30512
30765
  updateOAuth2WordPress(paramsOrFirst, ...rest) {
30513
30766
  let params;
30514
30767
  if ((typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
@@ -33491,15 +33744,25 @@ class Sites {
33491
33744
  };
33492
33745
  return this.client.call('post', uri, apiHeaders, apiPayload);
33493
33746
  }
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() {
33747
+ listFrameworks(paramsOrFirst) {
33748
+ let params;
33749
+ if (typeof paramsOrFirst === 'undefined' ||
33750
+ (paramsOrFirst &&
33751
+ typeof paramsOrFirst === 'object' &&
33752
+ !Array.isArray(paramsOrFirst))) {
33753
+ params = (paramsOrFirst || {});
33754
+ }
33755
+ else {
33756
+ params = {
33757
+ total: paramsOrFirst,
33758
+ };
33759
+ }
33760
+ const total = params.total;
33501
33761
  const apiPath = '/sites/frameworks';
33502
33762
  const apiPayload = {};
33763
+ if (typeof total !== 'undefined') {
33764
+ apiPayload['total'] = total;
33765
+ }
33503
33766
  const uri = new URL(this.client.config.endpoint + apiPath);
33504
33767
  const apiHeaders = {
33505
33768
  'X-Appwrite-Project': this.client.config.project,
@@ -33507,9 +33770,9 @@ class Sites {
33507
33770
  };
33508
33771
  return this.client.call('get', uri, apiHeaders, apiPayload);
33509
33772
  }
33510
- listSpecifications(paramsOrFirst) {
33773
+ listSpecifications(paramsOrFirst, ...rest) {
33511
33774
  let params;
33512
- if (typeof paramsOrFirst === 'undefined' ||
33775
+ if ((typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
33513
33776
  (paramsOrFirst &&
33514
33777
  typeof paramsOrFirst === 'object' &&
33515
33778
  !Array.isArray(paramsOrFirst))) {
@@ -33518,14 +33781,19 @@ class Sites {
33518
33781
  else {
33519
33782
  params = {
33520
33783
  type: paramsOrFirst,
33784
+ total: rest[0],
33521
33785
  };
33522
33786
  }
33523
33787
  const type = params.type;
33788
+ const total = params.total;
33524
33789
  const apiPath = '/sites/specifications';
33525
33790
  const apiPayload = {};
33526
33791
  if (typeof type !== 'undefined') {
33527
33792
  apiPayload['type'] = type;
33528
33793
  }
33794
+ if (typeof total !== 'undefined') {
33795
+ apiPayload['total'] = total;
33796
+ }
33529
33797
  const uri = new URL(this.client.config.endpoint + apiPath);
33530
33798
  const apiHeaders = {
33531
33799
  'X-Appwrite-Project': this.client.config.project,
@@ -33542,7 +33810,8 @@ class Sites {
33542
33810
  ('frameworks' in paramsOrFirst ||
33543
33811
  'useCases' in paramsOrFirst ||
33544
33812
  'limit' in paramsOrFirst ||
33545
- 'offset' in paramsOrFirst))) {
33813
+ 'offset' in paramsOrFirst ||
33814
+ 'total' in paramsOrFirst))) {
33546
33815
  params = (paramsOrFirst || {});
33547
33816
  }
33548
33817
  else {
@@ -33551,12 +33820,14 @@ class Sites {
33551
33820
  useCases: rest[0],
33552
33821
  limit: rest[1],
33553
33822
  offset: rest[2],
33823
+ total: rest[3],
33554
33824
  };
33555
33825
  }
33556
33826
  const frameworks = params.frameworks;
33557
33827
  const useCases = params.useCases;
33558
33828
  const limit = params.limit;
33559
33829
  const offset = params.offset;
33830
+ const total = params.total;
33560
33831
  const apiPath = '/sites/templates';
33561
33832
  const apiPayload = {};
33562
33833
  if (typeof frameworks !== 'undefined') {
@@ -33571,6 +33842,9 @@ class Sites {
33571
33842
  if (typeof offset !== 'undefined') {
33572
33843
  apiPayload['offset'] = offset;
33573
33844
  }
33845
+ if (typeof total !== 'undefined') {
33846
+ apiPayload['total'] = total;
33847
+ }
33574
33848
  const uri = new URL(this.client.config.endpoint + apiPath);
33575
33849
  const apiHeaders = {
33576
33850
  'X-Appwrite-Project': this.client.config.project,
@@ -35269,9 +35543,9 @@ class TablesDB {
35269
35543
  };
35270
35544
  return this.client.call('get', uri, apiHeaders, apiPayload);
35271
35545
  }
35272
- listTransactions(paramsOrFirst) {
35546
+ listTransactions(paramsOrFirst, ...rest) {
35273
35547
  let params;
35274
- if (typeof paramsOrFirst === 'undefined' ||
35548
+ if ((typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
35275
35549
  (paramsOrFirst &&
35276
35550
  typeof paramsOrFirst === 'object' &&
35277
35551
  !Array.isArray(paramsOrFirst))) {
@@ -35280,14 +35554,19 @@ class TablesDB {
35280
35554
  else {
35281
35555
  params = {
35282
35556
  queries: paramsOrFirst,
35557
+ total: rest[0],
35283
35558
  };
35284
35559
  }
35285
35560
  const queries = params.queries;
35561
+ const total = params.total;
35286
35562
  const apiPath = '/tablesdb/transactions';
35287
35563
  const apiPayload = {};
35288
35564
  if (typeof queries !== 'undefined') {
35289
35565
  apiPayload['queries'] = queries;
35290
35566
  }
35567
+ if (typeof total !== 'undefined') {
35568
+ apiPayload['total'] = total;
35569
+ }
35291
35570
  const uri = new URL(this.client.config.endpoint + apiPath);
35292
35571
  const apiHeaders = {
35293
35572
  'X-Appwrite-Project': this.client.config.project,
@@ -42109,12 +42388,14 @@ class Vcs {
42109
42388
  type: rest[0],
42110
42389
  search: rest[1],
42111
42390
  queries: rest[2],
42391
+ total: rest[3],
42112
42392
  };
42113
42393
  }
42114
42394
  const installationId = params.installationId;
42115
42395
  const type = params.type;
42116
42396
  const search = params.search;
42117
42397
  const queries = params.queries;
42398
+ const total = params.total;
42118
42399
  if (typeof installationId === 'undefined' || installationId === '') {
42119
42400
  throw new AppwriteException('Missing required parameter: "installationId"');
42120
42401
  }
@@ -42132,6 +42413,9 @@ class Vcs {
42132
42413
  if (typeof queries !== 'undefined') {
42133
42414
  apiPayload['queries'] = queries;
42134
42415
  }
42416
+ if (typeof total !== 'undefined') {
42417
+ apiPayload['total'] = total;
42418
+ }
42135
42419
  const uri = new URL(this.client.config.endpoint + apiPath);
42136
42420
  const apiHeaders = {
42137
42421
  'X-Appwrite-Project': this.client.config.project,
@@ -42232,12 +42516,14 @@ class Vcs {
42232
42516
  providerRepositoryId: rest[0],
42233
42517
  search: rest[1],
42234
42518
  queries: rest[2],
42519
+ total: rest[3],
42235
42520
  };
42236
42521
  }
42237
42522
  const installationId = params.installationId;
42238
42523
  const providerRepositoryId = params.providerRepositoryId;
42239
42524
  const search = params.search;
42240
42525
  const queries = params.queries;
42526
+ const total = params.total;
42241
42527
  if (typeof installationId === 'undefined' || installationId === '') {
42242
42528
  throw new AppwriteException('Missing required parameter: "installationId"');
42243
42529
  }
@@ -42255,6 +42541,9 @@ class Vcs {
42255
42541
  if (typeof queries !== 'undefined') {
42256
42542
  apiPayload['queries'] = queries;
42257
42543
  }
42544
+ if (typeof total !== 'undefined') {
42545
+ apiPayload['total'] = total;
42546
+ }
42258
42547
  const uri = new URL(this.client.config.endpoint + apiPath);
42259
42548
  const apiHeaders = {
42260
42549
  'X-Appwrite-Project': this.client.config.project,
@@ -42445,11 +42734,13 @@ class Vcs {
42445
42734
  installationId: paramsOrFirst,
42446
42735
  search: rest[0],
42447
42736
  queries: rest[1],
42737
+ total: rest[2],
42448
42738
  };
42449
42739
  }
42450
42740
  const installationId = params.installationId;
42451
42741
  const search = params.search;
42452
42742
  const queries = params.queries;
42743
+ const total = params.total;
42453
42744
  if (typeof installationId === 'undefined' || installationId === '') {
42454
42745
  throw new AppwriteException('Missing required parameter: "installationId"');
42455
42746
  }
@@ -42461,6 +42752,9 @@ class Vcs {
42461
42752
  if (typeof queries !== 'undefined') {
42462
42753
  apiPayload['queries'] = queries;
42463
42754
  }
42755
+ if (typeof total !== 'undefined') {
42756
+ apiPayload['total'] = total;
42757
+ }
42464
42758
  const uri = new URL(this.client.config.endpoint + apiPath);
42465
42759
  const apiHeaders = {
42466
42760
  'X-Appwrite-Project': this.client.config.project,
@@ -42578,9 +42872,9 @@ class VectorsDB {
42578
42872
  };
42579
42873
  return this.client.call('get', uri, apiHeaders, apiPayload);
42580
42874
  }
42581
- listTransactions(paramsOrFirst) {
42875
+ listTransactions(paramsOrFirst, ...rest) {
42582
42876
  let params;
42583
- if (typeof paramsOrFirst === 'undefined' ||
42877
+ if ((typeof paramsOrFirst === 'undefined' && rest.length === 0) ||
42584
42878
  (paramsOrFirst &&
42585
42879
  typeof paramsOrFirst === 'object' &&
42586
42880
  !Array.isArray(paramsOrFirst))) {
@@ -42589,14 +42883,19 @@ class VectorsDB {
42589
42883
  else {
42590
42884
  params = {
42591
42885
  queries: paramsOrFirst,
42886
+ total: rest[0],
42592
42887
  };
42593
42888
  }
42594
42889
  const queries = params.queries;
42890
+ const total = params.total;
42595
42891
  const apiPath = '/vectorsdb/transactions';
42596
42892
  const apiPayload = {};
42597
42893
  if (typeof queries !== 'undefined') {
42598
42894
  apiPayload['queries'] = queries;
42599
42895
  }
42896
+ if (typeof total !== 'undefined') {
42897
+ apiPayload['total'] = total;
42898
+ }
42600
42899
  const uri = new URL(this.client.config.endpoint + apiPath);
42601
42900
  const apiHeaders = {
42602
42901
  'X-Appwrite-Project': this.client.config.project,
@@ -45658,6 +45957,27 @@ class Realtime {
45658
45957
  }
45659
45958
  }
45660
45959
 
45960
+ const TAB_ID_KEY = 'appwrite-push-client-id';
45961
+ // Loaded on first connect, so an app that never uses Push does not bundle mqtt.js.
45962
+ let transport = null;
45963
+ function loadTransport() {
45964
+ if (!transport) {
45965
+ transport = Promise.all([import('mqtt'), import('buffer')]).then(
45966
+ // The browser build of mqtt.js (dist/mqtt.esm.js) exports only a default.
45967
+ ([mqtt, buffer]) => {
45968
+ var _a;
45969
+ return ({
45970
+ connect: ((_a = mqtt.default) !== null && _a !== void 0 ? _a : mqtt).connect,
45971
+ Buffer: buffer.Buffer,
45972
+ });
45973
+ });
45974
+ // A failed load must not poison later connects.
45975
+ transport.catch(() => {
45976
+ transport = null;
45977
+ });
45978
+ }
45979
+ return transport;
45980
+ }
45661
45981
  // Fixed connection tuning — not exposed as options.
45662
45982
  const KEEP_ALIVE_SECONDS = 60;
45663
45983
  const RECONNECT_PERIOD_MS = 2000;
@@ -45687,6 +46007,9 @@ class Push extends Service {
45687
46007
  super(client);
45688
46008
  this.mqtt = null;
45689
46009
  this.connecting = null;
46010
+ this.Buffer = null;
46011
+ /** Bumped by close(), so a connect still loading mqtt.js knows to stop. */
46012
+ this.generation = 0;
45690
46013
  /** Set once the first CONNACK lands, so 'connect' events after are reconnects. */
45691
46014
  this.everConnected = false;
45692
46015
  /** Errors already handed to onError, so one failure is reported once. */
@@ -45698,10 +46021,18 @@ class Push extends Service {
45698
46021
  // Local id -> subscription state. The id is never sent to the broker; it only lets
45699
46022
  // the same topic carry more than one callback (each with its own options).
45700
46023
  /**
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.
46024
+ * This tab's part of the default client id when the tab has none yet (see claimTabId):
46025
+ * random, but kept for this instance so reconnects resume the same broker session.
45703
46026
  */
45704
46027
  this.fallbackClientId = randomId();
46028
+ /** The default client id claimed for this instance's connection, released on close(). */
46029
+ this.tabId = '';
46030
+ /** In-flight claim of {@link tabId}, memoized per generation: a credential switch (same
46031
+ * generation) shares the one claim; a close/reopen (new generation) chains a fresh claim. */
46032
+ this.tabIdClaim = null;
46033
+ this.tabIdClaimGeneration = -1;
46034
+ this.connectedKey = '';
46035
+ this.connectionEpoch = 0;
45705
46036
  this.subscriptions = new Map();
45706
46037
  }
45707
46038
  // The broker subscription for a filter uses the highest QoS any local subscription on
@@ -45802,7 +46133,17 @@ class Push extends Service {
45802
46133
  if (background) {
45803
46134
  this.requestNotificationPermission();
45804
46135
  }
45805
- const client = yield this.connect();
46136
+ let client;
46137
+ try {
46138
+ client = yield this.connect();
46139
+ }
46140
+ catch (err) {
46141
+ if (err instanceof SupersededError) {
46142
+ return this.subscribeWith(topicsOrCallback, callbackOrOptions, topicOptions);
46143
+ }
46144
+ throw err;
46145
+ }
46146
+ const epoch = this.connectionEpoch;
45806
46147
  const ids = [];
45807
46148
  const acks = [];
45808
46149
  for (const topic of topicList) {
@@ -45861,6 +46202,12 @@ class Push extends Service {
45861
46202
  yield Promise.all(acks);
45862
46203
  }
45863
46204
  catch (err) {
46205
+ if (epoch !== this.connectionEpoch) {
46206
+ for (const id of ids) {
46207
+ this.subscriptions.delete(id);
46208
+ }
46209
+ return this.subscribeWith(topicsOrCallback, callbackOrOptions, topicOptions);
46210
+ }
45864
46211
  unsubscribe();
45865
46212
  throw err;
45866
46213
  }
@@ -45921,7 +46268,14 @@ class Push extends Service {
45921
46268
  this.mqtt.end(true);
45922
46269
  this.mqtt = null;
45923
46270
  }
46271
+ if (this.tabId !== '') {
46272
+ releaseTabId(this.tabId);
46273
+ this.tabId = '';
46274
+ }
45924
46275
  this.connecting = null;
46276
+ // Bumping the generation ends the current claim: one still in flight releases its id when
46277
+ // it resolves, and the next open() chains a fresh claim after it (see claimClientId).
46278
+ this.generation++;
45925
46279
  this.everConnected = false;
45926
46280
  this.subscriptions.clear();
45927
46281
  }
@@ -45946,19 +46300,62 @@ class Push extends Service {
45946
46300
  }
45947
46301
  // --- internals ---
45948
46302
  connect() {
45949
- if (this.mqtt) {
46303
+ var _a;
46304
+ if ((this.mqtt || this.connecting) &&
46305
+ this.connectedKey !== this.credentialKey()) {
46306
+ this.connectionEpoch++;
46307
+ (_a = this.mqtt) === null || _a === void 0 ? void 0 : _a.end(true);
46308
+ this.mqtt = null;
46309
+ this.connecting = null;
46310
+ this.everConnected = this.subscriptions.size > 0;
46311
+ }
46312
+ if (this.mqtt && !this.connecting) {
45950
46313
  return Promise.resolve(this.mqtt);
45951
46314
  }
45952
46315
  if (!this.connecting) {
45953
- this.connecting = this.open();
46316
+ const connecting = this.open();
46317
+ this.connecting = connecting;
45954
46318
  // A failed open must not poison future attempts — clear the cached
45955
46319
  // in-flight promise so a later subscribe/publish can retry.
45956
- this.connecting.catch(() => {
45957
- this.connecting = null;
46320
+ connecting.catch(() => {
46321
+ if (this.connecting === connecting) {
46322
+ this.connecting = null;
46323
+ }
45958
46324
  });
45959
46325
  }
45960
46326
  return this.connecting.then(() => this.mqtt);
45961
46327
  }
46328
+ credential() {
46329
+ if (this.client.config.jwt) {
46330
+ return {
46331
+ authMethod: 'appwrite-jwt',
46332
+ credential: this.client.config.jwt,
46333
+ };
46334
+ }
46335
+ if (this.client.config.session) {
46336
+ return {
46337
+ authMethod: 'appwrite-session',
46338
+ credential: this.client.config.session,
46339
+ };
46340
+ }
46341
+ throw new Error('No credential set on the client; call Client.setJWT() or Client.setSession() first.');
46342
+ }
46343
+ credentialKey() {
46344
+ var _a, _b;
46345
+ try {
46346
+ const { authMethod, credential } = this.credential();
46347
+ return [
46348
+ this.endpointUrl(),
46349
+ (_a = this.client.config.project) !== null && _a !== void 0 ? _a : '',
46350
+ (_b = this.client.config.pushClientId) !== null && _b !== void 0 ? _b : '',
46351
+ authMethod,
46352
+ credential,
46353
+ ].join('|');
46354
+ }
46355
+ catch (_c) {
46356
+ return '';
46357
+ }
46358
+ }
45962
46359
  endpointUrl() {
45963
46360
  // The push endpoint set on the client (Client.setPushEndpoint) wins.
45964
46361
  if (this.client.config.endpointPush !== '') {
@@ -45976,35 +46373,76 @@ class Push extends Service {
45976
46373
  ? wsEndpoint
45977
46374
  : `${wsEndpoint.slice(0, at + separator.length)}push.${wsEndpoint.slice(at + separator.length)}`;
45978
46375
  }
46376
+ /**
46377
+ * Claim this connection's default client id, memoized per generation. A credential switch (same
46378
+ * generation) shares the one claim, so concurrent open() calls never each claim. A close/reopen
46379
+ * (a new generation) chains a fresh claim after the previous one has settled and released its
46380
+ * id, so the reopened connection can take the tab's stored id back rather than a fallback. A
46381
+ * claim that resolves after its generation has ended releases its id instead of keeping it, so
46382
+ * a stale open connects with nothing reserved and the stored id is never stranded.
46383
+ */
46384
+ claimClientId() {
46385
+ var _a;
46386
+ const generation = this.generation;
46387
+ if (this.tabIdClaim === null ||
46388
+ this.tabIdClaimGeneration !== generation) {
46389
+ const previous = (_a = this.tabIdClaim) !== null && _a !== void 0 ? _a : Promise.resolve('');
46390
+ this.tabIdClaimGeneration = generation;
46391
+ const claim = previous
46392
+ .catch(() => '')
46393
+ .then(() => claimTabId(this.fallbackClientId))
46394
+ .then((id) => {
46395
+ if (this.generation !== generation) {
46396
+ releaseTabId(id);
46397
+ return '';
46398
+ }
46399
+ this.tabId = id;
46400
+ return id;
46401
+ });
46402
+ this.tabIdClaim = claim;
46403
+ return claim;
46404
+ }
46405
+ return this.tabIdClaim;
46406
+ }
45979
46407
  open() {
45980
46408
  return __awaiter(this, void 0, void 0, function* () {
45981
46409
  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
- }
46410
+ const { authMethod, credential } = this.credential();
46411
+ this.connectedKey = this.credentialKey();
46412
+ const epoch = this.connectionEpoch;
46413
+ const generation = this.generation;
45996
46414
  const project = (_a = this.client.config.project) !== null && _a !== void 0 ? _a : '';
45997
46415
  // Client id, when the app did not set one with Client.setPushClientId(). Unlike the
45998
46416
  // 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.
46417
+ // rejects an empty id with clean start off, so derive one per user and tab from the
46418
+ // credential this connection authenticates with (the JWT's userId, or the session's user
46419
+ // id) and an id kept in the tab's sessionStorage. It stays the same across reloads, so
46420
+ // the broker's replay cursor resumes, and differs between tabs and browsers, so two of
46421
+ // them do not take over each other's session. The credential itself is never used.
46422
+ const userId = authMethod === 'appwrite-jwt'
46423
+ ? userIdFromJwt(credential)
46424
+ : userIdFromSession(credential);
46425
+ // Claim once per instance (memoized) and reuse it across reconnects and credential
46426
+ // switches, so concurrent open() calls never each claim and strand the tab's stored id.
46427
+ // Concurrent instances still get distinct ids. If close() ran while the claim was pending
46428
+ // this open is stale, so stop before connecting (the claim releases its own id).
46429
+ if (!this.client.config.pushClientId) {
46430
+ yield this.claimClientId();
46431
+ if (generation !== this.generation) {
46432
+ throw new Error('Push was closed while connecting.');
46433
+ }
46434
+ }
46435
+ const tabId = this.tabId;
46003
46436
  const clientId = this.client.config.pushClientId ||
46004
- (authMethod === 'appwrite-jwt'
46005
- ? userIdFromJwt(credential)
46006
- : userIdFromSession(credential)) ||
46007
- this.fallbackClientId;
46437
+ (userId ? `${userId}-${tabId}` : tabId);
46438
+ const { connect, Buffer } = yield loadTransport();
46439
+ if (generation !== this.generation) {
46440
+ throw new Error('Push was closed while connecting.');
46441
+ }
46442
+ if (epoch !== this.connectionEpoch) {
46443
+ throw new SupersededError();
46444
+ }
46445
+ this.Buffer = Buffer;
46008
46446
  const options = {
46009
46447
  clientId,
46010
46448
  protocolVersion: 5,
@@ -46015,11 +46453,11 @@ class Push extends Service {
46015
46453
  // Enhanced auth carried in CONNECT properties.
46016
46454
  properties: {
46017
46455
  authenticationMethod: authMethod,
46018
- authenticationData: buffer.Buffer.from(credential),
46456
+ authenticationData: Buffer.from(credential),
46019
46457
  userProperties: { projectId: project },
46020
46458
  },
46021
46459
  };
46022
- const client = mqtt.connect(this.endpointUrl(), options);
46460
+ const client = connect(this.endpointUrl(), options);
46023
46461
  this.mqtt = client;
46024
46462
  client.on('message', (_topic, _payload, packet) => {
46025
46463
  this.dispatch(packet).catch((err) => this.report(err));
@@ -46051,6 +46489,9 @@ class Push extends Service {
46051
46489
  }
46052
46490
  });
46053
46491
  client.on('error', (err) => {
46492
+ if (epoch !== this.connectionEpoch) {
46493
+ return;
46494
+ }
46054
46495
  const error = this.connectError(err, refusedReason);
46055
46496
  // While the first connect is pending its caller receives the error (and reports it
46056
46497
  // through fail()); afterwards, e.g. on reconnect, report it here.
@@ -46069,6 +46510,10 @@ class Push extends Service {
46069
46510
  const onConnect = (packet) => {
46070
46511
  var _a, _b;
46071
46512
  cleanup();
46513
+ if (epoch !== this.connectionEpoch) {
46514
+ reject(new SupersededError());
46515
+ return;
46516
+ }
46072
46517
  const rc = (_b = (_a = packet.reasonCode) !== null && _a !== void 0 ? _a : packet.returnCode) !== null && _b !== void 0 ? _b : 0;
46073
46518
  if (rc !== 0) {
46074
46519
  this.close();
@@ -46080,16 +46525,30 @@ class Push extends Service {
46080
46525
  };
46081
46526
  const onError = (err) => {
46082
46527
  cleanup();
46528
+ if (epoch !== this.connectionEpoch) {
46529
+ reject(new SupersededError());
46530
+ return;
46531
+ }
46083
46532
  this.close();
46084
46533
  reject(this.connectError(err, refusedReason));
46085
46534
  };
46535
+ const onClose = () => {
46536
+ if (epoch !== this.connectionEpoch) {
46537
+ cleanup();
46538
+ reject(new SupersededError());
46539
+ }
46540
+ };
46086
46541
  const cleanup = () => {
46087
- this.opening = false;
46542
+ if (epoch === this.connectionEpoch) {
46543
+ this.opening = false;
46544
+ }
46088
46545
  client.removeListener('connect', onConnect);
46089
46546
  client.removeListener('error', onError);
46547
+ client.removeListener('close', onClose);
46090
46548
  };
46091
46549
  client.on('connect', onConnect);
46092
46550
  client.on('error', onError);
46551
+ client.on('close', onClose);
46093
46552
  client.connect();
46094
46553
  });
46095
46554
  });
@@ -46111,9 +46570,10 @@ class Push extends Service {
46111
46570
  /** Fan a delivered packet out to every subscription whose filter matches. */
46112
46571
  dispatch(packet) {
46113
46572
  return __awaiter(this, void 0, void 0, function* () {
46114
- const payload = buffer.Buffer.isBuffer(packet.payload)
46573
+ const Buffer = this.Buffer;
46574
+ const payload = Buffer.isBuffer(packet.payload)
46115
46575
  ? packet.payload
46116
- : buffer.Buffer.from(packet.payload);
46576
+ : Buffer.from(packet.payload);
46117
46577
  const message = {
46118
46578
  topic: packet.topic.toString(),
46119
46579
  data: new TextDecoder().decode(payload),
@@ -46154,6 +46614,11 @@ class Push extends Service {
46154
46614
  }
46155
46615
  }
46156
46616
  }
46617
+ class SupersededError extends Error {
46618
+ constructor() {
46619
+ super('The push connection was superseded');
46620
+ }
46621
+ }
46157
46622
  /** Normalize anything thrown or passed to an error handler into an `Error`. */
46158
46623
  function toError(error) {
46159
46624
  return error instanceof Error ? error : new Error(String(error));
@@ -46172,8 +46637,7 @@ function userIdFromJwt(jwt) {
46172
46637
  return '';
46173
46638
  }
46174
46639
  try {
46175
- const json = buffer.Buffer.from(parts[1].replace(/-/g, '+').replace(/_/g, '/'), 'base64').toString('utf-8');
46176
- const payload = JSON.parse(json);
46640
+ const payload = JSON.parse(decodeBase64(parts[1].replace(/-/g, '+').replace(/_/g, '/')));
46177
46641
  return typeof payload.userId === 'string' ? payload.userId : '';
46178
46642
  }
46179
46643
  catch (_a) {
@@ -46189,13 +46653,99 @@ function userIdFromSession(session) {
46189
46653
  return '';
46190
46654
  }
46191
46655
  try {
46192
- const payload = JSON.parse(buffer.Buffer.from(session, 'base64').toString('utf-8'));
46656
+ const payload = JSON.parse(decodeBase64(session));
46193
46657
  return typeof payload.id === 'string' ? payload.id : '';
46194
46658
  }
46195
46659
  catch (_a) {
46196
46660
  return '';
46197
46661
  }
46198
46662
  }
46663
+ /** Ids in use by live connections in this page, so two Push instances never share a client id. */
46664
+ const claimedTabIds = new Set();
46665
+ /** The tab's stored id, resolved and locked once per page (see claimStoredTabId). */
46666
+ let storedTabIdClaim = null;
46667
+ /**
46668
+ * A default client id for one Push connection in this page. The first connection alive takes the
46669
+ * tab's stored id (kept in sessionStorage and locked for the page's lifetime, so it stays the same
46670
+ * across reloads and the broker's replay cursor resumes). Any connection alive at the same time
46671
+ * takes a distinct locked id instead, so simultaneous Push instances never share a client id and
46672
+ * so cannot take over each other's broker session. `fallback` is this instance's own random id.
46673
+ */
46674
+ function claimTabId(fallback) {
46675
+ return __awaiter(this, void 0, void 0, function* () {
46676
+ const stored = yield claimStoredTabId(fallback);
46677
+ if (stored !== '' && !claimedTabIds.has(stored)) {
46678
+ claimedTabIds.add(stored);
46679
+ return stored;
46680
+ }
46681
+ // The tab's id is taken by another live connection here: take a distinct, locked id without
46682
+ // touching the tab's stored cursor.
46683
+ let id = fallback;
46684
+ while (claimedTabIds.has(id)) {
46685
+ id = randomId();
46686
+ }
46687
+ const locks = typeof navigator === 'undefined' ? undefined : navigator.locks;
46688
+ if (locks) {
46689
+ yield holdTabId(locks, id);
46690
+ }
46691
+ claimedTabIds.add(id);
46692
+ return id;
46693
+ });
46694
+ }
46695
+ /** Free an id when its connection closes, so a later connection can reuse it (e.g. the stored id). */
46696
+ function releaseTabId(id) {
46697
+ claimedTabIds.delete(id);
46698
+ }
46699
+ /**
46700
+ * The tab's stored id, resolved and locked once per page: the value in sessionStorage when a lock
46701
+ * on it is free (this tab owns it), else a fresh id that is locked and stored. Without Web Locks
46702
+ * (or when locking fails) a copied id cannot be told apart from another tab's, so the page uses a
46703
+ * fresh id and leaves sessionStorage alone. '' when sessionStorage cannot be read, so the caller
46704
+ * falls back to its own id.
46705
+ */
46706
+ function claimStoredTabId(fallback) {
46707
+ storedTabIdClaim !== null && storedTabIdClaim !== void 0 ? storedTabIdClaim : (storedTabIdClaim = (() => __awaiter(this, void 0, void 0, function* () {
46708
+ const locks = typeof navigator === 'undefined' ? undefined : navigator.locks;
46709
+ if (!locks) {
46710
+ return fallback;
46711
+ }
46712
+ let stored;
46713
+ try {
46714
+ stored = window.sessionStorage.getItem(TAB_ID_KEY);
46715
+ }
46716
+ catch (_a) {
46717
+ return '';
46718
+ }
46719
+ if (stored && (yield holdTabId(locks, stored))) {
46720
+ return stored;
46721
+ }
46722
+ if (!(yield holdTabId(locks, fallback))) {
46723
+ return fallback;
46724
+ }
46725
+ try {
46726
+ window.sessionStorage.setItem(TAB_ID_KEY, fallback);
46727
+ }
46728
+ catch (_b) {
46729
+ // Not persisted, but still usable as this page's stored id for this session.
46730
+ }
46731
+ return fallback;
46732
+ }))());
46733
+ return storedTabIdClaim;
46734
+ }
46735
+ function holdTabId(locks, id) {
46736
+ return new Promise((resolve) => {
46737
+ locks
46738
+ .request(`${TAB_ID_KEY}:${id}`, { ifAvailable: true }, (lock) => {
46739
+ resolve(lock !== null);
46740
+ return lock ? new Promise(() => { }) : undefined;
46741
+ })
46742
+ .catch(() => resolve(false));
46743
+ });
46744
+ }
46745
+ /** Base64 to UTF-8 text without `buffer`, which only loads once Push connects. */
46746
+ function decodeBase64(value) {
46747
+ return new TextDecoder().decode(Uint8Array.from(atob(value), (char) => char.charCodeAt(0)));
46748
+ }
46199
46749
  /** A hex id, uuid4-like enough for a client-generated client id suffix. */
46200
46750
  function randomId() {
46201
46751
  let out = '';
@@ -46919,6 +47469,7 @@ exports.OAuthProvider = void 0;
46919
47469
  OAuthProvider["Tradeshift"] = "tradeshift";
46920
47470
  OAuthProvider["TradeshiftBox"] = "tradeshiftBox";
46921
47471
  OAuthProvider["Twitch"] = "twitch";
47472
+ OAuthProvider["Webflow"] = "webflow";
46922
47473
  OAuthProvider["Wordpress"] = "wordpress";
46923
47474
  OAuthProvider["X"] = "x";
46924
47475
  OAuthProvider["Yahoo"] = "yahoo";
@@ -47990,6 +48541,9 @@ exports.Runtime = void 0;
47990
48541
  Runtime["Pythonml311"] = "python-ml-3.11";
47991
48542
  Runtime["Pythonml312"] = "python-ml-3.12";
47992
48543
  Runtime["Pythonml313"] = "python-ml-3.13";
48544
+ Runtime["Deno121"] = "deno-1.21";
48545
+ Runtime["Deno124"] = "deno-1.24";
48546
+ Runtime["Deno135"] = "deno-1.35";
47993
48547
  Runtime["Deno140"] = "deno-1.40";
47994
48548
  Runtime["Deno146"] = "deno-1.46";
47995
48549
  Runtime["Deno20"] = "deno-2.0";
@@ -48147,6 +48701,7 @@ exports.ProjectKeyScopes = void 0;
48147
48701
  ProjectKeyScopes["WebhooksWrite"] = "webhooks.write";
48148
48702
  ProjectKeyScopes["LocaleRead"] = "locale.read";
48149
48703
  ProjectKeyScopes["AvatarsRead"] = "avatars.read";
48704
+ ProjectKeyScopes["AvatarsWrite"] = "avatars.write";
48150
48705
  ProjectKeyScopes["HealthRead"] = "health.read";
48151
48706
  ProjectKeyScopes["AssistantRead"] = "assistant.read";
48152
48707
  ProjectKeyScopes["MigrationsRead"] = "migrations.read";
@@ -48541,6 +49096,7 @@ exports.ProjectOAuthProviderId = void 0;
48541
49096
  ProjectOAuthProviderId["Tradeshift"] = "tradeshift";
48542
49097
  ProjectOAuthProviderId["TradeshiftBox"] = "tradeshiftBox";
48543
49098
  ProjectOAuthProviderId["Twitch"] = "twitch";
49099
+ ProjectOAuthProviderId["Webflow"] = "webflow";
48544
49100
  ProjectOAuthProviderId["Wordpress"] = "wordpress";
48545
49101
  ProjectOAuthProviderId["X"] = "x";
48546
49102
  ProjectOAuthProviderId["Yahoo"] = "yahoo";
@@ -48694,6 +49250,9 @@ exports.BuildRuntime = void 0;
48694
49250
  BuildRuntime["Pythonml311"] = "python-ml-3.11";
48695
49251
  BuildRuntime["Pythonml312"] = "python-ml-3.12";
48696
49252
  BuildRuntime["Pythonml313"] = "python-ml-3.13";
49253
+ BuildRuntime["Deno121"] = "deno-1.21";
49254
+ BuildRuntime["Deno124"] = "deno-1.24";
49255
+ BuildRuntime["Deno135"] = "deno-1.35";
48697
49256
  BuildRuntime["Deno140"] = "deno-1.40";
48698
49257
  BuildRuntime["Deno146"] = "deno-1.46";
48699
49258
  BuildRuntime["Deno20"] = "deno-2.0";
@@ -48816,6 +49375,7 @@ exports.UsageEventMetric = void 0;
48816
49375
  UsageEventMetric["WebhooksEventsFailed"] = "webhooks.events.failed";
48817
49376
  UsageEventMetric["AuthMethodPhone"] = "auth.method.phone";
48818
49377
  UsageEventMetric["MessagesSent"] = "messages.sent";
49378
+ UsageEventMetric["MessagesFailed"] = "messages.failed";
48819
49379
  UsageEventMetric["MessagesSmsSent"] = "messages.sms.sent";
48820
49380
  UsageEventMetric["Executions"] = "executions";
48821
49381
  UsageEventMetric["ExecutionsCompute"] = "executions.compute";
@@ -48894,6 +49454,15 @@ exports.UsageEventDimension = void 0;
48894
49454
  UsageEventDimension["SdkVersion"] = "sdkVersion";
48895
49455
  UsageEventDimension["TeamId"] = "teamId";
48896
49456
  UsageEventDimension["ResourceId"] = "resourceId";
49457
+ UsageEventDimension["Protocol"] = "protocol";
49458
+ UsageEventDimension["QueryKeys"] = "queryKeys";
49459
+ UsageEventDimension["Accept"] = "accept";
49460
+ UsageEventDimension["AcceptLanguage"] = "acceptLanguage";
49461
+ UsageEventDimension["PostalCode"] = "postalCode";
49462
+ UsageEventDimension["Latitude"] = "latitude";
49463
+ UsageEventDimension["Longitude"] = "longitude";
49464
+ UsageEventDimension["TimeZone"] = "timeZone";
49465
+ UsageEventDimension["WeatherCode"] = "weatherCode";
48897
49466
  UsageEventDimension["Isp"] = "isp";
48898
49467
  UsageEventDimension["AutonomousSystemNumber"] = "autonomousSystemNumber";
48899
49468
  UsageEventDimension["AutonomousSystemOrganization"] = "autonomousSystemOrganization";