import { Service } from '../core/Service.js'
import { StoreSdk } from '@api-client/core/sdk/StoreSdkWeb.js'

export default class SdkService extends Service {
  static override key = 'api-service/sdk'
  sdk!: StoreSdk
  protected url: string

  /**
   * The URL of the API server.
   * @param url - The URL of the API server.
   */
  constructor(url: string) {
    super()
    this.url = url
  }

  override async onCreate(): Promise<void> {
    this.sdk = new StoreSdk(this.url)
  }

  // override async onStart(): Promise<void> {
  //   await this.sdk.initialize()
  // }

  get organizations(): StoreSdk['organizations'] {
    return this.sdk.organizations
  }

  get user(): StoreSdk['user'] {
    return this.sdk.user
  }

  get auth(): StoreSdk['auth'] {
    return this.sdk.auth
  }

  get file(): StoreSdk['file'] {
    return this.sdk.file
  }

  get shared(): StoreSdk['shared'] {
    return this.sdk.shared
  }

  get trash(): StoreSdk['trash'] {
    return this.sdk.trash
  }

  get dataCatalog(): StoreSdk['dataCatalog'] {
    return this.sdk.dataCatalog
  }

  get groups(): StoreSdk['groups'] {
    return this.sdk.groups
  }
}
