@slack/web-api
Advanced tools
Comparing version 6.1.0 to 6.2.0-rc.0
@@ -132,2 +132,5 @@ "use strict"; | ||
invalidate: bindApiCall(this, 'admin.users.session.invalidate'), | ||
getSettings: bindApiCall(this, 'admin.users.session.getSettings'), | ||
setSettings: bindApiCall(this, 'admin.users.session.setSettings'), | ||
clearSettings: bindApiCall(this, 'admin.users.session.clearSettings'), | ||
}, | ||
@@ -134,0 +137,0 @@ setAdmin: bindApiCall(this, 'admin.users.setAdmin'), |
@@ -105,3 +105,3 @@ /// <reference types="node" /> | ||
/** | ||
* Processes an HTTP response into a WebAPICallResult by performing JSON parsing on the body and merging relevent | ||
* Processes an HTTP response into a WebAPICallResult by performing JSON parsing on the body and merging relevant | ||
* HTTP headers into the object. | ||
@@ -108,0 +108,0 @@ * @param response - an http response |
@@ -74,3 +74,3 @@ "use strict"; | ||
*/ | ||
constructor(token, { slackApiUrl = 'https://slack.com/api/', logger = undefined, logLevel = logger_1.LogLevel.INFO, maxRequestConcurrency = 3, retryConfig = retry_policies_1.default.tenRetriesInAboutThirtyMinutes, agent = undefined, tls = undefined, rejectRateLimitedCalls = false, headers = {}, teamId = undefined, } = {}) { | ||
constructor(token, { slackApiUrl = 'https://slack.com/api/', logger = undefined, logLevel = undefined, maxRequestConcurrency = 3, retryConfig = retry_policies_1.default.tenRetriesInAboutThirtyMinutes, agent = undefined, tls = undefined, rejectRateLimitedCalls = false, headers = {}, teamId = undefined, } = {}) { | ||
super(); | ||
@@ -93,3 +93,3 @@ this.token = token; | ||
else { | ||
this.logger = logger_1.getLogger(WebClient.loggerName, logLevel, logger); | ||
this.logger = logger_1.getLogger(WebClient.loggerName, logLevel !== null && logLevel !== void 0 ? logLevel : logger_1.LogLevel.INFO, logger); | ||
} | ||
@@ -125,2 +125,3 @@ this.axios = axios_1.default.create({ | ||
warnDeprecations(method, this.logger); | ||
warnIfFallbackIsMissing(method, this.logger, options); | ||
if (typeof options === 'string' || typeof options === 'number' || typeof options === 'boolean') { | ||
@@ -365,3 +366,3 @@ throw new TypeError(`Expected an options argument but instead received a ${typeof options}`); | ||
/** | ||
* Processes an HTTP response into a WebAPICallResult by performing JSON parsing on the body and merging relevent | ||
* Processes an HTTP response into a WebAPICallResult by performing JSON parsing on the body and merging relevant | ||
* HTTP headers into the object. | ||
@@ -460,2 +461,26 @@ * @param response - an http response | ||
} | ||
/** | ||
* Log a warning when using chat.postMessage without text argument or attachments with fallback argument | ||
* @param method api method being called | ||
* @param logger instance of we clients logger | ||
*/ | ||
function warnIfFallbackIsMissing(method, logger, options) { | ||
const targetMethods = ['chat.postEphemeral', 'chat.postMessage', 'chat.scheduleMessage', 'chat.update']; | ||
const isTargetMethod = targetMethods.includes(method); | ||
const missingAttachmentFallbackDetected = (args) => Array.isArray(args.attachments) | ||
&& args.attachments.some(attachment => !attachment.fallback || attachment.fallback.trim() === 0); | ||
const isEmptyText = (args) => args.text === undefined || args.text === null || args.text === ''; | ||
const buildWarningMessage = (missing) => `The \`${missing}\` argument is missing in the request payload for a ${method} call - ` + | ||
`It's a best practice to always provide a \`${missing}\` argument when posting a message. ` + | ||
`The \`${missing}\` is used in places where the content cannot be rendered such as: ` + | ||
'system push notifications, assistive technology such as screen readers, etc.'; | ||
if (isTargetMethod && typeof options === 'object' && isEmptyText(options)) { | ||
if (missingAttachmentFallbackDetected(options)) { | ||
logger.warn(buildWarningMessage('fallback')); | ||
} | ||
else { | ||
logger.warn(buildWarningMessage('text')); | ||
} | ||
} | ||
} | ||
//# sourceMappingURL=WebClient.js.map |
{ | ||
"name": "@slack/web-api", | ||
"version": "6.1.0", | ||
"version": "6.2.0-rc.0", | ||
"description": "Official library for using the Slack Platform's Web API", | ||
@@ -48,4 +48,4 @@ "author": "Slack Technologies, Inc.", | ||
"dependencies": { | ||
"@slack/logger": ">=1.0.0 <3.0.0", | ||
"@slack/types": "^1.7.0", | ||
"@slack/logger": "^3.0.0", | ||
"@slack/types": "^2.0.0", | ||
"@types/is-stream": "^1.1.0", | ||
@@ -52,0 +52,0 @@ "@types/node": ">=12.0.0", |
# Slack Web API | ||
[![build-ci](https://github.com/slackapi/node-slack-sdk/workflows/CI%20Build/badge.svg)](https://github.com/slackapi/node-slack-sdk/actions?query=workflow%3A%22CI+Build%22) | ||
<!-- TODO: per-flag badge https://docs.codecov.io/docs/flags#section-flag-badges-and-graphs --> | ||
[![codecov](https://codecov.io/gh/slackapi/node-slack-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/slackapi/node-slack-sdk) | ||
<!-- TODO: npm versions with scoped packages: https://github.com/rvagg/nodei.co/issues/24 --> | ||
The `@slack/web-api` package contains a simple, convenient, and configurable HTTP client for making requests to Slack's | ||
@@ -9,0 +4,0 @@ [Web API](https://api.slack.com/web). Use it in your app to call any of the over 130 |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
854032
990
12366
1
389
2
+ Added@slack/logger@3.0.0(transitive)
+ Added@slack/types@2.14.0(transitive)
- Removed@slack/logger@2.0.0(transitive)
- Removed@slack/types@1.10.0(transitive)
Updated@slack/logger@^3.0.0
Updated@slack/types@^2.0.0