@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.
- package/components/controls/phi-background-control.js +1 -1
- package/components/controls/phi-breadcrumb-control.d.ts +2 -0
- package/components/media/media-asset-typed-fields.d.ts +10 -0
- package/components/media/media-asset-typed-fields.js +19 -0
- package/components/media/media-settings-labels.d.ts +33 -0
- package/components/media/media-settings-labels.js +62 -0
- package/components/media/media-upload-flow.d.ts +19 -0
- package/components/media/media-upload-flow.js +38 -0
- package/components/media/phi-asset-focal-rect-widget.js +2 -2
- package/components/media/phi-image-inspector-widget.js +1 -1
- package/components/media/phi-image-preview-data.js +5 -4
- package/components/media/phi-site-font-assets.js +2 -5
- package/components/media/use-authoring-asset-details.js +0 -1
- package/components/regions/presets/navigation-redirect.d.ts +2 -2
- package/components/regions/presets/navigation-redirect.js +3 -3
- package/components/regions/presets/phi-area-shell-preset-nodes.js +2 -1
- package/components/widgets/helpers/internal-reference-resolver.server.d.ts +1 -1
- package/components/widgets/helpers/internal-reference-resolver.server.js +4 -0
- package/components/widgets/label-sets/builder-modules.js +6 -0
- package/components/widgets/label-types/builder-modules.d.ts +4 -0
- package/components/widgets/label-types/builder-modules.js +3 -0
- package/constants/runtime-module-ownership.js +4 -0
- package/gateway/internal-references.d.ts +5 -0
- package/gateway/internal-references.js +12 -12
- package/gateway/site-media-settings.d.ts +2 -0
- package/gateway/site-media-settings.js +6 -1
- package/gateway/site-media-storage-reader.d.ts +19 -0
- package/gateway/site-media-storage-reader.js +24 -0
- package/helpers/cms-navigation-catalog.d.ts +2 -0
- package/helpers/cms-navigation-catalog.js +1 -0
- package/helpers/cms-page-catalog.d.ts +12 -0
- package/helpers/cms-page-catalog.js +5 -0
- package/helpers/phi-seo.d.ts +16 -2
- package/helpers/phi-seo.js +54 -11
- package/helpers/public-route-claims.d.ts +4 -0
- package/helpers/public-route-claims.js +1 -1
- package/next/seo-routes.d.ts +1 -1
- package/next/seo-routes.js +23 -5
- package/package.json +1 -1
- package/plugins/runtime-modules/area-definitions.d.ts +75 -6
- package/plugins/runtime-modules/area-definitions.js +20 -0
- package/plugins/runtime-modules/asset/client-data-providers.js +12 -0
- package/plugins/runtime-modules/asset/controller/runtime.js +1 -1
- package/plugins/runtime-modules/asset/data-providers.d.ts +27 -2
- package/plugins/runtime-modules/asset/data-providers.js +56 -0
- package/plugins/runtime-modules/asset/definition.d.ts +38 -2
- package/plugins/runtime-modules/asset/definition.js +2 -1
- package/plugins/runtime-modules/asset/ids.d.ts +4 -0
- package/plugins/runtime-modules/asset/ids.js +4 -0
- package/plugins/runtime-modules/asset/server.js +2 -1
- package/plugins/runtime-modules/asset/services/options.d.ts +7 -0
- package/plugins/runtime-modules/asset/services/options.js +38 -0
- package/plugins/runtime-modules/asset/services/storage-spaces-table.d.ts +3 -0
- package/plugins/runtime-modules/asset/services/storage-spaces-table.js +89 -0
- package/plugins/runtime-modules/asset/settings-forms.d.ts +17 -0
- package/plugins/runtime-modules/asset/settings-forms.js +117 -1
- package/plugins/runtime-modules/asset/trees/phi-default-admin-media-settings-page-tree.js +94 -1
- package/plugins/runtime-modules/builder/area-shell-presets.server.d.ts +8 -0
- package/plugins/runtime-modules/builder/area-shell-presets.server.js +13 -0
- package/plugins/runtime-modules/builder/controller/page-controller-helpers.js +1 -1
- package/plugins/runtime-modules/builder/controller/page-controller.d.ts +1 -1
- package/plugins/runtime-modules/builder/controller/page-controller.js +30 -3
- package/plugins/runtime-modules/builder/controller/server-definition.d.ts +7 -1
- package/plugins/runtime-modules/builder/controller/server-definition.js +8 -3
- package/plugins/runtime-modules/builder/data-providers.js +1 -0
- package/plugins/runtime-modules/builder/developer-workspace-types.d.ts +2 -0
- package/plugins/runtime-modules/builder/navigation-path-context.js +7 -3
- package/plugins/runtime-modules/builder/options-providers.js +2 -2
- package/plugins/runtime-modules/builder/page-address-rule.d.ts +39 -0
- package/plugins/runtime-modules/builder/page-address-rule.js +62 -0
- package/plugins/runtime-modules/builder/page-meta-form.js +10 -0
- package/plugins/runtime-modules/builder/public-route-collisions.js +7 -2
- package/plugins/runtime-modules/builder/services/page-source-tree.js +2 -1
- package/plugins/runtime-modules/builder/services/runtime-modules-table.js +49 -1
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +14 -2
- package/plugins/runtime-modules/core/widgets/breadcrumb/client.d.ts +14 -2
- package/plugins/runtime-modules/core/widgets/breadcrumb/client.js +35 -4
- package/plugins/runtime-modules/core/widgets/breadcrumb/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/breadcrumb/server.js +37 -2
- package/plugins/runtime-modules/core/widgets/card/editor.js +1 -1
- package/plugins/runtime-modules/core/widgets/image/client.js +1 -1
- package/plugins/runtime-modules/core/widgets/image/editor.js +1 -1
- package/plugins/runtime-modules/core/widgets/page-title/authoring.js +3 -1
- package/plugins/runtime-modules/core/widgets/page-title/client.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/page-title/client.js +5 -1
- package/plugins/runtime-modules/core/widgets/page-title/config.d.ts +25 -3
- package/plugins/runtime-modules/core/widgets/page-title/config.js +24 -3
- package/plugins/runtime-modules/core/widgets/page-title/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/page-title/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/page-title/server.js +4 -3
- package/plugins/runtime-modules/core/widgets/table/client.js +1 -1
- package/plugins/runtime-modules/core/widgets/table/config.js +9 -0
- package/plugins/runtime-modules/descriptor-compiler.js +33 -8
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +1 -1
- package/server-helpers/cms-review-params.d.ts +25 -0
- package/server-helpers/cms-review-params.js +54 -0
- package/server-helpers/cms-review.d.ts +1 -25
- package/server-helpers/cms-review.js +2 -54
- package/types/cms-module-descriptors.d.ts +33 -3
- package/types/media.d.ts +6 -2
- package/types/table-widget.d.ts +11 -0
- package/types.d.ts +1 -1
|
@@ -508,7 +508,7 @@ export function PhiBackgroundControl({ value, config, disabled = false, mode = "
|
|
|
508
508
|
deliveryUrl: asset.deliveryUrl ?? null,
|
|
509
509
|
deliveryRevision: asset.deliveryRevision ?? null,
|
|
510
510
|
variantVersion: asset.variantVersion ?? null,
|
|
511
|
-
focalRect: normalizeMediaFocalRect(asset.
|
|
511
|
+
focalRect: normalizeMediaFocalRect(asset.focalRect ?? null),
|
|
512
512
|
width: asset.width ?? null,
|
|
513
513
|
height: asset.height ?? null,
|
|
514
514
|
};
|
|
@@ -2,6 +2,8 @@ import type { ReactNode } from "react";
|
|
|
2
2
|
export type PhiBreadcrumbControlItem = {
|
|
3
3
|
key?: string;
|
|
4
4
|
title: ReactNode;
|
|
5
|
+
/** Where the item leads; an item without one is text. */
|
|
6
|
+
href?: string;
|
|
5
7
|
};
|
|
6
8
|
export type PhiBreadcrumbControlProps = {
|
|
7
9
|
items: readonly PhiBreadcrumbControlItem[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type PhiConfigReader } from "../widgets/config/strict-config-reader";
|
|
2
|
+
import type { PhiFontMetrics } from "../../types/media";
|
|
3
|
+
import type { MediaFocalRect } from "./focal-rect";
|
|
4
|
+
/**
|
|
5
|
+
* The entries of an Asset's stored `meta` a client acts on, as the server sends them: typed fields, never
|
|
6
|
+
* `meta` itself. One reader for every response that carries them -- the management tile and detail as much
|
|
7
|
+
* as the public reference projection -- so the three cannot disagree about what a focal rectangle is.
|
|
8
|
+
*/
|
|
9
|
+
export declare function readPhiMediaFocalRectField(reader: PhiConfigReader): MediaFocalRect | null;
|
|
10
|
+
export declare function readPhiMediaFontField(reader: PhiConfigReader): PhiFontMetrics | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { readPhiFontMetricsFields } from "./media-font-metrics";
|
|
2
|
+
import { requirePhiField } from "../widgets/config/strict-config-reader";
|
|
3
|
+
/**
|
|
4
|
+
* The entries of an Asset's stored `meta` a client acts on, as the server sends them: typed fields, never
|
|
5
|
+
* `meta` itself. One reader for every response that carries them -- the management tile and detail as much
|
|
6
|
+
* as the public reference projection -- so the three cannot disagree about what a focal rectangle is.
|
|
7
|
+
*/
|
|
8
|
+
export function readPhiMediaFocalRectField(reader) {
|
|
9
|
+
return reader.object("focalRect", (rect) => {
|
|
10
|
+
const fraction = (key) => {
|
|
11
|
+
const value = requirePhiField(rect, key, "a number from 0 to 1", rect.number);
|
|
12
|
+
return value >= 0 && value <= 1 ? value : rect.fail(key, "a number from 0 to 1");
|
|
13
|
+
};
|
|
14
|
+
return { x: fraction("x"), y: fraction("y"), width: fraction("width"), height: fraction("height") };
|
|
15
|
+
}) ?? null;
|
|
16
|
+
}
|
|
17
|
+
export function readPhiMediaFontField(reader) {
|
|
18
|
+
return reader.object("font", readPhiFontMetricsFields) ?? null;
|
|
19
|
+
}
|
|
@@ -39,5 +39,38 @@ export declare function getPhiMediaSettingsPageLabels(options: PhiGlobalTranslat
|
|
|
39
39
|
title: string;
|
|
40
40
|
empty: string;
|
|
41
41
|
};
|
|
42
|
+
storage: {
|
|
43
|
+
title: string;
|
|
44
|
+
description: string;
|
|
45
|
+
siteSpace: string;
|
|
46
|
+
siteSpaceHint: string;
|
|
47
|
+
siteSpaceRequired: string;
|
|
48
|
+
defaultUser: string;
|
|
49
|
+
defaultUserHint: string;
|
|
50
|
+
defaultGroup: string;
|
|
51
|
+
defaultGroupHint: string;
|
|
52
|
+
local: string;
|
|
53
|
+
allowed: string;
|
|
54
|
+
allowedHint: string;
|
|
55
|
+
all: string;
|
|
56
|
+
disabled: string;
|
|
57
|
+
disabledHint: string;
|
|
58
|
+
none: string;
|
|
59
|
+
};
|
|
60
|
+
spaces: {
|
|
61
|
+
title: string;
|
|
62
|
+
description: string;
|
|
63
|
+
userTable: string;
|
|
64
|
+
groupTable: string;
|
|
65
|
+
owner: string;
|
|
66
|
+
email: string;
|
|
67
|
+
profile: string;
|
|
68
|
+
quota: string;
|
|
69
|
+
quotaHint: string;
|
|
70
|
+
effective: string;
|
|
71
|
+
used: string;
|
|
72
|
+
search: string;
|
|
73
|
+
empty: string;
|
|
74
|
+
};
|
|
42
75
|
submitLabel: string;
|
|
43
76
|
}>;
|
|
@@ -35,6 +35,35 @@ const PHI_MEDIA_SETTINGS_PAGE_LABEL_SET = definePhiLabelSet({
|
|
|
35
35
|
addon_spaces_title: "Add-on stores",
|
|
36
36
|
addon_spaces_empty: definePhiMessageLabel("No Add-on holds files on this site."),
|
|
37
37
|
submit_label: "Save",
|
|
38
|
+
storage_title: "Storage",
|
|
39
|
+
storage_description: definePhiMessageLabel("Where this site's Spaces write new uploads. The storage profiles themselves are created by the operator; changing where a Space writes moves no files."),
|
|
40
|
+
storage_site_space_label: "Site Space",
|
|
41
|
+
storage_site_space_hint: definePhiMessageLabel("Where uploads into the site's own media go."),
|
|
42
|
+
storage_site_space_required: definePhiMessageLabel("Choose where the site's own media is stored."),
|
|
43
|
+
storage_default_user_label: "New User Spaces",
|
|
44
|
+
storage_default_user_hint: definePhiMessageLabel("Where a User Space created from now on writes. Existing User Spaces keep theirs."),
|
|
45
|
+
storage_default_group_label: "New Group Spaces",
|
|
46
|
+
storage_default_group_hint: definePhiMessageLabel("Where a Group Space created from now on writes. Existing Group Spaces keep theirs."),
|
|
47
|
+
storage_local_placeholder: "Local storage",
|
|
48
|
+
storage_allowed_label: "Offered profiles",
|
|
49
|
+
storage_allowed_hint: definePhiMessageLabel("The storage profiles a Space may be pointed at. Empty offers every profile."),
|
|
50
|
+
storage_all_placeholder: "All profiles",
|
|
51
|
+
storage_disabled_label: "Paused profiles",
|
|
52
|
+
storage_disabled_hint: definePhiMessageLabel("A paused profile still delivers what it holds but takes no new uploads."),
|
|
53
|
+
storage_none_placeholder: "None",
|
|
54
|
+
spaces_title: "Spaces",
|
|
55
|
+
spaces_description: definePhiMessageLabel("The User and Group Spaces that exist, with the storage profile each writes to and its own quota. A Space without a quota of its own follows the site default; changing its profile moves no files."),
|
|
56
|
+
spaces_user_table: "User Spaces",
|
|
57
|
+
spaces_group_table: "Group Spaces",
|
|
58
|
+
spaces_owner: "Owner",
|
|
59
|
+
spaces_email: "Email",
|
|
60
|
+
spaces_profile: "Storage profile",
|
|
61
|
+
spaces_quota: "Own quota",
|
|
62
|
+
spaces_quota_hint: definePhiMessageLabel("Empty follows the site default for this kind of Space."),
|
|
63
|
+
spaces_effective: "Applies",
|
|
64
|
+
spaces_used: "Used",
|
|
65
|
+
spaces_search: "Search",
|
|
66
|
+
spaces_empty: definePhiMessageLabel("No Space of this kind exists yet."),
|
|
38
67
|
},
|
|
39
68
|
});
|
|
40
69
|
export async function getPhiMediaSettingsPageLabels(options) {
|
|
@@ -78,6 +107,39 @@ export async function getPhiMediaSettingsPageLabels(options) {
|
|
|
78
107
|
title: labels.addon_spaces_title,
|
|
79
108
|
empty: labels.addon_spaces_empty,
|
|
80
109
|
},
|
|
110
|
+
storage: {
|
|
111
|
+
title: labels.storage_title,
|
|
112
|
+
description: labels.storage_description,
|
|
113
|
+
siteSpace: labels.storage_site_space_label,
|
|
114
|
+
siteSpaceHint: labels.storage_site_space_hint,
|
|
115
|
+
siteSpaceRequired: labels.storage_site_space_required,
|
|
116
|
+
defaultUser: labels.storage_default_user_label,
|
|
117
|
+
defaultUserHint: labels.storage_default_user_hint,
|
|
118
|
+
defaultGroup: labels.storage_default_group_label,
|
|
119
|
+
defaultGroupHint: labels.storage_default_group_hint,
|
|
120
|
+
local: labels.storage_local_placeholder,
|
|
121
|
+
allowed: labels.storage_allowed_label,
|
|
122
|
+
allowedHint: labels.storage_allowed_hint,
|
|
123
|
+
all: labels.storage_all_placeholder,
|
|
124
|
+
disabled: labels.storage_disabled_label,
|
|
125
|
+
disabledHint: labels.storage_disabled_hint,
|
|
126
|
+
none: labels.storage_none_placeholder,
|
|
127
|
+
},
|
|
128
|
+
spaces: {
|
|
129
|
+
title: labels.spaces_title,
|
|
130
|
+
description: labels.spaces_description,
|
|
131
|
+
userTable: labels.spaces_user_table,
|
|
132
|
+
groupTable: labels.spaces_group_table,
|
|
133
|
+
owner: labels.spaces_owner,
|
|
134
|
+
email: labels.spaces_email,
|
|
135
|
+
profile: labels.spaces_profile,
|
|
136
|
+
quota: labels.spaces_quota,
|
|
137
|
+
quotaHint: labels.spaces_quota_hint,
|
|
138
|
+
effective: labels.spaces_effective,
|
|
139
|
+
used: labels.spaces_used,
|
|
140
|
+
search: labels.spaces_search,
|
|
141
|
+
empty: labels.spaces_empty,
|
|
142
|
+
},
|
|
81
143
|
submitLabel: labels.submit_label,
|
|
82
144
|
};
|
|
83
145
|
}
|
|
@@ -138,7 +138,26 @@ type PhiMediaUploadInitSession = {
|
|
|
138
138
|
uploaded: readonly PhiMediaUploadStoredPart[];
|
|
139
139
|
/** Whether this session was taken over rather than opened, which only the Server can say. */
|
|
140
140
|
resumed: boolean;
|
|
141
|
+
/** Null where the Server asked for none: every plan but one sent in parts. */
|
|
142
|
+
heartbeat: PhiMediaUploadHeartbeat | null;
|
|
141
143
|
};
|
|
144
|
+
type PhiMediaUploadHeartbeat = {
|
|
145
|
+
url: string;
|
|
146
|
+
intervalMs: number;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Says, every so often, that this page is still sending the parts of this body.
|
|
150
|
+
*
|
|
151
|
+
* The beacon on `pagehide` covers a reload or a closed tab; a crashed tab, a killed browser or a power cut
|
|
152
|
+
* send nothing at all, and their session would sit as if a page were still writing into it. The Server tells
|
|
153
|
+
* the two apart by this: a session whose beat has lapsed may be continued by the next attempt at the same
|
|
154
|
+
* file, one that is still beating must not be. A 404 means the session is no longer being delivered
|
|
155
|
+
* (finalized, swept, taken over), and beating on would renew nothing. Failures are otherwise ignored: a
|
|
156
|
+
* missed beat costs at most a later continuation, never this upload.
|
|
157
|
+
*
|
|
158
|
+
* Returns the way to stop.
|
|
159
|
+
*/
|
|
160
|
+
export declare function keepPhiMediaUploadHeartbeat(heartbeat: PhiMediaUploadHeartbeat | null): () => void;
|
|
142
161
|
/**
|
|
143
162
|
* What a Client may say about a body it could not deliver.
|
|
144
163
|
*
|
|
@@ -101,6 +101,40 @@ function bindPhiMediaUploadAbort(signal, abort) {
|
|
|
101
101
|
signal.addEventListener("abort", abort, { once: true });
|
|
102
102
|
return () => signal.removeEventListener("abort", abort);
|
|
103
103
|
}
|
|
104
|
+
function readPhiMediaUploadHeartbeat(value) {
|
|
105
|
+
const url = value?.url;
|
|
106
|
+
const intervalMs = value?.intervalMs;
|
|
107
|
+
// A floor, so a Server that misstated the interval cannot turn this into a request loop.
|
|
108
|
+
return typeof url === "string" && url && typeof intervalMs === "number" && intervalMs >= 1_000
|
|
109
|
+
? { url, intervalMs }
|
|
110
|
+
: null;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Says, every so often, that this page is still sending the parts of this body.
|
|
114
|
+
*
|
|
115
|
+
* The beacon on `pagehide` covers a reload or a closed tab; a crashed tab, a killed browser or a power cut
|
|
116
|
+
* send nothing at all, and their session would sit as if a page were still writing into it. The Server tells
|
|
117
|
+
* the two apart by this: a session whose beat has lapsed may be continued by the next attempt at the same
|
|
118
|
+
* file, one that is still beating must not be. A 404 means the session is no longer being delivered
|
|
119
|
+
* (finalized, swept, taken over), and beating on would renew nothing. Failures are otherwise ignored: a
|
|
120
|
+
* missed beat costs at most a later continuation, never this upload.
|
|
121
|
+
*
|
|
122
|
+
* Returns the way to stop.
|
|
123
|
+
*/
|
|
124
|
+
export function keepPhiMediaUploadHeartbeat(heartbeat) {
|
|
125
|
+
if (!heartbeat || typeof window === "undefined") {
|
|
126
|
+
return () => { };
|
|
127
|
+
}
|
|
128
|
+
const timer = window.setInterval(() => {
|
|
129
|
+
void fetch(heartbeat.url, { method: "POST", credentials: "same-origin" })
|
|
130
|
+
.then((response) => {
|
|
131
|
+
if (response.status === 404)
|
|
132
|
+
window.clearInterval(timer);
|
|
133
|
+
})
|
|
134
|
+
.catch(() => undefined);
|
|
135
|
+
}, heartbeat.intervalMs);
|
|
136
|
+
return () => window.clearInterval(timer);
|
|
137
|
+
}
|
|
104
138
|
/**
|
|
105
139
|
* What a Client may say about a body it could not deliver.
|
|
106
140
|
*
|
|
@@ -341,6 +375,7 @@ export async function initPhiMediaUploadSession(file, options, signal) {
|
|
|
341
375
|
expiresAt: payload.expiresAt,
|
|
342
376
|
uploaded,
|
|
343
377
|
resumed: payload.resumed === true,
|
|
378
|
+
heartbeat: payload.plan.kind === "multipart-put" ? readPhiMediaUploadHeartbeat(payload.heartbeat) : null,
|
|
344
379
|
};
|
|
345
380
|
}
|
|
346
381
|
/**
|
|
@@ -637,6 +672,7 @@ async function readPhiMediaUploadCancellation(run, signal) {
|
|
|
637
672
|
export async function runPhiMediaUploadSession(file, onProgress, options, signal) {
|
|
638
673
|
const init = await readPhiMediaUploadCancellation(() => initPhiMediaUploadSession(file, options, signal), signal);
|
|
639
674
|
const standDown = reportPhiMediaUploadAbandonmentOnLeaving(init.reportUrl, init.plan);
|
|
675
|
+
const stopBeating = keepPhiMediaUploadHeartbeat(init.heartbeat);
|
|
640
676
|
let upload;
|
|
641
677
|
try {
|
|
642
678
|
upload = await uploadPhiMediaUploadBody(init.plan, file, onProgress, init.uploaded, signal);
|
|
@@ -644,6 +680,7 @@ export async function runPhiMediaUploadSession(file, onProgress, options, signal
|
|
|
644
680
|
throwIfPhiMediaUploadAborted(signal);
|
|
645
681
|
}
|
|
646
682
|
catch (uploadError) {
|
|
683
|
+
stopBeating();
|
|
647
684
|
standDown();
|
|
648
685
|
// The Server cannot see this leg, so it is told rather than left to infer it from an expiry.
|
|
649
686
|
await reportPhiMediaUploadFailure(init.reportUrl, readPhiMediaUploadFailureReason(uploadError), uploadError instanceof Error ? uploadError.message : null);
|
|
@@ -659,6 +696,7 @@ export async function runPhiMediaUploadSession(file, onProgress, options, signal
|
|
|
659
696
|
* body that has already arrived. What this gives up is the sliver where somebody leaves after the body
|
|
660
697
|
* landed and before finalize was sent, and expiry already answers for that.
|
|
661
698
|
*/
|
|
699
|
+
stopBeating();
|
|
662
700
|
standDown();
|
|
663
701
|
const finalize = await finalizePhiMediaUploadSession(init.finalizeUrl, upload.completion);
|
|
664
702
|
return {
|
|
@@ -56,7 +56,7 @@ export function PhiAssetFocalRectWidget({ config, }) {
|
|
|
56
56
|
return _jsx(PhiAssetFocalRectEditor, { asset: asset, config: config }, asset?.id ?? "");
|
|
57
57
|
}
|
|
58
58
|
function PhiAssetFocalRectEditor({ asset, config, }) {
|
|
59
|
-
const currentRect = useMemo(() => normalizeMediaFocalRect(asset?.
|
|
59
|
+
const currentRect = useMemo(() => normalizeMediaFocalRect(asset?.focalRect), [asset?.focalRect]);
|
|
60
60
|
const [draft, setDraft] = useState(() => currentRect ?? createDefaultFocalRect());
|
|
61
61
|
const originalRef = useRef(currentRect);
|
|
62
62
|
const interactionRef = useRef(null);
|
|
@@ -131,7 +131,7 @@ function PhiAssetFocalRectEditor({ asset, config, }) {
|
|
|
131
131
|
const next = normalizeMediaFocalRect(draft);
|
|
132
132
|
updatePhiImagePreviewAsset(PHI_ASSET_CONTROLLER_STORE_KEY, asset.id, (current) => ({
|
|
133
133
|
...current,
|
|
134
|
-
|
|
134
|
+
focalRect: next,
|
|
135
135
|
}));
|
|
136
136
|
/*
|
|
137
137
|
* The rectangle, and not a field: which field it lands in is written on the route
|
|
@@ -16,7 +16,7 @@ export function PhiAssetConfigWidget({ config, labels, sitePublicUrl }) {
|
|
|
16
16
|
valueType: "none",
|
|
17
17
|
typeKey: "image-inspector-focal-rect",
|
|
18
18
|
});
|
|
19
|
-
return selectedAsset ? (_jsx(PhiAssetInspectorSection, { section: config?.section ?? "preview", asset: selectedAsset, selectedVariantKey: state.selectedVariantKey, sitePublicUrl: sitePublicUrl, labels: labels, focalRect: normalizeMediaFocalRect(selectedAsset.
|
|
19
|
+
return selectedAsset ? (_jsx(PhiAssetInspectorSection, { section: config?.section ?? "preview", asset: selectedAsset, selectedVariantKey: state.selectedVariantKey, sitePublicUrl: sitePublicUrl, labels: labels, focalRect: normalizeMediaFocalRect(selectedAsset.focalRect), onVariantKeyChange: (nextVariantKey) => {
|
|
20
20
|
setPhiImagePreviewSelection(PHI_ASSET_CONTROLLER_STORE_KEY, selectedAsset.id, nextVariantKey ?? null, selectedAssetTile);
|
|
21
21
|
}, onFocalRectOpen: () => focalRectSignals.emitCapability("focalRectOpen", null) })) : null;
|
|
22
22
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PHI_MEDIA_SPACE_KINDS } from "@phis/contracts/media";
|
|
2
|
+
import { readPhiMediaFocalRectField, readPhiMediaFontField } from "./media-asset-typed-fields";
|
|
2
3
|
import { PhiImageAssetVariantKey, PhiMediaKind, resolvePhiMediaKindFromContentType } from "../../constants/media";
|
|
3
4
|
import { createPhiResponseReader, requirePhiField, } from "../widgets/config/strict-config-reader";
|
|
4
5
|
/*
|
|
@@ -95,7 +96,8 @@ function readPhiMediaAssetFields(reader) {
|
|
|
95
96
|
blurDataUrl: nullableString(reader, "blurDataUrl"),
|
|
96
97
|
thumbnailUrl: nullableString(reader, "thumbnailUrl"),
|
|
97
98
|
previewUrl: nullableString(reader, "previewUrl"),
|
|
98
|
-
|
|
99
|
+
focalRect: readPhiMediaFocalRectField(reader),
|
|
100
|
+
font: readPhiMediaFontField(reader),
|
|
99
101
|
title: nullableString(reader, "title"),
|
|
100
102
|
altText: nullableString(reader, "altText"),
|
|
101
103
|
lifecycleStatus: requiredInteger(reader, "lifecycleStatus"),
|
|
@@ -134,7 +136,6 @@ export function readPhiMediaPagination(value, source = PHI_MEDIA_LISTING) {
|
|
|
134
136
|
export function readPhiMediaAssetTiles(value, source = PHI_MEDIA_LISTING) {
|
|
135
137
|
return createPhiResponseReader({ assets: value }, source).list("assets", (reader) => {
|
|
136
138
|
const variantVersion = reader.integer("variantVersion");
|
|
137
|
-
const meta = reader.value("meta", "an object", (entry) => (isPlainRecord(entry) ? entry : undefined));
|
|
138
139
|
const blurDataUrl = reader.string("blurDataUrl");
|
|
139
140
|
const folder = reader.object("folder", (folderReader) => ({
|
|
140
141
|
id: requiredInteger(folderReader, "id"),
|
|
@@ -164,7 +165,8 @@ export function readPhiMediaAssetTiles(value, source = PHI_MEDIA_LISTING) {
|
|
|
164
165
|
deliveryRevision: requiredInteger(reader, "deliveryRevision"),
|
|
165
166
|
presentationFlags: requiredInteger(reader, "presentationFlags"),
|
|
166
167
|
...(blurDataUrl === undefined ? {} : { blurDataUrl }),
|
|
167
|
-
|
|
168
|
+
focalRect: readPhiMediaFocalRectField(reader),
|
|
169
|
+
font: readPhiMediaFontField(reader),
|
|
168
170
|
folder: folder ?? null,
|
|
169
171
|
};
|
|
170
172
|
}) ?? [];
|
|
@@ -238,7 +240,6 @@ export function normalizePhiImagePreviewSelectionAsset(tile) {
|
|
|
238
240
|
...rest,
|
|
239
241
|
kind: tile.kind,
|
|
240
242
|
blurDataUrl: tile.blurDataUrl ?? null,
|
|
241
|
-
meta: tile.meta ?? null,
|
|
242
243
|
folder: null,
|
|
243
244
|
variants: null,
|
|
244
245
|
};
|
|
@@ -4,9 +4,7 @@ import { PhiMediaKind } from "../../constants/media";
|
|
|
4
4
|
import { createPhiAssetUri } from "../../types/references";
|
|
5
5
|
import { usePhiCollectionProvider } from "../widgets/client/shared/phi-collection-provider";
|
|
6
6
|
import { PHI_ASSET_COLLECTION_DATA_SOURCE } from "./asset-collection-runtime";
|
|
7
|
-
import { readPhiFontMetricsFields } from "./media-font-metrics";
|
|
8
7
|
import { readPhiMediaAssetTiles } from "./phi-image-preview-data";
|
|
9
|
-
import { createPhiResponseReader } from "../widgets/config/strict-config-reader";
|
|
10
8
|
/**
|
|
11
9
|
* The typefaces a Site owns, as something a font slot can be set to.
|
|
12
10
|
*
|
|
@@ -21,9 +19,8 @@ import { createPhiResponseReader } from "../widgets/config/strict-config-reader"
|
|
|
21
19
|
/** Enough for any Site's own lettering; a ceiling rather than a page size. */
|
|
22
20
|
const PHI_SITE_FONT_ASSET_LIMIT = 100;
|
|
23
21
|
function readFontAssetMetrics(asset) {
|
|
24
|
-
//
|
|
25
|
-
return
|
|
26
|
-
.object("font", readPhiFontMetricsFields) ?? null;
|
|
22
|
+
// Read off the tile already: the management projection carries the metrics as a typed field.
|
|
23
|
+
return asset.font;
|
|
27
24
|
}
|
|
28
25
|
function readFontAssetLabel(asset) {
|
|
29
26
|
const family = readFontAssetMetrics(asset)?.familyName;
|
|
@@ -50,7 +50,6 @@ export function usePhiAuthoringAssetDetails(assetId) {
|
|
|
50
50
|
return {
|
|
51
51
|
...currentAssetTile,
|
|
52
52
|
blurDataUrl: currentAssetTile.blurDataUrl ?? null,
|
|
53
|
-
meta: currentAssetTile.meta ?? null,
|
|
54
53
|
folder: fetchedAsset?.folder ?? null,
|
|
55
54
|
variants: keepFetchedVariants ? fetchedAsset?.variants ?? null : null,
|
|
56
55
|
};
|
|
@@ -12,8 +12,8 @@ import type { PhiCmsPageNode, PhiResolvedCmsPageTree } from "../../../types/cms"
|
|
|
12
12
|
/**
|
|
13
13
|
* The first place a navigation subtree actually goes.
|
|
14
14
|
*
|
|
15
|
-
* An Overlay opener is not a destination, so it can never be what a redirect lands on, and an
|
|
16
|
-
* address is
|
|
15
|
+
* An Overlay opener is not a destination, so it can never be what a redirect lands on, and neither an
|
|
16
|
+
* external address nor another Area's root is a place in the Area. Neither is the path the redirecting page itself answers: an Area root whose sidebar still carries an item pointing
|
|
17
17
|
* at "/" would forward to itself forever, which is the whole reason `skipPath` exists.
|
|
18
18
|
*/
|
|
19
19
|
export declare function findFirstPhiCmsNavigationLinkPath(items: readonly PhiCmsResolvedNavigationItem[], skipPath?: string): string | null;
|
|
@@ -12,13 +12,13 @@ import { readPhiCmsNavigationTargetPath } from "../../../helpers/navigation-targ
|
|
|
12
12
|
/**
|
|
13
13
|
* The first place a navigation subtree actually goes.
|
|
14
14
|
*
|
|
15
|
-
* An Overlay opener is not a destination, so it can never be what a redirect lands on, and an
|
|
16
|
-
* address is
|
|
15
|
+
* An Overlay opener is not a destination, so it can never be what a redirect lands on, and neither an
|
|
16
|
+
* external address nor another Area's root is a place in the Area. Neither is the path the redirecting page itself answers: an Area root whose sidebar still carries an item pointing
|
|
17
17
|
* at "/" would forward to itself forever, which is the whole reason `skipPath` exists.
|
|
18
18
|
*/
|
|
19
19
|
export function findFirstPhiCmsNavigationLinkPath(items, skipPath) {
|
|
20
20
|
for (const item of items) {
|
|
21
|
-
const path = item.target?.kind === "custom" && item.target.external === true
|
|
21
|
+
const path = (item.target?.kind === "custom" && item.target.external === true) || item.target?.kind === "area"
|
|
22
22
|
? null
|
|
23
23
|
: readPhiCmsNavigationTargetPath(item.target);
|
|
24
24
|
if (item.kind === "link" && path && path !== skipPath) {
|
|
@@ -78,7 +78,8 @@ export function buildPhiAreaShellHeaderNodes({ nodes, runtime, labelPrefix, ids,
|
|
|
78
78
|
slotIndex: PHI_CMS_THREE_COLUMN_LAYOUT_SLOT_INDEX.Middle,
|
|
79
79
|
sortOrder: 0,
|
|
80
80
|
label: "Page title",
|
|
81
|
-
|
|
81
|
+
/* A caption in the bar: the Page's heading is the Page's. */
|
|
82
|
+
config: { display: "label" },
|
|
82
83
|
}),
|
|
83
84
|
nodes.widget({
|
|
84
85
|
typeKey: "account",
|
|
@@ -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",
|
|
@@ -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 {
|
|
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
|
|
52
|
-
|
|
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({
|
|
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 {
|
|
18
|
+
return {
|
|
19
|
+
...payload.media,
|
|
20
|
+
addonSpaces: payload.addonSpaces ?? [],
|
|
21
|
+
storage: readPhiSiteMediaStorageSettings(payload.storage, "The site media storage settings"),
|
|
22
|
+
};
|
|
18
23
|
});
|