@lightdash/common 0.2251.6 → 0.2252.1

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.
@@ -7,4 +7,24 @@
7
7
  * const isSlackId = SLACK_ID_REGEX.test('W1234567890');
8
8
  */
9
9
  export declare const SLACK_ID_REGEX: RegExp;
10
+ /**
11
+ * Slack error codes that indicate the installation is broken and won't be fixed by retrying.
12
+ * These are expected for orgs with invalid/revoked tokens - we handle them gracefully
13
+ * without spamming Sentry.
14
+ */
15
+ export declare const UNRECOVERABLE_SLACK_ERRORS: readonly ["account_inactive", "invalid_auth", "missing_scope"];
16
+ /**
17
+ * Extracts the Slack error code from an error object.
18
+ * Slack API errors have the format: { data: { error: 'error_code' } }
19
+ */
20
+ export declare const getSlackErrorCode: (error: unknown) => string | undefined;
21
+ /**
22
+ * Checks if a Slack error is unrecoverable (installation is broken).
23
+ */
24
+ export declare const isUnrecoverableSlackError: (error: unknown) => boolean;
25
+ /**
26
+ * Checks if a Slack error is a rate limit error.
27
+ * These errors have a special code from the @slack/web-api package.
28
+ */
29
+ export declare const isSlackRateLimitedError: (error: unknown) => boolean;
10
30
  //# sourceMappingURL=slack.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"slack.d.ts","sourceRoot":"","sources":["../../../src/utils/slack.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,QAA0B,CAAC"}
1
+ {"version":3,"file":"slack.d.ts","sourceRoot":"","sources":["../../../src/utils/slack.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,QAA0B,CAAC;AAEtD;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,gEAI7B,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,iBAAiB,UAAW,OAAO,KAAG,MAAM,GAAG,SAY3D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,UAAW,OAAO,KAAG,OAQ1D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,UAAW,OAAO,KAAG,OAGL,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SLACK_ID_REGEX = void 0;
3
+ exports.isSlackRateLimitedError = exports.isUnrecoverableSlackError = exports.getSlackErrorCode = exports.UNRECOVERABLE_SLACK_ERRORS = exports.SLACK_ID_REGEX = void 0;
4
4
  /**
5
5
  * Regex to detect Slack IDs: C (public channel), G (private channel), U/W (user/DM)
6
6
  * @example
@@ -10,4 +10,47 @@ exports.SLACK_ID_REGEX = void 0;
10
10
  * const isSlackId = SLACK_ID_REGEX.test('W1234567890');
11
11
  */
12
12
  exports.SLACK_ID_REGEX = /^[CGUW][A-Z0-9]{8,}$/i;
13
+ /**
14
+ * Slack error codes that indicate the installation is broken and won't be fixed by retrying.
15
+ * These are expected for orgs with invalid/revoked tokens - we handle them gracefully
16
+ * without spamming Sentry.
17
+ */
18
+ exports.UNRECOVERABLE_SLACK_ERRORS = [
19
+ 'account_inactive', // Bot/app was deactivated
20
+ 'invalid_auth', // Invalid authentication
21
+ 'missing_scope', // Missing required OAuth scope
22
+ ];
23
+ /**
24
+ * Extracts the Slack error code from an error object.
25
+ * Slack API errors have the format: { data: { error: 'error_code' } }
26
+ */
27
+ const getSlackErrorCode = (error) => {
28
+ if (error &&
29
+ typeof error === 'object' &&
30
+ 'data' in error &&
31
+ error.data &&
32
+ typeof error.data === 'object' &&
33
+ 'error' in error.data) {
34
+ return error.data.error;
35
+ }
36
+ return undefined;
37
+ };
38
+ exports.getSlackErrorCode = getSlackErrorCode;
39
+ /**
40
+ * Checks if a Slack error is unrecoverable (installation is broken).
41
+ */
42
+ const isUnrecoverableSlackError = (error) => {
43
+ const errorCode = (0, exports.getSlackErrorCode)(error);
44
+ return (errorCode !== undefined &&
45
+ exports.UNRECOVERABLE_SLACK_ERRORS.includes(errorCode));
46
+ };
47
+ exports.isUnrecoverableSlackError = isUnrecoverableSlackError;
48
+ /**
49
+ * Checks if a Slack error is a rate limit error.
50
+ * These errors have a special code from the @slack/web-api package.
51
+ */
52
+ const isSlackRateLimitedError = (error) => error instanceof Error &&
53
+ 'code' in error &&
54
+ error.code === 'slack_webapi_rate_limited_error';
55
+ exports.isSlackRateLimitedError = isSlackRateLimitedError;
13
56
  //# sourceMappingURL=slack.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"slack.js","sourceRoot":"","sources":["../../../src/utils/slack.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACU,QAAA,cAAc,GAAG,uBAAuB,CAAC"}
1
+ {"version":3,"file":"slack.js","sourceRoot":"","sources":["../../../src/utils/slack.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACU,QAAA,cAAc,GAAG,uBAAuB,CAAC;AAEtD;;;;GAIG;AACU,QAAA,0BAA0B,GAAG;IACtC,kBAAkB,EAAE,0BAA0B;IAC9C,cAAc,EAAE,yBAAyB;IACzC,eAAe,EAAE,+BAA+B;CAC1C,CAAC;AAEX;;;GAGG;AACI,MAAM,iBAAiB,GAAG,CAAC,KAAc,EAAsB,EAAE;IACpE,IACI,KAAK;QACL,OAAO,KAAK,KAAK,QAAQ;QACzB,MAAM,IAAI,KAAK;QACf,KAAK,CAAC,IAAI;QACV,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,OAAO,IAAI,KAAK,CAAC,IAAI,EACvB,CAAC;QACC,OAAQ,KAAK,CAAC,IAA0B,CAAC,KAAK,CAAC;IACnD,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAZW,QAAA,iBAAiB,qBAY5B;AAEF;;GAEG;AACI,MAAM,yBAAyB,GAAG,CAAC,KAAc,EAAW,EAAE;IACjE,MAAM,SAAS,GAAG,IAAA,yBAAiB,EAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,CACH,SAAS,KAAK,SAAS;QACvB,kCAA0B,CAAC,QAAQ,CAC/B,SAAsD,CACzD,CACJ,CAAC;AACN,CAAC,CAAC;AARW,QAAA,yBAAyB,6BAQpC;AAEF;;;GAGG;AACI,MAAM,uBAAuB,GAAG,CAAC,KAAc,EAAW,EAAE,CAC/D,KAAK,YAAY,KAAK;IACtB,MAAM,IAAI,KAAK;IACf,KAAK,CAAC,IAAI,KAAK,iCAAiC,CAAC;AAHxC,QAAA,uBAAuB,2BAGiB"}