From 5c62fdd28222be536412fb1ac3059e4653fdafd8 Mon Sep 17 00:00:00 2001 From: EiffelFly <57251712+EiffelFly@users.noreply.github.com> Date: Thu, 9 May 2024 14:49:08 +0800 Subject: [PATCH 1/2] fix: fix eslint config --- .eslintrc.cjs | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .eslintrc.cjs diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 0000000..d312170 --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,10 @@ +module.exports = { + root: true, + extends: ["@instill-ai/eslint-config-cortex"], + ignorePatterns: [ + ".eslintrc.cjs", + "tsup.config.ts", + "vitest.config.ts", + "dist/", + ], +}; From e2e9798ff6bd6ac51a73a2255b8c56241ae37c4e Mon Sep 17 00:00:00 2001 From: Naman Anand Date: Thu, 9 May 2024 17:48:25 +0530 Subject: [PATCH 2/2] fix: lint fix --- .eslintrc.cjs | 3 +++ src/connector/ConnectorClient.ts | 2 +- src/connector/index.ts | 3 +-- src/helper/axiosInstance.ts | 2 +- src/helper/createClient.ts | 8 ++++---- src/helper/index.ts | 2 +- src/index.ts | 15 +++++++-------- src/metric/MetricClient.ts | 2 +- src/metric/index.ts | 1 + src/mgmt/AuthClient.ts | 8 ++++++-- src/mgmt/index.ts | 2 +- src/mgmt/mutation.ts | 1 - src/model/ModelClient.ts | 2 +- src/model/index.ts | 2 +- src/operation/OperationClient.ts | 2 +- src/operation/index.ts | 2 +- src/organization/OrganizationClient.ts | 2 +- src/organization/index.ts | 3 ++- src/pipeline/PipelineClient.ts | 6 ++---- src/pipeline/index.ts | 2 +- 20 files changed, 37 insertions(+), 33 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index d312170..f4d7256 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -6,5 +6,8 @@ module.exports = { "tsup.config.ts", "vitest.config.ts", "dist/", + "examples/", + "setupTests.ts", + "turbo.json", ], }; diff --git a/src/connector/ConnectorClient.ts b/src/connector/ConnectorClient.ts index 1ef669e..d7c1305 100644 --- a/src/connector/ConnectorClient.ts +++ b/src/connector/ConnectorClient.ts @@ -29,7 +29,7 @@ class ConnectorClient { private axiosInstance: AxiosInstance; constructor(baseUrl: string, appVersion: string, apiToken: string) { - let URL: Nullable = `${baseUrl}/vdp/${appVersion}`; + const URL: Nullable = `${baseUrl}/vdp/${appVersion}`; this.axiosInstance = axios.create({ baseURL: URL, diff --git a/src/connector/index.ts b/src/connector/index.ts index 1dc24ee..593d635 100644 --- a/src/connector/index.ts +++ b/src/connector/index.ts @@ -1,3 +1,2 @@ export * from "./types"; -export * from "./ConnectorClient"; - +export { default } from "./ConnectorClient"; diff --git a/src/helper/axiosInstance.ts b/src/helper/axiosInstance.ts index 27f8566..2993dcd 100644 --- a/src/helper/axiosInstance.ts +++ b/src/helper/axiosInstance.ts @@ -7,7 +7,7 @@ const createAxiosInstance = ( appVersion: string, product: string ): AxiosInstance => { - let URL: Nullable = `${baseUrl}/${product}/${appVersion}`; + const URL: Nullable = `${baseUrl}/${product}/${appVersion}`; return axios.create({ baseURL: URL, diff --git a/src/helper/createClient.ts b/src/helper/createClient.ts index 77c398c..559ff69 100644 --- a/src/helper/createClient.ts +++ b/src/helper/createClient.ts @@ -25,13 +25,13 @@ export function createClient( } } - if (!process.env.API_GATEWAY_URL && !env("API_GATEWAY_URL")) { + if (!env("API_GATEWAY_URL")) { throw new Error("API_GATEWAY_URL or API_GATEWAY_URL is not defined"); } - let baseURL: Nullable = `${ - process.env.API_GATEWAY_URL ?? env("API_GATEWAY_URL") - }/${product}/${env("API_VERSION")}`; + const baseURL: Nullable = `${env("API_GATEWAY_URL")}/${product}/${env( + "API_VERSION" + )}`; return axios.create({ baseURL, diff --git a/src/helper/index.ts b/src/helper/index.ts index 2015a8f..b23abf1 100644 --- a/src/helper/index.ts +++ b/src/helper/index.ts @@ -2,4 +2,4 @@ export { createClient } from "./createClient"; export { getQueryString } from "./getQueryString"; export { getInstillApiErrorMessage } from "./getInstillApiErrorMessage"; export * from "./config"; -export * from "./axiosInstance"; +export { default } from "./axiosInstance"; diff --git a/src/index.ts b/src/index.ts index 781224d..a6d2c40 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,10 @@ -import ConnectorClient from "./connector/ConnectorClient"; -import MetricClient from "./metric/MetricClient"; -import AuthClient from "./mgmt/AuthClient"; -import ModelClient from "./model/ModelClient"; -import OperationClient from "./operation/OperationClient"; -import PipelineClient from "./pipeline/PipelineClient"; -import OrganizationClient from "./organization/OrganizationClient"; +import ConnectorClient from "./connector"; +import MetricClient from "./metric"; +import AuthClient from "./mgmt"; +import ModelClient from "./model"; +import OperationClient from "./operation"; +import OrganizationClient from "./organization"; +import PipelineClient from "./pipeline"; class InstillClient { public Pipeline: PipelineClient; @@ -30,7 +30,6 @@ export * from "./types"; export * from "./connector"; export * from "./helper"; export * from "./metric"; -export * from "./mgmt"; export * from "./model"; export * from "./operation"; export * from "./pipeline"; diff --git a/src/metric/MetricClient.ts b/src/metric/MetricClient.ts index 9110499..77c0777 100644 --- a/src/metric/MetricClient.ts +++ b/src/metric/MetricClient.ts @@ -10,7 +10,7 @@ class MetricClient { private axiosInstance: AxiosInstance; constructor(baseUrl: string, appVersion: string, apiToken: string) { - let URL: Nullable = `${baseUrl}/core/${appVersion}`; + const URL: Nullable = `${baseUrl}/core/${appVersion}`; this.axiosInstance = axios.create({ baseURL: URL, diff --git a/src/metric/index.ts b/src/metric/index.ts index 18b29ab..3fe31d5 100644 --- a/src/metric/index.ts +++ b/src/metric/index.ts @@ -1 +1,2 @@ export * from "./pipeline"; +export { default } from "./MetricClient"; diff --git a/src/mgmt/AuthClient.ts b/src/mgmt/AuthClient.ts index 4154af8..ec087cb 100644 --- a/src/mgmt/AuthClient.ts +++ b/src/mgmt/AuthClient.ts @@ -30,7 +30,7 @@ class AuthClient { private axiosInstance: AxiosInstance; constructor(baseUrl: string, appVersion: string, apiToken: string) { - let URL: Nullable = `${baseUrl}/core/${appVersion}`; + const URL: Nullable = `${baseUrl}/core/${appVersion}`; this.axiosInstance = axios.create({ baseURL: URL, @@ -84,7 +84,11 @@ class AuthClient { * MGMT Mutation * -----------------------------------------------------------------------*/ - async updateAuthenticatedUserMutation({ payload }: { payload: Partial }) { + async updateAuthenticatedUserMutation({ + payload, + }: { + payload: Partial; + }) { return updateAuthenticatedUserMutation({ axiosInstance: this.axiosInstance, payload: payload, diff --git a/src/mgmt/index.ts b/src/mgmt/index.ts index 0e48635..11c6e4b 100644 --- a/src/mgmt/index.ts +++ b/src/mgmt/index.ts @@ -1 +1 @@ -export * from "./AuthClient"; +export { default } from "./AuthClient"; diff --git a/src/mgmt/mutation.ts b/src/mgmt/mutation.ts index e8b2e3f..ecd54c3 100644 --- a/src/mgmt/mutation.ts +++ b/src/mgmt/mutation.ts @@ -5,7 +5,6 @@ import { CreateApiTokenPayload, CreateApiTokenResponse, UpdateUserResponse, - User, } from "./types"; export async function updateAuthenticatedUserMutation({ diff --git a/src/model/ModelClient.ts b/src/model/ModelClient.ts index 3b18371..ad011f6 100644 --- a/src/model/ModelClient.ts +++ b/src/model/ModelClient.ts @@ -20,7 +20,7 @@ class ModelClient { private axiosInstance: AxiosInstance; constructor(baseUrl: string, appVersion: string, apiToken: string) { - let URL: Nullable = `${baseUrl}/model/${appVersion}`; + const URL: Nullable = `${baseUrl}/model/${appVersion}`; this.axiosInstance = axios.create({ baseURL: URL, diff --git a/src/model/index.ts b/src/model/index.ts index 8395afc..8aa7a9a 100644 --- a/src/model/index.ts +++ b/src/model/index.ts @@ -1,2 +1,2 @@ export * from "./types"; -export * from "./ModelClient"; +export { default } from "./ModelClient"; diff --git a/src/operation/OperationClient.ts b/src/operation/OperationClient.ts index 67bbf5f..7a49d5a 100644 --- a/src/operation/OperationClient.ts +++ b/src/operation/OperationClient.ts @@ -6,7 +6,7 @@ class OperationClient { private axiosInstance: AxiosInstance; constructor(baseUrl: string, appVersion: string, apiToken: string) { - let URL: Nullable = `${baseUrl}/model/${appVersion}`; + const URL: Nullable = `${baseUrl}/model/${appVersion}`; this.axiosInstance = axios.create({ baseURL: URL, diff --git a/src/operation/index.ts b/src/operation/index.ts index c7cd75f..b8f42ec 100644 --- a/src/operation/index.ts +++ b/src/operation/index.ts @@ -1,2 +1,2 @@ export * from "./types"; -export * from "./OperationClient"; +export { default } from "./OperationClient"; diff --git a/src/organization/OrganizationClient.ts b/src/organization/OrganizationClient.ts index afc7243..1c1094f 100644 --- a/src/organization/OrganizationClient.ts +++ b/src/organization/OrganizationClient.ts @@ -26,7 +26,7 @@ class OrganizationClient { private axiosInstance: AxiosInstance; constructor(baseUrl: string, appVersion: string, apiToken: string) { - let URL: Nullable = `${baseUrl}/core/${appVersion}`; + const URL: Nullable = `${baseUrl}/core/${appVersion}`; this.axiosInstance = axios.create({ baseURL: URL, diff --git a/src/organization/index.ts b/src/organization/index.ts index ec576bd..6f7b4c1 100644 --- a/src/organization/index.ts +++ b/src/organization/index.ts @@ -1,2 +1,3 @@ export * from "./mutations"; -export * from "./queries"; \ No newline at end of file +export * from "./queries"; +export { default } from "./OrganizationClient"; diff --git a/src/pipeline/PipelineClient.ts b/src/pipeline/PipelineClient.ts index f9733ee..e75f641 100644 --- a/src/pipeline/PipelineClient.ts +++ b/src/pipeline/PipelineClient.ts @@ -35,13 +35,13 @@ import { triggerUserPipelineReleaseAction, } from "./action"; -class PipelineClient { +export class PipelineClient { // Define your specific API methods here private axiosInstance: AxiosInstance; constructor(baseUrl: string, appVersion: string, apiToken: string) { - let URL: Nullable = `${baseUrl}/vdp/${appVersion}`; + const URL: Nullable = `${baseUrl}/vdp/${appVersion}`; this.axiosInstance = axios.create({ baseURL: URL, @@ -58,7 +58,6 @@ class PipelineClient { async listPipelinesQuery({ pageSize, nextPageToken, - enablePagination, }: { pageSize: Nullable; nextPageToken: Nullable; @@ -76,7 +75,6 @@ class PipelineClient { pageSize, nextPageToken, userName, - enablePagination, }: { pageSize: Nullable; nextPageToken: Nullable; diff --git a/src/pipeline/index.ts b/src/pipeline/index.ts index fa0d1a2..36a2e67 100644 --- a/src/pipeline/index.ts +++ b/src/pipeline/index.ts @@ -1,2 +1,2 @@ export * from "./types"; -export * from "./PipelineClient"; +export { default } from "./PipelineClient";