@turndown/library 0.1.16 → 0.1.20

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 (44) hide show
  1. package/dist/helpers/date/index.d.ts +113 -0
  2. package/dist/helpers/date/index.js +171 -0
  3. package/dist/helpers/index.d.ts +3 -1
  4. package/dist/helpers/index.js +2 -1
  5. package/dist/helpers/object/index.d.ts +160 -75
  6. package/dist/helpers/object/index.js +355 -168
  7. package/dist/helpers/string/index.d.ts +227 -74
  8. package/dist/helpers/string/index.js +448 -114
  9. package/dist/types/api/index.d.ts +22 -11
  10. package/dist/types/api/index.js +9 -2
  11. package/dist/types/auth/index.d.ts +56 -18
  12. package/dist/types/auth/index.js +7 -0
  13. package/dist/types/auth/routes.d.ts +52 -43
  14. package/dist/types/auth/routes.js +0 -1
  15. package/dist/types/base/index.d.ts +188 -69
  16. package/dist/types/base/index.js +116 -0
  17. package/dist/types/base/paging.types.d.ts +11 -11
  18. package/dist/types/checklist-template/index.d.ts +8 -8
  19. package/dist/types/checklist-template/routes.d.ts +28 -28
  20. package/dist/types/company/index.d.ts +5 -5
  21. package/dist/types/company/routes.d.ts +23 -23
  22. package/dist/types/damage-report/index.d.ts +9 -9
  23. package/dist/types/damage-report/routes.d.ts +38 -38
  24. package/dist/types/errors/index.d.ts +15 -16
  25. package/dist/types/errors/index.js +17 -7
  26. package/dist/types/index.d.ts +1 -0
  27. package/dist/types/index.js +1 -0
  28. package/dist/types/inventory/index.d.ts +19 -19
  29. package/dist/types/inventory/routes.d.ts +36 -36
  30. package/dist/types/job/index.d.ts +7 -0
  31. package/dist/types/job/index.js +1 -0
  32. package/dist/types/property/index.d.ts +88 -29
  33. package/dist/types/property/index.js +23 -23
  34. package/dist/types/property/routes.d.ts +41 -14
  35. package/dist/types/property/routes.js +0 -1
  36. package/dist/types/room/index.d.ts +4 -4
  37. package/dist/types/room/routes.d.ts +8 -8
  38. package/dist/types/room-checklist/index.d.ts +9 -9
  39. package/dist/types/room-checklist/routes.d.ts +28 -28
  40. package/dist/types/user/index.d.ts +12 -12
  41. package/dist/types/user/routes.d.ts +15 -15
  42. package/dist/types/work-session/index.d.ts +12 -12
  43. package/dist/types/work-session/routes.d.ts +34 -34
  44. package/package.json +13 -4
@@ -0,0 +1,113 @@
1
+ export type TDateInput = Date | string | number | null | undefined;
2
+ export type TDateFormat = "MM/DD/YYYY" | "MM/DD/YY HH:mm A" | string;
3
+ /**
4
+ * Format a date using a dayjs format string.
5
+ *
6
+ * @param {TDateInput} date - Date-like value to format.
7
+ * @param {TDateFormat} format - dayjs format string.
8
+ * @returns {string} Formatted date or `--` for missing/invalid input.
9
+ */
10
+ export declare const formatDate: (date?: TDateInput, format?: TDateFormat) => string;
11
+ /**
12
+ * Return a human-readable relative time string.
13
+ *
14
+ * @param {TDateInput} date - Date-like value to compare against now.
15
+ * @returns {string} Relative time or `--` for missing/invalid input.
16
+ */
17
+ export declare const timeAgo: (date: TDateInput) => string;
18
+ /**
19
+ * Add days to a date.
20
+ *
21
+ * @param {TDateInput} date - Source date.
22
+ * @param {number} days - Number of days to add.
23
+ * @returns {Date} Updated date.
24
+ */
25
+ export declare const addDays: (date: TDateInput, days: number) => Date;
26
+ /**
27
+ * Subtract days from a date.
28
+ *
29
+ * @param {TDateInput} date - Source date.
30
+ * @param {number} days - Number of days to subtract.
31
+ * @returns {Date} Updated date.
32
+ */
33
+ export declare const subtractDays: (date: TDateInput, days: number) => Date;
34
+ /**
35
+ * Return the absolute number of whole day boundaries between two dates.
36
+ *
37
+ * @param {TDateInput} dateA - First date.
38
+ * @param {TDateInput} dateB - Second date.
39
+ * @returns {number} Absolute difference in days, or 0 for invalid input.
40
+ */
41
+ export declare const daysBetween: (dateA: TDateInput, dateB: TDateInput) => number;
42
+ /**
43
+ * Check whether a date is today.
44
+ *
45
+ * @param {TDateInput} date - Date-like value.
46
+ * @returns {boolean} True when the date is today.
47
+ */
48
+ export declare const isToday: (date: TDateInput) => boolean;
49
+ /**
50
+ * Check whether a date is in the past.
51
+ *
52
+ * @param {TDateInput} date - Date-like value.
53
+ * @returns {boolean} True when the date is before now.
54
+ */
55
+ export declare const isPast: (date: TDateInput) => boolean;
56
+ /**
57
+ * Check whether a date is in the future.
58
+ *
59
+ * @param {TDateInput} date - Date-like value.
60
+ * @returns {boolean} True when the date is after now.
61
+ */
62
+ export declare const isFuture: (date: TDateInput) => boolean;
63
+ /**
64
+ * Return the start of the day for a date.
65
+ *
66
+ * @param {TDateInput} date - Source date.
67
+ * @returns {Date} Date set to 00:00:00.000.
68
+ */
69
+ export declare const startOfDay: (date: TDateInput) => Date;
70
+ /**
71
+ * Return the end of the day for a date.
72
+ *
73
+ * @param {TDateInput} date - Source date.
74
+ * @returns {Date} Date set to 23:59:59.999.
75
+ */
76
+ export declare const endOfDay: (date: TDateInput) => Date;
77
+ /**
78
+ * Return the ISO week start date, Monday at 00:00:00.000.
79
+ *
80
+ * @param {TDateInput} date - Source date.
81
+ * @returns {Date} Start of ISO week.
82
+ */
83
+ export declare const startOfWeek: (date: TDateInput) => Date;
84
+ /**
85
+ * Return the ISO week end date, Sunday at 23:59:59.999.
86
+ *
87
+ * @param {TDateInput} date - Source date.
88
+ * @returns {Date} End of ISO week.
89
+ */
90
+ export declare const endOfWeek: (date: TDateInput) => Date;
91
+ /**
92
+ * Return all seven dates in the ISO week containing the provided date.
93
+ *
94
+ * @param {TDateInput} date - Source date.
95
+ * @returns {Date[]} Monday-through-Sunday dates at the start of each day.
96
+ */
97
+ export declare const getWeekDays: (date: TDateInput) => Date[];
98
+ /**
99
+ * Add weeks to a date.
100
+ *
101
+ * @param {TDateInput} date - Source date.
102
+ * @param {number} weeks - Number of weeks to add.
103
+ * @returns {Date} Updated date.
104
+ */
105
+ export declare const addWeeks: (date: TDateInput, weeks: number) => Date;
106
+ /**
107
+ * Subtract weeks from a date.
108
+ *
109
+ * @param {TDateInput} date - Source date.
110
+ * @param {number} weeks - Number of weeks to subtract.
111
+ * @returns {Date} Updated date.
112
+ */
113
+ export declare const subtractWeeks: (date: TDateInput, weeks: number) => Date;
@@ -0,0 +1,171 @@
1
+ import dayjs from "dayjs";
2
+ import isoWeek from "dayjs/plugin/isoWeek";
3
+ import relativeTime from "dayjs/plugin/relativeTime";
4
+ dayjs.extend(relativeTime);
5
+ dayjs.extend(isoWeek);
6
+ const defaultDateFallback = "--";
7
+ const isValidDateInput = (date) => {
8
+ return date !== null && date !== undefined && dayjs(date).isValid();
9
+ };
10
+ /**
11
+ * Format a date using a dayjs format string.
12
+ *
13
+ * @param {TDateInput} date - Date-like value to format.
14
+ * @param {TDateFormat} format - dayjs format string.
15
+ * @returns {string} Formatted date or `--` for missing/invalid input.
16
+ */
17
+ export const formatDate = (date, format = "MM/DD/YYYY") => {
18
+ if (!isValidDateInput(date)) {
19
+ return defaultDateFallback;
20
+ }
21
+ return dayjs(date).format(format);
22
+ };
23
+ /**
24
+ * Return a human-readable relative time string.
25
+ *
26
+ * @param {TDateInput} date - Date-like value to compare against now.
27
+ * @returns {string} Relative time or `--` for missing/invalid input.
28
+ */
29
+ export const timeAgo = (date) => {
30
+ if (!isValidDateInput(date)) {
31
+ return defaultDateFallback;
32
+ }
33
+ return dayjs(date).fromNow();
34
+ };
35
+ /**
36
+ * Add days to a date.
37
+ *
38
+ * @param {TDateInput} date - Source date.
39
+ * @param {number} days - Number of days to add.
40
+ * @returns {Date} Updated date.
41
+ */
42
+ export const addDays = (date, days) => {
43
+ return dayjs(date).add(days, "day").toDate();
44
+ };
45
+ /**
46
+ * Subtract days from a date.
47
+ *
48
+ * @param {TDateInput} date - Source date.
49
+ * @param {number} days - Number of days to subtract.
50
+ * @returns {Date} Updated date.
51
+ */
52
+ export const subtractDays = (date, days) => {
53
+ return dayjs(date).subtract(days, "day").toDate();
54
+ };
55
+ /**
56
+ * Return the absolute number of whole day boundaries between two dates.
57
+ *
58
+ * @param {TDateInput} dateA - First date.
59
+ * @param {TDateInput} dateB - Second date.
60
+ * @returns {number} Absolute difference in days, or 0 for invalid input.
61
+ */
62
+ export const daysBetween = (dateA, dateB) => {
63
+ if (!isValidDateInput(dateA) || !isValidDateInput(dateB)) {
64
+ return 0;
65
+ }
66
+ return Math.abs(dayjs(dateA).diff(dayjs(dateB), "day"));
67
+ };
68
+ /**
69
+ * Check whether a date is today.
70
+ *
71
+ * @param {TDateInput} date - Date-like value.
72
+ * @returns {boolean} True when the date is today.
73
+ */
74
+ export const isToday = (date) => {
75
+ if (!isValidDateInput(date)) {
76
+ return false;
77
+ }
78
+ return dayjs(date).isSame(dayjs(), "day");
79
+ };
80
+ /**
81
+ * Check whether a date is in the past.
82
+ *
83
+ * @param {TDateInput} date - Date-like value.
84
+ * @returns {boolean} True when the date is before now.
85
+ */
86
+ export const isPast = (date) => {
87
+ if (!isValidDateInput(date)) {
88
+ return false;
89
+ }
90
+ return dayjs(date).isBefore(dayjs());
91
+ };
92
+ /**
93
+ * Check whether a date is in the future.
94
+ *
95
+ * @param {TDateInput} date - Date-like value.
96
+ * @returns {boolean} True when the date is after now.
97
+ */
98
+ export const isFuture = (date) => {
99
+ if (!isValidDateInput(date)) {
100
+ return false;
101
+ }
102
+ return dayjs(date).isAfter(dayjs());
103
+ };
104
+ /**
105
+ * Return the start of the day for a date.
106
+ *
107
+ * @param {TDateInput} date - Source date.
108
+ * @returns {Date} Date set to 00:00:00.000.
109
+ */
110
+ export const startOfDay = (date) => {
111
+ return dayjs(date).startOf("day").toDate();
112
+ };
113
+ /**
114
+ * Return the end of the day for a date.
115
+ *
116
+ * @param {TDateInput} date - Source date.
117
+ * @returns {Date} Date set to 23:59:59.999.
118
+ */
119
+ export const endOfDay = (date) => {
120
+ return dayjs(date).endOf("day").toDate();
121
+ };
122
+ /**
123
+ * Return the ISO week start date, Monday at 00:00:00.000.
124
+ *
125
+ * @param {TDateInput} date - Source date.
126
+ * @returns {Date} Start of ISO week.
127
+ */
128
+ export const startOfWeek = (date) => {
129
+ return dayjs(date).startOf("isoWeek").toDate();
130
+ };
131
+ /**
132
+ * Return the ISO week end date, Sunday at 23:59:59.999.
133
+ *
134
+ * @param {TDateInput} date - Source date.
135
+ * @returns {Date} End of ISO week.
136
+ */
137
+ export const endOfWeek = (date) => {
138
+ return dayjs(date).endOf("isoWeek").toDate();
139
+ };
140
+ /**
141
+ * Return all seven dates in the ISO week containing the provided date.
142
+ *
143
+ * @param {TDateInput} date - Source date.
144
+ * @returns {Date[]} Monday-through-Sunday dates at the start of each day.
145
+ */
146
+ export const getWeekDays = (date) => {
147
+ const weekStart = dayjs(date).startOf("isoWeek");
148
+ return Array.from({ length: 7 }, (_value, index) => {
149
+ return weekStart.add(index, "day").startOf("day").toDate();
150
+ });
151
+ };
152
+ /**
153
+ * Add weeks to a date.
154
+ *
155
+ * @param {TDateInput} date - Source date.
156
+ * @param {number} weeks - Number of weeks to add.
157
+ * @returns {Date} Updated date.
158
+ */
159
+ export const addWeeks = (date, weeks) => {
160
+ return dayjs(date).add(weeks, "week").toDate();
161
+ };
162
+ /**
163
+ * Subtract weeks from a date.
164
+ *
165
+ * @param {TDateInput} date - Source date.
166
+ * @param {number} weeks - Number of weeks to subtract.
167
+ * @returns {Date} Updated date.
168
+ */
169
+ export const subtractWeeks = (date, weeks) => {
170
+ return dayjs(date).subtract(weeks, "week").toDate();
171
+ };
@@ -1,2 +1,4 @@
1
+ export * from "./date";
1
2
  export * from "./object";
2
- export * from "./string";
3
+ export { camelCase, capitalize, charCount, containsAll, containsAny, escapeRegex, extractNumbers, formatAddress, fromBase64, highlight, isEmail, isEmpty, isNumeric, isPalindrome, isUrl, kebabCase, kebabToSpaces, longestWord, lowerCase, normalCase, normalizeSpaces, padEnd, padStart, pascalCase, pluralize, removeDuplicates, removeSpecialChars, removeWhitespace, repeat, repeatChar, reverse, sentenceCase, slug, snakeCase, snakeCaseToSpaces, splitMultiple, stringSimilarity, stripHtml, titleCase, toBase64, toCamelCase, toKebabCase, toNumber, toPascalCase, toSnakeCase, truncate, upperCase, wordCount, } from "./string";
4
+ export type { IAddress } from "./string";
@@ -1,2 +1,3 @@
1
+ export * from "./date";
1
2
  export * from "./object";
2
- export * from "./string";
3
+ export { camelCase, capitalize, charCount, containsAll, containsAny, escapeRegex, extractNumbers, formatAddress, fromBase64, highlight, isEmail, isEmpty, isNumeric, isPalindrome, isUrl, kebabCase, kebabToSpaces, longestWord, lowerCase, normalCase, normalizeSpaces, padEnd, padStart, pascalCase, pluralize, removeDuplicates, removeSpecialChars, removeWhitespace, repeat, repeatChar, reverse, sentenceCase, slug, snakeCase, snakeCaseToSpaces, splitMultiple, stringSimilarity, stripHtml, titleCase, toBase64, toCamelCase, toKebabCase, toNumber, toPascalCase, toSnakeCase, truncate, upperCase, wordCount, } from "./string";
@@ -1,52 +1,62 @@
1
- import { FilterCondition, SortCondition, TurndownObject } from "../../index";
2
- export interface Version {
3
- major: number;
4
- minor: number;
5
- patch: number;
6
- }
7
- export type VersionInput = string | Version;
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;
8
7
  /**
9
- * Safely parse a JSON string into a value.
8
+ * Safely parse a JSON string into a typed value.
10
9
  *
11
- * Returns `{}` if parsing fails instead of throwing.
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
12
  *
13
- * @param {TurndownObject} jsonString - The JSON string to parse.
14
- * @returns {TurndownObject} Parsed value or `{}` on failure.
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.
15
17
  * @example
16
- * parseJSON('{"a":1}') // => { a: 1 }
18
+ * parseJSON<{ a: number }>('{"a":1}', { a: 0 }) // => { a: 1 }
17
19
  * parseJSON('not json') // => {}
18
20
  */
19
- export declare const parseJSON: (jsonString: TurndownObject) => TurndownObject;
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>;
20
23
  /**
21
- * Stringify an object to JSON while skipping circular references.
24
+ * Stringify a value to JSON while skipping circular references.
22
25
  *
23
26
  * Uses an internal cache to omit repeated object references that would
24
27
  * normally cause `JSON.stringify` to throw.
25
28
  *
26
- * @param {TurndownObject} obj - Value to stringify.
27
- * @returns {string} JSON string with circulars omitted.
29
+ * @param {unknown} value - Value to stringify.
30
+ * @returns {string | undefined} JSON string with circulars omitted.
28
31
  * @example
29
- * const a:any = {}; a.self = a;
30
- * JSONStringify(a) // => "{}"
32
+ * const value: Record<string, unknown> = {}; value.self = value;
33
+ * JSONStringify(value) // => "{}"
31
34
  */
32
- export declare const JSONStringify: (obj: TurndownObject) => string;
35
+ export declare const JSONStringify: (value: unknown) => string | undefined;
33
36
  /**
34
- * Deep-remove `undefined` properties by serializing & parsing.
37
+ * Deep-remove `undefined` properties while preserving Dates and arrays.
35
38
  *
36
- * @param {TurndownObject} obj - Input object.
37
- * @returns {TurndownObject} Cleaned clone with `undefined` removed.
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.
38
45
  */
39
- export declare const removeUndefined: (obj: TurndownObject) => TurndownObject;
46
+ export declare const removeUndefined: <TValue>(value: TValue) => TValue;
40
47
  /**
41
48
  * Test whether a location object's `pathname` equals a key.
42
49
  *
43
- * @param {TurndownObject} location - Object expected to have a `pathname`.
50
+ * @param {{ pathname?: string } | null | undefined} location - Object expected
51
+ * to have a `pathname`.
44
52
  * @param {string} key - Path to compare.
45
53
  * @returns {boolean}
46
54
  * @example
47
55
  * validPath({ pathname: "/home" }, "/home") // true
48
56
  */
49
- export declare const validPath: (location: TurndownObject, key: string) => boolean;
57
+ export declare const validPath: (location: {
58
+ pathname?: string;
59
+ } | null | undefined, key: string) => boolean;
50
60
  /**
51
61
  * Return the first element if the input is an array; otherwise return the value itself.
52
62
  *
@@ -64,7 +74,7 @@ export declare const returnObject: <T>(input: T | T[]) => T;
64
74
  * @typeParam T - Object type with an `id` field.
65
75
  * @param {T[]} [array1] - Source array.
66
76
  * @param {T[]} [array2] - Items whose `id`s should be excluded.
67
- * @returns {T[]} Filtered array (or `[]` on errors/invalid input).
77
+ * @returns {T[]} Filtered array (or `[]` on invalid input).
68
78
  */
69
79
  export declare const filterArrayById: <T extends {
70
80
  id: number | string;
@@ -75,68 +85,72 @@ export declare const filterArrayById: <T extends {
75
85
  * Mutates the original array (uses `Array.prototype.sort`).
76
86
  *
77
87
  * @typeParam T - Object type.
88
+ * @typeParam TKey - Sortable property key.
78
89
  * @param {T[]} array - Array to sort.
79
- * @param {keyof T} property - Property name to sort by.
90
+ * @param {TKey} property - Property name to sort by.
80
91
  * @returns {T[]} The same array instance, sorted (or empty array if input invalid).
81
92
  */
82
- export declare const sortArrayByProperty: <T extends Record<string, any>>(array: T[], property: keyof T) => T[];
93
+ export declare const sortArrayByProperty: <TKey extends PropertyKey, T extends Record<TKey, TSortableValue>>(array: T[], property: TKey) => T[];
83
94
  /**
84
95
  * Recursively replace `null` values with empty strings.
85
96
  *
86
- * Works on primitives, arrays, and plain objects.
97
+ * Works on primitives, arrays, Dates, and plain objects.
87
98
  *
88
- * @param {TurndownObject} obj - Input value.
89
- * @returns {TurndownObject} Value with all `null` replaced by `""`.
99
+ * @typeParam TValue - Input value type.
100
+ * @param {TValue} value - Input value.
101
+ * @returns {TReplaceNulls<TValue>} Value with all `null` replaced by `""`.
90
102
  */
91
- export declare const replaceNulls: (obj: TurndownObject) => TurndownObject;
103
+ export declare const replaceNulls: <TValue>(value: TValue) => TReplaceNulls<TValue>;
92
104
  /**
93
105
  * Recursively remove object keys that contain a dot (`.`).
94
106
  *
95
- * @typeParam T - Object type.
96
- * @param {T} obj - Input object.
97
- * @returns {T} New object with dotted keys removed at all levels.
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.
98
110
  */
99
- export declare const removeFormProperties: <T extends Record<string, TurndownObject>>(obj: T) => T;
111
+ export declare const removeFormProperties: <TValue>(value: TValue) => TValue;
100
112
  /**
101
113
  * Recursively convert string booleans `"true"`/`"false"` to actual booleans.
102
114
  *
103
115
  * Leaves all other values unchanged.
104
116
  *
105
- * @typeParam T - Object type.
106
- * @param {T} obj - Input object or array.
107
- * @returns {T} New value with boolean-like strings converted.
117
+ * @typeParam TValue - Input value type.
118
+ * @param {TValue} value - Input object or array.
119
+ * @returns {TValue} New value with boolean-like strings converted.
108
120
  */
109
- export declare const convertStringBooleans: <T extends Record<string, any>>(obj: T) => T;
121
+ export declare const convertStringBooleans: <TValue>(value: TValue) => TValue;
110
122
  /**
111
123
  * Convenience helper to clean form-like data:
112
124
  * - Removes `undefined` properties
113
125
  * - Converts string booleans to booleans
114
- * - Removes keys containing a dot ('.')
126
+ * - Removes keys containing a dot (`.`)
115
127
  *
116
- * @param {TurndownObject} obj - Input data.
117
- * @returns {TurndownObject} Cleaned clone.
128
+ * @typeParam TObject - Form data object type.
129
+ * @param {TObject} objectToClean - Input data.
130
+ * @returns {Partial<TObject>} Cleaned clone.
118
131
  */
119
- export declare const cleanFormData: (obj: TurndownObject) => any;
132
+ export declare const cleanFormData: <TObject extends TRecord>(objectToClean: TObject) => Partial<TObject>;
120
133
  /**
121
134
  * Return a default pagination object, allowing optional sort and filters.
122
135
  *
123
- * @param {SortCondition[]} [sort] - Optional sort conditions.
124
- * @param {FilterCondition[]} [filters] - Optional filter conditions.
125
- * @returns {{ page: number; size: number; sort: SortCondition[]; filters: FilterCondition[] }}
136
+ * @param {ISortCondition[]} [sort] - Optional sort conditions.
137
+ * @param {IFilterCondition[]} [filters] - Optional filter conditions.
138
+ * @returns {{ page: number; size: number; sort: ISortCondition[]; filters: IFilterCondition[] }}
126
139
  * @example
127
140
  * resetPagination() // => { page:1, size:25, sort:[], filters:[] }
128
141
  */
129
- export declare const resetPagination: (sort?: SortCondition[], filters?: FilterCondition[]) => {
142
+ export declare const resetPagination: (sort?: ISortCondition[], filters?: IFilterCondition[]) => {
130
143
  page: number;
131
144
  size: number;
132
- sort: SortCondition[];
133
- filters: FilterCondition[];
145
+ sort: ISortCondition[];
146
+ filters: IFilterCondition[];
134
147
  };
135
148
  /**
136
149
  * Format a string of digits into a U.S. phone number.
137
150
  *
138
- * Strips non-numeric characters and formats as `(XXX) XXX-XXXX`.
139
- * If fewer than 10 digits are provided, returns the input unchanged.
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.
140
154
  *
141
155
  * @param {string | number} value - Phone number digits (string or number).
142
156
  * @returns {string} Formatted phone number, or original input if invalid length.
@@ -156,58 +170,129 @@ export declare const formatPhoneNumber: (value: string | number) => string;
156
170
  */
157
171
  export declare const formatNumber: (value: number) => string;
158
172
  /**
159
- * Parse a number string (note: current implementation adds commas as well).
173
+ * Remove comma separators from a number-like value.
160
174
  *
161
- * @remarks
162
- * This function uses the same regex as `formatNumber`, so it **does not remove**
163
- * commas; it inserts them. If you intended to *strip* separators, consider:
164
- * `value.toString().replace(/,/g, "")`.
165
- *
166
- * @param {number} value - Number to "parse".
167
- * @returns {string} Currently returns a comma-formatted string.
175
+ * @param {number | string} value - Number-like value.
176
+ * @returns {string} Value without comma separators.
168
177
  */
169
- export declare const parseNumber: (value: number) => string;
178
+ export declare const parseNumber: (value: number | string) => string;
170
179
  /**
171
180
  * Delete a property from an object if it exists (no-op if it doesn't).
172
181
  *
173
- * @param {TurndownObject} obj - Target object (mutated).
174
- * @param {string} propertyName - Property to delete.
182
+ * @typeParam TObject - Object type.
183
+ * @param {TObject} objectToUpdate - Target object (mutated).
184
+ * @param {keyof TObject | string} propertyName - Property to delete.
175
185
  * @returns {void}
176
186
  */
177
- export declare const deletePropertyIfExists: (obj: TurndownObject, propertyName: string) => void;
187
+ export declare const deletePropertyIfExists: <TObject extends TRecord>(objectToUpdate: TObject, propertyName: keyof TObject | string) => void;
178
188
  /**
179
189
  * Split an array into chunks of a given size.
180
190
  *
181
191
  * @typeParam T - Element type.
182
192
  * @param {T[]} array - Source array.
183
- * @param {number} chunkSize - Size of each chunk (no validation performed).
193
+ * @param {number} chunkSize - Size of each chunk.
184
194
  * @returns {T[][]} Array of chunks (last one may be smaller).
185
195
  * @example
186
196
  * chunkArray([1,2,3,4,5], 2) // [[1,2],[3,4],[5]]
187
197
  */
188
198
  export declare const chunkArray: <T>(array: T[], chunkSize: number) => T[][];
189
199
  /**
190
- * Return a shallow clone of `obj` without the listed properties.
200
+ * Return a shallow clone of `objectToOmitFrom` without the listed properties.
191
201
  *
192
- * @param {TurndownObject} obj - Source object.
193
- * @param {TurndownObject} propsToOmit - Iterable of property names (expects array-like).
194
- * @returns {TurndownObject} New object without omitted props.
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.
195
207
  * @example
196
208
  * omitProperties({a:1,b:2}, ["b"]) // { a:1 }
197
209
  */
198
- export declare const omitProperties: (obj: TurndownObject, propsToOmit: TurndownObject) => any;
210
+ export declare const omitProperties: <TObject extends TRecord, TKey extends keyof TObject>(objectToOmitFrom: TObject, propsToOmit: readonly TKey[]) => Omit<TObject, TKey>;
199
211
  /**
200
212
  * Safe `hasOwnProperty` check.
201
213
  *
202
- * @param {Record<string, any>} obj - Object to test.
203
- * @param {string} key - Property name.
214
+ * @param {unknown} value - Value to test.
215
+ * @param {PropertyKey} key - Property name.
204
216
  * @returns {boolean}
205
217
  */
206
- export declare const hasProperty: (obj: Record<string, any>, key: string) => boolean;
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>;
207
227
  /**
208
228
  * Determine if an object has at least one own enumerable property.
209
229
  *
210
- * @param {object} obj - Object to test.
230
+ * @param {unknown} value - Object to test.
211
231
  * @returns {boolean} `true` if there is at least one key.
212
232
  */
213
- export declare const hasProperties: (obj: object) => boolean;
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 {};