@orpc/contract
Advanced tools
Comparing version 0.0.0-next.7b4c812 to 0.0.0-next.7d3bd71
@@ -0,179 +1,270 @@ | ||
// src/error.ts | ||
var ValidationError = class extends Error { | ||
issues; | ||
constructor(options) { | ||
super(options.message, options); | ||
this.issues = options.issues; | ||
} | ||
}; | ||
function mergeErrorMap(errorMap1, errorMap2) { | ||
return { ...errorMap1, ...errorMap2 }; | ||
} | ||
// src/meta.ts | ||
function mergeMeta(meta1, meta2) { | ||
return { ...meta1, ...meta2 }; | ||
} | ||
// src/procedure.ts | ||
var ContractProcedure = class { | ||
constructor(zz$cp) { | ||
this.zz$cp = zz$cp; | ||
"~orpc"; | ||
constructor(def) { | ||
if (def.route?.successStatus && (def.route.successStatus < 200 || def.route?.successStatus > 299)) { | ||
throw new Error("[ContractProcedure] The successStatus must be between 200 and 299"); | ||
} | ||
if (Object.values(def.errorMap).some((val) => val && val.status && (val.status < 400 || val.status > 599))) { | ||
throw new Error("[ContractProcedure] The error status code must be in the 400-599 range."); | ||
} | ||
this["~orpc"] = def; | ||
} | ||
}; | ||
var DecoratedContractProcedure = class _DecoratedContractProcedure extends ContractProcedure { | ||
static decorate(cp) { | ||
if (cp instanceof _DecoratedContractProcedure) | ||
return cp; | ||
return new _DecoratedContractProcedure(cp.zz$cp); | ||
function isContractProcedure(item) { | ||
if (item instanceof ContractProcedure) { | ||
return true; | ||
} | ||
route(opts) { | ||
return new _DecoratedContractProcedure({ | ||
...this.zz$cp, | ||
...opts, | ||
method: opts.method, | ||
path: opts.path | ||
}); | ||
return (typeof item === "object" || typeof item === "function") && item !== null && "~orpc" in item && typeof item["~orpc"] === "object" && item["~orpc"] !== null && "inputSchema" in item["~orpc"] && "outputSchema" in item["~orpc"] && "errorMap" in item["~orpc"] && "route" in item["~orpc"] && "meta" in item["~orpc"]; | ||
} | ||
// src/route.ts | ||
function mergeRoute(a, b) { | ||
return { ...a, ...b }; | ||
} | ||
function prefixRoute(route, prefix) { | ||
if (!route.path) { | ||
return route; | ||
} | ||
prefix(prefix) { | ||
if (!this.zz$cp.path) | ||
return this; | ||
return new _DecoratedContractProcedure({ | ||
...this.zz$cp, | ||
path: `${prefix}${this.zz$cp.path}` | ||
}); | ||
return { | ||
...route, | ||
path: `${prefix}${route.path}` | ||
}; | ||
} | ||
function unshiftTagRoute(route, tags) { | ||
return { | ||
...route, | ||
tags: [...tags, ...route.tags ?? []] | ||
}; | ||
} | ||
function mergePrefix(a, b) { | ||
return a ? `${a}${b}` : b; | ||
} | ||
function mergeTags(a, b) { | ||
return a ? [...a, ...b] : b; | ||
} | ||
function adaptRoute(route, options) { | ||
let router = route; | ||
if (options.prefix) { | ||
router = prefixRoute(router, options.prefix); | ||
} | ||
addTags(...tags) { | ||
if (!tags.length) | ||
return this; | ||
return new _DecoratedContractProcedure({ | ||
...this.zz$cp, | ||
tags: [...this.zz$cp.tags ?? [], ...tags] | ||
}); | ||
if (options.tags) { | ||
router = unshiftTagRoute(router, options.tags); | ||
} | ||
input(schema, example) { | ||
return new _DecoratedContractProcedure({ | ||
...this.zz$cp, | ||
InputSchema: schema, | ||
inputExample: example | ||
return router; | ||
} | ||
// src/router.ts | ||
function adaptContractRouter(contract, options) { | ||
if (isContractProcedure(contract)) { | ||
const adapted2 = new ContractProcedure({ | ||
...contract["~orpc"], | ||
errorMap: mergeErrorMap(options.errorMap, contract["~orpc"].errorMap), | ||
route: adaptRoute(contract["~orpc"].route, options) | ||
}); | ||
return adapted2; | ||
} | ||
output(schema, example) { | ||
return new _DecoratedContractProcedure({ | ||
...this.zz$cp, | ||
OutputSchema: schema, | ||
outputExample: example | ||
}); | ||
const adapted = {}; | ||
for (const key in contract) { | ||
adapted[key] = adaptContractRouter(contract[key], options); | ||
} | ||
}; | ||
function isContractProcedure(item) { | ||
if (item instanceof ContractProcedure) | ||
return true; | ||
return (typeof item === "object" || typeof item === "function") && item !== null && "zz$cp" in item && typeof item.zz$cp === "object" && item.zz$cp !== null && "InputSchema" in item.zz$cp && "OutputSchema" in item.zz$cp; | ||
return adapted; | ||
} | ||
// src/router-builder.ts | ||
var ContractRouterBuilder = class _ContractRouterBuilder { | ||
constructor(zz$crb) { | ||
this.zz$crb = zz$crb; | ||
if (zz$crb.prefix && zz$crb.prefix.includes("{")) { | ||
throw new Error('Prefix cannot contain "{" for dynamic routing'); | ||
} | ||
// src/builder.ts | ||
var ContractBuilder = class _ContractBuilder extends ContractProcedure { | ||
constructor(def) { | ||
super(def); | ||
this["~orpc"].prefix = def.prefix; | ||
this["~orpc"].tags = def.tags; | ||
} | ||
prefix(prefix) { | ||
return new _ContractRouterBuilder({ | ||
...this.zz$crb, | ||
prefix: `${this.zz$crb.prefix ?? ""}${prefix}` | ||
/** | ||
* Reset initial meta | ||
*/ | ||
$meta(initialMeta) { | ||
return new _ContractBuilder({ | ||
...this["~orpc"], | ||
meta: initialMeta | ||
}); | ||
} | ||
tags(...tags) { | ||
if (!tags.length) | ||
return this; | ||
return new _ContractRouterBuilder({ | ||
...this.zz$crb, | ||
tags: [...this.zz$crb.tags ?? [], ...tags] | ||
/** | ||
* Reset initial route | ||
*/ | ||
$route(initialRoute) { | ||
return new _ContractBuilder({ | ||
...this["~orpc"], | ||
route: initialRoute | ||
}); | ||
} | ||
router(router) { | ||
const handled = {}; | ||
for (const key in router) { | ||
const item = router[key]; | ||
if (isContractProcedure(item)) { | ||
const decorated = DecoratedContractProcedure.decorate(item).addTags( | ||
...this.zz$crb.tags ?? [] | ||
); | ||
handled[key] = this.zz$crb.prefix ? decorated.prefix(this.zz$crb.prefix) : decorated; | ||
} else { | ||
handled[key] = this.router(item); | ||
} | ||
} | ||
return handled; | ||
errors(errors) { | ||
return new _ContractBuilder({ | ||
...this["~orpc"], | ||
errorMap: mergeErrorMap(this["~orpc"].errorMap, errors) | ||
}); | ||
} | ||
}; | ||
// src/builder.ts | ||
var ContractBuilder = class { | ||
prefix(prefix) { | ||
return new ContractRouterBuilder({ | ||
prefix | ||
meta(meta) { | ||
return new _ContractBuilder({ | ||
...this["~orpc"], | ||
meta: mergeMeta(this["~orpc"].meta, meta) | ||
}); | ||
} | ||
tags(...tags) { | ||
return new ContractRouterBuilder({ | ||
tags | ||
route(route) { | ||
return new _ContractBuilder({ | ||
...this["~orpc"], | ||
route: mergeRoute(this["~orpc"].route, route) | ||
}); | ||
} | ||
route(opts) { | ||
return new DecoratedContractProcedure({ | ||
InputSchema: void 0, | ||
OutputSchema: void 0, | ||
...opts | ||
input(schema) { | ||
return new _ContractBuilder({ | ||
...this["~orpc"], | ||
inputSchema: schema | ||
}); | ||
} | ||
input(schema, example) { | ||
return new DecoratedContractProcedure({ | ||
InputSchema: schema, | ||
inputExample: example, | ||
OutputSchema: void 0 | ||
output(schema) { | ||
return new _ContractBuilder({ | ||
...this["~orpc"], | ||
outputSchema: schema | ||
}); | ||
} | ||
output(schema, example) { | ||
return new DecoratedContractProcedure({ | ||
InputSchema: void 0, | ||
OutputSchema: schema, | ||
outputExample: example | ||
prefix(prefix) { | ||
return new _ContractBuilder({ | ||
...this["~orpc"], | ||
prefix: mergePrefix(this["~orpc"].prefix, prefix) | ||
}); | ||
} | ||
tag(...tags) { | ||
return new _ContractBuilder({ | ||
...this["~orpc"], | ||
tags: mergeTags(this["~orpc"].tags, tags) | ||
}); | ||
} | ||
router(router) { | ||
return router; | ||
return adaptContractRouter(router, this["~orpc"]); | ||
} | ||
}; | ||
var oc = new ContractBuilder({ | ||
errorMap: {}, | ||
inputSchema: void 0, | ||
outputSchema: void 0, | ||
route: {}, | ||
meta: {} | ||
}); | ||
// src/constants.ts | ||
var ORPC_HEADER = "x-orpc-transformer"; | ||
var ORPC_HEADER_VALUE = "t"; | ||
// src/config.ts | ||
var DEFAULT_CONFIG = { | ||
defaultMethod: "POST", | ||
defaultSuccessStatus: 200, | ||
defaultSuccessDescription: "OK", | ||
defaultInputStructure: "compact", | ||
defaultOutputStructure: "compact" | ||
}; | ||
function fallbackContractConfig(key, value) { | ||
if (value === void 0) { | ||
return DEFAULT_CONFIG[key]; | ||
} | ||
return value; | ||
} | ||
// src/router.ts | ||
function eachContractRouterLeaf(router, callback, prefix = []) { | ||
for (const key in router) { | ||
const item = router[key]; | ||
if (isContractProcedure(item)) { | ||
callback(item, [...prefix, key]); | ||
} else { | ||
eachContractRouterLeaf(item, callback, [...prefix, key]); | ||
// src/event-iterator.ts | ||
import { mapEventIterator, ORPCError } from "@orpc/client"; | ||
import { isAsyncIteratorObject } from "@orpc/server-standard"; | ||
var EVENT_ITERATOR_SCHEMA_SYMBOL = Symbol("ORPC_EVENT_ITERATOR_SCHEMA"); | ||
function eventIterator(yields, returns) { | ||
return { | ||
"~standard": { | ||
[EVENT_ITERATOR_SCHEMA_SYMBOL]: { yields, returns }, | ||
vendor: "orpc", | ||
version: 1, | ||
validate(iterator) { | ||
if (!isAsyncIteratorObject(iterator)) { | ||
return { issues: [{ message: "Expect event source iterator", path: [] }] }; | ||
} | ||
const mapped = mapEventIterator(iterator, { | ||
async value(value, done) { | ||
const schema = done ? returns : yields; | ||
if (!schema) { | ||
return value; | ||
} | ||
const result = await schema["~standard"].validate(value); | ||
if (result.issues) { | ||
throw new ORPCError("EVENT_ITERATOR_VALIDATION_FAILED", { | ||
message: "Event source iterator validation failed", | ||
cause: new ValidationError({ | ||
issues: result.issues, | ||
message: "Event source iterator validation failed" | ||
}) | ||
}); | ||
} | ||
return result.value; | ||
}, | ||
error: async (error) => error | ||
}); | ||
return { value: mapped }; | ||
} | ||
} | ||
}; | ||
} | ||
function getEventIteratorSchemaDetails(schema) { | ||
if (schema === void 0) { | ||
return void 0; | ||
} | ||
return schema["~standard"][EVENT_ITERATOR_SCHEMA_SYMBOL]; | ||
} | ||
// src/utils.ts | ||
function standardizeHTTPPath(path) { | ||
return `/${path.replace(/\/{2,}/g, "/").replace(/^\/|\/$/g, "")}`; | ||
// src/schema.ts | ||
function type(...[map]) { | ||
return { | ||
"~standard": { | ||
vendor: "custom", | ||
version: 1, | ||
async validate(value) { | ||
if (map) { | ||
return { value: await map(value) }; | ||
} | ||
return { value }; | ||
} | ||
} | ||
}; | ||
} | ||
function prefixHTTPPath(prefix, path) { | ||
const prefix_ = standardizeHTTPPath(prefix); | ||
const path_ = standardizeHTTPPath(path); | ||
if (prefix_ === "/") | ||
return path_; | ||
if (path_ === "/") | ||
return prefix_; | ||
return `${prefix_}${path_}`; | ||
} | ||
// src/index.ts | ||
var oc = new ContractBuilder(); | ||
import { ORPCError as ORPCError2 } from "@orpc/client"; | ||
export { | ||
ContractBuilder, | ||
ContractProcedure, | ||
DecoratedContractProcedure, | ||
ORPC_HEADER, | ||
ORPC_HEADER_VALUE, | ||
eachContractRouterLeaf, | ||
ORPCError2 as ORPCError, | ||
ValidationError, | ||
adaptContractRouter, | ||
adaptRoute, | ||
eventIterator, | ||
fallbackContractConfig, | ||
getEventIteratorSchemaDetails, | ||
isContractProcedure, | ||
mergeErrorMap, | ||
mergeMeta, | ||
mergePrefix, | ||
mergeRoute, | ||
mergeTags, | ||
oc, | ||
prefixHTTPPath, | ||
standardizeHTTPPath | ||
prefixRoute, | ||
type, | ||
unshiftTagRoute | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,13 +0,32 @@ | ||
import type { ContractRouter } from './router'; | ||
import type { HTTPPath, Schema, SchemaInput, SchemaOutput } from './types'; | ||
import { DecoratedContractProcedure, type RouteOptions } from './procedure'; | ||
import { ContractRouterBuilder } from './router-builder'; | ||
export declare class ContractBuilder { | ||
prefix(prefix: HTTPPath): ContractRouterBuilder; | ||
tags(...tags: string[]): ContractRouterBuilder; | ||
route(opts: RouteOptions): DecoratedContractProcedure<undefined, undefined>; | ||
input<USchema extends Schema>(schema: USchema, example?: SchemaInput<USchema>): DecoratedContractProcedure<USchema, undefined>; | ||
output<USchema extends Schema>(schema: USchema, example?: SchemaOutput<USchema>): DecoratedContractProcedure<undefined, USchema>; | ||
router<T extends ContractRouter>(router: T): T; | ||
import type { ContractProcedureBuilder, ContractProcedureBuilderWithInput, ContractProcedureBuilderWithOutput, ContractRouterBuilder } from './builder-variants'; | ||
import type { ContractProcedureDef } from './procedure'; | ||
import type { AdaptContractRouterOptions, AdaptedContractRouter, ContractRouter } from './router'; | ||
import type { Schema } from './schema'; | ||
import { type ErrorMap, type MergedErrorMap } from './error'; | ||
import { type Meta } from './meta'; | ||
import { ContractProcedure } from './procedure'; | ||
import { type HTTPPath, type Route } from './route'; | ||
export interface ContractBuilderDef<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, AdaptContractRouterOptions<TErrorMap> { | ||
} | ||
export declare class ContractBuilder<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> { | ||
'~orpc': ContractBuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
constructor(def: ContractBuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>); | ||
/** | ||
* Reset initial meta | ||
*/ | ||
$meta<U extends Meta>(initialMeta: U): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, U>; | ||
/** | ||
* Reset initial route | ||
*/ | ||
$route(initialRoute: Route): ContractBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
errors<U extends ErrorMap>(errors: U): ContractBuilder<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>; | ||
meta(meta: TMeta): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
route(route: Route): ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
input<U extends Schema>(schema: U): ContractProcedureBuilderWithInput<U, TOutputSchema, TErrorMap, TMeta>; | ||
output<U extends Schema>(schema: U): ContractProcedureBuilderWithOutput<TInputSchema, U, TErrorMap, TMeta>; | ||
prefix(prefix: HTTPPath): ContractRouterBuilder<TErrorMap, TMeta>; | ||
tag(...tags: string[]): ContractRouterBuilder<TErrorMap, TMeta>; | ||
router<T extends ContractRouter<TMeta>>(router: T): AdaptedContractRouter<T, TErrorMap>; | ||
} | ||
export declare const oc: ContractBuilder<undefined, undefined, {}, {}>; | ||
//# sourceMappingURL=builder.d.ts.map |
/** unnoq */ | ||
import { ContractBuilder } from './builder'; | ||
export * from './builder'; | ||
export * from './constants'; | ||
export * from './builder-variants'; | ||
export * from './config'; | ||
export * from './error'; | ||
export * from './event-iterator'; | ||
export * from './meta'; | ||
export * from './procedure'; | ||
export * from './procedure-client'; | ||
export * from './route'; | ||
export * from './router'; | ||
export * from './types'; | ||
export * from './utils'; | ||
export declare const oc: ContractBuilder; | ||
export * from './router-client'; | ||
export * from './schema'; | ||
export { ORPCError } from '@orpc/client'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,47 +0,18 @@ | ||
import type { HTTPMethod, HTTPPath, Schema, SchemaInput, SchemaOutput } from './types'; | ||
export interface RouteOptions { | ||
method?: HTTPMethod; | ||
path?: HTTPPath; | ||
summary?: string; | ||
description?: string; | ||
deprecated?: boolean; | ||
tags?: string[]; | ||
import type { ErrorMap } from './error'; | ||
import type { Meta } from './meta'; | ||
import type { Route } from './route'; | ||
import type { Schema } from './schema'; | ||
export interface ContractProcedureDef<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> { | ||
meta: TMeta; | ||
route: Route; | ||
inputSchema: TInputSchema; | ||
outputSchema: TOutputSchema; | ||
errorMap: TErrorMap; | ||
} | ||
export declare class ContractProcedure<TInputSchema extends Schema, TOutputSchema extends Schema> { | ||
zz$cp: { | ||
path?: HTTPPath; | ||
method?: HTTPMethod; | ||
summary?: string; | ||
description?: string; | ||
deprecated?: boolean; | ||
tags?: string[]; | ||
InputSchema: TInputSchema; | ||
inputExample?: SchemaOutput<TInputSchema>; | ||
OutputSchema: TOutputSchema; | ||
outputExample?: SchemaOutput<TOutputSchema>; | ||
}; | ||
constructor(zz$cp: { | ||
path?: HTTPPath; | ||
method?: HTTPMethod; | ||
summary?: string; | ||
description?: string; | ||
deprecated?: boolean; | ||
tags?: string[]; | ||
InputSchema: TInputSchema; | ||
inputExample?: SchemaOutput<TInputSchema>; | ||
OutputSchema: TOutputSchema; | ||
outputExample?: SchemaOutput<TOutputSchema>; | ||
}); | ||
export declare class ContractProcedure<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> { | ||
'~orpc': ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>; | ||
constructor(def: ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>); | ||
} | ||
export type WELL_CONTRACT_PROCEDURE = ContractProcedure<Schema, Schema>; | ||
export declare class DecoratedContractProcedure<TInputSchema extends Schema, TOutputSchema extends Schema> extends ContractProcedure<TInputSchema, TOutputSchema> { | ||
static decorate<TInputSchema extends Schema, TOutputSchema extends Schema>(cp: ContractProcedure<TInputSchema, TOutputSchema>): DecoratedContractProcedure<TInputSchema, TOutputSchema>; | ||
route(opts: RouteOptions): DecoratedContractProcedure<TInputSchema, TOutputSchema>; | ||
prefix(prefix: HTTPPath): DecoratedContractProcedure<TInputSchema, TOutputSchema>; | ||
addTags(...tags: string[]): DecoratedContractProcedure<TInputSchema, TOutputSchema>; | ||
input<USchema extends Schema>(schema: USchema, example?: SchemaInput<USchema>): DecoratedContractProcedure<USchema, TOutputSchema>; | ||
output<USchema extends Schema>(schema: USchema, example?: SchemaOutput<USchema>): DecoratedContractProcedure<TInputSchema, USchema>; | ||
} | ||
export type WELL_DEFINED_CONTRACT_PROCEDURE = ContractProcedure<Schema, Schema>; | ||
export declare function isContractProcedure(item: unknown): item is WELL_DEFINED_CONTRACT_PROCEDURE; | ||
export type AnyContractProcedure = ContractProcedure<any, any, any, any>; | ||
export declare function isContractProcedure(item: unknown): item is AnyContractProcedure; | ||
//# sourceMappingURL=procedure.d.ts.map |
@@ -1,16 +0,29 @@ | ||
import type { SchemaInput, SchemaOutput } from './types'; | ||
import { type ContractProcedure, type DecoratedContractProcedure, type WELL_DEFINED_CONTRACT_PROCEDURE } from './procedure'; | ||
export interface ContractRouter { | ||
[k: string]: ContractProcedure<any, any> | ContractRouter; | ||
import type { Meta } from './meta'; | ||
import type { SchemaInput, SchemaOutput } from './schema'; | ||
import { type ErrorMap, type MergedErrorMap } from './error'; | ||
import { ContractProcedure } from './procedure'; | ||
import { type HTTPPath } from './route'; | ||
export type ContractRouter<TMeta extends Meta> = ContractProcedure<any, any, any, TMeta> | { | ||
[k: string]: ContractRouter<TMeta>; | ||
}; | ||
export type AnyContractRouter = ContractRouter<any>; | ||
export type AdaptedContractRouter<TContract extends AnyContractRouter, TErrorMap extends ErrorMap> = { | ||
[K in keyof TContract]: TContract[K] extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrors, infer UMeta> ? ContractProcedure<UInputSchema, UOutputSchema, MergedErrorMap<TErrorMap, UErrors>, UMeta> : TContract[K] extends AnyContractRouter ? AdaptedContractRouter<TContract[K], TErrorMap> : never; | ||
}; | ||
export interface AdaptContractRouterOptions<TErrorMap extends ErrorMap> { | ||
errorMap: TErrorMap; | ||
prefix?: HTTPPath; | ||
tags?: readonly string[]; | ||
} | ||
export type HandledContractRouter<TContract extends ContractRouter> = { | ||
[K in keyof TContract]: TContract[K] extends ContractProcedure<infer UInputSchema, infer UOutputSchema> ? DecoratedContractProcedure<UInputSchema, UOutputSchema> : TContract[K] extends ContractRouter ? HandledContractRouter<TContract[K]> : never; | ||
export declare function adaptContractRouter<TRouter extends ContractRouter<any>, TErrorMap extends ErrorMap>(contract: TRouter, options: AdaptContractRouterOptions<TErrorMap>): AdaptedContractRouter<TRouter, TErrorMap>; | ||
export type InferContractRouterInputs<T extends AnyContractRouter> = T extends ContractProcedure<infer UInputSchema, any, any, any> ? SchemaInput<UInputSchema> : { | ||
[K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterInputs<T[K]> : never; | ||
}; | ||
export declare function eachContractRouterLeaf(router: ContractRouter, callback: (item: WELL_DEFINED_CONTRACT_PROCEDURE, path: string[]) => void, prefix?: string[]): void; | ||
export type InferContractRouterInputs<T extends ContractRouter> = { | ||
[K in keyof T]: T[K] extends ContractProcedure<infer UInputSchema, any> ? SchemaInput<UInputSchema> : T[K] extends ContractRouter ? InferContractRouterInputs<T[K]> : never; | ||
export type InferContractRouterOutputs<T extends AnyContractRouter> = T extends ContractProcedure<any, infer UOutputSchema, any, any> ? SchemaOutput<UOutputSchema> : { | ||
[K in keyof T]: T[K] extends AnyContractRouter ? InferContractRouterOutputs<T[K]> : never; | ||
}; | ||
export type InferContractRouterOutputs<T extends ContractRouter> = { | ||
[K in keyof T]: T[K] extends ContractProcedure<any, infer UOutputSchema> ? SchemaOutput<UOutputSchema> : T[K] extends ContractRouter ? InferContractRouterOutputs<T[K]> : never; | ||
}; | ||
export type ContractRouterToErrorMap<T extends AnyContractRouter> = T extends ContractProcedure<any, any, infer UErrorMap, any> ? UErrorMap : { | ||
[K in keyof T]: T[K] extends AnyContractRouter ? ContractRouterToErrorMap<T[K]> : never; | ||
}[keyof T]; | ||
export type ContractRouterToMeta<T extends AnyContractRouter> = T extends ContractRouter<infer UMeta> ? UMeta : never; | ||
//# sourceMappingURL=router.d.ts.map |
{ | ||
"name": "@orpc/contract", | ||
"type": "module", | ||
"version": "0.0.0-next.7b4c812", | ||
"version": "0.0.0-next.7d3bd71", | ||
"license": "MIT", | ||
@@ -32,5 +32,12 @@ "homepage": "https://orpc.unnoq.com", | ||
"dependencies": { | ||
"@standard-schema/spec": "1.0.0-beta.4", | ||
"@orpc/shared": "0.0.0-next.7b4c812" | ||
"@orpc/server-standard": "^0.4.0", | ||
"@standard-schema/spec": "^1.0.0", | ||
"@orpc/client": "0.0.0-next.7d3bd71", | ||
"@orpc/shared": "0.0.0-next.7d3bd71" | ||
}, | ||
"devDependencies": { | ||
"arktype": "2.0.0-rc.26", | ||
"valibot": "1.0.0-beta.9", | ||
"zod": "^3.24.1" | ||
}, | ||
"scripts": { | ||
@@ -37,0 +44,0 @@ "build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
25811
16
531
4
3
1
+ Added@orpc/server-standard@^0.4.0
+ Added@orpc/client@0.0.0-next.7d3bd71(transitive)
+ Added@orpc/server-standard@0.4.0(transitive)
+ Added@orpc/server-standard-fetch@0.4.0(transitive)
+ Added@orpc/shared@0.0.0-next.7d3bd71(transitive)
+ Added@standard-schema/spec@1.0.0(transitive)
+ Added@tinyhttp/content-disposition@2.2.2(transitive)
- Removed@orpc/shared@0.0.0-next.7b4c812(transitive)
- Removed@standard-schema/spec@1.0.0-beta.4(transitive)
- Removedis-what@5.2.0(transitive)
Updated@standard-schema/spec@^1.0.0