Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @EiffelFly @xiaofei-du
* @EiffelFly @xiaofei-du @iamnamananand996
31 changes: 15 additions & 16 deletions examples/next-app/.env
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
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
NEXT_PUBLIC_MODEL_BACKEND_BASE_URL=http://localhost:8083
API_VERSION=v1alpha
INSTILL_AI_USER_COOKIE_NAME=instill-ai-user
APP_EDITION=local-ce:dev
API_GATEWAY_URL=http://localhost:8080
SELF_SIGNED_CERTIFICATION=false
DISABLE_CREATE_UPDATE_DELETE_RESOURCE=false
LIST_PAGE_SIZE=6
USAGE_COLLECTION_ENABLED=true
SET_SECURE_COOKIE=false
AMPLITUDE_KEY=9823fa6e3ff904bec67a8fc90db82fb9
APP_BASE_URL=http://localhost:3000
MGMT_BACKEND_BASE_URL=http://localhost:8084
PIPELINE_BACKEND_BASE_URL=http://localhost:8081
CONNECTOR_BACKEND_BASE_URL=http://localhost:8082
MODEL_BACKEND_BASE_URL=http://localhost:8083
2 changes: 1 addition & 1 deletion examples/next-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@instill-ai/typescript-sdk": "^1.0.2",
"@instill-ai/typescript-sdk": "^0.0.3-rc.0",
"@types/node": "20.6.2",
"@types/react": "18.2.22",
"@types/react-dom": "18.2.7",
Expand Down
8 changes: 4 additions & 4 deletions examples/next-app/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/next-app/public/__env.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/next-app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
"exclude": ["node_modules", "examples"]
}
29 changes: 14 additions & 15 deletions examples/node-app/.env
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
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
API_VERSION=v1alpha
INSTILL_AI_USER_COOKIE_NAME=instill-ai-user
APP_EDITION=local-ce:dev
API_GATEWAY_URL=http://localhost:8080
SELF_SIGNED_CERTIFICATION=false
DISABLE_CREATE_UPDATE_DELETE_RESOURCE=false
LIST_PAGE_SIZE=6
USAGE_COLLECTION_ENABLED=true
SET_SECURE_COOKIE=false
AMPLITUDE_KEY=9823fa6e3ff904bec67a8fc90db82fb9
APP_BASE_URL=http://localhost:3000
MGMT_BACKEND_BASE_URL=http://localhost:8084
PIPELINE_BACKEND_BASE_URL=http://localhost:8081
CONNECTOR_BACKEND_BASE_URL=http://localhost:8082
MODEL_BACKEND_BASE_URL=http://localhost:8083
2 changes: 1 addition & 1 deletion examples/node-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "index.js",
"dependencies": {
"@instill-ai/typescript-sdk": "^0.0.1",
"@instill-ai/typescript-sdk": "^0.0.3-rc.0",
"dotenv": "^16.3.1",
"express": "^4.18.2"
},
Expand Down
8 changes: 4 additions & 4 deletions examples/node-app/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions generate_proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ cp ../buf.gen.yaml ./

buf generate --template buf.gen.yaml

cd ..
rm -rf protobufs

echo "TypeScript code generation completed!"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@instill-ai/typescript-sdk",
"version": "0.0.2",
"version": "0.0.3-rc.0",
"description": "Instill AI's Typescript SDK",
"repository": "https://github.com/instill-ai/typescript-sdk.git",
"bugs": "https://github.com/instill-ai/community/issues",
Expand Down
8 changes: 4 additions & 4 deletions src/connector/actions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Nullable } from "../types";
import { createInstillAxiosClient } from "../helper";
import { createClient } from "../helper";
import { ConnectorResource, ConnectorResourceState } from "./types";

export type TestUserConnectorResourceConnectionResponse = {
Expand All @@ -14,7 +14,7 @@ export async function testUserConnectorResourceConnectionAction({
accessToken: Nullable<string>;
}) {
try {
const client = createInstillAxiosClient(accessToken, "vdp");
const client = createClient(accessToken, "vdp");
const { data } =
await client.post<TestUserConnectorResourceConnectionResponse>(
`/${connectorResourceName}/testConnection`
Expand All @@ -37,7 +37,7 @@ export async function connectUserConnectorResourceAction({
accessToken: Nullable<string>;
}) {
try {
const client = createInstillAxiosClient(accessToken, "vdp");
const client = createClient(accessToken, "vdp");
const { data } = await client.post<ConnectUserConnectorResourceResponse>(
`/${connectorResourceName}/connect`
);
Expand All @@ -59,7 +59,7 @@ export async function disconnectUserConnectorResourceAction({
accessToken: Nullable<string>;
}) {
try {
const client = createInstillAxiosClient(accessToken, "vdp");
const client = createClient(accessToken, "vdp");
const { data } = await client.post<DisconnectUserConnectorResourceResponse>(
`/${connectorResourceName}/disconnect`
);
Expand Down
10 changes: 5 additions & 5 deletions src/connector/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AirbyteFieldValues } from "@instill-ai/toolkit";
import { Nullable } from "../types";
import { createInstillAxiosClient } from "../helper";
import { createClient } from "../helper";
import { ConnectorResource } from "./types";

export type CreateUserConnectorResourcePayload = {
Expand All @@ -24,7 +24,7 @@ export async function createUserConnectorResourceMutation({
accessToken: Nullable<string>;
}) {
try {
const client = createInstillAxiosClient(accessToken, "vdp");
const client = createClient(accessToken, "vdp");

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

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

const res = await client.patch<UpdateUserConnectorResourceResponse>(
`/${payload.connectorResourceName}`,
Expand Down Expand Up @@ -103,7 +103,7 @@ export async function renameUserConnectorResource({
accessToken: Nullable<string>;
}) {
try {
const client = createInstillAxiosClient(accessToken, "vdp");
const client = createClient(accessToken, "vdp");

const { data } = await client.post<RenameUserConnectorResourceResponse>(
`/${payload.name}/rename`,
Expand Down
14 changes: 7 additions & 7 deletions src/connector/queries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Nullable } from "../types";
import { createInstillAxiosClient, getQueryString } from "../helper";
import { createClient, getQueryString } from "../helper";
import {
ConnectorDefinition,
ConnectorResourceWatchState,
Expand All @@ -24,7 +24,7 @@ export async function listConnectorResourcesQuery({
filter: Nullable<string>;
}) {
try {
const client = createInstillAxiosClient(accessToken, "vdp");
const client = createClient(accessToken, "vdp");
const connectors: ConnectorResourceWithDefinition[] = [];

const queryString = getQueryString({
Expand Down Expand Up @@ -76,7 +76,7 @@ export async function listUserConnectorResourcesQuery({
filter: Nullable<string>;
}) {
try {
const client = createInstillAxiosClient(accessToken, "vdp");
const client = createClient(accessToken, "vdp");
const connectors: ConnectorResourceWithDefinition[] = [];

const queryString = getQueryString({
Expand Down Expand Up @@ -127,7 +127,7 @@ export async function listConnectorDefinitionsQuery({
filter: Nullable<string>;
}) {
try {
const client = createInstillAxiosClient(accessToken, "vdp");
const client = createClient(accessToken, "vdp");
const connectorDefinitions: ConnectorDefinition[] = [];

const queryString = getQueryString({
Expand Down Expand Up @@ -171,7 +171,7 @@ export async function getConnectorDefinitionQuery({
accessToken: Nullable<string>;
}) {
try {
const client = createInstillAxiosClient(accessToken, "vdp");
const client = createClient(accessToken, "vdp");

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

const { data } = await client.get<GetUserConnectorResourceResponse>(
`/${connectorResourceName}?view=VIEW_FULL`
Expand All @@ -215,7 +215,7 @@ export async function watchUserConnectorResource({
accessToken: Nullable<string>;
}) {
try {
const client = createInstillAxiosClient(accessToken, "vdp");
const client = createClient(accessToken, "vdp");
const { data } = await client.get<ConnectorResourceWatchState>(
`/${connectorResourceName}/watch`
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios from "axios";
import { env } from "./config";
import { Nullable } from "../types";

export function createInstillAxiosClient(
export function createClient(
accessToken: Nullable<string>,
product: "base" | "model" | "vdp"
) {
Expand All @@ -18,24 +18,19 @@ export function createInstillAxiosClient(
}
: {};


console.log("process.env",process.env.API_GATEWAY_URL);



if (
!process.env.NEXT_SERVER_API_GATEWAY_URL &&
!env("NEXT_PUBLIC_API_GATEWAY_URL")
!process.env.API_GATEWAY_URL &&
!env("API_GATEWAY_URL")
) {
throw new Error(
"NEXT_SERVER_API_GATEWAY_URL or NEXT_PUBLIC_API_GATEWAY_URL is not defined"
"API_GATEWAY_URL or API_GATEWAY_URL is not defined"
);
}

let baseURL: Nullable<string> = `${
process.env.NEXT_SERVER_API_GATEWAY_URL ??
env("NEXT_PUBLIC_API_GATEWAY_URL")
}/${product}/${env("NEXT_PUBLIC_API_VERSION")}`;
process.env.API_GATEWAY_URL ??
env("API_GATEWAY_URL")
}/${product}/${env("API_VERSION")}`;

return axios.create({
baseURL,
Expand Down
2 changes: 1 addition & 1 deletion src/helper/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { createInstillAxiosClient } from "./createInstillAxiosClient";
export { createClient } from "./createClient";
export { getQueryString } from "./getQueryString";
export { getInstillApiErrorMessage } from "./getInstillApiErrorMessage";
export * from "./config";
8 changes: 4 additions & 4 deletions src/metric/pipeline/queries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Nullable } from "../../types";
import { createInstillAxiosClient, getQueryString } from "../../helper";
import { createClient, getQueryString } from "../../helper";
import {
PipelineTriggerRecord,
PipelinesChart,
Expand Down Expand Up @@ -34,7 +34,7 @@ export async function listPipelineTriggerRecordsQuery({
filter: Nullable<string>;
}) {
try {
const client = createInstillAxiosClient(accessToken, "base");
const client = createClient(accessToken, "base");
const triggers: PipelineTriggerRecord[] = [];

const queryString = getQueryString({
Expand Down Expand Up @@ -78,7 +78,7 @@ export async function listTriggeredPipelineQuery({
filter: Nullable<string>;
}) {
try {
const client = createInstillAxiosClient(accessToken, "base");
const client = createClient(accessToken, "base");
const pipelines: TriggeredPipeline[] = [];

const queryString = getQueryString({
Expand Down Expand Up @@ -122,7 +122,7 @@ export async function listTriggeredPipelineChartQuery({
filter: Nullable<string>;
}) {
try {
const client = createInstillAxiosClient(accessToken, "base");
const client = createClient(accessToken, "base");
const pipelinesChart: PipelinesChart[] = [];

const queryString = getQueryString({
Expand Down
Loading