@phis/ui 0.4.23 → 0.5.1

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.
Files changed (125) hide show
  1. package/components/controls/phi-background-control.js +1 -1
  2. package/components/controls/phi-breadcrumb-control.d.ts +2 -0
  3. package/components/controls/phi-button-control.d.ts +7 -1
  4. package/components/media/media-asset-typed-fields.d.ts +10 -0
  5. package/components/media/media-asset-typed-fields.js +19 -0
  6. package/components/media/media-settings-labels.d.ts +33 -0
  7. package/components/media/media-settings-labels.js +62 -0
  8. package/components/media/media-upload-flow.d.ts +19 -0
  9. package/components/media/media-upload-flow.js +38 -0
  10. package/components/media/phi-asset-focal-rect-widget.js +2 -2
  11. package/components/media/phi-asset-folder-control.js +1 -1
  12. package/components/media/phi-image-inspector-widget.js +1 -1
  13. package/components/media/phi-image-preview-data.js +5 -4
  14. package/components/media/phi-site-font-assets.js +2 -5
  15. package/components/media/use-authoring-asset-details.js +0 -1
  16. package/components/regions/presets/content-entry-editor-page-tree.js +1 -1
  17. package/components/regions/presets/navigation-redirect.d.ts +2 -2
  18. package/components/regions/presets/navigation-redirect.js +3 -3
  19. package/components/regions/presets/phi-area-shell-preset-nodes.js +2 -1
  20. package/components/regions/presets/phi-settings-page-shell-tree.js +1 -1
  21. package/components/shell/phi-antd-icon.d.ts +4 -0
  22. package/components/shell/phi-antd-icon.js +8 -0
  23. package/components/shell/phi-icon.d.ts +18 -0
  24. package/components/shell/phi-icon.js +50 -3
  25. package/components/widgets/client/shared/phi-button-icons.d.ts +7 -0
  26. package/components/widgets/client/shared/phi-button-icons.js +15 -67
  27. package/components/widgets/helpers/internal-reference-resolver.server.d.ts +1 -1
  28. package/components/widgets/helpers/internal-reference-resolver.server.js +4 -0
  29. package/components/widgets/label-sets/builder-modules.js +6 -0
  30. package/components/widgets/label-types/builder-modules.d.ts +4 -0
  31. package/components/widgets/label-types/builder-modules.js +3 -0
  32. package/components/widgets/label-types/common-controls.js +12 -12
  33. package/constants/runtime-module-ownership.js +4 -0
  34. package/gateway/internal-references.d.ts +5 -0
  35. package/gateway/internal-references.js +12 -12
  36. package/gateway/site-media-settings.d.ts +2 -0
  37. package/gateway/site-media-settings.js +6 -1
  38. package/gateway/site-media-storage-reader.d.ts +19 -0
  39. package/gateway/site-media-storage-reader.js +24 -0
  40. package/helpers/cms-navigation-catalog.d.ts +2 -0
  41. package/helpers/cms-navigation-catalog.js +1 -0
  42. package/helpers/cms-page-catalog.d.ts +12 -0
  43. package/helpers/cms-page-catalog.js +5 -0
  44. package/helpers/phi-seo.d.ts +16 -2
  45. package/helpers/phi-seo.js +54 -11
  46. package/helpers/public-route-claims.d.ts +4 -0
  47. package/helpers/public-route-claims.js +1 -1
  48. package/next/seo-routes.d.ts +1 -1
  49. package/next/seo-routes.js +23 -5
  50. package/package.json +1 -1
  51. package/plugins/runtime-modules/accounting/presets.d.ts +10 -1
  52. package/plugins/runtime-modules/accounting/presets.js +25 -8
  53. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-area-preset-tree.d.ts +6 -0
  54. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-area-preset-tree.js +53 -0
  55. package/plugins/runtime-modules/area-definitions.d.ts +123 -12
  56. package/plugins/runtime-modules/area-definitions.js +28 -0
  57. package/plugins/runtime-modules/asset/client-data-providers.js +12 -0
  58. package/plugins/runtime-modules/asset/controller/runtime.js +1 -1
  59. package/plugins/runtime-modules/asset/data-providers.d.ts +27 -2
  60. package/plugins/runtime-modules/asset/data-providers.js +56 -0
  61. package/plugins/runtime-modules/asset/definition.d.ts +38 -2
  62. package/plugins/runtime-modules/asset/definition.js +2 -1
  63. package/plugins/runtime-modules/asset/ids.d.ts +4 -0
  64. package/plugins/runtime-modules/asset/ids.js +4 -0
  65. package/plugins/runtime-modules/asset/server.js +2 -1
  66. package/plugins/runtime-modules/asset/services/options.d.ts +7 -0
  67. package/plugins/runtime-modules/asset/services/options.js +38 -0
  68. package/plugins/runtime-modules/asset/services/storage-spaces-table.d.ts +3 -0
  69. package/plugins/runtime-modules/asset/services/storage-spaces-table.js +89 -0
  70. package/plugins/runtime-modules/asset/settings-forms.d.ts +17 -0
  71. package/plugins/runtime-modules/asset/settings-forms.js +117 -1
  72. package/plugins/runtime-modules/asset/trees/phi-default-admin-media-settings-page-tree.js +94 -1
  73. package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +1 -1
  74. package/plugins/runtime-modules/builder/area-shell-presets.server.d.ts +8 -0
  75. package/plugins/runtime-modules/builder/area-shell-presets.server.js +13 -0
  76. package/plugins/runtime-modules/builder/controller/page-controller-helpers.js +1 -1
  77. package/plugins/runtime-modules/builder/controller/page-controller.d.ts +1 -1
  78. package/plugins/runtime-modules/builder/controller/page-controller.js +30 -3
  79. package/plugins/runtime-modules/builder/controller/server-definition.d.ts +7 -1
  80. package/plugins/runtime-modules/builder/controller/server-definition.js +8 -3
  81. package/plugins/runtime-modules/builder/data-providers.js +1 -0
  82. package/plugins/runtime-modules/builder/developer-workspace-types.d.ts +2 -0
  83. package/plugins/runtime-modules/builder/navigation-path-context.js +7 -3
  84. package/plugins/runtime-modules/builder/options-providers.js +2 -2
  85. package/plugins/runtime-modules/builder/page-address-rule.d.ts +39 -0
  86. package/plugins/runtime-modules/builder/page-address-rule.js +62 -0
  87. package/plugins/runtime-modules/builder/page-meta-form.js +10 -0
  88. package/plugins/runtime-modules/builder/public-route-collisions.js +7 -2
  89. package/plugins/runtime-modules/builder/services/page-source-tree.js +2 -1
  90. package/plugins/runtime-modules/builder/services/runtime-modules-table.js +49 -1
  91. package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +2 -2
  92. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +16 -4
  93. package/plugins/runtime-modules/core/widgets/breadcrumb/client.d.ts +14 -2
  94. package/plugins/runtime-modules/core/widgets/breadcrumb/client.js +35 -4
  95. package/plugins/runtime-modules/core/widgets/breadcrumb/server.d.ts +3 -1
  96. package/plugins/runtime-modules/core/widgets/breadcrumb/server.js +37 -2
  97. package/plugins/runtime-modules/core/widgets/card/editor.js +1 -1
  98. package/plugins/runtime-modules/core/widgets/image/client.js +1 -1
  99. package/plugins/runtime-modules/core/widgets/image/editor.js +1 -1
  100. package/plugins/runtime-modules/core/widgets/page-title/authoring.js +3 -1
  101. package/plugins/runtime-modules/core/widgets/page-title/client.d.ts +3 -1
  102. package/plugins/runtime-modules/core/widgets/page-title/client.js +5 -1
  103. package/plugins/runtime-modules/core/widgets/page-title/config.d.ts +25 -3
  104. package/plugins/runtime-modules/core/widgets/page-title/config.js +24 -3
  105. package/plugins/runtime-modules/core/widgets/page-title/plugin.js +1 -1
  106. package/plugins/runtime-modules/core/widgets/page-title/server.d.ts +3 -1
  107. package/plugins/runtime-modules/core/widgets/page-title/server.js +4 -3
  108. package/plugins/runtime-modules/core/widgets/table/client.js +1 -1
  109. package/plugins/runtime-modules/core/widgets/table/config.js +9 -0
  110. package/plugins/runtime-modules/descriptor-compiler.js +33 -8
  111. package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +1 -1
  112. package/plugins/runtime-modules/localization/trees/phi-default-editor-translations-page-tree.js +1 -1
  113. package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +1 -1
  114. package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +1 -1
  115. package/plugins/runtime-modules/threads/trees/phi-default-threads-page-tree.js +2 -2
  116. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +1 -1
  117. package/server-helpers/cms-review-params.d.ts +25 -0
  118. package/server-helpers/cms-review-params.js +54 -0
  119. package/server-helpers/cms-review.d.ts +1 -25
  120. package/server-helpers/cms-review.js +2 -54
  121. package/styles/controls.css +11 -0
  122. package/types/cms-module-descriptors.d.ts +33 -3
  123. package/types/media.d.ts +6 -2
  124. package/types/table-widget.d.ts +11 -0
  125. package/types.d.ts +1 -1
@@ -1,72 +1,20 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { PhiAntdIcon } from "../../../shell/phi-antd-icon";
4
- import { PhiIcon } from "../../../shell/phi-icon";
3
+ import { isPhiIconNameKnown, PhiIcon, reportPhiUnknownIconName } from "../../../shell/phi-icon";
4
+ /**
5
+ * The icon a Button, a Table action or a Command Toolbar names, or null where the name draws nothing.
6
+ *
7
+ * The same rule as `PhiIcon` (`isPhiIconNameKnown`): a short name is the Ant Design icon of that name,
8
+ * one name per icon. Null rather than an empty element, because a Table falls back to the action's label
9
+ * where its icon does not resolve and asks this to find out.
10
+ */
5
11
  export function resolvePhiButtonIcon(icon) {
6
- const normalizedIcon = icon?.trim();
7
- const alias = normalizedIcon?.toLowerCase().startsWith("antd:")
8
- ? normalizedIcon.slice("antd:".length).toLowerCase()
9
- : normalizedIcon?.toLowerCase();
10
- switch (alias) {
11
- case "apply":
12
- case "check":
13
- return _jsx(PhiAntdIcon, { icon: "CheckOutlined" });
14
- case "cancel":
15
- case "clear":
16
- case "close":
17
- return _jsx(PhiAntdIcon, { icon: "CloseOutlined" });
18
- case "upload":
19
- case "cloud-upload":
20
- case "publish":
21
- return _jsx(PhiAntdIcon, { icon: "CloudUploadOutlined" });
22
- case "delete":
23
- case "trash":
24
- return _jsx(PhiAntdIcon, { icon: "DeleteOutlined" });
25
- case "edit":
26
- case "meta":
27
- case "settings":
28
- return _jsx(PhiAntdIcon, { icon: "EditOutlined" });
29
- case "eye":
30
- case "preview":
31
- case "view":
32
- return _jsx(PhiAntdIcon, { icon: "EyeOutlined" });
33
- case "eye-invisible":
34
- case "eye-invisible-outlined":
35
- return _jsx(PhiAntdIcon, { icon: "EyeInvisibleOutlined" });
36
- case "folder-add":
37
- case "folder-add-outlined":
38
- return _jsx(PhiAntdIcon, { icon: "FolderAddOutlined" });
39
- case "history":
40
- return _jsx(PhiAntdIcon, { icon: "HistoryOutlined" });
41
- case "link":
42
- case "link-outlined":
43
- return _jsx(PhiAntdIcon, { icon: "LinkOutlined" });
44
- case "minus":
45
- case "minus-outlined":
46
- return _jsx(PhiAntdIcon, { icon: "MinusOutlined" });
47
- case "add":
48
- case "new":
49
- case "plus":
50
- return _jsx(PhiAntdIcon, { icon: "PlusOutlined" });
51
- case "redo":
52
- return _jsx(PhiAntdIcon, { icon: "RedoOutlined" });
53
- case "reload":
54
- case "refresh":
55
- case "reset":
56
- case "restore":
57
- return _jsx(PhiAntdIcon, { icon: "ReloadOutlined" });
58
- case "save":
59
- return _jsx(PhiAntdIcon, { icon: "SaveOutlined" });
60
- case "search":
61
- return _jsx(PhiAntdIcon, { icon: "SearchOutlined" });
62
- case "stop":
63
- case "retire":
64
- return _jsx(PhiAntdIcon, { icon: "StopOutlined" });
65
- case "undo":
66
- return _jsx(PhiAntdIcon, { icon: "UndoOutlined" });
67
- default:
68
- return normalizedIcon?.includes(":")
69
- ? _jsx(PhiIcon, { name: normalizedIcon, size: "1em" })
70
- : null;
12
+ const name = icon?.trim();
13
+ if (!name)
14
+ return null;
15
+ if (!isPhiIconNameKnown(name)) {
16
+ reportPhiUnknownIconName(name);
17
+ return null;
71
18
  }
19
+ return _jsx(PhiIcon, { name: name, size: "1em" });
72
20
  }
@@ -13,7 +13,7 @@ export declare function resolvePhiPublicAssetReference(input: {
13
13
  assetId: number;
14
14
  }): Promise<import("../../../types").PhiPublicMediaAssetReference | null>;
15
15
  export declare function resolvePhiWidgetInternalReferences(input: {
16
- runtime: Pick<PhiBlockRuntime, "site" | "locale" | "area" | "viewer">;
16
+ runtime: Pick<PhiBlockRuntime, "site" | "locale" | "area" | "viewer" | "request">;
17
17
  /**
18
18
  * Which Area to resolve the Page references in. Absent is the one being rendered.
19
19
  *
@@ -3,6 +3,7 @@ import { resolveSiteInternalReferences } from "../../../gateway/internal-referen
3
3
  import { resolvePhiCmsRoutePresetByPageId } from "../../../plugins/runtime-modules/descriptor-compiler";
4
4
  import { resolvePhiNavHref } from "../../../helpers/locale";
5
5
  import { phiRuntime } from "../../../server-helpers/phi-runtime";
6
+ import { hasPhiCmsAuthorizedPreviewRead } from "../../../server-helpers/cms-review-params";
6
7
  import { readPhiPageReference } from "../../../types/references";
7
8
  /**
8
9
  * Resolves one Asset reference for a Widget that binds a single Asset by id.
@@ -35,6 +36,9 @@ export async function resolvePhiWidgetInternalReferences(input) {
35
36
  internalToken: rt.internalToken,
36
37
  siteKey: rt.siteKey,
37
38
  area,
39
+ // A link to a Page that was never published leads nowhere for a visitor, so only an authorized preview
40
+ // (a draft or revision read Core has already allowed) gets its path.
41
+ preview: hasPhiCmsAuthorizedPreviewRead(input.runtime.request?.searchParams),
38
42
  references: pageReferences,
39
43
  assetIds: input.assetIds,
40
44
  });
@@ -60,6 +60,9 @@ const PHI_BUILDER_MODULES_PAGE_LABEL_SET = definePhiLabelSet({
60
60
  public_routes_page: PHI_BUILDER_MODULES_PAGE_DEFAULT_LABELS.publicRoutes.page,
61
61
  public_routes_wanted: PHI_BUILDER_MODULES_PAGE_DEFAULT_LABELS.publicRoutes.wanted,
62
62
  public_routes_held_by: PHI_BUILDER_MODULES_PAGE_DEFAULT_LABELS.publicRoutes.heldBy,
63
+ public_routes_status: PHI_BUILDER_MODULES_PAGE_DEFAULT_LABELS.publicRoutes.status,
64
+ public_routes_live: PHI_BUILDER_MODULES_PAGE_DEFAULT_LABELS.publicRoutes.live,
65
+ public_routes_not_live: PHI_BUILDER_MODULES_PAGE_DEFAULT_LABELS.publicRoutes.notLive,
63
66
  public_routes_address: PHI_BUILDER_MODULES_PAGE_DEFAULT_LABELS.publicRoutes.address,
64
67
  public_routes_assign: PHI_BUILDER_MODULES_PAGE_DEFAULT_LABELS.publicRoutes.assign,
65
68
  public_routes_cancel: PHI_BUILDER_MODULES_PAGE_DEFAULT_LABELS.publicRoutes.cancel,
@@ -143,6 +146,9 @@ export async function getPhiBuilderModulesPageLabels(options) {
143
146
  page: labels.public_routes_page,
144
147
  wanted: labels.public_routes_wanted,
145
148
  heldBy: labels.public_routes_held_by,
149
+ status: labels.public_routes_status,
150
+ live: labels.public_routes_live,
151
+ notLive: labels.public_routes_not_live,
146
152
  address: labels.public_routes_address,
147
153
  assign: labels.public_routes_assign,
148
154
  cancel: labels.public_routes_cancel,
@@ -67,6 +67,10 @@ export type PhiBuilderModulesPageLabels = {
67
67
  page: string;
68
68
  wanted: string;
69
69
  heldBy: string;
70
+ /** Whether what holds the address answers on it today, which decides what moving it costs. */
71
+ status: string;
72
+ live: string;
73
+ notLive: string;
70
74
  address: string;
71
75
  assign: string;
72
76
  cancel: string;
@@ -75,6 +75,9 @@ export const PHI_BUILDER_MODULES_PAGE_DEFAULT_LABELS = {
75
75
  page: "Page",
76
76
  wanted: "Wanted",
77
77
  heldBy: "Taken by",
78
+ status: "Status",
79
+ live: "Live",
80
+ notLive: "Not published yet",
78
81
  address: "Address",
79
82
  assign: "Enable with these addresses",
80
83
  cancel: "Cancel",
@@ -1,21 +1,21 @@
1
1
  export const PHI_COMMON_CONTROL_DEFAULT_LABELS = {
2
2
  actions: {
3
- add: { label: "Add", tooltip: "Add", icon: "add" },
4
- apply: { label: "Apply", tooltip: "Apply", icon: "apply", variant: "primary" },
5
- cancel: { label: "Cancel", tooltip: "Cancel", icon: "cancel" },
6
- clear: { label: "Clear", tooltip: "Clear", icon: "clear" },
3
+ add: { label: "Add", tooltip: "Add", icon: "plus" },
4
+ apply: { label: "Apply", tooltip: "Apply", icon: "check", variant: "primary" },
5
+ cancel: { label: "Cancel", tooltip: "Cancel", icon: "close" },
6
+ clear: { label: "Clear", tooltip: "Clear", icon: "close" },
7
7
  delete: { label: "Delete", tooltip: "Delete", icon: "delete", danger: true },
8
8
  deleteSelected: { label: "Delete selected", tooltip: "Delete selected", icon: "delete", danger: true },
9
9
  edit: { label: "Edit", tooltip: "Edit", icon: "edit" },
10
- livePreview: { label: "Live preview", tooltip: "Live preview", icon: "preview" },
11
- meta: { label: "Meta", tooltip: "Meta", icon: "meta" },
12
- new: { label: "New", tooltip: "New", icon: "new" },
13
- pageMeta: { label: "Meta", tooltip: "Page meta", icon: "meta" },
14
- publish: { label: "Publish", tooltip: "Publish", icon: "publish" },
10
+ livePreview: { label: "Live preview", tooltip: "Live preview", icon: "eye" },
11
+ meta: { label: "Meta", tooltip: "Meta", icon: "edit" },
12
+ new: { label: "New", tooltip: "New", icon: "plus" },
13
+ pageMeta: { label: "Meta", tooltip: "Page meta", icon: "edit" },
14
+ publish: { label: "Publish", tooltip: "Publish", icon: "cloud-upload" },
15
15
  reload: { label: "Reload", tooltip: "Reload", icon: "reload" },
16
- reset: { label: "Reset", tooltip: "Reset", icon: "reset", danger: true },
17
- restore: { label: "Restore", tooltip: "Restore", icon: "restore" },
18
- review: { label: "Review", tooltip: "Review", icon: "preview" },
16
+ reset: { label: "Reset", tooltip: "Reset", icon: "reload", danger: true },
17
+ restore: { label: "Restore", tooltip: "Restore", icon: "reload" },
18
+ review: { label: "Review", tooltip: "Review", icon: "eye" },
19
19
  save: { label: "Save", tooltip: "Save", icon: "save" },
20
20
  search: { label: "Search", tooltip: "Search", icon: "search" },
21
21
  undo: { label: "Undo", tooltip: "Undo", icon: "undo" },
@@ -70,6 +70,7 @@ const PHI_RUNTIME_MODULE_OWNERSHIP = {
70
70
  "form-handler/app-profile-theme": ["app", "profile-theme"],
71
71
  "form-handler/asset-folder-create": ["asset", "folder-create"],
72
72
  "form-handler/asset-media-settings": ["asset", "media-settings"],
73
+ "form-handler/asset-media-storage-settings": ["asset", "media-storage-settings"],
73
74
  "form-handler/asset-metadata": ["asset", "metadata"],
74
75
  "form-handler/auth-admin-installation-create": ["auth", "admin-installation-create"],
75
76
  "form-handler/auth-admin-installation-update": ["auth", "admin-installation-update"],
@@ -123,6 +124,7 @@ const PHI_RUNTIME_MODULE_OWNERSHIP = {
123
124
  "forms/app/profile-theme": ["app", "profile-theme"],
124
125
  "forms/asset/folder-create": ["asset", "folder-create"],
125
126
  "forms/asset/media-settings": ["asset", "media-settings"],
127
+ "forms/asset/media-storage-settings": ["asset", "media-storage-settings"],
126
128
  "forms/asset/metadata": ["asset", "metadata"],
127
129
  "forms/auth/admin-installation-create": ["auth", "admin-installation-create"],
128
130
  "forms/auth/admin-installation-edit": ["auth", "admin-installation-edit"],
@@ -184,6 +186,8 @@ const PHI_RUNTIME_MODULE_OWNERSHIP = {
184
186
  "options/localization-locales": ["localization", "locales"],
185
187
  "options/media-folders": ["asset", "media-folders"],
186
188
  "options/media-folder-choices": ["asset", "media-folder-choices"],
189
+ "options/media-storage-profiles": ["asset", "media-storage-profiles"],
190
+ "tables/media-storage-spaces": ["asset", "media-storage-spaces"],
187
191
  "options/my-groups": ["groups", "my-groups"],
188
192
  "options/revision-bindings": ["revisions", "revision-bindings"],
189
193
  "options/runtime-modules": ["builder", "runtime-modules"],
@@ -32,6 +32,11 @@ export declare function resolveSiteInternalReferences(input: {
32
32
  siteKey: string;
33
33
  /** Required only for Page references. Assets are Site scoped and carry no Area. */
34
34
  area?: string;
35
+ /**
36
+ * The render is a preview the server already authorized (`hasPhiCmsAuthorizedPreviewRead`). Without it a
37
+ * Page that was never published resolves to no path, because the Public render would answer 404 for it.
38
+ */
39
+ preview?: boolean;
35
40
  references?: readonly PhiPageReference[];
36
41
  assetIds?: readonly number[];
37
42
  }): Promise<PhiResolvedInternalReferences>;
@@ -1,7 +1,7 @@
1
1
  import "server-only";
2
2
  import { buildApiHeaders, buildApiUrl } from "../helpers/site-api";
3
3
  import { PhiMediaKind } from "../constants/media";
4
- import { readPhiFontMetricsFields } from "../components/media/media-font-metrics";
4
+ import { readPhiMediaFocalRectField, readPhiMediaFontField } from "../components/media/media-asset-typed-fields";
5
5
  import { createPhiResponseReader, requirePhiField } from "../components/widgets/config/strict-config-reader";
6
6
  import { readPhiPageReference } from "../types/references";
7
7
  import { throwPhiCmsGatewayError } from "./errors";
@@ -48,14 +48,8 @@ export function readPhiPublicMediaAssetReference(entry) {
48
48
  altText: nullableText("altText"),
49
49
  thumbnailUrl: nullableText("thumbnailUrl"),
50
50
  previewUrl: nullableText("previewUrl"),
51
- focalRect: reader.object("focalRect", (rect) => {
52
- const fraction = (key) => {
53
- const value = requirePhiField(rect, key, "a number from 0 to 1", rect.number);
54
- return value >= 0 && value <= 1 ? value : rect.fail(key, "a number from 0 to 1");
55
- };
56
- return { x: fraction("x"), y: fraction("y"), width: fraction("width"), height: fraction("height") };
57
- }) ?? null,
58
- font: reader.object("font", readPhiFontMetricsFields) ?? null,
51
+ focalRect: readPhiMediaFocalRectField(reader),
52
+ font: readPhiMediaFontField(reader),
59
53
  };
60
54
  }
61
55
  /** What the server takes per list in one request (`MAX_REFERENCES_PER_REQUEST`). */
@@ -71,7 +65,7 @@ const PHI_REFERENCES_PER_REQUEST = 256;
71
65
  */
72
66
  const pendingBatches = new Map();
73
67
  function batchKey(input) {
74
- return JSON.stringify([input.apiBaseUrl, input.internalToken, input.siteKey, input.area ?? ""]);
68
+ return JSON.stringify([input.apiBaseUrl, input.internalToken, input.siteKey, input.area ?? "", input.preview === true]);
75
69
  }
76
70
  async function requestSiteInternalReferences(input, references, assetIds) {
77
71
  const response = await fetch(buildApiUrl(input.apiBaseUrl, "/api/v1/site/references"), {
@@ -85,7 +79,12 @@ async function requestSiteInternalReferences(input, references, assetIds) {
85
79
  jsonBody: true,
86
80
  }),
87
81
  cache: "no-store",
88
- body: JSON.stringify({ ...(input.area ? { area: input.area } : {}), references, assets: assetIds }),
82
+ body: JSON.stringify({
83
+ ...(input.area ? { area: input.area } : {}),
84
+ ...(input.preview ? { preview: true } : {}),
85
+ references,
86
+ assets: assetIds,
87
+ }),
89
88
  });
90
89
  if (!response.ok) {
91
90
  throwPhiCmsGatewayError(`Failed to resolve internal references (${response.status}).`, response.status);
@@ -136,6 +135,7 @@ export async function resolveSiteInternalReferences(input) {
136
135
  internalToken: input.internalToken,
137
136
  siteKey: input.siteKey,
138
137
  ...(input.area ? { area: input.area } : {}),
138
+ ...(input.preview ? { preview: true } : {}),
139
139
  };
140
140
  if (!keepsReferences()) {
141
141
  return requestThroughBatch(request, references, assetIds);
@@ -202,7 +202,7 @@ function keepsReferences() {
202
202
  }
203
203
  // A Page reference resolves within its Area; an Asset is Site scoped and carries none.
204
204
  function pageCacheKey(request, reference) {
205
- return `references:${request.siteKey.trim().toLowerCase()}:page:${request.area ?? ""}:${reference}`;
205
+ return `references:${request.siteKey.trim().toLowerCase()}:page:${request.area ?? ""}:${request.preview ? "preview" : "live"}:${reference}`;
206
206
  }
207
207
  function assetCacheKey(request, id) {
208
208
  return `references:${request.siteKey.trim().toLowerCase()}:asset:${id}`;
@@ -1,4 +1,5 @@
1
1
  import "server-only";
2
+ import { type PhiSiteMediaStorageSettings } from "./site-media-storage-reader";
2
3
  type PhiSiteMediaSettings = {
3
4
  userSpacesEnabled: boolean;
4
5
  groupSpacesEnabled: boolean;
@@ -21,6 +22,7 @@ type PhiSiteAddonMediaSpace = {
21
22
  };
22
23
  type PhiSiteMediaSettingsResult = PhiSiteMediaSettings & {
23
24
  addonSpaces: readonly PhiSiteAddonMediaSpace[];
25
+ storage: PhiSiteMediaStorageSettings;
24
26
  };
25
27
  type GetResolvedSiteMediaSettingsOptions = {
26
28
  apiBaseUrl: string;
@@ -1,6 +1,7 @@
1
1
  import { definePhiRequestMemo } from "../server-helpers/request-memo";
2
2
  import "server-only";
3
3
  import { fetchPhiSiteApi } from "./site-api-request";
4
+ import { readPhiSiteMediaStorageSettings } from "./site-media-storage-reader";
4
5
  export const getResolvedSiteMediaSettings = definePhiRequestMemo(async function getResolvedSiteMediaSettings({ apiBaseUrl, internalToken, siteKey, }) {
5
6
  const payload = await fetchPhiSiteApi({
6
7
  context: "getResolvedSiteMediaSettings",
@@ -14,5 +15,9 @@ export const getResolvedSiteMediaSettings = definePhiRequestMemo(async function
14
15
  throw new Error("Missing site media settings payload.");
15
16
  }
16
17
  // A Site with no Add-on holding files reports none, which is an answer and not a missing field.
17
- return { ...payload.media, addonSpaces: payload.addonSpaces ?? [] };
18
+ return {
19
+ ...payload.media,
20
+ addonSpaces: payload.addonSpaces ?? [],
21
+ storage: readPhiSiteMediaStorageSettings(payload.storage, "The site media storage settings"),
22
+ };
18
23
  });
@@ -0,0 +1,19 @@
1
+ /** Where the Site's Spaces write, among the Storage Profiles the operator created. */
2
+ export type PhiSiteMediaStorageSettings = {
3
+ profiles: readonly {
4
+ id: number;
5
+ key: string;
6
+ providerId: string;
7
+ local: boolean;
8
+ disabled: boolean;
9
+ spaces: number;
10
+ }[];
11
+ siteSpaceProfileId: number;
12
+ /** `null` is the Site's Local Profile. */
13
+ defaultUserProfileId: number | null;
14
+ defaultGroupProfileId: number | null;
15
+ /** Empty offers every Profile. */
16
+ allowedProfileIds: readonly number[];
17
+ };
18
+ /** Read, not cast: every field of the storage settings, or a throw naming the one that is wrong. */
19
+ export declare function readPhiSiteMediaStorageSettings(value: unknown, source: string): PhiSiteMediaStorageSettings;
@@ -0,0 +1,24 @@
1
+ import { createPhiResponseReader, requirePhiField } from "../components/widgets/config/strict-config-reader";
2
+ /** Read, not cast: every field of the storage settings, or a throw naming the one that is wrong. */
3
+ export function readPhiSiteMediaStorageSettings(value, source) {
4
+ const reader = createPhiResponseReader(value, source);
5
+ const id = (key) => requirePhiField(reader, key, "a Storage Profile id", reader.integer);
6
+ const nullableId = (key) => (reader.record[key] === null ? null : id(key));
7
+ const ids = (key) => requirePhiField(reader, key, "a list of Storage Profile ids", (field) => reader.value(field, "a list of Storage Profile ids", (value) => Array.isArray(value) && value.every((entry) => Number.isSafeInteger(entry) && entry > 0)
8
+ ? value
9
+ : undefined));
10
+ return {
11
+ profiles: requirePhiField(reader, "profiles", "the Storage Profiles", (key) => reader.list(key, (profile) => ({
12
+ id: requirePhiField(profile, "id", "an id", profile.integer),
13
+ key: requirePhiField(profile, "key", "a key", profile.string),
14
+ providerId: requirePhiField(profile, "providerId", "a provider id", profile.string),
15
+ local: requirePhiField(profile, "local", "true or false", profile.boolean),
16
+ disabled: requirePhiField(profile, "disabled", "true or false", profile.boolean),
17
+ spaces: requirePhiField(profile, "spaces", "a count", profile.integer),
18
+ }))),
19
+ siteSpaceProfileId: id("siteSpaceProfileId"),
20
+ defaultUserProfileId: nullableId("defaultUserProfileId"),
21
+ defaultGroupProfileId: nullableId("defaultGroupProfileId"),
22
+ allowedProfileIds: ids("allowedProfileIds"),
23
+ };
24
+ }
@@ -13,6 +13,8 @@ export type PhiBuilderNavigationItem = {
13
13
  /** The Area the reference resolves in, where it is not this Navigation's own. */
14
14
  targetArea?: PhiCmsAreaKey | null;
15
15
  targetDeleted?: boolean;
16
+ /** Another Area this entry enters at its root; its `href` is that Area's segment, not a path in this one. */
17
+ targetAreaRoot?: PhiCmsAreaKey;
16
18
  icon?: string | null;
17
19
  external?: boolean;
18
20
  newTab?: boolean;
@@ -67,6 +67,7 @@ function materializeNavigationItem(item, tombstones, customItems, overrides) {
67
67
  targetDeleted: customTarget.deleted === true,
68
68
  } : {}),
69
69
  icon: item.icon ?? null,
70
+ ...(item.target?.kind === "area" ? { targetAreaRoot: item.target.area } : {}),
70
71
  ...(item.target?.kind === "module"
71
72
  ? { targetPreset: { ownerModuleId: item.target.ownerModuleId, presetKey: item.target.presetKey } }
72
73
  : {}),
@@ -28,10 +28,20 @@ export type PhiPresetPageNode = {
28
28
  pageScopeId?: number;
29
29
  reference?: PhiPageReference;
30
30
  tombstoned?: boolean;
31
+ /**
32
+ * The address a rename moves the Page to once it is published, or absent while there is none.
33
+ *
34
+ * Until then the Page still answers on its current address, so every place that shows that address shows
35
+ * this beside it (`formatPhiBuilderPagePathWithPending`): an author who renamed a Page and saw the old path
36
+ * in the picker could only conclude the rename had been lost.
37
+ */
38
+ pendingPath?: string | null;
31
39
  pathLocked?: boolean;
32
40
  pathOwnershipReason?: string;
33
41
  children?: PhiPresetPageNode[];
34
42
  };
43
+ /** A Page's address as the Builder shows it: the current one, and where a pending rename moves it. */
44
+ export declare function formatPhiBuilderPagePathWithPending(path: string, pendingPath: string | null | undefined): string;
35
45
  export type PhiBuilderModulePresetPagesByArea = Record<PhiBuilderPageCatalogArea, PhiPresetPageNode[]>;
36
46
  export declare function createEmptyPhiBuilderModulePresetPagesByArea(): PhiBuilderModulePresetPagesByArea;
37
47
  export type PhiBuilderPageCatalogArea = PhiBuilderAreaKey;
@@ -70,6 +80,8 @@ export type PhiBuilderPersistedPageCatalogEntry = {
70
80
  publishedRevisionId?: number | null;
71
81
  workingDraftRevisionId?: number | null;
72
82
  tombstoned: boolean;
83
+ /** Where a pending rename moves the Page when it is published (`draft_path`). */
84
+ pendingPath?: string | null;
73
85
  };
74
86
  /** The page catalog of one Area, with preset, local and persisted pages merged. */
75
87
  export type PhiBuilderActivePageCatalog = ReturnType<typeof resolvePhiBuilderActivePageCatalog>;
@@ -1,5 +1,9 @@
1
1
  import { PHI_BUILDER_AREA_KEYS, resolvePhiBuilderAreaAsCmsArea, } from "../constants/cms-areas";
2
2
  import { createPhiPageReference, readPhiPageReference, } from "../types/references";
3
+ /** A Page's address as the Builder shows it: the current one, and where a pending rename moves it. */
4
+ export function formatPhiBuilderPagePathWithPending(path, pendingPath) {
5
+ return pendingPath && pendingPath !== path ? `${path} → ${pendingPath}` : path;
6
+ }
3
7
  export function createEmptyPhiBuilderModulePresetPagesByArea() {
4
8
  return PHI_BUILDER_AREA_KEYS.reduce((current, area) => ({ ...current, [area]: [] }), {});
5
9
  }
@@ -310,6 +314,7 @@ function mergePhiBuilderPageCatalogWithPersistedPages(area, presetPages, persist
310
314
  pageScopeId: page.id,
311
315
  reference: page.reference,
312
316
  tombstoned: page.tombstoned,
317
+ pendingPath: page.pendingPath ? normalizePhiBuilderCmsCatalogPath(page.pendingPath) : null,
313
318
  pathLocked: false,
314
319
  };
315
320
  if (!annotatePageCatalogNode(merged, (node) => node.storagePath != null && normalizePhiBuilderCmsCatalogPath(node.storagePath) === path, patch)) {
@@ -63,16 +63,30 @@ export declare function collectPhiSitemapCandidates({ moduleRoutes, publishedPag
63
63
  }>;
64
64
  }): PhiSitemapCandidate[];
65
65
  /**
66
- * The sitemap: one `<url>` per Page per locale, each carrying the whole hreflang set.
66
+ * The sitemap as one or more `<urlset>` documents: one `<url>` per Page per locale, each carrying the
67
+ * whole hreflang set.
67
68
  *
68
69
  * Every version lists every other one, itself included, because that is what makes the set
69
- * reciprocal -- and a set that is not reciprocal is ignored without a word.
70
+ * reciprocal -- and a set that is not reciprocal is ignored without a word. A file closes at 50,000
71
+ * URLs or 45 MB, whichever comes first; a Site that needs more than one is listed by a sitemap index
72
+ * (`renderPhiSitemapIndexXml`).
70
73
  */
74
+ export declare function renderPhiSitemapDocuments(pages: ReadonlyArray<PhiSitemapCandidate>, site: {
75
+ publicBase: string;
76
+ availableLocales: readonly string[];
77
+ defaultLocale: string;
78
+ }, limits?: {
79
+ maxUrls?: number;
80
+ maxBytes?: number;
81
+ }): string[];
82
+ /** The sitemap of a Site small enough for one file, which is nearly every Site. */
71
83
  export declare function renderPhiSitemapXml(pages: ReadonlyArray<PhiSitemapCandidate>, site: {
72
84
  publicBase: string;
73
85
  availableLocales: readonly string[];
74
86
  defaultLocale: string;
75
87
  }): string;
88
+ /** A sitemap index naming each part by its address. */
89
+ export declare function renderPhiSitemapIndexXml(partUrls: readonly string[]): string;
76
90
  /**
77
91
  * The robots.txt: everything allowed, and the sitemap named when there is one.
78
92
  *
@@ -90,25 +90,47 @@ function escapePhiXml(value) {
90
90
  .replace(/"/g, "&quot;")
91
91
  .replace(/'/g, "&apos;");
92
92
  }
93
+ /** What one sitemap file may hold (sitemaps.org): 50,000 URLs, and 50 MB uncompressed. */
94
+ const PHI_SITEMAP_MAX_URLS = 50_000;
95
+ /** Below the 50 MB limit, so the closing tag and a rounding of the count never cross it. */
96
+ const PHI_SITEMAP_MAX_BYTES = 45 * 1024 * 1024;
97
+ const PHI_SITEMAP_URLSET_OPEN = [
98
+ '<?xml version="1.0" encoding="UTF-8"?>',
99
+ '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">',
100
+ ].join("\n");
101
+ const PHI_SITEMAP_URLSET_CLOSE = "</urlset>";
102
+ const utf8 = new TextEncoder();
103
+ function utf8Length(value) {
104
+ return utf8.encode(value).length;
105
+ }
93
106
  /**
94
- * The sitemap: one `<url>` per Page per locale, each carrying the whole hreflang set.
107
+ * The sitemap as one or more `<urlset>` documents: one `<url>` per Page per locale, each carrying the
108
+ * whole hreflang set.
95
109
  *
96
110
  * Every version lists every other one, itself included, because that is what makes the set
97
- * reciprocal -- and a set that is not reciprocal is ignored without a word.
111
+ * reciprocal -- and a set that is not reciprocal is ignored without a word. A file closes at 50,000
112
+ * URLs or 45 MB, whichever comes first; a Site that needs more than one is listed by a sitemap index
113
+ * (`renderPhiSitemapIndexXml`).
98
114
  */
99
- export function renderPhiSitemapXml(pages, site) {
100
- const lines = [
101
- '<?xml version="1.0" encoding="UTF-8"?>',
102
- '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">',
103
- ];
115
+ export function renderPhiSitemapDocuments(pages, site, limits = {}) {
116
+ const maxUrls = limits.maxUrls ?? PHI_SITEMAP_MAX_URLS;
117
+ const maxBytes = limits.maxBytes ?? PHI_SITEMAP_MAX_BYTES;
118
+ const overhead = utf8Length(`${PHI_SITEMAP_URLSET_OPEN}\n${PHI_SITEMAP_URLSET_CLOSE}\n`);
119
+ const documents = [];
120
+ let entries = [];
121
+ let bytes = overhead;
122
+ const close = () => {
123
+ documents.push(`${[PHI_SITEMAP_URLSET_OPEN, ...entries, PHI_SITEMAP_URLSET_CLOSE].join("\n")}\n`);
124
+ entries = [];
125
+ bytes = overhead;
126
+ };
104
127
  for (const page of pages) {
105
128
  for (const locale of site.availableLocales) {
106
129
  const alternates = buildPhiPublicPageAlternates({ ...site, path: page.path, locale });
107
130
  if (!alternates) {
108
131
  continue;
109
132
  }
110
- lines.push(" <url>");
111
- lines.push(` <loc>${escapePhiXml(alternates.canonical)}</loc>`);
133
+ const lines = [" <url>", ` <loc>${escapePhiXml(alternates.canonical)}</loc>`];
112
134
  if (page.lastModified) {
113
135
  lines.push(` <lastmod>${escapePhiXml(page.lastModified)}</lastmod>`);
114
136
  }
@@ -116,10 +138,31 @@ export function renderPhiSitemapXml(pages, site) {
116
138
  lines.push(` <xhtml:link rel="alternate" hreflang="${escapePhiXml(hreflang)}" href="${escapePhiXml(href)}"/>`);
117
139
  }
118
140
  lines.push(" </url>");
141
+ const entry = lines.join("\n");
142
+ const entryBytes = utf8Length(entry) + 1;
143
+ if (entries.length > 0 && (entries.length >= maxUrls || bytes + entryBytes > maxBytes)) {
144
+ close();
145
+ }
146
+ entries.push(entry);
147
+ bytes += entryBytes;
119
148
  }
120
149
  }
121
- lines.push("</urlset>");
122
- return `${lines.join("\n")}\n`;
150
+ close();
151
+ return documents;
152
+ }
153
+ /** The sitemap of a Site small enough for one file, which is nearly every Site. */
154
+ export function renderPhiSitemapXml(pages, site) {
155
+ const documents = renderPhiSitemapDocuments(pages, site, { maxUrls: Number.POSITIVE_INFINITY, maxBytes: Number.POSITIVE_INFINITY });
156
+ return documents[0];
157
+ }
158
+ /** A sitemap index naming each part by its address. */
159
+ export function renderPhiSitemapIndexXml(partUrls) {
160
+ return `${[
161
+ '<?xml version="1.0" encoding="UTF-8"?>',
162
+ '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
163
+ ...partUrls.map((url) => ` <sitemap><loc>${escapePhiXml(url)}</loc></sitemap>`),
164
+ "</sitemapindex>",
165
+ ].join("\n")}\n`;
123
166
  }
124
167
  /**
125
168
  * The robots.txt: everything allowed, and the sitemap named when there is one.
@@ -18,6 +18,8 @@ export type PhiPublicRouteClaim = {
18
18
  title: string;
19
19
  /** The address the Module declared. What it actually answers on may have been assigned. */
20
20
  declaredPath: string;
21
+ /** That the Module answers in the published Public Area, not only in the Builder's draft. */
22
+ live?: boolean;
21
23
  };
22
24
  export type PhiPublicRouteAddressHolder = {
23
25
  kind: "module";
@@ -26,6 +28,7 @@ export type PhiPublicRouteAddressHolder = {
26
28
  } | {
27
29
  kind: "page";
28
30
  title: string;
31
+ published: boolean;
29
32
  };
30
33
  export type PhiPublicRoutePathCollision = {
31
34
  claim: PhiPublicRouteClaim;
@@ -55,6 +58,7 @@ export declare function buildPhiPublicRouteAddressMap({ claims, activeModuleIds,
55
58
  sitePages?: readonly {
56
59
  path: string;
57
60
  title: string;
61
+ published: boolean;
58
62
  }[];
59
63
  }): Map<string, PhiPublicRouteAddressHolder>;
60
64
  /**
@@ -23,7 +23,7 @@ export function buildPhiPublicRouteAddressMap({ claims, activeModuleIds, assignm
23
23
  const addresses = new Map();
24
24
  for (const page of sitePages) {
25
25
  if (!addresses.has(page.path)) {
26
- addresses.set(page.path, { kind: "page", title: page.title });
26
+ addresses.set(page.path, { kind: "page", title: page.title, published: page.published });
27
27
  }
28
28
  }
29
29
  for (const claim of claims) {
@@ -12,7 +12,7 @@ import type { PhiCmsSiteBridge } from "../types/cms-plugins";
12
12
  */
13
13
  export declare function buildPhiSitemapRouteHandler({ bridge }: {
14
14
  bridge: PhiCmsSiteBridge;
15
- }): () => Promise<Response>;
15
+ }): (request: Request) => Promise<Response>;
16
16
  /**
17
17
  * `GET /robots.txt`, which allows everything and names the sitemap when there is one.
18
18
  *