{"version":3,"file":"context.mjs","sources":["../../src/router/context.ts"],"sourcesContent":["/**\n * Utility which allows resolution of resourceful model context.\n * @module @nhtio/lucid-resourceful/router/context\n */\n\nimport { E_NOT_IN_MODEL_CONTEXT } from '@nhtio/lucid-resourceful/errors'\nimport { ResourcefulHttpContext } from '@/private/router_macro/services/resourceful_router_context_service'\nimport type { ResolvedResourcefulHttpContext } from '@/private/router_macro/services/resourceful_router_context_service'\n\nexport const useResourcefulModelContext = async (): Promise<ResolvedResourcefulHttpContext> => {\n  try {\n    const store = ResourcefulHttpContext.getStore()\n    if (!store || !('resolver' in store) || 'function' !== typeof store.resolver) {\n      throw new E_NOT_IN_MODEL_CONTEXT()\n    }\n    return await store.resolver()\n  } catch (err) {\n    throw new E_NOT_IN_MODEL_CONTEXT(err)\n  }\n}\n\nexport type { ResolvedResourcefulHttpContext }\n"],"names":[],"mappings":";;AASO,MAAM,6BAA6B,YAAqD;AAC7F,MAAI;AACF,UAAM,QAAQ,uBAAuB,SAAA;AACrC,QAAI,CAAC,SAAS,EAAE,cAAc,UAAU,eAAe,OAAO,MAAM,UAAU;AAC5E,YAAM,IAAI,uBAAA;AAAA,IACZ;AACA,WAAO,MAAM,MAAM,SAAA;AAAA,EACrB,SAAS,KAAK;AACZ,UAAM,IAAI,uBAAuB,GAAG;AAAA,EACtC;AACF;"}