@tonysamperi/ts-mapi-core 1.6.0 → 1.6.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.
Files changed (80) hide show
  1. package/changelog.md +4 -1
  2. package/dist/cjs/index.cjs +1 -1
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/cjs/index.d.cts +12 -8
  5. package/dist/cjs/services/http/index.cjs +1 -1
  6. package/dist/cjs/services/http/index.cjs.map +1 -1
  7. package/dist/cjs/services/http/index.d.cts +3 -4
  8. package/dist/cjs/services/http/smp-http.service.cjs +1 -1
  9. package/dist/cjs/services/http/smp-http.service.cjs.map +1 -1
  10. package/dist/cjs/services/http/smp-http.service.d.cts +6 -3
  11. package/dist/cjs/services/index.cjs +1 -1
  12. package/dist/cjs/services/index.cjs.map +1 -1
  13. package/dist/cjs/services/index.d.cts +3 -4
  14. package/dist/cjs/shared/api/index.cjs +1 -1
  15. package/dist/cjs/shared/api/index.cjs.map +1 -1
  16. package/dist/cjs/shared/api/smp-api-common-utils.class.cjs +1 -1
  17. package/dist/cjs/shared/api/smp-api-common-utils.class.cjs.map +1 -1
  18. package/dist/cjs/shared/giftcard/index.cjs.map +1 -1
  19. package/dist/cjs/shared/giftcard/smp-giftcard-transaction.class.cjs.map +1 -1
  20. package/dist/cjs/shared/giftcard/smp-giftcard-transaction.class.d.cts +1 -1
  21. package/dist/cjs/shared/marketing-cloud/index.d.cts +1 -1
  22. package/dist/cjs/shared/marketing-cloud/smp-marketing-cloud-validation-response.interface.cjs.map +1 -1
  23. package/dist/cjs/shared/marketing-cloud/smp-marketing-cloud-validation-response.interface.d.cts +4 -4
  24. package/dist/cjs/shared/rxjs/index.cjs +1 -1
  25. package/dist/cjs/shared/rxjs/index.cjs.map +1 -1
  26. package/dist/cjs/shared/rxjs/index.d.cts +1 -0
  27. package/dist/cjs/shared/rxjs/smp-rxjs-in-memory-cache.class.cjs +1 -1
  28. package/dist/cjs/shared/rxjs/smp-rxjs-in-memory-cache.class.cjs.map +1 -1
  29. package/dist/cjs/shared/rxjs/smp-rxjs-in-memory-cache.class.d.cts +3 -3
  30. package/dist/cjs/shared/rxjs/smp-rxjs-throw-on-condition.function.cjs.map +1 -1
  31. package/dist/cjs/shared/rxjs/smp-rxjs-throw-on-condition.function.d.cts +3 -3
  32. package/dist/cjs/shared/utils/cache/index.cjs +1 -1
  33. package/dist/cjs/shared/utils/cache/index.cjs.map +1 -1
  34. package/dist/cjs/shared/utils/cache/index.d.cts +2 -3
  35. package/dist/cjs/shared/utils/index.cjs +1 -1
  36. package/dist/cjs/shared/utils/index.cjs.map +1 -1
  37. package/dist/cjs/shared/utils/index.d.cts +2 -3
  38. package/dist/esm/chunk-C3LKT6AF.js +1 -0
  39. package/dist/esm/chunk-ENM3HAPF.js +1 -0
  40. package/dist/esm/{chunk-7MD4IY4X.js → chunk-GXH2KPSQ.js} +1 -1
  41. package/dist/esm/{chunk-VP72PKJQ.js → chunk-IPMN727M.js} +1 -1
  42. package/dist/esm/chunk-NVYQBLR6.js +1 -0
  43. package/dist/esm/index.d.ts +5 -5
  44. package/dist/esm/index.js +1 -1
  45. package/dist/esm/services/firebase/index.js +1 -1
  46. package/dist/esm/services/firebase/smp-firebase.service.js +1 -1
  47. package/dist/esm/services/http/index.d.ts +3 -4
  48. package/dist/esm/services/http/index.js +1 -1
  49. package/dist/esm/services/http/smp-http.service.d.ts +6 -3
  50. package/dist/esm/services/http/smp-http.service.js +1 -1
  51. package/dist/esm/services/index.d.ts +3 -4
  52. package/dist/esm/services/index.js +1 -1
  53. package/dist/esm/shared/api/index.js +1 -1
  54. package/dist/esm/shared/api/smp-api-common-utils.class.js +1 -1
  55. package/dist/esm/shared/common/index.js +1 -1
  56. package/dist/esm/shared/crypto/index.js +1 -1
  57. package/dist/esm/shared/crypto/smp-secure-code.class.js +1 -1
  58. package/dist/esm/shared/giftcard/smp-giftcard-transaction.class.d.ts +1 -1
  59. package/dist/esm/shared/marketing-cloud/index.d.ts +1 -1
  60. package/dist/esm/shared/marketing-cloud/smp-marketing-cloud-validation-response.interface.d.ts +4 -4
  61. package/dist/esm/shared/rxjs/index.d.ts +1 -0
  62. package/dist/esm/shared/rxjs/index.js +1 -1
  63. package/dist/esm/shared/rxjs/smp-rxjs-in-memory-cache.class.d.ts +3 -3
  64. package/dist/esm/shared/rxjs/smp-rxjs-in-memory-cache.class.js +1 -1
  65. package/dist/esm/shared/rxjs/smp-rxjs-throw-on-condition.function.d.ts +3 -3
  66. package/dist/esm/shared/utils/cache/index.d.ts +2 -3
  67. package/dist/esm/shared/utils/cache/index.js +1 -1
  68. package/dist/esm/shared/utils/index.d.ts +2 -3
  69. package/dist/esm/shared/utils/index.js +1 -1
  70. package/package.json +3 -1
  71. package/dist/cjs/shared/utils/cache/smp-cache-strategy.interface.cjs +0 -2
  72. package/dist/cjs/shared/utils/cache/smp-cache-strategy.interface.cjs.map +0 -1
  73. package/dist/cjs/shared/utils/cache/smp-cache-strategy.interface.d.cts +0 -12
  74. package/dist/esm/chunk-3XWLMKWI.js +0 -1
  75. package/dist/esm/chunk-FE4YONC4.js +0 -0
  76. package/dist/esm/chunk-MD2DPFLF.js +0 -1
  77. package/dist/esm/shared/utils/cache/smp-cache-strategy.interface.d.ts +0 -12
  78. package/dist/esm/shared/utils/cache/smp-cache-strategy.interface.js +0 -1
  79. /package/dist/esm/{chunk-6MJDU4CZ.js → chunk-DGUMFWCQ.js} +0 -0
  80. /package/dist/esm/{chunk-B3OEBKFG.js → chunk-JJLFJN7K.js} +0 -0
@@ -13,11 +13,11 @@ import { OperatorFunction } from 'rxjs';
13
13
  *
14
14
  * @example
15
15
  * import { of } from 'rxjs';
16
- * import { kikRxjsThrowOnCondition } from "./path-to-your-file";
16
+ * import { smpRxjsThrowOnCondition } from "./path-to-your-file";
17
17
  *
18
18
  * const source$ = of(1, 5, -3, 7, 12).pipe(
19
- * kikRxjsThrowOnCondition(value => value >= 0, () => new Error("Value is less than 0")),
20
- * kikRxjsThrowOnCondition(value => value > 12, () => new Error("Value is lower than 12"))
19
+ * smpRxjsThrowOnCondition(value => value >= 0, () => new Error("Value is less than 0")),
20
+ * smpRxjsThrowOnCondition(value => value > 12, () => new Error("Value is lower than 12"))
21
21
  * );
22
22
  *
23
23
  * source$.subscribe({
@@ -1,8 +1,7 @@
1
- export { SmpBrowserCache } from './smp-browser-cache.class.js';
2
- export { SmpCacheStrategy } from './smp-cache-strategy.interface.js';
3
- export { SmpCachedValue } from './smp-cached-value.interface.js';
4
1
  export { SmpAbstractCacheStrategy } from './smp-abstract-cache-strategy.class.js';
5
2
  export { SmpAbstractTtlCacheStrategy } from './smp-abstract-ttl-cache-strategy.class.js';
3
+ export { SmpBrowserCache } from './smp-browser-cache.class.js';
4
+ export { SmpCachedValue } from './smp-cached-value.interface.js';
6
5
  export { SmpInMemoryCache } from './smp-in-memory-cache.class.js';
7
6
  export { smpIsSmpCachedValue } from './smp-is-smp-cached-value.function.js';
8
7
  import 'rxjs';
@@ -1 +1 @@
1
- import"../../../chunk-B3OEBKFG.js";import"../../../chunk-EB55SS67.js";import"../../../chunk-FE4YONC4.js";import{a as e}from"../../../chunk-FAUAQNPB.js";import{a as d}from"../../../chunk-GALYBKBP.js";import{a as c}from"../../../chunk-3AFPQCOH.js";import{a as b}from"../../../chunk-5VCNTUI6.js";import{a}from"../../../chunk-DADFHUII.js";import"../../../chunk-EI7MMDWY.js";export{a as SmpAbstractCacheStrategy,c as SmpAbstractTtlCacheStrategy,d as SmpBrowserCache,e as SmpInMemoryCache,b as smpIsSmpCachedValue};
1
+ import"../../../chunk-DGUMFWCQ.js";import"../../../chunk-EB55SS67.js";import{a as e}from"../../../chunk-FAUAQNPB.js";import{a as d}from"../../../chunk-GALYBKBP.js";import{a as c}from"../../../chunk-3AFPQCOH.js";import{a as b}from"../../../chunk-5VCNTUI6.js";import{a}from"../../../chunk-DADFHUII.js";import"../../../chunk-EI7MMDWY.js";export{a as SmpAbstractCacheStrategy,c as SmpAbstractTtlCacheStrategy,d as SmpBrowserCache,e as SmpInMemoryCache,b as smpIsSmpCachedValue};
@@ -3,11 +3,10 @@ export { SmpFilterException } from './smp-filter-exception.class.js';
3
3
  export { SmpSid } from './smp-sid.class.js';
4
4
  export { smpNoop } from './smp-noop.function.js';
5
5
  export { SmpRegularExpressions } from './smp-regular-expressions.class.js';
6
- export { SmpBrowserCache } from './cache/smp-browser-cache.class.js';
7
- export { SmpCacheStrategy } from './cache/smp-cache-strategy.interface.js';
8
- export { SmpCachedValue } from './cache/smp-cached-value.interface.js';
9
6
  export { SmpAbstractCacheStrategy } from './cache/smp-abstract-cache-strategy.class.js';
10
7
  export { SmpAbstractTtlCacheStrategy } from './cache/smp-abstract-ttl-cache-strategy.class.js';
8
+ export { SmpBrowserCache } from './cache/smp-browser-cache.class.js';
9
+ export { SmpCachedValue } from './cache/smp-cached-value.interface.js';
11
10
  export { SmpInMemoryCache } from './cache/smp-in-memory-cache.class.js';
12
11
  export { smpIsSmpCachedValue } from './cache/smp-is-smp-cached-value.function.js';
13
12
  import '../api/smp-rest-verbs.enum.js';
@@ -1 +1 @@
1
- import"../../chunk-T3P4NVTG.js";import"../../chunk-B3OEBKFG.js";import"../../chunk-EB55SS67.js";import"../../chunk-FE4YONC4.js";import{a as g}from"../../chunk-DTVHTARR.js";import"../../chunk-DOKJQH4K.js";import"../../chunk-R6VG4656.js";import{a as h}from"../../chunk-4UTF5FWK.js";import"../../chunk-NIN4PUZX.js";import{a as j}from"../../chunk-RGLXAD7B.js";import{a as i}from"../../chunk-MMNEY2JK.js";import"../../chunk-4NS456EU.js";import{a as f}from"../../chunk-ZNC4KYAS.js";import{a as e}from"../../chunk-FAUAQNPB.js";import{a as d}from"../../chunk-GALYBKBP.js";import{a as c}from"../../chunk-3AFPQCOH.js";import{a as b}from"../../chunk-5VCNTUI6.js";import{a}from"../../chunk-DADFHUII.js";import"../../chunk-EI7MMDWY.js";export{a as SmpAbstractCacheStrategy,c as SmpAbstractTtlCacheStrategy,d as SmpBrowserCache,g as SmpCommonUtils,h as SmpFilterException,e as SmpInMemoryCache,j as SmpRegularExpressions,i as SmpSid,b as smpIsSmpCachedValue,f as smpNoop};
1
+ import"../../chunk-T3P4NVTG.js";import"../../chunk-DGUMFWCQ.js";import"../../chunk-EB55SS67.js";import{a as g}from"../../chunk-DTVHTARR.js";import"../../chunk-DOKJQH4K.js";import"../../chunk-R6VG4656.js";import{a as h}from"../../chunk-4UTF5FWK.js";import"../../chunk-NIN4PUZX.js";import{a as j}from"../../chunk-RGLXAD7B.js";import{a as i}from"../../chunk-MMNEY2JK.js";import"../../chunk-4NS456EU.js";import{a as f}from"../../chunk-ZNC4KYAS.js";import{a as e}from"../../chunk-FAUAQNPB.js";import{a as d}from"../../chunk-GALYBKBP.js";import{a as c}from"../../chunk-3AFPQCOH.js";import{a as b}from"../../chunk-5VCNTUI6.js";import{a}from"../../chunk-DADFHUII.js";import"../../chunk-EI7MMDWY.js";export{a as SmpAbstractCacheStrategy,c as SmpAbstractTtlCacheStrategy,d as SmpBrowserCache,g as SmpCommonUtils,h as SmpFilterException,e as SmpInMemoryCache,j as SmpRegularExpressions,i as SmpSid,b as smpIsSmpCachedValue,f as smpNoop};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tonysamperi/ts-mapi-core",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "A set of shared utils to be used at BE or FE",
5
5
  "type": "module",
6
6
  "types": "./dist/esm/index.d.ts",
@@ -32,7 +32,9 @@
32
32
  "build:dev": "NODE_ENV=development node build.config",
33
33
  "build": "NODE_ENV=production node build.config",
34
34
  "build:cjs": "webpack --config webpack.cjs.config.cjs --stats verbose",
35
+ "check-exports": "node scripts/check-exports.js",
35
36
  "lint": "eslint && tsc --noEmit",
37
+ "prepublishOnly": "npm run build && npm run check-exports",
36
38
  "release": "npm publish",
37
39
  "release:beta": "npm publish --tag beta",
38
40
  "release:next": "npm publish --tag next",
@@ -1,2 +0,0 @@
1
- "use strict";var t=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var d=(o,e,x,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of b(e))!c.call(o,p)&&p!==x&&t(o,p,{get:()=>e[p],enumerable:!(r=a(e,p))||r.enumerable});return o};var f=o=>d(t({},"__esModule",{value:!0}),o);var g={};module.exports=f(g);
2
- //# sourceMappingURL=smp-cache-strategy.interface.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/shared/utils/cache/smp-cache-strategy.interface.ts"],"sourcesContent":["/**\n * @depcrecated use KikAbstractCacheStrategy instead.\n * This entity will be removed in the next major version.\n */\nexport interface SmpCacheStrategy {\n read<T = unknown>(key: string): T | undefined;\n\n write<T = unknown>(key: string, value: T): void;\n\n remove(key: string): void;\n\n flush(): void;\n}\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["smp_cache_strategy_interface_exports","__toCommonJS"]}
@@ -1,12 +0,0 @@
1
- /**
2
- * @depcrecated use KikAbstractCacheStrategy instead.
3
- * This entity will be removed in the next major version.
4
- */
5
- interface SmpCacheStrategy {
6
- read<T = unknown>(key: string): T | undefined;
7
- write<T = unknown>(key: string, value: T): void;
8
- remove(key: string): void;
9
- flush(): void;
10
- }
11
-
12
- export type { SmpCacheStrategy };
@@ -1 +0,0 @@
1
- import{a as o}from"./chunk-FAUAQNPB.js";import{a as u}from"./chunk-Z7KKB4KI.js";import{a as h}from"./chunk-V2OQU7B5.js";import{a as n}from"./chunk-EI7MMDWY.js";var _=class{static{n(this,"SmpHttpService")}static _cachePrefix="smp_rest_cache_";static _cacheStrategy=typeof sessionStorage<"u"?new h:new o;static _config={cachePrefix:this._cachePrefix,shared:new Map};static _errorClass=u;static _mergeParamsFallbackBaseUrl="https://ts-mapi-core";static $http(e){return this._generateAjax(e)}static async _generateAjax(e){if(e.cacheKey){let t=this._cacheRead(e.cacheKey);return t?Promise.resolve(t):this._generateAjaxBase(e).then(r=>(e.cacheKey&&this._cacheWrite(e.cacheKey,r),r))}return this._generateAjaxBase(e)}static async _generateAjaxBase(e){let t=await this._preprocessRequest(e),r={method:t.method,headers:new Headers({"content-type":"application/json",...t.headers}),body:t.body?JSON.stringify(t.body):null};return t.useCredentials&&(r.credentials="include"),t.url=this.mergeQueryParams(t.url,t.queryParams),fetch(t.url,r).then(a=>this._preprocessResponse(e,a)).then(a=>{if(a.ok){if(a.status===204||a.headers.get("content-length")==="0")return null;switch(t.responseType){case"blob":return a.blob();case"arraybuffer":return a.arrayBuffer();case"text":return a.text();case"json":default:return a.json()}}return a.json().then(s=>{let c=s;try{c=this._errorClass.fromPlain(s)}catch(i){console.debug("http: failed to parse error response into ErrorResponse",i)}return Promise.reject({status:a.status,message:a.statusText,body:c})})})}static cacheFlush(){this._cacheStrategy.flush()}static mergeQueryParams(e,t){let r=e.startsWith("http");if(t){let a=new URL(e,globalThis?.location?.origin||this._mergeParamsFallbackBaseUrl),s=Object.fromEntries(a.searchParams.entries());a.search=new URLSearchParams({...s,...Object.fromEntries(Object.entries(t).map(([c,i])=>[c,`${i}`]))}).toString(),e=r?a.href:a.pathname+a.search}return e}static _cacheKey(e){return`${this._config.cachePrefix}${e}`}static _cachePop(e){let t=this._cacheRead(e);return this._cacheRemove(e),t}static _cacheRead(e){return this._cacheStrategy.read(this._cacheKey(e))}static _cacheRemove(e){this._cacheStrategy.remove(this._cacheKey(e))}static _cacheWrite(e,t){this._cacheStrategy.write(this._cacheKey(e),t)}static async _preprocessRequest(e){return e}static async _preprocessResponse(e,t){return t}};export{_ as a};
File without changes
@@ -1 +0,0 @@
1
- import{a as s}from"./chunk-RCI7NEJO.js";import{a as i}from"./chunk-EI7MMDWY.js";var o=class{static{i(this,"SmpApiCommonUtils")}static _javascriptVariablePattern="[a-zA-Z_$][a-zA-Z_$0-9]*";static _logger=new s;static _pathParamRegex=new RegExp(`\\{(${this._javascriptVariablePattern})\\}`,"g");static credentialsToBasicAuth(e,t){return`Basic ${Buffer.from(`${e}:${t}`).toString("base64")}`}static fromBearer(e=""){return e.split(" ")[1]}static getCountryFromReferer(e){return this.getLocaleFromReferer(e)?.split("-")[0]?.toUpperCase()}static getLanguageFromReferer(e){return this.getLocaleFromReferer(e)?.split("-")[1]}static getLocaleFromReferer(e){return e?.match(/\/([A-Z]{2}-[A-Z]{2})\//i)?.[1]}static interpolateParams(e,t){try{return e.replace(this._pathParamRegex,(r,c)=>{let a=t[c];return a!==void 0?encodeURIComponent(a):r})}catch(r){this._logger.warn("KikApiCommonUtils: couldn't interpolate params",r)}return e}};export{o as a};
@@ -1,12 +0,0 @@
1
- /**
2
- * @depcrecated use KikAbstractCacheStrategy instead.
3
- * This entity will be removed in the next major version.
4
- */
5
- interface SmpCacheStrategy {
6
- read<T = unknown>(key: string): T | undefined;
7
- write<T = unknown>(key: string, value: T): void;
8
- remove(key: string): void;
9
- flush(): void;
10
- }
11
-
12
- export type { SmpCacheStrategy };
@@ -1 +0,0 @@
1
- import"../../../chunk-FE4YONC4.js";