@mionjs/type-formats 0.8.0-alpha.0 → 0.8.4-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist/cjs/src/bigint/bigIntFormat.runtype.cjs.map +1 -1
- package/.dist/cjs/src/constants.cjs.map +1 -1
- package/.dist/cjs/src/constants.mock.cjs.map +1 -1
- package/.dist/cjs/src/number/numberFormat.runtype.cjs.map +1 -1
- package/.dist/cjs/src/string/date.runtype.cjs.map +1 -1
- package/.dist/cjs/src/string/dateTime.runtype.cjs.map +1 -1
- package/.dist/cjs/src/string/defaultStringFormats.runtype.cjs.map +1 -1
- package/.dist/cjs/src/string/domain.runtype.cjs.map +1 -1
- package/.dist/cjs/src/string/email.runtype.cjs.map +1 -1
- package/.dist/cjs/src/string/ip.runtype.cjs.map +1 -1
- package/.dist/cjs/src/string/stringFormat.runtype.cjs.map +1 -1
- package/.dist/cjs/src/string/time.runtype.cjs.map +1 -1
- package/.dist/cjs/src/string/url.runtype.cjs.map +1 -1
- package/.dist/cjs/src/string/uuid.runtype.cjs.map +1 -1
- package/.dist/cjs/src/type-formats-pure-fns.cjs.map +1 -1
- package/.dist/cjs/src/utils.cjs.map +1 -1
- package/.dist/esm/src/bigint/bigIntFormat.runtype.js.map +1 -1
- package/.dist/esm/src/constants.js.map +1 -1
- package/.dist/esm/src/constants.mock.js.map +1 -1
- package/.dist/esm/src/number/numberFormat.runtype.js.map +1 -1
- package/.dist/esm/src/string/date.runtype.js.map +1 -1
- package/.dist/esm/src/string/dateTime.runtype.js.map +1 -1
- package/.dist/esm/src/string/defaultStringFormats.runtype.js.map +1 -1
- package/.dist/esm/src/string/domain.runtype.js.map +1 -1
- package/.dist/esm/src/string/email.runtype.js.map +1 -1
- package/.dist/esm/src/string/ip.runtype.js.map +1 -1
- package/.dist/esm/src/string/stringFormat.runtype.js.map +1 -1
- package/.dist/esm/src/string/time.runtype.js.map +1 -1
- package/.dist/esm/src/string/url.runtype.js.map +1 -1
- package/.dist/esm/src/string/uuid.runtype.js.map +1 -1
- package/.dist/esm/src/type-formats-pure-fns.js.map +1 -1
- package/.dist/esm/src/utils.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bigIntFormat.runtype.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"bigIntFormat.runtype.cjs","sources":["../../../../src/bigint/bigIntFormat.runtype.ts"],"sourcesContent":["/* ########\n * 2025 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\nimport type {\n BaseRunType,\n JitFnCompiler,\n JitErrorsFnCompiler,\n JitCode,\n jitBinarySerializerArgs,\n JitFunctions,\n BaseFnCompiler,\n jitBinaryDeserializerArgs,\n} from '@mionjs/run-types';\n// !Important: TypeFormat cant be imported as type for all runType functionality to work\nimport {TypeFormat, registerFormatter, BaseRunTypeFormat, RunTypeOptions, random} from '@mionjs/run-types';\nimport {ReflectionKind} from '@deepkit/type';\nimport {paramVal} from '../utils.ts';\nimport {FormatParams_BigInt} from '@mionjs/core';\n\ntype BinarySerializer = BaseFnCompiler<typeof jitBinarySerializerArgs, typeof JitFunctions.toBinary.id>;\ntype BinaryDeserializer = BaseFnCompiler<typeof jitBinaryDeserializerArgs, typeof JitFunctions.fromBinary.id>;\n\n// BigInt64 range: -9223372036854775808n to 9223372036854775807n (signed 64-bit)\nconst BIGINT64_MIN = -9223372036854775808n;\nconst BIGINT64_MAX = 9223372036854775807n;\n// BigUInt64 range: 0n to 18446744073709551615n (unsigned 64-bit)\nconst BIGUINT64_MIN = 0n;\nconst BIGUINT64_MAX = 18446744073709551615n;\n\n// ############### BigInt Format ###############\n\n/**\n * BigIntFormat is the base class for bigint formats.\n * It is used to define the bigint format and its parameters.\n * Jit code will be generated for each one of the BigIntFormat parameters.\n * @reflection never\n */\nexport class BigIntRunTypeFormat extends BaseRunTypeFormat<FormatParams_BigInt> {\n static readonly id = 'bigintFormat' as const;\n readonly kind = ReflectionKind.bigint;\n readonly name = BigIntRunTypeFormat.id;\n\n emitIsType(comp: JitFnCompiler, rt: BaseRunType): JitCode {\n const params = this.getParams(rt);\n const v = comp.vλl;\n\n // Create an array to hold all conditions\n const conditions: string[] = [];\n\n // Check range constraints\n if (params.max !== undefined) {\n const maxVal = paramVal(params.max);\n conditions.push(`${v} <= ${maxVal}n`);\n }\n if (params.min !== undefined) {\n const minVal = paramVal(params.min);\n conditions.push(`${v} >= ${minVal}n`);\n }\n if (params.lt !== undefined) {\n const ltVal = paramVal(params.lt);\n conditions.push(`${v} < ${ltVal}n`);\n }\n if (params.gt !== undefined) {\n const gtVal = paramVal(params.gt);\n conditions.push(`${v} > ${gtVal}n`);\n }\n\n // Check multipleOf constraint\n if (params.multipleOf !== undefined) {\n const multipleOfVal = paramVal(params.multipleOf);\n conditions.push(`(${v} % ${multipleOfVal}n === 0n)`);\n }\n\n // Join all conditions with AND operator\n return {code: conditions.length ? conditions.join(' && ') : 'true', type: 'E'};\n }\n\n emitIsTypeErrors(comp: JitErrorsFnCompiler, rt: BaseRunType): JitCode {\n const params = this.getParams(rt);\n const v = comp.vλl;\n const errFn = this.getCallJitFormatErr(comp, rt, this, false);\n\n // Create an array to hold all error conditions\n const conditions: string[] = [];\n\n // Check range constraints\n if (params.max !== undefined) {\n const maxVal = paramVal(params.max);\n conditions.push(`if (${v} > ${maxVal}n) ${errFn('max', maxVal)}`);\n }\n if (params.min !== undefined) {\n const minVal = paramVal(params.min);\n conditions.push(`if (${v} < ${minVal}n) ${errFn('min', minVal)}`);\n }\n if (params.lt !== undefined) {\n const ltVal = paramVal(params.lt);\n conditions.push(`if (${v} >= ${ltVal}n) ${errFn('lt', ltVal)}`);\n }\n if (params.gt !== undefined) {\n const gtVal = paramVal(params.gt);\n conditions.push(`if (${v} <= ${gtVal}n) ${errFn('gt', gtVal)}`);\n }\n\n // Check multipleOf constraint\n if (params.multipleOf !== undefined) {\n const multipleOfVal = paramVal(params.multipleOf);\n conditions.push(`if ((${v} % ${multipleOfVal}n !== 0n)) ${errFn('multipleOf', multipleOfVal)}`);\n }\n\n // Join all error conditions with newlines\n return {code: conditions.join(';'), type: 'S'};\n }\n\n // No format transformation needed for bigints\n emitFormat(): JitCode {\n // No transformation needed for bigints\n return {code: undefined, type: 'S'};\n }\n\n emitToBinary(comp: BinarySerializer, rt: BaseRunType): JitCode {\n const params = this.getParams(rt);\n const bigintType = getBigIntType(params);\n // If the bigint fits in 8 bytes (Int64 or UInt64), use binary encoding\n if (bigintType.isBigInt64 || bigintType.isBigUInt64) {\n const sεr = comp.args.sεr;\n if (bigintType.isBigUInt64) {\n return {code: `${sεr}.view.setBigUint64(${sεr}.index, ${comp.vλl}, 1, ${sεr}.index += 8)`, type: 'S'};\n }\n // isBigInt64\n return {code: `${sεr}.view.setBigInt64(${sεr}.index, ${comp.vλl}, 1, ${sεr}.index += 8)`, type: 'S'};\n }\n // For bigints outside 8-byte range, let run-types handle it (serializes as string)\n return {code: undefined, type: 'S'};\n }\n\n emitFromBinary(comp: BinaryDeserializer, rt: BaseRunType): JitCode {\n const params = this.getParams(rt);\n const bigintType = getBigIntType(params);\n // If the bigint fits in 8 bytes (Int64 or UInt64), use binary decoding\n if (bigintType.isBigInt64 || bigintType.isBigUInt64) {\n const dεs = comp.args.dεs;\n if (bigintType.isBigUInt64) {\n return {code: `${dεs}.view.getBigUint64(${dεs}.index, 1, ${dεs}.index += 8)`, type: 'E'};\n }\n // isBigInt64\n return {code: `${dεs}.view.getBigInt64(${dεs}.index, 1, ${dεs}.index += 8)`, type: 'E'};\n }\n // For bigints outside 8-byte range, let run-types handle it (deserializes from string)\n return {code: undefined, type: 'S'};\n }\n\n _mock(opts: RunTypeOptions, rt: BaseRunType): bigint {\n const params = this.getParams(rt);\n let min = params.min !== undefined ? (paramVal(params.min) as bigint) : -99999n;\n let max = params.max !== undefined ? (paramVal(params.max) as bigint) : 99999n;\n\n // Adjust for exclusive bounds\n if (params.gt !== undefined) {\n const gtVal = paramVal(params.gt) as bigint;\n min = gtVal + 1n;\n }\n if (params.lt !== undefined) {\n const ltVal = paramVal(params.lt) as bigint;\n max = ltVal - 1n;\n }\n\n // Generate a random bigint within the range\n // Convert to numbers for random function, then back to bigint\n // This limits the range to safe integers, but is a reasonable approach for most use cases\n const minNum = Number(min > BigInt(Number.MIN_SAFE_INTEGER) ? min : BigInt(Number.MIN_SAFE_INTEGER));\n const maxNum = Number(max < BigInt(Number.MAX_SAFE_INTEGER) ? max : BigInt(Number.MAX_SAFE_INTEGER));\n\n let result = BigInt(random(minNum, maxNum));\n\n // Handle multipleOf constraint\n if (params.multipleOf !== undefined) {\n const multipleOfVal = paramVal(params.multipleOf) as bigint;\n // Find the largest multiple of multipleOfVal that is <= result\n const factor = result / multipleOfVal;\n result = factor * multipleOfVal;\n }\n\n return result;\n }\n\n validateParams(rt: BaseRunType, params: FormatParams_BigInt): void {\n // Check for mutually exclusive lower bound parameters\n const lowerBoundCount = [params.min, params.gt].filter(Boolean).length;\n if (lowerBoundCount > 1) {\n throw new Error(`Cannot specify more than one of min or gt in ${this.printPath(rt)}`);\n }\n\n // Check for mutually exclusive upper bound parameters\n const upperBoundCount = [params.max, params.lt].filter(Boolean).length;\n if (upperBoundCount > 1) {\n throw new Error(`Cannot specify more than one of max or lt in ${this.printPath(rt)}`);\n }\n\n // Check for valid ranges\n if (params.min && params.max && paramVal(params.min) > paramVal(params.max)) {\n throw new Error(`min cannot be greater than max in ${this.printPath(rt)}`);\n }\n\n if (params.gt && params.lt && paramVal(params.gt) >= paramVal(params.lt)) {\n throw new Error(`gt cannot be greater than or equal to lt in ${this.printPath(rt)}`);\n }\n\n // Check for multipleOf > 0\n if (params.multipleOf !== undefined) {\n const multipleOfVal = paramVal(params.multipleOf);\n\n if (multipleOfVal <= 0) {\n throw new Error(`multipleOf must be greater than 0 in ${this.printPath(rt)}`);\n }\n }\n }\n}\n\n/** Determines if the bigint params fit within Int64 or UInt64 ranges for 8-byte binary encoding */\n/** @reflection never */\nfunction getBigIntType(params: FormatParams_BigInt) {\n const min = params.min !== undefined ? (paramVal(params.min) as bigint) : undefined;\n const max = params.max !== undefined ? (paramVal(params.max) as bigint) : undefined;\n // Check if fits in signed 64-bit range (BigInt64)\n const isBigInt64 = min !== undefined && max !== undefined && min >= BIGINT64_MIN && max <= BIGINT64_MAX;\n // Check if fits in unsigned 64-bit range (BigUInt64)\n const isBigUInt64 = min !== undefined && max !== undefined && min >= BIGUINT64_MIN && max <= BIGUINT64_MAX;\n return {isBigInt64, isBigUInt64};\n}\n\n// ############### Register runtypes ###############\n\n/** @reflection never */\nexport const BIGINT_RUN_TYPE_FORMATTER = registerFormatter(new BigIntRunTypeFormat());\n\n// ########################### Run Types ###########################\n\n// Define the type for bigint format (optional branding, unbranded by default like FormatString)\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport type FormatBigInt<P extends Partial<FormatParams_BigInt> = {}, BrandName extends string = never> = TypeFormat<\n bigint,\n typeof BigIntRunTypeFormat.id,\n P,\n BrandName\n>;\n"],"names":["BaseRunTypeFormat","ReflectionKind","paramVal","random","registerFormatter"],"mappings":";;;;;AA0BA,MAAM,eAAe,CAAC;AACtB,MAAM,eAAe;AAErB,MAAM,gBAAgB;AACtB,MAAM,gBAAgB;AAUhB,MAAO,4BAA4BA,SAAAA,kBAAsC;AAAA,EAC3E,OAAgB,KAAK;AAAA,EACZ,OAAOC,KAAAA,eAAe;AAAA,EACtB,OAAO,oBAAoB;AAAA,EAEpC,WAAW,MAAqB,IAAe;AAC3C,UAAM,SAAS,KAAK,UAAU,EAAE;AAChC,UAAM,IAAI,KAAK;AAGf,UA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AAO,EAAC,YAAY,YAAA;AACxB;AAKO,MAAM,4BAA4BE,SAAAA,kBAAkB,IAAI,oBAAA,CAAqB;mGAQrD,IAAE,gBAAA,wBAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.cjs","sources":["../../../src/constants.ts"],"sourcesContent":["import {BigIntRunTypeFormat} from '../BigintFormats.ts';\nimport {NumberRunTypeFormat} from '../NumberFormats.ts';\nimport {\n DateStringRunTypeFormat,\n DateTimeRunTypeFormat,\n DomainRunTypeFormat,\n EmailRunTypeFormat,\n IPRunTypeFormat,\n StringRunTypeFormat,\n TimeStringRunTypeFormat,\n URLRunTypeFormat,\n UUIDRunTypeFormat,\n} from '../StringFormats.ts';\n\n/** Format name constants for type formats - values imported from RunTypeFormat classes */\nexport const FormatNames = {\n // String formats\n stringFormat: StringRunTypeFormat.id,\n uuid: UUIDRunTypeFormat.id,\n email: EmailRunTypeFormat.id,\n url: URLRunTypeFormat.id,\n domain: DomainRunTypeFormat.id,\n ip: IPRunTypeFormat.id,\n date: DateStringRunTypeFormat.id,\n time: TimeStringRunTypeFormat.id,\n dateTime: DateTimeRunTypeFormat.id,\n // Number formats\n numberFormat: NumberRunTypeFormat.id,\n // BigInt formats\n bigintFormat: BigIntRunTypeFormat.id,\n} as const;\n\nexport type FormatName = (typeof FormatNames)[keyof typeof FormatNames];\n"],"names":["StringRunTypeFormat","UUIDRunTypeFormat","EmailRunTypeFormat","URLRunTypeFormat","DomainRunTypeFormat","IPRunTypeFormat","DateStringRunTypeFormat","TimeStringRunTypeFormat","DateTimeRunTypeFormat","NumberRunTypeFormat","BigIntRunTypeFormat"],"mappings":";;;;;;;;;;;;;;AAeO,MAAM,cAAc;AAAA;AAAA,EAEvB,cAAcA,gCAAAA,oBAAoB;AAAA,EAClC,MAAMC,wBAAAA,kBAAkB;AAAA,EACxB,OAAOC,yBAAAA,mBAAmB;AAAA,EAC1B,KAAKC,uBAAAA,iBAAiB;AAAA,EACtB,QAAQC,0BAAAA,oBAAoB;AAAA,EAC5B,IAAIC,sBAAAA,gBAAgB;AAAA,EACpB,MAAMC,wBAAAA,wBAAwB;AAAA,EAC9B,MAAMC,wBAAAA,wBAAwB;AAAA,EAC9B,UAAUC,4BAAAA,sBAAsB;AAAA;AAAA,EAEhC,cAAcC,gCAAAA,oBAAoB;AAAA;AAAA,EAElC,cAAcC,gCAAAA,oBAAoB;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mock.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"constants.mock.cjs","sources":["../../../src/constants.mock.ts"],"sourcesContent":["/* ########\n * 2025 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\n// constants using inside runtype params should be declared as types\nexport type EMAIL_NAME_SAMPLES = [\n // English Names\n 'john.doe',\n 'jane.smith',\n 'admin',\n 'support',\n 'contact',\n 'info',\n 'sales',\n 'marketing',\n 'hello',\n 'feedback',\n 'user123',\n 'test.account',\n 'random.name',\n 'developer',\n 'webmaster',\n\n // Spanish Names\n 'juan.perez',\n 'maria.garcia',\n 'soporte',\n 'contacto',\n 'ventas',\n 'informacion',\n 'hola',\n 'usuario',\n 'prueba',\n 'desarrollador',\n\n // French Names\n 'jean.dupont',\n 'marie.curie',\n 'contact',\n 'support',\n 'vente',\n 'bonjour',\n 'utilisateur',\n 'testeur',\n 'developpeur',\n\n // German Names\n 'hans.schmidt',\n 'anna.müller',\n 'kontakt',\n 'hilfe',\n 'verkauf',\n 'benutzer',\n 'testkonto',\n 'entwickler',\n\n // Italian Names\n 'giuseppe.rossi',\n 'maria.bianchi',\n 'contatto',\n 'supporto',\n 'vendite',\n 'utente',\n 'prova',\n 'sviluppatore',\n\n // Portuguese Names\n 'joao.silva',\n 'maria.oliveira',\n 'contato',\n 'suporte',\n 'vendas',\n 'usuario',\n 'teste',\n 'desenvolvedor',\n\n // Korean Names (Hangul)\n '홍길동',\n '김철수',\n '고객지원',\n '연락처',\n '판매',\n '사용자',\n\n // Japanese Names (Kanji and Kana)\n '山田太郎',\n '鈴木花子',\n '情報',\n 'サポート',\n '日本語',\n 'テスト',\n '携帯',\n '電子',\n\n // Chinese Names (Chinese Characters)\n '李伟',\n '王芳',\n '张三',\n '联系',\n '测试',\n '用户',\n '开发',\n\n // Indian Names\n 'arjun.sharma',\n 'priya.kumar',\n 'support',\n 'contact',\n 'vikas',\n 'pariksha',\n 'upayogakarta',\n\n // Russian Names (Cyrillic)\n 'иван.иванов',\n 'анна.петровна',\n 'поддержка',\n 'контакт',\n 'продажи',\n 'пользователь',\n 'разработчик',\n\n // Miscellaneous\n 'alpha.beta',\n 'charlie.delta',\n 'test123',\n 'mock.user',\n 'example.name',\n 'first.last',\n 'nickname',\n 'alias',\n 'temp.account',\n 'demo.user',\n];\n\nexport type EMAIL_SAMPLES = [\n // English full emails\n 'john.doe@mion.io',\n 'jane.smith@rpc.org',\n 'admin@wiki.org',\n 'support@www.mion.org',\n 'contact@www.api.org',\n 'info@arch.org',\n 'sales@ccmns.org',\n 'marketing@eff.org',\n 'hello@fsf.org',\n 'feedback@opensource.org',\n 'user123@node.org',\n 'test.account@typescript.org',\n 'random.name@rpc.org',\n 'developer@fullstack.org',\n 'webmaster@mion.io',\n\n // Spanish full emails\n 'juan.perez@wiki.org',\n 'maria.garcia@arch.org',\n 'soporte@ccmns.org',\n 'contacto@eff.org',\n 'ventas@fsf.org',\n 'informacion@opensource.org',\n 'hola@node.org',\n 'usuario@typescript.org',\n 'prueba@rpc.org',\n 'desarrollador@fullstack.org',\n\n // French full emails\n 'jean.dupont@mion.io',\n 'marie.curie@wiki.org',\n 'vente@arch.org',\n 'bonjour@ccmns.org',\n 'utilisateur@eff.org',\n 'testeur@fsf.org',\n 'developpeur@opensource.org',\n\n // German full emails\n 'anna.müller@node.org',\n 'anna.schmidt@typescript.org',\n 'kontakt@rpc.org',\n 'hilfe@fullstack.org',\n 'verkauf@mion.io',\n 'benutzer@wiki.org',\n 'entwickler@arch.org',\n\n // Chinese full emails\n '王芳@ccmns.org',\n '联系@eff.org',\n '测试@fsf.org',\n 'ceshi@opensource.org',\n '张三@node.org',\n 'kaifa@typescript.org',\n\n // Indian full emails\n 'arjun.sharma@rpc.org',\n 'priya.kumar@fullstack.org',\n 'vikas@mion.io',\n 'pariksha@wiki.org',\n 'upayogakarta@arch.org',\n\n // Russian full emails (Cyrillic)\n 'иван.иванов@ccmns.org',\n 'анна.петровна@eff.org',\n 'поддержка@fsf.org',\n 'контакт@opensource.org',\n 'продажи@node.org',\n 'пользователь@typescript.org',\n 'разработчик@rpc.org',\n\n // Miscellaneous\n 'alpha.beta@fullstack.org',\n 'charlie.delta@mion.io',\n 'test123@wiki.org',\n 'mock.user@arch.org',\n 'example.name@ccmns.org',\n 'first.last@eff.org',\n 'nickname@fsf.org',\n 'alias@opensource.org',\n 'temp.account@node.org',\n 'demo.user@typescript.org',\n\n // Tricky but valid email addresses\n 'email+tag@mion.io', // Plus sign for tagging/filtering\n 'email-with-hyphen@rpc.org', // Hyphen in local part\n 'email_with_underscore@wiki.org', // Underscore in local part\n 'very.common@arch.org', // Multiple dots in local part\n \"!#$%&'*+-/=?^_`{|}~@ccmns.org\", // Special chars allowed in local part\n '\"quoted\"@eff.org', // Quoted local part\n '\"very.(),:;<>[]\\\\\"@opensource.org', // Quoted local part with special chars\n 'user.name+tag+sorting@example.com', // Multiple plus signs\n 'x@example.com', // Single character local part\n 'example-indeed@strange-example.com', // Hyphen in domain\n 'test/test@test.com', // Slash in local part (valid in quoted form)\n 'very.\"(),:;<>[]..very.unusual@strange.example.com', // Very unusual but valid\n 'user%example.com@mion.io', // Routing format\n 'user-@example.org', // Hyphen at end of local part\n];\n\nexport type EMAIL_SAMPLES_PUNYCODE = [\n // English full emails with regular domains\n 'john.doe@mion.io',\n 'jane.smith@rpc.org',\n\n // English full emails with Punycode domains\n 'admin@xn--e1afmkfd.xn--p1ai', // admin@пример.рф\n 'support@xn--80aaicww6a.xn--p1acf', // support@домен.срб\n\n // Spanish full emails with regular domains\n 'juan.perez@wiki.org',\n 'maria.garcia@arch.org',\n\n // Spanish full emails with Punycode domains\n 'soporte@xn--mgbh0fb.xn--kgbechtv', // soporte@موقع.مصر\n 'contacto@xn--fiqz9s.xn--fiqs8s', // contacto@网址.中国\n\n // Russian full emails with regular domains\n 'иван.иванов@ccmns.org',\n\n // Russian full emails with Punycode domains\n 'анна.петровна@xn--80adxhks.xn--p1ai', // анна.петровна@москва.рф\n 'поддержка@xn--d1acufc.xn--j1amh', // поддержка@сайт.укр\n\n // Miscellaneous with regular domains\n 'user.name+tag+sorting@example.com',\n 'user@sub-domain.example-site.com',\n 'user@domain.with-number123.com',\n\n // Miscellaneous with Punycode domains\n 'user@xn--80akhbyknj4f.xn--p1ai', // user@испытание.рф\n 'x@xn--mgberp4a5d4ar.xn--mgbaam7a8h', // x@السعودية.امارات\n 'test@xn--qxam.xn--zckzah', // test@テスト.テスト\n 'info@xn--9n2bp8q.xn--9t4b11yi5a', // info@테스트.한국\n];\n\nexport type URL_SAMPLES = [\n // http and https\n 'https://mion.io',\n 'https://rpc.org',\n 'http://wiki.org',\n 'https://www.mion.org',\n 'http://www.api.org',\n 'https://arch.org/path/to/resource',\n 'http://ccmns.org/path/to/resource',\n 'https://eff.org?query=param',\n 'http://fsf.org?query=param#hello-world',\n 'https://opensource.org#fragment',\n 'http://node.org#fragment',\n 'https://subdomain.typescript.org',\n 'http://subdomain.rpc.org',\n 'https://fullstack.org:8080',\n\n // localhost and IP addresses\n 'http://localhost:8080/path/to/resource',\n 'https://127.0.0.1:8080/path/to/resource',\n 'https://254.60.167.80:80/path/to/resource',\n 'http://:8080/path/to/resource',\n 'http://[::1]:8080/path/to/resource',\n 'http://[::]:8080/path/to/resource?query=param',\n 'http://[::1]:8080/path/to/resource#fragment',\n 'http://[::1]/path/to/resource',\n\n // ws and wss\n 'ws://mion.io/socket',\n 'ws://websocket.org/socket',\n 'wss://socket.io/socket',\n 'ws://live.com/socket?query=param',\n 'wss://sock.org/socket?query=param#fragment',\n 'ws://socketcluster.io/socket#fragment',\n 'wss://developer..dev:8080/socket',\n 'ws://fast.com:8080/socket?query=param',\n\n /// ftp & ftps\n 'ftp://example.com/file.txt',\n 'ftps://example.com/file.txt',\n];\n\nexport type FILE_URL_SAMPLES = [\n // File URLs\n 'file:///path/to/file.txt',\n 'file:///C:/path/to/file.txt',\n 'file://localhost/path/to/file.txt',\n 'file:///home/user/file.txt',\n 'file://example.com/path/to/file.txt',\n 'file:///C:/Users/User/Documents/file.txt',\n 'file:///tmp/file.txt',\n 'file:///var/log/syslog',\n\n // File URLs with query parameters\n 'file:///path/to/file.txt?query=param',\n 'file:///C:/path/to/file.txt?query=param',\n\n // file URLs with special characters\n 'file:///path/to/file%20with%20spaces.txt',\n 'file:///path/to/file@with@special#characters.txt',\n\n // file with localhost & ips\n\n 'file://localhost/path/to/file.txt',\n 'file://localhost/C:/path/to/file.txt',\n 'file://localhost/home/user/file.txt',\n 'file://127.0.0.1:890/example.com/path/to/file.txt',\n 'file://localhost/path/to/file.txt?query=param',\n 'file:///home/user/file.txt?query=param',\n];\n\nexport type HTTP_URL_SAMPLES = [\n // http and https\n 'https://mion.io',\n 'https://rpc.org',\n 'http://wiki.org',\n 'https://www.mion.org',\n 'http://www.api.org',\n 'https://arch.org/path/to/resource',\n 'http://ccmns.org/path/to/resource',\n 'https://eff.org?query=param',\n 'http://fsf.org?query=param#hello-world',\n 'https://opensource.org#fragment',\n 'http://node.org#fragment',\n 'https://subdomain.typescript.org',\n 'http://subdomain.rpc.org',\n 'https://fullstack.org:8080',\n\n // localhost and IP addresses\n 'http://localhost:8080/path/to/resource',\n 'https://127.0.0.1:8080/path/to/resource',\n 'https://254.60.167.80:80/path/to/resource',\n 'http://:8080/path/to/resource',\n 'http://[::1]:8080/path/to/resource',\n 'http://[::]:8080/path/to/resource?query=param',\n 'http://[::1]:8080/path/to/resource#fragment',\n 'http://[::1]/path/to/resource',\n];\n\nexport type SOCIAL_MEDIA_URL_SAMPLES = [\n // Social Media URLs\n 'https://www.facebook.com/user',\n 'https://twitter.com/user',\n 'https://www.instagram.com/user/',\n 'https://www.linkedin.com/in/user/',\n 'https://www.tiktok.com/@user',\n 'https://www.youtube.com/c/user',\n 'https://www.snapchat.com/add/user',\n 'https://www.pinterest.com/user?query=param',\n 'https://www.reddit.com/user/user#fragment',\n 'https://www.whatsapp.com/user/',\n\n 'http://www.facebook.com/user',\n 'http://twitter.com/user',\n 'http://www.instagram.com/user/',\n 'http://www.linkedin.com/in/user/?query=param',\n 'http://www.tiktok.com/@user',\n 'http://www.youtube.com/c/user',\n 'http://www.snapchat.com/add/user?query=param#fragment',\n 'http://www.pinterest.com/user/',\n 'http://www.reddit.com/user/user/#fragment',\n 'http://www.whatsapp.com/user/',\n];\n\nexport type SOCIAL_MEDIA_DOMAINS_SAMPLES = [\n 'facebook',\n 'twitter',\n 'instagram',\n 'linkedin',\n 'tiktok',\n 'youtube',\n 'snapchat',\n 'pinterest',\n 'reddit',\n 'whatsapp',\n];\n\nexport const TLD_SAMPLES = [\n 'com',\n 'org',\n 'net',\n 'io',\n 'ai',\n 'app',\n 'co',\n 'dev',\n 'tech',\n 'co.uk',\n 'com.au',\n 'com.br',\n 'com.mx',\n 'com.ar',\n];\nexport const NAME_SAMPLES = [\n 'mion',\n 'mionkit',\n 'example',\n 'gogle',\n 'fcbook',\n 'amzn',\n 'twitt',\n 'insta',\n 'linked',\n 'yoube',\n 'pinturist',\n 'mion',\n 'mionkit',\n 'wiki',\n 'red',\n 'line',\n 'hello',\n 'world',\n 'test',\n 'random',\n 'user',\n 'developer',\n 'webmaster',\n 'admin',\n 'support',\n 'contact',\n 'info',\n 'mion',\n 'mionkit',\n];\n\nexport const TLD_CHARS = 'abcdefghijklmnopqrstuvwxyz';\nexport const NAME_CHARS = 'abcdefghijklmnopqrstuvwxyz0123456789';\nexport const NAME_CHARS_UNICODE =\n 'abcdefghijklmnopqrstuvwxyz0123456789' +\n // Cyrillic (Russian)\n 'абвгдеёжзийклмнопрстуфхцчшщъыьэюя' +\n // Japanese (Hiragana and Katakana samples)\n 'あいうえおかきくけこさしすせそたちつてとなにぬねのアイウエオカキクケコサシスセソタチツテト' +\n // Chinese (Simplified) samples\n '中国网址域名汉字电脑互联网技术计算机软件编程' +\n // Korean (Hangul) samples\n '한국어도메인이름인터넷기술컴퓨터소프트웨어프로그래밍' +\n // Arabic samples\n 'ابتثجحخدذرزسشصضطظعغفقكلمنهوي';\nexport const INTERNET_PROTOCOLS = ['http', 'https', 'ftp', 'ftps', 'ws', 'wss', 'file'];\n\n// Create a value export for EMAIL_NAME_SAMPLES\nexport const EMAIL_NAME_SAMPLES_ARRAY: string[] = [\n 'john.doe',\n 'jane.smith',\n 'admin',\n 'support',\n 'contact',\n 'info',\n 'sales',\n 'marketing',\n 'hello',\n 'feedback',\n 'user123',\n 'test.account',\n 'random.name',\n 'developer',\n 'webmaster',\n 'juan.perez',\n 'maria.garcia',\n 'soporte',\n 'contacto',\n 'ventas',\n 'informacion',\n 'hola',\n 'usuario',\n 'prueba',\n 'desarrollador',\n 'jean.dupont',\n 'marie.curie',\n 'vente',\n 'bonjour',\n 'utilisateur',\n 'testeur',\n 'developpeur',\n];\n"],"names":[],"mappings":";;;;;;;;;;AA2ZO,MAAM,cAAc;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;;AAEG,MAAM,eAAe;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;;AAGG,MAAM,YAAY;AAClB,MAAM,aAAa;AACnB,MAAM,qBACT;AAWG,MAAM,qBAAqB,CAAC,QAAQ,SAAS,OAAO,QAAQ,MAAM,OAAO,MAAM;AAG/E,MAAM,2BAAqC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numberFormat.runtype.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"numberFormat.runtype.cjs","sources":["../../../../src/number/numberFormat.runtype.ts"],"sourcesContent":["/* ########\n * 2025 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\nimport type {\n BaseRunType,\n JitFnCompiler,\n JitErrorsFnCompiler,\n JitCode,\n jitBinarySerializerArgs,\n JitFunctions,\n BaseFnCompiler,\n jitBinaryDeserializerArgs,\n} from '@mionjs/run-types';\n// TypeFormat is needed for type definitions even though it's not directly used in this file\n// !Important: TypeFormat cant be imported as type for all runType functionality to work\nimport {TypeFormat, registerFormatter, BaseRunTypeFormat, RunTypeOptions, random} from '@mionjs/run-types';\nimport {ReflectionKind} from '@deepkit/type';\nimport {paramVal} from '../utils.ts';\nimport {FormatParams_Number} from '@mionjs/core';\n\ntype BinarySerializer = BaseFnCompiler<typeof jitBinarySerializerArgs, typeof JitFunctions.toBinary.id>;\ntype BinaryDeserializer = BaseFnCompiler<typeof jitBinaryDeserializerArgs, typeof JitFunctions.fromBinary.id>;\n\n// ############### Number Format ###############\n\n/**\n * NumberFormat is the base class for number formats.\n * It is used to define the number format and its parameters.\n * Jit code will be generated for each one of the NumberFormat parameters.\n * @reflection never\n */\nexport class NumberRunTypeFormat extends BaseRunTypeFormat<FormatParams_Number> {\n static readonly id = 'numberFormat' as const;\n readonly kind = ReflectionKind.number;\n readonly name = NumberRunTypeFormat.id;\n\n emitIsType(comp: JitFnCompiler, rt: BaseRunType): JitCode {\n const params = this.getParams(rt);\n const v = comp.vλl;\n\n // Create an array to hold all conditions\n const conditions: string[] = [];\n\n // Check integer/float constraints\n if (params.integer) {\n conditions.push(`Number.isInteger(${v})`);\n } else if (params.float) {\n conditions.push(`!Number.isInteger(${v})`);\n }\n\n // Check range constraints\n if (params.max !== undefined) {\n const maxVal = paramVal(params.max);\n conditions.push(`${v} <= ${maxVal}`);\n }\n if (params.min !== undefined) {\n const minVal = paramVal(params.min);\n conditions.push(`${v} >= ${minVal}`);\n }\n if (params.lt !== undefined) {\n const ltVal = paramVal(params.lt);\n conditions.push(`${v} < ${ltVal}`);\n }\n if (params.gt !== undefined) {\n const gtVal = paramVal(params.gt);\n conditions.push(`${v} > ${gtVal}`);\n }\n\n // Check multipleOf constraint\n if (params.multipleOf !== undefined) {\n const multipleOfVal = paramVal(params.multipleOf);\n // multipleOf is enforced to be an integer in validateParams, so we can use simple modulo\n conditions.push(`(${v} % ${multipleOfVal} === 0)`);\n }\n\n // Join all conditions with AND operator\n return {code: conditions.join(' && '), type: 'E'};\n }\n\n emitIsTypeErrors(comp: JitErrorsFnCompiler, rt: BaseRunType): JitCode {\n const params = this.getParams(rt);\n const v = comp.vλl;\n const errFn = this.getCallJitFormatErr(comp, rt, this, false);\n\n // Create an array to hold all error conditions\n const conditions: string[] = [];\n\n // Check integer/float constraints\n if (params.integer) {\n conditions.push(`if (!Number.isInteger(${v})) ${errFn('integer', true)}`);\n } else if (params.float) {\n conditions.push(`if (Number.isInteger(${v})) ${errFn('float', true)}`);\n }\n\n // Check range constraints\n if (params.max !== undefined) {\n const maxVal = paramVal(params.max);\n conditions.push(`if (${v} > ${maxVal}) ${errFn('max', maxVal)}`);\n }\n if (params.min !== undefined) {\n const minVal = paramVal(params.min);\n conditions.push(`if (${v} < ${minVal}) ${errFn('min', minVal)}`);\n }\n if (params.lt !== undefined) {\n const ltVal = paramVal(params.lt);\n conditions.push(`if (${v} >= ${ltVal}) ${errFn('lt', ltVal)}`);\n }\n if (params.gt !== undefined) {\n const gtVal = paramVal(params.gt);\n conditions.push(`if (${v} <= ${gtVal}) ${errFn('gt', gtVal)}`);\n }\n\n // Check multipleOf constraint\n if (params.multipleOf !== undefined) {\n const multipleOfVal = paramVal(params.multipleOf);\n // multipleOf is enforced to be an integer in validateParams, so we can use simple modulo\n conditions.push(`if ((${v} % ${multipleOfVal} !== 0)) ${errFn('multipleOf', multipleOfVal)}`);\n }\n\n // Join all error conditions with newlines\n return {code: conditions.join(';'), type: 'S'};\n }\n\n // No format transformation needed for numbers\n emitFormat(): JitCode {\n // No transformation needed for numbers\n return {code: undefined, type: 'S'};\n }\n\n emitToBinary(comp: BinarySerializer, rt: BaseRunType): JitCode {\n const type = 'S';\n const sεr = comp.args.sεr;\n const params = this.getParams(rt);\n const isFloat = params.float !== undefined ? paramVal(params.float) : false;\n const floatCode = `${sεr}.view.setFloat64(${sεr}.index,${comp.vλl}, 1, (${sεr}.index += 8))`;\n if (isFloat) return {code: floatCode, type};\n const isInt = params.integer !== undefined ? paramVal(params.integer) : false;\n if (isInt) {\n const {isUint8, isUint16, isUint32, isInt8, isInt16, isInt32} = getIntegerType(params);\n switch (true) {\n case isUint8:\n return {code: `${sεr}.view.setUint8(${sεr}.index++, ${comp.vλl})`, type};\n case isUint16:\n return {code: `${sεr}.view.setUint16(${sεr}.index, ${comp.vλl}, 1, ${sεr}.index += 2)`, type};\n case isUint32:\n return {code: `${sεr}.view.setUint32(${sεr}.index, ${comp.vλl}, 1, ${sεr}.index += 4)`, type};\n case isInt8:\n return {code: `${sεr}.view.setInt8(${sεr}.index++, ${comp.vλl})`, type};\n case isInt16:\n return {code: `${sεr}.view.setInt16(${sεr}.index, ${comp.vλl}, 1, ${sεr}.index += 2)`, type};\n case isInt32:\n return {code: `${sεr}.view.setInt32(${sεr}.index, ${comp.vλl}, 1, ${sεr}.index += 4)`, type};\n default:\n return {code: floatCode, type};\n }\n }\n return {code: floatCode, type: 'S'};\n }\n\n emitFromBinary(comp: BinaryDeserializer, rt: BaseRunType): JitCode {\n const type = 'E';\n const dεs = comp.args.dεs;\n const params = this.getParams(rt);\n const isFloat = params.float !== undefined ? paramVal(params.float) : false;\n const floatCode = `${dεs}.view.getFloat64(${dεs}.index, 1, (${dεs}.index += 8))`;\n if (isFloat) return {code: floatCode, type};\n const isInt = params.integer !== undefined ? paramVal(params.integer) : false;\n if (isInt) {\n const {isUint8, isUint16, isUint32, isInt8, isInt16, isInt32} = getIntegerType(params);\n switch (true) {\n case isUint8:\n return {code: `${dεs}.view.getUint8(${dεs}.index++)`, type};\n case isUint16:\n return {code: `${dεs}.view.getUint16(${dεs}.index, 1, ${dεs}.index += 2)`, type};\n case isUint32:\n return {code: `${dεs}.view.getUint32(${dεs}.index, 1, ${dεs}.index += 4)`, type};\n case isInt8:\n return {code: `${dεs}.view.getInt8(${dεs}.index++)`, type};\n case isInt16:\n return {code: `${dεs}.view.getInt16(${dεs}.index, 1, ${dεs}.index += 2)`, type};\n case isInt32:\n return {code: `${dεs}.view.getInt32(${dεs}.index, 1, ${dεs}.index += 4)`, type};\n default:\n return {code: floatCode, type};\n }\n }\n return {code: floatCode, type};\n }\n\n _mock(opts: RunTypeOptions, rt: BaseRunType): number {\n const params = this.getParams(rt);\n let min = params.min !== undefined ? paramVal(params.min) : -99999;\n let max = params.max !== undefined ? paramVal(params.max) : 99999;\n\n // Adjust for exclusive bounds\n if (params.gt !== undefined) {\n const epsilon = params.float ? 0.01 : 1;\n const gtVal = paramVal(params.gt);\n min = Math.max(min, gtVal + epsilon);\n }\n if (params.lt !== undefined) {\n const epsilon = params.float ? 0.01 : 1;\n const ltVal = paramVal(params.lt);\n max = Math.min(max, ltVal - epsilon);\n }\n\n // Generate a random number within the range\n let result: number;\n\n if (params.integer) {\n // For integers, ensure we get whole numbers\n min = Math.ceil(min);\n max = Math.floor(max);\n result = random(min, max);\n } else {\n // For floats, generate a random decimal\n result = min + Math.random() * (max - min);\n }\n\n // Handle multipleOf constraint\n if (params.multipleOf !== undefined) {\n const multipleOfVal = paramVal(params.multipleOf);\n // Find the largest multiple of multipleOfVal that is <= result\n const factor = Math.floor(result / multipleOfVal);\n result = factor * multipleOfVal;\n }\n\n return result;\n }\n\n validateParams(rt: BaseRunType, params: FormatParams_Number): void {\n // Check for conflicting parameters\n if (params.integer && params.float) {\n throw new Error(`Cannot specify both integer and float in ${this.printPath(rt)}`);\n }\n\n // Check for mutually exclusive lower bound parameters\n const lowerBoundCount = [params.min, params.gt].filter(Boolean).length;\n if (lowerBoundCount > 1) {\n throw new Error(`Cannot specify more than one of min or gt in ${this.printPath(rt)}`);\n }\n\n // Check for mutually exclusive upper bound parameters\n const upperBoundCount = [params.max, params.lt].filter(Boolean).length;\n if (upperBoundCount > 1) {\n throw new Error(`Cannot specify more than one of max or lt in ${this.printPath(rt)}`);\n }\n\n // Check for valid ranges\n if (params.min && params.max && paramVal(params.min) > paramVal(params.max)) {\n throw new Error(`min cannot be greater than max in ${this.printPath(rt)}`);\n }\n\n if (params.gt && params.lt && paramVal(params.gt) >= paramVal(params.lt)) {\n throw new Error(`gt cannot be greater than or equal to lt in ${this.printPath(rt)}`);\n }\n\n // Check for multipleOf > 0 and must be integer\n if (params.multipleOf !== undefined) {\n const multipleOfVal = paramVal(params.multipleOf);\n\n if (multipleOfVal <= 0) {\n throw new Error(`multipleOf must be greater than 0 in ${this.printPath(rt)}`);\n }\n\n // Enforce that multipleOf must always be an integer to avoid floating-point precision issues\n if (!Number.isInteger(multipleOfVal)) {\n throw new Error(\n `multipleOf must be an integer to avoid floating-point precision issues in ${this.printPath(rt)}`\n );\n }\n\n // Check consistency with float parameter\n if (params.float) {\n throw new Error(\n `multipleOf cannot be used with float constraint as multipleOf must be an integer in ${this.printPath(rt)}`\n );\n }\n }\n }\n}\n\n/** @reflection never */\nfunction getIntegerType(params: any) {\n const min = params.min !== undefined ? paramVal(params.min) : Number.MIN_SAFE_INTEGER;\n const max = params.max !== undefined ? paramVal(params.max) : Number.MAX_SAFE_INTEGER;\n const isUint8 = min >= 0 && max !== undefined && max <= 255;\n const isUint16 = min >= 0 && max !== undefined && max <= 65535;\n const isUint32 = min >= 0 && max !== undefined && max <= 4294967295;\n const isInt8 = min >= -128 && max !== undefined && max <= 127;\n const isInt16 = min >= -32768 && max !== undefined && max <= 32767;\n const isInt32 = min >= -2147483648 && max !== undefined && max <= 2147483647;\n return {isUint8, isUint16, isUint32, isInt8, isInt16, isInt32};\n}\n\n// ############### Register runtypes ###############\n/** @reflection never */\nexport const NUMBER_RUN_TYPE_FORMATTER = registerFormatter(new NumberRunTypeFormat());\n\n// Define the type for number format (optional branding, unbranded by default like FormatString)\nexport type FormatNumber<P extends Partial<FormatParams_Number>, BrandName extends string = never> = TypeFormat<\n number,\n typeof NumberRunTypeFormat.id,\n P,\n BrandName\n>;\n"],"names":["BaseRunTypeFormat","ReflectionKind","paramVal","type","random","registerFormatter"],"mappings":";;;;;AAkCM,MAAO,4BAA4BA,SAAAA,kBAAsC;AAAA,EAC3E,OAAgB,KAAK;AAAA,EACZ,OAAOC,KAAAA,eAAe;AAAA,EACtB,OAAO,oBAAoB;AAAA,EAEpC,WAAW,MAAqB,IAAe;AAC3C,UAAM,SAAS,KAAK,UAAU,EAAE;AAChC,UAAM,IAAI,KAAK;AAGf,UAAM,aAAuB,CAAA;AAG7B,QAAI,OAAO,SAAS;AAChB,iBAAW,KAAK,oBAAoB,CAAC,GAAG;AAAA,IAC5C,WAAW,OAAO,OAAO;AACrB,iBAAW,KAAK,qBAAqB,CAAC,GAAG;AAAA,IAC7C;AAGA,QAAI,OAAO,QAAQ,QAAW;AAC1B,YAAM,SAASC,UAAAA,SAAS,OAAO,GAAG;AAClC,iBAAW,KAAK,GAAG,CAAC,OAAO,MAAM,EAAE;AAAA,IACvC;AACA,QAAI,OAAO,QAAQ,QAAW;AAC1B,YAAM,SAASA,UAAAA,SAAS,OAAO,GAAG;AAClC,iBAAW,KAAK,GAAG,CAAC,OAAO,MAAM,EAAE;AAAA,IACvC;AACA,QAAI,OAAO,OAAO,QAAW;AACzB,YAAM,QAAQA,UAAAA,SAAS,OAAO,EAAE;AAChC,iBAAW,KAAK,GAAG,CAAC,MAAM,KAAK,EAAE;AAAA,IACrC;AACA,QAAI,OAAO,OAAO,QAAW;AACzB,YAAM,QAAQA,UAAAA,SAAS,OAAO,EAAE;AAChC,iBAAW,KAAK,GAAG,CAAC,MAAM,KAAK,EAAE;AAAA,IACrC;AAGA,QAAI,OAAO,eAAe,QAAW;AACjC,YAAM,gBAAgBA,UAAAA,SAAS,OAAO,UAAU;AAEhD,iBAAW,KAAK,IAAI,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ACJ;AAAA,EACJ;;AAIJ,SAAS,eAAe,QAAW;AAC/B,QAAM,MAAM,OAAO,QAAQ,SAAYA,UAAAA,SAAS,OAAO,GAAG,IAAI,OAAO;AACrE,QAAM,MAAM,OAAO,QAAQ,SAAYA,UAAAA,SAAS,OAAO,GAAG,IAAI,OAAO;AACrE,QAAM,UAAU,OAAO,KAAK,QAAQ,UAAa,OAAO;AACxD,QAAM,WAAW,OAAO,KAAK,QAAQ,UAAa,OAAO;AACzD,QAAM,WAAW,OAAO,KAAK,QAAQ,UAAa,OAAO;AACzD,QAAM,SAAS,OAAO,QAAQ,QAAQ,UAAa,OAAO;AAC1D,QAAM,UAAU,OAAO,UAAU,QAAQ,UAAa,OAAO;AAC7D,QAAM,UAAU,OAAO,eAAe,QAAQ,UAAa,OAAO;AAClE,SAAO,EAAC,SAAS,UAAU,UAAU,QAAQ,SAAS,QAAA;AAC1D;AAIO,MAAM,4BAA4BG,SAAAA,kBAAkB,IAAI,oBAAA,CAAqB;mGAKrD,IAAE,gBAAA,sBAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.runtype.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"date.runtype.cjs","sources":["../../../../src/string/date.runtype.ts"],"sourcesContent":["/* ########\n * 2025 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\nimport {ReflectionKind} from '@deepkit/type';\nimport type {JitFnCompiler, JitErrorsFnCompiler, BaseRunType, RunTypeOptions, JitCode} from '@mionjs/run-types';\nimport {BaseRunTypeFormat, registerFormatter, TypeFormat} from '@mionjs/run-types'; // !Important: TypeFormat cant be imported as type for all runType functionality to work\nimport {paramVal} from '../utils.ts';\nimport {DateFmt, FormatParams_Date} from '@mionjs/core';\nimport {\n cpf_isDateString_YMD,\n cpf_isDateString_DMY,\n cpf_isDateString_MDY,\n cpf_isDateString_YM,\n cpf_isDateString_MD,\n cpf_isDateString_DM,\n} from '../type-formats-pure-fns.ts';\n\n// Date validator\n/** @reflection never */\nexport class DateStringRunTypeFormat extends BaseRunTypeFormat<FormatParams_Date> {\n static id = 'date' as const;\n kind = ReflectionKind.string;\n name = DateStringRunTypeFormat.id;\n emitIsType(comp: JitFnCompiler, rt: BaseRunType): JitCode {\n const params = this.getParams(rt);\n const formatFn = this.getFormatPureFn(paramVal(params.format));\n return {code: this.compilePureFunctionCall(comp, rt, formatFn).callCode, type: 'E'};\n }\n emitIsTypeErrors(comp: JitErrorsFnCompiler, rt: BaseRunType): JitCode {\n const isTypeCodeObj = this.emitIsType(comp, rt);\n const isTypeCode = isTypeCodeObj.code;\n if (!isTypeCode) return {code: '', type: 'S'};\n const params = this.getParams(rt);\n const errFn = this.getCallJitFormatErr(comp, rt, this);\n return {code: `if (!(${isTypeCode})) ${errFn('format', paramVal(params.format))}`, type: 'S'};\n }\n _mock(opts: RunTypeOptions, rt: BaseRunType) {\n const params = this.getParams(rt);\n const yy = Math.floor(Math.random() * 10000);\n const mm = Math.floor(Math.random() * 12) + 1;\n const dd = Math.floor(Math.random() * getMaxDaysInMonth(yy, mm)) + 1;\n const year = String(yy).padStart(4, '0');\n const month = String(mm).padStart(2, '0');\n const day = String(dd).padStart(2, '0');\n switch (paramVal(params.format)) {\n case 'ISO':\n case 'YYYY-MM-DD':\n return `${year}-${month}-${day}`;\n case 'DD-MM-YYYY':\n return `${day}-${month}-${year}`;\n case 'MM-DD-YYYY':\n return `${month}-${day}-${year}`;\n case 'YYYY-MM':\n return `${year}-${month}`;\n case 'MM-DD':\n return `${month}-${day}`;\n case 'DD-MM':\n return `${day}-${month}`;\n default:\n throw new Error(`Invalid date format: ${paramVal(params.format)}`);\n }\n }\n getFormatPureFn(format: DateFmt) {\n switch (format) {\n case 'ISO':\n case 'YYYY-MM-DD':\n return cpf_isDateString_YMD;\n case 'DD-MM-YYYY':\n return cpf_isDateString_DMY;\n case 'MM-DD-YYYY':\n return cpf_isDateString_MDY;\n case 'YYYY-MM':\n return cpf_isDateString_YM;\n case 'MM-DD':\n return cpf_isDateString_MD;\n case 'DD-MM':\n return cpf_isDateString_DM;\n default:\n throw new Error(`Invalid date format: ${format}`);\n }\n }\n}\n\n/** return the max days in a month taking into account leap years */\n/** @reflection never */\nfunction getMaxDaysInMonth(year: number, month: number): number {\n if (month === 2) {\n // check for leap years\n if (year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)) return 29;\n return 28;\n }\n if (month === 4 || month === 6 || month === 9 || month === 11) return 30;\n return 31;\n}\n\n// ######### Registering the date validator #########\n/** @reflection never */\nexport const DATE_RUN_TYPE_FORMATTER = registerFormatter(new DateStringRunTypeFormat());\n\n// ############### Run Types ###############\n\nexport type DEFAULT_DATE_PARAMS = {format: 'ISO'};\n/** Date string format, always branded with 'date'. */\nexport type FormatStringDate<P extends Partial<FormatParams_Date> = DEFAULT_DATE_PARAMS> = TypeFormat<\n string,\n typeof DateStringRunTypeFormat.id,\n P,\n 'date'\n>;\n"],"names":["BaseRunTypeFormat","ReflectionKind","paramVal","cpf_isDateString_YMD","cpf_isDateString_DMY","cpf_isDateString_MDY","cpf_isDateString_YM","cpf_isDateString_MD","cpf_isDateString_DM","registerFormatter"],"mappings":";;;;;;AAsBM,MAAO,gCAAgCA,SAAAA,kBAAoC;AAAA,EAC7E,OAAO,KAAK;AAAA,EACZ,OAAOC,KAAAA,eAAe;AAAA,EACtB,OAAO,wBAAwB;AAAA,EAC/B,WAAW,MAAqB,IAAe;AAC3C,UAAM,SAAS,KAAK,UAAU,EAAE;AAChC,UAAM,WAAW,KAAK,gBAAgBC,UAAAA,SAAS,OAAO,MAAM,CAAC;AAC7D,WAAO,EAAC,MAAM,KAAK,wBAAwB,MAAM,IAAI,QAAQ,EAAE,UAAU,MAAM,IAAA;AAAA,EACnF;AAAA,EACA,iBAAiB,MAA2B,IAAe;AACvD,UAAM,gBAAgB,KAAK,WAAW,MAAM,EAAE;AAC9C,UAAM,aAAa,cAAc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gBAAgB,QAAe;AAC3B,YAAQ,QAAA;AAAA,MACJ,KAAK;AAAA,MACL,KAAK;AACD,eAAOC,uBAAAA;AAAAA,MACX,KAAK;AACD,eAAOC,uBAAAA;AAAAA,MACX,KAAK;AACD,eAAOC,uBAAAA;AAAAA,MACX,KAAK;AACD,eAAOC,uBAAAA;AAAAA,MACX,KAAK;AACD,eAAOC,uBAAAA;AAAAA,MACX,KAAK;AACD,eAAOC,uBAAAA;AAAAA,MACX;AACI,cAAM,IAAI,MAAM,wBAAwB,MAAM,EAAE;AAAA,IAAA;AAAA,EAE5D;;AAKJ,SAAS,kBAAkB,MAAc,OAAa;AAClD,MAAI,UAAU,GAAG;AAEb,QAAI,OAAO,MAAM,MAAM,OAAO,QAAQ,KAAK,OAAO,QAAQ;AAAI,aAAO;AACrE,WAAO;AAAA,EACX;AACA,MAAI,UAAU,KAAK,UAAU,KAAK,UAAU,KAAK,UAAU;AAAI,WAAO;AACtE,SAAO;AACX;AAIO,MAAM,0BAA0BC,SAAAA,kBAAkB,IAAI,wBAAA,CAAyB;;4HAQnD,IAAE,QAAA,oBAAA,oBAAA;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateTime.runtype.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dateTime.runtype.cjs","sources":["../../../../src/string/dateTime.runtype.ts"],"sourcesContent":["/* ########\n * 2025 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n// !Important: TypeFormat cant be imported as type for the runType functionality to work\nimport type {BaseRunType, JitFnCompiler, JitErrorsFnCompiler, JitCode} from '@mionjs/run-types';\nimport {TypeFormat, RunTypeOptions, BaseRunTypeFormat, registerFormatter} from '@mionjs/run-types';\nimport {ReflectionKind} from '@deepkit/type';\nimport {DEFAULT_DATE_PARAMS, DateStringRunTypeFormat} from './date.runtype.ts';\nimport {FormatParams_DateTime} from '@mionjs/core';\nimport {DEFAULT_TIME_FORMAT_PARAMS, TimeStringRunTypeFormat} from './time.runtype.ts';\nimport {stringIgnoreProps} from './stringFormat.runtype.ts';\nimport {paramVal} from '../utils.ts';\n\n// DateTime validator\n/** @reflection never */\nexport class DateTimeRunTypeFormat extends BaseRunTypeFormat<FormatParams_DateTime> {\n static id = 'dateTime' as const;\n kind = ReflectionKind.string;\n name = DateTimeRunTypeFormat.id;\n dateFormatter: DateStringRunTypeFormat;\n timeFormatter: TimeStringRunTypeFormat;\n\n constructor(parentPath?: string[]) {\n super(parentPath);\n this.dateFormatter = new DateStringRunTypeFormat(this.getFormatPath('date'));\n this.timeFormatter = new TimeStringRunTypeFormat(this.getFormatPath('time'));\n }\n getIgnoredProps(): string[] | undefined {\n return stringIgnoreProps;\n }\n emitIsType(comp: JitFnCompiler, rt: BaseRunType): JitCode {\n const params = this.getParams(rt);\n const fnID = comp.fnID;\n const fmtName = this.getFormatName();\n const vλl = comp.vλl;\n const splitChar = paramVal(params.splitChar);\n const vDatePart = 'datePart' + this.getFormatNestLevel(); // Variable for date part\n const vTimePart = 'timePart' + this.getFormatNestLevel(); // Variable for time part\n const vSplitPos = 'splitPos' + this.getFormatNestLevel(); // Position of split character\n\n // Compile code for root, date part, and time part validation\n const dateCode = this.dateFormatter.compileFormat(fnID, comp, rt, params.date, vDatePart, fmtName);\n const timeCode = this.timeFormatter.compileFormat(fnID, comp, rt, params.time, vTimePart, fmtName);\n\n // If rootCode is empty, we don't need to emit jit code for it\n const returnCode = this.isRootFormat() ? `return true;` : '';\n\n const code = `\n const ${vSplitPos} = ${vλl}.indexOf('${splitChar}');\n if (${vSplitPos} === -1) return false;\n const ${vDatePart} = ${vλl}.substring(0, ${vSplitPos});\n const ${vTimePart} = ${vλl}.substring(${vSplitPos} + 1);\n if (!(${dateCode.code})) return false;\n if (!(${timeCode.code})) return false;\n ${returnCode}\n `;\n return {code, type: 'S'};\n }\n emitIsTypeErrors(comp: JitErrorsFnCompiler, rt: BaseRunType): JitCode {\n const params = this.getParams(rt);\n const fnID = comp.fnID;\n const fmtName = this.getFormatName();\n const splitChar = paramVal(params.splitChar);\n const errFn = this.getCallJitFormatErr(comp, rt, this, false);\n const vλl = comp.vλl;\n const vDatePart = 'datePart'; // Variable for date part\n const vTimePart = 'timePart'; // Variable for time part\n const vSplitPos = 'splitPos'; // Position of split character\n\n // Compile code for root, date part, and time part validation\n const dateCode = this.dateFormatter.compileFormat(fnID, comp, rt, params.date, vDatePart, fmtName);\n const timeCode = this.timeFormatter.compileFormat(fnID, comp, rt, params.time, vTimePart, fmtName);\n\n const code = `\n const ${vSplitPos} = ${vλl}.indexOf('${splitChar}');\n if (${vSplitPos} === -1) ${errFn('splitChar', splitChar)};\n const ${vDatePart} = ${vλl}.substring(0, ${vSplitPos});\n const ${vTimePart} = ${vλl}.substring(${vSplitPos} + 1);\n ${dateCode.code ? `${dateCode.code};` : ''}\n ${timeCode.code ? `${timeCode.code};` : ''}\n `;\n return {code, type: 'S'};\n }\n _mock(opts: RunTypeOptions, rt: BaseRunType): string {\n const params = this.getParams(rt);\n const splitChar = paramVal(params.splitChar);\n\n // Generate date part\n const datePart = this.dateFormatter.mock(opts, rt, params.date);\n\n // Generate time part\n const timePart = this.timeFormatter.mock(opts, rt, params.time);\n\n // Combine to form datetime\n return `${datePart}${splitChar}${timePart}`;\n }\n}\n\n// ######### Registering validator and pure functions ########\n/** @reflection never */\nexport const DATE_TIME_RUN_TYPE_FORMATTER = registerFormatter(new DateTimeRunTypeFormat());\n\n// ############### Run Types ###############\n\nexport type DEFAULT_DATE_TIME_PARAMS = {\n date: DEFAULT_DATE_PARAMS;\n time: DEFAULT_TIME_FORMAT_PARAMS;\n splitChar: 'T';\n};\n\n/** DateTime string format, always branded with 'dateTime'. */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport type FormatStringDateTime<P extends Partial<FormatParams_DateTime> = {}> = TypeFormat<\n string,\n typeof DateTimeRunTypeFormat.id,\n DEFAULT_DATE_TIME_PARAMS & P,\n 'dateTime'\n>;\n"],"names":["BaseRunTypeFormat","ReflectionKind","DateStringRunTypeFormat","TimeStringRunTypeFormat","stringIgnoreProps","paramVal","registerFormatter"],"mappings":";;;;;;;;AAkBM,MAAO,8BAA8BA,SAAAA,kBAAwC;AAAA,EAC/E,OAAO,KAAK;AAAA,EACZ,OAAOC,KAAAA,eAAe;AAAA,EACtB,OAAO,sBAAsB;AAAA,EAC7B;AAAA,EACA;AAAA,EAEA,YAAY,YAAqB;AAC7B,UAAM,UAAU;AAChB,SAAK,gBAAgB,IAAIC,wBAAAA,wBAAwB,KAAK,cAAc,MAAM,CAAC;AAC3E,SAAK,gBAAgB,IAAIC,wBAAAA,wBAAwB,KAAK,cAAc,MAAM,CAAC;AAAA,EAC/E;AAAA,EACA,kBAAe;AACX,WAAOC,gCAAAA;AAAAA,EACX;AAAA,EACA,WAAW,MAAqB,IAAe;AAC3C,UAAM,SAAS,KAAK,UAAU,EAAE;AAChC,UAAM,OAAO,KAAK;AAClB,UAAM,UAAU,KAAK,cAAA;AACrB,UAAM,MAAM,KAAK;AACjB,UAAM,YAAYC,UAAAA,SAAS,OAAO,SAAS;AAC3C,UAAM,YAAY,aAAa,KAAK,mBAAA;AACpC,UAAM,YAAY,aAAa,KAAK,mBAAA;AACpC,UAAM,YAAY,aAAa,KAAK,mBAAA;AAGpC,UAAM,WAAW,KAAK,cAAc,cAAc,MAAM,MAAM,IAAI,OAAO,MAAM,WAAW,OAAO;AACjG,UAAM,WAAW,KAAK,cAAc,cAAc,MAAM,MAAM,IAAI,OAAO,MAAM,WAAW,OAAO;AAGjG,UAAM,aAAa,KAAK,aAAA,IAAiB,iBAAiB;AAE1D,UAAM,OAAO;AAAA,oBACD,SAAS,MAAM,GAAG,aAAa,SAAS;AAAA,kBAC1C,SAAS;AAAA,oBACP,SAAS,MAAM,GAAG,iBAAiB,SAAS;AAAA,oBAC5C,SAAS,MAAM,GAAG,cAAc,SAAS;AAAA,oBACzC,SAAS,IAAI;A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MAAM,+BAA+BC,SAAAA,kBAAkB,IAAI,sBAAA,CAAuB;;gGAcxD,IAAE,MAAA,6BAAA,YAAA,wBAAA,wBAAA;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultStringFormats.runtype.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"defaultStringFormats.runtype.cjs","sources":["../../../../src/string/defaultStringFormats.runtype.ts"],"sourcesContent":["/* ########\n * 2025 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport {FormatString} from './stringFormat.runtype.ts';\nimport {StringParams} from '@mionjs/core';\n\n// ############### Default String Formats ###############\n\nexport const ALPHANUMERIC_REGEX = /^[\\p{L}\\p{N}]+$/u;\nexport const ALPHA_REGEX = /^[\\p{L}]+$/u;\nexport const NUMERIC_REGEX = /^[\\p{N}]+$/u;\n\ntype DEFAULT_ALPHA_NUM_PARAMS = {\n pattern: {\n val: typeof ALPHANUMERIC_REGEX;\n mockSamples: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';\n errorMessage: 'only alphanumeric values are allowed';\n };\n};\ntype DEFAULT_ALPHA_PARAMS = {\n pattern: {\n val: typeof ALPHA_REGEX;\n mockSamples: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';\n errorMessage: 'only alphabetic values are allowed';\n };\n};\ntype DEFAULT_NUMERIC_PARAMS = {\n pattern: {\n val: typeof NUMERIC_REGEX;\n mockSamples: '0123456789';\n errorMessage: 'only numeric values are allowed';\n };\n};\n\n/* eslint-disable @typescript-eslint/no-empty-object-type */\nexport type FormatAlphaNumeric<P extends StringParams = {}> = FormatString<P & DEFAULT_ALPHA_NUM_PARAMS>;\nexport type FormatAlpha<P extends StringParams = {}> = FormatString<P & DEFAULT_ALPHA_PARAMS>;\nexport type FormatNumeric<P extends StringParams = {}> = FormatString<P & DEFAULT_NUMERIC_PARAMS>;\nexport type FormatLowercase<P extends StringParams = {}> = FormatString<P & {lowercase: true}>;\nexport type FormatUppercase<P extends StringParams = {}> = FormatString<P & {uppercase: true}>;\nexport type FormatCapitalize<P extends StringParams = {}> = FormatString<P & {capitalize: true}>;\n"],"names":[],"mappings":";;;AAYO,MAAM,qBAAqB;AAC3B,MAAM,cAAc;AACpB,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain.runtype.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"domain.runtype.cjs","sources":["../../../../src/string/domain.runtype.ts"],"sourcesContent":["/* ########\n * 2025 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\nimport type {BaseRunType, JitFnCompiler, JitErrorsFnCompiler, JitCode, JitFnID, StrNumber} from '@mionjs/run-types';\nimport {\n BaseRunTypeFormat,\n RunTypeOptions,\n TypeFormat,\n registerFormatter,\n random,\n randomItem,\n JitFunctions,\n} from '@mionjs/run-types'; // !Important: TypeFormat cant be imported as type for all runType functionality to work\nimport {ReflectionKind} from '@deepkit/type';\nimport {StringRunTypeFormat, stringIgnoreProps} from './stringFormat.runtype.ts';\nimport {FormatParams_Domain, FormatParams_DomainName, FormatParams_Tld, StringParams, Samples} from '@mionjs/core';\nimport {StringValidators} from '@mionjs/core';\nimport {NAME_CHARS, NAME_SAMPLES, TLD_CHARS, TLD_SAMPLES} from '../constants.mock.ts';\nimport {paramVal} from '../utils.ts';\n\n// latin domain names each domain part must be 61 chars max, tld only supports latin chars\nexport const DOMAIN_PATTERN = /^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,63}$/;\n// unicode domain names each domain part must be 61 chars max, tld only supports latin chars\nexport const DOMAIN_PATTERN_UNICODE = /^(?:[\\p{L}\\p{N}](?:[\\p{L}\\p{N}-]{0,61}[\\p{L}\\p{N}])?\\.)+[a-zA-Z]{2,63}$/u;\n// punycode domain names each domain part must be 61 chars max, tld supports latin, number and hyphens\nexport const DOMAIN_PATTERN_PUNYCODE = /^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z0-9-]{2,63}$/;\nexport const DOMAIN_ALLOWED_CHARS_PATTERN = /^[a-zA-Z0-9-]+$/;\nexport const TLD_ALLOWED_CHARS_PATTERN = /^[a-zA-Z]+(\\.[a-zA-Z]+)?$/;\n\nconst tldAllowedChars: StringValidators['allowedChars'] = {\n val: TLD_CHARS,\n errorMessage: 'only alphabetical characters allowed',\n};\nconst namesAllowedChars: StringValidators['allowedChars'] = {\n val: NAME_CHARS,\n errorMessage: 'only alphabetical characters and hyphens allowed',\n};\n\n// Domain validator\n/** @reflection never */\nexport class DomainRunTypeFormat extends BaseRunTypeFormat<FormatParams_Domain> {\n static id = 'domain' as const;\n kind = ReflectionKind.string;\n name = DomainRunTypeFormat.id;\n\n // Formatter instances as class variables\n private rootFormatter: StringRunTypeFormat;\n private nameFormatter: StringRunTypeFormat;\n private tldFormatter: StringRunTypeFormat;\n\n constructor(parentPath?: StrNumber[]) {\n super(parentPath);\n\n // Initialize formatters in the constructor\n const domainPath = this.getFormatPath();\n const namePath = this.getFormatPath('names');\n const tldPath = this.getFormatPath('tld');\n\n this.rootFormatter = new StringRunTypeFormat(domainPath);\n this.nameFormatter = new StringRunTypeFormat(namePath);\n this.tldFormatter = new StringRunTypeFormat(tldPath);\n }\n canEmbedFormatterCode(fnID: JitFnID, rt: BaseRunType, p?: FormatParams_Domain): boolean {\n const params = p || this.getParams(rt);\n if (fnID === JitFunctions.isType.id || fnID === JitFunctions.typeErrors.id)\n return super.canEmbedFormatterCode(fnID, rt) && !!params.pattern;\n return super.canEmbedFormatterCode(fnID, rt);\n }\n getIgnoredProps(): string[] | undefined {\n return stringIgnoreProps;\n }\n emitIsType(comp: JitFnCompiler, rt: BaseRunType): JitCode {\n const params = this.getParams(rt);\n const fnID = comp.fnID;\n const fmtName = this.getFormatName();\n\n if (params.pattern) return this.rootFormatter.compileFormat(fnID, comp, rt, params, comp.vλl, fmtName);\n\n const vλl = comp.vλl;\n const vName = 'name' + this.getFormatNestLevel(); // must match var name in code\n const vTld = 'tld' + this.getFormatNestLevel(); // must match var name in code\n const vCount = 'count' + this.getFormatNestLevel(); // must match var name in code\n const vStart = 'start' + this.getFormatNestLevel(); // must match var name in code\n const vPos = 'pos' + this.getFormatNestLevel(); // must match var name in code\n\n const rootCode = this.rootFormatter.compileFormat(fnID, comp, rt, params, vλl, fmtName);\n const nameCode = this.nameFormatter.compileFormat(fnID, comp, rt, params.names, vName, fmtName);\n const tldCode = this.tldFormatter.compileFormat(fnID, comp, rt, params.tld, vTld, fmtName);\n const maxPartsCode = params.maxParts ? `if (${vCount} > ${params.maxParts}) return false;` : '';\n const minPartsCode = params.minParts ? `if (${vCount} < ${params.minParts}) return false;` : '';\n // if rootCode is empty, we don't need to emit jit code for it\n const rootSafeCode = rootCode.code ? `if (!(${rootCode.code})) return false;` : '';\n const tldSafeCode = tldCode.code\n ? `const ${vTld} = ${vλl}.substring(${vStart}); if (!(${tldCode.code})) return false;`\n : '';\n const returnCode = this.isRootFormat() ? `return true;` : '';\n const skipCount = !maxPartsCode && !minPartsCode && !tldCode.code;\n const code = `\n ${rootSafeCode}\n let ${vCount} = 1; let ${vStart} = 0; let ${vPos}; let ${vName};\n while ((${vPos} = ${vλl}.indexOf('.', ${vStart})) !== -1) {\n ${vName} = ${vλl}.substring(${vStart}, ${vPos});\n ${!params.names?.allowedValues ? `if (${vName}.startsWith('-') || ${vName}.endsWith('-')) return false;` : ''}\n if (!(${nameCode.code})) return false;\n ${vStart} = ${vPos} + 1;\n ${!skipCount ? `${vCount}++;` : ''}\n }\n ${maxPartsCode}\n ${minPartsCode}\n ${tldSafeCode}\n ${returnCode}\n `;\n return {code, type: 'S'};\n }\n emitIsTypeErrors(comp: JitErrorsFnCompiler, rt: BaseRunType): JitCode {\n const params = this.getParams(rt);\n const fnID = comp.fnID;\n const fmtName = this.getFormatName();\n\n if (params.pattern) return this.rootFormatter.compileFormat(fnID, comp, rt, params, comp.vλl, fmtName);\n\n const errFn = this.getCallJitFormatErr(comp, rt, this, false);\n const vλl = comp.vλl;\n const vName = 'name' + this.getFormatNestLevel(); // must match var name in code\n const vTld = 'tld' + this.getFormatNestLevel(); // must match var name in code\n const vCount = 'count' + this.getFormatNestLevel(); // must match var name in code\n const vStart = 'start' + this.getFormatNestLevel(); // must match var name in code\n const vPos = 'pos' + this.getFormatNestLevel(); // must match var name in code\n\n const rootCode = this.rootFormatter.compileFormat(fnID, comp, rt, params, vλl, fmtName);\n const nameCode = this.nameFormatter.compileFormat(fnID, comp, rt, params.names, vName, fmtName, vCount);\n const tldCode = this.tldFormatter.compileFormat(fnID, comp, rt, params.tld, vTld, fmtName);\n const maxPartsCode = params.maxParts\n ? `if (${vCount} > ${params.maxParts}) ${errFn('maxParts', paramVal(params.maxParts))};`\n : '';\n const minPartsCode = params.minParts\n ? `if (${vCount} < ${params.minParts}) ${errFn('minParts', paramVal(params.minParts))};`\n : '';\n\n const tldSafeCode = tldCode.code ? `const ${vTld} = ${vλl}.substring(${vStart}); ${tldCode.code};` : '';\n const skipCount = !maxPartsCode && !minPartsCode && !tldCode.code;\n const code = `\n ${rootCode.code};\n let ${vCount} = 0; let ${vStart} = 0; let ${vPos}; let ${vName};\n while ((${vPos} = ${vλl}.indexOf('.', ${vStart})) !== -1) {\n ${vName} = ${vλl}.substring(${vStart}, ${vPos});\n ${!params.names?.allowedValues ? `if (${vName}.startsWith('-') || ${vName}.endsWith('-')) ${errFn('hyphen', 'name')};` : ''}\n ${nameCode.code};\n ${vStart} = ${vPos} + 1;\n ${!skipCount ? `${vCount}++;` : ''}\n }\n ${!skipCount ? `${vCount}++;` : ''}\n ${maxPartsCode}\n ${minPartsCode}\n ${tldSafeCode};\n `;\n return {code, type: 'S'};\n }\n _mock(opts: RunTypeOptions, rt: BaseRunType): string {\n const params = this.getParams(rt);\n if (params.pattern) return this.rootFormatter.mock(opts, rt, params);\n\n const maxParts = paramVal(params.maxParts || 6);\n const minParts = paramVal(params.minParts || 2);\n const maxLength = paramVal(params.maxLength || 253);\n const minLength = paramVal(params.minLength || 3);\n let tld = this.mockTld(opts, rt, params.tld as FormatParams_Tld);\n const tldParts = tld.split('.');\n // ensure tld is not too long\n while (tldParts.length > 1 && tldParts.length >= maxParts) tldParts.shift();\n tld = tldParts.join('.');\n\n // force generating only one domain name more often\n const singleNameMax = tldParts.length + 1;\n // reduce probability of generating many subdomains\n const noNormalMax = Math.random() < 0.2 ? maxParts : singleNameMax;\n const maxRandom = noNormalMax - tldParts.length;\n const minRandom = minParts - paramVal(tldParts.length);\n const maxRandomParts = random(minRandom, maxRandom);\n const parts: string[] = [];\n\n parts.push(this.mockName(opts, rt, params.names as FormatParams_DomainName));\n let name = parts[0];\n let domain = `${name}.${tld}`;\n\n // keep adding names until we reach maxRandom or maxes are reached\n while ((domain.length < maxLength && parts.length < maxRandomParts) || domain.length < minLength) {\n parts.push(this.mockName(opts, rt, params.names as FormatParams_DomainName));\n name = parts.join('.');\n domain = `${name}.${tld}`;\n }\n\n return domain;\n }\n private hasNoConstrains(params: StringParams): boolean {\n return !params.allowedChars && !params.disallowedChars && !params.pattern && !params.allowedValues;\n }\n private mockName(opts: RunTypeOptions, rt: BaseRunType, params: FormatParams_DomainName): string {\n const hasParams = !!Object.keys(params).length;\n if (!hasParams) return randomItem(NAME_SAMPLES);\n const defaultParams = {\n ...params,\n maxLength: params.maxLength ?? 63,\n minLength: params.minLength ?? 2,\n pattern: params.pattern,\n allowedValues: params.allowedValues,\n disallowedValues: params.disallowedValues,\n allowedChars: this.hasNoConstrains(params) ? namesAllowedChars : undefined,\n };\n return this.nameFormatter.mock(opts, rt, defaultParams);\n }\n private mockTld(opts: RunTypeOptions, rt: BaseRunType, params: FormatParams_Tld): string {\n const hasParams = !!Object.keys(params).length;\n if (!hasParams) return randomItem(TLD_SAMPLES);\n const defaultParams = {\n ...params,\n maxLength: params.maxLength ?? 12,\n minLength: params.minLength ?? 2,\n pattern: params.pattern,\n allowedValues: params.allowedValues,\n disallowedValues: params.disallowedValues,\n allowedChars: this.hasNoConstrains(params) ? tldAllowedChars : undefined,\n };\n return this.tldFormatter.mock(opts, rt, defaultParams);\n }\n emitFormat(comp: JitFnCompiler): JitCode {\n return {code: `${comp.vλl}.toLowerCase()`, type: 'E'}; // all domain are lower case\n }\n _formatMockedValue(opts: RunTypeOptions, _rt: BaseRunType, val: any): string {\n return val.toLowerCase();\n }\n validateParams(rt: BaseRunType, params: FormatParams_Domain) {\n const onlyOne = [params.names, params.pattern].filter(Boolean);\n if (onlyOne.length > 1)\n throw new Error(`Domain can only have one of (names & tld), pattern or allowedValues in type ${this.printPath(rt)}`);\n if (params.maxLength && paramVal(params.maxLength) > 253)\n throw new Error(`Domain maxLength cannot be greater than 253 in type ${this.printPath(rt, 'maxLength')}`);\n if (params.minLength && paramVal(params.minLength) < 3)\n throw new Error(`Domain minLength cannot be less than 3 in type ${this.printPath(rt, 'minLength')}`);\n if (params.minParts && paramVal(params.minParts) < 2)\n throw new Error(`Domain minParts cannot be less than 2 in type ${this.printPath(rt, 'minParts')}`);\n if (params.maxParts && paramVal(params.maxParts) < 2)\n throw new Error(`Domain maxParts cannot be less than 2 in type ${this.printPath(rt, 'maxParts')}`);\n if ((params.names && !params.tld) || (!params.names && params.tld))\n throw new Error(`Domain names and tld must be used together in type ${this.printPath(rt, 'maxParts')}`);\n if (params.tld && params.tld.minLength && paramVal(params.tld.minLength) < 2)\n throw new Error(`Domain tld.minLength cannot be less than 2 in type ${this.printPath(rt, 'tld.minLength')}`);\n if (params.tld && params.tld.maxLength && paramVal(params.tld.maxLength) > 63)\n throw new Error(`Domain tld.maxLength cannot be greater than 63 in type ${this.printPath(rt, 'tld.maxLength')}`);\n if (params.names && params.names.maxLength && paramVal(params.names.maxLength) > 63)\n throw new Error(`Domain names.maxLength cannot be greater than 63 in type ${this.printPath(rt, 'names.maxLength')}`);\n\n this.rootFormatter.validateParams(rt, params);\n\n if (params.names?.allowedValues)\n params.names?.allowedValues.val.forEach((val) => {\n if (val.startsWith('-') || val.endsWith('-'))\n throw new Error(\n `allowedValues[${val}] can not start or end with a hyphen in type ${this.printPath(rt, 'names.allowedValues')}`\n );\n });\n if (params.names) {\n if (Object.values(params.names).length === 0)\n throw new Error(`Domain names must have at least one validator in type ${this.printPath(rt, 'names')}`);\n this.nameFormatter.validateParams(rt, params.names);\n }\n if (params.tld) {\n if (Object.values(params.tld).length === 0)\n throw new Error(`Domain tld must have at least one validator in type ${this.printPath(rt, 'tld')}`);\n this.tldFormatter.validateParams(rt, params.tld);\n }\n }\n}\n\n// ############### Register runtypes ###############\n\n// register Validator operations so they can be used in the jit compiler\n/** @reflection never */\nexport const DOMAIN_RUN_TYPE_FORMATTER = registerFormatter(new DomainRunTypeFormat());\n\n// ############### Type Params ###############\n\nexport type DEFAULT_DOMAIN_PARAMS<\n P extends RegExp = typeof DOMAIN_PATTERN,\n S extends Samples = ['ggle.com', 'mion.io', 'mionkit.io', 'yahuu.net', 'fbook.com', 'wiki.org', 'ms.net'],\n> = {\n maxLength: 253;\n minLength: 5; // name 2 + tld 2 + 1 dot\n pattern: {\n val: P;\n mockSamples: S;\n errorMessage: 'invalid domain';\n };\n};\nexport type DEFAULT_DMM_TLD_PARAMS<\n P extends RegExp = typeof TLD_ALLOWED_CHARS_PATTERN,\n S extends Samples = ['com', 'org', 'net', 'io', 'app', 'co', 'dev', 'tech', 'ai', 'mion', 'co.uk', 'com.au', 'com.br'],\n> = {\n maxLength: 12; // technical TLD max length is 63, but rarely is more than 12, as single words are the most common\n minLength: 2;\n pattern: {\n val: P;\n mockSamples: S;\n errorMessage: 'top level domain can only contain letters and dots';\n };\n};\nexport type DEFAULT_DOM_NAME_PARAMS<\n P extends RegExp = typeof DOMAIN_ALLOWED_CHARS_PATTERN,\n S extends Samples = ['domain', 'ggle', 'fbook', 'mion', 'prot', 'yahuu', 'hello', 'world', 'example', 'wiki', 'mionkit'],\n> = {\n maxLength: 63;\n minLength: 2;\n pattern: {\n val: P;\n mockSamples: S;\n errorMessage: 'domain names can only contain letters, numbers and hyphens';\n };\n};\nexport type DEFAULT_STRICT_DOMAIN_PARAMS = {\n // officially max subdomains is 127, but practically there is never more than 4 or 5, so better default to something smaller\n maxParts: 6;\n minParts: 2;\n names: DEFAULT_DOM_NAME_PARAMS;\n tld: DEFAULT_DMM_TLD_PARAMS;\n maxLength: 253;\n minLength: 5; // name 2 + tld 2 + 1 dot\n};\n// ############### Run Types ###############\n\n/** Domain based on a pattern, always branded with 'domain'. */\nexport type FormatDomain<DP extends FormatParams_Domain = DEFAULT_DOMAIN_PARAMS> = TypeFormat<string, 'domain', DP, 'domain'>;\n/** Domain with customizable names and tld, always branded with 'domain'. */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport type FormatDomainStrict<D extends Partial<FormatParams_Domain> = {}> = FormatDomain<DEFAULT_STRICT_DOMAIN_PARAMS & D>;\n"],"names":["TLD_CHARS","NAME_CHARS","BaseRunTypeFormat","ReflectionKind","StringRunTypeFormat","JitFunctions","stringIgnoreProps","paramVal","random","randomItem","NAME_SAMPLES","TLD_SAMPLES","registerFormatter"],"mappings":";;;;;;;AAwBO,MAAM,iBAAiB;AAEvB,MAAM,yBAAyB;AAE/B,MA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;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.runtype.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"email.runtype.cjs","sources":["../../../../src/string/email.runtype.ts"],"sourcesContent":["/* ########\n * 2025 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\nimport type {BaseRunType, JitFnCompiler, JitErrorsFnCompiler, StrNumber, JitFnID, JitCode} from '@mionjs/run-types';\nimport {BaseRunTypeFormat, TypeFormat, RunTypeOptions, registerFormatter, JitFunctions, randomItem} from '@mionjs/run-types';\nimport {ReflectionKind} from '@deepkit/type';\nimport {DEFAULT_STRICT_DOMAIN_PARAMS} from './domain.runtype.ts';\nimport {FormatParams_Email} from '@mionjs/core';\nimport {StringRunTypeFormat, stringIgnoreProps} from './stringFormat.runtype.ts';\nimport {StringValidators} from '@mionjs/core';\nimport {Samples} from '@mionjs/core';\nimport {DomainRunTypeFormat} from './domain.runtype.ts';\nimport {EMAIL_NAME_SAMPLES_ARRAY, EMAIL_NAME_SAMPLES, EMAIL_SAMPLES, EMAIL_SAMPLES_PUNYCODE} from '../constants.mock.ts'; // do not import using type\nimport {paramVal} from '../utils.ts';\n\n// Email pattern, allows punycode domains\nexport const EMAIL_PATTERN = /^[^\\s@]{1,64}@(?:[a-zA-Z0-9-]{1,63}\\.)+[a-zA-Z]{2,63}$/;\nexport const EMAIL_PATTERN_PUNYCODE = /^[^\\s@]{1,64}@(?:[a-zA-Z0-9-]{1,63}\\.)+[a-zA-Z0-9-]{2,63}$/;\n\n// Email validator\n/** @reflection never */\nexport class EmailRunTypeFormat extends BaseRunTypeFormat<FormatParams_Email> {\n static id = 'email';\n kind = ReflectionKind.string;\n name = EmailRunTypeFormat.id;\n // Formatter instances as class variables\n private rootFormatter: StringRunTypeFormat;\n private domainFormatter: DomainRunTypeFormat;\n private localPartFormatter: StringRunTypeFormat;\n\n constructor(parentPath?: StrNumber[]) {\n super(parentPath);\n\n this.rootFormatter = new StringRunTypeFormat(this.getFormatPath());\n this.domainFormatter = new DomainRunTypeFormat(this.getFormatPath('domain'));\n this.localPartFormatter = new StringRunTypeFormat(this.getFormatPath('localPart'));\n }\n getIgnoredProps(): string[] | undefined {\n return stringIgnoreProps;\n }\n canEmbedFormatterCode(fnID: JitFnID, rt: BaseRunType, p?: FormatParams_Email): boolean {\n const params = p || this.getParams(rt);\n if (fnID === JitFunctions.isType.id || fnID === JitFunctions.typeErrors.id) {\n const superResult = super.canEmbedFormatterCode(fnID, rt);\n const domainResult = params.domain ? this.domainFormatter.canEmbedFormatterCode(fnID, rt, params.domain) : false;\n return superResult && (!!params.pattern || domainResult);\n }\n return super.canEmbedFormatterCode(fnID, rt);\n }\n emitIsType(comp: JitFnCompiler, rt: BaseRunType): JitCode {\n const params = this.getParams(rt);\n const fnID = comp.fnID;\n const fmtName = this.getFormatName();\n\n // If pattern is provided, use the root formatter\n if (params.pattern) return this.rootFormatter.compileFormat(fnID, comp, rt, params, comp.vλl, fmtName);\n\n const vλl = comp.vλl;\n const vLocalPart = 'localPart' + this.getFormatNestLevel(); // Variable for local part\n const vDomain = 'domain' + this.getFormatNestLevel(); // Variable for domain\n const vAtPos = 'atPos' + this.getFormatNestLevel(); // Position of @ symbol\n\n // Compile code for root, local part, and domain validation\n const rootCode = this.rootFormatter.compileFormat(fnID, comp, rt, params, vλl, fmtName);\n const localPartCode = this.localPartFormatter.compileFormat(fnID, comp, rt, params.localPart, vLocalPart, fmtName);\n const domainCode = this.domainFormatter.compileFormat(fnID, comp, rt, params.domain, vDomain, fmtName);\n\n // If rootCode is empty, we don't need to emit jit code for it\n const rootSafeCode = rootCode.code ? `if (!(${rootCode.code})) return false;` : '';\n const returnCode = this.isRootFormat() ? `return true;` : '';\n const domainIsExpression = domainCode.type === 'E';\n const domainSafeCode =\n domainCode.code && domainIsExpression ? `if (!(${domainCode.code})) return false;` : domainCode.code;\n\n const code = `\n ${rootSafeCode}\n const ${vAtPos} = ${vλl}.lastIndexOf('@');\n if (${vAtPos} === -1) return false;\n const ${vLocalPart} = ${vλl}.substring(0, ${vAtPos});\n const ${vDomain} = ${vλl}.substring(${vAtPos} + 1);\n if (!(${localPartCode.code})) return false;\n ${domainSafeCode}\n ${returnCode}\n `;\n return {code, type: 'S'};\n }\n emitIsTypeErrors(comp: JitErrorsFnCompiler, rt: BaseRunType): JitCode {\n const params = this.getParams(rt);\n const fnID = comp.fnID;\n const fmtName = this.getFormatName();\n\n // If pattern is provided, use the root formatter\n if (params.pattern) return this.rootFormatter.compileFormat(fnID, comp, rt, params, comp.vλl, fmtName);\n\n const errFn = this.getCallJitFormatErr(comp, rt, this, false);\n const vλl = comp.vλl;\n const vLocalPart = 'localPart'; // Variable for local part\n const vDomain = 'domain'; // Variable for domain\n const vAtPos = 'atPos'; // Position of @ symbol\n\n // Compile code for root, local part, and domain validation\n const rootCode = this.rootFormatter.compileFormat(fnID, comp, rt, params, vλl, fmtName);\n const localPartCode = this.localPartFormatter.compileFormat(fnID, comp, rt, params.localPart, vLocalPart, fmtName);\n const domainCode = this.domainFormatter.compileFormat(fnID, comp, rt, params.domain, vDomain, fmtName);\n\n const code = `\n ${rootCode.code ? `${rootCode.code};` : ''}\n const ${vAtPos} = ${vλl}.lastIndexOf('@');\n if (${vAtPos} === -1) ${errFn('@', 'Email missing @ symbol')};\n const ${vLocalPart} = ${vλl}.substring(0, ${vAtPos});\n const ${vDomain} = ${vλl}.substring(${vAtPos} + 1);\n ${localPartCode.code ? `${localPartCode.code};` : ''}\n ${domainCode.code ? `${domainCode.code};` : ''}\n `;\n return {code, type: 'S'};\n }\n _mock(opts: RunTypeOptions, rt: BaseRunType): string {\n const params = this.getParams(rt);\n\n // If pattern is provided, use the root formatter\n if (params.pattern) return this.rootFormatter.mock(opts, rt, params);\n\n // Generate local part\n const localPart = this.mockLocalPart(opts, rt, params.localPart as StringValidators);\n\n // Generate domain\n const domain = this.domainFormatter.mock(opts, rt, params.domain);\n\n // Combine to form email\n return `${localPart}@${domain}`;\n }\n\n private mockLocalPart(opts: RunTypeOptions, rt: BaseRunType, params: StringValidators): string {\n const hasParams = !!Object.keys(params).length;\n if (!hasParams) return randomItem(EMAIL_NAME_SAMPLES_ARRAY);\n\n const defaultParams = {\n ...params,\n maxLength: params.maxLength ?? 64,\n minLength: params.minLength ?? 1,\n };\n\n return this.localPartFormatter.mock(opts, rt, defaultParams);\n }\n emitFormat(comp: JitFnCompiler): JitCode {\n return {code: `${comp.vλl}.toLowerCase()`, type: 'E'};\n }\n\n validateParams(rt: BaseRunType, params: FormatParams_Email) {\n // Check if pattern and localPart/domain are mutually exclusive\n const hasPattern = !!params.pattern;\n const hasLocalPartOrDomain = !!params.localPart || !!params.domain;\n\n if (hasPattern && hasLocalPartOrDomain)\n throw new Error(`Email can only have either pattern or (localPart and domain) in type ${this.printPath(rt)}`);\n if ((params.localPart && !params.domain) || (!params.localPart && params.domain))\n throw new Error(`Email localPart and domain must be used together in type ${this.printPath(rt)}`);\n if (params.maxLength && paramVal(params.maxLength) > 254)\n throw new Error(`Email maxLength cannot be greater than 254 in type ${this.printPath(rt, 'maxLength')}`);\n if (params.minLength && paramVal(params.minLength) < 7)\n throw new Error(`Email minLength cannot be less than 7 in type ${this.printPath(rt, 'minLength')}`);\n\n this.rootFormatter.validateParams(rt, params);\n\n if (params.localPart) {\n if (Object.values(params.localPart).length === 0)\n throw new Error(`Email localPart must have at least one validator in type ${this.printPath(rt, 'localPart')}`);\n if (params.localPart.maxLength && paramVal(params.localPart.maxLength) > 64)\n throw new Error(\n `Email localPart.maxLength cannot be greater than 64 in type ${this.printPath(rt, 'localPart.maxLength')}`\n );\n if (params.localPart.minLength && paramVal(params.localPart.minLength) < 1)\n throw new Error(\n `Email localPart.minLength cannot be less than 1 in type ${this.printPath(rt, 'localPart.minLength')}`\n );\n this.localPartFormatter.validateParams(rt, params.localPart);\n }\n if (params.domain) {\n if (Object.values(params.domain).length === 0) {\n throw new Error(`Email domain must have at least one validator in type ${this.printPath(rt, 'domain')}`);\n }\n this.domainFormatter.validateParams(rt, params.domain);\n }\n }\n}\n\n// ######### Registering validator and pure functions ########\n/** @reflection never */\nexport const EMAIL_RUN_TYPE_FORMATTER = registerFormatter(new EmailRunTypeFormat());\n\n// ############### Type ###############\n\nexport type DEFAULT_STRICT_EMAIL_PARAMS = {\n maxLength: 254;\n localPart: {\n maxLength: 64;\n minLength: 1;\n /** Disallows non typical email chars\n * avoiding the character + prevents aliasing used in goggle and other providers\n * characters . and @ are allowed as are typically used\n * */\n disallowedChars: {\n val: ` ()<>[]:;\\\\,{}|+@`;\n errorMessage: 'Invalid characters in email local part';\n mockSamples: EMAIL_NAME_SAMPLES;\n };\n };\n domain: DEFAULT_STRICT_DOMAIN_PARAMS;\n};\n\nexport type DEFAULT_EMAIL_PARAMS<\n EmailPattern extends RegExp = typeof EMAIL_PATTERN,\n MockSamples extends Samples = EMAIL_SAMPLES,\n> = {\n maxLength: 254;\n minLength: 7;\n pattern: {\n val: EmailPattern;\n mockSamples: MockSamples;\n errorMessage: 'Invalid email format';\n };\n};\n\n/** Email format, always branded with 'email'. */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport type FormatEmail<EP extends FormatParams_Email = DEFAULT_EMAIL_PARAMS> = TypeFormat<string, 'email', EP, 'email'>;\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport type FormatEmailStrict<E extends Partial<FormatParams_Email> = {}> = FormatEmail<DEFAULT_STRICT_EMAIL_PARAMS & E>;\nexport type FormatEmailPattern<EmailPattern extends RegExp, MockSamples extends Samples> = FormatEmail<\n DEFAULT_EMAIL_PARAMS<EmailPattern, MockSamples>\n>;\nexport type FormatEmailPunycode = FormatEmailPattern<typeof EMAIL_PATTERN_PUNYCODE, EMAIL_SAMPLES_PUNYCODE>;\n"],"names":["BaseRunTypeFormat","ReflectionKind","StringRunTypeFormat","DomainRunTypeFormat","stringIgnoreProps","JitFunctions","randomItem","EMAIL_NAME_SAMPLES_ARRAY","paramVal","registerFormatter"],"mappings":";;;;;;;;AAmBO,MAAM,gBAAgB;AACtB,MAAM,yBAAyB;AAIhC,MAAO,2BAA2BA,SAAAA,kBAAqC;AAAA,EACzE,OAAO,KAAK;AAAA,EACZ,OAAOC,KAAAA,eAAe;AAAA,EACtB,OAAO,mBAAmB;AAAA;AAAA,EAElB;AAAA,EACA;AAAA,EACA;AAAA,EAER,YAAY,YAAwB;AAChC,UAAM,UAAU;AAEhB,SAAK,gBAAgB,IAAIC,gCAAAA,oBAAoB,KAAK,eAAe;AACjE,SAAK,kBAAkB,IAAIC,0BAAAA,oBAAoB,KAAK,cAAc,QAAQ,CAAC;AAC3E,SAAK,qBAAqB,IAAID,gCAAAA,oBAAoB,KAAK,cAAc,WAAW,CAAC;AAAA,EACrF;AAAA,EACA,kBAAe;AACX,WAAOE,gCAAAA;AAAAA,EACX;AAAA,EACA,sBAAsB,MAAe,IAAiB,GAAsB;AACxE,UAAM,SAAS,KAAK,KAAK,UAAU,EAAE;AACrC,QAAI,SAASC,SAAAA,aAAa,OAAO,MAAM,SAASA,SAAAA,aAAa,WAAW,IAAI;AACxE,YAAM,cAAc,MAAM,sBAAsB,MAAM,EAAE;AACxD,YAAM,eAAe,OAAO,SAAS,KAAK,gBAAgB,sBAAsB,MAAM,IAAI,OAAO,MAAM,IAAI;AAC3G,aAAO,gBAAgB,CAAC,CAAC,OAAO,WAAW;AAAA,IAC/C;AACA,WAAO,MAAM,sBAAsB,MAAM,EAAE;AAAA,EAC/C;AAAA,EACA,WAAW,MAAqB,IAAe;AAC3C,UAAM,SAAS,KAAK,UAAU,EAAE;AAChC,UAAM,OAAO,KAAK;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AO,UAAU,SAAS,IAAI;AACrE,cAAM,IAAI,MACN,2DAA2D,KAAK,UAAU,IAAI,qBAAqB,CAAC,EAAE;AAE9G,WAAK,mBAAmB,eAAe,IAAI,OAAO,SAAS;AAAA,IAC/D;AACA,QAAI,OAAO,QAAQ;AACf,UAAI,OAAO,OAAO,OAAO,MAAM,EAAE,WAAW,GAAG;AAC3C,cAAM,IAAI,MAAM,yDAAyD,KAAK,UAAU,IAAI,QAAQ,CAAC,EAAE;AAAA,MAC3G;AACA,WAAK,gBAAgB,eAAe,IAAI,OAAO,MAAM;AAAA,IACzD;AAAA,EACJ;;AAKG,MAAM,2BAA2BC,SAAAA,kBAAkB,IAAI,mBAAA,CAAoB;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ip.runtype.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ip.runtype.cjs","sources":["../../../../src/string/ip.runtype.ts"],"sourcesContent":["/* ########\n * 2025 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport type {BaseRunType, JitFnCompiler, JitErrorsFnCompiler, RunTypeOptions, JitCode} from '@mionjs/run-types';\nimport {BaseRunTypeFormat, TypeFormat, registerFormatter} from '@mionjs/run-types';\nimport {ReflectionKind} from '@deepkit/type';\nimport {paramVal} from '../utils.ts';\nimport {FormatParams_IP} from '@mionjs/core';\nimport {cpf_isIPV4, cpf_isIPV6} from '../type-formats-pure-fns.ts';\n\n// IP validator\n/** @reflection never */\nexport class IPRunTypeFormat extends BaseRunTypeFormat<FormatParams_IP> {\n static id = 'ip';\n kind = ReflectionKind.string;\n name = IPRunTypeFormat.id;\n emitIsType(comp: JitFnCompiler, rt: BaseRunType): JitCode {\n const params = this.getParams(rt);\n if (params.version === 4) return {code: this.compilePureFunctionCall(comp, rt, cpf_isIPV4).callCode, type: 'E'};\n if (params.version === 6) return {code: this.compilePureFunctionCall(comp, rt, cpf_isIPV6).callCode, type: 'E'};\n return {\n code: `${this.compilePureFunctionCall(comp, rt, cpf_isIPV4).callCode} || ${this.compilePureFunctionCall(comp, rt, cpf_isIPV6).callCode}`,\n type: 'E',\n };\n }\n _mock(opts: RunTypeOptions, rt: BaseRunType) {\n const params = this.getParams(rt);\n if (params.version === 4) return mockIpV4(params);\n if (params.version === 6) return mockIpV6(params);\n return Math.random() > 0.5 ? mockIpV4(params) : mockIpV6(params);\n }\n emitIsTypeErrors(comp: JitErrorsFnCompiler, rt: BaseRunType): JitCode {\n const isTypeCodeObj = this.emitIsType(comp, rt);\n const isTypeCode = isTypeCodeObj.code;\n if (!isTypeCode) return {code: '', type: 'S'};\n const params = this.getParams(rt);\n const errFn = this.getCallJitFormatErr(comp, rt, this);\n return {code: `if (!(${isTypeCode})) ${errFn('version', paramVal(params.version))}`, type: 'S'};\n }\n emitFormat(comp: JitFnCompiler): JitCode {\n return {code: `${comp.vλl}.toLowerCase()`, type: 'E'}; // transform to lowercase in case it is localhost\n }\n}\n\n// ############### Mock Functions ###############\n/** @reflection never */\nexport function mockIpV4(p: FormatParams_IP): string {\n const r = Math.random();\n if (p.allowLocalHost && r > 0.8) return Math.random() > 0.5 ? 'localhost' : '127:0:0:1';\n return Array.from({length: 4}, () => Math.floor(Math.random() * 256)).join('.');\n}\n/** @reflection never */\nexport function mockIpV6(p: FormatParams_IP): string {\n if (p.allowLocalHost && Math.random() > 0.8) return Math.random() > 0.5 ? '0:0:0:0:0:0:0:1' : '::1';\n return Array.from({length: 8}, () => Math.floor(Math.random() * 0xffff).toString(16)).join(':');\n}\n\n// ############### Register runtypes ###############\n\n// register Validator operations so they can be used in the jit compiler\n/** @reflection never */\nexport const IP_RUN_TYPE_FORMATTER = registerFormatter(new IPRunTypeFormat());\n\n// ############### Type ###############\n\ntype DEFAULT_IP_PARAMS = {\n version: 'any';\n allowLocalHost: true;\n};\n\n/** IP address format, always branded with 'ip'. */\nexport type FormatIP<P extends FormatParams_IP = DEFAULT_IP_PARAMS> = TypeFormat<string, 'ip', P, 'ip'>;\nexport type FormatIPv4 = FormatIP<{version: 4; allowLocalHost: true}>;\nexport type FormatIPv6 = FormatIP<{version: 6; allowLocalHost: true}>;\nexport type FormatIPWithPort = FormatIP<{version: 'any'; allowLocalHost: true; allowPort: true}>;\nexport type FormatIPv4WithPort = FormatIP<{version: 4; allowLocalHost: true; allowPort: true}>;\nexport type FormatIPv6WithPort = FormatIP<{version: 6; allowLocalHost: true; allowPort: true}>;\n"],"names":["BaseRunTypeFormat","ReflectionKind","cpf_isIPV4","cpf_isIPV6","paramVal","registerFormatter"],"mappings":";;;;;;AAgBM,MAAO,wBAAwBA,SAAAA,kBAAkC;AAAA,EACnE,OAAO,KAAK;AAAA,EACZ,OAAOC,KAAAA,eAAe;AAAA,EACtB,OAAO,gBAAgB;AAAA,EACvB,WAAW,MAAqB,IAAe;AAC3C,UAAM,SAAS,KAAK,UAAU,EAAE;AAChC,QAAI,OAAO,YAAY;AAAG,aAAO,EAAC,MAAM,KAAK,wBAAwB,MAAM,IAAIC,uBAAAA,UAAU,EAAE,UAAU,MAAM,IAAA;AAC3G,QAAI,OAAO,YAAY;AAAG,aAAO,EAAC,MAAM,KAAK,wBAAwB,MAAM,IAAIC,uBAAAA,UAAU,EAAE,UAAU,MAAM,IAAA;AAC3G,WAAO;AAAA,MACH,MAAM,GAAG,KAAK,wBAAwB,MAAM,IAAID,uBAAAA,UAAU,EAAE,QAAQ,OAAO,KAAK,wBAAwB,MAAM,IAAIC,uBAAAA,UAAU,EAAE,QAAQ;AAAA,MACtI,MAAM;AAAA,IAAA;AAAA,EAEd;AAAA,EACA,MAAM,MAAsB,IAAe;AACvC,UAAM,SAAS,KAAK,UAAU,EAAE;AAChC,QAAI,OAAO,YAAY;AAAG,aAAO,SAAS,MAAM;AAChD,QAAI,OAAO,YAAY;AAAG,aAAO,SAAS,MAAM;AAChD,WAAO,KAAK,WAAW,MAAM,SAAS,MAAM,IA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"stringFormat.runtype.cjs","sources":["../../../../src/string/stringFormat.runtype.ts"],"sourcesContent":["/* ########\n * 2025 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport type {BaseRunType, JitFnCompiler, JitErrorsFnCompiler, JitCode} from '@mionjs/run-types';\nimport {TypeFormat, registerFormatter, getToLiteralFn, BaseRunTypeFormat, RunTypeOptions} from '@mionjs/run-types'; // !Important: TypeFormat cant be imported as type for all runType functionality to work\nimport {ReflectionKind} from '@deepkit/type';\nimport {mockString, random, randomItem} from '@mionjs/run-types';\nimport {paramVal, regexpEscape} from '../utils.ts';\nimport {FormatParam_Pattern, StringParams} from '@mionjs/core';\n\nconst defaultMessages = {\n allowedChars: 'Invalid characters',\n disallowedChars: 'Invalid characters',\n allowedValues: 'Invalid value',\n disallowedValues: 'Invalid value',\n pattern: 'Invalid pattern',\n};\nconst propsWithRequiredSamples = ['disallowedChars', 'disallowedChars', 'pattern'];\nexport const stringIgnoreProps = ['samples', 'sampleChars'];\n\n// ############### String Format ###############\n/**\n * StringFormat is the base class for all string formats.\n * It is used to define the string format and its parameters.\n * Jit code will be generated for each one of the StringFormat parameters.\n * @reflection never\n */\nexport class StringRunTypeFormat extends BaseRunTypeFormat<StringParams> {\n static readonly id = 'stringFormat' as const;\n readonly kind = ReflectionKind.string;\n readonly name = StringRunTypeFormat.id;\n\n getIgnoredProps(): string[] | undefined {\n return stringIgnoreProps;\n }\n emitFormat(comp: JitFnCompiler, rt: BaseRunType): JitCode {\n const operations: ((v) => string)[] = [];\n const p = this.getParams(rt);\n const vλl = comp.vλl;\n if (p.trim) operations.push((v) => `${v}.trim()`);\n if (p.replace) operations.push((v) => `${v}.replace(${p?.replace?.searchValue}, ${p?.replace?.replaceValue})`);\n if (p.replaceAll)\n operations.push((v) => `${v}.replaceAll(${p?.replaceAll?.searchValue}, ${p?.replaceAll?.replaceValue})`);\n if (p.lowercase) operations.push((v) => `${v}.toLowerCase()`);\n if (p.uppercase) operations.push((v) => `${v}.toUpperCase()`);\n if (p.capitalize) operations.push((v) => `(${v}.charAt(0).toUpperCase() + ${vλl}.slice(1))`);\n return {code: operations.reduce((acc, op) => op(acc), vλl), type: 'E'};\n }\n emitIsType(comp: JitFnCompiler, rt: BaseRunType): JitCode {\n const conditions: string[] = [];\n const p = this.getParams(rt);\n const vλl = comp.vλl;\n const literalFn = getToLiteralFn(comp, this.getIgnoredProps());\n if (p.maxLength !== undefined) conditions.push(`${vλl}.length <= ${literalFn(p.maxLength)}`);\n if (p.minLength !== undefined) conditions.push(`${vλl}.length >= ${literalFn(p.minLength)}`);\n if (p.length !== undefined) conditions.push(`${vλl}.length === ${literalFn(p.length)}`);\n if (p.pattern !== undefined) conditions.push(`${literalFn(p.pattern.val)}.test(${vλl})`);\n if (p.allowedChars) {\n const regexp = getAllowedCharsRegexp(p.allowedChars.val, p.allowedChars.ignoreCase);\n conditions.push(`${literalFn(regexp)}.test(${vλl})`);\n }\n if (p.disallowedChars) {\n const regexp = getDisallowedCharsRegexp(p.disallowedChars.val, p.disallowedChars.ignoreCase);\n conditions.push(`!${literalFn(regexp)}.test(${vλl})`);\n }\n if (p.allowedValues) {\n const regexp = getAllowedValuesRegexp(p.allowedValues.val, p.allowedValues.ignoreCase);\n conditions.push(`${literalFn(regexp)}.test(${vλl})`);\n }\n if (p.disallowedValues) {\n const regexp = getDisallowedValuesRegexp(p.disallowedValues.val, p.disallowedValues.ignoreCase);\n conditions.push(`!${literalFn(regexp)}.test(${vλl})`);\n }\n return {code: conditions.join(' && '), type: 'E'};\n }\n emitIsTypeErrors(comp: JitErrorsFnCompiler, rt: BaseRunType): JitCode {\n const conditions: string[] = [];\n const p = this.getParams(rt);\n const vλl = comp.vλl;\n const literalFn = getToLiteralFn(comp, this.getIgnoredProps());\n const errFn = this.getCallJitFormatErr(comp, rt, this, false);\n if (p.maxLength !== undefined) {\n const maxL = paramVal(p.maxLength);\n const errCode = errFn('maxLength', maxL);\n conditions.push(`if (${vλl}.length > ${maxL}) ${errCode}`);\n }\n\n if (p.minLength !== undefined) {\n const minL = paramVal(p.minLength);\n const errCode = errFn('minLength', minL);\n conditions.push(`if (${vλl}.length < ${minL}) ${errCode}`);\n }\n if (p.length !== undefined) {\n const length = paramVal(p.length);\n const errCode = errFn('length', length);\n conditions.push(`if (${vλl}.length !== ${length}) ${errCode}`);\n }\n if (p.pattern !== undefined) {\n const errCode = errFn('pattern', getDefaultMessage('pattern', p));\n conditions.push(`if (!${literalFn(p.pattern.val)}.test(${vλl})) ${errCode}`);\n }\n if (p.allowedChars) {\n const regexp = getAllowedCharsRegexp(p.allowedChars.val, p.allowedChars.ignoreCase);\n const errCode = errFn('allowedChars', getDefaultMessage('allowedChars', p));\n conditions.push(`if (!${literalFn(regexp)}.test(${vλl})) ${errCode}`);\n }\n if (p.disallowedChars) {\n const regexp = getDisallowedCharsRegexp(p.disallowedChars.val, p.disallowedChars.ignoreCase);\n const errCode = errFn('disallowedChars', getDefaultMessage('disallowedChars', p));\n conditions.push(`if (${literalFn(regexp)}.test(${vλl})) ${errCode}`);\n }\n if (p.allowedValues) {\n const regexp = getAllowedValuesRegexp(p.allowedValues.val, p.allowedValues.ignoreCase);\n const errCode = errFn('allowedValues', getDefaultMessage('allowedValues', p));\n conditions.push(`if (!${literalFn(regexp)}.test(${vλl})) ${errCode}`);\n }\n if (p.disallowedValues) {\n const regexp = getDisallowedValuesRegexp(p.disallowedValues.val, p.disallowedValues.ignoreCase);\n const errCode = errFn('disallowedValues', getDefaultMessage('disallowedValues', p));\n conditions.push(`if (${literalFn(regexp)}.test(${vλl})) ${errCode}`);\n }\n return {code: conditions.join(';'), type: 'S'};\n }\n _mock(opts: RunTypeOptions, rt: BaseRunType, params?: StringParams): string {\n const p = params || this.getParams(rt);\n if (p.allowedValues) return randomItem(p.allowedValues.val as string[]);\n\n const samples = p.pattern?.mockSamples || p.disallowedChars?.mockSamples || p.disallowedValues?.mockSamples;\n\n // if samples is an array we mock a value from one of the samples\n if (samples && typeof samples !== 'string' && Array.isArray(samples)) {\n const ignoreCase = p.disallowedChars?.ignoreCase || p.disallowedValues?.ignoreCase;\n const samplesAllCases = ignoreCase ? valuesAllCases(samples) : samples;\n return randomItem(samplesAllCases);\n }\n\n // if samples is a string we mock a random string using the samples as allowedChars\n if (samples && typeof samples === 'string') {\n return this.mockString(p, samples, undefined);\n }\n\n const allowedChars = p.allowedChars?.ignoreCase ? charsAllCases(p.allowedChars.val) : p.allowedChars?.val;\n const disallowedChars = p.disallowedChars?.ignoreCase ? charsAllCases(p.disallowedChars.val) : p.disallowedChars?.val;\n\n return this.mockString(p, allowedChars, disallowedChars);\n }\n private mockString(p: StringParams, allowedChars: string | undefined, disallowedChars: string | undefined): string {\n switch (true) {\n case p.length !== undefined:\n return mockString(paramVal(p.length), allowedChars, disallowedChars);\n case p.maxLength !== undefined && p.minLength !== undefined:\n return mockString(random(paramVal(p.minLength), paramVal(p.maxLength)), allowedChars, disallowedChars);\n case p.maxLength !== undefined:\n return mockString(random(0, paramVal(p.maxLength)), allowedChars, disallowedChars);\n case p.minLength !== undefined: {\n const minLength = paramVal(p.minLength);\n return mockString(random(minLength, minLength + random(1, 1 + minLength * 2)), allowedChars, disallowedChars);\n }\n default:\n return mockString(undefined, allowedChars, disallowedChars);\n }\n }\n validateParams(rt: BaseRunType, p: StringParams): void {\n const throwIfInvalid = (v: any, name: string, subName: 'mockSamples' | 'val', skipLengthChecks = false) => {\n const err = getParamError(v, p, skipLengthChecks);\n if (err)\n throw new Error(\n `Parameter ${name}.${subName} \"${v}\" does not satisfies \"${err}\" in type ${this.printPath(rt, subName)}`\n );\n };\n\n if (p.length !== undefined && (p.maxLength !== undefined || p.minLength !== undefined))\n throw new Error(`length can not be used with maxLength or minLength in ${this.printPath(rt, 'length')}`);\n if (p.maxLength !== undefined && p.minLength !== undefined && p.maxLength < p.minLength)\n throw new Error(`maxLength can not be less than minLength in ${this.printPath(rt, 'maxLength')}`);\n\n if (p.allowedValues?.val && p.allowedValues?.val.length > 100)\n throw new Error(`allowedValues can not have more than 100 values in ${this.printPath(rt, 'allowedValues')}`);\n if (p.disallowedValues?.val && p.disallowedValues?.val.length > 100)\n throw new Error(`disallowedValues can not have more than 100 values in ${this.printPath(rt, 'disallowedValues')}`);\n\n const complexParams = [\n {name: 'pattern', param: p.pattern as NonNullable<StringParams['pattern']>},\n {name: 'allowedChars', param: p.allowedChars as NonNullable<StringParams['allowedChars']>},\n {name: 'disallowedChars', param: p.disallowedChars as NonNullable<StringParams['disallowedChars']>},\n {name: 'allowedValues', param: p.allowedValues as NonNullable<StringParams['allowedValues']>},\n {name: 'disallowedValues', param: p.disallowedValues as NonNullable<StringParams['disallowedValues']>},\n ].filter((p) => p.param !== undefined);\n\n if (complexParams.length > 1) {\n throw new Error(\n `Only one of the parameters [pattern, allowedChars, disallowedChars, allowedValues, disallowedValues] can be used at once in ${this.printPath(rt)}`\n );\n }\n\n complexParams.forEach((c) => {\n const {mockSamples} = c.param;\n const requireSamples = propsWithRequiredSamples.includes(c.name);\n if (requireSamples && !mockSamples)\n throw new Error(\n `When ${c.name} is defined it is also required to provide samples in ${this.printPath(rt, c.name)}`\n );\n if (Array.isArray(mockSamples) && mockSamples.length === 0)\n throw new Error(`${c.name}.mockSamples can not be an empty array in ${this.printPath(rt, 'mockSamples')}`);\n if (typeof mockSamples === 'string' && mockSamples.length === 0)\n throw new Error(`${c.name}.mockSamples can not be an empty string in ${this.printPath(rt, 'mockSamples')}`);\n\n if (Array.isArray(mockSamples)) mockSamples.forEach((sample) => throwIfInvalid(sample, c.name, 'mockSamples'));\n if (typeof mockSamples === 'string')\n mockSamples.split('').forEach((char) => throwIfInvalid(char, c.name, 'mockSamples', true));\n });\n\n if (p.allowedChars?.val) throwIfInvalid(p.allowedChars?.val, 'allowedChars', 'val', true);\n p.allowedValues?.val.forEach((v) => throwIfInvalid(v, 'allowedValues', 'val'));\n\n // TODO: Bellow checks might cause problems\n // This us because replace and replaceAll might not pass regexp validation on their own\n // but could do once the operation is applied or mock value is generated\n if (p.pattern && p.replace && !p.pattern.val.test(p.replace.searchValue))\n throw new Error(\n `replace.searchValue \"${p.replace.searchValue}\" invalid for pattern ${p.pattern.val} in ${this.printPath(rt, 'replace')}`\n );\n if (p.pattern && p.replaceAll && !p.pattern.val.test(p.replaceAll.searchValue))\n throw new Error(\n `replaceAll.searchValue \"${p.replaceAll.searchValue}\" invalid for pattern ${p.pattern.val} in ${this.printPath(rt, 'replaceAll')}`\n );\n\n if ([p.lowercase, p.uppercase, p.capitalize].filter(Boolean).length > 1) {\n throw new Error(\n `Only one text formatter (lowercase, uppercase, capitalize) allowed for ${this.printPath(rt, 'formatters')}`\n );\n }\n }\n}\n\n/** @reflection never */\nexport function isPatternParam(p: any): p is FormatParam_Pattern {\n const isMessage = p.message === undefined || typeof p.message === 'string';\n const isSamples = p.samples === undefined || (Array.isArray(p.samples) && p.samples.every((s) => typeof s === 'string'));\n const isSampleChars = p.sampleChars === undefined || (typeof p.sampleChars === 'string' && p.sampleChars.length > 0);\n const hasSamples = !!p.samples?.length || !!p.sampleChars?.length;\n const isRegexpObj = typeof p.regexp === 'object' && p.regexp instanceof RegExp;\n return isMessage && hasSamples && isSamples && isSampleChars && isRegexpObj;\n}\n/** @reflection never */\nexport function patternParamsToStrParams(p: FormatParam_Pattern): StringParams {\n return {pattern: p};\n}\n/** @reflection never */\nfunction getParamError(v: any, p: StringParams, skipLengthChecks = false): string | undefined {\n if (!skipLengthChecks) {\n if (p.maxLength !== undefined && v.length > p.maxLength) return 'maxLength';\n if (p.minLength !== undefined && v.length < p.minLength) return 'minLength';\n if (p.length !== undefined && v.length !== p.length) return 'length';\n }\n if (p.pattern && !p.pattern.val.test(v)) return 'pattern';\n if (p.allowedChars && !getAllowedCharsRegexp(p.allowedChars.val).test(v)) return 'allowedChars';\n if (p.disallowedChars && getDisallowedCharsRegexp(p.disallowedChars.val).test(v)) return 'disallowedChars';\n if (p.allowedValues && !p.allowedValues.val.includes(v)) return 'allowedValues';\n if (p.disallowedValues && p.disallowedValues.val.includes(v)) return 'disallowedValues';\n}\n/** @reflection never */\nfunction getDefaultMessage(name: keyof typeof defaultMessages, p: StringParams): string {\n return p[name]?.errorMessage || defaultMessages[name];\n}\n/** @reflection never */\nfunction getAllowedCharsRegexp(allowedChars: string, ignoreCase?: boolean): RegExp {\n const flags = ignoreCase ? 'i' : '';\n return new RegExp(`^[${regexpEscape(allowedChars)}]+$`, flags);\n}\n/** @reflection never */\nfunction getDisallowedCharsRegexp(disallowedChars: string, ignoreCase?: boolean): RegExp {\n const flags = ignoreCase ? 'i' : '';\n return new RegExp(`[${regexpEscape(disallowedChars)}]`, flags);\n}\n/** @reflection never */\nfunction getAllowedValuesRegexp(allowedValues: readonly string[], ignoreCase?: boolean): RegExp {\n const flags = ignoreCase ? 'i' : '';\n return new RegExp(`^(?:${allowedValues.map((v) => regexpEscape(v)).join('|')})$`, flags);\n}\n/** @reflection never */\nfunction getDisallowedValuesRegexp(disallowedValues: readonly string[], ignoreCase?: boolean): RegExp {\n const flags = ignoreCase ? 'i' : '';\n return new RegExp(`^(?:${disallowedValues.map((v) => regexpEscape(v)).join('|')})$`, flags);\n}\n/** @reflection never */\nfunction charsAllCases(string?: string): string | undefined {\n if (!string) return;\n const chars = string.split('');\n const allCases = [...chars.map((c) => c.toLowerCase()), ...chars.map((c) => c.toUpperCase())];\n return Array.from(new Set(allCases)).join('');\n}\n/** @reflection never */\nfunction valuesAllCases(stringList: string[]): string[] {\n const allCases = [...stringList, ...stringList.map((s) => s.toLowerCase()), ...stringList.map((s) => s.toUpperCase())];\n return Array.from(new Set(allCases));\n}\n\n// ############### Register runtypes ###############\n// registerPureFnClosure(stringFormatErrors);\n\n// register Validator operations so they can be used in the jit compiler\n/** @reflection never */\nexport const STRING_RUN_TYPE_FORMATTER = registerFormatter(new StringRunTypeFormat());\n\n/** String format with optional branding. Unbranded by default. */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport type FormatString<P extends StringParams = {}, BrandName extends string = never> = TypeFormat<\n string,\n typeof StringRunTypeFormat.id,\n P,\n BrandName\n>;\n"],"names":["BaseRunTypeFormat","ReflectionKind","getToLiteralFn","paramVal","randomItem","mockString","random","p","regexpEscape","registerFormatter"],"mappings":";;;;;AAcA,MAAM,kBAAkB;AAAA,EACpB,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,SAAS;;AAEb,MAAM,2BAA2B,CAAC,mBAAmB,mBAAmB,SAAS;AAC1E,MAAM,oBAAoB,CAAC,WAAW,aAAa;AASpD,MAAO,4BAA4BA,SAAAA,kBAA+B;AAAA,EACpE,OAAgB,KAAK;AAAA,EACZ,OAAOC,KAAAA,eAAe;AAAA,EACtB,OAAO,oBAAoB;AAAA,EAEpC,kBAAe;AACX,WAAO;AAAA,EACX;AAAA,EACA,WAAW,MAAqB,IAAe;AAC3C,UAAM,aAAgC,CAAA;AACtC,UAAM,IAAI,KAAK,UAAU,EAAE;AAC3B,UAAM,MAAM,KAAK;AACjB,QAAI,EAAE;AAAM,iBAAW,KAAK,CAAC,MAAM,GAAG,CAAC,SAAS;AAChD,QAAI,EAAE;AAAS,iBAAW,KAAK,CAAC,MAAM,GAAG,CAAC,YAAY,GAAG,SAAS,WAAW,KAAK,GAAG,SAAS,YAAY,GAAG;AAC7G,QAAI,EAAE;AACF,iBAAW,KAAK,CAAC,MAAM,GAAG,CAAC,eAAe,GAAG,YAAY,WAAW,KAAK,GAAG,YA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AAW,CAAC,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,YAAA,CAAa,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,YAAA,CAAa,CAAC;AAC5F,SAAO,MAAM,KAAK,IAAI,IAAI,QAAQ,CAAC,EAAE,KAAK,EAAE;AAChD;AAEA,SAAS,eAAe,YAAoB;AACxC,QAAM,WAAW,CAAC,GAAG,YAAY,GAAG,WAAW,IAAI,CAAC,MAAM,EAAE,aAAa,GAAG,GAAG,WAAW,IAAI,CAAC,MAAM,EAAE,YAAA,CAAa,CAAC;AACrH,SAAO,MAAM,KAAK,IAAI,IAAI,QAAQ,CAAC;AACvC;AAOO,MAAM,4BAA4BC,SAAAA,kBAAkB,IAAI,oBAAA,CAAqB;mGAMrD,IAAE,gBAAA,wBAAA;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.runtype.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"time.runtype.cjs","sources":["../../../../src/string/time.runtype.ts"],"sourcesContent":["/* ########\n * 2025 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\nimport type {BrandTime} from '@mionjs/core';\nimport type {BaseRunType, JitFnCompiler, JitErrorsFnCompiler, JitCode} from '@mionjs/run-types';\nimport {BaseRunTypeFormat, TypeFormat, RunTypeOptions, registerFormatter} from '@mionjs/run-types'; // !Important: TypeFormat cant be imported as type for all runType functionality to work\nimport {ReflectionKind} from '@deepkit/type';\nimport {paramVal} from '../utils.ts';\nimport {FormatParams_Time} from '@mionjs/core';\nimport {\n cpf_isTimeString_ISO_TZ,\n cpf_isTimeString_ISO,\n cpf_isTimeString_HHmmss,\n cpf_isTimeString_HHmm,\n cpf_isTimeString_mmss,\n cpf_isHours,\n cpf_isMinutes,\n cpf_isSeconds,\n} from '../type-formats-pure-fns.ts';\n\n// Time validator\n/** @reflection never */\nexport class TimeStringRunTypeFormat extends BaseRunTypeFormat<FormatParams_Time> {\n static id = 'time' as const;\n kind = ReflectionKind.string;\n name = TimeStringRunTypeFormat.id;\n emitIsType(comp: JitFnCompiler, rt: BaseRunType): JitCode {\n const params = this.getParams(rt);\n const formatFn = this.getFormatPureFn(paramVal(params.format as BrandTime));\n return {code: this.compilePureFunctionCall(comp, rt, formatFn).callCode, type: 'E'};\n }\n emitIsTypeErrors(comp: JitErrorsFnCompiler, rt: BaseRunType): JitCode {\n const isTypeCodeObj = this.emitIsType(comp, rt);\n const isTypeCode = isTypeCodeObj.code;\n if (!isTypeCode) return {code: '', type: 'S'};\n const params = this.getParams(rt);\n const errFn = this.getCallJitFormatErr(comp, rt, this);\n return {code: `if (!(${isTypeCode})) ${errFn('format', paramVal(params.format))}`, type: 'S'};\n }\n _mock(opts: RunTypeOptions, rt: BaseRunType) {\n const params = this.getParams(rt);\n const hours = String(Math.floor(Math.random() * 24)).padStart(2, '0');\n const minutes = String(Math.floor(Math.random() * 60)).padStart(2, '0');\n const seconds = String(Math.floor(Math.random() * 60)).padStart(2, '0');\n switch (paramVal(params.format)) {\n case 'ISO': // ISO\n case 'HH:mm:ss[.mmm]TZ': // 'HH:mm:ss[.mmm]TZ'\n return `${hours}:${minutes}:${seconds}${mockMilliseconds()}${mockTimeZone()}`;\n case 'HH:mm:ss[.mmm]': // 'HH:mm:ss[.mmm]'\n return `${hours}:${minutes}:${seconds}${mockMilliseconds()}`;\n case 'HH:mm:ss': // 'HH:mm:ss'\n return `${hours}:${minutes}:${seconds}`;\n case 'HH:mm': // 'HH:mm'\n return `${hours}:${minutes}`;\n case 'mm:ss': // 'mm:ss'\n return `${minutes}:${seconds}`;\n case 'HH': // 'HH'\n return hours;\n case 'mm': // 'mm'\n return minutes;\n case 'ss': // 'ss'\n return seconds;\n default:\n throw new Error(`Invalid time format: ${paramVal(params.format)}`);\n }\n }\n getFormatPureFn(format: FormatStringTime) {\n switch (format) {\n case 'ISO':\n case 'HH:mm:ss[.mmm]TZ':\n return cpf_isTimeString_ISO_TZ;\n case 'HH:mm:ss[.mmm]':\n return cpf_isTimeString_ISO;\n case 'HH:mm:ss':\n return cpf_isTimeString_HHmmss;\n case 'HH:mm':\n return cpf_isTimeString_HHmm;\n case 'mm:ss':\n return cpf_isTimeString_mmss;\n case 'HH':\n return cpf_isHours;\n case 'mm':\n return cpf_isMinutes;\n case 'ss':\n return cpf_isSeconds;\n default:\n throw new Error(`Invalid time format: ${format}`);\n }\n }\n}\n\n// ######### Mocking functions #########\n/** @reflection never */\nexport function mockMilliseconds(): string {\n const showMilliseconds = Math.random() > 0.5;\n if (!showMilliseconds) return '';\n return `.${String(Math.floor(Math.random() * 1000)).padStart(3, '0')}`;\n}\n/** @reflection never */\nexport function mockTimeZone(): string {\n const isZ = Math.random() > 0.5;\n if (isZ) return 'Z';\n const hours = String(Math.floor(Math.random() * 24)).padStart(2, '0');\n const minutes = String(Math.floor(Math.random() * 60)).padStart(2, '0');\n return `${Math.random() > 0.5 ? '+' : '-'}${hours}:${minutes}`;\n}\n\n// ######### Registering the time validator #########\n/** @reflection never */\nexport const TIME_RUN_TYPE_FORMATTER = registerFormatter(new TimeStringRunTypeFormat());\n\n// ############### Type ###############\n\nexport type DEFAULT_TIME_FORMAT_PARAMS = {format: 'ISO'};\n\n/** Time string format, always branded with 'time'. */\nexport type FormatStringTime<P extends FormatParams_Time = DEFAULT_TIME_FORMAT_PARAMS> = TypeFormat<\n string,\n typeof TimeStringRunTypeFormat.id,\n P,\n 'time'\n>;\n"],"names":["BaseRunTypeFormat","ReflectionKind","paramVal","cpf_isTimeString_ISO_TZ","cpf_isTimeString_ISO","cpf_isTimeString_HHmmss","cpf_isTimeString_HHmm","cpf_isTimeString_mmss","cpf_isHours","cpf_isMinutes","cpf_isSeconds","registerFormatter"],"mappings":";;;;;;AAyBM,MAAO,gCAAgCA,SAAAA,kBAAoC;AAAA,EAC7E,OAAO,KAAK;AAAA,EACZ,OAAOC,KAAAA,eAAe;AAAA,EACtB,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;AACtE,SAAO,GAAG,KAAK,OAAA,IAAW,MAAM,MAAM,GAAG,GAAG,KAAK,IAAI,OAAO;AAChE;AAIO,MAAM,0BAA0BC,SAAAA,kBAAkB,IAAI,wBAAA,CAAyB;;mIASnD,IAAE,QAAA,oBAAA,oBAAA;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.runtype.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"url.runtype.cjs","sources":["../../../../src/string/url.runtype.ts"],"sourcesContent":["/* ########\n * 2025 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\nimport type {BaseRunType, JitFnCompiler, JitErrorsFnCompiler, JitCode, StrNumber} from '@mionjs/run-types';\nimport {registerFormatter, BaseRunTypeFormat, TypeFormat, RunTypeOptions, JitFunctions, randomItem} from '@mionjs/run-types';\nimport {ReflectionKind} from '@deepkit/type';\nimport {StringRunTypeFormat, stringIgnoreProps} from './stringFormat.runtype.ts';\nimport {FormatParams_Url} from '@mionjs/core';\nimport {DomainRunTypeFormat} from './domain.runtype.ts';\nimport {IPRunTypeFormat} from './ip.runtype.ts';\nimport {\n FILE_URL_SAMPLES,\n HTTP_URL_SAMPLES,\n SOCIAL_MEDIA_URL_SAMPLES,\n URL_SAMPLES,\n SOCIAL_MEDIA_DOMAINS_SAMPLES,\n INTERNET_PROTOCOLS,\n} from '../constants.mock.ts'; // do not import using type\nimport {paramVal} from '../utils.ts';\n\nexport const URL_REGEXP = /^(?:https?|ftps?|wss?):\\/\\/[^\\s/$.?#-][^\\s]*$/i;\nexport const URL_FILE_REGEXP = /^file:\\/\\/\\/?(?:[a-zA-Z]:)?[^\\s/$.?#-][^\\s]*$/i;\nexport const URL_HTTP_REGEXP = /^https?:\\/\\/[^\\s/$.?#-][^\\s]*$/i;\n\n// URL validator\n/** @reflection never */\nexport class URLRunTypeFormat extends BaseRunTypeFormat<FormatParams_Url> {\n static readonly id = 'url';\n readonly kind = ReflectionKind.string;\n readonly name = URLRunTypeFormat.id;\n\n // Formatter instances as class variables\n private urlFormatter: StringRunTypeFormat;\n private domainFormatter: DomainRunTypeFormat;\n private ipFormatter: IPRunTypeFormat;\n\n constructor(parentPath?: StrNumber[]) {\n super(parentPath);\n\n // Initialize formatters in the constructor\n const urlPath = this.getFormatPath();\n const domainPath = this.getFormatPath('domain');\n const ipPath = this.getFormatPath('ip');\n\n this.urlFormatter = new StringRunTypeFormat(urlPath);\n this.domainFormatter = new DomainRunTypeFormat(domainPath);\n this.ipFormatter = new IPRunTypeFormat(ipPath);\n }\n getIgnoredProps(): string[] | undefined {\n return stringIgnoreProps;\n }\n emitIsType(comp: JitFnCompiler, rt: BaseRunType): JitCode {\n const params = this.getParams(rt);\n const fnID = comp.fnID;\n const fmtName = this.getFormatName();\n const urlCode = this.urlFormatter!.compileFormat(fnID, comp, rt, params, comp.vλl, fmtName);\n if (!params.domain && !params.ip) return urlCode;\n\n const vDomain = 'domain';\n const dmnCode = params?.domain\n ? this.domainFormatter.compileFormat(fnID, comp, rt, params.domain, vDomain, fmtName)\n : null;\n const ipCodeObj = params.ip ? this.ipFormatter.compileFormat(fnID, comp, rt, params.ip, vDomain, fmtName) : null;\n // Remove debug logs\n const safeUrlCode = urlCode.code ? `if(!(${urlCode.code})) return false;` : '';\n\n const dIsExpression = dmnCode?.type === 'E';\n const ipExpression = ipCodeObj?.type === 'E';\n const domainSafeCode = dIsExpression && dmnCode?.code ? `if(!(${dmnCode.code})) return false;` : dmnCode?.code;\n const ipSafeCode = ipExpression && ipCodeObj?.code ? `if(${ipCodeObj.code}) return false;` : ipCodeObj?.code;\n const returnCode = this.isRootFormat() ? `return true;` : '';\n\n const code = `\n ${safeUrlCode}\n const start = ${comp.vλl}.indexOf('://') + 3;\n const end = ${comp.vλl}.indexOf('/', start);\n const endIdx = end === -1 ? ${comp.vλl}.length : end;\n const domain = ${comp.vλl}.substring(start, endIdx);\n ${domainSafeCode}\n ${ipSafeCode}\n ${returnCode}\n `;\n return {code, type: 'S'};\n }\n emitIsTypeErrors(comp: JitErrorsFnCompiler, rt: BaseRunType): JitCode {\n const params = this.getParams(rt);\n const fnID = comp.fnID;\n const fmtName = this.getFormatName();\n\n const urlCode = this.urlFormatter!.compileFormat(fnID, comp, rt, params, comp.vλl, fmtName);\n if (!params.domain && !params.ip) return urlCode;\n\n const vDomain = 'domain' + this.getFormatNestLevel(); // must match var name in code\n const dmnCode = params?.domain\n ? this.domainFormatter.compileFormat(fnID, comp, rt, params.domain, vDomain, fmtName)\n : null;\n const iPCode = params.ip ? this.ipFormatter.compileFormat(fnID, comp, rt, params.ip, vDomain, fmtName) : null;\n const checks = [urlCode.code, dmnCode?.code, iPCode?.code].filter(Boolean);\n\n const vStart = 'start' + this.getFormatNestLevel(); // must match var name in code\n const vEnd = 'end' + this.getFormatNestLevel(); // must match var name in code\n const vEndIdx = 'endIdx' + this.getFormatNestLevel(); // must match var name in code\n\n const code = `\n const ${vStart} = ${comp.vλl}.indexOf('://') + 3;\n const ${vEnd} = ${comp.vλl}.indexOf('/', ${vStart});\n const ${vEndIdx} = ${vEnd} === -1 ? ${comp.vλl}.length : ${vEnd};\n const ${vDomain} = ${comp.vλl}.substring(${vStart}, ${vEndIdx});\n ${checks.join(';')};\n `;\n return {code, type: 'S'};\n }\n _mock(opts: RunTypeOptions, rt: BaseRunType): string {\n const params = this.getParams(rt);\n let url = this.urlFormatter.mock(opts, rt, params);\n const hasProtocol = url.indexOf('://') !== -1;\n if (!hasProtocol) url = randomItem(INTERNET_PROTOCOLS) + url;\n if (params.domain) {\n const domain = this.domainFormatter.mock(opts, rt, params.domain);\n return replaceDomain(url, domain);\n }\n if (params.ip) return replaceDomain(url, this.ipFormatter.mock(opts, rt, params.ip));\n return url;\n }\n validateParams(rt: BaseRunType, params: FormatParams_Url): void {\n if (params.maxLength && paramVal(params.maxLength) > 2048) throw new Error('URL maxLength cannot be greater than 2048');\n if (params.minLength && paramVal(params.minLength) < 5) throw new Error('URL minLength cannot be less than 5');\n\n this.urlFormatter.validateParams(rt, params);\n\n const {ip, domain} = params;\n if (ip && domain) throw new Error('URL validator cannot have both IP and domain validators');\n\n if (domain) {\n this.domainFormatter.validateParams(rt, domain);\n }\n }\n emitFormat(comp: JitFnCompiler, rt: BaseRunType): JitCode {\n const params = this.getParams(rt);\n if (!params.domain) return {code: undefined, type: 'S'};\n const vDomain = 'domain' + this.getFormatNestLevel(); // must match var name in code\n const fnID = JitFunctions.format.id;\n const fmtName = this.getFormatName();\n\n const domainCode = this.domainFormatter!.compileFormat(fnID, comp, rt, params.domain, vDomain, fmtName);\n const vStart = 'start' + this.getFormatNestLevel(); // must match var name in code\n const vEnd = 'end' + this.getFormatNestLevel(); // must match var name in code\n const vEndIdx = 'endIdx' + this.getFormatNestLevel(); // must match var name in code\n\n const code = `\n const ${vStart} = ${comp.vλl}.indexOf('://') + 3;\n const ${vEnd} = ${comp.vλl}.indexOf('/', ${vStart});\n const ${vEndIdx} = ${vEnd} === -1 ? ${comp.vλl}.length : ${vEnd};\n const ${vDomain} = ${comp.vλl}.substring(${vStart}, ${vEndIdx});\n return ${domainCode.code};\n `;\n return {code, type: 'RB'};\n }\n}\n/** @reflection never */\nfunction replaceDomain(url: string, domain: string): string {\n const start = url.indexOf('://') + 3;\n const end = url.indexOf('/', start);\n const endIdx = end === -1 ? url.length : end;\n return url.substring(0, start) + domain + url.substring(endIdx);\n}\n\n// ############### Register runtypes ###############\n/** @reflection never */\nexport const URL_RUN_TYPE_FORMATTER = registerFormatter(new URLRunTypeFormat());\n\n// ############### Type ###############\n\nexport type DEFAULT_URL_PARAMS = {\n maxLength: 2048;\n pattern: {val: typeof URL_REGEXP; errorMessage: 'invalid URL format'; mockSamples: URL_SAMPLES};\n};\nexport type DEFAULT_URL_FILE_PARAMS = {\n maxLength: 2048;\n pattern: {val: typeof URL_FILE_REGEXP; errorMessage: 'invalid file URL format'; mockSamples: FILE_URL_SAMPLES};\n};\nexport type DEFAULT_URL_HTTP_PARAMS = {\n maxLength: 2048;\n pattern: {val: typeof URL_HTTP_REGEXP; errorMessage: 'invalid Http URL format'; mockSamples: HTTP_URL_SAMPLES};\n};\nexport type DEFAULT_URL_SOCIAL_MEDIA_PARAMS<DomainLIst extends readonly string[] = SOCIAL_MEDIA_DOMAINS_SAMPLES> = {\n maxLength: 2048;\n pattern: {\n val: typeof URL_HTTP_REGEXP;\n errorMessage: 'invalid social media URL format';\n mockSamples: SOCIAL_MEDIA_URL_SAMPLES;\n };\n domain: {\n names: {\n allowedValues: {\n val: DomainLIst;\n errorMessage: 'Only social media domains are allowed';\n };\n };\n tld: {\n allowedValues: {\n val: ['com'];\n errorMessage: 'Only com TLDs are allowed';\n };\n };\n };\n};\n\n/* eslint-disable @typescript-eslint/no-empty-object-type */\n/** URL format, always branded with 'url'. */\nexport type FormatUrl<P extends FormatParams_Url = {}> = TypeFormat<string, 'url', DEFAULT_URL_PARAMS & P, 'url'>;\n/** File URL format, always branded with 'url'. */\nexport type FormatUrlFile<P extends FormatParams_Url = {}> = TypeFormat<string, 'url', DEFAULT_URL_FILE_PARAMS & P, 'url'>;\n/** HTTP URL format, always branded with 'url'. */\nexport type FormatUrlHttp<P extends FormatParams_Url = {}> = TypeFormat<string, 'url', DEFAULT_URL_HTTP_PARAMS & P, 'url'>;\n/** Social media URL format, always branded with 'url'. */\nexport type FormatUrlSocialMedia<DomainLIst extends readonly string[] = SOCIAL_MEDIA_DOMAINS_SAMPLES> = FormatUrl<\n DEFAULT_URL_SOCIAL_MEDIA_PARAMS<DomainLIst>\n>;\n"],"names":["BaseRunTypeFormat","ReflectionKind","StringRunTypeFormat","Dom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AI,CAAC,OAAO;AAAQ,aAAO,EAAC,MAAM,QAAW,MAAM,IAAA;AACnD,UAAM,UAAU,WAAW,KAAK,mBAAA;AAChC,UAAM,OAAOC,sBAAa,OAAO;AACjC,UAAM,UAAU,KAAK,cAAA;AAErB,UAAM,aAAa,KAAK,gBAAiB,cAAc,MAAM,MAAM,IAAI,OAAO,QAAQ,SAAS,OAAO;AACtG,UAAM,SAAS,UAAU,KAAK,mBAAA;AAC9B,UAAM,OAAO,QAAQ,KAAK,mBAAA;AAC1B,UAAM,UAAU,WAAW,KAAK,mBAAA;AAEhC,UAAM,OAAO;AAAA,oBACD,MAAM,MAAM,KAAK,GAAG;AAAA,oBACpB,IAAI,MAAM,KAAK,GAAG,iBAAiB,MAAM;AAAA,oBACzC,OAAO,MAAM,IAAI,aAAa,KAAK,GAAG,aAAa,IAAI;AAAA,oBACvD,OAAO,MAAM,KAAK,GAAG,cAAc,MAAM,KAAK,OAAO;AAAA,qBACpD,WAAW,IAAI;AAAA;AAE5B,WAAO,EAAC,MAAM,MAAM,KAAA;AAAA,EACxB;;AAGJ,SAAS,cAAc,KAAa,QAAc;AAC9C,QAAM,QAAQ,IAAI,QAAQ,KAAK,IAAI;AACnC,QAAM,MAAM,IAAI,QAAQ,KAAK,KAAK;AAClC,QAAM,SAAS,QAAQ,KAAK,IAAI,SAAS;AACzC,SAAO,IAAI,UAAU,GAAG,KAAK,IAAI,SAAS,IAAI,UAAU,MAAM;AAClE;AAIO,MAAM,yBAAyBC,SAAAA,kBAAkB,IAAI,iBAAA,CAAkB;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.runtype.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uuid.runtype.cjs","sources":["../../../../src/string/uuid.runtype.ts"],"sourcesContent":["/* ########\n * 2025 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\nimport type {BaseRunType, JitFnCompiler, JitErrorsFnCompiler, JitCode} from '@mionjs/run-types';\nimport {registerFormatter, BaseRunTypeFormat, RunTypeOptions, TypeFormat} from '@mionjs/run-types'; // !Important: TypeFormat cant be imported as type for all runType functionality to work\nimport {ReflectionKind} from '@deepkit/type';\nimport {randomUUID_V7} from '@mionjs/core';\nimport {paramVal} from '../utils.ts';\nimport {FormatParams_UUID} from '@mionjs/core';\nimport {cpf_isUUID} from '../type-formats-pure-fns.ts';\n\n// UUID validator\n/** @reflection never */\nexport class UUIDRunTypeFormat extends BaseRunTypeFormat<FormatParams_UUID> {\n static readonly id = 'uuid' as const;\n readonly kind = ReflectionKind.string;\n readonly name = UUIDRunTypeFormat.id;\n emitIsType(comp: JitFnCompiler, rt: BaseRunType): JitCode {\n const params = this.getParams(rt);\n // version must be set as a string to call pure function isUUID, this is so no transform is needed when comparing with uuid charat\n return {code: this.compilePureFunctionCall(comp, rt, cpf_isUUID, params).callCode, type: 'E'};\n }\n emitIsTypeErrors(comp: JitErrorsFnCompiler, rt: BaseRunType): JitCode {\n const params = this.getParams(rt);\n const isTypeCodeObj = this.emitIsType(comp, rt);\n const isTypeCode = isTypeCodeObj.code;\n if (!isTypeCode) return {code: '', type: 'S'};\n const errFn = this.getCallJitFormatErr(comp, rt, this);\n return {code: `if (!(${isTypeCode})) ${errFn('version', paramVal(params.version))}`, type: 'S'};\n }\n _mock(opts: RunTypeOptions, rt: BaseRunType) {\n const params = this.getParams(rt);\n return params.version === '4' ? crypto.randomUUID() : randomUUID_V7();\n }\n validateParams(_rt: BaseRunType, params: FormatParams_UUID) {\n if (params.version !== '4' && params.version !== '7') {\n throw new Error(`Invalid UUID version: ${params.version}, must be either 4 or 7`);\n }\n }\n emitFormat?; // no format needed\n}\n\n// ############### Register runtypes ###############\n\nexport const UUID_RUN_TYPE_FORMATTER = registerFormatter(new UUIDRunTypeFormat());\n\n/** UUID v4 format, always branded with 'uuid'. */\nexport type FormatUUIDv4 = TypeFormat<string, typeof UUIDRunTypeFormat.id, {version: '4'}, 'uuid'>;\n/** UUID v7 format, always branded with 'uuid'. */\nexport type FormatUUIDv7 = TypeFormat<string, typeof UUIDRunTypeFormat.id, {version: '7'}, 'uuid'>;\n"],"names":["BaseRunTypeFormat","ReflectionKind","cpf_isUUID","paramVal","randomUUID_V7","registerFormatter"],"mappings":";;;;;;;AAgBM,MAAO,0BAA0BA,SAAAA,kBAAoC;AAAA,EACvE,OAAgB,KAAK;AAAA,EACZ,OAAOC,KAAAA,eAAe;AAAA,EACtB,OAAO,kBAAkB;AAAA,EAClC,WAAW,MAAqB,IAAe;AAC3C,UAAM,SAAS,KAAK,UAAU,EAAE;AAEhC,WAAO,EAAC,MAAM,KAAK,wBAAwB,MAAM,IAAIC,uBAAAA,YAAY,MAAM,EAAE,UAAU,MAAM,IAAA;AAAA,EAC7F;AAAA,EACA,iBAAiB,MAA2B,IAAe;AACvD,UAAM,SAAS,KAAK,UAAU,EAAE;AAChC,UAAM,gBAAgB,KAAK,WAAW,MAAM,EAAE;AAC9C,UAAM,aAAa,cAAc;AACjC,QAAI,CAAC;AAAY,aAAO,EAAC,MAAM,IAAI,MAAM,IAAA;AACzC,UAAM,QAAQ,KAAK,oBAAoB,MAAM,IAAI,IAAI;AACrD,WAAO,EAAC,MAAM,SAAS,UAAU,MAAM,MAAM,WAAWC,UAAAA,SAAS,OAAO,OAAO,CAAC,CAAC,IAAI,MAAM,IAAA;AAAA,EAC/F;AAAA,EACA,MAAM,MAAsB,IAAe;AACvC,UAAM,SAAS,KAAK,UAAU,EAAE;AAChC,WAAO,OAAO,YAAY,MAAM,OAAO,WAAA,IAAeC,mBAAA;AAAA,EAC1D;AAAA,EACA,eAAe,KAAkB,QAAyB;AACtD,QAAI,OAAO,YAAY,OAAO,OAAO,YAAY,KAAK;AAClD,YAAM,IAAI,MAAM,yBAAyB,OAAO,OAAO,yBAAyB;AAAA,IACpF;AAAA,EACJ;AAAA,EACA;AAAA;;AAKG,MAAM,0BAA0BC,SAAAA,kBAAkB,IAAI,kBAAA,CAAmB;+EAGT,IAAE,KAAA,WAAA,QAAA,gBAAA,mBAAA;+EAEF,IAAE,KAAA,WAAA,QAAA,gBAAA,mBAAA;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-formats-pure-fns.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"type-formats-pure-fns.cjs","sources":["../../../src/type-formats-pure-fns.ts"],"sourcesContent":["/* ########\n * 2025 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\n/**\n * This file contains all pure functions used by type-formats.\n * Pure functions are registered here and can be imported from this single file.\n * This makes it easier to export and use pure functions in AOT compilation.\n */\n\nimport {\n type JITUtils,\n GenericPureFunction,\n TypeFormatError,\n registerPureFnFactory,\n FormatParams_Date,\n FormatParams_Time,\n FormatParams_UUID,\n FormatParams_IP,\n} from '@mionjs/core';\n\n// ############### Date Pure Functions ###############\n\n/** @reflection never */\nexport const cpf_isDateString = registerPureFnFactory('mionFormats', 'isDateString', function () {\n // check is a valid date taking into account leap years\n return function is_date_string(year: string | undefined, month: string, day?: string): boolean {\n let y: undefined | number = undefined;\n if (year) {\n if (year.length !== 4) return false;\n y = Number(year);\n if (isNaN(y)) return false;\n if (y < 0 || y > 9999) return false;\n }\n if (month.length !== 2) return false;\n const m = Number(month);\n if (isNaN(m)) return false;\n if (m < 1 || m > 12) return false;\n if (day) {\n if (day.length !== 2) return false;\n const d = Number(day);\n if (isNaN(d)) return false;\n if (d < 1 || d > 31) return false;\n // check for leap years\n if (m === 2) {\n if (d > 29) return false;\n if (y && d === 29 && !(y % 4 === 0 && (y % 100 !== 0 || y % 400 === 0))) return false;\n } else if ((m === 4 || m === 6 || m === 9 || m === 11) && d > 30) {\n return false;\n }\n }\n return true;\n };\n});\n\n/** @reflection never */\nexport const cpf_isDateString_YMD = registerPureFnFactory('mionFormats', 'isDateString_YMD', function (jUtil: JITUtils) {\n const isDate = jUtil.getPureFn('mionFormats', 'isDateString') as any as ReturnType<typeof cpf_isDateString.createPureFn>;\n return function is_date(value: string): boolean {\n const parts = value.split('-');\n return parts.length === 3 && isDate(parts[0], parts[1], parts[2]);\n } satisfies GenericPureFunction<FormatParams_Date>;\n});\n\n/** @reflection never */\nexport const cpf_isDateString_DMY = registerPureFnFactory('mionFormats', 'isDateString_DMY', function (jUtil: JITUtils) {\n const isDate = jUtil.getPureFn('mionFormats', 'isDateString') as any as ReturnType<typeof cpf_isDateString.createPureFn>;\n return function is_date(value: string): boolean {\n const parts = value.split('-');\n return parts.length === 3 && isDate(parts[2], parts[1], parts[0]);\n } satisfies GenericPureFunction<FormatParams_Date>;\n});\n\n/** @reflection never */\nexport const cpf_isDateString_MDY = registerPureFnFactory('mionFormats', 'isDateString_MDY', function (jUtil: JITUtils) {\n const isDate = jUtil.getPureFn('mionFormats', 'isDateString') as any as ReturnType<typeof cpf_isDateString.createPureFn>;\n return function is_date(value: string): boolean {\n const parts = value.split('-');\n return parts.length === 3 && isDate(parts[2], parts[0], parts[1]);\n } satisfies GenericPureFunction<FormatParams_Date>;\n});\n\n/** @reflection never */\nexport const cpf_isDateString_YM = registerPureFnFactory('mionFormats', 'isDateString_YM', function (jUtil: JITUtils) {\n const isDate = jUtil.getPureFn('mionFormats', 'isDateString') as any as ReturnType<typeof cpf_isDateString.createPureFn>;\n return function is_date(value: string): boolean {\n const parts = value.split('-');\n return parts.length === 2 && isDate(parts[0], parts[1]);\n } satisfies GenericPureFunction<FormatParams_Date>;\n});\n\n/** @reflection never */\nexport const cpf_isDateString_MD = registerPureFnFactory('mionFormats', 'isDateString_MD', function (jUtil: JITUtils) {\n const isDate = jUtil.getPureFn('mionFormats', 'isDateString') as any as ReturnType<typeof cpf_isDateString.createPureFn>;\n return function is_date(value: string): boolean {\n const parts = value.split('-');\n return parts.length === 2 && isDate(undefined, parts[0], parts[1]);\n } satisfies GenericPureFunction<FormatParams_Date>;\n});\n\n/** @reflection never */\nexport const cpf_isDateString_DM = registerPureFnFactory('mionFormats', 'isDateString_DM', function (jUtil: JITUtils) {\n const isDate = jUtil.getPureFn('mionFormats', 'isDateString') as any as ReturnType<typeof cpf_isDateString.createPureFn>;\n return function is_date(value: string): boolean {\n const parts = value.split('-');\n return parts.length === 2 && isDate(undefined, parts[1], parts[0]);\n } satisfies GenericPureFunction<FormatParams_Date>;\n});\n\n/** Date pure functions array for registration */\nexport const dateFunctions = [\n cpf_isDateString,\n cpf_isDateString_YMD,\n cpf_isDateString_DMY,\n cpf_isDateString_MDY,\n cpf_isDateString_YM,\n cpf_isDateString_MD,\n cpf_isDateString_DM,\n];\n\n// ############### Time Pure Functions ###############\n\n/** @reflection never */\nexport const cpf_isTimeZone = registerPureFnFactory('mionFormats', 'isTimeZone', function (jUtil: JITUtils) {\n const isH = jUtil.getPureFn('mionFormats', 'isHours') as ReturnType<typeof cpf_isHours.createPureFn>;\n const isM = jUtil.getPureFn('mionFormats', 'isMinutes') as ReturnType<typeof cpf_isMinutes.createPureFn>;\n return function is_tz(timeZone: string): timeZone is 'TZ' {\n const isZ = timeZone === 'Z' || timeZone === 'z';\n if (isZ) return true;\n const tzParts = timeZone.split(':') as ['hh', 'mm'];\n if (tzParts.length !== 2) return false;\n const hours = tzParts[0];\n const minutes = tzParts[1];\n return isH(hours) && isM(minutes);\n } satisfies GenericPureFunction<FormatParams_Time>;\n});\n\n/** @reflection never */\nexport const cpf_isHours = registerPureFnFactory('mionFormats', 'isHours', function () {\n return function is_h(hours: string): hours is 'HH' {\n if (!hours.length || hours.length > 2) return false;\n const numberHours = Number(hours);\n if (isNaN(numberHours)) return false;\n return numberHours >= 0 && numberHours <= 23;\n } satisfies GenericPureFunction<FormatParams_Time>;\n});\n\n/** @reflection never */\nexport const cpf_isMinutes = registerPureFnFactory('mionFormats', 'isMinutes', function () {\n return function is_m(mins: string): mins is 'mm' {\n if (!mins.length || mins.length > 2) return false;\n const numberMinutes = Number(mins);\n if (isNaN(numberMinutes)) return false;\n return numberMinutes >= 0 && numberMinutes <= 59;\n } satisfies GenericPureFunction<FormatParams_Time>;\n});\n\n/** @reflection never */\nexport const cpf_isSeconds = registerPureFnFactory('mionFormats', 'isSeconds', function () {\n return function is_s(secs: string): secs is 'ss' {\n if (!secs.length || secs.length > 2) return false;\n const numberSeconds = Number(secs);\n if (isNaN(numberSeconds)) return false;\n return numberSeconds >= 0 && numberSeconds <= 59;\n } satisfies GenericPureFunction<FormatParams_Time>;\n});\n\n/** @reflection never */\nexport const cpf_isSecondsWithMs = registerPureFnFactory('mionFormats', 'isSecondsWithMs', function (jUtil: JITUtils) {\n const isS = jUtil.getPureFn('mionFormats', 'isSeconds') as ReturnType<typeof cpf_isSeconds.createPureFn>;\n return function is_s_ms(secsAnsMls: string): secsAnsMls is 'ss.mmm' {\n const parts = secsAnsMls.split('.') as ['ss', 'mmm' | undefined];\n if (parts.length > 2) return false;\n const secs = parts[0];\n if (!isS(secs)) return false;\n const mls = parts[1];\n if (mls) {\n if (mls.length !== 3) return false;\n const millisNumber = Number(mls);\n if (isNaN(millisNumber)) return false;\n if (millisNumber < 0 || millisNumber > 999) return false;\n }\n return true;\n } satisfies GenericPureFunction<FormatParams_Time>;\n});\n\n/** @reflection never */\nexport const cpf_isTimeString_ISO_TZ = registerPureFnFactory('mionFormats', 'isTimeString_ISO_TZ', function (jUtil: JITUtils) {\n const isTWms = jUtil.getPureFn('mionFormats', 'isTimeString_ISO') as ReturnType<typeof cpf_isTimeString_ISO.createPureFn>;\n const isTZ = jUtil.getPureFn('mionFormats', 'isTimeZone') as ReturnType<typeof cpf_isTimeZone.createPureFn>;\n return function is_iso_time(value: string): boolean {\n // 'ISO' OR 'HH:mm:ss[.mmm]TZ'\n const isZ = value.endsWith('Z') || value.endsWith('z');\n const isPositiveTZ = isZ || value.indexOf('+') !== -1;\n const isNegativeTZ = isZ || value.indexOf('-') !== -1;\n if (!isZ && !isPositiveTZ && !isNegativeTZ) return false;\n const timeAndTz = isZ\n ? [value.substring(0, value.length - 1), 'Z']\n : (value.split(isPositiveTZ ? '+' : '-') as ['HH:mm:ss[.mmm]', 'TZ']);\n if (timeAndTz.length !== 2) return false;\n const time = timeAndTz[0];\n const tz = timeAndTz[1];\n return isTWms(time) && isTZ(tz);\n } satisfies GenericPureFunction<FormatParams_Time>;\n});\n\n/** @reflection never */\nexport const cpf_isTimeString_ISO = registerPureFnFactory('mionFormats', 'isTimeString_ISO', function (jUtil: JITUtils) {\n const isH = jUtil.getPureFn('mionFormats', 'isHours') as ReturnType<typeof cpf_isHours.createPureFn>;\n const isM = jUtil.getPureFn('mionFormats', 'isMinutes') as ReturnType<typeof cpf_isMinutes.createPureFn>;\n const isSWithMls = jUtil.getPureFn('mionFormats', 'isSecondsWithMs') as ReturnType<typeof cpf_isSecondsWithMs.createPureFn>;\n return function is_iso_time(value: string): boolean {\n const parts = value.split(':');\n return parts.length === 3 && isH(parts[0]) && isM(parts[1]) && isSWithMls(parts[2]);\n } satisfies GenericPureFunction<FormatParams_Time>;\n});\n\n/** @reflection never */\nexport const cpf_isTimeString_HHmmss = registerPureFnFactory('mionFormats', 'isTimeString_HHmmss', function (jUtil: JITUtils) {\n const isH = jUtil.getPureFn('mionFormats', 'isHours') as ReturnType<typeof cpf_isHours.createPureFn>;\n const isM = jUtil.getPureFn('mionFormats', 'isMinutes') as ReturnType<typeof cpf_isMinutes.createPureFn>;\n const isS = jUtil.getPureFn('mionFormats', 'isSeconds') as ReturnType<typeof cpf_isSeconds.createPureFn>;\n return function is_iso_time(value: string): boolean {\n const parts = value.split(':');\n return parts.length === 3 && isH(parts[0]) && isM(parts[1]) && isS(parts[2]);\n } satisfies GenericPureFunction<FormatParams_Time>;\n});\n\n/** @reflection never */\nexport const cpf_isTimeString_HHmm = registerPureFnFactory('mionFormats', 'isTimeString_HHmm', function (jUtil: JITUtils) {\n const isH = jUtil.getPureFn('mionFormats', 'isHours') as ReturnType<typeof cpf_isHours.createPureFn>;\n const isM = jUtil.getPureFn('mionFormats', 'isMinutes') as ReturnType<typeof cpf_isMinutes.createPureFn>;\n return function is_iso_time(value: string): boolean {\n const parts = value.split(':');\n return parts.length === 2 && isH(parts[0]) && isM(parts[1]);\n } satisfies GenericPureFunction<FormatParams_Time>;\n});\n\n/** @reflection never */\nexport const cpf_isTimeString_mmss = registerPureFnFactory('mionFormats', 'isTimeString_mmss', function (jUtil: JITUtils) {\n const isM = jUtil.getPureFn('mionFormats', 'isMinutes') as ReturnType<typeof cpf_isMinutes.createPureFn>;\n const isS = jUtil.getPureFn('mionFormats', 'isSeconds') as ReturnType<typeof cpf_isSeconds.createPureFn>;\n return function is_iso_time(value: string): boolean {\n const parts = value.split(':');\n return parts.length === 2 && isM(parts[0]) && isS(parts[1]);\n } satisfies GenericPureFunction<FormatParams_Time>;\n});\n\n/** Base time pure functions (dependencies for other time functions) */\nexport const pureTimeFns = [cpf_isTimeZone, cpf_isHours, cpf_isMinutes, cpf_isSeconds, cpf_isSecondsWithMs];\n\n/** Time format pure functions */\nexport const timeFunctions = [\n cpf_isTimeString_ISO_TZ,\n cpf_isTimeString_ISO,\n cpf_isTimeString_HHmmss,\n cpf_isTimeString_HHmm,\n cpf_isTimeString_mmss,\n];\n\n// ############### UUID Pure Functions ###############\n\n/** @reflection never */\nexport const cpf_isUUID = registerPureFnFactory('mionFormats', 'isUUID', function () {\n return function is_uuid(value: string, p: FormatParams_UUID) {\n if (value.length !== 36) return false;\n for (let i = 0; i < 36; i++) {\n if (i === 8 || i === 13 || i === 18 || i === 23) {\n if (value[i] !== '-') return false;\n } else if (i === 14) {\n if (value[i] !== p.version) return false;\n } else {\n const charCode = value.charCodeAt(i);\n const is09 = charCode >= 48 && charCode <= 57;\n const isaf = charCode >= 97 && charCode <= 102;\n const isAF = charCode >= 65 && charCode <= 70;\n if (!(is09 || isaf || isAF)) return false;\n }\n }\n return true;\n } as GenericPureFunction<FormatParams_UUID>;\n});\n\n// ############### IP Pure Functions ###############\n\n/** @reflection never */\nexport const cpf_isLocalHost = registerPureFnFactory('mionFormats', 'isLocalHost', function () {\n const lhr = /^localhost$/i;\n return function is_local_host(ip: string, p: FormatParams_IP): boolean {\n if (p.version === 4) return lhr.test(ip) || ip === '127:0:0:1';\n if (p.version === 6) return ip === '::1' || ip === '0:0:0:0:0:0:0:1';\n return lhr.test(ip) || ip === '127:0:0:1' || ip === '::1' || ip === '0:0:0:0:0:0:0:1';\n };\n});\n\n/** @reflection never */\nexport const cpf_isIPV4 = registerPureFnFactory('mionFormats', 'isIPV4', function (utl: JITUtils) {\n const is_Localhost = utl.getPureFn('mionFormats', 'isLocalHost') as ReturnType<typeof cpf_isLocalHost.createPureFn>;\n function get_address(ip: string, p: FormatParams_IP): false | string {\n if (!p.allowPort) return ip;\n const parts = ip.split(':');\n if (parts.length > 2) return false;\n const [address, portS] = parts;\n if (!portS) return address;\n const port = Number(portS);\n if (isNaN(port) || port < 0 || port > 65535) return false;\n return address;\n }\n return function is_ip_v4(ip: string, p: FormatParams_IP): boolean {\n const address = get_address(ip, p);\n if (address === false) return false;\n const isLocal = is_Localhost(address, p);\n if (p.allowLocalHost && isLocal) return true;\n if (!p.allowLocalHost && isLocal) return false;\n const sections = address.split('.');\n if (sections.length !== 4) return false;\n for (const section of sections) {\n const num = Number(section);\n if (isNaN(num) || num < 0 || num > 255) return false;\n }\n return true;\n } as GenericPureFunction<FormatParams_IP>;\n});\n\n/** @reflection never */\nexport const cpf_isIPV6 = registerPureFnFactory('mionFormats', 'isIPV6', function (utl: JITUtils) {\n const is_Localhost = utl.getPureFn('mionFormats', 'isLocalHost') as ReturnType<typeof cpf_isLocalHost.createPureFn>;\n const ipv6PortRegexp = /^\\[([^\\]]+)\\](?::(\\d+))?$/;\n function get_address(ip: string, p: FormatParams_IP): false | string {\n if (!p.allowPort) return ip;\n const match = ip.match(ipv6PortRegexp);\n if (!match) return false;\n const address = match[1];\n const port = match[2];\n if (!port) return address;\n const num = Number(port);\n if (isNaN(num) || num < 0 || num > 65535) return false;\n return address;\n }\n return function is_ip_v6(ip: string, p: FormatParams_IP): boolean {\n const address = get_address(ip, p);\n if (address === false) return false;\n const isLocal = is_Localhost(address, p);\n if (p.allowLocalHost && isLocal) return true;\n if (!p.allowLocalHost && isLocal) return false;\n const sections = address.split(':');\n if (sections.length < 3 || sections.length > 8) return false;\n let doubleColon = 0;\n for (const section of sections) {\n if (section.length === 0) {\n doubleColon++;\n if (doubleColon > 1) return false;\n continue; // Allow empty sections for \"::\"\n }\n if (section.length > 4) return false;\n const num = parseInt(section, 16);\n if (isNaN(num) || num < 0 || num > 0xffff) return false;\n }\n return true;\n } as GenericPureFunction<FormatParams_IP>;\n});\n\n/** @reflection never */\nexport const cpf_mionGetIPErrors = registerPureFnFactory('mionFormats', 'mionGetIPErrors', function (utl: JITUtils) {\n const is_ip_v4 = utl.getPureFn('mionFormats', 'isIPV4') as ReturnType<typeof cpf_isIPV4.createPureFn>;\n const is_ip_v6 = utl.getPureFn('mionFormats', 'isIPV6') as ReturnType<typeof cpf_isIPV6.createPureFn>;\n const noopDeps = {};\n return function get_ip_errors(\n ip: string,\n p: FormatParams_IP,\n fPath: (string | number)[],\n fErrs: TypeFormatError[],\n name = 'ip'\n ): TypeFormatError[] {\n if (p.version === 4 && !is_ip_v4(ip, p, noopDeps))\n return (fErrs.push({name, formatPath: [...fPath, 'version'], val: 4}), fErrs);\n if (p.version === 6 && !is_ip_v6(ip, p, noopDeps))\n return (fErrs.push({name, formatPath: [...fPath, 'version'], val: 6}), fErrs);\n const isIP = is_ip_v4(ip, p, noopDeps) || is_ip_v6(ip, p, noopDeps);\n if (!isIP) fErrs.push({name, formatPath: ['version'], val: 'any'});\n return fErrs;\n };\n});\n\n/** IP pure functions array */\nexport const ipFunctions = [cpf_isLocalHost, cpf_isIPV4, cpf_isIPV6, cpf_mionGetIPErrors];\n\n// ############### All Pure Functions Export ###############\n\n/** All mionFormats pure functions for easy export */\nexport const mionFormatsPureFunctions = [\n // Date functions\n ...dateFunctions,\n // Time functions\n ...pureTimeFns,\n ...timeFunctions,\n // UUID functions\n cpf_isUUID,\n // IP functions\n ...ipFunctions,\n];\n"],"names":["registerPureFnFactory"],"mappings":";;;AA2BO,MAAM,mBAAmBA,KAAAA,sBAAsB,eAAe,gBAAgB,WAAA;AAEjF,SAAO,SAAS,eAAe,MAA0B,OAAe,KAAY;AAChF,QAAI,IAAwB;AAC5B,QAAI,MAAM;AACN,UAAI,KAAK,WAAW;AAAG,eAAO;AAC9B,UAAI,OAAO,IAAI;AACf,UAAI,MAAM,CAAC;AAAG,eAAO;AACrB,UAAI,IAAI,KAAK,IAAI;AAAM,eAAO;AAAA,IAClC;AACA,QAAI,MAAM,WAAW;AAAG,aAAO;AAC/B,UAAM,IAAI,OAAO,KAAK;AACtB,QAAI,MAAM,CAAC;AAAG,aAAO;AACrB,QAAI,IAAI,KAAK,IAAI;AAAI,aAAO;AAC5B,QAAI,KAAK;AACL,UAAI,IAAI,WAAW;AAAG,eAAO;AAC7B,YAAM,IAAI,OAAO,GAAG;AACpB,UAAI,MAAM,CAAC;AAAG,eAAO;AACrB,UAAI,IAAI,KAAK,IAAI;AAAI,eAAO;AAE5B,UAAI,MAAM,GAAG;AACT,YAAI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|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.cjs","sources":["../../../src/utils.ts"],"sourcesContent":["/* ########\n * 2025 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport type {FormatParam, FormatParamLiteral} from '@mionjs/core';\nimport {isFormatParamMeta} from '@mionjs/run-types';\n\n/** Returns the literal value of a FormatParam */\nexport function paramVal<L extends FormatParamLiteral>(p: FormatParam<L>): L {\n return isFormatParamMeta(p) ? p.val : p;\n}\n\n/**\n * Escapes special characters in a regular expression.\n * Should be the same as https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/escape\n * @param val\n * @returns\n */\nexport function regexpEscape(val: string): string {\n return val.replace(/[/\\-\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\n}\n"],"names":["isFormatParamMeta"],"mappings":";;;AAWM,SAAU,SAAuC,GAAiB;AACpE,SAAOA,SAAAA,kBAAkB,CAAC,IAAI,EAAE,MAAM;AAC1C;;AAQM,SAAU,aAAa,KAAW;AACpC,SAAO,IAAI,QAAQ,0BAA0B,MAAM;AACvD;;;;"}
|