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.

32 lines (31 loc) • 800 B
//#region src/codegen/user-groups.ts const DOC_NOTE = "> This document is generated automatically when a change is made in the app's user groups."; function renderUserGroups(groups) { return [ "interface SoftrUserGroups {", ` ids: ${groups.length === 0 ? "never" : groups.map(({ id }) => JSON.stringify(id)).join(" | ")};`, "}" ].join("\n"); } function renderUserGroupsDoc(groups) { const heading = [ "# User groups", "", DOC_NOTE, "" ]; if (groups.length === 0) return [ ...heading, "This app has no user groups.", "" ].join("\n"); return [ ...heading, "User groups available in this app:", "", ...groups.map(({ id, name, type }) => `- ${name} (${id}), ${type.toLowerCase()}`), "" ].join("\n"); } //#endregion export { renderUserGroups, renderUserGroupsDoc };