@tonysamperi/ts-mapi-core 2.0.0-beta.4 → 2.0.0-beta.5

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.
@@ -1,12 +1,14 @@
1
1
  import { S as SmpAbstractCacheStrategy, a as SmpCachedValue } from './smp-cached-value.interface-DoiEsQxI.cjs';
2
2
  import { SmpLoggerMethods } from '@tonysamperi/logger';
3
3
  export { smpNoop } from '@tonysamperi/logger';
4
- import { S as SmpResponseMessage, a as SmpGenericResponseBase } from './smp-generic-response-base.interface-D0jHrkjw.cjs';
5
- export { b as SmpResponseMessageBase, c as SmpResponseMessageTypes } from './smp-generic-response-base.interface-D0jHrkjw.cjs';
6
- export { S as SmpSocialSignInKeys, a as SmpSocialSignInUxModes } from './smp-social-sign-in-ux-modes.enum-Cw9H3EqT.cjs';
4
+ import { S as SmpResponseMessage, a as SmpResponseMessageTypes, b as SmpGenericResponseBase } from './smp-generic-response-base.interface-C0On2LBc.cjs';
5
+ export { c as SmpResponseMessageBase } from './smp-generic-response-base.interface-C0On2LBc.cjs';
6
+ export { b as SmpFirebaseErrors, S as SmpSocialSignInKeys, a as SmpSocialSignInUxModes } from './smp-firebase-errors.enum-BlzgwNdc.cjs';
7
7
  import { DateTime } from 'ts-luxon';
8
8
  import 'rxjs';
9
9
 
10
+ type SmpDynamicFetchReturn<T, U> = T extends "blob" ? Blob : T extends "arraybuffer" ? ArrayBuffer : T extends "text" ? string : T extends "json" ? U : T;
11
+
10
12
  declare abstract class SmpAbstractTtlCacheStrategy extends SmpAbstractCacheStrategy {
11
13
  protected abstract _flushRaw(): void;
12
14
  protected abstract _readRaw(key: string): unknown | undefined;
@@ -19,122 +21,6 @@ declare abstract class SmpAbstractTtlCacheStrategy extends SmpAbstractCacheStrat
19
21
  protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T>;
20
22
  }
21
23
 
22
- type SmpDynamicFetchReturn<T, U> = T extends "blob" ? Blob : T extends "arraybuffer" ? ArrayBuffer : T extends "text" ? string : T extends "json" ? U : T;
23
-
24
- type SmpGenericConstructor<T = any, U = any> = new (...args: U[]) => T;
25
-
26
- declare class SmpApiCommonUtils {
27
- protected static _javascriptVariablePattern: string;
28
- protected static _logger: SmpLoggerMethods;
29
- protected static _pathParamRegex: RegExp;
30
- static credentialsToBasicAuth(user: string, password: string): string;
31
- static fromBearer(header?: string): string;
32
- static getCountryFromReferer(referer: string): string | void;
33
- static getLanguageFromReferer(referer: string): string | void;
34
- static getLocaleFromReferer(referer: string): string | void;
35
- static interpolateParams(urlTemplate: string, params: Record<string, string | number | boolean>): string;
36
- }
37
-
38
- type ResponseMessageUnion = string | SmpResponseMessage;
39
- interface SmpErrorResponseCreateOpts<T> {
40
- messages: ResponseMessageUnion | ResponseMessageUnion[];
41
- errorCode: number | string;
42
- status: number;
43
- data: T;
44
- }
45
-
46
- declare class SmpGenericResponse<T, U = SmpGenericResponseBase> implements SmpGenericResponseBase<T> {
47
- protected _messages: SmpResponseMessage[];
48
- data?: T | undefined;
49
- set messages(newValue: string | SmpResponseMessage | (SmpResponseMessage | string)[]);
50
- get messages(): SmpResponseMessage[] | void;
51
- constructor(_messages?: SmpResponseMessage[], data?: T | undefined);
52
- static buildInfo<T = any>(msg: string | string[], data?: T): SmpGenericResponse<T>;
53
- static buildSuccess<T = any>(msg: string | string[], data?: T): SmpGenericResponse<T>;
54
- static fromPlain(plain: unknown): SmpGenericResponse<any, SmpGenericResponseBase<any>>;
55
- isError(): boolean;
56
- isSuccess(): boolean;
57
- serialize(): U;
58
- }
59
-
60
- declare class SmpErrorResponse<T = any> extends SmpGenericResponse<T, SmpGenericResponseBase & Pick<SmpErrorResponse, "errorCode" | "timestamp" | "status">> {
61
- protected _errorCode: number | string;
62
- protected _status: number;
63
- static get DEFAULT_MESSAGES(): SmpResponseMessage[];
64
- get errorCode(): number | string;
65
- get status(): number;
66
- get timestamp(): number;
67
- protected _timestamp: number;
68
- constructor(messages?: SmpResponseMessage[], _errorCode?: number | string, _status?: number, data?: T);
69
- static create<T>({ messages, ...opts }?: Partial<SmpErrorResponseCreateOpts<T>>): SmpErrorResponse;
70
- /**
71
- * This shouldn't be necessary, but it's a workaround for this bug https://github.com/typestack/class-transformer/issues/1807
72
- * @param plain
73
- */
74
- static fromPlain(plain: unknown): SmpErrorResponse<any>;
75
- }
76
-
77
- declare const SMP_HEALTHZ: {
78
- status: string;
79
- };
80
-
81
- declare enum SmpRestVerbs {
82
- GET = "GET",
83
- POST = "POST",
84
- PUT = "PUT",
85
- DELETE = "DELETE",
86
- PATCH = "PATCH"
87
- }
88
-
89
- interface SmpHttpConfig<T = any> {
90
- cacheKey?: string;
91
- clearCache?: boolean;
92
- url: string;
93
- method?: SmpRestVerbs | string;
94
- useCredentials?: boolean;
95
- body?: T;
96
- headers?: Record<string, string>;
97
- queryParams?: Record<string, string | number>;
98
- transform?: boolean;
99
- responseType?: "blob" | "arraybuffer" | "text" | "json" | "jsonp";
100
- }
101
-
102
- interface ParseableErrorClass<T> {
103
- fromPlain(plain: unknown): T;
104
- }
105
- declare class SmpHttpService {
106
- protected static _cachePrefix: string;
107
- protected static _cacheStrategy: SmpAbstractTtlCacheStrategy;
108
- protected static _config: {
109
- cachePrefix: string;
110
- shared: Map<string, Promise<any>>;
111
- };
112
- protected static _errorClass: SmpGenericConstructor & ParseableErrorClass<any>;
113
- protected static _mergeParamsFallbackBaseUrl: string;
114
- static $http(config: SmpHttpConfig): Promise<SmpDynamicFetchReturn<SmpHttpConfig["responseType"], any>>;
115
- static $http<T = any>(config: SmpHttpConfig): Promise<T>;
116
- static $http(config: SmpHttpConfig): Promise<SmpDynamicFetchReturn<SmpHttpConfig["responseType"], Blob>>;
117
- static $http(config: SmpHttpConfig): Promise<SmpDynamicFetchReturn<SmpHttpConfig["responseType"], ArrayBuffer>>;
118
- static $http(config: SmpHttpConfig): Promise<SmpDynamicFetchReturn<SmpHttpConfig["responseType"], string>>;
119
- static $http<T, U, V>(config: SmpHttpConfig): Promise<SmpDynamicFetchReturn<SmpHttpConfig["responseType"], U>>;
120
- /**
121
- * Internal method to generate ajax config
122
- * @param config
123
- * @protected
124
- */
125
- static _generateAjax<T, U, V = unknown>(config: SmpHttpConfig<T>): Promise<SmpDynamicFetchReturn<typeof config.responseType, U>>;
126
- static _generateAjaxBase<T, U, V = unknown>(config: SmpHttpConfig<T>): Promise<SmpDynamicFetchReturn<typeof config.responseType, U>>;
127
- static cacheFlush(): void;
128
- static mergeQueryParams(url: string, queryParams: SmpHttpConfig["queryParams"]): string;
129
- protected static _cacheKey(key: string): string;
130
- protected static _cachePop<T = any>(key: string): T | void;
131
- protected static _cacheRead<T>(key: string): T | void;
132
- protected static _cacheRemove(key: string): void;
133
- protected static _cacheWrite<T>(key: string, value: T): void;
134
- protected static _preprocessRequest<T>(config: SmpHttpConfig<T>): Promise<SmpHttpConfig<T>>;
135
- protected static _preprocessResponse<T>(_config_: SmpHttpConfig<T>, res: Response): Promise<Response>;
136
- }
137
-
138
24
  declare class SmpBrowserCache extends SmpAbstractTtlCacheStrategy {
139
25
  protected _storage: typeof localStorage | typeof sessionStorage;
140
26
  protected _prefix: string;
@@ -218,6 +104,121 @@ declare enum SmpHttpStatusCodes {
218
104
  NetworkAuthenticationRequired = 511
219
105
  }
220
106
 
107
+ type SmpGenericConstructor<T = any, U = any> = new (...args: U[]) => T;
108
+
109
+ declare enum SmpRestVerbs {
110
+ GET = "GET",
111
+ POST = "POST",
112
+ PUT = "PUT",
113
+ DELETE = "DELETE",
114
+ PATCH = "PATCH"
115
+ }
116
+
117
+ type SmpPrimitive = string | number | boolean | symbol;
118
+
119
+ interface SmpHttpTwoConfig<T = any> {
120
+ ttl?: number;
121
+ clearCache?: boolean;
122
+ url: string;
123
+ method?: SmpRestVerbs | string;
124
+ useCredentials?: boolean;
125
+ body?: T;
126
+ headers?: Record<string, string>;
127
+ queryParams?: Record<string, Exclude<SmpPrimitive, symbol> | Exclude<SmpPrimitive, symbol>[]>;
128
+ transform?: boolean;
129
+ responseType?: "blob" | "arraybuffer" | "text" | "json" | "jsonp";
130
+ }
131
+
132
+ interface ParseableErrorClass<T> {
133
+ fromPlain(plain: unknown): T;
134
+ }
135
+ declare class SmpHttpTwoService {
136
+ protected static _cacheStrategy: SmpAbstractTtlCacheStrategy;
137
+ protected static _errorClass: SmpGenericConstructor & ParseableErrorClass<any>;
138
+ protected static _mergeParamsFallbackBaseUrl: string;
139
+ protected static _running: Map<string, Promise<any>>;
140
+ static $http(config: SmpHttpTwoConfig): Promise<SmpDynamicFetchReturn<SmpHttpTwoConfig["responseType"], any>>;
141
+ static $http<T = any>(config: SmpHttpTwoConfig): Promise<T>;
142
+ static $http(config: SmpHttpTwoConfig): Promise<SmpDynamicFetchReturn<SmpHttpTwoConfig["responseType"], Blob>>;
143
+ static $http(config: SmpHttpTwoConfig): Promise<SmpDynamicFetchReturn<SmpHttpTwoConfig["responseType"], ArrayBuffer>>;
144
+ static $http(config: SmpHttpTwoConfig): Promise<SmpDynamicFetchReturn<SmpHttpTwoConfig["responseType"], string>>;
145
+ static $http<T, U, V>(config: SmpHttpTwoConfig): Promise<SmpDynamicFetchReturn<SmpHttpTwoConfig["responseType"], U>>;
146
+ /**
147
+ * Internal method to generate ajax config
148
+ * @param config
149
+ * @protected
150
+ */
151
+ static _generateAjax<T, U, V = unknown>(config: SmpHttpTwoConfig<T>): Promise<SmpDynamicFetchReturn<typeof config.responseType, U>>;
152
+ static _generateAjaxBase<T, U, V = unknown>(config: SmpHttpTwoConfig<T>): Promise<SmpDynamicFetchReturn<typeof config.responseType, U>>;
153
+ static cacheFlush(): void;
154
+ static mergeQueryParams(url: string, queryParams: SmpHttpTwoConfig["queryParams"]): string;
155
+ protected static _generateCacheKey(config: SmpHttpTwoConfig): string;
156
+ protected static _preprocessRequest<T>(config: SmpHttpTwoConfig<T>): Promise<SmpHttpTwoConfig<T>>;
157
+ protected static _preprocessResponse<T>(_config_: SmpHttpTwoConfig<T>, res: Response): Promise<Response>;
158
+ }
159
+
160
+ declare class SmpApiCommonUtils {
161
+ protected static _javascriptVariablePattern: string;
162
+ protected static _logger: SmpLoggerMethods;
163
+ protected static _pathParamRegex: RegExp;
164
+ static credentialsToBasicAuth(user: string, password: string): string;
165
+ static fromBearer(header?: string): string;
166
+ static getCountryFromReferer(referer: string): string | void;
167
+ static getLanguageFromReferer(referer: string): string | void;
168
+ static getLocaleFromReferer(referer: string): string | void;
169
+ static interpolateParams(urlTemplate: string, params: Record<string, string | number | boolean>): string;
170
+ }
171
+
172
+ type ResponseMessageUnion = string | SmpResponseMessage;
173
+ interface SmpErrorResponseCreateOpts<T> {
174
+ messages: ResponseMessageUnion | ResponseMessageUnion[];
175
+ errorCode: number | string;
176
+ status: number;
177
+ data: T;
178
+ }
179
+
180
+ interface SmpGenericResponseCreateOpts<T = any> {
181
+ messages: string | SmpResponseMessage | (string | SmpResponseMessage)[];
182
+ data: T;
183
+ type: SmpResponseMessageTypes;
184
+ }
185
+
186
+ declare class SmpGenericResponse<T, U = SmpGenericResponseBase> implements SmpGenericResponseBase<T> {
187
+ protected _messages: SmpResponseMessage[];
188
+ data?: T | undefined;
189
+ set messages(newValue: string | SmpResponseMessage | (SmpResponseMessage | string)[]);
190
+ get messages(): SmpResponseMessage[] | void;
191
+ constructor(_messages?: SmpResponseMessage[], data?: T | undefined);
192
+ static create<T = any>(config: Partial<SmpGenericResponseCreateOpts<T>>): SmpGenericResponse<T>;
193
+ static fromPlain(plain: unknown): SmpGenericResponse<any, SmpGenericResponseBase<any>>;
194
+ isError(): boolean;
195
+ isSuccess(): boolean;
196
+ serialize(): U;
197
+ }
198
+
199
+ declare class SmpErrorResponse<T = any> extends SmpGenericResponse<T, SmpGenericResponseBase & Pick<SmpErrorResponse, "errorCode" | "timestamp" | "status">> {
200
+ protected _errorCode: number | string;
201
+ protected _status: number;
202
+ static get DEFAULT_MESSAGES(): SmpResponseMessage[];
203
+ set errorCode(value: number | string);
204
+ get errorCode(): number | string;
205
+ get status(): number;
206
+ set timestamp(newValue: number);
207
+ get timestamp(): number;
208
+ protected _timestamp: number;
209
+ constructor(messages?: SmpResponseMessage[], _errorCode?: number | string, _status?: number, data?: T);
210
+ static create<T>({ messages, ...opts }?: Partial<SmpErrorResponseCreateOpts<T>>): SmpErrorResponse;
211
+ /**
212
+ * This shouldn't be necessary, but it's a workaround for this bug https://github.com/typestack/class-transformer/issues/1807
213
+ * @param plain
214
+ */
215
+ static fromPlain(plain: unknown): SmpErrorResponse<any>;
216
+ }
217
+
218
+ declare const SMP_HEALTHZ: {
219
+ status: string;
220
+ };
221
+
221
222
  declare class SmpBaseJwtTokenPlain {
222
223
  access_token: string;
223
224
  exp: number;
@@ -235,8 +236,6 @@ declare class SmpBaseJwtToken {
235
236
  serialize(): SmpBaseJwtTokenPlain;
236
237
  }
237
238
 
238
- type SmpPrimitive = string | number | boolean | symbol;
239
-
240
239
  declare class WordArray {
241
240
  sigBytes: number;
242
241
  words: number[];
@@ -734,19 +733,6 @@ declare class SmpSecureCode {
734
733
  protected _encode(): string;
735
734
  }
736
735
 
737
- declare enum SmpFirebaseErrors {
738
- DIFFERENT_CREDENTIAL = "auth/account-exists-with-different-credential",
739
- DIFFERENT_CREDENTIAL_APPLE = "auth/account-exists-with-different-credential/apple",
740
- DIFFERENT_CREDENTIAL_FACEBOOK = "auth/account-exists-with-different-credential/facebook",
741
- DIFFERENT_CREDENTIAL_GOOGLE = "auth/account-exists-with-different-credential/google",
742
- EMAIL_EXISTS = "auth/email-already-exists",
743
- INVALID_ACTION_CODE = "auth/invalid-action-code",
744
- POPUP_BLOCKED = "auth/popup-blocked",
745
- POPUP_CLOSED_BY_USER = "auth/popup-closed-by-user",
746
- USER_NOT_FOUND = "auth/user-not-found",
747
- WRONG_PASSWORD = "auth/wrong-password"
748
- }
749
-
750
736
  declare enum SmpGiftcardTransactionOps {
751
737
  ACTIVATE = "ACTIVATE",
752
738
  BLOCK = "BLOCK",
@@ -785,14 +771,13 @@ declare enum SmpGiftcardTransactionHashStrategies {
785
771
 
786
772
  /**
787
773
  * Base implementation that you can extend, even customizing the static parts like #SmpGiftcardTransaction._AES_ENCODER.
788
- * You can create your own instance of KikAesCrypt to override it.
774
+ * You can create your own instance of SmpAesCrypt to override it.
789
775
  */
790
776
  declare class SmpGiftcardTransaction implements SmpGiftcardTransactionPlain {
791
777
  readonly gc: string;
792
778
  readonly op: SmpGiftcardTransactionOps;
793
779
  readonly ot?: string | undefined;
794
780
  protected static _AES_ENCODER: SmpAesCrypt;
795
- protected static _LOGGER: SmpLoggerMethods;
796
781
  protected static _OP_CODES: Record<SmpGiftcardTransactionOps, string>;
797
782
  protected static readonly _SEP: string;
798
783
  get dto(): DateTime;
@@ -921,7 +906,7 @@ declare class SmpCommonUtils {
921
906
  * @param iteratee the map fn
922
907
  */
923
908
  static mapObject<T = any>(objLike: any, iteratee: (v: any, indexOrKey: string | number, arr?: string[]) => any): T[];
924
- static mapObjectKeys<T extends string = string>(obj: Record<T, any>, callback: (key: string, value: any) => any): Record<string, any>;
909
+ static mapObjectKeys<T extends string = string>(obj: Record<T, any>, callback: (key: string, value: any) => string): Record<string, any>;
925
910
  static mapObjectValues<T extends string = string>(obj: Partial<Record<T, any>>, callback: (value: any, key: string) => any): Record<string, any>;
926
911
  static noop(): void;
927
912
  static objectHasValue<T extends object>(obj: T, value: any): boolean;
@@ -983,6 +968,10 @@ declare class SmpRegularExpressions {
983
968
  protected static _language: RegExp;
984
969
  }
985
970
 
971
+ type SmpWithDateTimeAsDate<T, Keys extends keyof T = keyof T> = Omit<T, Keys> & {
972
+ [K in Keys]: T[K] extends DateTime | null | undefined ? Exclude<T[K], DateTime> | Date : T[K];
973
+ };
974
+
986
975
  declare class SmpInMemoryCache extends SmpAbstractTtlCacheStrategy {
987
976
  private static _storage;
988
977
  protected get _staticSelf(): typeof SmpInMemoryCache;
@@ -998,6 +987,6 @@ declare class SmpInMemoryCache extends SmpAbstractTtlCacheStrategy {
998
987
  */
999
988
  declare function smpIsSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T>;
1000
989
 
1001
- declare const VERSION: "2.0.0-beta.4";
990
+ declare const VERSION: "2.0.0-beta.5";
1002
991
 
1003
- export { SMP_HEALTHZ, SmpAbstractCacheStrategy, SmpAbstractTtlCacheStrategy, SmpAesCrypt, SmpApiCommonUtils, SmpBaseJwtToken, SmpBaseJwtTokenPlain, SmpBrowserCache, SmpCachedValue, SmpCommonUtils, SmpCrypto, SmpErrorResponse, type SmpErrorResponseCreateOpts, SmpFilterException, SmpFirebaseErrors, type SmpGenericConstructor, SmpGenericResponse, SmpGenericResponseBase, SmpGiftcardTransaction, type SmpGiftcardTransactionConfig, SmpGiftcardTransactionHashStrategies, SmpGiftcardTransactionOps, type SmpGiftcardTransactionPlain, type SmpHttpConfig, SmpHttpService, SmpHttpSessionStorageCache, SmpHttpStatusCodes, SmpInMemoryCache, type SmpMarketingCloudValidationResponse, type SmpMarketingCloudValidationResponseKo, type SmpMarketingCloudValidationResponseOk, SmpMarketingCloudValidators, type SmpPrimitive, SmpRegularExpressions, SmpResponseMessage, SmpRestVerbs, SmpSecureCode, SmpSid, VERSION, smpApplyMixin, smpIsSmpCachedValue };
992
+ export { SMP_HEALTHZ, SmpAbstractCacheStrategy, SmpAbstractTtlCacheStrategy, SmpAesCrypt, SmpApiCommonUtils, SmpBaseJwtToken, SmpBaseJwtTokenPlain, SmpBrowserCache, SmpCachedValue, SmpCommonUtils, SmpCrypto, type SmpDynamicFetchReturn, SmpErrorResponse, type SmpErrorResponseCreateOpts, SmpFilterException, type SmpGenericConstructor, SmpGenericResponse, SmpGenericResponseBase, type SmpGenericResponseCreateOpts, SmpGiftcardTransaction, type SmpGiftcardTransactionConfig, SmpGiftcardTransactionHashStrategies, SmpGiftcardTransactionOps, type SmpGiftcardTransactionPlain, SmpHttpSessionStorageCache, SmpHttpStatusCodes, type SmpHttpTwoConfig, SmpHttpTwoService, SmpInMemoryCache, type SmpMarketingCloudValidationResponse, type SmpMarketingCloudValidationResponseKo, type SmpMarketingCloudValidationResponseOk, SmpMarketingCloudValidators, type SmpPrimitive, SmpRegularExpressions, SmpResponseMessage, SmpResponseMessageTypes, SmpRestVerbs, SmpSecureCode, SmpSid, type SmpWithDateTimeAsDate, VERSION, smpApplyMixin, smpIsSmpCachedValue };
package/dist/cjs/rxjs.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var f=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var s=(t,r)=>f(t,"name",{value:r,configurable:!0});var C=(t,r)=>{for(var e in r)f(t,e,{get:r[e],enumerable:!0})},N=(t,r,e,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of j(r))!E.call(t,n)&&n!==e&&f(t,n,{get:()=>r[n],enumerable:!(o=b(r,n))||o.enumerable});return t};var O=t=>N(f({},"__esModule",{value:!0}),t);var D={};C(D,{SmpAbstractRxjsTtlCacheStrategy:()=>a,SmpRxjsInMemoryCache:()=>x,smpRxjsCatchOnly:()=>I,smpRxjsQueue:()=>T,smpRxjsSequence:()=>V,smpRxjsThrowIfEmpty:()=>y,smpRxjsThrowOnCondition:()=>M});module.exports=O(D);var d=require("rxjs"),_=require("ts-luxon");var u=class{static{s(this,"SmpAbstractCacheStrategy")}};function R(t){return typeof t=="object"&&t!==null&&"value"in t&&"expiry"in t&&typeof t.expiry=="number"}s(R,"smpIsSmpCachedValue");var a=class extends u{static{s(this,"SmpAbstractRxjsTtlCacheStrategy")}flush(){return this._flushRaw()}read(r){return this._readRaw(r).pipe((0,d.map)(e=>{if(this._isSmpCachedValue(e)){if(e.expiry>=_.DateTime.now().ts)return e.value;this._removeRaw(r).subscribe();return}return e}))}remove(r){return this._removeRaw(r)}write(r,e,o){let n;if(isNaN(+o)||+o<=0)n=this._writeRaw(r,e,o);else{let l=_.DateTime.now().ts+o*1e3,w={value:e,expiry:l};n=this._writeRaw(r,w,o)}return n.subscribe(),n}_isSmpCachedValue(r){return R(r)}};var m=require("rxjs");function I(t,r){return e=>e.pipe((0,m.catchError)(o=>(typeof t==typeof isNaN?v(t)?A(o,t):t(o):!1)?r(o):(0,m.throwError)(()=>o)))}s(I,"smpRxjsCatchOnly");function v(t){try{return Reflect.construct(String,[],t),!0}catch{return!1}}s(v,"isConstructor");function A(t,r){return typeof t=="object"&&t!==null&&t.constructor===r}s(A,"isExactInstance");var c=require("rxjs");var x=class extends a{static{s(this,"SmpRxjsInMemoryCache")}static _storage=new Map;get _staticSelf(){return this.constructor}_flushRaw(){return this._staticSelf._storage.clear(),(0,c.of)(void 0)}_readRaw(r){return(0,c.of)(this._staticSelf._storage.get(r))}_removeRaw(r){return this._staticSelf._storage.delete(r),(0,c.of)(void 0)}_writeRaw(r,e){return this._staticSelf._storage.set(r,e),(0,c.of)(void 0)}};var i=require("rxjs");function S(t){let r=[];function e(o){return o>=t.length?(0,i.of)(r):(0,i.defer)(()=>t[o]()).pipe((0,i.switchMap)(n=>(r[o]=n,e(o+1))))}return s(e,"runStep"),e(0)}s(S,"smpRxjsSequence");function T(t){if(Array.isArray(t))return S(t);{let r=Object.keys(t),e=r.map(o=>t[o]);return S(e).pipe((0,i.map)(o=>{let n={};return r.forEach((l,w)=>{n[l]=o[w]}),n}))}}s(T,"smpRxjsQueue");var p=require("rxjs");function V(t){return(0,p.from)(t).pipe((0,p.concatMap)(e=>e()),(0,p.toArray)())}s(V,"smpRxjsSequence");var g=require("rxjs");function y(t=J){return r=>r.pipe((0,g.map)(e=>{if(~q.indexOf(JSON.stringify(e)))throw t(e);return e}))}s(y,"smpRxjsThrowIfEmpty");var q=[void 0,null,!1,0,"","0",[],{}].map(t=>JSON.stringify(t)),J=s(()=>new Error,"defaultErrorFactory");var h=require("rxjs");function M(t,r){return e=>e.pipe((0,h.filter)(o=>!t(o)),(0,h.defaultIfEmpty)(!1),y(r))}s(M,"smpRxjsThrowOnCondition");0&&(module.exports={SmpAbstractRxjsTtlCacheStrategy,SmpRxjsInMemoryCache,smpRxjsCatchOnly,smpRxjsQueue,smpRxjsSequence,smpRxjsThrowIfEmpty,smpRxjsThrowOnCondition});
1
+ "use strict";var f=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var s=(t,r)=>f(t,"name",{value:r,configurable:!0});var C=(t,r)=>{for(var e in r)f(t,e,{get:r[e],enumerable:!0})},N=(t,r,e,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of j(r))!E.call(t,n)&&n!==e&&f(t,n,{get:()=>r[n],enumerable:!(o=b(r,n))||o.enumerable});return t};var O=t=>N(f({},"__esModule",{value:!0}),t);var $={};C($,{SmpAbstractRxjsTtlCacheStrategy:()=>a,SmpRxjsInMemoryCache:()=>x,smpRxjsCatchOnly:()=>I,smpRxjsQueue:()=>T,smpRxjsSequence:()=>V,smpRxjsThrowIfEmpty:()=>y,smpRxjsThrowOnCondition:()=>M});module.exports=O($);var d=require("rxjs"),_=require("ts-luxon");var m=class{static{s(this,"SmpAbstractCacheStrategy")}};function R(t){return typeof t=="object"&&t!==null&&"value"in t&&"expiry"in t&&typeof t.expiry=="number"}s(R,"smpIsSmpCachedValue");var a=class extends m{static{s(this,"SmpAbstractRxjsTtlCacheStrategy")}flush(){return this._flushRaw()}read(r){return this._readRaw(r).pipe((0,d.map)(e=>{if(this._isSmpCachedValue(e)){if(e.expiry>=_.DateTime.now().ts)return e.value;this._removeRaw(r).subscribe();return}return e}))}remove(r){return this._removeRaw(r)}write(r,e,o){let n;if(isNaN(+o)||+o<=0)n=this._writeRaw(r,e,o);else{let c=_.DateTime.now().ts+o*1e3,w={value:e,expiry:c};n=this._writeRaw(r,w,o)}return n.subscribe({error:s(c=>console.error(`${this.constructor.name}::write: error occurred`,c),"error")}),n}_isSmpCachedValue(r){return R(r)}};var h=require("rxjs");function I(t,r){return e=>e.pipe((0,h.catchError)(o=>(typeof t==typeof isNaN?v(t)?A(o,t):t(o):!1)?r(o):(0,h.throwError)(()=>o)))}s(I,"smpRxjsCatchOnly");function v(t){try{return Reflect.construct(String,[],t),!0}catch{return!1}}s(v,"isConstructor");function A(t,r){return typeof t=="object"&&t!==null&&t.constructor===r}s(A,"isExactInstance");var u=require("rxjs");var x=class extends a{static{s(this,"SmpRxjsInMemoryCache")}static _storage=new Map;get _staticSelf(){return this.constructor}_flushRaw(){return this._staticSelf._storage.clear(),(0,u.of)(void 0)}_readRaw(r){return(0,u.of)(this._staticSelf._storage.get(r))}_removeRaw(r){return this._staticSelf._storage.delete(r),(0,u.of)(void 0)}_writeRaw(r,e){return this._staticSelf._storage.set(r,e),(0,u.of)(void 0)}};var i=require("rxjs");function S(t){let r=[];function e(o){return o>=t.length?(0,i.of)(r):(0,i.defer)(()=>t[o]()).pipe((0,i.switchMap)(n=>(r[o]=n,e(o+1))))}return s(e,"runStep"),e(0)}s(S,"smpRxjsSequence");function T(t){if(Array.isArray(t))return S(t);{let r=Object.keys(t),e=r.map(o=>t[o]);return S(e).pipe((0,i.map)(o=>{let n={};return r.forEach((c,w)=>{n[c]=o[w]}),n}))}}s(T,"smpRxjsQueue");var p=require("rxjs");function V(t){return(0,p.from)(t).pipe((0,p.concatMap)(e=>e()),(0,p.toArray)())}s(V,"smpRxjsSequence");var g=require("rxjs");function y(t=J){return r=>r.pipe((0,g.map)(e=>{if(~q.indexOf(JSON.stringify(e)))throw t(e);return e}))}s(y,"smpRxjsThrowIfEmpty");var q=[void 0,null,!1,0,"","0",[],{}].map(t=>JSON.stringify(t)),J=s(()=>new Error,"defaultErrorFactory");var l=require("rxjs");function M(t,r){return e=>e.pipe((0,l.filter)(o=>!t(o)),(0,l.defaultIfEmpty)(!1),y(r))}s(M,"smpRxjsThrowOnCondition");0&&(module.exports={SmpAbstractRxjsTtlCacheStrategy,SmpRxjsInMemoryCache,smpRxjsCatchOnly,smpRxjsQueue,smpRxjsSequence,smpRxjsThrowIfEmpty,smpRxjsThrowOnCondition});
2
2
  //# sourceMappingURL=rxjs.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/rxjs.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 * from \"./shared/rxjs/index.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 = any>(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 = any>(key: string, value: T, ttl?: number): Observable<void> {\n let obs$: Observable<void>;\n\n if (isNaN(+ttl!) || +ttl! <= 0) {\n obs$ = this._writeRaw(key, value, ttl);\n }\n else {\n const expiry = DateTime.now().ts + ttl! * 1000;\n const wrappedValue: SmpCachedValue<T> = {\n value,\n expiry\n };\n obs$ = this._writeRaw(key, wrappedValue, ttl);\n }\n\n // Fire-and-forget\n obs$.subscribe();\n\n return obs$;\n }\n\n protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return smpIsSmpCachedValue(value);\n }\n}\n","import {Observable} from \"rxjs\";\n\n/**\n * Abstract class representing a caching strategy. This class is intended to be extended by concrete implementations\n * and provides an interface for performing common caching operations such as reading, writing, removing, and flushing cache entries.\n * You shouldn't need to implement this: you can go with SmpAbstractTtlCacheStrategy or SmpRxjsAbstractCacheStrategy, depending on what type of cache you want to implement.\n * For instance, for a local cache, you may stay sync, while for a Valkey cache, you should start with the rxjs.\n */\nexport abstract class SmpAbstractCacheStrategy {\n abstract read<T = any>(key: string): T | undefined | Observable<T | undefined>;\n\n abstract write<T = any>(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, any>();\n\n protected get _staticSelf(): typeof SmpRxjsInMemoryCache {\n return this.constructor as typeof SmpRxjsInMemoryCache;\n }\n\n protected _flushRaw(): Observable<void> {\n this._staticSelf._storage.clear();\n\n return of(void 0);\n }\n\n protected _readRaw(key: string): Observable<any | undefined> {\n return of(this._staticSelf._storage.get(key));\n }\n\n protected _removeRaw(key: string): Observable<void> {\n this._staticSelf._storage.delete(key);\n\n return of(void 0);\n }\n\n protected _writeRaw(key: string, value: any): Observable<void> {\n this._staticSelf._storage.set(key, value);\n\n return of(void 0);\n }\n}\n\n","import {map, Observable, of, defer, switchMap} from \"rxjs\";\n\nfunction smpRxjsSequence<T extends any[]>(steps: { [K in keyof T]: () => Observable<T[K]> }): Observable<T> {\n const results: Partial<T>[] = [];\n\n function runStep(index: number): Observable<T> {\n if (index >= steps.length) {\n return of(results as T);\n }\n\n return defer(() => steps[index]()).pipe(\n switchMap((value) => {\n results[index] = value;\n return runStep(index + 1);\n })\n );\n }\n\n return runStep(0);\n}\n\n// Overloads for array or object input\ntype ObsFnMap = Record<string, () => Observable<any>>;\n\nexport function smpRxjsQueue<T extends any[]>(source: { [K in keyof T]: () => Observable<T[K]> }): Observable<T>;\nexport function smpRxjsQueue<T extends ObsFnMap>(source: T): Observable<{ [K in keyof T]: T[K] extends () => Observable<infer U> ? U : never }>;\nexport function smpRxjsQueue(\n source: (() => Observable<any>)[] | ObsFnMap\n): Observable<any> {\n if (Array.isArray(source)) {\n // use a strongly typed sequence for the array of steps\n return smpRxjsSequence(source as any);\n }\n else {\n // for object, convert values, then reconstruct object mapping with correct types\n const keys = Object.keys(source);\n const stepsArray = keys.map((key) => source[key]);\n\n return smpRxjsSequence(stepsArray as any).pipe(\n map((results: any[]) => {\n const acc: any = {};\n keys.forEach((key, i) => {\n acc[key] = results[i];\n });\n return acc;\n })\n );\n }\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 * @param steps\n */\nexport function smpRxjsSequence<T extends any[]>(\n steps: { [K in keyof T]: () => Observable<T[K]> }\n): Observable<T> {\n // Cast to readonly tuple of functions to keep tuple inference\n const stepFunctions = steps as readonly (() => Observable<T[number]>)[];\n\n return from(stepFunctions).pipe(\n concatMap(step => step()),\n toArray()\n // TS loses tuple typing here, so we cast the result back to T\n // This cast is safe because we control the input and ordering\n ) as Observable<T>;\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 n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AAA,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,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","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","obs$","isNaN","_writeRaw","wrappedValue","smpIsSmpCachedValue","import_rxjs","smpRxjsCatchOnly","errorFilter","selector","source","pipe","catchError","err","isNaN","isConstructor","isExactInstance","throwError","fn","Reflect","construct","String","ctor","import_rxjs","SmpRxjsInMemoryCache","SmpAbstractRxjsTtlCacheStrategy","_storage","Map","_staticSelf","_flushRaw","clear","of","_readRaw","key","get","_removeRaw","delete","_writeRaw","value","set","import_rxjs","smpRxjsSequence","steps","results","runStep","index","length","of","defer","pipe","switchMap","value","smpRxjsQueue","source","Array","isArray","keys","Object","stepsArray","map","key","acc","forEach","i","import_rxjs","smpRxjsSequence","steps","from","stepFunctions","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
+ {"version":3,"sources":["../../src/rxjs.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 * from \"./shared/rxjs/index.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 = any>(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 = any>(key: string, value: T, ttl?: number): Observable<void> {\n let obs$: Observable<void>;\n\n if (isNaN(+ttl!) || +ttl! <= 0) {\n obs$ = this._writeRaw(key, value, ttl);\n }\n else {\n const expiry = DateTime.now().ts + ttl! * 1000;\n const wrappedValue: SmpCachedValue<T> = {\n value,\n expiry\n };\n obs$ = this._writeRaw(key, wrappedValue, ttl);\n }\n\n // Fire-and-forget\n obs$.subscribe({\n error: (err) => console.error(`${this.constructor.name}::write: error occurred`, err)\n });\n\n return obs$;\n }\n\n protected _isSmpCachedValue<T>(value: unknown): value is SmpCachedValue<T> {\n return smpIsSmpCachedValue(value);\n }\n}\n","import {Observable} from \"rxjs\";\n\n/**\n * Abstract class representing a caching strategy. This class is intended to be extended by concrete implementations\n * and provides an interface for performing common caching operations such as reading, writing, removing, and flushing cache entries.\n * You shouldn't need to implement this: you can go with SmpAbstractTtlCacheStrategy or SmpRxjsAbstractCacheStrategy, depending on what type of cache you want to implement.\n * For instance, for a local cache, you may stay sync, while for a Valkey cache, you should start with the rxjs.\n */\nexport abstract class SmpAbstractCacheStrategy {\n abstract read<T = any>(key: string): T | undefined | Observable<T | undefined>;\n\n abstract write<T = any>(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, any>();\n\n protected get _staticSelf(): typeof SmpRxjsInMemoryCache {\n return this.constructor as typeof SmpRxjsInMemoryCache;\n }\n\n protected _flushRaw(): Observable<void> {\n this._staticSelf._storage.clear();\n\n return of(void 0);\n }\n\n protected _readRaw(key: string): Observable<any | undefined> {\n return of(this._staticSelf._storage.get(key));\n }\n\n protected _removeRaw(key: string): Observable<void> {\n this._staticSelf._storage.delete(key);\n\n return of(void 0);\n }\n\n protected _writeRaw(key: string, value: any): Observable<void> {\n this._staticSelf._storage.set(key, value);\n\n return of(void 0);\n }\n}\n\n","import {map, Observable, of, defer, switchMap} from \"rxjs\";\n\nfunction smpRxjsSequence<T extends any[]>(steps: { [K in keyof T]: () => Observable<T[K]> }): Observable<T> {\n const results: Partial<T>[] = [];\n\n function runStep(index: number): Observable<T> {\n if (index >= steps.length) {\n return of(results as T);\n }\n\n return defer(() => steps[index]()).pipe(\n switchMap((value) => {\n results[index] = value;\n return runStep(index + 1);\n })\n );\n }\n\n return runStep(0);\n}\n\n// Overloads for array or object input\ntype ObsFnMap = Record<string, () => Observable<any>>;\n\nexport function smpRxjsQueue<T extends any[]>(source: { [K in keyof T]: () => Observable<T[K]> }): Observable<T>;\nexport function smpRxjsQueue<T extends ObsFnMap>(source: T): Observable<{ [K in keyof T]: T[K] extends () => Observable<infer U> ? U : never }>;\nexport function smpRxjsQueue(\n source: (() => Observable<any>)[] | ObsFnMap\n): Observable<any> {\n if (Array.isArray(source)) {\n // use a strongly typed sequence for the array of steps\n return smpRxjsSequence(source as any);\n }\n else {\n // for object, convert values, then reconstruct object mapping with correct types\n const keys = Object.keys(source);\n const stepsArray = keys.map((key) => source[key]);\n\n return smpRxjsSequence(stepsArray as any).pipe(\n map((results: any[]) => {\n const acc: any = {};\n keys.forEach((key, i) => {\n acc[key] = results[i];\n });\n return acc;\n })\n );\n }\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 * @param steps\n */\nexport function smpRxjsSequence<T extends any[]>(\n steps: { [K in keyof T]: () => Observable<T[K]> }\n): Observable<T> {\n // Cast to readonly tuple of functions to keep tuple inference\n const stepFunctions = steps as readonly (() => Observable<T[number]>)[];\n\n return from(stepFunctions).pipe(\n concatMap(step => step()),\n toArray()\n // TS loses tuple typing here, so we cast the result back to T\n // This cast is safe because we control the input and ordering\n ) as Observable<T>;\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?: (value: T) => 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,yBAAAC,EAAA,qBAAAC,EAAA,iBAAAC,EAAA,oBAAAC,EAAA,wBAAAC,EAAA,4BAAAC,IAAA,eAAAC,EAAAT,GCAA,IAAAU,EAA8B,gBAC9BC,EAAuB,oBCOhB,IAAeC,EAAf,KAAeA,CANtB,MAMsBA,CAAAA,EAAAA,iCAQtB,ECVO,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,KAAcC,EAAwC,CAClD,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,MAAed,EAAaU,EAAUK,EAAgC,CAClE,IAAIC,EAEJ,GAAIC,MAAM,CAACF,CAAAA,GAAS,CAACA,GAAQ,E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CAAAA,KAClBC,WAAAA,CAAAA,CAIR,CAZgBP,EAAAA,EAAAA,mBCPhB,IAAAQ,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,uBCnD5B,IAAAC,EAAmE,gBA6B5D,SAASC,EACZC,EACAC,EAAgC,CAEhC,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","obs$","isNaN","_writeRaw","wrappedValue","error","__name","err","console","name","smpIsSmpCachedValue","import_rxjs","smpRxjsCatchOnly","errorFilter","selector","source","pipe","catchError","err","isNaN","isConstructor","isExactInstance","throwError","fn","Reflect","construct","String","ctor","import_rxjs","SmpRxjsInMemoryCache","SmpAbstractRxjsTtlCacheStrategy","_storage","Map","_staticSelf","_flushRaw","clear","of","_readRaw","key","get","_removeRaw","delete","_writeRaw","value","set","import_rxjs","smpRxjsSequence","steps","results","runStep","index","length","of","defer","pipe","switchMap","value","smpRxjsQueue","source","Array","isArray","keys","Object","stepsArray","map","key","acc","forEach","i","import_rxjs","smpRxjsSequence","steps","from","stepFunctions","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"]}
@@ -101,6 +101,6 @@ declare function smpRxjsThrowIfEmpty<T>(errorFactory?: (value: T) => any): Opera
101
101
  * error: err => console.error("Error:", err)
102
102
  * });
103
103
  */
104
- declare function smpRxjsThrowOnCondition<T>(condition: (value: T) => boolean, errorFactory?: () => any): OperatorFunction<T, T>;
104
+ declare function smpRxjsThrowOnCondition<T>(condition: (value: T) => boolean, errorFactory?: (value: T) => any): OperatorFunction<T, T>;
105
105
 
106
106
  export { SmpAbstractRxjsTtlCacheStrategy, SmpRxjsInMemoryCache, smpRxjsCatchOnly, smpRxjsQueue, smpRxjsSequence, smpRxjsThrowIfEmpty, smpRxjsThrowOnCondition };
@@ -0,0 +1,25 @@
1
+ declare enum SmpSocialSignInKeys {
2
+ APPLE = "APPLE",
3
+ FACEBOOK = "FACEBOOK",
4
+ GOOGLE = "GOOGLE"
5
+ }
6
+
7
+ declare enum SmpSocialSignInUxModes {
8
+ POPUP = "POPUP",
9
+ REDIRECT = "REDIRECT"
10
+ }
11
+
12
+ declare enum SmpFirebaseErrors {
13
+ DIFFERENT_CREDENTIAL = "auth/account-exists-with-different-credential",
14
+ DIFFERENT_CREDENTIAL_APPLE = "auth/account-exists-with-different-credential/apple",
15
+ DIFFERENT_CREDENTIAL_FACEBOOK = "auth/account-exists-with-different-credential/facebook",
16
+ DIFFERENT_CREDENTIAL_GOOGLE = "auth/account-exists-with-different-credential/google",
17
+ EMAIL_EXISTS = "auth/email-already-exists",
18
+ INVALID_ACTION_CODE = "auth/invalid-action-code",
19
+ POPUP_BLOCKED = "auth/popup-blocked",
20
+ POPUP_CLOSED_BY_USER = "auth/popup-closed-by-user",
21
+ USER_NOT_FOUND = "auth/user-not-found",
22
+ WRONG_PASSWORD = "auth/wrong-password"
23
+ }
24
+
25
+ export { SmpSocialSignInKeys as S, SmpSocialSignInUxModes as a, SmpFirebaseErrors as b };
@@ -24,4 +24,4 @@ interface SmpGenericResponseBase<T = any> {
24
24
  messages: SmpResponseMessageBase[] | void;
25
25
  }
26
26
 
27
- export { SmpResponseMessage as S, type SmpGenericResponseBase as a, type SmpResponseMessageBase as b, SmpResponseMessageTypes as c };
27
+ export { SmpResponseMessage as S, SmpResponseMessageTypes as a, type SmpGenericResponseBase as b, type SmpResponseMessageBase as c };
package/dist/cjs/zod.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var D=Object.create;var u=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var a=(t,e)=>u(t,"name",{value:e,configurable:!0});var C=(t,e)=>{for(var n in e)u(t,n,{get:e[n],enumerable:!0})},l=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let d of b(e))!w.call(t,d)&&d!==n&&u(t,d,{get:()=>e[d],enumerable:!(i=g(e,d))||i.enumerable});return t};var S=(t,e,n)=>(n=t!=null?D(_(t)):{},l(e||!t||!t.__esModule?u(n,"default",{value:t,enumerable:!0}):n,t)),T=t=>l(u({},"__esModule",{value:!0}),t);var R={};C(R,{SmpZodDateTime:()=>x,smpGenericResponseSchema:()=>N,smpResponseMessageSchema:()=>h,smpZodDateTime:()=>O});module.exports=T(R);var f=require("zod");var I=(function(t){return t.INFO="INFO",t.SUCCESS="SUCCESS",t.WARNING="WARNING",t.ERROR="ERROR",t})({});var h=f.z.object({message:f.z.string(),type:f.z.nativeEnum(I)});var p=require("zod");var N=p.z.object({data:p.z.unknown().optional(),messages:p.z.array(h).optional()});var s=S(require("zod"),1),m=require("ts-luxon");var x=class t extends s.default.ZodType{static{a(this,"SmpZodDateTime")}constructor(e){super({typeName:"SmpZodDateTime",coerce:e?.coerce??!1,checks:e?.checks??[]})}_parse(e){let n=this._getOrReturnCtx(e),i=n.data;if(this._def.coerce&&(i=this._coerceToDateTime(i),!(i instanceof m.DateTime)||!i.isValid))return s.default.addIssueToContext(n,{code:s.ZodIssueCode.invalid_type,expected:s.ZodParsedType.date,received:s.ZodParsedType.unknown,path:n.path,message:"Invalid date format"}),s.default.INVALID;if((!(i instanceof m.DateTime)||!i.isValid)&&!this._def.coerce)return s.default.addIssueToContext(n,{code:s.ZodIssueCode.invalid_type,expected:s.ZodParsedType.date,received:s.ZodParsedType.unknown,path:n.path,message:"Input must be a valid DateTime object"}),s.default.INVALID;let d={min:a((o,r,c)=>{if(o.min&&r<o.min)return{code:s.ZodIssueCode.too_small,minimum:o.min.toMillis(),type:"date",inclusive:!0,message:o.message??`Date must be \u2265 ${o.min.toISODate()}`,path:c.path}},"min"),max:a((o,r,c)=>{if(o.max&&r>o.max)return{code:s.ZodIssueCode.too_big,maximum:o.max.toMillis(),type:"date",inclusive:!0,message:o.message??`Date must be \u2264 ${o.max.toISODate()}`,path:c.path}},"max"),between:a((o,r,c)=>{if(o.min&&o.max&&(r<o.min||r>o.max))return{code:s.ZodIssueCode.custom,message:o.message??`Date must be between ${o.min.toISODate()} and ${o.max.toISODate()}`,path:c.path}},"between")};for(let o of this._def.checks)if(i instanceof m.DateTime&&i.isValid){let r=d[o.kind](o,i,n);r&&s.default.addIssueToContext(n,r)}return n.common.issues.length>0?s.default.INVALID:s.default.OK(i)}between(e,n,i){return new t({...this._def,checks:[...this._def.checks,{kind:"between",min:e.toUTC(),max:n.toUTC(),message:i}]})}coerce(){return new t({...this._def,coerce:!0})}max(e,n){return new t({...this._def,checks:[...this._def.checks,{kind:"max",max:e.toUTC(),message:n}]})}min(e,n){return new t({...this._def,checks:[...this._def.checks,{kind:"min",min:e.toUTC(),message:n}]})}_coerceToDateTime(e){if(e instanceof m.DateTime&&e.isValid)return e;let n={string:a(()=>m.DateTime.fromJSDate(new Date(e)),"string"),number:a(()=>m.DateTime.fromMillis(e),"number"),object:a(()=>m.DateTime.fromJSDate(e),"object"),default:a(()=>null,"default")};return(n[typeof e]||n.default)()}},O=a((t={})=>new x({coerce:t.coerce??!1,checks:[]}),"smpZodDateTime");0&&(module.exports={SmpZodDateTime,smpGenericResponseSchema,smpResponseMessageSchema,smpZodDateTime});
1
+ "use strict";var D=Object.create;var u=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var a=(t,e)=>u(t,"name",{value:e,configurable:!0});var C=(t,e)=>{for(var n in e)u(t,n,{get:e[n],enumerable:!0})},l=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let d of b(e))!w.call(t,d)&&d!==n&&u(t,d,{get:()=>e[d],enumerable:!(i=g(e,d))||i.enumerable});return t};var S=(t,e,n)=>(n=t!=null?D(_(t)):{},l(e||!t||!t.__esModule?u(n,"default",{value:t,enumerable:!0}):n,t)),T=t=>l(u({},"__esModule",{value:!0}),t);var R={};C(R,{SmpZodDateTime:()=>x,smpGenericResponseSchema:()=>N,smpResponseMessageSchema:()=>h,smpZodDateTime:()=>O});module.exports=T(R);var p=require("zod");var f=require("zod");var I=(function(t){return t.INFO="INFO",t.SUCCESS="SUCCESS",t.WARNING="WARNING",t.ERROR="ERROR",t})({});var h=f.z.object({message:f.z.string(),type:f.z.nativeEnum(I)});var N=p.z.object({data:p.z.unknown().optional(),messages:p.z.array(h).optional()});var s=S(require("zod"),1),m=require("ts-luxon");var x=class t extends s.default.ZodType{static{a(this,"SmpZodDateTime")}constructor(e){super({typeName:"SmpZodDateTime",coerce:e?.coerce??!1,checks:e?.checks??[]})}_parse(e){let n=this._getOrReturnCtx(e),i=n.data;if(this._def.coerce&&(i=this._coerceToDateTime(i),!(i instanceof m.DateTime)||!i.isValid))return s.default.addIssueToContext(n,{code:s.ZodIssueCode.invalid_type,expected:s.ZodParsedType.date,received:s.ZodParsedType.unknown,path:n.path,message:"Invalid date format"}),s.default.INVALID;if((!(i instanceof m.DateTime)||!i.isValid)&&!this._def.coerce)return s.default.addIssueToContext(n,{code:s.ZodIssueCode.invalid_type,expected:s.ZodParsedType.date,received:s.ZodParsedType.unknown,path:n.path,message:"Input must be a valid DateTime object"}),s.default.INVALID;let d={min:a((o,r,c)=>{if(o.min&&r<o.min)return{code:s.ZodIssueCode.too_small,minimum:o.min.toMillis(),type:"date",inclusive:!0,message:o.message??`Date must be \u2265 ${o.min.toISODate()}`,path:c.path}},"min"),max:a((o,r,c)=>{if(o.max&&r>o.max)return{code:s.ZodIssueCode.too_big,maximum:o.max.toMillis(),type:"date",inclusive:!0,message:o.message??`Date must be \u2264 ${o.max.toISODate()}`,path:c.path}},"max"),between:a((o,r,c)=>{if(o.min&&o.max&&(r<o.min||r>o.max))return{code:s.ZodIssueCode.custom,message:o.message??`Date must be between ${o.min.toISODate()} and ${o.max.toISODate()}`,path:c.path}},"between")};for(let o of this._def.checks)if(i instanceof m.DateTime&&i.isValid){let r=d[o.kind](o,i,n);r&&s.default.addIssueToContext(n,r)}return n.common.issues.length>0?s.default.INVALID:s.default.OK(i)}between(e,n,i){return new t({...this._def,checks:[...this._def.checks,{kind:"between",min:e.toUTC(),max:n.toUTC(),message:i}]})}coerce(){return new t({...this._def,coerce:!0})}max(e,n){return new t({...this._def,checks:[...this._def.checks,{kind:"max",max:e.toUTC(),message:n}]})}min(e,n){return new t({...this._def,checks:[...this._def.checks,{kind:"min",min:e.toUTC(),message:n}]})}_coerceToDateTime(e){if(e instanceof m.DateTime&&e.isValid)return e;let n={string:a(()=>m.DateTime.fromJSDate(new Date(e)),"string"),number:a(()=>m.DateTime.fromMillis(e),"number"),object:a(()=>m.DateTime.fromJSDate(e),"object"),default:a(()=>null,"default")};return(n[typeof e]||n.default)()}},O=a((t={})=>new x({coerce:t.coerce??!1,checks:[]}),"smpZodDateTime");0&&(module.exports={SmpZodDateTime,smpGenericResponseSchema,smpResponseMessageSchema,smpZodDateTime});
2
2
  //# sourceMappingURL=zod.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/zod.ts","../../src/shared/zod/smp-response-message.schema.ts","../../src/shared/api/smp-response-message-types.enum.ts","../../src/shared/zod/smp-generic-response.schema.ts","../../src/shared/zod/smp-zod-date-time.definition.ts"],"sourcesContent":["export * from \"./shared/zod/index.js\";\n","import {z, ZodTypeAny} from \"zod\";\n//\nimport {SmpResponseMessage} from \"../api/smp-response-message.class.js\";\nimport {SmpResponseMessageTypes} from \"../api/smp-response-message-types.enum.js\";\n\nexport const smpResponseMessageSchema = z.object({\n message: z.string(),\n type: z.nativeEnum(SmpResponseMessageTypes)\n} as Record<keyof SmpResponseMessage, ZodTypeAny>);\n","export enum SmpResponseMessageTypes {\n INFO = \"INFO\",\n SUCCESS = \"SUCCESS\",\n WARNING = \"WARNING\",\n ERROR = \"ERROR\"\n}\n","import {z, ZodTypeAny} from \"zod\";\n//\nimport {SmpGenericResponseBase} from \"../api/smp-generic-response-base.interface.js\";\nimport {smpResponseMessageSchema} from \"./smp-response-message.schema.js\";\n\nexport const smpGenericResponseSchema = z.object({\n data: z.unknown().optional(),\n messages: z.array(smpResponseMessageSchema).optional()\n} as Record<keyof SmpGenericResponseBase, ZodTypeAny>);\n","import z, {ZodTypeDef, ZodIssueCode, ParseInput, ParseContext, ParseReturnType, ZodParsedType} from \"zod\";\nimport {DateTime} from \"ts-luxon\";\n\ninterface SmpZodDateTimeCheck {\n kind: \"min\" | \"max\" | \"between\";\n min?: DateTime;\n max?: DateTime;\n message?: string;\n}\n\ninterface SmpZodDateTimeDef extends ZodTypeDef {\n coerce: boolean;\n checks: SmpZodDateTimeCheck[];\n typeName: \"SmpZodDateTime\";\n}\n\nexport class SmpZodDateTime extends z.ZodType<DateTime, SmpZodDateTimeDef> {\n // Constructor and other methods (between, coerce, max, min, _coerceToDateTime) remain the same as your latest version or my previous suggestions.\n // For brevity, only _parse is shown fully modified here. Ensure other parts of the class are consistent.\n\n constructor(def?: Partial<SmpZodDateTimeDef>) {\n super({\n typeName: \"SmpZodDateTime\",\n coerce: def?.coerce ?? false,\n checks: def?.checks ?? []\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n _parse(input: ParseInput): ParseReturnType<DateTime> {\n const ctx = this._getOrReturnCtx(input);\n let val = ctx.data;\n\n if (this._def.coerce) {\n val = this._coerceToDateTime(val); // Assuming _coerceToDateTime is implemented\n if (!(val instanceof DateTime) || !val.isValid) {\n z.addIssueToContext(ctx, { // Changed from ctx.addIssue\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.date, // Using ZodParsedType.date\n received: ZodParsedType.unknown,\n path: ctx.path,\n message: \"Invalid date format\"\n });\n return z.INVALID;\n }\n }\n\n // Ensure val is a DateTime object before proceeding with checks if not coercing\n // or if coercion failed to produce a DateTime (though the above check should catch it)\n if (!(val instanceof DateTime) || !val.isValid) {\n // If not coercing, and it's not a valid DateTime, this is an invalid type.\n // This specific case might be implicitly handled if !this._def.coerce means val must already be DateTime.\n // However, adding an explicit check if not coercing can be safer.\n if (!this._def.coerce) {\n z.addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.date, // Or a custom type name if you prefer\n received: ZodParsedType.unknown, // Or more specific if possible\n path: ctx.path,\n message: \"Input must be a valid DateTime object\"\n });\n return z.INVALID;\n }\n // If coercion was supposed to happen, and we still don't have a valid DateTime,\n // the earlier check inside the `if (this._def.coerce)` block should have caught it.\n }\n\n\n const checkMap: Record<SmpZodDateTimeCheck[\"kind\"], (check: SmpZodDateTimeCheck, dateTimeVal: DateTime, parseCtx: ParseContext) => z.ZodIssue | undefined> = {\n min: (check, dateTimeVal, parseCtx) => {\n if (check.min && dateTimeVal < check.min) {\n return {\n code: ZodIssueCode.too_small,\n minimum: check.min.toMillis(), // Changed to number (milliseconds)\n type: \"date\", // Added type\n inclusive: true,\n message: check.message ?? `Date must be ≥ ${check.min.toISODate()}`,\n path: parseCtx.path\n };\n }\n return undefined;\n },\n max: (check, dateTimeVal, parseCtx) => {\n if (check.max && dateTimeVal > check.max) {\n return {\n code: ZodIssueCode.too_big,\n maximum: check.max.toMillis(), // Changed to number (milliseconds)\n type: \"date\", // Added type\n inclusive: true, // Added inclusive\n message: check.message ?? `Date must be ≤ ${check.max.toISODate()}`,\n path: parseCtx.path\n };\n }\n return undefined;\n },\n between: (check, dateTimeVal, parseCtx) => {\n if (check.min && check.max && (dateTimeVal < check.min || dateTimeVal > check.max)) {\n return {\n code: ZodIssueCode.custom,\n message: check.message ?? `Date must be between ${check.min.toISODate()} and ${check.max.toISODate()}`,\n path: parseCtx.path\n // Optionally, add params for more structured error data:\n // params: { min: check.min.toISO(), max: check.max.toISO() }\n };\n }\n return undefined;\n }\n };\n\n for (const check of this._def.checks) {\n // Ensure val is a DateTime before passing to checkMap functions\n // This is crucial if coercion didn't happen or didn't result in a DateTime.\n // The earlier checks should ideally ensure 'val' is a valid DateTime if it reached this point.\n if (val instanceof DateTime && val.isValid) {\n const issueData = checkMap[check.kind](check, val, ctx);\n if (issueData) {\n z.addIssueToContext(ctx, issueData); // Changed from ctx.addIssue\n }\n }\n else {\n // This case should ideally be caught earlier (e.g., if not coercing, or if coercion failed)\n // If it reaches here, it implies a logic flaw or an unexpected state.\n // For robustness, you might add a generic invalid_type issue here if 'val' is not a DateTime.\n // However, the checks at the beginning of _parse should prevent this.\n }\n }\n\n if (ctx.common.issues.length > 0) { // Check ctx.common.issues.length\n return z.INVALID;\n }\n\n return z.OK(val as DateTime); // Ensure the 'val' returned by OK is typed as DateTime\n }\n\n between(min: DateTime, max: DateTime, message?: string): this {\n return new SmpZodDateTime({\n ...this._def,\n checks: [...this._def.checks, {kind: \"between\", min: min.toUTC(), max: max.toUTC(), message}]\n }) as this;\n }\n\n coerce(): this {\n return new SmpZodDateTime({\n ...this._def,\n coerce: true\n }) as this;\n }\n\n max(max: DateTime, message?: string): this {\n return new SmpZodDateTime({\n ...this._def,\n checks: [...this._def.checks, {kind: \"max\", max: max.toUTC(), message}]\n }) as this;\n }\n\n min(min: DateTime, message?: string): this {\n return new SmpZodDateTime({\n ...this._def,\n checks: [...this._def.checks, {kind: \"min\", min: min.toUTC(), message}]\n }) as this;\n }\n\n // Coercion helper function (ensure it's robust as discussed previously)\n private _coerceToDateTime(val: any): DateTime | null {\n if (val instanceof DateTime && val.isValid) {\n return val; // Already valid DateTime\n }\n\n const coercionMap: Record<string, () => DateTime | null> = {\n string: () => DateTime.fromJSDate(new Date(val)),\n number: () => DateTime.fromMillis(val),\n object: () => DateTime.fromJSDate(val),\n default: () => null\n };\n\n return (coercionMap[typeof val] || coercionMap.default)();\n }\n}\n\nexport const smpZodDateTime = (opts: { coerce?: boolean } = {}) => {\n return new SmpZodDateTime({\n coerce: opts.coerce ?? false,\n checks: []\n });\n};\n"],"mappings":"6mBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,EAAA,6BAAAC,EAAA,6BAAAC,EAAA,mBAAAC,IAAA,eAAAC,EAAAN,GCAA,IAAAO,EAA4B,eCArB,IAAKC,GAAAA,SAAAA,EAAAA,8EAAAA,QDKL,IAAMC,EAA2BC,IAAEC,OAAO,CAC7CC,QAASF,IAAEG,OAAM,EACjBC,KAAMJ,IAAEK,WAAWC,CAAAA,CACvB,CAAA,EERA,IAAAC,EAA4B,eAKrB,IAAMC,EAA2BC,IAAEC,OAAO,CAC7CC,KAAMF,IAAEG,QAAO,EAAGC,SAAQ,EAC1BC,SAAUL,IAAEM,MAAMC,CAAAA,EAA0BH,SAAQ,CACxD,CAAA,ECRA,IAAAI,EAAoG,oBACpGC,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AAe,CACtB,GAAG,KAAKc,KACRP,OAAQ,IAAI,KAAKO,KAAKP,OAAQ,CAACwC,KAAM,MAAON,IAAKA,EAAIW,MAAK,EAAIxB,QAAAA,CAAO,EACzE,CAAA,CACJ,CAEAG,IAAIA,EAAeH,EAAwB,CACvC,OAAO,IAAI5B,EAAe,CACtB,GAAG,KAAKc,KACRP,OAAQ,IAAI,KAAKO,KAAKP,OAAQ,CAACwC,KAAM,MAAOhB,IAAKA,EAAIqB,MAAK,EAAIxB,QAAAA,CAAO,EACzE,CAAA,CACJ,CAGQb,kBAAkBH,EAA2B,CACjD,GAAIA,aAAeI,YAAYJ,EAAIK,QAC/B,OAAOL,EAGX,IAAMyC,EAAqD,CACvDC,OAAQnD,EAAA,IAAMa,WAASuC,WAAW,IAAIC,KAAK5C,CAAAA,CAAAA,EAAnC,UACR6C,OAAQtD,EAAA,IAAMa,WAAS0C,WAAW9C,CAAAA,EAA1B,UACR+C,OAAQxD,EAAA,IAAMa,WAASuC,WAAW3C,CAAAA,EAA1B,UACRgD,QAASzD,EAAA,IAAM,KAAN,UACb,EAEA,OAAQkD,EAAY,OAAOzC,CAAAA,GAAQyC,EAAYO,SAAM,CACzD,CACJ,EAEaC,EAAiB1D,EAAA,CAAC2D,EAA6B,CAAC,IAClD,IAAI9D,EAAe,CACtBM,OAAQwD,EAAKxD,QAAU,GACvBC,OAAQ,CAAA,CACZ,CAAA,EAJ0B","names":["zod_exports","__export","SmpZodDateTime","smpGenericResponseSchema","smpResponseMessageSchema","smpZodDateTime","__toCommonJS","import_zod","SmpResponseMessageTypes","smpResponseMessageSchema","z","object","message","string","type","nativeEnum","SmpResponseMessageTypes","import_zod","smpGenericResponseSchema","z","object","data","unknown","optional","messages","array","smpResponseMessageSchema","import_zod","import_ts_luxon","SmpZodDateTime","z","ZodType","__name","def","typeName","coerce","checks","_parse","input","ctx","_getOrReturnCtx","val","data","_def","_coerceToDateTime","DateTime","isValid","addIssueToContext","code","ZodIssueCode","invalid_type","expected","ZodParsedType","date","received","unknown","path","message","INVALID","checkMap","min","check","dateTimeVal","parseCtx","too_small","minimum","toMillis","type","inclusive","toISODate","max","too_big","maximum","between","custom","issueData","kind","common","issues","length","OK","toUTC","coercionMap","string","fromJSDate","Date","number","fromMillis","object","default","smpZodDateTime","opts"]}
1
+ {"version":3,"sources":["../../src/zod.ts","../../src/shared/zod/smp-generic-response.schema.ts","../../src/shared/zod/smp-response-message.schema.ts","../../src/shared/api/smp-response-message-types.enum.ts","../../src/shared/zod/smp-zod-date-time.definition.ts"],"sourcesContent":["export * from \"./shared/zod/index.js\";\n","import {z, ZodTypeAny} from \"zod\";\n//\nimport {SmpGenericResponseBase} from \"../api/smp-generic-response-base.interface.js\";\nimport {smpResponseMessageSchema} from \"./smp-response-message.schema.js\";\n\nexport const smpGenericResponseSchema = z.object({\n data: z.unknown().optional(),\n messages: z.array(smpResponseMessageSchema).optional()\n} as Record<keyof SmpGenericResponseBase, ZodTypeAny>);\n","import {z, ZodTypeAny} from \"zod\";\n//\nimport {SmpResponseMessage} from \"../api/smp-response-message.class.js\";\nimport {SmpResponseMessageTypes} from \"../api/smp-response-message-types.enum.js\";\n\nexport const smpResponseMessageSchema = z.object({\n message: z.string(),\n type: z.nativeEnum(SmpResponseMessageTypes)\n} as Record<keyof SmpResponseMessage, ZodTypeAny>);\n","export enum SmpResponseMessageTypes {\n INFO = \"INFO\",\n SUCCESS = \"SUCCESS\",\n WARNING = \"WARNING\",\n ERROR = \"ERROR\"\n}\n","import z, {ZodTypeDef, ZodIssueCode, ParseInput, ParseContext, ParseReturnType, ZodParsedType} from \"zod\";\nimport {DateTime} from \"ts-luxon\";\n\ninterface SmpZodDateTimeCheck {\n kind: \"min\" | \"max\" | \"between\";\n min?: DateTime;\n max?: DateTime;\n message?: string;\n}\n\ninterface SmpZodDateTimeDef extends ZodTypeDef {\n coerce: boolean;\n checks: SmpZodDateTimeCheck[];\n typeName: \"SmpZodDateTime\";\n}\n\nexport class SmpZodDateTime extends z.ZodType<DateTime, SmpZodDateTimeDef> {\n // Constructor and other methods (between, coerce, max, min, _coerceToDateTime) remain the same as your latest version or my previous suggestions.\n // For brevity, only _parse is shown fully modified here. Ensure other parts of the class are consistent.\n\n constructor(def?: Partial<SmpZodDateTimeDef>) {\n super({\n typeName: \"SmpZodDateTime\",\n coerce: def?.coerce ?? false,\n checks: def?.checks ?? []\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n _parse(input: ParseInput): ParseReturnType<DateTime> {\n const ctx = this._getOrReturnCtx(input);\n let val = ctx.data;\n\n if (this._def.coerce) {\n val = this._coerceToDateTime(val); // Assuming _coerceToDateTime is implemented\n if (!(val instanceof DateTime) || !val.isValid) {\n z.addIssueToContext(ctx, { // Changed from ctx.addIssue\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.date, // Using ZodParsedType.date\n received: ZodParsedType.unknown,\n path: ctx.path,\n message: \"Invalid date format\"\n });\n return z.INVALID;\n }\n }\n\n // Ensure val is a DateTime object before proceeding with checks if not coercing\n // or if coercion failed to produce a DateTime (though the above check should catch it)\n if (!(val instanceof DateTime) || !val.isValid) {\n // If not coercing, and it's not a valid DateTime, this is an invalid type.\n // This specific case might be implicitly handled if !this._def.coerce means val must already be DateTime.\n // However, adding an explicit check if not coercing can be safer.\n if (!this._def.coerce) {\n z.addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.date, // Or a custom type name if you prefer\n received: ZodParsedType.unknown, // Or more specific if possible\n path: ctx.path,\n message: \"Input must be a valid DateTime object\"\n });\n return z.INVALID;\n }\n // If coercion was supposed to happen, and we still don't have a valid DateTime,\n // the earlier check inside the `if (this._def.coerce)` block should have caught it.\n }\n\n\n const checkMap: Record<SmpZodDateTimeCheck[\"kind\"], (check: SmpZodDateTimeCheck, dateTimeVal: DateTime, parseCtx: ParseContext) => z.ZodIssue | undefined> = {\n min: (check, dateTimeVal, parseCtx) => {\n if (check.min && dateTimeVal < check.min) {\n return {\n code: ZodIssueCode.too_small,\n minimum: check.min.toMillis(), // Changed to number (milliseconds)\n type: \"date\", // Added type\n inclusive: true,\n message: check.message ?? `Date must be ≥ ${check.min.toISODate()}`,\n path: parseCtx.path\n };\n }\n return undefined;\n },\n max: (check, dateTimeVal, parseCtx) => {\n if (check.max && dateTimeVal > check.max) {\n return {\n code: ZodIssueCode.too_big,\n maximum: check.max.toMillis(), // Changed to number (milliseconds)\n type: \"date\", // Added type\n inclusive: true, // Added inclusive\n message: check.message ?? `Date must be ≤ ${check.max.toISODate()}`,\n path: parseCtx.path\n };\n }\n return undefined;\n },\n between: (check, dateTimeVal, parseCtx) => {\n if (check.min && check.max && (dateTimeVal < check.min || dateTimeVal > check.max)) {\n return {\n code: ZodIssueCode.custom,\n message: check.message ?? `Date must be between ${check.min.toISODate()} and ${check.max.toISODate()}`,\n path: parseCtx.path\n // Optionally, add params for more structured error data:\n // params: { min: check.min.toISO(), max: check.max.toISO() }\n };\n }\n return undefined;\n }\n };\n\n for (const check of this._def.checks) {\n // Ensure val is a DateTime before passing to checkMap functions\n // This is crucial if coercion didn't happen or didn't result in a DateTime.\n // The earlier checks should ideally ensure 'val' is a valid DateTime if it reached this point.\n if (val instanceof DateTime && val.isValid) {\n const issueData = checkMap[check.kind](check, val, ctx);\n if (issueData) {\n z.addIssueToContext(ctx, issueData); // Changed from ctx.addIssue\n }\n }\n else {\n // This case should ideally be caught earlier (e.g., if not coercing, or if coercion failed)\n // If it reaches here, it implies a logic flaw or an unexpected state.\n // For robustness, you might add a generic invalid_type issue here if 'val' is not a DateTime.\n // However, the checks at the beginning of _parse should prevent this.\n }\n }\n\n if (ctx.common.issues.length > 0) { // Check ctx.common.issues.length\n return z.INVALID;\n }\n\n return z.OK(val as DateTime); // Ensure the 'val' returned by OK is typed as DateTime\n }\n\n between(min: DateTime, max: DateTime, message?: string): this {\n return new SmpZodDateTime({\n ...this._def,\n checks: [...this._def.checks, {kind: \"between\", min: min.toUTC(), max: max.toUTC(), message}]\n }) as this;\n }\n\n coerce(): this {\n return new SmpZodDateTime({\n ...this._def,\n coerce: true\n }) as this;\n }\n\n max(max: DateTime, message?: string): this {\n return new SmpZodDateTime({\n ...this._def,\n checks: [...this._def.checks, {kind: \"max\", max: max.toUTC(), message}]\n }) as this;\n }\n\n min(min: DateTime, message?: string): this {\n return new SmpZodDateTime({\n ...this._def,\n checks: [...this._def.checks, {kind: \"min\", min: min.toUTC(), message}]\n }) as this;\n }\n\n // Coercion helper function (ensure it's robust as discussed previously)\n private _coerceToDateTime(val: any): DateTime | null {\n if (val instanceof DateTime && val.isValid) {\n return val; // Already valid DateTime\n }\n\n const coercionMap: Record<string, () => DateTime | null> = {\n string: () => DateTime.fromJSDate(new Date(val)),\n number: () => DateTime.fromMillis(val),\n object: () => DateTime.fromJSDate(val),\n default: () => null\n };\n\n return (coercionMap[typeof val] || coercionMap.default)();\n }\n}\n\nexport const smpZodDateTime = (opts: { coerce?: boolean } = {}) => {\n return new SmpZodDateTime({\n coerce: opts.coerce ?? false,\n checks: []\n });\n};\n"],"mappings":"6mBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,EAAA,6BAAAC,EAAA,6BAAAC,EAAA,mBAAAC,IAAA,eAAAC,EAAAN,GCAA,IAAAO,EAA4B,eCA5B,IAAAC,EAA4B,eCArB,IAAKC,GAAAA,SAAAA,EAAAA,8EAAAA,QDKL,IAAMC,EAA2BC,IAAEC,OAAO,CAC7CC,QAASF,IAAEG,OAAM,EACjBC,KAAMJ,IAAEK,WAAWC,CAAAA,CACvB,CAAA,EDHO,IAAMC,EAA2BC,IAAEC,OAAO,CAC7CC,KAAMF,IAAEG,QAAO,EAAGC,SAAQ,EAC1BC,SAAUL,IAAEM,MAAMC,CAAAA,EAA0BH,SAAQ,CACxD,CAAA,EGRA,IAAAI,EAAoG,oBACpGC,EAAuB,oBAehB,IAAMC,EAAN,MAAMA,UAAuBC,EAAAA,QAAEC,OAAO,CAhB7C,MAgB6C,CAAAC,EAAA,uB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W,MAAK,EAAIxB,QAAAA,CAAO,EACzE,CAAA,CACJ,CAEAG,IAAIA,EAAeH,EAAwB,CACvC,OAAO,IAAI5B,EAAe,CACtB,GAAG,KAAKc,KACRP,OAAQ,IAAI,KAAKO,KAAKP,OAAQ,CAACwC,KAAM,MAAOhB,IAAKA,EAAIqB,MAAK,EAAIxB,QAAAA,CAAO,EACzE,CAAA,CACJ,CAGQb,kBAAkBH,EAA2B,CACjD,GAAIA,aAAeI,YAAYJ,EAAIK,QAC/B,OAAOL,EAGX,IAAMyC,EAAqD,CACvDC,OAAQnD,EAAA,IAAMa,WAASuC,WAAW,IAAIC,KAAK5C,CAAAA,CAAAA,EAAnC,UACR6C,OAAQtD,EAAA,IAAMa,WAAS0C,WAAW9C,CAAAA,EAA1B,UACR+C,OAAQxD,EAAA,IAAMa,WAASuC,WAAW3C,CAAAA,EAA1B,UACRgD,QAASzD,EAAA,IAAM,KAAN,UACb,EAEA,OAAQkD,EAAY,OAAOzC,CAAAA,GAAQyC,EAAYO,SAAM,CACzD,CACJ,EAEaC,EAAiB1D,EAAA,CAAC2D,EAA6B,CAAC,IAClD,IAAI9D,EAAe,CACtBM,OAAQwD,EAAKxD,QAAU,GACvBC,OAAQ,CAAA,CACZ,CAAA,EAJ0B","names":["zod_exports","__export","SmpZodDateTime","smpGenericResponseSchema","smpResponseMessageSchema","smpZodDateTime","__toCommonJS","import_zod","import_zod","SmpResponseMessageTypes","smpResponseMessageSchema","z","object","message","string","type","nativeEnum","SmpResponseMessageTypes","smpGenericResponseSchema","z","object","data","unknown","optional","messages","array","smpResponseMessageSchema","import_zod","import_ts_luxon","SmpZodDateTime","z","ZodType","__name","def","typeName","coerce","checks","_parse","input","ctx","_getOrReturnCtx","val","data","_def","_coerceToDateTime","DateTime","isValid","addIssueToContext","code","ZodIssueCode","invalid_type","expected","ZodParsedType","date","received","unknown","path","message","INVALID","checkMap","min","check","dateTimeVal","parseCtx","too_small","minimum","toMillis","type","inclusive","toISODate","max","too_big","maximum","between","custom","issueData","kind","common","issues","length","OK","toUTC","coercionMap","string","fromJSDate","Date","number","fromMillis","object","default","smpZodDateTime","opts"]}
@@ -1,15 +1,7 @@
1
1
  import z$1, { z, ZodTypeDef, ParseInput, ParseReturnType } from 'zod';
2
- import { S as SmpResponseMessage, a as SmpGenericResponseBase } from './smp-generic-response-base.interface-D0jHrkjw.cjs';
2
+ import { b as SmpGenericResponseBase, S as SmpResponseMessage } from './smp-generic-response-base.interface-C0On2LBc.cjs';
3
3
  import { DateTime } from 'ts-luxon';
4
4
 
5
- declare const smpResponseMessageSchema: z.ZodObject<Record<keyof SmpResponseMessage, z.ZodTypeAny>, "strip", z.ZodTypeAny, {
6
- message?: any;
7
- type?: any;
8
- }, {
9
- message?: any;
10
- type?: any;
11
- }>;
12
-
13
5
  declare const smpGenericResponseSchema: z.ZodObject<Record<keyof SmpGenericResponseBase<any>, z.ZodTypeAny>, "strip", z.ZodTypeAny, {
14
6
  messages?: any;
15
7
  data?: any;
@@ -18,6 +10,14 @@ declare const smpGenericResponseSchema: z.ZodObject<Record<keyof SmpGenericRespo
18
10
  data?: any;
19
11
  }>;
20
12
 
13
+ declare const smpResponseMessageSchema: z.ZodObject<Record<keyof SmpResponseMessage, z.ZodTypeAny>, "strip", z.ZodTypeAny, {
14
+ message?: any;
15
+ type?: any;
16
+ }, {
17
+ message?: any;
18
+ type?: any;
19
+ }>;
20
+
21
21
  interface SmpZodDateTimeCheck {
22
22
  kind: "min" | "max" | "between";
23
23
  min?: DateTime;