dify icon indicating copy to clipboard operation
dify copied to clipboard

DataSourceInfo properties does not exist

Open AndyMik90 opened this issue 1 year ago • 1 comments

Self Checks

  • [X] This is only for bug report, if you would like to ask a question, please head to Discussions.
  • [X] I have searched for existing issues search for existing issues, including closed ones.
  • [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [X] Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.8

Cloud or Self Hosted

Cloud, Self Hosted (Docker), Self Hosted (Source)

Steps to reproduce

Errors on web/app/components/datasets/documents/detail/settings/index.tsx related to DataSourceInfo types:

[{ "resource": "/Users/andremikalsen/Documents/Coding/Valma AI/valma_backend/web/app/components/datasets/documents/detail/settings/index.tsx", "owner": "typescript", "code": "2339", "severity": 8, "message": "Property 'notion_workspace_id' does not exist on type 'DataSourceInfo'.", "source": "ts", "startLineNumber": 39, "startColumn": 54, "endLineNumber": 39, "endColumn": 73 },{ "resource": "/Users/andremikalsen/Documents/Coding/Valma AI/valma_backend/web/app/components/datasets/documents/detail/settings/index.tsx", "owner": "typescript", "code": "2551", "severity": 8, "message": "Property 'notion_page_id' does not exist on type 'DataSourceInfo'. Did you mean 'notion_page_icon'?", "source": "ts", "startLineNumber": 40, "startColumn": 49, "endLineNumber": 40, "endColumn": 63, "relatedInformation": [ { "startLineNumber": 154, "startColumn": 3, "endLineNumber": 154, "endColumn": 19, "message": "'notion_page_icon' is declared here.", "resource": "/Users/andremikalsen/Documents/Coding/Valma AI/valma_backend/web/models/datasets.ts" } ] },{ "resource": "/Users/andremikalsen/Documents/Coding/Valma AI/valma_backend/web/app/components/datasets/documents/detail/settings/index.tsx", "owner": "typescript", "code": "2339", "severity": 8, "message": "Property 'type' does not exist on type 'DataSourceInfo'.", "source": "ts", "startLineNumber": 43, "startColumn": 46, "endLineNumber": 43, "endColumn": 50 },{ "resource": "/Users/andremikalsen/Documents/Coding/Valma AI/valma_backend/web/app/components/datasets/documents/detail/settings/index.tsx", "owner": "typescript", "code": "2322", "severity": 8, "message": "Type '{ workspace_id: any; page_id: any; page_name: string | undefined; page_icon: string | undefined; type: any; }' is not assignable to type 'NotionPage'.\n Type '{ workspace_id: any; page_id: any; page_name: string | undefined; page_icon: string | undefined; type: any; }' is missing the following properties from type 'DataSourceNotionPage': parent_id, is_bound, finished", "source": "ts", "startLineNumber": 75, "startColumn": 27, "endLineNumber": 75, "endColumn": 38 },{ "resource": "/Users/andremikalsen/Documents/Coding/Valma AI/valma_backend/web/app/components/datasets/documents/detail/settings/index.tsx", "owner": "typescript", "code": "2322", "severity": 8, "message": "Type '{ id: string; name: string; size: number; mime_type: string; created_at: number; created_by: string; extension: string; }' is not assignable to type 'CustomFile'.\n Type '{ id: string; name: string; size: number; mime_type: string; created_at: number; created_by: string; extension: string; }' is missing the following properties from type 'File': lastModified, webkitRelativePath, type, arrayBuffer, and 4 more.", "source": "ts", "startLineNumber": 79, "startColumn": 21, "endLineNumber": 79, "endColumn": 64 }]

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

AndyMik90 avatar May 23 '24 04:05 AndyMik90

To resolve the TypeScript errors in your web/app/components/datasets/documents/detail/settings/index.tsx file, follow these steps:

Error 1: Property 'notion_workspace_id' does not exist on type 'DataSourceInfo'

Ensure that notion_workspace_id is part of the DataSourceInfo type if it is required. Update the type definition if necessary.

Error 2: Property 'notion_page_id' does not exist on type 'DataSourceInfo'

Similarly, verify if notion_page_id should be included in the DataSourceInfo type and update it accordingly.

Error 3: Property 'type' does not exist on type 'DataSourceInfo'

Check if the type property should be part of DataSourceInfo and update the type definition if needed.

Error 4: Type '{ workspace_id: any; page_id: any; page_name: string | undefined; page_icon: string | undefined; type: any; }' is not assignable to type 'NotionPage'

Ensure that the object assigned to NotionPage matches its type definition. Include all required properties.

Error 5: Type '{ id: string; name: string; size: number; mime_type: string; created_at: number; created_by: string; extension: string; }' is not assignable to type 'CustomFile'

Make sure the object assigned to CustomFile includes all required properties from the File type.

Suggested Fixes

  1. Update DataSourceInfo Type:

    export type DataSourceInfo = {
      upload_file: {
        id: string
        name: string
        size: number
        mime_type: string
        created_at: number
        created_by: string
        extension: string
      }
      notion_workspace_id?: string
      notion_page_id?: string
      notion_page_icon?: string
      type?: string
    }
    
  2. Ensure Correct Property Access:

    const currentPage = useMemo(() => {
      return {
        workspace_id: documentDetail?.data_source_info.notion_workspace_id,
        page_id: documentDetail?.data_source_info.notion_page_id,
        page_name: documentDetail?.name,
        page_icon: documentDetail?.data_source_info.notion_page_icon,
        type: documentDetail?.data_source_info.type,
      }
    }, [documentDetail])
    
  3. Update NotionPage Type Usage:

    const notionPage: NotionPage = {
      page_id: documentDetail?.data_source_info.notion_page_id,
      type: documentDetail?.data_source_info.type,
    }
    
  4. Ensure CustomFile Properties:

    const customFile: CustomFile = {
      ...documentDetail.data_source_info.upload_file,
      lastModified: new Date(documentDetail.data_source_info.upload_file.created_at).getTime(),
      webkitRelativePath: '',
      type: documentDetail.data_source_info.upload_file.mime_type,
      arrayBuffer: async () => new ArrayBuffer(0),
      slice: () => new Blob(),
      stream: () => new ReadableStream(),
      text: async () => '',
    }
    

By making these adjustments, you should be able to resolve the TypeScript errors in your index.tsx file. If you need further assistance, please provide more details or context.

Details

Sources


About Dosu This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

dosubot[bot] avatar May 23 '24 04:05 dosubot[bot]