@onivoro/isomorphic-common 24.9.0 → 24.11.0

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 (98) hide show
  1. package/package.json +8 -2
  2. package/jest.config.ts +0 -11
  3. package/project.json +0 -32
  4. package/src/index.ts +0 -80
  5. package/src/lib/constants/api-id-header.constant.ts +0 -1
  6. package/src/lib/constants/api-key-header.constant.ts +0 -1
  7. package/src/lib/constants/auth-cookie-name.constant.ts +0 -2
  8. package/src/lib/constants/millis-per-day.constant.ts +0 -3
  9. package/src/lib/constants/millis-per-hour.constant.ts +0 -3
  10. package/src/lib/constants/millis-per-minute.constant.ts +0 -1
  11. package/src/lib/constants/regexes.constant.ts +0 -30
  12. package/src/lib/functions/__snapshots__/chunk.function.spec.ts.snap +0 -94
  13. package/src/lib/functions/__snapshots__/split-date-range-into-days.function.spec.ts.snap +0 -50
  14. package/src/lib/functions/add-offset.function.spec.ts +0 -12
  15. package/src/lib/functions/add-offset.function.ts +0 -14
  16. package/src/lib/functions/arrange-act-assert.function.ts +0 -23
  17. package/src/lib/functions/camel-case.function.ts +0 -30
  18. package/src/lib/functions/chunk.function.spec.ts +0 -20
  19. package/src/lib/functions/chunk.function.ts +0 -25
  20. package/src/lib/functions/convert-object-to-literal.function.spec.ts +0 -16
  21. package/src/lib/functions/convert-object-to-literal.function.ts +0 -10
  22. package/src/lib/functions/format-usd.function.ts +0 -4
  23. package/src/lib/functions/from-boolean-string.function.ts +0 -3
  24. package/src/lib/functions/from-calendar-date.function.spec.ts +0 -11
  25. package/src/lib/functions/from-calendar-date.function.ts +0 -5
  26. package/src/lib/functions/from-csv-string.function.ts +0 -3
  27. package/src/lib/functions/get-date-last-month.function.ts +0 -6
  28. package/src/lib/functions/get-date-range-for-month.function copy.ts +0 -8
  29. package/src/lib/functions/get-date-range-for-month.function.ts +0 -8
  30. package/src/lib/functions/get-tag.function.ts +0 -10
  31. package/src/lib/functions/get-user-full-name.function.ts +0 -5
  32. package/src/lib/functions/is-symbol.function.ts +0 -11
  33. package/src/lib/functions/is-valid-date.function.ts +0 -5
  34. package/src/lib/functions/kebab-case.function.ts +0 -5
  35. package/src/lib/functions/map-entities-to-options.function.ts +0 -11
  36. package/src/lib/functions/map-enum-to-array-of-values.function copy.ts +0 -3
  37. package/src/lib/functions/map-enum-to-array-of-values.function.ts +0 -3
  38. package/src/lib/functions/map-enum-to-lookup-array.function.ts +0 -6
  39. package/src/lib/functions/map-enum-to-options.function copy.ts +0 -7
  40. package/src/lib/functions/map-enum-to-options.function.ts +0 -7
  41. package/src/lib/functions/mock-calls.function.ts +0 -4
  42. package/src/lib/functions/money.function.spec.ts +0 -10
  43. package/src/lib/functions/money.function.ts +0 -22
  44. package/src/lib/functions/parse-bool.function.ts +0 -3
  45. package/src/lib/functions/properties-to-array.function.ts +0 -21
  46. package/src/lib/functions/remove-alpha-chars.function.spec.ts +0 -11
  47. package/src/lib/functions/remove-alpha-chars.function.ts +0 -9
  48. package/src/lib/functions/remove-element-at-index.function copy.ts +0 -9
  49. package/src/lib/functions/remove-element-at-index.function.ts +0 -9
  50. package/src/lib/functions/round.function copy.ts +0 -4
  51. package/src/lib/functions/round.function.ts +0 -4
  52. package/src/lib/functions/sanitize-filename.function.ts +0 -9
  53. package/src/lib/functions/sleep.function.ts +0 -3
  54. package/src/lib/functions/snake-case.function.ts +0 -34
  55. package/src/lib/functions/sort-by-created-at.function.ts +0 -7
  56. package/src/lib/functions/sort-by-full-name.function.ts +0 -6
  57. package/src/lib/functions/sort-by-id.function.ts +0 -3
  58. package/src/lib/functions/sort-by-name.function.ts +0 -3
  59. package/src/lib/functions/sort-numbers.function.ts +0 -3
  60. package/src/lib/functions/split-date-range-into-days.function.spec.ts +0 -17
  61. package/src/lib/functions/split-date-range-into-days.function.ts +0 -26
  62. package/src/lib/functions/subtract-offset.function.spec.ts +0 -12
  63. package/src/lib/functions/subtract-offset.function.ts +0 -14
  64. package/src/lib/functions/to-boolean-string.function.ts +0 -3
  65. package/src/lib/functions/to-calendar-date.function.ts +0 -11
  66. package/src/lib/functions/to-csv-string.function.ts +0 -3
  67. package/src/lib/functions/to-decimal-base.function.ts +0 -23
  68. package/src/lib/functions/to-dollars-and-cents.function.spec.ts +0 -7
  69. package/src/lib/functions/to-dollars-and-cents.function.ts +0 -17
  70. package/src/lib/functions/to-string.function.ts +0 -25
  71. package/src/lib/functions/to-unique-array.function.spec.ts +0 -45
  72. package/src/lib/functions/to-unique-array.function.ts +0 -3
  73. package/src/lib/functions/to-words.function.spec.ts +0 -7
  74. package/src/lib/functions/to-words.function.ts +0 -108
  75. package/src/lib/functions/try-json-parse.spec.ts +0 -37
  76. package/src/lib/functions/try-json-parse.ts +0 -11
  77. package/src/lib/functions/try-json-stringify.spec.ts +0 -44
  78. package/src/lib/functions/try-json-stringify.ts +0 -11
  79. package/src/lib/functions/try-parse-date.function.spec.ts +0 -12
  80. package/src/lib/functions/try-parse-date.function.ts +0 -17
  81. package/src/lib/functions/unicode-words.const.ts +0 -70
  82. package/src/lib/functions/upper-first.function.spec.ts +0 -16
  83. package/src/lib/functions/upper-first.function.ts +0 -10
  84. package/src/lib/functions/use-date.function.ts +0 -21
  85. package/src/lib/functions/words.function.ts +0 -38
  86. package/src/lib/types/access-token.interface.ts +0 -8
  87. package/src/lib/types/axios-wrapped-nest-exception.interface.ts +0 -5
  88. package/src/lib/types/company.type.ts +0 -18
  89. package/src/lib/types/createable.type.ts +0 -1
  90. package/src/lib/types/entity-provider.interface.ts +0 -9
  91. package/src/lib/types/keys-of.type copy.ts +0 -1
  92. package/src/lib/types/keys-of.type.ts +0 -1
  93. package/src/lib/types/lookup.interface copy.ts +0 -4
  94. package/src/lib/types/lookup.interface.ts +0 -4
  95. package/src/lib/types/nameable.type.ts +0 -4
  96. package/tsconfig.json +0 -13
  97. package/tsconfig.lib.json +0 -10
  98. package/tsconfig.spec.json +0 -14
@@ -1,44 +0,0 @@
1
- import { tryJsonStringify } from './try-json-stringify';
2
-
3
- const arbitraryNumber: number = 337;
4
-
5
- describe('tryJsonStringify', () => {
6
- describe('GIVEN input is stringifiable', () => {
7
- describe.each([
8
- [0, '0'],
9
- ['0', '"0"'],
10
- [arbitraryNumber, expect.stringMatching(/\d/)],
11
- [arbitraryNumber.toString(), expect.stringMatching(/\d/)],
12
- [false, 'false'],
13
- ['false', '"false"'],
14
- [true, 'true'],
15
- ['true', '"true"'],
16
- ['', '""'],
17
- [{ test: arbitraryNumber }, expect.stringMatching(new RegExp(`"test".*${arbitraryNumber}`))],
18
- [{ test: arbitraryNumber.toString() }, expect.stringMatching(new RegExp(`"test".*"${arbitraryNumber}"`))],
19
- ['randommmm', expect.any(String)],
20
- ['so random', expect.any(String)],
21
- ])('WHEN input is: %j', (input, expectedOutput) => {
22
- it(`returns ${expectedOutput}`, () => {
23
- expect(tryJsonStringify(input as any)).toEqual(expectedOutput);
24
- });
25
- });
26
- });
27
-
28
- describe('GIVEN input is not stringifiable', () => {
29
- let circularObject: any;
30
-
31
- beforeEach(() => {
32
- circularObject = { children: [] };
33
- const circularObjectChild = { parent: circularObject };
34
- circularObject.children.push(circularObjectChild);
35
- });
36
-
37
- describe('WHEN input is circular', () => {
38
- it(`returns null`, () => {
39
- expect(tryJsonStringify(circularObject)).toMatchSnapshot();
40
- // expect(tryJsonStringify(circularObject)).toEqual(null);
41
- });
42
- });
43
- });
44
- });
@@ -1,11 +0,0 @@
1
- export function tryJsonStringify<T>(object: T | null | undefined, fmtr?: any, spaces?: number): string | null {
2
- if (typeof object === 'undefined') {
3
- return null;
4
- }
5
-
6
- try {
7
- return JSON.stringify(object, fmtr, spaces);
8
- } catch (_e) {
9
- return null;
10
- }
11
- }
@@ -1,12 +0,0 @@
1
- import { tryParseDate } from './try-parse-date.function';
2
-
3
- describe('tryParseDate', () => {
4
- describe('GIVEN input is partial or full ISO8601', () => {
5
- it.each([
6
- '2023-12-23',
7
- '2023-12-23T00:00:00.000',
8
- ])('%j', (input) => {
9
- expect(tryParseDate(input)).toMatchSnapshot();
10
- });
11
- });
12
- });
@@ -1,17 +0,0 @@
1
- export function tryParseDate(input: string | Date | undefined | null): Date | undefined {
2
- if (!input) {
3
- return;
4
- }
5
-
6
- if(input instanceof Date) {
7
- return input;
8
- }
9
-
10
- const date = new Date(input);
11
-
12
- if ((date as any) == 'Invalid Date') {
13
- return;
14
- }
15
-
16
- return date;
17
- }
@@ -1,70 +0,0 @@
1
- // source https://github.com/lodash/lodash/blob/master/.internal/unicodeWords.js
2
-
3
- /** Used to compose unicode character classes. */
4
- const rsAstralRange = '\\ud800-\\udfff'
5
- const rsComboMarksRange = '\\u0300-\\u036f'
6
- const reComboHalfMarksRange = '\\ufe20-\\ufe2f'
7
- const rsComboSymbolsRange = '\\u20d0-\\u20ff'
8
- const rsComboMarksExtendedRange = '\\u1ab0-\\u1aff'
9
- const rsComboMarksSupplementRange = '\\u1dc0-\\u1dff'
10
- const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange + rsComboMarksExtendedRange + rsComboMarksSupplementRange
11
- const rsDingbatRange = '\\u2700-\\u27bf'
12
- const rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff'
13
- const rsMathOpRange = '\\xac\\xb1\\xd7\\xf7'
14
- const rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf'
15
- const rsPunctuationRange = '\\u2000-\\u206f'
16
- const rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000'
17
- const rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde'
18
- const rsVarRange = '\\ufe0e\\ufe0f'
19
- const rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange
20
-
21
- /** Used to compose unicode capture groups. */
22
- const rsApos = "['\u2019]"
23
- const rsBreak = `[${rsBreakRange}]`
24
- const rsCombo = `[${rsComboRange}]`
25
- const rsDigit = '\\d'
26
- const rsDingbat = `[${rsDingbatRange}]`
27
- const rsLower = `[${rsLowerRange}]`
28
- const rsMisc = `[^${rsAstralRange}${rsBreakRange + rsDigit + rsDingbatRange + rsLowerRange + rsUpperRange}]`
29
- const rsFitz = '\\ud83c[\\udffb-\\udfff]'
30
- const rsModifier = `(?:${rsCombo}|${rsFitz})`
31
- const rsNonAstral = `[^${rsAstralRange}]`
32
- const rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}'
33
- const rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]'
34
- const rsUpper = `[${rsUpperRange}]`
35
- const rsZWJ = '\\u200d'
36
-
37
- /** Used to compose unicode regexes. */
38
- const rsMiscLower = `(?:${rsLower}|${rsMisc})`
39
- const rsMiscUpper = `(?:${rsUpper}|${rsMisc})`
40
- const rsOptContrLower = `(?:${rsApos}(?:d|ll|m|re|s|t|ve))?`
41
- const rsOptContrUpper = `(?:${rsApos}(?:D|LL|M|RE|S|T|VE))?`
42
- const reOptMod = `${rsModifier}?`
43
- const rsOptVar = `[${rsVarRange}]?`
44
- const rsOptJoin = `(?:${rsZWJ}(?:${[rsNonAstral, rsRegional, rsSurrPair].join('|')})${rsOptVar + reOptMod})*`
45
- const rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])'
46
- const rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])'
47
- const rsSeq = rsOptVar + reOptMod + rsOptJoin
48
- const rsEmoji = `(?:${[rsDingbat, rsRegional, rsSurrPair].join('|')})${rsSeq}`
49
-
50
- const reUnicodeWords = RegExp([
51
- `${rsUpper}?${rsLower}+${rsOptContrLower}(?=${[rsBreak, rsUpper, '$'].join('|')})`,
52
- `${rsMiscUpper}+${rsOptContrUpper}(?=${[rsBreak, rsUpper + rsMiscLower, '$'].join('|')})`,
53
- `${rsUpper}?${rsMiscLower}+${rsOptContrLower}`,
54
- `${rsUpper}+${rsOptContrUpper}`,
55
- rsOrdUpper,
56
- rsOrdLower,
57
- `${rsDigit}+`,
58
- rsEmoji
59
- ].join('|'), 'g')
60
-
61
- /**
62
- * Splits a Unicode `string` into an array of its words.
63
- *
64
- * @private
65
- * @param {string} The string to inspect.
66
- * @returns {Array} Returns the words of `string`.
67
- */
68
- export function unicodeWords(string: string) {
69
- return string.match(reUnicodeWords)
70
- }
@@ -1,16 +0,0 @@
1
- import { upperFirst } from './upper-first.function';
2
-
3
- describe('upperFirst', () => {
4
- it.each([
5
- 'asdf',
6
- 'XCVB'
7
- ])('GIVEN %j, does what u expect', (input) => {
8
- expect(upperFirst(input)).toMatchSnapshot();
9
- });
10
-
11
- it.each([
12
- null, undefined, 0, false
13
- ])('GIVEN falsey input %j, does what u expect', (input) => {
14
- expect(upperFirst(input)).toMatchSnapshot();
15
- });
16
- });
@@ -1,10 +0,0 @@
1
- export function upperFirst(string: string) {
2
- if (!string) {
3
- return string;
4
- }
5
-
6
- return string
7
- .split('')
8
- .map((curr: string, i: number) => curr[!i ? 'toUpperCase' : 'toLowerCase']())
9
- .join('');
10
- }
@@ -1,21 +0,0 @@
1
- /* eslint no-global-assign:0 */
2
- export async function useDate(date: string, fn: () => Promise<void>) {
3
- const mockedDate = new Date(date);
4
-
5
- const OriginalDate = Date;
6
-
7
- Date = class extends OriginalDate {
8
- constructor(...args: any[]) {
9
- super(
10
- (args.length === 0) ? mockedDate : new (OriginalDate as any)(...args)
11
- );
12
- }
13
- static override now() {
14
- return mockedDate.getTime();
15
- }
16
- } as any;
17
-
18
- await fn();
19
-
20
- Date = OriginalDate;
21
- }
@@ -1,38 +0,0 @@
1
- // source https://github.com/lodash/lodash/blob/master/words.js
2
-
3
- import { unicodeWords } from './unicode-words.const';
4
-
5
- const hasUnicodeWord = RegExp.prototype.test.bind(
6
- /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/
7
- )
8
-
9
- /** Used to match words composed of alphanumeric characters. */
10
- const reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g
11
-
12
- function asciiWords(string: string) {
13
- return string.match(reAsciiWord)
14
- }
15
-
16
- /**
17
- * Splits `string` into an array of its words.
18
- *
19
- * @since 3.0.0
20
- * @category String
21
- * @param {string} [string=''] The string to inspect.
22
- * @param {RegExp|string} [pattern] The pattern to match words.
23
- * @returns {Array} Returns the words of `string`.
24
- * @example
25
- *
26
- * words('fred, barney, & pebbles')
27
- * // => ['fred', 'barney', 'pebbles']
28
- *
29
- * words('fred, barney, & pebbles', /[^, ]+/g)
30
- * // => ['fred', 'barney', '&', 'pebbles']
31
- */
32
- export function words(string: string, pattern?: RegExp) {
33
- if (pattern === undefined) {
34
- const result = hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string)
35
- return result || []
36
- }
37
- return string.match(pattern) || []
38
- }
@@ -1,8 +0,0 @@
1
- export type IAccessToken = {
2
- id: string,
3
- brokerId?: string,
4
- companyId?: string,
5
- roleId: string,
6
- type: 'user' | 'machine',
7
- exp?: number
8
- };
@@ -1,5 +0,0 @@
1
- export interface IAxiosWrappedNestException {
2
- statusCode: number;
3
- error: string;
4
- message: string
5
- }
@@ -1,18 +0,0 @@
1
- export type TCompany = {
2
- id: string;
3
- statusId: string;
4
- renewalDate: string;
5
- name: string;
6
- ein: string;
7
- duns: string;
8
- address1: string;
9
- address2: string;
10
- city: string;
11
- state: string;
12
- zip: string;
13
- phone: string;
14
- externalId: string;
15
- bmiThresholdWithComorbidities: number;
16
- bmiThresholdWithoutComorbidities: number;
17
- membershipType: string;
18
- };
@@ -1 +0,0 @@
1
- export type TCreateable = { createdAt: Date | string };
@@ -1,9 +0,0 @@
1
- export interface IEntityProvider<TEntity, TFindOneOptions, TFindManyOptions, TFindOptionsWhere, TQueryDeepPartialEntity> {
2
- getOne: (options: TFindOneOptions) => Promise<TEntity>;
3
- getMany: (options: TFindManyOptions) => Promise<TEntity[]>;
4
- postOne: (body: Partial<TEntity>) => Promise<TEntity>;
5
- postMany: (body: Partial<TEntity[]>) => Promise<TEntity[]>;
6
- delete: (options: TFindOptionsWhere) => Promise<void>;
7
- put: (options: TFindOptionsWhere, body: TQueryDeepPartialEntity) => Promise<void>;
8
- patch: (options: TFindOptionsWhere, body: TQueryDeepPartialEntity) => Promise<void>;
9
- }
@@ -1 +0,0 @@
1
- export type TKeysOf<TKeySource, TValue> = { [key in keyof TKeySource]: TValue };
@@ -1 +0,0 @@
1
- export type TKeysOf<TKeySource, TValue> = { [key in keyof TKeySource]: TValue };
@@ -1,4 +0,0 @@
1
- export interface ILookup<TDisplay, TValue> {
2
- display: TDisplay;
3
- value: TValue;
4
- }
@@ -1,4 +0,0 @@
1
- export interface ILookup<TDisplay, TValue> {
2
- display: TDisplay;
3
- value: TValue;
4
- }
@@ -1,4 +0,0 @@
1
- export type TNameable = {
2
- firstName: string;
3
- lastName: string;
4
- };
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.isomorphic.json",
3
- "files": [],
4
- "include": [],
5
- "references": [
6
- {
7
- "path": "./tsconfig.lib.json"
8
- },
9
- {
10
- "path": "./tsconfig.spec.json"
11
- }
12
- ]
13
- }
package/tsconfig.lib.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "rootDir": "./src",
5
- "outDir": "../../dist/libs/isomorphic/common",
6
- "declaration": true
7
- },
8
- "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
9
- "include": ["src/**/*.ts"]
10
- }
@@ -1,14 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../../dist/out-tsc",
5
- "module": "commonjs",
6
- "types": ["jest", "node"]
7
- },
8
- "include": [
9
- "jest.config.ts",
10
- "src/**/*.test.ts",
11
- "src/**/*.spec.ts",
12
- "src/**/*.d.ts"
13
- ]
14
- }