@prisma/cli 8.0.0-rc.4-dev.59 → 8.0.0-rc.4-dev.61
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/dist/cli.js +34 -34
- package/package.json +5 -5
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
|
|
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
|
-
#
|
|
14580
|
-
/** Built for
|
|
14581
|
-
*
|
|
14582
|
-
* ctx.api cannot be handed storage for the credential it
|
|
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
|
|
14599
|
-
if (
|
|
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 (
|
|
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 ===
|
|
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.#
|
|
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.#
|
|
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.#
|
|
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.#
|
|
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
|
|
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
|
|
14714
|
-
if (
|
|
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 (
|
|
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 #
|
|
14790
|
-
const
|
|
14791
|
-
if (
|
|
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("
|
|
14794
|
-
|
|
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(`
|
|
14798
|
-
|
|
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
|
-
|
|
14804
|
-
this.#pin = pin;
|
|
14805
|
-
return pin;
|
|
14803
|
+
};
|
|
14804
|
+
this.#actingAs = resolved;
|
|
14805
|
+
return resolved;
|
|
14806
14806
|
}
|
|
14807
|
-
/**
|
|
14808
|
-
*
|
|
14809
|
-
#
|
|
14810
|
-
this.#
|
|
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.
|
|
3
|
+
"version": "8.0.0-rc.4-dev.61",
|
|
4
4
|
"description": "Command-line interface for the Prisma Developer Platform.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@prisma/compute-sdk": "0.39.0",
|
|
45
45
|
"@prisma/credentials-store": "^7.8.0",
|
|
46
46
|
"@prisma/management-api-sdk": "1.55.0",
|
|
47
|
-
"@prisma/orm-toolchain": "8.0.0-rc.2-dev.
|
|
47
|
+
"@prisma/orm-toolchain": "8.0.0-rc.2-dev.3",
|
|
48
48
|
"@vercel/detect-agent": "^1.2.3",
|
|
49
49
|
"better-result": "^2.9.2",
|
|
50
50
|
"dotenv": "^17.4.2",
|
|
@@ -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.
|
|
57
|
-
"@repo/cli-telemetry": "8.0.0-rc.4-dev.
|
|
58
|
-
"@repo/tsconfig": "8.0.0-rc.4-dev.
|
|
56
|
+
"@repo/cli-conformance": "8.0.0-rc.4-dev.61",
|
|
57
|
+
"@repo/cli-telemetry": "8.0.0-rc.4-dev.61",
|
|
58
|
+
"@repo/tsconfig": "8.0.0-rc.4-dev.61",
|
|
59
59
|
"@types/node": "^22.19.19",
|
|
60
60
|
"tsdown": "^0.21.10",
|
|
61
61
|
"tsx": "^4.22.4",
|