@exyconn/common 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 +259 -0
- package/dist/client/http/index.d.mts +85 -0
- package/dist/client/http/index.d.ts +85 -0
- package/dist/client/http/index.js +127 -0
- package/dist/client/http/index.js.map +1 -0
- package/dist/client/http/index.mjs +109 -0
- package/dist/client/http/index.mjs.map +1 -0
- package/dist/client/index.d.mts +7 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/index.js +964 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/index.mjs +889 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/client/logger/index.d.mts +53 -0
- package/dist/client/logger/index.d.ts +53 -0
- package/dist/client/logger/index.js +120 -0
- package/dist/client/logger/index.js.map +1 -0
- package/dist/client/logger/index.mjs +116 -0
- package/dist/client/logger/index.mjs.map +1 -0
- package/dist/client/utils/index.d.mts +285 -0
- package/dist/client/utils/index.d.ts +285 -0
- package/dist/client/utils/index.js +403 -0
- package/dist/client/utils/index.js.map +1 -0
- package/dist/client/utils/index.mjs +362 -0
- package/dist/client/utils/index.mjs.map +1 -0
- package/dist/index-BNdT-2X4.d.ts +229 -0
- package/dist/index-CcrANHAQ.d.mts +59 -0
- package/dist/index-ClWtDfwk.d.ts +833 -0
- package/dist/index-DSW6JfD-.d.mts +833 -0
- package/dist/index-Du0LLt9f.d.mts +229 -0
- package/dist/index-iTKxFa78.d.ts +59 -0
- package/dist/index.d.mts +171 -0
- package/dist/index.d.ts +171 -0
- package/dist/index.js +3806 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3792 -0
- package/dist/index.mjs.map +1 -0
- package/dist/response.types-D--UhLJq.d.mts +67 -0
- package/dist/response.types-D--UhLJq.d.ts +67 -0
- package/dist/server/db/index.d.mts +38 -0
- package/dist/server/db/index.d.ts +38 -0
- package/dist/server/db/index.js +68 -0
- package/dist/server/db/index.js.map +1 -0
- package/dist/server/db/index.mjs +60 -0
- package/dist/server/db/index.mjs.map +1 -0
- package/dist/server/enums/index.d.mts +46 -0
- package/dist/server/enums/index.d.ts +46 -0
- package/dist/server/enums/index.js +48 -0
- package/dist/server/enums/index.js.map +1 -0
- package/dist/server/enums/index.mjs +43 -0
- package/dist/server/enums/index.mjs.map +1 -0
- package/dist/server/index.d.mts +9 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +569 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/index.mjs +523 -0
- package/dist/server/index.mjs.map +1 -0
- package/dist/server/logger/index.d.mts +34 -0
- package/dist/server/logger/index.d.ts +34 -0
- package/dist/server/logger/index.js +125 -0
- package/dist/server/logger/index.js.map +1 -0
- package/dist/server/logger/index.mjs +113 -0
- package/dist/server/logger/index.mjs.map +1 -0
- package/dist/server/middleware/index.d.mts +56 -0
- package/dist/server/middleware/index.d.ts +56 -0
- package/dist/server/middleware/index.js +128 -0
- package/dist/server/middleware/index.js.map +1 -0
- package/dist/server/middleware/index.mjs +118 -0
- package/dist/server/middleware/index.mjs.map +1 -0
- package/dist/server/response/index.d.mts +86 -0
- package/dist/server/response/index.d.ts +86 -0
- package/dist/server/response/index.js +140 -0
- package/dist/server/response/index.js.map +1 -0
- package/dist/server/response/index.mjs +126 -0
- package/dist/server/response/index.mjs.map +1 -0
- package/dist/server/utils/index.d.mts +69 -0
- package/dist/server/utils/index.d.ts +69 -0
- package/dist/server/utils/index.js +114 -0
- package/dist/server/utils/index.js.map +1 -0
- package/dist/server/utils/index.mjs +106 -0
- package/dist/server/utils/index.mjs.map +1 -0
- package/dist/shared/index.d.mts +4 -0
- package/dist/shared/index.d.ts +4 -0
- package/dist/shared/index.js +933 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/index.mjs +612 -0
- package/dist/shared/index.mjs.map +1 -0
- package/package.json +202 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { a as ApiResponse, P as PaginatedResponse, c as PaginationMeta } from '../../response.types-D--UhLJq.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Format date to readable string
|
|
5
|
+
* @param date - Date to format
|
|
6
|
+
* @param locale - Locale for formatting (default: 'en-US')
|
|
7
|
+
*/
|
|
8
|
+
declare const formatDate: (date: Date | string | number, locale?: string) => string;
|
|
9
|
+
/**
|
|
10
|
+
* Format date with time
|
|
11
|
+
*/
|
|
12
|
+
declare const formatDateTime: (date: Date | string | number, locale?: string) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Format date as relative time (e.g., "2 hours ago")
|
|
15
|
+
*/
|
|
16
|
+
declare const formatRelativeTime: (date: Date | string | number) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Format date for input[type="date"]
|
|
19
|
+
*/
|
|
20
|
+
declare const formatDateForInput: (date: Date | string | number) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Format date for input[type="datetime-local"]
|
|
23
|
+
*/
|
|
24
|
+
declare const formatDateTimeForInput: (date: Date | string | number) => string;
|
|
25
|
+
/**
|
|
26
|
+
* Check if date is today
|
|
27
|
+
*/
|
|
28
|
+
declare const isToday: (date: Date | string | number) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Check if date is in the past
|
|
31
|
+
*/
|
|
32
|
+
declare const isPast: (date: Date | string | number) => boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Check if date is in the future
|
|
35
|
+
*/
|
|
36
|
+
declare const isFuture: (date: Date | string | number) => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Add days to a date
|
|
39
|
+
*/
|
|
40
|
+
declare const addDays: (date: Date | string | number, days: number) => Date;
|
|
41
|
+
/**
|
|
42
|
+
* Get start of day
|
|
43
|
+
*/
|
|
44
|
+
declare const startOfDay: (date: Date | string | number) => Date;
|
|
45
|
+
/**
|
|
46
|
+
* Get end of day
|
|
47
|
+
*/
|
|
48
|
+
declare const endOfDay: (date: Date | string | number) => Date;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Copy text to clipboard
|
|
52
|
+
* @returns Promise<boolean> - true if successful
|
|
53
|
+
*/
|
|
54
|
+
declare const copyToClipboard: (text: string) => Promise<boolean>;
|
|
55
|
+
/**
|
|
56
|
+
* Read text from clipboard
|
|
57
|
+
* @returns Promise<string | null>
|
|
58
|
+
*/
|
|
59
|
+
declare const readFromClipboard: () => Promise<string | null>;
|
|
60
|
+
/**
|
|
61
|
+
* Check if clipboard API is available
|
|
62
|
+
*/
|
|
63
|
+
declare const isClipboardAvailable: () => boolean;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Generate URL-friendly slug from text
|
|
67
|
+
*/
|
|
68
|
+
declare const slugify: (text: string) => string;
|
|
69
|
+
/**
|
|
70
|
+
* Generate slug with unique suffix
|
|
71
|
+
*/
|
|
72
|
+
declare const slugifyUnique: (text: string) => string;
|
|
73
|
+
/**
|
|
74
|
+
* Convert slug back to readable text
|
|
75
|
+
*/
|
|
76
|
+
declare const unslugify: (slug: string) => string;
|
|
77
|
+
/**
|
|
78
|
+
* Truncate text to specified length with ellipsis
|
|
79
|
+
*/
|
|
80
|
+
declare const truncate: (text: string, maxLength: number, suffix?: string) => string;
|
|
81
|
+
/**
|
|
82
|
+
* Truncate text by words
|
|
83
|
+
*/
|
|
84
|
+
declare const truncateWords: (text: string, maxWords: number, suffix?: string) => string;
|
|
85
|
+
/**
|
|
86
|
+
* Capitalize first letter of each word
|
|
87
|
+
*/
|
|
88
|
+
declare const capitalizeWords: (text: string) => string;
|
|
89
|
+
/**
|
|
90
|
+
* Capitalize first letter only
|
|
91
|
+
*/
|
|
92
|
+
declare const capitalize: (text: string) => string;
|
|
93
|
+
/**
|
|
94
|
+
* Convert camelCase to kebab-case
|
|
95
|
+
*/
|
|
96
|
+
declare const camelToKebab: (text: string) => string;
|
|
97
|
+
/**
|
|
98
|
+
* Convert kebab-case to camelCase
|
|
99
|
+
*/
|
|
100
|
+
declare const kebabToCamel: (text: string) => string;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Event Emitter for client-side event handling
|
|
104
|
+
*/
|
|
105
|
+
type EventHandler<T = unknown> = (data: T) => void;
|
|
106
|
+
interface EventMap {
|
|
107
|
+
[event: string]: unknown;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Simple typed event emitter for browser use
|
|
111
|
+
*/
|
|
112
|
+
declare class EventEmitter<Events extends EventMap = EventMap> {
|
|
113
|
+
private handlers;
|
|
114
|
+
/**
|
|
115
|
+
* Subscribe to an event
|
|
116
|
+
* @returns Unsubscribe function
|
|
117
|
+
*/
|
|
118
|
+
on<K extends keyof Events>(event: K, handler: EventHandler<Events[K]>): () => void;
|
|
119
|
+
/**
|
|
120
|
+
* Subscribe to an event once
|
|
121
|
+
*/
|
|
122
|
+
once<K extends keyof Events>(event: K, handler: EventHandler<Events[K]>): () => void;
|
|
123
|
+
/**
|
|
124
|
+
* Unsubscribe from an event
|
|
125
|
+
*/
|
|
126
|
+
off<K extends keyof Events>(event: K, handler: EventHandler<Events[K]>): void;
|
|
127
|
+
/**
|
|
128
|
+
* Emit an event
|
|
129
|
+
*/
|
|
130
|
+
emit<K extends keyof Events>(event: K, data: Events[K]): void;
|
|
131
|
+
/**
|
|
132
|
+
* Remove all handlers for an event (or all events)
|
|
133
|
+
*/
|
|
134
|
+
removeAllListeners(event?: keyof Events): void;
|
|
135
|
+
/**
|
|
136
|
+
* Get count of listeners for an event
|
|
137
|
+
*/
|
|
138
|
+
listenerCount(event: keyof Events): number;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Create a new event emitter instance
|
|
142
|
+
*/
|
|
143
|
+
declare const createEventEmitter: <Events extends EventMap = EventMap>() => EventEmitter<Events>;
|
|
144
|
+
/**
|
|
145
|
+
* Global app event emitter (singleton)
|
|
146
|
+
*/
|
|
147
|
+
declare const appEvents: EventEmitter<{
|
|
148
|
+
[key: string]: unknown;
|
|
149
|
+
'auth:login': {
|
|
150
|
+
userId: string;
|
|
151
|
+
};
|
|
152
|
+
'auth:logout': void;
|
|
153
|
+
'notification:show': {
|
|
154
|
+
message: string;
|
|
155
|
+
type: "success" | "error" | "warning" | "info";
|
|
156
|
+
};
|
|
157
|
+
'theme:change': "light" | "dark";
|
|
158
|
+
}>;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* API URL Builder
|
|
162
|
+
* Centralized API endpoint management
|
|
163
|
+
*/
|
|
164
|
+
interface ApiUrlConfig {
|
|
165
|
+
baseUrl: string;
|
|
166
|
+
version?: string;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* API URL builder class
|
|
170
|
+
*/
|
|
171
|
+
declare class ApiUrlBuilder {
|
|
172
|
+
private baseUrl;
|
|
173
|
+
private version;
|
|
174
|
+
constructor(config: ApiUrlConfig);
|
|
175
|
+
/**
|
|
176
|
+
* Build full URL from path
|
|
177
|
+
*/
|
|
178
|
+
build(path: string): string;
|
|
179
|
+
/**
|
|
180
|
+
* Build URL with query parameters
|
|
181
|
+
*/
|
|
182
|
+
buildWithParams(path: string, params: Record<string, string | number | boolean | undefined>): string;
|
|
183
|
+
/**
|
|
184
|
+
* Build URL with path parameters
|
|
185
|
+
*/
|
|
186
|
+
buildWithPathParams(template: string, params: Record<string, string | number>): string;
|
|
187
|
+
/**
|
|
188
|
+
* Get base URL
|
|
189
|
+
*/
|
|
190
|
+
getBaseUrl(): string;
|
|
191
|
+
/**
|
|
192
|
+
* Set new base URL
|
|
193
|
+
*/
|
|
194
|
+
setBaseUrl(baseUrl: string): void;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Create API URL builder
|
|
198
|
+
*/
|
|
199
|
+
declare const createApiUrlBuilder: (config: ApiUrlConfig) => ApiUrlBuilder;
|
|
200
|
+
/**
|
|
201
|
+
* Common API endpoints factory
|
|
202
|
+
*/
|
|
203
|
+
declare const createApiEndpoints: (builder: ApiUrlBuilder) => {
|
|
204
|
+
auth: {
|
|
205
|
+
login: () => string;
|
|
206
|
+
register: () => string;
|
|
207
|
+
logout: () => string;
|
|
208
|
+
refresh: () => string;
|
|
209
|
+
me: () => string;
|
|
210
|
+
forgotPassword: () => string;
|
|
211
|
+
resetPassword: () => string;
|
|
212
|
+
};
|
|
213
|
+
users: {
|
|
214
|
+
list: () => string;
|
|
215
|
+
get: (id: string) => string;
|
|
216
|
+
create: () => string;
|
|
217
|
+
update: (id: string) => string;
|
|
218
|
+
delete: (id: string) => string;
|
|
219
|
+
};
|
|
220
|
+
crud: (resource: string) => {
|
|
221
|
+
list: () => string;
|
|
222
|
+
get: (id: string) => string;
|
|
223
|
+
create: () => string;
|
|
224
|
+
update: (id: string) => string;
|
|
225
|
+
delete: (id: string) => string;
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Response Parser Utilities
|
|
231
|
+
* Common patterns for parsing API responses
|
|
232
|
+
*/
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Check if response is successful
|
|
236
|
+
*/
|
|
237
|
+
declare const isSuccessResponse: <T>(response: ApiResponse<T>) => response is ApiResponse<T> & {
|
|
238
|
+
success: true;
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Check if response is an error
|
|
242
|
+
*/
|
|
243
|
+
declare const isErrorResponse: <T>(response: ApiResponse<T>) => response is ApiResponse<T> & {
|
|
244
|
+
success: false;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* Extract data from response or return default
|
|
248
|
+
*/
|
|
249
|
+
declare const getResponseData: <T>(response: ApiResponse<T>, defaultValue: T) => T;
|
|
250
|
+
/**
|
|
251
|
+
* Extract error message from response
|
|
252
|
+
*/
|
|
253
|
+
declare const getErrorMessage: <T>(response: ApiResponse<T>, defaultMessage?: string) => string;
|
|
254
|
+
/**
|
|
255
|
+
* Check if response has data
|
|
256
|
+
*/
|
|
257
|
+
declare const hasData: <T>(response: ApiResponse<T>) => response is ApiResponse<T> & {
|
|
258
|
+
data: NonNullable<T>;
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Check if paginated response has more pages
|
|
262
|
+
*/
|
|
263
|
+
declare const hasMorePages: <T>(response: PaginatedResponse<T>) => boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Get next page number from paginated response
|
|
266
|
+
*/
|
|
267
|
+
declare const getNextPage: <T>(response: PaginatedResponse<T>) => number | null;
|
|
268
|
+
/**
|
|
269
|
+
* Get previous page number from paginated response
|
|
270
|
+
*/
|
|
271
|
+
declare const getPrevPage: <T>(response: PaginatedResponse<T>) => number | null;
|
|
272
|
+
/**
|
|
273
|
+
* Create empty pagination meta
|
|
274
|
+
*/
|
|
275
|
+
declare const createEmptyPaginationMeta: () => PaginationMeta;
|
|
276
|
+
/**
|
|
277
|
+
* Create success response
|
|
278
|
+
*/
|
|
279
|
+
declare const createSuccessResponse: <T>(data: T, message?: string) => ApiResponse<T>;
|
|
280
|
+
/**
|
|
281
|
+
* Create error response
|
|
282
|
+
*/
|
|
283
|
+
declare const createErrorResponse: (message: string, statusCode?: number, error?: string) => ApiResponse<never>;
|
|
284
|
+
|
|
285
|
+
export { ApiUrlBuilder, type ApiUrlConfig, EventEmitter, addDays, appEvents, camelToKebab, capitalize, capitalizeWords, copyToClipboard, createApiEndpoints, createApiUrlBuilder, createEmptyPaginationMeta, createErrorResponse, createEventEmitter, createSuccessResponse, endOfDay, formatDate, formatDateForInput, formatDateTime, formatDateTimeForInput, formatRelativeTime, getErrorMessage, getNextPage, getPrevPage, getResponseData, hasData, hasMorePages, isClipboardAvailable, isErrorResponse, isFuture, isPast, isSuccessResponse, isToday, kebabToCamel, readFromClipboard, slugify, slugifyUnique, startOfDay, truncate, truncateWords, unslugify };
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { a as ApiResponse, P as PaginatedResponse, c as PaginationMeta } from '../../response.types-D--UhLJq.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Format date to readable string
|
|
5
|
+
* @param date - Date to format
|
|
6
|
+
* @param locale - Locale for formatting (default: 'en-US')
|
|
7
|
+
*/
|
|
8
|
+
declare const formatDate: (date: Date | string | number, locale?: string) => string;
|
|
9
|
+
/**
|
|
10
|
+
* Format date with time
|
|
11
|
+
*/
|
|
12
|
+
declare const formatDateTime: (date: Date | string | number, locale?: string) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Format date as relative time (e.g., "2 hours ago")
|
|
15
|
+
*/
|
|
16
|
+
declare const formatRelativeTime: (date: Date | string | number) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Format date for input[type="date"]
|
|
19
|
+
*/
|
|
20
|
+
declare const formatDateForInput: (date: Date | string | number) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Format date for input[type="datetime-local"]
|
|
23
|
+
*/
|
|
24
|
+
declare const formatDateTimeForInput: (date: Date | string | number) => string;
|
|
25
|
+
/**
|
|
26
|
+
* Check if date is today
|
|
27
|
+
*/
|
|
28
|
+
declare const isToday: (date: Date | string | number) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Check if date is in the past
|
|
31
|
+
*/
|
|
32
|
+
declare const isPast: (date: Date | string | number) => boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Check if date is in the future
|
|
35
|
+
*/
|
|
36
|
+
declare const isFuture: (date: Date | string | number) => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Add days to a date
|
|
39
|
+
*/
|
|
40
|
+
declare const addDays: (date: Date | string | number, days: number) => Date;
|
|
41
|
+
/**
|
|
42
|
+
* Get start of day
|
|
43
|
+
*/
|
|
44
|
+
declare const startOfDay: (date: Date | string | number) => Date;
|
|
45
|
+
/**
|
|
46
|
+
* Get end of day
|
|
47
|
+
*/
|
|
48
|
+
declare const endOfDay: (date: Date | string | number) => Date;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Copy text to clipboard
|
|
52
|
+
* @returns Promise<boolean> - true if successful
|
|
53
|
+
*/
|
|
54
|
+
declare const copyToClipboard: (text: string) => Promise<boolean>;
|
|
55
|
+
/**
|
|
56
|
+
* Read text from clipboard
|
|
57
|
+
* @returns Promise<string | null>
|
|
58
|
+
*/
|
|
59
|
+
declare const readFromClipboard: () => Promise<string | null>;
|
|
60
|
+
/**
|
|
61
|
+
* Check if clipboard API is available
|
|
62
|
+
*/
|
|
63
|
+
declare const isClipboardAvailable: () => boolean;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Generate URL-friendly slug from text
|
|
67
|
+
*/
|
|
68
|
+
declare const slugify: (text: string) => string;
|
|
69
|
+
/**
|
|
70
|
+
* Generate slug with unique suffix
|
|
71
|
+
*/
|
|
72
|
+
declare const slugifyUnique: (text: string) => string;
|
|
73
|
+
/**
|
|
74
|
+
* Convert slug back to readable text
|
|
75
|
+
*/
|
|
76
|
+
declare const unslugify: (slug: string) => string;
|
|
77
|
+
/**
|
|
78
|
+
* Truncate text to specified length with ellipsis
|
|
79
|
+
*/
|
|
80
|
+
declare const truncate: (text: string, maxLength: number, suffix?: string) => string;
|
|
81
|
+
/**
|
|
82
|
+
* Truncate text by words
|
|
83
|
+
*/
|
|
84
|
+
declare const truncateWords: (text: string, maxWords: number, suffix?: string) => string;
|
|
85
|
+
/**
|
|
86
|
+
* Capitalize first letter of each word
|
|
87
|
+
*/
|
|
88
|
+
declare const capitalizeWords: (text: string) => string;
|
|
89
|
+
/**
|
|
90
|
+
* Capitalize first letter only
|
|
91
|
+
*/
|
|
92
|
+
declare const capitalize: (text: string) => string;
|
|
93
|
+
/**
|
|
94
|
+
* Convert camelCase to kebab-case
|
|
95
|
+
*/
|
|
96
|
+
declare const camelToKebab: (text: string) => string;
|
|
97
|
+
/**
|
|
98
|
+
* Convert kebab-case to camelCase
|
|
99
|
+
*/
|
|
100
|
+
declare const kebabToCamel: (text: string) => string;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Event Emitter for client-side event handling
|
|
104
|
+
*/
|
|
105
|
+
type EventHandler<T = unknown> = (data: T) => void;
|
|
106
|
+
interface EventMap {
|
|
107
|
+
[event: string]: unknown;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Simple typed event emitter for browser use
|
|
111
|
+
*/
|
|
112
|
+
declare class EventEmitter<Events extends EventMap = EventMap> {
|
|
113
|
+
private handlers;
|
|
114
|
+
/**
|
|
115
|
+
* Subscribe to an event
|
|
116
|
+
* @returns Unsubscribe function
|
|
117
|
+
*/
|
|
118
|
+
on<K extends keyof Events>(event: K, handler: EventHandler<Events[K]>): () => void;
|
|
119
|
+
/**
|
|
120
|
+
* Subscribe to an event once
|
|
121
|
+
*/
|
|
122
|
+
once<K extends keyof Events>(event: K, handler: EventHandler<Events[K]>): () => void;
|
|
123
|
+
/**
|
|
124
|
+
* Unsubscribe from an event
|
|
125
|
+
*/
|
|
126
|
+
off<K extends keyof Events>(event: K, handler: EventHandler<Events[K]>): void;
|
|
127
|
+
/**
|
|
128
|
+
* Emit an event
|
|
129
|
+
*/
|
|
130
|
+
emit<K extends keyof Events>(event: K, data: Events[K]): void;
|
|
131
|
+
/**
|
|
132
|
+
* Remove all handlers for an event (or all events)
|
|
133
|
+
*/
|
|
134
|
+
removeAllListeners(event?: keyof Events): void;
|
|
135
|
+
/**
|
|
136
|
+
* Get count of listeners for an event
|
|
137
|
+
*/
|
|
138
|
+
listenerCount(event: keyof Events): number;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Create a new event emitter instance
|
|
142
|
+
*/
|
|
143
|
+
declare const createEventEmitter: <Events extends EventMap = EventMap>() => EventEmitter<Events>;
|
|
144
|
+
/**
|
|
145
|
+
* Global app event emitter (singleton)
|
|
146
|
+
*/
|
|
147
|
+
declare const appEvents: EventEmitter<{
|
|
148
|
+
[key: string]: unknown;
|
|
149
|
+
'auth:login': {
|
|
150
|
+
userId: string;
|
|
151
|
+
};
|
|
152
|
+
'auth:logout': void;
|
|
153
|
+
'notification:show': {
|
|
154
|
+
message: string;
|
|
155
|
+
type: "success" | "error" | "warning" | "info";
|
|
156
|
+
};
|
|
157
|
+
'theme:change': "light" | "dark";
|
|
158
|
+
}>;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* API URL Builder
|
|
162
|
+
* Centralized API endpoint management
|
|
163
|
+
*/
|
|
164
|
+
interface ApiUrlConfig {
|
|
165
|
+
baseUrl: string;
|
|
166
|
+
version?: string;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* API URL builder class
|
|
170
|
+
*/
|
|
171
|
+
declare class ApiUrlBuilder {
|
|
172
|
+
private baseUrl;
|
|
173
|
+
private version;
|
|
174
|
+
constructor(config: ApiUrlConfig);
|
|
175
|
+
/**
|
|
176
|
+
* Build full URL from path
|
|
177
|
+
*/
|
|
178
|
+
build(path: string): string;
|
|
179
|
+
/**
|
|
180
|
+
* Build URL with query parameters
|
|
181
|
+
*/
|
|
182
|
+
buildWithParams(path: string, params: Record<string, string | number | boolean | undefined>): string;
|
|
183
|
+
/**
|
|
184
|
+
* Build URL with path parameters
|
|
185
|
+
*/
|
|
186
|
+
buildWithPathParams(template: string, params: Record<string, string | number>): string;
|
|
187
|
+
/**
|
|
188
|
+
* Get base URL
|
|
189
|
+
*/
|
|
190
|
+
getBaseUrl(): string;
|
|
191
|
+
/**
|
|
192
|
+
* Set new base URL
|
|
193
|
+
*/
|
|
194
|
+
setBaseUrl(baseUrl: string): void;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Create API URL builder
|
|
198
|
+
*/
|
|
199
|
+
declare const createApiUrlBuilder: (config: ApiUrlConfig) => ApiUrlBuilder;
|
|
200
|
+
/**
|
|
201
|
+
* Common API endpoints factory
|
|
202
|
+
*/
|
|
203
|
+
declare const createApiEndpoints: (builder: ApiUrlBuilder) => {
|
|
204
|
+
auth: {
|
|
205
|
+
login: () => string;
|
|
206
|
+
register: () => string;
|
|
207
|
+
logout: () => string;
|
|
208
|
+
refresh: () => string;
|
|
209
|
+
me: () => string;
|
|
210
|
+
forgotPassword: () => string;
|
|
211
|
+
resetPassword: () => string;
|
|
212
|
+
};
|
|
213
|
+
users: {
|
|
214
|
+
list: () => string;
|
|
215
|
+
get: (id: string) => string;
|
|
216
|
+
create: () => string;
|
|
217
|
+
update: (id: string) => string;
|
|
218
|
+
delete: (id: string) => string;
|
|
219
|
+
};
|
|
220
|
+
crud: (resource: string) => {
|
|
221
|
+
list: () => string;
|
|
222
|
+
get: (id: string) => string;
|
|
223
|
+
create: () => string;
|
|
224
|
+
update: (id: string) => string;
|
|
225
|
+
delete: (id: string) => string;
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Response Parser Utilities
|
|
231
|
+
* Common patterns for parsing API responses
|
|
232
|
+
*/
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Check if response is successful
|
|
236
|
+
*/
|
|
237
|
+
declare const isSuccessResponse: <T>(response: ApiResponse<T>) => response is ApiResponse<T> & {
|
|
238
|
+
success: true;
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Check if response is an error
|
|
242
|
+
*/
|
|
243
|
+
declare const isErrorResponse: <T>(response: ApiResponse<T>) => response is ApiResponse<T> & {
|
|
244
|
+
success: false;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* Extract data from response or return default
|
|
248
|
+
*/
|
|
249
|
+
declare const getResponseData: <T>(response: ApiResponse<T>, defaultValue: T) => T;
|
|
250
|
+
/**
|
|
251
|
+
* Extract error message from response
|
|
252
|
+
*/
|
|
253
|
+
declare const getErrorMessage: <T>(response: ApiResponse<T>, defaultMessage?: string) => string;
|
|
254
|
+
/**
|
|
255
|
+
* Check if response has data
|
|
256
|
+
*/
|
|
257
|
+
declare const hasData: <T>(response: ApiResponse<T>) => response is ApiResponse<T> & {
|
|
258
|
+
data: NonNullable<T>;
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Check if paginated response has more pages
|
|
262
|
+
*/
|
|
263
|
+
declare const hasMorePages: <T>(response: PaginatedResponse<T>) => boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Get next page number from paginated response
|
|
266
|
+
*/
|
|
267
|
+
declare const getNextPage: <T>(response: PaginatedResponse<T>) => number | null;
|
|
268
|
+
/**
|
|
269
|
+
* Get previous page number from paginated response
|
|
270
|
+
*/
|
|
271
|
+
declare const getPrevPage: <T>(response: PaginatedResponse<T>) => number | null;
|
|
272
|
+
/**
|
|
273
|
+
* Create empty pagination meta
|
|
274
|
+
*/
|
|
275
|
+
declare const createEmptyPaginationMeta: () => PaginationMeta;
|
|
276
|
+
/**
|
|
277
|
+
* Create success response
|
|
278
|
+
*/
|
|
279
|
+
declare const createSuccessResponse: <T>(data: T, message?: string) => ApiResponse<T>;
|
|
280
|
+
/**
|
|
281
|
+
* Create error response
|
|
282
|
+
*/
|
|
283
|
+
declare const createErrorResponse: (message: string, statusCode?: number, error?: string) => ApiResponse<never>;
|
|
284
|
+
|
|
285
|
+
export { ApiUrlBuilder, type ApiUrlConfig, EventEmitter, addDays, appEvents, camelToKebab, capitalize, capitalizeWords, copyToClipboard, createApiEndpoints, createApiUrlBuilder, createEmptyPaginationMeta, createErrorResponse, createEventEmitter, createSuccessResponse, endOfDay, formatDate, formatDateForInput, formatDateTime, formatDateTimeForInput, formatRelativeTime, getErrorMessage, getNextPage, getPrevPage, getResponseData, hasData, hasMorePages, isClipboardAvailable, isErrorResponse, isFuture, isPast, isSuccessResponse, isToday, kebabToCamel, readFromClipboard, slugify, slugifyUnique, startOfDay, truncate, truncateWords, unslugify };
|