@mondaydotcomorg/monday-authorization 3.8.0 → 4.0.0-feat-shaime-delay-retry-when-response-code-is-429-7046169

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 (38) hide show
  1. package/README.md +62 -2
  2. package/dist/authorization-internal-service.d.ts +12 -8
  3. package/dist/authorization-internal-service.d.ts.map +1 -1
  4. package/dist/authorization-internal-service.js +122 -23
  5. package/dist/authorization-service.d.ts +2 -2
  6. package/dist/authorization-service.d.ts.map +1 -1
  7. package/dist/esm/authorization-internal-service.d.ts +12 -8
  8. package/dist/esm/authorization-internal-service.d.ts.map +1 -1
  9. package/dist/esm/authorization-internal-service.mjs +122 -24
  10. package/dist/esm/authorization-service.d.ts +2 -2
  11. package/dist/esm/authorization-service.d.ts.map +1 -1
  12. package/dist/esm/index.d.ts +3 -2
  13. package/dist/esm/index.d.ts.map +1 -1
  14. package/dist/esm/memberships.d.ts.map +1 -1
  15. package/dist/esm/memberships.mjs +11 -2
  16. package/dist/esm/roles-service.d.ts.map +1 -1
  17. package/dist/esm/roles-service.mjs +6 -1
  18. package/dist/esm/types/fetch-options.d.ts +13 -0
  19. package/dist/esm/types/fetch-options.d.ts.map +1 -0
  20. package/dist/esm/types/fetch-options.mjs +1 -0
  21. package/dist/esm/utils/assignment-schema.d.ts +7 -7
  22. package/dist/index.d.ts +3 -2
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/memberships.d.ts.map +1 -1
  25. package/dist/memberships.js +11 -2
  26. package/dist/roles-service.d.ts.map +1 -1
  27. package/dist/roles-service.js +6 -1
  28. package/dist/types/fetch-options.d.ts +13 -0
  29. package/dist/types/fetch-options.d.ts.map +1 -0
  30. package/dist/types/fetch-options.js +1 -0
  31. package/dist/utils/assignment-schema.d.ts +7 -7
  32. package/package.json +2 -2
  33. package/src/authorization-internal-service.ts +184 -30
  34. package/src/authorization-service.ts +2 -2
  35. package/src/index.ts +4 -2
  36. package/src/memberships.ts +11 -2
  37. package/src/roles-service.ts +6 -1
  38. package/src/types/fetch-options.ts +18 -0
package/README.md CHANGED
@@ -31,7 +31,11 @@ await MondayAuthorization.init({
31
31
  serviceName: process.env.APP_NAME,
32
32
  },
33
33
  redisClient: redisClient,
34
- grantedFeatureRedisExpirationInSeconds: 10 * 60
34
+ grantedFeatureRedisExpirationInSeconds: 10 * 60,
35
+ mondayFetchOptions: {
36
+ maxRetries: 5,
37
+ retryDelayMS: 100,
38
+ },
35
39
  });
36
40
  startServer(...)
37
41
  ```
@@ -534,14 +538,70 @@ interface MembershipDeleteResponse {
534
538
  }
535
539
  ```
536
540
 
541
+ ### Retry Configuration (v4.0.0+)
542
+
543
+ Retry behavior is configurable via Ignite SDK. Configure the `authorization_retry_config` key in Ignite:
544
+
545
+ ```json
546
+ {
547
+ "maxRetries": 3,
548
+ "baseDelayMs": 20,
549
+ "exponentBase": 2,
550
+ "jitterMinMs": 0,
551
+ "jitterMaxMs": 1000,
552
+ "retryOnStatusPatterns": ["429", "5**"]
553
+ }
554
+ ```
555
+
556
+ **Configuration Options:**
557
+ - `maxRetries`: Maximum number of retry attempts (default: 3)
558
+ - `baseDelayMs`: Base delay in milliseconds for exponential backoff (default: 20)
559
+ - `exponentBase`: Base for exponential backoff calculation (default: 2)
560
+ - `jitterMinMs`: Minimum jitter value in milliseconds (default: 0)
561
+ - `jitterMaxMs`: Maximum jitter value in milliseconds (default: 1000)
562
+ - `retryOnStatusPatterns`: Array of status code patterns to retry on
563
+ - Exact codes: `"429"` (retry on 429)
564
+ - Wildcards: `"5**"` (retry on all 5xx errors), `"5*9"` (retry on 509, 519, 529, etc.)
565
+
566
+ **Retry Delay Formula:**
567
+ ```
568
+ delay = baseDelayMs * (exponentBase ^ (attemptCount - 1)) + random(jitterMinMs, jitterMaxMs)
569
+ ```
570
+
571
+ **Timeout Configuration:**
572
+ - Configure timeout via `outgoing-request-timeout-ms` Ignite key (default: 2000ms in production, 60000ms in development)
573
+ - Per-service overrides via `override-outgoing-request-timeout-ms` object keyed by `APP_NAME`
574
+
575
+ **Programmatic Configuration:**
576
+ You can also configure retry behavior programmatically via `mondayFetchOptions` in `init()`:
577
+
578
+ ```ts
579
+ import { init, AuthorizationFetchOptions } from '@mondaydotcomorg/monday-authorization';
580
+
581
+ const fetchOptions: AuthorizationFetchOptions = {
582
+ maxRetries: 5,
583
+ retryDelayMS: 100,
584
+ retryOn: (attempt, error, response, isTimeoutError) => {
585
+ // Custom retry logic
586
+ return isTimeoutError || (response?.status === 429);
587
+ },
588
+ };
589
+
590
+ await init({
591
+ mondayFetchOptions: fetchOptions,
592
+ // ... other options
593
+ });
594
+ ```
595
+
537
596
  ## Development
538
597
 
539
598
  ### Local Development and Testing
540
599
 
541
600
  This package includes an `ignite-local-overrides.json` file for local development and testing only. It does **not** affect consumers of this package - they use their own Ignite configuration.
542
601
 
543
- The file enables feature flags for testing:
602
+ The file enables feature flags and retry configuration for testing:
544
603
 
545
604
  - `navigate-can-action-in-scope-to-graph`: Graph API routing for `canActionInScope` methods
605
+ - `authorization_retry_config`: Retry configuration for testing (see Retry Configuration section above)
546
606
 
547
607
  Modify this file for different local test scenarios, but remember changes only affect this package's development/testing.
@@ -1,27 +1,31 @@
1
- import { fetch, MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
2
- import { OnRetryCallback, RetryPolicy, RetryDelayCallback } from '@mondaydotcomorg/monday-fetch-api';
1
+ import { OnRetryCallback, Response, RetryPolicy } from '@mondaydotcomorg/monday-fetch-api';
3
2
  import { IgniteClient } from '@mondaydotcomorg/ignite-sdk';
4
3
  import { BaseRequest } from './types/general';
4
+ import type { AuthorizationFetchOptions } from './types/fetch-options';
5
5
  export declare const MAX_RETRIES = 3;
6
6
  export declare const RETRY_DELAY_MS = 20;
7
7
  export declare const logger: import("bunyan");
8
+ export declare const IGNITE_RETRY_CONFIG_KEY = "authorization_retry_config";
8
9
  export declare const onRetryCallback: OnRetryCallback;
9
10
  /**
10
11
  * Exponential backoff retry delay callback
11
- * Calculates delay as: baseDelay * 2^(attemptCount - 1)
12
+ * Calculates delay as: baseDelay * (exponentBase)^(attemptCount - 1) + jitter(min..max)
12
13
  * Example: attempt 1 -> 100ms, attempt 2 -> 200ms, attempt 3 -> 400ms
13
14
  */
14
- export declare const calcDelayDurationInMs: RetryDelayCallback;
15
+ export declare const calcDelayDurationInMs: ({ attemptCount }: {
16
+ attemptCount: number;
17
+ }) => number;
15
18
  export declare class AuthorizationInternalService {
16
- static igniteClient?: IgniteClient;
19
+ static get igniteClient(): IgniteClient | undefined;
20
+ static set igniteClient(client: IgniteClient | undefined);
17
21
  static skipAuthorization(requset: BaseRequest): void;
18
22
  static markAuthorized(request: BaseRequest): void;
19
23
  static failIfNotCoveredByAuthorization(request: BaseRequest): void;
20
- static throwOnHttpErrorIfNeeded(response: Awaited<ReturnType<typeof fetch>>, placement: string): void;
24
+ static throwOnHttpErrorIfNeeded(response: Response, placement: string): void;
21
25
  static throwOnHttpError(status: number, placement: string): never;
22
26
  static generateInternalAuthToken(accountId: number, userId: number): string;
23
- static setRequestFetchOptions(customMondayFetchOptions: MondayFetchOptions): void;
24
- static getRequestFetchOptions(): MondayFetchOptions;
27
+ static setRequestFetchOptions(customMondayFetchOptions: AuthorizationFetchOptions): void;
28
+ static getRequestFetchOptions(): AuthorizationFetchOptions;
25
29
  static setIgniteClient(client: IgniteClient): void;
26
30
  static getRequestTimeout(): number;
27
31
  static getRetriesPolicy(): RetryPolicy;
@@ -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,EAEL,eAAe,EACf,WAAW,EACX,kBAAkB,EACnB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAA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@@ const INTERNAL_APP_NAME = 'internal_ms';
27
27
  const MAX_RETRIES = 3;
28
28
  const RETRY_DELAY_MS = 20;
29
29
  const logger = MondayLogger__namespace.getLogger();
30
+ const IGNITE_RETRY_CONFIG_KEY = 'authorization_retry_config';
31
+ let igniteClient;
32
+ const defaultRetryConfig = {
33
+ maxRetries: MAX_RETRIES,
34
+ baseDelayMs: RETRY_DELAY_MS,
35
+ exponentBase: 2,
36
+ jitterMinMs: 0,
37
+ jitterMaxMs: 1000,
38
+ retryOnStatusPatterns: ['429', '5**'],
39
+ };
40
+ function getRetryConfig() {
41
+ if (!igniteClient) {
42
+ return defaultRetryConfig;
43
+ }
44
+ try {
45
+ return igniteClient.configuration.getObjectValue(IGNITE_RETRY_CONFIG_KEY, defaultRetryConfig);
46
+ }
47
+ catch (error) {
48
+ logger.error({ tag: 'authorization-service', error, key: IGNITE_RETRY_CONFIG_KEY, defaultValue: defaultRetryConfig }, 'Failed to get ignite retry config, using defaults');
49
+ return defaultRetryConfig;
50
+ }
51
+ }
52
+ function randomIntInclusive(min, max) {
53
+ if (max <= min) {
54
+ return min;
55
+ }
56
+ return Math.floor(min + Math.random() * (max - min + 1));
57
+ }
58
+ function buildHttpStatusMatchers(patterns) {
59
+ const matchers = [];
60
+ const addWildcardMatcher = (wildcard) => {
61
+ // Normalized 3-char pattern with digits or '*'
62
+ matchers.push((status) => {
63
+ const s = String(status);
64
+ if (s.length !== 3) {
65
+ return false;
66
+ }
67
+ for (let i = 0; i < 3; i++) {
68
+ const w = wildcard[i];
69
+ const c = s[i];
70
+ if (w === '*') {
71
+ continue;
72
+ }
73
+ if (w !== c) {
74
+ return false;
75
+ }
76
+ }
77
+ return true;
78
+ });
79
+ };
80
+ for (const raw of patterns ?? []) {
81
+ const p = String(raw).trim();
82
+ if (!p) {
83
+ continue;
84
+ }
85
+ // Exact numeric status (e.g. "429")
86
+ if (/^\d+$/.test(p)) {
87
+ const exact = Number(p);
88
+ if (Number.isFinite(exact)) {
89
+ matchers.push((status) => status === exact);
90
+ }
91
+ continue;
92
+ }
93
+ // Wildcards for 3-digit HTTP codes:
94
+ // - "5**" => 5xx
95
+ // - "5*9" => 5?9
96
+ if (/^[0-9*]+$/.test(p) && p.includes('*')) {
97
+ const normalized = p.length < 3 ? p.padEnd(3, '*') : p;
98
+ if (normalized.length !== 3) {
99
+ logger.warn({ tag: 'authorization-service', pattern: p }, 'Invalid retry status wildcard pattern (expected a 3-character pattern like "5**" or "5*9")');
100
+ }
101
+ else {
102
+ addWildcardMatcher(normalized);
103
+ }
104
+ continue;
105
+ }
106
+ logger.warn({ tag: 'authorization-service', pattern: p }, 'Invalid retry status pattern (supported: exact code like "429" or wildcard like "5**")');
107
+ }
108
+ return matchers;
109
+ }
110
+ function shouldRetryOnResponseStatus(responseOrStatus, statusMatchers) {
111
+ const status = responseOrStatus?.status;
112
+ if (typeof status !== 'number') {
113
+ return false;
114
+ }
115
+ return statusMatchers.some(matcher => matcher(status));
116
+ }
30
117
  const defaultMondayFetchOptions = {
31
- retries: MAX_RETRIES,
32
- callback: logOnFetchFail,
118
+ useRetries: true,
119
+ maxRetries: MAX_RETRIES,
120
+ retryDelayMS: RETRY_DELAY_MS,
33
121
  };
34
- const onRetryCallback = (attempt, error) => {
35
- if (attempt == MAX_RETRIES) {
36
- logger.error({ tag: 'authorization-service', attempt, error }, 'Authorization attempt failed');
122
+ const onRetryCallback = (attempt, error, response, isTimeoutError) => {
123
+ const effectiveMaxRetries = getRetryConfig().maxRetries;
124
+ if (attempt == effectiveMaxRetries) {
125
+ logger.error({ tag: 'authorization-service', attempt, error, response, isTimeoutError }, 'Authorization attempt failed');
37
126
  }
38
127
  else {
39
- logger.info({ tag: 'authorization-service', attempt, error }, 'Authorization attempt failed, trying again');
128
+ logger.debug({ tag: 'authorization-service', attempt, error, response, isTimeoutError }, 'Authorization attempt failed, trying again');
40
129
  }
41
130
  };
42
131
  /**
43
132
  * Exponential backoff retry delay callback
44
- * Calculates delay as: baseDelay * 2^(attemptCount - 1)
133
+ * Calculates delay as: baseDelay * (exponentBase)^(attemptCount - 1) + jitter(min..max)
45
134
  * Example: attempt 1 -> 100ms, attempt 2 -> 200ms, attempt 3 -> 400ms
46
135
  */
47
136
  const calcDelayDurationInMs = ({ attemptCount }) => {
48
- return RETRY_DELAY_MS * Math.pow(2, attemptCount - 1);
137
+ const { baseDelayMs, exponentBase, jitterMinMs, jitterMaxMs } = getRetryConfig();
138
+ const jitterMin = Math.min(jitterMinMs, jitterMaxMs);
139
+ const jitterMax = Math.max(jitterMinMs, jitterMaxMs);
140
+ const expDelay = baseDelayMs * Math.pow(exponentBase, attemptCount - 1);
141
+ const jitter = randomIntInclusive(jitterMin, jitterMax);
142
+ return expDelay + jitter;
49
143
  };
50
- function logOnFetchFail(retriesLeft, error) {
51
- if (retriesLeft == 0) {
52
- logger.error({ retriesLeft, error }, `Authorization attempt failed due to ${error.message}`);
53
- }
54
- else {
55
- logger.info({ retriesLeft, error }, `Authorization attempt failed due to ${error.message}, trying again`);
56
- }
57
- }
58
144
  let mondayFetchOptions = defaultMondayFetchOptions;
59
145
  class AuthorizationInternalService {
60
- static igniteClient;
146
+ static get igniteClient() {
147
+ return igniteClient;
148
+ }
149
+ static set igniteClient(client) {
150
+ igniteClient = client;
151
+ }
61
152
  static skipAuthorization(requset) {
62
153
  requset.authorizationSkipPerformed = true;
63
154
  }
@@ -94,7 +185,7 @@ class AuthorizationInternalService {
94
185
  return mondayFetchOptions;
95
186
  }
96
187
  static setIgniteClient(client) {
97
- this.igniteClient = client;
188
+ igniteClient = client;
98
189
  }
99
190
  static getRequestTimeout() {
100
191
  const isDevEnv = process.env.NODE_ENV === 'development';
@@ -118,17 +209,25 @@ class AuthorizationInternalService {
118
209
  }
119
210
  static getRetriesPolicy() {
120
211
  const fetchOptions = AuthorizationInternalService.getRequestFetchOptions();
121
- const retryDelayMS = calcDelayDurationInMs;
212
+ const retryConfig = getRetryConfig();
213
+ const statusMatchers = buildHttpStatusMatchers(retryConfig.retryOnStatusPatterns);
214
+ const defaultRetryOn = (_attempt, _error, response, isTimeoutError) => isTimeoutError ? true : shouldRetryOnResponseStatus(response ?? undefined, statusMatchers);
215
+ const effectiveMaxRetries = fetchOptions?.maxRetries ?? retryConfig.maxRetries;
216
+ const defaultGetTimeout = timeoutsCount => calcDelayDurationInMs({ attemptCount: timeoutsCount });
122
217
  return {
123
- useRetries: !!fetchOptions.retries,
124
- maxRetries: fetchOptions.retries ?? 0,
125
- onRetry: onRetryCallback,
126
- retryDelayMS,
218
+ useRetries: fetchOptions?.useRetries ?? true,
219
+ maxRetries: effectiveMaxRetries,
220
+ retryDelayMS: fetchOptions?.retryDelayMS ?? calcDelayDurationInMs,
221
+ onRetry: fetchOptions?.callback ?? onRetryCallback,
222
+ retryOn: fetchOptions?.retryOn ?? defaultRetryOn,
223
+ timeoutRetries: fetchOptions?.timeoutRetries ?? effectiveMaxRetries,
224
+ getTimeout: fetchOptions?.getTimeout ?? defaultGetTimeout,
127
225
  };
128
226
  }
129
227
  }
130
228
 
131
229
  exports.AuthorizationInternalService = AuthorizationInternalService;
230
+ exports.IGNITE_RETRY_CONFIG_KEY = IGNITE_RETRY_CONFIG_KEY;
132
231
  exports.MAX_RETRIES = MAX_RETRIES;
133
232
  exports.RETRY_DELAY_MS = RETRY_DELAY_MS;
134
233
  exports.calcDelayDurationInMs = calcDelayDurationInMs;
@@ -1,13 +1,13 @@
1
- import { MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
2
1
  import { IgniteClient } from '@mondaydotcomorg/ignite-sdk';
3
2
  import { Action, AuthorizationObject, AuthorizationParams, AuthorizationResource } from './types/general';
4
3
  import { ScopedAction, ScopedActionPermit, ScopedActionResponseObject, ScopeOptions } from './types/scoped-actions-contracts';
4
+ import type { AuthorizationFetchOptions } from './types/fetch-options';
5
5
  export interface AuthorizeResponse {
6
6
  isAuthorized: boolean;
7
7
  unauthorizedIds?: number[];
8
8
  unauthorizedObjects?: AuthorizationObject[];
9
9
  }
10
- export declare function setRequestFetchOptions(customMondayFetchOptions: MondayFetchOptions): void;
10
+ export declare function setRequestFetchOptions(customMondayFetchOptions: AuthorizationFetchOptions): void;
11
11
  export declare class AuthorizationService {
12
12
  private static get graphApi();
13
13
  private static _graphApi?;
@@ -1 +1 @@
1
- {"version":3,"file":"authorization-service.d.ts","sourceRoot":"","sources":["../src/authorization-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAmB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAG1G,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACb,MAAM,kCAAkC,CAAC;AAY1C,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,mBAAmB,CAAC,EAAE,mBAAmB,EAAE,CAAC;CAC7C;AAED,wBAAgB,sBAAsB,CAAC,wBAAwB,EAAE,kBAAkB,QAElF;AAMD,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,KAAK,QAAQ,GAK1B;IACD,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAW;IAEpC,OAAO,CAAC,MAAM,KAAK,WAAW,GAK7B;IACD,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAc;IAE1C,MAAM,CAAC,eAAe,IAAI,IAAI;IAK9B,MAAM,CAAC,WAAW,CAAC,MAAC;IACpB,MAAM,CAAC,sCAAsC,CAAC,EAAE,MAAM,CAAC;IACvD,MAAM,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IAEnC;;;OAGG;WACU,YAAY,CACvB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,qBAAqB,EAAE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AgB,CAC3B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,kBAAkB,CAAC;WAMjB,wBAAwB,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,YAAY,EAAE,GAC5B,OAAO,CAAC,0BAA0B,EAAE,CAAC;mBA4CnB,oBAAoB;mBAUpB,oBAAoB;CAmF1C;AAED,wBAAgB,cAAc,CAC5B,MAAM,KAAA,EACN,sCAAsC,GAAE,MAAiD,QAY1F;AAED,wBAAsB,eAAe,kBAMpC;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,qBAAqB,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAiBjH"}
@@ -1,27 +1,31 @@
1
- import { fetch, MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
2
- import { OnRetryCallback, RetryPolicy, RetryDelayCallback } from '@mondaydotcomorg/monday-fetch-api';
1
+ import { OnRetryCallback, Response, RetryPolicy } from '@mondaydotcomorg/monday-fetch-api';
3
2
  import { IgniteClient } from '@mondaydotcomorg/ignite-sdk';
4
3
  import { BaseRequest } from './types/general';
4
+ import type { AuthorizationFetchOptions } from './types/fetch-options';
5
5
  export declare const MAX_RETRIES = 3;
6
6
  export declare const RETRY_DELAY_MS = 20;
7
7
  export declare const logger: import("bunyan");
8
+ export declare const IGNITE_RETRY_CONFIG_KEY = "authorization_retry_config";
8
9
  export declare const onRetryCallback: OnRetryCallback;
9
10
  /**
10
11
  * Exponential backoff retry delay callback
11
- * Calculates delay as: baseDelay * 2^(attemptCount - 1)
12
+ * Calculates delay as: baseDelay * (exponentBase)^(attemptCount - 1) + jitter(min..max)
12
13
  * Example: attempt 1 -> 100ms, attempt 2 -> 200ms, attempt 3 -> 400ms
13
14
  */
14
- export declare const calcDelayDurationInMs: RetryDelayCallback;
15
+ export declare const calcDelayDurationInMs: ({ attemptCount }: {
16
+ attemptCount: number;
17
+ }) => number;
15
18
  export declare class AuthorizationInternalService {
16
- static igniteClient?: IgniteClient;
19
+ static get igniteClient(): IgniteClient | undefined;
20
+ static set igniteClient(client: IgniteClient | undefined);
17
21
  static skipAuthorization(requset: BaseRequest): void;
18
22
  static markAuthorized(request: BaseRequest): void;
19
23
  static failIfNotCoveredByAuthorization(request: BaseRequest): void;
20
- static throwOnHttpErrorIfNeeded(response: Awaited<ReturnType<typeof fetch>>, placement: string): void;
24
+ static throwOnHttpErrorIfNeeded(response: Response, placement: string): void;
21
25
  static throwOnHttpError(status: number, placement: string): never;
22
26
  static generateInternalAuthToken(accountId: number, userId: number): string;
23
- static setRequestFetchOptions(customMondayFetchOptions: MondayFetchOptions): void;
24
- static getRequestFetchOptions(): MondayFetchOptions;
27
+ static setRequestFetchOptions(customMondayFetchOptions: AuthorizationFetchOptions): void;
28
+ static getRequestFetchOptions(): AuthorizationFetchOptions;
25
29
  static setIgniteClient(client: IgniteClient): void;
26
30
  static getRequestTimeout(): number;
27
31
  static getRetriesPolicy(): RetryPolicy;
@@ -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,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,C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AM,uBAAuB,+BAA+B,CAAC;AAqIpE,eAAO,MAAM,eAAe,EAAE,eAkB7B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,kBAAkB;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,KAAG,MAOlF,CAAC;AAIF,qBAAa,4BAA4B;IACvC,MAAM,KAAK,YAAY,IAAI,YAAY,GAAG,SAAS,CAElD;IAED,MAAM,KAAK,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,EAEvD;IACD,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,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAc5E,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,yBAAyB;IAOjF,MAAM,CAAC,sBAAsB,IAAI,yBAAyB;IAI1D,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,YAAY;IAI3C,MAAM,CAAC,iBAAiB;IA2BxB,MAAM,CAAC,gBAAgB,IAAI,WAAW;CAmBvC"}
@@ -5,37 +5,128 @@ const INTERNAL_APP_NAME = 'internal_ms';
5
5
  const MAX_RETRIES = 3;
6
6
  const RETRY_DELAY_MS = 20;
7
7
  const logger = MondayLogger.getLogger();
8
+ const IGNITE_RETRY_CONFIG_KEY = 'authorization_retry_config';
9
+ let igniteClient;
10
+ const defaultRetryConfig = {
11
+ maxRetries: MAX_RETRIES,
12
+ baseDelayMs: RETRY_DELAY_MS,
13
+ exponentBase: 2,
14
+ jitterMinMs: 0,
15
+ jitterMaxMs: 1000,
16
+ retryOnStatusPatterns: ['429', '5**'],
17
+ };
18
+ function getRetryConfig() {
19
+ if (!igniteClient) {
20
+ return defaultRetryConfig;
21
+ }
22
+ try {
23
+ return igniteClient.configuration.getObjectValue(IGNITE_RETRY_CONFIG_KEY, defaultRetryConfig);
24
+ }
25
+ catch (error) {
26
+ logger.error({ tag: 'authorization-service', error, key: IGNITE_RETRY_CONFIG_KEY, defaultValue: defaultRetryConfig }, 'Failed to get ignite retry config, using defaults');
27
+ return defaultRetryConfig;
28
+ }
29
+ }
30
+ function randomIntInclusive(min, max) {
31
+ if (max <= min) {
32
+ return min;
33
+ }
34
+ return Math.floor(min + Math.random() * (max - min + 1));
35
+ }
36
+ function buildHttpStatusMatchers(patterns) {
37
+ const matchers = [];
38
+ const addWildcardMatcher = (wildcard) => {
39
+ // Normalized 3-char pattern with digits or '*'
40
+ matchers.push((status) => {
41
+ const s = String(status);
42
+ if (s.length !== 3) {
43
+ return false;
44
+ }
45
+ for (let i = 0; i < 3; i++) {
46
+ const w = wildcard[i];
47
+ const c = s[i];
48
+ if (w === '*') {
49
+ continue;
50
+ }
51
+ if (w !== c) {
52
+ return false;
53
+ }
54
+ }
55
+ return true;
56
+ });
57
+ };
58
+ for (const raw of patterns ?? []) {
59
+ const p = String(raw).trim();
60
+ if (!p) {
61
+ continue;
62
+ }
63
+ // Exact numeric status (e.g. "429")
64
+ if (/^\d+$/.test(p)) {
65
+ const exact = Number(p);
66
+ if (Number.isFinite(exact)) {
67
+ matchers.push((status) => status === exact);
68
+ }
69
+ continue;
70
+ }
71
+ // Wildcards for 3-digit HTTP codes:
72
+ // - "5**" => 5xx
73
+ // - "5*9" => 5?9
74
+ if (/^[0-9*]+$/.test(p) && p.includes('*')) {
75
+ const normalized = p.length < 3 ? p.padEnd(3, '*') : p;
76
+ if (normalized.length !== 3) {
77
+ logger.warn({ tag: 'authorization-service', pattern: p }, 'Invalid retry status wildcard pattern (expected a 3-character pattern like "5**" or "5*9")');
78
+ }
79
+ else {
80
+ addWildcardMatcher(normalized);
81
+ }
82
+ continue;
83
+ }
84
+ logger.warn({ tag: 'authorization-service', pattern: p }, 'Invalid retry status pattern (supported: exact code like "429" or wildcard like "5**")');
85
+ }
86
+ return matchers;
87
+ }
88
+ function shouldRetryOnResponseStatus(responseOrStatus, statusMatchers) {
89
+ const status = responseOrStatus?.status;
90
+ if (typeof status !== 'number') {
91
+ return false;
92
+ }
93
+ return statusMatchers.some(matcher => matcher(status));
94
+ }
8
95
  const defaultMondayFetchOptions = {
9
- retries: MAX_RETRIES,
10
- callback: logOnFetchFail,
96
+ useRetries: true,
97
+ maxRetries: MAX_RETRIES,
98
+ retryDelayMS: RETRY_DELAY_MS,
11
99
  };
12
- const onRetryCallback = (attempt, error) => {
13
- if (attempt == MAX_RETRIES) {
14
- logger.error({ tag: 'authorization-service', attempt, error }, 'Authorization attempt failed');
100
+ const onRetryCallback = (attempt, error, response, isTimeoutError) => {
101
+ const effectiveMaxRetries = getRetryConfig().maxRetries;
102
+ if (attempt == effectiveMaxRetries) {
103
+ logger.error({ tag: 'authorization-service', attempt, error, response, isTimeoutError }, 'Authorization attempt failed');
15
104
  }
16
105
  else {
17
- logger.info({ tag: 'authorization-service', attempt, error }, 'Authorization attempt failed, trying again');
106
+ logger.debug({ tag: 'authorization-service', attempt, error, response, isTimeoutError }, 'Authorization attempt failed, trying again');
18
107
  }
19
108
  };
20
109
  /**
21
110
  * Exponential backoff retry delay callback
22
- * Calculates delay as: baseDelay * 2^(attemptCount - 1)
111
+ * Calculates delay as: baseDelay * (exponentBase)^(attemptCount - 1) + jitter(min..max)
23
112
  * Example: attempt 1 -> 100ms, attempt 2 -> 200ms, attempt 3 -> 400ms
24
113
  */
25
114
  const calcDelayDurationInMs = ({ attemptCount }) => {
26
- return RETRY_DELAY_MS * Math.pow(2, attemptCount - 1);
115
+ const { baseDelayMs, exponentBase, jitterMinMs, jitterMaxMs } = getRetryConfig();
116
+ const jitterMin = Math.min(jitterMinMs, jitterMaxMs);
117
+ const jitterMax = Math.max(jitterMinMs, jitterMaxMs);
118
+ const expDelay = baseDelayMs * Math.pow(exponentBase, attemptCount - 1);
119
+ const jitter = randomIntInclusive(jitterMin, jitterMax);
120
+ return expDelay + jitter;
27
121
  };
28
- function logOnFetchFail(retriesLeft, error) {
29
- if (retriesLeft == 0) {
30
- logger.error({ retriesLeft, error }, `Authorization attempt failed due to ${error.message}`);
31
- }
32
- else {
33
- logger.info({ retriesLeft, error }, `Authorization attempt failed due to ${error.message}, trying again`);
34
- }
35
- }
36
122
  let mondayFetchOptions = defaultMondayFetchOptions;
37
123
  class AuthorizationInternalService {
38
- static igniteClient;
124
+ static get igniteClient() {
125
+ return igniteClient;
126
+ }
127
+ static set igniteClient(client) {
128
+ igniteClient = client;
129
+ }
39
130
  static skipAuthorization(requset) {
40
131
  requset.authorizationSkipPerformed = true;
41
132
  }
@@ -72,7 +163,7 @@ class AuthorizationInternalService {
72
163
  return mondayFetchOptions;
73
164
  }
74
165
  static setIgniteClient(client) {
75
- this.igniteClient = client;
166
+ igniteClient = client;
76
167
  }
77
168
  static getRequestTimeout() {
78
169
  const isDevEnv = process.env.NODE_ENV === 'development';
@@ -96,14 +187,21 @@ class AuthorizationInternalService {
96
187
  }
97
188
  static getRetriesPolicy() {
98
189
  const fetchOptions = AuthorizationInternalService.getRequestFetchOptions();
99
- const retryDelayMS = calcDelayDurationInMs;
190
+ const retryConfig = getRetryConfig();
191
+ const statusMatchers = buildHttpStatusMatchers(retryConfig.retryOnStatusPatterns);
192
+ const defaultRetryOn = (_attempt, _error, response, isTimeoutError) => isTimeoutError ? true : shouldRetryOnResponseStatus(response ?? undefined, statusMatchers);
193
+ const effectiveMaxRetries = fetchOptions?.maxRetries ?? retryConfig.maxRetries;
194
+ const defaultGetTimeout = timeoutsCount => calcDelayDurationInMs({ attemptCount: timeoutsCount });
100
195
  return {
101
- useRetries: !!fetchOptions.retries,
102
- maxRetries: fetchOptions.retries ?? 0,
103
- onRetry: onRetryCallback,
104
- retryDelayMS,
196
+ useRetries: fetchOptions?.useRetries ?? true,
197
+ maxRetries: effectiveMaxRetries,
198
+ retryDelayMS: fetchOptions?.retryDelayMS ?? calcDelayDurationInMs,
199
+ onRetry: fetchOptions?.callback ?? onRetryCallback,
200
+ retryOn: fetchOptions?.retryOn ?? defaultRetryOn,
201
+ timeoutRetries: fetchOptions?.timeoutRetries ?? effectiveMaxRetries,
202
+ getTimeout: fetchOptions?.getTimeout ?? defaultGetTimeout,
105
203
  };
106
204
  }
107
205
  }
108
206
 
109
- export { AuthorizationInternalService, MAX_RETRIES, RETRY_DELAY_MS, calcDelayDurationInMs, logger, onRetryCallback };
207
+ export { AuthorizationInternalService, IGNITE_RETRY_CONFIG_KEY, MAX_RETRIES, RETRY_DELAY_MS, calcDelayDurationInMs, logger, onRetryCallback };
@@ -1,13 +1,13 @@
1
- import { MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
2
1
  import { IgniteClient } from '@mondaydotcomorg/ignite-sdk';
3
2
  import { Action, AuthorizationObject, AuthorizationParams, AuthorizationResource } from './types/general';
4
3
  import { ScopedAction, ScopedActionPermit, ScopedActionResponseObject, ScopeOptions } from './types/scoped-actions-contracts';
4
+ import type { AuthorizationFetchOptions } from './types/fetch-options';
5
5
  export interface AuthorizeResponse {
6
6
  isAuthorized: boolean;
7
7
  unauthorizedIds?: number[];
8
8
  unauthorizedObjects?: AuthorizationObject[];
9
9
  }
10
- export declare function setRequestFetchOptions(customMondayFetchOptions: MondayFetchOptions): void;
10
+ export declare function setRequestFetchOptions(customMondayFetchOptions: AuthorizationFetchOptions): void;
11
11
  export declare class AuthorizationService {
12
12
  private static get graphApi();
13
13
  private static _graphApi?;
@@ -1 +1 @@
1
- {"version":3,"file":"authorization-service.d.ts","sourceRoot":"","sources":["../../src/authorization-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,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AC;mBA4CnB,oBAAoB;mBAUpB,oBAAoB;CAmF1C;AAED,wBAAgB,cAAc,CAC5B,MAAM,KAAA,EACN,sCAAsC,GAAE,MAAiD,QAY1F;AAED,wBAAsB,eAAe,kBAMpC;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,qBAAqB,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAiBjH"}
@@ -1,6 +1,6 @@
1
- import { MondayFetchOptions } from '@mondaydotcomorg/monday-fetch';
2
1
  import { MetricsClient } from './metrics-service';
3
2
  import * as TestKit from './testKit';
3
+ import type { AuthorizationFetchOptions } from './types/fetch-options';
4
4
  interface MetricsInitOptions {
5
5
  client?: MetricsClient;
6
6
  serviceName?: string;
@@ -10,7 +10,7 @@ interface MetricsInitOptions {
10
10
  }
11
11
  export interface InitOptions {
12
12
  prometheus?: any;
13
- mondayFetchOptions?: MondayFetchOptions;
13
+ mondayFetchOptions?: AuthorizationFetchOptions;
14
14
  redisClient?: any;
15
15
  grantedFeatureRedisExpirationInSeconds?: number;
16
16
  metrics?: MetricsInitOptions;
@@ -31,4 +31,5 @@ export { CustomRole, BasicRole, RoleType, RoleCreateRequest, RoleUpdateRequest,
31
31
  export { AttributeAssignment, AttributeOperation, ResourceAttributeDeleteAssignment, ResourceAttributeUpsertOperation, ResourceAttributeDeleteOperation, EntityAttributeDeleteAssignment, EntityAttributeUpsertOperation, EntityAttributeDeleteOperation, ResourceAttributeAssignment as ResourceAttributeAssignmentContract, EntityAttributeAssignment as EntityAttributeAssignmentContract, } from './types/authorization-attributes-contracts';
32
32
  export { BaseAuthorizationAttributesService as IAuthorizationAttributesService } from './base-authorization-attributes-service';
33
33
  export { TestKit };
34
+ export type { AuthorizationFetchOptions };
34
35
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BA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