effect 4.0.0-beta.46 → 4.0.0-beta.48
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/Schema.d.ts +223 -140
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +110 -32
- package/dist/Schema.js.map +1 -1
- package/dist/Types.d.ts +9 -0
- package/dist/Types.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +1 -1
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts +4 -1
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +1 -1
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.js +1 -0
- package/dist/unstable/eventlog/EventLogRemote.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +3 -2
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +1 -0
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +7 -7
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +1 -1
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +1 -1
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/workers/Transferable.d.ts +1 -1
- package/dist/unstable/workers/Transferable.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +1 -1
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/package.json +10 -10
- package/src/Schema.ts +260 -167
- package/src/Types.ts +8 -0
- package/src/unstable/ai/McpSchema.ts +1 -1
- package/src/unstable/eventlog/EventLog.ts +7 -2
- package/src/unstable/eventlog/EventLogRemote.ts +1 -0
- package/src/unstable/httpapi/HttpApiBuilder.ts +11 -3
- package/src/unstable/httpapi/HttpApiClient.ts +2 -2
- package/src/unstable/httpapi/HttpApiMiddleware.ts +1 -0
- package/src/unstable/httpapi/HttpApiSchema.ts +4 -6
- package/src/unstable/observability/OtlpExporter.ts +1 -0
- package/src/unstable/reactivity/Atom.ts +1 -1
- package/src/unstable/reactivity/AtomRpc.ts +4 -4
- package/src/unstable/rpc/RpcSchema.ts +1 -1
- package/src/unstable/socket/Socket.ts +1 -1
- package/src/unstable/workers/Transferable.ts +2 -2
- package/src/unstable/workflow/Workflow.ts +5 -2
package/src/Types.ts
CHANGED
|
@@ -1001,3 +1001,11 @@ export type OmitReason<E, K extends string> = E extends { readonly reason: infer
|
|
|
1001
1001
|
export type ExcludeReason<E, K extends string> = E extends { readonly reason: infer R }
|
|
1002
1002
|
? Exclude<R, { readonly _tag: K }>
|
|
1003
1003
|
: never
|
|
1004
|
+
|
|
1005
|
+
/**
|
|
1006
|
+
* Extracts the required keys from a type.
|
|
1007
|
+
*
|
|
1008
|
+
* @since 4.0.0
|
|
1009
|
+
* @category types
|
|
1010
|
+
*/
|
|
1011
|
+
export type RequiredKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? never : K }[keyof T]
|
|
@@ -2106,7 +2106,7 @@ export interface Param<Name extends string, S extends Schema.Top> extends
|
|
|
2106
2106
|
S["~encoded.optionality"]
|
|
2107
2107
|
>
|
|
2108
2108
|
{
|
|
2109
|
-
readonly "
|
|
2109
|
+
readonly "Rebuild": Param<Name, S>
|
|
2110
2110
|
readonly [ParamSchemaTypeId]: typeof ParamSchemaTypeId
|
|
2111
2111
|
readonly name: Name
|
|
2112
2112
|
readonly schema: S
|
|
@@ -358,7 +358,9 @@ const IdentityEncodedSchema = Schema.Struct({
|
|
|
358
358
|
privateKey: Schema.Uint8ArrayFromBase64
|
|
359
359
|
})
|
|
360
360
|
|
|
361
|
-
const IdentityStringSchema = Schema.
|
|
361
|
+
const IdentityStringSchema = Schema.StringFromBase64Url.pipe(
|
|
362
|
+
Schema.decodeTo(Schema.fromJsonString(IdentityEncodedSchema))
|
|
363
|
+
)
|
|
362
364
|
|
|
363
365
|
/**
|
|
364
366
|
* @since 4.0.0
|
|
@@ -584,7 +586,10 @@ export const makeReplayFromRemote = (options: {
|
|
|
584
586
|
}
|
|
585
587
|
}) =>
|
|
586
588
|
Effect.fnUntraced(
|
|
587
|
-
function*({ conflicts, entry }
|
|
589
|
+
function*({ conflicts, entry }: {
|
|
590
|
+
readonly entry: Entry
|
|
591
|
+
readonly conflicts: ReadonlyArray<Entry>
|
|
592
|
+
}): Effect.fn.Return<void, Schema.SchemaError> {
|
|
588
593
|
const handler = options.handlers.get(entry.event) as Handlers.Item<any> | undefined
|
|
589
594
|
if (!handler) {
|
|
590
595
|
return yield* Effect.logDebug(`Event handler not found for: "${entry.event}"`)
|
|
@@ -245,6 +245,7 @@ export const makeWith = Effect.fnUntraced(function*({ encodeWrite, decodeChanges
|
|
|
245
245
|
return remote
|
|
246
246
|
})
|
|
247
247
|
|
|
248
|
+
/** @effect-diagnostics-next-line classSelfMismatch:off */
|
|
248
249
|
class IdentityService extends Context.Service<Identity, Identity["Service"]>()(
|
|
249
250
|
"effect/eventlog/EventLog/Identity" satisfies Identity["key"]
|
|
250
251
|
) {}
|
|
@@ -18,7 +18,7 @@ import * as Schema from "../../Schema.ts"
|
|
|
18
18
|
import type * as AST from "../../SchemaAST.ts"
|
|
19
19
|
import * as Issue from "../../SchemaIssue.ts"
|
|
20
20
|
import * as Transformation from "../../SchemaTransformation.ts"
|
|
21
|
-
import
|
|
21
|
+
import * as Scope from "../../Scope.ts"
|
|
22
22
|
import * as Stream from "../../Stream.ts"
|
|
23
23
|
import type { Covariant, NoInfer } from "../../Types.ts"
|
|
24
24
|
import * as UndefinedOr from "../../UndefinedOr.ts"
|
|
@@ -120,7 +120,9 @@ export const group = <
|
|
|
120
120
|
Exclude<Handlers.Context<Return>, Scope.Scope>
|
|
121
121
|
> =>
|
|
122
122
|
Layer.effectContext(Effect.gen(function*() {
|
|
123
|
-
const services = yield* Effect.context<any>()
|
|
123
|
+
const services = (yield* Effect.context<any>()).pipe(
|
|
124
|
+
Context.omit(Scope.Scope)
|
|
125
|
+
)
|
|
124
126
|
const group = api.groups[groupName]!
|
|
125
127
|
const result = build(makeHandlers(group))
|
|
126
128
|
const handlers: Handlers<any, any> = Effect.isEffect(result)
|
|
@@ -333,7 +335,13 @@ export const endpoint = <
|
|
|
333
335
|
Effect.contextWith((context: Context.Context<any>) => {
|
|
334
336
|
const group = api.groups[groupName] as unknown as HttpApiGroup.AnyWithProps
|
|
335
337
|
const endpoint = group.endpoints[endpointName] as unknown as HttpApiEndpoint.AnyWithProps
|
|
336
|
-
return Effect.succeed(handlerToHttpEffect(
|
|
338
|
+
return Effect.succeed(handlerToHttpEffect(
|
|
339
|
+
group,
|
|
340
|
+
endpoint,
|
|
341
|
+
Context.omit(Scope.Scope)(context),
|
|
342
|
+
handler as any,
|
|
343
|
+
false
|
|
344
|
+
))
|
|
337
345
|
})
|
|
338
346
|
|
|
339
347
|
/**
|
|
@@ -715,11 +715,11 @@ function getEncodePayloadSchemaFromBody(
|
|
|
715
715
|
const encoding = HttpApiSchema.getPayloadEncoding(ast, method)
|
|
716
716
|
const out = $HttpBody.pipe(Schema.decodeTo(
|
|
717
717
|
schema,
|
|
718
|
-
Transformation.transformOrFail({
|
|
718
|
+
Transformation.transformOrFail<unknown, HttpBody.HttpBody>({
|
|
719
719
|
decode(httpBody) {
|
|
720
720
|
return Effect.fail(new Issue.Forbidden(Option.some(httpBody), { message: "Encode only schema" }))
|
|
721
721
|
},
|
|
722
|
-
encode(t
|
|
722
|
+
encode(t) {
|
|
723
723
|
switch (encoding._tag) {
|
|
724
724
|
case "Multipart":
|
|
725
725
|
return Effect.fail(new Issue.Forbidden(Option.some(t), { message: "Payload must be a FormData" }))
|
|
@@ -279,6 +279,7 @@ export const Service = <
|
|
|
279
279
|
const creationError = new Err()
|
|
280
280
|
Err.stackTraceLimit = limit
|
|
281
281
|
|
|
282
|
+
/** @effect-diagnostics-next-line classSelfMismatch:off */
|
|
282
283
|
class Service extends Context.Service<Self, any>()(id) {}
|
|
283
284
|
const self = Service as any
|
|
284
285
|
Object.defineProperty(Service, "stack", {
|
|
@@ -87,7 +87,7 @@ export type ResponseEncoding = {
|
|
|
87
87
|
* @since 4.0.0
|
|
88
88
|
*/
|
|
89
89
|
export function status(code: number) {
|
|
90
|
-
return <S extends Schema.Top>(self: S): S["
|
|
90
|
+
return <S extends Schema.Top>(self: S): S["Rebuild"] => {
|
|
91
91
|
return self.annotate({ httpApiStatus: code })
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -190,7 +190,7 @@ export type MultipartTypeId = typeof MultipartTypeId
|
|
|
190
190
|
/**
|
|
191
191
|
* @since 4.0.0
|
|
192
192
|
*/
|
|
193
|
-
export interface asMultipart<S extends Schema.Top> extends Schema.brand<S["
|
|
193
|
+
export interface asMultipart<S extends Schema.Top> extends Schema.brand<S["Rebuild"], MultipartTypeId> {}
|
|
194
194
|
|
|
195
195
|
/**
|
|
196
196
|
* Marks a schema as a multipart payload.
|
|
@@ -225,9 +225,7 @@ export type MultipartStreamTypeId = typeof MultipartStreamTypeId
|
|
|
225
225
|
/**
|
|
226
226
|
* @since 4.0.0
|
|
227
227
|
*/
|
|
228
|
-
export interface asMultipartStream<S extends Schema.Top>
|
|
229
|
-
extends Schema.brand<S["~rebuild.out"], MultipartStreamTypeId>
|
|
230
|
-
{}
|
|
228
|
+
export interface asMultipartStream<S extends Schema.Top> extends Schema.brand<S["Rebuild"], MultipartStreamTypeId> {}
|
|
231
229
|
|
|
232
230
|
/**
|
|
233
231
|
* Marks a schema as a multipart stream payload.
|
|
@@ -252,7 +250,7 @@ export function asMultipartStream(options?: Multipart_.withLimits.Options) {
|
|
|
252
250
|
function asNonMultipartEncoding<S extends Schema.Top>(self: S, options: {
|
|
253
251
|
readonly _tag: "Json" | "FormUrlEncoded" | "Uint8Array" | "Text"
|
|
254
252
|
readonly contentType?: string | undefined
|
|
255
|
-
}): S["
|
|
253
|
+
}): S["Rebuild"] {
|
|
256
254
|
return self.annotate({
|
|
257
255
|
"~httpApiEncoding": {
|
|
258
256
|
_tag: options._tag,
|
|
@@ -61,6 +61,7 @@ export const make: (
|
|
|
61
61
|
let disabledUntil: number | undefined = undefined
|
|
62
62
|
|
|
63
63
|
const client = HttpClient.filterStatusOk(Context.get(services, HttpClient.HttpClient)).pipe(
|
|
64
|
+
HttpClient.transformResponse(Effect.provideService(HttpClient.TracerPropagationEnabled, false)),
|
|
64
65
|
HttpClient.retryTransient({ schedule: policy, times: 3 })
|
|
65
66
|
)
|
|
66
67
|
|
|
@@ -2201,7 +2201,7 @@ export const kvs = <S extends Schema.Codec<any, any>, const Mode extends "sync"
|
|
|
2201
2201
|
*/
|
|
2202
2202
|
export const searchParam = <S extends Schema.Codec<any, string> = never>(name: string, options?: {
|
|
2203
2203
|
readonly schema?: S | undefined
|
|
2204
|
-
}): Writable<S extends never ? string : Option.Option<S["Type"]>> => {
|
|
2204
|
+
}): Writable<[S] extends [never] ? string : Option.Option<S["Type"]>> => {
|
|
2205
2205
|
const decode = options?.schema && Schema.decodeExit(options.schema)
|
|
2206
2206
|
const encode = options?.schema && Schema.encodeExit(options.schema)
|
|
2207
2207
|
return writable(
|
|
@@ -179,10 +179,10 @@ export const Service = <Self>() =>
|
|
|
179
179
|
Effect.fnUntraced(function*({ headers, payload, reactivityKeys }) {
|
|
180
180
|
const client = yield* self
|
|
181
181
|
const effect = client(tag, payload, { headers } as any)
|
|
182
|
-
return yield* reactivityKeys
|
|
183
|
-
? Reactivity.mutation(effect, reactivityKeys)
|
|
184
|
-
: effect
|
|
185
|
-
})
|
|
182
|
+
return yield* (reactivityKeys
|
|
183
|
+
? Reactivity.mutation(effect, reactivityKeys) as Effect.Effect<any>
|
|
184
|
+
: effect as any as Effect.Effect<any>)
|
|
185
|
+
})
|
|
186
186
|
).pipe(
|
|
187
187
|
Atom.serializable({
|
|
188
188
|
key: `AtomRpc:mutation:${tag}`,
|
|
@@ -47,7 +47,7 @@ export interface Stream<A extends Schema.Top, E extends Schema.Top> extends
|
|
|
47
47
|
Stream<A, E>
|
|
48
48
|
>
|
|
49
49
|
{
|
|
50
|
-
readonly "
|
|
50
|
+
readonly "Rebuild": Stream<A, E>
|
|
51
51
|
readonly [StreamSchemaTypeId]: typeof StreamSchemaTypeId
|
|
52
52
|
readonly success: A
|
|
53
53
|
readonly error: E
|
|
@@ -316,7 +316,10 @@ export const make = <
|
|
|
316
316
|
})
|
|
317
317
|
},
|
|
318
318
|
execute: Effect.fnUntraced(
|
|
319
|
-
function
|
|
319
|
+
function*<const Discard extends boolean = false>(
|
|
320
|
+
fields: any,
|
|
321
|
+
opts?: { readonly discard?: Discard } | undefined
|
|
322
|
+
) {
|
|
320
323
|
const payload = self.payloadSchema.make(fields)
|
|
321
324
|
const engine = yield* EngineTag
|
|
322
325
|
const executionId = yield* makeExecutionId(payload)
|
|
@@ -376,7 +379,7 @@ export const make = <
|
|
|
376
379
|
),
|
|
377
380
|
executionId: (payload) =>
|
|
378
381
|
Effect.flatMap(
|
|
379
|
-
Effect.
|
|
382
|
+
Effect.orDie(self.payloadSchema.makeEffect(payload)),
|
|
380
383
|
makeExecutionId
|
|
381
384
|
),
|
|
382
385
|
withCompensation
|