useshortcut / shortcut-client-js Goto Github PK
View Code? Open in Web Editor NEWThe official JavaScript client library for the Shortcut (formerly Clubhouse) REST API.
Home Page: https://useshortcut.github.io/shortcut-client-js/
The official JavaScript client library for the Shortcut (formerly Clubhouse) REST API.
Home Page: https://useshortcut.github.io/shortcut-client-js/
In order to retrieve stories (https://github.com/clubhouse/clubhouse-lib/blob/master/src/index.js#L180) I need a project-public-id
, as noted in the REST API docs: https://clubhouse.io/api/rest/v2/#List-Stories.
Unfortunately, listProjects
, does not return this. How can I obtain the project-public-id
?
Currently, when adding or removing external links
, it does not notify the payload url.
I have a simple PR that can be reviewed / merged. Let me know how to get access. Thanks!
I was trying to figure out how to check if there's a clubhouse ticket already associated with a github issue.
SearchStories doesn't seem to work - if I give it a github issue ID, it returns lots of unrelated results
Is there a recommended way to do this?
Hi!
Do you plan a new release soon?
There are some useful bug fixes, already merged in main branch (for months).
Thank you 🙏
I'm looking to associate pull requests against stories (through a custom integration, because I'd like some extra control over my workflow).
Currently, it doesn't appear like the API exposes the following, which I think are necessary in order to support that:
POST /repositories
?)POST /stories/<id>/branches
?)Are those endpoints available (even if just in an unsupported way)? I'm totally willing to poke around until I figure out the endpoints 👍
Currently, the README is very sparse and doesn't provide too much information on how to get started.
We should improve this by adding information in the following outline:
# Clubhouse JavaScript SDK
or something like that)
To get a Member, the API requires an org-public-id
parameter: (https://shortcut.com/api/rest/v3#Get-Member).
However, I don't see anywhere in the API where an org ID is returned, and I'm not seeing where to get that ID from within the shortcut webapp (app.shortcut.com).
Any help would be appreciated!
Hey Clubhouse, just a heads up / possible documentation request.
I found that in order to actually use the fetch-everywhere
dependency, I had to add this to my webpack config:
plugins: [
...
new webpack.ProvidePlugin({
'fetch': 'fetch-everywhere'
}),
]
Without it, the fetch calls would fail in the browser. The fetch-everywhere docs don't mention this step either.
This might be obvious to someone who is less new to webpack projects than me, and if so, feel free to ignore. But I mention this in case you think it's worth adding to the readme for others. (Or if there's a better way to include fetch-everywhere in-browser.)
I wanted to use this library from Typescript and it seems the typings do not allow Clubhouse.create to be called like in the example in the README.
This is my work around:
import Clubhouse from 'clubhouse-lib';
import {create} from 'clubhouse-lib';
export function generateClubHouseReport(apiKey: string) {
const client = create(apiKey); // Compiles
const fail = Clubhouse.create(apiKey); // Does not
}
This doesn't seem intentional.
The API returns an "external_links" field on Story, but the Typescript type doesn't indicate this. Using ts-ignore allows clients to successfully access the data that is there.
I had some issues while trying to use the lib in the browser.
Both CRA configuration(webpack based) and a rollup based web config have issues with fetch-everywhere
.
It just doesn't work.
Do you want to support browsers with this lib, or you want to limit it to node.js?
Good news, everyone!
We heard you about missing endpoints and outdated types. We started this library based on our internal usages, especially for the mobile application. Unfortunately, we started moving to GraphQL and this library didn't receive all the attention it should and that's unfortunate. We want this library to follow closely our latest changes so we can all profit from this library and build awesome things with the Shortcut REST API.
So, we are working on a new and updated Swagger / OpenAPI schema that will expose our endpoints and their expected types. Then, from that Swagger schema, we rewrote entirely this library so we could generate a TypeScript client and all their associated entities. No more manual updates! 👏
The Swagger file will be available here (additional changes will land soon): https://shortcut.com/api/rest/v3#Swagger-OpenAPI-file.
We're still working on some tweaks, but we will soon be ready to publish a beta version of the complete rewrite as v1. clubhouse-lib
as formerly known.
👀 If you are curious and are not afraid of WIP, you can have a peek on next
branch.
On September 14th references to clubhouse.io will be deprecated. And on November 13th references to clubhouse.io will stop working. Instructions for migration: https://shortcut.com/api/rest/v3#Updating-your-application
I'm guessing this is on your internal roadmap, but just in-case it's not I filed this ticket :)
👋 Hi Shortcut team,
I am facing a CORS issue when using the @useshortcut/client
package with a valid token. I am able to hit your API successfully via Postman and Insomnia, but when using this package on CodeSandbox I get the following error.
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.app.shortcut.com/api/v3/projects. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
The CodeSandbox below was created to show the issue that I am facing.
🔗 https://codesandbox.io/s/useshortcut-client-cors-error-lkde01?file=/src/App.tsx
Relates to the follow-up of #86. It seems the field is deprecated and throws:
TypeError: story.external_tickets is not iterable
And it's no longer documented in the API (https://clubhouse.io/api/rest/v3/#Story), but it still shows up in the type.
Hello, it appears that fetch-everywhere
inhibits a vulnerable dependency, seeing that it has not been updated in a while, is there a replacement such as https://github.com/matthew-andrews/isomorphic-fetch that we can use? If not maybe we could submit a patch to fetch-everywhere
. Please advise.
I am getting a 400 Bad request for updateStory
in the following:
labels = await client.listLabels()
client.updateStory(story_id, { labels: [labels[0]] })
I was able to remove label by sending empty array labels: []
in params but I am not able to add a label
I tried passing the exact parameters as in API which is name, description, external_id, color
but it doesn't make any difference
Is there something I am doing wrong?
You have just released new features - Product Area and Skill Set.
Per the swagger file, in the definitions:
"Group": {
"description": "A Group.",
"type": "object",
"properties": {
//...
},
"required": [
"app_url",
"description",
"archived",
"entity_type",
"color",
"num_stories_started",
"mention_name",
"name",
"color_key",
"num_stories",
"num_epics_started",
"id",
"display_icon",
"member_ids",
"story_workflow_ids",
"workflow_ids"
]
}
But then when I query the API, some "required" attributes are nil. color
for example is not required, because most (to not say all) of the groups have an color_key
, which I guess replaces the color
I don't know when Creating a new group, but by definition, on how open-api generator build a client on top of the swagger files, it errors out because no color is present (API returns null
), but the attribute is "required"
I'ts only one issue I found. I will keep posting here if I found others
If you don't have requests already installed you get the following
Collecting requests==2.23.0
Using cached requests-2.23.0-py2.py3-none-any.whl (58 kB)
Collecting attrs==19.3.0
Using cached attrs-19.3.0-py2.py3-none-any.whl (39 kB)
Collecting certifi==2020.4.5.2
Using cached certifi-2020.4.5.2-py2.py3-none-any.whl (157 kB)
Collecting chardet==3.0.4
Using cached chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Collecting click==7.1.2
Using cached click-7.1.2-py2.py3-none-any.whl (82 kB)
Collecting clubhouse-lib==1.0.0
Using cached clubhouse-lib-1.0.0.tar.gz (23 kB)
ERROR: Command errored out with exit status 1:
command: /home/will/.virtualenvs/clubhub2/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/will/pip-install-uesiswx1/clubhouse-lib/setup.py'"'"'; __file__='"'"'/tmp/will/pip-install-uesiswx1/clubhouse-lib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/will/pip-pip-egg-info-hzuqziq0
cwd: /tmp/will/pip-install-uesiswx1/clubhouse-lib/
Complete output (9 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/will/pip-install-uesiswx1/clubhouse-lib/setup.py", line 6, in <module>
import clubhouse_lib
File "/tmp/will/pip-install-uesiswx1/clubhouse-lib/clubhouse_lib/__init__.py", line 4, in <module>
from clubhouse_lib.client import ClubhouseClient
File "/tmp/will/pip-install-uesiswx1/clubhouse-lib/clubhouse_lib/client.py", line 3, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Seeing on python 3.6 and 3.8.
This happens even if you have requests higher up in requirements.txt
than clubhouse_lib
.
This prevents using this library on a service like heroku where you have less control and only get one run of pip install
.
Support the get-workflow endpoint
This schema is out-of-date.
Nodejs v14.19.1
Typescript v4.7.4
Quokkajs
Steps
Error: Error: Response for preflight has invalid HTTP status code 401
I just wanted to open an issue, and also post the solution I found.
This was the comment, that pointed me to the solution
axios/axios#2061 (comment)
const shortcut = new ShortcutClient(SHORTCUT_API_TOKEN, {
adapter: require('axios/lib/adapters/http'), // <- add this
});
Hi there,
I get this type error when building and trying to add a change via clubhouseClient.updateStory
that includes external_links
as a property, even though this works with type safety off.
Type error: Argument of type '{ external_links: any[]; }' is not assignable to parameter of type 'StoryChange'.
--
I think it's because in Types.ts there's no entry for external_links in the StoryChange type.
Thanks
I was playing around with clubhouse api and this library to make simple app for exporting clubhouse data to CSV. It works fine when I was testing on localhost, but when I pushed to gh-pages, all fetch requests are returning with 403 error.
https://igordmitriev.github.io/clubhouse-export/
Is there anything I can do about it?
I was trying to fork library and add { mode: 'no-cors' }
to fetch
. It did not help much.
Fetch API cannot load https://api.clubhouse.io/api/beta/members?token=_hidden_. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://igordmitriev.github.io' is therefore not allowed access. The response had HTTP status code 403. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
I am using 0.4.0 and I am trying to use the search/stories
endpoint, but I am getting a 400 when calling the endpoint with clubhouse-lib. If I use curl or my own python lib (based on requests) everything works fine. The only difference I can see from the request is that the Content-Length
header is not set by clubhouse-lib. I might be a red herring.
client.getResource('search/stories', { query: 'owner:jm' }).then(console.log).catch(console.log);
If I can get it working I'll make a PR for it, but for now it's not working. :\
Documentation says it should:
https://clubhouse.io/api/rest/v3/#StorySlim
When making a valid call to deleteStoryComment(storyId, commentId)
, the comment is removed correctly but the client throws an error:
{
url: 'https://api.clubhouse.io/api/v3/stories/192/comments/222?token=xxxx',
status: 204,
statusText: 'No Content',
headers: [Headers],
counter: 0 }
},
body: {}
The issue is in src/FetchRequestParser.ts where json()
is being run before status code is checked.
Both the docs and this library lack any information on File uploading. It seems to be the only route that still passes the token through as a query parameter, and the files themselves I'm unclear on if they can be urls or not. Addtionally the docs list the files as being prepended with an "@" sign, but do not explain if this is necessary or not. I was hoping to see a reference implementation here to clear it up, but sadly haven't found one. Any work you can do to make this more clear would be much appreciated!
If you run into an error when accessing the API, this code gets executed:
It seems like ClientError
would be called with response
and the parsed body
, but unfortunately the .catch
grabs that error that's thrown, swallows it, and throws another error with a regular POJO instead.
Because the response.body
has already been parsed, you can't use the response
object on the error to call .json()
again to get the value. .clone()
also doesn't work because body
was already parsed.
It would be really nice to re-throw the original error if the thing that's caught is already a ClientError
instance! If you're interested in a fix like that, I would be happy to put together a PR.
The result of this is that it's hard to log the body of the error, in a case where you're using this library in a script and just want to see what went wrong!
As can be seen when actually trying to use it and finding that it connects with missing or broken endpoints
Error: Bad Request at new ClientError ([redacted]/node_modules/clubhouse-lib/build/client_error.js:19:112) at [redacted]/node_modules/clubhouse-lib/build/FetchRequestParser.js:26:29 at processTicksAndRejections (internal/process/task_queues.js:93:5) { response: Body { url: 'https://api.clubhouse.io/api/beta/epics/76?token=redacted', status: 400, statusText: 'Bad Request', headers: Headers { _headers: [Object] }, ok: false, body: PassThrough { _readableState: [ReadableState], readable: false, _events: [Object: null prototype], _eventsCount: 4, _maxListeners: undefined, _writableState: [WritableState], writable: false, allowHalfOpen: true, _transformState: [Object] }, bodyUsed: true, size: 0,
Hi,
Could you add the recommended way how to play with paginator? Many SDKs don't offer much more than building simple requests, but they expect the SDK to facilitate a certain abstraction. You can use async generators to make remote data "native" (see example iterator in GitHub SDK https://octokit.github.io/rest.js/v18#pagination , alternatively paginator in AWS SDK - https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rds.html#paginators ).
Available https://github.com/useshortcut/shortcut-client-js/tree/main/examples does not even attempt to reach that.
API response requires to the following URL, which is quite raw, and using raw API requests undermines the sense of the SDK.
Kind regards
First off, thanks for the great product. We've been a use of your Product for a few years.
Very similar to #70, We'd like to be able to query for tickets based on their associated Pull Requests.
While there are workarounds (we're currently parsing the PR Description for clubhouse links), it'd be great if this were a native feature of Clubhouse's.
Our usecase is we're doing a site deploy for every incoming PR, and need to post the URL to the ticket (as an external link) so our QA team can verify features.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.