@withmestra/sdk 0.1.0 → 0.1.1
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/edit.d.ts +1 -0
- package/dist/edit.js +11 -6
- package/dist/index.d.ts +3 -0
- package/dist/sizes.js +3 -2
- package/dist/types.d.ts +2 -0
- package/dist/v1.d.ts +4325 -2350
- package/package.json +1 -1
package/dist/edit.d.ts
CHANGED
package/dist/edit.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { sessionHeader } from "./http.js";
|
|
2
2
|
import { ReplayDivergedError, SessionGoneError, SizeChangedError } from "./errors.js";
|
|
3
|
+
/** A check with nothing in it, for a session built before its first check. */
|
|
4
|
+
const emptyCheck = () => ({ failures: [], warnings: [], objective: 0 });
|
|
3
5
|
function answerOf(body) {
|
|
4
6
|
return {
|
|
5
7
|
elements: [],
|
|
6
8
|
fixes: [],
|
|
7
9
|
carried: {},
|
|
8
|
-
check:
|
|
10
|
+
check: emptyCheck(),
|
|
9
11
|
refused: "",
|
|
10
12
|
detail: "",
|
|
11
13
|
limit: null,
|
|
@@ -228,8 +230,8 @@ export class SizeSession extends EditSession {
|
|
|
228
230
|
static fromBatch(transport, r, edit) {
|
|
229
231
|
const s = new SizeSession(transport, r.run, r.size, {
|
|
230
232
|
id: r.session,
|
|
231
|
-
elements: [],
|
|
232
|
-
check: r.check ??
|
|
233
|
+
elements: r.elements ?? [],
|
|
234
|
+
check: r.check ?? emptyCheck(),
|
|
233
235
|
label: r.label || "loaded",
|
|
234
236
|
sceneHash: r.sceneHash,
|
|
235
237
|
});
|
|
@@ -307,9 +309,11 @@ async function openSizeRaw(t, runId, size) {
|
|
|
307
309
|
const res = await t.send("POST", `/api/v1/jobs/${encodeURIComponent(runId)}/formats/${encodeURIComponent(size)}/edit`);
|
|
308
310
|
const b = res.body;
|
|
309
311
|
return {
|
|
312
|
+
run: (b.run ?? runId),
|
|
313
|
+
size: (b.size ?? size),
|
|
310
314
|
id: b.session,
|
|
311
315
|
elements: (b.elements ?? []),
|
|
312
|
-
check: (b.check ??
|
|
316
|
+
check: (b.check ?? emptyCheck()),
|
|
313
317
|
label: (b.label ?? "loaded"),
|
|
314
318
|
sceneHash: b.sceneHash,
|
|
315
319
|
format: b.format,
|
|
@@ -321,7 +325,8 @@ async function openMasterRaw(t, masterId, version) {
|
|
|
321
325
|
}
|
|
322
326
|
/** Opens one size of a run for editing. */
|
|
323
327
|
export async function openSize(t, runId, size) {
|
|
324
|
-
|
|
328
|
+
const o = await openSizeRaw(t, runId, size);
|
|
329
|
+
return new SizeSession(t, o.run, o.size, o);
|
|
325
330
|
}
|
|
326
331
|
/** Opens a master for editing: `version` is a number, or the latest by default. */
|
|
327
332
|
export async function openMaster(t, masterId, o = {}) {
|
|
@@ -329,7 +334,7 @@ export async function openMaster(t, masterId, o = {}) {
|
|
|
329
334
|
return new MasterSession(t, {
|
|
330
335
|
id: b.session,
|
|
331
336
|
elements: b.elements ?? [],
|
|
332
|
-
check: b.check ??
|
|
337
|
+
check: b.check ?? emptyCheck(),
|
|
333
338
|
label: b.label ?? "loaded",
|
|
334
339
|
master: b.master,
|
|
335
340
|
ifMatch: b.ifMatch,
|
package/dist/index.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ export declare function createMestra(options: MestraOptions): {
|
|
|
49
49
|
detail?: string;
|
|
50
50
|
limit?: Record<string, never>;
|
|
51
51
|
candidates?: import("./v1.js").components["schemas"]["EditCandidate"][];
|
|
52
|
+
elements?: import("./v1.js").components["schemas"]["EditElement"][];
|
|
52
53
|
}>>;
|
|
53
54
|
/** The raw first answer of a save across sizes. */
|
|
54
55
|
startSaveSizes: (sessions: SizeSession[], idempotencyKey?: string) => Promise<SizesProgress<{
|
|
@@ -78,6 +79,7 @@ export declare function createMestra(options: MestraOptions): {
|
|
|
78
79
|
detail?: string;
|
|
79
80
|
limit?: Record<string, never>;
|
|
80
81
|
candidates?: import("./v1.js").components["schemas"]["EditCandidate"][];
|
|
82
|
+
elements?: import("./v1.js").components["schemas"]["EditElement"][];
|
|
81
83
|
} | {
|
|
82
84
|
session: string;
|
|
83
85
|
outcome: "saved" | "failed";
|
|
@@ -105,6 +107,7 @@ export declare function createMestra(options: MestraOptions): {
|
|
|
105
107
|
detail?: string;
|
|
106
108
|
limit?: Record<string, never>;
|
|
107
109
|
candidates?: import("./v1.js").components["schemas"]["EditCandidate"][];
|
|
110
|
+
elements?: import("./v1.js").components["schemas"]["EditElement"][];
|
|
108
111
|
} | {
|
|
109
112
|
session: string;
|
|
110
113
|
outcome: "saved" | "failed";
|
package/dist/sizes.js
CHANGED
|
@@ -10,6 +10,7 @@ function progressOf(status, body) {
|
|
|
10
10
|
if (status === 202 || body.operation !== undefined) {
|
|
11
11
|
return {
|
|
12
12
|
operation: body.operation,
|
|
13
|
+
...(body.kind ? { kind: body.kind } : {}),
|
|
13
14
|
status: body.status,
|
|
14
15
|
done: body.done,
|
|
15
16
|
total: body.total,
|
|
@@ -63,10 +64,10 @@ export async function editSizes(t, req, o = {}) {
|
|
|
63
64
|
const last = await finish(t, await startEditSizes(t, req), o);
|
|
64
65
|
const results = last.results.map((r) => {
|
|
65
66
|
if (r.session && r.sceneHash && r.run && r.size) {
|
|
66
|
-
const { session: id, sceneHash, run, size, label, check } = r;
|
|
67
|
+
const { session: id, sceneHash, run, size, label, check, elements } = r;
|
|
67
68
|
return {
|
|
68
69
|
...r,
|
|
69
|
-
editSession: SizeSession.fromBatch(t, { run, size, session: id, sceneHash, ...(label ? { label } : {}), ...(check ? { check } : {}) }, req.edit),
|
|
70
|
+
editSession: SizeSession.fromBatch(t, { run, size, session: id, sceneHash, ...(label ? { label } : {}), ...(check ? { check } : {}), ...(elements ? { elements } : {}) }, req.edit),
|
|
70
71
|
};
|
|
71
72
|
}
|
|
72
73
|
return r;
|
package/dist/types.d.ts
CHANGED
|
@@ -97,6 +97,8 @@ export interface FormatInfo {
|
|
|
97
97
|
/** The progress of a call across sizes. A call that finished at once is `done` with no `operation`. */
|
|
98
98
|
export interface SizesProgress<R> {
|
|
99
99
|
operation?: string;
|
|
100
|
+
/** Which call the operation is (`edit` or `save`); absent on a call that finished at once. */
|
|
101
|
+
kind?: "edit" | "save";
|
|
100
102
|
status: "running" | "done";
|
|
101
103
|
done: number;
|
|
102
104
|
total: number;
|