@stim-cli/cache 1.21.0 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -59,6 +59,9 @@ export async function createCacheProvider({ projectRoot, options }) {
59
59
  }
60
60
  ```
61
61
 
62
+ The factory may also receive `env`, a captured caller environment. Use it for
63
+ authentication instead of reading or changing `process.env` when it is present.
64
+
62
65
  A provider implements one or more capabilities. It owns transport,
63
66
  serialization, archive format, authentication, and remote retention. Stim owns
64
67
  fingerprints, cache keys, and local artifact paths.
@@ -89,6 +92,10 @@ and `overwrite: true` must replace it.
89
92
 
90
93
  Every call receives an `AbortSignal`. A provider must honor it: Stim abandons
91
94
  the call at the deadline and keeps building or bundling with the local tier.
95
+ Factories and callbacks run as trusted host code in programmatic clients and the
96
+ server. They must keep the event loop responsive and settle when cancelled.
97
+ Deadlines are cooperative; they do not sandbox a module that blocks JavaScript
98
+ or terminates its host.
92
99
 
93
100
  `stim gc` never deletes provider data, and the contract has no delete
94
101
  operation, so shared team or CI data is never removed by a local command.
package/dist/index.d.mts CHANGED
@@ -110,6 +110,7 @@ interface CacheProviderModule {
110
110
  createCacheProvider(input: {
111
111
  projectRoot: string;
112
112
  options: Record<string, unknown>;
113
+ env?: NodeJS.ProcessEnv;
113
114
  }): CacheProvider | Promise<CacheProvider>;
114
115
  }
115
116
  interface LoadCacheProviderResult {
@@ -124,9 +125,10 @@ interface ProviderCallResult<T> {
124
125
  timedOut?: true;
125
126
  }
126
127
  type WarnOnce = (code: string, message: string) => void;
127
- declare function loadCacheProvider({ projectRoot, config, timeoutMs }: {
128
+ declare function loadCacheProvider({ projectRoot, config, env, timeoutMs }: {
128
129
  projectRoot: string;
129
130
  config?: CacheProviderConfig | null;
131
+ env?: NodeJS.ProcessEnv;
130
132
  timeoutMs?: number;
131
133
  }): Promise<LoadCacheProviderResult>;
132
134
  declare function callWithTimeout<T>(call: (signal: AbortSignal) => T | Promise<T>, timeoutMs: number, signal?: AbortSignal): Promise<ProviderCallResult<T>>;
package/dist/index.mjs CHANGED
@@ -42,13 +42,15 @@ function capabilityError(provider) {
42
42
  if (metro === void 0 && builds === void 0 && files === void 0) return "the provider advertises no files, metro or builds capability";
43
43
  return null;
44
44
  }
45
- async function loadCacheProvider({ projectRoot, config, timeoutMs = timeoutFromEnv(PROVIDER_LOAD_TIMEOUT_ENV, PROVIDER_LOAD_TIMEOUT_MS) }) {
45
+ async function loadCacheProvider({ projectRoot, config, env, timeoutMs = timeoutFromEnv(PROVIDER_LOAD_TIMEOUT_ENV, PROVIDER_LOAD_TIMEOUT_MS) }) {
46
46
  const reference = typeof config?.provider === "string" ? config.provider.trim() : "";
47
47
  if (!config || reference === "") return { none: true };
48
+ const environment = env === void 0 ? void 0 : { ...env };
48
49
  const outcome = await callWithTimeout(() => importCacheProvider({
49
50
  projectRoot,
50
51
  config,
51
- reference
52
+ reference,
53
+ env: environment
52
54
  }), timeoutMs);
53
55
  if (outcome.timedOut) return {
54
56
  name: reference,
@@ -63,7 +65,7 @@ async function loadCacheProvider({ projectRoot, config, timeoutMs = timeoutFromE
63
65
  unavailable: "the module produced no provider"
64
66
  };
65
67
  }
66
- async function importCacheProvider({ projectRoot, config, reference }) {
68
+ async function importCacheProvider({ projectRoot, config, reference, env }) {
67
69
  const options = isRecord(config.options) ? config.options : {};
68
70
  const baseDir = typeof config.baseDir === "string" && config.baseDir !== "" ? config.baseDir : projectRoot;
69
71
  let namespace;
@@ -89,7 +91,8 @@ async function importCacheProvider({ projectRoot, config, reference }) {
89
91
  try {
90
92
  provider = await candidate.createCacheProvider({
91
93
  projectRoot,
92
- options
94
+ options,
95
+ ...env === void 0 ? {} : { env: { ...env } }
93
96
  });
94
97
  } catch (error) {
95
98
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stim-cli/cache",
3
- "version": "1.21.0",
3
+ "version": "1.23.0",
4
4
  "description": "Cache provider contract and tier coordination for Stim.",
5
5
  "license": "MIT",
6
6
  "repository": {