@phis/ui 0.7.8 → 0.8.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/components/controls/phi-address-control.d.ts +23 -0
- package/components/controls/phi-address-control.js +43 -0
- package/components/controls/phi-color-control.d.ts +3 -1
- package/components/controls/phi-color-control.js +2 -2
- package/components/controls/phi-country-select-control.d.ts +22 -0
- package/components/controls/phi-country-select-control.js +16 -0
- package/components/controls/phi-dialog-control.d.ts +1 -1
- package/components/controls/phi-drawer-control-adapter.d.ts +1 -1
- package/components/controls/phi-drawer-control-adapter.js +5 -3
- package/components/controls/phi-drawer-control.d.ts +7 -5
- package/components/controls/phi-float-button-control.d.ts +8 -1
- package/components/controls/phi-float-button-control.js +19 -3
- package/components/controls/phi-form-control.js +52 -8
- package/components/controls/phi-modal-control-adapter.d.ts +1 -1
- package/components/controls/phi-modal-control-adapter.js +14 -37
- package/components/controls/phi-modal-control.d.ts +5 -5
- package/components/controls/phi-options-provider.d.ts +1 -0
- package/components/controls/phi-options-provider.js +1 -0
- package/components/controls/phi-overlay-control-contract.d.ts +52 -17
- package/components/controls/phi-overlay-control-contract.js +55 -30
- package/components/controls/phi-reveal-once-dialog-control.d.ts +21 -0
- package/components/controls/phi-reveal-once-dialog-control.js +52 -0
- package/components/controls/phi-reveal-once-dialog-labels.d.ts +10 -0
- package/components/controls/phi-reveal-once-dialog-labels.js +5 -0
- package/components/forms/flags-field.d.ts +22 -0
- package/components/forms/flags-field.js +58 -0
- package/components/forms/form-option-flags.d.ts +20 -0
- package/components/forms/form-option-flags.js +38 -0
- package/components/forms/form-provider-contract.d.ts +23 -0
- package/components/forms/form-provider-contract.js +36 -0
- package/components/forms/form-provider-registry.d.ts +5 -1
- package/components/forms/shared-form-provider-registry.js +13 -0
- package/components/forms/structured-field-labels.d.ts +24 -0
- package/components/forms/structured-field-labels.js +43 -0
- package/components/forms/structured-form-field-controls.d.ts +12 -0
- package/components/forms/structured-form-field-controls.js +65 -0
- package/components/overlays/phi-overlay-container-client.js +2 -2
- package/components/regions/phi-cms-region-shell.js +2 -2
- package/components/regions/presets/content-entry-editor-page-tree.js +12 -3
- package/components/regions/presets/phi-settings-page-shell-tree.d.ts +6 -2
- package/components/regions/presets/phi-settings-page-shell-tree.js +1 -1
- package/components/root/phi-root-theme-resolver.js +3 -0
- package/components/shell/phi-antd-icon.d.ts +1 -8
- package/components/shell/phi-antd-icon.js +1 -227
- package/components/shell/phi-icon-names.d.ts +19 -0
- package/components/shell/phi-icon-names.js +264 -0
- package/components/shell/phi-icon.d.ts +2 -11
- package/components/shell/phi-icon.js +4 -32
- package/components/widgets/client/shared/phi-command-buttons.d.ts +13 -2
- package/components/widgets/client/shared/phi-command-buttons.js +10 -4
- package/components/widgets/client/shared/phi-rendered-value.js +27 -3
- package/components/widgets/client/shared/phi-table-provider-refusal.d.ts +13 -0
- package/components/widgets/client/shared/phi-table-provider-refusal.js +13 -0
- package/components/widgets/config/background.d.ts +3 -2
- package/components/widgets/config/choice-shared.d.ts +10 -1
- package/components/widgets/config/choice-shared.js +8 -2
- package/components/widgets/label-sets/admin-locales.js +1 -1
- package/components/widgets/label-sets/admin-users.d.ts +2 -5
- package/components/widgets/label-sets/admin-users.js +4 -10
- package/components/widgets/label-sets/effects.js +2 -4
- package/components/widgets/label-sets/profile.d.ts +13 -0
- package/components/widgets/label-sets/profile.js +28 -0
- package/components/widgets/label-sets/search-results.js +2 -4
- package/components/widgets/label-sets/table.js +9 -0
- package/components/widgets/label-types/effects.d.ts +3 -2
- package/components/widgets/label-types/effects.js +1 -2
- package/components/widgets/label-types/search-results.d.ts +2 -2
- package/components/widgets/label-types/search-results.js +1 -2
- package/components/widgets/label-types/table.d.ts +3 -0
- package/components/widgets/label-types/table.js +2 -0
- package/components/widgets/server/builder-chrome.d.ts +4 -1
- package/components/widgets/server/builder-chrome.js +2 -2
- package/components/widgets/shared/markdown-body-client.d.ts +26 -0
- package/components/widgets/shared/markdown-body-client.js +31 -1
- package/components/widgets/shared/markdown-render.d.ts +10 -2
- package/components/widgets/shared/markdown-render.js +35 -13
- package/constants/countries.d.ts +9 -0
- package/constants/countries.js +28 -0
- package/constants/customer-file.d.ts +25 -0
- package/constants/customer-file.js +26 -0
- package/constants/record-field-kinds.d.ts +15 -0
- package/constants/record-field-kinds.js +13 -0
- package/constants/runtime-module-ownership.js +12 -0
- package/constants/runtime-render-client-types.d.ts +5 -0
- package/constants/runtime-render-client-types.js +5 -0
- package/{plugins/runtime-modules/threads/controller/address.js → constants/threads-controller-address.js} +1 -1
- package/constants.d.ts +1 -0
- package/constants.js +2 -0
- package/gateway/form-handler-request.d.ts +22 -0
- package/gateway/form-handler-request.js +40 -0
- package/gateway/label-set.d.ts +15 -2
- package/gateway/label-set.js +60 -22
- package/gateway/site-form-route.js +11 -2
- package/helpers/address-field.d.ts +43 -0
- package/helpers/address-field.js +68 -0
- package/helpers/cms-dialog.d.ts +5 -20
- package/helpers/cms-dialog.js +8 -13
- package/helpers/cms-page-catalog.d.ts +10 -0
- package/helpers/cms-page-catalog.js +19 -0
- package/helpers/cms-preset-nodes.d.ts +4 -4
- package/helpers/cms-preset-nodes.js +1 -1
- package/helpers/cms-region-keys.d.ts +1 -1
- package/helpers/country-names.d.ts +12 -0
- package/helpers/country-names.js +14 -0
- package/helpers/phi-metadata.d.ts +33 -1
- package/helpers/phi-metadata.js +62 -1
- package/helpers/preset-table-check.d.ts +34 -0
- package/helpers/preset-table-check.js +124 -0
- package/helpers/preset-text-source-check.d.ts +4 -1
- package/helpers/preset-text-source-check.js +6 -1
- package/helpers/preset-tree-contract-check.d.ts +3 -2
- package/helpers/preset-tree-contract-check.js +30 -5
- package/helpers/public-route-claims.d.ts +9 -1
- package/helpers/public-route-claims.js +23 -3
- package/helpers/record-fields.d.ts +1 -5
- package/helpers/record-fields.js +15 -6
- package/helpers/route-address-check.d.ts +22 -2
- package/helpers/route-address-check.js +29 -8
- package/helpers/site-address-row.d.ts +23 -0
- package/helpers/site-address-row.js +36 -0
- package/helpers/surface-style.d.ts +8 -1
- package/helpers/surface-style.js +12 -2
- package/helpers/thread-inbox-row.d.ts +20 -0
- package/helpers/thread-inbox-row.js +26 -0
- package/helpers/translation-format.d.ts +26 -0
- package/helpers/translation-format.js +31 -0
- package/module-labels.d.ts +1 -1
- package/module-labels.js +1 -1
- package/module-page-check.d.ts +1 -0
- package/module-page-check.js +1 -0
- package/module-records.d.ts +2 -2
- package/module-records.js +1 -0
- package/next/area-route.js +34 -1
- package/next/root-route.js +4 -5
- package/package.json +2 -2
- package/plugins/runtime-modules/accounting/customer-file-access.d.ts +11 -0
- package/plugins/runtime-modules/accounting/customer-file-access.js +12 -0
- package/plugins/runtime-modules/accounting/data-providers.js +1 -1
- package/plugins/runtime-modules/accounting/ids.d.ts +11 -0
- package/plugins/runtime-modules/accounting/ids.js +23 -0
- package/plugins/runtime-modules/accounting/presets.js +32 -5
- package/plugins/runtime-modules/accounting/trees/accounting-customer-file-label-set.d.ts +66 -0
- package/plugins/runtime-modules/accounting/trees/accounting-customer-file-label-set.js +122 -0
- package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.js +2 -2
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-customer-file-page-tree.d.ts +26 -0
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-customer-file-page-tree.js +381 -0
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.js +4 -0
- package/plugins/runtime-modules/app/client-data-providers.d.ts +7 -0
- package/plugins/runtime-modules/app/client-data-providers.js +9 -0
- package/plugins/runtime-modules/app/data-providers.d.ts +98 -0
- package/plugins/runtime-modules/app/data-providers.js +80 -0
- package/plugins/runtime-modules/app/definition.d.ts +131 -0
- package/plugins/runtime-modules/app/definition.js +2 -0
- package/plugins/runtime-modules/app/forms.d.ts +46 -1
- package/plugins/runtime-modules/app/forms.js +195 -1
- package/plugins/runtime-modules/app/ids.d.ts +7 -0
- package/plugins/runtime-modules/app/ids.js +8 -0
- package/plugins/runtime-modules/app/module.d.ts +131 -0
- package/plugins/runtime-modules/app/services/addresses-table.d.ts +135 -0
- package/plugins/runtime-modules/app/services/addresses-table.js +101 -0
- package/plugins/runtime-modules/app/trees/account-addresses-panel.d.ts +17 -0
- package/plugins/runtime-modules/app/trees/account-addresses-panel.js +179 -0
- package/plugins/runtime-modules/app/trees/addresses-label-set.d.ts +62 -0
- package/plugins/runtime-modules/app/trees/addresses-label-set.js +108 -0
- package/plugins/runtime-modules/app/trees/phi-default-app-profile-page-tree.js +27 -2
- package/plugins/runtime-modules/app/trees/profile-label-set.d.ts +1 -0
- package/plugins/runtime-modules/app/trees/profile-label-set.js +3 -0
- package/plugins/runtime-modules/asset/presets.d.ts +4 -0
- package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +4 -2
- package/plugins/runtime-modules/auth/trees/phi-auth-area-overlay-tree.server.js +4 -2
- package/plugins/runtime-modules/auth/trees/phi-default-admin-auth-settings-page-tree.js +2 -2
- package/plugins/runtime-modules/auth/widgets/logout/client.d.ts +1 -1
- package/plugins/runtime-modules/auth/widgets/logout/client.js +2 -2
- package/plugins/runtime-modules/auth/widgets/security/client.d.ts +5 -1
- package/plugins/runtime-modules/auth/widgets/security/client.js +12 -10
- package/plugins/runtime-modules/avatar/overlay-tree.server.js +1 -1
- package/plugins/runtime-modules/blog/presets.d.ts +4 -0
- package/plugins/runtime-modules/builder/clients/inspector-image-field.d.ts +2 -1
- package/plugins/runtime-modules/builder/clients/inspector-image-field.js +3 -2
- package/plugins/runtime-modules/builder/clients/metadata-table-provider-stand-ins.d.ts +23 -0
- package/plugins/runtime-modules/builder/clients/metadata-table-provider-stand-ins.js +38 -0
- package/plugins/runtime-modules/builder/clients/mode-switch.d.ts +4 -1
- package/plugins/runtime-modules/builder/clients/mode-switch.js +2 -15
- package/plugins/runtime-modules/builder/clients/pages-workspace.js +2 -0
- package/plugins/runtime-modules/builder/clients/runtime-module-authoring-boundary.js +2 -1
- package/plugins/runtime-modules/builder/controller/draft-status-controller.js +28 -1
- package/plugins/runtime-modules/builder/developer-workspace-types.d.ts +5 -0
- package/plugins/runtime-modules/builder/page-presets.server.d.ts +7 -0
- package/plugins/runtime-modules/builder/page-presets.server.js +10 -1
- package/plugins/runtime-modules/builder/persistence.js +4 -0
- package/plugins/runtime-modules/builder/public-route-collisions.js +8 -3
- package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +3 -1
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +33 -6
- package/plugins/runtime-modules/builder/widgets/chrome/config.d.ts +6 -4
- package/plugins/runtime-modules/builder/widgets/chrome/config.js +11 -1
- package/plugins/runtime-modules/builder/widgets/inspector-header/authoring.d.ts +2 -2
- package/plugins/runtime-modules/builder/widgets/inspector-header/plugin.d.ts +2 -2
- package/plugins/runtime-modules/builder/widgets/mode-switch/plugin.js +1 -1
- package/plugins/runtime-modules/builder/widgets/structure-region/built-in.js +2 -2
- package/plugins/runtime-modules/client-manifests/app.js +3 -0
- package/plugins/runtime-modules/client-manifests/builder.js +10 -0
- package/plugins/runtime-modules/content-entry-routes.d.ts +4 -0
- package/plugins/runtime-modules/contracts.js +31 -1
- package/plugins/runtime-modules/core/definition.d.ts +23 -0
- package/plugins/runtime-modules/core/form-providers.d.ts +23 -0
- package/plugins/runtime-modules/core/messaging/thread-inbox-table.d.ts +0 -17
- package/plugins/runtime-modules/core/messaging/thread-inbox-table.js +2 -23
- package/plugins/runtime-modules/core/widgets/card/config.d.ts +0 -1
- package/plugins/runtime-modules/core/widgets/card/config.js +0 -1
- package/plugins/runtime-modules/core/widgets/card/editor.js +1 -1
- package/plugins/runtime-modules/core/widgets/command-toolbar/client.js +3 -0
- package/plugins/runtime-modules/core/widgets/command-toolbar/config.d.ts +316 -1
- package/plugins/runtime-modules/core/widgets/command-toolbar/config.js +4 -4
- package/plugins/runtime-modules/core/widgets/dimension/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/float-button/client.js +4 -1
- package/plugins/runtime-modules/core/widgets/float-button/config.d.ts +326 -3
- package/plugins/runtime-modules/core/widgets/float-button/config.js +5 -2
- package/plugins/runtime-modules/core/widgets/header-navigation/client.js +1 -1
- package/plugins/runtime-modules/core/widgets/length/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/markdown/plugin.js +20 -7
- package/plugins/runtime-modules/core/widgets/markdown/server.d.ts +6 -2
- package/plugins/runtime-modules/core/widgets/markdown/server.js +2 -2
- package/plugins/runtime-modules/core/widgets/markdown/table-embeds.server.d.ts +12 -0
- package/plugins/runtime-modules/core/widgets/markdown/table-embeds.server.js +68 -0
- package/plugins/runtime-modules/core/widgets/number-input/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/simple-text/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/simple-text/plugin.js +2 -1
- package/plugins/runtime-modules/core/widgets/table/client.js +20 -5
- package/plugins/runtime-modules/core/widgets/table/config.js +6 -0
- package/plugins/runtime-modules/core/widgets/table/reader-query.d.ts +17 -0
- package/plugins/runtime-modules/core/widgets/table/reader-query.js +33 -0
- package/plugins/runtime-modules/dashboard/trees/dashboard-cards-page-tree.js +3 -1
- package/plugins/runtime-modules/descriptor-compiler.d.ts +19 -3
- package/plugins/runtime-modules/descriptor-compiler.js +44 -16
- package/plugins/runtime-modules/editor/presets.d.ts +4 -0
- package/plugins/runtime-modules/editor/trees/phi-default-editor-releases-page-tree.js +3 -1
- package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +5 -1
- package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +5 -1
- package/plugins/runtime-modules/localization/presets.d.ts +4 -0
- package/plugins/runtime-modules/localization/trees/phi-default-admin-locales-page-tree.js +3 -1
- package/plugins/runtime-modules/localization/trees/phi-default-editor-translations-page-tree.js +4 -2
- package/plugins/runtime-modules/news/presets.d.ts +4 -0
- package/plugins/runtime-modules/observability/trees/phi-default-admin-logs-page-tree.js +6 -2
- package/plugins/runtime-modules/resolver.js +17 -0
- package/plugins/runtime-modules/revisions/controller/client.js +13 -11
- package/plugins/runtime-modules/revisions/controller/draft-context-target.d.ts +25 -0
- package/plugins/runtime-modules/revisions/controller/draft-context-target.js +33 -0
- package/plugins/runtime-modules/revisions/presets.d.ts +4 -0
- package/plugins/runtime-modules/revisions/services/table.js +13 -4
- package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +3 -1
- package/plugins/runtime-modules/search/widgets/search-results/client.js +4 -2
- package/plugins/runtime-modules/theme/presets.d.ts +4 -0
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +76 -4
- package/plugins/runtime-modules/theme/widgets/brand-controls/config.d.ts +3 -2
- package/plugins/runtime-modules/theme/widgets/brand-controls/config.js +2 -2
- package/plugins/runtime-modules/theme/widgets/brand-controls/plugin.js +19 -7
- package/plugins/runtime-modules/threads/client-data-providers.js +5 -0
- package/plugins/runtime-modules/threads/controller/definition.js +1 -1
- package/plugins/runtime-modules/threads/data-providers.d.ts +115 -2
- package/plugins/runtime-modules/threads/data-providers.js +85 -0
- package/plugins/runtime-modules/threads/definition.d.ts +115 -2
- package/plugins/runtime-modules/threads/definition.js +1 -1
- package/plugins/runtime-modules/threads/ids.d.ts +2 -0
- package/plugins/runtime-modules/threads/ids.js +3 -0
- package/plugins/runtime-modules/threads/services/customer-file-table.d.ts +192 -0
- package/plugins/runtime-modules/threads/services/customer-file-table.js +164 -0
- package/plugins/runtime-modules/threads/trees/phi-default-threads-page-tree.js +5 -3
- package/plugins/runtime-modules/user-management/client-data-providers.js +5 -0
- package/plugins/runtime-modules/user-management/data-providers.d.ts +159 -0
- package/plugins/runtime-modules/user-management/data-providers.js +101 -3
- package/plugins/runtime-modules/user-management/definition.d.ts +159 -0
- package/plugins/runtime-modules/user-management/ids.d.ts +9 -0
- package/plugins/runtime-modules/user-management/ids.js +9 -0
- package/plugins/runtime-modules/user-management/presets.js +17 -1
- package/plugins/runtime-modules/user-management/services/users-access-table.d.ts +378 -0
- package/plugins/runtime-modules/user-management/services/users-access-table.js +132 -0
- package/plugins/runtime-modules/user-management/trees/admin-users-access-label-set.d.ts +86 -0
- package/plugins/runtime-modules/user-management/trees/admin-users-access-label-set.js +118 -0
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-access-page-tree.d.ts +20 -0
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-access-page-tree.js +166 -0
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +19 -18
- package/server-helpers/cms-page-record.d.ts +9 -1
- package/server-helpers/cms-page-record.js +11 -1
- package/server-helpers/cms-request.js +8 -5
- package/server-helpers/link-preview-image.d.ts +30 -0
- package/server-helpers/link-preview-image.js +57 -0
- package/server-helpers/search-text.js +3 -0
- package/server-helpers.d.ts +1 -1
- package/server-helpers.js +1 -1
- package/styles/shell.css +30 -6
- package/theme/phi-theme-composition.js +9 -0
- package/theme/phi-theme-inverse-ground.d.ts +39 -0
- package/theme/phi-theme-inverse-ground.js +103 -0
- package/theme/phi-theme-tokens.d.ts +2 -1
- package/theme/phi-theme-tokens.js +2 -0
- package/types/cms-module-descriptors.d.ts +14 -0
- package/types/cms-overlay.d.ts +13 -6
- package/types/cms-overlay.js +6 -22
- package/types/cms-plugins.d.ts +14 -2
- package/types/cms.d.ts +10 -0
- package/types/core-widget-placements.d.ts +3 -3
- package/types/link-preview.d.ts +19 -0
- package/types/link-preview.js +19 -0
- package/types/record-provider.d.ts +22 -1
- package/types/site-theme.d.ts +27 -0
- package/types/table-embed.d.ts +48 -0
- package/types/table-embed.js +1 -0
- package/types/table-widget.d.ts +14 -0
- package/types/widget-runtime.d.ts +3 -0
- package/types.d.ts +1 -0
- /package/{plugins/runtime-modules/threads/controller/address.d.ts → constants/threads-controller-address.d.ts} +0 -0
|
@@ -82,7 +82,7 @@ function createPhiCmsPresetNodeSet(defaults) {
|
|
|
82
82
|
config: { ...input.body?.config, ...PHI_DIALOG_BODY_CONFIG },
|
|
83
83
|
});
|
|
84
84
|
const form = input.body?.form;
|
|
85
|
-
const config = { width: form ? resolvePhiDialogFormWidth(form.descriptor) : PHI_DIALOG_WIDTH, ...input.config };
|
|
85
|
+
const config = { size: { width: form ? resolvePhiDialogFormWidth(form.descriptor) : PHI_DIALOG_WIDTH }, ...input.config };
|
|
86
86
|
const commands = input.commands;
|
|
87
87
|
if (!commands) {
|
|
88
88
|
return {
|
|
@@ -32,5 +32,5 @@ export type PhiCmsRegionOwnership = "shell" | "page";
|
|
|
32
32
|
* know is not a placement anybody chose -- refusing it would hide Widgets over a typo.
|
|
33
33
|
*/
|
|
34
34
|
export declare function phiCmsRegionAcceptsWidget(regionKey: string | null | undefined, required: PhiCmsRegionOwnership | null | undefined): boolean;
|
|
35
|
-
export declare function resolvePhiCmsRegionType(regionKey: string | null | undefined): 11 | 10 | 12 |
|
|
35
|
+
export declare function resolvePhiCmsRegionType(regionKey: string | null | undefined): 11 | 10 | 12 | 40 | 50 | 20 | 21 | 25 | 30 | 39 | 41;
|
|
36
36
|
export declare function resolvePhiCmsRegionKey(regionType: number | null | undefined): "content" | "header_top" | "header_main" | "header_bottom" | "sider_left" | "sider_right" | "hero" | "footer_top" | "footer_main" | "footer_bottom" | "drawer_right" | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type PhiCountryCode } from "../constants/countries";
|
|
2
|
+
export type PhiCountryOption = {
|
|
3
|
+
value: PhiCountryCode;
|
|
4
|
+
label: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Every ISO 3166-1 country as an option named in the reader's language (`Intl.DisplayNames`, type
|
|
8
|
+
* `region`), sorted as that language sorts. A code the runtime has no name for is shown as the code.
|
|
9
|
+
* The locale is the page's (`usePhiIntlLocale`), never the browser's, so the server and the browser draw
|
|
10
|
+
* the same list.
|
|
11
|
+
*/
|
|
12
|
+
export declare function listPhiCountryOptions(locale: string): PhiCountryOption[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PHI_ISO_3166_ALPHA2_CODES } from "../constants/countries";
|
|
2
|
+
/**
|
|
3
|
+
* Every ISO 3166-1 country as an option named in the reader's language (`Intl.DisplayNames`, type
|
|
4
|
+
* `region`), sorted as that language sorts. A code the runtime has no name for is shown as the code.
|
|
5
|
+
* The locale is the page's (`usePhiIntlLocale`), never the browser's, so the server and the browser draw
|
|
6
|
+
* the same list.
|
|
7
|
+
*/
|
|
8
|
+
export function listPhiCountryOptions(locale) {
|
|
9
|
+
const names = new Intl.DisplayNames([locale], { type: "region", fallback: "code" });
|
|
10
|
+
const collator = new Intl.Collator(locale);
|
|
11
|
+
return PHI_ISO_3166_ALPHA2_CODES
|
|
12
|
+
.map((code) => ({ value: code, label: names.of(code) ?? code }))
|
|
13
|
+
.sort((left, right) => collator.compare(left.label, right.label));
|
|
14
|
+
}
|
|
@@ -3,6 +3,36 @@ import type { PhiCmsAreaKey } from "../constants/cms-areas";
|
|
|
3
3
|
import { type PhiAreaMeta } from "./cms-area-config";
|
|
4
4
|
import type { PhiSignetHead } from "./phi-signet-head";
|
|
5
5
|
import { type PhiPublicPageAddress } from "./phi-seo";
|
|
6
|
+
/**
|
|
7
|
+
* What the head says of a Site that has said nothing: neither the Page's description nor the Theme's
|
|
8
|
+
* slogan. Worded as the placeholder it is, so a link shared before anybody replaced it tells the operator
|
|
9
|
+
* where to.
|
|
10
|
+
*/
|
|
11
|
+
export declare const PHI_DEFAULT_SITE_DESCRIPTION = "Default description of the phis starter. Set your own in the Page meta or as the Theme's slogan.";
|
|
12
|
+
/** The Site's description: the Theme's slogan, else the starter's placeholder. */
|
|
13
|
+
export declare function resolvePhiSiteDescription(slogan: string | null | undefined): string;
|
|
14
|
+
/** The picture of a link preview, resolved: its absolute address, its exact size and what it shows. */
|
|
15
|
+
export type PhiLinkPreviewImage = {
|
|
16
|
+
url: string;
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
alt: string;
|
|
20
|
+
type: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* What a Public Page's link preview is built from, beside the Page's own title and description
|
|
24
|
+
* (NEXT_INTEGRATION.md, "Link previews").
|
|
25
|
+
*/
|
|
26
|
+
export type PhiLinkPreviewInput = {
|
|
27
|
+
/** The record's preview title and description, where the Page is about a record whose Provider marks them. */
|
|
28
|
+
recordTitle?: string | null;
|
|
29
|
+
recordDescription?: string | null;
|
|
30
|
+
/** The Theme's slogan, the description where the Page states none. */
|
|
31
|
+
slogan?: string | null;
|
|
32
|
+
image?: PhiLinkPreviewImage | null;
|
|
33
|
+
/** `brand.xAccount`; stated as `twitter:site` only where it is an X account name. */
|
|
34
|
+
xAccount?: string | null;
|
|
35
|
+
};
|
|
6
36
|
export type PhiMetadataScope = {
|
|
7
37
|
title?: string | null;
|
|
8
38
|
description?: string | null;
|
|
@@ -49,7 +79,7 @@ export declare function buildPhiRootMetadata(options?: PhiRootMetadataInput): Me
|
|
|
49
79
|
* be indexed, because naming the preferred address of a Page that asks to stay out says nothing a
|
|
50
80
|
* search engine can use, and an hreflang set pointing at it contradicts the sitemap that leaves it out.
|
|
51
81
|
*/
|
|
52
|
-
export declare function buildPhiAreaPageMetadata({ area, meta, siteName, pageTitle, pageDescription, pageNoindex, publicAddress, }: {
|
|
82
|
+
export declare function buildPhiAreaPageMetadata({ area, meta, siteName, pageTitle, pageDescription, pageNoindex, publicAddress, linkPreview, }: {
|
|
53
83
|
area: PhiCmsAreaKey;
|
|
54
84
|
meta: PhiAreaMeta | null | undefined;
|
|
55
85
|
siteName?: string | null;
|
|
@@ -58,4 +88,6 @@ export declare function buildPhiAreaPageMetadata({ area, meta, siteName, pageTit
|
|
|
58
88
|
pageNoindex?: boolean | null;
|
|
59
89
|
/** Where this Page lives. Only Public has such an address; elsewhere it is ignored. */
|
|
60
90
|
publicAddress?: PhiPublicPageAddress | null;
|
|
91
|
+
/** What a link preview is built from; stated only for a Public Page with an address. */
|
|
92
|
+
linkPreview?: PhiLinkPreviewInput | null;
|
|
61
93
|
}): Metadata;
|
package/helpers/phi-metadata.js
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { PHI_AREA_META_PUBLIC_DEFAULTS, PHI_AREA_TITLE_TEMPLATE_PLACEHOLDER, } from "./cms-area-config";
|
|
2
2
|
import { buildPhiPublicPageAlternates } from "./phi-seo";
|
|
3
|
+
import { readPhiXAccount } from "../types/link-preview";
|
|
4
|
+
/**
|
|
5
|
+
* What the head says of a Site that has said nothing: neither the Page's description nor the Theme's
|
|
6
|
+
* slogan. Worded as the placeholder it is, so a link shared before anybody replaced it tells the operator
|
|
7
|
+
* where to.
|
|
8
|
+
*/
|
|
9
|
+
export const PHI_DEFAULT_SITE_DESCRIPTION = "Default description of the phis starter. Set your own in the Page meta or as the Theme's slogan.";
|
|
10
|
+
/** The Site's description: the Theme's slogan, else the starter's placeholder. */
|
|
11
|
+
export function resolvePhiSiteDescription(slogan) {
|
|
12
|
+
return slogan?.trim() || PHI_DEFAULT_SITE_DESCRIPTION;
|
|
13
|
+
}
|
|
14
|
+
/** A Site locale as Open Graph spells it: `pt-BR` is `pt_BR`. */
|
|
15
|
+
function toPhiOpenGraphLocale(locale) {
|
|
16
|
+
return locale.replaceAll("-", "_");
|
|
17
|
+
}
|
|
3
18
|
function resolveFirstText(...values) {
|
|
4
19
|
for (const value of values) {
|
|
5
20
|
const trimmed = value?.trim();
|
|
@@ -92,7 +107,7 @@ export function buildPhiRootMetadata(options = {}) {
|
|
|
92
107
|
* be indexed, because naming the preferred address of a Page that asks to stay out says nothing a
|
|
93
108
|
* search engine can use, and an hreflang set pointing at it contradicts the sitemap that leaves it out.
|
|
94
109
|
*/
|
|
95
|
-
export function buildPhiAreaPageMetadata({ area, meta, siteName, pageTitle, pageDescription, pageNoindex, publicAddress, }) {
|
|
110
|
+
export function buildPhiAreaPageMetadata({ area, meta, siteName, pageTitle, pageDescription, pageNoindex, publicAddress, linkPreview, }) {
|
|
96
111
|
const resolvedSiteName = resolveFirstText(siteName);
|
|
97
112
|
const resolvedPageTitle = resolveFirstText(pageTitle);
|
|
98
113
|
const template = resolveFirstText(meta?.titleTemplate);
|
|
@@ -114,10 +129,56 @@ export function buildPhiAreaPageMetadata({ area, meta, siteName, pageTitle, page
|
|
|
114
129
|
&& (meta?.index ?? PHI_AREA_META_PUBLIC_DEFAULTS.index)
|
|
115
130
|
&& pageNoindex !== true;
|
|
116
131
|
const alternates = indexable && publicAddress ? buildPhiPublicPageAlternates(publicAddress) : null;
|
|
132
|
+
const preview = area === "public" && publicAddress && linkPreview
|
|
133
|
+
? buildPhiLinkPreviewMetadata({
|
|
134
|
+
input: linkPreview,
|
|
135
|
+
address: publicAddress,
|
|
136
|
+
siteName: resolvedSiteName,
|
|
137
|
+
title: resolveFirstText(resolvedPageTitle, fallbackTitle),
|
|
138
|
+
description,
|
|
139
|
+
})
|
|
140
|
+
: null;
|
|
117
141
|
return {
|
|
118
142
|
...(title ? { title: { absolute: title } } : {}),
|
|
119
143
|
...(description ? { description } : {}),
|
|
120
144
|
...(indexable ? {} : { robots: { index: false, follow: false } }),
|
|
121
145
|
...(alternates ? { alternates: { canonical: alternates.canonical, languages: alternates.languages } } : {}),
|
|
146
|
+
...(preview ?? {}),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* The Open Graph and X tags of one Public Page (NEXT_INTEGRATION.md, "Link previews").
|
|
151
|
+
*
|
|
152
|
+
* Said of every Public Page, indexable or not: a link is shared whether or not a search engine may file
|
|
153
|
+
* it. The title is the Page's own, without the template the tab title wears -- the preview names the Site
|
|
154
|
+
* beside it as `og:site_name` -- and a record the Page is about may answer title and description first.
|
|
155
|
+
* The description falls back as the Root's does: the Theme's slogan, then the starter's placeholder. X
|
|
156
|
+
* reads the Open Graph tags; what this states for it is the card, large with a picture, and the Site's
|
|
157
|
+
* account where the Theme names one. Next copies title, description and picture into `twitter:*` itself.
|
|
158
|
+
*/
|
|
159
|
+
function buildPhiLinkPreviewMetadata({ input, address, siteName, title, description, }) {
|
|
160
|
+
const url = buildPhiPublicPageAlternates(address)?.canonical;
|
|
161
|
+
const image = input.image ?? null;
|
|
162
|
+
const xAccount = readPhiXAccount(input.xAccount);
|
|
163
|
+
const previewTitle = resolveFirstText(input.recordTitle, title, siteName);
|
|
164
|
+
return {
|
|
165
|
+
openGraph: {
|
|
166
|
+
type: "website",
|
|
167
|
+
...(siteName ? { siteName } : {}),
|
|
168
|
+
...(previewTitle ? { title: previewTitle } : {}),
|
|
169
|
+
description: resolveFirstText(input.recordDescription, description) ?? resolvePhiSiteDescription(input.slogan),
|
|
170
|
+
...(url ? { url } : {}),
|
|
171
|
+
locale: toPhiOpenGraphLocale(address.locale),
|
|
172
|
+
alternateLocale: address.availableLocales
|
|
173
|
+
.filter((code) => code !== address.locale)
|
|
174
|
+
.map(toPhiOpenGraphLocale),
|
|
175
|
+
...(image
|
|
176
|
+
? { images: [{ url: image.url, width: image.width, height: image.height, alt: image.alt, type: image.type }] }
|
|
177
|
+
: {}),
|
|
178
|
+
},
|
|
179
|
+
twitter: {
|
|
180
|
+
card: image ? "summary_large_image" : "summary",
|
|
181
|
+
...(xAccount ? { site: xAccount } : {}),
|
|
182
|
+
},
|
|
122
183
|
};
|
|
123
184
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { PhiResolvedCmsPageTree } from "../types/cms";
|
|
2
|
+
import { type PhiTableProviderResourceDescriptor } from "../types/table-widget";
|
|
3
|
+
import type { PhiPresetTreeContractFinding } from "./preset-tree-contract-check";
|
|
4
|
+
import type { PhiRuntimeModuleDefinition } from "../types/cms-plugins";
|
|
5
|
+
/**
|
|
6
|
+
* Every Table of a preset tree, read as the Table reads itself in the browser before its first request
|
|
7
|
+
* (THIRD_PARTY_MODULES.md, "Checking a Page preset"): its binding to its Provider's resource
|
|
8
|
+
* (`validatePhiTableWidgetBinding`) and every icon its actions and binding tools name (`isPhiIconNameKnown`).
|
|
9
|
+
*
|
|
10
|
+
* In the browser a finding leaves the Widget unavailable -- no table at all, only a console warning --
|
|
11
|
+
* while the Page around it renders, so nobody sees it until somebody misses the table. A package runs this
|
|
12
|
+
* in its own tests over every tree its presets build, beside `checkPhiPresetTreeContract`, with every Table
|
|
13
|
+
* Provider it ships. A Table on a Provider not handed over is not judged.
|
|
14
|
+
*
|
|
15
|
+
* Verify-time only, and apart from the contract check on purpose: that one also runs while a Site serves
|
|
16
|
+
* a Page, where an unavailable Table stays one Widget and must not become a 500 for the whole Page.
|
|
17
|
+
*/
|
|
18
|
+
export declare function checkPhiPresetTables(tree: PhiResolvedCmsPageTree, options: {
|
|
19
|
+
dataProviders: Iterable<PresetTreeTableProvider>;
|
|
20
|
+
}): 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
|
+
/**
|
|
27
|
+
* Every Table a Module offers to Markdown (TABLES.md, "Tables in Markdown"), checked as a Preset's Table is
|
|
28
|
+
* above: its columns against its resource, and what makes it an embed -- no editor; pinned filters and
|
|
29
|
+
* parameters naming a filter field or binding field of the resource, with values a parameter can check;
|
|
30
|
+
* `maxRows` on a resource that pages; each required binding field fixed or settable. The catalog refuses
|
|
31
|
+
* the key, Provider, resource and access policy itself; this half needs the Table's own code, so it runs
|
|
32
|
+
* where Preset Tables are checked: a package's tests, and `validate-module-descriptors` here.
|
|
33
|
+
*/
|
|
34
|
+
export declare function checkPhiEmbeddableTables(definition: Pick<PhiRuntimeModuleDefinition, "embeddableTables" | "dataProviders">): PhiPresetTreeContractFinding[];
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { PhiCmsWidgetType } from "../constants/cms-widget-types";
|
|
2
|
+
import { isPhiIconNameKnown } from "../components/shell/phi-icon-names";
|
|
3
|
+
import { validatePhiTableWidgetBinding, } from "../types/table-widget";
|
|
4
|
+
/**
|
|
5
|
+
* Every Table of a preset tree, read as the Table reads itself in the browser before its first request
|
|
6
|
+
* (THIRD_PARTY_MODULES.md, "Checking a Page preset"): its binding to its Provider's resource
|
|
7
|
+
* (`validatePhiTableWidgetBinding`) and every icon its actions and binding tools name (`isPhiIconNameKnown`).
|
|
8
|
+
*
|
|
9
|
+
* In the browser a finding leaves the Widget unavailable -- no table at all, only a console warning --
|
|
10
|
+
* while the Page around it renders, so nobody sees it until somebody misses the table. A package runs this
|
|
11
|
+
* in its own tests over every tree its presets build, beside `checkPhiPresetTreeContract`, with every Table
|
|
12
|
+
* Provider it ships. A Table on a Provider not handed over is not judged.
|
|
13
|
+
*
|
|
14
|
+
* Verify-time only, and apart from the contract check on purpose: that one also runs while a Site serves
|
|
15
|
+
* a Page, where an unavailable Table stays one Widget and must not become a 500 for the whole Page.
|
|
16
|
+
*/
|
|
17
|
+
export function checkPhiPresetTables(tree, options) {
|
|
18
|
+
const findings = [];
|
|
19
|
+
checkTables(tree, options.dataProviders, (node, message) => findings.push({ node, message }));
|
|
20
|
+
return findings;
|
|
21
|
+
}
|
|
22
|
+
function checkTables(tree, dataProviders, report) {
|
|
23
|
+
const providers = new Map([...dataProviders].map((provider) => [provider.key, provider]));
|
|
24
|
+
for (const widget of tree.contentWidgets) {
|
|
25
|
+
if (widget.widgetType !== PhiCmsWidgetType.Table)
|
|
26
|
+
continue;
|
|
27
|
+
// The config as the preset wrote it, which is what the Table receives: a preset states the whole shape.
|
|
28
|
+
const config = widget.config;
|
|
29
|
+
const source = config.source;
|
|
30
|
+
const provider = source?.providerKey ? providers.get(source.providerKey) : undefined;
|
|
31
|
+
if (!source || !provider)
|
|
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.`);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
for (const error of validatePhiTableWidgetBinding(config, resource))
|
|
39
|
+
report(widget.id, error);
|
|
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
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const hasStaticOptions = (field) => (field.options?.length ?? 0) > 0 && !field.optionsProvider;
|
|
58
|
+
/**
|
|
59
|
+
* Every Table a Module offers to Markdown (TABLES.md, "Tables in Markdown"), checked as a Preset's Table is
|
|
60
|
+
* above: its columns against its resource, and what makes it an embed -- no editor; pinned filters and
|
|
61
|
+
* parameters naming a filter field or binding field of the resource, with values a parameter can check;
|
|
62
|
+
* `maxRows` on a resource that pages; each required binding field fixed or settable. The catalog refuses
|
|
63
|
+
* the key, Provider, resource and access policy itself; this half needs the Table's own code, so it runs
|
|
64
|
+
* where Preset Tables are checked: a package's tests, and `validate-module-descriptors` here.
|
|
65
|
+
*/
|
|
66
|
+
export function checkPhiEmbeddableTables(definition) {
|
|
67
|
+
const findings = [];
|
|
68
|
+
for (const embed of definition.embeddableTables ?? []) {
|
|
69
|
+
const report = (message) => findings.push({ node: embed.key, message });
|
|
70
|
+
const provider = definition.dataProviders?.find((candidate) => candidate.key === embed.source.providerKey);
|
|
71
|
+
const resource = provider?.kind === "table"
|
|
72
|
+
? provider.resources.find((candidate) => candidate.resourceKey === embed.source.resourceKey)
|
|
73
|
+
: undefined;
|
|
74
|
+
if (!resource) {
|
|
75
|
+
report("reads a resource no table Provider of this Module declares.");
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const { query, bindingFields = [], fields } = resource;
|
|
79
|
+
const pager = embed.maxRows || query.pagination === "none" ? { pagination: { enabled: false } } : {};
|
|
80
|
+
const config = { presentation: embed.presentation, features: pager, source: embed.source };
|
|
81
|
+
validatePhiTableWidgetBinding(config, resource).forEach(report);
|
|
82
|
+
if (!embed.title?.trim())
|
|
83
|
+
report("needs a title.");
|
|
84
|
+
if (embed.presentation.columns.some((column) => column.editor))
|
|
85
|
+
report("has a column editor; an embedded Table is read-only.");
|
|
86
|
+
const filterFields = new Set(query.filterFields ?? []);
|
|
87
|
+
for (const key of Object.keys(embed.fixedFilters ?? {})) {
|
|
88
|
+
if (!filterFields.has(key))
|
|
89
|
+
report(`pins "${key}", which is no filter field of the resource.`);
|
|
90
|
+
}
|
|
91
|
+
if (embed.maxRows !== undefined && (!Number.isInteger(embed.maxRows) || embed.maxRows < 1 || embed.maxRows > 100)) {
|
|
92
|
+
report("needs maxRows from 1 to 100.");
|
|
93
|
+
}
|
|
94
|
+
else if (embed.maxRows !== undefined && query.pagination !== "offset" && query.pagination !== "cursor") {
|
|
95
|
+
report("has maxRows, which needs a resource that pages.");
|
|
96
|
+
}
|
|
97
|
+
const params = Object.entries(embed.params ?? {});
|
|
98
|
+
const fixed = (key) => Object.hasOwn(embed.source.params ?? {}, key);
|
|
99
|
+
for (const field of bindingFields) {
|
|
100
|
+
if (field.required && field.defaultValue === undefined && !fixed(field.key) &&
|
|
101
|
+
!params.some(([, param]) => "binding" in param && param.binding === field.key)) {
|
|
102
|
+
report(`leaves the required binding field "${field.key}" open.`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const targets = new Set();
|
|
106
|
+
for (const [name, param] of params) {
|
|
107
|
+
const key = "binding" in param ? param.binding : param.filter;
|
|
108
|
+
const field = "binding" in param ? bindingFields.find((candidate) => candidate.key === key) : fields.find((candidate) => candidate.key === key);
|
|
109
|
+
const problem = !/^[A-Za-z][A-Za-z0-9_-]*$/u.test(name) ? "is no parameter name"
|
|
110
|
+
: targets.has(`${"binding" in param}:${key}`) ? "sets what another parameter sets"
|
|
111
|
+
: !field || ("filter" in param && !filterFields.has(key)) ? `names "${key}", which the resource does not declare for this`
|
|
112
|
+
: "binding" in param ? fixed(key) ? `binds "${key}", which the source fixes` : null
|
|
113
|
+
: Object.hasOwn(embed.fixedFilters ?? {}, key) ? `filters by "${key}", which a fixed filter pins`
|
|
114
|
+
: !["string", "number", "boolean", "enum"].includes(field.type) ? `filters by a ${field.type} field`
|
|
115
|
+
: null;
|
|
116
|
+
targets.add(`${"binding" in param}:${key}`);
|
|
117
|
+
if (problem)
|
|
118
|
+
report(`parameter "${name}" ${problem}.`);
|
|
119
|
+
else if (field?.type === "enum" && !hasStaticOptions(field))
|
|
120
|
+
report(`parameter "${name}" needs choices it can check, not a Provider's.`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return findings;
|
|
124
|
+
}
|
|
@@ -12,7 +12,10 @@ import type { PhiResolvedCmsPageTree } from "../types/cms";
|
|
|
12
12
|
* own package does not run it: every word in its Pages is the Site's, which is what no marker means.
|
|
13
13
|
*
|
|
14
14
|
* It reads the config as stated, by the field names alone (`helpers/config-text-fields.ts`), so it needs
|
|
15
|
-
* no Widget definition: a text under a text's name, at the top
|
|
15
|
+
* no Widget definition: a text under a text's name, at the top, inside a list's entries or inside a nested
|
|
16
|
+
* object -- a Table's `presentation.columns[].title`, `features.filters[].label` and
|
|
17
|
+
* `presentation.emptyState.title` are words as much as a Button's label. A Table whose texts come from the
|
|
18
|
+
* Module's Label Set, already in the reader's language, says so with `NoTranslate` on its node.
|
|
16
19
|
*/
|
|
17
20
|
export type PhiPresetTextSourceFinding = {
|
|
18
21
|
/** The node's label, or its id where it has none. */
|
|
@@ -3,7 +3,7 @@ import { readPhiTextSource } from "./text-source";
|
|
|
3
3
|
import { PhiCmsFlags } from "../constants/phi-cms";
|
|
4
4
|
import { hasPhiFlag } from "./flags";
|
|
5
5
|
function findTextKey(value, depth = 0) {
|
|
6
|
-
if (depth >
|
|
6
|
+
if (depth > 6 || value == null || typeof value !== "object")
|
|
7
7
|
return null;
|
|
8
8
|
if (Array.isArray(value)) {
|
|
9
9
|
for (const item of value) {
|
|
@@ -21,6 +21,11 @@ function findTextKey(value, depth = 0) {
|
|
|
21
21
|
if (found)
|
|
22
22
|
return `${key}[].${found}`;
|
|
23
23
|
}
|
|
24
|
+
else if (entry !== null && typeof entry === "object") {
|
|
25
|
+
const found = findTextKey(entry, depth + 1);
|
|
26
|
+
if (found)
|
|
27
|
+
return `${key}.${found}`;
|
|
28
|
+
}
|
|
24
29
|
}
|
|
25
30
|
return null;
|
|
26
31
|
}
|
|
@@ -10,8 +10,9 @@ import type { PhiCmsPageNode, PhiResolvedCmsPageTree } from "../types/cms";
|
|
|
10
10
|
*
|
|
11
11
|
* The rules: every node a preset instance id, none twice, every parent, Region root, Overlay root and Page
|
|
12
12
|
* root resolved; the base page layout node only as the canonical scaffold; an actions Footer the canonical
|
|
13
|
-
* Flex preset;
|
|
14
|
-
*
|
|
13
|
+
* Flex preset; an Overlay's geometry the block's pairs, never `width` or one bare length; a modal's body
|
|
14
|
+
* and actions the dialog's (`helpers/cms-dialog.ts`), and a modal at the default `PHI_DIALOG_WIDTH` not
|
|
15
|
+
* holding only Forms of one column; a Form's or a record Widget's title from its
|
|
15
16
|
* record read, sent, and heard where it goes. The findings come in the order the compiler used to throw them, so its first is the
|
|
16
17
|
* error it always gave.
|
|
17
18
|
*
|
|
@@ -4,6 +4,7 @@ import { PhiCmsWidgetType } from "../constants/cms-widget-types";
|
|
|
4
4
|
import { isPhiCmsInstanceId, readPhiCmsInstanceIdDescriptor } from "../types/cms-instance-id";
|
|
5
5
|
import { PHI_DIALOG_BLEED_BODY_CONFIG, PHI_DIALOG_BODY_CONFIG, PHI_DIALOG_COMMANDS_CONFIG, PHI_DIALOG_WIDTH, isPhiFormSingleColumn, } from "./cms-dialog";
|
|
6
6
|
import { resolvePhiLayoutCreationPreset } from "./cms-layout-defaults";
|
|
7
|
+
import { isPhiRecord } from "./is-record";
|
|
7
8
|
import { PHI_FORM_RECORD_TITLE_CAPABILITY, readPhiFormWidgetTitleFromRecord, } from "../components/forms/form-record-title";
|
|
8
9
|
import { readPhiRecordWidgetTitleFromRecord } from "./record-widget";
|
|
9
10
|
function stablePresetNodeJson(value) {
|
|
@@ -106,6 +107,7 @@ export function checkPhiPresetTreeContract(tree, options = {}) {
|
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
for (const overlay of tree.overlays) {
|
|
110
|
+
checkOverlayGeometry(overlay, report);
|
|
109
111
|
if (overlay.overlayType !== "modal")
|
|
110
112
|
continue;
|
|
111
113
|
const body = layoutsById.get(overlay.bodyLayoutNodeId);
|
|
@@ -182,14 +184,37 @@ function checkDialogCommands(overlayId, footerLayoutId, widgets, report) {
|
|
|
182
184
|
}
|
|
183
185
|
}
|
|
184
186
|
}
|
|
187
|
+
/** The keys an Overlay states its geometry in: the block's three pairs. */
|
|
188
|
+
const PHI_OVERLAY_GEOMETRY_KEYS = ["size", "minSize", "maxSize"];
|
|
189
|
+
/*
|
|
190
|
+
* An Overlay is sized like a block: `size`, `minSize` and `maxSize`, each a `{ width?, height? }` pair
|
|
191
|
+
* (OVERLAYS.md, "Presentation config"). The Modal's `width` and the Drawer's single length are gone, and
|
|
192
|
+
* nothing reads them -- so a preset still writing either would open a dialog at a width nobody chose,
|
|
193
|
+
* with nothing said. Refused instead, with the spelling that replaces it. A bare length is refused too,
|
|
194
|
+
* although the block reader takes it as a width: a Drawer at the top or bottom opens along its height,
|
|
195
|
+
* and a bare `size: 377` there is the old single length meaning the wrong axis.
|
|
196
|
+
*/
|
|
197
|
+
function checkOverlayGeometry(overlay, report) {
|
|
198
|
+
if (overlay.config.width !== undefined) {
|
|
199
|
+
report(overlay.id, `Preset Overlay "${overlay.id}" states \`width\`; an Overlay is sized like a block. ` +
|
|
200
|
+
"State `size: { width }` (a dialog: `size: { width: PHI_DIALOG_WIDTH_SINGLE_COLUMN }`), and a viewport limit as `maxSize`.");
|
|
201
|
+
}
|
|
202
|
+
for (const key of PHI_OVERLAY_GEOMETRY_KEYS) {
|
|
203
|
+
const value = overlay.config[key];
|
|
204
|
+
if (value != null && !isPhiRecord(value)) {
|
|
205
|
+
report(overlay.id, `Preset Overlay "${overlay.id}" states \`${key}\` as one length; state the pair, \`${key}: { width }\` or \`${key}: { height }\`.`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
185
209
|
/*
|
|
186
210
|
* A dialog is as wide as its Form needs (`helpers/cms-dialog.ts`): one column takes
|
|
187
|
-
* `PHI_DIALOG_WIDTH_SINGLE_COLUMN`, two keep `PHI_DIALOG_WIDTH
|
|
188
|
-
* did not choose -- the default, holding nothing but
|
|
189
|
-
* caller that knows what else the body holds; a
|
|
211
|
+
* `PHI_DIALOG_WIDTH_SINGLE_COLUMN`, two keep `PHI_DIALOG_WIDTH`, either as the width of the Overlay's
|
|
212
|
+
* `size`. What is refused is the one width a Preset did not choose -- the default, holding nothing but
|
|
213
|
+
* Forms of one column. Any other width was stated, by a caller that knows what else the body holds; a
|
|
214
|
+
* Form the caller cannot see is not judged.
|
|
190
215
|
*/
|
|
191
216
|
function checkDialogWidth(overlay, tree, forms, report) {
|
|
192
|
-
if (stablePresetNodeJson(overlay.config.
|
|
217
|
+
if (stablePresetNodeJson(overlay.config.size) !== stablePresetNodeJson({ width: PHI_DIALOG_WIDTH }))
|
|
193
218
|
return;
|
|
194
219
|
const bodyLayoutIds = new Set([overlay.bodyLayoutNodeId]);
|
|
195
220
|
for (let grown = true; grown;) {
|
|
@@ -209,7 +234,7 @@ function checkDialogWidth(overlay, tree, forms, report) {
|
|
|
209
234
|
const descriptors = formIds.map((formId) => (typeof formId === "string" ? forms.get(formId) : undefined)?.descriptor);
|
|
210
235
|
if (descriptors.every((descriptor) => descriptor != null && isPhiFormSingleColumn(descriptor))) {
|
|
211
236
|
report(overlay.id, `Preset Overlay "${overlay.id}" holds the one-column Form "${String(formIds[0])}" at the full dialog width ` +
|
|
212
|
-
"(PHI_DIALOG_WIDTH). Hand the Form to `dialog` as `body.form`, or state `width: PHI_DIALOG_WIDTH_SINGLE_COLUMN`.");
|
|
237
|
+
"(PHI_DIALOG_WIDTH). Hand the Form to `dialog` as `body.form`, or state `size: { width: PHI_DIALOG_WIDTH_SINGLE_COLUMN }`.");
|
|
213
238
|
}
|
|
214
239
|
}
|
|
215
240
|
function readRoutes(config, side) {
|
|
@@ -35,6 +35,13 @@ export type PhiPublicRoutePathCollision = {
|
|
|
35
35
|
/** The address contested: the assignment this Site already made, or the declared path. */
|
|
36
36
|
path: string;
|
|
37
37
|
heldBy: PhiPublicRouteAddressHolder;
|
|
38
|
+
/**
|
|
39
|
+
* How the two addresses meet: the same address, or one beneath the other -- a Page and a folder at once
|
|
40
|
+
* (`isPhiRouteAddressBeneath`, THIRD_PARTY_MODULES.md "Addresses and folders").
|
|
41
|
+
*/
|
|
42
|
+
relation: "same" | "beneath" | "above";
|
|
43
|
+
/** The holder's address: `path` itself, or the one above or beneath it. */
|
|
44
|
+
heldPath: string;
|
|
38
45
|
};
|
|
39
46
|
/**
|
|
40
47
|
* The address a route answers on: what this Site assigned it, or what it declared.
|
|
@@ -62,7 +69,8 @@ export declare function buildPhiPublicRouteAddressMap({ claims, activeModuleIds,
|
|
|
62
69
|
}[];
|
|
63
70
|
}): Map<string, PhiPublicRouteAddressHolder>;
|
|
64
71
|
/**
|
|
65
|
-
* The addresses a Module could not have if it were switched on now
|
|
72
|
+
* The addresses a Module could not have if it were switched on now: one another holder answers on, or one
|
|
73
|
+
* beneath or above another holder's -- a Site Page's or another Module's route.
|
|
66
74
|
*
|
|
67
75
|
* `/` is left out on purpose: it is an application for the Area root slot, not a route of the Module's
|
|
68
76
|
* own, and several applicants are a list to choose from rather than a conflict.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isPhiRouteAddressBeneath } from "./route-address-check";
|
|
1
2
|
function buildPhiPublicRouteIdentity(ownerModuleId, presetKey) {
|
|
2
3
|
return `${ownerModuleId}/${presetKey}`;
|
|
3
4
|
}
|
|
@@ -38,7 +39,8 @@ export function buildPhiPublicRouteAddressMap({ claims, activeModuleIds, assignm
|
|
|
38
39
|
return addresses;
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
41
|
-
* The addresses a Module could not have if it were switched on now
|
|
42
|
+
* The addresses a Module could not have if it were switched on now: one another holder answers on, or one
|
|
43
|
+
* beneath or above another holder's -- a Site Page's or another Module's route.
|
|
42
44
|
*
|
|
43
45
|
* `/` is left out on purpose: it is an application for the Area root slot, not a route of the Module's
|
|
44
46
|
* own, and several applicants are a list to choose from rather than a conflict.
|
|
@@ -50,9 +52,27 @@ export function findPhiPublicRoutePathCollisions({ moduleId, claims, addresses,
|
|
|
50
52
|
continue;
|
|
51
53
|
}
|
|
52
54
|
const path = resolvePhiPublicRoutePath(claim, assignments);
|
|
55
|
+
const foreign = (holder) => !(holder.kind === "module" && holder.claim.ownerModuleId === moduleId);
|
|
53
56
|
const heldBy = addresses.get(path);
|
|
54
|
-
if (heldBy &&
|
|
55
|
-
collisions.push({ claim, path, heldBy });
|
|
57
|
+
if (heldBy && foreign(heldBy)) {
|
|
58
|
+
collisions.push({ claim, path, heldBy, relation: "same", heldPath: path });
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
/*
|
|
62
|
+
* An address that is free can still lie beneath another one, or above it: a route assigned
|
|
63
|
+
* `/contracts/terms` under a Site Page `/contracts` makes that Page a folder, which equality alone
|
|
64
|
+
* never saw.
|
|
65
|
+
*/
|
|
66
|
+
for (const [heldPath, holder] of addresses) {
|
|
67
|
+
if (!foreign(holder))
|
|
68
|
+
continue;
|
|
69
|
+
const relation = isPhiRouteAddressBeneath(heldPath, path)
|
|
70
|
+
? "beneath"
|
|
71
|
+
: isPhiRouteAddressBeneath(path, heldPath) ? "above" : null;
|
|
72
|
+
if (relation) {
|
|
73
|
+
collisions.push({ claim, path, heldBy: holder, relation, heldPath });
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
56
76
|
}
|
|
57
77
|
}
|
|
58
78
|
return collisions;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
+
import { type PHI_RECORD_TEXT_FIELD_KINDS } from "../constants/record-field-kinds";
|
|
1
2
|
import type { PhiRuntimeModuleCatalogEntry } from "../types/cms-plugins";
|
|
2
3
|
import type { PhiRuntimeDataProviderKey } from "../types/runtime-data-provider";
|
|
3
4
|
import type { PhiRecordDeclaration, PhiRecordField, PhiRecordFieldKind, PhiRecordFieldValueByKind } from "../types/record-provider";
|
|
4
5
|
/** `value` as a field of `kind`, or `undefined` where it is not one. */
|
|
5
6
|
export declare function readPhiRecordFieldValue<K extends PhiRecordFieldKind>(kind: K, value: unknown): PhiRecordFieldValueByKind[K] | undefined;
|
|
6
|
-
/**
|
|
7
|
-
* The kinds a line of text can show: a text as it is, a number, a date and an amount of money in the
|
|
8
|
-
* page's language.
|
|
9
|
-
*/
|
|
10
|
-
export declare const PHI_RECORD_TEXT_FIELD_KINDS: readonly ["text", "number", "date", "money"];
|
|
11
7
|
/**
|
|
12
8
|
* A text, number, date or money field as the words a page shows, written for `locale`; a date on the
|
|
13
9
|
* calendar of the Site's `timeZone`, as every other date the page shows (`formatPhiDate`).
|
package/helpers/record-fields.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { formatPhisMoney } from "@phis/contracts/payments";
|
|
2
|
+
import { PHI_RECORD_MARKDOWN_KNOWN_FLAGS } from "../constants/record-field-kinds";
|
|
3
|
+
import { isPhiRuntimeModuleSourceLocale } from "../types/runtime-module-locale";
|
|
2
4
|
import { formatPhiDate } from "./format-date-time";
|
|
3
5
|
import { isPhiMinorAmount, readPhiCurrencyExponent } from "./money-amount";
|
|
4
6
|
/*
|
|
@@ -43,6 +45,17 @@ function readLink(value) {
|
|
|
43
45
|
return undefined;
|
|
44
46
|
return typeof value.label === "string" && value.label ? { href, label: value.label } : { href };
|
|
45
47
|
}
|
|
48
|
+
/** A text, the locale key it is written in, and flags of no other bits than `PhiRecordMarkdownFlag` names. */
|
|
49
|
+
function readMarkdown(value) {
|
|
50
|
+
if (!isRecord(value) || typeof value.text !== "string" || !isPhiRuntimeModuleSourceLocale(value.sourceLocale)) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
const { flags } = value;
|
|
54
|
+
if (typeof flags !== "number" || !Number.isInteger(flags) || flags < 0 || (flags & ~PHI_RECORD_MARKDOWN_KNOWN_FLAGS) !== 0) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
return { text: value.text, sourceLocale: value.sourceLocale.trim(), flags };
|
|
58
|
+
}
|
|
46
59
|
/** The contract's money exactly: a currency a payment accepts and `minor` as an integer string. */
|
|
47
60
|
function readMoney(value) {
|
|
48
61
|
if (!isRecord(value) || typeof value.currency !== "string" || readPhiCurrencyExponent(value.currency) === undefined) {
|
|
@@ -59,8 +72,9 @@ function readAll(value, read) {
|
|
|
59
72
|
export function readPhiRecordFieldValue(kind, value) {
|
|
60
73
|
switch (kind) {
|
|
61
74
|
case "text":
|
|
62
|
-
case "markdown":
|
|
63
75
|
return typeof value === "string" ? value : undefined;
|
|
76
|
+
case "markdown":
|
|
77
|
+
return readMarkdown(value);
|
|
64
78
|
case "picture":
|
|
65
79
|
return readPicture(value);
|
|
66
80
|
case "pictures":
|
|
@@ -79,11 +93,6 @@ export function readPhiRecordFieldValue(kind, value) {
|
|
|
79
93
|
return readLink(value);
|
|
80
94
|
}
|
|
81
95
|
}
|
|
82
|
-
/**
|
|
83
|
-
* The kinds a line of text can show: a text as it is, a number, a date and an amount of money in the
|
|
84
|
-
* page's language.
|
|
85
|
-
*/
|
|
86
|
-
export const PHI_RECORD_TEXT_FIELD_KINDS = ["text", "number", "date", "money"];
|
|
87
96
|
/**
|
|
88
97
|
* A text, number, date or money field as the words a page shows, written for `locale`; a date on the
|
|
89
98
|
* calendar of the Site's `timeZone`, as every other date the page shows (`formatPhiDate`).
|
|
@@ -17,8 +17,12 @@ import type { PhiCmsAreaKey } from "../constants/cms-areas";
|
|
|
17
17
|
* Compared by segment, a parameter by its name like any other segment: `/shop/:slug` and `/shop/cart`
|
|
18
18
|
* are siblings. `/` is the Area's root slot and no folder.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* From `@phis/ui/module/page-check`: a package runs it over its own routes, and phis-ui over the
|
|
21
|
+
* first-party ones. `refusePhiCatalogRouteAddresses` is the same rule over a compiled catalog, every
|
|
22
|
+
* installed package's routes together: the descriptor compiler refuses a catalog that breaks it, so an
|
|
23
|
+
* installed package that does is refused. The addresses a Site assigns on
|
|
24
|
+
* Public are held to it in the Builder (`findPhiPublicRoutePathCollisions`). The Site's own Pages are
|
|
25
|
+
* refused by phis-server when written.
|
|
22
26
|
*/
|
|
23
27
|
export type PhiRouteAddressSubject = {
|
|
24
28
|
area: PhiCmsAreaKey;
|
|
@@ -32,4 +36,20 @@ export type PhiRouteAddressFinding = {
|
|
|
32
36
|
above: string;
|
|
33
37
|
message: string;
|
|
34
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* Whether `lowerPath` lies beneath `upperPath` so that the upper one would be a Page and a folder at once:
|
|
41
|
+
* by segment, `/` never above anything, a list's entries -- one parameter directly beneath -- excepted.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isPhiRouteAddressBeneath(upperPath: string, lowerPath: string): boolean;
|
|
35
44
|
export declare function checkPhiRouteAddresses(routes: readonly PhiRouteAddressSubject[]): PhiRouteAddressFinding[];
|
|
45
|
+
/** Every route of a compiled catalog as the rule reads it, Area by Area. */
|
|
46
|
+
export declare function listPhiCatalogRouteAddressSubjects(routesByArea: ReadonlyMap<PhiCmsAreaKey, readonly {
|
|
47
|
+
descriptor: PhiRouteAddressSubject;
|
|
48
|
+
}[]>): PhiRouteAddressSubject[];
|
|
49
|
+
/**
|
|
50
|
+
* The rule over a compiled catalog, as compiling it would refuse it: throws naming every route that lies
|
|
51
|
+
* beneath another of its Area, whichever packages the two come from.
|
|
52
|
+
*/
|
|
53
|
+
export declare function refusePhiCatalogRouteAddresses(routesByArea: ReadonlyMap<PhiCmsAreaKey, readonly {
|
|
54
|
+
descriptor: PhiRouteAddressSubject;
|
|
55
|
+
}[]>): void;
|