@tammsyr/admin-api-client 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/ActivityLogs.d.ts +17 -0
  2. package/dist/ActivityLogs.d.ts.map +1 -0
  3. package/dist/ActivityLogs.js +38 -0
  4. package/dist/ActivityLogs.js.map +1 -0
  5. package/dist/Admins.d.ts +67 -0
  6. package/dist/Admins.d.ts.map +1 -0
  7. package/dist/Admins.js +124 -0
  8. package/dist/Admins.js.map +1 -0
  9. package/dist/AgentBranches.d.ts +67 -0
  10. package/dist/AgentBranches.d.ts.map +1 -0
  11. package/dist/AgentBranches.js +119 -0
  12. package/dist/AgentBranches.js.map +1 -0
  13. package/dist/AgentSettlements.d.ts +87 -0
  14. package/dist/AgentSettlements.d.ts.map +1 -0
  15. package/dist/AgentSettlements.js +151 -0
  16. package/dist/AgentSettlements.js.map +1 -0
  17. package/dist/Agents.d.ts +157 -0
  18. package/dist/Agents.d.ts.map +1 -0
  19. package/dist/Agents.js +264 -0
  20. package/dist/Agents.js.map +1 -0
  21. package/dist/Auth.d.ts +42 -0
  22. package/dist/Auth.d.ts.map +1 -0
  23. package/dist/Auth.js +84 -0
  24. package/dist/Auth.js.map +1 -0
  25. package/dist/Kyc.d.ts +47 -0
  26. package/dist/Kyc.d.ts.map +1 -0
  27. package/dist/Kyc.js +89 -0
  28. package/dist/Kyc.js.map +1 -0
  29. package/dist/Notifications.d.ts +47 -0
  30. package/dist/Notifications.d.ts.map +1 -0
  31. package/dist/Notifications.js +85 -0
  32. package/dist/Notifications.js.map +1 -0
  33. package/dist/Permissions.d.ts +57 -0
  34. package/dist/Permissions.d.ts.map +1 -0
  35. package/dist/Permissions.js +107 -0
  36. package/dist/Permissions.js.map +1 -0
  37. package/dist/Roles.d.ts +87 -0
  38. package/dist/Roles.d.ts.map +1 -0
  39. package/dist/Roles.js +158 -0
  40. package/dist/Roles.js.map +1 -0
  41. package/dist/Seed.d.ts +17 -0
  42. package/dist/Seed.d.ts.map +1 -0
  43. package/dist/Seed.js +40 -0
  44. package/dist/Seed.js.map +1 -0
  45. package/dist/data-contracts.d.ts +1105 -0
  46. package/dist/data-contracts.d.ts.map +1 -0
  47. package/dist/data-contracts.js +14 -0
  48. package/dist/data-contracts.js.map +1 -0
  49. package/dist/http-client.d.ts +43 -0
  50. package/dist/http-client.d.ts.map +1 -0
  51. package/dist/http-client.js +111 -0
  52. package/dist/http-client.js.map +1 -0
  53. package/dist/index.d.ts +80 -0
  54. package/dist/index.d.ts.map +1 -0
  55. package/dist/index.js +144 -0
  56. package/dist/index.js.map +1 -0
  57. package/package.json +9 -11
  58. package/ActivityLogs.ts +0 -41
  59. package/Admins.ts +0 -154
  60. package/AgentBranches.ts +0 -152
  61. package/AgentSettlements.ts +0 -204
  62. package/Agents.ts +0 -359
  63. package/Auth.ts +0 -100
  64. package/Kyc.ts +0 -107
  65. package/Notifications.ts +0 -101
  66. package/Permissions.ts +0 -130
  67. package/Roles.ts +0 -199
  68. package/Seed.ts +0 -48
  69. package/data-contracts.ts +0 -1283
  70. package/http-client.ts +0 -186
  71. package/index.ts +0 -157
package/http-client.ts DELETED
@@ -1,186 +0,0 @@
1
- /* eslint-disable */
2
- /* tslint:disable */
3
- // @ts-nocheck
4
- /*
5
- * ---------------------------------------------------------------
6
- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
7
- * ## ##
8
- * ## AUTHOR: acacode ##
9
- * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
10
- * ---------------------------------------------------------------
11
- */
12
-
13
- import type {
14
- AxiosInstance,
15
- AxiosRequestConfig,
16
- AxiosResponse,
17
- HeadersDefaults,
18
- ResponseType,
19
- } from "axios";
20
- import axios from "axios";
21
-
22
- export type QueryParamsType = Record<string | number, any>;
23
-
24
- export interface FullRequestParams
25
- extends Omit<AxiosRequestConfig, "data" | "params" | "url" | "responseType"> {
26
- /** set parameter to `true` for call `securityWorker` for this request */
27
- secure?: boolean;
28
- /** request path */
29
- path: string;
30
- /** content type of request body */
31
- type?: ContentType;
32
- /** query params */
33
- query?: QueryParamsType;
34
- /** format of response (i.e. response.json() -> format: "json") */
35
- format?: ResponseType;
36
- /** request body */
37
- body?: unknown;
38
- }
39
-
40
- export type RequestParams = Omit<
41
- FullRequestParams,
42
- "body" | "method" | "query" | "path"
43
- >;
44
-
45
- export interface ApiConfig<SecurityDataType = unknown>
46
- extends Omit<AxiosRequestConfig, "data" | "cancelToken"> {
47
- securityWorker?: (
48
- securityData: SecurityDataType | null,
49
- ) => Promise<AxiosRequestConfig | void> | AxiosRequestConfig | void;
50
- secure?: boolean;
51
- format?: ResponseType;
52
- }
53
-
54
- export enum ContentType {
55
- Json = "application/json",
56
- JsonApi = "application/vnd.api+json",
57
- FormData = "multipart/form-data",
58
- UrlEncoded = "application/x-www-form-urlencoded",
59
- Text = "text/plain",
60
- }
61
-
62
- export class HttpClient<SecurityDataType = unknown> {
63
- public instance: AxiosInstance;
64
- private securityData: SecurityDataType | null = null;
65
- private securityWorker?: ApiConfig<SecurityDataType>["securityWorker"];
66
- private secure?: boolean;
67
- private format?: ResponseType;
68
-
69
- constructor({
70
- securityWorker,
71
- secure,
72
- format,
73
- ...axiosConfig
74
- }: ApiConfig<SecurityDataType> = {}) {
75
- this.instance = axios.create({
76
- ...axiosConfig,
77
- baseURL: axiosConfig.baseURL || "http://localhost:3006/admin/v1",
78
- });
79
- this.secure = secure;
80
- this.format = format;
81
- this.securityWorker = securityWorker;
82
- }
83
-
84
- public setSecurityData = (data: SecurityDataType | null) => {
85
- this.securityData = data;
86
- };
87
-
88
- protected mergeRequestParams(
89
- params1: AxiosRequestConfig,
90
- params2?: AxiosRequestConfig,
91
- ): AxiosRequestConfig {
92
- const method = params1.method || (params2 && params2.method);
93
-
94
- return {
95
- ...this.instance.defaults,
96
- ...params1,
97
- ...(params2 || {}),
98
- headers: {
99
- ...((method &&
100
- this.instance.defaults.headers[
101
- method.toLowerCase() as keyof HeadersDefaults
102
- ]) ||
103
- {}),
104
- ...(params1.headers || {}),
105
- ...((params2 && params2.headers) || {}),
106
- },
107
- };
108
- }
109
-
110
- protected stringifyFormItem(formItem: unknown) {
111
- if (typeof formItem === "object" && formItem !== null) {
112
- return JSON.stringify(formItem);
113
- } else {
114
- return `${formItem}`;
115
- }
116
- }
117
-
118
- protected createFormData(input: Record<string, unknown>): FormData {
119
- if (input instanceof FormData) {
120
- return input;
121
- }
122
- return Object.keys(input || {}).reduce((formData, key) => {
123
- const property = input[key];
124
- const propertyContent: any[] =
125
- property instanceof Array ? property : [property];
126
-
127
- for (const formItem of propertyContent) {
128
- const isFileType = formItem instanceof Blob || formItem instanceof File;
129
- formData.append(
130
- key,
131
- isFileType ? formItem : this.stringifyFormItem(formItem),
132
- );
133
- }
134
-
135
- return formData;
136
- }, new FormData());
137
- }
138
-
139
- public request = async <T = any, _E = any>({
140
- secure,
141
- path,
142
- type,
143
- query,
144
- format,
145
- body,
146
- ...params
147
- }: FullRequestParams): Promise<AxiosResponse<T>> => {
148
- const secureParams =
149
- ((typeof secure === "boolean" ? secure : this.secure) &&
150
- this.securityWorker &&
151
- (await this.securityWorker(this.securityData))) ||
152
- {};
153
- const requestParams = this.mergeRequestParams(params, secureParams);
154
- const responseFormat = format || this.format || undefined;
155
-
156
- if (
157
- type === ContentType.FormData &&
158
- body &&
159
- body !== null &&
160
- typeof body === "object"
161
- ) {
162
- body = this.createFormData(body as Record<string, unknown>);
163
- }
164
-
165
- if (
166
- type === ContentType.Text &&
167
- body &&
168
- body !== null &&
169
- typeof body !== "string"
170
- ) {
171
- body = JSON.stringify(body);
172
- }
173
-
174
- return this.instance.request({
175
- ...requestParams,
176
- headers: {
177
- ...(requestParams.headers || {}),
178
- ...(type ? { "Content-Type": type } : {}),
179
- },
180
- params: query,
181
- responseType: responseFormat,
182
- data: body,
183
- url: path,
184
- });
185
- };
186
- }
package/index.ts DELETED
@@ -1,157 +0,0 @@
1
- /**
2
- * @tammsyr/admin-api-client
3
- *
4
- * TypeScript client for TAMM Admin Service API
5
- * Auto-generated from OpenAPI specification
6
- *
7
- * @example
8
- * ```typescript
9
- * import { AdminApiClient } from '@tammsyr/admin-api-client';
10
- *
11
- * const client = new AdminApiClient({
12
- * baseURL: 'http://localhost:3006',
13
- * token: 'your-jwt-token'
14
- * });
15
- *
16
- * const admins = await client.admins.getAll();
17
- * ```
18
- */
19
-
20
- // Export HTTP client
21
- export { HttpClient, ContentType } from './http-client';
22
- export type {
23
- FullRequestParams,
24
- RequestParams,
25
- ApiConfig,
26
- QueryParamsType,
27
- } from './http-client';
28
-
29
- // Export all API classes
30
- export { Admins } from './Admins';
31
- export { Auth } from './Auth';
32
- export { Roles } from './Roles';
33
- export { Permissions } from './Permissions';
34
- export { Agents } from './Agents';
35
- export { AgentBranches } from './AgentBranches';
36
- export { AgentSettlements } from './AgentSettlements';
37
- export { Kyc } from './Kyc';
38
- export { Notifications } from './Notifications';
39
- export { ActivityLogs } from './ActivityLogs';
40
- export { Seed } from './Seed';
41
-
42
- // Export all types
43
- export * from './data-contracts';
44
-
45
- // Main client class for convenience
46
- import { HttpClient } from './http-client';
47
- import { Admins } from './Admins';
48
- import { Auth } from './Auth';
49
- import { Roles } from './Roles';
50
- import { Permissions } from './Permissions';
51
- import { Agents } from './Agents';
52
- import { AgentBranches } from './AgentBranches';
53
- import { AgentSettlements } from './AgentSettlements';
54
- import { Kyc } from './Kyc';
55
- import { Notifications } from './Notifications';
56
- import { ActivityLogs } from './ActivityLogs';
57
- import { Seed } from './Seed';
58
-
59
- export interface AdminApiClientConfig {
60
- baseURL?: string;
61
- timeout?: number;
62
- token?: string;
63
- headers?: Record<string, string>;
64
- }
65
-
66
- export class AdminApiClient {
67
- public readonly httpClient: HttpClient;
68
- public readonly admins: Admins;
69
- public readonly auth: Auth;
70
- public readonly roles: Roles;
71
- public readonly permissions: Permissions;
72
- public readonly agents: Agents;
73
- public readonly agentBranches: AgentBranches;
74
- public readonly agentSettlements: AgentSettlements;
75
- public readonly kyc: Kyc;
76
- public readonly notifications: Notifications;
77
- public readonly activityLogs: ActivityLogs;
78
- public readonly seed: Seed;
79
-
80
- constructor(config: AdminApiClientConfig = {}) {
81
- const {
82
- baseURL = 'http://localhost:3006',
83
- timeout = 10000,
84
- token,
85
- headers = {},
86
- } = config;
87
-
88
- this._token = token || null;
89
-
90
- this.httpClient = new HttpClient({
91
- baseURL,
92
- timeout,
93
- headers: {
94
- 'Content-Type': 'application/json',
95
- ...headers,
96
- },
97
- securityWorker: async (authData) => {
98
- const currentToken = this._token || (authData as any)?.token;
99
- if (currentToken) {
100
- return {
101
- headers: {
102
- Authorization: `Bearer ${currentToken}`,
103
- },
104
- };
105
- }
106
- return {};
107
- },
108
- secure: !!token,
109
- });
110
-
111
- // Set initial security data if token provided
112
- if (token) {
113
- this.httpClient.setSecurityData({ token } as any);
114
- }
115
-
116
- // Initialize all API classes
117
- this.admins = new Admins(this.httpClient);
118
- this.auth = new Auth(this.httpClient);
119
- this.roles = new Roles(this.httpClient);
120
- this.permissions = new Permissions(this.httpClient);
121
- this.agents = new Agents(this.httpClient);
122
- this.agentBranches = new AgentBranches(this.httpClient);
123
- this.agentSettlements = new AgentSettlements(this.httpClient);
124
- this.kyc = new Kyc(this.httpClient);
125
- this.notifications = new Notifications(this.httpClient);
126
- this.activityLogs = new ActivityLogs(this.httpClient);
127
- this.seed = new Seed(this.httpClient);
128
- }
129
-
130
- private _token: string | null = null;
131
-
132
- /**
133
- * Update authentication token
134
- */
135
- setToken(token: string): void {
136
- this._token = token;
137
- this.httpClient.setSecurityData({ token } as any);
138
- }
139
-
140
- /**
141
- * Clear authentication token
142
- */
143
- clearToken(): void {
144
- this._token = null;
145
- this.httpClient.setSecurityData(null);
146
- }
147
-
148
- /**
149
- * Get current token
150
- */
151
- getToken(): string | null {
152
- return this._token;
153
- }
154
- }
155
-
156
- // Default export for convenience
157
- export default AdminApiClient;