Giter VIP home page Giter VIP logo

deno-slack-api's People

Contributors

aishwarya-chauhan avatar anabulsi avatar btoo avatar chris-skud avatar cyungslack avatar dependabot[bot] avatar filmaj avatar jmplexi avatar lucasmichot avatar mcodik avatar rrreeeyyy avatar ryu-727 avatar sbarksdale97 avatar selfcontained avatar seratch avatar shapirone avatar srajiang avatar stevengill avatar uhunnyslack avatar williambergamin avatar wongjas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deno-slack-api's Issues

[FEATURE] Retry requests if "tls handshake eof" error detected

I have a workflow that runs daily, haven't made changes to it for some time. Got this error today. Maybe a hiccup on the backend?

2023-11-13 08:00:50 [info] [Fn060X3USBNZ] (Trace=Tr0657KMM4GN) Function output:
        Caught error from user supplied module: TypeError: error sending request for url (https://slack.com/api/functions.completeSuccess): error trying to connect: tls handshake eof
            at async mainFetch (ext:deno_fetch/26_fetch.js:277:12)
            at async fetch (ext:deno_fetch/26_fetch.js:504:7)
            at async BaseSlackAPIClient.apiCall (file:///opt/runtime.js:44:22)
            at async Object.RunFunction [as function_executed] (file:///opt/runtime.js:1709:29)
            at async DispatchPayload (file:///opt/runtime.js:1790:16)
            at async run (file:///opt/runtime.js:1857:18)
            at async serveHttp (file:///opt/runtime.js:1885:38)
        Error responding HTTP 500 to webapp request: Http: connection closed before message completed

[QUERY] How to use files.upload to upload a binary file

Question

How does one use files.upload? I tried

import { Readable } from "node:stream";

// ...

      // This is a `ReadableStream<Uint8Array>`...
      const audio = (await fetch("https://upload.wikimedia.org/wikipedia/commons/7/71/George_Gershwin_2.ogg")).body!;

      const response = await client.files.upload({
        channels: "<channel ID>",
        title: "Title",
        initial_comment: "Comment",
        // ...which I adapt into a Node.js `Readable` here
        file: Readable.from(audio),
        filename: "audio.ogg",
        filetype: "ogg",
      });

With this code, the API response is {"ok":false,"error":"no_file_data"}. I was expecting this to work since the files.upload JavaScript sample code, whose docs do similar, refer to something like the above as the legacy way to upload files. My use case is simple so I think I'm ok with a legacy way, as long as it works. Thanks!

Context

Environment

"deno-slack-sdk/": "https://deno.land/x/[email protected]/",
"deno-slack-api/": "https://deno.land/x/[email protected]/",

deno 1.40.5 (release, aarch64-apple-darwin)
v8 12.1.285.27
typescript 5.3.3

ProductName: macOS
ProductVersion: 14.2.1
BuildVersion: 23C71
Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

[FEATURE] Add `files.uploadV2` like the other Slack SDKs have

See https://slack.dev/node-slack-sdk/web-api#upload-a-file for docs on how this method works from a user perspective.

Here is the code from the node-slack-sdk for this method: https://github.com/slackapi/node-slack-sdk/blob/main/packages/web-api/src/file-upload.ts

@seratch has example code for deno-slack-sdk-based apps that use the above approach, more or less, that we could probably lift from: https://github.com/seratch/slack-timesheet/blob/412d9899c839fe24531a097ab0f1f68eb0513d2a/functions/internals/reports.ts#L549-L590

[FEATURE] Add proper types to clients

Description of the problem being solved

Please add types to the client. Seems like all but a very few of the SlackAPIClient methods are untyped. This makes the DX very poor.

Alternative solutions

Generate your own types based on the docs, but this can be inaccurate

Requirements

Have accurate types for all endpoints of the APIClient

Return Response instead of BaseResponse

Description

Currently the base BaseSlackClient defines the return type of apiCall and response as Promise<BaseResponse> which represents the json payload returned by the Slack API.

This is an issue since users may want to access more then just the json payload from the Response such as headers and status codes.

In the next major release apiCall and response should return some version of Promise<[Response](https://deno.com/deploy/docs/runtime-response)> instead. It will be a breaking change.

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

[FEATURE] expose block types

I'd like to have the block types exposed just like the NPM module:

For example with the nodejs module:

import type {
  ContextBlock,
  DividerBlock,
  HeaderBlock,
  SectionBlock,
} from 'npm:@slack/[email protected]'

I don't think the types are exposed in the deno module

Description of the problem being solved

Types for creating a chat request exposed.

[BUG] Can't access CLA assistant

Describe the bug

I can't sign CLA from Contributing guidelines. I found an error.

I want to contribute but I can't now.

Requirements (place an x in each of the [ ])**

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

To Reproduce

Access to https://cla-assistant.io/slackapi/deno-slack-api

Expected behavior

A developer can begin to sign CLA.

Screenshots

sc

Reproducible in:

deno-slack-api version:

Deno version:

OS version(s):

Additional context

Add any other context about the problem here.

Potential typing issue with datastore API

Need to reproduce as a first step!

But, as reported in a feedback session by a community developer, with the following datastore:

export const OldestCodeReviewDatastore = DefineDatastore({
  name: 'code_review_datastore',
  attributes: {
    id: {
      type: Schema.types.string
    },
    timestamp: {
      type: Schema.types.string
    }
  },
  primary_key: 'id'
})

This code apparently returns an any type.

async function getOldestReview(client: SlackAPIClient, channel: string) {
  const oldestReview = await client.apps.datastore.get<typeof OldestCodeReviewDatastore.definition>({
    datastore: 'code_review_datastore',
    id: 'oldest_review_' + channel
  })

  if (!oldestReview.ok) {
    console.log('Error during request apps.datastore.get!', oldestReview)
    return '0'
  }

  return oldestReview?.item?.timestamp ?? '0'
}

[FEATURE] apiCall support other HTTP methods

Description

Now, apiCall() only supports POST method.

method: "POST",

But Slack API has other HTTP methods.
So apiCall needs to support other HTTP methods.

Suggestion

  1. Add apiCallWithHTTPMethods()
  async apiCallWithHTTPMethods(
    http_methods: string,
    method: string,
    data: SlackAPIMethodArgs = {},
  ): Promise<BaseResponse> {
  }
  1. Add apiPostCall(), apiGetCall(), apiDeleteCall() and more

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.