Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ts-rest/core

Package Overview
Dependencies
Maintainers
1
Versions
136
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ts-rest/core - npm Package Compare versions

Comparing version 3.43.0 to 3.44.0

7

CHANGELOG.md
# @ts-rest/core
## 3.44.0
### Minor Changes
- 60f90fa: Allow entire contract to be passed to `TsRestResponseError` so common responses can be thrown easily
- 45e5104: Add router-level metadata
## 3.43.0

@@ -4,0 +11,0 @@

8

index.cjs.js

@@ -76,3 +76,3 @@ 'use strict';

return Object.fromEntries(Object.entries(router).map(([key, value]) => {
var _a, _b;
var _a, _b, _c;
if (isAppRoute(value)) {

@@ -93,2 +93,8 @@ return [

},
metadata: (options === null || options === void 0 ? void 0 : options.metadata)
? {
...options === null || options === void 0 ? void 0 : options.metadata,
...((_c = value.metadata) !== null && _c !== void 0 ? _c : {}),
}
: value.metadata,
},

@@ -95,0 +101,0 @@ ];

@@ -72,3 +72,3 @@ const isZodType = (obj) => {

return Object.fromEntries(Object.entries(router).map(([key, value]) => {
var _a, _b;
var _a, _b, _c;
if (isAppRoute(value)) {

@@ -89,2 +89,8 @@ return [

},
metadata: (options === null || options === void 0 ? void 0 : options.metadata)
? {
...options === null || options === void 0 ? void 0 : options.metadata,
...((_c = value.metadata) !== null && _c !== void 0 ? _c : {}),
}
: value.metadata,
},

@@ -91,0 +97,0 @@ ];

2

package.json
{
"name": "@ts-rest/core",
"version": "3.43.0",
"version": "3.44.0",
"description": "RPC-like experience over a regular REST API, with type safe server implementations 🪄",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -76,2 +76,3 @@ import { Merge, Opaque, Prettify, WithoutUnknown } from './type-utils';

responses: 'commonResponses' extends keyof TOptions ? Prettify<Merge<TOptions['commonResponses'], TRoute['responses']>> : TRoute['responses'];
metadata: 'metadata' extends keyof TOptions ? Prettify<Merge<TOptions['metadata'], TRoute['metadata']>> : TRoute['metadata'];
}>;

@@ -97,2 +98,3 @@ /**

commonResponses?: Record<number, AppRouteResponse>;
metadata?: unknown;
/**

@@ -99,0 +101,0 @@ * @deprecated Use `validateResponse` on the client options

@@ -1,8 +0,20 @@

import { AppRoute } from './dsl';
import { ServerInferResponses } from './infer-types';
import { AppRoute, AppRouter, AppRouteResponse } from './dsl';
import { ResolveResponseType, ServerInferResponses } from './infer-types';
import { HTTPStatusCode } from './status-codes';
export declare class TsRestResponseError<T extends AppRoute> extends Error {
import { CommonAndEqual, ZodInputOrType } from './type-utils';
export declare class TsRestResponseError<T extends AppRoute | AppRouter> extends Error {
statusCode: HTTPStatusCode;
body: any;
constructor(route: T, response: ServerInferResponses<T>);
constructor(route: T, response: T extends AppRouter ? ServerCommonResponses<T> : ServerInferResponses<T>);
}
type FlattenAppRouter<T extends AppRouter | AppRoute> = T extends AppRoute ? T : {
[TKey in keyof T]: T[TKey] extends AppRoute ? T[TKey] : T[TKey] extends AppRouter ? FlattenAppRouter<T[TKey]> : never;
}[keyof T];
type AppRouterCommonResponses<T extends AppRouter> = CommonAndEqual<FlattenAppRouter<T>['responses']>;
type ServerCommonResponses<T extends AppRouter, TResponses = AppRouterCommonResponses<T>> = {
[K in keyof TResponses]: {
status: K;
body: TResponses[K] extends AppRouteResponse ? ZodInputOrType<ResolveResponseType<TResponses[K]>> : never;
};
}[keyof TResponses];
export {};

@@ -76,2 +76,9 @@ import { z } from 'zod';

}[`${B}`];
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
type CommonKeys<T, R = {}> = R extends T ? keyof T & CommonKeys<Exclude<T, R>> : keyof T;
type Common<T> = Pick<T, CommonKeys<T>>;
type RemoveUnionProperties<T> = {
[TKey in keyof T as [T[TKey]] extends [UnionToIntersection<T[TKey]>] ? TKey : never]: T[TKey];
};
export type CommonAndEqual<T> = RemoveUnionProperties<Common<T>>;
export {};
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