@prisma/cli 8.0.0-rc.4-dev.58 → 8.0.0-rc.4-dev.60

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.
Files changed (2) hide show
  1. package/dist/cli.js +34 -34
  2. package/package.json +4 -4
package/dist/cli.js CHANGED
@@ -14566,7 +14566,7 @@ function memoryBackedStorage(credential, withRefreshLock) {
14566
14566
  }
14567
14567
  /**
14568
14568
  * The credential manager over one state file. Sessions are keyed by
14569
- * workspace id; which credential this process acts as is pinned once;
14569
+ * workspace id; which credential this process acts as is decided once;
14570
14570
  * every mutation takes a short file lock, re-reads, applies its slice,
14571
14571
  * and writes atomically. Reads never write and take no lock.
14572
14572
  */
@@ -14576,11 +14576,11 @@ var FileCredentialManager = class {
14576
14576
  #debug;
14577
14577
  #fetchWorkspaceName;
14578
14578
  #refreshCredential;
14579
- #pin = { kind: "unresolved" };
14580
- /** Built for one pinned credential. Every mutation that moves the
14581
- * pin discards it, so a command that mutates and then reaches for
14582
- * ctx.api cannot be handed storage for the credential it used to be
14583
- * acting as. */
14579
+ #actingAs = { kind: "unresolved" };
14580
+ /** Built for the credential the process acts as. Every mutation that
14581
+ * changes that discards it, so a command that mutates and then
14582
+ * reaches for ctx.api cannot be handed storage for the credential it
14583
+ * used to be acting as. */
14584
14584
  #activeStorage;
14585
14585
  #refreshLock = Promise.resolve();
14586
14586
  constructor(options) {
@@ -14595,14 +14595,14 @@ var FileCredentialManager = class {
14595
14595
  return this.#filePath;
14596
14596
  }
14597
14597
  async activeCredential() {
14598
- const pin = await this.#resolvePin();
14599
- if (pin.kind === "environment") return environmentCredential(this.#requireEnvironmentToken());
14598
+ const actingAs = await this.#resolveActingAs();
14599
+ if (actingAs.kind === "environment") return environmentCredential(this.#requireEnvironmentToken());
14600
14600
  const state = await readCredentialState(this.#filePath);
14601
- if (pin.kind === "none") {
14601
+ if (actingAs.kind === "none") {
14602
14602
  if (state.sessions.length > 0) throw credentialsRequiredError("sessions-held-none-selected");
14603
14603
  return null;
14604
14604
  }
14605
- const record = state.sessions.find((session) => session.workspaceId === pin.workspaceId);
14605
+ const record = state.sessions.find((session) => session.workspaceId === actingAs.workspaceId);
14606
14606
  if (record === void 0) throw credentialsRequiredError("session-ended");
14607
14607
  return storedCredential(record);
14608
14608
  }
@@ -14635,7 +14635,7 @@ var FileCredentialManager = class {
14635
14635
  result: toSession(record)
14636
14636
  };
14637
14637
  });
14638
- if (!environmentInForce) this.#repin({
14638
+ if (!environmentInForce) this.#actAs({
14639
14639
  kind: "session",
14640
14640
  workspaceId
14641
14641
  });
@@ -14669,7 +14669,7 @@ var FileCredentialManager = class {
14669
14669
  result: toSession(record)
14670
14670
  };
14671
14671
  });
14672
- if (!environmentInForce) this.#repin({
14672
+ if (!environmentInForce) this.#actAs({
14673
14673
  kind: "session",
14674
14674
  workspaceId
14675
14675
  });
@@ -14683,7 +14683,7 @@ var FileCredentialManager = class {
14683
14683
  state: withoutRecord(state, workspaceId),
14684
14684
  result: void 0
14685
14685
  } : { result: void 0 });
14686
- if (this.#pin.kind === "session" && this.#pin.workspaceId === workspaceId) this.#repin({ kind: "none" });
14686
+ if (this.#actingAs.kind === "session" && this.#actingAs.workspaceId === workspaceId) this.#actAs({ kind: "none" });
14687
14687
  }
14688
14688
  async endAllSessions() {
14689
14689
  const environmentInForce = this.#environmentToken() !== void 0;
@@ -14693,7 +14693,7 @@ var FileCredentialManager = class {
14693
14693
  });
14694
14694
  await this.#reapLegacyContextFile();
14695
14695
  await this.#reapOrphanedWrites();
14696
- if (!environmentInForce) this.#repin({ kind: "none" });
14696
+ if (!environmentInForce) this.#actAs({ kind: "none" });
14697
14697
  }
14698
14698
  async activeCredentialStorage() {
14699
14699
  this.#activeStorage ??= this.#buildActiveStorage();
@@ -14707,16 +14707,17 @@ var FileCredentialManager = class {
14707
14707
  if (await this.activeCredential() === null) return null;
14708
14708
  return readActiveAccessToken(await this.activeCredentialStorage(), this.#refreshCredential, options);
14709
14709
  }
14710
- /** §11.2: which storage is chosen once, when the pin resolves. Each
14710
+ /** §11.2: which storage is chosen once, when the acting-as decision
14711
+ * resolves. Each
14711
14712
  * has exactly one source of truth — the file, or process memory. */
14712
14713
  #buildActiveStorage() {
14713
- const pin = this.#pin;
14714
- if (pin.kind === "environment") return memoryBackedStorage({
14714
+ const actingAs = this.#actingAs;
14715
+ if (actingAs.kind === "environment") return memoryBackedStorage({
14715
14716
  token: this.#requireEnvironmentToken(),
14716
14717
  refreshToken: void 0,
14717
14718
  expiresAt: void 0
14718
14719
  }, (fn) => this.#withRefreshLock(fn));
14719
- if (pin.kind === "session") return this.#fileBackedStorage(pin.workspaceId);
14720
+ if (actingAs.kind === "session") return this.#fileBackedStorage(actingAs.workspaceId);
14720
14721
  throw new Error("@prisma/cli: activeCredentialStorage() is only valid once activeCredential() has returned non-null");
14721
14722
  }
14722
14723
  /**
@@ -14786,28 +14787,27 @@ var FileCredentialManager = class {
14786
14787
  this.#refreshLock = run.then(() => void 0, () => void 0);
14787
14788
  return run;
14788
14789
  }
14789
- async #resolvePin() {
14790
- const pinned = this.#pin;
14791
- if (pinned.kind !== "unresolved") return pinned;
14790
+ async #resolveActingAs() {
14791
+ const decided = this.#actingAs;
14792
+ if (decided.kind !== "unresolved") return decided;
14792
14793
  if (this.#environmentToken() !== void 0) {
14793
- this.#debug("pinned to the environment credential");
14794
- return this.#pinTo({ kind: "environment" });
14794
+ this.#debug("acting as the environment credential");
14795
+ this.#actingAs = { kind: "environment" };
14796
+ return { kind: "environment" };
14795
14797
  }
14796
14798
  const selected = resolvedMarker(await readCredentialState(this.#filePath));
14797
- this.#debug(`pinned to session ${selected ?? "(none)"}`);
14798
- return this.#pinTo(selected === null ? { kind: "none" } : {
14799
+ this.#debug(`acting as session ${selected ?? "(none)"}`);
14800
+ const resolved = selected === null ? { kind: "none" } : {
14799
14801
  kind: "session",
14800
14802
  workspaceId: selected
14801
- });
14802
- }
14803
- #pinTo(pin) {
14804
- this.#pin = pin;
14805
- return pin;
14803
+ };
14804
+ this.#actingAs = resolved;
14805
+ return resolved;
14806
14806
  }
14807
- /** Moves the pin after a mutation, discarding storage built for the
14808
- * credential this process was acting as before. */
14809
- #repin(pin) {
14810
- this.#pin = pin;
14807
+ /** Changes which credential the process acts as after a mutation,
14808
+ * discarding storage built for the previous one. */
14809
+ #actAs(next) {
14810
+ this.#actingAs = next;
14811
14811
  this.#activeStorage = void 0;
14812
14812
  }
14813
14813
  #environmentToken() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/cli",
3
- "version": "8.0.0-rc.4-dev.58",
3
+ "version": "8.0.0-rc.4-dev.60",
4
4
  "description": "Command-line interface for the Prisma Developer Platform.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -53,9 +53,9 @@
53
53
  },
54
54
  "devDependencies": {
55
55
  "@prisma/composer": "0.6.0-dev.23",
56
- "@repo/cli-conformance": "8.0.0-rc.4-dev.58",
57
- "@repo/cli-telemetry": "8.0.0-rc.4-dev.58",
58
- "@repo/tsconfig": "8.0.0-rc.4-dev.58",
56
+ "@repo/cli-conformance": "8.0.0-rc.4-dev.60",
57
+ "@repo/cli-telemetry": "8.0.0-rc.4-dev.60",
58
+ "@repo/tsconfig": "8.0.0-rc.4-dev.60",
59
59
  "@types/node": "^22.19.19",
60
60
  "tsdown": "^0.21.10",
61
61
  "tsx": "^4.22.4",