Skip to content

Commit

Permalink
feat: support moving file and folder
Browse files Browse the repository at this point in the history
  • Loading branch information
t-benze committed Nov 12, 2024
1 parent c7d1024 commit badcb64
Show file tree
Hide file tree
Showing 28 changed files with 1,255 additions and 740 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { tokens, makeStyles, Body2 } from '@fluentui/react-components';
import { FolderRegular, DocumentRegular } from '@fluentui/react-icons';
import { useTranslation } from 'react-i18next';
import { documentsApi } from '~/chrome-extension/utils/apiClient';
import { ListDocuments200ResponseInner as Document } from '@inkstain/client-api';
import { DocumentListItem as Document } from '@inkstain/client-api';
import { PopupContext } from '~/chrome-extension/components/SpacePopup/context';

interface FolderTreeProps {
Expand Down
2 changes: 1 addition & 1 deletion lib/client-api/src/lib/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ models/CreateSpaceRequest.ts
models/DocumentLayoutTextBlock.ts
models/DocumentLayoutTextLine.ts
models/DocumentLayoutTextLineBoundingBox.ts
models/DocumentListItem.ts
models/DocumentMeta.ts
models/DocumentMetaAttributesValue.ts
models/DocumentSearchResult.ts
Expand All @@ -45,7 +46,6 @@ models/IntelligenceAnalyzeDocumentRequest.ts
models/IntelligenceDocLayout200Response.ts
models/IntelligenceDocLayoutStatus200Response.ts
models/ListDirectories200ResponseInner.ts
models/ListDocuments200ResponseInner.ts
models/PlatformInfo200Response.ts
models/PlatformInfo200ResponseAttributes.ts
models/ProxyRequestOperationEnum.ts
Expand Down
40 changes: 20 additions & 20 deletions lib/client-api/src/lib/apis/DocumentsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import type {
AddDocumentTagsRequest,
AddUpdateDocumentAttributesRequest,
Annotation,
DocumentListItem,
ImportDocumentRequest,
ListDocuments200ResponseInner,
RemoveDocumentTagsRequest,
} from '../models/index';
import {
Expand All @@ -28,10 +28,10 @@ import {
AddUpdateDocumentAttributesRequestToJSON,
AnnotationFromJSON,
AnnotationToJSON,
DocumentListItemFromJSON,
DocumentListItemToJSON,
ImportDocumentRequestFromJSON,
ImportDocumentRequestToJSON,
ListDocuments200ResponseInnerFromJSON,
ListDocuments200ResponseInnerToJSON,
RemoveDocumentTagsRequestFromJSON,
RemoveDocumentTagsRequestToJSON,
} from '../models/index';
Expand Down Expand Up @@ -138,13 +138,13 @@ export interface RemoveDocumentTagsOperationRequest {
export interface RenameDocumentRequest {
spaceKey: string;
path: string;
newName: string;
newPath: string;
}

export interface RenameFolderRequest {
spaceKey: string;
path: string;
newName: string;
newPath: string;
}

export interface UpdateDocumentAnnotationRequest {
Expand Down Expand Up @@ -1211,7 +1211,7 @@ export class DocumentsApi extends runtime.BaseAPI {
async listDocumentsRaw(
requestParameters: ListDocumentsRequest,
initOverrides?: RequestInit | runtime.InitOverrideFunction
): Promise<runtime.ApiResponse<Array<ListDocuments200ResponseInner>>> {
): Promise<runtime.ApiResponse<Array<DocumentListItem>>> {
if (
requestParameters.spaceKey === null ||
requestParameters.spaceKey === undefined
Expand Down Expand Up @@ -1258,7 +1258,7 @@ export class DocumentsApi extends runtime.BaseAPI {
);

return new runtime.JSONApiResponse(response, (jsonValue) =>
jsonValue.map(ListDocuments200ResponseInnerFromJSON)
jsonValue.map(DocumentListItemFromJSON)
);
}

Expand All @@ -1268,7 +1268,7 @@ export class DocumentsApi extends runtime.BaseAPI {
async listDocuments(
requestParameters: ListDocumentsRequest,
initOverrides?: RequestInit | runtime.InitOverrideFunction
): Promise<Array<ListDocuments200ResponseInner>> {
): Promise<Array<DocumentListItem>> {
const response = await this.listDocumentsRaw(
requestParameters,
initOverrides
Expand Down Expand Up @@ -1441,12 +1441,12 @@ export class DocumentsApi extends runtime.BaseAPI {
}

if (
requestParameters.newName === null ||
requestParameters.newName === undefined
requestParameters.newPath === null ||
requestParameters.newPath === undefined
) {
throw new runtime.RequiredError(
'newName',
'Required parameter requestParameters.newName was null or undefined when calling renameDocument.'
'newPath',
'Required parameter requestParameters.newPath was null or undefined when calling renameDocument.'
);
}

Expand All @@ -1456,8 +1456,8 @@ export class DocumentsApi extends runtime.BaseAPI {
queryParameters['path'] = requestParameters.path;
}

if (requestParameters.newName !== undefined) {
queryParameters['newName'] = requestParameters.newName;
if (requestParameters.newPath !== undefined) {
queryParameters['newPath'] = requestParameters.newPath;
}

const headerParameters: runtime.HTTPHeaders = {};
Expand Down Expand Up @@ -1516,12 +1516,12 @@ export class DocumentsApi extends runtime.BaseAPI {
}

if (
requestParameters.newName === null ||
requestParameters.newName === undefined
requestParameters.newPath === null ||
requestParameters.newPath === undefined
) {
throw new runtime.RequiredError(
'newName',
'Required parameter requestParameters.newName was null or undefined when calling renameFolder.'
'newPath',
'Required parameter requestParameters.newPath was null or undefined when calling renameFolder.'
);
}

Expand All @@ -1531,8 +1531,8 @@ export class DocumentsApi extends runtime.BaseAPI {
queryParameters['path'] = requestParameters.path;
}

if (requestParameters.newName !== undefined) {
queryParameters['newName'] = requestParameters.newName;
if (requestParameters.newPath !== undefined) {
queryParameters['newPath'] = requestParameters.newPath;
}

const headerParameters: runtime.HTTPHeaders = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,43 @@ import { exists, mapValues } from '../runtime';
/**
*
* @export
* @interface ListDocuments200ResponseInner
* @interface DocumentListItem
*/
export interface ListDocuments200ResponseInner {
export interface DocumentListItem {
/**
* The name of the file or folder.
* @type {string}
* @memberof ListDocuments200ResponseInner
* @memberof DocumentListItem
*/
name: string;
/**
* The type of the item (file or folder).
* @type {string}
* @memberof ListDocuments200ResponseInner
* @memberof DocumentListItem
*/
type: ListDocuments200ResponseInnerTypeEnum;
type: DocumentListItemTypeEnum;
/**
* The full path of the file or folder.
* @type {string}
* @memberof ListDocuments200ResponseInner
* @memberof DocumentListItem
*/
path: string;
}

/**
* @export
*/
export const ListDocuments200ResponseInnerTypeEnum = {
export const DocumentListItemTypeEnum = {
File: 'file',
Folder: 'folder',
} as const;
export type ListDocuments200ResponseInnerTypeEnum =
(typeof ListDocuments200ResponseInnerTypeEnum)[keyof typeof ListDocuments200ResponseInnerTypeEnum];
export type DocumentListItemTypeEnum =
(typeof DocumentListItemTypeEnum)[keyof typeof DocumentListItemTypeEnum];

/**
* Check if a given object implements the ListDocuments200ResponseInner interface.
* Check if a given object implements the DocumentListItem interface.
*/
export function instanceOfListDocuments200ResponseInner(
value: object
): boolean {
export function instanceOfDocumentListItem(value: object): boolean {
let isInstance = true;
isInstance = isInstance && 'name' in value;
isInstance = isInstance && 'type' in value;
Expand All @@ -63,16 +61,14 @@ export function instanceOfListDocuments200ResponseInner(
return isInstance;
}

export function ListDocuments200ResponseInnerFromJSON(
json: any
): ListDocuments200ResponseInner {
return ListDocuments200ResponseInnerFromJSONTyped(json, false);
export function DocumentListItemFromJSON(json: any): DocumentListItem {
return DocumentListItemFromJSONTyped(json, false);
}

export function ListDocuments200ResponseInnerFromJSONTyped(
export function DocumentListItemFromJSONTyped(
json: any,
ignoreDiscriminator: boolean
): ListDocuments200ResponseInner {
): DocumentListItem {
if (json === undefined || json === null) {
return json;
}
Expand All @@ -83,9 +79,7 @@ export function ListDocuments200ResponseInnerFromJSONTyped(
};
}

export function ListDocuments200ResponseInnerToJSON(
value?: ListDocuments200ResponseInner | null
): any {
export function DocumentListItemToJSON(value?: DocumentListItem | null): any {
if (value === undefined) {
return undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/client-api/src/lib/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export * from './CreateSpaceRequest';
export * from './DocumentLayoutTextBlock';
export * from './DocumentLayoutTextLine';
export * from './DocumentLayoutTextLineBoundingBox';
export * from './DocumentListItem';
export * from './DocumentMeta';
export * from './DocumentMetaAttributesValue';
export * from './DocumentSearchResult';
Expand All @@ -36,7 +37,6 @@ export * from './IntelligenceAnalyzeDocumentRequest';
export * from './IntelligenceDocLayout200Response';
export * from './IntelligenceDocLayoutStatus200Response';
export * from './ListDirectories200ResponseInner';
export * from './ListDocuments200ResponseInner';
export * from './PlatformInfo200Response';
export * from './PlatformInfo200ResponseAttributes';
export * from './ProxyRequestOperationEnum';
Expand Down
41 changes: 41 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
},
"private": true,
"dependencies": {
"@dnd-kit/core": "^6.1.0",
"@dnd-kit/utilities": "^3.2.2",
"@fluentui/react-components": "^9.44.5",
"@fluentui/react-hooks": "^8.6.36",
"@fluentui/react-icons": "^2.0.225",
Expand Down
19 changes: 19 additions & 0 deletions server/src/assets/schema/components.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ components:
key:
type: string
description: Key of the space.
DocumentListItem:
type: object
required:
- path
- name
- type
properties:
name:
type: string
description: The name of the file or folder.
type:
type: string
enum:
- file
- folder
description: The type of the item (file or folder).
path:
type: string
description: The full path of the file or folder.
CreateSpaceOperationType:
type: string
enum:
Expand Down
Loading

0 comments on commit badcb64

Please sign in to comment.