glitch-javascript-sdk 0.0.6 → 0.0.8

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAWA,IAAA,MAAA,kBAAA,YAAA;AAAA,IAAA,SAAA,MAAA,GAAA;KAaG;IAAD,OAAC,MAAA,CAAA;AAAD,CAAC,EAAA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAYA,IAAA,MAAA,kBAAA,YAAA;AAAA,IAAA,SAAA,MAAA,GAAA;KAgBC;IAAD,OAAC,MAAA,CAAA;AAAD,CAAC,EAAA;;;;"}
@@ -26,12 +26,40 @@ declare class Auth {
26
26
  /**
27
27
  * Attempts to register a user.
28
28
  *
29
- * @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authRegister
29
+ * @see https://api.glitch.fun/api/documentation#/Authentication%20Route/oneTimeLoginToken
30
30
  *
31
31
  * @param data The data the user can register with.
32
32
  *
33
33
  * @returns A promise
34
34
  */
35
35
  static register<T>(data: object): AxiosPromise<Response<T>>;
36
+ /**
37
+ * Request an authentication token to faciliate a one time login of an user.
38
+ *
39
+ * @see https://api.glitch.fun/api/documentation#/Authentication%20Route/oneTimeLoginToken
40
+ *
41
+ * @returns promise
42
+ */
43
+ static oneTimeLogin<T>(): AxiosPromise<Response<T>>;
44
+ /**
45
+ * Execute the password reset process using a user's email address.
46
+ *
47
+ * @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authForgotPassword
48
+ *
49
+ * @param email The email address
50
+ *
51
+ * @returns promise
52
+ */
53
+ static forgotPasswordWithEmail<T>(email: string): AxiosPromise<Response<T>>;
54
+ /**
55
+ * Resets the users password after the forgot password has been executed.
56
+ *
57
+ * @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authResetPassword
58
+ *
59
+ * @param data The parameters required to reset the password.
60
+ *
61
+ * @returns promise
62
+ */
63
+ static resetPassword<T>(data: object): AxiosPromise<Response<T>>;
36
64
  }
37
65
  export default Auth;
@@ -1,6 +1,6 @@
1
1
  import Response from "../util/Response";
2
2
  import { AxiosPromise } from "axios";
3
- declare class Teams {
3
+ declare class Waitlists {
4
4
  /**
5
5
  * List all the waitlist sign-ups.
6
6
  *
@@ -50,4 +50,4 @@ declare class Teams {
50
50
  */
51
51
  static delete<T>(waitlist_id: string): AxiosPromise<Response<T>>;
52
52
  }
53
- export default Teams;
53
+ export default Waitlists;
@@ -3,8 +3,10 @@ import Competitions from "./Competitions";
3
3
  import Users from "./Users";
4
4
  import Events from "./Events";
5
5
  import Teams from "./Teams";
6
+ import Waitlists from "./Waitlist";
6
7
  export { Auth };
7
8
  export { Competitions };
8
9
  export { Users };
9
10
  export { Events };
10
11
  export { Teams };
12
+ export { Waitlists };
@@ -5,10 +5,36 @@
5
5
  * API.
6
6
  */
7
7
  declare class Config {
8
- baseUrl: string;
9
- authToken: string;
10
- constructor(baseUrl: string, authToken: string);
11
- setBaseUrl(baseUrl: string): void;
12
- setAuthToken(authToken: string): void;
8
+ private static _baseUrl;
9
+ private static _authToken;
10
+ private static _baseUrlLocked;
11
+ /**
12
+ * Set the configuration
13
+ *
14
+ * @param baseUrl The url base endpoint of the api
15
+ * @param authToken The JSON Web Token
16
+ */
17
+ static setConfig(baseUrl: string, authToken: string, lock?: boolean): void;
18
+ /**
19
+ * Sets the endpoint for the API
20
+ *
21
+ * @param baseUrl The url that connects to the APIs base
22
+ * @param lock If set to true, will lock the baseUrl so it cannot be changed
23
+ */
24
+ static setBaseUrl(baseUrl: string, lock?: boolean): void;
25
+ /**
26
+ * Set the JSON Web Token (JWT) that will be passed to the API
27
+ *
28
+ * @param authToken The JWT
29
+ */
30
+ static setAuthToken(authToken: string): void;
31
+ /**
32
+ * Gets base url
33
+ */
34
+ static get baseUrl(): string;
35
+ /**
36
+ * Gets auth token
37
+ */
38
+ static get authToken(): string;
13
39
  }
14
40
  export default Config;
@@ -4,14 +4,18 @@ import { Competitions } from "./api";
4
4
  import { Users } from "./api";
5
5
  import { Events } from "./api";
6
6
  import { Teams } from "./api";
7
+ import { Waitlists } from "./api";
7
8
  declare class Glitch {
8
- static config: Config;
9
+ static config: {
10
+ Config: Config;
11
+ };
9
12
  static api: {
10
13
  Auth: Auth;
11
14
  Competitions: Competitions;
12
15
  Users: Users;
13
16
  Events: Events;
14
17
  Teams: Teams;
18
+ Waitlists: Waitlists;
15
19
  };
16
20
  }
17
21
  export { Glitch };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAWA,IAAA,MAAA,kBAAA,YAAA;AAAA,IAAA,SAAA,MAAA,GAAA;KAaG;IAAD,OAAC,MAAA,CAAA;AAAD,CAAC,EAAA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAYA,IAAA,MAAA,kBAAA,YAAA;AAAA,IAAA,SAAA,MAAA,GAAA;KAgBC;IAAD,OAAC,MAAA,CAAA;AAAD,CAAC,EAAA;;;;"}
@@ -7,12 +7,6 @@ declare class Requests {
7
7
  private static baseUrl;
8
8
  private static authToken;
9
9
  constructor(config: Config);
10
- /**
11
- * Sets the configuration of the system.
12
- *
13
- * @param config Config The config class.
14
- */
15
- static setConfig(config: Config): void;
16
10
  /**
17
11
  * Sets the base url of the API.
18
12
  *
package/dist/index.d.ts CHANGED
@@ -7,11 +7,37 @@ import { AxiosPromise } from 'axios';
7
7
  * API.
8
8
  */
9
9
  declare class Config {
10
- baseUrl: string;
11
- authToken: string;
12
- constructor(baseUrl: string, authToken: string);
13
- setBaseUrl(baseUrl: string): void;
14
- setAuthToken(authToken: string): void;
10
+ private static _baseUrl;
11
+ private static _authToken;
12
+ private static _baseUrlLocked;
13
+ /**
14
+ * Set the configuration
15
+ *
16
+ * @param baseUrl The url base endpoint of the api
17
+ * @param authToken The JSON Web Token
18
+ */
19
+ static setConfig(baseUrl: string, authToken: string, lock?: boolean): void;
20
+ /**
21
+ * Sets the endpoint for the API
22
+ *
23
+ * @param baseUrl The url that connects to the APIs base
24
+ * @param lock If set to true, will lock the baseUrl so it cannot be changed
25
+ */
26
+ static setBaseUrl(baseUrl: string, lock?: boolean): void;
27
+ /**
28
+ * Set the JSON Web Token (JWT) that will be passed to the API
29
+ *
30
+ * @param authToken The JWT
31
+ */
32
+ static setAuthToken(authToken: string): void;
33
+ /**
34
+ * Gets base url
35
+ */
36
+ static get baseUrl(): string;
37
+ /**
38
+ * Gets auth token
39
+ */
40
+ static get authToken(): string;
15
41
  }
16
42
 
17
43
  interface Response<T> {
@@ -46,13 +72,41 @@ declare class Auth {
46
72
  /**
47
73
  * Attempts to register a user.
48
74
  *
49
- * @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authRegister
75
+ * @see https://api.glitch.fun/api/documentation#/Authentication%20Route/oneTimeLoginToken
50
76
  *
51
77
  * @param data The data the user can register with.
52
78
  *
53
79
  * @returns A promise
54
80
  */
55
81
  static register<T>(data: object): AxiosPromise<Response<T>>;
82
+ /**
83
+ * Request an authentication token to faciliate a one time login of an user.
84
+ *
85
+ * @see https://api.glitch.fun/api/documentation#/Authentication%20Route/oneTimeLoginToken
86
+ *
87
+ * @returns promise
88
+ */
89
+ static oneTimeLogin<T>(): AxiosPromise<Response<T>>;
90
+ /**
91
+ * Execute the password reset process using a user's email address.
92
+ *
93
+ * @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authForgotPassword
94
+ *
95
+ * @param email The email address
96
+ *
97
+ * @returns promise
98
+ */
99
+ static forgotPasswordWithEmail<T>(email: string): AxiosPromise<Response<T>>;
100
+ /**
101
+ * Resets the users password after the forgot password has been executed.
102
+ *
103
+ * @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authResetPassword
104
+ *
105
+ * @param data The parameters required to reset the password.
106
+ *
107
+ * @returns promise
108
+ */
109
+ static resetPassword<T>(data: object): AxiosPromise<Response<T>>;
56
110
  }
57
111
 
58
112
  declare class Competitions {
@@ -1024,14 +1078,68 @@ declare class Teams {
1024
1078
  static removetUser<T>(team_id: string, user_id: string): AxiosPromise<Response<T>>;
1025
1079
  }
1026
1080
 
1081
+ declare class Waitlists {
1082
+ /**
1083
+ * List all the waitlist sign-ups.
1084
+ *
1085
+ * @see https://api.glitch.fun/api/documentation#/Waitlist%20Route/waitlistList
1086
+ *
1087
+ * @returns promise
1088
+ */
1089
+ static list<T>(): AxiosPromise<Response<T>>;
1090
+ /**
1091
+ * Sign-up to the waitlist.
1092
+ *
1093
+ * @see https://api.glitch.fun/api/documentation#/Waitlist%20Route/waitlistCreate
1094
+ *
1095
+ * @param data The data to be passed when creating a team.
1096
+ *
1097
+ * @returns Promise
1098
+ */
1099
+ static create<T>(data: object): AxiosPromise<Response<T>>;
1100
+ /**
1101
+ * Update a waitlist.
1102
+ *
1103
+ * @see https://api.glitch.fun/api/documentation#/Waitlist%20Route/waitlistUpdate
1104
+ *
1105
+ * @param waitlist_id The id of the team to update.
1106
+ * @param data The data to update.
1107
+ *
1108
+ * @returns promise
1109
+ */
1110
+ static update<T>(waitlist_id: string, data: object): AxiosPromise<Response<T>>;
1111
+ /**
1112
+ * Retrieve the information for a single user who signed-up to the waitlist.
1113
+ *
1114
+ * @see https://api.glitch.fun/api/documentation#/Waitlist%20Route/waitlistUpdate
1115
+ *
1116
+ * @param waitlist_id The id fo the team to retrieve.
1117
+ *
1118
+ * @returns promise
1119
+ */
1120
+ static view<T>(waitlist_id: string): AxiosPromise<Response<T>>;
1121
+ /**
1122
+ * Deletes an entry from the waitlist.
1123
+ *
1124
+ * @see https://api.glitch.fun/api/documentation#/Waitlist%20Route/waitlistDelete
1125
+ *
1126
+ * @param waitlist_id The id of the team to delete.
1127
+ * @returns promise
1128
+ */
1129
+ static delete<T>(waitlist_id: string): AxiosPromise<Response<T>>;
1130
+ }
1131
+
1027
1132
  declare class Glitch {
1028
- static config: Config;
1133
+ static config: {
1134
+ Config: Config;
1135
+ };
1029
1136
  static api: {
1030
1137
  Auth: Auth;
1031
1138
  Competitions: Competitions;
1032
1139
  Users: Users;
1033
1140
  Events: Events;
1034
1141
  Teams: Teams;
1142
+ Waitlists: Waitlists;
1035
1143
  };
1036
1144
  }
1037
1145
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitch-javascript-sdk",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Javascrip SDK for GLitch",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
package/src/api/Auth.ts CHANGED
@@ -36,7 +36,7 @@ class Auth {
36
36
  /**
37
37
  * Attempts to register a user.
38
38
  *
39
- * @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authRegister
39
+ * @see https://api.glitch.fun/api/documentation#/Authentication%20Route/oneTimeLoginToken
40
40
  *
41
41
  * @param data The data the user can register with.
42
42
  *
@@ -45,6 +45,44 @@ class Auth {
45
45
  public static register<T>(data : object) : AxiosPromise<Response<T>> {
46
46
  return Requests.processRoute(AuthRoutes.routes.register, data);
47
47
  }
48
+
49
+ /**
50
+ * Request an authentication token to faciliate a one time login of an user.
51
+ *
52
+ * @see https://api.glitch.fun/api/documentation#/Authentication%20Route/oneTimeLoginToken
53
+ *
54
+ * @returns promise
55
+ */
56
+ public static oneTimeLogin<T>() : AxiosPromise<Response<T>> {
57
+ return Requests.processRoute(AuthRoutes.routes.one_time_login, {});
58
+ }
59
+
60
+ /**
61
+ * Execute the password reset process using a user's email address.
62
+ *
63
+ * @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authForgotPassword
64
+ *
65
+ * @param email The email address
66
+ *
67
+ * @returns promise
68
+ */
69
+ public static forgotPasswordWithEmail<T>(email: string) : AxiosPromise<Response<T>> {
70
+ return Requests.processRoute(AuthRoutes.routes.forgot_password, {email: email});
71
+ }
72
+
73
+ /**
74
+ * Resets the users password after the forgot password has been executed.
75
+ *
76
+ * @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authResetPassword
77
+ *
78
+ * @param data The parameters required to reset the password.
79
+ *
80
+ * @returns promise
81
+ */
82
+ public static resetPassword<T>(data : object) : AxiosPromise<Response<T>> {
83
+ return Requests.processRoute(AuthRoutes.routes.forgot_password, data);
84
+ }
85
+
48
86
  }
49
87
 
50
88
  export default Auth;
@@ -1,9 +1,9 @@
1
- import WaitlistRoutes from "../routes/TeamsRoute";
1
+ import WaitlistRoutes from "../routes/WaitlistRoutes";
2
2
  import Requests from "../util/Requests";
3
3
  import Response from "../util/Response";
4
4
  import { AxiosPromise } from "axios";
5
5
 
6
- class Teams {
6
+ class Waitlists {
7
7
 
8
8
  /**
9
9
  * List all the waitlist sign-ups.
@@ -75,4 +75,4 @@ class Teams {
75
75
 
76
76
  }
77
77
 
78
- export default Teams;
78
+ export default Waitlists;
package/src/api/index.ts CHANGED
@@ -3,9 +3,12 @@ import Competitions from "./Competitions";
3
3
  import Users from "./Users";
4
4
  import Events from "./Events";
5
5
  import Teams from "./Teams";
6
+ import Waitlists from "./Waitlist";
7
+
6
8
 
7
9
  export {Auth};
8
10
  export {Competitions};
9
11
  export {Users};
10
12
  export {Events};
11
- export {Teams};
13
+ export {Teams};
14
+ export {Waitlists}
@@ -7,31 +7,71 @@ import Requests from "../util/Requests";
7
7
  * API.
8
8
  */
9
9
  class Config {
10
- //The base url of the API, ie: http://api.example.com/v1/
11
- baseUrl: string;
12
10
 
13
- //The JWT token used to access the api.
14
- authToken: string;
15
-
16
- constructor(baseUrl: string, authToken: string) {
17
- this.baseUrl = baseUrl;
18
- this.authToken = authToken;
11
+ private static _baseUrl: string;
12
+ private static _authToken: string;
19
13
 
20
- Requests.setConfig(this);
21
- }
14
+ private static _baseUrlLocked: boolean = false;
15
+
16
+ /**
17
+ * Set the configuration
18
+ *
19
+ * @param baseUrl The url base endpoint of the api
20
+ * @param authToken The JSON Web Token
21
+ */
22
+ static setConfig(baseUrl: string, authToken: string, lock? : boolean) {
23
+
24
+ this.setBaseUrl(baseUrl, lock);
25
+
26
+ this.setAuthToken(authToken);
27
+
28
+ Requests.setBaseUrl(baseUrl);
29
+ Requests.setAuthToken(authToken);
30
+ }
31
+
32
+ /**
33
+ * Sets the endpoint for the API
34
+ *
35
+ * @param baseUrl The url that connects to the APIs base
36
+ * @param lock If set to true, will lock the baseUrl so it cannot be changed
37
+ */
38
+ static setBaseUrl(baseUrl: string, lock? : boolean) {
22
39
 
23
- setBaseUrl(baseUrl: string) {
24
- this.baseUrl = baseUrl;
40
+ if(!this._baseUrlLocked) {
41
+ Config._baseUrl = baseUrl;
25
42
 
26
43
  Requests.setBaseUrl(baseUrl);
27
44
  }
28
45
 
29
- setAuthToken(authToken: string) {
30
- this.authToken = authToken;
31
-
32
- Requests.setAuthToken(authToken);
46
+ if(lock) {
47
+ this._baseUrlLocked = true;
33
48
  }
49
+ }
50
+
51
+ /**
52
+ * Set the JSON Web Token (JWT) that will be passed to the API
53
+ *
54
+ * @param authToken The JWT
55
+ */
56
+ static setAuthToken(authToken: string) {
57
+ Config._authToken = authToken;
58
+
59
+ Requests.setAuthToken(authToken);
60
+ }
61
+
62
+ /**
63
+ * Gets base url
64
+ */
65
+ static get baseUrl(): string {
66
+ return Config._baseUrl;
67
+ }
34
68
 
69
+ /**
70
+ * Gets auth token
71
+ */
72
+ static get authToken(): string {
73
+ return Config._authToken;
35
74
  }
75
+ }
36
76
 
37
- export default Config;
77
+ export default Config;
package/src/index.ts CHANGED
@@ -6,22 +6,26 @@ import Config from "./config/Config";
6
6
  import { Auth } from "./api";
7
7
  import { Competitions } from "./api";
8
8
  import { Users } from "./api";
9
- import {Events} from "./api";
10
- import {Teams} from "./api";
9
+ import { Events } from "./api";
10
+ import { Teams } from "./api";
11
+ import { Waitlists } from "./api";
11
12
 
12
13
  class Glitch {
13
14
 
14
- public static config: Config;
15
+ public static config: {
16
+ Config: Config
17
+ };
15
18
 
16
- public static api : {
17
- Auth : Auth,
19
+ public static api: {
20
+ Auth: Auth,
18
21
  Competitions: Competitions,
19
- Users: Users,
20
- Events : Events,
21
- Teams : Teams
22
+ Users: Users,
23
+ Events: Events,
24
+ Teams: Teams,
25
+ Waitlists: Waitlists
22
26
  }
23
27
 
24
28
 
25
- }
29
+ }
26
30
 
27
- export {Glitch};
31
+ export { Glitch };
@@ -19,18 +19,6 @@ class Requests {
19
19
  this.config = config;
20
20
  }
21
21
 
22
- /**
23
- * Sets the configuration of the system.
24
- *
25
- * @param config Config The config class.
26
- */
27
- public static setConfig(config: Config) {
28
-
29
- this.baseUrl = config.baseUrl;
30
-
31
- this.authToken = config.authToken;
32
- }
33
-
34
22
  /**
35
23
  * Sets the base url of the API.
36
24
  *