From 98a706f80ad736ce8ab0cb99c55af89448a1e6e4 Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Tue, 3 Oct 2023 16:52:05 -0400 Subject: [PATCH 1/5] @slack/web-api: prep for next major release. bump min node to v18. cleaning up the readme. remove no longer used codecov and deno build npm run scripts. update dependencies as much as possible. fix linter errors. remove a test that is no longer applicable with new axios. --- packages/web-api/README.md | 19 +--- packages/web-api/package.json | 65 ++++++----- packages/web-api/src/WebClient.spec.js | 15 --- packages/web-api/src/WebClient.ts | 7 +- packages/web-api/src/errors.ts | 8 +- packages/web-api/src/methods.ts | 148 ++++++++++++++++--------- packages/web-api/src/retry-policies.ts | 4 +- 7 files changed, 145 insertions(+), 121 deletions(-) diff --git a/packages/web-api/README.md b/packages/web-api/README.md index cf31dc993..5c18d10a9 100644 --- a/packages/web-api/README.md +++ b/packages/web-api/README.md @@ -6,27 +6,16 @@ The `@slack/web-api` package contains a simple, convenient, and configurable HTT ## Requirements -This package supports Node v14 and higher. It's highly recommended to use [the latest LTS version of +This package supports Node v18 and higher. It's highly recommended to use [the latest LTS version of node](https://github.com/nodejs/Release#release-schedule), and the documentation is written using syntax and features from that version. -This package also has experimental support for Deno v1.15.2 and higher, though not all features are supported at this -time. - ## Installation -### Node.js - ```shell $ npm install @slack/web-api ``` -### Deno - -```typescript -import { WebClient } from 'https://deno.land/x/slack_web_api/mod.js'; -``` - ## Usage @@ -394,6 +383,6 @@ If you get stuck, we're here to help. The following are the best ways to get ass * [Issue Tracker](http://github.com/slackapi/node-slack-sdk/issues) for questions, feature requests, bug reports and general discussion related to these packages. Try searching before you create a new issue. - * [Email us](mailto:developers@slack.com) in Slack developer support: `developers@slack.com` - * [Bot Developers Hangout](https://community.botkit.ai/): a Slack community for developers - building all types of bots. You can find the maintainers and users of these packages in **#sdk-node-slack-sdk**. + * [Email us](mailto:feedback@slack.com): `feedback@slack.com` + * [Community Slack](https://community.slack.com/): a Slack community for developers + building all kinds of Slack apps. You can find the maintainers and users of these packages in **#lang-javascript**. diff --git a/packages/web-api/package.json b/packages/web-api/package.json index 4699b2409..fc92bf02c 100644 --- a/packages/web-api/package.json +++ b/packages/web-api/package.json @@ -21,8 +21,8 @@ "dist/**/*" ], "engines": { - "node": ">= 12.13.0", - "npm": ">= 6.12.0" + "node": ">= 18", + "npm": ">= 8.6.0" }, "repository": "slackapi/node-slack-sdk", "homepage": "https://slack.dev/node-slack-sdk/web-api", @@ -37,51 +37,48 @@ "build": "npm run build:clean && tsc", "build:clean": "shx rm -rf ./dist ./coverage ./.nyc_output", "lint": "eslint --ext .ts src", - "test": "npm run lint && npm run build && npm run test:mocha && npm run test:types", - "test:mocha": "nyc mocha --config .mocharc.json src/*.spec.js", + "mocha": "mocha --config .mocharc.json src/*.spec.js", + "test": "npm run lint && npm run test:unit && npm run test:types", + "test:unit": "npm run build && nyc --reporter=text-summary npm run mocha", "test:types": "tsd", - "coverage": "codecov -F webapi --root=$PWD", "ref-docs:model": "api-extractor run", - "watch": "npx nodemon --watch 'src' --ext 'ts' --exec npm run build", - "build:deno": "esbuild --bundle --define:process.cwd=String --define:process.version='\"v1.15.2\"' --define:process.title='\"deno\"' --define:Buffer=dummy_buffer --inject:./deno-shims/buffer-shim.js --inject:./deno-shims/xhr-shim.js --target=esnext --format=esm --outfile=./mod.js src/index.ts" + "watch": "npx nodemon --watch 'src' --ext 'ts' --exec npm run build" }, "dependencies": { - "@slack/logger": "^3.0.0", - "@slack/types": "^2.8.0", - "@types/is-stream": "^1.1.0", - "@types/node": ">=12.0.0", - "axios": "^0.27.2", - "eventemitter3": "^3.1.0", - "form-data": "^2.5.0", + "@slack/logger": "^4.0.0", + "@slack/types": "^2.9.0", + "@types/node": ">=18.0.0", + "axios": "^1.5.1", + "eventemitter3": "^5.0.1", + "form-data": "^4.0.0", "is-electron": "2.2.2", - "is-stream": "^1.1.0", - "p-queue": "^6.6.1", - "p-retry": "^4.0.0" + "is-stream": "^2.0.0", + "p-queue": "^6.6.2", + "p-retry": "^4.6.1", + "retry": "^0.13.1" }, "devDependencies": { "@aoberoi/capture-console": "^1.1.0", - "@microsoft/api-extractor": "^7.3.4", - "@types/chai": "^4.1.7", - "@types/mocha": "^5.2.6", - "@typescript-eslint/eslint-plugin": "^4.4.1", - "@typescript-eslint/parser": "^4.4.0", + "@microsoft/api-extractor": "^7.38.0", + "@types/chai": "^4.3.5", + "@types/mocha": "^10.0.1", + "@typescript-eslint/eslint-plugin": "^6.4.1", + "@typescript-eslint/parser": "^6.4.0", "busboy": "^1.6.0", - "chai": "^4.2.0", - "codecov": "^3.2.0", - "esbuild": "^0.13.15", - "eslint": "^7.32.0", - "eslint-config-airbnb-base": "^14.2.1", - "eslint-config-airbnb-typescript": "^12.3.1", - "eslint-plugin-import": "^2.22.1", - "eslint-plugin-jsdoc": "^30.6.1", + "chai": "^4.3.8", + "eslint": "^8.47.0", + "eslint-config-airbnb-base": "^15.0.0", + "eslint-config-airbnb-typescript": "^17.1.0", + "eslint-plugin-import": "^2.28.1", + "eslint-plugin-jsdoc": "^46.5.0", "eslint-plugin-node": "^11.1.0", - "mocha": "^9.1.0", - "nock": "^13.2.6", + "mocha": "^10.2.0", + "nock": "^13.3.3", "nyc": "^15.1.0", "shelljs": "^0.8.3", "shx": "^0.3.2", - "sinon": "^7.2.7", - "source-map-support": "^0.5.10", + "sinon": "^15.2.0", + "source-map-support": "^0.5.21", "ts-node": "^10.8.1", "tsd": "0.29.0", "typescript": "^4.1" diff --git a/packages/web-api/src/WebClient.spec.js b/packages/web-api/src/WebClient.spec.js index a6dbd924b..2afcadc47 100644 --- a/packages/web-api/src/WebClient.spec.js +++ b/packages/web-api/src/WebClient.spec.js @@ -34,20 +34,6 @@ describe('WebClient', function () { assert.instanceOf(client, WebClient); assert.notExists(client.axios.defaults.headers.Authorization); }); - it('should not modify global defaults in axios', function () { - // https://github.com/slackapi/node-slack-sdk/issues/1037 - const client = new WebClient(); - - const globalDefault = axios.defaults.headers.post['Content-Type']; - // The axios.default's defaults should not be modified. - // Specifically, defaults.headers.post should be kept as-is - assert.exists(globalDefault); - - const instanceDefault = client.axios.defaults.headers.post['Content-Type']; - // WebClient intentionally removes the default Content-Type - // from the underlying AxiosInstance used for performing web API calls - assert.notExists(instanceDefault) - }); }); describe('Methods superclass', function () { @@ -149,7 +135,6 @@ describe('WebClient', function () { assert.equal(error.code, ErrorCode.RequestError); assert.equal(error.original.config.timeout, timeoutOverride); assert.equal(error.original.isAxiosError, true); - assert.equal(error.original.request.aborted, true); done(); } catch (err) { done(err); diff --git a/packages/web-api/src/WebClient.ts b/packages/web-api/src/WebClient.ts index d4cacd460..af8d9022b 100644 --- a/packages/web-api/src/WebClient.ts +++ b/packages/web-api/src/WebClient.ts @@ -200,6 +200,7 @@ export class WebClient extends Methods { this.axios = axios.create({ timeout, baseURL: slackApiUrl, + // eslint-disable-next-line @typescript-eslint/naming-convention headers: isElectron() ? headers : { 'User-Agent': getUserAgent(), ...headers }, httpAgent: agent, httpsAgent: agent, @@ -220,7 +221,6 @@ export class WebClient extends Methods { /** * Generic method for calling a Web API method - * * @param method - the Web API method to call {@link https://api.slack.com/methods} * @param options - options */ @@ -299,7 +299,6 @@ export class WebClient extends Methods { * The for-await-of syntax is part of ES2018. It is available natively in Node starting with v10.0.0. You may be able * to use it in earlier JavaScript runtimes by transpiling your source with a tool like Babel. However, the * transpiled code will likely sacrifice performance. - * * @param method - the cursor-paginated Web API method to call {@link https://api.slack.com/docs/pagination} * @param options - options * @param shouldStop - a predicate that is called with each page, and should return true when pagination can end. @@ -613,7 +612,6 @@ export class WebClient extends Methods { * a string, used when posting with a content-type of url-encoded. Or, it can be a readable stream, used * when the options contain a binary (a stream or a buffer) and the upload should be done with content-type * multipart/form-data. - * * @param options - arguments for the Web API method * @param headers - a mutable object representing the HTTP headers for the outgoing request */ @@ -781,7 +779,8 @@ export default WebClient; * @param pageSize - the maximum number of additional items to fetch in the next request. */ function paginationOptionsForNextPage( - previousResult: WebAPICallResult | undefined, pageSize: number, + previousResult: WebAPICallResult | undefined, + pageSize: number, ): CursorPaginationEnabled | undefined { if ( previousResult !== undefined && diff --git a/packages/web-api/src/errors.ts b/packages/web-api/src/errors.ts index 03e09734f..9e8e7b720 100644 --- a/packages/web-api/src/errors.ts +++ b/packages/web-api/src/errors.ts @@ -94,7 +94,13 @@ export function httpErrorFromResponse(response: AxiosResponse): WebAPIHTTPError ) as Partial; error.statusCode = response.status; error.statusMessage = response.statusText; - error.headers = response.headers; + const nonNullHeaders: Record = {}; + Object.keys(response.headers).forEach((k) => { + if (k && response.headers[k]) { + nonNullHeaders[k] = response.headers[k]; + } + }); + error.headers = nonNullHeaders; error.body = response.data; return (error as WebAPIHTTPError); } diff --git a/packages/web-api/src/methods.ts b/packages/web-api/src/methods.ts index 71c3090b4..8ae345a49 100644 --- a/packages/web-api/src/methods.ts +++ b/packages/web-api/src/methods.ts @@ -317,73 +317,88 @@ export abstract class Methods extends EventEmitter { bulkMove: bindApiCall(this, 'admin.conversations.bulkMove'), convertToPrivate: bindApiCall( - this, 'admin.conversations.convertToPrivate', + this, + 'admin.conversations.convertToPrivate', ), convertToPublic: bindApiCall( - this, 'admin.conversations.convertToPublic', + this, + 'admin.conversations.convertToPublic', ), create: bindApiCall(this, 'admin.conversations.create'), delete: bindApiCall(this, 'admin.conversations.delete'), disconnectShared: bindApiCall( - this, 'admin.conversations.disconnectShared', + this, + 'admin.conversations.disconnectShared', ), ekm: { listOriginalConnectedChannelInfo: bindApiCall( - this, 'admin.conversations.ekm.listOriginalConnectedChannelInfo', + this, + 'admin.conversations.ekm.listOriginalConnectedChannelInfo', ), }, getConversationPrefs: bindApiCall( - this, 'admin.conversations.getConversationPrefs', + this, + 'admin.conversations.getConversationPrefs', ), getTeams: bindApiCall( - this, 'admin.conversations.getTeams', + this, + 'admin.conversations.getTeams', ), invite: bindApiCall(this, 'admin.conversations.invite'), rename: bindApiCall(this, 'admin.conversations.rename'), restrictAccess: { addGroup: bindApiCall( - this, 'admin.conversations.restrictAccess.addGroup', + this, + 'admin.conversations.restrictAccess.addGroup', ), listGroups: bindApiCall( - this, 'admin.conversations.restrictAccess.listGroups', + this, + 'admin.conversations.restrictAccess.listGroups', ), removeGroup: bindApiCall( - this, 'admin.conversations.restrictAccess.removeGroup', + this, + 'admin.conversations.restrictAccess.removeGroup', ), }, getCustomRetention: bindApiCall( - this, 'admin.conversations.getCustomRetention', + this, + 'admin.conversations.getCustomRetention', ), setCustomRetention: bindApiCall( - this, 'admin.conversations.setCustomRetention', + this, + 'admin.conversations.setCustomRetention', ), removeCustomRetention: bindApiCall( - this, 'admin.conversations.removeCustomRetention', + this, + 'admin.conversations.removeCustomRetention', ), lookup: bindApiCall(this, 'admin.conversations.lookup'), search: bindApiCall(this, 'admin.conversations.search'), setConversationPrefs: bindApiCall( - this, 'admin.conversations.setConversationPrefs', + this, + 'admin.conversations.setConversationPrefs', ), setTeams: bindApiCall( - this, 'admin.conversations.setTeams', + this, + 'admin.conversations.setTeams', ), unarchive: bindApiCall( - this, 'admin.conversations.unarchive', + this, + 'admin.conversations.unarchive', ), }, emoji: { @@ -402,16 +417,19 @@ export abstract class Methods extends EventEmitter { }, inviteRequests: { approve: bindApiCall( - this, 'admin.inviteRequests.approve', + this, + 'admin.inviteRequests.approve', ), approved: { list: bindApiCall( - this, 'admin.inviteRequests.approved.list', + this, + 'admin.inviteRequests.approved.list', ), }, denied: { list: bindApiCall( - this, 'admin.inviteRequests.denied.list', + this, + 'admin.inviteRequests.denied.list', ), }, deny: bindApiCall(this, 'admin.inviteRequests.deny'), @@ -430,22 +448,27 @@ export abstract class Methods extends EventEmitter { info: bindApiCall(this, 'admin.teams.settings.info'), setDefaultChannels: bindApiCall( - this, 'admin.teams.settings.setDefaultChannels', + this, + 'admin.teams.settings.setDefaultChannels', ), setDescription: bindApiCall( - this, 'admin.teams.settings.setDescription', + this, + 'admin.teams.settings.setDescription', ), setDiscoverability: bindApiCall( - this, 'admin.teams.settings.setDiscoverability', + this, + 'admin.teams.settings.setDiscoverability', ), setIcon: bindApiCall( - this, 'admin.teams.settings.setIcon', + this, + 'admin.teams.settings.setIcon', ), setName: bindApiCall( - this, 'admin.teams.settings.setName', + this, + 'admin.teams.settings.setName', ), }, }, @@ -456,16 +479,20 @@ export abstract class Methods extends EventEmitter { }, usergroups: { addChannels: bindApiCall( - this, 'admin.usergroups.addChannels', + this, + 'admin.usergroups.addChannels', ), addTeams: bindApiCall( - this, 'admin.usergroups.addTeams', + this, + 'admin.usergroups.addTeams', ), listChannels: bindApiCall( - this, 'admin.usergroups.listChannels', + this, + 'admin.usergroups.listChannels', ), removeChannels: bindApiCall( - this, 'admin.usergroups.removeChannels', + this, + 'admin.usergroups.removeChannels', ), }, users: { @@ -478,33 +505,41 @@ export abstract class Methods extends EventEmitter { reset: bindApiCall(this, 'admin.users.session.reset'), resetBulk: bindApiCall(this, 'admin.users.session.resetBulk'), invalidate: bindApiCall( - this, 'admin.users.session.invalidate', + this, + 'admin.users.session.invalidate', ), getSettings: bindApiCall( - this, 'admin.users.session.getSettings', + this, + 'admin.users.session.getSettings', ), setSettings: bindApiCall( - this, 'admin.users.session.setSettings', + this, + 'admin.users.session.setSettings', ), clearSettings: bindApiCall( - this, 'admin.users.session.clearSettings', + this, + 'admin.users.session.clearSettings', ), }, unsupportedVersions: { export: bindApiCall( - this, 'admin.users.unsupportedVersions.export', + this, + 'admin.users.unsupportedVersions.export', ), }, setAdmin: bindApiCall(this, 'admin.users.setAdmin'), setExpiration: bindApiCall( - this, 'admin.users.setExpiration', + this, + 'admin.users.setExpiration', ), setOwner: bindApiCall( - this, 'admin.users.setOwner', + this, + 'admin.users.setOwner', ), setRegular: bindApiCall( - this, 'admin.users.setRegular', + this, + 'admin.users.setRegular', ), }, workflows: { @@ -531,7 +566,8 @@ export abstract class Methods extends EventEmitter { event: { authorizations: { list: bindApiCall( - this, 'apps.event.authorizations.list', + this, + 'apps.event.authorizations.list', ), }, }, @@ -577,12 +613,14 @@ export abstract class Methods extends EventEmitter { postEphemeral: bindApiCall(this, 'chat.postEphemeral'), postMessage: bindApiCall(this, 'chat.postMessage'), scheduleMessage: bindApiCall( - this, 'chat.scheduleMessage', + this, + 'chat.scheduleMessage', ), scheduledMessages: { list: bindApiCall( - this, 'chat.scheduledMessages.list', + this, + 'chat.scheduledMessages.list', ), }, unfurl: bindApiCall(this, 'chat.unfurl'), @@ -591,24 +629,28 @@ export abstract class Methods extends EventEmitter { public readonly conversations = { acceptSharedInvite: bindApiCall( - this, 'conversations.acceptSharedInvite', + this, + 'conversations.acceptSharedInvite', ), approveSharedInvite: bindApiCall( - this, 'conversations.approveSharedInvite', + this, + 'conversations.approveSharedInvite', ), archive: bindApiCall(this, 'conversations.archive'), close: bindApiCall(this, 'conversations.close'), create: bindApiCall(this, 'conversations.create'), declineSharedInvite: bindApiCall( - this, 'conversations.declineSharedInvite', + this, + 'conversations.declineSharedInvite', ), history: bindApiCall(this, 'conversations.history'), info: bindApiCall(this, 'conversations.info'), invite: bindApiCall(this, 'conversations.invite'), inviteShared: bindApiCall( - this, 'conversations.inviteShared', + this, + 'conversations.inviteShared', ), join: bindApiCall(this, 'conversations.join'), kick: bindApiCall(this, 'conversations.kick'), @@ -616,7 +658,8 @@ export abstract class Methods extends EventEmitter { list: bindApiCall(this, 'conversations.list'), listConnectInvites: bindApiCall( - this, 'conversations.listConnectInvites', + this, + 'conversations.listConnectInvites', ), mark: bindApiCall(this, 'conversations.mark'), members: bindApiCall(this, 'conversations.members'), @@ -626,10 +669,12 @@ export abstract class Methods extends EventEmitter { setPurpose: bindApiCall(this, 'conversations.setPurpose'), setTopic: bindApiCall( - this, 'conversations.setTopic', + this, + 'conversations.setTopic', ), unarchive: bindApiCall( - this, 'conversations.unarchive', + this, + 'conversations.unarchive', ), }; @@ -770,10 +815,12 @@ export abstract class Methods extends EventEmitter { update: bindApiCall(this, 'usergroups.update'), users: { list: bindApiCall( - this, 'usergroups.users.list', + this, + 'usergroups.users.list', ), update: bindApiCall( - this, 'usergroups.users.update', + this, + 'usergroups.users.update', ), }, }; @@ -803,7 +850,8 @@ export abstract class Methods extends EventEmitter { public readonly workflows = { stepCompleted: bindApiCall( - this, 'workflows.stepCompleted', + this, + 'workflows.stepCompleted', ), stepFailed: bindApiCall(this, 'workflows.stepFailed'), updateStep: bindApiCall(this, 'workflows.updateStep'), @@ -1869,7 +1917,7 @@ export interface FilesSharedPublicURLArguments extends WebAPICallOptions, TokenO } /** * Legacy files.upload API files upload arguments - * */ + */ export interface FilesUploadArguments extends FileUpload, WebAPICallOptions, TokenOverridable {} interface FileUpload { channels?: string; // comma-separated list of channels @@ -1914,7 +1962,7 @@ export interface FilesGetUploadURLExternalArguments extends WebAPICallOptions, T /** * Finishes an upload started with files.getUploadURLExternal. Method: * {@link https://api.slack.com/methods/files.completeUploadExternal files.completeUploadExternal} - * */ + */ export interface FilesCompleteUploadExternalArguments extends WebAPICallOptions, TokenOverridable { files: FileUploadComplete[]; channel_id?: string, // if omitted, file will be private diff --git a/packages/web-api/src/retry-policies.ts b/packages/web-api/src/retry-policies.ts index e49636e83..9e511e5d7 100644 --- a/packages/web-api/src/retry-policies.ts +++ b/packages/web-api/src/retry-policies.ts @@ -1,10 +1,10 @@ -import { Options } from 'p-retry'; +import { OperationOptions } from 'retry'; /** * Options to create retry policies. Extends from https://github.com/tim-kos/node-retry. */ // eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface RetryOptions extends Options { +export interface RetryOptions extends OperationOptions { } /** From 2eb31e3011352697b08d9bb9f0d456e196485f27 Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Wed, 4 Oct 2023 12:52:13 -0400 Subject: [PATCH 2/5] Remove WebAPICallOptions, replace where it is used with `Record`. Remove unneeded disabling of no-trailing-space rule. Replace use of `headers: any` in private `serializeApiCallOptions` method with `Record`. --- packages/web-api/src/WebClient.ts | 77 ++--- packages/web-api/src/index.ts | 1 - packages/web-api/src/methods.ts | 553 +++++++++++++++--------------- 3 files changed, 313 insertions(+), 318 deletions(-) diff --git a/packages/web-api/src/WebClient.ts b/packages/web-api/src/WebClient.ts index af8d9022b..76254c302 100644 --- a/packages/web-api/src/WebClient.ts +++ b/packages/web-api/src/WebClient.ts @@ -64,10 +64,6 @@ export enum WebClientEvent { RATE_LIMITED = 'rate_limited', } -export interface WebAPICallOptions { - [argument: string]: unknown; -} - export interface WebAPICallResult { ok: boolean; error?: string; @@ -224,7 +220,7 @@ export class WebClient extends Methods { * @param method - the Web API method to call {@link https://api.slack.com/methods} * @param options - options */ - public async apiCall(method: string, options: WebAPICallOptions = {}): Promise { + public async apiCall(method: string, options: Record = {}): Promise { this.logger.debug(`apiCall('${method}') start`); warnDeprecations(method, this.logger); @@ -304,21 +300,21 @@ export class WebClient extends Methods { * @param shouldStop - a predicate that is called with each page, and should return true when pagination can end. * @param reduce - a callback that can be used to accumulate a value that the return promise is resolved to */ - public paginate(method: string, options?: WebAPICallOptions): AsyncIterable; + public paginate(method: string, options?: Record): AsyncIterable; public paginate( method: string, - options: WebAPICallOptions, + options: Record, shouldStop: PaginatePredicate, ): Promise; public paginate>( method: string, - options: WebAPICallOptions, + options: Record, shouldStop: PaginatePredicate, reduce?: PageReducer, ): Promise; public paginate>( method: string, - options?: WebAPICallOptions, + options?: Record, shouldStop?: PaginatePredicate, reduce?: PageReducer, ): (Promise | AsyncIterable) { @@ -394,19 +390,18 @@ export class WebClient extends Methods { })(); } - /* eslint-disable no-trailing-spaces */ /** * This wrapper method provides an easy way to upload files using the following endpoints: - * + * * **#1**: For each file submitted with this method, submit filenames * and file metadata to {@link https://api.slack.com/methods/files.getUploadURLExternal files.getUploadURLExternal} to request a URL to * which to send the file data to and an id for the file - * + * * **#2**: for each returned file `upload_url`, upload corresponding file to * URLs returned from step 1 (e.g. https://files.slack.com/upload/v1/...\") - * + * * **#3**: Complete uploads {@link https://api.slack.com/methods/files.completeUploadExternal files.completeUploadExternal} - * + * * **#4**: Unless `request_file_info` set to false, call {@link https://api.slack.com/methods/files.info files.info} for * each file uploaded and returns that data. Requires that your app have `files:read` scope. * @param options @@ -427,8 +422,8 @@ export class WebClient extends Methods { // 3 const completion = await this.completeFileUploads(fileUploads); - - // 4 + + // 4 let res = completion; if (options.request_file_info ?? true) { res = await this.getFileInfo(fileUploads); @@ -464,7 +459,7 @@ export class WebClient extends Methods { * @returns */ private async completeFileUploads(fileUploads: FileUploadV2Job[]): - Promise> { + Promise> { const toComplete: FilesCompleteUploadExternalArguments[] = Object.values(getAllFileUploadsToComplete(fileUploads)); return Promise.all( toComplete.map((job: FilesCompleteUploadExternalArguments) => this.files.completeUploadExternal(job)), @@ -506,10 +501,10 @@ export class WebClient extends Methods { }, headers); if (uploadRes.status !== 200) { return Promise.reject(Error(`Failed to upload file (id:${file_id}, filename: ${filename})`)); - } + } const returnData = { ok: true, body: uploadRes.data } as WebAPICallResult; return Promise.resolve(returnData); - } + } return Promise.reject(Error(`No upload url found for file (id: ${file_id}, filename: ${filename}`)); })); } @@ -525,7 +520,7 @@ export class WebClient extends Methods { if (options.file || options.content) { fileUploads.push(await getFileUploadJob(options, this.logger)); } - + // add multiple files data when file_uploads is supplied if (options.file_uploads) { fileUploads = fileUploads.concat(await getMultipleFileUploadJobs(options, this.logger)); @@ -615,8 +610,8 @@ export class WebClient extends Methods { * @param options - arguments for the Web API method * @param headers - a mutable object representing the HTTP headers for the outgoing request */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - private serializeApiCallOptions(options: WebAPICallOptions, headers?: any): string | Readable { + private serializeApiCallOptions(options: Record, headers?: Record): string | + Readable { // The following operation both flattens complex objects into a JSON-encoded strings and searches the values for // binary content let containsBinaryData: boolean = false; @@ -669,18 +664,20 @@ export class WebClient extends Methods { }, new FormData(), ); - // Copying FormData-generated headers into headers param - // not reassigning to headers param since it is passed by reference and behaves as an inout param - Object.entries(form.getHeaders()).forEach(([header, value]) => { - // eslint-disable-next-line no-param-reassign - headers[header] = value; - }); + if (headers) { + // Copying FormData-generated headers into headers param + // not reassigning to headers param since it is passed by reference and behaves as an inout param + Object.entries(form.getHeaders()).forEach(([header, value]) => { + // eslint-disable-next-line no-param-reassign + headers[header] = value; + }); + } return form; } // Otherwise, a simple key-value object is returned // eslint-disable-next-line no-param-reassign - headers['Content-Type'] = 'application/x-www-form-urlencoded'; + if (headers) headers['Content-Type'] = 'application/x-www-form-urlencoded'; // eslint-disable-next-line @typescript-eslint/no-explicit-any const initialValue: { [key: string]: any; } = {}; return qsStringify(flattened.reduce( @@ -844,16 +841,16 @@ function warnDeprecations(method: string, logger: Logger): void { * @param logger instance of we clients logger * @param options arguments for the Web API method */ -function warnIfFallbackIsMissing(method: string, logger: Logger, options?: WebAPICallOptions): void { +function warnIfFallbackIsMissing(method: string, logger: Logger, options?: Record): void { const targetMethods = ['chat.postEphemeral', 'chat.postMessage', 'chat.scheduleMessage', 'chat.update']; const isTargetMethod = targetMethods.includes(method); - const hasAttachments = (args: WebAPICallOptions) => Array.isArray(args.attachments) && args.attachments.length; + const hasAttachments = (args: Record) => Array.isArray(args.attachments) && args.attachments.length; - const missingAttachmentFallbackDetected = (args: WebAPICallOptions) => Array.isArray(args.attachments) && + const missingAttachmentFallbackDetected = (args: Record) => Array.isArray(args.attachments) && args.attachments.some((attachment) => !attachment.fallback || attachment.fallback.trim() === ''); - const isEmptyText = (args: WebAPICallOptions) => args.text === undefined || args.text === null || args.text === ''; + const isEmptyText = (args: Record) => args.text === undefined || args.text === null || args.text === ''; const buildMissingTextWarning = () => `The top-level \`text\` argument is missing in the request payload for a ${method} call - ` + 'It\'s a best practice to always provide a `text` argument when posting a message. ' + @@ -881,23 +878,23 @@ function warnIfFallbackIsMissing(method: string, logger: Logger, options?: WebAP * @param logger instance of web clients logger * @param options arguments for the Web API method */ -function warnIfThreadTsIsNotString(method: string, logger: Logger, options?: WebAPICallOptions): void { +function warnIfThreadTsIsNotString(method: string, logger: Logger, options?: Record): void { const targetMethods = ['chat.postEphemeral', 'chat.postMessage', 'chat.scheduleMessage', 'files.upload']; const isTargetMethod = targetMethods.includes(method); - + if (isTargetMethod && options?.thread_ts !== undefined && typeof options?.thread_ts !== 'string') { logger.warn(buildThreadTsWarningMessage(method)); } } -export function buildThreadTsWarningMessage(method: string): string { +export function buildThreadTsWarningMessage(method: string): string { return `The given thread_ts value in the request payload for a ${method} call is a float value. We highly recommend using a string value instead.`; } /** * Takes an object and redacts specific items - * @param body - * @returns + * @param body + * @returns */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function redact(body: any): any { @@ -907,7 +904,7 @@ function redact(body: any): any { if (value === undefined || value === null) { return []; } - + let serializedValue = value; // redact possible tokens @@ -924,7 +921,7 @@ function redact(body: any): any { return [key, serializedValue]; }); - // return as object + // return as object // eslint-disable-next-line @typescript-eslint/no-explicit-any const initialValue: { [key: string]: any; } = {}; return flattened.reduce( diff --git a/packages/web-api/src/index.ts b/packages/web-api/src/index.ts index 2565c4952..202c930e2 100644 --- a/packages/web-api/src/index.ts +++ b/packages/web-api/src/index.ts @@ -3,7 +3,6 @@ export { WebClient, WebClientOptions, - WebAPICallOptions, WebAPICallResult, PageAccumulator, PageReducer, diff --git a/packages/web-api/src/methods.ts b/packages/web-api/src/methods.ts index 8ae345a49..cc3a011df 100644 --- a/packages/web-api/src/methods.ts +++ b/packages/web-api/src/methods.ts @@ -1,7 +1,7 @@ import { Stream } from 'stream'; import { Dialog, View, KnownBlock, Block, MessageAttachment, LinkUnfurls, CallUser, MessageMetadata } from '@slack/types'; import { EventEmitter } from 'eventemitter3'; -import { WebAPICallOptions, WebAPICallResult, WebClient, WebClientEvent } from './WebClient'; +import { WebAPICallResult, WebClient, WebClientEvent } from './WebClient'; import { AdminAnalyticsGetFileResponse, AdminAppsApproveResponse, @@ -234,7 +234,7 @@ import { /** * Binds a certain `method` and its arguments and result types to the `apiCall` method in `WebClient`. */ -function bindApiCall( +function bindApiCall( self: Methods, method: string, ): Method { @@ -243,7 +243,7 @@ function bindApiCall; } -function bindFilesUploadV2( +function bindFilesUploadV2( self: Methods, ): Method { return self.filesUploadV2.bind(self) as unknown as Method; @@ -270,8 +270,8 @@ export abstract class Methods extends EventEmitter { } } - public abstract apiCall(method: string, options?: WebAPICallOptions): Promise; - public abstract filesUploadV2(options?: WebAPICallOptions): Promise; + public abstract apiCall(method: string, options?: Record): Promise; + public abstract filesUploadV2(options: Record): Promise; public readonly admin = { analytics: { @@ -921,7 +921,7 @@ export abstract class Methods extends EventEmitter { * Generic method definition */ export default interface Method< - MethodArguments extends WebAPICallOptions, + MethodArguments, MethodResult extends WebAPICallResult = WebAPICallResult, > { (options?: MethodArguments): Promise; @@ -973,52 +973,52 @@ export interface TraditionalPagingEnabled { /* * `admin.*` */ -export interface AdminAnalyticsGetFileArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminAnalyticsGetFileArguments extends TokenOverridable { type: string; date?: string; metadata_only?: boolean; } -export interface AdminAppsApproveArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminAppsApproveArguments extends TokenOverridable { app_id?: string; request_id?: string; team_id?: string; } -export interface AdminAppsApprovedListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { +export interface AdminAppsApprovedListArguments extends TokenOverridable, CursorPaginationEnabled { team_id?: string; enterprise_id?: string; } -export interface AdminAppsClearResolutionArguments extends WebAPICallOptions { +export interface AdminAppsClearResolutionArguments { app_id: string; enterprise_id?: string; team_id?: string; } cursorPaginationEnabledMethods.add('admin.apps.approved.list'); -export interface AdminAppsRequestsCancelArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminAppsRequestsCancelArguments extends TokenOverridable { request_id: string; enterprise_id?: string; team_id?: string; } -export interface AdminAppsRequestsListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { +export interface AdminAppsRequestsListArguments extends TokenOverridable, CursorPaginationEnabled { team_id?: string; } cursorPaginationEnabledMethods.add('admin.apps.requests.list'); -export interface AdminAppsRestrictArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminAppsRestrictArguments extends TokenOverridable { app_id?: string; request_id?: string; team_id?: string; } -export interface AdminAppsRestrictedListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { +export interface AdminAppsRestrictedListArguments extends TokenOverridable, CursorPaginationEnabled { team_id?: string; enterprise_id?: string; } cursorPaginationEnabledMethods.add('admin.apps.restricted.list'); -export interface AdminAppsUninstallArguments extends WebAPICallOptions { +export interface AdminAppsUninstallArguments { app_id: string; enterprise_id?: string; team_ids?: string[]; } -export interface AdminAppsActivitiesListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { +export interface AdminAppsActivitiesListArguments extends TokenOverridable, CursorPaginationEnabled { app_id?: string; component_id?: string; component_type?: string; @@ -1032,138 +1032,138 @@ export interface AdminAppsActivitiesListArguments extends WebAPICallOptions, Tok trace_id?: string; } cursorPaginationEnabledMethods.add('admin.apps.activities.list'); -export interface AdminAppsConfigLookupArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminAppsConfigLookupArguments extends TokenOverridable { app_ids: string[]; } -export interface AdminAppsConfigSetArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminAppsConfigSetArguments extends TokenOverridable { app_id: string; domain_restrictions?: Record; workflow_auth_strategy?: string; } -export interface AdminAuthPolicyAssignEntitiesArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminAuthPolicyAssignEntitiesArguments extends TokenOverridable { entity_ids: string[]; entity_type: string; policy_name: string; } -export interface AdminAuthPolicyGetEntitiesArguments extends WebAPICallOptions, TokenOverridable, +export interface AdminAuthPolicyGetEntitiesArguments extends TokenOverridable, CursorPaginationEnabled { policy_name: string; entity_type?: string; } cursorPaginationEnabledMethods.add('admin.auth.policy.getEntities'); -export interface AdminAuthPolicyRemoveEntitiesArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminAuthPolicyRemoveEntitiesArguments extends TokenOverridable { entity_ids: string[]; entity_type: string; policy_name: string; } -export interface AdminBarriersCreateArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminBarriersCreateArguments extends TokenOverridable { barriered_from_usergroup_ids: string[]; primary_usergroup_id: string; restricted_subjects: string[]; } -export interface AdminBarriersDeleteArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminBarriersDeleteArguments extends TokenOverridable { barrier_id: string; } -export interface AdminBarriersListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { } +export interface AdminBarriersListArguments extends TokenOverridable, CursorPaginationEnabled { } cursorPaginationEnabledMethods.add('admin.barriers.list'); -export interface AdminBarriersUpdateArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminBarriersUpdateArguments extends TokenOverridable { barrier_id: string; barriered_from_usergroup_ids: string[]; primary_usergroup_id: string; restricted_subjects: string[]; } -export interface AdminConversationsArchiveArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsArchiveArguments extends TokenOverridable { channel_id: string; } -export interface AdminConversationsBulkArchiveArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsBulkArchiveArguments extends TokenOverridable { channel_ids: string[]; } -export interface AdminConversationsBulkDeleteArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsBulkDeleteArguments extends TokenOverridable { channel_ids: string[]; } -export interface AdminConversationsBulkMoveArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsBulkMoveArguments extends TokenOverridable { channel_ids: string[]; target_team_id: string; } -export interface AdminConversationsConvertToPrivateArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsConvertToPrivateArguments extends TokenOverridable { channel_id: string; } -export interface AdminConversationsConvertToPublicArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsConvertToPublicArguments extends TokenOverridable { channel_id: string; } -export interface AdminConversationsCreateArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsCreateArguments extends TokenOverridable { is_private: boolean; name: string; description?: string; org_wide?: boolean; team_id?: string; } -export interface AdminConversationsDeleteArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsDeleteArguments extends TokenOverridable { channel_id: string; } -export interface AdminConversationsDisconnectSharedArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsDisconnectSharedArguments extends TokenOverridable { channel_id: string; leaving_team_ids?: string[]; } export interface AdminConversationsLookupArguments - extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { + extends TokenOverridable, CursorPaginationEnabled { last_message_activity_before: number; team_ids: string[]; max_member_count?: number; } cursorPaginationEnabledMethods.add('admin.conversations.lookup'); export interface AdminConversationsEKMListOriginalConnectedChannelInfoArguments - extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { + extends TokenOverridable, CursorPaginationEnabled { channel_ids?: string[]; team_ids?: string[]; } cursorPaginationEnabledMethods.add('admin.conversations.ekm.listOriginalConnectedChannelInfo'); -export interface AdminConversationsGetConversationPrefsArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsGetConversationPrefsArguments extends TokenOverridable { channel_id: string; } export interface AdminConversationsGetTeamsArguments - extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { + extends TokenOverridable, CursorPaginationEnabled { channel_id: string; } cursorPaginationEnabledMethods.add('admin.conversations.getTeams'); -export interface AdminConversationsInviteArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsInviteArguments extends TokenOverridable { channel_id: string; user_ids: string[]; } -export interface AdminConversationsRenameArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsRenameArguments extends TokenOverridable { channel_id: string; name: string; } -export interface AdminConversationsRestrictAccessAddGroupArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsRestrictAccessAddGroupArguments extends TokenOverridable { channel_id: string; group_id: string; team_id?: string; } -export interface AdminConversationsRestrictAccessListGroupsArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsRestrictAccessListGroupsArguments extends TokenOverridable { channel_id: string; team_id?: string; } -export interface AdminConversationsRestrictAccessRemoveGroupArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsRestrictAccessRemoveGroupArguments extends TokenOverridable { channel_id: string; group_id: string; team_id: string; } -export interface AdminConversationsGetCustomRetentionArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsGetCustomRetentionArguments extends TokenOverridable { channel_id: string; } -export interface AdminConversationsSetCustomRetentionArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsSetCustomRetentionArguments extends TokenOverridable { channel_id: string; duration_days: number; } -export interface AdminConversationsRemoveCustomRetentionArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsRemoveCustomRetentionArguments extends TokenOverridable { channel_id: string; } export interface AdminConversationsSearchArguments - extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { + extends TokenOverridable, CursorPaginationEnabled { query?: string; search_channel_types?: string[]; sort?: 'relevant' | 'name' | 'member_count' | 'created'; @@ -1171,159 +1171,159 @@ export interface AdminConversationsSearchArguments team_ids?: string[]; } cursorPaginationEnabledMethods.add('admin.conversations.search'); -export interface AdminConversationsSetConversationPrefsArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsSetConversationPrefsArguments extends TokenOverridable { channel_id: string; prefs: Record; } -export interface AdminConversationsSetTeamsArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsSetTeamsArguments extends TokenOverridable { channel_id: string; team_id?: string; target_team_ids?: string[]; org_channel?: boolean; } -export interface AdminConversationsUnarchiveArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminConversationsUnarchiveArguments extends TokenOverridable { channel_id: string; } -export interface AdminEmojiAddArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminEmojiAddArguments extends TokenOverridable { name: string; url: string; } -export interface AdminEmojiAddAliasArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminEmojiAddAliasArguments extends TokenOverridable { name: string; alias_for: string; } -export interface AdminEmojiListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { } +export interface AdminEmojiListArguments extends TokenOverridable, CursorPaginationEnabled { } cursorPaginationEnabledMethods.add('admin.emoji.list'); -export interface AdminEmojiRemoveArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminEmojiRemoveArguments extends TokenOverridable { name: string; } -export interface AdminEmojiRenameArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminEmojiRenameArguments extends TokenOverridable { name: string; new_name: string; } -export interface AdminFunctionsListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { +export interface AdminFunctionsListArguments extends TokenOverridable, CursorPaginationEnabled { app_ids: string[]; team_id?: string; } export interface AdminFunctionsPermissionsLookupArguments - extends WebAPICallOptions, TokenOverridable { + extends TokenOverridable { function_ids: string[]; } -export interface AdminFunctionsPermissionsSetArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminFunctionsPermissionsSetArguments extends TokenOverridable { function_id: string; visibility: string; user_ids?: string[]; } export interface AdminInviteRequestsApproveArguments - extends WebAPICallOptions, TokenOverridable { + extends TokenOverridable { invite_request_id: string; team_id: string; } export interface AdminInviteRequestsApprovedListArguments - extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { + extends TokenOverridable, CursorPaginationEnabled { team_id: string; } cursorPaginationEnabledMethods.add('admin.inviteRequests.approved.list'); export interface AdminInviteRequestsDenyArguments - extends WebAPICallOptions, TokenOverridable { + extends TokenOverridable { invite_request_id: string; team_id: string; } export interface AdminInviteRequestsDeniedListArguments - extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { + extends TokenOverridable, CursorPaginationEnabled { team_id: string; } cursorPaginationEnabledMethods.add('admin.inviteRequests.denied.list'); export interface AdminInviteRequestsListArguments - extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { + extends TokenOverridable, CursorPaginationEnabled { team_id: string; } cursorPaginationEnabledMethods.add('admin.inviteRequests.list'); export interface AdminRolesAddAssignmentsArguments - extends WebAPICallOptions, TokenOverridable { + extends TokenOverridable { role_id: string; entity_ids: string[]; user_ids: string[]; } export interface AdminRolesListAssignmentsArguments - extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { + extends TokenOverridable, CursorPaginationEnabled { entity_ids?: string[]; role_ids?: string[]; sort_dir?: string; } cursorPaginationEnabledMethods.add('admin.roles.listAssignments'); export interface AdminRolesRemoveAssignmentsArguments - extends WebAPICallOptions, TokenOverridable { + extends TokenOverridable { role_id: string; entity_ids: string[]; user_ids: string[]; } cursorPaginationEnabledMethods.add('admin.inviteRequests.list'); -export interface AdminTeamsAdminsListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { +export interface AdminTeamsAdminsListArguments extends TokenOverridable, CursorPaginationEnabled { team_id: string; } cursorPaginationEnabledMethods.add('admin.teams.admins.list'); -export interface AdminTeamsCreateArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminTeamsCreateArguments extends TokenOverridable { team_domain: string; team_name: string; team_description?: string; team_discoverability?: string; } -export interface AdminTeamsListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { } +export interface AdminTeamsListArguments extends TokenOverridable, CursorPaginationEnabled { } cursorPaginationEnabledMethods.add('admin.teams.list'); -export interface AdminTeamsOwnersListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { +export interface AdminTeamsOwnersListArguments extends TokenOverridable, CursorPaginationEnabled { team_id: string; } cursorPaginationEnabledMethods.add('admin.teams.owners.list'); -export interface AdminTeamsSettingsInfoArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminTeamsSettingsInfoArguments extends TokenOverridable { team_id: string; } -export interface AdminTeamsSettingsSetDefaultChannelsArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminTeamsSettingsSetDefaultChannelsArguments extends TokenOverridable { team_id: string; channel_ids: string[]; } -export interface AdminTeamsSettingsSetDescriptionArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminTeamsSettingsSetDescriptionArguments extends TokenOverridable { team_id: string; description: string; } -export interface AdminTeamsSettingsSetDiscoverabilityArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminTeamsSettingsSetDiscoverabilityArguments extends TokenOverridable { team_id: string; discoverability: 'open' | 'invite_only' | 'closed' | 'unlisted'; } -export interface AdminTeamsSettingsSetIconArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminTeamsSettingsSetIconArguments extends TokenOverridable { team_id: string; image_url: string; } -export interface AdminTeamsSettingsSetNameArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminTeamsSettingsSetNameArguments extends TokenOverridable { team_id: string; name: string; } -export interface AdminUsergroupsAddChannelsArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminUsergroupsAddChannelsArguments extends TokenOverridable { usergroup_id: string; team_id?: string; channel_ids: string | string[]; } -export interface AdminUsergroupsAddTeamsArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminUsergroupsAddTeamsArguments extends TokenOverridable { usergroup_id: string; team_ids: string | string[]; auto_provision?: boolean; } -export interface AdminUsergroupsListChannelsArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminUsergroupsListChannelsArguments extends TokenOverridable { usergroup_id: string; include_num_members?: boolean; team_id?: string; } -export interface AdminUsergroupsRemoveChannelsArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminUsergroupsRemoveChannelsArguments extends TokenOverridable { usergroup_id: string; channel_ids: string | string[]; } -export interface AdminUsersAssignArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminUsersAssignArguments extends TokenOverridable { team_id: string; user_id: string; is_restricted?: boolean; is_ultra_restricted?: boolean; } -export interface AdminUsersInviteArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminUsersInviteArguments extends TokenOverridable { channel_ids: string; email: string; team_id: string; @@ -1335,83 +1335,83 @@ export interface AdminUsersInviteArguments extends WebAPICallOptions, TokenOverr real_name?: string; resend?: boolean; } -export interface AdminUsersListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { +export interface AdminUsersListArguments extends TokenOverridable, CursorPaginationEnabled { team_id: string; } cursorPaginationEnabledMethods.add('admin.users.list'); -export interface AdminUsersRemoveArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminUsersRemoveArguments extends TokenOverridable { team_id: string; user_id: string; } -export interface AdminUsersSetAdminArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminUsersSetAdminArguments extends TokenOverridable { team_id: string; user_id: string; } -export interface AdminUsersSetExpirationArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminUsersSetExpirationArguments extends TokenOverridable { team_id: string; user_id: string; expiration_ts: number; } -export interface AdminUsersSetOwnerArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminUsersSetOwnerArguments extends TokenOverridable { team_id: string; user_id: string; } -export interface AdminUsersSetRegularArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminUsersSetRegularArguments extends TokenOverridable { team_id: string; user_id: string; } cursorPaginationEnabledMethods.add('admin.users.session.list'); -export interface AdminUsersSessionListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { +export interface AdminUsersSessionListArguments extends TokenOverridable, CursorPaginationEnabled { user_id?: string; team_id?: string; } -export interface AdminUsersSessionResetArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminUsersSessionResetArguments extends TokenOverridable { user_id: string; mobile_only?: boolean; web_only?: boolean; } -export interface AdminUsersSessionResetBulkArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminUsersSessionResetBulkArguments extends TokenOverridable { user_ids: string[]; mobile_only?: boolean; web_only?: boolean; } -export interface AdminUsersSessionInvalidateArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminUsersSessionInvalidateArguments extends TokenOverridable { session_id: string; team_id: string; } -export interface AdminUsersSessionGetSettingsArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminUsersSessionGetSettingsArguments extends TokenOverridable { user_ids: string[]; } -export interface AdminUsersSessionSetSettingsArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminUsersSessionSetSettingsArguments extends TokenOverridable { user_ids: string[]; desktop_app_browser_quit?: boolean; duration?: number; } -export interface AdminUsersSessionClearSettingsArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminUsersSessionClearSettingsArguments extends TokenOverridable { user_ids: string[]; } -export interface AdminUsersUnsupportedVersionsExportArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminUsersUnsupportedVersionsExportArguments extends TokenOverridable { date_end_of_support?: number; date_sessions_started?: number; } export interface AdminWorkflowsCollaboratorsAddArguments - extends WebAPICallOptions, TokenOverridable { + extends TokenOverridable { collaborator_ids: string[]; workflow_ids: string[]; } export interface AdminWorkflowsCollaboratorsRemoveArguments - extends WebAPICallOptions, TokenOverridable { + extends TokenOverridable { collaborator_ids: string[]; workflow_ids: string[]; } export interface AdminWorkflowsPermissionsLookupArguments - extends WebAPICallOptions, TokenOverridable { + extends TokenOverridable { workflow_ids: string[]; max_workflow_triggers?: number; } -export interface AdminWorkflowsSearchArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { +export interface AdminWorkflowsSearchArguments extends TokenOverridable, CursorPaginationEnabled { app_id?: string; collaborator_ids?: string[]; no_collaborators?: boolean; @@ -1422,30 +1422,30 @@ export interface AdminWorkflowsSearchArguments extends WebAPICallOptions, TokenO source?: string; } cursorPaginationEnabledMethods.add('admin.worfklows.search'); -export interface AdminWorkflowsUnpublishArguments extends WebAPICallOptions, TokenOverridable { +export interface AdminWorkflowsUnpublishArguments extends TokenOverridable { workflow_ids: string[]; } /* * `api.*` */ // eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface APITestArguments extends WebAPICallOptions { } +export interface APITestArguments { } /* * `apps.*` */ // eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface AppsConnectionsOpenArguments extends WebAPICallOptions { +export interface AppsConnectionsOpenArguments { // currently the method page lists Client id and client secret as optional arguments // circle back here to see if they stay as optional or are removed } export interface AppsEventAuthorizationsListArguments - extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { + extends TokenOverridable, CursorPaginationEnabled { event_context: string; } cursorPaginationEnabledMethods.add('apps.event.authorizations.list'); -export interface AppsUninstallArguments extends WebAPICallOptions { +export interface AppsUninstallArguments { client_id: string; client_secret: string; } @@ -1453,19 +1453,19 @@ export interface AppsUninstallArguments extends WebAPICallOptions { /* * `auth.*` */ -export interface AuthRevokeArguments extends WebAPICallOptions, TokenOverridable { +export interface AuthRevokeArguments extends TokenOverridable { test?: boolean; } -export interface AuthTeamsListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { +export interface AuthTeamsListArguments extends TokenOverridable, CursorPaginationEnabled { include_icon?: boolean; } cursorPaginationEnabledMethods.add('auth.teams.list'); -export interface AuthTestArguments extends WebAPICallOptions, TokenOverridable { } +export interface AuthTestArguments extends TokenOverridable { } /* * `bots.*` */ -export interface BotsInfoArguments extends WebAPICallOptions, TokenOverridable { +export interface BotsInfoArguments extends TokenOverridable { bot?: string; team_id?: string; } @@ -1473,7 +1473,7 @@ export interface BotsInfoArguments extends WebAPICallOptions, TokenOverridable { /* * `bookmarks.*` */ -export interface BookmarksAddArguments extends WebAPICallOptions, TokenOverridable { +export interface BookmarksAddArguments extends TokenOverridable { channel_id: string; title: string; type: string; @@ -1483,7 +1483,7 @@ export interface BookmarksAddArguments extends WebAPICallOptions, TokenOverridab parent_id?: string; } -export interface BookmarksEditArguments extends WebAPICallOptions, TokenOverridable { +export interface BookmarksEditArguments extends TokenOverridable { bookmark_id: string; channel_id: string; emoji?: string; @@ -1491,11 +1491,11 @@ export interface BookmarksEditArguments extends WebAPICallOptions, TokenOverrida title?: string; } -export interface BookmarksListArguments extends WebAPICallOptions, TokenOverridable { +export interface BookmarksListArguments extends TokenOverridable { channel_id: string; } -export interface BookmarksRemoveArguments extends WebAPICallOptions, TokenOverridable { +export interface BookmarksRemoveArguments extends TokenOverridable { bookmark_id: string; channel_id: string; } @@ -1503,7 +1503,7 @@ export interface BookmarksRemoveArguments extends WebAPICallOptions, TokenOverri /* * `calls.*` */ -export interface CallsAddArguments extends WebAPICallOptions, TokenOverridable { +export interface CallsAddArguments extends TokenOverridable { external_unique_id: string; join_url: string; created_by?: string; @@ -1514,28 +1514,28 @@ export interface CallsAddArguments extends WebAPICallOptions, TokenOverridable { users?: CallUser[]; } -export interface CallsEndArguments extends WebAPICallOptions, TokenOverridable { +export interface CallsEndArguments extends TokenOverridable { id: string; duration?: number; } -export interface CallsInfoArguments extends WebAPICallOptions, TokenOverridable { +export interface CallsInfoArguments extends TokenOverridable { id: string; } -export interface CallsUpdateArguments extends WebAPICallOptions, TokenOverridable { +export interface CallsUpdateArguments extends TokenOverridable { id: string; join_url?: string; desktop_app_join_url?: string; title?: string; } -export interface CallsParticipantsAddArguments extends WebAPICallOptions, TokenOverridable { +export interface CallsParticipantsAddArguments extends TokenOverridable { id: string; users: CallUser[]; } -export interface CallsParticipantsRemoveArguments extends WebAPICallOptions, TokenOverridable { +export interface CallsParticipantsRemoveArguments extends TokenOverridable { id: string; users: CallUser[]; } @@ -1543,91 +1543,91 @@ export interface CallsParticipantsRemoveArguments extends WebAPICallOptions, Tok /* * `channels.*` */ -export interface ChannelsArchiveArguments extends WebAPICallOptions, TokenOverridable { +export interface ChannelsArchiveArguments extends TokenOverridable { channel: string; } -export interface ChannelsCreateArguments extends WebAPICallOptions, TokenOverridable { +export interface ChannelsCreateArguments extends TokenOverridable { name: string; validate?: boolean; team_id?: string; } -export interface ChannelsHistoryArguments extends WebAPICallOptions, TokenOverridable, TimelinePaginationEnabled { +export interface ChannelsHistoryArguments extends TokenOverridable, TimelinePaginationEnabled { channel: string; count?: number; unreads?: boolean; } -export interface ChannelsInfoArguments extends WebAPICallOptions, TokenOverridable, LocaleAware { +export interface ChannelsInfoArguments extends TokenOverridable, LocaleAware { channel: string; } -export interface ChannelsInviteArguments extends WebAPICallOptions, TokenOverridable { +export interface ChannelsInviteArguments extends TokenOverridable { channel: string; user: string; } -export interface ChannelsJoinArguments extends WebAPICallOptions, TokenOverridable { +export interface ChannelsJoinArguments extends TokenOverridable { name: string; validate?: boolean; } -export interface ChannelsKickArguments extends WebAPICallOptions, TokenOverridable { +export interface ChannelsKickArguments extends TokenOverridable { channel: string; user: string; } -export interface ChannelsLeaveArguments extends WebAPICallOptions, TokenOverridable { +export interface ChannelsLeaveArguments extends TokenOverridable { channel: string; } -export interface ChannelsListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { +export interface ChannelsListArguments extends TokenOverridable, CursorPaginationEnabled { exclude_archived?: boolean; exclude_members?: boolean; team_id?: string; } cursorPaginationEnabledMethods.add('channels.list'); -export interface ChannelsMarkArguments extends WebAPICallOptions, TokenOverridable { +export interface ChannelsMarkArguments extends TokenOverridable { channel: string; ts: string; } -export interface ChannelsRenameArguments extends WebAPICallOptions, TokenOverridable { +export interface ChannelsRenameArguments extends TokenOverridable { channel: string; name: string; validate?: boolean; } -export interface ChannelsRepliesArguments extends WebAPICallOptions, TokenOverridable { +export interface ChannelsRepliesArguments extends TokenOverridable { channel: string; thread_ts: string; } -export interface ChannelsSetPurposeArguments extends WebAPICallOptions, TokenOverridable { +export interface ChannelsSetPurposeArguments extends TokenOverridable { channel: string; purpose: string; } -export interface ChannelsSetTopicArguments extends WebAPICallOptions, TokenOverridable { +export interface ChannelsSetTopicArguments extends TokenOverridable { channel: string; topic: string; } -export interface ChannelsUnarchiveArguments extends WebAPICallOptions, TokenOverridable { +export interface ChannelsUnarchiveArguments extends TokenOverridable { channel: string; } /* * `chat.*` */ -export interface ChatDeleteArguments extends WebAPICallOptions, TokenOverridable { +export interface ChatDeleteArguments extends TokenOverridable { channel: string; ts: string; as_user?: boolean; } -export interface ChatDeleteScheduledMessageArguments extends WebAPICallOptions, TokenOverridable { +export interface ChatDeleteScheduledMessageArguments extends TokenOverridable { channel: string; scheduled_message_id: string; as_user?: boolean; } -export interface ChatGetPermalinkArguments extends WebAPICallOptions, TokenOverridable { +export interface ChatGetPermalinkArguments extends TokenOverridable { channel: string; message_ts: string; } -export interface ChatMeMessageArguments extends WebAPICallOptions, TokenOverridable { +export interface ChatMeMessageArguments extends TokenOverridable { channel: string; text: string; } -export interface ChatPostEphemeralArguments extends WebAPICallOptions, TokenOverridable { +export interface ChatPostEphemeralArguments extends TokenOverridable { channel: string; text?: string; user: string; @@ -1641,7 +1641,7 @@ export interface ChatPostEphemeralArguments extends WebAPICallOptions, TokenOver icon_url?: string; // if specified, as_user must be false username?: string; // if specified, as_user must be false } -export interface ChatPostMessageArguments extends WebAPICallOptions, TokenOverridable { +export interface ChatPostMessageArguments extends TokenOverridable { channel: string; text?: string; as_user?: boolean; @@ -1659,7 +1659,7 @@ export interface ChatPostMessageArguments extends WebAPICallOptions, TokenOverri unfurl_media?: boolean; username?: string; // if specified, as_user must be false } -export interface ChatScheduleMessageArguments extends WebAPICallOptions, TokenOverridable { +export interface ChatScheduleMessageArguments extends TokenOverridable { channel: string; text?: string; post_at: string | number; @@ -1675,7 +1675,7 @@ export interface ChatScheduleMessageArguments extends WebAPICallOptions, TokenOv unfurl_media?: boolean; team_id?: string; } -export interface ChatScheduledMessagesListArguments extends WebAPICallOptions, TokenOverridable, +export interface ChatScheduledMessagesListArguments extends TokenOverridable, CursorPaginationEnabled { channel: string; latest: number; @@ -1708,8 +1708,7 @@ interface SourceAndUnfurlIDArguments { */ unfurl_id: string; } -export type ChatUnfurlArguments = (ChannelAndTSArguments | SourceAndUnfurlIDArguments) & WebAPICallOptions -& TokenOverridable +export type ChatUnfurlArguments = (ChannelAndTSArguments | SourceAndUnfurlIDArguments) & TokenOverridable & { /** * @description URL-encoded JSON map with keys set to URLs featured in the the message, pointing to their unfurl @@ -1737,7 +1736,7 @@ export type ChatUnfurlArguments = (ChannelAndTSArguments | SourceAndUnfurlIDArgu */ user_auth_blocks?: (KnownBlock | Block)[]; }; -export interface ChatUpdateArguments extends WebAPICallOptions, TokenOverridable { +export interface ChatUpdateArguments extends TokenOverridable { channel: string; ts: string; as_user?: boolean; @@ -1754,7 +1753,7 @@ export interface ChatUpdateArguments extends WebAPICallOptions, TokenOverridable /* * `conversations.*` */ -export interface ConversationsAcceptSharedInviteArguments extends WebAPICallOptions, TokenOverridable { +export interface ConversationsAcceptSharedInviteArguments extends TokenOverridable { channel_name: string; channel_id?: string; free_trial_accepted?: boolean; @@ -1762,106 +1761,106 @@ export interface ConversationsAcceptSharedInviteArguments extends WebAPICallOpti is_private?: boolean; team_id?: string; } -export interface ConversationsApproveSharedInviteArguments extends WebAPICallOptions, TokenOverridable { +export interface ConversationsApproveSharedInviteArguments extends TokenOverridable { invite_id: string; target_team?: string; } -export interface ConversationsArchiveArguments extends WebAPICallOptions, TokenOverridable { +export interface ConversationsArchiveArguments extends TokenOverridable { channel: string; } -export interface ConversationsCloseArguments extends WebAPICallOptions, TokenOverridable { +export interface ConversationsCloseArguments extends TokenOverridable { channel: string; } -export interface ConversationsCreateArguments extends WebAPICallOptions, TokenOverridable { +export interface ConversationsCreateArguments extends TokenOverridable { name: string; is_private?: boolean; team_id?: string; } -export interface ConversationsDeclineSharedInviteArguments extends WebAPICallOptions, TokenOverridable { +export interface ConversationsDeclineSharedInviteArguments extends TokenOverridable { invite_id: string; target_team?: string; } -export interface ConversationsHistoryArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled, +export interface ConversationsHistoryArguments extends TokenOverridable, CursorPaginationEnabled, TimelinePaginationEnabled { channel: string; include_all_metadata?: boolean; } cursorPaginationEnabledMethods.add('conversations.history'); -export interface ConversationsInfoArguments extends WebAPICallOptions, TokenOverridable, LocaleAware { +export interface ConversationsInfoArguments extends TokenOverridable, LocaleAware { channel: string; include_num_members?: boolean; } -export interface ConversationsInviteArguments extends WebAPICallOptions, TokenOverridable { +export interface ConversationsInviteArguments extends TokenOverridable { channel: string; users: string; // comma-separated list of users } -export interface ConversationsInviteSharedArguments extends WebAPICallOptions, TokenOverridable { +export interface ConversationsInviteSharedArguments extends TokenOverridable { channel: string; emails?: string[]; user_ids?: string[]; } -export interface ConversationsJoinArguments extends WebAPICallOptions, TokenOverridable { +export interface ConversationsJoinArguments extends TokenOverridable { channel: string; } -export interface ConversationsKickArguments extends WebAPICallOptions, TokenOverridable { +export interface ConversationsKickArguments extends TokenOverridable { channel: string; user: string; } -export interface ConversationsLeaveArguments extends WebAPICallOptions, TokenOverridable { +export interface ConversationsLeaveArguments extends TokenOverridable { channel: string; } -export interface ConversationsListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { +export interface ConversationsListArguments extends TokenOverridable, CursorPaginationEnabled { exclude_archived?: boolean; types?: string; // comma-separated list of conversation types team_id?: string; } cursorPaginationEnabledMethods.add('conversations.list'); -export interface ConversationsListConnectInvitesArguments extends WebAPICallOptions, TokenOverridable { +export interface ConversationsListConnectInvitesArguments extends TokenOverridable { count?: number; cursor?: string; team_id?: string; } cursorPaginationEnabledMethods.add('conversations.listConnectInvites'); -export interface ConversationsMarkArguments extends WebAPICallOptions, TokenOverridable { +export interface ConversationsMarkArguments extends TokenOverridable { channel: string; ts: string; } -export interface ConversationsMembersArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { +export interface ConversationsMembersArguments extends TokenOverridable, CursorPaginationEnabled { channel: string; } cursorPaginationEnabledMethods.add('conversations.members'); -export interface ConversationsOpenArguments extends WebAPICallOptions, TokenOverridable { +export interface ConversationsOpenArguments extends TokenOverridable { channel?: string; users?: string; // comma-separated list of users return_im?: boolean; } -export interface ConversationsRenameArguments extends WebAPICallOptions, TokenOverridable { +export interface ConversationsRenameArguments extends TokenOverridable { channel: string; name: string; } -export interface ConversationsRepliesArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled, +export interface ConversationsRepliesArguments extends TokenOverridable, CursorPaginationEnabled, TimelinePaginationEnabled { channel: string; ts: string; include_all_metadata?: boolean; } cursorPaginationEnabledMethods.add('conversations.replies'); -export interface ConversationsSetPurposeArguments extends WebAPICallOptions, TokenOverridable { +export interface ConversationsSetPurposeArguments extends TokenOverridable { channel: string; purpose: string; } -export interface ConversationsSetTopicArguments extends WebAPICallOptions, TokenOverridable { +export interface ConversationsSetTopicArguments extends TokenOverridable { channel: string; topic: string; } -export interface ConversationsUnarchiveArguments extends WebAPICallOptions, TokenOverridable { +export interface ConversationsUnarchiveArguments extends TokenOverridable { channel: string; } /* * `dialog.*` */ -export interface DialogOpenArguments extends WebAPICallOptions, TokenOverridable { +export interface DialogOpenArguments extends TokenOverridable { trigger_id: string; dialog: Dialog; } @@ -1869,38 +1868,38 @@ export interface DialogOpenArguments extends WebAPICallOptions, TokenOverridable /* * `dnd.*` */ -export interface DndEndDndArguments extends WebAPICallOptions, TokenOverridable { } -export interface DndEndSnoozeArguments extends WebAPICallOptions, TokenOverridable { } -export interface DndInfoArguments extends WebAPICallOptions, TokenOverridable { +export interface DndEndDndArguments extends TokenOverridable { } +export interface DndEndSnoozeArguments extends TokenOverridable { } +export interface DndInfoArguments extends TokenOverridable { user: string; } -export interface DndSetSnoozeArguments extends WebAPICallOptions, TokenOverridable { +export interface DndSetSnoozeArguments extends TokenOverridable { num_minutes: number; } -export interface DndTeamInfoArguments extends WebAPICallOptions, TokenOverridable { +export interface DndTeamInfoArguments extends TokenOverridable { users?: string; // comma-separated list of users } /* * `emoji.*` */ -export interface EmojiListArguments extends WebAPICallOptions, TokenOverridable { +export interface EmojiListArguments extends TokenOverridable { include_categories?: boolean; } /* * `files.*` */ -export interface FilesDeleteArguments extends WebAPICallOptions, TokenOverridable { +export interface FilesDeleteArguments extends TokenOverridable { file: string; // file id } -export interface FilesInfoArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { +export interface FilesInfoArguments extends TokenOverridable, CursorPaginationEnabled { file: string; // file id count?: number; page?: number; } cursorPaginationEnabledMethods.add('files.info'); -export interface FilesListArguments extends WebAPICallOptions, TokenOverridable, TraditionalPagingEnabled { +export interface FilesListArguments extends TokenOverridable, TraditionalPagingEnabled { channel?: string; user?: string; ts_from?: string; @@ -1909,16 +1908,16 @@ export interface FilesListArguments extends WebAPICallOptions, TokenOverridable, show_files_hidden_by_limit?: boolean; team_id?: string; } -export interface FilesRevokePublicURLArguments extends WebAPICallOptions, TokenOverridable { +export interface FilesRevokePublicURLArguments extends TokenOverridable { file: string; // file id } -export interface FilesSharedPublicURLArguments extends WebAPICallOptions, TokenOverridable { +export interface FilesSharedPublicURLArguments extends TokenOverridable { file: string; // file id } /** * Legacy files.upload API files upload arguments */ -export interface FilesUploadArguments extends FileUpload, WebAPICallOptions, TokenOverridable {} +export interface FilesUploadArguments extends FileUpload, TokenOverridable {} interface FileUpload { channels?: string; // comma-separated list of channels content?: string; // if omitted, must provide `file` @@ -1930,7 +1929,7 @@ interface FileUpload { title?: string; } -export interface FilesUploadV2Arguments extends FileUploadV2, WebAPICallOptions, TokenOverridable { +export interface FilesUploadV2Arguments extends FileUploadV2, TokenOverridable { file_uploads?: Omit[]; request_file_info?: boolean; } @@ -1953,7 +1952,7 @@ export interface FileUploadV2Job extends FileUploadV2, * Gets a URL for an edge external file upload. Method: * {@link https://api.slack.com/methods/files.getUploadURLExternal files.getUploadURLExternal} */ -export interface FilesGetUploadURLExternalArguments extends WebAPICallOptions, TokenOverridable { +export interface FilesGetUploadURLExternalArguments extends TokenOverridable { filename: string; length: number; alt_text?: string; @@ -1963,7 +1962,7 @@ export interface FilesGetUploadURLExternalArguments extends WebAPICallOptions, T * Finishes an upload started with files.getUploadURLExternal. Method: * {@link https://api.slack.com/methods/files.completeUploadExternal files.completeUploadExternal} */ -export interface FilesCompleteUploadExternalArguments extends WebAPICallOptions, TokenOverridable { +export interface FilesCompleteUploadExternalArguments extends TokenOverridable { files: FileUploadComplete[]; channel_id?: string, // if omitted, file will be private initial_comment?: string, @@ -1973,23 +1972,23 @@ interface FileUploadComplete { id: string, // file id title?: string // filename } -export interface FilesCommentsDeleteArguments extends WebAPICallOptions, TokenOverridable { +export interface FilesCommentsDeleteArguments extends TokenOverridable { file: string; // file id id: string; // comment id } // either file or external_id is required -export interface FilesRemoteInfoArguments extends WebAPICallOptions, TokenOverridable { +export interface FilesRemoteInfoArguments extends TokenOverridable { // either one of the file or external_id arguments are required file?: string; external_id?: string; } -export interface FilesRemoteListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { +export interface FilesRemoteListArguments extends TokenOverridable, CursorPaginationEnabled { ts_from?: string; ts_to?: string; channel?: string; } cursorPaginationEnabledMethods.add('files.remote.list'); -export interface FilesRemoteAddArguments extends WebAPICallOptions, TokenOverridable { +export interface FilesRemoteAddArguments extends TokenOverridable { title: string; external_url: string; external_id: string; // a unique identifier for the file in your system @@ -1997,7 +1996,7 @@ export interface FilesRemoteAddArguments extends WebAPICallOptions, TokenOverrid preview_image?: Buffer | Stream; indexable_file_contents?: Buffer | Stream; } -export interface FilesRemoteUpdateArguments extends WebAPICallOptions, TokenOverridable { +export interface FilesRemoteUpdateArguments extends TokenOverridable { title?: string; external_url?: string; filetype?: string; // possible values (except for 'auto'): https://api.slack.com/types/file#file_types @@ -2008,12 +2007,12 @@ export interface FilesRemoteUpdateArguments extends WebAPICallOptions, TokenOver file?: string; external_id?: string; } -export interface FilesRemoteRemoveArguments extends WebAPICallOptions, TokenOverridable { +export interface FilesRemoteRemoveArguments extends TokenOverridable { // either one of the file or external_id arguments are required file?: string; external_id?: string; } -export interface FilesRemoteShareArguments extends WebAPICallOptions, TokenOverridable { +export interface FilesRemoteShareArguments extends TokenOverridable { channels: string; // comma-separated list of channel ids // either one of the file or external_id arguments are required @@ -2024,92 +2023,92 @@ export interface FilesRemoteShareArguments extends WebAPICallOptions, TokenOverr /* * `groups.*` */ -export interface GroupsArchiveArguments extends WebAPICallOptions, TokenOverridable { +export interface GroupsArchiveArguments extends TokenOverridable { channel: string; } -export interface GroupsCreateArguments extends WebAPICallOptions, TokenOverridable { +export interface GroupsCreateArguments extends TokenOverridable { name: string; validate?: boolean; team_id?: string; } -export interface GroupsCreateChildArguments extends WebAPICallOptions, TokenOverridable { +export interface GroupsCreateChildArguments extends TokenOverridable { channel: string; } -export interface GroupsHistoryArguments extends WebAPICallOptions, TokenOverridable, TimelinePaginationEnabled { +export interface GroupsHistoryArguments extends TokenOverridable, TimelinePaginationEnabled { channel: string; unreads?: boolean; count?: number; } -export interface GroupsInfoArguments extends WebAPICallOptions, TokenOverridable, LocaleAware { +export interface GroupsInfoArguments extends TokenOverridable, LocaleAware { channel: string; } -export interface GroupsInviteArguments extends WebAPICallOptions, TokenOverridable { +export interface GroupsInviteArguments extends TokenOverridable { channel: string; user: string; } -export interface GroupsKickArguments extends WebAPICallOptions, TokenOverridable { +export interface GroupsKickArguments extends TokenOverridable { channel: string; user: string; } -export interface GroupsLeaveArguments extends WebAPICallOptions, TokenOverridable { +export interface GroupsLeaveArguments extends TokenOverridable { channel: string; } -export interface GroupsListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { +export interface GroupsListArguments extends TokenOverridable, CursorPaginationEnabled { exclude_archived?: boolean; exclude_members?: boolean; team_id?: string; } cursorPaginationEnabledMethods.add('groups.list'); -export interface GroupsMarkArguments extends WebAPICallOptions, TokenOverridable { +export interface GroupsMarkArguments extends TokenOverridable { channel: string; ts: string; } -export interface GroupsOpenArguments extends WebAPICallOptions, TokenOverridable { +export interface GroupsOpenArguments extends TokenOverridable { channel: string; } -export interface GroupsRenameArguments extends WebAPICallOptions, TokenOverridable { +export interface GroupsRenameArguments extends TokenOverridable { channel: string; name: string; validate?: boolean; } -export interface GroupsRepliesArguments extends WebAPICallOptions, TokenOverridable { +export interface GroupsRepliesArguments extends TokenOverridable { channel: string; thread_ts: boolean; } -export interface GroupsSetPurposeArguments extends WebAPICallOptions, TokenOverridable { +export interface GroupsSetPurposeArguments extends TokenOverridable { channel: string; purpose: string; } -export interface GroupsSetTopicArguments extends WebAPICallOptions, TokenOverridable { +export interface GroupsSetTopicArguments extends TokenOverridable { channel: string; topic: string; } -export interface GroupsUnarchiveArguments extends WebAPICallOptions, TokenOverridable { +export interface GroupsUnarchiveArguments extends TokenOverridable { channel: string; } /* * `im.*` */ -export interface IMCloseArguments extends WebAPICallOptions, TokenOverridable { +export interface IMCloseArguments extends TokenOverridable { channel: string; } -export interface IMHistoryArguments extends WebAPICallOptions, TokenOverridable, TimelinePaginationEnabled { +export interface IMHistoryArguments extends TokenOverridable, TimelinePaginationEnabled { channel: string; count?: number; unreads?: boolean; } -export interface IMListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { } +export interface IMListArguments extends TokenOverridable, CursorPaginationEnabled { } cursorPaginationEnabledMethods.add('im.list'); -export interface IMMarkArguments extends WebAPICallOptions, TokenOverridable { +export interface IMMarkArguments extends TokenOverridable { channel: string; ts: string; } -export interface IMOpenArguments extends WebAPICallOptions, TokenOverridable, LocaleAware { +export interface IMOpenArguments extends TokenOverridable, LocaleAware { user: string; return_im?: boolean; } -export interface IMRepliesArguments extends WebAPICallOptions, TokenOverridable { +export interface IMRepliesArguments extends TokenOverridable { channel: string; thread_ts?: string; } @@ -2117,7 +2116,7 @@ export interface IMRepliesArguments extends WebAPICallOptions, TokenOverridable /* * `migration.*` */ -export interface MigrationExchangeArguments extends WebAPICallOptions, TokenOverridable { +export interface MigrationExchangeArguments extends TokenOverridable { users: string; // comma-separated list of users to_old?: boolean; team_id?: string; @@ -2126,24 +2125,24 @@ export interface MigrationExchangeArguments extends WebAPICallOptions, TokenOver /* * `mpim.*` */ -export interface MPIMCloseArguments extends WebAPICallOptions, TokenOverridable { +export interface MPIMCloseArguments extends TokenOverridable { channel: string; } -export interface MPIMHistoryArguments extends WebAPICallOptions, TokenOverridable, TimelinePaginationEnabled { +export interface MPIMHistoryArguments extends TokenOverridable, TimelinePaginationEnabled { channel: string; count?: number; unreads?: boolean; } -export interface MPIMListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { } +export interface MPIMListArguments extends TokenOverridable, CursorPaginationEnabled { } cursorPaginationEnabledMethods.add('mpim.list'); -export interface MPIMMarkArguments extends WebAPICallOptions, TokenOverridable { +export interface MPIMMarkArguments extends TokenOverridable { channel: string; ts: string; } -export interface MPIMOpenArguments extends WebAPICallOptions, TokenOverridable { +export interface MPIMOpenArguments extends TokenOverridable { users: string; // comma-separated list of users } -export interface MPIMRepliesArguments extends WebAPICallOptions, TokenOverridable { +export interface MPIMRepliesArguments extends TokenOverridable { channel: string; thread_ts: string; } @@ -2151,14 +2150,14 @@ export interface MPIMRepliesArguments extends WebAPICallOptions, TokenOverridabl /* * `oauth.*` */ -export interface OAuthAccessArguments extends WebAPICallOptions { +export interface OAuthAccessArguments { client_id: string; client_secret: string; code: string; redirect_uri?: string; single_channel?: string; } -export interface OAuthV2AccessArguments extends WebAPICallOptions { +export interface OAuthV2AccessArguments { client_id: string; client_secret: string; code?: string; // not required for token rotation @@ -2167,7 +2166,7 @@ export interface OAuthV2AccessArguments extends WebAPICallOptions { refresh_token?: string; } -export interface OAuthV2ExchangeArguments extends WebAPICallOptions { +export interface OAuthV2ExchangeArguments { client_id: string; client_secret: string; } @@ -2175,7 +2174,7 @@ export interface OAuthV2ExchangeArguments extends WebAPICallOptions { /* * `openid.connect.*` */ -export interface OpenIDConnectTokenArguments extends WebAPICallOptions { +export interface OpenIDConnectTokenArguments { client_id: string; client_secret: string; code?: string; @@ -2185,20 +2184,20 @@ export interface OpenIDConnectTokenArguments extends WebAPICallOptions { } // eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface OpenIDConnectUserInfoArguments extends WebAPICallOptions { +export interface OpenIDConnectUserInfoArguments { } /* * `pins.*` */ -export interface PinsAddArguments extends WebAPICallOptions, TokenOverridable { +export interface PinsAddArguments extends TokenOverridable { channel: string; timestamp: string; } -export interface PinsListArguments extends WebAPICallOptions, TokenOverridable { +export interface PinsListArguments extends TokenOverridable { channel: string; } -export interface PinsRemoveArguments extends WebAPICallOptions, TokenOverridable { +export interface PinsRemoveArguments extends TokenOverridable { channel: string; timestamp: string; } @@ -2206,7 +2205,7 @@ export interface PinsRemoveArguments extends WebAPICallOptions, TokenOverridable /* * `reactions.*` */ -export interface ReactionsAddArguments extends WebAPICallOptions, TokenOverridable { +export interface ReactionsAddArguments extends TokenOverridable { name: string; // must supply one of: channel?: string; // paired with timestamp @@ -2214,7 +2213,7 @@ export interface ReactionsAddArguments extends WebAPICallOptions, TokenOverridab file?: string; // file id file_comment?: string; } -export interface ReactionsGetArguments extends WebAPICallOptions, TokenOverridable { +export interface ReactionsGetArguments extends TokenOverridable { full?: boolean; // must supply one of: channel?: string; // paired with timestamp @@ -2222,14 +2221,14 @@ export interface ReactionsGetArguments extends WebAPICallOptions, TokenOverridab file?: string; // file id file_comment?: string; } -export interface ReactionsListArguments extends WebAPICallOptions, TokenOverridable, TraditionalPagingEnabled, +export interface ReactionsListArguments extends TokenOverridable, TraditionalPagingEnabled, CursorPaginationEnabled { user?: string; full?: boolean; team_id?: string; } cursorPaginationEnabledMethods.add('reactions.list'); -export interface ReactionsRemoveArguments extends WebAPICallOptions, TokenOverridable { +export interface ReactionsRemoveArguments extends TokenOverridable { name: string; // must supply one of: channel?: string; // paired with timestamp @@ -2241,30 +2240,30 @@ export interface ReactionsRemoveArguments extends WebAPICallOptions, TokenOverri /* * `reminders.*` */ -export interface RemindersAddArguments extends WebAPICallOptions, TokenOverridable { +export interface RemindersAddArguments extends TokenOverridable { text: string; time: string | number; user?: string; } -export interface RemindersCompleteArguments extends WebAPICallOptions, TokenOverridable { +export interface RemindersCompleteArguments extends TokenOverridable { reminder: string; } -export interface RemindersDeleteArguments extends WebAPICallOptions, TokenOverridable { +export interface RemindersDeleteArguments extends TokenOverridable { reminder: string; } -export interface RemindersInfoArguments extends WebAPICallOptions, TokenOverridable { +export interface RemindersInfoArguments extends TokenOverridable { reminder: string; } -export interface RemindersListArguments extends WebAPICallOptions, TokenOverridable { } +export interface RemindersListArguments extends TokenOverridable { } /* * `rtm.*` */ -export interface RTMConnectArguments extends WebAPICallOptions, TokenOverridable { +export interface RTMConnectArguments extends TokenOverridable { batch_presence_aware?: boolean; presence_sub?: boolean; } -export interface RTMStartArguments extends WebAPICallOptions, TokenOverridable, LocaleAware { +export interface RTMStartArguments extends TokenOverridable, LocaleAware { batch_presence_aware?: boolean; mpim_aware?: boolean; no_latest?: '0' | '1'; @@ -2276,27 +2275,27 @@ export interface RTMStartArguments extends WebAPICallOptions, TokenOverridable, /* * `search.*` */ -export interface SearchAllArguments extends WebAPICallOptions, TokenOverridable, TraditionalPagingEnabled, +export interface SearchAllArguments extends TokenOverridable, TraditionalPagingEnabled, Searchable { } -export interface SearchFilesArguments extends WebAPICallOptions, TokenOverridable, TraditionalPagingEnabled, +export interface SearchFilesArguments extends TokenOverridable, TraditionalPagingEnabled, Searchable { } -export interface SearchMessagesArguments extends WebAPICallOptions, TokenOverridable, TraditionalPagingEnabled, +export interface SearchMessagesArguments extends TokenOverridable, TraditionalPagingEnabled, Searchable { } /* * `stars.*` */ -export interface StarsAddArguments extends WebAPICallOptions, TokenOverridable { +export interface StarsAddArguments extends TokenOverridable { // must supply one of: channel?: string; // paired with `timestamp` timestamp?: string; // paired with `channel` file?: string; // file id file_comment?: string; } -export interface StarsListArguments extends WebAPICallOptions, TokenOverridable, TraditionalPagingEnabled, +export interface StarsListArguments extends TokenOverridable, TraditionalPagingEnabled, CursorPaginationEnabled { } cursorPaginationEnabledMethods.add('stars.list'); -export interface StarsRemoveArguments extends WebAPICallOptions, TokenOverridable { +export interface StarsRemoveArguments extends TokenOverridable { // must supply one of: channel?: string; // paired with `timestamp` timestamp?: string; // paired with `channel` @@ -2307,7 +2306,7 @@ export interface StarsRemoveArguments extends WebAPICallOptions, TokenOverridabl /* * `team.*` */ -export interface TeamAccessLogsArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { +export interface TeamAccessLogsArguments extends TokenOverridable, CursorPaginationEnabled { before?: number; count?: number; page?: number; @@ -2315,19 +2314,19 @@ export interface TeamAccessLogsArguments extends WebAPICallOptions, TokenOverrid } cursorPaginationEnabledMethods.add('team.accessLogs'); -export interface TeamBillableInfoArguments extends WebAPICallOptions, TokenOverridable { +export interface TeamBillableInfoArguments extends TokenOverridable { user?: string; team_id?: string; } -export interface TeamBillingInfoArguments extends WebAPICallOptions, TokenOverridable { +export interface TeamBillingInfoArguments extends TokenOverridable { } -export interface TeamInfoArguments extends WebAPICallOptions, TokenOverridable { +export interface TeamInfoArguments extends TokenOverridable { // Team to get info on, if omitted, will return information about the current team. // Will only return team that the authenticated token is allowed to see through external shared channels team?: string; domain?: string; // available only for Enterprise Grid } -export interface TeamIntegrationLogsArguments extends WebAPICallOptions, TokenOverridable { +export interface TeamIntegrationLogsArguments extends TokenOverridable { app_id?: string; change_type?: string; // TODO: list types: 'x' | 'y' | 'z' count?: number; @@ -2336,37 +2335,37 @@ export interface TeamIntegrationLogsArguments extends WebAPICallOptions, TokenOv user?: string; team_id?: string; } -export interface TeamProfileGetArguments extends WebAPICallOptions, TokenOverridable { +export interface TeamProfileGetArguments extends TokenOverridable { visibility?: 'all' | 'visible' | 'hidden'; team_id?: string; } -export interface TeamPreferencesListArguments extends WebAPICallOptions, TokenOverridable { +export interface TeamPreferencesListArguments extends TokenOverridable { } /* * `usergroups.*` */ -export interface UsergroupsCreateArguments extends WebAPICallOptions, TokenOverridable { +export interface UsergroupsCreateArguments extends TokenOverridable { name: string; channels?: string; // comma-separated list of channels description?: string; handle?: string; include_count?: boolean; } -export interface UsergroupsDisableArguments extends WebAPICallOptions, TokenOverridable { +export interface UsergroupsDisableArguments extends TokenOverridable { usergroup: string; include_count?: boolean; } -export interface UsergroupsEnableArguments extends WebAPICallOptions, TokenOverridable { +export interface UsergroupsEnableArguments extends TokenOverridable { usergroup: string; include_count?: boolean; } -export interface UsergroupsListArguments extends WebAPICallOptions, TokenOverridable { +export interface UsergroupsListArguments extends TokenOverridable { include_count?: boolean; include_disabled?: boolean; include_users?: boolean; } -export interface UsergroupsUpdateArguments extends WebAPICallOptions, TokenOverridable { +export interface UsergroupsUpdateArguments extends TokenOverridable { usergroup: string; channels?: string; // comma-separated list of channels description?: string; @@ -2374,11 +2373,11 @@ export interface UsergroupsUpdateArguments extends WebAPICallOptions, TokenOverr include_count?: boolean; name?: string; } -export interface UsergroupsUsersListArguments extends WebAPICallOptions, TokenOverridable { +export interface UsergroupsUsersListArguments extends TokenOverridable { usergroup: string; include_disabled?: boolean; } -export interface UsergroupsUsersUpdateArguments extends WebAPICallOptions, TokenOverridable { +export interface UsergroupsUsersUpdateArguments extends TokenOverridable { usergroup: string; users: string; // comma-separated list of users include_count?: boolean; @@ -2387,66 +2386,66 @@ export interface UsergroupsUsersUpdateArguments extends WebAPICallOptions, Token /* * `users.*` */ -export interface UsersConversationsArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled { +export interface UsersConversationsArguments extends TokenOverridable, CursorPaginationEnabled { exclude_archived?: boolean; types?: string; // comma-separated list of conversation types user?: string; team_id?: string; } cursorPaginationEnabledMethods.add('users.conversations'); -export interface UsersDeletePhotoArguments extends WebAPICallOptions, TokenOverridable { } -export interface UsersGetPresenceArguments extends WebAPICallOptions, TokenOverridable { +export interface UsersDeletePhotoArguments extends TokenOverridable { } +export interface UsersGetPresenceArguments extends TokenOverridable { user: string; } -export interface UsersIdentityArguments extends WebAPICallOptions, TokenOverridable { } -export interface UsersInfoArguments extends WebAPICallOptions, TokenOverridable, LocaleAware { +export interface UsersIdentityArguments extends TokenOverridable { } +export interface UsersInfoArguments extends TokenOverridable, LocaleAware { user: string; } -export interface UsersListArguments extends WebAPICallOptions, TokenOverridable, CursorPaginationEnabled, LocaleAware { +export interface UsersListArguments extends TokenOverridable, CursorPaginationEnabled, LocaleAware { presence?: boolean; // deprecated, defaults to false team_id?: string; } cursorPaginationEnabledMethods.add('users.list'); -export interface UsersLookupByEmailArguments extends WebAPICallOptions, TokenOverridable { +export interface UsersLookupByEmailArguments extends TokenOverridable { email: string; } -export interface UsersSetPhotoArguments extends WebAPICallOptions, TokenOverridable { +export interface UsersSetPhotoArguments extends TokenOverridable { image: Buffer | Stream; crop_w?: number; crop_x?: number; crop_y?: number; } -export interface UsersSetPresenceArguments extends WebAPICallOptions, TokenOverridable { +export interface UsersSetPresenceArguments extends TokenOverridable { presence: 'auto' | 'away'; } -export interface UsersProfileGetArguments extends WebAPICallOptions, TokenOverridable { +export interface UsersProfileGetArguments extends TokenOverridable { include_labels?: boolean; user?: string; } -export interface UsersProfileSetArguments extends WebAPICallOptions, TokenOverridable { +export interface UsersProfileSetArguments extends TokenOverridable { profile?: string; // url-encoded json user?: string; name?: string; // usable if `profile` is not passed value?: string; // usable if `profile` is not passed } -export interface ViewsOpenArguments extends WebAPICallOptions, TokenOverridable { +export interface ViewsOpenArguments extends TokenOverridable { trigger_id: string; view: View; } -export interface ViewsPushArguments extends WebAPICallOptions, TokenOverridable { +export interface ViewsPushArguments extends TokenOverridable { trigger_id: string; view: View; } -export interface ViewsPublishArguments extends WebAPICallOptions, TokenOverridable { +export interface ViewsPublishArguments extends TokenOverridable { user_id: string; view: View; hash?: string; } -export interface ViewsUpdateArguments extends WebAPICallOptions, TokenOverridable { +export interface ViewsUpdateArguments extends TokenOverridable { view_id?: string; view: View; external_id?: string; @@ -2456,19 +2455,19 @@ export interface ViewsUpdateArguments extends WebAPICallOptions, TokenOverridabl /* * `workflows.*` */ -export interface WorkflowsStepCompletedArguments extends WebAPICallOptions, TokenOverridable { +export interface WorkflowsStepCompletedArguments extends TokenOverridable { workflow_step_execute_id: string; outputs?: Record; } -export interface WorkflowsStepFailedArguments extends WebAPICallOptions, TokenOverridable { +export interface WorkflowsStepFailedArguments extends TokenOverridable { workflow_step_execute_id: string; error: { message: string; }; } -export interface WorkflowsUpdateStepArguments extends WebAPICallOptions, TokenOverridable { +export interface WorkflowsUpdateStepArguments extends TokenOverridable { workflow_step_edit_id: string; step_image_url?: string; step_name?: string; From 73e19bc7e805bb1e6353f646b4727942ffeed4d2 Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Wed, 4 Oct 2023 13:02:04 -0400 Subject: [PATCH 3/5] @slack/web-api: Remove inclusion of arbitrary properties from WebAPICallResult. Tweak fileUploadV2 return type as a result. --- packages/web-api/src/WebClient.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/web-api/src/WebClient.ts b/packages/web-api/src/WebClient.ts index 76254c302..e97f1e388 100644 --- a/packages/web-api/src/WebClient.ts +++ b/packages/web-api/src/WebClient.ts @@ -78,7 +78,6 @@ export interface WebAPICallResult { // `chat.postMessage` returns an array of error messages (e.g., "messages": ["[ERROR] invalid_keys"]) messages?: string[]; }; - [key: string]: unknown; } // NOTE: should there be an async predicate? @@ -406,7 +405,9 @@ export class WebClient extends Methods { * each file uploaded and returns that data. Requires that your app have `files:read` scope. * @param options */ - public async filesUploadV2(options: FilesUploadV2Arguments): Promise { + public async filesUploadV2(options: FilesUploadV2Arguments): Promise< + WebAPICallResult & { files: FilesCompleteUploadExternalResponse[] | WebAPICallResult[] } + > { this.logger.debug('files.uploadV2() start'); // 1 const fileUploads = await this.getAllFileUploads(options); From 7edf1920185c3d94e8dedabcb4e88d224245d48b Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Wed, 4 Oct 2023 16:38:06 -0400 Subject: [PATCH 4/5] Remove optionality on abstract generic Method interface options arg, lines up behaviour with WebClient. --- packages/web-api/src/methods.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web-api/src/methods.ts b/packages/web-api/src/methods.ts index cc3a011df..d07d192f7 100644 --- a/packages/web-api/src/methods.ts +++ b/packages/web-api/src/methods.ts @@ -924,7 +924,7 @@ export default interface Method< MethodArguments, MethodResult extends WebAPICallResult = WebAPICallResult, > { - (options?: MethodArguments): Promise; + (options: MethodArguments): Promise; } /* From 95459e1aee681c69bf65b296669f9cb098246381 Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Wed, 4 Oct 2023 16:36:34 -0400 Subject: [PATCH 5/5] prototype using unions and intersections to model chat.postMessage arguments. --- packages/web-api/src/methods.ts | 171 ++++++++++++++++++++++++++++++-- 1 file changed, 160 insertions(+), 11 deletions(-) diff --git a/packages/web-api/src/methods.ts b/packages/web-api/src/methods.ts index d07d192f7..a56d773ef 100644 --- a/packages/web-api/src/methods.ts +++ b/packages/web-api/src/methods.ts @@ -1641,24 +1641,173 @@ export interface ChatPostEphemeralArguments extends TokenOverridable { icon_url?: string; // if specified, as_user must be false username?: string; // if specified, as_user must be false } -export interface ChatPostMessageArguments extends TokenOverridable { + +interface ChatPostMessageArgumentsBase extends TokenOverridable { + /** + * @description Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. + * @see {@link https://api.slack.com/methods/chat.postMessage#channels `chat.postMessage` Channels reference for more details}. + */ channel: string; - text?: string; - as_user?: boolean; - attachments?: MessageAttachment[]; - blocks?: (KnownBlock | Block)[]; - icon_emoji?: string; // if specified, as_user must be false - icon_url?: string; // if specified, as_user must be false - metadata?: MessageMetadata; + /** + * @description Find and link user groups. No longer supports linking individual users; use syntax shown in + * {@link https://api.slack.com/reference/surfaces/formatting#mentioning-users Mentioning Users} instead. + */ link_names?: boolean; + /** + * @description Attach metadata to your message. Metadata you post to Slack is accessible to any app or user who is a + * member of that workspace. + * @see {@link https://api.slack.com/metadata Message Metadata}. + */ + metadata?: MessageMetadata; + /** + * @description Disable Slack markup parsing by setting to `false`. Enabled by default. + */ mrkdwn?: boolean; + /** + * @description Change how messages are treated and formatted, depending on the contents of the message and the value + * of this property. + * @see {@link https://api.slack.com/methods/chat.postMessage#formatting `chat.postMessage` Formatting reference}. + */ parse?: 'full' | 'none'; - reply_broadcast?: boolean; // if specified, thread_ts must be set - thread_ts?: string; + /** + * @description Pass `true` to enable unfurling of primarily text-based content. + */ unfurl_links?: boolean; + /** + * @description Pass `false` to disable unfurling of media content. + */ unfurl_media?: boolean; - username?: string; // if specified, as_user must be false } + +/** + * @description `chat.postMessage` arguments where the `text` property captures the message contents. + */ +interface ChatPostMessageArgumentsTextBased extends ChatPostMessageArgumentsBase { + /** + * @description The formatted text of the message to be published. + */ + text: string; + attachments?: never; + blocks?: never; +} + +/** + * @description `chat.postMessage` arguments where the `attachments` property captures the message contents. + */ +interface ChatPostMessageArgumentsAttachmentsBased extends ChatPostMessageArgumentsBase { + /** + * @description The fallback text used in notifications. + */ + text?: string; + attachments: [MessageAttachment, ...MessageAttachment[]]; +} + +/** + * @description `chat.postMessage` arguments where the `blocks` property captures the message contents. + */ +interface ChatPostMessageArgumentsBlocksBased extends ChatPostMessageArgumentsBase { + /** + * @description The fallback text used in notifications. + */ + text?: string; + blocks: [(KnownBlock | Block), ...(KnownBlock | Block)[]]; +} + +type ChatPostMessageArgumentsContents = ChatPostMessageArgumentsTextBased | ChatPostMessageArgumentsAttachmentsBased | +ChatPostMessageArgumentsBlocksBased; + +interface ChatPostMessageArgumentsIdentityBase { + /** + * @description (Legacy) Pass `true` to post the message as the authed user instead of as a bot. Defaults to `false`. + * Can only be used by classic Slack apps. + * @see {@link https://api.slack.com/methods/chat.postMessage#legacy_authorship Legacy Concerns and Authorship when using `chat.postMessage`}. + */ + as_user?: boolean; // Legacy +} + +/** + * @description `chat.postMessage` arguments for specifying the message icon using a URL. + */ +interface ChatPostMessageArgumentsIconURL extends ChatPostMessageArgumentsIdentityBase { + as_user: false; + /** + * @description URL to an image to use as the icon for this message. + */ + icon_url: string; +} + +/** + * @description `chat.postMessage` arguments for specifying the message icon using an emoji. + */ +interface ChatPostMessageArgumentsIconEmoji extends ChatPostMessageArgumentsIdentityBase { + as_user: false; + /** + * @description Emoji to use as the icon for this message. Overrides `icon_url`. E.g. `:chart_with_upwards_trend:` + */ + icon_emoji: string; +} + +/** + * @description `chat.postMessage` arguments for specifying the message username. + */ +interface ChatPostMessageArgumentsUsername extends ChatPostMessageArgumentsIdentityBase { + as_user: false; + /** + * @description Set your bot's user name. + */ + username: string; +} + +type ChatPostMessageArgumentsIdentity = ChatPostMessageArgumentsIdentityBase | ChatPostMessageArgumentsIconEmoji | +ChatPostMessageArgumentsIconURL | ChatPostMessageArgumentsUsername; + +/** + * @description `chat.postMessage` arguments for specifying a thread reply, with optional conversation broadcast. + */ +interface ChatPostMessageArgumentsThreadReply { + thread_ts: string; + reply_broadcast?: boolean; +} + +/** + * @description `chat.postMessage` arguments for specifying a 'normal' message - not a thread reply - which will never + * have a `thread_ts`. + */ +interface ChatPostMessageArgumentsConversationMessage { + thread_ts?: never; + reply_broadcast?: never; +} + +type ChatPostMessageArgumentsType = ChatPostMessageArgumentsThreadReply | ChatPostMessageArgumentsConversationMessage; + +type ChatPostMessageArguments = + // Must provide one of the following to determine message contents + ChatPostMessageArgumentsContents & + // Controls the username/identity and icon display for the message + ChatPostMessageArgumentsIdentity & + // Controls whether a message is a thread reply or not + ChatPostMessageArgumentsType; + +const textOnly: ChatPostMessageArguments = { + channel: 'C1234', + text: 'hi', +}; +const attachments: ChatPostMessageArguments = { + channel: 'C1234', + attachments: [{}], + text: 'some fallback', +}; +const bs: ChatPostMessageArguments = { + channel: 'C1234', + blocks: [{ + type: '', + }], + thread_ts: '123', + reply_broadcast: true, + icon_url: '1234', +}; +console.log(textOnly, attachments, bs); + export interface ChatScheduleMessageArguments extends TokenOverridable { channel: string; text?: string;