zod-codegen 1.4.0 → 1.4.1

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.
Files changed (30) hide show
  1. package/.github/workflows/ci.yml +17 -17
  2. package/.github/workflows/release.yml +8 -8
  3. package/CHANGELOG.md +11 -0
  4. package/dist/src/services/code-generator.service.d.ts.map +1 -1
  5. package/dist/src/services/code-generator.service.js +3 -3
  6. package/package.json +10 -15
  7. package/src/services/code-generator.service.ts +4 -7
  8. package/tests/unit/code-generator.test.ts +3 -3
  9. package/tests/unit/generator.test.ts +2 -2
  10. package/tsconfig.json +1 -1
  11. package/.claude/settings.local.json +0 -43
  12. package/dist/scripts/update-manifest.d.ts +0 -14
  13. package/dist/scripts/update-manifest.d.ts.map +0 -1
  14. package/dist/scripts/update-manifest.js +0 -31
  15. package/dist/tests/integration/cli.test.d.ts +0 -2
  16. package/dist/tests/integration/cli.test.d.ts.map +0 -1
  17. package/dist/tests/integration/cli.test.js +0 -25
  18. package/dist/tests/unit/code-generator.test.d.ts +0 -2
  19. package/dist/tests/unit/code-generator.test.d.ts.map +0 -1
  20. package/dist/tests/unit/code-generator.test.js +0 -459
  21. package/dist/tests/unit/file-reader.test.d.ts +0 -2
  22. package/dist/tests/unit/file-reader.test.d.ts.map +0 -1
  23. package/dist/tests/unit/file-reader.test.js +0 -110
  24. package/dist/tests/unit/generator.test.d.ts +0 -2
  25. package/dist/tests/unit/generator.test.d.ts.map +0 -1
  26. package/dist/tests/unit/generator.test.js +0 -100
  27. package/dist/tests/unit/naming-convention.test.d.ts +0 -2
  28. package/dist/tests/unit/naming-convention.test.d.ts.map +0 -1
  29. package/dist/tests/unit/naming-convention.test.js +0 -231
  30. package/scripts/republish-versions.sh +0 -94
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=naming-convention.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"naming-convention.test.d.ts","sourceRoot":"","sources":["../../../tests/unit/naming-convention.test.ts"],"names":[],"mappings":""}
@@ -1,231 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { transformNamingConvention } from '../../src/utils/naming-convention.js';
3
- describe('transformNamingConvention', () => {
4
- describe('transform', () => {
5
- const testCases = [
6
- // camelCase
7
- {
8
- input: 'get_user_by_id',
9
- convention: 'camelCase',
10
- expected: 'getUserById',
11
- description: 'should convert snake_case to camelCase',
12
- },
13
- {
14
- input: 'GetUserById',
15
- convention: 'camelCase',
16
- expected: 'getUserById',
17
- description: 'should convert PascalCase to camelCase',
18
- },
19
- {
20
- input: 'get-user-by-id',
21
- convention: 'camelCase',
22
- expected: 'getUserById',
23
- description: 'should convert kebab-case to camelCase',
24
- },
25
- {
26
- input: 'getUserById',
27
- convention: 'camelCase',
28
- expected: 'getUserById',
29
- description: 'should keep camelCase as camelCase',
30
- },
31
- // PascalCase
32
- {
33
- input: 'get_user_by_id',
34
- convention: 'PascalCase',
35
- expected: 'GetUserById',
36
- description: 'should convert snake_case to PascalCase',
37
- },
38
- {
39
- input: 'get-user-by-id',
40
- convention: 'PascalCase',
41
- expected: 'GetUserById',
42
- description: 'should convert kebab-case to PascalCase',
43
- },
44
- {
45
- input: 'getUserById',
46
- convention: 'PascalCase',
47
- expected: 'GetUserById',
48
- description: 'should convert camelCase to PascalCase',
49
- },
50
- // snake_case
51
- {
52
- input: 'getUserById',
53
- convention: 'snake_case',
54
- expected: 'get_user_by_id',
55
- description: 'should convert camelCase to snake_case',
56
- },
57
- {
58
- input: 'GetUserById',
59
- convention: 'snake_case',
60
- expected: 'get_user_by_id',
61
- description: 'should convert PascalCase to snake_case',
62
- },
63
- {
64
- input: 'get-user-by-id',
65
- convention: 'snake_case',
66
- expected: 'get_user_by_id',
67
- description: 'should convert kebab-case to snake_case',
68
- },
69
- // kebab-case
70
- {
71
- input: 'getUserById',
72
- convention: 'kebab-case',
73
- expected: 'get-user-by-id',
74
- description: 'should convert camelCase to kebab-case',
75
- },
76
- {
77
- input: 'GetUserById',
78
- convention: 'kebab-case',
79
- expected: 'get-user-by-id',
80
- description: 'should convert PascalCase to kebab-case',
81
- },
82
- {
83
- input: 'get_user_by_id',
84
- convention: 'kebab-case',
85
- expected: 'get-user-by-id',
86
- description: 'should convert snake_case to kebab-case',
87
- },
88
- // SCREAMING_SNAKE_CASE
89
- {
90
- input: 'getUserById',
91
- convention: 'SCREAMING_SNAKE_CASE',
92
- expected: 'GET_USER_BY_ID',
93
- description: 'should convert camelCase to SCREAMING_SNAKE_CASE',
94
- },
95
- {
96
- input: 'get-user-by-id',
97
- convention: 'SCREAMING_SNAKE_CASE',
98
- expected: 'GET_USER_BY_ID',
99
- description: 'should convert kebab-case to SCREAMING_SNAKE_CASE',
100
- },
101
- // SCREAMING-KEBAB-CASE
102
- {
103
- input: 'getUserById',
104
- convention: 'SCREAMING-KEBAB-CASE',
105
- expected: 'GET-USER-BY-ID',
106
- description: 'should convert camelCase to SCREAMING-KEBAB-CASE',
107
- },
108
- {
109
- input: 'get_user_by_id',
110
- convention: 'SCREAMING-KEBAB-CASE',
111
- expected: 'GET-USER-BY-ID',
112
- description: 'should convert snake_case to SCREAMING-KEBAB-CASE',
113
- },
114
- // Edge cases
115
- {
116
- input: '',
117
- convention: 'camelCase',
118
- expected: '',
119
- description: 'should handle empty string',
120
- },
121
- {
122
- input: 'a',
123
- convention: 'camelCase',
124
- expected: 'a',
125
- description: 'should handle single character',
126
- },
127
- {
128
- input: 'API',
129
- convention: 'camelCase',
130
- expected: 'aPI',
131
- description: 'should handle all uppercase (splits at uppercase boundaries)',
132
- },
133
- {
134
- input: 'getUser123ById',
135
- convention: 'snake_case',
136
- expected: 'get_user_123_by_id',
137
- description: 'should handle numbers in identifiers (splits at digit boundaries)',
138
- },
139
- ];
140
- testCases.forEach(({ input, convention, expected, description }) => {
141
- it(description, () => {
142
- const result = transformNamingConvention(input, convention);
143
- expect(result).toBe(expected);
144
- });
145
- });
146
- });
147
- describe('edge cases', () => {
148
- describe('consecutive delimiters', () => {
149
- it('should handle consecutive underscores', () => {
150
- expect(transformNamingConvention('get__user__by__id', 'camelCase')).toBe('getUserById');
151
- });
152
- it('should handle consecutive hyphens', () => {
153
- expect(transformNamingConvention('get--user--by--id', 'snake_case')).toBe('get_user_by_id');
154
- });
155
- it('should handle mixed consecutive delimiters', () => {
156
- expect(transformNamingConvention('get__user--by_id', 'kebab-case')).toBe('get-user-by-id');
157
- });
158
- });
159
- describe('mixed delimiters', () => {
160
- it('should handle snake_case and kebab-case mixed', () => {
161
- // Note: Delimiters split the string, so 'byId' becomes 'by' and 'id' (normalized to lowercase)
162
- expect(transformNamingConvention('get_user-byId', 'camelCase')).toBe('getUserByid');
163
- });
164
- it('should handle camelCase with underscores', () => {
165
- // Note: Underscore delimiter splits, so 'byId' becomes 'by' and 'id'
166
- expect(transformNamingConvention('getUser_byId', 'PascalCase')).toBe('GetuserByid');
167
- });
168
- it('should handle dots as delimiters', () => {
169
- expect(transformNamingConvention('get.user.by.id', 'snake_case')).toBe('get_user_by_id');
170
- });
171
- it('should handle spaces as delimiters', () => {
172
- expect(transformNamingConvention('get user by id', 'kebab-case')).toBe('get-user-by-id');
173
- });
174
- });
175
- describe('unicode and special characters', () => {
176
- it('should handle accented characters', () => {
177
- expect(transformNamingConvention('getRésumé', 'snake_case')).toBe('get_résumé');
178
- });
179
- it('should handle numbers at start', () => {
180
- expect(transformNamingConvention('123getUser', 'camelCase')).toBe('123getUser');
181
- });
182
- it('should handle single uppercase letter', () => {
183
- expect(transformNamingConvention('getX', 'snake_case')).toBe('get_x');
184
- });
185
- it('should handle all numbers', () => {
186
- expect(transformNamingConvention('123456', 'camelCase')).toBe('123456');
187
- });
188
- });
189
- describe('acronyms and abbreviations', () => {
190
- it('should handle acronyms in camelCase (splits on uppercase boundaries)', () => {
191
- // Note: Algorithm splits on uppercase boundaries, so 'XML' becomes 'X', 'M', 'L'
192
- // This is correct behavior - detecting acronyms would require a dictionary
193
- expect(transformNamingConvention('getXMLData', 'snake_case')).toBe('get_x_m_l_data');
194
- });
195
- it('should handle multiple acronyms (splits on uppercase boundaries)', () => {
196
- // Note: 'JSON' and 'XML' are split into individual letters
197
- // 'parseJSONToXML' → ['parse', 'j', 's', 'o', 'n', 'to', 'x', 'm', 'l']
198
- expect(transformNamingConvention('parseJSONToXML', 'kebab-case')).toBe('parse-j-s-o-n-to-x-m-l');
199
- });
200
- it('should handle ID abbreviation (splits on uppercase boundaries)', () => {
201
- // Note: 'ID' is split into 'I' and 'D' because the algorithm splits on uppercase boundaries
202
- // This is correct behavior - detecting acronyms would require a dictionary
203
- expect(transformNamingConvention('getUserID', 'snake_case')).toBe('get_user_i_d');
204
- });
205
- });
206
- describe('already transformed names', () => {
207
- it('should be idempotent for camelCase', () => {
208
- const input = 'getUserById';
209
- const result = transformNamingConvention(input, 'camelCase');
210
- expect(transformNamingConvention(result, 'camelCase')).toBe(result);
211
- });
212
- it('should be idempotent for snake_case', () => {
213
- const input = 'get_user_by_id';
214
- const result = transformNamingConvention(input, 'snake_case');
215
- expect(transformNamingConvention(result, 'snake_case')).toBe(result);
216
- });
217
- });
218
- describe('special patterns', () => {
219
- it('should handle single word', () => {
220
- expect(transformNamingConvention('user', 'PascalCase')).toBe('User');
221
- });
222
- it('should handle two words', () => {
223
- expect(transformNamingConvention('getUser', 'snake_case')).toBe('get_user');
224
- });
225
- it('should handle very long names', () => {
226
- const longName = 'getVeryLongOperationNameWithManyWords';
227
- expect(transformNamingConvention(longName, 'kebab-case')).toBe('get-very-long-operation-name-with-many-words');
228
- });
229
- });
230
- });
231
- });
@@ -1,94 +0,0 @@
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
-