@parsrun/core 0.1.29 → 0.1.30
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/dist/decimal.d.ts +176 -46
- package/dist/decimal.js +123 -40
- package/dist/decimal.js.map +1 -1
- package/dist/errors.d.ts +39 -3
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +184 -15
- package/dist/index.js +155 -40
- package/dist/index.js.map +1 -1
- package/dist/{logger-3oVznpFY.d.ts → logger-DrxxwI7C.d.ts} +136 -11
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +32 -0
- package/dist/logger.js.map +1 -1
- package/dist/transports/index.d.ts +58 -7
- package/dist/transports/index.js.map +1 -1
- package/dist/types.d.ts +176 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Runtime, detectRuntime, getRuntimeVersion, isBrowser, isBun, isCloudflare, isDeno, isEdge, isNode, isServer, runtime, runtimeInfo } from './runtime.js';
|
|
2
2
|
export { EnvMode, clearEdgeEnv, createEnvConfig, getEnv, getEnvArray, getEnvBoolean, getEnvFloat, getEnvJson, getEnvMode, getEnvNumber, isDevelopment, isProduction, isTest, requireEnv, setEdgeEnv } from './env.js';
|
|
3
|
-
export { o as BaseTransportOptions, p as BatchTransportOptions, B as Breadcrumb, j as CombinedTransport, C as ConsoleTransport, k as ErrorContext, E as ErrorTransport, n as ErrorUser, g as LogEntry, a as LogLevel, e as LogLevelName, f as LogLevelValue, h as LogTransport, L as Logger, i as LoggerConfig, c as createLogger, d as createRequestLogger, b as logError, l as logger, m as measureTime } from './logger-
|
|
3
|
+
export { o as BaseTransportOptions, p as BatchTransportOptions, B as Breadcrumb, j as CombinedTransport, C as ConsoleTransport, k as ErrorContext, E as ErrorTransport, n as ErrorUser, g as LogEntry, a as LogLevel, e as LogLevelName, f as LogLevelValue, h as LogTransport, L as Logger, i as LoggerConfig, c as createLogger, d as createRequestLogger, b as logError, l as logger, m as measureTime } from './logger-DrxxwI7C.js';
|
|
4
4
|
export { Decimal, DecimalUtils, decimal } from './decimal.js';
|
|
5
5
|
export { AccessLevel, AuthContext, DeepPartial, IpRestrictions, MembershipPermissions, MembershipStatus, PaginatedResult, PaginationParams, Prettify, RequireAtLeastOne, ResourceRestrictions, Result, Session, Tenant, TenantMembership, TenantStatus, TimeRestrictions, User, err, ok } from './types.js';
|
|
6
6
|
export { AccountLockedError, AuthError, ConflictError, DuplicateError, ForbiddenError, InvalidCredentialsError, MembershipError, MembershipExpiredError, MembershipNotFoundError, NotFoundError, ParsError, RateLimitError, SessionExpiredError, TenantError, TenantNotFoundError, TenantSuspendedError, TwoFactorRequiredError, UnauthorizedError, ValidationError, ValidationErrorDetail } from './errors.js';
|
|
@@ -74,7 +74,17 @@ declare function generateId(): string;
|
|
|
74
74
|
*/
|
|
75
75
|
declare function sha256(input: string): Promise<string>;
|
|
76
76
|
/**
|
|
77
|
-
* Hash a string using SHA-256 and return as ArrayBuffer
|
|
77
|
+
* Hash a string using SHA-256 and return as ArrayBuffer.
|
|
78
|
+
* Useful when you need the raw bytes for further cryptographic operations.
|
|
79
|
+
*
|
|
80
|
+
* @param input - The string to hash
|
|
81
|
+
* @returns Promise resolving to the raw hash bytes
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const hashBytes = await sha256Bytes('data');
|
|
86
|
+
* const key = await crypto.subtle.importKey('raw', hashBytes, 'AES-GCM', false, ['encrypt']);
|
|
87
|
+
* ```
|
|
78
88
|
*/
|
|
79
89
|
declare function sha256Bytes(input: string): Promise<ArrayBuffer>;
|
|
80
90
|
/**
|
|
@@ -134,11 +144,31 @@ declare function retry<T>(fn: () => Promise<T>, options?: {
|
|
|
134
144
|
onRetry?: (error: unknown, attempt: number) => void;
|
|
135
145
|
}): Promise<T>;
|
|
136
146
|
/**
|
|
137
|
-
*
|
|
147
|
+
* Create a new object with specified keys omitted.
|
|
148
|
+
*
|
|
149
|
+
* @param obj - The source object
|
|
150
|
+
* @param keys - Array of keys to omit
|
|
151
|
+
* @returns A new object without the specified keys
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const user = { id: 1, name: 'John', password: 'secret' };
|
|
156
|
+
* const safe = omit(user, ['password']); // { id: 1, name: 'John' }
|
|
157
|
+
* ```
|
|
138
158
|
*/
|
|
139
159
|
declare function omit<T extends object, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
140
160
|
/**
|
|
141
|
-
*
|
|
161
|
+
* Create a new object with only the specified keys.
|
|
162
|
+
*
|
|
163
|
+
* @param obj - The source object
|
|
164
|
+
* @param keys - Array of keys to include
|
|
165
|
+
* @returns A new object with only the specified keys
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* const user = { id: 1, name: 'John', email: 'john@example.com' };
|
|
170
|
+
* const subset = pick(user, ['id', 'name']); // { id: 1, name: 'John' }
|
|
171
|
+
* ```
|
|
142
172
|
*/
|
|
143
173
|
declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
144
174
|
/**
|
|
@@ -155,47 +185,186 @@ declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): P
|
|
|
155
185
|
*/
|
|
156
186
|
declare function deepMerge<T extends object>(target: T, source: Partial<T>): T;
|
|
157
187
|
/**
|
|
158
|
-
*
|
|
188
|
+
* Create a deep clone of an object.
|
|
189
|
+
* Handles nested objects, arrays, and Date instances.
|
|
190
|
+
*
|
|
191
|
+
* @param obj - The object to clone
|
|
192
|
+
* @returns A deep copy of the object
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* const original = { nested: { value: 1 }, date: new Date() };
|
|
197
|
+
* const cloned = deepClone(original);
|
|
198
|
+
* cloned.nested.value = 2; // original.nested.value is still 1
|
|
199
|
+
* ```
|
|
159
200
|
*/
|
|
160
201
|
declare function deepClone<T>(obj: T): T;
|
|
161
202
|
/**
|
|
162
|
-
* Check if a value is a plain object
|
|
203
|
+
* Check if a value is a plain object (not an array, Date, etc.).
|
|
204
|
+
* Useful for type guards and deep merge operations.
|
|
205
|
+
*
|
|
206
|
+
* @param value - The value to check
|
|
207
|
+
* @returns True if the value is a plain object
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* isPlainObject({}); // true
|
|
212
|
+
* isPlainObject({ a: 1 }); // true
|
|
213
|
+
* isPlainObject([]); // false
|
|
214
|
+
* isPlainObject(new Date()); // false
|
|
215
|
+
* isPlainObject(null); // false
|
|
216
|
+
* ```
|
|
163
217
|
*/
|
|
164
218
|
declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
165
219
|
/**
|
|
166
|
-
* Check if value is null or undefined
|
|
220
|
+
* Check if a value is null or undefined.
|
|
221
|
+
* Provides a type guard for narrowing types.
|
|
222
|
+
*
|
|
223
|
+
* @param value - The value to check
|
|
224
|
+
* @returns True if the value is null or undefined
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* if (!isNil(user)) {
|
|
229
|
+
* console.log(user.name); // TypeScript knows user is not null/undefined
|
|
230
|
+
* }
|
|
231
|
+
* ```
|
|
167
232
|
*/
|
|
168
233
|
declare function isNil(value: unknown): value is null | undefined;
|
|
169
234
|
/**
|
|
170
|
-
* Check if value is empty
|
|
235
|
+
* Check if a value is empty.
|
|
236
|
+
* Considers null, undefined, empty strings (including whitespace-only),
|
|
237
|
+
* empty arrays, and empty objects as empty.
|
|
238
|
+
*
|
|
239
|
+
* @param value - The value to check
|
|
240
|
+
* @returns True if the value is considered empty
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```typescript
|
|
244
|
+
* isEmpty(null); // true
|
|
245
|
+
* isEmpty(''); // true
|
|
246
|
+
* isEmpty(' '); // true
|
|
247
|
+
* isEmpty([]); // true
|
|
248
|
+
* isEmpty({}); // true
|
|
249
|
+
* isEmpty('hello'); // false
|
|
250
|
+
* isEmpty([1]); // false
|
|
251
|
+
* ```
|
|
171
252
|
*/
|
|
172
253
|
declare function isEmpty(value: unknown): boolean;
|
|
173
254
|
/**
|
|
174
|
-
* Normalize email address
|
|
255
|
+
* Normalize an email address by converting to lowercase and trimming whitespace.
|
|
256
|
+
* Use this before storing or comparing email addresses.
|
|
257
|
+
*
|
|
258
|
+
* @param email - The email address to normalize
|
|
259
|
+
* @returns The normalized email address
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```typescript
|
|
263
|
+
* normalizeEmail(' John.Doe@Example.COM '); // 'john.doe@example.com'
|
|
264
|
+
* ```
|
|
175
265
|
*/
|
|
176
266
|
declare function normalizeEmail(email: string): string;
|
|
177
267
|
/**
|
|
178
|
-
* Validate email format
|
|
268
|
+
* Validate that a string is a valid email format.
|
|
269
|
+
* Uses a simple regex that covers most common email formats.
|
|
270
|
+
*
|
|
271
|
+
* @param email - The string to validate
|
|
272
|
+
* @returns True if the string is a valid email format
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```typescript
|
|
276
|
+
* isValidEmail('user@example.com'); // true
|
|
277
|
+
* isValidEmail('user@sub.example.com'); // true
|
|
278
|
+
* isValidEmail('invalid'); // false
|
|
279
|
+
* isValidEmail('user@'); // false
|
|
280
|
+
* ```
|
|
179
281
|
*/
|
|
180
282
|
declare function isValidEmail(email: string): boolean;
|
|
181
283
|
/**
|
|
182
|
-
* Generate a URL-friendly slug from a string
|
|
284
|
+
* Generate a URL-friendly slug from a string.
|
|
285
|
+
* Converts to lowercase, replaces non-alphanumeric characters with hyphens,
|
|
286
|
+
* and removes leading/trailing hyphens.
|
|
287
|
+
*
|
|
288
|
+
* @param str - The string to convert
|
|
289
|
+
* @returns A URL-friendly slug
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```typescript
|
|
293
|
+
* slugify('Hello World!'); // 'hello-world'
|
|
294
|
+
* slugify('My Blog Post Title'); // 'my-blog-post-title'
|
|
295
|
+
* slugify(' Multiple Spaces '); // 'multiple-spaces'
|
|
296
|
+
* ```
|
|
183
297
|
*/
|
|
184
298
|
declare function slugify(str: string): string;
|
|
185
299
|
/**
|
|
186
|
-
* Truncate string to a maximum length
|
|
300
|
+
* Truncate a string to a maximum length, adding a suffix if truncated.
|
|
301
|
+
*
|
|
302
|
+
* @param str - The string to truncate
|
|
303
|
+
* @param maxLength - Maximum length including the suffix
|
|
304
|
+
* @param suffix - String to append when truncated (default: "...")
|
|
305
|
+
* @returns The truncated string or original if within maxLength
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```typescript
|
|
309
|
+
* truncate('Hello World', 8); // 'Hello...'
|
|
310
|
+
* truncate('Hello', 10); // 'Hello'
|
|
311
|
+
* truncate('Long text here', 10, '>>'); // 'Long tex>>'
|
|
312
|
+
* ```
|
|
187
313
|
*/
|
|
188
314
|
declare function truncate(str: string, maxLength: number, suffix?: string): string;
|
|
189
315
|
/**
|
|
190
|
-
*
|
|
316
|
+
* Create a debounced version of a function.
|
|
317
|
+
* The function will only be called after it stops being called for the specified wait period.
|
|
318
|
+
*
|
|
319
|
+
* @param fn - The function to debounce
|
|
320
|
+
* @param wait - Milliseconds to wait before calling the function
|
|
321
|
+
* @returns A debounced version of the function
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* ```typescript
|
|
325
|
+
* const debouncedSearch = debounce((query: string) => {
|
|
326
|
+
* // API call
|
|
327
|
+
* }, 300);
|
|
328
|
+
*
|
|
329
|
+
* // Rapid calls will only trigger one API call after 300ms of inactivity
|
|
330
|
+
* input.addEventListener('input', (e) => debouncedSearch(e.target.value));
|
|
331
|
+
* ```
|
|
191
332
|
*/
|
|
192
333
|
declare function debounce<T extends (...args: unknown[]) => unknown>(fn: T, wait: number): (...args: Parameters<T>) => void;
|
|
193
334
|
/**
|
|
194
|
-
*
|
|
335
|
+
* Create a throttled version of a function.
|
|
336
|
+
* The function will be called at most once per wait period.
|
|
337
|
+
*
|
|
338
|
+
* @param fn - The function to throttle
|
|
339
|
+
* @param wait - Minimum milliseconds between function calls
|
|
340
|
+
* @returns A throttled version of the function
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```typescript
|
|
344
|
+
* const throttledScroll = throttle(() => {
|
|
345
|
+
* // Handle scroll event
|
|
346
|
+
* }, 100);
|
|
347
|
+
*
|
|
348
|
+
* // Called at most every 100ms during scrolling
|
|
349
|
+
* window.addEventListener('scroll', throttledScroll);
|
|
350
|
+
* ```
|
|
195
351
|
*/
|
|
196
352
|
declare function throttle<T extends (...args: unknown[]) => unknown>(fn: T, wait: number): (...args: Parameters<T>) => void;
|
|
197
353
|
/**
|
|
198
|
-
* Create a deferred promise
|
|
354
|
+
* Create a deferred promise with externally accessible resolve/reject functions.
|
|
355
|
+
* Useful when you need to resolve a promise from outside its executor.
|
|
356
|
+
*
|
|
357
|
+
* @returns An object containing the promise and its resolve/reject functions
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* ```typescript
|
|
361
|
+
* const { promise, resolve, reject } = createDeferred<string>();
|
|
362
|
+
*
|
|
363
|
+
* // Later, resolve from elsewhere
|
|
364
|
+
* setTimeout(() => resolve('done!'), 1000);
|
|
365
|
+
*
|
|
366
|
+
* const result = await promise; // 'done!'
|
|
367
|
+
* ```
|
|
199
368
|
*/
|
|
200
369
|
declare function createDeferred<T>(): {
|
|
201
370
|
promise: Promise<T>;
|