@fecommunity/reactpress-toolkit 1.0.0-beta.1 → 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 (130) hide show
  1. package/README.md +405 -0
  2. package/dist/Article.d.ts +121 -0
  3. package/dist/Article.js +189 -0
  4. package/dist/Auth.d.ts +30 -0
  5. package/dist/Auth.js +59 -0
  6. package/dist/Category.d.ts +49 -0
  7. package/dist/Category.js +85 -0
  8. package/dist/Comment.d.ts +58 -0
  9. package/dist/Comment.js +98 -0
  10. package/dist/File.d.ts +40 -0
  11. package/dist/File.js +72 -0
  12. package/dist/HttpClient.d.ts +41 -0
  13. package/dist/HttpClient.js +94 -0
  14. package/dist/Knowledge.d.ts +76 -0
  15. package/dist/Knowledge.js +124 -0
  16. package/dist/Page.d.ts +58 -0
  17. package/dist/Page.js +98 -0
  18. package/dist/Search.d.ts +30 -0
  19. package/dist/Search.js +59 -0
  20. package/dist/Setting.d.ts +22 -0
  21. package/dist/Setting.js +46 -0
  22. package/dist/Smtp.d.ts +31 -0
  23. package/dist/Smtp.js +59 -0
  24. package/dist/Tag.d.ts +58 -0
  25. package/dist/Tag.js +98 -0
  26. package/dist/User.d.ts +41 -0
  27. package/dist/User.js +73 -0
  28. package/dist/View.d.ts +49 -0
  29. package/dist/View.js +85 -0
  30. package/dist/api/ApiInstance.d.ts +39 -0
  31. package/dist/api/ApiInstance.js +46 -0
  32. package/dist/api/Article.d.ts +44 -29
  33. package/dist/api/Article.js +42 -31
  34. package/dist/api/ArticleRoute.d.ts +201 -0
  35. package/dist/api/ArticleRoute.js +12 -0
  36. package/dist/api/Auth.d.ts +11 -6
  37. package/dist/api/Auth.js +10 -8
  38. package/dist/api/AuthRoute.d.ts +44 -0
  39. package/dist/api/AuthRoute.js +12 -0
  40. package/dist/api/Category.d.ts +20 -13
  41. package/dist/api/Category.js +18 -15
  42. package/dist/api/CategoryRoute.d.ts +79 -0
  43. package/dist/api/CategoryRoute.js +12 -0
  44. package/dist/api/Comment.d.ts +22 -14
  45. package/dist/api/Comment.js +20 -16
  46. package/dist/api/CommentRoute.d.ts +95 -0
  47. package/dist/api/CommentRoute.js +12 -0
  48. package/dist/api/File.d.ts +16 -10
  49. package/dist/api/File.js +14 -12
  50. package/dist/api/FileRoute.d.ts +63 -0
  51. package/dist/api/FileRoute.js +12 -0
  52. package/dist/api/Knowledge.d.ts +29 -19
  53. package/dist/api/Knowledge.js +27 -22
  54. package/dist/api/KnowledgeRoute.d.ts +125 -0
  55. package/dist/api/KnowledgeRoute.js +12 -0
  56. package/dist/api/Page.d.ts +23 -15
  57. package/dist/api/Page.js +21 -17
  58. package/dist/api/PageRoute.d.ts +95 -0
  59. package/dist/api/PageRoute.js +12 -0
  60. package/dist/api/Search.d.ts +12 -7
  61. package/dist/api/Search.js +11 -9
  62. package/dist/api/SearchRoute.d.ts +46 -0
  63. package/dist/api/SearchRoute.js +12 -0
  64. package/dist/api/Setting.d.ts +10 -6
  65. package/dist/api/Setting.js +8 -8
  66. package/dist/api/SettingRoute.d.ts +31 -0
  67. package/dist/api/SettingRoute.js +12 -0
  68. package/dist/api/Smtp.d.ts +14 -9
  69. package/dist/api/Smtp.js +12 -11
  70. package/dist/api/SmtpRoute.d.ts +47 -0
  71. package/dist/api/SmtpRoute.js +12 -0
  72. package/dist/api/Tag.d.ts +22 -14
  73. package/dist/api/Tag.js +20 -16
  74. package/dist/api/TagRoute.d.ts +95 -0
  75. package/dist/api/TagRoute.js +12 -0
  76. package/dist/api/User.d.ts +15 -8
  77. package/dist/api/User.js +13 -13
  78. package/dist/api/UserRoute.d.ts +60 -0
  79. package/dist/api/UserRoute.js +12 -0
  80. package/dist/api/View.d.ts +19 -12
  81. package/dist/api/View.js +17 -14
  82. package/dist/api/ViewRoute.d.ts +77 -0
  83. package/dist/api/ViewRoute.js +12 -0
  84. package/dist/api/httpClient.d.ts +5 -5
  85. package/dist/api/httpClient.js +4 -2
  86. package/dist/api/index.d.ts +13 -18
  87. package/dist/api/index.js +28 -41
  88. package/dist/api/instance.d.ts +47 -0
  89. package/dist/api/instance.js +71 -0
  90. package/dist/data-contracts.d.ts +245 -0
  91. package/dist/data-contracts.js +12 -0
  92. package/dist/index.d.ts +5 -9
  93. package/dist/index.js +16 -21
  94. package/dist/types/index.d.ts +245 -1
  95. package/dist/types/index.js +10 -17
  96. package/dist/utils/common.d.ts +1 -3
  97. package/dist/utils/common.js +5 -31
  98. package/dist/utils/http.js +4 -6
  99. package/dist/utils/index.d.ts +33 -2
  100. package/dist/utils/index.js +57 -18
  101. package/package.json +11 -6
  102. package/demos/simple.ts +0 -65
  103. package/scripts/generate-api-types.js +0 -571
  104. package/scripts/generate-swagger.js +0 -47
  105. package/scripts/organize-api.js +0 -136
  106. package/src/api/Article.ts +0 -186
  107. package/src/api/Auth.ts +0 -54
  108. package/src/api/Category.ts +0 -82
  109. package/src/api/Comment.ts +0 -95
  110. package/src/api/File.ts +0 -69
  111. package/src/api/Knowledge.ts +0 -122
  112. package/src/api/Page.ts +0 -95
  113. package/src/api/Search.ts +0 -54
  114. package/src/api/Setting.ts +0 -43
  115. package/src/api/Smtp.ts +0 -56
  116. package/src/api/Tag.ts +0 -95
  117. package/src/api/User.ts +0 -72
  118. package/src/api/View.ts +0 -82
  119. package/src/api/api-instance.ts +0 -69
  120. package/src/api/httpClient.ts +0 -140
  121. package/src/api/index.ts +0 -25
  122. package/src/index.ts +0 -18
  123. package/src/types/data-contracts.ts +0 -198
  124. package/src/types/index.ts +0 -4
  125. package/src/utils/common.ts +0 -108
  126. package/src/utils/http.ts +0 -52
  127. package/src/utils/index.ts +0 -5
  128. package/test-final.js +0 -56
  129. package/test-import.js +0 -34
  130. package/tsconfig.json +0 -20
@@ -1,140 +0,0 @@
1
- /* eslint-disable */
2
- /* tslint:disable */
3
- /*
4
- * ---------------------------------------------------------------
5
- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
6
- * ## ##
7
- * ## AUTHOR: acacode ##
8
- * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
9
- * ---------------------------------------------------------------
10
- */
11
-
12
- import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, HeadersDefaults, ResponseType } from 'axios';
13
-
14
- export type QueryParamsType = Record<string | number, any>;
15
-
16
- export interface FullRequestParams extends Omit<AxiosRequestConfig, 'data' | 'params' | 'url' | 'responseType'> {
17
- /** set parameter to `true` for call `securityWorker` for this request */
18
- secure?: boolean;
19
- /** request path */
20
- path: string;
21
- /** content type of request body */
22
- type?: ContentType;
23
- /** query params */
24
- query?: QueryParamsType;
25
- /** format of response (i.e. response.json() -> format: "json") */
26
- format?: ResponseType;
27
- /** request body */
28
- body?: unknown;
29
- }
30
-
31
- export type RequestParams = Omit<FullRequestParams, 'body' | 'method' | 'query' | 'path'>;
32
-
33
- export interface HttpClientConfig<SecurityDataType = unknown> extends Omit<AxiosRequestConfig, 'data' | 'cancelToken'> {
34
- securityWorker?: (
35
- securityData: SecurityDataType | null
36
- ) => Promise<AxiosRequestConfig | void> | AxiosRequestConfig | void;
37
- secure?: boolean;
38
- format?: ResponseType;
39
- }
40
-
41
- export enum ContentType {
42
- Json = 'application/json',
43
- FormData = 'multipart/form-data',
44
- UrlEncoded = 'application/x-www-form-urlencoded',
45
- Text = 'text/plain',
46
- }
47
-
48
- export class HttpClient<SecurityDataType = unknown> {
49
- public instance: AxiosInstance;
50
- private securityData: SecurityDataType | null = null;
51
- public securityWorker?: HttpClientConfig<SecurityDataType>['securityWorker'];
52
- private secure?: boolean;
53
- private format?: ResponseType;
54
-
55
- constructor({ securityWorker, secure, format, ...axiosConfig }: HttpClientConfig<SecurityDataType> = {}) {
56
- this.instance = axios.create({ ...axiosConfig, baseURL: axiosConfig.baseURL || 'http://localhost:3002' });
57
- this.secure = secure;
58
- this.format = format;
59
- this.securityWorker = securityWorker;
60
- }
61
-
62
- public setSecurityData = (data: SecurityDataType | null) => {
63
- this.securityData = data;
64
- };
65
-
66
- protected mergeRequestParams(params1: AxiosRequestConfig, params2?: AxiosRequestConfig): AxiosRequestConfig {
67
- const method = params1.method || (params2 && params2.method);
68
-
69
- return {
70
- ...this.instance.defaults,
71
- ...params1,
72
- ...(params2 || {}),
73
- headers: {
74
- ...((method && this.instance.defaults.headers[method.toLowerCase() as keyof HeadersDefaults]) || {}),
75
- ...(params1.headers || {}),
76
- ...((params2 && params2.headers) || {}),
77
- },
78
- };
79
- }
80
-
81
- protected stringifyFormItem(formItem: unknown) {
82
- if (typeof formItem === 'object' && formItem !== null) {
83
- return JSON.stringify(formItem);
84
- } else {
85
- return `${formItem}`;
86
- }
87
- }
88
-
89
- protected createFormData(input: Record<string, unknown>): FormData {
90
- return Object.keys(input || {}).reduce((formData, key) => {
91
- const property = input[key];
92
- const propertyContent: any[] = property instanceof Array ? property : [property];
93
-
94
- for (const formItem of propertyContent) {
95
- const isFileType = formItem instanceof Blob || formItem instanceof File;
96
- formData.append(key, isFileType ? formItem : this.stringifyFormItem(formItem));
97
- }
98
-
99
- return formData;
100
- }, new FormData());
101
- }
102
-
103
- public request = async <T = any, _E = any>({
104
- secure,
105
- path,
106
- type,
107
- query,
108
- format,
109
- body,
110
- ...params
111
- }: FullRequestParams): Promise<AxiosResponse<T>> => {
112
- const secureParams =
113
- ((typeof secure === 'boolean' ? secure : this.secure) &&
114
- this.securityWorker &&
115
- (await this.securityWorker(this.securityData))) ||
116
- {};
117
- const requestParams = this.mergeRequestParams(params, secureParams);
118
- const responseFormat = format || this.format || undefined;
119
-
120
- if (type === ContentType.FormData && body && body !== null && typeof body === 'object') {
121
- body = this.createFormData(body as Record<string, unknown>);
122
- }
123
-
124
- if (type === ContentType.Text && body && body !== null && typeof body !== 'string') {
125
- body = JSON.stringify(body);
126
- }
127
-
128
- return this.instance.request({
129
- ...requestParams,
130
- headers: {
131
- ...(requestParams.headers || {}),
132
- ...(type && type !== ContentType.FormData ? { 'Content-Type': type } : {}),
133
- },
134
- params: query,
135
- responseType: responseFormat,
136
- data: body,
137
- url: path,
138
- });
139
- };
140
- }
package/src/api/index.ts DELETED
@@ -1,25 +0,0 @@
1
- // API 客户端索引
2
- // 自动生成,请勿手动修改
3
-
4
- export * from './Article';
5
- export * from './Auth';
6
- export * from './Category';
7
- export * from './Comment';
8
- export * from './File';
9
- export * from './Knowledge';
10
- export * from './Page';
11
- export * from './Search';
12
- export * from './Setting';
13
- export * from './Smtp';
14
- export * from './Tag';
15
- export * from './User';
16
- export * from './View';
17
- export * from './httpClient';
18
-
19
- // 导出HttpClient类而不是默认导出
20
- export { HttpClient } from './httpClient';
21
- export type { HttpClientConfig } from './httpClient';
22
-
23
- // API 实例化
24
- export * from './api-instance';
25
- export { default as api } from './api-instance';
package/src/index.ts DELETED
@@ -1,18 +0,0 @@
1
- // Auto-generated API client
2
- // Generated from Swagger/OpenAPI specification
3
-
4
- import * as api from './api';
5
- import * as types from './types';
6
- import * as utils from './utils';
7
- import apiInstance from './api/api-instance';
8
-
9
- // Export namespaces
10
- export { api, types, utils };
11
-
12
- // Export default API instance
13
- export { apiInstance as default };
14
-
15
- // Also export individual items for backward compatibility
16
- export * from './api';
17
- export * from './types';
18
- export * from './utils';
@@ -1,198 +0,0 @@
1
- /* eslint-disable */
2
- /* tslint:disable */
3
- /*
4
- * ---------------------------------------------------------------
5
- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
6
- * ## ##
7
- * ## AUTHOR: acacode ##
8
- * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
9
- * ---------------------------------------------------------------
10
- */
11
-
12
- export interface IUser {
13
- name: string;
14
- password: string;
15
- avatar: string;
16
- email: string;
17
- role: string;
18
- status: string;
19
- type: string;
20
- /** @format date-time */
21
- createAt: string;
22
- /** @format date-time */
23
- updateAt: string;
24
- }
25
-
26
- export interface ISetting {
27
- id: string;
28
- i18n: string;
29
- globalSetting: string;
30
- systemUrl: string;
31
- systemTitle: string;
32
- systemSubTitle: string;
33
- systemLogo: string;
34
- systemBg: string;
35
- systemFavicon: string;
36
- systemNoticeInfo: string;
37
- systemFooterInfo: string;
38
- adminSystemUrl: string;
39
- baiduAnalyticsId: string;
40
- googleAnalyticsId: string;
41
- seoKeyword: string;
42
- seoDesc: string;
43
- oss: string;
44
- smtpHost: string;
45
- smtpPort: string;
46
- smtpUser: string;
47
- smtpPass: string;
48
- smtpFromUser: string;
49
- /** @format date-time */
50
- createAt: string;
51
- /** @format date-time */
52
- updateAt: string;
53
- }
54
-
55
- export interface I_SMTP {
56
- id: string;
57
- from: string;
58
- to: string;
59
- subject: string;
60
- text: string;
61
- html: string;
62
- /** @format date-time */
63
- createAt: string;
64
- }
65
-
66
- export interface IFile {
67
- id: string;
68
- originalname: string;
69
- filename: string;
70
- type: string;
71
- size: number;
72
- url: string;
73
- /** @format date-time */
74
- createAt: string;
75
- }
76
-
77
- export interface ITag {
78
- label: string;
79
- value: string;
80
- articles: string[];
81
- /** @format date-time */
82
- createAt: string;
83
- /** @format date-time */
84
- updateAt: string;
85
- }
86
-
87
- export interface ICategory {
88
- id: string;
89
- label: string;
90
- value: string;
91
- articles: string[];
92
- /** @format date-time */
93
- createAt: string;
94
- /** @format date-time */
95
- updateAt: string;
96
- }
97
-
98
- export interface IArticle {
99
- id: string;
100
- title: string;
101
- cover: string;
102
- summary: string;
103
- content: string;
104
- html: string;
105
- toc: string;
106
- category: ICategory;
107
- tags: string[];
108
- status: string;
109
- views: number;
110
- likes: number;
111
- isRecommended: boolean;
112
- password: string;
113
- needPassword: boolean;
114
- isCommentable: boolean;
115
- /** @format date-time */
116
- publishAt: string;
117
- /** @format date-time */
118
- createAt: string;
119
- /** @format date-time */
120
- updateAt: string;
121
- }
122
-
123
- export interface IKnowledge {
124
- id: string;
125
- parentId: string;
126
- order: number;
127
- title: string;
128
- cover: string;
129
- summary: string;
130
- content: string;
131
- html: string;
132
- toc: string;
133
- status: string;
134
- views: number;
135
- likes: number;
136
- isCommentable: boolean;
137
- /** @format date-time */
138
- publishAt: string;
139
- /** @format date-time */
140
- createAt: string;
141
- /** @format date-time */
142
- updateAt: string;
143
- }
144
-
145
- export interface IComment {
146
- id: string;
147
- name: string;
148
- email: string;
149
- avatar: string;
150
- content: string;
151
- html: string;
152
- pass: boolean;
153
- userAgent: string;
154
- hostId: string;
155
- url: string;
156
- parentCommentId: string;
157
- replyUserName: string;
158
- replyUserEmail: string;
159
- /** @format date-time */
160
- createAt: string;
161
- /** @format date-time */
162
- updateAt: string;
163
- }
164
-
165
- export interface IPage {
166
- id: string;
167
- cover: string;
168
- name: string;
169
- path: string;
170
- order: number;
171
- content: string;
172
- html: string;
173
- toc: string;
174
- status: string;
175
- /** @format date-time */
176
- publishAt: string;
177
- views: number;
178
- /** @format date-time */
179
- createAt: string;
180
- /** @format date-time */
181
- updateAt: string;
182
- }
183
-
184
- export interface IView {
185
- ip: string;
186
- userAgent: string;
187
- url: string;
188
- count: number;
189
- address: string;
190
- browser: string;
191
- engine: string;
192
- os: string;
193
- device: string;
194
- /** @format date-time */
195
- createAt: string;
196
- /** @format date-time */
197
- updateAt: string;
198
- }
@@ -1,4 +0,0 @@
1
- // 类型定义索引
2
- // 自动生成,请勿手动修改
3
-
4
- export * from './data-contracts';
@@ -1,108 +0,0 @@
1
- // 通用工具函数
2
-
3
- // 日期格式化
4
- export const formatDate = (date: Date, format: string = 'YYYY-MM-DD'): string => {
5
- const year = date.getFullYear();
6
- const month = String(date.getMonth() + 1).padStart(2, '0');
7
- const day = String(date.getDate()).padStart(2, '0');
8
-
9
- return format
10
- .replace('YYYY', String(year))
11
- .replace('MM', month)
12
- .replace('DD', day);
13
- };
14
-
15
- // 深度克隆
16
- export const deepClone = <T>(obj: T): T => {
17
- if (obj === null || typeof obj !== 'object') {
18
- return obj;
19
- }
20
-
21
- if (obj instanceof Date) {
22
- return new Date(obj.getTime()) as unknown as T;
23
- }
24
-
25
- if (Array.isArray(obj)) {
26
- return obj.map(item => deepClone(item)) as unknown as T;
27
- }
28
-
29
- if (typeof obj === 'object') {
30
- const cloned = {} as T;
31
- for (const key in obj) {
32
- if (obj.hasOwnProperty(key)) {
33
- cloned[key] = deepClone(obj[key]);
34
- }
35
- }
36
- return cloned;
37
- }
38
-
39
- return obj;
40
- };
41
-
42
- // 防抖函数
43
- export const debounce = <T extends (...args: any[]) => any>(
44
- func: T,
45
- wait: number
46
- ): ((...args: Parameters<T>) => void) => {
47
- let timeout: NodeJS.Timeout | null = null;
48
-
49
- return (...args: Parameters<T>) => {
50
- if (timeout) {
51
- clearTimeout(timeout);
52
- }
53
-
54
- timeout = setTimeout(() => {
55
- func(...args);
56
- }, wait);
57
- };
58
- };
59
-
60
- // 节流函数
61
- export const throttle = <T extends (...args: any[]) => any>(
62
- func: T,
63
- limit: number
64
- ): ((...args: Parameters<T>) => void) => {
65
- let inThrottle: boolean = false;
66
-
67
- return (...args: Parameters<T>) => {
68
- if (!inThrottle) {
69
- func(...args);
70
- inThrottle = true;
71
- setTimeout(() => (inThrottle = false), limit);
72
- }
73
- };
74
- };
75
-
76
- // 检查是否为ApiError
77
- export const isApiError = (error: any): error is ApiError => {
78
- return error instanceof ApiError || (error && typeof error === 'object' && 'code' in error && 'message' in error);
79
- };
80
-
81
- // API 响应处理
82
- export interface ApiResponse<T = any> {
83
- code: number;
84
- message: string;
85
- data: T;
86
- timestamp: number;
87
- }
88
-
89
- // 分页响应
90
- export interface PaginatedResponse<T = any> {
91
- items: T[];
92
- total: number;
93
- page: number;
94
- limit: number;
95
- totalPages: number;
96
- }
97
-
98
- // 错误处理
99
- export class ApiError extends Error {
100
- constructor(
101
- public code: number,
102
- message: string,
103
- public details?: any
104
- ) {
105
- super(message);
106
- this.name = 'ApiError';
107
- }
108
- }
package/src/utils/http.ts DELETED
@@ -1,52 +0,0 @@
1
- import axios, { InternalAxiosRequestConfig, AxiosResponse } from 'axios';
2
-
3
- // 创建自定义 axios 实例
4
- export const createHttpClient = (baseURL?: string) => {
5
- const instance = axios.create({
6
- baseURL: baseURL || process.env.API_BASE_URL || 'http://localhost:3002',
7
- timeout: 30000,
8
- headers: {
9
- 'Content-Type': 'application/json',
10
- },
11
- });
12
-
13
- // 请求拦截器
14
- instance.interceptors.request.use(
15
- (config: InternalAxiosRequestConfig) => {
16
- // 添加认证令牌
17
- const token = typeof window !== 'undefined' ? localStorage.getItem('auth_token') : null;
18
- if (token && config.headers) {
19
- config.headers.Authorization = `Bearer ${token}`;
20
- }
21
- return config;
22
- },
23
- (error) => {
24
- return Promise.reject(error);
25
- }
26
- );
27
-
28
- // 响应拦截器
29
- instance.interceptors.response.use(
30
- (response: AxiosResponse) => {
31
- return response.data;
32
- },
33
- (error) => {
34
- // 统一错误处理
35
- if (error.response?.status === 401) {
36
- // 未授权处理
37
- if (typeof window !== 'undefined') {
38
- localStorage.removeItem('auth_token');
39
- window.location.href = '/login';
40
- }
41
- }
42
- return Promise.reject(error.response?.data || error);
43
- }
44
- );
45
-
46
- return instance;
47
- };
48
-
49
- // 默认 HTTP 客户端实例
50
- export const httpClient = createHttpClient();
51
-
52
- export default httpClient;
@@ -1,5 +0,0 @@
1
- // 工具函数索引
2
- // 自动生成,请勿手动修改
3
-
4
- export * from './http';
5
- export * from './common';
package/test-final.js DELETED
@@ -1,56 +0,0 @@
1
- const { api, types, utils } = require('./dist');
2
-
3
- console.log('Testing final toolkit usage...');
4
-
5
- // Test that namespaces exist
6
- console.log('✅ api namespace exists:', !!api);
7
- console.log('✅ types namespace exists:', !!types);
8
- console.log('✅ utils namespace exists:', !!utils);
9
-
10
- // Test utils functions
11
- console.log('\nTesting utils functions...');
12
-
13
- // Test formatDate
14
- const date = new Date('2023-01-01');
15
- const formattedDate = utils.formatDate(date, 'YYYY年MM月DD日');
16
- console.log('✅ formatDate works:', formattedDate);
17
-
18
- // Test deepClone
19
- const original = { name: 'test', profile: { age: 30 } };
20
- const cloned = utils.deepClone(original);
21
- console.log('✅ deepClone works:', JSON.stringify(cloned));
22
-
23
- // Test debounce
24
- const debouncedFunc = utils.debounce((value) => {
25
- console.log('Debounced function called with:', value);
26
- }, 100);
27
-
28
- console.log('✅ debounce function exists:', typeof debouncedFunc === 'function');
29
-
30
- // Test throttle
31
- const throttledFunc = utils.throttle((value) => {
32
- console.log('Throttled function called with:', value);
33
- }, 100);
34
-
35
- console.log('✅ throttle function exists:', typeof throttledFunc === 'function');
36
-
37
- // Test isApiError
38
- const error = new utils.ApiError(404, 'Not found');
39
- const isApiErr = utils.isApiError(error);
40
- console.log('✅ isApiError works:', isApiErr);
41
-
42
- // Test API methods (check if they exist)
43
- console.log('\nTesting API methods...');
44
-
45
- // Check what's in the API namespace
46
- console.log('✅ API namespace keys:', Object.keys(api));
47
-
48
- // Check if API methods exist (they should be functions)
49
- console.log('✅ API createInstance function exists:', typeof api.createApiInstance === 'function');
50
-
51
- // Test types (check if they exist)
52
- console.log('\nTesting types...');
53
- // Types are interfaces, so we can't directly test them, but we can check if the module exists
54
- console.log('✅ Types module exists:', !!types);
55
-
56
- console.log('\n🎉 All final tests passed! Toolkit is working correctly.');
package/test-import.js DELETED
@@ -1,34 +0,0 @@
1
- const toolkit = require('./dist');
2
-
3
- console.log('Testing toolkit import...');
4
-
5
- // Test that the toolkit object exists
6
- console.log('✅ Toolkit object exists:', !!toolkit);
7
-
8
- // Test the main namespaces
9
- console.log('✅ API namespace exists:', !!toolkit.api);
10
- console.log('✅ Types namespace exists:', !!toolkit.types);
11
- console.log('✅ Utils namespace exists:', !!toolkit.utils);
12
-
13
- // Test utils functions
14
- if (toolkit.utils) {
15
- console.log('✅ Utils functions:');
16
- console.log(' - formatDate:', typeof toolkit.utils.formatDate);
17
- console.log(' - deepClone:', typeof toolkit.utils.deepClone);
18
- console.log(' - debounce:', typeof toolkit.utils.debounce);
19
- console.log(' - throttle:', typeof toolkit.utils.throttle);
20
- console.log(' - isApiError:', typeof toolkit.utils.isApiError);
21
- console.log(' - ApiError:', typeof toolkit.utils.ApiError);
22
- }
23
-
24
- // Test API functions
25
- if (toolkit.api) {
26
- console.log('✅ API functions:');
27
- console.log(' - api:', typeof toolkit.api);
28
- console.log(' - createApiInstance:', typeof toolkit.api.createApiInstance);
29
- }
30
-
31
- // Test default export
32
- console.log('✅ Default export exists:', !!toolkit.default);
33
-
34
- console.log('\n🎉 Toolkit import test completed!');
package/tsconfig.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "commonjs",
5
- "declaration": true,
6
- "outDir": "./dist",
7
- "strict": true,
8
- "esModuleInterop": true,
9
- "skipLibCheck": true,
10
- "forceConsistentCasingInFileNames": true,
11
- "moduleResolution": "node"
12
- },
13
- "include": [
14
- "src/**/*"
15
- ],
16
- "exclude": [
17
- "node_modules",
18
- "dist"
19
- ]
20
- }