Skip to content

Commit 5a080e1

Browse files
chore: refactor docs and remove unused files (#23)
Because - refactor docs and remove unused files This commit - refactor docs and remove unused files
1 parent d8aa4b7 commit 5a080e1

35 files changed

+1138
-2653
lines changed

README.md

Lines changed: 179 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -39,36 +39,136 @@ pnpm add @instill-ai/typescript-sdk
3939

4040
```
4141
// node.js
42-
const instillAI = require("@instill-ai/typescript-sdk");
42+
const InstillClient = require("@instill-ai/typescript-sdk");
4343
4444
// next.js
45-
import { Pipeline, listPipelinesQuery } from "@instill-ai/typescript-sdk";
45+
import InstillClient from "@instill-ai/typescript-sdk";
4646
4747
```
48+
4849
### config
4950

50-
- `.env`
51+
```
52+
baseUrl: string
53+
appVersion: string
54+
accessToken: Nullable<string>
55+
```
56+
57+
## Example app templetes
58+
59+
### local
5160

5261
```
53-
API_VERSION=v1alpha
54-
INSTILL_AI_USER_COOKIE_NAME=instill-ai-user
55-
APP_EDITION=local-ce:dev
56-
API_GATEWAY_URL=http://localhost:8080
57-
SELF_SIGNED_CERTIFICATION=false
58-
DISABLE_CREATE_UPDATE_DELETE_RESOURCE=false
59-
LIST_PAGE_SIZE=6
60-
USAGE_COLLECTION_ENABLED=true
61-
SET_SECURE_COOKIE=false
62-
AMPLITUDE_KEY=9823fa6e3ff904bec67a8fc90db82fb9
63-
APP_BASE_URL=http://localhost:3000
64-
MGMT_BACKEND_BASE_URL=http://localhost:8084
65-
PIPELINE_BACKEND_BASE_URL=http://localhost:8081
66-
CONNECTOR_BACKEND_BASE_URL=http://localhost:8082
67-
MODEL_BACKEND_BASE_URL=http://localhost:8083
62+
import { useEffect, useState } from "react";
63+
import InstillClient, {
64+
Nullable,
65+
User,
66+
} from "@instill-ai/typescript-sdk";
67+
68+
export default function TypescriptSdkDemo() {
69+
const [user, setUser] = useState<User[]>([]);
70+
const [token, setToken] = useState<Nullable<string>>(null);
71+
72+
const client = new InstillClient("http://localhost:8080", "v1alpha", token);
73+
74+
const login = async () => {
75+
const userToken = await client.Auth.authLoginAction({
76+
payload: {
77+
username: "admin",
78+
password: "password",
79+
},
80+
});
81+
82+
setToken(userToken);
83+
};
84+
85+
useEffect(() => {
86+
login();
87+
}, []);
88+
89+
useEffect(() => {
90+
if (token) {
91+
client.Auth.getUserQuery()
92+
.then((data: any) => {
93+
console.log("data", data);
94+
setUser(data);
95+
})
96+
.catch((error: any) => {
97+
console.log("error", error);
98+
});
99+
}
100+
}, [token]);
101+
102+
return (
103+
<>
104+
<h1>User Data</h1>
105+
<pre style={{ backgroundColor: "white" }}>
106+
{JSON.stringify(user, null, 4)}
107+
</pre>
108+
</>
109+
);
110+
}
68111
```
69112

113+
### With Token
114+
115+
```
116+
import { useEffect, useState } from "react";
117+
import InstillClient, {
118+
Nullable,
119+
Pipeline,
120+
User,
121+
} from "@instill-ai/typescript-sdk";
122+
123+
export default function TypescriptSdkDemo() {
124+
const [pipelines, setPipelines] = useState<Pipeline[]>([]);
125+
const [user, setUser] = useState<User[]>([]);
126+
127+
const client = new InstillClient(
128+
"https://api.instill.tech",
129+
"v1alpha",
130+
"" // console API token
131+
);
132+
133+
useEffect(() => {
134+
client.Auth.getUserQuery()
135+
.then((data: any) => {
136+
console.log("data", data);
137+
setUser(data);
138+
})
139+
.catch((error: any) => {
140+
console.log("error", error);
141+
});
142+
143+
client.Pipeline.listPipelinesQuery({
144+
pageSize: null,
145+
nextPageToken: null,
146+
})
147+
.then((data: any) => {
148+
console.log("data", data);
149+
setPipelines(data);
150+
})
151+
.catch((error: any) => {
152+
console.log("error", error);
153+
});
154+
}, []);
155+
156+
return (
157+
<>
158+
<h1>User Data</h1>
159+
<pre style={{ backgroundColor: "white" }}>
160+
{JSON.stringify(user, null, 4)}
161+
</pre>
162+
163+
<h1>Pipelines List</h1>
164+
<pre style={{ backgroundColor: "white" }}>
165+
{JSON.stringify(pipelines, null, 4)}
166+
</pre>
167+
</>
168+
);
169+
}
170+
```
70171

71-
## Example app templetes
72172

73173
### Next APP
74174

@@ -84,89 +184,89 @@ MODEL_BACKEND_BASE_URL=http://localhost:8083
84184

85185
| function | params |
86186
| :------------------------------------ | :----------------------------------------------------------: |
87-
| listPipelinesQuery | pageSize, nextPageToken, accessToken |
88-
| listUserPipelinesQuery | pageSize, nextPageToken, userName |
89-
| getUserPipelineQuery | pipelineName, accessToken |
90-
| ListUserPipelineReleasesQuery | userName, pipelineName, pageSize, nextPageToken, accessToken |
91-
| getUserPipelineReleaseQuery | pipelineReleaseName, accessToken |
92-
| watchUserPipelineReleaseQuery | pipelineReleaseName, accessToken |
93-
| createUserPipelineMutation | userName, payload, accessToken |
94-
| updateUserPipelineMutation | payload, accessToken |
95-
| deleteUserPipelineMutation | pipelineName, accessToken |
96-
| renameUserPipelineMutation | payload, accessToken |
97-
| createUserPipelineReleaseMutation | pipelineName, payload, accessToken |
98-
| updateUserPipelineReleaseMutation | pipelineReleaseName, payload, accessToken |
99-
| deleteUserPipelineReleaseMutation | pipelineReleaseName, accessToken |
100-
| triggerUserPipelineAction | pipelineName, payload, returnTraces |
101-
| triggerAsyncUserPipelineAction | pipelineName, payload, returnTraces |
102-
| setDefaultUserPipelineReleaseMutation | pipelineReleaseName, accessToken |
103-
| restoreUserPipelineReleaseMutation | pipelineReleaseName, accessToken |
104-
| triggerUserPipelineReleaseAction | pipelineReleaseName, payload, returnTraces |
105-
| triggerAsyncUserPipelineReleaseAction | pipelineReleaseName, payload, returnTraces |
187+
| listPipelinesQuery | pageSize, nextPageToken |
188+
| listUserPipelinesQuery | pageSize, nextPageToken, userName |
189+
| getUserPipelineQuery | pipelineName |
190+
| ListUserPipelineReleasesQuery | userName, pipelineName, pageSize, nextPageToken |
191+
| getUserPipelineReleaseQuery | pipelineReleaseName |
192+
| watchUserPipelineReleaseQuery | pipelineReleaseName |
193+
| createUserPipelineMutation | userName, payload |
194+
| updateUserPipelineMutation | payload |
195+
| deleteUserPipelineMutation | pipelineName |
196+
| renameUserPipelineMutation | payload |
197+
| createUserPipelineReleaseMutation | pipelineName, payload |
198+
| updateUserPipelineReleaseMutation | pipelineReleaseName, payload |
199+
| deleteUserPipelineReleaseMutation | pipelineReleaseName |
200+
| triggerUserPipelineAction | pipelineName, payload, returnTraces |
201+
| triggerAsyncUserPipelineAction | pipelineName, payload, returnTraces |
202+
| setDefaultUserPipelineReleaseMutation | pipelineReleaseName |
203+
| restoreUserPipelineReleaseMutation | pipelineReleaseName |
204+
| triggerUserPipelineReleaseAction | pipelineReleaseName, payload, returnTraces |
205+
| triggerAsyncUserPipelineReleaseAction | pipelineReleaseName, payload, returnTraces |
106206

107207
### Connector
108208

109-
| function | params |
110-
| :---------------------------------------- | :----------------------------------------------------: |
111-
| listConnectorResourcesQuery | userName, pageSize, nextPageToken, filter |
112-
| listUserConnectorResourcesQuery | pageSize, nextPageToken, filter |
113-
| listConnectorDefinitionsQuery | connectorDefinitionName, accessToken |
114-
| getConnectorDefinitionQuery | connectorDefinitionName, accessToken |
115-
| getUserConnectorResourceQuery | connectorDefinitionName, accessToken |
116-
| watchUserConnectorResource | userName, payload, accessToken |
117-
| createUserConnectorResourceMutation | connectorDefinitionName, accessToken |
118-
| deleteUserConnectorResourceMutation | payload, accessToken |
119-
| updateUserConnectorResourceMutation | payload, accessToken |
120-
| renameUserConnectorResource | payload, accessToken |
121-
| testUserConnectorResourceConnectionAction | connectorDefinitionName, accessToken |
122-
| connectUserConnectorResourceAction | connectorDefinitionName, accessToken |
123-
| disconnectUserConnectorResourceAction | connectorDefinitionName, accessToken |
209+
| function | params |
210+
| :---------------------------------------- | :---------------------------------------: |
211+
| listConnectorResourcesQuery | userName, pageSize, nextPageToken, filter |
212+
| listUserConnectorResourcesQuery | pageSize, nextPageToken, filter |
213+
| listConnectorDefinitionsQuery | connectorDefinitionName |
214+
| getConnectorDefinitionQuery | connectorDefinitionName |
215+
| getUserConnectorResourceQuery | connectorDefinitionName |
216+
| watchUserConnectorResource | userName, payload |
217+
| createUserConnectorResourceMutation | connectorDefinitionName |
218+
| deleteUserConnectorResourceMutation | payload |
219+
| updateUserConnectorResourceMutation | payload |
220+
| renameUserConnectorResource | payload |
221+
| testUserConnectorResourceConnectionAction | connectorDefinitionName |
222+
| connectUserConnectorResourceAction | connectorDefinitionName |
223+
| disconnectUserConnectorResourceAction | connectorDefinitionName |
124224

125225
### Metric
126226

127-
| function | params |
128-
| :------------------------------ | :------------------------------------------: |
129-
| listPipelineTriggerRecordsQuery | pageSize, nextPageToken, filter |
130-
| listTriggeredPipelineQuery | pageSize, nextPageToken, filter |
131-
| listTriggeredPipelineChartQuery | pageSize, nextPageToken, filter |
227+
| function | params |
228+
| :------------------------------ | :-----------------------------: |
229+
| listPipelineTriggerRecordsQuery | pageSize, nextPageToken, filter |
230+
| listTriggeredPipelineQuery | pageSize, nextPageToken, filter |
231+
| listTriggeredPipelineChartQuery | pageSize, nextPageToken, filter |
132232

133-
modelDefinitionName,
233+
modelDefinitionName,
134234

135235
### Model
136236

137237
| function | params |
138238
| :------------------------ | :--------------------------------------------: |
139-
| getModelDefinitionQuery | modelDefinitionName, accessToken |
140-
| listModelDefinitionsQuery | pageSize, nextPageToken, accessToken |
141-
| getUserModelQuery | modelName, accessToken |
142-
| listModelsQuery | pageSize, nextPageToken, accessToken |
143-
| listUserModelsQuery | userName, pageSize, nextPageToken, accessToken |
144-
| getUserModelReadmeQuery | modelName, accessToken |
145-
| watchUserModel | modelName, accessToken |
146-
| createUserModelMutation | userName, payload, accessToken |
147-
| updateModelMutation | payload, accessToken |
148-
| deleteUserModelMutation | modelName, accessToken |
149-
| deployUserModelAction | modelName, accessToken |
150-
| undeployUserModeleAction | modelName, accessToken |
239+
| getModelDefinitionQuery | modelDefinitionName |
240+
| listModelDefinitionsQuery | pageSize, nextPageToken |
241+
| getUserModelQuery | modelName |
242+
| listModelsQuery | pageSize, nextPageToken |
243+
| listUserModelsQuery | userName, pageSize, nextPageToken |
244+
| getUserModelReadmeQuery | modelName |
245+
| watchUserModel | modelName |
246+
| createUserModelMutation | userName, payload |
247+
| updateModelMutation | payload |
248+
| deleteUserModelMutation | modelName |
249+
| deployUserModelAction | modelName |
250+
| undeployUserModeleAction | modelName |
151251

152252
### Operation
153253

154254
| function | params |
155255
| :------------------------ | :------------------------: |
156-
| getOperationQuery | operationName, accessToken |
157-
| checkUntilOperationIsDoen | operationName, accessToken |
256+
| getOperationQuery | operationName |
257+
| checkUntilOperationIsDoen | operationName |
158258

159259
### Mgmt
160260

161261
| function | params |
162262
| :--------------------- | :----------------------------------: |
163263
| getUserQuery | accessToken |
164-
| checkUserIdExist | id, accessToken |
165-
| getApiTokenQuery | tokenName, accessToken |
166-
| listApiTokensQuery | pageSize, nextPageToken, accessToken |
167-
| updateUserMutation | payload, accessToken |
168-
| createApiTokenMutation | payload, accessToken |
169-
| deleteApiTokenMutation | tokenName, accessToken |
264+
| checkUserIdExist | id |
265+
| getApiTokenQuery | tokenName |
266+
| listApiTokensQuery | pageSize, nextPageToken |
267+
| updateUserMutation | payload |
268+
| createApiTokenMutation | payload |
269+
| deleteApiTokenMutation | tokenName |
170270

171271
## Error Handling:
172272

0 commit comments

Comments
 (0)