@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.
- package/CHANGELOG.md +9 -0
- package/dist/cjs/Contacts.js +2 -2
- package/dist/cjs/Contacts.js.map +1 -1
- package/dist/cjs/__tests__/contacts-error-handling.spec.js +50 -37
- package/dist/cjs/__tests__/contacts-error-handling.spec.js.map +1 -1
- package/dist/cjs/__tests__/db-mismatch-callback.spec.js +2 -2
- package/dist/cjs/__tests__/db-mismatch-callback.spec.js.map +1 -1
- package/dist/cjs/__tests__/poll-migration.spec.js +7 -16
- package/dist/cjs/__tests__/poll-migration.spec.js.map +1 -1
- package/dist/cjs/api/baseWithPolingApi.js +2 -2
- package/dist/cjs/api/baseWithPolingApi.js.map +1 -1
- package/dist/cjs/api/migrationsApi.js +4 -3
- package/dist/cjs/api/migrationsApi.js.map +1 -1
- package/dist/cjs/apiError.js +18 -6
- package/dist/cjs/apiError.js.map +1 -1
- package/dist/cjs/utils.js +4 -3
- package/dist/cjs/utils.js.map +1 -1
- package/dist/esm/Contacts.js +2 -2
- package/dist/esm/Contacts.js.map +1 -1
- package/dist/esm/__tests__/contacts-error-handling.spec.js +33 -37
- package/dist/esm/__tests__/contacts-error-handling.spec.js.map +1 -1
- package/dist/esm/__tests__/db-mismatch-callback.spec.js +3 -3
- package/dist/esm/__tests__/db-mismatch-callback.spec.js.map +1 -1
- package/dist/esm/__tests__/poll-migration.spec.js +8 -17
- package/dist/esm/__tests__/poll-migration.spec.js.map +1 -1
- package/dist/esm/api/baseWithPolingApi.js +3 -3
- package/dist/esm/api/baseWithPolingApi.js.map +1 -1
- package/dist/esm/api/migrationsApi.js +2 -2
- package/dist/esm/api/migrationsApi.js.map +1 -1
- package/dist/esm/apiError.js +7 -6
- package/dist/esm/apiError.js.map +1 -1
- package/dist/esm/utils.js +4 -3
- package/dist/esm/utils.js.map +1 -1
- package/dist/types/api/migrationsApi.d.ts +3 -1
- package/dist/types/api/migrationsApi.d.ts.map +1 -1
- package/dist/types/apiError.d.ts +6 -5
- package/dist/types/apiError.d.ts.map +1 -1
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +12 -14
- package/src/Contacts.ts +2 -2
- package/src/__tests__/contacts-error-handling.spec.ts +35 -39
- package/src/__tests__/db-mismatch-callback.spec.ts +3 -3
- package/src/__tests__/poll-migration.spec.ts +30 -22
- package/src/api/baseWithPolingApi.ts +2 -2
- package/src/api/migrationsApi.ts +6 -2
- package/src/apiError.ts +13 -6
- package/src/utils.ts +8 -9
- 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
|
-
|
|
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
|
-
() =>
|
|
83
|
+
() => Promise.resolve(caller())
|
|
84
|
+
.then((x) => res(x))
|
|
85
|
+
.catch((err) => rej(err)),
|
|
87
86
|
delay
|
|
88
87
|
);
|
|
89
88
|
});
|