@veloxts/validation 0.6.87 → 0.6.89

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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @veloxts/validation
2
2
 
3
+ ## 0.6.89
4
+
5
+ ### Patch Changes
6
+
7
+ - expand preset system with server config, auth presets, and security validation
8
+ - Updated dependencies
9
+ - @veloxts/core@0.6.89
10
+
11
+ ## 0.6.88
12
+
13
+ ### Patch Changes
14
+
15
+ - add ecosystem presets for environment-aware configuration
16
+ - Updated dependencies
17
+ - @veloxts/core@0.6.88
18
+
3
19
  ## 0.6.87
4
20
 
5
21
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -34,5 +34,7 @@ export { baseEntitySchema, booleanStringSchema, createIdSchema, datetimeSchema,
34
34
  export type { CursorPaginatedResponse, CursorPaginationInput, CursorPaginationMeta, PaginatedResponse, PaginationInput, PaginationMeta, } from './schemas/pagination.js';
35
35
  export { calculateOffset, calculatePaginationMeta, createCursorPaginatedResponseSchema, createPaginatedResponse, createPaginatedResponseSchema, createPaginationSchema, cursorPaginationSchema, PAGINATION_DEFAULTS, paginationInputSchema, } from './schemas/pagination.js';
36
36
  export { pagination, queryArray, queryBoolean, queryEnum, queryInt, queryNumber, } from './schemas/query.js';
37
+ export type { HttpMethod } from './naming.js';
38
+ export { inferMethodFromName, isQueryProcedure, PROCEDURE_METHOD_MAP } from './naming.js';
37
39
  export type { InferWithTimestamps, OmitTimestamps, SerializedDates, WithOptional, } from './schemas/serialization.js';
38
40
  export { dateToISOString, dateToISOStringNullable, dateToISOStringOptional, dateToIso, dateToIsoNullable, dateToIsoOptional, prismaDecimal, prismaDecimalNullable, prismaDecimalOptional, timestamps, timestampsWithSoftDelete, withTimestamps, } from './schemas/serialization.js';
package/dist/index.js CHANGED
@@ -39,6 +39,7 @@ export { calculateOffset, calculatePaginationMeta, createCursorPaginatedResponse
39
39
  // Query Parameter Helpers
40
40
  // ============================================================================
41
41
  export { pagination, queryArray, queryBoolean, queryEnum, queryInt, queryNumber, } from './schemas/query.js';
42
+ export { inferMethodFromName, isQueryProcedure, PROCEDURE_METHOD_MAP } from './naming.js';
42
43
  export {
43
44
  // Date serialization
44
45
  dateToISOString, dateToISOStringNullable, dateToISOStringOptional,
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Naming conventions for procedure-to-REST mapping
3
+ *
4
+ * Provides shared constants for mapping procedure names to HTTP methods
5
+ * and REST paths. Used by both @veloxts/router and @veloxts/client.
6
+ *
7
+ * @module naming
8
+ */
9
+ /**
10
+ * HTTP methods supported by the REST adapter
11
+ *
12
+ * Full REST support: GET, POST, PUT, PATCH, DELETE
13
+ */
14
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
15
+ /**
16
+ * Maps procedure naming conventions to HTTP methods
17
+ *
18
+ * This is the single source of truth for the naming convention system.
19
+ * Both @veloxts/router and @veloxts/client import from here to ensure
20
+ * consistent behavior.
21
+ *
22
+ * @example
23
+ * - getUser -> GET
24
+ * - listUsers -> GET
25
+ * - createUser -> POST
26
+ * - updateUser -> PUT
27
+ * - patchUser -> PATCH
28
+ * - deleteUser -> DELETE
29
+ */
30
+ export declare const PROCEDURE_METHOD_MAP: Record<string, HttpMethod>;
31
+ /**
32
+ * Infers HTTP method from procedure name
33
+ *
34
+ * @param procedureName - The name of the procedure (e.g., 'getUser', 'createPost')
35
+ * @returns The inferred HTTP method
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * inferMethodFromName('getUser'); // 'GET'
40
+ * inferMethodFromName('createPost'); // 'POST'
41
+ * inferMethodFromName('updateUser'); // 'PUT'
42
+ * inferMethodFromName('someAction'); // 'POST' (default for mutations)
43
+ * ```
44
+ */
45
+ export declare function inferMethodFromName(procedureName: string): HttpMethod;
46
+ /**
47
+ * Checks if a procedure name indicates a query operation
48
+ *
49
+ * Query operations are read-only and map to GET requests.
50
+ *
51
+ * @param procedureName - The name of the procedure
52
+ * @returns true if the procedure is a query operation
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * isQueryProcedure('getUser'); // true
57
+ * isQueryProcedure('listUsers'); // true
58
+ * isQueryProcedure('findPosts'); // true
59
+ * isQueryProcedure('createUser'); // false
60
+ * ```
61
+ */
62
+ export declare function isQueryProcedure(procedureName: string): boolean;
package/dist/naming.js ADDED
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Naming conventions for procedure-to-REST mapping
3
+ *
4
+ * Provides shared constants for mapping procedure names to HTTP methods
5
+ * and REST paths. Used by both @veloxts/router and @veloxts/client.
6
+ *
7
+ * @module naming
8
+ */
9
+ // ============================================================================
10
+ // Procedure Method Mapping
11
+ // ============================================================================
12
+ /**
13
+ * Maps procedure naming conventions to HTTP methods
14
+ *
15
+ * This is the single source of truth for the naming convention system.
16
+ * Both @veloxts/router and @veloxts/client import from here to ensure
17
+ * consistent behavior.
18
+ *
19
+ * @example
20
+ * - getUser -> GET
21
+ * - listUsers -> GET
22
+ * - createUser -> POST
23
+ * - updateUser -> PUT
24
+ * - patchUser -> PATCH
25
+ * - deleteUser -> DELETE
26
+ */
27
+ export const PROCEDURE_METHOD_MAP = {
28
+ get: 'GET',
29
+ list: 'GET',
30
+ find: 'GET',
31
+ create: 'POST',
32
+ add: 'POST',
33
+ update: 'PUT',
34
+ edit: 'PUT',
35
+ patch: 'PATCH',
36
+ delete: 'DELETE',
37
+ remove: 'DELETE',
38
+ };
39
+ /**
40
+ * Infers HTTP method from procedure name
41
+ *
42
+ * @param procedureName - The name of the procedure (e.g., 'getUser', 'createPost')
43
+ * @returns The inferred HTTP method
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * inferMethodFromName('getUser'); // 'GET'
48
+ * inferMethodFromName('createPost'); // 'POST'
49
+ * inferMethodFromName('updateUser'); // 'PUT'
50
+ * inferMethodFromName('someAction'); // 'POST' (default for mutations)
51
+ * ```
52
+ */
53
+ export function inferMethodFromName(procedureName) {
54
+ for (const [prefix, method] of Object.entries(PROCEDURE_METHOD_MAP)) {
55
+ if (procedureName.startsWith(prefix)) {
56
+ return method;
57
+ }
58
+ }
59
+ // Default to POST for mutations (conservative default)
60
+ return 'POST';
61
+ }
62
+ /**
63
+ * Checks if a procedure name indicates a query operation
64
+ *
65
+ * Query operations are read-only and map to GET requests.
66
+ *
67
+ * @param procedureName - The name of the procedure
68
+ * @returns true if the procedure is a query operation
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * isQueryProcedure('getUser'); // true
73
+ * isQueryProcedure('listUsers'); // true
74
+ * isQueryProcedure('findPosts'); // true
75
+ * isQueryProcedure('createUser'); // false
76
+ * ```
77
+ */
78
+ export function isQueryProcedure(procedureName) {
79
+ return (procedureName.startsWith('get') ||
80
+ procedureName.startsWith('list') ||
81
+ procedureName.startsWith('find'));
82
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veloxts/validation",
3
- "version": "0.6.87",
3
+ "version": "0.6.89",
4
4
  "description": "Zod integration and validation middleware for VeloxTS framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "zod": "3.25.76",
26
- "@veloxts/core": "0.6.87"
26
+ "@veloxts/core": "0.6.89"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@vitest/coverage-v8": "4.0.16",