Skip to content

Commit

Permalink
feat: Docs & generic "doRequest" exposed for custom queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Negan1911 committed May 13, 2022
1 parent 1de7729 commit c76c30a
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 4 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,13 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Generate docs
run: yarn doc
if: success() && github.actor != 'kodiakhq[bot]'

- name: Deploy docs
uses: JamesIves/github-pages-deploy-action@v4.3.3
with:
branch: gh-pages
folder: docs
43 changes: 40 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,43 @@
# nodejs-api-sdk
Firesquad Node SDK
# @firesquad/api-sdk

Properly integrate your Nodejs apps with firesquad usign this SDK.

- [Firesquad API Knowledge Base](https://help.firesquad.io/category/627e6c7f1089aa742a648461/articles)
- [API Docs](https://firesquadio.github.io/nodejs-api-sdk/classes/Firesquad.html)

<p align="center">
<img alt="Firesquad" src="https://app.firesquad.io/public/firesquad-logo-background.png">
</p>
</p>

### Quick Start

For getting started, Create an API Integration on [Firesquad](https://app.firesquad.io/settings/integrations/new).
After that, you can use this firesquad package:

```ts
import { Firesquad, ConversationContentMessageType } from "@firesquad/api-sdk";

export const fs = new Firesquad(
"https://<your-account>.api.firesquad.io",
"<your-api-id>",
"<your-api-key>"
);

/* You can use firesquad methods after creating the instance, such as: */
fs.PostConversationItem(
{
internal: false,
content: {
message: [
{
type: ConversationContentMessageType.Paragraph,
children: [{ text: "Hello, World!" }],
},
],
},
},
"<your-conversation-id>"
)
/* And wait for the response */
.then((response) => console.log(response));
```
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@
"graphql": "^16.3.0",
"prettier": "^2.5.1",
"semantic-release": "^19.0.2",
"typedoc": "^0.22.15",
"typescript": "^4.6.2"
},
"scripts": {
"doc": "typedoc index.ts",
"build": "yarn generate && tsc",
"generate": "graphql-codegen",
"lint": "tsc --noEmit && eslint . --ext .js,.ts,.tsx",
Expand Down
8 changes: 7 additions & 1 deletion sdk.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ export class Firesquad {
}
}

private async doRequest<key extends keyof res, res = Record<key, unknown>>(
/**
* This is a generic method to run requests to our GraphQL API.
* If the default methods does not match your needs, you can use this method to run your own requests.
* @param request - Request to send to the API.
* @returns - Response from the API.
*/
public async doRequest<key extends keyof res, res = Record<key, unknown>>(
request: Request<key>
): Promise<res[key]> {
const req = await fetch(`${this.apiUrl}/graphql`, {
Expand Down
84 changes: 84 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@ __metadata:
graphql: ^16.3.0
prettier: ^2.5.1
semantic-release: ^19.0.2
typedoc: ^0.22.15
typescript: ^4.6.2
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -2551,6 +2552,15 @@ __metadata:
languageName: node
linkType: hard

"brace-expansion@npm:^2.0.1":
version: 2.0.1
resolution: "brace-expansion@npm:2.0.1"
dependencies:
balanced-match: ^1.0.0
checksum: a61e7cd2e8a8505e9f0036b3b6108ba5e926b4b55089eeb5550cd04a471fe216c96d4fe7e4c7f995c728c554ae20ddfc4244cad10aef255e72b62930afd233d1
languageName: node
linkType: hard

"braces@npm:^3.0.1, braces@npm:~3.0.2":
version: 3.0.2
resolution: "braces@npm:3.0.2"
Expand Down Expand Up @@ -5495,6 +5505,13 @@ __metadata:
languageName: node
linkType: hard

"jsonc-parser@npm:^3.0.0":
version: 3.0.0
resolution: "jsonc-parser@npm:3.0.0"
checksum: 1df2326f1f9688de30c70ff19c5b2a83ba3b89a1036160da79821d1361090775e9db502dc57a67c11b56e1186fc1ed70b887f25c5febf9a3ec4f91435836c99d
languageName: node
linkType: hard

"jsonfile@npm:^6.0.1":
version: 6.1.0
resolution: "jsonfile@npm:6.1.0"
Expand Down Expand Up @@ -6031,6 +6048,13 @@ __metadata:
languageName: node
linkType: hard

"lunr@npm:^2.3.9":
version: 2.3.9
resolution: "lunr@npm:2.3.9"
checksum: 176719e24fcce7d3cf1baccce9dd5633cd8bdc1f41ebe6a180112e5ee99d80373fe2454f5d4624d437e5a8319698ca6837b9950566e15d2cae5f2a543a3db4b8
languageName: node
linkType: hard

"make-error@npm:^1, make-error@npm:^1.1.1":
version: 1.3.6
resolution: "make-error@npm:1.3.6"
Expand Down Expand Up @@ -6132,6 +6156,15 @@ __metadata:
languageName: node
linkType: hard

"marked@npm:^4.0.12":
version: 4.0.15
resolution: "marked@npm:4.0.15"
bin:
marked: bin/marked.js
checksum: 8992c37669b872846a226f90dc5a8fa1e5d56bba6e32fa36270fd3d327dd9e11fedc5b47b68de611dcdce1573d30fbadf61bf23f86c1a679e5385424d7b9d9f3
languageName: node
linkType: hard

"meow@npm:^8.0.0":
version: 8.1.2
resolution: "meow@npm:8.1.2"
Expand Down Expand Up @@ -6267,6 +6300,15 @@ __metadata:
languageName: node
linkType: hard

"minimatch@npm:^5.0.1":
version: 5.0.1
resolution: "minimatch@npm:5.0.1"
dependencies:
brace-expansion: ^2.0.1
checksum: b34b98463da4754bc526b244d680c69d4d6089451ebe512edaf6dd9eeed0279399cfa3edb19233513b8f830bf4bfcad911dddcdf125e75074100d52f724774f0
languageName: node
linkType: hard

"minimist-options@npm:4.1.0":
version: 4.1.0
resolution: "minimist-options@npm:4.1.0"
Expand Down Expand Up @@ -8074,6 +8116,17 @@ __metadata:
languageName: node
linkType: hard

"shiki@npm:^0.10.1":
version: 0.10.1
resolution: "shiki@npm:0.10.1"
dependencies:
jsonc-parser: ^3.0.0
vscode-oniguruma: ^1.6.1
vscode-textmate: 5.2.0
checksum: fb746f3cb3de7e545e3b10a6cb658d3938f840e4ccc9a3c90ceb7e69a8f89dbb432171faac1e9f02a03f103684dad88ee5e54b5c4964fa6b579fca6e8e26424d
languageName: node
linkType: hard

"side-channel@npm:^1.0.4":
version: 1.0.4
resolution: "side-channel@npm:1.0.4"
Expand Down Expand Up @@ -8840,6 +8893,23 @@ __metadata:
languageName: node
linkType: hard

"typedoc@npm:^0.22.15":
version: 0.22.15
resolution: "typedoc@npm:0.22.15"
dependencies:
glob: ^7.2.0
lunr: ^2.3.9
marked: ^4.0.12
minimatch: ^5.0.1
shiki: ^0.10.1
peerDependencies:
typescript: 4.0.x || 4.1.x || 4.2.x || 4.3.x || 4.4.x || 4.5.x || 4.6.x
bin:
typedoc: bin/typedoc
checksum: 3f5f1cb9288bf811f42df59750c7062a026a23257b38dfe227515a30007a28e3d8139187949fcd19300fd6b2ef76bcdc4cf54549100bff3e000e61bb19958fb2
languageName: node
linkType: hard

"typescript@npm:^4.6.2":
version: 4.6.2
resolution: "typescript@npm:4.6.2"
Expand Down Expand Up @@ -9049,6 +9119,20 @@ __metadata:
languageName: node
linkType: hard

"vscode-oniguruma@npm:^1.6.1":
version: 1.6.2
resolution: "vscode-oniguruma@npm:1.6.2"
checksum: 6b754acdafd5b68242ea5938bb00a32effc16c77f471d4f0f337d879d0e8e592622998e2441f42d9a7ff799c1593f31c11f26ca8d9bf9917e3ca881d3c1f3e19
languageName: node
linkType: hard

"vscode-textmate@npm:5.2.0":
version: 5.2.0
resolution: "vscode-textmate@npm:5.2.0"
checksum: 5449b42d451080f6f3649b66948f4b5ee4643c4e88cfe3558a3b31c84c78060cfdd288c4958c1690eaa5cd65d09992fa6b7c3bef9d4aa72b3651054a04624d20
languageName: node
linkType: hard

"walk-up-path@npm:^1.0.0":
version: 1.0.0
resolution: "walk-up-path@npm:1.0.0"
Expand Down

0 comments on commit c76c30a

Please sign in to comment.