@mengine/medeo-client 2.1.1-dsl.26 → 2.1.1-dsl.27

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/testing.d.ts CHANGED
@@ -18,6 +18,7 @@ declare class InMemoryMengineServer {
18
18
  private readonly subscribers;
19
19
  private seq;
20
20
  private hasSnapshot;
21
+ private readonly revisions;
21
22
  /**
22
23
  * Close every open SSE stream, simulating a network drop. Clients reconnect
23
24
  * (a fresh `/events`) and catch up via their next sync — used to exercise
package/dist/testing.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { n as bytesToBase64, t as base64ToBytes } from "./base64-D-jd-dr5.js";
2
- import { a as DslEditor, d as documentFormat, i as createInitialMedeoDsl, l as assertDslDocument, n as toVideoDraft, s as MedeoDsl, u as assertPhoneticBindingFormat } from "./dsl-SmWJTQWV.js";
2
+ import { _ as DslProjectionError, a as DslEditor, d as documentFormat, i as createInitialMedeoDsl, l as assertDslDocument, n as toVideoDraft, s as MedeoDsl, u as assertPhoneticBindingFormat } from "./dsl-SmWJTQWV.js";
3
3
  import { t as classifyUpdate } from "./loro-relay-doc-Bi6JKqtQ.js";
4
4
  import { LoroDoc, VersionVector, encodeFrontiers } from "loro-crdt";
5
5
  //#region src/testing/in-memory-mengine-server.ts
@@ -19,6 +19,7 @@ var InMemoryMengineServer = class {
19
19
  subscribers = /* @__PURE__ */ new Set();
20
20
  seq = 0;
21
21
  hasSnapshot = false;
22
+ revisions = /* @__PURE__ */ new Map();
22
23
  /**
23
24
  * Close every open SSE stream, simulating a network drop. Clients reconnect
24
25
  * (a fresh `/events`) and catch up via their next sync — used to exercise
@@ -39,6 +40,7 @@ var InMemoryMengineServer = class {
39
40
  try {
40
41
  this.doc.import(dsl.doc.export({ mode: "snapshot" }));
41
42
  this.hasSnapshot = true;
43
+ this.revisions.set(this.seq, this.doc.export({ mode: "snapshot" }));
42
44
  return new Response(await this.handleSnapshot().text(), {
43
45
  status: 201,
44
46
  headers: { "content-type": "application/json" }
@@ -47,22 +49,33 @@ var InMemoryMengineServer = class {
47
49
  dsl.dispose();
48
50
  }
49
51
  }
50
- if (path === "draft" && method === "GET") {
52
+ const revision = /^revisions\/(\d+)\/draft$/.exec(path);
53
+ if ((path === "draft" || revision) && method === "GET") {
51
54
  if (!this.hasSnapshot) return this.handleSnapshot();
52
- assertDslDocument(this.doc);
53
- const dsl = new MedeoDsl(this.doc);
55
+ const seq = revision ? Number(revision[1]) : this.seq;
56
+ const snapshot = this.revisions.get(seq);
57
+ if (!snapshot) return Response.json({
58
+ code: "not_found",
59
+ message: "revision not found"
60
+ }, { status: 404 });
61
+ const attached = new LoroDoc();
62
+ attached.import(snapshot);
63
+ const dsl = new MedeoDsl(attached);
54
64
  try {
65
+ assertDslDocument(attached);
55
66
  return Response.json({
56
67
  ...toVideoDraft(dsl.getSnapshot()),
57
- version: this.version()
68
+ version: this.version(attached, seq)
58
69
  });
59
70
  } catch (error) {
60
- return Response.json({ error: {
61
- code: "projection_unsupported",
62
- message: String(error)
63
- } }, { status: 422 });
71
+ return Response.json({
72
+ code: revision ? "revision_unprojectable" : "projection_unsupported",
73
+ message: String(error),
74
+ ...error instanceof DslProjectionError ? { issues: error.issues } : {}
75
+ }, { status: 422 });
64
76
  } finally {
65
77
  dsl.dispose();
78
+ attached.free();
66
79
  }
67
80
  }
68
81
  if (/^\/internal\/mengine\/v1\/docs\/[^/]+\/bootstrap$/.test(new URL(url).pathname) && method === "POST") return this.handleBootstrap(init);
@@ -81,11 +94,11 @@ var InMemoryMengineServer = class {
81
94
  const afterDocId = url.slice(start + 21);
82
95
  return afterDocId.slice(afterDocId.indexOf("/") + 1);
83
96
  }
84
- version() {
97
+ version(doc = this.doc, seq = this.seq) {
85
98
  return {
86
- update_seq: this.seq,
87
- server_vv: bytesToBase64(this.doc.oplogVersion().encode()),
88
- frontiers: bytesToBase64(encodeFrontiers(this.doc.oplogFrontiers()))
99
+ update_seq: seq,
100
+ server_vv: bytesToBase64(doc.oplogVersion().encode()),
101
+ frontiers: bytesToBase64(encodeFrontiers(doc.oplogFrontiers()))
89
102
  };
90
103
  }
91
104
  handleSnapshot() {
@@ -104,6 +117,7 @@ var InMemoryMengineServer = class {
104
117
  if (body.snapshot != null && !this.hasSnapshot) {
105
118
  this.doc.import(base64ToBytes(body.snapshot));
106
119
  this.hasSnapshot = true;
120
+ this.revisions.set(this.seq, this.doc.export({ mode: "snapshot" }));
107
121
  }
108
122
  return this.handleSnapshot();
109
123
  }
@@ -185,6 +199,7 @@ var InMemoryMengineServer = class {
185
199
  this.doc.import(data);
186
200
  this.hasSnapshot = true;
187
201
  this.seq += 1;
202
+ this.revisions.set(this.seq, this.doc.export({ mode: "snapshot" }));
188
203
  const meta = extractMeta(this.doc, baseVV);
189
204
  const stored = {
190
205
  updateSeq: this.seq,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mengine/medeo-client",
3
- "version": "2.1.1-dsl.26",
3
+ "version": "2.1.1-dsl.27",
4
4
  "license": "UNLICENSED",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,9 +27,9 @@
27
27
  "dependencies": {
28
28
  "@noble/hashes": "^2.4.0",
29
29
  "zod": "^4.4.3",
30
- "@mengine/storage": "2.1.1-dsl.26",
31
- "@mengine/sync": "2.1.1-dsl.26",
32
- "@mengine/utils": "2.1.1-dsl.26"
30
+ "@mengine/sync": "2.1.1-dsl.27",
31
+ "@mengine/utils": "2.1.1-dsl.27",
32
+ "@mengine/storage": "2.1.1-dsl.27"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/node": "^25.9.1",