diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 90ad49a..596372e 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,3 +1,3 @@ { - "recommendations": ["dbaeumer.vscode-eslint", "dprint.dprint"] + "recommendations": ["dbaeumer.vscode-eslint", "dprint.dprint"] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 203c195..ea2a368 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,4 @@ { - "editor.defaultFormatter": "dprint.dprint", - "dprint.path": "node_modules/dprint/dprint" + "editor.defaultFormatter": "dprint.dprint", + "dprint.path": "node_modules/dprint/dprint" } diff --git a/README.md b/README.md index b488e39..0944c82 100644 --- a/README.md +++ b/README.md @@ -18,12 +18,12 @@ import { zodToTs } from 'zod-to-ts' // define your Zod schema const UserSchema = z.object({ - username: z.string(), - age: z.number(), - inventory: z.object({ - name: z.string(), - itemId: z.number(), - }).array(), + username: z.string(), + age: z.number(), + inventory: z.object({ + name: z.string(), + itemId: z.number(), + }).array(), }) // pass schema and name of type/identifier @@ -52,10 +52,10 @@ import { createTypeAlias, zodToTs } from 'zod-to-ts' const identifier = 'User' const { node } = zodToTs(UserSchema, identifier) const typeAlias = createTypeAlias( - node, - identifier, - // optionally pass a comment - // comment: UserSchema.description + node, + identifier, + // optionally pass a comment + // comment: UserSchema.description ) ``` @@ -63,7 +63,7 @@ result: ```ts type User = { - username: string + username: string } ``` @@ -127,13 +127,13 @@ import { z } from 'zod' import { withGetType, zodToTs } from 'zod-to-ts' const DateSchema = withGetType( - z.instanceof(Date), - (ts) => ts.factory.createIdentifier('Date'), + z.instanceof(Date), + (ts) => ts.factory.createIdentifier('Date'), ) const ItemSchema = z.object({ - name: z.string(), - date: DateSchema, + name: z.string(), + date: DateSchema, }) const { node } = zodToTs(ItemSchema, 'Item') @@ -143,8 +143,8 @@ result without `withGetType` override: ```ts type Item = { - name: string - date: any + name: string + date: any } ``` @@ -152,8 +152,8 @@ result with override: ```ts type Item = { - name: string - date: Date + name: string + date: Date } ``` @@ -170,13 +170,13 @@ Lazy types default to referencing the root type (`User` in the following example // so you must define it import { z } from 'zod' type User = { - username: string - friends: User[] + username: string + friends: User[] } const UserSchema: z.ZodSchema = z.object({ - username: z.string(), - friends: z.lazy(() => UserSchema).array(), + username: z.string(), + friends: z.lazy(() => UserSchema).array(), }) const { node } = zodToTs(UserSchema, 'User') @@ -186,8 +186,8 @@ result: ```ts type User = { - username: string - friends: User[] + username: string + friends: User[] } ``` @@ -195,12 +195,12 @@ But what happens when the schema looks like this? ```ts type User = { - username: string - item: { - name: string - itemId: string - } - friends: User[] + username: string + item: { + name: string + itemId: string + } + friends: User[] } // essentially when you are referencing a different field @@ -208,12 +208,12 @@ type User = { const friendItems = z.lazy(() => UserSchema.item).array() const UserSchema: z.ZodSchema = z.object({ - username: z.string(), - item: z.object({ - name: z.string(), - id: z.number(), - }), - friendItems, + username: z.string(), + item: z.object({ + name: z.string(), + id: z.number(), + }), + friendItems, }) const { node } = zodToTs(UserSchema, 'User') @@ -239,34 +239,34 @@ result: import { z } from 'zod' import { withGetType } from 'zod-to-ts' type User = { - username: string - item: { - name: string - id: number - } - friends: User[] + username: string + item: { + name: string + id: number + } + friends: User[] } const friendItems: z.Schema = withGetType( - z.lazy(() => UserSchema.item).array(), - // return a TS AST node - (ts, identifier) => - ts.factory.createIndexedAccessTypeNode( - ts.factory.createTypeReferenceNode( - ts.factory.createIdentifier(identifier), - undefined, - ), - ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral('item')), - ), + z.lazy(() => UserSchema.item).array(), + // return a TS AST node + (ts, identifier) => + ts.factory.createIndexedAccessTypeNode( + ts.factory.createTypeReferenceNode( + ts.factory.createIdentifier(identifier), + undefined, + ), + ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral('item')), + ), ) const UserSchema: z.ZodSchema = z.object({ - username: z.string(), - item: z.object({ - name: z.string(), - id: z.number(), - }), - friendItems, + username: z.string(), + item: z.object({ + name: z.string(), + id: z.number(), + }), + friendItems, }) const { node } = zodToTs(UserSchema, 'User') @@ -326,21 +326,21 @@ import { z } from 'zod' import { withGetType, zodToTs } from 'zod-to-ts' enum Fruit { - Apple = 'apple', - Banana = 'banana', - Cantaloupe = 'cantaloupe', + Apple = 'apple', + Banana = 'banana', + Cantaloupe = 'cantaloupe', } const fruitNativeEnum = withGetType( - z.nativeEnum( - Fruit, - ), - // return an identifier that will be used on the enum type - (ts) => ts.factory.createIdentifier('Fruit'), + z.nativeEnum( + Fruit, + ), + // return an identifier that will be used on the enum type + (ts) => ts.factory.createIdentifier('Fruit'), ) const TreeSchema = z.object({ - fruit: fruitNativeEnum, + fruit: fruitNativeEnum, }) const { node } = zodToTs(TreeSchema) diff --git a/package.json b/package.json index fbce999..6f5d202 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "@types/node": "18.15.11", "dprint": "0.35.3", "eslint": "8.37.0", + "npm-run-all": "4.1.5", "tsup": "6.7.0", "tsx": "3.12.6", "typescript": "4.9.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index adcf8f8..fabe0f2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,6 +13,9 @@ devDependencies: eslint: specifier: 8.37.0 version: 8.37.0 + npm-run-all: + specifier: 4.1.5 + version: 4.1.5 tsup: specifier: 6.7.0 version: 6.7.0(typescript@4.9.4) @@ -668,6 +671,13 @@ packages: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} dev: true + /array-buffer-byte-length@1.0.0: + resolution: {integrity: sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A==} + dependencies: + call-bind: 1.0.2 + is-array-buffer: 3.0.2 + dev: true + /array-union@2.1.0: resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} engines: {node: '>=8'} @@ -677,6 +687,11 @@ packages: resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==} dev: true + /available-typed-arrays@1.0.5: + resolution: {integrity: sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==} + engines: {node: '>= 0.4'} + dev: true + /balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} dev: true @@ -733,6 +748,13 @@ packages: engines: {node: '>=8'} dev: true + /call-bind@1.0.2: + resolution: {integrity: sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==} + dependencies: + function-bind: 1.1.1 + get-intrinsic: 1.2.0 + dev: true + /callsites@3.1.0: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} @@ -821,7 +843,7 @@ packages: dev: true /color-name@1.1.3: - resolution: {integrity: sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=} + resolution: {integrity: sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==} dev: true /color-name@1.1.4: @@ -837,6 +859,17 @@ packages: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} dev: true + /cross-spawn@6.0.5: + resolution: {integrity: sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==} + engines: {node: '>=4.8'} + dependencies: + nice-try: 1.0.5 + path-key: 2.0.1 + semver: 5.7.1 + shebang-command: 1.2.0 + which: 1.3.1 + dev: true + /cross-spawn@7.0.3: resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} engines: {node: '>= 8'} @@ -869,6 +902,14 @@ packages: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} dev: true + /define-properties@1.2.0: + resolution: {integrity: sha512-xvqAVKGfT1+UAvPwKTVw/njhdQ8ZhXK4lI0bCIuCMrp2up9nPnaDftrLtmpTazqd1o+UY4zgzU+avtMbDP+ldA==} + engines: {node: '>= 0.4'} + dependencies: + has-property-descriptors: 1.0.0 + object-keys: 1.1.1 + dev: true + /diff@5.1.0: resolution: {integrity: sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==} engines: {node: '>=0.3.1'} @@ -913,6 +954,64 @@ packages: is-arrayish: 0.2.1 dev: true + /es-abstract@1.21.2: + resolution: {integrity: sha512-y/B5POM2iBnIxCiernH1G7rC9qQoM77lLIMQLuob0zhp8C56Po81+2Nj0WFKnd0pNReDTnkYryc+zhOzpEIROg==} + engines: {node: '>= 0.4'} + dependencies: + array-buffer-byte-length: 1.0.0 + available-typed-arrays: 1.0.5 + call-bind: 1.0.2 + es-set-tostringtag: 2.0.1 + es-to-primitive: 1.2.1 + function.prototype.name: 1.1.5 + get-intrinsic: 1.2.0 + get-symbol-description: 1.0.0 + globalthis: 1.0.3 + gopd: 1.0.1 + has: 1.0.3 + has-property-descriptors: 1.0.0 + has-proto: 1.0.1 + has-symbols: 1.0.3 + internal-slot: 1.0.5 + is-array-buffer: 3.0.2 + is-callable: 1.2.7 + is-negative-zero: 2.0.2 + is-regex: 1.1.4 + is-shared-array-buffer: 1.0.2 + is-string: 1.0.7 + is-typed-array: 1.1.10 + is-weakref: 1.0.2 + object-inspect: 1.12.3 + object-keys: 1.1.1 + object.assign: 4.1.4 + regexp.prototype.flags: 1.4.3 + safe-regex-test: 1.0.0 + string.prototype.trim: 1.2.7 + string.prototype.trimend: 1.0.6 + string.prototype.trimstart: 1.0.6 + typed-array-length: 1.0.4 + unbox-primitive: 1.0.2 + which-typed-array: 1.1.9 + dev: true + + /es-set-tostringtag@2.0.1: + resolution: {integrity: sha512-g3OMbtlwY3QewlqAiMLI47KywjWZoEytKr8pf6iTC8uJq5bIAH52Z9pnQ8pVL6whrCto53JZDuUIsifGeLorTg==} + engines: {node: '>= 0.4'} + dependencies: + get-intrinsic: 1.2.0 + has: 1.0.3 + has-tostringtag: 1.0.0 + dev: true + + /es-to-primitive@1.2.1: + resolution: {integrity: sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==} + engines: {node: '>= 0.4'} + dependencies: + is-callable: 1.2.7 + is-date-object: 1.0.5 + is-symbol: 1.0.4 + dev: true + /esbuild-android-64@0.15.12: resolution: {integrity: sha512-MJKXwvPY9g0rGps0+U65HlTsM1wUs9lbjt5CU19RESqycGFDRijMDQsh68MtbzkqWSRdEtiKS1mtPzKneaAI0Q==} engines: {node: '>=12'} @@ -1422,6 +1521,12 @@ packages: resolution: {integrity: sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==} dev: true + /for-each@0.3.3: + resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} + dependencies: + is-callable: 1.2.7 + dev: true + /fs.realpath@1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} dev: true @@ -1438,15 +1543,45 @@ packages: resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==} dev: true + /function.prototype.name@1.1.5: + resolution: {integrity: sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.2 + define-properties: 1.2.0 + es-abstract: 1.21.2 + functions-have-names: 1.2.3 + dev: true + + /functions-have-names@1.2.3: + resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==} + dev: true + /get-func-name@2.0.0: resolution: {integrity: sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==} dev: true + /get-intrinsic@1.2.0: + resolution: {integrity: sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q==} + dependencies: + function-bind: 1.1.1 + has: 1.0.3 + has-symbols: 1.0.3 + dev: true + /get-stream@6.0.1: resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==} engines: {node: '>=10'} dev: true + /get-symbol-description@1.0.0: + resolution: {integrity: sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.2 + get-intrinsic: 1.2.0 + dev: true + /get-tsconfig@4.5.0: resolution: {integrity: sha512-MjhiaIWCJ1sAU4pIQ5i5OfOuHHxVo1oYeNsWTON7jxYkod8pHocXeh+SSbmu5OZZZK73B6cbJ2XADzXehLyovQ==} dev: true @@ -1494,6 +1629,13 @@ packages: type-fest: 0.20.2 dev: true + /globalthis@1.0.3: + resolution: {integrity: sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==} + engines: {node: '>= 0.4'} + dependencies: + define-properties: 1.2.0 + dev: true + /globby@11.1.0: resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} engines: {node: '>=10'} @@ -1506,10 +1648,24 @@ packages: slash: 3.0.0 dev: true + /gopd@1.0.1: + resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} + dependencies: + get-intrinsic: 1.2.0 + dev: true + + /graceful-fs@4.2.11: + resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} + dev: true + /grapheme-splitter@1.0.4: resolution: {integrity: sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==} dev: true + /has-bigints@1.0.2: + resolution: {integrity: sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==} + dev: true + /has-flag@3.0.0: resolution: {integrity: sha1-tdRU3CGZriJWmfNGfloH87lVuv0=} engines: {node: '>=4'} @@ -1520,6 +1676,29 @@ packages: engines: {node: '>=8'} dev: true + /has-property-descriptors@1.0.0: + resolution: {integrity: sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==} + dependencies: + get-intrinsic: 1.2.0 + dev: true + + /has-proto@1.0.1: + resolution: {integrity: sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==} + engines: {node: '>= 0.4'} + dev: true + + /has-symbols@1.0.3: + resolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==} + engines: {node: '>= 0.4'} + dev: true + + /has-tostringtag@1.0.0: + resolution: {integrity: sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==} + engines: {node: '>= 0.4'} + dependencies: + has-symbols: 1.0.3 + dev: true + /has@1.0.3: resolution: {integrity: sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==} engines: {node: '>= 0.4.0'} @@ -1580,10 +1759,33 @@ packages: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} dev: true + /internal-slot@1.0.5: + resolution: {integrity: sha512-Y+R5hJrzs52QCG2laLn4udYVnxsfny9CpOhNhUvk/SSSVyF6T27FzRbF0sroPidSu3X8oEAkOn2K804mjpt6UQ==} + engines: {node: '>= 0.4'} + dependencies: + get-intrinsic: 1.2.0 + has: 1.0.3 + side-channel: 1.0.4 + dev: true + + /is-array-buffer@3.0.2: + resolution: {integrity: sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w==} + dependencies: + call-bind: 1.0.2 + get-intrinsic: 1.2.0 + is-typed-array: 1.1.10 + dev: true + /is-arrayish@0.2.1: resolution: {integrity: sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=} dev: true + /is-bigint@1.0.4: + resolution: {integrity: sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==} + dependencies: + has-bigints: 1.0.2 + dev: true + /is-binary-path@2.1.0: resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} engines: {node: '>=8'} @@ -1591,6 +1793,14 @@ packages: binary-extensions: 2.2.0 dev: true + /is-boolean-object@1.1.2: + resolution: {integrity: sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.2 + has-tostringtag: 1.0.0 + dev: true + /is-builtin-module@3.2.0: resolution: {integrity: sha512-phDA4oSGt7vl1n5tJvTWooWWAsXLY+2xCnxNqvKhGEzujg+A43wPlPOyDg3C8XQHN+6k/JTQWJ/j0dQh/qr+Hw==} engines: {node: '>=6'} @@ -1598,12 +1808,24 @@ packages: builtin-modules: 3.3.0 dev: true + /is-callable@1.2.7: + resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==} + engines: {node: '>= 0.4'} + dev: true + /is-core-module@2.11.0: resolution: {integrity: sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==} dependencies: has: 1.0.3 dev: true + /is-date-object@1.0.5: + resolution: {integrity: sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==} + engines: {node: '>= 0.4'} + dependencies: + has-tostringtag: 1.0.0 + dev: true + /is-extglob@2.1.1: resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} engines: {node: '>=0.10.0'} @@ -1621,6 +1843,18 @@ packages: is-extglob: 2.1.1 dev: true + /is-negative-zero@2.0.2: + resolution: {integrity: sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==} + engines: {node: '>= 0.4'} + dev: true + + /is-number-object@1.0.7: + resolution: {integrity: sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==} + engines: {node: '>= 0.4'} + dependencies: + has-tostringtag: 1.0.0 + dev: true + /is-number@7.0.0: resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} engines: {node: '>=0.12.0'} @@ -1631,11 +1865,56 @@ packages: engines: {node: '>=8'} dev: true + /is-regex@1.1.4: + resolution: {integrity: sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.2 + has-tostringtag: 1.0.0 + dev: true + + /is-shared-array-buffer@1.0.2: + resolution: {integrity: sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==} + dependencies: + call-bind: 1.0.2 + dev: true + /is-stream@2.0.1: resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} engines: {node: '>=8'} dev: true + /is-string@1.0.7: + resolution: {integrity: sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==} + engines: {node: '>= 0.4'} + dependencies: + has-tostringtag: 1.0.0 + dev: true + + /is-symbol@1.0.4: + resolution: {integrity: sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==} + engines: {node: '>= 0.4'} + dependencies: + has-symbols: 1.0.3 + dev: true + + /is-typed-array@1.1.10: + resolution: {integrity: sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A==} + engines: {node: '>= 0.4'} + dependencies: + available-typed-arrays: 1.0.5 + call-bind: 1.0.2 + for-each: 0.3.3 + gopd: 1.0.1 + has-tostringtag: 1.0.0 + dev: true + + /is-weakref@1.0.2: + resolution: {integrity: sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==} + dependencies: + call-bind: 1.0.2 + dev: true + /isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} dev: true @@ -1660,6 +1939,10 @@ packages: argparse: 2.0.1 dev: true + /json-parse-better-errors@1.0.2: + resolution: {integrity: sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==} + dev: true + /json-parse-even-better-errors@2.3.1: resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} dev: true @@ -1693,6 +1976,16 @@ packages: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} dev: true + /load-json-file@4.0.0: + resolution: {integrity: sha512-Kx8hMakjX03tiGTLAIdJ+lL0htKnXjEZN6hk/tozf/WOuYGdZBJrZ+rCJRbVCugsjB3jMLn9746NsQIf5VjBMw==} + engines: {node: '>=4'} + dependencies: + graceful-fs: 4.2.11 + parse-json: 4.0.0 + pify: 3.0.0 + strip-bom: 3.0.0 + dev: true + /load-tsconfig@0.2.3: resolution: {integrity: sha512-iyT2MXws+dc2Wi6o3grCFtGXpeMvHmJqS27sMPGtV2eUu4PeFnG+33I8BlFK1t1NWMjOpcx9bridn5yxLDX2gQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -1748,6 +2041,11 @@ packages: yallist: 4.0.0 dev: true + /memorystream@0.3.1: + resolution: {integrity: sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==} + engines: {node: '>= 0.10.0'} + dev: true + /merge-stream@2.0.0: resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} dev: true @@ -1816,6 +2114,10 @@ packages: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} dev: true + /nice-try@1.0.5: + resolution: {integrity: sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==} + dev: true + /normalize-package-data@2.5.0: resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==} dependencies: @@ -1830,6 +2132,22 @@ packages: engines: {node: '>=0.10.0'} dev: true + /npm-run-all@4.1.5: + resolution: {integrity: sha512-Oo82gJDAVcaMdi3nuoKFavkIHBRVqQ1qvMb+9LHk/cF4P6B2m8aP04hGf7oL6wZ9BuGwX1onlLhpuoofSyoQDQ==} + engines: {node: '>= 4'} + hasBin: true + dependencies: + ansi-styles: 3.2.1 + chalk: 2.4.2 + cross-spawn: 6.0.5 + memorystream: 0.3.1 + minimatch: 3.1.2 + pidtree: 0.3.1 + read-pkg: 3.0.0 + shell-quote: 1.8.0 + string.prototype.padend: 3.1.4 + dev: true + /npm-run-path@4.0.1: resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==} engines: {node: '>=8'} @@ -1842,6 +2160,25 @@ packages: engines: {node: '>=0.10.0'} dev: true + /object-inspect@1.12.3: + resolution: {integrity: sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==} + dev: true + + /object-keys@1.1.1: + resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==} + engines: {node: '>= 0.4'} + dev: true + + /object.assign@4.1.4: + resolution: {integrity: sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.2 + define-properties: 1.2.0 + has-symbols: 1.0.3 + object-keys: 1.1.1 + dev: true + /once@1.4.0: resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} dependencies: @@ -1914,6 +2251,14 @@ packages: callsites: 3.1.0 dev: true + /parse-json@4.0.0: + resolution: {integrity: sha512-aOIos8bujGN93/8Ox/jPLh7RwVnPEysynVFE+fQZyg6jKELEHwzgKdLRFHUgXJL6kylijVSBC4BvN9OmsB48Rw==} + engines: {node: '>=4'} + dependencies: + error-ex: 1.3.2 + json-parse-better-errors: 1.0.2 + dev: true + /parse-json@5.2.0: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} @@ -1934,6 +2279,11 @@ packages: engines: {node: '>=0.10.0'} dev: true + /path-key@2.0.1: + resolution: {integrity: sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==} + engines: {node: '>=4'} + dev: true + /path-key@3.1.1: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} engines: {node: '>=8'} @@ -1943,6 +2293,13 @@ packages: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} dev: true + /path-type@3.0.0: + resolution: {integrity: sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==} + engines: {node: '>=4'} + dependencies: + pify: 3.0.0 + dev: true + /path-type@4.0.0: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} @@ -1969,6 +2326,17 @@ packages: engines: {node: '>=8.6'} dev: true + /pidtree@0.3.1: + resolution: {integrity: sha512-qQbW94hLHEqCg7nhby4yRC7G2+jYHY4Rguc2bjw7Uug4GIJuu1tvf2uHaZv5Q8zdt+WKJ6qK1FOI6amaWUo5FA==} + engines: {node: '>=0.10'} + hasBin: true + dev: true + + /pify@3.0.0: + resolution: {integrity: sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==} + engines: {node: '>=4'} + dev: true + /pirates@4.0.5: resolution: {integrity: sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ==} engines: {node: '>= 6'} @@ -2045,6 +2413,15 @@ packages: type-fest: 0.8.1 dev: true + /read-pkg@3.0.0: + resolution: {integrity: sha512-BLq/cCO9two+lBgiTYNqD6GdtK8s4NpaWrl6/rCO9w0TUS8oJl7cmToOZfRYllKTISY6nt1U7jQ53brmKqY6BA==} + engines: {node: '>=4'} + dependencies: + load-json-file: 4.0.0 + normalize-package-data: 2.5.0 + path-type: 3.0.0 + dev: true + /read-pkg@5.2.0: resolution: {integrity: sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==} engines: {node: '>=8'} @@ -2067,6 +2444,15 @@ packages: hasBin: true dev: true + /regexp.prototype.flags@1.4.3: + resolution: {integrity: sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.2 + define-properties: 1.2.0 + functions-have-names: 1.2.3 + dev: true + /regexpp@3.2.0: resolution: {integrity: sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==} engines: {node: '>=8'} @@ -2134,6 +2520,14 @@ packages: queue-microtask: 1.2.3 dev: true + /safe-regex-test@1.0.0: + resolution: {integrity: sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==} + dependencies: + call-bind: 1.0.2 + get-intrinsic: 1.2.0 + is-regex: 1.1.4 + dev: true + /safe-regex@2.1.1: resolution: {integrity: sha512-rx+x8AMzKb5Q5lQ95Zoi6ZbJqwCLkqi3XuJXp5P3rT8OEc6sZCJG5AE5dU3lsgRr/F4Bs31jSlVN+j5KrsGu9A==} dependencies: @@ -2153,6 +2547,13 @@ packages: lru-cache: 6.0.0 dev: true + /shebang-command@1.2.0: + resolution: {integrity: sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==} + engines: {node: '>=0.10.0'} + dependencies: + shebang-regex: 1.0.0 + dev: true + /shebang-command@2.0.0: resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} engines: {node: '>=8'} @@ -2160,11 +2561,28 @@ packages: shebang-regex: 3.0.0 dev: true + /shebang-regex@1.0.0: + resolution: {integrity: sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==} + engines: {node: '>=0.10.0'} + dev: true + /shebang-regex@3.0.0: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} dev: true + /shell-quote@1.8.0: + resolution: {integrity: sha512-QHsz8GgQIGKlRi24yFc6a6lN69Idnx634w49ay6+jA5yFh7a1UY+4Rp6HPx/L/1zcEDPEij8cIsiqR6bQsE5VQ==} + dev: true + + /side-channel@1.0.4: + resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} + dependencies: + call-bind: 1.0.2 + get-intrinsic: 1.2.0 + object-inspect: 1.12.3 + dev: true + /siginfo@2.0.0: resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==} dev: true @@ -2249,6 +2667,40 @@ packages: strip-ansi: 7.0.1 dev: true + /string.prototype.padend@3.1.4: + resolution: {integrity: sha512-67otBXoksdjsnXXRUq+KMVTdlVRZ2af422Y0aTyTjVaoQkGr3mxl2Bc5emi7dOQ3OGVVQQskmLEWwFXwommpNw==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.2 + define-properties: 1.2.0 + es-abstract: 1.21.2 + dev: true + + /string.prototype.trim@1.2.7: + resolution: {integrity: sha512-p6TmeT1T3411M8Cgg9wBTMRtY2q9+PNy9EV1i2lIXUN/btt763oIfxwN3RR8VU6wHX8j/1CFy0L+YuThm6bgOg==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.2 + define-properties: 1.2.0 + es-abstract: 1.21.2 + dev: true + + /string.prototype.trimend@1.0.6: + resolution: {integrity: sha512-JySq+4mrPf9EsDBEDYMOb/lM7XQLulwg5R/m1r0PXEFqrV0qHvl58sdTilSXtKOflCsK2E8jxf+GKC0T07RWwQ==} + dependencies: + call-bind: 1.0.2 + define-properties: 1.2.0 + es-abstract: 1.21.2 + dev: true + + /string.prototype.trimstart@1.0.6: + resolution: {integrity: sha512-omqjMDaY92pbn5HOX7f9IccLA+U1tA9GvtU4JrodiXFfYB7jPzzHpRzpglLAjtUV6bB557zwClJezTqnAiYnQA==} + dependencies: + call-bind: 1.0.2 + define-properties: 1.2.0 + es-abstract: 1.21.2 + dev: true + /strip-ansi@6.0.1: resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} engines: {node: '>=8'} @@ -2263,6 +2715,11 @@ packages: ansi-regex: 6.0.1 dev: true + /strip-bom@3.0.0: + resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} + engines: {node: '>=4'} + dev: true + /strip-final-newline@2.0.0: resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==} engines: {node: '>=6'} @@ -2459,6 +2916,14 @@ packages: engines: {node: '>=8'} dev: true + /typed-array-length@1.0.4: + resolution: {integrity: sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==} + dependencies: + call-bind: 1.0.2 + for-each: 0.3.3 + is-typed-array: 1.1.10 + dev: true + /typescript@4.9.4: resolution: {integrity: sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==} engines: {node: '>=4.2.0'} @@ -2469,6 +2934,15 @@ packages: resolution: {integrity: sha512-MvlCc4GHrmZdAllBc0iUDowff36Q9Ndw/UzqmEKyrfSzokTd9ZCy1i+IIk5hrYKkjoYVQyNbrw7/F8XJ2rEwTg==} dev: true + /unbox-primitive@1.0.2: + resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==} + dependencies: + call-bind: 1.0.2 + has-bigints: 1.0.2 + has-symbols: 1.0.3 + which-boxed-primitive: 1.0.2 + dev: true + /uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} dependencies: @@ -2613,6 +3087,35 @@ packages: webidl-conversions: 4.0.2 dev: true + /which-boxed-primitive@1.0.2: + resolution: {integrity: sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==} + dependencies: + is-bigint: 1.0.4 + is-boolean-object: 1.1.2 + is-number-object: 1.0.7 + is-string: 1.0.7 + is-symbol: 1.0.4 + dev: true + + /which-typed-array@1.1.9: + resolution: {integrity: sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA==} + engines: {node: '>= 0.4'} + dependencies: + available-typed-arrays: 1.0.5 + call-bind: 1.0.2 + for-each: 0.3.3 + gopd: 1.0.1 + has-tostringtag: 1.0.0 + is-typed-array: 1.1.10 + dev: true + + /which@1.3.1: + resolution: {integrity: sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==} + hasBin: true + dependencies: + isexe: 2.0.0 + dev: true + /which@2.0.2: resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} engines: {node: '>= 8'} diff --git a/src/index.ts b/src/index.ts index 7799c6d..5a03c31 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,7 +15,6 @@ import { createUnknownKeywordNode, getIdentifierOrStringLiteral, maybeIdentifierToTypeReference, - printNode, } from './utils' const { factory: f, SyntaxKind } = ts diff --git a/src/types.ts b/src/types.ts index 7b39cab..b837317 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3,24 +3,24 @@ import ts from 'typescript' export type LiteralType = string | number | boolean export type ZodToTsOptions = { - resolveNativeEnums?: boolean + resolveNativeEnums?: boolean } export type RequiredZodToTsOptions = Required export type ZodToTsStore = { - nativeEnums: ts.EnumDeclaration[] + nativeEnums: ts.EnumDeclaration[] } export type ZodToTsReturn = { - node: ts.TypeNode - store: ZodToTsStore + node: ts.TypeNode + store: ZodToTsStore } export type GetTypeFunction = ( - typescript: typeof ts, - identifier: string, - options: RequiredZodToTsOptions, + typescript: typeof ts, + identifier: string, + options: RequiredZodToTsOptions, ) => ts.Identifier | ts.TypeNode export type GetType = { getType?: GetTypeFunction } diff --git a/test/array.test.ts b/test/array.test.ts index 1a2cd82..570b411 100644 --- a/test/array.test.ts +++ b/test/array.test.ts @@ -4,19 +4,19 @@ import { zodToTs } from '../src' import { printNodeTest } from './utils' const ItemsSchema = z.object({ - id: z.number(), - value: z.string(), + id: z.number(), + value: z.string(), }).array() describe('z.array()', () => { - const { node } = zodToTs(ItemsSchema, 'User') + const { node } = zodToTs(ItemsSchema, 'User') - it('outputs correct typescript', () => { - expect(printNodeTest(node)).toMatchInlineSnapshot(` - "{ - id: number; - value: string; - }[]" - `) - }) + it('outputs correct typescript', () => { + expect(printNodeTest(node)).toMatchInlineSnapshot(` + "{ + id: number; + value: string; + }[]" + `) + }) }) diff --git a/test/create-type-alias.test.ts b/test/create-type-alias.test.ts index 0e3d29e..e95cdc7 100644 --- a/test/create-type-alias.test.ts +++ b/test/create-type-alias.test.ts @@ -4,39 +4,39 @@ import { createTypeAlias, zodToTs } from '../src' import { printNodeTest } from './utils' const UserSchema = z.object({ - username: z.string(), - age: z.number(), + username: z.string(), + age: z.number(), }) const identifier = 'User' describe('type alias', () => { - const { node } = zodToTs(UserSchema, identifier) + const { node } = zodToTs(UserSchema, identifier) - it('outputs correct typescript', () => { - const typeAlias = createTypeAlias(node, identifier) + it('outputs correct typescript', () => { + const typeAlias = createTypeAlias(node, identifier) - expect(printNodeTest(typeAlias)).toMatchInlineSnapshot(` - "type User = { - username: string; - age: number; - };" - `) - }) + expect(printNodeTest(typeAlias)).toMatchInlineSnapshot(` + "type User = { + username: string; + age: number; + };" + `) + }) - it('optionally takes a comment', () => { - const typeAlias = createTypeAlias( - node, - identifier, - 'A basic user', - ) + it('optionally takes a comment', () => { + const typeAlias = createTypeAlias( + node, + identifier, + 'A basic user', + ) - expect(printNodeTest(typeAlias)).toMatchInlineSnapshot(` - "/** A basic user */ - type User = { - username: string; - age: number; - };" - `) - }) + expect(printNodeTest(typeAlias)).toMatchInlineSnapshot(` + "/** A basic user */ + type User = { + username: string; + age: number; + };" + `) + }) }) diff --git a/test/enum.test.ts b/test/enum.test.ts index 74dd236..cd2c021 100644 --- a/test/enum.test.ts +++ b/test/enum.test.ts @@ -4,91 +4,91 @@ import { withGetType, zodToTs } from '../src' import { printNodeTest } from './utils' describe('Color enum', () => { - enum Color { - Red, - Green, - Blue, - } + enum Color { + Red, + Green, + Blue, + } - it('uses identifier provided using `withGetType`', () => { - const schema = withGetType( - z.nativeEnum(Color), - (ts) => ts.factory.createIdentifier('Color'), - ) + it('uses identifier provided using `withGetType`', () => { + const schema = withGetType( + z.nativeEnum(Color), + (ts) => ts.factory.createIdentifier('Color'), + ) - const { node } = zodToTs(schema) + const { node } = zodToTs(schema) - expect(printNodeTest(node)).toMatchInlineSnapshot('"Color"') - }) + expect(printNodeTest(node)).toMatchInlineSnapshot('"Color"') + }) - it('handles numeric literals with resolveNativeEnums', () => { - const schema = withGetType( - z.nativeEnum(Color), - (ts) => ts.factory.createIdentifier('Color'), - ) + it('handles numeric literals with resolveNativeEnums', () => { + const schema = withGetType( + z.nativeEnum(Color), + (ts) => ts.factory.createIdentifier('Color'), + ) - const { store } = zodToTs(schema, undefined, { resolveNativeEnums: true }) + const { store } = zodToTs(schema, undefined, { resolveNativeEnums: true }) - expect(printNodeTest(store.nativeEnums[0])).toMatchInlineSnapshot(` - "enum Color { - \\"0\\" = \\"Red\\", - \\"1\\" = \\"Green\\", - \\"2\\" = \\"Blue\\", - Red = 0, - Green = 1, - Blue = 2 - }" - `) - }) + expect(printNodeTest(store.nativeEnums[0])).toMatchInlineSnapshot(` + "enum Color { + \\"0\\" = \\"Red\\", + \\"1\\" = \\"Green\\", + \\"2\\" = \\"Blue\\", + Red = 0, + Green = 1, + Blue = 2 + }" + `) + }) }) describe('Fruit enum', () => { - enum Fruit { - Apple = 'apple', - Banana = 'banana', - Cantaloupe = 'cantaloupe', - } + enum Fruit { + Apple = 'apple', + Banana = 'banana', + Cantaloupe = 'cantaloupe', + } - it('handles string literals with resolveNativeEnums', () => { - const schema = withGetType( - z.nativeEnum(Fruit), - (ts) => ts.factory.createIdentifier('Fruit'), - ) + it('handles string literals with resolveNativeEnums', () => { + const schema = withGetType( + z.nativeEnum(Fruit), + (ts) => ts.factory.createIdentifier('Fruit'), + ) - const { store } = zodToTs(schema, undefined, { resolveNativeEnums: true }) + const { store } = zodToTs(schema, undefined, { resolveNativeEnums: true }) - expect(printNodeTest(store.nativeEnums[0])).toMatchInlineSnapshot(` - "enum Fruit { - Apple = \\"apple\\", - Banana = \\"banana\\", - Cantaloupe = \\"cantaloupe\\" - }" - `) - }) + expect(printNodeTest(store.nativeEnums[0])).toMatchInlineSnapshot(` + "enum Fruit { + Apple = \\"apple\\", + Banana = \\"banana\\", + Cantaloupe = \\"cantaloupe\\" + }" + `) + }) }) it('handles string literal properties', () => { - enum StringLiteral { - 'Two Words', - '\'Quotes"', - '\\"Escaped\\"', - } + enum StringLiteral { + 'Two Words', + '\'Quotes"', + '\\"Escaped\\"', + } - const schema = withGetType( - z.nativeEnum(StringLiteral), - (ts) => ts.factory.createIdentifier('StringLiteral'), - ) + const schema = withGetType( + z.nativeEnum(StringLiteral), + (ts) => ts.factory.createIdentifier('StringLiteral'), + ) - const { store } = zodToTs(schema, undefined, { resolveNativeEnums: true }) + const { store } = zodToTs(schema, undefined, { resolveNativeEnums: true }) - expect(printNodeTest(store.nativeEnums[0])).toMatchInlineSnapshot(` - "enum StringLiteral { - \\"0\\" = \\"Two Words\\", - \\"1\\" = \\"'Quotes\\\\\\"\\", - \\"2\\" = \\"\\\\\\\\\\\\\\"Escaped\\\\\\\\\\\\\\"\\", - \\"Two Words\\" = 0, - \\"'Quotes\\\\\\"\\" = 1, - \\"\\\\\\\\\\\\\\"Escaped\\\\\\\\\\\\\\"\\" = 2 - }" - `) + expect(printNodeTest(store.nativeEnums[0])).toMatchInlineSnapshot(` + "enum StringLiteral { + \\"0\\" = \\"Two Words\\", + \\"1\\" = \\"'Quotes\\\\\\"\\", + \\"2\\" = \\"\\\\\\\\\\\\\\"Escaped\\\\\\\\\\\\\\"\\", + \\"Two Words\\" = 0, + \\"'Quotes\\\\\\"\\" = 1, + \\"\\\\\\\\\\\\\\"Escaped\\\\\\\\\\\\\\"\\" = 2 + }" + `) }) diff --git a/test/instanceof.test.ts b/test/instanceof.test.ts index f7b39ff..8044ed6 100644 --- a/test/instanceof.test.ts +++ b/test/instanceof.test.ts @@ -6,19 +6,19 @@ import { printNodeTest } from './utils' const dateType = withGetType(z.instanceof(Date), (ts) => ts.factory.createIdentifier('Date')) const schema = z.object({ - name: z.string(), - date: dateType, + name: z.string(), + date: dateType, }) describe('z.instanceof()', () => { - const { node } = zodToTs(schema, 'Item') + const { node } = zodToTs(schema, 'Item') - it('outputs correct typescript', () => { - expect(printNodeTest(node)).toMatchInlineSnapshot(` - "{ - name: string; - date: Date; - }" - `) - }) + it('outputs correct typescript', () => { + expect(printNodeTest(node)).toMatchInlineSnapshot(` + "{ + name: string; + date: Date; + }" + `) + }) }) diff --git a/test/lazy.test.ts b/test/lazy.test.ts index 0201fa1..b21fa91 100644 --- a/test/lazy.test.ts +++ b/test/lazy.test.ts @@ -4,35 +4,35 @@ import { zodToTs } from '../src' import { printNodeTest } from './utils' type User = { - username: string - friends: User[] + username: string + friends: User[] } const UserSchema: z.ZodSchema = z.object({ - username: z.string(), - friends: z.lazy(() => UserSchema).array(), + username: z.string(), + friends: z.lazy(() => UserSchema).array(), }) describe('z.lazy() referencing root type', () => { - const { node } = zodToTs(UserSchema, 'User') + const { node } = zodToTs(UserSchema, 'User') - it('outputs correct typescript', () => { - expect(printNodeTest(node)).toMatchInlineSnapshot(` - "{ - username: string; - friends: User[]; - }" - `) - }) + it('outputs correct typescript', () => { + expect(printNodeTest(node)).toMatchInlineSnapshot(` + "{ + username: string; + friends: User[]; + }" + `) + }) - it('uses `Identifier` when no identifier is passed', () => { - const { node: nodeWithoutSpecifiedIdentifier } = zodToTs(UserSchema) + it('uses `Identifier` when no identifier is passed', () => { + const { node: nodeWithoutSpecifiedIdentifier } = zodToTs(UserSchema) - expect(printNodeTest(nodeWithoutSpecifiedIdentifier)).toMatchInlineSnapshot(` - "{ - username: string; - friends: Identifier[]; - }" - `) - }) + expect(printNodeTest(nodeWithoutSpecifiedIdentifier)).toMatchInlineSnapshot(` + "{ + username: string; + friends: Identifier[]; + }" + `) + }) }) diff --git a/test/object.test.ts b/test/object.test.ts index 7d85826..e6c7678 100644 --- a/test/object.test.ts +++ b/test/object.test.ts @@ -5,83 +5,83 @@ import { zodToTs } from '../src' import { printNodeTest } from './utils' it('supports string literal properties', () => { - const schema = z.object({ - 'string-literal': z.string(), - 5: z.number(), - }) + const schema = z.object({ + 'string-literal': z.string(), + 5: z.number(), + }) - const { node } = zodToTs(schema) + const { node } = zodToTs(schema) - expect(printNodeTest(node)).toMatchInlineSnapshot(` - "{ - \\"5\\": number; - \\"string-literal\\": string; - }" - `) + expect(printNodeTest(node)).toMatchInlineSnapshot(` + "{ + \\"5\\": number; + \\"string-literal\\": string; + }" + `) }) it('does not unnecessary quote identifiers', () => { - const schema = z.object({ - id: z.string(), - name: z.string(), - countryOfOrigin: z.string(), - }) + const schema = z.object({ + id: z.string(), + name: z.string(), + countryOfOrigin: z.string(), + }) - const { node } = zodToTs(schema) + const { node } = zodToTs(schema) - expect(printNodeTest(node)).toMatchInlineSnapshot(` - "{ - id: string; - name: string; - countryOfOrigin: string; - }" - `) + expect(printNodeTest(node)).toMatchInlineSnapshot(` + "{ + id: string; + name: string; + countryOfOrigin: string; + }" + `) }) it('escapes correctly', () => { - const schema = z.object({ - '\\': z.string(), - '"': z.string(), - "'": z.string(), - '`': z.string(), - '\n': z.number(), - '$e': z.any(), - '4t': z.any(), - '_r': z.any(), - '-r': z.undefined(), - }) + const schema = z.object({ + '\\': z.string(), + '"': z.string(), + "'": z.string(), + '`': z.string(), + '\n': z.number(), + '$e': z.any(), + '4t': z.any(), + '_r': z.any(), + '-r': z.undefined(), + }) - const { node } = zodToTs(schema) + const { node } = zodToTs(schema) - expect(printNodeTest(node)).toMatchInlineSnapshot(` - "{ - \\"\\\\\\\\\\": string; - \\"\\\\\\"\\": string; - \\"'\\": string; - \\"\`\\": string; - \\"\\\\n\\": number; - \$e?: any; - \\"4t\\"?: any; - _r?: any; - \\"-r\\"?: undefined; - }" - `) + expect(printNodeTest(node)).toMatchInlineSnapshot(` + "{ + \\"\\\\\\\\\\": string; + \\"\\\\\\"\\": string; + \\"'\\": string; + \\"\`\\": string; + \\"\\\\n\\": number; + \$e?: any; + \\"4t\\"?: any; + _r?: any; + \\"-r\\"?: undefined; + }" + `) }) it('supports zod.describe()', () => { - const schema = z.object({ - name: z.string().describe('The name of the item'), - price: z.number().describe('The price of the item'), - }) + const schema = z.object({ + name: z.string().describe('The name of the item'), + price: z.number().describe('The price of the item'), + }) - const { node } = zodToTs(schema) + const { node } = zodToTs(schema) - expect(printNodeTest(node)).toMatchInlineSnapshot(` - "{ - /** The name of the item */ - name: string; - /** The price of the item */ - price: number; - }" - `) + expect(printNodeTest(node)).toMatchInlineSnapshot(` + "{ + /** The name of the item */ + name: string; + /** The price of the item */ + price: number; + }" + `) }) diff --git a/test/primitive.test.ts b/test/primitive.test.ts index 23e50d2..4b91dbc 100644 --- a/test/primitive.test.ts +++ b/test/primitive.test.ts @@ -4,35 +4,35 @@ import { zodToTs } from '../src' import { printNodeTest } from './utils' const PrimitiveSchema = z.object({ - username: z.string(), - age: z.number(), - isAdmin: z.boolean(), - createdAt: z.date(), - undef: z.undefined(), - nu: z.null(), - vo: z.void(), - an: z.any(), - unknow: z.unknown(), - nev: z.never(), + username: z.string(), + age: z.number(), + isAdmin: z.boolean(), + createdAt: z.date(), + undef: z.undefined(), + nu: z.null(), + vo: z.void(), + an: z.any(), + unknow: z.unknown(), + nev: z.never(), }) describe('PrimitiveSchema', () => { - const { node } = zodToTs(PrimitiveSchema, 'User') + const { node } = zodToTs(PrimitiveSchema, 'User') - it('outputs correct typescript', () => { - expect(printNodeTest(node)).toMatchInlineSnapshot(` - "{ - username: string; - age: number; - isAdmin: boolean; - createdAt: Date; - undef?: undefined; - nu: null; - vo?: void | undefined; - an?: any; - unknow?: unknown; - nev: never; - }" - `) - }) + it('outputs correct typescript', () => { + expect(printNodeTest(node)).toMatchInlineSnapshot(` + "{ + username: string; + age: number; + isAdmin: boolean; + createdAt: Date; + undef?: undefined; + nu: null; + vo?: void | undefined; + an?: any; + unknow?: unknown; + nev: never; + }" + `) + }) }) diff --git a/test/union.test.ts b/test/union.test.ts index e5f0a30..d63a0d6 100644 --- a/test/union.test.ts +++ b/test/union.test.ts @@ -4,27 +4,27 @@ import { zodToTs } from '../src' import { printNodeTest } from './utils' const ShapeSchema = z.discriminatedUnion('kind', [ - z.object({ kind: z.literal('circle'), radius: z.number() }), - z.object({ kind: z.literal('square'), x: z.number() }), - z.object({ kind: z.literal('triangle'), x: z.number(), y: z.number() }), + z.object({ kind: z.literal('circle'), radius: z.number() }), + z.object({ kind: z.literal('square'), x: z.number() }), + z.object({ kind: z.literal('triangle'), x: z.number(), y: z.number() }), ]) describe('z.discriminatedUnion()', () => { - const { node } = zodToTs(ShapeSchema, 'Shape') + const { node } = zodToTs(ShapeSchema, 'Shape') - it('outputs correct typescript', () => { - expect(printNodeTest(node)).toMatchInlineSnapshot(` - "{ - kind: \\"circle\\"; - radius: number; - } | { - kind: \\"square\\"; - x: number; - } | { - kind: \\"triangle\\"; - x: number; - y: number; - }" - `) - }) + it('outputs correct typescript', () => { + expect(printNodeTest(node)).toMatchInlineSnapshot(` + "{ + kind: \\"circle\\"; + radius: number; + } | { + kind: \\"square\\"; + x: number; + } | { + kind: \\"triangle\\"; + x: number; + y: number; + }" + `) + }) }) diff --git a/tsconfig.json b/tsconfig.json index 55ede23..c5a65d4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,16 +1,16 @@ { - "compilerOptions": { - "target": "esnext", - "module": "esnext", - "moduleResolution": "node", - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true, - "allowSyntheticDefaultImports": true, - "forceConsistentCasingInFileNames": true, - "noEmit": true, - "isolatedModules": true - }, - "include": ["src", "test"], - "exclude": ["node_modules", "dist"] + "compilerOptions": { + "target": "esnext", + "module": "esnext", + "moduleResolution": "node", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "isolatedModules": true + }, + "include": ["src", "test"], + "exclude": ["node_modules", "dist"] }