Skip to content

Commit

Permalink
feat(catalog): feat expose helpers and static (#1531)
Browse files Browse the repository at this point in the history
Because

- expose helpers and static
  • Loading branch information
thewbuk authored Oct 11, 2024
1 parent e6c5381 commit 1235d62
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 26 deletions.
30 changes: 15 additions & 15 deletions packages/sdk/src/application/ApplicationClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class ApplicationClient extends APIResource {
const applications: Application[] = [];

const queryString = getQueryString({
baseURL: `/v1alpha/namespaces/${ownerId}/apps`,
baseURL: `/namespaces/${ownerId}/apps`,
pageSize,
pageToken,
view,
Expand Down Expand Up @@ -118,7 +118,7 @@ export class ApplicationClient extends APIResource {

try {
const queryString = getQueryString({
baseURL: `/v1alpha/namespaces/${ownerId}/apps`,
baseURL: `/namespaces/${ownerId}/apps`,
});

const data = await this._client.post<CreateApplicationResponse>(
Expand All @@ -141,7 +141,7 @@ export class ApplicationClient extends APIResource {

try {
const queryString = getQueryString({
baseURL: `/v1alpha/namespaces/${ownerId}/apps/${appId}`,
baseURL: `/namespaces/${ownerId}/apps/${appId}`,
});

const data = await this._client.put<UpdateApplicationResponse>(
Expand All @@ -163,7 +163,7 @@ export class ApplicationClient extends APIResource {
}: DeleteApplicationRequest): Promise<void> {
try {
const queryString = getQueryString({
baseURL: `/v1alpha/namespaces/${ownerId}/apps/${appId}`,
baseURL: `/namespaces/${ownerId}/apps/${appId}`,
});

await this._client.delete(queryString);
Expand Down Expand Up @@ -199,7 +199,7 @@ export class ApplicationClient extends APIResource {
const conversations: Conversation[] = [];

const queryString = getQueryString({
baseURL: `/v1alpha/namespaces/${ownerId}/apps/${appId}/conversations`,
baseURL: `/namespaces/${ownerId}/apps/${appId}/conversations`,
pageSize,
pageToken,
});
Expand Down Expand Up @@ -238,7 +238,7 @@ export class ApplicationClient extends APIResource {

try {
const queryString = getQueryString({
baseURL: `/v1alpha/namespaces/${ownerId}/apps/${appId}/conversations`,
baseURL: `/namespaces/${ownerId}/apps/${appId}/conversations`,
});

const response = await this._client.post<CreateConversationResponse>(
Expand All @@ -260,7 +260,7 @@ export class ApplicationClient extends APIResource {

try {
const queryString = getQueryString({
baseURL: `/v1alpha/namespaces/${namespaceId}/apps/${appId}/conversations/${conversationId}`,
baseURL: `/namespaces/${namespaceId}/apps/${appId}/conversations/${conversationId}`,
});

const response = await this._client.put<UpdateConversationResponse>(
Expand All @@ -280,7 +280,7 @@ export class ApplicationClient extends APIResource {

try {
const queryString = getQueryString({
baseURL: `/v1alpha/namespaces/${ownerId}/apps/${appId}/conversations/${conversationId}`,
baseURL: `/namespaces/${ownerId}/apps/${appId}/conversations/${conversationId}`,
});

await this._client.delete(queryString);
Expand Down Expand Up @@ -317,7 +317,7 @@ export class ApplicationClient extends APIResource {
const messages: Message[] = [];

const queryString = getQueryString({
baseURL: `/v1alpha/namespaces/${ownerId}/apps/${appId}/conversations/${conversationId}/messages`,
baseURL: `/namespaces/${ownerId}/apps/${appId}/conversations/${conversationId}/messages`,
});

const data = await this._client.get<ListMessagesResponse>(queryString);
Expand Down Expand Up @@ -354,7 +354,7 @@ export class ApplicationClient extends APIResource {

try {
const queryString = getQueryString({
baseURL: `/v1alpha/namespaces/${ownerId}/apps/${appId}/conversations/${conversationId}/messages`,
baseURL: `/namespaces/${ownerId}/apps/${appId}/conversations/${conversationId}/messages`,
});

const response = await this._client.post<CreateMessageResponse>(
Expand All @@ -376,7 +376,7 @@ export class ApplicationClient extends APIResource {

try {
const queryString = getQueryString({
baseURL: `/v1alpha/namespaces/${ownerId}/apps/${appId}/conversations/${conversationId}/messages/${messageUid}`,
baseURL: `/namespaces/${ownerId}/apps/${appId}/conversations/${conversationId}/messages/${messageUid}`,
});

const response = await this._client.put<UpdateMessageResponse>(
Expand All @@ -396,7 +396,7 @@ export class ApplicationClient extends APIResource {

try {
const queryString = getQueryString({
baseURL: `/v1alpha/namespaces/${ownerId}/apps/${appId}/conversations/${conversationId}/messages/${messageUid}`,
baseURL: `/namespaces/${ownerId}/apps/${appId}/conversations/${conversationId}/messages/${messageUid}`,
});

await this._client.delete(queryString);
Expand All @@ -413,7 +413,7 @@ export class ApplicationClient extends APIResource {

try {
const queryString = getQueryString({
baseURL: `/v1alpha/namespaces/${ownerId}/apps/${appId}/ai_assistant_playground/conversation`,
baseURL: `/namespaces/${ownerId}/apps/${appId}/ai_assistant_playground/conversation`,
});

const response =
Expand All @@ -431,7 +431,7 @@ export class ApplicationClient extends APIResource {

try {
const queryString = getQueryString({
baseURL: `/v1alpha/namespaces/${ownerId}/apps/${appId}/ai_assistant_playground/restart`,
baseURL: `/namespaces/${ownerId}/apps/${appId}/ai_assistant_playground/restart`,
});

const response =
Expand All @@ -449,7 +449,7 @@ export class ApplicationClient extends APIResource {

try {
const queryString = getQueryString({
baseURL: `/v1alpha/namespaces/${ownerId}/apps/${appId}/chat`,
baseURL: `/namespaces/${ownerId}/apps/${appId}/chat`,
});

const additionalHeaders = getInstillAdditionalHeaders({
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@instill-ai/toolkit",
"version": "0.106.3",
"version": "0.106.3-rc.7",
"description": "Instill AI's frontend toolkit",
"repository": "https://github.com/instill-ai/design-system.git",
"bugs": "https://github.com/instill-ai/design-system/issues",
Expand Down
11 changes: 4 additions & 7 deletions packages/toolkit/src/lib/vdp-sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,10 @@ export function getInstillApplicationAPIClient({
accessToken?: string;
}) {
if (!instillApplicationAPIClient) {
const apiGatewayUrl =
process.env.NEXT_PUBLIC_API_GATEWAY_URL ||
"https://api-d0.instill-inc.tech";
const apiVersion =
process.env.NEXT_PUBLIC_APPLICATION_API_VERSION || "v1alpha";

const baseURL = `${apiGatewayUrl}/${apiVersion}`;
const baseURL = `${
process.env.NEXT_SERVER_API_GATEWAY_URL ??
env("NEXT_PUBLIC_API_GATEWAY_URL")
}/${env("NEXT_PUBLIC_APPLICATION_API_VERSION")}`;

instillApplicationAPIClient = new InstillAPIClient({
baseURL,
Expand Down
4 changes: 2 additions & 2 deletions packages/toolkit/src/view/catalog/components/FileTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Button, Dialog, Icons, Tag } from "@instill-ai/design-system";
import { File } from "../../../lib/react-query-service/catalog/types";
import {
convertFileType,
formatDate,
formatDateFileTableRow,
formatFileSize,
truncateName,
} from "./lib/helpers";
Expand Down Expand Up @@ -63,7 +63,7 @@ export const FileTableRow = ({
<div>{`${item.totalChunks ?? "N/A"} chunks, ${item.totalTokens} tokens`}</div>
</div>
<div className="flex items-center justify-center text-semantic-bg-secondary-alt-primary product-body-text-3-regular">
{formatDate(item.createTime)}
{formatDateFileTableRow(item.createTime)}
</div>
<div className="flex items-center justify-center">
<Button
Expand Down
1 change: 1 addition & 0 deletions packages/toolkit/src/view/catalog/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ export * from "./CatalogCardMenu";
export * from "./WarnDiscardFilesDialog";
export * from "./CloneCatalogDialog";
export * from "./DragAndDropUpload";
export * from "./lib";
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export const formatFileSize = (bytes: number | undefined): string => {
return (bytes / Math.pow(1024, i)).toFixed(2) + " " + sizes[i];
};

export const formatDate = (dateString: string): string => {
export const formatDateFileTableRow = (dateString: string): string => {
const date = new Date(dateString);
return date.toLocaleString();
};
Expand Down
1 change: 1 addition & 0 deletions packages/toolkit/src/view/catalog/components/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./helpers";
export * from "./constant";
1 change: 1 addition & 0 deletions packages/toolkit/src/view/catalog/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./CatalogMainView";
export * from "./components";

0 comments on commit 1235d62

Please sign in to comment.