From ec25a8642801572fb49e91b8c4bf366e90bccfee Mon Sep 17 00:00:00 2001 From: Nils Kolvenbach Date: Thu, 1 Feb 2024 12:16:01 +0100 Subject: [PATCH 1/5] Added homepage and repo urls --- package.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/package.json b/package.json index 3cfddad..78b4968 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,11 @@ "name": "@elek-io/shared", "version": "0.1.0", "description": "Exposing shared code like zod schemas and utility functions to be used inside other @elek-io packages.", + "homepage": "https://elek.io", + "repository": "https://github.com/elek-io/shared", + "bugs": { + "url": "https://github.com/elek-io/shared/issues" + }, "type": "module", "files": [ "dist" From 507118e0a1021706e07ea6a2b08cbc4e46c1d4eb Mon Sep 17 00:00:00 2001 From: Nils Kolvenbach Date: Thu, 1 Feb 2024 14:16:54 +0100 Subject: [PATCH 2/5] Added initial unit tests for schema generation --- README.md | 2 + src/valueSchema.ts | 15 ++++-- test/valueSchema.test.ts | 114 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+), 3 deletions(-) create mode 100644 test/valueSchema.test.ts diff --git a/README.md b/README.md index c245470..de3a330 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # @elek-io/shared +[![codecov](https://codecov.io/gh/elek-io/shared/graph/badge.svg?token=GSZIZMVG6Q)](https://codecov.io/gh/elek-io/shared) + Exposing shared code like zod schemas and utility functions to be used inside other @elek-io packages. diff --git a/src/valueSchema.ts b/src/valueSchema.ts index 54e1af1..850ab0a 100644 --- a/src/valueSchema.ts +++ b/src/valueSchema.ts @@ -1,4 +1,4 @@ -import z from 'zod'; +import z, { ZodBoolean, ZodOptional } from 'zod'; import { fileTypeSchema, supportedLanguageSchema, @@ -225,16 +225,22 @@ export function getValueSchemaFromDefinition(definition: ValueDefinition) { } } +/** + * @todo use BooleanValueDefinition to be more specific and add default value logic + */ function getBooleanValueSchema(definition: ValueDefinition) { - let schema = z.boolean(); + let schema: ZodBoolean | ZodOptional = z.boolean(); if (definition.isRequired === false) { - return schema.optional(); + schema = schema.optional(); } return schema; } +/** + * @todo use NumberValueDefinition to be more specific and add more value logic + */ function getNumberValueSchema(definition: ValueDefinition) { let schema = z.number(); @@ -263,6 +269,9 @@ function getNumberValueSchema(definition: ValueDefinition) { return schema; } +/** + * @todo use StringValueDefinition to be more specific and add more value logic + */ function getStringValueSchema(definition: ValueDefinition) { let schema = z.string(); diff --git a/test/valueSchema.test.ts b/test/valueSchema.test.ts new file mode 100644 index 0000000..2b371a2 --- /dev/null +++ b/test/valueSchema.test.ts @@ -0,0 +1,114 @@ +import { describe, expect, it } from 'vitest'; +import { getValueSchemaFromDefinition } from '../src'; + +describe('Dynamic zod schema', () => { + it('can be generated from boolean Value type definition', () => { + const requiredBooleanValueschema = getValueSchemaFromDefinition({ + id: '', + valueType: 'boolean', + name: { + en: 'Test', + }, + description: { + en: 'Test', + }, + defaultValue: true, + inputType: 'toggle', + inputWidth: '12', + isDisabled: false, + isRequired: true, + }); + + expect(requiredBooleanValueschema.safeParse(true).success).toBe(true); + expect(requiredBooleanValueschema.safeParse(false).success).toBe(true); + expect(requiredBooleanValueschema.safeParse('test').success).toBe(false); + expect(requiredBooleanValueschema.safeParse(1).success).toBe(false); + expect(requiredBooleanValueschema.safeParse(undefined).success).toBe(false); + }); + + it('can be generated from optional boolean Value type definition', () => { + const optionalBooleanValueschema = getValueSchemaFromDefinition({ + id: '', + valueType: 'boolean', + name: { + en: 'Test', + }, + description: { + en: 'Test', + }, + defaultValue: true, + inputType: 'toggle', + inputWidth: '12', + isDisabled: false, + isRequired: false, + }); + + expect(optionalBooleanValueschema.safeParse(true).success).toBe(true); + expect(optionalBooleanValueschema.safeParse(false).success).toBe(true); + expect(optionalBooleanValueschema.safeParse('test').success).toBe(false); + expect(optionalBooleanValueschema.safeParse(1).success).toBe(false); + expect(optionalBooleanValueschema.safeParse(undefined).success).toBe(true); + }); + + it('can be generated from number Value type definition', () => { + const requiredNumberValueschema = getValueSchemaFromDefinition({ + id: '', + valueType: 'number', + name: { + en: 'Test', + }, + description: { + en: 'Test', + }, + defaultValue: undefined, + inputType: 'number', + inputWidth: '12', + isDisabled: false, + isRequired: true, + isUnique: false, + min: 1, + max: 10, + }); + + expect(requiredNumberValueschema.safeParse(5).success).toBe(true); + expect(requiredNumberValueschema.safeParse(0).success).toBe(false); + expect(requiredNumberValueschema.safeParse(0.5).success).toBe(false); + expect(requiredNumberValueschema.safeParse(11).success).toBe(false); + expect(requiredNumberValueschema.safeParse(10.5).success).toBe(false); + expect(requiredNumberValueschema.safeParse(-1).success).toBe(false); + expect(requiredNumberValueschema.safeParse(-0.5).success).toBe(false); + expect(requiredNumberValueschema.safeParse(undefined).success).toBe(false); + expect(requiredNumberValueschema.safeParse('hello').success).toBe(false); + }); + + it('can be generated from number Value type definition', () => { + const optionalNumberValueschema = getValueSchemaFromDefinition({ + id: '', + valueType: 'number', + name: { + en: 'Test', + }, + description: { + en: 'Test', + }, + defaultValue: undefined, + inputType: 'number', + inputWidth: '12', + isDisabled: false, + isRequired: false, + isUnique: false, + min: 1, + max: 10, + }); + + expect(optionalNumberValueschema.safeParse(5).success).toBe(true); + expect(optionalNumberValueschema.safeParse(0).success).toBe(false); + expect(optionalNumberValueschema.safeParse(0.5).success).toBe(false); + expect(optionalNumberValueschema.safeParse(11).success).toBe(false); + expect(optionalNumberValueschema.safeParse(10.5).success).toBe(false); + expect(optionalNumberValueschema.safeParse(-1).success).toBe(false); + expect(optionalNumberValueschema.safeParse(-0.5).success).toBe(false); + expect(optionalNumberValueschema.safeParse(undefined).success).toBe(true); + expect(optionalNumberValueschema.safeParse('hello').success).toBe(false); + }); +}); From 7bd1889797b27f7c73171982efc09b4d726b1fa0 Mon Sep 17 00:00:00 2001 From: Nils Kolvenbach Date: Thu, 1 Feb 2024 14:20:20 +0100 Subject: [PATCH 3/5] Added changeset --- .changeset/shiny-trees-matter.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/shiny-trees-matter.md diff --git a/.changeset/shiny-trees-matter.md b/.changeset/shiny-trees-matter.md new file mode 100644 index 0000000..d917038 --- /dev/null +++ b/.changeset/shiny-trees-matter.md @@ -0,0 +1,5 @@ +--- +'@elek-io/shared': patch +--- + +Added coverage badge and some unit tests From 05e0ec429b7121f482c18e799d0487b10bb67d16 Mon Sep 17 00:00:00 2001 From: Nils Kolvenbach Date: Thu, 1 Feb 2024 15:11:32 +0100 Subject: [PATCH 4/5] Removed not needed vite dts plugin --- package-lock.json | 286 ++++++++++------------------------------------ package.json | 1 - 2 files changed, 60 insertions(+), 227 deletions(-) diff --git a/package-lock.json b/package-lock.json index 83538b8..47f2353 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@elek-io/shared", - "version": "0.0.0", + "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@elek-io/shared", - "version": "0.0.0", + "version": "0.1.0", "dependencies": { "slugify": "^1.6.6", "uuid": "^9.0.1", @@ -19,7 +19,6 @@ "@vitest/coverage-v8": "^1.2.2", "tsup": "^8.0.1", "typescript": "^5.3.3", - "vite-plugin-dts": "^3.7.2", "vitest": "^1.2.2" } }, @@ -971,6 +970,8 @@ "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.39.0.tgz", "integrity": "sha512-PuXxzadgnvp+wdeZFPonssRAj/EW4Gm4s75TXzPk09h3wJ8RS3x7typf95B4vwZRrPTQBGopdUl+/vHvlPdAcg==", "dev": true, + "optional": true, + "peer": true, "dependencies": { "@microsoft/api-extractor-model": "7.28.3", "@microsoft/tsdoc": "0.14.2", @@ -994,6 +995,8 @@ "resolved": "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.28.3.tgz", "integrity": "sha512-wT/kB2oDbdZXITyDh2SQLzaWwTOFbV326fP0pUwNW00WeliARs0qjmXBWmGWardEzp2U3/axkO3Lboqun6vrig==", "dev": true, + "optional": true, + "peer": true, "dependencies": { "@microsoft/tsdoc": "0.14.2", "@microsoft/tsdoc-config": "~0.16.1", @@ -1004,13 +1007,17 @@ "version": "0.14.2", "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.14.2.tgz", "integrity": "sha512-9b8mPpKrfeGRuhFH5iO1iwCLeIIsV6+H1sRfxbkoGXIyQE2BTsPd9zqSqQJ+pv5sJ/hT5M1zvOFL02MnEezFug==", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "node_modules/@microsoft/tsdoc-config": { "version": "0.16.2", "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.16.2.tgz", "integrity": "sha512-OGiIzzoBLgWWR0UdRJX98oYO+XKGf7tiK4Zk6tQ/E4IJqGCe7dvkTvgDZV5cFJUzLGDOjeAXrnZoA6QkVySuxw==", "dev": true, + "optional": true, + "peer": true, "dependencies": { "@microsoft/tsdoc": "0.14.2", "ajv": "~6.12.6", @@ -1023,6 +1030,8 @@ "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz", "integrity": "sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==", "dev": true, + "optional": true, + "peer": true, "dependencies": { "is-core-module": "^2.1.0", "path-parse": "^1.0.6" @@ -1076,28 +1085,6 @@ "node": ">=14" } }, - "node_modules/@rollup/pluginutils": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.0.tgz", - "integrity": "sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==", - "dev": true, - "dependencies": { - "@types/estree": "^1.0.0", - "estree-walker": "^2.0.2", - "picomatch": "^2.3.1" - }, - "engines": { - "node": ">=14.0.0" - }, - "peerDependencies": { - "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" - }, - "peerDependenciesMeta": { - "rollup": { - "optional": true - } - } - }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.9.6", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.9.6.tgz", @@ -1272,6 +1259,8 @@ "resolved": "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-3.62.0.tgz", "integrity": "sha512-88aJn2h8UpSvdwuDXBv1/v1heM6GnBf3RjEy6ZPP7UnzHNCqOHA2Ut+ScYUbXcqIdfew9JlTAe3g+cnX9xQ/Aw==", "dev": true, + "optional": true, + "peer": true, "dependencies": { "colors": "~1.2.1", "fs-extra": "~7.0.1", @@ -1295,6 +1284,8 @@ "resolved": "https://registry.npmjs.org/@rushstack/rig-package/-/rig-package-0.5.1.tgz", "integrity": "sha512-pXRYSe29TjRw7rqxD4WS3HN/sRSbfr+tJs4a9uuaSIBAITbUggygdhuG0VrO0EO+QqH91GhYMN4S6KRtOEmGVA==", "dev": true, + "optional": true, + "peer": true, "dependencies": { "resolve": "~1.22.1", "strip-json-comments": "~3.1.1" @@ -1305,6 +1296,8 @@ "resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-4.17.1.tgz", "integrity": "sha512-2jweO1O57BYP5qdBGl6apJLB+aRIn5ccIRTPDyULh0KMwVzFqWtw6IZWt1qtUoZD/pD2RNkIOosH6Cq45rIYeg==", "dev": true, + "optional": true, + "peer": true, "dependencies": { "@types/argparse": "1.0.38", "argparse": "~1.0.9", @@ -1322,7 +1315,9 @@ "version": "1.0.38", "resolved": "https://registry.npmjs.org/@types/argparse/-/argparse-1.0.38.tgz", "integrity": "sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA==", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "node_modules/@types/estree": { "version": "1.0.5", @@ -1474,88 +1469,6 @@ "@types/estree": "^1.0.0" } }, - "node_modules/@volar/language-core": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@volar/language-core/-/language-core-1.11.1.tgz", - "integrity": "sha512-dOcNn3i9GgZAcJt43wuaEykSluAuOkQgzni1cuxLxTV0nJKanQztp7FxyswdRILaKH+P2XZMPRp2S4MV/pElCw==", - "dev": true, - "dependencies": { - "@volar/source-map": "1.11.1" - } - }, - "node_modules/@volar/source-map": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-1.11.1.tgz", - "integrity": "sha512-hJnOnwZ4+WT5iupLRnuzbULZ42L7BWWPMmruzwtLhJfpDVoZLjNBxHDi2sY2bgZXCKlpU5XcsMFoYrsQmPhfZg==", - "dev": true, - "dependencies": { - "muggle-string": "^0.3.1" - } - }, - "node_modules/@volar/typescript": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@volar/typescript/-/typescript-1.11.1.tgz", - "integrity": "sha512-iU+t2mas/4lYierSnoFOeRFQUhAEMgsFuQxoxvwn5EdQopw43j+J27a4lt9LMInx1gLJBC6qL14WYGlgymaSMQ==", - "dev": true, - "dependencies": { - "@volar/language-core": "1.11.1", - "path-browserify": "^1.0.1" - } - }, - "node_modules/@vue/compiler-core": { - "version": "3.4.15", - "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.4.15.tgz", - "integrity": "sha512-XcJQVOaxTKCnth1vCxEChteGuwG6wqnUHxAm1DO3gCz0+uXKaJNx8/digSz4dLALCy8n2lKq24jSUs8segoqIw==", - "dev": true, - "dependencies": { - "@babel/parser": "^7.23.6", - "@vue/shared": "3.4.15", - "entities": "^4.5.0", - "estree-walker": "^2.0.2", - "source-map-js": "^1.0.2" - } - }, - "node_modules/@vue/compiler-dom": { - "version": "3.4.15", - "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.4.15.tgz", - "integrity": "sha512-wox0aasVV74zoXyblarOM3AZQz/Z+OunYcIHe1OsGclCHt8RsRm04DObjefaI82u6XDzv+qGWZ24tIsRAIi5MQ==", - "dev": true, - "dependencies": { - "@vue/compiler-core": "3.4.15", - "@vue/shared": "3.4.15" - } - }, - "node_modules/@vue/language-core": { - "version": "1.8.27", - "resolved": "https://registry.npmjs.org/@vue/language-core/-/language-core-1.8.27.tgz", - "integrity": "sha512-L8Kc27VdQserNaCUNiSFdDl9LWT24ly8Hpwf1ECy3aFb9m6bDhBGQYOujDm21N7EW3moKIOKEanQwe1q5BK+mA==", - "dev": true, - "dependencies": { - "@volar/language-core": "~1.11.1", - "@volar/source-map": "~1.11.1", - "@vue/compiler-dom": "^3.3.0", - "@vue/shared": "^3.3.0", - "computeds": "^0.0.1", - "minimatch": "^9.0.3", - "muggle-string": "^0.3.1", - "path-browserify": "^1.0.1", - "vue-template-compiler": "^2.7.14" - }, - "peerDependencies": { - "typescript": "*" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@vue/shared": { - "version": "3.4.15", - "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.4.15.tgz", - "integrity": "sha512-KzfPTxVaWfB+eGcGdbSf4CWdaXcGDqckoeXUh7SB3fZdEtzPCK2Vq9B/lRRL3yutax/LWITz+SwvgyOxz5V75g==", - "dev": true - }, "node_modules/acorn": { "version": "8.11.3", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", @@ -1582,6 +1495,8 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "dev": true, + "optional": true, + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -2031,6 +1946,8 @@ "resolved": "https://registry.npmjs.org/colors/-/colors-1.2.5.tgz", "integrity": "sha512-erNRLao/Y3Fv54qUa0LBB+//Uf3YwMUmdJinN20yMXm9zdKKqH9wt7R9IIVZ+K7ShzfpLV/Zg8+VyrBJYB4lpg==", "dev": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.1.90" } @@ -2041,16 +1958,11 @@ "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==", "dev": true, "optional": true, + "peer": true, "engines": { "node": "^12.20.0 || >=14" } }, - "node_modules/computeds": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/computeds/-/computeds-0.0.1.tgz", - "integrity": "sha512-7CEBgcMjVmitjYo5q8JTJVra6X5mQ20uTThdK+0kR7UEaDrAWEQcRiBtWJzga4eRpP6afNwwLsX2SET2JhVB1Q==", - "dev": true - }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -2110,12 +2022,6 @@ "integrity": "sha512-PjiQ659aQ+fUTQqSrd1XEDnOr52jh30RBurfzkscaE2tPaFsDH5wOAHJiw8XAHphRknCwMUE9KRayc4K/NbO8A==", "dev": true }, - "node_modules/de-indent": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz", - "integrity": "sha512-e/1zu3xH5MQryN2zdVaF0OrdNLUbvWxzMbi+iNA6Bky7l1RoP8a2fIbRocyHclXt/arDrrR6lL3TqFD9pMQTsg==", - "dev": true - }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -2277,18 +2183,6 @@ "node": ">=8.6" } }, - "node_modules/entities": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", - "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", - "dev": true, - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -2460,12 +2354,6 @@ "node": ">=4" } }, - "node_modules/estree-walker": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", - "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", - "dev": true - }, "node_modules/execa": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", @@ -2513,7 +2401,9 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "node_modules/fast-glob": { "version": "3.3.2", @@ -2535,7 +2425,9 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "node_modules/fastq": { "version": "1.17.0", @@ -2940,15 +2832,6 @@ "node": ">= 0.4" } }, - "node_modules/he": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", - "dev": true, - "bin": { - "he": "bin/he" - } - }, "node_modules/hosted-git-info": { "version": "2.8.9", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", @@ -3002,6 +2885,8 @@ "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-4.0.0.tgz", "integrity": "sha512-rKtvo6a868b5Hu3heneU+L4yEQ4jYKLtjpnPeUdK7h0yzXGmyBTypknlkCvHFBqfX9YlorEiMM6Dnq/5atfHkw==", "dev": true, + "optional": true, + "peer": true, "engines": { "node": ">=8" } @@ -3421,7 +3306,9 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/jju/-/jju-1.4.0.tgz", "integrity": "sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "node_modules/joycon": { "version": "3.1.1", @@ -3461,7 +3348,9 @@ "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "node_modules/jsonc-parser": { "version": "3.2.1", @@ -3496,12 +3385,6 @@ "node": ">=6" } }, - "node_modules/kolorist": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/kolorist/-/kolorist-1.8.0.tgz", - "integrity": "sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==", - "dev": true - }, "node_modules/lilconfig": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.0.0.tgz", @@ -3573,19 +3456,25 @@ "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "node_modules/lodash.get": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "node_modules/lodash.isequal": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==", - "dev": true + "dev": true, + "optional": true, + "peer": true }, "node_modules/lodash.sortby": { "version": "4.7.0", @@ -3809,12 +3698,6 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "node_modules/muggle-string": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/muggle-string/-/muggle-string-0.3.1.tgz", - "integrity": "sha512-ckmWDJjphvd/FvZawgygcUeQCxzvohjFO5RxTjj4eq8kw359gFF3E1brjfI+viLMxss5JrHTDRHZvu2/tuy0Qg==", - "dev": true - }, "node_modules/mz": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", @@ -4075,12 +3958,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/path-browserify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", - "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==", - "dev": true - }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -5097,6 +4974,8 @@ "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.2.tgz", "integrity": "sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==", "dev": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.6.19" } @@ -5238,6 +5117,8 @@ "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true, + "optional": true, + "peer": true, "engines": { "node": ">=8" }, @@ -5871,6 +5752,8 @@ "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", "dev": true, + "optional": true, + "peer": true, "dependencies": { "punycode": "^2.1.0" } @@ -5916,6 +5799,8 @@ "resolved": "https://registry.npmjs.org/validator/-/validator-13.11.0.tgz", "integrity": "sha512-Ii+sehpSfZy+At5nPdnyMhx78fEoPDkR2XW/zimHEL3MyGJQOCQ7WeP20jPYRz7ZCpcKLB21NxuXHF3bxjStBQ==", "dev": true, + "optional": true, + "peer": true, "engines": { "node": ">= 0.10" } @@ -5997,32 +5882,6 @@ "url": "https://opencollective.com/vitest" } }, - "node_modules/vite-plugin-dts": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/vite-plugin-dts/-/vite-plugin-dts-3.7.2.tgz", - "integrity": "sha512-kg//1nDA01b8rufJf4TsvYN8LMkdwv0oBYpiQi6nRwpHyue+wTlhrBiqgipdFpMnW1oOYv6ywmzE5B0vg6vSEA==", - "dev": true, - "dependencies": { - "@microsoft/api-extractor": "7.39.0", - "@rollup/pluginutils": "^5.1.0", - "@vue/language-core": "^1.8.26", - "debug": "^4.3.4", - "kolorist": "^1.8.0", - "vue-tsc": "^1.8.26" - }, - "engines": { - "node": "^14.18.0 || >=16.0.0" - }, - "peerDependencies": { - "typescript": "*", - "vite": "*" - }, - "peerDependenciesMeta": { - "vite": { - "optional": true - } - } - }, "node_modules/vitest": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/vitest/-/vitest-1.2.2.tgz", @@ -6089,33 +5948,6 @@ } } }, - "node_modules/vue-template-compiler": { - "version": "2.7.16", - "resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.7.16.tgz", - "integrity": "sha512-AYbUWAJHLGGQM7+cNTELw+KsOG9nl2CnSv467WobS5Cv9uk3wFcnr1Etsz2sEIHEZvw1U+o9mRlEO6QbZvUPGQ==", - "dev": true, - "dependencies": { - "de-indent": "^1.0.2", - "he": "^1.2.0" - } - }, - "node_modules/vue-tsc": { - "version": "1.8.27", - "resolved": "https://registry.npmjs.org/vue-tsc/-/vue-tsc-1.8.27.tgz", - "integrity": "sha512-WesKCAZCRAbmmhuGl3+VrdWItEvfoFIPXOvUJkjULi+x+6G/Dy69yO3TBRJDr9eUlmsNAwVmxsNZxvHKzbkKdg==", - "dev": true, - "dependencies": { - "@volar/typescript": "~1.11.1", - "@vue/language-core": "1.8.27", - "semver": "^7.5.4" - }, - "bin": { - "vue-tsc": "bin/vue-tsc.js" - }, - "peerDependencies": { - "typescript": "*" - } - }, "node_modules/wcwidth": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", @@ -6415,6 +6247,8 @@ "resolved": "https://registry.npmjs.org/z-schema/-/z-schema-5.0.5.tgz", "integrity": "sha512-D7eujBWkLa3p2sIpJA0d1pr7es+a7m0vFAnZLlCEKq/Ij2k0MLi9Br2UPxoxdYystm5K1yeBGzub0FlYUEWj2Q==", "dev": true, + "optional": true, + "peer": true, "dependencies": { "lodash.get": "^4.4.2", "lodash.isequal": "^4.5.0", diff --git a/package.json b/package.json index 78b4968..6cd6325 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,6 @@ "@vitest/coverage-v8": "^1.2.2", "tsup": "^8.0.1", "typescript": "^5.3.3", - "vite-plugin-dts": "^3.7.2", "vitest": "^1.2.2" } } From a19cc6beb04443fb975e3e83c7932d177b3c97fe Mon Sep 17 00:00:00 2001 From: Nils Kolvenbach Date: Thu, 1 Feb 2024 15:13:08 +0100 Subject: [PATCH 5/5] Added possible "test" env to schema for vitest --- src/baseSchema.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/baseSchema.ts b/src/baseSchema.ts index 68db671..1048747 100644 --- a/src/baseSchema.ts +++ b/src/baseSchema.ts @@ -1,6 +1,6 @@ import z from 'zod'; -export const environmentSchema = z.enum(['production', 'development']); +export const environmentSchema = z.enum(['production', 'development', 'test']); export type Environment = z.infer; /**