@wildo-ai/saas-frontend-lib 1.1.13 → 1.1.15
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/dist/esm/components/ai-elements/meta/agent-wrappers.d.ts +1 -0
- package/dist/esm/components/ai-elements/meta/agent-wrappers.d.ts.map +1 -1
- package/dist/esm/components/ai-elements/meta/agent-wrappers.js.map +1 -1
- package/dist/esm/components/compliance/EmbeddedSigningFrame.d.ts +38 -0
- package/dist/esm/components/compliance/EmbeddedSigningFrame.d.ts.map +1 -0
- package/dist/esm/components/compliance/EmbeddedSigningFrame.js +106 -0
- package/dist/esm/components/compliance/EmbeddedSigningFrame.js.map +1 -0
- package/dist/esm/components/data-display/DisplayValueDispatcher.d.ts.map +1 -1
- package/dist/esm/components/data-display/DisplayValueDispatcher.js +17 -1
- package/dist/esm/components/data-display/DisplayValueDispatcher.js.map +1 -1
- package/dist/esm/components/data-display/ResourceAutomaticDisplayer.d.ts.map +1 -1
- package/dist/esm/components/data-display/ResourceAutomaticDisplayer.js +22 -0
- package/dist/esm/components/data-display/ResourceAutomaticDisplayer.js.map +1 -1
- package/dist/esm/components/data-display/external-data-provenance/external-data-provenance.frontend.d.ts.map +1 -1
- package/dist/esm/components/data-display/external-data-provenance/external-data-provenance.frontend.js +5 -2
- package/dist/esm/components/data-display/external-data-provenance/external-data-provenance.frontend.js.map +1 -1
- package/dist/esm/components/flows-actors/agent-config.labels.d.ts.map +1 -1
- package/dist/esm/components/flows-actors/agent-config.labels.js +2 -0
- package/dist/esm/components/flows-actors/agent-config.labels.js.map +1 -1
- package/dist/esm/components/flows-actors/approval.d.ts +7 -1
- package/dist/esm/components/flows-actors/approval.d.ts.map +1 -1
- package/dist/esm/components/flows-actors/approval.js +22 -5
- package/dist/esm/components/flows-actors/approval.js.map +1 -1
- package/dist/esm/components/form/automated/ResourceAutomatedForm.d.ts.map +1 -1
- package/dist/esm/components/form/automated/ResourceAutomatedForm.js +20 -1
- package/dist/esm/components/form/automated/ResourceAutomatedForm.js.map +1 -1
- package/dist/esm/components/form/chromes/FormFieldChrome.js +1 -1
- package/dist/esm/components/form/chromes/FormFieldChrome.js.map +1 -1
- package/dist/esm/components/form/chromes/field-control-aria.d.ts +8 -1
- package/dist/esm/components/form/chromes/field-control-aria.d.ts.map +1 -1
- package/dist/esm/components/form/chromes/field-control-aria.js +19 -2
- package/dist/esm/components/form/chromes/field-control-aria.js.map +1 -1
- package/dist/esm/components/form/validation-errors/validate-field-url.frontend.d.ts +5 -0
- package/dist/esm/components/form/validation-errors/validate-field-url.frontend.d.ts.map +1 -1
- package/dist/esm/components/form/validation-errors/validate-field-url.frontend.js +6 -2
- package/dist/esm/components/form/validation-errors/validate-field-url.frontend.js.map +1 -1
- package/dist/esm/components/resources/ResourceCollectionBody_Table.d.ts.map +1 -1
- package/dist/esm/components/resources/ResourceCollectionBody_Table.js +8 -1
- package/dist/esm/components/resources/ResourceCollectionBody_Table.js.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_DangerZone.d.ts.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_DangerZone.js +2 -2
- package/dist/esm/components/resources/ResourceLayout_DangerZone.js.map +1 -1
- package/dist/esm/components/resources/ResourceLayout_RecordSharing.js +2 -2
- package/dist/esm/components/resources/ResourceLayout_RecordSharing.js.map +1 -1
- package/dist/esm/components/resources/ResourceListItemRenderer.d.ts.map +1 -1
- package/dist/esm/components/resources/ResourceListItemRenderer.js +6 -1
- package/dist/esm/components/resources/ResourceListItemRenderer.js.map +1 -1
- package/dist/esm/components/resources/skeleton/DisplayLayout.js +2 -2
- package/dist/esm/components/resources/skeleton/DisplayLayout.js.map +1 -1
- package/dist/esm/components/resources-fields/_presets/resource-reference/ResourceFieldDisplayPreset_ResourceReference_Default.d.ts.map +1 -1
- package/dist/esm/components/resources-fields/_presets/resource-reference/ResourceFieldDisplayPreset_ResourceReference_Default.js +71 -16
- package/dist/esm/components/resources-fields/_presets/resource-reference/ResourceFieldDisplayPreset_ResourceReference_Default.js.map +1 -1
- package/dist/esm/components/sections/surface.d.ts +12 -0
- package/dist/esm/components/sections/surface.d.ts.map +1 -1
- package/dist/esm/components/sections/surface.js +14 -0
- package/dist/esm/components/sections/surface.js.map +1 -1
- package/dist/esm/core/app-shell/shell-motion/shell-motion-origins.d.ts.map +1 -1
- package/dist/esm/core/app-shell/shell-motion/shell-motion-origins.js +3 -2
- package/dist/esm/core/app-shell/shell-motion/shell-motion-origins.js.map +1 -1
- package/dist/esm/core/app-shell/shell-motion/shell-motion-vocabulary.d.ts +15 -0
- package/dist/esm/core/app-shell/shell-motion/shell-motion-vocabulary.d.ts.map +1 -1
- package/dist/esm/core/app-shell/shell-motion/shell-motion-vocabulary.js +29 -0
- package/dist/esm/core/app-shell/shell-motion/shell-motion-vocabulary.js.map +1 -1
- package/dist/esm/core/app-shell/shell-motion/use-shell-motion.d.ts.map +1 -1
- package/dist/esm/core/app-shell/shell-motion/use-shell-motion.js +2 -2
- package/dist/esm/core/app-shell/shell-motion/use-shell-motion.js.map +1 -1
- package/dist/esm/core/branding/useBrandPresentation.d.ts.map +1 -1
- package/dist/esm/core/branding/useBrandPresentation.js +17 -6
- package/dist/esm/core/branding/useBrandPresentation.js.map +1 -1
- package/dist/esm/core/events/events.frontend.schemas.d.ts +40 -0
- package/dist/esm/core/events/events.frontend.schemas.d.ts.map +1 -1
- package/dist/esm/core/events/events.frontend.schemas.js +24 -1
- package/dist/esm/core/events/events.frontend.schemas.js.map +1 -1
- package/dist/esm/core/execution/useExecutionResourceOperationContextBuilder.d.ts.map +1 -1
- package/dist/esm/core/execution/useExecutionResourceOperationContextBuilder.js +11 -1
- package/dist/esm/core/execution/useExecutionResourceOperationContextBuilder.js.map +1 -1
- package/dist/esm/core/i18n/I18nContext.d.ts.map +1 -1
- package/dist/esm/core/i18n/I18nContext.js +8 -2
- package/dist/esm/core/i18n/I18nContext.js.map +1 -1
- package/dist/esm/core/i18n/component-label-resolution.utils.d.ts.map +1 -1
- package/dist/esm/core/i18n/component-label-resolution.utils.js +6 -1
- package/dist/esm/core/i18n/component-label-resolution.utils.js.map +1 -1
- package/dist/esm/core/monitoring/analytics/AnalyticsContext.d.ts +0 -15
- package/dist/esm/core/monitoring/analytics/AnalyticsContext.d.ts.map +1 -1
- package/dist/esm/core/monitoring/analytics/AnalyticsContext.js +102 -5
- package/dist/esm/core/monitoring/analytics/AnalyticsContext.js.map +1 -1
- package/dist/esm/core/monitoring/analytics/AnalyticsEventBridge.d.ts.map +1 -1
- package/dist/esm/core/monitoring/analytics/AnalyticsEventBridge.js +12 -3
- package/dist/esm/core/monitoring/analytics/AnalyticsEventBridge.js.map +1 -1
- package/dist/esm/core/navigation/NavigationContext.d.ts.map +1 -1
- package/dist/esm/core/navigation/NavigationContext.js +60 -17
- package/dist/esm/core/navigation/NavigationContext.js.map +1 -1
- package/dist/esm/core/navigation/launcher-resolution.d.ts +29 -0
- package/dist/esm/core/navigation/launcher-resolution.d.ts.map +1 -1
- package/dist/esm/core/navigation/launcher-resolution.js +31 -0
- package/dist/esm/core/navigation/launcher-resolution.js.map +1 -1
- package/dist/esm/core/navigation/navigation-controller-internals.d.ts +48 -0
- package/dist/esm/core/navigation/navigation-controller-internals.d.ts.map +1 -1
- package/dist/esm/core/navigation/navigation-controller-internals.js +56 -3
- package/dist/esm/core/navigation/navigation-controller-internals.js.map +1 -1
- package/dist/esm/core/navigation/useNavigationRouterSync.d.ts.map +1 -1
- package/dist/esm/core/navigation/useNavigationRouterSync.js +30 -2
- package/dist/esm/core/navigation/useNavigationRouterSync.js.map +1 -1
- package/dist/esm/core/resources/resource-read-cache.frontend.service.d.ts +6 -1
- package/dist/esm/core/resources/resource-read-cache.frontend.service.d.ts.map +1 -1
- package/dist/esm/core/resources/resource-read-cache.frontend.service.js +11 -1
- package/dist/esm/core/resources/resource-read-cache.frontend.service.js.map +1 -1
- package/dist/esm/core/resources/route-parent-relocation.frontend.utils.d.ts +44 -0
- package/dist/esm/core/resources/route-parent-relocation.frontend.utils.d.ts.map +1 -0
- package/dist/esm/core/resources/route-parent-relocation.frontend.utils.js +63 -0
- package/dist/esm/core/resources/route-parent-relocation.frontend.utils.js.map +1 -0
- package/dist/esm/core/resources/useOperationDirectExecution.d.ts.map +1 -1
- package/dist/esm/core/resources/useOperationDirectExecution.js +45 -6
- package/dist/esm/core/resources/useOperationDirectExecution.js.map +1 -1
- package/dist/esm/core/runtime/AppRouter.d.ts.map +1 -1
- package/dist/esm/core/runtime/AppRouter.js +18 -1
- package/dist/esm/core/runtime/AppRouter.js.map +1 -1
- package/dist/esm/core/runtime/ApplicationMainContext.d.ts +1 -1
- package/dist/esm/core/runtime/ApplicationMainContext.d.ts.map +1 -1
- package/dist/esm/core/runtime/ApplicationMainContext.js +12 -3
- package/dist/esm/core/runtime/ApplicationMainContext.js.map +1 -1
- package/dist/esm/core/security/UserOrgsContext.d.ts +6 -1
- package/dist/esm/core/security/UserOrgsContext.d.ts.map +1 -1
- package/dist/esm/core/security/UserOrgsContext.js +87 -10
- package/dist/esm/core/security/UserOrgsContext.js.map +1 -1
- package/dist/esm/core/security/consent-gate.frontend.utils.d.ts +17 -5
- package/dist/esm/core/security/consent-gate.frontend.utils.d.ts.map +1 -1
- package/dist/esm/core/security/consent-gate.frontend.utils.js +16 -7
- package/dist/esm/core/security/consent-gate.frontend.utils.js.map +1 -1
- package/dist/esm/core/security/useConsentGateBehavior.js +1 -1
- package/dist/esm/core/security/useConsentGateBehavior.js.map +1 -1
- package/dist/esm/core/security/useGrantedConsentPurposes.js +1 -1
- package/dist/esm/core/security/useGrantedConsentPurposes.js.map +1 -1
- package/dist/esm/core/ui/inner-control-activation.utils.d.ts +16 -0
- package/dist/esm/core/ui/inner-control-activation.utils.d.ts.map +1 -0
- package/dist/esm/core/ui/inner-control-activation.utils.js +44 -0
- package/dist/esm/core/ui/inner-control-activation.utils.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +8 -8
|
@@ -221,7 +221,12 @@ export class ResourceReadCacheFrontendService {
|
|
|
221
221
|
* without sorting the second phrasing of one question would always miss. Arrays keep their order,
|
|
222
222
|
* because in a filter or a sort an array's order is part of the question.
|
|
223
223
|
*
|
|
224
|
-
*
|
|
224
|
+
* A `Date` renders as its instant. It has no own enumerable keys, so walked as a plain object it was `{}`, and every
|
|
225
|
+
* date window was one key: a calendar or timeline moving to another month was served the first month's rows from
|
|
226
|
+
* this cache, with no request (#3931). Any other object that is not a plain object or an array (a `Set`, a `Map`, a
|
|
227
|
+
* class instance) carries its identity somewhere its own keys do not, so it is refused rather than rendered as `{}`.
|
|
228
|
+
*
|
|
229
|
+
* Returns `null` for anything that cannot be rendered — a cycle, a `BigInt`, a function in a filter, such an object —
|
|
225
230
|
* which every caller reads as "do not cache this", never as an error.
|
|
226
231
|
*/
|
|
227
232
|
export function renderResourceReadCacheKey(operationPathKey, parameters) {
|
|
@@ -237,11 +242,16 @@ export function renderResourceReadCacheKey(operationPathKey, parameters) {
|
|
|
237
242
|
throw new Error('not renderable');
|
|
238
243
|
if (typeof value !== 'object')
|
|
239
244
|
return JSON.stringify(value) ?? 'u';
|
|
245
|
+
if (value instanceof Date)
|
|
246
|
+
return `D${value.getTime()}`;
|
|
240
247
|
if (seen.has(value))
|
|
241
248
|
throw new Error('not renderable');
|
|
242
249
|
seen.add(value);
|
|
243
250
|
if (Array.isArray(value))
|
|
244
251
|
return `[${value.map(render).join(',')}]`;
|
|
252
|
+
const prototype = Object.getPrototypeOf(value);
|
|
253
|
+
if (prototype !== Object.prototype && prototype !== null)
|
|
254
|
+
throw new Error('not renderable');
|
|
245
255
|
const entries = Object.entries(value)
|
|
246
256
|
.filter(([, entryValue]) => entryValue !== undefined)
|
|
247
257
|
.sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-read-cache.frontend.service.js","sourceRoot":"","sources":["../../../../src/core/resources/resource-read-cache.frontend.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6DAA6D,CAAC;AAEpG,MAAM,MAAM,GAAG,qBAAqB,CAAC,SAAS,EAAE,CAAC;AACjD,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;AACzD,MAAM,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;AAEvD;;;;;;;GAOG;AACH,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAqCjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,OAAO,gCAAgC;IACnC,aAAa,GAAkB,IAAI,CAAC;IACpC,cAAc,GAAkB,IAAI,CAAC;IAE5B,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;IACjD,SAAS,GAAyC,IAAI,CAAC;IACvD,OAAO,GAAG,IAAI,CAAC;IAEvB;;;;;;OAMG;IACH;;;;;;;;;;;;;OAaG;IACI,gBAAgB,CAAC,aAA4B;QAClD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAEM,gBAAgB;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACI,iBAAiB,CAAC,cAA6B;QACpD,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAEM,iBAAiB;QACtB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAEM,oBAAoB,CAAC,SAA+C;QACzE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,QAAQ,CAAC,4BAA4B,EAAE,EAAE,YAAY,EAAE,SAAS,KAAK,IAAI,EAAE,CAAC,CAA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,EAAE,CAAC,UAAU,KAAK,SAAS,CAAC;aACpD,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzE,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAC7G,CAAC,CAAC;IAEF,IAAI,CAAC;QACH,OAAO,GAAG,gBAAgB,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;IACrD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import type { ResourceScopeRoomQualifier } from '@wildo-ai/saas-models';\nimport { LoggerFrontendService } from '~wildo-frontend-lib/core/monitoring/logger.frontend.service';\n\nconst logger = LoggerFrontendService.getLogger();\nconst logDebug = logger.debugByType('ResourceReadCache');\nlogger.setDebugTypeLogging('ResourceReadCache', false);\n\n/**\n * A ceiling on how many read results are held.\n *\n * Not a memory bound so much as a staleness bound: every entry is one more thing that has to be\n * invalidated correctly, and an unbounded map makes a missed invalidation permanent. 200 is the same\n * order as `RMM_REGISTRY_MAX_INSTANCES`, and eviction is least-recently-USED so an entry a surface\n * keeps reading survives while a page visited once does not.\n */\nconst MAXIMUM_CACHED_READS = 200;\n\n/**\n * Whether a cached read is currently covered by something that would tell us it went stale.\n *\n * This is the whole safety contract. A cached read may be SERVED only while an authority reports\n * that every room an invalidation for it would arrive through is joined — so a cache entry can never\n * outlive the subscription that keeps it honest.\n *\n * Implemented by the WebSocket layer. Absent — no provider mounted, socket down, subscription\n * refused — nothing is ever served from cache, and the tier degrades to exactly today's behaviour.\n */\nexport interface ResourceReadCoverageAuthority {\n /**\n * Whether an invalidation for this resource in these scopes would currently reach us.\n *\n * Must answer `false` when the transport is down, when any required room is not joined, and when\n * the scope set is EMPTY — a read that belongs to no room has no channel through which it could\n * ever be told it is stale, so it is not cacheable at all.\n */\n covers(resourceType: string, scopes: readonly ResourceScopeRoomQualifier[]): boolean;\n\n /**\n * Asked to start covering a resource in these scopes. Best-effort and asynchronous: the entry it\n * was requested for is not servable until a later `covers` returns `true`.\n */\n requestCoverage(resourceType: string, scopes: readonly ResourceScopeRoomQualifier[]): void;\n}\n\ninterface CachedRead {\n readonly value: unknown;\n readonly resourceType: string;\n readonly scopes: readonly ResourceScopeRoomQualifier[];\n readonly storedAt: number;\n lastReadAt: number;\n}\n\n/**\n * Holds resource READ results between navigations, so a surface that was visited before does not\n * re-fetch what nothing has changed.\n *\n * ## The problem, measured rather than assumed\n *\n * There is no cross-time read cache anywhere in the frontend today — `WildoBackendHttpClient` says\n * so at its in-flight map: *\"IN-FLIGHT sharing only … There is NO cross-time cache / TTL\"*. That\n * same comment records the cost: **one resource-detail mount fires ~9 GETs from 7 independent\n * consumers**, and navigating away and back pays all of them again.\n *\n * ## Why an entry is not servable unless something is watching it\n *\n * The obvious cache — store the response, serve it next time, invalidate on a WebSocket event — has\n * a hole that is silent rather than noisy. Resource events are delivered to ROOMS, and rooms are\n * joined by subscription. An entry whose room nobody has joined receives no invalidation, so it is\n * served confidently forever. Nothing errors, nothing retries; the data is simply wrong.\n *\n * So this tier inverts the default: a stored entry is a candidate, and only a\n * {@link ResourceReadCoverageAuthority} reporting live coverage makes it servable. With no authority\n * the tier stores and serves nothing, which is exactly today's behaviour — slow and correct.\n *\n * ## What it deliberately does NOT do\n *\n * - **No TTL.** A time bound would be a guess about how stale is acceptable, and it would let an\n * uncovered entry be served for the length of the guess. Coverage is a fact; a TTL is a hope.\n * - **No stale-while-revalidate.** Serving a known-stale value while refetching is a reasonable\n * pattern elsewhere; here it would silently reintroduce the wrong-data path this design exists to\n * close, and it cannot satisfy \"a repeat navigation issues no request\" anyway.\n * - **No mutation caching.** Only read-family operations are ever stored.\n */\nexport class ResourceReadCacheFrontendService {\n private applicationId: string | null = null;\n private organizationId: string | null = null;\n\n private readonly entries = new Map<string, CachedRead>();\n private authority: ResourceReadCoverageAuthority | null = null;\n private enabled = true;\n\n /**\n * Install the coverage authority. Called by the WebSocket layer once it can answer.\n *\n * Replacing an authority CLEARS the cache: the new one knows nothing about what the old one was\n * covering, so every held entry is of unknown freshness. Clearing costs a refetch and cannot be\n * wrong, which is the direction this tier always errs in.\n */\n /**\n * The application this session is reading, for the one scope an APPLICATION-scoped resource has.\n *\n * `deriveResourceScopeRoomQualifiers` yields the `app` room only when `applicationId` is present in\n * the context it is handed, and a read's context is built from the URL's contextual parameters —\n * which never carry one, because an application id is ambient rather than addressed. So without\n * this, an APPLICATION-scoped resource derives whatever incidental `org`/`user` rooms its\n * parameters imply and never its own, and a push addressed to `app` reaches nobody (issue #283,\n * measured: 0 frames on a surface whose companion had just published to it).\n *\n * Set by `ResourceReadCacheBridge`, which is a component and can read the app scope; the service is\n * plain and cannot. Null until it does, which is correct — before the scope is mounted there is no\n * application to name.\n */\n public setApplicationId(applicationId: string | null): void {\n this.applicationId = applicationId;\n }\n\n public getApplicationId(): string | null {\n return this.applicationId;\n }\n\n /**\n * The ambient ORGANIZATION id, for the window in which the route has not published one yet.\n *\n * The sibling above exists because an application id is NEVER addressed. This one exists for the\n * opposite reason: an organization id usually IS — `/organizations/:organizationId/...` — and the\n * gap is purely temporal. A read issued before the organization scope hydrates carries no\n * `organizationId` in its contextual parameters, so `deriveResourceScopeRoomQualifiers` emits only\n * the incidental `user` room the generic loop produces and never the resource's own `org` room.\n *\n * That entry is still STORED, because `store()` refuses only an EMPTY scope set — so it is served\n * from a room that no org-scoped invalidation is addressed to. A change another member of the same\n * tenant makes cannot reach it, and `covers()` keeps reporting it servable. Measured as a test\n * failure first (`browser-read-cache`, #1137: the client subscribed `resource:todos:user:<user>`\n * and never `resource:todos:org:<org>`), but the stale read is the part that matters.\n *\n * Refusing to cache instead was REJECTED, and not on taste: the same choice was made for\n * APPLICATION scope and recorded there as \"strictly worse… disabled the tier in exchange for\n * nothing\". Supplying the id the resource is scoped by keeps the tier on AND makes the entry\n * invalidatable, which refusing does not.\n *\n * Set by `ResourceReadCacheBridge`, which is a component and can read the app scope; the service is\n * plain and cannot. Null until it does.\n */\n public setOrganizationId(organizationId: string | null): void {\n this.organizationId = organizationId;\n }\n\n public getOrganizationId(): string | null {\n return this.organizationId;\n }\n\n public setCoverageAuthority(authority: ResourceReadCoverageAuthority | null): void {\n this.authority = authority;\n this.entries.clear();\n logDebug('coverage authority changed', { hasAuthority: authority !== null });\n }\n\n /**\n * Turn the tier off entirely.\n *\n * A door rather than a design. The blast radius here is every generated application on every\n * persistence adapter, so an operator who suspects the cache must be able to remove it from the\n * picture without a rebuild.\n *\n * **The handle is `VITE_RESOURCE_READ_CACHE=off`**, applied by `ResourceReadCacheBridge` — mirroring\n * `COMPANION_INTROSPECTION_CACHE=off` on the companion side, same word and same value so an\n * operator who has met one knows the other. Said explicitly because a door with no handle is worse\n * than no door: this method existed for a while with only a test calling it, while this comment\n * claimed an operator could reach it.\n */\n public setEnabled(enabled: boolean): void {\n this.enabled = enabled;\n if (!enabled) this.entries.clear();\n }\n\n public get size(): number {\n return this.entries.size;\n }\n\n /**\n * The cached value for a read, or `undefined` when there is none that may be served.\n *\n * Coverage is re-checked on every read rather than recorded at store time, because coverage is a\n * property of NOW: a socket that dropped since the entry was stored must stop the entry being\n * served, and only asking at read time can see that.\n */\n public read(key: string): unknown | undefined {\n if (!this.enabled) return undefined;\n const entry = this.entries.get(key);\n if (!entry) return undefined;\n\n if (!this.authority?.covers(entry.resourceType, entry.scopes)) {\n // Not an error and not necessarily stale — simply unprovable. Dropping it keeps the map from\n // filling with entries that can never be served.\n this.entries.delete(key);\n logDebug('entry dropped: no live coverage', { resourceType: entry.resourceType });\n return undefined;\n }\n\n entry.lastReadAt = Date.now();\n return entry.value;\n }\n\n /** Store a read result and ask the authority to start covering it. */\n public store(\n key: string,\n value: unknown,\n resourceType: string,\n scopes: readonly ResourceScopeRoomQualifier[],\n ): void {\n if (!this.enabled || !this.authority) return;\n // A read belonging to no scope has no room through which an invalidation could arrive. Storing\n // it would create an entry that can never be proven fresh — so it is refused at the door rather\n // than kept and never served.\n if (scopes.length === 0) return;\n\n this.authority.requestCoverage(resourceType, scopes);\n\n const now = Date.now();\n this.entries.set(key, { value, resourceType, scopes, storedAt: now, lastReadAt: now });\n this.evictIfOverCapacity();\n }\n\n /**\n * Drop every entry for a resource type.\n *\n * The invalidation the WebSocket layer calls. Deliberately coarse — per-row invalidation would\n * have to know which cached LISTS contain that row, which is a question the cache cannot answer\n * without parsing every stored payload against a shape it does not own.\n */\n public invalidateResourceType(resourceType: string): void {\n let dropped = 0;\n for (const [key, entry] of this.entries) {\n if (entry.resourceType === resourceType) {\n this.entries.delete(key);\n dropped += 1;\n }\n }\n if (dropped > 0) logDebug('invalidated by resource type', { resourceType, dropped });\n }\n\n /**\n * Drop everything.\n *\n * Called on the two transitions that change WHICH rows a read would return without changing the\n * request: an organization switch and a session change. Both happen without a page reload, so\n * nothing else would clear this.\n */\n public clear(): void {\n const dropped = this.entries.size;\n this.entries.clear();\n if (dropped > 0) logDebug('cleared', { dropped });\n }\n\n /** Least-recently-READ eviction, so a surface being used keeps its entry. */\n private evictIfOverCapacity(): void {\n if (this.entries.size <= MAXIMUM_CACHED_READS) return;\n let oldestKey: string | undefined;\n let oldestAt = Number.POSITIVE_INFINITY;\n for (const [key, entry] of this.entries) {\n if (entry.lastReadAt < oldestAt) {\n oldestAt = entry.lastReadAt;\n oldestKey = key;\n }\n }\n if (oldestKey !== undefined) this.entries.delete(oldestKey);\n }\n}\n\n/**\n * Render a read's identity so two structurally equal requests produce one key.\n *\n * Object keys are sorted at every depth: `{a:1,b:2}` and `{b:2,a:1}` are the same request, and\n * without sorting the second phrasing of one question would always miss. Arrays keep their order,\n * because in a filter or a sort an array's order is part of the question.\n *\n * Returns `null` for anything that cannot be rendered — a cycle, a `BigInt`, a function in a filter —\n * which every caller reads as \"do not cache this\", never as an error.\n */\nexport function renderResourceReadCacheKey(\n operationPathKey: string,\n parameters: unknown,\n): string | null {\n const seen = new WeakSet<object>();\n\n const render = (value: unknown): string => {\n if (value === undefined) return 'u';\n if (value === null) return 'n';\n if (typeof value === 'function') throw new Error('not renderable');\n if (typeof value === 'bigint') throw new Error('not renderable');\n if (typeof value !== 'object') return JSON.stringify(value) ?? 'u';\n if (seen.has(value as object)) throw new Error('not renderable');\n seen.add(value as object);\n if (Array.isArray(value)) return `[${value.map(render).join(',')}]`;\n const entries = Object.entries(value as Record<string, unknown>)\n .filter(([, entryValue]) => entryValue !== undefined)\n .sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0));\n return `{${entries.map(([key, entryValue]) => `${JSON.stringify(key)}:${render(entryValue)}`).join(',')}}`;\n };\n\n try {\n return `${operationPathKey}\u0001${render(parameters)}`;\n } catch {\n return null;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"resource-read-cache.frontend.service.js","sourceRoot":"","sources":["../../../../src/core/resources/resource-read-cache.frontend.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6DAA6D,CAAC;AAEpG,MAAM,MAAM,GAAG,qBAAqB,CAAC,SAAS,EAAE,CAAC;AACjD,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;AACzD,MAAM,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;AAEvD;;;;;;;GAOG;AACH,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAqCjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,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C,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzE,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAC7G,CAAC,CAAC;IAEF,IAAI,CAAC;QACH,OAAO,GAAG,gBAAgB,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;IACrD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import type { ResourceScopeRoomQualifier } from '@wildo-ai/saas-models';\nimport { LoggerFrontendService } from '~wildo-frontend-lib/core/monitoring/logger.frontend.service';\n\nconst logger = LoggerFrontendService.getLogger();\nconst logDebug = logger.debugByType('ResourceReadCache');\nlogger.setDebugTypeLogging('ResourceReadCache', false);\n\n/**\n * A ceiling on how many read results are held.\n *\n * Not a memory bound so much as a staleness bound: every entry is one more thing that has to be\n * invalidated correctly, and an unbounded map makes a missed invalidation permanent. 200 is the same\n * order as `RMM_REGISTRY_MAX_INSTANCES`, and eviction is least-recently-USED so an entry a surface\n * keeps reading survives while a page visited once does not.\n */\nconst MAXIMUM_CACHED_READS = 200;\n\n/**\n * Whether a cached read is currently covered by something that would tell us it went stale.\n *\n * This is the whole safety contract. A cached read may be SERVED only while an authority reports\n * that every room an invalidation for it would arrive through is joined — so a cache entry can never\n * outlive the subscription that keeps it honest.\n *\n * Implemented by the WebSocket layer. Absent — no provider mounted, socket down, subscription\n * refused — nothing is ever served from cache, and the tier degrades to exactly today's behaviour.\n */\nexport interface ResourceReadCoverageAuthority {\n /**\n * Whether an invalidation for this resource in these scopes would currently reach us.\n *\n * Must answer `false` when the transport is down, when any required room is not joined, and when\n * the scope set is EMPTY — a read that belongs to no room has no channel through which it could\n * ever be told it is stale, so it is not cacheable at all.\n */\n covers(resourceType: string, scopes: readonly ResourceScopeRoomQualifier[]): boolean;\n\n /**\n * Asked to start covering a resource in these scopes. Best-effort and asynchronous: the entry it\n * was requested for is not servable until a later `covers` returns `true`.\n */\n requestCoverage(resourceType: string, scopes: readonly ResourceScopeRoomQualifier[]): void;\n}\n\ninterface CachedRead {\n readonly value: unknown;\n readonly resourceType: string;\n readonly scopes: readonly ResourceScopeRoomQualifier[];\n readonly storedAt: number;\n lastReadAt: number;\n}\n\n/**\n * Holds resource READ results between navigations, so a surface that was visited before does not\n * re-fetch what nothing has changed.\n *\n * ## The problem, measured rather than assumed\n *\n * There is no cross-time read cache anywhere in the frontend today — `WildoBackendHttpClient` says\n * so at its in-flight map: *\"IN-FLIGHT sharing only … There is NO cross-time cache / TTL\"*. That\n * same comment records the cost: **one resource-detail mount fires ~9 GETs from 7 independent\n * consumers**, and navigating away and back pays all of them again.\n *\n * ## Why an entry is not servable unless something is watching it\n *\n * The obvious cache — store the response, serve it next time, invalidate on a WebSocket event — has\n * a hole that is silent rather than noisy. Resource events are delivered to ROOMS, and rooms are\n * joined by subscription. An entry whose room nobody has joined receives no invalidation, so it is\n * served confidently forever. Nothing errors, nothing retries; the data is simply wrong.\n *\n * So this tier inverts the default: a stored entry is a candidate, and only a\n * {@link ResourceReadCoverageAuthority} reporting live coverage makes it servable. With no authority\n * the tier stores and serves nothing, which is exactly today's behaviour — slow and correct.\n *\n * ## What it deliberately does NOT do\n *\n * - **No TTL.** A time bound would be a guess about how stale is acceptable, and it would let an\n * uncovered entry be served for the length of the guess. Coverage is a fact; a TTL is a hope.\n * - **No stale-while-revalidate.** Serving a known-stale value while refetching is a reasonable\n * pattern elsewhere; here it would silently reintroduce the wrong-data path this design exists to\n * close, and it cannot satisfy \"a repeat navigation issues no request\" anyway.\n * - **No mutation caching.** Only read-family operations are ever stored.\n */\nexport class ResourceReadCacheFrontendService {\n private applicationId: string | null = null;\n private organizationId: string | null = null;\n\n private readonly entries = new Map<string, CachedRead>();\n private authority: ResourceReadCoverageAuthority | null = null;\n private enabled = true;\n\n /**\n * Install the coverage authority. Called by the WebSocket layer once it can answer.\n *\n * Replacing an authority CLEARS the cache: the new one knows nothing about what the old one was\n * covering, so every held entry is of unknown freshness. Clearing costs a refetch and cannot be\n * wrong, which is the direction this tier always errs in.\n */\n /**\n * The application this session is reading, for the one scope an APPLICATION-scoped resource has.\n *\n * `deriveResourceScopeRoomQualifiers` yields the `app` room only when `applicationId` is present in\n * the context it is handed, and a read's context is built from the URL's contextual parameters —\n * which never carry one, because an application id is ambient rather than addressed. So without\n * this, an APPLICATION-scoped resource derives whatever incidental `org`/`user` rooms its\n * parameters imply and never its own, and a push addressed to `app` reaches nobody (issue #283,\n * measured: 0 frames on a surface whose companion had just published to it).\n *\n * Set by `ResourceReadCacheBridge`, which is a component and can read the app scope; the service is\n * plain and cannot. Null until it does, which is correct — before the scope is mounted there is no\n * application to name.\n */\n public setApplicationId(applicationId: string | null): void {\n this.applicationId = applicationId;\n }\n\n public getApplicationId(): string | null {\n return this.applicationId;\n }\n\n /**\n * The ambient ORGANIZATION id, for the window in which the route has not published one yet.\n *\n * The sibling above exists because an application id is NEVER addressed. This one exists for the\n * opposite reason: an organization id usually IS — `/organizations/:organizationId/...` — and the\n * gap is purely temporal. A read issued before the organization scope hydrates carries no\n * `organizationId` in its contextual parameters, so `deriveResourceScopeRoomQualifiers` emits only\n * the incidental `user` room the generic loop produces and never the resource's own `org` room.\n *\n * That entry is still STORED, because `store()` refuses only an EMPTY scope set — so it is served\n * from a room that no org-scoped invalidation is addressed to. A change another member of the same\n * tenant makes cannot reach it, and `covers()` keeps reporting it servable. Measured as a test\n * failure first (`browser-read-cache`, #1137: the client subscribed `resource:todos:user:<user>`\n * and never `resource:todos:org:<org>`), but the stale read is the part that matters.\n *\n * Refusing to cache instead was REJECTED, and not on taste: the same choice was made for\n * APPLICATION scope and recorded there as \"strictly worse… disabled the tier in exchange for\n * nothing\". Supplying the id the resource is scoped by keeps the tier on AND makes the entry\n * invalidatable, which refusing does not.\n *\n * Set by `ResourceReadCacheBridge`, which is a component and can read the app scope; the service is\n * plain and cannot. Null until it does.\n */\n public setOrganizationId(organizationId: string | null): void {\n this.organizationId = organizationId;\n }\n\n public getOrganizationId(): string | null {\n return this.organizationId;\n }\n\n public setCoverageAuthority(authority: ResourceReadCoverageAuthority | null): void {\n this.authority = authority;\n this.entries.clear();\n logDebug('coverage authority changed', { hasAuthority: authority !== null });\n }\n\n /**\n * Turn the tier off entirely.\n *\n * A door rather than a design. The blast radius here is every generated application on every\n * persistence adapter, so an operator who suspects the cache must be able to remove it from the\n * picture without a rebuild.\n *\n * **The handle is `VITE_RESOURCE_READ_CACHE=off`**, applied by `ResourceReadCacheBridge` — mirroring\n * `COMPANION_INTROSPECTION_CACHE=off` on the companion side, same word and same value so an\n * operator who has met one knows the other. Said explicitly because a door with no handle is worse\n * than no door: this method existed for a while with only a test calling it, while this comment\n * claimed an operator could reach it.\n */\n public setEnabled(enabled: boolean): void {\n this.enabled = enabled;\n if (!enabled) this.entries.clear();\n }\n\n public get size(): number {\n return this.entries.size;\n }\n\n /**\n * The cached value for a read, or `undefined` when there is none that may be served.\n *\n * Coverage is re-checked on every read rather than recorded at store time, because coverage is a\n * property of NOW: a socket that dropped since the entry was stored must stop the entry being\n * served, and only asking at read time can see that.\n */\n public read(key: string): unknown | undefined {\n if (!this.enabled) return undefined;\n const entry = this.entries.get(key);\n if (!entry) return undefined;\n\n if (!this.authority?.covers(entry.resourceType, entry.scopes)) {\n // Not an error and not necessarily stale — simply unprovable. Dropping it keeps the map from\n // filling with entries that can never be served.\n this.entries.delete(key);\n logDebug('entry dropped: no live coverage', { resourceType: entry.resourceType });\n return undefined;\n }\n\n entry.lastReadAt = Date.now();\n return entry.value;\n }\n\n /** Store a read result and ask the authority to start covering it. */\n public store(\n key: string,\n value: unknown,\n resourceType: string,\n scopes: readonly ResourceScopeRoomQualifier[],\n ): void {\n if (!this.enabled || !this.authority) return;\n // A read belonging to no scope has no room through which an invalidation could arrive. Storing\n // it would create an entry that can never be proven fresh — so it is refused at the door rather\n // than kept and never served.\n if (scopes.length === 0) return;\n\n this.authority.requestCoverage(resourceType, scopes);\n\n const now = Date.now();\n this.entries.set(key, { value, resourceType, scopes, storedAt: now, lastReadAt: now });\n this.evictIfOverCapacity();\n }\n\n /**\n * Drop every entry for a resource type.\n *\n * The invalidation the WebSocket layer calls. Deliberately coarse — per-row invalidation would\n * have to know which cached LISTS contain that row, which is a question the cache cannot answer\n * without parsing every stored payload against a shape it does not own.\n */\n public invalidateResourceType(resourceType: string): void {\n let dropped = 0;\n for (const [key, entry] of this.entries) {\n if (entry.resourceType === resourceType) {\n this.entries.delete(key);\n dropped += 1;\n }\n }\n if (dropped > 0) logDebug('invalidated by resource type', { resourceType, dropped });\n }\n\n /**\n * Drop everything.\n *\n * Called on the two transitions that change WHICH rows a read would return without changing the\n * request: an organization switch and a session change. Both happen without a page reload, so\n * nothing else would clear this.\n */\n public clear(): void {\n const dropped = this.entries.size;\n this.entries.clear();\n if (dropped > 0) logDebug('cleared', { dropped });\n }\n\n /** Least-recently-READ eviction, so a surface being used keeps its entry. */\n private evictIfOverCapacity(): void {\n if (this.entries.size <= MAXIMUM_CACHED_READS) return;\n let oldestKey: string | undefined;\n let oldestAt = Number.POSITIVE_INFINITY;\n for (const [key, entry] of this.entries) {\n if (entry.lastReadAt < oldestAt) {\n oldestAt = entry.lastReadAt;\n oldestKey = key;\n }\n }\n if (oldestKey !== undefined) this.entries.delete(oldestKey);\n }\n}\n\n/**\n * Render a read's identity so two structurally equal requests produce one key.\n *\n * Object keys are sorted at every depth: `{a:1,b:2}` and `{b:2,a:1}` are the same request, and\n * without sorting the second phrasing of one question would always miss. Arrays keep their order,\n * because in a filter or a sort an array's order is part of the question.\n *\n * A `Date` renders as its instant. It has no own enumerable keys, so walked as a plain object it was `{}`, and every\n * date window was one key: a calendar or timeline moving to another month was served the first month's rows from\n * this cache, with no request (#3931). Any other object that is not a plain object or an array (a `Set`, a `Map`, a\n * class instance) carries its identity somewhere its own keys do not, so it is refused rather than rendered as `{}`.\n *\n * Returns `null` for anything that cannot be rendered — a cycle, a `BigInt`, a function in a filter, such an object —\n * which every caller reads as \"do not cache this\", never as an error.\n */\nexport function renderResourceReadCacheKey(\n operationPathKey: string,\n parameters: unknown,\n): string | null {\n const seen = new WeakSet<object>();\n\n const render = (value: unknown): string => {\n if (value === undefined) return 'u';\n if (value === null) return 'n';\n if (typeof value === 'function') throw new Error('not renderable');\n if (typeof value === 'bigint') throw new Error('not renderable');\n if (typeof value !== 'object') return JSON.stringify(value) ?? 'u';\n if (value instanceof Date) return `D${value.getTime()}`;\n if (seen.has(value as object)) throw new Error('not renderable');\n seen.add(value as object);\n if (Array.isArray(value)) return `[${value.map(render).join(',')}]`;\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) throw new Error('not renderable');\n const entries = Object.entries(value as Record<string, unknown>)\n .filter(([, entryValue]) => entryValue !== undefined)\n .sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0));\n return `{${entries.map(([key, entryValue]) => `${JSON.stringify(key)}:${render(entryValue)}`).join(',')}}`;\n };\n\n try {\n return `${operationPathKey}\u0001${render(parameters)}`;\n } catch {\n return null;\n }\n}\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { FrontendResourceOperationContext, FrontendResourcesRegistry } from '../../core/resources/resources.frontend.schemas';
|
|
2
|
+
type ContextResourceIdentifiers = FrontendResourceOperationContext['contextResourceIdentifiers'];
|
|
3
|
+
type RelocationRegistry = Pick<FrontendResourcesRegistry, 'fieldIdentifierToResourceType'>;
|
|
4
|
+
/**
|
|
5
|
+
* The context the acted-on row has after a single-row write that MOVED it out of a parent the current route is scoped
|
|
6
|
+
* by, or `undefined` when the row is still under every parent the route names (#3860).
|
|
7
|
+
*
|
|
8
|
+
* ## Why a host needs to know
|
|
9
|
+
*
|
|
10
|
+
* A record page is addressed under its parents: a todo opened in the Inbox is `/todo-lists/{inbox}/todos/{todo}`, and
|
|
11
|
+
* every read the page makes goes through that address. A write that reassigns the parent key (`todos.move_to_list`
|
|
12
|
+
* writes `todoListId`) takes the row out of that address, so the backend answers every later read there 404: the
|
|
13
|
+
* mutation manager's read-back, its recovery reads, the page's own refresh. The person saw the move succeed and then
|
|
14
|
+
* "Couldn't load item" on a todo that was where they had put it. The row is still readable, under the parent it joined,
|
|
15
|
+
* and that is where the host must go.
|
|
16
|
+
*
|
|
17
|
+
* ## How a move is recognised
|
|
18
|
+
*
|
|
19
|
+
* `rowValues` are values the row holds after the write: the row a write answered, or the row fields a request body sets
|
|
20
|
+
* ({@link rowValuesSetByRequest}). A row field the registry maps to a resource type the route context names
|
|
21
|
+
* (`fieldIdentifierToResourceType`: `todoListId` → `todoLists`) is that parent's key, and a value other than the route's
|
|
22
|
+
* 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
|
|
23
|
+
* opens cannot disagree about whether the row moved.
|
|
24
|
+
*
|
|
25
|
+
* Only meaningful for a SINGLE-ROW UPDATE-LIKE write; the caller decides that. A create-like operation that names a list
|
|
26
|
+
* (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.
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveRouteParentRelocation(params: {
|
|
29
|
+
resourceType: string;
|
|
30
|
+
contextResourceIdentifiers: ContextResourceIdentifiers | undefined;
|
|
31
|
+
rowValues: Readonly<Record<string, unknown>> | undefined;
|
|
32
|
+
registry: RelocationRegistry;
|
|
33
|
+
}): ContextResourceIdentifiers | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* The row fields a request body sets: each request field under the row field `requestFieldRowFields` names for it
|
|
36
|
+
* (#3465: a move names its target `targetTodoListId` and sets `todoListId`), else under its own name. Known BEFORE the
|
|
37
|
+
* 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
|
|
38
|
+
* failed read-back strips the write's answer, so afterwards the row cannot say where it went.
|
|
39
|
+
*/
|
|
40
|
+
export declare function rowValuesSetByRequest(requestData: Readonly<Record<string, unknown>> | undefined, requestFieldRowFields: Readonly<Record<string, string>> | undefined): Record<string, unknown> | undefined;
|
|
41
|
+
/** The `requestFieldRowFields` an operation declares, read off any of the shapes an operation arrives in. */
|
|
42
|
+
export declare function readRequestFieldRowFields(operation: unknown): Readonly<Record<string, string>> | undefined;
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=route-parent-relocation.frontend.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-parent-relocation.frontend.utils.d.ts","sourceRoot":"","sources":["../../../../src/core/resources/route-parent-relocation.frontend.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gCAAgC,EAAE,yBAAyB,EAAE,MAAM,+DAA+D,CAAC;AAGjJ,KAAK,0BAA0B,GAAG,gCAAgC,CAAC,4BAA4B,CAAC,CAAC;AACjG,KAAK,kBAAkB,GAAG,IAAI,CAAC,yBAAyB,EAAE,+BAA+B,CAAC,CAAC;AAE3F;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE;IACnD,YAAY,EAAE,MAAM,CAAC;IACrB,0BAA0B,EAAE,0BAA0B,GAAG,SAAS,CAAC;IACnE,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IACzD,QAAQ,EAAE,kBAAkB,CAAC;CAC9B,GAAG,0BAA0B,GAAG,SAAS,CAiBzC;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,EAC1D,qBAAqB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,GAClE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAGrC;AAED,6GAA6G;AAC7G,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAE1G"}
|
|
@@ -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":"
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,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,E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a;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":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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;
|
|
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
|
|
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
|
*
|