New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@orpc/contract

Package Overview
Dependencies
Maintainers
0
Versions
238
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@orpc/contract - npm Package Compare versions

Comparing version 0.31.0 to 0.32.0

40

dist/index.js

@@ -211,2 +211,14 @@ // src/procedure.ts

var ContractBuilder = class _ContractBuilder extends ContractProcedure {
constructor(def) {
super(def);
}
config(config) {
return new _ContractBuilder({
...this["~orpc"],
config: {
...this["~orpc"].config,
...config
}
});
}
errors(errors) {

@@ -223,3 +235,6 @@ return new _ContractBuilder({

return new ContractProcedureBuilder({
route,
route: {
...this["~orpc"].config.initialRoute,
...route
},
InputSchema: void 0,

@@ -232,2 +247,3 @@ OutputSchema: void 0,

return new ContractProcedureBuilderWithInput({
route: this["~orpc"].config.initialRoute,
InputSchema: schema,

@@ -241,2 +257,3 @@ inputExample: example,

return new ContractProcedureBuilderWithOutput({
route: this["~orpc"].config.initialRoute,
OutputSchema: schema,

@@ -430,16 +447,5 @@ outputExample: example,

};
var GLOBAL_CONFIG_REF = { value: DEFAULT_CONFIG };
function configGlobal(config) {
if (config.defaultSuccessStatus !== void 0 && (config.defaultSuccessStatus < 200 || config.defaultSuccessStatus > 299)) {
throw new Error("[configGlobal] The defaultSuccessStatus must be between 200 and 299");
}
GLOBAL_CONFIG_REF.value = config;
}
function fallbackToGlobalConfig(key, value) {
function fallbackContractConfig(key, value) {
if (value === void 0) {
const fallback = GLOBAL_CONFIG_REF.value[key];
if (fallback === void 0) {
return DEFAULT_CONFIG[key];
}
return fallback;
return DEFAULT_CONFIG[key];
}

@@ -478,3 +484,4 @@ return value;

InputSchema: void 0,
OutputSchema: void 0
OutputSchema: void 0,
config: {}
});

@@ -492,6 +499,5 @@ export {

ValidationError,
configGlobal,
fallbackContractConfig,
fallbackORPCErrorMessage,
fallbackORPCErrorStatus,
fallbackToGlobalConfig,
isContractProcedure,

@@ -498,0 +504,0 @@ isDefinedError,

import type { ErrorMap, ErrorMapGuard, ErrorMapSuggestions, StrictErrorMap } from './error-map';
import type { ContractProcedureDef, RouteOptions } from './procedure';
import type { ContractRouter } from './router';
import type { AdaptedContractRouter } from './router-builder';
import type { HTTPPath, Schema, SchemaInput, SchemaOutput } from './types';
import { ContractProcedure, type RouteOptions } from './procedure';
import { ContractProcedure } from './procedure';
import { ContractProcedureBuilder } from './procedure-builder';

@@ -10,6 +11,12 @@ import { ContractProcedureBuilderWithInput } from './procedure-builder-with-input';

import { ContractRouterBuilder } from './router-builder';
export type ContractBuilderDef<TErrorMap extends ErrorMap> = {
errorMap: TErrorMap;
};
export interface ContractBuilderConfig {
initialRoute?: RouteOptions;
}
export interface ContractBuilderDef<TErrorMap extends ErrorMap> extends ContractProcedureDef<undefined, undefined, TErrorMap> {
config: ContractBuilderConfig;
}
export declare class ContractBuilder<TErrorMap extends ErrorMap> extends ContractProcedure<undefined, undefined, TErrorMap> {
'~orpc': ContractBuilderDef<TErrorMap>;
constructor(def: ContractBuilderDef<TErrorMap>);
config(config: ContractBuilderConfig): ContractBuilder<TErrorMap>;
errors<const U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): ContractBuilder<U & TErrorMap>;

@@ -16,0 +23,0 @@ route(route: RouteOptions): ContractProcedureBuilder<TErrorMap>;

import type { HTTPMethod, InputStructure } from './types';
export interface ORPCConfig {
/**
* @default 'POST'
*/
defaultMethod?: HTTPMethod;
/**
*
* @default 200
*/
defaultSuccessStatus?: number;
/**
*
* @default 'OK'
*/
defaultSuccessDescription?: string;
/**
*
* @default 'compact'
*/
defaultInputStructure?: InputStructure;
/**
*
* @default 'compact'
*/
defaultOutputStructure?: InputStructure;
export interface ContractConfig {
defaultMethod: HTTPMethod;
defaultSuccessStatus: number;
defaultSuccessDescription: string;
defaultInputStructure: InputStructure;
defaultOutputStructure: InputStructure;
}
/**
* Set the global configuration, this configuration can effect entire project
*/
export declare function configGlobal(config: ORPCConfig): void;
/**
* Fallback the value to the global config if it is undefined
*/
export declare function fallbackToGlobalConfig<T extends keyof ORPCConfig>(key: T, value: ORPCConfig[T]): Exclude<ORPCConfig[T], undefined>;
export declare function fallbackContractConfig<T extends keyof ContractConfig>(key: T, value: ContractConfig[T] | undefined): ContractConfig[T];
//# sourceMappingURL=config.d.ts.map
{
"name": "@orpc/contract",
"type": "module",
"version": "0.31.0",
"version": "0.32.0",
"license": "MIT",

@@ -33,3 +33,3 @@ "homepage": "https://orpc.unnoq.com",

"@standard-schema/spec": "1.0.0-beta.4",
"@orpc/shared": "0.31.0"
"@orpc/shared": "0.32.0"
},

@@ -36,0 +36,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc