mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
* Add extensions system provide and useExtensions composable * Expose useExtensions through extensions-sdk
29 lines
819 B
TypeScript
29 lines
819 B
TypeScript
import { inject } from 'vue';
|
|
import { AxiosInstance } from 'axios';
|
|
import { API_INJECT, EXTENSIONS_INJECT, STORES_INJECT } from '../constants';
|
|
import { AppExtensionConfigs } from '../types';
|
|
|
|
export function useStores(): Record<string, any> {
|
|
const stores = inject<Record<string, any>>(STORES_INJECT);
|
|
|
|
if (!stores) throw new Error('[useStores]: The stores could not be found.');
|
|
|
|
return stores;
|
|
}
|
|
|
|
export function useApi(): AxiosInstance {
|
|
const api = inject<AxiosInstance>(API_INJECT);
|
|
|
|
if (!api) throw new Error('[useApi]: The api could not be found.');
|
|
|
|
return api;
|
|
}
|
|
|
|
export function useExtensions(): AppExtensionConfigs {
|
|
const extensions = inject<AppExtensionConfigs>(EXTENSIONS_INJECT);
|
|
|
|
if (!extensions) throw new Error('[useExtensions]: The extensions could not be found.');
|
|
|
|
return extensions;
|
|
}
|