import type { Literal, Quad_Object, NamedNode } from "@rdfjs/types"; import type { Time } from "../datatypes"; import type { Thing, ThingLocal, ThingPersisted, Url, UrlString } from "../interfaces"; import type { AddOfType } from "./add"; import { addStringWithLocale } from "./add"; import type { RemoveOfType } from "./remove"; import { removeLiteral, removeStringWithLocale } from "./remove"; import type { SetOfType } from "./set"; import { setStringWithLocale } from "./set"; import type { CreateThingLocalOptions, CreateThingPersistedOptions } from "./thing"; type Adder = (property: Parameters>[1], value: Parameters>[2]) => ThingBuilder; type Setter = (property: Parameters>[1], value: Parameters>[2]) => ThingBuilder; type Remover = (property: Parameters>[1], value: Parameters>[2]) => ThingBuilder; /** * A Fluent interface to build a [[Thing]]. * * Add, replace or remove property values using consecutive calls to `.add*()`, * `.set*()` and `.remove*()`, then finally generate a [[Thing]] with the given * properties using `.build()`. * @since 1.9.0 */ export type ThingBuilder = { build: () => T; addUrl: Adder; addIri: Adder; addBoolean: Adder; addDatetime: Adder; addDate: Adder; addTime: Adder; addDecimal: Adder; addInteger: Adder; addStringNoLocale: Adder; addStringEnglish: Adder; addStringWithLocale: (property: Parameters[1], value: Parameters[2], locale: Parameters[3]) => ThingBuilder; addNamedNode: Adder; addLiteral: Adder; addTerm: Adder; setUrl: Setter; setIri: Setter; setBoolean: Setter; setDatetime: Setter; setDate: Setter; setTime: Setter; setDecimal: Setter; setInteger: Setter; setStringNoLocale: Setter; setStringEnglish: Setter; setStringWithLocale: (property: Parameters[1], value: Parameters[2], locale: Parameters[3]) => ThingBuilder; setNamedNode: Setter; setLiteral: Setter; setTerm: Setter; removeAll: (property: Parameters[1]) => ThingBuilder; removeUrl: Remover; removeIri: Remover; removeBoolean: Remover; removeDatetime: Remover; removeDate: Remover; removeTime: Remover; removeDecimal: Remover; removeInteger: Remover; removeStringNoLocale: Remover; removeStringEnglish: Remover; removeStringWithLocale: (property: Parameters[1], value: Parameters[2], locale: Parameters[3]) => ThingBuilder; removeNamedNode: Remover; removeLiteral: Remover; }; /** * Modify a [[Thing]], setting multiple properties in a single expresssion. * * For example, you can initialise several properties of a given Thing as follows: * * const me = buildThing(createThing({ name: "profile-vincent" })) * .addUrl(rdf.type, schema.Person) * .addStringNoLocale(schema.givenName, "Vincent") * .build(); * * Take note of the final call to `.build()` to obtain the actual Thing. * * @param init A Thing to modify. * @returns a [[ThingBuilder]], a Fluent API that allows you to set multiple properties in a single expression. * @since 1.9.0 */ export declare function buildThing(init: ThingLocal): ThingBuilder; /** * Modify a [[Thing]], setting multiple properties in a single expresssion. * * For example, you can initialise several properties of a given Thing as follows: * * const me = buildThing(createThing({ url: "https://example.pod/profile#vincent" })) * .addUrl(rdf.type, schema.Person) * .addStringNoLocale(schema.givenName, "Vincent") * .build(); * * Take note of the final call to `.build()` to obtain the actual Thing. * * @param init A Thing to modify. * @returns a [[ThingBuilder]], a Fluent API that allows you to set multiple properties in a single expression. * @since 1.9.0 */ export declare function buildThing(init: ThingPersisted): ThingBuilder; /** * Create a [[Thing]], setting multiple properties in a single expresssion. * * For example, you can create a new Thing and initialise several properties as follows: * * const me = buildThing({ name: "profile-vincent" }) * .addUrl(rdf.type, schema.Person) * .addStringNoLocale(schema.givenName, "Vincent") * .build(); * * Take note of the final call to `.build()` to obtain the actual Thing. * * @param init Options used to initialise a new Thing. * @returns a [[ThingBuilder]], a Fluent API that allows you to set multiple properties in a single expression. * @since 1.9.0 */ export declare function buildThing(init: CreateThingLocalOptions): ThingBuilder; /** * Create a [[Thing]], setting multiple properties in a single expresssion. * * For example, you can create a new Thing and initialise several properties as follows: * * const me = buildThing({ url: "https://example.pod/profile#vincent" }) * .addUrl(rdf.type, schema.Person) * .addStringNoLocale(schema.givenName, "Vincent") * .build(); * * Take note of the final call to `.build()` to obtain the actual Thing. * * @param init Optionally pass an existing [[Thing]] to modify the properties of. If left empty, `buildThing` will initialise a new Thing. * @returns a [[ThingBuilder]], a Fluent API that allows you to set multiple properties in a single expression. * @since 1.9.0 */ export declare function buildThing(init: CreateThingPersistedOptions): ThingBuilder; /** * Create a [[Thing]], setting multiple properties in a single expresssion. * * For example, you can create a new Thing and initialise several properties as follows: * * const me = buildThing() * .addUrl(rdf.type, schema.Person) * .addStringNoLocale(schema.givenName, "Vincent") * .build(); * * Take note of the final call to `.build()` to obtain the actual Thing. * * @returns a [[ThingBuilder]], a Fluent API that allows you to set multiple properties in a single expression. * @since 1.9.0 */ export declare function buildThing(): ThingBuilder; export {};