From d7ec2329049aa437a262a8919875d984c51547f4 Mon Sep 17 00:00:00 2001 From: Marcos Passos Date: Fri, 13 Feb 2026 15:14:56 -0300 Subject: [PATCH 1/2] Fix resource validation --- .../actions/createResourceOptionsValidator.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/infrastructure/application/validation/actions/createResourceOptionsValidator.ts b/src/infrastructure/application/validation/actions/createResourceOptionsValidator.ts index 7285e9b..3b89f07 100644 --- a/src/infrastructure/application/validation/actions/createResourceOptionsValidator.ts +++ b/src/infrastructure/application/validation/actions/createResourceOptionsValidator.ts @@ -6,7 +6,7 @@ import type { ContentDefinition, RootDefinition, } from '@croct/content-model/definition/definition'; -import type {Content, PrimitiveValue} from '@croct/content-model/content/content'; +import {Content, ListItem, PrimitiveValue} from '@croct/content-model/content/content'; import type {JsonValue} from '@croct/json'; import type {CreateResourceOptions} from '@/application/template/action/createResourceAction'; import type { @@ -215,13 +215,19 @@ const structureContentSchema = z.strictObject({ attributes: z.record(z.string(), z.lazy((): ZodType => contentSchema)), }) satisfies ZodType>; +const labeledItemSchema: ZodType> = z.lazy( + () => z.discriminatedUnion('type', [ + textContentSchema.extend({label: z.string().optional()}), + numberContentSchema.extend({label: z.string().optional()}), + booleanContentSchema.extend({label: z.string().optional()}), + structureContentSchema.extend({label: z.string().optional()}), + listContentSchema.extend({label: z.string().optional()}), + ]), +); + const listContentSchema = z.strictObject({ type: z.literal('list'), - items: z.array(z.lazy( - (): ZodType => z.intersection(contentSchema, z.object({ - label: z.string().optional(), - })), - )), + items: z.array(labeledItemSchema), }) satisfies ZodType>; const contentSchema = z.discriminatedUnion('type', [ From 853e1694ca6da514d13509f00035113c66bd80e4 Mon Sep 17 00:00:00 2001 From: Marcos Passos Date: Fri, 13 Feb 2026 15:20:26 -0300 Subject: [PATCH 2/2] Fix lint and vulnerability --- package-lock.json | 32 ++++++++----------- .../actions/createResourceOptionsValidator.ts | 2 +- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index f4bd3a7..98735a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -159,7 +159,6 @@ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.28.6.tgz", "integrity": "sha512-H3mcG6ZDLTlYfaSNi0iOKkigqMFvkTKlGUYlD8GW7nNOYRrevuA46iTypPyv+06V3fEmvvazfntkBU34L0azAw==", "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.28.6", "@babel/generator": "^7.28.6", @@ -3012,9 +3011,9 @@ } }, "node_modules/@isaacs/brace-expansion": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.0.tgz", - "integrity": "sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.1.tgz", + "integrity": "sha512-WMz71T1JS624nWj2n2fnYAuPovhv7EUhk69R6i9dsVyzxt5eM3bjwvgk9L+APE1TRscGysAVMANkB0jh0LQZrQ==", "license": "MIT", "dependencies": { "@isaacs/balanced-match": "^4.0.1" @@ -4745,6 +4744,7 @@ "os": [ "darwin" ], + "peer": true, "engines": { "node": ">=10" } @@ -4762,6 +4762,7 @@ "os": [ "darwin" ], + "peer": true, "engines": { "node": ">=10" } @@ -4779,6 +4780,7 @@ "os": [ "linux" ], + "peer": true, "engines": { "node": ">=10" } @@ -4796,6 +4798,7 @@ "os": [ "linux" ], + "peer": true, "engines": { "node": ">=10" } @@ -4813,6 +4816,7 @@ "os": [ "linux" ], + "peer": true, "engines": { "node": ">=10" } @@ -4830,6 +4834,7 @@ "os": [ "linux" ], + "peer": true, "engines": { "node": ">=10" } @@ -4847,6 +4852,7 @@ "os": [ "linux" ], + "peer": true, "engines": { "node": ">=10" } @@ -4864,6 +4870,7 @@ "os": [ "win32" ], + "peer": true, "engines": { "node": ">=10" } @@ -4881,6 +4888,7 @@ "os": [ "win32" ], + "peer": true, "engines": { "node": ">=10" } @@ -4898,6 +4906,7 @@ "os": [ "win32" ], + "peer": true, "engines": { "node": ">=10" } @@ -4933,6 +4942,7 @@ "integrity": "sha512-iAoY/qRhNH8a/hBvm3zKj9qQ4oc2+3w1unPJa2XvTK3XjeLXtzcCingVPw/9e5mn1+0yPqxcBGp9Jf0pkfMb1g==", "dev": true, "license": "Apache-2.0", + "peer": true, "dependencies": { "@swc/counter": "^0.1.3" } @@ -5094,7 +5104,6 @@ "integrity": "sha512-t7frlewr6+cbx+9Ohpl0NOTKXZNV9xHRmNOvql47BFJKcEG1CxtxlPEEe+gR9uhVWM4DwhnvTF110mIL4yP9RA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "undici-types": "~7.16.0" } @@ -5167,7 +5176,6 @@ "integrity": "sha512-hAAP5io/7csFStuOmR782YmTthKBJ9ND3WVL60hcOjvtGFb+HJxH4O5huAcmcZ9v9G8P+JETiZ/G1B8MALnWZQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/regexpp": "^4.12.2", "@typescript-eslint/scope-manager": "8.54.0", @@ -5197,7 +5205,6 @@ "integrity": "sha512-BtE0k6cjwjLZoZixN0t5AKP0kSzlGu7FctRXYuPAm//aaiZhmfq1JwdYpYr1brzEspYyFeF+8XF5j2VK6oalrA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.54.0", "@typescript-eslint/types": "8.54.0", @@ -5373,7 +5380,6 @@ "integrity": "sha512-9Cnda8GS57AQakvRyG0PTejJNlA2xhvyNtEVIMlDWOOeEyBkYWhGPnfrIAnqxLMTSTo6q8g12XVjjev5l1NvMA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.9.1", "@typescript-eslint/scope-manager": "8.54.0", @@ -5742,7 +5748,6 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -6472,7 +6477,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -7084,7 +7088,6 @@ "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==", "license": "MIT", - "peer": true, "engines": { "node": ">=18" } @@ -7872,7 +7875,6 @@ "dev": true, "hasInstallScript": true, "license": "MIT", - "peer": true, "bin": { "esbuild": "bin/esbuild" }, @@ -7947,7 +7949,6 @@ "integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -10529,7 +10530,6 @@ "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/core": "^29.7.0", "@jest/types": "^29.6.3", @@ -12547,7 +12547,6 @@ "resolved": "https://registry.npmjs.org/jsep/-/jsep-1.4.0.tgz", "integrity": "sha512-B7qPcEVE3NVkmSJbaYxvv4cHkVW7DQsZz13pUMrfS8z8Q/BuShN+gcTXrUlPiGqM2/t/EEaI030bpxMqY8gMlw==", "license": "MIT", - "peer": true, "engines": { "node": ">= 10.16.0" } @@ -15979,7 +15978,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -16124,7 +16122,6 @@ "dev": true, "hasInstallScript": true, "license": "MIT", - "peer": true, "dependencies": { "napi-postinstall": "^0.3.0" }, @@ -16492,7 +16489,6 @@ "integrity": "sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=10.0.0" }, diff --git a/src/infrastructure/application/validation/actions/createResourceOptionsValidator.ts b/src/infrastructure/application/validation/actions/createResourceOptionsValidator.ts index 3b89f07..0de37d4 100644 --- a/src/infrastructure/application/validation/actions/createResourceOptionsValidator.ts +++ b/src/infrastructure/application/validation/actions/createResourceOptionsValidator.ts @@ -6,7 +6,7 @@ import type { ContentDefinition, RootDefinition, } from '@croct/content-model/definition/definition'; -import {Content, ListItem, PrimitiveValue} from '@croct/content-model/content/content'; +import type {Content, ListItem, PrimitiveValue} from '@croct/content-model/content/content'; import type {JsonValue} from '@croct/json'; import type {CreateResourceOptions} from '@/application/template/action/createResourceAction'; import type {