@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/dist/esm/sdk.js CHANGED
@@ -278,7 +278,7 @@ class Client {
278
278
  'x-sdk-name': 'Console',
279
279
  'x-sdk-platform': 'console',
280
280
  'x-sdk-language': 'web',
281
- 'x-sdk-version': '1.0.0',
281
+ 'x-sdk-version': '1.0.1',
282
282
  'X-Appwrite-Response-Format': '1.6.0',
283
283
  };
284
284
  this.realtime = {
@@ -622,16 +622,6 @@ class Client {
622
622
  return response;
623
623
  });
624
624
  }
625
- redirect(method, url, headers = {}, params = {}) {
626
- return __awaiter(this, void 0, void 0, function* () {
627
- const { uri, options } = this.prepareRequest(method, url, headers, params);
628
- const response = yield fetch(uri, Object.assign(Object.assign({}, options), { redirect: 'manual' }));
629
- if (response.status !== 301 && response.status !== 302) {
630
- throw new AppwriteException('Invalid redirect', response.status);
631
- }
632
- return response.headers.get('location') || '';
633
- });
634
- }
635
625
  call(method, url, headers = {}, params = {}, responseType = 'json') {
636
626
  var _a;
637
627
  return __awaiter(this, void 0, void 0, function* () {
@@ -680,6 +670,29 @@ class Client {
680
670
  }
681
671
  Client.CHUNK_SIZE = 1024 * 1024 * 5;
682
672
 
673
+ class Service {
674
+ constructor(client) {
675
+ this.client = client;
676
+ }
677
+ static flatten(data, prefix = '') {
678
+ let output = {};
679
+ for (const [key, value] of Object.entries(data)) {
680
+ let finalKey = prefix ? prefix + '[' + key + ']' : key;
681
+ if (Array.isArray(value)) {
682
+ output = Object.assign(Object.assign({}, output), Service.flatten(value, finalKey));
683
+ }
684
+ else {
685
+ output[finalKey] = value;
686
+ }
687
+ }
688
+ return output;
689
+ }
690
+ }
691
+ /**
692
+ * The size for chunked uploads in bytes.
693
+ */
694
+ Service.CHUNK_SIZE = 5 * 1024 * 1024; // 5MB
695
+
683
696
  class Account {
684
697
  constructor(client) {
685
698
  this.client = client;
@@ -1494,14 +1507,17 @@ A user is limited to 10 active sessions at a time by default. [Learn more about
1494
1507
  payload['scopes'] = scopes;
1495
1508
  }
1496
1509
  const uri = new URL(this.client.config.endpoint + apiPath);
1497
- const apiHeaders = {
1498
- 'content-type': 'application/json',
1499
- };
1500
- const location = yield this.client.redirect('get', uri, apiHeaders, payload);
1501
- if (typeof window !== 'undefined') {
1502
- window.location.href = location;
1510
+ payload['project'] = this.client.config.project;
1511
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
1512
+ uri.searchParams.append(key, value);
1513
+ }
1514
+ if (typeof window !== 'undefined' && (window === null || window === void 0 ? void 0 : window.location)) {
1515
+ window.location.href = uri.toString();
1516
+ return;
1517
+ }
1518
+ else {
1519
+ return uri.toString();
1503
1520
  }
1504
- return location.toString();
1505
1521
  });
1506
1522
  }
1507
1523
  /**
@@ -1861,14 +1877,17 @@ A user is limited to 10 active sessions at a time by default. [Learn more about
1861
1877
  payload['scopes'] = scopes;
1862
1878
  }
1863
1879
  const uri = new URL(this.client.config.endpoint + apiPath);
1864
- const apiHeaders = {
1865
- 'content-type': 'application/json',
1866
- };
1867
- const location = yield this.client.redirect('get', uri, apiHeaders, payload);
1868
- if (typeof window !== 'undefined') {
1869
- window.location.href = location;
1880
+ payload['project'] = this.client.config.project;
1881
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
1882
+ uri.searchParams.append(key, value);
1883
+ }
1884
+ if (typeof window !== 'undefined' && (window === null || window === void 0 ? void 0 : window.location)) {
1885
+ window.location.href = uri.toString();
1886
+ return;
1887
+ }
1888
+ else {
1889
+ return uri.toString();
1870
1890
  }
1871
- return location.toString();
1872
1891
  });
1873
1892
  }
1874
1893
  /**
@@ -2057,6 +2076,10 @@ When one dimension is specified and the other is 0, the image is scaled with pre
2057
2076
  }
2058
2077
  const uri = new URL(this.client.config.endpoint + apiPath);
2059
2078
  payload['project'] = this.client.config.project;
2079
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
2080
+ uri.searchParams.append(key, value);
2081
+ }
2082
+ payload['project'] = this.client.config.project;
2060
2083
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
2061
2084
  uri.searchParams.append(key, value);
2062
2085
  }
@@ -2094,6 +2117,10 @@ When one dimension is specified and the other is 0, the image is scaled with pre
2094
2117
  }
2095
2118
  const uri = new URL(this.client.config.endpoint + apiPath);
2096
2119
  payload['project'] = this.client.config.project;
2120
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
2121
+ uri.searchParams.append(key, value);
2122
+ }
2123
+ payload['project'] = this.client.config.project;
2097
2124
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
2098
2125
  uri.searchParams.append(key, value);
2099
2126
  }
@@ -2121,6 +2148,10 @@ This endpoint does not follow HTTP redirects.
2121
2148
  }
2122
2149
  const uri = new URL(this.client.config.endpoint + apiPath);
2123
2150
  payload['project'] = this.client.config.project;
2151
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
2152
+ uri.searchParams.append(key, value);
2153
+ }
2154
+ payload['project'] = this.client.config.project;
2124
2155
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
2125
2156
  uri.searchParams.append(key, value);
2126
2157
  }
@@ -2158,6 +2189,10 @@ When one dimension is specified and the other is 0, the image is scaled with pre
2158
2189
  }
2159
2190
  const uri = new URL(this.client.config.endpoint + apiPath);
2160
2191
  payload['project'] = this.client.config.project;
2192
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
2193
+ uri.searchParams.append(key, value);
2194
+ }
2195
+ payload['project'] = this.client.config.project;
2161
2196
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
2162
2197
  uri.searchParams.append(key, value);
2163
2198
  }
@@ -2195,6 +2230,10 @@ This endpoint does not follow HTTP redirects.
2195
2230
  }
2196
2231
  const uri = new URL(this.client.config.endpoint + apiPath);
2197
2232
  payload['project'] = this.client.config.project;
2233
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
2234
+ uri.searchParams.append(key, value);
2235
+ }
2236
+ payload['project'] = this.client.config.project;
2198
2237
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
2199
2238
  uri.searchParams.append(key, value);
2200
2239
  }
@@ -2234,6 +2273,10 @@ When one dimension is specified and the other is 0, the image is scaled with pre
2234
2273
  }
2235
2274
  const uri = new URL(this.client.config.endpoint + apiPath);
2236
2275
  payload['project'] = this.client.config.project;
2276
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
2277
+ uri.searchParams.append(key, value);
2278
+ }
2279
+ payload['project'] = this.client.config.project;
2237
2280
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
2238
2281
  uri.searchParams.append(key, value);
2239
2282
  }
@@ -2272,6 +2315,10 @@ When one dimension is specified and the other is 0, the image is scaled with pre
2272
2315
  }
2273
2316
  const uri = new URL(this.client.config.endpoint + apiPath);
2274
2317
  payload['project'] = this.client.config.project;
2318
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
2319
+ uri.searchParams.append(key, value);
2320
+ }
2321
+ payload['project'] = this.client.config.project;
2275
2322
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
2276
2323
  uri.searchParams.append(key, value);
2277
2324
  }
@@ -4925,6 +4972,10 @@ Use the "command" param to set the entrypoint used to execute your cod
4925
4972
  const payload = {};
4926
4973
  const uri = new URL(this.client.config.endpoint + apiPath);
4927
4974
  payload['project'] = this.client.config.project;
4975
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
4976
+ uri.searchParams.append(key, value);
4977
+ }
4978
+ payload['project'] = this.client.config.project;
4928
4979
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
4929
4980
  uri.searchParams.append(key, value);
4930
4981
  }
@@ -10926,6 +10977,10 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk
10926
10977
  const payload = {};
10927
10978
  const uri = new URL(this.client.config.endpoint + apiPath);
10928
10979
  payload['project'] = this.client.config.project;
10980
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
10981
+ uri.searchParams.append(key, value);
10982
+ }
10983
+ payload['project'] = this.client.config.project;
10929
10984
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
10930
10985
  uri.searchParams.append(key, value);
10931
10986
  }
@@ -10996,6 +11051,10 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk
10996
11051
  }
10997
11052
  const uri = new URL(this.client.config.endpoint + apiPath);
10998
11053
  payload['project'] = this.client.config.project;
11054
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
11055
+ uri.searchParams.append(key, value);
11056
+ }
11057
+ payload['project'] = this.client.config.project;
10999
11058
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
11000
11059
  uri.searchParams.append(key, value);
11001
11060
  }
@@ -11022,6 +11081,10 @@ If you're creating a new file using one of the Appwrite SDKs, all the chunk
11022
11081
  const payload = {};
11023
11082
  const uri = new URL(this.client.config.endpoint + apiPath);
11024
11083
  payload['project'] = this.client.config.project;
11084
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
11085
+ uri.searchParams.append(key, value);
11086
+ }
11087
+ payload['project'] = this.client.config.project;
11025
11088
  for (const [key, value] of Object.entries(Client.flatten(payload))) {
11026
11089
  uri.searchParams.append(key, value);
11027
11090
  }