@agentshouse/mdruntime-adapter 0.1.0-cd028205a5103 → 0.1.0-cd59fd8945dcb

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/write.js CHANGED
@@ -1,4 +1,4 @@
1
- import { parseOriginals } from './read.js';
1
+ import { headChange } from './read.js';
2
2
  import { sha256Hex, textBytes } from './digest.js';
3
3
  import { nativePath, roomLocalPath } from './map.js';
4
4
  import { classifyDoor, doorRefusal, scopedRefusal } from './refusal.js';
@@ -138,6 +138,9 @@ function material(value, handle) {
138
138
  return null;
139
139
  if (file.revision !== null && file.revision !== undefined && typeof file.revision !== 'string')
140
140
  return null;
141
+ const head = headChange(file);
142
+ if (head === null)
143
+ return null;
141
144
  let path;
142
145
  try {
143
146
  path = roomLocalPath(file.path, handle);
@@ -149,6 +152,7 @@ function material(value, handle) {
149
152
  path,
150
153
  content: file.content,
151
154
  revision: typeof file.revision === 'string' ? file.revision : null,
155
+ ...(head === undefined ? {} : { head }),
152
156
  });
153
157
  }
154
158
  return held;
@@ -171,7 +175,13 @@ export function mutationOutcome(status, body, locator, handle) {
171
175
  if (refusal !== null && refusal.code === 'edit_conflict') {
172
176
  const { current, ...fields } = refusal.fields;
173
177
  const held = material(current, handle) ?? [];
174
- return { kind: 'conflicted', affected: affectedOf(held), code: refusal.code, fields };
178
+ return {
179
+ kind: 'conflicted',
180
+ affected: affectedOf(held),
181
+ code: refusal.code,
182
+ fields,
183
+ retryable: refusal.retryable,
184
+ };
175
185
  }
176
186
  if (refusal !== null && status === 404) {
177
187
  return scopedRefusal(locator, 'undisclosed', refusal);
@@ -181,14 +191,26 @@ export function mutationOutcome(status, body, locator, handle) {
181
191
  if (refusal?.retryable === true &&
182
192
  typeof reset === 'string' &&
183
193
  classified?.kind === 'transport-uncertainty') {
184
- return { kind: 'retryable-refusal', code: refusal.code, fields: refusal.fields, reset };
194
+ return {
195
+ kind: 'retryable-refusal',
196
+ code: refusal.code,
197
+ fields: refusal.fields,
198
+ retryable: true,
199
+ reset,
200
+ };
185
201
  }
186
202
  if (classified !== null && classified.kind !== 'scoped-refusal')
187
203
  return classified;
188
204
  if (classified !== null && status === 403)
189
205
  return classified;
190
206
  if (refusal !== null && status >= 400) {
191
- return { kind: 'rejected', affected: {}, code: refusal.code, fields: refusal.fields };
207
+ return {
208
+ kind: 'rejected',
209
+ affected: {},
210
+ code: refusal.code,
211
+ fields: refusal.fields,
212
+ retryable: refusal.retryable,
213
+ };
192
214
  }
193
215
  if (status !== 200 || typeof body !== 'object' || body === null) {
194
216
  return { kind: 'transport-uncertainty' };
@@ -200,11 +222,9 @@ export function mutationOutcome(status, body, locator, handle) {
200
222
  const contents = material(held.contents, handle);
201
223
  if (contents === null)
202
224
  return { kind: 'transport-uncertainty' };
203
- const originals = parseOriginals(held.originals);
204
- if (originals === null)
205
- return { kind: 'transport-uncertainty' };
206
225
  const documents = {};
207
226
  const revisions = {};
227
+ const changes = {};
208
228
  const removals = [];
209
229
  for (const entry of contents) {
210
230
  if (entry.content === null || entry.revision === null) {
@@ -213,14 +233,17 @@ export function mutationOutcome(status, body, locator, handle) {
213
233
  }
214
234
  documents[entry.path] = entry.content;
215
235
  revisions[entry.path] = entry.revision;
236
+ if (entry.head !== undefined)
237
+ changes[entry.path] = entry.head;
216
238
  }
217
239
  return {
218
240
  kind: 'accepted',
219
241
  roomVersion: roomVersion(at),
220
242
  documents,
221
243
  revisions,
244
+ changes,
222
245
  removals: removals.sort(),
223
- originals,
246
+ originals: [],
224
247
  };
225
248
  }
226
249
  export function rejectedMapping(mapping) {
@@ -229,6 +252,7 @@ export function rejectedMapping(mapping) {
229
252
  affected: {},
230
253
  code: mapping.rule,
231
254
  fields: { path: mapping.path },
255
+ retryable: false,
232
256
  };
233
257
  }
234
258
  export function revisionBody(input) {
@@ -277,6 +301,7 @@ export function historyOutcome(status, body, locator, request) {
277
301
  scope: 'content',
278
302
  code: 'retained_history_unavailable',
279
303
  fields: { path: request.path, revision: request.revision },
304
+ retryable: false,
280
305
  };
281
306
  }
282
307
  if (typeof named.content !== 'string')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/mdruntime-adapter",
3
- "version": "0.1.0-cd028205a5103",
3
+ "version": "0.1.0-cd59fd8945dcb",
4
4
  "description": "Agents House Adapter for the MD Runtime",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,7 +14,7 @@
14
14
  "exports": {
15
15
  ".": {
16
16
  "types": "./dist/index.d.ts",
17
- "import": "./dist/index.js"
17
+ "default": "./dist/index.js"
18
18
  },
19
19
  "./package.json": "./package.json"
20
20
  },
@@ -25,7 +25,7 @@
25
25
  "LICENSE"
26
26
  ],
27
27
  "dependencies": {
28
- "@agentshouse/mdmodel": "0.1.0-c3d58cb8652e6",
29
- "@agentshouse/mdruntime": "0.1.0-ca1eff92bbe73"
28
+ "@agentshouse/mdmodel": "0.1.0-cc9fa0498a7f7",
29
+ "@agentshouse/mdruntime": "0.1.0-cd3486bd400ed"
30
30
  }
31
31
  }