The following is the code for creating a user dictionary Kibana plugin. However, when executed, it cannot reference the module named 'files:Filesetup', resulting in an error with 'undefined'. Is there anything I might be missing in my plugin development?

The following is the code for creating a user dictionary Kibana plugin. However, when executed, it cannot reference the module named 'files:Filesetup', resulting in an error with 'undefined'. Is there anything I might be missing in my plugin development?

import { PLUGIN_ID, PLUGIN_NAME, dictionaryFileKind, DicImageMetadata } from '../common';
import { AppMountParameters, CoreSetup, CoreStart, Plugin } from '../../../src/core/public';
import { UserDictionaryPluginSetup, UserDictionaryPluginStart } from './types';

export class UserDictionaryPlugin
  implements Plugin<unknown, unknown, UserDictionaryPluginSetup, UserDictionaryPluginStart>
{
  public setup(
    core: CoreSetup<UserDictionaryPluginStart>,
    { files }: UserDictionaryPluginSetup
  ) {
    console.log('UserDictionaryPluginSetup:', { files })
    if (!files) {
      console.error('Error: files is undefined.');
      // 적절한 디폴트 값을 반환하거나, 에러 처리를 추가하세요.
      return {};
    }
    files.registerFileKind({
      id: dictionaryFileKind.id,
      allowedMimeTypes: dictionaryFileKind.allowedMimeTypes,
    });
    // Register an application into the side navigation menu
    core.application.register({
      id: PLUGIN_ID,
      title: PLUGIN_NAME,
      async mount(params: AppMountParameters) {
        // Load application bundle
        const { renderApp } = await import('./application');
        // Get start services as specified in kibana.json
        const [coreStart, depsStart] = await core.getStartServices();
        // Render the application
        return renderApp(coreStart,
          {
            files: {
              unscoped: depsStart.files.filesClientFactory.asUnscoped<DicImageMetadata>(),
              example: depsStart.files.filesClientFactory.asScoped<DicImageMetadata>(dictionaryFileKind.id),
            },
          },
          params);
      },
    });

    // Return methods that should be available to other plugins
    return {};
  }

  public start(core: CoreStart) {
    return {};
  }

  public stop() { }
}

The following is the error message:
UserDictionaryPluginSetup:

  1. {files: undefined}

  2. files: undefined

  3. [[Prototype]]: Object

1. constructor: ƒ Object()
2. hasOwnProperty: ƒ hasOwnProperty()
3. isPrototypeOf: ƒ isPrototypeOf()
4. propertyIsEnumerable: ƒ propertyIsEnumerable()
5. toLocaleString: ƒ toLocaleString()
6. toString: ƒ toString()
7. valueOf: ƒ valueOf()
8. __defineGetter__: ƒ __defineGetter__()
9. __defineSetter__: ƒ __defineSetter__()
10. __lookupGetter__: ƒ __lookupGetter__()
11. __lookupSetter__: ƒ __lookupSetter__()
12. __proto__: (...)
13. get __proto__: ƒ __proto__()
14. set __proto__: ƒ __proto__()

Resolved. Thank you.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.