Skip to content

Commit 66f1fa8

Browse files
authored
chore: upgrade effect to 4.0.6 (#59630)
1 parent 7d0f79d commit 66f1fa8

13 files changed

Lines changed: 492 additions & 416 deletions

File tree

‎bun.lock‎

Lines changed: 12 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545
"packages/stats/*"
4646
],
4747
"catalog": {
48-
"@effect/opentelemetry": "4.0.1",
49-
"@effect/platform-node": "4.0.1",
50-
"@effect/platform-node-shared": "4.0.1",
51-
"@effect/sql-sqlite-bun": "4.0.1",
48+
"@effect/opentelemetry": "4.0.6",
49+
"@effect/platform-node": "4.0.6",
50+
"@effect/platform-node-shared": "4.0.6",
51+
"@effect/sql-sqlite-bun": "4.0.6",
5252
"@npmcli/arborist": "9.4.0",
5353
"@types/bun": "1.4.3",
5454
"@types/cross-spawn": "6.0.6",
@@ -79,7 +79,7 @@
7979
"dompurify": "3.4.17",
8080
"drizzle-kit": "1.0.0-rc.5-ab785fc",
8181
"drizzle-orm": "1.0.0-rc.5-169397b",
82-
"effect": "4.0.1",
82+
"effect": "4.0.6",
8383
"fast-check": "4.9.0",
8484
"cross-spawn": "7.0.6",
8585
"hono": "4.13.13",

‎packages/client/src/promise/generated/types.ts‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/codemode/src/tool-schema.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ const docTags = (schema: JsonSchema): Array<string> => {
7979
}
8080
if (typeof schema.format === "string") tags.push(`@format ${schema.format}`)
8181
if (schema.type === "integer") tags.push("@integer")
82-
if (typeof schema.minimum === "number") tags.push(`@minimum ${schema.minimum}`)
83-
if (typeof schema.maximum === "number") tags.push(`@maximum ${schema.maximum}`)
82+
const integer = schema.type === "integer"
83+
if (typeof schema.minimum === "number" && !(integer && schema.minimum === Number.MIN_SAFE_INTEGER))
84+
tags.push(`@minimum ${schema.minimum}`)
85+
if (typeof schema.maximum === "number" && !(integer && schema.maximum === Number.MAX_SAFE_INTEGER))
86+
tags.push(`@maximum ${schema.maximum}`)
8487
if (typeof schema.exclusiveMinimum === "number") tags.push(`@exclusiveMinimum ${schema.exclusiveMinimum}`)
8588
if (typeof schema.exclusiveMaximum === "number") tags.push(`@exclusiveMaximum ${schema.exclusiveMaximum}`)
8689
if (typeof schema.multipleOf === "number") tags.push(`@multipleOf ${schema.multipleOf}`)
@@ -154,7 +157,10 @@ const renderSchema = (
154157
}
155158
if (schema.const !== undefined) return renderLiteral(schema.const)
156159
if (schema.enum) return schema.enum.map(renderLiteral).join(" | ")
157-
const alternatives = schema.anyOf ?? schema.oneOf
160+
const listed = schema.anyOf ?? schema.oneOf
161+
const alternatives = listed?.some((item) => item.type === "number")
162+
? listed.filter((item) => !effectNumberSentinel(item))
163+
: listed
158164
if (alternatives) {
159165
if (
160166
alternatives.some((item) => item.type === "number") &&

‎packages/core/src/database/sqlite.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export const makeClient = <
7878
acquirer,
7979
compiler: Statement.makeCompilerSqlite(options.transformQueryNames),
8080
transactionAcquirer,
81+
driver: "sqlite",
8182
spanAttributes: [
8283
...(options.spanAttributes ? Object.entries(options.spanAttributes) : []),
8384
["db.system.name", "sqlite"],

‎packages/core/src/database/sqlite.workerd.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ const make = (options: Config) =>
185185
compiler,
186186
transactionAcquirer,
187187
transactionService: WorkerdTransaction,
188+
driver: "sqlite-do",
188189
spanAttributes: [
189190
...(options.spanAttributes ? Object.entries(options.spanAttributes) : []),
190191
[ATTR_DB_SYSTEM_NAME, "sqlite"],

‎packages/core/src/tool/runtime.ts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,21 @@ const flattenAllOf = (value: unknown): unknown => {
191191
if (Array.isArray(value)) return value.map(flattenAllOf)
192192
if (typeof value !== "object" || value === null) return value
193193

194-
const schema = Object.fromEntries(Object.entries(value).map(([key, item]) => [key, flattenAllOf(item)]))
194+
// Effect adds the safe-integer range to every Schema.Int. Drop it so tool schemas don't change and
195+
// bust prompt caches.
196+
const integer = "type" in value && value.type === "integer"
197+
const schema = Object.fromEntries(
198+
Object.entries(value)
199+
.filter(
200+
([key, item]) =>
201+
!integer ||
202+
!(
203+
(key === "minimum" && item === Number.MIN_SAFE_INTEGER) ||
204+
(key === "maximum" && item === Number.MAX_SAFE_INTEGER)
205+
),
206+
)
207+
.map(([key, item]) => [key, flattenAllOf(item)]),
208+
)
195209
if (!Array.isArray(schema.allOf) || !schema.allOf.every(isRecord) || !canFlattenAllOf(schema.allOf, schema))
196210
return schema
197211
const { allOf, ...rest } = schema

‎packages/core/test/database-migration.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const parkedClient = (arrived: Deferred.Deferred<void>, gate: Deferred.Deferred<
5858
executeRaw: (query, params) => park(query, connection.executeRaw(query, params)),
5959
}),
6060
compiler: Statement.makeCompilerSqlite(),
61+
driver: client.driver,
6162
spanAttributes: [],
6263
})
6364
}),

‎packages/httpapi-codegen/src/index.ts‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ type PromiseInputField =
106106
| (InputField & { readonly optional: boolean })
107107
| { readonly name: string; readonly source: "wildcard"; readonly optional: false }
108108

109-
const resolveHttpApiStatus = SchemaAST.resolveAt<number>("httpApiStatus")
109+
const resolveHttpApiStatus = (ast: SchemaAST.AST) =>
110+
SchemaAST.resolveAt<number>("httpApiStatus")(ast) ??
111+
(ast.checks === undefined ? ast.context?.annotations?.httpApiStatus : undefined)
110112
const resolveHttpApiEncoding = SchemaAST.resolveAt<HttpApiSchema.Encoding>("~httpApiEncoding")
111113
const Manifest = Schema.fromJsonString(Schema.Array(Schema.String))
112114
const manifestName = ".httpapi-codegen.json"
@@ -1784,7 +1786,10 @@ function sameChecks(left: SchemaAST.Checks | undefined, right: SchemaAST.Checks
17841786
}
17851787

17861788
function sameContext(left: SchemaAST.Context | undefined, right: SchemaAST.Context | undefined) {
1787-
return left?.isOptional === right?.isOptional && left?.isMutable === right?.isMutable
1789+
return (
1790+
(left?.isOptional ?? false) === (right?.isOptional ?? false) &&
1791+
(left?.isMutable ?? false) === (right?.isMutable ?? false)
1792+
)
17881793
}
17891794

17901795
export function write(
@@ -2068,7 +2073,9 @@ function isDataEnvelope(schema: Schema.Top) {
20682073
)
20692074
}
20702075

2071-
function isStreamSchema(schema: Schema.Top): schema is HttpApiSchema.StreamSchema {
2076+
function isStreamSchema(
2077+
schema: Schema.Top,
2078+
): schema is Exclude<HttpApiSchema.StreamSchema, HttpApiSchema.StreamNdjson<Schema.Top>> {
20722079
return "_tag" in schema && (schema._tag === "StreamSse" || schema._tag === "StreamUint8Array")
20732080
}
20742081

@@ -2171,7 +2178,7 @@ function renderGroup(group: Group) {
21712178
const inputDeclaration =
21722179
operation.operation.inputMode === "none"
21732180
? ""
2174-
: `${opaquePayload ? `type ${prefix}Request = Parameters<RawGroup[${JSON.stringify(endpoint.identifier)}]>[0]\n` : ""}type ${prefix}Input = { ${inputType} }\n`
2181+
: `${opaquePayload ? `type ${prefix}Request = Parameters<RawGroup[${JSON.stringify(endpoint.identifier)}]>[0] & { readonly responseMode?: "decoded-only" }\n` : ""}type ${prefix}Input = { ${inputType} }\n`
21752182
adapters.push(
21762183
`${inputDeclaration}const ${prefix}DeclaredError = ${declaredSchema}\nconst map${prefix}Error = (error: unknown) => HttpClientError.isHttpClientError(error) || Schema.isSchemaError(error) || Sse.Retry.is(error) ? new ClientError({ cause: error }) : Schema.is(${prefix}DeclaredError)(error) ? error : new ClientError({ cause: error })\nconst ${prefix} = (raw: RawGroup) => (${argument}) => ${operation.operation.success === "stream" ? `Stream.unwrap(${rawCall}.pipe(Effect.mapError(map${prefix}Error), Effect.map((stream) => stream.pipe(Stream.mapError(map${prefix}Error)))))` : mapped}`,
21772184
)
@@ -2252,7 +2259,9 @@ function renderSchemas(slots: ReadonlyArray<Slot>) {
22522259
]
22532260
const document = SchemaRepresentation.toCodeDocument(
22542261
SchemaRepresentation.toRepresentations(
2255-
codegenAsts(expanded.map((slot) => slot.schema.ast)) as [SchemaAST.AST, ...Array<SchemaAST.AST>],
2262+
codegenAsts(
2263+
expanded.map((slot) => slot.schema.annotate({ httpApiStatus: resolveHttpApiStatus(slot.schema.ast) }).ast),
2264+
) as [SchemaAST.AST, ...Array<SchemaAST.AST>],
22562265
),
22572266
)
22582267
const artifacts = document.artifacts.flatMap((artifact) => {

‎packages/httpapi-codegen/test/generated/session.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const mapEndpointInterruptError = (error: unknown) =>
114114
const EndpointInterrupt = (raw: RawGroup) => (input: EndpointInterruptInput) =>
115115
raw["interrupt"]({ params: { sessionID: input["sessionID"] } }).pipe(Effect.mapError(mapEndpointInterruptError))
116116

117-
type EndpointConfigureRequest = Parameters<RawGroup["configure"]>[0]
117+
type EndpointConfigureRequest = Parameters<RawGroup["configure"]>[0] & { readonly responseMode?: "decoded-only" }
118118
type EndpointConfigureInput = {
119119
readonly sessionID: (typeof EndpointConfigureParams.Type)["sessionID"]
120120
readonly dryRun?: (typeof EndpointConfigureQuery.Type)["dryRun"]

0 commit comments

Comments
 (0)