45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { CollectionService as AbstractCollectionService } from "@bitwarden/common/admin-console/abstractions/collection.service";
|
|
import { CollectionService } from "@bitwarden/common/admin-console/services/collection.service";
|
|
|
|
import {
|
|
cryptoServiceFactory,
|
|
CryptoServiceInitOptions,
|
|
} from "../../../platform/background/service-factories/crypto-service.factory";
|
|
import {
|
|
CachedServices,
|
|
factory,
|
|
FactoryOptions,
|
|
} from "../../../platform/background/service-factories/factory-options";
|
|
import {
|
|
i18nServiceFactory,
|
|
I18nServiceInitOptions,
|
|
} from "../../../platform/background/service-factories/i18n-service.factory";
|
|
import {
|
|
stateServiceFactory as stateServiceFactory,
|
|
StateServiceInitOptions,
|
|
} from "../../../platform/background/service-factories/state-service.factory";
|
|
|
|
type CollectionServiceFactoryOptions = FactoryOptions;
|
|
|
|
export type CollectionServiceInitOptions = CollectionServiceFactoryOptions &
|
|
CryptoServiceInitOptions &
|
|
I18nServiceInitOptions &
|
|
StateServiceInitOptions;
|
|
|
|
export function collectionServiceFactory(
|
|
cache: { collectionService?: AbstractCollectionService } & CachedServices,
|
|
opts: CollectionServiceInitOptions
|
|
): Promise<AbstractCollectionService> {
|
|
return factory(
|
|
cache,
|
|
"collectionService",
|
|
opts,
|
|
async () =>
|
|
new CollectionService(
|
|
await cryptoServiceFactory(cache, opts),
|
|
await i18nServiceFactory(cache, opts),
|
|
await stateServiceFactory(cache, opts)
|
|
)
|
|
);
|
|
}
|