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

Commit

Permalink
update effect (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored Nov 30, 2023
1 parent 92e56a1 commit 078fe2d
Show file tree
Hide file tree
Showing 28 changed files with 859 additions and 703 deletions.
23 changes: 9 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,33 @@
},
"devDependencies": {
"@babel/cli": "^7.23.4",
"@babel/core": "^7.23.3",
"@babel/core": "^7.23.5",
"@babel/plugin-transform-export-namespace-from": "^7.23.4",
"@babel/plugin-transform-modules-commonjs": "^7.23.3",
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.2",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.1",
"@effect/build-utils": "^0.5.0",
"@effect/docgen": "^0.3.5",
"@effect/docgen": "^0.3.6",
"@effect/eslint-plugin": "^0.1.2",
"@effect/language-service": "^0.0.21",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/parser": "^6.12.0",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"@vitest/coverage-v8": "^0.34.6",
"@vitest/web-worker": "^0.34.6",
"babel-plugin-annotate-pure-calls": "^0.4.0",
"eslint": "^8.54.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-codegen": "^0.18.1",
"eslint-plugin-codegen": "^0.21.0",
"eslint-plugin-deprecation": "^2.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-sort-destructure-keys": "^1.5.0",
"glob": "^10.3.10",
"madge": "^6.1.0",
"prettier": "^3.1.0",
"tsx": "^4.1.4",
"tsx": "^4.6.1",
"typescript": "^5.3.2",
"vite": "^5.0.0",
"vite": "^5.0.4",
"vitest": "^0.34.6"
},
"pnpm": {
"patchedDependencies": {
"@changesets/[email protected]": "patches/@[email protected]"
}
}
}
4 changes: 2 additions & 2 deletions packages/platform-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
"@effect/platform": "workspace:*"
},
"peerDependencies": {
"effect": "2.0.0-next.56"
"effect": "2.0.0-next.57"
},
"devDependencies": {
"effect": "2.0.0-next.56",
"effect": "2.0.0-next.57",
"happy-dom": "^12.10.3"
}
}
2 changes: 1 addition & 1 deletion packages/platform-browser/src/internal/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const platformWorkerImpl = Worker.PlatformWorker.of({
export const layerWorker = Layer.succeed(Worker.PlatformWorker, platformWorkerImpl)

/** @internal */
export const layerManager = Layer.provide(layerWorker, Worker.layerManager)
export const layerManager = Layer.provide(Worker.layerManager, layerWorker)

/** @internal */
export const makePool = Worker.makePool<globalThis.Worker | globalThis.SharedWorker>()
Expand Down
2 changes: 1 addition & 1 deletion packages/platform-bun/examples/http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const makeTodoService = Effect.gen(function*(_) {
})

const TodoServiceLive = Layer.effect(TodoService, makeTodoService).pipe(
Layer.use(Http.client.layer)
Layer.provide(Http.client.layer)
)

Effect.flatMap(
Expand Down
8 changes: 4 additions & 4 deletions packages/platform-bun/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
"@effect/platform-node": "workspace:*"
},
"peerDependencies": {
"effect": "2.0.0-next.56"
"effect": "2.0.0-next.57"
},
"devDependencies": {
"@effect/schema": "^0.49.0",
"bun-types": "^1.0.13",
"effect": "2.0.0-next.56"
"@effect/schema": "^0.51.0",
"bun-types": "^1.0.14",
"effect": "2.0.0-next.57"
}
}
12 changes: 7 additions & 5 deletions packages/platform-bun/src/BunContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ export type BunContext =
* @category layer
*/
export const layer: Layer.Layer<never, never, BunContext> = pipe(
FileSystem.layer,
Layer.merge(Path.layer),
Layer.merge(Layer.provideMerge(FileSystem.layer, CommandExecutor.layer)),
Layer.merge(Terminal.layer),
Layer.merge(Worker.layerManager)
Layer.mergeAll(
Path.layer,
CommandExecutor.layer,
Terminal.layer,
Worker.layerManager
),
Layer.provideMerge(FileSystem.layer)
)
4 changes: 2 additions & 2 deletions packages/platform-bun/src/internal/http/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export const make = Platform.make({
/** @internal */
export const layer = pipe(
Layer.effect(Platform.Platform, make),
Layer.use(FileSystem.layer),
Layer.use(Etag.layer)
Layer.provide(FileSystem.layer),
Layer.provide(Etag.layer)
)
2 changes: 1 addition & 1 deletion packages/platform-bun/src/internal/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const platformWorkerImpl = Worker.PlatformWorker.of({
export const layerWorker = Layer.succeed(Worker.PlatformWorker, platformWorkerImpl)

/** @internal */
export const layerManager = Layer.provide(layerWorker, Worker.layerManager)
export const layerManager = Layer.provide(Worker.layerManager, layerWorker)

/** @internal */
export const makePool = Worker.makePool<globalThis.Worker>()
Expand Down
2 changes: 1 addition & 1 deletion packages/platform-node/examples/http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const makeTodoService = Effect.gen(function*(_) {
})

const TodoServiceLive = Layer.effect(TodoService, makeTodoService).pipe(
Layer.use(Http.client.layer)
Layer.provide(Http.client.layer)
)

Effect.flatMap(
Expand Down
4 changes: 2 additions & 2 deletions packages/platform-node/examples/http-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const serve = Http.router.empty.pipe(
)

const HttpLive = Layer.scopedDiscard(serve).pipe(
Layer.use(ServerLive),
Layer.use(NodeContext.layer)
Layer.provide(ServerLive),
Layer.provide(NodeContext.layer)
)

Layer.launch(HttpLive).pipe(
Expand Down
12 changes: 6 additions & 6 deletions packages/platform-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@
},
"dependencies": {
"@effect/platform": "workspace:*",
"mime": "^3.0.0",
"mime": "^4.0.0",
"multipasta": "^0.1.19"
},
"peerDependencies": {
"effect": "2.0.0-next.56"
"effect": "2.0.0-next.57"
},
"devDependencies": {
"@effect/schema": "^0.49.0",
"@effect/schema": "^0.51.0",
"@types/mime": "^3.0.4",
"@types/node": "^20.9.2",
"@types/tar": "^6.1.9",
"effect": "2.0.0-next.56",
"@types/node": "^20.10.1",
"@types/tar": "^6.1.10",
"effect": "2.0.0-next.57",
"tar": "^6.2.0"
}
}
4 changes: 2 additions & 2 deletions packages/platform-node/src/KeyValueStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export const layerFileSystem: (
directory: string
) => Layer.Layer<never, PlatformError.PlatformError, KeyValueStore.KeyValueStore> = (directory: string) =>
Layer.provide(
Layer.merge(FileSystem.layer, Path.layer),
KeyValueStore.layerFileSystem(directory)
KeyValueStore.layerFileSystem(directory),
Layer.merge(FileSystem.layer, Path.layer)
)
12 changes: 7 additions & 5 deletions packages/platform-node/src/NodeContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ export type NodeContext =
* @category layer
*/
export const layer: Layer.Layer<never, never, NodeContext> = pipe(
FileSystem.layer,
Layer.merge(Path.layer),
Layer.merge(Layer.provideMerge(FileSystem.layer, CommandExecutor.layer)),
Layer.merge(Terminal.layer),
Layer.merge(Worker.layerManager)
Layer.mergeAll(
Path.layer,
CommandExecutor.layer,
Terminal.layer,
Worker.layerManager
),
Layer.provideMerge(FileSystem.layer)
)
2 changes: 1 addition & 1 deletion packages/platform-node/src/internal/http/nodeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,4 @@ export const make = Effect.map(HttpAgent, fromAgent)
export const layerWithoutAgent = Layer.effect(Client.Client, make)

/** @internal */
export const layer = Layer.provide(agentLayer, layerWithoutAgent)
export const layer = Layer.provide(layerWithoutAgent, agentLayer)
4 changes: 2 additions & 2 deletions packages/platform-node/src/internal/http/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ export const make = Platform.make({
/** @internal */
export const layer = pipe(
Layer.effect(Platform.Platform, make),
Layer.use(FileSystem.layer),
Layer.use(Etag.layer)
Layer.provide(FileSystem.layer),
Layer.provide(Etag.layer)
)
2 changes: 1 addition & 1 deletion packages/platform-node/src/internal/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const platformWorkerImpl = Worker.PlatformWorker.of({
export const layerWorker = Layer.succeed(Worker.PlatformWorker, platformWorkerImpl)

/** @internal */
export const layerManager = Layer.provide(layerWorker, Worker.layerManager)
export const layerManager = Layer.provide(Worker.layerManager, layerWorker)

/** @internal */
export const makePool = Worker.makePool<WorkerThreads.Worker>()
Expand Down
4 changes: 2 additions & 2 deletions packages/platform-node/test/Command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import { describe, expect, it } from "vitest"

const TEST_BASH_SCRIPTS_PATH = [__dirname, "fixtures", "bash"]

const TestLive = FileSystem.layer.pipe(
Layer.provideMerge(CommandExecutor.layer),
const TestLive = CommandExecutor.layer.pipe(
Layer.provideMerge(FileSystem.layer),
Layer.merge(Path.layer)
)

Expand Down
4 changes: 2 additions & 2 deletions packages/platform-node/test/Http/NodeClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const makeJsonPlaceholder = Effect.gen(function*(_) {
interface JsonPlaceholder extends Effect.Effect.Success<typeof makeJsonPlaceholder> {}
const JsonPlaceholder = Context.Tag<JsonPlaceholder>()
const JsonPlaceholderLive = Layer.provide(
NodeClient.layer,
Layer.effect(JsonPlaceholder, makeJsonPlaceholder)
Layer.effect(JsonPlaceholder, makeJsonPlaceholder),
NodeClient.layer
)

describe("HttpClient", () => {
Expand Down
4 changes: 3 additions & 1 deletion packages/platform-node/test/HttpServer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const EnvLive = Layer.mergeAll(
NodeContext.layer,
Etag.layer,
ServerLive,
Layer.provide(HttpC.nodeClient.makeAgentLayer({ keepAlive: false }), HttpC.nodeClient.layerWithoutAgent)
HttpC.nodeClient.layerWithoutAgent
).pipe(
Layer.provide(HttpC.nodeClient.makeAgentLayer({ keepAlive: false }))
)
const runPromise = <E, A>(
effect: Effect.Effect<
Expand Down
8 changes: 4 additions & 4 deletions packages/platform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
"path-browserify": "^1.0.1"
},
"peerDependencies": {
"@effect/schema": "^0.49.0",
"effect": "2.0.0-next.56"
"@effect/schema": "^0.51.0",
"effect": "2.0.0-next.57"
},
"devDependencies": {
"@effect/schema": "^0.49.0",
"@effect/schema": "^0.51.0",
"@types/path-browserify": "^1.0.2",
"effect": "2.0.0-next.56"
"effect": "2.0.0-next.57"
}
}
6 changes: 3 additions & 3 deletions packages/platform/src/Http/IncomingMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ export const schemaExternalSpan = flow(
(_) => {
const parts = _.b3.split("-")
if (parts.length >= 2) {
return ParseResult.success({
return ParseResult.succeed({
traceId: parts[0],
spanId: parts[1],
sampled: parts[2] ? parts[2] === "1" : true,
parentSpanId: parts[3]
})
}
return ParseResult.failure(ParseResult.missing)
return ParseResult.fail(ParseResult.missing)
},
(_) => ParseResult.success({ b3: "" })
(_) => ParseResult.succeed({ b3: "" })
),
Schema.transform(
Schema.struct({
Expand Down
Loading

0 comments on commit 078fe2d

Please sign in to comment.