@turndown/library 0.0.19 → 0.0.21

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.
@@ -0,0 +1,2 @@
1
+ export * from "./object";
2
+ export * from "./string";
@@ -1,13 +1,10 @@
1
1
  import { FilterCondition, SortCondition, TurndownObject } from "@/types/base";
2
-
3
2
  export interface Version {
4
- major: number;
5
- minor: number;
6
- patch: number;
3
+ major: number;
4
+ minor: number;
5
+ patch: number;
7
6
  }
8
-
9
7
  export type VersionInput = string | Version;
10
-
11
8
  /**
12
9
  * Safely parse a JSON string into a value.
13
10
  *
@@ -19,14 +16,7 @@ export type VersionInput = string | Version;
19
16
  * parseJSON('{"a":1}') // => { a: 1 }
20
17
  * parseJSON('not json') // => {}
21
18
  */
22
- export const parseJSON = (jsonString: TurndownObject): TurndownObject => {
23
- try {
24
- return JSON.parse(jsonString);
25
- } catch (error) {
26
- return {};
27
- }
28
- };
29
-
19
+ export declare const parseJSON: (jsonString: TurndownObject) => TurndownObject;
30
20
  /**
31
21
  * Stringify an object to JSON while skipping circular references.
32
22
  *
@@ -39,31 +29,14 @@ export const parseJSON = (jsonString: TurndownObject): TurndownObject => {
39
29
  * const a:any = {}; a.self = a;
40
30
  * JSONStringify(a) // => "{}"
41
31
  */
42
- export const JSONStringify = (obj: TurndownObject): string => {
43
- let cache: TurndownObject = [];
44
- let str = JSON.stringify(obj, function (_key, value) {
45
- if (typeof value === "object" && value !== null) {
46
- if (cache.indexOf(value) !== -1) {
47
- return;
48
- }
49
- cache.push(value);
50
- }
51
- return value;
52
- });
53
- cache = null;
54
- return str;
55
- };
56
-
32
+ export declare const JSONStringify: (obj: TurndownObject) => string;
57
33
  /**
58
34
  * Deep-remove `undefined` properties by serializing & parsing.
59
35
  *
60
36
  * @param {TurndownObject} obj - Input object.
61
37
  * @returns {TurndownObject} Cleaned clone with `undefined` removed.
62
38
  */
63
- export const removeUndefined = (obj: TurndownObject): TurndownObject => {
64
- return JSON.parse(JSONStringify(obj));
65
- };
66
-
39
+ export declare const removeUndefined: (obj: TurndownObject) => TurndownObject;
67
40
  /**
68
41
  * Test whether a location object's `pathname` equals a key.
69
42
  *
@@ -73,10 +46,7 @@ export const removeUndefined = (obj: TurndownObject): TurndownObject => {
73
46
  * @example
74
47
  * validPath({ pathname: "/home" }, "/home") // true
75
48
  */
76
- export const validPath = (location: TurndownObject, key: string): boolean => {
77
- return location?.pathname === key;
78
- };
79
-
49
+ export declare const validPath: (location: TurndownObject, key: string) => boolean;
80
50
  /**
81
51
  * Return the first element if the input is an array; otherwise return the value itself.
82
52
  *
@@ -87,10 +57,7 @@ export const validPath = (location: TurndownObject, key: string): boolean => {
87
57
  * returnObject([1,2,3]) // 1
88
58
  * returnObject(5) // 5
89
59
  */
90
- export const returnObject = <T>(input: T | T[]): T => {
91
- return Array.isArray(input) ? input[0] : input;
92
- };
93
-
60
+ export declare const returnObject: <T>(input: T | T[]) => T;
94
61
  /**
95
62
  * Filter out items from `array1` whose `id` appears in `array2`.
96
63
  *
@@ -99,21 +66,9 @@ export const returnObject = <T>(input: T | T[]): T => {
99
66
  * @param {T[]} [array2] - Items whose `id`s should be excluded.
100
67
  * @returns {T[]} Filtered array (or `[]` on errors/invalid input).
101
68
  */
102
- export const filterArrayById = <T extends { id: number | string }>(
103
- array1?: T[],
104
- array2?: T[]
105
- ): T[] => {
106
- try {
107
- if (!array1 || !array2) return [];
108
-
109
- const idsToExclude = new Set(array2.map((item) => item.id));
110
- return array1.filter((item) => !idsToExclude.has(item.id));
111
- } catch (error) {
112
- console.error("An error occurred:", error);
113
- return [];
114
- }
115
- };
116
-
69
+ export declare const filterArrayById: <T extends {
70
+ id: number | string;
71
+ }>(array1?: T[], array2?: T[]) => T[];
117
72
  /**
118
73
  * Sort an array of objects by a given property (ascending).
119
74
  *
@@ -124,19 +79,7 @@ export const filterArrayById = <T extends { id: number | string }>(
124
79
  * @param {keyof T} property - Property name to sort by.
125
80
  * @returns {T[]} The same array instance, sorted (or empty array if input invalid).
126
81
  */
127
- export const sortArrayByProperty = <T extends Record<string, any>>(
128
- array: T[],
129
- property: keyof T
130
- ): T[] => {
131
- if (!array || array.length === 0) return [];
132
-
133
- return array.sort((a, b) => {
134
- if (a[property] < b[property]) return -1;
135
- if (a[property] > b[property]) return 1;
136
- return 0;
137
- });
138
- };
139
-
82
+ export declare const sortArrayByProperty: <T extends Record<string, any>>(array: T[], property: keyof T) => T[];
140
83
  /**
141
84
  * Recursively replace `null` values with empty strings.
142
85
  *
@@ -145,23 +88,7 @@ export const sortArrayByProperty = <T extends Record<string, any>>(
145
88
  * @param {TurndownObject} obj - Input value.
146
89
  * @returns {TurndownObject} Value with all `null` replaced by `""`.
147
90
  */
148
- export const replaceNulls = (obj: TurndownObject): TurndownObject => {
149
- if (obj === null) {
150
- return "";
151
- } else if (Array.isArray(obj)) {
152
- return obj.map(replaceNulls);
153
- } else if (typeof obj === "object" && obj !== null) {
154
- const newObj: any = {};
155
- for (const key in obj) {
156
- if (obj.hasOwnProperty(key)) {
157
- newObj[key] = replaceNulls(obj[key]);
158
- }
159
- }
160
- return newObj;
161
- }
162
- return obj;
163
- };
164
-
91
+ export declare const replaceNulls: (obj: TurndownObject) => TurndownObject;
165
92
  /**
166
93
  * Recursively remove object keys that contain a dot (`.`).
167
94
  *
@@ -169,30 +96,7 @@ export const replaceNulls = (obj: TurndownObject): TurndownObject => {
169
96
  * @param {T} obj - Input object.
170
97
  * @returns {T} New object with dotted keys removed at all levels.
171
98
  */
172
- export const removeFormProperties = <T extends Record<string, TurndownObject>>(
173
- obj: T
174
- ): T => {
175
- const recursiveRemove = (input: TurndownObject): TurndownObject => {
176
- if (Array.isArray(input)) {
177
- return input.map((item) => recursiveRemove(item));
178
- } else if (typeof input === "object" && input !== null) {
179
- const newObj: Record<string, TurndownObject> = { ...input };
180
-
181
- Object.keys(newObj).forEach((key) => {
182
- if (key.includes(".")) {
183
- delete newObj[key];
184
- } else {
185
- newObj[key] = recursiveRemove(newObj[key]);
186
- }
187
- });
188
- return newObj;
189
- }
190
- return input;
191
- };
192
-
193
- return recursiveRemove(obj);
194
- };
195
-
99
+ export declare const removeFormProperties: <T extends Record<string, TurndownObject>>(obj: T) => T;
196
100
  /**
197
101
  * Recursively convert string booleans `"true"`/`"false"` to actual booleans.
198
102
  *
@@ -202,36 +106,7 @@ export const removeFormProperties = <T extends Record<string, TurndownObject>>(
202
106
  * @param {T} obj - Input object or array.
203
107
  * @returns {T} New value with boolean-like strings converted.
204
108
  */
205
- export const convertStringBooleans = <T extends Record<string, any>>(
206
- obj: T
207
- ): T => {
208
- const recursiveConvert = (input: any): any => {
209
- if (Array.isArray(input)) {
210
- return input.map((item) => recursiveConvert(item));
211
- } else if (typeof input === "object" && input !== null) {
212
- const newObj: Record<string, any> = { ...input };
213
-
214
- Object.keys(newObj).forEach((key) => {
215
- const value = newObj[key];
216
-
217
- if (value === "true") {
218
- newObj[key] = true;
219
- } else if (value === "false") {
220
- newObj[key] = false;
221
- } else if (typeof value === "object" && value !== null) {
222
- newObj[key] = recursiveConvert(value);
223
- }
224
- });
225
-
226
- return newObj;
227
- }
228
-
229
- return input;
230
- };
231
-
232
- return recursiveConvert(obj);
233
- };
234
-
109
+ export declare const convertStringBooleans: <T extends Record<string, any>>(obj: T) => T;
235
110
  /**
236
111
  * Convenience helper to clean form-like data:
237
112
  * - Removes `undefined` properties
@@ -241,10 +116,7 @@ export const convertStringBooleans = <T extends Record<string, any>>(
241
116
  * @param {TurndownObject} obj - Input data.
242
117
  * @returns {TurndownObject} Cleaned clone.
243
118
  */
244
- export const cleanFormData = (obj: TurndownObject) => {
245
- return removeFormProperties(convertStringBooleans(removeUndefined(obj)));
246
- };
247
-
119
+ export declare const cleanFormData: (obj: TurndownObject) => any;
248
120
  /**
249
121
  * Return a default pagination object, allowing optional sort and filters.
250
122
  *
@@ -254,18 +126,12 @@ export const cleanFormData = (obj: TurndownObject) => {
254
126
  * @example
255
127
  * resetPagination() // => { page:1, size:25, sort:[], filters:[] }
256
128
  */
257
- export const resetPagination = (
258
- sort?: SortCondition[],
259
- filters?: FilterCondition[]
260
- ) => {
261
- return {
262
- page: 1,
263
- size: 25,
264
- sort: sort || [],
265
- filters: filters || [],
266
- };
129
+ export declare const resetPagination: (sort?: SortCondition[], filters?: FilterCondition[]) => {
130
+ page: number;
131
+ size: number;
132
+ sort: SortCondition[];
133
+ filters: FilterCondition[];
267
134
  };
268
-
269
135
  /**
270
136
  * Format a string of digits into a U.S. phone number.
271
137
  *
@@ -279,17 +145,7 @@ export const resetPagination = (
279
145
  * formatPhoneNumber(9876543210) // "(987) 654-3210"
280
146
  * formatPhoneNumber("555") // "555"
281
147
  */
282
- export const formatPhoneNumber = (value: string | number): string => {
283
- const digits = value.toString().replace(/\D/g, "");
284
- if (digits.length !== 10) return value.toString();
285
-
286
- const area = digits.slice(0, 3);
287
- const prefix = digits.slice(3, 6);
288
- const line = digits.slice(6);
289
-
290
- return `(${area}) ${prefix}-${line}`;
291
- };
292
-
148
+ export declare const formatPhoneNumber: (value: string | number) => string;
293
149
  /**
294
150
  * Format a number with thousands separators (commas).
295
151
  *
@@ -298,10 +154,7 @@ export const formatPhoneNumber = (value: string | number): string => {
298
154
  * @example
299
155
  * formatNumber(1234567) // "1,234,567"
300
156
  */
301
- export const formatNumber = (value: number): string => {
302
- return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
303
- };
304
-
157
+ export declare const formatNumber: (value: number) => string;
305
158
  /**
306
159
  * Parse a number string (note: current implementation adds commas as well).
307
160
  *
@@ -313,10 +166,7 @@ export const formatNumber = (value: number): string => {
313
166
  * @param {number} value - Number to "parse".
314
167
  * @returns {string} Currently returns a comma-formatted string.
315
168
  */
316
- export const parseNumber = (value: number): string => {
317
- return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "");
318
- };
319
-
169
+ export declare const parseNumber: (value: number) => string;
320
170
  /**
321
171
  * Delete a property from an object if it exists (no-op if it doesn't).
322
172
  *
@@ -324,15 +174,7 @@ export const parseNumber = (value: number): string => {
324
174
  * @param {string} propertyName - Property to delete.
325
175
  * @returns {void}
326
176
  */
327
- export const deletePropertyIfExists = (
328
- obj: TurndownObject,
329
- propertyName: string
330
- ) => {
331
- if (Object.prototype.hasOwnProperty.call(obj, propertyName)) {
332
- delete obj[propertyName];
333
- }
334
- };
335
-
177
+ export declare const deletePropertyIfExists: (obj: TurndownObject, propertyName: string) => void;
336
178
  /**
337
179
  * Split an array into chunks of a given size.
338
180
  *
@@ -343,14 +185,7 @@ export const deletePropertyIfExists = (
343
185
  * @example
344
186
  * chunkArray([1,2,3,4,5], 2) // [[1,2],[3,4],[5]]
345
187
  */
346
- export const chunkArray = <T>(array: T[], chunkSize: number): T[][] => {
347
- const result: T[][] = [];
348
- for (let i = 0; i < array.length; i += chunkSize) {
349
- result.push(array.slice(i, i + chunkSize));
350
- }
351
- return result;
352
- };
353
-
188
+ export declare const chunkArray: <T>(array: T[], chunkSize: number) => T[][];
354
189
  /**
355
190
  * Return a shallow clone of `obj` without the listed properties.
356
191
  *
@@ -360,18 +195,7 @@ export const chunkArray = <T>(array: T[], chunkSize: number): T[][] => {
360
195
  * @example
361
196
  * omitProperties({a:1,b:2}, ["b"]) // { a:1 }
362
197
  */
363
- export const omitProperties = (
364
- obj: TurndownObject,
365
- propsToOmit: TurndownObject
366
- ) => {
367
- const newObj = { ...obj };
368
- propsToOmit.forEach((prop: TurndownObject) => {
369
- delete newObj[prop];
370
- });
371
-
372
- return newObj;
373
- };
374
-
198
+ export declare const omitProperties: (obj: TurndownObject, propsToOmit: TurndownObject) => any;
375
199
  /**
376
200
  * Safe `hasOwnProperty` check.
377
201
  *
@@ -379,17 +203,11 @@ export const omitProperties = (
379
203
  * @param {string} key - Property name.
380
204
  * @returns {boolean}
381
205
  */
382
- export const hasProperty = (obj: Record<string, any>, key: string): boolean => {
383
- if (!obj) return false;
384
- return Object.prototype.hasOwnProperty.call(obj, key);
385
- };
386
-
206
+ export declare const hasProperty: (obj: Record<string, any>, key: string) => boolean;
387
207
  /**
388
208
  * Determine if an object has at least one own enumerable property.
389
209
  *
390
210
  * @param {object} obj - Object to test.
391
211
  * @returns {boolean} `true` if there is at least one key.
392
212
  */
393
- export const hasProperties = (obj: object): boolean => {
394
- return Object.keys(obj || {}).length > 0;
395
- };
213
+ export declare const hasProperties: (obj: object) => boolean;
@@ -0,0 +1,350 @@
1
+ /**
2
+ * Safely parse a JSON string into a value.
3
+ *
4
+ * Returns `{}` if parsing fails instead of throwing.
5
+ *
6
+ * @param {TurndownObject} jsonString - The JSON string to parse.
7
+ * @returns {TurndownObject} Parsed value or `{}` on failure.
8
+ * @example
9
+ * parseJSON('{"a":1}') // => { a: 1 }
10
+ * parseJSON('not json') // => {}
11
+ */
12
+ export const parseJSON = (jsonString) => {
13
+ try {
14
+ return JSON.parse(jsonString);
15
+ }
16
+ catch (error) {
17
+ return {};
18
+ }
19
+ };
20
+ /**
21
+ * Stringify an object to JSON while skipping circular references.
22
+ *
23
+ * Uses an internal cache to omit repeated object references that would
24
+ * normally cause `JSON.stringify` to throw.
25
+ *
26
+ * @param {TurndownObject} obj - Value to stringify.
27
+ * @returns {string} JSON string with circulars omitted.
28
+ * @example
29
+ * const a:any = {}; a.self = a;
30
+ * JSONStringify(a) // => "{}"
31
+ */
32
+ export const JSONStringify = (obj) => {
33
+ let cache = [];
34
+ let str = JSON.stringify(obj, function (_key, value) {
35
+ if (typeof value === "object" && value !== null) {
36
+ if (cache.indexOf(value) !== -1) {
37
+ return;
38
+ }
39
+ cache.push(value);
40
+ }
41
+ return value;
42
+ });
43
+ cache = null;
44
+ return str;
45
+ };
46
+ /**
47
+ * Deep-remove `undefined` properties by serializing & parsing.
48
+ *
49
+ * @param {TurndownObject} obj - Input object.
50
+ * @returns {TurndownObject} Cleaned clone with `undefined` removed.
51
+ */
52
+ export const removeUndefined = (obj) => {
53
+ return JSON.parse(JSONStringify(obj));
54
+ };
55
+ /**
56
+ * Test whether a location object's `pathname` equals a key.
57
+ *
58
+ * @param {TurndownObject} location - Object expected to have a `pathname`.
59
+ * @param {string} key - Path to compare.
60
+ * @returns {boolean}
61
+ * @example
62
+ * validPath({ pathname: "/home" }, "/home") // true
63
+ */
64
+ export const validPath = (location, key) => {
65
+ return location?.pathname === key;
66
+ };
67
+ /**
68
+ * Return the first element if the input is an array; otherwise return the value itself.
69
+ *
70
+ * @typeParam T - Element type.
71
+ * @param {T | T[]} input - A single value or an array.
72
+ * @returns {T} First element or the input value.
73
+ * @example
74
+ * returnObject([1,2,3]) // 1
75
+ * returnObject(5) // 5
76
+ */
77
+ export const returnObject = (input) => {
78
+ return Array.isArray(input) ? input[0] : input;
79
+ };
80
+ /**
81
+ * Filter out items from `array1` whose `id` appears in `array2`.
82
+ *
83
+ * @typeParam T - Object type with an `id` field.
84
+ * @param {T[]} [array1] - Source array.
85
+ * @param {T[]} [array2] - Items whose `id`s should be excluded.
86
+ * @returns {T[]} Filtered array (or `[]` on errors/invalid input).
87
+ */
88
+ export const filterArrayById = (array1, array2) => {
89
+ try {
90
+ if (!array1 || !array2)
91
+ return [];
92
+ const idsToExclude = new Set(array2.map((item) => item.id));
93
+ return array1.filter((item) => !idsToExclude.has(item.id));
94
+ }
95
+ catch (error) {
96
+ console.error("An error occurred:", error);
97
+ return [];
98
+ }
99
+ };
100
+ /**
101
+ * Sort an array of objects by a given property (ascending).
102
+ *
103
+ * Mutates the original array (uses `Array.prototype.sort`).
104
+ *
105
+ * @typeParam T - Object type.
106
+ * @param {T[]} array - Array to sort.
107
+ * @param {keyof T} property - Property name to sort by.
108
+ * @returns {T[]} The same array instance, sorted (or empty array if input invalid).
109
+ */
110
+ export const sortArrayByProperty = (array, property) => {
111
+ if (!array || array.length === 0)
112
+ return [];
113
+ return array.sort((a, b) => {
114
+ if (a[property] < b[property])
115
+ return -1;
116
+ if (a[property] > b[property])
117
+ return 1;
118
+ return 0;
119
+ });
120
+ };
121
+ /**
122
+ * Recursively replace `null` values with empty strings.
123
+ *
124
+ * Works on primitives, arrays, and plain objects.
125
+ *
126
+ * @param {TurndownObject} obj - Input value.
127
+ * @returns {TurndownObject} Value with all `null` replaced by `""`.
128
+ */
129
+ export const replaceNulls = (obj) => {
130
+ if (obj === null) {
131
+ return "";
132
+ }
133
+ else if (Array.isArray(obj)) {
134
+ return obj.map(replaceNulls);
135
+ }
136
+ else if (typeof obj === "object" && obj !== null) {
137
+ const newObj = {};
138
+ for (const key in obj) {
139
+ if (obj.hasOwnProperty(key)) {
140
+ newObj[key] = replaceNulls(obj[key]);
141
+ }
142
+ }
143
+ return newObj;
144
+ }
145
+ return obj;
146
+ };
147
+ /**
148
+ * Recursively remove object keys that contain a dot (`.`).
149
+ *
150
+ * @typeParam T - Object type.
151
+ * @param {T} obj - Input object.
152
+ * @returns {T} New object with dotted keys removed at all levels.
153
+ */
154
+ export const removeFormProperties = (obj) => {
155
+ const recursiveRemove = (input) => {
156
+ if (Array.isArray(input)) {
157
+ return input.map((item) => recursiveRemove(item));
158
+ }
159
+ else if (typeof input === "object" && input !== null) {
160
+ const newObj = { ...input };
161
+ Object.keys(newObj).forEach((key) => {
162
+ if (key.includes(".")) {
163
+ delete newObj[key];
164
+ }
165
+ else {
166
+ newObj[key] = recursiveRemove(newObj[key]);
167
+ }
168
+ });
169
+ return newObj;
170
+ }
171
+ return input;
172
+ };
173
+ return recursiveRemove(obj);
174
+ };
175
+ /**
176
+ * Recursively convert string booleans `"true"`/`"false"` to actual booleans.
177
+ *
178
+ * Leaves all other values unchanged.
179
+ *
180
+ * @typeParam T - Object type.
181
+ * @param {T} obj - Input object or array.
182
+ * @returns {T} New value with boolean-like strings converted.
183
+ */
184
+ export const convertStringBooleans = (obj) => {
185
+ const recursiveConvert = (input) => {
186
+ if (Array.isArray(input)) {
187
+ return input.map((item) => recursiveConvert(item));
188
+ }
189
+ else if (typeof input === "object" && input !== null) {
190
+ const newObj = { ...input };
191
+ Object.keys(newObj).forEach((key) => {
192
+ const value = newObj[key];
193
+ if (value === "true") {
194
+ newObj[key] = true;
195
+ }
196
+ else if (value === "false") {
197
+ newObj[key] = false;
198
+ }
199
+ else if (typeof value === "object" && value !== null) {
200
+ newObj[key] = recursiveConvert(value);
201
+ }
202
+ });
203
+ return newObj;
204
+ }
205
+ return input;
206
+ };
207
+ return recursiveConvert(obj);
208
+ };
209
+ /**
210
+ * Convenience helper to clean form-like data:
211
+ * - Removes `undefined` properties
212
+ * - Converts string booleans to booleans
213
+ * - Removes keys containing a dot ('.')
214
+ *
215
+ * @param {TurndownObject} obj - Input data.
216
+ * @returns {TurndownObject} Cleaned clone.
217
+ */
218
+ export const cleanFormData = (obj) => {
219
+ return removeFormProperties(convertStringBooleans(removeUndefined(obj)));
220
+ };
221
+ /**
222
+ * Return a default pagination object, allowing optional sort and filters.
223
+ *
224
+ * @param {SortCondition[]} [sort] - Optional sort conditions.
225
+ * @param {FilterCondition[]} [filters] - Optional filter conditions.
226
+ * @returns {{ page: number; size: number; sort: SortCondition[]; filters: FilterCondition[] }}
227
+ * @example
228
+ * resetPagination() // => { page:1, size:25, sort:[], filters:[] }
229
+ */
230
+ export const resetPagination = (sort, filters) => {
231
+ return {
232
+ page: 1,
233
+ size: 25,
234
+ sort: sort || [],
235
+ filters: filters || [],
236
+ };
237
+ };
238
+ /**
239
+ * Format a string of digits into a U.S. phone number.
240
+ *
241
+ * Strips non-numeric characters and formats as `(XXX) XXX-XXXX`.
242
+ * If fewer than 10 digits are provided, returns the input unchanged.
243
+ *
244
+ * @param {string | number} value - Phone number digits (string or number).
245
+ * @returns {string} Formatted phone number, or original input if invalid length.
246
+ * @example
247
+ * formatPhoneNumber("1234567890") // "(123) 456-7890"
248
+ * formatPhoneNumber(9876543210) // "(987) 654-3210"
249
+ * formatPhoneNumber("555") // "555"
250
+ */
251
+ export const formatPhoneNumber = (value) => {
252
+ const digits = value.toString().replace(/\D/g, "");
253
+ if (digits.length !== 10)
254
+ return value.toString();
255
+ const area = digits.slice(0, 3);
256
+ const prefix = digits.slice(3, 6);
257
+ const line = digits.slice(6);
258
+ return `(${area}) ${prefix}-${line}`;
259
+ };
260
+ /**
261
+ * Format a number with thousands separators (commas).
262
+ *
263
+ * @param {number} value - Number to format.
264
+ * @returns {string} String with commas.
265
+ * @example
266
+ * formatNumber(1234567) // "1,234,567"
267
+ */
268
+ export const formatNumber = (value) => {
269
+ return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
270
+ };
271
+ /**
272
+ * Parse a number string (note: current implementation adds commas as well).
273
+ *
274
+ * @remarks
275
+ * This function uses the same regex as `formatNumber`, so it **does not remove**
276
+ * commas; it inserts them. If you intended to *strip* separators, consider:
277
+ * `value.toString().replace(/,/g, "")`.
278
+ *
279
+ * @param {number} value - Number to "parse".
280
+ * @returns {string} Currently returns a comma-formatted string.
281
+ */
282
+ export const parseNumber = (value) => {
283
+ return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "");
284
+ };
285
+ /**
286
+ * Delete a property from an object if it exists (no-op if it doesn't).
287
+ *
288
+ * @param {TurndownObject} obj - Target object (mutated).
289
+ * @param {string} propertyName - Property to delete.
290
+ * @returns {void}
291
+ */
292
+ export const deletePropertyIfExists = (obj, propertyName) => {
293
+ if (Object.prototype.hasOwnProperty.call(obj, propertyName)) {
294
+ delete obj[propertyName];
295
+ }
296
+ };
297
+ /**
298
+ * Split an array into chunks of a given size.
299
+ *
300
+ * @typeParam T - Element type.
301
+ * @param {T[]} array - Source array.
302
+ * @param {number} chunkSize - Size of each chunk (no validation performed).
303
+ * @returns {T[][]} Array of chunks (last one may be smaller).
304
+ * @example
305
+ * chunkArray([1,2,3,4,5], 2) // [[1,2],[3,4],[5]]
306
+ */
307
+ export const chunkArray = (array, chunkSize) => {
308
+ const result = [];
309
+ for (let i = 0; i < array.length; i += chunkSize) {
310
+ result.push(array.slice(i, i + chunkSize));
311
+ }
312
+ return result;
313
+ };
314
+ /**
315
+ * Return a shallow clone of `obj` without the listed properties.
316
+ *
317
+ * @param {TurndownObject} obj - Source object.
318
+ * @param {TurndownObject} propsToOmit - Iterable of property names (expects array-like).
319
+ * @returns {TurndownObject} New object without omitted props.
320
+ * @example
321
+ * omitProperties({a:1,b:2}, ["b"]) // { a:1 }
322
+ */
323
+ export const omitProperties = (obj, propsToOmit) => {
324
+ const newObj = { ...obj };
325
+ propsToOmit.forEach((prop) => {
326
+ delete newObj[prop];
327
+ });
328
+ return newObj;
329
+ };
330
+ /**
331
+ * Safe `hasOwnProperty` check.
332
+ *
333
+ * @param {Record<string, any>} obj - Object to test.
334
+ * @param {string} key - Property name.
335
+ * @returns {boolean}
336
+ */
337
+ export const hasProperty = (obj, key) => {
338
+ if (!obj)
339
+ return false;
340
+ return Object.prototype.hasOwnProperty.call(obj, key);
341
+ };
342
+ /**
343
+ * Determine if an object has at least one own enumerable property.
344
+ *
345
+ * @param {object} obj - Object to test.
346
+ * @returns {boolean} `true` if there is at least one key.
347
+ */
348
+ export const hasProperties = (obj) => {
349
+ return Object.keys(obj || {}).length > 0;
350
+ };
@@ -0,0 +1,104 @@
1
+ import { TurndownObject } from "@/types/base";
2
+ /**
3
+ * Convert a string to "Normal Case":
4
+ * - Inserts spaces between camel/pascal case boundaries
5
+ * - Capitalizes the first letter of each word, lowercases the rest
6
+ *
7
+ * @param {TurndownObject} [str] Input value (falsy returns an empty string)
8
+ * @returns {string}
9
+ * @example
10
+ * normalCase("helloWorld") // "Hello World"
11
+ * normalCase("XMLHttpRequest") // "Xml Http Request"
12
+ */
13
+ export declare const normalCase: (str?: TurndownObject) => string;
14
+ /**
15
+ * Capitalize only the first character; lowercases the rest.
16
+ * Trims leading/trailing spaces before processing.
17
+ *
18
+ * @param {TurndownObject} [str] Input value (falsy returns an empty string)
19
+ * @returns {string}
20
+ * @example
21
+ * sentenceCase("hELLO WORLD") // "Hello world"
22
+ */
23
+ export declare const sentenceCase: (str?: TurndownObject) => string;
24
+ /**
25
+ * Uppercase the entire string.
26
+ *
27
+ * @param {TurndownObject} [str] Input value (falsy returns an empty string)
28
+ * @returns {string}
29
+ * @example
30
+ * upperCase("Hello world") // "HELLO WORLD"
31
+ */
32
+ export declare const upperCase: (str?: TurndownObject) => string;
33
+ /**
34
+ * Lowercase the entire string.
35
+ *
36
+ * @param {TurndownObject} [str] Input value (falsy returns an empty string)
37
+ * @returns {string}
38
+ * @example
39
+ * lowerCase("Hello WORLD") // "hello world"
40
+ */
41
+ export declare const lowerCase: (str?: TurndownObject) => string;
42
+ /**
43
+ * Convert to camelCase.
44
+ * Splits on spaces, underscores, and hyphens; lowercases the first word,
45
+ * TitleCases the rest, then joins with no separators.
46
+ *
47
+ * @param {TurndownObject} [str] Input value (falsy returns an empty string)
48
+ * @returns {string}
49
+ * @example
50
+ * camelCase("Hello world") // "helloWorld"
51
+ * camelCase("hello_world-again") // "helloWorldAgain"
52
+ */
53
+ export declare const camelCase: (str?: TurndownObject) => string;
54
+ /**
55
+ * Convert to PascalCase.
56
+ * Splits on spaces, underscores, and hyphens; TitleCases all words and joins them.
57
+ *
58
+ * @param {TurndownObject} [str] Input value (falsy returns an empty string)
59
+ * @returns {string}
60
+ * @example
61
+ * pascalCase("hello world") // "HelloWorld"
62
+ * pascalCase("hello_world-again") // "HelloWorldAgain"
63
+ */
64
+ export declare const pascalCase: (str?: TurndownObject) => string;
65
+ /**
66
+ * Convert to kebab-case.
67
+ * Inserts hyphens between camelCase boundaries, then replaces spaces/underscores with hyphens.
68
+ *
69
+ * @param {TurndownObject} [str] Input value (falsy returns an empty string)
70
+ * @returns {string}
71
+ * @example
72
+ * kebabCase("HelloWorld Again") // "hello-world-again"
73
+ * kebabCase("hello_world") // "hello-world"
74
+ */
75
+ export declare const kebabCase: (str?: TurndownObject) => string;
76
+ /**
77
+ * Convert to snake_case.
78
+ * Inserts underscores between camelCase boundaries, then replaces spaces/hyphens with underscores.
79
+ *
80
+ * @param {TurndownObject} [str] Input value (falsy returns an empty string)
81
+ * @returns {string}
82
+ * @example
83
+ * snakeCase("HelloWorld Again") // "hello_world_again"
84
+ * snakeCase("hello-world") // "hello_world"
85
+ */
86
+ export declare const snakeCase: (str?: TurndownObject) => string;
87
+ /**
88
+ * Convert snake_case to space-delimited words.
89
+ *
90
+ * @param {TurndownObject} [str] Input value (falsy returns an empty string)
91
+ * @returns {string}
92
+ * @example
93
+ * snakeCaseToSpaces("hello_world_again") // "hello world again"
94
+ */
95
+ export declare const snakeCaseToSpaces: (str?: TurndownObject) => string;
96
+ /**
97
+ * Convert kebab-case to space-delimited words.
98
+ *
99
+ * @param {TurndownObject} [str] Input value (falsy returns an empty string)
100
+ * @returns {string}
101
+ * @example
102
+ * kebabToSpaces("hello-world-again") // "hello world again"
103
+ */
104
+ export declare const kebabToSpaces: (str?: TurndownObject) => string;
@@ -1,5 +1,3 @@
1
- import { TurndownObject } from "@/types/base";
2
-
3
1
  /**
4
2
  * Convert a string to "Normal Case":
5
3
  * - Inserts spaces between camel/pascal case boundaries
@@ -11,20 +9,16 @@ import { TurndownObject } from "@/types/base";
11
9
  * normalCase("helloWorld") // "Hello World"
12
10
  * normalCase("XMLHttpRequest") // "Xml Http Request"
13
11
  */
14
- export const normalCase = (str?: TurndownObject): string => {
15
- if (!str) return "";
16
-
17
- return str
18
- .replace(/([a-z])([A-Z])/g, "$1 $2")
19
- .replace(/([A-Z])([A-Z][a-z])/g, "$1 $2")
20
- .split(/\s+/)
21
- .map(
22
- (word: string) =>
23
- word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
24
- )
25
- .join(" ");
12
+ export const normalCase = (str) => {
13
+ if (!str)
14
+ return "";
15
+ return str
16
+ .replace(/([a-z])([A-Z])/g, "$1 $2")
17
+ .replace(/([A-Z])([A-Z][a-z])/g, "$1 $2")
18
+ .split(/\s+/)
19
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
20
+ .join(" ");
26
21
  };
27
-
28
22
  /**
29
23
  * Capitalize only the first character; lowercases the rest.
30
24
  * Trims leading/trailing spaces before processing.
@@ -34,13 +28,12 @@ export const normalCase = (str?: TurndownObject): string => {
34
28
  * @example
35
29
  * sentenceCase("hELLO WORLD") // "Hello world"
36
30
  */
37
- export const sentenceCase = (str?: TurndownObject): string => {
38
- if (!str) return "";
39
-
40
- const s = str.trim();
41
- return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
31
+ export const sentenceCase = (str) => {
32
+ if (!str)
33
+ return "";
34
+ const s = str.trim();
35
+ return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
42
36
  };
43
-
44
37
  /**
45
38
  * Uppercase the entire string.
46
39
  *
@@ -49,10 +42,9 @@ export const sentenceCase = (str?: TurndownObject): string => {
49
42
  * @example
50
43
  * upperCase("Hello world") // "HELLO WORLD"
51
44
  */
52
- export const upperCase = (str?: TurndownObject): string => {
53
- return str ? str.toUpperCase() : "";
45
+ export const upperCase = (str) => {
46
+ return str ? str.toUpperCase() : "";
54
47
  };
55
-
56
48
  /**
57
49
  * Lowercase the entire string.
58
50
  *
@@ -61,10 +53,9 @@ export const upperCase = (str?: TurndownObject): string => {
61
53
  * @example
62
54
  * lowerCase("Hello WORLD") // "hello world"
63
55
  */
64
- export const lowerCase = (str?: TurndownObject): string => {
65
- return str ? str.toLowerCase() : "";
56
+ export const lowerCase = (str) => {
57
+ return str ? str.toLowerCase() : "";
66
58
  };
67
-
68
59
  /**
69
60
  * Convert to camelCase.
70
61
  * Splits on spaces, underscores, and hyphens; lowercases the first word,
@@ -76,19 +67,17 @@ export const lowerCase = (str?: TurndownObject): string => {
76
67
  * camelCase("Hello world") // "helloWorld"
77
68
  * camelCase("hello_world-again") // "helloWorldAgain"
78
69
  */
79
- export const camelCase = (str?: TurndownObject): string => {
80
- if (!str) return "";
81
- return str
82
- .toLowerCase()
83
- .split(/[\s_-]+/)
84
- .map((word: string, i: number) =>
85
- i === 0
70
+ export const camelCase = (str) => {
71
+ if (!str)
72
+ return "";
73
+ return str
74
+ .toLowerCase()
75
+ .split(/[\s_-]+/)
76
+ .map((word, i) => i === 0
86
77
  ? word
87
- : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
88
- )
89
- .join("");
78
+ : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
79
+ .join("");
90
80
  };
91
-
92
81
  /**
93
82
  * Convert to PascalCase.
94
83
  * Splits on spaces, underscores, and hyphens; TitleCases all words and joins them.
@@ -99,15 +88,15 @@ export const camelCase = (str?: TurndownObject): string => {
99
88
  * pascalCase("hello world") // "HelloWorld"
100
89
  * pascalCase("hello_world-again") // "HelloWorldAgain"
101
90
  */
102
- export const pascalCase = (str?: TurndownObject): string => {
103
- if (!str) return "";
104
- return str
105
- .toLowerCase()
106
- .split(/[\s_-]+/)
107
- .map((word: string) => word.charAt(0).toUpperCase() + word.slice(1))
108
- .join("");
91
+ export const pascalCase = (str) => {
92
+ if (!str)
93
+ return "";
94
+ return str
95
+ .toLowerCase()
96
+ .split(/[\s_-]+/)
97
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
98
+ .join("");
109
99
  };
110
-
111
100
  /**
112
101
  * Convert to kebab-case.
113
102
  * Inserts hyphens between camelCase boundaries, then replaces spaces/underscores with hyphens.
@@ -118,14 +107,14 @@ export const pascalCase = (str?: TurndownObject): string => {
118
107
  * kebabCase("HelloWorld Again") // "hello-world-again"
119
108
  * kebabCase("hello_world") // "hello-world"
120
109
  */
121
- export const kebabCase = (str?: TurndownObject): string => {
122
- if (!str) return "";
123
- return str
124
- .replace(/([a-z])([A-Z])/g, "$1-$2")
125
- .replace(/[\s_]+/g, "-")
126
- .toLowerCase();
110
+ export const kebabCase = (str) => {
111
+ if (!str)
112
+ return "";
113
+ return str
114
+ .replace(/([a-z])([A-Z])/g, "$1-$2")
115
+ .replace(/[\s_]+/g, "-")
116
+ .toLowerCase();
127
117
  };
128
-
129
118
  /**
130
119
  * Convert to snake_case.
131
120
  * Inserts underscores between camelCase boundaries, then replaces spaces/hyphens with underscores.
@@ -136,14 +125,14 @@ export const kebabCase = (str?: TurndownObject): string => {
136
125
  * snakeCase("HelloWorld Again") // "hello_world_again"
137
126
  * snakeCase("hello-world") // "hello_world"
138
127
  */
139
- export const snakeCase = (str?: TurndownObject): string => {
140
- if (!str) return "";
141
- return str
142
- .replace(/([a-z])([A-Z])/g, "$1_$2")
143
- .replace(/[\s-]+/g, "_")
144
- .toLowerCase();
128
+ export const snakeCase = (str) => {
129
+ if (!str)
130
+ return "";
131
+ return str
132
+ .replace(/([a-z])([A-Z])/g, "$1_$2")
133
+ .replace(/[\s-]+/g, "_")
134
+ .toLowerCase();
145
135
  };
146
-
147
136
  /**
148
137
  * Convert snake_case to space-delimited words.
149
138
  *
@@ -152,11 +141,11 @@ export const snakeCase = (str?: TurndownObject): string => {
152
141
  * @example
153
142
  * snakeCaseToSpaces("hello_world_again") // "hello world again"
154
143
  */
155
- export const snakeCaseToSpaces = (str?: TurndownObject): string => {
156
- if (!str) return "";
157
- return str.split("_").join(" ");
144
+ export const snakeCaseToSpaces = (str) => {
145
+ if (!str)
146
+ return "";
147
+ return str.split("_").join(" ");
158
148
  };
159
-
160
149
  /**
161
150
  * Convert kebab-case to space-delimited words.
162
151
  *
@@ -165,7 +154,8 @@ export const snakeCaseToSpaces = (str?: TurndownObject): string => {
165
154
  * @example
166
155
  * kebabToSpaces("hello-world-again") // "hello world again"
167
156
  */
168
- export const kebabToSpaces = (str?: TurndownObject): string => {
169
- if (!str) return "";
170
- return str.split("-").join(" ");
157
+ export const kebabToSpaces = (str) => {
158
+ if (!str)
159
+ return "";
160
+ return str.split("-").join(" ");
171
161
  };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./helpers";
2
+ export * from "./types";
@@ -0,0 +1,18 @@
1
+ export type GenericTurndownObject = Record<string, any> | any | undefined;
2
+ export type TurndownObject<T = GenericTurndownObject> = Record<string, T> | T | undefined;
3
+ export type ObjectValues<T> = T[keyof T];
4
+ export type ObjectKeys<T> = [keyof T];
5
+ export interface MetaData {
6
+ company_id: string;
7
+ deleted: boolean;
8
+ updated_by: string;
9
+ created_by: string;
10
+ created_at: Date;
11
+ updated_at: Date;
12
+ }
13
+ export declare const STATUS: {
14
+ readonly ACTIVE: "ACTIVE";
15
+ readonly INACTIVE: "INACTIVE";
16
+ };
17
+ export type Status = ObjectValues<typeof STATUS>;
18
+ export * from "./paging.types";
@@ -0,0 +1,5 @@
1
+ export const STATUS = {
2
+ ACTIVE: "ACTIVE",
3
+ INACTIVE: "INACTIVE",
4
+ };
5
+ export * from "./paging.types";
@@ -0,0 +1,30 @@
1
+ export interface PagingResult {
2
+ hasNextPage: boolean;
3
+ totalPages: number;
4
+ totalRecords: number;
5
+ }
6
+ export interface DataWithPagingResult<T> {
7
+ data: T;
8
+ pagination: PagingResult;
9
+ }
10
+ export interface SortCondition {
11
+ name: string;
12
+ direction: "ASC" | "DESC";
13
+ }
14
+ export interface FilterCondition {
15
+ name: string;
16
+ condition: "=" | ">" | "<" | "!=" | "LIKE" | "IN" | ">=" | "<=";
17
+ valueString?: string;
18
+ valueNumber?: number;
19
+ valueBoolean?: boolean;
20
+ useAnd?: boolean;
21
+ }
22
+ export interface PaginationRequest {
23
+ page: number;
24
+ size: number;
25
+ sort?: SortCondition[];
26
+ filters?: FilterCondition[];
27
+ }
28
+ export declare const createPagingObject: (page: number, size: number, sort?: SortCondition[], filters?: FilterCondition[]) => {
29
+ pagination: any;
30
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./user";
2
+ export * from "./base";
@@ -0,0 +1,37 @@
1
+ import { MetaData, ObjectValues, Status } from "@/types";
2
+ export interface User extends Omit<MetaData, "created_by" | "updated_by"> {
3
+ id: string;
4
+ firstName: string;
5
+ lastName: string;
6
+ mi: string;
7
+ username: string;
8
+ email: string;
9
+ password: string;
10
+ loginAttempts: number;
11
+ locked: boolean;
12
+ passwordLastReset: Date;
13
+ passwordResetRequired: boolean;
14
+ type: AccountType;
15
+ status: Status;
16
+ companyId: number;
17
+ phoneNumber: string;
18
+ phoneFormat: string;
19
+ language: Language;
20
+ biometrics: string;
21
+ lastLogin: Date;
22
+ }
23
+ export declare const ACCOUNT_TYPE: {
24
+ readonly TURNDOWN_ADMIN: "TURNDOWN_ADMIN";
25
+ readonly OWNER: "OWNER";
26
+ readonly ACCOUNT_ADMIN: "ACCOUNT_ADMIN";
27
+ readonly MAINTAINER: "MAINTAINER";
28
+ readonly CLEANER: "CLEANER";
29
+ };
30
+ export type AccountType = ObjectValues<typeof ACCOUNT_TYPE>;
31
+ export declare const LANGUAGE: {
32
+ readonly ENGLISH: "ENGLISH";
33
+ readonly FRENCH: "FRENCH";
34
+ readonly SPANISH: "SPANISH";
35
+ readonly GERMAN: "GERMAN";
36
+ };
37
+ export type Language = ObjectValues<typeof LANGUAGE>;
@@ -0,0 +1,13 @@
1
+ export const ACCOUNT_TYPE = {
2
+ TURNDOWN_ADMIN: "TURNDOWN_ADMIN",
3
+ OWNER: "OWNER",
4
+ ACCOUNT_ADMIN: "ACCOUNT_ADMIN",
5
+ MAINTAINER: "MAINTAINER",
6
+ CLEANER: "CLEANER",
7
+ };
8
+ export const LANGUAGE = {
9
+ ENGLISH: "ENGLISH",
10
+ FRENCH: "FRENCH",
11
+ SPANISH: "SPANISH",
12
+ GERMAN: "GERMAN",
13
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turndown/library",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "description": "Shared TypeScript library for the Turndown suite.",
5
5
  "keywords": [
6
6
  "types",
@@ -16,21 +16,20 @@
16
16
  "access": "public"
17
17
  },
18
18
  "type": "module",
19
- "main": "dist/index.ts",
20
- "module": "dist/index.ts",
21
- "types": "./dist/index.d.ts",
22
- "files": [
23
- "src",
24
- "dist"
25
- ],
26
19
  "exports": {
27
20
  ".": {
28
21
  "types": "./dist/index.d.ts",
29
- "browser": "./dist/index.ts",
30
- "import": "./dist/index.ts"
22
+ "import": "./dist/index.ts",
23
+ "default": "./dist/index.ts"
31
24
  },
32
25
  "./package.json": "./package.json"
33
26
  },
27
+ "types": "./dist/index.d.ts",
28
+ "files": [
29
+ "dist",
30
+ "LICENSE",
31
+ "README.md"
32
+ ],
34
33
  "scripts": {
35
34
  "clean": "rimraf dist",
36
35
  "build": "npm run clean && tsc -p .",
@@ -1,26 +0,0 @@
1
- export type GenericTurndownObject = Record<string, any> | any | undefined;
2
- export type TurndownObject<T = GenericTurndownObject> =
3
- | Record<string, T>
4
- | T
5
- | undefined;
6
-
7
- export type ObjectValues<T> = T[keyof T];
8
- export type ObjectKeys<T> = [keyof T];
9
-
10
- export interface MetaData {
11
- company_id: string;
12
- deleted: boolean;
13
- updated_by: string;
14
- created_by: string;
15
- created_at: Date;
16
- updated_at: Date;
17
- }
18
-
19
- export const STATUS = {
20
- ACTIVE: "ACTIVE",
21
- INACTIVE: "INACTIVE",
22
- } as const;
23
-
24
- export type Status = ObjectValues<typeof STATUS>;
25
-
26
- export * from "./paging.types";
@@ -1,35 +0,0 @@
1
- export interface PagingResult {
2
- hasNextPage: boolean;
3
- totalPages: number;
4
- totalRecords: number;
5
- }
6
- export interface DataWithPagingResult<T> {
7
- data: T;
8
- pagination: PagingResult;
9
- }
10
- export interface SortCondition {
11
- name: string;
12
- direction: "ASC" | "DESC";
13
- }
14
- export interface FilterCondition {
15
- name: string;
16
- condition: "=" | ">" | "<" | "!=" | "LIKE" | "IN" | ">=" | "<=";
17
- valueString?: string;
18
- valueNumber?: number;
19
- valueBoolean?: boolean;
20
- useAnd?: boolean;
21
- }
22
- export interface PaginationRequest {
23
- page: number;
24
- size: number;
25
- sort?: SortCondition[];
26
- filters?: FilterCondition[];
27
- }
28
- export declare const createPagingObject: (
29
- page: number,
30
- size: number,
31
- sort?: SortCondition[],
32
- filters?: FilterCondition[]
33
- ) => {
34
- pagination: any;
35
- };
@@ -1,42 +0,0 @@
1
- import { MetaData, ObjectValues, Status } from "@/types";
2
-
3
- export interface User extends Omit<MetaData, "created_by" | "updated_by"> {
4
- id: string;
5
- firstName: string;
6
- lastName: string;
7
- mi: string;
8
- username: string;
9
- email: string;
10
- password: string;
11
- loginAttempts: number;
12
- locked: boolean;
13
- passwordLastReset: Date;
14
- passwordResetRequired: boolean;
15
- type: AccountType;
16
- status: Status;
17
- companyId: number;
18
- phoneNumber: string;
19
- phoneFormat: string;
20
- language: Language;
21
- biometrics: string;
22
- lastLogin: Date;
23
- }
24
-
25
- export const ACCOUNT_TYPE = {
26
- TURNDOWN_ADMIN: "TURNDOWN_ADMIN",
27
- OWNER: "OWNER",
28
- ACCOUNT_ADMIN: "ACCOUNT_ADMIN",
29
- MAINTAINER: "MAINTAINER",
30
- CLEANER: "CLEANER",
31
- } as const;
32
-
33
- export type AccountType = ObjectValues<typeof ACCOUNT_TYPE>;
34
-
35
- export const LANGUAGE = {
36
- ENGLISH: "ENGLISH",
37
- FRENCH: "FRENCH",
38
- SPANISH: "SPANISH",
39
- GERMAN: "GERMAN",
40
- } as const;
41
-
42
- export type Language = ObjectValues<typeof LANGUAGE>;
File without changes
File without changes