@bid-scents/shared-sdk 1.0.0
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 +123 -0
- package/dist/api/core/ApiError.d.ts +11 -0
- package/dist/api/core/ApiError.d.ts.map +1 -0
- package/dist/api/core/ApiError.js +11 -0
- package/dist/api/core/ApiRequestOptions.d.ts +14 -0
- package/dist/api/core/ApiRequestOptions.d.ts.map +1 -0
- package/dist/api/core/ApiRequestOptions.js +1 -0
- package/dist/api/core/ApiResult.d.ts +8 -0
- package/dist/api/core/ApiResult.d.ts.map +1 -0
- package/dist/api/core/ApiResult.js +1 -0
- package/dist/api/core/CancelablePromise.d.ts +21 -0
- package/dist/api/core/CancelablePromise.d.ts.map +1 -0
- package/dist/api/core/CancelablePromise.js +111 -0
- package/dist/api/core/OpenAPI.d.ts +17 -0
- package/dist/api/core/OpenAPI.d.ts.map +1 -0
- package/dist/api/core/OpenAPI.js +11 -0
- package/dist/api/core/request.d.ts +31 -0
- package/dist/api/core/request.d.ts.map +1 -0
- package/dist/api/core/request.js +275 -0
- package/dist/api/index.d.ts +14 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +9 -0
- package/dist/api/models/CheckUniqueUsernameResponse.d.ts +7 -0
- package/dist/api/models/CheckUniqueUsernameResponse.d.ts.map +1 -0
- package/dist/api/models/CheckUniqueUsernameResponse.js +1 -0
- package/dist/api/models/HTTPValidationError.d.ts +5 -0
- package/dist/api/models/HTTPValidationError.d.ts.map +1 -0
- package/dist/api/models/HTTPValidationError.js +1 -0
- package/dist/api/models/LoginResponse.d.ts +12 -0
- package/dist/api/models/LoginResponse.d.ts.map +1 -0
- package/dist/api/models/LoginResponse.js +1 -0
- package/dist/api/models/OnboardRequest.d.ts +27 -0
- package/dist/api/models/OnboardRequest.d.ts.map +1 -0
- package/dist/api/models/OnboardRequest.js +1 -0
- package/dist/api/models/OnboardResponse.d.ts +12 -0
- package/dist/api/models/OnboardResponse.d.ts.map +1 -0
- package/dist/api/models/OnboardResponse.js +1 -0
- package/dist/api/models/User.d.ts +15 -0
- package/dist/api/models/User.d.ts.map +1 -0
- package/dist/api/models/User.js +1 -0
- package/dist/api/models/ValidationError.d.ts +6 -0
- package/dist/api/models/ValidationError.d.ts.map +1 -0
- package/dist/api/models/ValidationError.js +1 -0
- package/dist/api/services/AuthService.d.ts +31 -0
- package/dist/api/services/AuthService.d.ts.map +1 -0
- package/dist/api/services/AuthService.js +53 -0
- package/dist/api/services/DefaultService.d.ts +10 -0
- package/dist/api/services/DefaultService.d.ts.map +1 -0
- package/dist/api/services/DefaultService.js +15 -0
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/stores/auth.d.ts +41 -0
- package/dist/stores/auth.d.ts.map +1 -0
- package/dist/stores/auth.js +58 -0
- package/dist/stores/index.d.ts +2 -0
- package/dist/stores/index.d.ts.map +1 -0
- package/dist/stores/index.js +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/utils/auth/supabase-config.d.ts +17 -0
- package/dist/utils/auth/supabase-config.d.ts.map +1 -0
- package/dist/utils/auth/supabase-config.js +44 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/validation/schemas.d.ts +40 -0
- package/dist/utils/validation/schemas.d.ts.map +1 -0
- package/dist/utils/validation/schemas.js +46 -0
- package/package.json +46 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do not edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
import { ApiError } from './ApiError';
|
|
6
|
+
import { CancelablePromise } from './CancelablePromise';
|
|
7
|
+
export const isDefined = (value) => {
|
|
8
|
+
return value !== undefined && value !== null;
|
|
9
|
+
};
|
|
10
|
+
export const isString = (value) => {
|
|
11
|
+
return typeof value === 'string';
|
|
12
|
+
};
|
|
13
|
+
export const isStringWithValue = (value) => {
|
|
14
|
+
return isString(value) && value !== '';
|
|
15
|
+
};
|
|
16
|
+
export const isBlob = (value) => {
|
|
17
|
+
return (typeof value === 'object' &&
|
|
18
|
+
typeof value.type === 'string' &&
|
|
19
|
+
typeof value.stream === 'function' &&
|
|
20
|
+
typeof value.arrayBuffer === 'function' &&
|
|
21
|
+
typeof value.constructor === 'function' &&
|
|
22
|
+
typeof value.constructor.name === 'string' &&
|
|
23
|
+
/^(Blob|File)$/.test(value.constructor.name) &&
|
|
24
|
+
/^(Blob|File)$/.test(value[Symbol.toStringTag]));
|
|
25
|
+
};
|
|
26
|
+
export const isFormData = (value) => {
|
|
27
|
+
return value instanceof FormData;
|
|
28
|
+
};
|
|
29
|
+
export const base64 = (str) => {
|
|
30
|
+
try {
|
|
31
|
+
return btoa(str);
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
return Buffer.from(str).toString('base64');
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export const getQueryString = (params) => {
|
|
39
|
+
const qs = [];
|
|
40
|
+
const append = (key, value) => {
|
|
41
|
+
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
42
|
+
};
|
|
43
|
+
const process = (key, value) => {
|
|
44
|
+
if (isDefined(value)) {
|
|
45
|
+
if (Array.isArray(value)) {
|
|
46
|
+
value.forEach(v => {
|
|
47
|
+
process(key, v);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else if (typeof value === 'object') {
|
|
51
|
+
Object.entries(value).forEach(([k, v]) => {
|
|
52
|
+
process(`${key}[${k}]`, v);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
append(key, value);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
61
|
+
process(key, value);
|
|
62
|
+
});
|
|
63
|
+
if (qs.length > 0) {
|
|
64
|
+
return `?${qs.join('&')}`;
|
|
65
|
+
}
|
|
66
|
+
return '';
|
|
67
|
+
};
|
|
68
|
+
const getUrl = (config, options) => {
|
|
69
|
+
const encoder = config.ENCODE_PATH || encodeURI;
|
|
70
|
+
const path = options.url
|
|
71
|
+
.replace('{api-version}', config.VERSION)
|
|
72
|
+
.replace(/{(.*?)}/g, (substring, group) => {
|
|
73
|
+
if (options.path?.hasOwnProperty(group)) {
|
|
74
|
+
return encoder(String(options.path[group]));
|
|
75
|
+
}
|
|
76
|
+
return substring;
|
|
77
|
+
});
|
|
78
|
+
const url = `${config.BASE}${path}`;
|
|
79
|
+
if (options.query) {
|
|
80
|
+
return `${url}${getQueryString(options.query)}`;
|
|
81
|
+
}
|
|
82
|
+
return url;
|
|
83
|
+
};
|
|
84
|
+
export const getFormData = (options) => {
|
|
85
|
+
if (options.formData) {
|
|
86
|
+
const formData = new FormData();
|
|
87
|
+
const process = (key, value) => {
|
|
88
|
+
if (isString(value) || isBlob(value)) {
|
|
89
|
+
formData.append(key, value);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
formData.append(key, JSON.stringify(value));
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
Object.entries(options.formData)
|
|
96
|
+
.filter(([_, value]) => isDefined(value))
|
|
97
|
+
.forEach(([key, value]) => {
|
|
98
|
+
if (Array.isArray(value)) {
|
|
99
|
+
value.forEach(v => process(key, v));
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
process(key, value);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
return formData;
|
|
106
|
+
}
|
|
107
|
+
return undefined;
|
|
108
|
+
};
|
|
109
|
+
export const resolve = async (options, resolver) => {
|
|
110
|
+
if (typeof resolver === 'function') {
|
|
111
|
+
return resolver(options);
|
|
112
|
+
}
|
|
113
|
+
return resolver;
|
|
114
|
+
};
|
|
115
|
+
export const getHeaders = async (config, options) => {
|
|
116
|
+
const [token, username, password, additionalHeaders] = await Promise.all([
|
|
117
|
+
resolve(options, config.TOKEN),
|
|
118
|
+
resolve(options, config.USERNAME),
|
|
119
|
+
resolve(options, config.PASSWORD),
|
|
120
|
+
resolve(options, config.HEADERS),
|
|
121
|
+
]);
|
|
122
|
+
const headers = Object.entries({
|
|
123
|
+
Accept: 'application/json',
|
|
124
|
+
...additionalHeaders,
|
|
125
|
+
...options.headers,
|
|
126
|
+
})
|
|
127
|
+
.filter(([_, value]) => isDefined(value))
|
|
128
|
+
.reduce((headers, [key, value]) => ({
|
|
129
|
+
...headers,
|
|
130
|
+
[key]: String(value),
|
|
131
|
+
}), {});
|
|
132
|
+
if (isStringWithValue(token)) {
|
|
133
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
134
|
+
}
|
|
135
|
+
if (isStringWithValue(username) && isStringWithValue(password)) {
|
|
136
|
+
const credentials = base64(`${username}:${password}`);
|
|
137
|
+
headers['Authorization'] = `Basic ${credentials}`;
|
|
138
|
+
}
|
|
139
|
+
if (options.body !== undefined) {
|
|
140
|
+
if (options.mediaType) {
|
|
141
|
+
headers['Content-Type'] = options.mediaType;
|
|
142
|
+
}
|
|
143
|
+
else if (isBlob(options.body)) {
|
|
144
|
+
headers['Content-Type'] = options.body.type || 'application/octet-stream';
|
|
145
|
+
}
|
|
146
|
+
else if (isString(options.body)) {
|
|
147
|
+
headers['Content-Type'] = 'text/plain';
|
|
148
|
+
}
|
|
149
|
+
else if (!isFormData(options.body)) {
|
|
150
|
+
headers['Content-Type'] = 'application/json';
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return new Headers(headers);
|
|
154
|
+
};
|
|
155
|
+
export const getRequestBody = (options) => {
|
|
156
|
+
if (options.body !== undefined) {
|
|
157
|
+
if (options.mediaType?.includes('/json')) {
|
|
158
|
+
return JSON.stringify(options.body);
|
|
159
|
+
}
|
|
160
|
+
else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
|
|
161
|
+
return options.body;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
return JSON.stringify(options.body);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return undefined;
|
|
168
|
+
};
|
|
169
|
+
export const sendRequest = async (config, options, url, body, formData, headers, onCancel) => {
|
|
170
|
+
const controller = new AbortController();
|
|
171
|
+
const request = {
|
|
172
|
+
headers,
|
|
173
|
+
body: body ?? formData,
|
|
174
|
+
method: options.method,
|
|
175
|
+
signal: controller.signal,
|
|
176
|
+
};
|
|
177
|
+
if (config.WITH_CREDENTIALS) {
|
|
178
|
+
request.credentials = config.CREDENTIALS;
|
|
179
|
+
}
|
|
180
|
+
onCancel(() => controller.abort());
|
|
181
|
+
return await fetch(url, request);
|
|
182
|
+
};
|
|
183
|
+
export const getResponseHeader = (response, responseHeader) => {
|
|
184
|
+
if (responseHeader) {
|
|
185
|
+
const content = response.headers.get(responseHeader);
|
|
186
|
+
if (isString(content)) {
|
|
187
|
+
return content;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return undefined;
|
|
191
|
+
};
|
|
192
|
+
export const getResponseBody = async (response) => {
|
|
193
|
+
if (response.status !== 204) {
|
|
194
|
+
try {
|
|
195
|
+
const contentType = response.headers.get('Content-Type');
|
|
196
|
+
if (contentType) {
|
|
197
|
+
const jsonTypes = ['application/json', 'application/problem+json'];
|
|
198
|
+
const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
|
|
199
|
+
if (isJSON) {
|
|
200
|
+
return await response.json();
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
return await response.text();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
console.error(error);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return undefined;
|
|
212
|
+
};
|
|
213
|
+
export const catchErrorCodes = (options, result) => {
|
|
214
|
+
const errors = {
|
|
215
|
+
400: 'Bad Request',
|
|
216
|
+
401: 'Unauthorized',
|
|
217
|
+
403: 'Forbidden',
|
|
218
|
+
404: 'Not Found',
|
|
219
|
+
500: 'Internal Server Error',
|
|
220
|
+
502: 'Bad Gateway',
|
|
221
|
+
503: 'Service Unavailable',
|
|
222
|
+
...options.errors,
|
|
223
|
+
};
|
|
224
|
+
const error = errors[result.status];
|
|
225
|
+
if (error) {
|
|
226
|
+
throw new ApiError(options, result, error);
|
|
227
|
+
}
|
|
228
|
+
if (!result.ok) {
|
|
229
|
+
const errorStatus = result.status ?? 'unknown';
|
|
230
|
+
const errorStatusText = result.statusText ?? 'unknown';
|
|
231
|
+
const errorBody = (() => {
|
|
232
|
+
try {
|
|
233
|
+
return JSON.stringify(result.body, null, 2);
|
|
234
|
+
}
|
|
235
|
+
catch (e) {
|
|
236
|
+
return undefined;
|
|
237
|
+
}
|
|
238
|
+
})();
|
|
239
|
+
throw new ApiError(options, result, `Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}`);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Request method
|
|
244
|
+
* @param config The OpenAPI configuration object
|
|
245
|
+
* @param options The request options from the service
|
|
246
|
+
* @returns CancelablePromise<T>
|
|
247
|
+
* @throws ApiError
|
|
248
|
+
*/
|
|
249
|
+
export const request = (config, options) => {
|
|
250
|
+
return new CancelablePromise(async (resolve, reject, onCancel) => {
|
|
251
|
+
try {
|
|
252
|
+
const url = getUrl(config, options);
|
|
253
|
+
const formData = getFormData(options);
|
|
254
|
+
const body = getRequestBody(options);
|
|
255
|
+
const headers = await getHeaders(config, options);
|
|
256
|
+
if (!onCancel.isCancelled) {
|
|
257
|
+
const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
|
|
258
|
+
const responseBody = await getResponseBody(response);
|
|
259
|
+
const responseHeader = getResponseHeader(response, options.responseHeader);
|
|
260
|
+
const result = {
|
|
261
|
+
url,
|
|
262
|
+
ok: response.ok,
|
|
263
|
+
status: response.status,
|
|
264
|
+
statusText: response.statusText,
|
|
265
|
+
body: responseHeader ?? responseBody,
|
|
266
|
+
};
|
|
267
|
+
catchErrorCodes(options, result);
|
|
268
|
+
resolve(result.body);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
catch (error) {
|
|
272
|
+
reject(error);
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { ApiError } from './core/ApiError';
|
|
2
|
+
export { CancelablePromise, CancelError } from './core/CancelablePromise';
|
|
3
|
+
export { OpenAPI } from './core/OpenAPI';
|
|
4
|
+
export type { OpenAPIConfig } from './core/OpenAPI';
|
|
5
|
+
export type { CheckUniqueUsernameResponse } from './models/CheckUniqueUsernameResponse';
|
|
6
|
+
export type { HTTPValidationError } from './models/HTTPValidationError';
|
|
7
|
+
export type { LoginResponse } from './models/LoginResponse';
|
|
8
|
+
export type { OnboardRequest } from './models/OnboardRequest';
|
|
9
|
+
export type { OnboardResponse } from './models/OnboardResponse';
|
|
10
|
+
export type { User } from './models/User';
|
|
11
|
+
export type { ValidationError } from './models/ValidationError';
|
|
12
|
+
export { AuthService } from './services/AuthService';
|
|
13
|
+
export { DefaultService } from './services/DefaultService';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,YAAY,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACxF,YAAY,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACxE,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,YAAY,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,YAAY,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,YAAY,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do not edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
export { ApiError } from './core/ApiError';
|
|
6
|
+
export { CancelablePromise, CancelError } from './core/CancelablePromise';
|
|
7
|
+
export { OpenAPI } from './core/OpenAPI';
|
|
8
|
+
export { AuthService } from './services/AuthService';
|
|
9
|
+
export { DefaultService } from './services/DefaultService';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckUniqueUsernameResponse.d.ts","sourceRoot":"","sources":["../../../src/api/models/CheckUniqueUsernameResponse.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,2BAA2B,GAAG;IACtC;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;CACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HTTPValidationError.d.ts","sourceRoot":"","sources":["../../../src/api/models/HTTPValidationError.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,MAAM,MAAM,mBAAmB,GAAG;IAC9B,MAAM,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;CACnC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { User } from './User';
|
|
2
|
+
export type LoginResponse = {
|
|
3
|
+
/**
|
|
4
|
+
* Indicates whether the user has completed onboarding.
|
|
5
|
+
*/
|
|
6
|
+
onboarded: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The user's profile information if available.
|
|
9
|
+
*/
|
|
10
|
+
profile: (User | null);
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=LoginResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoginResponse.d.ts","sourceRoot":"","sources":["../../../src/api/models/LoginResponse.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,MAAM,MAAM,aAAa,GAAG;IACxB;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,OAAO,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;CAC1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type OnboardRequest = {
|
|
2
|
+
/**
|
|
3
|
+
* The username for the user.
|
|
4
|
+
*/
|
|
5
|
+
username: string;
|
|
6
|
+
/**
|
|
7
|
+
* The first name of the user.
|
|
8
|
+
*/
|
|
9
|
+
first_name: string;
|
|
10
|
+
/**
|
|
11
|
+
* The last name of the user.
|
|
12
|
+
*/
|
|
13
|
+
last_name: string;
|
|
14
|
+
/**
|
|
15
|
+
* URL to the user's profile image.
|
|
16
|
+
*/
|
|
17
|
+
profile_image_url?: (string | null);
|
|
18
|
+
/**
|
|
19
|
+
* URL to the user's cover image.
|
|
20
|
+
*/
|
|
21
|
+
cover_image_url?: (string | null);
|
|
22
|
+
/**
|
|
23
|
+
* A short biography of the user.
|
|
24
|
+
*/
|
|
25
|
+
bio?: (string | null);
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=OnboardRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnboardRequest.d.ts","sourceRoot":"","sources":["../../../src/api/models/OnboardRequest.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,cAAc,GAAG;IACzB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACpC;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAClC;;OAEG;IACH,GAAG,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { User } from './User';
|
|
2
|
+
export type OnboardResponse = {
|
|
3
|
+
/**
|
|
4
|
+
* A message indicating the result of the onboarding process.
|
|
5
|
+
*/
|
|
6
|
+
message: string;
|
|
7
|
+
/**
|
|
8
|
+
* The user's profile information after onboarding.
|
|
9
|
+
*/
|
|
10
|
+
profile: User;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=OnboardResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnboardResponse.d.ts","sourceRoot":"","sources":["../../../src/api/models/OnboardResponse.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,MAAM,MAAM,eAAe,GAAG;IAC1B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,OAAO,EAAE,IAAI,CAAC;CACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type User = {
|
|
2
|
+
id: string;
|
|
3
|
+
username: string;
|
|
4
|
+
first_name: string;
|
|
5
|
+
last_name: string;
|
|
6
|
+
profile_image_url?: (string | null);
|
|
7
|
+
cover_image_url?: (string | null);
|
|
8
|
+
bio?: (string | null);
|
|
9
|
+
location?: (string | null);
|
|
10
|
+
is_admin?: boolean;
|
|
11
|
+
badges?: Array<string>;
|
|
12
|
+
eligible_for_swap_until?: (string | null);
|
|
13
|
+
onboarded_at?: (string | null);
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=User.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"User.d.ts","sourceRoot":"","sources":["../../../src/api/models/User.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,IAAI,GAAG;IACf,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACpC,eAAe,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAClC,GAAG,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,uBAAuB,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC1C,YAAY,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAClC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationError.d.ts","sourceRoot":"","sources":["../../../src/api/models/ValidationError.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,eAAe,GAAG;IAC1B,GAAG,EAAE,KAAK,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CheckUniqueUsernameResponse } from '../models/CheckUniqueUsernameResponse';
|
|
2
|
+
import type { LoginResponse } from '../models/LoginResponse';
|
|
3
|
+
import type { OnboardRequest } from '../models/OnboardRequest';
|
|
4
|
+
import type { OnboardResponse } from '../models/OnboardResponse';
|
|
5
|
+
import type { CancelablePromise } from '../core/CancelablePromise';
|
|
6
|
+
export declare class AuthService {
|
|
7
|
+
/**
|
|
8
|
+
* Login
|
|
9
|
+
* Handle OAuth callback and check if the user has completed onboarding.
|
|
10
|
+
* @returns LoginResponse Successful Response
|
|
11
|
+
* @throws ApiError
|
|
12
|
+
*/
|
|
13
|
+
static loginV1AuthLoginGet(): CancelablePromise<LoginResponse>;
|
|
14
|
+
/**
|
|
15
|
+
* Onboard User
|
|
16
|
+
* Onboard a user by providing their profile information.
|
|
17
|
+
* @param requestBody
|
|
18
|
+
* @returns OnboardResponse Successful Response
|
|
19
|
+
* @throws ApiError
|
|
20
|
+
*/
|
|
21
|
+
static onboardUserV1AuthOnboardPost(requestBody: OnboardRequest): CancelablePromise<OnboardResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Check Unique Username
|
|
24
|
+
* Check if a username is unique.
|
|
25
|
+
* @param username
|
|
26
|
+
* @returns CheckUniqueUsernameResponse Successful Response
|
|
27
|
+
* @throws ApiError
|
|
28
|
+
*/
|
|
29
|
+
static checkUniqueUsernameV1AuthCheckUsernameGet(username: string): CancelablePromise<CheckUniqueUsernameResponse>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=AuthService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthService.d.ts","sourceRoot":"","sources":["../../../src/api/services/AuthService.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAGnE,qBAAa,WAAW;IACpB;;;;;OAKG;WACW,mBAAmB,IAAI,iBAAiB,CAAC,aAAa,CAAC;IAMrE;;;;;;OAMG;WACW,4BAA4B,CACtC,WAAW,EAAE,cAAc,GAC5B,iBAAiB,CAAC,eAAe,CAAC;IAWrC;;;;;;OAMG;WACW,yCAAyC,CACnD,QAAQ,EAAE,MAAM,GACjB,iBAAiB,CAAC,2BAA2B,CAAC;CAYpD"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { OpenAPI } from '../core/OpenAPI';
|
|
2
|
+
import { request as __request } from '../core/request';
|
|
3
|
+
export class AuthService {
|
|
4
|
+
/**
|
|
5
|
+
* Login
|
|
6
|
+
* Handle OAuth callback and check if the user has completed onboarding.
|
|
7
|
+
* @returns LoginResponse Successful Response
|
|
8
|
+
* @throws ApiError
|
|
9
|
+
*/
|
|
10
|
+
static loginV1AuthLoginGet() {
|
|
11
|
+
return __request(OpenAPI, {
|
|
12
|
+
method: 'GET',
|
|
13
|
+
url: '/v1/auth/login',
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Onboard User
|
|
18
|
+
* Onboard a user by providing their profile information.
|
|
19
|
+
* @param requestBody
|
|
20
|
+
* @returns OnboardResponse Successful Response
|
|
21
|
+
* @throws ApiError
|
|
22
|
+
*/
|
|
23
|
+
static onboardUserV1AuthOnboardPost(requestBody) {
|
|
24
|
+
return __request(OpenAPI, {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
url: '/v1/auth/onboard',
|
|
27
|
+
body: requestBody,
|
|
28
|
+
mediaType: 'application/json',
|
|
29
|
+
errors: {
|
|
30
|
+
422: `Validation Error`,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Check Unique Username
|
|
36
|
+
* Check if a username is unique.
|
|
37
|
+
* @param username
|
|
38
|
+
* @returns CheckUniqueUsernameResponse Successful Response
|
|
39
|
+
* @throws ApiError
|
|
40
|
+
*/
|
|
41
|
+
static checkUniqueUsernameV1AuthCheckUsernameGet(username) {
|
|
42
|
+
return __request(OpenAPI, {
|
|
43
|
+
method: 'GET',
|
|
44
|
+
url: '/v1/auth/check-username',
|
|
45
|
+
query: {
|
|
46
|
+
'username': username,
|
|
47
|
+
},
|
|
48
|
+
errors: {
|
|
49
|
+
422: `Validation Error`,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CancelablePromise } from '../core/CancelablePromise';
|
|
2
|
+
export declare class DefaultService {
|
|
3
|
+
/**
|
|
4
|
+
* Read Root
|
|
5
|
+
* @returns any Successful Response
|
|
6
|
+
* @throws ApiError
|
|
7
|
+
*/
|
|
8
|
+
static readRootGet(): CancelablePromise<any>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=DefaultService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultService.d.ts","sourceRoot":"","sources":["../../../src/api/services/DefaultService.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAGnE,qBAAa,cAAc;IACvB;;;;OAIG;WACW,WAAW,IAAI,iBAAiB,CAAC,GAAG,CAAC;CAMtD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { OpenAPI } from '../core/OpenAPI';
|
|
2
|
+
import { request as __request } from '../core/request';
|
|
3
|
+
export class DefaultService {
|
|
4
|
+
/**
|
|
5
|
+
* Read Root
|
|
6
|
+
* @returns any Successful Response
|
|
7
|
+
* @throws ApiError
|
|
8
|
+
*/
|
|
9
|
+
static readRootGet() {
|
|
10
|
+
return __request(OpenAPI, {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
url: '/',
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,OAAO,CAAA;AAGrB,cAAc,UAAU,CAAA;AAGxB,cAAc,SAAS,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { User } from '../api/models/User';
|
|
2
|
+
interface AuthState {
|
|
3
|
+
user: User | null;
|
|
4
|
+
session: any | null;
|
|
5
|
+
isAuthenticated: boolean;
|
|
6
|
+
isOnboarded: boolean;
|
|
7
|
+
setUser: (user: User | null) => void;
|
|
8
|
+
setSession: (session: any | null) => void;
|
|
9
|
+
logout: () => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Zustand store for authentication state management with Supabase.
|
|
13
|
+
*
|
|
14
|
+
* Manages user data and Supabase session which contains tokens.
|
|
15
|
+
* Supabase automatically handles token refresh in the background.
|
|
16
|
+
*
|
|
17
|
+
* @returns Auth store with user state, session, and actions
|
|
18
|
+
*/
|
|
19
|
+
export declare const useAuthStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<AuthState>, "persist"> & {
|
|
20
|
+
persist: {
|
|
21
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<AuthState, {
|
|
22
|
+
user: User | null;
|
|
23
|
+
session: any;
|
|
24
|
+
isAuthenticated: boolean;
|
|
25
|
+
isOnboarded: boolean;
|
|
26
|
+
}>>) => void;
|
|
27
|
+
clearStorage: () => void;
|
|
28
|
+
rehydrate: () => Promise<void> | void;
|
|
29
|
+
hasHydrated: () => boolean;
|
|
30
|
+
onHydrate: (fn: (state: AuthState) => void) => () => void;
|
|
31
|
+
onFinishHydration: (fn: (state: AuthState) => void) => () => void;
|
|
32
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<AuthState, {
|
|
33
|
+
user: User | null;
|
|
34
|
+
session: any;
|
|
35
|
+
isAuthenticated: boolean;
|
|
36
|
+
isOnboarded: boolean;
|
|
37
|
+
}>>;
|
|
38
|
+
};
|
|
39
|
+
}>;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/stores/auth.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAE9C,UAAU,SAAS;IACjB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAA;IACjB,OAAO,EAAE,GAAG,GAAG,IAAI,CAAA;IACnB,eAAe,EAAE,OAAO,CAAA;IACxB,WAAW,EAAE,OAAO,CAAA;IACpB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAA;IACpC,UAAU,EAAE,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,KAAK,IAAI,CAAA;IACzC,MAAM,EAAE,MAAM,IAAI,CAAA;CACnB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;EAsDxB,CAAA"}
|