Skip to content
24 changes: 24 additions & 0 deletions .changeset/36444-setup-public-forms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
'@object-ui/app-shell': patch
'@object-ui/i18n': patch
'@objectstack/platform-objects': patch
'@objectstack/spec': patch
'@objectstack/metadata-core': patch
---

feat(setup): Setup → Configuration → Public forms lists every public form of the environment and switches it on or off

Clause-②: yes (widening) — a new Setup navigation id `nav_public_forms`, a new component id `forms:public-forms`, new language-pack keys (the `publicFormsSetup` block and the nav label) in every shipped locale, and `anonymousFormIntakeWithdrawnIn` newly exported from `@objectstack/spec/ui` (moved from `@objectstack/metadata-core`, which re-exports the same binding)
Metadata-protocol: none

A system administrator (`manage_platform_settings`, the capability the Setup entry asks) now has one page for the operations side of public forms. It lists every public form of the environment: its name, the object a submission creates a record of, its address, and whether it is on. Per row: switch it on or off, copy its address, or open it in a new tab. A form is designed (created, deleted, its fields and title changed) in Studio, not here.

- **Which forms are listed.** A form view whose `sharing` opens it to anonymous intake once switched on (`allowAnonymous: true` and a `publicLink`), read by the same rule the anonymous form routes use (`anonymousFormIntakeCandidates`). A switched-off form stays listed and can be switched back on. A form with no public address or no anonymous access is an internal form and is not listed. The list is the effective one (`GET /meta/view`), so an installed app's form switched off in this environment lists as off.
- **Where a switch is saved.** The switch is the form's `sharing.enabled`, saved and published at once. A form of a writable package is saved in that package. A form of an installed (read-only) app is saved as this environment's customization, an override in the app's `.custom` package (ADR-0146), never an edit of the app's own package, so the app upgrades as before. Switching such a form back on removes the override when it held nothing but the switch, so the app's own form is served again; an override that also carries design changes keeps them, with the switch on.
- **A form its installed app ships switched off** (its address kept, `enabled` or `allowAnonymous` set to `false`, or `enabled` omitted, which the stack schema reads as `false`) stays closed whatever the environment saves: the anonymous routes treat the app's own document as a withdrawal that no override re-opens. The page judges this with the routes' own function, `anonymousFormIntakeWithdrawnIn`, now declared in `@objectstack/spec/ui` beside the rest of the intake rule; `@objectstack/metadata-core` re-exports the same binding, so the server's import is unchanged. The page lists such a form as "Off (switched off by its app)" with its switch disabled, also when an override already switches it on, and a switch-on writes nothing and says the app ships it switched off. A form whose app's document cannot be read is shown as status unknown, never as on.
- **After an app upgrade**, switching back on an override taken from an earlier version restores the app's own form when the form is otherwise unchanged. When it is not, the override is kept with the switch on and the page says the form stays on the app's earlier version, which Studio's "Restore package original" undoes.
- A switch over a draft already pending where it would save writes nothing and says so: that draft is its saver's and is never published on their behalf.
- A switch writes the form's metadata, which the server lets only a `manage_metadata` holder do. Without it the page still lists the forms but disables the switches and says why. A refused switch, and a list read that fails, are told in business words, never the server's raw message.
- A switched-off form keeps answering as it does today: `404 FORM_NOT_FOUND` at its address. No route, error code or stored key is added.

New Setup navigation entry `nav_public_forms` in `group_configuration` (label "Public Forms", in every shipped locale) opening the component `forms:public-forms`; the Setup navigation now carries 35 entries. New locale block `publicFormsSetup` in every console locale. Not shown: when a form last took a submission, since a submission is an ordinary record of the form's object and records no form.
10 changes: 6 additions & 4 deletions packages/cli/test/connect-agent-both-halves-wire.pin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,15 @@ describe('#17647 — Connect-an-Agent visibility: BOTH halves, over the wire', (
// `group_apps` held here, so that group collapses too; 31 until the
// Units of Measure entry, `nav_units_of_measure`, joined Configuration
// (#35488); 32 until the working-calendar pair, `nav_work_calendars`
// and `nav_work_calendar_exceptions`, joined it, ADR-0157.)
// and `nav_work_calendar_exceptions`, joined it, ADR-0157; 34 until
// the public forms entry, `nav_public_forms`, joined it, #36444.)
// `nav_settings_branding` is not among them, and not because of a
// tenancy wall (this harness boots none): since #24766 it is
// contributed by `@objectstack/service-settings` together with the
// `branding` namespace, offered only where no organization wall stands,
// and this harness composes platform-objects and the MCP bundle alone.
expect(allowedIds).toHaveLength(34);
expect(allowedIds).toHaveLength(35);
expect(allowedIds).toContain('nav_public_forms');
expect(allowedIds).toContain('nav_work_calendars');
expect(allowedIds).toContain('nav_work_calendar_exceptions');
expect(allowedIds).not.toContain('nav_packaged_actions');
Expand Down Expand Up @@ -312,8 +314,8 @@ describe('#17647 — Connect-an-Agent visibility: BOTH halves, over the wire', (
expect(withAccountHalf.statusCode).toBe(200);
expect(withoutAccountHalf.statusCode).toBe(200);
expect(navIds(withAccountHalf.body?.item)).toEqual(navIds(withoutAccountHalf.body?.item));
// 34: the composition the count in the test above states.
expect(navIds(withAccountHalf.body?.item)).toHaveLength(34);
// 35: the composition the count in the test above states.
expect(navIds(withAccountHalf.body?.item)).toHaveLength(35);

// The mechanism behind the invariance, asserted rather than assumed:
// the bundle aims exactly one contribution at `setup` and one at
Expand Down
3 changes: 2 additions & 1 deletion packages/metadata-core/src/anonymous-form-intake.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,14 @@ describe('anonymousFormIntakeWithdrawnIn — an explicit withdrawal of the same
// The candidates half is declared in `@objectstack/spec/ui` and re-exported by
// this package. "One copy" is checkable only as IDENTITY: a wrapper or a copy
// answers the same today and drifts tomorrow, while the same binding cannot.
describe('the candidates and object-name halves are the spec bindings themselves, re-exported (one copy, not a copy)', () => {
describe('the candidates, object-name and withdrawal halves are the spec bindings themselves, re-exported (one copy, not a copy)', () => {
const NAMES = [
'publicFormSlug',
'anonymousFormIntakeSlug',
'anonymousFormIntakeCandidates',
'anonymousFormIntakeSlugs',
'anonymousFormObjectName',
'anonymousFormIntakeWithdrawnIn',
] as const;

it.each(NAMES)('%s: this module and the package barrel export the @objectstack/spec/ui function', (name) => {
Expand Down
117 changes: 7 additions & 110 deletions packages/metadata-core/src/anonymous-form-intake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,23 @@ import {
postureEnforcesWall,
type TenancyPosture,
} from '@objectstack/spec/security';
import { publicFormSlug, type AnonymousFormIntakeCandidate } from '@objectstack/spec/ui';
import type { AnonymousFormIntakeCandidate } from '@objectstack/spec/ui';
import { applyInjectedSystemColumns } from './injected-system-columns.js';
import { resolveRecordWallOrganizationField } from './record-organization.js';

// The candidates half of the rule — which form candidates a `view` body opens
// to anonymous intake — and the object-name half (`anonymousFormObjectName`,
// the object a candidate submits into) live in `@objectstack/spec/ui` beside the
// `SharingConfigSchema` it reads, so a console can import the same rule the
// doors serve. Re-exported here as the SAME bindings (never a wrapper or a
// to anonymous intake — the object-name half (`anonymousFormObjectName`, the
// object a candidate submits into) and the withdrawal half
// (`anonymousFormIntakeWithdrawnIn`, whether a layer's body withdraws a
// candidate) live in `@objectstack/spec/ui` beside the `SharingConfigSchema`
// they read, so a console can import the same rule the doors serve. Re-exported here as the SAME bindings (never a wrapper or a
// copy), so every server caller keeps importing it from this package and the
// two entries cannot disagree; the identity is pinned in this module's test.
export {
anonymousFormIntakeCandidates,
anonymousFormIntakeSlug,
anonymousFormIntakeSlugs,
anonymousFormIntakeWithdrawnIn,
anonymousFormObjectName,
publicFormSlug,
} from '@objectstack/spec/ui';
Expand Down Expand Up @@ -196,108 +198,3 @@ export function anonymousFormIntakeUnavailableMessage(slug: string, u: Anonymous
);
}

/**
* Where a form sits in a `view` body, independent of its content: the nested
* `form`, one `formViews` entry, or the flattened `config`.
*/
function anonymousFormSlot(view: Record<string, any>, candidate: AnonymousFormIntakeCandidate): string {
if (candidate.form === view.form) return 'form';
if (candidate.key !== undefined && view.formViews?.[candidate.key] === candidate.form) {
return `formViews:${candidate.key}`;
}
return 'config';
}

/**
* The forms a `view` body EXPLICITLY withdraws, with their slot and slug: a
* form `sharing` that keeps a non-empty `publicLink` and sets `enabled ===
* false` or `allowAnonymous === false`. Judged on the body as stored: a switch
* that is absent is not a withdrawal (only an explicit `false` is), and a
* sharing with no public link withdraws nothing — removing the sharing block or
* clearing the link is not a withdrawal. A package artifact parsed by the
* stack schema (strict `defineStack`) carries the schema's default
* `enabled: false`, which is an explicit `false`: a shipped form that keeps its
* link without switching `enabled` on is withdrawn (fail closed). An artifact
* that reached the runtime unparsed (`strict: false`, a hand-built manifest)
* is judged as written, so a switch it omits is absent. The env-wide definition is the
* switch above it, so an env-wide save may still open it.
*/
function anonymousFormExplicitWithdrawals(view: unknown): Array<{ slot: string; slug: string }> {
if (!view || typeof view !== 'object') return [];
const v = view as Record<string, any>;
const forms: Array<{ slot: string; form: unknown }> = [];
if (v.form && typeof v.form === 'object') forms.push({ slot: 'form', form: v.form });
if (v.formViews && typeof v.formViews === 'object') {
for (const [key, fv] of Object.entries(v.formViews)) forms.push({ slot: `formViews:${key}`, form: fv });
}
if (v.viewKind === 'form' && v.config && typeof v.config === 'object') forms.push({ slot: 'config', form: v.config });
const out: Array<{ slot: string; slug: string }> = [];
for (const { slot, form } of forms) {
const sharing = form && typeof form === 'object' ? (form as Record<string, unknown>).sharing : undefined;
if (!sharing || typeof sharing !== 'object') continue;
const s = sharing as Record<string, unknown>;
if (typeof s.publicLink !== 'string' || !s.publicLink) continue;
if (s.enabled !== false && s.allowAnonymous !== false) continue;
out.push({ slot, slug: publicFormSlug(s.publicLink) });
}
return out;
}

/**
* Does one metadata layer withdraw an open form candidate? A WITHDRAWAL IS A
* KILL SWITCH: layering may only narrow anonymous intake, never re-open it, so
* the anonymous form doors serve a candidate only when no layer beneath it
* withdraws it, and the organization-scoped write door refuses a save that
* would leave one open.
*
* Identity is the `name`: the layer withdraws the candidate only through a
* body of the same `name` as the candidate's `view`. What that name is depends
* on the caller. The organization-scoped write door passes the env-wide body
* of the stored row the overlay is keyed by, so a key rename, a `form.name`,
* a slot move or an expansion rename is still judged against the form it was.
* The anonymous doors pass the env-wide view list and the item they serve, so
* they judge by the served item name (a known limit: an overlay stored before
* the withdrawal, or restored by rollback or revert, that moves its form to
* another key or slot is not matched there). The layer withdraws the
* candidate when its body of that name EXPLICITLY
* withdraws a form ({@link anonymousFormExplicitWithdrawals}) that matches the
* candidate by slot (the same `form`, `formViews` key or `config`) OR by slug
* (the same public link, compared exactly as the doors resolve it). Either
* match is enough, so the same form cannot escape a withdrawal by moving to
* another slot or key, or by pointing its link at a new slug; only a form that
* differs from every withdrawn one in both is a different form (a sibling in
* the same container).
*
* Another row that publishes or withdraws the same slug is a different form
* and closes nothing. The package a body is bound to is NOT compared: a
* withdrawal of a name closes that name's form in every package (a known
* limit that fails closed: it may over-close another package's form of the
* same name). It judges only the bodies the layer holds, so a caller closes a
* name in every package only when its layer holds every package's body of the
* name. The organization-scoped write door anchors one body per package. The
* env-wide view list the anonymous doors read holds one item per package of a
* name: a package's saved env-wide copy of a view container serves that
* package's item of each form it expands, and a package-less copy stands in
* for every package with no copy of its own. A layer
* with no body of the row, or whose body has no explicit withdrawal, withdraws
* nothing, so a form published only in an organization stays open there.
*/
export function anonymousFormIntakeWithdrawnIn(
layer: ReadonlyArray<unknown>,
view: unknown,
candidate: AnonymousFormIntakeCandidate,
): boolean {
if (!view || typeof view !== 'object') return false;
const v = view as Record<string, any>;
const name = typeof v.name === 'string' && v.name ? v.name : undefined;
if (name === undefined) return false;
const slot = anonymousFormSlot(v, candidate);
for (const other of layer) {
if (!other || typeof other !== 'object') continue;
if ((other as Record<string, unknown>).name !== name) continue;
for (const w of anonymousFormExplicitWithdrawals(other)) {
if (w.slot === slot || w.slug === candidate.slug) return true;
}
}
return false;
}
5 changes: 5 additions & 0 deletions packages/platform-objects/src/apps/setup-nav.contributions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ export const SETUP_NAV_CONTRIBUTIONS: NavigationContribution[] = [
// per object (`manageRecycleBin`), and the page lists only the objects
// whose bin the caller manages.
{ id: 'nav_recycle_bin', type: 'component', label: 'Recycle Bin', componentRef: 'data:recycle-bin', icon: 'trash-2' },
// objectstack#36444 — every public form of the environment (a form anyone
// fills in without signing in): switch one on or off, copy its address,
// open it. Operations only; Studio designs the forms. For system
// administrators: the page asks the same capability.
{ id: 'nav_public_forms', type: 'component', label: 'Public Forms', componentRef: 'forms:public-forms', icon: 'file-text', requiredPermissions: ['manage_platform_settings'] },
],
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export const arSourceHashes: Readonly<Record<string, string>> = {
'apps.setup.navigation.nav_settings_knowledge.label': '140348539a50d9d5',
'apps.setup.navigation.nav_settings_lifecycle.label': 'cd9fe9c930afed06',
'apps.setup.navigation.nav_recycle_bin.label': '2f5aefe2be221196',
'apps.setup.navigation.nav_public_forms.label': '4592e97959994e86',
'apps.setup.navigation.nav_notification_preferences.label': '8869f324c1bd545a',
'apps.setup.navigation.nav_notification_templates.label': '9e270c87ef2578df',
'apps.setup.navigation.nav_sessions.label': '673bde6e0c8a3ef9',
Expand Down
1 change: 1 addition & 0 deletions packages/platform-objects/src/apps/translations/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const ar: TranslationData = {
nav_settings_knowledge: { label: 'المعرفة' },
nav_settings_lifecycle: { label: 'دورة حياة البيانات' },
nav_recycle_bin: { label: 'سلة المحذوفات' },
nav_public_forms: { label: 'النماذج العامة' },
nav_notification_preferences: { label: 'تفضيلات الإشعارات' },
nav_notification_templates: { label: 'قوالب الإشعارات' },

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export const deSourceHashes: Readonly<Record<string, string>> = {
'apps.setup.navigation.nav_settings_knowledge.label': '140348539a50d9d5',
'apps.setup.navigation.nav_settings_lifecycle.label': 'cd9fe9c930afed06',
'apps.setup.navigation.nav_recycle_bin.label': '2f5aefe2be221196',
'apps.setup.navigation.nav_public_forms.label': '4592e97959994e86',
'apps.setup.navigation.nav_notification_preferences.label': '8869f324c1bd545a',
'apps.setup.navigation.nav_notification_templates.label': '9e270c87ef2578df',
'apps.setup.navigation.nav_sessions.label': '673bde6e0c8a3ef9',
Expand Down
1 change: 1 addition & 0 deletions packages/platform-objects/src/apps/translations/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export const de: TranslationData = {
nav_settings_knowledge: { label: 'Wissen' },
nav_settings_lifecycle: { label: 'Datenlebenszyklus' },
nav_recycle_bin: { label: 'Papierkorb' },
nav_public_forms: { label: 'Öffentliche Formulare' },
nav_notification_preferences: { label: 'Benachrichtigungseinstellungen' },
nav_notification_templates: { label: 'Benachrichtigungsvorlagen' },

Expand Down
1 change: 1 addition & 0 deletions packages/platform-objects/src/apps/translations/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export const en: TranslationData = {
nav_settings_knowledge: { label: 'Knowledge' },
nav_settings_lifecycle: { label: 'Data Lifecycle' },
nav_recycle_bin: { label: 'Recycle Bin' },
nav_public_forms: { label: 'Public Forms' },
// Notifications (contributed by @objectstack/service-messaging)
nav_notification_preferences: { label: 'Notification Preferences' },
nav_notification_templates: { label: 'Notification Templates' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export const esESSourceHashes: Readonly<Record<string, string>> = {
'apps.setup.navigation.nav_settings_knowledge.label': '140348539a50d9d5',
'apps.setup.navigation.nav_settings_lifecycle.label': 'cd9fe9c930afed06',
'apps.setup.navigation.nav_recycle_bin.label': '2f5aefe2be221196',
'apps.setup.navigation.nav_public_forms.label': '4592e97959994e86',
'apps.setup.navigation.nav_notification_preferences.label': '8869f324c1bd545a',
'apps.setup.navigation.nav_notification_templates.label': '9e270c87ef2578df',
'apps.setup.navigation.nav_sessions.label': '673bde6e0c8a3ef9',
Expand Down
1 change: 1 addition & 0 deletions packages/platform-objects/src/apps/translations/es-ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const esES: TranslationData = {
nav_settings_knowledge: { label: 'Conocimiento' },
nav_settings_lifecycle: { label: 'Ciclo de vida de los datos' },
nav_recycle_bin: { label: 'Papelera' },
nav_public_forms: { label: 'Formularios públicos' },
nav_notification_preferences: { label: 'Preferencias de Notificación' },
nav_notification_templates: { label: 'Plantillas de Notificación' },

Expand Down
Loading
Loading