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

@effect/platform

Package Overview
Dependencies
Maintainers
3
Versions
399
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@effect/platform - npm Package Compare versions

Comparing version 0.25.1 to 0.26.0

dist/Client-77da56b5.cjs.dev.js

20

dist/declarations/src/Http/Client.d.ts

@@ -30,4 +30,6 @@ /**

export interface Client<R, E, A> extends Pipeable {
(request: ClientRequest.ClientRequest): Effect.Effect<R, E, A>;
readonly [TypeId]: TypeId;
(request: ClientRequest.ClientRequest): Effect.Effect<R, E, A>;
readonly preprocess: Client.Preprocess<R, E>;
readonly execute: Client.Execute<R, E, A>;
}

@@ -42,2 +44,12 @@ /**

*/
type Preprocess<R, E> = (request: ClientRequest.ClientRequest) => Effect.Effect<R, E, ClientRequest.ClientRequest>;
/**
* @since 1.0.0
* @category models
*/
type Execute<R, E, A> = (request: Effect.Effect<R, E, ClientRequest.ClientRequest>) => Effect.Effect<R, E, A>;
/**
* @since 1.0.0
* @category models
*/
type WithResponse<R, E> = Client<R, E, ClientResponse.ClientResponse>;

@@ -167,3 +179,3 @@ /**

*/
export declare const make: <R, E, A>(f: (request: ClientRequest.ClientRequest) => Effect.Effect<R, E, A>) => Client<R, E, A>;
export declare const make: <R, E, A, R2, E2>(execute: (request: Effect.Effect<R2, E2, ClientRequest.ClientRequest>) => Effect.Effect<R, E, A>, preprocess: Client.Preprocess<R2, E2>) => Client<R, E, A>;
/**

@@ -179,4 +191,4 @@ * @since 1.0.0

export declare const transform: {
<R, E, A, R1, E1, A1>(f: (client: Client<R, E, A>) => (request: ClientRequest.ClientRequest) => Effect.Effect<R1, E1, A1>): (self: Client<R, E, A>) => Client<R1, E1, A1>;
<R, E, A, R1, E1, A1>(self: Client<R, E, A>, f: (client: Client<R, E, A>) => (request: ClientRequest.ClientRequest) => Effect.Effect<R1, E1, A1>): Client<R1, E1, A1>;
<R, E, A, R1, E1, A1>(f: (effect: Effect.Effect<R, E, A>, request: ClientRequest.ClientRequest) => Effect.Effect<R1, E1, A1>): (self: Client<R, E, A>) => Client<R | R1, E | E1, A1>;
<R, E, A, R1, E1, A1>(self: Client<R, E, A>, f: (effect: Effect.Effect<R, E, A>, request: ClientRequest.ClientRequest) => Effect.Effect<R1, E1, A1>): Client<R | R1, E | E1, A1>;
};

@@ -183,0 +195,0 @@ /**

2

Http/Client/dist/effect-platform-Http-Client.cjs.dev.js

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

var Http_Client_dist_effectPlatformHttpClient = require('../../../dist/Client-9ce8428f.cjs.dev.js');
var Http_Client_dist_effectPlatformHttpClient = require('../../../dist/Client-77da56b5.cjs.dev.js');
require('@effect/schema/Schema');

@@ -8,0 +8,0 @@ require('effect/Context');

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

var Http_Client_dist_effectPlatformHttpClient = require('../../../dist/Client-58fdb5b3.cjs.prod.js');
var Http_Client_dist_effectPlatformHttpClient = require('../../../dist/Client-d31ac2bf.cjs.prod.js');
require('@effect/schema/Schema');

@@ -8,0 +8,0 @@ require('effect/Context');

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

export { a as Client, T as TypeId, c as catchAll, d as catchTag, e as catchTags, f as fetch, b as fetchOk, g as filterOrElse, h as filterOrFail, i as filterStatus, j as filterStatusOk, l as layer, m as make, k as makeDefault, o as map, p as mapEffect, q as mapRequest, r as mapRequestEffect, s as retry, u as schemaFunction, v as tap, w as tapRequest, t as transform, n as transformResponse } from '../../../dist/Client-37e710a6.esm.js';
export { a as Client, T as TypeId, c as catchAll, d as catchTag, e as catchTags, f as fetch, b as fetchOk, g as filterOrElse, h as filterOrFail, i as filterStatus, j as filterStatusOk, l as layer, m as make, k as makeDefault, o as map, p as mapEffect, q as mapRequest, r as mapRequestEffect, s as retry, u as schemaFunction, v as tap, w as tapRequest, t as transform, n as transformResponse } from '../../../dist/Client-ed53ec74.esm.js';
import '@effect/schema/Schema';

@@ -3,0 +3,0 @@ import 'effect/Context';

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

var Http_Body_dist_effectPlatformHttpBody = require('../../dist/Body-f4eb1a35.cjs.dev.js');
var Http_Client_dist_effectPlatformHttpClient = require('../../dist/Client-9ce8428f.cjs.dev.js');
var Http_Client_dist_effectPlatformHttpClient = require('../../dist/Client-77da56b5.cjs.dev.js');
var Http_ClientError_dist_effectPlatformHttpClientError = require('../../dist/ClientError-b7828377.cjs.dev.js');

@@ -9,0 +9,0 @@ var Http_ClientRequest_dist_effectPlatformHttpClientRequest = require('../../dist/ClientRequest-4c64deb3.cjs.dev.js');

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

var Http_Body_dist_effectPlatformHttpBody = require('../../dist/Body-bf109de0.cjs.prod.js');
var Http_Client_dist_effectPlatformHttpClient = require('../../dist/Client-58fdb5b3.cjs.prod.js');
var Http_Client_dist_effectPlatformHttpClient = require('../../dist/Client-d31ac2bf.cjs.prod.js');
var Http_ClientError_dist_effectPlatformHttpClientError = require('../../dist/ClientError-22781879.cjs.prod.js');

@@ -9,0 +9,0 @@ var Http_ClientRequest_dist_effectPlatformHttpClientRequest = require('../../dist/ClientRequest-71df9f94.cjs.prod.js');

export { B as body } from '../../dist/Body-e69a4f4c.esm.js';
export { C as client } from '../../dist/Client-37e710a6.esm.js';
export { C as client } from '../../dist/Client-ed53ec74.esm.js';
export { C as error } from '../../dist/ClientError-98b5da8c.esm.js';

@@ -4,0 +4,0 @@ export { C as request } from '../../dist/ClientRequest-dc3e2234.esm.js';

{
"name": "@effect/platform",
"version": "0.25.1",
"version": "0.26.0",
"description": "Unified interfaces for common platform-specific services",

@@ -5,0 +5,0 @@ "main": "dist/effect-platform.cjs.js",

@@ -34,4 +34,6 @@ /**

export interface Client<R, E, A> extends Pipeable {
(request: ClientRequest.ClientRequest): Effect.Effect<R, E, A>
readonly [TypeId]: TypeId
(request: ClientRequest.ClientRequest): Effect.Effect<R, E, A>
readonly preprocess: Client.Preprocess<R, E>
readonly execute: Client.Execute<R, E, A>
}

@@ -47,2 +49,18 @@

*/
export type Preprocess<R, E> = (
request: ClientRequest.ClientRequest
) => Effect.Effect<R, E, ClientRequest.ClientRequest>
/**
* @since 1.0.0
* @category models
*/
export type Execute<R, E, A> = (
request: Effect.Effect<R, E, ClientRequest.ClientRequest>
) => Effect.Effect<R, E, A>
/**
* @since 1.0.0
* @category models
*/
export type WithResponse<R, E> = Client<R, E, ClientResponse.ClientResponse>

@@ -207,4 +225,6 @@

*/
export const make: <R, E, A>(f: (request: ClientRequest.ClientRequest) => Effect.Effect<R, E, A>) => Client<R, E, A> =
internal.make
export const make: <R, E, A, R2, E2>(
execute: (request: Effect.Effect<R2, E2, ClientRequest.ClientRequest>) => Effect.Effect<R, E, A>,
preprocess: Client.Preprocess<R2, E2>
) => Client<R, E, A> = internal.make

@@ -227,8 +247,8 @@ /**

<R, E, A, R1, E1, A1>(
f: (client: Client<R, E, A>) => (request: ClientRequest.ClientRequest) => Effect.Effect<R1, E1, A1>
): (self: Client<R, E, A>) => Client<R1, E1, A1>
f: (effect: Effect.Effect<R, E, A>, request: ClientRequest.ClientRequest) => Effect.Effect<R1, E1, A1>
): (self: Client<R, E, A>) => Client<R | R1, E | E1, A1>
<R, E, A, R1, E1, A1>(
self: Client<R, E, A>,
f: (client: Client<R, E, A>) => (request: ClientRequest.ClientRequest) => Effect.Effect<R1, E1, A1>
): Client<R1, E1, A1>
f: (effect: Effect.Effect<R, E, A>, request: ClientRequest.ClientRequest) => Effect.Effect<R1, E1, A1>
): Client<R | R1, E | E1, A1>
} = internal.transform

@@ -235,0 +255,0 @@

@@ -38,30 +38,29 @@ import type * as ParseResult from "@effect/schema/ParseResult"

/** @internal */
export const make = <R, E, A>(
f: (request: ClientRequest.ClientRequest) => Effect.Effect<R, E, A>
) => {
Object.setPrototypeOf(f, clientProto)
return f as Client.Client<R, E, A>
export const make = <R, E, A, R2, E2>(
execute: (request: Effect.Effect<R2, E2, ClientRequest.ClientRequest>) => Effect.Effect<R, E, A>,
preprocess: Client.Client.Preprocess<R2, E2>
): Client.Client<R, E, A> => {
function client(request: ClientRequest.ClientRequest) {
return execute(preprocess(request))
}
Object.setPrototypeOf(client, clientProto)
;(client as any).preprocess = preprocess
;(client as any).execute = execute
return client as any
}
const withB3Propagation = <R, E>(
self: Client.Client.WithResponse<R, E>
): Client.Client.WithResponse<R, E> =>
make((req) =>
Effect.flatMap(
Effect.map(
Effect.currentSpan,
Option.match({
onNone: () => req,
onSome: (span) =>
internalRequest.setHeader(
req,
"b3",
`${span.traceId}-${span.spanId}-${span.sampled ? "1" : "0"}${
span.parent._tag === "Some" ? `-${span.parent.value.spanId}` : ""
}`
)
})
),
self
)
const addB3Headers = (req: ClientRequest.ClientRequest) =>
Effect.map(
Effect.currentSpan,
Option.match({
onNone: () => req,
onSome: (span) =>
internalRequest.setHeader(
req,
"b3",
`${span.traceId}-${span.spanId}-${span.sampled ? "1" : "0"}${
span.parent._tag === "Some" ? `-${span.parent.value.spanId}` : ""
}`
)
})
)

@@ -74,3 +73,3 @@

) => Effect.Effect<never, Error.HttpClientError, ClientResponse.ClientResponse>
): Client.Client.Default => withB3Propagation(make(f))
): Client.Client.Default => make(Effect.flatMap(f), addB3Headers)

@@ -146,9 +145,16 @@ /** @internal */

<R, E, A, R1, E1, A1>(
f: (client: Client.Client<R, E, A>) => (request: ClientRequest.ClientRequest) => Effect.Effect<R1, E1, A1>
) => (self: Client.Client<R, E, A>) => Client.Client<R1, E1, A1>,
f: (effect: Effect.Effect<R, E, A>, request: ClientRequest.ClientRequest) => Effect.Effect<R1, E1, A1>
) => (self: Client.Client<R, E, A>) => Client.Client<R | R1, E | E1, A1>,
<R, E, A, R1, E1, A1>(
self: Client.Client<R, E, A>,
f: (client: Client.Client<R, E, A>) => (request: ClientRequest.ClientRequest) => Effect.Effect<R1, E1, A1>
) => Client.Client<R1, E1, A1>
>(2, (self, f) => make(f(self)))
f: (effect: Effect.Effect<R, E, A>, request: ClientRequest.ClientRequest) => Effect.Effect<R1, E1, A1>
) => Client.Client<R | R1, E | E1, A1>
>(
2,
(self, f) =>
make(
Effect.flatMap((request) => f(self.execute(Effect.succeed(request)), request)),
self.preprocess
)
)

@@ -164,3 +170,3 @@ /** @internal */

) => Client.Client<R1, E1, A1>
>(2, (self, f) => make((request) => f(self(request))))
>(2, (self, f) => make((request) => f(self.execute(request)), self.preprocess))

@@ -186,4 +192,3 @@ /** @internal */

f: (e: Extract<E, { _tag: K }>) => Effect.Effect<R1, E1, A1>
): Client.Client<R1 | R, E1 | Exclude<E, { _tag: K }>, A1 | A> =>
make((request) => Effect.catchTag(self(request), tag, f))
): Client.Client<R1 | R, E1 | Exclude<E, { _tag: K }>, A1 | A> => transformResponse(self, Effect.catchTag(tag, f))
)

@@ -295,3 +300,3 @@

}[keyof Cases]
> => make((request) => Effect.catchTags(self(request), cases))
> => transformResponse(self, Effect.catchTags(cases))
)

@@ -313,3 +318,3 @@

f: (e: E) => Effect.Effect<R2, E2, A2>
): Client.Client<R | R2, E2, A2 | A> => make((request) => Effect.catchAll(self(request), f))
): Client.Client<R | R2, E2, A2 | A> => transformResponse(self, Effect.catchAll(f))
)

@@ -327,3 +332,3 @@

) => Client.Client<R2 | R, E2 | E, A | B>
>(3, (self, f, orElse) => make((request) => Effect.filterOrElse(self(request), f, orElse)))
>(3, (self, f, orElse) => transformResponse(self, Effect.filterOrElse(f, orElse)))

@@ -340,3 +345,3 @@ /** @internal */

) => Client.Client<R, E2 | E, A>
>(3, (self, f, orFailWith) => make((request) => Effect.filterOrFail(self(request), f, orFailWith)))
>(3, (self, f, orFailWith) => transformResponse(self, Effect.filterOrFail(f, orFailWith)))

@@ -355,5 +360,5 @@ /** @internal */

(self, f) =>
make((request) =>
transform(self, (effect, request) =>
Effect.filterOrFail(
self(request),
effect,
(response) => f(response.status),

@@ -367,4 +372,3 @@ (response) =>

})
)
)
))
)

@@ -386,3 +390,3 @@

) => Client.Client<R, E, B>
>(2, (self, f) => make((request) => Effect.map(self(request), f)))
>(2, (self, f) => transformResponse(self, Effect.map(f)))

@@ -398,3 +402,3 @@ /** @internal */

) => Client.Client<R | R2, E | E2, B>
>(2, (self, f) => make((request) => Effect.flatMap(self(request), f)))
>(2, (self, f) => transformResponse(self, Effect.flatMap(f)))

@@ -410,3 +414,3 @@ /** @internal */

) => Client.Client<R, E, A>
>(2, (self, f) => make((request) => self(f(request))))
>(2, (self, f) => make(self.execute, (request) => Effect.map(self.preprocess(request), f)))

@@ -422,3 +426,3 @@ /** @internal */

) => Client.Client<R | R2, E | E2, A>
>(2, (self, f) => make((request) => Effect.flatMap(f(request), self)))
>(2, (self, f) => make(self.execute as any, (request) => Effect.flatMap(self.preprocess(request), f)))

@@ -439,3 +443,3 @@ /** @internal */

policy: Schedule.Schedule<R1, E0, B>
): Client.Client<R | R1, E, A> => make((request) => Effect.retry(self(request), policy))
): Client.Client<R | R1, E, A> => transformResponse(self, Effect.retry(policy))
)

@@ -488,3 +492,3 @@

) => Client.Client<R | R2, E | E2, A>
>(2, (self, f) => make((request) => Effect.tap(self(request), f)))
>(2, (self, f) => transformResponse(self, Effect.tap(f)))

@@ -500,2 +504,2 @@ /** @internal */

) => Client.Client<R | R2, E | E2, A>
>(2, (self, f) => make((request) => Effect.zipRight(f(request), self(request))))
>(2, (self, f) => make(self.execute as any, (request) => Effect.tap(self.preprocess(request), f)))

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