@appwrite.io/console 1.0.0 → 1.0.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.
package/README.md CHANGED
@@ -33,7 +33,7 @@ import { Client, Account } from "@appwrite.io/console";
33
33
  To install with a CDN (content delivery network) add the following scripts to the bottom of your <body> tag, but before you use any Appwrite services:
34
34
 
35
35
  ```html
36
- <script src="https://cdn.jsdelivr.net/npm/@appwrite.io/console@1.0.0"></script>
36
+ <script src="https://cdn.jsdelivr.net/npm/@appwrite.io/console@1.0.1"></script>
37
37
  ```
38
38
 
39
39
 
package/dist/cjs/sdk.js CHANGED
@@ -280,7 +280,7 @@ class Client {
280
280
  'x-sdk-name': 'Console',
281
281
  'x-sdk-platform': 'console',
282
282
  'x-sdk-language': 'web',
283
- 'x-sdk-version': '1.0.0',
283
+ 'x-sdk-version': '1.0.1',
284
284
  'X-Appwrite-Response-Format': '1.6.0',
285
285
  };
286
286
  this.realtime = {
@@ -624,16 +624,6 @@ class Client {
624
624
  return response;
625
625
  });
626
626
  }
627
- redirect(method, url, headers = {}, params = {}) {
628
- return __awaiter(this, void 0, void 0, function* () {
629
- const { uri, options } = this.prepareRequest(method, url, headers, params);
630
- const response = yield fetch(uri, Object.assign(Object.assign({}, options), { redirect: 'manual' }));
631
- if (response.status !== 301 && response.status !== 302) {
632
- throw new AppwriteException('Invalid redirect', response.status);
633
- }
634
- return response.headers.get('location') || '';
635
- });
636
- }
637
627
  call(method, url, headers = {}, params = {}, responseType = 'json') {
638
628
  var _a;
639
629
  return __awaiter(this, void 0, void 0, function* () {
@@ -682,6 +672,29 @@ class Client {
682
672
  }
683
673
  Client.CHUNK_SIZE = 1024 * 1024 * 5;
684
674
 
675
+ class Service {
676
+ constructor(client) {
677
+ this.client = client;
678
+ }
679
+ static flatten(data, prefix = '') {
680
+ let output = {};
681
+ for (const [key, value] of Object.entries(data)) {
682
+ let finalKey = prefix ? prefix + '[' + key + ']' : key;
683
+ if (Array.isArray(value)) {
684
+ output = Object.assign(Object.assign({}, output), Service.flatten(value, finalKey));
685
+ }
686
+ else {
687
+ output[finalKey] = value;
688
+ }
689
+ }
690
+ return output;
691
+ }
692
+ }
693
+ /**
694
+ * The size for chunked uploads in bytes.
695
+ */
696
+ Service.CHUNK_SIZE = 5 * 1024 * 1024; // 5MB
697
+
685
698
  class Account {
686
699
  constructor(client) {
687
700
  this.client = client;
@@ -1496,14 +1509,17 @@ A user is limited to 10 active sessions at a time by default. [Learn more about
1496
1509
  payload['scopes'] = scopes;
1497
1510
  }
1498
1511
  const uri = new URL(this.client.config.endpoint + apiPath);
1499
- const apiHeaders = {
1500
- 'content-type': 'application/json',
1501
- };
1502
- const location = yield this.client.redirect('get', uri, apiHeaders, payload);
1503
- if (typeof window !== 'undefined') {
1504
- window.location.href = location;
1512
+ payload['project'] = this.client.config.project;
1513
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
1514
+ uri.searchParams.append(key, value);
1515
+ }
1516
+ if (typeof window !== 'undefined' && (window === null || window === void 0 ? void 0 : window.location)) {
1517
+ window.location.href = uri.toString();
1518
+ return;
1519
+ }
1520
+ else {
1521
+ return uri.toString();
1505
1522
  }
1506
- return location.toString();
1507
1523
  });
1508
1524
  }
1509
1525
  /**
@@ -1863,14 +1879,17 @@ A user is limited to 10 active sessions at a time by default. [Learn more about
1863
1879
  payload['scopes'] = scopes;
1864
1880
  }
1865
1881
  const uri = new URL(this.client.config.endpoint + apiPath);
1866
- const apiHeaders = {
1867
- 'content-type': 'application/json',
1868
- };
1869
- const location = yield this.client.redirect('get', uri, apiHeaders, payload);
1870
- if (typeof window !== 'undefined') {
1871
- window.location.href = location;
1882
+ payload['project'] = this.client.config.project;
1883
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
1884
+ uri.searchParams.append(key, value);
1885
+ }
1886
+ if (typeof window !== 'undefined' && (window === null || window === void 0 ? void 0 : window.location)) {
1887
+ window.location.href = uri.toString();
1888
+ return;
1889
+ }
1890
+ else {
1891
+ return uri.toString();
1872
1892
  }
1873
- return location.toString();
1874
1893
  });
1875
1894
  }
1876
1895
  /**
@@ -2059,6 +2078,10 @@ When one dimension is specified and the other is 0, the image is scaled with pre
2059
2078
  }
2060
2079
  const uri = new URL(this.client.config.endpoint + apiPath);
2061
2080
  payload['project'] = this.client.config.project;
2081
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
2082
+ uri.searchParams.append(key, value);
2083
+ }
2084
+ payload['project'] = this.client.config.project;
2062
2085
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
2063
2086
  uri.searchParams.append(key, value);
2064
2087
  }
@@ -2096,6 +2119,10 @@ When one dimension is specified and the other is 0, the image is scaled with pre
2096
2119
  }
2097
2120
  const uri = new URL(this.client.config.endpoint + apiPath);
2098
2121
  payload['project'] = this.client.config.project;
2122
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
2123
+ uri.searchParams.append(key, value);
2124
+ }
2125
+ payload['project'] = this.client.config.project;
2099
2126
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
2100
2127
  uri.searchParams.append(key, value);
2101
2128
  }
@@ -2123,6 +2150,10 @@ This endpoint does not follow HTTP redirects.
2123
2150
  }
2124
2151
  const uri = new URL(this.client.config.endpoint + apiPath);
2125
2152
  payload['project'] = this.client.config.project;
2153
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
2154
+ uri.searchParams.append(key, value);
2155
+ }
2156
+ payload['project'] = this.client.config.project;
2126
2157
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
2127
2158
  uri.searchParams.append(key, value);
2128
2159
  }
@@ -2160,6 +2191,10 @@ When one dimension is specified and the other is 0, the image is scaled with pre
2160
2191
  }
2161
2192
  const uri = new URL(this.client.config.endpoint + apiPath);
2162
2193
  payload['project'] = this.client.config.project;
2194
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
2195
+ uri.searchParams.append(key, value);
2196
+ }
2197
+ payload['project'] = this.client.config.project;
2163
2198
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
2164
2199
  uri.searchParams.append(key, value);
2165
2200
  }
@@ -2197,6 +2232,10 @@ This endpoint does not follow HTTP redirects.
2197
2232
  }
2198
2233
  const uri = new URL(this.client.config.endpoint + apiPath);
2199
2234
  payload['project'] = this.client.config.project;
2235
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
2236
+ uri.searchParams.append(key, value);
2237
+ }
2238
+ payload['project'] = this.client.config.project;
2200
2239
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
2201
2240
  uri.searchParams.append(key, value);
2202
2241
  }
@@ -2236,6 +2275,10 @@ When one dimension is specified and the other is 0, the image is scaled with pre
2236
2275
  }
2237
2276
  const uri = new URL(this.client.config.endpoint + apiPath);
2238
2277
  payload['project'] = this.client.config.project;
2278
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
2279
+ uri.searchParams.append(key, value);
2280
+ }
2281
+ payload['project'] = this.client.config.project;
2239
2282
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
2240
2283
  uri.searchParams.append(key, value);
2241
2284
  }
@@ -2274,6 +2317,10 @@ When one dimension is specified and the other is 0, the image is scaled with pre
2274
2317
  }
2275
2318
  const uri = new URL(this.client.config.endpoint + apiPath);
2276
2319
  payload['project'] = this.client.config.project;
2320
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
2321
+ uri.searchParams.append(key, value);
2322
+ }
2323
+ payload['project'] = this.client.config.project;
2277
2324
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
2278
2325
  uri.searchParams.append(key, value);
2279
2326
  }
@@ -4927,6 +4974,10 @@ Use the &quot;command&quot; param to set the entrypoint used to execute your cod
4927
4974
  const payload = {};
4928
4975
  const uri = new URL(this.client.config.endpoint + apiPath);
4929
4976
  payload['project'] = this.client.config.project;
4977
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
4978
+ uri.searchParams.append(key, value);
4979
+ }
4980
+ payload['project'] = this.client.config.project;
4930
4981
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
4931
4982
  uri.searchParams.append(key, value);
4932
4983
  }
@@ -10928,6 +10979,10 @@ If you&#039;re creating a new file using one of the Appwrite SDKs, all the chunk
10928
10979
  const payload = {};
10929
10980
  const uri = new URL(this.client.config.endpoint + apiPath);
10930
10981
  payload['project'] = this.client.config.project;
10982
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
10983
+ uri.searchParams.append(key, value);
10984
+ }
10985
+ payload['project'] = this.client.config.project;
10931
10986
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
10932
10987
  uri.searchParams.append(key, value);
10933
10988
  }
@@ -10998,6 +11053,10 @@ If you&#039;re creating a new file using one of the Appwrite SDKs, all the chunk
10998
11053
  }
10999
11054
  const uri = new URL(this.client.config.endpoint + apiPath);
11000
11055
  payload['project'] = this.client.config.project;
11056
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
11057
+ uri.searchParams.append(key, value);
11058
+ }
11059
+ payload['project'] = this.client.config.project;
11001
11060
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
11002
11061
  uri.searchParams.append(key, value);
11003
11062
  }
@@ -11024,6 +11083,10 @@ If you&#039;re creating a new file using one of the Appwrite SDKs, all the chunk
11024
11083
  const payload = {};
11025
11084
  const uri = new URL(this.client.config.endpoint + apiPath);
11026
11085
  payload['project'] = this.client.config.project;
11086
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
11087
+ uri.searchParams.append(key, value);
11088
+ }
11089
+ payload['project'] = this.client.config.project;
11027
11090
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
11028
11091
  uri.searchParams.append(key, value);
11029
11092
  }