@gewis/grooster-backend-ts 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/src/base.ts ADDED
@@ -0,0 +1,91 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * GRooster
5
+ * A GEWIS Rooster maker
6
+ *
7
+ * The version of the OpenAPI document: 0.1
8
+ *
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+ import type { Configuration } from "./configuration";
16
+ // Some imports not used depending on template conditions
17
+ // @ts-ignore
18
+ import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from "axios";
19
+ import globalAxios from "axios";
20
+
21
+ export const BASE_PATH = "http://localhost".replace(/\/+$/, "");
22
+
23
+ /**
24
+ *
25
+ * @export
26
+ */
27
+ export const COLLECTION_FORMATS = {
28
+ csv: ",",
29
+ ssv: " ",
30
+ tsv: "\t",
31
+ pipes: "|",
32
+ };
33
+
34
+ /**
35
+ *
36
+ * @export
37
+ * @interface RequestArgs
38
+ */
39
+ export interface RequestArgs {
40
+ url: string;
41
+ options: RawAxiosRequestConfig;
42
+ }
43
+
44
+ /**
45
+ *
46
+ * @export
47
+ * @class BaseAPI
48
+ */
49
+ export class BaseAPI {
50
+ protected configuration: Configuration | undefined;
51
+
52
+ constructor(
53
+ configuration?: Configuration,
54
+ protected basePath: string = BASE_PATH,
55
+ protected axios: AxiosInstance = globalAxios,
56
+ ) {
57
+ if (configuration) {
58
+ this.configuration = configuration;
59
+ this.basePath = configuration.basePath ?? basePath;
60
+ }
61
+ }
62
+ }
63
+
64
+ /**
65
+ *
66
+ * @export
67
+ * @class RequiredError
68
+ * @extends {Error}
69
+ */
70
+ export class RequiredError extends Error {
71
+ constructor(
72
+ public field: string,
73
+ msg?: string,
74
+ ) {
75
+ super(msg);
76
+ this.name = "RequiredError";
77
+ }
78
+ }
79
+
80
+ interface ServerMap {
81
+ [key: string]: {
82
+ url: string;
83
+ description: string;
84
+ }[];
85
+ }
86
+
87
+ /**
88
+ *
89
+ * @export
90
+ */
91
+ export const operationServerMap: ServerMap = {};
package/src/common.ts ADDED
@@ -0,0 +1,202 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * GRooster
5
+ * A GEWIS Rooster maker
6
+ *
7
+ * The version of the OpenAPI document: 0.1
8
+ *
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+ import type { Configuration } from "./configuration";
16
+ import type { RequestArgs } from "./base";
17
+ import type { AxiosInstance, AxiosResponse } from "axios";
18
+ import { RequiredError } from "./base";
19
+
20
+ /**
21
+ *
22
+ * @export
23
+ */
24
+ export const DUMMY_BASE_URL = "https://example.com";
25
+
26
+ /**
27
+ *
28
+ * @throws {RequiredError}
29
+ * @export
30
+ */
31
+ export const assertParamExists = function (
32
+ functionName: string,
33
+ paramName: string,
34
+ paramValue: unknown,
35
+ ) {
36
+ if (paramValue === null || paramValue === undefined) {
37
+ throw new RequiredError(
38
+ paramName,
39
+ `Required parameter ${paramName} was null or undefined when calling ${functionName}.`,
40
+ );
41
+ }
42
+ };
43
+
44
+ /**
45
+ *
46
+ * @export
47
+ */
48
+ export const setApiKeyToObject = async function (
49
+ object: any,
50
+ keyParamName: string,
51
+ configuration?: Configuration,
52
+ ) {
53
+ if (configuration && configuration.apiKey) {
54
+ const localVarApiKeyValue =
55
+ typeof configuration.apiKey === "function"
56
+ ? await configuration.apiKey(keyParamName)
57
+ : await configuration.apiKey;
58
+ object[keyParamName] = localVarApiKeyValue;
59
+ }
60
+ };
61
+
62
+ /**
63
+ *
64
+ * @export
65
+ */
66
+ export const setBasicAuthToObject = function (
67
+ object: any,
68
+ configuration?: Configuration,
69
+ ) {
70
+ if (configuration && (configuration.username || configuration.password)) {
71
+ object["auth"] = {
72
+ username: configuration.username,
73
+ password: configuration.password,
74
+ };
75
+ }
76
+ };
77
+
78
+ /**
79
+ *
80
+ * @export
81
+ */
82
+ export const setBearerAuthToObject = async function (
83
+ object: any,
84
+ configuration?: Configuration,
85
+ ) {
86
+ if (configuration && configuration.accessToken) {
87
+ const accessToken =
88
+ typeof configuration.accessToken === "function"
89
+ ? await configuration.accessToken()
90
+ : await configuration.accessToken;
91
+ object["Authorization"] = "Bearer " + accessToken;
92
+ }
93
+ };
94
+
95
+ /**
96
+ *
97
+ * @export
98
+ */
99
+ export const setOAuthToObject = async function (
100
+ object: any,
101
+ name: string,
102
+ scopes: string[],
103
+ configuration?: Configuration,
104
+ ) {
105
+ if (configuration && configuration.accessToken) {
106
+ const localVarAccessTokenValue =
107
+ typeof configuration.accessToken === "function"
108
+ ? await configuration.accessToken(name, scopes)
109
+ : await configuration.accessToken;
110
+ object["Authorization"] = "Bearer " + localVarAccessTokenValue;
111
+ }
112
+ };
113
+
114
+ function setFlattenedQueryParams(
115
+ urlSearchParams: URLSearchParams,
116
+ parameter: any,
117
+ key: string = "",
118
+ ): void {
119
+ if (parameter == null) return;
120
+ if (typeof parameter === "object") {
121
+ if (Array.isArray(parameter)) {
122
+ (parameter as any[]).forEach((item) =>
123
+ setFlattenedQueryParams(urlSearchParams, item, key),
124
+ );
125
+ } else {
126
+ Object.keys(parameter).forEach((currentKey) =>
127
+ setFlattenedQueryParams(
128
+ urlSearchParams,
129
+ parameter[currentKey],
130
+ `${key}${key !== "" ? "." : ""}${currentKey}`,
131
+ ),
132
+ );
133
+ }
134
+ } else {
135
+ if (urlSearchParams.has(key)) {
136
+ urlSearchParams.append(key, parameter);
137
+ } else {
138
+ urlSearchParams.set(key, parameter);
139
+ }
140
+ }
141
+ }
142
+
143
+ /**
144
+ *
145
+ * @export
146
+ */
147
+ export const setSearchParams = function (url: URL, ...objects: any[]) {
148
+ const searchParams = new URLSearchParams(url.search);
149
+ setFlattenedQueryParams(searchParams, objects);
150
+ url.search = searchParams.toString();
151
+ };
152
+
153
+ /**
154
+ *
155
+ * @export
156
+ */
157
+ export const serializeDataIfNeeded = function (
158
+ value: any,
159
+ requestOptions: any,
160
+ configuration?: Configuration,
161
+ ) {
162
+ const nonString = typeof value !== "string";
163
+ const needsSerialization =
164
+ nonString && configuration && configuration.isJsonMime
165
+ ? configuration.isJsonMime(requestOptions.headers["Content-Type"])
166
+ : nonString;
167
+ return needsSerialization
168
+ ? JSON.stringify(value !== undefined ? value : {})
169
+ : value || "";
170
+ };
171
+
172
+ /**
173
+ *
174
+ * @export
175
+ */
176
+ export const toPathString = function (url: URL) {
177
+ return url.pathname + url.search + url.hash;
178
+ };
179
+
180
+ /**
181
+ *
182
+ * @export
183
+ */
184
+ export const createRequestFunction = function (
185
+ axiosArgs: RequestArgs,
186
+ globalAxios: AxiosInstance,
187
+ BASE_PATH: string,
188
+ configuration?: Configuration,
189
+ ) {
190
+ return <T = unknown, R = AxiosResponse<T>>(
191
+ axios: AxiosInstance = globalAxios,
192
+ basePath: string = BASE_PATH,
193
+ ) => {
194
+ const axiosRequestArgs = {
195
+ ...axiosArgs.options,
196
+ url:
197
+ (axios.defaults.baseURL ? "" : (configuration?.basePath ?? basePath)) +
198
+ axiosArgs.url,
199
+ };
200
+ return axios.request<T, R>(axiosRequestArgs);
201
+ };
202
+ };
@@ -0,0 +1,137 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * GRooster
5
+ * A GEWIS Rooster maker
6
+ *
7
+ * The version of the OpenAPI document: 0.1
8
+ *
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+ export interface ConfigurationParameters {
16
+ apiKey?:
17
+ | string
18
+ | Promise<string>
19
+ | ((name: string) => string)
20
+ | ((name: string) => Promise<string>);
21
+ username?: string;
22
+ password?: string;
23
+ accessToken?:
24
+ | string
25
+ | Promise<string>
26
+ | ((name?: string, scopes?: string[]) => string)
27
+ | ((name?: string, scopes?: string[]) => Promise<string>);
28
+ basePath?: string;
29
+ serverIndex?: number;
30
+ baseOptions?: any;
31
+ formDataCtor?: new () => any;
32
+ }
33
+
34
+ export class Configuration {
35
+ /**
36
+ * parameter for apiKey security
37
+ * @param name security name
38
+ * @memberof Configuration
39
+ */
40
+ apiKey?:
41
+ | string
42
+ | Promise<string>
43
+ | ((name: string) => string)
44
+ | ((name: string) => Promise<string>);
45
+ /**
46
+ * parameter for basic security
47
+ *
48
+ * @type {string}
49
+ * @memberof Configuration
50
+ */
51
+ username?: string;
52
+ /**
53
+ * parameter for basic security
54
+ *
55
+ * @type {string}
56
+ * @memberof Configuration
57
+ */
58
+ password?: string;
59
+ /**
60
+ * parameter for oauth2 security
61
+ * @param name security name
62
+ * @param scopes oauth2 scope
63
+ * @memberof Configuration
64
+ */
65
+ accessToken?:
66
+ | string
67
+ | Promise<string>
68
+ | ((name?: string, scopes?: string[]) => string)
69
+ | ((name?: string, scopes?: string[]) => Promise<string>);
70
+ /**
71
+ * override base path
72
+ *
73
+ * @type {string}
74
+ * @memberof Configuration
75
+ */
76
+ basePath?: string;
77
+ /**
78
+ * override server index
79
+ *
80
+ * @type {number}
81
+ * @memberof Configuration
82
+ */
83
+ serverIndex?: number;
84
+ /**
85
+ * base options for axios calls
86
+ *
87
+ * @type {any}
88
+ * @memberof Configuration
89
+ */
90
+ baseOptions?: any;
91
+ /**
92
+ * The FormData constructor that will be used to create multipart form data
93
+ * requests. You can inject this here so that execution environments that
94
+ * do not support the FormData class can still run the generated client.
95
+ *
96
+ * @type {new () => FormData}
97
+ */
98
+ formDataCtor?: new () => any;
99
+
100
+ constructor(param: ConfigurationParameters = {}) {
101
+ this.apiKey = param.apiKey;
102
+ this.username = param.username;
103
+ this.password = param.password;
104
+ this.accessToken = param.accessToken;
105
+ this.basePath = param.basePath;
106
+ this.serverIndex = param.serverIndex;
107
+ this.baseOptions = {
108
+ ...param.baseOptions,
109
+ headers: {
110
+ ...param.baseOptions?.headers,
111
+ },
112
+ };
113
+ this.formDataCtor = param.formDataCtor;
114
+ }
115
+
116
+ /**
117
+ * Check if the given MIME is a JSON MIME.
118
+ * JSON MIME examples:
119
+ * application/json
120
+ * application/json; charset=UTF8
121
+ * APPLICATION/JSON
122
+ * application/vnd.company+json
123
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
124
+ * @return True if the given MIME is JSON, false otherwise.
125
+ */
126
+ public isJsonMime(mime: string): boolean {
127
+ const jsonMime: RegExp = new RegExp(
128
+ "^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$",
129
+ "i",
130
+ );
131
+ return (
132
+ mime !== null &&
133
+ (jsonMime.test(mime) ||
134
+ mime.toLowerCase() === "application/json-patch+json")
135
+ );
136
+ }
137
+ }
@@ -0,0 +1,105 @@
1
+ # AuthApi
2
+
3
+ All URIs are relative to _http://localhost_
4
+
5
+ | Method | HTTP request | Description |
6
+ | --------------------------------------- | ---------------------- | ------------------------- |
7
+ | [**authCallbackGet**](#authcallbackget) | **GET** /auth/callback | Handle OAuth2 Callback |
8
+ | [**authRedirectGet**](#authredirectget) | **GET** /auth/redirect | Redirect to OIDC provider |
9
+
10
+ # **authCallbackGet**
11
+
12
+ > { [key: string]: string; } authCallbackGet()
13
+
14
+ Validates state, exchanges code for token, and returns user info
15
+
16
+ ### Example
17
+
18
+ ```typescript
19
+ import { AuthApi, Configuration } from "./api";
20
+
21
+ const configuration = new Configuration();
22
+ const apiInstance = new AuthApi(configuration);
23
+
24
+ let state: string; //State returned from provider (default to undefined)
25
+ let code: string; //Authorization code from provider (default to undefined)
26
+
27
+ const { status, data } = await apiInstance.authCallbackGet(state, code);
28
+ ```
29
+
30
+ ### Parameters
31
+
32
+ | Name | Type | Description | Notes |
33
+ | --------- | ------------ | -------------------------------- | --------------------- |
34
+ | **state** | [**string**] | State returned from provider | defaults to undefined |
35
+ | **code** | [**string**] | Authorization code from provider | defaults to undefined |
36
+
37
+ ### Return type
38
+
39
+ **{ [key: string]: string; }**
40
+
41
+ ### Authorization
42
+
43
+ No authorization required
44
+
45
+ ### HTTP request headers
46
+
47
+ - **Content-Type**: Not defined
48
+ - **Accept**: _/_
49
+
50
+ ### HTTP response details
51
+
52
+ | Status code | Description | Response headers |
53
+ | ----------- | ------------------------------------- | ---------------- |
54
+ | **200** | User info and token | - |
55
+ | **400** | Bad request: missing or invalid state | - |
56
+ | **500** | Internal server error | - |
57
+
58
+ [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
59
+
60
+ # **authRedirectGet**
61
+
62
+ > string authRedirectGet()
63
+
64
+ Generates state, sets a cookie, and redirects to Google OIDC
65
+
66
+ ### Example
67
+
68
+ ```typescript
69
+ import { AuthApi, Configuration } from "./api";
70
+
71
+ const configuration = new Configuration();
72
+ const apiInstance = new AuthApi(configuration);
73
+
74
+ let state: string; //State returned from provider (default to undefined)
75
+
76
+ const { status, data } = await apiInstance.authRedirectGet(state);
77
+ ```
78
+
79
+ ### Parameters
80
+
81
+ | Name | Type | Description | Notes |
82
+ | --------- | ------------ | ---------------------------- | --------------------- |
83
+ | **state** | [**string**] | State returned from provider | defaults to undefined |
84
+
85
+ ### Return type
86
+
87
+ **string**
88
+
89
+ ### Authorization
90
+
91
+ No authorization required
92
+
93
+ ### HTTP request headers
94
+
95
+ - **Content-Type**: Not defined
96
+ - **Accept**: _/_
97
+
98
+ ### HTTP response details
99
+
100
+ | Status code | Description | Response headers |
101
+ | ----------- | ---------------- | ---------------- |
102
+ | **200** | redirect | - |
103
+ | **500** | pkg server error | - |
104
+
105
+ [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
@@ -0,0 +1,21 @@
1
+ # GormDeletedAt
2
+
3
+ ## Properties
4
+
5
+ | Name | Type | Description | Notes |
6
+ | --------- | ----------- | --------------------------------- | --------------------------------- |
7
+ | **time** | **string** | | [optional] [default to undefined] |
8
+ | **valid** | **boolean** | Valid is true if Time is not NULL | [optional] [default to undefined] |
9
+
10
+ ## Example
11
+
12
+ ```typescript
13
+ import { GormDeletedAt } from "./api";
14
+
15
+ const instance: GormDeletedAt = {
16
+ time,
17
+ valid,
18
+ };
19
+ ```
20
+
21
+ [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
@@ -0,0 +1,31 @@
1
+ # Organ
2
+
3
+ An organ that users can be part of.
4
+
5
+ ## Properties
6
+
7
+ | Name | Type | Description | Notes |
8
+ | ------------- | ------------------------------------- | ----------- | --------------------------------- |
9
+ | **createdAt** | **string** | | [optional] [default to undefined] |
10
+ | **deletedAt** | [**GormDeletedAt**](GormDeletedAt.md) | | [optional] [default to undefined] |
11
+ | **id** | **number** | | [optional] [default to undefined] |
12
+ | **name** | **string** | | [optional] [default to undefined] |
13
+ | **updatedAt** | **string** | | [optional] [default to undefined] |
14
+ | **users** | [**Array&lt;User&gt;**](User.md) | | [optional] [default to undefined] |
15
+
16
+ ## Example
17
+
18
+ ```typescript
19
+ import { Organ } from "./api";
20
+
21
+ const instance: Organ = {
22
+ createdAt,
23
+ deletedAt,
24
+ id,
25
+ name,
26
+ updatedAt,
27
+ users,
28
+ };
29
+ ```
30
+
31
+ [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
@@ -0,0 +1,41 @@
1
+ # Roster
2
+
3
+ ## Properties
4
+
5
+ | Name | Type | Description | Notes |
6
+ | ---------------- | ------------------------------------------------ | ----------- | --------------------------------- |
7
+ | **createdAt** | **string** | | [optional] [default to undefined] |
8
+ | **date** | **string** | | [optional] [default to undefined] |
9
+ | **deletedAt** | [**GormDeletedAt**](GormDeletedAt.md) | | [optional] [default to undefined] |
10
+ | **id** | **number** | | [optional] [default to undefined] |
11
+ | **name** | **string** | | [optional] [default to undefined] |
12
+ | **organ** | [**Organ**](Organ.md) | | [optional] [default to undefined] |
13
+ | **organId** | **number** | | [optional] [default to undefined] |
14
+ | **rosterAnswer** | [**Array&lt;RosterAnswer&gt;**](RosterAnswer.md) | | [optional] [default to undefined] |
15
+ | **rosterShift** | [**Array&lt;RosterShift&gt;**](RosterShift.md) | | [optional] [default to undefined] |
16
+ | **saved** | **boolean** | | [optional] [default to undefined] |
17
+ | **updatedAt** | **string** | | [optional] [default to undefined] |
18
+ | **values** | **Array&lt;string&gt;** | | [optional] [default to undefined] |
19
+
20
+ ## Example
21
+
22
+ ```typescript
23
+ import { Roster } from "./api";
24
+
25
+ const instance: Roster = {
26
+ createdAt,
27
+ date,
28
+ deletedAt,
29
+ id,
30
+ name,
31
+ organ,
32
+ organId,
33
+ rosterAnswer,
34
+ rosterShift,
35
+ saved,
36
+ updatedAt,
37
+ values,
38
+ };
39
+ ```
40
+
41
+ [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
@@ -0,0 +1,33 @@
1
+ # RosterAnswer
2
+
3
+ ## Properties
4
+
5
+ | Name | Type | Description | Notes |
6
+ | ----------------- | ------------------------------------- | ----------- | --------------------------------- |
7
+ | **createdAt** | **string** | | [optional] [default to undefined] |
8
+ | **deletedAt** | [**GormDeletedAt**](GormDeletedAt.md) | | [optional] [default to undefined] |
9
+ | **id** | **number** | | [optional] [default to undefined] |
10
+ | **rosterId** | **number** | | [optional] [default to undefined] |
11
+ | **rosterShiftId** | **number** | | [optional] [default to undefined] |
12
+ | **updatedAt** | **string** | | [optional] [default to undefined] |
13
+ | **userId** | **number** | | [optional] [default to undefined] |
14
+ | **value** | **string** | | [optional] [default to undefined] |
15
+
16
+ ## Example
17
+
18
+ ```typescript
19
+ import { RosterAnswer } from "./api";
20
+
21
+ const instance: RosterAnswer = {
22
+ createdAt,
23
+ deletedAt,
24
+ id,
25
+ rosterId,
26
+ rosterShiftId,
27
+ updatedAt,
28
+ userId,
29
+ value,
30
+ };
31
+ ```
32
+
33
+ [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)