effect 4.0.0-beta.97 → 4.0.0-beta.98
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/LayerRef.d.ts +4 -6
- package/dist/LayerRef.d.ts.map +1 -1
- package/dist/LayerRef.js +4 -6
- package/dist/LayerRef.js.map +1 -1
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +28 -10
- package/dist/Number.js.map +1 -1
- package/dist/Schema.d.ts +22 -22
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +36 -33
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +25 -10
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaError.d.ts +53 -0
- package/dist/SchemaError.d.ts.map +1 -0
- package/dist/SchemaError.js +61 -0
- package/dist/SchemaError.js.map +1 -0
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +17 -12
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +186 -224
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/effect.js +26 -8
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/schema/equivalence.js +1 -2
- package/dist/internal/schema/equivalence.js.map +1 -1
- package/dist/internal/schema/representation.js +1 -3
- package/dist/internal/schema/representation.js.map +1 -1
- package/dist/internal/schema/schema.d.ts +0 -13
- package/dist/internal/schema/schema.d.ts.map +1 -1
- package/dist/internal/schema/schema.js +4 -29
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +128 -128
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.d.ts +8 -16
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +8 -16
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +4 -3
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +3 -3
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/GlobalFlag.d.ts +6 -8
- package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -1
- package/dist/unstable/cli/GlobalFlag.js +6 -6
- package/dist/unstable/cli/GlobalFlag.js.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.d.ts +1 -1
- package/dist/unstable/cluster/EntityProxyServer.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.js +2 -4
- package/dist/unstable/cluster/EntityProxyServer.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +15 -12
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/httpapi/HttpApi.d.ts +36 -15
- package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js +19 -20
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +51 -62
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +68 -58
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +53 -53
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +40 -30
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +165 -164
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js +31 -19
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +22 -0
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +31 -0
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.d.ts +55 -30
- package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js +22 -29
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +8 -8
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts +2 -2
- package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.js +4 -3
- package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +8 -0
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSwagger.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiSwagger.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSwagger.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiTest.d.ts +4 -4
- package/dist/unstable/httpapi/HttpApiTest.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiTest.js +9 -8
- package/dist/unstable/httpapi/HttpApiTest.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +77 -37
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/httpapi/internal/html.js +6 -2
- package/dist/unstable/httpapi/internal/html.js.map +1 -1
- package/dist/unstable/httpapi/internal/mediaType.d.ts +2 -0
- package/dist/unstable/httpapi/internal/mediaType.d.ts.map +1 -0
- package/dist/unstable/httpapi/internal/mediaType.js +7 -0
- package/dist/unstable/httpapi/internal/mediaType.js.map +1 -0
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +16 -12
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/reactivity/Atom.js +1 -1
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +7 -7
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +3 -2
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +3 -1
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +6 -3
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js +1 -1
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/WorkflowProxyServer.d.ts +1 -1
- package/dist/unstable/workflow/WorkflowProxyServer.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowProxyServer.js +1 -2
- package/dist/unstable/workflow/WorkflowProxyServer.js.map +1 -1
- package/package.json +1 -1
- package/src/LayerRef.ts +4 -6
- package/src/Number.ts +29 -10
- package/src/Schema.ts +42 -34
- package/src/SchemaAST.ts +25 -13
- package/src/SchemaError.ts +64 -0
- package/src/SchemaGetter.ts +22 -16
- package/src/SchemaRepresentation.ts +165 -202
- package/src/index.ts +10 -0
- package/src/internal/effect.ts +39 -22
- package/src/internal/schema/equivalence.ts +1 -2
- package/src/internal/schema/representation.ts +4 -4
- package/src/internal/schema/schema.ts +4 -37
- package/src/unstable/cli/CliError.ts +24 -16
- package/src/unstable/cli/Command.ts +8 -8
- package/src/unstable/cli/GlobalFlag.ts +22 -33
- package/src/unstable/cluster/EntityProxyServer.ts +15 -17
- package/src/unstable/cluster/internal/entityManager.ts +48 -34
- package/src/unstable/httpapi/HttpApi.ts +72 -47
- package/src/unstable/httpapi/HttpApiBuilder.ts +320 -217
- package/src/unstable/httpapi/HttpApiClient.ts +196 -151
- package/src/unstable/httpapi/HttpApiEndpoint.ts +251 -447
- package/src/unstable/httpapi/HttpApiError.ts +33 -0
- package/src/unstable/httpapi/HttpApiGroup.ts +95 -74
- package/src/unstable/httpapi/HttpApiMiddleware.ts +10 -7
- package/src/unstable/httpapi/HttpApiScalar.ts +15 -12
- package/src/unstable/httpapi/HttpApiSchema.ts +8 -0
- package/src/unstable/httpapi/HttpApiSwagger.ts +2 -2
- package/src/unstable/httpapi/HttpApiTest.ts +15 -14
- package/src/unstable/httpapi/OpenApi.ts +74 -36
- package/src/unstable/httpapi/internal/html.ts +9 -2
- package/src/unstable/httpapi/internal/mediaType.ts +6 -0
- package/src/unstable/persistence/PersistedQueue.ts +16 -14
- package/src/unstable/reactivity/Atom.ts +1 -1
- package/src/unstable/reactivity/AtomHttpApi.ts +164 -162
- package/src/unstable/rpc/RpcServer.ts +10 -4
- package/src/unstable/workflow/DurableDeferred.ts +1 -1
- package/src/unstable/workflow/WorkflowProxyServer.ts +11 -12
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as Cause from "../../Cause.ts"
|
|
2
|
-
import * as Data from "../../Data.ts"
|
|
3
2
|
import * as Effect from "../../Effect.ts"
|
|
4
|
-
import * as Exit from "../../Exit.ts"
|
|
5
3
|
import * as Pipeable from "../../Pipeable.ts"
|
|
6
4
|
import type * as Schema from "../../Schema.ts"
|
|
7
5
|
import * as SchemaAST from "../../SchemaAST.ts"
|
|
6
|
+
import { SchemaError } from "../../SchemaError.ts"
|
|
8
7
|
import type { Issue } from "../../SchemaIssue.ts"
|
|
9
8
|
import * as SchemaParser from "../../SchemaParser.ts"
|
|
10
9
|
|
|
@@ -35,34 +34,16 @@ export function make<S extends Schema.Constraint>(ast: S["ast"], options?: objec
|
|
|
35
34
|
}
|
|
36
35
|
self.ast = ast
|
|
37
36
|
self.rebuild = (ast: SchemaAST.AST) => make(ast, options)
|
|
37
|
+
const makeEffect = SchemaParser.makeEffect(self)
|
|
38
38
|
self.makeEffect = (input: S["~type.make.in"], options?: Schema.MakeOptions) =>
|
|
39
|
-
|
|
39
|
+
fromIssueEffect(makeEffect(input, options))
|
|
40
40
|
self.make = SchemaParser.make(self)
|
|
41
41
|
self.makeOption = SchemaParser.makeOption(self)
|
|
42
42
|
return self
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/** @internal */
|
|
46
|
-
export
|
|
47
|
-
|
|
48
|
-
// purposefully not internal
|
|
49
|
-
export class SchemaError extends Data.TaggedError("SchemaError")<{
|
|
50
|
-
readonly issue: Issue
|
|
51
|
-
}> {
|
|
52
|
-
readonly [SchemaErrorTypeId]: typeof SchemaErrorTypeId = SchemaErrorTypeId
|
|
53
|
-
constructor(issue: Issue) {
|
|
54
|
-
super({ issue })
|
|
55
|
-
}
|
|
56
|
-
override get message() {
|
|
57
|
-
return this.issue.toString()
|
|
58
|
-
}
|
|
59
|
-
override toString() {
|
|
60
|
-
return `SchemaError(${this.message})`
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** @internal */
|
|
65
|
-
export function mapSchemaIssueEffect<A, R>(
|
|
46
|
+
export function fromIssueEffect<A, R>(
|
|
66
47
|
self: Effect.Effect<A, Issue, R>
|
|
67
48
|
): Effect.Effect<A, SchemaError, R> {
|
|
68
49
|
return Effect.catchCause(
|
|
@@ -71,20 +52,6 @@ export function mapSchemaIssueEffect<A, R>(
|
|
|
71
52
|
)
|
|
72
53
|
}
|
|
73
54
|
|
|
74
|
-
/** @internal */
|
|
75
|
-
export function mapSchemaErrorEffect<A, R>(
|
|
76
|
-
self: Effect.Effect<A, SchemaError, R>
|
|
77
|
-
): Effect.Effect<A, Issue, R> {
|
|
78
|
-
return Effect.catchCause(self, (cause) => Effect.failCauseSync(() => Cause.map(cause, (error) => error.issue)))
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/** @internal */
|
|
82
|
-
export function mapSchemaIssueExit<A>(exit: Exit.Exit<A, Issue>): Exit.Exit<A, SchemaError> {
|
|
83
|
-
return Exit.isSuccess(exit)
|
|
84
|
-
? Exit.succeed(exit.value)
|
|
85
|
-
: Exit.failCause(Cause.map(exit.cause, (issue) => new SchemaError(issue)))
|
|
86
|
-
}
|
|
87
|
-
|
|
88
55
|
/** @internal */
|
|
89
56
|
export const jsonReorder = makeReorder(getJsonPriority)
|
|
90
57
|
|
|
@@ -127,8 +127,9 @@ export type CliError =
|
|
|
127
127
|
* @category models
|
|
128
128
|
* @since 4.0.0
|
|
129
129
|
*/
|
|
130
|
-
export class UnrecognizedOption extends Schema.
|
|
131
|
-
|
|
130
|
+
export class UnrecognizedOption extends Schema.TaggedErrorClass<UnrecognizedOption>(
|
|
131
|
+
`${TypeId}/UnrecognizedOption`
|
|
132
|
+
)("UnrecognizedOption", {
|
|
132
133
|
option: Schema.String,
|
|
133
134
|
command: Schema.optional(Schema.Array(Schema.String)),
|
|
134
135
|
suggestions: Schema.Array(Schema.String)
|
|
@@ -178,8 +179,9 @@ export class UnrecognizedOption extends Schema.ErrorClass<UnrecognizedOption>(`$
|
|
|
178
179
|
* @category models
|
|
179
180
|
* @since 4.0.0
|
|
180
181
|
*/
|
|
181
|
-
export class DuplicateOption extends Schema.
|
|
182
|
-
|
|
182
|
+
export class DuplicateOption extends Schema.TaggedErrorClass<DuplicateOption>(
|
|
183
|
+
`${TypeId}/DuplicateOption`
|
|
184
|
+
)("DuplicateOption", {
|
|
183
185
|
option: Schema.String,
|
|
184
186
|
parentCommand: Schema.String,
|
|
185
187
|
childCommand: Schema.String
|
|
@@ -232,8 +234,9 @@ export class DuplicateOption extends Schema.ErrorClass<DuplicateOption>(`${TypeI
|
|
|
232
234
|
* @category models
|
|
233
235
|
* @since 4.0.0
|
|
234
236
|
*/
|
|
235
|
-
export class MissingOption extends Schema.
|
|
236
|
-
|
|
237
|
+
export class MissingOption extends Schema.TaggedErrorClass<MissingOption>(
|
|
238
|
+
`${TypeId}/MissingOption`
|
|
239
|
+
)("MissingOption", {
|
|
237
240
|
option: Schema.String
|
|
238
241
|
}) {
|
|
239
242
|
/**
|
|
@@ -282,8 +285,9 @@ export class MissingOption extends Schema.ErrorClass<MissingOption>(`${TypeId}/M
|
|
|
282
285
|
* @category models
|
|
283
286
|
* @since 4.0.0
|
|
284
287
|
*/
|
|
285
|
-
export class MissingArgument extends Schema.
|
|
286
|
-
|
|
288
|
+
export class MissingArgument extends Schema.TaggedErrorClass<MissingArgument>(
|
|
289
|
+
`${TypeId}/MissingArgument`
|
|
290
|
+
)("MissingArgument", {
|
|
287
291
|
argument: Schema.String
|
|
288
292
|
}) {
|
|
289
293
|
/**
|
|
@@ -337,8 +341,9 @@ export class MissingArgument extends Schema.ErrorClass<MissingArgument>(`${TypeI
|
|
|
337
341
|
* @category models
|
|
338
342
|
* @since 4.0.0
|
|
339
343
|
*/
|
|
340
|
-
export class InvalidValue extends Schema.
|
|
341
|
-
|
|
344
|
+
export class InvalidValue extends Schema.TaggedErrorClass<InvalidValue>(
|
|
345
|
+
`${TypeId}/InvalidValue`
|
|
346
|
+
)("InvalidValue", {
|
|
342
347
|
option: Schema.String,
|
|
343
348
|
value: Schema.String,
|
|
344
349
|
expected: Schema.String,
|
|
@@ -400,8 +405,9 @@ export class InvalidValue extends Schema.ErrorClass<InvalidValue>(`${TypeId}/Inv
|
|
|
400
405
|
* @category models
|
|
401
406
|
* @since 4.0.0
|
|
402
407
|
*/
|
|
403
|
-
export class UnknownSubcommand extends Schema.
|
|
404
|
-
|
|
408
|
+
export class UnknownSubcommand extends Schema.TaggedErrorClass<UnknownSubcommand>(
|
|
409
|
+
`${TypeId}/UnknownSubcommand`
|
|
410
|
+
)("UnknownSubcomand", {
|
|
405
411
|
subcommand: Schema.String,
|
|
406
412
|
parent: Schema.optional(Schema.Array(Schema.String)),
|
|
407
413
|
suggestions: Schema.Array(Schema.String)
|
|
@@ -464,8 +470,9 @@ export class UnknownSubcommand extends Schema.ErrorClass<UnknownSubcommand>(`${T
|
|
|
464
470
|
* @category models
|
|
465
471
|
* @since 4.0.0
|
|
466
472
|
*/
|
|
467
|
-
export class UserError extends Schema.
|
|
468
|
-
|
|
473
|
+
export class UserError extends Schema.TaggedErrorClass<UserError>(
|
|
474
|
+
`${TypeId}/UserError`
|
|
475
|
+
)("UserError", {
|
|
469
476
|
cause: Schema.Defect()
|
|
470
477
|
}) {
|
|
471
478
|
/**
|
|
@@ -533,8 +540,9 @@ export type NonShowHelpErrors = typeof NonShowHelpErrors.Type
|
|
|
533
540
|
* @category models
|
|
534
541
|
* @since 4.0.0
|
|
535
542
|
*/
|
|
536
|
-
export class ShowHelp extends Schema.
|
|
537
|
-
|
|
543
|
+
export class ShowHelp extends Schema.TaggedErrorClass<ShowHelp>(
|
|
544
|
+
`${TypeId}/ShowHelp`
|
|
545
|
+
)("ShowHelp", {
|
|
538
546
|
commandPath: Schema.Array(Schema.String),
|
|
539
547
|
errors: Schema.Array(NonShowHelpErrors)
|
|
540
548
|
}) {
|
|
@@ -697,7 +697,7 @@ export const make: {
|
|
|
697
697
|
name: Name,
|
|
698
698
|
config: Config,
|
|
699
699
|
handler: (config: Command.Config.Infer<Config>) => Effect.Effect<void, E, R>
|
|
700
|
-
): Command<Name, Command.Config.Infer<Config>, {}, E, Exclude<R,
|
|
700
|
+
): Command<Name, Command.Config.Infer<Config>, {}, E, Exclude<R, BuiltInSettingContext>>
|
|
701
701
|
} = ((
|
|
702
702
|
name: string,
|
|
703
703
|
config?: Command.Config,
|
|
@@ -772,7 +772,7 @@ export const withHandler: {
|
|
|
772
772
|
*/
|
|
773
773
|
<A, R, E>(handler: (value: A) => Effect.Effect<void, E, R>): <Name extends string, XR, XE, ContextInput>(
|
|
774
774
|
self: Command<Name, A, ContextInput, XE, XR>
|
|
775
|
-
) => Command<Name, A, ContextInput, E, Exclude<R,
|
|
775
|
+
) => Command<Name, A, ContextInput, E, Exclude<R, BuiltInSettingContext>>
|
|
776
776
|
/* ========================================================================== */
|
|
777
777
|
/* Combinators */
|
|
778
778
|
/* ========================================================================== */
|
|
@@ -805,11 +805,11 @@ export const withHandler: {
|
|
|
805
805
|
<Name extends string, A, XR, XE, R, E, ContextInput>(
|
|
806
806
|
self: Command<Name, A, ContextInput, XE, XR>,
|
|
807
807
|
handler: (value: A) => Effect.Effect<void, E, R>
|
|
808
|
-
): Command<Name, A, ContextInput, E, Exclude<R,
|
|
808
|
+
): Command<Name, A, ContextInput, E, Exclude<R, BuiltInSettingContext>>
|
|
809
809
|
} = dual(2, <Name extends string, A, XR, XE, R, E, ContextInput>(
|
|
810
810
|
self: Command<Name, A, ContextInput, XE, XR>,
|
|
811
811
|
handler: (value: A) => Effect.Effect<void, E, R>
|
|
812
|
-
): Command<Name, A, ContextInput, E, Exclude<R,
|
|
812
|
+
): Command<Name, A, ContextInput, E, Exclude<R, BuiltInSettingContext>> =>
|
|
813
813
|
makeCommand({ ...toImpl(self), handle: handler } as any))
|
|
814
814
|
|
|
815
815
|
interface SubcommandGroupInternal {
|
|
@@ -1272,6 +1272,7 @@ type ExtractGlobalFlagContext<T extends ReadonlyArray<GlobalFlag.GlobalFlag<any>
|
|
|
1272
1272
|
? F extends GlobalFlag.Setting<infer Id, infer _A> ? GlobalFlag.Setting.Identifier<Id>
|
|
1273
1273
|
: never
|
|
1274
1274
|
: never
|
|
1275
|
+
type BuiltInSettingContext = ExtractGlobalFlagContext<typeof GlobalFlag.BuiltIns>
|
|
1275
1276
|
type ExtractSubcommand<T> = T extends Command<infer _Name, infer _Input, infer _CI, infer _E, infer _R> ? T
|
|
1276
1277
|
: T extends Command.SubcommandGroup<infer Commands> ? Commands[number]
|
|
1277
1278
|
: never
|
|
@@ -2352,15 +2353,14 @@ export const runWith = <const Name extends string, Input, E, R, ContextInput>(
|
|
|
2352
2353
|
|
|
2353
2354
|
// 7. Provide setting values
|
|
2354
2355
|
let program = commandImpl.handle(parseResult.success, [command.name])
|
|
2356
|
+
const [, logLevel] = yield* GlobalFlag.LogLevel.flag.parse(emptyArgs)
|
|
2357
|
+
program = Effect.provideService(program, GlobalFlag.LogLevel, logLevel)
|
|
2355
2358
|
for (const flag of activeFlags) {
|
|
2356
|
-
if (flag._tag !== "Setting") continue
|
|
2359
|
+
if (flag._tag !== "Setting" || flag === GlobalFlag.LogLevel) continue
|
|
2357
2360
|
const [, value] = yield* flag.flag.parse(emptyArgs)
|
|
2358
2361
|
program = Effect.provideService(program, flag, value)
|
|
2359
2362
|
}
|
|
2360
2363
|
|
|
2361
|
-
const [, logLevel] = yield* GlobalFlag.LogLevel.flag.parse(emptyArgs)
|
|
2362
|
-
program = Effect.provideService(program, GlobalFlag.LogLevel, logLevel)
|
|
2363
|
-
|
|
2364
2364
|
// 8. Apply built-in setting behavior
|
|
2365
2365
|
const services = Option.match(logLevel, {
|
|
2366
2366
|
onNone: () => Context.empty(),
|
|
@@ -156,12 +156,11 @@ export const Help: Action<boolean> = action({
|
|
|
156
156
|
Flag.withAlias("h"),
|
|
157
157
|
Flag.withDescription("Show help information")
|
|
158
158
|
),
|
|
159
|
-
run: (_, { command, commandPath })
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
})
|
|
159
|
+
run: Effect.fnUntraced(function*(_, { command, commandPath }) {
|
|
160
|
+
const formatter = yield* CliOutput.Formatter
|
|
161
|
+
const helpDoc = yield* HelpInternal.getHelpForCommandPath(command, commandPath, BuiltIns)
|
|
162
|
+
yield* Console.log(formatter.formatHelpDoc(helpDoc))
|
|
163
|
+
})
|
|
165
164
|
})
|
|
166
165
|
|
|
167
166
|
/**
|
|
@@ -179,11 +178,10 @@ export const Version: Action<boolean> = action({
|
|
|
179
178
|
Flag.withAlias("v"),
|
|
180
179
|
Flag.withDescription("Show version information")
|
|
181
180
|
),
|
|
182
|
-
run: (_, { command, version })
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
})
|
|
181
|
+
run: Effect.fnUntraced(function*(_, { command, version }) {
|
|
182
|
+
const formatter = yield* CliOutput.Formatter
|
|
183
|
+
yield* Console.log(formatter.formatVersion(command.name, version))
|
|
184
|
+
})
|
|
187
185
|
})
|
|
188
186
|
|
|
189
187
|
/**
|
|
@@ -206,14 +204,13 @@ export const Completions: Action<Option.Option<"bash" | "zsh" | "fish">> = actio
|
|
|
206
204
|
Flag.withMetavar("<bash|zsh|fish|sh>"),
|
|
207
205
|
Flag.withDescription("Print shell completion script")
|
|
208
206
|
),
|
|
209
|
-
run: (shell, { command })
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
})
|
|
207
|
+
run: Effect.fnUntraced(function*(shell, { command }) {
|
|
208
|
+
if (Option.isNone(shell)) return
|
|
209
|
+
const descriptor = CommandDescriptor.fromCommand(command)
|
|
210
|
+
yield* Console.log(
|
|
211
|
+
Completions_.generate(command.name, shell.value, descriptor)
|
|
212
|
+
)
|
|
213
|
+
})
|
|
217
214
|
})
|
|
218
215
|
|
|
219
216
|
/**
|
|
@@ -279,17 +276,9 @@ export const LogLevel: Setting<"log-level", Option.Option<LogLevelType>> = setti
|
|
|
279
276
|
* @category references
|
|
280
277
|
* @since 4.0.0
|
|
281
278
|
*/
|
|
282
|
-
export const BuiltIns:
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
]
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Built-in setting context identifiers.
|
|
291
|
-
*
|
|
292
|
-
* @category models
|
|
293
|
-
* @since 4.0.0
|
|
294
|
-
*/
|
|
295
|
-
export type BuiltInSettingContext = Setting.Identifier<"log-level">
|
|
279
|
+
export const BuiltIns: readonly [
|
|
280
|
+
Action<boolean>,
|
|
281
|
+
Action<boolean>,
|
|
282
|
+
Action<Option.Option<"bash" | "zsh" | "fish">>,
|
|
283
|
+
Setting<"log-level", Option.Option<LogLevelType>>
|
|
284
|
+
] = [Help, Version, Completions, LogLevel]
|
|
@@ -34,27 +34,25 @@ import type { Sharding } from "./Sharding.ts"
|
|
|
34
34
|
*/
|
|
35
35
|
export const layerHttpApi = <
|
|
36
36
|
ApiId extends string,
|
|
37
|
-
Groups extends HttpApiGroup.
|
|
38
|
-
|
|
37
|
+
Groups extends HttpApiGroup.Constraint,
|
|
38
|
+
Identifier extends HttpApiGroup.Identifier<Groups>,
|
|
39
39
|
Type extends string,
|
|
40
40
|
Rpcs extends Rpc.Any
|
|
41
41
|
>(
|
|
42
42
|
api: HttpApi.HttpApi<ApiId, Groups>,
|
|
43
|
-
|
|
43
|
+
identifier: Identifier,
|
|
44
44
|
entity: Entity.Entity<Type, Rpcs>
|
|
45
|
-
): Layer.Layer<HttpApiGroup.
|
|
45
|
+
): Layer.Layer<HttpApiGroup.Service<ApiId, Identifier>, never, Sharding | Rpc.ServicesServer<Rpcs>> =>
|
|
46
46
|
HttpApiBuilder.group(
|
|
47
47
|
api,
|
|
48
|
-
|
|
49
|
-
Effect.fnUntraced(function*(
|
|
48
|
+
identifier,
|
|
49
|
+
Effect.fnUntraced(function*(handlers: any) {
|
|
50
50
|
const client = yield* entity.client
|
|
51
|
-
|
|
52
|
-
for (const parentRpc_ of entity.protocol.requests.values()) {
|
|
53
|
-
const parentRpc = parentRpc_ as any as Rpc.AnyWithProps
|
|
51
|
+
for (const parentRpc of entity.protocol.requests.values()) {
|
|
54
52
|
handlers = handlers
|
|
55
53
|
.handle(
|
|
56
|
-
parentRpc._tag
|
|
57
|
-
(
|
|
54
|
+
parentRpc._tag,
|
|
55
|
+
({ params, payload }: { params: { entityId: string }; payload: any }) =>
|
|
58
56
|
(client(params.entityId) as any as Record<string, (p: any) => Effect.Effect<any>>)[parentRpc._tag](
|
|
59
57
|
payload
|
|
60
58
|
).pipe(
|
|
@@ -65,11 +63,11 @@ export const layerHttpApi = <
|
|
|
65
63
|
entityId: params.entityId,
|
|
66
64
|
method: parentRpc._tag
|
|
67
65
|
})
|
|
68
|
-
)
|
|
66
|
+
)
|
|
69
67
|
)
|
|
70
68
|
.handle(
|
|
71
|
-
`${parentRpc._tag}Discard
|
|
72
|
-
(
|
|
69
|
+
`${parentRpc._tag}Discard`,
|
|
70
|
+
({ params, payload }: { params: { entityId: string }; payload: any }) =>
|
|
73
71
|
(client(params.entityId) as any as Record<string, (p: any, o: {}) => Effect.Effect<any>>)[parentRpc._tag](
|
|
74
72
|
payload,
|
|
75
73
|
{ discard: true }
|
|
@@ -81,10 +79,10 @@ export const layerHttpApi = <
|
|
|
81
79
|
entityId: params.entityId,
|
|
82
80
|
method: `${parentRpc._tag}Discard`
|
|
83
81
|
})
|
|
84
|
-
)
|
|
85
|
-
)
|
|
82
|
+
)
|
|
83
|
+
)
|
|
86
84
|
}
|
|
87
|
-
return handlers as HttpApiBuilder.Handlers<never
|
|
85
|
+
return handlers as HttpApiBuilder.Handlers<never>
|
|
88
86
|
})
|
|
89
87
|
)
|
|
90
88
|
|
|
@@ -207,15 +207,21 @@ export const make = Effect.fnUntraced(function*<
|
|
|
207
207
|
(isShuttingDown || isUninterruptibleForServer(request.message.annotations))
|
|
208
208
|
) {
|
|
209
209
|
if (!isShuttingDown) {
|
|
210
|
-
return server.write(
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
tag: request.message.envelope.tag as any,
|
|
214
|
-
payload: new Request({
|
|
210
|
+
return server.write(
|
|
211
|
+
0,
|
|
212
|
+
{
|
|
215
213
|
...request.message.envelope,
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
214
|
+
id: request.message.envelope.requestId as any,
|
|
215
|
+
tag: request.message.envelope.tag as any,
|
|
216
|
+
payload: new Request({
|
|
217
|
+
...request.message.envelope,
|
|
218
|
+
lastSentChunk: request.lastSentChunk
|
|
219
|
+
} as any) as any
|
|
220
|
+
},
|
|
221
|
+
Context.get(request.rpc.annotations, WithTransaction)
|
|
222
|
+
? { onRequest: options.storage.withTransaction }
|
|
223
|
+
: undefined
|
|
224
|
+
).pipe(
|
|
219
225
|
Effect.forkIn(scope)
|
|
220
226
|
)
|
|
221
227
|
}
|
|
@@ -295,16 +301,22 @@ export const make = Effect.fnUntraced(function*<
|
|
|
295
301
|
for (const id of defectRequestIds) {
|
|
296
302
|
const request = activeRequests.get(id)
|
|
297
303
|
if (!request) continue
|
|
298
|
-
const { lastSentChunk, message } = request
|
|
299
|
-
yield* server.write(
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
tag: message.envelope.tag as any,
|
|
303
|
-
payload: new Request({
|
|
304
|
+
const { lastSentChunk, message, rpc } = request
|
|
305
|
+
yield* server.write(
|
|
306
|
+
0,
|
|
307
|
+
{
|
|
304
308
|
...message.envelope,
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
309
|
+
id: message.envelope.requestId as any,
|
|
310
|
+
tag: message.envelope.tag as any,
|
|
311
|
+
payload: new Request({
|
|
312
|
+
...message.envelope,
|
|
313
|
+
lastSentChunk
|
|
314
|
+
} as any) as any
|
|
315
|
+
},
|
|
316
|
+
Context.get(rpc.annotations, WithTransaction)
|
|
317
|
+
? { onRequest: options.storage.withTransaction }
|
|
318
|
+
: undefined
|
|
319
|
+
)
|
|
308
320
|
}
|
|
309
321
|
defectRequestIds.clear()
|
|
310
322
|
}
|
|
@@ -341,11 +353,11 @@ export const make = Effect.fnUntraced(function*<
|
|
|
341
353
|
const state: EntityState = {
|
|
342
354
|
scope,
|
|
343
355
|
address,
|
|
344
|
-
write(clientId, message) {
|
|
356
|
+
write(clientId, message, writeOptions) {
|
|
345
357
|
if (writeRef.state.current._tag !== "Acquired") {
|
|
346
|
-
return Effect.flatMap(writeRef.await, (write) => write(clientId, message))
|
|
358
|
+
return Effect.flatMap(writeRef.await, (write) => write(clientId, message, writeOptions))
|
|
347
359
|
}
|
|
348
|
-
return writeRef.state.current.value(clientId, message)
|
|
360
|
+
return writeRef.state.current.value(clientId, message, writeOptions)
|
|
349
361
|
},
|
|
350
362
|
activeRequests,
|
|
351
363
|
lastActiveCheck: clock.currentTimeMillisUnsafe(),
|
|
@@ -472,21 +484,23 @@ export const make = Effect.fnUntraced(function*<
|
|
|
472
484
|
})
|
|
473
485
|
}
|
|
474
486
|
server.activeRequests.set(message.envelope.requestId, entry)
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
payload: new Request({
|
|
487
|
+
return server.write(
|
|
488
|
+
0,
|
|
489
|
+
{
|
|
479
490
|
...message.envelope,
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
491
|
+
id: message.envelope.requestId as any,
|
|
492
|
+
payload: new Request({
|
|
493
|
+
...message.envelope,
|
|
494
|
+
lastSentChunk: Option.filter(
|
|
495
|
+
message.lastSentReply,
|
|
496
|
+
(reply): reply is Reply.Chunk<R> => reply._tag === "Chunk"
|
|
497
|
+
)
|
|
498
|
+
})
|
|
499
|
+
},
|
|
500
|
+
Context.get(message.annotations, WithTransaction)
|
|
501
|
+
? { onRequest: options.storage.withTransaction }
|
|
502
|
+
: undefined
|
|
503
|
+
)
|
|
490
504
|
}
|
|
491
505
|
case "IncomingEnvelope": {
|
|
492
506
|
const entry = server.activeRequests.get(message.envelope.requestId)
|