@evergonlabs/tmi-protocol-utils 0.11.0-rc.3 → 0.11.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/common.cjs +1 -1
- package/dist/common.cjs.map +1 -1
- package/dist/common.d.cts +2 -25
- package/dist/common.d.ts +2 -25
- package/dist/common.js +1 -1
- package/dist/common.js.map +1 -1
- package/dist/typeUtils.cjs +1 -1
- package/dist/typeUtils.cjs.map +1 -1
- package/dist/typeUtils.d.cts +0 -1
- package/dist/typeUtils.d.ts +0 -1
- package/dist/typeUtils.js +0 -1
- package/dist/typeUtils.js.map +1 -1
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.js.map +1 -1
- package/package.json +5 -5
- package/dist/nonEmptyArray-GKx7EeID.d.cts +0 -4
- package/dist/nonEmptyArray-GKx7EeID.d.ts +0 -4
package/dist/common.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var R=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},h=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of a(t))!l.call(e,s)&&s!==n&&i(e,s,{get:()=>t[s],enumerable:!(r=o(t,s))||r.enumerable});return e};var T=e=>h(i({},"__esModule",{value:!0}),e);var m={};R(m,{joinPaths:()=>p});module.exports=T(m);function p(...e){return u(...e)}function u(...e){return g(e.join("/").replace(/\/+/g,"/").replace(/\/+$/,""))}function g(e){return e.startsWith("/")?e:`/${e}`}0&&(module.exports={joinPaths});
|
|
2
2
|
//# sourceMappingURL=common.cjs.map
|
package/dist/common.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/common/index.ts","../src/common/
|
|
1
|
+
{"version":3,"sources":["../src/common/index.ts","../src/common/joinPath/joinPath.ts"],"sourcesContent":["export * from \"./joinPath/joinPath.js\";\n","import { NonEmptyArray } from \"@evergonlabs/tmi-utils/typeUtils\";\n\ntype RemoveConsecutiveSlashes<T extends string> = T extends `${infer First}//${infer Rest}`\n ? RemoveConsecutiveSlashes<`${First}/${Rest}`>\n : T;\n\nexport type JoinPathResult<T extends string[]> = T extends [infer First, ...infer Rest]\n ? First extends string\n ? Rest extends NonEmptyArray<string>\n ? RemoveConsecutiveSlashes<`/${First}/${JoinPathResult<Rest>}`>\n : RemoveConsecutiveSlashes<`/${First}`>\n : never\n : never;\n\ntype RemoveTrailingSlash<T extends string> = T extends `${infer First}/` ? First : T;\n\nexport function joinPaths<T extends string[]>(...segments: T): RemoveTrailingSlash<JoinPathResult<T>> {\n return joinPathsSimple(...segments) as RemoveTrailingSlash<JoinPathResult<T>>;\n}\n\nfunction joinPathsSimple(...strings: string[]) {\n return prependLeadingSlash(\n strings\n .join(\"/\")\n .replace(/\\/+/g, \"/\") // Remove double slashes\n .replace(/\\/+$/, \"\"), // Remove trailing slash\n );\n}\n\nfunction prependLeadingSlash(str: string) {\n return str.startsWith(\"/\") ? str : `/${str}`;\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,IAAA,eAAAC,EAAAH,GCgBO,SAASI,KAAiCC,EAAqD,CACpG,OAAOC,EAAgB,GAAGD,CAAQ,CACpC,CAEA,SAASC,KAAmBC,EAAmB,CAC7C,OAAOC,EACLD,EACG,KAAK,GAAG,EACR,QAAQ,OAAQ,GAAG,EACnB,QAAQ,OAAQ,EAAE,CACvB,CACF,CAEA,SAASC,EAAoBC,EAAa,CACxC,OAAOA,EAAI,WAAW,GAAG,EAAIA,EAAM,IAAIA,CAAG,EAC5C","names":["common_exports","__export","joinPaths","__toCommonJS","joinPaths","segments","joinPathsSimple","strings","prependLeadingSlash","str"]}
|
package/dist/common.d.cts
CHANGED
|
@@ -1,31 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Trim } from 'type-fest';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* TMI uses percentage with 10^6 base, i.e. 1000000p = 100%
|
|
6
|
-
* @param basisPoints basis points value, i.e. 10000bp = 100%
|
|
7
|
-
* @returns 10^6 bases value
|
|
8
|
-
*/
|
|
9
|
-
declare function bpToFixedPercentage(basisPoints: number): bigint;
|
|
1
|
+
import { NonEmptyArray } from '@evergonlabs/tmi-utils/typeUtils';
|
|
10
2
|
|
|
11
3
|
type RemoveConsecutiveSlashes<T extends string> = T extends `${infer First}//${infer Rest}` ? RemoveConsecutiveSlashes<`${First}/${Rest}`> : T;
|
|
12
4
|
type JoinPathResult<T extends string[]> = T extends [infer First, ...infer Rest] ? First extends string ? Rest extends NonEmptyArray<string> ? RemoveConsecutiveSlashes<`/${First}/${JoinPathResult<Rest>}`> : RemoveConsecutiveSlashes<`/${First}`> : never : never;
|
|
13
5
|
type RemoveTrailingSlash<T extends string> = T extends `${infer First}/` ? First : T;
|
|
14
6
|
declare function joinPaths<T extends string[]>(...segments: T): RemoveTrailingSlash<JoinPathResult<T>>;
|
|
15
7
|
|
|
16
|
-
|
|
17
|
-
type IMiddlewareRequire<InitData, NextData = any> = (input: InitData) => Promise<NextData>;
|
|
18
|
-
type InferMiddlewareInput<T extends IMiddleware> = T extends IMiddleware<infer C, any> ? C : never;
|
|
19
|
-
type InferMiddlewareOutput<T extends IMiddleware> = T extends IMiddleware<any, infer C> ? C : never;
|
|
20
|
-
type IMiddlewares<TMiddleware extends IMiddleware> = {
|
|
21
|
-
add: <TNextMiddleware extends IMiddleware<InferMiddlewareOutput<TMiddleware>, any>>(next: TNextMiddleware) => IMiddlewares<IMiddleware<InferMiddlewareInput<TMiddleware>, InferMiddlewareOutput<TNextMiddleware>>>;
|
|
22
|
-
run: (input: InferMiddlewareInput<TMiddleware>) => Promise<InferMiddlewareOutput<TMiddleware>>;
|
|
23
|
-
};
|
|
24
|
-
declare function createMiddlewares<TMiddleware extends IMiddleware>(middleware: TMiddleware): IMiddlewares<TMiddleware>;
|
|
25
|
-
type IIdentityMiddleware<T> = IMiddleware<T, T>;
|
|
26
|
-
declare const identityMiddleware: <T>(input: T) => Promise<T>;
|
|
27
|
-
|
|
28
|
-
type JoinCamelCaseResult<Words extends string[], IsFirst = false, OutputString extends string = ""> = Words extends [infer FirstWord extends string, ...infer RemainingWords extends string[]] ? Trim<FirstWord> extends "" ? JoinCamelCaseResult<RemainingWords> : IsFirst extends false ? `${Trim<FirstWord>}${JoinCamelCaseResult<RemainingWords, true>}` : `${Capitalize<Trim<FirstWord>>}${JoinCamelCaseResult<RemainingWords, true>}` : OutputString;
|
|
29
|
-
declare function toCamelCase<const T extends string[]>(args: T): JoinCamelCaseResult<T>;
|
|
30
|
-
|
|
31
|
-
export { type IIdentityMiddleware, type IMiddleware, type IMiddlewareRequire, type IMiddlewares, type JoinCamelCaseResult, type JoinPathResult, bpToFixedPercentage, createMiddlewares, identityMiddleware, joinPaths, toCamelCase };
|
|
8
|
+
export { type JoinPathResult, joinPaths };
|
package/dist/common.d.ts
CHANGED
|
@@ -1,31 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Trim } from 'type-fest';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* TMI uses percentage with 10^6 base, i.e. 1000000p = 100%
|
|
6
|
-
* @param basisPoints basis points value, i.e. 10000bp = 100%
|
|
7
|
-
* @returns 10^6 bases value
|
|
8
|
-
*/
|
|
9
|
-
declare function bpToFixedPercentage(basisPoints: number): bigint;
|
|
1
|
+
import { NonEmptyArray } from '@evergonlabs/tmi-utils/typeUtils';
|
|
10
2
|
|
|
11
3
|
type RemoveConsecutiveSlashes<T extends string> = T extends `${infer First}//${infer Rest}` ? RemoveConsecutiveSlashes<`${First}/${Rest}`> : T;
|
|
12
4
|
type JoinPathResult<T extends string[]> = T extends [infer First, ...infer Rest] ? First extends string ? Rest extends NonEmptyArray<string> ? RemoveConsecutiveSlashes<`/${First}/${JoinPathResult<Rest>}`> : RemoveConsecutiveSlashes<`/${First}`> : never : never;
|
|
13
5
|
type RemoveTrailingSlash<T extends string> = T extends `${infer First}/` ? First : T;
|
|
14
6
|
declare function joinPaths<T extends string[]>(...segments: T): RemoveTrailingSlash<JoinPathResult<T>>;
|
|
15
7
|
|
|
16
|
-
|
|
17
|
-
type IMiddlewareRequire<InitData, NextData = any> = (input: InitData) => Promise<NextData>;
|
|
18
|
-
type InferMiddlewareInput<T extends IMiddleware> = T extends IMiddleware<infer C, any> ? C : never;
|
|
19
|
-
type InferMiddlewareOutput<T extends IMiddleware> = T extends IMiddleware<any, infer C> ? C : never;
|
|
20
|
-
type IMiddlewares<TMiddleware extends IMiddleware> = {
|
|
21
|
-
add: <TNextMiddleware extends IMiddleware<InferMiddlewareOutput<TMiddleware>, any>>(next: TNextMiddleware) => IMiddlewares<IMiddleware<InferMiddlewareInput<TMiddleware>, InferMiddlewareOutput<TNextMiddleware>>>;
|
|
22
|
-
run: (input: InferMiddlewareInput<TMiddleware>) => Promise<InferMiddlewareOutput<TMiddleware>>;
|
|
23
|
-
};
|
|
24
|
-
declare function createMiddlewares<TMiddleware extends IMiddleware>(middleware: TMiddleware): IMiddlewares<TMiddleware>;
|
|
25
|
-
type IIdentityMiddleware<T> = IMiddleware<T, T>;
|
|
26
|
-
declare const identityMiddleware: <T>(input: T) => Promise<T>;
|
|
27
|
-
|
|
28
|
-
type JoinCamelCaseResult<Words extends string[], IsFirst = false, OutputString extends string = ""> = Words extends [infer FirstWord extends string, ...infer RemainingWords extends string[]] ? Trim<FirstWord> extends "" ? JoinCamelCaseResult<RemainingWords> : IsFirst extends false ? `${Trim<FirstWord>}${JoinCamelCaseResult<RemainingWords, true>}` : `${Capitalize<Trim<FirstWord>>}${JoinCamelCaseResult<RemainingWords, true>}` : OutputString;
|
|
29
|
-
declare function toCamelCase<const T extends string[]>(args: T): JoinCamelCaseResult<T>;
|
|
30
|
-
|
|
31
|
-
export { type IIdentityMiddleware, type IMiddleware, type IMiddlewareRequire, type IMiddlewares, type JoinCamelCaseResult, type JoinPathResult, bpToFixedPercentage, createMiddlewares, identityMiddleware, joinPaths, toCamelCase };
|
|
8
|
+
export { type JoinPathResult, joinPaths };
|
package/dist/common.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
function n(...e){return t(...e)}function t(...e){return s(e.join("/").replace(/\/+/g,"/").replace(/\/+$/,""))}function s(e){return e.startsWith("/")?e:`/${e}`}export{n as joinPaths};
|
|
2
2
|
//# sourceMappingURL=common.js.map
|
package/dist/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/common/
|
|
1
|
+
{"version":3,"sources":["../src/common/joinPath/joinPath.ts"],"sourcesContent":["import { NonEmptyArray } from \"@evergonlabs/tmi-utils/typeUtils\";\n\ntype RemoveConsecutiveSlashes<T extends string> = T extends `${infer First}//${infer Rest}`\n ? RemoveConsecutiveSlashes<`${First}/${Rest}`>\n : T;\n\nexport type JoinPathResult<T extends string[]> = T extends [infer First, ...infer Rest]\n ? First extends string\n ? Rest extends NonEmptyArray<string>\n ? RemoveConsecutiveSlashes<`/${First}/${JoinPathResult<Rest>}`>\n : RemoveConsecutiveSlashes<`/${First}`>\n : never\n : never;\n\ntype RemoveTrailingSlash<T extends string> = T extends `${infer First}/` ? First : T;\n\nexport function joinPaths<T extends string[]>(...segments: T): RemoveTrailingSlash<JoinPathResult<T>> {\n return joinPathsSimple(...segments) as RemoveTrailingSlash<JoinPathResult<T>>;\n}\n\nfunction joinPathsSimple(...strings: string[]) {\n return prependLeadingSlash(\n strings\n .join(\"/\")\n .replace(/\\/+/g, \"/\") // Remove double slashes\n .replace(/\\/+$/, \"\"), // Remove trailing slash\n );\n}\n\nfunction prependLeadingSlash(str: string) {\n return str.startsWith(\"/\") ? str : `/${str}`;\n}\n"],"mappings":"AAgBO,SAASA,KAAiCC,EAAqD,CACpG,OAAOC,EAAgB,GAAGD,CAAQ,CACpC,CAEA,SAASC,KAAmBC,EAAmB,CAC7C,OAAOC,EACLD,EACG,KAAK,GAAG,EACR,QAAQ,OAAQ,GAAG,EACnB,QAAQ,OAAQ,EAAE,CACvB,CACF,CAEA,SAASC,EAAoBC,EAAa,CACxC,OAAOA,EAAI,WAAW,GAAG,EAAIA,EAAM,IAAIA,CAAG,EAC5C","names":["joinPaths","segments","joinPathsSimple","strings","prependLeadingSlash","str"]}
|
package/dist/typeUtils.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var b=(r,o,p,f)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of x(o))!a.call(r,e)&&e!==p&&m(r,e,{get:()=>o[e],enumerable:!(f=t(o,e))||f.enumerable});return r};var c=r=>b(m({},"__esModule",{value:!0}),r);var d={};module.exports=c(d);
|
|
2
2
|
//# sourceMappingURL=typeUtils.cjs.map
|
package/dist/typeUtils.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/typeUtils/index.ts"
|
|
1
|
+
{"version":3,"sources":["../src/typeUtils/index.ts"],"sourcesContent":["export * from \"./common.js\";\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["typeUtils_exports","__toCommonJS"]}
|
package/dist/typeUtils.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ConditionalKeys } from 'type-fest';
|
|
2
|
-
export { N as NonEmptyArray, i as isNonEmptyArray } from './nonEmptyArray-GKx7EeID.cjs';
|
|
3
2
|
|
|
4
3
|
type ExcludeVoidKeys<T> = Exclude<keyof T, ConditionalKeys<T, void>>;
|
|
5
4
|
type ExcludeVoidProperties<T> = Pick<T, ExcludeVoidKeys<T>>;
|
package/dist/typeUtils.d.ts
CHANGED
package/dist/typeUtils.js
CHANGED
package/dist/typeUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/zod.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/zod/index.ts","../../../node_modules/.pnpm/@evergonlabs+tmi-utils@0.8.0-rc.0_type-fest@5.4.4_typescript@5.7.3_viem@2.46.2_bufferut_0de127f6c973c87270308f40f6c18316/node_modules/@evergonlabs/tmi-utils/dist/models.js"],"sourcesContent":["// eslint-disable-next-line simple-import-sort/imports\nimport \"@hono/zod-openapi\";\nimport { z } from \"zod\";\nimport {\n AddressSchema as _AddressSchema,\n HexStringSchema as _HexStringSchema,\n HttpsUrlSchema as _HttpsUrlSchema,\n Int256Json as _Int256Json,\n IpfsUrlSchema as _IpfsUrlSchema,\n ISODateString,\n PercentageSchema as _PercentageSchema,\n TransactionHashSchema as _TransactionHashSchema,\n} from \"@evergonlabs/tmi-utils/models\";\n\nexport const AddressSchema = _AddressSchema.openapi({\n type: \"string\",\n example: \"0x0000000000000000000000000000000000000000\",\n});\n\nexport const HexStringSchema = _HexStringSchema.openapi({\n type: \"string\",\n example: \"0x\",\n});\n\nexport const HashSchema = _TransactionHashSchema.openapi({\n type: \"string\",\n minLength: 66,\n maxLength: 66,\n example: \"0x02dfb1fcdb76a64b88e5b31ab393bf3302e2fade282123bd9ca473d0e26a25df\",\n description: \"Transaction hash\",\n});\n\nexport const AbiSchema = z.array(z.any()).openapi({\n description: \"ABI of a contract. Can be used for contract output decode.\",\n type: \"array\",\n});\n\nexport const ISOJson = ISODateString.openapi({\n description: \"Date in ISO format\",\n});\n\nexport type IISOJson = z.output<typeof ISOJson>;\n\nexport function toISOJson(date: Date): IISOJson {\n return date.toISOString() as IISOJson;\n}\n\nexport function ISODate(validator?: z.ZodDate) {\n return ISOJson.transform((x) => {\n const val = new Date(x);\n if (validator) validator.parse(val);\n return val;\n });\n}\n\nconst Int256Json = _Int256Json.openapi({\n description: \"Big integer 256 bit\",\n});\n\nexport function Int256BigInt(validator?: z.ZodBigInt) {\n return Int256Json.transform((x) => {\n const val = BigInt(x);\n if (validator) validator.parse(val);\n return val;\n }).openapi({\n example: \"42\",\n type: \"integer\",\n });\n}\n\nexport const PercentageSchema = _PercentageSchema.openapi({\n description: \"Percentage in basis points, i.e. 10000bp = 100%\",\n});\n\nexport const IpfsUrlSchema = _IpfsUrlSchema.openapi({\n type: \"string\",\n example: \"ipfs://\",\n});\n\nexport const HttpsUrlSchema = _HttpsUrlSchema.openapi({\n type: \"string\",\n example: \"https://example.com\",\n});\n\nexport { z };\n","// src/models/basisPoints/basisPoints.ts\nimport z from \"zod\";\nvar BasisPointsSchema = z.number().int().transform((x) => x);\nfunction bpToFixedPercentage(basisPoints) {\n if (!Number.isInteger(basisPoints)) {\n throw new Error(`Basis points must be an integer, got ${basisPoints}`);\n }\n if (basisPoints < 0 || basisPoints > 1e4) {\n throw new Error(`Basis points must be in [0, 10000], got ${basisPoints}`);\n }\n return BigInt(basisPoints) * 100n;\n}\n\n// src/models/errorLike.ts\nimport { z as z2 } from \"zod\";\nvar ErrorLikeSchema = z2.object({\n name: z2.string(),\n message: z2.string()\n});\n\n// src/models/htmlString.ts\nvar HtmlString = (schema) => schema.refine((data) => HTML_PATTERN.test(data), {\n message: \"Invalid HTML format\"\n});\nvar HTML_PATTERN = /<\\/?[a-z][\\s\\S]*>/i;\n\n// src/models/id.ts\nimport z3 from \"zod\";\nfunction IdSchema(brandName) {\n return z3.string().brand(brandName);\n}\n\n// src/models/int256.ts\nimport z5 from \"zod\";\n\n// src/models/numberish/numberish.ts\nimport { z as z4 } from \"zod\";\nvar NumberishSchema = z4.union([z4.string(), z4.number(), z4.bigint()]);\nvar NumberishJsonSchema = z4.union([z4.string(), z4.number()]);\nvar StringNumberSchema = z4.string().transform((x) => x.replace(\",\", \".\")).refine((x) => !isNaN(Number(x)), { message: \"Invalid number format\" }).transform((x) => Number(x));\n\n// src/models/int256.ts\nvar Int256 = createInt256((x) => x);\nvar Int256Positive = createInt256((x) => x.min(BigInt(0)));\nfunction createInt256(corce) {\n return NumberishSchema.pipe(corce(z5.coerce.bigint()));\n}\nvar Int256Json = z5.string().brand(\"Int256\");\nfunction toInt256Json(value) {\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n if (typeof value === \"number\") {\n if (!Number.isSafeInteger(value)) {\n throw new Error(`Number ${value} is not a safe integer and cannot be converted to bigint`);\n }\n return value.toString();\n }\n if (typeof value === \"string\") {\n if (value.trim().length === 0) {\n throw new Error(\"String cannot be empty\");\n }\n try {\n return value.trim();\n } catch {\n throw new Error(`String \"${value}\" is not a valid bigint`);\n }\n }\n throw new Error(`Invalid type: ${typeof value}`);\n}\n\n// src/models/isoString/isoString.ts\nimport { z as z6 } from \"zod\";\nvar ISODateString = z6.string().refine((value) => !Number.isNaN(new Date(value).getTime()), {\n message: \"Invalid ISO 8601 date string\"\n}).brand();\n\n// src/models/nullableInput.ts\nimport z7 from \"zod\";\nfunction NullableInput(schema) {\n return z7.nullable(schema).pipe(schema);\n}\n\n// src/models/nullableString.ts\nimport z8 from \"zod\";\nfunction NullableString(base) {\n return z8.nullable(base ?? z8.string()).transform((x) => x === \"\" ? null : x);\n}\n\n// src/models/percentage/percentage.ts\nimport z9 from \"zod\";\nfunction percentageToBp(percentage) {\n const basis = Math.round(percentage * 100);\n if (Math.abs(basis - percentage * 100) > 1e-9) {\n throw new Error(\"Too many decimals, expected 2\");\n }\n return basis;\n}\nfunction bpToPercentage(bps) {\n return bps / 100;\n}\nvar PercentageNumber = z9.number().refine((val) => Math.abs(Math.round(val * 100) - val * 100) < 1e-9, {\n message: \"Percentage can have at most 2 decimal places\"\n}).transform((x) => x);\nvar PercentageSchema = StringNumberSchema.pipe(PercentageNumber);\n\n// src/models/phoneNumber/phoneNumber.ts\nimport { z as z10 } from \"zod\";\nvar phoneRegex = new RegExp(/^\\+?(?:[0-9]{1,3})?[-. (]*[0-9]{1,4}[-. )]*(?:[0-9]{1,4}[-. ]*){1,3}[0-9]{1,4}$/);\nvar PhoneNumberSchema = z10.string().min(7).regex(phoneRegex, \"Invalid phone number\");\n\n// src/models/uri/https.ts\nimport { z as z11 } from \"zod\";\nvar HttpsUrlSchema = z11.string().url().refine((val) => val.startsWith(\"https://\"), {\n message: \"URL must start with https://\"\n});\n\n// src/models/uri/ipfs.ts\nimport { z as z12 } from \"zod\";\nvar IpfsUrlSchema = z12.string().regex(/^ipfs:\\/\\S+$/, {\n message: \"Must start with ipfs://\"\n});\n\n// src/models/viem/address.ts\nimport { isAddress } from \"viem\";\nimport { z as z13 } from \"zod\";\nvar AddressSchema = z13.string().refine((x) => isAddress(x), { message: \"Not a valid address string\" }).transform((x) => x);\n\n// src/models/viem/hex.ts\nimport { isHex } from \"viem\";\nimport { z as z14 } from \"zod\";\nvar HexStringSchema = z14.string().refine((x) => isHex(x), { message: \"Not a valid Hexademical string\" }).transform((x) => x);\n\n// src/models/viem/supportedChainId.ts\nimport { extractChain } from \"viem\";\nimport { z as z15 } from \"zod\";\nfunction SupportedChainIds(chains) {\n const literals = chains.map((chain) => z15.literal(`${chain.id}`));\n return z15.union(literals);\n}\nfunction createSupportedChains(chains) {\n const Schema = SupportedChainIds(chains);\n return {\n Schema,\n chains,\n chainIds: chains.map((x) => `${x.id}`),\n isSupported: (chainId) => !!chains.find((x) => `${x.id}` === chainId),\n get: (chainId) => extractChain({ chains, id: Number(chainId) })\n };\n}\n\n// src/models/viem/transactionHash.ts\nimport { isHash } from \"viem\";\nimport { z as z16 } from \"zod\";\nvar TransactionHashSchema = z16.string().refine((x) => isHash(x), { message: \"Not a valid transaction hash string\" }).transform((x) => x);\nexport {\n AddressSchema,\n BasisPointsSchema,\n ErrorLikeSchema,\n HexStringSchema,\n HtmlString,\n HttpsUrlSchema,\n ISODateString,\n IdSchema,\n Int256,\n Int256Json,\n Int256Positive,\n IpfsUrlSchema,\n NullableInput,\n NullableString,\n NumberishJsonSchema,\n NumberishSchema,\n PercentageNumber,\n PercentageSchema,\n PhoneNumberSchema,\n StringNumberSchema,\n SupportedChainIds,\n TransactionHashSchema,\n bpToFixedPercentage,\n bpToPercentage,\n createInt256,\n createSupportedChains,\n percentageToBp,\n toInt256Json\n};\n"],"mappings":"0jBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,eAAAE,EAAA,kBAAAC,EAAA,eAAAC,EAAA,oBAAAC,EAAA,mBAAAC,GAAA,YAAAC,GAAA,YAAAC,EAAA,iBAAAC,GAAA,kBAAAC,GAAA,qBAAAC,GAAA,cAAAC,GAAA,2BAAAC,EAAAb,IACA,IAAAc,GAAO,6BACPC,EAAkB,eCDlB,IAAAC,EAAc,oBAadA,EAAwB,eAaxBA,EAAe,oBAMfA,EAAe,oBAGfA,EAAwB,eAoCxBA,EAAwB,eAMxBA,EAAe,oBAMfA,EAAe,oBAMfA,EAAe,oBAiBfA,EAAyB,eAKzBA,EAAyB,eAMzBA,EAAyB,eAMzBC,EAA0B,gBAC1BD,EAAyB,eAIzBC,EAAsB,gBACtBD,EAAyB,eAIzBC,EAA6B,gBAC7BD,EAAyB,eAiBzBC,EAAuB,gBACvBD,EAAyB,eAvJrBE,GAAoB,EAAAC,QAAE,OAAO,EAAE,IAAI,EAAE,UAAWC,GAAMA,CAAC,EAa3D,IAAIC,GAAkB,EAAAC,EAAG,OAAO,CAC9B,KAAM,EAAAA,EAAG,OAAO,EAChB,QAAS,EAAAA,EAAG,OAAO,CACrB,CAAC,EAmBD,IAAIC,EAAkB,EAAAC,EAAG,MAAM,CAAC,EAAAA,EAAG,OAAO,EAAG,EAAAA,EAAG,OAAO,EAAG,EAAAA,EAAG,OAAO,CAAC,CAAC,EAClEC,GAAsB,EAAAD,EAAG,MAAM,CAAC,EAAAA,EAAG,OAAO,EAAG,EAAAA,EAAG,OAAO,CAAC,CAAC,EACzDE,EAAqB,EAAAF,EAAG,OAAO,EAAE,UAAW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S,SACX,CAAC,EAEYC,GAAiBA,EAAgB,QAAQ,CACpD,KAAM,SACN,QAAS,qBACX,CAAC","names":["zod_exports","__export","AbiSchema","AddressSchema","HashSchema","HexStringSchema","HttpsUrlSchema","ISODate","ISOJson","Int256BigInt","IpfsUrlSchema","PercentageSchema","toISOJson","__toCommonJS","import_zod_openapi","import_zod","import_zod","import_viem","BasisPointsSchema","z","x","ErrorLikeSchema","z2","NumberishSchema","z4","NumberishJsonSchema","StringNumberSchema","x","Int256","createInt256","Int256Positive","corce","z5","Int256Json","ISODateString","z6","value","PercentageNumber","z9","val","x","PercentageSchema","StringNumberSchema","phoneRegex","PhoneNumberSchema","z10","HttpsUrlSchema","z11","IpfsUrlSchema","z12","AddressSchema","z13","HexStringSchema","z14","TransactionHashSchema","z16","x","AddressSchema","HexStringSchema","HashSchema","TransactionHashSchema","AbiSchema","ISOJson","ISODateString","toISOJson","date","ISODate","validator","x","val","Int256Json","Int256BigInt","PercentageSchema","IpfsUrlSchema","HttpsUrlSchema"]}
|
|
1
|
+
{"version":3,"sources":["../src/zod/index.ts","../../../node_modules/.pnpm/@evergonlabs+tmi-utils@0.8.0-rc.1_type-fest@5.4.4_typescript@5.7.3_viem@2.46.2_bufferut_a12db19da3918260259d0daa35f81109/node_modules/@evergonlabs/tmi-utils/dist/models.js"],"sourcesContent":["// eslint-disable-next-line simple-import-sort/imports\nimport \"@hono/zod-openapi\";\nimport { z } from \"zod\";\nimport {\n AddressSchema as _AddressSchema,\n HexStringSchema as _HexStringSchema,\n HttpsUrlSchema as _HttpsUrlSchema,\n Int256Json as _Int256Json,\n IpfsUrlSchema as _IpfsUrlSchema,\n ISODateString,\n PercentageSchema as _PercentageSchema,\n TransactionHashSchema as _TransactionHashSchema,\n} from \"@evergonlabs/tmi-utils/models\";\n\nexport const AddressSchema = _AddressSchema.openapi({\n type: \"string\",\n example: \"0x0000000000000000000000000000000000000000\",\n});\n\nexport const HexStringSchema = _HexStringSchema.openapi({\n type: \"string\",\n example: \"0x\",\n});\n\nexport const HashSchema = _TransactionHashSchema.openapi({\n type: \"string\",\n minLength: 66,\n maxLength: 66,\n example: \"0x02dfb1fcdb76a64b88e5b31ab393bf3302e2fade282123bd9ca473d0e26a25df\",\n description: \"Transaction hash\",\n});\n\nexport const AbiSchema = z.array(z.any()).openapi({\n description: \"ABI of a contract. Can be used for contract output decode.\",\n type: \"array\",\n});\n\nexport const ISOJson = ISODateString.openapi({\n description: \"Date in ISO format\",\n});\n\nexport type IISOJson = z.output<typeof ISOJson>;\n\nexport function toISOJson(date: Date): IISOJson {\n return date.toISOString() as IISOJson;\n}\n\nexport function ISODate(validator?: z.ZodDate) {\n return ISOJson.transform((x) => {\n const val = new Date(x);\n if (validator) validator.parse(val);\n return val;\n });\n}\n\nconst Int256Json = _Int256Json.openapi({\n description: \"Big integer 256 bit\",\n});\n\nexport function Int256BigInt(validator?: z.ZodBigInt) {\n return Int256Json.transform((x) => {\n const val = BigInt(x);\n if (validator) validator.parse(val);\n return val;\n }).openapi({\n example: \"42\",\n type: \"integer\",\n });\n}\n\nexport const PercentageSchema = _PercentageSchema.openapi({\n description: \"Percentage in basis points, i.e. 10000bp = 100%\",\n});\n\nexport const IpfsUrlSchema = _IpfsUrlSchema.openapi({\n type: \"string\",\n example: \"ipfs://\",\n});\n\nexport const HttpsUrlSchema = _HttpsUrlSchema.openapi({\n type: \"string\",\n example: \"https://example.com\",\n});\n\nexport { z };\n","// src/models/basisPoints/basisPoints.ts\nimport z from \"zod\";\nvar BasisPointsSchema = z.number().int().transform((x) => x);\nfunction bpToFixedPercentage(basisPoints) {\n if (!Number.isInteger(basisPoints)) {\n throw new Error(`Basis points must be an integer, got ${basisPoints}`);\n }\n if (basisPoints < 0 || basisPoints > 1e4) {\n throw new Error(`Basis points must be in [0, 10000], got ${basisPoints}`);\n }\n return BigInt(basisPoints) * 100n;\n}\n\n// src/models/errorLike.ts\nimport { z as z2 } from \"zod\";\nvar ErrorLikeSchema = z2.object({\n name: z2.string(),\n message: z2.string()\n});\n\n// src/models/htmlString.ts\nvar HtmlString = (schema) => schema.refine((data) => HTML_PATTERN.test(data), {\n message: \"Invalid HTML format\"\n});\nvar HTML_PATTERN = /<\\/?[a-z][\\s\\S]*>/i;\n\n// src/models/id.ts\nimport z3 from \"zod\";\nfunction IdSchema(brandName) {\n return z3.string().brand(brandName);\n}\n\n// src/models/int256.ts\nimport z5 from \"zod\";\n\n// src/models/numberish/numberish.ts\nimport { z as z4 } from \"zod\";\nvar NumberishSchema = z4.union([z4.string(), z4.number(), z4.bigint()]);\nvar NumberishJsonSchema = z4.union([z4.string(), z4.number()]);\nvar StringNumberSchema = z4.string().transform((x) => x.replace(\",\", \".\")).refine((x) => !isNaN(Number(x)), { message: \"Invalid number format\" }).transform((x) => Number(x));\n\n// src/models/int256.ts\nvar Int256 = createInt256((x) => x);\nvar Int256Positive = createInt256((x) => x.min(BigInt(0)));\nfunction createInt256(corce) {\n return NumberishSchema.pipe(corce(z5.coerce.bigint()));\n}\nvar Int256Json = z5.string().brand(\"Int256\");\nfunction toInt256Json(value) {\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n if (typeof value === \"number\") {\n if (!Number.isSafeInteger(value)) {\n throw new Error(`Number ${value} is not a safe integer and cannot be converted to bigint`);\n }\n return value.toString();\n }\n if (typeof value === \"string\") {\n if (value.trim().length === 0) {\n throw new Error(\"String cannot be empty\");\n }\n try {\n return value.trim();\n } catch {\n throw new Error(`String \"${value}\" is not a valid bigint`);\n }\n }\n throw new Error(`Invalid type: ${typeof value}`);\n}\n\n// src/models/isoString/isoString.ts\nimport { z as z6 } from \"zod\";\nvar ISODateString = z6.string().refine((value) => !Number.isNaN(new Date(value).getTime()), {\n message: \"Invalid ISO 8601 date string\"\n}).brand();\n\n// src/models/nullableInput.ts\nimport z7 from \"zod\";\nfunction NullableInput(schema) {\n return z7.nullable(schema).pipe(schema);\n}\n\n// src/models/nullableString.ts\nimport z8 from \"zod\";\nfunction NullableString(base) {\n return z8.nullable(base ?? z8.string()).transform((x) => x === \"\" ? null : x);\n}\n\n// src/models/percentage/percentage.ts\nimport z9 from \"zod\";\nfunction percentageToBp(percentage) {\n const basis = Math.round(percentage * 100);\n if (Math.abs(basis - percentage * 100) > 1e-9) {\n throw new Error(\"Too many decimals, expected 2\");\n }\n return basis;\n}\nfunction bpToPercentage(bps) {\n return bps / 100;\n}\nvar PercentageNumber = z9.number().refine((val) => Math.abs(Math.round(val * 100) - val * 100) < 1e-9, {\n message: \"Percentage can have at most 2 decimal places\"\n}).transform((x) => x);\nvar PercentageSchema = StringNumberSchema.pipe(PercentageNumber);\n\n// src/models/phoneNumber/phoneNumber.ts\nimport { z as z10 } from \"zod\";\nvar phoneRegex = new RegExp(/^\\+?(?:[0-9]{1,3})?[-. (]*[0-9]{1,4}[-. )]*(?:[0-9]{1,4}[-. ]*){1,3}[0-9]{1,4}$/);\nvar PhoneNumberSchema = z10.string().min(7).regex(phoneRegex, \"Invalid phone number\");\n\n// src/models/uri/https.ts\nimport { z as z11 } from \"zod\";\nvar HttpsUrlSchema = z11.string().url().refine((val) => val.startsWith(\"https://\"), {\n message: \"URL must start with https://\"\n});\n\n// src/models/uri/ipfs.ts\nimport { z as z12 } from \"zod\";\nvar IpfsUrlSchema = z12.string().regex(/^ipfs:\\/\\S+$/, {\n message: \"Must start with ipfs://\"\n});\n\n// src/models/viem/address.ts\nimport { isAddress } from \"viem\";\nimport { z as z13 } from \"zod\";\nvar AddressSchema = z13.string().refine((x) => isAddress(x), { message: \"Not a valid address string\" }).transform((x) => x);\n\n// src/models/viem/hex.ts\nimport { isHex } from \"viem\";\nimport { z as z14 } from \"zod\";\nvar HexStringSchema = z14.string().refine((x) => isHex(x), { message: \"Not a valid Hexademical string\" }).transform((x) => x);\n\n// src/models/viem/supportedChainId.ts\nimport { extractChain } from \"viem\";\nimport { z as z15 } from \"zod\";\nfunction SupportedChainIds(chains) {\n const literals = chains.map((chain) => z15.literal(`${chain.id}`));\n return z15.union(literals);\n}\nfunction createSupportedChains(chains) {\n const Schema = SupportedChainIds(chains);\n return {\n Schema,\n chains,\n chainIds: chains.map((x) => `${x.id}`),\n isSupported: (chainId) => !!chains.find((x) => `${x.id}` === chainId),\n get: (chainId) => extractChain({ chains, id: Number(chainId) })\n };\n}\n\n// src/models/viem/transactionHash.ts\nimport { isHash } from \"viem\";\nimport { z as z16 } from \"zod\";\nvar TransactionHashSchema = z16.string().refine((x) => isHash(x), { message: \"Not a valid transaction hash string\" }).transform((x) => x);\nexport {\n AddressSchema,\n BasisPointsSchema,\n ErrorLikeSchema,\n HexStringSchema,\n HtmlString,\n HttpsUrlSchema,\n ISODateString,\n IdSchema,\n Int256,\n Int256Json,\n Int256Positive,\n IpfsUrlSchema,\n NullableInput,\n NullableString,\n NumberishJsonSchema,\n NumberishSchema,\n PercentageNumber,\n PercentageSchema,\n PhoneNumberSchema,\n StringNumberSchema,\n SupportedChainIds,\n TransactionHashSchema,\n bpToFixedPercentage,\n bpToPercentage,\n createInt256,\n createSupportedChains,\n percentageToBp,\n toInt256Json\n};\n"],"mappings":"0jBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,eAAAE,EAAA,kBAAAC,EAAA,eAAAC,EAAA,oBAAAC,EAAA,mBAAAC,GAAA,YAAAC,GAAA,YAAAC,EAAA,iBAAAC,GAAA,kBAAAC,GAAA,qBAAAC,GAAA,cAAAC,GAAA,2BAAAC,EAAAb,IACA,IAAAc,GAAO,6BACPC,EAAkB,eCDlB,IAAAC,EAAc,oBAadA,EAAwB,eAaxBA,EAAe,oBAMfA,EAAe,oBAGfA,EAAwB,eAoCxBA,EAAwB,eAMxBA,EAAe,oBAMfA,EAAe,oBAMfA,EAAe,oBAiBfA,EAAyB,eAKzBA,EAAyB,eAMzBA,EAAyB,eAMzBC,EAA0B,gBAC1BD,EAAyB,eAIzBC,EAAsB,gBACtBD,EAAyB,eAIzBC,EAA6B,gBAC7BD,EAAyB,eAiBzBC,EAAuB,gBACvBD,EAAyB,eAvJrBE,GAAo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AAI,KAAKD,CAAC,EACtB,OAAID,GAAWA,EAAU,MAAME,CAAG,EAC3BA,CACT,CAAC,CACH,CAEA,IAAMC,GAAaA,EAAY,QAAQ,CACrC,YAAa,qBACf,CAAC,EAEM,SAASC,GAAaJ,EAAyB,CACpD,OAAOG,GAAW,UAAWF,GAAM,CACjC,IAAMC,EAAM,OAAOD,CAAC,EACpB,OAAID,GAAWA,EAAU,MAAME,CAAG,EAC3BA,CACT,CAAC,EAAE,QAAQ,CACT,QAAS,KACT,KAAM,SACR,CAAC,CACH,CAEO,IAAMG,GAAmBA,EAAkB,QAAQ,CACxD,YAAa,iDACf,CAAC,EAEYC,GAAgBA,EAAe,QAAQ,CAClD,KAAM,SACN,QAAS,SACX,CAAC,EAEYC,GAAiBA,EAAgB,QAAQ,CACpD,KAAM,SACN,QAAS,qBACX,CAAC","names":["zod_exports","__export","AbiSchema","AddressSchema","HashSchema","HexStringSchema","HttpsUrlSchema","ISODate","ISOJson","Int256BigInt","IpfsUrlSchema","PercentageSchema","toISOJson","__toCommonJS","import_zod_openapi","import_zod","import_zod","import_viem","BasisPointsSchema","z","x","ErrorLikeSchema","z2","NumberishSchema","z4","NumberishJsonSchema","StringNumberSchema","x","Int256","createInt256","Int256Positive","corce","z5","Int256Json","ISODateString","z6","value","PercentageNumber","z9","val","x","PercentageSchema","StringNumberSchema","phoneRegex","PhoneNumberSchema","z10","HttpsUrlSchema","z11","IpfsUrlSchema","z12","AddressSchema","z13","HexStringSchema","z14","TransactionHashSchema","z16","x","AddressSchema","HexStringSchema","HashSchema","TransactionHashSchema","AbiSchema","ISOJson","ISODateString","toISOJson","date","ISODate","validator","x","val","Int256Json","Int256BigInt","PercentageSchema","IpfsUrlSchema","HttpsUrlSchema"]}
|
package/dist/zod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/zod/index.ts","../../../node_modules/.pnpm/@evergonlabs+tmi-utils@0.8.0-rc.0_type-fest@5.4.4_typescript@5.7.3_viem@2.46.2_bufferut_0de127f6c973c87270308f40f6c18316/node_modules/@evergonlabs/tmi-utils/dist/models.js"],"sourcesContent":["// eslint-disable-next-line simple-import-sort/imports\nimport \"@hono/zod-openapi\";\nimport { z } from \"zod\";\nimport {\n AddressSchema as _AddressSchema,\n HexStringSchema as _HexStringSchema,\n HttpsUrlSchema as _HttpsUrlSchema,\n Int256Json as _Int256Json,\n IpfsUrlSchema as _IpfsUrlSchema,\n ISODateString,\n PercentageSchema as _PercentageSchema,\n TransactionHashSchema as _TransactionHashSchema,\n} from \"@evergonlabs/tmi-utils/models\";\n\nexport const AddressSchema = _AddressSchema.openapi({\n type: \"string\",\n example: \"0x0000000000000000000000000000000000000000\",\n});\n\nexport const HexStringSchema = _HexStringSchema.openapi({\n type: \"string\",\n example: \"0x\",\n});\n\nexport const HashSchema = _TransactionHashSchema.openapi({\n type: \"string\",\n minLength: 66,\n maxLength: 66,\n example: \"0x02dfb1fcdb76a64b88e5b31ab393bf3302e2fade282123bd9ca473d0e26a25df\",\n description: \"Transaction hash\",\n});\n\nexport const AbiSchema = z.array(z.any()).openapi({\n description: \"ABI of a contract. Can be used for contract output decode.\",\n type: \"array\",\n});\n\nexport const ISOJson = ISODateString.openapi({\n description: \"Date in ISO format\",\n});\n\nexport type IISOJson = z.output<typeof ISOJson>;\n\nexport function toISOJson(date: Date): IISOJson {\n return date.toISOString() as IISOJson;\n}\n\nexport function ISODate(validator?: z.ZodDate) {\n return ISOJson.transform((x) => {\n const val = new Date(x);\n if (validator) validator.parse(val);\n return val;\n });\n}\n\nconst Int256Json = _Int256Json.openapi({\n description: \"Big integer 256 bit\",\n});\n\nexport function Int256BigInt(validator?: z.ZodBigInt) {\n return Int256Json.transform((x) => {\n const val = BigInt(x);\n if (validator) validator.parse(val);\n return val;\n }).openapi({\n example: \"42\",\n type: \"integer\",\n });\n}\n\nexport const PercentageSchema = _PercentageSchema.openapi({\n description: \"Percentage in basis points, i.e. 10000bp = 100%\",\n});\n\nexport const IpfsUrlSchema = _IpfsUrlSchema.openapi({\n type: \"string\",\n example: \"ipfs://\",\n});\n\nexport const HttpsUrlSchema = _HttpsUrlSchema.openapi({\n type: \"string\",\n example: \"https://example.com\",\n});\n\nexport { z };\n","// src/models/basisPoints/basisPoints.ts\nimport z from \"zod\";\nvar BasisPointsSchema = z.number().int().transform((x) => x);\nfunction bpToFixedPercentage(basisPoints) {\n if (!Number.isInteger(basisPoints)) {\n throw new Error(`Basis points must be an integer, got ${basisPoints}`);\n }\n if (basisPoints < 0 || basisPoints > 1e4) {\n throw new Error(`Basis points must be in [0, 10000], got ${basisPoints}`);\n }\n return BigInt(basisPoints) * 100n;\n}\n\n// src/models/errorLike.ts\nimport { z as z2 } from \"zod\";\nvar ErrorLikeSchema = z2.object({\n name: z2.string(),\n message: z2.string()\n});\n\n// src/models/htmlString.ts\nvar HtmlString = (schema) => schema.refine((data) => HTML_PATTERN.test(data), {\n message: \"Invalid HTML format\"\n});\nvar HTML_PATTERN = /<\\/?[a-z][\\s\\S]*>/i;\n\n// src/models/id.ts\nimport z3 from \"zod\";\nfunction IdSchema(brandName) {\n return z3.string().brand(brandName);\n}\n\n// src/models/int256.ts\nimport z5 from \"zod\";\n\n// src/models/numberish/numberish.ts\nimport { z as z4 } from \"zod\";\nvar NumberishSchema = z4.union([z4.string(), z4.number(), z4.bigint()]);\nvar NumberishJsonSchema = z4.union([z4.string(), z4.number()]);\nvar StringNumberSchema = z4.string().transform((x) => x.replace(\",\", \".\")).refine((x) => !isNaN(Number(x)), { message: \"Invalid number format\" }).transform((x) => Number(x));\n\n// src/models/int256.ts\nvar Int256 = createInt256((x) => x);\nvar Int256Positive = createInt256((x) => x.min(BigInt(0)));\nfunction createInt256(corce) {\n return NumberishSchema.pipe(corce(z5.coerce.bigint()));\n}\nvar Int256Json = z5.string().brand(\"Int256\");\nfunction toInt256Json(value) {\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n if (typeof value === \"number\") {\n if (!Number.isSafeInteger(value)) {\n throw new Error(`Number ${value} is not a safe integer and cannot be converted to bigint`);\n }\n return value.toString();\n }\n if (typeof value === \"string\") {\n if (value.trim().length === 0) {\n throw new Error(\"String cannot be empty\");\n }\n try {\n return value.trim();\n } catch {\n throw new Error(`String \"${value}\" is not a valid bigint`);\n }\n }\n throw new Error(`Invalid type: ${typeof value}`);\n}\n\n// src/models/isoString/isoString.ts\nimport { z as z6 } from \"zod\";\nvar ISODateString = z6.string().refine((value) => !Number.isNaN(new Date(value).getTime()), {\n message: \"Invalid ISO 8601 date string\"\n}).brand();\n\n// src/models/nullableInput.ts\nimport z7 from \"zod\";\nfunction NullableInput(schema) {\n return z7.nullable(schema).pipe(schema);\n}\n\n// src/models/nullableString.ts\nimport z8 from \"zod\";\nfunction NullableString(base) {\n return z8.nullable(base ?? z8.string()).transform((x) => x === \"\" ? null : x);\n}\n\n// src/models/percentage/percentage.ts\nimport z9 from \"zod\";\nfunction percentageToBp(percentage) {\n const basis = Math.round(percentage * 100);\n if (Math.abs(basis - percentage * 100) > 1e-9) {\n throw new Error(\"Too many decimals, expected 2\");\n }\n return basis;\n}\nfunction bpToPercentage(bps) {\n return bps / 100;\n}\nvar PercentageNumber = z9.number().refine((val) => Math.abs(Math.round(val * 100) - val * 100) < 1e-9, {\n message: \"Percentage can have at most 2 decimal places\"\n}).transform((x) => x);\nvar PercentageSchema = StringNumberSchema.pipe(PercentageNumber);\n\n// src/models/phoneNumber/phoneNumber.ts\nimport { z as z10 } from \"zod\";\nvar phoneRegex = new RegExp(/^\\+?(?:[0-9]{1,3})?[-. (]*[0-9]{1,4}[-. )]*(?:[0-9]{1,4}[-. ]*){1,3}[0-9]{1,4}$/);\nvar PhoneNumberSchema = z10.string().min(7).regex(phoneRegex, \"Invalid phone number\");\n\n// src/models/uri/https.ts\nimport { z as z11 } from \"zod\";\nvar HttpsUrlSchema = z11.string().url().refine((val) => val.startsWith(\"https://\"), {\n message: \"URL must start with https://\"\n});\n\n// src/models/uri/ipfs.ts\nimport { z as z12 } from \"zod\";\nvar IpfsUrlSchema = z12.string().regex(/^ipfs:\\/\\S+$/, {\n message: \"Must start with ipfs://\"\n});\n\n// src/models/viem/address.ts\nimport { isAddress } from \"viem\";\nimport { z as z13 } from \"zod\";\nvar AddressSchema = z13.string().refine((x) => isAddress(x), { message: \"Not a valid address string\" }).transform((x) => x);\n\n// src/models/viem/hex.ts\nimport { isHex } from \"viem\";\nimport { z as z14 } from \"zod\";\nvar HexStringSchema = z14.string().refine((x) => isHex(x), { message: \"Not a valid Hexademical string\" }).transform((x) => x);\n\n// src/models/viem/supportedChainId.ts\nimport { extractChain } from \"viem\";\nimport { z as z15 } from \"zod\";\nfunction SupportedChainIds(chains) {\n const literals = chains.map((chain) => z15.literal(`${chain.id}`));\n return z15.union(literals);\n}\nfunction createSupportedChains(chains) {\n const Schema = SupportedChainIds(chains);\n return {\n Schema,\n chains,\n chainIds: chains.map((x) => `${x.id}`),\n isSupported: (chainId) => !!chains.find((x) => `${x.id}` === chainId),\n get: (chainId) => extractChain({ chains, id: Number(chainId) })\n };\n}\n\n// src/models/viem/transactionHash.ts\nimport { isHash } from \"viem\";\nimport { z as z16 } from \"zod\";\nvar TransactionHashSchema = z16.string().refine((x) => isHash(x), { message: \"Not a valid transaction hash string\" }).transform((x) => x);\nexport {\n AddressSchema,\n BasisPointsSchema,\n ErrorLikeSchema,\n HexStringSchema,\n HtmlString,\n HttpsUrlSchema,\n ISODateString,\n IdSchema,\n Int256,\n Int256Json,\n Int256Positive,\n IpfsUrlSchema,\n NullableInput,\n NullableString,\n NumberishJsonSchema,\n NumberishSchema,\n PercentageNumber,\n PercentageSchema,\n PhoneNumberSchema,\n StringNumberSchema,\n SupportedChainIds,\n TransactionHashSchema,\n bpToFixedPercentage,\n bpToPercentage,\n createInt256,\n createSupportedChains,\n percentageToBp,\n toInt256Json\n};\n"],"mappings":"AACA,MAAO,oBACP,OAAS,KAAAA,MAAS,MCDlB,OAAOC,MAAO,MAad,OAAS,KAAKC,MAAU,MA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,UAAW,GACX,UAAW,GACX,QAAS,qEACT,YAAa,kBACf,CAAC,EAEYC,GAAYC,EAAE,MAAMA,EAAE,IAAI,CAAC,EAAE,QAAQ,CAChD,YAAa,6DACb,KAAM,OACR,CAAC,EAEYC,EAAUC,EAAc,QAAQ,CAC3C,YAAa,oBACf,CAAC,EAIM,SAASC,GAAUC,EAAsB,CAC9C,OAAOA,EAAK,YAAY,CAC1B,CAEO,SAASC,GAAQC,EAAuB,CAC7C,OAAOL,EAAQ,UAAWM,GAAM,CAC9B,IAAMC,EAAM,IAAI,KAAKD,CAAC,EACtB,OAAID,GAAWA,EAAU,MAAME,CAAG,EAC3BA,CACT,CAAC,CACH,CAEA,IAAMC,EAAaA,EAAY,QAAQ,CACrC,YAAa,qBACf,CAAC,EAEM,SAASC,GAAaJ,EAAyB,CACpD,OAAOG,EAAW,UAAWF,GAAM,CACjC,IAAMC,EAAM,OAAOD,CAAC,EACpB,OAAID,GAAWA,EAAU,MAAME,CAAG,EAC3BA,CACT,CAAC,EAAE,QAAQ,CACT,QAAS,KACT,KAAM,SACR,CAAC,CACH,CAEO,IAAMG,GAAmBA,EAAkB,QAAQ,CACxD,YAAa,iDACf,CAAC,EAEYC,GAAgBA,EAAe,QAAQ,CAClD,KAAM,SACN,QAAS,SACX,CAAC,EAEYC,GAAiBA,EAAgB,QAAQ,CACpD,KAAM,SACN,QAAS,qBACX,CAAC","names":["z","z","z2","z3","z5","z4","z6","z7","z8","z9","z10","z11","z12","isAddress","z13","isHex","z14","extractChain","z15","isHash","z16","BasisPointsSchema","x","ErrorLikeSchema","z2","NumberishSchema","z4","NumberishJsonSchema","StringNumberSchema","x","Int256","createInt256","Int256Positive","corce","z5","Int256Json","ISODateString","z6","value","PercentageNumber","z9","val","x","PercentageSchema","StringNumberSchema","phoneRegex","PhoneNumberSchema","z10","HttpsUrlSchema","z11","IpfsUrlSchema","z12","AddressSchema","z13","isAddress","HexStringSchema","z14","isHex","TransactionHashSchema","z16","x","isHash","AddressSchema","HexStringSchema","HashSchema","TransactionHashSchema","AbiSchema","z","ISOJson","ISODateString","toISOJson","date","ISODate","validator","x","val","Int256Json","Int256BigInt","PercentageSchema","IpfsUrlSchema","HttpsUrlSchema"]}
|
|
1
|
+
{"version":3,"sources":["../src/zod/index.ts","../../../node_modules/.pnpm/@evergonlabs+tmi-utils@0.8.0-rc.1_type-fest@5.4.4_typescript@5.7.3_viem@2.46.2_bufferut_a12db19da3918260259d0daa35f81109/node_modules/@evergonlabs/tmi-utils/dist/models.js"],"sourcesContent":["// eslint-disable-next-line simple-import-sort/imports\nimport \"@hono/zod-openapi\";\nimport { z } from \"zod\";\nimport {\n AddressSchema as _AddressSchema,\n HexStringSchema as _HexStringSchema,\n HttpsUrlSchema as _HttpsUrlSchema,\n Int256Json as _Int256Json,\n IpfsUrlSchema as _IpfsUrlSchema,\n ISODateString,\n PercentageSchema as _PercentageSchema,\n TransactionHashSchema as _TransactionHashSchema,\n} from \"@evergonlabs/tmi-utils/models\";\n\nexport const AddressSchema = _AddressSchema.openapi({\n type: \"string\",\n example: \"0x0000000000000000000000000000000000000000\",\n});\n\nexport const HexStringSchema = _HexStringSchema.openapi({\n type: \"string\",\n example: \"0x\",\n});\n\nexport const HashSchema = _TransactionHashSchema.openapi({\n type: \"string\",\n minLength: 66,\n maxLength: 66,\n example: \"0x02dfb1fcdb76a64b88e5b31ab393bf3302e2fade282123bd9ca473d0e26a25df\",\n description: \"Transaction hash\",\n});\n\nexport const AbiSchema = z.array(z.any()).openapi({\n description: \"ABI of a contract. Can be used for contract output decode.\",\n type: \"array\",\n});\n\nexport const ISOJson = ISODateString.openapi({\n description: \"Date in ISO format\",\n});\n\nexport type IISOJson = z.output<typeof ISOJson>;\n\nexport function toISOJson(date: Date): IISOJson {\n return date.toISOString() as IISOJson;\n}\n\nexport function ISODate(validator?: z.ZodDate) {\n return ISOJson.transform((x) => {\n const val = new Date(x);\n if (validator) validator.parse(val);\n return val;\n });\n}\n\nconst Int256Json = _Int256Json.openapi({\n description: \"Big integer 256 bit\",\n});\n\nexport function Int256BigInt(validator?: z.ZodBigInt) {\n return Int256Json.transform((x) => {\n const val = BigInt(x);\n if (validator) validator.parse(val);\n return val;\n }).openapi({\n example: \"42\",\n type: \"integer\",\n });\n}\n\nexport const PercentageSchema = _PercentageSchema.openapi({\n description: \"Percentage in basis points, i.e. 10000bp = 100%\",\n});\n\nexport const IpfsUrlSchema = _IpfsUrlSchema.openapi({\n type: \"string\",\n example: \"ipfs://\",\n});\n\nexport const HttpsUrlSchema = _HttpsUrlSchema.openapi({\n type: \"string\",\n example: \"https://example.com\",\n});\n\nexport { z };\n","// src/models/basisPoints/basisPoints.ts\nimport z from \"zod\";\nvar BasisPointsSchema = z.number().int().transform((x) => x);\nfunction bpToFixedPercentage(basisPoints) {\n if (!Number.isInteger(basisPoints)) {\n throw new Error(`Basis points must be an integer, got ${basisPoints}`);\n }\n if (basisPoints < 0 || basisPoints > 1e4) {\n throw new Error(`Basis points must be in [0, 10000], got ${basisPoints}`);\n }\n return BigInt(basisPoints) * 100n;\n}\n\n// src/models/errorLike.ts\nimport { z as z2 } from \"zod\";\nvar ErrorLikeSchema = z2.object({\n name: z2.string(),\n message: z2.string()\n});\n\n// src/models/htmlString.ts\nvar HtmlString = (schema) => schema.refine((data) => HTML_PATTERN.test(data), {\n message: \"Invalid HTML format\"\n});\nvar HTML_PATTERN = /<\\/?[a-z][\\s\\S]*>/i;\n\n// src/models/id.ts\nimport z3 from \"zod\";\nfunction IdSchema(brandName) {\n return z3.string().brand(brandName);\n}\n\n// src/models/int256.ts\nimport z5 from \"zod\";\n\n// src/models/numberish/numberish.ts\nimport { z as z4 } from \"zod\";\nvar NumberishSchema = z4.union([z4.string(), z4.number(), z4.bigint()]);\nvar NumberishJsonSchema = z4.union([z4.string(), z4.number()]);\nvar StringNumberSchema = z4.string().transform((x) => x.replace(\",\", \".\")).refine((x) => !isNaN(Number(x)), { message: \"Invalid number format\" }).transform((x) => Number(x));\n\n// src/models/int256.ts\nvar Int256 = createInt256((x) => x);\nvar Int256Positive = createInt256((x) => x.min(BigInt(0)));\nfunction createInt256(corce) {\n return NumberishSchema.pipe(corce(z5.coerce.bigint()));\n}\nvar Int256Json = z5.string().brand(\"Int256\");\nfunction toInt256Json(value) {\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n if (typeof value === \"number\") {\n if (!Number.isSafeInteger(value)) {\n throw new Error(`Number ${value} is not a safe integer and cannot be converted to bigint`);\n }\n return value.toString();\n }\n if (typeof value === \"string\") {\n if (value.trim().length === 0) {\n throw new Error(\"String cannot be empty\");\n }\n try {\n return value.trim();\n } catch {\n throw new Error(`String \"${value}\" is not a valid bigint`);\n }\n }\n throw new Error(`Invalid type: ${typeof value}`);\n}\n\n// src/models/isoString/isoString.ts\nimport { z as z6 } from \"zod\";\nvar ISODateString = z6.string().refine((value) => !Number.isNaN(new Date(value).getTime()), {\n message: \"Invalid ISO 8601 date string\"\n}).brand();\n\n// src/models/nullableInput.ts\nimport z7 from \"zod\";\nfunction NullableInput(schema) {\n return z7.nullable(schema).pipe(schema);\n}\n\n// src/models/nullableString.ts\nimport z8 from \"zod\";\nfunction NullableString(base) {\n return z8.nullable(base ?? z8.string()).transform((x) => x === \"\" ? null : x);\n}\n\n// src/models/percentage/percentage.ts\nimport z9 from \"zod\";\nfunction percentageToBp(percentage) {\n const basis = Math.round(percentage * 100);\n if (Math.abs(basis - percentage * 100) > 1e-9) {\n throw new Error(\"Too many decimals, expected 2\");\n }\n return basis;\n}\nfunction bpToPercentage(bps) {\n return bps / 100;\n}\nvar PercentageNumber = z9.number().refine((val) => Math.abs(Math.round(val * 100) - val * 100) < 1e-9, {\n message: \"Percentage can have at most 2 decimal places\"\n}).transform((x) => x);\nvar PercentageSchema = StringNumberSchema.pipe(PercentageNumber);\n\n// src/models/phoneNumber/phoneNumber.ts\nimport { z as z10 } from \"zod\";\nvar phoneRegex = new RegExp(/^\\+?(?:[0-9]{1,3})?[-. (]*[0-9]{1,4}[-. )]*(?:[0-9]{1,4}[-. ]*){1,3}[0-9]{1,4}$/);\nvar PhoneNumberSchema = z10.string().min(7).regex(phoneRegex, \"Invalid phone number\");\n\n// src/models/uri/https.ts\nimport { z as z11 } from \"zod\";\nvar HttpsUrlSchema = z11.string().url().refine((val) => val.startsWith(\"https://\"), {\n message: \"URL must start with https://\"\n});\n\n// src/models/uri/ipfs.ts\nimport { z as z12 } from \"zod\";\nvar IpfsUrlSchema = z12.string().regex(/^ipfs:\\/\\S+$/, {\n message: \"Must start with ipfs://\"\n});\n\n// src/models/viem/address.ts\nimport { isAddress } from \"viem\";\nimport { z as z13 } from \"zod\";\nvar AddressSchema = z13.string().refine((x) => isAddress(x), { message: \"Not a valid address string\" }).transform((x) => x);\n\n// src/models/viem/hex.ts\nimport { isHex } from \"viem\";\nimport { z as z14 } from \"zod\";\nvar HexStringSchema = z14.string().refine((x) => isHex(x), { message: \"Not a valid Hexademical string\" }).transform((x) => x);\n\n// src/models/viem/supportedChainId.ts\nimport { extractChain } from \"viem\";\nimport { z as z15 } from \"zod\";\nfunction SupportedChainIds(chains) {\n const literals = chains.map((chain) => z15.literal(`${chain.id}`));\n return z15.union(literals);\n}\nfunction createSupportedChains(chains) {\n const Schema = SupportedChainIds(chains);\n return {\n Schema,\n chains,\n chainIds: chains.map((x) => `${x.id}`),\n isSupported: (chainId) => !!chains.find((x) => `${x.id}` === chainId),\n get: (chainId) => extractChain({ chains, id: Number(chainId) })\n };\n}\n\n// src/models/viem/transactionHash.ts\nimport { isHash } from \"viem\";\nimport { z as z16 } from \"zod\";\nvar TransactionHashSchema = z16.string().refine((x) => isHash(x), { message: \"Not a valid transaction hash string\" }).transform((x) => x);\nexport {\n AddressSchema,\n BasisPointsSchema,\n ErrorLikeSchema,\n HexStringSchema,\n HtmlString,\n HttpsUrlSchema,\n ISODateString,\n IdSchema,\n Int256,\n Int256Json,\n Int256Positive,\n IpfsUrlSchema,\n NullableInput,\n NullableString,\n NumberishJsonSchema,\n NumberishSchema,\n PercentageNumber,\n PercentageSchema,\n PhoneNumberSchema,\n StringNumberSchema,\n SupportedChainIds,\n TransactionHashSchema,\n bpToFixedPercentage,\n bpToPercentage,\n createInt256,\n createSupportedChains,\n percentageToBp,\n toInt256Json\n};\n"],"mappings":"AACA,MAAO,oBACP,OAAS,KAAAA,MAAS,MCDlB,OAAOC,MAAO,MAad,OAAS,KAAKC,MAAU,MAaxB,OAAOC,MAAQ,MAMf,OAAOC,MAAQ,MAGf,OAAS,KAAKC,MAAU,MAoCxB,OAAS,KAAKC,MAAU,MAMxB,OAAOC,MAAQ,MAMf,OAAOC,MAAQ,MAMf,OAAOC,MAAQ,MAiBf,OAAS,KAAKC,MAAW,MAKzB,OAAS,KAAKC,MAAW,MAMzB,OAAS,KAAKC,MAAW,MAMzB,OAAS,aAAAC,MAAiB,OAC1B,OAAS,KAAKC,MAAW,MAIzB,OAAS,SAAAC,MAAa,OACtB,OAAS,KAAKC,MAAW,MAIzB,OAAS,gBAAAC,OAAoB,OAC7B,OAAS,KAAKC,OAAW,MAiBzB,OAAS,UAAAC,MAAc,OACvB,OAAS,KAAKC,MAAW,MAvJzB,IAAIC,EAAoBpB,EAAE,OAAO,EAAE,IAAI,EAAE,UAAWqB,GAAMA,CAAC,EAa3D,IAAIC,EAAkBC,EAAG,OAAO,CAC9B,KAAMA,EAAG,OAAO,EAChB,QAASA,EAAG,OAAO,CACrB,CAAC,EAmBD,IAAIC,EAAkBC,EAAG,MAAM,CAACA,EAAG,OAAO,EAAGA,EAAG,OAAO,EAAGA,EAAG,OAAO,CAAC,CAAC,EAClEC,EAAsBD,EAAG,MAAM,CAACA,EAAG,OAAO,EAAGA,EAAG,OAAO,CAAC,CAAC,EACzDE,EAAqBF,EAAG,OAAO,EAAE,UAAWG,GAAMA,EAAE,QAAQ,IAAK,GAAG,CAAC,EAAE,OAAQA,GAAM,CAAC,MAAM,OAAOA,CAAC,CAAC,EAAG,CAAE,QAAS,uBAAwB,CAAC,EAAE,UAAWA,GAAM,O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,CAAC,EAAG,CAAE,QAAS,qCAAsC,CAAC,EAAE,UAAWA,GAAMA,CAAC,ED5IjI,IAAME,GAAgBA,EAAe,QAAQ,CAClD,KAAM,SACN,QAAS,4CACX,CAAC,EAEYC,GAAkBA,EAAiB,QAAQ,CACtD,KAAM,SACN,QAAS,IACX,CAAC,EAEYC,GAAaC,EAAuB,QAAQ,CACvD,KAAM,SACN,UAAW,GACX,UAAW,GACX,QAAS,qEACT,YAAa,kBACf,CAAC,EAEYC,GAAYC,EAAE,MAAMA,EAAE,IAAI,CAAC,EAAE,QAAQ,CAChD,YAAa,6DACb,KAAM,OACR,CAAC,EAEYC,EAAUC,EAAc,QAAQ,CAC3C,YAAa,oBACf,CAAC,EAIM,SAASC,GAAUC,EAAsB,CAC9C,OAAOA,EAAK,YAAY,CAC1B,CAEO,SAASC,GAAQC,EAAuB,CAC7C,OAAOL,EAAQ,UAAWM,GAAM,CAC9B,IAAMC,EAAM,IAAI,KAAKD,CAAC,EACtB,OAAID,GAAWA,EAAU,MAAME,CAAG,EAC3BA,CACT,CAAC,CACH,CAEA,IAAMC,EAAaA,EAAY,QAAQ,CACrC,YAAa,qBACf,CAAC,EAEM,SAASC,GAAaJ,EAAyB,CACpD,OAAOG,EAAW,UAAWF,GAAM,CACjC,IAAMC,EAAM,OAAOD,CAAC,EACpB,OAAID,GAAWA,EAAU,MAAME,CAAG,EAC3BA,CACT,CAAC,EAAE,QAAQ,CACT,QAAS,KACT,KAAM,SACR,CAAC,CACH,CAEO,IAAMG,GAAmBA,EAAkB,QAAQ,CACxD,YAAa,iDACf,CAAC,EAEYC,GAAgBA,EAAe,QAAQ,CAClD,KAAM,SACN,QAAS,SACX,CAAC,EAEYC,GAAiBA,EAAgB,QAAQ,CACpD,KAAM,SACN,QAAS,qBACX,CAAC","names":["z","z","z2","z3","z5","z4","z6","z7","z8","z9","z10","z11","z12","isAddress","z13","isHex","z14","extractChain","z15","isHash","z16","BasisPointsSchema","x","ErrorLikeSchema","z2","NumberishSchema","z4","NumberishJsonSchema","StringNumberSchema","x","Int256","createInt256","Int256Positive","corce","z5","Int256Json","ISODateString","z6","value","PercentageNumber","z9","val","x","PercentageSchema","StringNumberSchema","phoneRegex","PhoneNumberSchema","z10","HttpsUrlSchema","z11","IpfsUrlSchema","z12","AddressSchema","z13","isAddress","HexStringSchema","z14","isHex","TransactionHashSchema","z16","x","isHash","AddressSchema","HexStringSchema","HashSchema","TransactionHashSchema","AbiSchema","z","ISOJson","ISODateString","toISOJson","date","ISODate","validator","x","val","Int256Json","Int256BigInt","PercentageSchema","IpfsUrlSchema","HttpsUrlSchema"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evergonlabs/tmi-protocol-utils",
|
|
3
|
-
"version": "0.11.0
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@hono/zod-openapi": "^1.2.1",
|
|
38
38
|
"zod": "^4.3.6",
|
|
39
|
-
"@evergonlabs/tmi-protocol-types": "0.11.0
|
|
39
|
+
"@evergonlabs/tmi-protocol-types": "0.11.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@evergonlabs/tmi-eslint-config": "0.8.0-rc.
|
|
43
|
-
"@evergonlabs/tmi-typescript-config": "0.8.0-rc.
|
|
44
|
-
"@evergonlabs/tmi-utils": "0.8.0-rc.
|
|
42
|
+
"@evergonlabs/tmi-eslint-config": "0.8.0-rc.1",
|
|
43
|
+
"@evergonlabs/tmi-typescript-config": "0.8.0-rc.1",
|
|
44
|
+
"@evergonlabs/tmi-utils": "0.8.0-rc.1",
|
|
45
45
|
"eslint": "^9.39.2",
|
|
46
46
|
"jiti": "^2.4.2",
|
|
47
47
|
"npm-run-all": "^4.1.5",
|