@dosu/seshi-client 0.14.0 → 0.17.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 +1 -1
- package/dist/index.js +44 -13
- package/package.json +2 -2
- package/types/http.d.ts +15 -7
- package/types/types.d.ts +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<img src="https://raw.githubusercontent.com/dosu-ai/seshi/v0.
|
|
1
|
+
<img src="https://raw.githubusercontent.com/dosu-ai/seshi/v0.17.0/brand/glyph/seshi-glyph-badge.svg" alt="" width="64" height="64">
|
|
2
2
|
|
|
3
3
|
# @dosu/seshi-client
|
|
4
4
|
|
package/dist/index.js
CHANGED
|
@@ -36,7 +36,10 @@ async function send(transport, method, path, options = {}) {
|
|
|
36
36
|
const timeoutMs = transport.timeoutMs ?? 120000;
|
|
37
37
|
const url = new URL(`${server}${path}`);
|
|
38
38
|
for (const [key, value] of Object.entries(options.query ?? {})) {
|
|
39
|
-
if (value
|
|
39
|
+
if (Array.isArray(value))
|
|
40
|
+
for (const item of value)
|
|
41
|
+
url.searchParams.append(key, String(item));
|
|
42
|
+
else if (value !== undefined)
|
|
40
43
|
url.searchParams.set(key, String(value));
|
|
41
44
|
}
|
|
42
45
|
const headers = {
|
|
@@ -150,11 +153,11 @@ class HttpSessionDB {
|
|
|
150
153
|
refuse(status, body, upload.offset ?? 0);
|
|
151
154
|
return body;
|
|
152
155
|
}
|
|
153
|
-
sessionPath(
|
|
154
|
-
return `/v1/sessions/${encodeURIComponent(
|
|
156
|
+
sessionPath(format, sessionId) {
|
|
157
|
+
return `/v1/sessions/${encodeURIComponent(format)}/${encodeURIComponent(sessionId)}`;
|
|
155
158
|
}
|
|
156
|
-
async getSession(
|
|
157
|
-
const { status, body } = await this.request("GET", this.sessionPath(
|
|
159
|
+
async getSession(format, sessionId, options = {}) {
|
|
160
|
+
const { status, body } = await this.request("GET", this.sessionPath(format, sessionId), {
|
|
158
161
|
query: { owner: options.owner }
|
|
159
162
|
});
|
|
160
163
|
if (status === 404)
|
|
@@ -163,14 +166,41 @@ class HttpSessionDB {
|
|
|
163
166
|
refuse(status, body);
|
|
164
167
|
return body;
|
|
165
168
|
}
|
|
166
|
-
async getTrace(
|
|
167
|
-
const { status, body } = await this.request("GET", `${this.sessionPath(
|
|
169
|
+
async getTrace(format, sessionId, hash, render, options = {}) {
|
|
170
|
+
const { status, body } = await this.request("GET", `${this.sessionPath(format, sessionId)}/trace`, { query: { hash, render, owner: options.owner } });
|
|
168
171
|
if (status === 404 || status === 410)
|
|
169
172
|
return null;
|
|
170
173
|
if (status !== 200)
|
|
171
174
|
refuse(status, body);
|
|
172
175
|
return body;
|
|
173
176
|
}
|
|
177
|
+
archivePath(owner, archiveId) {
|
|
178
|
+
return `/v1/owners/${encodeURIComponent(owner)}/sessions/${encodeURIComponent(archiveId)}`;
|
|
179
|
+
}
|
|
180
|
+
async getSessionByArchive(owner, archiveId) {
|
|
181
|
+
const { status, body } = await this.request("GET", this.archivePath(owner, archiveId));
|
|
182
|
+
if (status === 404)
|
|
183
|
+
return null;
|
|
184
|
+
if (status !== 200)
|
|
185
|
+
refuse(status, body);
|
|
186
|
+
return body;
|
|
187
|
+
}
|
|
188
|
+
async getTraceByArchive(owner, archiveId, hash, render) {
|
|
189
|
+
const { status, body } = await this.request("GET", `${this.archivePath(owner, archiveId)}/trace`, { query: { hash, render } });
|
|
190
|
+
if (status === 404 || status === 410)
|
|
191
|
+
return null;
|
|
192
|
+
if (status !== 200)
|
|
193
|
+
refuse(status, body);
|
|
194
|
+
return body;
|
|
195
|
+
}
|
|
196
|
+
async reviewsByArchive(owner, archiveId) {
|
|
197
|
+
const { status, body } = await this.request("GET", `${this.archivePath(owner, archiveId)}/reviews`);
|
|
198
|
+
if (status === 404)
|
|
199
|
+
return null;
|
|
200
|
+
if (status !== 200)
|
|
201
|
+
refuse(status, body);
|
|
202
|
+
return body.reviews;
|
|
203
|
+
}
|
|
174
204
|
async listSessions(options = {}) {
|
|
175
205
|
const { status, body } = await this.request("GET", "/v1/sessions", {
|
|
176
206
|
query: { after: options.after, limit: options.limit, owner: options.owner }
|
|
@@ -187,8 +217,8 @@ class HttpSessionDB {
|
|
|
187
217
|
refuse(status, body);
|
|
188
218
|
return body;
|
|
189
219
|
}
|
|
190
|
-
async tombstone(
|
|
191
|
-
const { status, body } = await this.request("DELETE", this.sessionPath(
|
|
220
|
+
async tombstone(format, sessionId, options = {}) {
|
|
221
|
+
const { status, body } = await this.request("DELETE", this.sessionPath(format, sessionId), {
|
|
192
222
|
query: { owner: options.owner },
|
|
193
223
|
...options.retractSecret !== undefined ? { headers: { [RETRACT_HEADER]: options.retractSecret } } : {}
|
|
194
224
|
});
|
|
@@ -198,8 +228,8 @@ class HttpSessionDB {
|
|
|
198
228
|
refuse(status, body);
|
|
199
229
|
return body;
|
|
200
230
|
}
|
|
201
|
-
async setVisibility(
|
|
202
|
-
const { status, body } = await this.request("PATCH", this.sessionPath(
|
|
231
|
+
async setVisibility(format, sessionId, visibility, options = {}) {
|
|
232
|
+
const { status, body } = await this.request("PATCH", this.sessionPath(format, sessionId), {
|
|
203
233
|
body: { visibility },
|
|
204
234
|
query: { owner: options.owner }
|
|
205
235
|
});
|
|
@@ -209,8 +239,8 @@ class HttpSessionDB {
|
|
|
209
239
|
refuse(status, body);
|
|
210
240
|
return body;
|
|
211
241
|
}
|
|
212
|
-
async reviews(
|
|
213
|
-
const { status, body } = await this.request("GET", `${this.sessionPath(
|
|
242
|
+
async reviews(format, sessionId, options = {}) {
|
|
243
|
+
const { status, body } = await this.request("GET", `${this.sessionPath(format, sessionId)}/reviews`, { query: { owner: options.owner } });
|
|
214
244
|
if (status === 404)
|
|
215
245
|
return null;
|
|
216
246
|
if (status !== 200)
|
|
@@ -241,6 +271,7 @@ class HttpSessionDB {
|
|
|
241
271
|
agent: request.agent,
|
|
242
272
|
repo: request.repo,
|
|
243
273
|
branch: request.branch,
|
|
274
|
+
label: Object.entries(request.labels ?? {}).map(([key, value]) => `${key}=${value}`),
|
|
244
275
|
source: request.source,
|
|
245
276
|
since: request.since,
|
|
246
277
|
until: request.until,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dosu/seshi-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://github.com/dosu-ai/seshi#readme",
|
|
6
6
|
"repository": {
|
|
@@ -30,6 +30,6 @@
|
|
|
30
30
|
"node": ">=20"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@dosu/seshi-model": "0.
|
|
33
|
+
"@dosu/seshi-model": "0.17.0"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/types/http.d.ts
CHANGED
|
@@ -59,10 +59,18 @@ export declare class HttpSessionDB implements SessionDB {
|
|
|
59
59
|
ingest(upload: Upload, options?: IngestOptions): Promise<StoreSessionResult>;
|
|
60
60
|
private sessionPath;
|
|
61
61
|
/** The session's metadata; null for one not stored, or one the caller may not read. */
|
|
62
|
-
getSession(
|
|
63
|
-
/** The head trace, or `hash`, as `
|
|
64
|
-
* redacted. */
|
|
65
|
-
getTrace(
|
|
62
|
+
getSession(format: string, sessionId: string, options?: OwnerOption): Promise<SessionMetadata | null>;
|
|
63
|
+
/** The head trace, or `hash`, rendered as `render`; null for a session not stored,
|
|
64
|
+
* unreadable or redacted. */
|
|
65
|
+
getTrace(format: string, sessionId: string, hash?: string, render?: RenderFormat, options?: OwnerOption): Promise<StoredTrace | null>;
|
|
66
|
+
private archivePath;
|
|
67
|
+
/** The session's metadata by its owner and archive id, as change entries, search results and
|
|
68
|
+
* listings name it (that owner's folder exactly); null when not stored or not readable. */
|
|
69
|
+
getSessionByArchive(owner: string, archiveId: string): Promise<SessionMetadata | null>;
|
|
70
|
+
/** `getTrace` by owner and archive id. */
|
|
71
|
+
getTraceByArchive(owner: string, archiveId: string, hash?: string, render?: RenderFormat): Promise<StoredTrace | null>;
|
|
72
|
+
/** `reviews` by owner and archive id. */
|
|
73
|
+
reviewsByArchive(owner: string, archiveId: string): Promise<ReviewDecision[] | null>;
|
|
66
74
|
listSessions(options?: ListSessionsOptions): Promise<SessionsPage>;
|
|
67
75
|
/** `GET /v1/sessions/stale`: the caller's own sessions an older normalizer built (X4.9), a
|
|
68
76
|
* page at a time. Needs `sessions:write`, which the uploader's credential has. */
|
|
@@ -76,18 +84,18 @@ export declare class HttpSessionDB implements SessionDB {
|
|
|
76
84
|
* session proves it with the secret whose hash it sent, using its normal upload credential
|
|
77
85
|
* (`sessions:write`), and the tombstone says `retracted`. A refused retraction is
|
|
78
86
|
* `ServerError` 403 `bad_retract_secret` or `retract_disabled`. */
|
|
79
|
-
tombstone(
|
|
87
|
+
tombstone(format: string, sessionId: string, options?: OwnerOption & {
|
|
80
88
|
retractSecret?: string;
|
|
81
89
|
}): Promise<{
|
|
82
90
|
removed: number;
|
|
83
91
|
} | null>;
|
|
84
92
|
/** Change who may read a session (X5.10); the metadata as it now is, null for one not
|
|
85
93
|
* stored. A redacted session is `ServerError` 410. The owner or an admin may. */
|
|
86
|
-
setVisibility(
|
|
94
|
+
setVisibility(format: string, sessionId: string, visibility: Visibility, options?: OwnerOption): Promise<SessionMetadata | null>;
|
|
87
95
|
/** What model review decided for each stored write of the session, oldest first (F3.8,
|
|
88
96
|
* `GET …/reviews`): the whole audit record for admins, only `n`, `at`, `content_hash` and
|
|
89
97
|
* `decision` for anyone else who may read it. Null for a session not stored. */
|
|
90
|
-
reviews(
|
|
98
|
+
reviews(format: string, sessionId: string, options?: OwnerOption): Promise<ReviewDecision[] | null>;
|
|
91
99
|
changes(options?: ReadChangesOptions): Promise<ChangesPage>;
|
|
92
100
|
/** Every owner's change feed as one (`GET /v1/changes/all`), by stamp, then owner, then
|
|
93
101
|
* key; each entry names its owner. Only for a credential that reads every session (a
|
package/types/types.d.ts
CHANGED
|
@@ -193,7 +193,7 @@ export interface ConfigStatus {
|
|
|
193
193
|
live_sections: string[];
|
|
194
194
|
restart_only_sections: string[];
|
|
195
195
|
}
|
|
196
|
-
/** One stored write's model review (`GET /v1/sessions/{
|
|
196
|
+
/** One stored write's model review (`GET /v1/sessions/{format}/{id}/reviews`, F3.8). Callers
|
|
197
197
|
* who are not admins get `schema`, `n`, `at`, `content_hash` and `decision` only. */
|
|
198
198
|
export interface ReviewDecision {
|
|
199
199
|
schema: "seshi/review/1";
|