@tonysamperi/ts-mapi-core 1.6.0 → 1.7.0

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 (105) hide show
  1. package/changelog.md +13 -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 +17 -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-session-storage-cache.class.cjs.map +1 -1
  9. package/dist/cjs/services/http/smp-http.service.cjs +1 -1
  10. package/dist/cjs/services/http/smp-http.service.cjs.map +1 -1
  11. package/dist/cjs/services/http/smp-http.service.d.cts +6 -3
  12. package/dist/cjs/services/index.cjs +1 -1
  13. package/dist/cjs/services/index.cjs.map +1 -1
  14. package/dist/cjs/services/index.d.cts +3 -4
  15. package/dist/cjs/shared/api/index.cjs +1 -1
  16. package/dist/cjs/shared/api/index.cjs.map +1 -1
  17. package/dist/cjs/shared/api/smp-api-common-utils.class.cjs +1 -1
  18. package/dist/cjs/shared/api/smp-api-common-utils.class.cjs.map +1 -1
  19. package/dist/cjs/shared/giftcard/index.cjs +1 -1
  20. package/dist/cjs/shared/giftcard/index.cjs.map +1 -1
  21. package/dist/cjs/shared/giftcard/smp-giftcard-transaction.class.cjs +1 -1
  22. package/dist/cjs/shared/giftcard/smp-giftcard-transaction.class.cjs.map +1 -1
  23. package/dist/cjs/shared/giftcard/smp-giftcard-transaction.class.d.cts +1 -1
  24. package/dist/cjs/shared/marketing-cloud/index.d.cts +1 -1
  25. package/dist/cjs/shared/marketing-cloud/smp-marketing-cloud-validation-response.interface.cjs.map +1 -1
  26. package/dist/cjs/shared/marketing-cloud/smp-marketing-cloud-validation-response.interface.d.cts +4 -4
  27. package/dist/cjs/shared/rxjs/index.cjs +1 -1
  28. package/dist/cjs/shared/rxjs/index.cjs.map +1 -1
  29. package/dist/cjs/shared/rxjs/index.d.cts +3 -0
  30. package/dist/cjs/shared/rxjs/smp-abstract-rxjs-ttl-cache-strategy.class.cjs.map +1 -1
  31. package/dist/cjs/shared/rxjs/smp-rxjs-in-memory-cache.class.cjs +1 -1
  32. package/dist/cjs/shared/rxjs/smp-rxjs-in-memory-cache.class.cjs.map +1 -1
  33. package/dist/cjs/shared/rxjs/smp-rxjs-in-memory-cache.class.d.cts +3 -3
  34. package/dist/cjs/shared/rxjs/smp-rxjs-queue.function.cjs +2 -0
  35. package/dist/cjs/shared/rxjs/smp-rxjs-queue.function.cjs.map +1 -0
  36. package/dist/cjs/shared/rxjs/smp-rxjs-queue.function.d.cts +23 -0
  37. package/dist/cjs/shared/rxjs/smp-rxjs-sequence.function.cjs +2 -0
  38. package/dist/cjs/shared/rxjs/smp-rxjs-sequence.function.cjs.map +1 -0
  39. package/dist/cjs/shared/rxjs/smp-rxjs-sequence.function.d.cts +11 -0
  40. package/dist/cjs/shared/rxjs/smp-rxjs-throw-on-condition.function.cjs.map +1 -1
  41. package/dist/cjs/shared/rxjs/smp-rxjs-throw-on-condition.function.d.cts +3 -3
  42. package/dist/cjs/shared/utils/cache/index.cjs +1 -1
  43. package/dist/cjs/shared/utils/cache/index.cjs.map +1 -1
  44. package/dist/cjs/shared/utils/cache/index.d.cts +2 -3
  45. package/dist/cjs/shared/utils/cache/smp-abstract-ttl-cache-strategy.class.cjs.map +1 -1
  46. package/dist/cjs/shared/utils/cache/smp-browser-cache.class.cjs.map +1 -1
  47. package/dist/cjs/shared/utils/cache/smp-in-memory-cache.class.cjs.map +1 -1
  48. package/dist/cjs/shared/utils/cache/smp-is-smp-cached-value.function.cjs.map +1 -1
  49. package/dist/cjs/shared/utils/index.cjs +1 -1
  50. package/dist/cjs/shared/utils/index.cjs.map +1 -1
  51. package/dist/cjs/shared/utils/index.d.cts +4 -3
  52. package/dist/cjs/shared/utils/smp-apply-mixin.function.cjs +2 -0
  53. package/dist/cjs/shared/utils/smp-apply-mixin.function.cjs.map +1 -0
  54. package/dist/cjs/shared/utils/smp-apply-mixin.function.d.cts +5 -0
  55. package/dist/cjs/shared/utils/smp-sid.class.cjs.map +1 -1
  56. package/dist/esm/chunk-3TSDCOVH.js +1 -0
  57. package/dist/esm/chunk-C3LKT6AF.js +1 -0
  58. package/dist/esm/chunk-ENM3HAPF.js +1 -0
  59. package/dist/esm/chunk-JXXO4LSO.js +1 -0
  60. package/dist/esm/chunk-NVYQBLR6.js +1 -0
  61. package/dist/esm/chunk-Z3K5PNSB.js +1 -0
  62. package/dist/esm/chunk-ZKODHJSY.js +1 -0
  63. package/dist/esm/index.d.ts +8 -5
  64. package/dist/esm/index.js +1 -1
  65. package/dist/esm/services/http/index.d.ts +3 -4
  66. package/dist/esm/services/http/index.js +1 -1
  67. package/dist/esm/services/http/smp-http.service.d.ts +6 -3
  68. package/dist/esm/services/http/smp-http.service.js +1 -1
  69. package/dist/esm/services/index.d.ts +3 -4
  70. package/dist/esm/services/index.js +1 -1
  71. package/dist/esm/shared/api/index.js +1 -1
  72. package/dist/esm/shared/api/smp-api-common-utils.class.js +1 -1
  73. package/dist/esm/shared/giftcard/index.js +1 -1
  74. package/dist/esm/shared/giftcard/smp-giftcard-transaction.class.d.ts +1 -1
  75. package/dist/esm/shared/giftcard/smp-giftcard-transaction.class.js +1 -1
  76. package/dist/esm/shared/marketing-cloud/index.d.ts +1 -1
  77. package/dist/esm/shared/marketing-cloud/smp-marketing-cloud-validation-response.interface.d.ts +4 -4
  78. package/dist/esm/shared/rxjs/index.d.ts +3 -0
  79. package/dist/esm/shared/rxjs/index.js +1 -1
  80. package/dist/esm/shared/rxjs/smp-rxjs-in-memory-cache.class.d.ts +3 -3
  81. package/dist/esm/shared/rxjs/smp-rxjs-in-memory-cache.class.js +1 -1
  82. package/dist/esm/shared/rxjs/smp-rxjs-queue.function.d.ts +23 -0
  83. package/dist/esm/shared/rxjs/smp-rxjs-queue.function.js +1 -0
  84. package/dist/esm/shared/rxjs/smp-rxjs-sequence.function.d.ts +11 -0
  85. package/dist/esm/shared/rxjs/smp-rxjs-sequence.function.js +1 -0
  86. package/dist/esm/shared/rxjs/smp-rxjs-throw-on-condition.function.d.ts +3 -3
  87. package/dist/esm/shared/utils/cache/index.d.ts +2 -3
  88. package/dist/esm/shared/utils/cache/index.js +1 -1
  89. package/dist/esm/shared/utils/index.d.ts +4 -3
  90. package/dist/esm/shared/utils/index.js +1 -1
  91. package/dist/esm/shared/utils/smp-apply-mixin.function.d.ts +5 -0
  92. package/dist/esm/shared/utils/smp-apply-mixin.function.js +1 -0
  93. package/package.json +4 -1
  94. package/dist/cjs/shared/utils/cache/smp-cache-strategy.interface.cjs +0 -2
  95. package/dist/cjs/shared/utils/cache/smp-cache-strategy.interface.cjs.map +0 -1
  96. package/dist/cjs/shared/utils/cache/smp-cache-strategy.interface.d.cts +0 -12
  97. package/dist/esm/chunk-3XWLMKWI.js +0 -1
  98. package/dist/esm/chunk-MD2DPFLF.js +0 -1
  99. package/dist/esm/chunk-T3P4NVTG.js +0 -0
  100. package/dist/esm/chunk-VPL2IMUA.js +0 -1
  101. package/dist/esm/shared/utils/cache/smp-cache-strategy.interface.d.ts +0 -12
  102. package/dist/esm/shared/utils/cache/smp-cache-strategy.interface.js +0 -1
  103. /package/dist/esm/{chunk-6MJDU4CZ.js → chunk-DGUMFWCQ.js} +0 -0
  104. /package/dist/esm/{chunk-B3OEBKFG.js → chunk-PKEW426R.js} +0 -0
  105. /package/dist/esm/{chunk-FE4YONC4.js → chunk-SZM4WHQJ.js} +0 -0
@@ -7,7 +7,7 @@ import { SmpGiftcardTransactionConfig } from './smp-giftcard-transaction-config.
7
7
  import { SmpGiftcardTransactionHashStrategies } from './smp-giftcard-transaction-hash-strategies.enum.cjs';
8
8
 
9
9
  /**
10
- * Base implementation that you can extend, even customizing the static parts like #KikGiftcardTransaction._AES_ENCODER.
10
+ * Base implementation that you can extend, even customizing the static parts like #SmpGiftcardTransaction._AES_ENCODER.
11
11
  * You can create your own instance of KikAesCrypt to override it.
12
12
  */
13
13
  declare class SmpGiftcardTransaction implements SmpGiftcardTransactionPlain {
@@ -1,2 +1,2 @@
1
- export { KikMarketingCloudValidationResponse, KikMarketingCloudValidationResponseKo, KikMarketingCloudValidationResponseOk } from './smp-marketing-cloud-validation-response.interface.cjs';
1
+ export { SmpMarketingCloudValidationResponse, SmpMarketingCloudValidationResponseKo, SmpMarketingCloudValidationResponseOk } from './smp-marketing-cloud-validation-response.interface.cjs';
2
2
  export { SmpMarketingCloudValidators } from './smp-marketing-cloud-validators.enum.cjs';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/shared/marketing-cloud/smp-marketing-cloud-validation-response.interface.ts"],"sourcesContent":["import { SmpMarketingCloudValidators } from \"./smp-marketing-cloud-validators.enum.js\";\n\nexport interface KikMarketingCloudValidationResponseOk {\n email: string;\n valid: true;\n}\n\nexport interface KikMarketingCloudValidationResponseKo {\n email: string;\n valid: boolean;\n failedValidation: SmpMarketingCloudValidators;\n}\n\nexport type KikMarketingCloudValidationResponse = KikMarketingCloudValidationResponseOk | KikMarketingCloudValidationResponseKo;\n"],"mappings":"+WAaA,IAAAA,EAAA,kBAAAC,EAAAD","names":["smp_marketing_cloud_validation_response_interface_exports","__toCommonJS"]}
1
+ {"version":3,"sources":["../../../../src/shared/marketing-cloud/smp-marketing-cloud-validation-response.interface.ts"],"sourcesContent":["import { SmpMarketingCloudValidators } from \"./smp-marketing-cloud-validators.enum.js\";\n\nexport interface SmpMarketingCloudValidationResponseOk {\n email: string;\n valid: true;\n}\n\nexport interface SmpMarketingCloudValidationResponseKo {\n email: string;\n valid: boolean;\n failedValidation: SmpMarketingCloudValidators;\n}\n\nexport type SmpMarketingCloudValidationResponse = SmpMarketingCloudValidationResponseOk | SmpMarketingCloudValidationResponseKo;\n"],"mappings":"+WAaA,IAAAA,EAAA,kBAAAC,EAAAD","names":["smp_marketing_cloud_validation_response_interface_exports","__toCommonJS"]}
@@ -1,14 +1,14 @@
1
1
  import { SmpMarketingCloudValidators } from './smp-marketing-cloud-validators.enum.cjs';
2
2
 
3
- interface KikMarketingCloudValidationResponseOk {
3
+ interface SmpMarketingCloudValidationResponseOk {
4
4
  email: string;
5
5
  valid: true;
6
6
  }
7
- interface KikMarketingCloudValidationResponseKo {
7
+ interface SmpMarketingCloudValidationResponseKo {
8
8
  email: string;
9
9
  valid: boolean;
10
10
  failedValidation: SmpMarketingCloudValidators;
11
11
  }
12
- type KikMarketingCloudValidationResponse = KikMarketingCloudValidationResponseOk | KikMarketingCloudValidationResponseKo;
12
+ type SmpMarketingCloudValidationResponse = SmpMarketingCloudValidationResponseOk | SmpMarketingCloudValidationResponseKo;
13
13
 
14
- export type { KikMarketingCloudValidationResponse, KikMarketingCloudValidationResponseKo, KikMarketingCloudValidationResponseOk };
14
+ export type { SmpMarketingCloudValidationResponse, SmpMarketingCloudValidationResponseKo, SmpMarketingCloudValidationResponseOk };
@@ -1,2 +1,2 @@
1
- "use strict";var i=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var n=(r,t)=>i(r,"name",{value:t,configurable:!0});var E=(r,t)=>{for(var o in t)i(r,o,{get:t[o],enumerable:!0})},_=(r,t,o,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of j(t))!C.call(r,p)&&p!==o&&i(r,p,{get:()=>t[p],enumerable:!(e=d(t,p))||e.enumerable});return r};var I=r=>_(i({},"__esModule",{value:!0}),r);var b={};E(b,{SmpAbstractRxjsTtlCacheStrategy:()=>m,smpRxjsCatchOnly:()=>w,smpRxjsThrowIfEmpty:()=>u,smpRxjsThrowOnCondition:()=>R});module.exports=I(b);var x=require("rxjs"),a=require("ts-luxon");var s=class{static{n(this,"SmpAbstractCacheStrategy")}};function h(r){return typeof r=="object"&&r!==null&&"value"in r&&"expiry"in r&&typeof r.expiry=="number"}n(h,"smpIsSmpCachedValue");var m=class extends s{static{n(this,"SmpAbstractRxjsTtlCacheStrategy")}flush(){return this._flushRaw()}read(t){return this._readRaw(t).pipe((0,x.map)(o=>{if(this._isSmpCachedValue(o)){if(o.expiry>=a.DateTime.now().ts)return o.value;this._removeRaw(t).subscribe();return}return o}))}remove(t){return this._removeRaw(t)}write(t,o,e){if(isNaN(+e)||+e<=0)return this._writeRaw(t,o,e);let p=a.DateTime.now().ts+e*1e3,l={value:o,expiry:p};return this._writeRaw(t,l,e)}_isSmpCachedValue(t){return h(t)}};var f=require("rxjs");function w(r,t){return o=>o.pipe((0,f.catchError)(e=>(typeof r==typeof isNaN?O(r)?S(e,r):r(e):!1)?t(e):(0,f.throwError)(()=>e)))}n(w,"smpRxjsCatchOnly");function O(r){try{return Reflect.construct(String,[],r),!0}catch{return!1}}n(O,"isConstructor");function S(r,t){return typeof r=="object"&&r!==null&&r.constructor===t}n(S,"isExactInstance");var y=require("rxjs");function u(r=T){return t=>t.pipe((0,y.map)(o=>{if(~N.indexOf(JSON.stringify(o)))throw r(o);return o}))}n(u,"smpRxjsThrowIfEmpty");var N=[void 0,null,!1,0,"","0",[],{}].map(r=>JSON.stringify(r)),T=n(()=>new Error,"defaultErrorFactory");var c=require("rxjs");function R(r,t){return o=>o.pipe((0,c.filter)(e=>!r(e)),(0,c.defaultIfEmpty)(!1),u(t))}n(R,"smpRxjsThrowOnCondition");0&&(module.exports={SmpAbstractRxjsTtlCacheStrategy,smpRxjsCatchOnly,smpRxjsThrowIfEmpty,smpRxjsThrowOnCondition});
1
+ "use strict";var m=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var o=(r,t)=>m(r,"name",{value:t,configurable:!0});var T=(r,t)=>{for(var e in t)m(r,e,{get:t[e],enumerable:!0})},N=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of b(t))!I.call(r,s)&&s!==e&&m(r,s,{get:()=>t[s],enumerable:!(n=O(t,s))||n.enumerable});return r};var v=r=>N(m({},"__esModule",{value:!0}),r);var J={};T(J,{SmpAbstractRxjsTtlCacheStrategy:()=>u,SmpRxjsInMemoryCache:()=>h,smpRxjsCatchOnly:()=>_,smpRxjsQueue:()=>S,smpRxjsSequence:()=>j,smpRxjsThrowIfEmpty:()=>x,smpRxjsThrowOnCondition:()=>C});module.exports=v(J);var y=require("rxjs"),l=require("ts-luxon");var a=class{static{o(this,"SmpAbstractCacheStrategy")}};function R(r){return typeof r=="object"&&r!==null&&"value"in r&&"expiry"in r&&typeof r.expiry=="number"}o(R,"smpIsSmpCachedValue");var u=class extends a{static{o(this,"SmpAbstractRxjsTtlCacheStrategy")}flush(){return this._flushRaw()}read(t){return this._readRaw(t).pipe((0,y.map)(e=>{if(this._isSmpCachedValue(e)){if(e.expiry>=l.DateTime.now().ts)return e.value;this._removeRaw(t).subscribe();return}return e}))}remove(t){return this._removeRaw(t)}write(t,e,n){if(isNaN(+n)||+n<=0)return this._writeRaw(t,e,n);let s=l.DateTime.now().ts+n*1e3,E={value:e,expiry:s};return this._writeRaw(t,E,n)}_isSmpCachedValue(t){return R(t)}};var c=require("rxjs");function _(r,t){return e=>e.pipe((0,c.catchError)(n=>(typeof r==typeof isNaN?A(r)?q(n,r):r(n):!1)?t(n):(0,c.throwError)(()=>n)))}o(_,"smpRxjsCatchOnly");function A(r){try{return Reflect.construct(String,[],r),!0}catch{return!1}}o(A,"isConstructor");function q(r,t){return typeof r=="object"&&r!==null&&r.constructor===t}o(q,"isExactInstance");var p=require("rxjs");var h=class extends u{static{o(this,"SmpRxjsInMemoryCache")}static _storage=new Map;get _staticSelf(){return this.constructor}_flushRaw(){return(0,p.defer)(()=>(this._staticSelf._storage.clear(),(0,p.of)(void 0)))}_readRaw(t){return(0,p.defer)(()=>(0,p.of)(this._staticSelf._storage.get(t)))}_removeRaw(t){return(0,p.defer)(()=>(this._staticSelf._storage.delete(t),(0,p.of)(void 0)))}_writeRaw(t,e){return(0,p.defer)(()=>(this._staticSelf._storage.set(t,e),(0,p.of)(void 0)))}};var i=require("rxjs");function d(r){let t=[],e=o(n=>n>=r.length?(0,i.of)(t):(0,i.defer)(()=>r[n]()).pipe((0,i.switchMap)(s=>(t.push(s),e(n+1)))),"runStep");return e(0)}o(d,"smpRxjsSequence");function S(r){return Array.isArray(r)?d(r).pipe((0,i.map)(t=>t)):d(Object.values(r)).pipe((0,i.map)(t=>Object.keys(r).reduce((e,n,s)=>(e[n]=t[s],e),{})))}o(S,"smpRxjsQueue");var f=require("rxjs");function j(r){return(0,f.from)(r).pipe((0,f.concatMap)(t=>t()),(0,f.toArray)())}o(j,"smpRxjsSequence");var g=require("rxjs");function x(r=V){return t=>t.pipe((0,g.map)(e=>{if(~M.indexOf(JSON.stringify(e)))throw r(e);return e}))}o(x,"smpRxjsThrowIfEmpty");var M=[void 0,null,!1,0,"","0",[],{}].map(r=>JSON.stringify(r)),V=o(()=>new Error,"defaultErrorFactory");var w=require("rxjs");function C(r,t){return e=>e.pipe((0,w.filter)(n=>!r(n)),(0,w.defaultIfEmpty)(!1),x(t))}o(C,"smpRxjsThrowOnCondition");0&&(module.exports={SmpAbstractRxjsTtlCacheStrategy,SmpRxjsInMemoryCache,smpRxjsCatchOnly,smpRxjsQueue,smpRxjsSequence,smpRxjsThrowIfEmpty,smpRxjsThrowOnCondition});
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/shared/rxjs/index.ts","../../../../src/shared/rxjs/smp-abstract-rxjs-ttl-cache-strategy.class.ts","../../../../src/shared/utils/cache/smp-abstract-cache-strategy.class.ts","../../../../src/shared/utils/cache/smp-is-smp-cached-value.function.ts","../../../../src/shared/rxjs/smp-rxjs-catch-only.function.ts","../../../../src/shared/rxjs/smp-rxjs-throw-if-empty.function.ts","../../../../src/shared/rxjs/smp-rxjs-throw-on-condition.function.ts"],"sourcesContent":["export {SmpAbstractRxjsTtlCacheStrategy} from \"./smp-abstract-rxjs-ttl-cache-strategy.class.js\"\nexport {smpRxjsCatchOnly} from \"./smp-rxjs-catch-only.function.js\";\nexport {smpRxjsThrowIfEmpty} from \"./smp-rxjs-throw-if-empty.function.js\";\nexport {smpRxjsThrowOnCondition} from \"./smp-rxjs-throw-on-condition.function.js\";\n","import {map, Observable} from \"rxjs\";\nimport {DateTime} from \"ts-luxon\";\n//\nimport {SmpAbstractCacheStrategy} from \"../utils/cache/smp-abstract-cache-strategy.class.js\";\nimport {SmpCachedValue} from \"../utils/cache/smp-cached-value.interface.js\";\nimport {smpIsSmpCachedValue} from \"../utils/cache/smp-is-smp-cached-value.function.js\";\n\nexport abstract class SmpAbstractRxjsTtlCacheStrategy extends SmpAbstractCacheStrategy {\n\n protected abstract _flushRaw(): Observable<void>;\n\n protected abstract _readRaw(key: string): Observable<unknown | undefined>;\n\n protected abstract _removeRaw(key: string): Observable<void>;\n\n protected abstract _writeRaw(key: string, value: unknown, ttl?: number): Observable<void>;\n\n flush(): Observable<void> {\n return this._flushRaw();\n }\n\n read<T = unknown>(key: string): Observable<T | undefined> {\n return this._readRaw(key).pipe(\n map((storedValue) => {\n if (this._isSmpCachedValue<T>(storedValue)) {\n if (storedValue.expiry >= DateTime.now().ts) {\n return storedValue.value as T;\n }\n this._removeRaw(key).subscribe(); // fire-and-forget\n\n return void 0;\n }\n\n return storedValue as T | undefined;\n })\n );\n }\n\n remove(key: string) {\n return this._removeRaw(key);\n }\n\n write<T = unknown>(key: string, value: T, ttl?: number): Observable<void> {\n if (isNaN(+ttl!) || +ttl! <= 0) {\n return this._writeRaw(key, value, ttl);\n }\n\n const expiry = DateTime.now().ts + ttl! * 1000;\n const wrappedValue: SmpCachedValue<T> = {\n value,\n expiry\n };\n\n return this._writeRaw(key, wrappedValue, ttl);\n }\n\n protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return smpIsSmpCachedValue(value);\n }\n}\n","import {Observable} from \"rxjs\";\n\nexport abstract class SmpAbstractCacheStrategy {\n abstract read<T = unknown>(key: string): T | undefined | Observable<T | undefined>;\n\n abstract write<T = unknown>(key: string, value: T, ttl?: number): void | Observable<void>;\n\n abstract remove(key: string): void | Observable<void>;\n\n abstract flush(): void | Observable<void>;\n}\n","import {SmpCachedValue} from \"./smp-cached-value.interface\";\n\n/**\n * Tells you if a value is a SmpCachedValue\n * @param value\n */\nexport function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n \"expiry\" in value &&\n typeof (value as any).expiry === \"number\"\n );\n}\n","import {Observable, OperatorFunction, catchError, throwError} from \"rxjs\";\nimport type {ObservableInput, ObservedValueOf} from \"rxjs\";\n\nexport function smpRxjsCatchOnly<T, E extends Error, O extends ObservableInput<any>>(\n errorFilter: (new (...args: any[]) => E) | ((err: unknown) => boolean),\n selector: (err: E) => O\n): OperatorFunction<T, T | ObservedValueOf<O>> {\n return (source: Observable<T>) =>\n source.pipe(\n catchError((err: unknown) => {\n const matches = typeof errorFilter === typeof isNaN\n ? isConstructor(errorFilter)\n ? isExactInstance(err, errorFilter as new (...args: any[]) => E)\n : (errorFilter as (err: unknown) => boolean)(err)\n : false;\n\n if (matches) {\n return selector(err as E);\n }\n return throwError(() => err);\n })\n );\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nfunction isConstructor(fn: unknown): fn is Function {\n try {\n // try creating a dummy instance\n Reflect.construct(String, [], fn as any);\n return true;\n }\n catch {\n return false;\n }\n}\n\n// Ensures that the error is an *exact* instance of the given error constructor, not a subclass\nfunction isExactInstance<E extends Error>(err: unknown, ctor: new (...args: any[]) => E): boolean {\n return (\n typeof err === \"object\" &&\n err !== null &&\n err.constructor === ctor\n );\n}\n","import {map, Observable, OperatorFunction} from \"rxjs\";\n\n/**\n * If the source observable completes emitting an empty value (empty array or object will be considered empty), it will emit\n * an error. The error will be created at that time by the optional\n * `errorFactory` argument, otherwise, the error will be {@link Error}.\n *\n * ## Example\n *\n * Throw an error if the query didn't match anything\n *\n * ```ts\n * import { of, takeUntil, timer, throwIfEmpty } from 'rxjs';\n *\n * const query$ = of([]);\n *\n * query$.pipe(\n * smpRxjsThrowIfEmpty(() => new Error('The query had no results'))\n * )\n * .subscribe({\n * next() {\n * console.log(\"The query had results\");\n * },\n * error(err) {\n * console.error(err.message);\n * }\n * });\n * ```\n *\n * @param errorFactory A factory function called to produce the\n * error to be thrown when the source observable completes without emitting a\n * value.\n * @return A function that returns an Observable that throws an error if the\n * source Observable completed without emitting.\n */\nexport function smpRxjsThrowIfEmpty<T>(errorFactory: (value: T) => any = defaultErrorFactory): OperatorFunction<T, T> {\n return (source: Observable<T>) => source.pipe(\n map(v => {\n if (~emptyValues.indexOf(JSON.stringify(v))) {\n throw errorFactory(v);\n }\n\n return v;\n })\n );\n}\n\nconst emptyValues = [void 0, null, false, 0, \"\", \"0\", [], {}].map((v) =>\n JSON.stringify(v)\n);\n\nconst defaultErrorFactory = (): Error => new Error();\n","import {defaultIfEmpty, filter, Observable, OperatorFunction} from \"rxjs\";\n//\nimport {smpRxjsThrowIfEmpty} from \"./smp-rxjs-throw-if-empty.function.js\";\n\n/**\n * Custom RxJS operator that filters the source observable based on a condition\n * and throws an error if the resulting observable is empty.\n *\n * @template T The type of items emitted by the source observable.\n * @param {function(T): boolean} condition - A function that takes a value from the source observable and returns a boolean.\n * If the function returns `true`, the value will be emitted; otherwise, it will be filtered out.\n * @param {function(): Error} [errorFactory] - An optional function that returns an error to be thrown if the resulting observable is empty.\n * If not provided, a default error will be thrown.\n * @returns {OperatorFunction<T, T>} An operator function that can be used in the RxJS pipeline.\n *\n * @example\n * import { of } from 'rxjs';\n * import { kikRxjsThrowOnCondition } from \"./path-to-your-file\";\n *\n * const source$ = of(1, 5, -3, 7, 12).pipe(\n * kikRxjsThrowOnCondition(value => value >= 0, () => new Error(\"Value is less than 0\")),\n * kikRxjsThrowOnCondition(value => value > 12, () => new Error(\"Value is lower than 12\"))\n * );\n *\n * source$.subscribe({\n * next: value => console.log(\"Value:\", value),\n * error: err => console.error(\"Error:\", err)\n * });\n */\nexport function smpRxjsThrowOnCondition<T>(\n condition: (value: T) => boolean,\n errorFactory?: () => any\n): OperatorFunction<T, T> {\n return (source: Observable<T>) =>\n source.pipe(\n filter((v: T) => !condition(v)), // Invert the condition because if I need to throw on that condition we should filter all that don't match\n defaultIfEmpty(false as unknown as T), // We nuke type errors, cause when falsy kikRxjsThrowIfEmpty will throw\n smpRxjsThrowIfEmpty(errorFactory)\n );\n}\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,EAAA,qBAAAC,EAAA,wBAAAC,EAAA,4BAAAC,IAAA,eAAAC,EAAAN,GCAA,IAAAO,EAA8B,gBAC9BC,EAAuB,oBCChB,IAAeC,EAAf,KAAeA,CAAtB,MAAsBA,CAAAA,EAAAA,iCAQtB,ECJO,SAASC,EAAuBC,EAAc,CACjD,OACI,OAAOA,GAAU,UACjBA,IAAU,MACV,UAAWA,GACX,WAAYA,GACZ,OAAQA,EAAcC,QAAW,QAEzC,CARgBF,EAAAA,EAAAA,uBFCT,IAAeG,EAAf,cAAuDC,CAAAA,CAP9D,MAO8DA,CAAAA,EAAAA,wCAU1DC,OAA0B,CACtB,OAAO,KAAKC,UAAS,CACzB,CAEAC,KAAkBC,EAAwC,CACtD,OAAO,KAAKC,SAASD,CAAAA,EAAKE,QACtBC,OAAKC,GAAAA,CACD,GAAI,KAAKC,kBAAqBD,CAAAA,EAAc,CACxC,GAAIA,EAAYE,QAAUC,WAASC,IAAG,EAAGC,GACrC,OAAOL,EAAYM,MAEvB,KAAKC,WAAWX,CAAAA,EAAKY,UAAS,EAE9B,MACJ,CAEA,OAAOR,CACX,CAAA,CAAA,CAER,CAEAS,OAAOb,EAAa,CAChB,OAAO,KAAKW,WAAWX,CAAAA,CAC3B,CAEAc,MAAmBd,EAAaU,EAAUK,EAAgC,CACtE,GAAIC,MAAM,CAACD,CAAAA,GAAS,CAACA,GAAQ,EACzB,OAA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AAAA,EAGbJ,EAAsBS,EAAA,IAAa,IAAIC,MAAjB,uBCnD5B,IAAAC,EAAmE,gBA6B5D,SAASC,EACZC,EACAC,EAAwB,CAExB,OAAQC,GACJA,EAAOC,QACHC,UAAQC,GAAS,CAACL,EAAUK,CAAAA,CAAAA,KAC5BC,kBAAe,EAAA,EACfC,EAAoBN,CAAAA,CAAAA,CAEhC,CAVgBF,EAAAA,EAAAA","names":["rxjs_exports","__export","SmpAbstractRxjsTtlCacheStrategy","smpRxjsCatchOnly","smpRxjsThrowIfEmpty","smpRxjsThrowOnCondition","__toCommonJS","import_rxjs","import_ts_luxon","SmpAbstractCacheStrategy","smpIsSmpCachedValue","value","expiry","SmpAbstractRxjsTtlCacheStrategy","SmpAbstractCacheStrategy","flush","_flushRaw","read","key","_readRaw","pipe","map","storedValue","_isSmpCachedValue","expiry","DateTime","now","ts","value","_removeRaw","subscribe","remove","write","ttl","isNaN","_writeRaw","wrappedValue","smpIsSmpCachedValue","import_rxjs","smpRxjsCatchOnly","errorFilter","selector","source","pipe","catchError","err","isNaN","isConstructor","isExactInstance","throwError","fn","Reflect","construct","String","ctor","constructor","import_rxjs","smpRxjsThrowIfEmpty","errorFactory","defaultErrorFactory","source","pipe","map","v","emptyValues","indexOf","JSON","stringify","__name","Error","import_rxjs","smpRxjsThrowOnCondition","condition","errorFactory","source","pipe","filter","v","defaultIfEmpty","smpRxjsThrowIfEmpty"]}
1
+ {"version":3,"sources":["../../../../src/shared/rxjs/index.ts","../../../../src/shared/rxjs/smp-abstract-rxjs-ttl-cache-strategy.class.ts","../../../../src/shared/utils/cache/smp-abstract-cache-strategy.class.ts","../../../../src/shared/utils/cache/smp-is-smp-cached-value.function.ts","../../../../src/shared/rxjs/smp-rxjs-catch-only.function.ts","../../../../src/shared/rxjs/smp-rxjs-in-memory-cache.class.ts","../../../../src/shared/rxjs/smp-rxjs-queue.function.ts","../../../../src/shared/rxjs/smp-rxjs-sequence.function.ts","../../../../src/shared/rxjs/smp-rxjs-throw-if-empty.function.ts","../../../../src/shared/rxjs/smp-rxjs-throw-on-condition.function.ts"],"sourcesContent":["export {SmpAbstractRxjsTtlCacheStrategy} from \"./smp-abstract-rxjs-ttl-cache-strategy.class.js\"\nexport {smpRxjsCatchOnly} from \"./smp-rxjs-catch-only.function.js\";\nexport {SmpRxjsInMemoryCache} from \"./smp-rxjs-in-memory-cache.class.js\"\nexport {smpRxjsQueue} from \"./smp-rxjs-queue.function.js\"\nexport {smpRxjsSequence} from \"./smp-rxjs-sequence.function.js\"\nexport {smpRxjsThrowIfEmpty} from \"./smp-rxjs-throw-if-empty.function.js\";\nexport {smpRxjsThrowOnCondition} from \"./smp-rxjs-throw-on-condition.function.js\";\n","import {map, Observable} from \"rxjs\";\nimport {DateTime} from \"ts-luxon\";\n//\nimport {SmpAbstractCacheStrategy} from \"../utils/cache/smp-abstract-cache-strategy.class.js\";\nimport {SmpCachedValue} from \"../utils/cache/smp-cached-value.interface.js\";\nimport {smpIsSmpCachedValue} from \"../utils/cache/smp-is-smp-cached-value.function.js\";\n\nexport abstract class SmpAbstractRxjsTtlCacheStrategy extends SmpAbstractCacheStrategy {\n\n protected abstract _flushRaw(): Observable<void>;\n\n protected abstract _readRaw(key: string): Observable<unknown | undefined>;\n\n protected abstract _removeRaw(key: string): Observable<void>;\n\n protected abstract _writeRaw(key: string, value: unknown, ttl?: number): Observable<void>;\n\n flush(): Observable<void> {\n return this._flushRaw();\n }\n\n read<T = unknown>(key: string): Observable<T | undefined> {\n return this._readRaw(key).pipe(\n map((storedValue) => {\n if (this._isSmpCachedValue<T>(storedValue)) {\n if (storedValue.expiry >= DateTime.now().ts) {\n return storedValue.value as T;\n }\n this._removeRaw(key).subscribe(); // fire-and-forget\n\n return void 0;\n }\n\n return storedValue as T | undefined;\n })\n );\n }\n\n remove(key: string) {\n return this._removeRaw(key);\n }\n\n write<T = unknown>(key: string, value: T, ttl?: number): Observable<void> {\n if (isNaN(+ttl!) || +ttl! <= 0) {\n return this._writeRaw(key, value, ttl);\n }\n\n const expiry = DateTime.now().ts + ttl! * 1000;\n const wrappedValue: SmpCachedValue<T> = {\n value,\n expiry\n };\n\n return this._writeRaw(key, wrappedValue, ttl);\n }\n\n protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return smpIsSmpCachedValue(value);\n }\n}\n","import {Observable} from \"rxjs\";\n\nexport abstract class SmpAbstractCacheStrategy {\n abstract read<T = unknown>(key: string): T | undefined | Observable<T | undefined>;\n\n abstract write<T = unknown>(key: string, value: T, ttl?: number): void | Observable<void>;\n\n abstract remove(key: string): void | Observable<void>;\n\n abstract flush(): void | Observable<void>;\n}\n","import {SmpCachedValue} from \"./smp-cached-value.interface.js\";\n\n/**\n * Tells you if a value is a SmpCachedValue\n * @param value\n */\nexport function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n \"expiry\" in value &&\n typeof (value as any).expiry === \"number\"\n );\n}\n","import {Observable, OperatorFunction, catchError, throwError} from \"rxjs\";\nimport type {ObservableInput, ObservedValueOf} from \"rxjs\";\n\nexport function smpRxjsCatchOnly<T, E extends Error, O extends ObservableInput<any>>(\n errorFilter: (new (...args: any[]) => E) | ((err: unknown) => boolean),\n selector: (err: E) => O\n): OperatorFunction<T, T | ObservedValueOf<O>> {\n return (source: Observable<T>) =>\n source.pipe(\n catchError((err: unknown) => {\n const matches = typeof errorFilter === typeof isNaN\n ? isConstructor(errorFilter)\n ? isExactInstance(err, errorFilter as new (...args: any[]) => E)\n : (errorFilter as (err: unknown) => boolean)(err)\n : false;\n\n if (matches) {\n return selector(err as E);\n }\n return throwError(() => err);\n })\n );\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nfunction isConstructor(fn: unknown): fn is Function {\n try {\n // try creating a dummy instance\n Reflect.construct(String, [], fn as any);\n return true;\n }\n catch {\n return false;\n }\n}\n\n// Ensures that the error is an *exact* instance of the given error constructor, not a subclass\nfunction isExactInstance<E extends Error>(err: unknown, ctor: new (...args: any[]) => E): boolean {\n return (\n typeof err === \"object\" &&\n err !== null &&\n err.constructor === ctor\n );\n}\n","import {defer, Observable, of} from \"rxjs\";\n//\nimport {SmpAbstractRxjsTtlCacheStrategy} from \"./smp-abstract-rxjs-ttl-cache-strategy.class.js\";\n\nexport class SmpRxjsInMemoryCache extends SmpAbstractRxjsTtlCacheStrategy {\n\n private static _storage = new Map<string, unknown>();\n\n protected get _staticSelf(): typeof SmpRxjsInMemoryCache {\n return this.constructor as typeof SmpRxjsInMemoryCache;\n }\n\n protected _flushRaw(): Observable<void> {\n return defer(() => {\n this._staticSelf._storage.clear();\n\n return of(void 0);\n });\n }\n\n protected _readRaw(key: string): Observable<unknown | undefined> {\n return defer(() => {\n\n return of(this._staticSelf._storage.get(key));\n });\n }\n\n protected _removeRaw(key: string): Observable<void> {\n return defer(() => {\n this._staticSelf._storage.delete(key);\n\n return of(void 0);\n });\n }\n\n protected _writeRaw(key: string, value: unknown): Observable<void> {\n return defer(() => {\n this._staticSelf._storage.set(key, value);\n\n return of(void 0);\n });\n }\n}\n\n","import {map, Observable, of, defer, switchMap} from \"rxjs\";\n\nfunction smpRxjsSequence<T>(steps: (() => Observable<T>)[]): Observable<T[]> {\n const results: T[] = [];\n\n const runStep = (index: number): Observable<T[]> => {\n if (index >= steps.length) {\n return of(results);\n }\n\n return defer(() => steps[index]()).pipe(\n switchMap((value) => {\n results.push(value);\n return runStep(index + 1);\n })\n );\n };\n\n return runStep(0);\n}\n\ntype ObsFnMap = Record<string, () => Observable<any>>;\n\n/**\n * Processes a queue of RxJS Observables sequentially, either as an array or a mapped object.\n *\n * @param {(() => Observable<T>)[] | Record<string, () => Observable<T>>} source\n * A source of Observables to be processed in sequence. It can either be:\n * - An array of functions returning Observables.\n * - An object where keys are mapped to functions returning Observables.\n *\n * @return {Observable<any>}\n * An Observable that emits the combined results of the processed Observables. If the input is an array,\n * the output is an array of results. If the input is an object, the output is an object with the same keys containing the results.\n */\nexport function smpRxjsQueue<T extends (() => Observable<any>)[]>(\n source: T\n): Observable<{ [K in keyof T]: T[K] extends () => Observable<infer U> ? U : never }>;\nexport function smpRxjsQueue<T extends ObsFnMap>(\n source: T\n): Observable<{ [K in keyof T]: T[K] extends () => Observable<infer U> ? U : never }>;\nexport function smpRxjsQueue<T>(\n source: (() => Observable<T>)[] | ObsFnMap\n): Observable<any> {\n if (Array.isArray(source)) {\n return smpRxjsSequence(source).pipe(\n map((results) => results as any) // Type assertion per array di tuple\n );\n }\n\n return smpRxjsSequence(Object.values(source)).pipe(\n map((results) =>\n Object.keys(source).reduce((acc, key, index) => {\n acc[key] = results[index];\n return acc;\n }, {} as Record<string, any>)\n )\n );\n}\n","import {concatMap, from, Observable, toArray} from \"rxjs\";\n\n/**\n * Old version of the sequence. Now rewritten using recursion, which is way faster.\n * But you can use this if you want to stick with the rxjs pattern.\n * Use smpRxjsQueue for better performance ;)\n * @param steps\n */\nexport function smpRxjsSequence<T = any>(steps: (() => Observable<T>)[]) {\n return from(steps).pipe(\n concatMap(step => step()),\n toArray()\n );\n}\n","import {map, Observable, OperatorFunction} from \"rxjs\";\n\n/**\n * If the source observable completes emitting an empty value (empty array or object will be considered empty), it will emit\n * an error. The error will be created at that time by the optional\n * `errorFactory` argument, otherwise, the error will be {@link Error}.\n *\n * ## Example\n *\n * Throw an error if the query didn't match anything\n *\n * ```ts\n * import { of, takeUntil, timer, throwIfEmpty } from 'rxjs';\n *\n * const query$ = of([]);\n *\n * query$.pipe(\n * smpRxjsThrowIfEmpty(() => new Error('The query had no results'))\n * )\n * .subscribe({\n * next() {\n * console.log(\"The query had results\");\n * },\n * error(err) {\n * console.error(err.message);\n * }\n * });\n * ```\n *\n * @param errorFactory A factory function called to produce the\n * error to be thrown when the source observable completes without emitting a\n * value.\n * @return A function that returns an Observable that throws an error if the\n * source Observable completed without emitting.\n */\nexport function smpRxjsThrowIfEmpty<T>(errorFactory: (value: T) => any = defaultErrorFactory): OperatorFunction<T, T> {\n return (source: Observable<T>) => source.pipe(\n map(v => {\n if (~emptyValues.indexOf(JSON.stringify(v))) {\n throw errorFactory(v);\n }\n\n return v;\n })\n );\n}\n\nconst emptyValues = [void 0, null, false, 0, \"\", \"0\", [], {}].map((v) =>\n JSON.stringify(v)\n);\n\nconst defaultErrorFactory = (): Error => new Error();\n","import {defaultIfEmpty, filter, Observable, OperatorFunction} from \"rxjs\";\n//\nimport {smpRxjsThrowIfEmpty} from \"./smp-rxjs-throw-if-empty.function.js\";\n\n/**\n * Custom RxJS operator that filters the source observable based on a condition\n * and throws an error if the resulting observable is empty.\n *\n * @template T The type of items emitted by the source observable.\n * @param {function(T): boolean} condition - A function that takes a value from the source observable and returns a boolean.\n * If the function returns `true`, the value will be emitted; otherwise, it will be filtered out.\n * @param {function(): Error} [errorFactory] - An optional function that returns an error to be thrown if the resulting observable is empty.\n * If not provided, a default error will be thrown.\n * @returns {OperatorFunction<T, T>} An operator function that can be used in the RxJS pipeline.\n *\n * @example\n * import { of } from 'rxjs';\n * import { smpRxjsThrowOnCondition } from \"./path-to-your-file\";\n *\n * const source$ = of(1, 5, -3, 7, 12).pipe(\n * smpRxjsThrowOnCondition(value => value >= 0, () => new Error(\"Value is less than 0\")),\n * smpRxjsThrowOnCondition(value => value > 12, () => new Error(\"Value is lower than 12\"))\n * );\n *\n * source$.subscribe({\n * next: value => console.log(\"Value:\", value),\n * error: err => console.error(\"Error:\", err)\n * });\n */\nexport function smpRxjsThrowOnCondition<T>(\n condition: (value: T) => boolean,\n errorFactory?: () => any\n): OperatorFunction<T, T> {\n return (source: Observable<T>) =>\n source.pipe(\n filter((v: T) => !condition(v)), // Invert the condition because if I need to throw on that condition we should filter all that don't match\n defaultIfEmpty(false as unknown as T), // We nuke type errors, cause when falsy smpRxjsThrowIfEmpty will throw\n smpRxjsThrowIfEmpty(errorFactory)\n );\n}\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,EAAA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B,IAAAC,EAAmE,gBA6B5D,SAASC,EACZC,EACAC,EAAwB,CAExB,OAAQC,GACJA,EAAOC,QACHC,UAAQC,GAAS,CAACL,EAAUK,CAAAA,CAAAA,KAC5BC,kBAAe,EAAA,EACfC,EAAoBN,CAAAA,CAAAA,CAEhC,CAVgBF,EAAAA,EAAAA","names":["rxjs_exports","__export","SmpAbstractRxjsTtlCacheStrategy","SmpRxjsInMemoryCache","smpRxjsCatchOnly","smpRxjsQueue","smpRxjsSequence","smpRxjsThrowIfEmpty","smpRxjsThrowOnCondition","__toCommonJS","import_rxjs","import_ts_luxon","SmpAbstractCacheStrategy","smpIsSmpCachedValue","value","expiry","SmpAbstractRxjsTtlCacheStrategy","SmpAbstractCacheStrategy","flush","_flushRaw","read","key","_readRaw","pipe","map","storedValue","_isSmpCachedValue","expiry","DateTime","now","ts","value","_removeRaw","subscribe","remove","write","ttl","isNaN","_writeRaw","wrappedValue","smpIsSmpCachedValue","import_rxjs","smpRxjsCatchOnly","errorFilter","selector","source","pipe","catchError","err","isNaN","isConstructor","isExactInstance","throwError","fn","Reflect","construct","String","ctor","constructor","import_rxjs","SmpRxjsInMemoryCache","SmpAbstractRxjsTtlCacheStrategy","_storage","Map","_staticSelf","constructor","_flushRaw","defer","clear","of","_readRaw","key","get","_removeRaw","delete","_writeRaw","value","set","import_rxjs","smpRxjsSequence","steps","results","runStep","__name","index","length","of","defer","pipe","switchMap","value","push","smpRxjsQueue","source","Array","isArray","map","Object","values","keys","reduce","acc","key","import_rxjs","smpRxjsSequence","steps","from","pipe","concatMap","step","toArray","import_rxjs","smpRxjsThrowIfEmpty","errorFactory","defaultErrorFactory","source","pipe","map","v","emptyValues","indexOf","JSON","stringify","__name","Error","import_rxjs","smpRxjsThrowOnCondition","condition","errorFactory","source","pipe","filter","v","defaultIfEmpty","smpRxjsThrowIfEmpty"]}
@@ -1,5 +1,8 @@
1
1
  export { SmpAbstractRxjsTtlCacheStrategy } from './smp-abstract-rxjs-ttl-cache-strategy.class.cjs';
2
2
  export { smpRxjsCatchOnly } from './smp-rxjs-catch-only.function.cjs';
3
+ export { SmpRxjsInMemoryCache } from './smp-rxjs-in-memory-cache.class.cjs';
4
+ export { smpRxjsQueue } from './smp-rxjs-queue.function.cjs';
5
+ export { smpRxjsSequence } from './smp-rxjs-sequence.function.cjs';
3
6
  export { smpRxjsThrowIfEmpty } from './smp-rxjs-throw-if-empty.function.cjs';
4
7
  export { smpRxjsThrowOnCondition } from './smp-rxjs-throw-on-condition.function.cjs';
5
8
  import 'rxjs';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/shared/rxjs/smp-abstract-rxjs-ttl-cache-strategy.class.ts","../../../../src/shared/utils/cache/smp-abstract-cache-strategy.class.ts","../../../../src/shared/utils/cache/smp-is-smp-cached-value.function.ts"],"sourcesContent":["import {map, Observable} from \"rxjs\";\nimport {DateTime} from \"ts-luxon\";\n//\nimport {SmpAbstractCacheStrategy} from \"../utils/cache/smp-abstract-cache-strategy.class.js\";\nimport {SmpCachedValue} from \"../utils/cache/smp-cached-value.interface.js\";\nimport {smpIsSmpCachedValue} from \"../utils/cache/smp-is-smp-cached-value.function.js\";\n\nexport abstract class SmpAbstractRxjsTtlCacheStrategy extends SmpAbstractCacheStrategy {\n\n protected abstract _flushRaw(): Observable<void>;\n\n protected abstract _readRaw(key: string): Observable<unknown | undefined>;\n\n protected abstract _removeRaw(key: string): Observable<void>;\n\n protected abstract _writeRaw(key: string, value: unknown, ttl?: number): Observable<void>;\n\n flush(): Observable<void> {\n return this._flushRaw();\n }\n\n read<T = unknown>(key: string): Observable<T | undefined> {\n return this._readRaw(key).pipe(\n map((storedValue) => {\n if (this._isSmpCachedValue<T>(storedValue)) {\n if (storedValue.expiry >= DateTime.now().ts) {\n return storedValue.value as T;\n }\n this._removeRaw(key).subscribe(); // fire-and-forget\n\n return void 0;\n }\n\n return storedValue as T | undefined;\n })\n );\n }\n\n remove(key: string) {\n return this._removeRaw(key);\n }\n\n write<T = unknown>(key: string, value: T, ttl?: number): Observable<void> {\n if (isNaN(+ttl!) || +ttl! <= 0) {\n return this._writeRaw(key, value, ttl);\n }\n\n const expiry = DateTime.now().ts + ttl! * 1000;\n const wrappedValue: SmpCachedValue<T> = {\n value,\n expiry\n };\n\n return this._writeRaw(key, wrappedValue, ttl);\n }\n\n protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return smpIsSmpCachedValue(value);\n }\n}\n","import {Observable} from \"rxjs\";\n\nexport abstract class SmpAbstractCacheStrategy {\n abstract read<T = unknown>(key: string): T | undefined | Observable<T | undefined>;\n\n abstract write<T = unknown>(key: string, value: T, ttl?: number): void | Observable<void>;\n\n abstract remove(key: string): void | Observable<void>;\n\n abstract flush(): void | Observable<void>;\n}\n","import {SmpCachedValue} from \"./smp-cached-value.interface\";\n\n/**\n * Tells you if a value is a SmpCachedValue\n * @param value\n */\nexport function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n \"expiry\" in value &&\n typeof (value as any).expiry === \"number\"\n );\n}\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA8B,gBAC9BC,EAAuB,oBCChB,IAAeC,EAAf,KAAeA,CAAtB,MAAsBA,CAAAA,EAAAA,iCAQtB,ECJO,SAASC,EAAuBC,EAAc,CACjD,OACI,OAAOA,GAAU,UACjBA,IAAU,MACV,UAAWA,GACX,WAAYA,GACZ,OAAQA,EAAcC,QAAW,QAEzC,CARgBF,EAAAA,EAAAA,uBFCT,IAAeG,EAAf,cAAuDC,CAAAA,CAP9D,MAO8DA,CAAAA,EAAAA,wCAU1DC,OAA0B,CACtB,OAAO,KAAKC,UAAS,CACzB,CAEAC,KAAkBC,EAAwC,CACtD,OAAO,KAAKC,SAASD,CAAAA,EAAKE,QACtBC,OAAKC,GAAAA,CACD,GAAI,KAAKC,kBAAqBD,CAAAA,EAAc,CACxC,GAAIA,EAAYE,QAAUC,WAASC,IAAG,EAAGC,GACrC,OAAOL,EAAYM,MAEvB,KAAKC,WAAWX,CAAAA,EAAKY,UAAS,EAE9B,MACJ,CAEA,OAAOR,CACX,CAAA,CAAA,CAER,CAEAS,OAAOb,EAAa,CAChB,OAAO,KAAKW,WAAWX,CAAAA,CAC3B,CAEAc,MAAmBd,EAAaU,EAAUK,EAAgC,CACtE,GAAIC,MAAM,CAACD,CAAAA,GAAS,CAACA,GAAQ,EACzB,OAAO,KAAKE,UAAUjB,EAAKU,EAAOK,CAAAA,EAGtC,IAAMT,EAASC,WAASC,IAAG,EAAGC,GAAKM,EAAO,IACpCG,EAAkC,CACpCR,MAAAA,EACAJ,OAAAA,CACJ,EAEA,OAAO,KAAKW,UAAUjB,EAAKkB,EAAcH,CAAAA,CAC7C,CAEUV,kBAAqBK,EAA4C,CACvE,OAAOS,EAAoBT,CAAAA,CAC/B,CACJ","names":["smp_abstract_rxjs_ttl_cache_strategy_class_exports","__export","SmpAbstractRxjsTtlCacheStrategy","__toCommonJS","import_rxjs","import_ts_luxon","SmpAbstractCacheStrategy","smpIsSmpCachedValue","value","expiry","SmpAbstractRxjsTtlCacheStrategy","SmpAbstractCacheStrategy","flush","_flushRaw","read","key","_readRaw","pipe","map","storedValue","_isSmpCachedValue","expiry","DateTime","now","ts","value","_removeRaw","subscribe","remove","write","ttl","isNaN","_writeRaw","wrappedValue","smpIsSmpCachedValue"]}
1
+ {"version":3,"sources":["../../../../src/shared/rxjs/smp-abstract-rxjs-ttl-cache-strategy.class.ts","../../../../src/shared/utils/cache/smp-abstract-cache-strategy.class.ts","../../../../src/shared/utils/cache/smp-is-smp-cached-value.function.ts"],"sourcesContent":["import {map, Observable} from \"rxjs\";\nimport {DateTime} from \"ts-luxon\";\n//\nimport {SmpAbstractCacheStrategy} from \"../utils/cache/smp-abstract-cache-strategy.class.js\";\nimport {SmpCachedValue} from \"../utils/cache/smp-cached-value.interface.js\";\nimport {smpIsSmpCachedValue} from \"../utils/cache/smp-is-smp-cached-value.function.js\";\n\nexport abstract class SmpAbstractRxjsTtlCacheStrategy extends SmpAbstractCacheStrategy {\n\n protected abstract _flushRaw(): Observable<void>;\n\n protected abstract _readRaw(key: string): Observable<unknown | undefined>;\n\n protected abstract _removeRaw(key: string): Observable<void>;\n\n protected abstract _writeRaw(key: string, value: unknown, ttl?: number): Observable<void>;\n\n flush(): Observable<void> {\n return this._flushRaw();\n }\n\n read<T = unknown>(key: string): Observable<T | undefined> {\n return this._readRaw(key).pipe(\n map((storedValue) => {\n if (this._isSmpCachedValue<T>(storedValue)) {\n if (storedValue.expiry >= DateTime.now().ts) {\n return storedValue.value as T;\n }\n this._removeRaw(key).subscribe(); // fire-and-forget\n\n return void 0;\n }\n\n return storedValue as T | undefined;\n })\n );\n }\n\n remove(key: string) {\n return this._removeRaw(key);\n }\n\n write<T = unknown>(key: string, value: T, ttl?: number): Observable<void> {\n if (isNaN(+ttl!) || +ttl! <= 0) {\n return this._writeRaw(key, value, ttl);\n }\n\n const expiry = DateTime.now().ts + ttl! * 1000;\n const wrappedValue: SmpCachedValue<T> = {\n value,\n expiry\n };\n\n return this._writeRaw(key, wrappedValue, ttl);\n }\n\n protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return smpIsSmpCachedValue(value);\n }\n}\n","import {Observable} from \"rxjs\";\n\nexport abstract class SmpAbstractCacheStrategy {\n abstract read<T = unknown>(key: string): T | undefined | Observable<T | undefined>;\n\n abstract write<T = unknown>(key: string, value: T, ttl?: number): void | Observable<void>;\n\n abstract remove(key: string): void | Observable<void>;\n\n abstract flush(): void | Observable<void>;\n}\n","import {SmpCachedValue} from \"./smp-cached-value.interface.js\";\n\n/**\n * Tells you if a value is a SmpCachedValue\n * @param value\n */\nexport function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n \"expiry\" in value &&\n typeof (value as any).expiry === \"number\"\n );\n}\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA8B,gBAC9BC,EAAuB,oBCChB,IAAeC,EAAf,KAAeA,CAAtB,MAAsBA,CAAAA,EAAAA,iCAQtB,ECJO,SAASC,EAAuBC,EAAc,CACjD,OACI,OAAOA,GAAU,UACjBA,IAAU,MACV,UAAWA,GACX,WAAYA,GACZ,OAAQA,EAAcC,QAAW,QAEzC,CARgBF,EAAAA,EAAAA,uBFCT,IAAeG,EAAf,cAAuDC,CAAAA,CAP9D,MAO8DA,CAAAA,EAAAA,wCAU1DC,OAA0B,CACtB,OAAO,KAAKC,UAAS,CACzB,CAEAC,KAAkBC,EAAwC,CACtD,OAAO,KAAKC,SAASD,CAAAA,EAAKE,QACtBC,OAAKC,GAAAA,CACD,GAAI,KAAKC,kBAAqBD,CAAAA,EAAc,CACxC,GAAIA,EAAYE,QAAUC,WAASC,IAAG,EAAGC,GACrC,OAAOL,EAAYM,MAEvB,KAAKC,WAAWX,CAAAA,EAAKY,UAAS,EAE9B,MACJ,CAEA,OAAOR,CACX,CAAA,CAAA,CAER,CAEAS,OAAOb,EAAa,CAChB,OAAO,KAAKW,WAAWX,CAAAA,CAC3B,CAEAc,MAAmBd,EAAaU,EAAUK,EAAgC,CACtE,GAAIC,MAAM,CAACD,CAAAA,GAAS,CAACA,GAAQ,EACzB,OAAO,KAAKE,UAAUjB,EAAKU,EAAOK,CAAAA,EAGtC,IAAMT,EAASC,WAASC,IAAG,EAAGC,GAAKM,EAAO,IACpCG,EAAkC,CACpCR,MAAAA,EACAJ,OAAAA,CACJ,EAEA,OAAO,KAAKW,UAAUjB,EAAKkB,EAAcH,CAAAA,CAC7C,CAEUV,kBAAqBK,EAA4C,CACvE,OAAOS,EAAoBT,CAAAA,CAC/B,CACJ","names":["smp_abstract_rxjs_ttl_cache_strategy_class_exports","__export","SmpAbstractRxjsTtlCacheStrategy","__toCommonJS","import_rxjs","import_ts_luxon","SmpAbstractCacheStrategy","smpIsSmpCachedValue","value","expiry","SmpAbstractRxjsTtlCacheStrategy","SmpAbstractCacheStrategy","flush","_flushRaw","read","key","_readRaw","pipe","map","storedValue","_isSmpCachedValue","expiry","DateTime","now","ts","value","_removeRaw","subscribe","remove","write","ttl","isNaN","_writeRaw","wrappedValue","smpIsSmpCachedValue"]}
@@ -1,2 +1,2 @@
1
- "use strict";var n=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var o=(e,r)=>n(e,"name",{value:r,configurable:!0});var x=(e,r)=>{for(var t in r)n(e,t,{get:r[t],enumerable:!0})},R=(e,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of d(r))!l.call(e,a)&&a!==t&&n(e,a,{get:()=>r[a],enumerable:!(s=w(r,a))||s.enumerable});return e};var S=e=>R(n({},"__esModule",{value:!0}),e);var g={};x(g,{KikRxjsInMemoryCache:()=>f});module.exports=S(g);var i=require("rxjs");var c=require("rxjs"),m=require("ts-luxon");var p=class{static{o(this,"SmpAbstractCacheStrategy")}};function _(e){return typeof e=="object"&&e!==null&&"value"in e&&"expiry"in e&&typeof e.expiry=="number"}o(_,"smpIsSmpCachedValue");var u=class extends p{static{o(this,"SmpAbstractRxjsTtlCacheStrategy")}flush(){return this._flushRaw()}read(r){return this._readRaw(r).pipe((0,c.map)(t=>{if(this._isSmpCachedValue(t)){if(t.expiry>=m.DateTime.now().ts)return t.value;this._removeRaw(r).subscribe();return}return t}))}remove(r){return this._removeRaw(r)}write(r,t,s){if(isNaN(+s)||+s<=0)return this._writeRaw(r,t,s);let a=m.DateTime.now().ts+s*1e3,h={value:t,expiry:a};return this._writeRaw(r,h,s)}_isSmpCachedValue(r){return _(r)}};var f=class extends u{static{o(this,"KikRxjsInMemoryCache")}static _storage=new Map;get _staticSelf(){return this.constructor}_flushRaw(){return(0,i.defer)(()=>(this._staticSelf._storage.clear(),(0,i.of)(void 0)))}_readRaw(r){return(0,i.defer)(()=>(0,i.of)(this._staticSelf._storage.get(r)))}_removeRaw(r){return(0,i.defer)(()=>(this._staticSelf._storage.delete(r),(0,i.of)(void 0)))}_writeRaw(r,t){return(0,i.defer)(()=>(this._staticSelf._storage.set(r,t),(0,i.of)(void 0)))}};0&&(module.exports={KikRxjsInMemoryCache});
1
+ "use strict";var n=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var o=(e,r)=>n(e,"name",{value:r,configurable:!0});var x=(e,r)=>{for(var t in r)n(e,t,{get:r[t],enumerable:!0})},R=(e,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of d(r))!l.call(e,a)&&a!==t&&n(e,a,{get:()=>r[a],enumerable:!(s=w(r,a))||s.enumerable});return e};var S=e=>R(n({},"__esModule",{value:!0}),e);var g={};x(g,{SmpRxjsInMemoryCache:()=>f});module.exports=S(g);var i=require("rxjs");var c=require("rxjs"),m=require("ts-luxon");var p=class{static{o(this,"SmpAbstractCacheStrategy")}};function _(e){return typeof e=="object"&&e!==null&&"value"in e&&"expiry"in e&&typeof e.expiry=="number"}o(_,"smpIsSmpCachedValue");var u=class extends p{static{o(this,"SmpAbstractRxjsTtlCacheStrategy")}flush(){return this._flushRaw()}read(r){return this._readRaw(r).pipe((0,c.map)(t=>{if(this._isSmpCachedValue(t)){if(t.expiry>=m.DateTime.now().ts)return t.value;this._removeRaw(r).subscribe();return}return t}))}remove(r){return this._removeRaw(r)}write(r,t,s){if(isNaN(+s)||+s<=0)return this._writeRaw(r,t,s);let a=m.DateTime.now().ts+s*1e3,h={value:t,expiry:a};return this._writeRaw(r,h,s)}_isSmpCachedValue(r){return _(r)}};var f=class extends u{static{o(this,"SmpRxjsInMemoryCache")}static _storage=new Map;get _staticSelf(){return this.constructor}_flushRaw(){return(0,i.defer)(()=>(this._staticSelf._storage.clear(),(0,i.of)(void 0)))}_readRaw(r){return(0,i.defer)(()=>(0,i.of)(this._staticSelf._storage.get(r)))}_removeRaw(r){return(0,i.defer)(()=>(this._staticSelf._storage.delete(r),(0,i.of)(void 0)))}_writeRaw(r,t){return(0,i.defer)(()=>(this._staticSelf._storage.set(r,t),(0,i.of)(void 0)))}};0&&(module.exports={SmpRxjsInMemoryCache});
2
2
  //# sourceMappingURL=smp-rxjs-in-memory-cache.class.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/shared/rxjs/smp-rxjs-in-memory-cache.class.ts","../../../../src/shared/rxjs/smp-abstract-rxjs-ttl-cache-strategy.class.ts","../../../../src/shared/utils/cache/smp-abstract-cache-strategy.class.ts","../../../../src/shared/utils/cache/smp-is-smp-cached-value.function.ts"],"sourcesContent":["import {defer, Observable, of} from \"rxjs\";\n//\nimport {SmpAbstractRxjsTtlCacheStrategy} from \"./smp-abstract-rxjs-ttl-cache-strategy.class.js\";\n\nexport class KikRxjsInMemoryCache extends SmpAbstractRxjsTtlCacheStrategy {\n\n private static _storage = new Map<string, unknown>();\n\n protected get _staticSelf(): typeof KikRxjsInMemoryCache {\n return this.constructor as typeof KikRxjsInMemoryCache;\n }\n\n protected _flushRaw(): Observable<void> {\n return defer(() => {\n this._staticSelf._storage.clear();\n\n return of(void 0);\n });\n }\n\n protected _readRaw(key: string): Observable<unknown | undefined> {\n return defer(() => {\n\n return of(this._staticSelf._storage.get(key));\n });\n }\n\n protected _removeRaw(key: string): Observable<void> {\n return defer(() => {\n this._staticSelf._storage.delete(key);\n\n return of(void 0);\n });\n }\n\n protected _writeRaw(key: string, value: unknown): Observable<void> {\n return defer(() => {\n this._staticSelf._storage.set(key, value);\n\n return of(void 0);\n });\n }\n}\n\n","import {map, Observable} from \"rxjs\";\nimport {DateTime} from \"ts-luxon\";\n//\nimport {SmpAbstractCacheStrategy} from \"../utils/cache/smp-abstract-cache-strategy.class.js\";\nimport {SmpCachedValue} from \"../utils/cache/smp-cached-value.interface.js\";\nimport {smpIsSmpCachedValue} from \"../utils/cache/smp-is-smp-cached-value.function.js\";\n\nexport abstract class SmpAbstractRxjsTtlCacheStrategy extends SmpAbstractCacheStrategy {\n\n protected abstract _flushRaw(): Observable<void>;\n\n protected abstract _readRaw(key: string): Observable<unknown | undefined>;\n\n protected abstract _removeRaw(key: string): Observable<void>;\n\n protected abstract _writeRaw(key: string, value: unknown, ttl?: number): Observable<void>;\n\n flush(): Observable<void> {\n return this._flushRaw();\n }\n\n read<T = unknown>(key: string): Observable<T | undefined> {\n return this._readRaw(key).pipe(\n map((storedValue) => {\n if (this._isSmpCachedValue<T>(storedValue)) {\n if (storedValue.expiry >= DateTime.now().ts) {\n return storedValue.value as T;\n }\n this._removeRaw(key).subscribe(); // fire-and-forget\n\n return void 0;\n }\n\n return storedValue as T | undefined;\n })\n );\n }\n\n remove(key: string) {\n return this._removeRaw(key);\n }\n\n write<T = unknown>(key: string, value: T, ttl?: number): Observable<void> {\n if (isNaN(+ttl!) || +ttl! <= 0) {\n return this._writeRaw(key, value, ttl);\n }\n\n const expiry = DateTime.now().ts + ttl! * 1000;\n const wrappedValue: SmpCachedValue<T> = {\n value,\n expiry\n };\n\n return this._writeRaw(key, wrappedValue, ttl);\n }\n\n protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return smpIsSmpCachedValue(value);\n }\n}\n","import {Observable} from \"rxjs\";\n\nexport abstract class SmpAbstractCacheStrategy {\n abstract read<T = unknown>(key: string): T | undefined | Observable<T | undefined>;\n\n abstract write<T = unknown>(key: string, value: T, ttl?: number): void | Observable<void>;\n\n abstract remove(key: string): void | Observable<void>;\n\n abstract flush(): void | Observable<void>;\n}\n","import {SmpCachedValue} from \"./smp-cached-value.interface\";\n\n/**\n * Tells you if a value is a SmpCachedValue\n * @param value\n */\nexport function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n \"expiry\" in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CC,CAAAA,CAJ1C,MAI0CA,CAAAA,EAAAA,6BAEtC,OAAeC,SAAW,IAAIC,IAE9B,IAAcC,aAA2C,CACrD,OAAO,KAAKC,WAChB,CAEUC,WAA8B,CACpC,SAAOC,SAAM,KACT,KAAKH,YAAYF,SAASM,MAAK,KAExBC,MAAG,MAAK,EACnB,CACJ,CAEUC,SAASC,EAA8C,CAC7D,SAAOJ,SAAM,OAEFE,MAAG,KAAKL,YAAYF,SAASU,IAAID,CAAAA,CAAAA,CAC5C,CACJ,CAEUE,WAAWF,EAA+B,CAChD,SAAOJ,SAAM,KACT,KAAKH,YAAYF,SAASY,OAAOH,CAAAA,KAE1BF,MAAG,MAAK,EACnB,CACJ,CAEUM,UAAUJ,EAAaK,EAAkC,CAC/D,SAAOT,SAAM,KACT,KAAKH,YAAYF,SAASe,IAAIN,EAAKK,CAAAA,KAE5BP,MAAG,MAAK,EACnB,CACJ,CACJ","names":["smp_rxjs_in_memory_cache_class_exports","__export","KikRxjsInMemoryCache","__toCommonJS","import_rxjs","import_rxjs","import_ts_luxon","SmpAbstractCacheStrategy","smpIsSmpCachedValue","value","expiry","SmpAbstractRxjsTtlCacheStrategy","SmpAbstractCacheStrategy","flush","_flushRaw","read","key","_readRaw","pipe","map","storedValue","_isSmpCachedValue","expiry","DateTime","now","ts","value","_removeRaw","subscribe","remove","write","ttl","isNaN","_writeRaw","wrappedValue","smpIsSmpCachedValue","KikRxjsInMemoryCache","SmpAbstractRxjsTtlCacheStrategy","_storage","Map","_staticSelf","constructor","_flushRaw","defer","clear","of","_readRaw","key","get","_removeRaw","delete","_writeRaw","value","set"]}
1
+ {"version":3,"sources":["../../../../src/shared/rxjs/smp-rxjs-in-memory-cache.class.ts","../../../../src/shared/rxjs/smp-abstract-rxjs-ttl-cache-strategy.class.ts","../../../../src/shared/utils/cache/smp-abstract-cache-strategy.class.ts","../../../../src/shared/utils/cache/smp-is-smp-cached-value.function.ts"],"sourcesContent":["import {defer, Observable, of} from \"rxjs\";\n//\nimport {SmpAbstractRxjsTtlCacheStrategy} from \"./smp-abstract-rxjs-ttl-cache-strategy.class.js\";\n\nexport class SmpRxjsInMemoryCache extends SmpAbstractRxjsTtlCacheStrategy {\n\n private static _storage = new Map<string, unknown>();\n\n protected get _staticSelf(): typeof SmpRxjsInMemoryCache {\n return this.constructor as typeof SmpRxjsInMemoryCache;\n }\n\n protected _flushRaw(): Observable<void> {\n return defer(() => {\n this._staticSelf._storage.clear();\n\n return of(void 0);\n });\n }\n\n protected _readRaw(key: string): Observable<unknown | undefined> {\n return defer(() => {\n\n return of(this._staticSelf._storage.get(key));\n });\n }\n\n protected _removeRaw(key: string): Observable<void> {\n return defer(() => {\n this._staticSelf._storage.delete(key);\n\n return of(void 0);\n });\n }\n\n protected _writeRaw(key: string, value: unknown): Observable<void> {\n return defer(() => {\n this._staticSelf._storage.set(key, value);\n\n return of(void 0);\n });\n }\n}\n\n","import {map, Observable} from \"rxjs\";\nimport {DateTime} from \"ts-luxon\";\n//\nimport {SmpAbstractCacheStrategy} from \"../utils/cache/smp-abstract-cache-strategy.class.js\";\nimport {SmpCachedValue} from \"../utils/cache/smp-cached-value.interface.js\";\nimport {smpIsSmpCachedValue} from \"../utils/cache/smp-is-smp-cached-value.function.js\";\n\nexport abstract class SmpAbstractRxjsTtlCacheStrategy extends SmpAbstractCacheStrategy {\n\n protected abstract _flushRaw(): Observable<void>;\n\n protected abstract _readRaw(key: string): Observable<unknown | undefined>;\n\n protected abstract _removeRaw(key: string): Observable<void>;\n\n protected abstract _writeRaw(key: string, value: unknown, ttl?: number): Observable<void>;\n\n flush(): Observable<void> {\n return this._flushRaw();\n }\n\n read<T = unknown>(key: string): Observable<T | undefined> {\n return this._readRaw(key).pipe(\n map((storedValue) => {\n if (this._isSmpCachedValue<T>(storedValue)) {\n if (storedValue.expiry >= DateTime.now().ts) {\n return storedValue.value as T;\n }\n this._removeRaw(key).subscribe(); // fire-and-forget\n\n return void 0;\n }\n\n return storedValue as T | undefined;\n })\n );\n }\n\n remove(key: string) {\n return this._removeRaw(key);\n }\n\n write<T = unknown>(key: string, value: T, ttl?: number): Observable<void> {\n if (isNaN(+ttl!) || +ttl! <= 0) {\n return this._writeRaw(key, value, ttl);\n }\n\n const expiry = DateTime.now().ts + ttl! * 1000;\n const wrappedValue: SmpCachedValue<T> = {\n value,\n expiry\n };\n\n return this._writeRaw(key, wrappedValue, ttl);\n }\n\n protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return smpIsSmpCachedValue(value);\n }\n}\n","import {Observable} from \"rxjs\";\n\nexport abstract class SmpAbstractCacheStrategy {\n abstract read<T = unknown>(key: string): T | undefined | Observable<T | undefined>;\n\n abstract write<T = unknown>(key: string, value: T, ttl?: number): void | Observable<void>;\n\n abstract remove(key: string): void | Observable<void>;\n\n abstract flush(): void | Observable<void>;\n}\n","import {SmpCachedValue} from \"./smp-cached-value.interface.js\";\n\n/**\n * Tells you if a value is a SmpCachedValue\n * @param value\n */\nexport function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n \"expiry\" in value &&\n typeof (value as any).expiry === \"number\"\n );\n}\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoC,gBCApC,IAAAC,EAA8B,gBAC9BC,EAAuB,oBCChB,IAAeC,EAAf,KAAeA,CAAtB,MAAsBA,CAAAA,EAAAA,iCAQtB,ECJO,SAASC,EAAuBC,EAAc,CACjD,OACI,OAAOA,GAAU,UACjBA,IAAU,MACV,UAAWA,GACX,WAAYA,GACZ,OAAQA,EAAcC,QAAW,QAEzC,CARgBF,EAAAA,EAAAA,uBFCT,IAAeG,EAAf,cAAuDC,CAAAA,CAP9D,MAO8DA,CAAAA,EAAAA,wCAU1DC,OAA0B,CACtB,OAAO,KAAKC,UAAS,CACzB,CAEAC,KAAkBC,EAAwC,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EAAKK,CAAAA,KAE5BP,MAAG,MAAK,EACnB,CACJ,CACJ","names":["smp_rxjs_in_memory_cache_class_exports","__export","SmpRxjsInMemoryCache","__toCommonJS","import_rxjs","import_rxjs","import_ts_luxon","SmpAbstractCacheStrategy","smpIsSmpCachedValue","value","expiry","SmpAbstractRxjsTtlCacheStrategy","SmpAbstractCacheStrategy","flush","_flushRaw","read","key","_readRaw","pipe","map","storedValue","_isSmpCachedValue","expiry","DateTime","now","ts","value","_removeRaw","subscribe","remove","write","ttl","isNaN","_writeRaw","wrappedValue","smpIsSmpCachedValue","SmpRxjsInMemoryCache","SmpAbstractRxjsTtlCacheStrategy","_storage","Map","_staticSelf","constructor","_flushRaw","defer","clear","of","_readRaw","key","get","_removeRaw","delete","_writeRaw","value","set"]}
@@ -3,13 +3,13 @@ import { SmpAbstractRxjsTtlCacheStrategy } from './smp-abstract-rxjs-ttl-cache-s
3
3
  import '../utils/cache/smp-abstract-cache-strategy.class.cjs';
4
4
  import '../utils/cache/smp-cached-value.interface.cjs';
5
5
 
6
- declare class KikRxjsInMemoryCache extends SmpAbstractRxjsTtlCacheStrategy {
6
+ declare class SmpRxjsInMemoryCache extends SmpAbstractRxjsTtlCacheStrategy {
7
7
  private static _storage;
8
- protected get _staticSelf(): typeof KikRxjsInMemoryCache;
8
+ protected get _staticSelf(): typeof SmpRxjsInMemoryCache;
9
9
  protected _flushRaw(): Observable<void>;
10
10
  protected _readRaw(key: string): Observable<unknown | undefined>;
11
11
  protected _removeRaw(key: string): Observable<void>;
12
12
  protected _writeRaw(key: string, value: unknown): Observable<void>;
13
13
  }
14
14
 
15
- export { KikRxjsInMemoryCache };
15
+ export { SmpRxjsInMemoryCache };
@@ -0,0 +1,2 @@
1
+ "use strict";var i=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var s=(e,r)=>i(e,"name",{value:r,configurable:!0});var c=(e,r)=>{for(var t in r)i(e,t,{get:r[t],enumerable:!0})},j=(e,r,t,p)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of o(r))!a.call(e,n)&&n!==t&&i(e,n,{get:()=>r[n],enumerable:!(p=m(r,n))||p.enumerable});return e};var h=e=>j(i({},"__esModule",{value:!0}),e);var y={};c(y,{smpRxjsQueue:()=>l});module.exports=h(y);var u=require("rxjs");function f(e){let r=[],t=s(p=>p>=e.length?(0,u.of)(r):(0,u.defer)(()=>e[p]()).pipe((0,u.switchMap)(n=>(r.push(n),t(p+1)))),"runStep");return t(0)}s(f,"smpRxjsSequence");function l(e){return Array.isArray(e)?f(e).pipe((0,u.map)(r=>r)):f(Object.values(e)).pipe((0,u.map)(r=>Object.keys(e).reduce((t,p,n)=>(t[p]=r[n],t),{})))}s(l,"smpRxjsQueue");0&&(module.exports={smpRxjsQueue});
2
+ //# sourceMappingURL=smp-rxjs-queue.function.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/shared/rxjs/smp-rxjs-queue.function.ts"],"sourcesContent":["import {map, Observable, of, defer, switchMap} from \"rxjs\";\n\nfunction smpRxjsSequence<T>(steps: (() => Observable<T>)[]): Observable<T[]> {\n const results: T[] = [];\n\n const runStep = (index: number): Observable<T[]> => {\n if (index >= steps.length) {\n return of(results);\n }\n\n return defer(() => steps[index]()).pipe(\n switchMap((value) => {\n results.push(value);\n return runStep(index + 1);\n })\n );\n };\n\n return runStep(0);\n}\n\ntype ObsFnMap = Record<string, () => Observable<any>>;\n\n/**\n * Processes a queue of RxJS Observables sequentially, either as an array or a mapped object.\n *\n * @param {(() => Observable<T>)[] | Record<string, () => Observable<T>>} source\n * A source of Observables to be processed in sequence. It can either be:\n * - An array of functions returning Observables.\n * - An object where keys are mapped to functions returning Observables.\n *\n * @return {Observable<any>}\n * An Observable that emits the combined results of the processed Observables. If the input is an array,\n * the output is an array of results. If the input is an object, the output is an object with the same keys containing the results.\n */\nexport function smpRxjsQueue<T extends (() => Observable<any>)[]>(\n source: T\n): Observable<{ [K in keyof T]: T[K] extends () => Observable<infer U> ? U : never }>;\nexport function smpRxjsQueue<T extends ObsFnMap>(\n source: T\n): Observable<{ [K in keyof T]: T[K] extends () => Observable<infer U> ? U : never }>;\nexport function smpRxjsQueue<T>(\n source: (() => Observable<T>)[] | ObsFnMap\n): Observable<any> {\n if (Array.isArray(source)) {\n return smpRxjsSequence(source).pipe(\n map((results) => results as any) // Type assertion per array di tuple\n );\n }\n\n return smpRxjsSequence(Object.values(source)).pipe(\n map((results) =>\n Object.keys(source).reduce((acc, key, index) => {\n acc[key] = results[index];\n return acc;\n }, {} as Record<string, any>)\n )\n );\n}\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoD,gBAEpD,SAASC,EAAmBC,EAA8B,CACtD,IAAMC,EAAe,CAAA,EAEfC,EAAUC,EAACC,GACTA,GAASJ,EAAMK,UACRC,MAAGL,CAAAA,KAGPM,SAAM,IAAMP,EAAMI,CAAAA,EAAM,CAAA,EAAII,QAC/BC,aAAWC,IACPT,EAAQU,KAAKD,CAAAA,EACNR,EAAQE,EAAQ,CAAA,EAC3B,CAAA,EATQ,WAahB,OAAOF,EAAQ,CAAA,CACnB,CAjBSH,EAAAA,EAAAA,mBAuCF,SAASa,EACZC,EAA0C,CAE1C,OAAIC,MAAMC,QAAQF,CAAAA,EACPd,EAAgBc,CAAAA,EAAQL,QAC3BQ,OAAKf,GAAYA,CAAAA,GAIlBF,EAAgBkB,OAAOC,OAAOL,CAAAA,CAAAA,EAASL,QAC1CQ,OAAKf,GACDgB,OAAOE,KAAKN,CAAAA,EAAQO,OAAO,CAACC,EAAKC,EAAKlB,KAClCiB,EAAIC,CAAAA,EAAOrB,EAAQG,CAAAA,EACZiB,GACR,CAAC,CAAA,CAAA,CAAA,CAGhB,CAjBgBT,EAAAA,EAAAA","names":["smp_rxjs_queue_function_exports","__export","smpRxjsQueue","__toCommonJS","import_rxjs","smpRxjsSequence","steps","results","runStep","__name","index","length","of","defer","pipe","switchMap","value","push","smpRxjsQueue","source","Array","isArray","map","Object","values","keys","reduce","acc","key"]}
@@ -0,0 +1,23 @@
1
+ import { Observable } from 'rxjs';
2
+
3
+ type ObsFnMap = Record<string, () => Observable<any>>;
4
+ /**
5
+ * Processes a queue of RxJS Observables sequentially, either as an array or a mapped object.
6
+ *
7
+ * @param {(() => Observable<T>)[] | Record<string, () => Observable<T>>} source
8
+ * A source of Observables to be processed in sequence. It can either be:
9
+ * - An array of functions returning Observables.
10
+ * - An object where keys are mapped to functions returning Observables.
11
+ *
12
+ * @return {Observable<any>}
13
+ * An Observable that emits the combined results of the processed Observables. If the input is an array,
14
+ * the output is an array of results. If the input is an object, the output is an object with the same keys containing the results.
15
+ */
16
+ declare function smpRxjsQueue<T extends (() => Observable<any>)[]>(source: T): Observable<{
17
+ [K in keyof T]: T[K] extends () => Observable<infer U> ? U : never;
18
+ }>;
19
+ declare function smpRxjsQueue<T extends ObsFnMap>(source: T): Observable<{
20
+ [K in keyof T]: T[K] extends () => Observable<infer U> ? U : never;
21
+ }>;
22
+
23
+ export { smpRxjsQueue };
@@ -0,0 +1,2 @@
1
+ "use strict";var n=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var m=(o,r)=>n(o,"name",{value:r,configurable:!0});var u=(o,r)=>{for(var t in r)n(o,t,{get:r[t],enumerable:!0})},s=(o,r,t,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let p of f(r))!i.call(o,p)&&p!==t&&n(o,p,{get:()=>r[p],enumerable:!(c=a(r,p))||c.enumerable});return o};var x=o=>s(n({},"__esModule",{value:!0}),o);var q={};u(q,{smpRxjsSequence:()=>j});module.exports=x(q);var e=require("rxjs");function j(o){return(0,e.from)(o).pipe((0,e.concatMap)(r=>r()),(0,e.toArray)())}m(j,"smpRxjsSequence");0&&(module.exports={smpRxjsSequence});
2
+ //# sourceMappingURL=smp-rxjs-sequence.function.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/shared/rxjs/smp-rxjs-sequence.function.ts"],"sourcesContent":["import {concatMap, from, Observable, toArray} from \"rxjs\";\n\n/**\n * Old version of the sequence. Now rewritten using recursion, which is way faster.\n * But you can use this if you want to stick with the rxjs pattern.\n * Use smpRxjsQueue for better performance ;)\n * @param steps\n */\nexport function smpRxjsSequence<T = any>(steps: (() => Observable<T>)[]) {\n return from(steps).pipe(\n concatMap(step => step()),\n toArray()\n );\n}\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmD,gBAQ5C,SAASC,EAAyBC,EAA8B,CACnE,SAAOC,QAAKD,CAAAA,EAAOE,QACfC,aAAUC,GAAQA,EAAAA,CAAAA,KAClBC,WAAAA,CAAAA,CAER,CALgBN,EAAAA,EAAAA","names":["smp_rxjs_sequence_function_exports","__export","smpRxjsSequence","__toCommonJS","import_rxjs","smpRxjsSequence","steps","from","pipe","concatMap","step","toArray"]}
@@ -0,0 +1,11 @@
1
+ import { Observable } from 'rxjs';
2
+
3
+ /**
4
+ * Old version of the sequence. Now rewritten using recursion, which is way faster.
5
+ * But you can use this if you want to stick with the rxjs pattern.
6
+ * Use smpRxjsQueue for better performance ;)
7
+ * @param steps
8
+ */
9
+ declare function smpRxjsSequence<T = any>(steps: (() => Observable<T>)[]): Observable<T[]>;
10
+
11
+ export { smpRxjsSequence };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/shared/rxjs/smp-rxjs-throw-on-condition.function.ts","../../../../src/shared/rxjs/smp-rxjs-throw-if-empty.function.ts"],"sourcesContent":["import {defaultIfEmpty, filter, Observable, OperatorFunction} from \"rxjs\";\n//\nimport {smpRxjsThrowIfEmpty} from \"./smp-rxjs-throw-if-empty.function.js\";\n\n/**\n * Custom RxJS operator that filters the source observable based on a condition\n * and throws an error if the resulting observable is empty.\n *\n * @template T The type of items emitted by the source observable.\n * @param {function(T): boolean} condition - A function that takes a value from the source observable and returns a boolean.\n * If the function returns `true`, the value will be emitted; otherwise, it will be filtered out.\n * @param {function(): Error} [errorFactory] - An optional function that returns an error to be thrown if the resulting observable is empty.\n * If not provided, a default error will be thrown.\n * @returns {OperatorFunction<T, T>} An operator function that can be used in the RxJS pipeline.\n *\n * @example\n * import { of } from 'rxjs';\n * import { kikRxjsThrowOnCondition } from \"./path-to-your-file\";\n *\n * const source$ = of(1, 5, -3, 7, 12).pipe(\n * kikRxjsThrowOnCondition(value => value >= 0, () => new Error(\"Value is less than 0\")),\n * kikRxjsThrowOnCondition(value => value > 12, () => new Error(\"Value is lower than 12\"))\n * );\n *\n * source$.subscribe({\n * next: value => console.log(\"Value:\", value),\n * error: err => console.error(\"Error:\", err)\n * });\n */\nexport function smpRxjsThrowOnCondition<T>(\n condition: (value: T) => boolean,\n errorFactory?: () => any\n): OperatorFunction<T, T> {\n return (source: Observable<T>) =>\n source.pipe(\n filter((v: T) => !condition(v)), // Invert the condition because if I need to throw on that condition we should filter all that don't match\n defaultIfEmpty(false as unknown as T), // We nuke type errors, cause when falsy kikRxjsThrowIfEmpty will throw\n smpRxjsThrowIfEmpty(errorFactory)\n );\n}\n","import {map, Observable, OperatorFunction} from \"rxjs\";\n\n/**\n * If the source observable completes emitting an empty value (empty array or object will be considered empty), it will emit\n * an error. The error will be created at that time by the optional\n * `errorFactory` argument, otherwise, the error will be {@link Error}.\n *\n * ## Example\n *\n * Throw an error if the query didn't match anything\n *\n * ```ts\n * import { of, takeUntil, timer, throwIfEmpty } from 'rxjs';\n *\n * const query$ = of([]);\n *\n * query$.pipe(\n * smpRxjsThrowIfEmpty(() => new Error('The query had no results'))\n * )\n * .subscribe({\n * next() {\n * console.log(\"The query had results\");\n * },\n * error(err) {\n * console.error(err.message);\n * }\n * });\n * ```\n *\n * @param errorFactory A factory function called to produce the\n * error to be thrown when the source observable completes without emitting a\n * value.\n * @return A function that returns an Observable that throws an error if the\n * source Observable completed without emitting.\n */\nexport function smpRxjsThrowIfEmpty<T>(errorFactory: (value: T) => any = defaultErrorFactory): OperatorFunction<T, T> {\n return (source: Observable<T>) => source.pipe(\n map(v => {\n if (~emptyValues.indexOf(JSON.stringify(v))) {\n throw errorFactory(v);\n }\n\n return v;\n })\n );\n}\n\nconst emptyValues = [void 0, null, false, 0, \"\", \"0\", [], {}].map((v) =>\n JSON.stringify(v)\n);\n\nconst defaultErrorFactory = (): Error => new Error();\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmE,gBCAnE,IAAAC,EAAgD,gBAmCzC,SAASC,EAAuBC,EAAkCC,EAAmB,CACxF,OAAQC,GAA0BA,EAAOC,QACrCC,OAAIC,GAAAA,CACA,GAAI,CAACC,EAAYC,QAAQC,KAAKC,UAAUJ,CAAAA,CAAAA,EACpC,MAAML,EAAaK,CAAAA,EAGvB,OAAOA,CACX,CAAA,CAAA,CAER,CAVgBN,EAAAA,EAAAA,uBAYhB,IAAMO,EAAc,CAAC,OAAQ,KAAM,GAAO,EAAG,GAAI,IAAK,CAAA,EAAI,CAAC,GAAGF,IAAKC,GAC/DG,KAAKC,UAAUJ,CAAAA,CAAAA,EAGbJ,EAAsBS,EAAA,IAAa,IAAIC,MAAjB,uBDtBrB,SAASC,EACZC,EACAC,EAAwB,CAExB,OAAQC,GACJA,EAAOC,QACHC,UAAQC,GAAS,CAACL,EAAUK,CAAAA,CAAAA,KAC5BC,kBAAe,EAAA,EACfC,EAAoBN,CAAAA,CAAAA,CAEhC,CAVgBF,EAAAA,EAAAA","names":["smp_rxjs_throw_on_condition_function_exports","__export","smpRxjsThrowOnCondition","__toCommonJS","import_rxjs","import_rxjs","smpRxjsThrowIfEmpty","errorFactory","defaultErrorFactory","source","pipe","map","v","emptyValues","indexOf","JSON","stringify","__name","Error","smpRxjsThrowOnCondition","condition","errorFactory","source","pipe","filter","v","defaultIfEmpty","smpRxjsThrowIfEmpty"]}
1
+ {"version":3,"sources":["../../../../src/shared/rxjs/smp-rxjs-throw-on-condition.function.ts","../../../../src/shared/rxjs/smp-rxjs-throw-if-empty.function.ts"],"sourcesContent":["import {defaultIfEmpty, filter, Observable, OperatorFunction} from \"rxjs\";\n//\nimport {smpRxjsThrowIfEmpty} from \"./smp-rxjs-throw-if-empty.function.js\";\n\n/**\n * Custom RxJS operator that filters the source observable based on a condition\n * and throws an error if the resulting observable is empty.\n *\n * @template T The type of items emitted by the source observable.\n * @param {function(T): boolean} condition - A function that takes a value from the source observable and returns a boolean.\n * If the function returns `true`, the value will be emitted; otherwise, it will be filtered out.\n * @param {function(): Error} [errorFactory] - An optional function that returns an error to be thrown if the resulting observable is empty.\n * If not provided, a default error will be thrown.\n * @returns {OperatorFunction<T, T>} An operator function that can be used in the RxJS pipeline.\n *\n * @example\n * import { of } from 'rxjs';\n * import { smpRxjsThrowOnCondition } from \"./path-to-your-file\";\n *\n * const source$ = of(1, 5, -3, 7, 12).pipe(\n * smpRxjsThrowOnCondition(value => value >= 0, () => new Error(\"Value is less than 0\")),\n * smpRxjsThrowOnCondition(value => value > 12, () => new Error(\"Value is lower than 12\"))\n * );\n *\n * source$.subscribe({\n * next: value => console.log(\"Value:\", value),\n * error: err => console.error(\"Error:\", err)\n * });\n */\nexport function smpRxjsThrowOnCondition<T>(\n condition: (value: T) => boolean,\n errorFactory?: () => any\n): OperatorFunction<T, T> {\n return (source: Observable<T>) =>\n source.pipe(\n filter((v: T) => !condition(v)), // Invert the condition because if I need to throw on that condition we should filter all that don't match\n defaultIfEmpty(false as unknown as T), // We nuke type errors, cause when falsy smpRxjsThrowIfEmpty will throw\n smpRxjsThrowIfEmpty(errorFactory)\n );\n}\n","import {map, Observable, OperatorFunction} from \"rxjs\";\n\n/**\n * If the source observable completes emitting an empty value (empty array or object will be considered empty), it will emit\n * an error. The error will be created at that time by the optional\n * `errorFactory` argument, otherwise, the error will be {@link Error}.\n *\n * ## Example\n *\n * Throw an error if the query didn't match anything\n *\n * ```ts\n * import { of, takeUntil, timer, throwIfEmpty } from 'rxjs';\n *\n * const query$ = of([]);\n *\n * query$.pipe(\n * smpRxjsThrowIfEmpty(() => new Error('The query had no results'))\n * )\n * .subscribe({\n * next() {\n * console.log(\"The query had results\");\n * },\n * error(err) {\n * console.error(err.message);\n * }\n * });\n * ```\n *\n * @param errorFactory A factory function called to produce the\n * error to be thrown when the source observable completes without emitting a\n * value.\n * @return A function that returns an Observable that throws an error if the\n * source Observable completed without emitting.\n */\nexport function smpRxjsThrowIfEmpty<T>(errorFactory: (value: T) => any = defaultErrorFactory): OperatorFunction<T, T> {\n return (source: Observable<T>) => source.pipe(\n map(v => {\n if (~emptyValues.indexOf(JSON.stringify(v))) {\n throw errorFactory(v);\n }\n\n return v;\n })\n );\n}\n\nconst emptyValues = [void 0, null, false, 0, \"\", \"0\", [], {}].map((v) =>\n JSON.stringify(v)\n);\n\nconst defaultErrorFactory = (): Error => new Error();\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmE,gBCAnE,IAAAC,EAAgD,gBAmCzC,SAASC,EAAuBC,EAAkCC,EAAmB,CACxF,OAAQC,GAA0BA,EAAOC,QACrCC,OAAIC,GAAAA,CACA,GAAI,CAACC,EAAYC,QAAQC,KAAKC,UAAUJ,CAAAA,CAAAA,EACpC,MAAML,EAAaK,CAAAA,EAGvB,OAAOA,CACX,CAAA,CAAA,CAER,CAVgBN,EAAAA,EAAAA,uBAYhB,IAAMO,EAAc,CAAC,OAAQ,KAAM,GAAO,EAAG,GAAI,IAAK,CAAA,EAAI,CAAC,GAAGF,IAAKC,GAC/DG,KAAKC,UAAUJ,CAAAA,CAAAA,EAGbJ,EAAsBS,EAAA,IAAa,IAAIC,MAAjB,uBDtBrB,SAASC,EACZC,EACAC,EAAwB,CAExB,OAAQC,GACJA,EAAOC,QACHC,UAAQC,GAAS,CAACL,EAAUK,CAAAA,CAAAA,KAC5BC,kBAAe,EAAA,EACfC,EAAoBN,CAAAA,CAAAA,CAEhC,CAVgBF,EAAAA,EAAAA","names":["smp_rxjs_throw_on_condition_function_exports","__export","smpRxjsThrowOnCondition","__toCommonJS","import_rxjs","import_rxjs","smpRxjsThrowIfEmpty","errorFactory","defaultErrorFactory","source","pipe","map","v","emptyValues","indexOf","JSON","stringify","__name","Error","smpRxjsThrowOnCondition","condition","errorFactory","source","pipe","filter","v","defaultIfEmpty","smpRxjsThrowIfEmpty"]}
@@ -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,2 +1,2 @@
1
- "use strict";var p=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var i=(r,e)=>p(r,"name",{value:e,configurable:!0});var l=(r,e)=>{for(var t in e)p(r,t,{get:e[t],enumerable:!0})},d=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of w(e))!x.call(r,o)&&o!==t&&p(r,o,{get:()=>e[o],enumerable:!(s=u(e,o))||s.enumerable});return r};var g=r=>d(p({},"__esModule",{value:!0}),r);var R={};l(R,{SmpAbstractCacheStrategy:()=>h,SmpAbstractTtlCacheStrategy:()=>a,SmpBrowserCache:()=>_,SmpInMemoryCache:()=>c,smpIsSmpCachedValue:()=>f});module.exports=g(R);var n=require("ts-luxon");var h=class{static{i(this,"SmpAbstractCacheStrategy")}};function f(r){return typeof r=="object"&&r!==null&&"value"in r&&"expiry"in r&&typeof r.expiry=="number"}i(f,"smpIsSmpCachedValue");var a=class extends h{static{i(this,"SmpAbstractTtlCacheStrategy")}flush(){this._flushRaw()}read(e){let t=this._readRaw(e);if(this._isSmpCachedValue(t)){if(t.expiry>=n.DateTime.now().ts)return t.value;this._removeRaw(e);return}return t}remove(e){this._removeRaw(e)}write(e,t,s){if(isNaN(+s)||+s<=0){this._writeRaw(e,t,s);return}let o=n.DateTime.now().ts+s*1e3,m={value:t,expiry:o};this._writeRaw(e,m,s)}_isSmpCachedValue(e){return f(e)}};var _=class extends a{static{i(this,"SmpBrowserCache")}_storage;_prefix;constructor(e,t){super(),this._storage=e,this._prefix=t}_flushRaw(){let e=[],t=-1;for(;++t<this._storage.length;){let s=this._storage.key(t);s&&s.startsWith(this._prefix)&&e.push(s)}for(t=-1;++t<e.length;)this._storage.removeItem(e[t])}_readRaw(e){let t=this._storage.getItem(this._prefix+e);try{return t?JSON.parse(t):void 0}catch{console.warn(`${this.constructor.name}: failed to parse cache item for key ${this._prefix+e}`);return}}_removeRaw(e){this._storage.removeItem(this._prefix+e)}_writeRaw(e,t){try{this._storage.setItem(this._prefix+e,JSON.stringify(t))}catch(s){console.warn(`${this.constructor.name}: failed to write cache item for key ${this._prefix+e}`,s)}}};var c=class extends a{static{i(this,"SmpInMemoryCache")}static _storage=new Map;get _staticSelf(){return this.constructor}_flushRaw(){this._staticSelf._storage.clear()}_readRaw(e){return this._staticSelf._storage.get(e)}_removeRaw(e){this._staticSelf._storage.delete(e)}_writeRaw(e,t){this._staticSelf._storage.set(e,t)}};0&&(module.exports={SmpAbstractCacheStrategy,SmpAbstractTtlCacheStrategy,SmpBrowserCache,SmpInMemoryCache,smpIsSmpCachedValue});
1
+ "use strict";var p=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var i=(r,e)=>p(r,"name",{value:e,configurable:!0});var x=(r,e)=>{for(var t in e)p(r,t,{get:e[t],enumerable:!0})},d=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of w(e))!l.call(r,o)&&o!==t&&p(r,o,{get:()=>e[o],enumerable:!(s=u(e,o))||s.enumerable});return r};var g=r=>d(p({},"__esModule",{value:!0}),r);var R={};x(R,{SmpAbstractCacheStrategy:()=>h,SmpAbstractTtlCacheStrategy:()=>a,SmpBrowserCache:()=>c,SmpInMemoryCache:()=>f,smpIsSmpCachedValue:()=>n});module.exports=g(R);var h=class{static{i(this,"SmpAbstractCacheStrategy")}};var _=require("ts-luxon");function n(r){return typeof r=="object"&&r!==null&&"value"in r&&"expiry"in r&&typeof r.expiry=="number"}i(n,"smpIsSmpCachedValue");var a=class extends h{static{i(this,"SmpAbstractTtlCacheStrategy")}flush(){this._flushRaw()}read(e){let t=this._readRaw(e);if(this._isSmpCachedValue(t)){if(t.expiry>=_.DateTime.now().ts)return t.value;this._removeRaw(e);return}return t}remove(e){this._removeRaw(e)}write(e,t,s){if(isNaN(+s)||+s<=0){this._writeRaw(e,t,s);return}let o=_.DateTime.now().ts+s*1e3,m={value:t,expiry:o};this._writeRaw(e,m,s)}_isSmpCachedValue(e){return n(e)}};var c=class extends a{static{i(this,"SmpBrowserCache")}_storage;_prefix;constructor(e,t){super(),this._storage=e,this._prefix=t}_flushRaw(){let e=[],t=-1;for(;++t<this._storage.length;){let s=this._storage.key(t);s&&s.startsWith(this._prefix)&&e.push(s)}for(t=-1;++t<e.length;)this._storage.removeItem(e[t])}_readRaw(e){let t=this._storage.getItem(this._prefix+e);try{return t?JSON.parse(t):void 0}catch{console.warn(`${this.constructor.name}: failed to parse cache item for key ${this._prefix+e}`);return}}_removeRaw(e){this._storage.removeItem(this._prefix+e)}_writeRaw(e,t){try{this._storage.setItem(this._prefix+e,JSON.stringify(t))}catch(s){console.warn(`${this.constructor.name}: failed to write cache item for key ${this._prefix+e}`,s)}}};var f=class extends a{static{i(this,"SmpInMemoryCache")}static _storage=new Map;get _staticSelf(){return this.constructor}_flushRaw(){this._staticSelf._storage.clear()}_readRaw(e){return this._staticSelf._storage.get(e)}_removeRaw(e){this._staticSelf._storage.delete(e)}_writeRaw(e,t){this._staticSelf._storage.set(e,t)}};0&&(module.exports={SmpAbstractCacheStrategy,SmpAbstractTtlCacheStrategy,SmpBrowserCache,SmpInMemoryCache,smpIsSmpCachedValue});
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/shared/utils/cache/index.ts","../../../../../src/shared/utils/cache/smp-abstract-ttl-cache-strategy.class.ts","../../../../../src/shared/utils/cache/smp-abstract-cache-strategy.class.ts","../../../../../src/shared/utils/cache/smp-is-smp-cached-value.function.ts","../../../../../src/shared/utils/cache/smp-browser-cache.class.ts","../../../../../src/shared/utils/cache/smp-in-memory-cache.class.ts"],"sourcesContent":["export * from \"./smp-browser-cache.class.js\";\nexport * from \"./smp-cache-strategy.interface.js\";\nexport * from \"./smp-cached-value.interface.js\";\nexport * from \"./smp-abstract-cache-strategy.class.js\";\nexport * from \"./smp-abstract-ttl-cache-strategy.class.js\";\nexport * from \"./smp-in-memory-cache.class.js\";\nexport * from \"./smp-is-smp-cached-value.function.js\";\n","import {DateTime} from \"ts-luxon\";\n//\nimport {SmpAbstractCacheStrategy} from \"./smp-abstract-cache-strategy.class.js\";\nimport {SmpCachedValue} from \"./smp-cached-value.interface.js\";\nimport {smpIsSmpCachedValue} from \"./smp-is-smp-cached-value.function.js\";\n\nexport abstract class SmpAbstractTtlCacheStrategy extends SmpAbstractCacheStrategy {\n\n protected abstract _flushRaw(): void;\n\n protected abstract _readRaw(key: string): unknown | undefined;\n\n protected abstract _removeRaw(key: string): void;\n\n protected abstract _writeRaw(key: string, value: unknown, ttl?: number): void;\n\n flush(): void {\n this._flushRaw();\n }\n\n read<T = unknown>(key: string): T | undefined {\n const storedValue = this._readRaw(key);\n if (this._isSmpCachedValue<T>(storedValue)) {\n if (storedValue.expiry >= DateTime.now().ts) {\n return storedValue.value as T;\n }\n this._removeRaw(key);\n\n return void 0;\n }\n return storedValue as T | undefined;\n }\n\n remove(key: string): void {\n this._removeRaw(key);\n }\n\n\n write<T = unknown>(key: string, value: T, ttl?: number): void {\n if (isNaN(+ttl!) || +ttl! <= 0) {\n this._writeRaw(key, value, ttl);\n return;\n }\n const expiry = DateTime.now().ts + ttl! * 1000;\n const wrappedValue: SmpCachedValue<T> = {\n value: value,\n expiry: expiry\n };\n this._writeRaw(key, wrappedValue, ttl);\n }\n\n protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return smpIsSmpCachedValue(value);\n }\n}\n","import {Observable} from \"rxjs\";\n\nexport abstract class SmpAbstractCacheStrategy {\n abstract read<T = unknown>(key: string): T | undefined | Observable<T | undefined>;\n\n abstract write<T = unknown>(key: string, value: T, ttl?: number): void | Observable<void>;\n\n abstract remove(key: string): void | Observable<void>;\n\n abstract flush(): void | Observable<void>;\n}\n","import {SmpCachedValue} from \"./smp-cached-value.interface\";\n\n/**\n * Tells you if a value is a SmpCachedValue\n * @param value\n */\nexport function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n \"expiry\" in value &&\n typeof (value as any).expiry === \"number\"\n );\n}\n","import {SmpAbstractTtlCacheStrategy} from \"./smp-abstract-ttl-cache-strategy.class.js\";\n\nexport class SmpBrowserCache extends SmpAbstractTtlCacheStrategy {\n\n constructor(protected _storage: typeof localStorage | typeof sessionStorage,\n protected _prefix: string) {\n super();\n }\n\n protected _flushRaw(): void {\n const keysToRemove: string[] = [];\n let i = -1;\n while (++i < this._storage.length) {\n const key = this._storage.key(i);\n if (key && key.startsWith(this._prefix)) {\n keysToRemove.push(key);\n }\n }\n i = -1;\n while (++i < keysToRemove.length) {\n this._storage.removeItem(keysToRemove[i]);\n }\n }\n\n protected _readRaw(key: string): unknown | undefined {\n const raw = this._storage.getItem(this._prefix + key);\n try {\n return raw ? JSON.parse(raw) : undefined;\n }\n catch {\n console.warn(`${this.constructor.name}: failed to parse cache item for key ${this._prefix + key}`);\n\n return void 0;\n }\n }\n\n protected _removeRaw(key: string): void {\n this._storage.removeItem(this._prefix + key);\n }\n\n protected _writeRaw(key: string, value: unknown): void {\n try {\n this._storage.setItem(this._prefix + key, JSON.stringify(value));\n }\n catch (e) {\n console.warn(`${this.constructor.name}: failed to write cache item for key ${this._prefix + key}`, e);\n }\n }\n\n}\n\n\n","import {SmpAbstractTtlCacheStrategy} from \"./smp-abstract-ttl-cache-strategy.class.js\";\n\nexport class SmpInMemoryCache extends SmpAbstractTtlCacheStrategy {\n\n private static _storage = new Map<string, unknown>();\n\n protected get _staticSelf(): typeof SmpInMemoryCache {\n return (this.constructor as typeof SmpInMemoryCache);\n }\n\n protected _flushRaw(): void {\n this._staticSelf._storage.clear();\n }\n\n protected _readRaw(key: string): unknown | undefined {\n return this._staticSelf._storage.get(key);\n }\n\n protected _removeRaw(key: string): void {\n this._staticSelf._storage.delete(key);\n }\n\n protected _writeRaw(key: string, value: unknown): void {\n this._staticSelf._storage.set(key, value);\n }\n\n}\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,gCAAAC,EAAA,oBAAAC,EAAA,qBAAAC,EAAA,wBAAAC,IAAA,eAAAC,EAAAP,GCAA,IAAAQ,EAAuB,oBCEhB,IAAeC,EAAf,KAAeA,CAAtB,MAAsBA,CAAAA,EAAAA,iCAQtB,ECJO,SAASC,EAAuBC,EAAc,CACjD,OACI,OAAOA,GAAU,UACjBA,IAAU,MACV,UAAWA,GACX,WAAYA,GACZ,OAAQA,EAAcC,QAAW,QAEzC,CARgBF,EAAAA,EAAAA,uBFAT,IAAe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CAEUM,SAASJ,EAAkC,CACjD,IAAMK,EAAM,KAAKX,SAASY,QAAQ,KAAKX,QAAUK,CAAAA,EACjD,GAAI,CACA,OAAOK,EAAME,KAAKC,MAAMH,CAAAA,EAAOI,MACnC,MACM,CACFC,QAAQC,KAAK,GAAG,KAAKlB,YAAYmB,IAAI,wCAAwC,KAAKjB,QAAUK,CAAAA,EAAK,EAEjG,MACJ,CACJ,CAEUa,WAAWb,EAAmB,CACpC,KAAKN,SAASS,WAAW,KAAKR,QAAUK,CAAAA,CAC5C,CAEUc,UAAUd,EAAae,EAAsB,CACnD,GAAI,CACA,KAAKrB,SAASsB,QAAQ,KAAKrB,QAAUK,EAAKO,KAAKU,UAAUF,CAAAA,CAAAA,CAC7D,OACOG,EAAG,CACNR,QAAQC,KAAK,GAAG,KAAKlB,YAAYmB,IAAI,wCAAwC,KAAKjB,QAAUK,CAAAA,GAAOkB,CAAAA,CACvG,CACJ,CAEJ,EC/CO,IAAMC,EAAN,cAA+BC,CAAAA,CAFtC,MAEsCA,CAAAA,EAAAA,yBAElC,OAAeC,SAAW,IAAIC,IAE9B,IAAcC,aAAuC,CACjD,OAAQ,KAAKC,WACjB,CAEUC,WAAkB,CACxB,KAAKF,YAAYF,SAASK,MAAK,CACnC,CAEUC,SAASC,EAAkC,CACjD,OAAO,KAAKL,YAAYF,SAASQ,IAAID,CAAAA,CACzC,CAEUE,WAAWF,EAAmB,CACpC,KAAKL,YAAYF,SAASU,OAAOH,CAAAA,CACrC,CAEUI,UAAUJ,EAAaK,EAAsB,CACnD,KAAKV,YAAYF,SAASa,IAAIN,EAAKK,CAAAA,CACvC,CAEJ","names":["cache_exports","__export","SmpAbstractCacheStrategy","SmpAbstractTtlCacheStrategy","SmpBrowserCache","SmpInMemoryCache","smpIsSmpCachedValue","__toCommonJS","import_ts_luxon","SmpAbstractCacheStrategy","smpIsSmpCachedValue","value","expiry","SmpAbstractTtlCacheStrategy","SmpAbstractCacheStrategy","flush","_flushRaw","read","key","storedValue","_readRaw","_isSmpCachedValue","expiry","DateTime","now","ts","value","_removeRaw","remove","write","ttl","isNaN","_writeRaw","wrappedValue","smpIsSmpCachedValue","SmpBrowserCache","SmpAbstractTtlCacheStrategy","constructor","_storage","_prefix","_flushRaw","keysToRemove","i","length","key","startsWith","push","removeItem","_readRaw","raw","getItem","JSON","parse","undefined","console","warn","name","_removeRaw","_writeRaw","value","setItem","stringify","e","SmpInMemoryCache","SmpAbstractTtlCacheStrategy","_storage","Map","_staticSelf","constructor","_flushRaw","clear","_readRaw","key","get","_removeRaw","delete","_writeRaw","value","set"]}
1
+ {"version":3,"sources":["../../../../../src/shared/utils/cache/index.ts","../../../../../src/shared/utils/cache/smp-abstract-cache-strategy.class.ts","../../../../../src/shared/utils/cache/smp-abstract-ttl-cache-strategy.class.ts","../../../../../src/shared/utils/cache/smp-is-smp-cached-value.function.ts","../../../../../src/shared/utils/cache/smp-browser-cache.class.ts","../../../../../src/shared/utils/cache/smp-in-memory-cache.class.ts"],"sourcesContent":["export * from \"./smp-abstract-cache-strategy.class.js\";\nexport * from \"./smp-abstract-ttl-cache-strategy.class.js\";\nexport * from \"./smp-browser-cache.class.js\";\nexport * from \"./smp-cached-value.interface.js\";\nexport * from \"./smp-in-memory-cache.class.js\";\nexport * from \"./smp-is-smp-cached-value.function.js\";\n","import {Observable} from \"rxjs\";\n\nexport abstract class SmpAbstractCacheStrategy {\n abstract read<T = unknown>(key: string): T | undefined | Observable<T | undefined>;\n\n abstract write<T = unknown>(key: string, value: T, ttl?: number): void | Observable<void>;\n\n abstract remove(key: string): void | Observable<void>;\n\n abstract flush(): void | Observable<void>;\n}\n","import {DateTime} from \"ts-luxon\";\n//\nimport {SmpAbstractCacheStrategy} from \"./smp-abstract-cache-strategy.class.js\";\nimport {SmpCachedValue} from \"./smp-cached-value.interface.js\";\nimport {smpIsSmpCachedValue} from \"./smp-is-smp-cached-value.function.js\";\n\nexport abstract class SmpAbstractTtlCacheStrategy extends SmpAbstractCacheStrategy {\n\n protected abstract _flushRaw(): void;\n\n protected abstract _readRaw(key: string): unknown | undefined;\n\n protected abstract _removeRaw(key: string): void;\n\n protected abstract _writeRaw(key: string, value: unknown, ttl?: number): void;\n\n flush(): void {\n this._flushRaw();\n }\n\n read<T = unknown>(key: string): T | undefined {\n const storedValue = this._readRaw(key);\n if (this._isSmpCachedValue<T>(storedValue)) {\n if (storedValue.expiry >= DateTime.now().ts) {\n return storedValue.value as T;\n }\n this._removeRaw(key);\n\n return void 0;\n }\n return storedValue as T | undefined;\n }\n\n remove(key: string): void {\n this._removeRaw(key);\n }\n\n\n write<T = unknown>(key: string, value: T, ttl?: number): void {\n if (isNaN(+ttl!) || +ttl! <= 0) {\n this._writeRaw(key, value, ttl);\n return;\n }\n const expiry = DateTime.now().ts + ttl! * 1000;\n const wrappedValue: SmpCachedValue<T> = {\n value: value,\n expiry: expiry\n };\n this._writeRaw(key, wrappedValue, ttl);\n }\n\n protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return smpIsSmpCachedValue(value);\n }\n}\n","import {SmpCachedValue} from \"./smp-cached-value.interface.js\";\n\n/**\n * Tells you if a value is a SmpCachedValue\n * @param value\n */\nexport function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n \"expiry\" in value &&\n typeof (value as any).expiry === \"number\"\n );\n}\n","import {SmpAbstractTtlCacheStrategy} from \"./smp-abstract-ttl-cache-strategy.class.js\";\n\nexport class SmpBrowserCache extends SmpAbstractTtlCacheStrategy {\n\n constructor(protected _storage: typeof localStorage | typeof sessionStorage,\n protected _prefix: string) {\n super();\n }\n\n protected _flushRaw(): void {\n const keysToRemove: string[] = [];\n let i = -1;\n while (++i < this._storage.length) {\n const key = this._storage.key(i);\n if (key && key.startsWith(this._prefix)) {\n keysToRemove.push(key);\n }\n }\n i = -1;\n while (++i < keysToRemove.length) {\n this._storage.removeItem(keysToRemove[i]);\n }\n }\n\n protected _readRaw(key: string): unknown | undefined {\n const raw = this._storage.getItem(this._prefix + key);\n try {\n return raw ? JSON.parse(raw) : undefined;\n }\n catch {\n console.warn(`${this.constructor.name}: failed to parse cache item for key ${this._prefix + key}`);\n\n return void 0;\n }\n }\n\n protected _removeRaw(key: string): void {\n this._storage.removeItem(this._prefix + key);\n }\n\n protected _writeRaw(key: string, value: unknown): void {\n try {\n this._storage.setItem(this._prefix + key, JSON.stringify(value));\n }\n catch (e) {\n console.warn(`${this.constructor.name}: failed to write cache item for key ${this._prefix + key}`, e);\n }\n }\n\n}\n\n\n","import {SmpAbstractTtlCacheStrategy} from \"./smp-abstract-ttl-cache-strategy.class.js\";\n\nexport class SmpInMemoryCache extends SmpAbstractTtlCacheStrategy {\n\n private static _storage = new Map<string, unknown>();\n\n protected get _staticSelf(): typeof SmpInMemoryCache {\n return (this.constructor as typeof SmpInMemoryCache);\n }\n\n protected _flushRaw(): void {\n this._staticSelf._storage.clear();\n }\n\n protected _readRaw(key: string): unknown | undefined {\n return this._staticSelf._storage.get(key);\n }\n\n protected _removeRaw(key: string): void {\n this._staticSelf._storage.delete(key);\n }\n\n protected _writeRaw(key: string, value: unknown): void {\n this._staticSelf._storage.set(key, value);\n }\n\n}\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,gCAAAC,EAAA,oBAAAC,EAAA,qBAAAC,EAAA,wBAAAC,IAAA,eAAAC,EAAAP,GCEO,IAAeQ,EAAf,KAAeA,CAAtB,MAAsBA,CAAAA,EAAAA,iCAQtB,ECVA,IAAAC,EAAuB,oBCMhB,SAASC,EAAuBC,EAAc,CACjD,OACI,OAAOA,GAAU,UACjBA,IAAU,MACV,UAAWA,GACX,WAAYA,GACZ,OAAQA,EAAcC,QAAW,QAEzC,CARgBF,EAAAA,EAAAA,uBDAT,IAAeG,EAAf,cAAmDC,CAAAA,CAN1D,MAM0DA,CAAAA,EAAAA,oCAUtDC,OAAc,CACV,KAAKC,UA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ACjD,GAAI,CACA,OAAOK,EAAME,KAAKC,MAAMH,CAAAA,EAAOI,MACnC,MACM,CACFC,QAAQC,KAAK,GAAG,KAAKlB,YAAYmB,IAAI,wCAAwC,KAAKjB,QAAUK,CAAAA,EAAK,EAEjG,MACJ,CACJ,CAEUa,WAAWb,EAAmB,CACpC,KAAKN,SAASS,WAAW,KAAKR,QAAUK,CAAAA,CAC5C,CAEUc,UAAUd,EAAae,EAAsB,CACnD,GAAI,CACA,KAAKrB,SAASsB,QAAQ,KAAKrB,QAAUK,EAAKO,KAAKU,UAAUF,CAAAA,CAAAA,CAC7D,OACOG,EAAG,CACNR,QAAQC,KAAK,GAAG,KAAKlB,YAAYmB,IAAI,wCAAwC,KAAKjB,QAAUK,CAAAA,GAAOkB,CAAAA,CACvG,CACJ,CAEJ,EC/CO,IAAMC,EAAN,cAA+BC,CAAAA,CAFtC,MAEsCA,CAAAA,EAAAA,yBAElC,OAAeC,SAAW,IAAIC,IAE9B,IAAcC,aAAuC,CACjD,OAAQ,KAAKC,WACjB,CAEUC,WAAkB,CACxB,KAAKF,YAAYF,SAASK,MAAK,CACnC,CAEUC,SAASC,EAAkC,CACjD,OAAO,KAAKL,YAAYF,SAASQ,IAAID,CAAAA,CACzC,CAEUE,WAAWF,EAAmB,CACpC,KAAKL,YAAYF,SAASU,OAAOH,CAAAA,CACrC,CAEUI,UAAUJ,EAAaK,EAAsB,CACnD,KAAKV,YAAYF,SAASa,IAAIN,EAAKK,CAAAA,CACvC,CAEJ","names":["cache_exports","__export","SmpAbstractCacheStrategy","SmpAbstractTtlCacheStrategy","SmpBrowserCache","SmpInMemoryCache","smpIsSmpCachedValue","__toCommonJS","SmpAbstractCacheStrategy","import_ts_luxon","smpIsSmpCachedValue","value","expiry","SmpAbstractTtlCacheStrategy","SmpAbstractCacheStrategy","flush","_flushRaw","read","key","storedValue","_readRaw","_isSmpCachedValue","expiry","DateTime","now","ts","value","_removeRaw","remove","write","ttl","isNaN","_writeRaw","wrappedValue","smpIsSmpCachedValue","SmpBrowserCache","SmpAbstractTtlCacheStrategy","constructor","_storage","_prefix","_flushRaw","keysToRemove","i","length","key","startsWith","push","removeItem","_readRaw","raw","getItem","JSON","parse","undefined","console","warn","name","_removeRaw","_writeRaw","value","setItem","stringify","e","SmpInMemoryCache","SmpAbstractTtlCacheStrategy","_storage","Map","_staticSelf","constructor","_flushRaw","clear","_readRaw","key","get","_removeRaw","delete","_writeRaw","value","set"]}
@@ -1,8 +1,7 @@
1
- export { SmpBrowserCache } from './smp-browser-cache.class.cjs';
2
- export { SmpCacheStrategy } from './smp-cache-strategy.interface.cjs';
3
- export { SmpCachedValue } from './smp-cached-value.interface.cjs';
4
1
  export { SmpAbstractCacheStrategy } from './smp-abstract-cache-strategy.class.cjs';
5
2
  export { SmpAbstractTtlCacheStrategy } from './smp-abstract-ttl-cache-strategy.class.cjs';
3
+ export { SmpBrowserCache } from './smp-browser-cache.class.cjs';
4
+ export { SmpCachedValue } from './smp-cached-value.interface.cjs';
6
5
  export { SmpInMemoryCache } from './smp-in-memory-cache.class.cjs';
7
6
  export { smpIsSmpCachedValue } from './smp-is-smp-cached-value.function.cjs';
8
7
  import 'rxjs';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/shared/utils/cache/smp-abstract-ttl-cache-strategy.class.ts","../../../../../src/shared/utils/cache/smp-abstract-cache-strategy.class.ts","../../../../../src/shared/utils/cache/smp-is-smp-cached-value.function.ts"],"sourcesContent":["import {DateTime} from \"ts-luxon\";\n//\nimport {SmpAbstractCacheStrategy} from \"./smp-abstract-cache-strategy.class.js\";\nimport {SmpCachedValue} from \"./smp-cached-value.interface.js\";\nimport {smpIsSmpCachedValue} from \"./smp-is-smp-cached-value.function.js\";\n\nexport abstract class SmpAbstractTtlCacheStrategy extends SmpAbstractCacheStrategy {\n\n protected abstract _flushRaw(): void;\n\n protected abstract _readRaw(key: string): unknown | undefined;\n\n protected abstract _removeRaw(key: string): void;\n\n protected abstract _writeRaw(key: string, value: unknown, ttl?: number): void;\n\n flush(): void {\n this._flushRaw();\n }\n\n read<T = unknown>(key: string): T | undefined {\n const storedValue = this._readRaw(key);\n if (this._isSmpCachedValue<T>(storedValue)) {\n if (storedValue.expiry >= DateTime.now().ts) {\n return storedValue.value as T;\n }\n this._removeRaw(key);\n\n return void 0;\n }\n return storedValue as T | undefined;\n }\n\n remove(key: string): void {\n this._removeRaw(key);\n }\n\n\n write<T = unknown>(key: string, value: T, ttl?: number): void {\n if (isNaN(+ttl!) || +ttl! <= 0) {\n this._writeRaw(key, value, ttl);\n return;\n }\n const expiry = DateTime.now().ts + ttl! * 1000;\n const wrappedValue: SmpCachedValue<T> = {\n value: value,\n expiry: expiry\n };\n this._writeRaw(key, wrappedValue, ttl);\n }\n\n protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return smpIsSmpCachedValue(value);\n }\n}\n","import {Observable} from \"rxjs\";\n\nexport abstract class SmpAbstractCacheStrategy {\n abstract read<T = unknown>(key: string): T | undefined | Observable<T | undefined>;\n\n abstract write<T = unknown>(key: string, value: T, ttl?: number): void | Observable<void>;\n\n abstract remove(key: string): void | Observable<void>;\n\n abstract flush(): void | Observable<void>;\n}\n","import {SmpCachedValue} from \"./smp-cached-value.interface\";\n\n/**\n * Tells you if a value is a SmpCachedValue\n * @param value\n */\nexport function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n \"expiry\" in value &&\n typeof (value as any).expiry === \"number\"\n );\n}\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAuB,oBCEhB,IAAeC,EAAf,KAAeA,CAAtB,MAAsBA,CAAAA,EAAAA,iCAQtB,ECJO,SAASC,EAAuBC,EAAc,CACjD,OACI,OAAOA,GAAU,UACjBA,IAAU,MACV,UAAWA,GACX,WAAYA,GACZ,OAAQA,EAAcC,QAAW,QAEzC,CARgBF,EAAAA,EAAAA,uBFAT,IAAeG,EAAf,cAAmDC,CAAAA,CAN1D,MAM0DA,CAAAA,EAAAA,oCAUtDC,OAAc,CACV,KAAKC,UAAS,CAClB,CAEAC,KAAkBC,EAA4B,CAC1C,IAAMC,EAAc,KAAKC,SAASF,CAAAA,EAClC,GAAI,KAAKG,kBAAqBF,CAAAA,EAAc,CACxC,GAAIA,EAAYG,QAAUC,WAASC,IAAG,EAAGC,GACrC,OAAON,EAAYO,MAEvB,KAAKC,WAAWT,CAAAA,EAEhB,MACJ,CACA,OAAOC,CACX,CAEAS,OAAOV,EAAmB,CACtB,KAAKS,WAAWT,CAAAA,CACpB,CAGAW,MAAmBX,EAAaQ,EAAUI,EAAoB,CAC1D,GAAIC,MAAM,CAACD,CAAAA,GAAS,CAACA,GAAQ,EAAG,CAC5B,KAAKE,UAAUd,EAAKQ,EAAOI,CAAAA,EAC3B,MACJ,CACA,IAAMR,EAASC,WAASC,IAAG,EAAGC,GAAKK,EAAO,IACpCG,EAAkC,CACpCP,MAAOA,EACPJ,OAAQA,CACZ,EACA,KAAKU,UAAUd,EAAKe,EAAcH,CAAAA,CACtC,CAEUT,kBAAqBK,EAA4C,CACvE,OAAOQ,EAAoBR,CAAAA,CAC/B,CACJ","names":["smp_abstract_ttl_cache_strategy_class_exports","__export","SmpAbstractTtlCacheStrategy","__toCommonJS","import_ts_luxon","SmpAbstractCacheStrategy","smpIsSmpCachedValue","value","expiry","SmpAbstractTtlCacheStrategy","SmpAbstractCacheStrategy","flush","_flushRaw","read","key","storedValue","_readRaw","_isSmpCachedValue","expiry","DateTime","now","ts","value","_removeRaw","remove","write","ttl","isNaN","_writeRaw","wrappedValue","smpIsSmpCachedValue"]}
1
+ {"version":3,"sources":["../../../../../src/shared/utils/cache/smp-abstract-ttl-cache-strategy.class.ts","../../../../../src/shared/utils/cache/smp-abstract-cache-strategy.class.ts","../../../../../src/shared/utils/cache/smp-is-smp-cached-value.function.ts"],"sourcesContent":["import {DateTime} from \"ts-luxon\";\n//\nimport {SmpAbstractCacheStrategy} from \"./smp-abstract-cache-strategy.class.js\";\nimport {SmpCachedValue} from \"./smp-cached-value.interface.js\";\nimport {smpIsSmpCachedValue} from \"./smp-is-smp-cached-value.function.js\";\n\nexport abstract class SmpAbstractTtlCacheStrategy extends SmpAbstractCacheStrategy {\n\n protected abstract _flushRaw(): void;\n\n protected abstract _readRaw(key: string): unknown | undefined;\n\n protected abstract _removeRaw(key: string): void;\n\n protected abstract _writeRaw(key: string, value: unknown, ttl?: number): void;\n\n flush(): void {\n this._flushRaw();\n }\n\n read<T = unknown>(key: string): T | undefined {\n const storedValue = this._readRaw(key);\n if (this._isSmpCachedValue<T>(storedValue)) {\n if (storedValue.expiry >= DateTime.now().ts) {\n return storedValue.value as T;\n }\n this._removeRaw(key);\n\n return void 0;\n }\n return storedValue as T | undefined;\n }\n\n remove(key: string): void {\n this._removeRaw(key);\n }\n\n\n write<T = unknown>(key: string, value: T, ttl?: number): void {\n if (isNaN(+ttl!) || +ttl! <= 0) {\n this._writeRaw(key, value, ttl);\n return;\n }\n const expiry = DateTime.now().ts + ttl! * 1000;\n const wrappedValue: SmpCachedValue<T> = {\n value: value,\n expiry: expiry\n };\n this._writeRaw(key, wrappedValue, ttl);\n }\n\n protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return smpIsSmpCachedValue(value);\n }\n}\n","import {Observable} from \"rxjs\";\n\nexport abstract class SmpAbstractCacheStrategy {\n abstract read<T = unknown>(key: string): T | undefined | Observable<T | undefined>;\n\n abstract write<T = unknown>(key: string, value: T, ttl?: number): void | Observable<void>;\n\n abstract remove(key: string): void | Observable<void>;\n\n abstract flush(): void | Observable<void>;\n}\n","import {SmpCachedValue} from \"./smp-cached-value.interface.js\";\n\n/**\n * Tells you if a value is a SmpCachedValue\n * @param value\n */\nexport function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n \"expiry\" in value &&\n typeof (value as any).expiry === \"number\"\n );\n}\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAuB,oBCEhB,IAAeC,EAAf,KAAeA,CAAtB,MAAsBA,CAAAA,EAAAA,iCAQtB,ECJO,SAASC,EAAuBC,EAAc,CACjD,OACI,OAAOA,GAAU,UACjBA,IAAU,MACV,UAAWA,GACX,WAAYA,GACZ,OAAQA,EAAcC,QAAW,QAEzC,CARgBF,EAAAA,EAAAA,uBFAT,IAAeG,EAAf,cAAmDC,CAAAA,CAN1D,MAM0DA,CAAAA,EAAAA,oCAUtDC,OAAc,CACV,KAAKC,UAAS,CAClB,CAEAC,KAAkBC,EAA4B,CAC1C,IAAMC,EAAc,KAAKC,SAASF,CAAAA,EAClC,GAAI,KAAKG,kBAAqBF,CAAAA,EAAc,CACxC,GAAIA,EAAYG,QAAUC,WAASC,IAAG,EAAGC,GACrC,OAAON,EAAYO,MAEvB,KAAKC,WAAWT,CAAAA,EAEhB,MACJ,CACA,OAAOC,CACX,CAEAS,OAAOV,EAAmB,CACtB,KAAKS,WAAWT,CAAAA,CACpB,CAGAW,MAAmBX,EAAaQ,EAAUI,EAAoB,CAC1D,GAAIC,MAAM,CAACD,CAAAA,GAAS,CAACA,GAAQ,EAAG,CAC5B,KAAKE,UAAUd,EAAKQ,EAAOI,CAAAA,EAC3B,MACJ,CACA,IAAMR,EAASC,WAASC,IAAG,EAAGC,GAAKK,EAAO,IACpCG,EAAkC,CACpCP,MAAOA,EACPJ,OAAQA,CACZ,EACA,KAAKU,UAAUd,EAAKe,EAAcH,CAAAA,CACtC,CAEUT,kBAAqBK,EAA4C,CACvE,OAAOQ,EAAoBR,CAAAA,CAC/B,CACJ","names":["smp_abstract_ttl_cache_strategy_class_exports","__export","SmpAbstractTtlCacheStrategy","__toCommonJS","import_ts_luxon","SmpAbstractCacheStrategy","smpIsSmpCachedValue","value","expiry","SmpAbstractTtlCacheStrategy","SmpAbstractCacheStrategy","flush","_flushRaw","read","key","storedValue","_readRaw","_isSmpCachedValue","expiry","DateTime","now","ts","value","_removeRaw","remove","write","ttl","isNaN","_writeRaw","wrappedValue","smpIsSmpCachedValue"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/shared/utils/cache/smp-browser-cache.class.ts","../../../../../src/shared/utils/cache/smp-abstract-ttl-cache-strategy.class.ts","../../../../../src/shared/utils/cache/smp-abstract-cache-strategy.class.ts","../../../../../src/shared/utils/cache/smp-is-smp-cached-value.function.ts"],"sourcesContent":["import {SmpAbstractTtlCacheStrategy} from \"./smp-abstract-ttl-cache-strategy.class.js\";\n\nexport class SmpBrowserCache extends SmpAbstractTtlCacheStrategy {\n\n constructor(protected _storage: typeof localStorage | typeof sessionStorage,\n protected _prefix: string) {\n super();\n }\n\n protected _flushRaw(): void {\n const keysToRemove: string[] = [];\n let i = -1;\n while (++i < this._storage.length) {\n const key = this._storage.key(i);\n if (key && key.startsWith(this._prefix)) {\n keysToRemove.push(key);\n }\n }\n i = -1;\n while (++i < keysToRemove.length) {\n this._storage.removeItem(keysToRemove[i]);\n }\n }\n\n protected _readRaw(key: string): unknown | undefined {\n const raw = this._storage.getItem(this._prefix + key);\n try {\n return raw ? JSON.parse(raw) : undefined;\n }\n catch {\n console.warn(`${this.constructor.name}: failed to parse cache item for key ${this._prefix + key}`);\n\n return void 0;\n }\n }\n\n protected _removeRaw(key: string): void {\n this._storage.removeItem(this._prefix + key);\n }\n\n protected _writeRaw(key: string, value: unknown): void {\n try {\n this._storage.setItem(this._prefix + key, JSON.stringify(value));\n }\n catch (e) {\n console.warn(`${this.constructor.name}: failed to write cache item for key ${this._prefix + key}`, e);\n }\n }\n\n}\n\n\n","import {DateTime} from \"ts-luxon\";\n//\nimport {SmpAbstractCacheStrategy} from \"./smp-abstract-cache-strategy.class.js\";\nimport {SmpCachedValue} from \"./smp-cached-value.interface.js\";\nimport {smpIsSmpCachedValue} from \"./smp-is-smp-cached-value.function.js\";\n\nexport abstract class SmpAbstractTtlCacheStrategy extends SmpAbstractCacheStrategy {\n\n protected abstract _flushRaw(): void;\n\n protected abstract _readRaw(key: string): unknown | undefined;\n\n protected abstract _removeRaw(key: string): void;\n\n protected abstract _writeRaw(key: string, value: unknown, ttl?: number): void;\n\n flush(): void {\n this._flushRaw();\n }\n\n read<T = unknown>(key: string): T | undefined {\n const storedValue = this._readRaw(key);\n if (this._isSmpCachedValue<T>(storedValue)) {\n if (storedValue.expiry >= DateTime.now().ts) {\n return storedValue.value as T;\n }\n this._removeRaw(key);\n\n return void 0;\n }\n return storedValue as T | undefined;\n }\n\n remove(key: string): void {\n this._removeRaw(key);\n }\n\n\n write<T = unknown>(key: string, value: T, ttl?: number): void {\n if (isNaN(+ttl!) || +ttl! <= 0) {\n this._writeRaw(key, value, ttl);\n return;\n }\n const expiry = DateTime.now().ts + ttl! * 1000;\n const wrappedValue: SmpCachedValue<T> = {\n value: value,\n expiry: expiry\n };\n this._writeRaw(key, wrappedValue, ttl);\n }\n\n protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return smpIsSmpCachedValue(value);\n }\n}\n","import {Observable} from \"rxjs\";\n\nexport abstract class SmpAbstractCacheStrategy {\n abstract read<T = unknown>(key: string): T | undefined | Observable<T | undefined>;\n\n abstract write<T = unknown>(key: string, value: T, ttl?: number): void | Observable<void>;\n\n abstract remove(key: string): void | Observable<void>;\n\n abstract flush(): void | Observable<void>;\n}\n","import {SmpCachedValue} from \"./smp-cached-value.interface\";\n\n/**\n * Tells you if a value is a SmpCachedValue\n * @param value\n */\nexport function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n \"expiry\" in value &&\n typeof (value as any).expiry === \"number\"\n );\n}\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,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AAO,EAAEA,EAAI,KAAKJ,SAASK,QAAQ,CAC/B,IAAMC,EAAM,KAAKN,SAASM,IAAIF,CAAAA,EAC1BE,GAAOA,EAAIC,WAAW,KAAKN,OAAO,GAClCE,EAAaK,KAAKF,CAAAA,CAE1B,CAEA,IADAF,EAAI,GACG,EAAEA,EAAID,EAAaE,QACtB,KAAKL,SAASS,WAAWN,EAAaC,CAAAA,CAAE,CAEhD,CAEUM,SAASJ,EAAkC,CACjD,IAAMK,EAAM,KAAKX,SAASY,QAAQ,KAAKX,QAAUK,CAAAA,EACjD,GAAI,CACA,OAAOK,EAAME,KAAKC,MAAMH,CAAAA,EAAOI,MACnC,MACM,CACFC,QAAQC,KAAK,GAAG,KAAKlB,YAAYmB,IAAI,wCAAwC,KAAKjB,QAAUK,CAAAA,EAAK,EAEjG,MACJ,CACJ,CAEUa,WAAWb,EAAmB,CACpC,KAAKN,SAASS,WAAW,KAAKR,QAAUK,CAAAA,CAC5C,CAEUc,UAAUd,EAAae,EAAsB,CACnD,GAAI,CACA,KAAKrB,SAASsB,QAAQ,KAAKrB,QAAUK,EAAKO,KAAKU,UAAUF,CAAAA,CAAAA,CAC7D,OACOG,EAAG,CACNR,QAAQC,KAAK,GAAG,KAAKlB,YAAYmB,IAAI,wCAAwC,KAAKjB,QAAUK,CAAAA,GAAOkB,CAAAA,CACvG,CACJ,CAEJ","names":["smp_browser_cache_class_exports","__export","SmpBrowserCache","__toCommonJS","import_ts_luxon","SmpAbstractCacheStrategy","smpIsSmpCachedValue","value","expiry","SmpAbstractTtlCacheStrategy","SmpAbstractCacheStrategy","flush","_flushRaw","read","key","storedValue","_readRaw","_isSmpCachedValue","expiry","DateTime","now","ts","value","_removeRaw","remove","write","ttl","isNaN","_writeRaw","wrappedValue","smpIsSmpCachedValue","SmpBrowserCache","SmpAbstractTtlCacheStrategy","constructor","_storage","_prefix","_flushRaw","keysToRemove","i","length","key","startsWith","push","removeItem","_readRaw","raw","getItem","JSON","parse","undefined","console","warn","name","_removeRaw","_writeRaw","value","setItem","stringify","e"]}
1
+ {"version":3,"sources":["../../../../../src/shared/utils/cache/smp-browser-cache.class.ts","../../../../../src/shared/utils/cache/smp-abstract-ttl-cache-strategy.class.ts","../../../../../src/shared/utils/cache/smp-abstract-cache-strategy.class.ts","../../../../../src/shared/utils/cache/smp-is-smp-cached-value.function.ts"],"sourcesContent":["import {SmpAbstractTtlCacheStrategy} from \"./smp-abstract-ttl-cache-strategy.class.js\";\n\nexport class SmpBrowserCache extends SmpAbstractTtlCacheStrategy {\n\n constructor(protected _storage: typeof localStorage | typeof sessionStorage,\n protected _prefix: string) {\n super();\n }\n\n protected _flushRaw(): void {\n const keysToRemove: string[] = [];\n let i = -1;\n while (++i < this._storage.length) {\n const key = this._storage.key(i);\n if (key && key.startsWith(this._prefix)) {\n keysToRemove.push(key);\n }\n }\n i = -1;\n while (++i < keysToRemove.length) {\n this._storage.removeItem(keysToRemove[i]);\n }\n }\n\n protected _readRaw(key: string): unknown | undefined {\n const raw = this._storage.getItem(this._prefix + key);\n try {\n return raw ? JSON.parse(raw) : undefined;\n }\n catch {\n console.warn(`${this.constructor.name}: failed to parse cache item for key ${this._prefix + key}`);\n\n return void 0;\n }\n }\n\n protected _removeRaw(key: string): void {\n this._storage.removeItem(this._prefix + key);\n }\n\n protected _writeRaw(key: string, value: unknown): void {\n try {\n this._storage.setItem(this._prefix + key, JSON.stringify(value));\n }\n catch (e) {\n console.warn(`${this.constructor.name}: failed to write cache item for key ${this._prefix + key}`, e);\n }\n }\n\n}\n\n\n","import {DateTime} from \"ts-luxon\";\n//\nimport {SmpAbstractCacheStrategy} from \"./smp-abstract-cache-strategy.class.js\";\nimport {SmpCachedValue} from \"./smp-cached-value.interface.js\";\nimport {smpIsSmpCachedValue} from \"./smp-is-smp-cached-value.function.js\";\n\nexport abstract class SmpAbstractTtlCacheStrategy extends SmpAbstractCacheStrategy {\n\n protected abstract _flushRaw(): void;\n\n protected abstract _readRaw(key: string): unknown | undefined;\n\n protected abstract _removeRaw(key: string): void;\n\n protected abstract _writeRaw(key: string, value: unknown, ttl?: number): void;\n\n flush(): void {\n this._flushRaw();\n }\n\n read<T = unknown>(key: string): T | undefined {\n const storedValue = this._readRaw(key);\n if (this._isSmpCachedValue<T>(storedValue)) {\n if (storedValue.expiry >= DateTime.now().ts) {\n return storedValue.value as T;\n }\n this._removeRaw(key);\n\n return void 0;\n }\n return storedValue as T | undefined;\n }\n\n remove(key: string): void {\n this._removeRaw(key);\n }\n\n\n write<T = unknown>(key: string, value: T, ttl?: number): void {\n if (isNaN(+ttl!) || +ttl! <= 0) {\n this._writeRaw(key, value, ttl);\n return;\n }\n const expiry = DateTime.now().ts + ttl! * 1000;\n const wrappedValue: SmpCachedValue<T> = {\n value: value,\n expiry: expiry\n };\n this._writeRaw(key, wrappedValue, ttl);\n }\n\n protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return smpIsSmpCachedValue(value);\n }\n}\n","import {Observable} from \"rxjs\";\n\nexport abstract class SmpAbstractCacheStrategy {\n abstract read<T = unknown>(key: string): T | undefined | Observable<T | undefined>;\n\n abstract write<T = unknown>(key: string, value: T, ttl?: number): void | Observable<void>;\n\n abstract remove(key: string): void | Observable<void>;\n\n abstract flush(): void | Observable<void>;\n}\n","import {SmpCachedValue} from \"./smp-cached-value.interface.js\";\n\n/**\n * Tells you if a value is a SmpCachedValue\n * @param value\n */\nexport function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n \"expiry\" in value &&\n typeof (value as any).expiry === \"number\"\n );\n}\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GCAA,IAAAI,EAAuB,oBCEhB,IAAeC,EAAf,KAAeA,CAAtB,MAAsBA,CAAAA,EAAAA,iCAQtB,ECJO,SAASC,EAAuBC,EAAc,CACjD,OACI,OAAOA,GAAU,UACj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1B,CAEA,IADAF,EAAI,GACG,EAAEA,EAAID,EAAaE,QACtB,KAAKL,SAASS,WAAWN,EAAaC,CAAAA,CAAE,CAEhD,CAEUM,SAASJ,EAAkC,CACjD,IAAMK,EAAM,KAAKX,SAASY,QAAQ,KAAKX,QAAUK,CAAAA,EACjD,GAAI,CACA,OAAOK,EAAME,KAAKC,MAAMH,CAAAA,EAAOI,MACnC,MACM,CACFC,QAAQC,KAAK,GAAG,KAAKlB,YAAYmB,IAAI,wCAAwC,KAAKjB,QAAUK,CAAAA,EAAK,EAEjG,MACJ,CACJ,CAEUa,WAAWb,EAAmB,CACpC,KAAKN,SAASS,WAAW,KAAKR,QAAUK,CAAAA,CAC5C,CAEUc,UAAUd,EAAae,EAAsB,CACnD,GAAI,CACA,KAAKrB,SAASsB,QAAQ,KAAKrB,QAAUK,EAAKO,KAAKU,UAAUF,CAAAA,CAAAA,CAC7D,OACOG,EAAG,CACNR,QAAQC,KAAK,GAAG,KAAKlB,YAAYmB,IAAI,wCAAwC,KAAKjB,QAAUK,CAAAA,GAAOkB,CAAAA,CACvG,CACJ,CAEJ","names":["smp_browser_cache_class_exports","__export","SmpBrowserCache","__toCommonJS","import_ts_luxon","SmpAbstractCacheStrategy","smpIsSmpCachedValue","value","expiry","SmpAbstractTtlCacheStrategy","SmpAbstractCacheStrategy","flush","_flushRaw","read","key","storedValue","_readRaw","_isSmpCachedValue","expiry","DateTime","now","ts","value","_removeRaw","remove","write","ttl","isNaN","_writeRaw","wrappedValue","smpIsSmpCachedValue","SmpBrowserCache","SmpAbstractTtlCacheStrategy","constructor","_storage","_prefix","_flushRaw","keysToRemove","i","length","key","startsWith","push","removeItem","_readRaw","raw","getItem","JSON","parse","undefined","console","warn","name","_removeRaw","_writeRaw","value","setItem","stringify","e"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/shared/utils/cache/smp-in-memory-cache.class.ts","../../../../../src/shared/utils/cache/smp-abstract-ttl-cache-strategy.class.ts","../../../../../src/shared/utils/cache/smp-abstract-cache-strategy.class.ts","../../../../../src/shared/utils/cache/smp-is-smp-cached-value.function.ts"],"sourcesContent":["import {SmpAbstractTtlCacheStrategy} from \"./smp-abstract-ttl-cache-strategy.class.js\";\n\nexport class SmpInMemoryCache extends SmpAbstractTtlCacheStrategy {\n\n private static _storage = new Map<string, unknown>();\n\n protected get _staticSelf(): typeof SmpInMemoryCache {\n return (this.constructor as typeof SmpInMemoryCache);\n }\n\n protected _flushRaw(): void {\n this._staticSelf._storage.clear();\n }\n\n protected _readRaw(key: string): unknown | undefined {\n return this._staticSelf._storage.get(key);\n }\n\n protected _removeRaw(key: string): void {\n this._staticSelf._storage.delete(key);\n }\n\n protected _writeRaw(key: string, value: unknown): void {\n this._staticSelf._storage.set(key, value);\n }\n\n}\n","import {DateTime} from \"ts-luxon\";\n//\nimport {SmpAbstractCacheStrategy} from \"./smp-abstract-cache-strategy.class.js\";\nimport {SmpCachedValue} from \"./smp-cached-value.interface.js\";\nimport {smpIsSmpCachedValue} from \"./smp-is-smp-cached-value.function.js\";\n\nexport abstract class SmpAbstractTtlCacheStrategy extends SmpAbstractCacheStrategy {\n\n protected abstract _flushRaw(): void;\n\n protected abstract _readRaw(key: string): unknown | undefined;\n\n protected abstract _removeRaw(key: string): void;\n\n protected abstract _writeRaw(key: string, value: unknown, ttl?: number): void;\n\n flush(): void {\n this._flushRaw();\n }\n\n read<T = unknown>(key: string): T | undefined {\n const storedValue = this._readRaw(key);\n if (this._isSmpCachedValue<T>(storedValue)) {\n if (storedValue.expiry >= DateTime.now().ts) {\n return storedValue.value as T;\n }\n this._removeRaw(key);\n\n return void 0;\n }\n return storedValue as T | undefined;\n }\n\n remove(key: string): void {\n this._removeRaw(key);\n }\n\n\n write<T = unknown>(key: string, value: T, ttl?: number): void {\n if (isNaN(+ttl!) || +ttl! <= 0) {\n this._writeRaw(key, value, ttl);\n return;\n }\n const expiry = DateTime.now().ts + ttl! * 1000;\n const wrappedValue: SmpCachedValue<T> = {\n value: value,\n expiry: expiry\n };\n this._writeRaw(key, wrappedValue, ttl);\n }\n\n protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return smpIsSmpCachedValue(value);\n }\n}\n","import {Observable} from \"rxjs\";\n\nexport abstract class SmpAbstractCacheStrategy {\n abstract read<T = unknown>(key: string): T | undefined | Observable<T | undefined>;\n\n abstract write<T = unknown>(key: string, value: T, ttl?: number): void | Observable<void>;\n\n abstract remove(key: string): void | Observable<void>;\n\n abstract flush(): void | Observable<void>;\n}\n","import {SmpCachedValue} from \"./smp-cached-value.interface\";\n\n/**\n * Tells you if a value is a SmpCachedValue\n * @param value\n */\nexport function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n \"expiry\" in value &&\n typeof (value as any).expiry === \"number\"\n );\n}\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GCAA,IAAAI,EAAuB,oBCEhB,IAAeC,EAAf,KAAeA,CAAtB,MAAsBA,CAAAA,EAAAA,iCAQtB,ECJO,SAASC,EAAuBC,EAAc,CACjD,OACI,OAAOA,GAAU,UACjBA,IAAU,MACV,UAAWA,GACX,WAAYA,GACZ,OAAQA,EAAcC,QAAW,QAEzC,CARgBF,EAAAA,EAAAA,uBFAT,IAAeG,EAAf,cAAmDC,CAAAA,CAN1D,MAM0DA,CAAAA,EAAAA,oCAUtDC,OAAc,CACV,KAAKC,UAAS,CAClB,CAEAC,KAAkBC,EAA4B,CAC1C,IAAMC,EAAc,KAAKC,SAASF,CAAAA,EAClC,GAAI,KAAKG,kBAAqBF,CAAAA,EAAc,CACxC,GAAIA,EAAYG,QAAUC,WAASC,IAAG,EAAGC,GACrC,OAAON,EAAYO,MAEvB,KAAKC,WAAWT,CAAAA,EAEhB,MACJ,CACA,OAAOC,CACX,CAEAS,OAAOV,EAAmB,CACtB,KAAKS,WAAWT,CAAAA,CACpB,CAGAW,MAAmBX,EAAaQ,EAAUI,EAAoB,CAC1D,GAAIC,MAAM,CAACD,CAAAA,GAAS,CAACA,GAAQ,EAAG,CAC5B,KAAKE,UAAUd,EAAKQ,EAAOI,CAAAA,EAC3B,MACJ,CACA,IAAMR,EAASC,WAASC,IAAG,EAAGC,GAAKK,EAAO,IACpCG,EAAkC,CACpCP,MAAOA,EACPJ,OAAQA,CACZ,EACA,KAAKU,UAAUd,EAAKe,EAAcH,CAAAA,CACtC,CAEUT,kBAAqBK,EAA4C,CACvE,OAAOQ,EAAoBR,CAAAA,CAC/B,CACJ,EDpDO,IAAMS,EAAN,cAA+BC,CAAAA,CAFtC,MAEsCA,CAAAA,EAAAA,yBAElC,OAAeC,SAAW,IAAIC,IAE9B,IAAcC,aAAuC,CACjD,OAAQ,KAAKC,WACjB,CAEUC,WAAkB,CACxB,KAAKF,YAAYF,SAASK,MAAK,CACnC,CAEUC,SAASC,EAAkC,CACjD,OAAO,KAAKL,YAAYF,SAASQ,IAAID,CAAAA,CACzC,CAEUE,WAAWF,EAAmB,CACpC,KAAKL,YAAYF,SAASU,OAAOH,CAAAA,CACrC,CAEUI,UAAUJ,EAAaK,EAAsB,CACnD,KAAKV,YAAYF,SAASa,IAAIN,EAAKK,CAAAA,CACvC,CAEJ","names":["smp_in_memory_cache_class_exports","__export","SmpInMemoryCache","__toCommonJS","import_ts_luxon","SmpAbstractCacheStrategy","smpIsSmpCachedValue","value","expiry","SmpAbstractTtlCacheStrategy","SmpAbstractCacheStrategy","flush","_flushRaw","read","key","storedValue","_readRaw","_isSmpCachedValue","expiry","DateTime","now","ts","value","_removeRaw","remove","write","ttl","isNaN","_writeRaw","wrappedValue","smpIsSmpCachedValue","SmpInMemoryCache","SmpAbstractTtlCacheStrategy","_storage","Map","_staticSelf","constructor","_flushRaw","clear","_readRaw","key","get","_removeRaw","delete","_writeRaw","value","set"]}
1
+ {"version":3,"sources":["../../../../../src/shared/utils/cache/smp-in-memory-cache.class.ts","../../../../../src/shared/utils/cache/smp-abstract-ttl-cache-strategy.class.ts","../../../../../src/shared/utils/cache/smp-abstract-cache-strategy.class.ts","../../../../../src/shared/utils/cache/smp-is-smp-cached-value.function.ts"],"sourcesContent":["import {SmpAbstractTtlCacheStrategy} from \"./smp-abstract-ttl-cache-strategy.class.js\";\n\nexport class SmpInMemoryCache extends SmpAbstractTtlCacheStrategy {\n\n private static _storage = new Map<string, unknown>();\n\n protected get _staticSelf(): typeof SmpInMemoryCache {\n return (this.constructor as typeof SmpInMemoryCache);\n }\n\n protected _flushRaw(): void {\n this._staticSelf._storage.clear();\n }\n\n protected _readRaw(key: string): unknown | undefined {\n return this._staticSelf._storage.get(key);\n }\n\n protected _removeRaw(key: string): void {\n this._staticSelf._storage.delete(key);\n }\n\n protected _writeRaw(key: string, value: unknown): void {\n this._staticSelf._storage.set(key, value);\n }\n\n}\n","import {DateTime} from \"ts-luxon\";\n//\nimport {SmpAbstractCacheStrategy} from \"./smp-abstract-cache-strategy.class.js\";\nimport {SmpCachedValue} from \"./smp-cached-value.interface.js\";\nimport {smpIsSmpCachedValue} from \"./smp-is-smp-cached-value.function.js\";\n\nexport abstract class SmpAbstractTtlCacheStrategy extends SmpAbstractCacheStrategy {\n\n protected abstract _flushRaw(): void;\n\n protected abstract _readRaw(key: string): unknown | undefined;\n\n protected abstract _removeRaw(key: string): void;\n\n protected abstract _writeRaw(key: string, value: unknown, ttl?: number): void;\n\n flush(): void {\n this._flushRaw();\n }\n\n read<T = unknown>(key: string): T | undefined {\n const storedValue = this._readRaw(key);\n if (this._isSmpCachedValue<T>(storedValue)) {\n if (storedValue.expiry >= DateTime.now().ts) {\n return storedValue.value as T;\n }\n this._removeRaw(key);\n\n return void 0;\n }\n return storedValue as T | undefined;\n }\n\n remove(key: string): void {\n this._removeRaw(key);\n }\n\n\n write<T = unknown>(key: string, value: T, ttl?: number): void {\n if (isNaN(+ttl!) || +ttl! <= 0) {\n this._writeRaw(key, value, ttl);\n return;\n }\n const expiry = DateTime.now().ts + ttl! * 1000;\n const wrappedValue: SmpCachedValue<T> = {\n value: value,\n expiry: expiry\n };\n this._writeRaw(key, wrappedValue, ttl);\n }\n\n protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return smpIsSmpCachedValue(value);\n }\n}\n","import {Observable} from \"rxjs\";\n\nexport abstract class SmpAbstractCacheStrategy {\n abstract read<T = unknown>(key: string): T | undefined | Observable<T | undefined>;\n\n abstract write<T = unknown>(key: string, value: T, ttl?: number): void | Observable<void>;\n\n abstract remove(key: string): void | Observable<void>;\n\n abstract flush(): void | Observable<void>;\n}\n","import {SmpCachedValue} from \"./smp-cached-value.interface.js\";\n\n/**\n * Tells you if a value is a SmpCachedValue\n * @param value\n */\nexport function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n \"expiry\" in value &&\n typeof (value as any).expiry === \"number\"\n );\n}\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GCAA,IAAAI,EAAuB,oBCEhB,IAAeC,EAAf,KAAeA,CAAtB,MAAsBA,CAAAA,EAAAA,iCAQtB,ECJO,SAASC,EAAuBC,EAAc,CACjD,OACI,OAAOA,GAAU,UACjBA,IAAU,MACV,UAAWA,GACX,WAAYA,GACZ,OAAQA,EAAcC,QAAW,QAEzC,CARgBF,EAAAA,EAAAA,uBFAT,IAAeG,EAAf,cAAmDC,CAAAA,CAN1D,MAM0DA,CAAAA,EAAAA,oCAUtDC,OAAc,CACV,KAAKC,UAAS,CAClB,CAEAC,KAAkBC,EAA4B,CAC1C,IAAMC,EAAc,KAAKC,SAASF,CAAAA,EAClC,GAAI,KAAKG,kBAAqBF,CAAAA,EAAc,CACxC,GAAIA,EAAYG,QAAUC,WAASC,IAAG,EAAGC,GACrC,OAAON,EAAYO,MAEvB,KAAKC,WAAWT,CAAAA,EAEhB,MACJ,CACA,OAAOC,CACX,CAEAS,OAAOV,EAAmB,CACtB,KAAKS,WAAWT,CAAAA,CACpB,CAGAW,MAAmBX,EAAaQ,EAAUI,EAAoB,CAC1D,GAAIC,MAAM,CAACD,CAAAA,GAAS,CAACA,GAAQ,EAAG,CAC5B,KAAKE,UAAUd,EAAKQ,EAAOI,CAAAA,EAC3B,MACJ,CACA,IAAMR,EAASC,WAASC,IAAG,EAAGC,GAAKK,EAAO,IACpCG,EAAkC,CACpCP,MAAOA,EACPJ,OAAQA,CACZ,EACA,KAAKU,UAAUd,EAAKe,EAAcH,CAAAA,CACtC,CAEUT,kBAAqBK,EAA4C,CACvE,OAAOQ,EAAoBR,CAAAA,CAC/B,CACJ,EDpDO,IAAMS,EAAN,cAA+BC,CAAAA,CAFtC,MAEsCA,CAAAA,EAAAA,yBAElC,OAAeC,SAAW,IAAIC,IAE9B,IAAcC,aAAuC,CACjD,OAAQ,KAAKC,WACjB,CAEUC,WAAkB,CACxB,KAAKF,YAAYF,SAASK,MAAK,CACnC,CAEUC,SAASC,EAAkC,CACjD,OAAO,KAAKL,YAAYF,SAASQ,IAAID,CAAAA,CACzC,CAEUE,WAAWF,EAAmB,CACpC,KAAKL,YAAYF,SAASU,OAAOH,CAAAA,CACrC,CAEUI,UAAUJ,EAAaK,EAAsB,CACnD,KAAKV,YAAYF,SAASa,IAAIN,EAAKK,CAAAA,CACvC,CAEJ","names":["smp_in_memory_cache_class_exports","__export","SmpInMemoryCache","__toCommonJS","import_ts_luxon","SmpAbstractCacheStrategy","smpIsSmpCachedValue","value","expiry","SmpAbstractTtlCacheStrategy","SmpAbstractCacheStrategy","flush","_flushRaw","read","key","storedValue","_readRaw","_isSmpCachedValue","expiry","DateTime","now","ts","value","_removeRaw","remove","write","ttl","isNaN","_writeRaw","wrappedValue","smpIsSmpCachedValue","SmpInMemoryCache","SmpAbstractTtlCacheStrategy","_storage","Map","_staticSelf","constructor","_flushRaw","clear","_readRaw","key","get","_removeRaw","delete","_writeRaw","value","set"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/shared/utils/cache/smp-is-smp-cached-value.function.ts"],"sourcesContent":["import {SmpCachedValue} from \"./smp-cached-value.interface\";\n\n/**\n * Tells you if a value is a SmpCachedValue\n * @param value\n */\nexport function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n \"expiry\" in value &&\n typeof (value as any).expiry === \"number\"\n );\n}\n"],"mappings":"4dAEA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAIO,SAASI,EAAuBC,EAAc,CACjD,OACI,OAAOA,GAAU,UACjBA,IAAU,MACV,UAAWA,GACX,WAAYA,GACZ,OAAQA,EAAcC,QAAW,QAEzC,CARgBF,EAAAA,EAAAA","names":["smp_is_smp_cached_value_function_exports","__export","smpIsSmpCachedValue","__toCommonJS","smpIsSmpCachedValue","value","expiry"]}
1
+ {"version":3,"sources":["../../../../../src/shared/utils/cache/smp-is-smp-cached-value.function.ts"],"sourcesContent":["import {SmpCachedValue} from \"./smp-cached-value.interface.js\";\n\n/**\n * Tells you if a value is a SmpCachedValue\n * @param value\n */\nexport function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n \"expiry\" in value &&\n typeof (value as any).expiry === \"number\"\n );\n}\n"],"mappings":"4dAEA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAIO,SAASI,EAAuBC,EAAc,CACjD,OACI,OAAOA,GAAU,UACjBA,IAAU,MACV,UAAWA,GACX,WAAYA,GACZ,OAAQA,EAAcC,QAAW,QAEzC,CARgBF,EAAAA,EAAAA","names":["smp_is_smp_cached_value_function_exports","__export","smpIsSmpCachedValue","__toCommonJS","smpIsSmpCachedValue","value","expiry"]}