import CancelablePromise from 'apprt-core/CancelablePromise'; import { ServiceInstance, ComponentContext, ComponentProperties, Bundle, BundleContext, ServiceReference, BundleId, ServiceEvent, AnyPropertyValue, ConfigurationStore, ConfigAdminService, ConfigurationStoreEntry, Configuration, AppConfigJson } from 'apprt/api'; interface InternalComponentContext extends ComponentContext { dispose(): void; _getInstance(): ExpectedServiceType | undefined; _getFactoryInstance(): ExpectedServiceType | undefined; _setFactoryInstance(instance: ExpectedServiceType | undefined): void; _setInstance(instance: ExpectedServiceType | undefined): void; _activated: CancelablePromise | boolean; } interface InternalComponent { readonly pid: string; readonly factoryPid: string | undefined; readonly _name: string; readonly log: string[]; readonly configPolicy: ComponentDefinition["configPolicy"]; getId(): number; getName(): string; isActive(): boolean; isEnabled(): boolean; getBundle(): Bundle; getProperties(): ComponentProperties; getComponentContextCount(): number; getBundleContext(): BundleContext; getResourceURL(subPath: string, otherNamespace?: string): string; disposeComponentContext(ctx?: InternalComponentContext): void; locateServiceReferences(name: string): ReadonlyArray; locateService(name: string, reference: ServiceReference): ServiceType | undefined; enableComponent(name?: string, ok?: boolean): void; disableComponent(name?: string): void; getComponentContext(bundleId?: BundleId): InternalComponentContext | undefined; createNewComponent(name: string, properties?: ComponentProperties, noError?: boolean): InternalComponent; updated(properties: ComponentProperties): void; getReferenceInterfaces(): string[]; onServiceChangedListener(evt: ServiceEvent): void; } interface ComponentDefinition { name: string; impl?: string; enabled?: boolean; configPolicy?: "optional" | "ignore"; componentFactory?: boolean; propertiesConstructor?: boolean; instanceFactory?: boolean; serviceFactory?: boolean; provides?: string[] | string; immediate?: boolean; init?: string; destroy?: string; activate?: string; deactivate?: string; modified?: string; createInstance?: string; destroyInstance?: string; references?: ComponentReferenceDefinition[]; privateProperties?: string[]; publicProperties?: string[]; properties?: ComponentProperties; } interface ComponentReferenceDefinition { name: string; providing: string; filter?: string; policy?: "dynamic" | "static"; noInjection?: boolean; cardinality?: string; bind?: string; unbind?: string; connect?: Record; on?: Record; watch?: Record; } interface IdGenerator { nextId(): number; } interface ComponentRuntime { getComponent(bundle: Bundle, name: string): InternalComponent | undefined; registerComponent(bundle: Bundle, component: InternalComponent): void; unregisterComponent(bundle: Bundle, component: InternalComponent): void; componentEnabled(component: InternalComponent): void; componentDisabled(component: InternalComponent): void; } interface ComponentPropertiesMap { get(key: string): T | undefined; set(key: string, value: T): void; has(key: string): boolean; flat(): ComponentProperties; clone(): ComponentPropertiesMap; } type ComponentServiceInstance = ServiceInstance & { [key: string]: any; }; interface InternalConfigurationStore extends ConfigurationStore { save(): Promise; } interface InternalConfigAdminService extends ConfigAdminService { listConfigurations(filter: (entry: ConfigurationStoreEntry) => boolean): Configuration[]; /** * Updates a configuration instance. */ updateConfiguration(config: Configuration, properties: ComponentProperties): void; /** * Removes/deletes a configuration instance. */ removeConfiguration(config: Configuration): void; } interface PersistencePlugin { save(item: { appConfig: AppConfigJson; appLocation: string; appName: string; }): Promise; } export type { ComponentDefinition, ComponentPropertiesMap, ComponentReferenceDefinition, ComponentRuntime, ComponentServiceInstance, IdGenerator, InternalComponent, InternalComponentContext, InternalConfigAdminService, InternalConfigurationStore, PersistencePlugin };