@cratis/arc 22.161.0 → 22.162.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commands/Command.ts +14 -4
- package/commands/for_Command/GeneratedCommand.ts +32 -0
- package/commands/for_Command/when_executing/with_a_failed_submission.ts +40 -0
- package/commands/for_Command/when_executing/with_an_edit_during_submission.ts +33 -0
- package/commands/for_Command/when_executing/with_generated_property_accessors.ts +54 -0
- package/commands/for_Command/when_executing/with_submitted_falsy_values.ts +30 -0
- package/commands/for_Command/when_setting_initial_values_from_current_values.ts +28 -0
- package/dist/cjs/commands/Command.d.ts +1 -0
- package/dist/cjs/commands/Command.d.ts.map +1 -1
- package/dist/cjs/commands/Command.js +13 -4
- package/dist/cjs/commands/Command.js.map +1 -1
- package/dist/cjs/queries/QueryInstanceCache.d.ts +1 -0
- package/dist/cjs/queries/QueryInstanceCache.d.ts.map +1 -1
- package/dist/cjs/queries/QueryInstanceCache.js +6 -2
- package/dist/cjs/queries/QueryInstanceCache.js.map +1 -1
- package/dist/esm/commands/Command.d.ts +1 -0
- package/dist/esm/commands/Command.d.ts.map +1 -1
- package/dist/esm/commands/Command.js +13 -4
- package/dist/esm/commands/Command.js.map +1 -1
- package/dist/esm/commands/for_Command/GeneratedCommand.d.ts +15 -0
- package/dist/esm/commands/for_Command/GeneratedCommand.d.ts.map +1 -0
- package/dist/esm/commands/for_Command/GeneratedCommand.js +24 -0
- package/dist/esm/commands/for_Command/GeneratedCommand.js.map +1 -0
- package/dist/esm/commands/for_Command/when_executing/with_a_failed_submission.d.ts +2 -0
- package/dist/esm/commands/for_Command/when_executing/with_a_failed_submission.d.ts.map +1 -0
- package/dist/esm/commands/for_Command/when_executing/with_a_failed_submission.js +34 -0
- package/dist/esm/commands/for_Command/when_executing/with_a_failed_submission.js.map +1 -0
- package/dist/esm/commands/for_Command/when_executing/with_an_edit_during_submission.d.ts +2 -0
- package/dist/esm/commands/for_Command/when_executing/with_an_edit_during_submission.d.ts.map +1 -0
- package/dist/esm/commands/for_Command/when_executing/with_an_edit_during_submission.js +26 -0
- package/dist/esm/commands/for_Command/when_executing/with_an_edit_during_submission.js.map +1 -0
- package/dist/esm/commands/for_Command/when_executing/with_generated_property_accessors.d.ts +2 -0
- package/dist/esm/commands/for_Command/when_executing/with_generated_property_accessors.d.ts.map +1 -0
- package/dist/esm/commands/for_Command/when_executing/with_generated_property_accessors.js +44 -0
- package/dist/esm/commands/for_Command/when_executing/with_generated_property_accessors.js.map +1 -0
- package/dist/esm/commands/for_Command/when_executing/with_submitted_falsy_values.d.ts +2 -0
- package/dist/esm/commands/for_Command/when_executing/with_submitted_falsy_values.d.ts.map +1 -0
- package/dist/esm/commands/for_Command/when_executing/with_submitted_falsy_values.js +24 -0
- package/dist/esm/commands/for_Command/when_executing/with_submitted_falsy_values.js.map +1 -0
- package/dist/esm/commands/for_Command/when_setting_initial_values_from_current_values.d.ts +2 -0
- package/dist/esm/commands/for_Command/when_setting_initial_values_from_current_values.d.ts.map +1 -0
- package/dist/esm/commands/for_Command/when_setting_initial_values_from_current_values.js +24 -0
- package/dist/esm/commands/for_Command/when_setting_initial_values_from_current_values.js.map +1 -0
- package/dist/esm/queries/QueryInstanceCache.d.ts +1 -0
- package/dist/esm/queries/QueryInstanceCache.d.ts.map +1 -1
- package/dist/esm/queries/QueryInstanceCache.js +6 -2
- package/dist/esm/queries/QueryInstanceCache.js.map +1 -1
- package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_changed_metadata.d.ts +2 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_changed_metadata.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_changed_metadata.js +51 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_changed_metadata.js.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_equivalent_metadata.d.ts +2 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_equivalent_metadata.d.ts.map +1 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_equivalent_metadata.js +27 -0
- package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_equivalent_metadata.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/queries/QueryInstanceCache.ts +17 -4
- package/queries/for_QueryInstanceCache/when_setting_last_result/with_changed_metadata.ts +58 -0
- package/queries/for_QueryInstanceCache/when_setting_last_result/with_equivalent_metadata.ts +39 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_setting_initial_values_from_current_values.js","sourceRoot":"","sources":["../../../../commands/for_Command/when_setting_initial_values_from_current_values.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,KAAK,MAAM,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC;IAC7D,QAAQ,CAAC,kDAAkD,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE;QAC7E,IAAI,OAAoB,CAAC;QAEzB,UAAU,CAAC,GAAG,EAAE;YACZ,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;YAC5B,OAAO,CAAC,gBAAgB,CAAC,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC,CAAC;YACvD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACtB,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;YACpD,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,YAAY,GAAG,KAA0B,CAAC;YACtD,CAAC;YACD,OAAO,CAAC,iCAAiC,EAAE,CAAC;QAChD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;QACxF,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;YAC3C,OAAO,CAAC,YAAY,GAAG,YAAY,CAAC;YACpC,OAAO,CAAC,aAAa,EAAE,CAAC;YACxB,CAAC,OAAO,CAAC,YAAY,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;QACxF,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -25,6 +25,7 @@ export declare class QueryInstanceCache {
|
|
|
25
25
|
getLastResult<TDataType>(key: QueryCacheKey): QueryResultWithState<TDataType> | undefined;
|
|
26
26
|
setLastResult<TDataType>(key: QueryCacheKey, result: QueryResultWithState<TDataType>): void;
|
|
27
27
|
private withReconciledData;
|
|
28
|
+
private hasEquivalentMetadata;
|
|
28
29
|
addListener<TDataType>(key: QueryCacheKey, listener: QueryCacheListener<TDataType>): void;
|
|
29
30
|
removeListener<TDataType>(key: QueryCacheKey, listener: QueryCacheListener<TDataType>): void;
|
|
30
31
|
setTeardown(key: QueryCacheKey, teardown: () => void): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryInstanceCache.d.ts","sourceRoot":"","sources":["../../../queries/QueryInstanceCache.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EACR,gBAAgB,EAEnB,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"QueryInstanceCache.d.ts","sourceRoot":"","sources":["../../../queries/QueryInstanceCache.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EACR,gBAAgB,EAEnB,MAAM,yCAAyC,CAAC;AAOjD,MAAM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AUD,OAAO,CAAC,kBAAkB;IA0B1B,OAAO,CAAC,qBAAqB;IAmB7B,WAAW,CAAC,SAAS,EACjB,GAAG,EAAE,aAAa,EAClB,QAAQ,EAAE,kBAAkB,CAAC,SAAS,CAAC,GACxC,IAAI,CAMN;IAQD,cAAc,CAAC,SAAS,EACpB,GAAG,EAAE,aAAa,EAClB,QAAQ,EAAE,kBAAkB,CAAC,SAAS,CAAC,GACxC,IAAI,CAMN;IAQD,WAAW,CAAC,GAAG,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAO1D;IAOD,YAAY,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAExC;IAUD,OAAO,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAuBhC;IAOD,GAAG,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAE/B;IAYD,wBAAwB,IAAI,IAAI,CAW/B;IAOD,OAAO,IAAI,IAAI,CAad;IAWD,YAAY,IAAI,IAAI,CASnB;IAQD,oBAAoB,IAAI,IAAI,CAK3B;IAMD,sBAAsB,IAAI,gBAAgB,CAwCzC;CACJ"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { QueryResultWithState } from './QueryResultWithState.js';
|
|
2
2
|
import { reconcileQueryData } from './reconcileQueryData.js';
|
|
3
|
+
import { deepEqual } from '../deepEqual.js';
|
|
3
4
|
|
|
4
5
|
// Copyright (c) Cratis. All rights reserved.
|
|
5
6
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
@@ -110,9 +111,9 @@ import { reconcileQueryData } from './reconcileQueryData.js';
|
|
|
110
111
|
const reconciled = previousResult === undefined ? result : this.withReconciledData(previousResult, result);
|
|
111
112
|
entry.lastResult = reconciled;
|
|
112
113
|
// Reconciliation returns the previous data reference when nothing changed, so identity is
|
|
113
|
-
// enough to detect it. Data
|
|
114
|
+
// enough to detect it. Data and result metadata affect what the user sees; changeSet is
|
|
114
115
|
// ephemeral and does not independently require a notification.
|
|
115
|
-
if (previousResult !== undefined && previousResult.
|
|
116
|
+
if (previousResult !== undefined && previousResult.data === reconciled.data && this.hasEquivalentMetadata(previousResult, reconciled)) {
|
|
116
117
|
return;
|
|
117
118
|
}
|
|
118
119
|
for (const listener of entry.listeners){
|
|
@@ -133,6 +134,9 @@ import { reconcileQueryData } from './reconcileQueryData.js';
|
|
|
133
134
|
}
|
|
134
135
|
return new QueryResultWithState(reconciledData, next.paging, next.isSuccess, next.isAuthorized, next.isValid, next.validationResults, next.hasExceptions, next.exceptionMessages, next.exceptionStackTrace, next.isPerforming, next.changeSet, next.isReady);
|
|
135
136
|
}
|
|
137
|
+
hasEquivalentMetadata(result, previous) {
|
|
138
|
+
return result.isPerforming === previous.isPerforming && result.isSuccess === previous.isSuccess && result.isReady === previous.isReady && result.isAuthorized === previous.isAuthorized && result.isValid === previous.isValid && result.hasExceptions === previous.hasExceptions && result.exceptionStackTrace === previous.exceptionStackTrace && deepEqual(result.paging, previous.paging) && deepEqual(result.exceptionMessages, previous.exceptionMessages) && deepEqual(result.validationResults, previous.validationResults);
|
|
139
|
+
}
|
|
136
140
|
/**
|
|
137
141
|
* Registers a listener that is invoked whenever the cached result for the given key changes.
|
|
138
142
|
* @template TDataType The type of data returned by the query.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryInstanceCache.js","sources":["../../../queries/QueryInstanceCache.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { QueryResultWithState } from './QueryResultWithState.js';\nimport type {\n CacheDiagnostics,\n CacheEntryDiagnostics,\n} from './ObservableQueryDiagnosticsSnapshot.js';\nimport { reconcileQueryData } from './reconcileQueryData.js';\n\n/**\n * Represents a key that uniquely identifies a query instance in the cache, based on the query type name and its serialized arguments.\n */\nexport type QueryCacheKey = string;\n\n/**\n * Callback invoked when the cached result for an entry changes.\n */\nexport type QueryCacheListener<TDataType> = (\n result: QueryResultWithState<TDataType>,\n) => void;\n\n/**\n * Represents a single entry in the {@link QueryInstanceCache}.\n * @template TDataType The type of data returned by the query.\n */\nexport interface QueryCacheEntry<TDataType> {\n /**\n * The cached query instance.\n */\n readonly instance: unknown;\n\n /**\n * The last result received from the query, if any.\n */\n lastResult?: QueryResultWithState<TDataType>;\n\n /**\n * The number of active subscribers holding a reference to this entry.\n */\n subscriberCount: number;\n\n /**\n * Set of listener callbacks that are notified when {@link lastResult} changes.\n */\n readonly listeners: Set<QueryCacheListener<TDataType>>;\n\n /**\n * Cleanup function returned by the first subscriber that starts the query connection.\n * Called when the last subscriber releases the entry.\n */\n teardown?: () => void;\n\n /**\n * Whether an active subscription has been established for this entry.\n */\n subscribed: boolean;\n\n /**\n * Timer handle for deferred cleanup. Allows React StrictMode re-mounts (in any build\n * environment) to cancel the pending teardown so the connection is reused instead of\n * torn down and recreated.\n */\n pendingCleanup?: ReturnType<typeof setTimeout>;\n}\n\n/**\n * Provides a cache for query instances, keyed by query type and serialized arguments.\n *\n * Two callers requesting the same query type with identical arguments receive the same\n * cached instance and immediately see the last known result — without an additional\n * round trip to the server. When the last subscriber releases its reference the entry\n * is evicted.\n */\nexport class QueryInstanceCache {\n private readonly _entries = new Map<QueryCacheKey, QueryCacheEntry<unknown>>();\n private _pendingDispose?: ReturnType<typeof setTimeout>;\n\n /**\n * Initializes a new instance of {@link QueryInstanceCache}.\n * @param retentionMs How long in milliseconds to keep a cache entry alive after the last\n * subscriber releases it before evicting the subscription and cached data. A non-zero\n * value lets users navigate away and back without losing cached data. Defaults to\n * 30 000 ms. Pass 0 for immediate eviction.\n */\n constructor(private readonly _retentionMs: number = 30_000) {}\n\n /**\n * Builds the cache key for a query.\n * @param queryTypeName The stable type name for the query. Use the instance's `queryName`\n * (a hardcoded fully-qualified string in generated proxies) rather than {@link Function.name},\n * which is unstable under minification.\n * @param args Optional arguments supplied to the query.\n * @returns A stable string key.\n */\n buildKey(queryTypeName: string, args?: object): QueryCacheKey {\n if (!args || Object.keys(args).length === 0) {\n return `${queryTypeName}::`;\n }\n\n const sorted = Object.keys(args)\n .sort()\n .reduce<Record<string, unknown>>((accumulator, key) => {\n accumulator[key] = (args as Record<string, unknown>)[key];\n return accumulator;\n }, {});\n\n return `${queryTypeName}::${JSON.stringify(sorted)}`;\n }\n\n /**\n * Returns a cached instance for the given key, or creates a new one using the provided factory.\n * The subscriber count of the entry is incremented.\n * @template TInstance The type of the query instance.\n * @param key The cache key produced by {@link buildKey}.\n * @param factory A zero-argument factory that creates a fresh query instance when one is not yet cached.\n * @returns The cached (or newly created) instance and whether it was newly created.\n */\n getOrCreate<TInstance>(\n key: QueryCacheKey,\n factory: () => TInstance,\n ): { instance: TInstance; isNew: boolean } {\n if (!this._entries.has(key)) {\n const entry: QueryCacheEntry<unknown> = {\n instance: factory(),\n lastResult: undefined,\n subscriberCount: 0,\n listeners: new Set(),\n subscribed: false,\n };\n\n this._entries.set(key, entry);\n return { instance: entry.instance as TInstance, isNew: true };\n }\n\n const entry = this._entries.get(key)!;\n return { instance: entry.instance as TInstance, isNew: false };\n }\n\n /**\n * Increments the active subscriber count for the given key.\n * If a deferred cleanup was pending (from a recent {@link release}),\n * it is cancelled so the existing subscription is reused.\n * Call from `useEffect` setup to pair with {@link release} in the cleanup.\n * @param key The cache key produced by {@link buildKey}.\n */\n acquire(key: QueryCacheKey): void {\n const entry = this._entries.get(key);\n\n if (entry) {\n if (entry.pendingCleanup !== undefined) {\n clearTimeout(entry.pendingCleanup);\n entry.pendingCleanup = undefined;\n }\n\n entry.subscriberCount++;\n }\n }\n\n /**\n * Returns the last cached result for the given key, or `undefined` if no result has been stored yet.\n * @template TDataType The type of data returned by the query.\n * @param key The cache key produced by {@link buildKey}.\n * @returns The last {@link QueryResultWithState}, or `undefined`.\n */\n getLastResult<TDataType>(\n key: QueryCacheKey,\n ): QueryResultWithState<TDataType> | undefined {\n return this._entries.get(key)?.lastResult as\n | QueryResultWithState<TDataType>\n | undefined;\n }\n\n /**\n * Stores the most recent result for the given key and notifies all registered listeners.\n * @template TDataType The type of data returned by the query.\n * @param key The cache key produced by {@link buildKey}.\n * @param result The result to store.\n */\n setLastResult<TDataType>(\n key: QueryCacheKey,\n result: QueryResultWithState<TDataType>,\n ): void {\n const entry = this._entries.get(key);\n\n if (!entry) {\n return;\n }\n\n const previousResult = entry.lastResult as\n | QueryResultWithState<TDataType>\n | undefined;\n\n // Reconcile the incoming payload against the one already held so items that did not actually\n // change keep their previous references. A full snapshot — which is what the server re-sends\n // whenever a subscription is re-established — otherwise arrives as all-new references and\n // makes every consumer treat every item as changed.\n const reconciled =\n previousResult === undefined\n ? result\n : this.withReconciledData(previousResult, result);\n\n entry.lastResult = reconciled as QueryResultWithState<unknown>;\n\n // Reconciliation returns the previous data reference when nothing changed, so identity is\n // enough to detect it. Data, success, and readiness affect what the user sees; changeSet is\n // ephemeral and does not independently require a notification.\n if (\n previousResult !== undefined &&\n previousResult.isSuccess === reconciled.isSuccess &&\n previousResult.isReady === reconciled.isReady &&\n previousResult.data === reconciled.data\n ) {\n return;\n }\n\n for (const listener of entry.listeners) {\n (listener as QueryCacheListener<TDataType>)(reconciled);\n }\n }\n\n /**\n * Returns the incoming result with its data reconciled against the previous result, or the\n * incoming result unchanged when reconciliation found nothing to carry over.\n * @template TDataType The type of data returned by the query.\n * @param previous The previously held result.\n * @param next The freshly received result.\n * @returns A result whose data preserves references for everything that did not change.\n */\n private withReconciledData<TDataType>(\n previous: QueryResultWithState<TDataType>,\n next: QueryResultWithState<TDataType>,\n ): QueryResultWithState<TDataType> {\n const reconciledData = reconcileQueryData(previous.data, next.data);\n\n if (reconciledData === next.data) {\n return next;\n }\n\n return new QueryResultWithState<TDataType>(\n reconciledData,\n next.paging,\n next.isSuccess,\n next.isAuthorized,\n next.isValid,\n next.validationResults,\n next.hasExceptions,\n next.exceptionMessages,\n next.exceptionStackTrace,\n next.isPerforming,\n next.changeSet,\n next.isReady,\n );\n }\n\n /**\n * Registers a listener that is invoked whenever the cached result for the given key changes.\n * @template TDataType The type of data returned by the query.\n * @param key The cache key produced by {@link buildKey}.\n * @param listener The callback to register.\n */\n addListener<TDataType>(\n key: QueryCacheKey,\n listener: QueryCacheListener<TDataType>,\n ): void {\n const entry = this._entries.get(key);\n\n if (entry) {\n entry.listeners.add(listener as QueryCacheListener<unknown>);\n }\n }\n\n /**\n * Removes a previously registered listener.\n * @template TDataType The type of data returned by the query.\n * @param key The cache key produced by {@link buildKey}.\n * @param listener The callback to remove.\n */\n removeListener<TDataType>(\n key: QueryCacheKey,\n listener: QueryCacheListener<TDataType>,\n ): void {\n const entry = this._entries.get(key);\n\n if (entry) {\n entry.listeners.delete(listener as QueryCacheListener<unknown>);\n }\n }\n\n /**\n * Stores a teardown function for the given key and marks the entry as subscribed.\n * Called automatically when the last subscriber releases the entry.\n * @param key The cache key produced by {@link buildKey}.\n * @param teardown Cleanup function that disconnects the underlying query subscription.\n */\n setTeardown(key: QueryCacheKey, teardown: () => void): void {\n const entry = this._entries.get(key);\n\n if (entry) {\n entry.teardown = teardown;\n entry.subscribed = true;\n }\n }\n\n /**\n * Returns whether an active subscription exists for the given key.\n * @param key The cache key to check.\n * @returns `true` if a subscription has been established; `false` otherwise.\n */\n isSubscribed(key: QueryCacheKey): boolean {\n return this._entries.get(key)?.subscribed ?? false;\n }\n\n /**\n * Decrements the subscriber count for the given key. When the count reaches zero, both teardown\n * and eviction are deferred by one microtask so that React StrictMode re-mounts — in any build\n * environment — can re-acquire the entry and cancel the cleanup before the timeout fires. This\n * prevents an unnecessary disconnect/reconnect cycle during the synthetic unmount/remount that\n * StrictMode performs.\n * @param key The cache key produced by {@link buildKey}.\n */\n release(key: QueryCacheKey): void {\n const entry = this._entries.get(key);\n\n if (entry) {\n entry.subscriberCount--;\n\n if (entry.subscriberCount <= 0) {\n // Defer both teardown and eviction. React StrictMode re-mounts can cancel by\n // calling acquire() before the timeout fires. A non-zero _retentionMs keeps the\n // entry alive so users navigating back quickly see cached data immediately.\n entry.pendingCleanup = setTimeout(() => {\n const current = this._entries.get(key);\n\n if (current && current.subscriberCount <= 0) {\n current.subscribed = false;\n current.teardown?.();\n current.teardown = undefined;\n current.pendingCleanup = undefined;\n this._entries.delete(key);\n }\n }, this._retentionMs);\n }\n }\n }\n\n /**\n * Returns whether an entry exists for the given key.\n * @param key The cache key to check.\n * @returns `true` if an entry exists; `false` otherwise.\n */\n has(key: QueryCacheKey): boolean {\n return this._entries.has(key);\n }\n\n /**\n * Tears down all active subscriptions and marks every entry as not subscribed,\n * but preserves entries, subscriber counts, and listeners. This allows\n * hooks whose effects re-run afterward to detect that the entry is no longer\n * subscribed and re-establish a fresh connection.\n *\n * Use this when the underlying transport must be replaced (e.g. after an\n * authentication change that requires new WebSocket connections with updated\n * credentials).\n */\n teardownAllSubscriptions(): void {\n for (const [, entry] of this._entries) {\n if (entry.pendingCleanup !== undefined) {\n clearTimeout(entry.pendingCleanup);\n entry.pendingCleanup = undefined;\n }\n\n entry.subscribed = false;\n entry.teardown?.();\n entry.teardown = undefined;\n }\n }\n\n /**\n * Immediately tears down all subscriptions, cancels any pending deferred cleanups,\n * and evicts all entries. Call when the owning component (e.g. the {@link Arc} provider)\n * unmounts permanently so that all query connections are closed synchronously.\n */\n dispose(): void {\n for (const [, entry] of this._entries) {\n if (entry.pendingCleanup !== undefined) {\n clearTimeout(entry.pendingCleanup);\n entry.pendingCleanup = undefined;\n }\n\n entry.subscribed = false;\n entry.teardown?.();\n entry.teardown = undefined;\n }\n\n this._entries.clear();\n }\n\n /**\n * Schedules a deferred {@link dispose} using {@code setTimeout(0)}.\n *\n * This allows React StrictMode re-mounts to call {@link cancelPendingDispose}\n * before the dispose fires, avoiding the destruction of cache entries that child\n * effects are about to re-acquire.\n *\n * If a deferred dispose is already pending, it is replaced.\n */\n deferDispose(): void {\n if (this._pendingDispose !== undefined) {\n clearTimeout(this._pendingDispose);\n }\n\n this._pendingDispose = setTimeout(() => {\n this._pendingDispose = undefined;\n this.dispose();\n }, 0);\n }\n\n /**\n * Cancels a pending deferred dispose scheduled by {@link deferDispose}.\n *\n * Call from the {@code useEffect} setup phase so that a StrictMode re-mount\n * prevents the synthetic unmount's deferred dispose from firing.\n */\n cancelPendingDispose(): void {\n if (this._pendingDispose !== undefined) {\n clearTimeout(this._pendingDispose);\n this._pendingDispose = undefined;\n }\n }\n\n /**\n * Returns a diagnostics snapshot of the current cache state.\n * @returns A {@link CacheDiagnostics} describing all entries.\n */\n getDiagnosticsSnapshot(): CacheDiagnostics {\n const entries: CacheEntryDiagnostics[] = [];\n let totalBytes = 0;\n let unhealthyCount = 0;\n\n for (const [key, entry] of this._entries) {\n const colonIndex = key.indexOf('::');\n const queryName = colonIndex >= 0 ? key.substring(0, colonIndex) : key;\n\n let estimatedBytes = 0;\n try {\n if (entry.lastResult !== undefined) {\n estimatedBytes = JSON.stringify(entry.lastResult).length;\n }\n } catch {\n // Ignore serialization errors\n }\n\n if (entry.subscriberCount > 0 && !entry.subscribed) {\n unhealthyCount++;\n }\n\n totalBytes += estimatedBytes;\n entries.push({\n key,\n queryName,\n subscriberCount: entry.subscriberCount,\n listenerCount: entry.listeners.size,\n subscribed: entry.subscribed,\n hasResult: entry.lastResult !== undefined,\n estimatedBytes,\n });\n }\n\n return {\n healthy: unhealthyCount === 0,\n entryCount: this._entries.size,\n estimatedBytes: totalBytes,\n entries,\n };\n }\n}\n"],"names":["QueryInstanceCache","_entries","Map","_pendingDispose","_retentionMs","buildKey","queryTypeName","args","Object","keys","length","sorted","sort","reduce","accumulator","key","JSON","stringify","getOrCreate","factory","has","entry","instance","lastResult","undefined","subscriberCount","listeners","Set","subscribed","set","isNew","get","acquire","pendingCleanup","clearTimeout","getLastResult","setLastResult","result","previousResult","reconciled","withReconciledData","isSuccess","isReady","data","listener","previous","next","reconciledData","reconcileQueryData","QueryResultWithState","paging","isAuthorized","isValid","validationResults","hasExceptions","exceptionMessages","exceptionStackTrace","isPerforming","changeSet","addListener","add","removeListener","delete","setTeardown","teardown","isSubscribed","release","setTimeout","current","teardownAllSubscriptions","dispose","clear","deferDispose","cancelPendingDispose","getDiagnosticsSnapshot","entries","totalBytes","unhealthyCount","colonIndex","indexOf","queryName","substring","estimatedBytes","push","listenerCount","size","hasResult","healthy","entryCount"],"mappings":";;;AAAA;AACA;AAiEA;;;;;;;AAOC,IACM,MAAMA,kBAAAA,CAAAA;;AACQC,IAAAA,QAAAA,GAAW,IAAIC,GAAAA,EAAAA;IACxBC,eAAAA;AAER;;;;;;AAMC,QACD,WAAA,CAA6BC,YAAAA,GAAuB,MAAM,CAAE;aAA/BA,YAAAA,GAAAA,YAAAA;AAAgC,IAAA;AAE7D;;;;;;;AAOC,QACDC,QAAAA,CAASC,aAAqB,EAAEC,IAAa,EAAiB;QAC1D,IAAI,CAACA,QAAQC,MAAAA,CAAOC,IAAI,CAACF,IAAAA,CAAAA,CAAMG,MAAM,KAAK,CAAA,EAAG;YACzC,OAAO,CAAA,EAAGJ,aAAAA,CAAc,EAAE,CAAC;AAC/B,QAAA;QAEA,MAAMK,MAAAA,GAASH,MAAAA,CAAOC,IAAI,CAACF,IAAAA,CAAAA,CACtBK,IAAI,EAAA,CACJC,MAAM,CAA0B,CAACC,WAAAA,EAAaC,GAAAA,GAAAA;AAC3CD,YAAAA,WAAW,CAACC,GAAAA,CAAI,GAAG,IAAiC,CAACA,GAAAA,CAAI;YACzD,OAAOD,WAAAA;AACX,QAAA,CAAA,EAAG,EAAC,CAAA;AAER,QAAA,OAAO,GAAGR,aAAAA,CAAc,EAAE,EAAEU,IAAAA,CAAKC,SAAS,CAACN,MAAAA,CAAAA,CAAAA,CAAS;AACxD,IAAA;AAEA;;;;;;;AAOC,QACDO,WAAAA,CACIH,GAAkB,EAClBI,OAAwB,EACe;AACvC,QAAA,IAAI,CAAC,IAAI,CAAClB,QAAQ,CAACmB,GAAG,CAACL,GAAAA,CAAAA,EAAM;AACzB,YAAA,MAAMM,KAAAA,GAAkC;gBACpCC,QAAAA,EAAUH,OAAAA,EAAAA;gBACVI,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reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { QueryResultWithState } from './QueryResultWithState.js';\nimport type {\n CacheDiagnostics,\n CacheEntryDiagnostics,\n} from './ObservableQueryDiagnosticsSnapshot.js';\nimport { reconcileQueryData } from './reconcileQueryData.js';\nimport { deepEqual } from '../deepEqual.js';\n\n/**\n * Represents a key that uniquely identifies a query instance in the cache, based on the query type name and its serialized arguments.\n */\nexport type QueryCacheKey = string;\n\n/**\n * Callback invoked when the cached result for an entry changes.\n */\nexport type QueryCacheListener<TDataType> = (\n result: QueryResultWithState<TDataType>,\n) => void;\n\n/**\n * Represents a single entry in the {@link QueryInstanceCache}.\n * @template TDataType The type of data returned by the query.\n */\nexport interface QueryCacheEntry<TDataType> {\n /**\n * The cached query instance.\n */\n readonly instance: unknown;\n\n /**\n * The last result received from the query, if any.\n */\n lastResult?: QueryResultWithState<TDataType>;\n\n /**\n * The number of active subscribers holding a reference to this entry.\n */\n subscriberCount: number;\n\n /**\n * Set of listener callbacks that are notified when {@link lastResult} changes.\n */\n readonly listeners: Set<QueryCacheListener<TDataType>>;\n\n /**\n * Cleanup function returned by the first subscriber that starts the query connection.\n * Called when the last subscriber releases the entry.\n */\n teardown?: () => void;\n\n /**\n * Whether an active subscription has been established for this entry.\n */\n subscribed: boolean;\n\n /**\n * Timer handle for deferred cleanup. Allows React StrictMode re-mounts (in any build\n * environment) to cancel the pending teardown so the connection is reused instead of\n * torn down and recreated.\n */\n pendingCleanup?: ReturnType<typeof setTimeout>;\n}\n\n/**\n * Provides a cache for query instances, keyed by query type and serialized arguments.\n *\n * Two callers requesting the same query type with identical arguments receive the same\n * cached instance and immediately see the last known result — without an additional\n * round trip to the server. When the last subscriber releases its reference the entry\n * is evicted.\n */\nexport class QueryInstanceCache {\n private readonly _entries = new Map<QueryCacheKey, QueryCacheEntry<unknown>>();\n private _pendingDispose?: ReturnType<typeof setTimeout>;\n\n /**\n * Initializes a new instance of {@link QueryInstanceCache}.\n * @param retentionMs How long in milliseconds to keep a cache entry alive after the last\n * subscriber releases it before evicting the subscription and cached data. A non-zero\n * value lets users navigate away and back without losing cached data. Defaults to\n * 30 000 ms. Pass 0 for immediate eviction.\n */\n constructor(private readonly _retentionMs: number = 30_000) {}\n\n /**\n * Builds the cache key for a query.\n * @param queryTypeName The stable type name for the query. Use the instance's `queryName`\n * (a hardcoded fully-qualified string in generated proxies) rather than {@link Function.name},\n * which is unstable under minification.\n * @param args Optional arguments supplied to the query.\n * @returns A stable string key.\n */\n buildKey(queryTypeName: string, args?: object): QueryCacheKey {\n if (!args || Object.keys(args).length === 0) {\n return `${queryTypeName}::`;\n }\n\n const sorted = Object.keys(args)\n .sort()\n .reduce<Record<string, unknown>>((accumulator, key) => {\n accumulator[key] = (args as Record<string, unknown>)[key];\n return accumulator;\n }, {});\n\n return `${queryTypeName}::${JSON.stringify(sorted)}`;\n }\n\n /**\n * Returns a cached instance for the given key, or creates a new one using the provided factory.\n * The subscriber count of the entry is incremented.\n * @template TInstance The type of the query instance.\n * @param key The cache key produced by {@link buildKey}.\n * @param factory A zero-argument factory that creates a fresh query instance when one is not yet cached.\n * @returns The cached (or newly created) instance and whether it was newly created.\n */\n getOrCreate<TInstance>(\n key: QueryCacheKey,\n factory: () => TInstance,\n ): { instance: TInstance; isNew: boolean } {\n if (!this._entries.has(key)) {\n const entry: QueryCacheEntry<unknown> = {\n instance: factory(),\n lastResult: undefined,\n subscriberCount: 0,\n listeners: new Set(),\n subscribed: false,\n };\n\n this._entries.set(key, entry);\n return { instance: entry.instance as TInstance, isNew: true };\n }\n\n const entry = this._entries.get(key)!;\n return { instance: entry.instance as TInstance, isNew: false };\n }\n\n /**\n * Increments the active subscriber count for the given key.\n * If a deferred cleanup was pending (from a recent {@link release}),\n * it is cancelled so the existing subscription is reused.\n * Call from `useEffect` setup to pair with {@link release} in the cleanup.\n * @param key The cache key produced by {@link buildKey}.\n */\n acquire(key: QueryCacheKey): void {\n const entry = this._entries.get(key);\n\n if (entry) {\n if (entry.pendingCleanup !== undefined) {\n clearTimeout(entry.pendingCleanup);\n entry.pendingCleanup = undefined;\n }\n\n entry.subscriberCount++;\n }\n }\n\n /**\n * Returns the last cached result for the given key, or `undefined` if no result has been stored yet.\n * @template TDataType The type of data returned by the query.\n * @param key The cache key produced by {@link buildKey}.\n * @returns The last {@link QueryResultWithState}, or `undefined`.\n */\n getLastResult<TDataType>(\n key: QueryCacheKey,\n ): QueryResultWithState<TDataType> | undefined {\n return this._entries.get(key)?.lastResult as\n | QueryResultWithState<TDataType>\n | undefined;\n }\n\n /**\n * Stores the most recent result for the given key and notifies all registered listeners.\n * @template TDataType The type of data returned by the query.\n * @param key The cache key produced by {@link buildKey}.\n * @param result The result to store.\n */\n setLastResult<TDataType>(\n key: QueryCacheKey,\n result: QueryResultWithState<TDataType>,\n ): void {\n const entry = this._entries.get(key);\n\n if (!entry) {\n return;\n }\n\n const previousResult = entry.lastResult as\n | QueryResultWithState<TDataType>\n | undefined;\n\n // Reconcile the incoming payload against the one already held so items that did not actually\n // change keep their previous references. A full snapshot — which is what the server re-sends\n // whenever a subscription is re-established — otherwise arrives as all-new references and\n // makes every consumer treat every item as changed.\n const reconciled =\n previousResult === undefined\n ? result\n : this.withReconciledData(previousResult, result);\n\n entry.lastResult = reconciled as QueryResultWithState<unknown>;\n\n // Reconciliation returns the previous data reference when nothing changed, so identity is\n // enough to detect it. Data and result metadata affect what the user sees; changeSet is\n // ephemeral and does not independently require a notification.\n if (\n previousResult !== undefined &&\n previousResult.data === reconciled.data &&\n this.hasEquivalentMetadata(previousResult, reconciled)\n ) {\n return;\n }\n\n for (const listener of entry.listeners) {\n (listener as QueryCacheListener<TDataType>)(reconciled);\n }\n }\n\n /**\n * Returns the incoming result with its data reconciled against the previous result, or the\n * incoming result unchanged when reconciliation found nothing to carry over.\n * @template TDataType The type of data returned by the query.\n * @param previous The previously held result.\n * @param next The freshly received result.\n * @returns A result whose data preserves references for everything that did not change.\n */\n private withReconciledData<TDataType>(\n previous: QueryResultWithState<TDataType>,\n next: QueryResultWithState<TDataType>,\n ): QueryResultWithState<TDataType> {\n const reconciledData = reconcileQueryData(previous.data, next.data);\n\n if (reconciledData === next.data) {\n return next;\n }\n\n return new QueryResultWithState<TDataType>(\n reconciledData,\n next.paging,\n next.isSuccess,\n next.isAuthorized,\n next.isValid,\n next.validationResults,\n next.hasExceptions,\n next.exceptionMessages,\n next.exceptionStackTrace,\n next.isPerforming,\n next.changeSet,\n next.isReady,\n );\n }\n\n private hasEquivalentMetadata<TDataType>(result: QueryResultWithState<TDataType>, previous: QueryResultWithState<TDataType>): boolean {\n return result.isPerforming === previous.isPerforming\n && result.isSuccess === previous.isSuccess\n && result.isReady === previous.isReady\n && result.isAuthorized === previous.isAuthorized\n && result.isValid === previous.isValid\n && result.hasExceptions === previous.hasExceptions\n && result.exceptionStackTrace === previous.exceptionStackTrace\n && deepEqual(result.paging, previous.paging)\n && deepEqual(result.exceptionMessages, previous.exceptionMessages)\n && deepEqual(result.validationResults, previous.validationResults);\n }\n\n /**\n * Registers a listener that is invoked whenever the cached result for the given key changes.\n * @template TDataType The type of data returned by the query.\n * @param key The cache key produced by {@link buildKey}.\n * @param listener The callback to register.\n */\n addListener<TDataType>(\n key: QueryCacheKey,\n listener: QueryCacheListener<TDataType>,\n ): void {\n const entry = this._entries.get(key);\n\n if (entry) {\n entry.listeners.add(listener as QueryCacheListener<unknown>);\n }\n }\n\n /**\n * Removes a previously registered listener.\n * @template TDataType The type of data returned by the query.\n * @param key The cache key produced by {@link buildKey}.\n * @param listener The callback to remove.\n */\n removeListener<TDataType>(\n key: QueryCacheKey,\n listener: QueryCacheListener<TDataType>,\n ): void {\n const entry = this._entries.get(key);\n\n if (entry) {\n entry.listeners.delete(listener as QueryCacheListener<unknown>);\n }\n }\n\n /**\n * Stores a teardown function for the given key and marks the entry as subscribed.\n * Called automatically when the last subscriber releases the entry.\n * @param key The cache key produced by {@link buildKey}.\n * @param teardown Cleanup function that disconnects the underlying query subscription.\n */\n setTeardown(key: QueryCacheKey, teardown: () => void): void {\n const entry = this._entries.get(key);\n\n if (entry) {\n entry.teardown = teardown;\n entry.subscribed = true;\n }\n }\n\n /**\n * Returns whether an active subscription exists for the given key.\n * @param key The cache key to check.\n * @returns `true` if a subscription has been established; `false` otherwise.\n */\n isSubscribed(key: QueryCacheKey): boolean {\n return this._entries.get(key)?.subscribed ?? false;\n }\n\n /**\n * Decrements the subscriber count for the given key. When the count reaches zero, both teardown\n * and eviction are deferred by one microtask so that React StrictMode re-mounts — in any build\n * environment — can re-acquire the entry and cancel the cleanup before the timeout fires. This\n * prevents an unnecessary disconnect/reconnect cycle during the synthetic unmount/remount that\n * StrictMode performs.\n * @param key The cache key produced by {@link buildKey}.\n */\n release(key: QueryCacheKey): void {\n const entry = this._entries.get(key);\n\n if (entry) {\n entry.subscriberCount--;\n\n if (entry.subscriberCount <= 0) {\n // Defer both teardown and eviction. React StrictMode re-mounts can cancel by\n // calling acquire() before the timeout fires. A non-zero _retentionMs keeps the\n // entry alive so users navigating back quickly see cached data immediately.\n entry.pendingCleanup = setTimeout(() => {\n const current = this._entries.get(key);\n\n if (current && current.subscriberCount <= 0) {\n current.subscribed = false;\n current.teardown?.();\n current.teardown = undefined;\n current.pendingCleanup = undefined;\n this._entries.delete(key);\n }\n }, this._retentionMs);\n }\n }\n }\n\n /**\n * Returns whether an entry exists for the given key.\n * @param key The cache key to check.\n * @returns `true` if an entry exists; `false` otherwise.\n */\n has(key: QueryCacheKey): boolean {\n return this._entries.has(key);\n }\n\n /**\n * Tears down all active subscriptions and marks every entry as not subscribed,\n * but preserves entries, subscriber counts, and listeners. This allows\n * hooks whose effects re-run afterward to detect that the entry is no longer\n * subscribed and re-establish a fresh connection.\n *\n * Use this when the underlying transport must be replaced (e.g. after an\n * authentication change that requires new WebSocket connections with updated\n * credentials).\n */\n teardownAllSubscriptions(): void {\n for (const [, entry] of this._entries) {\n if (entry.pendingCleanup !== undefined) {\n clearTimeout(entry.pendingCleanup);\n entry.pendingCleanup = undefined;\n }\n\n entry.subscribed = false;\n entry.teardown?.();\n entry.teardown = undefined;\n }\n }\n\n /**\n * Immediately tears down all subscriptions, cancels any pending deferred cleanups,\n * and evicts all entries. Call when the owning component (e.g. the {@link Arc} provider)\n * unmounts permanently so that all query connections are closed synchronously.\n */\n dispose(): void {\n for (const [, entry] of this._entries) {\n if (entry.pendingCleanup !== undefined) {\n clearTimeout(entry.pendingCleanup);\n entry.pendingCleanup = undefined;\n }\n\n entry.subscribed = false;\n entry.teardown?.();\n entry.teardown = undefined;\n }\n\n this._entries.clear();\n }\n\n /**\n * Schedules a deferred {@link dispose} using {@code setTimeout(0)}.\n *\n * This allows React StrictMode re-mounts to call {@link cancelPendingDispose}\n * before the dispose fires, avoiding the destruction of cache entries that child\n * effects are about to re-acquire.\n *\n * If a deferred dispose is already pending, it is replaced.\n */\n deferDispose(): void {\n if (this._pendingDispose !== undefined) {\n clearTimeout(this._pendingDispose);\n }\n\n this._pendingDispose = setTimeout(() => {\n this._pendingDispose = undefined;\n this.dispose();\n }, 0);\n }\n\n /**\n * Cancels a pending deferred dispose scheduled by {@link deferDispose}.\n *\n * Call from the {@code useEffect} setup phase so that a StrictMode re-mount\n * prevents the synthetic unmount's deferred dispose from firing.\n */\n cancelPendingDispose(): void {\n if (this._pendingDispose !== undefined) {\n clearTimeout(this._pendingDispose);\n this._pendingDispose = undefined;\n }\n }\n\n /**\n * Returns a diagnostics snapshot of the current cache state.\n * @returns A {@link CacheDiagnostics} describing all entries.\n */\n getDiagnosticsSnapshot(): CacheDiagnostics {\n const entries: CacheEntryDiagnostics[] = [];\n let totalBytes = 0;\n let unhealthyCount = 0;\n\n for (const [key, entry] of this._entries) {\n const colonIndex = key.indexOf('::');\n const queryName = colonIndex >= 0 ? key.substring(0, colonIndex) : key;\n\n let estimatedBytes = 0;\n try {\n if (entry.lastResult !== undefined) {\n estimatedBytes = JSON.stringify(entry.lastResult).length;\n }\n } catch {\n // Ignore serialization errors\n }\n\n if (entry.subscriberCount > 0 && !entry.subscribed) {\n unhealthyCount++;\n }\n\n totalBytes += estimatedBytes;\n entries.push({\n key,\n queryName,\n subscriberCount: entry.subscriberCount,\n listenerCount: entry.listeners.size,\n subscribed: entry.subscribed,\n hasResult: entry.lastResult !== undefined,\n estimatedBytes,\n });\n }\n\n return {\n healthy: unhealthyCount === 0,\n entryCount: this._entries.size,\n estimatedBytes: totalBytes,\n entries,\n };\n }\n}\n"],"names":["QueryInstanceCache","_entries","Map","_pendingDispose","_retentionMs","buildKey","queryTypeName","args","Object","keys","length","sorted","sort","reduce","accumulator","key","JSON","stringify","getOrCreate","factory","has","entry","instance","lastResult","undefined","subscriberCount","listeners","Set","subscribed","set","isNew","get","acquire","pendingCleanup","clearTimeout","getLastResult","setLastResult","result","previousResult","reconciled","withReconciledData","data","hasEquivalentMetadata","listener","previous","next","reconciledData","reconcileQueryData","QueryResultWithState","paging","isSuccess","isAuthorized","isValid","validationResults","hasExceptions","exceptionMessages","exceptionStackTrace","isPerforming","changeSet","isReady","deepEqual","addListener","add","removeListener","delete","setTeardown","teardown","isSubscribed","release","setTimeout","current","teardownAllSubscriptions","dispose","clear","deferDispose","cancelPendingDispose","getDiagnosticsSnapshot","entries","totalBytes","unhealthyCount","colonIndex","indexOf","queryName","substring","estimatedBytes","push","listenerCount","size","hasResult","healthy","entryCount"],"mappings":";;;;AAAA;AACA;AAkEA;;;;;;;AAOC,IACM,MAAMA,kBAAAA,CAAAA;;AACQC,IAAAA,QAAAA,GAAW,IAAIC,GAAAA,EAAAA;IACxBC,eAAAA;AAER;;;;;;AAMC,QACD,WAAA,CAA6BC,YAAAA,GAAuB,MAAM,CAAE;aAA/BA,YAAAA,GAAAA,YAAAA;AAAgC,IAAA;AAE7D;;;;;;;AAOC,QACDC,QAAAA,CAASC,aAAqB,EAAEC,IAAa,EAAiB;QAC1D,IAAI,CAACA,QAAQC,MAAAA,CAAOC,IAAI,CAACF,IAAAA,CAAAA,CAAMG,MAAM,KAAK,CAA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,IAAA;AACJ;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with_changed_metadata.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryInstanceCache/when_setting_last_result/with_changed_metadata.ts"],"names":[],"mappings":""}
|
package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_changed_metadata.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import sinon from 'sinon';
|
|
2
|
+
import { QueryInstanceCache } from '../../QueryInstanceCache.js';
|
|
3
|
+
import { QueryResultWithState } from '../../QueryResultWithState.js';
|
|
4
|
+
import { PagingInfo } from '../../PagingInfo.js';
|
|
5
|
+
import { ValidationResult } from '../../../validation/ValidationResult.js';
|
|
6
|
+
import { ValidationResultSeverity } from '../../../validation/ValidationResultSeverity.js';
|
|
7
|
+
import { ValidationResultReason } from '../../../validation/ValidationResultReason.js';
|
|
8
|
+
const validation = new ValidationResult(ValidationResultSeverity.Error, 'first', ['name'], { limit: 1 });
|
|
9
|
+
const changes = [
|
|
10
|
+
['paging total items', { paging: { ...new PagingInfo(), totalItems: 2 } }],
|
|
11
|
+
['paging total pages', { paging: { ...new PagingInfo(), totalPages: 2 } }],
|
|
12
|
+
['paging page', { paging: { ...new PagingInfo(), page: 1 } }],
|
|
13
|
+
['paging size', { paging: { ...new PagingInfo(), size: 10 } }],
|
|
14
|
+
['authorization', { isAuthorized: false }],
|
|
15
|
+
['validity', { isValid: false }],
|
|
16
|
+
['exception flag', { hasExceptions: true }],
|
|
17
|
+
['exception messages', { exceptionMessages: ['second'] }],
|
|
18
|
+
['exception stack trace', { exceptionStackTrace: 'second stack' }],
|
|
19
|
+
['performing state', { isPerforming: true }],
|
|
20
|
+
['validation message', { validationResults: [{ ...validation, message: 'second' }] }],
|
|
21
|
+
['validation severity', { validationResults: [{ ...validation, severity: ValidationResultSeverity.Warning }] }],
|
|
22
|
+
['validation members', { validationResults: [{ ...validation, members: ['other'] }] }],
|
|
23
|
+
['validation state', { validationResults: [{ ...validation, state: { limit: 2 } }] }],
|
|
24
|
+
['validation reason', { validationResults: [{ ...validation, reason: ValidationResultReason.ConstraintViolation }] }],
|
|
25
|
+
['validation reason detail', { validationResults: [{ ...validation, reasonDetail: 'required' }] }]
|
|
26
|
+
];
|
|
27
|
+
for (const [field, change] of changes) {
|
|
28
|
+
describe(`when setting the last result with changed ${field}`, () => {
|
|
29
|
+
const key = 'MyQuery::';
|
|
30
|
+
let cache;
|
|
31
|
+
let listener;
|
|
32
|
+
let first;
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
cache = new QueryInstanceCache();
|
|
35
|
+
cache.getOrCreate(key, () => ({}));
|
|
36
|
+
first = Object.assign(QueryResultWithState.empty([{ id: 'a' }]), {
|
|
37
|
+
isSuccess: false,
|
|
38
|
+
validationResults: [validation],
|
|
39
|
+
exceptionMessages: ['first']
|
|
40
|
+
});
|
|
41
|
+
cache.setLastResult(key, first);
|
|
42
|
+
listener = sinon.stub();
|
|
43
|
+
cache.addListener(key, listener);
|
|
44
|
+
const next = Object.assign(QueryResultWithState.empty([{ id: 'a' }]), first, { data: [{ id: 'a' }] }, change);
|
|
45
|
+
cache.setLastResult(key, next);
|
|
46
|
+
});
|
|
47
|
+
it('should notify the listener', () => listener.calledOnce.should.be.true);
|
|
48
|
+
it('should preserve unchanged row references', () => cache.getLastResult(key).data[0].should.equal(first.data[0]));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=with_changed_metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with_changed_metadata.js","sourceRoot":"","sources":["../../../../../queries/for_QueryInstanceCache/when_setting_last_result/with_changed_metadata.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,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C,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE;gBAC7D,SAAS,EAAE,KAAK;gBAChB,iBAAiB,EAAE,CAAC,UAAU,CAAC;gBAC/B,iBAAiB,EAAE,CAAC,OAAO,CAAC;aAC/B,CAAC,CAAC;YACH,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YAChC,QAAQ,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;YACxB,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YACjC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;YAC9G,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;QAC3E,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,aAAa,CAAS,GAAG,CAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChI,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with_equivalent_metadata.d.ts","sourceRoot":"","sources":["../../../../../queries/for_QueryInstanceCache/when_setting_last_result/with_equivalent_metadata.ts"],"names":[],"mappings":""}
|
package/dist/esm/queries/for_QueryInstanceCache/when_setting_last_result/with_equivalent_metadata.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import sinon from 'sinon';
|
|
2
|
+
import { QueryInstanceCache } from '../../QueryInstanceCache.js';
|
|
3
|
+
import { QueryResultWithState } from '../../QueryResultWithState.js';
|
|
4
|
+
import { PagingInfo } from '../../PagingInfo.js';
|
|
5
|
+
import { ValidationResult } from '../../../validation/ValidationResult.js';
|
|
6
|
+
import { ValidationResultSeverity } from '../../../validation/ValidationResultSeverity.js';
|
|
7
|
+
for (const changeSetOnly of [false, true]) {
|
|
8
|
+
describe(`when setting the last result with ${changeSetOnly ? 'only a changed change set' : 'equivalent metadata'}`, () => {
|
|
9
|
+
let listener;
|
|
10
|
+
const result = () => new QueryResultWithState([{ id: 'a' }], { ...new PagingInfo(), totalItems: 1, totalPages: 1 }, false, true, false, [new ValidationResult(ValidationResultSeverity.Error, 'invalid', ['name'], { limit: 1 })], true, ['failed'], 'stack', false);
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
const cache = new QueryInstanceCache();
|
|
13
|
+
const key = 'MyQuery::';
|
|
14
|
+
cache.getOrCreate(key, () => ({}));
|
|
15
|
+
cache.setLastResult(key, result());
|
|
16
|
+
listener = sinon.stub();
|
|
17
|
+
cache.addListener(key, listener);
|
|
18
|
+
const next = result();
|
|
19
|
+
if (changeSetOnly) {
|
|
20
|
+
Object.assign(next, { changeSet: { added: [{ id: 'a' }], replaced: [], removed: [] } });
|
|
21
|
+
}
|
|
22
|
+
cache.setLastResult(key, next);
|
|
23
|
+
});
|
|
24
|
+
it('should suppress the notification', () => listener.notCalled.should.be.true);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=with_equivalent_metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with_equivalent_metadata.js","sourceRoot":"","sources":["../../../../../queries/for_QueryInstanceCache/when_setting_last_result/with_equivalent_metadata.ts"],"names":[],"mapp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