@lincyaw/workspace 1.0.0-rc.52 → 1.0.0-rc.54

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lincyaw/workspace",
3
- "version": "1.0.0-rc.52",
3
+ "version": "1.0.0-rc.54",
4
4
  "description": "Presmium's workspace service (presmium serve): documents, their history, reviews and the workspace site",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -34,12 +34,12 @@
34
34
  "mime-types": "3.0.2",
35
35
  "playwright-chromium": "1.64.1",
36
36
  "yaml": "^2.9.1",
37
- "@lincyaw/compiler": "1.0.0-rc.52",
38
- "@lincyaw/kernel": "1.0.0-rc.52",
39
- "@lincyaw/server": "1.0.0-rc.52"
37
+ "@lincyaw/kernel": "1.0.0-rc.54",
38
+ "@lincyaw/compiler": "1.0.0-rc.54",
39
+ "@lincyaw/server": "1.0.0-rc.54"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/mime-types": "^3.0.1",
43
- "@lincyaw/mcp": "1.0.0-rc.52"
43
+ "@lincyaw/mcp": "1.0.0-rc.54"
44
44
  }
45
45
  }
@@ -70,7 +70,7 @@ export function createAuthoringClients(editor: SourceEditor, options: { reviewRe
70
70
  if (!validateAuthoringClientQuery(query)) throw new RequestError(400, 'client-query-invalid')
71
71
  const all = [...clients.values()].filter(client => client.member === member.id && client.value.document === document && (!query.clientId || client.value.clientId === query.clientId)
72
72
  && (!query.after || client.value.clientId > query.after)).sort((a, b) => a.value.clientId.localeCompare(b.value.clientId))
73
- const answer = { document, clients: [] as AuthoringClientDescriptor[], unavailable: ['new-comment-restore', 'active-comment-discard', 'timing-drafts', 'recording-range-drafts', 'review', 'open-document', ...options.reviewRequired ? ['source-writes-require-review'] : []] }
73
+ const answer = { document, clients: [] as AuthoringClientDescriptor[], unavailable: ['other-form-drafts', 'review', 'open-document', ...options.reviewRequired ? ['source-writes-require-review'] : []] }
74
74
  for (const client of all) {
75
75
  const row = structuredClone(client.value)
76
76
  row.snapshot.actions = row.snapshot.actions.filter(type => !requiresReview(type))
@@ -179,31 +179,33 @@ export function createAuthoringClients(editor: SourceEditor, options: { reviewRe
179
179
  if (ack.state === 'executing' && (ack.snapshot.revision !== pending.request.expectedClientState.revision || !localDraft && (!actual || !sameSource(actual, pending.request.source)))) throw new RequestError(409, 'client-state-changed')
180
180
  if (ack.state === 'done' && !localDraft && (!actual || !sameSource(actual, ack.snapshot.source))) throw new RequestError(409, 'client-source-changed')
181
181
  const action = pending.request.action
182
- const family = action.type.startsWith('body-drafts.') ? 'body' : action.type.startsWith('comment-drafts.') ? 'comment' : action.type.startsWith('component-drafts.') ? 'component' : undefined
182
+ const family = action.type.startsWith('production-drafts.') ? 'production' : action.type.startsWith('body-drafts.') ? 'body' : action.type.startsWith('comment-drafts.') ? 'comment' : action.type.startsWith('component-drafts.') ? 'component' : undefined
183
183
  if (ack.result && (!family || ack.state !== 'done' || ack.result.type !== action.type || ack.result.family !== family)) throw new RequestError(400, 'client-result-invalid')
184
184
  if (family && ack.state === 'done') {
185
185
  const result = ack.result
186
186
  const mutation = authoringClientActionMutatesDraft(action.type)
187
187
  if (!result || (mutation ? ack.snapshot.revision <= pending.request.expectedClientState.revision : ack.snapshot.revision !== pending.request.expectedClientState.revision)) throw new RequestError(409, `client-${family}-drafts-changed`)
188
188
  if (!authoringClientResultFits({ request: pending.request, connection: client.value, document, snapshot: ack.snapshot }, result)) throw new RequestError(413, `client-${family}-result-too-large`)
189
- if (action.type === 'body-drafts.read' && (result.type !== action.type || result.draft !== action.draft
189
+ if ((action.type === 'body-drafts.read' || action.type === 'production-drafts.read') && (result.type !== action.type || result.draft !== action.draft
190
190
  || result.offset !== action.offset || result.endOffset !== result.offset + result.jsonText.length || result.endOffset > result.totalUtf16
191
191
  || result.jsonText.length > (action.maxChars ?? 2048))) throw new RequestError(400, 'client-result-invalid')
192
192
  if ((action.type === 'comment-drafts.read' || action.type === 'component-drafts.read') && (result.type !== action.type || result.draft.id !== action.draft.id || result.draft.revision !== action.draft.revision || result.draft.token !== action.draft.token
193
193
  || action.type === 'component-drafts.read' && (result.type !== action.type || result.draft.blockId !== action.draft.blockId || result.draft.stepId !== action.draft.stepId)
194
194
  || result.offset !== action.offset || result.endOffset !== result.offset + result.jsonText.length || result.endOffset > result.totalUtf16
195
195
  || result.jsonText.length > (action.maxChars ?? 2048))) throw new RequestError(400, 'client-result-invalid')
196
- if ((action.type === 'comment-drafts.inspect' || action.type === 'component-drafts.inspect' || action.type === 'body-drafts.inspect') && (result.type !== action.type || result.drafts.length > (action.limit ?? 10)
196
+ if ((action.type === 'comment-drafts.inspect' || action.type === 'component-drafts.inspect' || action.type === 'body-drafts.inspect' || action.type === 'production-drafts.inspect') && (result.type !== action.type || result.drafts.length > (action.limit ?? 10)
197
197
  || action.cursor && action.cursor.token !== result.token || result.next && result.next.token !== result.token)) throw new RequestError(400, 'client-result-invalid')
198
198
  if (action.type === 'body-drafts.restore' || action.type === 'body-drafts.discard' || action.type === 'body-drafts.retry') {
199
199
  if (result.type !== action.type || !('outcome' in result) || result.draft !== action.draft
200
200
  || (action.type === 'body-drafts.restore' ? !['restored', 'already-saved'].includes(result.outcome)
201
201
  : action.type === 'body-drafts.discard' ? !['source-restored', 'backup-discarded'].includes(result.outcome) : result.outcome !== 'saved')) throw new RequestError(400, 'client-result-invalid')
202
202
  }
203
+ if (action.type === 'production-drafts.discard' && (result.type !== action.type || result.draft !== action.draft || !result.discarded)) throw new RequestError(400, 'client-result-invalid')
203
204
  const sameComment = (a: import('@lincyaw/kernel').ClientCommentDraftReference | null, b: import('@lincyaw/kernel').ClientCommentDraftReference | null) => a === null || b === null ? a === b
204
205
  : a.id === b.id && a.revision === b.revision && a.token === b.token
205
- if (action.type === 'comment-drafts.restore' && (result.type !== action.type || !sameComment(result.draft, action.draft) || result.composerId !== action.composerId
206
- || !sameComment(result.preservedCurrent, action.expectedCurrent) || result.restored.revision !== 1 || result.restored.id === action.draft.id || result.restored.id === action.expectedCurrent?.id)) throw new RequestError(400, 'client-result-invalid')
206
+ if (action.type === 'comment-drafts.restore' && (result.type !== action.type || !sameComment(result.draft, action.draft)
207
+ || action.composerId !== undefined && (result.composerId !== action.composerId || !sameComment(result.preservedCurrent, action.expectedCurrent ?? null))
208
+ || result.restored.revision !== 1 || result.restored.id === action.draft.id || result.restored.id === result.preservedCurrent?.id)) throw new RequestError(400, 'client-result-invalid')
207
209
  if (action.type === 'comment-drafts.discard' && (result.type !== action.type || !sameComment(result.draft, action.draft) || !result.discarded)) throw new RequestError(400, 'client-result-invalid')
208
210
  const sameDraft = (a: import('@lincyaw/kernel').ClientComponentDraftReference | null, b: import('@lincyaw/kernel').ClientComponentDraftReference | null) => a === null || b === null ? a === b
209
211
  : a.id === b.id && a.revision === b.revision && a.token === b.token && a.blockId === b.blockId && a.stepId === b.stepId