zod-codegen 1.2.2 → 1.3.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.
@@ -0,0 +1,43 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(npm install:*)",
5
+ "Bash(npm uninstall:*)",
6
+ "Bash(npm run type-check:*)",
7
+ "Bash(npm run build:*)",
8
+ "Bash(./dist/src/cli.js --help)",
9
+ "Bash(./dist/src/cli.js --version)",
10
+ "Bash(npm run dev:*)",
11
+ "Bash(node:*)",
12
+ "Bash(npm run lint)",
13
+ "Bash(npx husky init:*)",
14
+ "Bash(chmod:*)",
15
+ "Bash(npm run validate:*)",
16
+ "Bash(npm run format:*)",
17
+ "Bash(npm run test:*)",
18
+ "Bash(npm test)",
19
+ "Bash(npm audit:*)",
20
+ "Bash(npx depcheck:*)",
21
+ "Bash(npm outdated)",
22
+ "Bash(npm update:*)",
23
+ "WebSearch",
24
+ "Bash(find:*)",
25
+ "Bash(npx zod-codegen:*)",
26
+ "Bash(DEBUG=1 node ./dist/src/cli.js --input ./samples/openapi.json --output ./test-generated)",
27
+ "Bash(rm:*)",
28
+ "Bash(npm outdated:*)",
29
+ "Bash(npm view:*)",
30
+ "Bash(git tag:*)",
31
+ "Bash(npm run release:*)",
32
+ "Bash(git log:*)",
33
+ "Bash(npx commitlint:*)",
34
+ "Bash(git rev-list:*)",
35
+ "Bash(./fix-commit-messages.sh:*)",
36
+ "Bash(git add:*)",
37
+ "Bash(git commit:*)",
38
+ "Bash(FILTER_BRANCH_SQUELCH_WARNING=1 ./fix-commit-messages.sh)"
39
+ ],
40
+ "deny": [],
41
+ "ask": []
42
+ }
43
+ }
@@ -21,7 +21,7 @@ jobs:
21
21
 
22
22
  steps:
23
23
  - name: Checkout code
24
- uses: actions/checkout@v5
24
+ uses: actions/checkout@v6
25
25
  with:
26
26
  fetch-depth: 0
27
27
 
@@ -64,7 +64,7 @@ jobs:
64
64
 
65
65
  steps:
66
66
  - name: Checkout code
67
- uses: actions/checkout@v5
67
+ uses: actions/checkout@v6
68
68
 
69
69
  - name: Setup Node.js
70
70
  uses: actions/setup-node@v5
@@ -85,7 +85,7 @@ jobs:
85
85
 
86
86
  steps:
87
87
  - name: Checkout code
88
- uses: actions/checkout@v5
88
+ uses: actions/checkout@v6
89
89
 
90
90
  - name: Setup Node.js
91
91
  uses: actions/setup-node@v5
@@ -121,7 +121,7 @@ jobs:
121
121
 
122
122
  steps:
123
123
  - name: Checkout code
124
- uses: actions/checkout@v5
124
+ uses: actions/checkout@v6
125
125
  with:
126
126
  fetch-depth: 0
127
127
 
@@ -20,7 +20,7 @@ jobs:
20
20
 
21
21
  steps:
22
22
  - name: Checkout code
23
- uses: actions/checkout@v5
23
+ uses: actions/checkout@v6
24
24
  with:
25
25
  fetch-depth: 0
26
26
  token: ${{ secrets.GITHUB_TOKEN }}
package/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 1.3.0 (2025-11-24)
2
+
3
+ - Merge pull request #36 from julienandreu/dependabot/npm_and_yarn/dev-dependencies-16beb30ed0 ([3d85de4](https://github.com/julienandreu/zod-codegen/commit/3d85de4)), closes [#36](https://github.com/julienandreu/zod-codegen/issues/36)
4
+ - Merge pull request #37 from julienandreu/dependabot/npm_and_yarn/production-dependencies-e947a059e9 ([25bfc2e](https://github.com/julienandreu/zod-codegen/commit/25bfc2e)), closes [#37](https://github.com/julienandreu/zod-codegen/issues/37)
5
+ - Merge pull request #38 from julienandreu/dependabot/github_actions/actions/checkout-6 ([6377f8b](https://github.com/julienandreu/zod-codegen/commit/6377f8b)), closes [#38](https://github.com/julienandreu/zod-codegen/issues/38)
6
+ - Merge pull request #39 from julienandreu/migrate-zod-string-api-v4 ([472d53f](https://github.com/julienandreu/zod-codegen/commit/472d53f)), closes [#39](https://github.com/julienandreu/zod-codegen/issues/39)
7
+ - feat: migrate deprecated Zod string schema API to v4 ([b4461b4](https://github.com/julienandreu/zod-codegen/commit/b4461b4))
8
+ - ci(deps): bump actions/checkout from 5 to 6 ([45d007c](https://github.com/julienandreu/zod-codegen/commit/45d007c))
9
+ - chore(deps-dev): bump the dev-dependencies group with 3 updates ([644ecdc](https://github.com/julienandreu/zod-codegen/commit/644ecdc))
10
+ - chore(deps): bump zod in the production-dependencies group ([69b5694](https://github.com/julienandreu/zod-codegen/commit/69b5694))
11
+
1
12
  ## <small>1.2.2 (2025-11-19)</small>
2
13
 
3
14
  - Merge pull request #35 from julienandreu/fix/generate-typescript-type-aliases ([b8d9250](https://github.com/julienandreu/zod-codegen/commit/b8d9250)), closes [#35](https://github.com/julienandreu/zod-codegen/issues/35)
@@ -981,20 +981,20 @@ export class TypeScriptCodeGeneratorService {
981
981
  if (prop['format']) {
982
982
  switch (prop['format']) {
983
983
  case 'email':
984
- stringSchema = ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(stringSchema, ts.factory.createIdentifier('email')), undefined, []);
984
+ stringSchema = ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), ts.factory.createIdentifier('email')), undefined, []);
985
985
  break;
986
986
  case 'uri':
987
987
  case 'url':
988
- stringSchema = ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(stringSchema, ts.factory.createIdentifier('url')), undefined, []);
988
+ stringSchema = ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), ts.factory.createIdentifier('url')), undefined, []);
989
989
  break;
990
990
  case 'uuid':
991
- stringSchema = ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(stringSchema, ts.factory.createIdentifier('uuid')), undefined, []);
991
+ stringSchema = ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), ts.factory.createIdentifier('uuid')), undefined, []);
992
992
  break;
993
993
  case 'date-time':
994
- stringSchema = ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(stringSchema, ts.factory.createIdentifier('datetime')), undefined, []);
994
+ stringSchema = ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), ts.factory.createIdentifier('iso')), ts.factory.createIdentifier('datetime')), undefined, [this.buildDefaultValue({ local: true })]);
995
995
  break;
996
996
  case 'date':
997
- stringSchema = ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(stringSchema, ts.factory.createIdentifier('date')), undefined, []);
997
+ stringSchema = ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), ts.factory.createIdentifier('iso')), ts.factory.createIdentifier('date')), undefined, []);
998
998
  break;
999
999
  case 'time':
1000
1000
  stringSchema = ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(stringSchema, ts.factory.createIdentifier('time')), undefined, []);
package/package.json CHANGED
@@ -19,7 +19,7 @@
19
19
  "typescript": "^5.9.3",
20
20
  "url-pattern": "^1.0.3",
21
21
  "yargs": "^18.0.0",
22
- "zod": "^4.1.12"
22
+ "zod": "^4.1.13"
23
23
  },
24
24
  "description": "A powerful TypeScript code generator that creates Zod schemas and type-safe clients from OpenAPI specifications",
25
25
  "keywords": [
@@ -45,16 +45,16 @@
45
45
  "@types/jsonpath": "^0.2.4",
46
46
  "@types/node": "^24.10.1",
47
47
  "@types/yargs": "^17.0.35",
48
- "@vitest/coverage-v8": "^4.0.9",
48
+ "@vitest/coverage-v8": "^4.0.13",
49
49
  "eslint": "^9.39.1",
50
50
  "eslint-config-prettier": "^10.1.8",
51
51
  "husky": "^9.1.7",
52
- "lint-staged": "^16.2.6",
52
+ "lint-staged": "^16.2.7",
53
53
  "semantic-release": "^25.0.2",
54
54
  "ts-node": "^10.9.2",
55
55
  "typescript-eslint": "^8.46.4",
56
56
  "undici": "^7.16.0",
57
- "vitest": "^4.0.8",
57
+ "vitest": "^4.0.13",
58
58
  "yarn-audit-fix": "^10.1.1"
59
59
  },
60
60
  "optionalDependencies": {
@@ -110,5 +110,5 @@
110
110
  "release": "semantic-release",
111
111
  "release:dry": "semantic-release --dry-run"
112
112
  },
113
- "version": "1.2.2"
113
+ "version": "1.3.0"
114
114
  }
@@ -0,0 +1,94 @@
1
+ #!/bin/bash
2
+
3
+ # Script to republish missing versions to npm
4
+ # Usage: ./scripts/republish-versions.sh [version1] [version2]
5
+ # Example: ./scripts/republish-versions.sh 1.3.0 1.4.0
6
+
7
+ set -e
8
+
9
+ # Colors for output
10
+ RED='\033[0;31m'
11
+ GREEN='\033[0;32m'
12
+ YELLOW='\033[1;33m'
13
+ NC='\033[0m' # No Color
14
+
15
+ # Function to publish a version
16
+ publish_version() {
17
+ local version=$1
18
+ local tag="v${version}"
19
+
20
+ echo -e "${YELLOW}📦 Publishing version ${version}...${NC}"
21
+
22
+ # Check if tag exists
23
+ if ! git rev-parse "$tag" >/dev/null 2>&1; then
24
+ echo -e "${RED}❌ Tag ${tag} does not exist${NC}"
25
+ return 1
26
+ fi
27
+
28
+ # Check if version is already published
29
+ if npm view "zod-codegen@${version}" version >/dev/null 2>&1; then
30
+ echo -e "${YELLOW}⚠️ Version ${version} already exists on npm. Skipping...${NC}"
31
+ return 0
32
+ fi
33
+
34
+ # Save current branch/commit
35
+ local current_branch=$(git rev-parse --abbrev-ref HEAD)
36
+ local current_commit=$(git rev-parse HEAD)
37
+
38
+ echo -e "${GREEN}✓ Checking out tag ${tag}${NC}"
39
+ git checkout "$tag" --quiet
40
+
41
+ # Verify package.json version matches
42
+ local package_version=$(node -p "require('./package.json').version")
43
+ if [ "$package_version" != "$version" ]; then
44
+ echo -e "${RED}❌ Package.json version (${package_version}) doesn't match tag version (${version})${NC}"
45
+ git checkout "$current_branch" --quiet 2>/dev/null || git checkout "$current_commit" --quiet
46
+ return 1
47
+ fi
48
+
49
+ # Install dependencies
50
+ echo -e "${GREEN}✓ Installing dependencies...${NC}"
51
+ yarn install --frozen-lockfile
52
+
53
+ # Build project
54
+ echo -e "${GREEN}✓ Building project...${NC}"
55
+ yarn build
56
+
57
+ # Run prepublishOnly checks (build, test, lint, type-check)
58
+ echo -e "${GREEN}✓ Running prepublish checks...${NC}"
59
+ yarn test
60
+ yarn lint:check
61
+ yarn type-check
62
+
63
+ # Publish to npm
64
+ echo -e "${GREEN}✓ Publishing to npm...${NC}"
65
+ npm publish --access public
66
+
67
+ echo -e "${GREEN}✅ Successfully published version ${version}${NC}"
68
+
69
+ # Return to original branch/commit
70
+ echo -e "${GREEN}✓ Returning to ${current_branch}...${NC}"
71
+ git checkout "$current_branch" --quiet 2>/dev/null || git checkout "$current_commit" --quiet
72
+
73
+ echo ""
74
+ }
75
+
76
+ # Check if npm is authenticated
77
+ if ! npm whoami >/dev/null 2>&1; then
78
+ echo -e "${RED}❌ Not authenticated to npm. Please run 'npm login' first.${NC}"
79
+ exit 1
80
+ fi
81
+
82
+ echo -e "${GREEN}✓ Authenticated as $(npm whoami)${NC}"
83
+ echo ""
84
+
85
+ # Get versions from arguments or use defaults
86
+ VERSIONS=("${@:-1.3.0 1.4.0}")
87
+
88
+ # Publish each version
89
+ for version in "${VERSIONS[@]}"; do
90
+ publish_version "$version"
91
+ done
92
+
93
+ echo -e "${GREEN}🎉 All versions published successfully!${NC}"
94
+
@@ -2286,7 +2286,10 @@ export class TypeScriptCodeGeneratorService implements CodeGenerator, SchemaBuil
2286
2286
  switch (prop['format']) {
2287
2287
  case 'email':
2288
2288
  stringSchema = ts.factory.createCallExpression(
2289
- ts.factory.createPropertyAccessExpression(stringSchema, ts.factory.createIdentifier('email')),
2289
+ ts.factory.createPropertyAccessExpression(
2290
+ ts.factory.createIdentifier('z'),
2291
+ ts.factory.createIdentifier('email'),
2292
+ ),
2290
2293
  undefined,
2291
2294
  [],
2292
2295
  );
@@ -2294,28 +2297,46 @@ export class TypeScriptCodeGeneratorService implements CodeGenerator, SchemaBuil
2294
2297
  case 'uri':
2295
2298
  case 'url':
2296
2299
  stringSchema = ts.factory.createCallExpression(
2297
- ts.factory.createPropertyAccessExpression(stringSchema, ts.factory.createIdentifier('url')),
2300
+ ts.factory.createPropertyAccessExpression(
2301
+ ts.factory.createIdentifier('z'),
2302
+ ts.factory.createIdentifier('url'),
2303
+ ),
2298
2304
  undefined,
2299
2305
  [],
2300
2306
  );
2301
2307
  break;
2302
2308
  case 'uuid':
2303
2309
  stringSchema = ts.factory.createCallExpression(
2304
- ts.factory.createPropertyAccessExpression(stringSchema, ts.factory.createIdentifier('uuid')),
2310
+ ts.factory.createPropertyAccessExpression(
2311
+ ts.factory.createIdentifier('z'),
2312
+ ts.factory.createIdentifier('uuid'),
2313
+ ),
2305
2314
  undefined,
2306
2315
  [],
2307
2316
  );
2308
2317
  break;
2309
2318
  case 'date-time':
2310
2319
  stringSchema = ts.factory.createCallExpression(
2311
- ts.factory.createPropertyAccessExpression(stringSchema, ts.factory.createIdentifier('datetime')),
2320
+ ts.factory.createPropertyAccessExpression(
2321
+ ts.factory.createPropertyAccessExpression(
2322
+ ts.factory.createIdentifier('z'),
2323
+ ts.factory.createIdentifier('iso'),
2324
+ ),
2325
+ ts.factory.createIdentifier('datetime'),
2326
+ ),
2312
2327
  undefined,
2313
- [],
2328
+ [this.buildDefaultValue({local: true})],
2314
2329
  );
2315
2330
  break;
2316
2331
  case 'date':
2317
2332
  stringSchema = ts.factory.createCallExpression(
2318
- ts.factory.createPropertyAccessExpression(stringSchema, ts.factory.createIdentifier('date')),
2333
+ ts.factory.createPropertyAccessExpression(
2334
+ ts.factory.createPropertyAccessExpression(
2335
+ ts.factory.createIdentifier('z'),
2336
+ ts.factory.createIdentifier('iso'),
2337
+ ),
2338
+ ts.factory.createIdentifier('date'),
2339
+ ),
2319
2340
  undefined,
2320
2341
  [],
2321
2342
  );