@effect/platform 0.84.9 → 0.84.11

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.
@@ -118,7 +118,12 @@ export const getEncoding = (ast: AST.AST, fallback = encodingJson): Encoding =>
118
118
  * @since 1.0.0
119
119
  * @category annotations
120
120
  */
121
- export const getParam = (ast: AST.AST): string | undefined => ast.annotations[AnnotationParam] as string | undefined
121
+ export const getParam = (ast: AST.AST | Schema.PropertySignature.AST): string | undefined => {
122
+ if (ast._tag === "PropertySignatureTransformation") {
123
+ ast = ast.to.type
124
+ }
125
+ return (ast.annotations[AnnotationParam] as any)?.name as string | undefined
126
+ }
122
127
 
123
128
  /**
124
129
  * @since 1.0.0
@@ -228,10 +233,13 @@ type Void$ = typeof Schema.Void
228
233
  * @since 1.0.0
229
234
  * @category path params
230
235
  */
231
- export interface Param<Name extends string, S extends Schema.Schema.Any>
232
- extends Schema.Schema<S["Type"], S["Encoded"], S["Context"]>
236
+ export interface Param<Name extends string, S extends Schema.Schema.Any | Schema.PropertySignature.Any>
237
+ extends Schema.Schema<Schema.Schema.Type<S>, Schema.Schema.Encoded<S>, Schema.Schema.Context<S>>
233
238
  {
234
- readonly [AnnotationParam]: Name
239
+ readonly [AnnotationParam]: {
240
+ readonly name: Name
241
+ readonly schema: S
242
+ }
235
243
  }
236
244
 
237
245
  /**
@@ -243,21 +251,30 @@ export const param: {
243
251
  * @since 1.0.0
244
252
  * @category path params
245
253
  */
246
- <Name extends string>(name: Name): <S extends Schema.Schema.Any>(
247
- schema: S & ([S["Encoded"]] extends [string] ? unknown : "Schema must be encodable to a string")
254
+ <Name extends string>(name: Name): <S extends Schema.Schema.Any | Schema.PropertySignature.Any>(
255
+ schema:
256
+ & S
257
+ & ([Schema.Schema.Encoded<S> & {}] extends [string] ? unknown : "Schema must be encodable to a string")
248
258
  ) => Param<Name, S>
249
259
  /**
250
260
  * @since 1.0.0
251
261
  * @category path params
252
262
  */
253
- <Name extends string, S extends Schema.Schema.Any>(
263
+ <Name extends string, S extends Schema.Schema.Any | Schema.PropertySignature.Any>(
254
264
  name: Name,
255
- schema: S & ([S["Encoded"]] extends [string] ? unknown : "Schema must be encodable to a string")
265
+ schema:
266
+ & S
267
+ & ([Schema.Schema.Encoded<S> & {}] extends [string] ? unknown : "Schema must be encodable to a string")
256
268
  ): Param<Name, S>
257
269
  } = dual(
258
270
  2,
259
- <Name extends string, S extends Schema.Schema.Any>(name: Name, schema: S): Param<Name, S> =>
260
- schema.annotations({ [AnnotationParam]: name }) as any
271
+ <Name extends string, S extends Schema.Schema.Any | Schema.PropertySignature.Any>(
272
+ name: Name,
273
+ schema: S
274
+ ): Param<Name, S> =>
275
+ schema.annotations({
276
+ [AnnotationParam]: { name, schema }
277
+ }) as any
261
278
  )
262
279
 
263
280
  /**
package/src/OpenApi.ts CHANGED
@@ -420,7 +420,7 @@ export const fromApi = <Id extends string, Groups extends HttpApiGroup.Any, E, R
420
420
  processResponseMap(successes, () => "Success")
421
421
  processResponseMap(errors, () => "Error")
422
422
 
423
- const path = endpoint.path.replace(/:(\w+)/g, "{$1}")
423
+ const path = endpoint.path.replace(/:(\w+)\??/g, "{$1}")
424
424
  const method = endpoint.method.toLowerCase() as OpenAPISpecMethodName
425
425
  if (!spec.paths[path]) {
426
426
  spec.paths[path] = {}
@@ -50,7 +50,7 @@ class ClientResponseImpl extends Inspectable.Class implements ClientResponse.Htt
50
50
  }
51
51
 
52
52
  get headers(): Headers.Headers {
53
- return Headers.fromInput(this.source.headers)
53
+ return Headers.fromInput(this.source.headers as any)
54
54
  }
55
55
 
56
56
  cachedCookies?: Cookies.Cookies
@@ -229,7 +229,7 @@ class ServerRequestImpl extends Inspectable.Class implements ServerRequest.HttpS
229
229
  return this.remoteAddressOverride ? Option.some(this.remoteAddressOverride) : Option.none()
230
230
  }
231
231
  get headers(): Headers.Headers {
232
- this.headersOverride ??= Headers.fromInput(this.source.headers)
232
+ this.headersOverride ??= Headers.fromInput(this.source.headers as any)
233
233
  return this.headersOverride
234
234
  }
235
235