/** * @since 1.0.0 */ import * as Arr from "effect/Array"; import type * as Effect from "effect/Effect"; import * as Either from "effect/Either"; import * as Option from "effect/Option"; import type * as ParseResult from "effect/ParseResult"; import * as Schema from "effect/Schema"; import type { ParseOptions } from "effect/SchemaAST"; /** * @since 1.0.0 * @category models */ export interface UrlParams extends ReadonlyArray { } /** * @since 1.0.0 * @category models */ export type Input = CoercibleRecord | Iterable | URLSearchParams; /** * @since 1.0.0 * @category models */ export type Coercible = string | number | bigint | boolean | null | undefined; /** * @since 1.0.0 * @category models */ export interface CoercibleRecord { readonly [key: string]: Coercible | ReadonlyArray | CoercibleRecord; } /** * @since 1.0.0 * @category constructors */ export declare const fromInput: (input: Input) => UrlParams; /** * @since 1.0.0 * @category schemas */ export declare const schemaFromSelf: Schema.Schema; /** * @since 1.0.0 * @category constructors */ export declare const empty: UrlParams; /** * @since 1.0.0 * @category combinators */ export declare const getAll: { /** * @since 1.0.0 * @category combinators */ (key: string): (self: UrlParams) => ReadonlyArray; /** * @since 1.0.0 * @category combinators */ (self: UrlParams, key: string): ReadonlyArray; }; /** * @since 1.0.0 * @category combinators */ export declare const getFirst: { /** * @since 1.0.0 * @category combinators */ (key: string): (self: UrlParams) => Option.Option; /** * @since 1.0.0 * @category combinators */ (self: UrlParams, key: string): Option.Option; }; /** * @since 1.0.0 * @category combinators */ export declare const getLast: { /** * @since 1.0.0 * @category combinators */ (key: string): (self: UrlParams) => Option.Option; /** * @since 1.0.0 * @category combinators */ (self: UrlParams, key: string): Option.Option; }; /** * @since 1.0.0 * @category combinators */ export declare const set: { /** * @since 1.0.0 * @category combinators */ (key: string, value: Coercible): (self: UrlParams) => UrlParams; /** * @since 1.0.0 * @category combinators */ (self: UrlParams, key: string, value: Coercible): UrlParams; }; /** * @since 1.0.0 * @category combinators */ export declare const setAll: { /** * @since 1.0.0 * @category combinators */ (input: Input): (self: UrlParams) => UrlParams; /** * @since 1.0.0 * @category combinators */ (self: UrlParams, input: Input): UrlParams; }; /** * @since 1.0.0 * @category combinators */ export declare const append: { /** * @since 1.0.0 * @category combinators */ (key: string, value: Coercible): (self: UrlParams) => UrlParams; /** * @since 1.0.0 * @category combinators */ (self: UrlParams, key: string, value: Coercible): UrlParams; }; /** * @since 1.0.0 * @category combinators */ export declare const appendAll: { /** * @since 1.0.0 * @category combinators */ (input: Input): (self: UrlParams) => UrlParams; /** * @since 1.0.0 * @category combinators */ (self: UrlParams, input: Input): UrlParams; }; /** * @since 1.0.0 * @category combinators */ export declare const remove: { /** * @since 1.0.0 * @category combinators */ (key: string): (self: UrlParams) => UrlParams; /** * @since 1.0.0 * @category combinators */ (self: UrlParams, key: string): UrlParams; }; /** * @since 1.0.0 * @category conversions */ export declare const makeUrl: (url: string, params: UrlParams, hash: Option.Option) => Either.Either; /** * @since 1.0.0 * @category conversions */ export declare const toString: (self: UrlParams) => string; /** * Builds a `Record` containing all the key-value pairs in the given `UrlParams` * as `string` (if only one value for a key) or a `NonEmptyArray` * (when more than one value for a key) * * **Example** * * ```ts * import * as assert from "node:assert" * import { UrlParams } from "@effect/platform" * * const urlParams = UrlParams.fromInput({ a: 1, b: true, c: "string", e: [1, 2, 3] }) * const result = UrlParams.toRecord(urlParams) * * assert.deepStrictEqual( * result, * { "a": "1", "b": "true", "c": "string", "e": ["1", "2", "3"] } * ) * ``` * * @since 1.0.0 * @category conversions */ export declare const toRecord: (self: UrlParams) => Record>; /** * @since 1.0.0 * @category schema */ export declare const schemaJson: (schema: Schema.Schema, options?: ParseOptions | undefined) => { (field: string): (self: UrlParams) => Effect.Effect; (self: UrlParams, field: string): Effect.Effect; }; /** * Extract schema from all key-value pairs in the given `UrlParams`. * * **Example** * * ```ts * import * as assert from "node:assert" * import { Effect, Schema } from "effect" * import { UrlParams } from "@effect/platform" * * Effect.gen(function* () { * const urlParams = UrlParams.fromInput({ "a": [10, "string"], "b": false }) * const result = yield* UrlParams.schemaStruct(Schema.Struct({ * a: Schema.Tuple(Schema.NumberFromString, Schema.String), * b: Schema.BooleanFromString * }))(urlParams) * * assert.deepStrictEqual(result, { * a: [10, "string"], * b: false * }) * }) * ``` * * @since 1.0.0 * @category schema */ export declare const schemaStruct: | undefined>, R>(schema: Schema.Schema, options?: ParseOptions | undefined) => (self: UrlParams) => Effect.Effect; /** * @since 1.0.0 * @category schema */ export declare const schemaFromString: Schema.Schema; /** * @since 1.0.0 * @category schema */ export declare const schemaRecord: | undefined>, R>(schema: Schema.Schema) => Schema.Schema; /** * @since 1.0.0 * @category schema */ export declare const schemaParse: | undefined>, R>(schema: Schema.Schema) => Schema.Schema; //# sourceMappingURL=UrlParams.d.ts.map