UNPKG

@softr/sdk

Version:

The SDK for building Softr apps on TanStack Start. It lets an app interact with Softr: auth, datasources, workflows and integrations.

30 lines • 1.34 kB
//#region src/record-url.d.ts /** * A record page's path segment: the record's name and its id, such as * `belem-coast-cruiser--2d0grM08PZDtDs`. A link then shows what it opens, and * search results show a readable address. `name` is the value of the record's * name field. When it is not text, or has no letters or digits, the segment is the id. * * The route keeps one parameter for it. Read the id back with {@link recordIdFromSlug}. * * @example * <Link to="/bikes/$bikeId" params={{ bikeId: recordSlug(bike.id, bike.fields.name) }}> */ declare function recordSlug(id: string, name: unknown): string; /** * The record id in a path segment that {@link recordSlug} made. A segment with * no name part is the id itself, so a link with a plain id still opens the page. * * @example * loader: async ({ params }) => { * const bike = await loadBike({ data: recordIdFromSlug(params.bikeId) }) * if (bike === null) throw notFound() * const slug = recordSlug(bike.id, bike.fields.name) * // One address per record: an old name or a plain id moves to the current one. * if (params.bikeId !== slug) throw redirect({ to: "/bikes/$bikeId", params: { bikeId: slug }, statusCode: 301 }) * return bike * } */ declare function recordIdFromSlug(segment: string): string; //#endregion export { recordIdFromSlug, recordSlug };