effect 4.0.0-beta.13 → 4.0.0-beta.15
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/dist/Channel.d.ts +6 -6
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +4 -4
- package/dist/Channel.js.map +1 -1
- package/dist/Effect.d.ts +7 -7
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js.map +1 -1
- package/dist/Stream.d.ts +7 -7
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +8 -6
- package/dist/Stream.js.map +1 -1
- package/dist/Types.d.ts +70 -0
- package/dist/Types.d.ts.map +1 -1
- package/dist/internal/effect.js +4 -4
- package/dist/internal/effect.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +2 -0
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +34 -4
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +75 -20
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/GlobalFlag.d.ts +25 -62
- package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -1
- package/dist/unstable/cli/GlobalFlag.js +41 -87
- package/dist/unstable/cli/GlobalFlag.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +3 -0
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +2 -0
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/help.d.ts +18 -4
- package/dist/unstable/cli/internal/help.d.ts.map +1 -1
- package/dist/unstable/cli/internal/help.js +62 -9
- package/dist/unstable/cli/internal/help.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +10 -4
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +17 -6
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +7 -2
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +3 -4
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +2 -2
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +2 -6
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/package.json +1 -1
- package/src/Channel.ts +24 -14
- package/src/Effect.ts +30 -8
- package/src/Stream.ts +46 -22
- package/src/Types.ts +66 -0
- package/src/internal/effect.ts +41 -14
- package/src/unstable/ai/LanguageModel.ts +9 -6
- package/src/unstable/cli/Command.ts +122 -24
- package/src/unstable/cli/GlobalFlag.ts +98 -197
- package/src/unstable/cli/internal/command.ts +5 -0
- package/src/unstable/cli/internal/help.ts +104 -24
- package/src/unstable/httpapi/HttpApiBuilder.ts +68 -13
- package/src/unstable/httpapi/HttpApiEndpoint.ts +13 -4
- package/src/unstable/httpapi/OpenApi.ts +3 -4
- package/src/unstable/reactivity/AtomHttpApi.ts +2 -2
- package/src/unstable/reactivity/AtomRegistry.ts +2 -6
|
@@ -20,7 +20,7 @@ import * as Transformation from "../../SchemaTransformation.ts"
|
|
|
20
20
|
import type * as Scope from "../../Scope.ts"
|
|
21
21
|
import * as ServiceMap from "../../ServiceMap.ts"
|
|
22
22
|
import * as Stream from "../../Stream.ts"
|
|
23
|
-
import type { Covariant } from "../../Types.ts"
|
|
23
|
+
import type { Covariant, NoInfer } from "../../Types.ts"
|
|
24
24
|
import * as UndefinedOr from "../../UndefinedOr.ts"
|
|
25
25
|
import type { Cookie } from "../http/Cookies.ts"
|
|
26
26
|
import type * as Etag from "../http/Etag.ts"
|
|
@@ -63,7 +63,6 @@ export const layer = <Id extends string, Groups extends HttpApiGroup.Any>(
|
|
|
63
63
|
| HttpPlatform
|
|
64
64
|
| Path
|
|
65
65
|
| HttpApiGroup.ToService<Id, Groups>
|
|
66
|
-
| HttpApiGroup.ErrorServicesEncode<Groups>
|
|
67
66
|
> =>
|
|
68
67
|
HttpRouter.use(Effect.fnUntraced(function*(router) {
|
|
69
68
|
const services = yield* Effect.services<
|
|
@@ -168,7 +167,7 @@ export interface Handlers<
|
|
|
168
167
|
| R
|
|
169
168
|
| HttpApiEndpoint.MiddlewareWithName<Endpoints, Name>
|
|
170
169
|
| HttpApiEndpoint.MiddlewareServicesWithName<Endpoints, Name>
|
|
171
|
-
| HttpApiEndpoint.
|
|
170
|
+
| HttpApiEndpoint.ExcludeProvidedWithName<
|
|
172
171
|
Endpoints,
|
|
173
172
|
Name,
|
|
174
173
|
R1 | HttpApiEndpoint.ServerServicesWithName<Endpoints, Name>
|
|
@@ -188,7 +187,7 @@ export interface Handlers<
|
|
|
188
187
|
| R
|
|
189
188
|
| HttpApiEndpoint.MiddlewareWithName<Endpoints, Name>
|
|
190
189
|
| HttpApiEndpoint.MiddlewareServicesWithName<Endpoints, Name>
|
|
191
|
-
| HttpApiEndpoint.
|
|
190
|
+
| HttpApiEndpoint.ExcludeProvidedWithName<
|
|
192
191
|
Endpoints,
|
|
193
192
|
Name,
|
|
194
193
|
R1 | HttpApiEndpoint.ServerServicesWithName<Endpoints, Name>
|
|
@@ -284,6 +283,54 @@ export declare namespace Handlers {
|
|
|
284
283
|
never
|
|
285
284
|
}
|
|
286
285
|
|
|
286
|
+
/**
|
|
287
|
+
* @since 4.0.0
|
|
288
|
+
* @category handlers
|
|
289
|
+
*/
|
|
290
|
+
export const endpoint = <
|
|
291
|
+
ApiId extends string,
|
|
292
|
+
Groups extends HttpApiGroup.Any,
|
|
293
|
+
const GroupName extends HttpApiGroup.Name<Groups>,
|
|
294
|
+
const EndpointName extends HttpApiEndpoint.Name<HttpApiGroup.Endpoints<HttpApiGroup.WithName<Groups, GroupName>>>,
|
|
295
|
+
R,
|
|
296
|
+
Group extends HttpApiGroup.Any = HttpApiGroup.WithName<Groups, GroupName>,
|
|
297
|
+
Endpoint extends HttpApiEndpoint.Any = HttpApiEndpoint.WithName<HttpApiGroup.Endpoints<Group>, EndpointName>
|
|
298
|
+
>(
|
|
299
|
+
api: HttpApi.HttpApi<ApiId, Groups>,
|
|
300
|
+
groupName: GroupName,
|
|
301
|
+
endpointName: EndpointName,
|
|
302
|
+
handler: NoInfer<
|
|
303
|
+
HttpApiEndpoint.HandlerWithName<
|
|
304
|
+
HttpApiGroup.Endpoints<HttpApiGroup.WithName<Groups, GroupName>>,
|
|
305
|
+
EndpointName,
|
|
306
|
+
never,
|
|
307
|
+
R
|
|
308
|
+
>
|
|
309
|
+
>
|
|
310
|
+
): Effect.Effect<
|
|
311
|
+
Effect.Effect<
|
|
312
|
+
HttpServerResponse,
|
|
313
|
+
never,
|
|
314
|
+
| HttpServerRequest
|
|
315
|
+
| HttpRouter.RouteContext
|
|
316
|
+
| Request.ParsedSearchParams
|
|
317
|
+
| Exclude<R, HttpApiEndpoint.MiddlewareProvides<Endpoint>>
|
|
318
|
+
>,
|
|
319
|
+
never,
|
|
320
|
+
| HttpApiEndpoint.ServerServices<Endpoint>
|
|
321
|
+
| HttpApiEndpoint.Middleware<Endpoint>
|
|
322
|
+
| HttpApiEndpoint.MiddlewareServices<Endpoint>
|
|
323
|
+
| Etag.Generator
|
|
324
|
+
| FileSystem
|
|
325
|
+
| HttpPlatform
|
|
326
|
+
| Path
|
|
327
|
+
> =>
|
|
328
|
+
Effect.servicesWith((services: ServiceMap.ServiceMap<any>) => {
|
|
329
|
+
const group = api.groups[groupName] as unknown as HttpApiGroup.AnyWithProps
|
|
330
|
+
const endpoint = group.endpoints[endpointName] as unknown as HttpApiEndpoint.AnyWithProps
|
|
331
|
+
return Effect.succeed(handlerToHttpEffect(group, endpoint, services, handler as any, false))
|
|
332
|
+
})
|
|
333
|
+
|
|
287
334
|
/**
|
|
288
335
|
* @since 4.0.0
|
|
289
336
|
* @category security
|
|
@@ -497,22 +544,23 @@ function decodePayload(
|
|
|
497
544
|
}
|
|
498
545
|
}
|
|
499
546
|
|
|
500
|
-
function
|
|
547
|
+
function handlerToHttpEffect(
|
|
501
548
|
group: HttpApiGroup.AnyWithProps,
|
|
502
|
-
|
|
503
|
-
services: ServiceMap.ServiceMap<any
|
|
504
|
-
|
|
505
|
-
|
|
549
|
+
endpoint: HttpApiEndpoint.AnyWithProps,
|
|
550
|
+
services: ServiceMap.ServiceMap<any>,
|
|
551
|
+
handler: HttpApiEndpoint.Handler<any, any, any>,
|
|
552
|
+
isRaw: boolean
|
|
553
|
+
) {
|
|
506
554
|
const encodeSuccess = Schema.encodeUnknownEffect(makeSuccessSchema(endpoint))
|
|
507
555
|
const encodeError = Schema.encodeUnknownEffect(makeErrorSchema(endpoint))
|
|
508
556
|
const decodeParams = UndefinedOr.map(endpoint.params, Schema.decodeUnknownEffect)
|
|
509
557
|
const decodeHeaders = UndefinedOr.map(endpoint.headers, Schema.decodeUnknownEffect)
|
|
510
558
|
const decodeQuery = UndefinedOr.map(endpoint.query, Schema.decodeUnknownEffect)
|
|
511
559
|
|
|
512
|
-
const shouldParsePayload = endpoint.payload.size > 0 && !
|
|
560
|
+
const shouldParsePayload = endpoint.payload.size > 0 && !isRaw
|
|
513
561
|
const payloadBy = shouldParsePayload ? buildPayloadDecoders(endpoint.payload) : undefined
|
|
514
562
|
|
|
515
|
-
|
|
563
|
+
return applyMiddleware(
|
|
516
564
|
group,
|
|
517
565
|
endpoint,
|
|
518
566
|
services,
|
|
@@ -545,7 +593,7 @@ function handlerToRoute(
|
|
|
545
593
|
request.payload = yield* result
|
|
546
594
|
}
|
|
547
595
|
}
|
|
548
|
-
const response = yield* handler
|
|
596
|
+
const response = yield* handler(request)
|
|
549
597
|
return Response.isHttpServerResponse(response) ? response : yield* encodeSuccess(response)
|
|
550
598
|
})
|
|
551
599
|
).pipe(
|
|
@@ -558,11 +606,18 @@ function handlerToRoute(
|
|
|
558
606
|
}),
|
|
559
607
|
Effect.provideServices(services)
|
|
560
608
|
)
|
|
609
|
+
}
|
|
561
610
|
|
|
611
|
+
function handlerToRoute(
|
|
612
|
+
group: HttpApiGroup.AnyWithProps,
|
|
613
|
+
handler: Handlers.Item<any>,
|
|
614
|
+
services: ServiceMap.ServiceMap<any>
|
|
615
|
+
): HttpRouter.Route<any, any> {
|
|
616
|
+
const endpoint = handler.endpoint
|
|
562
617
|
return HttpRouter.route(
|
|
563
618
|
endpoint.method,
|
|
564
619
|
endpoint.path as HttpRouter.PathInput,
|
|
565
|
-
|
|
620
|
+
handlerToHttpEffect(group, endpoint, services, handler.handler, handler.isRaw),
|
|
566
621
|
{ uninterruptible: handler.uninterruptible }
|
|
567
622
|
)
|
|
568
623
|
}
|
|
@@ -513,8 +513,8 @@ export type ServerServices<Endpoint> = Endpoint extends HttpApiEndpoint<
|
|
|
513
513
|
| _Payload["DecodingServices"]
|
|
514
514
|
| _Headers["DecodingServices"]
|
|
515
515
|
| _Success["EncodingServices"]
|
|
516
|
-
|
|
517
|
-
|
|
516
|
+
| _Error["EncodingServices"]
|
|
517
|
+
| HttpApiMiddleware.ErrorServicesEncode<_M>
|
|
518
518
|
: never
|
|
519
519
|
|
|
520
520
|
/**
|
|
@@ -668,10 +668,19 @@ export type MiddlewareServicesWithName<Endpoints extends Any, Name extends strin
|
|
|
668
668
|
* @since 4.0.0
|
|
669
669
|
* @category models
|
|
670
670
|
*/
|
|
671
|
-
export type
|
|
671
|
+
export type ExcludeProvidedWithName<Endpoints extends Any, Name extends string, R> = ExcludeProvided<
|
|
672
|
+
WithName<Endpoints, Name>,
|
|
673
|
+
R
|
|
674
|
+
>
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* @since 4.0.0
|
|
678
|
+
* @category models
|
|
679
|
+
*/
|
|
680
|
+
export type ExcludeProvided<Endpoint extends Any, R> = Exclude<
|
|
672
681
|
R,
|
|
673
682
|
| HttpRouter.Provided
|
|
674
|
-
| HttpApiMiddleware.Provides<
|
|
683
|
+
| HttpApiMiddleware.Provides<Middleware<Endpoint>>
|
|
675
684
|
>
|
|
676
685
|
|
|
677
686
|
/**
|
|
@@ -351,10 +351,9 @@ export function fromApi<Id extends string, Groups extends HttpApiGroup.Any>(
|
|
|
351
351
|
ast: toEncodingAST(ast, encoding),
|
|
352
352
|
path: ["paths", path, method, "responses", String(status), "content", contentType, "schema"]
|
|
353
353
|
})
|
|
354
|
-
op.responses[status].content
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
354
|
+
op.responses[status].content ??= {}
|
|
355
|
+
op.responses[status].content[contentType] = {
|
|
356
|
+
schema: {}
|
|
358
357
|
}
|
|
359
358
|
})
|
|
360
359
|
})
|
|
@@ -66,7 +66,7 @@ export interface AtomHttpApiClient<Self, Id extends string, Groups extends HttpA
|
|
|
66
66
|
readonly reactivityKeys?: ReadonlyArray<unknown> | ReadonlyRecord<string, ReadonlyArray<unknown>> | undefined
|
|
67
67
|
}
|
|
68
68
|
>,
|
|
69
|
-
WithResponse extends true ? [_Success, HttpClientResponse] : _Success,
|
|
69
|
+
WithResponse extends true ? [_Success["Type"], HttpClientResponse] : _Success["Type"],
|
|
70
70
|
_Error | HttpClientError.HttpClientError | SchemaError
|
|
71
71
|
>
|
|
72
72
|
: never
|
|
@@ -123,7 +123,7 @@ export interface AtomHttpApiClient<Self, Id extends string, Groups extends HttpA
|
|
|
123
123
|
>
|
|
124
124
|
] ? Atom.Atom<
|
|
125
125
|
AsyncResult.AsyncResult<
|
|
126
|
-
WithResponse extends true ? [_Success, HttpClientResponse] : _Success,
|
|
126
|
+
WithResponse extends true ? [_Success["Type"], HttpClientResponse] : _Success["Type"],
|
|
127
127
|
_Error | HttpClientError.HttpClientError | SchemaError
|
|
128
128
|
>
|
|
129
129
|
>
|
|
@@ -482,9 +482,7 @@ class RegistryImpl implements AtomRegistry {
|
|
|
482
482
|
|
|
483
483
|
removeNodeTimeout(node: NodeImpl<any>): void {
|
|
484
484
|
const bucket = this.nodeTimeoutBucket.get(node)
|
|
485
|
-
if (bucket === undefined)
|
|
486
|
-
return
|
|
487
|
-
}
|
|
485
|
+
if (bucket === undefined) return
|
|
488
486
|
this.nodeTimeoutBucket.delete(node)
|
|
489
487
|
this.scheduleNodeRemoval(node)
|
|
490
488
|
|
|
@@ -502,10 +500,8 @@ class RegistryImpl implements AtomRegistry {
|
|
|
502
500
|
this.timeoutBuckets.delete(bucket)
|
|
503
501
|
|
|
504
502
|
nodes.forEach((node) => {
|
|
505
|
-
if (!node.canBeRemoved) {
|
|
506
|
-
return
|
|
507
|
-
}
|
|
508
503
|
this.nodeTimeoutBucket.delete(node)
|
|
504
|
+
if (!node.canBeRemoved) return
|
|
509
505
|
this.nodes.delete(atomKey(node.atom))
|
|
510
506
|
this.onNodeRemoved?.(node)
|
|
511
507
|
this.#currentSweepTTL = node.atom.idleTTL ?? this.defaultIdleTTL!
|