Skip to content

Commit

Permalink
feat: add QuerySchema.number and update @effect/platform packages (#…
Browse files Browse the repository at this point in the history
…628)

* feat: QuerySchema.number

* chore: update @effect/platform packages
  • Loading branch information
sukovanej authored Jul 16, 2024
1 parent bc9b1a8 commit 8481868
Show file tree
Hide file tree
Showing 9 changed files with 237 additions and 177 deletions.
5 changes: 5 additions & 0 deletions .changeset/gentle-bats-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect-http": patch
---

Add `QuerySchema.number`.
6 changes: 6 additions & 0 deletions .changeset/shaggy-years-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"effect-http-node": minor
"effect-http": minor
---

Update @effect/platform packages.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"devDependencies": {
"@babel/cli": "^7.24.8",
"@babel/core": "^7.24.8",
"@babel/core": "^7.24.9",
"@babel/plugin-transform-export-namespace-from": "^7.24.7",
"@babel/plugin-transform-modules-commonjs": "^7.24.8",
"@changesets/changelog-github": "^0.5.0",
Expand All @@ -31,11 +31,11 @@
"@effect/dtslint": "^0.1.0",
"@effect/eslint-plugin": "^0.1.2",
"@effect/language-service": "^0.1.0",
"@effect/vitest": "^0.6.7",
"@effect/vitest": "^0.6.8",
"@types/node": "^20.14.10",
"@types/swagger-ui-dist": "^3.30.5",
"@typescript-eslint/eslint-plugin": "^7.16.0",
"@typescript-eslint/parser": "^7.16.0",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"@vitest/coverage-v8": "^1.6.0",
"babel-plugin-annotate-pure-calls": "^0.4.0",
"eslint": "^8.57.0",
Expand Down
14 changes: 7 additions & 7 deletions packages/effect-http-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@
"swagger-ui-dist": "^5.17.14"
},
"peerDependencies": {
"@effect/platform": "^0.58.0",
"@effect/platform-node": "^0.53.0",
"@effect/platform": "^0.59.0",
"@effect/platform-node": "^0.54.0",
"@effect/schema": "^0.68.0",
"effect": "^3.5.0",
"effect-http": "workspace:^"
},
"devDependencies": {
"@effect/platform": "^0.58.27",
"@effect/platform-bun": "^0.38.26",
"@effect/platform-node": "^0.53.26",
"@effect/schema": "^0.68.23",
"@effect/platform": "^0.59.0",
"@effect/platform-bun": "^0.39.0",
"@effect/platform-node": "^0.54.1",
"@effect/schema": "^0.68.24",
"@types/node": "^20.14.10",
"effect": "^3.5.3",
"effect": "^3.5.4",
"effect-http": "workspace:^"
}
}
8 changes: 4 additions & 4 deletions packages/effect-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
"coverage": "vitest --coverage"
},
"peerDependencies": {
"@effect/platform": "^0.58.0",
"@effect/platform": "^0.59.0",
"@effect/schema": "^0.68.0",
"effect": "^3.5.0"
},
"devDependencies": {
"@apidevtools/swagger-parser": "^10.1.0",
"@effect/platform": "^0.58.27",
"@effect/schema": "^0.68.23",
"effect": "^3.5.3"
"@effect/platform": "^0.59.0",
"@effect/schema": "^0.68.24",
"effect": "^3.5.4"
}
}
6 changes: 6 additions & 0 deletions packages/effect-http/src/QuerySchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import * as internal from "./internal/query-schema.js"
*/
export const Number: Schema.Schema<number, string> = internal.Number

/**
* @category schema
* @since 1.0.0
*/
export const number: <A, R>(schema: Schema.Schema<A, number, R>) => Schema.Schema<A, string, R> = internal.number

/**
* @category schema
* @since 1.0.0
Expand Down
4 changes: 2 additions & 2 deletions packages/effect-http/src/internal/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export const endpointClient = <A extends Api.Api.Any, Id extends Api.Api.Ids<A>>
Effect.map(mapper ?? identity),
Effect.flatMap(httpClient),
Effect.catchTags({
RequestError: (err) => ClientError.makeClientSide(err.error, err.message),
ResponseError: (err) => ClientError.makeServerSide(err.error, err.response.status, err.message),
RequestError: (err) => ClientError.makeClientSide(err.cause, err.message),
ResponseError: (err) => ClientError.makeServerSide(err.cause, err.response.status, err.message),
ClientError: (err) => Effect.fail(err)
}),
Effect.flatMap(responseParser.parseResponse),
Expand Down
5 changes: 5 additions & 0 deletions packages/effect-http/src/internal/query-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ export const Number = Schema.NumberFromString.pipe(
circular.annotate(() => ({ type: "number", description: "a number" }))
)

export const number = <A, R>(schema: Schema.Schema<A, number, R>) =>
Schema.compose(Schema.NumberFromString, schema, { strict: true }).pipe(
circular.annotate(() => ({ type: "number", description: "a number" }))
)

/** @internal */
export const Array = <A, R>(
schema: Schema.Schema<A, string, R>
Expand Down
Loading

0 comments on commit 8481868

Please sign in to comment.