@phis/ui 0.6.11 → 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/widgets/label-sets/region.js +2 -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/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/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-default-builder-area-preset-tree.d.ts +0 -1
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +0 -2
- 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/phi-default-site-area-preset-tree.js +0 -2
- package/plugins/runtime-modules/revisions/controller/client.js +13 -7
- package/plugins/runtime-modules/revisions/services/table.js +10 -3
- package/plugins/runtime-modules/shell-tree-composition.d.ts +0 -2
- package/plugins/runtime-modules/shell-tree-composition.js +0 -3
- 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/types/cms-module-descriptors.d.ts +26 -1
- package/types/cms-plugins.d.ts +3 -0
- package/types/cms.d.ts +10 -3
|
@@ -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
|
*
|
|
@@ -196,6 +196,47 @@ function signInLabel(params) {
|
|
|
196
196
|
"Sign-in: nobody can sign in any more. " +
|
|
197
197
|
"Run phis auth restore-preset --site <site key> to bring it back.";
|
|
198
198
|
}
|
|
199
|
+
/** What the Modules table says when a Module that brings its own shell is switched on over a stored one. */
|
|
200
|
+
export 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.";
|
|
201
|
+
/**
|
|
202
|
+
* The Module that already brings the shell of one of these Areas, if switching this one on there would
|
|
203
|
+
* make it the second. One provider per Area (MODULES.md): the newcomer is refused with the holder named,
|
|
204
|
+
* the way a Site Page on its package path refuses it (`package-path-taken`).
|
|
205
|
+
*/
|
|
206
|
+
export function findPhiBuilderShellProviderHolder(state, moduleId, cmsAreas) {
|
|
207
|
+
for (const areaKey of cmsAreas) {
|
|
208
|
+
if (!isPhiBuilderAreaKey(areaKey))
|
|
209
|
+
continue;
|
|
210
|
+
const providers = state.areaShellsByArea?.[areaKey]?.providerModuleIds ?? [];
|
|
211
|
+
if (!providers.includes(moduleId))
|
|
212
|
+
continue;
|
|
213
|
+
const holderModuleId = providers.find((candidate) => {
|
|
214
|
+
if (candidate === moduleId)
|
|
215
|
+
return false;
|
|
216
|
+
const definition = state.runtimeModuleDefinitions.find((entry) => entry.moduleId === candidate);
|
|
217
|
+
return definition != null && isModuleActiveInArea(state, definition, areaKey);
|
|
218
|
+
});
|
|
219
|
+
if (holderModuleId)
|
|
220
|
+
return { areaKey, holderModuleId };
|
|
221
|
+
}
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Whether switching this Module on in these Areas puts its shell over a structure the Area stores for
|
|
226
|
+
* another shell. Nothing is lost -- the structure is kept and applies again once the Module is off --
|
|
227
|
+
* but what the Area looks like changes at once, so it is said.
|
|
228
|
+
*/
|
|
229
|
+
export function coversPhiBuilderStoredShellStructure(state, moduleId, cmsAreas) {
|
|
230
|
+
return cmsAreas.some((areaKey) => {
|
|
231
|
+
if (!isPhiBuilderAreaKey(areaKey))
|
|
232
|
+
return false;
|
|
233
|
+
const shells = state.areaShellsByArea?.[areaKey];
|
|
234
|
+
return shells != null &&
|
|
235
|
+
shells.providerModuleIds.includes(moduleId) &&
|
|
236
|
+
shells.storedSource != null &&
|
|
237
|
+
shells.storedSource.ownerModuleId !== moduleId;
|
|
238
|
+
});
|
|
239
|
+
}
|
|
199
240
|
/**
|
|
200
241
|
* Whether switching this Module off in these Areas leaves Public with no Auth UI provider.
|
|
201
242
|
*
|
|
@@ -461,6 +502,26 @@ export function PhiBuilderRuntimeModulesTableProviderClient({ children }) {
|
|
|
461
502
|
}
|
|
462
503
|
return null;
|
|
463
504
|
};
|
|
505
|
+
const refuseShellProviderTaken = (cmsAreas) => {
|
|
506
|
+
if (!proposedActive)
|
|
507
|
+
return null;
|
|
508
|
+
const held = findPhiBuilderShellProviderHolder(builderState, definition.moduleId, cmsAreas);
|
|
509
|
+
if (!held)
|
|
510
|
+
return null;
|
|
511
|
+
const holderTitle = builderState.runtimeModuleDefinitions
|
|
512
|
+
.find((entry) => entry.moduleId === held.holderModuleId)?.title ?? held.holderModuleId;
|
|
513
|
+
return {
|
|
514
|
+
status: "rejected",
|
|
515
|
+
invalidation: "none",
|
|
516
|
+
errorCode: "shell-provider-taken",
|
|
517
|
+
message: `"${definition.title}" brings its own Header and Footer for Area ${areaLabelFor(held.areaKey, request.params)}, `
|
|
518
|
+
+ `where "${holderTitle}" already brings them. Switch "${holderTitle}" off there first.`,
|
|
519
|
+
};
|
|
520
|
+
};
|
|
521
|
+
// Said once the switch is accepted: the Area's look changes, and the structure it stored is kept.
|
|
522
|
+
const shellProviderNotice = (cmsAreas) => proposedActive && coversPhiBuilderStoredShellStructure(builderState, definition.moduleId, cmsAreas)
|
|
523
|
+
? { message: PHI_BUILDER_SHELL_PROVIDER_NOTICE }
|
|
524
|
+
: {};
|
|
464
525
|
const refusePackagePathTaken = (held) => ({
|
|
465
526
|
status: "rejected",
|
|
466
527
|
invalidation: "none",
|
|
@@ -548,6 +609,9 @@ export function PhiBuilderRuntimeModulesTableProviderClient({ children }) {
|
|
|
548
609
|
message: `"${definition.title}" is Area "${baseAreaKey}"'s Base module and always runs there.`,
|
|
549
610
|
};
|
|
550
611
|
}
|
|
612
|
+
const shellProviderTaken = refuseShellProviderTaken(definition.eligibleAreas);
|
|
613
|
+
if (shellProviderTaken)
|
|
614
|
+
return shellProviderTaken;
|
|
551
615
|
const heldPackagePath = await findSitePageOnPackagePath(definition.eligibleAreas);
|
|
552
616
|
if (heldPackagePath)
|
|
553
617
|
return refusePackagePathTaken(heldPackagePath);
|
|
@@ -573,7 +637,12 @@ export function PhiBuilderRuntimeModulesTableProviderClient({ children }) {
|
|
|
573
637
|
message: error instanceof Error ? error.message : "Invalid Module selection.",
|
|
574
638
|
};
|
|
575
639
|
}
|
|
576
|
-
return {
|
|
640
|
+
return {
|
|
641
|
+
status: "accepted",
|
|
642
|
+
invalidation: "view",
|
|
643
|
+
rowPatch: { active: proposedActive },
|
|
644
|
+
...shellProviderNotice(definition.eligibleAreas),
|
|
645
|
+
};
|
|
577
646
|
}
|
|
578
647
|
// An area_* checkbox: one Area's own choice.
|
|
579
648
|
const areaKey = request.fieldKey.startsWith("area_") ? request.fieldKey.slice("area_".length) : null;
|
|
@@ -596,6 +665,9 @@ export function PhiBuilderRuntimeModulesTableProviderClient({ children }) {
|
|
|
596
665
|
message: `"${definition.title}" is not eligible for Area "${areaKey}".`,
|
|
597
666
|
};
|
|
598
667
|
}
|
|
668
|
+
const areaShellProviderTaken = refuseShellProviderTaken([areaKey]);
|
|
669
|
+
if (areaShellProviderTaken)
|
|
670
|
+
return areaShellProviderTaken;
|
|
599
671
|
const heldAreaPackagePath = await findSitePageOnPackagePath([areaKey]);
|
|
600
672
|
if (heldAreaPackagePath)
|
|
601
673
|
return refusePackagePathTaken(heldAreaPackagePath);
|
|
@@ -621,7 +693,12 @@ export function PhiBuilderRuntimeModulesTableProviderClient({ children }) {
|
|
|
621
693
|
message: error instanceof Error ? error.message : "Invalid Module selection.",
|
|
622
694
|
};
|
|
623
695
|
}
|
|
624
|
-
return {
|
|
696
|
+
return {
|
|
697
|
+
status: "accepted",
|
|
698
|
+
invalidation: "view",
|
|
699
|
+
rowPatch: { [request.fieldKey]: proposedActive },
|
|
700
|
+
...shellProviderNotice([areaKey]),
|
|
701
|
+
};
|
|
625
702
|
};
|
|
626
703
|
return {
|
|
627
704
|
key: PHI_BUILDER_RUNTIME_DATA_PROVIDER_KEYS.runtimeModulesTable,
|
|
@@ -134,5 +134,4 @@ export declare function buildPhiDefaultBuilderPagePresetTree({ page, runtime, ow
|
|
|
134
134
|
resolvedContent?: import("../../../../types").PhiCmsResolvedContent | null;
|
|
135
135
|
}[];
|
|
136
136
|
pageMeta?: import("../../../../types").PhiCmsResolvedPageMeta | null;
|
|
137
|
-
runtimeModuleIds?: PhiRuntimeModuleId[] | null;
|
|
138
137
|
}>;
|
|
@@ -18,7 +18,6 @@ import { PHI_BUILDER_RUNTIME_MODULE_ID } from "../ids";
|
|
|
18
18
|
import { PHI_BUILDER_RUNTIME_DATA_PROVIDER_KEYS } from "../ids";
|
|
19
19
|
import { PHI_BUILDER_MODULES_TABLE_ALL_AREAS_VALUE, PHI_BUILDER_MODULES_TABLE_FILTER_KEYS, } from "../data-providers";
|
|
20
20
|
import { PHI_BUILDER_NAVIGATION_DND_TYPE_PAGE } from "../../../../constants/builder-navigation-dnd";
|
|
21
|
-
import { createPhiDefaultAreaRuntimeModuleIds } from "../../area-module-defaults";
|
|
22
21
|
import { getPhiBuilderChromeWidgetLabels } from "../../../../components/widgets/label-sets/builder-chrome";
|
|
23
22
|
import { PHI_BUILDER_CHROME_WIDGET_DEFAULT_LABELS } from "../../../../components/widgets/label-types/builder-chrome";
|
|
24
23
|
import { getPhiRegionWidgetLabels } from "../../../../components/widgets/label-sets/region";
|
|
@@ -347,7 +346,6 @@ export async function buildPhiDefaultBuilderAreaPresetTree({ page, runtime, }) {
|
|
|
347
346
|
},
|
|
348
347
|
description: null,
|
|
349
348
|
},
|
|
350
|
-
runtimeModuleIds: createPhiDefaultAreaRuntimeModuleIds("builder"),
|
|
351
349
|
/*
|
|
352
350
|
* The Shell's own receivers: the header's Area selector and debug switch, which the Controller arms
|
|
353
351
|
* on the Pages that use them. The Inspector Overlay contribution adds its receivers to this setting
|
|
@@ -25,7 +25,7 @@ export declare function assignPhiWorkspacePublicRoutePaths(moduleId: PhiRuntimeM
|
|
|
25
25
|
/** Catalog fields an undo or redo puts back (`splitWorkspacePatch`). */
|
|
26
26
|
export declare function restorePhiWorkspaceCatalog(fields: Partial<PhiWorkspaceCatalogState>): void;
|
|
27
27
|
/** What the server rendered the Builder with, as its preload hands it in. */
|
|
28
|
-
export type PhiWorkspaceCatalogPreload = Pick<PhiWorkspaceCatalogState, "areaPresetSourcesByArea" | "unresolvedModuleIdsByArea" | "serverUnavailableModules" | "publicRouteClaims" | "publicRoutePaths"> & {
|
|
28
|
+
export type PhiWorkspaceCatalogPreload = Pick<PhiWorkspaceCatalogState, "areaPresetSourcesByArea" | "areaShellsByArea" | "unresolvedModuleIdsByArea" | "serverUnavailableModules" | "publicRouteClaims" | "publicRoutePaths"> & {
|
|
29
29
|
runtimeModuleDefinitions: readonly PhiWorkspaceCatalogState["runtimeModuleDefinitions"][number][];
|
|
30
30
|
runtimeModuleIdsByArea: Readonly<Record<string, PhiRuntimeModuleId[]>>;
|
|
31
31
|
/** The Pages and surfaces of the active Modules, which is what the catalog holds. */
|
|
@@ -39,6 +39,7 @@ export type PhiWorkspaceCatalogPreload = Pick<PhiWorkspaceCatalogState, "areaPre
|
|
|
39
39
|
runtimeModuleDefinitions: string;
|
|
40
40
|
modulePresetPagesByArea: string;
|
|
41
41
|
areaPresetSourcesByArea: string;
|
|
42
|
+
areaShellsByArea: string;
|
|
42
43
|
navigationSurfacesByArea: string;
|
|
43
44
|
unresolvedModuleIdsByArea: string;
|
|
44
45
|
publicRouteClaims: string;
|
|
@@ -96,6 +96,7 @@ export function applyPhiWorkspaceCatalogPreload(preload) {
|
|
|
96
96
|
const definitionsChanged = JSON.stringify(current.runtimeModuleDefinitions ?? []) !== preload.keys.runtimeModuleDefinitions;
|
|
97
97
|
const modulePresetPagesChanged = JSON.stringify(current.modulePresetPagesByArea) !== preload.keys.modulePresetPagesByArea;
|
|
98
98
|
const areaPresetSourcesChanged = JSON.stringify(current.areaPresetSourcesByArea) !== preload.keys.areaPresetSourcesByArea;
|
|
99
|
+
const areaShellsChanged = JSON.stringify(current.areaShellsByArea) !== preload.keys.areaShellsByArea;
|
|
99
100
|
const navigationSurfacesChanged = JSON.stringify(current.navigationSurfacesByArea) !== preload.keys.navigationSurfacesByArea;
|
|
100
101
|
const unresolvedModuleIdsChanged = JSON.stringify(current.unresolvedModuleIdsByArea) !== preload.keys.unresolvedModuleIdsByArea;
|
|
101
102
|
const publicRouteClaimsChanged = JSON.stringify(current.publicRouteClaims) !== preload.keys.publicRouteClaims;
|
|
@@ -119,7 +120,7 @@ export function applyPhiWorkspaceCatalogPreload(preload) {
|
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
openedPageKey = initialPageChanged ? initialPageKey : null;
|
|
122
|
-
return changed || definitionsChanged || modulePresetPagesChanged || areaPresetSourcesChanged ||
|
|
123
|
+
return changed || definitionsChanged || modulePresetPagesChanged || areaPresetSourcesChanged || areaShellsChanged ||
|
|
123
124
|
navigationSurfacesChanged || unresolvedModuleIdsChanged || serverUnavailableModulesChanged ||
|
|
124
125
|
publicRouteClaimsChanged || publicRoutePathsChanged || catalogHydrationChanged || initialPageChanged
|
|
125
126
|
? {
|
|
@@ -130,6 +131,7 @@ export function applyPhiWorkspaceCatalogPreload(preload) {
|
|
|
130
131
|
catalogHydrated: true,
|
|
131
132
|
modulePresetPagesByArea: preload.activeCatalogs.modulePresetPagesByArea,
|
|
132
133
|
areaPresetSourcesByArea: preload.areaPresetSourcesByArea,
|
|
134
|
+
areaShellsByArea: preload.areaShellsByArea,
|
|
133
135
|
navigationSurfacesByArea: preload.activeCatalogs.navigationSurfacesByArea,
|
|
134
136
|
unresolvedModuleIdsByArea: preload.unresolvedModuleIdsByArea,
|
|
135
137
|
serverUnavailableModules: preload.serverUnavailableModules,
|
|
@@ -11,10 +11,10 @@ export declare const PHI_CASCADER_WIDGET_BUILDER_PLUGIN: {
|
|
|
11
11
|
icon?: string | undefined;
|
|
12
12
|
iconFamily?: string | undefined;
|
|
13
13
|
pluginKey: string;
|
|
14
|
-
runtimeSignals?: (import("../../../../../types").PhiSignalPluginMeta | null) | undefined;
|
|
15
14
|
typeKey: string;
|
|
16
15
|
iconName?: string | undefined;
|
|
17
16
|
commercial?: import("../../../../../types").PhiCmsPluginCommercialMeta | undefined;
|
|
17
|
+
runtimeSignals?: (import("../../../../../types").PhiSignalPluginMeta | null) | undefined;
|
|
18
18
|
signalSubcontrols?: readonly import("../../../../../types").PhiCmsWidgetSignalSubcontrolCollection[] | undefined;
|
|
19
19
|
requiredRuntimeControllers?: import("../../../../../types").PhiCmsWidgetRuntimeControllerRequirementResolver<PhiCascaderWidgetConfig> | undefined;
|
|
20
20
|
requiredDataProviders?: readonly import("@phis/contracts/controls").PhiRuntimeDataProviderKey[] | undefined;
|
|
@@ -2,7 +2,7 @@ import { type PhiCmsAreaKey } from "../../constants/cms-areas";
|
|
|
2
2
|
import type { PhiFormDescriptor } from "@phis/contracts/forms";
|
|
3
3
|
import { type PhiCmsInstanceId } from "../../types/cms-instance-id";
|
|
4
4
|
import type { PhiThemeFontsBlock, PhiThemeGroundBlock, PhiThemeSetBlock, PhiThemeStyleBlock } from "../../theme/phi-theme-blocks";
|
|
5
|
-
import type { PhiCmsActiveRouteTable, PhiCmsAreaDefinition, PhiCmsAreaShellPresetBinding, PhiCmsCompiledDescriptorCatalog, PhiCmsCompiledRoutePattern, PhiCmsNavigationOverlay, PhiCmsNavigationOverlayResolution, PhiCmsResolvedNavigationSurface, PhiCmsRoutePresetBinding, PhiCmsRoutePresetDescriptor, PhiCmsCompiledThemeDescriptors, PhiCmsThemeDescriptorContribution, PhiCmsThemePresetBinding, PhiRuntimeModuleId } from "../../types/cms-module-descriptors";
|
|
5
|
+
import type { PhiCmsActiveRouteTable, PhiCmsAreaDefinition, PhiCmsAreaShellPresetBinding, PhiCmsAreaShellProviderBinding, PhiCmsCompiledDescriptorCatalog, PhiCmsCompiledRoutePattern, PhiCmsNavigationOverlay, PhiCmsNavigationOverlayResolution, PhiCmsResolvedNavigationSurface, PhiCmsRoutePresetBinding, PhiCmsRoutePresetDescriptor, PhiCmsCompiledThemeDescriptors, PhiCmsThemeDescriptorContribution, PhiCmsThemePresetBinding, PhiRuntimeModuleId } from "../../types/cms-module-descriptors";
|
|
6
6
|
import type { PhiCmsPageNode, PhiResolvedCmsAreaPresetTree, PhiResolvedCmsPageTree } from "../../types/cms";
|
|
7
7
|
import type { PhiRuntimeModuleCatalog } from "../../types/cms-plugins";
|
|
8
8
|
import type { PhiBlockRuntime } from "../../types/widget-runtime";
|
|
@@ -78,7 +78,21 @@ export declare function resolvePhiCmsModuleNavigationFolderTargets(input: {
|
|
|
78
78
|
export declare function resolvePhiCmsNavigationOverlay(surface: PhiCmsResolvedNavigationSurface, overlay: PhiCmsNavigationOverlay | null): PhiCmsNavigationOverlayResolution;
|
|
79
79
|
export declare function resolvePhiCmsRoutePreset(table: PhiCmsActiveRouteTable, requestedPath: string): PhiCmsRoutePresetBinding | null;
|
|
80
80
|
export declare function resolvePhiCmsRoutePresetByPageId(table: PhiCmsActiveRouteTable, pageId: PhiCmsInstanceId): PhiCmsRoutePresetBinding | null;
|
|
81
|
-
|
|
81
|
+
/** The shell of the Area's base Module, whatever the Area runs: what it takes while no active Module brings one. */
|
|
82
|
+
export declare function resolvePhiCmsAreaBaseShellPresetBinding(catalog: PhiCmsCompiledDescriptorCatalog, area: PhiCmsAreaKey): PhiCmsAreaShellPresetBinding | null;
|
|
83
|
+
/** The shells optional Modules bring for the Area, active or not. */
|
|
84
|
+
export declare function listPhiCmsAreaShellProviders(catalog: PhiCmsCompiledDescriptorCatalog, area: PhiCmsAreaKey): readonly PhiCmsAreaShellProviderBinding[];
|
|
85
|
+
/**
|
|
86
|
+
* The Area's effective shell: the shell of the one active Module that brings one, otherwise the base
|
|
87
|
+
* shell. The active Modules are the Area's selection as `resolveActivePresetModuleKeys` reads it, so a
|
|
88
|
+
* provider that is installed but not selected -- or selected but off for want of its server half --
|
|
89
|
+
* changes nothing.
|
|
90
|
+
*
|
|
91
|
+
* Two active providers is a selection the Builder refuses to make (one provider per Area); a stored one
|
|
92
|
+
* that holds two anyway is refused here rather than settled by catalog order, which would hand the
|
|
93
|
+
* Area to whichever package happened to be listed first.
|
|
94
|
+
*/
|
|
95
|
+
export declare function resolvePhiCmsAreaShellPresetBinding(catalog: PhiCmsCompiledDescriptorCatalog, area: PhiCmsAreaKey, activeModuleIds: ReadonlySet<PhiRuntimeModuleId>): PhiCmsAreaShellPresetBinding | null;
|
|
82
96
|
export declare function resolvePhiCmsRoutePresetByIdentity(catalog: PhiCmsCompiledDescriptorCatalog, ownerModuleId: PhiRuntimeModuleId, presetKey: string): PhiCmsRoutePresetDescriptor | null;
|
|
83
97
|
export declare function resolvePhiCmsThemePresetBinding(catalog: PhiCmsCompiledDescriptorCatalog, themeKey: string, activeModuleIds: ReadonlySet<PhiRuntimeModuleId>): PhiCmsThemePresetBinding | null;
|
|
84
98
|
export declare function instantiatePhiCmsThemePreset(binding: PhiCmsThemePresetBinding): Promise<import("../../theme").PhiThemePresetPlugin>;
|