@oxyhq/services 5.13.23 → 5.13.25
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/lib/commonjs/core/RequestManager.js +2 -31
- package/lib/commonjs/core/RequestManager.js.map +1 -1
- package/lib/commonjs/core/mixins/OxyServices.assets.js +1 -1
- package/lib/commonjs/ui/components/FollowButton.js +0 -53
- package/lib/commonjs/ui/components/FollowButton.js.map +1 -1
- package/lib/commonjs/utils/asyncUtils.js +23 -3
- package/lib/commonjs/utils/asyncUtils.js.map +1 -1
- package/lib/commonjs/utils/errorUtils.js +13 -18
- package/lib/commonjs/utils/errorUtils.js.map +1 -1
- package/lib/commonjs/utils/validationUtils.js +15 -0
- package/lib/commonjs/utils/validationUtils.js.map +1 -1
- package/lib/module/core/RequestManager.js +2 -31
- package/lib/module/core/RequestManager.js.map +1 -1
- package/lib/module/core/mixins/OxyServices.assets.js +1 -1
- package/lib/module/ui/components/FollowButton.js +1 -54
- package/lib/module/ui/components/FollowButton.js.map +1 -1
- package/lib/module/utils/asyncUtils.js +24 -3
- package/lib/module/utils/asyncUtils.js.map +1 -1
- package/lib/module/utils/errorUtils.js +7 -18
- package/lib/module/utils/errorUtils.js.map +1 -1
- package/lib/module/utils/validationUtils.js +14 -0
- package/lib/module/utils/validationUtils.js.map +1 -1
- package/lib/typescript/core/RequestManager.d.ts +0 -4
- package/lib/typescript/core/RequestManager.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.assets.d.ts.map +1 -1
- package/lib/typescript/ui/components/FollowButton.d.ts.map +1 -1
- package/lib/typescript/utils/asyncUtils.d.ts +4 -0
- package/lib/typescript/utils/asyncUtils.d.ts.map +1 -1
- package/lib/typescript/utils/errorUtils.d.ts +9 -1
- package/lib/typescript/utils/errorUtils.d.ts.map +1 -1
- package/lib/typescript/utils/validationUtils.d.ts +6 -0
- package/lib/typescript/utils/validationUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/RequestManager.ts +2 -37
- package/src/core/mixins/OxyServices.assets.ts +1 -1
- package/src/ui/components/FollowButton.tsx +0 -53
- package/src/utils/asyncUtils.ts +23 -3
- package/src/utils/errorUtils.ts +7 -26
- package/src/utils/validationUtils.ts +14 -0
package/src/utils/errorUtils.ts
CHANGED
|
@@ -16,6 +16,7 @@ export const ErrorCodes = {
|
|
|
16
16
|
|
|
17
17
|
// Validation errors
|
|
18
18
|
VALIDATION_ERROR: 'VALIDATION_ERROR',
|
|
19
|
+
BAD_REQUEST: 'BAD_REQUEST',
|
|
19
20
|
MISSING_PARAMETER: 'MISSING_PARAMETER',
|
|
20
21
|
INVALID_FORMAT: 'INVALID_FORMAT',
|
|
21
22
|
|
|
@@ -103,11 +104,12 @@ export function handleHttpError(error: unknown): ApiError {
|
|
|
103
104
|
|
|
104
105
|
/**
|
|
105
106
|
* Get error code from HTTP status
|
|
107
|
+
* Exported for use in other modules
|
|
106
108
|
*/
|
|
107
|
-
function getErrorCodeFromStatus(status: number): string {
|
|
109
|
+
export function getErrorCodeFromStatus(status: number): string {
|
|
108
110
|
switch (status) {
|
|
109
111
|
case 400:
|
|
110
|
-
return ErrorCodes.
|
|
112
|
+
return ErrorCodes.BAD_REQUEST;
|
|
111
113
|
case 401:
|
|
112
114
|
return ErrorCodes.UNAUTHORIZED;
|
|
113
115
|
case 403:
|
|
@@ -157,28 +159,7 @@ export function logError(error: unknown, context?: string): void {
|
|
|
157
159
|
|
|
158
160
|
/**
|
|
159
161
|
* Retry function with exponential backoff
|
|
162
|
+
* Re-exports retryAsync for backward compatibility
|
|
163
|
+
* @deprecated Use retryAsync from asyncUtils instead
|
|
160
164
|
*/
|
|
161
|
-
export
|
|
162
|
-
fn: () => Promise<T>,
|
|
163
|
-
maxRetries = 3,
|
|
164
|
-
baseDelay = 1000
|
|
165
|
-
): Promise<T> {
|
|
166
|
-
let lastError: unknown;
|
|
167
|
-
|
|
168
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
169
|
-
try {
|
|
170
|
-
return await fn();
|
|
171
|
-
} catch (error) {
|
|
172
|
-
lastError = error;
|
|
173
|
-
|
|
174
|
-
if (attempt === maxRetries) {
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const delay = baseDelay * 2 ** attempt;
|
|
179
|
-
await new Promise(resolve => setTimeout(resolve, delay));
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
throw lastError;
|
|
184
|
-
}
|
|
165
|
+
export { retryAsync as retryWithBackoff } from './asyncUtils';
|
|
@@ -137,6 +137,20 @@ export function sanitizeHTML(input: string): string {
|
|
|
137
137
|
.replace(/'/g, ''');
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
/**
|
|
141
|
+
* Validate MongoDB ObjectId format
|
|
142
|
+
* Note: This is a basic format check. For full validation, use mongoose.Types.ObjectId.isValid()
|
|
143
|
+
* This function works in environments where mongoose may not be available (e.g., client-side)
|
|
144
|
+
*/
|
|
145
|
+
export function isValidObjectId(id: string): boolean {
|
|
146
|
+
if (typeof id !== 'string') {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
// MongoDB ObjectId is 24 hex characters
|
|
150
|
+
const OBJECT_ID_REGEX = /^[0-9a-fA-F]{24}$/;
|
|
151
|
+
return OBJECT_ID_REGEX.test(id);
|
|
152
|
+
}
|
|
153
|
+
|
|
140
154
|
/**
|
|
141
155
|
* Validate and sanitize user input
|
|
142
156
|
*/
|