@phis/ui 0.8.0 → 0.8.2
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/README.md +9 -2
- package/components/cms/phi-cms-layout-renderer.js +15 -7
- package/components/cms/phi-cms-render-diagnostic-client.d.ts +3 -1
- package/components/cms/phi-cms-render-diagnostic-client.js +4 -3
- package/components/cms/phi-cms-render-diagnostic.d.ts +8 -2
- package/components/cms/phi-cms-render-diagnostic.js +12 -2
- package/components/cms/phi-cms-render-error-boundary.d.ts +2 -0
- package/components/cms/phi-cms-render-error-boundary.js +1 -1
- package/components/cms/phi-cms-root-layout.js +3 -1
- package/components/controls/phi-media-picker-control.d.ts +9 -0
- package/components/controls/phi-media-picker-control.js +1 -1
- package/components/controls/phi-popover-control.js +4 -1
- package/components/controls/phi-table-control.d.ts +7 -1
- package/components/controls/phi-table-control.js +26 -11
- package/components/forms/form-descriptor-field-check.d.ts +18 -0
- package/components/forms/form-descriptor-field-check.js +41 -0
- package/components/forms/form-descriptor-runtime-client.js +11 -10
- package/components/forms/form-record-source.d.ts +38 -0
- package/components/forms/form-record-source.js +48 -0
- package/components/forms/shared-form-descriptors.d.ts +0 -34
- package/components/forms/shared-form-descriptors.js +0 -6
- package/components/forms/shared-form-ids.d.ts +1 -1
- package/components/forms/shared-form-ids.js +1 -1
- package/components/media/media-settings-labels.d.ts +1 -0
- package/components/media/media-settings-labels.js +2 -0
- package/components/media/media-upload-flow.d.ts +62 -5
- package/components/media/media-upload-flow.js +62 -24
- package/components/media/phi-area-upload-widget.d.ts +44 -1
- package/components/media/phi-area-upload-widget.js +32 -7
- package/components/media/phi-media-picker-binding.d.ts +41 -33
- package/components/media/phi-media-picker-binding.js +2 -1
- package/components/media/phi-media-upload.d.ts +10 -3
- package/components/media/phi-media-upload.js +11 -8
- package/components/media/use-media-library-add-picker.d.ts +33 -32
- package/components/overlays/phi-overlay-container-client.js +11 -9
- package/components/regions/presets/phi-settings-page-shell-tree.d.ts +7 -0
- package/components/regions/presets/phi-settings-page-shell-tree.js +3 -3
- package/components/shell/phi-icon-names.d.ts +3 -0
- package/components/shell/phi-icon-names.js +3 -0
- package/components/shell/phi-icon.d.ts +5 -7
- package/components/shell/phi-icon.js +8 -21
- package/components/shell/phi-widget-icon.js +1 -0
- package/components/tables/client/phi-table-binding-params.d.ts +24 -0
- package/components/tables/client/phi-table-binding-params.js +39 -0
- package/components/tables/client/phi-table-binding.d.ts +1 -3
- package/components/tables/client/phi-table-binding.js +5 -9
- package/components/widgets/client/html-editor-link-node.d.ts +12 -0
- package/components/widgets/client/html-editor-link-node.js +60 -0
- package/components/widgets/client/html-editor.js +10 -6
- package/components/widgets/client/shared/phi-button-icons.d.ts +6 -4
- package/components/widgets/client/shared/phi-button-icons.js +8 -12
- package/components/widgets/client/shared/phi-collection-binding-params.d.ts +8 -0
- package/components/widgets/client/shared/phi-collection-binding-params.js +13 -0
- package/components/widgets/client/shared/phi-collection-provider.d.ts +11 -1
- package/components/widgets/client/shared/phi-collection-provider.js +5 -0
- package/components/widgets/client/shared/phi-collection-view-binding.d.ts +1 -0
- package/components/widgets/client/shared/phi-collection-view-binding.js +33 -26
- package/components/widgets/client/shared/phi-command-buttons.d.ts +16 -0
- package/components/widgets/client/shared/phi-command-buttons.js +9 -1
- package/components/widgets/label-sets/admin-users.d.ts +1 -0
- package/components/widgets/label-sets/admin-users.js +2 -0
- package/components/widgets/label-sets/builder-modules.js +4 -0
- package/components/widgets/label-sets/profile.d.ts +0 -16
- package/components/widgets/label-sets/profile.js +0 -37
- package/components/widgets/label-sets/registration.d.ts +0 -1
- package/components/widgets/label-sets/registration.js +0 -2
- package/components/widgets/label-sets/revisions.js +2 -0
- package/components/widgets/label-sets/signals.js +2 -0
- package/components/widgets/label-types/builder-modules.d.ts +4 -0
- package/components/widgets/label-types/builder-modules.js +2 -0
- package/components/widgets/label-types/revisions.d.ts +2 -0
- package/components/widgets/label-types/revisions.js +2 -1
- package/components/widgets/label-types/signals.d.ts +2 -0
- package/components/widgets/label-types/signals.js +1 -0
- package/components/widgets/shared/widget-failure-audience.d.ts +7 -0
- package/components/widgets/shared/widget-failure-audience.js +21 -0
- package/components/widgets/shared/widget-failure-client.js +5 -2
- package/components/widgets/shared/widget-failure-notice-client.d.ts +6 -0
- package/components/widgets/shared/widget-failure-notice-client.js +10 -0
- package/components/widgets/shared/widget-failure-notice.d.ts +6 -0
- package/components/widgets/shared/widget-failure-notice.js +17 -0
- package/components/widgets/shared/widget-failure-staff.d.ts +3 -0
- package/components/widgets/shared/widget-failure-staff.js +18 -0
- package/components/widgets/shared/widget-failure.d.ts +9 -6
- package/components/widgets/shared/widget-failure.js +0 -9
- package/components/widgets/shared/widget-failure.server.d.ts +4 -2
- package/components/widgets/shared/widget-failure.server.js +8 -3
- package/constants/cms-widget-types.d.ts +1 -0
- package/constants/cms-widget-types.js +3 -0
- package/constants/customer-file.d.ts +12 -3
- package/constants/customer-file.js +12 -3
- package/constants/runtime-module-ownership.js +5 -3
- package/constants/site-address.d.ts +9 -0
- package/constants/site-address.js +10 -0
- package/constants/table-loading.d.ts +14 -0
- package/constants/table-loading.js +14 -0
- package/constants.d.ts +2 -1
- package/constants.js +3 -1
- package/gateway/site-cms-write-validation.js +19 -3
- package/gateway/site-proxy.d.ts +12 -0
- package/gateway/site-proxy.js +20 -0
- package/helpers/announced-action.d.ts +17 -0
- package/helpers/announced-action.js +29 -0
- package/helpers/phi-metadata.d.ts +0 -8
- package/helpers/phi-metadata.js +1 -10
- package/helpers/phi-site-description.d.ts +11 -0
- package/helpers/phi-site-description.js +13 -0
- package/helpers/preset-form-check.d.ts +14 -0
- package/helpers/preset-form-check.js +12 -0
- package/helpers/preset-table-check.d.ts +19 -15
- package/helpers/preset-table-check.js +33 -39
- package/helpers/record-widget-binding.d.ts +10 -0
- package/helpers/record-widget-binding.js +35 -0
- package/helpers/record-widget.d.ts +1 -10
- package/helpers/record-widget.js +4 -33
- package/helpers/table-widget-binding.d.ts +12 -0
- package/helpers/table-widget-binding.js +296 -0
- package/helpers/tree-widget-binding.d.ts +19 -0
- package/helpers/tree-widget-binding.js +72 -0
- package/helpers/typed-confirmation.d.ts +9 -0
- package/helpers/typed-confirmation.js +13 -0
- package/helpers/widget-binding-check.d.ts +22 -0
- package/helpers/widget-binding-check.js +91 -0
- package/module-page-check.d.ts +2 -0
- package/module-page-check.js +2 -0
- package/net/phi-next-proxy.d.ts +7 -0
- package/net/phi-next-proxy.js +1 -1
- package/next/root-route.js +2 -1
- package/package.json +27 -14
- package/plugins/runtime-modules/accounting/ids.d.ts +7 -4
- package/plugins/runtime-modules/accounting/ids.js +14 -3
- package/plugins/runtime-modules/accounting/trees/accounting-customer-file-label-set.d.ts +21 -9
- package/plugins/runtime-modules/accounting/trees/accounting-customer-file-label-set.js +29 -15
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-customer-file-page-tree.d.ts +11 -8
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-customer-file-page-tree.js +206 -137
- package/plugins/runtime-modules/app/client-data-providers.js +1 -1
- package/plugins/runtime-modules/app/data-providers.d.ts +14 -69
- package/plugins/runtime-modules/app/data-providers.js +19 -54
- package/plugins/runtime-modules/app/definition.d.ts +8 -80
- package/plugins/runtime-modules/app/forms.d.ts +1 -16
- package/plugins/runtime-modules/app/forms.js +0 -59
- package/plugins/runtime-modules/app/ids.d.ts +2 -1
- package/plugins/runtime-modules/app/ids.js +3 -2
- package/plugins/runtime-modules/app/module.d.ts +8 -80
- package/plugins/runtime-modules/app/services/addresses-collection.d.ts +59 -0
- package/plugins/runtime-modules/app/services/{addresses-table.js → addresses-collection.js} +23 -19
- package/plugins/runtime-modules/app/trees/account-addresses-panel.d.ts +10 -6
- package/plugins/runtime-modules/app/trees/account-addresses-panel.js +37 -73
- package/plugins/runtime-modules/app/trees/addresses-label-set.d.ts +0 -5
- package/plugins/runtime-modules/app/trees/addresses-label-set.js +2 -6
- package/plugins/runtime-modules/app/trees/phi-default-app-profile-page-tree.d.ts +1 -2
- package/plugins/runtime-modules/app/trees/phi-default-app-profile-page-tree.js +1 -17
- package/plugins/runtime-modules/app/trees/profile-label-set.d.ts +0 -2
- package/plugins/runtime-modules/app/trees/profile-label-set.js +2 -14
- package/plugins/runtime-modules/area-contributions/admin.d.ts +1 -1
- package/plugins/runtime-modules/area-contributions/admin.js +2 -0
- package/plugins/runtime-modules/asset/trees/phi-default-admin-media-settings-page-tree.js +5 -0
- package/plugins/runtime-modules/avatar/addresses.d.ts +1 -1
- package/plugins/runtime-modules/builder/clients/inspector-config-field.js +16 -6
- package/plugins/runtime-modules/builder/clients/inspector-image-field.js +3 -1
- package/plugins/runtime-modules/builder/clients/inspector-section-widget.js +3 -1
- package/plugins/runtime-modules/builder/controller/signal-wiring-controller.js +5 -1
- package/plugins/runtime-modules/builder/signal-wiring-options.js +9 -2
- package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +5 -0
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +14 -1
- package/plugins/runtime-modules/cdn/authoring-widgets.d.ts +3 -0
- package/plugins/runtime-modules/cdn/authoring-widgets.js +7 -0
- package/plugins/runtime-modules/cdn/authoring.d.ts +1 -0
- package/plugins/runtime-modules/cdn/authoring.js +8 -0
- package/plugins/runtime-modules/cdn/bytes.d.ts +5 -0
- package/plugins/runtime-modules/cdn/bytes.js +17 -0
- package/plugins/runtime-modules/cdn/client-data-providers.d.ts +7 -0
- package/plugins/runtime-modules/cdn/client-data-providers.js +9 -0
- package/plugins/runtime-modules/cdn/data-providers.d.ts +134 -0
- package/plugins/runtime-modules/cdn/data-providers.js +117 -0
- package/plugins/runtime-modules/cdn/definition.d.ts +140 -0
- package/plugins/runtime-modules/cdn/definition.js +23 -0
- package/plugins/runtime-modules/cdn/ids.d.ts +18 -0
- package/plugins/runtime-modules/cdn/ids.js +20 -0
- package/plugins/runtime-modules/cdn/module.d.ts +131 -0
- package/plugins/runtime-modules/cdn/module.js +4 -0
- package/plugins/runtime-modules/cdn/platform.d.ts +25 -0
- package/plugins/runtime-modules/cdn/platform.js +73 -0
- package/plugins/runtime-modules/cdn/presets.d.ts +2 -0
- package/plugins/runtime-modules/cdn/presets.js +20 -0
- package/plugins/runtime-modules/cdn/server.d.ts +1 -0
- package/plugins/runtime-modules/cdn/server.js +14 -0
- package/plugins/runtime-modules/cdn/services/table.d.ts +11 -0
- package/plugins/runtime-modules/cdn/services/table.js +296 -0
- package/plugins/runtime-modules/cdn/services/upload.d.ts +20 -0
- package/plugins/runtime-modules/cdn/services/upload.js +146 -0
- package/plugins/runtime-modules/cdn/table-params.d.ts +10 -0
- package/plugins/runtime-modules/cdn/table-params.js +10 -0
- package/plugins/runtime-modules/cdn/trees/admin-cdn-label-set.d.ts +95 -0
- package/plugins/runtime-modules/cdn/trees/admin-cdn-label-set.js +156 -0
- package/plugins/runtime-modules/cdn/trees/phi-default-admin-cdn-page-tree.d.ts +18 -0
- package/plugins/runtime-modules/cdn/trees/phi-default-admin-cdn-page-tree.js +479 -0
- package/plugins/runtime-modules/cdn/widgets/upload/client.d.ts +12 -0
- package/plugins/runtime-modules/cdn/widgets/upload/client.js +138 -0
- package/plugins/runtime-modules/cdn/widgets/upload/config.d.ts +29 -0
- package/plugins/runtime-modules/cdn/widgets/upload/config.js +43 -0
- package/plugins/runtime-modules/cdn/widgets/upload/label-types.d.ts +24 -0
- package/plugins/runtime-modules/cdn/widgets/upload/label-types.js +1 -0
- package/plugins/runtime-modules/cdn/widgets/upload/labels.d.ts +4 -0
- package/plugins/runtime-modules/cdn/widgets/upload/labels.js +72 -0
- package/plugins/runtime-modules/cdn/widgets/upload/plugin.d.ts +3 -0
- package/plugins/runtime-modules/cdn/widgets/upload/plugin.js +7 -0
- package/plugins/runtime-modules/cdn/widgets/upload/server.d.ts +8 -0
- package/plugins/runtime-modules/cdn/widgets/upload/server.js +17 -0
- package/plugins/runtime-modules/cdn/widgets.d.ts +2 -0
- package/plugins/runtime-modules/cdn/widgets.js +13 -0
- package/plugins/runtime-modules/client-authoring-providers/admin.d.ts +1 -1
- package/plugins/runtime-modules/client-authoring-providers/admin.js +6 -0
- package/plugins/runtime-modules/client-manifests/admin.js +11 -1
- package/plugins/runtime-modules/client-manifests/common.js +6 -0
- package/plugins/runtime-modules/core/widgets/card/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +1 -1
- package/plugins/runtime-modules/core/widgets/collection-view/client.js +5 -2
- package/plugins/runtime-modules/core/widgets/collection-view/config.js +8 -0
- package/plugins/runtime-modules/core/widgets/collection-view/site-address-binding.d.ts +55 -0
- package/plugins/runtime-modules/core/widgets/collection-view/site-address-binding.js +175 -0
- package/plugins/runtime-modules/core/widgets/collection-view/site-address-tiles.d.ts +48 -0
- package/plugins/runtime-modules/core/widgets/collection-view/site-address-tiles.js +67 -0
- package/plugins/runtime-modules/core/widgets/command-toolbar/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/description/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/float-button/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/form/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/form/config.js +14 -1
- package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/record/client.js +2 -6
- package/plugins/runtime-modules/core/widgets/result/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/table/client.js +36 -52
- package/plugins/runtime-modules/core/widgets/table/config.d.ts +3 -3
- package/plugins/runtime-modules/core/widgets/table/config.js +3 -0
- package/plugins/runtime-modules/core/widgets/thread-conversation/client.js +2 -2
- package/plugins/runtime-modules/core/widgets/thread-conversation/config.d.ts +6 -2
- package/plugins/runtime-modules/core/widgets/thread-conversation/config.js +6 -1
- package/plugins/runtime-modules/core/widgets/thread-widget-config.d.ts +10 -0
- package/plugins/runtime-modules/core/widgets/thread-widget-config.js +6 -0
- package/plugins/runtime-modules/core/widgets/tree/client.js +6 -6
- package/plugins/runtime-modules/localization/trees/editor-translations-widget-label-set.d.ts +2 -0
- package/plugins/runtime-modules/localization/trees/editor-translations-widget-label-set.js +2 -0
- package/plugins/runtime-modules/localization/trees/phi-default-editor-translations-page-tree.js +5 -0
- package/plugins/runtime-modules/revisions/controller/binding.d.ts +37 -0
- package/plugins/runtime-modules/revisions/controller/binding.js +75 -0
- package/plugins/runtime-modules/revisions/controller/client.d.ts +5 -0
- package/plugins/runtime-modules/revisions/controller/client.js +74 -50
- package/plugins/runtime-modules/revisions/controller/definition.d.ts +5 -0
- package/plugins/runtime-modules/revisions/controller/definition.js +10 -0
- package/plugins/runtime-modules/revisions/forms.js +1 -1
- package/plugins/runtime-modules/revisions/page-ids.d.ts +1 -1
- package/plugins/runtime-modules/revisions/page-ids.js +4 -1
- package/plugins/runtime-modules/revisions/services/options.js +14 -4
- package/plugins/runtime-modules/revisions/services/table.js +41 -21
- package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +76 -3
- package/plugins/runtime-modules/theme/controller/runtime.js +14 -2
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +39 -13
- package/plugins/runtime-modules/threads/client-data-providers.js +5 -0
- package/plugins/runtime-modules/threads/controller/client.js +62 -2
- package/plugins/runtime-modules/threads/controller/definition.js +48 -0
- package/plugins/runtime-modules/threads/data-providers.d.ts +22 -37
- package/plugins/runtime-modules/threads/data-providers.js +35 -24
- package/plugins/runtime-modules/threads/definition.d.ts +22 -37
- package/plugins/runtime-modules/threads/ids.d.ts +2 -0
- package/plugins/runtime-modules/threads/ids.js +2 -0
- package/plugins/runtime-modules/threads/services/customer-file-addresses.d.ts +30 -0
- package/plugins/runtime-modules/threads/services/customer-file-addresses.js +59 -0
- package/plugins/runtime-modules/threads/services/customer-file-read.d.ts +22 -0
- package/plugins/runtime-modules/threads/services/customer-file-read.js +101 -0
- package/plugins/runtime-modules/threads/services/customer-file-table.d.ts +14 -80
- package/plugins/runtime-modules/threads/services/customer-file-table.js +27 -112
- package/plugins/runtime-modules/user-management/trees/admin-users-access-label-set.d.ts +4 -0
- package/plugins/runtime-modules/user-management/trees/admin-users-access-label-set.js +4 -0
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-access-page-tree.js +15 -0
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +5 -0
- package/server-helpers/runtime.js +0 -1
- package/styles/controls.css +4 -2
- package/styles/layout.css +7 -0
- package/theme/phi-antd-token-resolver.d.ts +8 -0
- package/theme/phi-antd-token-resolver.js +10 -0
- package/theme/phi-theme-color.d.ts +19 -0
- package/theme/phi-theme-color.js +42 -0
- package/theme/phi-theme-gradients.js +4 -22
- package/theme/phi-theme-palette-defaults.d.ts +16 -0
- package/theme/phi-theme-palette-defaults.js +103 -0
- package/types/cms-plugins.d.ts +6 -1
- package/types/collection-provider.d.ts +27 -0
- package/types/collection-signal-values.d.ts +2 -0
- package/types/collection-signal-values.js +23 -0
- package/types/collection-view-widget.d.ts +9 -0
- package/types/core-widget-placements.d.ts +6 -0
- package/types/signals.d.ts +2 -0
- package/types/signals.js +2 -0
- package/types/table-widget.d.ts +17 -3
- package/types/table-widget.js +0 -282
- package/types/tree-widget.d.ts +0 -1
- package/types/tree-widget.js +0 -60
- package/types/widget-runtime.d.ts +0 -1
- package/types.d.ts +1 -1
- package/types.js +1 -1
- package/plugins/runtime-modules/app/services/addresses-table.d.ts +0 -135
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { checkPhiFormDescriptorFields } from "../components/forms/form-descriptor-field-check";
|
|
2
|
+
/**
|
|
3
|
+
* Every Form a package ships, held to the rules its fields' Controls read them by
|
|
4
|
+
* (`checkPhiFormDescriptorFields`: a money field's currency and `currencyField`, a flags field's bits),
|
|
5
|
+
* as findings whose `node` is the Form id (THIRD_PARTY_MODULES.md, "Checking a Page preset").
|
|
6
|
+
*
|
|
7
|
+
* Verify-time only, from `@phis/ui/module/page-check`: a package runs it in its own tests over its Form
|
|
8
|
+
* definitions (`definePhiRuntimeModuleForm`), as phis-ui runs it over its own, and a Site never loads it.
|
|
9
|
+
*/
|
|
10
|
+
export function checkPhiPresetForms(forms) {
|
|
11
|
+
return [...forms].flatMap((form) => checkPhiFormDescriptorFields(form.descriptor).map((message) => ({ node: form.formId, message })));
|
|
12
|
+
}
|
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
import type { PhiResolvedCmsPageTree } from "../types/cms";
|
|
2
|
-
import { type PhiTableProviderResourceDescriptor } from "../types/table-widget";
|
|
3
2
|
import type { PhiPresetTreeContractFinding } from "./preset-tree-contract-check";
|
|
4
3
|
import type { PhiRuntimeModuleDefinition } from "../types/cms-plugins";
|
|
4
|
+
import { type PhiBindingCheckProvider } from "./widget-binding-check";
|
|
5
5
|
/**
|
|
6
|
-
* Every
|
|
7
|
-
* (THIRD_PARTY_MODULES.md, "Checking a Page preset")
|
|
8
|
-
* (`
|
|
6
|
+
* Every bound Widget of a preset tree -- Table, Tree and record Widget -- read against the resource its
|
|
7
|
+
* Provider declares (THIRD_PARTY_MODULES.md, "Checking a Page preset"), by the same check the Builder's
|
|
8
|
+
* save runs (`checkPhiWidgetBinding`): a Table's columns, filters, sorting, counted footer and actions
|
|
9
|
+
* (`validatePhiTableWidgetBinding`) and every icon its actions and binding tools name
|
|
10
|
+
* (`isPhiIconNameKnown`), a Tree's node fields, tools, actions and drag and drop
|
|
11
|
+
* (`validatePhiTreeWidgetBinding`), a record Widget's actions (`validatePhiRecordWidgetBinding`). And one
|
|
12
|
+
* rule of the house: a Table that shows its header row ends in its footer (`presentation.footer`, the
|
|
13
|
+
* count or paging line), and a Table without a header -- one that only lays out rows or aligns columns --
|
|
14
|
+
* needs none (TABLES.md, "Footer and summary"); the rare Table with a header and nothing to count says why
|
|
15
|
+
* in `footerOmitted`. New Pages kept leaving the footer out, and nothing but a reader missing the count
|
|
16
|
+
* noticed.
|
|
9
17
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* in its own tests over every tree its presets build, beside
|
|
13
|
-
*
|
|
18
|
+
* Nothing in the browser checks a binding (owner, 2026-11-24): a live Widget trusts the config it is
|
|
19
|
+
* handed, so a binding that does not hold is a Widget that draws the wrong thing, and this check is where
|
|
20
|
+
* it is caught. A package runs it in its own tests over every tree its presets build, beside
|
|
21
|
+
* `checkPhiPresetTreeContract`, with every data Provider it ships (`dataProviders`: its Module's Provider
|
|
22
|
+
* descriptors, Table and Tree alike). A Widget on a Provider not handed over is not judged.
|
|
14
23
|
*
|
|
15
24
|
* Verify-time only, and apart from the contract check on purpose: that one also runs while a Site serves
|
|
16
|
-
* a Page,
|
|
25
|
+
* a Page, which must not pay for checks that belong where the config is made.
|
|
17
26
|
*/
|
|
18
27
|
export declare function checkPhiPresetTables(tree: PhiResolvedCmsPageTree, options: {
|
|
19
|
-
dataProviders: Iterable<
|
|
28
|
+
dataProviders: Iterable<PhiBindingCheckProvider>;
|
|
20
29
|
}): PhiPresetTreeContractFinding[];
|
|
21
|
-
/** A Table Provider as a package declares it: its key and the resources a Table binds to. */
|
|
22
|
-
export type PresetTreeTableProvider = {
|
|
23
|
-
key: string;
|
|
24
|
-
resources?: readonly PhiTableProviderResourceDescriptor[];
|
|
25
|
-
};
|
|
26
30
|
/**
|
|
27
31
|
* Every Table a Module offers to Markdown (TABLES.md, "Tables in Markdown"), checked as a Preset's Table is
|
|
28
32
|
* above: its columns against its resource, and what makes it an embed -- no editor; pinned filters and
|
|
@@ -1,58 +1,52 @@
|
|
|
1
1
|
import { PhiCmsWidgetType } from "../constants/cms-widget-types";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { validatePhiTableWidgetBinding } from "./table-widget-binding";
|
|
3
|
+
import { checkPhiWidgetBinding } from "./widget-binding-check";
|
|
4
4
|
/**
|
|
5
|
-
* Every
|
|
6
|
-
* (THIRD_PARTY_MODULES.md, "Checking a Page preset")
|
|
7
|
-
* (`
|
|
5
|
+
* Every bound Widget of a preset tree -- Table, Tree and record Widget -- read against the resource its
|
|
6
|
+
* Provider declares (THIRD_PARTY_MODULES.md, "Checking a Page preset"), by the same check the Builder's
|
|
7
|
+
* save runs (`checkPhiWidgetBinding`): a Table's columns, filters, sorting, counted footer and actions
|
|
8
|
+
* (`validatePhiTableWidgetBinding`) and every icon its actions and binding tools name
|
|
9
|
+
* (`isPhiIconNameKnown`), a Tree's node fields, tools, actions and drag and drop
|
|
10
|
+
* (`validatePhiTreeWidgetBinding`), a record Widget's actions (`validatePhiRecordWidgetBinding`). And one
|
|
11
|
+
* rule of the house: a Table that shows its header row ends in its footer (`presentation.footer`, the
|
|
12
|
+
* count or paging line), and a Table without a header -- one that only lays out rows or aligns columns --
|
|
13
|
+
* needs none (TABLES.md, "Footer and summary"); the rare Table with a header and nothing to count says why
|
|
14
|
+
* in `footerOmitted`. New Pages kept leaving the footer out, and nothing but a reader missing the count
|
|
15
|
+
* noticed.
|
|
8
16
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* in its own tests over every tree its presets build, beside
|
|
12
|
-
*
|
|
17
|
+
* Nothing in the browser checks a binding (owner, 2026-11-24): a live Widget trusts the config it is
|
|
18
|
+
* handed, so a binding that does not hold is a Widget that draws the wrong thing, and this check is where
|
|
19
|
+
* it is caught. A package runs it in its own tests over every tree its presets build, beside
|
|
20
|
+
* `checkPhiPresetTreeContract`, with every data Provider it ships (`dataProviders`: its Module's Provider
|
|
21
|
+
* descriptors, Table and Tree alike). A Widget on a Provider not handed over is not judged.
|
|
13
22
|
*
|
|
14
23
|
* Verify-time only, and apart from the contract check on purpose: that one also runs while a Site serves
|
|
15
|
-
* a Page,
|
|
24
|
+
* a Page, which must not pay for checks that belong where the config is made.
|
|
16
25
|
*/
|
|
17
26
|
export function checkPhiPresetTables(tree, options) {
|
|
18
27
|
const findings = [];
|
|
19
|
-
|
|
20
|
-
return findings;
|
|
21
|
-
}
|
|
22
|
-
function checkTables(tree, dataProviders, report) {
|
|
23
|
-
const providers = new Map([...dataProviders].map((provider) => [provider.key, provider]));
|
|
28
|
+
const providers = new Map([...options.dataProviders].map((provider) => [provider.key, provider]));
|
|
24
29
|
for (const widget of tree.contentWidgets) {
|
|
30
|
+
// The config as the preset wrote it, which is what the Widget receives: a preset states the whole shape.
|
|
31
|
+
const bindingFindings = checkPhiWidgetBinding(widget.widgetType, widget.config, providers);
|
|
32
|
+
for (const message of bindingFindings)
|
|
33
|
+
findings.push({ node: widget.id, message });
|
|
25
34
|
if (widget.widgetType !== PhiCmsWidgetType.Table)
|
|
26
35
|
continue;
|
|
27
|
-
// The config as the preset wrote it, which is what the Table receives: a preset states the whole shape.
|
|
28
36
|
const config = widget.config;
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
if (!
|
|
32
|
-
continue;
|
|
33
|
-
const resource = provider.resources?.find((candidate) => candidate.resourceKey === source.resourceKey);
|
|
34
|
-
if (!resource) {
|
|
35
|
-
report(widget.id, `Table is bound to resource "${source.resourceKey}", which "${provider.key}" does not declare.`);
|
|
37
|
+
const provider = config.source?.providerKey ? providers.get(config.source.providerKey) : undefined;
|
|
38
|
+
const declared = provider?.resources?.some((candidate) => candidate.resourceKey === config.source?.resourceKey);
|
|
39
|
+
if (!declared)
|
|
36
40
|
continue;
|
|
41
|
+
const footerOmitted = config.presentation?.footerOmitted?.trim();
|
|
42
|
+
if (config.presentation?.footer && footerOmitted) {
|
|
43
|
+
findings.push({ node: widget.id, message: "Table states a footer and `footerOmitted` beside it; a reason for leaving the footer out is for a Table without one." });
|
|
37
44
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const actions = [
|
|
41
|
-
...(config.features?.actions?.toolbar ?? []),
|
|
42
|
-
...(config.features?.actions?.row ?? []),
|
|
43
|
-
...(config.features?.actions?.bulk ?? []),
|
|
44
|
-
];
|
|
45
|
-
for (const action of actions) {
|
|
46
|
-
if (action.display !== "label" && action.icon && !isPhiIconNameKnown(action.icon.trim())) {
|
|
47
|
-
report(widget.id, `Table action "${action.key}" names the icon "${action.icon}", which PhiIcon does not know.`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
for (const tool of config.features?.tools?.bindingFields ?? []) {
|
|
51
|
-
if (tool.create?.display !== "label" && tool.create?.icon && !isPhiIconNameKnown(tool.create.icon.trim())) {
|
|
52
|
-
report(widget.id, `Table binding field "${tool.key}" names the create icon "${tool.create.icon}", which PhiIcon does not know.`);
|
|
53
|
-
}
|
|
45
|
+
else if (config.presentation?.header !== false && !config.presentation?.footer && !footerOmitted) {
|
|
46
|
+
findings.push({ node: widget.id, message: "Table shows a header and no footer: a Table with a header row ends in `presentation.footer` (TABLES.md, \"Footer and summary\"); one that only lays out rows says `header: false`, and one with a header and nothing to count says why in `footerOmitted`." });
|
|
54
47
|
}
|
|
55
48
|
}
|
|
49
|
+
return findings;
|
|
56
50
|
}
|
|
57
51
|
const hasStaticOptions = (field) => (field.options?.length ?? 0) > 0 && !field.optionsProvider;
|
|
58
52
|
/**
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PhiRecordWidgetConfig } from "../types/record-widget";
|
|
2
|
+
import type { PhiTableProviderResourceDescriptor } from "../types/table-widget";
|
|
3
|
+
/**
|
|
4
|
+
* What the record Widget's actions ask of its resource, as findings --
|
|
5
|
+
* the Table's binding check (`validatePhiTableWidgetBinding`) for the one scope a record has. Each action
|
|
6
|
+
* is the resource's, of scope `row`, named once, and drawn as the danger a destructive one is. A
|
|
7
|
+
* confirmation the resource requires is not asked for here: the record on screen, named in the dialog's
|
|
8
|
+
* title, and the press beside it are that confirmation, and a `confirm` would ask a second time.
|
|
9
|
+
*/
|
|
10
|
+
export declare function validatePhiRecordWidgetBinding(config: Partial<Pick<PhiRecordWidgetConfig, "actions">>, resource: Pick<PhiTableProviderResourceDescriptor, "resourceKey" | "actions">): string[];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Checked where a config is made, as the Table's binding is (`helpers/table-widget-binding.ts`): a
|
|
3
|
+
* package's preset tests (`checkPhiPresetTables`), `pnpm verify` and the Builder's save, never in the
|
|
4
|
+
* browser, so the record Widget's live Client trusts its actions.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* What the record Widget's actions ask of its resource, as findings --
|
|
8
|
+
* the Table's binding check (`validatePhiTableWidgetBinding`) for the one scope a record has. Each action
|
|
9
|
+
* is the resource's, of scope `row`, named once, and drawn as the danger a destructive one is. A
|
|
10
|
+
* confirmation the resource requires is not asked for here: the record on screen, named in the dialog's
|
|
11
|
+
* title, and the press beside it are that confirmation, and a `confirm` would ask a second time.
|
|
12
|
+
*/
|
|
13
|
+
export function validatePhiRecordWidgetBinding(config, resource) {
|
|
14
|
+
const errors = [];
|
|
15
|
+
const declared = new Map(resource.actions?.map((action) => [action.key, action]) ?? []);
|
|
16
|
+
const seen = new Set();
|
|
17
|
+
for (const action of config.actions ?? []) {
|
|
18
|
+
if (seen.has(action.key)) {
|
|
19
|
+
errors.push(`Record action "${action.key}" is configured more than once.`);
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
seen.add(action.key);
|
|
23
|
+
const capability = declared.get(action.key);
|
|
24
|
+
if (!capability) {
|
|
25
|
+
errors.push(`Record action "${action.key}" is not declared by resource "${resource.resourceKey}".`);
|
|
26
|
+
}
|
|
27
|
+
else if (capability.scope !== "row") {
|
|
28
|
+
errors.push(`Record action "${action.key}" cannot run on a record: its scope is "${capability.scope}".`);
|
|
29
|
+
}
|
|
30
|
+
else if (capability.intent === "destructive" && action.mode !== "danger") {
|
|
31
|
+
errors.push(`Destructive Record action "${action.key}" requires danger presentation.`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return errors;
|
|
35
|
+
}
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { PhiTableProviderResourceDescriptor } from "../types/table-widget";
|
|
1
|
+
import type { PhiRecordWidgetTitleFromRecord } from "../types/record-widget";
|
|
3
2
|
/**
|
|
4
3
|
* The placement's `titleFromRecord`, or null where it states none. Strict, as the Form's: no field, or a
|
|
5
4
|
* sentence without exactly one `%1`, is refused rather than read as no title.
|
|
6
5
|
*/
|
|
7
6
|
export declare function readPhiRecordWidgetTitleFromRecord(value: unknown): PhiRecordWidgetTitleFromRecord | null;
|
|
8
|
-
/**
|
|
9
|
-
* What the record Widget's actions ask of its resource, as the errors it shows instead of the record --
|
|
10
|
-
* the Table's binding check (`validatePhiTableWidgetBinding`) for the one scope a record has. Each action
|
|
11
|
-
* is the resource's, of scope `row`, named once, and drawn as the danger a destructive one is. A
|
|
12
|
-
* confirmation the resource requires is not asked for here: the record on screen, named in the dialog's
|
|
13
|
-
* title, and the press beside it are that confirmation, and a `confirm` would ask a second time.
|
|
14
|
-
*/
|
|
15
|
-
export declare function validatePhiRecordWidgetBinding(config: Pick<PhiRecordWidgetConfig, "actions">, resource: Pick<PhiTableProviderResourceDescriptor, "resourceKey" | "actions">): string[];
|
package/helpers/record-widget.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { isPhiRecord } from "./is-record";
|
|
2
2
|
import { checkPhiRecordTitleTemplate } from "./record-title";
|
|
3
3
|
/*
|
|
4
|
-
* The record Widget's
|
|
5
|
-
* record
|
|
6
|
-
*
|
|
4
|
+
* The record Widget's reader that the descriptor compiler and the Widget share: its title from the
|
|
5
|
+
* record (TABLES.md, "The record Widget"). Apart from `types/record-widget.ts`, so the type stays a type
|
|
6
|
+
* for everything that only names it. Its actions against the resource are checked where a config is
|
|
7
|
+
* made (`helpers/record-widget-binding.ts`), not here.
|
|
7
8
|
*/
|
|
8
9
|
/**
|
|
9
10
|
* The placement's `titleFromRecord`, or null where it states none. Strict, as the Form's: no field, or a
|
|
@@ -25,33 +26,3 @@ export function readPhiRecordWidgetTitleFromRecord(value) {
|
|
|
25
26
|
throw new Error(`Record titleFromRecord.template ${templateError}`);
|
|
26
27
|
return { template, field };
|
|
27
28
|
}
|
|
28
|
-
/**
|
|
29
|
-
* What the record Widget's actions ask of its resource, as the errors it shows instead of the record --
|
|
30
|
-
* the Table's binding check (`validatePhiTableWidgetBinding`) for the one scope a record has. Each action
|
|
31
|
-
* is the resource's, of scope `row`, named once, and drawn as the danger a destructive one is. A
|
|
32
|
-
* confirmation the resource requires is not asked for here: the record on screen, named in the dialog's
|
|
33
|
-
* title, and the press beside it are that confirmation, and a `confirm` would ask a second time.
|
|
34
|
-
*/
|
|
35
|
-
export function validatePhiRecordWidgetBinding(config, resource) {
|
|
36
|
-
const errors = [];
|
|
37
|
-
const declared = new Map(resource.actions?.map((action) => [action.key, action]) ?? []);
|
|
38
|
-
const seen = new Set();
|
|
39
|
-
for (const action of config.actions) {
|
|
40
|
-
if (seen.has(action.key)) {
|
|
41
|
-
errors.push(`Record action "${action.key}" is configured more than once.`);
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
seen.add(action.key);
|
|
45
|
-
const capability = declared.get(action.key);
|
|
46
|
-
if (!capability) {
|
|
47
|
-
errors.push(`Record action "${action.key}" is not declared by resource "${resource.resourceKey}".`);
|
|
48
|
-
}
|
|
49
|
-
else if (capability.scope !== "row") {
|
|
50
|
-
errors.push(`Record action "${action.key}" cannot run on a record: its scope is "${capability.scope}".`);
|
|
51
|
-
}
|
|
52
|
-
else if (capability.intent === "destructive" && action.mode !== "danger") {
|
|
53
|
-
errors.push(`Destructive Record action "${action.key}" requires danger presentation.`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return errors;
|
|
57
|
-
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PhiTableProviderResourceDescriptor, PhiTableWidgetConfig } from "../types/table-widget";
|
|
2
|
+
/**
|
|
3
|
+
* A Table's config against the resource its Provider declares: columns, filters, sorting, the counted
|
|
4
|
+
* footer, every Provider action in its scope with the confirmation and danger the resource asks for
|
|
5
|
+
* (TABLES.md, "Checked where it is made").
|
|
6
|
+
*
|
|
7
|
+
* Checked where a config is made -- a package's preset tests (`checkPhiPresetTables`), `pnpm verify`, the
|
|
8
|
+
* Builder's save (`gateway/site-cms-write-validation.ts`) -- and never in the browser or the render of a
|
|
9
|
+
* request: a live Table trusts the config it is handed, and this file is kept out of every live Client
|
|
10
|
+
* graph for that reason.
|
|
11
|
+
*/
|
|
12
|
+
export declare function validatePhiTableWidgetBinding(config: PhiTableWidgetConfig, resource: PhiTableProviderResourceDescriptor): string[];
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Table's config against the resource its Provider declares: columns, filters, sorting, the counted
|
|
3
|
+
* footer, every Provider action in its scope with the confirmation and danger the resource asks for
|
|
4
|
+
* (TABLES.md, "Checked where it is made").
|
|
5
|
+
*
|
|
6
|
+
* Checked where a config is made -- a package's preset tests (`checkPhiPresetTables`), `pnpm verify`, the
|
|
7
|
+
* Builder's save (`gateway/site-cms-write-validation.ts`) -- and never in the browser or the render of a
|
|
8
|
+
* request: a live Table trusts the config it is handed, and this file is kept out of every live Client
|
|
9
|
+
* graph for that reason.
|
|
10
|
+
*/
|
|
11
|
+
export function validatePhiTableWidgetBinding(config, resource) {
|
|
12
|
+
const errors = [];
|
|
13
|
+
/*
|
|
14
|
+
* A count shown needs a count given. The rows of one page are not the query's, so a Table that says
|
|
15
|
+
* how many there are, or how many pages, is bound to a resource that counts -- or one that does not
|
|
16
|
+
* page and so answers every row at once (`query.total`).
|
|
17
|
+
*/
|
|
18
|
+
const resourceCounts = resource.query.total === true ||
|
|
19
|
+
(resource.query.pagination !== "offset" && resource.query.pagination !== "cursor");
|
|
20
|
+
if (!resourceCounts) {
|
|
21
|
+
const footer = config.presentation.footer;
|
|
22
|
+
const shownSources = [
|
|
23
|
+
...(footer?.values ?? []).map((item) => item.value),
|
|
24
|
+
...(footer?.variants ?? []).flatMap((variant) => [variant.when.value, ...(variant.values ?? []).map((item) => item.value)]),
|
|
25
|
+
...(config.presentation.summary?.rows ?? []).flatMap((row) => row.cells.map((cell) => cell.item.value)),
|
|
26
|
+
];
|
|
27
|
+
const counted = shownSources.find((source) => source.source === "core" && (source.fieldKey === "totalRows" || source.fieldKey === "pageCount"));
|
|
28
|
+
if (counted) {
|
|
29
|
+
errors.push(`Table shows "${counted.fieldKey}", but resource "${resource.resourceKey}" pages without a count ` +
|
|
30
|
+
"(declare query.total on a resource that answers total).");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const fields = new Set(resource.fields.map((field) => field.key));
|
|
34
|
+
const fieldsByKey = new Map(resource.fields.map((field) => [field.key, field]));
|
|
35
|
+
const columns = config.presentation.columns;
|
|
36
|
+
const columnKeys = new Set();
|
|
37
|
+
for (const column of columns) {
|
|
38
|
+
if (!column.key.trim() || columnKeys.has(column.key)) {
|
|
39
|
+
errors.push("Table columns require unique non-empty keys.");
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
columnKeys.add(column.key);
|
|
43
|
+
if (!column.fieldKey.trim() || !fields.has(column.fieldKey)) {
|
|
44
|
+
errors.push(`Table column "${column.key}" references undeclared field "${column.fieldKey}".`);
|
|
45
|
+
}
|
|
46
|
+
if (column.sortable && !fields.has(column.sortField ?? column.fieldKey)) {
|
|
47
|
+
errors.push(`Table column "${column.key}" references an undeclared sort field.`);
|
|
48
|
+
}
|
|
49
|
+
const field = fieldsByKey.get(column.fieldKey);
|
|
50
|
+
if (column.editor && !field?.mutable) {
|
|
51
|
+
errors.push(`Table column "${column.key}" cannot edit read-only field "${column.fieldKey}".`);
|
|
52
|
+
}
|
|
53
|
+
if (column.titleDisplay === "icon" && !column.titleIcon) {
|
|
54
|
+
errors.push(`Table column "${column.key}" hides its title without a title icon.`);
|
|
55
|
+
}
|
|
56
|
+
if (column.iconFieldKey !== undefined) {
|
|
57
|
+
const iconField = fieldsByKey.get(column.iconFieldKey);
|
|
58
|
+
if (!iconField) {
|
|
59
|
+
errors.push(`Table column "${column.key}" references undeclared icon field "${column.iconFieldKey}".`);
|
|
60
|
+
}
|
|
61
|
+
else if (iconField.type !== "icon") {
|
|
62
|
+
errors.push(`Table column "${column.key}" icon field "${column.iconFieldKey}" must be an icon field.`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (column.imageFieldKey !== undefined) {
|
|
66
|
+
const imageField = fieldsByKey.get(column.imageFieldKey);
|
|
67
|
+
if (!imageField) {
|
|
68
|
+
errors.push(`Table column "${column.key}" references undeclared image field "${column.imageFieldKey}".`);
|
|
69
|
+
}
|
|
70
|
+
else if (imageField.type !== "string") {
|
|
71
|
+
errors.push(`Table column "${column.key}" image field "${column.imageFieldKey}" must be a string field.`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (column.editor && field?.type === "json") {
|
|
75
|
+
errors.push(`Table column "${column.key}" cannot use an implicit JSON editor.`);
|
|
76
|
+
}
|
|
77
|
+
const editorControlCompatible = !column.editor?.control ||
|
|
78
|
+
(field?.type === "boolean" && (column.editor.control === "switch" || column.editor.control === "checkbox")) ||
|
|
79
|
+
(field?.type === "icon" && column.editor.control === "icon-picker") ||
|
|
80
|
+
(field?.type === "enum" && (column.editor.control === "select" || column.editor.control === "radio" ||
|
|
81
|
+
column.editor.control === "segmented")) ||
|
|
82
|
+
// A string chosen from a list: the row's options, or the placement's own (`editor.options`).
|
|
83
|
+
(field?.type === "string" && (Boolean(field.rowOptionsPath) || column.editor.options !== undefined) &&
|
|
84
|
+
column.editor.control === "select") ||
|
|
85
|
+
(field?.type === "string" && column.editor.control === "textarea") ||
|
|
86
|
+
(field?.type === "enum[]" && (column.editor.control === "multi-select" ||
|
|
87
|
+
column.editor.control === "checkbox-group"));
|
|
88
|
+
if (column.editor && !editorControlCompatible) {
|
|
89
|
+
errors.push(`Table column "${column.key}" editor is incompatible with field "${column.fieldKey}".`);
|
|
90
|
+
}
|
|
91
|
+
const rendererCompatible = !column.renderer || column.renderer === "text" ||
|
|
92
|
+
(column.renderer === "switch" && field?.type === "boolean") ||
|
|
93
|
+
(column.renderer === "checkbox" && field?.type === "boolean") ||
|
|
94
|
+
(column.renderer === "icon" && field?.type === "icon") ||
|
|
95
|
+
(column.renderer === "image" && field?.type === "string") ||
|
|
96
|
+
((column.renderer === "date" || column.renderer === "datetime") && field?.type === column.renderer) ||
|
|
97
|
+
(column.renderer === "json" && field?.type === "json") ||
|
|
98
|
+
(column.renderer === "tags" && (field?.type === "json" || field?.type === "enum[]")) ||
|
|
99
|
+
((column.renderer === "money" || column.renderer === "interval") && field?.type === "json") ||
|
|
100
|
+
((column.renderer === "email" || column.renderer === "link" || column.renderer === "code" ||
|
|
101
|
+
column.renderer === "badge") && (field?.type === "string" || field?.type === "enum"));
|
|
102
|
+
if (!rendererCompatible) {
|
|
103
|
+
errors.push(`Table column "${column.key}" renderer is incompatible with field "${column.fieldKey}".`);
|
|
104
|
+
}
|
|
105
|
+
if (config.presentation.layout.mode === "fixed" && column.sizing?.mode === "content") {
|
|
106
|
+
errors.push(`Table column "${column.key}" cannot use content sizing with fixed Table layout.`);
|
|
107
|
+
}
|
|
108
|
+
if (!column.hidden && column.sticky && config.presentation.layout.overflowX !== "auto") {
|
|
109
|
+
errors.push(`Sticky Table column "${column.key}" requires automatic horizontal overflow.`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const summaryFields = new Set(resource.summaryFields?.map((field) => field.key) ?? []);
|
|
113
|
+
const validateSummaryItem = (item, owner) => {
|
|
114
|
+
if (!item.key.trim())
|
|
115
|
+
errors.push(`${owner} requires a non-empty item key.`);
|
|
116
|
+
if (item.value.source === "provider" && !summaryFields.has(item.value.fieldKey)) {
|
|
117
|
+
errors.push(`${owner} references undeclared Provider summary field "${item.value.fieldKey}".`);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const footerValueKeys = new Set();
|
|
121
|
+
const footer = config.presentation.footer;
|
|
122
|
+
for (const binding of footer?.values ?? []) {
|
|
123
|
+
if (footerValueKeys.has(binding.key))
|
|
124
|
+
errors.push("Table footer value keys must be unique.");
|
|
125
|
+
footerValueKeys.add(binding.key);
|
|
126
|
+
validateSummaryItem({ key: binding.key, value: binding.value }, `Table footer value "${binding.key}"`);
|
|
127
|
+
}
|
|
128
|
+
if (footer) {
|
|
129
|
+
const placeholderIndexes = new Set([...footer.template.matchAll(/%([1-9]\d*)/g)].map((match) => Number(match[1])));
|
|
130
|
+
// A sentence of its own is a footer too (the reader and PhiTableFooterVariant allow `values: []`):
|
|
131
|
+
// only its placeholders and its values must match.
|
|
132
|
+
if (!footer.template.trim() ||
|
|
133
|
+
footer.values.some((_value, index) => !placeholderIndexes.has(index + 1)) ||
|
|
134
|
+
[...placeholderIndexes].some((index) => index > footer.values.length)) {
|
|
135
|
+
errors.push("Table footer template placeholders must match its ordered values.");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const summaryRowKeys = new Set();
|
|
139
|
+
for (const row of config.presentation.summary?.rows ?? []) {
|
|
140
|
+
if (!row.key.trim() || summaryRowKeys.has(row.key)) {
|
|
141
|
+
errors.push("Table summary rows require unique non-empty keys.");
|
|
142
|
+
}
|
|
143
|
+
summaryRowKeys.add(row.key);
|
|
144
|
+
const cellKeys = new Set();
|
|
145
|
+
const occupiedColumns = new Set();
|
|
146
|
+
for (const cell of row.cells) {
|
|
147
|
+
if (!cell.key.trim() || cellKeys.has(cell.key)) {
|
|
148
|
+
errors.push(`Table summary row "${row.key}" requires unique non-empty cell keys.`);
|
|
149
|
+
}
|
|
150
|
+
cellKeys.add(cell.key);
|
|
151
|
+
if (!columnKeys.has(cell.columnKey) || cell.throughColumnKey && !columnKeys.has(cell.throughColumnKey)) {
|
|
152
|
+
errors.push(`Table summary cell "${cell.key}" references an undeclared column.`);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
const start = columns.findIndex((column) => column.key === cell.columnKey);
|
|
156
|
+
const end = cell.throughColumnKey
|
|
157
|
+
? columns.findIndex((column) => column.key === cell.throughColumnKey)
|
|
158
|
+
: start;
|
|
159
|
+
if (end < start) {
|
|
160
|
+
errors.push(`Table summary cell "${cell.key}" has a backwards column span.`);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
for (const column of columns.slice(start, end + 1)) {
|
|
164
|
+
if (occupiedColumns.has(column.key)) {
|
|
165
|
+
errors.push(`Table summary row "${row.key}" contains overlapping cells.`);
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
occupiedColumns.add(column.key);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
validateSummaryItem(cell.item, `Table summary cell "${cell.key}"`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (config.presentation.layout.mode === "fixed" &&
|
|
176
|
+
columns.every((column) => column.hidden || (column.sizing?.mode ?? "content") !== "fill")) {
|
|
177
|
+
errors.push("Fixed Table layout requires at least one visible fill column.");
|
|
178
|
+
}
|
|
179
|
+
if (config.presentation.layout.mode !== "fixed" && columns.some((column) => column.ellipsis)) {
|
|
180
|
+
errors.push("Ellipsis requires fixed Table layout.");
|
|
181
|
+
}
|
|
182
|
+
const sortingMode = config.features.sorting?.mode ?? "none";
|
|
183
|
+
const providerSorting = resource.query.sorting ?? "none";
|
|
184
|
+
if (sortingMode !== "none" && providerSorting === "none") {
|
|
185
|
+
errors.push(`Table resource "${resource.resourceKey}" does not support sorting.`);
|
|
186
|
+
}
|
|
187
|
+
else if (sortingMode === "multiple" && providerSorting !== "multiple") {
|
|
188
|
+
errors.push(`Table resource "${resource.resourceKey}" does not support multiple sorting.`);
|
|
189
|
+
}
|
|
190
|
+
if (config.features.search?.enabled && resource.query.search !== true) {
|
|
191
|
+
errors.push(`Table resource "${resource.resourceKey}" does not support search.`);
|
|
192
|
+
}
|
|
193
|
+
if (config.features.pagination?.enabled !== false && resource.query.pagination === "none") {
|
|
194
|
+
errors.push(`Table resource "${resource.resourceKey}" does not support pagination.`);
|
|
195
|
+
}
|
|
196
|
+
for (const sort of config.features.sorting?.defaultSorts ?? []) {
|
|
197
|
+
if (!fields.has(sort.key))
|
|
198
|
+
errors.push(`Table default sort "${sort.key}" is not declared by the resource.`);
|
|
199
|
+
}
|
|
200
|
+
const filterFields = new Set(resource.query.filterFields ?? []);
|
|
201
|
+
for (const filter of config.features.filters ?? []) {
|
|
202
|
+
const keys = filter.type === "dateRange" ? [filter.startKey, filter.endKey] : [filter.key];
|
|
203
|
+
for (const key of keys) {
|
|
204
|
+
if (!filterFields.has(key))
|
|
205
|
+
errors.push(`Table filter "${key}" is not declared by the resource.`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const structure = config.features.structure;
|
|
209
|
+
if (structure?.mode === "tree" &&
|
|
210
|
+
resource.hierarchy?.parentRowIdentityPath !== structure.parentRowIdentityPath) {
|
|
211
|
+
errors.push(`Table resource "${resource.resourceKey}" does not declare the selected hierarchy.`);
|
|
212
|
+
}
|
|
213
|
+
if (structure?.mode === "tree" && !columns.some((column) => column.key === structure.expandColumnKey && !column.hidden)) {
|
|
214
|
+
errors.push(`Table tree expand column "${structure.expandColumnKey}" is not a visible configured column.`);
|
|
215
|
+
}
|
|
216
|
+
if (resource.hierarchy?.canAcceptChildrenField) {
|
|
217
|
+
const acceptanceField = fieldsByKey.get(resource.hierarchy.canAcceptChildrenField);
|
|
218
|
+
if (acceptanceField?.type !== "boolean") {
|
|
219
|
+
errors.push(`Table resource "${resource.resourceKey}" child-acceptance field must be a declared boolean field.`);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (config.features.editing?.mode === "none" && columns.some((column) => column.editor)) {
|
|
223
|
+
errors.push("Editable Table columns require cell editing mode.");
|
|
224
|
+
}
|
|
225
|
+
if (config.features.rowReordering?.enabled) {
|
|
226
|
+
const requiredOrdering = structure?.mode === "tree" ? "tree" : "flat";
|
|
227
|
+
if (resource.rowOrdering !== requiredOrdering) {
|
|
228
|
+
errors.push(`Table resource "${resource.resourceKey}" does not support ${requiredOrdering} row ordering.`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
const providerActions = new Map(resource.actions?.map((action) => [action.key, action]) ?? []);
|
|
232
|
+
const bindingFields = new Map(resource.bindingFields?.map((field) => [field.key, field]) ?? []);
|
|
233
|
+
const configuredBindingKeys = new Set();
|
|
234
|
+
for (const bindingTool of config.features.tools?.bindingFields ?? []) {
|
|
235
|
+
if (configuredBindingKeys.has(bindingTool.key)) {
|
|
236
|
+
errors.push(`Table binding field "${bindingTool.key}" is configured more than once.`);
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
configuredBindingKeys.add(bindingTool.key);
|
|
240
|
+
const bindingField = bindingFields.get(bindingTool.key);
|
|
241
|
+
if (!bindingField) {
|
|
242
|
+
errors.push(`Table binding field "${bindingTool.key}" is not declared by resource "${resource.resourceKey}".`);
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
if (bindingField.create) {
|
|
246
|
+
const action = providerActions.get(bindingField.create.actionKey);
|
|
247
|
+
if (!action || action.scope !== "resource" || action.valueType !== "string") {
|
|
248
|
+
errors.push(`Table binding field "${bindingTool.key}" create action must be a declared string-valued resource action.`);
|
|
249
|
+
}
|
|
250
|
+
if (!bindingTool.create)
|
|
251
|
+
errors.push(`Table binding field "${bindingTool.key}" needs Widget create-tool presentation.`);
|
|
252
|
+
else if (!bindingTool.create.display) {
|
|
253
|
+
errors.push(`Table binding field "${bindingTool.key}" create tool requires explicit display presentation.`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
else if (bindingTool.create) {
|
|
257
|
+
errors.push(`Table binding field "${bindingTool.key}" configures create presentation without a Provider create capability.`);
|
|
258
|
+
}
|
|
259
|
+
if (bindingTool.create && (bindingTool.create.display === "icon" || bindingTool.create.display === "icon-label") &&
|
|
260
|
+
!bindingTool.create.icon?.trim()) {
|
|
261
|
+
errors.push(`Table binding field "${bindingTool.key}" create tool needs an icon for display "${bindingTool.create.display}".`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
for (const [scope, actions] of [
|
|
265
|
+
["resource", config.features.actions?.toolbar ?? []],
|
|
266
|
+
["row", config.features.actions?.row ?? []],
|
|
267
|
+
["selection", config.features.actions?.bulk ?? []],
|
|
268
|
+
]) {
|
|
269
|
+
for (const action of actions) {
|
|
270
|
+
if (!action.display) {
|
|
271
|
+
errors.push(`Table action "${action.key}" requires explicit display presentation.`);
|
|
272
|
+
}
|
|
273
|
+
if ((action.display === "icon" || action.display === "icon-label") && !action.icon?.trim()) {
|
|
274
|
+
errors.push(`Table action "${action.key}" needs an icon for display "${action.display}".`);
|
|
275
|
+
}
|
|
276
|
+
if (action.execution !== "provider")
|
|
277
|
+
continue;
|
|
278
|
+
const capability = providerActions.get(action.key);
|
|
279
|
+
if (!capability) {
|
|
280
|
+
errors.push(`Table action "${action.key}" is not declared by resource "${resource.resourceKey}".`);
|
|
281
|
+
}
|
|
282
|
+
else if (capability.scope !== scope) {
|
|
283
|
+
errors.push(`Table action "${action.key}" cannot be placed in the ${scope} action scope.`);
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
if (capability.confirmation === "required" && !action.confirm?.title.trim()) {
|
|
287
|
+
errors.push(`Table action "${action.key}" requires Widget confirmation presentation.`);
|
|
288
|
+
}
|
|
289
|
+
if (capability.intent === "destructive" && action.mode !== "danger") {
|
|
290
|
+
errors.push(`Destructive Table action "${action.key}" requires danger presentation.`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return errors;
|
|
296
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PhiTreeProviderResourceDescriptor, PhiTreeWidgetConfig } from "../types/tree-widget";
|
|
2
|
+
/**
|
|
3
|
+
* The parts of a Tree's config its binding reads. A preset states its config as the Tree reads it and
|
|
4
|
+
* may leave out what it does not use, so every part is optional here; a parsed config is one too.
|
|
5
|
+
*/
|
|
6
|
+
export type PhiTreeWidgetBindingConfig = {
|
|
7
|
+
presentation?: Partial<Pick<PhiTreeWidgetConfig["presentation"], "node">>;
|
|
8
|
+
features?: Partial<PhiTreeWidgetConfig["features"]>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A Tree's config against the resource its Provider declares: the node fields it shows and edits, its
|
|
12
|
+
* binding tools, search, every Provider action in its scope with the confirmation the resource asks for,
|
|
13
|
+
* and drag and drop (TREES.md).
|
|
14
|
+
*
|
|
15
|
+
* Checked where a config is made, as the Table's is (`helpers/table-widget-binding.ts`): a package's
|
|
16
|
+
* preset tests (`checkPhiPresetTables`), `pnpm verify` and the Builder's save, never in the browser or
|
|
17
|
+
* the render of a request. A live Tree trusts the config it is handed.
|
|
18
|
+
*/
|
|
19
|
+
export declare function validatePhiTreeWidgetBinding(config: PhiTreeWidgetBindingConfig, resource: PhiTreeProviderResourceDescriptor): string[];
|