@hydranium/protocol 1.0.0-next.39 → 1.0.0-next.391

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.
Files changed (311) hide show
  1. package/README.md +46 -83
  2. package/lib/abstract-logger.d.ts +11 -0
  3. package/lib/abstract-logger.d.ts.map +1 -1
  4. package/lib/abstract-logger.js +16 -0
  5. package/lib/abstract-logger.js.map +1 -1
  6. package/lib/client/data-connection.d.ts +303 -0
  7. package/lib/client/data-connection.d.ts.map +1 -0
  8. package/lib/client/data-connection.js +534 -0
  9. package/lib/client/data-connection.js.map +1 -0
  10. package/lib/client/data-events.d.ts +11 -2
  11. package/lib/client/data-events.d.ts.map +1 -1
  12. package/lib/client/data-events.js +13 -1
  13. package/lib/client/data-events.js.map +1 -1
  14. package/lib/client/data-port.d.ts +34 -24
  15. package/lib/client/data-port.d.ts.map +1 -1
  16. package/lib/client/data-session.d.ts +762 -89
  17. package/lib/client/data-session.d.ts.map +1 -1
  18. package/lib/client/data-session.js +1253 -115
  19. package/lib/client/data-session.js.map +1 -1
  20. package/lib/client/index.d.ts +16 -9
  21. package/lib/client/index.d.ts.map +1 -1
  22. package/lib/client/index.js +16 -9
  23. package/lib/client/index.js.map +1 -1
  24. package/lib/client/message-relay.d.ts +6 -4
  25. package/lib/client/message-relay.d.ts.map +1 -1
  26. package/lib/client/message-relay.js +4 -4
  27. package/lib/client/message-relay.js.map +1 -1
  28. package/lib/client/post-message-transport.d.ts +69 -3
  29. package/lib/client/post-message-transport.d.ts.map +1 -1
  30. package/lib/client/post-message-transport.js +175 -1
  31. package/lib/client/post-message-transport.js.map +1 -1
  32. package/lib/client/rpc-connection.d.ts +173 -0
  33. package/lib/client/rpc-connection.d.ts.map +1 -0
  34. package/lib/client/rpc-connection.js +225 -0
  35. package/lib/client/rpc-connection.js.map +1 -0
  36. package/lib/client/worker-handshake.d.ts +94 -0
  37. package/lib/client/worker-handshake.d.ts.map +1 -0
  38. package/lib/client/worker-handshake.js +51 -0
  39. package/lib/client/worker-handshake.js.map +1 -0
  40. package/lib/client/working-copy.d.ts +420 -0
  41. package/lib/client/working-copy.d.ts.map +1 -0
  42. package/lib/client/working-copy.js +958 -0
  43. package/lib/client/working-copy.js.map +1 -0
  44. package/lib/client-ids.d.ts +45 -0
  45. package/lib/client-ids.d.ts.map +1 -0
  46. package/lib/client-ids.js +48 -0
  47. package/lib/client-ids.js.map +1 -0
  48. package/lib/clock.d.ts +50 -10
  49. package/lib/clock.d.ts.map +1 -1
  50. package/lib/clock.js +36 -1
  51. package/lib/clock.js.map +1 -1
  52. package/lib/console-logger.d.ts +23 -0
  53. package/lib/console-logger.d.ts.map +1 -0
  54. package/lib/console-logger.js +39 -0
  55. package/lib/console-logger.js.map +1 -0
  56. package/lib/data/data-protocol-methods.d.ts +4 -4
  57. package/lib/data/data-protocol-methods.d.ts.map +1 -1
  58. package/lib/data/data-protocol-methods.js +7 -0
  59. package/lib/data/data-protocol-methods.js.map +1 -1
  60. package/lib/data/data-server-protocol.d.ts +160 -50
  61. package/lib/data/data-server-protocol.d.ts.map +1 -1
  62. package/lib/data/events.d.ts +75 -31
  63. package/lib/data/events.d.ts.map +1 -1
  64. package/lib/data/requests.d.ts +84 -11
  65. package/lib/data/requests.d.ts.map +1 -1
  66. package/lib/debouncer.d.ts +7 -4
  67. package/lib/debouncer.d.ts.map +1 -1
  68. package/lib/debouncer.js +10 -10
  69. package/lib/debouncer.js.map +1 -1
  70. package/lib/errors.d.ts +241 -48
  71. package/lib/errors.d.ts.map +1 -1
  72. package/lib/errors.js +395 -60
  73. package/lib/errors.js.map +1 -1
  74. package/lib/format-log-arg.d.ts +33 -0
  75. package/lib/format-log-arg.d.ts.map +1 -0
  76. package/lib/format-log-arg.js +158 -0
  77. package/lib/format-log-arg.js.map +1 -0
  78. package/lib/glsp-edits-settled-actions.d.ts +54 -0
  79. package/lib/glsp-edits-settled-actions.d.ts.map +1 -0
  80. package/lib/glsp-edits-settled-actions.js +28 -0
  81. package/lib/glsp-edits-settled-actions.js.map +1 -0
  82. package/lib/glsp-request-model-args.d.ts +16 -0
  83. package/lib/glsp-request-model-args.d.ts.map +1 -0
  84. package/lib/glsp-request-model-args.js +19 -0
  85. package/lib/glsp-request-model-args.js.map +1 -0
  86. package/lib/glsp-save-model-actions.d.ts +55 -0
  87. package/lib/glsp-save-model-actions.d.ts.map +1 -0
  88. package/lib/glsp-save-model-actions.js +28 -0
  89. package/lib/glsp-save-model-actions.js.map +1 -0
  90. package/lib/index.d.ts +11 -0
  91. package/lib/index.d.ts.map +1 -1
  92. package/lib/index.js +11 -0
  93. package/lib/index.js.map +1 -1
  94. package/lib/latency-collector.d.ts +10 -4
  95. package/lib/latency-collector.d.ts.map +1 -1
  96. package/lib/latency-collector.js +2 -0
  97. package/lib/latency-collector.js.map +1 -1
  98. package/lib/logger.d.ts +38 -7
  99. package/lib/logger.d.ts.map +1 -1
  100. package/lib/logger.js +42 -4
  101. package/lib/logger.js.map +1 -1
  102. package/lib/messages/index.d.ts +4 -2
  103. package/lib/messages/index.d.ts.map +1 -1
  104. package/lib/messages/index.js +17 -4
  105. package/lib/messages/index.js.map +1 -1
  106. package/lib/messages/primitives.d.ts +59 -4
  107. package/lib/messages/primitives.d.ts.map +1 -1
  108. package/lib/messages/primitives.js +97 -4
  109. package/lib/messages/primitives.js.map +1 -1
  110. package/lib/model-server.d.ts +58 -11
  111. package/lib/model-server.d.ts.map +1 -1
  112. package/lib/model-server.js +4 -2
  113. package/lib/model-server.js.map +1 -1
  114. package/lib/model-service/base-version.d.ts +67 -0
  115. package/lib/model-service/base-version.d.ts.map +1 -0
  116. package/lib/model-service/base-version.js +44 -0
  117. package/lib/model-service/base-version.js.map +1 -0
  118. package/lib/model-service/index.d.ts +1 -1
  119. package/lib/model-service/index.d.ts.map +1 -1
  120. package/lib/model-service/index.js +4 -5
  121. package/lib/model-service/index.js.map +1 -1
  122. package/lib/model-service/reference-candidate.d.ts +5 -3
  123. package/lib/model-service/reference-candidate.d.ts.map +1 -1
  124. package/lib/node/index.d.ts +10 -0
  125. package/lib/node/index.d.ts.map +1 -0
  126. package/lib/node/index.js +29 -0
  127. package/lib/node/index.js.map +1 -0
  128. package/lib/node/process-memory.d.ts +66 -0
  129. package/lib/node/process-memory.d.ts.map +1 -0
  130. package/lib/node/process-memory.js +291 -0
  131. package/lib/node/process-memory.js.map +1 -0
  132. package/lib/noop-logger.d.ts.map +1 -1
  133. package/lib/noop-logger.js.map +1 -1
  134. package/lib/observable-value.js.map +1 -1
  135. package/lib/patch-merge.d.ts +63 -35
  136. package/lib/patch-merge.d.ts.map +1 -1
  137. package/lib/patch-merge.js +171 -25
  138. package/lib/patch-merge.js.map +1 -1
  139. package/lib/pending-work-tracker.d.ts +33 -0
  140. package/lib/pending-work-tracker.d.ts.map +1 -0
  141. package/lib/pending-work-tracker.js +48 -0
  142. package/lib/pending-work-tracker.js.map +1 -0
  143. package/lib/profile-session.d.ts +24 -8
  144. package/lib/profile-session.d.ts.map +1 -1
  145. package/lib/profile-session.js +13 -4
  146. package/lib/profile-session.js.map +1 -1
  147. package/lib/profiling.d.ts +15 -2
  148. package/lib/profiling.d.ts.map +1 -1
  149. package/lib/profiling.js.map +1 -1
  150. package/lib/project.d.ts +6 -2
  151. package/lib/project.d.ts.map +1 -1
  152. package/lib/project.js.map +1 -1
  153. package/lib/random-uuid.d.ts +14 -0
  154. package/lib/random-uuid.d.ts.map +1 -0
  155. package/lib/random-uuid.js +24 -0
  156. package/lib/random-uuid.js.map +1 -0
  157. package/lib/reconcile-write.d.ts +70 -0
  158. package/lib/reconcile-write.d.ts.map +1 -0
  159. package/lib/reconcile-write.js +69 -0
  160. package/lib/reconcile-write.js.map +1 -0
  161. package/lib/rpc/bind-rpc-methods.d.ts +6 -2
  162. package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
  163. package/lib/rpc/bind-rpc-methods.js +17 -7
  164. package/lib/rpc/bind-rpc-methods.js.map +1 -1
  165. package/lib/rpc/create-rpc-proxy.d.ts +3 -0
  166. package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
  167. package/lib/rpc/create-rpc-proxy.js +6 -1
  168. package/lib/rpc/create-rpc-proxy.js.map +1 -1
  169. package/lib/rpc/index.d.ts +1 -0
  170. package/lib/rpc/index.d.ts.map +1 -1
  171. package/lib/rpc/index.js +1 -0
  172. package/lib/rpc/index.js.map +1 -1
  173. package/lib/rpc/send-by-method-name.d.ts +76 -0
  174. package/lib/rpc/send-by-method-name.d.ts.map +1 -0
  175. package/lib/rpc/send-by-method-name.js +120 -0
  176. package/lib/rpc/send-by-method-name.js.map +1 -0
  177. package/lib/rpc/wire-prefix.js.map +1 -1
  178. package/lib/save-text-document.d.ts +40 -0
  179. package/lib/save-text-document.d.ts.map +1 -0
  180. package/lib/save-text-document.js +34 -0
  181. package/lib/save-text-document.js.map +1 -0
  182. package/lib/testing/catalogue-audit.js.map +1 -1
  183. package/lib/testing/data-doubles.d.ts +36 -11
  184. package/lib/testing/data-doubles.d.ts.map +1 -1
  185. package/lib/testing/data-doubles.js +47 -9
  186. package/lib/testing/data-doubles.js.map +1 -1
  187. package/lib/testing/fake-clock.d.ts +17 -2
  188. package/lib/testing/fake-clock.d.ts.map +1 -1
  189. package/lib/testing/fake-clock.js +61 -46
  190. package/lib/testing/fake-clock.js.map +1 -1
  191. package/lib/testing/harness.d.ts +9 -0
  192. package/lib/testing/harness.d.ts.map +1 -1
  193. package/lib/testing/index.d.ts +1 -0
  194. package/lib/testing/index.d.ts.map +1 -1
  195. package/lib/testing/index.js +4 -3
  196. package/lib/testing/index.js.map +1 -1
  197. package/lib/testing/node/duplex-connection.d.ts.map +1 -1
  198. package/lib/testing/node/duplex-connection.js +3 -2
  199. package/lib/testing/node/duplex-connection.js.map +1 -1
  200. package/lib/testing/node/duplex-stream.js.map +1 -1
  201. package/lib/testing/node/index.d.ts +2 -0
  202. package/lib/testing/node/index.d.ts.map +1 -1
  203. package/lib/testing/node/index.js +3 -2
  204. package/lib/testing/node/index.js.map +1 -1
  205. package/lib/testing/node/message-port-pair.d.ts +25 -0
  206. package/lib/testing/node/message-port-pair.d.ts.map +1 -0
  207. package/lib/testing/node/message-port-pair.js +26 -0
  208. package/lib/testing/node/message-port-pair.js.map +1 -0
  209. package/lib/testing/node/unhandled-rejections.d.ts +20 -0
  210. package/lib/testing/node/unhandled-rejections.d.ts.map +1 -0
  211. package/lib/testing/node/unhandled-rejections.js +35 -0
  212. package/lib/testing/node/unhandled-rejections.js.map +1 -0
  213. package/lib/testing/transfer-node-builder.d.ts +81 -0
  214. package/lib/testing/transfer-node-builder.d.ts.map +1 -0
  215. package/lib/testing/transfer-node-builder.js +47 -0
  216. package/lib/testing/transfer-node-builder.js.map +1 -0
  217. package/lib/testing/wait-for.d.ts +9 -3
  218. package/lib/testing/wait-for.d.ts.map +1 -1
  219. package/lib/testing/wait-for.js +57 -11
  220. package/lib/testing/wait-for.js.map +1 -1
  221. package/lib/tracer.d.ts.map +1 -1
  222. package/lib/tracer.js +5 -9
  223. package/lib/tracer.js.map +1 -1
  224. package/lib/transfer-diagnostic.d.ts +11 -0
  225. package/lib/transfer-diagnostic.d.ts.map +1 -1
  226. package/lib/transfer-diagnostic.js +17 -0
  227. package/lib/transfer-diagnostic.js.map +1 -1
  228. package/lib/transfer-document.d.ts +108 -32
  229. package/lib/transfer-document.d.ts.map +1 -1
  230. package/lib/transfer-document.js +17 -9
  231. package/lib/transfer-document.js.map +1 -1
  232. package/lib/transfer-element.d.ts +4 -4
  233. package/lib/types.d.ts +32 -0
  234. package/lib/types.d.ts.map +1 -0
  235. package/lib/{model-service/args.js → types.js} +2 -2
  236. package/lib/types.js.map +1 -0
  237. package/lib/uri.d.ts.map +1 -1
  238. package/lib/uri.js.map +1 -1
  239. package/lib/util.d.ts +8 -2
  240. package/lib/util.d.ts.map +1 -1
  241. package/lib/util.js +32 -4
  242. package/lib/util.js.map +1 -1
  243. package/package.json +24 -40
  244. package/src/abstract-logger.ts +18 -0
  245. package/src/client/data-connection.ts +654 -0
  246. package/src/client/data-events.ts +15 -1
  247. package/src/client/data-port.ts +36 -25
  248. package/src/client/data-session.ts +1606 -137
  249. package/src/client/index.ts +16 -9
  250. package/src/client/message-relay.ts +6 -4
  251. package/src/client/post-message-transport.ts +224 -4
  252. package/src/client/rpc-connection.ts +302 -0
  253. package/src/client/worker-handshake.ts +121 -0
  254. package/src/client/working-copy.ts +1116 -0
  255. package/src/client-ids.ts +49 -0
  256. package/src/clock.ts +68 -10
  257. package/src/console-logger.ts +39 -0
  258. package/src/data/data-protocol-methods.ts +8 -1
  259. package/src/data/data-server-protocol.ts +184 -49
  260. package/src/data/events.ts +77 -31
  261. package/src/data/requests.ts +90 -11
  262. package/src/debouncer.ts +11 -11
  263. package/src/errors.ts +496 -71
  264. package/src/format-log-arg.ts +176 -0
  265. package/src/glsp-edits-settled-actions.ts +62 -0
  266. package/src/glsp-request-model-args.ts +16 -0
  267. package/src/glsp-save-model-actions.ts +64 -0
  268. package/src/index.ts +11 -0
  269. package/src/latency-collector.ts +10 -3
  270. package/src/logger.ts +44 -8
  271. package/src/messages/index.ts +12 -2
  272. package/src/messages/primitives.ts +129 -5
  273. package/src/model-server.ts +62 -17
  274. package/src/model-service/base-version.ts +75 -0
  275. package/src/model-service/index.ts +4 -5
  276. package/src/model-service/reference-candidate.ts +5 -3
  277. package/src/node/index.ts +14 -0
  278. package/src/node/process-memory.ts +299 -0
  279. package/src/patch-merge.ts +230 -45
  280. package/src/pending-work-tracker.ts +48 -0
  281. package/src/profile-session.ts +31 -11
  282. package/src/profiling.ts +15 -2
  283. package/src/project.ts +6 -2
  284. package/src/random-uuid.ts +21 -0
  285. package/src/reconcile-write.ts +131 -0
  286. package/src/rpc/README.md +6 -6
  287. package/src/rpc/bind-rpc-methods.ts +18 -8
  288. package/src/rpc/create-rpc-proxy.ts +6 -1
  289. package/src/rpc/index.ts +1 -0
  290. package/src/rpc/send-by-method-name.ts +140 -0
  291. package/src/save-text-document.ts +39 -0
  292. package/src/testing/data-doubles.ts +119 -19
  293. package/src/testing/fake-clock.ts +76 -48
  294. package/src/testing/harness.ts +10 -0
  295. package/src/testing/index.ts +4 -3
  296. package/src/testing/node/duplex-connection.ts +3 -2
  297. package/src/testing/node/index.ts +3 -2
  298. package/src/testing/node/message-port-pair.ts +40 -0
  299. package/src/testing/node/unhandled-rejections.ts +31 -0
  300. package/src/testing/transfer-node-builder.ts +107 -0
  301. package/src/testing/wait-for.ts +61 -13
  302. package/src/tracer.ts +5 -9
  303. package/src/transfer-diagnostic.ts +17 -0
  304. package/src/transfer-document.ts +130 -34
  305. package/src/transfer-element.ts +4 -4
  306. package/src/types.ts +30 -0
  307. package/src/util.ts +33 -6
  308. package/lib/model-service/args.d.ts +0 -64
  309. package/lib/model-service/args.d.ts.map +0 -1
  310. package/lib/model-service/args.js.map +0 -1
  311. package/src/model-service/args.ts +0 -67
@@ -9,11 +9,11 @@
9
9
  import type { TransferDiagnostic } from '../transfer-diagnostic';
10
10
  import type { TransferElement } from '../transfer-element';
11
11
  import type { Project } from '../project';
12
- import type { TransferDocument } from '../transfer-document';
12
+ import type { TransferCreatedDocument, TransferDocument, TransferSavedDocument, TransferWatchedDocument, TransferWrittenDocument } from '../transfer-document';
13
13
  import type { CloseModelArgs, FindNextNameArgs, OpenModelArgs, ReferenceContext, ReferenceRequest } from '../model-server';
14
14
  import type { ReferenceCandidate, ReferenceTarget } from '../model-service/reference-candidate';
15
- import type { ProjectsChangedEvent, TransferDocumentDeletedEvent, TransferDocumentSavedEvent, TransferDocumentsBuiltEvent, TransferDocumentUpdatedEvent } from './events';
16
- import type { GetModelDocumentArgs, GetProjectForUriArgs, TransferSaveDocumentArgs, WatchModelDocumentArgs, TransferUpdateDocumentArgs } from './requests';
15
+ import type { ProjectsChangedEvent, TransferDocumentDeletedEvent, TransferDocumentDirtyChangedEvent, TransferDocumentSavedEvent, TransferDocumentsBuiltEvent, TransferDocumentUpdatedEvent } from './events';
16
+ import type { CloseSessionArgs, CreateModelDocumentArgs, CreateSessionArgs, GetModelDocumentArgs, GetProjectForUriArgs, TransferDeleteDocumentArgs, TransferPersistDocumentArgs, TransferSaveDocumentArgs, WatchModelDocumentArgs, TransferUpdateDocumentArgs, TransferUpdateDocumentsArgs } from './requests';
17
17
  /**
18
18
  * Document-scoped slice of the data-server wire contract: the per-document
19
19
  * lifecycle (get / update / save), the per-`(uri, clientId)` watch
@@ -32,34 +32,77 @@ import type { GetModelDocumentArgs, GetProjectForUriArgs, TransferSaveDocumentAr
32
32
  */
33
33
  export interface DocumentServerProtocol<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic> {
34
34
  /**
35
- * Open a document for an editor session and return its current state.
36
- * Registers `(uri, clientId)` with the multi-client document manager
37
- * (so concurrent editors share one built document) and returns the
38
- * document at the server's configured target phase — the same shape
39
- * {@link getModelDocument} returns, except that `version` is taken from
40
- * the text-document store so the caller's first `baseVersion` write
41
- * cannot self-conflict. Idempotent in registration terms: opening an
42
- * already-open document refreshes the client registration. Note it does
43
- * NOT avoid a rebuild — a second client attaching triggers
44
- * `refreshContent`, which fires a change event, so mounting a form on a
45
- * document already open in a text editor rebuilds it.
35
+ * Register `args.clientId` as a client session owned by this connection.
36
+ * Rejects with a `DuplicateClientIdError` code when the id is live anywhere
37
+ * in the server process, and with a `ReservedClientIdError` code when the
38
+ * framework reserves it.
46
39
  *
47
- * The default `DataServer` impl delegates to `ModelService.open` then
48
- * reads the built state. Pair with {@link watchModelDocument} to receive
49
- * subsequent build-phase events (open returns a one-shot snapshot;
50
- * later validation diagnostics arrive on the watch channel).
40
+ * A request carrying a registered id acts as that session: it writes only
41
+ * what the session has open, failing with a `DocumentNotOpenError` code
42
+ * otherwise, and opens nothing implicitly; its open reads the file and takes
43
+ * no `languageId`, `version` or `text` seed. The session ends with
44
+ * {@link closeSession} or when the connection closes, and either closes
45
+ * every document it has open.
46
+ *
47
+ * A registration carrying the `resumeToken` an earlier registration of the
48
+ * same id carried ends that session first, from any connection, so a client
49
+ * whose connection dropped can register again before the server notices.
50
+ */
51
+ createSession(args: CreateSessionArgs): Promise<void>;
52
+ /**
53
+ * End a session this connection registered: close every document it has
54
+ * open, drop its watches, and free its id. A no-op for an id this
55
+ * connection did not register.
56
+ */
57
+ closeSession(args: CloseSessionArgs): Promise<void>;
58
+ /**
59
+ * Create a document with `args.text`, open for the session, and return it
60
+ * as {@link openModelDocument} does, with the version the create made in
61
+ * `created`. The answer is read after the create, so it can already hold
62
+ * another client's write or an integrity repair; a write based on
63
+ * `created.version` then conflicts. It reaches disk with the first save.
64
+ * Fails when the file exists, any client has the URI open, or a lost
65
+ * client's unsaved text is held for it, and with a
66
+ * `SessionClosedError` code when `args.clientId` is not a session
67
+ * registered on this connection.
68
+ */
69
+ createModelDocument(args: CreateModelDocumentArgs): Promise<TransferCreatedDocument<TTransfer, TDiagnostic>>;
70
+ /**
71
+ * Write several documents the session has open, all or none: a conflict, a
72
+ * document not open, or a model for a document whose parse lacks some of
73
+ * its text fails the whole set before any text applies.
74
+ * Resolves to the documents in the order given, each with the version its
75
+ * text took in `written`, once the language client has answered the push
76
+ * of each, or the server-side bound on that wait passes, as
77
+ * {@link updateModelDocument} does. Only for a session registered on this
78
+ * connection.
79
+ */
80
+ updateModelDocuments(args: TransferUpdateDocumentsArgs<TTransfer>): Promise<TransferWrittenDocument<TTransfer, TDiagnostic>[]>;
81
+ /**
82
+ * Open a document for the client session `clientId` and return its current
83
+ * state. `clientId` must be a session this connection registered with
84
+ * {@link createSession}; any other id fails with the closed-session code,
85
+ * as every document request here does. The document is read from disk
86
+ * unless a client has it open already, so the request carries no
87
+ * `languageId`, `version` or `text` seed. Returns the document at
88
+ * the server's configured target phase, as {@link getModelDocument} does.
89
+ * A repeat open changes nothing.
90
+ *
91
+ * Pair with {@link watchModelDocument} to receive subsequent build-phase
92
+ * events (open returns a one-shot snapshot; later validation diagnostics
93
+ * arrive on the watch channel).
51
94
  */
52
- openModelDocument(args: OpenModelArgs): Promise<TransferDocument<TTransfer, TDiagnostic>>;
95
+ openModelDocument(args: Pick<OpenModelArgs, 'uri' | 'clientId' | 'options'>): Promise<TransferDocument<TTransfer, TDiagnostic>>;
53
96
  /**
54
- * Close an editor session for `(uri, clientId)`. Counterpart to
55
- * {@link openModelDocument}; the underlying document stays built until
56
- * every registered client has closed. The default `DataServer` impl
57
- * delegates to `ModelService.close` and ALSO releases any watch for the
58
- * same `(uri, clientId)` (closing a session frees its own watch — a
59
- * forgotten {@link unwatchModelDocument} would otherwise leak dispatch;
60
- * the implicit unwatch is idempotent). `watchModelDocument` is NOT
61
- * coupled the other way: opening does not force a watch, so a snapshot
62
- * reader can open without streaming.
97
+ * Close the session's open of `uri`. Counterpart to
98
+ * {@link openModelDocument}; the document stays open until every client
99
+ * has closed it, and then the server releases it, by default reverting it
100
+ * to disk. The default
101
+ * `DataServer` impl ALSO releases any watch for the same
102
+ * `(uri, clientId)` (a forgotten {@link unwatchModelDocument} would
103
+ * otherwise leak dispatch; the implicit unwatch is idempotent).
104
+ * `watchModelDocument` is NOT coupled the other way: opening does not force
105
+ * a watch, so a snapshot reader can open without streaming.
63
106
  */
64
107
  closeModelDocument(args: CloseModelArgs): Promise<void>;
65
108
  /**
@@ -70,32 +113,73 @@ export interface DocumentServerProtocol<TTransfer extends TransferElement, TDiag
70
113
  */
71
114
  getModelDocument(args: GetModelDocumentArgs): Promise<TransferDocument<TTransfer, TDiagnostic>>;
72
115
  /**
73
- * Update a document's content. The response carries the latest built
74
- * state including diagnostics; callers observe convergence via that
75
- * response.
116
+ * Update a document's content as the session `clientId`, which must have
117
+ * it open. The response carries the latest built state including
118
+ * diagnostics. Callers observe convergence via that response. `written`
119
+ * carries the version the write's text took, which tells a writer whether
120
+ * the build holds a later text too. It is sent once the language client
121
+ * has answered the push of the text, or the server-side bound on that wait
122
+ * passes, as {@link saveModelDocument}'s is, so an editor already shows
123
+ * the write when it arrives. A model, not text, for a document whose parse
124
+ * lacks some of its text fails with a `DocumentSyntaxError` code, unless
125
+ * the write is a `restore`.
76
126
  */
77
- updateModelDocument(args: TransferUpdateDocumentArgs<TTransfer>): Promise<TransferDocument<TTransfer, TDiagnostic>>;
127
+ updateModelDocument(args: TransferUpdateDocumentArgs<TTransfer>): Promise<TransferWrittenDocument<TTransfer, TDiagnostic>>;
78
128
  /**
79
- * Persist a document to disk. The response is the post-save document
80
- * state (matches the file on disk). Save semantics depend on the
81
- * filesystem-provider wiring; rejection paths surface as awaited
82
- * promise rejections.
129
+ * Write a document as the session `clientId`, which must have it open, and
130
+ * persist it to disk. The response is the build of the text written, with
131
+ * its version in `persisted`, sent once the language client has answered
132
+ * the push of that text, applied or refused, or a server-side bound on
133
+ * that wait passes; it does not wait again for a push that wait already
134
+ * gave up on and the client has not answered since. Save semantics depend
135
+ * on the filesystem-provider wiring; rejection paths surface as awaited
136
+ * promise rejections, as a model for a document whose parse lacks some of
137
+ * its text does with a `DocumentSyntaxError` code.
83
138
  */
84
- saveModelDocument(args: TransferSaveDocumentArgs<TTransfer>): Promise<TransferDocument<TTransfer, TDiagnostic>>;
139
+ saveModelDocument(args: TransferSaveDocumentArgs<TTransfer>): Promise<TransferSavedDocument<TTransfer, TDiagnostic>>;
140
+ /**
141
+ * Persist the text the server holds for a document the session `clientId`
142
+ * has open, as it is: no update and no serialisation, so another client's
143
+ * unsaved text keeps its formatting. `baseVersion` is checked in the step
144
+ * that takes the text, so text that moved on fails with a `ConflictError`
145
+ * code. The saved event names this session, whoever wrote the text.
146
+ * Answers after the same language-client wait as {@link saveModelDocument},
147
+ * with the document's latest build, read after that wait, so another
148
+ * session's write during it shows; `persisted` carries the version written.
149
+ */
150
+ persistModelDocument(args: TransferPersistDocumentArgs): Promise<TransferSavedDocument<TTransfer, TDiagnostic>>;
151
+ /**
152
+ * Delete a document the session `clientId` has open, at once: its file,
153
+ * then the document, as a deletion a file watcher reports removes it. Every
154
+ * session's open of it closes and every client hears
155
+ * {@link DocumentClientProtocol.onDocumentDeleted} naming this session; the
156
+ * session's own watch is released, as {@link closeModelDocument} releases
157
+ * it. `baseVersion` is checked in the step that marks the document for
158
+ * deletion, so text that moved on fails with a `ConflictError` code. A file
159
+ * already gone deletes only the document; a file that cannot be removed
160
+ * fails the call and changes nothing. Resolves once the build that removes
161
+ * the document has run; a read then answers the URI without a model, unless
162
+ * an editor still has it open, whose buffer the document is built from.
163
+ */
164
+ deleteModelDocument(args: TransferDeleteDocumentArgs): Promise<void>;
85
165
  /**
86
166
  * Start watching `(uri, clientId)`. The server starts dispatching
87
167
  * {@link DocumentClientProtocol.onDocumentUpdated} on the paired wire
88
168
  * for every build-phase event on `uri`.
89
169
  *
90
- * Returns `Promise<void>` — the bidirectional pattern means the event
91
- * channel is the client interface, not a returned handle. Callers fan
92
- * out a single inbound `onDocumentUpdated` to multiple local listeners
93
- * with their own `Emitter<T>` (matching Theia's pattern). Pair every
94
- * `watchModelDocument` with {@link unwatchModelDocument} when no longer
95
- * needed; the server holds the watch record until the matching unwatch
96
- * lands.
170
+ * Answers with the key the watch's events name the document by, whether
171
+ * a document exists, taken once the watch is in place and the document
172
+ * is loaded as a read loads it, the text held at that moment, and the
173
+ * position of the last update or deletion event sent as of it, so an event
174
+ * the client heard while the watch was in flight tells by its own position
175
+ * whether it is newer than the answer. No handle: the event channel is the
176
+ * client interface. Callers fan out a single inbound `onDocumentUpdated` to
177
+ * multiple local listeners with their own `Emitter<T>` (matching Theia's
178
+ * pattern). Pair every `watchModelDocument` with
179
+ * {@link unwatchModelDocument} when no longer needed; the server holds the
180
+ * watch record until the matching unwatch lands.
97
181
  */
98
- watchModelDocument(args: WatchModelDocumentArgs): Promise<void>;
182
+ watchModelDocument(args: WatchModelDocumentArgs): Promise<TransferWatchedDocument>;
99
183
  /**
100
184
  * Stop watching `(uri, clientId)` previously started by
101
185
  * {@link watchModelDocument}. Idempotent — unwatching twice is a no-op.
@@ -171,6 +255,19 @@ export interface ProjectServerProtocol<TProject extends Project = Project> {
171
255
  */
172
256
  export interface DataServerProtocol<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic, TProject extends Project = Project> extends DocumentServerProtocol<TTransfer, TDiagnostic>, ProjectServerProtocol<TProject> {
173
257
  }
258
+ /**
259
+ * The diagnostic shape a server answers with, read back off its own
260
+ * declaration.
261
+ *
262
+ * This is what lets a client tier stay generic over the server alone and still
263
+ * describe what it hands back. Both parameters must be inferred: naming
264
+ * {@link TransferElement} for the transfer instead fails to match while that
265
+ * parameter is still generic, and a default declared against the constraint
266
+ * then stops satisfying it.
267
+ */
268
+ export type DiagnosticOf<TServer> = TServer extends DocumentServerProtocol<infer _TTransfer, infer TDiagnostic> ? TDiagnostic : TransferDiagnostic;
269
+ /** The project shape a server answers with, read back off its own declaration. */
270
+ export type ProjectOf<TServer> = TServer extends ProjectServerProtocol<infer TProject> ? TProject : Project;
174
271
  /**
175
272
  * Cross-reference / naming slice of the server surface — scope-aware
176
273
  * queries that resolve against the language's reference services. NOT part
@@ -181,11 +278,11 @@ export interface DataServerProtocol<TTransfer extends TransferElement, TDiagnost
181
278
  * source/URI (an `ElementSource` with no URI resolves to the sole
182
279
  * registered language; a multi-language workspace overrides).
183
280
  *
184
- * Generic over the transfer root type only — the resolution result
185
- * ({@link ReferenceTarget}) carries the resolved node's encoded subtree;
186
- * candidates and names are diagnostic-free.
281
+ * Not generic over a server's root type: {@link resolveReference} answers with
282
+ * a node a reference names, which is no document root, and candidates and
283
+ * names are diagnostic-free.
187
284
  */
188
- export interface ReferenceServerProtocol<TTransfer extends TransferElement> {
285
+ export interface ReferenceServerProtocol {
189
286
  /**
190
287
  * List the reference candidates reachable for the property named in `ctx`
191
288
  * from its (possibly synthetic) source. Backed by the language's
@@ -197,8 +294,11 @@ export interface ReferenceServerProtocol<TTransfer extends TransferElement> {
197
294
  * target's document URI, display fields, and the resolved node's encoded
198
295
  * transfer subtree. Resolves via the language's reference services;
199
296
  * `undefined` when the reference does not resolve.
297
+ *
298
+ * `TElement` is the caller's claim about the target node's type; nothing
299
+ * checks it, so leave it at the default unless the reference names one type.
200
300
  */
201
- resolveReference(ref: ReferenceRequest): Promise<ReferenceTarget<TTransfer> | undefined>;
301
+ resolveReference<TElement extends TransferElement = TransferElement>(ref: ReferenceRequest): Promise<ReferenceTarget<TElement> | undefined>;
202
302
  /**
203
303
  * Compute the next free name for a new element of `args.type` based on
204
304
  * `args.proposal`, unique within the `args.tier` scope (default
@@ -235,6 +335,16 @@ export interface DocumentClientProtocol<TTransfer extends TransferElement, TDiag
235
335
  * codepath, not a subscription codepath).
236
336
  */
237
337
  onDocumentSaved(event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>): void;
338
+ /**
339
+ * Delivered when a subscribed document's text starts or stops differing
340
+ * from its file, as the server last knew it. Gated like
341
+ * {@link onDocumentSaved}; the answer at any one moment is the `dirty` of
342
+ * the documents the server sends. After a reconnect, a `DataSession`
343
+ * delivers here the answer of each document it restored, when that differs
344
+ * from the last this client was told: the flips while the connection was
345
+ * down reached no one.
346
+ */
347
+ onDocumentDirtyChanged(event: TransferDocumentDirtyChangedEvent): void;
238
348
  /**
239
349
  * Delivered when a document's backing file was removed. Separate from
240
350
  * {@link onDocumentUpdated} for the same reason as {@link onDocumentSaved},
@@ -1 +1 @@
1
- {"version":3,"file":"data-server-protocol.d.ts","sourceRoot":"","sources":["../../src/data/data-server-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC3H,OAAO,KAAK,EAAE,k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AAK,EAAE,0BAA0B,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,IAAI,CAAC;IAEjF;;;;;;;;OAQG;IACH,sBAAsB,CAAC,KAAK,EAAE,iCAAiC,GAAG,IAAI,CAAC;IAEvE;;;;;;;;;OASG;IACH,iBAAiB,CAAC,KAAK,EAAE,4BAA4B,GAAG,IAAI,CAAC;IAE7D;;;;;;;OAOG;IACH,gBAAgB,CAAC,KAAK,EAAE,2BAA2B,GAAG,IAAI,CAAC;CAC7D;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB,CAAC,QAAQ,SAAS,OAAO,GAAG,OAAO;IACtE;;;;;;;;OAQG;IACH,iBAAiB,CAAC,KAAK,EAAE,oBAAoB,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;CACjE;AAED;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB,CAChC,SAAS,SAAS,eAAe,EACjC,WAAW,SAAS,kBAAkB,GAAG,kBAAkB,EAC3D,QAAQ,SAAS,OAAO,GAAG,OAAO,CAElC,SAAQ,sBAAsB,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,qBAAqB,CAAC,QAAQ,CAAC;CAAG"}
@@ -9,26 +9,28 @@
9
9
  import type { TransferDiagnostic } from '../transfer-diagnostic';
10
10
  import type { TransferElement } from '../transfer-element';
11
11
  import type { Project } from '../project';
12
- import type { TransferDocument } from '../transfer-document';
12
+ import type { TextState, TransferDocument } from '../transfer-document';
13
13
  /**
14
14
  * Why an update event fired. Subscribers filter on reason for behaviour
15
15
  * decisions (e.g. dirty-flag handling, undo-history grouping, telemetry):
16
16
  *
17
- * - `'changed'` — the URI appeared in `DocumentBuilder.onUpdate`'s
18
- * `changed` list. The framework's underlying primitive is "this URI was
19
- * passed to `documentBuilder.update(changed, deleted)`", which spans
20
- * `didChange` text-document events, `notifyDidChangeTextDocument` calls,
21
- * and any programmatic `documentBuilder.update([uri], [])` invocation.
22
- * The name matches Langium's own `changed` parameter — it's vague-on-
23
- * purpose because the underlying primitive is.
24
- * - `'rebuilt'` — the URI was rebuilt as a cascade from another URI's
25
- * build (dependency graph re-derivation), without itself being passed to
26
- * `documentBuilder.update`. The complement of `'changed'`.
17
+ * - `'changed'` — the server's first update event for the document's current
18
+ * version: its content changed since the last one. A write whose build a
19
+ * later write cancelled is still `'changed'` in the build that takes over.
20
+ * - `'rebuilt'` — a later event for a version the server already delivered,
21
+ * whether or not any client watched it then: something the document depends
22
+ * on changed, or the document was built again with the same content. The
23
+ * complement of `'changed'`.
27
24
  * - `'saved'` — emitted by adopters that synthesise a unified update stream
28
25
  * from both `onDocumentUpdated` and `onDocumentSaved`. The framework's own
29
26
  * `dispatchPhaseEvent` does NOT emit `'saved'` — saves take the dedicated
30
27
  * `DataClientProtocol.onDocumentSaved` channel.
31
28
  *
29
+ * The version rule needs a version the server keeps and builds that validate.
30
+ * For a document no client has opened, or when rebuilds do not validate,
31
+ * `'changed'` means the URI was passed to `DocumentBuilder.update` for this
32
+ * build. A document that a validating build skips is `'changed'` every time.
33
+ *
32
34
  * Deletion is deliberately NOT a member. An update event carries a built
33
35
  * document, which a deleted one has none of, and the phase-driven path that
34
36
  * produces these events never runs for a deleted URI — the builder drops the
@@ -39,43 +41,71 @@ export type TransferDocumentUpdateReason = 'changed' | 'rebuilt' | 'saved';
39
41
  /**
40
42
  * Delivered on the data-server when a document's content (or existence)
41
43
  * changed. Subscribers receive this via `DocumentServerProtocol.watchModelDocument`.
42
- *
43
- * The `document` field carries the latest built state — diagnostics + root
44
- * are coherent with each other at the time the event fired.
45
44
  */
46
45
  export interface TransferDocumentUpdatedEvent<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic> {
46
+ /** The latest built state: diagnostics and root are coherent with each other at the time the event fired. */
47
47
  document: TransferDocument<TTransfer, TDiagnostic>;
48
- /** Stable identifier of the client that triggered the update. */
48
+ /**
49
+ * The client whose write this event echoes: the author of the version on a
50
+ * `'changed'`, and the unknown-client id on a `'rebuilt'`, which echoes no
51
+ * write. A recipient compares it against its own id to recognise its echo.
52
+ * The build that follows a document's release names the release id
53
+ * instead.
54
+ */
49
55
  sourceClientId: string;
56
+ /** See {@link TransferDocumentUpdateReason} for which reasons the framework sends. */
50
57
  reason: TransferDocumentUpdateReason;
58
+ /**
59
+ * The position of this event among the update and deletion events the
60
+ * server sent on this connection, which a watch's answer carries as of
61
+ * the moment it was taken: a greater one was sent later.
62
+ */
63
+ sequence: number;
51
64
  }
52
65
  /** Callback shape for `DataClientProtocol.onDocumentUpdated`. */
53
66
  export type TransferDocumentUpdatedListener<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic> = (event: TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>) => void;
54
67
  /**
55
- * Delivered on the data-server when a document was persisted to disk via
56
- * `DataServerProtocol.saveModelDocument`. Distinct from
57
- * {@link TransferDocumentUpdatedEvent}: subscribers that only care about
58
- * persistence (external sync, editor "saved" indicators, dirty-flag
59
- * clear) listen for this event family instead of filtering an update
60
- * stream for `reason: 'saved'`.
61
- *
62
- * The `document` field carries the post-save built state — same shape
63
- * the synchronous `saveModelDocument` RPC response returns, delivered
64
- * to subscribers (`DataClientProtocol.onDocumentSaved`) so non-caller
65
- * clients see the persistence event too.
68
+ * Delivered on the data-server when a subscribed document was saved to disk,
69
+ * whichever client saved it, an editor's save through the LSP head included.
70
+ * Distinct from {@link TransferDocumentUpdatedEvent}: subscribers that only
71
+ * care about persistence (external sync, editor "saved" indicators,
72
+ * dirty-flag clear) listen for this event family instead of filtering an
73
+ * update stream for `reason: 'saved'`.
66
74
  */
67
75
  export interface TransferDocumentSavedEvent<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic> {
76
+ /** The latest built state, taken after the save. */
68
77
  document: TransferDocument<TTransfer, TDiagnostic>;
69
78
  /**
70
- * The client whose `saveModelDocument` call produced this. Every subscriber
71
- * receives the event including the originator, which already had the same
72
- * state as the RPC response — compare against your own id to drop the echo
73
- * rather than re-rendering from it.
79
+ * The client whose save produced this, also when another client wrote the
80
+ * persisted text: the caller of `saveModelDocument` or
81
+ * `persistModelDocument`, or `LANGUAGE_CLIENT_ID` for an editor's save
82
+ * through the LSP head. Every subscriber receives the event, the saving
83
+ * client included, so compare against your own id to drop the echo.
74
84
  */
75
85
  sourceClientId: string;
76
86
  }
77
87
  /** Callback shape for `DataClientProtocol.onDocumentSaved`. */
78
88
  export type TransferDocumentSavedListener<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic> = (event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>) => void;
89
+ /**
90
+ * Delivered on the data-server when a watched document's text starts or stops
91
+ * differing from its file, as the server last knew the file. The current
92
+ * answer rides on every transfer document the server sends as `text.dirty`;
93
+ * this carries only its changes, so a client that follows it needs no rebuild
94
+ * to learn of a save.
95
+ */
96
+ export interface TransferDocumentDirtyChangedEvent {
97
+ /** Canonical URI, keyed as the subscription is. */
98
+ readonly uri: string;
99
+ /**
100
+ * The text the answer was decided on. It is sent before that text is
101
+ * built, so a `text.version` ahead of the model a client holds means an
102
+ * update at this version or a later one follows. Absent when the document
103
+ * no longer exists, or when the build that follows its release failed.
104
+ */
105
+ readonly text?: TextState;
106
+ }
107
+ /** Callback shape for `DataClientProtocol.onDocumentDirtyChanged`. */
108
+ export type TransferDocumentDirtyChangedListener = (event: TransferDocumentDirtyChangedEvent) => void;
79
109
  /**
80
110
  * Delivered on the data-server when a document's backing file was removed.
81
111
  * Carries no document, and cannot: the state a
@@ -99,11 +129,25 @@ export type TransferDocumentSavedListener<TTransfer extends TransferElement, TDi
99
129
  * A watch survives the deletion, so a file that comes back resumes delivering
100
130
  * `onDocumentUpdated` to the same subscribers with no re-subscription. A
101
131
  * client that responds by closing its editor releases the watch through
102
- * `closeModelDocument` as usual.
132
+ * `closeModelDocument` as usual, and `deleteModelDocument` releases the
133
+ * deleting session's own.
103
134
  */
104
135
  export interface TransferDocumentDeletedEvent {
105
136
  /** Canonical URI of the removed document, keyed as the subscription is. */
106
137
  readonly uri: string;
138
+ /**
139
+ * The session whose `deleteModelDocument` removed the file, so it can tell
140
+ * its own deletion from another's; the unknown-client id for a file
141
+ * removed outside any session, as a file watcher reports one, and for one
142
+ * a `DataConnection` found gone after a reconnect, which no event named.
143
+ */
144
+ readonly sourceClientId: string;
145
+ /**
146
+ * The position of this event among the update and deletion events the
147
+ * server sent on this connection, as on an update; absent on a deletion a
148
+ * `DataConnection` found after a reconnect, which the server never sent.
149
+ */
150
+ readonly sequence?: number;
107
151
  }
108
152
  /** Callback shape for `DataClientProtocol.onDocumentDeleted`. */
109
153
  export type TransferDocumentDeletedListener = (event: TransferDocumentDeletedEvent) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/data/events.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,4BAA4B,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAE3E;;;;;;GAMG;AACH,MAAM,WAAW,4BAA4B,CAC1C,SAAS,SAAS,eAAe,EACjC,WAAW,SAAS,kBAAkB,GAAG,kBAAkB;IAE3D,QAAQ,EAAE,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IACnD,iEAAiE;IACjE,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,4BAA4B,CAAC;CACvC;AAED,iEAAiE;AACjE,MAAM,MAAM,+BAA+B,CACxC,SAAS,SAAS,eAAe,EACjC,WAAW,SAAS,kBAAkB,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AAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AAElE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,oBAAoB,CAAC,QAAQ,SAAS,OAAO,GAAG,OAAO;IACrE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;CACvC;AAED,iEAAiE;AACjE,MAAM,MAAM,uBAAuB,CAAC,QAAQ,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,KAAK,EAAE,oBAAoB,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC"}
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
- import type { TransferSaveArgs, TransferUpdateArgs } from '../model-service/args';
9
+ import type { BaseVersion } from '../model-service/base-version';
10
10
  /** Get the current state of a single document. The server returns the latest built version. */
11
11
  export interface GetModelDocumentArgs {
12
12
  /** Document URI. */
@@ -37,27 +37,100 @@ export interface GetProjectForUriArgs {
37
37
  uri: string;
38
38
  }
39
39
  /**
40
- * Update a document's content. Wire-side projection of the facade's
41
- * {@link TransferUpdateArgs}; structurally identical so the data-server RPC
42
- * handler can forward straight to the in-process `ModelService.update`
43
- * without an args mapping.
40
+ * Update a document the session `clientId` has open. Generic over `TTransfer`
41
+ * so adopters parameterise the structured shape against their grammar's
42
+ * transfer-model overlay; passing a string is always allowed.
44
43
  */
45
- export type TransferUpdateDocumentArgs<TTransfer> = TransferUpdateArgs<TTransfer>;
46
- /** Persist a document to disk. Wire-side projection of {@link TransferSaveArgs}. */
47
- export type TransferSaveDocumentArgs<TTransfer> = TransferSaveArgs<TTransfer>;
44
+ export interface TransferUpdateDocumentArgs<TTransfer> {
45
+ /** Document URI. */
46
+ uri: string;
47
+ /** The id of a live session registered on this connection. */
48
+ clientId: string;
49
+ /** The whole structured model root, or its serialised textual form. */
50
+ model: TTransfer | string;
51
+ /**
52
+ * What this write was authored against. A `ModelVersion` is compared
53
+ * against the server's current text-document version for `uri` and throws
54
+ * `ConflictError` on mismatch; `'any'` writes unconditionally.
55
+ *
56
+ * **Required so that an ungated write is a decision rather than an
57
+ * omission.** An optional gate is indistinguishable from a forgotten one at
58
+ * the call site, and a file of twenty writes hides the one that lost the
59
+ * field. Nothing else here can see that, since the defect is an absence.
60
+ */
61
+ baseVersion: BaseVersion;
62
+ /**
63
+ * Set by a session's restore after a reconnect, which sends its last write
64
+ * again. A model the server took was written over text that parsed, so it
65
+ * is written even over text that does not, as it was before the
66
+ * reconnect. Any other model write over such text is refused with
67
+ * `DocumentSyntaxError`, a save's even when it sets this.
68
+ */
69
+ restore?: boolean;
70
+ }
71
+ /** Update a document the session `clientId` has open, then persist it to disk. */
72
+ export interface TransferSaveDocumentArgs<TTransfer> extends Omit<TransferUpdateDocumentArgs<TTransfer>, 'restore'> {
73
+ }
74
+ /** Persist the text the server holds for a document the session `clientId` has open, without writing a model. */
75
+ export type TransferPersistDocumentArgs = Omit<TransferUpdateDocumentArgs<never>, 'model' | 'restore'>;
76
+ /** Delete a document the session `clientId` has open: its file, then the document. */
77
+ export type TransferDeleteDocumentArgs = Omit<TransferUpdateDocumentArgs<never>, 'model' | 'restore'>;
78
+ /** Register a client session on the connection. */
79
+ export interface CreateSessionArgs {
80
+ /** The session's id, minted by the client; unique in the server process while the session is live. */
81
+ clientId: string;
82
+ /** What the participant is; kept as the server session's `label`. */
83
+ label?: string;
84
+ /**
85
+ * A token the client keeps for the session's lifetime. It is no secret: the
86
+ * wire carries no authentication. A later `createSession` for the same id
87
+ * carrying the same token, from any connection, ends the session it names
88
+ * and registers the id afresh, so a client whose connection dropped before
89
+ * the server noticed can register again. Without it the id stays refused
90
+ * until the server notices.
91
+ */
92
+ resumeToken?: string;
93
+ }
94
+ /** End a client session registered on the connection. */
95
+ export interface CloseSessionArgs {
96
+ clientId: string;
97
+ }
98
+ /** Create a document that exists nowhere yet, open for the session creating it. */
99
+ export interface CreateModelDocumentArgs {
100
+ uri: string;
101
+ /** The id of a live session registered on this connection. */
102
+ clientId: string;
103
+ /** The document's initial content; it reaches disk with the first save. */
104
+ text: string;
105
+ }
106
+ /**
107
+ * Write several documents a session has open, all or none. `clientId` is on
108
+ * the set rather than on each update: an id per update would allow a set
109
+ * mixing clients, which the server would have to refuse.
110
+ */
111
+ export interface TransferUpdateDocumentsArgs<TTransfer> {
112
+ /** The id of a live session registered on this connection. */
113
+ clientId: string;
114
+ /**
115
+ * One entry per document: a set naming one twice, by any spellings that
116
+ * share its canonical URI, is refused.
117
+ */
118
+ updates: Omit<TransferUpdateDocumentArgs<TTransfer>, 'clientId'>[];
119
+ }
48
120
  /**
49
121
  * Identifies a per-document watch on the data server. Shared by both
50
122
  * `watchModelDocument` and `unwatchModelDocument` — the `(uri, clientId)`
51
123
  * pair is the watch key, so unwatching names the same watch that was
52
124
  * started. The `clientId` identifies the originator the same way it does
53
- * on facade-side mutations (`TransferUpdateArgs.clientId`,
54
- * `TransferSaveArgs.clientId`): it keys the per-`(uri, clientId)` watch
55
- * bucket so multiple watchers on the same wire stay distinct, AND it lets
125
+ * on the document writes (`TransferUpdateDocumentArgs.clientId`,
126
+ * `TransferSaveDocumentArgs.clientId`): it keys the per-`(uri, clientId)`
127
+ * watch bucket so multiple watchers on the same wire stay distinct, AND it lets
56
128
  * each watcher recognise its own echo on inbound `onDocumentUpdated` events
57
129
  * (the wire shape's `sourceClientId` carries the originating mutation's
58
130
  * `clientId`).
59
131
  */
60
132
  export interface WatchModelDocumentArgs {
133
+ /** Any spelling that the document URI policy maps to the document. */
61
134
  uri: string;
62
135
  /** Stable identifier for the watching client. */
63
136
  clientId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../src/data/requests.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAElF,+FAA+F;AAC/F,MAAM,W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