-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: namananand/ins 1901 example documentation for sdk (#3)
Because - example documentation for sdk This commit - example documentation for sdk
- Loading branch information
1 parent
38e0a39
commit b7e6255
Showing
13 changed files
with
3,927 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,34 @@ | ||
# Contributing Guidelines | ||
|
||
Hello! Thanks for your interest in contributing to the codebase. | ||
We appreciate your contribution to this amazing project! Any form of engagement is welcome, including but not limiting to | ||
|
||
## How to contribute | ||
- feature request | ||
- documentation wording | ||
- bug report | ||
- roadmap suggestion | ||
- ...and so on! | ||
|
||
TBD | ||
Please refer to the [community contributing section](https://github.com/instill-ai/community#contributing) for more details. | ||
|
||
## Development and codebase contribution | ||
|
||
## Submitting a pull request | ||
Before delving into the details to come up with your first PR, please familiarise yourself with the project structure of [Instill Core](https://github.com/instill-ai/community#instill-core). | ||
|
||
To make an efficient review process, we very much appreciate if the PR commits | ||
### Sending PRs | ||
|
||
- follow the [conventional commits guidelines](https://www.conventionalcommits.org/), | ||
- follow the [7 rules of commit messages](https://chris.beams.io/posts/git-commit/), and | ||
- are rearranged to squash trivial commits together (use [git rebase](http://gitready.com/advanced/2009/03/20/reorder-commits-with-rebase.html)). | ||
Please take these general guidelines into consideration when you are sending a PR: | ||
|
||
1. **Fork the Repository:** Begin by forking the repository to your GitHub account. | ||
2. **Create a New Branch:** Create a new branch to house your work. Use a clear and descriptive name, like `<your-github-username>/<what-your-pr-about>`. | ||
3. **Make and Commit Changes:** Implement your changes and commit them. We encourage you to follow these best practices for commits to ensure an efficient review process: | ||
- Adhere to the [conventional commits guidelines](https://www.conventionalcommits.org/) for meaningful commit messages. | ||
- Follow the [7 rules of commit messages](https://chris.beams.io/posts/git-commit/) for well-structured and informative commits. | ||
- Rearrange commits to squash trivial changes together, if possible. Utilize [git rebase](http://gitready.com/advanced/2009/03/20/reorder-commits-with-rebase.html) for this purpose. | ||
4. **Push to Your Branch:** Push your branch to your GitHub repository: `git push origin feat/<your-feature-name>`. | ||
5. **Open a Pull Request:** Initiate a pull request to our repository. Our team will review your changes and collaborate with you on any necessary refinements. | ||
|
||
When you are ready to send a PR, we recommend you to first open a `draft` one. This will trigger a bunch of `integration-test` [workflows](https://github.com/instill-ai/model/tree/main/.github/workflows) running a thorough test suite on multiple platforms. After the tests are done and passed, you can now mark the PR `open` to notify the codebase owners to review. We appreciate your endeavour to pass the integration test for your PR to make sure the sanity with respect to the entire scope of **Instill Core**. | ||
|
||
## Last words | ||
|
||
Your contributions make a difference. Let's build something amazing together! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,53 @@ | ||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). | ||
## Config and installation | ||
|
||
## Getting Started | ||
### installation | ||
|
||
First, run the development server: | ||
|
||
```bash | ||
npm run dev | ||
# or | ||
yarn dev | ||
# or | ||
pnpm dev | ||
# or | ||
bun run dev | ||
``` | ||
npm i @instill-ai/typescript-sdk | ||
``` | ||
``` | ||
yarn add @instill-ai/typescript-sdk | ||
``` | ||
``` | ||
pnpm add @instill-ai/typescript-sdk | ||
``` | ||
|
||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
|
||
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file. | ||
|
||
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`. | ||
|
||
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. | ||
|
||
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. | ||
|
||
## Learn More | ||
|
||
To learn more about Next.js, take a look at the following resources: | ||
|
||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. | ||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. | ||
|
||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! | ||
### config | ||
|
||
## Deploy on Vercel | ||
- make sure you have vdp up running, to run vdp check this [vdp](https://github.com/instill-ai/vdp) | ||
- verify `.env` | ||
- see the changes done in `_document.tsx` and `next.env.mjs` | ||
|
||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. | ||
### Now You are ready. | ||
|
||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. | ||
``` | ||
import { Pipeline, listPipelinesQuery } from "@instill-ai/typescript-sdk"; | ||
export default function TypescriptSdkDemo() { | ||
const [pipelines, setPipelines] = useState<Pipeline[]>([]); | ||
useEffect(() => { | ||
// Pipeline | ||
listPipelinesQuery({ | ||
pageSize: 6, | ||
nextPageToken: null, | ||
accessToken: null, | ||
}) | ||
.then((data) => { | ||
// response data | ||
console.log("data", data); | ||
setPipelines(data); | ||
}) | ||
.catch((error) => { | ||
// error | ||
console.log("error", error); | ||
}); | ||
}, []); | ||
return ( | ||
<div> | ||
{JSON.stringify(pipelines)} | ||
</div> | ||
); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
NEXT_PUBLIC_API_VERSION=v1alpha | ||
NEXT_PUBLIC_INSTILL_AI_USER_COOKIE_NAME=instill-ai-user | ||
NEXT_PUBLIC_CONSOLE_EDITION=local-ce:dev | ||
NEXT_PUBLIC_API_GATEWAY_URL=http://localhost:8080 | ||
NEXT_SERVER_API_GATEWAY_URL=http://localhost:8080 | ||
NEXT_PUBLIC_SELF_SIGNED_CERTIFICATION=false | ||
NEXT_PUBLIC_DISABLE_CREATE_UPDATE_DELETE_RESOURCE=false | ||
NEXT_PUBLIC_LIST_PAGE_SIZE=6 | ||
NEXT_PUBLIC_USAGE_COLLECTION_ENABLED=true | ||
NEXT_PUBLIC_SET_SECURE_COOKIE=false | ||
NEXT_PUBLIC_AMPLITUDE_KEY=9823fa6e3ff904bec67a8fc90db82fb9 | ||
NEXT_PUBLIC_CONSOLE_BASE_URL=http://localhost:3000 | ||
NEXT_PUBLIC_MGMT_BACKEND_BASE_URL=http://localhost:8084 | ||
NEXT_PUBLIC_PIPELINE_BACKEND_BASE_URL=http://localhost:8081 | ||
NEXT_PUBLIC_CONNECTOR_BACKEND_BASE_URL=http://localhost:8082 | ||
MODEL_BACKEND_BASE_URL=http://localhost:8083 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
## Config and installation | ||
|
||
### installation | ||
|
||
``` | ||
npm i @instill-ai/typescript-sdk | ||
``` | ||
``` | ||
yarn add @instill-ai/typescript-sdk | ||
``` | ||
``` | ||
pnpm add @instill-ai/typescript-sdk | ||
``` | ||
|
||
### config | ||
|
||
- make sure you have vdp up running, to run vdp check this [vdp](https://github.com/instill-ai/vdp) | ||
- verify `.env` | ||
|
||
### Now You are ready. | ||
|
||
``` | ||
// setup express project | ||
const express = require("express"); | ||
const instillAI = require("@instill-ai/typescript-sdk"); | ||
require("dotenv").config(); // Load environment variables from .env file | ||
const app = express(); | ||
const port = process.env.PORT || 5000; | ||
// Define a route for listing pipelines using the SDK | ||
app.get("/list-pipelines", async (req, res) => { | ||
try { | ||
const data = await instillAI.listPipelinesQuery({ | ||
pageSize: 6, | ||
nextPageToken: null, | ||
accessToken: null, // Use the environment variable | ||
}); | ||
res.json(data); | ||
} catch (error) { | ||
console.error("Error:", error); | ||
res.status(500).json({ error: "An error occurred" }); | ||
} | ||
}); | ||
app.listen(port, () => { | ||
console.log(`Server is running on port ${port}`); | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "app", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"dependencies": { | ||
"@instill-ai/typescript-sdk": "^0.0.1", | ||
"dotenv": "^16.3.1", | ||
"express": "^4.18.2" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"dev": "node server.js" | ||
}, | ||
"author": "", | ||
"license": "ISC" | ||
} |
Oops, something went wrong.