@conduit-client/command-cache-control 2.0.1 → 2.1.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../utils/dist/index.js","../../src/v1/utils.ts","../../src/v1/cache-control-request-runner.ts","../../src/v1/cache-control-command.ts","../../src/v1/index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2022, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nfunction bfs(start, predicate, getChildren) {\n const queue = [...start];\n const visited = /* @__PURE__ */ new Set([...start]);\n const matches2 = /* @__PURE__ */ new Set();\n while (queue.length) {\n const curr = queue.shift();\n if (predicate(curr)) {\n matches2.add(curr);\n }\n const children = getChildren(curr);\n for (const child of children) {\n if (!visited.has(child)) {\n visited.add(child);\n queue.push(child);\n }\n }\n }\n return matches2;\n}\nfunction lineFormatter(position, message, filePath) {\n return `${message} (${filePath}:${position.line}:${position.column})`;\n}\nclass DefaultFileParserLogger {\n constructor(services, filePath) {\n this.services = services;\n this.filePath = filePath;\n }\n trace(position, message) {\n this.services.logger.trace(this.format(position, message));\n }\n debug(position, message) {\n this.services.logger.debug(this.format(position, message));\n }\n info(position, message) {\n this.services.logger.info(this.format(position, message));\n }\n warn(position, message) {\n this.services.logger.warn(this.format(position, message));\n }\n error(position, message) {\n this.services.logger.error(this.format(position, message));\n }\n format(position, message) {\n return lineFormatter(position, message, this.filePath);\n }\n}\nfunction matches(test, s) {\n if (test === void 0) {\n return false;\n } else if (typeof test === \"string\") {\n return s === test;\n } else if (test instanceof RegExp) {\n return test.test(s);\n } else if (typeof test === \"function\") {\n return test(s);\n }\n return test.some((m) => matches(m, s));\n}\nfunction includes(incexc, s) {\n if (matches(incexc.exclude, s)) {\n return false;\n }\n if (matches(incexc.include, s)) {\n return true;\n }\n if (incexc.include) {\n return false;\n }\n return true;\n}\nconst { create, freeze, keys, entries } = Object;\nconst { hasOwnProperty } = Object.prototype;\nconst { isArray } = Array;\nconst { push, indexOf, slice } = Array.prototype;\nconst { stringify, parse } = JSON;\nconst WeakSetConstructor = WeakSet;\nconst LogLevelMap = {\n TRACE: 4,\n DEBUG: 3,\n INFO: 2,\n WARN: 1,\n ERROR: 0\n};\nclass ConsoleLogger {\n constructor(level = \"WARN\", printer = console.log, formatter = (level2, message) => `${level2}: ${message}`) {\n this.level = level;\n this.printer = printer;\n this.formatter = formatter;\n this.messages = [];\n }\n trace(message) {\n this.log(\"TRACE\", message);\n }\n debug(message) {\n this.log(\"DEBUG\", message);\n }\n info(message) {\n this.log(\"INFO\", message);\n }\n warn(message) {\n this.log(\"WARN\", message);\n }\n error(message) {\n this.log(\"ERROR\", message);\n }\n log(level, message) {\n if (LogLevelMap[level] > LogLevelMap[this.level]) {\n return;\n }\n this.printer(this.formatter(level, message));\n }\n}\nfunction loggerService(level, printer, formatter) {\n return new ConsoleLogger(level, printer, formatter);\n}\nclass Ok {\n constructor(value) {\n this.value = value;\n }\n isOk() {\n return true;\n }\n isErr() {\n return !this.isOk();\n }\n}\nclass Err {\n constructor(error) {\n this.error = error;\n }\n isOk() {\n return false;\n }\n isErr() {\n return !this.isOk();\n }\n}\nconst ok = (value) => new Ok(value);\nconst err = (err2) => new Err(err2);\nclass DataNotFoundError extends Error {\n constructor(message) {\n super(message);\n this.name = \"DataNotFoundError\";\n }\n}\nclass DataIncompleteError extends Error {\n constructor(message, partialData) {\n super(message);\n this.partialData = partialData;\n this.name = \"DataIncompleteError\";\n }\n}\nfunction isDataNotFoundError(error) {\n return error instanceof DataNotFoundError || error.name === \"DataNotFoundError\";\n}\nfunction isDataIncompleteError(error) {\n return error instanceof DataIncompleteError || error.name === \"DataIncompleteError\";\n}\nfunction isCacheHitOrError(value) {\n if (value.isErr() && (isDataIncompleteError(value.error) || isDataNotFoundError(value.error))) {\n return false;\n }\n return true;\n}\nfunction isCacheMiss(value) {\n return !isCacheHitOrError(value);\n}\nfunction isResult(value) {\n return value != null && typeof value === \"object\" && \"isOk\" in value && \"isErr\" in value && typeof value.isOk === \"function\" && typeof value.isErr === \"function\" && (value.isOk() === true && value.isErr() === false && \"value\" in value || value.isOk() === false && value.isErr() === true && \"error\" in value);\n}\nfunction setOverlaps(setA, setB) {\n for (const element of setA) {\n if (setB.has(element)) {\n return true;\n }\n }\n return false;\n}\nfunction setDifference(setA, setB) {\n const differenceSet = /* @__PURE__ */ new Set();\n for (const element of setA) {\n if (!setB.has(element)) {\n differenceSet.add(element);\n }\n }\n return differenceSet;\n}\nfunction addAllToSet(targetSet, sourceSet) {\n for (const element of sourceSet) {\n targetSet.add(element);\n }\n}\nconst toTypeScriptSafeIdentifier = (s) => s.length >= 1 ? s[0].replace(/[^$_\\p{ID_Start}]/u, \"_\") + s.slice(1).replace(/[^$\\u200c\\u200d\\p{ID_Continue}]/gu, \"_\") : \"\";\nfunction isSubscribable(obj) {\n return typeof obj === \"object\" && obj !== null && \"subscribe\" in obj && typeof obj.subscribe === \"function\" && \"refresh\" in obj && typeof obj.refresh === \"function\";\n}\nfunction isSubscribableResult(x) {\n if (!isResult(x)) {\n return false;\n }\n return isSubscribable(x.isOk() ? x.value : x.error);\n}\nfunction buildSubscribableResult(result, subscribe, refresh) {\n if (result.isOk()) {\n return ok({ data: result.value, subscribe, refresh });\n } else {\n return err({ failure: result.error, subscribe, refresh });\n }\n}\nfunction resolvedPromiseLike(result) {\n if (isPromiseLike(result)) {\n return result.then((nextResult) => nextResult);\n }\n return {\n then: (onFulfilled, _onRejected) => {\n try {\n return resolvedPromiseLike(onFulfilled(result));\n } catch (e) {\n if (onFulfilled === void 0) {\n return resolvedPromiseLike(result);\n }\n return rejectedPromiseLike(e);\n }\n }\n };\n}\nfunction rejectedPromiseLike(reason) {\n if (isPromiseLike(reason)) {\n return reason.then((nextResult) => nextResult);\n }\n return {\n then: (_onFulfilled, onRejected) => {\n if (typeof onRejected === \"function\") {\n try {\n return resolvedPromiseLike(onRejected(reason));\n } catch (e) {\n return rejectedPromiseLike(e);\n }\n }\n return rejectedPromiseLike(reason);\n }\n };\n}\nfunction isPromiseLike(x) {\n return typeof (x == null ? void 0 : x.then) === \"function\";\n}\nfunction racesync(values) {\n for (const value of values) {\n let settled = void 0;\n if (isPromiseLike(value)) {\n value.then(\n (_) => {\n settled = value;\n },\n (_) => {\n settled = value;\n }\n );\n } else {\n settled = resolvedPromiseLike(value);\n }\n if (settled !== void 0) {\n return settled;\n }\n }\n return Promise.race(values);\n}\nfunction withResolvers() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\nfunction deepEquals(x, y) {\n if (x === void 0) {\n return y === void 0;\n } else if (x === null) {\n return y === null;\n } else if (y === null) {\n return x === null;\n } else if (isArray(x)) {\n if (!isArray(y) || x.length !== y.length) {\n return false;\n }\n for (let i = 0; i < x.length; ++i) {\n if (!deepEquals(x[i], y[i])) {\n return false;\n }\n }\n return true;\n } else if (typeof x === \"object\") {\n if (typeof y !== \"object\") {\n return false;\n }\n const xkeys = Object.keys(x);\n const ykeys = Object.keys(y);\n if (xkeys.length !== ykeys.length) {\n return false;\n }\n for (let i = 0; i < xkeys.length; ++i) {\n const key = xkeys[i];\n if (!deepEquals(x[key], y[key])) {\n return false;\n }\n }\n return true;\n }\n return x === y;\n}\nfunction stableJSONStringify(node) {\n if (node && node.toJSON && typeof node.toJSON === \"function\") {\n node = node.toJSON();\n }\n if (node === void 0) {\n return;\n }\n if (typeof node === \"number\") {\n return isFinite(node) ? \"\" + node : \"null\";\n }\n if (typeof node !== \"object\") {\n return stringify(node);\n }\n let i;\n let out;\n if (isArray(node)) {\n out = \"[\";\n for (i = 0; i < node.length; i++) {\n if (i) {\n out += \",\";\n }\n out += stableJSONStringify(node[i]) || \"null\";\n }\n return out + \"]\";\n }\n if (node === null) {\n return \"null\";\n }\n const objKeys = keys(node).sort();\n out = \"\";\n for (i = 0; i < objKeys.length; i++) {\n const key = objKeys[i];\n const value = stableJSONStringify(node[key]);\n if (!value) {\n continue;\n }\n if (out) {\n out += \",\";\n }\n out += stringify(key) + \":\" + value;\n }\n return \"{\" + out + \"}\";\n}\nfunction toError(x) {\n if (x instanceof Error) {\n return x;\n }\n return new Error(typeof x === \"string\" ? x : JSON.stringify(x));\n}\nfunction deepCopy(x) {\n const stringified = stringify(x);\n return stringified ? parse(stringified) : void 0;\n}\nfunction readableStreamToAsyncIterable(stream) {\n if (stream.locked) {\n return err(new Error(\"ReadableStream is already locked\"));\n }\n if (Symbol.asyncIterator in stream) {\n return ok(stream);\n }\n const reader = stream.getReader();\n return ok({\n [Symbol.asyncIterator]: () => ({\n next: async () => {\n try {\n const result = await reader.read();\n if (result.done) {\n try {\n reader.releaseLock();\n } catch {\n }\n return { done: true, value: void 0 };\n }\n return {\n done: false,\n value: result.value\n };\n } catch (e) {\n try {\n reader.releaseLock();\n } catch {\n }\n throw e;\n }\n },\n return: async (value) => {\n try {\n await reader.cancel();\n } catch {\n }\n try {\n reader.releaseLock();\n } catch {\n }\n return { done: true, value };\n },\n throw: async (exception) => {\n try {\n await reader.cancel();\n } catch {\n }\n try {\n reader.releaseLock();\n } catch {\n }\n throw exception;\n }\n })\n });\n}\nfunction satisfies(provided, requested) {\n const providedN = provided.split(\".\").map((s) => parseInt(s));\n const requestedN = requested.split(\".\").map((s) => parseInt(s));\n return providedN[0] === requestedN[0] && providedN[1] >= requestedN[1];\n}\nfunction stringIsVersion(s) {\n const versionParts = s.split(\".\");\n return (versionParts.length === 2 || versionParts.length === 3) && versionParts.every((part) => part.match(/^\\d+$/));\n}\nvar HttpStatusCode = /* @__PURE__ */ ((HttpStatusCode2) => {\n HttpStatusCode2[HttpStatusCode2[\"Ok\"] = 200] = \"Ok\";\n HttpStatusCode2[HttpStatusCode2[\"Created\"] = 201] = \"Created\";\n HttpStatusCode2[HttpStatusCode2[\"NoContent\"] = 204] = \"NoContent\";\n HttpStatusCode2[HttpStatusCode2[\"NotModified\"] = 304] = \"NotModified\";\n HttpStatusCode2[HttpStatusCode2[\"BadRequest\"] = 400] = \"BadRequest\";\n HttpStatusCode2[HttpStatusCode2[\"Unauthorized\"] = 401] = \"Unauthorized\";\n HttpStatusCode2[HttpStatusCode2[\"Forbidden\"] = 403] = \"Forbidden\";\n HttpStatusCode2[HttpStatusCode2[\"NotFound\"] = 404] = \"NotFound\";\n HttpStatusCode2[HttpStatusCode2[\"ServerError\"] = 500] = \"ServerError\";\n HttpStatusCode2[HttpStatusCode2[\"GatewayTimeout\"] = 504] = \"GatewayTimeout\";\n return HttpStatusCode2;\n})(HttpStatusCode || {});\nfunction getFetchResponseFromAuraError(err2) {\n if (err2.data !== void 0 && err2.data.statusCode !== void 0) {\n let data = {};\n data = err2.data;\n if (err2.id !== void 0) {\n data.id = err2.id;\n }\n return new FetchResponse(data.statusCode, data);\n }\n return new FetchResponse(500, {\n error: err2.message\n });\n}\nasync function coerceResponseToFetchResponse(response) {\n const { status } = response;\n const responseHeaders = {};\n response.headers.forEach((value, key) => {\n responseHeaders[key] = value;\n });\n let responseBody = null;\n if (status !== 204) {\n const contentType = responseHeaders[\"content-type\"];\n responseBody = contentType && contentType.startsWith(\"application/json\") ? await response.json() : await response.text();\n }\n return new FetchResponse(status, responseBody, responseHeaders);\n}\nfunction getStatusText(status) {\n switch (status) {\n case 200:\n return \"OK\";\n case 201:\n return \"Created\";\n case 304:\n return \"Not Modified\";\n case 400:\n return \"Bad Request\";\n case 404:\n return \"Not Found\";\n case 500:\n return \"Server Error\";\n default:\n return `Unexpected HTTP Status Code: ${status}`;\n }\n}\nclass FetchResponse extends Error {\n constructor(status, body, headers) {\n super();\n this.status = status;\n this.body = body;\n this.headers = headers || {};\n this.ok = status >= 200 && this.status <= 299;\n this.statusText = getStatusText(status);\n }\n}\nconst deeplyFrozen = new WeakSetConstructor();\nfunction deepFreeze(value) {\n if (typeof value !== \"object\" || value === null || deeplyFrozen.has(value)) {\n return;\n }\n deeplyFrozen.add(value);\n if (isArray(value)) {\n for (let i = 0, len = value.length; i < len; i += 1) {\n deepFreeze(value[i]);\n }\n } else {\n const keys$1 = keys(value);\n for (let i = 0, len = keys$1.length; i < len; i += 1) {\n deepFreeze(value[keys$1[i]]);\n }\n }\n freeze(value);\n}\nfunction isScalar(value) {\n return typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\" || value === null || value === void 0;\n}\nfunction isScalarObject(value) {\n return Object.values(value).every((value2) => isScalar(value2));\n}\nfunction isScalarArray(value) {\n return value.every((item) => isScalar(item));\n}\nfunction encodeQueryParam(paramName, value, explode) {\n switch (typeof value) {\n case \"string\":\n return [`${paramName}=${encodeURIComponent(value)}`];\n case \"number\":\n case \"boolean\":\n return [`${paramName}=${value}`];\n case \"object\":\n if (value === null) {\n return [];\n }\n if (isArray(value)) {\n if (!isScalarArray(value)) {\n throw new Error(`Unsupported non-scalar array type for ${paramName}`);\n }\n if (explode) {\n return value.map(\n (item) => `${paramName}=${item ? encodeURIComponent(item) : item}`\n );\n }\n return [\n `${paramName}=${value.map((item) => item ? encodeURIComponent(item) : item).join(\",\")}`\n ];\n }\n if (!isScalarObject(value)) {\n throw new Error(`Unsupported non-scalar object type for ${paramName}`);\n }\n if (explode) {\n return entries(value).map(\n ([key, value2]) => `${key}=${value2 ? encodeURIComponent(value2) : value2}`\n );\n }\n return [\n `${paramName}=${entries(value).flat().map((item) => item ? encodeURIComponent(item) : item).join(\",\")}`\n ];\n default:\n return [];\n }\n}\nclass InternalError extends Error {\n constructor(data) {\n super();\n this.data = data;\n this.type = \"internal\";\n }\n}\nclass UserVisibleError extends Error {\n constructor(data) {\n super();\n this.data = data;\n this.type = \"user-visible\";\n }\n}\nfunction applyDecorators(baseCommand, decorators, options) {\n if (!decorators || decorators.length === 0) {\n return baseCommand;\n }\n return decorators.reduce((command, decorator) => decorator(command, options), baseCommand);\n}\nexport {\n isArray as ArrayIsArray,\n indexOf as ArrayPrototypeIndexOf,\n push as ArrayPrototypePush,\n slice as ArrayPrototypeSlice,\n ConsoleLogger,\n DataIncompleteError,\n DataNotFoundError,\n DefaultFileParserLogger,\n Err,\n FetchResponse,\n HttpStatusCode,\n InternalError,\n parse as JSONParse,\n stringify as JSONStringify,\n LogLevelMap,\n create as ObjectCreate,\n entries as ObjectEntries,\n freeze as ObjectFreeze,\n keys as ObjectKeys,\n hasOwnProperty as ObjectPrototypeHasOwnProperty,\n Ok,\n UserVisibleError,\n WeakSetConstructor,\n addAllToSet,\n applyDecorators,\n bfs,\n buildSubscribableResult,\n coerceResponseToFetchResponse,\n deepCopy,\n deepEquals,\n deepFreeze,\n encodeQueryParam,\n err,\n getFetchResponseFromAuraError,\n includes,\n isCacheHitOrError,\n isCacheMiss,\n isDataIncompleteError,\n isDataNotFoundError,\n isPromiseLike,\n isResult,\n isSubscribable,\n isSubscribableResult,\n lineFormatter,\n loggerService,\n ok,\n racesync,\n readableStreamToAsyncIterable,\n rejectedPromiseLike,\n resolvedPromiseLike,\n satisfies,\n setDifference,\n setOverlaps,\n stableJSONStringify,\n stringIsVersion,\n toError,\n toTypeScriptSafeIdentifier,\n withResolvers\n};\n//# sourceMappingURL=index.js.map\n","import type { Key } from '@conduit-client/service-cache/v1';\n\n// Needs TS 2023+ (esnext) AND node 20+ to remove\nexport function setOverlaps(setA: Set<Key>, setB: Set<Key>): boolean {\n if (setA.size > setB.size) {\n for (const key of setB.keys()) {\n if (setA.has(key)) {\n return true;\n }\n }\n } else {\n for (const key of setA) {\n if (setB.has(key)) {\n return true;\n }\n }\n }\n return false;\n}\n","import { Cache, ReadonlyCache } from '@conduit-client/service-cache/v1';\nimport { Err, err, Ok, ok, Result, SubscribableResult, SyncOrAsync } from '@conduit-client/utils';\n\nexport class CacheControlRequestRunner<ReturnData, NetworkData> {\n returnData: SubscribableResult<ReturnData, Error> | undefined;\n networkData: Ok<NetworkData, Error> | undefined;\n networkError: Err<never, Error> | undefined;\n readFromCacheInternal;\n requestFromNetworkInternal;\n writeToCacheInternal;\n\n constructor(\n readFromCache: (cache: ReadonlyCache) => SyncOrAsync<SubscribableResult<ReturnData, Error>>,\n requestFromNetwork: () => SyncOrAsync<Result<NetworkData, Error>>,\n writeToCache: (\n cache: Cache,\n networkResult: Result<NetworkData, Error>\n ) => SyncOrAsync<Result<void, Error>>\n ) {\n this.readFromCacheInternal = readFromCache;\n this.requestFromNetworkInternal = requestFromNetwork;\n this.writeToCacheInternal = writeToCache;\n }\n\n readFromCache(cache: ReadonlyCache) {\n const resultPromise = this.readFromCacheInternal(cache);\n\n return resultPromise.then((result) => {\n if (result.isErr()) {\n return err(result.error.failure);\n }\n\n this.returnData = result;\n return ok(undefined);\n });\n }\n\n requestFromNetwork() {\n const that = this;\n return (async function* () {\n const result = await that.requestFromNetworkInternal();\n if (result.isErr()) {\n that.networkError = result;\n } else {\n that.networkData = result;\n }\n yield result;\n })();\n }\n\n writeToCache(cache: Cache, networkResult: Result<NetworkData, Error>) {\n return this.writeToCacheInternal(cache, networkResult);\n }\n}\n","import { BaseCommand } from '@conduit-client/command-base/v1';\nimport { type Event, type NamedPubSubService } from '@conduit-client/service-pubsub/v1';\nimport {\n ok,\n err,\n deepEquals,\n resolvedPromiseLike,\n buildSubscribableResult,\n} from '@conduit-client/utils';\nimport type {\n Callback,\n Result,\n Unsubscribe,\n SubscribableResult,\n SyncOrAsync,\n RefreshResult,\n} from '@conduit-client/utils';\nimport type { Cache, Key, ReadonlyCache } from '@conduit-client/service-cache/v1';\nimport type {\n CacheControlStrategyConfig,\n NamedCacheControllerService,\n} from '@conduit-client/service-cache-control/v1';\nimport { InstrumentationAttributes } from '@conduit-client/service-instrumentation/v1';\nimport { setOverlaps } from './utils';\nimport { CacheControlRequestRunner } from './cache-control-request-runner';\n\ntype ExecuteOverrides = {\n now?: number;\n cacheControlConfig?: Omit<CacheControlStrategyConfig, 'now'>;\n};\n\n/**\n * An implementation of BaseCommand that allows for extending abstract cache methods\n *\n * @typeParam Data cache result for read operations\n * @typeParam NetworkResult cache result including network metadata\n * @typeParam ExtraServices additional named services needed by a subclass\n */\nexport abstract class CacheControlCommand<\n ReturnData,\n NetworkData,\n ExtraServices extends object = object,\n> extends BaseCommand<SyncOrAsync<SubscribableResult<ReturnData, Error>>> {\n instantiationTime: number;\n instrumentationAttributes?: InstrumentationAttributes;\n private keysUsed = new Set<Key>();\n private keysUpdated: Set<Key> | undefined = undefined;\n private _isInternalExecution = false;\n\n get isInternalExecution(): boolean {\n return this._isInternalExecution;\n }\n\n /**\n * Creates a new CacheControlCommand instance\n *\n * @param services - Required services including cache controller and optional pub/sub service\n * @param services.cacheController - The cache controller service for managing cache operations\n * @param services.pubSub - Optional pub/sub service for cache invalidation notifications\n * @param services - Additional services specific to the implementation\n */\n constructor(\n protected services: NamedCacheControllerService &\n Partial<NamedPubSubService> &\n ExtraServices\n ) {\n super();\n this.instantiationTime = Date.now() / 1000; // in seconds\n }\n\n /**\n * Executes the cache control command with optional overrides\n *\n * This method orchestrates the cache control flow by:\n * 1. Clearing any existing subscriptions\n * 2. Merging configuration overrides with the base strategy config\n * 3. Building a request runner for cache operations\n * 4. Executing the cache controller with the request runner\n * 5. Handling the result and setting up subscriptions if needed\n *\n * @param overrides - Optional execution overrides including timestamp and cache control config\n * @param overrides.now - Override the current timestamp for cache control calculations\n * @param overrides.cacheControlConfig - Override cache control strategy configuration\n * @returns A subscribable result containing either the cached/network data or an error\n */\n execute(overrides?: ExecuteOverrides): SyncOrAsync<SubscribableResult<ReturnData, Error>> {\n this.keysUpdated = undefined;\n this.unsubscribe();\n\n const mergedCacheControlConfig = mergeCacheControlConfigs(\n this.cacheControlStrategyConfig,\n overrides\n );\n\n const requestRunner = this.buildRequestRunner();\n\n const resultPromise = this.services.cacheController.execute<\n Result<NetworkData, Error>,\n Error\n >(mergedCacheControlConfig, requestRunner, {\n instrumentationAttributes: this.instrumentationAttributes,\n });\n\n return resultPromise.then((result) => {\n return this.handleCacheControllerResult(result, requestRunner).then((result) => {\n // This is our first pass through the Command, so we need to set the lastResult.\n // Subsequent results are kept up to date in rerun()\n if (this.lastResult === undefined) {\n if (result.isErr()) {\n this.lastResult = { type: 'error', error: result.error.failure };\n } else {\n this.lastResult = { type: 'data', data: result.value.data };\n }\n }\n return result;\n });\n });\n }\n\n /**\n * Handles the result from the cache controller and builds the appropriate subscribable result\n *\n * This method processes the cache controller execution result and determines the appropriate\n * response based on network errors, cache errors, and available data. It handles graceful\n * degradation scenarios where network data is available even when cache operations fail.\n *\n * @param result - The result from the cache controller execution\n * @param requestRunner - The request runner containing network data and errors\n * @returns A subscribable result with the appropriate data or error\n */\n handleCacheControllerResult(\n result: Result<void, Error>,\n requestRunner: CacheControlRequestRunner<ReturnData, NetworkData>\n ): SyncOrAsync<SubscribableResult<ReturnData, Error>> {\n const { networkError, networkData, returnData } = requestRunner;\n return this.publishUpdatedKeys().then(() => {\n // First check if there was an error from the network\n if (networkError) {\n return buildSubscribableResult(networkError, this.buildSubscribe(), () =>\n this.refresh()\n );\n }\n\n // Then return other errors from read/write\n if (result.isErr()) {\n // If the result was an error but we got network data, gracefully degrade to returning the\n // network data without caching/subscriptions\n if (networkData) {\n return buildSubscribableResult(networkData, this.buildSubscribe(), () =>\n this.refresh()\n );\n }\n // otherwise return the error\n return buildSubscribableResult(result, this.buildSubscribe(), () => this.refresh());\n }\n\n if (returnData === undefined) {\n if (networkData) {\n return buildSubscribableResult(networkData, this.buildSubscribe(), () =>\n this.refresh()\n );\n }\n return buildSubscribableResult(\n err(new Error('Cache miss after fetching from network')),\n this.buildSubscribe(),\n () => this.refresh()\n );\n }\n\n if (this.subscriptions.length > 0) {\n this.subscribe();\n }\n return returnData;\n });\n }\n\n /**\n * Builds a request runner that orchestrates cache read, network request, and cache write operations\n *\n * The request runner encapsulates the three main operations:\n * 1. Reading from cache with subscription setup\n * 2. Requesting data from the network\n * 3. Writing network results to cache and recording keys\n *\n * @returns A configured request runner for the cache controller\n */\n protected buildRequestRunner(): CacheControlRequestRunner<ReturnData, NetworkData> {\n return new CacheControlRequestRunner<ReturnData, NetworkData>(\n (cache: ReadonlyCache) => this.buildResultWithSubscribe(cache),\n () => this.requestFromNetwork(),\n (cache: Cache, networkResult: Result<NetworkData, Error>) =>\n this.writeToCacheAndRecordKeys(cache, networkResult)\n );\n }\n\n /**\n * Publishes cache update events for keys that were modified during the operation\n *\n * This method notifies other parts of the system about cache changes by publishing\n * a 'cacheUpdate' event with the set of keys that were updated. This enables\n * cache invalidation and reactive updates across the application.\n *\n * @returns A promise that resolves when the update event is published (or immediately if no pub/sub service)\n */\n protected publishUpdatedKeys(): SyncOrAsync<void> {\n if (this.services.pubSub) {\n if (this.keysUpdated !== undefined && this.keysUpdated.size > 0) {\n return this.services.pubSub.publish({\n type: 'cacheUpdate',\n data: this.keysUpdated,\n });\n }\n }\n return resolvedPromiseLike(undefined);\n }\n\n protected get operationType(): 'query' | 'mutation' {\n return 'query';\n }\n protected lastResult:\n | { type: 'data'; data: ReturnData }\n | { type: 'error'; error: Error }\n | undefined = undefined;\n\n /**\n * Subscribes to cache update and invalidation events for reactive updates\n *\n * This method sets up subscriptions to listen for changes that affect the data returned\n * by this Command.\n *\n * By default, it subscribes to two types of events on the PubSub service:\n * - 'cacheUpdate': Triggers a rebuild with the original instantiation time\n * - 'cacheInvalidation': Triggers a full refresh without time constraints\n *\n * This method can be extended by subclasses to add additional subscriptions.\n *\n * Note: ALL subscriptions should push an unsubscribe function to the unsubscribers array,\n * for the lifecycle to work correctly and avoid memory leaks.\n */\n protected subscribe(): void {\n this.unsubscribe();\n const { pubSub } = this.services;\n if (!pubSub) {\n return;\n }\n\n const rebuildUnsubscribe = pubSub.subscribe({\n type: 'cacheUpdate',\n predicate: (event: Event<Set<Key>>) => setOverlaps(event.data, this.keysUsed),\n callback: () => this.rerun({ now: this.instantiationTime }).then(() => undefined),\n keys: this.keysUsed,\n } as any);\n\n const refreshUnsubscribe = pubSub.subscribe({\n type: 'cacheInvalidation',\n predicate: (event: Event<Set<Key>>) => setOverlaps(event.data, this.keysUsed),\n callback: () => this.rerun().then(() => undefined),\n keys: this.keysUsed,\n } as any);\n\n this.unsubscribers.push(rebuildUnsubscribe, refreshUnsubscribe);\n }\n\n /**\n * Unsubscribes from all stored subscriptions\n *\n * This method calls all stored unsubscribe functions to clean up event listeners\n * and prevent memory leaks. It should be called when the command is no longer\n * needed and is also called before setting up new subscriptions.\n */\n private unsubscribe() {\n while (this.unsubscribers.length > 0) {\n const unsubscriber = this.unsubscribers.pop();\n unsubscriber?.();\n }\n }\n\n protected unsubscribers: Unsubscribe[] = [];\n\n protected subscriptions: Callback<Result<ReturnData, Error>>[] = [];\n\n protected abstract readonly cacheControlStrategyConfig: CacheControlStrategyConfig;\n\n /**\n * Compares two result values for equality to determine if a cache update should trigger a rerun\n *\n * This method is used to prevent unnecessary reruns when the cached data hasn't actually changed.\n * The default implementation uses deep equality comparison, but subclasses can override this\n * to provide more efficient or domain-specific comparison logic.\n *\n * @param result1 - The first result to compare\n * @param result2 - The second result to compare\n * @returns True if the results are equal, false otherwise\n *\n * @todo This should likely be abstract in v2. For v1, provide default comparison logic.\n */\n protected equals(result1: ReturnData | undefined, result2: ReturnData | undefined): boolean {\n return deepEquals(result1, result2);\n }\n\n /**\n * Reads from the cache and returns the cache result or error\n *\n * In case of a missing or partial result, this should return either a DataNotFoundError or\n * DataIncompleteError, respectively, in the Error response\n *\n * Note that any subclass should JUST try to read the data from the cache here; it should\n * NOT try to take metadata (eg cache control semantics) into account while reading the\n * data. The CacheController is responsible for enforcing those semantics.\n *\n * @param cache source of cached data\n * @returns result or error from the cache\n */\n abstract readFromCache(cache: ReadonlyCache): SyncOrAsync<Result<ReturnData, Error>>;\n\n /**\n * Requests the resource from network, returning the result along with network metadata\n *\n * @returns network result including metadata\n */\n abstract requestFromNetwork(): SyncOrAsync<Result<NetworkData, Error>>;\n\n /**\n * Writes the given result to the cache\n *\n * @param cache source of cached data\n * @param networkResult network result with metadata to write to the cache. This param will\n * be the result of a previous requestFromNetwork call, if the CacheController determines\n * that the data should be cached\n */\n abstract writeToCache(\n cache: Cache,\n networkResult: Result<NetworkData, Error>\n ): SyncOrAsync<void>;\n\n /**\n * Hook method called after a network request completes\n *\n * This method provides a point for subclasses to perform post-request operations\n * such as logging, metrics collection, or cleanup. The default implementation\n * is empty and can be overridden by subclasses as needed.\n *\n * @param _options - Request completion options\n * @param _options.statusCode - HTTP status code from the network response\n */\n async afterRequestHooks(_options: { statusCode: number }) {}\n\n /**\n * Forces a refresh of the cached data by bypassing cache and fetching from network\n *\n * This method executes the command with a \"no-cache\" configuration, ensuring that\n * fresh data is fetched from the network regardless of cache state. It's useful\n * for scenarios where you need to ensure the most up-to-date data.\n *\n * @returns A refresh result indicating success or failure of the refresh operation\n */\n refresh(): SyncOrAsync<RefreshResult<Error>> {\n return this.rerun({ cacheControlConfig: { type: 'no-cache' } }).then((result) => {\n if (result.isErr()) {\n return err(result.error.failure);\n }\n\n return ok(undefined);\n });\n }\n\n /**\n * Writes network result to cache and records the keys that were updated\n *\n * This method wraps the cache write operation with key tracking functionality.\n * It uses a recordable cache wrapper to capture which keys are modified during\n * the write operation, then updates the internal tracking of used and updated keys.\n *\n * @param cache - The cache instance to write to\n * @param networkResult - The network result containing data to write to cache\n * @returns A result indicating success or failure of the write operation\n */\n writeToCacheAndRecordKeys(\n cache: Cache,\n networkResult: Result<NetworkData, Error>\n ): SyncOrAsync<Result<void, Error>> {\n const recordableCache = cache.record();\n return this.writeToCache(recordableCache, networkResult).then((result) => {\n this.instantiationTime = Date.now() / 1000;\n this.keysUpdated = recordableCache.keysUpdated;\n return ok(result);\n });\n }\n\n /**\n * Builds a subscribable result by reading from cache and setting up subscriptions\n *\n * This method reads data from the cache and wraps the result in a subscribable\n * structure that allows consumers to subscribe to updates. It also tracks which\n * cache keys were read for future invalidation purposes.\n *\n * @param cache - The readonly cache to read from\n * @returns A subscribable result containing the cached data or error\n */\n buildResultWithSubscribe(cache: ReadonlyCache) {\n const recordableCache = cache.record();\n const result = this.readFromCache(recordableCache);\n return result.then((readResult) => {\n if (readResult.isErr()) {\n return buildSubscribableResult(readResult, this.buildSubscribe(), () =>\n this.refresh()\n );\n } else {\n const data = readResult.value;\n this.keysUsed = recordableCache.keysRead;\n return buildSubscribableResult(ok(data), this.buildSubscribe(), () =>\n this.refresh()\n );\n }\n });\n }\n\n /**\n * Builds a function that subscribes to cache changes via the pubsub service. Whenever\n * relevant cache updates occur, it re-reads the data and compares it against\n * the last known value. If a change is detected, the provided\n * callback is invoked.\n *\n * @returns an unsubscribe function to stop watching for updates\n */\n protected buildSubscribe() {\n return (consumerCallback: Callback<Result<ReturnData, Error>>): Unsubscribe => {\n if (this.subscriptions.length === 0 && this.operationType === 'query') {\n this.subscribe();\n }\n this.subscriptions.push(consumerCallback);\n return () => {\n this.subscriptions = this.subscriptions.filter((cb) => cb !== consumerCallback);\n if (this.subscriptions.length === 0) {\n this.unsubscribe();\n }\n };\n };\n }\n\n /**\n * Re-runs the command execution with optional overrides and notifies subscribers of changes\n *\n * This method is called internally when cache updates occur that affect the command's data.\n * It executes the command with the provided overrides and compares the result with the\n * last known result. If the data has changed, it notifies all subscribers with the new data.\n *\n * The method handles deduplication to prevent unnecessary notifications when the data\n * hasn't actually changed, and properly manages the internal execution state.\n *\n * @param overrides - Optional execution overrides for the rerun\n * @returns A promise that resolves to the execution result\n */\n protected rerun(overrides?: ExecuteOverrides) {\n this._isInternalExecution = true;\n\n return this.execute(overrides).then((result) => {\n this._isInternalExecution = false;\n\n // if we're emitting an error Result, we do not dedupe the emits against previous emits\n if (result.isErr()) {\n this.lastResult = { type: 'error', error: result.error.failure };\n this.invokeConsumerCallbacks(err(result.error.failure));\n return result;\n }\n if (\n this.lastResult === undefined ||\n this.lastResult.type === 'error' ||\n !this.equals(this.lastResult.data, result.value.data)\n ) {\n this.lastResult = { type: 'data', data: result.value.data };\n this.invokeConsumerCallbacks(ok(result.value.data));\n }\n\n return result;\n });\n }\n\n /**\n * Invokes all registered consumer callbacks with the provided data\n *\n * This private method safely calls all registered subscriber callbacks with the\n * provided result data. It includes error handling to prevent callback failures\n * from affecting other callbacks or the overall system.\n *\n * @param data - The result data to send to all subscribers\n */\n private invokeConsumerCallbacks(data: Result<ReturnData, Error>) {\n this.subscriptions.forEach((cb) => {\n try {\n cb(data);\n } catch (error) {\n // TODO: Add logging here\n }\n });\n }\n}\n/**\n * Merges a base cache control strategy configuration with execution overrides\n *\n * This utility function combines a base cache control configuration with optional\n * execution overrides, handling the merging of nested configuration properties\n * and ensuring that override values take precedence over base values.\n *\n * @param baseConfig - The base cache control strategy configuration\n * @param overrides - Optional execution overrides to merge with the base config\n * @param overrides.now - Override timestamp for cache control calculations\n * @param overrides.cacheControlConfig - Override cache control strategy configuration\n * @returns A merged cache control strategy configuration\n */\nexport function mergeCacheControlConfigs(\n baseConfig: CacheControlStrategyConfig,\n overrides?: ExecuteOverrides\n): CacheControlStrategyConfig {\n if (!overrides) {\n return baseConfig;\n }\n const now = overrides.now ?? baseConfig.now;\n\n if (!overrides.cacheControlConfig) {\n return {\n ...baseConfig,\n now,\n };\n }\n\n return {\n ...overrides.cacheControlConfig,\n now,\n } as CacheControlStrategyConfig;\n}\n","import { type ServiceDescriptor } from '@conduit-client/utils';\nimport { CacheControlCommand } from './cache-control-command';\n\nexport { CacheControlCommand } from './cache-control-command';\nexport { CacheControlRequestRunner } from './cache-control-request-runner';\n\nexport type CacheControlCommandServiceDescriptor = ServiceDescriptor<\n typeof CacheControlCommand,\n 'cacheControlCommandBaseClass',\n '1.0'\n>;\n\nexport function buildServiceDescriptor(): CacheControlCommandServiceDescriptor {\n return {\n type: 'cacheControlCommandBaseClass',\n version: '1.0',\n service: CacheControlCommand,\n };\n}\n"],"names":["result"],"mappings":";;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6EA,MAAM,EAAE,QAAO,IAAK;AA2CpB,MAAM,GAAG;AAAA,EACP,YAAY,OAAO;AACjB,SAAK,QAAQ;AAAA,EACf;AAAA,EACA,OAAO;AACL,WAAO;AAAA,EACT;AAAA,EACA,QAAQ;AACN,WA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1/utils.ts","../../src/v1/cache-control-request-runner.ts","../../src/v1/cache-control-command.ts","../../src/v1/index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2022, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nfunction bfs(start, predicate, getChildren) {\n const queue = [...start];\n const visited = /* @__PURE__ */ new Set([...start]);\n const matches2 = /* @__PURE__ */ new Set();\n while (queue.length) {\n const curr = queue.shift();\n if (predicate(curr)) {\n matches2.add(curr);\n }\n const children = getChildren(curr);\n for (const child of children) {\n if (!visited.has(child)) {\n visited.add(child);\n queue.push(child);\n }\n }\n }\n return matches2;\n}\nfunction lineFormatter(position, message, filePath) {\n return `${message} (${filePath}:${position.line}:${position.column})`;\n}\nclass DefaultFileParserLogger {\n constructor(services, filePath) {\n this.services = services;\n this.filePath = filePath;\n }\n trace(position, message) {\n this.services.logger.trace(this.format(position, message));\n }\n debug(position, message) {\n this.services.logger.debug(this.format(position, message));\n }\n info(position, message) {\n this.services.logger.info(this.format(position, message));\n }\n warn(position, message) {\n this.services.logger.warn(this.format(position, message));\n }\n error(position, message) {\n this.services.logger.error(this.format(position, message));\n }\n format(position, message) {\n return lineFormatter(position, message, this.filePath);\n }\n}\nfunction matches(test, s) {\n if (test === void 0) {\n return false;\n } else if (typeof test === \"string\") {\n return s === test;\n } else if (test instanceof RegExp) {\n return test.test(s);\n } else if (typeof test === \"function\") {\n return test(s);\n }\n return test.some((m) => matches(m, s));\n}\nfunction includes(incexc, s) {\n if (matches(incexc.exclude, s)) {\n return false;\n }\n if (matches(incexc.include, s)) {\n return true;\n }\n if (incexc.include) {\n return false;\n }\n return true;\n}\nconst { create, freeze, keys, entries } = Object;\nconst { hasOwnProperty } = Object.prototype;\nconst { isArray } = Array;\nconst { push, indexOf, slice } = Array.prototype;\nconst { stringify, parse } = JSON;\nconst WeakSetConstructor = WeakSet;\nconst LogLevelMap = {\n TRACE: 4,\n DEBUG: 3,\n INFO: 2,\n WARN: 1,\n ERROR: 0\n};\nclass ConsoleLogger {\n constructor(level = \"WARN\", printer = console.log, formatter = (level2, message) => `${level2}: ${message}`) {\n this.level = level;\n this.printer = printer;\n this.formatter = formatter;\n this.messages = [];\n }\n trace(message) {\n this.log(\"TRACE\", message);\n }\n debug(message) {\n this.log(\"DEBUG\", message);\n }\n info(message) {\n this.log(\"INFO\", message);\n }\n warn(message) {\n this.log(\"WARN\", message);\n }\n error(message) {\n this.log(\"ERROR\", message);\n }\n log(level, message) {\n if (LogLevelMap[level] > LogLevelMap[this.level]) {\n return;\n }\n this.printer(this.formatter(level, message));\n }\n}\nfunction loggerService(level, printer, formatter) {\n return new ConsoleLogger(level, printer, formatter);\n}\nclass Ok {\n constructor(value) {\n this.value = value;\n }\n isOk() {\n return true;\n }\n isErr() {\n return !this.isOk();\n }\n}\nclass Err {\n constructor(error) {\n this.error = error;\n }\n isOk() {\n return false;\n }\n isErr() {\n return !this.isOk();\n }\n}\nconst ok = (value) => new Ok(value);\nconst err = (err2) => new Err(err2);\nclass DataNotFoundError extends Error {\n constructor(message) {\n super(message);\n this.name = \"DataNotFoundError\";\n }\n}\nclass DataIncompleteError extends Error {\n constructor(message, partialData) {\n super(message);\n this.partialData = partialData;\n this.name = \"DataIncompleteError\";\n }\n}\nfunction isDataNotFoundError(error) {\n return error instanceof DataNotFoundError || error.name === \"DataNotFoundError\";\n}\nfunction isDataIncompleteError(error) {\n return error instanceof DataIncompleteError || error.name === \"DataIncompleteError\";\n}\nfunction isCacheHitOrError(value) {\n if (value.isErr() && (isDataIncompleteError(value.error) || isDataNotFoundError(value.error))) {\n return false;\n }\n return true;\n}\nfunction isCacheMiss(value) {\n return !isCacheHitOrError(value);\n}\nfunction isResult(value) {\n return value != null && typeof value === \"object\" && \"isOk\" in value && \"isErr\" in value && typeof value.isOk === \"function\" && typeof value.isErr === \"function\" && (value.isOk() === true && value.isErr() === false && \"value\" in value || value.isOk() === false && value.isErr() === true && \"error\" in value);\n}\nfunction setOverlaps(setA, setB) {\n for (const element of setA) {\n if (setB.has(element)) {\n return true;\n }\n }\n return false;\n}\nfunction setDifference(setA, setB) {\n const differenceSet = /* @__PURE__ */ new Set();\n for (const element of setA) {\n if (!setB.has(element)) {\n differenceSet.add(element);\n }\n }\n return differenceSet;\n}\nfunction addAllToSet(targetSet, sourceSet) {\n for (const element of sourceSet) {\n targetSet.add(element);\n }\n}\nconst toTypeScriptSafeIdentifier = (s) => s.length >= 1 ? s[0].replace(/[^$_\\p{ID_Start}]/u, \"_\") + s.slice(1).replace(/[^$\\u200c\\u200d\\p{ID_Continue}]/gu, \"_\") : \"\";\nfunction isSubscribable(obj) {\n return typeof obj === \"object\" && obj !== null && \"subscribe\" in obj && typeof obj.subscribe === \"function\" && \"refresh\" in obj && typeof obj.refresh === \"function\";\n}\nfunction isSubscribableResult(x) {\n if (!isResult(x)) {\n return false;\n }\n return isSubscribable(x.isOk() ? x.value : x.error);\n}\nfunction buildSubscribableResult(result, subscribe, refresh) {\n if (result.isOk()) {\n return ok({ data: result.value, subscribe, refresh });\n } else {\n return err({ failure: result.error, subscribe, refresh });\n }\n}\nfunction resolvedPromiseLike(result) {\n if (isPromiseLike(result)) {\n return result.then((nextResult) => nextResult);\n }\n return {\n then: (onFulfilled, _onRejected) => {\n try {\n return resolvedPromiseLike(onFulfilled(result));\n } catch (e) {\n if (onFulfilled === void 0) {\n return resolvedPromiseLike(result);\n }\n return rejectedPromiseLike(e);\n }\n }\n };\n}\nfunction rejectedPromiseLike(reason) {\n if (isPromiseLike(reason)) {\n return reason.then((nextResult) => nextResult);\n }\n return {\n then: (_onFulfilled, onRejected) => {\n if (typeof onRejected === \"function\") {\n try {\n return resolvedPromiseLike(onRejected(reason));\n } catch (e) {\n return rejectedPromiseLike(e);\n }\n }\n return rejectedPromiseLike(reason);\n }\n };\n}\nfunction isPromiseLike(x) {\n return typeof (x == null ? void 0 : x.then) === \"function\";\n}\nfunction racesync(values) {\n for (const value of values) {\n let settled = void 0;\n if (isPromiseLike(value)) {\n value.then(\n (_) => {\n settled = value;\n },\n (_) => {\n settled = value;\n }\n );\n } else {\n settled = resolvedPromiseLike(value);\n }\n if (settled !== void 0) {\n return settled;\n }\n }\n return Promise.race(values);\n}\nfunction withResolvers() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\nfunction deepEquals(x, y) {\n if (x === void 0) {\n return y === void 0;\n } else if (x === null) {\n return y === null;\n } else if (y === null) {\n return x === null;\n } else if (isArray(x)) {\n if (!isArray(y) || x.length !== y.length) {\n return false;\n }\n for (let i = 0; i < x.length; ++i) {\n if (!deepEquals(x[i], y[i])) {\n return false;\n }\n }\n return true;\n } else if (typeof x === \"object\") {\n if (typeof y !== \"object\") {\n return false;\n }\n const xkeys = Object.keys(x);\n const ykeys = Object.keys(y);\n if (xkeys.length !== ykeys.length) {\n return false;\n }\n for (let i = 0; i < xkeys.length; ++i) {\n const key = xkeys[i];\n if (!deepEquals(x[key], y[key])) {\n return false;\n }\n }\n return true;\n }\n return x === y;\n}\nfunction stableJSONStringify(node) {\n if (node && node.toJSON && typeof node.toJSON === \"function\") {\n node = node.toJSON();\n }\n if (node === void 0) {\n return;\n }\n if (typeof node === \"number\") {\n return isFinite(node) ? \"\" + node : \"null\";\n }\n if (typeof node !== \"object\") {\n return stringify(node);\n }\n let i;\n let out;\n if (isArray(node)) {\n out = \"[\";\n for (i = 0; i < node.length; i++) {\n if (i) {\n out += \",\";\n }\n out += stableJSONStringify(node[i]) || \"null\";\n }\n return out + \"]\";\n }\n if (node === null) {\n return \"null\";\n }\n const objKeys = keys(node).sort();\n out = \"\";\n for (i = 0; i < objKeys.length; i++) {\n const key = objKeys[i];\n const value = stableJSONStringify(node[key]);\n if (!value) {\n continue;\n }\n if (out) {\n out += \",\";\n }\n out += stringify(key) + \":\" + value;\n }\n return \"{\" + out + \"}\";\n}\nfunction toError(x) {\n if (x instanceof Error) {\n return x;\n }\n return new Error(typeof x === \"string\" ? x : JSON.stringify(x));\n}\nfunction deepCopy(x) {\n const stringified = stringify(x);\n return stringified ? parse(stringified) : void 0;\n}\nfunction readableStreamToAsyncIterable(stream) {\n if (stream.locked) {\n return err(new Error(\"ReadableStream is already locked\"));\n }\n if (Symbol.asyncIterator in stream) {\n return ok(stream);\n }\n const reader = stream.getReader();\n return ok({\n [Symbol.asyncIterator]: () => ({\n next: async () => {\n try {\n const result = await reader.read();\n if (result.done) {\n try {\n reader.releaseLock();\n } catch {\n }\n return { done: true, value: void 0 };\n }\n return {\n done: false,\n value: result.value\n };\n } catch (e) {\n try {\n reader.releaseLock();\n } catch {\n }\n throw e;\n }\n },\n return: async (value) => {\n try {\n await reader.cancel();\n } catch {\n }\n try {\n reader.releaseLock();\n } catch {\n }\n return { done: true, value };\n },\n throw: async (exception) => {\n try {\n await reader.cancel();\n } catch {\n }\n try {\n reader.releaseLock();\n } catch {\n }\n throw exception;\n }\n })\n });\n}\nfunction satisfies(provided, requested) {\n const providedN = provided.split(\".\").map((s) => parseInt(s));\n const requestedN = requested.split(\".\").map((s) => parseInt(s));\n return providedN[0] === requestedN[0] && providedN[1] >= requestedN[1];\n}\nfunction stringIsVersion(s) {\n const versionParts = s.split(\".\");\n return (versionParts.length === 2 || versionParts.length === 3) && versionParts.every((part) => part.match(/^\\d+$/));\n}\nvar HttpStatusCode = /* @__PURE__ */ ((HttpStatusCode2) => {\n HttpStatusCode2[HttpStatusCode2[\"Ok\"] = 200] = \"Ok\";\n HttpStatusCode2[HttpStatusCode2[\"Created\"] = 201] = \"Created\";\n HttpStatusCode2[HttpStatusCode2[\"NoContent\"] = 204] = \"NoContent\";\n HttpStatusCode2[HttpStatusCode2[\"NotModified\"] = 304] = \"NotModified\";\n HttpStatusCode2[HttpStatusCode2[\"BadRequest\"] = 400] = \"BadRequest\";\n HttpStatusCode2[HttpStatusCode2[\"Unauthorized\"] = 401] = \"Unauthorized\";\n HttpStatusCode2[HttpStatusCode2[\"Forbidden\"] = 403] = \"Forbidden\";\n HttpStatusCode2[HttpStatusCode2[\"NotFound\"] = 404] = \"NotFound\";\n HttpStatusCode2[HttpStatusCode2[\"ServerError\"] = 500] = \"ServerError\";\n HttpStatusCode2[HttpStatusCode2[\"GatewayTimeout\"] = 504] = \"GatewayTimeout\";\n return HttpStatusCode2;\n})(HttpStatusCode || {});\nfunction getFetchResponseFromAuraError(err2) {\n if (err2.data !== void 0 && err2.data.statusCode !== void 0) {\n let data = {};\n data = err2.data;\n if (err2.id !== void 0) {\n data.id = err2.id;\n }\n return new FetchResponse(data.statusCode, data);\n }\n return new FetchResponse(500, {\n error: err2.message\n });\n}\nasync function coerceResponseToFetchResponse(response) {\n const { status } = response;\n const responseHeaders = {};\n response.headers.forEach((value, key) => {\n responseHeaders[key] = value;\n });\n let responseBody = null;\n if (status !== 204) {\n const contentType = responseHeaders[\"content-type\"];\n responseBody = contentType && contentType.startsWith(\"application/json\") ? await response.json() : await response.text();\n }\n return new FetchResponse(status, responseBody, responseHeaders);\n}\nfunction getStatusText(status) {\n switch (status) {\n case 200:\n return \"OK\";\n case 201:\n return \"Created\";\n case 304:\n return \"Not Modified\";\n case 400:\n return \"Bad Request\";\n case 404:\n return \"Not Found\";\n case 500:\n return \"Server Error\";\n default:\n return `Unexpected HTTP Status Code: ${status}`;\n }\n}\nclass FetchResponse extends Error {\n constructor(status, body, headers) {\n super();\n this.status = status;\n this.body = body;\n this.headers = headers || {};\n this.ok = status >= 200 && this.status <= 299;\n this.statusText = getStatusText(status);\n }\n}\nconst deeplyFrozen = new WeakSetConstructor();\nfunction deepFreeze(value) {\n if (typeof value !== \"object\" || value === null || deeplyFrozen.has(value)) {\n return;\n }\n deeplyFrozen.add(value);\n if (isArray(value)) {\n for (let i = 0, len = value.length; i < len; i += 1) {\n deepFreeze(value[i]);\n }\n } else {\n const keys$1 = keys(value);\n for (let i = 0, len = keys$1.length; i < len; i += 1) {\n deepFreeze(value[keys$1[i]]);\n }\n }\n freeze(value);\n}\nfunction isScalar(value) {\n return typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\" || value === null || value === void 0;\n}\nfunction isScalarObject(value) {\n return Object.values(value).every((value2) => isScalar(value2));\n}\nfunction isScalarArray(value) {\n return value.every((item) => isScalar(item));\n}\nfunction encodeQueryParam(paramName, value, explode) {\n switch (typeof value) {\n case \"string\":\n return [`${paramName}=${encodeURIComponent(value)}`];\n case \"number\":\n case \"boolean\":\n return [`${paramName}=${value}`];\n case \"object\":\n if (value === null) {\n return [];\n }\n if (isArray(value)) {\n if (!isScalarArray(value)) {\n throw new Error(`Unsupported non-scalar array type for ${paramName}`);\n }\n if (explode) {\n return value.map(\n (item) => `${paramName}=${item ? encodeURIComponent(item) : item}`\n );\n }\n return [\n `${paramName}=${value.map((item) => item ? encodeURIComponent(item) : item).join(\",\")}`\n ];\n }\n if (!isScalarObject(value)) {\n throw new Error(`Unsupported non-scalar object type for ${paramName}`);\n }\n if (explode) {\n return entries(value).map(\n ([key, value2]) => `${key}=${value2 ? encodeURIComponent(value2) : value2}`\n );\n }\n return [\n `${paramName}=${entries(value).flat().map((item) => item ? encodeURIComponent(item) : item).join(\",\")}`\n ];\n default:\n return [];\n }\n}\nclass InternalError extends Error {\n constructor(data) {\n super();\n this.data = data;\n this.type = \"internal\";\n }\n}\nclass UserVisibleError extends Error {\n constructor(data) {\n super();\n this.data = data;\n this.type = \"user-visible\";\n }\n}\nfunction isUserVisibleError(error) {\n return error instanceof Error && \"type\" in error && error.type === \"user-visible\";\n}\nfunction logError(error) {\n if (isUserVisibleError(error)) {\n return;\n }\n console.error(\"OneStore Command threw an error that we did not expect\", error);\n}\nfunction applyDecorators(baseCommand, decorators, options) {\n if (!decorators || decorators.length === 0) {\n return baseCommand;\n }\n return decorators.reduce((command, decorator) => decorator(command, options), baseCommand);\n}\nexport {\n isArray as ArrayIsArray,\n indexOf as ArrayPrototypeIndexOf,\n push as ArrayPrototypePush,\n slice as ArrayPrototypeSlice,\n ConsoleLogger,\n DataIncompleteError,\n DataNotFoundError,\n DefaultFileParserLogger,\n Err,\n FetchResponse,\n HttpStatusCode,\n InternalError,\n parse as JSONParse,\n stringify as JSONStringify,\n LogLevelMap,\n create as ObjectCreate,\n entries as ObjectEntries,\n freeze as ObjectFreeze,\n keys as ObjectKeys,\n hasOwnProperty as ObjectPrototypeHasOwnProperty,\n Ok,\n UserVisibleError,\n WeakSetConstructor,\n addAllToSet,\n applyDecorators,\n bfs,\n buildSubscribableResult,\n coerceResponseToFetchResponse,\n deepCopy,\n deepEquals,\n deepFreeze,\n encodeQueryParam,\n err,\n getFetchResponseFromAuraError,\n includes,\n isCacheHitOrError,\n isCacheMiss,\n isDataIncompleteError,\n isDataNotFoundError,\n isPromiseLike,\n isResult,\n isSubscribable,\n isSubscribableResult,\n isUserVisibleError,\n lineFormatter,\n logError,\n loggerService,\n ok,\n racesync,\n readableStreamToAsyncIterable,\n rejectedPromiseLike,\n resolvedPromiseLike,\n satisfies,\n setDifference,\n setOverlaps,\n stableJSONStringify,\n stringIsVersion,\n toError,\n toTypeScriptSafeIdentifier,\n withResolvers\n};\n//# sourceMappingURL=index.js.map\n","import type { Key } from '@conduit-client/service-cache/v1';\n\n// Needs TS 2023+ (esnext) AND node 20+ to remove\nexport function setOverlaps(setA: Set<Key>, setB: Set<Key>): boolean {\n if (setA.size > setB.size) {\n for (const key of setB.keys()) {\n if (setA.has(key)) {\n return true;\n }\n }\n } else {\n for (const key of setA) {\n if (setB.has(key)) {\n return true;\n }\n }\n }\n return false;\n}\n","import { Cache, ReadonlyCache } from '@conduit-client/service-cache/v1';\nimport { Err, err, Ok, ok, Result, SubscribableResult, SyncOrAsync } from '@conduit-client/utils';\n\nexport class CacheControlRequestRunner<ReturnData, NetworkData> {\n returnData: SubscribableResult<ReturnData, Error> | undefined;\n networkData: Ok<NetworkData, Error> | undefined;\n networkError: Err<never, Error> | undefined;\n readFromCacheInternal;\n requestFromNetworkInternal;\n writeToCacheInternal;\n\n constructor(\n readFromCache: (cache: ReadonlyCache) => SyncOrAsync<SubscribableResult<ReturnData, Error>>,\n requestFromNetwork: () => SyncOrAsync<Result<NetworkData, Error>>,\n writeToCache: (\n cache: Cache,\n networkResult: Result<NetworkData, Error>\n ) => SyncOrAsync<Result<void, Error>>\n ) {\n this.readFromCacheInternal = readFromCache;\n this.requestFromNetworkInternal = requestFromNetwork;\n this.writeToCacheInternal = writeToCache;\n }\n\n readFromCache(cache: ReadonlyCache) {\n const resultPromise = this.readFromCacheInternal(cache);\n\n return resultPromise.then((result) => {\n if (result.isErr()) {\n return err(result.error.failure);\n }\n\n this.returnData = result;\n return ok(undefined);\n });\n }\n\n requestFromNetwork() {\n const that = this;\n return (async function* () {\n const result = await that.requestFromNetworkInternal();\n if (result.isErr()) {\n that.networkError = result;\n } else {\n that.networkData = result;\n }\n yield result;\n })();\n }\n\n writeToCache(cache: Cache, networkResult: Result<NetworkData, Error>) {\n return this.writeToCacheInternal(cache, networkResult);\n }\n}\n","import { BaseCommand } from '@conduit-client/command-base/v1';\nimport { type Event, type NamedPubSubService } from '@conduit-client/service-pubsub/v1';\nimport {\n ok,\n err,\n deepEquals,\n resolvedPromiseLike,\n buildSubscribableResult,\n} from '@conduit-client/utils';\nimport type {\n Callback,\n Result,\n Unsubscribe,\n SubscribableResult,\n SyncOrAsync,\n RefreshResult,\n} from '@conduit-client/utils';\nimport type { Cache, Key, ReadonlyCache } from '@conduit-client/service-cache/v1';\nimport type {\n CacheControlStrategyConfig,\n NamedCacheControllerService,\n} from '@conduit-client/service-cache-control/v1';\nimport { InstrumentationAttributes } from '@conduit-client/service-instrumentation/v1';\nimport { setOverlaps } from './utils';\nimport { CacheControlRequestRunner } from './cache-control-request-runner';\n\ntype ExecuteOverrides = {\n now?: number;\n cacheControlConfig?: Omit<CacheControlStrategyConfig, 'now'>;\n};\n\n/**\n * An implementation of BaseCommand that allows for extending abstract cache methods\n *\n * @typeParam Data cache result for read operations\n * @typeParam NetworkResult cache result including network metadata\n * @typeParam ExtraServices additional named services needed by a subclass\n */\nexport abstract class CacheControlCommand<\n ReturnData,\n NetworkData,\n ExtraServices extends object = object,\n> extends BaseCommand<SyncOrAsync<SubscribableResult<ReturnData, Error>>> {\n instantiationTime: number;\n instrumentationAttributes?: InstrumentationAttributes;\n private keysUsed = new Set<Key>();\n private keysUpdated: Set<Key> | undefined = undefined;\n private _isInternalExecution = false;\n\n get isInternalExecution(): boolean {\n return this._isInternalExecution;\n }\n\n /**\n * Creates a new CacheControlCommand instance\n *\n * @param services - Required services including cache controller and optional pub/sub service\n * @param services.cacheController - The cache controller service for managing cache operations\n * @param services.pubSub - Optional pub/sub service for cache invalidation notifications\n * @param services - Additional services specific to the implementation\n */\n constructor(\n protected services: NamedCacheControllerService &\n Partial<NamedPubSubService> &\n ExtraServices\n ) {\n super();\n this.instantiationTime = Date.now() / 1000; // in seconds\n }\n\n /**\n * Executes the cache control command with optional overrides\n *\n * This method orchestrates the cache control flow by:\n * 1. Clearing any existing subscriptions\n * 2. Merging configuration overrides with the base strategy config\n * 3. Building a request runner for cache operations\n * 4. Executing the cache controller with the request runner\n * 5. Handling the result and setting up subscriptions if needed\n *\n * @param overrides - Optional execution overrides including timestamp and cache control config\n * @param overrides.now - Override the current timestamp for cache control calculations\n * @param overrides.cacheControlConfig - Override cache control strategy configuration\n * @returns A subscribable result containing either the cached/network data or an error\n */\n execute(overrides?: ExecuteOverrides): SyncOrAsync<SubscribableResult<ReturnData, Error>> {\n this.keysUpdated = undefined;\n this.unsubscribe();\n\n const mergedCacheControlConfig = mergeCacheControlConfigs(\n this.cacheControlStrategyConfig,\n overrides\n );\n\n const requestRunner = this.buildRequestRunner();\n\n const resultPromise = this.services.cacheController.execute<\n Result<NetworkData, Error>,\n Error\n >(mergedCacheControlConfig, requestRunner, {\n instrumentationAttributes: this.instrumentationAttributes,\n });\n\n return resultPromise.then((result) => {\n return this.handleCacheControllerResult(result, requestRunner).then((result) => {\n // This is our first pass through the Command, so we need to set the lastResult.\n // Subsequent results are kept up to date in rerun()\n if (this.lastResult === undefined) {\n if (result.isErr()) {\n this.lastResult = { type: 'error', error: result.error.failure };\n } else {\n this.lastResult = { type: 'data', data: result.value.data };\n }\n }\n return result;\n });\n });\n }\n\n /**\n * Handles the result from the cache controller and builds the appropriate subscribable result\n *\n * This method processes the cache controller execution result and determines the appropriate\n * response based on network errors, cache errors, and available data. It handles graceful\n * degradation scenarios where network data is available even when cache operations fail.\n *\n * @param result - The result from the cache controller execution\n * @param requestRunner - The request runner containing network data and errors\n * @returns A subscribable result with the appropriate data or error\n */\n handleCacheControllerResult(\n result: Result<void, Error>,\n requestRunner: CacheControlRequestRunner<ReturnData, NetworkData>\n ): SyncOrAsync<SubscribableResult<ReturnData, Error>> {\n const { networkError, networkData, returnData } = requestRunner;\n return this.publishUpdatedKeys().then(() => {\n // First check if there was an error from the network\n if (networkError) {\n return buildSubscribableResult(networkError, this.buildSubscribe(), () =>\n this.refresh()\n );\n }\n\n // Then return other errors from read/write\n if (result.isErr()) {\n // If the result was an error but we got network data, gracefully degrade to returning the\n // network data without caching/subscriptions\n if (networkData) {\n return buildSubscribableResult(networkData, this.buildSubscribe(), () =>\n this.refresh()\n );\n }\n // otherwise return the error\n return buildSubscribableResult(result, this.buildSubscribe(), () => this.refresh());\n }\n\n if (returnData === undefined) {\n if (networkData) {\n return buildSubscribableResult(networkData, this.buildSubscribe(), () =>\n this.refresh()\n );\n }\n return buildSubscribableResult(\n err(new Error('Cache miss after fetching from network')),\n this.buildSubscribe(),\n () => this.refresh()\n );\n }\n\n if (this.subscriptions.length > 0) {\n this.subscribe();\n }\n return returnData;\n });\n }\n\n /**\n * Builds a request runner that orchestrates cache read, network request, and cache write operations\n *\n * The request runner encapsulates the three main operations:\n * 1. Reading from cache with subscription setup\n * 2. Requesting data from the network\n * 3. Writing network results to cache and recording keys\n *\n * @returns A configured request runner for the cache controller\n */\n protected buildRequestRunner(): CacheControlRequestRunner<ReturnData, NetworkData> {\n return new CacheControlRequestRunner<ReturnData, NetworkData>(\n (cache: ReadonlyCache) => this.buildResultWithSubscribe(cache),\n () => this.requestFromNetwork(),\n (cache: Cache, networkResult: Result<NetworkData, Error>) =>\n this.writeToCacheAndRecordKeys(cache, networkResult)\n );\n }\n\n /**\n * Publishes cache update events for keys that were modified during the operation\n *\n * This method notifies other parts of the system about cache changes by publishing\n * a 'cacheUpdate' event with the set of keys that were updated. This enables\n * cache invalidation and reactive updates across the application.\n *\n * @returns A promise that resolves when the update event is published (or immediately if no pub/sub service)\n */\n protected publishUpdatedKeys(): SyncOrAsync<void> {\n if (this.services.pubSub) {\n if (this.keysUpdated !== undefined && this.keysUpdated.size > 0) {\n return this.services.pubSub.publish({\n type: 'cacheUpdate',\n data: this.keysUpdated,\n });\n }\n }\n return resolvedPromiseLike(undefined);\n }\n\n protected get operationType(): 'query' | 'mutation' {\n return 'query';\n }\n protected lastResult:\n | { type: 'data'; data: ReturnData }\n | { type: 'error'; error: Error }\n | undefined = undefined;\n\n /**\n * Subscribes to cache update and invalidation events for reactive updates\n *\n * This method sets up subscriptions to listen for changes that affect the data returned\n * by this Command.\n *\n * By default, it subscribes to two types of events on the PubSub service:\n * - 'cacheUpdate': Triggers a rebuild with the original instantiation time\n * - 'cacheInvalidation': Triggers a full refresh without time constraints\n *\n * This method can be extended by subclasses to add additional subscriptions.\n *\n * Note: ALL subscriptions should push an unsubscribe function to the unsubscribers array,\n * for the lifecycle to work correctly and avoid memory leaks.\n */\n protected subscribe(): void {\n this.unsubscribe();\n const { pubSub } = this.services;\n if (!pubSub) {\n return;\n }\n\n const rebuildUnsubscribe = pubSub.subscribe({\n type: 'cacheUpdate',\n predicate: (event: Event<Set<Key>>) => setOverlaps(event.data, this.keysUsed),\n callback: () => this.rerun({ now: this.instantiationTime }).then(() => undefined),\n keys: this.keysUsed,\n } as any);\n\n const refreshUnsubscribe = pubSub.subscribe({\n type: 'cacheInvalidation',\n predicate: (event: Event<Set<Key>>) => setOverlaps(event.data, this.keysUsed),\n callback: () => this.rerun().then(() => undefined),\n keys: this.keysUsed,\n } as any);\n\n this.unsubscribers.push(rebuildUnsubscribe, refreshUnsubscribe);\n }\n\n /**\n * Unsubscribes from all stored subscriptions\n *\n * This method calls all stored unsubscribe functions to clean up event listeners\n * and prevent memory leaks. It should be called when the command is no longer\n * needed and is also called before setting up new subscriptions.\n */\n private unsubscribe() {\n while (this.unsubscribers.length > 0) {\n const unsubscriber = this.unsubscribers.pop();\n unsubscriber?.();\n }\n }\n\n protected unsubscribers: Unsubscribe[] = [];\n\n protected subscriptions: Callback<Result<ReturnData, Error>>[] = [];\n\n protected abstract readonly cacheControlStrategyConfig: CacheControlStrategyConfig;\n\n /**\n * Compares two result values for equality to determine if a cache update should trigger a rerun\n *\n * This method is used to prevent unnecessary reruns when the cached data hasn't actually changed.\n * The default implementation uses deep equality comparison, but subclasses can override this\n * to provide more efficient or domain-specific comparison logic.\n *\n * @param result1 - The first result to compare\n * @param result2 - The second result to compare\n * @returns True if the results are equal, false otherwise\n *\n * @todo This should likely be abstract in v2. For v1, provide default comparison logic.\n */\n protected equals(result1: ReturnData | undefined, result2: ReturnData | undefined): boolean {\n return deepEquals(result1, result2);\n }\n\n /**\n * Reads from the cache and returns the cache result or error\n *\n * In case of a missing or partial result, this should return either a DataNotFoundError or\n * DataIncompleteError, respectively, in the Error response\n *\n * Note that any subclass should JUST try to read the data from the cache here; it should\n * NOT try to take metadata (eg cache control semantics) into account while reading the\n * data. The CacheController is responsible for enforcing those semantics.\n *\n * @param cache source of cached data\n * @returns result or error from the cache\n */\n abstract readFromCache(cache: ReadonlyCache): SyncOrAsync<Result<ReturnData, Error>>;\n\n /**\n * Requests the resource from network, returning the result along with network metadata\n *\n * @returns network result including metadata\n */\n abstract requestFromNetwork(): SyncOrAsync<Result<NetworkData, Error>>;\n\n /**\n * Writes the given result to the cache\n *\n * @param cache source of cached data\n * @param networkResult network result with metadata to write to the cache. This param will\n * be the result of a previous requestFromNetwork call, if the CacheController determines\n * that the data should be cached\n */\n abstract writeToCache(\n cache: Cache,\n networkResult: Result<NetworkData, Error>\n ): SyncOrAsync<void>;\n\n /**\n * Hook method called after a network request completes\n *\n * This method provides a point for subclasses to perform post-request operations\n * such as logging, metrics collection, or cleanup. The default implementation\n * is empty and can be overridden by subclasses as needed.\n *\n * @param _options - Request completion options\n * @param _options.statusCode - HTTP status code from the network response\n */\n async afterRequestHooks(_options: { statusCode: number }) {}\n\n /**\n * Forces a refresh of the cached data by bypassing cache and fetching from network\n *\n * This method executes the command with a \"no-cache\" configuration, ensuring that\n * fresh data is fetched from the network regardless of cache state. It's useful\n * for scenarios where you need to ensure the most up-to-date data.\n *\n * @returns A refresh result indicating success or failure of the refresh operation\n */\n refresh(): SyncOrAsync<RefreshResult<Error>> {\n return this.rerun({ cacheControlConfig: { type: 'no-cache' } }).then((result) => {\n if (result.isErr()) {\n return err(result.error.failure);\n }\n\n return ok(undefined);\n });\n }\n\n /**\n * Writes network result to cache and records the keys that were updated\n *\n * This method wraps the cache write operation with key tracking functionality.\n * It uses a recordable cache wrapper to capture which keys are modified during\n * the write operation, then updates the internal tracking of used and updated keys.\n *\n * @param cache - The cache instance to write to\n * @param networkResult - The network result containing data to write to cache\n * @returns A result indicating success or failure of the write operation\n */\n writeToCacheAndRecordKeys(\n cache: Cache,\n networkResult: Result<NetworkData, Error>\n ): SyncOrAsync<Result<void, Error>> {\n const recordableCache = cache.record();\n return this.writeToCache(recordableCache, networkResult).then((result) => {\n this.instantiationTime = Date.now() / 1000;\n this.keysUpdated = recordableCache.keysUpdated;\n return ok(result);\n });\n }\n\n /**\n * Builds a subscribable result by reading from cache and setting up subscriptions\n *\n * This method reads data from the cache and wraps the result in a subscribable\n * structure that allows consumers to subscribe to updates. It also tracks which\n * cache keys were read for future invalidation purposes.\n *\n * @param cache - The readonly cache to read from\n * @returns A subscribable result containing the cached data or error\n */\n buildResultWithSubscribe(cache: ReadonlyCache) {\n const recordableCache = cache.record();\n const result = this.readFromCache(recordableCache);\n return result.then((readResult) => {\n if (readResult.isErr()) {\n return buildSubscribableResult(readResult, this.buildSubscribe(), () =>\n this.refresh()\n );\n } else {\n const data = readResult.value;\n this.keysUsed = recordableCache.keysRead;\n return buildSubscribableResult(ok(data), this.buildSubscribe(), () =>\n this.refresh()\n );\n }\n });\n }\n\n /**\n * Builds a function that subscribes to cache changes via the pubsub service. Whenever\n * relevant cache updates occur, it re-reads the data and compares it against\n * the last known value. If a change is detected, the provided\n * callback is invoked.\n *\n * @returns an unsubscribe function to stop watching for updates\n */\n protected buildSubscribe() {\n return (consumerCallback: Callback<Result<ReturnData, Error>>): Unsubscribe => {\n if (this.subscriptions.length === 0 && this.operationType === 'query') {\n this.subscribe();\n }\n this.subscriptions.push(consumerCallback);\n return () => {\n this.subscriptions = this.subscriptions.filter((cb) => cb !== consumerCallback);\n if (this.subscriptions.length === 0) {\n this.unsubscribe();\n }\n };\n };\n }\n\n /**\n * Re-runs the command execution with optional overrides and notifies subscribers of changes\n *\n * This method is called internally when cache updates occur that affect the command's data.\n * It executes the command with the provided overrides and compares the result with the\n * last known result. If the data has changed, it notifies all subscribers with the new data.\n *\n * The method handles deduplication to prevent unnecessary notifications when the data\n * hasn't actually changed, and properly manages the internal execution state.\n *\n * @param overrides - Optional execution overrides for the rerun\n * @returns A promise that resolves to the execution result\n */\n protected rerun(overrides?: ExecuteOverrides) {\n this._isInternalExecution = true;\n\n return this.execute(overrides).then((result) => {\n this._isInternalExecution = false;\n\n // if we're emitting an error Result, we do not dedupe the emits against previous emits\n if (result.isErr()) {\n this.lastResult = { type: 'error', error: result.error.failure };\n this.invokeConsumerCallbacks(err(result.error.failure));\n return result;\n }\n if (\n this.lastResult === undefined ||\n this.lastResult.type === 'error' ||\n !this.equals(this.lastResult.data, result.value.data)\n ) {\n this.lastResult = { type: 'data', data: result.value.data };\n this.invokeConsumerCallbacks(ok(result.value.data));\n }\n\n return result;\n });\n }\n\n /**\n * Invokes all registered consumer callbacks with the provided data\n *\n * This private method safely calls all registered subscriber callbacks with the\n * provided result data. It includes error handling to prevent callback failures\n * from affecting other callbacks or the overall system.\n *\n * @param data - The result data to send to all subscribers\n */\n private invokeConsumerCallbacks(data: Result<ReturnData, Error>) {\n this.subscriptions.forEach((cb) => {\n try {\n cb(data);\n } catch (error) {\n // TODO: Add logging here\n }\n });\n }\n}\n/**\n * Merges a base cache control strategy configuration with execution overrides\n *\n * This utility function combines a base cache control configuration with optional\n * execution overrides, handling the merging of nested configuration properties\n * and ensuring that override values take precedence over base values.\n *\n * @param baseConfig - The base cache control strategy configuration\n * @param overrides - Optional execution overrides to merge with the base config\n * @param overrides.now - Override timestamp for cache control calculations\n * @param overrides.cacheControlConfig - Override cache control strategy configuration\n * @returns A merged cache control strategy configuration\n */\nexport function mergeCacheControlConfigs(\n baseConfig: CacheControlStrategyConfig,\n overrides?: ExecuteOverrides\n): CacheControlStrategyConfig {\n if (!overrides) {\n return baseConfig;\n }\n const now = overrides.now ?? baseConfig.now;\n\n if (!overrides.cacheControlConfig) {\n return {\n ...baseConfig,\n now,\n };\n }\n\n return {\n ...overrides.cacheControlConfig,\n now,\n } as CacheControlStrategyConfig;\n}\n","import { type ServiceDescriptor } from '@conduit-client/utils';\nimport { CacheControlCommand } from './cache-control-command';\n\nexport { CacheControlCommand } from './cache-control-command';\nexport { CacheControlRequestRunner } from './cache-control-request-runner';\n\nexport type CacheControlCommandServiceDescriptor = ServiceDescriptor<\n typeof CacheControlCommand,\n 'cacheControlCommandBaseClass',\n '1.0'\n>;\n\nexport function buildServiceDescriptor(): CacheControlCommandServiceDescriptor {\n return {\n type: 'cacheControlCommandBaseClass',\n version: '1.0',\n service: CacheControlCommand,\n };\n}\n"],"names":["result"],"mappings":";;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6EA,MAAM,EAAE,QAAO,IAAK;AA2CpB,MAAM,GAAG;AAAA,EACP,YAAY,OAAO;AACjB,SAAK,QAAQ;AAAA,EACf;AAAA,EACA,OAAO;AACL,WAAO;AAAA,EACT;AAAA,EACA,QAAQ;AACN,WAAO,CAAC,KAAK,KAA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
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "private": false,
5
5
  "description": "Luvio Cache Control Command",
6
6
  "type": "module",
@@ -31,10 +31,10 @@
31
31
  "watch": "npm run build --watch"
32
32
  },
33
33
  "dependencies": {
34
- "@conduit-client/command-base": "2.0.1",
35
- "@conduit-client/service-cache-control": "2.0.1",
36
- "@conduit-client/service-instrumentation": "2.0.1",
37
- "@conduit-client/utils": "2.0.1"
34
+ "@conduit-client/command-base": "2.1.0",
35
+ "@conduit-client/service-cache-control": "2.1.0",
36
+ "@conduit-client/service-instrumentation": "2.1.0",
37
+ "@conduit-client/utils": "2.1.0"
38
38
  },
39
39
  "volta": {
40
40
  "extends": "../../../../package.json"