@localazy/cdn-client 1.4.1 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,24 +9,61 @@
9
9
  [**Live Demo**](https://localazy.github.io/cdn-client/sandbox/live-demo.html)  | 
10
10
  [**API Reference**](https://localazy.github.io/cdn-client/reference/client-api.html)
11
11
 
12
- [//]: # ([**Live Demo**]())
13
-
14
12
  Node.js module that allows you to easily interact with the [Localazy CDN](https://localazy.com/docs/cdn/cdn-introduction).
15
13
 
16
- [![coverage](.github/badges/version.svg)](https://www.npmjs.com/package/@localazy/cdn-client)
17
- [![coverage](.github/badges/license.svg)](https://github.com/localazy/cdn-client/blob/main/LICENSE)
14
+ [![npm](.github/badges/npm.svg)](https://www.npmjs.com/package/@localazy/cdn-client)
15
+ [![maintainer](.github/badges/maintainer.svg)](https://github.com/localazy)
16
+ [![license](.github/badges/license.svg)](https://github.com/localazy/cdn-client/blob/main/LICENSE)<br>
18
17
  [![coverage](.github/badges/coverage.svg)](https://github.com/localazy/cdn-client/actions)
18
+ [![size](.github/badges/size.svg)](https://bundlephobia.com/package/@localazy/cdn-client)
19
19
 
20
20
  </div>
21
21
 
22
- ## 🔧 Install
22
+ ## 🚀 Quick Start
23
23
 
24
24
  ```bash
25
25
  npm install @localazy/cdn-client
26
- # or use your favorite package manager
26
+ # or use your favourite package manager
27
+ ```
28
+
29
+ ```javascript
30
+ import { CdnClient } from '@localazy/cdn-client';
31
+
32
+ const cdn = await CdnClient.create({
33
+ // use your own metafile
34
+ metafile: 'https://delivery.localazy.com/_a855374211039568660198b39c31/_e0.v2.json',
35
+ });
36
+
37
+ const result = await cdn.fetch({
38
+ // select files from metafile
39
+ files: cdn.metafile.files[0],
40
+ // select locales
41
+ locales: ['en', 'de'],
42
+ });
43
+ ```
44
+
45
+ <details><summary><i><samp>example result</samp></i></summary>
46
+
47
+ ```javascript
48
+ const result = {
49
+ en: {
50
+ cdn_info: 'With the CDN you can deliver the translation files instantly',
51
+ cdn_testing: "We're testing the CDN",
52
+ hello_localazy: 'Hello Localazy!',
53
+ using_javascript: 'In this project we decided to use JavaScript',
54
+ },
55
+ de: {
56
+ cdn_info: 'Mit dem CDN können Sie die Übersetzungsdateien sofort liefern',
57
+ cdn_testing: 'Wir testen das CDN',
58
+ hello_localazy: 'Hallo Localazy!',
59
+ using_javascript: 'In diesem Projekt haben wir uns für JavaScript entschieden',
60
+ },
61
+ };
27
62
  ```
28
63
 
29
- For more information, visit the [installation guide](https://localazy.github.io/cdn-client/get-started/install.html).
64
+ </details>
65
+
66
+ For more information, visit [Installation](https://localazy.github.io/cdn-client/get-started/install.html) guide.
30
67
 
31
68
  ## 🛟 Support
32
69
 
@@ -35,17 +72,20 @@ For more information, visit the [installation guide](https://localazy.github.io/
35
72
  - [Discussion forum](https://discuss.localazy.com/)
36
73
  - [team@localazy.com](mailto:team@localazy.com)
37
74
 
38
- ## 💙 Localazy Ecosystem
75
+ ## 💙 Localazy Packages
39
76
 
40
- Check out other npm packages from Localazy:
77
+ Check out all npm packages from Localazy:
41
78
 
42
- - [@localazy/cli](https://www.npmjs.com/package/@localazy/cli)
43
- - [@localazy/api-client](https://www.npmjs.com/package/@localazy/api-client)
44
- - [@localazy/cdn-client](https://www.npmjs.com/package/@localazy/cdn-client)
45
- - [@localazy/languages](https://www.npmjs.com/package/@localazy/languages)
46
- - [@localazy/strapi-plugin](https://www.npmjs.com/package/@localazy/strapi-plugin)
79
+ | Package | Description |
80
+ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------ |
81
+ | [@localazy/cli](https://www.npmjs.com/package/@localazy/cli) | Localazy CLI tool for app and software localization and translation. |
82
+ | [@localazy/api-client](https://www.npmjs.com/package/@localazy/api-client) | Node.js module that allows you to easily interact with the Localazy API. |
83
+ | [@localazy/cdn-client](https://www.npmjs.com/package/@localazy/cdn-client) | Node.js module that allows you to easily interact with the Localazy CDN. |
84
+ | [@localazy/languages](https://www.npmjs.com/package/@localazy/languages) | Available Localazy Languages |
85
+ | [@localazy/strapi-plugin](https://www.npmjs.com/package/@localazy/strapi-plugin) | The official Strapi Plugin by Localazy. |
86
+ | [@localazy/directus-extension-localazy](https://www.npmjs.com/package/@localazy/directus-extension-localazy) | The official Localazy module extension for Directus |
47
87
 
48
- Discover all available [integration options and localization examples](https://github.com/localazy).
88
+ Discover all available [integration options](https://github.com/localazy) and [localization examples](https://github.com/localazy).
49
89
 
50
90
  ## 📜 License
51
91
 
@@ -1,6 +1,6 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("isomorphic-fetch")):"function"==typeof define&&define.amd?define(["exports","isomorphic-fetch"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LocalazyCDN={})}(this,(function(e){"use strict";var t=Object.defineProperty,s=(e,s,i)=>(((e,s,i)=>{s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[s]=i})(e,"symbol"!=typeof s?s+"":s,i),i);
2
- /* @localazy/cdn-client@1.4.1
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LocalazyCDN={})}(this,(function(e){"use strict";var t=Object.defineProperty,s=(e,s,i)=>(((e,s,i)=>{s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[s]=i})(e,"symbol"!=typeof s?s+"":s,i),i);
2
+ /* @localazy/cdn-client@1.5.1
3
3
  * (c) 2024 Localazy <team@localazy.com>
4
4
  * @license MIT */
5
- class i{constructor(e){s(this,"context"),this.context=e}async fetchLocale(e){return this.context.cache.has(e)?new Promise((t=>{t(this.context.cache.get(e))})):this.context.client.get(e.metafileLocale.uri)}async fetchMetafile(){return await this.context.client.get(this.context.metafile.params.jsonPath)}}const a=e=>"string"==typeof e,l=e=>void 0===e,r=e=>Array.isArray(e),o=e=>"[object Object]"===Object.prototype.toString.call(e),n=e=>[...new Set(e)],c=(e,t)=>{const s={};return e.filter((e=>{const i=t(e);return!Object.hasOwn(s,i)&&(s[i]=!0,!0)}))};class h{constructor(){s(this,"map"),this.map=new Map}get(e){return this.map.get(e)}has(e){return this.map.has(e)}set(e,t){this.map.set(e,t)}flush(){this.map=new Map}}class u{constructor(e){s(this,"context"),s(this,"cacheAdapter"),this.context=e,this.cacheAdapter=new h}setIfMissed(e){const{metafileFile:t,metafileLocale:s,data:i}=e,a=this.keyFromMetafile({metafileFile:t,metafileLocale:s});this.cacheAdapter.has(a)||this.cacheAdapter.set(a,i)}has(e){const t=this.keyFromMetafile(e);return this.cacheAdapter.has(t)}get(e){const t=this.keyFromMetafile(e);return this.cacheAdapter.get(t)}flush(){this.cacheAdapter.flush()}keyFromMetafile(e){const{metafileFile:t,metafileLocale:s}=e,i=[...n(t.productFlavors)].sort().join("-");return[this.context.metafile.params.cdnId,t.id,t.file,t.path,t.library,t.module,t.buildType,i,s.locale,s.timestamp.toString()].filter((e=>""!==e)).join("-")}}class p{constructor(e){s(this,"context"),this.context=e}}class f extends p{constructor(){super(...arguments),s(this,"flush",(()=>{this.context.cache.flush()}))}}class d{constructor(e,t){s(this,"language"),s(this,"region"),s(this,"script"),s(this,"isRtl"),s(this,"name"),s(this,"localizedName"),s(this,"uri"),s(this,"timestamp"),s(this,"baseLocale"),this.language=e.language,this.region=e.region,this.script=e.script,this.isRtl=e.isRtl,this.name=e.name,this.localizedName=e.localizedName,this.uri=e.uri,this.timestamp=e.timestamp,this.baseLocale=t}get locale(){return this.language&&this.region&&this.script?`${this.language}_${this.region}#${this.script}`:this.language&&this.script?`${this.language}#${this.script}`:this.language&&this.region?`${this.language}_${this.region}`:this.language}get isBaseLocale(){return this.locale===this.baseLocale}toCdnLocale(){return{locale:this.locale,isBaseLocale:this.isBaseLocale,language:this.language,region:this.region,script:this.script,isRtl:this.isRtl,name:this.name,localizedName:this.localizedName}}}class m{constructor(e){s(this,"id"),s(this,"file"),s(this,"path"),s(this,"library"),s(this,"module"),s(this,"buildType"),s(this,"timestamp"),s(this,"productFlavors"),s(this,"locales"),s(this,"baseUrl"),this.id=e.id,this.file=e.file,this.path=e.path,this.library=e.library,this.module=e.module,this.buildType=e.buildType,this.timestamp=e.timestamp,this.productFlavors=e.productFlavors,this.locales=e.locales,this.baseUrl=e.baseUrl}toCdnFile(){return{id:this.id,file:this.file,path:this.path,library:this.library,module:this.module,buildType:this.buildType,productFlavors:this.productFlavors,locales:this.locales.map((e=>({locale:e.locale,isBaseLocale:e.isBaseLocale,uri:`${this.baseUrl}${e.uri}`})))}}}class g{constructor(e,t){s(this,"projectUrl"),s(this,"baseLocale"),s(this,"locales"),s(this,"timestamp"),s(this,"files"),s(this,"filesMap"),this.projectUrl=e.projectUrl,this.timestamp=e.timestamp,this.files=g.filesFactory(e.files,e.baseLocale,t),this.filesMap=g.filesMapFactory(this.files),this.locales=g.localesFactory(this.files),this.baseLocale=this.locales.find((e=>e.isBaseLocale))}static createEmpty(e){return new g({projectUrl:"",baseLocale:"",timestamp:0,files:{}},e)}static filesFactory(e,t,s){return Object.keys(e).reduce(((i,a)=>{const l=e[a].locales.map((e=>new d(e,t)));return i.push(new m({...e[a],id:a,locales:l,baseUrl:s.baseUrl})),i}),[])}static filesMapFactory(e){return e.reduce(((e,t)=>(e[t.id]=t,e)),{})}static localesFactory(e){const t=e.reduce(((e,t)=>(e.push(...t.locales.map((e=>e.toCdnLocale()))),e)),[]);return c(t,(e=>e.locale))}}class w{constructor(e){s(this,"options"),this.options=w.parseMetafileUrl(e)}get url(){return this.options.url}get baseUrl(){return this.options.baseUrl}get cdnId(){return this.options.cdnId}get jsonPath(){return this.options.jsonPath}static parseMetafileUrl(e){let t;try{t=new URL(e)}catch(e){throw new Error('Invalid param: "options.metafile" cannot be parsed as url.')}const s=t.pathname.match(/^\/(.*?)\/(.*?)\.(v2.json|js|ts)$/);if(null===s||4!==s.length)throw new Error('Invalid param: "options.metafile" contains invalid metafile url.');const i=s[1],a=s[2];return{url:e,baseUrl:t.origin,cdnId:i,jsonPath:`/${i}/${a}.v2.json`}}}class y{constructor(e){s(this,"params"),s(this,"parsedData"),s(this,"data"),this.params=new w(e.metafile),this.parsedData=null,this.data=g.createEmpty(this.params)}setMetafile(e){this.parsedData=e,this.data=new g(e,this.params)}}class x{constructor(e){s(this,"context"),this.context=e}createCdnResponse(e){const{requests:t,responses:s,hasSingleFileResponse:i,hasSingleLocaleResponse:a}=e;return 0===s.length?{}:(this.cacheResponses(t,s),i&&a?s[0]:x.transformResponses(e))}cacheResponses(e,t){t.forEach(((t,s)=>{const{metafileFile:i,metafileLocale:a}=e[s];i&&a&&this.context.cache.setIfMissed({metafileFile:i,metafileLocale:a,data:t})}))}static transformResponses(e){const{requests:t,responses:s,hasSingleFileResponse:i}=e;return s.reduce(((e,s,a)=>{const{metafileFile:l,metafileLocale:r}=t[a];return l&&r&&(i?e[r.locale]=s:(e[l.id]||(e[l.id]={}),e[l.id][r.locale]=s)),e}),{})}}class b{constructor(e){s(this,"metafile"),s(this,"cdn"),s(this,"client"),s(this,"api"),s(this,"cache"),s(this,"responseFactory"),this.metafile=e.metafileContext,this.cdn=e.cdn,this.client=e.client,this.api=new i(this),this.cache=new u(this),this.responseFactory=new x(this)}}class F extends p{constructor(){super(...arguments),s(this,"locales",(e=>{const{excludeBaseLocale:t}=e||{},{locales:s}=this.context.metafile.data;return t?s.filter((e=>!e.isBaseLocale)):s})),s(this,"refresh",(async()=>{const e=await this.context.api.fetchMetafile();this.context.metafile.setMetafile(e)})),s(this,"switch",(async e=>{this.context.metafile.params=new w(e.metafile),await this.refresh()}))}get projectUrl(){return this.context.metafile.data.projectUrl}get baseLocale(){return this.context.metafile.data.baseLocale}get url(){return this.context.metafile.params.url}get files(){return this.context.metafile.data.files.map((e=>e.toCdnFile()))}}class L{constructor(e){s(this,"data"),s(this,"context"),this.context=e.context,this.data=e.data||{}}}class M{constructor(e){s(this,"files"),s(this,"localesMap"),s(this,"hasSingleFileResponse"),s(this,"hasSingleLocaleResponse"),s(this,"context"),this.files=[],this.localesMap=new L({context:e}),this.hasSingleFileResponse=!1,this.hasSingleLocaleResponse=!1,this.context=e}async execute(){const e=this.getPromises(),t=e.map((e=>e[0])),s=e.map((e=>e[1])),i=await Promise.all(t);return this.context.responseFactory.createCdnResponse({requests:s,responses:i,localesMap:this.localesMap,hasSingleFileResponse:this.hasSingleFileResponse,hasSingleLocaleResponse:this.hasSingleLocaleResponse})}getPromises(){return this.files.reduce(((e,t)=>(this.localesMap.data[t.id]&&e.push(...this.localesMap.data[t.id].map((e=>{const s={metafileFile:t,metafileLocale:e};return[this.context.api.fetchLocale(s),s]}))),e)),[])}}class q{constructor(e){s(this,"context"),s(this,"request"),this.context=e,this.request=new M(this.context)}addFiles(e){if(!(o(e)||a(e)||l(e)||r(e)))throw new Error('Invalid param: "request.files" must be object, array, string or undefined.');if(r(e)&&e.forEach((e=>{if(!o(e)&&!a(e))throw new Error('Invalid param: array "request.files" must contain objects or strings.')})),a(e)){this.request.hasSingleFileResponse=!0;const t=this.context.metafile.data.files.find((t=>t.id===e));if(!(t instanceof m))throw new Error(`File not found: "${e}".`);this.request.files=[t]}else if(l(e))this.request.files=[...this.context.metafile.data.files];else if(r(e))this.request.files=e.map((e=>{let t;if(a(e)){const s=this.context.metafile.data.files.find((t=>t.id===e));if(l(s))throw new Error(`File not found: "${e}".`);t=s}else{const s=this.context.metafile.data.files.find((t=>t.id===e.id));if(l(s))throw new Error(`File not found: "${e.id}".`);t=s}return t}));else if(o(e)){this.request.hasSingleFileResponse=!0;const t=this.context.metafile.data.files.find((t=>t.id===e.id));if(l(t))throw new Error(`File not found: "${e.id}".`);this.request.files=[t]}return this}addLocales(e,t){if(!(a(e)||l(e)||r(e)))throw new Error('Invalid param: "request.locales" must be array, string or undefined.');return r(e)&&e.forEach((e=>{if(!a(e))throw new Error('Invalid param: array "request.locales" must contain strings.')})),a(e)?(this.request.hasSingleLocaleResponse=!0,this.request.files.reduce(((t,s)=>(t.data[s.id]=s.locales.filter((t=>t.locale===e)),t)),this.request.localesMap)):l(e)?this.request.files.reduce(((e,s)=>(e.data[s.id]=t?s.locales.filter((e=>!e.isBaseLocale)):s.locales,e)),this.request.localesMap):r(e)&&this.request.files.reduce(((t,s)=>(t.data[s.id]=s.locales.filter((t=>e.includes(t.locale))),t)),this.request.localesMap),this}getCdnRequest(){const e=this.request;return this.request=new M(this.context),e}}class R{constructor(e){s(this,"baseUrl"),this.baseUrl=e}async get(e){const t=await fetch(`${this.baseUrl}${e}`),s=t.headers.get("content-type")||"",i=["application/json5","application/json"].includes(s);if(t.status>=400)throw new Error(`Request failed with status code ${t.status}`);let a="";if(i)try{a=await t.json()}catch(e){a={}}else try{a=await t.text()}catch(e){a=""}return a}}class j{constructor(e){s(this,"metafile"),s(this,"cache"),s(this,"context"),s(this,"fetch",(async e=>{const{files:t,locales:s,excludeBaseLocale:i}=e||{};return new q(this.context).addFiles(t).addLocales(s,i).getCdnRequest().execute()}));const t=new y(e),i=new R(t.params.baseUrl);this.context=new b({metafileContext:t,cdn:this,client:i}),this.metafile=new F(this.context),this.cache=new f(this.context)}static async create(e){if(!e)throw new Error('Invalid param: missing required "options" parameter.');if(!a(e.metafile))throw new Error('Invalid param: "options.metafile" must be string.');const t=new j(e);return await t.metafile.refresh(),t}}e.Api=i,e.CdnBase=p,e.CdnCache=f,e.CdnClient=j,e.CdnMetafile=F,e.Context=b,e.FetchHttpAdapter=R,e.LocalesCache=u,e.LocalesMap=L,e.MemoryCacheAdapter=h,e.MetafileContext=y,e.MetafileData=g,e.MetafileFile=m,e.MetafileLocale=d,e.MetafileParams=w,e.Request=M,e.RequestBuilder=q,e.ResponseFactory=x,e.isArray=r,e.isPlainObject=o,e.isString=a,e.isUndefined=l,e.uniq=n,e.uniqBy=c,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
5
+ class i{constructor(e){s(this,"context"),this.context=e}async fetchLocale(e){return this.context.cache.has(e)?new Promise((t=>{t(this.context.cache.get(e))})):this.context.client.get(e.metafileLocale.uri)}async fetchMetafile(){return await this.context.client.get(this.context.metafile.params.jsonPath)}}const a=e=>"string"==typeof e,l=e=>void 0===e,r=e=>Array.isArray(e),o=e=>"[object Object]"===Object.prototype.toString.call(e),n=e=>[...new Set(e)],c=(e,t)=>{const s={};return e.filter((e=>{const i=t(e);return!Object.hasOwn(s,i)&&(s[i]=!0,!0)}))};class h{constructor(){s(this,"map"),this.map=new Map}get(e){return this.map.get(e)}has(e){return this.map.has(e)}set(e,t){this.map.set(e,t)}flush(){this.map=new Map}}class u{constructor(e){s(this,"context"),s(this,"cacheAdapter"),this.context=e,this.cacheAdapter=new h}setIfMissed(e){const{metafileFile:t,metafileLocale:s,data:i}=e,a=this.keyFromMetafile({metafileFile:t,metafileLocale:s});this.cacheAdapter.has(a)||this.cacheAdapter.set(a,i)}has(e){const t=this.keyFromMetafile(e);return this.cacheAdapter.has(t)}get(e){const t=this.keyFromMetafile(e);return this.cacheAdapter.get(t)}flush(){this.cacheAdapter.flush()}keyFromMetafile(e){const{metafileFile:t,metafileLocale:s}=e,i=[...n(t.productFlavors)].sort().join("-");return[this.context.metafile.params.cdnId,t.id,t.file,t.path,t.library,t.module,t.buildType,i,s.locale,s.timestamp.toString()].filter((e=>""!==e)).join("-")}}class p{constructor(e){s(this,"context"),this.context=e}}class f extends p{constructor(){super(...arguments),s(this,"flush",(()=>{this.context.cache.flush()}))}}class d{constructor(e,t){s(this,"language"),s(this,"region"),s(this,"script"),s(this,"isRtl"),s(this,"name"),s(this,"localizedName"),s(this,"uri"),s(this,"timestamp"),s(this,"baseLocale"),this.language=e.language,this.region=e.region,this.script=e.script,this.isRtl=e.isRtl,this.name=e.name,this.localizedName=e.localizedName,this.uri=e.uri,this.timestamp=e.timestamp,this.baseLocale=t}get locale(){return this.language&&this.region&&this.script?`${this.language}_${this.region}#${this.script}`:this.language&&this.script?`${this.language}#${this.script}`:this.language&&this.region?`${this.language}_${this.region}`:this.language}get isBaseLocale(){return this.locale===this.baseLocale}toCdnLocale(){return{locale:this.locale,isBaseLocale:this.isBaseLocale,language:this.language,region:this.region,script:this.script,isRtl:this.isRtl,name:this.name,localizedName:this.localizedName}}}class m{constructor(e){s(this,"id"),s(this,"file"),s(this,"path"),s(this,"library"),s(this,"module"),s(this,"buildType"),s(this,"timestamp"),s(this,"productFlavors"),s(this,"locales"),s(this,"baseUrl"),this.id=e.id,this.file=e.file,this.path=e.path,this.library=e.library,this.module=e.module,this.buildType=e.buildType,this.timestamp=e.timestamp,this.productFlavors=e.productFlavors,this.locales=e.locales,this.baseUrl=e.baseUrl}toCdnFile(){return{id:this.id,file:this.file,path:this.path,library:this.library,module:this.module,buildType:this.buildType,productFlavors:this.productFlavors,locales:this.locales.map((e=>({locale:e.locale,isBaseLocale:e.isBaseLocale,uri:`${this.baseUrl}${e.uri}`})))}}}class g{constructor(e,t){s(this,"projectUrl"),s(this,"baseLocale"),s(this,"locales"),s(this,"timestamp"),s(this,"files"),s(this,"filesMap"),this.projectUrl=e.projectUrl,this.timestamp=e.timestamp,this.files=g.filesFactory(e.files,e.baseLocale,t),this.filesMap=g.filesMapFactory(this.files),this.locales=g.localesFactory(this.files),this.baseLocale=this.locales.find((e=>e.isBaseLocale))}static createEmpty(e){return new g({projectUrl:"",baseLocale:"",timestamp:0,files:{}},e)}static filesFactory(e,t,s){return Object.keys(e).reduce(((i,a)=>{const l=e[a].locales.map((e=>new d(e,t)));return i.push(new m({...e[a],id:a,locales:l,baseUrl:s.baseUrl})),i}),[])}static filesMapFactory(e){return e.reduce(((e,t)=>(e[t.id]=t,e)),{})}static localesFactory(e){const t=e.reduce(((e,t)=>(e.push(...t.locales.map((e=>e.toCdnLocale()))),e)),[]);return c(t,(e=>e.locale))}}class w{constructor(e){s(this,"options"),this.options=w.parseMetafileUrl(e)}get url(){return this.options.url}get baseUrl(){return this.options.baseUrl}get cdnId(){return this.options.cdnId}get jsonPath(){return this.options.jsonPath}static parseMetafileUrl(e){let t;try{t=new URL(e)}catch(e){throw new Error('Invalid param: "options.metafile" cannot be parsed as url.')}const s=t.pathname.match(/^\/(.*?)\/(.*?)\.(v2.json|js|ts)$/);if(null===s||4!==s.length)throw new Error('Invalid param: "options.metafile" contains invalid metafile url.');const i=s[1],a=s[2];return{url:e,baseUrl:t.origin,cdnId:i,jsonPath:`/${i}/${a}.v2.json`}}}class x{constructor(e){s(this,"params"),s(this,"parsedData"),s(this,"data"),this.params=new w(e.metafile),this.parsedData=null,this.data=g.createEmpty(this.params)}setMetafile(e){this.parsedData=e,this.data=new g(e,this.params)}}class y{constructor(e){s(this,"context"),this.context=e}createCdnResponse(e){const{requests:t,responses:s,hasSingleFileResponse:i,hasSingleLocaleResponse:a}=e;return 0===s.length?{}:(this.cacheResponses(t,s),i&&a?s[0]:y.transformResponses(e))}cacheResponses(e,t){t.forEach(((t,s)=>{const{metafileFile:i,metafileLocale:a}=e[s];i&&a&&this.context.cache.setIfMissed({metafileFile:i,metafileLocale:a,data:t})}))}static transformResponses(e){const{requests:t,responses:s,hasSingleFileResponse:i}=e;return s.reduce(((e,s,a)=>{const{metafileFile:l,metafileLocale:r}=t[a];return l&&r&&(i?e[r.locale]=s:(e[l.id]||(e[l.id]={}),e[l.id][r.locale]=s)),e}),{})}}class b{constructor(e){s(this,"metafile"),s(this,"cdn"),s(this,"client"),s(this,"api"),s(this,"cache"),s(this,"responseFactory"),this.metafile=e.metafileContext,this.cdn=e.cdn,this.client=e.client,this.api=new i(this),this.cache=new u(this),this.responseFactory=new y(this)}}class F extends p{constructor(){super(...arguments),s(this,"locales",(e=>{const{excludeBaseLocale:t}=e||{},{locales:s}=this.context.metafile.data;return t?s.filter((e=>!e.isBaseLocale)):s})),s(this,"refresh",(async()=>{const e=await this.context.api.fetchMetafile();this.context.metafile.setMetafile(e)})),s(this,"switch",(async e=>{this.context.metafile.params=new w(e.metafile),await this.refresh()}))}get projectUrl(){return this.context.metafile.data.projectUrl}get baseLocale(){return this.context.metafile.data.baseLocale}get url(){return this.context.metafile.params.url}get files(){return this.context.metafile.data.files.map((e=>e.toCdnFile()))}}class L{constructor(e){s(this,"data"),s(this,"context"),this.context=e.context,this.data=e.data||{}}}class M{constructor(e){s(this,"files"),s(this,"localesMap"),s(this,"hasSingleFileResponse"),s(this,"hasSingleLocaleResponse"),s(this,"context"),this.files=[],this.localesMap=new L({context:e}),this.hasSingleFileResponse=!1,this.hasSingleLocaleResponse=!1,this.context=e}async execute(){const e=this.getPromises(),t=e.map((e=>e[0])),s=e.map((e=>e[1])),i=await Promise.all(t);return this.context.responseFactory.createCdnResponse({requests:s,responses:i,localesMap:this.localesMap,hasSingleFileResponse:this.hasSingleFileResponse,hasSingleLocaleResponse:this.hasSingleLocaleResponse})}getPromises(){return this.files.reduce(((e,t)=>(this.localesMap.data[t.id]&&e.push(...this.localesMap.data[t.id].map((e=>{const s={metafileFile:t,metafileLocale:e};return[this.context.api.fetchLocale(s),s]}))),e)),[])}}class q{constructor(e){s(this,"context"),s(this,"request"),this.context=e,this.request=new M(this.context)}addFiles(e){if(!(o(e)||a(e)||l(e)||r(e)))throw new Error('Invalid param: "request.files" must be object, array, string or undefined.');if(r(e)&&e.forEach((e=>{if(!o(e)&&!a(e))throw new Error('Invalid param: array "request.files" must contain objects or strings.')})),a(e)){this.request.hasSingleFileResponse=!0;const t=this.context.metafile.data.files.find((t=>t.id===e));if(!(t instanceof m))throw new Error(`File not found: "${e}".`);this.request.files=[t]}else if(l(e))this.request.files=[...this.context.metafile.data.files];else if(r(e))this.request.files=e.map((e=>{let t;if(a(e)){const s=this.context.metafile.data.files.find((t=>t.id===e));if(l(s))throw new Error(`File not found: "${e}".`);t=s}else{const s=this.context.metafile.data.files.find((t=>t.id===e.id));if(l(s))throw new Error(`File not found: "${e.id}".`);t=s}return t}));else if(o(e)){this.request.hasSingleFileResponse=!0;const t=this.context.metafile.data.files.find((t=>t.id===e.id));if(l(t))throw new Error(`File not found: "${e.id}".`);this.request.files=[t]}return this}addLocales(e,t){if(!(a(e)||l(e)||r(e)))throw new Error('Invalid param: "request.locales" must be array, string or undefined.');return r(e)&&e.forEach((e=>{if(!a(e))throw new Error('Invalid param: array "request.locales" must contain strings.')})),a(e)?(this.request.hasSingleLocaleResponse=!0,this.request.files.reduce(((t,s)=>(t.data[s.id]=s.locales.filter((t=>t.locale===e)),t)),this.request.localesMap)):l(e)?this.request.files.reduce(((e,s)=>(e.data[s.id]=t?s.locales.filter((e=>!e.isBaseLocale)):s.locales,e)),this.request.localesMap):r(e)&&this.request.files.reduce(((t,s)=>(t.data[s.id]=s.locales.filter((t=>e.includes(t.locale))),t)),this.request.localesMap),this}getCdnRequest(){const e=this.request;return this.request=new M(this.context),e}}class R{constructor(e){s(this,"baseUrl"),this.baseUrl=e}async get(e){const t=await fetch(`${this.baseUrl}${e}`),s=t.headers.get("content-type"),i="application/json5"===s||"application/json"===s;if(t.status>=400)throw new Error(`Request failed with status code ${t.status}`);let a;return a=i?await t.json():await t.text(),a}}const j=class e{constructor(e){s(this,"metafile"),s(this,"cache"),s(this,"context"),s(this,"fetch",(async e=>{const{files:t,locales:s,excludeBaseLocale:i}=e||{};return new q(this.context).addFiles(t).addLocales(s,i).getCdnRequest().execute()}));const t=new x(e),i=new R(t.params.baseUrl);this.context=new b({metafileContext:t,cdn:this,client:i}),this.metafile=new F(this.context),this.cache=new f(this.context)}static async create(t){if(!t)throw new Error('Invalid param: missing required "options" parameter.');if(!a(t.metafile))throw new Error('Invalid param: "options.metafile" must be string.');const s=new e(t);return await s.metafile.refresh(),s}};s(j,"version","1.5.1");let U=j;e.Api=i,e.CdnBase=p,e.CdnCache=f,e.CdnClient=U,e.CdnMetafile=F,e.Context=b,e.FetchHttpAdapter=R,e.LocalesCache=u,e.LocalesMap=L,e.MemoryCacheAdapter=h,e.MetafileContext=x,e.MetafileData=g,e.MetafileFile=m,e.MetafileLocale=d,e.MetafileParams=w,e.Request=M,e.RequestBuilder=q,e.ResponseFactory=y,e.isArray=r,e.isPlainObject=o,e.isString=a,e.isUndefined=l,e.uniq=n,e.uniqBy=c,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
6
6
  //# sourceMappingURL=localazy-cdn-client.umd.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"localazy-cdn-client.umd.min.js","sources":["../../src/cdn/api/api.ts","../../src/cdn/utils.ts","../../src/cdn/cache/memory-cache-adapter.ts","../../src/cdn/cache/locales-cache.ts","../../src/cdn/methods/cdn-base.ts","../../src/cdn/methods/cdn-cache.ts","../../src/cdn/metafile/metafile-locale.ts","../../src/cdn/metafile/metafile-file.ts","../../src/cdn/metafile/metafile-data.ts","../../src/cdn/metafile/metafile-params.ts","../../src/cdn/context/metafile-context.ts","../../src/cdn/response/response-factory.ts","../../src/cdn/context/context.ts","../../src/cdn/methods/cdn-metafile.ts","../../src/cdn/request/locales-map.ts","../../src/cdn/request/request.ts","../../src/cdn/request/request-builder.ts","../../src/cdn/http/fetch-http-adapter.ts","../../src/cdn/cdn-client.ts"],"sourcesContent":["import { IMetafile } from '@/interfaces/i-metafile';\nimport { ApiLocaleRequest } from '@/types/api-locale-request';\nimport { Context } from '@/cdn/context/context';\n\nexport type ApiRequestConfig = object & {\n reference: ApiLocaleRequest;\n};\n\nexport class Api {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public async fetchLocale(options: ApiLocaleRequest): Promise<object | string> {\n if (this.context.cache.has(options)) {\n return new Promise((resolve): void => {\n resolve(this.context.cache.get(options) as object | string);\n });\n }\n\n return this.context.client.get(options.metafileLocale.uri);\n }\n\n public async fetchMetafile(): Promise<IMetafile> {\n return await this.context.client.get(this.context.metafile.params.jsonPath) as IMetafile;\n }\n}\n","export const isString = (value: unknown): value is string => typeof value === 'string';\n\nexport const isUndefined = (value: unknown): value is undefined => typeof value === 'undefined';\n\nexport const isArray = <T>(value: unknown): value is T[] => Array.isArray(value);\n\nexport const isPlainObject = (value: unknown): value is Record<string, unknown> => Object\n .prototype.toString.call(value) === '[object Object]';\n\nexport const uniq = <T>(array: T[]): T[] => [...new Set(array)];\n\nexport const uniqBy = <T>(array: T[], predicate: (item: T) => string): T[] => {\n const seen: Record<string, boolean> = {};\n\n return array.filter((item: T): boolean => {\n const key: string = predicate(item);\n\n if (!Object.hasOwn(seen, key)) {\n seen[key] = true;\n\n return true;\n }\n\n return false;\n });\n};\n","import { ICacheAdapter } from '@/interfaces/i-cache-adapter';\n\nexport class MemoryCacheAdapter<K, V> implements ICacheAdapter<K, V> {\n protected map: Map<K, V>;\n\n constructor() {\n this.map = new Map();\n }\n\n public get(key: K): V | undefined {\n return this.map.get(key);\n }\n\n public has(key: K): boolean {\n return this.map.has(key);\n }\n\n public set(key: K, value: V): void {\n this.map.set(key, value);\n }\n\n public flush(): void {\n this.map = new Map();\n }\n}\n","import { uniq } from '@/cdn/utils';\nimport { ICacheAdapter } from '@/interfaces/i-cache-adapter';\nimport { CacheKeyMetafileOptions } from '@/types/cache-key-metafile-options';\nimport { CacheGetLocalesRequest } from '@/types/cache-get-locales-request';\nimport { CacheHasLocalesRequest } from '@/types/cache-has-locales-request';\nimport { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request';\nimport { MemoryCacheAdapter } from '@/cdn/cache/memory-cache-adapter';\nimport { Context } from '@/cdn/context/context';\n\nexport class LocalesCache {\n protected context: Context;\n\n protected cacheAdapter: ICacheAdapter<string, object | string>;\n\n constructor(context: Context) {\n this.context = context;\n this.cacheAdapter = new MemoryCacheAdapter();\n }\n\n public setIfMissed(options: CacheStoreLocalesRequest): void {\n const { metafileFile, metafileLocale, data }: CacheStoreLocalesRequest = options;\n\n const key: string = this.keyFromMetafile({\n metafileFile,\n metafileLocale,\n });\n\n if (!this.cacheAdapter.has(key)) {\n this.cacheAdapter.set(key, data);\n }\n }\n\n public has(options: CacheHasLocalesRequest): boolean {\n const key: string = this.keyFromMetafile(options);\n\n return this.cacheAdapter.has(key);\n }\n\n public get(options: CacheGetLocalesRequest): object | string | undefined {\n const key: string = this.keyFromMetafile(options);\n\n return this.cacheAdapter.get(key);\n }\n\n public flush(): void {\n this.cacheAdapter.flush();\n }\n\n protected keyFromMetafile(options: CacheKeyMetafileOptions): string {\n const { metafileFile, metafileLocale }: CacheKeyMetafileOptions = options;\n const productFlavors: string = [...uniq(metafileFile.productFlavors)].sort().join('-');\n\n const indices: string[] = [\n this.context.metafile.params.cdnId,\n metafileFile.id,\n metafileFile.file,\n metafileFile.path,\n metafileFile.library,\n metafileFile.module,\n metafileFile.buildType,\n productFlavors,\n metafileLocale.locale,\n metafileLocale.timestamp.toString(),\n ];\n\n return indices.filter((key: string): boolean => key !== '').join('-');\n }\n}\n","import { Context } from '@/cdn/context/context';\n\nexport abstract class CdnBase {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n}\n","import { CdnBase } from '@/cdn/methods/cdn-base';\n\nexport class CdnCache extends CdnBase {\n public flush = (): void => {\n this.context.cache.flush();\n };\n}\n","import { CdnLocale } from '@/types/cdn-locale';\nimport { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale';\n\nexport class MetafileLocale implements IMetafileFileLocale {\n public language: string;\n\n public region: string;\n\n public script: string;\n\n public isRtl: boolean;\n\n public name: string;\n\n public localizedName: string;\n\n public uri: string;\n\n public timestamp: number;\n\n protected baseLocale: string;\n\n constructor(options: IMetafileFileLocale, baseLocale: string) {\n this.language = options.language;\n this.region = options.region;\n this.script = options.script;\n this.isRtl = options.isRtl;\n this.name = options.name;\n this.localizedName = options.localizedName;\n this.uri = options.uri;\n this.timestamp = options.timestamp;\n this.baseLocale = baseLocale;\n }\n\n get locale(): string {\n if (this.language && this.region && this.script) {\n return `${this.language}_${this.region}#${this.script}`;\n }\n\n if (this.language && this.script) {\n return `${this.language}#${this.script}`;\n }\n\n if (this.language && this.region) {\n return `${this.language}_${this.region}`;\n }\n\n return this.language;\n }\n\n get isBaseLocale(): boolean {\n return this.locale === this.baseLocale;\n }\n\n public toCdnLocale(): CdnLocale {\n return {\n locale: this.locale,\n isBaseLocale: this.isBaseLocale,\n language: this.language,\n region: this.region,\n script: this.script,\n isRtl: this.isRtl,\n name: this.name,\n localizedName: this.localizedName,\n };\n }\n}\n","import { CdnFile } from '@/types/cdn-file';\nimport { CdnFileLocale } from '@/types/cdn-file-locale';\nimport { MetafileLocale } from '@/cdn/metafile/metafile-locale';\nimport { IMetafileFile } from '@/interfaces/i-metafile-file';\nimport { MetafileFileOptions } from '@/types/metafile-file-options';\n\nexport class MetafileFile implements Omit<IMetafileFile, 'locales'> {\n public id: string;\n\n public file: string;\n\n public path: string;\n\n public library: string;\n\n public module: string;\n\n public buildType: string;\n\n public timestamp: number;\n\n public productFlavors: string[];\n\n public locales: MetafileLocale[];\n\n protected baseUrl: string;\n\n constructor(options: MetafileFileOptions) {\n this.id = options.id;\n this.file = options.file;\n this.path = options.path;\n this.library = options.library;\n this.module = options.module;\n this.buildType = options.buildType;\n this.timestamp = options.timestamp;\n this.productFlavors = options.productFlavors;\n this.locales = options.locales;\n this.baseUrl = options.baseUrl;\n }\n\n public toCdnFile(): CdnFile {\n return {\n id: this.id,\n file: this.file,\n path: this.path,\n library: this.library,\n module: this.module,\n buildType: this.buildType,\n productFlavors: this.productFlavors,\n locales: this.locales.map((locale: MetafileLocale): CdnFileLocale => ({\n locale: locale.locale,\n isBaseLocale: locale.isBaseLocale,\n uri: `${this.baseUrl}${locale.uri}`,\n })),\n };\n }\n}\n","import { uniqBy } from '@/cdn/utils';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params';\nimport { CdnLocale } from '@/types/cdn-locale';\nimport { MetafileLocale } from '@/cdn/metafile/metafile-locale';\nimport { IMetafile } from '@/interfaces/i-metafile';\nimport { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale';\nimport { IMetafileFiles } from '@/interfaces/i-metafile-files';\nimport { MetafileFile } from '@/cdn/metafile/metafile-file';\nimport { MetafileOptions } from '@/types/metafile-options';\nimport { FilesMap } from '@/types/files-map';\n\nexport class MetafileData implements Omit<IMetafile, 'files' | 'baseLocale'> {\n public projectUrl: string;\n\n public baseLocale: CdnLocale;\n\n public locales: CdnLocale[];\n\n public timestamp: number;\n\n public files: MetafileFile[];\n\n public filesMap: FilesMap;\n\n constructor(options: MetafileOptions, params: MetafileParams) {\n this.projectUrl = options.projectUrl;\n this.timestamp = options.timestamp;\n this.files = MetafileData.filesFactory(options.files, options.baseLocale, params);\n this.filesMap = MetafileData.filesMapFactory(this.files);\n this.locales = MetafileData.localesFactory(this.files);\n this.baseLocale = this.locales.find((locale: CdnLocale) => locale.isBaseLocale) as CdnLocale;\n }\n\n public static createEmpty(params: MetafileParams): MetafileData {\n return new MetafileData(\n {\n projectUrl: '',\n baseLocale: '',\n timestamp: 0,\n files: {},\n },\n params,\n );\n }\n\n protected static filesFactory(files: IMetafileFiles, baseLocale: string, params: MetafileParams): MetafileFile[] {\n return Object.keys(files).reduce(\n (acc: MetafileFile[], cur: string) => {\n const locales: MetafileLocale[] = files[cur].locales.map(\n (locale: IMetafileFileLocale) => new MetafileLocale(locale, baseLocale),\n );\n\n acc.push(\n new MetafileFile({\n ...files[cur],\n id: cur,\n locales,\n baseUrl: params.baseUrl,\n }),\n );\n\n return acc;\n },\n [],\n );\n }\n\n protected static filesMapFactory(files: MetafileFile[]): FilesMap {\n return files.reduce(\n (acc: FilesMap, cur: MetafileFile) => {\n acc[cur.id] = cur;\n\n return acc;\n },\n {},\n );\n }\n\n protected static localesFactory(files: MetafileFile[]): CdnLocale[] {\n const locales: CdnLocale[] = files.reduce(\n (acc: CdnLocale[], cur: MetafileFile) => {\n acc.push(\n ...cur.locales.map(\n (locale: MetafileLocale): CdnLocale => locale.toCdnLocale(),\n ),\n );\n return acc;\n },\n [],\n );\n\n return uniqBy(locales, (cdnLocale: CdnLocale): string => cdnLocale.locale);\n }\n}\n","import { IMetafileParams } from '@/interfaces/i-metafile-params';\n\nexport class MetafileParams implements IMetafileParams {\n protected options: IMetafileParams;\n\n constructor(metafileUrl: string) {\n this.options = MetafileParams.parseMetafileUrl(metafileUrl);\n }\n\n get url(): string {\n return this.options.url;\n }\n\n get baseUrl(): string {\n return this.options.baseUrl;\n }\n\n get cdnId(): string {\n return this.options.cdnId;\n }\n\n get jsonPath(): string {\n return this.options.jsonPath;\n }\n\n protected static parseMetafileUrl(metafileUrl: string): IMetafileParams {\n let url: URL;\n\n try {\n url = new URL(metafileUrl);\n } catch (e) {\n throw new Error('Invalid param: \"options.metafile\" cannot be parsed as url.');\n }\n\n const matches: string[] | null = url.pathname.match(/^\\/(.*?)\\/(.*?)\\.(v2.json|js|ts)$/);\n\n if (matches === null || matches.length !== 4) {\n throw new Error('Invalid param: \"options.metafile\" contains invalid metafile url.');\n }\n\n const cdnId: string = matches[1];\n const tagId: string = matches[2];\n\n return {\n url: metafileUrl,\n baseUrl: url.origin,\n cdnId,\n jsonPath: `/${cdnId}/${tagId}.v2.json`,\n };\n }\n}\n","import { MetafileData } from '@/cdn/metafile/metafile-data';\nimport { IMetafile } from '@/interfaces/i-metafile';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params';\nimport { CdnClientOptions } from '@/types/cdn-client-options';\n\nexport class MetafileContext {\n public params: MetafileParams;\n\n public parsedData: IMetafile | null;\n\n public data: MetafileData;\n\n constructor(options: CdnClientOptions) {\n this.params = new MetafileParams(options.metafile);\n this.parsedData = null;\n this.data = MetafileData.createEmpty(this.params);\n }\n\n public setMetafile(metafile: IMetafile): void {\n this.parsedData = metafile;\n\n this.data = new MetafileData(metafile, this.params);\n }\n}\n","import { ApiLocaleRequest } from '@/types/api-locale-request';\nimport { Context } from '@/cdn/context/context';\nimport { ResponseFactoryOptions } from '@/types/response-factory-options';\nimport { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request';\nimport { CdnResponse } from '@/types/cdn-response';\n\nexport class ResponseFactory {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public createCdnResponse(options: ResponseFactoryOptions): CdnResponse {\n const {\n requests, responses, hasSingleFileResponse, hasSingleLocaleResponse,\n }: ResponseFactoryOptions = options;\n\n if (responses.length === 0) {\n return {};\n }\n\n this.cacheResponses(requests, responses);\n\n return hasSingleFileResponse && hasSingleLocaleResponse\n ? responses[0]\n : ResponseFactory.transformResponses(options);\n }\n\n protected cacheResponses(requests: ApiLocaleRequest[], responses: (object | string)[]): void {\n responses.forEach((response: object | string, index: number): void => {\n const {\n metafileFile,\n metafileLocale,\n }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n if (metafileFile && metafileLocale) {\n this.context.cache.setIfMissed({ metafileFile, metafileLocale, data: response });\n }\n });\n }\n\n protected static transformResponses(options: ResponseFactoryOptions): CdnResponse {\n const { requests, responses, hasSingleFileResponse }: ResponseFactoryOptions = options;\n\n return responses.reduce(\n (acc: CdnResponse, cur: object | string, index: number) => {\n const {\n metafileFile,\n metafileLocale,\n }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n if (metafileFile && metafileLocale) {\n if (hasSingleFileResponse) {\n // @ts-expect-error fix output type\n acc[metafileLocale.locale] = cur;\n } else {\n // @ts-expect-error fix output type\n if (!acc[metafileFile.id]) {\n // @ts-expect-error fix output type\n acc[metafileFile.id] = {};\n }\n\n // @ts-expect-error fix output type\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n acc[metafileFile.id][metafileLocale.locale] = cur;\n }\n }\n\n return acc;\n },\n {},\n );\n }\n}\n","import { Api } from '@/cdn/api/api';\nimport { LocalesCache } from '@/cdn/cache/locales-cache';\nimport { CdnClient } from '@/cdn/cdn-client';\nimport { ResponseFactory } from '@/cdn/response/response-factory';\nimport { ContextOptions } from '@/types/context-options';\nimport { MetafileContext } from '@/cdn/context/metafile-context';\nimport { IHttpAdapter } from '@/interfaces/i-http-adapter';\n\nexport class Context {\n public metafile: MetafileContext;\n\n public cdn: CdnClient;\n\n public client: IHttpAdapter;\n\n public api: Api;\n\n public cache: LocalesCache;\n\n public responseFactory: ResponseFactory;\n\n constructor(options: ContextOptions) {\n this.metafile = options.metafileContext;\n this.cdn = options.cdn;\n this.client = options.client;\n this.api = new Api(this);\n this.cache = new LocalesCache(this);\n this.responseFactory = new ResponseFactory(this);\n }\n}\n","import { MetafileFile } from '@/cdn/metafile/metafile-file';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params';\nimport { CdnClientOptions } from '@/types/cdn-client-options';\nimport { MetafileData } from '@/cdn/metafile/metafile-data';\nimport { CdnBase } from '@/cdn/methods/cdn-base';\nimport { CdnFile } from '@/types/cdn-file';\nimport { CdnLocalesOptions } from '@/types/cdn-locales-options';\nimport { IMetafile } from '@/interfaces/i-metafile';\nimport { CdnLocale } from '@/types/cdn-locale';\n\nexport class CdnMetafile extends CdnBase {\n get projectUrl(): string {\n return this.context.metafile.data.projectUrl;\n }\n\n get baseLocale(): CdnLocale {\n return this.context.metafile.data.baseLocale;\n }\n\n get url(): string {\n return this.context.metafile.params.url;\n }\n\n get files(): CdnFile[] {\n return this.context.metafile.data.files.map((file: MetafileFile): CdnFile => file.toCdnFile());\n }\n\n public locales = (options?: CdnLocalesOptions): CdnLocale[] => {\n const { excludeBaseLocale }: CdnLocalesOptions = options || {};\n const { locales }: MetafileData = this.context.metafile.data;\n\n return excludeBaseLocale\n ? locales.filter((cdnLocale: CdnLocale): boolean => !cdnLocale.isBaseLocale)\n : locales;\n };\n\n public refresh = async (): Promise<void> => {\n const response: IMetafile = await this.context.api.fetchMetafile();\n\n this.context.metafile.setMetafile(response);\n };\n\n public switch = async (options: CdnClientOptions): Promise<void> => {\n this.context.metafile.params = new MetafileParams(options.metafile);\n\n await this.refresh();\n };\n}\n","import { Context } from '@/cdn/context/context';\nimport { LocalesMapData } from '@/types/locales-map-data';\nimport { LocalesMapOptions } from '@/types/locales-map-options';\n\nexport class LocalesMap {\n public data: LocalesMapData;\n\n protected context: Context;\n\n constructor(options: LocalesMapOptions) {\n this.context = options.context;\n this.data = options.data || {};\n }\n}\n","import { Context } from '@/cdn/context/context';\nimport { MetafileFile } from '@/cdn/metafile/metafile-file';\nimport { MetafileLocale } from '@/cdn/metafile/metafile-locale';\nimport { LocalesMap } from '@/cdn/request/locales-map';\nimport { ApiLocaleRequest } from '@/types/api-locale-request';\nimport { CdnResponse } from '@/types/cdn-response';\n\nexport class Request {\n public files: MetafileFile[];\n\n public localesMap: LocalesMap;\n\n public hasSingleFileResponse: boolean;\n\n public hasSingleLocaleResponse: boolean;\n\n protected context: Context;\n\n constructor(context: Context) {\n this.files = [];\n this.localesMap = new LocalesMap({ context });\n this.hasSingleFileResponse = false;\n this.hasSingleLocaleResponse = false;\n this.context = context;\n }\n\n public async execute(): Promise<CdnResponse> {\n const payload: [Promise<string | object>, ApiLocaleRequest][] = this.getPromises();\n const promises: Promise<string | object>[] = payload.map(\n (item: [Promise<string | object>, ApiLocaleRequest]) => item[0],\n );\n const requests: ApiLocaleRequest[] = payload.map(\n (item: [Promise<string | object>, ApiLocaleRequest]) => item[1],\n );\n const responses: (string | object)[] = await Promise.all(promises);\n\n return this.context.responseFactory.createCdnResponse({\n requests,\n responses,\n localesMap: this.localesMap,\n hasSingleFileResponse: this.hasSingleFileResponse,\n hasSingleLocaleResponse: this.hasSingleLocaleResponse,\n });\n }\n\n protected getPromises(): [Promise<string | object>, ApiLocaleRequest][] {\n return this.files.reduce(\n (acc: [Promise<string | object>, ApiLocaleRequest][], cur: MetafileFile) => {\n if (this.localesMap.data[cur.id]) {\n acc.push(\n ...this.localesMap.data[cur.id].map(\n (metafileLocale: MetafileLocale): [Promise<string | object>, ApiLocaleRequest] => {\n const request: ApiLocaleRequest = {\n metafileFile: cur,\n metafileLocale,\n };\n\n return [\n this.context.api.fetchLocale(request),\n request,\n ];\n },\n ),\n );\n }\n return acc;\n },\n [],\n );\n }\n}\n","import {\n isPlainObject, isArray, isString, isUndefined,\n} from '@/cdn/utils';\nimport { CdnFile } from '@/types/cdn-file';\nimport { MetafileLocale } from '@/cdn/metafile/metafile-locale';\nimport { LocalesMap } from '@/cdn/request/locales-map';\nimport { Context } from '@/cdn/context/context';\nimport { MetafileFile } from '@/cdn/metafile/metafile-file';\nimport { IRequestBuilder } from '@/interfaces/i-request-builder';\nimport { Request } from '@/cdn/request/request';\n\nexport class RequestBuilder implements IRequestBuilder {\n protected context: Context;\n\n protected request: Request;\n\n constructor(context: Context) {\n this.context = context;\n this.request = new Request(this.context);\n }\n\n public addFiles(files?: (CdnFile | string)[] | CdnFile | string): RequestBuilder {\n if (!(isPlainObject(files) || isString(files) || isUndefined(files) || isArray(files))) {\n throw new Error('Invalid param: \"request.files\" must be object, array, string or undefined.');\n }\n\n if (isArray(files)) {\n files.forEach((i: CdnFile | string): void => {\n if (!(isPlainObject(i) || isString(i))) {\n throw new Error('Invalid param: array \"request.files\" must contain objects or strings.');\n }\n });\n }\n\n if (isString(files)) {\n this.request.hasSingleFileResponse = true;\n\n const file: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === files,\n );\n\n if (!(file instanceof MetafileFile)) {\n throw new Error(`File not found: \"${files}\".`);\n }\n\n this.request.files = [file];\n } else if (isUndefined(files)) {\n this.request.files = [...this.context.metafile.data.files];\n } else if (isArray(files)) {\n this.request.files = files.map((file: CdnFile | string): MetafileFile => {\n let metafileFile: MetafileFile;\n\n if (isString(file)) {\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === file,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${file}\".`);\n }\n\n metafileFile = foundFile;\n } else {\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === file.id,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${file.id}\".`);\n }\n\n metafileFile = foundFile;\n }\n\n return metafileFile;\n });\n } else if (isPlainObject(files)) {\n this.request.hasSingleFileResponse = true;\n\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === files.id,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${files.id}\".`);\n }\n\n this.request.files = [foundFile];\n }\n\n return this;\n }\n\n public addLocales(locales?: string[] | string, excludeBaseLocale?: boolean): RequestBuilder {\n if (!(isString(locales) || isUndefined(locales) || isArray(locales))) {\n throw new Error('Invalid param: \"request.locales\" must be array, string or undefined.');\n }\n\n if (isArray(locales)) {\n locales.forEach((i: MetafileFile | string): void => {\n if (!isString(i)) {\n throw new Error('Invalid param: array \"request.locales\" must contain strings.');\n }\n });\n }\n\n if (isString(locales)) {\n this.request.hasSingleLocaleResponse = true;\n this.request.files.reduce(\n (acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = cur.locales.filter(\n (metafileLocale: MetafileLocale): boolean => metafileLocale.locale === locales,\n );\n\n return acc;\n },\n this.request.localesMap,\n );\n } else if (isUndefined(locales)) {\n this.request.files.reduce(\n (acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = excludeBaseLocale\n ? cur.locales.filter((metafileLocale: MetafileLocale): boolean => !metafileLocale.isBaseLocale)\n : cur.locales;\n\n return acc;\n },\n this.request.localesMap,\n );\n } else if (isArray(locales)) {\n this.request.files.reduce(\n (acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = cur.locales.filter(\n (metafileLocale: MetafileLocale) => locales.includes(metafileLocale.locale),\n );\n\n return acc;\n },\n this.request.localesMap,\n );\n }\n\n return this;\n }\n\n public getCdnRequest(): Request {\n const result: Request = this.request;\n this.request = new Request(this.context);\n return result;\n }\n}\n","import { IHttpAdapter } from '@/interfaces/i-http-adapter';\n\nexport class FetchHttpAdapter implements IHttpAdapter {\n protected baseUrl: string;\n\n constructor(baseUrl: string) {\n this.baseUrl = baseUrl;\n }\n\n async get(url: string): Promise<string | object> {\n const response: Response = await fetch(`${this.baseUrl}${url}`);\n const contentType: string = response.headers.get('content-type') || '';\n const isJson: boolean = [\n 'application/json5',\n 'application/json',\n ].includes(contentType);\n\n if (response.status >= 400) {\n throw new Error(`Request failed with status code ${response.status}`);\n }\n\n let result: string | object = '';\n\n if (isJson) {\n try {\n result = await response.json() as object;\n } catch (error) {\n result = {};\n }\n } else {\n try {\n result = await response.text();\n } catch (error) {\n result = '';\n }\n }\n\n return result;\n }\n}\n","import 'isomorphic-fetch';\nimport { isString } from '@/cdn/utils';\nimport { CdnFetchOptions } from '@/types/cdn-fetch-options';\nimport { CdnResponse } from '@/types/cdn-response';\nimport { CdnCache } from '@/cdn/methods/cdn-cache';\nimport { MetafileContext } from '@/cdn/context/metafile-context';\nimport { Context } from '@/cdn/context/context';\nimport { CdnMetafile } from '@/cdn/methods/cdn-metafile';\nimport { RequestBuilder } from '@/cdn/request/request-builder';\nimport { FetchHttpAdapter } from '@/cdn/http/fetch-http-adapter';\nimport { CdnClientOptions } from '@/types/cdn-client-options';\n\nexport class CdnClient {\n public metafile: CdnMetafile;\n\n public cache: CdnCache;\n\n protected context: Context;\n\n protected constructor(options: CdnClientOptions) {\n const metafileContext: MetafileContext = new MetafileContext(options);\n const client: FetchHttpAdapter = new FetchHttpAdapter(metafileContext.params.baseUrl);\n\n this.context = new Context({ metafileContext, cdn: this, client });\n this.metafile = new CdnMetafile(this.context);\n this.cache = new CdnCache(this.context);\n }\n\n public fetch = async (options?: CdnFetchOptions): Promise<CdnResponse> => {\n const { files, locales, excludeBaseLocale }: CdnFetchOptions = options || {};\n const requestBuilder: RequestBuilder = new RequestBuilder(this.context)\n .addFiles(files)\n .addLocales(locales, excludeBaseLocale);\n\n return requestBuilder.getCdnRequest().execute();\n };\n\n public static async create(options: CdnClientOptions): Promise<CdnClient> {\n if (!options) {\n throw new Error('Invalid param: missing required \"options\" parameter.');\n }\n\n if (!isString(options.metafile)) {\n throw new Error('Invalid param: \"options.metafile\" must be string.');\n }\n\n const cdn: CdnClient = new CdnClient(options);\n\n await cdn.metafile.refresh();\n\n return cdn;\n }\n}\n"],"names":["Api","constructor","context","__publicField","this","fetchLocale","options","cache","has","Promise","resolve","get","client","metafileLocale","uri","fetchMetafile","metafile","params","jsonPath","isString","value","isUndefined","isArray","Array","isPlainObject","Object","prototype","toString","call","uniq","array","Set","uniqBy","predicate","seen","filter","item","key","hasOwn","MemoryCacheAdapter","map","Map","set","flush","LocalesCache","cacheAdapter","setIfMissed","metafileFile","data","keyFromMetafile","productFlavors","sort","join","cdnId","id","file","path","library","module","buildType","locale","timestamp","CdnBase","CdnCache","super","arguments","MetafileLocale","baseLocale","language","region","script","isRtl","name","localizedName","isBaseLocale","toCdnLocale","MetafileFile","locales","baseUrl","toCdnFile","MetafileData","projectUrl","files","filesFactory","filesMap","filesMapFactory","localesFactory","find","createEmpty","keys","reduce","acc","cur","push","cdnLocale","MetafileParams","metafileUrl","parseMetafileUrl","url","URL","e","Error","matches","pathname","match","length","tagId","origin","MetafileContext","parsedData","setMetafile","ResponseFactory","createCdnResponse","requests","responses","hasSingleFileResponse","hasSingleLocaleResponse","cacheResponses","transformResponses","forEach","response","index","Context","metafileContext","cdn","api","responseFactory","CdnMetafile","excludeBaseLocale","async","refresh","LocalesMap","Request","localesMap","execute","payload","getPromises","promises","all","request","RequestBuilder","addFiles","i","foundFile","addLocales","includes","getCdnRequest","result","FetchHttpAdapter","fetch","contentType","headers","isJson","status","json","error","text","CdnClient","create"],"mappings":";;;;AAQO,MAAMA,EAGX,WAAAC,CAAYC,GAFFC,EAAAC,KAAA,WAGRA,KAAKF,QAAUA,CACjB,CAEA,iBAAaG,CAAYC,GACvB,OAAIF,KAAKF,QAAQK,MAAMC,IAAIF,GAClB,IAAIG,SAASC,IAClBA,EAAQN,KAAKF,QAAQK,MAAMI,IAAIL,GAA2B,IAIvDF,KAAKF,QAAQU,OAAOD,IAAIL,EAAQO,eAAeC,IACxD,CAEA,mBAAaC,GACJ,aAAMX,KAAKF,QAAQU,OAAOD,IAAIP,KAAKF,QAAQc,SAASC,OAAOC,SACpE,EC3BW,MAAAC,EAAYC,GAAqD,iBAAVA,EAEvDC,EAAeD,QAAwD,IAAVA,EAE7DE,EAAcF,GAAiCG,MAAMD,QAAQF,GAE7DI,EAAiBJ,GACQ,oB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Q6H,MAAO3H,IACpB,MAAM4E,MAAEA,EAAOL,QAAAA,EAAAmD,kBAASA,GAAuC1H,GAAW,CAAA,EAKnE,OAJgC,IAAIsI,EAAexI,KAAKF,SAC5D2I,SAAS3D,GACT8D,WAAWnE,EAASmD,GAEDkB,gBAAgBZ,aAdhC,MAAAX,EAAmC,IAAIf,EAAgBtG,GACvDM,EAA2B,IAAIwI,EAAiBzB,EAAgB1G,OAAO6D,SAExE1E,KAAAF,QAAU,IAAIwH,EAAQ,CAAEC,kBAAiBC,IAAKxH,KAAMQ,WACzDR,KAAKY,SAAW,IAAI+G,EAAY3H,KAAKF,SACrCE,KAAKG,MAAQ,IAAIwD,EAAS3D,KAAKF,QACjC,CAWA,mBAAoB4J,CAAOxJ,GACzB,IAAKA,EACG,MAAA,IAAI+F,MAAM,wDAGlB,IAAKlF,EAASb,EAAQU,UACd,MAAA,IAAIqF,MAAM,qDAGZ,MAAAuB,EAAiB,IAAIiC,EAAUvJ,GAI9B,aAFDsH,EAAI5G,SAASkH,UAEZN,CACT"}
1
+ {"version":3,"file":"localazy-cdn-client.umd.min.js","sources":["../../src/cdn/api/api.ts","../../src/cdn/utils.ts","../../src/cdn/cache/memory-cache-adapter.ts","../../src/cdn/cache/locales-cache.ts","../../src/cdn/methods/cdn-base.ts","../../src/cdn/methods/cdn-cache.ts","../../src/cdn/metafile/metafile-locale.ts","../../src/cdn/metafile/metafile-file.ts","../../src/cdn/metafile/metafile-data.ts","../../src/cdn/metafile/metafile-params.ts","../../src/cdn/context/metafile-context.ts","../../src/cdn/response/response-factory.ts","../../src/cdn/context/context.ts","../../src/cdn/methods/cdn-metafile.ts","../../src/cdn/request/locales-map.ts","../../src/cdn/request/request.ts","../../src/cdn/request/request-builder.ts","../../src/cdn/http/fetch-http-adapter.ts","../../src/cdn/cdn-client.ts"],"sourcesContent":["import { IMetafile } from '@/interfaces/i-metafile';\nimport { ApiLocaleRequest } from '@/types/api-locale-request';\nimport { Context } from '@/cdn/context/context';\n\nexport class Api {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public async fetchLocale(options: ApiLocaleRequest): Promise<object | string> {\n if (this.context.cache.has(options)) {\n return new Promise((resolve): void => {\n resolve(this.context.cache.get(options) as object | string);\n });\n }\n\n return this.context.client.get(options.metafileLocale.uri);\n }\n\n public async fetchMetafile(): Promise<IMetafile> {\n return (await this.context.client.get(this.context.metafile.params.jsonPath)) as IMetafile;\n }\n}\n","export const isString = (value: unknown): value is string => typeof value === 'string';\n\nexport const isUndefined = (value: unknown): value is undefined => typeof value === 'undefined';\n\nexport const isArray = <T>(value: unknown): value is T[] => Array.isArray(value);\n\nexport const isPlainObject = (value: unknown): value is Record<string, unknown> =>\n Object.prototype.toString.call(value) === '[object Object]';\n\nexport const uniq = <T>(array: T[]): T[] => [...new Set(array)];\n\nexport const uniqBy = <T>(array: T[], predicate: (item: T) => string): T[] => {\n const seen: Record<string, boolean> = {};\n\n return array.filter((item: T): boolean => {\n const key: string = predicate(item);\n\n if (!Object.hasOwn(seen, key)) {\n seen[key] = true;\n\n return true;\n }\n\n return false;\n });\n};\n","import { ICacheAdapter } from '@/interfaces/i-cache-adapter';\n\nexport class MemoryCacheAdapter<K, V> implements ICacheAdapter<K, V> {\n protected map: Map<K, V>;\n\n constructor() {\n this.map = new Map();\n }\n\n public get(key: K): V | undefined {\n return this.map.get(key);\n }\n\n public has(key: K): boolean {\n return this.map.has(key);\n }\n\n public set(key: K, value: V): void {\n this.map.set(key, value);\n }\n\n public flush(): void {\n this.map = new Map();\n }\n}\n","import { uniq } from '@/cdn/utils';\nimport { ICacheAdapter } from '@/interfaces/i-cache-adapter';\nimport { CacheKeyMetafileOptions } from '@/types/cache-key-metafile-options';\nimport { CacheGetLocalesRequest } from '@/types/cache-get-locales-request';\nimport { CacheHasLocalesRequest } from '@/types/cache-has-locales-request';\nimport { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request';\nimport { MemoryCacheAdapter } from '@/cdn/cache/memory-cache-adapter';\nimport { Context } from '@/cdn/context/context';\n\nexport class LocalesCache {\n protected context: Context;\n\n protected cacheAdapter: ICacheAdapter<string, object | string>;\n\n constructor(context: Context) {\n this.context = context;\n this.cacheAdapter = new MemoryCacheAdapter();\n }\n\n public setIfMissed(options: CacheStoreLocalesRequest): void {\n const { metafileFile, metafileLocale, data }: CacheStoreLocalesRequest = options;\n\n const key: string = this.keyFromMetafile({\n metafileFile,\n metafileLocale,\n });\n\n if (!this.cacheAdapter.has(key)) {\n this.cacheAdapter.set(key, data);\n }\n }\n\n public has(options: CacheHasLocalesRequest): boolean {\n const key: string = this.keyFromMetafile(options);\n\n return this.cacheAdapter.has(key);\n }\n\n public get(options: CacheGetLocalesRequest): object | string | undefined {\n const key: string = this.keyFromMetafile(options);\n\n return this.cacheAdapter.get(key);\n }\n\n public flush(): void {\n this.cacheAdapter.flush();\n }\n\n protected keyFromMetafile(options: CacheKeyMetafileOptions): string {\n const { metafileFile, metafileLocale }: CacheKeyMetafileOptions = options;\n const productFlavors: string = [...uniq(metafileFile.productFlavors)].sort().join('-');\n\n const indices: string[] = [\n this.context.metafile.params.cdnId,\n metafileFile.id,\n metafileFile.file,\n metafileFile.path,\n metafileFile.library,\n metafileFile.module,\n metafileFile.buildType,\n productFlavors,\n metafileLocale.locale,\n metafileLocale.timestamp.toString(),\n ];\n\n return indices.filter((key: string): boolean => key !== '').join('-');\n }\n}\n","import { Context } from '@/cdn/context/context';\n\nexport abstract class CdnBase {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n}\n","import { CdnBase } from '@/cdn/methods/cdn-base';\n\nexport class CdnCache extends CdnBase {\n public flush = (): void => {\n this.context.cache.flush();\n };\n}\n","import { CdnLocale } from '@/types/cdn-locale';\nimport { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale';\n\nexport class MetafileLocale implements IMetafileFileLocale {\n public language: string;\n\n public region: string;\n\n public script: string;\n\n public isRtl: boolean;\n\n public name: string;\n\n public localizedName: string;\n\n public uri: string;\n\n public timestamp: number;\n\n protected baseLocale: string;\n\n constructor(options: IMetafileFileLocale, baseLocale: string) {\n this.language = options.language;\n this.region = options.region;\n this.script = options.script;\n this.isRtl = options.isRtl;\n this.name = options.name;\n this.localizedName = options.localizedName;\n this.uri = options.uri;\n this.timestamp = options.timestamp;\n this.baseLocale = baseLocale;\n }\n\n get locale(): string {\n if (this.language && this.region && this.script) {\n return `${this.language}_${this.region}#${this.script}`;\n }\n\n if (this.language && this.script) {\n return `${this.language}#${this.script}`;\n }\n\n if (this.language && this.region) {\n return `${this.language}_${this.region}`;\n }\n\n return this.language;\n }\n\n get isBaseLocale(): boolean {\n return this.locale === this.baseLocale;\n }\n\n public toCdnLocale(): CdnLocale {\n return {\n locale: this.locale,\n isBaseLocale: this.isBaseLocale,\n language: this.language,\n region: this.region,\n script: this.script,\n isRtl: this.isRtl,\n name: this.name,\n localizedName: this.localizedName,\n };\n }\n}\n","import { CdnFile } from '@/types/cdn-file';\nimport { CdnFileLocale } from '@/types/cdn-file-locale';\nimport { MetafileLocale } from '@/cdn/metafile/metafile-locale';\nimport { IMetafileFile } from '@/interfaces/i-metafile-file';\nimport { MetafileFileOptions } from '@/types/metafile-file-options';\n\nexport class MetafileFile implements Omit<IMetafileFile, 'locales'> {\n public id: string;\n\n public file: string;\n\n public path: string;\n\n public library: string;\n\n public module: string;\n\n public buildType: string;\n\n public timestamp: number;\n\n public productFlavors: string[];\n\n public locales: MetafileLocale[];\n\n protected baseUrl: string;\n\n constructor(options: MetafileFileOptions) {\n this.id = options.id;\n this.file = options.file;\n this.path = options.path;\n this.library = options.library;\n this.module = options.module;\n this.buildType = options.buildType;\n this.timestamp = options.timestamp;\n this.productFlavors = options.productFlavors;\n this.locales = options.locales;\n this.baseUrl = options.baseUrl;\n }\n\n public toCdnFile(): CdnFile {\n return {\n id: this.id,\n file: this.file,\n path: this.path,\n library: this.library,\n module: this.module,\n buildType: this.buildType,\n productFlavors: this.productFlavors,\n locales: this.locales.map(\n (locale: MetafileLocale): CdnFileLocale => ({\n locale: locale.locale,\n isBaseLocale: locale.isBaseLocale,\n uri: `${this.baseUrl}${locale.uri}`,\n }),\n ),\n };\n }\n}\n","import { uniqBy } from '@/cdn/utils';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params';\nimport { CdnLocale } from '@/types/cdn-locale';\nimport { MetafileLocale } from '@/cdn/metafile/metafile-locale';\nimport { IMetafile } from '@/interfaces/i-metafile';\nimport { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale';\nimport { IMetafileFiles } from '@/interfaces/i-metafile-files';\nimport { MetafileFile } from '@/cdn/metafile/metafile-file';\nimport { MetafileOptions } from '@/types/metafile-options';\nimport { FilesMap } from '@/types/files-map';\n\nexport class MetafileData implements Omit<IMetafile, 'files' | 'baseLocale'> {\n public projectUrl: string;\n\n public baseLocale: CdnLocale;\n\n public locales: CdnLocale[];\n\n public timestamp: number;\n\n public files: MetafileFile[];\n\n public filesMap: FilesMap;\n\n constructor(options: MetafileOptions, params: MetafileParams) {\n this.projectUrl = options.projectUrl;\n this.timestamp = options.timestamp;\n this.files = MetafileData.filesFactory(options.files, options.baseLocale, params);\n this.filesMap = MetafileData.filesMapFactory(this.files);\n this.locales = MetafileData.localesFactory(this.files);\n this.baseLocale = this.locales.find((locale: CdnLocale) => locale.isBaseLocale) as CdnLocale;\n }\n\n public static createEmpty(params: MetafileParams): MetafileData {\n return new MetafileData(\n {\n projectUrl: '',\n baseLocale: '',\n timestamp: 0,\n files: {},\n },\n params,\n );\n }\n\n protected static filesFactory(files: IMetafileFiles, baseLocale: string, params: MetafileParams): MetafileFile[] {\n return Object.keys(files).reduce((acc: MetafileFile[], cur: string) => {\n const locales: MetafileLocale[] = files[cur].locales.map(\n (locale: IMetafileFileLocale) => new MetafileLocale(locale, baseLocale),\n );\n\n acc.push(\n new MetafileFile({\n ...files[cur],\n id: cur,\n locales,\n baseUrl: params.baseUrl,\n }),\n );\n\n return acc;\n }, []);\n }\n\n protected static filesMapFactory(files: MetafileFile[]): FilesMap {\n return files.reduce((acc: FilesMap, cur: MetafileFile) => {\n acc[cur.id] = cur;\n\n return acc;\n }, {});\n }\n\n protected static localesFactory(files: MetafileFile[]): CdnLocale[] {\n const locales: CdnLocale[] = files.reduce((acc: CdnLocale[], cur: MetafileFile) => {\n acc.push(...cur.locales.map((locale: MetafileLocale): CdnLocale => locale.toCdnLocale()));\n return acc;\n }, []);\n\n return uniqBy(locales, (cdnLocale: CdnLocale): string => cdnLocale.locale);\n }\n}\n","import { IMetafileParams } from '@/interfaces/i-metafile-params';\n\nexport class MetafileParams implements IMetafileParams {\n protected options: IMetafileParams;\n\n constructor(metafileUrl: string) {\n this.options = MetafileParams.parseMetafileUrl(metafileUrl);\n }\n\n get url(): string {\n return this.options.url;\n }\n\n get baseUrl(): string {\n return this.options.baseUrl;\n }\n\n get cdnId(): string {\n return this.options.cdnId;\n }\n\n get jsonPath(): string {\n return this.options.jsonPath;\n }\n\n protected static parseMetafileUrl(metafileUrl: string): IMetafileParams {\n let url: URL;\n\n try {\n url = new URL(metafileUrl);\n } catch (e) {\n throw new Error('Invalid param: \"options.metafile\" cannot be parsed as url.');\n }\n\n const matches: string[] | null = url.pathname.match(/^\\/(.*?)\\/(.*?)\\.(v2.json|js|ts)$/);\n\n if (matches === null || matches.length !== 4) {\n throw new Error('Invalid param: \"options.metafile\" contains invalid metafile url.');\n }\n\n const cdnId: string = matches[1];\n const tagId: string = matches[2];\n\n return {\n url: metafileUrl,\n baseUrl: url.origin,\n cdnId,\n jsonPath: `/${cdnId}/${tagId}.v2.json`,\n };\n }\n}\n","import { MetafileData } from '@/cdn/metafile/metafile-data';\nimport { IMetafile } from '@/interfaces/i-metafile';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params';\nimport { CdnClientOptions } from '@/types/cdn-client-options';\n\nexport class MetafileContext {\n public params: MetafileParams;\n\n public parsedData: IMetafile | null;\n\n public data: MetafileData;\n\n constructor(options: CdnClientOptions) {\n this.params = new MetafileParams(options.metafile);\n this.parsedData = null;\n this.data = MetafileData.createEmpty(this.params);\n }\n\n public setMetafile(metafile: IMetafile): void {\n this.parsedData = metafile;\n\n this.data = new MetafileData(metafile, this.params);\n }\n}\n","import { ApiLocaleRequest } from '@/types/api-locale-request';\nimport { Context } from '@/cdn/context/context';\nimport { ResponseFactoryOptions } from '@/types/response-factory-options';\nimport { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request';\nimport { CdnResponse } from '@/types/cdn-response';\n\nexport class ResponseFactory {\n protected context: Context;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public createCdnResponse(options: ResponseFactoryOptions): CdnResponse {\n const { requests, responses, hasSingleFileResponse, hasSingleLocaleResponse }: ResponseFactoryOptions = options;\n\n if (responses.length === 0) {\n return {};\n }\n\n this.cacheResponses(requests, responses);\n\n return hasSingleFileResponse && hasSingleLocaleResponse\n ? responses[0]\n : ResponseFactory.transformResponses(options);\n }\n\n protected cacheResponses(requests: ApiLocaleRequest[], responses: (object | string)[]): void {\n responses.forEach((response: object | string, index: number): void => {\n const { metafileFile, metafileLocale }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n if (metafileFile && metafileLocale) {\n this.context.cache.setIfMissed({ metafileFile, metafileLocale, data: response });\n }\n });\n }\n\n protected static transformResponses(options: ResponseFactoryOptions): CdnResponse {\n const { requests, responses, hasSingleFileResponse }: ResponseFactoryOptions = options;\n\n return responses.reduce((acc: CdnResponse, cur: object | string, index: number) => {\n const { metafileFile, metafileLocale }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n if (metafileFile && metafileLocale) {\n if (hasSingleFileResponse) {\n // @ts-expect-error fix output type\n acc[metafileLocale.locale] = cur;\n } else {\n // @ts-expect-error fix output type\n if (!acc[metafileFile.id]) {\n // @ts-expect-error fix output type\n acc[metafileFile.id] = {};\n }\n\n // @ts-expect-error fix output type\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n acc[metafileFile.id][metafileLocale.locale] = cur;\n }\n }\n\n return acc;\n }, {});\n }\n}\n","import { Api } from '@/cdn/api/api';\nimport { LocalesCache } from '@/cdn/cache/locales-cache';\nimport { CdnClient } from '@/cdn/cdn-client';\nimport { ResponseFactory } from '@/cdn/response/response-factory';\nimport { ContextOptions } from '@/types/context-options';\nimport { MetafileContext } from '@/cdn/context/metafile-context';\nimport { IHttpAdapter } from '@/interfaces/i-http-adapter';\n\nexport class Context {\n public metafile: MetafileContext;\n\n public cdn: CdnClient;\n\n public client: IHttpAdapter;\n\n public api: Api;\n\n public cache: LocalesCache;\n\n public responseFactory: ResponseFactory;\n\n constructor(options: ContextOptions) {\n this.metafile = options.metafileContext;\n this.cdn = options.cdn;\n this.client = options.client;\n this.api = new Api(this);\n this.cache = new LocalesCache(this);\n this.responseFactory = new ResponseFactory(this);\n }\n}\n","import { MetafileFile } from '@/cdn/metafile/metafile-file';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params';\nimport { CdnClientOptions } from '@/types/cdn-client-options';\nimport { MetafileData } from '@/cdn/metafile/metafile-data';\nimport { CdnBase } from '@/cdn/methods/cdn-base';\nimport { CdnFile } from '@/types/cdn-file';\nimport { CdnLocalesOptions } from '@/types/cdn-locales-options';\nimport { IMetafile } from '@/interfaces/i-metafile';\nimport { CdnLocale } from '@/types/cdn-locale';\n\nexport class CdnMetafile extends CdnBase {\n get projectUrl(): string {\n return this.context.metafile.data.projectUrl;\n }\n\n get baseLocale(): CdnLocale {\n return this.context.metafile.data.baseLocale;\n }\n\n get url(): string {\n return this.context.metafile.params.url;\n }\n\n get files(): CdnFile[] {\n return this.context.metafile.data.files.map((file: MetafileFile): CdnFile => file.toCdnFile());\n }\n\n public locales = (options?: CdnLocalesOptions): CdnLocale[] => {\n const { excludeBaseLocale }: CdnLocalesOptions = options || {};\n const { locales }: MetafileData = this.context.metafile.data;\n\n return excludeBaseLocale ? locales.filter((cdnLocale: CdnLocale): boolean => !cdnLocale.isBaseLocale) : locales;\n };\n\n public refresh = async (): Promise<void> => {\n const response: IMetafile = await this.context.api.fetchMetafile();\n\n this.context.metafile.setMetafile(response);\n };\n\n public switch = async (options: CdnClientOptions): Promise<void> => {\n this.context.metafile.params = new MetafileParams(options.metafile);\n\n await this.refresh();\n };\n}\n","import { Context } from '@/cdn/context/context';\nimport { LocalesMapData } from '@/types/locales-map-data';\nimport { LocalesMapOptions } from '@/types/locales-map-options';\n\nexport class LocalesMap {\n public data: LocalesMapData;\n\n protected context: Context;\n\n constructor(options: LocalesMapOptions) {\n this.context = options.context;\n this.data = options.data || {};\n }\n}\n","import { Context } from '@/cdn/context/context';\nimport { MetafileFile } from '@/cdn/metafile/metafile-file';\nimport { MetafileLocale } from '@/cdn/metafile/metafile-locale';\nimport { LocalesMap } from '@/cdn/request/locales-map';\nimport { ApiLocaleRequest } from '@/types/api-locale-request';\nimport { CdnResponse } from '@/types/cdn-response';\n\nexport class Request {\n public files: MetafileFile[];\n\n public localesMap: LocalesMap;\n\n public hasSingleFileResponse: boolean;\n\n public hasSingleLocaleResponse: boolean;\n\n protected context: Context;\n\n constructor(context: Context) {\n this.files = [];\n this.localesMap = new LocalesMap({ context });\n this.hasSingleFileResponse = false;\n this.hasSingleLocaleResponse = false;\n this.context = context;\n }\n\n public async execute(): Promise<CdnResponse> {\n const payload: [Promise<string | object>, ApiLocaleRequest][] = this.getPromises();\n const promises: Promise<string | object>[] = payload.map(\n (item: [Promise<string | object>, ApiLocaleRequest]) => item[0],\n );\n const requests: ApiLocaleRequest[] = payload.map((item: [Promise<string | object>, ApiLocaleRequest]) => item[1]);\n const responses: (string | object)[] = await Promise.all(promises);\n\n return this.context.responseFactory.createCdnResponse({\n requests,\n responses,\n localesMap: this.localesMap,\n hasSingleFileResponse: this.hasSingleFileResponse,\n hasSingleLocaleResponse: this.hasSingleLocaleResponse,\n });\n }\n\n protected getPromises(): [Promise<string | object>, ApiLocaleRequest][] {\n return this.files.reduce((acc: [Promise<string | object>, ApiLocaleRequest][], cur: MetafileFile) => {\n if (this.localesMap.data[cur.id]) {\n acc.push(\n ...this.localesMap.data[cur.id].map(\n (metafileLocale: MetafileLocale): [Promise<string | object>, ApiLocaleRequest] => {\n const request: ApiLocaleRequest = {\n metafileFile: cur,\n metafileLocale,\n };\n\n return [this.context.api.fetchLocale(request), request];\n },\n ),\n );\n }\n return acc;\n }, []);\n }\n}\n","import { isPlainObject, isArray, isString, isUndefined } from '@/cdn/utils';\nimport { CdnFile } from '@/types/cdn-file';\nimport { MetafileLocale } from '@/cdn/metafile/metafile-locale';\nimport { LocalesMap } from '@/cdn/request/locales-map';\nimport { Context } from '@/cdn/context/context';\nimport { MetafileFile } from '@/cdn/metafile/metafile-file';\nimport { IRequestBuilder } from '@/interfaces/i-request-builder';\nimport { Request } from '@/cdn/request/request';\n\nexport class RequestBuilder implements IRequestBuilder {\n protected context: Context;\n\n protected request: Request;\n\n constructor(context: Context) {\n this.context = context;\n this.request = new Request(this.context);\n }\n\n public addFiles(files?: (CdnFile | string)[] | CdnFile | string): RequestBuilder {\n if (!(isPlainObject(files) || isString(files) || isUndefined(files) || isArray(files))) {\n throw new Error('Invalid param: \"request.files\" must be object, array, string or undefined.');\n }\n\n if (isArray(files)) {\n files.forEach((i: CdnFile | string): void => {\n if (!(isPlainObject(i) || isString(i))) {\n throw new Error('Invalid param: array \"request.files\" must contain objects or strings.');\n }\n });\n }\n\n if (isString(files)) {\n this.request.hasSingleFileResponse = true;\n\n const file: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === files,\n );\n\n if (!(file instanceof MetafileFile)) {\n throw new Error(`File not found: \"${files}\".`);\n }\n\n this.request.files = [file];\n } else if (isUndefined(files)) {\n this.request.files = [...this.context.metafile.data.files];\n } else if (isArray(files)) {\n this.request.files = files.map((file: CdnFile | string): MetafileFile => {\n let metafileFile: MetafileFile;\n\n if (isString(file)) {\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === file,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${file}\".`);\n }\n\n metafileFile = foundFile;\n } else {\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === file.id,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${file.id}\".`);\n }\n\n metafileFile = foundFile;\n }\n\n return metafileFile;\n });\n } else if (isPlainObject(files)) {\n this.request.hasSingleFileResponse = true;\n\n const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n (i: MetafileFile): boolean => i.id === files.id,\n );\n\n if (isUndefined(foundFile)) {\n throw new Error(`File not found: \"${files.id}\".`);\n }\n\n this.request.files = [foundFile];\n }\n\n return this;\n }\n\n public addLocales(locales?: string[] | string, excludeBaseLocale?: boolean): RequestBuilder {\n if (!(isString(locales) || isUndefined(locales) || isArray(locales))) {\n throw new Error('Invalid param: \"request.locales\" must be array, string or undefined.');\n }\n\n if (isArray(locales)) {\n locales.forEach((i: MetafileFile | string): void => {\n if (!isString(i)) {\n throw new Error('Invalid param: array \"request.locales\" must contain strings.');\n }\n });\n }\n\n if (isString(locales)) {\n this.request.hasSingleLocaleResponse = true;\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = cur.locales.filter(\n (metafileLocale: MetafileLocale): boolean => metafileLocale.locale === locales,\n );\n\n return acc;\n }, this.request.localesMap);\n } else if (isUndefined(locales)) {\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = excludeBaseLocale\n ? cur.locales.filter((metafileLocale: MetafileLocale): boolean => !metafileLocale.isBaseLocale)\n : cur.locales;\n\n return acc;\n }, this.request.localesMap);\n } else if (isArray(locales)) {\n this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n acc.data[cur.id] = cur.locales.filter((metafileLocale: MetafileLocale) =>\n locales.includes(metafileLocale.locale),\n );\n\n return acc;\n }, this.request.localesMap);\n }\n\n return this;\n }\n\n public getCdnRequest(): Request {\n const result: Request = this.request;\n this.request = new Request(this.context);\n return result;\n }\n}\n","import { IHttpAdapter } from '@/interfaces/i-http-adapter';\n\nexport class FetchHttpAdapter implements IHttpAdapter {\n protected baseUrl: string;\n\n constructor(baseUrl: string) {\n this.baseUrl = baseUrl;\n }\n\n async get(url: string): Promise<string | object> {\n const response: Response = await fetch(`${this.baseUrl}${url}`);\n const contentType: string | null = response.headers.get('content-type');\n const isJson: boolean = contentType === 'application/json5' || contentType === 'application/json';\n\n if (response.status >= 400) {\n throw new Error(`Request failed with status code ${response.status}`);\n }\n\n let result: string | object;\n\n if (isJson) {\n result = (await response.json()) as object;\n } else {\n result = await response.text();\n }\n\n return result;\n }\n}\n","import { isString } from '@/cdn/utils';\nimport { CdnFetchOptions } from '@/types/cdn-fetch-options';\nimport { CdnResponse } from '@/types/cdn-response';\nimport { CdnCache } from '@/cdn/methods/cdn-cache';\nimport { MetafileContext } from '@/cdn/context/metafile-context';\nimport { Context } from '@/cdn/context/context';\nimport { CdnMetafile } from '@/cdn/methods/cdn-metafile';\nimport { RequestBuilder } from '@/cdn/request/request-builder';\nimport { FetchHttpAdapter } from '@/cdn/http/fetch-http-adapter';\nimport { CdnClientOptions } from '@/types/cdn-client-options';\n\nexport class CdnClient {\n public metafile: CdnMetafile;\n\n public cache: CdnCache;\n\n protected context: Context;\n\n public static version = '__CLIENT_VERSION__';\n\n protected constructor(options: CdnClientOptions) {\n const metafileContext: MetafileContext = new MetafileContext(options);\n const client: FetchHttpAdapter = new FetchHttpAdapter(metafileContext.params.baseUrl);\n\n this.context = new Context({ metafileContext, cdn: this, client });\n this.metafile = new CdnMetafile(this.context);\n this.cache = new CdnCache(this.context);\n }\n\n public fetch = async (options?: CdnFetchOptions): Promise<CdnResponse> => {\n const { files, locales, excludeBaseLocale }: CdnFetchOptions = options || {};\n const requestBuilder: RequestBuilder = new RequestBuilder(this.context)\n .addFiles(files)\n .addLocales(locales, excludeBaseLocale);\n\n return requestBuilder.getCdnRequest().execute();\n };\n\n public static async create(options: CdnClientOptions): Promise<CdnClient> {\n if (!options) {\n throw new Error('Invalid param: missing required \"options\" parameter.');\n }\n\n if (!isString(options.metafile)) {\n throw new Error('Invalid param: \"options.metafile\" must be string.');\n }\n\n const cdn: CdnClient = new CdnClient(options);\n\n await cdn.metafile.refresh();\n\n return cdn;\n }\n}\n"],"names":["Api","constructor","context","__publicField","this","fetchLocale","options","cache","has","Promise","resolve","get","client","metafileLocale","uri","fetchMetafile","metafile","params","jsonPath","isString","value","isUndefined","isArray","Array","isPlainObject","Object","prototype","toString","call","uniq","array","Set","uniqBy","predicate","seen","filter","item","key","hasOwn","MemoryCacheAdapter","map","Map","set","flush","LocalesCache","cacheAdapter","setIfMissed","metafileFile","data","keyFromMetafile","productFlavors","sort","join","cdnId","id","file","path","library","module","buildType","locale","timestamp","CdnBase","CdnCache","super","arguments","MetafileLocale","baseLocale","language","region","script","isRtl","name","localizedName","isBaseLocale","toCdnLocale","MetafileFile","locales","baseUrl","toCdnFile","MetafileData","projectUrl","files","filesFactory","filesMap","filesMapFactory","localesFactory","find","createEmpty","keys","reduce","acc","cur","push","cdnLocale","MetafileParams","metafileUrl","parseMetafileUrl","url","URL","e","Error","matches","pathname","match","length","tagId","origin","MetafileContext","parsedData","setMetafile","ResponseFactory","createCdnResponse","requests","responses","hasSingleFileResponse","hasSingleLocaleResponse","cacheResponses","transformResponses","forEach","response","index","Context","metafileContext","cdn","api","responseFactory","CdnMetafile","excludeBaseLocale","async","refresh","LocalesMap","Request","localesMap","execute","payload","getPromises","promises","all","request","RequestBuilder","addFiles","i","foundFile","addLocales","includes","getCdnRequest","result","FetchHttpAdapter","fetch","contentType","headers","isJson","status","json","text","_CdnClient","create","CdnClient"],"mappings":";;;;AAIO,MAAMA,EAGX,WAAAC,CAAYC,GAFFC,EAAAC,KAAA,WAGRA,KAAKF,QAAUA,CACjB,CAEA,iBAAaG,CAAYC,GACvB,OAAIF,KAAKF,QAAQK,MAAMC,IAAIF,GAClB,IAAIG,SAASC,IAClBA,EAAQN,KAA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AAM,IAAIpD,MAAM,mCAAmCmB,EAASiC,UAG1D,IAAAN,EAQG,OALKA,EADRK,QACchC,EAASkC,aAEVlC,EAASmC,OAGnBR,CACT,EChBW,MAAAS,EAAN,MAAMA,EASD,WAAA3J,CAAYK,GARfH,EAAAC,KAAA,YAEAD,EAAAC,KAAA,SAEGD,EAAAC,KAAA,WAaHD,EAAAC,KAAA,SAAQ6H,MAAO3H,IACpB,MAAM4E,MAAEA,EAAOL,QAAAA,EAAAmD,kBAASA,GAAuC1H,GAAW,CAAA,EAKnE,OAJgC,IAAIsI,EAAexI,KAAKF,SAC5D2I,SAAS3D,GACT8D,WAAWnE,EAASmD,GAEDkB,gBAAgBZ,aAdhC,MAAAX,EAAmC,IAAIf,EAAgBtG,GACvDM,EAA2B,IAAIwI,EAAiBzB,EAAgB1G,OAAO6D,SAExE1E,KAAAF,QAAU,IAAIwH,EAAQ,CAAEC,kBAAiBC,IAAKxH,KAAMQ,WACzDR,KAAKY,SAAW,IAAI+G,EAAY3H,KAAKF,SACrCE,KAAKG,MAAQ,IAAIwD,EAAS3D,KAAKF,QACjC,CAWA,mBAAoB2J,CAAOvJ,GACzB,IAAKA,EACG,MAAA,IAAI+F,MAAM,wDAGlB,IAAKlF,EAASb,EAAQU,UACd,MAAA,IAAIqF,MAAM,qDAGZ,MAAAuB,EAAiB,IAAIgC,EAAUtJ,GAI9B,aAFDsH,EAAI5G,SAASkH,UAEZN,CACT,GAlCAzH,EAPWyJ,EAOG,UAAU,SAPnB,IAAME,EAANF"}
package/dist/index.d.ts CHANGED
@@ -7,10 +7,6 @@ export declare class Api {
7
7
 
8
8
  export declare type ApiLocaleRequest = ILocalesCacheItem;
9
9
 
10
- export declare type ApiRequestConfig = object & {
11
- reference: ApiLocaleRequest;
12
- };
13
-
14
10
  export declare type CacheGetLocalesRequest = ILocalesCacheItem;
15
11
 
16
12
  export declare type CacheHasLocalesRequest = ILocalesCacheItem;
@@ -34,6 +30,7 @@ export declare class CdnClient {
34
30
  metafile: CdnMetafile;
35
31
  cache: CdnCache;
36
32
  protected context: Context;
33
+ static version: string;
37
34
  protected constructor(options: CdnClientOptions);
38
35
  fetch: (options?: CdnFetchOptions) => Promise<CdnResponse>;
39
36
  static create(options: CdnClientOptions): Promise<CdnClient>;
@@ -115,16 +112,6 @@ export declare type CdnFileLocale = {
115
112
  uri: string;
116
113
  };
117
114
 
118
- export declare type CdnFilesSearchOptions = ((file: CdnFile, index?: number, array?: CdnFile[]) => boolean) | {
119
- id?: string;
120
- file?: string;
121
- path?: string;
122
- library?: string;
123
- module?: string;
124
- buildType?: string;
125
- productFlavors?: string[];
126
- };
127
-
128
115
  export declare type CdnLocale = {
129
116
  /**
130
117
  * Locale code.
@@ -220,20 +207,12 @@ export declare type ContextOptions = {
220
207
  client: IHttpAdapter;
221
208
  };
222
209
 
223
- export declare type ExcludeBaseLocale = {
224
- excludeBaseLocale?: boolean;
225
- };
226
-
227
210
  export declare class FetchHttpAdapter implements IHttpAdapter {
228
211
  protected baseUrl: string;
229
212
  constructor(baseUrl: string);
230
213
  get(url: string): Promise<string | object>;
231
214
  }
232
215
 
233
- export declare type FileResponse = {
234
- [fileId: string]: LocaleResponse;
235
- };
236
-
237
216
  export declare type FilesMap = {
238
217
  [id: string]: MetafileFile;
239
218
  };