@happyvertical/utils 0.74.8
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/AGENT.md +33 -0
- package/LICENSE +7 -0
- package/README.md +143 -0
- package/dist/browser.d.ts +20 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +59 -0
- package/dist/browser.js.map +1 -0
- package/dist/chunks/universal-BeseWxvS.js +934 -0
- package/dist/chunks/universal-BeseWxvS.js.map +1 -0
- package/dist/cli/claude-context.d.ts +3 -0
- package/dist/cli/claude-context.d.ts.map +1 -0
- package/dist/cli/claude-context.js +21 -0
- package/dist/cli/claude-context.js.map +1 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/parse-args.d.ts +61 -0
- package/dist/cli/parse-args.d.ts.map +1 -0
- package/dist/cli/parse-flags.d.ts +22 -0
- package/dist/cli/parse-flags.d.ts.map +1 -0
- package/dist/config/env-config.d.ts +119 -0
- package/dist/config/env-config.d.ts.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +394 -0
- package/dist/index.js.map +1 -0
- package/dist/shared/code/extraction.d.ts +90 -0
- package/dist/shared/code/extraction.d.ts.map +1 -0
- package/dist/shared/code/index.d.ts +14 -0
- package/dist/shared/code/index.d.ts.map +1 -0
- package/dist/shared/code/sandbox.d.ts +165 -0
- package/dist/shared/code/sandbox.d.ts.map +1 -0
- package/dist/shared/code/validation.d.ts +113 -0
- package/dist/shared/code/validation.d.ts.map +1 -0
- package/dist/shared/index.d.ts +5 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/logger.d.ts +43 -0
- package/dist/shared/logger.d.ts.map +1 -0
- package/dist/shared/types.d.ts +195 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/universal.d.ts +400 -0
- package/dist/shared/universal.d.ts.map +1 -0
- package/dist/web.d.ts +35 -0
- package/dist/web.d.ts.map +1 -0
- package/metadata.json +54 -0
- package/package.json +70 -0
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import { createId as cuid2CreateId, isCuid } from '@paralleldrive/cuid2';
|
|
2
|
+
import { add, isValid } from 'date-fns';
|
|
3
|
+
import { default as pluralize } from 'pluralize';
|
|
4
|
+
/**
|
|
5
|
+
* Generates a unique identifier using CUID2 (preferred) or UUID fallback
|
|
6
|
+
*
|
|
7
|
+
* CUID2 is more secure and collision-resistant than UUIDs, but UUID is provided
|
|
8
|
+
* as a fallback for RFC4122 compliance requirements.
|
|
9
|
+
*
|
|
10
|
+
* @param type - ID type: 'cuid2' (default) or 'uuid'
|
|
11
|
+
* @returns A unique identifier string
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const id = makeId(); // CUID2: "ckx5f8h3z0000qzrmn831i7rn"
|
|
15
|
+
* const uuid = makeId('uuid'); // UUID: "f47ac10b-58cc-4372-a567-0e02b2c3d479"
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const makeId: (type?: "cuid2" | "uuid") => string;
|
|
19
|
+
/**
|
|
20
|
+
* Generates a CUID2 identifier (collision-resistant, more secure than UUID)
|
|
21
|
+
*
|
|
22
|
+
* CUID2 provides better entropy and security compared to UUID v4, making it
|
|
23
|
+
* ideal for distributed systems and user-facing identifiers.
|
|
24
|
+
*
|
|
25
|
+
* @returns A CUID2 identifier string
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const id = createId(); // "ckx5f8h3z0000qzrmn831i7rn"
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const createId: typeof cuid2CreateId;
|
|
32
|
+
/**
|
|
33
|
+
* Checks if a string is a valid CUID2
|
|
34
|
+
*/
|
|
35
|
+
export { isCuid };
|
|
36
|
+
/**
|
|
37
|
+
* Converts a string to a URL-friendly slug
|
|
38
|
+
*
|
|
39
|
+
* Handles international characters, removes special characters, and replaces
|
|
40
|
+
* spaces with hyphens. Ampersands are converted to "-38-" for uniqueness.
|
|
41
|
+
*
|
|
42
|
+
* @param str - The string to convert to a slug
|
|
43
|
+
* @returns A URL-friendly slug string
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* makeSlug("My Example Title & Co."); // "my-example-title-38-co"
|
|
47
|
+
* makeSlug("Café España"); // "cafe-espana"
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare const makeSlug: (str: string) => string;
|
|
51
|
+
/**
|
|
52
|
+
* Extracts the filename from a URL's pathname
|
|
53
|
+
*
|
|
54
|
+
* Returns the last segment of the URL path. If no filename is found,
|
|
55
|
+
* defaults to 'index.html'.
|
|
56
|
+
*
|
|
57
|
+
* @param url - The URL to extract filename from
|
|
58
|
+
* @returns The filename from the URL
|
|
59
|
+
* @throws {TypeError} When URL is invalid
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* urlFilename("https://example.com/path/file.pdf"); // "file.pdf"
|
|
63
|
+
* urlFilename("https://example.com/path/"); // "index.html"
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare const urlFilename: (url: string) => string;
|
|
67
|
+
/**
|
|
68
|
+
* Converts a URL to a file path by joining hostname and pathname
|
|
69
|
+
*
|
|
70
|
+
* Creates a file system compatible path from a URL by combining the hostname
|
|
71
|
+
* with the pathname segments, useful for creating local file structures.
|
|
72
|
+
*
|
|
73
|
+
* @param url - The URL to convert to a path
|
|
74
|
+
* @returns A file path string with hostname and path segments
|
|
75
|
+
* @throws {TypeError} When URL is invalid
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* urlPath("https://example.com/path/to/resource"); // "example.com/path/to/resource"
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare const urlPath: (url: string) => string;
|
|
82
|
+
/**
|
|
83
|
+
* Creates a Promise that resolves after a specified duration
|
|
84
|
+
*
|
|
85
|
+
* Useful for adding delays in async functions or rate limiting operations.
|
|
86
|
+
*
|
|
87
|
+
* @param duration - Time to wait in milliseconds
|
|
88
|
+
* @returns Promise that resolves after the specified duration
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* await sleep(1000); // Wait 1 second
|
|
92
|
+
* console.log('1 second has passed');
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare const sleep: (duration: number) => Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Repeatedly calls a function until it returns a defined value or times out
|
|
98
|
+
*
|
|
99
|
+
* Polls an async function at regular intervals until it returns a defined value
|
|
100
|
+
* or the timeout is reached. Useful for waiting for conditions to be met.
|
|
101
|
+
*
|
|
102
|
+
* @param it - Async function to poll
|
|
103
|
+
* @param options - Configuration options
|
|
104
|
+
* @param options.timeout - Maximum time to wait in milliseconds (0 = no timeout)
|
|
105
|
+
* @param options.delay - Time between polling attempts in milliseconds
|
|
106
|
+
* @returns Promise that resolves with the function result or rejects on timeout
|
|
107
|
+
* @throws {TimeoutError} When timeout is reached before function returns defined value
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* // Wait for a file to exist
|
|
111
|
+
* const fileExists = await waitFor(
|
|
112
|
+
* async () => {
|
|
113
|
+
* try {
|
|
114
|
+
* await fs.access('/path/to/file');
|
|
115
|
+
* return true;
|
|
116
|
+
* } catch {
|
|
117
|
+
* return undefined; // Keep polling
|
|
118
|
+
* }
|
|
119
|
+
* },
|
|
120
|
+
* { timeout: 10000, delay: 500 }
|
|
121
|
+
* );
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
export declare function waitFor(it: () => Promise<any>, { timeout, delay }?: {
|
|
125
|
+
timeout?: number;
|
|
126
|
+
delay?: number;
|
|
127
|
+
}): Promise<any>;
|
|
128
|
+
/**
|
|
129
|
+
* Type guard to check if a value is an array
|
|
130
|
+
*
|
|
131
|
+
* @param obj - Value to check
|
|
132
|
+
* @returns True if value is an array, with TypeScript type narrowing
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* if (isArray(data)) {
|
|
136
|
+
* // TypeScript knows data is unknown[]
|
|
137
|
+
* data.forEach(item => console.log(item));
|
|
138
|
+
* }
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
export declare const isArray: (obj: unknown) => obj is unknown[];
|
|
142
|
+
/**
|
|
143
|
+
* Type guard to check if a value is a plain object
|
|
144
|
+
*
|
|
145
|
+
* Checks for objects that are not null, arrays, or other non-plain object types.
|
|
146
|
+
*
|
|
147
|
+
* @param obj - Value to check
|
|
148
|
+
* @returns True if value is a plain object, with TypeScript type narrowing
|
|
149
|
+
* @example
|
|
150
|
+
* ```typescript
|
|
151
|
+
* if (isPlainObject(data)) {
|
|
152
|
+
* // TypeScript knows data is Record<string, unknown>
|
|
153
|
+
* Object.keys(data).forEach(key => console.log(key, data[key]));
|
|
154
|
+
* }
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
export declare const isPlainObject: (obj: unknown) => obj is Record<string, unknown>;
|
|
158
|
+
/**
|
|
159
|
+
* Checks if a string is a valid URL
|
|
160
|
+
*
|
|
161
|
+
* Uses the URL constructor to validate the string format. Returns false
|
|
162
|
+
* for any string that cannot be parsed as a valid URL.
|
|
163
|
+
*
|
|
164
|
+
* @param url - String to validate as URL
|
|
165
|
+
* @returns True if string is a valid URL
|
|
166
|
+
* @example
|
|
167
|
+
* ```typescript
|
|
168
|
+
* isUrl("https://example.com"); // true
|
|
169
|
+
* isUrl("not-a-url"); // false
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
export declare const isUrl: (url: string) => boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Converts a string to camelCase
|
|
175
|
+
*
|
|
176
|
+
* Handles kebab-case, snake_case, and space-separated strings.
|
|
177
|
+
* Removes special characters and ensures proper camelCase formatting.
|
|
178
|
+
*
|
|
179
|
+
* @param str - String to convert
|
|
180
|
+
* @returns camelCase formatted string
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* camelCase("hello-world"); // "helloWorld"
|
|
184
|
+
* camelCase("snake_case_string"); // "snakeCaseString"
|
|
185
|
+
* camelCase("Some Title"); // "someTitle"
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
export declare const camelCase: (str: string) => string;
|
|
189
|
+
/**
|
|
190
|
+
* Converts a string to snake_case
|
|
191
|
+
*
|
|
192
|
+
* Handles camelCase, kebab-case, and space-separated strings.
|
|
193
|
+
* Converts to lowercase with underscore separators.
|
|
194
|
+
*
|
|
195
|
+
* @param str - String to convert
|
|
196
|
+
* @returns snake_case formatted string
|
|
197
|
+
* @example
|
|
198
|
+
* ```typescript
|
|
199
|
+
* snakeCase("helloWorld"); // "hello_world"
|
|
200
|
+
* snakeCase("kebab-case-string"); // "kebab_case_string"
|
|
201
|
+
* snakeCase("Some Title"); // "some_title"
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
export declare const snakeCase: (str: string) => string;
|
|
205
|
+
/**
|
|
206
|
+
* Recursively converts all object keys to camelCase
|
|
207
|
+
*
|
|
208
|
+
* Deeply traverses an object or array and converts all keys to camelCase.
|
|
209
|
+
* Preserves the structure and values, only transforming key names.
|
|
210
|
+
*
|
|
211
|
+
* @param obj - Object or array to transform
|
|
212
|
+
* @returns New object/array with camelCase keys
|
|
213
|
+
* @example
|
|
214
|
+
* ```typescript
|
|
215
|
+
* keysToCamel({
|
|
216
|
+
* user_name: "john",
|
|
217
|
+
* user_details: { first_name: "John" }
|
|
218
|
+
* }); // { userName: "john", userDetails: { firstName: "John" } }
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
export declare const keysToCamel: (obj: unknown) => unknown;
|
|
222
|
+
/**
|
|
223
|
+
* Recursively converts all object keys to snake_case
|
|
224
|
+
*
|
|
225
|
+
* Deeply traverses an object or array and converts all keys to snake_case.
|
|
226
|
+
* Preserves the structure and values, only transforming key names.
|
|
227
|
+
*
|
|
228
|
+
* @param obj - Object or array to transform
|
|
229
|
+
* @returns New object/array with snake_case keys
|
|
230
|
+
* @example
|
|
231
|
+
* ```typescript
|
|
232
|
+
* keysToSnake({
|
|
233
|
+
* userName: "john",
|
|
234
|
+
* userDetails: { firstName: "John" }
|
|
235
|
+
* }); // { user_name: "john", user_details: { first_name: "John" } }
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
export declare const keysToSnake: (obj: unknown) => unknown;
|
|
239
|
+
/**
|
|
240
|
+
* Converts a domain string to camelCase
|
|
241
|
+
*
|
|
242
|
+
* Convenience function that applies camelCase conversion to domain strings.
|
|
243
|
+
* Useful for converting API service names or domain identifiers.
|
|
244
|
+
*
|
|
245
|
+
* @param domain - Domain string to convert
|
|
246
|
+
* @returns camelCase formatted domain string
|
|
247
|
+
* @example
|
|
248
|
+
* ```typescript
|
|
249
|
+
* domainToCamel("api-service"); // "apiService"
|
|
250
|
+
* domainToCamel("user_management"); // "userManagement"
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
export declare const domainToCamel: (domain: string) => string;
|
|
254
|
+
/**
|
|
255
|
+
* Creates a visual progress indicator by cycling through a sequence of characters
|
|
256
|
+
*
|
|
257
|
+
* Useful for creating animated progress indicators in CLI applications.
|
|
258
|
+
* Cycles through provided characters or defaults to dot sequences.
|
|
259
|
+
*
|
|
260
|
+
* @param tick - Current tick state (null to start)
|
|
261
|
+
* @param options - Configuration options
|
|
262
|
+
* @param options.chars - Array of characters to cycle through
|
|
263
|
+
* @returns Next character in the sequence
|
|
264
|
+
* @example
|
|
265
|
+
* ```typescript
|
|
266
|
+
* let tick = null;
|
|
267
|
+
* setInterval(() => {
|
|
268
|
+
* tick = logTicker(tick);
|
|
269
|
+
* process.stdout.write(`\rProcessing ${tick}`);
|
|
270
|
+
* }, 500);
|
|
271
|
+
* // Outputs: "Processing ." → "Processing .." → "Processing ..."
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
export declare const logTicker: (tick: string | null, options?: {
|
|
275
|
+
chars?: string[];
|
|
276
|
+
}) => string;
|
|
277
|
+
/**
|
|
278
|
+
* Parses an Amazon date string format (YYYYMMDDTHHMMSSZ) to a Date object
|
|
279
|
+
*
|
|
280
|
+
* Specifically handles the compact date format used by Amazon AWS services.
|
|
281
|
+
* Validates the format and throws detailed errors for invalid inputs.
|
|
282
|
+
*
|
|
283
|
+
* @param dateStr - Amazon date string in format YYYYMMDDTHHMMSSZ
|
|
284
|
+
* @returns Parsed Date object
|
|
285
|
+
* @throws {ParsingError} When date string format is invalid
|
|
286
|
+
* @example
|
|
287
|
+
* ```typescript
|
|
288
|
+
* parseAmazonDateString('20220223T215409Z');
|
|
289
|
+
* // Returns: Date object for February 23, 2022, 21:54:09 UTC
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
export declare const parseAmazonDateString: (dateStr: string) => Date;
|
|
293
|
+
/**
|
|
294
|
+
* Extracts and parses a date from a string
|
|
295
|
+
*
|
|
296
|
+
* Intelligently extracts dates from filenames or text strings by looking for
|
|
297
|
+
* common date patterns. Supports multiple formats including:
|
|
298
|
+
* - ISO dates (2023-01-15, 2023/01/15)
|
|
299
|
+
* - US dates (01/15/2023, 01-15-2023)
|
|
300
|
+
* - Natural language (January 15, 2023, Oct 14 2025)
|
|
301
|
+
* - Filenames with dates (Report_January_15_2023.pdf)
|
|
302
|
+
*
|
|
303
|
+
* @param str - String containing date information (filename, title, or text)
|
|
304
|
+
* @returns Parsed Date object or null if no valid date found
|
|
305
|
+
* @example
|
|
306
|
+
* ```typescript
|
|
307
|
+
* dateInString("Report_January_15_2023.pdf"); // Date(2023, 0, 15)
|
|
308
|
+
* dateInString("Regular Council Meeting October 14, 2025"); // Date(2025, 9, 14)
|
|
309
|
+
* dateInString("financial-report-dec-2023.pdf"); // Date(2023, 11, 1)
|
|
310
|
+
* dateInString("2023-01-15"); // Date(2023, 0, 15)
|
|
311
|
+
* dateInString("no-date-here.pdf"); // null
|
|
312
|
+
* ```
|
|
313
|
+
*/
|
|
314
|
+
export declare const dateInString: (str: string) => Date | null;
|
|
315
|
+
/**
|
|
316
|
+
* Formats a date string into a human-readable format using the system locale
|
|
317
|
+
*
|
|
318
|
+
* Uses the Intl.DateTimeFormat API to create localized, human-readable date strings.
|
|
319
|
+
* Automatically adapts to the user's system locale settings.
|
|
320
|
+
*
|
|
321
|
+
* @param dateString - ISO date string or any valid date string
|
|
322
|
+
* @returns Human-readable date string in system locale
|
|
323
|
+
* @example
|
|
324
|
+
* ```typescript
|
|
325
|
+
* prettyDate("2023-01-15T12:00:00Z"); // "January 15, 2023" (in English locale)
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
export declare const prettyDate: (dateString: string) => string;
|
|
329
|
+
/**
|
|
330
|
+
* String pluralization utilities using the pluralize library
|
|
331
|
+
*
|
|
332
|
+
* Re-exports the pluralize library function for word pluralization.
|
|
333
|
+
* Handles English pluralization rules including irregular forms.
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```typescript
|
|
337
|
+
* pluralizeWord("cat"); // "cats"
|
|
338
|
+
* pluralizeWord("mouse"); // "mice"
|
|
339
|
+
* singularize("cats"); // "cat"
|
|
340
|
+
* isPlural("cats"); // true
|
|
341
|
+
* isSingular("cat"); // true
|
|
342
|
+
* ```
|
|
343
|
+
*/
|
|
344
|
+
export declare const pluralizeWord: typeof pluralize;
|
|
345
|
+
export declare const singularize: typeof pluralize.singular;
|
|
346
|
+
export declare const isPlural: typeof pluralize.isPlural;
|
|
347
|
+
export declare const isSingular: typeof pluralize.isSingular;
|
|
348
|
+
/**
|
|
349
|
+
* Enhanced date utilities using date-fns library
|
|
350
|
+
*
|
|
351
|
+
* Re-exports commonly used date-fns functions for date manipulation and formatting.
|
|
352
|
+
* Provides more reliable date handling than native Date methods.
|
|
353
|
+
*
|
|
354
|
+
* @param date - Date object or ISO string to format
|
|
355
|
+
* @param formatStr - Format string (defaults to 'yyyy-MM-dd')
|
|
356
|
+
* @returns Formatted date string
|
|
357
|
+
* @example
|
|
358
|
+
* ```typescript
|
|
359
|
+
* formatDate(new Date(), 'yyyy-MM-dd'); // "2023-01-15"
|
|
360
|
+
* formatDate(new Date(), 'MM/dd/yyyy'); // "01/15/2023"
|
|
361
|
+
* parseDate('2023-01-15'); // Date object
|
|
362
|
+
* isValidDate(new Date()); // true
|
|
363
|
+
* addInterval(new Date(), { days: 7 }); // Date 7 days from now
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
export declare const formatDate: (date: Date | string, formatStr?: string) => string;
|
|
367
|
+
/**
|
|
368
|
+
* Parses a date string into a Date object
|
|
369
|
+
*
|
|
370
|
+
* When a format string is provided, uses date-fns `parse` with that format.
|
|
371
|
+
* Otherwise falls back to `parseISO` for ISO 8601 strings.
|
|
372
|
+
*
|
|
373
|
+
* @param dateStr - The date string to parse
|
|
374
|
+
* @param formatStr - Optional format pattern (e.g., 'MM/dd/yyyy', 'dd-MMM-yyyy')
|
|
375
|
+
* @returns Parsed Date object
|
|
376
|
+
* @example
|
|
377
|
+
* ```typescript
|
|
378
|
+
* parseDate('2023-01-15'); // ISO parse
|
|
379
|
+
* parseDate('01/15/2023', 'MM/dd/yyyy'); // Custom format parse
|
|
380
|
+
* ```
|
|
381
|
+
*/
|
|
382
|
+
export declare const parseDate: (dateStr: string, formatStr?: string) => Date;
|
|
383
|
+
export declare const isValidDate: typeof isValid;
|
|
384
|
+
export declare const addInterval: typeof add;
|
|
385
|
+
/**
|
|
386
|
+
* Gets a temporary directory path (cross-platform)
|
|
387
|
+
*
|
|
388
|
+
* Creates a platform-appropriate temporary directory path under the .have-sdk namespace.
|
|
389
|
+
* Uses environment variables in Node.js or falls back to /tmp.
|
|
390
|
+
*
|
|
391
|
+
* @param subfolder - Optional subfolder name within the temp directory
|
|
392
|
+
* @returns Cross-platform temporary directory path
|
|
393
|
+
* @example
|
|
394
|
+
* ```typescript
|
|
395
|
+
* getTempDirectory(); // "/tmp/.have-sdk" (Unix) or equivalent
|
|
396
|
+
* getTempDirectory("cache"); // "/tmp/.have-sdk/cache"
|
|
397
|
+
* ```
|
|
398
|
+
*/
|
|
399
|
+
export declare const getTempDirectory: (subfolder?: string) => string;
|
|
400
|
+
//# sourceMappingURL=universal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"universal.d.ts","sourceRoot":"","sources":["../../src/shared/universal.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,GAAG,EAAU,OAAO,EAAmB,MAAM,UAAU,CAAC;AACjE,OAAO,SAAS,MAAM,WAAW,CAAC;AAGlC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,MAAM,GAAI,OAAM,OAAO,GAAG,MAAgB,KAAG,MAgBzD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,QAAQ,sBAAgB,CAAC;AAEtC;;GAEG;AACH,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,KAAG,MAqBtC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,KAAG,MAKzC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,KAAG,MAOrC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,KAAK,GAAI,UAAU,MAAM,KAAG,OAAO,CAAC,IAAI,CAIpD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,OAAO,CACrB,EAAE,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,EACtB,EAAE,OAAW,EAAE,KAAY,EAAE,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GACvE,OAAO,CAAC,GAAG,CAAC,CA6Bd;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,OAAO,GAAI,KAAK,OAAO,KAAG,GAAG,IAAI,OAAO,EAEpD,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,OAAO,KAAG,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAEzE,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,KAAK,GAAI,KAAK,MAAM,KAAG,OAOnC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,KAAG,MAQvC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,KAAG,MAMvC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,OAAO,KAAG,OAY1C,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,OAAO,KAAG,OAY1C,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,MAAM,KAAG,MAA2B,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,SAAS,GACpB,MAAM,MAAM,GAAG,IAAI,EACnB,UAAS;IAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,KACjC,MAOF,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,MAAM,KAAG,IAwBvD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,KAAG,IAAI,GAAG,IAyIjD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,GAAI,YAAY,MAAM,KAAG,MAO/C,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,kBAAY,CAAC;AACvC,eAAO,MAAM,WAAW,2BAAqB,CAAC;AAC9C,eAAO,MAAM,QAAQ,2BAAqB,CAAC;AAC3C,eAAO,MAAM,UAAU,6BAAuB,CAAC;AAE/C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,UAAU,GACrB,MAAM,IAAI,GAAG,MAAM,EACnB,kBAAwB,KACvB,MAGF,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,SAAS,GAAI,SAAS,MAAM,EAAE,YAAY,MAAM,KAAG,IAK/D,CAAC;AAEF,eAAO,MAAM,WAAW,gBAAU,CAAC;AACnC,eAAO,MAAM,WAAW,YAAM,CAAC;AAE/B;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,GAAI,YAAY,MAAM,KAAG,MAQrD,CAAC"}
|
package/dist/web.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web and URL utility functions
|
|
3
|
+
*
|
|
4
|
+
* General-purpose utilities for working with URLs and web content.
|
|
5
|
+
* Used by scrapers, note systems, and content processors.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Normalize URL for consistent key storage
|
|
9
|
+
* Removes tracking params, sorts query string, lowercases, etc.
|
|
10
|
+
*
|
|
11
|
+
* @param url - The URL to normalize
|
|
12
|
+
* @returns Normalized URL string
|
|
13
|
+
*/
|
|
14
|
+
export declare function normalizeUrl(url: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Generate hierarchical scope from URL for organized note storage
|
|
17
|
+
*
|
|
18
|
+
* @param url - The URL to generate scope from
|
|
19
|
+
* @param baseScope - Base scope prefix (default: 'discovery/parser')
|
|
20
|
+
* @returns Hierarchical scope string
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* generateScopeFromUrl('https://cityofboston.gov/meetings/minutes')
|
|
24
|
+
* // Returns: 'discovery/parser/cityofboston.gov/meetings'
|
|
25
|
+
*/
|
|
26
|
+
export declare function generateScopeFromUrl(url: string, baseScope?: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Hash page content for change detection
|
|
29
|
+
* Uses SHA-256 to create a unique fingerprint of the HTML
|
|
30
|
+
*
|
|
31
|
+
* @param html - Page HTML content
|
|
32
|
+
* @returns SHA-256 hash as hex string
|
|
33
|
+
*/
|
|
34
|
+
export declare function hashPageContent(html: string): string;
|
|
35
|
+
//# sourceMappingURL=web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAiDhD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,EACX,SAAS,SAAqB,GAC7B,MAAM,CASR;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
package/metadata.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@happyvertical/utils",
|
|
3
|
+
"path": "packages/utils",
|
|
4
|
+
"position": {
|
|
5
|
+
"index": 28,
|
|
6
|
+
"count": 30
|
|
7
|
+
},
|
|
8
|
+
"description": "Foundation utilities for ID generation, date parsing, URL handling, string conversion, error handling, and logging",
|
|
9
|
+
"provides": [
|
|
10
|
+
"Foundation utilities for ID generation, date parsing, URL handling, string conversion, error handling, and logging"
|
|
11
|
+
],
|
|
12
|
+
"implements": [],
|
|
13
|
+
"requires": {
|
|
14
|
+
"workspace": [],
|
|
15
|
+
"externalHappyVertical": [],
|
|
16
|
+
"external": [
|
|
17
|
+
"@paralleldrive/cuid2",
|
|
18
|
+
"date-fns",
|
|
19
|
+
"pluralize",
|
|
20
|
+
"uuid"
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"dependents": [
|
|
24
|
+
"@happyvertical/accounting",
|
|
25
|
+
"@happyvertical/ai",
|
|
26
|
+
"@happyvertical/analytics",
|
|
27
|
+
"@happyvertical/auth",
|
|
28
|
+
"@happyvertical/cache",
|
|
29
|
+
"@happyvertical/comfyui",
|
|
30
|
+
"@happyvertical/directory",
|
|
31
|
+
"@happyvertical/documents",
|
|
32
|
+
"@happyvertical/email",
|
|
33
|
+
"@happyvertical/encryption",
|
|
34
|
+
"@happyvertical/files",
|
|
35
|
+
"@happyvertical/geo",
|
|
36
|
+
"@happyvertical/jobs",
|
|
37
|
+
"@happyvertical/logger",
|
|
38
|
+
"@happyvertical/messages",
|
|
39
|
+
"@happyvertical/sdk-mcp",
|
|
40
|
+
"@happyvertical/secrets",
|
|
41
|
+
"@happyvertical/social",
|
|
42
|
+
"@happyvertical/sql",
|
|
43
|
+
"@happyvertical/translator",
|
|
44
|
+
"@happyvertical/video",
|
|
45
|
+
"@happyvertical/weather"
|
|
46
|
+
],
|
|
47
|
+
"stability": {
|
|
48
|
+
"level": "stable",
|
|
49
|
+
"reason": "Primary package surface is described as implemented and production-oriented."
|
|
50
|
+
},
|
|
51
|
+
"keywords": [
|
|
52
|
+
"utils"
|
|
53
|
+
]
|
|
54
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@happyvertical/utils",
|
|
3
|
+
"version": "0.74.8",
|
|
4
|
+
"description": "Foundation utilities for ID generation, date parsing, URL handling, string conversion, error handling, and logging",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"browser": {
|
|
11
|
+
"import": "./dist/browser.js",
|
|
12
|
+
"types": "./dist/browser.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"./browser": {
|
|
18
|
+
"import": "./dist/browser.js",
|
|
19
|
+
"types": "./dist/browser.d.ts"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@paralleldrive/cuid2": "^3.3.0",
|
|
24
|
+
"date-fns": "^4.1.0",
|
|
25
|
+
"pluralize": "^8.0.0",
|
|
26
|
+
"uuid": "^13.0.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "25.0.10",
|
|
30
|
+
"@types/pluralize": "^0.0.33",
|
|
31
|
+
"typescript": "^5.9.3",
|
|
32
|
+
"vite": "7.3.2",
|
|
33
|
+
"vite-plugin-dts": "4.5.4",
|
|
34
|
+
"vitest": "^4.1.5"
|
|
35
|
+
},
|
|
36
|
+
"bin": {
|
|
37
|
+
"have-utils-context": "./dist/cli/claude-context.js"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"README.md",
|
|
42
|
+
"LICENSE",
|
|
43
|
+
"AGENT.md",
|
|
44
|
+
"metadata.json"
|
|
45
|
+
],
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"registry": "https://registry.npmjs.org",
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "https://github.com/happyvertical/sdk.git",
|
|
53
|
+
"directory": "packages/utils"
|
|
54
|
+
},
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/happyvertical/sdk/issues"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://github.com/happyvertical/sdk/tree/main/packages/utils#readme",
|
|
59
|
+
"license": "MIT",
|
|
60
|
+
"scripts": {
|
|
61
|
+
"test": "npx vitest run",
|
|
62
|
+
"test:watch": "npx vitest",
|
|
63
|
+
"build": "vite build",
|
|
64
|
+
"build:watch": "vite build --watch",
|
|
65
|
+
"docs": "typedoc --plugin typedoc-plugin-markdown --out docs --entryPoints ./src/index.ts --tsconfig ./tsconfig.json --excludePrivate --excludeInternal --hideGenerator --fileExtension .md --readme none --categorizeByGroup false --includeVersion false --hidePageHeader --hidePageTitle false --outputFileStrategy modules",
|
|
66
|
+
"docs:watch": "typedoc --plugin typedoc-plugin-markdown --out docs --entryPoints ./src/index.ts --tsconfig ./tsconfig.json --excludePrivate --excludeInternal --hideGenerator --fileExtension .md --readme none --categorizeByGroup false --includeVersion false --hidePageHeader --hidePageTitle false --outputFileStrategy modules --watch",
|
|
67
|
+
"clean": "rm -rf dist docs",
|
|
68
|
+
"dev": "npm run build:watch & npm run test:watch"
|
|
69
|
+
}
|
|
70
|
+
}
|