declare module "@smapiot/piral-cloud-node" {
  /**
   * Creates a new service client for use in Node.js-based applications.
   * @param options The options for creating the client.
   * @returns The created service client.
   */
  export function createServiceClient(options: CreateServiceClientOptions): FeedServiceApiClient;

  /**
   * The options for creating a new service client.
   */
  export type CreateServiceClientOptions = CreateServiceClientBaseOptions & CreateServiceClientApiKeyOptions;

  export class FeedServiceApiClient {
    private _listeners: Record<string, Array<(ev: any) => void>>;
    constructor(private http: FetchClient, public host?: string);
    on<TEventName extends EventNames>(name: TEventName, handler: (ev: EventDefinitions[TEventName]) => void): void;
    off<TEventName extends EventNames>(name: TEventName, handler: (ev: EventDefinitions[TEventName]) => void): void;
    once<TEventName extends EventNames>(name: TEventName, handler: (ev: EventDefinitions[TEventName]) => void): void;
    private emit<TEventName extends EventNames>(name: TEventName, ev: EventDefinitions[TEventName]): void;
    getUrl(path: string): string;
    getEvents(): string;
    doAny<T>(path: string, init?: RequestInit): Promise<T>;
    doGet<T>(path: string, init?: RequestInit): Promise<T>;
    doPost<T>(path: string, content: any, init?: RequestInit): Promise<T>;
    doPut<T>(path: string, content: any, init?: RequestInit): Promise<T>;
    doDelete<T>(path: string, init?: RequestInit): Promise<T>;
    getPilets(ac?: AbortController): Promise<Array<PiletMetadataDTO>>;
    doQueryFeeds(ac?: AbortController): Promise<FeedsDTO>;
    doQueryFeed(feed: string, ac?: AbortController): Promise<FullFeedDTO>;
    doQueryValidEnvSourceTags(feed: string, eid?: string, offset?: number, count?: number, ac?: AbortController): Promise<ValidSourceTags>;
    doQueryEnvironments(feed: string, ac?: AbortController): Promise<EnvironmentsDTO>;
    doQueryEnvironment(feed: string, eid: string, ac?: AbortController): Promise<EnvironmentDTO>;
    doAddEnvironment(feed: string, content: EnvironmentCreateDetails, ac?: AbortController): Promise<unknown>;
    doUpdateEnvironment(feed: string, eid: string, content: EnvironmentUpdateDetails, ac?: AbortController): Promise<unknown>;
    doDeleteEnvironment(feed: string, eid: string, ac?: AbortController): Promise<unknown>;
    doQueryEnvironmentElevationReviews(feed: string, eid: string, ac?: AbortController): Promise<ElevationReviewsDTO>;
    doQueryFeedElevationReviews(feed: string, ac?: AbortController): Promise<ElevationReviewsDTO>;
    doQueryEnvironmentElevationReview(feed: string, eid: string, ac?: AbortController): Promise<ElevationReviewsDTO>;
    doAddElevationReview(feed: string, eid: string, content: ElevationReviewCreateDetails, ac?: AbortController): Promise<unknown>;
    doUpdateElevationReview(feed: string, eid: string, id: string, content: ElevationReviewUpdateDetails, ac?: AbortController): Promise<unknown>;
    doQueryElevationReviewComments(feed: string, eid: string, ac?: AbortController): Promise<ElevationReviewCommentsDTO>;
    doAddElevationReviewComment(feed: string, eid: string, content: ElevationReviewCommentCreateDetails, ac?: AbortController): Promise<unknown>;
    doQueryPages(feed: string, tag?: string, ac?: AbortController): Promise<PagesDTO>;
    doUpdatePageSettings(feed: string, content: PageSettingsUpdateDetails, ac?: AbortController): Promise<unknown>;
    doUpdatePage(feed: string, version: string, content: PageUpdateDetails, tag?: string, ac?: AbortController): Promise<unknown>;
    doPublishPage(feed: string, content: PagePublishDetails, ac?: AbortController): Promise<unknown>;
    doQueryAllPilets(feed: string, tag?: string, view?: "all" | "selected", ac?: AbortController): Promise<SelectedPiletsDTO>;
    doQueryUploadedPilets(feed: string, name: string, offset?: string, count?: string, ac?: AbortController): Promise<UploadedPiletsDTO>;
    doPublishPilet(feed: string, tag: string, file: File, ac?: AbortController): Promise<unknown>;
    doQueryCurrentPilets(feed: string, ac?: AbortController): Promise<Array<PiletMetadataDTO>>;
    doQueryPiletDetails(feed: string, pilet: string, tag?: string, ac?: AbortController): Promise<PiletDetailsDTO>;
    doQueryPiletReadme(feed: string, pilet: string, ac?: AbortController): Promise<PiletReadmeDTO>;
    doQueryFeedExists(feed: string, ac?: AbortController): Promise<FeedCheckDTO>;
    doQueryApiKeyScopes(ac?: AbortController): Promise<ApiKeyScopesDTO>;
    doQueryApiKeys(feed: string, ac?: AbortController): Promise<ApiKeysDTO>;
    doQueryFeedApiKeys(feed: string, ac?: AbortController): Promise<ApiKeysDTO>;
    doQueryGeneralApiKeys(ac?: AbortController): Promise<ApiKeysDTO>;
    doQueryFeatures(feed: string, ac?: AbortController): Promise<FeaturesDTO>;
    doQueryRules(feed: string, ac?: AbortController): Promise<RulesDTO>;
    doCreateFeed(content: FeedCreateDetails, ac?: AbortController): Promise<CreatedFeedDTO>;
    doAddFeature(feed: string, content: FeatureCreateDetails, ac?: AbortController): Promise<AddedFeatureDTO>;
    doAddRule(feed: string, content: RuleCreateDetails, ac?: AbortController): Promise<AddedRuleDTO>;
    doGenerateApiKey(feed: string, content: ApiKeyCreateDetails, ac?: AbortController): Promise<GeneratedApiKeyDTO>;
    doGenerateFeedApiKey(feed: string, content: ApiKeyCreateDetails, ac?: AbortController): Promise<GeneratedApiKeyDTO>;
    doGenerateGeneralApiKey(content: ApiKeyCreateDetails, ac?: AbortController): Promise<GeneratedApiKeyDTO>;
    doDeleteFeed(feed: string, ac?: AbortController): Promise<unknown>;
    doRevokeGeneralApiKey(id: string, ac?: AbortController): Promise<unknown>;
    doRevokeApiKey(feed: string, id: string, ac?: AbortController): Promise<unknown>;
    doRevokeFeedApiKey(feed: string, id: string, ac?: AbortController): Promise<unknown>;
    doDeletePilet(feed: string, id: string, all?: boolean, ac?: AbortController): Promise<unknown>;
    doDeleteFeature(feed: string, id: string, ac?: AbortController): Promise<unknown>;
    doDeleteRule(feed: string, id: string, ac?: AbortController): Promise<unknown>;
    doUpdateFeature(feed: string, id: string, content: FeatureUpdateDetails, ac?: AbortController): Promise<unknown>;
    doUpdateRule(feed: string, id: string, content: RuleUpdateDetails, ac?: AbortController): Promise<unknown>;
    doUpdatePilet(feed: string, id: string, content: PiletUpdateDetails, tag?: string, ac?: AbortController): Promise<unknown>;
    doUpdateFeed(feed: string, content: FeedUpdateDetails, ac?: AbortController): Promise<unknown>;
    doUpdateApiKey(feed: string, id: string, content: ApiKeyUpdateDetails, ac?: AbortController): Promise<unknown>;
    doUpdateFeedApiKey(feed: string, id: string, content: ApiKeyUpdateDetails, ac?: AbortController): Promise<unknown>;
    doUpdateGeneralApiKey(id: string, content: ApiKeyUpdateDetails, ac?: AbortController): Promise<unknown>;
    doQueryAudits(offset?: string, count?: string, areaName?: string, areaId?: string, objectId?: string, userId?: string, q?: string, ac?: AbortController, start?: Date, end?: Date): Promise<AuditsDTO>;
    doQueryAudit(id: string, ac?: AbortController): Promise<AuditDTO>;
    doQueryAllUsers(q: string, offset?: number, count?: number, ac?: AbortController): Promise<AllUsersDTO>;
    doQueryFeedContributors(feed: string, ac?: AbortController): Promise<FeedContributorsDTO>;
    doPutFeedContributors(feed: string, content: ContributorUpdateDetails, ac?: AbortController): Promise<unknown>;
    doQueryConfigs(feed: string, pilet: string, ac?: AbortController): Promise<ConfigsDTO>;
    doQueryConfig(feed: string, pilet: string, config: string, ac?: AbortController): Promise<ConfigDTO>;
    doAddConfig(feed: string, pilet: string, content: ConfigCreateDetails, ac?: AbortController): Promise<unknown>;
    doDeleteConfig(feed: string, pilet: string, config: string, ac?: AbortController): Promise<unknown>;
    doUpdateConfig(feed: string, pilet: string, config: string, content: ConfigUpdateDetails, ac?: AbortController): Promise<unknown>;
    doQueryAllFeedConfigs(feed: string, ac?: AbortController): Promise<AllFeedConfigsDTO>;
    doQueryFeedConfigs(feed: string, configId: string, ac?: AbortController): Promise<FeedConfigsDTO>;
    doQueryFeedConfig(feed: string, configId: string, config: string, ac?: AbortController): Promise<FeedConfigDTO>;
    doAddFeedConfig(feed: string, configId: string, content: ConfigCreateDetails, ac?: AbortController): Promise<unknown>;
    doDeleteFeedConfig(feed: string, configId: string, config: string, ac?: AbortController): Promise<unknown>;
    doUpdateFeedConfig(feed: string, configId: string, config: string, content: ConfigUpdateDetails, ac?: AbortController): Promise<unknown>;
    doQueryEntities(feed: string, ac?: AbortController): Promise<EntitiesDTO>;
    doQueryEntity(feed: string, id: string, ac?: AbortController): Promise<EntityDTO>;
    doAddEntity(feed: string, content: EntityCreateDetails, ac?: AbortController): Promise<EntityDTO>;
    doDeleteEntity(feed: string, id: string, ac?: AbortController): Promise<EntityDTO>;
    doUpdateEntity(feed: string, id: string, content: EntityUpdateDetails, ac?: AbortController): Promise<EntityDTO>;
    doQueryExternalUsers(q: string, offset?: number, count?: number, ac?: AbortController): Promise<ExternalUsersDTO>;
    doQueryUsers(ac?: AbortController): Promise<UsersDTO>;
    doQueryUser(id: string, ac?: AbortController): Promise<UserDTO>;
    doAddUser(content: UserCreateDetails, ac?: AbortController): Promise<ChangedUserDTO>;
    doDeleteUser(id: string, ac?: AbortController): Promise<DeletedUserDTO>;
    doUpdateUser(id: string, content: UserUpdateDetails, ac?: AbortController): Promise<ChangedUserDTO>;
    doQueryCustomRules(ac?: AbortController): Promise<CustomRuleModulesDTO>;
    doQueryGroups(ac?: AbortController): Promise<GroupsDTO>;
    doQueryGroup(id: string, ac?: AbortController): Promise<GroupDetailsDTO>;
    doAddGroup(content: GroupCreateDetails, ac?: AbortController): Promise<GroupDetailsDTO>;
    doUpdateGroup(id: string, content: GroupUpdateDetails, ac?: AbortController): Promise<GroupDetailsDTO>;
    doDeleteGroup(id: string, ac?: AbortController): Promise<DeletedGroupDTO>;
    doAddCustomRules(file: string, content: string, ac?: AbortController): Promise<ChangedCustomRuleModuleDTO>;
    doDeleteCustomRule(file: string, ac?: AbortController): Promise<ChangedCustomRuleModuleDTO>;
    doQueryCustomRuleDetails(file: string, ac?: AbortController): Promise<CustomRuleDetailsDTO>;
    doTestRule(feed: string, rule: string, content: TestRuleDetails, ac?: AbortController): Promise<TestRuleResultDTO>;
    doQueryCurrentUser(ac?: AbortController): Promise<CurrentUserDTO>;
    doUpdateCurrentUser(content: CurrentUserUpdateDetails, ac?: AbortController): Promise<ChangedUserDTO>;
    doQueryStatus(ac?: AbortController): Promise<StatusDTO>;
    doQueryStatistics(ac?: AbortController): Promise<StatisticsDTO>;
    doQueryRulesSchema(ac?: AbortController): Promise<any>;
    doQueryFeedAnalysis(feed: string, ac?: AbortController): Promise<FeedAnalysisDTO>;
    doQueryPiletAnalysis(feed: string, id: string, ac?: AbortController): Promise<PiletAnalysisDTO>;
    doQueryFeedVulnerabiltiyAnalysis(feed: string, ac?: AbortController): Promise<VulnerabilityReportDTO>;
    doTriggerVulnerabilityAnalysis(feed: string, ac?: AbortController): Promise<VulnerabilityReportDTO>;
    doRecheckDomains(feed: string, domains: Array<string>, ac?: AbortController): Promise<unknown>;
    doQueryFeedStatistics(feed: string, from: string, to: string, ac?: AbortController): Promise<FeedStatisticsDTO>;
    doQueryAdminFeedStatistics(offset?: string, count?: string, ac?: AbortController): Promise<AdminStatisticsDTO>;
    doQueryAdminFeedStatisticsDetails(feed: string, from: string, to: string, ac?: AbortController): Promise<AdminStatisticsDetailsDTO>;
    doQueryNpmRegistry(feed: string, ac?: AbortController): Promise<NpmRegistryDTO>;
    doQueryNpmPackage(feed: string, name: string, ac?: AbortController): Promise<NpmPackageDTO>;
    doUploadNpmPackage(feed: string, name: string, body: any, ac?: AbortController): Promise<void>;
    doDownloadFile(fileUrl: string, ac?: AbortController): Promise<Blob>;
    doGetLicenseInfo(ac?: AbortController): Promise<LicenseInfo>;
    doQueryPiletStorageEntries(feed: string, pilet: string, ac?: AbortController): Promise<StorageEntriesDTO>;
    doAddPiletStorageEntry(feed: string, pilet: string, name: string, content: string, ac?: AbortController): Promise<StorageEntryDetailsDTO>;
    doQueryPiletStorageEntry(feed: string, pilet: string, name: string, ac?: AbortController): Promise<StorageEntryFullDTO>;
    doUpdatePiletStorageEntry(feed: string, pilet: string, name: string, details: StorageEntryUpdateDetails, ac?: AbortController): Promise<StorageEntryDetailsDTO>;
    doDeletePiletStorageEntry(feed: string, pilet: string, name: string, ac?: AbortController): Promise<StorageEntryDetailsDTO>;
    doQueryGenerators(feed: string, ac?: AbortController): Promise<GeneratorsDTO>;
    doQueryGeneratorSteps(feed: string, generator: string, ac?: AbortController): Promise<GeneratorStepDTO>;
    doGeneratePilet(feed: string, generator: string, details: GeneratePiletDetails, ac?: AbortController): Promise<GeneratePiletResult>;
    doQueryAllGenerators(ac?: AbortController): Promise<GeneratorDTO>;
    doCreateGenerator(details: CreateGeneratorDetails, ac?: AbortController): Promise<CreateGeneratorResponse>;
    doQueryGeneratorDetails(generatorId: string, ac?: AbortController): Promise<GeneratorDetails>;
    doDeleteGenerator(generatorId: string, ac?: AbortController): Promise<GeneratorResponse>;
    doQueryDashboard(ac?: AbortController): Promise<DashboardResponse>;
    doQueryDashboardFeeds(offset?: string, count?: string, ac?: AbortController): Promise<DashboardFeedsResponse>;
    doSendNotification(details: SendNotificationDetails, ac?: AbortController): Promise<unknown>;
    doQueryIssues(ac?: AbortController): Promise<IssueDTO>;
    doCreateIssue(details: CreateIssueDetails, ac?: AbortController): Promise<CreateIssueResponse>;
  }

  /**
   * The basic / core options for creating a new service client.
   */
  export interface CreateServiceClientBaseOptions {
    /**
     * Defines the host to talk to. Set this if you want to communicate
     * with your own feed service instance.
     * @default https://feed.piral.cloud
     */
    host?: string;
    /**
     * Defines the default options for `fetch` to use.
     * @default undefined
     */
    defaults?: RequestInit;
  }

  /**
   * The API key options for creating a new service client.
   */
  export type CreateServiceClientApiKeyOptions = CreateServiceClientSimpleApiKeyOptions | CreateServiceClientAdvancedApiKeyOptions;

  export interface FetchClient {
    getAuthorizationHeader(): Promise<string>;
    fetch: {
      (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
      (input: string | URL | Request, init?: RequestInit): Promise<Response>;
    };
    Headers: {
      new (init?: HeadersInit): Headers;
      prototype: Headers;
    };
    FormData: {
      new (form?: HTMLFormElement, submitter?: HTMLElement): FormData;
      prototype: FormData;
    };
    defaults: RequestInit;
  }

  export interface EventDefinitions {
    /**
     * The payload for the unauthorized event.
     * Allows retrieval of a new session to retry the request.
     */
    unauthorized: {
      /**
       * The response received from the API.
       */
      res: Response;
      /**
       * Retries the API call using an updated session.
       * @param delay The promise resolving when the call should be retried.
       */
      retry(delay: Promise<void>): void;
    };
  }

  export type EventNames = keyof EventDefinitions;

  export interface PiletMetadataDTO {
    /**
     * The name of the pilet, i.e., the package id.
     */
    name: string;
    /**
     * The version of the pilet. Should be semantically versioned.
     */
    version: string;
    /**
     * Provides the version of the specification for this pilet.
     */
    spec: string;
    /**
     * The reference name for the global require.
     */
    requireRef: string;
    /**
     * The computed integrity of the pilet.
     */
    integrity?: string;
    /**
     * The content of a v0 pilet. If the content is not available
     * the link will be used (unless caching has been activated).
     */
    content?: string;
    /**
     * If available indicates that the pilet should not be cached.
     * In case of a string this is interpreted as the expiration time
     * of the cache. In case of an accurate hash this should not be
     * required or set.
     */
    noCache?: boolean | string;
    /**
     * The computed hash value of the pilet's content. Should be
     * accurate to allow caching.
     */
    hash?: string;
    /**
     * The link for retrieving the content of the pilet.
     */
    link: string;
    /**
     * Optionally provides some custom metadata for the pilet.
     */
    custom?: any;
    /**
     * Optionally provides some configuration to be used in the pilet.
     */
    config?: Record<string, any>;
    /**
     * Additional shared dependency script files.
     */
    dependencies?: Record<string, string>;
  }

  export interface FeedsDTO extends ApiData<FeedDTO> {
    used: number;
    maximum: number;
  }

  export interface FullFeedDTO extends BaseFeedDTO {
    _details: "all";
    contributors: Array<string>;
    targetFeeds: Array<string>;
    links: Record<string, string>;
    sources: Array<FeedSourceReference>;
    domains: Array<string>;
    retentionPolicies: Array<string>;
    invalidDomains: Array<string>;
    newDomains: Array<string>;
  }

  export interface ValidSourceTags extends ApiData<string> {}

  export interface EnvironmentsDTO extends ApiData<EnvironmentDTO> {}

  export interface EnvironmentDTO {
    id: string;
    name: string;
    description: string;
    feed: string;
    source: string;
    trigger: EnvironmentTriggerType;
    time: number;
    rules: EnvironmentApprovalRules;
    format: string;
    created: string;
    changed: string;
  }

  export interface EnvironmentCreateDetails {
    name: string;
    description: string;
    source: string;
    trigger: EnvironmentTriggerType;
    time: number;
    rules: EnvironmentApprovalRules;
    format?: string;
  }

  export interface EnvironmentUpdateDetails {
    name: string;
    description: string;
    feed: string;
    source: string;
    trigger: EnvironmentTriggerType;
    time: number;
    rules: EnvironmentApprovalRules;
    format?: string;
  }

  export interface ElevationReviewsDTO extends ApiData<ElevationReviewDTO> {}

  export interface ElevationReviewCreateDetails {
    environmentId: string;
    userId: string;
    piletId: string;
    description: string;
  }

  export interface ElevationReviewUpdateDetails {
    environmentId: string;
    userId: string;
    piletId: string;
    description: string;
    status: EnvironmentApprovalStatus;
    approved: Array<string>;
    rejected: Array<string>;
  }

  export interface ElevationReviewCommentsDTO extends ApiData<ElevationReviewCommentDTO> {}

  export interface ElevationReviewCommentCreateDetails {
    elevationReviewId: string;
    userId: string;
    content: string;
  }

  export interface PagesDTO extends ApiData<PageDTO> {
    feed: string;
    tags: Array<string>;
    settings: PageSettings;
  }

  export interface PageSettingsUpdateDetails {
    settings?: Partial<PageSettings>;
  }

  export interface PageUpdateDetails extends PageSettingsUpdateDetails {
    active: boolean;
  }

  export interface PagePublishDetails {
    version: string;
    type: "custom" | "none" | "docs" | "siteless";
    embed: "yes" | "no";
    tag?: string;
    options?: any;
    files?: Array<[string, Blob]>;
  }

  export interface SelectedPiletsDTO extends ApiData<PiletDTO> {
    enabled: Array<string>;
    bundled: Array<string>;
    feed: string;
    tags: Array<string>;
  }

  export interface UploadedPiletsDTO extends ApiPaginatedData<PiletDTO> {}

  export interface PiletDetailsDTO extends PiletDTO {
    configRefs: Array<string>;
    feed: string;
    description: string;
    main: string;
    authorName: string;
    authorEmail: string;
    requireRef: string;
    enabled: boolean;
    bundled: boolean;
    dependencies: Record<string, string>;
  }

  export interface PiletReadmeDTO {
    content: string;
  }

  export interface FeedCheckDTO {
    exists: boolean;
    restore?: boolean;
    self: boolean;
    feed: string;
  }

  export interface ApiKeyScopesDTO extends ApiData<string> {
    feedScopes: Array<string>;
    generalScopes: Array<string>;
  }

  export interface ApiKeysDTO extends ApiData<ApiKeyDTO> {
    feed: string;
  }

  export interface FeaturesDTO extends ApiData<FeatureDTO> {
    feed: string;
  }

  export interface RulesDTO extends ApiData<RuleDTO> {
    feed: string;
  }

  export interface FeedCreateDetails {
    id: string;
    description: string;
    hosts?: Array<string>;
    npmRegistry?: boolean;
    integrity?: boolean;
    scanned?: boolean;
    cleanup?: number;
    hook?: string;
    contributors?: Array<string>;
    retentionPolicies?: Array<string>;
    domains?: Array<string>;
    sources?: Array<FeedSourceReference>;
  }

  export interface CreatedFeedDTO {
    id: string;
    account: string;
    description: string;
    active: boolean;
  }

  export interface FeatureCreateDetails {
    id: string;
    description?: string;
    enabled?: boolean;
  }

  export interface AddedFeatureDTO {
    feed: string;
    success: boolean;
  }

  export type RuleCreateDetails = FeatureRuleCreateDetails | PiletRuleCreateDetails;

  export interface AddedRuleDTO {
    id: string;
    feed: string;
    success: boolean;
  }

  export interface ApiKeyCreateDetails {
    name: string;
    description: string;
    expires?: string;
    constraints?: Array<string>;
    scopes?: Array<string>;
    apiKey?: string;
  }

  export interface GeneratedApiKeyDTO {
    feed: string;
    id: string;
    name: string;
    description: string;
    expires: string;
    apiKey: string;
  }

  export interface FeatureUpdateDetails {
    description?: string;
    enabled?: boolean;
  }

  export interface RuleUpdateDetails {
    description?: string;
    order?: number;
    definition?: any;
    mode?: string;
    meta?: string;
  }

  export interface PiletUpdateDetails {
    selected?: boolean;
    enabled?: boolean;
    bundled?: boolean;
    priority?: number;
    tag?: string;
    configRefs?: Array<string>;
  }

  export interface FeedUpdateDetails {
    description?: string;
    hosts?: Array<string>;
    active?: boolean;
    hook?: string;
    integrity?: boolean;
    npmRegistry?: boolean;
    cleanup?: number;
    scanned?: boolean;
    contributors?: Array<string>;
    retentionPolicies?: Array<string>;
    domains?: Array<string>;
    account?: string;
    sources?: Array<FeedSourceReference>;
  }

  export interface ApiKeyUpdateDetails {
    description?: string;
    name?: string;
    expires?: string;
  }

  export interface AuditsDTO extends ApiPaginatedData<AuditDTO> {}

  export interface AuditDTO {
    id: string;
    userId: string;
    time: string;
    actionName: string;
    areaName: string;
    areaId: string;
    objectId: string;
    details: string;
  }

  export interface AllUsersDTO extends ApiData<ServiceUserDTO> {}

  export interface FeedContributorsDTO extends ApiData<FeedContributorDTO> {
    canEdit: boolean;
  }

  export interface ContributorUpdateDetails {
    items: Array<{
      id: string;
      constraints: Array<string>;
    }>;
  }

  export interface ConfigsDTO extends ApiData<ConfigDTO> {
    feed: string;
    pilet: string;
  }

  export interface ConfigDTO extends ConfigBaseDTO {
    pilet: string;
  }

  export interface ConfigCreateDetails {
    name: string;
    value: any;
    secret?: boolean;
  }

  export interface ConfigUpdateDetails {
    value: any;
  }

  export interface AllFeedConfigsDTO extends ApiData<string> {
    feed: string;
  }

  export interface FeedConfigsDTO extends ApiData<FeedConfigDTO> {
    feed: string;
    config: string;
  }

  export interface FeedConfigDTO extends ConfigBaseDTO {
    id: string;
  }

  export interface EntitiesDTO extends ApiData<EntityDTO> {
    feed: string;
  }

  export interface EntityDTO {
    id: string;
    feed: string;
    type: string;
    name: string;
    pilet: string;
    description: string;
    order: number;
    changed: string;
  }

  export interface EntityCreateDetails {
    pilet: string;
    name: string;
    description: string;
    type: string;
  }

  export interface EntityUpdateDetails {
    description?: string;
    order?: number;
  }

  export interface ExternalUsersDTO extends ApiData<ExternalUserDTO> {}

  export interface UsersDTO extends ApiData<UserDTO> {}

  export interface UserDTO {
    id: string;
    name: string;
    provider: string;
    plan: string;
    role: string;
    created: string;
    changed: string;
    self: boolean;
    canCreateFeed: boolean | null;
  }

  export interface UserCreateDetails {
    id: string;
    provider: string;
    name?: string;
    email?: string;
    plan?: string;
    role?: string;
    canCreateFeed?: boolean | null;
  }

  export interface ChangedUserDTO {
    id: string;
    passphrase: string;
    success: boolean;
  }

  export interface DeletedUserDTO {
    id: string;
    success: boolean;
  }

  export interface UserUpdateDetails {
    name?: string;
    provider?: string;
    plan?: string;
    role?: string;
    resetpass?: boolean;
    canCreateFeed?: boolean | null;
  }

  export interface CustomRuleModulesDTO {
    items: Array<CustomRuleModuleDTO>;
  }

  export interface GroupsDTO extends ApiData<GroupDTO> {}

  export interface GroupDetailsDTO extends GroupDTO {
    changed: string;
    created: string;
    owner: string;
    admin: boolean;
    referencedBy: Array<string>;
    members: Array<{
      id: string;
      name: string;
      type: ServiceUserType;
    }>;
  }

  export interface GroupCreateDetails {
    name: string;
    description?: string;
    members?: Array<string>;
  }

  export interface GroupUpdateDetails {
    name?: string;
    description?: string;
    members?: Array<string>;
  }

  export interface DeletedGroupDTO {
    id: string;
    success: boolean;
  }

  export interface ChangedCustomRuleModuleDTO {
    success: boolean;
    file: string;
    rules: Array<string>;
  }

  export interface CustomRuleDetailsDTO {
    file: string;
    content: string;
    rules?: Array<string>;
    error?: string;
  }

  export interface TestRuleDetails {
    headers: Record<string, string>;
    query: Record<string, string>;
  }

  export interface TestRuleResultDTO {
    result: boolean;
  }

  export interface CurrentUserDTO {
    id: string;
    name: string;
    provider: string;
    plan: string;
    role: string;
    created: string;
    changed: string;
    settings: Record<string, any>;
    canCreateFeed: boolean;
  }

  export interface CurrentUserUpdateDetails {
    name?: string;
    resetpass?: boolean;
    oldPassword?: string;
    newPassword?: string;
    settings?: Record<string, any>;
  }

  export interface StatusDTO {
    instanceId: string;
    started: string;
    status: "healthy" | "unhealthy";
    modules: Array<string>;
    healthy: boolean;
    version: string;
    requests: {
      count: number;
      avg: number;
    };
    ping: string;
  }

  export interface StatisticsDTO {
    accounts: number;
    apiKeys: number;
    feeds: number;
    piletAlls: number;
    piletCurrents: number;
    rules: number;
  }

  export interface FeedAnalysisDTO {
    items: Array<PiletAnalysisDTO>;
  }

  export interface PiletAnalysisDTO {
    name: string;
    version: string;
    spec: string;
    report: {
      dependencies: {
        referenced: Array<{
          name: string;
          version: string;
          distributed: boolean;
        }>;
        included: Array<{
          name: string;
          version: string;
          href: string;
        }>;
      };
      metrics: {
        files: {
          total: number;
          css: number;
          html: number;
          js: number;
          json: number;
          maps: number;
          images: number;
          videos: number;
          assemblies: number;
          wasm: number;
        };
        size: {
          total: number;
          css: number;
          json: number;
          html: number;
          js: number;
        };
        entryPoints: Array<{
          path: string;
          size: number;
        }>;
      };
      styles: {
        sheets: Array<{
          name: string;
          selectors: Array<string>;
          score: number;
          conflicts: Array<string>;
        }>;
      };
      scripts: {
        files: Array<{
          name: string;
          score: number;
          vulnerabilities: Array<VulnerabilityResult>;
        }>;
      };
    };
  }

  export interface VulnerabilityReportDTO {
    name: string;
    report: FeedVulnerabilityAnalysisDTO;
  }

  export interface FeedStatisticsDTO {
    feedRequests: Array<FeedRequestsDTO>;
    feedUserCountries: Array<FeedUserCountriesDTO>;
  }

  export interface AdminStatisticsDTO extends ApiPaginatedData<AdminStatisticsItemDTO> {}

  export interface AdminStatisticsDetailsDTO {
    feedRequests: Array<FeedRequestsDTO>;
    feedUserCountries: Array<FeedUserCountriesDTO>;
    feedContributors: number;
    feedSources: number;
    feedPilets: AdminStatisticsFeedPiletsDTO;
  }

  export interface NpmRegistryDTO extends ApiData<NpmItemDTO> {
    feed: string;
  }

  export interface NpmPackageDTO {
    _id: string;
    name: string;
    description: string;
    "dist-tags": Record<string, string>;
    versions: Record<string, {
      name: string;
      description: string;
      version: string;
      keywords: Array<string>;
      readme: string;
      _from: string;
      _resolved: string;
      _integrity: string;
      _id: string;
      _nodeVersion: string;
      _npmVersion: string;
      dist: {
        integrity: string;
        shasum: string;
        tarball: string;
      };
    }>;
  }

  export interface LicenseInfo {
    /**
     * The reference name identifying the licensee.
     */
    customer: string;
    /**
     * The expiration date of the license provided as an ISO-datetime string.
     */
    expires: string;
  }

  export interface StorageEntriesDTO extends ApiData<StorageEntryDTO> {}

  export interface StorageEntryDetailsDTO extends StorageEntryDTO {
    feed: string;
    pilet: string;
  }

  export interface StorageEntryFullDTO extends StorageEntryDetailsDTO {
    content: string;
  }

  export interface StorageEntryUpdateDetails {
    content: string;
  }

  export interface GeneratorsDTO extends ApiData<GeneratorDTO> {}

  export interface GeneratorStepDTO extends GeneratorDTO {
    steps: Array<any>;
  }

  export interface GeneratePiletDetails {
    name: string;
    version: string;
    input: Record<string, any>;
  }

  export interface GeneratePiletResult {
    feed: string;
    id: string;
    url: string;
  }

  export interface GeneratorDTO {
    id: string;
    name: string;
    version: string;
    author: string;
    description: string;
  }

  export interface CreateGeneratorDetails {
    file: string;
    content: string;
  }

  export interface CreateGeneratorResponse extends GeneratorResponse {
    error: string;
  }

  export interface GeneratorDetails extends GeneratorDTO {
    file: string;
    error: string;
    readOnly: boolean;
    version: string;
    icon: string;
  }

  export interface GeneratorResponse {
    id: string;
    success: boolean;
    name: string;
    version: string;
  }

  export interface DashboardResponse extends ApiData<RecentChange> {}

  export interface DashboardFeedsResponse extends ApiData<DashboardFeed> {}

  export interface SendNotificationDetails {
    subject: string;
    content: string;
    recipients: Array<string>;
    severity?: "info" | "critical" | "high" | "medium" | "low";
  }

  export interface IssueDTO extends ApiData<NotificationItem> {}

  export interface CreateIssueDetails {
    topic: string;
    content: string;
  }

  export interface CreateIssueResponse {
    id: string;
    success: boolean;
  }

  /**
   * The simple API key options for creating a new service client.
   */
  export interface CreateServiceClientSimpleApiKeyOptions {
    /**
     * Defines the API key to use for making the HTTP calls. Needs
     * to be provided.
     */
    apiKey: string;
  }

  /**
   * The advanced API key options for creating a new service client.
   */
  export interface CreateServiceClientAdvancedApiKeyOptions {
    /**
     * Defines the API key to use for making the HTTP calls. Needs
     * to be provided.
     */
    resolveApiKey(): Promise<string>;
    /**
     * Defines the type of the resolved API key.
     */
    apiKeyType?: "basic" | "bearer" | "none";
  }

  export interface ApiData<T> {
    items: Array<T>;
  }

  export type FeedDTO = ShortFeedDTO | FullFeedDTO;

  export interface BaseFeedDTO {
    id: string;
    name: string;
    account: string;
    description: string;
    active: boolean;
    deleted: boolean;
    integrity: boolean;
    npmRegistry: boolean;
    scanned: boolean;
    hook: string;
    hosts: Array<string>;
    owner: boolean;
    canEdit: boolean;
    canAddUser: boolean;
    canDelete: boolean;
    plan: string;
    cleanup?: number;
  }

  export interface FeedSourceReference {
    type: string;
    source: string;
  }

  export type EnvironmentTriggerType = "immediate" | "periodically" | "delayed" | "manual";

  export interface EnvironmentApprovalRules {
    canSelfApprove: boolean;
    reviewers: {
      min: number;
      required: Array<string>;
      allowed: Array<string>;
      excluded: Array<string>;
    };
  }

  export interface ElevationReviewDTO {
    id: string;
    environmentId: string;
    userId: string;
    piletId: string;
    description: string;
    status: EnvironmentApprovalStatus;
    approved: Array<string>;
    rejected: Array<string>;
    date: Date;
  }

  export type EnvironmentApprovalStatus = "approved" | "rejected" | "pending" | "none";

  export interface ElevationReviewCommentDTO {
    id: string;
    elevationReviewId: string;
    userId: string;
    content: string;
    date: Date;
  }

  export interface PageDTO {
    feed: string;
    type: "custom" | "siteless" | "none";
    version: string;
    active: boolean;
  }

  export interface PageSettings {
    fallback: string;
    auth: "none" | "feed" | "user";
    headers: Array<{
      name: string;
      value: string;
    }>;
  }

  export interface PiletDTO {
    id: string;
    name: string;
    version: string;
    hash: string;
    tag: string;
    selected: boolean;
    priority: number;
    schema: PiletType;
    canSetTag: boolean;
    canBundle: boolean;
    canDelete: boolean;
    created: string;
  }

  export interface ApiPaginatedData<T> {
    items: Array<T>;
    continuation: string;
  }

  export interface ApiKeyDTO {
    id: string;
    name: string;
    description: string;
    revoked: boolean;
    expires: string;
    scopes: Array<string>;
    constraints: Array<string>;
  }

  export interface FeatureDTO {
    id: string;
    description: string;
    changed: string;
    enabled: boolean;
  }

  export interface RuleDTO {
    id: string;
    order: number;
    feed: string;
    pilet?: string;
    feature?: string;
    description: string;
    meta?: string;
    mode: "allow" | "block";
    definition: any;
  }

  export interface FeatureRuleCreateDetails extends BaseRuleCreateDetails {
    feature: string;
  }

  export interface PiletRuleCreateDetails extends BaseRuleCreateDetails {
    pilet: string;
  }

  export interface ServiceUserDTO {
    id: string;
    name: string;
    type: ServiceUserType;
  }

  export interface FeedContributorDTO {
    id: string;
    name: string;
    verified: boolean;
    constraints: Array<string>;
  }

  export interface ConfigBaseDTO {
    name: string;
    value: any;
    feed: string;
    secret: boolean;
    created: string;
    changed: string;
  }

  export interface ExternalUserDTO {
    id: string;
    externalId: string;
    name: string;
    email: string;
  }

  export interface CustomRuleModuleDTO {
    file: string;
    success: boolean;
    source: "vs" | "fs";
    rules?: Array<string>;
    error?: string;
  }

  export interface GroupDTO {
    id: string;
    name: string;
    description: string;
    memberCount: number;
  }

  export type ServiceUserType = "user" | "group";

  export interface VulnerabilityResult {
    summary: string;
    value?: string;
    severity: VulnerabilitySeverityLevel;
    source: string;
  }

  export interface FeedVulnerabilityAnalysisDTO {
    issues: Record<string, Array<string>>;
    pilets: Record<string, Array<string>>;
    dependencies: Array<string>;
    lastScanned: string;
  }

  export interface FeedRequestsDTO {
    count: number;
    from: string;
    to: string;
  }

  export interface FeedUserCountriesDTO {
    name: string;
    count: number;
  }

  export interface AdminStatisticsItemDTO {
    id: string;
    name: string;
    owner: string;
    enabled: boolean;
    requestsToday: number;
    requestsLastMonth: number;
  }

  export interface AdminStatisticsFeedPiletsDTO {
    current: number;
    all: number;
  }

  export interface NpmItemDTO {
    feed: string;
    id: string;
    name: string;
    version: string;
    created: string;
  }

  export interface StorageEntryDTO {
    name: string;
  }

  export interface RecentChange {
    id: string;
    time: string;
    userId: string;
    feed: string;
    type: string;
    value: any;
  }

  export interface DashboardFeed {
    id: string;
    name: string;
    account: string;
    description: string;
    active: boolean;
    deleted: boolean;
    integrity: boolean;
    npmRegistry: boolean;
    hook: string;
    hosts: Array<string>;
  }

  export interface NotificationItem {}

  export interface ShortFeedDTO extends BaseFeedDTO {
    contributors: undefined;
    targetFeeds: undefined;
    sources: undefined;
  }

  export type PiletType = "v0" | "v1" | "v2" | "oc" | "sspa" | "wmf" | "nf" | "esm" | "json" | "yaml";

  export interface BaseRuleCreateDetails {
    description: string;
    definition: any;
    mode: "allow" | "block";
    meta?: string;
  }

  export type VulnerabilitySeverityLevel = "none" | "low" | "medium" | "high" | "critical";
}