@mondaydotcomorg/monday-authorization 3.8.0 → 3.9.4
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 +1 -9
- package/dist/authorization-internal-service.d.ts.map +1 -1
- package/dist/authorization-internal-service.js +6 -18
- package/dist/esm/authorization-internal-service.d.ts +1 -9
- package/dist/esm/authorization-internal-service.d.ts.map +1 -1
- package/dist/esm/authorization-internal-service.mjs +7 -16
- package/dist/esm/types/fetch-options.d.ts +13 -0
- package/dist/esm/types/fetch-options.d.ts.map +1 -0
- package/dist/esm/types/fetch-options.mjs +1 -0
- package/dist/esm/types/scoped-actions-contracts.d.ts +1 -4
- package/dist/esm/types/scoped-actions-contracts.d.ts.map +1 -1
- package/dist/esm/utils/authorization.utils.d.ts.map +1 -1
- package/dist/esm/utils/authorization.utils.mjs +0 -3
- package/dist/types/fetch-options.d.ts +13 -0
- package/dist/types/fetch-options.d.ts.map +1 -0
- package/dist/types/fetch-options.js +1 -0
- package/dist/types/scoped-actions-contracts.d.ts +1 -4
- package/dist/types/scoped-actions-contracts.d.ts.map +1 -1
- package/dist/utils/authorization.utils.d.ts.map +1 -1
- package/dist/utils/authorization.utils.js +0 -3
- package/package.json +1 -1
- package/src/authorization-internal-service.ts +8 -23
- package/src/types/fetch-options.ts +18 -0
- package/src/types/scoped-actions-contracts.ts +1 -11
- package/src/utils/authorization.utils.ts +0 -3
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import { fetch, MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
|
|
2
|
-
import { OnRetryCallback, RetryPolicy
|
|
2
|
+
import { OnRetryCallback, RetryPolicy } 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;
|
|
7
5
|
export declare const logger: import("bunyan");
|
|
8
6
|
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;
|
|
15
7
|
export declare class AuthorizationInternalService {
|
|
16
8
|
static igniteClient?: IgniteClient;
|
|
17
9
|
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,EAAyB,eAAe,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AACxG,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAK9C,eAAO,MAAM,MAAM,kBAA2B,CAAC;AAO/C,eAAO,MAAM,eAAe,EAAE,eAM7B,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;CASvC"}
|
|
@@ -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 = 10;
|
|
29
29
|
const logger = MondayLogger__namespace.getLogger();
|
|
30
30
|
const defaultMondayFetchOptions = {
|
|
31
31
|
retries: MAX_RETRIES,
|
|
@@ -39,20 +39,12 @@ 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
|
-
};
|
|
50
42
|
function logOnFetchFail(retriesLeft, error) {
|
|
51
43
|
if (retriesLeft == 0) {
|
|
52
|
-
logger.error({ retriesLeft, error },
|
|
44
|
+
logger.error({ retriesLeft, error }, 'Authorization attempt failed due to network issues');
|
|
53
45
|
}
|
|
54
46
|
else {
|
|
55
|
-
logger.info({ retriesLeft, error },
|
|
47
|
+
logger.info({ retriesLeft, error }, 'Authorization attempt failed due to network issues, trying again');
|
|
56
48
|
}
|
|
57
49
|
}
|
|
58
50
|
let mondayFetchOptions = defaultMondayFetchOptions;
|
|
@@ -118,19 +110,15 @@ class AuthorizationInternalService {
|
|
|
118
110
|
}
|
|
119
111
|
static getRetriesPolicy() {
|
|
120
112
|
const fetchOptions = AuthorizationInternalService.getRequestFetchOptions();
|
|
121
|
-
const retryDelayMS = calcDelayDurationInMs;
|
|
122
113
|
return {
|
|
123
|
-
useRetries:
|
|
124
|
-
maxRetries: fetchOptions.retries
|
|
114
|
+
useRetries: fetchOptions.retries !== undefined,
|
|
115
|
+
maxRetries: fetchOptions.retries !== undefined ? fetchOptions.retries : 0,
|
|
125
116
|
onRetry: onRetryCallback,
|
|
126
|
-
retryDelayMS,
|
|
117
|
+
retryDelayMS: fetchOptions.retryDelay ?? RETRY_DELAY_MS,
|
|
127
118
|
};
|
|
128
119
|
}
|
|
129
120
|
}
|
|
130
121
|
|
|
131
122
|
exports.AuthorizationInternalService = AuthorizationInternalService;
|
|
132
|
-
exports.MAX_RETRIES = MAX_RETRIES;
|
|
133
|
-
exports.RETRY_DELAY_MS = RETRY_DELAY_MS;
|
|
134
|
-
exports.calcDelayDurationInMs = calcDelayDurationInMs;
|
|
135
123
|
exports.logger = logger;
|
|
136
124
|
exports.onRetryCallback = onRetryCallback;
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import { fetch, MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
|
|
2
|
-
import { OnRetryCallback, RetryPolicy
|
|
2
|
+
import { OnRetryCallback, RetryPolicy } 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;
|
|
7
5
|
export declare const logger: import("bunyan");
|
|
8
6
|
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;
|
|
15
7
|
export declare class AuthorizationInternalService {
|
|
16
8
|
static igniteClient?: IgniteClient;
|
|
17
9
|
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,EAAyB,eAAe,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AACxG,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAK9C,eAAO,MAAM,MAAM,kBAA2B,CAAC;AAO/C,eAAO,MAAM,eAAe,EAAE,eAM7B,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;CASvC"}
|
|
@@ -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 = 10;
|
|
7
7
|
const logger = MondayLogger.getLogger();
|
|
8
8
|
const defaultMondayFetchOptions = {
|
|
9
9
|
retries: MAX_RETRIES,
|
|
@@ -17,20 +17,12 @@ 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
|
-
};
|
|
28
20
|
function logOnFetchFail(retriesLeft, error) {
|
|
29
21
|
if (retriesLeft == 0) {
|
|
30
|
-
logger.error({ retriesLeft, error },
|
|
22
|
+
logger.error({ retriesLeft, error }, 'Authorization attempt failed due to network issues');
|
|
31
23
|
}
|
|
32
24
|
else {
|
|
33
|
-
logger.info({ retriesLeft, error },
|
|
25
|
+
logger.info({ retriesLeft, error }, 'Authorization attempt failed due to network issues, trying again');
|
|
34
26
|
}
|
|
35
27
|
}
|
|
36
28
|
let mondayFetchOptions = defaultMondayFetchOptions;
|
|
@@ -96,14 +88,13 @@ class AuthorizationInternalService {
|
|
|
96
88
|
}
|
|
97
89
|
static getRetriesPolicy() {
|
|
98
90
|
const fetchOptions = AuthorizationInternalService.getRequestFetchOptions();
|
|
99
|
-
const retryDelayMS = calcDelayDurationInMs;
|
|
100
91
|
return {
|
|
101
|
-
useRetries:
|
|
102
|
-
maxRetries: fetchOptions.retries
|
|
92
|
+
useRetries: fetchOptions.retries !== undefined,
|
|
93
|
+
maxRetries: fetchOptions.retries !== undefined ? fetchOptions.retries : 0,
|
|
103
94
|
onRetry: onRetryCallback,
|
|
104
|
-
retryDelayMS,
|
|
95
|
+
retryDelayMS: fetchOptions.retryDelay ?? RETRY_DELAY_MS,
|
|
105
96
|
};
|
|
106
97
|
}
|
|
107
98
|
}
|
|
108
99
|
|
|
109
|
-
export { AuthorizationInternalService,
|
|
100
|
+
export { AuthorizationInternalService, logger, onRetryCallback };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ShouldRetryCallback, RetryDelayCallback, OnRetryCallback, GetTimeout } from '@mondaydotcomorg/monday-fetch-api';
|
|
2
|
+
interface FetchOptions {
|
|
3
|
+
callback: OnRetryCallback;
|
|
4
|
+
useRetries: boolean;
|
|
5
|
+
retries: number;
|
|
6
|
+
retryDelayMS: number | RetryDelayCallback;
|
|
7
|
+
retryOn: ShouldRetryCallback;
|
|
8
|
+
getTimeout: GetTimeout;
|
|
9
|
+
timeoutRetries: number;
|
|
10
|
+
}
|
|
11
|
+
export type AuthorizationFetchOptions = Partial<FetchOptions>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=fetch-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-options.d.ts","sourceRoot":"","sources":["../../../src/types/fetch-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,UAAU,EACX,MAAM,mCAAmC,CAAC;AAE3C,UAAU,YAAY;IACpB,QAAQ,EAAE,eAAe,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,GAAG,kBAAkB,CAAC;IAC1C,OAAO,EAAE,mBAAmB,CAAC;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -13,10 +13,7 @@ export interface AccountProductScope {
|
|
|
13
13
|
export interface AccountScope {
|
|
14
14
|
accountId: number;
|
|
15
15
|
}
|
|
16
|
-
export
|
|
17
|
-
credentialsSharedConfigId: number;
|
|
18
|
-
}
|
|
19
|
-
export type ScopeOptions = WorkspaceScope | BoardScope | PulseScope | AccountProductScope | AccountScope | CredentialsSharedConfigScope;
|
|
16
|
+
export type ScopeOptions = WorkspaceScope | BoardScope | PulseScope | AccountProductScope | AccountScope;
|
|
20
17
|
export interface Translation {
|
|
21
18
|
key: string;
|
|
22
19
|
[option: string]: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scoped-actions-contracts.d.ts","sourceRoot":"","sources":["../../../src/types/scoped-actions-contracts.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,
|
|
1
|
+
{"version":3,"file":"scoped-actions-contracts.d.ts","sourceRoot":"","sources":["../../../src/types/scoped-actions-contracts.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,mBAAmB,GAAG,YAAY,CAAC;AAEzG,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAED,oBAAY,qBAAqB;IAC/B,SAAS,IAAI;IACb,YAAY,IAAI;IAChB,gBAAgB,IAAI;IACpB;;;;;OAKG;IACH,cAAc,IAAI;IAClB,SAAS,IAAI;IACb,WAAW,IAAI;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,OAAO,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,eAAe,EAAE,qBAAqB,CAAC;CACxC;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,YAAY,CAAC;CACrB;AAED,MAAM,WAAW,0BAA0B;IACzC,YAAY,EAAE,YAAY,CAAC;IAC3B,MAAM,EAAE,kBAAkB,CAAC;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization.utils.d.ts","sourceRoot":"","sources":["../../../src/utils/authorization.utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEpE,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,MAAM,CAAC,EAAE,GAAG,GAAG,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACpH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAC3C;KAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAC9E,CAAC,CAAC;AAEN;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG;IAAE,YAAY,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"authorization.utils.d.ts","sourceRoot":"","sources":["../../../src/utils/authorization.utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEpE,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,MAAM,CAAC,EAAE,GAAG,GAAG,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACpH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAC3C;KAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAC9E,CAAC,CAAC;AAEN;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG;IAAE,YAAY,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,CAkB3G;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAEtE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAEzE"}
|
|
@@ -21,9 +21,6 @@ function scopeToResource(scope) {
|
|
|
21
21
|
if ('accountId' in scope) {
|
|
22
22
|
return { resourceType: 'account', resourceId: scope.accountId };
|
|
23
23
|
}
|
|
24
|
-
if ('credentialsSharedConfigId' in scope) {
|
|
25
|
-
return { resourceType: 'credentials_shared_config', resourceId: scope.credentialsSharedConfigId };
|
|
26
|
-
}
|
|
27
24
|
throw new Error('Unsupported scope provided');
|
|
28
25
|
}
|
|
29
26
|
/**
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ShouldRetryCallback, RetryDelayCallback, OnRetryCallback, GetTimeout } from '@mondaydotcomorg/monday-fetch-api';
|
|
2
|
+
interface FetchOptions {
|
|
3
|
+
callback: OnRetryCallback;
|
|
4
|
+
useRetries: boolean;
|
|
5
|
+
retries: number;
|
|
6
|
+
retryDelayMS: number | RetryDelayCallback;
|
|
7
|
+
retryOn: ShouldRetryCallback;
|
|
8
|
+
getTimeout: GetTimeout;
|
|
9
|
+
timeoutRetries: number;
|
|
10
|
+
}
|
|
11
|
+
export type AuthorizationFetchOptions = Partial<FetchOptions>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=fetch-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-options.d.ts","sourceRoot":"","sources":["../../src/types/fetch-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,UAAU,EACX,MAAM,mCAAmC,CAAC;AAE3C,UAAU,YAAY;IACpB,QAAQ,EAAE,eAAe,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,GAAG,kBAAkB,CAAC;IAC1C,OAAO,EAAE,mBAAmB,CAAC;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -13,10 +13,7 @@ export interface AccountProductScope {
|
|
|
13
13
|
export interface AccountScope {
|
|
14
14
|
accountId: number;
|
|
15
15
|
}
|
|
16
|
-
export
|
|
17
|
-
credentialsSharedConfigId: number;
|
|
18
|
-
}
|
|
19
|
-
export type ScopeOptions = WorkspaceScope | BoardScope | PulseScope | AccountProductScope | AccountScope | CredentialsSharedConfigScope;
|
|
16
|
+
export type ScopeOptions = WorkspaceScope | BoardScope | PulseScope | AccountProductScope | AccountScope;
|
|
20
17
|
export interface Translation {
|
|
21
18
|
key: string;
|
|
22
19
|
[option: string]: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scoped-actions-contracts.d.ts","sourceRoot":"","sources":["../../src/types/scoped-actions-contracts.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,
|
|
1
|
+
{"version":3,"file":"scoped-actions-contracts.d.ts","sourceRoot":"","sources":["../../src/types/scoped-actions-contracts.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,mBAAmB,GAAG,YAAY,CAAC;AAEzG,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAED,oBAAY,qBAAqB;IAC/B,SAAS,IAAI;IACb,YAAY,IAAI;IAChB,gBAAgB,IAAI;IACpB;;;;;OAKG;IACH,cAAc,IAAI;IAClB,SAAS,IAAI;IACb,WAAW,IAAI;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,OAAO,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,eAAe,EAAE,qBAAqB,CAAC;CACxC;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,YAAY,CAAC;CACrB;AAED,MAAM,WAAW,0BAA0B;IACzC,YAAY,EAAE,YAAY,CAAC;IAC3B,MAAM,EAAE,kBAAkB,CAAC;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization.utils.d.ts","sourceRoot":"","sources":["../../src/utils/authorization.utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEpE,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,MAAM,CAAC,EAAE,GAAG,GAAG,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACpH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAC3C;KAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAC9E,CAAC,CAAC;AAEN;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG;IAAE,YAAY,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"authorization.utils.d.ts","sourceRoot":"","sources":["../../src/utils/authorization.utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEpE,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,MAAM,CAAC,EAAE,GAAG,GAAG,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACpH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAC3C;KAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAC9E,CAAC,CAAC;AAEN;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG;IAAE,YAAY,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,CAkB3G;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAEtE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAEzE"}
|
|
@@ -29,9 +29,6 @@ function scopeToResource(scope) {
|
|
|
29
29
|
if ('accountId' in scope) {
|
|
30
30
|
return { resourceType: 'account', resourceId: scope.accountId };
|
|
31
31
|
}
|
|
32
|
-
if ('credentialsSharedConfigId' in scope) {
|
|
33
|
-
return { resourceType: 'credentials_shared_config', resourceId: scope.credentialsSharedConfigId };
|
|
34
|
-
}
|
|
35
32
|
throw new Error('Unsupported scope provided');
|
|
36
33
|
}
|
|
37
34
|
/**
|
package/package.json
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
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 {
|
|
5
|
-
NullableErrorWithType,
|
|
6
|
-
OnRetryCallback,
|
|
7
|
-
RetryPolicy,
|
|
8
|
-
RetryDelayCallback,
|
|
9
|
-
} from '@mondaydotcomorg/monday-fetch-api';
|
|
4
|
+
import { NullableErrorWithType, OnRetryCallback, RetryPolicy } from '@mondaydotcomorg/monday-fetch-api';
|
|
10
5
|
import { IgniteClient } from '@mondaydotcomorg/ignite-sdk';
|
|
11
6
|
import { BaseRequest } from './types/general';
|
|
12
7
|
|
|
13
8
|
const INTERNAL_APP_NAME = 'internal_ms';
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
const MAX_RETRIES = 3;
|
|
10
|
+
const RETRY_DELAY_MS = 10;
|
|
16
11
|
export const logger = MondayLogger.getLogger();
|
|
17
12
|
|
|
18
13
|
const defaultMondayFetchOptions: MondayFetchOptions = {
|
|
@@ -28,20 +23,11 @@ export const onRetryCallback: OnRetryCallback = (attempt: number, error?: Nullab
|
|
|
28
23
|
}
|
|
29
24
|
};
|
|
30
25
|
|
|
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
|
-
|
|
40
26
|
function logOnFetchFail(retriesLeft: number, error: Error) {
|
|
41
27
|
if (retriesLeft == 0) {
|
|
42
|
-
logger.error({ retriesLeft, error },
|
|
28
|
+
logger.error({ retriesLeft, error }, 'Authorization attempt failed due to network issues');
|
|
43
29
|
} else {
|
|
44
|
-
logger.info({ retriesLeft, error },
|
|
30
|
+
logger.info({ retriesLeft, error }, 'Authorization attempt failed due to network issues, trying again');
|
|
45
31
|
}
|
|
46
32
|
}
|
|
47
33
|
|
|
@@ -133,12 +119,11 @@ export class AuthorizationInternalService {
|
|
|
133
119
|
|
|
134
120
|
static getRetriesPolicy(): RetryPolicy {
|
|
135
121
|
const fetchOptions = AuthorizationInternalService.getRequestFetchOptions();
|
|
136
|
-
const retryDelayMS = calcDelayDurationInMs;
|
|
137
122
|
return {
|
|
138
|
-
useRetries:
|
|
139
|
-
maxRetries: fetchOptions.retries
|
|
123
|
+
useRetries: fetchOptions.retries !== undefined,
|
|
124
|
+
maxRetries: fetchOptions.retries !== undefined ? fetchOptions.retries : 0,
|
|
140
125
|
onRetry: onRetryCallback,
|
|
141
|
-
retryDelayMS,
|
|
126
|
+
retryDelayMS: fetchOptions.retryDelay ?? RETRY_DELAY_MS,
|
|
142
127
|
};
|
|
143
128
|
}
|
|
144
129
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ShouldRetryCallback,
|
|
3
|
+
RetryDelayCallback,
|
|
4
|
+
OnRetryCallback,
|
|
5
|
+
GetTimeout,
|
|
6
|
+
} from '@mondaydotcomorg/monday-fetch-api';
|
|
7
|
+
|
|
8
|
+
interface FetchOptions {
|
|
9
|
+
callback: OnRetryCallback;
|
|
10
|
+
useRetries: boolean;
|
|
11
|
+
retries: number;
|
|
12
|
+
retryDelayMS: number | RetryDelayCallback;
|
|
13
|
+
retryOn: ShouldRetryCallback;
|
|
14
|
+
getTimeout: GetTimeout;
|
|
15
|
+
timeoutRetries: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type AuthorizationFetchOptions = Partial<FetchOptions>;
|
|
@@ -18,17 +18,7 @@ export interface AccountScope {
|
|
|
18
18
|
accountId: number;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export
|
|
22
|
-
credentialsSharedConfigId: number;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export type ScopeOptions =
|
|
26
|
-
| WorkspaceScope
|
|
27
|
-
| BoardScope
|
|
28
|
-
| PulseScope
|
|
29
|
-
| AccountProductScope
|
|
30
|
-
| AccountScope
|
|
31
|
-
| CredentialsSharedConfigScope;
|
|
21
|
+
export type ScopeOptions = WorkspaceScope | BoardScope | PulseScope | AccountProductScope | AccountScope;
|
|
32
22
|
|
|
33
23
|
export interface Translation {
|
|
34
24
|
key: string;
|
|
@@ -28,9 +28,6 @@ export function scopeToResource(scope: ScopeOptions): { resourceType: ResourceTy
|
|
|
28
28
|
if ('accountId' in scope) {
|
|
29
29
|
return { resourceType: 'account', resourceId: scope.accountId };
|
|
30
30
|
}
|
|
31
|
-
if ('credentialsSharedConfigId' in scope) {
|
|
32
|
-
return { resourceType: 'credentials_shared_config', resourceId: scope.credentialsSharedConfigId };
|
|
33
|
-
}
|
|
34
31
|
|
|
35
32
|
throw new Error('Unsupported scope provided');
|
|
36
33
|
}
|