@wildo-ai/saas-frontend-lib 1.1.13 → 1.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/dist/esm/components/data-display/DisplayValueDispatcher.d.ts.map +1 -1
  2. package/dist/esm/components/data-display/DisplayValueDispatcher.js +17 -1
  3. package/dist/esm/components/data-display/DisplayValueDispatcher.js.map +1 -1
  4. package/dist/esm/components/data-display/external-data-provenance/external-data-provenance.frontend.d.ts.map +1 -1
  5. package/dist/esm/components/data-display/external-data-provenance/external-data-provenance.frontend.js +5 -2
  6. package/dist/esm/components/data-display/external-data-provenance/external-data-provenance.frontend.js.map +1 -1
  7. package/dist/esm/components/form/automated/ResourceAutomatedForm.d.ts.map +1 -1
  8. package/dist/esm/components/form/automated/ResourceAutomatedForm.js +20 -1
  9. package/dist/esm/components/form/automated/ResourceAutomatedForm.js.map +1 -1
  10. package/dist/esm/components/form/chromes/FormFieldChrome.js +1 -1
  11. package/dist/esm/components/form/chromes/FormFieldChrome.js.map +1 -1
  12. package/dist/esm/components/form/chromes/field-control-aria.d.ts +8 -1
  13. package/dist/esm/components/form/chromes/field-control-aria.d.ts.map +1 -1
  14. package/dist/esm/components/form/chromes/field-control-aria.js +19 -2
  15. package/dist/esm/components/form/chromes/field-control-aria.js.map +1 -1
  16. package/dist/esm/components/form/validation-errors/validate-field-url.frontend.d.ts +5 -0
  17. package/dist/esm/components/form/validation-errors/validate-field-url.frontend.d.ts.map +1 -1
  18. package/dist/esm/components/form/validation-errors/validate-field-url.frontend.js +6 -2
  19. package/dist/esm/components/form/validation-errors/validate-field-url.frontend.js.map +1 -1
  20. package/dist/esm/components/resources/ResourceCollectionBody_Table.d.ts.map +1 -1
  21. package/dist/esm/components/resources/ResourceCollectionBody_Table.js +8 -1
  22. package/dist/esm/components/resources/ResourceCollectionBody_Table.js.map +1 -1
  23. package/dist/esm/components/resources/ResourceLayout_DangerZone.d.ts.map +1 -1
  24. package/dist/esm/components/resources/ResourceLayout_DangerZone.js +2 -2
  25. package/dist/esm/components/resources/ResourceLayout_DangerZone.js.map +1 -1
  26. package/dist/esm/components/resources/ResourceLayout_RecordSharing.js +2 -2
  27. package/dist/esm/components/resources/ResourceLayout_RecordSharing.js.map +1 -1
  28. package/dist/esm/components/resources/ResourceListItemRenderer.d.ts.map +1 -1
  29. package/dist/esm/components/resources/ResourceListItemRenderer.js +6 -1
  30. package/dist/esm/components/resources/ResourceListItemRenderer.js.map +1 -1
  31. package/dist/esm/components/resources/skeleton/DisplayLayout.js +2 -2
  32. package/dist/esm/components/resources/skeleton/DisplayLayout.js.map +1 -1
  33. package/dist/esm/components/resources-fields/_presets/resource-reference/ResourceFieldDisplayPreset_ResourceReference_Default.d.ts.map +1 -1
  34. package/dist/esm/components/resources-fields/_presets/resource-reference/ResourceFieldDisplayPreset_ResourceReference_Default.js +71 -16
  35. package/dist/esm/components/resources-fields/_presets/resource-reference/ResourceFieldDisplayPreset_ResourceReference_Default.js.map +1 -1
  36. package/dist/esm/components/sections/surface.d.ts +12 -0
  37. package/dist/esm/components/sections/surface.d.ts.map +1 -1
  38. package/dist/esm/components/sections/surface.js +14 -0
  39. package/dist/esm/components/sections/surface.js.map +1 -1
  40. package/dist/esm/core/app-shell/shell-motion/shell-motion-origins.d.ts.map +1 -1
  41. package/dist/esm/core/app-shell/shell-motion/shell-motion-origins.js +3 -2
  42. package/dist/esm/core/app-shell/shell-motion/shell-motion-origins.js.map +1 -1
  43. package/dist/esm/core/app-shell/shell-motion/shell-motion-vocabulary.d.ts +15 -0
  44. package/dist/esm/core/app-shell/shell-motion/shell-motion-vocabulary.d.ts.map +1 -1
  45. package/dist/esm/core/app-shell/shell-motion/shell-motion-vocabulary.js +29 -0
  46. package/dist/esm/core/app-shell/shell-motion/shell-motion-vocabulary.js.map +1 -1
  47. package/dist/esm/core/app-shell/shell-motion/use-shell-motion.d.ts.map +1 -1
  48. package/dist/esm/core/app-shell/shell-motion/use-shell-motion.js +2 -2
  49. package/dist/esm/core/app-shell/shell-motion/use-shell-motion.js.map +1 -1
  50. package/dist/esm/core/branding/useBrandPresentation.d.ts.map +1 -1
  51. package/dist/esm/core/branding/useBrandPresentation.js +17 -6
  52. package/dist/esm/core/branding/useBrandPresentation.js.map +1 -1
  53. package/dist/esm/core/execution/useExecutionResourceOperationContextBuilder.d.ts.map +1 -1
  54. package/dist/esm/core/execution/useExecutionResourceOperationContextBuilder.js +11 -1
  55. package/dist/esm/core/execution/useExecutionResourceOperationContextBuilder.js.map +1 -1
  56. package/dist/esm/core/i18n/I18nContext.d.ts.map +1 -1
  57. package/dist/esm/core/i18n/I18nContext.js +8 -2
  58. package/dist/esm/core/i18n/I18nContext.js.map +1 -1
  59. package/dist/esm/core/i18n/component-label-resolution.utils.d.ts.map +1 -1
  60. package/dist/esm/core/i18n/component-label-resolution.utils.js +6 -1
  61. package/dist/esm/core/i18n/component-label-resolution.utils.js.map +1 -1
  62. package/dist/esm/core/monitoring/analytics/AnalyticsContext.d.ts +0 -15
  63. package/dist/esm/core/monitoring/analytics/AnalyticsContext.d.ts.map +1 -1
  64. package/dist/esm/core/monitoring/analytics/AnalyticsContext.js +71 -6
  65. package/dist/esm/core/monitoring/analytics/AnalyticsContext.js.map +1 -1
  66. package/dist/esm/core/monitoring/analytics/AnalyticsEventBridge.d.ts.map +1 -1
  67. package/dist/esm/core/monitoring/analytics/AnalyticsEventBridge.js +12 -3
  68. package/dist/esm/core/monitoring/analytics/AnalyticsEventBridge.js.map +1 -1
  69. package/dist/esm/core/navigation/NavigationContext.d.ts.map +1 -1
  70. package/dist/esm/core/navigation/NavigationContext.js +60 -17
  71. package/dist/esm/core/navigation/NavigationContext.js.map +1 -1
  72. package/dist/esm/core/navigation/launcher-resolution.d.ts +29 -0
  73. package/dist/esm/core/navigation/launcher-resolution.d.ts.map +1 -1
  74. package/dist/esm/core/navigation/launcher-resolution.js +31 -0
  75. package/dist/esm/core/navigation/launcher-resolution.js.map +1 -1
  76. package/dist/esm/core/navigation/navigation-controller-internals.d.ts +48 -0
  77. package/dist/esm/core/navigation/navigation-controller-internals.d.ts.map +1 -1
  78. package/dist/esm/core/navigation/navigation-controller-internals.js +56 -3
  79. package/dist/esm/core/navigation/navigation-controller-internals.js.map +1 -1
  80. package/dist/esm/core/navigation/useNavigationRouterSync.d.ts.map +1 -1
  81. package/dist/esm/core/navigation/useNavigationRouterSync.js +30 -2
  82. package/dist/esm/core/navigation/useNavigationRouterSync.js.map +1 -1
  83. package/dist/esm/core/resources/route-parent-relocation.frontend.utils.d.ts +44 -0
  84. package/dist/esm/core/resources/route-parent-relocation.frontend.utils.d.ts.map +1 -0
  85. package/dist/esm/core/resources/route-parent-relocation.frontend.utils.js +63 -0
  86. package/dist/esm/core/resources/route-parent-relocation.frontend.utils.js.map +1 -0
  87. package/dist/esm/core/resources/useOperationDirectExecution.d.ts.map +1 -1
  88. package/dist/esm/core/resources/useOperationDirectExecution.js +45 -6
  89. package/dist/esm/core/resources/useOperationDirectExecution.js.map +1 -1
  90. package/dist/esm/core/runtime/AppRouter.d.ts.map +1 -1
  91. package/dist/esm/core/runtime/AppRouter.js +18 -1
  92. package/dist/esm/core/runtime/AppRouter.js.map +1 -1
  93. package/dist/esm/core/security/UserOrgsContext.d.ts.map +1 -1
  94. package/dist/esm/core/security/UserOrgsContext.js +61 -8
  95. package/dist/esm/core/security/UserOrgsContext.js.map +1 -1
  96. package/dist/esm/core/ui/inner-control-activation.utils.d.ts +16 -0
  97. package/dist/esm/core/ui/inner-control-activation.utils.d.ts.map +1 -0
  98. package/dist/esm/core/ui/inner-control-activation.utils.js +44 -0
  99. package/dist/esm/core/ui/inner-control-activation.utils.js.map +1 -0
  100. package/dist/tsconfig.build.tsbuildinfo +1 -1
  101. package/package.json +8 -8
@@ -0,0 +1,63 @@
1
+ import { frontendResourceUtils } from '../../core/resources/frontend-resource.utils.js';
2
+ /**
3
+ * The context the acted-on row has after a single-row write that MOVED it out of a parent the current route is scoped
4
+ * by, or `undefined` when the row is still under every parent the route names (#3860).
5
+ *
6
+ * ## Why a host needs to know
7
+ *
8
+ * A record page is addressed under its parents: a todo opened in the Inbox is `/todo-lists/{inbox}/todos/{todo}`, and
9
+ * every read the page makes goes through that address. A write that reassigns the parent key (`todos.move_to_list`
10
+ * writes `todoListId`) takes the row out of that address, so the backend answers every later read there 404: the
11
+ * mutation manager's read-back, its recovery reads, the page's own refresh. The person saw the move succeed and then
12
+ * "Couldn't load item" on a todo that was where they had put it. The row is still readable, under the parent it joined,
13
+ * and that is where the host must go.
14
+ *
15
+ * ## How a move is recognised
16
+ *
17
+ * `rowValues` are values the row holds after the write: the row a write answered, or the row fields a request body sets
18
+ * ({@link rowValuesSetByRequest}). A row field the registry maps to a resource type the route context names
19
+ * (`fieldIdentifierToResourceType`: `todoListId` → `todoLists`) is that parent's key, and a value other than the route's
20
+ * id for that parent means the row left it. One decision for both inputs, so the read-back a host skips and the page it
21
+ * opens cannot disagree about whether the row moved.
22
+ *
23
+ * Only meaningful for a SINGLE-ROW UPDATE-LIKE write; the caller decides that. A create-like operation that names a list
24
+ * (a copy into another list) leaves the acted-on row where it was, and a bulk write has no one row whose page is left.
25
+ */
26
+ export function resolveRouteParentRelocation(params) {
27
+ const { resourceType, contextResourceIdentifiers, rowValues, registry } = params;
28
+ if (!contextResourceIdentifiers || !rowValues || typeof rowValues !== 'object' || Array.isArray(rowValues))
29
+ return undefined;
30
+ let relocated;
31
+ for (const [rowField, value] of Object.entries(rowValues)) {
32
+ if (typeof value !== 'string' || value.length === 0)
33
+ continue;
34
+ const parentType = registry.fieldIdentifierToResourceType?.[rowField];
35
+ if (!parentType || parentType === resourceType)
36
+ continue;
37
+ const routeParent = contextResourceIdentifiers[parentType];
38
+ if (routeParent === undefined || routeParent === null)
39
+ continue;
40
+ const routeParentId = frontendResourceUtils.getResourceId(routeParent);
41
+ if (!routeParentId || routeParentId === value)
42
+ continue;
43
+ relocated ??= { ...contextResourceIdentifiers };
44
+ relocated[parentType] = value;
45
+ }
46
+ return relocated;
47
+ }
48
+ /**
49
+ * The row fields a request body sets: each request field under the row field `requestFieldRowFields` names for it
50
+ * (#3465: a move names its target `targetTodoListId` and sets `todoListId`), else under its own name. Known BEFORE the
51
+ * write is sent, which is when a host must decide not to read the row back at an address the write takes it out of: a
52
+ * failed read-back strips the write's answer, so afterwards the row cannot say where it went.
53
+ */
54
+ export function rowValuesSetByRequest(requestData, requestFieldRowFields) {
55
+ if (!requestData)
56
+ return undefined;
57
+ return Object.fromEntries(Object.entries(requestData).map(([field, value]) => [requestFieldRowFields?.[field] ?? field, value]));
58
+ }
59
+ /** The `requestFieldRowFields` an operation declares, read off any of the shapes an operation arrives in. */
60
+ export function readRequestFieldRowFields(operation) {
61
+ return operation?.requestFieldRowFields;
62
+ }
63
+ //# sourceMappingURL=route-parent-relocation.frontend.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-parent-relocation.frontend.utils.js","sourceRoot":"","sources":["../../../../src/core/resources/route-parent-relocation.frontend.utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4DAA4D,CAAC;AAKnG;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,4BAA4B,CAAC,MAK5C;IACC,MAAM,EAAE,YAAY,EAAE,0BAA0B,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IACjF,IAAI,CAAC,0BAA0B,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;QAAE,OAAO,SAAS,CAAC;IAE7H,IAAI,SAA8C,CAAC;IACnD,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QAC1D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,SAAS;QAC9D,MAAM,UAAU,GAAG,QAAQ,CAAC,6BAA6B,EAAE,CAAC,QAAQ,CAAC,CAAC;QACtE,IAAI,CAAC,UAAU,IAAI,UAAU,KAAK,YAAY;YAAE,SAAS;QACzD,MAAM,WAAW,GAAI,0BAAsD,CAAC,UAAU,CAAC,CAAC;QACxF,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,IAAI;YAAE,SAAS;QAChE,MAAM,aAAa,GAAG,qBAAqB,CAAC,aAAa,CAAC,WAAwE,CAAC,CAAC;QACpI,IAAI,CAAC,aAAa,IAAI,aAAa,KAAK,KAAK;YAAE,SAAS;QACxD,SAAS,KAAK,EAAE,GAAI,0BAAsD,EAAE,CAAC;QAC7E,SAAS,CAAC,UAAU,CAAC,GAAG,KAAK,CAAC;IAChC,CAAC;IACD,OAAO,SAAmD,CAAC;AAC7D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,WAA0D,EAC1D,qBAAmE;IAEnE,IAAI,CAAC,WAAW;QAAE,OAAO,SAAS,CAAC;IACnC,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,qBAAqB,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AACnI,CAAC;AAED,6GAA6G;AAC7G,MAAM,UAAU,yBAAyB,CAAC,SAAkB;IAC1D,OAAQ,SAAsF,EAAE,qBAAqB,CAAC;AACxH,CAAC","sourcesContent":["import type { FrontendResourceOperationContext, FrontendResourcesRegistry } from '~wildo-frontend-lib/core/resources/resources.frontend.schemas';\nimport { frontendResourceUtils } from '~wildo-frontend-lib/core/resources/frontend-resource.utils';\n\ntype ContextResourceIdentifiers = FrontendResourceOperationContext['contextResourceIdentifiers'];\ntype RelocationRegistry = Pick<FrontendResourcesRegistry, 'fieldIdentifierToResourceType'>;\n\n/**\n * The context the acted-on row has after a single-row write that MOVED it out of a parent the current route is scoped\n * by, or `undefined` when the row is still under every parent the route names (#3860).\n *\n * ## Why a host needs to know\n *\n * A record page is addressed under its parents: a todo opened in the Inbox is `/todo-lists/{inbox}/todos/{todo}`, and\n * every read the page makes goes through that address. A write that reassigns the parent key (`todos.move_to_list`\n * writes `todoListId`) takes the row out of that address, so the backend answers every later read there 404: the\n * mutation manager's read-back, its recovery reads, the page's own refresh. The person saw the move succeed and then\n * \"Couldn't load item\" on a todo that was where they had put it. The row is still readable, under the parent it joined,\n * and that is where the host must go.\n *\n * ## How a move is recognised\n *\n * `rowValues` are values the row holds after the write: the row a write answered, or the row fields a request body sets\n * ({@link rowValuesSetByRequest}). A row field the registry maps to a resource type the route context names\n * (`fieldIdentifierToResourceType`: `todoListId` → `todoLists`) is that parent's key, and a value other than the route's\n * id for that parent means the row left it. One decision for both inputs, so the read-back a host skips and the page it\n * opens cannot disagree about whether the row moved.\n *\n * Only meaningful for a SINGLE-ROW UPDATE-LIKE write; the caller decides that. A create-like operation that names a list\n * (a copy into another list) leaves the acted-on row where it was, and a bulk write has no one row whose page is left.\n */\nexport function resolveRouteParentRelocation(params: {\n resourceType: string;\n contextResourceIdentifiers: ContextResourceIdentifiers | undefined;\n rowValues: Readonly<Record<string, unknown>> | undefined;\n registry: RelocationRegistry;\n}): ContextResourceIdentifiers | undefined {\n const { resourceType, contextResourceIdentifiers, rowValues, registry } = params;\n if (!contextResourceIdentifiers || !rowValues || typeof rowValues !== 'object' || Array.isArray(rowValues)) return undefined;\n\n let relocated: Record<string, unknown> | undefined;\n for (const [rowField, value] of Object.entries(rowValues)) {\n if (typeof value !== 'string' || value.length === 0) continue;\n const parentType = registry.fieldIdentifierToResourceType?.[rowField];\n if (!parentType || parentType === resourceType) continue;\n const routeParent = (contextResourceIdentifiers as Record<string, unknown>)[parentType];\n if (routeParent === undefined || routeParent === null) continue;\n const routeParentId = frontendResourceUtils.getResourceId(routeParent as Parameters<typeof frontendResourceUtils.getResourceId>[0]);\n if (!routeParentId || routeParentId === value) continue;\n relocated ??= { ...(contextResourceIdentifiers as Record<string, unknown>) };\n relocated[parentType] = value;\n }\n return relocated as ContextResourceIdentifiers | undefined;\n}\n\n/**\n * The row fields a request body sets: each request field under the row field `requestFieldRowFields` names for it\n * (#3465: a move names its target `targetTodoListId` and sets `todoListId`), else under its own name. Known BEFORE the\n * write is sent, which is when a host must decide not to read the row back at an address the write takes it out of: a\n * failed read-back strips the write's answer, so afterwards the row cannot say where it went.\n */\nexport function rowValuesSetByRequest(\n requestData: Readonly<Record<string, unknown>> | undefined,\n requestFieldRowFields: Readonly<Record<string, string>> | undefined,\n): Record<string, unknown> | undefined {\n if (!requestData) return undefined;\n return Object.fromEntries(Object.entries(requestData).map(([field, value]) => [requestFieldRowFields?.[field] ?? field, value]));\n}\n\n/** The `requestFieldRowFields` an operation declares, read off any of the shapes an operation arrives in. */\nexport function readRequestFieldRowFields(operation: unknown): Readonly<Record<string, string>> | undefined {\n return (operation as { requestFieldRowFields?: Readonly<Record<string, string>> } | undefined)?.requestFieldRowFields;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useOperationDirectExecution.d.ts","sourceRoot":"","sources":["../../../../src/core/resources/useOperationDirectExecution.ts"],"names":[],"mappings":"AA0BA,MAAM,WAAW,iCAAiC;IAChD,oHAAoH;IACpH,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,+CAA+C;IAC/C,YAAY,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,yCAAyC;IACzC,WAAW,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;;;OAIG;IACH,mBAAmB,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/C,gGAAgG;IAChG,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACvC;AAOD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,2BAA2B,CAAC,EAC1C,SAAS,EACT,YAAY,EACZ,cAAc,GACf,EAAE,iCAAiC,GAAG,wBAAwB,CAqS9D"}
1
+ {"version":3,"file":"useOperationDirectExecution.d.ts","sourceRoot":"","sources":["../../../../src/core/resources/useOperationDirectExecution.ts"],"names":[],"mappings":"AA4BA,MAAM,WAAW,iCAAiC;IAChD,oHAAoH;IACpH,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,+CAA+C;IAC/C,YAAY,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,yCAAyC;IACzC,WAAW,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;;;OAIG;IACH,mBAAmB,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/C,gGAAgG;IAChG,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACvC;AAOD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,2BAA2B,CAAC,EAC1C,SAAS,EACT,YAAY,EACZ,cAAc,GACf,EAAE,iCAAiC,GAAG,wBAAwB,CA+U9D"}
@@ -14,6 +14,7 @@ import { ConflictStrategy, MutationPriority, MutationSourceType, MutationType }
14
14
  import { performCanonicalRMMRead, resolveCanonicalRMMReadOperationPathKey, } from '../../core/resources/rmm/canonical-read.frontend.utils.js';
15
15
  import { isSingleResourceUpdateLikeOperation } from '../../core/resources/operation-semantics.frontend.utils.js';
16
16
  import { useResourceOperationOutcomeEmitter } from '../../core/resources/useResourceOperationOutcomeEmitter.js';
17
+ import { readRequestFieldRowFields, resolveRouteParentRelocation, rowValuesSetByRequest } from '../../core/resources/route-parent-relocation.frontend.utils.js';
17
18
  /**
18
19
  * Execute the NEAREST operation view's operation with a body the caller already has — the form-less
19
20
  * half of every operation host.
@@ -41,7 +42,7 @@ import { useResourceOperationOutcomeEmitter } from '../../core/resources/useReso
41
42
  * detached host establishes one (`ResourceOperationDetachedHost`, `ResourceOperationActionDropdown`).
42
43
  */
43
44
  export function useOperationDirectExecution({ onSuccess, errorMessage, errorComponent, }) {
44
- const { resourceContext: currentResourceContext, resourceType, operation, reportError, goBackWithinZone, executeCurrentOperation, } = useResourceOperationViewContext();
45
+ const { resourceContext: currentResourceContext, resourceType, operation, reportError, goBackWithinZone, navigateToPreferredRead, executeCurrentOperation, } = useResourceOperationViewContext();
45
46
  const { doOperation, registry } = useResourceRegistry();
46
47
  // `resource` as well as the component: a resource may override the component's words, and the
47
48
  // fallback this was extracted from resolved them resource-scoped.
@@ -143,7 +144,12 @@ export function useOperationDirectExecution({ onSuccess, errorMessage, errorComp
143
144
  const notification = useContext(NotificationContext);
144
145
  const notificationRef = useRef(notification);
145
146
  notificationRef.current = notification;
146
- const handleSuccess = useCallback((result) => {
147
+ /*
148
+ * `relocatedContext`: the context the row has after a write that moved it out of a parent the route is scoped by
149
+ * (#3860, `resolveRouteParentRelocation`). The host then opens the row where it now is, instead of staying on (or going
150
+ * back within) an address the backend answers 404 for.
151
+ */
152
+ const settleSuccess = useCallback((result, relocatedContext) => {
147
153
  // #2288: an operation held for another person's approval changed nothing. Said as waiting, and announced as nothing
148
154
  // (the emitter refuses a held answer); the host still moves on, since the request was made.
149
155
  if (readOperationApprovalPending(result)) {
@@ -154,12 +160,31 @@ export function useOperationDirectExecution({ onSuccess, errorMessage, errorComp
154
160
  }));
155
161
  }
156
162
  announceOutcome(result);
163
+ // A write held for approval moved nothing, so the row is still where the route says.
164
+ if (relocatedContext && !readOperationApprovalPending(result)) {
165
+ onSuccess?.(result);
166
+ navigateToPreferredRead({ contextResourceIdentifiers: relocatedContext });
167
+ return;
168
+ }
157
169
  if (onSuccess) {
158
170
  onSuccess(result);
159
171
  return;
160
172
  }
161
173
  goBackWithinZone();
162
- }, [announceOutcome, goBackWithinZone, onSuccess, tComponent]);
174
+ }, [announceOutcome, goBackWithinZone, navigateToPreferredRead, onSuccess, tComponent]);
175
+ /*
176
+ * The success a host hands in after its OWN write (the form): whether the row moved is read off the row the write
177
+ * answered, the one input that host has. The form does not read the row back after such a write
178
+ * (`ResourceAutomatedForm`), so the answer is the written row.
179
+ */
180
+ const handleSuccess = useCallback((result) => settleSuccess(result, isSingleRowUpdateLike && !readOperationApprovalPending(result)
181
+ ? resolveRouteParentRelocation({
182
+ resourceType,
183
+ contextResourceIdentifiers: contextResourceIdentifiersWithResourceId,
184
+ rowValues: result,
185
+ registry,
186
+ })
187
+ : undefined), [contextResourceIdentifiersWithResourceId, isSingleRowUpdateLike, registry, resourceType, settleSuccess]);
163
188
  const handleError = useCallback((error) => {
164
189
  reportError(error, errorMessage, errorComponent);
165
190
  }, [errorComponent, errorMessage, reportError]);
@@ -218,6 +243,16 @@ export function useOperationDirectExecution({ onSuccess, errorMessage, errorComp
218
243
  setIsExecuting(true);
219
244
  try {
220
245
  let result;
246
+ // Decided from the declarations and the body BEFORE sending: a write that takes the row out of the route's parent
247
+ // must not be read back at the address it leaves (#3860), and the response cannot say so once a read-back failed.
248
+ const relocatedContext = isSingleRowUpdateLike
249
+ ? resolveRouteParentRelocation({
250
+ resourceType,
251
+ contextResourceIdentifiers: contextResourceIdentifiersWithResourceId,
252
+ rowValues: rowValuesSetByRequest(requestData, readRequestFieldRowFields(operation)),
253
+ registry,
254
+ })
255
+ : undefined;
221
256
  if (isSingleRowUpdateLike && (rmm || !acceptsDirectLane)) {
222
257
  if (!rmm) {
223
258
  throw new MissingRMMRuntimeError({
@@ -240,7 +275,9 @@ export function useOperationDirectExecution({ onSuccess, errorMessage, errorComp
240
275
  contextualParameters,
241
276
  parentResourcesRequirements: currentResourceContext.parentResourcesRequirements,
242
277
  requestData: requestData ?? {},
243
- readBackOnSuccess: true,
278
+ // The row's canonical read is addressed under the route's parents; after a move it answers 404 there, and a
279
+ // failed read-back strips the response and schedules recovery reads of the same dead address (#3860).
280
+ readBackOnSuccess: relocatedContext === undefined,
244
281
  },
245
282
  });
246
283
  if (!mutationResult.success) {
@@ -267,7 +304,7 @@ export function useOperationDirectExecution({ onSuccess, errorMessage, errorComp
267
304
  else {
268
305
  result = await executeCurrentOperation(requestData);
269
306
  }
270
- handleSuccess(result);
307
+ settleSuccess(result, relocatedContext);
271
308
  }
272
309
  catch (error) {
273
310
  handleError(error instanceof Error ? error : new Error(executionFailedLabel));
@@ -278,9 +315,10 @@ export function useOperationDirectExecution({ onSuccess, errorMessage, errorComp
278
315
  }, [
279
316
  contextualParameters,
280
317
  currentResourceContext.parentResourcesRequirements,
318
+ contextResourceIdentifiersWithResourceId,
281
319
  executeCurrentOperation,
282
320
  handleError,
283
- handleSuccess,
321
+ settleSuccess,
284
322
  acceptsDirectLane,
285
323
  isSingleRowUpdateLike,
286
324
  currentResourceId,
@@ -288,6 +326,7 @@ export function useOperationDirectExecution({ onSuccess, errorMessage, errorComp
288
326
  resourceType,
289
327
  rmm,
290
328
  executionFailedLabel,
329
+ registry,
291
330
  ]);
292
331
  return {
293
332
  execute,
@@ -1 +1 @@
1
- {"version":3,"file":"useOperationDirectExecution.js","sourceRoot":"","sources":["../../../../src/core/resources/useOperationDirectExecution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,E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AAoB,CAAC,CAAC,CAAC;QAChF,CAAC;gBAAS,CAAC;YACT,cAAc,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,EAAE;QACD,oBAAoB;QACpB,sBAAsB,CAAC,2BAA2B;QAClD,uBAAuB;QACvB,WAAW;QACX,aAAa;QACb,iBAAiB;QACjB,qBAAqB;QACrB,iBAAiB;QACjB,SAAS;QACT,YAAY;QACZ,GAAG;QACH,oBAAoB;KACrB,CAAC,CAAC;IAEH,OAAO;QACL,OAAO;QACP,WAAW;QACX,eAAe;QACf,mBAAmB,EAAE,aAAa;QAClC,aAAa,EAAE,WAAW;KAC3B,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';\n\nimport type { FieldMetaEntry } from '@wildo-ai/saas-models';\nimport { ResourcesConfig_OperationPathUtils, readOperationApprovalPending } from '@wildo-ai/saas-models';\nimport { NotificationContext } from '~wildo-frontend-lib/core/events/NotificationContext';\nimport { FrontendComponentType } from '@wildo-ai/presets-components-models';\nimport { useI18n } from '~wildo-frontend-lib/core/i18n/useI18n';\nimport { resolveComponentLabel } from '~wildo-frontend-lib/core/i18n/component-label-resolution.utils';\nimport { useResourceOperationViewContext } from '~wildo-frontend-lib/core/resources/ResourceOperationViewContext';\nimport { FrontendResourceUtils, frontendResourceUtils } from '~wildo-frontend-lib/core/resources/frontend-resource.utils';\nimport { useResourceRegistry } from '~wildo-frontend-lib/core/resources/useResourceRegistry';\nimport {\n allowsDirectOperationFallback,\n MissingRMMRuntimeError,\n resolveUpdateLikeMutationFallbackMode,\n} from '~wildo-frontend-lib/core/resources/rmm/update-like-mutation-fallback.frontend';\nimport { useResourceRMM } from '~wildo-frontend-lib/core/resources/rmm/useResourceRMM';\nimport { mutationErrorForReport } from '~wildo-frontend-lib/core/resources/rmm/mutation-error-report.utils';\nimport { ConflictStrategy, MutationPriority, MutationSourceType, MutationType } from '~wildo-frontend-lib/core/resources/rmm/types';\nimport {\n performCanonicalRMMRead,\n resolveCanonicalRMMReadOperationPathKey,\n} from '~wildo-frontend-lib/core/resources/rmm/canonical-read.frontend.utils';\nimport { isSingleResourceUpdateLikeOperation } from '~wildo-frontend-lib/core/resources/operation-semantics.frontend.utils';\nimport { useResourceOperationOutcomeEmitter } from '~wildo-frontend-lib/core/resources/useResourceOperationOutcomeEmitter';\n\nexport interface UseOperationDirectExecutionParams {\n /** Replaces what happens AFTER a success. The outcome is announced either way. Omitted: go back within the zone. */\n onSuccess?: (result: unknown) => void;\n /** The message a failure is reported under. */\n errorMessage: string;\n /** The component a failure is attributed to in the report. */\n errorComponent: string;\n}\n\nexport interface OperationDirectExecution {\n /**\n * Execute the hosted operation with this exact request body — no form, no validation pass beyond\n * the server's. Resolves once the outcome has been announced (success) or reported (failure).\n * Omitted means \"no body at all\", which is what a zero-input action sends — not an empty object.\n */\n execute: (requestData?: Record<string, unknown>) => Promise<void>;\n /** True while a request is in flight. */\n isExecuting: boolean;\n /**\n * True while an update-like operation with no target id in its context is resolving that id from\n * the canonical READ. Execution must wait for it: the RMM that carries the mutation is keyed on it.\n */\n isBootstrapping: boolean;\n /**\n * The success path itself — announce the outcome, then `onSuccess` or go back. Exposed so a host\n * that ALSO renders a form hands the form this very function, and \"what success means\" has one\n * definition across the form and the form-less paths.\n */\n completeWithSuccess: (result: unknown) => void;\n /** The failure path — reports under `errorMessage` / `errorComponent`. Same reason as above. */\n reportFailure: (error: Error) => void;\n}\n\ntype BootstrappedTargetRow = {\n contextKey: string;\n row: Record<string, unknown>;\n};\n\n/**\n * Execute the NEAREST operation view's operation with a body the caller already has — the form-less\n * half of every operation host.\n *\n * ## Why this is its own hook\n *\n * It began as the zero-input branch of `ResourceLayout_SemanticOperationFallback` (\"Run\" with an\n * empty body), and a DROPDOWN action needs exactly the same thing with a one-field body: the pick is\n * the submission. The alternative — a second copy of the RMM-or-direct decision, the canonical-READ\n * bootstrap and the outcome announcement inside the dropdown — is the shape this package has already\n * paid for once (the bulk selector, spelled two ways). One hook, so a host that executes without a\n * form inherits the whole contract by using it:\n *\n * - **update-like single-resource operations run through the RMM**, never the plain `doOperation`\n * lane, and fail closed with `MissingRMMRuntimeError` rather than writing without it;\n * - **a missing target id is resolved first** from the canonical READ, so a detail-less context (a\n * bulk bar, a singleton) still mutates the right row;\n * - **everything else runs `executeCurrentOperation`**, which merges a bulk selection into the body;\n * - **the outcome is ALWAYS announced**, and `onSuccess` replaces only what happens next.\n *\n * Confirmation is NOT decided here. Each host owns the dialog it shows, because only the host knows\n * whether a person has already acted deliberately (typed a phrase, pressed Submit) or merely picked.\n *\n * Must be called under a `ResourceOperationViewProvider` for the operation being executed — a\n * detached host establishes one (`ResourceOperationDetachedHost`, `ResourceOperationActionDropdown`).\n */\nexport function useOperationDirectExecution({\n onSuccess,\n errorMessage,\n errorComponent,\n}: UseOperationDirectExecutionParams): OperationDirectExecution {\n const {\n resourceContext: currentResourceContext,\n resourceType,\n operation,\n reportError,\n goBackWithinZone,\n executeCurrentOperation,\n } = useResourceOperationViewContext();\n const { doOperation, registry } = useResourceRegistry();\n // `resource` as well as the component: a resource may override the component's words, and the\n // fallback this was extracted from resolved them resource-scoped.\n const { tComponent } = useI18n({ component: FrontendComponentType.RESOURCES_LAYOUTS_ACTION, resource: resourceType });\n const doOperationRef = useRef(doOperation);\n doOperationRef.current = doOperation;\n\n const [isExecuting, setIsExecuting] = useState(false);\n const [isBootstrapping, setIsBootstrapping] = useState(false);\n const [bootstrappedRow, setBootstrappedRow] = useState<BootstrappedTargetRow | null>(null);\n /*\n * A single-row update-like operation addresses ONE row, whichever lane it runs on, so its target id\n * is resolved (the canonical-READ bootstrap below) for both lanes, and the row's RMM is attached when\n * the row has one.\n *\n * It runs through that RMM when there is one. Without one it runs directly only if the operation's lane\n * is the direct one — declared by the operation, or derived because its resource has no field-write\n * route (#1956) — read through the same function the form host and `useResourceOperationSurface` read, so\n * the two hosts pick the same lane; otherwise it fails closed.\n */\n const isSingleRowUpdateLike = useMemo(() => isSingleResourceUpdateLikeOperation(operation), [operation]);\n const acceptsDirectLane = isSingleRowUpdateLike\n && allowsDirectOperationFallback(resolveUpdateLikeMutationFallbackMode(operation, registry.resourceConfigurations[resourceType]?.operations));\n\n const bootstrapContextKey = useMemo(() => JSON.stringify({\n contextResourceIdentifiers: FrontendResourceUtils.buildContextResourceIdentifiersKey(\n currentResourceContext.contextResourceIdentifiers ?? {},\n ),\n parentResourcesRequirements: currentResourceContext.parentResourcesRequirements ?? [],\n }), [\n currentResourceContext.contextResourceIdentifiers,\n currentResourceContext.parentResourcesRequirements,\n ]);\n const routeResourceId = useMemo(() => {\n const identifier = currentResourceContext.contextResourceIdentifiers?.[resourceType];\n if (!identifier) {\n return null;\n }\n return frontendResourceUtils.getResourceId(identifier) ?? null;\n }, [currentResourceContext.contextResourceIdentifiers, resourceType]);\n const currentResourceId = routeResourceId ?? (\n bootstrappedRow?.contextKey === bootstrapContextKey\n && typeof bootstrappedRow.row._id === 'string'\n && bootstrappedRow.row._id.length > 0\n ? bootstrappedRow.row._id\n : null\n );\n const contextResourceIdentifiersWithResourceId = useMemo(() => {\n if (!currentResourceId || currentResourceContext.contextResourceIdentifiers?.[resourceType]) {\n return currentResourceContext.contextResourceIdentifiers;\n }\n\n return {\n ...currentResourceContext.contextResourceIdentifiers,\n [resourceType]: currentResourceId,\n };\n }, [currentResourceContext.contextResourceIdentifiers, currentResourceId, resourceType]);\n const contextualParameters = useMemo(() => {\n return FrontendResourceUtils.buildContextualParameters(\n contextResourceIdentifiersWithResourceId,\n registry,\n );\n }, [contextResourceIdentifiersWithResourceId, registry]);\n // The row is read in the operation's own lane (#3170): an operator's crossed verb reads it through a crossed READ,\n // since a member's read of a tenant the operator does not belong to answers 404.\n const actingVariantKey = (operation as { variantKey?: string } | undefined)?.variantKey;\n const actingCrossesTenant = (operation as { admitsCrossTenantPlatformAdministration?: boolean } | undefined)?.admitsCrossTenantPlatformAdministration === true;\n const actingOperation = useMemo(\n () => ({ variantKey: actingVariantKey, admitsCrossTenantPlatformAdministration: actingCrossesTenant }),\n [actingCrossesTenant, actingVariantKey],\n );\n const canonicalReadOperationPathKey = useMemo(() => {\n return resolveCanonicalRMMReadOperationPathKey(resourceType, registry, {\n hasResourceId: Boolean(currentResourceId),\n contextResourceIdentifiers: contextResourceIdentifiersWithResourceId,\n contextualParameters,\n actingOperation,\n });\n }, [contextResourceIdentifiersWithResourceId, contextualParameters, currentResourceId, actingOperation, registry, resourceType]);\n const { rmm } = useResourceRMM({\n resourceType,\n resourceId: currentResourceId,\n doOperationRef,\n contextualParameters,\n parentResourcesRequirements: currentResourceContext.parentResourcesRequirements,\n contextResourceIdentifiers: contextResourceIdentifiersWithResourceId,\n resourceSchema: registry.resourceConfigurations[resourceType]?.mainSchema,\n resourceInheritance: registry.resourceConfigurations[resourceType]?.inheritenceSchemaDefinition,\n enabled: isSingleRowUpdateLike && !!currentResourceId,\n conflictPolicy: { strategy: ConflictStrategy.ACCEPT_REMOTE },\n directFallbackAccepted: acceptsDirectLane,\n actingOperation,\n });\n\n const executionFailedLabel = useMemo(() => {\n return resolveComponentLabel({\n tComponent,\n componentType: FrontendComponentType.RESOURCES_LAYOUTS_ACTION,\n key: 'executionFailed',\n });\n }, [tComponent]);\n\n /*\n * Announced with the context that carries the RESOLVED row id, not the route's. A context-addressed\n * singleton has no id on its route; the id comes from the canonical READ, and a page showing that row\n * re-reads only when the announcement names it (#1782). The route context named no row, so an action\n * whose result carries no `_id` (a secret's change outcome) announced a change to nobody.\n */\n const announcedContext = useMemo(\n () => (contextResourceIdentifiersWithResourceId === currentResourceContext.contextResourceIdentifiers\n ? currentResourceContext\n : { ...currentResourceContext, contextResourceIdentifiers: contextResourceIdentifiersWithResourceId }),\n [contextResourceIdentifiersWithResourceId, currentResourceContext],\n );\n const announceOutcome = useResourceOperationOutcomeEmitter(announcedContext, operation);\n // Read directly, never through the throwing `useNotification()`: this hook must not require a provider.\n const notification = useContext(NotificationContext);\n const notificationRef = useRef(notification);\n notificationRef.current = notification;\n const handleSuccess = useCallback((result: unknown) => {\n // #2288: an operation held for another person's approval changed nothing. Said as waiting, and announced as nothing\n // (the emitter refuses a held answer); the host still moves on, since the request was made.\n if (readOperationApprovalPending(result)) {\n notificationRef.current?.notifyInfo(resolveComponentLabel({\n tComponent,\n componentType: FrontendComponentType.RESOURCES_LAYOUTS_ACTION,\n key: 'operationSentForApproval',\n }));\n }\n announceOutcome(result);\n if (onSuccess) {\n onSuccess(result);\n return;\n }\n goBackWithinZone();\n }, [announceOutcome, goBackWithinZone, onSuccess, tComponent]);\n\n const handleError = useCallback((error: Error) => {\n reportError(error, errorMessage, errorComponent);\n }, [errorComponent, errorMessage, reportError]);\n\n useEffect(() => {\n if (!isSingleRowUpdateLike || currentResourceId || !canonicalReadOperationPathKey) {\n return;\n }\n\n let cancelled = false;\n setIsBootstrapping(true);\n void performCanonicalRMMRead({\n doOperation: doOperationRef.current,\n readOperationPathKey: canonicalReadOperationPathKey,\n contextualParameters,\n parentResourcesRequirements: currentResourceContext.parentResourcesRequirements,\n }).then((row) => {\n if (cancelled) return;\n setBootstrappedRow({\n contextKey: bootstrapContextKey,\n row,\n });\n }).catch((error: unknown) => {\n if (cancelled) return;\n handleError(error instanceof Error ? error : new Error(String(error)));\n }).finally(() => {\n if (!cancelled) {\n setIsBootstrapping(false);\n }\n });\n\n return () => {\n cancelled = true;\n };\n }, [\n bootstrapContextKey,\n canonicalReadOperationPathKey,\n contextualParameters,\n currentResourceContext.parentResourcesRequirements,\n currentResourceId,\n handleError,\n isSingleRowUpdateLike,\n ]);\n\n useEffect(() => {\n if (!rmm || !bootstrappedRow || bootstrappedRow.contextKey !== bootstrapContextKey) {\n return;\n }\n\n if (typeof rmm.getSnapshot === 'function' && rmm.getSnapshot().confirmedData !== null) {\n return;\n }\n\n if (typeof rmm.setInitialState === 'function') {\n const row = bootstrappedRow.row;\n rmm.setInitialState(\n row,\n (row._version as number | undefined) ?? 0,\n row._field_meta as Record<string, FieldMetaEntry> | undefined,\n );\n }\n }, [bootstrapContextKey, bootstrappedRow, rmm]);\n\n const execute = useCallback(async (requestData?: Record<string, unknown>) => {\n setIsExecuting(true);\n try {\n let result: unknown;\n\n if (isSingleRowUpdateLike && (rmm || !acceptsDirectLane)) {\n if (!rmm) {\n throw new MissingRMMRuntimeError({\n surfaceName: 'useOperationDirectExecution',\n resourceType,\n operationIdentifier: String(operation.operationIdentifier),\n });\n }\n\n // No optimistic patch: the body is the OPERATION's input, not a set of resource fields, and a\n // custom operation's input names need not be the row's. The row is read back on success.\n const mutationResult = await rmm.queueMutation({}, {\n type: MutationType.CUSTOM,\n priority: MutationPriority.HIGH,\n source: {\n type: MutationSourceType.CUSTOM,\n subscriberId: `direct-execution:${String(operation.operationIdentifier)}`,\n },\n transportOverride: {\n operationPathKey: ResourcesConfig_OperationPathUtils.createOperationPathKeyFromOperation(operation),\n contextualParameters,\n parentResourcesRequirements: currentResourceContext.parentResourcesRequirements,\n requestData: requestData ?? {},\n readBackOnSuccess: true,\n },\n });\n\n if (!mutationResult.success) {\n throw mutationErrorForReport(mutationResult.error, executionFailedLabel);\n }\n\n result = mutationResult.heldForApproval ?? mutationResult.responseData;\n } else if (isSingleRowUpdateLike) {\n /*\n * No RMM and the direct lane declared, still for ONE row: sent with the parameters this hook resolved, which carry the\n * bootstrapped id when the route had none. `executeCurrentOperation` builds its parameters from the\n * route alone, so from a detail-less context (a singleton, a bulk bar) it would address `{id}`\n * unresolved. With no id at all the operation has no row to act on, and says so instead of sending.\n */\n if (!currentResourceId) {\n throw new Error(`${String(operation.operationIdentifier)} on ${resourceType} has no row to act on: no id on the route and none from its canonical READ.`);\n }\n result = await doOperationRef.current(ResourcesConfig_OperationPathUtils.createOperationPathKeyFromOperation(operation), {\n contextualParameters,\n parentResourcesRequirements: currentResourceContext.parentResourcesRequirements,\n requestData: requestData ?? {},\n });\n } else {\n result = await executeCurrentOperation(requestData);\n }\n\n handleSuccess(result);\n } catch (error) {\n handleError(error instanceof Error ? error : new Error(executionFailedLabel));\n } finally {\n setIsExecuting(false);\n }\n }, [\n contextualParameters,\n currentResourceContext.parentResourcesRequirements,\n executeCurrentOperation,\n handleError,\n handleSuccess,\n acceptsDirectLane,\n isSingleRowUpdateLike,\n currentResourceId,\n operation,\n resourceType,\n rmm,\n executionFailedLabel,\n ]);\n\n return {\n execute,\n isExecuting,\n isBootstrapping,\n completeWithSuccess: handleSuccess,\n reportFailure: handleError,\n };\n}\n"]}
1
+ {"version":3,"file":"useOperationDirectExecution.js","sourceRoot":"","sources":["../../../../src/core/resources/useOperationDirectExecution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtF,OAAO,EAAE,kCAAkC,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACzG,OAAO,EAAE,mBAAmB,EAAE,MAAM,qDAAqD,CAAC;AAC1F,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,uCAAuC,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gEAAgE,CAAC;AACvG,OAAO,EAAE,+BAA+B,EAAE,MAAM,iEAAiE,CAAC;AAClH,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,4DAA4D,CAAC;AAC1H,OAAO,EAAE,mBAAmB,EAAE,MAAM,wDAAwD,CAAC;AAC7F,OAAO,EACL,6BAA6B,EAC7B,sBAAsB,EACtB,qCAAqC,GACtC,MAAM,+EAA+E,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,uDAAuD,CAAC;AACvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oEAAoE,CAAC;AAC5G,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AACpI,OAAO,EACL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YACL,CAAC;iBAAM,CAAC;gBACN,MAAM,GAAG,MAAM,uBAAuB,CAAC,WAAW,CAAC,CAAC;YACtD,CAAC;YAED,aAAa,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,WAAW,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAChF,CAAC;gBAAS,CAAC;YACT,cAAc,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,EAAE;QACD,oBAAoB;QACpB,sBAAsB,CAAC,2BAA2B;QAClD,wCAAwC;QACxC,uBAAuB;QACvB,WAAW;QACX,aAAa;QACb,iBAAiB;QACjB,qBAAqB;QACrB,iBAAiB;QACjB,SAAS;QACT,YAAY;QACZ,GAAG;QACH,oBAAoB;QACpB,QAAQ;KACT,CAAC,CAAC;IAEH,OAAO;QACL,OAAO;QACP,WAAW;QACX,eAAe;QACf,mBAAmB,EAAE,aAAa;QAClC,aAAa,EAAE,WAAW;KAC3B,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';\n\nimport type { FieldMetaEntry } from '@wildo-ai/saas-models';\nimport { ResourcesConfig_OperationPathUtils, readOperationApprovalPending } from '@wildo-ai/saas-models';\nimport { NotificationContext } from '~wildo-frontend-lib/core/events/NotificationContext';\nimport { FrontendComponentType } from '@wildo-ai/presets-components-models';\nimport { useI18n } from '~wildo-frontend-lib/core/i18n/useI18n';\nimport { resolveComponentLabel } from '~wildo-frontend-lib/core/i18n/component-label-resolution.utils';\nimport { useResourceOperationViewContext } from '~wildo-frontend-lib/core/resources/ResourceOperationViewContext';\nimport { FrontendResourceUtils, frontendResourceUtils } from '~wildo-frontend-lib/core/resources/frontend-resource.utils';\nimport { useResourceRegistry } from '~wildo-frontend-lib/core/resources/useResourceRegistry';\nimport {\n allowsDirectOperationFallback,\n MissingRMMRuntimeError,\n resolveUpdateLikeMutationFallbackMode,\n} from '~wildo-frontend-lib/core/resources/rmm/update-like-mutation-fallback.frontend';\nimport { useResourceRMM } from '~wildo-frontend-lib/core/resources/rmm/useResourceRMM';\nimport { mutationErrorForReport } from '~wildo-frontend-lib/core/resources/rmm/mutation-error-report.utils';\nimport { ConflictStrategy, MutationPriority, MutationSourceType, MutationType } from '~wildo-frontend-lib/core/resources/rmm/types';\nimport {\n performCanonicalRMMRead,\n resolveCanonicalRMMReadOperationPathKey,\n} from '~wildo-frontend-lib/core/resources/rmm/canonical-read.frontend.utils';\nimport { isSingleResourceUpdateLikeOperation } from '~wildo-frontend-lib/core/resources/operation-semantics.frontend.utils';\nimport { useResourceOperationOutcomeEmitter } from '~wildo-frontend-lib/core/resources/useResourceOperationOutcomeEmitter';\nimport { readRequestFieldRowFields, resolveRouteParentRelocation, rowValuesSetByRequest } from '~wildo-frontend-lib/core/resources/route-parent-relocation.frontend.utils';\nimport type { FrontendResourceOperationContext } from '~wildo-frontend-lib/core/resources/resources.frontend.schemas';\n\nexport interface UseOperationDirectExecutionParams {\n /** Replaces what happens AFTER a success. The outcome is announced either way. Omitted: go back within the zone. */\n onSuccess?: (result: unknown) => void;\n /** The message a failure is reported under. */\n errorMessage: string;\n /** The component a failure is attributed to in the report. */\n errorComponent: string;\n}\n\nexport interface OperationDirectExecution {\n /**\n * Execute the hosted operation with this exact request body — no form, no validation pass beyond\n * the server's. Resolves once the outcome has been announced (success) or reported (failure).\n * Omitted means \"no body at all\", which is what a zero-input action sends — not an empty object.\n */\n execute: (requestData?: Record<string, unknown>) => Promise<void>;\n /** True while a request is in flight. */\n isExecuting: boolean;\n /**\n * True while an update-like operation with no target id in its context is resolving that id from\n * the canonical READ. Execution must wait for it: the RMM that carries the mutation is keyed on it.\n */\n isBootstrapping: boolean;\n /**\n * The success path itself — announce the outcome, then `onSuccess` or go back. Exposed so a host\n * that ALSO renders a form hands the form this very function, and \"what success means\" has one\n * definition across the form and the form-less paths.\n */\n completeWithSuccess: (result: unknown) => void;\n /** The failure path — reports under `errorMessage` / `errorComponent`. Same reason as above. */\n reportFailure: (error: Error) => void;\n}\n\ntype BootstrappedTargetRow = {\n contextKey: string;\n row: Record<string, unknown>;\n};\n\n/**\n * Execute the NEAREST operation view's operation with a body the caller already has — the form-less\n * half of every operation host.\n *\n * ## Why this is its own hook\n *\n * It began as the zero-input branch of `ResourceLayout_SemanticOperationFallback` (\"Run\" with an\n * empty body), and a DROPDOWN action needs exactly the same thing with a one-field body: the pick is\n * the submission. The alternative — a second copy of the RMM-or-direct decision, the canonical-READ\n * bootstrap and the outcome announcement inside the dropdown — is the shape this package has already\n * paid for once (the bulk selector, spelled two ways). One hook, so a host that executes without a\n * form inherits the whole contract by using it:\n *\n * - **update-like single-resource operations run through the RMM**, never the plain `doOperation`\n * lane, and fail closed with `MissingRMMRuntimeError` rather than writing without it;\n * - **a missing target id is resolved first** from the canonical READ, so a detail-less context (a\n * bulk bar, a singleton) still mutates the right row;\n * - **everything else runs `executeCurrentOperation`**, which merges a bulk selection into the body;\n * - **the outcome is ALWAYS announced**, and `onSuccess` replaces only what happens next.\n *\n * Confirmation is NOT decided here. Each host owns the dialog it shows, because only the host knows\n * whether a person has already acted deliberately (typed a phrase, pressed Submit) or merely picked.\n *\n * Must be called under a `ResourceOperationViewProvider` for the operation being executed — a\n * detached host establishes one (`ResourceOperationDetachedHost`, `ResourceOperationActionDropdown`).\n */\nexport function useOperationDirectExecution({\n onSuccess,\n errorMessage,\n errorComponent,\n}: UseOperationDirectExecutionParams): OperationDirectExecution {\n const {\n resourceContext: currentResourceContext,\n resourceType,\n operation,\n reportError,\n goBackWithinZone,\n navigateToPreferredRead,\n executeCurrentOperation,\n } = useResourceOperationViewContext();\n const { doOperation, registry } = useResourceRegistry();\n // `resource` as well as the component: a resource may override the component's words, and the\n // fallback this was extracted from resolved them resource-scoped.\n const { tComponent } = useI18n({ component: FrontendComponentType.RESOURCES_LAYOUTS_ACTION, resource: resourceType });\n const doOperationRef = useRef(doOperation);\n doOperationRef.current = doOperation;\n\n const [isExecuting, setIsExecuting] = useState(false);\n const [isBootstrapping, setIsBootstrapping] = useState(false);\n const [bootstrappedRow, setBootstrappedRow] = useState<BootstrappedTargetRow | null>(null);\n /*\n * A single-row update-like operation addresses ONE row, whichever lane it runs on, so its target id\n * is resolved (the canonical-READ bootstrap below) for both lanes, and the row's RMM is attached when\n * the row has one.\n *\n * It runs through that RMM when there is one. Without one it runs directly only if the operation's lane\n * is the direct one — declared by the operation, or derived because its resource has no field-write\n * route (#1956) — read through the same function the form host and `useResourceOperationSurface` read, so\n * the two hosts pick the same lane; otherwise it fails closed.\n */\n const isSingleRowUpdateLike = useMemo(() => isSingleResourceUpdateLikeOperation(operation), [operation]);\n const acceptsDirectLane = isSingleRowUpdateLike\n && allowsDirectOperationFallback(resolveUpdateLikeMutationFallbackMode(operation, registry.resourceConfigurations[resourceType]?.operations));\n\n const bootstrapContextKey = useMemo(() => JSON.stringify({\n contextResourceIdentifiers: FrontendResourceUtils.buildContextResourceIdentifiersKey(\n currentResourceContext.contextResourceIdentifiers ?? {},\n ),\n parentResourcesRequirements: currentResourceContext.parentResourcesRequirements ?? [],\n }), [\n currentResourceContext.contextResourceIdentifiers,\n currentResourceContext.parentResourcesRequirements,\n ]);\n const routeResourceId = useMemo(() => {\n const identifier = currentResourceContext.contextResourceIdentifiers?.[resourceType];\n if (!identifier) {\n return null;\n }\n return frontendResourceUtils.getResourceId(identifier) ?? null;\n }, [currentResourceContext.contextResourceIdentifiers, resourceType]);\n const currentResourceId = routeResourceId ?? (\n bootstrappedRow?.contextKey === bootstrapContextKey\n && typeof bootstrappedRow.row._id === 'string'\n && bootstrappedRow.row._id.length > 0\n ? bootstrappedRow.row._id\n : null\n );\n const contextResourceIdentifiersWithResourceId = useMemo(() => {\n if (!currentResourceId || currentResourceContext.contextResourceIdentifiers?.[resourceType]) {\n return currentResourceContext.contextResourceIdentifiers;\n }\n\n return {\n ...currentResourceContext.contextResourceIdentifiers,\n [resourceType]: currentResourceId,\n };\n }, [currentResourceContext.contextResourceIdentifiers, currentResourceId, resourceType]);\n const contextualParameters = useMemo(() => {\n return FrontendResourceUtils.buildContextualParameters(\n contextResourceIdentifiersWithResourceId,\n registry,\n );\n }, [contextResourceIdentifiersWithResourceId, registry]);\n // The row is read in the operation's own lane (#3170): an operator's crossed verb reads it through a crossed READ,\n // since a member's read of a tenant the operator does not belong to answers 404.\n const actingVariantKey = (operation as { variantKey?: string } | undefined)?.variantKey;\n const actingCrossesTenant = (operation as { admitsCrossTenantPlatformAdministration?: boolean } | undefined)?.admitsCrossTenantPlatformAdministration === true;\n const actingOperation = useMemo(\n () => ({ variantKey: actingVariantKey, admitsCrossTenantPlatformAdministration: actingCrossesTenant }),\n [actingCrossesTenant, actingVariantKey],\n );\n const canonicalReadOperationPathKey = useMemo(() => {\n return resolveCanonicalRMMReadOperationPathKey(resourceType, registry, {\n hasResourceId: Boolean(currentResourceId),\n contextResourceIdentifiers: contextResourceIdentifiersWithResourceId,\n contextualParameters,\n actingOperation,\n });\n }, [contextResourceIdentifiersWithResourceId, contextualParameters, currentResourceId, actingOperation, registry, resourceType]);\n const { rmm } = useResourceRMM({\n resourceType,\n resourceId: currentResourceId,\n doOperationRef,\n contextualParameters,\n parentResourcesRequirements: currentResourceContext.parentResourcesRequirements,\n contextResourceIdentifiers: contextResourceIdentifiersWithResourceId,\n resourceSchema: registry.resourceConfigurations[resourceType]?.mainSchema,\n resourceInheritance: registry.resourceConfigurations[resourceType]?.inheritenceSchemaDefinition,\n enabled: isSingleRowUpdateLike && !!currentResourceId,\n conflictPolicy: { strategy: ConflictStrategy.ACCEPT_REMOTE },\n directFallbackAccepted: acceptsDirectLane,\n actingOperation,\n });\n\n const executionFailedLabel = useMemo(() => {\n return resolveComponentLabel({\n tComponent,\n componentType: FrontendComponentType.RESOURCES_LAYOUTS_ACTION,\n key: 'executionFailed',\n });\n }, [tComponent]);\n\n /*\n * Announced with the context that carries the RESOLVED row id, not the route's. A context-addressed\n * singleton has no id on its route; the id comes from the canonical READ, and a page showing that row\n * re-reads only when the announcement names it (#1782). The route context named no row, so an action\n * whose result carries no `_id` (a secret's change outcome) announced a change to nobody.\n */\n const announcedContext = useMemo(\n () => (contextResourceIdentifiersWithResourceId === currentResourceContext.contextResourceIdentifiers\n ? currentResourceContext\n : { ...currentResourceContext, contextResourceIdentifiers: contextResourceIdentifiersWithResourceId }),\n [contextResourceIdentifiersWithResourceId, currentResourceContext],\n );\n const announceOutcome = useResourceOperationOutcomeEmitter(announcedContext, operation);\n // Read directly, never through the throwing `useNotification()`: this hook must not require a provider.\n const notification = useContext(NotificationContext);\n const notificationRef = useRef(notification);\n notificationRef.current = notification;\n /*\n * `relocatedContext`: the context the row has after a write that moved it out of a parent the route is scoped by\n * (#3860, `resolveRouteParentRelocation`). The host then opens the row where it now is, instead of staying on (or going\n * back within) an address the backend answers 404 for.\n */\n const settleSuccess = useCallback((result: unknown, relocatedContext?: FrontendResourceOperationContext['contextResourceIdentifiers']) => {\n // #2288: an operation held for another person's approval changed nothing. Said as waiting, and announced as nothing\n // (the emitter refuses a held answer); the host still moves on, since the request was made.\n if (readOperationApprovalPending(result)) {\n notificationRef.current?.notifyInfo(resolveComponentLabel({\n tComponent,\n componentType: FrontendComponentType.RESOURCES_LAYOUTS_ACTION,\n key: 'operationSentForApproval',\n }));\n }\n announceOutcome(result);\n // A write held for approval moved nothing, so the row is still where the route says.\n if (relocatedContext && !readOperationApprovalPending(result)) {\n onSuccess?.(result);\n navigateToPreferredRead({ contextResourceIdentifiers: relocatedContext });\n return;\n }\n if (onSuccess) {\n onSuccess(result);\n return;\n }\n goBackWithinZone();\n }, [announceOutcome, goBackWithinZone, navigateToPreferredRead, onSuccess, tComponent]);\n /*\n * The success a host hands in after its OWN write (the form): whether the row moved is read off the row the write\n * answered, the one input that host has. The form does not read the row back after such a write\n * (`ResourceAutomatedForm`), so the answer is the written row.\n */\n const handleSuccess = useCallback((result: unknown) => settleSuccess(\n result,\n isSingleRowUpdateLike && !readOperationApprovalPending(result)\n ? resolveRouteParentRelocation({\n resourceType,\n contextResourceIdentifiers: contextResourceIdentifiersWithResourceId,\n rowValues: result as Record<string, unknown> | undefined,\n registry,\n })\n : undefined,\n ), [contextResourceIdentifiersWithResourceId, isSingleRowUpdateLike, registry, resourceType, settleSuccess]);\n\n const handleError = useCallback((error: Error) => {\n reportError(error, errorMessage, errorComponent);\n }, [errorComponent, errorMessage, reportError]);\n\n useEffect(() => {\n if (!isSingleRowUpdateLike || currentResourceId || !canonicalReadOperationPathKey) {\n return;\n }\n\n let cancelled = false;\n setIsBootstrapping(true);\n void performCanonicalRMMRead({\n doOperation: doOperationRef.current,\n readOperationPathKey: canonicalReadOperationPathKey,\n contextualParameters,\n parentResourcesRequirements: currentResourceContext.parentResourcesRequirements,\n }).then((row) => {\n if (cancelled) return;\n setBootstrappedRow({\n contextKey: bootstrapContextKey,\n row,\n });\n }).catch((error: unknown) => {\n if (cancelled) return;\n handleError(error instanceof Error ? error : new Error(String(error)));\n }).finally(() => {\n if (!cancelled) {\n setIsBootstrapping(false);\n }\n });\n\n return () => {\n cancelled = true;\n };\n }, [\n bootstrapContextKey,\n canonicalReadOperationPathKey,\n contextualParameters,\n currentResourceContext.parentResourcesRequirements,\n currentResourceId,\n handleError,\n isSingleRowUpdateLike,\n ]);\n\n useEffect(() => {\n if (!rmm || !bootstrappedRow || bootstrappedRow.contextKey !== bootstrapContextKey) {\n return;\n }\n\n if (typeof rmm.getSnapshot === 'function' && rmm.getSnapshot().confirmedData !== null) {\n return;\n }\n\n if (typeof rmm.setInitialState === 'function') {\n const row = bootstrappedRow.row;\n rmm.setInitialState(\n row,\n (row._version as number | undefined) ?? 0,\n row._field_meta as Record<string, FieldMetaEntry> | undefined,\n );\n }\n }, [bootstrapContextKey, bootstrappedRow, rmm]);\n\n const execute = useCallback(async (requestData?: Record<string, unknown>) => {\n setIsExecuting(true);\n try {\n let result: unknown;\n // Decided from the declarations and the body BEFORE sending: a write that takes the row out of the route's parent\n // must not be read back at the address it leaves (#3860), and the response cannot say so once a read-back failed.\n const relocatedContext = isSingleRowUpdateLike\n ? resolveRouteParentRelocation({\n resourceType,\n contextResourceIdentifiers: contextResourceIdentifiersWithResourceId,\n rowValues: rowValuesSetByRequest(requestData, readRequestFieldRowFields(operation)),\n registry,\n })\n : undefined;\n\n if (isSingleRowUpdateLike && (rmm || !acceptsDirectLane)) {\n if (!rmm) {\n throw new MissingRMMRuntimeError({\n surfaceName: 'useOperationDirectExecution',\n resourceType,\n operationIdentifier: String(operation.operationIdentifier),\n });\n }\n\n // No optimistic patch: the body is the OPERATION's input, not a set of resource fields, and a\n // custom operation's input names need not be the row's. The row is read back on success.\n const mutationResult = await rmm.queueMutation({}, {\n type: MutationType.CUSTOM,\n priority: MutationPriority.HIGH,\n source: {\n type: MutationSourceType.CUSTOM,\n subscriberId: `direct-execution:${String(operation.operationIdentifier)}`,\n },\n transportOverride: {\n operationPathKey: ResourcesConfig_OperationPathUtils.createOperationPathKeyFromOperation(operation),\n contextualParameters,\n parentResourcesRequirements: currentResourceContext.parentResourcesRequirements,\n requestData: requestData ?? {},\n // The row's canonical read is addressed under the route's parents; after a move it answers 404 there, and a\n // failed read-back strips the response and schedules recovery reads of the same dead address (#3860).\n readBackOnSuccess: relocatedContext === undefined,\n },\n });\n\n if (!mutationResult.success) {\n throw mutationErrorForReport(mutationResult.error, executionFailedLabel);\n }\n\n result = mutationResult.heldForApproval ?? mutationResult.responseData;\n } else if (isSingleRowUpdateLike) {\n /*\n * No RMM and the direct lane declared, still for ONE row: sent with the parameters this hook resolved, which carry the\n * bootstrapped id when the route had none. `executeCurrentOperation` builds its parameters from the\n * route alone, so from a detail-less context (a singleton, a bulk bar) it would address `{id}`\n * unresolved. With no id at all the operation has no row to act on, and says so instead of sending.\n */\n if (!currentResourceId) {\n throw new Error(`${String(operation.operationIdentifier)} on ${resourceType} has no row to act on: no id on the route and none from its canonical READ.`);\n }\n result = await doOperationRef.current(ResourcesConfig_OperationPathUtils.createOperationPathKeyFromOperation(operation), {\n contextualParameters,\n parentResourcesRequirements: currentResourceContext.parentResourcesRequirements,\n requestData: requestData ?? {},\n });\n } else {\n result = await executeCurrentOperation(requestData);\n }\n\n settleSuccess(result, relocatedContext);\n } catch (error) {\n handleError(error instanceof Error ? error : new Error(executionFailedLabel));\n } finally {\n setIsExecuting(false);\n }\n }, [\n contextualParameters,\n currentResourceContext.parentResourcesRequirements,\n contextResourceIdentifiersWithResourceId,\n executeCurrentOperation,\n handleError,\n settleSuccess,\n acceptsDirectLane,\n isSingleRowUpdateLike,\n currentResourceId,\n operation,\n resourceType,\n rmm,\n executionFailedLabel,\n registry,\n ]);\n\n return {\n execute,\n isExecuting,\n isBootstrapping,\n completeWithSuccess: handleSuccess,\n reportFailure: handleError,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AppRouter.d.ts","sourceRoot":"","sources":["../../../../src/core/runtime/AppRouter.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,MAAM,OAAO,CAAC;AA+rB1B,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EA6S7B,CAAC"}
1
+ {"version":3,"file":"AppRouter.d.ts","sourceRoot":"","sources":["../../../../src/core/runtime/AppRouter.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,MAAM,OAAO,CAAC;AAgtB1B,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EA6S7B,CAAC"}
@@ -34,6 +34,7 @@ import { PublicLayout_LegalNotice } from '../../components/app/PublicLayout_Lega
34
34
  import { RouterErrorBoundary } from '../../core/errors/RouterErrorBoundary.js';
35
35
  import { LoggerFrontendService } from '../../core/monitoring/logger.frontend.service.js';
36
36
  import { NavigationContentType, NavigationSource, NavigationZone } from '../../core/navigation/navigation.schemas.js';
37
+ import { clickKeepsRestoredContentInPrimary } from '../../core/navigation/navigation-controller-internals.js';
37
38
  import { NavigationRequestBridge } from '../../core/navigation/NavigationRequestBridge.js';
38
39
  import { adjacentZoneUsableAtViewport } from '../../core/navigation/zone-collapse.js';
39
40
  import { NavigationUtils } from '../../core/navigation/navigation.utils.js';
@@ -296,11 +297,27 @@ const ResourcePageWrapper = ({ resourceType, operation, PageComponent, routePath
296
297
  const prefersAdjacentZoneForDetail = resourceRelationshipDepth === 0
297
298
  && !!navigationLayout?.zones?.secondary
298
299
  && NavigationUtils.layoutSplitsOperationFromPrimary(navigationLayout, operation, currentBreakpoint);
299
- const preferredNavigationZone = NavigationUtils.resolveResourceTargetZone(resourceRelationshipDepth, {
300
+ const depthPreferredNavigationZone = NavigationUtils.resolveResourceTargetZone(resourceRelationshipDepth, {
300
301
  hasSecondary: !!navigationLayout?.zones?.secondary,
301
302
  hasCompanion: !!navigationLayout?.zones?.companion,
302
303
  prefersAdjacentZoneForDetail,
303
304
  });
305
+ /*
306
+ * A nested record stays in its depth's pane only when a click from its parent's zone would open it there — the
307
+ * same gate `useRouterSync` applies (#3764), so the page props and the restored stack name one zone.
308
+ */
309
+ const preferredNavigationZone = resourceRelationshipDepth >= 1
310
+ && depthPreferredNavigationZone !== NavigationZoneName.PRIMARY
311
+ && clickKeepsRestoredContentInPrimary({
312
+ content: { contentType: NavigationContentType.RESOURCE_OPERATION, resourceContext },
313
+ paneZone: depthPreferredNavigationZone,
314
+ layout: navigationLayout,
315
+ registry,
316
+ viewport: currentBreakpoint,
317
+ contentAreaWidth,
318
+ })
319
+ ? NavigationZoneName.PRIMARY
320
+ : depthPreferredNavigationZone;
304
321
  /*
305
322
  * ─── The VIEWPORT decides here too, for the reason the comment below already gives ─────────────
306
323
  *