@lightdash/common 0.2252.0 → 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.
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/utils/slack.d.ts +20 -0
- package/dist/cjs/utils/slack.d.ts.map +1 -1
- package/dist/cjs/utils/slack.js +44 -1
- package/dist/cjs/utils/slack.js.map +1 -1
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/utils/slack.d.ts +20 -0
- package/dist/esm/utils/slack.d.ts.map +1 -1
- package/dist/esm/utils/slack.js +40 -0
- package/dist/esm/utils/slack.js.map +1 -1
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/utils/slack.d.ts +20 -0
- package/dist/types/utils/slack.d.ts.map +1 -1
- package/dist/types/utils/slack.js +40 -0
- package/dist/types/utils/slack.js.map +1 -1
- package/package.json +1 -1
|
@@ -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"}
|
package/dist/esm/utils/slack.js
CHANGED
|
@@ -7,4 +7,44 @@
|
|
|
7
7
|
* const isSlackId = SLACK_ID_REGEX.test('W1234567890');
|
|
8
8
|
*/
|
|
9
9
|
export const SLACK_ID_REGEX = /^[CGUW][A-Z0-9]{8,}$/i;
|
|
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 const UNRECOVERABLE_SLACK_ERRORS = [
|
|
16
|
+
'account_inactive', // Bot/app was deactivated
|
|
17
|
+
'invalid_auth', // Invalid authentication
|
|
18
|
+
'missing_scope', // Missing required OAuth scope
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* Extracts the Slack error code from an error object.
|
|
22
|
+
* Slack API errors have the format: { data: { error: 'error_code' } }
|
|
23
|
+
*/
|
|
24
|
+
export const getSlackErrorCode = (error) => {
|
|
25
|
+
if (error &&
|
|
26
|
+
typeof error === 'object' &&
|
|
27
|
+
'data' in error &&
|
|
28
|
+
error.data &&
|
|
29
|
+
typeof error.data === 'object' &&
|
|
30
|
+
'error' in error.data) {
|
|
31
|
+
return error.data.error;
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Checks if a Slack error is unrecoverable (installation is broken).
|
|
37
|
+
*/
|
|
38
|
+
export const isUnrecoverableSlackError = (error) => {
|
|
39
|
+
const errorCode = getSlackErrorCode(error);
|
|
40
|
+
return (errorCode !== undefined &&
|
|
41
|
+
UNRECOVERABLE_SLACK_ERRORS.includes(errorCode));
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Checks if a Slack error is a rate limit error.
|
|
45
|
+
* These errors have a special code from the @slack/web-api package.
|
|
46
|
+
*/
|
|
47
|
+
export const isSlackRateLimitedError = (error) => error instanceof Error &&
|
|
48
|
+
'code' in error &&
|
|
49
|
+
error.code === 'slack_webapi_rate_limited_error';
|
|
10
50
|
//# sourceMappingURL=slack.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slack.js","sourceRoot":"","sources":["../../../src/utils/slack.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"slack.js","sourceRoot":"","sources":["../../../src/utils/slack.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAEtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACtC,kBAAkB,EAAE,0BAA0B;IAC9C,cAAc,EAAE,yBAAyB;IACzC,eAAe,EAAE,+BAA+B;CAC1C,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,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;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,KAAc,EAAW,EAAE;IACjE,MAAM,SAAS,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,CACH,SAAS,KAAK,SAAS;QACvB,0BAA0B,CAAC,QAAQ,CAC/B,SAAsD,CACzD,CACJ,CAAC;AACN,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAc,EAAW,EAAE,CAC/D,KAAK,YAAY,KAAK;IACtB,MAAM,IAAI,KAAK;IACf,KAAK,CAAC,IAAI,KAAK,iCAAiC,CAAC"}
|