chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:24:55 +08:00
commit 7baeb17845
15305 changed files with 2077301 additions and 0 deletions
@@ -0,0 +1,31 @@
import { mergeConfig } from 'vite';
import svgr from 'vite-plugin-svgr';
/** @type { import('@storybook/react-vite').StorybookConfig } */
const config = {
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.tsx'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-onboarding',
'@storybook/addon-interactions',
],
framework: {
name: '@storybook/react-vite',
options: {},
},
docs: {
autodocs: 'tag',
},
viteFinal: config =>
mergeConfig(config, {
plugins: [
svgr({
svgrOptions: {
native: false,
},
}),
],
}),
};
export default config;
@@ -0,0 +1,14 @@
/** @type { import('@storybook/react').Preview } */
const preview = {
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};
export default preview;
@@ -0,0 +1,5 @@
const { defineConfig } = require('@coze-arch/stylelint-config');
module.exports = defineConfig({
extends: [],
});
@@ -0,0 +1,16 @@
# @coze-data/knowledge-resource-processor-core
> Project template for react component with storybook.
## Features
- [x] eslint & ts
- [x] esm bundle
- [x] umd bundle
- [x] storybook
## Commands
- init: `rush update`
- dev: `npm run dev`
- build: `npm run build`
@@ -0,0 +1,248 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React, { useState } from 'react';
import { type StoreApi, type UseBoundStore, create } from 'zustand';
import { expect, describe, test } from 'vitest';
import { fireEvent, render, screen } from '@testing-library/react';
import { Button } from '@coze-arch/bot-semi';
import { type ProgressItem, type UnitItem } from '../src/types/common';
import {
type UploadBaseState,
type UploadBaseAction,
type UploadConfig,
} from '../src/protocol/base';
import { Upload } from '../src/main';
import { CheckedStatus, CreateUnitStatus } from '../src/constants/common';
import { type ContentProps } from '../src';
import { KnowledgeUploadStoreProvider } from '../src';
enum UploadStep {
UPLOAD = 0,
MANAGE = 1,
PROCESS = 2,
}
describe('test upload struct', () => {
const testConfig: UploadConfig<
UploadStep,
UploadBaseState<UploadStep> & UploadBaseAction<UploadStep>
> = {
steps: [
{
content: (
props: ContentProps<
UploadBaseState<UploadStep> & UploadBaseAction<UploadStep>
>,
) => {
const { useStore } = props;
// eslint-disable-next-line react-hooks/rules-of-hooks -- linter-disable-autofix
const { setCurrentStep, currentStep } = useStore();
return (
<>
Upload
<Button
onClick={() => {
console.log('debug there setCurrentStep');
setCurrentStep(currentStep + 1);
}}
>
next Step
</Button>
</>
);
},
title: 'test',
step: UploadStep.UPLOAD,
showThisStep: checkStatus => checkStatus === CheckedStatus.NO_FILE,
},
{
content: (
props: ContentProps<
UploadBaseState<UploadStep> & UploadBaseAction<UploadStep>
>,
) => {
const { useStore } = props;
// eslint-disable-next-line react-hooks/rules-of-hooks -- linter-disable-autofix
const { setCurrentStep, currentStep } = useStore();
return (
<>
MANAGE
<Button
onClick={() => {
setCurrentStep(currentStep - 1);
}}
>
prev Step
</Button>
<Button
onClick={() => {
setCurrentStep(currentStep + 1);
}}
>
next Step
</Button>
</>
);
},
title: 'test',
step: UploadStep.MANAGE,
},
{
content: (
props: ContentProps<
UploadBaseState<UploadStep> & UploadBaseAction<UploadStep>
>,
) => {
const { useStore } = props;
// eslint-disable-next-line react-hooks/rules-of-hooks -- linter-disable-autofix
const { setCurrentStep, currentStep } = useStore();
return (
<>
PROCESS
<Button
onClick={() => {
setCurrentStep(currentStep - 1);
}}
>
prev Step
</Button>
</>
);
},
title: 'test',
step: UploadStep.PROCESS,
},
],
createStore: () =>
create<UploadBaseState<UploadStep> & UploadBaseAction<UploadStep>>()(
set => ({
currentStep: UploadStep.MANAGE,
createStatus: CreateUnitStatus.UPLOAD_UNIT,
progressList: [],
unitList: [],
setCurrentStep: (step: UploadStep) =>
set({
currentStep: step,
}),
setCreateStatus: (createStatus: CreateUnitStatus) =>
set({
createStatus,
}),
setProgressList: (progressList: ProgressItem[]) =>
set({
progressList,
}),
setUnitList: (unitList: UnitItem[]) =>
set({
unitList,
}),
reset: () =>
set({
currentStep: UploadStep.MANAGE,
createStatus: CreateUnitStatus.UPLOAD_UNIT,
progressList: [],
unitList: [],
}),
}),
),
};
test('step render', async () => {
await render(
<KnowledgeUploadStoreProvider createStore={testConfig.createStore}>
<Upload config={testConfig} />
</KnowledgeUploadStoreProvider>,
);
const currentStepComp = await screen.queryByText('MANAGE');
expect(currentStepComp).toBeDefined();
});
test('no step comp', async () => {
testConfig.showStep = false;
await render(
<KnowledgeUploadStoreProvider createStore={testConfig.createStore}>
<Upload config={testConfig} />
</KnowledgeUploadStoreProvider>,
);
const currentStepComp = await screen.queryByText('MANAGE');
const stepComp = await screen.queryByText('1');
expect(stepComp).toBeNull();
expect(currentStepComp).toBeDefined();
});
test('next step', async () => {
testConfig.showStep = true;
await render(
<KnowledgeUploadStoreProvider createStore={testConfig.createStore}>
<Upload config={testConfig} />
</KnowledgeUploadStoreProvider>,
);
const nextButton = await screen.queryByText('next Step');
expect(nextButton).toBeDefined();
await fireEvent.click(nextButton as unknown as any);
const manageComp = await screen.queryByText('PROCESS');
expect(manageComp).toBeDefined();
});
test('skip step', async () => {
await render(
<KnowledgeUploadStoreProvider createStore={testConfig.createStore}>
<Upload config={testConfig} />
</KnowledgeUploadStoreProvider>,
);
const uploadStep = await screen.queryByText('Upload');
expect(uploadStep).toBeNull();
});
test('enter placeHolder & no skip', async () => {
testConfig.useUploadMount = (
store: UseBoundStore<
StoreApi<UploadBaseState<UploadStep> & UploadBaseAction<UploadStep>>
>,
) => {
// eslint-disable-next-line react-hooks/rules-of-hooks -- linter-disable-autofix
const [showPlaceHolder, setShowPlaceHolder] = useState(true);
const setCurrentStep = store(s => s.setCurrentStep);
setCurrentStep(UploadStep.UPLOAD);
if (!showPlaceHolder) {
return [undefined, CheckedStatus.NO_FILE];
}
return [
<Button
onClick={() => {
setShowPlaceHolder(false);
}}
>
skip
</Button>,
CheckedStatus.NO_FILE,
];
};
await render(
<KnowledgeUploadStoreProvider createStore={testConfig.createStore}>
<Upload config={testConfig} />
</KnowledgeUploadStoreProvider>,
);
const skipButton = await screen.queryByText('skip');
await fireEvent.click(skipButton as unknown as any);
const uploadStep = await screen.queryByText('Upload');
expect(uploadStep).not.toBeNull();
});
});
@@ -0,0 +1,12 @@
{
"operationSettings": [
{
"operationName": "test:cov",
"outputFolderNames": ["coverage"]
},
{
"operationName": "ts-check",
"outputFolderNames": ["./dist"]
}
]
}
@@ -0,0 +1,6 @@
{
"codecov": {
"coverage": 0,
"incrementCoverage": 0
}
}
@@ -0,0 +1,9 @@
const { defineConfig } = require('@coze-arch/eslint-config');
module.exports = defineConfig({
packageRoot: __dirname,
preset: 'web',
rules: {
'@coze-arch/no-deep-relative-import': 'off',
},
});
@@ -0,0 +1,49 @@
{
"name": "@coze-data/knowledge-resource-processor-core",
"version": "0.1.0",
"description": "knowledge resource processor core framework",
"license": "Apache-2.0",
"author": "rosefang.123@bytedance.com",
"maintainers": [],
"main": "src/index.tsx",
"scripts": {
"build": "exit 0",
"lint": "eslint ./ --cache",
"test": "vitest --run --passWithNoTests",
"test:cov": "npm run test -- --coverage"
},
"dependencies": {
"@coze-arch/bot-api": "workspace:*",
"@coze-arch/bot-error": "workspace:*",
"@coze-arch/bot-semi": "workspace:*",
"@coze-arch/coze-design": "0.0.6-alpha.346d77",
"@coze-arch/pdfjs-shadow": "workspace:*",
"@coze-arch/report-events": "workspace:*",
"classnames": "^2.3.2",
"immer": "^10.0.3",
"zustand": "^4.4.7"
},
"devDependencies": {
"@coze-arch/eslint-config": "workspace:*",
"@coze-arch/stylelint-config": "workspace:*",
"@coze-arch/ts-config": "workspace:*",
"@coze-arch/vitest-config": "workspace:*",
"@testing-library/jest-dom": "^6.1.5",
"@testing-library/react": "^14.1.2",
"@testing-library/react-hooks": "^8.0.1",
"@types/react": "18.2.37",
"@types/react-dom": "18.2.15",
"@vitest/coverage-v8": "~3.0.5",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"stylelint": "^15.11.0",
"vite-plugin-svgr": "~3.3.0",
"vitest": "~3.0.5"
},
"peerDependencies": {
"react": ">=18.2.0",
"react-dom": ">=18.2.0"
},
"// deps": "immer@^10.0.3 为脚本自动补齐,请勿改动"
}
@@ -0,0 +1,120 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** The type value on the upload page url */
export enum UnitType {
/** Text format: local documents, upload PDF, TXT, DOCX local files */
TEXT_DOC = 'text_doc',
/** Text format: online data, automatically captures online web content */
TEXT_URL = 'text_url',
/** Text format: online data, manual access to online web content */
TEXT_EXTENSION = 'text_extension',
/** Text format: custom content, support for creation & editing */
TEXT_CUSTOM = 'text_custom',
/** Text Format: Import Notion pages and databases into the knowledge base */
TEXT_NOTION = 'text_notion',
/** Text formatting to import Google Docs into the Knowledge Base */
TEXT_GOOGLE_DRIVE = 'text_google_drive',
/** Text format: Feishu document, imported into the knowledge base */
TEXT_FEISHU = 'text_feishu',
/** Text format: official account */
TEXT_WECHAT = 'text_wechat',
/** Text format: Lark document, imported into the knowledge base */
TEXT_LARK = 'text_lark',
/** Table format: local document, upload Excel or CSV format document */
TABLE_DOC = 'table_doc',
/** Table format: API fetches API content in JSON format */
TABLE_API = 'table_api',
/** Table format: custom, custom content, support for creation & editing */
TABLE_CUSTOM = 'table_custom',
/** Table Format: Import Google Sheets into the Knowledge Base */
TABLE_GOOGLE_DRIVE = 'table_google_drive',
/** Table format: Import the Feishu table into the knowledge base */
TABLE_FEISHU = 'table_feishu',
/** Table format: Import Lark tables into the knowledge base */
TABLE_LARK = 'table_lark',
/** Image format: local image, upload PNG, JPG, JPEG and other format images */
IMAGE_FILE = 'image_file',
/** table format */
TABLE = 'table',
/** text format */
TEXT = 'text',
/** image format */
IMAGE = 'image',
}
/**
* Unit operation type
* Upload page supports the following ways
* - ADD created for the first time
* - UPDATE data
* - INCREMENTAL INCREMENTAL DATA
* - RESEGMENT
*/
export enum OptType {
RESEGMENT = 'resegment',
ADD = 'add',
UPDATE = 'update',
INCREMENTAL = 'incremental',
}
/** Footer button status */
export enum FooterBtnStatus {
DISABLE = 'disable',
LOADING = 'loading',
ENABLE = 'enable',
}
/** Create unit global process state. Note the difference with UploadStatus*/
export enum CreateUnitStatus {
UPLOAD_UNIT = 'uploadUnit',
GET_TASK_PROGRESS = 'getTaskProGress',
TASK_FINISH = 'taskFinish',
}
/**
* UploadStatus is the upload-unit-file, upload-unit-table components, the status of the upload file process
* Prototype from import {type FileItemStatus} from '@douyinfe/semi-foundation/lib/es/upload/foundation';
* There is a problem with the writing of FileItemStatus
*/
export enum UploadStatus {
SUCCESS = 'success',
UPLOAD_FAIL = 'uploadFail',
VALIDATE_FAIL = 'validateFail',
VALIDATING = 'validating',
UPLOADING = 'uploading',
WAIT = 'wait',
}
export enum FileNodeType {
FileNodeTypeFolder = 'folder',
FileNodeTypeDocument = 'document',
FileNodeTypeSheet = 'sheet',
}
export enum EntityStatus {
EntityStatusProcess = 'process',
EntityStatusSuccess = 'success',
EntityStatusFail = 'failure',
}
export enum CheckedStatus {
LOADING = 0,
NO_AUTH = 1,
NO_FILE = 2,
SIMPLE = 3,
HAD_SEGMENT_RULES = 4,
}
@@ -0,0 +1,26 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {
UnitType,
OptType,
FooterBtnStatus,
CreateUnitStatus,
FileNodeType,
UploadStatus,
EntityStatus,
CheckedStatus,
} from './common';
@@ -0,0 +1,50 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { createContext, type PropsWithChildren, type FC, useRef } from 'react';
import { type StoreApi, type UseBoundStore } from 'zustand';
interface StoreRef {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
knowledge?: UseBoundStore<StoreApi<any>> | undefined;
}
export const KnowledgeUploadStoreContext = createContext<{
storeRef: StoreRef;
}>({
storeRef: {
knowledge: undefined,
},
});
export const KnowledgeUploadStoreProvider: FC<
PropsWithChildren<{
createStore: () => StoreRef['knowledge'];
}>
> = ({ createStore, children }) => {
const store = useRef<StoreRef>({});
if (!store.current?.knowledge) {
store.current.knowledge = createStore();
}
return (
<KnowledgeUploadStoreContext.Provider value={{ storeRef: store.current }}>
{children}
</KnowledgeUploadStoreContext.Provider>
);
};
@@ -0,0 +1,79 @@
/* stylelint-disable max-nesting-depth */
/* stylelint-disable no-descending-specificity */
.knowledge-steps {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
:global {
.semi-steps-horizontal {
display: flex;
justify-content: center;
width: 100%;
.semi-steps-item {
flex: none;
// padding-left: 12px;
.semi-steps-item-container {
align-items: center;
}
&.semi-steps-item-active {
.semi-steps-item-title {
color: var(--coz-fg-hglt);
}
.semi-steps-item-number-icon {
color: var(--coz-fg-hglt-plus);
}
}
.semi-steps-item-title {
max-width: 100%;
padding-right: 4px;
padding-bottom: 0;
font-weight: 500;
color: var(--coz-fg-secondary);
}
.semi-steps-item-icon {
height: 28px;
.semi-steps-item-number-icon {
width: 28px;
height: 28px;
}
}
}
.semi-steps-item-left .semi-steps-item-icon .semi-steps-item-number-icon{
font-size: 20px;
font-weight: 500;
}
.semi-steps-item-wait {
.semi-steps-item-left .semi-steps-item-icon .semi-steps-item-number-icon {
font-size: 20px;
font-weight: 500;
color: var(--coz-fg-secondary);
}
}
}
}
/** Successful icon */
.finish-icon {
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
background-color: var(--coz-mg-hglt);
border-radius: 50%;
}
}
@@ -0,0 +1,42 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { Upload } from './main';
export type {
UploadBaseState,
UploadBaseAction,
GetUploadConfig,
UploadConfig,
} from './protocol';
export type {
ContentProps,
FooterControlsProps,
FooterControlProp,
FooterBtnProps,
ProgressItem,
UnitItem,
FooterPrefixType,
} from './types';
export {
UnitType,
OptType,
CreateUnitStatus,
FooterBtnStatus,
UploadStatus,
EntityStatus,
CheckedStatus,
} from './constants';
export { KnowledgeUploadStoreProvider } from './context';
@@ -0,0 +1,116 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React, { useContext, useEffect } from 'react';
import classNames from 'classnames';
import { REPORT_EVENTS } from '@coze-arch/report-events';
import { Steps } from '@coze-arch/bot-semi';
import { CustomError } from '@coze-arch/bot-error';
import { IconCozCheckMarkFill } from '@coze-arch/coze-design/icons';
import type {
UploadBaseState,
UploadBaseAction,
UploadConfig,
} from './protocol/base';
import { KnowledgeUploadStoreContext } from './context';
import styles from './index.module.less';
const BOT_DATA_REFACTOR_CLASS_NAME = 'data-refactor';
export const Upload = <
T extends number,
R extends UploadBaseState<T> & UploadBaseAction<T>,
>(props: {
config: UploadConfig<T, R>;
}) => {
useEffect(
() => () => {
// It is necessary, otherwise it will be wrong to re-enter the page status
reset();
},
[],
);
/** get store */
const storeContext = useContext(KnowledgeUploadStoreContext);
if (!storeContext.storeRef.knowledge) {
throw new CustomError(
REPORT_EVENTS.normalError,
'no knowledge store context',
);
}
const store = storeContext.storeRef.knowledge;
/** get steps */
const { config } = props;
if (!config) {
return null;
}
const { className, useUploadMount, showStep = true } = config;
const currentStep = store(state => state.currentStep);
const reset = store(state => state.reset);
// eslint-disable-next-line react-hooks/rules-of-hooks -- linter-disable-autofix
const [placeHolder, checkStatus] = useUploadMount?.(store) ?? [];
const showStepFlags = config.steps.map(
step => step.showThisStep?.(checkStatus) ?? true,
);
const steps = config.steps.filter((_v, index) => showStepFlags[index]);
// After the array is filtered, there is a problem with steps getting the value through the index, so it is changed to get the corresponding step value to associate the item data.
const ContentComp = steps.find(item => item.step === currentStep)?.content;
if (placeHolder) {
return placeHolder;
}
return (
<div
className={classNames(
`${className} ${BOT_DATA_REFACTOR_CLASS_NAME}`,
styles['knowledge-steps'],
)}
>
{showStep ? (
<Steps
type="basic"
hasLine={false}
current={currentStep}
className="mb-[32px]"
>
{steps.map(step =>
currentStep > step.step ? (
<Steps.Step
key={step.title}
title={step.title}
icon={
<div className={styles['finish-icon']}>
<IconCozCheckMarkFill />
</div>
}
/>
) : (
<Steps.Step key={step.title} title={step.title} />
),
)}
</Steps>
) : null}
{ContentComp ? (
<ContentComp useStore={store} checkStatus={checkStatus} />
) : null}
</div>
);
};
@@ -0,0 +1,68 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type StoreApi, type UseBoundStore } from 'zustand';
import type { ProgressItem, UnitItem, ContentProps } from '../types';
import {
type OptType,
type CreateUnitStatus,
type UnitType,
type CheckedStatus,
} from '../constants';
export interface UploadBaseState<T extends number | string> {
currentStep: T;
createStatus: CreateUnitStatus;
progressList: ProgressItem[];
unitList: UnitItem[];
}
export interface UploadBaseAction<T extends number | string> {
setCurrentStep: (step: T) => void;
setCreateStatus: (createStatus: CreateUnitStatus) => void;
setProgressList: (progressList: ProgressItem[]) => void;
setUnitList: (unitList: UnitItem[]) => void;
reset: () => void;
}
/** need to implement this function. */
export type GetUploadConfig<T, R> = (
type: UnitType,
opt: OptType,
) => UploadConfig<T, R> | null;
/** upload unified configuration */
export interface UploadConfig<T, R> {
steps: UploadConfigSteps<T, R>;
createStore: () => UseBoundStore<StoreApi<R>>;
className?: string;
/** Whether to show the top step, default true */
showStep?: boolean;
useUploadMount?: (
store: UseBoundStore<StoreApi<R>>,
) => [React.ReactElement | undefined, CheckedStatus | undefined] | null;
}
export type UploadConfigSteps<T, R> = Array<UploadConfigStep<T, R>>;
export interface UploadConfigStep<T, R> {
content?: (props: ContentProps<R>) => React.ReactElement;
showThisStep?: (checkStatus?: CheckedStatus) => boolean;
title: string;
step: T;
e2e?: string;
}
@@ -0,0 +1,22 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export type {
UploadBaseState,
UploadBaseAction,
GetUploadConfig,
UploadConfig,
} from './base';
@@ -0,0 +1,112 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
type UpdateType,
type DocumentStatus,
type Int64,
type WebStatus,
type DocumentProgress,
} from '@coze-arch/bot-api/knowledge';
import type { FileNodeType, EntityStatus, UploadStatus } from '../constants';
interface CommonUnitItem {
key?: string;
percent: number | undefined;
status: UploadStatus | WebStatus | EntityStatus;
type: string; // Unit type, url, doc, pdf, etc
uri: string; // The relative path of the file on tos url | web_url
url: string; // Absolute URL of the file
name: string; // unit namewebpage title
validateMessage?: string;
// External incoming dynamic errorMessage
dynamicErrorMessage?: string;
}
interface DocUnitItem {
size?: string; // file size
docId?: string; // Document ID, used when updating content
fileInstance?: File | undefined;
uid?: string;
}
interface URLUnitItem {
updateInterval?: number; // URL usage, update frequency
subpagesCount?: number;
updateType?: UpdateType;
webID?: string;
statusDescript?: string;
manualCrawlingConfig?: {
response: {
title: string;
url: string;
recordType: 'text' | 'list';
result: {
key: string;
name: string;
data: string | string[];
xPath: string;
type: 'text' | 'image' | 'link';
/**
* FIXME: The data structure cannot be modified for compatibility, so the following three parameters will be included in the depth acquisition
*/
parentKey?: string;
titles?: string[];
urls?: string[];
}[];
};
/**
* If it is a deep capture document, there is a value corresponding to the key of the parent document column.
*/
fromParentUnitColumnKey?: string;
};
manualCrawlingTableContent?: Record<string, string>[];
}
/**
* Three-way data connector task
*/
interface EntityUnitItem {
file_name?: string;
file_id?: string;
entity_id?: string;
tos_url?: string;
error_msg?: string;
file_node_type?: FileNodeType;
has_children_nodes?: boolean;
error_code?: Int64;
file_size?: string;
instance_id?: string;
tos_key?: string;
}
// There is a problem with the implementation of TODO UnitItem, which needs to be optimized.
/** Except for UnitItem, nothing else is used externally, so it will not be exported for the time being.*/
export type UnitItem = CommonUnitItem &
DocUnitItem &
URLUnitItem &
EntityUnitItem;
export interface ProgressItem extends DocumentProgress {
documentId: string | undefined;
progress: number;
uri: string;
name: string;
status: DocumentStatus;
statusDesc: string;
remainingTime: number;
}
@@ -0,0 +1,27 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Types Since multiple locations are used to avoid circular dependencies, the top layer is mentioned
*/
export type { UnitItem, ProgressItem } from './common';
export type {
ContentProps,
FooterControlsProps,
FooterControlProp,
FooterBtnProps,
FooterPrefixType,
} from './upload';
@@ -0,0 +1,56 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type ReactNode } from 'react';
/**
* types for upload
*/
import { type StoreApi, type UseBoundStore } from 'zustand';
import {
type OptType,
type FooterBtnStatus,
type CheckedStatus,
} from '../constants';
export interface ContentProps<T> {
useStore: UseBoundStore<StoreApi<T>>;
footer?: (
controls: FooterControlsProps | FooterBtnProps[],
) => React.ReactElement;
opt?: OptType;
checkStatus: CheckedStatus | undefined;
}
export type FooterControlsProps = FooterControlProp | FooterBtnProps[];
export type FooterPrefixType = React.ReactElement | string | undefined;
export interface FooterControlProp {
prefix: FooterPrefixType;
btns: FooterBtnProps[];
}
export interface FooterBtnProps {
e2e?: string;
onClick: () => void;
text: string;
status?: FooterBtnStatus;
theme?: 'solid' | 'borderless' | 'light';
type?: 'hgltplus' | 'primary' | 'secondary' | 'yellow' | 'red' | 'green';
disableHoverContent?: ReactNode;
}
@@ -0,0 +1,20 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare module '*.less' {
const resource: { [key: string]: string };
export = resource;
}
@@ -0,0 +1,34 @@
import { Meta } from "@storybook/blocks";
<Meta title="Hello world" />
<div className="sb-container">
<div className='sb-section-title'>
# Hello world
Hello world
</div>
</div>
<style>
{`
.sb-container {
margin-bottom: 48px;
}
.sb-section {
width: 100%;
display: flex;
flex-direction: row;
gap: 20px;
}
img {
object-fit: cover;
}
.sb-section-title {
margin-bottom: 32px;
}
`}
</style>
@@ -0,0 +1,42 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@coze-arch/ts-config/tsconfig.web.json",
"compilerOptions": {
"types": [],
"strictNullChecks": true,
"noImplicitAny": true,
"rootDir": "./src",
"outDir": "./dist",
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo"
},
"include": ["src"],
"references": [
{
"path": "../../../arch/bot-api/tsconfig.build.json"
},
{
"path": "../../../arch/bot-error/tsconfig.build.json"
},
{
"path": "../../../arch/pdfjs-shadow/tsconfig.build.json"
},
{
"path": "../../../arch/report-events/tsconfig.build.json"
},
{
"path": "../../../components/bot-semi/tsconfig.build.json"
},
{
"path": "../../../../config/eslint-config/tsconfig.build.json"
},
{
"path": "../../../../config/stylelint-config/tsconfig.build.json"
},
{
"path": "../../../../config/ts-config/tsconfig.build.json"
},
{
"path": "../../../../config/vitest-config/tsconfig.build.json"
}
]
}
@@ -0,0 +1,15 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"composite": true
},
"references": [
{
"path": "./tsconfig.build.json"
},
{
"path": "./tsconfig.misc.json"
}
],
"exclude": ["**/*"]
}
@@ -0,0 +1,18 @@
{
"extends": "@coze-arch/ts-config/tsconfig.web.json",
"$schema": "https://json.schemastore.org/tsconfig",
"include": ["__tests__", "stories", "vitest.config.ts", "tailwind.config.ts"],
"exclude": ["./dist"],
"references": [
{
"path": "./tsconfig.build.json"
}
],
"compilerOptions": {
"rootDir": "./",
"outDir": "./dist",
"types": ["vitest/globals"],
"strictNullChecks": true,
"noImplicitAny": true
}
}
@@ -0,0 +1,33 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { defineConfig } from '@coze-arch/vitest-config';
export default defineConfig(
{
dirname: __dirname,
preset: 'web',
test: {
coverage: {
all: true,
exclude: ['src/types', 'src/index.tsx'],
},
},
},
{
fixSemi: true,
},
);