Skip to content

Commit b7e6255

Browse files
chore: namananand/ins 1901 example documentation for sdk (#3)
Because - example documentation for sdk This commit - example documentation for sdk
1 parent 38e0a39 commit b7e6255

File tree

13 files changed

+3927
-67
lines changed

13 files changed

+3927
-67
lines changed

.github/CONTRIBUTING.md

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
11
# Contributing Guidelines
22

3-
Hello! Thanks for your interest in contributing to the codebase.
3+
We appreciate your contribution to this amazing project! Any form of engagement is welcome, including but not limiting to
44

5-
## How to contribute
5+
- feature request
6+
- documentation wording
7+
- bug report
8+
- roadmap suggestion
9+
- ...and so on!
610

7-
TBD
11+
Please refer to the [community contributing section](https://github.com/instill-ai/community#contributing) for more details.
812

13+
## Development and codebase contribution
914

10-
## Submitting a pull request
15+
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).
1116

12-
To make an efficient review process, we very much appreciate if the PR commits
17+
### Sending PRs
1318

14-
- follow the [conventional commits guidelines](https://www.conventionalcommits.org/),
15-
- follow the [7 rules of commit messages](https://chris.beams.io/posts/git-commit/), and
16-
- are rearranged to squash trivial commits together (use [git rebase](http://gitready.com/advanced/2009/03/20/reorder-commits-with-rebase.html)).
19+
Please take these general guidelines into consideration when you are sending a PR:
20+
21+
1. **Fork the Repository:** Begin by forking the repository to your GitHub account.
22+
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>`.
23+
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:
24+
- Adhere to the [conventional commits guidelines](https://www.conventionalcommits.org/) for meaningful commit messages.
25+
- Follow the [7 rules of commit messages](https://chris.beams.io/posts/git-commit/) for well-structured and informative commits.
26+
- 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.
27+
4. **Push to Your Branch:** Push your branch to your GitHub repository: `git push origin feat/<your-feature-name>`.
28+
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.
29+
30+
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**.
31+
32+
## Last words
33+
34+
Your contributions make a difference. Let's build something amazing together!

ReadMe.md

Lines changed: 117 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,134 @@
1+
### installation
2+
3+
```
4+
npm i @instill-ai/typescript-sdk
5+
```
6+
```
7+
yarn add @instill-ai/typescript-sdk
8+
```
9+
```
10+
pnpm add @instill-ai/typescript-sdk
11+
```
12+
113
## Usage Examples:
214

3-
Gives real-life examples showing how to utilise the SDK.
15+
```
16+
// node.js
17+
const instillAI = require("@instill-ai/typescript-sdk");
418
5-
## Error Handling:
19+
// next.js
20+
import { Pipeline, listPipelinesQuery } from "@instill-ai/typescript-sdk";
621
7-
Explains common errors and ways to resolve them.
22+
```
823

9-
## Integration Guide:
1024

11-
Guidance on how to incorporate the SDK into other applications.
25+
## API Reference
1226

13-
## Guidelines:
27+
### Pipelines
1428

15-
Recommendations for best practices while using the SDK.
29+
| function | params | response |
30+
| :------------------- | :---------------------------------------: | ----------------------: |
31+
| listPipelinesQuery | pageSize, nextPageToken, accessToken | |
32+
| listUserPipelinesQuery | pageSize, nextPageToken, accessToken, userName | |
33+
| getUserPipelineQuery | pipelineName, accessToken | |
34+
| ListUserPipelineReleasesQuery | userName, pipelineName, pageSize, nextPageToken, accessToken | |
35+
| getUserPipelineReleaseQuery | pipelineReleaseName, accessToken | |
36+
| watchUserPipelineReleaseQuery | pipelineReleaseName, accessToken | |
37+
| createUserPipelineMutation | userName, payload, accessToken | |
38+
| updateUserPipelineMutation | payload, accessToken | |
39+
| deleteUserPipelineMutation | pipelineName, accessToken | |
40+
| renameUserPipelineMutation | payload, accessToken | |
41+
| createUserPipelineReleaseMutation | pipelineName, payload, accessToken | |
42+
| updateUserPipelineReleaseMutation | pipelineReleaseName, payload, accessToken | |
43+
| deleteUserPipelineReleaseMutation | pipelineReleaseName, accessToken | |
44+
| triggerUserPipelineAction | pipelineName, payload, accessToken, returnTraces | |
45+
| triggerAsyncUserPipelineAction | pipelineName, payload, accessToken, returnTraces | |
46+
| setDefaultUserPipelineReleaseMutation | pipelineReleaseName, accessToken | |
47+
| restoreUserPipelineReleaseMutation | pipelineReleaseName, accessToken | |
48+
| triggerUserPipelineReleaseAction | pipelineReleaseName, payload, accessToken, returnTraces | |
49+
| triggerAsyncUserPipelineReleaseAction | pipelineReleaseName, payload, accessToken, returnTraces | |
1650

17-
## Troubleshooting Tips:
51+
### Connector
1852

19-
How to diagnose and fix problems.
53+
| function | params | response |
54+
| :------------------- | :-----------------------------------------------------------: | -----------------: |
55+
| listConnectorResourcesQuery | userName, pageSize, nextPageToken, accessToken, filter | |
56+
| listUserConnectorResourcesQuery | pageSize, nextPageToken, accessToken, filter | |
57+
| listConnectorDefinitionsQuery | connectorDefinitionName, accessToken | |
58+
| getConnectorDefinitionQuery | connectorDefinitionName, accessToken | |
59+
| getUserConnectorResourceQuery | connectorDefinitionName, accessToken | |
60+
| watchUserConnectorResource | userName, payload, accessToken | |
61+
| createUserConnectorResourceMutation | connectorDefinitionName, accessToken | |
62+
| deleteUserConnectorResourceMutation | payload, accessToken | |
63+
| updateUserConnectorResourceMutation | payload, accessToken | |
64+
| renameUserConnectorResource | payload, accessToken | |
65+
| testUserConnectorResourceConnectionAction | connectorDefinitionName, accessToken | |
66+
| connectUserConnectorResourceAction | connectorDefinitionName, accessToken | |
67+
| disconnectUserConnectorResourceAction | connectorDefinitionName, accessToken | |
2068

21-
## License & Version Control:
69+
### Metric
2270

23-
Information about licenses and updates related to the SDK.
71+
| function | params | response |
72+
| :------------------- | :------------------: | -----------------: |
73+
| listPipelineTriggerRecordsQuery | pageSize, nextPageToken, accessToken, filter | |
74+
| listTriggeredPipelineQuery | pageSize, nextPageToken, accessToken, filter | |
75+
| listTriggeredPipelineChartQuery | pageSize, nextPageToken, accessToken, filter | |
2476

25-
## Release Notes:
77+
modelDefinitionName, accessToken,
78+
### Model
79+
80+
| function | params | response |
81+
| :------------------- | :------------------: | -----------------: |
82+
| getModelDefinitionQuery | modelDefinitionName, accessToken | |
83+
| listModelDefinitionsQuery | pageSize, nextPageToken, accessToken | |
84+
| getUserModelQuery | modelName, accessToken | |
85+
| listModelsQuery | pageSize, nextPageToken, accessToken | |
86+
| listUserModelsQuery | userName, pageSize, nextPageToken, accessToken | |
87+
| getUserModelReadmeQuery | modelName, accessToken | |
88+
| watchUserModel | modelName, accessToken | |
89+
| createUserModelMutation | userName, payload, accessToken | |
90+
| updateModelMutation | payload, accessToken | |
91+
| deleteUserModelMutation | modelName, accessToken | |
92+
| deployUserModelAction | modelName, accessToken | |
93+
| undeployUserModeleAction | modelName, accessToken | |
94+
95+
### Operation
96+
97+
| function | params | response |
98+
| :------------------- | :-----------------------------------------------------------: | -----------------: |
99+
| getOperationQuery | operationName, accessToken | |
100+
| checkUntilOperationIsDoen | operationName, accessToken | |
101+
102+
### Mgmt
103+
104+
| function | params | response |
105+
| :------------------- | :------------------: | -----------------: |
106+
| getUserQuery | accessToken | |
107+
| checkUserIdExist | id, accessToken | |
108+
| getApiTokenQuery | tokenName, accessToken | |
109+
| listApiTokensQuery | pageSize, nextPageToken, accessToken | |
110+
| updateUserMutation | payload, accessToken | |
111+
| createApiTokenMutation | payload, accessToken | |
112+
| deleteApiTokenMutation | tokenName, accessToken | |
26113

27-
Details about new releases, changes, bug fixes, improvements, known issues.
114+
## Error Handling:
115+
116+
Explains common errors and ways to resolve them.
117+
118+
## Integration Guide:
119+
### Next APP
120+
- [next-app](./examples/next-app/)
121+
### Node APP
122+
- [node-app](./examples/node-app/)
123+
124+
Guidance on how to incorporate the SDK into other applications.
125+
126+
## Contribution Guidelines:
127+
128+
Please refer to the [Contributing Guidelines](./.github/CONTRIBUTING.md) for more details.
129+
130+
## Release Notes:
131+
[Release](./CHANGELOG.md)
28132

29133
## Support:
30134

examples/next-app/README.md

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,53 @@
1-
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).
1+
## Config and installation
22

3-
## Getting Started
3+
### installation
44

5-
First, run the development server:
6-
7-
```bash
8-
npm run dev
9-
# or
10-
yarn dev
11-
# or
12-
pnpm dev
13-
# or
14-
bun run dev
5+
```
6+
npm i @instill-ai/typescript-sdk
7+
```
8+
```
9+
yarn add @instill-ai/typescript-sdk
10+
```
11+
```
12+
pnpm add @instill-ai/typescript-sdk
1513
```
1614

17-
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18-
19-
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
20-
21-
[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`.
22-
23-
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.
24-
25-
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
26-
27-
## Learn More
28-
29-
To learn more about Next.js, take a look at the following resources:
30-
31-
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
32-
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
33-
34-
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
15+
### config
3516

36-
## Deploy on Vercel
17+
- make sure you have vdp up running, to run vdp check this [vdp](https://github.com/instill-ai/vdp)
18+
- verify `.env`
19+
- see the changes done in `_document.tsx` and `next.env.mjs`
3720

38-
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.
21+
### Now You are ready.
3922

40-
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
23+
```
24+
import { Pipeline, listPipelinesQuery } from "@instill-ai/typescript-sdk";
25+
26+
export default function TypescriptSdkDemo() {
27+
const [pipelines, setPipelines] = useState<Pipeline[]>([]);
28+
useEffect(() => {
29+
// Pipeline
30+
31+
listPipelinesQuery({
32+
pageSize: 6,
33+
nextPageToken: null,
34+
accessToken: null,
35+
})
36+
.then((data) => {
37+
// response data
38+
console.log("data", data);
39+
setPipelines(data);
40+
})
41+
.catch((error) => {
42+
// error
43+
console.log("error", error);
44+
});
45+
}, []);
46+
47+
return (
48+
<div>
49+
{JSON.stringify(pipelines)}
50+
</div>
51+
);
52+
}
53+
```

examples/next-app/src/pages/index.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { Inter } from "next/font/google";
22
import { useEffect, useState } from "react";
33
import { Pipeline, listPipelinesQuery } from "@instill-ai/typescript-sdk";
44

5-
const inter = Inter({ subsets: ["latin"] });
6-
75
export default function TypescriptSdkDemo() {
86
const [pipelines, setPipelines] = useState<Pipeline[]>([]);
97
useEffect(() => {
@@ -23,11 +21,5 @@ export default function TypescriptSdkDemo() {
2321
});
2422
}, []);
2523

26-
return (
27-
<main
28-
className={`flex min-h-screen flex-col items-center justify-between p-24 ${inter.className}`}
29-
>
30-
{JSON.stringify(pipelines)}
31-
</main>
32-
);
24+
return <div>{JSON.stringify(pipelines)}</div>;
3325
}

examples/node-app/.env

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
NEXT_PUBLIC_API_VERSION=v1alpha
2+
NEXT_PUBLIC_INSTILL_AI_USER_COOKIE_NAME=instill-ai-user
3+
NEXT_PUBLIC_CONSOLE_EDITION=local-ce:dev
4+
NEXT_PUBLIC_API_GATEWAY_URL=http://localhost:8080
5+
NEXT_SERVER_API_GATEWAY_URL=http://localhost:8080
6+
NEXT_PUBLIC_SELF_SIGNED_CERTIFICATION=false
7+
NEXT_PUBLIC_DISABLE_CREATE_UPDATE_DELETE_RESOURCE=false
8+
NEXT_PUBLIC_LIST_PAGE_SIZE=6
9+
NEXT_PUBLIC_USAGE_COLLECTION_ENABLED=true
10+
NEXT_PUBLIC_SET_SECURE_COOKIE=false
11+
NEXT_PUBLIC_AMPLITUDE_KEY=9823fa6e3ff904bec67a8fc90db82fb9
12+
NEXT_PUBLIC_CONSOLE_BASE_URL=http://localhost:3000
13+
NEXT_PUBLIC_MGMT_BACKEND_BASE_URL=http://localhost:8084
14+
NEXT_PUBLIC_PIPELINE_BACKEND_BASE_URL=http://localhost:8081
15+
NEXT_PUBLIC_CONNECTOR_BACKEND_BASE_URL=http://localhost:8082
16+
MODEL_BACKEND_BASE_URL=http://localhost:8083

examples/node-app/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
## Config and installation
2+
3+
### installation
4+
5+
```
6+
npm i @instill-ai/typescript-sdk
7+
```
8+
```
9+
yarn add @instill-ai/typescript-sdk
10+
```
11+
```
12+
pnpm add @instill-ai/typescript-sdk
13+
```
14+
15+
### config
16+
17+
- make sure you have vdp up running, to run vdp check this [vdp](https://github.com/instill-ai/vdp)
18+
- verify `.env`
19+
20+
### Now You are ready.
21+
22+
```
23+
// setup express project
24+
25+
const express = require("express");
26+
const instillAI = require("@instill-ai/typescript-sdk");
27+
require("dotenv").config(); // Load environment variables from .env file
28+
29+
const app = express();
30+
const port = process.env.PORT || 5000;
31+
32+
// Define a route for listing pipelines using the SDK
33+
app.get("/list-pipelines", async (req, res) => {
34+
try {
35+
const data = await instillAI.listPipelinesQuery({
36+
pageSize: 6,
37+
nextPageToken: null,
38+
accessToken: null, // Use the environment variable
39+
});
40+
res.json(data);
41+
} catch (error) {
42+
console.error("Error:", error);
43+
res.status(500).json({ error: "An error occurred" });
44+
}
45+
});
46+
47+
app.listen(port, () => {
48+
console.log(`Server is running on port ${port}`);
49+
});
50+
```

examples/node-app/package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "app",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"dependencies": {
7+
"@instill-ai/typescript-sdk": "^0.0.1",
8+
"dotenv": "^16.3.1",
9+
"express": "^4.18.2"
10+
},
11+
"scripts": {
12+
"test": "echo \"Error: no test specified\" && exit 1",
13+
"dev": "node server.js"
14+
},
15+
"author": "",
16+
"license": "ISC"
17+
}

0 commit comments

Comments
 (0)