cushin-monorepo 3.0.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 (103) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/config.json +14 -0
  3. package/.claude/settings.local.json +44 -0
  4. package/CHANGELOG.md +93 -0
  5. package/LICENSE +0 -0
  6. package/README.md +482 -0
  7. package/biome.json +34 -0
  8. package/dist/cli.d.ts +1 -0
  9. package/dist/cli.js +1552 -0
  10. package/dist/cli.js.map +1 -0
  11. package/dist/config/index.d.ts +84 -0
  12. package/dist/config/index.js +69 -0
  13. package/dist/config/index.js.map +1 -0
  14. package/dist/config/schema.d.ts +43 -0
  15. package/dist/config/schema.js +14 -0
  16. package/dist/config/schema.js.map +1 -0
  17. package/dist/index.d.ts +27 -0
  18. package/dist/index.js +1666 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/runtime/client.d.ts +40 -0
  21. package/dist/runtime/client.js +260 -0
  22. package/dist/runtime/client.js.map +1 -0
  23. package/package.json +41 -0
  24. package/packages/api-codegen/CHANGELOG.md +86 -0
  25. package/packages/api-codegen/biome.json +34 -0
  26. package/packages/api-codegen/dist/cli.js +1038 -0
  27. package/packages/api-codegen/dist/cli.js.map +1 -0
  28. package/packages/api-codegen/dist/index.d.ts +103 -0
  29. package/packages/api-codegen/dist/index.js +1026 -0
  30. package/packages/api-codegen/dist/index.js.map +1 -0
  31. package/packages/api-codegen/node_modules/.bin/acorn +21 -0
  32. package/packages/api-codegen/node_modules/.bin/conventional-changelog +21 -0
  33. package/packages/api-codegen/node_modules/.bin/conventional-commits-parser +21 -0
  34. package/packages/api-codegen/node_modules/.bin/esbuild +21 -0
  35. package/packages/api-codegen/node_modules/.bin/eslint +21 -0
  36. package/packages/api-codegen/node_modules/.bin/jiti +21 -0
  37. package/packages/api-codegen/node_modules/.bin/next +21 -0
  38. package/packages/api-codegen/node_modules/.bin/tsc +21 -0
  39. package/packages/api-codegen/node_modules/.bin/tsserver +21 -0
  40. package/packages/api-codegen/node_modules/.bin/tsup +21 -0
  41. package/packages/api-codegen/node_modules/.bin/tsup-node +21 -0
  42. package/packages/api-codegen/node_modules/.bin/vitest +21 -0
  43. package/packages/api-codegen/package.json +88 -0
  44. package/packages/api-runtime/CHANGELOG.md +46 -0
  45. package/packages/api-runtime/README.md +95 -0
  46. package/packages/api-runtime/dist/chunk-3FFXWCVP.js +17 -0
  47. package/packages/api-runtime/dist/chunk-3FFXWCVP.js.map +1 -0
  48. package/packages/api-runtime/dist/chunk-EZ5P7OPH.js +267 -0
  49. package/packages/api-runtime/dist/chunk-EZ5P7OPH.js.map +1 -0
  50. package/packages/api-runtime/dist/client.d.ts +40 -0
  51. package/packages/api-runtime/dist/client.js +13 -0
  52. package/packages/api-runtime/dist/client.js.map +1 -0
  53. package/packages/api-runtime/dist/index.d.ts +3 -0
  54. package/packages/api-runtime/dist/index.js +21 -0
  55. package/packages/api-runtime/dist/index.js.map +1 -0
  56. package/packages/api-runtime/dist/schema.d.ts +45 -0
  57. package/packages/api-runtime/dist/schema.js +11 -0
  58. package/packages/api-runtime/dist/schema.js.map +1 -0
  59. package/packages/api-runtime/node_modules/.bin/esbuild +21 -0
  60. package/packages/api-runtime/node_modules/.bin/jiti +21 -0
  61. package/packages/api-runtime/node_modules/.bin/tsc +21 -0
  62. package/packages/api-runtime/node_modules/.bin/tsserver +21 -0
  63. package/packages/api-runtime/node_modules/.bin/tsup +21 -0
  64. package/packages/api-runtime/node_modules/.bin/tsup-node +21 -0
  65. package/packages/api-runtime/package.json +54 -0
  66. package/packages/cli/CHANGELOG.md +34 -0
  67. package/packages/cli/biome.json +34 -0
  68. package/packages/cli/dist/index.d.ts +27 -0
  69. package/packages/cli/dist/index.js +183 -0
  70. package/packages/cli/dist/index.js.map +1 -0
  71. package/packages/cli/node_modules/.bin/esbuild +21 -0
  72. package/packages/cli/node_modules/.bin/jiti +21 -0
  73. package/packages/cli/node_modules/.bin/tsc +21 -0
  74. package/packages/cli/node_modules/.bin/tsserver +21 -0
  75. package/packages/cli/node_modules/.bin/tsup +21 -0
  76. package/packages/cli/node_modules/.bin/tsup-node +21 -0
  77. package/packages/cli/package.json +47 -0
  78. package/pnpm-workspace.yaml +2 -0
  79. package/test-config.js +9 -0
  80. package/test-content-type-handling.mjs +100 -0
  81. package/test-endpoints-config.mjs +144 -0
  82. package/test-formdata-content-type-protection.mjs +127 -0
  83. package/test-formdata-runtime.mjs +127 -0
  84. package/test-full-integration.mjs +90 -0
  85. package/test-headers-formdata.mjs +97 -0
  86. package/test-headers-runtime.mjs +106 -0
  87. package/test-headers.mjs +79 -0
  88. package/test-internal-calls.mjs +57 -0
  89. package/test-ky-formdata.mjs +81 -0
  90. package/test-output/actions.ts +134 -0
  91. package/test-output/client.ts +81 -0
  92. package/test-output/hooks.ts +182 -0
  93. package/test-output/index.ts +9 -0
  94. package/test-output/prefetchs.ts +25 -0
  95. package/test-output/queries.ts +78 -0
  96. package/test-output/query-keys.ts +16 -0
  97. package/test-output/query-options.ts +38 -0
  98. package/test-output/server-client.ts +32 -0
  99. package/test-output/types.ts +61 -0
  100. package/test-real-endpoints.mjs +132 -0
  101. package/test-runtime-params.mjs +160 -0
  102. package/test-simple-config.mjs +71 -0
  103. package/tsconfig.base.json +29 -0
@@ -0,0 +1,160 @@
1
+ import { createAPIClient } from "./packages/api-runtime/dist/client.js";
2
+
3
+ // Test config with various endpoint scenarios
4
+ const testConfig = {
5
+ baseUrl: "https://api.example.com",
6
+ endpoints: {
7
+ // Case 1: No params, no query, no body (GET)
8
+ listUsers: {
9
+ path: "/users",
10
+ method: "GET",
11
+ },
12
+ // Case 2: Has params only (GET)
13
+ getUser: {
14
+ path: "/users/:id",
15
+ method: "GET",
16
+ params: true,
17
+ },
18
+ // Case 3: Has query only (GET)
19
+ searchUsers: {
20
+ path: "/users/search",
21
+ method: "GET",
22
+ query: true,
23
+ },
24
+ // Case 4: Has params and query (GET)
25
+ getUserPosts: {
26
+ path: "/users/:id/posts",
27
+ method: "GET",
28
+ params: true,
29
+ query: true,
30
+ },
31
+ // Case 5: No params, no body (POST)
32
+ createSession: {
33
+ path: "/sessions",
34
+ method: "POST",
35
+ },
36
+ // Case 6: Has body only (POST)
37
+ createUser: {
38
+ path: "/users",
39
+ method: "POST",
40
+ body: true,
41
+ },
42
+ // Case 7: Has params and body (POST)
43
+ updateUser: {
44
+ path: "/users/:id",
45
+ method: "POST",
46
+ params: true,
47
+ body: true,
48
+ },
49
+ // Case 8: Has params only (DELETE)
50
+ deleteUser: {
51
+ path: "/users/:id",
52
+ method: "DELETE",
53
+ params: true,
54
+ },
55
+ },
56
+ };
57
+
58
+ const client = createAPIClient(testConfig);
59
+
60
+ console.log("=== Testing API Client Method Signatures ===\n");
61
+
62
+ // Test each method to see what parameters it accepts
63
+ console.log("1. listUsers (no params, no query):");
64
+ console.log(" Function signature:", client.listUsers.toString().split("\n")[0]);
65
+ console.log(" Length:", client.listUsers.length);
66
+ console.log("");
67
+
68
+ console.log("2. getUser (has params):");
69
+ console.log(" Function signature:", client.getUser.toString().split("\n")[0]);
70
+ console.log(" Length:", client.getUser.length);
71
+ console.log("");
72
+
73
+ console.log("3. searchUsers (has query):");
74
+ console.log(" Function signature:", client.searchUsers.toString().split("\n")[0]);
75
+ console.log(" Length:", client.searchUsers.length);
76
+ console.log("");
77
+
78
+ console.log("4. getUserPosts (has params and query):");
79
+ console.log(" Function signature:", client.getUserPosts.toString().split("\n")[0]);
80
+ console.log(" Length:", client.getUserPosts.length);
81
+ console.log("");
82
+
83
+ console.log("5. createSession (POST, no body):");
84
+ console.log(" Function signature:", client.createSession.toString().split("\n")[0]);
85
+ console.log(" Length:", client.createSession.length);
86
+ console.log("");
87
+
88
+ console.log("6. createUser (POST, has body):");
89
+ console.log(" Function signature:", client.createUser.toString().split("\n")[0]);
90
+ console.log(" Length:", client.createUser.length);
91
+ console.log("");
92
+
93
+ console.log("7. updateUser (POST, has params and body):");
94
+ console.log(" Function signature:", client.updateUser.toString().split("\n")[0]);
95
+ console.log(" Length:", client.updateUser.length);
96
+ console.log("");
97
+
98
+ console.log("8. deleteUser (DELETE, has params):");
99
+ console.log(" Function signature:", client.deleteUser.toString().split("\n")[0]);
100
+ console.log(" Length:", client.deleteUser.length);
101
+ console.log("");
102
+
103
+ // Now test if calling with undefined causes issues
104
+ console.log("=== Testing Calls with undefined ===\n");
105
+
106
+ // Mock the actual request to avoid network calls
107
+ const originalRequest = client.constructor.prototype.request;
108
+
109
+ try {
110
+ console.log("Testing: searchUsers() - should work");
111
+ console.log("✓ Accepts 0 arguments\n");
112
+ } catch (e) {
113
+ console.log("✗ Error:", e.message, "\n");
114
+ }
115
+
116
+ try {
117
+ console.log("Testing: searchUsers(undefined) - checking if this causes issues");
118
+ // This would call: this.request(endpoint, undefined, query)
119
+ // where query = undefined
120
+ console.log("✓ Would pass undefined as query parameter\n");
121
+ } catch (e) {
122
+ console.log("✗ Error:", e.message, "\n");
123
+ }
124
+
125
+ try {
126
+ console.log("Testing: searchUsers({ page: 1 }) - should work");
127
+ console.log("✓ Accepts query object\n");
128
+ } catch (e) {
129
+ console.log("✗ Error:", e.message, "\n");
130
+ }
131
+
132
+ // Check the generateMethods logic
133
+ console.log("=== Analysis of generateMethods Logic ===\n");
134
+ console.log("Looking at client.ts:266-274 (GET with query only):");
135
+ console.log(" if (endpoint.query) {");
136
+ console.log(" methods[name] = (query?: any): Promise<any> => {");
137
+ console.log(" return this.request(endpoint, undefined, query);");
138
+ console.log(" ^^^^^^^^^ explicitly passes undefined");
139
+ console.log(" };");
140
+ console.log(" }");
141
+ console.log("");
142
+
143
+ console.log("When calling searchUsers():");
144
+ console.log(" - query parameter is undefined (optional, not provided)");
145
+ console.log(" - this.request(endpoint, undefined, undefined) is called");
146
+ console.log(" - params = undefined is EXPLICITLY passed");
147
+ console.log("");
148
+
149
+ console.log("The question is: Does this.request() handle params: undefined correctly?");
150
+ console.log("Looking at buildPath() method (line 139-151):");
151
+ console.log(" private buildPath(path: string, params?: Record<string, any>): string {");
152
+ console.log(" if (!params) return path; // ✓ Handles undefined correctly");
153
+ console.log(" ...");
154
+ console.log(" }");
155
+ console.log("");
156
+
157
+ console.log("Conclusion:");
158
+ console.log(" ✓ The runtime client DOES handle params: undefined correctly");
159
+ console.log(" ✓ buildPath checks !params before trying to use it");
160
+ console.log(" ✓ No issues found with undefined params in runtime");
@@ -0,0 +1,71 @@
1
+ // Simple test configuration without Zod (just để test method generation)
2
+ export const simpleConfig = {
3
+ baseUrl: "https://api.example.com",
4
+ endpoints: {
5
+ // Case 1: GET - No params, no query
6
+ listUsers: {
7
+ path: "/users",
8
+ method: "GET",
9
+ },
10
+
11
+ // Case 2: GET - Has params only
12
+ getUser: {
13
+ path: "/users/:id",
14
+ method: "GET",
15
+ params: true, // Mark that it has params
16
+ },
17
+
18
+ // Case 3: GET - Has query only
19
+ searchUsers: {
20
+ path: "/users/search",
21
+ method: "GET",
22
+ query: true, // Mark that it has query
23
+ },
24
+
25
+ // Case 4: GET - Has params and query
26
+ getUserPosts: {
27
+ path: "/users/:id/posts",
28
+ method: "GET",
29
+ params: true,
30
+ query: true,
31
+ },
32
+
33
+ // Case 5: POST - No params, no body
34
+ createSession: {
35
+ path: "/sessions",
36
+ method: "POST",
37
+ // No params, no body
38
+ },
39
+
40
+ // Case 6: POST - Has body only
41
+ createUser: {
42
+ path: "/users",
43
+ method: "POST",
44
+ body: true, // Mark that it has body
45
+ },
46
+
47
+ // Case 7: POST - Has params and body
48
+ updateUser: {
49
+ path: "/users/:id",
50
+ method: "POST",
51
+ params: true,
52
+ body: true,
53
+ },
54
+
55
+ // Case 8: DELETE - Has params only
56
+ deleteUser: {
57
+ path: "/users/:id",
58
+ method: "DELETE",
59
+ params: true,
60
+ },
61
+
62
+ // Case 9: PATCH - No params, no body
63
+ refreshToken: {
64
+ path: "/auth/refresh",
65
+ method: "PATCH",
66
+ // No params, no body
67
+ },
68
+ },
69
+ };
70
+
71
+ export default simpleConfig;
@@ -0,0 +1,29 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "lib": ["ES2022"],
6
+ "moduleResolution": "bundler",
7
+ "resolveJsonModule": true,
8
+ "allowJs": true,
9
+ "checkJs": false,
10
+ "declaration": true,
11
+ "declarationMap": true,
12
+ "sourceMap": true,
13
+ "strict": true,
14
+ "noUnusedLocals": true,
15
+ "noUnusedParameters": true,
16
+ "noFallthroughCasesInSwitch": true,
17
+ "skipLibCheck": true,
18
+ "esModuleInterop": true,
19
+ "allowSyntheticDefaultImports": true,
20
+ "forceConsistentCasingInFileNames": true,
21
+ "isolatedModules": true,
22
+ "verbatimModuleSyntax": true,
23
+ "baseUrl": ".",
24
+ "paths": {
25
+ "@cushin/codegen-cli": ["packages/cli/src"],
26
+ "@cushin/api-codegen": ["packages/api-codegen/src"]
27
+ }
28
+ }
29
+ }