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.

41 lines (40 loc) • 1.29 kB
//#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"); const pastLimit = groups.filter((group) => group.exceedsPlanLimit === true); return [ ...heading, "User groups available in this app:", "", ...groups.map(({ id, name, type }) => `- ${name} (${id}), ${type.toLowerCase()}`), "", ...pastLimit.length === 0 ? [] : [ "## Not available on the workspace's plan", "", "The plan allows fewer custom user groups than this app has. The groups below are kept with their members, but nobody counts as a member of them until the plan is upgraded, so a page or an action limited to one of them admits no user:", "", ...pastLimit.map(({ id, name }) => `- ${name} (${id})`), "" ] ].join("\n"); } //#endregion export { renderUserGroups, renderUserGroupsDoc };