{"version":3,"file":"useDpiContext.mjs","sources":["../../../lib/data-provider-interface/composables/useDpiContext.ts"],"sourcesContent":["import { FormKitLibrary } from \"@formkit/core\"\nimport { computed, ComputedRef, getCurrentInstance, inject, InjectionKey, MaybeRefOrGetter, provide, toValue } from \"vue\"\n\nexport interface DpiSpecification {\n  pageConent?: object\n  inputDefinition: object\n  prefixes: object\n  formatTypes: object\n  vocabPrefixes: object\n}\n\nexport interface DpiContext {\n  specification: DpiSpecification\n  specificationName: string\n  edit?: {\n    enabled?: boolean\n    catalog?: string\n    id?: string\n    fromDraft?: boolean\n  }\n}\n\nexport type ComputedDpiContext = ComputedRef<DpiContext>\n\nexport const dpiContextKey: InjectionKey<ComputedDpiContext> = Symbol('dpiContext')\n\nexport function useDpiContext(): ComputedDpiContext {\n  const dpiContext = inject(dpiContextKey)\n\n  if (!dpiContext) {\n    throw new Error('[useDpiContext] DPI Context not found. Did you forget to inject it?')\n  }\n\n  return dpiContext\n}\n\nexport function setupDpiContext(context: MaybeRefOrGetter<DpiContext>) {\n  provide(dpiContextKey, computed(() => toValue(context)))\n}"],"names":["dpiContextKey","useDpiContext","dpiContext","inject","setupDpiContext","context","provide","computed","toValue"],"mappings":";AAwBa,MAAAA,IAAkD,OAAO,YAAY;AAE3E,SAASC,IAAoC;AAC5C,QAAAC,IAAaC,EAAOH,CAAa;AAEvC,MAAI,CAACE;AACG,UAAA,IAAI,MAAM,qEAAqE;AAGhF,SAAAA;AACT;AAEO,SAASE,EAAgBC,GAAuC;AACrE,EAAAC,EAAQN,GAAeO,EAAS,MAAMC,EAAQH,CAAO,CAAC,CAAC;AACzD;"}