@veloxts/client 0.7.0 → 0.7.2
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.
- package/CHANGELOG.md +12 -0
- package/dist/client.js +28 -32
- package/dist/errors.js +6 -4
- package/dist/react/proxy-hooks.js +2 -7
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @veloxts/client
|
|
2
2
|
|
|
3
|
+
## 0.7.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- chore(auth,core,create,cli,client,orm,mcp,router,validation,web): simplify code for clarity and maintainability
|
|
8
|
+
|
|
9
|
+
## 0.7.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- security audit, bumps dependency packages
|
|
14
|
+
|
|
3
15
|
## 0.7.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/client.js
CHANGED
|
@@ -61,11 +61,11 @@ function inferMethodFromName(procedureName) {
|
|
|
61
61
|
* @internal
|
|
62
62
|
*/
|
|
63
63
|
function isRouteEntry(value) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
if (typeof value !== 'object' || value === null) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
const obj = value;
|
|
68
|
+
return 'method' in obj && typeof obj.path === 'string';
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* Resolves a route mapping to method and path
|
|
@@ -84,43 +84,39 @@ function resolveRouteOverride(override, procedureName) {
|
|
|
84
84
|
return { method: inferMethodFromName(procedureName), path: override };
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
|
-
*
|
|
87
|
+
* Prefixes that map to collection endpoints (no :id)
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
const COLLECTION_PREFIXES = ['list', 'find', 'create', 'add'];
|
|
91
|
+
/**
|
|
92
|
+
* Prefixes that map to single-resource endpoints (with :id)
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
const SINGLE_RESOURCE_PREFIXES = ['get', 'update', 'edit', 'patch', 'delete', 'remove'];
|
|
96
|
+
/**
|
|
97
|
+
* Infers REST path from namespace and procedure name using naming conventions
|
|
88
98
|
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
99
|
+
* This function only handles convention-based inference. Route overrides
|
|
100
|
+
* are resolved by the caller (resolveMethodAndPath).
|
|
91
101
|
*
|
|
92
102
|
* @example
|
|
93
103
|
* - namespace='users', name='getUser' -> '/users/:id'
|
|
94
104
|
* - namespace='users', name='listUsers' -> '/users'
|
|
95
105
|
* - namespace='posts', name='createPost' -> '/posts'
|
|
96
|
-
* - namespace='auth', name='createAccount', routes={auth:{createAccount:{method:'POST',path:'/auth/register'}}} -> '/auth/register'
|
|
97
106
|
*
|
|
98
107
|
* @internal
|
|
99
108
|
*/
|
|
100
|
-
function
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return resolved.path;
|
|
106
|
-
}
|
|
107
|
-
// 2. Convention inference — collection endpoints (no :id)
|
|
108
|
-
if (procedureName.startsWith('list') ||
|
|
109
|
-
procedureName.startsWith('find') ||
|
|
110
|
-
procedureName.startsWith('create') ||
|
|
111
|
-
procedureName.startsWith('add')) {
|
|
112
|
-
return `/${namespace}`;
|
|
109
|
+
function inferRestPath(namespace, procedureName) {
|
|
110
|
+
for (const prefix of COLLECTION_PREFIXES) {
|
|
111
|
+
if (procedureName.startsWith(prefix)) {
|
|
112
|
+
return `/${namespace}`;
|
|
113
|
+
}
|
|
113
114
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
procedureName.startsWith('patch') ||
|
|
119
|
-
procedureName.startsWith('delete') ||
|
|
120
|
-
procedureName.startsWith('remove')) {
|
|
121
|
-
return `/${namespace}/:id`;
|
|
115
|
+
for (const prefix of SINGLE_RESOURCE_PREFIXES) {
|
|
116
|
+
if (procedureName.startsWith(prefix)) {
|
|
117
|
+
return `/${namespace}/:id`;
|
|
118
|
+
}
|
|
122
119
|
}
|
|
123
|
-
// 4. Fallback: /{namespace}
|
|
124
120
|
return `/${namespace}`;
|
|
125
121
|
}
|
|
126
122
|
/**
|
|
@@ -273,7 +269,7 @@ function resolveMethodAndPath(namespace, procedureName, routes) {
|
|
|
273
269
|
}
|
|
274
270
|
// Fall back to naming convention inference
|
|
275
271
|
const method = inferMethodFromName(procedureName);
|
|
276
|
-
const path =
|
|
272
|
+
const path = inferRestPath(namespace, procedureName);
|
|
277
273
|
return { method, path };
|
|
278
274
|
}
|
|
279
275
|
/**
|
package/dist/errors.js
CHANGED
|
@@ -242,8 +242,10 @@ function isErrorResponseLike(body) {
|
|
|
242
242
|
if (typeof body !== 'object' || body === null) {
|
|
243
243
|
return false;
|
|
244
244
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
typeof
|
|
245
|
+
return ('error' in body &&
|
|
246
|
+
typeof body.error === 'string' &&
|
|
247
|
+
'message' in body &&
|
|
248
|
+
typeof body.message === 'string' &&
|
|
249
|
+
'statusCode' in body &&
|
|
250
|
+
typeof body.statusCode === 'number');
|
|
249
251
|
}
|
|
@@ -444,15 +444,10 @@ function createMutationProcedureProxy(namespace, procedureName, getClient) {
|
|
|
444
444
|
* @returns true if the procedure is a query, false for mutation
|
|
445
445
|
*/
|
|
446
446
|
function isProcedureQuery(namespace, procedureName, routes) {
|
|
447
|
-
// Check routes for explicit kind first
|
|
448
447
|
const routeEntry = routes?.[namespace]?.[procedureName];
|
|
449
|
-
if (routeEntry) {
|
|
450
|
-
|
|
451
|
-
if (typeof routeEntry === 'object' && 'kind' in routeEntry) {
|
|
452
|
-
return routeEntry.kind === 'query';
|
|
453
|
-
}
|
|
448
|
+
if (typeof routeEntry === 'object' && 'kind' in routeEntry) {
|
|
449
|
+
return routeEntry.kind === 'query';
|
|
454
450
|
}
|
|
455
|
-
// Fall back to naming convention
|
|
456
451
|
return isQueryProcedure(procedureName);
|
|
457
452
|
}
|
|
458
453
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veloxts/client",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Type-safe frontend API client for VeloxTS framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@tanstack/react-query": "5.90.
|
|
38
|
+
"@tanstack/react-query": "5.90.21",
|
|
39
39
|
"@testing-library/jest-dom": "6.9.1",
|
|
40
40
|
"@testing-library/react": "16.3.2",
|
|
41
|
-
"@types/react": "19.2.
|
|
41
|
+
"@types/react": "19.2.14",
|
|
42
42
|
"@types/react-dom": "19.2.3",
|
|
43
43
|
"@vitest/coverage-v8": "4.0.18",
|
|
44
|
-
"jsdom": "
|
|
44
|
+
"jsdom": "28.0.0",
|
|
45
45
|
"react": "19.2.4",
|
|
46
46
|
"react-dom": "19.2.4",
|
|
47
47
|
"typescript": "5.9.3",
|