Skip to content

accept UrlParams.Input in some UrlParams apis - #2505

Merged
tim-smart merged 5 commits into
Effect-TS:mainfrom
KhraksMamtsov:url-search-input
Jul 1, 2026
Merged

accept UrlParams.Input in some UrlParams apis#2505
tim-smart merged 5 commits into
Effect-TS:mainfrom
KhraksMamtsov:url-search-input

Conversation

@KhraksMamtsov

Copy link
Copy Markdown
Contributor

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Updated the Input type to include the target type, following the approach used in the Duration module, to improve usability.

Related

  • Related Issue #
  • Closes #

@changeset-bot

changeset-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6ab7cfd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@KhraksMamtsov KhraksMamtsov changed the title make input type like in great duration module make input type like in duration module Jun 29, 2026
@KhraksMamtsov KhraksMamtsov changed the title make input type like in duration module make input type like in the Duration module Jun 29, 2026
Comment thread packages/effect/src/unstable/http/Url.ts Outdated
Comment thread packages/effect/src/unstable/http/Headers.ts
@KhraksMamtsov

KhraksMamtsov commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

@tim-smart
I'd also suggest either removing this function or moving it from UrlParams to Url.

The behavior of baseUrl() isn't very intuitive.

const baseUrl = (): string | undefined => {
  if (
    "location" in globalThis &&
    globalThis.location !== undefined &&
    globalThis.location.origin !== undefined &&
    globalThis.location.pathname !== undefined
  ) {
    return location.origin + location.pathname
  }
  return undefined
}

/**
 * Creates a `URL` safely by appending `UrlParams` and an optional hash to a URL string.
 *
 * **Details**
 *
 * Returns a `Result` that fails with `UrlParamsError` if the URL cannot be
 * constructed.
 *
 * @category converting
 * @since 4.0.0
 */
export const makeUrl = (
  url: string,
  params: UrlParams,
  hash: string | undefined
): Result.Result<URL, UrlParamsError> => {
  try {
    const urlInstance = new URL(url, baseUrl())
    for (let i = 0; i < params.params.length; i++) {
      const [key, value] = params.params[i]
      if (value !== undefined) {
        urlInstance.searchParams.append(key, value)
      }
    }
    if (hash !== undefined) {
      urlInstance.hash = hash
    }
    return Result.succeed(urlInstance)
  } catch (e) {
    return Result.fail(new UrlParamsError({ cause: e }))
  }
}

@tim-smart tim-smart changed the title make input type like in the Duration module accept UrlParams.Input in some UrlParams apis Jul 1, 2026
@tim-smart
tim-smart enabled auto-merge (squash) July 1, 2026 21:39
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

File Name Current Size Previous Size Difference
basic.ts 6.58 KB 6.58 KB 0.00 KB (0.00%)
batching.ts 9.09 KB 9.09 KB 0.00 KB (0.00%)
brand.ts 6.14 KB 6.14 KB 0.00 KB (0.00%)
cache.ts 9.79 KB 9.79 KB 0.00 KB (0.00%)
config.ts 18.63 KB 18.63 KB 0.00 KB (0.00%)
differ.ts 16.84 KB 16.84 KB 0.00 KB (0.00%)
http-client.ts 20.35 KB 20.34 KB +0.01 KB (+0.06%)
logger.ts 10.13 KB 10.13 KB 0.00 KB (0.00%)
metric.ts 8.42 KB 8.42 KB 0.00 KB (0.00%)
optic.ts 7.35 KB 7.35 KB 0.00 KB (0.00%)
pubsub.ts 13.89 KB 13.89 KB 0.00 KB (0.00%)
queue.ts 10.97 KB 10.97 KB 0.00 KB (0.00%)
schedule.ts 10.17 KB 10.17 KB 0.00 KB (0.00%)
schema-class.ts 17.70 KB 17.70 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 3.49 KB 3.49 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 26.90 KB 26.90 KB 0.00 KB (0.00%)
schema-string-transformation.ts 12.47 KB 12.47 KB 0.00 KB (0.00%)
schema-string.ts 10.18 KB 10.18 KB 0.00 KB (0.00%)
schema-template-literal.ts 14.07 KB 14.07 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 20.50 KB 20.50 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 21.07 KB 21.07 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 17.65 KB 17.65 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 17.55 KB 17.55 KB 0.00 KB (0.00%)
schema-toFormatter.ts 17.41 KB 17.41 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 19.96 KB 19.96 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 17.94 KB 17.94 KB 0.00 KB (0.00%)
schema.ts 16.98 KB 16.98 KB 0.00 KB (0.00%)
stm.ts 11.89 KB 11.89 KB 0.00 KB (0.00%)
stream.ts 9.20 KB 9.20 KB 0.00 KB (0.00%)

@tim-smart
tim-smart merged commit 5713ee7 into Effect-TS:main Jul 1, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants