Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
update effect (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored Oct 10, 2023
1 parent 2711aea commit 9ec4b1d
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 153 deletions.
8 changes: 8 additions & 0 deletions .changeset/wicked-games-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@effect/platform-browser": minor
"@effect/platform-node": minor
"@effect/platform-bun": minor
"@effect/platform": minor
---

update effect
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
"@babel/preset-typescript": "^7.23.0",
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.2",
"@effect/build-utils": "^0.1.8",
"@effect/build-utils": "^0.1.9",
"@effect/docgen": "^0.1.8",
"@effect/eslint-plugin": "^0.1.2",
"@effect/language-service": "0.0.21",
"@preconstruct/cli": "^2.8.1",
"@types/chai": "^4.3.6",
"@types/node": "^20.8.3",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"@types/chai": "^4.3.7",
"@types/node": "^20.8.4",
"@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.5",
"@vitejs/plugin-react": "^4.1.0",
"@vitest/coverage-v8": "^0.34.6",
"@vitest/expect": "^0.34.6",
Expand All @@ -56,6 +56,7 @@
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"ultra-runner": "^3.10.5",
"undici-types": "^5.25.3",
"vite": "^4.4.11",
"vitest": "0.34.6"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/platform-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
"@effect/platform": "workspace:^"
},
"devDependencies": {
"effect": "2.0.0-next.47",
"effect": "2.0.0-next.48",
"vitest-localstorage-mock": "^0.0.1"
},
"peerDependencies": {
"effect": "2.0.0-next.47"
"effect": "2.0.0-next.48"
},
"files": [
"src",
Expand Down
10 changes: 5 additions & 5 deletions packages/platform-bun/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"scripts": {
"example": "ts-node --project tsconfig.examples.json",
"lint": "eslint src/**/*.ts test/**/*.ts",
"tc": "tsc --noEmit",
"tc": "tsc -b",
"test": "vitest",
"coverage": "vitest run --coverage"
},
Expand All @@ -41,12 +41,12 @@
"@effect/platform-node": "workspace:^"
},
"devDependencies": {
"@effect/schema": "^0.42.0",
"bun-types": "1.0.5-canary.20231008T140131",
"effect": "2.0.0-next.47"
"@effect/schema": "^0.43.0",
"bun-types": "1.0.5-canary.20231009T140142",
"effect": "2.0.0-next.48"
},
"peerDependencies": {
"effect": "2.0.0-next.47"
"effect": "2.0.0-next.48"
},
"files": [
"src",
Expand Down
5 changes: 2 additions & 3 deletions packages/platform-bun/src/internal/http/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export const make = (
Effect.async<never, Error.ServeError, never>(() => {
const runFork = Runtime.runFork(runtime)
function handler(request: Request, _server: BunServer) {
console.log(request)
return new Promise<Response>((resolve, reject) => {
const fiber = runFork(Effect.provideService(
app,
Expand Down Expand Up @@ -112,7 +111,7 @@ const makeResponse = (request: ServerRequest.ServerRequest, response: ServerResp
})
}
case "FormData": {
return new Response(body.formData, {
return new Response(body.formData as any, {
status: response.status,
statusText: response.statusText,
headers: response.headers
Expand Down Expand Up @@ -213,7 +212,7 @@ class ServerRequestImpl implements ServerRequest.ServerRequest {

get stream(): Stream.Stream<never, Error.RequestError, Uint8Array> {
return this.source.body
? Stream.fromReadableStream(() => this.source.body!, (_) =>
? Stream.fromReadableStream(() => this.source.body as any, (_) =>
Error.RequestError({
request: this,
reason: "Decode",
Expand Down
6 changes: 3 additions & 3 deletions packages/platform-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
"license": "MIT",
"sideEffects": false,
"devDependencies": {
"@effect/schema": "^0.42.0",
"@effect/schema": "^0.43.0",
"@types/busboy": "^1.5.1",
"@types/mime": "^3.0.2",
"effect": "2.0.0-next.47"
"effect": "2.0.0-next.48"
},
"peerDependencies": {
"effect": "2.0.0-next.47"
"effect": "2.0.0-next.48"
},
"dependencies": {
"@effect/platform": "workspace:^",
Expand Down
7 changes: 1 addition & 6 deletions packages/platform-node/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
/// <reference types="vitest" />
import babel from "@vitejs/plugin-react"
import path from "path"
import * as path from "path"
import { defineConfig } from "vite"

// eslint-disable-next-line @typescript-eslint/no-var-requires
const babelConfig = require("../../.babel.mjs.json")

export default defineConfig({
plugins: [babel({ babel: babelConfig })],
test: {
include: ["./test/**/*.test.ts"],
globals: true
Expand Down
10 changes: 5 additions & 5 deletions packages/platform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@
"license": "MIT",
"sideEffects": false,
"dependencies": {
"find-my-way": "^7.6.2",
"find-my-way": "^7.7.0",
"path-browserify": "^1.0.1"
},
"devDependencies": {
"@effect/schema": "^0.42.0",
"@effect/schema": "^0.43.0",
"@types/path-browserify": "^1.0.0",
"effect": "2.0.0-next.47"
"effect": "2.0.0-next.48"
},
"peerDependencies": {
"@effect/schema": "^0.42.0",
"effect": "2.0.0-next.47"
"@effect/schema": "^0.43.0",
"effect": "2.0.0-next.48"
},
"files": [
"src",
Expand Down
28 changes: 17 additions & 11 deletions packages/platform/src/Http/IncomingMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
*/
import * as ParseResult from "@effect/schema/ParseResult"
import * as Schema from "@effect/schema/Schema"
import * as Context from "effect/Context"
import * as Effect from "effect/Effect"
import * as FiberRef from "effect/FiberRef"
import { dual, flow } from "effect/Function"
import * as Global from "effect/GlobalValue"
import * as Option from "effect/Option"
import type * as Stream from "effect/Stream"
import * as Tracer from "effect/Tracer"
import type { ExternalSpan } from "effect/Tracer"
import * as FileSystem from "../FileSystem"
import type * as Headers from "./Headers"
Expand Down Expand Up @@ -74,7 +74,8 @@ export const schemaHeaders = <I extends Readonly<Record<string, string>>, A>(sch
const SpanSchema = Schema.struct({
traceId: Schema.string,
spanId: Schema.string,
parentSpanId: Schema.union(Schema.string, Schema.undefined)
parentSpanId: Schema.union(Schema.string, Schema.undefined),
sampled: Schema.boolean
})

/**
Expand All @@ -94,6 +95,7 @@ export const schemaExternalSpan = flow(
return ParseResult.success({
traceId: parts[0],
spanId: parts[1],
sampled: parts[2] ? parts[2] === "1" : true,
parentSpanId: parts[3]
})
}
Expand All @@ -105,27 +107,31 @@ export const schemaExternalSpan = flow(
Schema.struct({
"x-b3-traceid": Schema.NonEmpty,
"x-b3-spanid": Schema.NonEmpty,
"x-b3-parentspanid": Schema.optional(Schema.NonEmpty)
"x-b3-parentspanid": Schema.optional(Schema.NonEmpty),
"x-b3-sampled": Schema.optional(Schema.NonEmpty).withDefault(() => "1")
}),
SpanSchema,
(_) => ({
traceId: _["x-b3-traceid"],
spanId: _["x-b3-spanid"],
parentSpanId: _["x-b3-parentspanid"]
parentSpanId: _["x-b3-parentspanid"],
sampled: _["x-b3-sampled"] === "1"
}),
(_) => ({
"x-b3-traceid": _.traceId,
"x-b3-spanid": _.spanId,
"x-b3-parentspanid": _.parentSpanId
"x-b3-parentspanid": _.parentSpanId,
"x-b3-sampled": _.sampled ? "1" : "0"
})
)
)),
Effect.map((_): ExternalSpan => ({
_tag: "ExternalSpan",
traceId: _.traceId,
spanId: _.spanId,
context: Context.empty()
}))
Effect.map((_): ExternalSpan =>
Tracer.externalSpan({
traceId: _.traceId,
spanId: _.spanId,
sampled: _.sampled
})
)
)

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/platform/src/internal/http/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export const withB3Propagation = <R, E>(
Effect.flatMap(self),
Effect.tap((res) =>
Effect.ignore(
Effect.flatMap(IncomingMessage.schemaExternalSpan(res), Effect.withParentSpanScoped)
Effect.flatMap(IncomingMessage.schemaExternalSpan(res), Effect.setParentSpan)
)
)
)
Expand Down
Loading

0 comments on commit 9ec4b1d

Please sign in to comment.