@wildo-ai/saas-frontend-lib 1.1.14 → 1.1.16
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/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/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/flows-actors/approval.labels.d.ts.map +1 -1
- package/dist/esm/components/flows-actors/approval.labels.js +3 -0
- package/dist/esm/components/flows-actors/approval.labels.js.map +1 -1
- package/dist/esm/components/flows-actors/task-detail.d.ts +12 -1
- package/dist/esm/components/flows-actors/task-detail.d.ts.map +1 -1
- package/dist/esm/components/flows-actors/task-detail.js +2 -2
- package/dist/esm/components/flows-actors/task-detail.js.map +1 -1
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.d.ts +79 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.d.ts.map +1 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.js +271 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.js.map +1 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.labels.d.ts +3 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.labels.d.ts.map +1 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.labels.js +66 -0
- package/dist/esm/components/settings/AppPage_AgentActivitySettings.labels.js.map +1 -0
- package/dist/esm/components/settings/SettingsHub.d.ts.map +1 -1
- package/dist/esm/components/settings/SettingsHub.js +6 -0
- package/dist/esm/components/settings/SettingsHub.js.map +1 -1
- package/dist/esm/components/views/composite-view/CompositeView.d.ts +6 -0
- package/dist/esm/components/views/composite-view/CompositeView.d.ts.map +1 -1
- package/dist/esm/components/views/composite-view/CompositeView.js +12 -2
- package/dist/esm/components/views/composite-view/CompositeView.js.map +1 -1
- package/dist/esm/components/views/flows-actors-view/ConversationLinkPage.d.ts +57 -0
- package/dist/esm/components/views/flows-actors-view/ConversationLinkPage.d.ts.map +1 -0
- package/dist/esm/components/views/flows-actors-view/ConversationLinkPage.js +136 -0
- package/dist/esm/components/views/flows-actors-view/ConversationLinkPage.js.map +1 -0
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.d.ts +20 -0
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.d.ts.map +1 -1
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.js +139 -22
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.js.map +1 -1
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.labels.d.ts.map +1 -1
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.labels.js +5 -0
- package/dist/esm/components/views/flows-actors-view/FlowsActorsView.labels.js.map +1 -1
- package/dist/esm/components/views/flows-actors-view/held-conversation-selection.d.ts +4 -0
- package/dist/esm/components/views/flows-actors-view/held-conversation-selection.d.ts.map +1 -1
- package/dist/esm/components/views/flows-actors-view/held-conversation-selection.js +19 -0
- package/dist/esm/components/views/flows-actors-view/held-conversation-selection.js.map +1 -1
- package/dist/esm/components/views/flows-actors-view/linked-conversation.context.d.ts +26 -0
- package/dist/esm/components/views/flows-actors-view/linked-conversation.context.d.ts.map +1 -0
- package/dist/esm/components/views/flows-actors-view/linked-conversation.context.js +3 -0
- package/dist/esm/components/views/flows-actors-view/linked-conversation.context.js.map +1 -0
- package/dist/esm/core/components-registry/assert-registry-completeness.frontend.helper.d.ts.map +1 -1
- package/dist/esm/core/components-registry/assert-registry-completeness.frontend.helper.js +1 -0
- package/dist/esm/core/components-registry/assert-registry-completeness.frontend.helper.js.map +1 -1
- package/dist/esm/core/config/composite-view.schemas.d.ts +19 -0
- package/dist/esm/core/config/composite-view.schemas.d.ts.map +1 -1
- package/dist/esm/core/config/composite-view.schemas.js.map +1 -1
- package/dist/esm/core/config/engine-settings-destinations.d.ts.map +1 -1
- package/dist/esm/core/config/engine-settings-destinations.js +23 -0
- package/dist/esm/core/config/engine-settings-destinations.js.map +1 -1
- package/dist/esm/core/config/settings-hub-presentation.frontend.utils.d.ts.map +1 -1
- package/dist/esm/core/config/settings-hub-presentation.frontend.utils.js +3 -0
- package/dist/esm/core/config/settings-hub-presentation.frontend.utils.js.map +1 -1
- package/dist/esm/core/config/settings-hub.frontend.schemas.d.ts +12 -0
- package/dist/esm/core/config/settings-hub.frontend.schemas.d.ts.map +1 -1
- package/dist/esm/core/config/settings-hub.frontend.schemas.js +12 -0
- package/dist/esm/core/config/settings-hub.frontend.schemas.js.map +1 -1
- package/dist/esm/core/events/events.frontend.schemas.d.ts +56 -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/flows-actors/FlowsActorsContext.d.ts +10 -1
- package/dist/esm/core/flows-actors/FlowsActorsContext.d.ts.map +1 -1
- package/dist/esm/core/flows-actors/FlowsActorsContext.js +12 -3
- package/dist/esm/core/flows-actors/FlowsActorsContext.js.map +1 -1
- package/dist/esm/core/flows-actors/conversation-history.model.d.ts +19 -1
- package/dist/esm/core/flows-actors/conversation-history.model.d.ts.map +1 -1
- package/dist/esm/core/flows-actors/conversation-history.model.js +45 -4
- package/dist/esm/core/flows-actors/conversation-history.model.js.map +1 -1
- package/dist/esm/core/monitoring/analytics/AnalyticsContext.d.ts.map +1 -1
- package/dist/esm/core/monitoring/analytics/AnalyticsContext.js +50 -18
- package/dist/esm/core/monitoring/analytics/AnalyticsContext.js.map +1 -1
- package/dist/esm/core/navigation/NavigationContentAreas.d.ts +0 -5
- package/dist/esm/core/navigation/NavigationContentAreas.d.ts.map +1 -1
- package/dist/esm/core/navigation/NavigationContentAreas.js +27 -1
- package/dist/esm/core/navigation/NavigationContentAreas.js.map +1 -1
- package/dist/esm/core/navigation/navigation.schemas.d.ts +20 -0
- package/dist/esm/core/navigation/navigation.schemas.d.ts.map +1 -1
- package/dist/esm/core/navigation/navigation.schemas.js +4 -0
- package/dist/esm/core/navigation/navigation.schemas.js.map +1 -1
- package/dist/esm/core/navigation/useNavigationRouterSync.d.ts.map +1 -1
- package/dist/esm/core/navigation/useNavigationRouterSync.js +5 -1
- package/dist/esm/core/navigation/useNavigationRouterSync.js.map +1 -1
- package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.d.ts +20 -1
- package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.d.ts.map +1 -1
- package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.js +25 -0
- package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.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/resources-repository.frontend.service.d.ts.map +1 -1
- package/dist/esm/core/resources/resources-repository.frontend.service.js +2 -0
- package/dist/esm/core/resources/resources-repository.frontend.service.js.map +1 -1
- package/dist/esm/core/runtime/AppRouter.d.ts.map +1 -1
- package/dist/esm/core/runtime/AppRouter.js +2 -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/runtime/routes.frontend.definitions.d.ts +6 -0
- package/dist/esm/core/runtime/routes.frontend.definitions.d.ts.map +1 -1
- package/dist/esm/core/runtime/routes.frontend.definitions.js +7 -1
- package/dist/esm/core/runtime/routes.frontend.definitions.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 +35 -11
- 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/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 +6 -6
|
@@ -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,MA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AC,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,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,G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AAE,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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources-repository.frontend.service.d.ts","sourceRoot":"","sources":["../../../../src/core/resources/resources-repository.frontend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,sBAAsB,EAAE,MAAM,sEAAsE,CAAC;AAC9G,OAAO,EAAE,gCAAgC,EAAE,MAAM,gFAAgF,CAAC;AAOlI,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+DAA+D,CAAC;AAKxG,OAAO,EAGL,2CAA2C,EAE3C,oBAAoB,EAqBU,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAEV,2BAA2B,EAC5B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAGV,yBAAyB,EAE1B,MAAM,+DAA+D,CAAC;AAoZvE,qBAAa,kCAAkC;IAiB3C,OAAO,CAAC,UAAU;IAhBpB,OAAO,CAAC,QAAQ,CAA0C;IAC1D,OAAO,CAAC,aAAa,CAAS;IAC9B;;;OAGG;IACH,OAAO,CAAC,gCAAgC,CAA0C;IAClF;;;;OAIG;IACH,OAAO,CAAC,mCAAmC,CAA8D;IACzG,OAAO,CAAC,mBAAmB,CAAiD;gBAGlE,UAAU,EAAE,sBAAsB;IAG5C;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAa/B;;;;;;;;;OASG;IACU,mBAAmB,CAC9B,8CAA8C,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,2CAA2C,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;KAAE,EAC9H,oCAAoC,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,EAChE,mCAAmC,CAAC,EAAE,oBAAoB,EAAE,EAC5D,qBAAqB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,EAC3C,kBAAkB,CAAC,EAAE,kBAAkB,EACvC,kCAAkC,CAAC,EAAE,2BAA2B,EAAE,GACjE,OAAO,CAAC,IAAI,CAAC;IA0QhB,OAAO,CAAC,2CAA2C;IA4BnD;;;;OAIG;IACH,OAAO,CAAC,2CAA2C;IAYnD;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,cAAc;IAoCtB;;;;;;;;;OASG;IACH,OAAO,CAAC,oCAAoC;IAiB5C,OAAO,CAAC,8BAA8B;IA2BtC;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,mCAAmC;IAuR3C,OAAO,CAAC,qCAAqC;
|
|
1
|
+
{"version":3,"file":"resources-repository.frontend.service.d.ts","sourceRoot":"","sources":["../../../../src/core/resources/resources-repository.frontend.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,sBAAsB,EAAE,MAAM,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,cAAc;IAoCtB;;;;;;;;;OASG;IACH,OAAO,CAAC,oCAAoC;IAiB5C,OAAO,CAAC,8BAA8B;IA2BtC;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,mCAAmC;IAuR3C,OAAO,CAAC,qCAAqC;IAwB7C,OAAO,CAAC,qCAAqC;IA0C7C;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,mCAAmC;IAwJ3C;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,wCAAwC;IAgGhD;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,wBAAwB;IAyChC;;;;;;OAMG;IACH,OAAO,CAAC,gCAAgC;IAgBxC;;OAEG;IACI,oBAAoB,IAAI,yBAAyB;IAUxD;;OAEG;IACI,yBAAyB,IAAI,MAAM,EAAE;IAO5C;;OAEG;IACI,eAAe,IAAI;QACxB,uBAAuB,EAAE,MAAM,EAAE,CAAC;KACnC;IAUD;;;OAGG;IACI,sBAAsB,IAAI,gCAAgC;IAUjE;;;;;;;;;;;;OAYG;IACI,wBAAwB,IAAI,sBAAsB;IAIzD;;;;;;OAMG;IACH,OAAO,CAAC,4BAA4B;IA0CpC;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,kCAAkC;IAwD1C;;;;;;OAMG;IACH,OAAO,CAAC,sCAAsC;CAkC/C"}
|
|
@@ -1024,6 +1024,8 @@ export class ResourcesRepositoryFrontendService {
|
|
|
1024
1024
|
sectionRefs: authoredView.sectionRefs,
|
|
1025
1025
|
viewComponent: authoredView.viewComponent,
|
|
1026
1026
|
icon: authoredView.icon,
|
|
1027
|
+
// The conversations it hosts on its record: how a link to one finds this view (#4043).
|
|
1028
|
+
...(authoredView.conversationSystemRef ? { conversationSystemRef: authoredView.conversationSystemRef } : {}),
|
|
1027
1029
|
}));
|
|
1028
1030
|
}
|
|
1029
1031
|
buildResourceExecutionViewDefinitions(primaryScope, executionViews) {
|