@orpc/contract 0.0.0-next.e361acd → 0.0.0-next.e4b0df6

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/contract",
3
3
  "type": "module",
4
- "version": "0.0.0-next.e361acd",
4
+ "version": "0.0.0-next.e4b0df6",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -15,30 +15,32 @@
15
15
  ],
16
16
  "exports": {
17
17
  ".": {
18
- "types": "./dist/src/index.d.ts",
19
- "import": "./dist/index.js",
20
- "default": "./dist/index.js"
18
+ "types": "./dist/index.d.mts",
19
+ "import": "./dist/index.mjs",
20
+ "default": "./dist/index.mjs"
21
21
  },
22
- "./🔒/*": {
23
- "types": "./dist/src/*.d.ts"
22
+ "./plugins": {
23
+ "types": "./dist/plugins/index.d.mts",
24
+ "import": "./dist/plugins/index.mjs",
25
+ "default": "./dist/plugins/index.mjs"
24
26
  }
25
27
  },
26
28
  "files": [
27
- "!**/*.map",
28
- "!**/*.tsbuildinfo",
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@standard-schema/spec": "1.0.0-beta.4",
33
- "@orpc/shared": "0.0.0-next.e361acd"
32
+ "@standard-schema/spec": "^1.0.0",
33
+ "openapi-types": "^12.1.3",
34
+ "@orpc/client": "0.0.0-next.e4b0df6",
35
+ "@orpc/shared": "0.0.0-next.e4b0df6"
34
36
  },
35
37
  "devDependencies": {
36
- "arktype": "2.0.0-rc.26",
37
- "valibot": "1.0.0-beta.9",
38
- "zod": "3.24.1"
38
+ "arktype": "2.1.21",
39
+ "valibot": "^1.1.0",
40
+ "zod": "^4.1.5"
39
41
  },
40
42
  "scripts": {
41
- "build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
43
+ "build": "unbuild",
42
44
  "build:watch": "pnpm run build --watch",
43
45
  "type:check": "tsc -b"
44
46
  }
package/dist/index.js DELETED
@@ -1,155 +0,0 @@
1
- // src/procedure.ts
2
- var ContractProcedure = class {
3
- "~type" = "ContractProcedure";
4
- "~orpc";
5
- constructor(def) {
6
- this["~orpc"] = def;
7
- }
8
- };
9
- function isContractProcedure(item) {
10
- if (item instanceof ContractProcedure) {
11
- return true;
12
- }
13
- return (typeof item === "object" || typeof item === "function") && item !== null && "~type" in item && item["~type"] === "ContractProcedure" && "~orpc" in item && typeof item["~orpc"] === "object" && item["~orpc"] !== null && "InputSchema" in item["~orpc"] && "OutputSchema" in item["~orpc"];
14
- }
15
-
16
- // src/procedure-decorated.ts
17
- var DecoratedContractProcedure = class _DecoratedContractProcedure extends ContractProcedure {
18
- static decorate(procedure) {
19
- if (procedure instanceof _DecoratedContractProcedure) {
20
- return procedure;
21
- }
22
- return new _DecoratedContractProcedure(procedure["~orpc"]);
23
- }
24
- route(route) {
25
- return new _DecoratedContractProcedure({
26
- ...this["~orpc"],
27
- route
28
- });
29
- }
30
- prefix(prefix) {
31
- return new _DecoratedContractProcedure({
32
- ...this["~orpc"],
33
- ...this["~orpc"].route?.path ? {
34
- route: {
35
- ...this["~orpc"].route,
36
- path: `${prefix}${this["~orpc"].route.path}`
37
- }
38
- } : void 0
39
- });
40
- }
41
- unshiftTag(...tags) {
42
- return new _DecoratedContractProcedure({
43
- ...this["~orpc"],
44
- route: {
45
- ...this["~orpc"].route,
46
- tags: [
47
- ...tags,
48
- ...this["~orpc"].route?.tags?.filter((tag) => !tags.includes(tag)) ?? []
49
- ]
50
- }
51
- });
52
- }
53
- input(schema, example) {
54
- return new _DecoratedContractProcedure({
55
- ...this["~orpc"],
56
- InputSchema: schema,
57
- inputExample: example
58
- });
59
- }
60
- output(schema, example) {
61
- return new _DecoratedContractProcedure({
62
- ...this["~orpc"],
63
- OutputSchema: schema,
64
- outputExample: example
65
- });
66
- }
67
- };
68
-
69
- // src/router-builder.ts
70
- var ContractRouterBuilder = class _ContractRouterBuilder {
71
- "~type" = "ContractProcedure";
72
- "~orpc";
73
- constructor(def) {
74
- this["~orpc"] = def;
75
- }
76
- prefix(prefix) {
77
- return new _ContractRouterBuilder({
78
- ...this["~orpc"],
79
- prefix: `${this["~orpc"].prefix ?? ""}${prefix}`
80
- });
81
- }
82
- tag(...tags) {
83
- return new _ContractRouterBuilder({
84
- ...this["~orpc"],
85
- tags: [...this["~orpc"].tags ?? [], ...tags]
86
- });
87
- }
88
- router(router) {
89
- if (isContractProcedure(router)) {
90
- let decorated = DecoratedContractProcedure.decorate(router);
91
- if (this["~orpc"].tags) {
92
- decorated = decorated.unshiftTag(...this["~orpc"].tags);
93
- }
94
- if (this["~orpc"].prefix) {
95
- decorated = decorated.prefix(this["~orpc"].prefix);
96
- }
97
- return decorated;
98
- }
99
- const adapted = {};
100
- for (const key in router) {
101
- adapted[key] = this.router(router[key]);
102
- }
103
- return adapted;
104
- }
105
- };
106
-
107
- // src/builder.ts
108
- var ContractBuilder = class {
109
- prefix(prefix) {
110
- return new ContractRouterBuilder({
111
- prefix
112
- });
113
- }
114
- tag(...tags) {
115
- return new ContractRouterBuilder({
116
- tags
117
- });
118
- }
119
- route(route) {
120
- return new DecoratedContractProcedure({
121
- route,
122
- InputSchema: void 0,
123
- OutputSchema: void 0
124
- });
125
- }
126
- input(schema, example) {
127
- return new DecoratedContractProcedure({
128
- InputSchema: schema,
129
- inputExample: example,
130
- OutputSchema: void 0
131
- });
132
- }
133
- output(schema, example) {
134
- return new DecoratedContractProcedure({
135
- OutputSchema: schema,
136
- outputExample: example,
137
- InputSchema: void 0
138
- });
139
- }
140
- router(router) {
141
- return router;
142
- }
143
- };
144
-
145
- // src/index.ts
146
- var oc = new ContractBuilder();
147
- export {
148
- ContractBuilder,
149
- ContractProcedure,
150
- ContractRouterBuilder,
151
- DecoratedContractProcedure,
152
- isContractProcedure,
153
- oc
154
- };
155
- //# sourceMappingURL=index.js.map
@@ -1,14 +0,0 @@
1
- import type { RouteOptions } from './procedure';
2
- import type { ContractRouter } from './router';
3
- import type { HTTPPath, Schema, SchemaInput, SchemaOutput } from './types';
4
- import { DecoratedContractProcedure } from './procedure-decorated';
5
- import { ContractRouterBuilder } from './router-builder';
6
- export declare class ContractBuilder {
7
- prefix(prefix: HTTPPath): ContractRouterBuilder;
8
- tag(...tags: string[]): ContractRouterBuilder;
9
- route(route: RouteOptions): DecoratedContractProcedure<undefined, undefined>;
10
- input<U extends Schema = undefined>(schema: U, example?: SchemaInput<U>): DecoratedContractProcedure<U, undefined>;
11
- output<U extends Schema = undefined>(schema: U, example?: SchemaOutput<U>): DecoratedContractProcedure<undefined, U>;
12
- router<T extends ContractRouter>(router: T): T;
13
- }
14
- //# sourceMappingURL=builder.d.ts.map
@@ -1,10 +0,0 @@
1
- /** unnoq */
2
- import { ContractBuilder } from './builder';
3
- export * from './builder';
4
- export * from './procedure';
5
- export * from './procedure-decorated';
6
- export * from './router';
7
- export * from './router-builder';
8
- export * from './types';
9
- export declare const oc: ContractBuilder;
10
- //# sourceMappingURL=index.d.ts.map
@@ -1,12 +0,0 @@
1
- import type { RouteOptions } from './procedure';
2
- import type { HTTPPath, Schema, SchemaInput, SchemaOutput } from './types';
3
- import { ContractProcedure } from './procedure';
4
- export declare class DecoratedContractProcedure<TInputSchema extends Schema, TOutputSchema extends Schema> extends ContractProcedure<TInputSchema, TOutputSchema> {
5
- static decorate<UInputSchema extends Schema = undefined, UOutputSchema extends Schema = undefined>(procedure: ContractProcedure<UInputSchema, UOutputSchema>): DecoratedContractProcedure<UInputSchema, UOutputSchema>;
6
- route(route: RouteOptions): DecoratedContractProcedure<TInputSchema, TOutputSchema>;
7
- prefix(prefix: HTTPPath): DecoratedContractProcedure<TInputSchema, TOutputSchema>;
8
- unshiftTag(...tags: string[]): DecoratedContractProcedure<TInputSchema, TOutputSchema>;
9
- input<U extends Schema = undefined>(schema: U, example?: SchemaInput<U>): DecoratedContractProcedure<U, TOutputSchema>;
10
- output<U extends Schema = undefined>(schema: U, example?: SchemaOutput<U>): DecoratedContractProcedure<TInputSchema, U>;
11
- }
12
- //# sourceMappingURL=procedure-decorated.d.ts.map
@@ -1,25 +0,0 @@
1
- import type { HTTPMethod, HTTPPath, Schema, SchemaOutput } from './types';
2
- export interface RouteOptions {
3
- method?: HTTPMethod;
4
- path?: HTTPPath;
5
- summary?: string;
6
- description?: string;
7
- deprecated?: boolean;
8
- tags?: readonly string[];
9
- }
10
- export interface ContractProcedureDef<TInputSchema extends Schema, TOutputSchema extends Schema> {
11
- route?: RouteOptions;
12
- InputSchema: TInputSchema;
13
- inputExample?: SchemaOutput<TInputSchema>;
14
- OutputSchema: TOutputSchema;
15
- outputExample?: SchemaOutput<TOutputSchema>;
16
- }
17
- export declare class ContractProcedure<TInputSchema extends Schema, TOutputSchema extends Schema> {
18
- '~type': "ContractProcedure";
19
- '~orpc': ContractProcedureDef<TInputSchema, TOutputSchema>;
20
- constructor(def: ContractProcedureDef<TInputSchema, TOutputSchema>);
21
- }
22
- export type ANY_CONTRACT_PROCEDURE = ContractProcedure<any, any>;
23
- export type WELL_CONTRACT_PROCEDURE = ContractProcedure<Schema, Schema>;
24
- export declare function isContractProcedure(item: unknown): item is ANY_CONTRACT_PROCEDURE;
25
- //# sourceMappingURL=procedure.d.ts.map
@@ -1,20 +0,0 @@
1
- import type { ContractProcedure } from './procedure';
2
- import type { ContractRouter } from './router';
3
- import type { HTTPPath } from './types';
4
- import { DecoratedContractProcedure } from './procedure-decorated';
5
- export type AdaptedContractRouter<TContract extends ContractRouter> = {
6
- [K in keyof TContract]: TContract[K] extends ContractProcedure<infer UInputSchema, infer UOutputSchema> ? DecoratedContractProcedure<UInputSchema, UOutputSchema> : TContract[K] extends ContractRouter ? AdaptedContractRouter<TContract[K]> : never;
7
- };
8
- export interface ContractRouterBuilderDef {
9
- prefix?: HTTPPath;
10
- tags?: string[];
11
- }
12
- export declare class ContractRouterBuilder {
13
- '~type': "ContractProcedure";
14
- '~orpc': ContractRouterBuilderDef;
15
- constructor(def: ContractRouterBuilderDef);
16
- prefix(prefix: HTTPPath): ContractRouterBuilder;
17
- tag(...tags: string[]): ContractRouterBuilder;
18
- router<T extends ContractRouter>(router: T): AdaptedContractRouter<T>;
19
- }
20
- //# sourceMappingURL=router-builder.d.ts.map
@@ -1,12 +0,0 @@
1
- import type { ANY_CONTRACT_PROCEDURE, ContractProcedure } from './procedure';
2
- import type { SchemaInput, SchemaOutput } from './types';
3
- export type ContractRouter = ANY_CONTRACT_PROCEDURE | {
4
- [k: string]: ContractRouter;
5
- };
6
- export type InferContractRouterInputs<T extends ContractRouter> = T extends ContractProcedure<infer UInputSchema, any> ? SchemaInput<UInputSchema> : {
7
- [K in keyof T]: T[K] extends ContractRouter ? InferContractRouterInputs<T[K]> : never;
8
- };
9
- export type InferContractRouterOutputs<T extends ContractRouter> = T extends ContractProcedure<any, infer UOutputSchema> ? SchemaOutput<UOutputSchema> : {
10
- [K in keyof T]: T[K] extends ContractRouter ? InferContractRouterOutputs<T[K]> : never;
11
- };
12
- //# sourceMappingURL=router.d.ts.map
@@ -1,7 +0,0 @@
1
- import type { StandardSchemaV1 } from '@standard-schema/spec';
2
- export type HTTPPath = `/${string}`;
3
- export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
4
- export type Schema = StandardSchemaV1 | undefined;
5
- export type SchemaInput<TSchema extends Schema, TFallback = unknown> = TSchema extends undefined ? TFallback : TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferInput<TSchema> : TFallback;
6
- export type SchemaOutput<TSchema extends Schema, TFallback = unknown> = TSchema extends undefined ? TFallback : TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TSchema> : TFallback;
7
- //# sourceMappingURL=types.d.ts.map