@phis/ui 0.4.23 → 0.5.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.
Files changed (102) 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/media/media-asset-typed-fields.d.ts +10 -0
  4. package/components/media/media-asset-typed-fields.js +19 -0
  5. package/components/media/media-settings-labels.d.ts +33 -0
  6. package/components/media/media-settings-labels.js +62 -0
  7. package/components/media/media-upload-flow.d.ts +19 -0
  8. package/components/media/media-upload-flow.js +38 -0
  9. package/components/media/phi-asset-focal-rect-widget.js +2 -2
  10. package/components/media/phi-image-inspector-widget.js +1 -1
  11. package/components/media/phi-image-preview-data.js +5 -4
  12. package/components/media/phi-site-font-assets.js +2 -5
  13. package/components/media/use-authoring-asset-details.js +0 -1
  14. package/components/regions/presets/navigation-redirect.d.ts +2 -2
  15. package/components/regions/presets/navigation-redirect.js +3 -3
  16. package/components/regions/presets/phi-area-shell-preset-nodes.js +2 -1
  17. package/components/widgets/helpers/internal-reference-resolver.server.d.ts +1 -1
  18. package/components/widgets/helpers/internal-reference-resolver.server.js +4 -0
  19. package/components/widgets/label-sets/builder-modules.js +6 -0
  20. package/components/widgets/label-types/builder-modules.d.ts +4 -0
  21. package/components/widgets/label-types/builder-modules.js +3 -0
  22. package/constants/runtime-module-ownership.js +4 -0
  23. package/gateway/internal-references.d.ts +5 -0
  24. package/gateway/internal-references.js +12 -12
  25. package/gateway/site-media-settings.d.ts +2 -0
  26. package/gateway/site-media-settings.js +6 -1
  27. package/gateway/site-media-storage-reader.d.ts +19 -0
  28. package/gateway/site-media-storage-reader.js +24 -0
  29. package/helpers/cms-navigation-catalog.d.ts +2 -0
  30. package/helpers/cms-navigation-catalog.js +1 -0
  31. package/helpers/cms-page-catalog.d.ts +12 -0
  32. package/helpers/cms-page-catalog.js +5 -0
  33. package/helpers/phi-seo.d.ts +16 -2
  34. package/helpers/phi-seo.js +54 -11
  35. package/helpers/public-route-claims.d.ts +4 -0
  36. package/helpers/public-route-claims.js +1 -1
  37. package/next/seo-routes.d.ts +1 -1
  38. package/next/seo-routes.js +23 -5
  39. package/package.json +1 -1
  40. package/plugins/runtime-modules/area-definitions.d.ts +75 -6
  41. package/plugins/runtime-modules/area-definitions.js +20 -0
  42. package/plugins/runtime-modules/asset/client-data-providers.js +12 -0
  43. package/plugins/runtime-modules/asset/controller/runtime.js +1 -1
  44. package/plugins/runtime-modules/asset/data-providers.d.ts +27 -2
  45. package/plugins/runtime-modules/asset/data-providers.js +56 -0
  46. package/plugins/runtime-modules/asset/definition.d.ts +38 -2
  47. package/plugins/runtime-modules/asset/definition.js +2 -1
  48. package/plugins/runtime-modules/asset/ids.d.ts +4 -0
  49. package/plugins/runtime-modules/asset/ids.js +4 -0
  50. package/plugins/runtime-modules/asset/server.js +2 -1
  51. package/plugins/runtime-modules/asset/services/options.d.ts +7 -0
  52. package/plugins/runtime-modules/asset/services/options.js +38 -0
  53. package/plugins/runtime-modules/asset/services/storage-spaces-table.d.ts +3 -0
  54. package/plugins/runtime-modules/asset/services/storage-spaces-table.js +89 -0
  55. package/plugins/runtime-modules/asset/settings-forms.d.ts +17 -0
  56. package/plugins/runtime-modules/asset/settings-forms.js +117 -1
  57. package/plugins/runtime-modules/asset/trees/phi-default-admin-media-settings-page-tree.js +94 -1
  58. package/plugins/runtime-modules/builder/area-shell-presets.server.d.ts +8 -0
  59. package/plugins/runtime-modules/builder/area-shell-presets.server.js +13 -0
  60. package/plugins/runtime-modules/builder/controller/page-controller-helpers.js +1 -1
  61. package/plugins/runtime-modules/builder/controller/page-controller.d.ts +1 -1
  62. package/plugins/runtime-modules/builder/controller/page-controller.js +30 -3
  63. package/plugins/runtime-modules/builder/controller/server-definition.d.ts +7 -1
  64. package/plugins/runtime-modules/builder/controller/server-definition.js +8 -3
  65. package/plugins/runtime-modules/builder/data-providers.js +1 -0
  66. package/plugins/runtime-modules/builder/developer-workspace-types.d.ts +2 -0
  67. package/plugins/runtime-modules/builder/navigation-path-context.js +7 -3
  68. package/plugins/runtime-modules/builder/options-providers.js +2 -2
  69. package/plugins/runtime-modules/builder/page-address-rule.d.ts +39 -0
  70. package/plugins/runtime-modules/builder/page-address-rule.js +62 -0
  71. package/plugins/runtime-modules/builder/page-meta-form.js +10 -0
  72. package/plugins/runtime-modules/builder/public-route-collisions.js +7 -2
  73. package/plugins/runtime-modules/builder/services/page-source-tree.js +2 -1
  74. package/plugins/runtime-modules/builder/services/runtime-modules-table.js +49 -1
  75. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +14 -2
  76. package/plugins/runtime-modules/core/widgets/breadcrumb/client.d.ts +14 -2
  77. package/plugins/runtime-modules/core/widgets/breadcrumb/client.js +35 -4
  78. package/plugins/runtime-modules/core/widgets/breadcrumb/server.d.ts +3 -1
  79. package/plugins/runtime-modules/core/widgets/breadcrumb/server.js +37 -2
  80. package/plugins/runtime-modules/core/widgets/card/editor.js +1 -1
  81. package/plugins/runtime-modules/core/widgets/image/client.js +1 -1
  82. package/plugins/runtime-modules/core/widgets/image/editor.js +1 -1
  83. package/plugins/runtime-modules/core/widgets/page-title/authoring.js +3 -1
  84. package/plugins/runtime-modules/core/widgets/page-title/client.d.ts +3 -1
  85. package/plugins/runtime-modules/core/widgets/page-title/client.js +5 -1
  86. package/plugins/runtime-modules/core/widgets/page-title/config.d.ts +25 -3
  87. package/plugins/runtime-modules/core/widgets/page-title/config.js +24 -3
  88. package/plugins/runtime-modules/core/widgets/page-title/plugin.js +1 -1
  89. package/plugins/runtime-modules/core/widgets/page-title/server.d.ts +3 -1
  90. package/plugins/runtime-modules/core/widgets/page-title/server.js +4 -3
  91. package/plugins/runtime-modules/core/widgets/table/client.js +1 -1
  92. package/plugins/runtime-modules/core/widgets/table/config.js +9 -0
  93. package/plugins/runtime-modules/descriptor-compiler.js +33 -8
  94. package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +1 -1
  95. package/server-helpers/cms-review-params.d.ts +25 -0
  96. package/server-helpers/cms-review-params.js +54 -0
  97. package/server-helpers/cms-review.d.ts +1 -25
  98. package/server-helpers/cms-review.js +2 -54
  99. package/types/cms-module-descriptors.d.ts +33 -3
  100. package/types/media.d.ts +6 -2
  101. package/types/table-widget.d.ts +11 -0
  102. package/types.d.ts +1 -1
@@ -6,7 +6,63 @@ export const PHI_MEDIA_FOLDER_IMAGES_SORTS = ["name_asc", "created_at_desc"];
6
6
  export const PHI_MEDIA_FOLDER_IMAGES_DEFAULT_LIMIT = 50;
7
7
  /** What the server hands out at most (`/api/v1/site/media/folder-images`). */
8
8
  export const PHI_MEDIA_FOLDER_IMAGES_MAX_LIMIT = 200;
9
+ /** The existing User and Group Spaces, one resource per kind, for the Admin storage table. */
10
+ export const PHI_ASSET_STORAGE_SPACES_RESOURCES = [
11
+ {
12
+ resourceKey: "userSpaces",
13
+ title: "User Spaces",
14
+ rowIdentityPath: "id",
15
+ fields: [
16
+ { key: "id", title: "Space", type: "number", required: true },
17
+ { key: "owner", title: "Owner", type: "string", required: true },
18
+ { key: "email", title: "Email", type: "string" },
19
+ { key: "storageProfileId", title: "Storage profile", type: "string", required: true, mutable: true },
20
+ // Megabytes, as every quota field of the settings states them. Empty inherits the Site default.
21
+ { key: "quotaMegabytes", title: "Quota", type: "number", mutable: true, constraints: { min: 0 } },
22
+ { key: "effectiveQuotaMegabytes", title: "Effective quota", type: "number" },
23
+ { key: "usedMegabytes", title: "Used", type: "number" },
24
+ ],
25
+ query: { search: true, sorting: "none", pagination: "offset", total: true },
26
+ actions: [{ key: "refresh", title: "Refresh", scope: "resource" }],
27
+ },
28
+ {
29
+ resourceKey: "groupSpaces",
30
+ title: "Group Spaces",
31
+ rowIdentityPath: "id",
32
+ fields: [
33
+ { key: "id", title: "Space", type: "number", required: true },
34
+ { key: "owner", title: "Owner", type: "string", required: true },
35
+ { key: "email", title: "Email", type: "string" },
36
+ { key: "storageProfileId", title: "Storage profile", type: "string", required: true, mutable: true },
37
+ // Megabytes, as every quota field of the settings states them. Empty inherits the Site default.
38
+ { key: "quotaMegabytes", title: "Quota", type: "number", mutable: true, constraints: { min: 0 } },
39
+ { key: "effectiveQuotaMegabytes", title: "Effective quota", type: "number" },
40
+ { key: "usedMegabytes", title: "Used", type: "number" },
41
+ ],
42
+ query: { search: true, sorting: "none", pagination: "offset", total: true },
43
+ actions: [{ key: "refresh", title: "Refresh", scope: "resource" }],
44
+ },
45
+ ];
9
46
  export const PHI_ASSET_RUNTIME_DATA_PROVIDER_DESCRIPTORS = [
47
+ {
48
+ key: PHI_ASSET_RUNTIME_DATA_PROVIDER_KEYS.mediaStorageSpaces,
49
+ ownerModuleId: PHI_ASSET_RUNTIME_MODULE_ID,
50
+ kind: "table",
51
+ executionMode: "live",
52
+ authoringMode: "none",
53
+ title: "Media Spaces and their storage",
54
+ description: "The site's existing User and Group Spaces, with the storage profile each writes to and its quota.",
55
+ resources: PHI_ASSET_STORAGE_SPACES_RESOURCES,
56
+ },
57
+ {
58
+ key: PHI_ASSET_RUNTIME_DATA_PROVIDER_KEYS.mediaStorageProfiles,
59
+ ownerModuleId: PHI_ASSET_RUNTIME_MODULE_ID,
60
+ kind: "options",
61
+ executionMode: "live",
62
+ authoringMode: "none",
63
+ title: "Storage profiles",
64
+ description: "The site's storage profiles, for a setting that points Spaces at one.",
65
+ },
10
66
  {
11
67
  key: PHI_ASSET_RUNTIME_DATA_PROVIDER_KEYS.mediaFolderChoices,
12
68
  ownerModuleId: PHI_ASSET_RUNTIME_MODULE_ID,
@@ -11,6 +11,17 @@ export declare const PHI_ASSET_RUNTIME_MODULE_DEFINITION: {
11
11
  iconFamily: string;
12
12
  controllerMountPolicy: "area";
13
13
  dataProviders: ({
14
+ key: `${string}/${string}`;
15
+ ownerModuleId: "@phis/ui/modules/asset";
16
+ kind: "table";
17
+ executionMode: "live";
18
+ authoringMode: "none";
19
+ title: string;
20
+ description: string;
21
+ resources: readonly import("../../../types").PhiTableProviderResourceDescriptor[];
22
+ availableToAuthoringChrome?: undefined;
23
+ settingsFields?: undefined;
24
+ } | {
14
25
  key: `${string}/${string}`;
15
26
  ownerModuleId: "@phis/ui/modules/asset";
16
27
  kind: "options";
@@ -18,9 +29,20 @@ export declare const PHI_ASSET_RUNTIME_MODULE_DEFINITION: {
18
29
  authoringMode: "none";
19
30
  title: string;
20
31
  description: string;
21
- availableToAuthoringChrome: true;
32
+ resources?: undefined;
33
+ availableToAuthoringChrome?: undefined;
22
34
  settingsFields?: undefined;
35
+ } | {
36
+ key: `${string}/${string}`;
37
+ ownerModuleId: "@phis/ui/modules/asset";
38
+ kind: "options";
39
+ executionMode: "live";
40
+ authoringMode: "none";
41
+ title: string;
42
+ description: string;
43
+ availableToAuthoringChrome: true;
23
44
  resources?: undefined;
45
+ settingsFields?: undefined;
24
46
  } | {
25
47
  key: `${string}/${string}`;
26
48
  ownerModuleId: "@phis/ui/modules/asset";
@@ -75,8 +97,8 @@ export declare const PHI_ASSET_RUNTIME_MODULE_DEFINITION: {
75
97
  description?: undefined;
76
98
  options?: undefined;
77
99
  })[];
78
- availableToAuthoringChrome?: undefined;
79
100
  resources?: undefined;
101
+ availableToAuthoringChrome?: undefined;
80
102
  } | {
81
103
  key: `${string}/${string}`;
82
104
  ownerModuleId: "@phis/ui/modules/asset";
@@ -158,6 +180,20 @@ export declare const PHI_ASSET_RUNTIME_MODULE_DEFINITION: {
158
180
  csrfPath: null;
159
181
  requiresCsrf: false;
160
182
  credentialPolicy: "site-session";
183
+ } | {
184
+ key: `${string}/${string}`;
185
+ ownerModuleId: "@phis/ui/modules/asset";
186
+ title: string;
187
+ phase: "submit";
188
+ handlerKey: "site.admin.media-storage-settings";
189
+ category: "site";
190
+ transport: "relay";
191
+ method: "PATCH";
192
+ endpointKey: null;
193
+ upstreamPath: string;
194
+ csrfPath: null;
195
+ requiresCsrf: false;
196
+ credentialPolicy: "site-session";
161
197
  } | {
162
198
  key: `${string}/${string}`;
163
199
  ownerModuleId: "@phis/ui/modules/asset";
@@ -7,7 +7,7 @@ import { PHI_CMS_AREA_KEYS } from "../../../constants/cms-areas";
7
7
  import { PHI_CORE_SERVER_BINDING } from "../../../types/server-capabilities";
8
8
  import { PHI_ASSET_FOLDER_FORM_HANDLER_PROVIDER_DESCRIPTOR, PHI_ASSET_METADATA_FORM_HANDLER_PROVIDER_DESCRIPTOR, } from "./metadata-form";
9
9
  import { PHI_ASSET_FOCAL_RECT_FORM_PROVIDER_DESCRIPTOR } from "./form-providers";
10
- import { PHI_MEDIA_SETTINGS_FORM_HANDLER_PROVIDER_DESCRIPTOR } from "./settings-forms";
10
+ import { PHI_MEDIA_SETTINGS_FORM_HANDLER_PROVIDER_DESCRIPTOR, PHI_MEDIA_STORAGE_SETTINGS_FORM_HANDLER_PROVIDER_DESCRIPTOR, } from "./settings-forms";
11
11
  export const PHI_ASSET_RUNTIME_MODULE_DEFINITION = {
12
12
  moduleId: PHI_ASSET_RUNTIME_MODULE_ID,
13
13
  kind: "module",
@@ -35,6 +35,7 @@ export const PHI_ASSET_RUNTIME_MODULE_DEFINITION = {
35
35
  PHI_ASSET_METADATA_FORM_HANDLER_PROVIDER_DESCRIPTOR,
36
36
  PHI_ASSET_FOLDER_FORM_HANDLER_PROVIDER_DESCRIPTOR,
37
37
  PHI_MEDIA_SETTINGS_FORM_HANDLER_PROVIDER_DESCRIPTOR,
38
+ PHI_MEDIA_STORAGE_SETTINGS_FORM_HANDLER_PROVIDER_DESCRIPTOR,
38
39
  ],
39
40
  },
40
41
  };
@@ -13,6 +13,10 @@ export declare const PHI_ASSET_RUNTIME_DATA_PROVIDER_KEYS: {
13
13
  * Media page's store, which is not there when a Gallery is configured on some other page.
14
14
  */
15
15
  readonly mediaFolderChoices: `${string}/${string}`;
16
+ /** The Site's Storage Profiles, for the Admin storage settings that point Spaces at one. */
17
+ readonly mediaStorageProfiles: `${string}/${string}`;
18
+ /** The existing User and Group Spaces with their Profile and quota, for the Admin storage table. */
19
+ readonly mediaStorageSpaces: `${string}/${string}`;
16
20
  };
17
21
  /** The card this Module ships for its own items; a Site may name another. */
18
22
  export declare const PHI_ASSET_RUNTIME_ITEM_RENDERER_KEY: `${string}/${string}`;
@@ -16,6 +16,10 @@ export const PHI_ASSET_RUNTIME_DATA_PROVIDER_KEYS = {
16
16
  * Media page's store, which is not there when a Gallery is configured on some other page.
17
17
  */
18
18
  mediaFolderChoices: createPhiSharedRuntimeDataProviderKey("options", "media-folder-choices"),
19
+ /** The Site's Storage Profiles, for the Admin storage settings that point Spaces at one. */
20
+ mediaStorageProfiles: createPhiSharedRuntimeDataProviderKey("options", "media-storage-profiles"),
21
+ /** The existing User and Group Spaces with their Profile and quota, for the Admin storage table. */
22
+ mediaStorageSpaces: createPhiSharedRuntimeDataProviderKey("tables", "media-storage-spaces"),
19
23
  };
20
24
  /** The card this Module ships for its own items; a Site may name another. */
21
25
  export const PHI_ASSET_RUNTIME_ITEM_RENDERER_KEY = PHI_MEDIA_LIBRARY_ITEM_RENDERER_KEY;
@@ -1,5 +1,5 @@
1
1
  import { PHI_ASSET_FOLDER_RUNTIME_MODULE_FORM, PHI_ASSET_METADATA_RUNTIME_MODULE_FORM, } from "./metadata-form";
2
- import { PHI_MEDIA_SETTINGS_RUNTIME_MODULE_FORM } from "./settings-forms";
2
+ import { PHI_MEDIA_SETTINGS_RUNTIME_MODULE_FORM, PHI_MEDIA_STORAGE_SETTINGS_RUNTIME_MODULE_FORM } from "./settings-forms";
3
3
  import { definePhiRuntimeModuleServerAreaContribution } from "../area-contributions";
4
4
  import { PHI_ASSET_RUNTIME_MODULE_DEFINITION } from "./definition";
5
5
  import { PHI_ASSET_RUNTIME_DATA_PROVIDER_KEYS } from "./ids";
@@ -20,6 +20,7 @@ export function createPhiAssetRuntimeModuleServerAreaContribution() {
20
20
  PHI_ASSET_METADATA_RUNTIME_MODULE_FORM,
21
21
  PHI_ASSET_FOLDER_RUNTIME_MODULE_FORM,
22
22
  PHI_MEDIA_SETTINGS_RUNTIME_MODULE_FORM,
23
+ PHI_MEDIA_STORAGE_SETTINGS_RUNTIME_MODULE_FORM,
23
24
  ],
24
25
  routes: PHI_ASSET_RUNTIME_MODULE_ROUTES,
25
26
  uiProvider: true,
@@ -4,3 +4,10 @@ export declare const PhiMediaFoldersOptionsProviderClient: import("react").Compo
4
4
  export declare const PhiMediaFolderChoicesOptionsProviderClient: import("react").ComponentType<{
5
5
  children: import("react").ReactNode;
6
6
  }>;
7
+ /**
8
+ * The Site's Storage Profiles as choices, by id. Named by key and Provider, because that is what the
9
+ * operator gave them; the key alone does not say whether a Profile is local or a bucket.
10
+ */
11
+ export declare const PhiMediaStorageProfilesOptionsProviderClient: import("react").ComponentType<{
12
+ children: import("react").ReactNode;
13
+ }>;
@@ -93,3 +93,41 @@ export const PhiMediaFolderChoicesOptionsProviderClient = createPhiControlOption
93
93
  };
94
94
  },
95
95
  });
96
+ const STORAGE_SETTINGS_PATH = "/api/site/admin/media/storage";
97
+ async function loadStorageProfiles() {
98
+ const response = await fetch(STORAGE_SETTINGS_PATH, {
99
+ cache: "no-store",
100
+ credentials: "include",
101
+ headers: { accept: "application/json" },
102
+ });
103
+ const payload = await response.json().catch(() => null);
104
+ if (!response.ok)
105
+ throw new Error("Failed to load the site's storage profiles.");
106
+ // Only what a choice shows. A profile this cannot name is left out rather than offered as a guess.
107
+ const profiles = isPhiRecord(payload) && isPhiRecord(payload.storage) && Array.isArray(payload.storage.profiles)
108
+ ? payload.storage.profiles
109
+ : null;
110
+ if (!profiles)
111
+ throw new Error("The storage settings route answered without its profiles.");
112
+ return profiles.flatMap((profile) => isPhiRecord(profile) && Number.isSafeInteger(profile.id) && typeof profile.key === "string"
113
+ && typeof profile.providerId === "string"
114
+ ? [{ id: profile.id, key: profile.key, providerId: profile.providerId }]
115
+ : []);
116
+ }
117
+ /**
118
+ * The Site's Storage Profiles as choices, by id. Named by key and Provider, because that is what the
119
+ * operator gave them; the key alone does not say whether a Profile is local or a bucket.
120
+ */
121
+ export const PhiMediaStorageProfilesOptionsProviderClient = createPhiControlOptionsProviderClient({
122
+ key: PHI_ASSET_RUNTIME_DATA_PROVIDER_KEYS.mediaStorageProfiles,
123
+ load: loadStorageProfiles,
124
+ resolveLoadKey: () => "site-media-storage-profiles",
125
+ resolve: (context) => {
126
+ const profiles = Array.isArray(context.asyncData)
127
+ ? context.asyncData
128
+ : [];
129
+ return {
130
+ options: profiles.map((profile) => ({ value: String(profile.id), label: `${profile.key} (${profile.providerId})` })),
131
+ };
132
+ },
133
+ });
@@ -0,0 +1,3 @@
1
+ export declare const PhiMediaStorageSpacesTableProviderClient: import("react").ComponentType<{
2
+ children: import("react").ReactNode;
3
+ }>;
@@ -0,0 +1,89 @@
1
+ "use client";
2
+ import { isPhiRecord } from "../../../../helpers/is-record";
3
+ import { PhiTableProviderError, } from "../../../../types/table-widget";
4
+ import { createPhiTableProviderClient } from "../../../../components/widgets/client/shared/phi-table-provider";
5
+ import { readPhiTableProviderResponse, } from "../../../../components/widgets/client/shared/phi-table-provider-response";
6
+ import { phiBytesToStorageSize, phiStorageSizeToBytes } from "../../../../components/forms/storage-size";
7
+ import { PHI_ASSET_RUNTIME_DATA_PROVIDER_KEYS } from "../ids";
8
+ import { PHI_ASSET_STORAGE_SPACES_RESOURCES } from "../data-providers";
9
+ /*
10
+ * The existing User and Group Spaces with the Profile each writes to and its own quota, read and written
11
+ * through `/api/site/admin/media/spaces`. Sizes travel in bytes and are shown in megabytes, as every
12
+ * quota field of the Media settings states them; an emptied quota inherits the Site default again.
13
+ */
14
+ const API_PATH = "/api/site/admin/media/spaces";
15
+ const RESPONSE_OPTIONS = { subject: "Media Space" };
16
+ const KIND_BY_RESOURCE = { userSpaces: "user", groupSpaces: "group" };
17
+ function toRow(entry) {
18
+ return {
19
+ id: entry.id,
20
+ owner: entry.owner,
21
+ email: entry.email ?? null,
22
+ storageProfileId: entry.storageProfileId == null ? null : String(entry.storageProfileId),
23
+ quotaMegabytes: phiBytesToStorageSize(entry.quotaBytes),
24
+ effectiveQuotaMegabytes: phiBytesToStorageSize(entry.effectiveQuotaBytes),
25
+ usedMegabytes: phiBytesToStorageSize(entry.usedBytes),
26
+ };
27
+ }
28
+ function readKind(resourceKey) {
29
+ const kind = KIND_BY_RESOURCE[resourceKey];
30
+ if (!kind)
31
+ throw new PhiTableProviderError("resource-not-found", `Unknown Media Space resource "${resourceKey}".`);
32
+ return kind;
33
+ }
34
+ async function querySpaces({ resourceKey, query, signal }) {
35
+ const kind = readKind(resourceKey);
36
+ const params = new URLSearchParams({
37
+ kind,
38
+ page: String(query.page && query.page > 0 ? query.page : 1),
39
+ pageSize: String(query.pageSize && query.pageSize > 0 ? query.pageSize : 25),
40
+ });
41
+ const search = query.search?.trim();
42
+ if (search)
43
+ params.set("search", search);
44
+ const result = await readPhiTableProviderResponse(await fetch(`${API_PATH}?${params.toString()}`, {
45
+ cache: "no-store",
46
+ credentials: "include",
47
+ headers: { accept: "application/json" },
48
+ signal,
49
+ }), RESPONSE_OPTIONS);
50
+ const rows = (Array.isArray(result?.spaces) ? result.spaces : []).filter(isPhiRecord).map(toRow);
51
+ return { rows, total: typeof result?.total === "number" ? result.total : rows.length };
52
+ }
53
+ async function mutateSpace(request) {
54
+ readKind(request.resourceKey);
55
+ if (request.kind !== "field") {
56
+ throw new PhiTableProviderError("mutation-not-supported", "Media Spaces take edits of their profile and quota only.");
57
+ }
58
+ const spaceId = "rowIdentity" in request ? Number(request.rowIdentity) : Number.NaN;
59
+ if (!Number.isSafeInteger(spaceId) || spaceId <= 0) {
60
+ throw new PhiTableProviderError("invalid-query", "A Media Space edit needs the Space.");
61
+ }
62
+ let body;
63
+ if (request.fieldKey === "storageProfileId" && typeof request.proposedValue === "string") {
64
+ body = { storageProfileId: request.proposedValue };
65
+ }
66
+ else if (request.fieldKey === "quotaMegabytes"
67
+ && (request.proposedValue === null || typeof request.proposedValue === "number")) {
68
+ body = { quotaBytes: phiStorageSizeToBytes(request.proposedValue) };
69
+ }
70
+ else {
71
+ throw new PhiTableProviderError("invalid-field-value", "Only the profile and the quota can be edited.");
72
+ }
73
+ await readPhiTableProviderResponse(await fetch(`${API_PATH}/${spaceId}`, {
74
+ method: "PATCH",
75
+ cache: "no-store",
76
+ credentials: "include",
77
+ headers: { accept: "application/json", "content-type": "application/json" },
78
+ body: JSON.stringify(body),
79
+ signal: request.signal,
80
+ }), RESPONSE_OPTIONS);
81
+ // The effective quota follows from the override and the Site default, which only the server combines.
82
+ return { status: "accepted", invalidation: "view", canonicalValue: request.proposedValue };
83
+ }
84
+ export const PhiMediaStorageSpacesTableProviderClient = createPhiTableProviderClient({
85
+ key: PHI_ASSET_RUNTIME_DATA_PROVIDER_KEYS.mediaStorageSpaces,
86
+ resources: PHI_ASSET_STORAGE_SPACES_RESOURCES,
87
+ query: querySpaces,
88
+ mutate: mutateSpace,
89
+ });
@@ -1,5 +1,22 @@
1
1
  export declare const PHI_MEDIA_SETTINGS_FORM_IDS: {
2
2
  readonly general: `${string}/forms/${string}`;
3
+ readonly storage: `${string}/forms/${string}`;
4
+ };
5
+ export declare const PHI_MEDIA_STORAGE_SETTINGS_RUNTIME_MODULE_FORM: import("../contracts").PhiRuntimeModuleFormDefinition;
6
+ export declare const PHI_MEDIA_STORAGE_SETTINGS_FORM_HANDLER_PROVIDER_DESCRIPTOR: {
7
+ key: `${string}/${string}`;
8
+ ownerModuleId: "@phis/ui/modules/asset";
9
+ title: string;
10
+ phase: "submit";
11
+ handlerKey: "site.admin.media-storage-settings";
12
+ category: "site";
13
+ transport: "relay";
14
+ method: "PATCH";
15
+ endpointKey: null;
16
+ upstreamPath: string;
17
+ csrfPath: null;
18
+ requiresCsrf: false;
19
+ credentialPolicy: "site-session";
3
20
  };
4
21
  export declare const PHI_MEDIA_SETTINGS_RUNTIME_MODULE_FORM: import("../contracts").PhiRuntimeModuleFormDefinition;
5
22
  export declare const PHI_MEDIA_SETTINGS_FORM_HANDLER_PROVIDER_DESCRIPTOR: {
@@ -1,4 +1,4 @@
1
- import { PHI_ASSET_RUNTIME_MODULE_ID } from "./ids";
1
+ import { PHI_ASSET_RUNTIME_DATA_PROVIDER_KEYS, PHI_ASSET_RUNTIME_MODULE_ID } from "./ids";
2
2
  import { createPhiFormId } from "../../../types/form-id";
3
3
  import { PHI_SHARED_PACKAGE_NAME } from "../../../types/signals";
4
4
  import { PHI_FORM_GRID_LAST_LINE } from "../../../components/forms/form-descriptor-contract";
@@ -9,9 +9,11 @@ import { readPhiServerApiCredentials } from "../../../helpers/phis-server-creden
9
9
  import { phiFormLabel as label } from "../../../components/forms/form-descriptor-text";
10
10
  export const PHI_MEDIA_SETTINGS_FORM_IDS = {
11
11
  general: createPhiFormId(PHI_SHARED_PACKAGE_NAME, "asset/media-settings"),
12
+ storage: createPhiFormId(PHI_SHARED_PACKAGE_NAME, "asset/media-storage-settings"),
12
13
  };
13
14
  const PHI_MEDIA_SETTINGS_FORM_HANDLER_KEYS = {
14
15
  general: "site.admin.media-settings",
16
+ storage: "site.admin.media-storage-settings",
15
17
  };
16
18
  const LABEL_SET_KEY = "@phis/ui/modules/asset/labels/settings";
17
19
  const PHI_MEDIA_SETTINGS_FORM_DESCRIPTOR = {
@@ -119,6 +121,66 @@ const PHI_MEDIA_SETTINGS_FORM_DESCRIPTOR = {
119
121
  },
120
122
  },
121
123
  };
124
+ const profileChoices = { providerKey: PHI_ASSET_RUNTIME_DATA_PROVIDER_KEYS.mediaStorageProfiles };
125
+ /**
126
+ * Where the Site's Spaces write, among the Storage Profiles the operator created with `phis storage add`.
127
+ *
128
+ * Every choice is a Profile id; an emptied default is the Site's Local Profile, an emptied list offers
129
+ * every Profile, and the paused list is the whole set -- a Profile left out of it takes uploads again.
130
+ * The server refuses what does not fit (a Space pointed at a Profile outside the offered list, or newly at
131
+ * a paused one, or a Provider one serving Instance lacks) and says why.
132
+ */
133
+ const PHI_MEDIA_STORAGE_SETTINGS_FORM_DESCRIPTOR = {
134
+ schemaVersion: 1,
135
+ key: PHI_MEDIA_SETTINGS_FORM_IDS.storage,
136
+ labelSetKey: LABEL_SET_KEY,
137
+ fields: [
138
+ {
139
+ key: "siteSpaceProfileId",
140
+ fieldProviderKey: PHI_FORM_FIELD_PROVIDER_KEYS.select,
141
+ label: label("storageSiteSpace", "Site Space"),
142
+ description: label("storageSiteSpaceHint", "Where uploads into the site's own media go."),
143
+ optionsProvider: profileChoices,
144
+ validation: [{
145
+ providerKey: PHI_FORM_VALIDATION_PROVIDER_KEYS.required,
146
+ message: label("storageSiteSpaceRequired", "Choose where the site's own media is stored."),
147
+ }],
148
+ },
149
+ {
150
+ key: "defaultUserProfileId",
151
+ fieldProviderKey: PHI_FORM_FIELD_PROVIDER_KEYS.select,
152
+ label: label("storageDefaultUser", "New User Spaces"),
153
+ description: label("storageDefaultUserHint", "Where a User Space created from now on writes. Existing User Spaces keep theirs."),
154
+ placeholder: label("storageLocal", "Local storage"),
155
+ optionsProvider: profileChoices,
156
+ },
157
+ {
158
+ key: "defaultGroupProfileId",
159
+ fieldProviderKey: PHI_FORM_FIELD_PROVIDER_KEYS.select,
160
+ label: label("storageDefaultGroup", "New Group Spaces"),
161
+ description: label("storageDefaultGroupHint", "Where a Group Space created from now on writes. Existing Group Spaces keep theirs."),
162
+ placeholder: label("storageLocal", "Local storage"),
163
+ optionsProvider: profileChoices,
164
+ },
165
+ {
166
+ key: "allowedProfileIds",
167
+ fieldProviderKey: PHI_FORM_FIELD_PROVIDER_KEYS.multiSelect,
168
+ label: label("storageAllowed", "Offered profiles"),
169
+ description: label("storageAllowedHint", "The storage profiles a Space may be pointed at. Empty offers every profile."),
170
+ placeholder: label("storageAll", "All profiles"),
171
+ optionsProvider: profileChoices,
172
+ },
173
+ {
174
+ key: "disabledProfileIds",
175
+ fieldProviderKey: PHI_FORM_FIELD_PROVIDER_KEYS.multiSelect,
176
+ label: label("storageDisabled", "Paused profiles"),
177
+ description: label("storageDisabledHint", "A paused profile still delivers what it holds but takes no new uploads."),
178
+ placeholder: label("storageNone", "None"),
179
+ optionsProvider: profileChoices,
180
+ },
181
+ ],
182
+ layout: PHI_MEDIA_SETTINGS_FORM_DESCRIPTOR.layout,
183
+ };
122
184
  async function loadLabels(context) {
123
185
  const { getPhiMediaSettingsPageLabels } = await import("../../../components/media/media-settings-labels");
124
186
  const labels = await getPhiMediaSettingsPageLabels({
@@ -146,6 +208,60 @@ async function loadLabels(context) {
146
208
  unlimited: labels.fields.unlimited,
147
209
  });
148
210
  }
211
+ async function loadStorageLabels(context) {
212
+ const { getPhiMediaSettingsPageLabels } = await import("../../../components/media/media-settings-labels");
213
+ const labels = await getPhiMediaSettingsPageLabels({
214
+ apiBaseUrl: readPhiServerApiCredentials().apiBaseUrl,
215
+ internalToken: readPhiServerApiCredentials().internalToken,
216
+ locale: context.runtime.locale.current,
217
+ });
218
+ return flattenPhiFormLabels({
219
+ actions: { submitLabel: labels.submitLabel },
220
+ storageSiteSpace: labels.storage.siteSpace,
221
+ storageSiteSpaceHint: labels.storage.siteSpaceHint,
222
+ storageSiteSpaceRequired: labels.storage.siteSpaceRequired,
223
+ storageDefaultUser: labels.storage.defaultUser,
224
+ storageDefaultUserHint: labels.storage.defaultUserHint,
225
+ storageDefaultGroup: labels.storage.defaultGroup,
226
+ storageDefaultGroupHint: labels.storage.defaultGroupHint,
227
+ storageLocal: labels.storage.local,
228
+ storageAllowed: labels.storage.allowed,
229
+ storageAllowedHint: labels.storage.allowedHint,
230
+ storageAll: labels.storage.all,
231
+ storageDisabled: labels.storage.disabled,
232
+ storageDisabledHint: labels.storage.disabledHint,
233
+ storageNone: labels.storage.none,
234
+ });
235
+ }
236
+ export const PHI_MEDIA_STORAGE_SETTINGS_RUNTIME_MODULE_FORM = definePhiRuntimeModuleForm({
237
+ ownerModuleId: PHI_ASSET_RUNTIME_MODULE_ID,
238
+ areas: ["admin"],
239
+ formId: PHI_MEDIA_SETTINGS_FORM_IDS.storage,
240
+ version: 1,
241
+ flags: 0,
242
+ title: "Media storage settings",
243
+ description: "Which storage profile the site's Spaces write to, which are offered, and which are paused.",
244
+ category: "forms",
245
+ tags: ["settings", "media", "storage", "admin"],
246
+ descriptor: PHI_MEDIA_STORAGE_SETTINGS_FORM_DESCRIPTOR,
247
+ submitHandlerKey: PHI_MEDIA_SETTINGS_FORM_HANDLER_KEYS.storage,
248
+ loadLabels: loadStorageLabels,
249
+ });
250
+ export const PHI_MEDIA_STORAGE_SETTINGS_FORM_HANDLER_PROVIDER_DESCRIPTOR = {
251
+ key: createPhiSharedFormProviderKey("handler", "asset-media-storage-settings"),
252
+ ownerModuleId: PHI_ASSET_RUNTIME_MODULE_ID,
253
+ title: "Admin media storage settings",
254
+ phase: "submit",
255
+ handlerKey: PHI_MEDIA_SETTINGS_FORM_HANDLER_KEYS.storage,
256
+ category: "site",
257
+ transport: "relay",
258
+ method: "PATCH",
259
+ endpointKey: null,
260
+ upstreamPath: "/api/site/admin/media/storage",
261
+ csrfPath: null,
262
+ requiresCsrf: false,
263
+ credentialPolicy: "site-session",
264
+ };
149
265
  export const PHI_MEDIA_SETTINGS_RUNTIME_MODULE_FORM = definePhiRuntimeModuleForm({
150
266
  ownerModuleId: PHI_ASSET_RUNTIME_MODULE_ID,
151
267
  areas: ["admin"],
@@ -1,4 +1,4 @@
1
- import { PHI_ASSET_RUNTIME_MODULE_ID } from "../ids";
1
+ import { PHI_ASSET_RUNTIME_DATA_PROVIDER_KEYS, PHI_ASSET_RUNTIME_MODULE_ID } from "../ids";
2
2
  import { PHI_MEDIA_SETTINGS_FORM_IDS } from "../settings-forms";
3
3
  import { getPhiMediaSettingsPageLabels } from "../../../../components/media/media-settings-labels";
4
4
  import { getResolvedSiteMediaSettings } from "../../../../gateway/site-media-settings";
@@ -10,6 +10,10 @@ function formatMegabytes(bytes) {
10
10
  const size = phiBytesToStorageSize(bytes);
11
11
  return size == null ? "—" : `${size} ${PHI_STORAGE_SIZE_UNIT_LABEL}`;
12
12
  }
13
+ function readDefaultChoice(id, storage) {
14
+ const chosen = id ?? storage.profiles.find((profile) => profile.local)?.id;
15
+ return chosen == null ? null : String(chosen);
16
+ }
13
17
  const SYNTHETIC_MEDIA_SETTINGS_REGION_IDS = {
14
18
  regionContent: -473,
15
19
  };
@@ -22,6 +26,65 @@ export async function buildPhiDefaultAdminMediaSettingsPageTree({ page, runtime,
22
26
  siteKey: runtime.site.key,
23
27
  }),
24
28
  ]);
29
+ /*
30
+ * The Spaces that exist, per kind, with the Profile each writes to and its own quota. The Profiles are
31
+ * this Site's, so their names and the choices of the profile cell are set here (`valueMap`,
32
+ * `editor.options`) rather than in the resource, which is the same on every Site. Offered only for a kind
33
+ * the Site's Modules activate, and only among the offered Profiles where the Site restricts them.
34
+ */
35
+ const offered = settings.storage.allowedProfileIds.length > 0
36
+ ? settings.storage.profiles.filter((profile) => settings.storage.allowedProfileIds.includes(profile.id))
37
+ : settings.storage.profiles;
38
+ const profileNames = Object.fromEntries(settings.storage.profiles.map((profile) => [String(profile.id), `${profile.key} (${profile.providerId})`]));
39
+ const profileChoices = offered.map((profile) => ({ value: String(profile.id), label: profileNames[String(profile.id)] }));
40
+ const buildSpacesTable = (nodeKey, resourceKey, label, withEmail) => ({
41
+ nodeKey,
42
+ typeKey: "table",
43
+ label,
44
+ config: {
45
+ source: { providerKey: PHI_ASSET_RUNTIME_DATA_PROVIDER_KEYS.mediaStorageSpaces, resourceKey },
46
+ presentation: {
47
+ controlSize: "small",
48
+ borders: true,
49
+ layout: { mode: "auto", overflowX: "auto" },
50
+ columns: [
51
+ { key: "owner", fieldKey: "owner", title: labels.spaces.owner, sizing: { mode: "fill", minWidth: 180 } },
52
+ ...(withEmail ? [{ key: "email", fieldKey: "email", title: labels.spaces.email, sizing: { mode: "content" } }] : []),
53
+ {
54
+ key: "storageProfileId",
55
+ fieldKey: "storageProfileId",
56
+ title: labels.spaces.profile,
57
+ valueMap: profileNames,
58
+ editor: { control: "select", options: profileChoices },
59
+ sizing: { mode: "content" },
60
+ },
61
+ {
62
+ key: "quotaMegabytes",
63
+ fieldKey: "quotaMegabytes",
64
+ title: labels.spaces.quota,
65
+ description: labels.spaces.quotaHint,
66
+ editor: { prefix: PHI_STORAGE_SIZE_UNIT_LABEL },
67
+ sizing: { mode: "content" },
68
+ align: "right",
69
+ },
70
+ { key: "effectiveQuotaMegabytes", fieldKey: "effectiveQuotaMegabytes", title: labels.spaces.effective, sizing: { mode: "content" }, align: "right" },
71
+ { key: "usedMegabytes", fieldKey: "usedMegabytes", title: labels.spaces.used, sizing: { mode: "content" }, align: "right" },
72
+ ],
73
+ emptyState: { title: labels.spaces.empty },
74
+ },
75
+ features: {
76
+ search: { enabled: true, placeholder: labels.spaces.search, debounceMs: 250 },
77
+ pagination: { enabled: true, pageSize: 25, pageSizes: [25, 50, 100] },
78
+ sorting: { mode: "none" },
79
+ editing: { mode: "cell" },
80
+ tools: { mode: "self-contained", reset: false, reload: true },
81
+ },
82
+ },
83
+ });
84
+ const spaceTables = [
85
+ ...(settings.userSpacesEnabled ? [buildSpacesTable("widgetUserSpacesTable", "userSpaces", labels.spaces.userTable, true)] : []),
86
+ ...(settings.groupSpacesEnabled ? [buildSpacesTable("widgetGroupSpacesTable", "groupSpaces", labels.spaces.groupTable, false)] : []),
87
+ ];
25
88
  const tree = buildPhiSettingsPageShellTree({
26
89
  page,
27
90
  ownerModuleId: PHI_ASSET_RUNTIME_MODULE_ID,
@@ -49,6 +112,36 @@ export async function buildPhiDefaultAdminMediaSettingsPageTree({ page, runtime,
49
112
  },
50
113
  }],
51
114
  },
115
+ {
116
+ nodeKey: "panelStorage",
117
+ title: labels.storage.title,
118
+ description: labels.storage.description,
119
+ sections: [{
120
+ kind: "form",
121
+ nodeKey: "widgetStorageForm",
122
+ formId: PHI_MEDIA_SETTINGS_FORM_IDS.storage,
123
+ label: labels.storage.title,
124
+ /*
125
+ * As the choices carry them: a Profile id as text. An unset default is the Site's Local Profile,
126
+ * which is itself one of the choices -- so it is shown as that choice rather than as an empty
127
+ * field, and choosing it again is a choice like any other instead of a clear the form drops.
128
+ */
129
+ initialValues: {
130
+ siteSpaceProfileId: String(settings.storage.siteSpaceProfileId),
131
+ defaultUserProfileId: readDefaultChoice(settings.storage.defaultUserProfileId, settings.storage),
132
+ defaultGroupProfileId: readDefaultChoice(settings.storage.defaultGroupProfileId, settings.storage),
133
+ allowedProfileIds: settings.storage.allowedProfileIds.map(String),
134
+ disabledProfileIds: settings.storage.profiles.filter((profile) => profile.disabled).map((profile) => String(profile.id)),
135
+ },
136
+ }],
137
+ },
138
+ // Only where the Site's Modules activate a delegated kind: otherwise there is no Space to list.
139
+ ...(spaceTables.length > 0 ? [{
140
+ nodeKey: "panelSpaces",
141
+ title: labels.spaces.title,
142
+ description: labels.spaces.description,
143
+ sections: spaceTables,
144
+ }] : []),
52
145
  {
53
146
  nodeKey: "panelTechnical",
54
147
  title: labels.technical.title,
@@ -44,6 +44,14 @@ export declare const buildPhiBuilderCurrentStructureShellDrafts: (runtime: PhiBl
44
44
  }>;
45
45
  export declare const buildPhiBuilderStructureShellDraftsForArea: (runtime: PhiBlockRuntime, area: PhiDeveloperBuilderArea, runtimeModuleCatalog: PhiRuntimeModuleCatalog) => Promise<Record<string, PhiDeveloperBuilderRegionDraft>>;
46
46
  export declare function buildPhiBuilderRuntimeModulesConfigForArea(runtime: PhiBlockRuntime, area: PhiDeveloperBuilderArea, runtimeModuleCatalog: PhiRuntimeModuleCatalog): Promise<PhiBuilderAreaModulesConfig>;
47
+ /**
48
+ * The Modules the published Area answers with, as opposed to the draft the Builder edits.
49
+ *
50
+ * Without a published revision the shell preset's default list decides, which is what a visitor is
51
+ * served in that case too. Read for the collision dialog, which has to say whether an address it asks to
52
+ * move already stands on the live Site.
53
+ */
54
+ export declare const buildPhiBuilderPublishedRuntimeModuleIdsForArea: (runtime: PhiBlockRuntime, area: PhiDeveloperBuilderArea, runtimeModuleCatalog: PhiRuntimeModuleCatalog) => Promise<PhiRuntimeModuleId[]>;
47
55
  export declare function buildPhiBuilderRuntimeModuleIdsForArea(runtime: PhiBlockRuntime, area: PhiDeveloperBuilderArea, runtimeModuleCatalog: PhiRuntimeModuleCatalog): Promise<`${string}/${string}`[]>;
48
56
  export declare function buildPhiBuilderStructureRuntimeModuleIdsByArea(runtime: PhiBlockRuntime, runtimeModuleCatalog: PhiRuntimeModuleCatalog): Promise<Record<PhiDeveloperBuilderArea, PhiRuntimeModuleId[]>>;
49
57
  /**