backend-plugin-api: update API report + fixes

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-01-13 17:40:46 +01:00
parent d08a7251fe
commit c1369c2cf4
2 changed files with 133 additions and 42 deletions
+118 -33
View File
@@ -126,22 +126,86 @@ export function createExtensionPoint<T>(
config: ExtensionPointConfig,
): ExtensionPoint<T>;
// @public (undocumented)
// @public
export function createServiceFactory<
TService,
TScope extends 'root' | 'plugin',
TImpl extends TService,
TDeps extends {
[name in string]: ServiceRef<unknown>;
},
TOpts extends [options?: object] = [],
TOpts extends object | undefined = undefined,
>(
config: RootServiceFactoryConfig<TService, TImpl, TDeps>,
): () => ServiceFactory<TService>;
// @public
export function createServiceFactory<
TService,
TImpl extends TService,
TDeps extends {
[name in string]: ServiceRef<unknown>;
},
TOpts extends object | undefined = undefined,
>(
config: (options?: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>,
): (options?: TOpts) => ServiceFactory<TService>;
// @public
export function createServiceFactory<
TService,
TImpl extends TService,
TDeps extends {
[name in string]: ServiceRef<unknown>;
},
TOpts extends object | undefined = undefined,
>(
config: (options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>,
): (options: TOpts) => ServiceFactory<TService>;
// @public
export function createServiceFactory<
TService,
TImpl extends TService,
TDeps extends {
[name in string]: ServiceRef<unknown>;
},
TContext = undefined,
TOpts extends object | undefined = undefined,
>(
config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>,
): () => ServiceFactory<TService>;
// @public
export function createServiceFactory<
TService,
TImpl extends TService,
TDeps extends {
[name in string]: ServiceRef<unknown>;
},
TContext = undefined,
TOpts extends object | undefined = undefined,
>(
config: (
options?: TOpts,
) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>,
): (options?: TOpts) => ServiceFactory<TService>;
// @public
export function createServiceFactory<
TService,
TImpl extends TService,
TDeps extends {
[name in string]: ServiceRef<unknown>;
},
TContext = undefined,
TOpts extends object | undefined = undefined,
>(
config:
| ServiceFactoryConfig<TService, TScope, TImpl, TDeps>
| PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>
| ((
...options: TOpts
) => ServiceFactoryConfig<TService, TScope, TImpl, TDeps>),
): (...params: TOpts) => ServiceFactory<TService>;
options: TOpts,
) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>),
): (options: TOpts) => ServiceFactory<TService>;
// @public
export function createServiceRef<TService>(
@@ -229,6 +293,30 @@ export interface PluginMetadataService {
getId(): string;
}
// @public (undocumented)
export interface PluginServiceFactoryConfig<
TService,
TContext,
TImpl extends TService,
TDeps extends {
[name in string]: ServiceRef<unknown>;
},
> {
// (undocumented)
createRootContext?(
deps: ServiceRefsToInstances<TDeps, 'root'>,
): Promise<TContext>;
// (undocumented)
deps: TDeps;
// (undocumented)
factory(
deps: ServiceRefsToInstances<TDeps>,
context: TContext,
): Promise<TImpl>;
// (undocumented)
service: ServiceRef<TService, 'plugin'>;
}
// @public
export type ReadTreeOptions = {
filter?(
@@ -284,6 +372,22 @@ export interface RootLifecycleService extends LifecycleService {}
// @public (undocumented)
export interface RootLoggerService extends LoggerService {}
// @public (undocumented)
export interface RootServiceFactoryConfig<
TService,
TImpl extends TService,
TDeps extends {
[name in string]: ServiceRef<unknown>;
},
> {
// (undocumented)
deps: TDeps;
// (undocumented)
factory(deps: ServiceRefsToInstances<TDeps, 'root'>): Promise<TImpl>;
// (undocumented)
service: ServiceRef<TService, 'root'>;
}
// @public (undocumented)
export interface SchedulerService extends PluginTaskScheduler {}
@@ -323,36 +427,17 @@ export type ServiceFactory<TService = unknown> =
deps: {
[key in string]: ServiceRef<unknown>;
};
factory(deps: {
createRootContext?(deps: {
[key in string]: unknown;
}): Promise<
(deps: {
}): Promise<unknown>;
factory(
deps: {
[key in string]: unknown;
}) => Promise<TService>
>;
},
context: unknown,
): Promise<TService>;
};
// @public (undocumented)
export interface ServiceFactoryConfig<
TService,
TScope extends 'root' | 'plugin',
TImpl extends TService,
TDeps extends {
[name in string]: ServiceRef<unknown>;
},
> {
// (undocumented)
deps: TDeps;
// (undocumented)
factory(
deps: ServiceRefsToInstances<TDeps, 'root'>,
): TScope extends 'root'
? Promise<TImpl>
: Promise<(deps: ServiceRefsToInstances<TDeps>) => Promise<TImpl>>;
// (undocumented)
service: ServiceRef<TService, TScope>;
}
// @public
export type ServiceFactoryOrFunction<TService = unknown> =
| ServiceFactory<TService>
@@ -166,10 +166,10 @@ export interface PluginServiceFactoryConfig<
}
/**
* Creates a root scoped service factory.
* Creates a root scoped service factory without options.
*
* @public
* @param config
* @param config - The service factory configuration.
*/
export function createServiceFactory<
TService,
@@ -183,7 +183,7 @@ export function createServiceFactory<
* Creates a root scoped service factory with optional options.
*
* @public
* @param config
* @param config - The service factory configuration.
*/
export function createServiceFactory<
TService,
@@ -194,10 +194,10 @@ export function createServiceFactory<
config: (options?: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>,
): (options?: TOpts) => ServiceFactory<TService>;
/**
* Creates a plugin scoped service factory with required options.
* Creates a root scoped service factory with required options.
*
* @public
* @param config
* @param config - The service factory configuration.
*/
export function createServiceFactory<
TService,
@@ -208,10 +208,10 @@ export function createServiceFactory<
config: (options: TOpts) => RootServiceFactoryConfig<TService, TImpl, TDeps>,
): (options: TOpts) => ServiceFactory<TService>;
/**
* Creates a plugin scoped service factory with optional options.
* Creates a plugin scoped service factory without options.
*
* @public
* @param config
* @param config - The service factory configuration.
*/
export function createServiceFactory<
TService,
@@ -223,10 +223,10 @@ export function createServiceFactory<
config: PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>,
): () => ServiceFactory<TService>;
/**
* Creates a plugin scoped service factory with required options.
* Creates a plugin scoped service factory with optional options.
*
* @public
* @param config
* @param config - The service factory configuration.
*/
export function createServiceFactory<
TService,
@@ -239,6 +239,12 @@ export function createServiceFactory<
options?: TOpts,
) => PluginServiceFactoryConfig<TService, TContext, TImpl, TDeps>,
): (options?: TOpts) => ServiceFactory<TService>;
/**
* Creates a plugin scoped service factory with required options.
*
* @public
* @param config - The service factory configuration.
*/
export function createServiceFactory<
TService,
TImpl extends TService,