fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: rename plugin to orpc

Lubos 51becd48 61561825

+507 -1130
+1 -1
.changeset/lazy-nails-give.md
··· 2 2 "@hey-api/openapi-ts": patch 3 3 --- 4 4 5 - **plugin(@orpc/contract)**: initial release 5 + **plugin(orpc)**: initial release
+1 -7
dev/typescript/presets.ts
··· 32 32 ], 33 33 rpc: () => [ 34 34 /** RPC-style SDK with Zod validation */ 35 - { 36 - contracts: { 37 - containerName: 'contracted', 38 - strategy: 'single', 39 - }, 40 - name: '@orpc/contract', 41 - }, 35 + 'orpc', 42 36 'zod', 43 37 ], 44 38 sdk: () => [
packages/openapi-ts-tests/@orpc/contract/v1/.gitignore packages/openapi-ts-tests/orpc/v1/.gitignore
+18 -20
packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.0.x/custom-contract-name/@orpc/contract.gen.ts packages/openapi-ts-tests/orpc/v1/__snapshots__/3.0.x/custom-names/orpc.gen.ts
··· 2 2 3 3 import { oc } from '@orpc/contract'; 4 4 5 - import { zCreatePostData, zCreatePostResponse, zCreateUserData, zCreateUserResponse, zDeleteUserData, zGetPostByIdData, zGetPostByIdResponse, zGetPostsData, zGetPostsResponse, zGetUserByIdData, zGetUserByIdResponse, zGetUsersData, zGetUsersResponse, zUpdateUserData, zUpdateUserResponse } from '../zod.gen'; 5 + import { vCreatePostData, vCreatePostResponse, vCreateUserData, vCreateUserResponse, vDeleteUserData, vGetPostByIdData, vGetPostByIdResponse, vGetPostsData, vGetPostsResponse, vGetUserByIdData, vGetUserByIdResponse, vGetUsersData, vGetUsersResponse, vUpdateUserData, vUpdateUserResponse } from './valibot.gen'; 6 6 7 7 export const base = oc.$route({ inputStructure: 'detailed' }); 8 8 ··· 15 15 path: '/users', 16 16 summary: 'Get all users', 17 17 tags: ['users'] 18 - }).input(zGetUsersData).output(zGetUsersResponse); 18 + }).input(vGetUsersData).output(vGetUsersResponse); 19 19 20 20 /** 21 21 * Create a new user ··· 27 27 successStatus: 201, 28 28 summary: 'Create a new user', 29 29 tags: ['users'] 30 - }).input(zCreateUserData).output(zCreateUserResponse); 30 + }).input(vCreateUserData).output(vCreateUserResponse); 31 31 32 32 /** 33 33 * Delete a user ··· 38 38 path: '/users/{userId}', 39 39 summary: 'Delete a user', 40 40 tags: ['users'] 41 - }).input(zDeleteUserData); 41 + }).input(vDeleteUserData); 42 42 43 43 /** 44 44 * Get a user by ID ··· 49 49 path: '/users/{userId}', 50 50 summary: 'Get a user by ID', 51 51 tags: ['users'] 52 - }).input(zGetUserByIdData).output(zGetUserByIdResponse); 52 + }).input(vGetUserByIdData).output(vGetUserByIdResponse); 53 53 54 54 /** 55 55 * Update a user ··· 60 60 path: '/users/{userId}', 61 61 summary: 'Update a user', 62 62 tags: ['users'] 63 - }).input(zUpdateUserData).output(zUpdateUserResponse); 63 + }).input(vUpdateUserData).output(vUpdateUserResponse); 64 64 65 65 /** 66 66 * Get all posts ··· 71 71 path: '/posts', 72 72 summary: 'Get all posts', 73 73 tags: ['posts'] 74 - }).input(zGetPostsData).output(zGetPostsResponse); 74 + }).input(vGetPostsData).output(vGetPostsResponse); 75 75 76 76 /** 77 77 * Create a new post ··· 83 83 successStatus: 201, 84 84 summary: 'Create a new post', 85 85 tags: ['posts'] 86 - }).input(zCreatePostData).output(zCreatePostResponse); 86 + }).input(vCreatePostData).output(vCreatePostResponse); 87 87 88 88 /** 89 89 * Get a post by ID ··· 94 94 path: '/posts/{postId}', 95 95 summary: 'Get a post by ID', 96 96 tags: ['posts'] 97 - }).input(zGetPostByIdData).output(zGetPostByIdResponse); 97 + }).input(vGetPostByIdData).output(vGetPostByIdResponse); 98 98 99 - export const router = { 100 - getUsers: getUsersRpc, 101 - createUser: createUserRpc, 102 - deleteUser: deleteUserRpc, 103 - getUserById: getUserByIdRpc, 104 - updateUser: updateUserRpc, 105 - getPosts: getPostsRpc, 106 - createPost: createPostRpc, 107 - getPostById: getPostByIdRpc 99 + export const rpcContract = { 100 + getUsersRpc, 101 + createUserRpc, 102 + deleteUserRpc, 103 + getUserByIdRpc, 104 + updateUserRpc, 105 + getPostsRpc, 106 + createPostRpc, 107 + getPostByIdRpc 108 108 }; 109 - 110 - export type Router = typeof router;
-154
packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.0.x/custom-contract-name/zod.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import * as z from 'zod'; 4 - 5 - export const zUser = z.object({ 6 - id: z.string(), 7 - email: z.email(), 8 - name: z.string(), 9 - createdAt: z.iso.datetime().optional() 10 - }); 11 - 12 - export const zCreateUserInput = z.object({ 13 - email: z.email(), 14 - name: z.string(), 15 - password: z.string().min(8).optional() 16 - }); 17 - 18 - export const zUpdateUserInput = z.object({ 19 - email: z.email().optional(), 20 - name: z.string().optional() 21 - }); 22 - 23 - export const zPost = z.object({ 24 - id: z.string(), 25 - title: z.string(), 26 - content: z.string(), 27 - authorId: z.string(), 28 - status: z.enum([ 29 - 'draft', 30 - 'published', 31 - 'archived' 32 - ]).optional(), 33 - createdAt: z.iso.datetime().optional() 34 - }); 35 - 36 - export const zCreatePostInput = z.object({ 37 - title: z.string(), 38 - content: z.string(), 39 - status: z.enum(['draft', 'published']).optional() 40 - }); 41 - 42 - export const zGetUsersData = z.object({ 43 - body: z.never().optional(), 44 - path: z.never().optional(), 45 - query: z.object({ 46 - limit: z.int().optional().default(10), 47 - offset: z.int().optional().default(0) 48 - }).optional() 49 - }); 50 - 51 - /** 52 - * List of users 53 - */ 54 - export const zGetUsersResponse = z.array(zUser); 55 - 56 - export const zCreateUserData = z.object({ 57 - body: zCreateUserInput, 58 - path: z.never().optional(), 59 - query: z.never().optional() 60 - }); 61 - 62 - /** 63 - * User created 64 - */ 65 - export const zCreateUserResponse = zUser; 66 - 67 - export const zDeleteUserData = z.object({ 68 - body: z.never().optional(), 69 - path: z.object({ 70 - userId: z.string() 71 - }), 72 - query: z.never().optional(), 73 - headers: z.object({ 74 - 'X-Request-Id': z.string().optional() 75 - }).optional() 76 - }); 77 - 78 - /** 79 - * User deleted 80 - */ 81 - export const zDeleteUserResponse = z.void(); 82 - 83 - export const zGetUserByIdData = z.object({ 84 - body: z.never().optional(), 85 - path: z.object({ 86 - userId: z.string() 87 - }), 88 - query: z.never().optional() 89 - }); 90 - 91 - /** 92 - * User found 93 - */ 94 - export const zGetUserByIdResponse = zUser; 95 - 96 - export const zUpdateUserData = z.object({ 97 - body: zUpdateUserInput, 98 - path: z.object({ 99 - userId: z.string() 100 - }), 101 - query: z.never().optional() 102 - }); 103 - 104 - /** 105 - * User updated 106 - */ 107 - export const zUpdateUserResponse = zUser; 108 - 109 - export const zGetPostsData = z.object({ 110 - body: z.never().optional(), 111 - path: z.never().optional(), 112 - query: z.object({ 113 - authorId: z.string().optional(), 114 - status: z.enum([ 115 - 'draft', 116 - 'published', 117 - 'archived' 118 - ]).optional() 119 - }).optional() 120 - }); 121 - 122 - /** 123 - * List of posts 124 - */ 125 - export const zGetPostsResponse = z.array(zPost); 126 - 127 - export const zCreatePostData = z.object({ 128 - body: zCreatePostInput, 129 - path: z.never().optional(), 130 - query: z.never().optional(), 131 - headers: z.object({ 132 - 'X-Author-Id': z.string() 133 - }) 134 - }); 135 - 136 - /** 137 - * Post created 138 - */ 139 - export const zCreatePostResponse = zPost; 140 - 141 - export const zGetPostByIdData = z.object({ 142 - body: z.never().optional(), 143 - path: z.object({ 144 - postId: z.string() 145 - }), 146 - query: z.object({ 147 - includeComments: z.boolean().optional().default(false) 148 - }).optional() 149 - }); 150 - 151 - /** 152 - * Post found 153 - */ 154 - export const zGetPostByIdResponse = zPost;
+1 -3
packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.0.x/custom-router-name/@orpc/contract.gen.ts packages/openapi-ts-tests/orpc/v1/__snapshots__/3.0.x/default/orpc.gen.ts
··· 2 2 3 3 import { oc } from '@orpc/contract'; 4 4 5 - import { zCreatePostData, zCreatePostResponse, zCreateUserData, zCreateUserResponse, zDeleteUserData, zGetPostByIdData, zGetPostByIdResponse, zGetPostsData, zGetPostsResponse, zGetUserByIdData, zGetUserByIdResponse, zGetUsersData, zGetUsersResponse, zUpdateUserData, zUpdateUserResponse } from '../zod.gen'; 5 + import { zCreatePostData, zCreatePostResponse, zCreateUserData, zCreateUserResponse, zDeleteUserData, zGetPostByIdData, zGetPostByIdResponse, zGetPostsData, zGetPostsResponse, zGetUserByIdData, zGetUserByIdResponse, zGetUsersData, zGetUsersResponse, zUpdateUserData, zUpdateUserResponse } from './zod.gen'; 6 6 7 7 export const base = oc.$route({ inputStructure: 'detailed' }); 8 8 ··· 106 106 createPost, 107 107 getPostById 108 108 }; 109 - 110 - export type Contract = typeof contract;
-154
packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.0.x/custom-router-name/zod.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import * as z from 'zod'; 4 - 5 - export const zUser = z.object({ 6 - id: z.string(), 7 - email: z.email(), 8 - name: z.string(), 9 - createdAt: z.iso.datetime().optional() 10 - }); 11 - 12 - export const zCreateUserInput = z.object({ 13 - email: z.email(), 14 - name: z.string(), 15 - password: z.string().min(8).optional() 16 - }); 17 - 18 - export const zUpdateUserInput = z.object({ 19 - email: z.email().optional(), 20 - name: z.string().optional() 21 - }); 22 - 23 - export const zPost = z.object({ 24 - id: z.string(), 25 - title: z.string(), 26 - content: z.string(), 27 - authorId: z.string(), 28 - status: z.enum([ 29 - 'draft', 30 - 'published', 31 - 'archived' 32 - ]).optional(), 33 - createdAt: z.iso.datetime().optional() 34 - }); 35 - 36 - export const zCreatePostInput = z.object({ 37 - title: z.string(), 38 - content: z.string(), 39 - status: z.enum(['draft', 'published']).optional() 40 - }); 41 - 42 - export const zGetUsersData = z.object({ 43 - body: z.never().optional(), 44 - path: z.never().optional(), 45 - query: z.object({ 46 - limit: z.int().optional().default(10), 47 - offset: z.int().optional().default(0) 48 - }).optional() 49 - }); 50 - 51 - /** 52 - * List of users 53 - */ 54 - export const zGetUsersResponse = z.array(zUser); 55 - 56 - export const zCreateUserData = z.object({ 57 - body: zCreateUserInput, 58 - path: z.never().optional(), 59 - query: z.never().optional() 60 - }); 61 - 62 - /** 63 - * User created 64 - */ 65 - export const zCreateUserResponse = zUser; 66 - 67 - export const zDeleteUserData = z.object({ 68 - body: z.never().optional(), 69 - path: z.object({ 70 - userId: z.string() 71 - }), 72 - query: z.never().optional(), 73 - headers: z.object({ 74 - 'X-Request-Id': z.string().optional() 75 - }).optional() 76 - }); 77 - 78 - /** 79 - * User deleted 80 - */ 81 - export const zDeleteUserResponse = z.void(); 82 - 83 - export const zGetUserByIdData = z.object({ 84 - body: z.never().optional(), 85 - path: z.object({ 86 - userId: z.string() 87 - }), 88 - query: z.never().optional() 89 - }); 90 - 91 - /** 92 - * User found 93 - */ 94 - export const zGetUserByIdResponse = zUser; 95 - 96 - export const zUpdateUserData = z.object({ 97 - body: zUpdateUserInput, 98 - path: z.object({ 99 - userId: z.string() 100 - }), 101 - query: z.never().optional() 102 - }); 103 - 104 - /** 105 - * User updated 106 - */ 107 - export const zUpdateUserResponse = zUser; 108 - 109 - export const zGetPostsData = z.object({ 110 - body: z.never().optional(), 111 - path: z.never().optional(), 112 - query: z.object({ 113 - authorId: z.string().optional(), 114 - status: z.enum([ 115 - 'draft', 116 - 'published', 117 - 'archived' 118 - ]).optional() 119 - }).optional() 120 - }); 121 - 122 - /** 123 - * List of posts 124 - */ 125 - export const zGetPostsResponse = z.array(zPost); 126 - 127 - export const zCreatePostData = z.object({ 128 - body: zCreatePostInput, 129 - path: z.never().optional(), 130 - query: z.never().optional(), 131 - headers: z.object({ 132 - 'X-Author-Id': z.string() 133 - }) 134 - }); 135 - 136 - /** 137 - * Post created 138 - */ 139 - export const zCreatePostResponse = zPost; 140 - 141 - export const zGetPostByIdData = z.object({ 142 - body: z.never().optional(), 143 - path: z.object({ 144 - postId: z.string() 145 - }), 146 - query: z.object({ 147 - includeComments: z.boolean().optional().default(false) 148 - }).optional() 149 - }); 150 - 151 - /** 152 - * Post found 153 - */ 154 - export const zGetPostByIdResponse = zPost;
+10 -9
packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.0.x/default/@orpc/contract.gen.ts packages/openapi-ts-tests/orpc/v1/__snapshots__/3.1.x/contracts-strategy-by-tags/orpc.gen.ts
··· 2 2 3 3 import { oc } from '@orpc/contract'; 4 4 5 - import { zCreatePostData, zCreatePostResponse, zCreateUserData, zCreateUserResponse, zDeleteUserData, zGetPostByIdData, zGetPostByIdResponse, zGetPostsData, zGetPostsResponse, zGetUserByIdData, zGetUserByIdResponse, zGetUsersData, zGetUsersResponse, zUpdateUserData, zUpdateUserResponse } from '../zod.gen'; 5 + import { zCreatePostData, zCreatePostResponse, zCreateUserData, zCreateUserResponse, zDeleteUserData, zGetPostByIdData, zGetPostByIdResponse, zGetPostsData, zGetPostsResponse, zGetUserByIdData, zGetUserByIdResponse, zGetUsersData, zGetUsersResponse, zUpdateUserData, zUpdateUserResponse } from './zod.gen'; 6 6 7 7 export const base = oc.$route({ inputStructure: 'detailed' }); 8 8 ··· 62 62 tags: ['users'] 63 63 }).input(zUpdateUserData).output(zUpdateUserResponse); 64 64 65 + export const users = { 66 + getUsers, 67 + createUser, 68 + deleteUser, 69 + getUserById, 70 + updateUser 71 + }; 72 + 65 73 /** 66 74 * Get all posts 67 75 */ ··· 96 104 tags: ['posts'] 97 105 }).input(zGetPostByIdData).output(zGetPostByIdResponse); 98 106 99 - export const router = { 100 - getUsers, 101 - createUser, 102 - deleteUser, 103 - getUserById, 104 - updateUser, 107 + export const posts = { 105 108 getPosts, 106 109 createPost, 107 110 getPostById 108 111 }; 109 - 110 - export type Router = typeof router;
packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.0.x/default/zod.gen.ts packages/openapi-ts-tests/orpc/v1/__snapshots__/3.0.x/default/zod.gen.ts
+1 -14
packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.1.x/contracts-custom-naming/@orpc/contract.gen.ts packages/openapi-ts-tests/orpc/v1/__snapshots__/3.1.x/contracts-custom-naming/orpc.gen.ts
··· 2 2 3 3 import { oc } from '@orpc/contract'; 4 4 5 - import { zCreatePostData, zCreatePostResponse, zCreateUserData, zCreateUserResponse, zDeleteUserData, zGetPostByIdData, zGetPostByIdResponse, zGetPostsData, zGetPostsResponse, zGetUserByIdData, zGetUserByIdResponse, zGetUsersData, zGetUsersResponse, zUpdateUserData, zUpdateUserResponse } from '../zod.gen'; 5 + import { zCreatePostData, zCreatePostResponse, zCreateUserData, zCreateUserResponse, zDeleteUserData, zGetPostByIdData, zGetPostByIdResponse, zGetPostsData, zGetPostsResponse, zGetUserByIdData, zGetUserByIdResponse, zGetUsersData, zGetUsersResponse, zUpdateUserData, zUpdateUserResponse } from './zod.gen'; 6 6 7 7 export const base = oc.$route({ inputStructure: 'detailed' }); 8 8 ··· 109 109 CreatePost, 110 110 GetPostById 111 111 }; 112 - 113 - export const router = { 114 - getUsers: GetUsers, 115 - createUser: CreateUser, 116 - deleteUser: DeleteUser, 117 - getUserById: GetUserById, 118 - updateUser: UpdateUser, 119 - getPosts: GetPosts, 120 - createPost: CreatePost, 121 - getPostById: GetPostById 122 - }; 123 - 124 - export type Router = typeof router;
packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.1.x/contracts-custom-naming/zod.gen.ts packages/openapi-ts-tests/orpc/v1/__snapshots__/3.1.x/contracts-custom-naming/zod.gen.ts
-124
packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.1.x/contracts-nesting-id/@orpc/contract.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { oc } from '@orpc/contract'; 4 - 5 - import { zCreatePostData, zCreatePostResponse, zCreateUserData, zCreateUserResponse, zDeleteUserData, zGetPostByIdData, zGetPostByIdResponse, zGetPostsData, zGetPostsResponse, zGetUserByIdData, zGetUserByIdResponse, zGetUsersData, zGetUsersResponse, zUpdateUserData, zUpdateUserResponse } from '../zod.gen'; 6 - 7 - export const base = oc.$route({ inputStructure: 'detailed' }); 8 - 9 - /** 10 - * Get all users 11 - */ 12 - export const getUsers = base.route({ 13 - method: 'GET', 14 - operationId: 'getUsers', 15 - path: '/users', 16 - summary: 'Get all users', 17 - tags: ['users'] 18 - }).input(zGetUsersData).output(zGetUsersResponse); 19 - 20 - /** 21 - * Create a new user 22 - */ 23 - export const createUser = base.route({ 24 - method: 'POST', 25 - operationId: 'createUser', 26 - path: '/users', 27 - successStatus: 201, 28 - summary: 'Create a new user', 29 - tags: ['users'] 30 - }).input(zCreateUserData).output(zCreateUserResponse); 31 - 32 - /** 33 - * Delete a user 34 - */ 35 - export const deleteUser = base.route({ 36 - method: 'DELETE', 37 - operationId: 'deleteUser', 38 - path: '/users/{userId}', 39 - summary: 'Delete a user', 40 - tags: ['users'] 41 - }).input(zDeleteUserData); 42 - 43 - /** 44 - * Get a user by ID 45 - */ 46 - export const getUserById = base.route({ 47 - method: 'GET', 48 - operationId: 'getUserById', 49 - path: '/users/{userId}', 50 - summary: 'Get a user by ID', 51 - tags: ['users'] 52 - }).input(zGetUserByIdData).output(zGetUserByIdResponse); 53 - 54 - /** 55 - * Update a user 56 - */ 57 - export const updateUser = base.route({ 58 - method: 'PUT', 59 - operationId: 'updateUser', 60 - path: '/users/{userId}', 61 - summary: 'Update a user', 62 - tags: ['users'] 63 - }).input(zUpdateUserData).output(zUpdateUserResponse); 64 - 65 - export const users = { 66 - getUsers, 67 - createUser, 68 - deleteUser, 69 - getUserById, 70 - updateUser 71 - }; 72 - 73 - /** 74 - * Get all posts 75 - */ 76 - export const getPosts = base.route({ 77 - method: 'GET', 78 - operationId: 'getPosts', 79 - path: '/posts', 80 - summary: 'Get all posts', 81 - tags: ['posts'] 82 - }).input(zGetPostsData).output(zGetPostsResponse); 83 - 84 - /** 85 - * Create a new post 86 - */ 87 - export const createPost = base.route({ 88 - method: 'POST', 89 - operationId: 'createPost', 90 - path: '/posts', 91 - successStatus: 201, 92 - summary: 'Create a new post', 93 - tags: ['posts'] 94 - }).input(zCreatePostData).output(zCreatePostResponse); 95 - 96 - /** 97 - * Get a post by ID 98 - */ 99 - export const getPostById = base.route({ 100 - method: 'GET', 101 - operationId: 'getPostById', 102 - path: '/posts/{postId}', 103 - summary: 'Get a post by ID', 104 - tags: ['posts'] 105 - }).input(zGetPostByIdData).output(zGetPostByIdResponse); 106 - 107 - export const posts = { 108 - getPosts, 109 - createPost, 110 - getPostById 111 - }; 112 - 113 - export const router = { 114 - getUsers, 115 - createUser, 116 - deleteUser, 117 - getUserById, 118 - updateUser, 119 - getPosts, 120 - createPost, 121 - getPostById 122 - }; 123 - 124 - export type Router = typeof router;
packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.1.x/contracts-nesting-id/zod.gen.ts packages/openapi-ts-tests/orpc/v1/__snapshots__/3.1.x/contracts-nesting-id/zod.gen.ts
+1 -14
packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.1.x/contracts-strategy-by-tags/@orpc/contract.gen.ts packages/openapi-ts-tests/orpc/v1/__snapshots__/3.1.x/contracts-nesting-id/orpc.gen.ts
··· 2 2 3 3 import { oc } from '@orpc/contract'; 4 4 5 - import { zCreatePostData, zCreatePostResponse, zCreateUserData, zCreateUserResponse, zDeleteUserData, zGetPostByIdData, zGetPostByIdResponse, zGetPostsData, zGetPostsResponse, zGetUserByIdData, zGetUserByIdResponse, zGetUsersData, zGetUsersResponse, zUpdateUserData, zUpdateUserResponse } from '../zod.gen'; 5 + import { zCreatePostData, zCreatePostResponse, zCreateUserData, zCreateUserResponse, zDeleteUserData, zGetPostByIdData, zGetPostByIdResponse, zGetPostsData, zGetPostsResponse, zGetUserByIdData, zGetUserByIdResponse, zGetUsersData, zGetUsersResponse, zUpdateUserData, zUpdateUserResponse } from './zod.gen'; 6 6 7 7 export const base = oc.$route({ inputStructure: 'detailed' }); 8 8 ··· 109 109 createPost, 110 110 getPostById 111 111 }; 112 - 113 - export const router = { 114 - getUsers, 115 - createUser, 116 - deleteUser, 117 - getUserById, 118 - updateUser, 119 - getPosts, 120 - createPost, 121 - getPostById 122 - }; 123 - 124 - export type Router = typeof router;
packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.1.x/contracts-strategy-by-tags/zod.gen.ts packages/openapi-ts-tests/orpc/v1/__snapshots__/3.1.x/contracts-strategy-by-tags/zod.gen.ts
-121
packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.1.x/contracts-strategy-single/@orpc/contract.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import { oc } from '@orpc/contract'; 4 - 5 - import { zCreatePostData, zCreatePostResponse, zCreateUserData, zCreateUserResponse, zDeleteUserData, zGetPostByIdData, zGetPostByIdResponse, zGetPostsData, zGetPostsResponse, zGetUserByIdData, zGetUserByIdResponse, zGetUsersData, zGetUsersResponse, zUpdateUserData, zUpdateUserResponse } from '../zod.gen'; 6 - 7 - export const base = oc.$route({ inputStructure: 'detailed' }); 8 - 9 - /** 10 - * Get all users 11 - */ 12 - export const getUsers = base.route({ 13 - method: 'GET', 14 - operationId: 'getUsers', 15 - path: '/users', 16 - summary: 'Get all users', 17 - tags: ['users'] 18 - }).input(zGetUsersData).output(zGetUsersResponse); 19 - 20 - /** 21 - * Create a new user 22 - */ 23 - export const createUser = base.route({ 24 - method: 'POST', 25 - operationId: 'createUser', 26 - path: '/users', 27 - successStatus: 201, 28 - summary: 'Create a new user', 29 - tags: ['users'] 30 - }).input(zCreateUserData).output(zCreateUserResponse); 31 - 32 - /** 33 - * Delete a user 34 - */ 35 - export const deleteUser = base.route({ 36 - method: 'DELETE', 37 - operationId: 'deleteUser', 38 - path: '/users/{userId}', 39 - summary: 'Delete a user', 40 - tags: ['users'] 41 - }).input(zDeleteUserData); 42 - 43 - /** 44 - * Get a user by ID 45 - */ 46 - export const getUserById = base.route({ 47 - method: 'GET', 48 - operationId: 'getUserById', 49 - path: '/users/{userId}', 50 - summary: 'Get a user by ID', 51 - tags: ['users'] 52 - }).input(zGetUserByIdData).output(zGetUserByIdResponse); 53 - 54 - /** 55 - * Update a user 56 - */ 57 - export const updateUser = base.route({ 58 - method: 'PUT', 59 - operationId: 'updateUser', 60 - path: '/users/{userId}', 61 - summary: 'Update a user', 62 - tags: ['users'] 63 - }).input(zUpdateUserData).output(zUpdateUserResponse); 64 - 65 - /** 66 - * Get all posts 67 - */ 68 - export const getPosts = base.route({ 69 - method: 'GET', 70 - operationId: 'getPosts', 71 - path: '/posts', 72 - summary: 'Get all posts', 73 - tags: ['posts'] 74 - }).input(zGetPostsData).output(zGetPostsResponse); 75 - 76 - /** 77 - * Create a new post 78 - */ 79 - export const createPost = base.route({ 80 - method: 'POST', 81 - operationId: 'createPost', 82 - path: '/posts', 83 - successStatus: 201, 84 - summary: 'Create a new post', 85 - tags: ['posts'] 86 - }).input(zCreatePostData).output(zCreatePostResponse); 87 - 88 - /** 89 - * Get a post by ID 90 - */ 91 - export const getPostById = base.route({ 92 - method: 'GET', 93 - operationId: 'getPostById', 94 - path: '/posts/{postId}', 95 - summary: 'Get a post by ID', 96 - tags: ['posts'] 97 - }).input(zGetPostByIdData).output(zGetPostByIdResponse); 98 - 99 - export const api = { 100 - getUsers, 101 - createUser, 102 - deleteUser, 103 - getUserById, 104 - updateUser, 105 - getPosts, 106 - createPost, 107 - getPostById 108 - }; 109 - 110 - export const router = { 111 - getUsers, 112 - createUser, 113 - deleteUser, 114 - getUserById, 115 - updateUser, 116 - getPosts, 117 - createPost, 118 - getPostById 119 - }; 120 - 121 - export type Router = typeof router;
packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.1.x/contracts-strategy-single/zod.gen.ts packages/openapi-ts-tests/orpc/v1/__snapshots__/3.1.x/contracts-strategy-single/zod.gen.ts
+18 -20
packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.1.x/custom-contract-name/@orpc/contract.gen.ts packages/openapi-ts-tests/orpc/v1/__snapshots__/3.1.x/custom-names/orpc.gen.ts
··· 2 2 3 3 import { oc } from '@orpc/contract'; 4 4 5 - import { zCreatePostData, zCreatePostResponse, zCreateUserData, zCreateUserResponse, zDeleteUserData, zGetPostByIdData, zGetPostByIdResponse, zGetPostsData, zGetPostsResponse, zGetUserByIdData, zGetUserByIdResponse, zGetUsersData, zGetUsersResponse, zUpdateUserData, zUpdateUserResponse } from '../zod.gen'; 5 + import { vCreatePostData, vCreatePostResponse, vCreateUserData, vCreateUserResponse, vDeleteUserData, vGetPostByIdData, vGetPostByIdResponse, vGetPostsData, vGetPostsResponse, vGetUserByIdData, vGetUserByIdResponse, vGetUsersData, vGetUsersResponse, vUpdateUserData, vUpdateUserResponse } from './valibot.gen'; 6 6 7 7 export const base = oc.$route({ inputStructure: 'detailed' }); 8 8 ··· 15 15 path: '/users', 16 16 summary: 'Get all users', 17 17 tags: ['users'] 18 - }).input(zGetUsersData).output(zGetUsersResponse); 18 + }).input(vGetUsersData).output(vGetUsersResponse); 19 19 20 20 /** 21 21 * Create a new user ··· 27 27 successStatus: 201, 28 28 summary: 'Create a new user', 29 29 tags: ['users'] 30 - }).input(zCreateUserData).output(zCreateUserResponse); 30 + }).input(vCreateUserData).output(vCreateUserResponse); 31 31 32 32 /** 33 33 * Delete a user ··· 38 38 path: '/users/{userId}', 39 39 summary: 'Delete a user', 40 40 tags: ['users'] 41 - }).input(zDeleteUserData); 41 + }).input(vDeleteUserData); 42 42 43 43 /** 44 44 * Get a user by ID ··· 49 49 path: '/users/{userId}', 50 50 summary: 'Get a user by ID', 51 51 tags: ['users'] 52 - }).input(zGetUserByIdData).output(zGetUserByIdResponse); 52 + }).input(vGetUserByIdData).output(vGetUserByIdResponse); 53 53 54 54 /** 55 55 * Update a user ··· 60 60 path: '/users/{userId}', 61 61 summary: 'Update a user', 62 62 tags: ['users'] 63 - }).input(zUpdateUserData).output(zUpdateUserResponse); 63 + }).input(vUpdateUserData).output(vUpdateUserResponse); 64 64 65 65 /** 66 66 * Get all posts ··· 71 71 path: '/posts', 72 72 summary: 'Get all posts', 73 73 tags: ['posts'] 74 - }).input(zGetPostsData).output(zGetPostsResponse); 74 + }).input(vGetPostsData).output(vGetPostsResponse); 75 75 76 76 /** 77 77 * Create a new post ··· 83 83 successStatus: 201, 84 84 summary: 'Create a new post', 85 85 tags: ['posts'] 86 - }).input(zCreatePostData).output(zCreatePostResponse); 86 + }).input(vCreatePostData).output(vCreatePostResponse); 87 87 88 88 /** 89 89 * Get a post by ID ··· 94 94 path: '/posts/{postId}', 95 95 summary: 'Get a post by ID', 96 96 tags: ['posts'] 97 - }).input(zGetPostByIdData).output(zGetPostByIdResponse); 97 + }).input(vGetPostByIdData).output(vGetPostByIdResponse); 98 98 99 - export const router = { 100 - getUsers: getUsersRpc, 101 - createUser: createUserRpc, 102 - deleteUser: deleteUserRpc, 103 - getUserById: getUserByIdRpc, 104 - updateUser: updateUserRpc, 105 - getPosts: getPostsRpc, 106 - createPost: createPostRpc, 107 - getPostById: getPostByIdRpc 99 + export const rpcContract = { 100 + getUsersRpc, 101 + createUserRpc, 102 + deleteUserRpc, 103 + getUserByIdRpc, 104 + updateUserRpc, 105 + getPostsRpc, 106 + createPostRpc, 107 + getPostByIdRpc 108 108 }; 109 - 110 - export type Router = typeof router;
-154
packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.1.x/custom-contract-name/zod.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import * as z from 'zod'; 4 - 5 - export const zUser = z.object({ 6 - id: z.string(), 7 - email: z.email(), 8 - name: z.string(), 9 - createdAt: z.iso.datetime().optional() 10 - }); 11 - 12 - export const zCreateUserInput = z.object({ 13 - email: z.email(), 14 - name: z.string(), 15 - password: z.string().min(8).optional() 16 - }); 17 - 18 - export const zUpdateUserInput = z.object({ 19 - email: z.email().optional(), 20 - name: z.string().optional() 21 - }); 22 - 23 - export const zPost = z.object({ 24 - id: z.string(), 25 - title: z.string(), 26 - content: z.string(), 27 - authorId: z.string(), 28 - status: z.enum([ 29 - 'draft', 30 - 'published', 31 - 'archived' 32 - ]).optional(), 33 - createdAt: z.iso.datetime().optional() 34 - }); 35 - 36 - export const zCreatePostInput = z.object({ 37 - title: z.string(), 38 - content: z.string(), 39 - status: z.enum(['draft', 'published']).optional() 40 - }); 41 - 42 - export const zGetUsersData = z.object({ 43 - body: z.never().optional(), 44 - path: z.never().optional(), 45 - query: z.object({ 46 - limit: z.int().optional().default(10), 47 - offset: z.int().optional().default(0) 48 - }).optional() 49 - }); 50 - 51 - /** 52 - * List of users 53 - */ 54 - export const zGetUsersResponse = z.array(zUser); 55 - 56 - export const zCreateUserData = z.object({ 57 - body: zCreateUserInput, 58 - path: z.never().optional(), 59 - query: z.never().optional() 60 - }); 61 - 62 - /** 63 - * User created 64 - */ 65 - export const zCreateUserResponse = zUser; 66 - 67 - export const zDeleteUserData = z.object({ 68 - body: z.never().optional(), 69 - path: z.object({ 70 - userId: z.string() 71 - }), 72 - query: z.never().optional(), 73 - headers: z.object({ 74 - 'X-Request-Id': z.string().optional() 75 - }).optional() 76 - }); 77 - 78 - /** 79 - * User deleted 80 - */ 81 - export const zDeleteUserResponse = z.void(); 82 - 83 - export const zGetUserByIdData = z.object({ 84 - body: z.never().optional(), 85 - path: z.object({ 86 - userId: z.string() 87 - }), 88 - query: z.never().optional() 89 - }); 90 - 91 - /** 92 - * User found 93 - */ 94 - export const zGetUserByIdResponse = zUser; 95 - 96 - export const zUpdateUserData = z.object({ 97 - body: zUpdateUserInput, 98 - path: z.object({ 99 - userId: z.string() 100 - }), 101 - query: z.never().optional() 102 - }); 103 - 104 - /** 105 - * User updated 106 - */ 107 - export const zUpdateUserResponse = zUser; 108 - 109 - export const zGetPostsData = z.object({ 110 - body: z.never().optional(), 111 - path: z.never().optional(), 112 - query: z.object({ 113 - authorId: z.string().optional(), 114 - status: z.enum([ 115 - 'draft', 116 - 'published', 117 - 'archived' 118 - ]).optional() 119 - }).optional() 120 - }); 121 - 122 - /** 123 - * List of posts 124 - */ 125 - export const zGetPostsResponse = z.array(zPost); 126 - 127 - export const zCreatePostData = z.object({ 128 - body: zCreatePostInput, 129 - path: z.never().optional(), 130 - query: z.never().optional(), 131 - headers: z.object({ 132 - 'X-Author-Id': z.string() 133 - }) 134 - }); 135 - 136 - /** 137 - * Post created 138 - */ 139 - export const zCreatePostResponse = zPost; 140 - 141 - export const zGetPostByIdData = z.object({ 142 - body: z.never().optional(), 143 - path: z.object({ 144 - postId: z.string() 145 - }), 146 - query: z.object({ 147 - includeComments: z.boolean().optional().default(false) 148 - }).optional() 149 - }); 150 - 151 - /** 152 - * Post found 153 - */ 154 - export const zGetPostByIdResponse = zPost;
+1 -3
packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.1.x/custom-router-name/@orpc/contract.gen.ts packages/openapi-ts-tests/orpc/v1/__snapshots__/3.1.x/default/orpc.gen.ts
··· 2 2 3 3 import { oc } from '@orpc/contract'; 4 4 5 - import { zCreatePostData, zCreatePostResponse, zCreateUserData, zCreateUserResponse, zDeleteUserData, zGetPostByIdData, zGetPostByIdResponse, zGetPostsData, zGetPostsResponse, zGetUserByIdData, zGetUserByIdResponse, zGetUsersData, zGetUsersResponse, zUpdateUserData, zUpdateUserResponse } from '../zod.gen'; 5 + import { zCreatePostData, zCreatePostResponse, zCreateUserData, zCreateUserResponse, zDeleteUserData, zGetPostByIdData, zGetPostByIdResponse, zGetPostsData, zGetPostsResponse, zGetUserByIdData, zGetUserByIdResponse, zGetUsersData, zGetUsersResponse, zUpdateUserData, zUpdateUserResponse } from './zod.gen'; 6 6 7 7 export const base = oc.$route({ inputStructure: 'detailed' }); 8 8 ··· 106 106 createPost, 107 107 getPostById 108 108 }; 109 - 110 - export type Contract = typeof contract;
-154
packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.1.x/custom-router-name/zod.gen.ts
··· 1 - // This file is auto-generated by @hey-api/openapi-ts 2 - 3 - import * as z from 'zod'; 4 - 5 - export const zUser = z.object({ 6 - id: z.string(), 7 - email: z.email(), 8 - name: z.string(), 9 - createdAt: z.iso.datetime().optional() 10 - }); 11 - 12 - export const zCreateUserInput = z.object({ 13 - email: z.email(), 14 - name: z.string(), 15 - password: z.string().min(8).optional() 16 - }); 17 - 18 - export const zUpdateUserInput = z.object({ 19 - email: z.email().optional(), 20 - name: z.string().optional() 21 - }); 22 - 23 - export const zPost = z.object({ 24 - id: z.string(), 25 - title: z.string(), 26 - content: z.string(), 27 - authorId: z.string(), 28 - status: z.enum([ 29 - 'draft', 30 - 'published', 31 - 'archived' 32 - ]).optional(), 33 - createdAt: z.iso.datetime().optional() 34 - }); 35 - 36 - export const zCreatePostInput = z.object({ 37 - title: z.string(), 38 - content: z.string(), 39 - status: z.enum(['draft', 'published']).optional() 40 - }); 41 - 42 - export const zGetUsersData = z.object({ 43 - body: z.never().optional(), 44 - path: z.never().optional(), 45 - query: z.object({ 46 - limit: z.int().optional().default(10), 47 - offset: z.int().optional().default(0) 48 - }).optional() 49 - }); 50 - 51 - /** 52 - * List of users 53 - */ 54 - export const zGetUsersResponse = z.array(zUser); 55 - 56 - export const zCreateUserData = z.object({ 57 - body: zCreateUserInput, 58 - path: z.never().optional(), 59 - query: z.never().optional() 60 - }); 61 - 62 - /** 63 - * User created 64 - */ 65 - export const zCreateUserResponse = zUser; 66 - 67 - export const zDeleteUserData = z.object({ 68 - body: z.never().optional(), 69 - path: z.object({ 70 - userId: z.string() 71 - }), 72 - query: z.never().optional(), 73 - headers: z.object({ 74 - 'X-Request-Id': z.string().optional() 75 - }).optional() 76 - }); 77 - 78 - /** 79 - * User deleted 80 - */ 81 - export const zDeleteUserResponse = z.void(); 82 - 83 - export const zGetUserByIdData = z.object({ 84 - body: z.never().optional(), 85 - path: z.object({ 86 - userId: z.string() 87 - }), 88 - query: z.never().optional() 89 - }); 90 - 91 - /** 92 - * User found 93 - */ 94 - export const zGetUserByIdResponse = zUser; 95 - 96 - export const zUpdateUserData = z.object({ 97 - body: zUpdateUserInput, 98 - path: z.object({ 99 - userId: z.string() 100 - }), 101 - query: z.never().optional() 102 - }); 103 - 104 - /** 105 - * User updated 106 - */ 107 - export const zUpdateUserResponse = zUser; 108 - 109 - export const zGetPostsData = z.object({ 110 - body: z.never().optional(), 111 - path: z.never().optional(), 112 - query: z.object({ 113 - authorId: z.string().optional(), 114 - status: z.enum([ 115 - 'draft', 116 - 'published', 117 - 'archived' 118 - ]).optional() 119 - }).optional() 120 - }); 121 - 122 - /** 123 - * List of posts 124 - */ 125 - export const zGetPostsResponse = z.array(zPost); 126 - 127 - export const zCreatePostData = z.object({ 128 - body: zCreatePostInput, 129 - path: z.never().optional(), 130 - query: z.never().optional(), 131 - headers: z.object({ 132 - 'X-Author-Id': z.string() 133 - }) 134 - }); 135 - 136 - /** 137 - * Post created 138 - */ 139 - export const zCreatePostResponse = zPost; 140 - 141 - export const zGetPostByIdData = z.object({ 142 - body: z.never().optional(), 143 - path: z.object({ 144 - postId: z.string() 145 - }), 146 - query: z.object({ 147 - includeComments: z.boolean().optional().default(false) 148 - }).optional() 149 - }); 150 - 151 - /** 152 - * Post found 153 - */ 154 - export const zGetPostByIdResponse = zPost;
+2 -4
packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.1.x/default/@orpc/contract.gen.ts packages/openapi-ts-tests/orpc/v1/__snapshots__/3.1.x/contracts-strategy-single/orpc.gen.ts
··· 2 2 3 3 import { oc } from '@orpc/contract'; 4 4 5 - import { zCreatePostData, zCreatePostResponse, zCreateUserData, zCreateUserResponse, zDeleteUserData, zGetPostByIdData, zGetPostByIdResponse, zGetPostsData, zGetPostsResponse, zGetUserByIdData, zGetUserByIdResponse, zGetUsersData, zGetUsersResponse, zUpdateUserData, zUpdateUserResponse } from '../zod.gen'; 5 + import { zCreatePostData, zCreatePostResponse, zCreateUserData, zCreateUserResponse, zDeleteUserData, zGetPostByIdData, zGetPostByIdResponse, zGetPostsData, zGetPostsResponse, zGetUserByIdData, zGetUserByIdResponse, zGetUsersData, zGetUsersResponse, zUpdateUserData, zUpdateUserResponse } from './zod.gen'; 6 6 7 7 export const base = oc.$route({ inputStructure: 'detailed' }); 8 8 ··· 96 96 tags: ['posts'] 97 97 }).input(zGetPostByIdData).output(zGetPostByIdResponse); 98 98 99 - export const router = { 99 + export const api = { 100 100 getUsers, 101 101 createUser, 102 102 deleteUser, ··· 106 106 createPost, 107 107 getPostById 108 108 }; 109 - 110 - export type Router = typeof router;
packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.1.x/default/zod.gen.ts packages/openapi-ts-tests/orpc/v1/__snapshots__/3.1.x/default/zod.gen.ts
+1 -1
packages/openapi-ts-tests/@orpc/contract/v1/package.json packages/openapi-ts-tests/orpc/v1/package.json
··· 1 1 { 2 - "name": "@test/openapi-ts-orpc-contract-v1", 2 + "name": "@test/openapi-ts-orpc-v1", 3 3 "version": "0.0.0", 4 4 "private": true, 5 5 "type": "module",
-73
packages/openapi-ts-tests/@orpc/contract/v1/test/3.0.x.test.ts
··· 1 - import fs from 'node:fs'; 2 - import path from 'node:path'; 3 - 4 - import { createClient } from '@hey-api/openapi-ts'; 5 - 6 - import { getFilePaths } from '../../../../utils'; 7 - import { snapshotsDir, tmpDir } from './constants'; 8 - import { createOrpcContractConfig } from './utils'; 9 - 10 - const version = '3.0.x'; 11 - 12 - const outputDir = path.join(tmpDir, version); 13 - 14 - describe(`OpenAPI ${version}`, () => { 15 - const createConfig = createOrpcContractConfig({ openApiVersion: version, outputDir }); 16 - 17 - const scenarios = [ 18 - { 19 - config: createConfig({ 20 - input: 'orpc-contract.yaml', 21 - output: 'default', 22 - plugins: ['@orpc/contract', 'zod'], 23 - }), 24 - description: 'generate oRPC contracts with Zod schemas', 25 - }, 26 - { 27 - config: createConfig({ 28 - input: 'orpc-contract.yaml', 29 - output: 'custom-contract-name', 30 - plugins: [ 31 - 'zod', 32 - { 33 - contracts: { 34 - contractName: '{{name}}Rpc', 35 - }, 36 - name: '@orpc/contract', 37 - }, 38 - ], 39 - }), 40 - description: 'generate oRPC contracts with custom contract name builder', 41 - }, 42 - { 43 - config: createConfig({ 44 - input: 'orpc-contract.yaml', 45 - output: 'custom-router-name', 46 - plugins: [ 47 - 'zod', 48 - { 49 - name: '@orpc/contract', 50 - routerName: 'contract', 51 - }, 52 - ], 53 - }), 54 - description: 'generate oRPC contracts with custom router name', 55 - }, 56 - ]; 57 - 58 - it.each(scenarios)('$description', async ({ config }) => { 59 - await createClient(config); 60 - 61 - const outputString = config.output as string; 62 - const filePaths = getFilePaths(outputString); 63 - 64 - await Promise.all( 65 - filePaths.map(async (filePath) => { 66 - const fileContent = fs.readFileSync(filePath, 'utf-8'); 67 - await expect(fileContent).toMatchFileSnapshot( 68 - path.join(snapshotsDir, version, filePath.slice(outputDir.length + 1)), 69 - ); 70 - }), 71 - ); 72 - }); 73 - });
+19 -32
packages/openapi-ts-tests/@orpc/contract/v1/test/3.1.x.test.ts packages/openapi-ts-tests/orpc/v1/test/3.1.x.test.ts
··· 3 3 4 4 import { createClient } from '@hey-api/openapi-ts'; 5 5 6 - import { getFilePaths } from '../../../../utils'; 6 + import { getFilePaths } from '../../../utils'; 7 7 import { snapshotsDir, tmpDir } from './constants'; 8 - import { createOrpcContractConfig } from './utils'; 8 + import { createOrpcConfig } from './utils'; 9 9 10 10 const version = '3.1.x'; 11 11 12 12 const outputDir = path.join(tmpDir, version); 13 13 14 14 describe(`OpenAPI ${version}`, () => { 15 - const createConfig = createOrpcContractConfig({ openApiVersion: version, outputDir }); 15 + const createConfig = createOrpcConfig({ openApiVersion: version, outputDir }); 16 16 17 17 const scenarios = [ 18 18 { 19 19 config: createConfig({ 20 - input: 'orpc-contract.yaml', 20 + input: 'orpc.yaml', 21 21 output: 'default', 22 - plugins: ['@orpc/contract', 'zod'], 22 + plugins: ['orpc', 'zod'], 23 23 }), 24 24 description: 'generate oRPC contracts with Zod schemas', 25 25 }, 26 26 { 27 27 config: createConfig({ 28 - input: 'orpc-contract.yaml', 29 - output: 'custom-contract-name', 28 + input: 'orpc.yaml', 29 + output: 'custom-names', 30 30 plugins: [ 31 - 'zod', 31 + 'valibot', 32 32 { 33 33 contracts: { 34 + containerName: 'rpcContract', 34 35 contractName: '{{name}}Rpc', 35 36 }, 36 - name: '@orpc/contract', 37 + name: 'orpc', 37 38 }, 38 39 ], 39 40 }), 40 - description: 'generate oRPC contracts with custom contract name builder', 41 + description: 'generate oRPC contracts with custom names and Valibot schemas', 41 42 }, 42 43 { 43 44 config: createConfig({ 44 - input: 'orpc-contract.yaml', 45 - output: 'custom-router-name', 46 - plugins: [ 47 - 'zod', 48 - { 49 - name: '@orpc/contract', 50 - routerName: 'contract', 51 - }, 52 - ], 53 - }), 54 - description: 'generate oRPC contracts with custom router name', 55 - }, 56 - { 57 - config: createConfig({ 58 - input: 'orpc-contract.yaml', 45 + input: 'orpc.yaml', 59 46 output: 'contracts-strategy-by-tags', 60 47 plugins: [ 61 48 'zod', ··· 63 50 contracts: { 64 51 strategy: 'byTags', 65 52 }, 66 - name: '@orpc/contract', 53 + name: 'orpc', 67 54 }, 68 55 ], 69 56 }), ··· 71 58 }, 72 59 { 73 60 config: createConfig({ 74 - input: 'orpc-contract.yaml', 61 + input: 'orpc.yaml', 75 62 output: 'contracts-strategy-single', 76 63 plugins: [ 77 64 'zod', ··· 80 67 containerName: 'api', 81 68 strategy: 'single', 82 69 }, 83 - name: '@orpc/contract', 70 + name: 'orpc', 84 71 }, 85 72 ], 86 73 }), ··· 88 75 }, 89 76 { 90 77 config: createConfig({ 91 - input: 'orpc-contract.yaml', 78 + input: 'orpc.yaml', 92 79 output: 'contracts-nesting-id', 93 80 plugins: [ 94 81 'zod', ··· 97 84 nesting: 'id', 98 85 strategy: 'byTags', 99 86 }, 100 - name: '@orpc/contract', 87 + name: 'orpc', 101 88 }, 102 89 ], 103 90 }), ··· 105 92 }, 106 93 { 107 94 config: createConfig({ 108 - input: 'orpc-contract.yaml', 95 + input: 'orpc.yaml', 109 96 output: 'contracts-custom-naming', 110 97 plugins: [ 111 98 'zod', ··· 116 103 segmentName: { casing: 'PascalCase' }, 117 104 strategy: 'byTags', 118 105 }, 119 - name: '@orpc/contract', 106 + name: 'orpc', 120 107 }, 121 108 ], 122 109 }),
packages/openapi-ts-tests/@orpc/contract/v1/test/constants.ts packages/openapi-ts-tests/orpc/v1/test/constants.ts
packages/openapi-ts-tests/@orpc/contract/v1/test/globalTeardown.ts packages/openapi-ts-tests/orpc/v1/test/globalTeardown.ts
+3 -3
packages/openapi-ts-tests/@orpc/contract/v1/test/utils.ts packages/openapi-ts-tests/orpc/v1/test/utils.ts
··· 2 2 3 3 import type { UserConfig } from '@hey-api/openapi-ts'; 4 4 5 - import { getSpecsPath } from '../../../../utils'; 5 + import { getSpecsPath } from '../../../utils'; 6 6 7 - export const createOrpcContractConfig = 7 + export const createOrpcConfig = 8 8 ({ openApiVersion, outputDir }: { openApiVersion: string; outputDir: string }) => 9 9 (userConfig: UserConfig) => { 10 10 const input = userConfig.input instanceof Array ? userConfig.input[0]! : userConfig.input; ··· 16 16 const output = userConfig.output instanceof Array ? userConfig.output[0]! : userConfig.output; 17 17 const outputPath = typeof output === 'string' ? output : (output?.path ?? ''); 18 18 return { 19 - plugins: ['@orpc/contract'], 19 + plugins: ['orpc'], 20 20 ...userConfig, 21 21 input: 22 22 typeof userConfig.input === 'string'
-6
packages/openapi-ts-tests/@orpc/contract/v1/tsconfig.json
··· 1 - { 2 - "extends": "../../../tsconfig.base.json", 3 - "include": ["test/**/*", "__snapshots__/**/*"], 4 - "exclude": [".gen/**/*"], 5 - "references": [{ "path": "../../../../openapi-ts" }] 6 - }
+1 -1
packages/openapi-ts-tests/@orpc/contract/v1/turbo.json packages/openapi-ts-tests/orpc/v1/turbo.json
··· 1 1 { 2 - "$schema": "../../../../../node_modules/turbo/schema.json", 2 + "$schema": "../../../../node_modules/turbo/schema.json", 3 3 "extends": ["//"], 4 4 "tasks": { 5 5 "build": {
packages/openapi-ts-tests/@orpc/contract/v1/vitest.setup.ts packages/openapi-ts-tests/orpc/v1/vitest.setup.ts
+154
packages/openapi-ts-tests/orpc/v1/__snapshots__/3.0.x/custom-names/valibot.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as v from 'valibot'; 4 + 5 + export const vUser = v.object({ 6 + id: v.string(), 7 + email: v.pipe(v.string(), v.email()), 8 + name: v.string(), 9 + createdAt: v.optional(v.pipe(v.string(), v.isoTimestamp())) 10 + }); 11 + 12 + export const vCreateUserInput = v.object({ 13 + email: v.pipe(v.string(), v.email()), 14 + name: v.string(), 15 + password: v.optional(v.pipe(v.string(), v.minLength(8))) 16 + }); 17 + 18 + export const vUpdateUserInput = v.object({ 19 + email: v.optional(v.pipe(v.string(), v.email())), 20 + name: v.optional(v.string()) 21 + }); 22 + 23 + export const vPost = v.object({ 24 + id: v.string(), 25 + title: v.string(), 26 + content: v.string(), 27 + authorId: v.string(), 28 + status: v.optional(v.picklist([ 29 + 'draft', 30 + 'published', 31 + 'archived' 32 + ])), 33 + createdAt: v.optional(v.pipe(v.string(), v.isoTimestamp())) 34 + }); 35 + 36 + export const vCreatePostInput = v.object({ 37 + title: v.string(), 38 + content: v.string(), 39 + status: v.optional(v.picklist(['draft', 'published'])) 40 + }); 41 + 42 + export const vGetUsersData = v.object({ 43 + body: v.optional(v.never()), 44 + path: v.optional(v.never()), 45 + query: v.optional(v.object({ 46 + limit: v.optional(v.pipe(v.number(), v.integer()), 10), 47 + offset: v.optional(v.pipe(v.number(), v.integer()), 0) 48 + })) 49 + }); 50 + 51 + /** 52 + * List of users 53 + */ 54 + export const vGetUsersResponse = v.array(vUser); 55 + 56 + export const vCreateUserData = v.object({ 57 + body: vCreateUserInput, 58 + path: v.optional(v.never()), 59 + query: v.optional(v.never()) 60 + }); 61 + 62 + /** 63 + * User created 64 + */ 65 + export const vCreateUserResponse = vUser; 66 + 67 + export const vDeleteUserData = v.object({ 68 + body: v.optional(v.never()), 69 + path: v.object({ 70 + userId: v.string() 71 + }), 72 + query: v.optional(v.never()), 73 + headers: v.optional(v.object({ 74 + 'X-Request-Id': v.optional(v.string()) 75 + })) 76 + }); 77 + 78 + /** 79 + * User deleted 80 + */ 81 + export const vDeleteUserResponse = v.void(); 82 + 83 + export const vGetUserByIdData = v.object({ 84 + body: v.optional(v.never()), 85 + path: v.object({ 86 + userId: v.string() 87 + }), 88 + query: v.optional(v.never()) 89 + }); 90 + 91 + /** 92 + * User found 93 + */ 94 + export const vGetUserByIdResponse = vUser; 95 + 96 + export const vUpdateUserData = v.object({ 97 + body: vUpdateUserInput, 98 + path: v.object({ 99 + userId: v.string() 100 + }), 101 + query: v.optional(v.never()) 102 + }); 103 + 104 + /** 105 + * User updated 106 + */ 107 + export const vUpdateUserResponse = vUser; 108 + 109 + export const vGetPostsData = v.object({ 110 + body: v.optional(v.never()), 111 + path: v.optional(v.never()), 112 + query: v.optional(v.object({ 113 + authorId: v.optional(v.string()), 114 + status: v.optional(v.picklist([ 115 + 'draft', 116 + 'published', 117 + 'archived' 118 + ])) 119 + })) 120 + }); 121 + 122 + /** 123 + * List of posts 124 + */ 125 + export const vGetPostsResponse = v.array(vPost); 126 + 127 + export const vCreatePostData = v.object({ 128 + body: vCreatePostInput, 129 + path: v.optional(v.never()), 130 + query: v.optional(v.never()), 131 + headers: v.object({ 132 + 'X-Author-Id': v.string() 133 + }) 134 + }); 135 + 136 + /** 137 + * Post created 138 + */ 139 + export const vCreatePostResponse = vPost; 140 + 141 + export const vGetPostByIdData = v.object({ 142 + body: v.optional(v.never()), 143 + path: v.object({ 144 + postId: v.string() 145 + }), 146 + query: v.optional(v.object({ 147 + includeComments: v.optional(v.boolean(), false) 148 + })) 149 + }); 150 + 151 + /** 152 + * Post found 153 + */ 154 + export const vGetPostByIdResponse = vPost;
+154
packages/openapi-ts-tests/orpc/v1/__snapshots__/3.1.x/custom-names/valibot.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as v from 'valibot'; 4 + 5 + export const vUser = v.object({ 6 + id: v.string(), 7 + email: v.pipe(v.string(), v.email()), 8 + name: v.string(), 9 + createdAt: v.optional(v.pipe(v.string(), v.isoTimestamp())) 10 + }); 11 + 12 + export const vCreateUserInput = v.object({ 13 + email: v.pipe(v.string(), v.email()), 14 + name: v.string(), 15 + password: v.optional(v.pipe(v.string(), v.minLength(8))) 16 + }); 17 + 18 + export const vUpdateUserInput = v.object({ 19 + email: v.optional(v.pipe(v.string(), v.email())), 20 + name: v.optional(v.string()) 21 + }); 22 + 23 + export const vPost = v.object({ 24 + id: v.string(), 25 + title: v.string(), 26 + content: v.string(), 27 + authorId: v.string(), 28 + status: v.optional(v.picklist([ 29 + 'draft', 30 + 'published', 31 + 'archived' 32 + ])), 33 + createdAt: v.optional(v.pipe(v.string(), v.isoTimestamp())) 34 + }); 35 + 36 + export const vCreatePostInput = v.object({ 37 + title: v.string(), 38 + content: v.string(), 39 + status: v.optional(v.picklist(['draft', 'published'])) 40 + }); 41 + 42 + export const vGetUsersData = v.object({ 43 + body: v.optional(v.never()), 44 + path: v.optional(v.never()), 45 + query: v.optional(v.object({ 46 + limit: v.optional(v.pipe(v.number(), v.integer()), 10), 47 + offset: v.optional(v.pipe(v.number(), v.integer()), 0) 48 + })) 49 + }); 50 + 51 + /** 52 + * List of users 53 + */ 54 + export const vGetUsersResponse = v.array(vUser); 55 + 56 + export const vCreateUserData = v.object({ 57 + body: vCreateUserInput, 58 + path: v.optional(v.never()), 59 + query: v.optional(v.never()) 60 + }); 61 + 62 + /** 63 + * User created 64 + */ 65 + export const vCreateUserResponse = vUser; 66 + 67 + export const vDeleteUserData = v.object({ 68 + body: v.optional(v.never()), 69 + path: v.object({ 70 + userId: v.string() 71 + }), 72 + query: v.optional(v.never()), 73 + headers: v.optional(v.object({ 74 + 'X-Request-Id': v.optional(v.string()) 75 + })) 76 + }); 77 + 78 + /** 79 + * User deleted 80 + */ 81 + export const vDeleteUserResponse = v.void(); 82 + 83 + export const vGetUserByIdData = v.object({ 84 + body: v.optional(v.never()), 85 + path: v.object({ 86 + userId: v.string() 87 + }), 88 + query: v.optional(v.never()) 89 + }); 90 + 91 + /** 92 + * User found 93 + */ 94 + export const vGetUserByIdResponse = vUser; 95 + 96 + export const vUpdateUserData = v.object({ 97 + body: vUpdateUserInput, 98 + path: v.object({ 99 + userId: v.string() 100 + }), 101 + query: v.optional(v.never()) 102 + }); 103 + 104 + /** 105 + * User updated 106 + */ 107 + export const vUpdateUserResponse = vUser; 108 + 109 + export const vGetPostsData = v.object({ 110 + body: v.optional(v.never()), 111 + path: v.optional(v.never()), 112 + query: v.optional(v.object({ 113 + authorId: v.optional(v.string()), 114 + status: v.optional(v.picklist([ 115 + 'draft', 116 + 'published', 117 + 'archived' 118 + ])) 119 + })) 120 + }); 121 + 122 + /** 123 + * List of posts 124 + */ 125 + export const vGetPostsResponse = v.array(vPost); 126 + 127 + export const vCreatePostData = v.object({ 128 + body: vCreatePostInput, 129 + path: v.optional(v.never()), 130 + query: v.optional(v.never()), 131 + headers: v.object({ 132 + 'X-Author-Id': v.string() 133 + }) 134 + }); 135 + 136 + /** 137 + * Post created 138 + */ 139 + export const vCreatePostResponse = vPost; 140 + 141 + export const vGetPostByIdData = v.object({ 142 + body: v.optional(v.never()), 143 + path: v.object({ 144 + postId: v.string() 145 + }), 146 + query: v.optional(v.object({ 147 + includeComments: v.optional(v.boolean(), false) 148 + })) 149 + }); 150 + 151 + /** 152 + * Post found 153 + */ 154 + export const vGetPostByIdResponse = vPost;
+60
packages/openapi-ts-tests/orpc/v1/test/3.0.x.test.ts
··· 1 + import fs from 'node:fs'; 2 + import path from 'node:path'; 3 + 4 + import { createClient } from '@hey-api/openapi-ts'; 5 + 6 + import { getFilePaths } from '../../../utils'; 7 + import { snapshotsDir, tmpDir } from './constants'; 8 + import { createOrpcConfig } from './utils'; 9 + 10 + const version = '3.0.x'; 11 + 12 + const outputDir = path.join(tmpDir, version); 13 + 14 + describe(`OpenAPI ${version}`, () => { 15 + const createConfig = createOrpcConfig({ openApiVersion: version, outputDir }); 16 + 17 + const scenarios = [ 18 + { 19 + config: createConfig({ 20 + input: 'orpc.yaml', 21 + output: 'default', 22 + plugins: ['orpc', 'zod'], 23 + }), 24 + description: 'generate oRPC contracts with Zod schemas', 25 + }, 26 + { 27 + config: createConfig({ 28 + input: 'orpc.yaml', 29 + output: 'custom-names', 30 + plugins: [ 31 + 'valibot', 32 + { 33 + contracts: { 34 + containerName: 'rpcContract', 35 + contractName: '{{name}}Rpc', 36 + }, 37 + name: 'orpc', 38 + }, 39 + ], 40 + }), 41 + description: 'generate oRPC contracts with custom names and Valibot schemas', 42 + }, 43 + ]; 44 + 45 + it.each(scenarios)('$description', async ({ config }) => { 46 + await createClient(config); 47 + 48 + const outputString = config.output as string; 49 + const filePaths = getFilePaths(outputString); 50 + 51 + await Promise.all( 52 + filePaths.map(async (filePath) => { 53 + const fileContent = fs.readFileSync(filePath, 'utf-8'); 54 + await expect(fileContent).toMatchFileSnapshot( 55 + path.join(snapshotsDir, version, filePath.slice(outputDir.length + 1)), 56 + ); 57 + }), 58 + ); 59 + }); 60 + });
+5
packages/openapi-ts-tests/orpc/v1/tsconfig.json
··· 1 + { 2 + "extends": "../../tsconfig.base.json", 3 + "include": ["test/**/*", "__snapshots__/**/*"], 4 + "references": [{ "path": "../../../openapi-ts" }] 5 + }
+4 -4
packages/openapi-ts/src/index.ts
··· 71 71 '@hey-api/sdk': Plugins.HeyApiSdk.Types['Types']; 72 72 '@hey-api/transformers': Plugins.HeyApiTransformers.Types['Types']; 73 73 '@hey-api/typescript': Plugins.HeyApiTypeScript.Types['Types']; 74 - '@orpc/contract': Plugins.OrpcContract.Types['Types']; 75 74 '@pinia/colada': Plugins.PiniaColada.Types['Types']; 76 75 '@tanstack/angular-query-experimental': Plugins.TanStackAngularQuery.Types['Types']; 77 76 '@tanstack/preact-query': Plugins.TanStackPreactQuery.Types['Types']; ··· 82 81 arktype: Plugins.Arktype.Types['Types']; 83 82 fastify: Plugins.Fastify.Types['Types']; 84 83 nestjs: Plugins.NestJs.Types['Types']; 84 + orpc: Plugins.Orpc.Types['Types']; 85 85 swr: Plugins.Swr.Types['Types']; 86 86 valibot: Plugins.Valibot.Types['Types']; 87 87 zod: Plugins.Zod.Types['Types']; ··· 133 133 HeyApiTypeScriptPlugin, 134 134 HeyApiTypeScriptResolvers, 135 135 } from './plugins/@hey-api/typescript'; 136 - import type { OrpcContractPlugin } from './plugins/@orpc/contract'; 137 136 import type { PiniaColadaPlugin } from './plugins/@pinia/colada'; 138 137 import type { TanStackAngularQueryPlugin } from './plugins/@tanstack/angular-query-experimental'; 139 138 import type { TanStackPreactQueryPlugin } from './plugins/@tanstack/preact-query'; ··· 144 143 import type { ArktypePlugin } from './plugins/arktype'; 145 144 import type { FastifyPlugin } from './plugins/fastify'; 146 145 import type { NestJsPlugin } from './plugins/nestjs'; 146 + import type { OrpcPlugin } from './plugins/orpc'; 147 147 import type { SwrPlugin } from './plugins/swr'; 148 148 import type { ValibotPlugin, ValibotResolvers } from './plugins/valibot'; 149 149 import type { ZodPlugin, ZodResolvers } from './plugins/zod'; ··· 268 268 export type Types = NestJsPlugin; 269 269 } 270 270 271 - export namespace OrpcContract { 272 - export type Types = OrpcContractPlugin; 271 + export namespace Orpc { 272 + export type Types = OrpcPlugin; 273 273 } 274 274 275 275 export namespace PiniaColada {
+3 -3
packages/openapi-ts/src/plugins/@orpc/contract/config.ts packages/openapi-ts/src/plugins/orpc/config.ts
··· 3 3 4 4 import { resolveContracts } from './contracts/config'; 5 5 import { handler } from './plugin'; 6 - import type { OrpcContractPlugin } from './types'; 6 + import type { OrpcPlugin } from './types'; 7 7 8 8 const validatorInferWarn = 9 9 'You set `validator: true` but no validator plugin was found in your plugins. Add a validator plugin like `zod` to enable this feature. The validator option has been disabled.'; 10 10 11 - export const defaultConfig: OrpcContractPlugin['Config'] = { 11 + export const defaultConfig: OrpcPlugin['Config'] = { 12 12 config: { 13 13 includeInEntry: false, 14 14 }, 15 15 handler, 16 - name: '@orpc/contract', 16 + name: 'orpc', 17 17 resolveConfig: (plugin, context) => { 18 18 if (typeof plugin.config.validator !== 'object') { 19 19 plugin.config.validator = {
+1 -1
packages/openapi-ts/src/plugins/@orpc/contract/contracts/config.ts packages/openapi-ts/src/plugins/orpc/contracts/config.ts
··· 14 14 input = { strategy: input }; 15 15 } 16 16 17 - const strategy = input.strategy ?? 'flat'; 17 + const strategy = input.strategy ?? 'single'; 18 18 19 19 return context.valueToObject({ 20 20 defaultValue: {
packages/openapi-ts/src/plugins/@orpc/contract/contracts/index.ts packages/openapi-ts/src/plugins/orpc/contracts/index.ts
+9 -9
packages/openapi-ts/src/plugins/@orpc/contract/contracts/node.ts packages/openapi-ts/src/plugins/orpc/contracts/node.ts
··· 2 2 import type { IR } from '@hey-api/shared'; 3 3 import { applyNaming } from '@hey-api/shared'; 4 4 5 - import { $ } from '../../../../ts-dsl'; 6 - import { createOperationComment } from '../../../shared/utils/operation'; 5 + import { $ } from '../../../ts-dsl'; 6 + import { createOperationComment } from '../../shared/utils/operation'; 7 7 import { getSuccessResponse, getTags, hasInput } from '../shared/operation'; 8 - import type { OrpcContractPlugin } from '../types'; 8 + import type { OrpcPlugin } from '../types'; 9 9 10 10 export interface ContractItem { 11 11 operation: IR.OperationObject; ··· 13 13 tags: ReadonlyArray<string> | undefined; 14 14 } 15 15 16 - export const source = globalThis.Symbol('@orpc/contract'); 16 + export const source = globalThis.Symbol('orpc'); 17 17 18 18 function createContractSymbol( 19 - plugin: OrpcContractPlugin['Instance'], 19 + plugin: OrpcPlugin['Instance'], 20 20 item: StructureItem & { data: ContractItem }, 21 21 ): Symbol { 22 22 const { operation, path, tags } = item.data; ··· 35 35 } 36 36 37 37 function createContractExpression( 38 - plugin: OrpcContractPlugin['Instance'], 38 + plugin: OrpcPlugin['Instance'], 39 39 operation: IR.OperationObject, 40 40 baseSymbol: Symbol, 41 41 ) { ··· 90 90 91 91 function buildContainerObject( 92 92 node: StructureNode, 93 - plugin: OrpcContractPlugin['Instance'], 93 + plugin: OrpcPlugin['Instance'], 94 94 symbols: Map<string, Symbol>, 95 95 ): ReturnType<typeof $.object> { 96 96 const obj = $.object(); ··· 117 117 return obj; 118 118 } 119 119 120 - export function createShell(plugin: OrpcContractPlugin['Instance']): StructureShell { 120 + export function createShell(plugin: OrpcPlugin['Instance']): StructureShell { 121 121 return { 122 122 define: (node) => { 123 123 const symbol = plugin.symbol( ··· 144 144 145 145 export function toNode( 146 146 model: StructureNode, 147 - plugin: OrpcContractPlugin['Instance'], 147 + plugin: OrpcPlugin['Instance'], 148 148 baseSymbol: Symbol, 149 149 ): { 150 150 nodes: ReadonlyArray<ReturnType<typeof $.const>>;
+3 -5
packages/openapi-ts/src/plugins/@orpc/contract/contracts/resolve.ts packages/openapi-ts/src/plugins/orpc/contracts/resolve.ts
··· 1 1 import type { OperationPathStrategy, OperationStructureStrategy } from '@hey-api/shared'; 2 2 import { OperationPath, OperationStrategy } from '@hey-api/shared'; 3 3 4 - import type { OrpcContractPlugin } from '../types'; 4 + import type { OrpcPlugin } from '../types'; 5 5 6 - function resolvePath(plugin: OrpcContractPlugin['Instance']): OperationPathStrategy { 6 + function resolvePath(plugin: OrpcPlugin['Instance']): OperationPathStrategy { 7 7 if (plugin.config.contracts.nesting === 'id') { 8 8 return OperationPath.id(); 9 9 } ··· 18 18 return plugin.config.contracts.nesting; 19 19 } 20 20 21 - export function resolveStrategy( 22 - plugin: OrpcContractPlugin['Instance'], 23 - ): OperationStructureStrategy { 21 + export function resolveStrategy(plugin: OrpcPlugin['Instance']): OperationStructureStrategy { 24 22 if (plugin.config.contracts.strategy === 'flat') { 25 23 return OperationStrategy.flat({ 26 24 path: (operation) => [resolvePath(plugin)(operation).join('.')],
+1 -1
packages/openapi-ts/src/plugins/@orpc/contract/contracts/types.ts packages/openapi-ts/src/plugins/orpc/contracts/types.ts
··· 75 75 * - `'single'` - All contracts in one container 76 76 * - Custom function for full control 77 77 * 78 - * @default 'flat' 78 + * @default 'single' 79 79 */ 80 80 strategy?: OperationsStrategy; 81 81 /**
-2
packages/openapi-ts/src/plugins/@orpc/contract/index.ts
··· 1 - export { defaultConfig, defineConfig } from './config'; 2 - export type { OrpcContractPlugin } from './types';
-4
packages/openapi-ts/src/plugins/@orpc/contract/plugin.ts
··· 1 - import type { OrpcContractPlugin } from './types'; 2 - import { handlerV1 } from './v1/plugin'; 3 - 4 - export const handler: OrpcContractPlugin['Handler'] = (args) => handlerV1(args);
packages/openapi-ts/src/plugins/@orpc/contract/shared/operation.ts packages/openapi-ts/src/plugins/orpc/shared/operation.ts
+5 -5
packages/openapi-ts/src/plugins/@orpc/contract/types.d.ts packages/openapi-ts/src/plugins/orpc/types.ts
··· 1 1 import type { DefinePlugin, OperationsStrategy, Plugin } from '@hey-api/shared'; 2 2 3 - import type { PluginValidatorNames } from '../../types'; 3 + import type { PluginValidatorNames } from '../types'; 4 4 import type { ContractsConfig, UserContractsConfig } from './contracts/types'; 5 5 6 - export type UserConfig = Plugin.Name<'@orpc/contract'> & 6 + export type UserConfig = Plugin.Name<'orpc'> & 7 7 Plugin.Hooks & 8 8 Plugin.UserExports & { 9 9 /** ··· 17 17 * 18 18 * Use the object form for advanced configuration. 19 19 * 20 - * @default 'flat' 20 + * @default 'single' 21 21 */ 22 22 contracts?: OperationsStrategy | UserContractsConfig; 23 23 /** ··· 50 50 }; 51 51 }; 52 52 53 - export type Config = Plugin.Name<'@orpc/contract'> & 53 + export type Config = Plugin.Name<'orpc'> & 54 54 Plugin.Hooks & 55 55 Plugin.Exports & { 56 56 /** Define the structure of generated oRPC contracts. */ ··· 64 64 }; 65 65 }; 66 66 67 - export type OrpcContractPlugin = DefinePlugin<UserConfig, Config>; 67 + export type OrpcPlugin = DefinePlugin<UserConfig, Config>;
+3 -3
packages/openapi-ts/src/plugins/@orpc/contract/v1/plugin.ts packages/openapi-ts/src/plugins/orpc/v1/plugin.ts
··· 1 1 import { StructureModel } from '@hey-api/codegen-core'; 2 2 3 - import { $ } from '../../../../ts-dsl'; 3 + import { $ } from '../../../ts-dsl'; 4 4 import type { ContractItem } from '../contracts'; 5 5 import { createShell, resolveStrategy, source, toNode } from '../contracts'; 6 - import type { OrpcContractPlugin } from '../types'; 6 + import type { OrpcPlugin } from '../types'; 7 7 8 - export const handlerV1: OrpcContractPlugin['Handler'] = ({ plugin }) => { 8 + export const handlerV1: OrpcPlugin['Handler'] = ({ plugin }) => { 9 9 const oc = plugin.symbol('oc', { 10 10 external: '@orpc/contract', 11 11 });
+2 -2
packages/openapi-ts/src/plugins/config.ts
··· 13 13 import { defaultConfig as heyApiSdk } from '../plugins/@hey-api/sdk'; 14 14 import { defaultConfig as heyApiTransformers } from '../plugins/@hey-api/transformers'; 15 15 import { defaultConfig as heyApiTypeScript } from '../plugins/@hey-api/typescript'; 16 - import { defaultConfig as orpcContract } from '../plugins/@orpc/contract'; 17 16 import { defaultConfig as piniaColada } from '../plugins/@pinia/colada'; 18 17 import { defaultConfig as tanStackAngularQuery } from '../plugins/@tanstack/angular-query-experimental'; 19 18 import { defaultConfig as tanStackPreactQuery } from '../plugins/@tanstack/preact-query'; ··· 24 23 import { defaultConfig as arktype } from '../plugins/arktype'; 25 24 import { defaultConfig as fastify } from '../plugins/fastify'; 26 25 import { defaultConfig as nestjs } from '../plugins/nestjs'; 26 + import { defaultConfig as orpc } from '../plugins/orpc'; 27 27 import { defaultConfig as swr } from '../plugins/swr'; 28 28 import { defaultConfig as valibot } from '../plugins/valibot'; 29 29 import { defaultConfig as zod } from '../plugins/zod'; ··· 44 44 '@hey-api/sdk': heyApiSdk, 45 45 '@hey-api/transformers': heyApiTransformers, 46 46 '@hey-api/typescript': heyApiTypeScript, 47 - '@orpc/contract': orpcContract, 48 47 '@pinia/colada': piniaColada, 49 48 '@tanstack/angular-query-experimental': tanStackAngularQuery, 50 49 '@tanstack/preact-query': tanStackPreactQuery, ··· 55 54 arktype, 56 55 fastify, 57 56 nestjs, 57 + orpc, 58 58 swr, 59 59 valibot, 60 60 zod,
+2
packages/openapi-ts/src/plugins/orpc/index.ts
··· 1 + export { defaultConfig, defineConfig } from './config'; 2 + export type { OrpcPlugin } from './types';
+4
packages/openapi-ts/src/plugins/orpc/plugin.ts
··· 1 + import type { OrpcPlugin } from './types'; 2 + import { handlerV1 } from './v1/plugin'; 3 + 4 + export const handler: OrpcPlugin['Handler'] = (args) => handlerV1(args);
+15 -15
pnpm-lock.yaml
··· 1464 1464 specifier: 0.16.0 1465 1465 version: 0.16.0 1466 1466 1467 - packages/openapi-ts-tests/@orpc/contract/v1: 1468 - devDependencies: 1469 - '@hey-api/openapi-ts': 1470 - specifier: workspace:* 1471 - version: link:../../../../openapi-ts 1472 - '@orpc/contract': 1473 - specifier: 1.13.4 1474 - version: 1.13.4 1475 - typescript: 1476 - specifier: 5.9.3 1477 - version: 5.9.3 1478 - zod: 1479 - specifier: 4.3.6 1480 - version: 4.3.6 1481 - 1482 1467 packages/openapi-ts-tests/main: 1483 1468 devDependencies: 1484 1469 '@angular-devkit/build-angular': ··· 1601 1586 typescript: 1602 1587 specifier: 5.9.3 1603 1588 version: 5.9.3 1589 + 1590 + packages/openapi-ts-tests/orpc/v1: 1591 + devDependencies: 1592 + '@hey-api/openapi-ts': 1593 + specifier: workspace:* 1594 + version: link:../../../openapi-ts 1595 + '@orpc/contract': 1596 + specifier: 1.13.4 1597 + version: 1.13.4 1598 + typescript: 1599 + specifier: 5.9.3 1600 + version: 5.9.3 1601 + zod: 1602 + specifier: 4.3.6 1603 + version: 4.3.6 1604 1604 1605 1605 packages/openapi-ts-tests/sdks: 1606 1606 devDependencies:
+1 -1
specs/3.0.x/orpc-contract.yaml specs/3.0.x/orpc.yaml
··· 1 1 openapi: 3.0.4 2 2 info: 3 - title: OpenAPI 3.0.4 oRPC contract example 3 + title: OpenAPI 3.0.4 oRPC example 4 4 version: 1 5 5 paths: 6 6 /users:
+1 -1
specs/3.1.x/orpc-contract.yaml specs/3.1.x/orpc.yaml
··· 1 1 openapi: 3.1.1 2 2 info: 3 - title: OpenAPI 3.1.1 oRPC contract example 3 + title: OpenAPI 3.1.1 oRPC example 4 4 version: 1 5 5 paths: 6 6 /users:
+2 -2
vitest.config.ts
··· 71 71 extends: true, 72 72 test: { 73 73 globalSetup: ['./test/globalTeardown.ts'], 74 - name: '@test/openapi-ts-orpc-contract-v1', 75 - root: 'packages/openapi-ts-tests/@orpc/contract/v1', 74 + name: '@test/openapi-ts-orpc-v1', 75 + root: 'packages/openapi-ts-tests/orpc/v1', 76 76 setupFiles: ['./vitest.setup.ts'], 77 77 }, 78 78 },