@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.
Files changed (74) hide show
  1. package/README.md +123 -0
  2. package/dist/api/core/ApiError.d.ts +11 -0
  3. package/dist/api/core/ApiError.d.ts.map +1 -0
  4. package/dist/api/core/ApiError.js +11 -0
  5. package/dist/api/core/ApiRequestOptions.d.ts +14 -0
  6. package/dist/api/core/ApiRequestOptions.d.ts.map +1 -0
  7. package/dist/api/core/ApiRequestOptions.js +1 -0
  8. package/dist/api/core/ApiResult.d.ts +8 -0
  9. package/dist/api/core/ApiResult.d.ts.map +1 -0
  10. package/dist/api/core/ApiResult.js +1 -0
  11. package/dist/api/core/CancelablePromise.d.ts +21 -0
  12. package/dist/api/core/CancelablePromise.d.ts.map +1 -0
  13. package/dist/api/core/CancelablePromise.js +111 -0
  14. package/dist/api/core/OpenAPI.d.ts +17 -0
  15. package/dist/api/core/OpenAPI.d.ts.map +1 -0
  16. package/dist/api/core/OpenAPI.js +11 -0
  17. package/dist/api/core/request.d.ts +31 -0
  18. package/dist/api/core/request.d.ts.map +1 -0
  19. package/dist/api/core/request.js +275 -0
  20. package/dist/api/index.d.ts +14 -0
  21. package/dist/api/index.d.ts.map +1 -0
  22. package/dist/api/index.js +9 -0
  23. package/dist/api/models/CheckUniqueUsernameResponse.d.ts +7 -0
  24. package/dist/api/models/CheckUniqueUsernameResponse.d.ts.map +1 -0
  25. package/dist/api/models/CheckUniqueUsernameResponse.js +1 -0
  26. package/dist/api/models/HTTPValidationError.d.ts +5 -0
  27. package/dist/api/models/HTTPValidationError.d.ts.map +1 -0
  28. package/dist/api/models/HTTPValidationError.js +1 -0
  29. package/dist/api/models/LoginResponse.d.ts +12 -0
  30. package/dist/api/models/LoginResponse.d.ts.map +1 -0
  31. package/dist/api/models/LoginResponse.js +1 -0
  32. package/dist/api/models/OnboardRequest.d.ts +27 -0
  33. package/dist/api/models/OnboardRequest.d.ts.map +1 -0
  34. package/dist/api/models/OnboardRequest.js +1 -0
  35. package/dist/api/models/OnboardResponse.d.ts +12 -0
  36. package/dist/api/models/OnboardResponse.d.ts.map +1 -0
  37. package/dist/api/models/OnboardResponse.js +1 -0
  38. package/dist/api/models/User.d.ts +15 -0
  39. package/dist/api/models/User.d.ts.map +1 -0
  40. package/dist/api/models/User.js +1 -0
  41. package/dist/api/models/ValidationError.d.ts +6 -0
  42. package/dist/api/models/ValidationError.d.ts.map +1 -0
  43. package/dist/api/models/ValidationError.js +1 -0
  44. package/dist/api/services/AuthService.d.ts +31 -0
  45. package/dist/api/services/AuthService.d.ts.map +1 -0
  46. package/dist/api/services/AuthService.js +53 -0
  47. package/dist/api/services/DefaultService.d.ts +10 -0
  48. package/dist/api/services/DefaultService.d.ts.map +1 -0
  49. package/dist/api/services/DefaultService.js +15 -0
  50. package/dist/config/index.d.ts +1 -0
  51. package/dist/config/index.d.ts.map +1 -0
  52. package/dist/config/index.js +1 -0
  53. package/dist/index.d.ts +4 -0
  54. package/dist/index.d.ts.map +1 -0
  55. package/dist/index.js +7 -0
  56. package/dist/stores/auth.d.ts +41 -0
  57. package/dist/stores/auth.d.ts.map +1 -0
  58. package/dist/stores/auth.js +58 -0
  59. package/dist/stores/index.d.ts +2 -0
  60. package/dist/stores/index.d.ts.map +1 -0
  61. package/dist/stores/index.js +2 -0
  62. package/dist/types/index.d.ts +1 -0
  63. package/dist/types/index.d.ts.map +1 -0
  64. package/dist/types/index.js +1 -0
  65. package/dist/utils/auth/supabase-config.d.ts +17 -0
  66. package/dist/utils/auth/supabase-config.d.ts.map +1 -0
  67. package/dist/utils/auth/supabase-config.js +44 -0
  68. package/dist/utils/index.d.ts +4 -0
  69. package/dist/utils/index.d.ts.map +1 -0
  70. package/dist/utils/index.js +3 -0
  71. package/dist/utils/validation/schemas.d.ts +40 -0
  72. package/dist/utils/validation/schemas.d.ts.map +1 -0
  73. package/dist/utils/validation/schemas.js +46 -0
  74. package/package.json +46 -0
package/README.md ADDED
@@ -0,0 +1,123 @@
1
+ # Shared SDK Setup Guide
2
+
3
+ A modular and reusable SDK for the Bid-Scents Marketplace, built with TypeScript, Zustand, and Zod. This SDK provides stores, API clients, and utilities shared across web and mobile apps. React Query is used in the consuming applications for data fetching.
4
+
5
+ ---
6
+
7
+ ## Quick Start
8
+
9
+ ### 1. Clone and Initialize
10
+ ```bash
11
+ git clone https://github.com/Shawarmaa/shared-sdk.git
12
+ cd shared-sdk
13
+ bun install # or npm install
14
+ ```
15
+
16
+ ### 2. Build the SDK
17
+ ```bash
18
+ bun run build
19
+ ```
20
+
21
+ ### 3. Regenerate the API (when backend is live)
22
+ ```bash
23
+ bun run generate-api
24
+ ```
25
+
26
+ ---
27
+
28
+ ## Project Structure
29
+
30
+ ```
31
+ shared-sdk/
32
+ ├── src/
33
+ │ ├── api/ # OpenAPI-generated client
34
+ │ ├── config/ # Configuration
35
+ │ ├── stores/ # Zustand stores (auth, listings, etc.)
36
+ │ ├── utils/ # Utility modules
37
+ │ ├── types/ # Shared types
38
+ │ └── index.ts # Main SDK export
39
+ ├── dist/ # Compiled output (auto-generated)
40
+ ├── tests/ # Future tests
41
+ ├── .gitignore
42
+ ├── package.json
43
+ ├── tsconfig.json
44
+ └── README.md
45
+ ```
46
+
47
+ ---
48
+
49
+ ## Available Scripts
50
+
51
+ ```json
52
+ "scripts": {
53
+ "build": "tsc",
54
+ "dev": "tsc --watch",
55
+ "clean": "rm -rf dist",
56
+ "generate-api": "openapi-typescript-codegen --input http://localhost:3000/api-docs --output src/api",
57
+ "prepublishOnly": "npm run clean && npm run build",
58
+ "test": "echo \"No tests yet\" && exit 0"
59
+ }
60
+ ```
61
+
62
+ ---
63
+
64
+ ## Dependencies
65
+
66
+ | Category | Packages |
67
+ |----------|----------|
68
+ | **Core** | `zustand`, `zod` |
69
+ | **Peer** | `react >= 18.0.0` |
70
+ | **Dev** | `typescript`, `@types/react`, `@types/node`, `openapi-typescript-codegen` |
71
+
72
+ ---
73
+
74
+ ## How It Works
75
+
76
+ - **Zustand** manages client-side state (auth, listings, etc.)
77
+ - **Zod** handles runtime schema validation
78
+ - **OpenAPI codegen** auto-generates `src/api` client functions from your backend
79
+ - **React Query** is used in consuming apps to handle remote data fetching
80
+ - All modules are re-exported from `src/index.ts` for clean usage
81
+
82
+ ## Usage in Apps
83
+
84
+ The SDK provides the building blocks, while apps handle data fetching:
85
+
86
+ ```typescript
87
+ // In your web/mobile app
88
+ import { apiClient, authStore } from '@bid-scents/shared-sdk'
89
+ import { useQuery } from '@tanstack/react-query'
90
+
91
+ // App-specific React Query hooks
92
+ const useListings = () => {
93
+ return useQuery({
94
+ queryKey: ['listings'],
95
+ queryFn: () => apiClient.getListings(),
96
+ // App-specific configuration
97
+ })
98
+ }
99
+
100
+ // Use SDK stores directly
101
+ const { user, login } = authStore()
102
+ ```
103
+
104
+ ---
105
+
106
+ ## Publishing
107
+
108
+ For scoped publishing to npm:
109
+
110
+ ```bash
111
+ npm login
112
+ npm publish --access public
113
+ ```
114
+
115
+ Make sure `package.json` has `"name": "@bid-scents/shared-sdk"` and correct `main`/`types`/`files`.
116
+
117
+ ---
118
+
119
+ ## Final Notes
120
+
121
+ Use this SDK to abstract business logic and API clients from your web and mobile apps. Keep stores small and focused, validate all inputs with Zod, and auto-generate API clients whenever your backend changes.
122
+
123
+ Apps should implement their own React Query hooks using the SDK's API client functions, allowing for app-specific caching strategies and data fetching patterns.
@@ -0,0 +1,11 @@
1
+ import type { ApiRequestOptions } from './ApiRequestOptions';
2
+ import type { ApiResult } from './ApiResult';
3
+ export declare class ApiError extends Error {
4
+ readonly url: string;
5
+ readonly status: number;
6
+ readonly statusText: string;
7
+ readonly body: any;
8
+ readonly request: ApiRequestOptions;
9
+ constructor(request: ApiRequestOptions, response: ApiResult, message: string);
10
+ }
11
+ //# sourceMappingURL=ApiError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiError.d.ts","sourceRoot":"","sources":["../../../src/api/core/ApiError.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,qBAAa,QAAS,SAAQ,KAAK;IAC/B,SAAgB,GAAG,EAAE,MAAM,CAAC;IAC5B,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,IAAI,EAAE,GAAG,CAAC;IAC1B,SAAgB,OAAO,EAAE,iBAAiB,CAAC;gBAE/B,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM;CAU/E"}
@@ -0,0 +1,11 @@
1
+ export class ApiError extends Error {
2
+ constructor(request, response, message) {
3
+ super(message);
4
+ this.name = 'ApiError';
5
+ this.url = response.url;
6
+ this.status = response.status;
7
+ this.statusText = response.statusText;
8
+ this.body = response.body;
9
+ this.request = request;
10
+ }
11
+ }
@@ -0,0 +1,14 @@
1
+ export type ApiRequestOptions = {
2
+ readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
3
+ readonly url: string;
4
+ readonly path?: Record<string, any>;
5
+ readonly cookies?: Record<string, any>;
6
+ readonly headers?: Record<string, any>;
7
+ readonly query?: Record<string, any>;
8
+ readonly formData?: Record<string, any>;
9
+ readonly body?: any;
10
+ readonly mediaType?: string;
11
+ readonly responseHeader?: string;
12
+ readonly errors?: Record<number, string>;
13
+ };
14
+ //# sourceMappingURL=ApiRequestOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiRequestOptions.d.ts","sourceRoot":"","sources":["../../../src/api/core/ApiRequestOptions.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,iBAAiB,GAAG;IAC5B,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;IAClF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACxC,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC;IACpB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5C,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ export type ApiResult = {
2
+ readonly url: string;
3
+ readonly ok: boolean;
4
+ readonly status: number;
5
+ readonly statusText: string;
6
+ readonly body: any;
7
+ };
8
+ //# sourceMappingURL=ApiResult.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiResult.d.ts","sourceRoot":"","sources":["../../../src/api/core/ApiResult.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,SAAS,GAAG;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC;CACtB,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ export declare class CancelError extends Error {
2
+ constructor(message: string);
3
+ get isCancelled(): boolean;
4
+ }
5
+ export interface OnCancel {
6
+ readonly isResolved: boolean;
7
+ readonly isRejected: boolean;
8
+ readonly isCancelled: boolean;
9
+ (cancelHandler: () => void): void;
10
+ }
11
+ export declare class CancelablePromise<T> implements Promise<T> {
12
+ #private;
13
+ constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void, onCancel: OnCancel) => void);
14
+ get [Symbol.toStringTag](): string;
15
+ then<TResult1 = T, TResult2 = never>(onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
16
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
17
+ finally(onFinally?: (() => void) | null): Promise<T>;
18
+ cancel(): void;
19
+ get isCancelled(): boolean;
20
+ }
21
+ //# sourceMappingURL=CancelablePromise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CancelablePromise.d.ts","sourceRoot":"","sources":["../../../src/api/core/CancelablePromise.ts"],"names":[],"mappings":"AAIA,qBAAa,WAAY,SAAQ,KAAK;gBAEtB,OAAO,EAAE,MAAM;IAK3B,IAAW,WAAW,IAAI,OAAO,CAEhC;CACJ;AAED,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAE9B,CAAC,aAAa,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CACrC;AAED,qBAAa,iBAAiB,CAAC,CAAC,CAAE,YAAW,OAAO,CAAC,CAAC,CAAC;;gBAU/C,QAAQ,EAAE,CACN,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,EAC5C,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,EAC9B,QAAQ,EAAE,QAAQ,KACjB,IAAI;IAiDb,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;IAEM,IAAI,CAAC,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,KAAK,EACtC,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,EACrE,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,GACxE,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAIxB,KAAK,CAAC,OAAO,GAAG,KAAK,EACxB,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,GACtE,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC;IAIhB,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC;IAIpD,MAAM,IAAI,IAAI;IAmBrB,IAAW,WAAW,IAAI,OAAO,CAEhC;CACJ"}
@@ -0,0 +1,111 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _CancelablePromise_isResolved, _CancelablePromise_isRejected, _CancelablePromise_isCancelled, _CancelablePromise_cancelHandlers, _CancelablePromise_promise, _CancelablePromise_resolve, _CancelablePromise_reject;
13
+ /* generated using openapi-typescript-codegen -- do not edit */
14
+ /* istanbul ignore file */
15
+ /* tslint:disable */
16
+ /* eslint-disable */
17
+ export class CancelError extends Error {
18
+ constructor(message) {
19
+ super(message);
20
+ this.name = 'CancelError';
21
+ }
22
+ get isCancelled() {
23
+ return true;
24
+ }
25
+ }
26
+ export class CancelablePromise {
27
+ constructor(executor) {
28
+ _CancelablePromise_isResolved.set(this, void 0);
29
+ _CancelablePromise_isRejected.set(this, void 0);
30
+ _CancelablePromise_isCancelled.set(this, void 0);
31
+ _CancelablePromise_cancelHandlers.set(this, void 0);
32
+ _CancelablePromise_promise.set(this, void 0);
33
+ _CancelablePromise_resolve.set(this, void 0);
34
+ _CancelablePromise_reject.set(this, void 0);
35
+ __classPrivateFieldSet(this, _CancelablePromise_isResolved, false, "f");
36
+ __classPrivateFieldSet(this, _CancelablePromise_isRejected, false, "f");
37
+ __classPrivateFieldSet(this, _CancelablePromise_isCancelled, false, "f");
38
+ __classPrivateFieldSet(this, _CancelablePromise_cancelHandlers, [], "f");
39
+ __classPrivateFieldSet(this, _CancelablePromise_promise, new Promise((resolve, reject) => {
40
+ __classPrivateFieldSet(this, _CancelablePromise_resolve, resolve, "f");
41
+ __classPrivateFieldSet(this, _CancelablePromise_reject, reject, "f");
42
+ const onResolve = (value) => {
43
+ if (__classPrivateFieldGet(this, _CancelablePromise_isResolved, "f") || __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f") || __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f")) {
44
+ return;
45
+ }
46
+ __classPrivateFieldSet(this, _CancelablePromise_isResolved, true, "f");
47
+ if (__classPrivateFieldGet(this, _CancelablePromise_resolve, "f"))
48
+ __classPrivateFieldGet(this, _CancelablePromise_resolve, "f").call(this, value);
49
+ };
50
+ const onReject = (reason) => {
51
+ if (__classPrivateFieldGet(this, _CancelablePromise_isResolved, "f") || __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f") || __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f")) {
52
+ return;
53
+ }
54
+ __classPrivateFieldSet(this, _CancelablePromise_isRejected, true, "f");
55
+ if (__classPrivateFieldGet(this, _CancelablePromise_reject, "f"))
56
+ __classPrivateFieldGet(this, _CancelablePromise_reject, "f").call(this, reason);
57
+ };
58
+ const onCancel = (cancelHandler) => {
59
+ if (__classPrivateFieldGet(this, _CancelablePromise_isResolved, "f") || __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f") || __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f")) {
60
+ return;
61
+ }
62
+ __classPrivateFieldGet(this, _CancelablePromise_cancelHandlers, "f").push(cancelHandler);
63
+ };
64
+ Object.defineProperty(onCancel, 'isResolved', {
65
+ get: () => __classPrivateFieldGet(this, _CancelablePromise_isResolved, "f"),
66
+ });
67
+ Object.defineProperty(onCancel, 'isRejected', {
68
+ get: () => __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f"),
69
+ });
70
+ Object.defineProperty(onCancel, 'isCancelled', {
71
+ get: () => __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f"),
72
+ });
73
+ return executor(onResolve, onReject, onCancel);
74
+ }), "f");
75
+ }
76
+ get [(_CancelablePromise_isResolved = new WeakMap(), _CancelablePromise_isRejected = new WeakMap(), _CancelablePromise_isCancelled = new WeakMap(), _CancelablePromise_cancelHandlers = new WeakMap(), _CancelablePromise_promise = new WeakMap(), _CancelablePromise_resolve = new WeakMap(), _CancelablePromise_reject = new WeakMap(), Symbol.toStringTag)]() {
77
+ return "Cancellable Promise";
78
+ }
79
+ then(onFulfilled, onRejected) {
80
+ return __classPrivateFieldGet(this, _CancelablePromise_promise, "f").then(onFulfilled, onRejected);
81
+ }
82
+ catch(onRejected) {
83
+ return __classPrivateFieldGet(this, _CancelablePromise_promise, "f").catch(onRejected);
84
+ }
85
+ finally(onFinally) {
86
+ return __classPrivateFieldGet(this, _CancelablePromise_promise, "f").finally(onFinally);
87
+ }
88
+ cancel() {
89
+ if (__classPrivateFieldGet(this, _CancelablePromise_isResolved, "f") || __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f") || __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f")) {
90
+ return;
91
+ }
92
+ __classPrivateFieldSet(this, _CancelablePromise_isCancelled, true, "f");
93
+ if (__classPrivateFieldGet(this, _CancelablePromise_cancelHandlers, "f").length) {
94
+ try {
95
+ for (const cancelHandler of __classPrivateFieldGet(this, _CancelablePromise_cancelHandlers, "f")) {
96
+ cancelHandler();
97
+ }
98
+ }
99
+ catch (error) {
100
+ console.warn('Cancellation threw an error', error);
101
+ return;
102
+ }
103
+ }
104
+ __classPrivateFieldGet(this, _CancelablePromise_cancelHandlers, "f").length = 0;
105
+ if (__classPrivateFieldGet(this, _CancelablePromise_reject, "f"))
106
+ __classPrivateFieldGet(this, _CancelablePromise_reject, "f").call(this, new CancelError('Request aborted'));
107
+ }
108
+ get isCancelled() {
109
+ return __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f");
110
+ }
111
+ }
@@ -0,0 +1,17 @@
1
+ import type { ApiRequestOptions } from './ApiRequestOptions';
2
+ type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
3
+ type Headers = Record<string, string>;
4
+ export type OpenAPIConfig = {
5
+ BASE: string;
6
+ VERSION: string;
7
+ WITH_CREDENTIALS: boolean;
8
+ CREDENTIALS: 'include' | 'omit' | 'same-origin';
9
+ TOKEN?: string | Resolver<string> | undefined;
10
+ USERNAME?: string | Resolver<string> | undefined;
11
+ PASSWORD?: string | Resolver<string> | undefined;
12
+ HEADERS?: Headers | Resolver<Headers> | undefined;
13
+ ENCODE_PATH?: ((path: string) => string) | undefined;
14
+ };
15
+ export declare const OpenAPI: OpenAPIConfig;
16
+ export {};
17
+ //# sourceMappingURL=OpenAPI.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenAPI.d.ts","sourceRoot":"","sources":["../../../src/api/core/OpenAPI.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAC9D,KAAK,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEtC,MAAM,MAAM,aAAa,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,EAAE,SAAS,GAAG,MAAM,GAAG,aAAa,CAAC;IAChD,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IACjD,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IACjD,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;IAClD,WAAW,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,SAAS,CAAC;CACxD,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,aAUrB,CAAC"}
@@ -0,0 +1,11 @@
1
+ export const OpenAPI = {
2
+ BASE: '/api',
3
+ VERSION: '1.0.0',
4
+ WITH_CREDENTIALS: false,
5
+ CREDENTIALS: 'include',
6
+ TOKEN: undefined,
7
+ USERNAME: undefined,
8
+ PASSWORD: undefined,
9
+ HEADERS: undefined,
10
+ ENCODE_PATH: undefined,
11
+ };
@@ -0,0 +1,31 @@
1
+ import type { ApiRequestOptions } from './ApiRequestOptions';
2
+ import type { ApiResult } from './ApiResult';
3
+ import { CancelablePromise } from './CancelablePromise';
4
+ import type { OnCancel } from './CancelablePromise';
5
+ import type { OpenAPIConfig } from './OpenAPI';
6
+ export declare const isDefined: <T>(value: T | null | undefined) => value is Exclude<T, null | undefined>;
7
+ export declare const isString: (value: any) => value is string;
8
+ export declare const isStringWithValue: (value: any) => value is string;
9
+ export declare const isBlob: (value: any) => value is Blob;
10
+ export declare const isFormData: (value: any) => value is FormData;
11
+ export declare const base64: (str: string) => string;
12
+ export declare const getQueryString: (params: Record<string, any>) => string;
13
+ export declare const getFormData: (options: ApiRequestOptions) => FormData | undefined;
14
+ type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
15
+ export declare const resolve: <T>(options: ApiRequestOptions, resolver?: T | Resolver<T>) => Promise<T | undefined>;
16
+ export declare const getHeaders: (config: OpenAPIConfig, options: ApiRequestOptions) => Promise<Headers>;
17
+ export declare const getRequestBody: (options: ApiRequestOptions) => any;
18
+ export declare const sendRequest: (config: OpenAPIConfig, options: ApiRequestOptions, url: string, body: any, formData: FormData | undefined, headers: Headers, onCancel: OnCancel) => Promise<Response>;
19
+ export declare const getResponseHeader: (response: Response, responseHeader?: string) => string | undefined;
20
+ export declare const getResponseBody: (response: Response) => Promise<any>;
21
+ export declare const catchErrorCodes: (options: ApiRequestOptions, result: ApiResult) => void;
22
+ /**
23
+ * Request method
24
+ * @param config The OpenAPI configuration object
25
+ * @param options The request options from the service
26
+ * @returns CancelablePromise<T>
27
+ * @throws ApiError
28
+ */
29
+ export declare const request: <T>(config: OpenAPIConfig, options: ApiRequestOptions) => CancelablePromise<T>;
30
+ export {};
31
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/api/core/request.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,KAAG,KAAK,IAAI,OAAO,CAAC,CAAC,EAAE,IAAI,GAAG,SAAS,CAE9F,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,OAAO,GAAG,KAAG,KAAK,IAAI,MAE9C,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,OAAO,GAAG,KAAG,KAAK,IAAI,MAEvD,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,OAAO,GAAG,KAAG,KAAK,IAAI,IAW5C,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,OAAO,GAAG,KAAG,KAAK,IAAI,QAEhD,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,KAAK,MAAM,KAAG,MAOpC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,MAgC5D,CAAC;AAqBF,eAAO,MAAM,WAAW,GAAI,SAAS,iBAAiB,KAAG,QAAQ,GAAG,SAyBnE,CAAC;AAEF,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAE9D,eAAO,MAAM,OAAO,GAAU,CAAC,EAAE,SAAS,iBAAiB,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAK9G,CAAC;AAEF,eAAO,MAAM,UAAU,GAAU,QAAQ,aAAa,EAAE,SAAS,iBAAiB,KAAG,OAAO,CAAC,OAAO,CAyCnG,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,SAAS,iBAAiB,KAAG,GAW3D,CAAC;AAEF,eAAO,MAAM,WAAW,GACpB,QAAQ,aAAa,EACrB,SAAS,iBAAiB,EAC1B,KAAK,MAAM,EACX,MAAM,GAAG,EACT,UAAU,QAAQ,GAAG,SAAS,EAC9B,SAAS,OAAO,EAChB,UAAU,QAAQ,KACnB,OAAO,CAAC,QAAQ,CAiBlB,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,UAAU,QAAQ,EAAE,iBAAiB,MAAM,KAAG,MAAM,GAAG,SAQxF,CAAC;AAEF,eAAO,MAAM,eAAe,GAAU,UAAU,QAAQ,KAAG,OAAO,CAAC,GAAG,CAkBrE,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,SAAS,iBAAiB,EAAE,QAAQ,SAAS,KAAG,IAgC/E,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,EAAE,QAAQ,aAAa,EAAE,SAAS,iBAAiB,KAAG,iBAAiB,CAAC,CAAC,CA6BjG,CAAC"}