@mondaydotcomorg/monday-authorization 3.7.4 → 3.7.5
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/dist/authorization-internal-service.d.ts +9 -1
- package/dist/authorization-internal-service.d.ts.map +1 -1
- package/dist/authorization-internal-service.js +18 -6
- package/dist/esm/authorization-internal-service.d.ts +9 -1
- package/dist/esm/authorization-internal-service.d.ts.map +1 -1
- package/dist/esm/authorization-internal-service.mjs +16 -7
- package/package.json +1 -1
- package/src/authorization-internal-service.ts +23 -8
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { fetch, MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
|
|
2
|
-
import { OnRetryCallback, RetryPolicy } from '@mondaydotcomorg/monday-fetch-api';
|
|
2
|
+
import { OnRetryCallback, RetryPolicy, RetryDelayCallback } from '@mondaydotcomorg/monday-fetch-api';
|
|
3
3
|
import { IgniteClient } from '@mondaydotcomorg/ignite-sdk';
|
|
4
4
|
import { BaseRequest } from './types/general';
|
|
5
|
+
export declare const MAX_RETRIES = 3;
|
|
6
|
+
export declare const RETRY_DELAY_MS = 20;
|
|
5
7
|
export declare const logger: import("bunyan");
|
|
6
8
|
export declare const onRetryCallback: OnRetryCallback;
|
|
9
|
+
/**
|
|
10
|
+
* Exponential backoff retry delay callback
|
|
11
|
+
* Calculates delay as: baseDelay * 2^(attemptCount - 1)
|
|
12
|
+
* Example: attempt 1 -> 100ms, attempt 2 -> 200ms, attempt 3 -> 400ms
|
|
13
|
+
*/
|
|
14
|
+
export declare const calcDelayDurationInMs: RetryDelayCallback;
|
|
7
15
|
export declare class AuthorizationInternalService {
|
|
8
16
|
static igniteClient?: IgniteClient;
|
|
9
17
|
static skipAuthorization(requset: BaseRequest): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-internal-service.d.ts","sourceRoot":"","sources":["../src/authorization-internal-service.ts"],"names":[],"mappings":"AACA,OAAO,E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,MAAM,CAAC,sBAAsB,IAAI,kBAAkB;IAInD,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,YAAY;IAI3C,MAAM,CAAC,iBAAiB;IA2BxB,MAAM,CAAC,gBAAgB,IAAI,WAAW;CAUvC"}
|
|
@@ -25,7 +25,7 @@ const MondayLogger__namespace = /*#__PURE__*/_interopNamespace(MondayLogger);
|
|
|
25
25
|
|
|
26
26
|
const INTERNAL_APP_NAME = 'internal_ms';
|
|
27
27
|
const MAX_RETRIES = 3;
|
|
28
|
-
const RETRY_DELAY_MS =
|
|
28
|
+
const RETRY_DELAY_MS = 20;
|
|
29
29
|
const logger = MondayLogger__namespace.getLogger();
|
|
30
30
|
const defaultMondayFetchOptions = {
|
|
31
31
|
retries: MAX_RETRIES,
|
|
@@ -39,12 +39,20 @@ const onRetryCallback = (attempt, error) => {
|
|
|
39
39
|
logger.info({ tag: 'authorization-service', attempt, error }, 'Authorization attempt failed, trying again');
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Exponential backoff retry delay callback
|
|
44
|
+
* Calculates delay as: baseDelay * 2^(attemptCount - 1)
|
|
45
|
+
* Example: attempt 1 -> 100ms, attempt 2 -> 200ms, attempt 3 -> 400ms
|
|
46
|
+
*/
|
|
47
|
+
const calcDelayDurationInMs = ({ attemptCount }) => {
|
|
48
|
+
return RETRY_DELAY_MS * Math.pow(2, attemptCount - 1);
|
|
49
|
+
};
|
|
42
50
|
function logOnFetchFail(retriesLeft, error) {
|
|
43
51
|
if (retriesLeft == 0) {
|
|
44
|
-
logger.error({ retriesLeft, error },
|
|
52
|
+
logger.error({ retriesLeft, error }, `Authorization attempt failed due to ${error.message}`);
|
|
45
53
|
}
|
|
46
54
|
else {
|
|
47
|
-
logger.info({ retriesLeft, error },
|
|
55
|
+
logger.info({ retriesLeft, error }, `Authorization attempt failed due to ${error.message}, trying again`);
|
|
48
56
|
}
|
|
49
57
|
}
|
|
50
58
|
let mondayFetchOptions = defaultMondayFetchOptions;
|
|
@@ -110,15 +118,19 @@ class AuthorizationInternalService {
|
|
|
110
118
|
}
|
|
111
119
|
static getRetriesPolicy() {
|
|
112
120
|
const fetchOptions = AuthorizationInternalService.getRequestFetchOptions();
|
|
121
|
+
const retryDelayMS = calcDelayDurationInMs;
|
|
113
122
|
return {
|
|
114
|
-
useRetries: fetchOptions.retries
|
|
115
|
-
maxRetries: fetchOptions.retries
|
|
123
|
+
useRetries: !!fetchOptions.retries,
|
|
124
|
+
maxRetries: fetchOptions.retries ?? 0,
|
|
116
125
|
onRetry: onRetryCallback,
|
|
117
|
-
retryDelayMS
|
|
126
|
+
retryDelayMS,
|
|
118
127
|
};
|
|
119
128
|
}
|
|
120
129
|
}
|
|
121
130
|
|
|
122
131
|
exports.AuthorizationInternalService = AuthorizationInternalService;
|
|
132
|
+
exports.MAX_RETRIES = MAX_RETRIES;
|
|
133
|
+
exports.RETRY_DELAY_MS = RETRY_DELAY_MS;
|
|
134
|
+
exports.calcDelayDurationInMs = calcDelayDurationInMs;
|
|
123
135
|
exports.logger = logger;
|
|
124
136
|
exports.onRetryCallback = onRetryCallback;
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { fetch, MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
|
|
2
|
-
import { OnRetryCallback, RetryPolicy } from '@mondaydotcomorg/monday-fetch-api';
|
|
2
|
+
import { OnRetryCallback, RetryPolicy, RetryDelayCallback } from '@mondaydotcomorg/monday-fetch-api';
|
|
3
3
|
import { IgniteClient } from '@mondaydotcomorg/ignite-sdk';
|
|
4
4
|
import { BaseRequest } from './types/general';
|
|
5
|
+
export declare const MAX_RETRIES = 3;
|
|
6
|
+
export declare const RETRY_DELAY_MS = 20;
|
|
5
7
|
export declare const logger: import("bunyan");
|
|
6
8
|
export declare const onRetryCallback: OnRetryCallback;
|
|
9
|
+
/**
|
|
10
|
+
* Exponential backoff retry delay callback
|
|
11
|
+
* Calculates delay as: baseDelay * 2^(attemptCount - 1)
|
|
12
|
+
* Example: attempt 1 -> 100ms, attempt 2 -> 200ms, attempt 3 -> 400ms
|
|
13
|
+
*/
|
|
14
|
+
export declare const calcDelayDurationInMs: RetryDelayCallback;
|
|
7
15
|
export declare class AuthorizationInternalService {
|
|
8
16
|
static igniteClient?: IgniteClient;
|
|
9
17
|
static skipAuthorization(requset: BaseRequest): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-internal-service.d.ts","sourceRoot":"","sources":["../../src/authorization-internal-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,OAAO,
|
|
1
|
+
{"version":3,"file":"authorization-internal-service.d.ts","sourceRoot":"","sources":["../../src/authorization-internal-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,OAAO,EAEL,eAAe,EACf,WAAW,EACX,kBAAkB,EACnB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,MAAM,kBAA2B,CAAC;AAO/C,eAAO,MAAM,eAAe,EAAE,eAM7B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,kBAEnC,CAAC;AAYF,qBAAa,4BAA4B;IACvC,MAAM,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IACnC,MAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAIpD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAIjD,MAAM,CAAC,+BAA+B,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAMlE,MAAM,CAAC,wBAAwB,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAcrG,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK;IAQjE,MAAM,CAAC,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAIlE,MAAM,CAAC,sBAAsB,CAAC,wBAAwB,EAAE,kBAAkB;IAO1E,MAAM,CAAC,sBAAsB,IAAI,kBAAkB;IAInD,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,YAAY;IAI3C,MAAM,CAAC,iBAAiB;IA2BxB,MAAM,CAAC,gBAAgB,IAAI,WAAW;CAUvC"}
|
|
@@ -3,7 +3,7 @@ import * as MondayLogger from '@mondaydotcomorg/monday-logger';
|
|
|
3
3
|
|
|
4
4
|
const INTERNAL_APP_NAME = 'internal_ms';
|
|
5
5
|
const MAX_RETRIES = 3;
|
|
6
|
-
const RETRY_DELAY_MS =
|
|
6
|
+
const RETRY_DELAY_MS = 20;
|
|
7
7
|
const logger = MondayLogger.getLogger();
|
|
8
8
|
const defaultMondayFetchOptions = {
|
|
9
9
|
retries: MAX_RETRIES,
|
|
@@ -17,12 +17,20 @@ const onRetryCallback = (attempt, error) => {
|
|
|
17
17
|
logger.info({ tag: 'authorization-service', attempt, error }, 'Authorization attempt failed, trying again');
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Exponential backoff retry delay callback
|
|
22
|
+
* Calculates delay as: baseDelay * 2^(attemptCount - 1)
|
|
23
|
+
* Example: attempt 1 -> 100ms, attempt 2 -> 200ms, attempt 3 -> 400ms
|
|
24
|
+
*/
|
|
25
|
+
const calcDelayDurationInMs = ({ attemptCount }) => {
|
|
26
|
+
return RETRY_DELAY_MS * Math.pow(2, attemptCount - 1);
|
|
27
|
+
};
|
|
20
28
|
function logOnFetchFail(retriesLeft, error) {
|
|
21
29
|
if (retriesLeft == 0) {
|
|
22
|
-
logger.error({ retriesLeft, error },
|
|
30
|
+
logger.error({ retriesLeft, error }, `Authorization attempt failed due to ${error.message}`);
|
|
23
31
|
}
|
|
24
32
|
else {
|
|
25
|
-
logger.info({ retriesLeft, error },
|
|
33
|
+
logger.info({ retriesLeft, error }, `Authorization attempt failed due to ${error.message}, trying again`);
|
|
26
34
|
}
|
|
27
35
|
}
|
|
28
36
|
let mondayFetchOptions = defaultMondayFetchOptions;
|
|
@@ -88,13 +96,14 @@ class AuthorizationInternalService {
|
|
|
88
96
|
}
|
|
89
97
|
static getRetriesPolicy() {
|
|
90
98
|
const fetchOptions = AuthorizationInternalService.getRequestFetchOptions();
|
|
99
|
+
const retryDelayMS = calcDelayDurationInMs;
|
|
91
100
|
return {
|
|
92
|
-
useRetries: fetchOptions.retries
|
|
93
|
-
maxRetries: fetchOptions.retries
|
|
101
|
+
useRetries: !!fetchOptions.retries,
|
|
102
|
+
maxRetries: fetchOptions.retries ?? 0,
|
|
94
103
|
onRetry: onRetryCallback,
|
|
95
|
-
retryDelayMS
|
|
104
|
+
retryDelayMS,
|
|
96
105
|
};
|
|
97
106
|
}
|
|
98
107
|
}
|
|
99
108
|
|
|
100
|
-
export { AuthorizationInternalService, logger, onRetryCallback };
|
|
109
|
+
export { AuthorizationInternalService, MAX_RETRIES, RETRY_DELAY_MS, calcDelayDurationInMs, logger, onRetryCallback };
|
package/package.json
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { signAuthorizationHeader } from '@mondaydotcomorg/monday-jwt';
|
|
2
2
|
import { fetch, MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
|
|
3
3
|
import * as MondayLogger from '@mondaydotcomorg/monday-logger';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
NullableErrorWithType,
|
|
6
|
+
OnRetryCallback,
|
|
7
|
+
RetryPolicy,
|
|
8
|
+
RetryDelayCallback,
|
|
9
|
+
} from '@mondaydotcomorg/monday-fetch-api';
|
|
5
10
|
import { IgniteClient } from '@mondaydotcomorg/ignite-sdk';
|
|
6
11
|
import { BaseRequest } from './types/general';
|
|
7
12
|
|
|
8
13
|
const INTERNAL_APP_NAME = 'internal_ms';
|
|
9
|
-
const MAX_RETRIES = 3;
|
|
10
|
-
const RETRY_DELAY_MS =
|
|
14
|
+
export const MAX_RETRIES = 3;
|
|
15
|
+
export const RETRY_DELAY_MS = 20;
|
|
11
16
|
export const logger = MondayLogger.getLogger();
|
|
12
17
|
|
|
13
18
|
const defaultMondayFetchOptions: MondayFetchOptions = {
|
|
@@ -23,11 +28,20 @@ export const onRetryCallback: OnRetryCallback = (attempt: number, error?: Nullab
|
|
|
23
28
|
}
|
|
24
29
|
};
|
|
25
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Exponential backoff retry delay callback
|
|
33
|
+
* Calculates delay as: baseDelay * 2^(attemptCount - 1)
|
|
34
|
+
* Example: attempt 1 -> 100ms, attempt 2 -> 200ms, attempt 3 -> 400ms
|
|
35
|
+
*/
|
|
36
|
+
export const calcDelayDurationInMs: RetryDelayCallback = ({ attemptCount }) => {
|
|
37
|
+
return RETRY_DELAY_MS * Math.pow(2, attemptCount - 1);
|
|
38
|
+
};
|
|
39
|
+
|
|
26
40
|
function logOnFetchFail(retriesLeft: number, error: Error) {
|
|
27
41
|
if (retriesLeft == 0) {
|
|
28
|
-
logger.error({ retriesLeft, error },
|
|
42
|
+
logger.error({ retriesLeft, error }, `Authorization attempt failed due to ${error.message}`);
|
|
29
43
|
} else {
|
|
30
|
-
logger.info({ retriesLeft, error },
|
|
44
|
+
logger.info({ retriesLeft, error }, `Authorization attempt failed due to ${error.message}, trying again`);
|
|
31
45
|
}
|
|
32
46
|
}
|
|
33
47
|
|
|
@@ -119,11 +133,12 @@ export class AuthorizationInternalService {
|
|
|
119
133
|
|
|
120
134
|
static getRetriesPolicy(): RetryPolicy {
|
|
121
135
|
const fetchOptions = AuthorizationInternalService.getRequestFetchOptions();
|
|
136
|
+
const retryDelayMS = calcDelayDurationInMs;
|
|
122
137
|
return {
|
|
123
|
-
useRetries: fetchOptions.retries
|
|
124
|
-
maxRetries: fetchOptions.retries
|
|
138
|
+
useRetries: !!fetchOptions.retries,
|
|
139
|
+
maxRetries: fetchOptions.retries ?? 0,
|
|
125
140
|
onRetry: onRetryCallback,
|
|
126
|
-
retryDelayMS
|
|
141
|
+
retryDelayMS,
|
|
127
142
|
};
|
|
128
143
|
}
|
|
129
144
|
}
|