@protobase/ui 0.122.1 → 0.123.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/messages.d.ts +2 -2
- package/dist/activity-chart/messages.d.ts +2 -2
- package/dist/app/charts/messages.d.ts +2 -2
- package/dist/app/confirm-sign-in-messages.d.ts +2 -2
- package/dist/app/conversation-page/messages.d.ts +2 -2
- package/dist/app/create/messages.d.ts +2 -2
- package/dist/app/delete/messages.d.ts +2 -2
- package/dist/app/displays/messages.d.ts +2 -2
- package/dist/app/embedded-list/messages.d.ts +2 -2
- package/dist/app/export/messages.d.ts +2 -2
- package/dist/app/field-messages.d.ts +2 -2
- package/dist/app/field-types/custom-step-container/messages.d.ts +2 -2
- package/dist/app/field-types/json/messages.d.ts +2 -2
- package/dist/app/field-types/runner-install/messages.d.ts +2 -2
- package/dist/app/field-types/workflow/definition.d.ts +1 -1
- package/dist/app/field-types/workflow/messages.d.ts +2 -2
- package/dist/app/field-types/workflow/pins/pin-text.d.ts +1 -1
- package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
- package/dist/app/field-types/workflow-run/messages.d.ts +2 -2
- package/dist/app/field-types/workflow-status/messages.d.ts +2 -2
- package/dist/app/file-viewers/messages.d.ts +2 -2
- package/dist/app/focus/messages.d.ts +2 -2
- package/dist/app/gallery/messages.d.ts +2 -2
- package/dist/app/hand-order/messages.d.ts +2 -2
- package/dist/app/history/messages.d.ts +2 -2
- package/dist/app/import/messages.d.ts +2 -2
- package/dist/app/list-edit/messages.d.ts +2 -2
- package/dist/app/list-messages.d.ts +2 -2
- package/dist/app/messages.d.ts +2 -2
- package/dist/app/meta-gate-messages.d.ts +2 -2
- package/dist/app/new-version/messages.d.ts +2 -2
- package/dist/app/pages/messages.d.ts +2 -2
- package/dist/app/record-chart/messages.d.ts +2 -2
- package/dist/app/record-messages.d.ts +2 -2
- package/dist/app/record-mode/shown-layout.d.ts +1 -1
- package/dist/app/record-row/messages.d.ts +2 -2
- package/dist/app/related-cards/messages.d.ts +2 -2
- package/dist/app/runtime/messages.d.ts +2 -2
- package/dist/app/saved/messages.d.ts +2 -2
- package/dist/app/search/messages.d.ts +2 -2
- package/dist/app/searches/messages.d.ts +2 -2
- package/dist/app-shell/messages.d.ts +2 -2
- package/dist/assistant-dock/messages.d.ts +2 -2
- package/dist/auth/messages.d.ts +2 -2
- package/dist/calls/messages.d.ts +2 -2
- package/dist/data-grid/column-spec.d.ts +1 -1
- package/dist/data-grid/messages.d.ts +2 -2
- package/dist/filter-panel/messages.d.ts +2 -2
- package/dist/inline-child-table/messages.d.ts +2 -2
- package/dist/invitations/messages.d.ts +2 -2
- package/dist/mailbox/messages.d.ts +2 -2
- package/dist/mentions/messages.d.ts +2 -2
- package/dist/mocks/customers.d.ts +1 -1
- package/dist/mocks/invoices.d.ts +2 -2
- package/dist/mocks/orders.d.ts +2 -2
- package/dist/notifications/bell/messages.d.ts +2 -2
- package/dist/organizations/messages.d.ts +2 -2
- package/dist/package.js +1 -1
- package/dist/record-view/messages.d.ts +2 -2
- package/dist/record-view/use-autosave.d.ts +1 -1
- package/dist/shell/assets/{account-page-BESKgoYT.js → account-page-D15oXHUN.js} +2 -2
- package/dist/shell/assets/{app-DANB5cb3.js → app-CG26wvV-.js} +5 -5
- package/dist/shell/assets/{assistant-shell-DUxCRpci.js → assistant-shell-vuaTWe1u.js} +2 -2
- package/dist/shell/assets/{board-display-Blx6nTDs.js → board-display-DPYwY014.js} +2 -2
- package/dist/shell/assets/{calendar-display-SPyIwDLG.js → calendar-display-CPqQ_x_H.js} +2 -2
- package/dist/shell/assets/{call-rings-BGJkCQwP.js → call-rings-CN1O37Vm.js} +2 -2
- package/dist/shell/assets/{calls-BRoDIvWu.js → calls-BgpYzNDg.js} +2 -2
- package/dist/shell/assets/{circle-alert-BZyGgZSj.js → circle-alert-CYtCwklT.js} +2 -2
- package/dist/shell/assets/{composed-page-By2d8F85.js → composed-page-CfvP7zgM.js} +2 -2
- package/dist/shell/assets/{composer-section-BiCIOqwU.js → composer-section-D8Iupdnl.js} +2 -2
- package/dist/shell/assets/{connect-route-BZsnJGaF.js → connect-route-2GF04qVw.js} +2 -2
- package/dist/shell/assets/{copy-field-DpbjVuK4.js → copy-field-Od-pW31E.js} +2 -2
- package/dist/shell/assets/{create-route-DglCC2Tk.js → create-route-BOGcWPvp.js} +2 -2
- package/dist/shell/assets/{custom-step-container-field-DJbluU0F.js → custom-step-container-field-B0JbqL0W.js} +2 -2
- package/dist/shell/assets/{embedded-list-CepLmiOu.js → embedded-list-BiErfCKc.js} +3 -3
- package/dist/shell/assets/{export-dialog-B9fvLoT2.js → export-dialog-Cj0urwkZ.js} +2 -2
- package/dist/shell/assets/{first-organization-page-CSIsJmoQ.js → first-organization-page-Cr_eunjI.js} +2 -2
- package/dist/shell/assets/{graph-view-IPDrZVmC.js → graph-view-Ck8qrE0y.js} +2 -2
- package/dist/shell/assets/{group-donut-DRT539D9.js → group-donut-_2BqPybE.js} +2 -2
- package/dist/shell/assets/{guest-call-page-IxjqrW0F.js → guest-call-page-BKpxRWu7.js} +3 -3
- package/dist/shell/assets/{html-viewer-C-FI9kDC.js → html-viewer-PjyNPHSq.js} +2 -2
- package/dist/shell/assets/{import-dialog-DDaXN05w.js → import-dialog-K0rhUDim.js} +2 -2
- package/dist/shell/assets/{import-table-dialog-CHWoi7_S.js → import-table-dialog-QNdJfEUq.js} +2 -2
- package/dist/shell/assets/{index-tI-2Oomu.js → index-xBA_aU0w.js} +1 -1
- package/dist/shell/assets/{invitations-page-BE0tj3Aw.js → invitations-page-BA90Dbkk.js} +2 -2
- package/dist/shell/assets/{layout-grid-7R6t_Nlh.js → layout-grid-Cr-RvgOt.js} +2 -2
- package/dist/shell/assets/{legend-item-C-DA-JTo.js → legend-item-BOIlaOng.js} +2 -2
- package/dist/shell/assets/{list-page-Dj-oZ99M.js → list-page-lR1G4P0j.js} +4 -4
- package/dist/shell/assets/{maplibre-D0uTAdwG.js → maplibre-BOy1wGSA.js} +2 -2
- package/dist/shell/assets/{markdown-content-BpKVfSRq.js → markdown-content-BrnTSgUW.js} +2 -2
- package/dist/shell/assets/{members-page-Ced4meCg.js → members-page-VcGQ0wXn.js} +2 -2
- package/dist/shell/assets/{message-content-DSZOlZUY.js → message-content-BLdexhtW.js} +2 -2
- package/dist/shell/assets/{messages-CEK97JXa.js → messages-DPRjc1DX.js} +2 -2
- package/dist/shell/assets/{organization-page-Dp_D2xbC.js → organization-page-DprBMbrZ.js} +2 -2
- package/dist/shell/assets/{organizations-page-CtrgjIWL.js → organizations-page--4KynkcH.js} +2 -2
- package/dist/shell/assets/{pending-invitation-row-Bs60Zx0i.js → pending-invitation-row-2aTEUX6U.js} +2 -2
- package/dist/shell/assets/{period-chart-CIgxhMTn.js → period-chart-Bf1e1Rfd.js} +2 -2
- package/dist/shell/assets/{person-row-BH3iAvuG.js → person-row-DM8AgaGL.js} +2 -2
- package/dist/shell/assets/{public-form-page-NPPZ_rgo.js → public-form-page-Dk47d12N.js} +2 -2
- package/dist/shell/assets/{record-lines-hY9wRXCf.js → record-lines-DO-JkjJw.js} +2 -2
- package/dist/shell/assets/{record-map-Dzt7xpK8.js → record-map-BM3T3O3d.js} +2 -2
- package/dist/shell/assets/{record-opens-DN1LnH9j.js → record-opens-1_hpMdpy.js} +2 -2
- package/dist/shell/assets/{record-page-CSsNYC0Q.js → record-page-C7tfbihg.js} +3 -3
- package/dist/shell/assets/{record-preview-B1WiPOw4.js → record-preview-WMGeft1g.js} +2 -2
- package/dist/shell/assets/{records-map-BLcMBygH.js → records-map-DA4QJ5o1.js} +2 -2
- package/dist/shell/assets/{render-node-DyvozeRy.js → render-node-BYXtHiwx.js} +3 -3
- package/dist/shell/assets/{reorder-button-NNfcfua7.js → reorder-button-DlbkRsr1.js} +2 -2
- package/dist/shell/assets/{run-trace-view-BoBj-5R0.js → run-trace-view-DZqLuDCs.js} +2 -2
- package/dist/shell/assets/{runner-install-field-BdfsPY9H.js → runner-install-field-CZFX7YDn.js} +2 -2
- package/dist/shell/assets/{runtime-update-CRO1fS5O.js → runtime-update-BSvbTfZB.js} +2 -2
- package/dist/shell/assets/{shared-protobase-ui-BbJCcQ0y.js → shared-protobase-ui-CDYOdP3n.js} +1 -1
- package/dist/shell/assets/{sheet-source-DSJ73Heh.js → sheet-source-8s0DvsVl.js} +2 -2
- package/dist/shell/assets/{sign-in-policy-page-RaxuDREW.js → sign-in-policy-page-BJN_TfWv.js} +2 -2
- package/dist/shell/assets/{start-block-queries-DTa6akPc.js → start-block-queries-nfDrEnQD.js} +2 -2
- package/dist/shell/assets/{step-catalog-UHxllpni.js → step-catalog-QhL8OPW4.js} +2 -2
- package/dist/shell/assets/{step-panel-BkpaCVJd.js → step-panel-k-OfcV1o.js} +2 -2
- package/dist/shell/assets/{timeline-display-CFIOdA59.js → timeline-display-CbqpZrs6.js} +2 -2
- package/dist/shell/assets/{trash-IV6Ox5bV.js → trash-C576xGNJ.js} +2 -2
- package/dist/shell/assets/{update-set-BTHuLrBr.js → update-set-OSkktpzc.js} +2 -2
- package/dist/shell/assets/{use-calendar-move-CaU_5smA.js → use-calendar-move-DJbTVBiR.js} +2 -2
- package/dist/shell/assets/{use-display-rows-C_H7lxLW.js → use-display-rows-xrXX3vo7.js} +2 -2
- package/dist/shell/assets/{use-my-invitations-DSp8OwP9.js → use-my-invitations-BzmabmV5.js} +2 -2
- package/dist/shell/assets/{use-paged-search-DOcO0Rbz.js → use-paged-search-1j6rT5dX.js} +2 -2
- package/dist/shell/assets/{use-run-trace-BsH3vq5k.js → use-run-trace-DhxoDhjX.js} +2 -2
- package/dist/shell/assets/{use-workflow-page-DDl2MUPY.js → use-workflow-page-Dof4TXvO.js} +2 -2
- package/dist/shell/assets/{use-workflow-types-nJ6UhHeL.js → use-workflow-types-DlnnSIon.js} +2 -2
- package/dist/shell/assets/{workflow-canvas-xG0FmrJj.js → workflow-canvas-04KWcras.js} +2 -2
- package/dist/shell/assets/{workflow-field-fuI75chK.js → workflow-field-DnRl3Zn3.js} +3 -3
- package/dist/shell/assets/{workflow-graph-editor-DCCcZ5AP.js → workflow-graph-editor-CW-k7iPq.js} +2 -2
- package/dist/shell/assets/{workflow-run-field-BxIU66mn.js → workflow-run-field-Cb04vQvU.js} +3 -3
- package/dist/shell/assets/{workflow-status-field-Bnk5IHI5.js → workflow-status-field-D4-yEdIA.js} +2 -2
- package/dist/shell/assets/{workflow-workbench-7EvpXFq6.js → workflow-workbench-BBRBLI2p.js} +2 -2
- package/dist/shell/index.html +3 -3
- package/dist/shell/protobase.shell.json +2 -2
- package/dist/shell/protobase.sw.js +2 -2
- package/dist/shell-source-maps/assets/{account-page-BESKgoYT.js.map → account-page-D15oXHUN.js.map} +1 -1
- package/dist/shell-source-maps/assets/{app-DANB5cb3.js.map → app-CG26wvV-.js.map} +1 -1
- package/dist/shell-source-maps/assets/{assistant-shell-DUxCRpci.js.map → assistant-shell-vuaTWe1u.js.map} +1 -1
- package/dist/shell-source-maps/assets/{board-display-Blx6nTDs.js.map → board-display-DPYwY014.js.map} +1 -1
- package/dist/shell-source-maps/assets/{calendar-display-SPyIwDLG.js.map → calendar-display-CPqQ_x_H.js.map} +1 -1
- package/dist/shell-source-maps/assets/{call-rings-BGJkCQwP.js.map → call-rings-CN1O37Vm.js.map} +1 -1
- package/dist/shell-source-maps/assets/{calls-BRoDIvWu.js.map → calls-BgpYzNDg.js.map} +1 -1
- package/dist/shell-source-maps/assets/{circle-alert-BZyGgZSj.js.map → circle-alert-CYtCwklT.js.map} +1 -1
- package/dist/shell-source-maps/assets/{composed-page-By2d8F85.js.map → composed-page-CfvP7zgM.js.map} +1 -1
- package/dist/shell-source-maps/assets/{composer-section-BiCIOqwU.js.map → composer-section-D8Iupdnl.js.map} +1 -1
- package/dist/shell-source-maps/assets/{connect-route-BZsnJGaF.js.map → connect-route-2GF04qVw.js.map} +1 -1
- package/dist/shell-source-maps/assets/{copy-field-DpbjVuK4.js.map → copy-field-Od-pW31E.js.map} +1 -1
- package/dist/shell-source-maps/assets/{create-route-DglCC2Tk.js.map → create-route-BOGcWPvp.js.map} +1 -1
- package/dist/shell-source-maps/assets/{custom-step-container-field-DJbluU0F.js.map → custom-step-container-field-B0JbqL0W.js.map} +1 -1
- package/dist/shell-source-maps/assets/{embedded-list-CepLmiOu.js.map → embedded-list-BiErfCKc.js.map} +1 -1
- package/dist/shell-source-maps/assets/{export-dialog-B9fvLoT2.js.map → export-dialog-Cj0urwkZ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{first-organization-page-CSIsJmoQ.js.map → first-organization-page-Cr_eunjI.js.map} +1 -1
- package/dist/shell-source-maps/assets/{graph-view-IPDrZVmC.js.map → graph-view-Ck8qrE0y.js.map} +1 -1
- package/dist/shell-source-maps/assets/{group-donut-DRT539D9.js.map → group-donut-_2BqPybE.js.map} +1 -1
- package/dist/shell-source-maps/assets/{guest-call-page-IxjqrW0F.js.map → guest-call-page-BKpxRWu7.js.map} +1 -1
- package/dist/shell-source-maps/assets/{html-viewer-C-FI9kDC.js.map → html-viewer-PjyNPHSq.js.map} +1 -1
- package/dist/shell-source-maps/assets/{import-dialog-DDaXN05w.js.map → import-dialog-K0rhUDim.js.map} +1 -1
- package/dist/shell-source-maps/assets/{import-table-dialog-CHWoi7_S.js.map → import-table-dialog-QNdJfEUq.js.map} +1 -1
- package/dist/shell-source-maps/assets/{invitations-page-BE0tj3Aw.js.map → invitations-page-BA90Dbkk.js.map} +1 -1
- package/dist/shell-source-maps/assets/{layout-grid-7R6t_Nlh.js.map → layout-grid-Cr-RvgOt.js.map} +1 -1
- package/dist/shell-source-maps/assets/{legend-item-C-DA-JTo.js.map → legend-item-BOIlaOng.js.map} +1 -1
- package/dist/shell-source-maps/assets/{list-page-Dj-oZ99M.js.map → list-page-lR1G4P0j.js.map} +1 -1
- package/dist/shell-source-maps/assets/{maplibre-D0uTAdwG.js.map → maplibre-BOy1wGSA.js.map} +1 -1
- package/dist/shell-source-maps/assets/{markdown-content-BpKVfSRq.js.map → markdown-content-BrnTSgUW.js.map} +1 -1
- package/dist/shell-source-maps/assets/{members-page-Ced4meCg.js.map → members-page-VcGQ0wXn.js.map} +1 -1
- package/dist/shell-source-maps/assets/{message-content-DSZOlZUY.js.map → message-content-BLdexhtW.js.map} +1 -1
- package/dist/shell-source-maps/assets/{messages-CEK97JXa.js.map → messages-DPRjc1DX.js.map} +1 -1
- package/dist/shell-source-maps/assets/{organization-page-Dp_D2xbC.js.map → organization-page-DprBMbrZ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{organizations-page-CtrgjIWL.js.map → organizations-page--4KynkcH.js.map} +1 -1
- package/dist/shell-source-maps/assets/{pending-invitation-row-Bs60Zx0i.js.map → pending-invitation-row-2aTEUX6U.js.map} +1 -1
- package/dist/shell-source-maps/assets/{period-chart-CIgxhMTn.js.map → period-chart-Bf1e1Rfd.js.map} +1 -1
- package/dist/shell-source-maps/assets/{person-row-BH3iAvuG.js.map → person-row-DM8AgaGL.js.map} +1 -1
- package/dist/shell-source-maps/assets/{public-form-page-NPPZ_rgo.js.map → public-form-page-Dk47d12N.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-lines-hY9wRXCf.js.map → record-lines-DO-JkjJw.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-map-Dzt7xpK8.js.map → record-map-BM3T3O3d.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-opens-DN1LnH9j.js.map → record-opens-1_hpMdpy.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-page-CSsNYC0Q.js.map → record-page-C7tfbihg.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-preview-B1WiPOw4.js.map → record-preview-WMGeft1g.js.map} +1 -1
- package/dist/shell-source-maps/assets/{records-map-BLcMBygH.js.map → records-map-DA4QJ5o1.js.map} +1 -1
- package/dist/shell-source-maps/assets/{render-node-DyvozeRy.js.map → render-node-BYXtHiwx.js.map} +1 -1
- package/dist/shell-source-maps/assets/{reorder-button-NNfcfua7.js.map → reorder-button-DlbkRsr1.js.map} +1 -1
- package/dist/shell-source-maps/assets/{run-trace-view-BoBj-5R0.js.map → run-trace-view-DZqLuDCs.js.map} +1 -1
- package/dist/shell-source-maps/assets/{runner-install-field-BdfsPY9H.js.map → runner-install-field-CZFX7YDn.js.map} +1 -1
- package/dist/shell-source-maps/assets/{runtime-update-CRO1fS5O.js.map → runtime-update-BSvbTfZB.js.map} +1 -1
- package/dist/shell-source-maps/assets/{sheet-source-DSJ73Heh.js.map → sheet-source-8s0DvsVl.js.map} +1 -1
- package/dist/shell-source-maps/assets/{sign-in-policy-page-RaxuDREW.js.map → sign-in-policy-page-BJN_TfWv.js.map} +1 -1
- package/dist/shell-source-maps/assets/{start-block-queries-DTa6akPc.js.map → start-block-queries-nfDrEnQD.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-catalog-UHxllpni.js.map → step-catalog-QhL8OPW4.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-panel-BkpaCVJd.js.map → step-panel-k-OfcV1o.js.map} +1 -1
- package/dist/shell-source-maps/assets/{timeline-display-CFIOdA59.js.map → timeline-display-CbqpZrs6.js.map} +1 -1
- package/dist/shell-source-maps/assets/{trash-IV6Ox5bV.js.map → trash-C576xGNJ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{update-set-BTHuLrBr.js.map → update-set-OSkktpzc.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-calendar-move-CaU_5smA.js.map → use-calendar-move-DJbTVBiR.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-display-rows-C_H7lxLW.js.map → use-display-rows-xrXX3vo7.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-my-invitations-DSp8OwP9.js.map → use-my-invitations-BzmabmV5.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-paged-search-DOcO0Rbz.js.map → use-paged-search-1j6rT5dX.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-run-trace-BsH3vq5k.js.map → use-run-trace-DhxoDhjX.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-workflow-page-DDl2MUPY.js.map → use-workflow-page-Dof4TXvO.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-workflow-types-nJ6UhHeL.js.map → use-workflow-types-DlnnSIon.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-canvas-xG0FmrJj.js.map → workflow-canvas-04KWcras.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-field-fuI75chK.js.map → workflow-field-DnRl3Zn3.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-graph-editor-DCCcZ5AP.js.map → workflow-graph-editor-CW-k7iPq.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-run-field-BxIU66mn.js.map → workflow-run-field-Cb04vQvU.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-status-field-Bnk5IHI5.js.map → workflow-status-field-D4-yEdIA.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-workbench-7EvpXFq6.js.map → workflow-workbench-BBRBLI2p.js.map} +1 -1
- package/dist/status/messages.d.ts +2 -2
- package/dist/users/messages.d.ts +2 -2
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-status-field-Bnk5IHI5.js","names":["z.string","z.boolean","z.string","z.string","z.iso.date","z.string","z.enum","z.string","z.int","z.preprocess","z.json","z.email","z.union","z.string","z.int","text","z.string","z.iso.datetime","z.uuid","z.registry","text","listColumns","columns","_Fragment","useState","n","a","t","__toESM","require_react","require_jsx_runtime","useMembers","addressPlaceholders","viewOfList","membersTitle","datesErrors","formNamePattern","recordPageErrors","useOptionalAuth","useToast","displays","displayErrors","AppLink","filterErrors","badgeTones","StatusDot","isBadgeTone","useRecord","ref","can","navRecentErrors","builtInFieldTypes","Button","useClient","boardErrors","layoutItems","customComponent","createRefs","linkActionError","messages","formatDateTime","displayFields","hrefPlaceholders","useRefreshResource","usePermissions","orderByErrors","inputs","actionInputErrors","updateSetErrors","email","preprocess","uuid$1","registry","boolean$1","string","datetime","int","_enum","json$1","date$1","union","chartModel","useWorkflowView","workflowViewAddress","workflowsResource","digits","min","max","bigint","v","boolean","country","currency","date","shape","decimal","o","maxInteger","maxFraction","match","integer","fraction","enumeration","file","schema","withinJsonDepth","stack","value","current","depth","child","json","ctx","mailSender","relation","text$1","timestamp","uuid","promptFields","prompt","promptError","tokenPattern","tokenize","tokens","source","at","rest","skipped","whole","number","name","symbol","text","parseFormula","position","fail","token","what","peek","expect","args","list","sum","call","operand","inner","product","node","op","fieldRegistry","Field","def","meta","rules","minutes","names","error","expression","patch","constraint","RelationField","imageFormats","defaultMaxSize","units","parseSize","size","unit","typePattern","checkedAccept","types","lower","type","providerPattern","reservedProviders","checkedProvider","variantNamePattern","fits","checkedBound","label","checkedVariant","variant","checkedVariants","variants","FileField","provider","processors","field","options","baseMeta","make","extra","f","values","isMenuHref","href","navStartErrors","start","model","actionConditionError","named","builtInputs","option","built","errors","actions","formModel","input","fields","repeated","index","thanks","title","perMinute","isListColumn","columns","hexColor","currencyCode","FieldView","props","question","format","_","labels","entries","colors","wrong","color","widgets","refs","namedListParts","searchesOfErrors","typed","resource","role","searches","ViewBuilder","state","pick","rule","titles","subtitle","build","columns$1","shown","opens","related","column","stray","editable","sort","dir","search","filter","drag","where","entry","view","key","enabled","choices","to","controls","control","unseen","limit","titleBadge","unknownTitleField","titleFrom","missing","searchResult","display","unknown","flag","board","dates","clash","groupTitles","tabs","item","apart","tab","tabTitles","listOf","searchErrors","form","nav","tenantField","recentErrors","conversation","startErrors","opensUnknown","pageErrors","workflowStatuses","workflowStatusTones","resolvableStatuses","readsRuns","r","import_jsx_runtime","MemberName","id","ResolvedBy","auth","who","by","isStatus","toneOf","status","statusLabel","when","statusReason","record","shared","run","import_react","resolutionsResource","useResolve","client","refresh","toast","permitted","mayUpdate","busy","setBusy","workflow","StatusOf","stored","resolver","reason","StatusDisplay","StatusCell","workflowStatusField"],"sources":["../../../../schema/src/fields/bigint.ts","../../../../schema/src/fields/boolean.ts","../../../../schema/src/fields/country.ts","../../../../schema/src/fields/currency.ts","../../../../schema/src/fields/date.ts","../../../../schema/src/fields/decimal.ts","../../../../schema/src/fields/enum.ts","../../../../schema/src/fields/file.ts","../../../../schema/src/fields/integer.ts","../../../../schema/src/fields/json-depth.ts","../../../../schema/src/fields/json.ts","../../../../schema/src/fields/mail-sender.ts","../../../../schema/src/fields/relation.ts","../../../../schema/src/fields/text.ts","../../../../schema/src/fields/timestamp.ts","../../../../schema/src/fields/uuid.ts","../../../../schema/src/ai-prompt.ts","../../../../schema/src/computed/formula.ts","../../../../schema/src/field.ts","../../../../schema/src/relation-field.ts","../../../../schema/src/files/file-options.ts","../../../../schema/src/file-field.ts","../../../../schema/src/fields.ts","../../../../schema/src/menu-href.ts","../../../../schema/src/nav-start.ts","../../../../schema/src/view-actions.ts","../../../../schema/src/view-form.ts","../../../../schema/src/view-columns.ts","../../../../schema/src/view-field.ts","../../../../schema/src/view-widgets.ts","../../../../schema/src/view.ts","../../../../schema/src/workflows/workflow-status.ts","../../../src/app/field-types/workflow-status/messages.ts","../../../src/app/field-types/workflow-status/resolved-by.tsx","../../../src/app/field-types/workflow-status/status-reason.ts","../../../src/app/field-types/workflow-status/use-resolve.ts","../../../src/app/field-types/workflow-status/workflow-status-field.tsx"],"sourcesContent":["import { z } from 'zod'\n\nconst digits = /^-?\\d+$/\nconst min = -(2n ** 63n)\nconst max = 2n ** 63n - 1n\n\nexport const bigint = {\n type: 'bigint',\n constraints: [],\n build: () =>\n z.string().refine((v) => digits.test(v) && BigInt(v) >= min && BigInt(v) <= max, {\n message: 'Expected a 64-bit integer as a string',\n }),\n} as const\n","import { z } from 'zod'\n\nexport const boolean = { type: 'boolean', constraints: [], build: () => z.boolean() } as const\n","import { z } from 'zod'\n\nexport const country = {\n type: 'country',\n constraints: [],\n build: () => z.string().regex(/^[A-Z]{2}$/, 'Expected an ISO 3166-1 alpha-2 country code'),\n} as const\n","import { z } from 'zod'\n\nexport const currency = {\n type: 'currency',\n constraints: [],\n build: () => z.string().regex(/^[A-Z]{3}$/, 'Expected an ISO 4217 currency code'),\n} as const\n","import { z } from 'zod'\n\nexport const date = { type: 'date', constraints: [], build: () => z.iso.date() } as const\n","import { z } from 'zod'\n\nconst shape = /^-?(\\d*)(?:\\.(\\d+))?$/\n\nexport const decimal = {\n type: 'decimal',\n constraints: [],\n build: (o: { precision?: number; scale?: number }) => {\n if (o.precision === undefined || o.scale === undefined) {\n throw new Error('f.decimal requires precision and scale')\n }\n const maxInteger = o.precision - o.scale\n const maxFraction = o.scale\n return z.string().refine(\n (v) => {\n const match = shape.exec(v)\n if (!match) return false\n const integer = (match[1] ?? '').replace(/^0+/, '')\n const fraction = match[2] ?? ''\n if (!(match[1] || fraction)) return false\n return integer.length <= maxInteger && fraction.length <= maxFraction\n },\n { message: `Expected a decimal string with at most ${o.precision} digits, ${o.scale} after the point`, params: { precision: o.precision, scale: o.scale } },\n )\n },\n} as const\n","import { z } from 'zod'\n\nexport const enumeration = {\n type: 'enum',\n constraints: [],\n build: (o: { enumValues?: string[] }) => {\n if (!o.enumValues?.length) throw new Error('f.enum requires at least one value')\n return z.enum(o.enumValues)\n },\n} as const\n","import { z } from 'zod'\n\n/**\n * A file column holds `{provider}:{path}?name=…&size=…` as text, or an https URL with `.externalUrls()`; writes send a\n * ticket from `:upload` instead.\n */\nexport const file = { type: 'file', constraints: [], build: () => z.string().min(1).max(4096) } as const\n","import { z } from 'zod'\n\nexport const integer = {\n type: 'integer',\n constraints: ['min', 'max'],\n build: (o: { min?: number; max?: number }) => {\n let schema = z.int()\n if (o.min !== undefined) schema = schema.min(o.min)\n if (o.max !== undefined) schema = schema.max(o.max)\n return schema\n },\n} as const\n","/** How deeply a JSON field's value may nest: each array or object is one level. */\nexport const maxJsonDepth = 256\n\n/**\n * Whether `value` nests at most `max` levels, counting each array or object as one level (`[]` is 1, a scalar 0).\n * It walks with a stack of its own rather than recursing, so a value nested far deeper than the call stack allows is\n * refused rather than overflowing, and it stops at the first level past `max`, which also ends a cyclic value.\n */\nexport const withinJsonDepth = (value: unknown, max = maxJsonDepth) => {\n const stack: [unknown, number][] = [[value, 0]]\n while (stack.length > 0) {\n const [current, depth] = stack.pop()!\n if (typeof current !== 'object' || current === null) continue\n if (depth + 1 > max) return false\n for (const child of Object.values(current)) stack.push([child, depth + 1])\n }\n return true\n}\n","import { z } from 'zod'\nimport { maxJsonDepth, withinJsonDepth } from './json-depth'\n\n// The depth check runs first and a value it refuses stops the pipe, since z.json() walks a value recursively and\n// overflows the stack on one nested thousands of levels deep.\nexport const json = {\n type: 'json',\n constraints: [],\n build: () =>\n z.preprocess((value, ctx) => {\n if (!withinJsonDepth(value)) ctx.addIssue({ code: 'custom', message: `Nested deeper than ${maxJsonDepth} levels`, params: { max_depth: maxJsonDepth } })\n return value\n }, z.json()),\n} as const\n","import { z } from 'zod'\n\nexport const mailSender = {\n type: 'mail_sender',\n constraints: [],\n build: () => z.email('Expected a mail address').max(254),\n} as const\n","import { z } from 'zod'\n\nexport const relation = {\n type: 'relation',\n constraints: [],\n build: () => z.union([z.string(), z.int()]),\n} as const\n","import { z } from 'zod'\n\nexport const text = {\n type: 'text',\n constraints: ['min', 'max', 'regex'],\n build: (o: { min?: number; max?: number; regex?: { re: RegExp; message: string } }) => {\n let schema = z.string()\n if (o.min !== undefined) schema = schema.min(o.min)\n if (o.max !== undefined) schema = schema.max(o.max)\n if (o.regex) schema = schema.regex(o.regex.re, o.regex.message)\n return schema\n },\n} as const\n","import { z } from 'zod'\n\nexport const timestamp = {\n type: 'timestamp',\n constraints: [],\n build: () => z.iso.datetime({ offset: true }),\n} as const\n","import { z } from 'zod'\n\nexport const uuid = { type: 'uuid', constraints: [], build: () => z.uuid() } as const\n","import { fillText, hrefPlaceholders } from './address-template'\nimport { recordValueAt } from './template-path'\n\n/** The fields an AI prompt reads from the record, from its `{{field}}` placeholders. */\nexport const promptFields = (prompt: string) => hrefPlaceholders(prompt)\n\nconst asText = (value: unknown) => {\n if (value === null || value === undefined) return ''\n if (typeof value === 'string') return value\n if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') return String(value)\n return JSON.stringify(value)\n}\n\n/** `prompt` with every `{{field}}` replaced by the record's value as text; a missing value becomes empty, json as JSON. */\nexport const renderPrompt = (prompt: string, record: Record<string, unknown>) => fillText(prompt, (path) => asText(recordValueAt(record, path)))\n\n/** Why a prompt cannot be an AI field's or action's: it reads no field of the record. */\nexport const promptError = (prompt: string) => (promptFields(prompt).length === 0 ? 'its prompt must name at least one {{field}} of the record' : undefined)\n","/**\n * A formula as {@link parseFormula} reads it: numbers, the record's fields, `+ - * /`, a leading minus, parentheses,\n * `coalesce(a, b, ...)` and `round(x)` or `round(x, digits)`.\n */\nexport type FormulaNode =\n | { kind: 'number'; value: string }\n | { kind: 'field'; name: string }\n | { kind: 'negate'; operand: FormulaNode }\n | { kind: 'binary'; op: '+' | '-' | '*' | '/'; left: FormulaNode; right: FormulaNode }\n | { kind: 'coalesce'; args: FormulaNode[] }\n | { kind: 'round'; value: FormulaNode; digits?: number }\n\ntype Token = { kind: 'number' | 'name' | 'symbol'; text: string; at: number }\n\nconst tokenPattern = /\\s*(?:(\\d+(?:\\.\\d+)?)|([A-Za-z_][A-Za-z0-9_]*)|([-+*/(),]))/y\n\nconst tokenize = (source: string) => {\n const tokens: Token[] = []\n tokenPattern.lastIndex = 0\n while (tokenPattern.lastIndex < source.length) {\n const at = tokenPattern.lastIndex\n const match = tokenPattern.exec(source)\n if (!match) {\n const rest = source.slice(at)\n if (rest.trim() === '') break\n const skipped = rest.length - rest.trimStart().length\n throw new Error(`Formula \"${source}\": unexpected \"${rest[skipped]}\" at ${at + skipped + 1}`)\n }\n const [whole, number, name, symbol] = match\n const text = (number ?? name ?? symbol)!\n tokens.push({ kind: number !== undefined ? 'number' : name !== undefined ? 'name' : 'symbol', text, at: at + whole.length - text.length })\n }\n return tokens\n}\n\n/** Reads a formula, or throws naming what it cannot read. */\nexport const parseFormula = (source: string): FormulaNode => {\n const tokens = tokenize(source)\n let position = 0\n const fail = (what: string): never => {\n const token = tokens[position]\n throw new Error(`Formula \"${source}\": ${what}${token ? ` at ${token.at + 1}, found \"${token.text}\"` : ' at the end'}`)\n }\n const peek = (text: string) => tokens[position]?.kind === 'symbol' && tokens[position]!.text === text\n const expect = (text: string) => {\n if (!peek(text)) fail(`expected \"${text}\"`)\n position += 1\n }\n const args = () => {\n expect('(')\n const list = [sum()]\n while (peek(',')) {\n position += 1\n list.push(sum())\n }\n expect(')')\n return list\n }\n const call = (name: string): FormulaNode => {\n if (name === 'coalesce') {\n const list = args()\n if (list.length < 2) fail('coalesce() takes at least two values')\n return { kind: 'coalesce', args: list }\n }\n const list = args()\n const [value, digits] = list\n if (list.length > 2) fail('round() takes a value and at most a number of digits')\n if (digits === undefined) return { kind: 'round', value: value! }\n if (digits.kind !== 'number' || digits.value.includes('.')) fail(\"round()'s digits must be a whole number\")\n return { kind: 'round', value: value!, digits: Number((digits as { value: string }).value) }\n }\n const operand = (): FormulaNode => {\n const token = tokens[position]\n if (!token) return fail('expected a number, a field or \"(\"')\n if (token.kind === 'number') {\n position += 1\n return { kind: 'number', value: token.text }\n }\n if (token.kind === 'name') {\n position += 1\n if (!peek('(')) return { kind: 'field', name: token.text }\n if (token.text !== 'coalesce' && token.text !== 'round') {\n position -= 1\n return fail(`unknown function \"${token.text}\", only coalesce() and round()`)\n }\n return call(token.text)\n }\n if (token.text === '-') {\n position += 1\n return { kind: 'negate', operand: operand() }\n }\n if (token.text === '(') {\n position += 1\n const inner = sum()\n expect(')')\n return inner\n }\n return fail('expected a number, a field or \"(\"')\n }\n const product = (): FormulaNode => {\n let node = operand()\n while (peek('*') || peek('/')) {\n const op = tokens[position]!.text as '*' | '/'\n position += 1\n node = { kind: 'binary', op, left: node, right: operand() }\n }\n return node\n }\n const sum = (): FormulaNode => {\n let node = product()\n while (peek('+') || peek('-')) {\n const op = tokens[position]!.text as '+' | '-'\n position += 1\n node = { kind: 'binary', op, left: node, right: product() }\n }\n return node\n }\n const node = sum()\n if (position < tokens.length) fail('expected an operator')\n return node\n}\n\n/** The fields a formula reads, each once, in the order it names them. */\nexport const formulaFields = (node: FormulaNode): string[] => {\n const names = (part: FormulaNode): string[] => {\n if (part.kind === 'field') return [part.name]\n if (part.kind === 'number') return []\n if (part.kind === 'negate') return names(part.operand)\n if (part.kind === 'binary') return [...names(part.left), ...names(part.right)]\n if (part.kind === 'coalesce') return part.args.flatMap(names)\n return names(part.value)\n }\n return [...new Set(names(node))]\n}\n\n/** Whether a formula can be empty: when a field it needs is, unless `coalesce()` has a value that is not. */\nexport const formulaNullable = (node: FormulaNode, nullable: (field: string) => boolean): boolean => {\n if (node.kind === 'field') return nullable(node.name)\n if (node.kind === 'number') return false\n if (node.kind === 'negate') return formulaNullable(node.operand, nullable)\n if (node.kind === 'binary') return formulaNullable(node.left, nullable) || formulaNullable(node.right, nullable)\n if (node.kind === 'coalesce') return node.args.every((arg) => formulaNullable(arg, nullable))\n return formulaNullable(node.value, nullable)\n}\n","import { z } from 'zod'\nimport type { FieldAccess } from './access/types'\nimport { promptError } from './ai-prompt'\nimport type { FieldType } from './model'\nimport type { FileOptions } from './files/file-options'\nimport { parseFormula } from './computed/formula'\nimport type { Rollup } from './computed/rollup'\nimport type { Encrypted } from './encrypted-value'\nimport type { Lookup } from './lookup/lookup'\n\n/** A check on the value that only some field types take: `.min()`, `.max()` and `.regex()`. */\nexport type Constraint = 'min' | 'max' | 'regex'\n\n/** Everything a field's builder methods have set, from which the resource's {@link FieldModel} is built. */\nexport type FieldMeta = {\n /** The field's type. */\n type: FieldType\n /** The column, when it is not the snake_case of the field's name (`.column()`). */\n column?: string\n /** Whether the value may be `null` (`.optional()`). */\n nullable: boolean\n /** Whether the API never writes it (`.readOnly()`). */\n readOnly: boolean\n /** Whether filters may use it (`.filterable()`). */\n filterable: boolean\n /** Whether sorts may use it (`.sortable()`). */\n sortable: boolean\n /** Other names filters may use for it (`.alias()`). */\n aliases: string[]\n /** Whether `.default()` gave it a value. */\n hasDefault: boolean\n /** The value of `.default()`. */\n defaultValue?: unknown\n /** Whether the database supplies a value when none is given (`.dbDefault()`). */\n dbDefault?: boolean\n /** Its role rules (`.access()`). */\n access?: FieldAccess\n /** Whether it is hidden like a password (`.sensitive()`). */\n sensitive?: boolean\n /** Whether it is stored encrypted, and so sensitive too (`.encrypted()`). */\n encrypted?: boolean\n /** How recent a strong sign-in its reveal needs, and so sensitive too (`.strongSignIn()`). */\n strongSignIn?: {\n /** The most minutes since the sign-in, or its confirmation, proved a passkey or a second step. */\n minutes: number\n }\n /** An enum's values (`f.enum()`). */\n enumValues?: string[]\n /** A relation's resource and the columns that hold its key (`f.relation()`, `.columns()`). */\n relation?: {\n /** The resource it points at. */\n resource: string\n /** The columns holding the other record's key, in the order of that key; the field's own column when omitted. */\n columns?: string[]\n }\n /** A decimal's number of digits (`f.decimal()`). */\n precision?: number\n /** A decimal's number of digits after the point (`f.decimal()`). */\n scale?: number\n /** The least value, or for text the shortest length (`.min()`). */\n min?: number\n /** The greatest value, or for text the longest length (`.max()`). */\n max?: number\n /** A pattern the text must match (`.regex()`). */\n regex?: {\n /** The pattern. */\n re: RegExp\n /** The message of the issue a value that does not match gets. */\n message: string\n }\n /** A file field's settings (`f.file()`). */\n file?: FileOptions\n /** How a job fills it (`.ai()`). */\n ai?: {\n /** The prompt the job fills it from. */\n prompt: string\n }\n /** What the database keeps it from: the records of another resource (`.rollup()`). */\n rollup?: Rollup\n /** The expression the database computes it from, over the record's other fields (`.formula()`). */\n formula?: string\n /** The linked record's field it shows (`.lookup()`). */\n lookup?: Lookup\n}\n\n/** A field type: its name, the constraints it takes and how it builds the schema that checks a value. */\nexport type FieldTypeDef = {\n /** The field type it defines. */\n type: FieldType\n /** The constraints its fields may use; any other throws when the config loads. */\n constraints: readonly Constraint[]\n /** The Zod schema of a value, from the field's settings. */\n build: (meta: FieldMeta) => z.ZodType\n}\n\nexport const fieldRegistry = z.registry<FieldMeta>()\n\n/**\n * A field of a resource, holding values of type `V`, as `f` builds it. Every option returns a new field, so they chain\n * in any order. See [Field options](docs/website/src/content/docs/reference/data-config.mdx#field-options).\n */\nexport class Field<V> {\n /** The Zod schema a value is checked with on every create and update: the type's, nullable and defaulted as set. */\n readonly schema: z.ZodType<V>\n\n constructor(\n /** Its field type. */\n readonly def: FieldTypeDef,\n /** What its builder methods have set. */\n readonly meta: FieldMeta,\n ) {\n let schema = def.build(meta)\n if (meta.nullable) schema = schema.nullable()\n if (meta.hasDefault) schema = schema.default(meta.defaultValue as never)\n // Zod maps the meta type member by member, which a file field's processor functions do not survive\n this.schema = schema.register(fieldRegistry, meta as never) as z.ZodType<V>\n }\n\n /** The column, when it is not the snake_case of the field's name, such as `'EMP_NAME'`. */\n column(name: string) {\n return this.with({ column: name })\n }\n\n /** Never written through the API: ids, computed columns, audit timestamps. */\n readOnly() {\n return this.with({ readOnly: true })\n }\n\n /** The column is nullable: the value may be `null`. */\n optional() {\n return this.with({ nullable: true }) as unknown as Field<V | null>\n }\n\n /** The value a create uses when none is given; the admin's create form shows it. */\n default(value: V) {\n return this.with({ hasDefault: true, defaultValue: value })\n }\n\n /**\n * Role-based rules for reading and writing this column. They never see a record, so the set of\n * readable columns is fixed per request. A field without a rule follows its resource.\n */\n access(rules: FieldAccess) {\n return this.with({ access: { ...this.meta.access, ...rules } })\n }\n\n /**\n * Hidden like a password: never part of a list, record, search or write response. A caller who may read it fetches the\n * value of one record on its own (`POST /{{resource}}/{{key}}:reveal`), and every reveal is published as an audit event.\n */\n sensitive() {\n return this.with({ sensitive: true })\n }\n\n /**\n * Stored encrypted with the app's own key (`PROTOBASE_ENCRYPTION_KEY`): the database only ever holds ciphertext. It is\n * sensitive too, so only its reveal decrypts it, and record rules, validators and hooks get a set stored value as\n * {@link encrypted}, never the value. Only `f.text()` takes it. See\n * [Encrypted fields](docs/website/src/content/docs/reference/data-config.mdx#encrypted-fields).\n */\n encrypted() {\n if (this.meta.type !== 'text') throw new Error('.encrypted() takes only f.text() fields')\n return this.with({ encrypted: true, sensitive: true }) as unknown as Field<V | Encrypted>\n }\n\n /**\n * Revealing it needs a strong sign-in: one that proved a passkey or a second step, made or confirmed in the last\n * `minutes` (15 by default). Otherwise the reveal is refused with `403 strong-sign-in-required`, and the record page\n * asks the person to confirm it's them first. It is sensitive too. See\n * [Recent strong sign-in](docs/website/src/content/docs/reference/data-config.mdx#recent-strong-sign-in).\n */\n strongSignIn(o: { minutes?: number } = {}) {\n const minutes = o.minutes ?? 15\n if (!Number.isInteger(minutes) || minutes < 1) throw new Error('.strongSignIn(): minutes must be a whole number of at least 1')\n return this.with({ strongSignIn: { minutes }, sensitive: true })\n }\n\n /** The database supplies a value when none is given (identity, now(), ...). */\n dbDefault() {\n return this.with({ dbDefault: true })\n }\n\n /** Other names filters may use for the field. */\n alias(...names: string[]) {\n return this.with({ aliases: [...this.meta.aliases, ...names] })\n }\n\n /** The field may appear in `filter`, in filter widgets and in the filters of composed pages. Give it an index. */\n filterable() {\n return this.with({ filterable: true })\n }\n\n /** The field may appear in `order_by` and in sorts. */\n sortable() {\n return this.with({ sortable: true })\n }\n\n /** Text must match `re`; a value that does not gets an issue with `message`. Only `f.text()` takes it. */\n regex(re: RegExp, message: string) {\n return this.constrain('regex', { regex: { re, message } })\n }\n\n /** The least value of an integer, or the shortest length of a text. Only `f.integer()` and `f.text()` take it. */\n min(value: number) {\n return this.constrain('min', { min: value })\n }\n\n /** The greatest value of an integer, or the longest length of a text. Only `f.integer()` and `f.text()` take it. */\n max(value: number) {\n return this.constrain('max', { max: value })\n }\n\n /**\n * A job fills the field from `prompt`, `{{field}}` replaced by the record's values, after a create, and after an update\n * that changes a field the prompt names, as the user who wrote; see [AI fields and actions](docs/website/src/content/docs/reference/ai.mdx).\n */\n ai(o: { prompt: string }) {\n const error = promptError(o.prompt)\n if (error) throw new Error(`.ai(): ${error}`)\n return this.with({ ai: { prompt: o.prompt } })\n }\n\n /**\n * The database keeps the field: a column a trigger on `from`'s table sets to `fn` of the records whose `via` points at\n * this record, in the transaction that writes them. `count` and `sum` are 0 without records; `avg`, `min` and `max`\n * are empty, so their fields are `.optional()`. Empty values are left out, as in SQL. Read-only; `protobase migration`\n * writes the column and its trigger. See [Rollups and formulas](docs/website/src/content/docs/reference/data-config.mdx#rollups-and-formulas).\n *\n * @example\n * ```ts\n * total: f.decimal({ precision: 12, scale: 2 }).rollup({ from: 'order_lines', via: 'order_id', fn: 'sum', field: 'amount' }),\n * ```\n */\n rollup(o: Rollup) {\n return this.with({ rollup: { ...o }, readOnly: true })\n }\n\n /**\n * The database computes the field from the record's other number fields: a generated column. `expression` takes\n * numbers, fields, `+ - * /`, parentheses, `coalesce(a, b, ...)` and `round(x, digits)`, computed exactly as decimals and\n * stored as the field's type. Read-only; `protobase migration` writes the column. See\n * [Rollups and formulas](docs/website/src/content/docs/reference/data-config.mdx#rollups-and-formulas).\n *\n * @example\n * ```ts\n * amount: f.decimal({ precision: 12, scale: 2 }).formula('round(quantity * unit_price, 2)'),\n * ```\n */\n formula(expression: string) {\n parseFormula(expression)\n return this.with({ formula: expression, readOnly: true })\n }\n\n /**\n * Shows a field of the record this one is linked to, read with the record in the same query. Without `from` that\n * record is the one this record's relation `via` points at; with `from` it is the one record of `from` whose relation\n * `via` points at this record. The field's type is the linked field's. It is read-only and empty when there is no\n * linked record or the caller may not read it; a caller who may not read the linked field does not see it at all. See\n * [Lookups](docs/website/src/content/docs/reference/data-config.mdx#lookups).\n *\n * @example\n * ```ts\n * customer_name: f.text().lookup({ via: 'customer_id', field: 'name' }).filterable(),\n * release: f.text().lookup({ from: 'app_runtimes', via: 'app_id', field: 'release' }),\n * ```\n */\n lookup(o: Lookup) {\n return this.with({ lookup: { ...o }, readOnly: true, nullable: true }) as unknown as Field<V | null>\n }\n\n /** A copy of the field with `patch` applied, which every option returns. */\n protected with(patch: Partial<FieldMeta>): Field<V> {\n return new Field<V>(this.def, { ...this.meta, ...patch })\n }\n\n private constrain(constraint: Constraint, patch: Partial<FieldMeta>) {\n if (!this.def.constraints.includes(constraint)) {\n throw new Error(`f.${this.def.type} does not support .${constraint}()`)\n }\n return this.with(patch)\n }\n}\n\n/** A field of any value type. */\nexport type AnyField = Field<any>\n","import { Field } from './field'\n\n/** `f.relation(resource)`: a field holding the key of a record of another resource. */\nexport class RelationField<V> extends Field<V> {\n /**\n * The columns that hold the other record's key, in the order of that key, for a resource with a key of several\n * columns. See [Keys and relations](docs/website/src/content/docs/reference/data-config.mdx#keys-and-relations).\n */\n columns(columns: string[]) {\n return this.with({ relation: { resource: this.meta.relation!.resource, columns } })\n }\n}\n","/** What a processor gets: the stored upload's decided type, size and name, its first bytes, and the whole of it on demand. */\nexport type FileProcessorInput = {\n /** The file's name, its extension matched to the decided type. */\n name: string\n /** The type decided from the content, such as `image/jpeg`. */\n type: string\n /** The size in bytes. */\n size: number\n /** The first bytes of the content (up to 256 KB), enough for image headers. */\n head: Uint8Array\n /** The whole content, read from storage. */\n read(): Promise<ReadableStream<Uint8Array>>\n}\n\n/**\n * Computes a value for another column from an upload (`.derive()`). It runs once, on the upload route; a file whose type\n * is not in `accepts` leaves the column null.\n */\nexport type FileProcessor = {\n /** Exact types and `type/*` wildcards; every type when omitted. */\n accepts?: readonly string[]\n /** The value for the column, which must pass that field's schema. */\n run: (file: FileProcessorInput) => unknown\n}\n\n/** The formats an image variant is written in. */\nexport const imageFormats = ['webp', 'avif', 'jpeg', 'png'] as const\n\n/** A format an image variant is written in: `webp`, `avif`, `jpeg` or `png`. */\nexport type ImageFormat = (typeof imageFormats)[number]\n\n/**\n * A resized copy of an uploaded image: at most `width` by `height` pixels, never enlarged. `inside` (the default) keeps\n * the whole image within that box, `cover` fills the box and crops what is outside it. `quality` is 1 to 100, the\n * format's default when omitted.\n */\nexport type ImageVariant = {\n /** The largest width in pixels; any width when omitted. */\n width?: number\n /** The largest height in pixels; any height when omitted. */\n height?: number\n /** `inside` keeps the whole image within the box; `cover` fills the box and crops the rest, and needs both sides. */\n fit?: 'inside' | 'cover'\n /** The format it is written in. */\n format: ImageFormat\n /** 1 to 100; the format's default when omitted. */\n quality?: number\n}\n\n/** `.variants()`' second argument: `original` replaces the upload by that image, so the upload itself is not kept. */\nexport type ImageVariantOptions = {\n /** The image stored instead of the upload, such as `{ width: 2560, format: 'webp' }`. */\n original?: ImageVariant\n}\n\n/** A file field's settings, as the builder collects them. */\nexport type FileOptions = {\n /** The allowed types and `type/*` wildcards (`.accept()`); any type when empty. */\n accept: string[]\n /** The largest upload in bytes (`.maxSize()`). */\n maxSize: number\n /** The provider of `files.providers` the files are stored with (`.storage()`, `.public()`). */\n provider: string\n /** The processors computing other fields from each upload, by field name (`.derive()`). */\n derive?: Record<string, FileProcessor>\n /** The read-only text field each image's ThumbHash goes to (`.placeholder()`). */\n placeholder?: string\n /** The read-only text field each file's media type goes to (`.typeField()`). */\n typeField?: string\n /** The read-only integer field each file's size in bytes goes to (`.sizeField()`). */\n sizeField?: string\n /** The resized copies stored beside each image, by name (`.variants()`). */\n variants?: Record<string, ImageVariant>\n /** The image stored instead of the upload (`.variants()`' `original`). */\n original?: ImageVariant\n /** Whether a value may also be an https URL of a file elsewhere (`.externalUrls()`). */\n external?: true\n}\n\nexport const defaultMaxSize = 50_000_000\n\nconst units: Record<string, number> = { b: 1, kb: 1e3, mb: 1e6, gb: 1e9, kib: 1024, mib: 1024 ** 2, gib: 1024 ** 3 }\n\n/** Bytes from a number or text such as `10 MB` (decimal units) or `5 MiB` (binary units). */\nexport const parseSize = (size: number | string): number => {\n if (typeof size === 'number') {\n if (!Number.isSafeInteger(size) || size <= 0) throw new Error(`A file size must be a positive whole number of bytes, not ${size}`)\n return size\n }\n const match = /^\\s*(\\d+(?:\\.\\d+)?)\\s*([a-z]+)?\\s*$/i.exec(size)\n const unit = units[(match?.[2] ?? 'b').toLowerCase()]\n if (!match || !unit) throw new Error(`\"${size}\" is not a size; write it like \"10 MB\" or \"512 KiB\"`)\n return parseSize(Math.round(Number(match[1]) * unit))\n}\n\nconst typePattern = /^(?:\\*\\/\\*|[a-z0-9][a-z0-9!#$&^_.+-]*\\/(?:\\*|[a-z0-9][a-z0-9!#$&^_.+-]*))$/\n\n/** Allowed types, lowercased: exact types and `type/*` wildcards; `*` alone is refused so that every type is a choice. */\nexport const checkedAccept = (types: readonly string[]) =>\n types.map((type) => {\n const lower = type.trim().toLowerCase()\n if (!typePattern.test(lower)) throw new Error(`\"${type}\" is not a media type or a type/* wildcard`)\n return lower\n })\n\nconst providerPattern = /^[a-z][a-z0-9-]{0,31}$/\n// A stored value starting with one of these would read as a link or another standard URI.\nconst reservedProviders = new Set(['http', 'https', 'data', 'blob', 'file', 'javascript', 'mailto'])\n\n/** A provider name: lowercase, at most 32 characters, and not a scheme browsers already know. */\nexport const checkedProvider = (name: string) => {\n if (!providerPattern.test(name)) throw new Error(`\"${name}\" is not a file provider name: lowercase letters, digits and dashes, starting with a letter`)\n if (reservedProviders.has(name)) throw new Error(`\"${name}\" cannot name a file provider: stored values would read as ${name}: links`)\n return name\n}\n\nconst variantNamePattern = /^[a-z][a-z0-9_]{0,31}$/\nconst fits = ['inside', 'cover']\n\n// A pixel bound of a variant: a whole number from 1 to 16384, the largest side WebP can hold.\nconst checkedBound = (label: string, value: number | undefined) => {\n if (value !== undefined && (!Number.isSafeInteger(value) || value < 1 || value > 16_384)) throw new Error(`${label} must be a whole number of pixels from 1 to 16384, not ${value}`)\n}\n\n/** A variant as written, checked: a known format and fit, and bounds and a quality in range. */\nexport const checkedVariant = (label: string, variant: ImageVariant): ImageVariant => {\n if (!(imageFormats as readonly string[]).includes(variant.format)) throw new Error(`${label}: \"${variant.format}\" is not an image format; use ${imageFormats.join(', ')}`)\n if (variant.fit !== undefined && !fits.includes(variant.fit)) throw new Error(`${label}: fit is \"inside\" or \"cover\", not \"${variant.fit}\"`)\n if (variant.fit === 'cover' && (variant.width === undefined || variant.height === undefined)) throw new Error(`${label}: fit \"cover\" needs both a width and a height`)\n checkedBound(`${label}: width`, variant.width)\n checkedBound(`${label}: height`, variant.height)\n if (variant.quality !== undefined && (!Number.isSafeInteger(variant.quality) || variant.quality < 1 || variant.quality > 100)) {\n throw new Error(`${label}: quality must be a whole number from 1 to 100, not ${variant.quality}`)\n }\n return { ...variant }\n}\n\n/** Variants by name: snake_case names, since each one is part of its file's path. */\nexport const checkedVariants = (variants: Record<string, ImageVariant>) =>\n Object.fromEntries(\n Object.entries(variants).map(([name, variant]) => {\n if (!variantNamePattern.test(name)) throw new Error(`\"${name}\" cannot name an image variant: lowercase letters, digits and underscores, starting with a letter`)\n return [name, checkedVariant(`Image variant \"${name}\"`, variant)]\n }),\n )\n","import type { FieldAccess } from './access/types'\nimport { Field, type FieldMeta } from './field'\nimport { checkedAccept, checkedProvider, checkedVariant, checkedVariants, parseSize, type FileOptions, type FileProcessor, type ImageVariant, type ImageVariantOptions } from './files/file-options'\n\n/** `f.file()`: a text column holding a file's URI, uploaded through `:upload`. See [Files](docs/website/src/content/docs/reference/files.mdx). */\nexport class FileField<V> extends Field<V> {\n /** Allowed types, checked against the type detected from the content: `['image/*', 'application/pdf']`. */\n accept(types: readonly string[]) {\n return this.withFile({ accept: checkedAccept(types) })\n }\n\n /** The largest upload, as bytes or text such as `10 MB`; default 50 MB. */\n maxSize(size: number | string) {\n return this.withFile({ maxSize: parseSize(size) })\n }\n\n /** Stored with the `public` provider, at a permanent URL anyone with it may open. */\n public() {\n return this.storage('public')\n }\n\n /** Stored with this provider of `files.providers`; default `private`. */\n storage(provider: string) {\n return this.withFile({ provider: checkedProvider(provider) })\n }\n\n /**\n * Values computed from each upload, written to other fields of the resource (read-only ones) in the same write as the\n * file: `{ image_width: imageSize('width') }`. Clearing the file clears them.\n */\n derive(processors: Record<string, FileProcessor>) {\n return this.withFile({ derive: { ...this.meta.file!.derive, ...processors } })\n }\n\n /**\n * Computes a ThumbHash of each image into a read-only text field (`photo_placeholder`), which the admin app shows\n * while the image loads. Other files leave it null.\n */\n placeholder(field: string) {\n return this.withFile({ placeholder: field })\n }\n\n /**\n * Writes each file's media type into this read-only text field (`attachment_type`), so lists and aggregates can read\n * it, and serving and file viewers take the type from it. An external URL whose extension names no type leaves it null.\n */\n typeField(field: string) {\n return this.withFile({ typeField: field })\n }\n\n /**\n * Writes each file's size in bytes into this read-only integer or bigint field (`attachment_size`), so lists and\n * aggregates can read it. An external URL leaves it null, as its size is unknown.\n */\n sizeField(field: string) {\n return this.withFile({ sizeField: field })\n }\n\n /**\n * Resized copies of each image, stored beside it under these names: `{ card: { width: 640, height: 480, fit: 'cover',\n * format: 'webp' } }`. `{ original }` stores that image instead of the upload. Other files get none.\n */\n variants(variants: Record<string, ImageVariant>, options: ImageVariantOptions = {}) {\n return this.withFile({\n variants: { ...this.meta.file!.variants, ...checkedVariants(variants) },\n ...(options.original && { original: checkedVariant('The original', options.original) }),\n })\n }\n\n /**\n * Also takes an https URL of a file elsewhere, such as `https://images.example.com/photos/42.jpg`, stored as it is:\n * never uploaded, without variants, and drawn from that address. See\n * [External URLs](docs/website/src/content/docs/reference/files.mdx#external-urls).\n */\n externalUrls() {\n return this.withFile({ external: true })\n }\n\n /** The column is nullable: the field may hold no file. */\n override optional() {\n return this.with({ nullable: true }) as unknown as FileField<V | null>\n }\n\n /** Never written through the API. */\n override readOnly() {\n return this.with({ readOnly: true })\n }\n\n /** The column, when it is not the snake_case of the field's name. */\n override column(name: string) {\n return this.with({ column: name })\n }\n\n /** Role-based rules for reading and writing the file; uploading needs write access to the field. */\n override access(rules: FieldAccess) {\n return this.with({ access: { ...this.meta.access, ...rules } })\n }\n\n /** A copy of the field with `patch` applied, which every option returns. */\n protected override with(patch: Partial<FieldMeta>): FileField<V> {\n return new FileField<V>(this.def, { ...this.meta, ...patch })\n }\n\n private withFile(patch: Partial<FileOptions>) {\n return this.with({ file: { ...this.meta.file!, ...patch } })\n }\n}\n","import type { z } from 'zod'\nimport { bigint } from './fields/bigint'\nimport { boolean } from './fields/boolean'\nimport { country } from './fields/country'\nimport { currency } from './fields/currency'\nimport { date } from './fields/date'\nimport { decimal } from './fields/decimal'\nimport { enumeration } from './fields/enum'\nimport { file } from './fields/file'\nimport { integer } from './fields/integer'\nimport { json } from './fields/json'\nimport { mailSender } from './fields/mail-sender'\nimport { relation } from './fields/relation'\nimport { text } from './fields/text'\nimport { timestamp } from './fields/timestamp'\nimport { uuid } from './fields/uuid'\nimport { Field, type FieldMeta, type FieldTypeDef } from './field'\nimport { RelationField } from './relation-field'\nimport { FileField } from './file-field'\nimport { defaultMaxSize } from './files/file-options'\n\nconst baseMeta = (def: FieldTypeDef): FieldMeta => ({\n type: def.type,\n nullable: false,\n readOnly: false,\n filterable: false,\n sortable: false,\n aliases: [],\n hasDefault: false,\n})\n\nconst make = <V>(def: FieldTypeDef, extra: Partial<FieldMeta> = {}) =>\n new Field<V>(def, { ...baseMeta(def), ...extra })\n\n/**\n * The field builders of a resource's `.fields({ ... })`, one per field type. Each returns a {@link Field} whose options\n * chain in any order. See [Field types](docs/website/src/content/docs/reference/data-config.mdx#field-types).\n *\n * @example\n * ```ts\n * .fields({\n * id: f.integer().readOnly().filterable().sortable().dbDefault(),\n * status: f.enum(['booked', 'ready', 'collected']).default('booked').filterable(),\n * customer_id: f.relation('customers').filterable(),\n * estimate: f.decimal({ precision: 8, scale: 2 }),\n * notes: f.text().optional().column('internal_notes'),\n * })\n * ```\n */\nexport const f = {\n /** Text: a `text`, `varchar` or `bpchar` column. Takes `.min()`, `.max()` (length) and `.regex()`. */\n text: () => make<string>(text),\n /** A 32-bit or smaller integer: an `int2` or `int4` column. Takes `.min()` and `.max()`. */\n integer: () => make<number>(integer),\n /** A 64-bit integer: an `int8` column, a string in the API so that all 64 bits survive. */\n bigint: () => make<string>(bigint),\n /** An exact decimal of `precision` digits, `scale` of them after the point: a `numeric` column, a string in the API. */\n decimal: (o: { precision: number; scale: number }) => make<string>(decimal, o),\n /** A `bool` column. */\n boolean: () => make<boolean>(boolean),\n /** A `date` column, `2026-10-08` in the API. */\n date: () => make<string>(date),\n /** A `timestamp` or `timestamptz` column, ISO 8601 with an offset in the API. */\n timestamp: () => make<string>(timestamp),\n /** A `uuid` column. */\n uuid: () => make<string>(uuid),\n /** One of `values`: a Postgres enum, or text with a `CHECK (... IN ...)`. The record type is the union of the values. */\n enum: <const T extends readonly string[]>(values: T) =>\n make<T[number]>(enumeration, { enumValues: [...values] }),\n /** Any JSON: a `json` or `jsonb` column. */\n json: () => make<z.infer<ReturnType<typeof z.json>>>(json),\n /**\n * The key of a record of `resource`, in that resource's key column(s); the admin shows the other record's title and\n * links to it. A relation to a resource with a key of several columns names them with `.columns()`.\n */\n relation: (resource: string) =>\n new RelationField<string | number>(relation, { ...baseMeta(relation), relation: { resource } }),\n /** A file: its column holds `{provider}:{path}?name=…&size=…` as text, and responses carry `{ uri, name, type, size, url }`. */\n file: () => new FileField<string>(file, { ...baseMeta(file), file: { accept: [], maxSize: defaultMaxSize, provider: 'private' } }),\n /** An ISO 4217 currency code such as `EUR`, in a `text` column. */\n currency: () => make<string>(currency),\n /** An ISO 3166-1 alpha-2 country code such as `NL`, in a `text` column. */\n country: () => make<string>(country),\n /**\n * A From address the person saving may send mail from (`personalMail.senders()`), in a `text` column holding the\n * address, as `personalMail.send({ from })` takes it; empty sends from their default. The form offers their senders\n * as a dropdown, and an address in use cannot be deleted from the account page.\n */\n mailSender: () => make<string>(mailSender),\n}\n","/** Where a menu link may point: a web or mail address outside the admin, never `javascript:` or a path inside it. */\nexport const isMenuHref = (href: string) => /^(https?:\\/\\/|mailto:)/i.test(href)\n","import type { NavStartModel, ResourceModel } from './model'\nimport { filterErrors, orderByErrors } from './nav-recent'\n\n/** What is wrong with a sidebar entry's start record for this model; empty when the app can look it up. */\nexport const navStartErrors = (start: NavStartModel, model: ResourceModel): string[] => [\n ...(typeof start.filter === 'string' && start.filter.trim() !== '' ? filterErrors(model, start.filter).map((error) => `filter: ${error.message}`) : ['needs a filter that finds the record']),\n ...(start.orderBy === undefined ? [] : orderByErrors(model, start.orderBy).map((error) => `orderBy: ${error.message}`)),\n]\n","import { actionInputErrors, inputs } from './action-inputs'\nimport { linkActionError } from './address-template'\nimport { promptError } from './ai-prompt'\nimport { updateSetErrors } from './update-set'\nimport type { ActionInputModel, ActionModel, AppAddress } from './model'\n\n/**\n * A button's label, icon and question, and the records it applies to: `when`, an AIP-160 condition over the record's own\n * fields such as `status = 'running'`, leaves the button out on a record it does not hold for, or with\n * `otherwise: 'disable'` shows it disabled with `reason`. `variant: 'danger'` draws it in red.\n * @inline\n */\ntype ActionOptions = { label: string; icon?: string; confirm?: string; when?: string; otherwise?: 'hide' | 'disable'; reason?: string; variant?: 'danger' }\n\n/** What is wrong with an action's `when`, `otherwise` and `reason`: a fallback needs a condition, and a disabled button says why. */\nexport const actionConditionError = (o: Pick<ActionOptions, 'when' | 'otherwise' | 'reason'>) => {\n if (o.when === undefined) return o.otherwise !== undefined || o.reason !== undefined ? '\"otherwise\" and \"reason\" need a \"when\" condition' : undefined\n if (o.when.trim() === '') return '\"when\" is empty'\n if (o.otherwise === 'disable') return o.reason ? undefined : 'a button disabled by \"when\" needs a \"reason\"'\n return o.reason === undefined ? undefined : '\"reason\" shows only with otherwise: \\'disable\\''\n}\n\nconst named = (name: string, o: ActionOptions & { bulk?: boolean }): ActionModel => {\n const error = actionConditionError(o)\n if (error) throw new Error(`Action \"${name}\": ${error}`)\n return {\n name,\n label: o.label,\n bulk: o.bulk ?? false,\n ...(o.icon !== undefined && { icon: o.icon }),\n ...(o.confirm !== undefined && { confirm: o.confirm }),\n ...(o.when !== undefined && { when: o.when }),\n ...(o.otherwise === 'disable' && { otherwise: o.otherwise, reason: o.reason }),\n ...(o.variant !== undefined && { variant: o.variant }),\n }\n}\n\n/**\n * `mailbox: true` says the handler sends mail from the person's own mailbox, such as an invoice: its dialog offers to\n * connect one instead of running while none is linked.\n * @inline\n */\ntype MailboxOption = { mailbox?: boolean }\n\n/** @inline */\ntype InputsOption = { inputs?: (i: typeof inputs) => ActionInputModel[] }\n\n// The inputs an action asks for, built and checked once for every action that takes them.\nconst builtInputs = (name: string, option: InputsOption['inputs']) => {\n if (!option) return {}\n const built = option(inputs)\n const errors = actionInputErrors(built)\n if (errors.length > 0) throw new Error(`Action \"${name}\": ${errors.join('; ')}`)\n return { inputs: built }\n}\n\nexport const actions = {\n /**\n * An action the app implements: it runs the handler registered under `name`. With `inputs`, such as\n * `(i) => [i.text('reason', { label: 'Reason' })]`, the button first asks for them in a dialog, and the handler gets the\n * answers as `values`. With `bulk`, the list offers it for the selected rows too, asks its inputs once, and runs the handler on each it applies to.\n * With `mailbox: true`, it sends from the person's own mailbox, and its dialog offers to connect one while none is linked.\n */\n action: (name: string, o: ActionOptions & InputsOption & MailboxOption & { bulk?: boolean }): ActionModel => ({\n ...named(name, o),\n ...builtInputs(name, o.inputs),\n ...(o.mailbox && { mailbox: true }),\n }),\n /**\n * Sets fields of the record, as one update with its ETag, for example `{ status: 'paid' }`. It is not offered on a\n * record that holds these values already. With `inputs`, the button first asks for them in a dialog, and a `set` value\n * that is exactly `'{{name}}'` is written as that input's answer, with no handler code:\n * `a.update('answer', { label: 'Answer', inputs: (i) => [i.text('answer', { label: 'Answer', multiline: true })], set: { answer: '{{answer}}' } })`.\n * With `bulk`, the list offers it for the selected rows too, asks its inputs once, and updates each it applies to.\n */\n update: (name: string, o: ActionOptions & InputsOption & { set: Record<string, unknown>; bulk?: boolean }): ActionModel => {\n const built = builtInputs(name, o.inputs)\n const errors = updateSetErrors(o.set, built.inputs)\n if (errors.length > 0) throw new Error(`Action \"${name}\": ${errors.join('; ')}`)\n return { ...named(name, o), ...built, run: { kind: 'update', values: o.set } }\n },\n /** Deletes the record (soft delete when the resource has one). */\n remove: (name: string, o: ActionOptions): ActionModel => ({ ...named(name, o), run: { kind: 'delete' } }),\n /**\n * Goes `to` an address in the app, such as `{ kind: 'record', resource: 'orders', key: '{{order_id}}' }`, or opens an\n * `href` that leaves it (`https:`, `mailto:`); `{{field}}` is replaced by the record's value. An `https:` or `http:` link\n * opens in a new tab without the referrer. An href that is only `{{field}}`, such as `'{{website}}'`, opens the URL the\n * record holds, and the button shows only when it is an `https:` or `http:` URL; `{{host}}` in the label becomes its host,\n * as in `'View on {{host}}'`. A path in the app is refused as an `href`, so every address in the app is written one way.\n */\n link: (name: string, o: Omit<ActionOptions, 'confirm'> & ({ to: AppAddress } | { href: string })): ActionModel => {\n const error = linkActionError(o.label, o)\n if (error) throw new Error(`Action \"${name}\": ${error}`)\n if ('to' in o) return { ...named(name, o), run: { kind: 'link', to: structuredClone(o.to) } }\n return { ...named(name, o), run: { kind: 'link', href: o.href } }\n },\n /**\n * Has the model write the `writes` field of the record from `prompt`, `{{field}}` replaced by the record's values, as the\n * user who clicks; see [AI fields and actions](docs/website/src/content/docs/reference/ai.mdx). The prompt may name the\n * field it writes, to rewrite or translate it in place.\n */\n ai: (name: string, o: ActionOptions & { prompt: string; writes: string }): ActionModel => {\n const error = promptError(o.prompt) ?? (o.writes === '' ? 'it writes no field' : undefined)\n if (error) throw new Error(`Action \"${name}\": ${error}`)\n return { ...named(name, o), run: { kind: 'ai', prompt: o.prompt, writes: o.writes } }\n },\n}\n","import { formNamePattern } from './form-address'\nimport type { FormModel } from './model'\nimport type { Ref } from './refs'\n\n/** How many submissions one client may send a form per minute, unless the form says: as many as sign-in allows. */\nexport const defaultPerMinute = 5\n\n/** What `.form(...)` takes. */\nexport type FormInput = {\n /** Its address in the app, `/-/forms/<name>`: lowercase letters, digits, `-` and `_`, unique across the app. */\n name: string\n /** The page's heading; the view's singular name when omitted. */\n title?: string\n /** The fields a visitor fills in, in order: plain fields the `anonymous` role may create. */\n fields: Ref[]\n /** What the page shows once the record is created. */\n thanks: string\n /** How many submissions one client may send per minute; default 5. */\n perMinute?: number\n}\n\nexport const formModel = (input: FormInput): FormModel => {\n const { name, title, fields, thanks } = input\n if (!formNamePattern.test(name)) throw new Error(`A form's name goes in its address, so it takes lowercase letters, digits, - and _, not \"${name}\"`)\n if (fields.length === 0) throw new Error(`Form \"${name}\" has no fields`)\n const names = fields.map((field) => field.name)\n const repeated = names.find((field, index) => names.indexOf(field) !== index)\n if (repeated !== undefined) throw new Error(`Form \"${name}\" lists the field \"${repeated}\" twice`)\n if (thanks.trim() === '') throw new Error(`Form \"${name}\" needs a thanks text, shown once a visitor sends it`)\n if (title !== undefined && title.trim() === '') throw new Error(`Form \"${name}\" has an empty title; leave it out for the view's name`)\n const perMinute = input.perMinute ?? defaultPerMinute\n if (!Number.isInteger(perMinute) || perMinute < 1) throw new Error(`Form \"${name}\" takes perMinute as a positive whole number, not ${perMinute}`)\n return { name, ...(title !== undefined && { title }), fields: names, thanks, perMinute }\n}\n","import type { RelatedColumnModel } from './model'\n\n/** A column of a view's list that is no field of the resource, as `c` makes one. */\nexport type ListColumn = RelatedColumnModel & {\n /** Marks a related records column. */\n readonly kind: 'related'\n}\n\nexport const isListColumn = (value: unknown): value is ListColumn => typeof value === 'object' && value !== null && (value as { kind?: unknown }).kind === 'related'\n\nexport const columns = {\n /**\n * A column named `name` of the records of `resource` that point at each row, through its relation `field` or, with\n * `through`, through a join resource, as a related section's. Each record is a dot in the colour its `status` value\n * has in its view's `valueColors`, in `sort` order, and a link to the record, showing its card on hover or focus. The\n * name must not be a field of the resource. See\n * [Related records in a list](docs/website/src/content/docs/reference/ui-config.mdx#related-records-in-a-list).\n */\n related: (name: string, o: Omit<RelatedColumnModel, 'name'>): ListColumn => ({ kind: 'related', name, ...structuredClone(o) }),\n}\n","import { badgeTones, isBadgeTone, type BadgeTone } from './badge-tones'\nimport type { BadgeShape, FieldFormat, FieldViewModel, HelpWhen, JsonValue, ShowWhen } from './model'\n\nconst hexColor = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i\n\nconst currencyCode = /^[A-Z]{3}$/\n\n/** How a view shows one field, as `.fields((r) => ...)` hands it out: each hint returns a new field view. */\nexport class FieldView<N extends string = string, V = unknown> {\n /** @internal */\n constructor(\n /** The field's name. */\n readonly name: N,\n /** The hints given so far. */\n readonly props: FieldViewModel = {},\n ) {}\n\n /** What the field is called, instead of its name in words. */\n label(label: string) {\n return this.with({ label })\n }\n\n /**\n * A line under the field on the record page and in forms; `when: 'editing'` shows it only while the record is edited,\n * not on its read view (the view's `.helpWhen(...)` when omitted).\n */\n help(help: string, o: { when?: HelpWhen } = {}) {\n return this.with({ help, ...(o.when !== undefined && { helpWhen: o.when }) })\n }\n\n /**\n * When the field shows on the record page: `editing` only on its form and the create form, `reading` only on its read\n * view and locked form; `always` when omitted. Its lists, cards and filters show it either way.\n */\n when(when: ShowWhen) {\n return this.with({ when })\n }\n\n /**\n * Leaves the field off the create form, for one that makes sense only once the record exists, such as a choice among\n * records added after it; the create leaves it empty or to its default, and the record page shows it as usual. The\n * server stops at startup on a field a create needs: not optional and with no default.\n */\n notOnCreate() {\n return this.with({ notOnCreate: true })\n }\n\n /**\n * Asks `question` before a person changes the value in a form or a list cell, such as a flag that is easy to set by\n * mistake: once as the value first moves away from the saved one, not on every key. Cancelling keeps the value. See\n * [Confirming a change](docs/website/src/content/docs/reference/ui-config.mdx#confirming-a-change).\n */\n confirm(question: string) {\n if (question.trim() === '') throw new Error(`Field \"${this.name}\": .confirm() needs the question to ask`)\n return this.with({ confirm: question })\n }\n\n /**\n * How the value shows: `badge` for statuses, `code` in monospace, `percent` with a % sign, `signed` with its sign, green\n * above zero and red below; for a text field, `email`, `phone` and `url` as a mail, call or open link, edited with an\n * email, phone or address keyboard on a mobile screen. `text` gives a `url` link the text it shows instead of the\n * address, fixed or with `{{field}}` placeholders from the record: `.format('url', { text: '{{title}}' })`.\n */\n format(format: FieldFormat, o: { text?: string } = {}) {\n if (o.text === undefined && format === 'url') return this.with({ format })\n // Another format drops the link text an earlier format('url') gave, which only a url link shows\n if (o.text === undefined) {\n const { linkText: _, ...props } = this.props\n return new FieldView<N, V>(this.name, { ...props, format })\n }\n if (format !== 'url') throw new Error(`Field \"${this.name}\": only format('url') takes a link text`)\n if (o.text.trim() === '') throw new Error(`Field \"${this.name}\": format('url') needs a link text that is not empty`)\n return this.with({ format, linkText: o.text })\n }\n\n /**\n * A text of several lines, such as a description: forms edit it in a box that grows with the text, and the record\n * page and cards keep its line breaks. Only a text field takes it.\n */\n multiline() {\n return this.with({ multiline: true })\n }\n\n /**\n * Markdown, such as notes: forms edit its source with a Write and Preview switch, and the record page, a page's field\n * blocks and a card's subtitle show it rendered, raw HTML shown as text and links opening in a new tab; the list's\n * table shows its text on one line. Only a text field takes it.\n */\n markdown() {\n return this.with({ markdown: true })\n }\n\n /** Text before a number wherever it is shown, such as a currency sign: `.prefix('€')`. */\n prefix(prefix: string) {\n return this.with({ prefix })\n }\n\n /** The ISO 4217 code of the currency a decimal is an amount of, such as `.currency('EUR')`: lists show it as money in it. */\n currency(currency: string) {\n if (!currencyCode.test(currency)) throw new Error(`Field \"${this.name}\": currency \"${currency}\" is not an ISO 4217 code such as EUR`)\n return this.with({ currency })\n }\n\n /** Text after a number wherever it is shown, such as a unit: `.suffix(' m²')`. */\n suffix(suffix: string) {\n return this.with({ suffix })\n }\n\n /** How many decimals a number shows wherever it is shown. */\n decimals(decimals: number) {\n return this.with({ decimals })\n }\n\n /** Labels for an enum's values, such as `{ co_signer: 'Co-signer' }`; values left out read as themselves in words. */\n valueLabels(labels: { readonly [P in Extract<V, string>]?: string }) {\n return this.with({ valueLabels: { ...this.props.valueLabels, ...(labels as Record<string, string>) } })\n }\n\n /**\n * A badge tone (`neutral`, `blue`, `green`, `amber`, `red` or `violet`) or a hex colour that fills the badge, per enum\n * value, such as `{ paid: 'green', a: '#00a651' }`; values left out are `neutral`.\n */\n valueColors(colors: { readonly [P in Extract<V, string>]?: BadgeTone | (string & {}) }) {\n const entries = Object.entries(colors as Record<string, string>)\n const wrong = entries.find(([, color]) => !isBadgeTone(color) && !hexColor.test(color))\n if (wrong) throw new Error(`Field \"${this.name}\": value colour \"${wrong[1]}\" of \"${wrong[0]}\" is not a tone (${badgeTones.join(', ')}) or a hex colour such as #00a651`)\n return this.with({ valueColors: { ...this.props.valueColors, ...Object.fromEntries(entries) } })\n }\n\n /** Enum values that mark a wait rather than work, such as `.waitingValues(['queued', 'blocked'])`: a `Timeline` draws them striped. */\n waitingValues(values: readonly Extract<V, string>[]) {\n return this.with({ waitingValues: [...values] })\n }\n\n /** `arrow` draws the field's badges as arrows pointing right, as on a rating scale such as the EU energy label. */\n badgeShape(badgeShape: BadgeShape) {\n return this.with({ badgeShape })\n }\n\n /**\n * An icon before the value on a card's meta row and above it in a section of key facts, by the names actions take,\n * such as `ruler`.\n */\n icon(icon: string) {\n return this.with({ icon })\n }\n\n /**\n * Shows and edits the field with the field type a plugin registers under `name` (`definePlugin({ fields })`), given\n * `props`, such as `r.score.widget('rating', { max: 5 })`, or with the built-in `members`, which picks an\n * organization's members into a JSON array of user ids (see\n * [Members](docs/website/src/content/docs/reference/plugins.md#members)). Without that field type, or when it does not show\n * this field's storage type, the field shows as it would without it.\n */\n widget(name: string, props?: Record<string, JsonValue>) {\n return this.with({ widget: { name, ...(props && { props }) } })\n }\n\n private with(patch: FieldViewModel) {\n return new FieldView<N, V>(this.name, { ...this.props, ...patch })\n }\n}\n","import type { DatePreset, FilterWidgetModel } from './model'\nimport type { Ref } from './refs'\n\n/** Every widget also takes `secondary: true`, which puts it behind the bar's \"More filters\" menu until it is picked there or set. */\nexport const widgets = {\n /** A slider between the field's lowest and highest value; `histogram` draws the values' histogram behind it. */\n range: (ref: Ref, o: { histogram?: boolean; secondary?: boolean } = {}): FilterWidgetModel => ({\n kind: 'range',\n field: ref.name,\n histogram: o.histogram ?? false,\n ...(o.secondary && { secondary: true }),\n }),\n /**\n * A menu of the field's values with counts; `search` adds a search box for long lists. On a relation it searches the\n * referenced records as you type, on a number field it is a range slider.\n */\n facets: (ref: Ref, o: { search?: boolean; secondary?: boolean } = {}): FilterWidgetModel => ({\n kind: 'facets',\n field: ref.name,\n search: o.search ?? false,\n ...(o.secondary && { secondary: true }),\n }),\n /** A date range with buttons for the `presets`, such as `today` and `30d`. */\n dateRange: (ref: Ref, o: { presets?: DatePreset[]; secondary?: boolean } = {}): FilterWidgetModel => ({\n kind: 'dateRange',\n field: ref.name,\n presets: o.presets ?? [],\n ...(o.secondary && { secondary: true }),\n }),\n /** A switch for a boolean field. */\n toggle: (ref: Ref, o: { secondary?: boolean } = {}): FilterWidgetModel => ({ kind: 'toggle', field: ref.name, ...(o.secondary && { secondary: true }) }),\n /**\n * A menu of boolean fields under one `label`, such as \"for sale\" and \"for rent\": a record shows when any chosen field\n * is true, so one that is both shows under each.\n */\n flags: (refs: Ref<string, boolean | null>[], o: { label: string; secondary?: boolean }): FilterWidgetModel => ({\n kind: 'flags',\n fields: refs.map((ref) => ref.name),\n label: o.label,\n ...(o.secondary && { secondary: true }),\n }),\n}\n","import type {\n ActionModel,\n AppAddress,\n CreateModel,\n ExportModel,\n FilterWidgetModel,\n HelpWhen,\n LayoutItemModel,\n PageWidth,\n RecordMode,\n ConversationPageModel,\n SaveFeedback,\n SortSpec,\n NamedListModel,\n NavModel,\n NavRecentModel,\n ListDisplayModel,\n ListDragModel,\n ResourceModel,\n SaveSearchModel,\n SearchesOfModel,\n SignInPromptModel,\n ViewModel,\n} from './model'\nimport { addressPlaceholders } from './address-template'\nimport { formNamePattern } from './form-address'\nimport { layoutItems } from './layout-items'\nimport { isMenuHref } from './menu-href'\nimport { viewOfList } from './named-list'\nimport { navRecentErrors } from './nav-recent'\nimport { membersTitle, recordPageErrors } from './record-page'\nimport { navStartErrors } from './nav-start'\nimport { createRefs, ref, type FieldRefs, type Ref } from './refs'\nimport { actions } from './view-actions'\nimport { chartModel, type ChartInput } from './view-chart'\nimport { formModel, type FormInput } from './view-form'\nimport { columns as listColumns, isListColumn, type ListColumn } from './view-columns'\nimport { boardErrors, customComponent, datesErrors, displayErrors, displayFields, displays, type ComponentRef } from './view-displays'\nimport { FieldView } from './view-field'\nimport { widgets } from './view-widgets'\n\n// What a named list's builder may set; anything else would be silently ignored.\nconst namedListParts = new Set(['resource', 'names', 'nav', 'help', 'list', 'filters', 'chart'])\n\ntype FieldsOf<R extends { readonly $fields: unknown }> = R['$fields']\n\n// The saved search's own fields: text for the filter and name, a timestamp for when its results were last opened.\nconst searchesOfErrors = (searches: SearchesOfModel, resource: ResourceModel) => {\n const typed = (role: string, name: string | undefined, type: string) =>\n name === undefined || resource.fields[name]?.type === type ? [] : [`${role} \"${name}\" is not a ${type} field of the resource`]\n return [\n ...typed('filter', searches.filter, 'text'),\n ...typed('name', searches.name, 'text'),\n ...typed('unseen.seenAt', searches.unseen?.seenAt, 'timestamp'),\n ...(searches.controls ?? []).flatMap((name) => (['enum', 'boolean'].includes(resource.fields[name]?.type ?? '') ? [] : [`control \"${name}\" is not an enum or boolean field of the resource`])),\n ...(searches.limit === undefined || (Number.isInteger(searches.limit) && searches.limit > 0) ? [] : ['limit must be a positive whole number']),\n ]\n}\n\n/**\n * `nav(...)` with `recent.status` limited to the resource's fields, and `recent.pulse` only beside a status.\n *\n * @inline\n */\ntype NavInput<R extends { readonly $fields: unknown }> = Omit<NavModel, 'recent'> & {\n recent?: Omit<NavRecentModel, 'status' | 'pulse'> & ({ status: keyof FieldsOf<R> & string; pulse?: string[] } | { status?: never; pulse?: never })\n}\n\n/** The `r` of `.fields((r) => ...)`: a field view per field of the resource, to give hints such as `.label()`. */\nexport type FieldViews<R extends {\n /** The resource's fields, as `resource(...)` declares them. */\n readonly $fields: unknown\n}> = {\n readonly [K in keyof FieldRefs<FieldsOf<R>> & string]: FieldView<K, NonNullable<FieldRefs<FieldsOf<R>>[K]['$value']>>\n}\n\n/**\n * A view of a resource, as `view(...)` starts it: how the admin shows it. Each method returns a new view, so one view\n * can build on another. See [UI config](docs/website/src/content/docs/reference/ui-config.mdx).\n */\nexport class ViewBuilder<R extends {\n /** The resource's fields, as `resource(...)` declares them. */\n readonly $fields: unknown\n}> {\n /** @internal */\n constructor(\n /** @internal */\n readonly state: ViewModel,\n ) {}\n\n /** What a record and the records are called, such as \"New repair\" and \"Repairs\"; the resource name in words by default. */\n names(names: { singular: string; plural: string }) {\n return this.next({ names })\n }\n\n /** The resource's icon in the sidebar, bottom bar and user menu; a table without one. See [Sidebar icons](docs/website/src/content/docs/reference/sidebar.md#sidebar-icons). */\n icon(icon: string) {\n return this.next({ icon })\n }\n\n /** Shows this view only to users with one of these roles; a view without roles is the default. */\n forRoles(roles: string[]) {\n return this.next({ roles })\n }\n\n /** The field shown as this record's title. Throws when the field does not exist. */\n title(pick: (r: FieldRefs<FieldsOf<R>>) => Ref) {\n return this.next({ title: pick(this.refs()).name })\n }\n\n /**\n * A title derived per reader in the browser, in place of `title`: `rule` names a function of the project's UI\n * `titles`, which gets the record with the `fields` picked and the signed-in reader, such as the names of the members\n * other than the reader. The record's key shows while it returns nothing. Throws when a field does not exist.\n */\n titleFrom(rule: string, pick: (r: FieldRefs<FieldsOf<R>>) => Ref[]) {\n const fields = pick(this.refs()).map((ref) => ref.name)\n if (rule === '') throw new Error(`View \"${this.state.resource}\": titleFrom needs the name of a rule`)\n if (fields.length === 0) throw new Error(`View \"${this.state.resource}\": titleFrom \"${rule}\" reads no fields`)\n return this.next({ titleFrom: { rule, fields } })\n }\n\n /**\n * How a record shows in the global search: a bold `title` of one or more fields joined by spaces (default: `title`)\n * and a `subtitle` field under it, replaced by the search field the text matched when that is neither.\n */\n searchResult(pick: (r: FieldRefs<FieldsOf<R>>) => { title?: Ref | Ref[]; subtitle?: Ref }) {\n const { title, subtitle } = pick(this.refs())\n const titles = title === undefined ? [] : Array.isArray(title) ? title : [title]\n return this.next({ searchResult: { ...(titles.length > 0 && { title: titles.map((ref) => ref.name) }), ...(subtitle && { subtitle: subtitle.name }) } })\n }\n\n /**\n * Where the resource sits in the sidebar; `recent` lists a few of its records under the entry (see\n * [Sidebar](docs/website/src/content/docs/reference/sidebar.md#recent-records)), and `tenant: 'current'` opens it on the\n * caller's own tenant (see [The current organization](docs/website/src/content/docs/reference/sidebar.md#the-current-organization)),\n * `create` links to the create form under it (see [Create link](docs/website/src/content/docs/reference/sidebar.md#create-link)),\n * and `start` names the record the app opens at `/` (see [Start record](docs/website/src/content/docs/reference/sidebar.md#start-record)).\n */\n nav(nav: NavInput<R>) {\n return this.next({ nav })\n }\n\n /** A line under the list's title. */\n help(help: string) {\n return this.next({ help })\n }\n\n /** Hints per field, such as `{ total: r.total.prefix('€').decimals(2) }`; calls add up. */\n fields(build: (r: FieldViews<R>) => Record<string, FieldView>) {\n const built = build(createRefs((name) => new FieldView(name)))\n const fields = Object.fromEntries(Object.values(built).map((v) => [v.name, v.props]))\n return this.next({ fields: { ...this.state.fields, ...fields } })\n }\n\n /**\n * The list: its table's `columns`, fields or columns of related records (`c.related`), `sort`, `search` and a `filter` it opens with, the\n * columns that are `editable` in their cell, and other `displays` to switch to (`d.cards`, `d.map`, `d.board`, `d.calendar`, `d.timeline`, `d.custom`), one of which\n * may be the `default` the list opens in, and what `drag` lets a user change by dragging, nothing unless it says.\n * Throws when display or column names collide, `default` names none or an editable field is not among the columns. See\n * [Editing in the list](docs/website/src/content/docs/reference/ui-config.mdx#editing-in-the-list).\n */\n list(\n build: (\n r: FieldRefs<FieldsOf<R>>,\n d: typeof displays,\n c: typeof listColumns,\n ) => {\n columns: Array<Ref | ListColumn>\n sort?: Array<[Ref, 'asc' | 'desc']>\n search?: Ref[]\n filter?: string\n editable?: Ref[]\n displays?: ListDisplayModel[]\n default?: string\n drag?: ListDragModel\n },\n ) {\n const { columns, sort, search, filter, editable, displays: shown = [], default: opens, drag } = build(this.refs(), displays, listColumns)\n const related = columns.filter(isListColumn).map(({ kind: _, ...column }) => column)\n const names = columns.map((column) => column.name)\n const repeated = names.find((name, index) => names.indexOf(name) !== index)\n if (repeated !== undefined) throw new Error(`View \"${this.state.resource}\": the list has two columns named \"${repeated}\"`)\n const stray = editable?.find((ref) => !names.includes(ref.name))\n if (stray) throw new Error(`View \"${this.state.resource}\": editable field \"${stray.name}\" is not among the list's columns`)\n const list = {\n columns: names,\n ...(related.length > 0 && { relatedColumns: related }),\n ...(sort && { sort: sort.map(([ref, dir]) => [ref.name, dir]) as SortSpec }),\n ...(search && { search: search.map((ref) => ref.name) }),\n ...(filter !== undefined && filter !== '' && { filter }),\n ...(editable && editable.length > 0 && { editable: editable.map((ref) => ref.name) }),\n ...(shown.length > 0 && { displays: shown }),\n ...(opens !== undefined && { default: opens }),\n ...(drag && { drag: { ...drag } }),\n }\n const errors = displayErrors(list)\n if (errors.length > 0) throw new Error(`View \"${this.state.resource}\": ${errors.join('; ')}`)\n return this.next({ list })\n }\n\n /**\n * The filter widgets above the list, in order, each on a `.filterable()` field: `w.facets`, `w.dateRange`, `w.range`,\n * `w.toggle` and `w.flags`. Together they write the list's `?filter=`.\n */\n filters(build: (r: FieldRefs<FieldsOf<R>>, w: typeof widgets) => FilterWidgetModel[]) {\n return this.next({ filters: build(this.refs(), widgets) })\n }\n\n /**\n * Another list of this resource, with its own sidebar entry and address (`/<resource>?list=<name>`). `build` gets a\n * fresh view and sets its `names` (the sidebar entry, required), `nav`, `help`, `list`, `filters` and `chart`, none of\n * which come from the view's own list. Its records open at the resource's own address. Throws on a name that does not\n * fit an address or repeats, on anything else set, on `nav.recent`, and in `toModel` when the view has `listOf` or\n * `searchesOf`. See [More than one list](docs/website/src/content/docs/reference/ui-config.mdx#more-than-one-list).\n */\n namedList(name: string, build: (v: ViewBuilder<R>) => ViewBuilder<R>) {\n const where = `View \"${this.state.resource}\": named list \"${name}\"`\n if (!formNamePattern.test(name)) throw new Error(`${where}: its name goes in its address, so it takes lowercase letters, digits, - and _`)\n if (this.state.lists?.some((entry) => entry.name === name)) throw new Error(`${where} is declared twice`)\n const start = view<R>(this.state.resource)\n const { state } = build(start)\n const extra = Object.keys(state).filter((key) => !namedListParts.has(key) && state[key as keyof ViewModel] !== start.state[key as keyof ViewModel])\n if (extra.length > 0) throw new Error(`${where} sets ${extra.join(', ')}; a named list takes names, nav, help, list, filters and chart`)\n if (!state.names) throw new Error(`${where} needs .names(...), its sidebar entry`)\n if (state.nav?.recent) throw new Error(`${where}: recent records are the view's own, not a named list's`)\n const named: NamedListModel = {\n name,\n names: state.names,\n filters: state.filters,\n ...(state.nav && { nav: state.nav }),\n ...(state.help !== undefined && { help: state.help }),\n ...(state.list && { list: state.list }),\n ...(state.chart && { chart: state.chart }),\n }\n return this.next({ lists: [...(this.state.lists ?? []), named] })\n }\n\n /**\n * The record page, as items of `l` in order: sections, sidebar cards, related records, maps and custom components.\n * Without it the page shows one section with every field.\n */\n layout(build: (r: FieldRefs<FieldsOf<R>>) => LayoutItemModel[]) {\n return this.next({ layout: build(this.refs()) })\n }\n\n /**\n * A chart above the list, following its filters: records per `granularity` over a date or timestamp `field`, or\n * records per value of `groupBy`, such as a status or a relation, as bars or a donut of the `limit` largest (default\n * 10), counted or with `sum` or `average` that of a numeric field.\n */\n chart(build: (r: FieldRefs<FieldsOf<R>>) => ChartInput) {\n return this.next({ chart: chartModel(build(this.refs())) })\n }\n\n /**\n * A public form that creates a record of this resource for anyone, signed in or not, at `/-/forms/<name>`: the\n * `fields` a visitor fills in, the `thanks` shown once it is sent, a `title` (the view's singular name by default) and\n * how many submissions one client may send `perMinute` (default 5). The `anonymous` role must grant `create` of those\n * fields; the form is the only way it creates. Each call adds a form. Throws on a name that does not fit an address, no\n * or repeated fields, or an empty `thanks`. See [Public forms](docs/website/src/content/docs/reference/forms.mdx).\n */\n form(build: (r: FieldRefs<FieldsOf<R>>) => FormInput) {\n return this.next({ forms: [...(this.state.forms ?? []), formModel(build(this.refs()))] })\n }\n\n /**\n * How the record page opens to a user who may change the record: `edit`, the default, as its form; `read` as a read\n * view, its sections as tables of labels and values, with an Edit button to the form; `locked` as the form, locked\n * until Edit is pressed. A user who may not change it gets the read view in every mode. The form has its own address\n * (`edit: true`), so it opens in a new tab and Back leaves it. See [The record page](docs/website/src/content/docs/reference/ui-config.mdx#read-view-and-edit).\n */\n recordMode(recordMode: RecordMode) {\n return this.next({ recordMode })\n }\n\n /**\n * When the help lines of the view's fields and sections show: `always`, the default, or only while the record is\n * `editing`, on its form; a field's `.help(text, { when })` or a section's `helpWhen` says otherwise for its own.\n */\n helpWhen(helpWhen: HelpWhen) {\n return this.next({ helpWhen })\n }\n\n /** Where the record page shows that it saved: a toast (the default) or the Save button. */\n saveFeedback(saveFeedback: SaveFeedback) {\n return this.next({ saveFeedback })\n }\n\n /**\n * How wide the standard record page is: a centred `column`, the default, or the `full` width of the content pane, its\n * sidebar cards still beside the sections. See [The record page](docs/website/src/content/docs/reference/ui-config.mdx#page-width).\n */\n recordWidth(recordWidth: PageWidth) {\n return this.next({ recordWidth })\n }\n\n /**\n * The field the record page shows as a badge beside its title, in the field's `valueColors` and labels, such as a\n * verdict; without it an enum field named `status` shows there. Throws when the field does not exist, or is neither\n * an enum nor shown with `.format('badge')`. See\n * [The record page](docs/website/src/content/docs/reference/ui-config.mdx#read-only-values-and-a-title-badge).\n */\n titleBadge(pick: (r: FieldRefs<FieldsOf<R>>) => Ref) {\n return this.next({ titleBadge: pick(this.refs()).name })\n }\n\n /**\n * Whether the list page offers Import, which creates or updates records from an .xlsx, CSV or JSON file the user\n * picks (`true`, the default, to users who may create records); `.import(false)` turns it off. `.import('table')`\n * makes it a new table users add from the file instead, as the Tables list of user tables does. See\n * [Importing records](docs/website/src/content/docs/reference/ui-config.mdx#importing-records).\n */\n import(enabled: boolean | 'table') {\n return this.next({ import: enabled })\n }\n\n /**\n * The named actions of the record page's action rail, which composed pages can put on buttons too: `a.update`,\n * `a.remove` and `a.link` need no code, `a.action` runs a handler the app registers.\n */\n actions(build: (a: typeof actions) => ActionModel[]) {\n return this.next({ actions: build(actions) })\n }\n\n /**\n * The list page shows the records this relation field points at instead of this resource's rows, in their own view's\n * list with its displays, filters and search: the listings among a member's favorites, say. The record pages stay this\n * resource's. Throws in `toModel` when the field is not a relation.\n */\n listOf(pick: (r: FieldRefs<FieldsOf<R>>) => Ref) {\n return this.next({ listOf: pick(this.refs()).name })\n }\n\n /**\n * What a visitor who is not signed in is told about this resource, which they could use once signed in: on its list\n * page, in place of the list, and in the dialog of a card's favorite button or a list's \"Save search\" button that\n * saves here. The page offers \"Sign in\", and a way to make an account: the page `signUp` names, or the app's own sign-up\n * when the server has [open sign-up](docs/website/src/content/docs/reference/auth.md#open-sign-up). With it, the resource keeps its place in the bottom\n * bar and the sidebar of visitors. Throws when `signUp.href` is not `https:`, `http:` or `mailto:`. See\n * [Sign-in prompts](docs/website/src/content/docs/reference/ui-config.mdx#sign-in-prompts).\n */\n signIn(prompt: SignInPromptModel) {\n if (prompt.signUp && !isMenuHref(prompt.signUp.href)) throw new Error(`View \"${this.state.resource}\": signIn signUp.href must start with https://, http:// or mailto:`)\n return this.next({ signIn: structuredClone(prompt) })\n }\n\n /**\n * A \"Save search\" button on the list page while its filter narrows it: it saves the filter as a record of `resource`,\n * the signed-in user's own, whose view lists them with `.searchesOf(...)`, and takes it off again while pressed. A\n * visitor is told what signing in gives, when that view has `.signIn(...)`. See\n * [Saved searches](docs/website/src/content/docs/reference/ui-config.mdx#saved-searches).\n */\n saveSearch(search: SaveSearchModel) {\n return this.next({ saveSearch: { ...search } })\n }\n\n /**\n * Whether the list page offers Export, which saves its rows as an Excel or CSV file built in the browser: `false`\n * takes it away, `{ maxRows }` limits how many rows a file holds. A list offers it by default. It only shapes the\n * page: the rows and fields a file holds are those the list API gives the user. Throws when `maxRows` is not a\n * positive whole number. See [Exports](docs/website/src/content/docs/reference/ui-config.mdx#exports).\n */\n export(options: false | ExportModel) {\n if (options && options.maxRows !== undefined && !(Number.isInteger(options.maxRows) && options.maxRows > 0)) {\n throw new Error(`View \"${this.state.resource}\": export maxRows must be a positive whole number`)\n }\n return this.next({ export: options && { ...options } })\n }\n\n /**\n * Records are created on `page`, a composed page of the app's own, in place of the create form: `/<resource>/new`\n * shows it with the address's `values`, and the list's New button opens it for whoever may open the page, whatever the\n * resource's `create` access. So the resource's API can refuse creates (`create: never`) while the page creates\n * through an API function. The server refuses a page that does not exist when it starts. See\n * [Create pages](docs/website/src/content/docs/reference/ui-config.mdx#create-pages).\n */\n create(options: CreateModel) {\n return this.next({ create: { ...options } })\n }\n\n /**\n * The record page at `/<resource>/<key>` is `component`, a component of the app's own declared with `component(...)`\n * and exported from `protobase.ui.tsx`, filling the content area beside the sidebar and under the top bar, where the\n * page does not scroll. It reads the record with `useLayoutRecord()`. The standard record page stays at the record's\n * address with `standard: true`, which the component links to; it shows instead while the component is missing or\n * when it throws. Throws when `component` is a built-in block. See\n * [Full-area record pages](docs/website/src/content/docs/reference/ui-config.mdx#full-area-record-pages).\n *\n * `focus: true` draws it on a focus page, with the bar's state, Save, the record's actions and panels; the form\n * `(r) => ({ surface: r.body })` needs no component: the surface is one field, drawn by its field type. See\n * [Focus pages](docs/website/src/content/docs/reference/ui-config.mdx#focus-pages).\n *\n * `conversation` makes the page the record's conversation, filling the area with no component of the app's own: a\n * header, the messages that point at the record and a box that sends one. A conversation with `members` titles its\n * record after them for each reader, as `.titleFrom('members', ...)` does, unless the view sets its own. See\n * [Conversation pages](docs/website/src/content/docs/reference/ui-config.mdx#conversation-pages).\n */\n record(options: { component: ComponentRef<never>; focus?: boolean } | { conversation: ConversationPageModel } | ((r: FieldRefs<FieldsOf<R>>) => { surface: Ref })) {\n if (typeof options === 'function') return this.next({ record: { surface: options(this.refs()).surface.name } })\n if ('conversation' in options) return this.next({ record: { conversation: structuredClone(options.conversation) } })\n return this.next({ record: { component: customComponent(options.component, 'record component'), ...(options.focus && { focus: true }) } })\n }\n\n /**\n * A record's page opens `to` in its place, replacing the address in the history, `{{field}}` in its resource, key and\n * run replaced by the record's values: a workflow run's opens its workflow's page with the run on the graph. A list\n * of addresses opens the first whose `{{field}}`s all have a value in the record, as a row button's choices do: a\n * message opens in its channel, else in its direct message. Links that know the record's fields, such as the top bar's\n * search results, point at it too. A caller who cannot see where a choice leads skips it, and a record no choice fits\n * gets its own page. Throws on an empty list. See\n * [Open elsewhere](docs/website/src/content/docs/reference/ui-config.mdx#open-elsewhere).\n */\n recordOpens(to: AppAddress | readonly AppAddress[]) {\n const choices = Array.isArray(to) ? [...to] : [to as AppAddress]\n if (choices.length === 0) throw new Error(`View \"${this.state.resource}\": recordOpens needs at least one address`)\n return this.next({ recordOpens: structuredClone(choices) })\n }\n\n /**\n * The resource's create address opens `to` in place of the form, replacing the address in the history, `{{field}}`\n * filled from the address's values, for a record that is made where it is used: a workflow's test run opens in the\n * workflow's page. An address that does not give every such field shows the form.\n */\n createOpens(to: AppAddress) {\n return this.next({ createOpens: structuredClone(to) })\n }\n\n /**\n * This resource holds saved searches of `resource`, which a list page saves with `.saveSearch(...)`: its list page\n * shows each of the user's searches with its filters, its `controls` to change in place, the records it finds (with\n * `unseen`, newest first, those new since the user last opened its results marked) and a link to all of them. Throws in\n * `toModel` when `filter` or `name` is not a text field, `unseen.seenAt` not a timestamp or a control not an enum or\n * boolean field.\n * See [Saved searches](docs/website/src/content/docs/reference/ui-config.mdx#saved-searches).\n */\n searchesOf(\n pick: (r: FieldRefs<FieldsOf<R>>) => {\n resource: string\n filter: Ref\n name?: Ref\n controls?: Ref[]\n unseen?: { seenAt: Ref; field: string }\n limit?: number\n },\n ) {\n const { resource, filter, name, controls, unseen, limit } = pick(this.refs())\n const searches: SearchesOfModel = {\n resource,\n filter: filter.name,\n ...(name && { name: name.name }),\n ...(controls && { controls: controls.map((control) => control.name) }),\n ...(unseen && { unseen: { seenAt: unseen.seenAt.name, field: unseen.field } }),\n ...(limit !== undefined && { limit }),\n }\n return this.next({ searchesOf: searches })\n }\n\n /** With the resource's model, also verifies the title and `titleFrom`, search result and list display fields, related column names, a gallery's image, `listOf`, `searchesOf`, the sidebar's `recent` group and `tenant`, and the forms' fields. */\n toModel(resource?: ResourceModel): ViewModel {\n const { title, titleFrom, titleBadge, nav, searchResult, list, listOf } = this.state\n if (resource && title !== undefined && !Object.hasOwn(resource.fields, title)) {\n throw new Error(`View \"${this.state.resource}\": title field \"${title}\" does not exist on the resource`)\n }\n if (resource && titleBadge !== undefined && !Object.hasOwn(resource.fields, titleBadge)) {\n throw new Error(`View \"${this.state.resource}\": title badge field \"${titleBadge}\" does not exist on the resource`)\n }\n if (resource && titleBadge !== undefined && resource.fields[titleBadge]!.type !== 'enum' && this.state.fields[titleBadge]?.format !== 'badge') {\n throw new Error(`View \"${this.state.resource}\": title badge field \"${titleBadge}\" is no enum and has no .format('badge'), so it would not fit a badge`)\n }\n const unknownTitleField = resource ? titleFrom?.fields.find((name) => !Object.hasOwn(resource.fields, name)) : undefined\n if (unknownTitleField !== undefined) throw new Error(`View \"${this.state.resource}\": titleFrom field \"${unknownTitleField}\" does not exist on the resource`)\n const missing = resource ? [...(searchResult?.title ?? []), ...(searchResult?.subtitle ? [searchResult.subtitle] : [])].filter((name) => !Object.hasOwn(resource.fields, name)) : []\n if (missing.length > 0) throw new Error(`View \"${this.state.resource}\": search result field \"${missing[0]}\" does not exist on the resource`)\n for (const display of resource ? (list?.displays ?? []) : []) {\n const unknown = displayFields(display).find((name) => !Object.hasOwn(resource!.fields, name))\n if (unknown !== undefined) throw new Error(`View \"${this.state.resource}\": display \"${display.name}\" names field \"${unknown}\", which the resource does not have`)\n if (display.kind === 'cards' && display.image !== undefined && resource!.fields[display.image]!.type !== 'file') {\n throw new Error(`View \"${this.state.resource}\": display \"${display.name}\" shows \"${display.image}\" as its image, which is not a file field`)\n }\n const flag = display.kind === 'cards' ? display.flags?.find((name) => resource!.fields[name]!.type !== 'boolean') : undefined\n if (flag !== undefined) throw new Error(`View \"${this.state.resource}\": display \"${display.name}\" shows \"${flag}\" as a flag, which is not a boolean field`)\n const board = display.kind === 'board' ? boardErrors(display, resource!, list?.drag?.board) : []\n if (board.length > 0) throw new Error(`View \"${this.state.resource}\": display \"${display.name}\": ${board.join('; ')}`)\n const dates = display.kind === 'calendar' || display.kind === 'timeline' ? datesErrors(display, resource!) : []\n if (dates.length > 0) throw new Error(`View \"${this.state.resource}\": display \"${display.name}\": ${dates.join('; ')}`)\n }\n const clash = resource ? list?.relatedColumns?.find((column) => Object.hasOwn(resource.fields, column.name)) : undefined\n if (clash) throw new Error(`View \"${this.state.resource}\": related column \"${clash.name}\" has the name of a field of the resource`)\n const groupTitles = new Set<string>()\n const tabs = this.state.layout.flatMap((item, index) => (item.kind === 'tab' ? [{ item, index }] : []))\n const apart = tabs.find((tab, at) => at > 0 && tab.index !== tabs[at - 1]!.index + 1)\n if (apart) throw new Error(`View \"${this.state.resource}\": tabs stand together, and \"${apart.item.title}\" is apart from the others`)\n const tabTitles = new Set<string>()\n for (const { item } of tabs) {\n if (tabTitles.has(item.title)) throw new Error(`View \"${this.state.resource}\": two tabs are titled \"${item.title}\"`)\n tabTitles.add(item.title)\n }\n for (const item of this.state.layout.flatMap((item) => (item.kind === 'tab' ? item.items : [item]))) {\n if (item.kind !== 'group') continue\n if (groupTitles.has(item.title)) throw new Error(`View \"${this.state.resource}\": two groups are titled \"${item.title}\"`)\n groupTitles.add(item.title)\n }\n for (const item of resource ? layoutItems(this.state.layout) : []) {\n if (item.kind !== 'gallery' || item.image === undefined) continue\n if (!Object.hasOwn(resource!.fields, item.image)) throw new Error(`View \"${this.state.resource}\": gallery \"${item.title}\" names field \"${item.image}\", which the resource does not have`)\n if (resource!.fields[item.image]!.type !== 'file') throw new Error(`View \"${this.state.resource}\": gallery \"${item.title}\" shows \"${item.image}\" as its image, which is not a file field`)\n }\n if (resource && listOf !== undefined && (!Object.hasOwn(resource.fields, listOf) || resource.fields[listOf]!.type !== 'relation')) {\n throw new Error(`View \"${this.state.resource}\": listOf names \"${listOf}\", which is not a relation field of the resource`)\n }\n const searchErrors = resource && this.state.searchesOf ? searchesOfErrors(this.state.searchesOf, resource) : []\n if (searchErrors.length > 0) throw new Error(`View \"${this.state.resource}\": searchesOf ${searchErrors.join('; ')}`)\n for (const form of resource ? (this.state.forms ?? []) : []) {\n const unknown = form.fields.find((name) => !Object.hasOwn(resource!.fields, name))\n if (unknown !== undefined) throw new Error(`View \"${this.state.resource}\": form \"${form.name}\" names field \"${unknown}\", which the resource does not have`)\n }\n if (nav?.tenant === 'current' && !list) throw new Error(`View \"${this.state.resource}\": nav.tenant narrows the opening filter of the list, so the view needs .list(...)`)\n const tenantField = resource?.tenant === undefined ? undefined : resource.fields[resource.tenant]\n if (resource && nav?.tenant === 'current' && !tenantField?.filterable) {\n throw new Error(`View \"${this.state.resource}\": nav.tenant opens the list on the current tenant, so the resource needs .tenant() on a .filterable() field`)\n }\n if (typeof nav?.create === 'object' && nav.create.label.trim() === '') throw new Error(`View \"${this.state.resource}\": nav.create needs a label, or true for \"New <singular>\"`)\n const recentErrors = resource && nav?.recent ? navRecentErrors(nav.recent, resource) : []\n if (recentErrors.length > 0) throw new Error(`View \"${this.state.resource}\": nav.recent ${recentErrors.join('; ')}`)\n const conversation = this.state.record && 'conversation' in this.state.record ? this.state.record.conversation : undefined\n if (nav?.recent?.unread && !conversation?.readPosition) throw new Error(`View \"${this.state.resource}\": nav.recent.unread counts from the conversation's read positions, so the view needs .record({ conversation }) with readPosition`)\n if (nav?.recent?.typing && !conversation?.typing) throw new Error(`View \"${this.state.resource}\": nav.recent.typing shows the typing of the record's conversation, so the view needs .record({ conversation }) with typing`)\n const startErrors = resource && nav?.start ? navStartErrors(nav.start, resource) : []\n if (startErrors.length > 0) throw new Error(`View \"${this.state.resource}\": nav.start ${startErrors.join('; ')}`)\n const opensUnknown = resource ? (this.state.recordOpens ?? []).flatMap(addressPlaceholders).find((name) => !Object.hasOwn(resource.fields, name)) : undefined\n if (opensUnknown !== undefined) throw new Error(`View \"${this.state.resource}\": recordOpens names field \"${opensUnknown}\", which the resource does not have`)\n if (this.state.lists?.length && (listOf !== undefined || this.state.searchesOf)) {\n throw new Error(`View \"${this.state.resource}\": named lists cannot go with listOf or searchesOf, which replace the list page`)\n }\n const pageErrors = resource ? recordPageErrors(this.state.record, resource) : []\n if (pageErrors.length > 0) throw new Error(`View \"${this.state.resource}\": record ${pageErrors.join('; ')}`)\n for (const named of this.state.lists ?? []) new ViewBuilder<R>(viewOfList(this.state, named.name)!).toModel(resource)\n return structuredClone({ ...this.state, ...(!titleFrom && membersTitle(this.state.record)) })\n }\n\n private refs() {\n return createRefs<FieldRefs<FieldsOf<R>>>(ref)\n }\n\n private next(patch: Partial<ViewModel>) {\n return new ViewBuilder<R>({ ...this.state, ...patch })\n }\n}\n\n/**\n * Starts the view of a resource: how the admin shows it. Pass the resource's type, so every field reference (`r.status`)\n * is checked against it. See [UI config](docs/website/src/content/docs/reference/ui-config.mdx).\n *\n * @example\n * ```ts\n * import { view } from '@protobase/schema'\n * import type { repairs } from './data'\n *\n * export const repairsView = view<typeof repairs>('repairs')\n * .names({ singular: 'Repair', plural: 'Repairs' })\n * .list((r) => ({ columns: [r.number, r.status, r.booked_on], sort: [[r.booked_on, 'desc']] }))\n * ```\n */\nexport const view = <R extends {\n /** The resource's fields, as `resource(...)` declares them. */\n readonly $fields: unknown\n}>(resource: string) =>\n new ViewBuilder<R>({ resource, fields: {}, filters: [], layout: [], actions: [] })\n","import type { FieldAccess } from '../access/types'\nimport { f } from '../fields'\nimport type { StatusTone } from '../model'\nimport { resource } from '../resource'\nimport { view } from '../view'\n\n/** How many of a workflow's latest ended runs its status reads. */\nexport const statusRuns = 10\n\n/**\n * A workflow's status from its last {@link statusRuns} ended runs, as its database triggers keep it: `failing` when the\n * latest failed and still counts, `unresolved` when it succeeded and an earlier one failed and still counts, `healthy`\n * when none counts; `no_runs`, `resolved` and `new_version` when there is no ended run, or the latest is a failure that\n * stopped counting as someone marked the workflow resolved or saved a new version.\n */\nexport const workflowStatuses = ['failing', 'unresolved', 'healthy', 'no_runs', 'resolved', 'new_version'] as const\n\nexport type WorkflowStatus = (typeof workflowStatuses)[number]\n\n/** What each status is called, in the sidebar's names for screen readers and on the workflow's page. */\nexport const workflowStatusLabels = {\n failing: 'Last run failed',\n unresolved: 'Earlier failure unresolved',\n healthy: 'No unresolved failures',\n no_runs: 'No runs yet',\n resolved: 'No runs since resolved',\n new_version: 'No runs since this version',\n} as const satisfies Record<WorkflowStatus, string>\n\n/** The sidebar's tone for each status; the gray ones are `neutral`. */\nexport const workflowStatusTones = { failing: 'danger', unresolved: 'warning', healthy: 'success' } as const satisfies Partial<Record<WorkflowStatus, StatusTone>>\n\n/** The statuses \"Mark as resolved\" clears. */\nexport const resolvableStatuses: readonly WorkflowStatus[] = ['failing', 'unresolved']\n\n// The status tells how runs went, so only a caller who reads every run of the workflow sees it.\nconst readsRuns: FieldAccess = { read: (ctx) => ctx.holds?.('workflow_runs.read') ?? false }\n\n/**\n * The status fields of a workflow, all written by the database: the status, the run its reason links to and when it\n * ended, how many failures among the last runs still count, and who last marked it resolved and when.\n */\nexport const workflowStatusFields = {\n run_status: f.enum(workflowStatuses).readOnly().dbDefault().access(readsRuns),\n status_run_id: f.relation('workflow_runs').optional().readOnly().access(readsRuns),\n status_run_at: f.timestamp().optional().readOnly().access(readsRuns),\n unresolved_failures: f.integer().readOnly().dbDefault().access(readsRuns),\n resolved_at: f.timestamp().optional().readOnly(),\n resolved_by: f.text().optional().readOnly(),\n}\n\n/**\n * Each time someone marked a workflow resolved: kept, never changed, and copied onto the workflow. Whoever may change\n * the workflow may mark it, naming the workflow without reading these records, which take `workflow_resolutions.read`.\n */\nexport const resolutionsResource = (schema: string) =>\n resource('workflow_resolutions')\n .table(`${schema}.resolutions`)\n .fields({\n id: f.uuid().readOnly().dbDefault(),\n workflow_id: f.relation('workflows').filterable().access({ create: () => true }),\n resolved_by: f.text().optional().readOnly(),\n tenant_id: f.text().optional().readOnly(),\n resolved_at: f.timestamp().readOnly().dbDefault().sortable(),\n })\n .primaryKey((r) => r.id)\n .tenant((r) => r.tenant_id)\n .author((r) => r.resolved_by)\n .parent((r) => r.workflow_id, 'update')\n .explicitGrants()\n .access({ create: () => true, update: () => false, delete: () => false })\n\nexport const resolutionsView = view<ReturnType<typeof resolutionsResource>>('workflow_resolutions')\n .names({ singular: 'Workflow resolution', plural: 'Workflow resolutions' })\n .icon('check')\n .nav({ hidden: true })\n .title((r) => r.resolved_at)\n .fields((r) => ({ workflow_id: r.workflow_id.label('Workflow'), resolved_by: r.resolved_by.label('Resolved by'), resolved_at: r.resolved_at.label('Resolved') }))\n .list((r) => ({ columns: [r.workflow_id, r.resolved_by, r.resolved_at], sort: [[r.resolved_at, 'desc']] }))\n","import { messages } from '../../../locale/messages'\n\nexport const text = messages('app/field-types/workflow-status')\n","import { useOptionalAuth } from '../../../auth/auth-provider'\nimport { formatDateTime } from '../../../format/date'\nimport { useMembers } from '../../../people/use-members'\nimport { text } from './messages'\n\n// An organization's member by name, read with the members list.\nconst MemberName = ({ id }: { id: string }) => <>{useMembers().member(id)?.name ?? id}</>\n\n/** Who last marked the workflow resolved and when: you, a member of the organization by name, or else their user id. */\nexport const ResolvedBy = ({ by, at }: { by: string | null; at: string }) => {\n const auth = useOptionalAuth()\n const self = auth?.state.kind === 'signed-in' && by !== null && String(auth.state.user.id) === by\n const who = self ? text('you') : by === null ? '?' : auth?.organizations ? <MemberName id={by} /> : by\n return <p className=\"text-body text-muted-foreground\">{text.rich('resolvedBy', { who, when: formatDateTime(Date.parse(at)) })}</p>\n}\n","import type { StatusTone } from '@protobase/schema'\nimport { resolvableStatuses, statusRuns, workflowStatuses, workflowStatusTones, type WorkflowStatus } from '@protobase/schema/internal'\nimport { formatDateTime } from '../../../format/date'\nimport { text } from './messages'\n\n/** What a workflow's page says of its status: its tone, the words, the run they name when they name one, and whether it can be marked resolved. */\nexport type StatusReason = { status: WorkflowStatus; tone: StatusTone; words: string; run?: string; resolvable: boolean }\n\nconst isStatus = (value: unknown): value is WorkflowStatus => (workflowStatuses as readonly unknown[]).includes(value)\n\nconst toneOf = (status: WorkflowStatus): StatusTone => (workflowStatusTones as Partial<Record<WorkflowStatus, StatusTone>>)[status] ?? 'neutral'\n\n/** A status as a list's cell shows it: its tone and its name; none for a value that is no status. */\nexport const statusLabel = (value: unknown): { tone: StatusTone; words: string } | undefined => {\n if (!isStatus(value)) return\n return { tone: toneOf(value), words: text('label', { status: value }) }\n}\n\nconst when = (value: unknown) => formatDateTime(Date.parse(String(value)))\n\n/** The reason of a workflow's status, from its record's status fields; none for a record without a status, as for a caller who cannot read its runs. */\nexport const statusReason = (record: Record<string, unknown>): StatusReason | undefined => {\n const status = record.run_status\n if (!isStatus(status)) return\n const shared = { status, tone: toneOf(status), resolvable: resolvableStatuses.includes(status) }\n const run = record.status_run_id == null ? undefined : String(record.status_run_id)\n if (status === 'failing' || status === 'healthy') return { ...shared, words: text(status, { when: when(record.status_run_at), runs: statusRuns }), ...(run && { run }) }\n if (status === 'unresolved') return { ...shared, words: text(status, { count: Number(record.unresolved_failures), runs: statusRuns, when: when(record.status_run_at) }), ...(run && { run }) }\n return { ...shared, words: text(status) }\n}\n","import { useState } from 'react'\nimport { useClient } from '../../../data/api-provider'\nimport { useToast } from '../../../toasts'\nimport { usePermissions } from '../../meta-gate'\nimport { useRefreshResource } from '../../pages/use-layout-data'\nimport { can } from '../../permissions'\nimport { text } from './messages'\n\n/** The resource whose records mark a workflow resolved: one per mark, copied onto the workflow by the database. */\nexport const resolutionsResource = 'workflow_resolutions'\n\n/**\n * Marks the workflow resolved, clearing every failure so far, for a caller who may change it (`mayUpdate`, the record's\n * own permission) and so mark it; then reads the workflow again, which the sidebar follows.\n */\nexport const useResolve = (workflow: string, mayUpdate: boolean) => {\n const client = useClient()\n const refresh = useRefreshResource()\n const toast = useToast()\n const permitted = can(usePermissions(resolutionsResource), 'create') && mayUpdate\n const [busy, setBusy] = useState(false)\n const resolve = async () => {\n setBusy(true)\n await client.create(resolutionsResource, { workflow_id: workflow }).then(\n async () => {\n await Promise.all([refresh('workflows'), refresh(resolutionsResource)])\n toast.show({ state: 'success', title: text('resolveDone') })\n },\n () => toast.show({ state: 'error', title: text('resolveFailed') }),\n )\n setBusy(false)\n }\n return { permitted, busy, resolve }\n}\n","import { builtInFieldTypes } from '@protobase/schema/internal'\nimport { StatusDot } from '../../../app-shell/status-dot'\nimport { useRecord } from '../../../data/use-record'\nimport { Button } from '../../../primitives/button'\nimport { AppLink } from '../../use-app-address'\nimport type { FieldWidget, FieldWidgetProps } from '../field-widget'\nimport { useWorkflowView } from '../workflow-page/use-workflow-page'\nimport { workflowsResource, workflowViewAddress } from '../workflow-page/workflow-view'\nimport { ResolvedBy } from './resolved-by'\nimport { statusLabel, statusReason } from './status-reason'\nimport { useResolve } from './use-resolve'\nimport { text } from './messages'\n\n// The status of the workflow the page shows, said in words that link to the run they name, with Mark as resolved while\n// failures count and who last marked it.\nconst StatusOf = ({ workflow, value }: { workflow: string; value: string }) => {\n const stored = useRecord(workflowsResource, workflow).data\n const record = stored?.record\n const resolver = useResolve(workflow, stored?.permissions?.update !== false)\n const reason = record && statusReason({ ...record, run_status: value })\n if (!record || !reason) return null\n return (\n <div className=\"grid gap-2\">\n <div className=\"flex flex-wrap items-center gap-x-3 gap-y-2\">\n <span className=\"inline-flex min-w-0 items-center gap-2 text-body\" data-status={reason.status}>\n <StatusDot tone={reason.tone} />\n {reason.run ? (\n <AppLink to={workflowViewAddress({ workflow, run: reason.run })} className=\"font-medium text-primary-text hover:underline\">\n {reason.words}\n </AppLink>\n ) : (\n <span>{reason.words}</span>\n )}\n </span>\n {reason.resolvable && resolver.permitted && (\n <Button size=\"sm\" loading={resolver.busy} onClick={() => void resolver.resolve()}>\n {text('resolve')}\n </Button>\n )}\n </div>\n {record.resolved_at != null && <ResolvedBy by={record.resolved_by == null ? null : String(record.resolved_by)} at={String(record.resolved_at)} />}\n </div>\n )\n}\n\nconst StatusDisplay = ({ value }: FieldWidgetProps<string>) => {\n const view = useWorkflowView()\n return value === null || !view ? null : <StatusOf workflow={view.workflow} value={value} />\n}\n\n// The workflows list shows each status by its mark and name.\nconst StatusCell = ({ value }: FieldWidgetProps<string>) => {\n const label = statusLabel(value)\n if (!label) return null\n return (\n <span className=\"inline-flex items-center gap-2\">\n <StatusDot tone={label.tone} />\n {label.words}\n </span>\n )\n}\n\n/**\n * The built-in `workflow_status` field type, for a workflow's status from its last runs, as the `workflows` resource\n * shows its own: `r.run_status.widget('workflow_status')`. A workflow's page says the reason in words, linking to the\n * run it names, with Mark as resolved while a failure counts for whoever may change the workflow, and who last marked\n * it and when; a list shows the status by its mark and name. See the workflows reference.\n */\nexport const workflowStatusField: FieldWidget = { of: [...builtInFieldTypes.workflow_status], display: StatusDisplay, cell: StatusCell }\n"],"mappings":"2qCAEA,IAAMqF,GAAS,UACTC,GAAM,EAAE,IAAM,KACdC,GAAM,IAAM,IAAM,GAEXC,GAAS,CACpB,KAAM,SACN,YAAa,CAAC,EACd,UACExF,EAAS,CAAC,CAAC,OAAQ,GAAMqF,GAAO,KAAKI,CAAC,GAAK,OAAOA,CAAC,GAAKH,IAAO,OAAOG,CAAC,GAAKF,GAAK,CAC/E,QAAS,uCACX,CAAC,CACL,ECXaG,GAAU,CAAE,KAAM,UAAW,YAAa,CAAC,EAAG,UAAazF,GAAU,CAAE,ECAvE0F,GAAU,CACrB,KAAM,UACN,YAAa,CAAC,EACd,UAAazF,EAAS,CAAC,CAAC,MAAM,aAAc,6CAA6C,CAC3F,ECJa0F,GAAW,CACtB,KAAM,WACN,YAAa,CAAC,EACd,UAAazF,EAAS,CAAC,CAAC,MAAM,aAAc,oCAAoC,CAClF,ECJa0F,GAAO,CAAE,KAAM,OAAQ,YAAa,CAAC,EAAG,UAAazF,GAAW,CAAE,ECAzE0F,GAAQ,wBAEDC,GAAU,CACrB,KAAM,UACN,YAAa,CAAC,EACd,MAAQ,GAA8C,CACpD,GAAIC,EAAE,YAAc,IAAA,IAAaA,EAAE,QAAU,IAAA,GAC3C,MAAU,MAAM,wCAAwC,EAE1D,IAAMC,EAAaD,EAAE,UAAYA,EAAE,MAC7BE,EAAcF,EAAE,MACtB,OAAO3F,EAAS,CAAC,CAAC,OACf,GAAM,CACL,IAAM8F,EAAQL,GAAM,KAAKL,CAAC,EAC1B,GAAI,CAACU,EAAO,MAAO,GACnB,IAAMC,GAAWD,EAAM,IAAM,GAAA,CAAI,QAAQ,MAAO,EAAE,EAC5CE,EAAWF,EAAM,IAAM,GAE7B,OADMA,EAAM,IAAME,EACXD,EAAQ,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CAAC,EAAG,UAAU,gDACxE,SAAAA,EAAO,KACD,CAAA,GAET,EAAA9B,EAAA,IAAA,CAAC,OAAD,CAAA,SAAO8B,EAAO,KAAY,CAAA,CAExB,CACL,CAAA,EAAAA,EAAO,YAAcD,EAAS,YAC7B,EAAA7B,EAAA,IAAA,CAACrP,EAAD,CAAQ,KAAK,KAAK,QAASkR,EAAS,KAAM,YAAe,KAAKA,EAAS,QAAQ,EAC5E,SAAAlM,EAAK,SAAS,CACT,CAAA,CAEP,CACJ,CAAA,EAAAkL,EAAO,aAAe,OAAQ,EAAAb,EAAA,IAAA,CAACG,GAAD,CAAY,GAAIU,EAAO,aAAe,KAAO,KAAO,OAAOA,EAAO,WAAW,EAAG,GAAI,OAAOA,EAAO,WAAW,CAAI,CAAA,CAC7I,GAET,EAEMkB,IAAiB,CAAE,WAAsC,CAC7D,IAAMxE,EAAO9K,GAAgB,EAC7B,OAAOyB,IAAU,MAAQ,CAACqJ,EAAO,MAAO,EAAAyC,EAAA,IAAA,CAAC2B,GAAD,CAAU,SAAUpE,EAAK,SAAiB,OAAQ,CAAA,CAC5F,EAGMyE,IAAc,CAAE,WAAsC,CAC1D,IAAMvJ,EAAQiI,GAAYxM,CAAK,EAE/B,OADKuE,GAEH,EAAAuH,EAAA,KAAA,CAAC,OAAD,CAAM,UAAU,iCAAhB,SAAA,EACE,EAAAA,EAAA,IAAA,CAAC5P,EAAD,CAAW,KAAMqI,EAAM,IAAO,CAAA,EAC7BA,EAAM,KACH,IALW,IAOrB,EAQawJ,GAAmC,CAAE,GAAI,CAAC,GAAGvR,EAAkB,eAAe,EAAG,QAASqR,GAAe,KAAMC,EAAW","debugId":"67939207-239b-4f74-87c9-5d6c7c95a6f5"}
|
|
1
|
+
{"version":3,"file":"workflow-status-field-D4-yEdIA.js","names":["z.string","z.boolean","z.string","z.string","z.iso.date","z.string","z.enum","z.string","z.int","z.preprocess","z.json","z.email","z.union","z.string","z.int","text","z.string","z.iso.datetime","z.uuid","z.registry","text","listColumns","columns","_Fragment","useState","n","a","t","__toESM","require_react","require_jsx_runtime","useMembers","addressPlaceholders","viewOfList","membersTitle","datesErrors","formNamePattern","recordPageErrors","useOptionalAuth","useToast","displays","displayErrors","AppLink","filterErrors","badgeTones","StatusDot","isBadgeTone","useRecord","ref","can","navRecentErrors","builtInFieldTypes","Button","useClient","boardErrors","layoutItems","customComponent","createRefs","linkActionError","messages","formatDateTime","displayFields","hrefPlaceholders","useRefreshResource","usePermissions","orderByErrors","inputs","actionInputErrors","updateSetErrors","email","preprocess","uuid$1","registry","boolean$1","string","datetime","int","_enum","json$1","date$1","union","chartModel","useWorkflowView","workflowViewAddress","workflowsResource","digits","min","max","bigint","v","boolean","country","currency","date","shape","decimal","o","maxInteger","maxFraction","match","integer","fraction","enumeration","file","schema","withinJsonDepth","stack","value","current","depth","child","json","ctx","mailSender","relation","text$1","timestamp","uuid","promptFields","prompt","promptError","tokenPattern","tokenize","tokens","source","at","rest","skipped","whole","number","name","symbol","text","parseFormula","position","fail","token","what","peek","expect","args","list","sum","call","operand","inner","product","node","op","fieldRegistry","Field","def","meta","rules","minutes","names","error","expression","patch","constraint","RelationField","imageFormats","defaultMaxSize","units","parseSize","size","unit","typePattern","checkedAccept","types","lower","type","providerPattern","reservedProviders","checkedProvider","variantNamePattern","fits","checkedBound","label","checkedVariant","variant","checkedVariants","variants","FileField","provider","processors","field","options","baseMeta","make","extra","f","values","isMenuHref","href","navStartErrors","start","model","actionConditionError","named","builtInputs","option","built","errors","actions","formModel","input","fields","repeated","index","thanks","title","perMinute","isListColumn","columns","hexColor","currencyCode","FieldView","props","question","format","_","labels","entries","colors","wrong","color","widgets","refs","namedListParts","searchesOfErrors","typed","resource","role","searches","ViewBuilder","state","pick","rule","titles","subtitle","build","columns$1","shown","opens","related","column","stray","editable","sort","dir","search","filter","drag","where","entry","view","key","enabled","choices","to","controls","control","unseen","limit","titleBadge","unknownTitleField","titleFrom","missing","searchResult","display","unknown","flag","board","dates","clash","groupTitles","tabs","item","apart","tab","tabTitles","listOf","searchErrors","form","nav","tenantField","recentErrors","conversation","startErrors","opensUnknown","pageErrors","workflowStatuses","workflowStatusTones","resolvableStatuses","readsRuns","r","import_jsx_runtime","MemberName","id","ResolvedBy","auth","who","by","isStatus","toneOf","status","statusLabel","when","statusReason","record","shared","run","import_react","resolutionsResource","useResolve","client","refresh","toast","permitted","mayUpdate","busy","setBusy","workflow","StatusOf","stored","resolver","reason","StatusDisplay","StatusCell","workflowStatusField"],"sources":["../../../../schema/src/fields/bigint.ts","../../../../schema/src/fields/boolean.ts","../../../../schema/src/fields/country.ts","../../../../schema/src/fields/currency.ts","../../../../schema/src/fields/date.ts","../../../../schema/src/fields/decimal.ts","../../../../schema/src/fields/enum.ts","../../../../schema/src/fields/file.ts","../../../../schema/src/fields/integer.ts","../../../../schema/src/fields/json-depth.ts","../../../../schema/src/fields/json.ts","../../../../schema/src/fields/mail-sender.ts","../../../../schema/src/fields/relation.ts","../../../../schema/src/fields/text.ts","../../../../schema/src/fields/timestamp.ts","../../../../schema/src/fields/uuid.ts","../../../../schema/src/ai-prompt.ts","../../../../schema/src/computed/formula.ts","../../../../schema/src/field.ts","../../../../schema/src/relation-field.ts","../../../../schema/src/files/file-options.ts","../../../../schema/src/file-field.ts","../../../../schema/src/fields.ts","../../../../schema/src/menu-href.ts","../../../../schema/src/nav-start.ts","../../../../schema/src/view-actions.ts","../../../../schema/src/view-form.ts","../../../../schema/src/view-columns.ts","../../../../schema/src/view-field.ts","../../../../schema/src/view-widgets.ts","../../../../schema/src/view.ts","../../../../schema/src/workflows/workflow-status.ts","../../../src/app/field-types/workflow-status/messages.ts","../../../src/app/field-types/workflow-status/resolved-by.tsx","../../../src/app/field-types/workflow-status/status-reason.ts","../../../src/app/field-types/workflow-status/use-resolve.ts","../../../src/app/field-types/workflow-status/workflow-status-field.tsx"],"sourcesContent":["import { z } from 'zod'\n\nconst digits = /^-?\\d+$/\nconst min = -(2n ** 63n)\nconst max = 2n ** 63n - 1n\n\nexport const bigint = {\n type: 'bigint',\n constraints: [],\n build: () =>\n z.string().refine((v) => digits.test(v) && BigInt(v) >= min && BigInt(v) <= max, {\n message: 'Expected a 64-bit integer as a string',\n }),\n} as const\n","import { z } from 'zod'\n\nexport const boolean = { type: 'boolean', constraints: [], build: () => z.boolean() } as const\n","import { z } from 'zod'\n\nexport const country = {\n type: 'country',\n constraints: [],\n build: () => z.string().regex(/^[A-Z]{2}$/, 'Expected an ISO 3166-1 alpha-2 country code'),\n} as const\n","import { z } from 'zod'\n\nexport const currency = {\n type: 'currency',\n constraints: [],\n build: () => z.string().regex(/^[A-Z]{3}$/, 'Expected an ISO 4217 currency code'),\n} as const\n","import { z } from 'zod'\n\nexport const date = { type: 'date', constraints: [], build: () => z.iso.date() } as const\n","import { z } from 'zod'\n\nconst shape = /^-?(\\d*)(?:\\.(\\d+))?$/\n\nexport const decimal = {\n type: 'decimal',\n constraints: [],\n build: (o: { precision?: number; scale?: number }) => {\n if (o.precision === undefined || o.scale === undefined) {\n throw new Error('f.decimal requires precision and scale')\n }\n const maxInteger = o.precision - o.scale\n const maxFraction = o.scale\n return z.string().refine(\n (v) => {\n const match = shape.exec(v)\n if (!match) return false\n const integer = (match[1] ?? '').replace(/^0+/, '')\n const fraction = match[2] ?? ''\n if (!(match[1] || fraction)) return false\n return integer.length <= maxInteger && fraction.length <= maxFraction\n },\n { message: `Expected a decimal string with at most ${o.precision} digits, ${o.scale} after the point`, params: { precision: o.precision, scale: o.scale } },\n )\n },\n} as const\n","import { z } from 'zod'\n\nexport const enumeration = {\n type: 'enum',\n constraints: [],\n build: (o: { enumValues?: string[] }) => {\n if (!o.enumValues?.length) throw new Error('f.enum requires at least one value')\n return z.enum(o.enumValues)\n },\n} as const\n","import { z } from 'zod'\n\n/**\n * A file column holds `{provider}:{path}?name=…&size=…` as text, or an https URL with `.externalUrls()`; writes send a\n * ticket from `:upload` instead.\n */\nexport const file = { type: 'file', constraints: [], build: () => z.string().min(1).max(4096) } as const\n","import { z } from 'zod'\n\nexport const integer = {\n type: 'integer',\n constraints: ['min', 'max'],\n build: (o: { min?: number; max?: number }) => {\n let schema = z.int()\n if (o.min !== undefined) schema = schema.min(o.min)\n if (o.max !== undefined) schema = schema.max(o.max)\n return schema\n },\n} as const\n","/** How deeply a JSON field's value may nest: each array or object is one level. */\nexport const maxJsonDepth = 256\n\n/**\n * Whether `value` nests at most `max` levels, counting each array or object as one level (`[]` is 1, a scalar 0).\n * It walks with a stack of its own rather than recursing, so a value nested far deeper than the call stack allows is\n * refused rather than overflowing, and it stops at the first level past `max`, which also ends a cyclic value.\n */\nexport const withinJsonDepth = (value: unknown, max = maxJsonDepth) => {\n const stack: [unknown, number][] = [[value, 0]]\n while (stack.length > 0) {\n const [current, depth] = stack.pop()!\n if (typeof current !== 'object' || current === null) continue\n if (depth + 1 > max) return false\n for (const child of Object.values(current)) stack.push([child, depth + 1])\n }\n return true\n}\n","import { z } from 'zod'\nimport { maxJsonDepth, withinJsonDepth } from './json-depth'\n\n// The depth check runs first and a value it refuses stops the pipe, since z.json() walks a value recursively and\n// overflows the stack on one nested thousands of levels deep.\nexport const json = {\n type: 'json',\n constraints: [],\n build: () =>\n z.preprocess((value, ctx) => {\n if (!withinJsonDepth(value)) ctx.addIssue({ code: 'custom', message: `Nested deeper than ${maxJsonDepth} levels`, params: { max_depth: maxJsonDepth } })\n return value\n }, z.json()),\n} as const\n","import { z } from 'zod'\n\nexport const mailSender = {\n type: 'mail_sender',\n constraints: [],\n build: () => z.email('Expected a mail address').max(254),\n} as const\n","import { z } from 'zod'\n\nexport const relation = {\n type: 'relation',\n constraints: [],\n build: () => z.union([z.string(), z.int()]),\n} as const\n","import { z } from 'zod'\n\nexport const text = {\n type: 'text',\n constraints: ['min', 'max', 'regex'],\n build: (o: { min?: number; max?: number; regex?: { re: RegExp; message: string } }) => {\n let schema = z.string()\n if (o.min !== undefined) schema = schema.min(o.min)\n if (o.max !== undefined) schema = schema.max(o.max)\n if (o.regex) schema = schema.regex(o.regex.re, o.regex.message)\n return schema\n },\n} as const\n","import { z } from 'zod'\n\nexport const timestamp = {\n type: 'timestamp',\n constraints: [],\n build: () => z.iso.datetime({ offset: true }),\n} as const\n","import { z } from 'zod'\n\nexport const uuid = { type: 'uuid', constraints: [], build: () => z.uuid() } as const\n","import { fillText, hrefPlaceholders } from './address-template'\nimport { recordValueAt } from './template-path'\n\n/** The fields an AI prompt reads from the record, from its `{{field}}` placeholders. */\nexport const promptFields = (prompt: string) => hrefPlaceholders(prompt)\n\nconst asText = (value: unknown) => {\n if (value === null || value === undefined) return ''\n if (typeof value === 'string') return value\n if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') return String(value)\n return JSON.stringify(value)\n}\n\n/** `prompt` with every `{{field}}` replaced by the record's value as text; a missing value becomes empty, json as JSON. */\nexport const renderPrompt = (prompt: string, record: Record<string, unknown>) => fillText(prompt, (path) => asText(recordValueAt(record, path)))\n\n/** Why a prompt cannot be an AI field's or action's: it reads no field of the record. */\nexport const promptError = (prompt: string) => (promptFields(prompt).length === 0 ? 'its prompt must name at least one {{field}} of the record' : undefined)\n","/**\n * A formula as {@link parseFormula} reads it: numbers, the record's fields, `+ - * /`, a leading minus, parentheses,\n * `coalesce(a, b, ...)` and `round(x)` or `round(x, digits)`.\n */\nexport type FormulaNode =\n | { kind: 'number'; value: string }\n | { kind: 'field'; name: string }\n | { kind: 'negate'; operand: FormulaNode }\n | { kind: 'binary'; op: '+' | '-' | '*' | '/'; left: FormulaNode; right: FormulaNode }\n | { kind: 'coalesce'; args: FormulaNode[] }\n | { kind: 'round'; value: FormulaNode; digits?: number }\n\ntype Token = { kind: 'number' | 'name' | 'symbol'; text: string; at: number }\n\nconst tokenPattern = /\\s*(?:(\\d+(?:\\.\\d+)?)|([A-Za-z_][A-Za-z0-9_]*)|([-+*/(),]))/y\n\nconst tokenize = (source: string) => {\n const tokens: Token[] = []\n tokenPattern.lastIndex = 0\n while (tokenPattern.lastIndex < source.length) {\n const at = tokenPattern.lastIndex\n const match = tokenPattern.exec(source)\n if (!match) {\n const rest = source.slice(at)\n if (rest.trim() === '') break\n const skipped = rest.length - rest.trimStart().length\n throw new Error(`Formula \"${source}\": unexpected \"${rest[skipped]}\" at ${at + skipped + 1}`)\n }\n const [whole, number, name, symbol] = match\n const text = (number ?? name ?? symbol)!\n tokens.push({ kind: number !== undefined ? 'number' : name !== undefined ? 'name' : 'symbol', text, at: at + whole.length - text.length })\n }\n return tokens\n}\n\n/** Reads a formula, or throws naming what it cannot read. */\nexport const parseFormula = (source: string): FormulaNode => {\n const tokens = tokenize(source)\n let position = 0\n const fail = (what: string): never => {\n const token = tokens[position]\n throw new Error(`Formula \"${source}\": ${what}${token ? ` at ${token.at + 1}, found \"${token.text}\"` : ' at the end'}`)\n }\n const peek = (text: string) => tokens[position]?.kind === 'symbol' && tokens[position]!.text === text\n const expect = (text: string) => {\n if (!peek(text)) fail(`expected \"${text}\"`)\n position += 1\n }\n const args = () => {\n expect('(')\n const list = [sum()]\n while (peek(',')) {\n position += 1\n list.push(sum())\n }\n expect(')')\n return list\n }\n const call = (name: string): FormulaNode => {\n if (name === 'coalesce') {\n const list = args()\n if (list.length < 2) fail('coalesce() takes at least two values')\n return { kind: 'coalesce', args: list }\n }\n const list = args()\n const [value, digits] = list\n if (list.length > 2) fail('round() takes a value and at most a number of digits')\n if (digits === undefined) return { kind: 'round', value: value! }\n if (digits.kind !== 'number' || digits.value.includes('.')) fail(\"round()'s digits must be a whole number\")\n return { kind: 'round', value: value!, digits: Number((digits as { value: string }).value) }\n }\n const operand = (): FormulaNode => {\n const token = tokens[position]\n if (!token) return fail('expected a number, a field or \"(\"')\n if (token.kind === 'number') {\n position += 1\n return { kind: 'number', value: token.text }\n }\n if (token.kind === 'name') {\n position += 1\n if (!peek('(')) return { kind: 'field', name: token.text }\n if (token.text !== 'coalesce' && token.text !== 'round') {\n position -= 1\n return fail(`unknown function \"${token.text}\", only coalesce() and round()`)\n }\n return call(token.text)\n }\n if (token.text === '-') {\n position += 1\n return { kind: 'negate', operand: operand() }\n }\n if (token.text === '(') {\n position += 1\n const inner = sum()\n expect(')')\n return inner\n }\n return fail('expected a number, a field or \"(\"')\n }\n const product = (): FormulaNode => {\n let node = operand()\n while (peek('*') || peek('/')) {\n const op = tokens[position]!.text as '*' | '/'\n position += 1\n node = { kind: 'binary', op, left: node, right: operand() }\n }\n return node\n }\n const sum = (): FormulaNode => {\n let node = product()\n while (peek('+') || peek('-')) {\n const op = tokens[position]!.text as '+' | '-'\n position += 1\n node = { kind: 'binary', op, left: node, right: product() }\n }\n return node\n }\n const node = sum()\n if (position < tokens.length) fail('expected an operator')\n return node\n}\n\n/** The fields a formula reads, each once, in the order it names them. */\nexport const formulaFields = (node: FormulaNode): string[] => {\n const names = (part: FormulaNode): string[] => {\n if (part.kind === 'field') return [part.name]\n if (part.kind === 'number') return []\n if (part.kind === 'negate') return names(part.operand)\n if (part.kind === 'binary') return [...names(part.left), ...names(part.right)]\n if (part.kind === 'coalesce') return part.args.flatMap(names)\n return names(part.value)\n }\n return [...new Set(names(node))]\n}\n\n/** Whether a formula can be empty: when a field it needs is, unless `coalesce()` has a value that is not. */\nexport const formulaNullable = (node: FormulaNode, nullable: (field: string) => boolean): boolean => {\n if (node.kind === 'field') return nullable(node.name)\n if (node.kind === 'number') return false\n if (node.kind === 'negate') return formulaNullable(node.operand, nullable)\n if (node.kind === 'binary') return formulaNullable(node.left, nullable) || formulaNullable(node.right, nullable)\n if (node.kind === 'coalesce') return node.args.every((arg) => formulaNullable(arg, nullable))\n return formulaNullable(node.value, nullable)\n}\n","import { z } from 'zod'\nimport type { FieldAccess } from './access/types'\nimport { promptError } from './ai-prompt'\nimport type { FieldType } from './model'\nimport type { FileOptions } from './files/file-options'\nimport { parseFormula } from './computed/formula'\nimport type { Rollup } from './computed/rollup'\nimport type { Encrypted } from './encrypted-value'\nimport type { Lookup } from './lookup/lookup'\n\n/** A check on the value that only some field types take: `.min()`, `.max()` and `.regex()`. */\nexport type Constraint = 'min' | 'max' | 'regex'\n\n/** Everything a field's builder methods have set, from which the resource's {@link FieldModel} is built. */\nexport type FieldMeta = {\n /** The field's type. */\n type: FieldType\n /** The column, when it is not the snake_case of the field's name (`.column()`). */\n column?: string\n /** Whether the value may be `null` (`.optional()`). */\n nullable: boolean\n /** Whether the API never writes it (`.readOnly()`). */\n readOnly: boolean\n /** Whether filters may use it (`.filterable()`). */\n filterable: boolean\n /** Whether sorts may use it (`.sortable()`). */\n sortable: boolean\n /** Other names filters may use for it (`.alias()`). */\n aliases: string[]\n /** Whether `.default()` gave it a value. */\n hasDefault: boolean\n /** The value of `.default()`. */\n defaultValue?: unknown\n /** Whether the database supplies a value when none is given (`.dbDefault()`). */\n dbDefault?: boolean\n /** Its role rules (`.access()`). */\n access?: FieldAccess\n /** Whether it is hidden like a password (`.sensitive()`). */\n sensitive?: boolean\n /** Whether it is stored encrypted, and so sensitive too (`.encrypted()`). */\n encrypted?: boolean\n /** How recent a strong sign-in its reveal needs, and so sensitive too (`.strongSignIn()`). */\n strongSignIn?: {\n /** The most minutes since the sign-in, or its confirmation, proved a passkey or a second step. */\n minutes: number\n }\n /** An enum's values (`f.enum()`). */\n enumValues?: string[]\n /** A relation's resource and the columns that hold its key (`f.relation()`, `.columns()`). */\n relation?: {\n /** The resource it points at. */\n resource: string\n /** The columns holding the other record's key, in the order of that key; the field's own column when omitted. */\n columns?: string[]\n }\n /** A decimal's number of digits (`f.decimal()`). */\n precision?: number\n /** A decimal's number of digits after the point (`f.decimal()`). */\n scale?: number\n /** The least value, or for text the shortest length (`.min()`). */\n min?: number\n /** The greatest value, or for text the longest length (`.max()`). */\n max?: number\n /** A pattern the text must match (`.regex()`). */\n regex?: {\n /** The pattern. */\n re: RegExp\n /** The message of the issue a value that does not match gets. */\n message: string\n }\n /** A file field's settings (`f.file()`). */\n file?: FileOptions\n /** How a job fills it (`.ai()`). */\n ai?: {\n /** The prompt the job fills it from. */\n prompt: string\n }\n /** What the database keeps it from: the records of another resource (`.rollup()`). */\n rollup?: Rollup\n /** The expression the database computes it from, over the record's other fields (`.formula()`). */\n formula?: string\n /** The linked record's field it shows (`.lookup()`). */\n lookup?: Lookup\n}\n\n/** A field type: its name, the constraints it takes and how it builds the schema that checks a value. */\nexport type FieldTypeDef = {\n /** The field type it defines. */\n type: FieldType\n /** The constraints its fields may use; any other throws when the config loads. */\n constraints: readonly Constraint[]\n /** The Zod schema of a value, from the field's settings. */\n build: (meta: FieldMeta) => z.ZodType\n}\n\nexport const fieldRegistry = z.registry<FieldMeta>()\n\n/**\n * A field of a resource, holding values of type `V`, as `f` builds it. Every option returns a new field, so they chain\n * in any order. See [Field options](docs/website/src/content/docs/reference/data-config.mdx#field-options).\n */\nexport class Field<V> {\n /** The Zod schema a value is checked with on every create and update: the type's, nullable and defaulted as set. */\n readonly schema: z.ZodType<V>\n\n constructor(\n /** Its field type. */\n readonly def: FieldTypeDef,\n /** What its builder methods have set. */\n readonly meta: FieldMeta,\n ) {\n let schema = def.build(meta)\n if (meta.nullable) schema = schema.nullable()\n if (meta.hasDefault) schema = schema.default(meta.defaultValue as never)\n // Zod maps the meta type member by member, which a file field's processor functions do not survive\n this.schema = schema.register(fieldRegistry, meta as never) as z.ZodType<V>\n }\n\n /** The column, when it is not the snake_case of the field's name, such as `'EMP_NAME'`. */\n column(name: string) {\n return this.with({ column: name })\n }\n\n /** Never written through the API: ids, computed columns, audit timestamps. */\n readOnly() {\n return this.with({ readOnly: true })\n }\n\n /** The column is nullable: the value may be `null`. */\n optional() {\n return this.with({ nullable: true }) as unknown as Field<V | null>\n }\n\n /** The value a create uses when none is given; the admin's create form shows it. */\n default(value: V) {\n return this.with({ hasDefault: true, defaultValue: value })\n }\n\n /**\n * Role-based rules for reading and writing this column. They never see a record, so the set of\n * readable columns is fixed per request. A field without a rule follows its resource.\n */\n access(rules: FieldAccess) {\n return this.with({ access: { ...this.meta.access, ...rules } })\n }\n\n /**\n * Hidden like a password: never part of a list, record, search or write response. A caller who may read it fetches the\n * value of one record on its own (`POST /{{resource}}/{{key}}:reveal`), and every reveal is published as an audit event.\n */\n sensitive() {\n return this.with({ sensitive: true })\n }\n\n /**\n * Stored encrypted with the app's own key (`PROTOBASE_ENCRYPTION_KEY`): the database only ever holds ciphertext. It is\n * sensitive too, so only its reveal decrypts it, and record rules, validators and hooks get a set stored value as\n * {@link encrypted}, never the value. Only `f.text()` takes it. See\n * [Encrypted fields](docs/website/src/content/docs/reference/data-config.mdx#encrypted-fields).\n */\n encrypted() {\n if (this.meta.type !== 'text') throw new Error('.encrypted() takes only f.text() fields')\n return this.with({ encrypted: true, sensitive: true }) as unknown as Field<V | Encrypted>\n }\n\n /**\n * Revealing it needs a strong sign-in: one that proved a passkey or a second step, made or confirmed in the last\n * `minutes` (15 by default). Otherwise the reveal is refused with `403 strong-sign-in-required`, and the record page\n * asks the person to confirm it's them first. It is sensitive too. See\n * [Recent strong sign-in](docs/website/src/content/docs/reference/data-config.mdx#recent-strong-sign-in).\n */\n strongSignIn(o: { minutes?: number } = {}) {\n const minutes = o.minutes ?? 15\n if (!Number.isInteger(minutes) || minutes < 1) throw new Error('.strongSignIn(): minutes must be a whole number of at least 1')\n return this.with({ strongSignIn: { minutes }, sensitive: true })\n }\n\n /** The database supplies a value when none is given (identity, now(), ...). */\n dbDefault() {\n return this.with({ dbDefault: true })\n }\n\n /** Other names filters may use for the field. */\n alias(...names: string[]) {\n return this.with({ aliases: [...this.meta.aliases, ...names] })\n }\n\n /** The field may appear in `filter`, in filter widgets and in the filters of composed pages. Give it an index. */\n filterable() {\n return this.with({ filterable: true })\n }\n\n /** The field may appear in `order_by` and in sorts. */\n sortable() {\n return this.with({ sortable: true })\n }\n\n /** Text must match `re`; a value that does not gets an issue with `message`. Only `f.text()` takes it. */\n regex(re: RegExp, message: string) {\n return this.constrain('regex', { regex: { re, message } })\n }\n\n /** The least value of an integer, or the shortest length of a text. Only `f.integer()` and `f.text()` take it. */\n min(value: number) {\n return this.constrain('min', { min: value })\n }\n\n /** The greatest value of an integer, or the longest length of a text. Only `f.integer()` and `f.text()` take it. */\n max(value: number) {\n return this.constrain('max', { max: value })\n }\n\n /**\n * A job fills the field from `prompt`, `{{field}}` replaced by the record's values, after a create, and after an update\n * that changes a field the prompt names, as the user who wrote; see [AI fields and actions](docs/website/src/content/docs/reference/ai.mdx).\n */\n ai(o: { prompt: string }) {\n const error = promptError(o.prompt)\n if (error) throw new Error(`.ai(): ${error}`)\n return this.with({ ai: { prompt: o.prompt } })\n }\n\n /**\n * The database keeps the field: a column a trigger on `from`'s table sets to `fn` of the records whose `via` points at\n * this record, in the transaction that writes them. `count` and `sum` are 0 without records; `avg`, `min` and `max`\n * are empty, so their fields are `.optional()`. Empty values are left out, as in SQL. Read-only; `protobase migration`\n * writes the column and its trigger. See [Rollups and formulas](docs/website/src/content/docs/reference/data-config.mdx#rollups-and-formulas).\n *\n * @example\n * ```ts\n * total: f.decimal({ precision: 12, scale: 2 }).rollup({ from: 'order_lines', via: 'order_id', fn: 'sum', field: 'amount' }),\n * ```\n */\n rollup(o: Rollup) {\n return this.with({ rollup: { ...o }, readOnly: true })\n }\n\n /**\n * The database computes the field from the record's other number fields: a generated column. `expression` takes\n * numbers, fields, `+ - * /`, parentheses, `coalesce(a, b, ...)` and `round(x, digits)`, computed exactly as decimals and\n * stored as the field's type. Read-only; `protobase migration` writes the column. See\n * [Rollups and formulas](docs/website/src/content/docs/reference/data-config.mdx#rollups-and-formulas).\n *\n * @example\n * ```ts\n * amount: f.decimal({ precision: 12, scale: 2 }).formula('round(quantity * unit_price, 2)'),\n * ```\n */\n formula(expression: string) {\n parseFormula(expression)\n return this.with({ formula: expression, readOnly: true })\n }\n\n /**\n * Shows a field of the record this one is linked to, read with the record in the same query. Without `from` that\n * record is the one this record's relation `via` points at; with `from` it is the one record of `from` whose relation\n * `via` points at this record. The field's type is the linked field's. It is read-only and empty when there is no\n * linked record or the caller may not read it; a caller who may not read the linked field does not see it at all. See\n * [Lookups](docs/website/src/content/docs/reference/data-config.mdx#lookups).\n *\n * @example\n * ```ts\n * customer_name: f.text().lookup({ via: 'customer_id', field: 'name' }).filterable(),\n * release: f.text().lookup({ from: 'app_runtimes', via: 'app_id', field: 'release' }),\n * ```\n */\n lookup(o: Lookup) {\n return this.with({ lookup: { ...o }, readOnly: true, nullable: true }) as unknown as Field<V | null>\n }\n\n /** A copy of the field with `patch` applied, which every option returns. */\n protected with(patch: Partial<FieldMeta>): Field<V> {\n return new Field<V>(this.def, { ...this.meta, ...patch })\n }\n\n private constrain(constraint: Constraint, patch: Partial<FieldMeta>) {\n if (!this.def.constraints.includes(constraint)) {\n throw new Error(`f.${this.def.type} does not support .${constraint}()`)\n }\n return this.with(patch)\n }\n}\n\n/** A field of any value type. */\nexport type AnyField = Field<any>\n","import { Field } from './field'\n\n/** `f.relation(resource)`: a field holding the key of a record of another resource. */\nexport class RelationField<V> extends Field<V> {\n /**\n * The columns that hold the other record's key, in the order of that key, for a resource with a key of several\n * columns. See [Keys and relations](docs/website/src/content/docs/reference/data-config.mdx#keys-and-relations).\n */\n columns(columns: string[]) {\n return this.with({ relation: { resource: this.meta.relation!.resource, columns } })\n }\n}\n","/** What a processor gets: the stored upload's decided type, size and name, its first bytes, and the whole of it on demand. */\nexport type FileProcessorInput = {\n /** The file's name, its extension matched to the decided type. */\n name: string\n /** The type decided from the content, such as `image/jpeg`. */\n type: string\n /** The size in bytes. */\n size: number\n /** The first bytes of the content (up to 256 KB), enough for image headers. */\n head: Uint8Array\n /** The whole content, read from storage. */\n read(): Promise<ReadableStream<Uint8Array>>\n}\n\n/**\n * Computes a value for another column from an upload (`.derive()`). It runs once, on the upload route; a file whose type\n * is not in `accepts` leaves the column null.\n */\nexport type FileProcessor = {\n /** Exact types and `type/*` wildcards; every type when omitted. */\n accepts?: readonly string[]\n /** The value for the column, which must pass that field's schema. */\n run: (file: FileProcessorInput) => unknown\n}\n\n/** The formats an image variant is written in. */\nexport const imageFormats = ['webp', 'avif', 'jpeg', 'png'] as const\n\n/** A format an image variant is written in: `webp`, `avif`, `jpeg` or `png`. */\nexport type ImageFormat = (typeof imageFormats)[number]\n\n/**\n * A resized copy of an uploaded image: at most `width` by `height` pixels, never enlarged. `inside` (the default) keeps\n * the whole image within that box, `cover` fills the box and crops what is outside it. `quality` is 1 to 100, the\n * format's default when omitted.\n */\nexport type ImageVariant = {\n /** The largest width in pixels; any width when omitted. */\n width?: number\n /** The largest height in pixels; any height when omitted. */\n height?: number\n /** `inside` keeps the whole image within the box; `cover` fills the box and crops the rest, and needs both sides. */\n fit?: 'inside' | 'cover'\n /** The format it is written in. */\n format: ImageFormat\n /** 1 to 100; the format's default when omitted. */\n quality?: number\n}\n\n/** `.variants()`' second argument: `original` replaces the upload by that image, so the upload itself is not kept. */\nexport type ImageVariantOptions = {\n /** The image stored instead of the upload, such as `{ width: 2560, format: 'webp' }`. */\n original?: ImageVariant\n}\n\n/** A file field's settings, as the builder collects them. */\nexport type FileOptions = {\n /** The allowed types and `type/*` wildcards (`.accept()`); any type when empty. */\n accept: string[]\n /** The largest upload in bytes (`.maxSize()`). */\n maxSize: number\n /** The provider of `files.providers` the files are stored with (`.storage()`, `.public()`). */\n provider: string\n /** The processors computing other fields from each upload, by field name (`.derive()`). */\n derive?: Record<string, FileProcessor>\n /** The read-only text field each image's ThumbHash goes to (`.placeholder()`). */\n placeholder?: string\n /** The read-only text field each file's media type goes to (`.typeField()`). */\n typeField?: string\n /** The read-only integer field each file's size in bytes goes to (`.sizeField()`). */\n sizeField?: string\n /** The resized copies stored beside each image, by name (`.variants()`). */\n variants?: Record<string, ImageVariant>\n /** The image stored instead of the upload (`.variants()`' `original`). */\n original?: ImageVariant\n /** Whether a value may also be an https URL of a file elsewhere (`.externalUrls()`). */\n external?: true\n}\n\nexport const defaultMaxSize = 50_000_000\n\nconst units: Record<string, number> = { b: 1, kb: 1e3, mb: 1e6, gb: 1e9, kib: 1024, mib: 1024 ** 2, gib: 1024 ** 3 }\n\n/** Bytes from a number or text such as `10 MB` (decimal units) or `5 MiB` (binary units). */\nexport const parseSize = (size: number | string): number => {\n if (typeof size === 'number') {\n if (!Number.isSafeInteger(size) || size <= 0) throw new Error(`A file size must be a positive whole number of bytes, not ${size}`)\n return size\n }\n const match = /^\\s*(\\d+(?:\\.\\d+)?)\\s*([a-z]+)?\\s*$/i.exec(size)\n const unit = units[(match?.[2] ?? 'b').toLowerCase()]\n if (!match || !unit) throw new Error(`\"${size}\" is not a size; write it like \"10 MB\" or \"512 KiB\"`)\n return parseSize(Math.round(Number(match[1]) * unit))\n}\n\nconst typePattern = /^(?:\\*\\/\\*|[a-z0-9][a-z0-9!#$&^_.+-]*\\/(?:\\*|[a-z0-9][a-z0-9!#$&^_.+-]*))$/\n\n/** Allowed types, lowercased: exact types and `type/*` wildcards; `*` alone is refused so that every type is a choice. */\nexport const checkedAccept = (types: readonly string[]) =>\n types.map((type) => {\n const lower = type.trim().toLowerCase()\n if (!typePattern.test(lower)) throw new Error(`\"${type}\" is not a media type or a type/* wildcard`)\n return lower\n })\n\nconst providerPattern = /^[a-z][a-z0-9-]{0,31}$/\n// A stored value starting with one of these would read as a link or another standard URI.\nconst reservedProviders = new Set(['http', 'https', 'data', 'blob', 'file', 'javascript', 'mailto'])\n\n/** A provider name: lowercase, at most 32 characters, and not a scheme browsers already know. */\nexport const checkedProvider = (name: string) => {\n if (!providerPattern.test(name)) throw new Error(`\"${name}\" is not a file provider name: lowercase letters, digits and dashes, starting with a letter`)\n if (reservedProviders.has(name)) throw new Error(`\"${name}\" cannot name a file provider: stored values would read as ${name}: links`)\n return name\n}\n\nconst variantNamePattern = /^[a-z][a-z0-9_]{0,31}$/\nconst fits = ['inside', 'cover']\n\n// A pixel bound of a variant: a whole number from 1 to 16384, the largest side WebP can hold.\nconst checkedBound = (label: string, value: number | undefined) => {\n if (value !== undefined && (!Number.isSafeInteger(value) || value < 1 || value > 16_384)) throw new Error(`${label} must be a whole number of pixels from 1 to 16384, not ${value}`)\n}\n\n/** A variant as written, checked: a known format and fit, and bounds and a quality in range. */\nexport const checkedVariant = (label: string, variant: ImageVariant): ImageVariant => {\n if (!(imageFormats as readonly string[]).includes(variant.format)) throw new Error(`${label}: \"${variant.format}\" is not an image format; use ${imageFormats.join(', ')}`)\n if (variant.fit !== undefined && !fits.includes(variant.fit)) throw new Error(`${label}: fit is \"inside\" or \"cover\", not \"${variant.fit}\"`)\n if (variant.fit === 'cover' && (variant.width === undefined || variant.height === undefined)) throw new Error(`${label}: fit \"cover\" needs both a width and a height`)\n checkedBound(`${label}: width`, variant.width)\n checkedBound(`${label}: height`, variant.height)\n if (variant.quality !== undefined && (!Number.isSafeInteger(variant.quality) || variant.quality < 1 || variant.quality > 100)) {\n throw new Error(`${label}: quality must be a whole number from 1 to 100, not ${variant.quality}`)\n }\n return { ...variant }\n}\n\n/** Variants by name: snake_case names, since each one is part of its file's path. */\nexport const checkedVariants = (variants: Record<string, ImageVariant>) =>\n Object.fromEntries(\n Object.entries(variants).map(([name, variant]) => {\n if (!variantNamePattern.test(name)) throw new Error(`\"${name}\" cannot name an image variant: lowercase letters, digits and underscores, starting with a letter`)\n return [name, checkedVariant(`Image variant \"${name}\"`, variant)]\n }),\n )\n","import type { FieldAccess } from './access/types'\nimport { Field, type FieldMeta } from './field'\nimport { checkedAccept, checkedProvider, checkedVariant, checkedVariants, parseSize, type FileOptions, type FileProcessor, type ImageVariant, type ImageVariantOptions } from './files/file-options'\n\n/** `f.file()`: a text column holding a file's URI, uploaded through `:upload`. See [Files](docs/website/src/content/docs/reference/files.mdx). */\nexport class FileField<V> extends Field<V> {\n /** Allowed types, checked against the type detected from the content: `['image/*', 'application/pdf']`. */\n accept(types: readonly string[]) {\n return this.withFile({ accept: checkedAccept(types) })\n }\n\n /** The largest upload, as bytes or text such as `10 MB`; default 50 MB. */\n maxSize(size: number | string) {\n return this.withFile({ maxSize: parseSize(size) })\n }\n\n /** Stored with the `public` provider, at a permanent URL anyone with it may open. */\n public() {\n return this.storage('public')\n }\n\n /** Stored with this provider of `files.providers`; default `private`. */\n storage(provider: string) {\n return this.withFile({ provider: checkedProvider(provider) })\n }\n\n /**\n * Values computed from each upload, written to other fields of the resource (read-only ones) in the same write as the\n * file: `{ image_width: imageSize('width') }`. Clearing the file clears them.\n */\n derive(processors: Record<string, FileProcessor>) {\n return this.withFile({ derive: { ...this.meta.file!.derive, ...processors } })\n }\n\n /**\n * Computes a ThumbHash of each image into a read-only text field (`photo_placeholder`), which the admin app shows\n * while the image loads. Other files leave it null.\n */\n placeholder(field: string) {\n return this.withFile({ placeholder: field })\n }\n\n /**\n * Writes each file's media type into this read-only text field (`attachment_type`), so lists and aggregates can read\n * it, and serving and file viewers take the type from it. An external URL whose extension names no type leaves it null.\n */\n typeField(field: string) {\n return this.withFile({ typeField: field })\n }\n\n /**\n * Writes each file's size in bytes into this read-only integer or bigint field (`attachment_size`), so lists and\n * aggregates can read it. An external URL leaves it null, as its size is unknown.\n */\n sizeField(field: string) {\n return this.withFile({ sizeField: field })\n }\n\n /**\n * Resized copies of each image, stored beside it under these names: `{ card: { width: 640, height: 480, fit: 'cover',\n * format: 'webp' } }`. `{ original }` stores that image instead of the upload. Other files get none.\n */\n variants(variants: Record<string, ImageVariant>, options: ImageVariantOptions = {}) {\n return this.withFile({\n variants: { ...this.meta.file!.variants, ...checkedVariants(variants) },\n ...(options.original && { original: checkedVariant('The original', options.original) }),\n })\n }\n\n /**\n * Also takes an https URL of a file elsewhere, such as `https://images.example.com/photos/42.jpg`, stored as it is:\n * never uploaded, without variants, and drawn from that address. See\n * [External URLs](docs/website/src/content/docs/reference/files.mdx#external-urls).\n */\n externalUrls() {\n return this.withFile({ external: true })\n }\n\n /** The column is nullable: the field may hold no file. */\n override optional() {\n return this.with({ nullable: true }) as unknown as FileField<V | null>\n }\n\n /** Never written through the API. */\n override readOnly() {\n return this.with({ readOnly: true })\n }\n\n /** The column, when it is not the snake_case of the field's name. */\n override column(name: string) {\n return this.with({ column: name })\n }\n\n /** Role-based rules for reading and writing the file; uploading needs write access to the field. */\n override access(rules: FieldAccess) {\n return this.with({ access: { ...this.meta.access, ...rules } })\n }\n\n /** A copy of the field with `patch` applied, which every option returns. */\n protected override with(patch: Partial<FieldMeta>): FileField<V> {\n return new FileField<V>(this.def, { ...this.meta, ...patch })\n }\n\n private withFile(patch: Partial<FileOptions>) {\n return this.with({ file: { ...this.meta.file!, ...patch } })\n }\n}\n","import type { z } from 'zod'\nimport { bigint } from './fields/bigint'\nimport { boolean } from './fields/boolean'\nimport { country } from './fields/country'\nimport { currency } from './fields/currency'\nimport { date } from './fields/date'\nimport { decimal } from './fields/decimal'\nimport { enumeration } from './fields/enum'\nimport { file } from './fields/file'\nimport { integer } from './fields/integer'\nimport { json } from './fields/json'\nimport { mailSender } from './fields/mail-sender'\nimport { relation } from './fields/relation'\nimport { text } from './fields/text'\nimport { timestamp } from './fields/timestamp'\nimport { uuid } from './fields/uuid'\nimport { Field, type FieldMeta, type FieldTypeDef } from './field'\nimport { RelationField } from './relation-field'\nimport { FileField } from './file-field'\nimport { defaultMaxSize } from './files/file-options'\n\nconst baseMeta = (def: FieldTypeDef): FieldMeta => ({\n type: def.type,\n nullable: false,\n readOnly: false,\n filterable: false,\n sortable: false,\n aliases: [],\n hasDefault: false,\n})\n\nconst make = <V>(def: FieldTypeDef, extra: Partial<FieldMeta> = {}) =>\n new Field<V>(def, { ...baseMeta(def), ...extra })\n\n/**\n * The field builders of a resource's `.fields({ ... })`, one per field type. Each returns a {@link Field} whose options\n * chain in any order. See [Field types](docs/website/src/content/docs/reference/data-config.mdx#field-types).\n *\n * @example\n * ```ts\n * .fields({\n * id: f.integer().readOnly().filterable().sortable().dbDefault(),\n * status: f.enum(['booked', 'ready', 'collected']).default('booked').filterable(),\n * customer_id: f.relation('customers').filterable(),\n * estimate: f.decimal({ precision: 8, scale: 2 }),\n * notes: f.text().optional().column('internal_notes'),\n * })\n * ```\n */\nexport const f = {\n /** Text: a `text`, `varchar` or `bpchar` column. Takes `.min()`, `.max()` (length) and `.regex()`. */\n text: () => make<string>(text),\n /** A 32-bit or smaller integer: an `int2` or `int4` column. Takes `.min()` and `.max()`. */\n integer: () => make<number>(integer),\n /** A 64-bit integer: an `int8` column, a string in the API so that all 64 bits survive. */\n bigint: () => make<string>(bigint),\n /** An exact decimal of `precision` digits, `scale` of them after the point: a `numeric` column, a string in the API. */\n decimal: (o: { precision: number; scale: number }) => make<string>(decimal, o),\n /** A `bool` column. */\n boolean: () => make<boolean>(boolean),\n /** A `date` column, `2026-10-08` in the API. */\n date: () => make<string>(date),\n /** A `timestamp` or `timestamptz` column, ISO 8601 with an offset in the API. */\n timestamp: () => make<string>(timestamp),\n /** A `uuid` column. */\n uuid: () => make<string>(uuid),\n /** One of `values`: a Postgres enum, or text with a `CHECK (... IN ...)`. The record type is the union of the values. */\n enum: <const T extends readonly string[]>(values: T) =>\n make<T[number]>(enumeration, { enumValues: [...values] }),\n /** Any JSON: a `json` or `jsonb` column. */\n json: () => make<z.infer<ReturnType<typeof z.json>>>(json),\n /**\n * The key of a record of `resource`, in that resource's key column(s); the admin shows the other record's title and\n * links to it. A relation to a resource with a key of several columns names them with `.columns()`.\n */\n relation: (resource: string) =>\n new RelationField<string | number>(relation, { ...baseMeta(relation), relation: { resource } }),\n /** A file: its column holds `{provider}:{path}?name=…&size=…` as text, and responses carry `{ uri, name, type, size, url }`. */\n file: () => new FileField<string>(file, { ...baseMeta(file), file: { accept: [], maxSize: defaultMaxSize, provider: 'private' } }),\n /** An ISO 4217 currency code such as `EUR`, in a `text` column. */\n currency: () => make<string>(currency),\n /** An ISO 3166-1 alpha-2 country code such as `NL`, in a `text` column. */\n country: () => make<string>(country),\n /**\n * A From address the person saving may send mail from (`personalMail.senders()`), in a `text` column holding the\n * address, as `personalMail.send({ from })` takes it; empty sends from their default. The form offers their senders\n * as a dropdown, and an address in use cannot be deleted from the account page.\n */\n mailSender: () => make<string>(mailSender),\n}\n","/** Where a menu link may point: a web or mail address outside the admin, never `javascript:` or a path inside it. */\nexport const isMenuHref = (href: string) => /^(https?:\\/\\/|mailto:)/i.test(href)\n","import type { NavStartModel, ResourceModel } from './model'\nimport { filterErrors, orderByErrors } from './nav-recent'\n\n/** What is wrong with a sidebar entry's start record for this model; empty when the app can look it up. */\nexport const navStartErrors = (start: NavStartModel, model: ResourceModel): string[] => [\n ...(typeof start.filter === 'string' && start.filter.trim() !== '' ? filterErrors(model, start.filter).map((error) => `filter: ${error.message}`) : ['needs a filter that finds the record']),\n ...(start.orderBy === undefined ? [] : orderByErrors(model, start.orderBy).map((error) => `orderBy: ${error.message}`)),\n]\n","import { actionInputErrors, inputs } from './action-inputs'\nimport { linkActionError } from './address-template'\nimport { promptError } from './ai-prompt'\nimport { updateSetErrors } from './update-set'\nimport type { ActionInputModel, ActionModel, AppAddress } from './model'\n\n/**\n * A button's label, icon and question, and the records it applies to: `when`, an AIP-160 condition over the record's own\n * fields such as `status = 'running'`, leaves the button out on a record it does not hold for, or with\n * `otherwise: 'disable'` shows it disabled with `reason`. `variant: 'danger'` draws it in red.\n * @inline\n */\ntype ActionOptions = { label: string; icon?: string; confirm?: string; when?: string; otherwise?: 'hide' | 'disable'; reason?: string; variant?: 'danger' }\n\n/** What is wrong with an action's `when`, `otherwise` and `reason`: a fallback needs a condition, and a disabled button says why. */\nexport const actionConditionError = (o: Pick<ActionOptions, 'when' | 'otherwise' | 'reason'>) => {\n if (o.when === undefined) return o.otherwise !== undefined || o.reason !== undefined ? '\"otherwise\" and \"reason\" need a \"when\" condition' : undefined\n if (o.when.trim() === '') return '\"when\" is empty'\n if (o.otherwise === 'disable') return o.reason ? undefined : 'a button disabled by \"when\" needs a \"reason\"'\n return o.reason === undefined ? undefined : '\"reason\" shows only with otherwise: \\'disable\\''\n}\n\nconst named = (name: string, o: ActionOptions & { bulk?: boolean }): ActionModel => {\n const error = actionConditionError(o)\n if (error) throw new Error(`Action \"${name}\": ${error}`)\n return {\n name,\n label: o.label,\n bulk: o.bulk ?? false,\n ...(o.icon !== undefined && { icon: o.icon }),\n ...(o.confirm !== undefined && { confirm: o.confirm }),\n ...(o.when !== undefined && { when: o.when }),\n ...(o.otherwise === 'disable' && { otherwise: o.otherwise, reason: o.reason }),\n ...(o.variant !== undefined && { variant: o.variant }),\n }\n}\n\n/**\n * `mailbox: true` says the handler sends mail from the person's own mailbox, such as an invoice: its dialog offers to\n * connect one instead of running while none is linked.\n * @inline\n */\ntype MailboxOption = { mailbox?: boolean }\n\n/** @inline */\ntype InputsOption = { inputs?: (i: typeof inputs) => ActionInputModel[] }\n\n// The inputs an action asks for, built and checked once for every action that takes them.\nconst builtInputs = (name: string, option: InputsOption['inputs']) => {\n if (!option) return {}\n const built = option(inputs)\n const errors = actionInputErrors(built)\n if (errors.length > 0) throw new Error(`Action \"${name}\": ${errors.join('; ')}`)\n return { inputs: built }\n}\n\nexport const actions = {\n /**\n * An action the app implements: it runs the handler registered under `name`. With `inputs`, such as\n * `(i) => [i.text('reason', { label: 'Reason' })]`, the button first asks for them in a dialog, and the handler gets the\n * answers as `values`. With `bulk`, the list offers it for the selected rows too, asks its inputs once, and runs the handler on each it applies to.\n * With `mailbox: true`, it sends from the person's own mailbox, and its dialog offers to connect one while none is linked.\n */\n action: (name: string, o: ActionOptions & InputsOption & MailboxOption & { bulk?: boolean }): ActionModel => ({\n ...named(name, o),\n ...builtInputs(name, o.inputs),\n ...(o.mailbox && { mailbox: true }),\n }),\n /**\n * Sets fields of the record, as one update with its ETag, for example `{ status: 'paid' }`. It is not offered on a\n * record that holds these values already. With `inputs`, the button first asks for them in a dialog, and a `set` value\n * that is exactly `'{{name}}'` is written as that input's answer, with no handler code:\n * `a.update('answer', { label: 'Answer', inputs: (i) => [i.text('answer', { label: 'Answer', multiline: true })], set: { answer: '{{answer}}' } })`.\n * With `bulk`, the list offers it for the selected rows too, asks its inputs once, and updates each it applies to.\n */\n update: (name: string, o: ActionOptions & InputsOption & { set: Record<string, unknown>; bulk?: boolean }): ActionModel => {\n const built = builtInputs(name, o.inputs)\n const errors = updateSetErrors(o.set, built.inputs)\n if (errors.length > 0) throw new Error(`Action \"${name}\": ${errors.join('; ')}`)\n return { ...named(name, o), ...built, run: { kind: 'update', values: o.set } }\n },\n /** Deletes the record (soft delete when the resource has one). */\n remove: (name: string, o: ActionOptions): ActionModel => ({ ...named(name, o), run: { kind: 'delete' } }),\n /**\n * Goes `to` an address in the app, such as `{ kind: 'record', resource: 'orders', key: '{{order_id}}' }`, or opens an\n * `href` that leaves it (`https:`, `mailto:`); `{{field}}` is replaced by the record's value. An `https:` or `http:` link\n * opens in a new tab without the referrer. An href that is only `{{field}}`, such as `'{{website}}'`, opens the URL the\n * record holds, and the button shows only when it is an `https:` or `http:` URL; `{{host}}` in the label becomes its host,\n * as in `'View on {{host}}'`. A path in the app is refused as an `href`, so every address in the app is written one way.\n */\n link: (name: string, o: Omit<ActionOptions, 'confirm'> & ({ to: AppAddress } | { href: string })): ActionModel => {\n const error = linkActionError(o.label, o)\n if (error) throw new Error(`Action \"${name}\": ${error}`)\n if ('to' in o) return { ...named(name, o), run: { kind: 'link', to: structuredClone(o.to) } }\n return { ...named(name, o), run: { kind: 'link', href: o.href } }\n },\n /**\n * Has the model write the `writes` field of the record from `prompt`, `{{field}}` replaced by the record's values, as the\n * user who clicks; see [AI fields and actions](docs/website/src/content/docs/reference/ai.mdx). The prompt may name the\n * field it writes, to rewrite or translate it in place.\n */\n ai: (name: string, o: ActionOptions & { prompt: string; writes: string }): ActionModel => {\n const error = promptError(o.prompt) ?? (o.writes === '' ? 'it writes no field' : undefined)\n if (error) throw new Error(`Action \"${name}\": ${error}`)\n return { ...named(name, o), run: { kind: 'ai', prompt: o.prompt, writes: o.writes } }\n },\n}\n","import { formNamePattern } from './form-address'\nimport type { FormModel } from './model'\nimport type { Ref } from './refs'\n\n/** How many submissions one client may send a form per minute, unless the form says: as many as sign-in allows. */\nexport const defaultPerMinute = 5\n\n/** What `.form(...)` takes. */\nexport type FormInput = {\n /** Its address in the app, `/-/forms/<name>`: lowercase letters, digits, `-` and `_`, unique across the app. */\n name: string\n /** The page's heading; the view's singular name when omitted. */\n title?: string\n /** The fields a visitor fills in, in order: plain fields the `anonymous` role may create. */\n fields: Ref[]\n /** What the page shows once the record is created. */\n thanks: string\n /** How many submissions one client may send per minute; default 5. */\n perMinute?: number\n}\n\nexport const formModel = (input: FormInput): FormModel => {\n const { name, title, fields, thanks } = input\n if (!formNamePattern.test(name)) throw new Error(`A form's name goes in its address, so it takes lowercase letters, digits, - and _, not \"${name}\"`)\n if (fields.length === 0) throw new Error(`Form \"${name}\" has no fields`)\n const names = fields.map((field) => field.name)\n const repeated = names.find((field, index) => names.indexOf(field) !== index)\n if (repeated !== undefined) throw new Error(`Form \"${name}\" lists the field \"${repeated}\" twice`)\n if (thanks.trim() === '') throw new Error(`Form \"${name}\" needs a thanks text, shown once a visitor sends it`)\n if (title !== undefined && title.trim() === '') throw new Error(`Form \"${name}\" has an empty title; leave it out for the view's name`)\n const perMinute = input.perMinute ?? defaultPerMinute\n if (!Number.isInteger(perMinute) || perMinute < 1) throw new Error(`Form \"${name}\" takes perMinute as a positive whole number, not ${perMinute}`)\n return { name, ...(title !== undefined && { title }), fields: names, thanks, perMinute }\n}\n","import type { RelatedColumnModel } from './model'\n\n/** A column of a view's list that is no field of the resource, as `c` makes one. */\nexport type ListColumn = RelatedColumnModel & {\n /** Marks a related records column. */\n readonly kind: 'related'\n}\n\nexport const isListColumn = (value: unknown): value is ListColumn => typeof value === 'object' && value !== null && (value as { kind?: unknown }).kind === 'related'\n\nexport const columns = {\n /**\n * A column named `name` of the records of `resource` that point at each row, through its relation `field` or, with\n * `through`, through a join resource, as a related section's. Each record is a dot in the colour its `status` value\n * has in its view's `valueColors`, in `sort` order, and a link to the record, showing its card on hover or focus. The\n * name must not be a field of the resource. See\n * [Related records in a list](docs/website/src/content/docs/reference/ui-config.mdx#related-records-in-a-list).\n */\n related: (name: string, o: Omit<RelatedColumnModel, 'name'>): ListColumn => ({ kind: 'related', name, ...structuredClone(o) }),\n}\n","import { badgeTones, isBadgeTone, type BadgeTone } from './badge-tones'\nimport type { BadgeShape, FieldFormat, FieldViewModel, HelpWhen, JsonValue, ShowWhen } from './model'\n\nconst hexColor = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i\n\nconst currencyCode = /^[A-Z]{3}$/\n\n/** How a view shows one field, as `.fields((r) => ...)` hands it out: each hint returns a new field view. */\nexport class FieldView<N extends string = string, V = unknown> {\n /** @internal */\n constructor(\n /** The field's name. */\n readonly name: N,\n /** The hints given so far. */\n readonly props: FieldViewModel = {},\n ) {}\n\n /** What the field is called, instead of its name in words. */\n label(label: string) {\n return this.with({ label })\n }\n\n /**\n * A line under the field on the record page and in forms; `when: 'editing'` shows it only while the record is edited,\n * not on its read view (the view's `.helpWhen(...)` when omitted).\n */\n help(help: string, o: { when?: HelpWhen } = {}) {\n return this.with({ help, ...(o.when !== undefined && { helpWhen: o.when }) })\n }\n\n /**\n * When the field shows on the record page: `editing` only on its form and the create form, `reading` only on its read\n * view and locked form; `always` when omitted. Its lists, cards and filters show it either way.\n */\n when(when: ShowWhen) {\n return this.with({ when })\n }\n\n /**\n * Leaves the field off the create form, for one that makes sense only once the record exists, such as a choice among\n * records added after it; the create leaves it empty or to its default, and the record page shows it as usual. The\n * server stops at startup on a field a create needs: not optional and with no default.\n */\n notOnCreate() {\n return this.with({ notOnCreate: true })\n }\n\n /**\n * Asks `question` before a person changes the value in a form or a list cell, such as a flag that is easy to set by\n * mistake: once as the value first moves away from the saved one, not on every key. Cancelling keeps the value. See\n * [Confirming a change](docs/website/src/content/docs/reference/ui-config.mdx#confirming-a-change).\n */\n confirm(question: string) {\n if (question.trim() === '') throw new Error(`Field \"${this.name}\": .confirm() needs the question to ask`)\n return this.with({ confirm: question })\n }\n\n /**\n * How the value shows: `badge` for statuses, `code` in monospace, `percent` with a % sign, `signed` with its sign, green\n * above zero and red below; for a text field, `email`, `phone` and `url` as a mail, call or open link, edited with an\n * email, phone or address keyboard on a mobile screen. `text` gives a `url` link the text it shows instead of the\n * address, fixed or with `{{field}}` placeholders from the record: `.format('url', { text: '{{title}}' })`.\n */\n format(format: FieldFormat, o: { text?: string } = {}) {\n if (o.text === undefined && format === 'url') return this.with({ format })\n // Another format drops the link text an earlier format('url') gave, which only a url link shows\n if (o.text === undefined) {\n const { linkText: _, ...props } = this.props\n return new FieldView<N, V>(this.name, { ...props, format })\n }\n if (format !== 'url') throw new Error(`Field \"${this.name}\": only format('url') takes a link text`)\n if (o.text.trim() === '') throw new Error(`Field \"${this.name}\": format('url') needs a link text that is not empty`)\n return this.with({ format, linkText: o.text })\n }\n\n /**\n * A text of several lines, such as a description: forms edit it in a box that grows with the text, and the record\n * page and cards keep its line breaks. Only a text field takes it.\n */\n multiline() {\n return this.with({ multiline: true })\n }\n\n /**\n * Markdown, such as notes: forms edit its source with a Write and Preview switch, and the record page, a page's field\n * blocks and a card's subtitle show it rendered, raw HTML shown as text and links opening in a new tab; the list's\n * table shows its text on one line. Only a text field takes it.\n */\n markdown() {\n return this.with({ markdown: true })\n }\n\n /** Text before a number wherever it is shown, such as a currency sign: `.prefix('€')`. */\n prefix(prefix: string) {\n return this.with({ prefix })\n }\n\n /** The ISO 4217 code of the currency a decimal is an amount of, such as `.currency('EUR')`: lists show it as money in it. */\n currency(currency: string) {\n if (!currencyCode.test(currency)) throw new Error(`Field \"${this.name}\": currency \"${currency}\" is not an ISO 4217 code such as EUR`)\n return this.with({ currency })\n }\n\n /** Text after a number wherever it is shown, such as a unit: `.suffix(' m²')`. */\n suffix(suffix: string) {\n return this.with({ suffix })\n }\n\n /** How many decimals a number shows wherever it is shown. */\n decimals(decimals: number) {\n return this.with({ decimals })\n }\n\n /** Labels for an enum's values, such as `{ co_signer: 'Co-signer' }`; values left out read as themselves in words. */\n valueLabels(labels: { readonly [P in Extract<V, string>]?: string }) {\n return this.with({ valueLabels: { ...this.props.valueLabels, ...(labels as Record<string, string>) } })\n }\n\n /**\n * A badge tone (`neutral`, `blue`, `green`, `amber`, `red` or `violet`) or a hex colour that fills the badge, per enum\n * value, such as `{ paid: 'green', a: '#00a651' }`; values left out are `neutral`.\n */\n valueColors(colors: { readonly [P in Extract<V, string>]?: BadgeTone | (string & {}) }) {\n const entries = Object.entries(colors as Record<string, string>)\n const wrong = entries.find(([, color]) => !isBadgeTone(color) && !hexColor.test(color))\n if (wrong) throw new Error(`Field \"${this.name}\": value colour \"${wrong[1]}\" of \"${wrong[0]}\" is not a tone (${badgeTones.join(', ')}) or a hex colour such as #00a651`)\n return this.with({ valueColors: { ...this.props.valueColors, ...Object.fromEntries(entries) } })\n }\n\n /** Enum values that mark a wait rather than work, such as `.waitingValues(['queued', 'blocked'])`: a `Timeline` draws them striped. */\n waitingValues(values: readonly Extract<V, string>[]) {\n return this.with({ waitingValues: [...values] })\n }\n\n /** `arrow` draws the field's badges as arrows pointing right, as on a rating scale such as the EU energy label. */\n badgeShape(badgeShape: BadgeShape) {\n return this.with({ badgeShape })\n }\n\n /**\n * An icon before the value on a card's meta row and above it in a section of key facts, by the names actions take,\n * such as `ruler`.\n */\n icon(icon: string) {\n return this.with({ icon })\n }\n\n /**\n * Shows and edits the field with the field type a plugin registers under `name` (`definePlugin({ fields })`), given\n * `props`, such as `r.score.widget('rating', { max: 5 })`, or with the built-in `members`, which picks an\n * organization's members into a JSON array of user ids (see\n * [Members](docs/website/src/content/docs/reference/plugins.md#members)). Without that field type, or when it does not show\n * this field's storage type, the field shows as it would without it.\n */\n widget(name: string, props?: Record<string, JsonValue>) {\n return this.with({ widget: { name, ...(props && { props }) } })\n }\n\n private with(patch: FieldViewModel) {\n return new FieldView<N, V>(this.name, { ...this.props, ...patch })\n }\n}\n","import type { DatePreset, FilterWidgetModel } from './model'\nimport type { Ref } from './refs'\n\n/** Every widget also takes `secondary: true`, which puts it behind the bar's \"More filters\" menu until it is picked there or set. */\nexport const widgets = {\n /** A slider between the field's lowest and highest value; `histogram` draws the values' histogram behind it. */\n range: (ref: Ref, o: { histogram?: boolean; secondary?: boolean } = {}): FilterWidgetModel => ({\n kind: 'range',\n field: ref.name,\n histogram: o.histogram ?? false,\n ...(o.secondary && { secondary: true }),\n }),\n /**\n * A menu of the field's values with counts; `search` adds a search box for long lists. On a relation it searches the\n * referenced records as you type, on a number field it is a range slider.\n */\n facets: (ref: Ref, o: { search?: boolean; secondary?: boolean } = {}): FilterWidgetModel => ({\n kind: 'facets',\n field: ref.name,\n search: o.search ?? false,\n ...(o.secondary && { secondary: true }),\n }),\n /** A date range with buttons for the `presets`, such as `today` and `30d`. */\n dateRange: (ref: Ref, o: { presets?: DatePreset[]; secondary?: boolean } = {}): FilterWidgetModel => ({\n kind: 'dateRange',\n field: ref.name,\n presets: o.presets ?? [],\n ...(o.secondary && { secondary: true }),\n }),\n /** A switch for a boolean field. */\n toggle: (ref: Ref, o: { secondary?: boolean } = {}): FilterWidgetModel => ({ kind: 'toggle', field: ref.name, ...(o.secondary && { secondary: true }) }),\n /**\n * A menu of boolean fields under one `label`, such as \"for sale\" and \"for rent\": a record shows when any chosen field\n * is true, so one that is both shows under each.\n */\n flags: (refs: Ref<string, boolean | null>[], o: { label: string; secondary?: boolean }): FilterWidgetModel => ({\n kind: 'flags',\n fields: refs.map((ref) => ref.name),\n label: o.label,\n ...(o.secondary && { secondary: true }),\n }),\n}\n","import type {\n ActionModel,\n AppAddress,\n CreateModel,\n ExportModel,\n FilterWidgetModel,\n HelpWhen,\n LayoutItemModel,\n PageWidth,\n RecordMode,\n ConversationPageModel,\n SaveFeedback,\n SortSpec,\n NamedListModel,\n NavModel,\n NavRecentModel,\n ListDisplayModel,\n ListDragModel,\n ResourceModel,\n SaveSearchModel,\n SearchesOfModel,\n SignInPromptModel,\n ViewModel,\n} from './model'\nimport { addressPlaceholders } from './address-template'\nimport { formNamePattern } from './form-address'\nimport { layoutItems } from './layout-items'\nimport { isMenuHref } from './menu-href'\nimport { viewOfList } from './named-list'\nimport { navRecentErrors } from './nav-recent'\nimport { membersTitle, recordPageErrors } from './record-page'\nimport { navStartErrors } from './nav-start'\nimport { createRefs, ref, type FieldRefs, type Ref } from './refs'\nimport { actions } from './view-actions'\nimport { chartModel, type ChartInput } from './view-chart'\nimport { formModel, type FormInput } from './view-form'\nimport { columns as listColumns, isListColumn, type ListColumn } from './view-columns'\nimport { boardErrors, customComponent, datesErrors, displayErrors, displayFields, displays, type ComponentRef } from './view-displays'\nimport { FieldView } from './view-field'\nimport { widgets } from './view-widgets'\n\n// What a named list's builder may set; anything else would be silently ignored.\nconst namedListParts = new Set(['resource', 'names', 'nav', 'help', 'list', 'filters', 'chart'])\n\ntype FieldsOf<R extends { readonly $fields: unknown }> = R['$fields']\n\n// The saved search's own fields: text for the filter and name, a timestamp for when its results were last opened.\nconst searchesOfErrors = (searches: SearchesOfModel, resource: ResourceModel) => {\n const typed = (role: string, name: string | undefined, type: string) =>\n name === undefined || resource.fields[name]?.type === type ? [] : [`${role} \"${name}\" is not a ${type} field of the resource`]\n return [\n ...typed('filter', searches.filter, 'text'),\n ...typed('name', searches.name, 'text'),\n ...typed('unseen.seenAt', searches.unseen?.seenAt, 'timestamp'),\n ...(searches.controls ?? []).flatMap((name) => (['enum', 'boolean'].includes(resource.fields[name]?.type ?? '') ? [] : [`control \"${name}\" is not an enum or boolean field of the resource`])),\n ...(searches.limit === undefined || (Number.isInteger(searches.limit) && searches.limit > 0) ? [] : ['limit must be a positive whole number']),\n ]\n}\n\n/**\n * `nav(...)` with `recent.status` limited to the resource's fields, and `recent.pulse` only beside a status.\n *\n * @inline\n */\ntype NavInput<R extends { readonly $fields: unknown }> = Omit<NavModel, 'recent'> & {\n recent?: Omit<NavRecentModel, 'status' | 'pulse'> & ({ status: keyof FieldsOf<R> & string; pulse?: string[] } | { status?: never; pulse?: never })\n}\n\n/** The `r` of `.fields((r) => ...)`: a field view per field of the resource, to give hints such as `.label()`. */\nexport type FieldViews<R extends {\n /** The resource's fields, as `resource(...)` declares them. */\n readonly $fields: unknown\n}> = {\n readonly [K in keyof FieldRefs<FieldsOf<R>> & string]: FieldView<K, NonNullable<FieldRefs<FieldsOf<R>>[K]['$value']>>\n}\n\n/**\n * A view of a resource, as `view(...)` starts it: how the admin shows it. Each method returns a new view, so one view\n * can build on another. See [UI config](docs/website/src/content/docs/reference/ui-config.mdx).\n */\nexport class ViewBuilder<R extends {\n /** The resource's fields, as `resource(...)` declares them. */\n readonly $fields: unknown\n}> {\n /** @internal */\n constructor(\n /** @internal */\n readonly state: ViewModel,\n ) {}\n\n /** What a record and the records are called, such as \"New repair\" and \"Repairs\"; the resource name in words by default. */\n names(names: { singular: string; plural: string }) {\n return this.next({ names })\n }\n\n /** The resource's icon in the sidebar, bottom bar and user menu; a table without one. See [Sidebar icons](docs/website/src/content/docs/reference/sidebar.md#sidebar-icons). */\n icon(icon: string) {\n return this.next({ icon })\n }\n\n /** Shows this view only to users with one of these roles; a view without roles is the default. */\n forRoles(roles: string[]) {\n return this.next({ roles })\n }\n\n /** The field shown as this record's title. Throws when the field does not exist. */\n title(pick: (r: FieldRefs<FieldsOf<R>>) => Ref) {\n return this.next({ title: pick(this.refs()).name })\n }\n\n /**\n * A title derived per reader in the browser, in place of `title`: `rule` names a function of the project's UI\n * `titles`, which gets the record with the `fields` picked and the signed-in reader, such as the names of the members\n * other than the reader. The record's key shows while it returns nothing. Throws when a field does not exist.\n */\n titleFrom(rule: string, pick: (r: FieldRefs<FieldsOf<R>>) => Ref[]) {\n const fields = pick(this.refs()).map((ref) => ref.name)\n if (rule === '') throw new Error(`View \"${this.state.resource}\": titleFrom needs the name of a rule`)\n if (fields.length === 0) throw new Error(`View \"${this.state.resource}\": titleFrom \"${rule}\" reads no fields`)\n return this.next({ titleFrom: { rule, fields } })\n }\n\n /**\n * How a record shows in the global search: a bold `title` of one or more fields joined by spaces (default: `title`)\n * and a `subtitle` field under it, replaced by the search field the text matched when that is neither.\n */\n searchResult(pick: (r: FieldRefs<FieldsOf<R>>) => { title?: Ref | Ref[]; subtitle?: Ref }) {\n const { title, subtitle } = pick(this.refs())\n const titles = title === undefined ? [] : Array.isArray(title) ? title : [title]\n return this.next({ searchResult: { ...(titles.length > 0 && { title: titles.map((ref) => ref.name) }), ...(subtitle && { subtitle: subtitle.name }) } })\n }\n\n /**\n * Where the resource sits in the sidebar; `recent` lists a few of its records under the entry (see\n * [Sidebar](docs/website/src/content/docs/reference/sidebar.md#recent-records)), and `tenant: 'current'` opens it on the\n * caller's own tenant (see [The current organization](docs/website/src/content/docs/reference/sidebar.md#the-current-organization)),\n * `create` links to the create form under it (see [Create link](docs/website/src/content/docs/reference/sidebar.md#create-link)),\n * and `start` names the record the app opens at `/` (see [Start record](docs/website/src/content/docs/reference/sidebar.md#start-record)).\n */\n nav(nav: NavInput<R>) {\n return this.next({ nav })\n }\n\n /** A line under the list's title. */\n help(help: string) {\n return this.next({ help })\n }\n\n /** Hints per field, such as `{ total: r.total.prefix('€').decimals(2) }`; calls add up. */\n fields(build: (r: FieldViews<R>) => Record<string, FieldView>) {\n const built = build(createRefs((name) => new FieldView(name)))\n const fields = Object.fromEntries(Object.values(built).map((v) => [v.name, v.props]))\n return this.next({ fields: { ...this.state.fields, ...fields } })\n }\n\n /**\n * The list: its table's `columns`, fields or columns of related records (`c.related`), `sort`, `search` and a `filter` it opens with, the\n * columns that are `editable` in their cell, and other `displays` to switch to (`d.cards`, `d.map`, `d.board`, `d.calendar`, `d.timeline`, `d.custom`), one of which\n * may be the `default` the list opens in, and what `drag` lets a user change by dragging, nothing unless it says.\n * Throws when display or column names collide, `default` names none or an editable field is not among the columns. See\n * [Editing in the list](docs/website/src/content/docs/reference/ui-config.mdx#editing-in-the-list).\n */\n list(\n build: (\n r: FieldRefs<FieldsOf<R>>,\n d: typeof displays,\n c: typeof listColumns,\n ) => {\n columns: Array<Ref | ListColumn>\n sort?: Array<[Ref, 'asc' | 'desc']>\n search?: Ref[]\n filter?: string\n editable?: Ref[]\n displays?: ListDisplayModel[]\n default?: string\n drag?: ListDragModel\n },\n ) {\n const { columns, sort, search, filter, editable, displays: shown = [], default: opens, drag } = build(this.refs(), displays, listColumns)\n const related = columns.filter(isListColumn).map(({ kind: _, ...column }) => column)\n const names = columns.map((column) => column.name)\n const repeated = names.find((name, index) => names.indexOf(name) !== index)\n if (repeated !== undefined) throw new Error(`View \"${this.state.resource}\": the list has two columns named \"${repeated}\"`)\n const stray = editable?.find((ref) => !names.includes(ref.name))\n if (stray) throw new Error(`View \"${this.state.resource}\": editable field \"${stray.name}\" is not among the list's columns`)\n const list = {\n columns: names,\n ...(related.length > 0 && { relatedColumns: related }),\n ...(sort && { sort: sort.map(([ref, dir]) => [ref.name, dir]) as SortSpec }),\n ...(search && { search: search.map((ref) => ref.name) }),\n ...(filter !== undefined && filter !== '' && { filter }),\n ...(editable && editable.length > 0 && { editable: editable.map((ref) => ref.name) }),\n ...(shown.length > 0 && { displays: shown }),\n ...(opens !== undefined && { default: opens }),\n ...(drag && { drag: { ...drag } }),\n }\n const errors = displayErrors(list)\n if (errors.length > 0) throw new Error(`View \"${this.state.resource}\": ${errors.join('; ')}`)\n return this.next({ list })\n }\n\n /**\n * The filter widgets above the list, in order, each on a `.filterable()` field: `w.facets`, `w.dateRange`, `w.range`,\n * `w.toggle` and `w.flags`. Together they write the list's `?filter=`.\n */\n filters(build: (r: FieldRefs<FieldsOf<R>>, w: typeof widgets) => FilterWidgetModel[]) {\n return this.next({ filters: build(this.refs(), widgets) })\n }\n\n /**\n * Another list of this resource, with its own sidebar entry and address (`/<resource>?list=<name>`). `build` gets a\n * fresh view and sets its `names` (the sidebar entry, required), `nav`, `help`, `list`, `filters` and `chart`, none of\n * which come from the view's own list. Its records open at the resource's own address. Throws on a name that does not\n * fit an address or repeats, on anything else set, on `nav.recent`, and in `toModel` when the view has `listOf` or\n * `searchesOf`. See [More than one list](docs/website/src/content/docs/reference/ui-config.mdx#more-than-one-list).\n */\n namedList(name: string, build: (v: ViewBuilder<R>) => ViewBuilder<R>) {\n const where = `View \"${this.state.resource}\": named list \"${name}\"`\n if (!formNamePattern.test(name)) throw new Error(`${where}: its name goes in its address, so it takes lowercase letters, digits, - and _`)\n if (this.state.lists?.some((entry) => entry.name === name)) throw new Error(`${where} is declared twice`)\n const start = view<R>(this.state.resource)\n const { state } = build(start)\n const extra = Object.keys(state).filter((key) => !namedListParts.has(key) && state[key as keyof ViewModel] !== start.state[key as keyof ViewModel])\n if (extra.length > 0) throw new Error(`${where} sets ${extra.join(', ')}; a named list takes names, nav, help, list, filters and chart`)\n if (!state.names) throw new Error(`${where} needs .names(...), its sidebar entry`)\n if (state.nav?.recent) throw new Error(`${where}: recent records are the view's own, not a named list's`)\n const named: NamedListModel = {\n name,\n names: state.names,\n filters: state.filters,\n ...(state.nav && { nav: state.nav }),\n ...(state.help !== undefined && { help: state.help }),\n ...(state.list && { list: state.list }),\n ...(state.chart && { chart: state.chart }),\n }\n return this.next({ lists: [...(this.state.lists ?? []), named] })\n }\n\n /**\n * The record page, as items of `l` in order: sections, sidebar cards, related records, maps and custom components.\n * Without it the page shows one section with every field.\n */\n layout(build: (r: FieldRefs<FieldsOf<R>>) => LayoutItemModel[]) {\n return this.next({ layout: build(this.refs()) })\n }\n\n /**\n * A chart above the list, following its filters: records per `granularity` over a date or timestamp `field`, or\n * records per value of `groupBy`, such as a status or a relation, as bars or a donut of the `limit` largest (default\n * 10), counted or with `sum` or `average` that of a numeric field.\n */\n chart(build: (r: FieldRefs<FieldsOf<R>>) => ChartInput) {\n return this.next({ chart: chartModel(build(this.refs())) })\n }\n\n /**\n * A public form that creates a record of this resource for anyone, signed in or not, at `/-/forms/<name>`: the\n * `fields` a visitor fills in, the `thanks` shown once it is sent, a `title` (the view's singular name by default) and\n * how many submissions one client may send `perMinute` (default 5). The `anonymous` role must grant `create` of those\n * fields; the form is the only way it creates. Each call adds a form. Throws on a name that does not fit an address, no\n * or repeated fields, or an empty `thanks`. See [Public forms](docs/website/src/content/docs/reference/forms.mdx).\n */\n form(build: (r: FieldRefs<FieldsOf<R>>) => FormInput) {\n return this.next({ forms: [...(this.state.forms ?? []), formModel(build(this.refs()))] })\n }\n\n /**\n * How the record page opens to a user who may change the record: `edit`, the default, as its form; `read` as a read\n * view, its sections as tables of labels and values, with an Edit button to the form; `locked` as the form, locked\n * until Edit is pressed. A user who may not change it gets the read view in every mode. The form has its own address\n * (`edit: true`), so it opens in a new tab and Back leaves it. See [The record page](docs/website/src/content/docs/reference/ui-config.mdx#read-view-and-edit).\n */\n recordMode(recordMode: RecordMode) {\n return this.next({ recordMode })\n }\n\n /**\n * When the help lines of the view's fields and sections show: `always`, the default, or only while the record is\n * `editing`, on its form; a field's `.help(text, { when })` or a section's `helpWhen` says otherwise for its own.\n */\n helpWhen(helpWhen: HelpWhen) {\n return this.next({ helpWhen })\n }\n\n /** Where the record page shows that it saved: a toast (the default) or the Save button. */\n saveFeedback(saveFeedback: SaveFeedback) {\n return this.next({ saveFeedback })\n }\n\n /**\n * How wide the standard record page is: a centred `column`, the default, or the `full` width of the content pane, its\n * sidebar cards still beside the sections. See [The record page](docs/website/src/content/docs/reference/ui-config.mdx#page-width).\n */\n recordWidth(recordWidth: PageWidth) {\n return this.next({ recordWidth })\n }\n\n /**\n * The field the record page shows as a badge beside its title, in the field's `valueColors` and labels, such as a\n * verdict; without it an enum field named `status` shows there. Throws when the field does not exist, or is neither\n * an enum nor shown with `.format('badge')`. See\n * [The record page](docs/website/src/content/docs/reference/ui-config.mdx#read-only-values-and-a-title-badge).\n */\n titleBadge(pick: (r: FieldRefs<FieldsOf<R>>) => Ref) {\n return this.next({ titleBadge: pick(this.refs()).name })\n }\n\n /**\n * Whether the list page offers Import, which creates or updates records from an .xlsx, CSV or JSON file the user\n * picks (`true`, the default, to users who may create records); `.import(false)` turns it off. `.import('table')`\n * makes it a new table users add from the file instead, as the Tables list of user tables does. See\n * [Importing records](docs/website/src/content/docs/reference/ui-config.mdx#importing-records).\n */\n import(enabled: boolean | 'table') {\n return this.next({ import: enabled })\n }\n\n /**\n * The named actions of the record page's action rail, which composed pages can put on buttons too: `a.update`,\n * `a.remove` and `a.link` need no code, `a.action` runs a handler the app registers.\n */\n actions(build: (a: typeof actions) => ActionModel[]) {\n return this.next({ actions: build(actions) })\n }\n\n /**\n * The list page shows the records this relation field points at instead of this resource's rows, in their own view's\n * list with its displays, filters and search: the listings among a member's favorites, say. The record pages stay this\n * resource's. Throws in `toModel` when the field is not a relation.\n */\n listOf(pick: (r: FieldRefs<FieldsOf<R>>) => Ref) {\n return this.next({ listOf: pick(this.refs()).name })\n }\n\n /**\n * What a visitor who is not signed in is told about this resource, which they could use once signed in: on its list\n * page, in place of the list, and in the dialog of a card's favorite button or a list's \"Save search\" button that\n * saves here. The page offers \"Sign in\", and a way to make an account: the page `signUp` names, or the app's own sign-up\n * when the server has [open sign-up](docs/website/src/content/docs/reference/auth.md#open-sign-up). With it, the resource keeps its place in the bottom\n * bar and the sidebar of visitors. Throws when `signUp.href` is not `https:`, `http:` or `mailto:`. See\n * [Sign-in prompts](docs/website/src/content/docs/reference/ui-config.mdx#sign-in-prompts).\n */\n signIn(prompt: SignInPromptModel) {\n if (prompt.signUp && !isMenuHref(prompt.signUp.href)) throw new Error(`View \"${this.state.resource}\": signIn signUp.href must start with https://, http:// or mailto:`)\n return this.next({ signIn: structuredClone(prompt) })\n }\n\n /**\n * A \"Save search\" button on the list page while its filter narrows it: it saves the filter as a record of `resource`,\n * the signed-in user's own, whose view lists them with `.searchesOf(...)`, and takes it off again while pressed. A\n * visitor is told what signing in gives, when that view has `.signIn(...)`. See\n * [Saved searches](docs/website/src/content/docs/reference/ui-config.mdx#saved-searches).\n */\n saveSearch(search: SaveSearchModel) {\n return this.next({ saveSearch: { ...search } })\n }\n\n /**\n * Whether the list page offers Export, which saves its rows as an Excel or CSV file built in the browser: `false`\n * takes it away, `{ maxRows }` limits how many rows a file holds. A list offers it by default. It only shapes the\n * page: the rows and fields a file holds are those the list API gives the user. Throws when `maxRows` is not a\n * positive whole number. See [Exports](docs/website/src/content/docs/reference/ui-config.mdx#exports).\n */\n export(options: false | ExportModel) {\n if (options && options.maxRows !== undefined && !(Number.isInteger(options.maxRows) && options.maxRows > 0)) {\n throw new Error(`View \"${this.state.resource}\": export maxRows must be a positive whole number`)\n }\n return this.next({ export: options && { ...options } })\n }\n\n /**\n * Records are created on `page`, a composed page of the app's own, in place of the create form: `/<resource>/new`\n * shows it with the address's `values`, and the list's New button opens it for whoever may open the page, whatever the\n * resource's `create` access. So the resource's API can refuse creates (`create: never`) while the page creates\n * through an API function. The server refuses a page that does not exist when it starts. See\n * [Create pages](docs/website/src/content/docs/reference/ui-config.mdx#create-pages).\n */\n create(options: CreateModel) {\n return this.next({ create: { ...options } })\n }\n\n /**\n * The record page at `/<resource>/<key>` is `component`, a component of the app's own declared with `component(...)`\n * and exported from `protobase.ui.tsx`, filling the content area beside the sidebar and under the top bar, where the\n * page does not scroll. It reads the record with `useLayoutRecord()`. The standard record page stays at the record's\n * address with `standard: true`, which the component links to; it shows instead while the component is missing or\n * when it throws. Throws when `component` is a built-in block. See\n * [Full-area record pages](docs/website/src/content/docs/reference/ui-config.mdx#full-area-record-pages).\n *\n * `focus: true` draws it on a focus page, with the bar's state, Save, the record's actions and panels; the form\n * `(r) => ({ surface: r.body })` needs no component: the surface is one field, drawn by its field type. See\n * [Focus pages](docs/website/src/content/docs/reference/ui-config.mdx#focus-pages).\n *\n * `conversation` makes the page the record's conversation, filling the area with no component of the app's own: a\n * header, the messages that point at the record and a box that sends one. A conversation with `members` titles its\n * record after them for each reader, as `.titleFrom('members', ...)` does, unless the view sets its own. See\n * [Conversation pages](docs/website/src/content/docs/reference/ui-config.mdx#conversation-pages).\n */\n record(options: { component: ComponentRef<never>; focus?: boolean } | { conversation: ConversationPageModel } | ((r: FieldRefs<FieldsOf<R>>) => { surface: Ref })) {\n if (typeof options === 'function') return this.next({ record: { surface: options(this.refs()).surface.name } })\n if ('conversation' in options) return this.next({ record: { conversation: structuredClone(options.conversation) } })\n return this.next({ record: { component: customComponent(options.component, 'record component'), ...(options.focus && { focus: true }) } })\n }\n\n /**\n * A record's page opens `to` in its place, replacing the address in the history, `{{field}}` in its resource, key and\n * run replaced by the record's values: a workflow run's opens its workflow's page with the run on the graph. A list\n * of addresses opens the first whose `{{field}}`s all have a value in the record, as a row button's choices do: a\n * message opens in its channel, else in its direct message. Links that know the record's fields, such as the top bar's\n * search results, point at it too. A caller who cannot see where a choice leads skips it, and a record no choice fits\n * gets its own page. Throws on an empty list. See\n * [Open elsewhere](docs/website/src/content/docs/reference/ui-config.mdx#open-elsewhere).\n */\n recordOpens(to: AppAddress | readonly AppAddress[]) {\n const choices = Array.isArray(to) ? [...to] : [to as AppAddress]\n if (choices.length === 0) throw new Error(`View \"${this.state.resource}\": recordOpens needs at least one address`)\n return this.next({ recordOpens: structuredClone(choices) })\n }\n\n /**\n * The resource's create address opens `to` in place of the form, replacing the address in the history, `{{field}}`\n * filled from the address's values, for a record that is made where it is used: a workflow's test run opens in the\n * workflow's page. An address that does not give every such field shows the form.\n */\n createOpens(to: AppAddress) {\n return this.next({ createOpens: structuredClone(to) })\n }\n\n /**\n * This resource holds saved searches of `resource`, which a list page saves with `.saveSearch(...)`: its list page\n * shows each of the user's searches with its filters, its `controls` to change in place, the records it finds (with\n * `unseen`, newest first, those new since the user last opened its results marked) and a link to all of them. Throws in\n * `toModel` when `filter` or `name` is not a text field, `unseen.seenAt` not a timestamp or a control not an enum or\n * boolean field.\n * See [Saved searches](docs/website/src/content/docs/reference/ui-config.mdx#saved-searches).\n */\n searchesOf(\n pick: (r: FieldRefs<FieldsOf<R>>) => {\n resource: string\n filter: Ref\n name?: Ref\n controls?: Ref[]\n unseen?: { seenAt: Ref; field: string }\n limit?: number\n },\n ) {\n const { resource, filter, name, controls, unseen, limit } = pick(this.refs())\n const searches: SearchesOfModel = {\n resource,\n filter: filter.name,\n ...(name && { name: name.name }),\n ...(controls && { controls: controls.map((control) => control.name) }),\n ...(unseen && { unseen: { seenAt: unseen.seenAt.name, field: unseen.field } }),\n ...(limit !== undefined && { limit }),\n }\n return this.next({ searchesOf: searches })\n }\n\n /** With the resource's model, also verifies the title and `titleFrom`, search result and list display fields, related column names, a gallery's image, `listOf`, `searchesOf`, the sidebar's `recent` group and `tenant`, and the forms' fields. */\n toModel(resource?: ResourceModel): ViewModel {\n const { title, titleFrom, titleBadge, nav, searchResult, list, listOf } = this.state\n if (resource && title !== undefined && !Object.hasOwn(resource.fields, title)) {\n throw new Error(`View \"${this.state.resource}\": title field \"${title}\" does not exist on the resource`)\n }\n if (resource && titleBadge !== undefined && !Object.hasOwn(resource.fields, titleBadge)) {\n throw new Error(`View \"${this.state.resource}\": title badge field \"${titleBadge}\" does not exist on the resource`)\n }\n if (resource && titleBadge !== undefined && resource.fields[titleBadge]!.type !== 'enum' && this.state.fields[titleBadge]?.format !== 'badge') {\n throw new Error(`View \"${this.state.resource}\": title badge field \"${titleBadge}\" is no enum and has no .format('badge'), so it would not fit a badge`)\n }\n const unknownTitleField = resource ? titleFrom?.fields.find((name) => !Object.hasOwn(resource.fields, name)) : undefined\n if (unknownTitleField !== undefined) throw new Error(`View \"${this.state.resource}\": titleFrom field \"${unknownTitleField}\" does not exist on the resource`)\n const missing = resource ? [...(searchResult?.title ?? []), ...(searchResult?.subtitle ? [searchResult.subtitle] : [])].filter((name) => !Object.hasOwn(resource.fields, name)) : []\n if (missing.length > 0) throw new Error(`View \"${this.state.resource}\": search result field \"${missing[0]}\" does not exist on the resource`)\n for (const display of resource ? (list?.displays ?? []) : []) {\n const unknown = displayFields(display).find((name) => !Object.hasOwn(resource!.fields, name))\n if (unknown !== undefined) throw new Error(`View \"${this.state.resource}\": display \"${display.name}\" names field \"${unknown}\", which the resource does not have`)\n if (display.kind === 'cards' && display.image !== undefined && resource!.fields[display.image]!.type !== 'file') {\n throw new Error(`View \"${this.state.resource}\": display \"${display.name}\" shows \"${display.image}\" as its image, which is not a file field`)\n }\n const flag = display.kind === 'cards' ? display.flags?.find((name) => resource!.fields[name]!.type !== 'boolean') : undefined\n if (flag !== undefined) throw new Error(`View \"${this.state.resource}\": display \"${display.name}\" shows \"${flag}\" as a flag, which is not a boolean field`)\n const board = display.kind === 'board' ? boardErrors(display, resource!, list?.drag?.board) : []\n if (board.length > 0) throw new Error(`View \"${this.state.resource}\": display \"${display.name}\": ${board.join('; ')}`)\n const dates = display.kind === 'calendar' || display.kind === 'timeline' ? datesErrors(display, resource!) : []\n if (dates.length > 0) throw new Error(`View \"${this.state.resource}\": display \"${display.name}\": ${dates.join('; ')}`)\n }\n const clash = resource ? list?.relatedColumns?.find((column) => Object.hasOwn(resource.fields, column.name)) : undefined\n if (clash) throw new Error(`View \"${this.state.resource}\": related column \"${clash.name}\" has the name of a field of the resource`)\n const groupTitles = new Set<string>()\n const tabs = this.state.layout.flatMap((item, index) => (item.kind === 'tab' ? [{ item, index }] : []))\n const apart = tabs.find((tab, at) => at > 0 && tab.index !== tabs[at - 1]!.index + 1)\n if (apart) throw new Error(`View \"${this.state.resource}\": tabs stand together, and \"${apart.item.title}\" is apart from the others`)\n const tabTitles = new Set<string>()\n for (const { item } of tabs) {\n if (tabTitles.has(item.title)) throw new Error(`View \"${this.state.resource}\": two tabs are titled \"${item.title}\"`)\n tabTitles.add(item.title)\n }\n for (const item of this.state.layout.flatMap((item) => (item.kind === 'tab' ? item.items : [item]))) {\n if (item.kind !== 'group') continue\n if (groupTitles.has(item.title)) throw new Error(`View \"${this.state.resource}\": two groups are titled \"${item.title}\"`)\n groupTitles.add(item.title)\n }\n for (const item of resource ? layoutItems(this.state.layout) : []) {\n if (item.kind !== 'gallery' || item.image === undefined) continue\n if (!Object.hasOwn(resource!.fields, item.image)) throw new Error(`View \"${this.state.resource}\": gallery \"${item.title}\" names field \"${item.image}\", which the resource does not have`)\n if (resource!.fields[item.image]!.type !== 'file') throw new Error(`View \"${this.state.resource}\": gallery \"${item.title}\" shows \"${item.image}\" as its image, which is not a file field`)\n }\n if (resource && listOf !== undefined && (!Object.hasOwn(resource.fields, listOf) || resource.fields[listOf]!.type !== 'relation')) {\n throw new Error(`View \"${this.state.resource}\": listOf names \"${listOf}\", which is not a relation field of the resource`)\n }\n const searchErrors = resource && this.state.searchesOf ? searchesOfErrors(this.state.searchesOf, resource) : []\n if (searchErrors.length > 0) throw new Error(`View \"${this.state.resource}\": searchesOf ${searchErrors.join('; ')}`)\n for (const form of resource ? (this.state.forms ?? []) : []) {\n const unknown = form.fields.find((name) => !Object.hasOwn(resource!.fields, name))\n if (unknown !== undefined) throw new Error(`View \"${this.state.resource}\": form \"${form.name}\" names field \"${unknown}\", which the resource does not have`)\n }\n if (nav?.tenant === 'current' && !list) throw new Error(`View \"${this.state.resource}\": nav.tenant narrows the opening filter of the list, so the view needs .list(...)`)\n const tenantField = resource?.tenant === undefined ? undefined : resource.fields[resource.tenant]\n if (resource && nav?.tenant === 'current' && !tenantField?.filterable) {\n throw new Error(`View \"${this.state.resource}\": nav.tenant opens the list on the current tenant, so the resource needs .tenant() on a .filterable() field`)\n }\n if (typeof nav?.create === 'object' && nav.create.label.trim() === '') throw new Error(`View \"${this.state.resource}\": nav.create needs a label, or true for \"New <singular>\"`)\n const recentErrors = resource && nav?.recent ? navRecentErrors(nav.recent, resource) : []\n if (recentErrors.length > 0) throw new Error(`View \"${this.state.resource}\": nav.recent ${recentErrors.join('; ')}`)\n const conversation = this.state.record && 'conversation' in this.state.record ? this.state.record.conversation : undefined\n if (nav?.recent?.unread && !conversation?.readPosition) throw new Error(`View \"${this.state.resource}\": nav.recent.unread counts from the conversation's read positions, so the view needs .record({ conversation }) with readPosition`)\n if (nav?.recent?.typing && !conversation?.typing) throw new Error(`View \"${this.state.resource}\": nav.recent.typing shows the typing of the record's conversation, so the view needs .record({ conversation }) with typing`)\n const startErrors = resource && nav?.start ? navStartErrors(nav.start, resource) : []\n if (startErrors.length > 0) throw new Error(`View \"${this.state.resource}\": nav.start ${startErrors.join('; ')}`)\n const opensUnknown = resource ? (this.state.recordOpens ?? []).flatMap(addressPlaceholders).find((name) => !Object.hasOwn(resource.fields, name)) : undefined\n if (opensUnknown !== undefined) throw new Error(`View \"${this.state.resource}\": recordOpens names field \"${opensUnknown}\", which the resource does not have`)\n if (this.state.lists?.length && (listOf !== undefined || this.state.searchesOf)) {\n throw new Error(`View \"${this.state.resource}\": named lists cannot go with listOf or searchesOf, which replace the list page`)\n }\n const pageErrors = resource ? recordPageErrors(this.state.record, resource) : []\n if (pageErrors.length > 0) throw new Error(`View \"${this.state.resource}\": record ${pageErrors.join('; ')}`)\n for (const named of this.state.lists ?? []) new ViewBuilder<R>(viewOfList(this.state, named.name)!).toModel(resource)\n return structuredClone({ ...this.state, ...(!titleFrom && membersTitle(this.state.record)) })\n }\n\n private refs() {\n return createRefs<FieldRefs<FieldsOf<R>>>(ref)\n }\n\n private next(patch: Partial<ViewModel>) {\n return new ViewBuilder<R>({ ...this.state, ...patch })\n }\n}\n\n/**\n * Starts the view of a resource: how the admin shows it. Pass the resource's type, so every field reference (`r.status`)\n * is checked against it. See [UI config](docs/website/src/content/docs/reference/ui-config.mdx).\n *\n * @example\n * ```ts\n * import { view } from '@protobase/schema'\n * import type { repairs } from './data'\n *\n * export const repairsView = view<typeof repairs>('repairs')\n * .names({ singular: 'Repair', plural: 'Repairs' })\n * .list((r) => ({ columns: [r.number, r.status, r.booked_on], sort: [[r.booked_on, 'desc']] }))\n * ```\n */\nexport const view = <R extends {\n /** The resource's fields, as `resource(...)` declares them. */\n readonly $fields: unknown\n}>(resource: string) =>\n new ViewBuilder<R>({ resource, fields: {}, filters: [], layout: [], actions: [] })\n","import type { FieldAccess } from '../access/types'\nimport { f } from '../fields'\nimport type { StatusTone } from '../model'\nimport { resource } from '../resource'\nimport { view } from '../view'\n\n/** How many of a workflow's latest ended runs its status reads. */\nexport const statusRuns = 10\n\n/**\n * A workflow's status from its last {@link statusRuns} ended runs, as its database triggers keep it: `failing` when the\n * latest failed and still counts, `unresolved` when it succeeded and an earlier one failed and still counts, `healthy`\n * when none counts; `no_runs`, `resolved` and `new_version` when there is no ended run, or the latest is a failure that\n * stopped counting as someone marked the workflow resolved or saved a new version.\n */\nexport const workflowStatuses = ['failing', 'unresolved', 'healthy', 'no_runs', 'resolved', 'new_version'] as const\n\nexport type WorkflowStatus = (typeof workflowStatuses)[number]\n\n/** What each status is called, in the sidebar's names for screen readers and on the workflow's page. */\nexport const workflowStatusLabels = {\n failing: 'Last run failed',\n unresolved: 'Earlier failure unresolved',\n healthy: 'No unresolved failures',\n no_runs: 'No runs yet',\n resolved: 'No runs since resolved',\n new_version: 'No runs since this version',\n} as const satisfies Record<WorkflowStatus, string>\n\n/** The sidebar's tone for each status; the gray ones are `neutral`. */\nexport const workflowStatusTones = { failing: 'danger', unresolved: 'warning', healthy: 'success' } as const satisfies Partial<Record<WorkflowStatus, StatusTone>>\n\n/** The statuses \"Mark as resolved\" clears. */\nexport const resolvableStatuses: readonly WorkflowStatus[] = ['failing', 'unresolved']\n\n// The status tells how runs went, so only a caller who reads every run of the workflow sees it.\nconst readsRuns: FieldAccess = { read: (ctx) => ctx.holds?.('workflow_runs.read') ?? false }\n\n/**\n * The status fields of a workflow, all written by the database: the status, the run its reason links to and when it\n * ended, how many failures among the last runs still count, and who last marked it resolved and when.\n */\nexport const workflowStatusFields = {\n run_status: f.enum(workflowStatuses).readOnly().dbDefault().access(readsRuns),\n status_run_id: f.relation('workflow_runs').optional().readOnly().access(readsRuns),\n status_run_at: f.timestamp().optional().readOnly().access(readsRuns),\n unresolved_failures: f.integer().readOnly().dbDefault().access(readsRuns),\n resolved_at: f.timestamp().optional().readOnly(),\n resolved_by: f.text().optional().readOnly(),\n}\n\n/**\n * Each time someone marked a workflow resolved: kept, never changed, and copied onto the workflow. Whoever may change\n * the workflow may mark it, naming the workflow without reading these records, which take `workflow_resolutions.read`.\n */\nexport const resolutionsResource = (schema: string) =>\n resource('workflow_resolutions')\n .table(`${schema}.resolutions`)\n .fields({\n id: f.uuid().readOnly().dbDefault(),\n workflow_id: f.relation('workflows').filterable().access({ create: () => true }),\n resolved_by: f.text().optional().readOnly(),\n tenant_id: f.text().optional().readOnly(),\n resolved_at: f.timestamp().readOnly().dbDefault().sortable(),\n })\n .primaryKey((r) => r.id)\n .tenant((r) => r.tenant_id)\n .author((r) => r.resolved_by)\n .parent((r) => r.workflow_id, 'update')\n .explicitGrants()\n .access({ create: () => true, update: () => false, delete: () => false })\n\nexport const resolutionsView = view<ReturnType<typeof resolutionsResource>>('workflow_resolutions')\n .names({ singular: 'Workflow resolution', plural: 'Workflow resolutions' })\n .icon('check')\n .nav({ hidden: true })\n .title((r) => r.resolved_at)\n .fields((r) => ({ workflow_id: r.workflow_id.label('Workflow'), resolved_by: r.resolved_by.label('Resolved by'), resolved_at: r.resolved_at.label('Resolved') }))\n .list((r) => ({ columns: [r.workflow_id, r.resolved_by, r.resolved_at], sort: [[r.resolved_at, 'desc']] }))\n","import { messages } from '../../../locale/messages'\n\nexport const text = messages('app/field-types/workflow-status')\n","import { useOptionalAuth } from '../../../auth/auth-provider'\nimport { formatDateTime } from '../../../format/date'\nimport { useMembers } from '../../../people/use-members'\nimport { text } from './messages'\n\n// An organization's member by name, read with the members list.\nconst MemberName = ({ id }: { id: string }) => <>{useMembers().member(id)?.name ?? id}</>\n\n/** Who last marked the workflow resolved and when: you, a member of the organization by name, or else their user id. */\nexport const ResolvedBy = ({ by, at }: { by: string | null; at: string }) => {\n const auth = useOptionalAuth()\n const self = auth?.state.kind === 'signed-in' && by !== null && String(auth.state.user.id) === by\n const who = self ? text('you') : by === null ? '?' : auth?.organizations ? <MemberName id={by} /> : by\n return <p className=\"text-body text-muted-foreground\">{text.rich('resolvedBy', { who, when: formatDateTime(Date.parse(at)) })}</p>\n}\n","import type { StatusTone } from '@protobase/schema'\nimport { resolvableStatuses, statusRuns, workflowStatuses, workflowStatusTones, type WorkflowStatus } from '@protobase/schema/internal'\nimport { formatDateTime } from '../../../format/date'\nimport { text } from './messages'\n\n/** What a workflow's page says of its status: its tone, the words, the run they name when they name one, and whether it can be marked resolved. */\nexport type StatusReason = { status: WorkflowStatus; tone: StatusTone; words: string; run?: string; resolvable: boolean }\n\nconst isStatus = (value: unknown): value is WorkflowStatus => (workflowStatuses as readonly unknown[]).includes(value)\n\nconst toneOf = (status: WorkflowStatus): StatusTone => (workflowStatusTones as Partial<Record<WorkflowStatus, StatusTone>>)[status] ?? 'neutral'\n\n/** A status as a list's cell shows it: its tone and its name; none for a value that is no status. */\nexport const statusLabel = (value: unknown): { tone: StatusTone; words: string } | undefined => {\n if (!isStatus(value)) return\n return { tone: toneOf(value), words: text('label', { status: value }) }\n}\n\nconst when = (value: unknown) => formatDateTime(Date.parse(String(value)))\n\n/** The reason of a workflow's status, from its record's status fields; none for a record without a status, as for a caller who cannot read its runs. */\nexport const statusReason = (record: Record<string, unknown>): StatusReason | undefined => {\n const status = record.run_status\n if (!isStatus(status)) return\n const shared = { status, tone: toneOf(status), resolvable: resolvableStatuses.includes(status) }\n const run = record.status_run_id == null ? undefined : String(record.status_run_id)\n if (status === 'failing' || status === 'healthy') return { ...shared, words: text(status, { when: when(record.status_run_at), runs: statusRuns }), ...(run && { run }) }\n if (status === 'unresolved') return { ...shared, words: text(status, { count: Number(record.unresolved_failures), runs: statusRuns, when: when(record.status_run_at) }), ...(run && { run }) }\n return { ...shared, words: text(status) }\n}\n","import { useState } from 'react'\nimport { useClient } from '../../../data/api-provider'\nimport { useToast } from '../../../toasts'\nimport { usePermissions } from '../../meta-gate'\nimport { useRefreshResource } from '../../pages/use-layout-data'\nimport { can } from '../../permissions'\nimport { text } from './messages'\n\n/** The resource whose records mark a workflow resolved: one per mark, copied onto the workflow by the database. */\nexport const resolutionsResource = 'workflow_resolutions'\n\n/**\n * Marks the workflow resolved, clearing every failure so far, for a caller who may change it (`mayUpdate`, the record's\n * own permission) and so mark it; then reads the workflow again, which the sidebar follows.\n */\nexport const useResolve = (workflow: string, mayUpdate: boolean) => {\n const client = useClient()\n const refresh = useRefreshResource()\n const toast = useToast()\n const permitted = can(usePermissions(resolutionsResource), 'create') && mayUpdate\n const [busy, setBusy] = useState(false)\n const resolve = async () => {\n setBusy(true)\n await client.create(resolutionsResource, { workflow_id: workflow }).then(\n async () => {\n await Promise.all([refresh('workflows'), refresh(resolutionsResource)])\n toast.show({ state: 'success', title: text('resolveDone') })\n },\n () => toast.show({ state: 'error', title: text('resolveFailed') }),\n )\n setBusy(false)\n }\n return { permitted, busy, resolve }\n}\n","import { builtInFieldTypes } from '@protobase/schema/internal'\nimport { StatusDot } from '../../../app-shell/status-dot'\nimport { useRecord } from '../../../data/use-record'\nimport { Button } from '../../../primitives/button'\nimport { AppLink } from '../../use-app-address'\nimport type { FieldWidget, FieldWidgetProps } from '../field-widget'\nimport { useWorkflowView } from '../workflow-page/use-workflow-page'\nimport { workflowsResource, workflowViewAddress } from '../workflow-page/workflow-view'\nimport { ResolvedBy } from './resolved-by'\nimport { statusLabel, statusReason } from './status-reason'\nimport { useResolve } from './use-resolve'\nimport { text } from './messages'\n\n// The status of the workflow the page shows, said in words that link to the run they name, with Mark as resolved while\n// failures count and who last marked it.\nconst StatusOf = ({ workflow, value }: { workflow: string; value: string }) => {\n const stored = useRecord(workflowsResource, workflow).data\n const record = stored?.record\n const resolver = useResolve(workflow, stored?.permissions?.update !== false)\n const reason = record && statusReason({ ...record, run_status: value })\n if (!record || !reason) return null\n return (\n <div className=\"grid gap-2\">\n <div className=\"flex flex-wrap items-center gap-x-3 gap-y-2\">\n <span className=\"inline-flex min-w-0 items-center gap-2 text-body\" data-status={reason.status}>\n <StatusDot tone={reason.tone} />\n {reason.run ? (\n <AppLink to={workflowViewAddress({ workflow, run: reason.run })} className=\"font-medium text-primary-text hover:underline\">\n {reason.words}\n </AppLink>\n ) : (\n <span>{reason.words}</span>\n )}\n </span>\n {reason.resolvable && resolver.permitted && (\n <Button size=\"sm\" loading={resolver.busy} onClick={() => void resolver.resolve()}>\n {text('resolve')}\n </Button>\n )}\n </div>\n {record.resolved_at != null && <ResolvedBy by={record.resolved_by == null ? null : String(record.resolved_by)} at={String(record.resolved_at)} />}\n </div>\n )\n}\n\nconst StatusDisplay = ({ value }: FieldWidgetProps<string>) => {\n const view = useWorkflowView()\n return value === null || !view ? null : <StatusOf workflow={view.workflow} value={value} />\n}\n\n// The workflows list shows each status by its mark and name.\nconst StatusCell = ({ value }: FieldWidgetProps<string>) => {\n const label = statusLabel(value)\n if (!label) return null\n return (\n <span className=\"inline-flex items-center gap-2\">\n <StatusDot tone={label.tone} />\n {label.words}\n </span>\n )\n}\n\n/**\n * The built-in `workflow_status` field type, for a workflow's status from its last runs, as the `workflows` resource\n * shows its own: `r.run_status.widget('workflow_status')`. A workflow's page says the reason in words, linking to the\n * run it names, with Mark as resolved while a failure counts for whoever may change the workflow, and who last marked\n * it and when; a list shows the status by its mark and name. See the workflows reference.\n */\nexport const workflowStatusField: FieldWidget = { of: [...builtInFieldTypes.workflow_status], display: StatusDisplay, cell: StatusCell }\n"],"mappings":"2qCAEA,IAAMqF,GAAS,UACTC,GAAM,EAAE,IAAM,KACdC,GAAM,IAAM,IAAM,GAEXC,GAAS,CACpB,KAAM,SACN,YAAa,CAAC,EACd,UACExF,EAAS,CAAC,CAAC,OAAQ,GAAMqF,GAAO,KAAKI,CAAC,GAAK,OAAOA,CAAC,GAAKH,IAAO,OAAOG,CAAC,GAAKF,GAAK,CAC/E,QAAS,uCACX,CAAC,CACL,ECXaG,GAAU,CAAE,KAAM,UAAW,YAAa,CAAC,EAAG,UAAazF,GAAU,CAAE,ECAvE0F,GAAU,CACrB,KAAM,UACN,YAAa,CAAC,EACd,UAAazF,EAAS,CAAC,CAAC,MAAM,aAAc,6CAA6C,CAC3F,ECJa0F,GAAW,CACtB,KAAM,WACN,YAAa,CAAC,EACd,UAAazF,EAAS,CAAC,CAAC,MAAM,aAAc,oCAAoC,CAClF,ECJa0F,GAAO,CAAE,KAAM,OAAQ,YAAa,CAAC,EAAG,UAAazF,GAAW,CAAE,ECAzE0F,GAAQ,wBAEDC,GAAU,CACrB,KAAM,UACN,YAAa,CAAC,EACd,MAAQ,GAA8C,CACpD,GAAIC,EAAE,YAAc,IAA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