@lage-run/cache 1.4.2 → 1.4.4

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/CHANGELOG.json CHANGED
@@ -1,6 +1,35 @@
1
1
  {
2
2
  "name": "@lage-run/cache",
3
3
  "entries": [
4
+ {
5
+ "date": "Sat, 24 Jan 2026 09:00:58 GMT",
6
+ "version": "1.4.4",
7
+ "tag": "@lage-run/cache_v1.4.4",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "elcraig@microsoft.com",
12
+ "package": "@lage-run/cache",
13
+ "commit": "092607a7d55561a9342ab3265ccab0142dd59b9b",
14
+ "comment": "Add explicit module boundary types and update typescript version"
15
+ },
16
+ {
17
+ "author": "elcraig@microsoft.com",
18
+ "package": "@lage-run/cache",
19
+ "commit": "092607a7d55561a9342ab3265ccab0142dd59b9b",
20
+ "comment": "Bump and pin dependencies locally, but unpin them when the package is published"
21
+ }
22
+ ],
23
+ "none": [
24
+ {
25
+ "author": "elcraig@microsoft.com",
26
+ "package": "@lage-run/cache",
27
+ "commit": "092607a7d55561a9342ab3265ccab0142dd59b9b",
28
+ "comment": "Update internal types and docs"
29
+ }
30
+ ]
31
+ }
32
+ },
4
33
  {
5
34
  "date": "Fri, 10 Oct 2025 07:48:07 GMT",
6
35
  "version": "1.4.1",
package/CHANGELOG.md CHANGED
@@ -1,9 +1,18 @@
1
1
  # Change Log - @lage-run/cache
2
2
 
3
- <!-- This log was last generated on Fri, 10 Oct 2025 07:48:07 GMT and should not be manually modified. -->
3
+ <!-- This log was last generated on Sat, 24 Jan 2026 09:00:58 GMT and should not be manually modified. -->
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 1.4.4
8
+
9
+ Sat, 24 Jan 2026 09:00:58 GMT
10
+
11
+ ### Patches
12
+
13
+ - Add explicit module boundary types and update typescript version (elcraig@microsoft.com)
14
+ - Bump and pin dependencies locally, but unpin them when the package is published (elcraig@microsoft.com)
15
+
7
16
  ## 1.4.1
8
17
 
9
18
  Fri, 10 Oct 2025 07:48:07 GMT
package/README.md CHANGED
@@ -9,13 +9,14 @@ This package provides:
9
9
 
10
10
  ```ts
11
11
  import { BackfillCacheProvider, RemoteFallbackCacheProvider, TargetHasher } from "@lage-run/cache";
12
+ import { getWorkspaceManagerRoot } from "workspace-tools";
12
13
 
13
14
  const cacheOptions = {
14
15
  internalCacheFolder: ".cache",
15
16
  outputGlob: ["dist/**", "lib/**"]
16
17
  }
17
18
 
18
- const root = getWorkspaceRoot(cwd);
19
+ const root = getWorkspaceManagerRoot(cwd);
19
20
 
20
21
  const remoteFallbackCacheProviderOptions = {
21
22
  root,
@@ -1,25 +1,8 @@
1
1
  /**
2
2
  * Backfill wrappers: some functions that uses the `backfill` library that doesn't require them to be inside a class
3
3
  */
4
+ import { type Config } from "backfill-config";
4
5
  import type { Logger as BackfillLogger } from "backfill-logger";
5
6
  import type { CacheOptions } from "@lage-run/config";
6
7
  export declare function createBackfillLogger(): BackfillLogger;
7
- export declare function createBackfillCacheConfig(cwd: string, cacheOptions: Partial<CacheOptions> | undefined, backfillLogger: BackfillLogger): {
8
- cacheStorageConfig: import("backfill-config").CacheStorageConfig;
9
- outputGlob: string[];
10
- clearOutput: boolean;
11
- internalCacheFolder: string;
12
- logFolder: string;
13
- logLevel: "silly" | "verbose" | "info" | "warn" | "error" | "mute";
14
- name: string;
15
- mode: "READ_ONLY" | "WRITE_ONLY" | "READ_WRITE" | "PASS";
16
- packageRoot: string;
17
- producePerformanceLogs: boolean;
18
- validateOutput: boolean;
19
- incrementalCaching: boolean;
20
- performanceReportName?: string | undefined;
21
- writeRemoteCache?: boolean | undefined;
22
- skipLocalCache?: boolean | undefined;
23
- environmentGlob?: string[] | undefined;
24
- cacheKey?: string | undefined;
25
- };
8
+ export declare function createBackfillCacheConfig(cwd: string, cacheOptions: Partial<CacheOptions> | undefined, backfillLogger: BackfillLogger): Config;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/backfillWrapper.ts"],"sourcesContent":["/**\n * Backfill wrappers: some functions that uses the `backfill` library that doesn't require them to be inside a class\n */\n\nimport * as os from \"os\";\nimport { createDefaultConfig, getEnvConfig } from \"backfill-config\";\nimport { makeLogger } from \"backfill-logger\";\nimport type { Logger as BackfillLogger } from \"backfill-logger\";\nimport type { CacheOptions } from \"@lage-run/config\";\nimport type { AzureCredentialName } from \"@lage-run/config\";\nimport { CredentialCache } from \"./CredentialCache.js\";\n\nexport function createBackfillLogger() {\n const stdout = process.stdout;\n const stderr = process.stderr;\n return makeLogger(\"error\", {\n console: {\n info(...args) {\n stdout.write(args.join(\" \") + os.EOL);\n },\n warn(...args) {\n stderr.write(args.join(\" \") + os.EOL);\n },\n error(...args) {\n stderr.write(args.join(\" \") + os.EOL);\n },\n },\n });\n}\n\nexport function createBackfillCacheConfig(cwd: string, cacheOptions: Partial<CacheOptions> = {}, backfillLogger: BackfillLogger) {\n const envConfig = getEnvConfig(backfillLogger);\n const mergedConfig = {\n ...createDefaultConfig(cwd),\n ...cacheOptions,\n ...envConfig,\n };\n\n if (mergedConfig.cacheStorageConfig.provider === \"azure-blob\") {\n const azureOptions = mergedConfig.cacheStorageConfig.options;\n if (\"connectionString\" in azureOptions && !isTokenConnectionString(azureOptions.connectionString)) {\n /** Pass through optional credentialName from config to select a specific credential implementation\n * Type assertion: only the connection-string variant is augmented with credentialName in @lage-run/config\n */\n const name = (azureOptions as { credentialName?: AzureCredentialName }).credentialName as string | undefined;\n if (name != null) {\n if (!CredentialCache.credentialNames.includes(name as AzureCredentialName)) {\n throw new Error(\n `Invalid cacheStorageConfig.options.credentialName: \"${name}\". Allowed values: ${CredentialCache.credentialNames.join(\", \")}`\n );\n }\n azureOptions.credential = CredentialCache.getInstance(name as AzureCredentialName);\n } else {\n /** No name provided in config: if env var AZURE_IDENTITY_CREDENTIAL_NAME is set, honor it; otherwise default to EnvironmentCredential\n */\n const envName = process.env.AZURE_IDENTITY_CREDENTIAL_NAME as string | undefined;\n if (envName != null) {\n if (!CredentialCache.credentialNames.includes(envName as AzureCredentialName)) {\n throw new Error(\n `Invalid AZURE_IDENTITY_CREDENTIAL_NAME: \"${envName}\". Allowed values: ${CredentialCache.credentialNames.join(\", \")}`\n );\n }\n azureOptions.credential = CredentialCache.getInstance(envName as AzureCredentialName);\n } else {\n // Fall back to EnvironmentCredential\n azureOptions.credential = CredentialCache.getInstance();\n }\n }\n }\n }\n\n return mergedConfig;\n}\n\nfunction isTokenConnectionString(connectionString: string) {\n return connectionString.includes(\"SharedAccessSignature\") || connectionString.includes(\"AccountKey\");\n}\n"],"names":["createBackfillCacheConfig","createBackfillLogger","stdout","process","stderr","makeLogger","console","info","args","write","join","os","EOL","warn","error","cwd","cacheOptions","backfillLogger","envConfig","getEnvConfig","mergedConfig","createDefaultConfig","cacheStorageConfig","provider","azureOptions","options","isTokenConnectionString","connectionString","name","credentialName","CredentialCache","credentialNames","includes","Error","credential","getInstance","envName","env","AZURE_IDENTITY_CREDENTIAL_NAME"],"mappings":"AAAA;;CAEC;;;;;;;;;;;QA4BeA;eAAAA;;QAlBAC;eAAAA;;;4DARI;gCAC8B;gCACvB;iCAIK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzB,SAASA;IACd,MAAMC,SAASC,QAAQD,MAAM;IAC7B,MAAME,SAASD,QAAQC,MAAM;IAC7B,OAAOC,IAAAA,0BAAU,EAAC,SAAS;QACzBC,SAAS;YACPC,MAAK,GAAGC,IAAI;gBACVN,OAAOO,KAAK,CAACD,KAAKE,IAAI,CAAC,OAAOC,IAAGC,GAAG;YACtC;YACAC,MAAK,GAAGL,IAAI;gBACVJ,OAAOK,KAAK,CAACD,KAAKE,IAAI,CAAC,OAAOC,IAAGC,GAAG;YACtC;YACAE,OAAM,GAAGN,IAAI;gBACXJ,OAAOK,KAAK,CAACD,KAAKE,IAAI,CAAC,OAAOC,IAAGC,GAAG;YACtC;QACF;IACF;AACF;AAEO,SAASZ,0BAA0Be,GAA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QAAQ,CAAC;AACzF"}
1
+ {"version":3,"sources":["../src/backfillWrapper.ts"],"sourcesContent":["/**\n * Backfill wrappers: some functions that uses the `backfill` library that doesn't require them to be inside a class\n */\n\nimport * as os from \"os\";\nimport { type Config, createDefaultConfig, getEnvConfig } from \"backfill-config\";\nimport { makeLogger } from \"backfill-logger\";\nimport type { Logger as BackfillLogger } from \"backfill-logger\";\nimport type { CacheOptions } from \"@lage-run/config\";\nimport type { AzureCredentialName } from \"@lage-run/config\";\nimport { CredentialCache } from \"./CredentialCache.js\";\n\nexport function createBackfillLogger(): BackfillLogger {\n const stdout = process.stdout;\n const stderr = process.stderr;\n return makeLogger(\"error\", {\n console: {\n info(...args) {\n stdout.write(args.join(\" \") + os.EOL);\n },\n warn(...args) {\n stderr.write(args.join(\" \") + os.EOL);\n },\n error(...args) {\n stderr.write(args.join(\" \") + os.EOL);\n },\n },\n });\n}\n\nexport function createBackfillCacheConfig(\n cwd: string,\n cacheOptions: Partial<CacheOptions> | undefined = {},\n backfillLogger: BackfillLogger\n): Config {\n const envConfig = getEnvConfig(backfillLogger);\n const mergedConfig = {\n ...createDefaultConfig(cwd),\n ...cacheOptions,\n ...envConfig,\n } as Config;\n\n if (mergedConfig.cacheStorageConfig.provider === \"azure-blob\") {\n const azureOptions = mergedConfig.cacheStorageConfig.options;\n if (\"connectionString\" in azureOptions && !isTokenConnectionString(azureOptions.connectionString)) {\n /** Pass through optional credentialName from config to select a specific credential implementation\n * Type assertion: only the connection-string variant is augmented with credentialName in @lage-run/config\n */\n const name = (azureOptions as { credentialName?: AzureCredentialName }).credentialName as string | undefined;\n if (name != null) {\n if (!CredentialCache.credentialNames.includes(name as AzureCredentialName)) {\n throw new Error(\n `Invalid cacheStorageConfig.options.credentialName: \"${name}\". Allowed values: ${CredentialCache.credentialNames.join(\", \")}`\n );\n }\n azureOptions.credential = CredentialCache.getInstance(name as AzureCredentialName);\n } else {\n /** No name provided in config: if env var AZURE_IDENTITY_CREDENTIAL_NAME is set, honor it; otherwise default to EnvironmentCredential\n */\n const envName = process.env.AZURE_IDENTITY_CREDENTIAL_NAME as string | undefined;\n if (envName != null) {\n if (!CredentialCache.credentialNames.includes(envName as AzureCredentialName)) {\n throw new Error(\n `Invalid AZURE_IDENTITY_CREDENTIAL_NAME: \"${envName}\". Allowed values: ${CredentialCache.credentialNames.join(\", \")}`\n );\n }\n azureOptions.credential = CredentialCache.getInstance(envName as AzureCredentialName);\n } else {\n // Fall back to EnvironmentCredential\n azureOptions.credential = CredentialCache.getInstance();\n }\n }\n }\n }\n\n return mergedConfig;\n}\n\nfunction isTokenConnectionString(connectionString: string) {\n return connectionString.includes(\"SharedAccessSignature\") || connectionString.includes(\"AccountKey\");\n}\n"],"names":["createBackfillCacheConfig","createBackfillLogger","stdout","process","stderr","makeLogger","console","info","args","write","join","os","EOL","warn","error","cwd","cacheOptions","backfillLogger","envConfig","getEnvConfig","mergedConfig","createDefaultConfig","cacheStorageConfig","provider","azureOptions","options","isTokenConnectionString","connectionString","name","credentialName","CredentialCache","credentialNames","includes","Error","credential","getInstance","envName","env","AZURE_IDENTITY_CREDENTIAL_NAME"],"mappings":"AAAA;;CAEC;;;;;;;;;;;QA4BeA;eAAAA;;QAlBAC;eAAAA;;;4DARI;gCAC2C;gCACpC;iCAIK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzB,SAASA;IACd,MAAMC,SAASC,QAAQD,MAAM;IAC7B,MAAME,SAASD,QAAQC,MAAM;IAC7B,OAAOC,IAAAA,0BAAU,EAAC,SAAS;QACzBC,SAAS;YACPC,MAAK,GAAGC,IAAI;gBACVN,OAAOO,KAAK,CAACD,KAAKE,IAAI,CAAC,OAAOC,IAAGC,GAAG;YACtC;YACAC,MAAK,GAAGL,IAAI;gBACVJ,OAAOK,KAAK,CAACD,KAAKE,IAAI,CAAC,OAAOC,IAAGC,GAAG;YACtC;YACAE,OAAM,GAAGN,IAAI;gBACXJ,OAAOK,KAAK,CAACD,KAAKE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M,wBAAwBC,gBAAwB;IACvD,OAAOA,iBAAiBK,QAAQ,CAAC,4BAA4BL,iBAAiBK,QAAQ,CAAC;AACzF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/chunkPromise.ts"],"sourcesContent":["type PromiseFn = () => Promise<unknown>;\n\nexport async function chunkPromise(promises: (Promise<unknown> | PromiseFn)[], limit = 5) {\n for (let i = 0; i < promises.length; i += limit) {\n await Promise.all(promises.slice(i, i + limit).map((p) => (typeof p === \"function\" ? p() : p)));\n }\n}\n"],"names":["chunkPromise","promises","limit","i","length","Promise","all","slice","map","p"],"mappings":";;;;+BAEsBA;;;eAAAA;;;AAAf,eAAeA,aAAaC,QAA0C,EAAEC,QAAQ,CAAC;IACtF,IAAK,IAAIC,IAAI,GAAGA,IAAIF,SAASG,MAAM,EAAED,KAAKD,MAAO;QAC/C,MAAMG,QAAQC,GAAG,CAACL,SAASM,KAAK,CAACJ,GAAGA,IAAID,OAAOM,GAAG,CAAC,CAACC,IAAO,OAAOA,MAAM,aAAaA,MAAMA;IAC7F;AACF"}
1
+ {"version":3,"sources":["../src/chunkPromise.ts"],"sourcesContent":["type PromiseFn = () => Promise<unknown>;\n\nexport async function chunkPromise(promises: (Promise<unknown> | PromiseFn)[], limit = 5): Promise<void> {\n for (let i = 0; i < promises.length; i += limit) {\n await Promise.all(promises.slice(i, i + limit).map((p) => (typeof p === \"function\" ? p() : p)));\n }\n}\n"],"names":["chunkPromise","promises","limit","i","length","Promise","all","slice","map","p"],"mappings":";;;;+BAEsBA;;;eAAAA;;;AAAf,eAAeA,aAAaC,QAA0C,EAAEC,QAAQ,CAAC;IACtF,IAAK,IAAIC,IAAI,GAAGA,IAAIF,SAASG,MAAM,EAAED,KAAKD,MAAO;QAC/C,MAAMG,QAAQC,GAAG,CAACL,SAASM,KAAK,CAACJ,GAAGA,IAAID,OAAOM,GAAG,CAAC,CAACC,IAAO,OAAOA,MAAM,aAAaA,MAAMA;IAC7F;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/getCacheDirectory.ts"],"sourcesContent":["import path from \"path\";\n\nexport function getCacheDirectoryRoot(root: string) {\n return path.join(root, \"node_modules\", \".cache\", \"lage\");\n}\n\nexport function getCacheDirectory(root: string, hash: string) {\n return path.join(getCacheDirectoryRoot(root), \"cache\", hash.substring(0, 4));\n}\n\nexport function getLogsCacheDirectory(root: string, hash: string) {\n return path.join(getCacheDirectoryRoot(root), \"logs\", hash.substring(0, 4));\n}\n"],"names":["getCacheDirectory","getCacheDirectoryRoot","getLogsCacheDirectory","root","path","join","hash","substring"],"mappings":";;;;;;;;;;;QAMgBA;eAAAA;;QAJAC;eAAAA;;QAQAC;eAAAA;;;6DAVC;;;;;;AAEV,SAASD,sBAAsBE,IAAY;IAChD,OAAOC,aAAI,CAACC,IAAI,CAACF,MAAM,gBAAgB,UAAU;AACnD;AAEO,SAASH,kBAAkBG,IAAY,EAAEG,IAAY;IAC1D,OAAOF,aAAI,CAACC,IAAI,CAACJ,sBAAsBE,OAAO,SAASG,KAAKC,SAAS,CAAC,GAAG;AAC3E;AAEO,SAASL,sBAAsBC,IAAY,EAAEG,IAAY;IAC9D,OAAOF,aAAI,CAACC,IAAI,CAACJ,sBAAsBE,OAAO,QAAQG,KAAKC,SAAS,CAAC,GAAG;AAC1E"}
1
+ {"version":3,"sources":["../src/getCacheDirectory.ts"],"sourcesContent":["import path from \"path\";\n\nexport function getCacheDirectoryRoot(root: string): string {\n return path.join(root, \"node_modules\", \".cache\", \"lage\");\n}\n\nexport function getCacheDirectory(root: string, hash: string): string {\n return path.join(getCacheDirectoryRoot(root), \"cache\", hash.substring(0, 4));\n}\n\nexport function getLogsCacheDirectory(root: string, hash: string): string {\n return path.join(getCacheDirectoryRoot(root), \"logs\", hash.substring(0, 4));\n}\n"],"names":["getCacheDirectory","getCacheDirectoryRoot","getLogsCacheDirectory","root","path","join","hash","substring"],"mappings":";;;;;;;;;;;QAMgBA;eAAAA;;QAJAC;eAAAA;;QAQAC;eAAAA;;;6DAVC;;;;;;AAEV,SAASD,sBAAsBE,IAAY;IAChD,OAAOC,aAAI,CAACC,IAAI,CAACF,MAAM,gBAAgB,UAAU;AACnD;AAEO,SAASH,kBAAkBG,IAAY,EAAEG,IAAY;IAC1D,OAAOF,aAAI,CAACC,IAAI,CAACJ,sBAAsBE,OAAO,SAASG,KAAKC,SAAS,CAAC,GAAG;AAC3E;AAEO,SAASL,sBAAsBC,IAAY,EAAEG,IAAY;IAC9D,OAAOF,aAAI,CAACC,IAAI,CAACJ,sBAAsBE,OAAO,QAAQG,KAAKC,SAAS,CAAC,GAAG;AAC1E"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/providers/BackfillCacheProvider.ts"],"sourcesContent":["import { createBackfillCacheConfig, createBackfillLogger } from \"../backfillWrapper.js\";\nimport { getCacheStorageProvider } from \"backfill-cache\";\nimport { promisify } from \"util\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport type { CacheProvider } from \"../types/CacheProvider.js\";\nimport type { CacheOptions } from \"@lage-run/config\";\nimport type { Logger as BackfillLogger } from \"backfill-logger\";\nimport type { Target } from \"@lage-run/target-graph\";\nimport type { Logger } from \"@lage-run/logger\";\nimport { getCacheDirectory, getCacheDirectoryRoot } from \"../getCacheDirectory.js\";\nimport { chunkPromise } from \"../chunkPromise.js\";\n\nconst rm = promisify(fs.rm);\nconst readdir = promisify(fs.readdir);\nconst stat = promisify(fs.stat);\n\nconst MS_IN_A_DAY = 1000 * 60 * 60 * 24;\n\nexport interface BackfillCacheProviderOptions {\n root: string;\n logger: Logger;\n cacheOptions: Partial<CacheOptions>;\n}\n\nexport class BackfillCacheProvider implements CacheProvider {\n /**\n * logger for backfill\n */\n private backfillLogger: BackfillLogger;\n\n private getTargetCacheStorageProvider(cwd: string, hash: string) {\n const { cacheOptions } = this.options;\n const { cacheStorageConfig, incrementalCaching } = createBackfillCacheConfig(cwd, cacheOptions, this.backfillLogger);\n\n const cachePath = this.getCachePath(cwd, hash);\n\n return getCacheStorageProvider(cacheStorageConfig ?? { provider: \"local\" }, cachePath, this.backfillLogger, cwd, incrementalCaching);\n }\n\n constructor(private options: BackfillCacheProviderOptions) {\n this.backfillLogger = createBackfillLogger();\n }\n\n async fetch(hash: string, target: Target): Promise<boolean> {\n const { logger } = this.options;\n\n if (!hash) {\n return false;\n }\n\n const cacheStorage = this.getTargetCacheStorageProvider(target.cwd, hash);\n\n try {\n return await cacheStorage.fetch(hash);\n } catch (error) {\n let message;\n\n if (error instanceof Error) {\n message = error.message;\n } else message = String(error);\n\n logger.silly(`Cache fetch failed: ${message}`, { target });\n\n // backfill fetch can error, but we should simply ignore and continue\n return false;\n }\n }\n\n async put(hash: string, target: Target): Promise<void> {\n const { logger } = this.options;\n\n if (!hash) {\n return;\n }\n\n const cacheStorage = this.getTargetCacheStorageProvider(target.cwd, hash);\n\n try {\n await cacheStorage.put(hash, target.outputs ?? this.options.cacheOptions.outputGlob ?? [\"**/*\"]);\n } catch (error) {\n let message;\n\n if (error instanceof Error) {\n message = error.message;\n } else message = String(error);\n\n logger.silly(`Cache fetch failed: ${message}`, { target });\n\n // backfill throws an error if outputGlob doesn't match any files, we will skip this error\n }\n }\n\n async clear(concurrency = 10): Promise<void> {\n return this.purge(0, concurrency);\n }\n\n async purge(prunePeriod = 30, concurrency = 10): Promise<void> {\n const now = new Date();\n\n const cacheTypes = [\"cache\", \"logs\"];\n const entries: string[] = [];\n\n for (const cacheType of cacheTypes) {\n const cacheTypeDirectory = path.join(getCacheDirectoryRoot(this.options.root), cacheType);\n if (fs.existsSync(cacheTypeDirectory)) {\n const hashPrefixes = await readdir(cacheTypeDirectory);\n for (const prefix of hashPrefixes) {\n const cachePath = path.join(cacheTypeDirectory, prefix);\n entries.push(cachePath);\n }\n }\n }\n\n await chunkPromise(\n entries.map((entry) => {\n return async () => {\n const entryPath = entry;\n const entryStat = await stat(entryPath);\n\n if (now.getTime() - entryStat.mtime.getTime() > prunePeriod * MS_IN_A_DAY) {\n await removeCache(entryPath, entryStat);\n }\n };\n }),\n concurrency\n );\n }\n\n getCachePath(packagePath: string, hash: string) {\n return path.relative(packagePath, getCacheDirectory(this.options.root, hash));\n }\n}\n\nasync function removeCache(cachePath: string, entryStat: fs.Stats) {\n if (entryStat.isDirectory()) {\n return rm(cachePath, { recursive: true });\n } else {\n return rm(cachePath);\n }\n}\n"],"names":["BackfillCacheProvider","rm","promisify","fs","readdir","stat","MS_IN_A_DAY","getTargetCacheStorageProvider","cwd","hash","cacheOptions","options","cacheStorageConfig","incrementalCaching","createBackfillCacheConfig","backfillLogger","cachePath","getCachePath","getCacheStorageProvider","provider","fetch","target","logger","cacheStorage","error","message","Error","String","silly","put","outputs","outputGlob","clear","concurrency","purge","prunePeriod","now","Date","cacheTypes","entries","cacheType","cacheTypeDirectory","path","join","getCacheDirectoryRoot","root","existsSync","hashPrefixes","prefix","push","chunkPromise","map","entry","entryPath","entryStat","getTime","mtime","removeCache","packagePath","relative","getCacheDirectory","createBackfillLogger","isDirectory","recursive"],"mappings":";;;;+BAyBaA;;;eAAAA;;;iCAzBmD;+BACxB;sBACd;4DACN;8DACE;mCAMmC;8BAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7B,MAAMC,KAAKC,IAAAA,eAAS,EAACC,IAAGF,EAAE;AAC1B,MAAMG,UAAUF,IAAAA,eAAS,EAACC,IAAGC,OAAO;AACpC,MAAMC,OAAOH,IAAAA,eAAS,EAACC,IAAGE,IAAI;AAE9B,MAAMC,cAAc,OAAO,KAAK,KAAK;AAQ9B,MAAMN;IAMHO,8BAA8BC,GAAW,EAAEC,IAAY,EAAE;QAC/D,MAAM,EAAEC,YAAY,EAAE,GAAG,IAAI,CAACC,OAAO;QACrC,MAAM,EAAEC,kBAAkB,EAAEC,kBAAkB,EAAE,GAAGC,IAAAA,0CAAyB,EAACN,KAAKE,cAAc,IAAI,CAACK,cAAc;QAEnH,MAAMC,YAAY,IAAI,CAACC,YAA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3B,OAAO7D,GAAGe,WAAW;YAAE+C,WAAW;QAAK;IACzC,OAAO;QACL,OAAO9D,GAAGe;IACZ;AACF"}
1
+ {"version":3,"sources":["../../src/providers/BackfillCacheProvider.ts"],"sourcesContent":["import { createBackfillCacheConfig, createBackfillLogger } from \"../backfillWrapper.js\";\nimport { getCacheStorageProvider } from \"backfill-cache\";\nimport { promisify } from \"util\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport type { CacheProvider } from \"../types/CacheProvider.js\";\nimport type { CacheOptions } from \"@lage-run/config\";\nimport type { Logger as BackfillLogger } from \"backfill-logger\";\nimport type { Target } from \"@lage-run/target-graph\";\nimport type { Logger } from \"@lage-run/logger\";\nimport { getCacheDirectory, getCacheDirectoryRoot } from \"../getCacheDirectory.js\";\nimport { chunkPromise } from \"../chunkPromise.js\";\n\nconst rm = promisify(fs.rm);\nconst readdir = promisify(fs.readdir);\nconst stat = promisify(fs.stat);\n\nconst MS_IN_A_DAY = 1000 * 60 * 60 * 24;\n\nexport interface BackfillCacheProviderOptions {\n root: string;\n logger: Logger;\n cacheOptions: Partial<CacheOptions>;\n}\n\nexport class BackfillCacheProvider implements CacheProvider {\n /**\n * logger for backfill\n */\n private backfillLogger: BackfillLogger;\n\n private getTargetCacheStorageProvider(cwd: string, hash: string) {\n const { cacheOptions } = this.options;\n const { cacheStorageConfig, incrementalCaching } = createBackfillCacheConfig(cwd, cacheOptions, this.backfillLogger);\n\n const cachePath = this.getCachePath(cwd, hash);\n\n return getCacheStorageProvider(cacheStorageConfig ?? { provider: \"local\" }, cachePath, this.backfillLogger, cwd, incrementalCaching);\n }\n\n constructor(private options: BackfillCacheProviderOptions) {\n this.backfillLogger = createBackfillLogger();\n }\n\n async fetch(hash: string, target: Target): Promise<boolean> {\n const { logger } = this.options;\n\n if (!hash) {\n return false;\n }\n\n const cacheStorage = this.getTargetCacheStorageProvider(target.cwd, hash);\n\n try {\n return await cacheStorage.fetch(hash);\n } catch (error) {\n let message;\n\n if (error instanceof Error) {\n message = error.message;\n } else message = String(error);\n\n logger.silly(`Cache fetch failed: ${message}`, { target });\n\n // backfill fetch can error, but we should simply ignore and continue\n return false;\n }\n }\n\n async put(hash: string, target: Target): Promise<void> {\n const { logger } = this.options;\n\n if (!hash) {\n return;\n }\n\n const cacheStorage = this.getTargetCacheStorageProvider(target.cwd, hash);\n\n try {\n await cacheStorage.put(hash, target.outputs ?? this.options.cacheOptions.outputGlob ?? [\"**/*\"]);\n } catch (error) {\n let message;\n\n if (error instanceof Error) {\n message = error.message;\n } else message = String(error);\n\n logger.silly(`Cache fetch failed: ${message}`, { target });\n\n // backfill throws an error if outputGlob doesn't match any files, we will skip this error\n }\n }\n\n async clear(concurrency = 10): Promise<void> {\n return this.purge(0, concurrency);\n }\n\n async purge(prunePeriod = 30, concurrency = 10): Promise<void> {\n const now = new Date();\n\n const cacheTypes = [\"cache\", \"logs\"];\n const entries: string[] = [];\n\n for (const cacheType of cacheTypes) {\n const cacheTypeDirectory = path.join(getCacheDirectoryRoot(this.options.root), cacheType);\n if (fs.existsSync(cacheTypeDirectory)) {\n const hashPrefixes = await readdir(cacheTypeDirectory);\n for (const prefix of hashPrefixes) {\n const cachePath = path.join(cacheTypeDirectory, prefix);\n entries.push(cachePath);\n }\n }\n }\n\n await chunkPromise(\n entries.map((entry) => {\n return async () => {\n const entryPath = entry;\n const entryStat = await stat(entryPath);\n\n if (now.getTime() - entryStat.mtime.getTime() > prunePeriod * MS_IN_A_DAY) {\n await removeCache(entryPath, entryStat);\n }\n };\n }),\n concurrency\n );\n }\n\n getCachePath(packagePath: string, hash: string): string {\n return path.relative(packagePath, getCacheDirectory(this.options.root, hash));\n }\n}\n\nasync function removeCache(cachePath: string, entryStat: fs.Stats) {\n if (entryStat.isDirectory()) {\n return rm(cachePath, { recursive: true });\n } else {\n return rm(cachePath);\n }\n}\n"],"names":["BackfillCacheProvider","rm","promisify","fs","readdir","stat","MS_IN_A_DAY","getTargetCacheStorageProvider","cwd","hash","cacheOptions","options","cacheStorageConfig","incrementalCaching","createBackfillCacheConfig","backfillLogger","cachePath","getCachePath","getCacheStorageProvider","provider","fetch","target","logger","cacheStorage","error","message","Error","String","silly","put","outputs","outputGlob","clear","concurrency","purge","prunePeriod","now","Date","cacheTypes","entries","cacheType","cacheTypeDirectory","path","join","getCacheDirectoryRoot","root","existsSync","hashPrefixes","prefix","push","chunkPromise","map","entry","entryPath","entryStat","getTime","mtime","removeCache","packagePath","relative","getCacheDirectory","createBackfillLogger","isDirectory","recursive"],"mappings":";;;;+BAyBaA;;;eAAAA;;;iCAzBmD;+BACxB;sBACd;4DACN;8DACE;mCAMmC;8BAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7B,MAAMC,KAAKC,IAAAA,eAAS,EAACC,IAAGF,EAAE;AAC1B,MAAMG,UAAUF,IAAAA,eAAS,EAACC,IAAGC,OAAO;AACpC,MAAMC,OAAOH,IAAAA,eAAS,EAACC,IAAGE,IAAI;AAE9B,MAAMC,cAAc,OAAO,KAAK,KAAK;AAQ9B,MAAMN;IAMHO,8BAA8BC,GAAW,EAAEC,IAAY,EAAE;QAC/D,MAAM,EAAEC,YAAY,EAAE,GAAG,IAAI,CAACC,OAAO;QACrC,MAAM,EAAEC,kBAAkB,EAAEC,kBAAkB,EAAE,GAAGC,IAAAA,0CAAyB,EAACN,KAAKE,cAAc,IAAI,CAACK,cAAc;QAEnH,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACT,KAAKC;QAEzC,OAAOS,IAAAA,sCAAuB,EAACN,sBAAsB;YAAEO,UAAU;QAAQ,GAAGH,WAAW,IAAI,CAACD,cAAc,EAAEP,KAAKK;IACnH;IAMA,MAAMO,MAAMX,IAAY,EAAEY,MAAc,EAAoB;QAC1D,MAAM,EAAEC,MAAM,EAAE,GAAG,IAAI,CAACX,OAAO;QAE/B,IAAI,CAACF,MAAM;YACT,OAAO;QACT;QAEA,MAAMc,eAAe,IAAI,C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AC,IAAI,CAACjC,OAAO,CAACkC,IAAI,GAAGL;YAC/E,IAAIrC,IAAG2C,UAAU,CAACL,qBAAqB;gBACrC,MAAMM,eAAe,MAAM3C,QAAQqC;gBACnC,KAAK,MAAMO,UAAUD,aAAc;oBACjC,MAAM/B,YAAY0B,MAAKC,IAAI,CAACF,oBAAoBO;oBAChDT,QAAQU,IAAI,CAACjC;gBACf;YACF;QACF;QAEA,MAAMkC,IAAAA,0BAAY,EAChBX,QAAQY,GAAG,CAAC,CAACC;YACX,OAAO;gBACL,MAAMC,YAAYD;gBAClB,MAAME,YAAY,MAAMjD,KAAKgD;gBAE7B,IAAIjB,IAAImB,OAAO,KAAKD,UAAUE,KAAK,CAACD,OAAO,KAAKpB,cAAc7B,aAAa;oBACzE,MAAMmD,YAAYJ,WAAWC;gBAC/B;YACF;QACF,IACArB;IAEJ;IAEAhB,aAAayC,WAAmB,EAAEjD,IAAY,EAAU;QACtD,OAAOiC,MAAKiB,QAAQ,CAACD,aAAaE,IAAAA,oCAAiB,EAAC,IAAI,CAACjD,OAAO,CAACkC,IAAI,EAAEpC;IACzE;IA3FA,YAAY,AAAQE,OAAqC,CAAE;;QAd3D;;GAEC,GACD,uBAAQI,kBAAR,KAAA;aAWoBJ,UAAAA;QAClB,IAAI,CAACI,cAAc,GAAG8C,IAAAA,qCAAoB;IAC5C;AA0FF;AAEA,eAAeJ,YAAYzC,SAAiB,EAAEsC,SAAmB;IAC/D,IAAIA,UAAUQ,WAAW,IAAI;QAC3B,OAAO7D,GAAGe,WAAW;YAAE+C,WAAW;QAAK;IACzC,OAAO;QACL,OAAO9D,GAAGe;IACZ;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/providers/RemoteFallbackCacheProvider.ts"],"sourcesContent":["import type { CacheProvider } from \"../types/CacheProvider.js\";\nimport type { Logger } from \"@lage-run/logger\";\nimport type { Target } from \"@lage-run/target-graph\";\n\nexport interface RemoteFallbackCacheProviderOptions {\n root: string;\n logger: Logger;\n\n localCacheProvider?: CacheProvider;\n remoteCacheProvider?: CacheProvider;\n\n writeRemoteCache?: boolean;\n}\n\n/**\n * Remote Fallback Cache Provider\n *\n * This backfill cache provider will fallback to a remote cache provider if the local cache does not contain the item.\n * It will also automatically populate the local cache with the remote cache.\n */\nexport class RemoteFallbackCacheProvider implements CacheProvider {\n private static localHits: { [hash: string]: boolean } = {};\n private static remoteHits: { [hash: string]: boolean } = {};\n\n constructor(private options: RemoteFallbackCacheProviderOptions) {}\n\n async fetch(hash: string, target: Target) {\n const { logger, remoteCacheProvider, localCacheProvider } = this.options;\n\n if (localCacheProvider) {\n RemoteFallbackCacheProvider.localHits[hash] = await localCacheProvider.fetch(hash, target);\n logger.silly(`local cache fetch: ${hash} ${RemoteFallbackCacheProvider.localHits[hash]}`);\n }\n\n if (!RemoteFallbackCacheProvider.localHits[hash] && remoteCacheProvider) {\n RemoteFallbackCacheProvider.remoteHits[hash] = await remoteCacheProvider.fetch(hash, target);\n logger.silly(`remote fallback fetch: ${hash} ${RemoteFallbackCacheProvider.remoteHits[hash]}`);\n\n // now save this into the localCacheProvider, if available\n if (localCacheProvider && RemoteFallbackCacheProvider.remoteHits[hash]) {\n logger.silly(`local cache put, fetched cache from remote: ${hash}`);\n await localCacheProvider.put(hash, target);\n }\n\n return RemoteFallbackCacheProvider.remoteHits[hash];\n }\n\n return RemoteFallbackCacheProvider.localHits[hash];\n }\n\n async put(hash: string, target: Target) {\n const { logger, remoteCacheProvider, localCacheProvider, writeRemoteCache } = this.options;\n const putPromises: Promise<void>[] = [];\n\n // Write local cache if it doesn't already exist, or if the the hash isn't in the localHits\n const shouldWriteLocalCache = !this.isLocalHit(hash) && !!localCacheProvider;\n\n if (shouldWriteLocalCache) {\n logger.silly(`local cache put: ${hash}`);\n putPromises.push(localCacheProvider.put(hash, target));\n }\n\n // Write to remote if there is a no hit in the remote cache, and remote cache storage provider, and that the \"writeRemoteCache\" config flag is set to true\n const shouldWriteRemoteCache = !this.isRemoteHit(hash) && !!remoteCacheProvider && writeRemoteCache;\n\n if (shouldWriteRemoteCache) {\n logger.silly(`remote fallback put: ${hash}`);\n const remotePut = remoteCacheProvider.put(hash, target);\n putPromises.push(remotePut);\n }\n\n await Promise.all(putPromises);\n }\n\n private isRemoteHit(hash) {\n return hash in RemoteFallbackCacheProvider.remoteHits && RemoteFallbackCacheProvider.remoteHits[hash];\n }\n\n private isLocalHit(hash) {\n return hash in RemoteFallbackCacheProvider.localHits && RemoteFallbackCacheProvider.localHits[hash];\n }\n\n async clear(): Promise<void> {\n const { localCacheProvider } = this.options;\n if (localCacheProvider) {\n return localCacheProvider.clear();\n }\n }\n\n async purge(sinceDays: number): Promise<void> {\n const { localCacheProvider } = this.options;\n if (localCacheProvider) {\n return localCacheProvider.purge(sinceDays);\n }\n }\n}\n"],"names":["RemoteFallbackCacheProvider","fetch","hash","target","logger","remoteCacheProvider","localCacheProvider","options","localHits","silly","remoteHits","put","writeRemoteCache","putPromises","shouldWriteLocalCache","isLocalHit","push","shouldWriteRemoteCache","isRemoteHit","remotePut","Promise","all","clear","purge","sinceDays"],"mappings":";;;;+BAoBaA;;;eAAAA;;;;;;;;;;;;;;;;AAAN,MAAMA;IAMX,MAAMC,MAAMC,IAAY,EAAEC,MAAc,EAAE;QACxC,MAAM,EAAEC,MAAM,EAAEC,mBAAmB,EAAEC,kBAAkB,EAAE,GAAG,IAAI,CAACC,OAAO;QAExE,IAAID,oBAAoB;YACtBN,4BAA4BQ,SAAS,CAACN,KAAK,GAAG,MAAMI,mBAAmBL,KAAK,CAACC,MAAMC;YACnFC,OAAOK,KAAK,CAAC,CAAC,mBAAmB,EAAEP,KAAK,CAAC,EAAEF,4BAA4BQ,SAAS,CAACN,KAAK,EAAE;QAC1F;QAEA,IAAI,CAACF,4BAA4BQ,SAAS,CAACN,KAAK,IAAIG,qBAAqB;YACvEL,4BAA4BU,UAAU,CAACR,KAAK,GAAG,MAAMG,oBAAoBJ,KAAK,CAACC,MAAMC;YACrFC,OAAOK,K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,4BAA4BQ,SAAS,CAACN,KAAK;IACrG;IAEA,MAAMoB,QAAuB;QAC3B,MAAM,EAAEhB,kBAAkB,EAAE,GAAG,IAAI,CAACC,OAAO;QAC3C,IAAID,oBAAoB;YACtB,OAAOA,mBAAmBgB,KAAK;QACjC;IACF;IAEA,MAAMC,MAAMC,SAAiB,EAAiB;QAC5C,MAAM,EAAElB,kBAAkB,EAAE,GAAG,IAAI,CAACC,OAAO;QAC3C,IAAID,oBAAoB;YACtB,OAAOA,mBAAmBiB,KAAK,CAACC;QAClC;IACF;IAtEA,YAAY,AAAQjB,OAA2C,CAAE;;aAA7CA,UAAAA;IAA8C;AAuEpE;AA1EE,iBADWP,6BACIQ,aAAyC,CAAC;AACzD,iBAFWR,6BAEIU,cAA0C,CAAC"}
1
+ {"version":3,"sources":["../../src/providers/RemoteFallbackCacheProvider.ts"],"sourcesContent":["import type { CacheProvider } from \"../types/CacheProvider.js\";\nimport type { Logger } from \"@lage-run/logger\";\nimport type { Target } from \"@lage-run/target-graph\";\n\nexport interface RemoteFallbackCacheProviderOptions {\n root: string;\n logger: Logger;\n\n localCacheProvider?: CacheProvider;\n remoteCacheProvider?: CacheProvider;\n\n writeRemoteCache?: boolean;\n}\n\n/**\n * Remote Fallback Cache Provider\n *\n * This backfill cache provider will fallback to a remote cache provider if the local cache does not contain the item.\n * It will also automatically populate the local cache with the remote cache.\n */\nexport class RemoteFallbackCacheProvider implements CacheProvider {\n private static localHits: { [hash: string]: boolean } = {};\n private static remoteHits: { [hash: string]: boolean } = {};\n\n constructor(private options: RemoteFallbackCacheProviderOptions) {}\n\n async fetch(hash: string, target: Target): Promise<boolean> {\n const { logger, remoteCacheProvider, localCacheProvider } = this.options;\n\n if (localCacheProvider) {\n RemoteFallbackCacheProvider.localHits[hash] = await localCacheProvider.fetch(hash, target);\n logger.silly(`local cache fetch: ${hash} ${RemoteFallbackCacheProvider.localHits[hash]}`);\n }\n\n if (!RemoteFallbackCacheProvider.localHits[hash] && remoteCacheProvider) {\n RemoteFallbackCacheProvider.remoteHits[hash] = await remoteCacheProvider.fetch(hash, target);\n logger.silly(`remote fallback fetch: ${hash} ${RemoteFallbackCacheProvider.remoteHits[hash]}`);\n\n // now save this into the localCacheProvider, if available\n if (localCacheProvider && RemoteFallbackCacheProvider.remoteHits[hash]) {\n logger.silly(`local cache put, fetched cache from remote: ${hash}`);\n await localCacheProvider.put(hash, target);\n }\n\n return RemoteFallbackCacheProvider.remoteHits[hash];\n }\n\n return RemoteFallbackCacheProvider.localHits[hash];\n }\n\n async put(hash: string, target: Target): Promise<void> {\n const { logger, remoteCacheProvider, localCacheProvider, writeRemoteCache } = this.options;\n const putPromises: Promise<void>[] = [];\n\n // Write local cache if it doesn't already exist, or if the the hash isn't in the localHits\n const shouldWriteLocalCache = !this.isLocalHit(hash) && !!localCacheProvider;\n\n if (shouldWriteLocalCache) {\n logger.silly(`local cache put: ${hash}`);\n putPromises.push(localCacheProvider.put(hash, target));\n }\n\n // Write to remote if there is a no hit in the remote cache, and remote cache storage provider, and that the \"writeRemoteCache\" config flag is set to true\n const shouldWriteRemoteCache = !this.isRemoteHit(hash) && !!remoteCacheProvider && writeRemoteCache;\n\n if (shouldWriteRemoteCache) {\n logger.silly(`remote fallback put: ${hash}`);\n const remotePut = remoteCacheProvider.put(hash, target);\n putPromises.push(remotePut);\n }\n\n await Promise.all(putPromises);\n }\n\n private isRemoteHit(hash: string) {\n return hash in RemoteFallbackCacheProvider.remoteHits && RemoteFallbackCacheProvider.remoteHits[hash];\n }\n\n private isLocalHit(hash: string) {\n return hash in RemoteFallbackCacheProvider.localHits && RemoteFallbackCacheProvider.localHits[hash];\n }\n\n async clear(): Promise<void> {\n const { localCacheProvider } = this.options;\n if (localCacheProvider) {\n return localCacheProvider.clear();\n }\n }\n\n async purge(sinceDays: number): Promise<void> {\n const { localCacheProvider } = this.options;\n if (localCacheProvider) {\n return localCacheProvider.purge(sinceDays);\n }\n }\n}\n"],"names":["RemoteFallbackCacheProvider","fetch","hash","target","logger","remoteCacheProvider","localCacheProvider","options","localHits","silly","remoteHits","put","writeRemoteCache","putPromises","shouldWriteLocalCache","isLocalHit","push","shouldWriteRemoteCache","isRemoteHit","remotePut","Promise","all","clear","purge","sinceDays"],"mappings":";;;;+BAoBaA;;;eAAAA;;;;;;;;;;;;;;;;AAAN,MAAMA;IAMX,MAAMC,MAAMC,IAAY,EAAEC,MAAc,EAAoB;QAC1D,MAAM,EAAEC,MAAM,EAAEC,mBAAmB,EAAEC,kBAAkB,EAAE,GAAG,IAAI,CAACC,OAAO;QAExE,IAAID,oBAAoB;YACtBN,4BAA4BQ,SAAS,CAACN,KAAK,GAAG,MAAMI,mBAAmBL,KAAK,CAACC,MAAMC;YACnFC,OAAOK,KAAK,CAAC,CAAC,mBAAmB,EAAEP,KAAK,CAAC,EAAEF,4BAA4BQ,SAAS,CAACN,KAAK,EAAE;QAC1F;QAEA,IAAI,CAACF,4BAA4BQ,SAAS,CAACN,KAAK,IAAIG,qBAAqB;YACvEL,4BAA4BU,UAAU,CAACR,KAAK,GAAG,MAAMG,oBAAoBJ,KAAK,CAACC,MAAMC;YACrFC,OAAOK,KAAK,CAAC,CAAC,uBAAuB,EAAEP,KAAK,CAAC,EAAEF,4BAA4BU,UAAU,CAACR,KAAK,EAAE;YAE7F,0DAA0D;YAC1D,IAAII,sBAAsBN,4BAA4BU,UAAU,CAACR,KAAK,EAAE;gBACtEE,OAAOK,KAAK,CAAC,CAAC,4CAA4C,EAAEP,MAAM;gBAClE,MAAMI,mBAAmBK,GAAG,CAACT,MAAMC;YACrC;YAEA,OAAOH,4BAA4BU,UAAU,CAACR,KAAK;QACrD;QAEA,OAAOF,4BAA4BQ,SAAS,CAACN,KAAK;IACpD;IAEA,MAAMS,IAAIT,IAAY,EAAEC,MAAc,EAAiB;QACrD,MAAM,EAAEC,MAAM,EAAEC,mBAAmB,EAAEC,kBAAkB,EAAEM,gBAAgB,EAAE,GAAG,IAAI,CAACL,OAAO;QAC1F,MAAMM,cA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
  {
2
2
  "name": "@lage-run/cache",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "Cache for Lage",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,14 +17,14 @@
17
17
  "lint": "monorepo-scripts lint"
18
18
  },
19
19
  "dependencies": {
20
- "@azure/core-auth": "1.10.1",
21
- "@azure/identity": "^4.12.0",
22
- "@lage-run/config": "^0.7.0",
23
- "@lage-run/logger": "^1.3.1",
24
- "@lage-run/target-graph": "^0.12.0",
25
- "backfill-cache": "5.11.2",
26
- "backfill-config": "6.7.1",
27
- "backfill-logger": "5.4.0",
20
+ "@azure/core-auth": "^1.10.1",
21
+ "@azure/identity": "^4.13.0",
22
+ "@lage-run/config": "^0.7.2",
23
+ "@lage-run/logger": "^1.3.2",
24
+ "@lage-run/target-graph": "^0.12.2",
25
+ "backfill-cache": "^5.11.2",
26
+ "backfill-config": "^6.7.1",
27
+ "backfill-logger": "^5.4.0",
28
28
  "glob-hasher": "^1.4.2"
29
29
  },
30
30
  "devDependencies": {