@prisma/cli-engine 0.1.0 → 0.2.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/dist/{token-claims-CJNNCGkL.js → engine-Az5SU8Aa.js} +645 -257
- package/dist/index.d.ts +8 -4
- package/dist/index.js +14 -9
- package/dist/protocol.js +1 -1
- package/dist/{report-DID_e0si.d.ts → report-BpE5F1IH.d.ts} +204 -161
- package/dist/testing.d.ts +9 -4
- package/dist/testing.js +20 -12
- package/package.json +4 -4
- /package/dist/{protocol-D1CRNkhv.js → protocol-TtNVkeVS.js} +0 -0
package/dist/testing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as credentialWorkspaceMismatchError, E as noSessionForWorkspaceError, _ as readActiveAccessToken, b as credentialWorkspaceId, t as buildEngine, v as claimedExpiresAt, w as credentialsRequiredError, y as claimedIdentity } from "./engine-Az5SU8Aa.js";
|
|
2
2
|
import { Buffer } from "node:buffer";
|
|
3
3
|
//#region src/in-memory-credential-manager.ts
|
|
4
4
|
/**
|
|
@@ -65,12 +65,16 @@ function memoryBackedStorage(credential, singleFlight) {
|
|
|
65
65
|
let tokens = {
|
|
66
66
|
workspaceId: credentialWorkspaceId(credential.token) ?? NO_WORKSPACE_CLAIMED,
|
|
67
67
|
accessToken: credential.token,
|
|
68
|
-
refreshToken: credential.refreshToken
|
|
68
|
+
refreshToken: credential.refreshToken,
|
|
69
|
+
expiresAt: claimedExpiresAt(credential.token) ?? credential.expiresAt
|
|
69
70
|
};
|
|
70
71
|
return {
|
|
71
72
|
getTokens: async () => tokens,
|
|
72
|
-
setTokens: async (rotated) => {
|
|
73
|
-
tokens =
|
|
73
|
+
setTokens: async (rotated, expiresAt) => {
|
|
74
|
+
tokens = {
|
|
75
|
+
...rotated,
|
|
76
|
+
expiresAt: claimedExpiresAt(rotated.accessToken) ?? expiresAt ?? tokens?.expiresAt
|
|
77
|
+
};
|
|
74
78
|
},
|
|
75
79
|
clearTokens: async () => {
|
|
76
80
|
tokens = null;
|
|
@@ -95,12 +99,14 @@ var InMemoryCredentialManager = class {
|
|
|
95
99
|
storedSessions;
|
|
96
100
|
selection;
|
|
97
101
|
environmentCredential;
|
|
102
|
+
refreshCredential;
|
|
98
103
|
pin = { kind: "unresolved" };
|
|
99
104
|
activeStorage;
|
|
100
105
|
constructor(seed) {
|
|
101
106
|
this.storedSessions = [...seed.sessions ?? []];
|
|
102
107
|
this.selection = seed.selectedWorkspaceId;
|
|
103
108
|
this.environmentCredential = seed.environmentCredential;
|
|
109
|
+
this.refreshCredential = seed.refreshCredential;
|
|
104
110
|
if (seed.credential !== void 0) {
|
|
105
111
|
const workspaceId = credentialWorkspaceId(seed.credential.token);
|
|
106
112
|
if (workspaceId === void 0) throw new Error("@prisma/cli-engine/testing: the `credential` seed runs createSession's claims derivation — the token must be a JWT with `workspace_id` (use mintTestJwt)");
|
|
@@ -163,14 +169,13 @@ var InMemoryCredentialManager = class {
|
|
|
163
169
|
this.activeStorage ??= this.buildActiveStorage();
|
|
164
170
|
return this.activeStorage;
|
|
165
171
|
}
|
|
166
|
-
/** The
|
|
172
|
+
/** The delegated path's read: the active credential's access token,
|
|
167
173
|
* fresh on every call, never the refresh token. Null when there is
|
|
168
174
|
* no active credential to read — storage exists only once
|
|
169
175
|
* activeCredential() has returned non-null. */
|
|
170
|
-
async activeAccessToken() {
|
|
176
|
+
async activeAccessToken(options) {
|
|
171
177
|
if (await this.activeCredential() === null) return null;
|
|
172
|
-
|
|
173
|
-
return tokens === null ? null : tokens.accessToken;
|
|
178
|
+
return readActiveAccessToken(await this.activeCredentialStorage(), this.refreshCredential, options);
|
|
174
179
|
}
|
|
175
180
|
buildActiveStorage() {
|
|
176
181
|
const pin = this.pin;
|
|
@@ -189,10 +194,11 @@ var InMemoryCredentialManager = class {
|
|
|
189
194
|
return {
|
|
190
195
|
workspaceId,
|
|
191
196
|
accessToken: record.credential.token,
|
|
192
|
-
refreshToken: record.credential.refreshToken
|
|
197
|
+
refreshToken: record.credential.refreshToken,
|
|
198
|
+
expiresAt: record.credential.expiresAt
|
|
193
199
|
};
|
|
194
200
|
},
|
|
195
|
-
setTokens: async (tokens) => {
|
|
201
|
+
setTokens: async (tokens, expiresAt) => {
|
|
196
202
|
if (pinnedRecord() === void 0) throw credentialsRequiredError("session-ended");
|
|
197
203
|
const claimed = credentialWorkspaceId(tokens.accessToken);
|
|
198
204
|
if (claimed !== void 0 && claimed !== workspaceId) throw credentialWorkspaceMismatchError(workspaceId);
|
|
@@ -201,7 +207,7 @@ var InMemoryCredentialManager = class {
|
|
|
201
207
|
credential: {
|
|
202
208
|
token: tokens.accessToken,
|
|
203
209
|
refreshToken: tokens.refreshToken,
|
|
204
|
-
expiresAt: claimedExpiresAt(tokens.accessToken)
|
|
210
|
+
expiresAt: claimedExpiresAt(tokens.accessToken) ?? expiresAt ?? stored.credential.expiresAt
|
|
205
211
|
}
|
|
206
212
|
} : stored);
|
|
207
213
|
},
|
|
@@ -303,6 +309,7 @@ function recordingSpawn(adapter, spawns) {
|
|
|
303
309
|
command: request.command,
|
|
304
310
|
args: [...request.args],
|
|
305
311
|
cwd: request.cwd,
|
|
312
|
+
output: request.output,
|
|
306
313
|
envKeys: Object.keys(request.env),
|
|
307
314
|
kills: []
|
|
308
315
|
};
|
|
@@ -350,7 +357,8 @@ function createTestCli(spec) {
|
|
|
350
357
|
sessions: spec.sessions,
|
|
351
358
|
selectedWorkspaceId: spec.selectedWorkspaceId,
|
|
352
359
|
credential: spec.credential,
|
|
353
|
-
environmentCredential: spec.environmentCredential
|
|
360
|
+
environmentCredential: spec.environmentCredential,
|
|
361
|
+
refreshCredential: spec.refreshCredential
|
|
354
362
|
});
|
|
355
363
|
const managementApiBaseUrl = spec.managementApi?.baseUrl ?? "https://test.invalid";
|
|
356
364
|
const managementApiClientConfig = spec.managementApiClientConfig ?? {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/cli-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "The execution engine of the unified Prisma CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -44,15 +44,15 @@
|
|
|
44
44
|
"@prisma/management-api-sdk": "1.55.0",
|
|
45
45
|
"@stricli/core": "1.3.0",
|
|
46
46
|
"c12": "3.3.4",
|
|
47
|
-
"ci-info": "^4.3.1",
|
|
48
47
|
"colorette": "^2.0.20",
|
|
49
48
|
"package-manager-detector": "1.8.0",
|
|
50
49
|
"string-width": "^8.2.1"
|
|
51
50
|
},
|
|
52
51
|
"devDependencies": {
|
|
53
|
-
"@repo/cli-conformance": "8.0.0-rc.
|
|
54
|
-
"@repo/tsconfig": "8.0.0-rc.
|
|
52
|
+
"@repo/cli-conformance": "8.0.0-rc.4-dev.57",
|
|
53
|
+
"@repo/tsconfig": "8.0.0-rc.4-dev.57",
|
|
55
54
|
"@types/node": "^22.19.19",
|
|
55
|
+
"ci-info": "^4.3.1",
|
|
56
56
|
"tsdown": "^0.21.10",
|
|
57
57
|
"typescript": "^6.0.3",
|
|
58
58
|
"vitest": "^4.1.8"
|
|
File without changes
|