@nyc-transit-kit/soda3 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nyc-transit-kit/soda3",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {
@@ -24,7 +24,7 @@
24
24
  "test": "bun test ./test"
25
25
  },
26
26
  "dependencies": {
27
- "@nyc-transit-kit/contracts": "0.1.2",
27
+ "@nyc-transit-kit/contracts": "0.1.3",
28
28
  "effect": "4.0.0-beta.92"
29
29
  },
30
30
  "publishConfig": {
package/src/client.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  export { catalogSearch } from "./catalog"
2
2
  export { exportResponse } from "./export"
3
3
  export { Soda3HttpLive } from "./internal/http"
4
- export type { Soda3ClientConfigShape } from "./internal/services"
5
- export { Soda3ClientConfig, Soda3Live } from "./internal/services"
4
+ export type { Soda3ClientConfigShape, Soda3LayerOptions } from "./internal/services"
5
+ export {
6
+ Soda3ClientConfig,
7
+ Soda3Live,
8
+ soda3ConfigLayer,
9
+ soda3FetchLayer,
10
+ soda3Layer
11
+ } from "./internal/services"
6
12
  export { queryRows } from "./query"
package/src/index.ts CHANGED
@@ -1,7 +1,14 @@
1
1
  export const packageName = "@nyc-transit-kit/soda3"
2
2
  export { buildCatalogSearchUrl, catalogSearch } from "./catalog"
3
- export type { Soda3ClientConfigShape } from "./client"
4
- export { Soda3ClientConfig, Soda3HttpLive, Soda3Live } from "./client"
3
+ export type { Soda3ClientConfigShape, Soda3LayerOptions } from "./client"
4
+ export {
5
+ Soda3ClientConfig,
6
+ Soda3HttpLive,
7
+ Soda3Live,
8
+ soda3ConfigLayer,
9
+ soda3FetchLayer,
10
+ soda3Layer
11
+ } from "./client"
5
12
  export {
6
13
  buildExportUrl,
7
14
  buildQueryUrl,
@@ -1,5 +1,6 @@
1
1
  import * as Context from "effect/Context"
2
2
  import * as Layer from "effect/Layer"
3
+ import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient"
3
4
  import { Soda3HttpLive } from "./http"
4
5
 
5
6
  export interface Soda3ClientConfigShape {
@@ -8,6 +9,10 @@ export interface Soda3ClientConfigShape {
8
9
  readonly timeoutMs?: number
9
10
  }
10
11
 
12
+ export interface Soda3LayerOptions extends Soda3ClientConfigShape {
13
+ readonly fetch?: typeof fetch
14
+ }
15
+
11
16
  export class Soda3ClientConfig extends Context.Service<Soda3ClientConfig, Soda3ClientConfigShape>()(
12
17
  "@nyc-transit-kit/soda3/Soda3ClientConfig"
13
18
  ) {
@@ -16,4 +21,21 @@ export class Soda3ClientConfig extends Context.Service<Soda3ClientConfig, Soda3C
16
21
  })
17
22
  }
18
23
 
19
- export const Soda3Live = Layer.mergeAll(Soda3ClientConfig.Default, Soda3HttpLive)
24
+ export const soda3ConfigLayer = (options: Soda3ClientConfigShape = {}) =>
25
+ Layer.succeed(Soda3ClientConfig)({
26
+ retryTimes: options.retryTimes ?? 0,
27
+ ...(options.appToken === undefined ? {} : { appToken: options.appToken }),
28
+ ...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs })
29
+ })
30
+
31
+ export const soda3FetchLayer = (fetchImplementation?: typeof fetch) =>
32
+ fetchImplementation === undefined
33
+ ? Soda3HttpLive
34
+ : FetchHttpClient.layer.pipe(
35
+ Layer.provide(Layer.succeed(FetchHttpClient.Fetch, fetchImplementation))
36
+ )
37
+
38
+ export const soda3Layer = (options: Soda3LayerOptions = {}) =>
39
+ Layer.mergeAll(soda3ConfigLayer(options), soda3FetchLayer(options.fetch))
40
+
41
+ export const Soda3Live = soda3Layer()