@decaf-ts/decorator-validation 1.21.1 → 1.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/decorator-validation.cjs +1 -1
- package/dist/decorator-validation.cjs.map +1 -1
- package/dist/decorator-validation.js +1 -1
- package/dist/decorator-validation.js.map +1 -1
- package/lib/cjs/index.cjs +16 -2
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/model/ModelRegistry.cjs +29 -33
- package/lib/cjs/model/ModelRegistry.cjs.map +1 -1
- package/lib/cjs/model/decorators.cjs +2 -0
- package/lib/cjs/model/decorators.cjs.map +1 -1
- package/lib/cjs/validation/Validators/ListValidator.cjs +3 -9
- package/lib/cjs/validation/Validators/ListValidator.cjs.map +1 -1
- package/lib/cjs/validation/Validators/TypeValidator.cjs +5 -4
- package/lib/cjs/validation/Validators/TypeValidator.cjs.map +1 -1
- package/lib/cjs/validation/Validators/utils.cjs +44 -16
- package/lib/cjs/validation/Validators/utils.cjs.map +1 -1
- package/lib/esm/index.js +15 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/model/ModelRegistry.js +29 -33
- package/lib/esm/model/ModelRegistry.js.map +1 -1
- package/lib/esm/model/decorators.js +2 -0
- package/lib/esm/model/decorators.js.map +1 -1
- package/lib/esm/validation/Validators/ListValidator.js +3 -9
- package/lib/esm/validation/Validators/ListValidator.js.map +1 -1
- package/lib/esm/validation/Validators/TypeValidator.js +5 -4
- package/lib/esm/validation/Validators/TypeValidator.js.map +1 -1
- package/lib/esm/validation/Validators/utils.js +43 -16
- package/lib/esm/validation/Validators/utils.js.map +1 -1
- package/lib/types/index.d.cts +15 -1
- package/lib/types/index.d.mts +15 -1
- package/lib/types/validation/Validators/utils.d.cts +3 -1
- package/lib/types/validation/Validators/utils.d.mts +3 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Metadata as e,apply as t,metadata as r,Decoration as s,propMetadata as n,description as i,DecorationKeys as o,prop as a}from"@decaf-ts/decoration";import{__decorate as c,__metadata as u}from"tslib";import{ObjectAccumulator as l}from"typed-object-accumulator";const d={EQUALS:"equals",DIFF:"different",LESS_THAN:"lessThan",LESS_THAN_OR_EQUAL:"lessThanOrEqual",GREATER_THAN:"greaterThan",GREATER_THAN_OR_EQUAL:"greaterThanOrEqual"},h={REFLECT:"validation",DATE:"date",EMAIL:"email",FORMAT:"format",LIST:"list",MAX:"max",MAX_LENGTH:"maxlength",MIN:"min",MIN_LENGTH:"minlength",PASSWORD:"password",PATTERN:"pattern",REQUIRED:"required",STEP:"step",TYPE:"type",UNIQUE:"unique",URL:"url",VALIDATOR:"validator",ENUM:"enum",...d},g=["January","February","March","April","May","June","July","August","September","October","November","December"],f=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],p={REQUIRED:"This field is required",MIN:"The minimum value is {0}",MAX:"The maximum value is {0}",MIN_LENGTH:"The minimum length is {0}",MAX_LENGTH:"The maximum length is {0}",PATTERN:"The value does not match the pattern",EMAIL:"The value is not a valid email",URL:"The value is not a valid URL",TYPE:"Invalid type. Expected {0}, received {1}",STEP:"Invalid value. Not a step of {0}",DATE:"Invalid value. not a valid Date",DEFAULT:"There is an Error",PASSWORD:"Must be at least 8 characters and contain one of number, lower and upper case letters, and special character (@$!%*?&_-.,)",LIST:"Invalid list of {0}",MODEL_NOT_FOUND:"No model registered under {0}",EQUALS:"This field must be equal to field {0}",DIFF:"This field must be different from field {0}",LESS_THAN:"This field must be less than field {0}",LESS_THAN_OR_EQUAL:"This field must be less than or equal to field {0}",GREATER_THAN:"This field must be greater than field {0}",GREATER_THAN_OR_EQUAL:"This field must be greater than or equal to field {0}",UNIQUE:"Duplicate found, this field must be unique.",ENUM:"Value is not allowed. Must be one of {0}"},y={EMAIL:/[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?/,URL:/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i,PASSWORD:{CHAR8_ONE_OF_EACH:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&_\-.,])[A-Za-z\d@$!%*?&_\-.,]{8,}$/g},asd:"^(?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\xa1-\uffff][a-z0-9\xa1-\uffff_-]{0,62})?[a-z0-9\xa1-\uffff]\\.)+(?:[a-z\xa1-\uffff]{2,}\\.?))(?::\\d{2,5})?(?:[/?#]\\S*)?$"};function m(e,...t){return e.replace(/{(\d+)}/g,(e,r)=>void 0!==t[r]?t[r].toString():"undefined")}const E=m,b={INVALID_PATH:"Invalid path argument. Expected non-empty string but received: '{0}'",CONTEXT_NOT_OBJECT_COMPARISON:"Unable to access parent at level {0} for path '{1}': current context is not an object",PROPERTY_INVALID:"Failed to resolve path {0}: property '{1}' is invalid or does not exist.",PROPERTY_NOT_EXIST:"Failed to resolve path: property '{0}' does not exist.",UNSUPPORTED_TYPES_COMPARISON:"Unsupported types for comparison: '{0}' and '{1}'",NULL_OR_UNDEFINED_COMPARISON:"Comparison failed due to null or undefined value",INVALID_DATE_COMPARISON:"Invalid Date objects are not comparable",TYPE_MISMATCH_COMPARISON:"Cannot compare values of different types: {0} and {1}.",NAN_COMPARISON:"Comparison not supported for NaN values"},A=Symbol("_parent"),T=Symbol("isAsync"),N=e=>null===e?"null":e instanceof Date?"Date":Number.isNaN(e)?"NaN":e===1/0?"Infinity":e===-1/0?"-Infinity":Array.isArray(e)?"array":typeof e,M=e=>void 0===e||e instanceof Date||"bigint"==typeof e||"number"==typeof e&&Number.isFinite(e);function S(e,t){if(M(e)&&M(t))return!0;throw new TypeError(E(b.UNSUPPORTED_TYPES_COMPARISON,N(e),N(t)))}function O(e,t){if([null,void 0].includes(e)||[null,void 0].includes(t))throw Error(b.NULL_OR_UNDEFINED_COMPARISON);const r=typeof e,s=typeof t;if(r!==s){if("bigint"===r&&"number"===s)return t>Number(e);if("number"===r&&"bigint"===s)return Number(t)>e;throw new TypeError(E(b.TYPE_MISMATCH_COMPARISON,r,s))}if("number"===r&&"number"===s||"bigint"===r&&"bigint"===s){if(Number.isNaN(e)||Number.isNaN(t))throw new TypeError(b.NAN_COMPARISON);return t>e}if(e instanceof Date&&t instanceof Date){if(isNaN(e.getTime())||isNaN(t.getTime()))throw new TypeError(b.INVALID_DATE_COMPARISON);return e.getTime()<t.getTime()}throw new TypeError(E(b.UNSUPPORTED_TYPES_COMPARISON,N(e),N(t)))}function R(e,t){if([null,void 0].includes(e)||[null,void 0].includes(t))throw Error(b.NULL_OR_UNDEFINED_COMPARISON);const r=typeof e,s=typeof t;if(r!==s){if("bigint"===r&&"number"===s)return Number(e)>t;if("number"===r&&"bigint"===s)return e>Number(t);throw Error(E(b.TYPE_MISMATCH_COMPARISON,r,s))}if("number"===r&&"number"===s||"bigint"===r&&"bigint"===s){if(Number.isNaN(e)||Number.isNaN(t))throw new TypeError(b.NAN_COMPARISON);return e>t}if(e instanceof Date&&t instanceof Date){if(isNaN(e.getTime())||isNaN(t.getTime()))throw new TypeError(b.INVALID_DATE_COMPARISON);return e.getTime()>t.getTime()}throw new TypeError(E(b.UNSUPPORTED_TYPES_COMPARISON,N(e),N(t)))}function v(e,t){return typeof e===t.toLowerCase()||void 0!==e&&"object"==typeof e&&e.constructor&&e.constructor.name.toLowerCase()===t.toLowerCase()}function _(e,t){return!t.every(t=>!v(e,t))}function P(e,t){switch(typeof t){case"string":return v(e,t);case"object":return!Array.isArray(t)||_(e,t);case"function":return!t.name||"Object"===t.name||v(e,t.name);default:return!0}}function w(e){return e instanceof Set||e instanceof Map?e.size:e.length}class L{constructor(e,t=p.DEFAULT,...r){this.async=e,this.message=t,r.length&&(this.acceptedTypes=r),this.acceptedTypes&&(this.hasErrors=this.checkTypeAndHasErrors(this.hasErrors.bind(this)))}getMessage(e,...t){return E(e,...t)}checkTypeAndHasErrors(e){return function(t,r,s,...n){return void 0!==t&&this.acceptedTypes?_(t,this.acceptedTypes)?e(t,r,s,...n):this.getMessage(p.TYPE,this.acceptedTypes.join(", "),"number"!=typeof t?typeof t:isNaN(t)?"NaN":typeof t):e(t,r,s,...n)}.bind(this)}static isValidator(e){return e.constructor&&!!e.hasErrors}}class D extends L{constructor(e=p.DEFAULT,...t){super(!0,e,...t)}}class I extends L{constructor(e=p.DEFAULT,...t){super(!1,e,...t)}}class H{constructor(...e){this.cache={},this.customKeyCache={},this.register(...e)}getCustomKeys(){return Object.assign({},this.customKeyCache)}getKeys(){return Object.keys(this.cache)}get(e){if(!(e in this.cache))return;const t=this.cache[e];if(I.isValidator(t))return t;const r=new(t.default||t);return this.cache[e]=r,r}register(...e){e.forEach(e=>{if(I.isValidator(e)){if(e.validationKey in this.cache)return;this.cache[e.validationKey]=e}else{const{validationKey:t,validator:r,save:s}=e;if(t in this.cache)return;if(this.cache[t]=r,!s)return;const n={};n[t.toUpperCase()]=t,this.customKeyCache=Object.assign({},this.customKeyCache,n)}})}}var j;(e=>{e.DESCRIPTION="description",e.TYPE="design:type",e.MODEL="model",e.ANCHOR="__model",e.CONSTRUCTION="constructed-by",e.ATTRIBUTE="__attributes",e.HASHING="hashing",e.SERIALIZATION="serialization",e.DECORATORS="decorators",e.CONSTRUCTOR="__original"})(j||(j={}));const U="json";class x{static{this.actingValidatorRegistry=void 0}constructor(){}static setRegistry(e,t){t&&x.actingValidatorRegistry&&x.actingValidatorRegistry.getKeys().forEach(r=>{const s=e.get(r);s&&e.register(t(s))}),x.actingValidatorRegistry=e}static getRegistry(){return x.actingValidatorRegistry||(x.actingValidatorRegistry=new H),x.actingValidatorRegistry}static get(e){return x.getRegistry().get(e)}static register(...e){return x.getRegistry().register(...e)}static key(e){return h.REFLECT+e}static keys(){return this.getRegistry().getKeys()}static registerDecorator(t,r){const s=e.innerGet(Symbol.for(j.DECORATORS),e.key(h.REFLECT,t));s?.[t]||e.set(j.DECORATORS,e.key(h.REFLECT,t),r)}static decoratorFromKey(t){try{return e.innerGet(Symbol.for(j.DECORATORS),e.key(h.REFLECT,t))}catch(e){throw Error(`No decorator registered under ${t}: ${e}`)}}}function C(...e){return t(t=>(e.forEach(e=>{x.register({validator:t,validationKey:e,save:!0})}),t),r(h.VALIDATOR,e))}let F=class extends I{constructor(e=p.DATE){super(e,Number.name,Date.name,String.name)}hasErrors(e,t={}){if(void 0!==e&&("string"==typeof e&&(e=new Date(e)),Number.isNaN(e.getDate()))){const{message:e=""}=t;return this.getMessage(e||this.message)}}};function z(e,t,...r){if(e===t)return 0!==e||1/e==1/t;if(null==e||null==t)return e===t;if(typeof e!=typeof t)return!1;if(Number.isNaN(e)&&Number.isNaN(t))return!0;if("object"!=typeof e)return e===t;if(e instanceof Date&&t instanceof Date)return!(!isNaN(e.getTime())||!isNaN(t.getTime()))||e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.toString()===t.toString();if(e instanceof Error&&t instanceof Error)return e.name===t.name&&e.message===t.message;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(!z(e[s],t[s],...r))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[s,n]of e)if(!t.has(s)||!z(n,t.get(s),...r))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(e.byteLength!==t.byteLength)return!1;if(e.byteOffset!==t.byteOffset)return!1;if(e.buffer.byteLength!==t.buffer.byteLength)return!1;const r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);for(let e=0;e<r.length;e++)if(r[e]!==s[e])return!1;return!0}const s=Object.keys(e).filter(e=>!r.includes(e)),n=Object.keys(t).filter(e=>!r.includes(e));if(s.length!==n.length)return!1;for(const i of s){if(!n.includes(i))return!1;if(!z(e[i],t[i],...r))return!1}const i=Object.getOwnPropertySymbols(e).filter(e=>!r.includes(e.toString())),o=Object.getOwnPropertySymbols(t).filter(e=>!r.includes(e.toString()));if(i.length!==o.length)return!1;for(const s of i){if(!o.includes(s))return!1;if(!z(e[s],t[s],...r))return!1}return Object.getPrototypeOf(e)===Object.getPrototypeOf(t)}F=c([C(h.DATE),u("design:paramtypes",[String])],F);let Y=class extends I{constructor(e=p.DIFF){super(e)}hasErrors(e,t,r){let s;try{s=r.getValueFromPath(t[h.DIFF])}catch(e){return this.getMessage(e.message||this.message)}return z(e,s)?this.getMessage(t.message||this.message,t.label||t[h.DIFF]):void 0}};Y=c([C(h.DIFF),u("design:paramtypes",[String])],Y);const $=RegExp("^/(.+)/([gimus]*)$");let G=class extends I{constructor(e=p.PATTERN){super(e,"string")}getPattern(e){if(!$.test(e))return RegExp(e);const t=e.match($);return RegExp(t[1],t[2])}hasErrors(e,t){if(!e)return;let{pattern:r}=t;if(!r)throw Error("Missing Pattern");return r="string"==typeof r?this.getPattern(r):r,r.lastIndex=0,r.test(e)?void 0:this.getMessage(t.message||this.message)}};G=c([C(h.PATTERN),u("design:paramtypes",[String])],G);let Q=class extends G{constructor(e=p.EMAIL){super(e)}hasErrors(e,t={}){return super.hasErrors(e,{...t,message:t.message||this.message,pattern:t?.pattern||y.EMAIL})}};Q=c([C(h.EMAIL),u("design:paramtypes",[String])],Q);let k=class extends I{constructor(e=p.EQUALS){super(e)}hasErrors(e,t,r){let s;try{s=r.getValueFromPath(t[h.EQUALS])}catch(e){return this.getMessage(e.message||this.message)}return z(e,s)?void 0:this.getMessage(t.message||this.message,t.label||t[h.EQUALS])}};k=c([C(h.EQUALS),u("design:paramtypes",[String])],k);let V=class extends I{constructor(e=p.GREATER_THAN){super(e)}hasErrors(e,t,r){let s;try{s=r.getValueFromPath(t[h.GREATER_THAN])}catch(e){return this.getMessage(e.message||this.message)}try{if(!R(e,s))throw Error(t.message||this.message)}catch(e){return this.getMessage(e.message,t.label||t[h.GREATER_THAN])}}};V=c([C(h.GREATER_THAN),u("design:paramtypes",[String])],V);let q=class extends I{constructor(e=p.GREATER_THAN_OR_EQUAL){super(e)}hasErrors(e,t,r){let s;try{s=r.getValueFromPath(t[h.GREATER_THAN_OR_EQUAL])}catch(e){return this.getMessage(e.message||this.message)}try{if(S(e,s)&&z(e,s)||R(e,s))return;throw Error(t.message||this.message)}catch(e){return this.getMessage(e.message,t.label||t[h.GREATER_THAN_OR_EQUAL])}}};q=c([C(h.GREATER_THAN_OR_EQUAL),u("design:paramtypes",[String])],q);let B=class extends I{constructor(e=p.LESS_THAN){super(e)}hasErrors(e,t,r){let s;try{s=r.getValueFromPath(t[h.LESS_THAN])}catch(e){return this.getMessage(e.message||this.message)}try{if(!O(e,s))throw Error(t.message||this.message)}catch(e){return this.getMessage(e.message,t.label||t[h.LESS_THAN])}}};B=c([C(h.LESS_THAN),u("design:paramtypes",[String])],B);let X=class extends I{constructor(e=p.LESS_THAN_OR_EQUAL){super(e)}hasErrors(e,t,r){let s;try{s=r.getValueFromPath(t[h.LESS_THAN_OR_EQUAL])}catch(e){return this.getMessage(e.message||this.message)}try{if(S(e,s)&&z(e,s)||O(e,s))return;throw Error(t.message||this.message)}catch(e){return this.getMessage(e.message,t.label||t[h.LESS_THAN_OR_EQUAL])}}};X=c([C(h.LESS_THAN_OR_EQUAL),u("design:paramtypes",[String])],X);let K=class extends I{constructor(e=p.LIST){super(e,Array.name,Set.name)}hasErrors(e,t){if(!e||(Array.isArray(e)?!e.length:!e.size))return;const r=(Array.isArray(t.clazz)?t.clazz:[t.clazz]).map(e=>"string"==typeof e?e:e?.name||"function"!=typeof e?e?.name:e().name);let s,n=!0;for(let t=0;t<(Array.isArray(e)?e.length:e.size);t++)switch(s=[...e][t],typeof s){case"object":case"function":n=r.includes((s??{}).constructor?.name);break;default:n=r.some(e=>typeof s===e?.toLowerCase())}return n?void 0:this.getMessage(t.message||this.message,r)}};K=c([C(h.LIST),u("design:paramtypes",[String])],K);let W=class extends I{constructor(e=p.MAX_LENGTH){super(e,String.name,Array.name,Set.name,Map.name)}hasErrors(e,t){if(void 0!==e)return w(e)>t.maxlength?this.getMessage(t.message||this.message,t.maxlength):void 0}};W=c([C(h.MAX_LENGTH),u("design:paramtypes",[String])],W);let Z=class extends I{constructor(e=p.MAX){super(e,Number.name,Date.name,String.name)}hasErrors(e,t){if(void 0===e)return;let{max:r}=t;if(e instanceof Date&&!(r instanceof Date)&&(r=new Date(r),Number.isNaN(r.getDate())))throw Error("Invalid Max param defined");return e>r?this.getMessage(t.message||this.message,r):void 0}};Z=c([C(h.MAX),u("design:paramtypes",[String])],Z);let J=class extends I{constructor(e=p.MIN_LENGTH){super(e,String.name,Array.name,Set.name,Map.name)}hasErrors(e,t){if(void 0!==e)return w(e)<t.minlength?this.getMessage(t.message||this.message,t.minlength):void 0}};J=c([C(h.MIN_LENGTH),u("design:paramtypes",[String])],J);let ee=class extends I{constructor(e=p.MIN){super(e,Number.name,Date.name,String.name)}hasErrors(e,t){if(void 0===e)return;let{min:r}=t;if(e instanceof Date&&!(r instanceof Date)&&(r=new Date(r),Number.isNaN(r.getDate())))throw Error("Invalid Min param defined");return r>e?this.getMessage(t.message||this.message,r):void 0}};ee=c([C(h.MIN),u("design:paramtypes",[String])],ee);let te=class extends I{constructor(e=p.ENUM){super(e)}hasErrors(e,t){if(void 0!==e){if(Array.isArray(t.enum))return t.enum.includes(e)?void 0:this.getMessage(t.message||this.message,t.enum);if("object"==typeof t.enum){const r=Object.keys(t.enum);for(const s of r)if(t.enum[s]===e)return;return this.getMessage(t.message||this.message,Object.values(t.enum))}}}};te=c([C(h.ENUM),u("design:paramtypes",[String])],te);let re=class extends G{constructor(e=p.PASSWORD){super(e)}hasErrors(e,t={}){return super.hasErrors(e,{...t,message:t.message||this.message,[h.PATTERN]:t?.pattern||y.PASSWORD.CHAR8_ONE_OF_EACH})}};re=c([C(h.PASSWORD),u("design:paramtypes",[Object])],re);let se=class extends I{constructor(e=p.REQUIRED){super(e)}hasErrors(e,t={}){switch(typeof e){case"boolean":case"number":return void 0===e?this.getMessage(t.message||this.message):void 0;default:return e?void 0:this.getMessage(t.message||this.message)}}};se=c([C(h.REQUIRED),u("design:paramtypes",[String])],se);let ne=class extends I{constructor(e=p.STEP){super(e,"number","string")}hasErrors(e,t){if(void 0!==e)return Number(e)%Number(t.step)!==0?this.getMessage(t.message||this.message,t.step):void 0}};ne=c([C(h.STEP),u("design:paramtypes",[String])],ne);let ie=class extends I{constructor(e=p.TYPE){super(e)}hasErrors(e,t){if(void 0===e)return;const{type:r,message:s,customTypes:n}=t;let i=n||r;return i=(Array.isArray(i)?i:[i]).map(e=>"string"==typeof e?e:("function"!=typeof e||e.name||(e=e()),e.name||e)),P(e,i)?void 0:this.getMessage(s||this.message,"string"==typeof i?i:Array.isArray(i)?i.join(", "):i,typeof e)}};ie=c([C(h.TYPE),u("design:paramtypes",[String])],ie),x.register({validator:ie,validationKey:j.TYPE,save:!1});let oe=class extends G{constructor(e=p.URL){super(e)}hasErrors(e,t={}){return super.hasErrors(e,{...t,message:t.message||this.message,pattern:t.pattern||y.URL})}};function ae(e,t){let r=t;r.match(/hh/)?r=r.replace("hh","(?<hour>\\d{2})"):r.match(/h/)?r=r.replace("h","(?<hour>\\d{1,2})"):r.match(/HH/)?r=r.replace("HH","(?<hour>\\d{2})"):r.match(/H/)&&(r=r.replace("H","(?<hour>\\d{1,2})")),r.match(/mm/)?r=r.replace("mm","(?<minutes>\\d{2})"):r.match(/m/)&&(r=r.replace("m","(?<minutes>\\d{1,2})")),r.match(/ss/)?r=r.replace("ss","(?<seconds>\\d{2})"):r.match(/s/)&&(r=r.replace("s","(?<seconds>\\d{1,2})")),r.match(/dd/)?r=r.replace("dd","(?<day>\\d{2})"):r.match(/d/)&&(r=r.replace("d","(?<day>\\d{1,2})")),r.match(/EEEE/)?r=r.replace("EEEE","(?<dayofweek>\\w+)"):r.match(/EEEE/)&&(r=r.replace("EEE","(?<dayofweek>\\w+)")),r.match(/yyyy/)?r=r.replace("yyyy","(?<year>\\d{4})"):r.match(/yy/)&&(r=r.replace("yy","(?<year>\\d{2})")),r.match(/MMMM/)?r=r.replace("MMMM","(?<monthname>\\w+)"):r.match(/MMM/)&&(r=r.replace("MMM","(?<monthnamesmall>\\w+)")),r.match(/MM/)?r=r.replace("MM","(?<month>\\d{2})"):r.match(/M/)&&(r=r.replace("M","(?<month>\\d{1,2})")),r=r.replace("S","(?<milis>\\d{1,3})").replace("aaa","(?<ampm>\\w{2})");const s=RegExp(r,"g").exec(e);if(!s||!s.groups)return new Date(e);const n=e=>{if(!e)return 0;const t=parseInt(e);return isNaN(t)?0:t},i=n(s.groups.year),o=n(s.groups.day),a=s.groups.ampm;let c=n(s.groups.hour);a&&(c="PM"===a?c+12:c);const u=n(s.groups.minutes),l=n(s.groups.seconds),d=n(s.groups.milis),h=s.groups.monthname,f=s.groups.monthnamesmall;let p=s.groups.month;if(h)p=g.indexOf(h);else if(f){const t=g.find(e=>e.toLowerCase().startsWith(f.toLowerCase()));if(!t)return new Date(e);p=g.indexOf(t)}else p=n(""+p);return new Date(i,p-1,o,c,u,l,d)}function ce(e,t){if(e)return Object.defineProperty(e,"toISOString",{enumerable:!1,configurable:!1,value:new Proxy(e.toISOString,{apply:(e,r)=>de(r,t)})}),Object.defineProperty(e,"toString",{enumerable:!1,configurable:!1,value:new Proxy(e.toISOString,{apply:(e,r)=>de(r,t)})}),e}function ue(e){return e&&"[object Date]"===Object.prototype.toString.call(e)&&!Number.isNaN(e)}function le(e){return 10>e?"0"+e:e.toString()}function de(e,t="yyyy/MM/dd"){const r=e.getDate(),s=e.getMonth(),n=e.getFullYear(),i=e.getHours(),o=e.getMinutes(),a=e.getSeconds(),c=e.getMilliseconds(),u=i%12,l=le(u),d=le(i),h=le(o),p=le(a),y=12>i?"AM":"PM",m=f[e.getDay()],E=m.substr(0,3),b=le(r),A=s+1,T=le(A),N=g[s],M=N.substr(0,3),S=n+"",O=S.substr(2,2);return(t=t.replace("hh",l).replace("h",u.toString()).replace("HH",d).replace("H",i.toString()).replace("mm",h).replace("m",o.toString()).replace("ss",p).replace("s",a.toString()).replace("S",c.toString()).replace("dd",b).replace("d",r.toString()).replace("EEEE",m).replace("EEE",E).replace("yyyy",S).replace("yy",O).replace("aaa",y)).indexOf("MMM")>-1?t.replace("MMMM",N).replace("MMM",M):t.replace("MM",T).replace("M",A.toString())}function he(e,t){let r;if(t){if(t instanceof Date)try{r=ae(de(t,e),e)}catch(r){throw Error(E("Could not convert date {0} to format: {1}",t.toString(),e))}else if("string"==typeof t)r=ae(t,e);else if("number"==typeof t)r=ae(de(new Date(t),e),e);else{if(!ue(t))throw Error("Invalid value provided "+t);try{r=ae(de(new Date(t),e),e)}catch(r){throw Error(E("Could not convert date {0} to format: {1}",t,e))}}return ce(r,e)}}function ge(e,r,s){return t(n(r,s))}function fe(e,t,r){return x.registerDecorator(t,e),(e,s)=>ge(0,`${h.REFLECT}.${s}.${t}`,r)(e,s)}function pe(){return e=>{Object.prototype.hasOwnProperty.call(e,T)||(e[T]=!0)}}function ye(e=p.REQUIRED){const t=h.REQUIRED,r={message:e,description:"defines the attribute as required",async:!1};return s.for(t).define({decorator:fe,args:[ye,t,r]}).apply()}function me(e,t=p.MIN){const r=h.MIN,n={[h.MIN]:e,message:t,description:`defines the max value of the attribute as ${e} (applies to numbers or Dates)`,async:!1};return s.for(r).define({decorator:fe,args:[me,r,n]}).apply()}function Ee(e,t=p.MAX){const r=h.MAX,n={[h.MAX]:e,message:t,description:`defines the max value of the attribute as ${e} (applies to numbers or Dates)`,async:!1};return s.for(r).define({decorator:fe,args:[Ee,r,n]}).apply()}function be(e,t=p.STEP){const r=h.STEP,n={[h.STEP]:e,message:t,description:"defines the step of the attribute as "+e,async:!1};return s.for(r).define({decorator:fe,args:[be,r,n]}).apply()}function Ae(e,t=p.MIN_LENGTH){const r=h.MIN_LENGTH,n={[h.MIN_LENGTH]:e,message:t,description:`defines the min length of the attribute as ${e} (applies to strings or lists)`,async:!1};return s.for(r).define({decorator:fe,args:[Ae,r,n]}).apply()}function Te(e,t=p.MAX_LENGTH){const r=h.MAX_LENGTH,n={[h.MAX_LENGTH]:e,message:t,description:`defines the max length of the attribute as ${e} (applies to strings or lists)`,async:!1};return s.for(r).define({decorator:fe,args:[Te,r,n]}).apply()}function Ne(e,t=p.PATTERN){const r=h.PATTERN,n={[h.PATTERN]:"string"==typeof e?e:e.toString(),message:t,description:`assigns the ${"string"===e?e:e.toString()} pattern to the attribute`,async:!1};return s.for(r).define({decorator:fe,args:[Ne,r,n]}).apply()}function Me(e=p.EMAIL){const t=h.EMAIL,r={[h.PATTERN]:y.EMAIL.toString(),message:e,description:"marks the attribute as an email",async:!1};return s.for(t).define({decorator:fe,args:[Me,t,r]}).apply()}function Se(e=p.URL){const t=h.URL,r={[h.PATTERN]:y.URL.toString(),message:e,description:"marks the attribute as an url",async:!1};return s.for(t).define({decorator:fe,args:[Se,t,r]}).apply()}function Oe(e,t=p.TYPE){const r=h.TYPE,n={customTypes:e,message:t,description:"defines the accepted types for the attribute",async:!1};return s.for(r).define({decorator:fe,args:[Oe,r,n]}).apply()}function Re(e="dd-MM-yyyy HH:mm:ss:S",t=p.DATE){const r=h.DATE;return s.for(r).define({decorator:function(e,t){const s={[h.FORMAT]:e,message:t,description:"defines the attribute as a date with the format "+e,async:!1};return function(t,n){const i=new WeakMap;return Object.defineProperty(t,n,{configurable:!0,set(t){const r=Object.getOwnPropertyDescriptor(this,n);r&&!r.configurable||Object.defineProperty(this,n,{enumerable:!0,configurable:!1,get:()=>i.get(this),set:t=>{let r;try{r=he(e,t),i.set(this,r)}catch(e){}}}),this[n]=t},get(){return i.get(this)}}),fe(Re,r,s)(t,n)}},args:[e,t]}).apply()}function ve(e=y.PASSWORD.CHAR8_ONE_OF_EACH,t=p.PASSWORD){const r=h.PASSWORD,n={[h.PATTERN]:e.toString(),message:t,description:"attribute as a password",async:!1};return s.for(r).define({decorator:fe,args:[ve,r,n]}).apply()}function _e(e,t="Array",r=p.LIST){const n=h.LIST,i={clazz:Array.isArray(e)?e:[e],type:t,message:r,async:!1,description:`defines the attribute as a ${t} of ${e.name}`};return s.for(n).define({decorator:fe,args:[_e,n,i]}).apply()}function Pe(e,t=p.LIST){return _e(e,"Set",t)}function we(e,t){return fe(we,h.EQUALS,{label:t?.label||e,message:t?.message||p.EQUALS,[h.EQUALS]:e,description:"defines attribute as equal to "+e,async:!1})}function Le(e,t){return fe(Le,h.DIFF,{label:t?.label||e,message:t?.message||p.DIFF,[h.DIFF]:e,description:"defines attribute as different to "+e,async:!1})}function De(e,t){return fe(De,h.LESS_THAN,{label:t?.label||e,message:t?.message||p.LESS_THAN,[h.LESS_THAN]:e,description:"defines attribute as less than to "+e,async:!1})}function Ie(e,t){return fe(Ie,h.LESS_THAN_OR_EQUAL,{label:t?.label||e,message:t?.message||p.LESS_THAN_OR_EQUAL,[h.LESS_THAN_OR_EQUAL]:e,description:"defines attribute as less or equal to "+e,async:!1})}function He(e,t){return fe(He,h.GREATER_THAN,{label:t?.label||e,message:t?.message||p.GREATER_THAN,[h.GREATER_THAN]:e,description:"defines attribute as greater than "+e,async:!1})}function je(e,t){return fe(je,h.GREATER_THAN_OR_EQUAL,{label:t?.label||e,message:t?.message||p.GREATER_THAN_OR_EQUAL,[h.GREATER_THAN_OR_EQUAL]:e,description:"defines attribute as greater or equal to "+e,async:!1})}function Ue(e,t=p.ENUM){const r=h.ENUM,n={[h.ENUM]:e,message:t,description:"defines a list or an object of accepted values for the attribute",async:!1};return s.for(r).define({decorator:fe,args:[Ue,r,n]}).apply()}oe=c([C(h.URL),u("design:paramtypes",[String])],oe);class xe{static{this.current=U}constructor(){}static get(e){if(e in this.cache)return this.cache[e];throw Error("No serialization method registered under "+e)}static register(e,t,r=!1){if(e in this.cache)throw Error(`Serialization method ${e} already registered`);this.cache[e]=new t,r&&(this.current=e)}static serialize(e,t,...r){return t?this.get(t).serialize(e,...r):this.get(this.current).serialize(e,...r)}static deserialize(e,t,...r){return t?this.get(t).deserialize(e,...r):this.get(this.current).deserialize(e,...r)}static setDefault(e){this.current=this.get(e)}}class Ce{constructor(e){for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&e[t]&&Object.defineProperty(this,t,{enumerable:!0,configurable:!1,value:e[t],writable:!1})}toString(){const e=this;return Object.keys(e).filter(t=>Object.prototype.hasOwnProperty.call(e,t)&&"function"!=typeof e[t]).reduce((t,r)=>{let s=Object.keys(e[r]).reduce((t,s)=>(t?t+="\n"+e[r][s]:t=e[r][s],t),void 0);return s&&(s=`${r} - ${s}`,t?t+="\n"+s:t=s),t},"")}}const Fe=e=>e[A],ze=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw Error(E(b.PROPERTY_NOT_EXIST,t));return e[t]};class Ye{static create(e,t){const{getValue:r,getParent:s,ignoreUndefined:n,ignoreNull:i}={getParent:Fe,getValue:ze,ignoreNull:!1,ignoreUndefined:!1,...t},o=new Proxy({},{get:(t,o)=>"getValueFromPath"===o?t=>{const o=Ye.parsePath(t);let a=e;for(let e=0;e<o.length;e++){const c=o[e];if(".."===c){const r=s(a);if(!r||"object"!=typeof r)throw Error(E(b.CONTEXT_NOT_OBJECT_COMPARISON,e+1,t));a=r;continue}if(a=r(a,c),!n&&void 0===a)throw Error(E(b.PROPERTY_INVALID,t,c));if(!i&&null===a)throw Error(E(b.PROPERTY_INVALID,t,c))}return a}:t[o]});return o}static parsePath(e){if("string"!=typeof e||!e.trim())throw Error(E(b.INVALID_PATH,e));return e.match(/(\.\.|[^/.]+)/g)||[]}}function $e(e,t){return t?Promise.resolve(e):e}var Ge;(e=>{e.STRING="string",e.NUMBER="number",e.BOOLEAN="boolean",e.BIGINT="bigint"})(Ge||(Ge={}));const Qe={STRING:String,OBJECT:Object,NUMBER:Number,BOOLEAN:Boolean,BIGINT:BigInt,DATE:Date},ke=["string","array","number","boolean","symbol","function","object","undefined","null","bigint"];let Ve,qe;class Be{constructor(t=e.isModel){this.cache={},this.testFunction=t}register(e,t){if("function"!=typeof e)throw Error("Model registering failed. Missing Class name or constructor");t=t||e.name,this.cache[t]=e}get(e){try{return this.cache[e]}catch(e){return}}build(t={},r){if(!r&&!this.testFunction(t))throw Error("Provided obj is not a Model object");const s=r||e.modelName(t.constructor);if(!(s in this.cache))throw Error(`Provided class ${s} is not a registered Model object`);return new this.cache[s](t)}static setBuilder(e){Ve=e}static getBuilder(){return Ve||Be.fromModel}static fromModel(t,r){let s;r||(r={});const n=e.getAttributes(t),i=Object.getPrototypeOf(t);let o;for(const a of n){try{t[a]=r[a]??t[a]??void 0}catch(e){if(o=Object.getOwnPropertyDescriptor(i,a),!o||o.writable)throw Error(`Unable to write property ${a} to model: ${e}`)}if("object"!=typeof t[a])continue;const n=e.isPropertyModel(t,a);if(n){try{t[a]=Be.getRegistry().build(t[a],"string"==typeof n?n:void 0)}catch(e){}continue}if(s=e.allowedTypes(t.constructor,a),!s||!s.length)throw Error("failed to find decorators for property "+a);const c=s.map(e=>"function"!=typeof e||e.name?e:e()),u=Object.values(Qe);c.forEach(r=>{if(!u.includes(r))try{switch(r.name){case"Array":case"Set":{const s=e.validationFor(t.constructor,a);if(!s||!s[h.LIST])break;const n=s[h.LIST].clazz.map(e=>"function"!=typeof e||e.name?e:e()).find(e=>!ke.includes(e.name));if("Array"===r.name&&(t[a]=t[a].map(e=>["object","function"].includes(typeof e)&&n?Be.getRegistry().build(e,n.name):e)),"Set"===r.name){const e=new Set;for(const r of t[a])["object","function"].includes(typeof r)&&n?e.add(Be.getRegistry().build(r,n.name)):e.add(r);t[a]=e}break}default:void 0!==t[a]&&Be.getRegistry().get(r.name)&&(t[a]=Be.getRegistry().build(t[a],r.name))}}catch(e){}})}return t}static getRegistry(){return qe||(qe=new Be),qe}static setRegistry(e){qe=e}}function Xe(...e){e.forEach(e=>{const t=e.constructor?e.constructor:e;Be.getRegistry().register(t,e.name)})}function Ke(e,t,r){Object.hasOwnProperty.call(e,t)||(e[t]=r)}function We(e,t){Object.hasOwnProperty.call(e,t)&&delete e[t]}function Ze(e,t,r,...s){t&&Ke(e,A,t),Ke(e,T,!!r);const n=e.hasErrors(...s);return We(e,A),We(e,T),n}function Je(e,t,r,s,n,...i){let o,a=!1;for(const c of s){const s=Be.getRegistry().get(c);if(s||(o=new Ce({[e]:{[h.TYPE]:"Unable to verify type consistency, missing model registry for "+c}})),t instanceof s){a=!0,o=Ze(t,r,n,...i);break}}return a?o:o||new Ce({[e]:{[h.TYPE]:"Value must be an instance of one of the expected types: "+s.join(", ")}})}function et(e,...t){return t?.map(t=>("string"==typeof t&&t?.startsWith(e+".")&&(t=t.replace(e+".","")),t))}function tt(e,t,r,s){const n=x.get(r.key);if(!n)throw Error("Missing validator for "+r.key);if(!s&&r.async)return;const i=r.key===j.TYPE?[r]:r||{},o=Ye.create(e,{ignoreUndefined:!0,ignoreNull:!0}),a=r.key===j.TYPE?i[0]:i;return $e(n.hasErrors(t,a,o),s)}function rt(t,r,s,n,i,...o){const a={};for(const c in n){const u={...n[c],key:c};if(!i&&u.async)continue;let l=tt(t,s,u,i);if(c===h.LIST&&(!l||i)){const n=s instanceof Set?[...s]:s;if(n&&n.length>0){let s=u.class||u.clazz||u.customTypes;s=(Array.isArray(s)?s:[s]).map(e=>(e="function"!=typeof e||e.name?e:e()).name?e.name:e);const a=[s].flat().map(e=>(e+"").toLowerCase()),c=n.map(n=>{if(!["string","number","bigint"].includes(typeof n)){if(e.isModel(n)){const e=et(r,...o);return Je(r,n,t,s.flat(),!!i,...e)}return a.includes(typeof n)?void 0:"Value has no validatable type"}});if(i)l=Promise.all(c).then(e=>e.every(e=>!e)?void 0:e);else{const e=c.every(e=>!e);l=c.length>0&&!e?c:void 0}}}const d=c===j.TYPE?h.TYPE:c;l&&(a[d]=l)}if(!i)return Object.keys(a).length>0?a:void 0;const c=Object.keys(a),u=Object.values(a);return Promise.all(u).then(e=>{const t={};for(let r=0;r<e.length;r++){const s=e[r];void 0!==s&&(t[c[r]]=s)}return Object.keys(t).length>0?t:void 0})}function st(t,r,...s){const n=e.validatableProperties(t.constructor,...s),i={},o={};for(const a of n){const n=a+"",c=t[a],u=e.validationFor(t.constructor,a)||{},{designTypes:l}=e.getPropDesignTypes(t.constructor,a);if(!l)continue;if(l.some(e=>[Array.name,Set.name].includes(e.name))){if(!u||!Object.keys(u).includes(h.LIST)){i[n]={[h.TYPE]:`Array or Set property '${n}' requires a @list decorator`};continue}if(c&&!(Array.isArray(c)||c instanceof Set)){i[n]={[h.TYPE]:`Property '${a+""}' must be either an Array or a Set`};continue}}const d=rt(t,n,c,u,r,...s)||{};if(e.isPropertyModel(t,n)&&null!=c){const e=l.map(e=>Be.getRegistry().get(e.name||e)).find(e=>!!e),i=l.map(e=>"function"==typeof e?e.name?e.name.toLowerCase():e()?.name.toLowerCase():e.toLowerCase());if(e&&c instanceof e){const e=et(n,...s);o[n]=Ze(c,t,r,...e)}else i.includes(typeof c)||(d[h.TYPE]=e?"Value must be an instance of "+e.name:`Unable to verify type consistency, missing model registry for ${l.toString()} on prop ${n}`,delete d[j.TYPE])}(Object.keys(d).length>0||r)&&(i[n]=d),r||Object.entries(o[n]||{}).forEach(([e,t])=>{void 0!==t&&(i[`${n}.${e}`]=t)})}if(!r)return Object.keys(i).length>0?new Ce(i):void 0;const a=i,c=Object.keys(a),u=Object.values(a);return Promise.allSettled(u).then(async e=>{const t={};for(const[e,r]of Object.entries(o)){const s=await r;s&&Object.entries(s).forEach(([r,s])=>{void 0!==s&&(t[[e,r].join(".")]=s)})}for(let r=0;r<e.length;r++){const s=c[r],n=e[r];"fulfilled"===n.status&&void 0!==n.value?t[s]=n.value:"rejected"===n.status&&(t[s]=n.reason instanceof Error?n.reason.message:(n.reason||"Validation failed")+"")}return Object.keys(t).length>0?new Ce(t):void 0})}function nt(e){e+="";let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return t.toString()}function it(e){const t=(e,t)=>{const r=s(t);return"string"==typeof r?s((e||"")+s(t)):(e=((e=e||0)<<5)-e+r)&e},r=nt,s=e=>void 0===e?"":-1!==["string","number","symbol"].indexOf(typeof e)?r(e.toString()):e instanceof Date?r(e.getTime()):Array.isArray(e)?e.reduce(t,void 0):Object.values(e).reduce(t,void 0),n=Object.values(e).reduce(t,0);return("number"==typeof n?Math.abs(n):n).toString()}const ot="default";class at{static{this.current=ot}static{this.cache={default:it}}constructor(){}static get(e){if(e in this.cache)return this.cache[e];throw Error("No hashing method registered under "+e)}static register(e,t,r=!1){if(e in this.cache)throw Error(`Hashing method ${e} already registered`);this.cache[e]=t,r&&(this.current=e)}static hash(e,t,...r){return t?this.get(t)(e,...r):this.get(this.current)(e,...r)}static setDefault(e){this.current=this.get(e)}}class ct{constructor(e=void 0){}isAsync(){return!!(this[T]??this?.constructor[T])}hasErrors(...e){return st(this,this.isAsync(),...e)}equals(e,...t){return z(this,e,...t)}compare(t,...r){const s=e.properties(this.constructor);if(!s||!s.length)return;const n=s.reduce((e,s)=>{const n=s;if(r.includes(n))return e;if(void 0===this[n]&&void 0!==t[n])return e[n]={other:t[n],current:void 0},e;if(void 0!==this[n]&&void 0===t[n])return e[n]={other:void 0,current:this[n]},e;if(z(this[n],t[n]))return e;if(ct.isPropertyModel(this,n)){const r=this[n].compare(t[n]);return r&&(e[n]=r),e}if(Array.isArray(this[n])&&Array.isArray(t[n])){if(this[n].length!==t[n].length)return e[n]={current:this[n],other:t[n]},e;const r=this[n].map((e,r)=>z(e,t[n][r])?null:e instanceof ct&&t[n][r]instanceof ct?e.compare(t[n][r]):{current:e,other:t[n][r]});return r.some(e=>null!==e)&&(e[n]=r),e}return e[n]={other:t[n],current:this[n]},e},{});return Object.keys(n).length>0?n:void 0}serialize(){return ct.serialize(this)}toString(){return this.constructor.name+": "+JSON.stringify(this,void 0,2)}hash(){return ct.hash(this)}static deserialize(t){let r;try{r=e.get(this.constructor,j.SERIALIZATION)}catch(e){r=void 0}return r&&r.serializer?xe.deserialize(t,r.serializer,...r.args||[]):xe.deserialize(t)}static fromObject(e,t){t||(t={});for(const r of ct.getAttributes(e))e[r]=t[r]??e[r]??void 0;return e}static fromModel(e,t){return Be.fromModel(e,t)}static setBuilder(e){Be.setBuilder(e)}static getBuilder(){return Be.getBuilder()}static getRegistry(){return Be.getRegistry()}static setRegistry(e){Be.setRegistry(e)}static register(e,t){return Be.getRegistry().register(e,t)}static get(e){return Be.getRegistry().get(e)}static build(e={},t){return ct.getRegistry().build(e,t)}static getAttributes(t){return e.getAttributes(t)}static equals(e,t,...r){return z(e,t,...r)}static hasErrors(e,t,...r){return st(e,t,...r)}static serialize(t){let r;try{r=e.get(t.constructor,j.SERIALIZATION)}catch(e){r=void 0}return r&&r.serializer?xe.serialize(this,r.serializer,...r.args||[]):xe.serialize(t)}static hash(t){const r=e.get(t.constructor,j.HASHING);return r&&r.algorithm?at.hash(t,r.algorithm,...r.args||[]):at.hash(t)}static isModel(t){return e.isModel(t)}static isPropertyModel(t,r){return e.isPropertyModel(t,r)}static describe(t,r){return e.description(t,r)}}function ut(e){return e instanceof dt?e.build():new Date(e)}function lt(e,t,r){const s=new Date(e);return r.years&&s.setFullYear(s.getFullYear()+t*r.years),r.months&&s.setMonth(s.getMonth()+t*r.months),r.days&&s.setDate(s.getDate()+t*r.days),r.hours&&s.setHours(s.getHours()+t*r.hours),r.minutes&&s.setMinutes(s.getMinutes()+t*r.minutes),r.seconds&&s.setSeconds(s.getSeconds()+t*r.seconds),s}e.validationFor=((t,r,s)=>{const n=e.get(t);if(!n)return;if(!r)return n.validation;if(!n.validation)return;if(!n.validation[h.TYPE]){const{designTypes:s}=e.getPropDesignTypes(t,r);n.validation[r]&&s?.length&&s[0]!==Qe.OBJECT&&(n.validation[r][h.TYPE]={customTypes:s,message:p.TYPE,description:"defines the accepted types for the attribute",async:!1})}if(!s)return n.validation[r];const i=n.validation[r];return i?i[s]:void 0}).bind(e),e.modelName=(t=>{const r=e.constr(t);return r?r.name:t.name}).bind(e),e.validatableProperties=((t,...r)=>{const s=e.validationFor(t),n=s?Object.keys(s):[];return[...new Set([...ct.getAttributes(t),...n])].filter(e=>!r||!r?.includes(e))}).bind(e),e.allowedTypes=((t,r)=>{const s=e.type(t,r);if(!s)throw Error("No metadata found for property "+r);const n=e.validationFor(t,r);return n&&n[h.TYPE]&&"function"==typeof n[h.TYPE]?.customTypes[Symbol.iterator]?[...n[h.TYPE].customTypes]:[s]}).bind(e),e.getPropDesignTypes=((t,r)=>{const s=e.get(t),n=e.type(t,r),i=s?.[h.REFLECT]?.[r];if(!(n||i&&i[h.TYPE]))return{};const o=i&&i[h.TYPE]?[i[h.TYPE].customTypes]:[n];if(!o?.length)return{};const a=o[0],c=a.class||a.clazz||a.customTypes||a;return{designTypes:(Array.isArray(c)?c:[c]).map(e=>"function"!=typeof e||e.name?e:e()),designType:c}}).bind(e),e.isModel=(t=>{try{if(t instanceof ct)return!0;const r=e.constr(t);return!(!r||r===t||!e.modelName(r))}catch(e){return!1}}).bind(e),e.isPropertyModel=((t,r)=>{if(e.isModel(t[r]))return!0;const s=e.type(t.constructor,r);return s&&Be.getRegistry().get(s.name)?s.name:void 0}).bind(e),e.getAttributes=(t=>{const r=t instanceof ct?t.constructor:t,s=new Set,n=t=>{if(!t)return[];const r=e.constr(t),i=n(Object.getPrototypeOf(r)),o=e.properties(t)??[];for(const e of o)s.has(e)||(s.add(e),i.push(e));return i};return n(r)}).bind(e);class dt{constructor(){this.years=0,this.months=0,this.days=0,this.hours=0,this.minutes=0,this.seconds=0}static Years(e){return(new dt).Years(e)}static Months(e){return(new dt).Months(e)}static Days(e){return(new dt).Days(e)}static Hours(e){return(new dt).Hours(e)}static Minutes(e){return(new dt).Minutes(e)}static Seconds(e){return(new dt).Seconds(e)}static Now(){return new Date}static Tomorrow(){return dt.Days(1).from(dt.Now())}static Yesterday(){return dt.Days(1).until(dt.Now())}static DaysAgo(e){return dt.Days(e).until(dt.Now())}static NextDays(e){return dt.Days(e).from(dt.Now())}static YearsAgo(e){return dt.Years(e).until(dt.Now())}static NextYears(e){return dt.Years(e).from(dt.Now())}static MonthsAgo(e){return dt.Months(e).until(dt.Now())}static NextMonths(e){return dt.Months(e).from(dt.Now())}static HoursAgo(e){return dt.Hours(e).until(dt.Now())}static NextHours(e){return dt.Hours(e).from(dt.Now())}static MinutesAgo(e){return dt.Minutes(e).until(dt.Now())}static NextMinutes(e){return dt.Minutes(e).from(dt.Now())}static SecondsAgo(e){return dt.Seconds(e).until(dt.Now())}static NextSeconds(e){return dt.Seconds(e).from(dt.Now())}Years(e){return this.years+=e,this}Months(e){return this.months+=e,this}Days(e){return this.days+=e,this}Hours(e){return this.hours+=e,this}Minutes(e){return this.minutes+=e,this}Seconds(e){return this.seconds+=e,this}build(e=new Date){return this.from(e)}from(e){return lt(ut(e),1,this.offsets())}past(e){return this.from(e)}after(e){return this.from(e)}until(e){return lt(ut(e),-1,this.offsets())}before(e){return this.until(e)}ago(e=new Date){return this.until(e)}Now(){return dt.Now()}Tomorrow(){return dt.Tomorrow()}Yesterday(){return dt.Yesterday()}DaysAgo(e){return dt.DaysAgo(e)}NextDays(e){return dt.NextDays(e)}YearsAgo(e){return dt.YearsAgo(e)}NextYears(e){return dt.NextYears(e)}MonthsAgo(e){return dt.MonthsAgo(e)}NextMonths(e){return dt.NextMonths(e)}HoursAgo(e){return dt.HoursAgo(e)}NextHours(e){return dt.NextHours(e)}MinutesAgo(e){return dt.MinutesAgo(e)}NextMinutes(e){return dt.NextMinutes(e)}SecondsAgo(e){return dt.SecondsAgo(e)}NextSeconds(e){return dt.NextSeconds(e)}offsets(){return{years:this.years,months:this.months,days:this.days,hours:this.hours,minutes:this.minutes,seconds:this.seconds}}}const ht=dt,gt=()=>dt.Now(),ft=()=>dt.Tomorrow(),pt=()=>dt.Yesterday(),yt=e=>dt.DaysAgo(e),mt=e=>dt.NextDays(e),Et=e=>dt.YearsAgo(e),bt=e=>dt.NextYears(e),At=e=>dt.MonthsAgo(e),Tt=e=>dt.NextMonths(e),Nt=e=>dt.HoursAgo(e),Mt=e=>dt.NextHours(e),St=e=>dt.MinutesAgo(e),Ot=e=>dt.NextMinutes(e),Rt=e=>dt.SecondsAgo(e),vt=e=>dt.NextSeconds(e);class _t{constructor(){}preSerialize(t,...r){const s=Object.assign({},t);let n;try{n=e.modelName(t.constructor)}catch(e){n=void 0}return s[j.ANCHOR]=n||t.constructor.name,s}deserialize(e,...t){const r=JSON.parse(e),s=r[j.ANCHOR];if(!s)throw Error("Could not find class reference in serialized model");return ct.build(r,s)}serialize(e,...t){return JSON.stringify(this.preSerialize(e))}}function Pt(e,...t){const r=(...t)=>new e(...t);return r.prototype=e.prototype,r(...t)}function wt(e){let t=Object.getPrototypeOf(e);if(t===Object.prototype)return e;for(;t!==Object.prototype;){if(t=Object.getPrototypeOf(t),t===Object.prototype)return t;if(Object.getPrototypeOf(t)===Object.prototype)return t}throw Error("Could not find proper prototype")}function Lt(e){if(e instanceof ct)return;function t(e,t){Object.setPrototypeOf(e,t)}const r=Object.getPrototypeOf(e);if(r===Object.prototype)return t(e,ct.prototype);for(;r!==Object.prototype;){const e=Object.getPrototypeOf(r);if(e===Object.prototype||Object.getPrototypeOf(e)===Object.prototype)return t(r,ct.prototype)}throw Error("Could not find proper prototype to bind")}function Dt(e){const t=(...t)=>{const r=Pt(e,...t);Lt(r);const s=ct.getBuilder();return s&&s(r,t.length?t[0]:void 0),r};return t.prototype=e.prototype,Object.defineProperty(t,"name",{writable:!1,enumerable:!0,configurable:!1,value:e.prototype.constructor.name}),r(j.CONSTRUCTOR,e)(t),ct.register(t,e.name),t}function It(){const e=j.MODEL;return s.for(e).define(Dt).apply()}function Ht(e,...t){return r(j.HASHING,{algorithm:e,args:t})}function jt(e,...t){return r(j.SERIALIZATION,{serializer:e,args:t})}xe.cache={json:new _t};class Ut{constructor(e,t,r){this.parent=e,this.attr=t,this.declaredType=r,this.decorators=[]}decorate(...e){for(const t of e){if(this.decorators.includes(t))throw Error(`Decorator "${t}" has already been used`);this.decorators.push(t)}return this.parent}undecorate(...e){for(const t of e){const e=this.decorators.indexOf(t);if(0>e)throw Error(`Decorator "${t}" is not applied to ${this.attr}`);this.decorators.splice(e,1)}return this.parent}required(e){const t=Ut.asMeta(e),r="string"==typeof e?e:Ut.resolveMessage(t);return this.decorate(ye(r))}min(e,t){const r=Ut.asMeta(e),s=r?.[h.MIN]??(r?void 0:e);if(void 0===s)throw Error(`Missing ${h.MIN} for ${this.attr+""}`);return this.decorate(me(s,Ut.resolveMessage(r,t)))}max(e,t){const r=Ut.asMeta(e),s=r?.[h.MAX]??(r?void 0:e);if(void 0===s)throw Error(`Missing ${h.MAX} for ${this.attr+""}`);return this.decorate(Ee(s,Ut.resolveMessage(r,t)))}step(e,t){const r=Ut.asMeta(e),s=r?.[h.STEP]??(r?void 0:e);if(void 0===s)throw Error(`Missing ${h.STEP} for ${this.attr+""}`);return this.decorate(be(s,Ut.resolveMessage(r,t)))}minlength(e,t){const r=Ut.asMeta(e),s=r?.[h.MIN_LENGTH]??(r?void 0:e);if(void 0===s)throw Error(`Missing ${h.MIN_LENGTH} for ${this.attr+""}`);return this.decorate(Ae(s,Ut.resolveMessage(r,t)))}maxlength(e,t){const r=Ut.asMeta(e),s=r?.[h.MAX_LENGTH]??(r?void 0:e);if(void 0===s)throw Error(`Missing ${h.MAX_LENGTH} for ${this.attr+""}`);return this.decorate(Te(s,Ut.resolveMessage(r,t)))}pattern(e,t){const r=Ut.asMeta(e),s=r?.[h.PATTERN]??(r?void 0:e),n=Ut.patternFromString(s)??/.*/;return this.decorate(Ne(n,Ut.resolveMessage(r,t)))}email(e){const t=Ut.asMeta(e),r="string"==typeof e?e:Ut.resolveMessage(t);return this.decorate(Me(r))}url(e){const t=Ut.asMeta(e),r="string"==typeof e?e:Ut.resolveMessage(t);return this.decorate(Se(r))}type(e,t){const r=Ut.asMeta(e),s=r?.customTypes??r?.type??(r?void 0:e);return this.decorate(Oe(s,Ut.resolveMessage(r,t)))}date(e,t){const r=Ut.asMeta(e),s=r?.[h.FORMAT]??(r?void 0:e);return this.decorate(Re(s,Ut.resolveMessage(r,t)))}password(e,t){const r=Ut.asMeta(e),s=r?.[h.PATTERN]??(r?void 0:e),n=Ut.patternFromString(s);return this.decorate(ve(n,Ut.resolveMessage(r,t)))}list(e,t,r){const s=Ut.asMeta(e),n=s?.clazz??(s?void 0:e),i=s?.type??t;return this.decorate(_e(n,i,Ut.resolveMessage(s,r)))}set(e,t){return Ut.isMetadataPayload(e)?this.list(e):this.list(e,"Set",t)}enum(e,t){const r=Ut.asMeta(e),s=r?.[h.ENUM]??(r?void 0:e);return this.decorate(Ue(s,Ut.resolveMessage(r,t)))}option(e,t){return this.enum(e,t)}static isMetadataPayload(e){return!(!e||e instanceof Date||e instanceof RegExp||Array.isArray(e)||"object"!=typeof e)}static asMeta(e){return Ut.isMetadataPayload(e)?e:void 0}static resolveMessage(e,t){return e?.message??t}static patternFromString(e){if(!e)return;if(e instanceof RegExp)return e;const t=e.match(/^\/(.+)\/([gimsuy]*)$/);return t?RegExp(t[1],t[2]):RegExp(e)}resolveComparison(e,t,r){const s=Ut.asMeta(e);return s?{target:s[t],options:{label:s.label,message:s.message}}:{target:e,options:r}}equals(e,t){const{target:r,options:s}=this.resolveComparison(e,h.EQUALS,t);return this.decorate(we(r,s))}eq(e,t){return this.equals(e,t)}different(e,t){const{target:r,options:s}=this.resolveComparison(e,h.DIFF,t);return this.decorate(Le(r,s))}diff(e,t){return this.different(e,t)}lessThan(e,t){const{target:r,options:s}=this.resolveComparison(e,h.LESS_THAN,t);return this.decorate(De(r,s))}lt(e,t){return this.lessThan(e,t)}lessThanOrEqual(e,t){const{target:r,options:s}=this.resolveComparison(e,h.LESS_THAN_OR_EQUAL,t);return this.decorate(Ie(r,s))}lte(e,t){return this.lessThanOrEqual(e,t)}greaterThan(e,t){const{target:r,options:s}=this.resolveComparison(e,h.GREATER_THAN,t);return this.decorate(He(r,s))}gt(e,t){return this.greaterThan(e,t)}greaterThanOrEqual(e,t){const{target:r,options:s}=this.resolveComparison(e,h.GREATER_THAN_OR_EQUAL,t);return this.decorate(je(r,s))}gte(e,t){return this.greaterThanOrEqual(e,t)}description(e){return this.decorate(i(e))}build(e){const t=e.prototype,r=this.attr;Object.getOwnPropertyDescriptor(t,r)||Object.defineProperty(t,r,{configurable:!0,enumerable:!0,writable:!0,value:void 0}),this.declaredType&&Reflect.defineMetadata(o.DESIGN_TYPE,this.declaredType,t,r),a()(t,r),this.decorators.forEach(e=>{try{e(t,r)}catch(e){throw Error(`Failed to apply decorator to property "${this.attr}": ${e}`)}})}}class xt{constructor(e,t,r){this.parent=e,this.attribute=t,this.collection=r}ofPrimitives(e,t){return this.attribute.list(e,this.collection,t),this.parent}ofModel(){const e=Ct.builder(),t=e.build;let r;return this.attribute.list(()=>(r||(r=Reflect.apply(t,e,[])),r),this.collection),e.build=new Proxy(t,{apply:(e,t,s)=>(r=Reflect.apply(e,t,s),this.parent)}),e}}class Ct extends l{constructor(){super(...arguments),this.attributes=new Map,this._classDecorators=[]}setName(e){return this._name=e,this}description(e){return this._description=e,this}decorateClass(e){return this._classDecorators.push(e),this}attribute(e,t){const r=this.attributes.get(e);if(r){if(r.declaredType!==t)throw Error(`Attribute "${e+""}" already exists with a different type`);return r}const s=new Ut(this,e,t);return this.attributes.set(e,s),s}string(e){return this.attribute(e,String)}number(e){return this.attribute(e,Number)}date(e){return this.attribute(e,Date)}bigint(e){return this.attribute(e,BigInt)}instance(e,t){return this.attribute(t,e)}model(e){const t=new Ct;return t.build=new Proxy(t.build,{apply:(t,r,s)=>{const n=Reflect.apply(t,r,s);return this.instance(n,e)}}),t}listOf(e,t="Array"){const r="Set"===t?Set:Array,s=this.attribute(e,r);return new xt(this,s,t)}build(){if(!this._name)throw Error("name is required");const e=this._parent??ct;class t extends e{constructor(e){super(e)}}Object.defineProperty(t,"name",{value:this._name,writable:!1});for(const e of this.attributes.values())e.build(t);let r=It()(t);for(const e of this._classDecorators){const t=e(r);t&&(r=t)}return this._description&&(r=i(this._description)(r)),r}static builder(){return new Ct}static from(e,t){if(!e)throw Error("metadata is required");const r=Ct.builder(),s=t??"GeneratedModel"+Date.now();r.setName(s);const n=e.properties||{},i=e.validation||{};for(const[e,t]of Object.entries(n)){const s=r.attribute(e,t||Object),n=i[e];if(n)for(const[e,t]of Object.entries(n)){const r=s[e];if("function"!=typeof r)try{const r=x.decoratorFromKey(e),n="function"==typeof r?r(t):r;s.decorate(n)}catch{}else r.call(s,t)}}return r.build()}}const Ft="##VERSION##",zt="##PACKAGE##";e.registerLibrary(zt,Ft);export{T as ASYNC_META_KEY,D as AsyncValidator,Ut as AttributeBuilder,b as COMPARISON_ERROR_MESSAGES,d as ComparisonValidationKeys,f as DAYS_OF_WEEK_NAMES,p as DEFAULT_ERROR_MESSAGES,y as DEFAULT_PATTERNS,dt as DateBuilder,F as DateValidator,ht as Dates,yt as DaysAgo,ot as DefaultHashingMethod,U as DefaultSerializationMethod,Y as DiffValidator,Q as EmailValidator,k as EqualsValidator,q as GreaterThanOrEqualValidator,V as GreaterThanValidator,at as Hashing,Nt as HoursAgo,_t as JSONSerializer,X as LessThanOrEqualValidator,B as LessThanValidator,K as ListValidator,g as MONTH_NAMES,W as MaxLengthValidator,Z as MaxValidator,J as MinLengthValidator,ee as MinValidator,St as MinutesAgo,ct as Model,Ct as ModelBuilder,Ce as ModelErrorDefinition,j as ModelKeys,Be as ModelRegistryManager,At as MonthsAgo,mt as NextDays,Mt as NextHours,Ot as NextMinutes,Tt as NextMonths,vt as NextSeconds,bt as NextYears,gt as Now,te as OptionValidator,zt as PACKAGE_NAME,re as PasswordValidator,Ye as PathProxyEngine,G as PatternValidator,Ge as Primitives,se as RequiredValidator,Qe as ReservedModels,Rt as SecondsAgo,xe as Serialization,ne as StepValidator,ft as Tomorrow,ie as TypeValidator,oe as URLValidator,A as VALIDATION_PARENT_KEY,Ft as VERSION,x as Validation,h as ValidationKeys,I as Validator,H as ValidatorRegistry,Et as YearsAgo,pt as Yesterday,pe as async,ce as bindDateToString,Lt as bindModelPrototype,Xe as bulkModelRegister,v as checkType,_ as checkTypes,Pt as construct,Re as date,ae as dateFromFormat,Le as diff,Me as email,we as eq,P as evaluateDesignTypes,wt as findLastProtoBeforeObject,de as formatDate,et as getChildNestedPropsToIgnore,He as gt,je as gte,nt as hashCode,it as hashObj,Ht as hashedBy,fe as innerValidationDecorator,z as isEqual,R as isGreaterThan,O as isLessThan,ue as isValidDate,S as isValidForGteOrLteComparison,ke as jsTypes,_e as list,De as lt,Ie as lte,Ee as max,Te as maxlength,me as min,Ae as minlength,It as model,Dt as modelBaseDecorator,lt as offsetDate,Ue as option,he as parseDate,ve as password,Ne as pattern,$ as regexpParser,ye as required,jt as serializedBy,Pe as set,E as sf,be as step,m as stringFormat,$e as toConditionalPromise,le as twoDigitPad,Oe as type,Se as url,st as validate,Je as validateChildValue,tt as validateDecorator,rt as validateDecorators,ge as validationMetadata,C as validator,w as valueLength};
|
|
1
|
+
import{Metadata as e,apply as t,metadata as r,Decoration as s,propMetadata as n,description as i,DecorationKeys as o,prop as a}from"@decaf-ts/decoration";import{__decorate as c,__metadata as u}from"tslib";import{ObjectAccumulator as l}from"typed-object-accumulator";const d={EQUALS:"equals",DIFF:"different",LESS_THAN:"lessThan",LESS_THAN_OR_EQUAL:"lessThanOrEqual",GREATER_THAN:"greaterThan",GREATER_THAN_OR_EQUAL:"greaterThanOrEqual"},f={REFLECT:"validation",DATE:"date",EMAIL:"email",FORMAT:"format",LIST:"list",MAX:"max",MAX_LENGTH:"maxlength",MIN:"min",MIN_LENGTH:"minlength",PASSWORD:"password",PATTERN:"pattern",REQUIRED:"required",STEP:"step",TYPE:"type",UNIQUE:"unique",URL:"url",VALIDATOR:"validator",ENUM:"enum",...d},g=["January","February","March","April","May","June","July","August","September","October","November","December"],h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],p={REQUIRED:"This field is required",MIN:"The minimum value is {0}",MAX:"The maximum value is {0}",MIN_LENGTH:"The minimum length is {0}",MAX_LENGTH:"The maximum length is {0}",PATTERN:"The value does not match the pattern",EMAIL:"The value is not a valid email",URL:"The value is not a valid URL",TYPE:"Invalid type. Expected {0}, received {1}",STEP:"Invalid value. Not a step of {0}",DATE:"Invalid value. not a valid Date",DEFAULT:"There is an Error",PASSWORD:"Must be at least 8 characters and contain one of number, lower and upper case letters, and special character (@$!%*?&_-.,)",LIST:"Invalid list of {0}",MODEL_NOT_FOUND:"No model registered under {0}",EQUALS:"This field must be equal to field {0}",DIFF:"This field must be different from field {0}",LESS_THAN:"This field must be less than field {0}",LESS_THAN_OR_EQUAL:"This field must be less than or equal to field {0}",GREATER_THAN:"This field must be greater than field {0}",GREATER_THAN_OR_EQUAL:"This field must be greater than or equal to field {0}",UNIQUE:"Duplicate found, this field must be unique.",ENUM:"Value is not allowed. Must be one of {0}"},y={EMAIL:/[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?/,URL:/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i,PASSWORD:{CHAR8_ONE_OF_EACH:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&_\-.,])[A-Za-z\d@$!%*?&_\-.,]{8,}$/g},asd:"^(?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\xa1-\uffff][a-z0-9\xa1-\uffff_-]{0,62})?[a-z0-9\xa1-\uffff]\\.)+(?:[a-z\xa1-\uffff]{2,}\\.?))(?::\\d{2,5})?(?:[/?#]\\S*)?$"};function m(e,...t){return e.replace(/{(\d+)}/g,(e,r)=>void 0!==t[r]?t[r].toString():"undefined")}const E=m,b={INVALID_PATH:"Invalid path argument. Expected non-empty string but received: '{0}'",CONTEXT_NOT_OBJECT_COMPARISON:"Unable to access parent at level {0} for path '{1}': current context is not an object",PROPERTY_INVALID:"Failed to resolve path {0}: property '{1}' is invalid or does not exist.",PROPERTY_NOT_EXIST:"Failed to resolve path: property '{0}' does not exist.",UNSUPPORTED_TYPES_COMPARISON:"Unsupported types for comparison: '{0}' and '{1}'",NULL_OR_UNDEFINED_COMPARISON:"Comparison failed due to null or undefined value",INVALID_DATE_COMPARISON:"Invalid Date objects are not comparable",TYPE_MISMATCH_COMPARISON:"Cannot compare values of different types: {0} and {1}.",NAN_COMPARISON:"Comparison not supported for NaN values"},A=Symbol("_parent"),T=Symbol("isAsync"),N=e=>null===e?"null":e instanceof Date?"Date":Number.isNaN(e)?"NaN":e===1/0?"Infinity":e===-1/0?"-Infinity":Array.isArray(e)?"array":typeof e,M=e=>void 0===e||e instanceof Date||"bigint"==typeof e||"number"==typeof e&&Number.isFinite(e);function S(e,t){if(M(e)&&M(t))return!0;throw new TypeError(E(b.UNSUPPORTED_TYPES_COMPARISON,N(e),N(t)))}function O(e,t){if([null,void 0].includes(e)||[null,void 0].includes(t))throw Error(b.NULL_OR_UNDEFINED_COMPARISON);const r=typeof e,s=typeof t;if(r!==s){if("bigint"===r&&"number"===s)return t>Number(e);if("number"===r&&"bigint"===s)return Number(t)>e;throw new TypeError(E(b.TYPE_MISMATCH_COMPARISON,r,s))}if("number"===r&&"number"===s||"bigint"===r&&"bigint"===s){if(Number.isNaN(e)||Number.isNaN(t))throw new TypeError(b.NAN_COMPARISON);return t>e}if(e instanceof Date&&t instanceof Date){if(isNaN(e.getTime())||isNaN(t.getTime()))throw new TypeError(b.INVALID_DATE_COMPARISON);return e.getTime()<t.getTime()}throw new TypeError(E(b.UNSUPPORTED_TYPES_COMPARISON,N(e),N(t)))}function R(e,t){if([null,void 0].includes(e)||[null,void 0].includes(t))throw Error(b.NULL_OR_UNDEFINED_COMPARISON);const r=typeof e,s=typeof t;if(r!==s){if("bigint"===r&&"number"===s)return Number(e)>t;if("number"===r&&"bigint"===s)return e>Number(t);throw Error(E(b.TYPE_MISMATCH_COMPARISON,r,s))}if("number"===r&&"number"===s||"bigint"===r&&"bigint"===s){if(Number.isNaN(e)||Number.isNaN(t))throw new TypeError(b.NAN_COMPARISON);return e>t}if(e instanceof Date&&t instanceof Date){if(isNaN(e.getTime())||isNaN(t.getTime()))throw new TypeError(b.INVALID_DATE_COMPARISON);return e.getTime()>t.getTime()}throw new TypeError(E(b.UNSUPPORTED_TYPES_COMPARISON,N(e),N(t)))}function v(e,t){return typeof e===t.toLowerCase()||null!=e&&"object"==typeof e&&e instanceof Object&&!!e.constructor&&e.constructor.name.toLowerCase()===t.toLowerCase()}function _(e,t){return!t.every(t=>!v(e,t))}function P(e,t){const r=(e=>"function"!=typeof e||e.name?e:e())(t);if("string"==typeof r)return v(e,r);if("function"!=typeof r)return!1;switch(r.name){case"String":return"string"==typeof e;case"Number":return"number"==typeof e;case"Boolean":return"boolean"==typeof e;case"BigInt":return"bigint"==typeof e;case"Symbol":return"symbol"==typeof e;case"Function":return"function"==typeof e;case"Array":return Array.isArray(e);case"Date":return e instanceof Date;case"Object":return"object"==typeof e}return e instanceof r}function w(e,t){return(Array.isArray(t)?t:[t]).some(t=>P(e,t))}function L(e){return e instanceof Set||e instanceof Map?e.size:e.length}class D{constructor(e,t=p.DEFAULT,...r){this.async=e,this.message=t,r.length&&(this.acceptedTypes=r),this.acceptedTypes&&(this.hasErrors=this.checkTypeAndHasErrors(this.hasErrors.bind(this)))}getMessage(e,...t){return E(e,...t)}checkTypeAndHasErrors(e){return function(t,r,s,...n){return void 0!==t&&this.acceptedTypes?_(t,this.acceptedTypes)?e(t,r,s,...n):this.getMessage(p.TYPE,this.acceptedTypes.join(", "),"number"!=typeof t?typeof t:isNaN(t)?"NaN":typeof t):e(t,r,s,...n)}.bind(this)}static isValidator(e){return e.constructor&&!!e.hasErrors}}class I extends D{constructor(e=p.DEFAULT,...t){super(!0,e,...t)}}class H extends D{constructor(e=p.DEFAULT,...t){super(!1,e,...t)}}class j{constructor(...e){this.cache={},this.customKeyCache={},this.register(...e)}getCustomKeys(){return Object.assign({},this.customKeyCache)}getKeys(){return Object.keys(this.cache)}get(e){if(!(e in this.cache))return;const t=this.cache[e];if(H.isValidator(t))return t;const r=new(t.default||t);return this.cache[e]=r,r}register(...e){e.forEach(e=>{if(H.isValidator(e)){if(e.validationKey in this.cache)return;this.cache[e.validationKey]=e}else{const{validationKey:t,validator:r,save:s}=e;if(t in this.cache)return;if(this.cache[t]=r,!s)return;const n={};n[t.toUpperCase()]=t,this.customKeyCache=Object.assign({},this.customKeyCache,n)}})}}var U;(e=>{e.DESCRIPTION="description",e.TYPE="design:type",e.MODEL="model",e.ANCHOR="__model",e.CONSTRUCTION="constructed-by",e.ATTRIBUTE="__attributes",e.HASHING="hashing",e.SERIALIZATION="serialization",e.DECORATORS="decorators",e.CONSTRUCTOR="__original"})(U||(U={}));const x="json";class C{static{this.actingValidatorRegistry=void 0}constructor(){}static setRegistry(e,t){t&&C.actingValidatorRegistry&&C.actingValidatorRegistry.getKeys().forEach(r=>{const s=e.get(r);s&&e.register(t(s))}),C.actingValidatorRegistry=e}static getRegistry(){return C.actingValidatorRegistry||(C.actingValidatorRegistry=new j),C.actingValidatorRegistry}static get(e){return C.getRegistry().get(e)}static register(...e){return C.getRegistry().register(...e)}static key(e){return f.REFLECT+e}static keys(){return this.getRegistry().getKeys()}static registerDecorator(t,r){const s=e.innerGet(Symbol.for(U.DECORATORS),e.key(f.REFLECT,t));s?.[t]||e.set(U.DECORATORS,e.key(f.REFLECT,t),r)}static decoratorFromKey(t){try{return e.innerGet(Symbol.for(U.DECORATORS),e.key(f.REFLECT,t))}catch(e){throw Error(`No decorator registered under ${t}: ${e}`)}}}function z(...e){return t(t=>(e.forEach(e=>{C.register({validator:t,validationKey:e,save:!0})}),t),r(f.VALIDATOR,e))}let F=class extends H{constructor(e=p.DATE){super(e,Number.name,Date.name,String.name)}hasErrors(e,t={}){if(void 0!==e&&("string"==typeof e&&(e=new Date(e)),Number.isNaN(e.getDate()))){const{message:e=""}=t;return this.getMessage(e||this.message)}}};function Y(e,t,...r){if(e===t)return 0!==e||1/e==1/t;if(null==e||null==t)return e===t;if(typeof e!=typeof t)return!1;if(Number.isNaN(e)&&Number.isNaN(t))return!0;if("object"!=typeof e)return e===t;if(e instanceof Date&&t instanceof Date)return!(!isNaN(e.getTime())||!isNaN(t.getTime()))||e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.toString()===t.toString();if(e instanceof Error&&t instanceof Error)return e.name===t.name&&e.message===t.message;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(!Y(e[s],t[s],...r))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[s,n]of e)if(!t.has(s)||!Y(n,t.get(s),...r))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(e.byteLength!==t.byteLength)return!1;if(e.byteOffset!==t.byteOffset)return!1;if(e.buffer.byteLength!==t.buffer.byteLength)return!1;const r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);for(let e=0;e<r.length;e++)if(r[e]!==s[e])return!1;return!0}const s=Object.keys(e).filter(e=>!r.includes(e)),n=Object.keys(t).filter(e=>!r.includes(e));if(s.length!==n.length)return!1;for(const i of s){if(!n.includes(i))return!1;if(!Y(e[i],t[i],...r))return!1}const i=Object.getOwnPropertySymbols(e).filter(e=>!r.includes(e.toString())),o=Object.getOwnPropertySymbols(t).filter(e=>!r.includes(e.toString()));if(i.length!==o.length)return!1;for(const s of i){if(!o.includes(s))return!1;if(!Y(e[s],t[s],...r))return!1}return Object.getPrototypeOf(e)===Object.getPrototypeOf(t)}F=c([z(f.DATE),u("design:paramtypes",[String])],F);let $=class extends H{constructor(e=p.DIFF){super(e)}hasErrors(e,t,r){let s;try{s=r.getValueFromPath(t[f.DIFF])}catch(e){return this.getMessage(e.message||this.message)}return Y(e,s)?this.getMessage(t.message||this.message,t.label||t[f.DIFF]):void 0}};$=c([z(f.DIFF),u("design:paramtypes",[String])],$);const G=RegExp("^/(.+)/([gimus]*)$");let Q=class extends H{constructor(e=p.PATTERN){super(e,"string")}getPattern(e){if(!G.test(e))return RegExp(e);const t=e.match(G);return RegExp(t[1],t[2])}hasErrors(e,t){if(!e)return;let{pattern:r}=t;if(!r)throw Error("Missing Pattern");return r="string"==typeof r?this.getPattern(r):r,r.lastIndex=0,r.test(e)?void 0:this.getMessage(t.message||this.message)}};Q=c([z(f.PATTERN),u("design:paramtypes",[String])],Q);let V=class extends Q{constructor(e=p.EMAIL){super(e)}hasErrors(e,t={}){return super.hasErrors(e,{...t,message:t.message||this.message,pattern:t?.pattern||y.EMAIL})}};V=c([z(f.EMAIL),u("design:paramtypes",[String])],V);let k=class extends H{constructor(e=p.EQUALS){super(e)}hasErrors(e,t,r){let s;try{s=r.getValueFromPath(t[f.EQUALS])}catch(e){return this.getMessage(e.message||this.message)}return Y(e,s)?void 0:this.getMessage(t.message||this.message,t.label||t[f.EQUALS])}};k=c([z(f.EQUALS),u("design:paramtypes",[String])],k);let q=class extends H{constructor(e=p.GREATER_THAN){super(e)}hasErrors(e,t,r){let s;try{s=r.getValueFromPath(t[f.GREATER_THAN])}catch(e){return this.getMessage(e.message||this.message)}try{if(!R(e,s))throw Error(t.message||this.message)}catch(e){return this.getMessage(e.message,t.label||t[f.GREATER_THAN])}}};q=c([z(f.GREATER_THAN),u("design:paramtypes",[String])],q);let B=class extends H{constructor(e=p.GREATER_THAN_OR_EQUAL){super(e)}hasErrors(e,t,r){let s;try{s=r.getValueFromPath(t[f.GREATER_THAN_OR_EQUAL])}catch(e){return this.getMessage(e.message||this.message)}try{if(S(e,s)&&Y(e,s)||R(e,s))return;throw Error(t.message||this.message)}catch(e){return this.getMessage(e.message,t.label||t[f.GREATER_THAN_OR_EQUAL])}}};B=c([z(f.GREATER_THAN_OR_EQUAL),u("design:paramtypes",[String])],B);let X=class extends H{constructor(e=p.LESS_THAN){super(e)}hasErrors(e,t,r){let s;try{s=r.getValueFromPath(t[f.LESS_THAN])}catch(e){return this.getMessage(e.message||this.message)}try{if(!O(e,s))throw Error(t.message||this.message)}catch(e){return this.getMessage(e.message,t.label||t[f.LESS_THAN])}}};X=c([z(f.LESS_THAN),u("design:paramtypes",[String])],X);let K=class extends H{constructor(e=p.LESS_THAN_OR_EQUAL){super(e)}hasErrors(e,t,r){let s;try{s=r.getValueFromPath(t[f.LESS_THAN_OR_EQUAL])}catch(e){return this.getMessage(e.message||this.message)}try{if(S(e,s)&&Y(e,s)||O(e,s))return;throw Error(t.message||this.message)}catch(e){return this.getMessage(e.message,t.label||t[f.LESS_THAN_OR_EQUAL])}}};K=c([z(f.LESS_THAN_OR_EQUAL),u("design:paramtypes",[String])],K);let W=class extends H{constructor(e=p.LIST){super(e,Array.name,Set.name)}hasErrors(e,t){if(!e||(Array.isArray(e)?!e.length:!e.size))return;const r=(Array.isArray(t.clazz)?t.clazz:[t.clazz]).map(e=>"string"==typeof e?e:e?.name||"function"!=typeof e?e?.name:e().name);let s,n=!0;for(let r=0;r<(Array.isArray(e)?e.length:e.size);r++)s=[...e][r],n=(Array.isArray(t.clazz)?t.clazz:[t.clazz]).some(e=>P(s,e));return n?void 0:this.getMessage(t.message||this.message,r)}};W=c([z(f.LIST),u("design:paramtypes",[String])],W);let Z=class extends H{constructor(e=p.MAX_LENGTH){super(e,String.name,Array.name,Set.name,Map.name)}hasErrors(e,t){if(void 0!==e)return L(e)>t.maxlength?this.getMessage(t.message||this.message,t.maxlength):void 0}};Z=c([z(f.MAX_LENGTH),u("design:paramtypes",[String])],Z);let J=class extends H{constructor(e=p.MAX){super(e,Number.name,Date.name,String.name)}hasErrors(e,t){if(void 0===e)return;let{max:r}=t;if(e instanceof Date&&!(r instanceof Date)&&(r=new Date(r),Number.isNaN(r.getDate())))throw Error("Invalid Max param defined");return e>r?this.getMessage(t.message||this.message,r):void 0}};J=c([z(f.MAX),u("design:paramtypes",[String])],J);let ee=class extends H{constructor(e=p.MIN_LENGTH){super(e,String.name,Array.name,Set.name,Map.name)}hasErrors(e,t){if(void 0!==e)return L(e)<t.minlength?this.getMessage(t.message||this.message,t.minlength):void 0}};ee=c([z(f.MIN_LENGTH),u("design:paramtypes",[String])],ee);let te=class extends H{constructor(e=p.MIN){super(e,Number.name,Date.name,String.name)}hasErrors(e,t){if(void 0===e)return;let{min:r}=t;if(e instanceof Date&&!(r instanceof Date)&&(r=new Date(r),Number.isNaN(r.getDate())))throw Error("Invalid Min param defined");return r>e?this.getMessage(t.message||this.message,r):void 0}};te=c([z(f.MIN),u("design:paramtypes",[String])],te);let re=class extends H{constructor(e=p.ENUM){super(e)}hasErrors(e,t){if(void 0!==e){if(Array.isArray(t.enum))return t.enum.includes(e)?void 0:this.getMessage(t.message||this.message,t.enum);if("object"==typeof t.enum){const r=Object.keys(t.enum);for(const s of r)if(t.enum[s]===e)return;return this.getMessage(t.message||this.message,Object.values(t.enum))}}}};re=c([z(f.ENUM),u("design:paramtypes",[String])],re);let se=class extends Q{constructor(e=p.PASSWORD){super(e)}hasErrors(e,t={}){return super.hasErrors(e,{...t,message:t.message||this.message,[f.PATTERN]:t?.pattern||y.PASSWORD.CHAR8_ONE_OF_EACH})}};se=c([z(f.PASSWORD),u("design:paramtypes",[Object])],se);let ne=class extends H{constructor(e=p.REQUIRED){super(e)}hasErrors(e,t={}){switch(typeof e){case"boolean":case"number":return void 0===e?this.getMessage(t.message||this.message):void 0;default:return e?void 0:this.getMessage(t.message||this.message)}}};ne=c([z(f.REQUIRED),u("design:paramtypes",[String])],ne);let ie=class extends H{constructor(e=p.STEP){super(e,"number","string")}hasErrors(e,t){if(void 0!==e)return Number(e)%Number(t.step)!==0?this.getMessage(t.message||this.message,t.step):void 0}};ie=c([z(f.STEP),u("design:paramtypes",[String])],ie);let oe=class extends H{constructor(e=p.TYPE){super(e)}hasErrors(e,t){if(void 0===e)return;const{type:r,message:s,customTypes:n}=t;let i=n||r;i=Array.isArray(i)?i:[i];const o=i.map(e=>"string"==typeof e?e:"function"!=typeof e||e.name?e?.name||e+"":e().name);return w(e,i)?void 0:this.getMessage(s||this.message,o.join(", "),typeof e)}};oe=c([z(f.TYPE),u("design:paramtypes",[String])],oe),C.register({validator:oe,validationKey:U.TYPE,save:!1});let ae=class extends Q{constructor(e=p.URL){super(e)}hasErrors(e,t={}){return super.hasErrors(e,{...t,message:t.message||this.message,pattern:t.pattern||y.URL})}};function ce(e,t){let r=t;r.match(/hh/)?r=r.replace("hh","(?<hour>\\d{2})"):r.match(/h/)?r=r.replace("h","(?<hour>\\d{1,2})"):r.match(/HH/)?r=r.replace("HH","(?<hour>\\d{2})"):r.match(/H/)&&(r=r.replace("H","(?<hour>\\d{1,2})")),r.match(/mm/)?r=r.replace("mm","(?<minutes>\\d{2})"):r.match(/m/)&&(r=r.replace("m","(?<minutes>\\d{1,2})")),r.match(/ss/)?r=r.replace("ss","(?<seconds>\\d{2})"):r.match(/s/)&&(r=r.replace("s","(?<seconds>\\d{1,2})")),r.match(/dd/)?r=r.replace("dd","(?<day>\\d{2})"):r.match(/d/)&&(r=r.replace("d","(?<day>\\d{1,2})")),r.match(/EEEE/)?r=r.replace("EEEE","(?<dayofweek>\\w+)"):r.match(/EEEE/)&&(r=r.replace("EEE","(?<dayofweek>\\w+)")),r.match(/yyyy/)?r=r.replace("yyyy","(?<year>\\d{4})"):r.match(/yy/)&&(r=r.replace("yy","(?<year>\\d{2})")),r.match(/MMMM/)?r=r.replace("MMMM","(?<monthname>\\w+)"):r.match(/MMM/)&&(r=r.replace("MMM","(?<monthnamesmall>\\w+)")),r.match(/MM/)?r=r.replace("MM","(?<month>\\d{2})"):r.match(/M/)&&(r=r.replace("M","(?<month>\\d{1,2})")),r=r.replace("S","(?<milis>\\d{1,3})").replace("aaa","(?<ampm>\\w{2})");const s=RegExp(r,"g").exec(e);if(!s||!s.groups)return new Date(e);const n=e=>{if(!e)return 0;const t=parseInt(e);return isNaN(t)?0:t},i=n(s.groups.year),o=n(s.groups.day),a=s.groups.ampm;let c=n(s.groups.hour);a&&(c="PM"===a?c+12:c);const u=n(s.groups.minutes),l=n(s.groups.seconds),d=n(s.groups.milis),f=s.groups.monthname,h=s.groups.monthnamesmall;let p=s.groups.month;if(f)p=g.indexOf(f);else if(h){const t=g.find(e=>e.toLowerCase().startsWith(h.toLowerCase()));if(!t)return new Date(e);p=g.indexOf(t)}else p=n(""+p);return new Date(i,p-1,o,c,u,l,d)}function ue(e,t){if(e)return Object.defineProperty(e,"toISOString",{enumerable:!1,configurable:!1,value:new Proxy(e.toISOString,{apply:(e,r)=>fe(r,t)})}),Object.defineProperty(e,"toString",{enumerable:!1,configurable:!1,value:new Proxy(e.toISOString,{apply:(e,r)=>fe(r,t)})}),e}function le(e){return e&&"[object Date]"===Object.prototype.toString.call(e)&&!Number.isNaN(e)}function de(e){return 10>e?"0"+e:e.toString()}function fe(e,t="yyyy/MM/dd"){const r=e.getDate(),s=e.getMonth(),n=e.getFullYear(),i=e.getHours(),o=e.getMinutes(),a=e.getSeconds(),c=e.getMilliseconds(),u=i%12,l=de(u),d=de(i),f=de(o),p=de(a),y=12>i?"AM":"PM",m=h[e.getDay()],E=m.substr(0,3),b=de(r),A=s+1,T=de(A),N=g[s],M=N.substr(0,3),S=n+"",O=S.substr(2,2);return(t=t.replace("hh",l).replace("h",u.toString()).replace("HH",d).replace("H",i.toString()).replace("mm",f).replace("m",o.toString()).replace("ss",p).replace("s",a.toString()).replace("S",c.toString()).replace("dd",b).replace("d",r.toString()).replace("EEEE",m).replace("EEE",E).replace("yyyy",S).replace("yy",O).replace("aaa",y)).indexOf("MMM")>-1?t.replace("MMMM",N).replace("MMM",M):t.replace("MM",T).replace("M",A.toString())}function ge(e,t){let r;if(t){if(t instanceof Date)try{r=ce(fe(t,e),e)}catch(r){throw Error(E("Could not convert date {0} to format: {1}",t.toString(),e))}else if("string"==typeof t)r=ce(t,e);else if("number"==typeof t)r=ce(fe(new Date(t),e),e);else{if(!le(t))throw Error("Invalid value provided "+t);try{r=ce(fe(new Date(t),e),e)}catch(r){throw Error(E("Could not convert date {0} to format: {1}",t,e))}}return ue(r,e)}}function he(e,r,s){return t(n(r,s))}function pe(e,t,r){return C.registerDecorator(t,e),(e,s)=>he(0,`${f.REFLECT}.${s}.${t}`,r)(e,s)}function ye(){return e=>{Object.prototype.hasOwnProperty.call(e,T)||(e[T]=!0)}}function me(e=p.REQUIRED){const t=f.REQUIRED,r={message:e,description:"defines the attribute as required",async:!1};return s.for(t).define({decorator:pe,args:[me,t,r]}).apply()}function Ee(e,t=p.MIN){const r=f.MIN,n={[f.MIN]:e,message:t,description:`defines the max value of the attribute as ${e} (applies to numbers or Dates)`,async:!1};return s.for(r).define({decorator:pe,args:[Ee,r,n]}).apply()}function be(e,t=p.MAX){const r=f.MAX,n={[f.MAX]:e,message:t,description:`defines the max value of the attribute as ${e} (applies to numbers or Dates)`,async:!1};return s.for(r).define({decorator:pe,args:[be,r,n]}).apply()}function Ae(e,t=p.STEP){const r=f.STEP,n={[f.STEP]:e,message:t,description:"defines the step of the attribute as "+e,async:!1};return s.for(r).define({decorator:pe,args:[Ae,r,n]}).apply()}function Te(e,t=p.MIN_LENGTH){const r=f.MIN_LENGTH,n={[f.MIN_LENGTH]:e,message:t,description:`defines the min length of the attribute as ${e} (applies to strings or lists)`,async:!1};return s.for(r).define({decorator:pe,args:[Te,r,n]}).apply()}function Ne(e,t=p.MAX_LENGTH){const r=f.MAX_LENGTH,n={[f.MAX_LENGTH]:e,message:t,description:`defines the max length of the attribute as ${e} (applies to strings or lists)`,async:!1};return s.for(r).define({decorator:pe,args:[Ne,r,n]}).apply()}function Me(e,t=p.PATTERN){const r=f.PATTERN,n={[f.PATTERN]:"string"==typeof e?e:e.toString(),message:t,description:`assigns the ${"string"===e?e:e.toString()} pattern to the attribute`,async:!1};return s.for(r).define({decorator:pe,args:[Me,r,n]}).apply()}function Se(e=p.EMAIL){const t=f.EMAIL,r={[f.PATTERN]:y.EMAIL.toString(),message:e,description:"marks the attribute as an email",async:!1};return s.for(t).define({decorator:pe,args:[Se,t,r]}).apply()}function Oe(e=p.URL){const t=f.URL,r={[f.PATTERN]:y.URL.toString(),message:e,description:"marks the attribute as an url",async:!1};return s.for(t).define({decorator:pe,args:[Oe,t,r]}).apply()}function Re(e,t=p.TYPE){const r=f.TYPE,n={customTypes:e,message:t,description:"defines the accepted types for the attribute",async:!1};return s.for(r).define({decorator:pe,args:[Re,r,n]}).apply()}function ve(e="dd-MM-yyyy HH:mm:ss:S",t=p.DATE){const r=f.DATE;return s.for(r).define({decorator:function(e,t){const s={[f.FORMAT]:e,message:t,description:"defines the attribute as a date with the format "+e,async:!1};return function(t,n){const i=new WeakMap;return Object.defineProperty(t,n,{configurable:!0,set(t){const r=Object.getOwnPropertyDescriptor(this,n);r&&!r.configurable||Object.defineProperty(this,n,{enumerable:!0,configurable:!1,get:()=>i.get(this),set:t=>{let r;try{r=ge(e,t),i.set(this,r)}catch(e){}}}),this[n]=t},get(){return i.get(this)}}),pe(ve,r,s)(t,n)}},args:[e,t]}).apply()}function _e(e=y.PASSWORD.CHAR8_ONE_OF_EACH,t=p.PASSWORD){const r=f.PASSWORD,n={[f.PATTERN]:e.toString(),message:t,description:"attribute as a password",async:!1};return s.for(r).define({decorator:pe,args:[_e,r,n]}).apply()}function Pe(e,t="Array",r=p.LIST){const n=f.LIST,i={clazz:Array.isArray(e)?e:[e],type:t,message:r,async:!1,description:`defines the attribute as a ${t} of ${e.name}`};return s.for(n).define({decorator:pe,args:[Pe,n,i]}).apply()}function we(e,t=p.LIST){return Pe(e,"Set",t)}function Le(e,t){return pe(Le,f.EQUALS,{label:t?.label||e,message:t?.message||p.EQUALS,[f.EQUALS]:e,description:"defines attribute as equal to "+e,async:!1})}function De(e,t){return pe(De,f.DIFF,{label:t?.label||e,message:t?.message||p.DIFF,[f.DIFF]:e,description:"defines attribute as different to "+e,async:!1})}function Ie(e,t){return pe(Ie,f.LESS_THAN,{label:t?.label||e,message:t?.message||p.LESS_THAN,[f.LESS_THAN]:e,description:"defines attribute as less than to "+e,async:!1})}function He(e,t){return pe(He,f.LESS_THAN_OR_EQUAL,{label:t?.label||e,message:t?.message||p.LESS_THAN_OR_EQUAL,[f.LESS_THAN_OR_EQUAL]:e,description:"defines attribute as less or equal to "+e,async:!1})}function je(e,t){return pe(je,f.GREATER_THAN,{label:t?.label||e,message:t?.message||p.GREATER_THAN,[f.GREATER_THAN]:e,description:"defines attribute as greater than "+e,async:!1})}function Ue(e,t){return pe(Ue,f.GREATER_THAN_OR_EQUAL,{label:t?.label||e,message:t?.message||p.GREATER_THAN_OR_EQUAL,[f.GREATER_THAN_OR_EQUAL]:e,description:"defines attribute as greater or equal to "+e,async:!1})}function xe(e,t=p.ENUM){const r=f.ENUM,n={[f.ENUM]:e,message:t,description:"defines a list or an object of accepted values for the attribute",async:!1};return s.for(r).define({decorator:pe,args:[xe,r,n]}).apply()}ae=c([z(f.URL),u("design:paramtypes",[String])],ae);class Ce{static{this.current=x}constructor(){}static get(e){if(e in this.cache)return this.cache[e];throw Error("No serialization method registered under "+e)}static register(e,t,r=!1){if(e in this.cache)throw Error(`Serialization method ${e} already registered`);this.cache[e]=new t,r&&(this.current=e)}static serialize(e,t,...r){return t?this.get(t).serialize(e,...r):this.get(this.current).serialize(e,...r)}static deserialize(e,t,...r){return t?this.get(t).deserialize(e,...r):this.get(this.current).deserialize(e,...r)}static setDefault(e){this.current=this.get(e)}}class ze{constructor(e){for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&e[t]&&Object.defineProperty(this,t,{enumerable:!0,configurable:!1,value:e[t],writable:!1})}toString(){const e=this;return Object.keys(e).filter(t=>Object.prototype.hasOwnProperty.call(e,t)&&"function"!=typeof e[t]).reduce((t,r)=>{let s=Object.keys(e[r]).reduce((t,s)=>(t?t+="\n"+e[r][s]:t=e[r][s],t),void 0);return s&&(s=`${r} - ${s}`,t?t+="\n"+s:t=s),t},"")}}const Fe=e=>e[A],Ye=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw Error(E(b.PROPERTY_NOT_EXIST,t));return e[t]};class $e{static create(e,t){const{getValue:r,getParent:s,ignoreUndefined:n,ignoreNull:i}={getParent:Fe,getValue:Ye,ignoreNull:!1,ignoreUndefined:!1,...t},o=new Proxy({},{get:(t,o)=>"getValueFromPath"===o?t=>{const o=$e.parsePath(t);let a=e;for(let e=0;e<o.length;e++){const c=o[e];if(".."===c){const r=s(a);if(!r||"object"!=typeof r)throw Error(E(b.CONTEXT_NOT_OBJECT_COMPARISON,e+1,t));a=r;continue}if(a=r(a,c),!n&&void 0===a)throw Error(E(b.PROPERTY_INVALID,t,c));if(!i&&null===a)throw Error(E(b.PROPERTY_INVALID,t,c))}return a}:t[o]});return o}static parsePath(e){if("string"!=typeof e||!e.trim())throw Error(E(b.INVALID_PATH,e));return e.match(/(\.\.|[^/.]+)/g)||[]}}function Ge(e,t){return t?Promise.resolve(e):e}var Qe;(e=>{e.STRING="string",e.NUMBER="number",e.BOOLEAN="boolean",e.BIGINT="bigint"})(Qe||(Qe={}));const Ve={STRING:String,OBJECT:Object,NUMBER:Number,BOOLEAN:Boolean,BIGINT:BigInt,DATE:Date},ke=["string","array","number","boolean","symbol","function","object","undefined","null","bigint"];let qe,Be;class Xe{constructor(t=e.isModel){this.cache={},this.testFunction=t}register(e,t){if("function"!=typeof e)throw Error("Model registering failed. Missing Class name or constructor");t=t||e.name,this.cache[t]=e}get(e){try{return this.cache[e]}catch(e){return}}build(t={},r){if(!r&&!this.testFunction(t))throw Error("Provided obj is not a Model object");const s=r||e.modelName(t.constructor);if(!(s in this.cache))throw Error(`Provided class ${s} is not a registered Model object`);return new this.cache[s](t)}static setBuilder(e){qe=e}static getBuilder(){return qe||Xe.fromModel}static fromModel(t,r){let s;r||(r={});const n=e.getAttributes(t),i=Object.getPrototypeOf(t);let o;for(const a of n){try{t[a]=r[a]??t[a]??void 0}catch(e){if(o=Object.getOwnPropertyDescriptor(i,a),!o||o.writable)throw Error(`Unable to write property ${a} to model: ${e}`)}if("object"!=typeof t[a])continue;const n=e.isPropertyModel(t,a);if(n){try{t[a]=Xe.getRegistry().build(t[a],"string"==typeof n?n:void 0)}catch(e){}continue}const c=e.validationFor(t.constructor,a);if(c?.[f.LIST]&&(Array.isArray(t[a])||t[a]instanceof Set)){const e=c[f.LIST].clazz.map(e=>"function"!=typeof e||e.name?e:e()).find(e=>!ke.includes(e.name.toLowerCase()));if(Array.isArray(t[a])&&(t[a]=t[a].map(t=>["object","function"].includes(typeof t)&&e?Xe.getRegistry().build(t,e.name):t)),t[a]instanceof Set){const r=new Set;for(const s of t[a])["object","function"].includes(typeof s)&&e?r.add(Xe.getRegistry().build(s,e.name)):r.add(s);t[a]=r}continue}if(s=e.allowedTypes(t.constructor,a),!s||!s.length)throw Error("failed to find decorators for property "+a);const u=s.map(e=>"function"!=typeof e||e.name?e:e()),l=Object.values(Ve);u.forEach(e=>{if(!l.includes(e))try{e.name,void 0!==t[a]&&Xe.getRegistry().get(e.name)&&(t[a]=Xe.getRegistry().build(t[a],e.name))}catch(e){}})}return t}static getRegistry(){return Be||(Be=new Xe),Be}static setRegistry(e){Be=e}}function Ke(...e){e.forEach(e=>{const t=e.constructor?e.constructor:e;Xe.getRegistry().register(t,e.name)})}function We(e,t,r){Object.hasOwnProperty.call(e,t)||(e[t]=r)}function Ze(e,t){Object.hasOwnProperty.call(e,t)&&delete e[t]}function Je(e,t,r,...s){t&&We(e,A,t),We(e,T,!!r);const n=e.hasErrors(...s);return Ze(e,A),Ze(e,T),n}function et(e,t,r,s,n,...i){let o,a=!1;for(const c of s){const s=Xe.getRegistry().get(c);if(s||(o=new ze({[e]:{[f.TYPE]:"Unable to verify type consistency, missing model registry for "+c}})),t instanceof s){a=!0,o=Je(t,r,n,...i);break}}return a?o:o||new ze({[e]:{[f.TYPE]:"Value must be an instance of one of the expected types: "+s.join(", ")}})}function tt(e,...t){return t?.map(t=>("string"==typeof t&&t?.startsWith(e+".")&&(t=t.replace(e+".","")),t))}function rt(e,t,r,s){const n=C.get(r.key);if(!n)throw Error("Missing validator for "+r.key);if(!s&&r.async)return;const i=r.key===U.TYPE?[r]:r||{},o=$e.create(e,{ignoreUndefined:!0,ignoreNull:!0}),a=r.key===U.TYPE?i[0]:i;return Ge(n.hasErrors(t,a,o),s)}function st(t,r,s,n,i,...o){const a={};for(const c in n){const u={...n[c],key:c};if(!i&&u.async)continue;let l=rt(t,s,u,i);if(c===f.LIST&&(!l||i)){const n=s instanceof Set?[...s]:s;if(n&&n.length>0){let s=u.class||u.clazz||u.customTypes;s=(Array.isArray(s)?s:[s]).map(e=>(e="function"!=typeof e||e.name?e:e()).name?e.name:e);const a=[s].flat().map(e=>(e+"").toLowerCase()),c=n.map(n=>{if(!["string","number","bigint"].includes(typeof n)){if(e.isModel(n)){const e=tt(r,...o);return et(r,n,t,s.flat(),!!i,...e)}return a.includes(typeof n)?void 0:"Value has no validatable type"}});if(i)l=Promise.all(c).then(e=>e.every(e=>!e)?void 0:e);else{const e=c.every(e=>!e);l=c.length>0&&!e?c:void 0}}}const d=c===U.TYPE?f.TYPE:c;l&&(a[d]=l)}if(!i)return Object.keys(a).length>0?a:void 0;const c=Object.keys(a),u=Object.values(a);return Promise.all(u).then(e=>{const t={};for(let r=0;r<e.length;r++){const s=e[r];void 0!==s&&(t[c[r]]=s)}return Object.keys(t).length>0?t:void 0})}function nt(t,r,...s){const n=e.validatableProperties(t.constructor,...s),i={},o={};for(const a of n){const n=a+"",c=t[a],u=e.validationFor(t.constructor,a)||{},{designTypes:l}=e.getPropDesignTypes(t.constructor,a);if(!l)continue;if(l.some(e=>[Array.name,Set.name].includes(e.name))){if(!u||!Object.keys(u).includes(f.LIST)){i[n]={[f.TYPE]:`Array or Set property '${n}' requires a @list decorator`};continue}if(c&&!(Array.isArray(c)||c instanceof Set)){i[n]={[f.TYPE]:`Property '${a+""}' must be either an Array or a Set`};continue}}const d=st(t,n,c,u,r,...s)||{};if(e.isPropertyModel(t,n)&&null!=c){const e=l.map(e=>Xe.getRegistry().get(e.name||e)).find(e=>!!e),i=l.map(e=>"function"==typeof e?e.name?e.name.toLowerCase():e()?.name.toLowerCase():e.toLowerCase());if(e&&c instanceof e){const e=tt(n,...s);o[n]=Je(c,t,r,...e)}else i.includes(typeof c)||(d[f.TYPE]=e?"Value must be an instance of "+e.name:`Unable to verify type consistency, missing model registry for ${l.toString()} on prop ${n}`,delete d[U.TYPE])}(Object.keys(d).length>0||r)&&(i[n]=d),r||Object.entries(o[n]||{}).forEach(([e,t])=>{void 0!==t&&(i[`${n}.${e}`]=t)})}if(!r)return Object.keys(i).length>0?new ze(i):void 0;const a=i,c=Object.keys(a),u=Object.values(a);return Promise.allSettled(u).then(async e=>{const t={};for(const[e,r]of Object.entries(o)){const s=await r;s&&Object.entries(s).forEach(([r,s])=>{void 0!==s&&(t[[e,r].join(".")]=s)})}for(let r=0;r<e.length;r++){const s=c[r],n=e[r];"fulfilled"===n.status&&void 0!==n.value?t[s]=n.value:"rejected"===n.status&&(t[s]=n.reason instanceof Error?n.reason.message:(n.reason||"Validation failed")+"")}return Object.keys(t).length>0?new ze(t):void 0})}function it(e){e+="";let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return t.toString()}function ot(e){const t=(e,t)=>{const r=s(t);return"string"==typeof r?s((e||"")+s(t)):(e=((e=e||0)<<5)-e+r)&e},r=it,s=e=>void 0===e?"":-1!==["string","number","symbol"].indexOf(typeof e)?r(e.toString()):e instanceof Date?r(e.getTime()):Array.isArray(e)?e.reduce(t,void 0):Object.values(e).reduce(t,void 0),n=Object.values(e).reduce(t,0);return("number"==typeof n?Math.abs(n):n).toString()}const at="default";class ct{static{this.current=at}static{this.cache={default:ot}}constructor(){}static get(e){if(e in this.cache)return this.cache[e];throw Error("No hashing method registered under "+e)}static register(e,t,r=!1){if(e in this.cache)throw Error(`Hashing method ${e} already registered`);this.cache[e]=t,r&&(this.current=e)}static hash(e,t,...r){return t?this.get(t)(e,...r):this.get(this.current)(e,...r)}static setDefault(e){this.current=this.get(e)}}class ut{constructor(e=void 0){}isAsync(){return!!(this[T]??this?.constructor[T])}hasErrors(...e){return nt(this,this.isAsync(),...e)}equals(e,...t){return Y(this,e,...t)}compare(t,...r){const s=e.properties(this.constructor);if(!s||!s.length)return;const n=s.reduce((e,s)=>{const n=s;if(r.includes(n))return e;if(void 0===this[n]&&void 0!==t[n])return e[n]={other:t[n],current:void 0},e;if(void 0!==this[n]&&void 0===t[n])return e[n]={other:void 0,current:this[n]},e;if(Y(this[n],t[n]))return e;if(ut.isPropertyModel(this,n)){const r=this[n].compare(t[n]);return r&&(e[n]=r),e}if(Array.isArray(this[n])&&Array.isArray(t[n])){if(this[n].length!==t[n].length)return e[n]={current:this[n],other:t[n]},e;const r=this[n].map((e,r)=>Y(e,t[n][r])?null:e instanceof ut&&t[n][r]instanceof ut?e.compare(t[n][r]):{current:e,other:t[n][r]});return r.some(e=>null!==e)&&(e[n]=r),e}return e[n]={other:t[n],current:this[n]},e},{});return Object.keys(n).length>0?n:void 0}serialize(){return ut.serialize(this)}toString(){return this.constructor.name+": "+JSON.stringify(this,void 0,2)}hash(){return ut.hash(this)}static deserialize(t){let r;try{r=e.get(this.constructor,U.SERIALIZATION)}catch(e){r=void 0}return r&&r.serializer?Ce.deserialize(t,r.serializer,...r.args||[]):Ce.deserialize(t)}static fromObject(e,t){t||(t={});for(const r of ut.getAttributes(e))e[r]=t[r]??e[r]??void 0;return e}static fromModel(e,t){return Xe.fromModel(e,t)}static setBuilder(e){Xe.setBuilder(e)}static getBuilder(){return Xe.getBuilder()}static getRegistry(){return Xe.getRegistry()}static setRegistry(e){Xe.setRegistry(e)}static register(e,t){return Xe.getRegistry().register(e,t)}static get(e){return Xe.getRegistry().get(e)}static build(e={},t){return ut.getRegistry().build(e,t)}static getAttributes(t){return e.getAttributes(t)}static equals(e,t,...r){return Y(e,t,...r)}static hasErrors(e,t,...r){return nt(e,t,...r)}static serialize(t){let r;try{r=e.get(t.constructor,U.SERIALIZATION)}catch(e){r=void 0}return r&&r.serializer?Ce.serialize(this,r.serializer,...r.args||[]):Ce.serialize(t)}static hash(t){const r=e.get(t.constructor,U.HASHING);return r&&r.algorithm?ct.hash(t,r.algorithm,...r.args||[]):ct.hash(t)}static isModel(t){return e.isModel(t)}static isPropertyModel(t,r){return e.isPropertyModel(t,r)}static describe(t,r){return e.description(t,r)}}function lt(e){return e instanceof ft?e.build():new Date(e)}function dt(e,t,r){const s=new Date(e);return r.years&&s.setFullYear(s.getFullYear()+t*r.years),r.months&&s.setMonth(s.getMonth()+t*r.months),r.days&&s.setDate(s.getDate()+t*r.days),r.hours&&s.setHours(s.getHours()+t*r.hours),r.minutes&&s.setMinutes(s.getMinutes()+t*r.minutes),r.seconds&&s.setSeconds(s.getSeconds()+t*r.seconds),s}e.validationFor=((t,r,s)=>{const n=e.get(t);if(!n)return;if(!r)return n.validation;if(!n.validation)return;if(!n.validation[f.TYPE]){const{designTypes:s}=e.getPropDesignTypes(t,r);n.validation[r]&&s?.length&&s[0]!==Ve.OBJECT&&(n.validation[r][f.TYPE]={customTypes:s,message:p.TYPE,description:"defines the accepted types for the attribute",async:!1})}if(!s)return n.validation[r];const i=n.validation[r];return i?i[s]:void 0}).bind(e),e.modelName=(t=>{const r=e.constr(t);return r?r.name:t.name}).bind(e),e.validatableProperties=((t,...r)=>{const s=e.validationFor(t),n=s?Object.keys(s):[];return[...new Set([...ut.getAttributes(t),...n])].filter(e=>!r||!r?.includes(e))}).bind(e),e.allowedTypes=((t,r)=>{const s=e.type(t,r);if(!s)throw Error("No metadata found for property "+r);const n=e.validationFor(t,r);return n&&n[f.TYPE]&&"function"==typeof n[f.TYPE]?.customTypes[Symbol.iterator]?[...n[f.TYPE].customTypes]:[s]}).bind(e),e.getPropDesignTypes=((t,r)=>{const s=e.get(t),n=e.type(t,r),i=s?.[f.REFLECT]?.[r];if(!(n||i&&i[f.TYPE]))return{};const o=i&&i[f.TYPE]?[i[f.TYPE].customTypes]:[n];if(!o?.length)return{};const a=o[0],c=a.class||a.clazz||a.customTypes||a;return{designTypes:(Array.isArray(c)?c:[c]).map(e=>"function"!=typeof e||e.name?e:e()),designType:c}}).bind(e),e.isModel=(t=>{try{if(t instanceof ut)return!0;const r=e.constr(t);return!(!r||r===t||!e.modelName(r))}catch(e){return!1}}).bind(e),e.isPropertyModel=((t,r)=>{if(e.isModel(t[r]))return!0;const s=e.type(t.constructor,r);return s&&Xe.getRegistry().get(s.name)?s.name:void 0}).bind(e),e.getAttributes=(t=>{const r=t instanceof ut?t.constructor:t,s=new Set,n=t=>{if(!t)return[];const r=e.constr(t),i=n(Object.getPrototypeOf(r)),o=e.properties(t)??[];for(const e of o)s.has(e)||(s.add(e),i.push(e));return i};return n(r)}).bind(e);class ft{constructor(){this.years=0,this.months=0,this.days=0,this.hours=0,this.minutes=0,this.seconds=0}static Years(e){return(new ft).Years(e)}static Months(e){return(new ft).Months(e)}static Days(e){return(new ft).Days(e)}static Hours(e){return(new ft).Hours(e)}static Minutes(e){return(new ft).Minutes(e)}static Seconds(e){return(new ft).Seconds(e)}static Now(){return new Date}static Tomorrow(){return ft.Days(1).from(ft.Now())}static Yesterday(){return ft.Days(1).until(ft.Now())}static DaysAgo(e){return ft.Days(e).until(ft.Now())}static NextDays(e){return ft.Days(e).from(ft.Now())}static YearsAgo(e){return ft.Years(e).until(ft.Now())}static NextYears(e){return ft.Years(e).from(ft.Now())}static MonthsAgo(e){return ft.Months(e).until(ft.Now())}static NextMonths(e){return ft.Months(e).from(ft.Now())}static HoursAgo(e){return ft.Hours(e).until(ft.Now())}static NextHours(e){return ft.Hours(e).from(ft.Now())}static MinutesAgo(e){return ft.Minutes(e).until(ft.Now())}static NextMinutes(e){return ft.Minutes(e).from(ft.Now())}static SecondsAgo(e){return ft.Seconds(e).until(ft.Now())}static NextSeconds(e){return ft.Seconds(e).from(ft.Now())}Years(e){return this.years+=e,this}Months(e){return this.months+=e,this}Days(e){return this.days+=e,this}Hours(e){return this.hours+=e,this}Minutes(e){return this.minutes+=e,this}Seconds(e){return this.seconds+=e,this}build(e=new Date){return this.from(e)}from(e){return dt(lt(e),1,this.offsets())}past(e){return this.from(e)}after(e){return this.from(e)}until(e){return dt(lt(e),-1,this.offsets())}before(e){return this.until(e)}ago(e=new Date){return this.until(e)}Now(){return ft.Now()}Tomorrow(){return ft.Tomorrow()}Yesterday(){return ft.Yesterday()}DaysAgo(e){return ft.DaysAgo(e)}NextDays(e){return ft.NextDays(e)}YearsAgo(e){return ft.YearsAgo(e)}NextYears(e){return ft.NextYears(e)}MonthsAgo(e){return ft.MonthsAgo(e)}NextMonths(e){return ft.NextMonths(e)}HoursAgo(e){return ft.HoursAgo(e)}NextHours(e){return ft.NextHours(e)}MinutesAgo(e){return ft.MinutesAgo(e)}NextMinutes(e){return ft.NextMinutes(e)}SecondsAgo(e){return ft.SecondsAgo(e)}NextSeconds(e){return ft.NextSeconds(e)}offsets(){return{years:this.years,months:this.months,days:this.days,hours:this.hours,minutes:this.minutes,seconds:this.seconds}}}const gt=ft,ht=()=>ft.Now(),pt=()=>ft.Tomorrow(),yt=()=>ft.Yesterday(),mt=e=>ft.DaysAgo(e),Et=e=>ft.NextDays(e),bt=e=>ft.YearsAgo(e),At=e=>ft.NextYears(e),Tt=e=>ft.MonthsAgo(e),Nt=e=>ft.NextMonths(e),Mt=e=>ft.HoursAgo(e),St=e=>ft.NextHours(e),Ot=e=>ft.MinutesAgo(e),Rt=e=>ft.NextMinutes(e),vt=e=>ft.SecondsAgo(e),_t=e=>ft.NextSeconds(e);class Pt{constructor(){}preSerialize(t,...r){const s=Object.assign({},t);let n;try{n=e.modelName(t.constructor)}catch(e){n=void 0}return s[U.ANCHOR]=n||t.constructor.name,s}deserialize(e,...t){const r=JSON.parse(e),s=r[U.ANCHOR];if(!s)throw Error("Could not find class reference in serialized model");return ut.build(r,s)}serialize(e,...t){return JSON.stringify(this.preSerialize(e))}}function wt(e,...t){const r=(...t)=>new e(...t);return r.prototype=e.prototype,r(...t)}function Lt(e){let t=Object.getPrototypeOf(e);if(t===Object.prototype)return e;for(;t!==Object.prototype;){if(t=Object.getPrototypeOf(t),t===Object.prototype)return t;if(Object.getPrototypeOf(t)===Object.prototype)return t}throw Error("Could not find proper prototype")}function Dt(e){if(e instanceof ut)return;function t(e,t){Object.setPrototypeOf(e,t)}const r=Object.getPrototypeOf(e);if(r===Object.prototype)return t(e,ut.prototype);for(;r!==Object.prototype;){const e=Object.getPrototypeOf(r);if(e===Object.prototype||Object.getPrototypeOf(e)===Object.prototype)return t(r,ut.prototype)}throw Error("Could not find proper prototype to bind")}function It(e){const t=(...t)=>{const r=wt(e,...t);Dt(r);const s=ut.getBuilder();return s&&s(r,t.length?t[0]:void 0),r};return t.prototype=e.prototype,Object.setPrototypeOf(t,e),Object.defineProperty(t,"name",{writable:!1,enumerable:!0,configurable:!1,value:e.prototype.constructor.name}),r(U.CONSTRUCTOR,e)(t),ut.register(t,e.name),t}function Ht(){const e=U.MODEL;return s.for(e).define(It).apply()}function jt(e,...t){return r(U.HASHING,{algorithm:e,args:t})}function Ut(e,...t){return r(U.SERIALIZATION,{serializer:e,args:t})}Ce.cache={json:new Pt};class xt{constructor(e,t,r){this.parent=e,this.attr=t,this.declaredType=r,this.decorators=[]}decorate(...e){for(const t of e){if(this.decorators.includes(t))throw Error(`Decorator "${t}" has already been used`);this.decorators.push(t)}return this.parent}undecorate(...e){for(const t of e){const e=this.decorators.indexOf(t);if(0>e)throw Error(`Decorator "${t}" is not applied to ${this.attr}`);this.decorators.splice(e,1)}return this.parent}required(e){const t=xt.asMeta(e),r="string"==typeof e?e:xt.resolveMessage(t);return this.decorate(me(r))}min(e,t){const r=xt.asMeta(e),s=r?.[f.MIN]??(r?void 0:e);if(void 0===s)throw Error(`Missing ${f.MIN} for ${this.attr+""}`);return this.decorate(Ee(s,xt.resolveMessage(r,t)))}max(e,t){const r=xt.asMeta(e),s=r?.[f.MAX]??(r?void 0:e);if(void 0===s)throw Error(`Missing ${f.MAX} for ${this.attr+""}`);return this.decorate(be(s,xt.resolveMessage(r,t)))}step(e,t){const r=xt.asMeta(e),s=r?.[f.STEP]??(r?void 0:e);if(void 0===s)throw Error(`Missing ${f.STEP} for ${this.attr+""}`);return this.decorate(Ae(s,xt.resolveMessage(r,t)))}minlength(e,t){const r=xt.asMeta(e),s=r?.[f.MIN_LENGTH]??(r?void 0:e);if(void 0===s)throw Error(`Missing ${f.MIN_LENGTH} for ${this.attr+""}`);return this.decorate(Te(s,xt.resolveMessage(r,t)))}maxlength(e,t){const r=xt.asMeta(e),s=r?.[f.MAX_LENGTH]??(r?void 0:e);if(void 0===s)throw Error(`Missing ${f.MAX_LENGTH} for ${this.attr+""}`);return this.decorate(Ne(s,xt.resolveMessage(r,t)))}pattern(e,t){const r=xt.asMeta(e),s=r?.[f.PATTERN]??(r?void 0:e),n=xt.patternFromString(s)??/.*/;return this.decorate(Me(n,xt.resolveMessage(r,t)))}email(e){const t=xt.asMeta(e),r="string"==typeof e?e:xt.resolveMessage(t);return this.decorate(Se(r))}url(e){const t=xt.asMeta(e),r="string"==typeof e?e:xt.resolveMessage(t);return this.decorate(Oe(r))}type(e,t){const r=xt.asMeta(e),s=r?.customTypes??r?.type??(r?void 0:e);return this.decorate(Re(s,xt.resolveMessage(r,t)))}date(e,t){const r=xt.asMeta(e),s=r?.[f.FORMAT]??(r?void 0:e);return this.decorate(ve(s,xt.resolveMessage(r,t)))}password(e,t){const r=xt.asMeta(e),s=r?.[f.PATTERN]??(r?void 0:e),n=xt.patternFromString(s);return this.decorate(_e(n,xt.resolveMessage(r,t)))}list(e,t,r){const s=xt.asMeta(e),n=s?.clazz??(s?void 0:e),i=s?.type??t;return this.decorate(Pe(n,i,xt.resolveMessage(s,r)))}set(e,t){return xt.isMetadataPayload(e)?this.list(e):this.list(e,"Set",t)}enum(e,t){const r=xt.asMeta(e),s=r?.[f.ENUM]??(r?void 0:e);return this.decorate(xe(s,xt.resolveMessage(r,t)))}option(e,t){return this.enum(e,t)}static isMetadataPayload(e){return!(!e||e instanceof Date||e instanceof RegExp||Array.isArray(e)||"object"!=typeof e)}static asMeta(e){return xt.isMetadataPayload(e)?e:void 0}static resolveMessage(e,t){return e?.message??t}static patternFromString(e){if(!e)return;if(e instanceof RegExp)return e;const t=e.match(/^\/(.+)\/([gimsuy]*)$/);return t?RegExp(t[1],t[2]):RegExp(e)}resolveComparison(e,t,r){const s=xt.asMeta(e);return s?{target:s[t],options:{label:s.label,message:s.message}}:{target:e,options:r}}equals(e,t){const{target:r,options:s}=this.resolveComparison(e,f.EQUALS,t);return this.decorate(Le(r,s))}eq(e,t){return this.equals(e,t)}different(e,t){const{target:r,options:s}=this.resolveComparison(e,f.DIFF,t);return this.decorate(De(r,s))}diff(e,t){return this.different(e,t)}lessThan(e,t){const{target:r,options:s}=this.resolveComparison(e,f.LESS_THAN,t);return this.decorate(Ie(r,s))}lt(e,t){return this.lessThan(e,t)}lessThanOrEqual(e,t){const{target:r,options:s}=this.resolveComparison(e,f.LESS_THAN_OR_EQUAL,t);return this.decorate(He(r,s))}lte(e,t){return this.lessThanOrEqual(e,t)}greaterThan(e,t){const{target:r,options:s}=this.resolveComparison(e,f.GREATER_THAN,t);return this.decorate(je(r,s))}gt(e,t){return this.greaterThan(e,t)}greaterThanOrEqual(e,t){const{target:r,options:s}=this.resolveComparison(e,f.GREATER_THAN_OR_EQUAL,t);return this.decorate(Ue(r,s))}gte(e,t){return this.greaterThanOrEqual(e,t)}description(e){return this.decorate(i(e))}build(e){const t=e.prototype,r=this.attr;Object.getOwnPropertyDescriptor(t,r)||Object.defineProperty(t,r,{configurable:!0,enumerable:!0,writable:!0,value:void 0}),this.declaredType&&Reflect.defineMetadata(o.DESIGN_TYPE,this.declaredType,t,r),a()(t,r),this.decorators.forEach(e=>{try{e(t,r)}catch(e){throw Error(`Failed to apply decorator to property "${this.attr}": ${e}`)}})}}class Ct{constructor(e,t,r){this.parent=e,this.attribute=t,this.collection=r}ofPrimitives(e,t){return this.attribute.list(e,this.collection,t),this.parent}ofModel(){const e=zt.builder(),t=e.build;let r;return this.attribute.list(()=>(r||(r=Reflect.apply(t,e,[])),r),this.collection),e.build=new Proxy(t,{apply:(e,t,s)=>(r=Reflect.apply(e,t,s),this.parent)}),e}}class zt extends l{constructor(){super(...arguments),this.attributes=new Map,this._classDecorators=[]}setName(e){return this._name=e,this}description(e){return this._description=e,this}decorateClass(e){return this._classDecorators.push(e),this}attribute(e,t){const r=this.attributes.get(e);if(r){if(r.declaredType!==t)throw Error(`Attribute "${e+""}" already exists with a different type`);return r}const s=new xt(this,e,t);return this.attributes.set(e,s),s}string(e){return this.attribute(e,String)}number(e){return this.attribute(e,Number)}date(e){return this.attribute(e,Date)}bigint(e){return this.attribute(e,BigInt)}instance(e,t){return this.attribute(t,e)}model(e){const t=new zt;return t.build=new Proxy(t.build,{apply:(t,r,s)=>{const n=Reflect.apply(t,r,s);return this.instance(n,e)}}),t}listOf(e,t="Array"){const r="Set"===t?Set:Array,s=this.attribute(e,r);return new Ct(this,s,t)}build(){if(!this._name)throw Error("name is required");const e=this._parent??ut;class t extends e{constructor(e){super(e)}}Object.defineProperty(t,"name",{value:this._name,writable:!1});for(const e of this.attributes.values())e.build(t);let r=Ht()(t);for(const e of this._classDecorators){const t=e(r);t&&(r=t)}return this._description&&(r=i(this._description)(r)),r}static builder(){return new zt}static from(e,t){if(!e)throw Error("metadata is required");const r=zt.builder(),s=t??"GeneratedModel"+Date.now();r.setName(s);const n=e.properties||{},i=e.validation||{};for(const[e,t]of Object.entries(n)){const s=r.attribute(e,t||Object),n=i[e];if(n)for(const[e,t]of Object.entries(n)){const r=s[e];if("function"!=typeof r)try{const r=C.decoratorFromKey(e),n="function"==typeof r?r(t):r;s.decorate(n)}catch{}else r.call(s,t)}}return r.build()}}const Ft="##VERSION##",Yt="##COMMIT##",$t="##FULL_VERSION##",Gt="##PACKAGE##";e.registerLibrary(Gt,Ft);export{T as ASYNC_META_KEY,I as AsyncValidator,xt as AttributeBuilder,Yt as COMMIT,b as COMPARISON_ERROR_MESSAGES,d as ComparisonValidationKeys,h as DAYS_OF_WEEK_NAMES,p as DEFAULT_ERROR_MESSAGES,y as DEFAULT_PATTERNS,ft as DateBuilder,F as DateValidator,gt as Dates,mt as DaysAgo,at as DefaultHashingMethod,x as DefaultSerializationMethod,$ as DiffValidator,V as EmailValidator,k as EqualsValidator,$t as FULL_VERSION,B as GreaterThanOrEqualValidator,q as GreaterThanValidator,ct as Hashing,Mt as HoursAgo,Pt as JSONSerializer,K as LessThanOrEqualValidator,X as LessThanValidator,W as ListValidator,g as MONTH_NAMES,Z as MaxLengthValidator,J as MaxValidator,ee as MinLengthValidator,te as MinValidator,Ot as MinutesAgo,ut as Model,zt as ModelBuilder,ze as ModelErrorDefinition,U as ModelKeys,Xe as ModelRegistryManager,Tt as MonthsAgo,Et as NextDays,St as NextHours,Rt as NextMinutes,Nt as NextMonths,_t as NextSeconds,At as NextYears,ht as Now,re as OptionValidator,Gt as PACKAGE_NAME,se as PasswordValidator,$e as PathProxyEngine,Q as PatternValidator,Qe as Primitives,ne as RequiredValidator,Ve as ReservedModels,vt as SecondsAgo,Ce as Serialization,ie as StepValidator,pt as Tomorrow,oe as TypeValidator,ae as URLValidator,A as VALIDATION_PARENT_KEY,Ft as VERSION,C as Validation,f as ValidationKeys,H as Validator,j as ValidatorRegistry,bt as YearsAgo,yt as Yesterday,ye as async,ue as bindDateToString,Dt as bindModelPrototype,Ke as bulkModelRegister,v as checkType,_ as checkTypes,wt as construct,ve as date,ce as dateFromFormat,De as diff,Se as email,Le as eq,w as evaluateDesignTypes,Lt as findLastProtoBeforeObject,fe as formatDate,tt as getChildNestedPropsToIgnore,je as gt,Ue as gte,it as hashCode,ot as hashObj,jt as hashedBy,pe as innerValidationDecorator,Y as isEqual,R as isGreaterThan,O as isLessThan,le as isValidDate,S as isValidForGteOrLteComparison,ke as jsTypes,Pe as list,Ie as lt,He as lte,P as matchesAcceptedType,be as max,Ne as maxlength,Ee as min,Te as minlength,Ht as model,It as modelBaseDecorator,dt as offsetDate,xe as option,ge as parseDate,_e as password,Me as pattern,G as regexpParser,me as required,Ut as serializedBy,we as set,E as sf,Ae as step,m as stringFormat,Ge as toConditionalPromise,de as twoDigitPad,Re as type,Oe as url,nt as validate,et as validateChildValue,rt as validateDecorator,st as validateDecorators,he as validationMetadata,z as validator,L as valueLength};
|
|
2
2
|
//# sourceMappingURL=decorator-validation.js.map
|