@aidc-toolkit/utility 0.9.14-beta → 0.9.16-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/character-set.d.ts +301 -0
  2. package/dist/character-set.d.ts.map +1 -0
  3. package/dist/character-set.js +559 -0
  4. package/dist/character-set.js.map +1 -0
  5. package/dist/index.d.ts +24 -909
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +7 -1
  8. package/dist/index.js.map +1 -0
  9. package/dist/locale/en/locale-strings.d.ts +33 -0
  10. package/dist/locale/en/locale-strings.d.ts.map +1 -0
  11. package/dist/locale/en/locale-strings.js +33 -0
  12. package/dist/locale/en/locale-strings.js.map +1 -0
  13. package/dist/locale/fr/locale-strings.d.ts +33 -0
  14. package/dist/locale/fr/locale-strings.d.ts.map +1 -0
  15. package/dist/locale/fr/locale-strings.js +33 -0
  16. package/dist/locale/fr/locale-strings.js.map +1 -0
  17. package/dist/locale/i18n.d.ts +27 -0
  18. package/dist/locale/i18n.d.ts.map +1 -0
  19. package/dist/locale/i18n.js +35 -0
  20. package/dist/locale/i18n.js.map +1 -0
  21. package/dist/record.d.ts +41 -0
  22. package/dist/record.d.ts.map +1 -0
  23. package/dist/record.js +55 -0
  24. package/dist/record.js.map +1 -0
  25. package/dist/reg-exp.d.ts +43 -0
  26. package/dist/reg-exp.d.ts.map +1 -0
  27. package/dist/reg-exp.js +55 -0
  28. package/dist/reg-exp.js.map +1 -0
  29. package/dist/sequence.d.ts +68 -0
  30. package/dist/sequence.d.ts.map +1 -0
  31. package/dist/sequence.js +96 -0
  32. package/dist/sequence.js.map +1 -0
  33. package/dist/string.d.ts +22 -0
  34. package/dist/string.d.ts.map +1 -0
  35. package/dist/string.js +2 -0
  36. package/dist/string.js.map +1 -0
  37. package/dist/transformer.d.ts +377 -0
  38. package/dist/transformer.d.ts.map +1 -0
  39. package/dist/transformer.js +483 -0
  40. package/dist/transformer.js.map +1 -0
  41. package/package.json +8 -8
  42. package/dist/index.cjs +0 -17
  43. package/dist/index.d.cts +0 -909
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,mBAAmB,aAAa,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import{i18nAssertValidResources as v,i18nCoreInit as w}from"@aidc-toolkit/core";import A from"i18next";var E={Transformer:{domainMustBeGreaterThanZero:"Domain {{domain}} must be greater than 0",tweakMustBeGreaterThanOrEqualToZero:"Tweak {{tweak}} must be greater than or equal to 0",valueMustBeGreaterThanOrEqualToZero:"Value {{value}} must be greater than or equal to 0",valueMustBeLessThan:"Value {{value}} must be less than {{domain}}",minimumValueMustBeGreaterThanOrEqualToZero:"Minimum value {{minimumValue}} must be greater than or equal to 0",maximumValueMustBeLessThan:"Maximum value {{maximumValue}} must be less than {{domain}}"},RegExpValidator:{stringDoesNotMatchPattern:"String {{s}} does not match pattern"},CharacterSetValidator:{firstZeroFirstCharacter:"Character set must support zero as first character",allNumericAllNumericCharacters:"Character set must support all numeric characters in sequence",stringMustNotBeAllNumeric:"String must not be all numeric",lengthMustBeGreaterThanOrEqualTo:"Length {{length}} must be greater than or equal to {{minimumLength}}",lengthMustBeLessThanOrEqualTo:"Length {{length}} must be less than or equal to {{maximumLength}}",lengthMustBeEqualTo:"Length {{length}} must be equal to {{exactLength}}",lengthOfComponentMustBeGreaterThanOrEqualTo:"Length {{length}} of {{component}} must be greater than or equal to {{minimumLength}}",lengthOfComponentMustBeLessThanOrEqualTo:"Length {{length}} of {{component}} must be less than or equal to {{maximumLength}}",lengthOfComponentMustBeEqualTo:"Length {{length}} of {{component}} must be equal to {{exactLength}}",invalidCharacterAtPosition:"Invalid character '{{c}}' at position {{position}}",invalidCharacterAtPositionOfComponent:"Invalid character '{{c}}' at position {{position}} of {{component}}",exclusionNotSupported:"Exclusion value of {{exclusion}} is not supported",invalidTweakWithAllNumericExclusion:"Tweak must not be used with all-numeric exclusion",endSequenceValueMustBeLessThanOrEqualTo:"End sequence value (start sequence value + count - 1) must be less than {{domain}}"},RecordValidator:{typeNameKeyNotFound:'{{typeName}} "{{key}}" not found'}};var S={Transformer:{domainMustBeGreaterThanZero:"Le domaine {{domain}} doit \xEAtre sup\xE9rieur \xE0 0",tweakMustBeGreaterThanOrEqualToZero:"Le r\xE9glage {{tweak}} doit \xEAtre sup\xE9rieur ou \xE9gal \xE0 0",valueMustBeGreaterThanOrEqualToZero:"La valeur {{value}} doit \xEAtre sup\xE9rieure ou \xE9gale \xE0 0",valueMustBeLessThan:"La valeur {{value}} doit \xEAtre inf\xE9rieure \xE0 {{domain}}",minimumValueMustBeGreaterThanOrEqualToZero:"La valeur minimale {{minimumValue}} doit \xEAtre sup\xE9rieure ou \xE9gale \xE0 0",maximumValueMustBeLessThan:"La valeur maximale {{maximumValue}} doit \xEAtre inf\xE9rieure \xE0 {{domain}}"},RegExpValidator:{stringDoesNotMatchPattern:"La cha\xEEne {{s}} ne correspond pas au mod\xE8le"},CharacterSetValidator:{firstZeroFirstCharacter:"Le jeu de caract\xE8res doit prendre en charge z\xE9ro comme premier caract\xE8re",allNumericAllNumericCharacters:"Le jeu de caract\xE8res doit prendre en charge tous les caract\xE8res num\xE9riques en s\xE9quence",stringMustNotBeAllNumeric:"La cha\xEEne ne doit pas \xEAtre enti\xE8rement num\xE9rique",lengthMustBeGreaterThanOrEqualTo:"La longueur {{length}} doit \xEAtre sup\xE9rieure ou \xE9gale \xE0 {{minimumLength}}",lengthMustBeLessThanOrEqualTo:"La longueur {{length}} doit \xEAtre inf\xE9rieure ou \xE9gale \xE0 {{maximumLength}}",lengthMustBeEqualTo:"La longueur {{length}} doit \xEAtre \xE9gale \xE0 {{exactLength}}",lengthOfComponentMustBeGreaterThanOrEqualTo:"La longueur {{length}} de {{component}} doit \xEAtre sup\xE9rieure ou \xE9gale \xE0 {{minimumLength}}",lengthOfComponentMustBeLessThanOrEqualTo:"La longueur {{length}} de {{component}} doit \xEAtre inf\xE9rieure ou \xE9gale \xE0 {{maximumLength}}",lengthOfComponentMustBeEqualTo:"La longueur {{length}} de {{component}} doit \xEAtre \xE9gale \xE0 {{exactLength}}",invalidCharacterAtPosition:"Caract\xE8re non valide '{{c}}' \xE0 la position {{position}}",invalidCharacterAtPositionOfComponent:"Caract\xE8re non valide '{{c}}' \xE0 la position {{position}} de {{component}}",exclusionNotSupported:"La valeur d'exclusion de {{exclusion}} n'est pas prise en charge",invalidTweakWithAllNumericExclusion:"Le r\xE9glage ne doit pas \xEAtre utilis\xE9 avec une exclusion enti\xE8rement num\xE9rique",endSequenceValueMustBeLessThanOrEqualTo:"La valeur de la s\xE9quence de fin (valeur de la s\xE9quence de d\xE9but + nombre - 1) doit \xEAtre inf\xE9rieure \xE0 {{domaine}}"},RecordValidator:{typeNameKeyNotFound:'{{typeName}} "{{key}}" introuvable'}};var B="aidct_utility";v(E,"fr",S);var V={en:{aidct_utility:E},fr:{aidct_utility:S}},u=A.createInstance();async function F(i,e=!1){await w(u,i,e,B,V)}var T=class{_startValue;_endValue;_count;_nextDelta;_minimumValue;_maximumValue;constructor(e,t){this._startValue=BigInt(e),this._endValue=this._startValue+BigInt(t),this._count=t,t>=0?(this._nextDelta=1n,this._minimumValue=this._startValue,this._maximumValue=this._endValue-1n):(this._nextDelta=-1n,this._minimumValue=this._endValue+1n,this._maximumValue=this._startValue)}get startValue(){return this._startValue}get endValue(){return this._endValue}get count(){return this._count}get minimumValue(){return this._minimumValue}get maximumValue(){return this._maximumValue}*[Symbol.iterator](){for(let e=this._startValue;e!==this._endValue;e+=this._nextDelta)yield e}};function b(i,e){return{*[Symbol.iterator](){let t=0;for(let r of i)yield e(r,t++)}}}var g=class i{static TRANSFORMER_MAPS_MAP=new Map;_domain;constructor(e){if(this._domain=BigInt(e),this._domain<=0n)throw new RangeError(u.t("Transformer.domainMustBeGreaterThanZero",{domain:e}))}static get(e,t){let r=BigInt(e),n=i.TRANSFORMER_MAPS_MAP.get(r);n===void 0&&(n=new Map,i.TRANSFORMER_MAPS_MAP.set(r,n));let a=t===void 0?void 0:BigInt(t),o=n.get(a);return o===void 0&&(o=a===void 0?new N(r):new M(r,a),n.set(a,o)),o}get domain(){return this._domain}validate(e){if(e<0n)throw new RangeError(u.t("Transformer.valueMustBeGreaterThanOrEqualToZero",{value:e}));if(e>=this.domain)throw new RangeError(u.t("Transformer.valueMustBeLessThan",{value:e,domain:this.domain}))}validateDoForward(e){let t=BigInt(e);return this.validate(t),this.doForward(t)}validateDoForwardCallback(e,t,r){return e(this.validateDoForward(t),r)}forward(e,t){let r;if(typeof e!="object")r=t===void 0?this.validateDoForward(e):this.validateDoForwardCallback(t,e,0);else if(e instanceof T){if(e.minimumValue<0n)throw new RangeError(u.t("Transformer.minimumValueMustBeGreaterThanOrEqualToZero",{minimumValue:e.minimumValue}));if(e.maximumValue>=this.domain)throw new RangeError(u.t("Transformer.maximumValueMustBeLessThan",{maximumValue:e.maximumValue,domain:this.domain}));r=t===void 0?b(e,n=>this.doForward(n)):b(e,(n,a)=>t(this.doForward(n),a))}else r=t===void 0?b(e,n=>this.validateDoForward(n)):b(e,(n,a)=>this.validateDoForwardCallback(t,n,a));return r}reverse(e){let t=BigInt(e);return this.validate(t),this.doReverse(t)}},N=class extends g{doForward(e){return e}doReverse(e){return e}},M=class i extends g{static BITS=new Uint8Array([1,2,4,8,16,32,64,128]);static INVERSE_BITS=new Uint8Array([254,253,251,247,239,223,191,127]);_domainBytes;_xorBytes;_bits;_inverseBits;_rounds;constructor(e,t){if(super(e),t<0n)throw new RangeError(u.t("Transformer.tweakMustBeGreaterThanOrEqualToZero",{tweak:t}));let r=0;for(let s=this.domain-1n;s!==0n;s>>=8n)r++;this._domainBytes=r;let n=new Array,a=new Array,o=new Array;for(let s=this.domain*BigInt(t)*603868999n;s!==0n;s>>=8n){n.unshift(Number(BigInt.asUintN(8,s)));let l=Number(BigInt.asUintN(3,s));a.push(i.BITS[l]),o.push(i.INVERSE_BITS[l])}if(r===1){let s=i.BITS.filter(l=>l<e).reduce((l,h)=>l|h,0);this._xorBytes=new Uint8Array([n.reduce((l,h)=>l^h,0)&s]),this._bits=new Uint8Array([i.BITS[0]]),this._inverseBits=new Uint8Array([i.INVERSE_BITS[0]]),this._rounds=1}else this._xorBytes=new Uint8Array(n),this._bits=new Uint8Array(a),this._inverseBits=new Uint8Array(o),this._rounds=n.length}valueToBytes(e){let t=new Uint8Array(this._domainBytes);for(let r=this._domainBytes-1,n=e;r>=0&&n!==0n;r--,n>>=8n)t[r]=Number(BigInt.asUintN(8,n));return t}static bytesToValue(e){return e.reduce((t,r)=>t<<8n|BigInt(r),0n)}shuffle(e,t,r){let n=e.length,a=new Uint8Array(n),o=new Array,s=new Array,l=this._bits[t];e.forEach((m,c)=>{let p=m&l;a[c]=p,(p!==0?o:s).push(c)});let h=this._inverseBits[t],d=new Uint8Array(n);return[...o,...s].forEach((m,c)=>{r?d[c]=e[m]&h|a[c]:d[m]=e[c]&h|a[m]}),d}xor(e,t,r){let n=this._xorBytes[t];return e.map(a=>{let o=a^n;return n=r?o:a,o})}doForward(e){let t=this.valueToBytes(e),r;do{for(let n=0;n<this._rounds;n++)t=this.xor(this.shuffle(t,n,!0),n,!0);r=i.bytesToValue(t)}while(r>=this.domain);return r}doReverse(e){let t=this.valueToBytes(e),r;do{for(let n=this._rounds-1;n>=0;n--)t=this.shuffle(this.xor(t,n,!1),n,!1);r=i.bytesToValue(t)}while(r>=this.domain);return r}};var x=class{_regExp;constructor(e){this._regExp=e}get regExp(){return this._regExp}createErrorMessage(e){return u.t("RegExpValidator.stringDoesNotMatchPattern",{s:e})}validate(e){if(!this._regExp.test(e))throw new RangeError(this.createErrorMessage(e))}};var _=class{_typeName;_record;constructor(e,t){this._typeName=e,this._record=t}get typeName(){return this._typeName}get record(){return this._record}validate(e){if(!(e in this.record))throw new RangeError(u.t("RecordValidator.typeNameKeyNotFound",{typeName:this.typeName,key:e}))}};var O=(r=>(r[r.None=0]="None",r[r.FirstZero=1]="FirstZero",r[r.AllNumeric=2]="AllNumeric",r))(O||{}),I=class i{static NOT_ALL_NUMERIC_VALIDATOR=new class extends x{createErrorMessage(e){return u.t("CharacterSetValidator.stringMustNotBeAllNumeric")}}(/\D/);_characterSet;_characterSetMap;_exclusionSupport;constructor(e,...t){this._characterSet=e;let r=new Map;e.forEach((n,a)=>{r.set(n,a)}),this._characterSetMap=r,this._exclusionSupport=t}get characterSet(){return this._characterSet}get characterSetSize(){return this._characterSet.length}get exclusionSupport(){return this._exclusionSupport}character(e){return this._characterSet[e]}characterIndex(e){return this._characterSetMap.get(e)}characterIndexes(e){return Array.from(e).map(t=>this._characterSetMap.get(t))}static componentToString(e){return typeof e=="function"?e():e}validateExclusion(e){if(e!==0&&!this._exclusionSupport.includes(e))throw new RangeError(u.t("CharacterSetValidator.exclusionNotSupported",{exclusion:e}))}validate(e,t){let r=e.length,n=t?.minimumLength,a=t?.maximumLength;if(n!==void 0&&r<n){let s;throw a!==void 0&&a===n?s=u.t(t?.component===void 0?"CharacterSetValidator.lengthMustBeEqualTo":"CharacterSetValidator.lengthOfComponentMustBeEqualTo",{component:i.componentToString(t?.component),length:r,exactLength:n}):s=u.t(t?.component===void 0?"CharacterSetValidator.lengthMustBeGreaterThanOrEqualTo":"CharacterSetValidator.lengthOfComponentMustBeGreaterThanOrEqualTo",{component:i.componentToString(t?.component),length:r,minimumLength:n}),new RangeError(s)}if(a!==void 0&&r>a)throw new RangeError(u.t(t?.component===void 0?"CharacterSetValidator.lengthMustBeLessThanOrEqualTo":"CharacterSetValidator.lengthOfComponentMustBeLessThanOrEqualTo",{component:i.componentToString(t?.component),length:r,maximumLength:a}));let o=this.characterIndexes(e).findIndex(s=>s===void 0);if(o!==-1)throw new RangeError(u.t(t?.component===void 0?"CharacterSetValidator.invalidCharacterAtPosition":"CharacterSetValidator.invalidCharacterAtPositionOfComponent",{component:i.componentToString(t?.component),c:e.charAt(o),position:o+(t?.positionOffset??0)+1}));if(t?.exclusion!==void 0)switch(this.validateExclusion(t.exclusion),t.exclusion){case 0:break;case 1:if(e.startsWith("0"))throw new RangeError(u.t(t.component===void 0?"CharacterSetValidator.invalidCharacterAtPosition":"CharacterSetValidator.invalidCharacterAtPositionOfComponent",{component:i.componentToString(t.component),c:"0",position:(t.positionOffset??0)+1}));break;case 2:i.NOT_ALL_NUMERIC_VALIDATOR.validate(e);break}}},f=class i extends I{static MAXIMUM_STRING_LENGTH=40;static _powersOf10=i.createPowersOf(10);static createPowersOf(e){let t=new Array(this.MAXIMUM_STRING_LENGTH+1),r=BigInt(e);for(let n=0,a=1n;n<=this.MAXIMUM_STRING_LENGTH;n++,a*=r)t[n]=a;return t}static powerOf10(e){return this._powersOf10[e]}_characterSetSizeN;_characterSetSizeMinusOneN;_exclusionDomains;_allZerosValues;constructor(e,...t){super(e,...t),this._characterSetSizeN=BigInt(this.characterSetSize),this._characterSetSizeMinusOneN=BigInt(this.characterSetSize-1);let r=[],n=i.createPowersOf(this.characterSetSize);if(r[0]=n,t.includes(1)){if(e[0]!=="0")throw new RangeError(u.t("CharacterSetValidator.firstZeroFirstCharacter"));let o=new Array(i.MAXIMUM_STRING_LENGTH+1);o[0]=0n;for(let s=1;s<=i.MAXIMUM_STRING_LENGTH;s++)o[s]=this._characterSetSizeMinusOneN*n[s-1];r[1]=o}if(t.includes(2)){let s=function(c){let p=c[0];for(let y of c){if(y===void 0||y!==p)throw new RangeError(u.t("CharacterSetValidator.allNumericAllNumericCharacters"));p=y+1}};var a=s;let o=new Array(i.MAXIMUM_STRING_LENGTH+1),l=this.characterIndexes("0123456789");s(l);let h=BigInt(l[0]),d=new Array(i.MAXIMUM_STRING_LENGTH+1),m=0n;for(let c=0;c<=i.MAXIMUM_STRING_LENGTH;c++)o[c]=n[c]-i.powerOf10(c),d[c]=m,m=m*this._characterSetSizeN+h;this._allZerosValues=d,r[2]=o}else this._allZerosValues=[];this._exclusionDomains=r}powerOfSize(e){return this._exclusionDomains[0][e]}allNumericShift(e,t,r){let n;if(t===0){if(!e&&r<10n)throw new RangeError(u.t("CharacterSetValidator.stringMustNotBeAllNumeric"));n=10n}else{let a=this.powerOfSize(t),o=i.powerOf10(t),s=e?a-o:a,l=r/s;l>=10n?n=i.powerOf10(t+1):n=l*o+this.allNumericShift(e,t-1,r-l*s)}return n}validateLength(e){if(e<0)throw new RangeError(u.t("CharacterSetValidator.lengthMustBeGreaterThanOrEqualTo",{length:e,minimumLength:0}));if(e>i.MAXIMUM_STRING_LENGTH)throw new RangeError(u.t("CharacterSetValidator.lengthMustBeLessThanOrEqualTo",{length:e,maximumLength:i.MAXIMUM_STRING_LENGTH}))}create(e,t,r=0,n,a){this.validateLength(e),this.validateExclusion(r);let o=r===2?this._allZerosValues[e]:0n;return g.get(this._exclusionDomains[r][e],n).forward(t,(l,h)=>{let d="";if(e!==0){let m=l;r===2&&m>=o&&(m=m+this.allNumericShift(!0,e,m-o));for(let c=e-1;c>0;c--){let p=m/this._characterSetSizeN;d=this.character(Number(m-p*this._characterSetSizeN))+d,m=p}d=this.character(r===1?Number(m%this._characterSetSizeMinusOneN)+1:Number(m%this._characterSetSizeN))+d}return a===void 0?d:a(d,h)})}valueFor(e,t=0,r){let n=e.length;this.validateLength(n),this.validateExclusion(t);let a=BigInt(this.characterSetSize),o=this.characterIndexes(e).reduce((s,l,h)=>{if(l===void 0)throw new RangeError(u.t("CharacterSetValidator.invalidCharacterAtPosition",{c:e.charAt(h),position:h+1}));let d;if(h===0&&t===1){if(l===0)throw new RangeError(u.t("CharacterSetValidator.invalidCharacterAtPosition",{c:"0",position:1}));d=BigInt(l-1)}else d=s*a+BigInt(l);return d},0n);if(t===2){let s=this._allZerosValues[n];o>=s&&(o-=this.allNumericShift(!1,n,o-s))}return g.get(this._exclusionDomains[t][n],r).reverse(o)}},Y=new f(["0","1","2","3","4","5","6","7","8","9"],1),$=new f(["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"],1,2),ee=new f(["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]),te=new f(["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],1,2);export{ee as ALPHABETIC_CREATOR,te as ALPHANUMERIC_CREATOR,f as CharacterSetCreator,I as CharacterSetValidator,M as EncryptionTransformer,O as Exclusion,$ as HEXADECIMAL_CREATOR,N as IdentityTransformer,Y as NUMERIC_CREATOR,_ as RecordValidator,x as RegExpValidator,T as Sequence,g as Transformer,F as i18nUtilityInit,u as i18nextUtility,b as transformIterable,B as utilityNS,V as utilityResources};
2
1
  /*!
3
2
  * Copyright © 2024-2025 Dolphin Data Development Ltd. and AIDC Toolkit
4
3
  * contributors
@@ -15,3 +14,10 @@ import{i18nAssertValidResources as v,i18nCoreInit as w}from"@aidc-toolkit/core";
15
14
  * See the License for the specific language governing permissions and
16
15
  * limitations under the License.
17
16
  */
17
+ export * from "./locale/i18n.js";
18
+ export * from "./sequence.js";
19
+ export * from "./transformer.js";
20
+ export * from "./reg-exp.js";
21
+ export * from "./record.js";
22
+ export * from "./character-set.js";
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,33 @@
1
+ export declare const localeStrings: {
2
+ readonly Transformer: {
3
+ readonly domainMustBeGreaterThanZero: "Domain {{domain}} must be greater than 0";
4
+ readonly tweakMustBeGreaterThanOrEqualToZero: "Tweak {{tweak}} must be greater than or equal to 0";
5
+ readonly valueMustBeGreaterThanOrEqualToZero: "Value {{value}} must be greater than or equal to 0";
6
+ readonly valueMustBeLessThan: "Value {{value}} must be less than {{domain}}";
7
+ readonly minimumValueMustBeGreaterThanOrEqualToZero: "Minimum value {{minimumValue}} must be greater than or equal to 0";
8
+ readonly maximumValueMustBeLessThan: "Maximum value {{maximumValue}} must be less than {{domain}}";
9
+ };
10
+ readonly RegExpValidator: {
11
+ readonly stringDoesNotMatchPattern: "String {{s}} does not match pattern";
12
+ };
13
+ readonly CharacterSetValidator: {
14
+ readonly firstZeroFirstCharacter: "Character set must support zero as first character";
15
+ readonly allNumericAllNumericCharacters: "Character set must support all numeric characters in sequence";
16
+ readonly stringMustNotBeAllNumeric: "String must not be all numeric";
17
+ readonly lengthMustBeGreaterThanOrEqualTo: "Length {{length}} must be greater than or equal to {{minimumLength}}";
18
+ readonly lengthMustBeLessThanOrEqualTo: "Length {{length}} must be less than or equal to {{maximumLength}}";
19
+ readonly lengthMustBeEqualTo: "Length {{length}} must be equal to {{exactLength}}";
20
+ readonly lengthOfComponentMustBeGreaterThanOrEqualTo: "Length {{length}} of {{component}} must be greater than or equal to {{minimumLength}}";
21
+ readonly lengthOfComponentMustBeLessThanOrEqualTo: "Length {{length}} of {{component}} must be less than or equal to {{maximumLength}}";
22
+ readonly lengthOfComponentMustBeEqualTo: "Length {{length}} of {{component}} must be equal to {{exactLength}}";
23
+ readonly invalidCharacterAtPosition: "Invalid character '{{c}}' at position {{position}}";
24
+ readonly invalidCharacterAtPositionOfComponent: "Invalid character '{{c}}' at position {{position}} of {{component}}";
25
+ readonly exclusionNotSupported: "Exclusion value of {{exclusion}} is not supported";
26
+ readonly invalidTweakWithAllNumericExclusion: "Tweak must not be used with all-numeric exclusion";
27
+ readonly endSequenceValueMustBeLessThanOrEqualTo: "End sequence value (start sequence value + count - 1) must be less than {{domain}}";
28
+ };
29
+ readonly RecordValidator: {
30
+ readonly typeNameKeyNotFound: "{{typeName}} \"{{key}}\" not found";
31
+ };
32
+ };
33
+ //# sourceMappingURL=locale-strings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale-strings.d.ts","sourceRoot":"","sources":["../../../src/locale/en/locale-strings.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BhB,CAAC"}
@@ -0,0 +1,33 @@
1
+ export const localeStrings = {
2
+ Transformer: {
3
+ domainMustBeGreaterThanZero: "Domain {{domain}} must be greater than 0",
4
+ tweakMustBeGreaterThanOrEqualToZero: "Tweak {{tweak}} must be greater than or equal to 0",
5
+ valueMustBeGreaterThanOrEqualToZero: "Value {{value}} must be greater than or equal to 0",
6
+ valueMustBeLessThan: "Value {{value}} must be less than {{domain}}",
7
+ minimumValueMustBeGreaterThanOrEqualToZero: "Minimum value {{minimumValue}} must be greater than or equal to 0",
8
+ maximumValueMustBeLessThan: "Maximum value {{maximumValue}} must be less than {{domain}}"
9
+ },
10
+ RegExpValidator: {
11
+ stringDoesNotMatchPattern: "String {{s}} does not match pattern"
12
+ },
13
+ CharacterSetValidator: {
14
+ firstZeroFirstCharacter: "Character set must support zero as first character",
15
+ allNumericAllNumericCharacters: "Character set must support all numeric characters in sequence",
16
+ stringMustNotBeAllNumeric: "String must not be all numeric",
17
+ lengthMustBeGreaterThanOrEqualTo: "Length {{length}} must be greater than or equal to {{minimumLength}}",
18
+ lengthMustBeLessThanOrEqualTo: "Length {{length}} must be less than or equal to {{maximumLength}}",
19
+ lengthMustBeEqualTo: "Length {{length}} must be equal to {{exactLength}}",
20
+ lengthOfComponentMustBeGreaterThanOrEqualTo: "Length {{length}} of {{component}} must be greater than or equal to {{minimumLength}}",
21
+ lengthOfComponentMustBeLessThanOrEqualTo: "Length {{length}} of {{component}} must be less than or equal to {{maximumLength}}",
22
+ lengthOfComponentMustBeEqualTo: "Length {{length}} of {{component}} must be equal to {{exactLength}}",
23
+ invalidCharacterAtPosition: "Invalid character '{{c}}' at position {{position}}",
24
+ invalidCharacterAtPositionOfComponent: "Invalid character '{{c}}' at position {{position}} of {{component}}",
25
+ exclusionNotSupported: "Exclusion value of {{exclusion}} is not supported",
26
+ invalidTweakWithAllNumericExclusion: "Tweak must not be used with all-numeric exclusion",
27
+ endSequenceValueMustBeLessThanOrEqualTo: "End sequence value (start sequence value + count - 1) must be less than {{domain}}"
28
+ },
29
+ RecordValidator: {
30
+ typeNameKeyNotFound: "{{typeName}} \"{{key}}\" not found"
31
+ }
32
+ };
33
+ //# sourceMappingURL=locale-strings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale-strings.js","sourceRoot":"","sources":["../../../src/locale/en/locale-strings.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,WAAW,EAAE;QACT,2BAA2B,EAAE,0CAA0C;QACvE,mCAAmC,EAAE,oDAAoD;QACzF,mCAAmC,EAAE,oDAAoD;QACzF,mBAAmB,EAAE,8CAA8C;QACnE,0CAA0C,EAAE,mEAAmE;QAC/G,0BAA0B,EAAE,6DAA6D;KAC5F;IACD,eAAe,EAAE;QACb,yBAAyB,EAAE,qCAAqC;KACnE;IACD,qBAAqB,EAAE;QACnB,uBAAuB,EAAE,oDAAoD;QAC7E,8BAA8B,EAAE,+DAA+D;QAC/F,yBAAyB,EAAE,gCAAgC;QAC3D,gCAAgC,EAAE,sEAAsE;QACxG,6BAA6B,EAAE,mEAAmE;QAClG,mBAAmB,EAAE,oDAAoD;QACzE,2CAA2C,EAAE,uFAAuF;QACpI,wCAAwC,EAAE,oFAAoF;QAC9H,8BAA8B,EAAE,qEAAqE;QACrG,0BAA0B,EAAE,oDAAoD;QAChF,qCAAqC,EAAE,qEAAqE;QAC5G,qBAAqB,EAAE,mDAAmD;QAC1E,mCAAmC,EAAE,mDAAmD;QACxF,uCAAuC,EAAE,oFAAoF;KAChI;IACD,eAAe,EAAE;QACb,mBAAmB,EAAE,oCAAoC;KAC5D;CACK,CAAC"}
@@ -0,0 +1,33 @@
1
+ export declare const localeStrings: {
2
+ readonly Transformer: {
3
+ readonly domainMustBeGreaterThanZero: "Le domaine {{domain}} doit être supérieur à 0";
4
+ readonly tweakMustBeGreaterThanOrEqualToZero: "Le réglage {{tweak}} doit être supérieur ou égal à 0";
5
+ readonly valueMustBeGreaterThanOrEqualToZero: "La valeur {{value}} doit être supérieure ou égale à 0";
6
+ readonly valueMustBeLessThan: "La valeur {{value}} doit être inférieure à {{domain}}";
7
+ readonly minimumValueMustBeGreaterThanOrEqualToZero: "La valeur minimale {{minimumValue}} doit être supérieure ou égale à 0";
8
+ readonly maximumValueMustBeLessThan: "La valeur maximale {{maximumValue}} doit être inférieure à {{domain}}";
9
+ };
10
+ readonly RegExpValidator: {
11
+ readonly stringDoesNotMatchPattern: "La chaîne {{s}} ne correspond pas au modèle";
12
+ };
13
+ readonly CharacterSetValidator: {
14
+ readonly firstZeroFirstCharacter: "Le jeu de caractères doit prendre en charge zéro comme premier caractère";
15
+ readonly allNumericAllNumericCharacters: "Le jeu de caractères doit prendre en charge tous les caractères numériques en séquence";
16
+ readonly stringMustNotBeAllNumeric: "La chaîne ne doit pas être entièrement numérique";
17
+ readonly lengthMustBeGreaterThanOrEqualTo: "La longueur {{length}} doit être supérieure ou égale à {{minimumLength}}";
18
+ readonly lengthMustBeLessThanOrEqualTo: "La longueur {{length}} doit être inférieure ou égale à {{maximumLength}}";
19
+ readonly lengthMustBeEqualTo: "La longueur {{length}} doit être égale à {{exactLength}}";
20
+ readonly lengthOfComponentMustBeGreaterThanOrEqualTo: "La longueur {{length}} de {{component}} doit être supérieure ou égale à {{minimumLength}}";
21
+ readonly lengthOfComponentMustBeLessThanOrEqualTo: "La longueur {{length}} de {{component}} doit être inférieure ou égale à {{maximumLength}}";
22
+ readonly lengthOfComponentMustBeEqualTo: "La longueur {{length}} de {{component}} doit être égale à {{exactLength}}";
23
+ readonly invalidCharacterAtPosition: "Caractère non valide '{{c}}' à la position {{position}}";
24
+ readonly invalidCharacterAtPositionOfComponent: "Caractère non valide '{{c}}' à la position {{position}} de {{component}}";
25
+ readonly exclusionNotSupported: "La valeur d'exclusion de {{exclusion}} n'est pas prise en charge";
26
+ readonly invalidTweakWithAllNumericExclusion: "Le réglage ne doit pas être utilisé avec une exclusion entièrement numérique";
27
+ readonly endSequenceValueMustBeLessThanOrEqualTo: "La valeur de la séquence de fin (valeur de la séquence de début + nombre - 1) doit être inférieure à {{domaine}}";
28
+ };
29
+ readonly RecordValidator: {
30
+ readonly typeNameKeyNotFound: "{{typeName}} \"{{key}}\" introuvable";
31
+ };
32
+ };
33
+ //# sourceMappingURL=locale-strings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale-strings.d.ts","sourceRoot":"","sources":["../../../src/locale/fr/locale-strings.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BhB,CAAC"}
@@ -0,0 +1,33 @@
1
+ export const localeStrings = {
2
+ Transformer: {
3
+ domainMustBeGreaterThanZero: "Le domaine {{domain}} doit être supérieur à 0",
4
+ tweakMustBeGreaterThanOrEqualToZero: "Le réglage {{tweak}} doit être supérieur ou égal à 0",
5
+ valueMustBeGreaterThanOrEqualToZero: "La valeur {{value}} doit être supérieure ou égale à 0",
6
+ valueMustBeLessThan: "La valeur {{value}} doit être inférieure à {{domain}}",
7
+ minimumValueMustBeGreaterThanOrEqualToZero: "La valeur minimale {{minimumValue}} doit être supérieure ou égale à 0",
8
+ maximumValueMustBeLessThan: "La valeur maximale {{maximumValue}} doit être inférieure à {{domain}}"
9
+ },
10
+ RegExpValidator: {
11
+ stringDoesNotMatchPattern: "La chaîne {{s}} ne correspond pas au modèle"
12
+ },
13
+ CharacterSetValidator: {
14
+ firstZeroFirstCharacter: "Le jeu de caractères doit prendre en charge zéro comme premier caractère",
15
+ allNumericAllNumericCharacters: "Le jeu de caractères doit prendre en charge tous les caractères numériques en séquence",
16
+ stringMustNotBeAllNumeric: "La chaîne ne doit pas être entièrement numérique",
17
+ lengthMustBeGreaterThanOrEqualTo: "La longueur {{length}} doit être supérieure ou égale à {{minimumLength}}",
18
+ lengthMustBeLessThanOrEqualTo: "La longueur {{length}} doit être inférieure ou égale à {{maximumLength}}",
19
+ lengthMustBeEqualTo: "La longueur {{length}} doit être égale à {{exactLength}}",
20
+ lengthOfComponentMustBeGreaterThanOrEqualTo: "La longueur {{length}} de {{component}} doit être supérieure ou égale à {{minimumLength}}",
21
+ lengthOfComponentMustBeLessThanOrEqualTo: "La longueur {{length}} de {{component}} doit être inférieure ou égale à {{maximumLength}}",
22
+ lengthOfComponentMustBeEqualTo: "La longueur {{length}} de {{component}} doit être égale à {{exactLength}}",
23
+ invalidCharacterAtPosition: "Caractère non valide '{{c}}' à la position {{position}}",
24
+ invalidCharacterAtPositionOfComponent: "Caractère non valide '{{c}}' à la position {{position}} de {{component}}",
25
+ exclusionNotSupported: "La valeur d'exclusion de {{exclusion}} n'est pas prise en charge",
26
+ invalidTweakWithAllNumericExclusion: "Le réglage ne doit pas être utilisé avec une exclusion entièrement numérique",
27
+ endSequenceValueMustBeLessThanOrEqualTo: "La valeur de la séquence de fin (valeur de la séquence de début + nombre - 1) doit être inférieure à {{domaine}}"
28
+ },
29
+ RecordValidator: {
30
+ typeNameKeyNotFound: "{{typeName}} \"{{key}}\" introuvable"
31
+ }
32
+ };
33
+ //# sourceMappingURL=locale-strings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale-strings.js","sourceRoot":"","sources":["../../../src/locale/fr/locale-strings.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,WAAW,EAAE;QACT,2BAA2B,EAAE,+CAA+C;QAC5E,mCAAmC,EAAE,sDAAsD;QAC3F,mCAAmC,EAAE,uDAAuD;QAC5F,mBAAmB,EAAE,uDAAuD;QAC5E,0CAA0C,EAAE,uEAAuE;QACnH,0BAA0B,EAAE,uEAAuE;KACtG;IACD,eAAe,EAAE;QACb,yBAAyB,EAAE,6CAA6C;KAC3E;IACD,qBAAqB,EAAE;QACnB,uBAAuB,EAAE,0EAA0E;QACnG,8BAA8B,EAAE,wFAAwF;QACxH,yBAAyB,EAAE,kDAAkD;QAC7E,gCAAgC,EAAE,0EAA0E;QAC5G,6BAA6B,EAAE,0EAA0E;QACzG,mBAAmB,EAAE,0DAA0D;QAC/E,2CAA2C,EAAE,2FAA2F;QACxI,wCAAwC,EAAE,2FAA2F;QACrI,8BAA8B,EAAE,2EAA2E;QAC3G,0BAA0B,EAAE,yDAAyD;QACrF,qCAAqC,EAAE,0EAA0E;QACjH,qBAAqB,EAAE,kEAAkE;QACzF,mCAAmC,EAAE,8EAA8E;QACnH,uCAAuC,EAAE,kHAAkH;KAC9J;IACD,eAAe,EAAE;QACb,mBAAmB,EAAE,sCAAsC;KAC9D;CACK,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { type I18NEnvironment } from "@aidc-toolkit/core";
2
+ import { type i18n, type Resource } from "i18next";
3
+ import { localeStrings as enLocaleStrings } from "./en/locale-strings.js";
4
+ export declare const utilityNS = "aidct_utility";
5
+ /**
6
+ * Locale strings type is extracted from the English locale strings object.
7
+ */
8
+ export type UtilityLocaleStrings = typeof enLocaleStrings;
9
+ /**
10
+ * Utility resources.
11
+ */
12
+ export declare const utilityResources: Resource;
13
+ export declare const i18nextUtility: i18n;
14
+ /**
15
+ * Initialize internationalization.
16
+ *
17
+ * @param environment
18
+ * Environment in which the application is running.
19
+ *
20
+ * @param debug
21
+ * Debug setting.
22
+ *
23
+ * @returns
24
+ * Void promise.
25
+ */
26
+ export declare function i18nUtilityInit(environment: I18NEnvironment, debug?: boolean): Promise<void>;
27
+ //# sourceMappingURL=i18n.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/locale/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAClG,OAAgB,EAAE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG1E,eAAO,MAAM,SAAS,kBAAkB,CAAC;AAEzC;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,eAAe,CAAC;AAI1D;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAO9B,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,IAA+B,CAAC;AAE7D;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,WAAW,EAAE,eAAe,EAAE,KAAK,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhG"}
@@ -0,0 +1,35 @@
1
+ import { i18nAssertValidResources, i18nCoreInit } from "@aidc-toolkit/core";
2
+ import i18next from "i18next";
3
+ import { localeStrings as enLocaleStrings } from "./en/locale-strings.js";
4
+ import { localeStrings as frLocaleStrings } from "./fr/locale-strings.js";
5
+ export const utilityNS = "aidct_utility";
6
+ i18nAssertValidResources(enLocaleStrings, "fr", frLocaleStrings);
7
+ /**
8
+ * Utility resources.
9
+ */
10
+ export const utilityResources = {
11
+ en: {
12
+ aidct_utility: enLocaleStrings
13
+ },
14
+ fr: {
15
+ aidct_utility: frLocaleStrings
16
+ }
17
+ };
18
+ // Explicit type is necessary to work around bug in type discovery with linked packages.
19
+ export const i18nextUtility = i18next.createInstance();
20
+ /**
21
+ * Initialize internationalization.
22
+ *
23
+ * @param environment
24
+ * Environment in which the application is running.
25
+ *
26
+ * @param debug
27
+ * Debug setting.
28
+ *
29
+ * @returns
30
+ * Void promise.
31
+ */
32
+ export async function i18nUtilityInit(environment, debug = false) {
33
+ await i18nCoreInit(i18nextUtility, environment, debug, utilityNS, utilityResources);
34
+ }
35
+ //# sourceMappingURL=i18n.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/locale/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAwB,MAAM,oBAAoB,CAAC;AAClG,OAAO,OAAqC,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE1E,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,CAAC;AAOzC,wBAAwB,CAAC,eAAe,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC;AAEjE;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAa;IACtC,EAAE,EAAE;QACA,aAAa,EAAE,eAAe;KACjC;IACD,EAAE,EAAE;QACA,aAAa,EAAE,eAAe;KACjC;CACJ,CAAC;AAEF,wFAAwF;AACxF,MAAM,CAAC,MAAM,cAAc,GAAS,OAAO,CAAC,cAAc,EAAE,CAAC;AAE7D;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,WAA4B,EAAE,KAAK,GAAG,KAAK;IAC7E,MAAM,YAAY,CAAC,cAAc,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC;AACxF,CAAC"}
@@ -0,0 +1,41 @@
1
+ import type { StringValidator } from "./string.js";
2
+ /**
3
+ * Record validator. Validation is performed against a record with a string key type and throws an error if the key is
4
+ * not found.
5
+ */
6
+ export declare class RecordValidator<T> implements StringValidator {
7
+ /**
8
+ * Type name for error message.
9
+ */
10
+ private readonly _typeName;
11
+ /**
12
+ * Record in which to look up keys.
13
+ */
14
+ private readonly _record;
15
+ /**
16
+ * Constructor.
17
+ *
18
+ * @param typeName
19
+ * Type name for error message.
20
+ *
21
+ * @param record
22
+ * Record in which to look up keys.
23
+ */
24
+ constructor(typeName: string, record: Readonly<Record<string, T>>);
25
+ /**
26
+ * Get the type name.
27
+ */
28
+ get typeName(): string;
29
+ /**
30
+ * Get the record.
31
+ */
32
+ get record(): Readonly<Record<string, T>>;
33
+ /**
34
+ * Validate a key by looking it up in the record.
35
+ *
36
+ * @param key
37
+ * Record key.
38
+ */
39
+ validate(key: string): void;
40
+ }
41
+ //# sourceMappingURL=record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../src/record.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;GAGG;AACH,qBAAa,eAAe,CAAC,CAAC,CAAE,YAAW,eAAe;IACtD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAEnC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;IAEtD;;;;;;;;OAQG;gBACS,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAKjE;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAExC;IAED;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;CAQ9B"}
package/dist/record.js ADDED
@@ -0,0 +1,55 @@
1
+ import { i18nextUtility } from "./locale/i18n.js";
2
+ /**
3
+ * Record validator. Validation is performed against a record with a string key type and throws an error if the key is
4
+ * not found.
5
+ */
6
+ export class RecordValidator {
7
+ /**
8
+ * Type name for error message.
9
+ */
10
+ _typeName;
11
+ /**
12
+ * Record in which to look up keys.
13
+ */
14
+ _record;
15
+ /**
16
+ * Constructor.
17
+ *
18
+ * @param typeName
19
+ * Type name for error message.
20
+ *
21
+ * @param record
22
+ * Record in which to look up keys.
23
+ */
24
+ constructor(typeName, record) {
25
+ this._typeName = typeName;
26
+ this._record = record;
27
+ }
28
+ /**
29
+ * Get the type name.
30
+ */
31
+ get typeName() {
32
+ return this._typeName;
33
+ }
34
+ /**
35
+ * Get the record.
36
+ */
37
+ get record() {
38
+ return this._record;
39
+ }
40
+ /**
41
+ * Validate a key by looking it up in the record.
42
+ *
43
+ * @param key
44
+ * Record key.
45
+ */
46
+ validate(key) {
47
+ if (!(key in this.record)) {
48
+ throw new RangeError(i18nextUtility.t("RecordValidator.typeNameKeyNotFound", {
49
+ typeName: this.typeName,
50
+ key
51
+ }));
52
+ }
53
+ }
54
+ }
55
+ //# sourceMappingURL=record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.js","sourceRoot":"","sources":["../src/record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD;;;GAGG;AACH,MAAM,OAAO,eAAe;IACxB;;OAEG;IACc,SAAS,CAAS;IAEnC;;OAEG;IACc,OAAO,CAA8B;IAEtD;;;;;;;;OAQG;IACH,YAAY,QAAgB,EAAE,MAAmC;QAC7D,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACH,QAAQ,CAAC,GAAW;QAChB,IAAI,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,qCAAqC,EAAE;gBACzE,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,GAAG;aACN,CAAC,CAAC,CAAC;QACR,CAAC;IACL,CAAC;CACJ"}
@@ -0,0 +1,43 @@
1
+ import type { StringValidator } from "./string.js";
2
+ /**
3
+ * Regular expression validator. The regular expression applies to the full string only if constructed as such. For
4
+ * example, <code>&#x2F;\d&#x2A;&#x2F;</code> (0 or more digits) matches every string, <code>&#x2F;\d+&#x2F;</code>
5
+ * (1 or more digits) matches strings with at least one digit, <code>&#x2F;^\d&#x2A;$&#x2F;</code> matches strings that
6
+ * are all digits or empty, and <code>&#x2F;^\d+$&#x2F;</code> matches strings that are all digits and not empty.
7
+ *
8
+ * Clients of this class are recommended to override the {@link createErrorMessage} method create a more suitable error
9
+ * message for their use case.
10
+ */
11
+ export declare class RegExpValidator implements StringValidator {
12
+ /**
13
+ * Regular expression.
14
+ */
15
+ private readonly _regExp;
16
+ /**
17
+ * Constructor.
18
+ *
19
+ * @param regExp
20
+ * Regular expression. See {@link RegExpValidator | class documentation} for notes.
21
+ */
22
+ constructor(regExp: RegExp);
23
+ /**
24
+ * Get the regular expression.
25
+ */
26
+ get regExp(): RegExp;
27
+ /**
28
+ * Create an error message for a string. The generic error message is sufficient for many use cases but a more
29
+ * domain-specific error message, possibly including the pattern itself, is often required.
30
+ *
31
+ * @param s
32
+ * String.
33
+ *
34
+ * @returns
35
+ * Error message.
36
+ */
37
+ protected createErrorMessage(s: string): string;
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ validate(s: string): void;
42
+ }
43
+ //# sourceMappingURL=reg-exp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reg-exp.d.ts","sourceRoot":"","sources":["../src/reg-exp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;GAQG;AACH,qBAAa,eAAgB,YAAW,eAAe;IACnD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC;;;;;OAKG;gBACS,MAAM,EAAE,MAAM;IAI1B;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;;;;;;;;OASG;IACH,SAAS,CAAC,kBAAkB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAM/C;;OAEG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;CAK5B"}
@@ -0,0 +1,55 @@
1
+ import { i18nextUtility } from "./locale/i18n.js";
2
+ /**
3
+ * Regular expression validator. The regular expression applies to the full string only if constructed as such. For
4
+ * example, <code>&#x2F;\d&#x2A;&#x2F;</code> (0 or more digits) matches every string, <code>&#x2F;\d+&#x2F;</code>
5
+ * (1 or more digits) matches strings with at least one digit, <code>&#x2F;^\d&#x2A;$&#x2F;</code> matches strings that
6
+ * are all digits or empty, and <code>&#x2F;^\d+$&#x2F;</code> matches strings that are all digits and not empty.
7
+ *
8
+ * Clients of this class are recommended to override the {@link createErrorMessage} method create a more suitable error
9
+ * message for their use case.
10
+ */
11
+ export class RegExpValidator {
12
+ /**
13
+ * Regular expression.
14
+ */
15
+ _regExp;
16
+ /**
17
+ * Constructor.
18
+ *
19
+ * @param regExp
20
+ * Regular expression. See {@link RegExpValidator | class documentation} for notes.
21
+ */
22
+ constructor(regExp) {
23
+ this._regExp = regExp;
24
+ }
25
+ /**
26
+ * Get the regular expression.
27
+ */
28
+ get regExp() {
29
+ return this._regExp;
30
+ }
31
+ /**
32
+ * Create an error message for a string. The generic error message is sufficient for many use cases but a more
33
+ * domain-specific error message, possibly including the pattern itself, is often required.
34
+ *
35
+ * @param s
36
+ * String.
37
+ *
38
+ * @returns
39
+ * Error message.
40
+ */
41
+ createErrorMessage(s) {
42
+ return i18nextUtility.t("RegExpValidator.stringDoesNotMatchPattern", {
43
+ s
44
+ });
45
+ }
46
+ /**
47
+ * @inheritDoc
48
+ */
49
+ validate(s) {
50
+ if (!this._regExp.test(s)) {
51
+ throw new RangeError(this.createErrorMessage(s));
52
+ }
53
+ }
54
+ }
55
+ //# sourceMappingURL=reg-exp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reg-exp.js","sourceRoot":"","sources":["../src/reg-exp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD;;;;;;;;GAQG;AACH,MAAM,OAAO,eAAe;IACxB;;OAEG;IACc,OAAO,CAAS;IAEjC;;;;;OAKG;IACH,YAAY,MAAc;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;;;;;;;;OASG;IACO,kBAAkB,CAAC,CAAS;QAClC,OAAO,cAAc,CAAC,CAAC,CAAC,2CAA2C,EAAE;YACjE,CAAC;SACJ,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,CAAS;QACd,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;QACrD,CAAC;IACL,CAAC;CACJ"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Sequence. Defines an ascending or descending sequence of big integers implemented as an iterable.
3
+ */
4
+ export declare class Sequence implements Iterable<bigint> {
5
+ /**
6
+ * Start value (inclusive).
7
+ */
8
+ private readonly _startValue;
9
+ /**
10
+ * End value (exclusive).
11
+ */
12
+ private readonly _endValue;
13
+ /**
14
+ * Count of values.
15
+ */
16
+ private readonly _count;
17
+ /**
18
+ * Delta to the next value; equal to the sign of the count.
19
+ */
20
+ private readonly _nextDelta;
21
+ /**
22
+ * Minimum value (inclusive).
23
+ */
24
+ private readonly _minimumValue;
25
+ /**
26
+ * Maximum value (inclusive).
27
+ */
28
+ private readonly _maximumValue;
29
+ /**
30
+ * Constructor.
31
+ *
32
+ * @param startValue
33
+ * Start value.
34
+ *
35
+ * @param count
36
+ * Count of values. If count is zero or positive, iteration ascends from start value, otherwise it descends from
37
+ * start value.
38
+ */
39
+ constructor(startValue: number | bigint, count: number);
40
+ /**
41
+ * Get the start value (inclusive).
42
+ */
43
+ get startValue(): bigint;
44
+ /**
45
+ * Get the end value (exclusive).
46
+ */
47
+ get endValue(): bigint;
48
+ /**
49
+ * Get the count of values.
50
+ */
51
+ get count(): number;
52
+ /**
53
+ * Get the minimum value (inclusive).
54
+ */
55
+ get minimumValue(): bigint;
56
+ /**
57
+ * Get the maximum value (inclusive).
58
+ */
59
+ get maximumValue(): bigint;
60
+ /**
61
+ * Iterable implementation.
62
+ *
63
+ * @yields
64
+ * Next value in sequence.
65
+ */
66
+ [Symbol.iterator](): Generator<bigint>;
67
+ }
68
+ //# sourceMappingURL=sequence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sequence.d.ts","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,QAAS,YAAW,QAAQ,CAAC,MAAM,CAAC;IAC7C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IAErC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAEnC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAW;IAEtC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IAEvC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IAEvC;;;;;;;;;OASG;gBACS,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM;IAgBtD;;OAEG;IACH,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;OAEG;IACH,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED;;OAEG;IACH,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED;;;;;OAKG;IACD,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,MAAM,CAAC;CAK3C"}