@turndown/library 0.1.24 → 0.1.29

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 (78) hide show
  1. package/dist/index.cjs +1719 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +2820 -0
  4. package/dist/index.d.ts +2820 -2
  5. package/dist/index.mjs +1577 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +10 -6
  8. package/dist/helpers/date/index.d.ts +0 -113
  9. package/dist/helpers/date/index.js +0 -171
  10. package/dist/helpers/index.d.ts +0 -4
  11. package/dist/helpers/index.js +0 -3
  12. package/dist/helpers/object/index.d.ts +0 -298
  13. package/dist/helpers/object/index.js +0 -540
  14. package/dist/helpers/string/index.d.ts +0 -258
  15. package/dist/helpers/string/index.js +0 -496
  16. package/dist/index.js +0 -2
  17. package/dist/types/api/index.d.ts +0 -71
  18. package/dist/types/api/index.js +0 -54
  19. package/dist/types/auth/index.d.ts +0 -107
  20. package/dist/types/auth/index.js +0 -8
  21. package/dist/types/auth/routes.d.ts +0 -160
  22. package/dist/types/auth/routes.js +0 -1
  23. package/dist/types/base/index.d.ts +0 -200
  24. package/dist/types/base/index.js +0 -177
  25. package/dist/types/base/paging.types.d.ts +0 -47
  26. package/dist/types/base/paging.types.js +0 -1
  27. package/dist/types/checklist-template/index.d.ts +0 -48
  28. package/dist/types/checklist-template/index.js +0 -1
  29. package/dist/types/checklist-template/routes.d.ts +0 -85
  30. package/dist/types/checklist-template/routes.js +0 -1
  31. package/dist/types/company/index.d.ts +0 -22
  32. package/dist/types/company/index.js +0 -7
  33. package/dist/types/company/routes.d.ts +0 -100
  34. package/dist/types/company/routes.js +0 -1
  35. package/dist/types/damage-report/index.d.ts +0 -148
  36. package/dist/types/damage-report/index.js +0 -29
  37. package/dist/types/damage-report/routes.d.ts +0 -112
  38. package/dist/types/damage-report/routes.js +0 -1
  39. package/dist/types/errors/index.d.ts +0 -66
  40. package/dist/types/errors/index.js +0 -41
  41. package/dist/types/health/index.d.ts +0 -20
  42. package/dist/types/health/index.js +0 -1
  43. package/dist/types/health/routes.d.ts +0 -10
  44. package/dist/types/health/routes.js +0 -1
  45. package/dist/types/image/index.d.ts +0 -35
  46. package/dist/types/image/index.js +0 -12
  47. package/dist/types/image/routes.d.ts +0 -32
  48. package/dist/types/image/routes.js +0 -1
  49. package/dist/types/index.d.ts +0 -22
  50. package/dist/types/index.js +0 -22
  51. package/dist/types/inventory/index.d.ts +0 -124
  52. package/dist/types/inventory/index.js +0 -30
  53. package/dist/types/inventory/routes.d.ts +0 -109
  54. package/dist/types/inventory/routes.js +0 -1
  55. package/dist/types/job/index.d.ts +0 -7
  56. package/dist/types/job/index.js +0 -1
  57. package/dist/types/property/index.d.ts +0 -113
  58. package/dist/types/property/index.js +0 -25
  59. package/dist/types/property/routes.d.ts +0 -54
  60. package/dist/types/property/routes.js +0 -1
  61. package/dist/types/room/index.d.ts +0 -28
  62. package/dist/types/room/index.js +0 -17
  63. package/dist/types/room/routes.d.ts +0 -35
  64. package/dist/types/room/routes.js +0 -1
  65. package/dist/types/room-checklist/index.d.ts +0 -43
  66. package/dist/types/room-checklist/index.js +0 -1
  67. package/dist/types/room-checklist/routes.d.ts +0 -78
  68. package/dist/types/room-checklist/routes.js +0 -1
  69. package/dist/types/subscription/index.d.ts +0 -32
  70. package/dist/types/subscription/index.js +0 -16
  71. package/dist/types/user/index.d.ts +0 -59
  72. package/dist/types/user/index.js +0 -20
  73. package/dist/types/user/routes.d.ts +0 -46
  74. package/dist/types/user/routes.js +0 -1
  75. package/dist/types/work-session/index.d.ts +0 -97
  76. package/dist/types/work-session/index.js +0 -18
  77. package/dist/types/work-session/routes.d.ts +0 -89
  78. package/dist/types/work-session/routes.js +0 -1
@@ -1,298 +0,0 @@
1
- import type { IFilterCondition, ISortCondition } from "../../types/base/paging.types";
2
- type TRecord = Record<string, unknown>;
3
- type TSortableValue = string | number | bigint | boolean | Date | null | undefined;
4
- type TReplaceNulls<TValue> = TValue extends null ? "" : TValue extends (infer TItem)[] ? TReplaceNulls<TItem>[] : TValue extends Date ? TValue : TValue extends object ? {
5
- [TKey in keyof TValue]: TReplaceNulls<TValue[TKey]>;
6
- } : TValue;
7
- /**
8
- * Safely parse a JSON string into a typed value.
9
- *
10
- * When a fallback value is provided, the function always returns that generic
11
- * type. Without a fallback value, parse failures return an empty object.
12
- *
13
- * @typeParam TParsed - Expected parsed value type.
14
- * @param {string | null | undefined} jsonString - JSON string to parse.
15
- * @param {TParsed} [fallbackValue] - Value returned when parsing fails.
16
- * @returns {TParsed | Record<string, unknown>} Parsed value or fallback.
17
- * @example
18
- * parseJSON<{ a: number }>('{"a":1}', { a: 0 }) // => { a: 1 }
19
- * parseJSON('not json') // => {}
20
- */
21
- export declare function parseJSON<TParsed>(jsonString: string | null | undefined, fallbackValue: TParsed): TParsed;
22
- export declare function parseJSON(jsonString: string | null | undefined): Record<string, unknown>;
23
- /**
24
- * Stringify a value to JSON while skipping circular references.
25
- *
26
- * Uses an internal cache to omit repeated object references that would
27
- * normally cause `JSON.stringify` to throw.
28
- *
29
- * @param {unknown} value - Value to stringify.
30
- * @returns {string | undefined} JSON string with circulars omitted.
31
- * @example
32
- * const value: Record<string, unknown> = {}; value.self = value;
33
- * JSONStringify(value) // => "{}"
34
- */
35
- export declare const JSONStringify: (value: unknown) => string | undefined;
36
- /**
37
- * Deep-remove `undefined` properties while preserving Dates and arrays.
38
- *
39
- * Object properties with `undefined` values are removed. Array items are
40
- * preserved so array indexes do not shift.
41
- *
42
- * @typeParam TValue - Input value type.
43
- * @param {TValue} value - Input value.
44
- * @returns {TValue} Cleaned clone with `undefined` object properties removed.
45
- */
46
- export declare const removeUndefined: <TValue>(value: TValue) => TValue;
47
- /**
48
- * Test whether a location object's `pathname` equals a key.
49
- *
50
- * @param {{ pathname?: string } | null | undefined} location - Object expected
51
- * to have a `pathname`.
52
- * @param {string} key - Path to compare.
53
- * @returns {boolean}
54
- * @example
55
- * validPath({ pathname: "/home" }, "/home") // true
56
- */
57
- export declare const validPath: (location: {
58
- pathname?: string;
59
- } | null | undefined, key: string) => boolean;
60
- /**
61
- * Return the first element if the input is an array; otherwise return the value itself.
62
- *
63
- * @typeParam T - Element type.
64
- * @param {T | T[]} input - A single value or an array.
65
- * @returns {T} First element or the input value.
66
- * @example
67
- * returnObject([1,2,3]) // 1
68
- * returnObject(5) // 5
69
- */
70
- export declare const returnObject: <T>(input: T | T[]) => T;
71
- /**
72
- * Filter out items from `array1` whose `id` appears in `array2`.
73
- *
74
- * @typeParam T - Object type with an `id` field.
75
- * @param {T[]} [array1] - Source array.
76
- * @param {T[]} [array2] - Items whose `id`s should be excluded.
77
- * @returns {T[]} Filtered array (or `[]` on invalid input).
78
- */
79
- export declare const filterArrayById: <T extends {
80
- id: number | string;
81
- }>(array1?: T[], array2?: T[]) => T[];
82
- /**
83
- * Sort an array of objects by a given property (ascending).
84
- *
85
- * Mutates the original array (uses `Array.prototype.sort`).
86
- *
87
- * @typeParam T - Object type.
88
- * @typeParam TKey - Sortable property key.
89
- * @param {T[]} array - Array to sort.
90
- * @param {TKey} property - Property name to sort by.
91
- * @returns {T[]} The same array instance, sorted (or empty array if input invalid).
92
- */
93
- export declare const sortArrayByProperty: <TKey extends PropertyKey, T extends Record<TKey, TSortableValue>>(array: T[], property: TKey) => T[];
94
- /**
95
- * Recursively replace `null` values with empty strings.
96
- *
97
- * Works on primitives, arrays, Dates, and plain objects.
98
- *
99
- * @typeParam TValue - Input value type.
100
- * @param {TValue} value - Input value.
101
- * @returns {TReplaceNulls<TValue>} Value with all `null` replaced by `""`.
102
- */
103
- export declare const replaceNulls: <TValue>(value: TValue) => TReplaceNulls<TValue>;
104
- /**
105
- * Recursively remove object keys that contain a dot (`.`).
106
- *
107
- * @typeParam TValue - Input value type.
108
- * @param {TValue} value - Input object or array.
109
- * @returns {TValue} New value with dotted keys removed at all levels.
110
- */
111
- export declare const removeFormProperties: <TValue>(value: TValue) => TValue;
112
- /**
113
- * Recursively convert string booleans `"true"`/`"false"` to actual booleans.
114
- *
115
- * Leaves all other values unchanged.
116
- *
117
- * @typeParam TValue - Input value type.
118
- * @param {TValue} value - Input object or array.
119
- * @returns {TValue} New value with boolean-like strings converted.
120
- */
121
- export declare const convertStringBooleans: <TValue>(value: TValue) => TValue;
122
- /**
123
- * Convenience helper to clean form-like data:
124
- * - Removes `undefined` properties
125
- * - Converts string booleans to booleans
126
- * - Removes keys containing a dot (`.`)
127
- *
128
- * @typeParam TObject - Form data object type.
129
- * @param {TObject} objectToClean - Input data.
130
- * @returns {Partial<TObject>} Cleaned clone.
131
- */
132
- export declare const cleanFormData: <TObject extends TRecord>(objectToClean: TObject) => Partial<TObject>;
133
- /**
134
- * Return a default pagination object, allowing optional sort and filters.
135
- *
136
- * @param {ISortCondition[]} [sort] - Optional sort conditions.
137
- * @param {IFilterCondition[]} [filters] - Optional filter conditions.
138
- * @returns {{ page: number; size: number; sort: ISortCondition[]; filters: IFilterCondition[] }}
139
- * @example
140
- * resetPagination() // => { page:1, size:25, sort:[], filters:[] }
141
- */
142
- export declare const resetPagination: (sort?: ISortCondition[], filters?: IFilterCondition[]) => {
143
- page: number;
144
- size: number;
145
- sort: ISortCondition[];
146
- filters: IFilterCondition[];
147
- };
148
- /**
149
- * Format a string of digits into a U.S. phone number.
150
- *
151
- * Strips non-numeric characters and formats 10 digits as `(XXX) XXX-XXXX`.
152
- * Strips a leading US country code when 11 digits are provided.
153
- * If a value cannot be formatted, returns the original value as a string.
154
- *
155
- * @param {string | number} value - Phone number digits (string or number).
156
- * @returns {string} Formatted phone number, or original input if invalid length.
157
- * @example
158
- * formatPhoneNumber("1234567890") // "(123) 456-7890"
159
- * formatPhoneNumber(9876543210) // "(987) 654-3210"
160
- * formatPhoneNumber("555") // "555"
161
- */
162
- export declare const formatPhoneNumber: (value: string | number) => string;
163
- /**
164
- * Format a number with thousands separators (commas).
165
- *
166
- * @param {number} value - Number to format.
167
- * @returns {string} String with commas.
168
- * @example
169
- * formatNumber(1234567) // "1,234,567"
170
- */
171
- export declare const formatNumber: (value: number) => string;
172
- /**
173
- * Remove comma separators from a number-like value.
174
- *
175
- * @param {number | string} value - Number-like value.
176
- * @returns {string} Value without comma separators.
177
- */
178
- export declare const parseNumber: (value: number | string) => string;
179
- /**
180
- * Delete a property from an object if it exists (no-op if it doesn't).
181
- *
182
- * @typeParam TObject - Object type.
183
- * @param {TObject} objectToUpdate - Target object (mutated).
184
- * @param {keyof TObject | string} propertyName - Property to delete.
185
- * @returns {void}
186
- */
187
- export declare const deletePropertyIfExists: <TObject extends TRecord>(objectToUpdate: TObject, propertyName: keyof TObject | string) => void;
188
- /**
189
- * Split an array into chunks of a given size.
190
- *
191
- * @typeParam T - Element type.
192
- * @param {T[]} array - Source array.
193
- * @param {number} chunkSize - Size of each chunk.
194
- * @returns {T[][]} Array of chunks (last one may be smaller).
195
- * @example
196
- * chunkArray([1,2,3,4,5], 2) // [[1,2],[3,4],[5]]
197
- */
198
- export declare const chunkArray: <T>(array: T[], chunkSize: number) => T[][];
199
- /**
200
- * Return a shallow clone of `objectToOmitFrom` without the listed properties.
201
- *
202
- * @typeParam TObject - Source object type.
203
- * @typeParam TKey - Keys to omit.
204
- * @param {TObject} objectToOmitFrom - Source object.
205
- * @param {readonly TKey[]} propsToOmit - Property names to omit.
206
- * @returns {Omit<TObject, TKey>} New object without omitted props.
207
- * @example
208
- * omitProperties({a:1,b:2}, ["b"]) // { a:1 }
209
- */
210
- export declare const omitProperties: <TObject extends TRecord, TKey extends keyof TObject>(objectToOmitFrom: TObject, propsToOmit: readonly TKey[]) => Omit<TObject, TKey>;
211
- /**
212
- * Safe `hasOwnProperty` check.
213
- *
214
- * @param {unknown} value - Value to test.
215
- * @param {PropertyKey} key - Property name.
216
- * @returns {boolean}
217
- */
218
- export declare const hasProperty: <TKey extends PropertyKey>(value: unknown, key: TKey) => value is Record<TKey, unknown>;
219
- /**
220
- * Safe `hasOwnProperty` alias from the reference utilities.
221
- *
222
- * @param {unknown} value - Value to test.
223
- * @param {PropertyKey} key - Property name.
224
- * @returns {boolean}
225
- */
226
- export declare const hasOwnProp: <TKey extends PropertyKey>(value: unknown, key: TKey) => value is Record<TKey, unknown>;
227
- /**
228
- * Determine if an object has at least one own enumerable property.
229
- *
230
- * @param {unknown} value - Object to test.
231
- * @returns {boolean} `true` if there is at least one key.
232
- */
233
- export declare const hasProperties: (value: unknown) => boolean;
234
- /**
235
- * Get the first own enumerable property value from an object.
236
- *
237
- * @typeParam TObject - Source object type.
238
- * @param {TObject | null | undefined} value - Source object.
239
- * @returns {TObject[keyof TObject] | null} First value, or null for empty/non-object input.
240
- */
241
- export declare const getFirstPropertyValue: <TObject extends TRecord>(value: TObject | null | undefined) => TObject[keyof TObject] | null;
242
- /**
243
- * Get a nested value from an object using dot notation.
244
- *
245
- * @param {unknown} value - Source object.
246
- * @param {string} path - Dot-delimited path.
247
- * @returns {unknown} Nested value, or undefined when the path cannot be resolved.
248
- * @example
249
- * getNestedValue({ user: { name: "John" } }, "user.name") // "John"
250
- */
251
- export declare const getNestedValue: (value: unknown, path: string) => unknown;
252
- /**
253
- * Set a nested value on an object using dot notation.
254
- *
255
- * Mutates and returns the provided object. Unsafe path segments are ignored to
256
- * prevent prototype pollution.
257
- *
258
- * @typeParam TObject - Target object type.
259
- * @param {TObject} objectToUpdate - Target object.
260
- * @param {string} path - Dot-delimited path.
261
- * @param {unknown} value - Value to set.
262
- * @returns {TObject} The mutated target object.
263
- * @example
264
- * setNestedValue({}, "user.name", "John") // { user: { name: "John" } }
265
- */
266
- export declare const setNestedValue: <TObject extends TRecord>(objectToUpdate: TObject, path: string, value: unknown) => TObject;
267
- /**
268
- * Deep clone a value while preserving Dates and circular references.
269
- *
270
- * @typeParam TValue - Input value type.
271
- * @param {TValue} value - Value to clone.
272
- * @returns {TValue} Deep clone of the input.
273
- */
274
- export declare const deepClone: <TValue>(value: TValue) => TValue;
275
- /**
276
- * Flatten a nested object into dot notation.
277
- *
278
- * Arrays and Dates are treated as leaf values.
279
- *
280
- * @param {TRecord} value - Source object.
281
- * @param {string} [prefix] - Internal prefix for recursion.
282
- * @returns {TRecord} Flattened object.
283
- * @example
284
- * flatten({ user: { name: "John" } }) // { "user.name": "John" }
285
- */
286
- export declare const flatten: (value: TRecord, prefix?: string) => TRecord;
287
- /**
288
- * Convert a dot-notation object into a nested object.
289
- *
290
- * Unsafe path segments are ignored to prevent prototype pollution.
291
- *
292
- * @param {TRecord} value - Dot-notation source object.
293
- * @returns {TRecord} Nested object.
294
- * @example
295
- * unflatten({ "user.name": "John" }) // { user: { name: "John" } }
296
- */
297
- export declare const unflatten: (value: TRecord) => TRecord;
298
- export {};