{"version":3,"file":"momento.cjs","names":["CreateCache"],"sources":["../../src/utils/momento.ts"],"sourcesContent":["/* eslint-disable no-instanceof/no-instanceof */\nimport { ICacheClient, CreateCache } from \"@gomomento/sdk-core\";\n\n/**\n * Utility function to ensure that a Momento cache exists.\n * If the cache does not exist, it is created.\n *\n * @param client The Momento cache client.\n * @param cacheName The name of the cache to ensure exists.\n */\nexport async function ensureCacheExists(\n  client: ICacheClient,\n  cacheName: string\n): Promise<void> {\n  const createResponse = await client.createCache(cacheName);\n  if (\n    createResponse instanceof CreateCache.Success ||\n    createResponse instanceof CreateCache.AlreadyExists\n  ) {\n    // pass\n  } else if (createResponse instanceof CreateCache.Error) {\n    throw createResponse.innerException();\n  } else {\n    throw new Error(`Unknown response type: ${createResponse.toString()}`);\n  }\n}\n"],"mappings":";;;;;;;;;;AAUA,eAAsB,kBACpB,QACA,WACe;CACf,MAAM,iBAAiB,MAAM,OAAO,YAAY,UAAU;AAC1D,KACE,0BAA0BA,oBAAAA,YAAY,WACtC,0BAA0BA,oBAAAA,YAAY,eACtC,YAES,0BAA0BA,oBAAAA,YAAY,MAC/C,OAAM,eAAe,gBAAgB;KAErC,OAAM,IAAI,MAAM,0BAA0B,eAAe,UAAU,GAAG"}