{"version":3,"sources":["../../src/ssr-v1-invalidate-cache-request-cache.universal.ts","../../src/ssr-v1-invalidate-cache-request-cache.http.ts","../../src/ssr-v1-invalidate-cache-request-cache.public.ts","../../src/ssr-v1-invalidate-cache-request-cache.context.ts"],"sourcesContent":["import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport { renameKeysFromSDKRequestToRESTRequest } from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient } from '@wix/sdk-types';\nimport * as ambassadorWixSsrV1InvalidateCacheRequest from './ssr-v1-invalidate-cache-request-cache.http.js';\n\nexport interface InvalidateCacheRequest {\n  /**\n   * An array of objects containing a `tag` field used to identify the cache to invalidate. All cached return values with any listed tags are invalidated. If no tags are specified, nothing is invalidated.\n   * @maxSize 100\n   */\n  invalidationMethods?: InvalidationMethods[];\n}\n\nexport interface InvalidationMethods\n  extends InvalidationMethodsInvalidateByOneOf {\n  /**\n   * *Required.** Identifier of the caches to invalidate.\n   * @maxLength 500\n   * @minLength 1\n   */\n  tag?: string;\n}\n\n/** @oneof */\nexport interface InvalidationMethodsInvalidateByOneOf {\n  /**\n   * *Required.** Identifier of the caches to invalidate.\n   * @maxLength 500\n   * @minLength 1\n   */\n  tag?: string;\n}\n\nexport interface InvalidateCacheResponse {}\n\nexport interface PurgeSiteCacheRequest {}\n\nexport interface PurgeSiteCacheResponse {}\n\n/**\n * <blockquote class=\"important\">\n *\n * __Important:__\n * This API is only supported for developing sites and works only when used together with the Web Methods or Router APIs.\n *\n * </blockquote>\n *\n * Invalidates or clears previously cached return values based on specified tags.\n *\n * The `invalidationMethods` parameter accepts an array of objects, each containing a `tag` field. These tags are defined when caching return values of site [web methods](https://dev.wix.com/docs/sdk/core-modules/web-methods/introduction) and [routers](https://dev.wix.com/docs/velo/events-service-plugins/routers/service-plugins/wix-router/introduction#events-service-plugins_routers_service-plugins_wix-router_router-caching).\n *\n * For example, an array such as `[{ tag: \"contacts\" }, { tag: \"labels\" }]` will clear any cached return values tagged with \"contacts\" or \"labels.\"\n *\n * Any cache containing at least one tag specified in the `invalidationMethods` parameter will be cleared.\n *\n * >**Notes:**\n * >- If you don't specify any tags in the `invalidationMethods` parameter, no caches are invalidated.\n * >- If you don't call Invalidate Cache, caches are only invalidated when the Time to Live (TTL) expires or when the site is republished with a code change.\n * >- This method does not invalidate the Server Side Rendering (SSR) cache for your site. To invalidate that cache, use the Invalidate Cache method from the [`wix-site-backend`](https://dev.wix.com/docs/velo/api-reference/wix-site-backend/invalidate-cache) module.\n * @param invalidationMethods - An array of objects containing a `tag` field used to identify the cache to invalidate. All cached return values with any listed tags are invalidated. If no tags are specified, nothing is invalidated.\n * @public\n * @documentationMaturity preview\n * @requiredField invalidationMethods\n * @permissionId SSR.INVALIDATE_CACHE\n * @fqn com.wixpress.html.cache.invalidate.InvalidateCacheService.invalidateCache\n */\nexport async function invalidateCache(\n  invalidationMethods: InvalidationMethods[]\n): Promise<void> {\n  // @ts-ignore\n  const { httpClient, sideEffects } = arguments[1] as {\n    httpClient: HttpClient;\n    sideEffects?: any;\n  };\n\n  const payload = renameKeysFromSDKRequestToRESTRequest({\n    invalidationMethods: invalidationMethods,\n  });\n\n  const reqOpts =\n    ambassadorWixSsrV1InvalidateCacheRequest.invalidateCache(payload);\n\n  sideEffects?.onSiteCall?.();\n  try {\n    const result = await httpClient.request(reqOpts);\n    sideEffects?.onSuccess?.(result);\n  } catch (err: any) {\n    const transformedError = sdkTransformError(\n      err,\n      {\n        spreadPathsToArguments: {},\n        explicitPathsToArguments: { invalidationMethods: '$[0]' },\n        singleArgumentUnchanged: false,\n      },\n      ['invalidationMethods']\n    );\n    sideEffects?.onError?.(err);\n\n    throw transformedError;\n  }\n}\n\n/**\n * Invalidates or clears previously cached return values based on metaSiteID.\n * Takes the metaSiteID from the context and performs a hard purge.\n * @public\n * @documentationMaturity preview\n * @permissionId SSR.PURGE_SITE_CACHE\n * @fqn com.wixpress.html.cache.invalidate.InvalidateCacheService.PurgeSiteCache\n */\nexport async function purgeSiteCache(): Promise<void> {\n  // @ts-ignore\n  const { httpClient, sideEffects } = arguments[0] as {\n    httpClient: HttpClient;\n    sideEffects?: any;\n  };\n\n  const payload = renameKeysFromSDKRequestToRESTRequest({});\n\n  const reqOpts =\n    ambassadorWixSsrV1InvalidateCacheRequest.purgeSiteCache(payload);\n\n  sideEffects?.onSiteCall?.();\n  try {\n    const result = await httpClient.request(reqOpts);\n    sideEffects?.onSuccess?.(result);\n  } catch (err: any) {\n    const transformedError = sdkTransformError(\n      err,\n      {\n        spreadPathsToArguments: {},\n        explicitPathsToArguments: {},\n        singleArgumentUnchanged: false,\n      },\n      []\n    );\n    sideEffects?.onError?.(err);\n\n    throw transformedError;\n  }\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveComWixpressHtmlCacheInvalidateInvalidateCacheServiceUrl(\n  opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n  const domainToMappings = {\n    'api._api_base_domain_': [\n      {\n        srcPath: '/wix-public-html-cache-invalidate-webapp',\n        destPath: '',\n      },\n    ],\n    'manage._base_domain_': [\n      {\n        srcPath:\n          '/_api/wix-public-html-cache-invalidate-webapp/v1/purge-site-cache',\n        destPath: '/v1/purge-site-cache',\n      },\n      {\n        srcPath:\n          '/_api/wix-public-html-cache-invalidate-webapp/invalidate-cache',\n        destPath: '/v1/invalidate-cache',\n      },\n    ],\n    'www.wixapis.com': [\n      {\n        srcPath: '/ssr/v1/invalidate-cache',\n        destPath: '/v1/invalidate-cache',\n      },\n    ],\n    '*.dev.wix-code.com': [\n      {\n        srcPath: '/ssr/v1/invalidate-cache',\n        destPath: '/v1/invalidate-cache',\n      },\n    ],\n  };\n\n  return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_cache_cache';\n\n/**\n * <blockquote class=\"important\">\n *\n * __Important:__\n * This API is only supported for developing sites and works only when used together with the Web Methods or Router APIs.\n *\n * </blockquote>\n *\n * Invalidates or clears previously cached return values based on specified tags.\n *\n * The `invalidationMethods` parameter accepts an array of objects, each containing a `tag` field. These tags are defined when caching return values of site [web methods](https://dev.wix.com/docs/sdk/core-modules/web-methods/introduction) and [routers](https://dev.wix.com/docs/velo/events-service-plugins/routers/service-plugins/wix-router/introduction#events-service-plugins_routers_service-plugins_wix-router_router-caching).\n *\n * For example, an array such as `[{ tag: \"contacts\" }, { tag: \"labels\" }]` will clear any cached return values tagged with \"contacts\" or \"labels.\"\n *\n * Any cache containing at least one tag specified in the `invalidationMethods` parameter will be cleared.\n *\n * >**Notes:**\n * >- If you don't specify any tags in the `invalidationMethods` parameter, no caches are invalidated.\n * >- If you don't call Invalidate Cache, caches are only invalidated when the Time to Live (TTL) expires or when the site is republished with a code change.\n * >- This method does not invalidate the Server Side Rendering (SSR) cache for your site. To invalidate that cache, use the Invalidate Cache method from the [`wix-site-backend`](https://dev.wix.com/docs/velo/api-reference/wix-site-backend/invalidate-cache) module.\n */\nexport function invalidateCache(payload: object): RequestOptionsFactory<any> {\n  function __invalidateCache({ host }: any) {\n    const metadata = {\n      entityFqdn: 'wix.ssr.v1.invalidate_cache_request',\n      method: 'POST' as any,\n      methodFqn:\n        'com.wixpress.html.cache.invalidate.InvalidateCacheService.invalidateCache',\n      packageName: PACKAGE_NAME,\n      migrationOptions: {\n        optInTransformResponse: true,\n      },\n      url: resolveComWixpressHtmlCacheInvalidateInvalidateCacheServiceUrl({\n        protoPath: '/v1/invalidate-cache',\n        data: payload,\n        host,\n      }),\n      data: payload,\n    };\n\n    return metadata;\n  }\n\n  return __invalidateCache;\n}\n\n/**\n * Invalidates or clears previously cached return values based on metaSiteID.\n * Takes the metaSiteID from the context and performs a hard purge.\n */\nexport function purgeSiteCache(payload: object): RequestOptionsFactory<any> {\n  function __purgeSiteCache({ host }: any) {\n    const metadata = {\n      entityFqdn: 'wix.ssr.v1.invalidate_cache_request',\n      method: 'POST' as any,\n      methodFqn:\n        'com.wixpress.html.cache.invalidate.InvalidateCacheService.PurgeSiteCache',\n      packageName: PACKAGE_NAME,\n      migrationOptions: {\n        optInTransformResponse: true,\n      },\n      url: resolveComWixpressHtmlCacheInvalidateInvalidateCacheServiceUrl({\n        protoPath: '/v1/purge-site-cache',\n        data: payload,\n        host,\n      }),\n      data: payload,\n    };\n\n    return metadata;\n  }\n\n  return __purgeSiteCache;\n}\n","import { HttpClient } from '@wix/sdk-types';\nimport {\n  InvalidationMethods,\n  invalidateCache as universalInvalidateCache,\n  purgeSiteCache as universalPurgeSiteCache,\n} from './ssr-v1-invalidate-cache-request-cache.universal.js';\n\nexport const __metadata = { PACKAGE_NAME: '@wix/cache' };\n\nexport function invalidateCache(\n  httpClient: HttpClient\n): InvalidateCacheSignature {\n  return (invalidationMethods: InvalidationMethods[]) =>\n    universalInvalidateCache(\n      invalidationMethods,\n      // @ts-ignore\n      { httpClient }\n    );\n}\n\ninterface InvalidateCacheSignature {\n  /**\n   * <blockquote class=\"important\">\n   *\n   * __Important:__\n   * This API is only supported for developing sites and works only when used together with the Web Methods or Router APIs.\n   *\n   * </blockquote>\n   *\n   * Invalidates or clears previously cached return values based on specified tags.\n   *\n   * The `invalidationMethods` parameter accepts an array of objects, each containing a `tag` field. These tags are defined when caching return values of site [web methods](https://dev.wix.com/docs/sdk/core-modules/web-methods/introduction) and [routers](https://dev.wix.com/docs/velo/events-service-plugins/routers/service-plugins/wix-router/introduction#events-service-plugins_routers_service-plugins_wix-router_router-caching).\n   *\n   * For example, an array such as `[{ tag: \"contacts\" }, { tag: \"labels\" }]` will clear any cached return values tagged with \"contacts\" or \"labels.\"\n   *\n   * Any cache containing at least one tag specified in the `invalidationMethods` parameter will be cleared.\n   *\n   * >**Notes:**\n   * >- If you don't specify any tags in the `invalidationMethods` parameter, no caches are invalidated.\n   * >- If you don't call Invalidate Cache, caches are only invalidated when the Time to Live (TTL) expires or when the site is republished with a code change.\n   * >- This method does not invalidate the Server Side Rendering (SSR) cache for your site. To invalidate that cache, use the Invalidate Cache method from the [`wix-site-backend`](https://dev.wix.com/docs/velo/api-reference/wix-site-backend/invalidate-cache) module.\n   * @param - An array of objects containing a `tag` field used to identify the cache to invalidate. All cached return values with any listed tags are invalidated. If no tags are specified, nothing is invalidated.\n   */\n  (invalidationMethods: InvalidationMethods[]): Promise<void>;\n}\n\nexport function purgeSiteCache(\n  httpClient: HttpClient\n): PurgeSiteCacheSignature {\n  return () =>\n    universalPurgeSiteCache(\n      // @ts-ignore\n      { httpClient }\n    );\n}\n\ninterface PurgeSiteCacheSignature {\n  /**\n   * Invalidates or clears previously cached return values based on metaSiteID.\n   * Takes the metaSiteID from the context and performs a hard purge.\n   */\n  (): Promise<void>;\n}\n\nexport {\n  InvalidateCacheRequest,\n  InvalidateCacheResponse,\n  InvalidationMethods,\n  InvalidationMethodsInvalidateByOneOf,\n  PurgeSiteCacheRequest,\n  PurgeSiteCacheResponse,\n} from './ssr-v1-invalidate-cache-request-cache.universal.js';\n","import {\n  invalidateCache as publicInvalidateCache,\n  purgeSiteCache as publicPurgeSiteCache,\n} from './ssr-v1-invalidate-cache-request-cache.public.js';\nimport { createRESTModule } from '@wix/sdk-runtime/rest-modules';\nimport { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';\n\nexport const invalidateCache: MaybeContext<\n  BuildRESTFunction<typeof publicInvalidateCache> & typeof publicInvalidateCache\n> = /*#__PURE__*/ createRESTModule(publicInvalidateCache);\nexport const purgeSiteCache: MaybeContext<\n  BuildRESTFunction<typeof publicPurgeSiteCache> & typeof publicPurgeSiteCache\n> = /*#__PURE__*/ createRESTModule(publicPurgeSiteCache);\n\nexport {\n  InvalidateCacheRequest,\n  InvalidationMethods,\n  InvalidationMethodsInvalidateByOneOf,\n  InvalidateCacheResponse,\n  PurgeSiteCacheRequest,\n  PurgeSiteCacheResponse,\n} from './ssr-v1-invalidate-cache-request-cache.universal.js';\n"],"mappings":";A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4BO,SAASC,gBACd,YACyB;AACzB,SAAO,MACLA;AAAA;AAAA,IAEE,EAAE,WAAW;AAAA,EACf;AACJ;;;AClDA,SAAS,wBAAwB;AAG1B,IAAMC,mBAEK,iCAAiBA,gBAAqB;AACjD,IAAMC,kBAEK,iCAAiBA,eAAoB;","names":["invalidateCache","purgeSiteCache","invalidateCache","purgeSiteCache","invalidateCache","purgeSiteCache"]}