@phis/ui 0.6.10 → 0.7.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/cms/phi-cms-area-render-scope.d.ts +2 -0
- package/components/cms/phi-cms-area-render-scope.js +1 -1
- package/components/cms/phi-cms-error-page.js +1 -1
- package/components/cms/phi-cms-page-render-scope.d.ts +0 -1
- package/components/cms/phi-cms-page-render-scope.js +1 -1
- package/components/cms/phi-cms-root-layout.js +1 -0
- package/components/cms/phi-cms-runtime-registry.d.ts +4 -4
- package/components/cms/phi-cms-runtime-registry.js +4 -4
- package/components/controls/phi-padding-control.js +18 -5
- package/components/layouts/layout-definitions.d.ts +8 -0
- package/components/regions/presets/phi-base-page-column.js +1 -2
- package/components/regions/presets/phi-header-top-actions-layout.d.ts +2 -2
- package/components/regions/presets/phi-header-top-actions-layout.js +2 -4
- package/components/regions/presets/phi-settings-page-shell-tree.js +0 -2
- package/components/widgets/label-sets/padding.js +2 -0
- package/components/widgets/label-sets/region.js +2 -0
- package/components/widgets/label-types/padding.d.ts +2 -0
- package/components/widgets/label-types/padding.js +1 -0
- package/components/widgets/label-types/region.d.ts +2 -0
- package/components/widgets/label-types/region.js +1 -0
- package/components/widgets/label-types/revisions.js +2 -2
- package/components/workspace/catalog-state.d.ts +17 -1
- package/components/workspace/catalog-store.js +1 -0
- package/gateway/dashboard-cards-route.js +4 -9
- package/gateway/form-handler-resolution.js +10 -34
- package/gateway/navigation-target-route.js +4 -10
- package/gateway/page-references-route.js +3 -8
- package/gateway/site-area.d.ts +43 -6
- package/gateway/site-area.js +70 -17
- package/helpers/cms-area-config.d.ts +36 -14
- package/helpers/cms-area-config.js +72 -26
- package/helpers/cms-dialog.d.ts +0 -1
- package/helpers/cms-dialog.js +0 -1
- package/helpers/cms-layout-defaults.d.ts +4 -0
- package/helpers/cms-layout-defaults.js +14 -17
- package/helpers/cms-region-keys.d.ts +1 -1
- package/helpers/page-layout-check.js +4 -1
- package/next/seo-routes.js +24 -28
- package/package.json +2 -2
- package/plugins/runtime-modules/accounting/presets.d.ts +0 -1
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-area-preset-tree.js +0 -2
- package/plugins/runtime-modules/admin/presets.d.ts +0 -1
- package/plugins/runtime-modules/admin/trees/phi-default-admin-area-preset-tree.js +0 -2
- package/plugins/runtime-modules/app/presets.d.ts +0 -1
- package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.js +0 -2
- package/plugins/runtime-modules/area-definitions.d.ts +17 -0
- package/plugins/runtime-modules/area-definitions.js +6 -0
- package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +0 -2
- package/plugins/runtime-modules/builder/area-shell-presets.server.d.ts +21 -5
- package/plugins/runtime-modules/builder/area-shell-presets.server.js +171 -63
- package/plugins/runtime-modules/builder/clients/shells-workspace.js +12 -1
- package/plugins/runtime-modules/builder/controller/client.js +2 -0
- package/plugins/runtime-modules/builder/controller/definition.d.ts +1 -0
- package/plugins/runtime-modules/builder/controller/draft-command-controller.d.ts +2 -3
- package/plugins/runtime-modules/builder/controller/draft-command-controller.js +56 -25
- package/plugins/runtime-modules/builder/controller/draft-status-controller.js +13 -7
- package/plugins/runtime-modules/builder/controller/server-definition.d.ts +1 -0
- package/plugins/runtime-modules/builder/controller/server-definition.js +7 -4
- package/plugins/runtime-modules/builder/controller/workspace-controller.d.ts +2 -1
- package/plugins/runtime-modules/builder/controller/workspace-controller.js +9 -3
- package/plugins/runtime-modules/builder/data-providers.d.ts +1 -1
- package/plugins/runtime-modules/builder/definition.d.ts +1 -1
- package/plugins/runtime-modules/builder/developer-workspace-store.js +1 -0
- package/plugins/runtime-modules/builder/page-preset-catalog.server.d.ts +0 -2
- package/plugins/runtime-modules/builder/page-preset-catalog.server.js +0 -16
- package/plugins/runtime-modules/builder/persistence.d.ts +20 -25
- package/plugins/runtime-modules/builder/persistence.js +67 -75
- package/plugins/runtime-modules/builder/services/runtime-modules-table.d.ts +17 -0
- package/plugins/runtime-modules/builder/services/runtime-modules-table.js +79 -2
- package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +0 -1
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.d.ts +0 -1
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +1 -10
- package/plugins/runtime-modules/builder/workspace-catalog-actions.d.ts +2 -1
- package/plugins/runtime-modules/builder/workspace-catalog-actions.js +3 -1
- package/plugins/runtime-modules/core/widgets/cascader/authoring.d.ts +1 -1
- package/plugins/runtime-modules/descriptor-compiler.d.ts +16 -2
- package/plugins/runtime-modules/descriptor-compiler.js +69 -13
- package/plugins/runtime-modules/editor/services/releases-table.js +26 -14
- package/plugins/runtime-modules/editor/trees/phi-default-editor-area-preset-tree.js +0 -2
- package/plugins/runtime-modules/groups/definition.d.ts +1 -1
- package/plugins/runtime-modules/localization/trees/phi-default-admin-locales-page-tree.js +0 -2
- package/plugins/runtime-modules/phi-default-site-area-preset-tree.js +0 -4
- package/plugins/runtime-modules/revisions/controller/client.js +13 -7
- package/plugins/runtime-modules/revisions/services/table.js +10 -3
- package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +0 -1
- package/plugins/runtime-modules/shell-tree-composition.d.ts +0 -2
- package/plugins/runtime-modules/shell-tree-composition.js +0 -3
- package/plugins/runtime-modules/theme/trees/phi-default-builder-theme-page-tree.js +0 -6
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +17 -1
- package/server-helpers/area-root-door-warmup.d.ts +5 -2
- package/server-helpers/area-root-door-warmup.js +2 -10
- package/server-helpers/cms-area.d.ts +9 -1
- package/server-helpers/cms-area.js +16 -11
- package/server-helpers/cms-lookup.js +1 -1
- package/server-helpers/cms-request.d.ts +58 -13
- package/server-helpers/cms-request.js +103 -33
- package/server-helpers/cms-root.d.ts +4 -0
- package/server-helpers/cms-root.js +48 -35
- package/server-helpers/cms.d.ts +5 -5
- package/server-helpers/public-login-route.js +4 -9
- package/server-helpers/search-index.js +9 -14
- package/styles/shell.css +12 -0
- package/theme/antd-css-var-contract.d.ts +6 -0
- package/theme/antd-css-var-contract.js +6 -0
- package/theme/phi-theme-tokens.d.ts +3 -2
- package/theme/phi-theme-tokens.js +11 -1
- package/theme/phi-theme.d.ts +2 -0
- package/theme/phi-theme.js +2 -0
- package/theme/phi-tokens.d.ts +1 -0
- package/theme/phi-tokens.js +7 -0
- package/theme.d.ts +1 -1
- package/theme.js +1 -1
- package/types/cms-module-descriptors.d.ts +26 -1
- package/types/cms-plugins.d.ts +3 -0
- package/types/cms.d.ts +10 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "server-only";
|
|
2
2
|
import { PHI_BUILDER_RUNTIME_CONTROLLER_DEFINITION, } from "./definition";
|
|
3
|
-
import { buildPhiBuilderAreaRootRoutesByArea, buildPhiBuilderAreaMetaByArea, buildPhiBuilderAreaControllerSettingsByArea, buildPhiBuilderPublicRoutePaths, buildPhiBuilderPublishedRuntimeModuleIdsForArea, buildPhiBuilderStructureRuntimeModuleIdsByArea, buildPhiBuilderUnresolvedRuntimeModuleIdsByArea, buildPhiBuilderStructureShellPresetDraftsByArea, } from "../area-shell-presets.server";
|
|
4
|
-
import {
|
|
3
|
+
import { buildPhiBuilderAreaPresetSourcesByArea, buildPhiBuilderAreaRootRoutesByArea, buildPhiBuilderAreaMetaByArea, buildPhiBuilderAreaShellsByArea, buildPhiBuilderAreaControllerSettingsByArea, buildPhiBuilderPublicRoutePaths, buildPhiBuilderPublishedRuntimeModuleIdsForArea, buildPhiBuilderStructureRuntimeModuleIdsByArea, buildPhiBuilderUnresolvedRuntimeModuleIdsByArea, buildPhiBuilderStructureShellPresetDraftsByArea, } from "../area-shell-presets.server";
|
|
4
|
+
import { buildPhiBuilderModulePresetPagesByArea, buildPhiBuilderPublicRouteClaims, } from "../page-preset-catalog.server";
|
|
5
5
|
import { buildPhiBuilderNavigationSurfacesByArea } from "../navigation-catalog.server";
|
|
6
6
|
import { PHI_BUILDER_AREA_SEARCH_PARAM, PHI_BUILDER_RUNTIME_MODULES_SEARCH_PARAM, normalizePhiBuilderAreaSearchParam, normalizePhiBuilderRuntimeModuleIdsSearchParam, } from "../../../../helpers/cms-scope-search-params";
|
|
7
7
|
import { resolvePhiRuntimeModuleIdsForArea } from "../../../../plugins/runtime-modules/settings";
|
|
@@ -13,7 +13,7 @@ import { buildPhiWidgetLabelTranslatorOptions } from "../../../../components/wid
|
|
|
13
13
|
export const PHI_BUILDER_RUNTIME_CONTROLLER_SERVER_DEFINITION = {
|
|
14
14
|
...PHI_BUILDER_RUNTIME_CONTROLLER_DEFINITION,
|
|
15
15
|
serverPreload: async ({ runtime, runtimeModuleCatalog, serverCapabilities }) => {
|
|
16
|
-
const [shellPresetDraftsByArea, runtimeModuleIdsByArea, unresolvedModuleIdsByArea, publicRoutePaths, areaRootRoutesByArea, areaMetaByArea, areaControllerSettingsByArea, builderLabels, historyLabels, livePublicModuleIds,] = await Promise.all([
|
|
16
|
+
const [shellPresetDraftsByArea, runtimeModuleIdsByArea, unresolvedModuleIdsByArea, publicRoutePaths, areaRootRoutesByArea, areaMetaByArea, areaControllerSettingsByArea, builderLabels, historyLabels, livePublicModuleIds, areaPresetSourcesByArea, areaShellsByArea,] = await Promise.all([
|
|
17
17
|
buildPhiBuilderStructureShellPresetDraftsByArea(runtime, runtimeModuleCatalog),
|
|
18
18
|
buildPhiBuilderStructureRuntimeModuleIdsByArea(runtime, runtimeModuleCatalog),
|
|
19
19
|
buildPhiBuilderUnresolvedRuntimeModuleIdsByArea(runtime, runtimeModuleCatalog),
|
|
@@ -24,6 +24,8 @@ export const PHI_BUILDER_RUNTIME_CONTROLLER_SERVER_DEFINITION = {
|
|
|
24
24
|
getPhiBuilderChromeWidgetLabels(buildPhiWidgetLabelTranslatorOptions(runtime)),
|
|
25
25
|
getPhiHistoryLabels(buildPhiWidgetLabelTranslatorOptions(runtime)),
|
|
26
26
|
buildPhiBuilderPublishedRuntimeModuleIdsForArea(runtime, "public", runtimeModuleCatalog),
|
|
27
|
+
buildPhiBuilderAreaPresetSourcesByArea(runtime, runtimeModuleCatalog),
|
|
28
|
+
buildPhiBuilderAreaShellsByArea(runtime, runtimeModuleCatalog),
|
|
27
29
|
]);
|
|
28
30
|
const requestedArea = normalizePhiBuilderAreaSearchParam(runtime.request?.searchParams?.[PHI_BUILDER_AREA_SEARCH_PARAM]);
|
|
29
31
|
const requestedModuleIds = normalizePhiBuilderRuntimeModuleIdsSearchParam(runtime.request?.searchParams?.[PHI_BUILDER_RUNTIME_MODULES_SEARCH_PARAM]);
|
|
@@ -66,7 +68,8 @@ export const PHI_BUILDER_RUNTIME_CONTROLLER_SERVER_DEFINITION = {
|
|
|
66
68
|
areaMetaByArea,
|
|
67
69
|
areaControllerSettingsByArea,
|
|
68
70
|
modulePresetPagesByArea: buildPhiBuilderModulePresetPagesByArea(runtimeModuleCatalog),
|
|
69
|
-
areaPresetSourcesByArea
|
|
71
|
+
areaPresetSourcesByArea,
|
|
72
|
+
areaShellsByArea,
|
|
70
73
|
navigationSurfacesByArea: await buildPhiBuilderNavigationSurfacesByArea(runtime, runtimeModuleCatalog, effectiveRuntimeModuleIdsByArea),
|
|
71
74
|
pageMetaLabels: {
|
|
72
75
|
createTitle: builderLabels.pages.newPage,
|
|
@@ -13,6 +13,7 @@ export type PhiDeveloperBuilderWorkspaceControllerProps = {
|
|
|
13
13
|
runtimeModuleIdsByArea?: Record<string, PhiRuntimeModuleId[]>;
|
|
14
14
|
modulePresetPagesByArea?: PhiWorkspaceCatalogState["modulePresetPagesByArea"];
|
|
15
15
|
areaPresetSourcesByArea?: PhiWorkspaceCatalogState["areaPresetSourcesByArea"];
|
|
16
|
+
areaShellsByArea?: PhiWorkspaceCatalogState["areaShellsByArea"];
|
|
16
17
|
navigationSurfacesByArea?: PhiWorkspaceCatalogState["navigationSurfacesByArea"];
|
|
17
18
|
unresolvedModuleIdsByArea?: PhiWorkspaceCatalogState["unresolvedModuleIdsByArea"];
|
|
18
19
|
serverUnavailableModules?: PhiWorkspaceCatalogState["serverUnavailableModules"];
|
|
@@ -26,4 +27,4 @@ export type PhiDeveloperBuilderWorkspaceControllerProps = {
|
|
|
26
27
|
historyLabels: PhiHistoryLabels;
|
|
27
28
|
signalRoutes?: PhiSignalRouteSet | null;
|
|
28
29
|
};
|
|
29
|
-
export declare function PhiDeveloperBuilderWorkspaceController({ shellPresetDraftsByArea, runtimeModuleDefinitions, runtimeModuleIdsByArea, modulePresetPagesByArea, areaPresetSourcesByArea, navigationSurfacesByArea, unresolvedModuleIdsByArea, serverUnavailableModules, publicRouteClaims, publicRoutePaths, areaRootRoutesByArea, areaMetaByArea, areaControllerSettingsByArea, pageMetaLabels, historyLabels, signalRoutes, }: PhiDeveloperBuilderWorkspaceControllerProps): import("react").JSX.Element;
|
|
30
|
+
export declare function PhiDeveloperBuilderWorkspaceController({ shellPresetDraftsByArea, runtimeModuleDefinitions, runtimeModuleIdsByArea, modulePresetPagesByArea, areaPresetSourcesByArea, areaShellsByArea, navigationSurfacesByArea, unresolvedModuleIdsByArea, serverUnavailableModules, publicRouteClaims, publicRoutePaths, areaRootRoutesByArea, areaMetaByArea, areaControllerSettingsByArea, pageMetaLabels, historyLabels, signalRoutes, }: PhiDeveloperBuilderWorkspaceControllerProps): import("react").JSX.Element;
|
|
@@ -48,6 +48,7 @@ import { PHI_BUILDER_PAGE_META_DEFAULT_PRESENTATION_LABELS, resolvePhiBuilderEff
|
|
|
48
48
|
import { formatPhiHistoryTooltip, } from "../../../../components/widgets/label-types/history";
|
|
49
49
|
const EMPTY_RUNTIME_MODULE_IDS_BY_AREA = {};
|
|
50
50
|
const EMPTY_SERVER_UNAVAILABLE_MODULES = {};
|
|
51
|
+
const EMPTY_AREA_SHELLS = {};
|
|
51
52
|
const EMPTY_MODULE_PRESET_PAGES_BY_AREA = createEmptyPhiBuilderModulePresetPagesByArea();
|
|
52
53
|
const EMPTY_PUBLIC_ROUTE_CLAIMS = [];
|
|
53
54
|
const EMPTY_PUBLIC_ROUTE_PATHS = [];
|
|
@@ -129,7 +130,7 @@ function usePhiDeveloperBuilderWorkspaceController(options) {
|
|
|
129
130
|
const effectsWorkflowCorrelationRef = useRef(null);
|
|
130
131
|
const initializedEffectsCorrelationRef = useRef(null);
|
|
131
132
|
const effectsFormSubmissionRef = useRef(null);
|
|
132
|
-
const { shellPresetDraftsByArea = {}, runtimeModuleDefinitions = [], runtimeModuleIdsByArea = {}, modulePresetPagesByArea = EMPTY_MODULE_PRESET_PAGES_BY_AREA, areaPresetSourcesByArea = {}, navigationSurfacesByArea = {}, unresolvedModuleIdsByArea = EMPTY_RUNTIME_MODULE_IDS_BY_AREA, serverUnavailableModules = EMPTY_SERVER_UNAVAILABLE_MODULES, publicRouteClaims = EMPTY_PUBLIC_ROUTE_CLAIMS, publicRoutePaths = EMPTY_PUBLIC_ROUTE_PATHS, areaRootRoutesByArea = EMPTY_AREA_ROOT_ROUTES, areaMetaByArea = EMPTY_AREA_META, areaControllerSettingsByArea = EMPTY_AREA_CONTROLLER_SETTINGS, pageMetaLabels = PHI_BUILDER_PAGE_META_DEFAULT_PRESENTATION_LABELS, historyLabels, signalRoutes = null, } = options;
|
|
133
|
+
const { shellPresetDraftsByArea = {}, runtimeModuleDefinitions = [], runtimeModuleIdsByArea = {}, modulePresetPagesByArea = EMPTY_MODULE_PRESET_PAGES_BY_AREA, areaPresetSourcesByArea = {}, areaShellsByArea = EMPTY_AREA_SHELLS, navigationSurfacesByArea = {}, unresolvedModuleIdsByArea = EMPTY_RUNTIME_MODULE_IDS_BY_AREA, serverUnavailableModules = EMPTY_SERVER_UNAVAILABLE_MODULES, publicRouteClaims = EMPTY_PUBLIC_ROUTE_CLAIMS, publicRoutePaths = EMPTY_PUBLIC_ROUTE_PATHS, areaRootRoutesByArea = EMPTY_AREA_ROOT_ROUTES, areaMetaByArea = EMPTY_AREA_META, areaControllerSettingsByArea = EMPTY_AREA_CONTROLLER_SETTINGS, pageMetaLabels = PHI_BUILDER_PAGE_META_DEFAULT_PRESENTATION_LABELS, historyLabels, signalRoutes = null, } = options;
|
|
133
134
|
/*
|
|
134
135
|
* One declared output, delivered through every route written for it.
|
|
135
136
|
*
|
|
@@ -185,7 +186,6 @@ function usePhiDeveloperBuilderWorkspaceController(options) {
|
|
|
185
186
|
captureHistoryHead,
|
|
186
187
|
hasUnsavedChanges,
|
|
187
188
|
reportSaved,
|
|
188
|
-
shellPresetDraftsByArea,
|
|
189
189
|
state,
|
|
190
190
|
historyLabels,
|
|
191
191
|
});
|
|
@@ -205,6 +205,7 @@ function usePhiDeveloperBuilderWorkspaceController(options) {
|
|
|
205
205
|
const runtimeModuleDefinitionsPreloadKey = useMemo(() => serializeRuntimeModuleDefinitions(runtimeModuleDefinitions), [runtimeModuleDefinitions]);
|
|
206
206
|
const modulePresetPagesPreloadKey = useMemo(() => JSON.stringify(activePreloadCatalogs.modulePresetPagesByArea), [activePreloadCatalogs.modulePresetPagesByArea]);
|
|
207
207
|
const areaPresetSourcesPreloadKey = useMemo(() => JSON.stringify(areaPresetSourcesByArea), [areaPresetSourcesByArea]);
|
|
208
|
+
const areaShellsPreloadKey = useMemo(() => JSON.stringify(areaShellsByArea), [areaShellsByArea]);
|
|
208
209
|
const navigationSurfacesPreloadKey = useMemo(() => JSON.stringify(activePreloadCatalogs.navigationSurfacesByArea), [activePreloadCatalogs.navigationSurfacesByArea]);
|
|
209
210
|
const unresolvedModuleIdsPreloadKey = useMemo(() => JSON.stringify(unresolvedModuleIdsByArea), [unresolvedModuleIdsByArea]);
|
|
210
211
|
const publicRouteClaimsPreloadKey = useMemo(() => JSON.stringify(publicRouteClaims), [publicRouteClaims]);
|
|
@@ -434,6 +435,7 @@ function usePhiDeveloperBuilderWorkspaceController(options) {
|
|
|
434
435
|
runtimeModuleDefinitions,
|
|
435
436
|
runtimeModuleIdsByArea,
|
|
436
437
|
areaPresetSourcesByArea,
|
|
438
|
+
areaShellsByArea,
|
|
437
439
|
unresolvedModuleIdsByArea,
|
|
438
440
|
serverUnavailableModules,
|
|
439
441
|
publicRouteClaims,
|
|
@@ -443,6 +445,7 @@ function usePhiDeveloperBuilderWorkspaceController(options) {
|
|
|
443
445
|
runtimeModuleDefinitions: runtimeModuleDefinitionsPreloadKey,
|
|
444
446
|
modulePresetPagesByArea: modulePresetPagesPreloadKey,
|
|
445
447
|
areaPresetSourcesByArea: areaPresetSourcesPreloadKey,
|
|
448
|
+
areaShellsByArea: areaShellsPreloadKey,
|
|
446
449
|
navigationSurfacesByArea: navigationSurfacesPreloadKey,
|
|
447
450
|
unresolvedModuleIdsByArea: unresolvedModuleIdsPreloadKey,
|
|
448
451
|
publicRouteClaims: publicRouteClaimsPreloadKey,
|
|
@@ -472,6 +475,8 @@ function usePhiDeveloperBuilderWorkspaceController(options) {
|
|
|
472
475
|
publicRoutePathsPreloadKey,
|
|
473
476
|
areaPresetSourcesByArea,
|
|
474
477
|
areaPresetSourcesPreloadKey,
|
|
478
|
+
areaShellsByArea,
|
|
479
|
+
areaShellsPreloadKey,
|
|
475
480
|
activePreloadCatalogs,
|
|
476
481
|
navigationSurfacesByArea,
|
|
477
482
|
navigationSurfacesPreloadKey,
|
|
@@ -1439,13 +1444,14 @@ function usePhiDeveloperBuilderWorkspaceController(options) {
|
|
|
1439
1444
|
*/
|
|
1440
1445
|
return _jsxs(_Fragment, { children: [pageMetaDialog, confirmDialog] });
|
|
1441
1446
|
}
|
|
1442
|
-
export function PhiDeveloperBuilderWorkspaceController({ shellPresetDraftsByArea = {}, runtimeModuleDefinitions = [], runtimeModuleIdsByArea = {}, modulePresetPagesByArea = EMPTY_MODULE_PRESET_PAGES_BY_AREA, areaPresetSourcesByArea = {}, navigationSurfacesByArea = {}, unresolvedModuleIdsByArea = EMPTY_RUNTIME_MODULE_IDS_BY_AREA, serverUnavailableModules = EMPTY_SERVER_UNAVAILABLE_MODULES, publicRouteClaims = EMPTY_PUBLIC_ROUTE_CLAIMS, publicRoutePaths = EMPTY_PUBLIC_ROUTE_PATHS, areaRootRoutesByArea = EMPTY_AREA_ROOT_ROUTES, areaMetaByArea = EMPTY_AREA_META, areaControllerSettingsByArea = EMPTY_AREA_CONTROLLER_SETTINGS, pageMetaLabels = PHI_BUILDER_PAGE_META_DEFAULT_PRESENTATION_LABELS, historyLabels, signalRoutes = null, }) {
|
|
1447
|
+
export function PhiDeveloperBuilderWorkspaceController({ shellPresetDraftsByArea = {}, runtimeModuleDefinitions = [], runtimeModuleIdsByArea = {}, modulePresetPagesByArea = EMPTY_MODULE_PRESET_PAGES_BY_AREA, areaPresetSourcesByArea = {}, areaShellsByArea = EMPTY_AREA_SHELLS, navigationSurfacesByArea = {}, unresolvedModuleIdsByArea = EMPTY_RUNTIME_MODULE_IDS_BY_AREA, serverUnavailableModules = EMPTY_SERVER_UNAVAILABLE_MODULES, publicRouteClaims = EMPTY_PUBLIC_ROUTE_CLAIMS, publicRoutePaths = EMPTY_PUBLIC_ROUTE_PATHS, areaRootRoutesByArea = EMPTY_AREA_ROOT_ROUTES, areaMetaByArea = EMPTY_AREA_META, areaControllerSettingsByArea = EMPTY_AREA_CONTROLLER_SETTINGS, pageMetaLabels = PHI_BUILDER_PAGE_META_DEFAULT_PRESENTATION_LABELS, historyLabels, signalRoutes = null, }) {
|
|
1443
1448
|
const controller = usePhiDeveloperBuilderWorkspaceController({
|
|
1444
1449
|
shellPresetDraftsByArea,
|
|
1445
1450
|
runtimeModuleDefinitions,
|
|
1446
1451
|
runtimeModuleIdsByArea,
|
|
1447
1452
|
modulePresetPagesByArea,
|
|
1448
1453
|
areaPresetSourcesByArea,
|
|
1454
|
+
areaShellsByArea,
|
|
1449
1455
|
navigationSurfacesByArea,
|
|
1450
1456
|
unresolvedModuleIdsByArea,
|
|
1451
1457
|
serverUnavailableModules,
|
|
@@ -451,7 +451,7 @@ export declare const PHI_BUILDER_RUNTIME_DATA_PROVIDER_DESCRIPTORS: ({
|
|
|
451
451
|
};
|
|
452
452
|
dropTargets: {
|
|
453
453
|
payloadType: "@phis/builder-navigation-page";
|
|
454
|
-
modes: ("
|
|
454
|
+
modes: ("before" | "after" | "child" | "append")[];
|
|
455
455
|
}[];
|
|
456
456
|
}[];
|
|
457
457
|
} | {
|
|
@@ -454,7 +454,7 @@ export declare const PHI_BUILDER_RUNTIME_MODULE_DEFINITION: Omit<{
|
|
|
454
454
|
};
|
|
455
455
|
dropTargets: {
|
|
456
456
|
payloadType: "@phis/builder-navigation-page";
|
|
457
|
-
modes: ("
|
|
457
|
+
modes: ("before" | "after" | "child" | "append")[];
|
|
458
458
|
}[];
|
|
459
459
|
}[];
|
|
460
460
|
} | {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "server-only";
|
|
2
2
|
import type { PhiRuntimeModuleCatalog } from "../../../types";
|
|
3
3
|
import type { PhiBuilderModulePresetPagesByArea } from "../../../helpers/cms-page-catalog";
|
|
4
|
-
import type { PhiCmsPresetSource } from "../../../types/cms-module-descriptors";
|
|
5
4
|
import type { PhiPublicRouteClaim } from "../../../helpers/public-route-claims";
|
|
6
5
|
export declare function buildPhiBuilderModulePresetPagesByArea(runtimeModuleCatalog: PhiRuntimeModuleCatalog): PhiBuilderModulePresetPagesByArea;
|
|
7
6
|
/**
|
|
@@ -12,4 +11,3 @@ export declare function buildPhiBuilderModulePresetPagesByArea(runtimeModuleCata
|
|
|
12
11
|
* its switch. Which of them currently answer is decided elsewhere, from the active set.
|
|
13
12
|
*/
|
|
14
13
|
export declare function buildPhiBuilderPublicRouteClaims(runtimeModuleCatalog: PhiRuntimeModuleCatalog): PhiPublicRouteClaim[];
|
|
15
|
-
export declare function buildPhiBuilderAreaPresetSourcesByArea(runtimeModuleCatalog: PhiRuntimeModuleCatalog): Partial<Record<"public" | "app" | "admin" | "builder" | "editor" | "accounting", PhiCmsPresetSource>>;
|
|
@@ -48,19 +48,3 @@ export function buildPhiBuilderPublicRouteClaims(runtimeModuleCatalog) {
|
|
|
48
48
|
}
|
|
49
49
|
return claims;
|
|
50
50
|
}
|
|
51
|
-
export function buildPhiBuilderAreaPresetSourcesByArea(runtimeModuleCatalog) {
|
|
52
|
-
const sources = {};
|
|
53
|
-
const catalog = resolvePhiCmsDescriptorCatalog(runtimeModuleCatalog);
|
|
54
|
-
for (const { descriptor } of catalog.areaShellByArea.values()) {
|
|
55
|
-
const area = resolveBuilderArea(descriptor.area);
|
|
56
|
-
if (!area) {
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
sources[area] = {
|
|
60
|
-
ownerModuleId: descriptor.ownerModuleId,
|
|
61
|
-
presetKey: descriptor.presetKey,
|
|
62
|
-
sourcePresetVersion: descriptor.shellPresetVersion,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
return sources;
|
|
66
|
-
}
|
|
@@ -3,7 +3,7 @@ import { type PhiCmsInstanceId } from "../../../types/cms-instance-id";
|
|
|
3
3
|
import type { PhiDeveloperBuilderArea, PhiDeveloperBuilderRegionDraft, PhiDeveloperBuilderWorkspaceState } from "./developer-workspace-types";
|
|
4
4
|
import type { PhiCmsWidgetContentBinding } from "../../../types/cms-plugins";
|
|
5
5
|
import { type PhiPresetPageNode } from "../../../helpers/cms-page-catalog";
|
|
6
|
-
import type { PhiCmsPresetSource } from "../../../types/cms-module-descriptors";
|
|
6
|
+
import type { PhiCmsPresetIdentity, PhiCmsPresetSource } from "../../../types/cms-module-descriptors";
|
|
7
7
|
import type { PhiBuilderPluginMeta, PhiBuilderWidgetMeta } from "../../../types/builder";
|
|
8
8
|
export type SerializedRoot = {
|
|
9
9
|
rootLayoutNodeId: PhiCmsInstanceId;
|
|
@@ -13,6 +13,17 @@ export type SerializedRoot = {
|
|
|
13
13
|
}>;
|
|
14
14
|
};
|
|
15
15
|
export type PhiDeveloperBuilderWorkspaceKind = "structure" | "pages";
|
|
16
|
+
/**
|
|
17
|
+
* A structure save under the Area's effective shell while the Area stores its one structure under
|
|
18
|
+
* another shell's identity -- the base shell's, typically, saved before a Module that brings its own was
|
|
19
|
+
* switched on. Core keeps one structure per Area and refuses the save (409); the stored one has to be
|
|
20
|
+
* cleared first ("Clear Area" in Revisions), and the Module selection survives that.
|
|
21
|
+
*/
|
|
22
|
+
export declare class PhiBuilderAreaStructureTakenError extends Error {
|
|
23
|
+
readonly area: PhiDeveloperBuilderArea;
|
|
24
|
+
readonly storedSource: PhiCmsPresetIdentity;
|
|
25
|
+
constructor(area: PhiDeveloperBuilderArea, storedSource: PhiCmsPresetIdentity);
|
|
26
|
+
}
|
|
16
27
|
/**
|
|
17
28
|
* Creating a Page at a path a Page already holds. The server wrote nothing; the Builder opens the Page
|
|
18
29
|
* that is there instead of the blank one it meant to create.
|
|
@@ -55,7 +66,6 @@ export declare function getPhiDeveloperBuilderDraftAllocation(input: {
|
|
|
55
66
|
/** The Area's open Module draft, if the Builder does not already have it cached. */
|
|
56
67
|
export declare function getPhiDeveloperBuilderModulesDraftAllocation(input: {
|
|
57
68
|
area: PhiDeveloperBuilderArea;
|
|
58
|
-
areaPresetSource: PhiCmsPresetSource | null;
|
|
59
69
|
}): Promise<{
|
|
60
70
|
revisionId: number;
|
|
61
71
|
version: number;
|
|
@@ -65,46 +75,31 @@ export declare function getPhiDeveloperBuilderModulesDraftAllocation(input: {
|
|
|
65
75
|
/**
|
|
66
76
|
* Saves an Area's Module selection, apart from its structure.
|
|
67
77
|
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* already has it loaded (every `/builder/*` page does, regardless of which one is open), so this is the
|
|
73
|
-
* one path along which a Module save reaches into Shell region drafts at all.
|
|
74
|
-
*
|
|
75
|
-
* Which is why the Shell preset is a second source here. The region drafts hold what a workspace has
|
|
76
|
-
* *hydrated*, and the Modules workspace hydrates none: it edits a selection, not a structure. Building
|
|
77
|
-
* the baseline from those alone therefore worked on the Shells page and nowhere else, and an operator
|
|
78
|
-
* activating a Module for a fresh Area was told to go and create a Shell first -- for a Shell that
|
|
79
|
-
* already exists in code and that they were not going to change. The preset fills whatever the drafts
|
|
80
|
-
* do not hold, and an open draft still wins where there is one.
|
|
78
|
+
* The selection has revisions of its own (a Modules revision of the Area), so this writes only
|
|
79
|
+
* `config.modules` and never touches the structure: an Area that never stored a structure keeps running
|
|
80
|
+
* on its code-owned shell, and the next shell preset still reaches it. Which shell that is follows from
|
|
81
|
+
* the selection -- a Module that brings its own shell applies once it is active here.
|
|
81
82
|
*/
|
|
82
|
-
export declare function savePhiDeveloperBuilderModulesDraft(state: Pick<PhiDeveloperBuilderWorkspaceState, "draftAllocations" | "runtimeModuleDefinitions" | "runtimeModuleIdsByArea" | "
|
|
83
|
-
builderPlugins: readonly PhiBuilderPluginMeta[];
|
|
83
|
+
export declare function savePhiDeveloperBuilderModulesDraft(state: Pick<PhiDeveloperBuilderWorkspaceState, "draftAllocations" | "runtimeModuleDefinitions" | "runtimeModuleIdsByArea" | "publicRoutePaths" | "publicRouteClaims">, options: {
|
|
84
84
|
scope: {
|
|
85
85
|
area: PhiDeveloperBuilderArea;
|
|
86
86
|
};
|
|
87
|
-
/** The Area's code-owned Shell, for the one case where nothing is stored and nothing is loaded. */
|
|
88
|
-
shellPresetDrafts?: Record<string, PhiDeveloperBuilderRegionDraft> | null;
|
|
89
87
|
}): Promise<{
|
|
90
88
|
revisionId: number;
|
|
91
89
|
version: number;
|
|
92
90
|
nextNodeSequence: number;
|
|
93
91
|
}>;
|
|
94
92
|
/** Publishes the Area's Module selection. Its structure draft, if one is open, is left exactly as it is. */
|
|
95
|
-
export declare function publishPhiDeveloperBuilderModulesDraft(state: Pick<PhiDeveloperBuilderWorkspaceState, "draftAllocations" | "runtimeModuleDefinitions" | "runtimeModuleIdsByArea" | "
|
|
96
|
-
builderPlugins: readonly PhiBuilderPluginMeta[];
|
|
93
|
+
export declare function publishPhiDeveloperBuilderModulesDraft(state: Pick<PhiDeveloperBuilderWorkspaceState, "draftAllocations" | "runtimeModuleDefinitions" | "runtimeModuleIdsByArea" | "publicRoutePaths" | "publicRouteClaims">, options: {
|
|
97
94
|
scope: {
|
|
98
95
|
area: PhiDeveloperBuilderArea;
|
|
99
96
|
};
|
|
100
|
-
/** As on save: without it an Area with no stored revision met the 409 fallback with nothing to write. */
|
|
101
|
-
shellPresetDrafts?: Record<string, PhiDeveloperBuilderRegionDraft> | null;
|
|
102
97
|
}): Promise<{
|
|
103
98
|
revisionId: number;
|
|
104
99
|
version: number;
|
|
105
100
|
nextNodeSequence: number;
|
|
106
101
|
}>;
|
|
107
|
-
export declare function savePhiDeveloperBuilderDraft(state: Pick<PhiDeveloperBuilderWorkspaceState, "area" | "pageKey" | "pageMetaDrafts" | "deletedPageDrafts" | "draftAllocations" | "modulePresetPagesByArea" | "customPages" | "persistedPageCatalogByArea" | "areaPresetSourcesByArea" | "areaRootRouteDrafts" | "areaRootRoutes" | "areaMetaDrafts" | "areaMeta" | "areaControllerSettings" | "pageControllerSettings">, regionDrafts: Record<string, PhiDeveloperBuilderRegionDraft>, workspaceKind: PhiDeveloperBuilderWorkspaceKind, options: {
|
|
102
|
+
export declare function savePhiDeveloperBuilderDraft(state: Pick<PhiDeveloperBuilderWorkspaceState, "area" | "pageKey" | "pageMetaDrafts" | "deletedPageDrafts" | "draftAllocations" | "modulePresetPagesByArea" | "customPages" | "persistedPageCatalogByArea" | "areaPresetSourcesByArea" | "areaRootRouteDrafts" | "areaRootRoutes" | "areaMetaDrafts" | "areaMeta" | "areaControllerSettings" | "pageControllerSettings" | "areaShellsByArea">, regionDrafts: Record<string, PhiDeveloperBuilderRegionDraft>, workspaceKind: PhiDeveloperBuilderWorkspaceKind, options: {
|
|
108
103
|
builderPlugins: readonly PhiBuilderPluginMeta[];
|
|
109
104
|
pathname?: string | null;
|
|
110
105
|
scope?: {
|
|
@@ -150,7 +145,7 @@ export declare function previewPhiDeveloperBuilderDraft(state: Pick<PhiDeveloper
|
|
|
150
145
|
revisionId: number;
|
|
151
146
|
previewHref: string;
|
|
152
147
|
}>;
|
|
153
|
-
export declare function publishPhiDeveloperBuilderDraft(state: Pick<PhiDeveloperBuilderWorkspaceState, "area" | "pageKey" | "pageMetaDrafts" | "deletedPageDrafts" | "draftAllocations" | "runtimeModuleDefinitions" | "runtimeModuleIdsByArea" | "modulePresetPagesByArea" | "customPages" | "persistedPageCatalogByArea" | "areaPresetSourcesByArea" | "areaRootRouteDrafts" | "areaRootRoutes" | "areaMetaDrafts" | "areaMeta" | "areaControllerSettings" | "pageControllerSettings">, regionDrafts: Record<string, PhiDeveloperBuilderRegionDraft>, workspaceKind: PhiDeveloperBuilderWorkspaceKind, options: {
|
|
148
|
+
export declare function publishPhiDeveloperBuilderDraft(state: Pick<PhiDeveloperBuilderWorkspaceState, "area" | "pageKey" | "pageMetaDrafts" | "deletedPageDrafts" | "draftAllocations" | "runtimeModuleDefinitions" | "runtimeModuleIdsByArea" | "modulePresetPagesByArea" | "customPages" | "persistedPageCatalogByArea" | "areaPresetSourcesByArea" | "areaRootRouteDrafts" | "areaRootRoutes" | "areaMetaDrafts" | "areaMeta" | "areaControllerSettings" | "pageControllerSettings" | "areaShellsByArea">, regionDrafts: Record<string, PhiDeveloperBuilderRegionDraft>, workspaceKind: PhiDeveloperBuilderWorkspaceKind, options: {
|
|
154
149
|
builderPlugins: readonly PhiBuilderPluginMeta[];
|
|
155
150
|
pathname?: string | null;
|
|
156
151
|
scope?: {
|
|
@@ -18,12 +18,29 @@ import { isPhiRuntimeModuleId } from "../../../constants/module-identity";
|
|
|
18
18
|
import { createPhiResponseReader, requirePhiField } from "../../../components/widgets/config/strict-config-reader";
|
|
19
19
|
import { PHI_AREA_CONFIG_MODULES_NAMESPACE, PHI_AREA_CONFIG_SHELL_NAMESPACE, PHI_AREA_PUBLIC_ROUTE_PATHS_KEY, PHI_AREA_ROOT_ROUTE_KEY, PHI_AREA_META_KEY, normalizePhiAreaPublicRoutePaths, } from "../../../helpers/cms-area-config";
|
|
20
20
|
/**
|
|
21
|
-
* A save
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* A save Core refused with 409: a Draft written past, or a structure saved under a shell identity while
|
|
22
|
+
* the Area stores its structure under another. The second is what `PhiBuilderAreaStructureTakenError`
|
|
23
|
+
* names, so the Builder can offer to clear the stored structure first.
|
|
24
24
|
*/
|
|
25
25
|
class CmsDraftConflictError extends Error {
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* A structure save under the Area's effective shell while the Area stores its one structure under
|
|
29
|
+
* another shell's identity -- the base shell's, typically, saved before a Module that brings its own was
|
|
30
|
+
* switched on. Core keeps one structure per Area and refuses the save (409); the stored one has to be
|
|
31
|
+
* cleared first ("Clear Area" in Revisions), and the Module selection survives that.
|
|
32
|
+
*/
|
|
33
|
+
export class PhiBuilderAreaStructureTakenError extends Error {
|
|
34
|
+
area;
|
|
35
|
+
storedSource;
|
|
36
|
+
constructor(area, storedSource) {
|
|
37
|
+
super(`Area "${area}" stores its structure for the shell of ${storedSource.ownerModuleId}. ` +
|
|
38
|
+
"Clear the Area's stored structure in Revisions first; its Module selection stays.");
|
|
39
|
+
this.area = area;
|
|
40
|
+
this.storedSource = storedSource;
|
|
41
|
+
this.name = "PhiBuilderAreaStructureTakenError";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
27
44
|
/**
|
|
28
45
|
* Creating a Page at a path a Page already holds. The server wrote nothing; the Builder opens the Page
|
|
29
46
|
* that is there instead of the blank one it meant to create.
|
|
@@ -176,7 +193,7 @@ export function serializePhiBuilderRootDraft(draft, widgetMetasByType, bindings
|
|
|
176
193
|
contentWidgets,
|
|
177
194
|
};
|
|
178
195
|
}
|
|
179
|
-
async function postCmsDraft(path, payload) {
|
|
196
|
+
async function postCmsDraft(path, payload, kind = "tree") {
|
|
180
197
|
const response = await fetch(path, {
|
|
181
198
|
method: "POST",
|
|
182
199
|
headers: {
|
|
@@ -195,7 +212,7 @@ async function postCmsDraft(path, payload) {
|
|
|
195
212
|
const addressRefused = body?.error === "path_collision" || body?.error === "path_nested";
|
|
196
213
|
throw response.status === 409 && !addressRefused ? new CmsDraftConflictError(message) : new Error(message);
|
|
197
214
|
}
|
|
198
|
-
return readPhiDraftAllocation(body, "The CMS draft save");
|
|
215
|
+
return readPhiDraftAllocation(body, "The CMS draft save", kind);
|
|
199
216
|
}
|
|
200
217
|
/**
|
|
201
218
|
* What a Draft save or read answers about the Draft it now stands on: its revision, version and node
|
|
@@ -203,12 +220,21 @@ async function postCmsDraft(path, payload) {
|
|
|
203
220
|
* left out. Read field by field; each was checked before and then cast, and the preset source was not
|
|
204
221
|
* checked at all.
|
|
205
222
|
*/
|
|
206
|
-
function readPhiDraftAllocation(body, source) {
|
|
223
|
+
function readPhiDraftAllocation(body, source, kind = "tree") {
|
|
207
224
|
const reader = createPhiResponseReader(body, source);
|
|
208
225
|
const positive = (key) => {
|
|
209
226
|
const value = requirePhiField(reader, key, "a positive whole number", reader.integer);
|
|
210
227
|
return value >= 1 ? value : reader.fail(key, "a positive whole number");
|
|
211
228
|
};
|
|
229
|
+
// A Module selection stands on no preset, and its answers say none.
|
|
230
|
+
if (kind === "modules") {
|
|
231
|
+
return {
|
|
232
|
+
revisionId: positive("revisionId"),
|
|
233
|
+
version: positive("version"),
|
|
234
|
+
nextNodeSequence: positive("nextNodeSequence"),
|
|
235
|
+
sourcePreset: null,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
212
238
|
if (!Object.prototype.hasOwnProperty.call(reader.record, "sourcePreset")) {
|
|
213
239
|
reader.fail("sourcePreset", "a preset source or null");
|
|
214
240
|
}
|
|
@@ -241,7 +267,7 @@ async function postCmsAction(path, payload) {
|
|
|
241
267
|
revisionId: Number.isInteger(body?.revisionId) ? body?.revisionId : null,
|
|
242
268
|
};
|
|
243
269
|
}
|
|
244
|
-
async function getCmsDraft(path, payload) {
|
|
270
|
+
async function getCmsDraft(path, payload, kind = "tree") {
|
|
245
271
|
const url = new URL(path, typeof window !== "undefined" ? window.location.origin : "http://localhost");
|
|
246
272
|
for (const [key, value] of Object.entries(payload)) {
|
|
247
273
|
if (typeof value === "string" && value.trim().length > 0) {
|
|
@@ -259,7 +285,7 @@ async function getCmsDraft(path, payload) {
|
|
|
259
285
|
const detail = body?.details?.length ? ` ${body.details.join(" ")}` : "";
|
|
260
286
|
throw new Error(`${body?.error ?? "CMS draft read failed."}${detail}`);
|
|
261
287
|
}
|
|
262
|
-
return readPhiDraftAllocation(body, "The CMS draft read");
|
|
288
|
+
return readPhiDraftAllocation(body, "The CMS draft read", kind);
|
|
263
289
|
}
|
|
264
290
|
/**
|
|
265
291
|
* The href a preview opens, with no locale in it.
|
|
@@ -323,11 +349,7 @@ export async function getPhiDeveloperBuilderDraftAllocation(input) {
|
|
|
323
349
|
/** The Area's open Module draft, if the Builder does not already have it cached. */
|
|
324
350
|
export async function getPhiDeveloperBuilderModulesDraftAllocation(input) {
|
|
325
351
|
const cmsArea = resolvePhiBuilderAreaAsCmsArea(input.area);
|
|
326
|
-
const draft = await getCmsDraft("/api/site/cms/area/modules/draft", {
|
|
327
|
-
area: cmsArea,
|
|
328
|
-
ownerModuleId: input.areaPresetSource?.ownerModuleId,
|
|
329
|
-
presetKey: input.areaPresetSource?.presetKey,
|
|
330
|
-
});
|
|
352
|
+
const draft = await getCmsDraft("/api/site/cms/area/modules/draft", { area: cmsArea }, "modules");
|
|
331
353
|
if (!draft) {
|
|
332
354
|
return null;
|
|
333
355
|
}
|
|
@@ -354,36 +376,30 @@ function requirePhiBuilderControllerSettings(settingsByKey, key, label) {
|
|
|
354
376
|
/**
|
|
355
377
|
* Saves an Area's Module selection, apart from its structure.
|
|
356
378
|
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
* already has it loaded (every `/builder/*` page does, regardless of which one is open), so this is the
|
|
362
|
-
* one path along which a Module save reaches into Shell region drafts at all.
|
|
363
|
-
*
|
|
364
|
-
* Which is why the Shell preset is a second source here. The region drafts hold what a workspace has
|
|
365
|
-
* *hydrated*, and the Modules workspace hydrates none: it edits a selection, not a structure. Building
|
|
366
|
-
* the baseline from those alone therefore worked on the Shells page and nowhere else, and an operator
|
|
367
|
-
* activating a Module for a fresh Area was told to go and create a Shell first -- for a Shell that
|
|
368
|
-
* already exists in code and that they were not going to change. The preset fills whatever the drafts
|
|
369
|
-
* do not hold, and an open draft still wins where there is one.
|
|
379
|
+
* The selection has revisions of its own (a Modules revision of the Area), so this writes only
|
|
380
|
+
* `config.modules` and never touches the structure: an Area that never stored a structure keeps running
|
|
381
|
+
* on its code-owned shell, and the next shell preset still reaches it. Which shell that is follows from
|
|
382
|
+
* the selection -- a Module that brings its own shell applies once it is active here.
|
|
370
383
|
*/
|
|
371
|
-
export async function savePhiDeveloperBuilderModulesDraft(state,
|
|
384
|
+
export async function savePhiDeveloperBuilderModulesDraft(state, options) {
|
|
372
385
|
const area = options.scope.area;
|
|
373
386
|
const cmsArea = resolvePhiBuilderAreaAsCmsArea(area);
|
|
374
|
-
const areaPresetSource = state.areaPresetSourcesByArea[area] ?? null;
|
|
375
|
-
if (!areaPresetSource) {
|
|
376
|
-
throw new Error(`Area "${area}" has no active shell preset source.`);
|
|
377
|
-
}
|
|
378
387
|
const optionalRuntimeModuleIds = resolvePhiRuntimeModuleIdsForArea(area, state.runtimeModuleIdsByArea?.[area] ?? null, state.runtimeModuleDefinitions);
|
|
379
388
|
assertPersistableAreaRuntimeModuleIds(optionalRuntimeModuleIds, state.runtimeModuleDefinitions);
|
|
380
389
|
const allocationKey = createPhiBuilderDraftAllocationKey(area, area, "modules");
|
|
381
390
|
const draftAllocation = state.draftAllocations[allocationKey] ??
|
|
382
|
-
(await getPhiDeveloperBuilderModulesDraftAllocation({ area
|
|
391
|
+
(await getPhiDeveloperBuilderModulesDraftAllocation({ area }));
|
|
383
392
|
const payload = {
|
|
384
393
|
area: cmsArea,
|
|
385
|
-
|
|
386
|
-
|
|
394
|
+
...(draftAllocation
|
|
395
|
+
? {
|
|
396
|
+
draft: {
|
|
397
|
+
revisionId: draftAllocation.revisionId,
|
|
398
|
+
version: draftAllocation.version,
|
|
399
|
+
nextNodeSequence: draftAllocation.nextNodeSequence,
|
|
400
|
+
},
|
|
401
|
+
}
|
|
402
|
+
: {}),
|
|
387
403
|
config: {
|
|
388
404
|
// The Module namespace, and only it: `config.shell` belongs to the structure draft, and this
|
|
389
405
|
// route rejects a payload that carries it.
|
|
@@ -421,56 +437,19 @@ export async function savePhiDeveloperBuilderModulesDraft(state, regionDrafts, o
|
|
|
421
437
|
},
|
|
422
438
|
},
|
|
423
439
|
};
|
|
424
|
-
|
|
425
|
-
try {
|
|
426
|
-
result = await postCmsDraft("/api/site/cms/area/modules", payload);
|
|
427
|
-
}
|
|
428
|
-
catch (error) {
|
|
429
|
-
if (!(error instanceof CmsDraftConflictError) || draftAllocation) {
|
|
430
|
-
throw error;
|
|
431
|
-
}
|
|
432
|
-
const widgetMetasByType = buildPhiBuilderWidgetMetaMap(options.builderPlugins);
|
|
433
|
-
// The preset first, so anything a workspace actually hydrated overwrites it rather than the reverse.
|
|
434
|
-
const baselineDrafts = { ...(options.shellPresetDrafts ?? {}), ...regionDrafts };
|
|
435
|
-
/*
|
|
436
|
-
* Bindings are carried rather than derived here, because there is nothing to derive them from: the
|
|
437
|
-
* Modules workspace mounts no Canvas, so no Module's metadata is loaded, and a Shell preset names
|
|
438
|
-
* Widgets of Modules this Area may not even have selected yet. What the nodes already hold is the
|
|
439
|
-
* preset's own answer, which is the better one for a tree nobody is editing.
|
|
440
|
-
*/
|
|
441
|
-
const structurePayload = buildAreaStructureWritePayload(area, baselineDrafts, widgetMetasByType, "carry");
|
|
442
|
-
if (!structurePayload) {
|
|
443
|
-
throw error;
|
|
444
|
-
}
|
|
445
|
-
result = await postCmsDraft("/api/site/cms/area/modules", {
|
|
446
|
-
...payload,
|
|
447
|
-
baseline: {
|
|
448
|
-
area: cmsArea,
|
|
449
|
-
sourcePreset: areaPresetSource,
|
|
450
|
-
preset: { status: 1, flags: 0, visibilityMask: structurePayload.areaMask },
|
|
451
|
-
regions: structurePayload.regions,
|
|
452
|
-
overlays: structurePayload.overlays,
|
|
453
|
-
layoutNodes: structurePayload.layoutNodes,
|
|
454
|
-
contentWidgets: structurePayload.contentWidgets,
|
|
455
|
-
controllerSettings: requirePhiBuilderControllerSettings(state.areaControllerSettings, area, `Area "${area}"`),
|
|
456
|
-
},
|
|
457
|
-
});
|
|
458
|
-
}
|
|
440
|
+
const result = await postCmsDraft("/api/site/cms/area/modules", payload, "modules");
|
|
459
441
|
storePhiDeveloperBuilderDraftAllocation(allocationKey, result);
|
|
460
442
|
return { revisionId: result.revisionId, version: result.version, nextNodeSequence: result.nextNodeSequence };
|
|
461
443
|
}
|
|
462
444
|
/** Publishes the Area's Module selection. Its structure draft, if one is open, is left exactly as it is. */
|
|
463
|
-
export async function publishPhiDeveloperBuilderModulesDraft(state,
|
|
445
|
+
export async function publishPhiDeveloperBuilderModulesDraft(state, options) {
|
|
464
446
|
const area = options.scope.area;
|
|
465
|
-
const
|
|
466
|
-
const saved = await savePhiDeveloperBuilderModulesDraft(state, regionDrafts, options);
|
|
447
|
+
const saved = await savePhiDeveloperBuilderModulesDraft(state, options);
|
|
467
448
|
if (!Number.isInteger(saved.revisionId) || saved.revisionId <= 0) {
|
|
468
449
|
throw new Error("Module draft save did not return a revision.");
|
|
469
450
|
}
|
|
470
451
|
await postCmsAction("/api/site/cms/area/modules/publish", {
|
|
471
|
-
area,
|
|
472
|
-
ownerModuleId: areaPresetSource?.ownerModuleId,
|
|
473
|
-
presetKey: areaPresetSource?.presetKey,
|
|
452
|
+
area: resolvePhiBuilderAreaAsCmsArea(area),
|
|
474
453
|
revisionId: saved.revisionId,
|
|
475
454
|
});
|
|
476
455
|
clearPhiDeveloperBuilderModulesDraftAllocation(area);
|
|
@@ -673,6 +652,7 @@ export async function savePhiDeveloperBuilderDraft(state, regionDrafts, workspac
|
|
|
673
652
|
if (!areaPresetSource) {
|
|
674
653
|
throw new Error(`Area "${area}" has no active shell preset source.`);
|
|
675
654
|
}
|
|
655
|
+
const storedSource = state.areaShellsByArea?.[area]?.storedSource ?? null;
|
|
676
656
|
const result = await postCmsDraft("/api/site/cms/area", {
|
|
677
657
|
area: cmsArea,
|
|
678
658
|
sourcePreset: areaPresetSource,
|
|
@@ -701,6 +681,18 @@ export async function savePhiDeveloperBuilderDraft(state, regionDrafts, workspac
|
|
|
701
681
|
layoutNodes: structurePayload.layoutNodes,
|
|
702
682
|
contentWidgets: structurePayload.contentWidgets,
|
|
703
683
|
controllerSettings: requirePhiBuilderControllerSettings(state.areaControllerSettings, area, `Area "${area}"`),
|
|
684
|
+
}).catch((error) => {
|
|
685
|
+
/*
|
|
686
|
+
* An Area stores one structure. A 409 while the one it stores stands on another shell is that,
|
|
687
|
+
* and not a Draft written past: the Builder offers to clear the stored one first.
|
|
688
|
+
*/
|
|
689
|
+
if (error instanceof CmsDraftConflictError &&
|
|
690
|
+
storedSource &&
|
|
691
|
+
(storedSource.ownerModuleId !== areaPresetSource.ownerModuleId ||
|
|
692
|
+
storedSource.presetKey !== areaPresetSource.presetKey)) {
|
|
693
|
+
throw new PhiBuilderAreaStructureTakenError(area, storedSource);
|
|
694
|
+
}
|
|
695
|
+
throw error;
|
|
704
696
|
});
|
|
705
697
|
storePhiDeveloperBuilderDraftAllocation(allocationKey, result);
|
|
706
698
|
/*
|
|
@@ -20,6 +20,23 @@ export declare function buildRuntimeModuleRows(state: PhiDeveloperBuilderWorkspa
|
|
|
20
20
|
isBaseModule: boolean;
|
|
21
21
|
baseAreaKey: "public" | "app" | "admin" | "builder" | "editor" | "accounting" | null;
|
|
22
22
|
}[];
|
|
23
|
+
/** What the Modules table says when a Module that brings its own shell is switched on over a stored one. */
|
|
24
|
+
export declare const PHI_BUILDER_SHELL_PROVIDER_NOTICE = "This Module brings its own Header and Footer. The saved structure stays and comes back when the Module is switched off.";
|
|
25
|
+
/**
|
|
26
|
+
* The Module that already brings the shell of one of these Areas, if switching this one on there would
|
|
27
|
+
* make it the second. One provider per Area (MODULES.md): the newcomer is refused with the holder named,
|
|
28
|
+
* the way a Site Page on its package path refuses it (`package-path-taken`).
|
|
29
|
+
*/
|
|
30
|
+
export declare function findPhiBuilderShellProviderHolder(state: Pick<PhiDeveloperBuilderWorkspaceState, "runtimeModuleIdsByArea" | "runtimeModuleDefinitions" | "areaShellsByArea">, moduleId: PhiRuntimeModuleId, cmsAreas: readonly PhiCmsAreaKey[]): {
|
|
31
|
+
areaKey: PhiCmsAreaKey;
|
|
32
|
+
holderModuleId: PhiRuntimeModuleId;
|
|
33
|
+
} | null;
|
|
34
|
+
/**
|
|
35
|
+
* Whether switching this Module on in these Areas puts its shell over a structure the Area stores for
|
|
36
|
+
* another shell. Nothing is lost -- the structure is kept and applies again once the Module is off --
|
|
37
|
+
* but what the Area looks like changes at once, so it is said.
|
|
38
|
+
*/
|
|
39
|
+
export declare function coversPhiBuilderStoredShellStructure(state: Pick<PhiDeveloperBuilderWorkspaceState, "areaShellsByArea">, moduleId: PhiRuntimeModuleId, cmsAreas: readonly PhiCmsAreaKey[]): boolean;
|
|
23
40
|
/**
|
|
24
41
|
* Whether switching this Module off in these Areas leaves Public with no Auth UI provider.
|
|
25
42
|
*
|