Socket
Socket
Sign inDemoInstall

@effect/rpc-http

Package Overview
Dependencies
Maintainers
3
Versions
267
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@effect/rpc-http - npm Package Compare versions

Comparing version 0.0.0 to 0.1.0

Client.d.ts

21

internal/resolver.js

@@ -6,14 +6,24 @@ "use strict";

});
exports.RpcFetchError = void 0;
exports.make = make;
var Effect = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Effect"));
var _Error = /*#__PURE__*/require("@effect/rpc/Error");
var Resolver = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/rpc/Resolver"));
var _SchemaC = /*#__PURE__*/require("@effect/rpc/SchemaC");
var S = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/schema/Schema"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const RpcFetchError_ = /*#__PURE__*/(0, _SchemaC.withConstructorTagged)( /*#__PURE__*/S.struct({
_tag: /*#__PURE__*/S.literal("RpcFetchError"),
reason: /*#__PURE__*/S.union( /*#__PURE__*/S.literal("FetchError"), /*#__PURE__*/S.literal("JsonDecodeError")),
error: S.unknown
}), "RpcFetchError");
/** @internal */
const RpcFetchError = /*#__PURE__*/(0, _SchemaC.withTo)()(RpcFetchError_);
/** @internal */
exports.RpcFetchError = RpcFetchError;
function make(options) {
return Resolver.make(requests => Effect.mapError(error => ({
_tag: "RpcTransportError",
return Resolver.make(requests => Effect.mapError(error => (0, _Error.RpcTransportError)({
error
}))(Effect.flatMap(response => Effect.tryCatchPromise(() => response.json(), error => ({
_tag: "RpcFetchError",
}))(Effect.flatMap(response => Effect.tryCatchPromise(() => response.json(), error => RpcFetchError({
reason: "JsonDecodeError",

@@ -31,4 +41,3 @@ error

});
}, error => ({
_tag: "RpcFetchError",
}, error => RpcFetchError({
reason: "FetchError",

@@ -35,0 +44,0 @@ error

{
"name": "@effect/rpc-http",
"version": "0.0.0",
"version": "0.1.0",
"license": "MIT",

@@ -11,4 +11,4 @@ "repository": {

"@effect/data": "^0.12.2",
"@effect/io": "^0.22.4",
"@effect/rpc": "0.0.0"
"@effect/io": "^0.25.5",
"@effect/rpc": "0.1.0"
},

@@ -15,0 +15,0 @@ "main": "./index.js",

import type { RpcResolver } from "@effect/rpc/Resolver";
import type { SchemaC } from "@effect/rpc/SchemaC";
/**

@@ -11,3 +12,3 @@ * @category models

/**
* @category models
* @category errors
* @since 1.0.0

@@ -21,2 +22,10 @@ */

/**
* @category errors
* @since 1.0.0
*/
export declare const RpcFetchError: SchemaC<RpcFetchError, RpcFetchError, {
readonly reason: "FetchError" | "JsonDecodeError";
readonly error: unknown;
}>;
/**
* @category constructors

@@ -23,0 +32,0 @@ * @since 1.0.0

@@ -6,3 +6,3 @@ "use strict";

});
exports.make = void 0;
exports.make = exports.RpcFetchError = void 0;
var internal = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/rpc-http/internal/resolver"));

@@ -16,7 +16,13 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

/**
* @category errors
* @since 1.0.0
*/
const RpcFetchError = internal.RpcFetchError;
/**
* @category constructors
* @since 1.0.0
*/
exports.RpcFetchError = RpcFetchError;
const make = internal.make;
exports.make = make;
//# sourceMappingURL=Resolver.js.map

@@ -8,3 +8,3 @@ /**

import type { RpcResponse } from "@effect/rpc/Resolver";
import type { RpcHandlers, RpcRouter } from "@effect/rpc/Server";
import type { RpcHandlers, RpcRouter } from "@effect/rpc/Router";
/**

@@ -11,0 +11,0 @@ * @category models

import { pipe } from "@effect/data/Function"
import * as Effect from "@effect/io/Effect"
import type {
FetchResolverOptions,
RpcFetchError,
} from "@effect/rpc-http/Resolver"
import type { RpcTransportError } from "@effect/rpc/Error"
import type * as resolver from "@effect/rpc-http/Resolver"
import { RpcTransportError } from "@effect/rpc/Error"
import * as Resolver from "@effect/rpc/Resolver"
import { withConstructorTagged, withTo } from "@effect/rpc/SchemaC"
import * as S from "@effect/schema/Schema"
const RpcFetchError_ = withConstructorTagged(
S.struct({
_tag: S.literal("RpcFetchError"),
reason: S.union(S.literal("FetchError"), S.literal("JsonDecodeError")),
error: S.unknown,
}),
"RpcFetchError",
)
/** @internal */
export const RpcFetchError = withTo<resolver.RpcFetchError>()(RpcFetchError_)
/** @internal */
export function make(
options: FetchResolverOptions,
options: resolver.FetchResolverOptions,
): Resolver.RpcResolver<never> {

@@ -28,7 +39,3 @@ return Resolver.make((requests) =>

},
(error): RpcFetchError => ({
_tag: "RpcFetchError",
reason: "FetchError",
error,
}),
(error) => RpcFetchError({ reason: "FetchError", error }),
),

@@ -38,17 +45,8 @@ Effect.flatMap((response) =>

() => response.json(),
(error): RpcFetchError => ({
_tag: "RpcFetchError",
reason: "JsonDecodeError",
error,
}),
(error) => RpcFetchError({ reason: "JsonDecodeError", error }),
),
),
Effect.mapError(
(error): RpcTransportError => ({
_tag: "RpcTransportError",
error,
}),
),
Effect.mapError((error) => RpcTransportError({ error })),
),
)
}
import { Tag } from "@effect/data/Context"
import * as Effect from "@effect/io/Effect"
import type * as server from "@effect/rpc-http/Server"
import type { RpcRouter } from "@effect/rpc/Server"
import type { RpcRouter } from "@effect/rpc/Router"
import * as Server from "@effect/rpc/Server"

@@ -6,0 +6,0 @@

@@ -6,2 +6,3 @@ /**

import type { RpcResolver } from "@effect/rpc/Resolver"
import type { SchemaC } from "@effect/rpc/SchemaC"

@@ -18,3 +19,3 @@ /**

/**
* @category models
* @category errors
* @since 1.0.0

@@ -29,2 +30,12 @@ */

/**
* @category errors
* @since 1.0.0
*/
export const RpcFetchError: SchemaC<
RpcFetchError,
RpcFetchError,
{ readonly reason: "FetchError" | "JsonDecodeError"; readonly error: unknown }
> = internal.RpcFetchError
/**
* @category constructors

@@ -31,0 +42,0 @@ * @since 1.0.0

@@ -9,3 +9,3 @@ /**

import type { RpcResponse } from "@effect/rpc/Resolver"
import type { RpcHandlers, RpcRouter } from "@effect/rpc/Server"
import type { RpcHandlers, RpcRouter } from "@effect/rpc/Router"

@@ -45,2 +45,2 @@ /**

export const make: <R extends RpcRouter.Base>(router: R) => RpcHttpHandler<R> =
internal.make
internal.make as any
{
"extends": "../../tsconfig.base.json",
"references": [
{ "path": "./tsconfig.build.json" },
{ "path": "./tsconfig.test.json" },
{ "path": "./tsconfig.examples.json" }
]
}
"extends": "../../tsconfig.base.json",
"references": [
{ "path": "./tsconfig.build.json" },
{ "path": "./tsconfig.test.json" }
]
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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