@or-sdk/contacts 4.5.22 → 4.6.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 (48) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/Contacts.js +2 -2
  3. package/dist/cjs/Contacts.js.map +1 -1
  4. package/dist/cjs/__tests__/contacts-error-handling.spec.js +50 -37
  5. package/dist/cjs/__tests__/contacts-error-handling.spec.js.map +1 -1
  6. package/dist/cjs/__tests__/db-mismatch-callback.spec.js +2 -2
  7. package/dist/cjs/__tests__/db-mismatch-callback.spec.js.map +1 -1
  8. package/dist/cjs/__tests__/poll-migration.spec.js +7 -16
  9. package/dist/cjs/__tests__/poll-migration.spec.js.map +1 -1
  10. package/dist/cjs/api/baseWithPolingApi.js +2 -2
  11. package/dist/cjs/api/baseWithPolingApi.js.map +1 -1
  12. package/dist/cjs/api/migrationsApi.js +4 -3
  13. package/dist/cjs/api/migrationsApi.js.map +1 -1
  14. package/dist/cjs/apiError.js +18 -6
  15. package/dist/cjs/apiError.js.map +1 -1
  16. package/dist/cjs/utils.js +4 -3
  17. package/dist/cjs/utils.js.map +1 -1
  18. package/dist/esm/Contacts.js +2 -2
  19. package/dist/esm/Contacts.js.map +1 -1
  20. package/dist/esm/__tests__/contacts-error-handling.spec.js +33 -37
  21. package/dist/esm/__tests__/contacts-error-handling.spec.js.map +1 -1
  22. package/dist/esm/__tests__/db-mismatch-callback.spec.js +3 -3
  23. package/dist/esm/__tests__/db-mismatch-callback.spec.js.map +1 -1
  24. package/dist/esm/__tests__/poll-migration.spec.js +8 -17
  25. package/dist/esm/__tests__/poll-migration.spec.js.map +1 -1
  26. package/dist/esm/api/baseWithPolingApi.js +3 -3
  27. package/dist/esm/api/baseWithPolingApi.js.map +1 -1
  28. package/dist/esm/api/migrationsApi.js +2 -2
  29. package/dist/esm/api/migrationsApi.js.map +1 -1
  30. package/dist/esm/apiError.js +7 -6
  31. package/dist/esm/apiError.js.map +1 -1
  32. package/dist/esm/utils.js +4 -3
  33. package/dist/esm/utils.js.map +1 -1
  34. package/dist/types/api/migrationsApi.d.ts +3 -1
  35. package/dist/types/api/migrationsApi.d.ts.map +1 -1
  36. package/dist/types/apiError.d.ts +6 -5
  37. package/dist/types/apiError.d.ts.map +1 -1
  38. package/dist/types/utils.d.ts.map +1 -1
  39. package/package.json +12 -14
  40. package/src/Contacts.ts +2 -2
  41. package/src/__tests__/contacts-error-handling.spec.ts +35 -39
  42. package/src/__tests__/db-mismatch-callback.spec.ts +3 -3
  43. package/src/__tests__/poll-migration.spec.ts +30 -22
  44. package/src/api/baseWithPolingApi.ts +2 -2
  45. package/src/api/migrationsApi.ts +6 -2
  46. package/src/apiError.ts +13 -6
  47. package/src/utils.ts +8 -9
  48. package/{vitest.config.js → vitest.config.mjs} +1 -1
package/src/utils.ts CHANGED
@@ -6,7 +6,7 @@ const propertyToEscape = ['from', 'size', 'orderProperty', 'orderDirection'] as
6
6
  type Omitted<T> = Omit<T, typeof propertyToEscape[number]>;
7
7
 
8
8
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- export const adaptListParams = <T extends AdaptedListParams<{[key: string|number]: any;}>>(
9
+ export const adaptListParams = <T extends AdaptedListParams<{ [key: string | number]: any; }>>(
10
10
  params: T
11
11
  ): Omitted<T> & Partial<ListApiParams & OrderParams> => {
12
12
  const toInclude = Object.keys(params).reduce<Omitted<T>>((acc, k) => {
@@ -46,12 +46,11 @@ export const chunkArrByMaxSize = <T>(arr: T[], maxSize: number): T[][] => {
46
46
  let chunkSize = 0;
47
47
  let lastTakenItem = 0;
48
48
 
49
- for (let idx = 0;idx < arr.length;idx ++) {
49
+ for (let idx = 0; idx < arr.length; idx++) {
50
50
  const itemSize = getObjectSizeInBytes(arr[idx]);
51
51
  if (itemSize > maxSize) {
52
- throw new Error(`Single array element exceeds maximum size: size of the ${
53
- idx
54
- } element is ${itemSize} while maximum size is ${maxSize}`);
52
+ throw new Error(`Single array element exceeds maximum size: size of the ${idx
53
+ } element is ${itemSize} while maximum size is ${maxSize}`);
55
54
  }
56
55
 
57
56
  if (chunkSize + itemSize < maxSize) {
@@ -79,11 +78,11 @@ export function debouncePromise<T>(
79
78
  let timeout: NodeJS.Timeout | null = null;
80
79
 
81
80
  return new Promise<T>((res, rej) => {
82
- if (timeout) {
83
- clearTimeout(timeout);
84
- }
81
+ if (timeout) clearTimeout(timeout);
85
82
  timeout = setTimeout(
86
- () => caller().then((x) => res(x)).catch((err) => rej(err)),
83
+ () => Promise.resolve(caller())
84
+ .then((x) => res(x))
85
+ .catch((err) => rej(err)),
87
86
  delay
88
87
  );
89
88
  });
@@ -2,7 +2,7 @@ import { defineConfig } from 'vitest/config';
2
2
 
3
3
  export default defineConfig({
4
4
  test: {
5
- reporters: ['junit', 'basic'],
5
+ reporters: ['junit', 'default'],
6
6
  outputFile: 'test-results/junit.xml',
7
7
  coverage: {
8
8
  all: true,