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

@orpc/shared

Package Overview
Dependencies
Maintainers
0
Versions
241
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@orpc/shared - npm Package Compare versions

Comparing version 0.0.0-next.aa72097 to 0.0.0-next.ad0709a

dist/src/chain.d.ts

120

dist/index.js

@@ -1,5 +0,1 @@

import {
convertToStandardError
} from "./chunk-CCTAECMC.js";
// src/constants.ts

@@ -9,2 +5,35 @@ var ORPC_HANDLER_HEADER = "x-orpc-handler";

// src/error.ts
import { isPlainObject } from "is-what";
function toError(error) {
if (error instanceof Error) {
return error;
}
if (typeof error === "string") {
return new Error(error, { cause: error });
}
if (isPlainObject(error)) {
if ("message" in error && typeof error.message === "string") {
return new Error(error.message, { cause: error });
}
if ("name" in error && typeof error.name === "string") {
return new Error(error.name, { cause: error });
}
}
return new Error("Unknown error", { cause: error });
}
// src/function.ts
function once(fn) {
let cached;
return () => {
if (cached) {
return cached.result;
}
const result = fn();
cached = { result };
return result;
};
}
// src/hook.ts

@@ -29,4 +58,4 @@ async function executeWithHooks(options) {

try {
for (const onStart of onStarts) {
await onStart(state, options.context, options.meta);
for (const onStart2 of onStarts) {
await onStart2(state, options.context, options.meta);
}

@@ -39,3 +68,3 @@ const output = await options.execute();

} catch (e) {
state = { status: "error", input: options.input, error: convertToStandardError(e), output: void 0 };
state = { status: "error", input: options.input, error: toError(e), output: void 0 };
for (let i = onErrors.length - 1; i >= 0; i--) {

@@ -45,3 +74,3 @@ try {

} catch (e2) {
state = { status: "error", input: options.input, error: convertToStandardError(e2), output: void 0 };
state = { status: "error", input: options.input, error: toError(e2), output: void 0 };
}

@@ -54,3 +83,3 @@ }

} catch (e) {
state = { status: "error", input: options.input, error: convertToStandardError(e), output: void 0 };
state = { status: "error", input: options.input, error: toError(e), output: void 0 };
}

@@ -72,2 +101,57 @@ }

// src/interceptor.ts
function onStart(callback) {
return async (options, ...rest) => {
await callback(options, ...rest);
return await options.next();
};
}
function onSuccess(callback) {
return async (options, ...rest) => {
const result = await options.next();
await callback(result, options, ...rest);
return result;
};
}
function onError(callback) {
return async (options, ...rest) => {
try {
return await options.next();
} catch (error) {
await callback(error, options, ...rest);
throw error;
}
};
}
function onFinish(callback) {
let state;
return async (options, ...rest) => {
try {
const result = await options.next();
state = [result, void 0, "success"];
return result;
} catch (error) {
state = [void 0, error, "error"];
throw error;
} finally {
await callback(state, options, ...rest);
}
};
}
async function intercept(interceptable, options, main) {
const interceptors = interceptable.interceptors ?? [];
let index = 0;
const next = async (nextOptions = options) => {
const interceptor = interceptors[index++];
if (!interceptor) {
return await main(nextOptions);
}
return await interceptor({
...nextOptions,
next
});
};
return await next();
}
// src/json.ts

@@ -85,3 +169,3 @@ function parseJSONSafely(text) {

// src/object.ts
import { isPlainObject } from "is-what";
import { isPlainObject as isPlainObject2 } from "is-what";
function set(root, segments, value2) {

@@ -122,3 +206,3 @@ const ref = { root };

});
} else if (isPlainObject(payload)) {
} else if (isPlainObject2(payload)) {
for (const key in payload) {

@@ -168,4 +252,4 @@ findDeepMatches(check, payload[key], [...segments, key], maps, values);

// src/index.ts
import { isPlainObject as isPlainObject2 } from "is-what";
import { guard, mapEntries, mapValues, omit, trim } from "radash";
import { isPlainObject as isPlainObject3 } from "is-what";
import { group, guard, mapEntries, mapValues, omit, trim } from "radash";
export {

@@ -179,9 +263,17 @@ ORPC_HANDLER_HEADER,

get,
group,
guard,
isPlainObject2 as isPlainObject,
intercept,
isPlainObject3 as isPlainObject,
mapEntries,
mapValues,
omit,
onError,
onFinish,
onStart,
onSuccess,
once,
parseJSONSafely,
set,
toError,
trim,

@@ -188,0 +280,0 @@ value

65

dist/src/error.d.ts

@@ -1,65 +0,2 @@

import type { StandardSchemaV1 } from '@standard-schema/spec';
export declare const ORPC_ERROR_CODE_STATUSES: {
readonly BAD_REQUEST: 400;
readonly UNAUTHORIZED: 401;
readonly FORBIDDEN: 403;
readonly NOT_FOUND: 404;
readonly METHOD_NOT_SUPPORTED: 405;
readonly NOT_ACCEPTABLE: 406;
readonly TIMEOUT: 408;
readonly CONFLICT: 409;
readonly PRECONDITION_FAILED: 412;
readonly PAYLOAD_TOO_LARGE: 413;
readonly UNSUPPORTED_MEDIA_TYPE: 415;
readonly UNPROCESSABLE_CONTENT: 422;
readonly TOO_MANY_REQUESTS: 429;
readonly CLIENT_CLOSED_REQUEST: 499;
readonly INTERNAL_SERVER_ERROR: 500;
readonly NOT_IMPLEMENTED: 501;
readonly BAD_GATEWAY: 502;
readonly SERVICE_UNAVAILABLE: 503;
readonly GATEWAY_TIMEOUT: 504;
};
export type ORPCErrorCode = keyof typeof ORPC_ERROR_CODE_STATUSES;
export interface ORPCErrorJSON<TCode extends ORPCErrorCode, TData> {
code: TCode;
status: number;
message: string;
data: TData;
issues?: readonly StandardSchemaV1.Issue[];
}
export type ANY_ORPC_ERROR_JSON = ORPCErrorJSON<any, any>;
export type WELL_ORPC_ERROR_JSON = ORPCErrorJSON<ORPCErrorCode, unknown>;
export declare class ORPCError<TCode extends ORPCErrorCode, TData> extends Error {
zz$oe: {
code: TCode;
status?: number;
message?: string;
cause?: unknown;
issues?: readonly StandardSchemaV1.Issue[];
} & (undefined extends TData ? {
data?: TData;
} : {
data: TData;
});
constructor(zz$oe: {
code: TCode;
status?: number;
message?: string;
cause?: unknown;
issues?: readonly StandardSchemaV1.Issue[];
} & (undefined extends TData ? {
data?: TData;
} : {
data: TData;
}));
get code(): TCode;
get status(): number;
get data(): TData;
get issues(): readonly StandardSchemaV1.Issue[] | undefined;
toJSON(): ORPCErrorJSON<TCode, TData>;
static fromJSON(json: unknown): ORPCError<ORPCErrorCode, any> | undefined;
}
export type WELL_ORPC_ERROR = ORPCError<ORPCErrorCode, unknown>;
export declare function convertToStandardError(error: unknown): Error;
export declare function toError(error: unknown): Error;
//# sourceMappingURL=error.d.ts.map
export type AnyFunction = (...args: any[]) => any;
export declare function once<T extends () => any>(fn: T): () => ReturnType<T>;
//# sourceMappingURL=function.d.ts.map

@@ -21,3 +21,3 @@ import type { Arrayable, Promisable } from 'type-fest';

export interface BaseHookMeta<TOutput> {
next: () => Promise<TOutput>;
next(): Promise<TOutput>;
}

@@ -24,0 +24,0 @@ export interface Hooks<TInput, TOutput, TContext, TMeta extends (Record<string, any> & {

@@ -0,4 +1,7 @@

export * from './chain';
export * from './constants';
export * from './error';
export * from './function';
export * from './hook';
export * from './interceptor';
export * from './json';

@@ -9,4 +12,4 @@ export * from './object';

export { isPlainObject } from 'is-what';
export { guard, mapEntries, mapValues, omit, trim } from 'radash';
export { group, guard, mapEntries, mapValues, omit, trim } from 'radash';
export type * from 'type-fest';
//# sourceMappingURL=index.d.ts.map
export type Segment = string | number;
export declare function set(root: Readonly<Record<string, unknown> | unknown[]>, segments: Readonly<Segment[]>, value: unknown): unknown;
export declare function set(root: unknown, segments: Readonly<Segment[]>, value: unknown): unknown;
export declare function get(root: Readonly<Record<string, unknown> | unknown[]>, segments: Readonly<Segment[]>): unknown;

@@ -4,0 +4,0 @@ export declare function findDeepMatches(check: (value: unknown) => boolean, payload: unknown, segments?: Segment[], maps?: Segment[][], values?: unknown[]): {

{
"name": "@orpc/shared",
"type": "module",
"version": "0.0.0-next.aa72097",
"version": "0.0.0-next.ad0709a",
"license": "MIT",

@@ -22,7 +22,2 @@ "homepage": "https://orpc.unnoq.com",

},
"./error": {
"types": "./dist/src/error.d.ts",
"import": "./dist/error.js",
"default": "./dist/error.js"
},
"./🔒/*": {

@@ -44,3 +39,3 @@ "types": "./dist/src/*.d.ts"

"scripts": {
"build": "tsup --clean --sourcemap --entry.index=src/index.ts --entry.error=src/error.ts --format=esm --onSuccess='tsc -b --noCheck'",
"build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
"build:watch": "pnpm run build --watch",

@@ -47,0 +42,0 @@ "type:check": "tsc -b"

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