glitch-javascript-sdk 0.0.1 → 0.0.3

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/index.js CHANGED
@@ -1,56 +1,3 @@
1
- /******************************************************************************
2
- Copyright (c) Microsoft Corporation.
3
-
4
- Permission to use, copy, modify, and/or distribute this software for any
5
- purpose with or without fee is hereby granted.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
- PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */
15
-
16
- function __awaiter(thisArg, _arguments, P, generator) {
17
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
- return new (P || (P = Promise))(function (resolve, reject) {
19
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23
- });
24
- }
25
-
26
- function __generator(thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
33
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- }
53
-
54
1
  function getDefaultExportFromCjs (x) {
55
2
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
56
3
  }
@@ -4254,30 +4201,30 @@ var _polyfillNode_util = {
4254
4201
  };
4255
4202
 
4256
4203
  var _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({
4257
- __proto__: null,
4258
- _extend: _extend,
4259
- debuglog: debuglog,
4260
- default: _polyfillNode_util,
4261
- deprecate: deprecate,
4262
- format: format$1,
4263
- inherits: inherits$1,
4264
- inspect: inspect$1,
4265
- isArray: isArray$1,
4266
- isBoolean: isBoolean,
4267
- isBuffer: isBuffer,
4268
- isDate: isDate,
4269
- isError: isError,
4270
- isFunction: isFunction,
4271
- isNull: isNull,
4272
- isNullOrUndefined: isNullOrUndefined,
4273
- isNumber: isNumber,
4274
- isObject: isObject,
4275
- isPrimitive: isPrimitive,
4276
- isRegExp: isRegExp,
4277
- isString: isString,
4278
- isSymbol: isSymbol,
4279
- isUndefined: isUndefined,
4280
- log: log
4204
+ __proto__: null,
4205
+ _extend: _extend,
4206
+ debuglog: debuglog,
4207
+ default: _polyfillNode_util,
4208
+ deprecate: deprecate,
4209
+ format: format$1,
4210
+ inherits: inherits$1,
4211
+ inspect: inspect$1,
4212
+ isArray: isArray$1,
4213
+ isBoolean: isBoolean,
4214
+ isBuffer: isBuffer,
4215
+ isDate: isDate,
4216
+ isError: isError,
4217
+ isFunction: isFunction,
4218
+ isNull: isNull,
4219
+ isNullOrUndefined: isNullOrUndefined,
4220
+ isNumber: isNumber,
4221
+ isObject: isObject,
4222
+ isPrimitive: isPrimitive,
4223
+ isRegExp: isRegExp,
4224
+ isString: isString,
4225
+ isSymbol: isSymbol,
4226
+ isUndefined: isUndefined,
4227
+ log: log
4281
4228
  });
4282
4229
 
4283
4230
  var domain;
@@ -6645,14 +6592,14 @@ Stream.prototype.pipe = function(dest, options) {
6645
6592
  };
6646
6593
 
6647
6594
  var _polyfillNode_stream = /*#__PURE__*/Object.freeze({
6648
- __proto__: null,
6649
- Duplex: Duplex,
6650
- PassThrough: PassThrough,
6651
- Readable: Readable,
6652
- Stream: Stream,
6653
- Transform: Transform,
6654
- Writable: Writable,
6655
- default: Stream
6595
+ __proto__: null,
6596
+ Duplex: Duplex,
6597
+ PassThrough: PassThrough,
6598
+ Readable: Readable,
6599
+ Stream: Stream,
6600
+ Transform: Transform,
6601
+ Writable: Writable,
6602
+ default: Stream
6656
6603
  });
6657
6604
 
6658
6605
  var rStates = {
@@ -8311,16 +8258,16 @@ function parseHost(self) {
8311
8258
  }
8312
8259
 
8313
8260
  var _polyfillNode_url$1 = /*#__PURE__*/Object.freeze({
8314
- __proto__: null,
8315
- URL: URL,
8316
- URLSearchParams: URLSearchParams,
8317
- Url: Url,
8318
- default: _polyfillNode_url,
8319
- fileURLToPath: urlFileURLToPath,
8320
- format: urlFormat,
8321
- parse: urlParse,
8322
- resolve: urlResolve,
8323
- resolveObject: urlResolveObject
8261
+ __proto__: null,
8262
+ URL: URL,
8263
+ URLSearchParams: URLSearchParams,
8264
+ Url: Url,
8265
+ default: _polyfillNode_url,
8266
+ fileURLToPath: urlFileURLToPath,
8267
+ format: urlFormat,
8268
+ parse: urlParse,
8269
+ resolve: urlResolve,
8270
+ resolveObject: urlResolveObject
8324
8271
  });
8325
8272
 
8326
8273
  function request$1(opts, cb) {
@@ -8460,13 +8407,13 @@ var _polyfillNode_http = {
8460
8407
  };
8461
8408
 
8462
8409
  var _polyfillNode_http$1 = /*#__PURE__*/Object.freeze({
8463
- __proto__: null,
8464
- Agent: Agent$1,
8465
- METHODS: METHODS$1,
8466
- STATUS_CODES: STATUS_CODES$1,
8467
- default: _polyfillNode_http,
8468
- get: get$1,
8469
- request: request$1
8410
+ __proto__: null,
8411
+ Agent: Agent$1,
8412
+ METHODS: METHODS$1,
8413
+ STATUS_CODES: STATUS_CODES$1,
8414
+ default: _polyfillNode_http,
8415
+ get: get$1,
8416
+ request: request$1
8470
8417
  });
8471
8418
 
8472
8419
  var require$$3 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_http$1);
@@ -8608,13 +8555,13 @@ var _polyfillNode_https = {
8608
8555
  };
8609
8556
 
8610
8557
  var _polyfillNode_https$1 = /*#__PURE__*/Object.freeze({
8611
- __proto__: null,
8612
- Agent: Agent,
8613
- METHODS: METHODS,
8614
- STATUS_CODES: STATUS_CODES,
8615
- default: _polyfillNode_https,
8616
- get: get,
8617
- request: request
8558
+ __proto__: null,
8559
+ Agent: Agent,
8560
+ METHODS: METHODS,
8561
+ STATUS_CODES: STATUS_CODES,
8562
+ default: _polyfillNode_https,
8563
+ get: get,
8564
+ request: request
8618
8565
  });
8619
8566
 
8620
8567
  var require$$4$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_https$1);
@@ -9089,23 +9036,23 @@ function ifError(err) {
9089
9036
  }
9090
9037
 
9091
9038
  var _polyfillNode_assert = /*#__PURE__*/Object.freeze({
9092
- __proto__: null,
9093
- AssertionError: AssertionError,
9094
- assert: ok,
9095
- deepEqual: deepEqual,
9096
- deepStrictEqual: deepStrictEqual,
9097
- default: assert$1,
9098
- doesNotThrow: doesNotThrow,
9099
- equal: equal,
9100
- fail: fail,
9101
- ifError: ifError,
9102
- notDeepEqual: notDeepEqual,
9103
- notDeepStrictEqual: notDeepStrictEqual,
9104
- notEqual: notEqual,
9105
- notStrictEqual: notStrictEqual,
9106
- ok: ok,
9107
- strictEqual: strictEqual,
9108
- throws: throws
9039
+ __proto__: null,
9040
+ AssertionError: AssertionError,
9041
+ assert: ok,
9042
+ deepEqual: deepEqual,
9043
+ deepStrictEqual: deepStrictEqual,
9044
+ default: assert$1,
9045
+ doesNotThrow: doesNotThrow,
9046
+ equal: equal,
9047
+ fail: fail,
9048
+ ifError: ifError,
9049
+ notDeepEqual: notDeepEqual,
9050
+ notDeepStrictEqual: notDeepStrictEqual,
9051
+ notEqual: notEqual,
9052
+ notStrictEqual: notStrictEqual,
9053
+ ok: ok,
9054
+ strictEqual: strictEqual,
9055
+ throws: throws
9109
9056
  });
9110
9057
 
9111
9058
  var require$$4 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_assert);
@@ -15335,43 +15282,43 @@ Zlib$1.prototype._error = function(status) {
15335
15282
  };
15336
15283
 
15337
15284
  var _binding = /*#__PURE__*/Object.freeze({
15338
- __proto__: null,
15339
- DEFLATE: DEFLATE,
15340
- DEFLATERAW: DEFLATERAW,
15341
- GUNZIP: GUNZIP,
15342
- GZIP: GZIP,
15343
- INFLATE: INFLATE,
15344
- INFLATERAW: INFLATERAW,
15345
- NONE: NONE,
15346
- UNZIP: UNZIP,
15347
- Z_BEST_COMPRESSION: Z_BEST_COMPRESSION,
15348
- Z_BEST_SPEED: Z_BEST_SPEED,
15349
- Z_BINARY: Z_BINARY,
15350
- Z_BLOCK: Z_BLOCK,
15351
- Z_BUF_ERROR: Z_BUF_ERROR,
15352
- Z_DATA_ERROR: Z_DATA_ERROR,
15353
- Z_DEFAULT_COMPRESSION: Z_DEFAULT_COMPRESSION,
15354
- Z_DEFAULT_STRATEGY: Z_DEFAULT_STRATEGY,
15355
- Z_DEFLATED: Z_DEFLATED,
15356
- Z_ERRNO: Z_ERRNO,
15357
- Z_FILTERED: Z_FILTERED,
15358
- Z_FINISH: Z_FINISH,
15359
- Z_FIXED: Z_FIXED,
15360
- Z_FULL_FLUSH: Z_FULL_FLUSH,
15361
- Z_HUFFMAN_ONLY: Z_HUFFMAN_ONLY,
15362
- Z_NEED_DICT: Z_NEED_DICT,
15363
- Z_NO_COMPRESSION: Z_NO_COMPRESSION,
15364
- Z_NO_FLUSH: Z_NO_FLUSH,
15365
- Z_OK: Z_OK,
15366
- Z_PARTIAL_FLUSH: Z_PARTIAL_FLUSH,
15367
- Z_RLE: Z_RLE,
15368
- Z_STREAM_END: Z_STREAM_END,
15369
- Z_STREAM_ERROR: Z_STREAM_ERROR,
15370
- Z_SYNC_FLUSH: Z_SYNC_FLUSH,
15371
- Z_TEXT: Z_TEXT,
15372
- Z_TREES: Z_TREES,
15373
- Z_UNKNOWN: Z_UNKNOWN,
15374
- Zlib: Zlib$1
15285
+ __proto__: null,
15286
+ DEFLATE: DEFLATE,
15287
+ DEFLATERAW: DEFLATERAW,
15288
+ GUNZIP: GUNZIP,
15289
+ GZIP: GZIP,
15290
+ INFLATE: INFLATE,
15291
+ INFLATERAW: INFLATERAW,
15292
+ NONE: NONE,
15293
+ UNZIP: UNZIP,
15294
+ Z_BEST_COMPRESSION: Z_BEST_COMPRESSION,
15295
+ Z_BEST_SPEED: Z_BEST_SPEED,
15296
+ Z_BINARY: Z_BINARY,
15297
+ Z_BLOCK: Z_BLOCK,
15298
+ Z_BUF_ERROR: Z_BUF_ERROR,
15299
+ Z_DATA_ERROR: Z_DATA_ERROR,
15300
+ Z_DEFAULT_COMPRESSION: Z_DEFAULT_COMPRESSION,
15301
+ Z_DEFAULT_STRATEGY: Z_DEFAULT_STRATEGY,
15302
+ Z_DEFLATED: Z_DEFLATED,
15303
+ Z_ERRNO: Z_ERRNO,
15304
+ Z_FILTERED: Z_FILTERED,
15305
+ Z_FINISH: Z_FINISH,
15306
+ Z_FIXED: Z_FIXED,
15307
+ Z_FULL_FLUSH: Z_FULL_FLUSH,
15308
+ Z_HUFFMAN_ONLY: Z_HUFFMAN_ONLY,
15309
+ Z_NEED_DICT: Z_NEED_DICT,
15310
+ Z_NO_COMPRESSION: Z_NO_COMPRESSION,
15311
+ Z_NO_FLUSH: Z_NO_FLUSH,
15312
+ Z_OK: Z_OK,
15313
+ Z_PARTIAL_FLUSH: Z_PARTIAL_FLUSH,
15314
+ Z_RLE: Z_RLE,
15315
+ Z_STREAM_END: Z_STREAM_END,
15316
+ Z_STREAM_ERROR: Z_STREAM_ERROR,
15317
+ Z_SYNC_FLUSH: Z_SYNC_FLUSH,
15318
+ Z_TEXT: Z_TEXT,
15319
+ Z_TREES: Z_TREES,
15320
+ Z_UNKNOWN: Z_UNKNOWN,
15321
+ Zlib: Zlib$1
15375
15322
  });
15376
15323
 
15377
15324
  function assert (a, msg) {
@@ -15987,38 +15934,38 @@ var _polyfillNode_zlib = {
15987
15934
  };
15988
15935
 
15989
15936
  var _polyfillNode_zlib$1 = /*#__PURE__*/Object.freeze({
15990
- __proto__: null,
15991
- Deflate: Deflate,
15992
- DeflateRaw: DeflateRaw,
15993
- Gunzip: Gunzip,
15994
- Gzip: Gzip,
15995
- Inflate: Inflate,
15996
- InflateRaw: InflateRaw,
15997
- Unzip: Unzip,
15998
- Zlib: Zlib,
15999
- codes: codes,
16000
- createDeflate: createDeflate,
16001
- createDeflateRaw: createDeflateRaw,
16002
- createGunzip: createGunzip,
16003
- createGzip: createGzip,
16004
- createInflate: createInflate,
16005
- createInflateRaw: createInflateRaw,
16006
- createUnzip: createUnzip,
16007
- default: _polyfillNode_zlib,
16008
- deflate: deflate,
16009
- deflateRaw: deflateRaw,
16010
- deflateRawSync: deflateRawSync,
16011
- deflateSync: deflateSync,
16012
- gunzip: gunzip,
16013
- gunzipSync: gunzipSync,
16014
- gzip: gzip,
16015
- gzipSync: gzipSync,
16016
- inflate: inflate,
16017
- inflateRaw: inflateRaw,
16018
- inflateRawSync: inflateRawSync,
16019
- inflateSync: inflateSync,
16020
- unzip: unzip,
16021
- unzipSync: unzipSync
15937
+ __proto__: null,
15938
+ Deflate: Deflate,
15939
+ DeflateRaw: DeflateRaw,
15940
+ Gunzip: Gunzip,
15941
+ Gzip: Gzip,
15942
+ Inflate: Inflate,
15943
+ InflateRaw: InflateRaw,
15944
+ Unzip: Unzip,
15945
+ Zlib: Zlib,
15946
+ codes: codes,
15947
+ createDeflate: createDeflate,
15948
+ createDeflateRaw: createDeflateRaw,
15949
+ createGunzip: createGunzip,
15950
+ createGzip: createGzip,
15951
+ createInflate: createInflate,
15952
+ createInflateRaw: createInflateRaw,
15953
+ createUnzip: createUnzip,
15954
+ default: _polyfillNode_zlib,
15955
+ deflate: deflate,
15956
+ deflateRaw: deflateRaw,
15957
+ deflateRawSync: deflateRawSync,
15958
+ deflateSync: deflateSync,
15959
+ gunzip: gunzip,
15960
+ gunzipSync: gunzipSync,
15961
+ gzip: gzip,
15962
+ gzipSync: gzipSync,
15963
+ inflate: inflate,
15964
+ inflateRaw: inflateRaw,
15965
+ inflateRawSync: inflateRawSync,
15966
+ inflateSync: inflateSync,
15967
+ unzip: unzip,
15968
+ unzipSync: unzipSync
16022
15969
  });
16023
15970
 
16024
15971
  var require$$8 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_zlib$1);
@@ -17040,18 +16987,18 @@ var substr = 'ab'.substr(-1) === 'b' ?
17040
16987
  ;
17041
16988
 
17042
16989
  var _polyfillNode_path$1 = /*#__PURE__*/Object.freeze({
17043
- __proto__: null,
17044
- basename: basename,
17045
- default: _polyfillNode_path,
17046
- delimiter: delimiter,
17047
- dirname: dirname,
17048
- extname: extname,
17049
- isAbsolute: isAbsolute,
17050
- join: join,
17051
- normalize: normalize,
17052
- relative: relative,
17053
- resolve: resolve,
17054
- sep: sep
16990
+ __proto__: null,
16991
+ basename: basename,
16992
+ default: _polyfillNode_path,
16993
+ delimiter: delimiter,
16994
+ dirname: dirname,
16995
+ extname: extname,
16996
+ isAbsolute: isAbsolute,
16997
+ join: join,
16998
+ normalize: normalize,
16999
+ relative: relative,
17000
+ resolve: resolve,
17001
+ sep: sep
17055
17002
  });
17056
17003
 
17057
17004
  var require$$2 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_path$1);
@@ -17059,8 +17006,8 @@ var require$$2 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_path$1);
17059
17006
  var _polyfillNode_fs = {};
17060
17007
 
17061
17008
  var _polyfillNode_fs$1 = /*#__PURE__*/Object.freeze({
17062
- __proto__: null,
17063
- default: _polyfillNode_fs
17009
+ __proto__: null,
17010
+ default: _polyfillNode_fs
17064
17011
  });
17065
17012
 
17066
17013
  var require$$6 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_fs$1);
@@ -29873,79 +29820,60 @@ var Requests = /** @class */ (function () {
29873
29820
  function Requests(config) {
29874
29821
  this.config = config;
29875
29822
  }
29823
+ /**
29824
+ * Sets the configuration of the system.
29825
+ *
29826
+ * @param config Config The config class.
29827
+ */
29876
29828
  Requests.setConfig = function (config) {
29877
29829
  this.baseUrl = config.baseUrl;
29878
29830
  this.authToken = config.authToken;
29879
29831
  };
29832
+ /**
29833
+ * Sets the base url of the API.
29834
+ *
29835
+ * @param url The url to of the API.
29836
+ */
29880
29837
  Requests.setBaseUrl = function (url) {
29881
29838
  this.baseUrl = url;
29882
29839
  };
29840
+ /**
29841
+ * Sets the JSON Web token
29842
+ *
29843
+ * @param token
29844
+ */
29883
29845
  Requests.setAuthToken = function (token) {
29884
29846
  this.authToken = token;
29885
29847
  };
29886
29848
  Requests.request = function (method, url, data) {
29887
- var _a, _b;
29888
- return __awaiter(this, void 0, void 0, function () {
29889
- var response, error_1, message;
29890
- return __generator(this, function (_c) {
29891
- switch (_c.label) {
29892
- case 0:
29893
- _c.trys.push([0, 2, , 3]);
29894
- return [4 /*yield*/, axios({
29895
- method: method,
29896
- url: "".concat(this.baseUrl).concat(url),
29897
- data: data,
29898
- headers: {
29899
- Authorization: "Bearer ".concat(this.authToken),
29900
- 'Content-Type': 'application/json',
29901
- },
29902
- })];
29903
- case 1:
29904
- response = _c.sent();
29905
- return [2 /*return*/, {
29906
- data: response.data,
29907
- success: true,
29908
- }];
29909
- case 2:
29910
- error_1 = _c.sent();
29911
- message = ((_b = (_a = error_1.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) || 'An error occurred';
29912
- return [2 /*return*/, {
29913
- data: null,
29914
- success: false,
29915
- message: message,
29916
- }];
29917
- case 3: return [2 /*return*/];
29918
- }
29919
- });
29849
+ var axiosPromise = axios({
29850
+ method: method,
29851
+ url: "".concat(this.baseUrl).concat(url),
29852
+ data: data,
29853
+ headers: {
29854
+ Authorization: "Bearer ".concat(this.authToken),
29855
+ 'Content-Type': 'application/json',
29856
+ },
29920
29857
  });
29858
+ return axiosPromise;
29921
29859
  };
29860
+ /**
29861
+ * Calls a GET request to the url endpoint.
29862
+ *
29863
+ * @param url
29864
+ * @returns
29865
+ */
29922
29866
  Requests.get = function (url) {
29923
- return __awaiter(this, void 0, void 0, function () {
29924
- return __generator(this, function (_a) {
29925
- return [2 /*return*/, this.request('GET', url)];
29926
- });
29927
- });
29867
+ return this.request('GET', url);
29928
29868
  };
29929
29869
  Requests.post = function (url, data) {
29930
- return __awaiter(this, void 0, void 0, function () {
29931
- return __generator(this, function (_a) {
29932
- return [2 /*return*/, this.request('POST', url, data)];
29933
- });
29934
- });
29870
+ return this.request('POST', url, data);
29935
29871
  };
29936
29872
  Requests.put = function (url, data) {
29937
- return __awaiter(this, void 0, void 0, function () {
29938
- return __generator(this, function (_a) {
29939
- return [2 /*return*/, this.request('PUT', url, data)];
29940
- });
29941
- });
29873
+ return this.request('PUT', url, data);
29942
29874
  };
29943
29875
  Requests.delete = function (url) {
29944
- return __awaiter(this, void 0, void 0, function () {
29945
- return __generator(this, function (_a) {
29946
- return [2 /*return*/, this.request('DELETE', url)];
29947
- });
29948
- });
29876
+ return this.request('DELETE', url);
29949
29877
  };
29950
29878
  /**
29951
29879
  * The Route class contains the method and url, thereforce items can be
@@ -29956,27 +29884,29 @@ var Requests = /** @class */ (function () {
29956
29884
  * @returns
29957
29885
  */
29958
29886
  Requests.processRoute = function (route, data, routeReplace) {
29959
- return __awaiter(this, void 0, void 0, function () {
29960
- var url;
29961
- return __generator(this, function (_a) {
29962
- url = route.url;
29963
- if (route.method == HTTP_METHODS.GET) {
29964
- return [2 /*return*/, this.get(url)];
29965
- }
29966
- else if (route.method == HTTP_METHODS.POST) {
29967
- return [2 /*return*/, this.post(url, data)];
29968
- }
29969
- else if (route.method == HTTP_METHODS.PUT) {
29970
- return [2 /*return*/, this.put(url, data)];
29971
- }
29972
- else if (route.method == HTTP_METHODS.DELETE) {
29973
- return [2 /*return*/, this.delete(url)];
29974
- }
29975
- return [2 /*return*/];
29976
- });
29977
- });
29887
+ var url = route.url;
29888
+ if (routeReplace) {
29889
+ for (var key in routeReplace) {
29890
+ url = url.replace("{" + key + "}", routeReplace[key]);
29891
+ }
29892
+ }
29893
+ if (route.method == HTTP_METHODS.GET) {
29894
+ return this.get(url);
29895
+ }
29896
+ else if (route.method == HTTP_METHODS.POST) {
29897
+ return this.post(url, data);
29898
+ }
29899
+ else if (route.method == HTTP_METHODS.PUT) {
29900
+ return this.put(url, data);
29901
+ }
29902
+ else if (route.method == HTTP_METHODS.DELETE) {
29903
+ return this.delete(url);
29904
+ }
29905
+ return this.get(url);
29978
29906
  };
29907
+ //The base url of the API.
29979
29908
  Requests.baseUrl = "";
29909
+ //The Json Web Token to send in the header
29980
29910
  Requests.authToken = "";
29981
29911
  return Requests;
29982
29912
  }());
@@ -30004,72 +29934,11 @@ var Config = /** @class */ (function () {
30004
29934
  return Config;
30005
29935
  }());
30006
29936
 
30007
- var AuthRoutes = /** @class */ (function () {
30008
- function AuthRoutes() {
30009
- }
30010
- AuthRoutes.routes = {
30011
- login: { url: '/auth/login', method: HTTP_METHODS.POST },
30012
- register: { url: '/auth/register', method: HTTP_METHODS.POST },
30013
- one_time_login: { url: '/auth/oneTimeLoginWithToken', method: HTTP_METHODS.POST },
30014
- forgot_password: { url: '/auth/forgotpassword', method: HTTP_METHODS.POST },
30015
- reset_password: { url: '/auth/resetpassword', method: HTTP_METHODS.POST },
30016
- };
30017
- return AuthRoutes;
30018
- }());
30019
-
30020
- var Auth = /** @class */ (function () {
30021
- function Auth() {
30022
- }
30023
- Auth.login = function (login, password) {
30024
- return Requests.post(AuthRoutes.routes.login.url, { email: login, password: password });
30025
- };
30026
- Auth.register = function (data) {
30027
- return Requests.processRoute(AuthRoutes.routes.register, data);
30028
- };
30029
- return Auth;
30030
- }());
30031
-
30032
- var CompetitionRoutes = /** @class */ (function () {
30033
- function CompetitionRoutes() {
30034
- }
30035
- CompetitionRoutes.routes = {
30036
- list: { url: '/competitions', method: HTTP_METHODS.GET },
30037
- create: { url: '/competitions', method: HTTP_METHODS.POST },
30038
- view: { url: '/competitions/{competition_id}', method: HTTP_METHODS.GET },
30039
- update: { url: '/competitions/{competition_id}', method: HTTP_METHODS.PUT },
30040
- delete: { url: '/competitions/{competition_id}', method: HTTP_METHODS.DELETE },
30041
- };
30042
- return CompetitionRoutes;
30043
- }());
30044
-
30045
- var Competitions = /** @class */ (function () {
30046
- function Competitions() {
30047
- }
30048
- Competitions.list = function () {
30049
- return Requests.processRoute(CompetitionRoutes.routes.list);
30050
- };
30051
- Competitions.create = function (data) {
30052
- return Requests.processRoute(CompetitionRoutes.routes.create, data);
30053
- };
30054
- Competitions.update = function (competition_id, data) {
30055
- return Requests.processRoute(CompetitionRoutes.routes.create, data, { competition_id: competition_id });
30056
- };
30057
- Competitions.view = function (competition_id) {
30058
- return Requests.processRoute(CompetitionRoutes.routes.view, {}, { competition_id: competition_id });
30059
- };
30060
- Competitions.delete = function (competition_id) {
30061
- return Requests.processRoute(CompetitionRoutes.routes.delete, {}, { competition_id: competition_id });
30062
- };
30063
- return Competitions;
30064
- }());
30065
-
30066
29937
  //Configuration
30067
29938
  var Glitch = /** @class */ (function () {
30068
29939
  function Glitch() {
30069
29940
  }
30070
29941
  Glitch.config = Config;
30071
- Glitch.auth = Auth;
30072
- Glitch.competitions = Competitions;
30073
29942
  return Glitch;
30074
29943
  }());
30075
29944