import { useSDKContext } from './context'; import { EventTopic, BaseModel } from '../models'; export const useBaseModelRelation = (model: any, classProp: string) => { if (model) { if (model[classProp]) { return model[classProp]; } } throw new Error(`'${classProp}' does not exist in Model (${model.name}).`); }; export const useSDKModel = (classProp: string): BaseModel => { const { api } = useSDKContext(); if (api) { if (api[classProp]) { return api[classProp]; } } throw new Error(`'${classProp}' does not exist in API.`); }; export const useSDKEventBus = (): EventTopic => { const { eventBus } = useSDKContext(); if (eventBus) { return eventBus; } throw new Error( 'eventBus is not properly initialized in useSDKContext. Did you attach the Provider?', ); }; export const useResetStore = (): (() => void) => { const { api } = useSDKContext(); if (api) { return api.resetStore.bind(api); } throw new Error( 'API is not properly initialized in useSDKContext. Did you attach the Provider?', ); };