Skip to content

Commit fbcda4f

Browse files
chore: Namananand/ins 1898 make changes to use sdk independently (#6)
Because - make changes to use sdk independently This commit - make changes to use sdk independently
1 parent 01a0b5f commit fbcda4f

29 files changed

+211
-132
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @EiffelFly @xiaofei-du
1+
* @EiffelFly @xiaofei-du @iamnamananand996

examples/next-app/.env

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
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-
NEXT_PUBLIC_MODEL_BACKEND_BASE_URL=http://localhost:8083
1+
API_VERSION=v1alpha
2+
INSTILL_AI_USER_COOKIE_NAME=instill-ai-user
3+
APP_EDITION=local-ce:dev
4+
API_GATEWAY_URL=http://localhost:8080
5+
SELF_SIGNED_CERTIFICATION=false
6+
DISABLE_CREATE_UPDATE_DELETE_RESOURCE=false
7+
LIST_PAGE_SIZE=6
8+
USAGE_COLLECTION_ENABLED=true
9+
SET_SECURE_COOKIE=false
10+
AMPLITUDE_KEY=9823fa6e3ff904bec67a8fc90db82fb9
11+
APP_BASE_URL=http://localhost:3000
12+
MGMT_BACKEND_BASE_URL=http://localhost:8084
13+
PIPELINE_BACKEND_BASE_URL=http://localhost:8081
14+
CONNECTOR_BACKEND_BASE_URL=http://localhost:8082
15+
MODEL_BACKEND_BASE_URL=http://localhost:8083

examples/next-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"@instill-ai/typescript-sdk": "^1.0.2",
12+
"@instill-ai/typescript-sdk": "^0.0.3-rc.0",
1313
"@types/node": "20.6.2",
1414
"@types/react": "18.2.22",
1515
"@types/react-dom": "18.2.7",

examples/next-app/pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/next-app/public/__env.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/next-app/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
}
1919
},
2020
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
21-
"exclude": ["node_modules"]
21+
"exclude": ["node_modules", "examples"]
2222
}

examples/node-app/.env

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
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
1+
API_VERSION=v1alpha
2+
INSTILL_AI_USER_COOKIE_NAME=instill-ai-user
3+
APP_EDITION=local-ce:dev
4+
API_GATEWAY_URL=http://localhost:8080
5+
SELF_SIGNED_CERTIFICATION=false
6+
DISABLE_CREATE_UPDATE_DELETE_RESOURCE=false
7+
LIST_PAGE_SIZE=6
8+
USAGE_COLLECTION_ENABLED=true
9+
SET_SECURE_COOKIE=false
10+
AMPLITUDE_KEY=9823fa6e3ff904bec67a8fc90db82fb9
11+
APP_BASE_URL=http://localhost:3000
12+
MGMT_BACKEND_BASE_URL=http://localhost:8084
13+
PIPELINE_BACKEND_BASE_URL=http://localhost:8081
14+
CONNECTOR_BACKEND_BASE_URL=http://localhost:8082
1615
MODEL_BACKEND_BASE_URL=http://localhost:8083

examples/node-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "",
55
"main": "index.js",
66
"dependencies": {
7-
"@instill-ai/typescript-sdk": "^0.0.1",
7+
"@instill-ai/typescript-sdk": "^0.0.3-rc.0",
88
"dotenv": "^16.3.1",
99
"express": "^4.18.2"
1010
},

examples/node-app/pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generate_proto.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ cp ../buf.gen.yaml ./
1212

1313
buf generate --template buf.gen.yaml
1414

15+
cd ..
1516
rm -rf protobufs
1617

1718
echo "TypeScript code generation completed!"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@instill-ai/typescript-sdk",
3-
"version": "0.0.2",
3+
"version": "0.0.3-rc.0",
44
"description": "Instill AI's Typescript SDK",
55
"repository": "https://github.com/instill-ai/typescript-sdk.git",
66
"bugs": "https://github.com/instill-ai/community/issues",

src/connector/actions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Nullable } from "../types";
2-
import { createInstillAxiosClient } from "../helper";
2+
import { createClient } from "../helper";
33
import { ConnectorResource, ConnectorResourceState } from "./types";
44

55
export type TestUserConnectorResourceConnectionResponse = {
@@ -14,7 +14,7 @@ export async function testUserConnectorResourceConnectionAction({
1414
accessToken: Nullable<string>;
1515
}) {
1616
try {
17-
const client = createInstillAxiosClient(accessToken, "vdp");
17+
const client = createClient(accessToken, "vdp");
1818
const { data } =
1919
await client.post<TestUserConnectorResourceConnectionResponse>(
2020
`/${connectorResourceName}/testConnection`
@@ -37,7 +37,7 @@ export async function connectUserConnectorResourceAction({
3737
accessToken: Nullable<string>;
3838
}) {
3939
try {
40-
const client = createInstillAxiosClient(accessToken, "vdp");
40+
const client = createClient(accessToken, "vdp");
4141
const { data } = await client.post<ConnectUserConnectorResourceResponse>(
4242
`/${connectorResourceName}/connect`
4343
);
@@ -59,7 +59,7 @@ export async function disconnectUserConnectorResourceAction({
5959
accessToken: Nullable<string>;
6060
}) {
6161
try {
62-
const client = createInstillAxiosClient(accessToken, "vdp");
62+
const client = createClient(accessToken, "vdp");
6363
const { data } = await client.post<DisconnectUserConnectorResourceResponse>(
6464
`/${connectorResourceName}/disconnect`
6565
);

src/connector/mutations.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AirbyteFieldValues } from "@instill-ai/toolkit";
22
import { Nullable } from "../types";
3-
import { createInstillAxiosClient } from "../helper";
3+
import { createClient } from "../helper";
44
import { ConnectorResource } from "./types";
55

66
export type CreateUserConnectorResourcePayload = {
@@ -24,7 +24,7 @@ export async function createUserConnectorResourceMutation({
2424
accessToken: Nullable<string>;
2525
}) {
2626
try {
27-
const client = createInstillAxiosClient(accessToken, "vdp");
27+
const client = createClient(accessToken, "vdp");
2828

2929
const res = await client.post<CreateUserConnectorResourceResponse>(
3030
`${userName}/connector-resources`,
@@ -44,7 +44,7 @@ export async function deleteUserConnectorResourceMutation({
4444
accessToken: Nullable<string>;
4545
}) {
4646
try {
47-
const client = createInstillAxiosClient(accessToken, "vdp");
47+
const client = createClient(accessToken, "vdp");
4848

4949
await client.delete(`/${connectorResourceName}`);
5050
} catch (err) {
@@ -71,7 +71,7 @@ export async function updateUserConnectorResourceMutation({
7171
accessToken: Nullable<string>;
7272
}) {
7373
try {
74-
const client = createInstillAxiosClient(accessToken, "vdp");
74+
const client = createClient(accessToken, "vdp");
7575

7676
const res = await client.patch<UpdateUserConnectorResourceResponse>(
7777
`/${payload.connectorResourceName}`,
@@ -103,7 +103,7 @@ export async function renameUserConnectorResource({
103103
accessToken: Nullable<string>;
104104
}) {
105105
try {
106-
const client = createInstillAxiosClient(accessToken, "vdp");
106+
const client = createClient(accessToken, "vdp");
107107

108108
const { data } = await client.post<RenameUserConnectorResourceResponse>(
109109
`/${payload.name}/rename`,

src/connector/queries.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Nullable } from "../types";
2-
import { createInstillAxiosClient, getQueryString } from "../helper";
2+
import { createClient, getQueryString } from "../helper";
33
import {
44
ConnectorDefinition,
55
ConnectorResourceWatchState,
@@ -24,7 +24,7 @@ export async function listConnectorResourcesQuery({
2424
filter: Nullable<string>;
2525
}) {
2626
try {
27-
const client = createInstillAxiosClient(accessToken, "vdp");
27+
const client = createClient(accessToken, "vdp");
2828
const connectors: ConnectorResourceWithDefinition[] = [];
2929

3030
const queryString = getQueryString({
@@ -76,7 +76,7 @@ export async function listUserConnectorResourcesQuery({
7676
filter: Nullable<string>;
7777
}) {
7878
try {
79-
const client = createInstillAxiosClient(accessToken, "vdp");
79+
const client = createClient(accessToken, "vdp");
8080
const connectors: ConnectorResourceWithDefinition[] = [];
8181

8282
const queryString = getQueryString({
@@ -127,7 +127,7 @@ export async function listConnectorDefinitionsQuery({
127127
filter: Nullable<string>;
128128
}) {
129129
try {
130-
const client = createInstillAxiosClient(accessToken, "vdp");
130+
const client = createClient(accessToken, "vdp");
131131
const connectorDefinitions: ConnectorDefinition[] = [];
132132

133133
const queryString = getQueryString({
@@ -171,7 +171,7 @@ export async function getConnectorDefinitionQuery({
171171
accessToken: Nullable<string>;
172172
}) {
173173
try {
174-
const client = createInstillAxiosClient(accessToken, "vdp");
174+
const client = createClient(accessToken, "vdp");
175175

176176
const { data } = await client.get<GetConnectorDefinitionResponse>(
177177
`/${connectorDefinitionName}?view=VIEW_FULL`
@@ -195,7 +195,7 @@ export async function getUserConnectorResourceQuery({
195195
accessToken: Nullable<string>;
196196
}) {
197197
try {
198-
const client = createInstillAxiosClient(accessToken, "vdp");
198+
const client = createClient(accessToken, "vdp");
199199

200200
const { data } = await client.get<GetUserConnectorResourceResponse>(
201201
`/${connectorResourceName}?view=VIEW_FULL`
@@ -215,7 +215,7 @@ export async function watchUserConnectorResource({
215215
accessToken: Nullable<string>;
216216
}) {
217217
try {
218-
const client = createInstillAxiosClient(accessToken, "vdp");
218+
const client = createClient(accessToken, "vdp");
219219
const { data } = await client.get<ConnectorResourceWatchState>(
220220
`/${connectorResourceName}/watch`
221221
);

src/helper/createInstillAxiosClient.ts renamed to src/helper/createClient.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import axios from "axios";
22
import { env } from "./config";
33
import { Nullable } from "../types";
44

5-
export function createInstillAxiosClient(
5+
export function createClient(
66
accessToken: Nullable<string>,
77
product: "base" | "model" | "vdp"
88
) {
@@ -18,24 +18,19 @@ export function createInstillAxiosClient(
1818
}
1919
: {};
2020

21-
22-
console.log("process.env",process.env.API_GATEWAY_URL);
23-
24-
25-
2621
if (
27-
!process.env.NEXT_SERVER_API_GATEWAY_URL &&
28-
!env("NEXT_PUBLIC_API_GATEWAY_URL")
22+
!process.env.API_GATEWAY_URL &&
23+
!env("API_GATEWAY_URL")
2924
) {
3025
throw new Error(
31-
"NEXT_SERVER_API_GATEWAY_URL or NEXT_PUBLIC_API_GATEWAY_URL is not defined"
26+
"API_GATEWAY_URL or API_GATEWAY_URL is not defined"
3227
);
3328
}
3429

3530
let baseURL: Nullable<string> = `${
36-
process.env.NEXT_SERVER_API_GATEWAY_URL ??
37-
env("NEXT_PUBLIC_API_GATEWAY_URL")
38-
}/${product}/${env("NEXT_PUBLIC_API_VERSION")}`;
31+
process.env.API_GATEWAY_URL ??
32+
env("API_GATEWAY_URL")
33+
}/${product}/${env("API_VERSION")}`;
3934

4035
return axios.create({
4136
baseURL,

src/helper/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { createInstillAxiosClient } from "./createInstillAxiosClient";
1+
export { createClient } from "./createClient";
22
export { getQueryString } from "./getQueryString";
33
export { getInstillApiErrorMessage } from "./getInstillApiErrorMessage";
44
export * from "./config";

src/metric/pipeline/queries.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Nullable } from "../../types";
2-
import { createInstillAxiosClient, getQueryString } from "../../helper";
2+
import { createClient, getQueryString } from "../../helper";
33
import {
44
PipelineTriggerRecord,
55
PipelinesChart,
@@ -34,7 +34,7 @@ export async function listPipelineTriggerRecordsQuery({
3434
filter: Nullable<string>;
3535
}) {
3636
try {
37-
const client = createInstillAxiosClient(accessToken, "base");
37+
const client = createClient(accessToken, "base");
3838
const triggers: PipelineTriggerRecord[] = [];
3939

4040
const queryString = getQueryString({
@@ -78,7 +78,7 @@ export async function listTriggeredPipelineQuery({
7878
filter: Nullable<string>;
7979
}) {
8080
try {
81-
const client = createInstillAxiosClient(accessToken, "base");
81+
const client = createClient(accessToken, "base");
8282
const pipelines: TriggeredPipeline[] = [];
8383

8484
const queryString = getQueryString({
@@ -122,7 +122,7 @@ export async function listTriggeredPipelineChartQuery({
122122
filter: Nullable<string>;
123123
}) {
124124
try {
125-
const client = createInstillAxiosClient(accessToken, "base");
125+
const client = createClient(accessToken, "base");
126126
const pipelinesChart: PipelinesChart[] = [];
127127

128128
const queryString = getQueryString({

0 commit comments

Comments
 (0)