@hydranium/protocol 1.0.0-next.34 → 1.0.0-next.340
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/README.md +44 -83
- package/lib/abstract-logger.d.ts +5 -0
- package/lib/abstract-logger.d.ts.map +1 -1
- package/lib/abstract-logger.js +7 -0
- package/lib/abstract-logger.js.map +1 -1
- package/lib/client/data-connection.d.ts +302 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +533 -0
- package/lib/client/data-connection.js.map +1 -0
- package/lib/client/data-events.d.ts +17 -1
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +25 -0
- package/lib/client/data-events.js.map +1 -1
- package/lib/client/data-port.d.ts +34 -24
- package/lib/client/data-port.d.ts.map +1 -1
- package/lib/client/data-session.d.ts +684 -89
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +1148 -115
- package/lib/client/data-session.js.map +1 -1
- package/lib/client/index.d.ts +15 -9
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +15 -9
- package/lib/client/index.js.map +1 -1
- package/lib/client/message-relay.d.ts +4 -4
- package/lib/client/message-relay.js +4 -4
- package/lib/client/message-relay.js.map +1 -1
- package/lib/client/post-message-transport.d.ts +64 -3
- package/lib/client/post-message-transport.d.ts.map +1 -1
- package/lib/client/post-message-transport.js +175 -1
- package/lib/client/post-message-transport.js.map +1 -1
- package/lib/client/rpc-connection.d.ts +157 -0
- package/lib/client/rpc-connection.d.ts.map +1 -0
- package/lib/client/rpc-connection.js +214 -0
- package/lib/client/rpc-connection.js.map +1 -0
- package/lib/client/worker-handshake.d.ts +86 -0
- package/lib/client/worker-handshake.d.ts.map +1 -0
- package/lib/client/worker-handshake.js +51 -0
- package/lib/client/worker-handshake.js.map +1 -0
- package/lib/client-ids.d.ts +45 -0
- package/lib/client-ids.d.ts.map +1 -0
- package/lib/client-ids.js +48 -0
- package/lib/client-ids.js.map +1 -0
- package/lib/clock.d.ts +50 -10
- package/lib/clock.d.ts.map +1 -1
- package/lib/clock.js +36 -1
- package/lib/clock.js.map +1 -1
- package/lib/console-logger.d.ts +23 -0
- package/lib/console-logger.d.ts.map +1 -0
- package/lib/console-logger.js +39 -0
- package/lib/console-logger.js.map +1 -0
- package/lib/data/data-protocol-methods.d.ts +4 -4
- package/lib/data/data-protocol-methods.d.ts.map +1 -1
- package/lib/data/data-protocol-methods.js +13 -1
- package/lib/data/data-protocol-methods.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +170 -48
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +137 -21
- package/lib/data/events.d.ts.map +1 -1
- package/lib/data/requests.d.ts +71 -11
- package/lib/data/requests.d.ts.map +1 -1
- package/lib/debouncer.d.ts +3 -3
- package/lib/debouncer.d.ts.map +1 -1
- package/lib/debouncer.js +6 -9
- package/lib/debouncer.js.map +1 -1
- package/lib/errors.d.ts +183 -30
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +268 -32
- package/lib/errors.js.map +1 -1
- package/lib/glsp-edits-settled-actions.d.ts +52 -0
- package/lib/glsp-edits-settled-actions.d.ts.map +1 -0
- package/lib/glsp-edits-settled-actions.js +28 -0
- package/lib/glsp-edits-settled-actions.js.map +1 -0
- package/lib/glsp-request-model-args.d.ts +16 -0
- package/lib/glsp-request-model-args.d.ts.map +1 -0
- package/lib/glsp-request-model-args.js +19 -0
- package/lib/glsp-request-model-args.js.map +1 -0
- package/lib/glsp-save-model-actions.d.ts +50 -0
- package/lib/glsp-save-model-actions.d.ts.map +1 -0
- package/lib/glsp-save-model-actions.js +28 -0
- package/lib/glsp-save-model-actions.js.map +1 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -1
- package/lib/latency-collector.d.ts +8 -4
- package/lib/latency-collector.d.ts.map +1 -1
- package/lib/latency-collector.js.map +1 -1
- package/lib/logger.d.ts +38 -7
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +42 -4
- package/lib/logger.js.map +1 -1
- package/lib/messages/index.d.ts +4 -2
- package/lib/messages/index.d.ts.map +1 -1
- package/lib/messages/index.js +15 -4
- package/lib/messages/index.js.map +1 -1
- package/lib/messages/primitives.d.ts +59 -4
- package/lib/messages/primitives.d.ts.map +1 -1
- package/lib/messages/primitives.js +97 -4
- package/lib/messages/primitives.js.map +1 -1
- package/lib/model-server.d.ts +60 -13
- package/lib/model-server.d.ts.map +1 -1
- package/lib/model-server.js +4 -2
- package/lib/model-server.js.map +1 -1
- package/lib/model-service/base-version.d.ts +67 -0
- package/lib/model-service/base-version.d.ts.map +1 -0
- package/lib/model-service/base-version.js +44 -0
- package/lib/model-service/base-version.js.map +1 -0
- package/lib/model-service/index.d.ts +1 -1
- package/lib/model-service/index.d.ts.map +1 -1
- package/lib/model-service/index.js +4 -5
- package/lib/model-service/index.js.map +1 -1
- package/lib/model-service/reference-candidate.d.ts +5 -3
- package/lib/model-service/reference-candidate.d.ts.map +1 -1
- package/lib/node/index.d.ts +10 -0
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +29 -0
- package/lib/node/index.js.map +1 -0
- package/lib/node/process-memory.d.ts +66 -0
- package/lib/node/process-memory.d.ts.map +1 -0
- package/lib/node/process-memory.js +291 -0
- package/lib/node/process-memory.js.map +1 -0
- package/lib/noop-logger.d.ts.map +1 -1
- package/lib/noop-logger.js.map +1 -1
- package/lib/observable-value.js.map +1 -1
- package/lib/patch-merge.d.ts +63 -35
- package/lib/patch-merge.d.ts.map +1 -1
- package/lib/patch-merge.js +171 -25
- package/lib/patch-merge.js.map +1 -1
- package/lib/pending-work-tracker.d.ts +29 -0
- package/lib/pending-work-tracker.d.ts.map +1 -0
- package/lib/pending-work-tracker.js +46 -0
- package/lib/pending-work-tracker.js.map +1 -0
- package/lib/profile-session.d.ts +8 -4
- package/lib/profile-session.d.ts.map +1 -1
- package/lib/profile-session.js.map +1 -1
- package/lib/project.d.ts +4 -1
- package/lib/project.d.ts.map +1 -1
- package/lib/project.js.map +1 -1
- package/lib/random-uuid.d.ts +14 -0
- package/lib/random-uuid.d.ts.map +1 -0
- package/lib/random-uuid.js +24 -0
- package/lib/random-uuid.js.map +1 -0
- package/lib/reconcile-write.d.ts +67 -0
- package/lib/reconcile-write.d.ts.map +1 -0
- package/lib/reconcile-write.js +69 -0
- package/lib/reconcile-write.js.map +1 -0
- package/lib/rpc/bind-rpc-methods.d.ts +6 -2
- package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.js +17 -7
- package/lib/rpc/bind-rpc-methods.js.map +1 -1
- package/lib/rpc/create-rpc-proxy.d.ts +3 -0
- package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
- package/lib/rpc/create-rpc-proxy.js +6 -1
- package/lib/rpc/create-rpc-proxy.js.map +1 -1
- package/lib/rpc/index.d.ts +1 -0
- package/lib/rpc/index.d.ts.map +1 -1
- package/lib/rpc/index.js +1 -0
- package/lib/rpc/index.js.map +1 -1
- package/lib/rpc/send-by-method-name.d.ts +76 -0
- package/lib/rpc/send-by-method-name.d.ts.map +1 -0
- package/lib/rpc/send-by-method-name.js +120 -0
- package/lib/rpc/send-by-method-name.js.map +1 -0
- package/lib/rpc/wire-prefix.js.map +1 -1
- package/lib/save-text-document.d.ts +40 -0
- package/lib/save-text-document.d.ts.map +1 -0
- package/lib/save-text-document.js +34 -0
- package/lib/save-text-document.js.map +1 -0
- package/lib/testing/catalogue-audit.d.ts +1 -1
- package/lib/testing/catalogue-audit.js +1 -1
- package/lib/testing/catalogue-audit.js.map +1 -1
- package/lib/testing/data-doubles.d.ts +41 -12
- package/lib/testing/data-doubles.d.ts.map +1 -1
- package/lib/testing/data-doubles.js +56 -8
- package/lib/testing/data-doubles.js.map +1 -1
- package/lib/testing/fake-clock.d.ts +17 -2
- package/lib/testing/fake-clock.d.ts.map +1 -1
- package/lib/testing/fake-clock.js +61 -46
- package/lib/testing/fake-clock.js.map +1 -1
- package/lib/testing/index.d.ts +1 -0
- package/lib/testing/index.d.ts.map +1 -1
- package/lib/testing/index.js +4 -3
- package/lib/testing/index.js.map +1 -1
- package/lib/testing/node/duplex-connection.d.ts.map +1 -1
- package/lib/testing/node/duplex-connection.js +3 -2
- package/lib/testing/node/duplex-connection.js.map +1 -1
- package/lib/testing/node/duplex-stream.js.map +1 -1
- package/lib/testing/node/index.d.ts +1 -0
- package/lib/testing/node/index.d.ts.map +1 -1
- package/lib/testing/node/index.js +2 -2
- package/lib/testing/node/index.js.map +1 -1
- package/lib/testing/node/message-port-pair.d.ts +25 -0
- package/lib/testing/node/message-port-pair.d.ts.map +1 -0
- package/lib/testing/node/message-port-pair.js +26 -0
- package/lib/testing/node/message-port-pair.js.map +1 -0
- package/lib/testing/transfer-node-builder.d.ts +81 -0
- package/lib/testing/transfer-node-builder.d.ts.map +1 -0
- package/lib/testing/transfer-node-builder.js +47 -0
- package/lib/testing/transfer-node-builder.js.map +1 -0
- package/lib/testing/wait-for.d.ts +9 -3
- package/lib/testing/wait-for.d.ts.map +1 -1
- package/lib/testing/wait-for.js +57 -11
- package/lib/testing/wait-for.js.map +1 -1
- package/lib/tracer.d.ts.map +1 -1
- package/lib/tracer.js +5 -9
- package/lib/tracer.js.map +1 -1
- package/lib/transfer-diagnostic.js.map +1 -1
- package/lib/transfer-document.d.ts +95 -32
- package/lib/transfer-document.d.ts.map +1 -1
- package/lib/transfer-document.js +17 -9
- package/lib/transfer-document.js.map +1 -1
- package/lib/transfer-element.d.ts +4 -4
- package/lib/types.d.ts +32 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/{model-service/args.js → types.js} +2 -2
- package/lib/types.js.map +1 -0
- package/lib/uri.d.ts.map +1 -1
- package/lib/uri.js.map +1 -1
- package/lib/util.d.ts +8 -2
- package/lib/util.d.ts.map +1 -1
- package/lib/util.js +32 -4
- package/lib/util.js.map +1 -1
- package/package.json +24 -40
- package/src/abstract-logger.ts +8 -0
- package/src/client/data-connection.ts +653 -0
- package/src/client/data-events.ts +37 -1
- package/src/client/data-port.ts +36 -25
- package/src/client/data-session.ts +1469 -137
- package/src/client/index.ts +15 -9
- package/src/client/message-relay.ts +4 -4
- package/src/client/post-message-transport.ts +219 -4
- package/src/client/rpc-connection.ts +281 -0
- package/src/client/worker-handshake.ts +113 -0
- package/src/client-ids.ts +49 -0
- package/src/clock.ts +68 -10
- package/src/console-logger.ts +39 -0
- package/src/data/data-protocol-methods.ts +14 -4
- package/src/data/data-server-protocol.ts +197 -48
- package/src/data/events.ts +143 -21
- package/src/data/requests.ts +77 -11
- package/src/debouncer.ts +7 -10
- package/src/errors.ts +326 -40
- package/src/glsp-edits-settled-actions.ts +60 -0
- package/src/glsp-request-model-args.ts +16 -0
- package/src/glsp-save-model-actions.ts +59 -0
- package/src/index.ts +10 -0
- package/src/latency-collector.ts +8 -3
- package/src/logger.ts +44 -8
- package/src/messages/index.ts +4 -2
- package/src/messages/primitives.ts +129 -5
- package/src/model-server.ts +64 -19
- package/src/model-service/base-version.ts +75 -0
- package/src/model-service/index.ts +4 -5
- package/src/model-service/reference-candidate.ts +5 -3
- package/src/node/index.ts +14 -0
- package/src/node/process-memory.ts +299 -0
- package/src/patch-merge.ts +230 -45
- package/src/pending-work-tracker.ts +46 -0
- package/src/profile-session.ts +9 -4
- package/src/project.ts +4 -1
- package/src/random-uuid.ts +21 -0
- package/src/reconcile-write.ts +128 -0
- package/src/rpc/README.md +6 -6
- package/src/rpc/bind-rpc-methods.ts +18 -8
- package/src/rpc/create-rpc-proxy.ts +6 -1
- package/src/rpc/index.ts +1 -0
- package/src/rpc/send-by-method-name.ts +140 -0
- package/src/save-text-document.ts +39 -0
- package/src/testing/catalogue-audit.ts +1 -1
- package/src/testing/data-doubles.ts +141 -19
- package/src/testing/fake-clock.ts +76 -48
- package/src/testing/index.ts +4 -3
- package/src/testing/node/duplex-connection.ts +3 -2
- package/src/testing/node/index.ts +2 -2
- package/src/testing/node/message-port-pair.ts +40 -0
- package/src/testing/transfer-node-builder.ts +107 -0
- package/src/testing/wait-for.ts +61 -13
- package/src/tracer.ts +5 -9
- package/src/transfer-document.ts +115 -34
- package/src/transfer-element.ts +4 -4
- package/src/types.ts +30 -0
- package/src/util.ts +33 -6
- package/lib/model-service/args.d.ts +0 -64
- package/lib/model-service/args.d.ts.map +0 -1
- package/lib/model-service/args.js.map +0 -1
- package/src/model-service/args.ts +0 -67
|
@@ -10,16 +10,29 @@
|
|
|
10
10
|
import type { TransferDiagnostic } from '../transfer-diagnostic';
|
|
11
11
|
import type { TransferElement } from '../transfer-element';
|
|
12
12
|
import type { Project } from '../project';
|
|
13
|
-
import type { TransferDocument } from '../transfer-document';
|
|
13
|
+
import type { TransferCreatedDocument, TransferDocument, TransferSavedDocument, TransferWatchedDocument } from '../transfer-document';
|
|
14
14
|
import type { CloseModelArgs, FindNextNameArgs, OpenModelArgs, ReferenceContext, ReferenceRequest } from '../model-server';
|
|
15
15
|
import type { ReferenceCandidate, ReferenceTarget } from '../model-service/reference-candidate';
|
|
16
|
-
import type { ProjectsChangedEvent, TransferDocumentSavedEvent, TransferDocumentUpdatedEvent } from './events';
|
|
17
16
|
import type {
|
|
17
|
+
ProjectsChangedEvent,
|
|
18
|
+
TransferDocumentDeletedEvent,
|
|
19
|
+
TransferDocumentDirtyChangedEvent,
|
|
20
|
+
TransferDocumentSavedEvent,
|
|
21
|
+
TransferDocumentsBuiltEvent,
|
|
22
|
+
TransferDocumentUpdatedEvent
|
|
23
|
+
} from './events';
|
|
24
|
+
import type {
|
|
25
|
+
CloseSessionArgs,
|
|
26
|
+
CreateModelDocumentArgs,
|
|
27
|
+
CreateSessionArgs,
|
|
18
28
|
GetModelDocumentArgs,
|
|
19
29
|
GetProjectForUriArgs,
|
|
30
|
+
TransferDeleteDocumentArgs,
|
|
31
|
+
TransferPersistDocumentArgs,
|
|
20
32
|
TransferSaveDocumentArgs,
|
|
21
33
|
WatchModelDocumentArgs,
|
|
22
|
-
TransferUpdateDocumentArgs
|
|
34
|
+
TransferUpdateDocumentArgs,
|
|
35
|
+
TransferUpdateDocumentsArgs
|
|
23
36
|
} from './requests';
|
|
24
37
|
|
|
25
38
|
/**
|
|
@@ -40,35 +53,79 @@ import type {
|
|
|
40
53
|
*/
|
|
41
54
|
export interface DocumentServerProtocol<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic> {
|
|
42
55
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* document
|
|
56
|
+
* Register `args.clientId` as a client session owned by this connection.
|
|
57
|
+
* Rejects with a `DuplicateClientIdError` code when the id is live anywhere
|
|
58
|
+
* in the server process, and with a `ReservedClientIdError` code when the
|
|
59
|
+
* framework reserves it.
|
|
60
|
+
*
|
|
61
|
+
* A request carrying a registered id acts as that session: it writes only
|
|
62
|
+
* what the session has open, failing with a `DocumentNotOpenError` code
|
|
63
|
+
* otherwise, and opens nothing implicitly; its open reads the file and takes
|
|
64
|
+
* no `languageId`, `version` or `text` seed. The session ends with
|
|
65
|
+
* {@link closeSession} or when the connection closes, and either closes
|
|
66
|
+
* every document it has open.
|
|
54
67
|
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
|
|
68
|
+
* A registration carrying the `resumeToken` an earlier registration of the
|
|
69
|
+
* same id carried ends that session first, from any connection, so a client
|
|
70
|
+
* whose connection dropped can register again before the server notices.
|
|
71
|
+
*/
|
|
72
|
+
createSession(args: CreateSessionArgs): Promise<void>;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* End a session this connection registered: close every document it has
|
|
76
|
+
* open, drop its watches, and free its id. A no-op for an id this
|
|
77
|
+
* connection did not register.
|
|
59
78
|
*/
|
|
60
|
-
|
|
79
|
+
closeSession(args: CloseSessionArgs): Promise<void>;
|
|
61
80
|
|
|
62
81
|
/**
|
|
63
|
-
*
|
|
64
|
-
* {@link openModelDocument}
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
|
|
82
|
+
* Create a document with `args.text`, open for the session, and return it
|
|
83
|
+
* as {@link openModelDocument} does, with the version the create made in
|
|
84
|
+
* `created`. The answer is read after the create, so it can already hold
|
|
85
|
+
* another client's write or an integrity repair; a write based on
|
|
86
|
+
* `created.version` then conflicts. It reaches disk with the first save.
|
|
87
|
+
* Fails when the file exists or any client has the URI open, and with a
|
|
88
|
+
* `SessionClosedError` code when `args.clientId` is not a session
|
|
89
|
+
* registered on this connection.
|
|
90
|
+
*/
|
|
91
|
+
createModelDocument(args: CreateModelDocumentArgs): Promise<TransferCreatedDocument<TTransfer, TDiagnostic>>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Write several documents the session has open, all or none: a conflict or
|
|
95
|
+
* a document not open fails the whole set before any text applies.
|
|
96
|
+
* Resolves to the documents in the order given, once the language client
|
|
97
|
+
* has answered the push of each, or the server-side bound on that wait
|
|
98
|
+
* passes, as {@link updateModelDocument} does. Only for a session
|
|
99
|
+
* registered on this connection.
|
|
100
|
+
*/
|
|
101
|
+
updateModelDocuments(args: TransferUpdateDocumentsArgs<TTransfer>): Promise<TransferDocument<TTransfer, TDiagnostic>[]>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Open a document for the client session `clientId` and return its current
|
|
105
|
+
* state. `clientId` must be a session this connection registered with
|
|
106
|
+
* {@link createSession}; any other id fails with the closed-session code,
|
|
107
|
+
* as every document request here does. The document is read from disk
|
|
108
|
+
* unless a client has it open already, so the request carries no
|
|
109
|
+
* `languageId`, `version` or `text` seed. Returns the document at
|
|
110
|
+
* the server's configured target phase, as {@link getModelDocument} does.
|
|
111
|
+
* A repeat open changes nothing.
|
|
112
|
+
*
|
|
113
|
+
* Pair with {@link watchModelDocument} to receive subsequent build-phase
|
|
114
|
+
* events (open returns a one-shot snapshot; later validation diagnostics
|
|
115
|
+
* arrive on the watch channel).
|
|
116
|
+
*/
|
|
117
|
+
openModelDocument(args: Pick<OpenModelArgs, 'uri' | 'clientId' | 'options'>): Promise<TransferDocument<TTransfer, TDiagnostic>>;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Close the session's open of `uri`. Counterpart to
|
|
121
|
+
* {@link openModelDocument}; the document stays open until every client
|
|
122
|
+
* has closed it, and then the server releases it, by default reverting it
|
|
123
|
+
* to disk. The default
|
|
124
|
+
* `DataServer` impl ALSO releases any watch for the same
|
|
125
|
+
* `(uri, clientId)` (a forgotten {@link unwatchModelDocument} would
|
|
126
|
+
* otherwise leak dispatch; the implicit unwatch is idempotent).
|
|
127
|
+
* `watchModelDocument` is NOT coupled the other way: opening does not force
|
|
128
|
+
* a watch, so a snapshot reader can open without streaming.
|
|
72
129
|
*/
|
|
73
130
|
closeModelDocument(args: CloseModelArgs): Promise<void>;
|
|
74
131
|
|
|
@@ -81,34 +138,72 @@ export interface DocumentServerProtocol<TTransfer extends TransferElement, TDiag
|
|
|
81
138
|
getModelDocument(args: GetModelDocumentArgs): Promise<TransferDocument<TTransfer, TDiagnostic>>;
|
|
82
139
|
|
|
83
140
|
/**
|
|
84
|
-
* Update a document's content
|
|
85
|
-
*
|
|
86
|
-
* response.
|
|
141
|
+
* Update a document's content as the session `clientId`, which must have
|
|
142
|
+
* it open. The response carries the latest built state including
|
|
143
|
+
* diagnostics; callers observe convergence via that response. It is sent
|
|
144
|
+
* once the language client has answered the push of the text, or the
|
|
145
|
+
* server-side bound on that wait passes, as {@link saveModelDocument}'s
|
|
146
|
+
* is, so an editor already shows the write when it arrives.
|
|
87
147
|
*/
|
|
88
148
|
updateModelDocument(args: TransferUpdateDocumentArgs<TTransfer>): Promise<TransferDocument<TTransfer, TDiagnostic>>;
|
|
89
149
|
|
|
90
150
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
151
|
+
* Write a document as the session `clientId`, which must have it open, and
|
|
152
|
+
* persist it to disk. The response is the build of the text written, with
|
|
153
|
+
* its version in `persisted`, sent once the language client has answered
|
|
154
|
+
* the push of that text, applied or refused, or a server-side bound on
|
|
155
|
+
* that wait passes; it does not wait again for a push that wait already
|
|
156
|
+
* gave up on and the client has not answered since. Save semantics depend
|
|
157
|
+
* on the filesystem-provider wiring; rejection paths surface as awaited
|
|
94
158
|
* promise rejections.
|
|
95
159
|
*/
|
|
96
|
-
saveModelDocument(args: TransferSaveDocumentArgs<TTransfer>): Promise<
|
|
160
|
+
saveModelDocument(args: TransferSaveDocumentArgs<TTransfer>): Promise<TransferSavedDocument<TTransfer, TDiagnostic>>;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Persist the text the server holds for a document the session `clientId`
|
|
164
|
+
* has open, as it is: no update and no serialisation, so another client's
|
|
165
|
+
* unsaved text keeps its formatting. `baseVersion` is checked in the step
|
|
166
|
+
* that takes the text, so text that moved on fails with a `ConflictError`
|
|
167
|
+
* code. The saved event names this session, whoever wrote the text.
|
|
168
|
+
* Answers after the same language-client wait as {@link saveModelDocument},
|
|
169
|
+
* with the document's latest build, read after that wait, so another
|
|
170
|
+
* session's write during it shows; `persisted` carries the version written.
|
|
171
|
+
*/
|
|
172
|
+
persistModelDocument(args: TransferPersistDocumentArgs): Promise<TransferSavedDocument<TTransfer, TDiagnostic>>;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Delete a document the session `clientId` has open, at once: its file,
|
|
176
|
+
* then the document, as a deletion a file watcher reports removes it. Every
|
|
177
|
+
* session's open of it closes and every client hears
|
|
178
|
+
* {@link DocumentClientProtocol.onDocumentDeleted} naming this session; the
|
|
179
|
+
* session's own watch is released, as {@link closeModelDocument} releases
|
|
180
|
+
* it. `baseVersion` is checked in the step that marks the document for
|
|
181
|
+
* deletion, so text that moved on fails with a `ConflictError` code. A file
|
|
182
|
+
* already gone deletes only the document; a file that cannot be removed
|
|
183
|
+
* fails the call and changes nothing. Resolves once the build that removes
|
|
184
|
+
* the document has run; a read then answers the URI without a model, unless
|
|
185
|
+
* an editor still has it open, whose buffer the document is built from.
|
|
186
|
+
*/
|
|
187
|
+
deleteModelDocument(args: TransferDeleteDocumentArgs): Promise<void>;
|
|
97
188
|
|
|
98
189
|
/**
|
|
99
190
|
* Start watching `(uri, clientId)`. The server starts dispatching
|
|
100
191
|
* {@link DocumentClientProtocol.onDocumentUpdated} on the paired wire
|
|
101
192
|
* for every build-phase event on `uri`.
|
|
102
193
|
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
194
|
+
* Answers with the key the watch's events name the document by, whether
|
|
195
|
+
* a document exists, taken once the watch is in place and the document
|
|
196
|
+
* is loaded as a read loads it, the text held at that moment, and the
|
|
197
|
+
* position of the last update or deletion event sent as of it, so an event
|
|
198
|
+
* the client heard while the watch was in flight tells by its own position
|
|
199
|
+
* whether it is newer than the answer. No handle: the event channel is the
|
|
200
|
+
* client interface. Callers fan out a single inbound `onDocumentUpdated` to
|
|
201
|
+
* multiple local listeners with their own `Emitter<T>` (matching Theia's
|
|
202
|
+
* pattern). Pair every `watchModelDocument` with
|
|
203
|
+
* {@link unwatchModelDocument} when no longer needed; the server holds the
|
|
204
|
+
* watch record until the matching unwatch lands.
|
|
110
205
|
*/
|
|
111
|
-
watchModelDocument(args: WatchModelDocumentArgs): Promise<
|
|
206
|
+
watchModelDocument(args: WatchModelDocumentArgs): Promise<TransferWatchedDocument>;
|
|
112
207
|
|
|
113
208
|
/**
|
|
114
209
|
* Stop watching `(uri, clientId)` previously started by
|
|
@@ -194,6 +289,22 @@ export interface DataServerProtocol<
|
|
|
194
289
|
>
|
|
195
290
|
extends DocumentServerProtocol<TTransfer, TDiagnostic>, ProjectServerProtocol<TProject> {}
|
|
196
291
|
|
|
292
|
+
/**
|
|
293
|
+
* The diagnostic shape a server answers with, read back off its own
|
|
294
|
+
* declaration.
|
|
295
|
+
*
|
|
296
|
+
* This is what lets a client tier stay generic over the server alone and still
|
|
297
|
+
* describe what it hands back. Both parameters must be inferred: naming
|
|
298
|
+
* {@link TransferElement} for the transfer instead fails to match while that
|
|
299
|
+
* parameter is still generic, and a default declared against the constraint
|
|
300
|
+
* then stops satisfying it.
|
|
301
|
+
*/
|
|
302
|
+
export type DiagnosticOf<TServer> =
|
|
303
|
+
TServer extends DocumentServerProtocol<infer _TTransfer, infer TDiagnostic> ? TDiagnostic : TransferDiagnostic;
|
|
304
|
+
|
|
305
|
+
/** The project shape a server answers with, read back off its own declaration. */
|
|
306
|
+
export type ProjectOf<TServer> = TServer extends ProjectServerProtocol<infer TProject> ? TProject : Project;
|
|
307
|
+
|
|
197
308
|
/**
|
|
198
309
|
* Cross-reference / naming slice of the server surface — scope-aware
|
|
199
310
|
* queries that resolve against the language's reference services. NOT part
|
|
@@ -204,11 +315,11 @@ export interface DataServerProtocol<
|
|
|
204
315
|
* source/URI (an `ElementSource` with no URI resolves to the sole
|
|
205
316
|
* registered language; a multi-language workspace overrides).
|
|
206
317
|
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
318
|
+
* Not generic over a server's root type: {@link resolveReference} answers with
|
|
319
|
+
* a node a reference names, which is no document root, and candidates and
|
|
320
|
+
* names are diagnostic-free.
|
|
210
321
|
*/
|
|
211
|
-
export interface ReferenceServerProtocol
|
|
322
|
+
export interface ReferenceServerProtocol {
|
|
212
323
|
/**
|
|
213
324
|
* List the reference candidates reachable for the property named in `ctx`
|
|
214
325
|
* from its (possibly synthetic) source. Backed by the language's
|
|
@@ -221,8 +332,13 @@ export interface ReferenceServerProtocol<TTransfer extends TransferElement> {
|
|
|
221
332
|
* target's document URI, display fields, and the resolved node's encoded
|
|
222
333
|
* transfer subtree. Resolves via the language's reference services;
|
|
223
334
|
* `undefined` when the reference does not resolve.
|
|
335
|
+
*
|
|
336
|
+
* `TElement` is the caller's claim about the target node's type; nothing
|
|
337
|
+
* checks it, so leave it at the default unless the reference names one type.
|
|
224
338
|
*/
|
|
225
|
-
resolveReference
|
|
339
|
+
resolveReference<TElement extends TransferElement = TransferElement>(
|
|
340
|
+
ref: ReferenceRequest
|
|
341
|
+
): Promise<ReferenceTarget<TElement> | undefined>;
|
|
226
342
|
|
|
227
343
|
/**
|
|
228
344
|
* Compute the next free name for a new element of `args.type` based on
|
|
@@ -262,6 +378,39 @@ export interface DocumentClientProtocol<TTransfer extends TransferElement, TDiag
|
|
|
262
378
|
* codepath, not a subscription codepath).
|
|
263
379
|
*/
|
|
264
380
|
onDocumentSaved(event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>): void;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Delivered when a subscribed document's text starts or stops differing
|
|
384
|
+
* from its file, as the server last knew it. Gated like
|
|
385
|
+
* {@link onDocumentSaved}; the answer at any one moment is the `dirty` of
|
|
386
|
+
* the documents the server sends. After a reconnect, a `DataSession`
|
|
387
|
+
* delivers here the answer of each document it restored, when that differs
|
|
388
|
+
* from the last this client was told: the flips while the connection was
|
|
389
|
+
* down reached no one.
|
|
390
|
+
*/
|
|
391
|
+
onDocumentDirtyChanged(event: TransferDocumentDirtyChangedEvent): void;
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Delivered when a document's backing file was removed. Separate from
|
|
395
|
+
* {@link onDocumentUpdated} for the same reason as {@link onDocumentSaved},
|
|
396
|
+
* and more strongly: there is no built state to deliver, and the build-phase
|
|
397
|
+
* path cannot report a deletion at all.
|
|
398
|
+
*
|
|
399
|
+
* Ungated, because on a browser host — where the workspace lives behind the
|
|
400
|
+
* head — no other source can observe a file disappearing. Recipients that
|
|
401
|
+
* only care about their own documents filter by URI.
|
|
402
|
+
*/
|
|
403
|
+
onDocumentDeleted(event: TransferDocumentDeletedEvent): void;
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Delivered once per build, naming the documents that reached the
|
|
407
|
+
* subscription phase and that
|
|
408
|
+
* nobody on this connection watches — chiefly the ones rebuilt as a cascade
|
|
409
|
+
* from a dependency's change, which no filesystem watcher can see because
|
|
410
|
+
* their own files did not change. The complement of
|
|
411
|
+
* {@link onDocumentUpdated}; carries URIs and no documents.
|
|
412
|
+
*/
|
|
413
|
+
onDocumentsBuilt(event: TransferDocumentsBuiltEvent): void;
|
|
265
414
|
}
|
|
266
415
|
|
|
267
416
|
/**
|
package/src/data/events.ts
CHANGED
|
@@ -10,30 +10,36 @@
|
|
|
10
10
|
import type { TransferDiagnostic } from '../transfer-diagnostic';
|
|
11
11
|
import type { TransferElement } from '../transfer-element';
|
|
12
12
|
import type { Project } from '../project';
|
|
13
|
-
import type { TransferDocument } from '../transfer-document';
|
|
13
|
+
import type { TextState, TransferDocument } from '../transfer-document';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Why an update event fired. Subscribers filter on reason for behaviour
|
|
17
17
|
* decisions (e.g. dirty-flag handling, undo-history grouping, telemetry):
|
|
18
18
|
*
|
|
19
|
-
* - `'changed'` — the
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* - `'rebuilt'` — the URI was rebuilt as a cascade from another URI's
|
|
27
|
-
* build (dependency graph re-derivation), without itself being passed to
|
|
28
|
-
* `documentBuilder.update`. The complement of `'changed'`.
|
|
19
|
+
* - `'changed'` — the server's first update event for the document's current
|
|
20
|
+
* version: its content changed since the last one. A write whose build a
|
|
21
|
+
* later write cancelled is still `'changed'` in the build that takes over.
|
|
22
|
+
* - `'rebuilt'` — a later event for a version the server already delivered,
|
|
23
|
+
* whether or not any client watched it then: something the document depends
|
|
24
|
+
* on changed, or the document was built again with the same content. The
|
|
25
|
+
* complement of `'changed'`.
|
|
29
26
|
* - `'saved'` — emitted by adopters that synthesise a unified update stream
|
|
30
27
|
* from both `onDocumentUpdated` and `onDocumentSaved`. The framework's own
|
|
31
28
|
* `dispatchPhaseEvent` does NOT emit `'saved'` — saves take the dedicated
|
|
32
29
|
* `DataClientProtocol.onDocumentSaved` channel.
|
|
33
|
-
*
|
|
34
|
-
*
|
|
30
|
+
*
|
|
31
|
+
* The version rule needs a version the server keeps and builds that validate.
|
|
32
|
+
* For a document no client has opened, or when rebuilds do not validate,
|
|
33
|
+
* `'changed'` means the URI was passed to `DocumentBuilder.update` for this
|
|
34
|
+
* build. A document that a validating build skips is `'changed'` every time.
|
|
35
|
+
*
|
|
36
|
+
* Deletion is deliberately NOT a member. An update event carries a built
|
|
37
|
+
* document, which a deleted one has none of, and the phase-driven path that
|
|
38
|
+
* produces these events never runs for a deleted URI — the builder drops the
|
|
39
|
+
* document before deriving the rebuild set. It travels as
|
|
40
|
+
* {@link TransferDocumentDeletedEvent} on its own channel instead.
|
|
35
41
|
*/
|
|
36
|
-
export type TransferDocumentUpdateReason = 'changed' | 'rebuilt' | 'saved'
|
|
42
|
+
export type TransferDocumentUpdateReason = 'changed' | 'rebuilt' | 'saved';
|
|
37
43
|
|
|
38
44
|
/**
|
|
39
45
|
* Delivered on the data-server when a document's content (or existence)
|
|
@@ -47,9 +53,21 @@ export interface TransferDocumentUpdatedEvent<
|
|
|
47
53
|
TDiagnostic extends TransferDiagnostic = TransferDiagnostic
|
|
48
54
|
> {
|
|
49
55
|
document: TransferDocument<TTransfer, TDiagnostic>;
|
|
50
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* The client whose write this event echoes: the author of the version on a
|
|
58
|
+
* `'changed'`, and the unknown-client id on a `'rebuilt'`, which echoes no
|
|
59
|
+
* write. A recipient compares it against its own id to recognise its echo.
|
|
60
|
+
* The build that follows a document's release names the release id
|
|
61
|
+
* instead.
|
|
62
|
+
*/
|
|
51
63
|
sourceClientId: string;
|
|
52
64
|
reason: TransferDocumentUpdateReason;
|
|
65
|
+
/**
|
|
66
|
+
* The position of this event among the update and deletion events the
|
|
67
|
+
* server sent on this connection, which a watch's answer carries as of
|
|
68
|
+
* the moment it was taken: a greater one was sent later.
|
|
69
|
+
*/
|
|
70
|
+
sequence: number;
|
|
53
71
|
}
|
|
54
72
|
|
|
55
73
|
/** Callback shape for `DataClientProtocol.onDocumentUpdated`. */
|
|
@@ -60,8 +78,8 @@ export type TransferDocumentUpdatedListener<
|
|
|
60
78
|
|
|
61
79
|
/**
|
|
62
80
|
* Delivered on the data-server when a document was persisted to disk via
|
|
63
|
-
* `DataServerProtocol.saveModelDocument`. Distinct
|
|
64
|
-
* {@link TransferDocumentUpdatedEvent}: subscribers that only care about
|
|
81
|
+
* `DataServerProtocol.saveModelDocument` or `persistModelDocument`. Distinct
|
|
82
|
+
* from {@link TransferDocumentUpdatedEvent}: subscribers that only care about
|
|
65
83
|
* persistence (external sync, editor "saved" indicators, dirty-flag
|
|
66
84
|
* clear) listen for this event family instead of filtering an update
|
|
67
85
|
* stream for `reason: 'saved'`.
|
|
@@ -77,10 +95,11 @@ export interface TransferDocumentSavedEvent<
|
|
|
77
95
|
> {
|
|
78
96
|
document: TransferDocument<TTransfer, TDiagnostic>;
|
|
79
97
|
/**
|
|
80
|
-
* The client whose `saveModelDocument`
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
98
|
+
* The client whose `saveModelDocument` or `persistModelDocument` call
|
|
99
|
+
* produced this, also when another client wrote the persisted text. Every
|
|
100
|
+
* subscriber receives the event including the originator, which already had
|
|
101
|
+
* the same state as the RPC response — compare against your own id to drop
|
|
102
|
+
* the echo rather than re-rendering from it.
|
|
84
103
|
*/
|
|
85
104
|
sourceClientId: string;
|
|
86
105
|
}
|
|
@@ -91,6 +110,109 @@ export type TransferDocumentSavedListener<
|
|
|
91
110
|
TDiagnostic extends TransferDiagnostic = TransferDiagnostic
|
|
92
111
|
> = (event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>) => void;
|
|
93
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Delivered on the data-server when a watched document's text starts or stops
|
|
115
|
+
* differing from its file, as the server last knew the file. The current
|
|
116
|
+
* answer rides on every transfer document the server sends as `text.dirty`;
|
|
117
|
+
* this carries only its changes, so a client that follows it needs no rebuild
|
|
118
|
+
* to learn of a save.
|
|
119
|
+
*/
|
|
120
|
+
export interface TransferDocumentDirtyChangedEvent {
|
|
121
|
+
/** Canonical URI, keyed as the subscription is. */
|
|
122
|
+
readonly uri: string;
|
|
123
|
+
/**
|
|
124
|
+
* The text the answer was decided on. It is sent before that text is
|
|
125
|
+
* built, so a `text.version` ahead of the model a client holds means an
|
|
126
|
+
* update at this version or a later one follows. Absent when the document
|
|
127
|
+
* no longer exists, or when the build that follows its release failed.
|
|
128
|
+
*/
|
|
129
|
+
readonly text?: TextState;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Callback shape for `DataClientProtocol.onDocumentDirtyChanged`. */
|
|
133
|
+
export type TransferDocumentDirtyChangedListener = (event: TransferDocumentDirtyChangedEvent) => void;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Delivered on the data-server when a document's backing file was removed.
|
|
137
|
+
* Carries no document, and cannot: the state a
|
|
138
|
+
* {@link TransferDocumentUpdatedEvent} would have to carry no longer exists by
|
|
139
|
+
* the time anyone can be told. That is also why deletion is not a `reason` on
|
|
140
|
+
* the update stream — `DocumentBuilder.update` drops the document before
|
|
141
|
+
* deriving the rebuild set, so the phase-driven path that produces update
|
|
142
|
+
* events never runs for it.
|
|
143
|
+
*
|
|
144
|
+
* **Delivered for EVERY document, not only watched ones**, unlike
|
|
145
|
+
* `onDocumentUpdated` and `onDocumentSaved`. The test that decides which
|
|
146
|
+
* channels are gated is whether any OTHER source can observe the fact on the
|
|
147
|
+
* least capable host: a browser-hosted client's workspace lives behind the
|
|
148
|
+
* head, so nothing there can see a file disappear, and gating the notification
|
|
149
|
+
* would leave it blind. (A Theia frontend's filesystem watcher would cover it,
|
|
150
|
+
* which is why this is a host argument and not a structure-versus-content one.)
|
|
151
|
+
* A watcher is told about its own document's deletion here too, the update
|
|
152
|
+
* channel being silent for deletions by construction. Filter on {@link uri} if
|
|
153
|
+
* the receiver only cares about documents it opened.
|
|
154
|
+
*
|
|
155
|
+
* A watch survives the deletion, so a file that comes back resumes delivering
|
|
156
|
+
* `onDocumentUpdated` to the same subscribers with no re-subscription. A
|
|
157
|
+
* client that responds by closing its editor releases the watch through
|
|
158
|
+
* `closeModelDocument` as usual, and `deleteModelDocument` releases the
|
|
159
|
+
* deleting session's own.
|
|
160
|
+
*/
|
|
161
|
+
export interface TransferDocumentDeletedEvent {
|
|
162
|
+
/** Canonical URI of the removed document, keyed as the subscription is. */
|
|
163
|
+
readonly uri: string;
|
|
164
|
+
/**
|
|
165
|
+
* The session whose `deleteModelDocument` removed the file, so it can tell
|
|
166
|
+
* its own deletion from another's; the unknown-client id for a file
|
|
167
|
+
* removed outside any session, as a file watcher reports one, and for one
|
|
168
|
+
* a `DataConnection` found gone after a reconnect, which no event named.
|
|
169
|
+
*/
|
|
170
|
+
readonly sourceClientId: string;
|
|
171
|
+
/**
|
|
172
|
+
* The position of this event among the update and deletion events the
|
|
173
|
+
* server sent on this connection, as on an update; absent on a deletion a
|
|
174
|
+
* `DataConnection` found after a reconnect, which the server never sent.
|
|
175
|
+
*/
|
|
176
|
+
readonly sequence?: number;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Callback shape for `DataClientProtocol.onDocumentDeleted`. */
|
|
180
|
+
export type TransferDocumentDeletedListener = (event: TransferDocumentDeletedEvent) => void;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Delivered on the data-server once per build, naming the documents that reached
|
|
184
|
+
* the configured subscription phase (`DataServerOptions.subscriptionPhase`,
|
|
185
|
+
* `Validated` by default) and that NO client on the connection is watching. Not
|
|
186
|
+
* the integrity-settled landmark, which is a different point and a different
|
|
187
|
+
* word in this framework.
|
|
188
|
+
*
|
|
189
|
+
* The complement of {@link TransferDocumentUpdatedEvent}, which is gated per
|
|
190
|
+
* URI: together the two cover every document a build touched. This one exists
|
|
191
|
+
* for the case no source outside the server can observe — a document rebuilt
|
|
192
|
+
* because something it DEPENDS ON changed. Its own file never changed, so a
|
|
193
|
+
* filesystem watcher cannot see it, and it has no subscriber, so the update
|
|
194
|
+
* channel does not report it. A consumer showing data derived from such a
|
|
195
|
+
* document (a tree label, a decorator) would otherwise hold a stale value with
|
|
196
|
+
* nothing to invalidate it.
|
|
197
|
+
*
|
|
198
|
+
* Carries URIs and no documents: a recipient re-reads what it displays, through
|
|
199
|
+
* `getModelDocument` or its own request. That keeps the bandwidth property the
|
|
200
|
+
* per-URI subscription exists for, without gating the message.
|
|
201
|
+
*
|
|
202
|
+
* Not sent when the set is empty, which is the normal case while editing — the
|
|
203
|
+
* document being edited is watched by its own editor and therefore excluded.
|
|
204
|
+
* Workspace initialisation sends nothing either: it does not build to the
|
|
205
|
+
* subscription phase. The largest message a workspace can produce is therefore
|
|
206
|
+
* a whole-workspace rebuild at that phase, which is one message of URIs.
|
|
207
|
+
*/
|
|
208
|
+
export interface TransferDocumentsBuiltEvent {
|
|
209
|
+
/** Canonical URIs, keyed as subscriptions are. Never empty. */
|
|
210
|
+
readonly uris: readonly string[];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** Callback shape for `DataClientProtocol.onDocumentsBuilt`. */
|
|
214
|
+
export type TransferDocumentsBuiltListener = (event: TransferDocumentsBuiltEvent) => void;
|
|
215
|
+
|
|
94
216
|
/**
|
|
95
217
|
* Why a project-change event fired. `added` — the project was newly
|
|
96
218
|
* registered (descriptor discovered); `updated` — the project's
|
package/src/data/requests.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type { BaseVersion } from '../model-service/base-version';
|
|
11
11
|
|
|
12
12
|
/** Get the current state of a single document. The server returns the latest built version. */
|
|
13
13
|
export interface GetModelDocumentArgs {
|
|
@@ -41,24 +41,90 @@ export interface GetProjectForUriArgs {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* Update a document
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* without an args mapping.
|
|
44
|
+
* Update a document the session `clientId` has open. Generic over `TTransfer`
|
|
45
|
+
* so adopters parameterise the structured shape against their grammar's
|
|
46
|
+
* transfer-model overlay; passing a string is always allowed.
|
|
48
47
|
*/
|
|
49
|
-
export
|
|
48
|
+
export interface TransferUpdateDocumentArgs<TTransfer> {
|
|
49
|
+
/** Document URI. */
|
|
50
|
+
uri: string;
|
|
51
|
+
/** The id of a live session registered on this connection. */
|
|
52
|
+
clientId: string;
|
|
53
|
+
/** The whole structured model root, or its serialised textual form. */
|
|
54
|
+
model: TTransfer | string;
|
|
55
|
+
/**
|
|
56
|
+
* What this write was authored against. A `ModelVersion` is compared
|
|
57
|
+
* against the server's current text-document version for `uri` and throws
|
|
58
|
+
* `ConflictError` on mismatch; `'any'` writes unconditionally.
|
|
59
|
+
*
|
|
60
|
+
* **Required so that an ungated write is a decision rather than an
|
|
61
|
+
* omission.** An optional gate is indistinguishable from a forgotten one at
|
|
62
|
+
* the call site, and a file of twenty writes hides the one that lost the
|
|
63
|
+
* field. Nothing else here can see that, since the defect is an absence.
|
|
64
|
+
*/
|
|
65
|
+
baseVersion: BaseVersion;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Update a document the session `clientId` has open, then persist it to disk. */
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- save names its own args; it adds no field to update's
|
|
70
|
+
export interface TransferSaveDocumentArgs<TTransfer> extends TransferUpdateDocumentArgs<TTransfer> {}
|
|
71
|
+
|
|
72
|
+
/** Persist the text the server holds for a document the session `clientId` has open, without writing a model. */
|
|
73
|
+
export type TransferPersistDocumentArgs = Omit<TransferUpdateDocumentArgs<never>, 'model'>;
|
|
74
|
+
|
|
75
|
+
/** Delete a document the session `clientId` has open: its file, then the document. */
|
|
76
|
+
export type TransferDeleteDocumentArgs = Omit<TransferUpdateDocumentArgs<never>, 'model'>;
|
|
77
|
+
|
|
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
|
+
}
|
|
50
94
|
|
|
51
|
-
/**
|
|
52
|
-
export
|
|
95
|
+
/** End a client session registered on the connection. */
|
|
96
|
+
export interface CloseSessionArgs {
|
|
97
|
+
clientId: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Create a document that exists nowhere yet, open for the session creating it. */
|
|
101
|
+
export interface CreateModelDocumentArgs {
|
|
102
|
+
uri: string;
|
|
103
|
+
/** The id of a live session registered on this connection. */
|
|
104
|
+
clientId: string;
|
|
105
|
+
/** The document's initial content; it reaches disk with the first save. */
|
|
106
|
+
text: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Write several documents a session has open, all or none. `clientId` is on
|
|
111
|
+
* the set rather than on each update: an id per update would allow a set
|
|
112
|
+
* mixing clients, which the server would have to refuse.
|
|
113
|
+
*/
|
|
114
|
+
export interface TransferUpdateDocumentsArgs<TTransfer> {
|
|
115
|
+
/** The id of a live session registered on this connection. */
|
|
116
|
+
clientId: string;
|
|
117
|
+
updates: Omit<TransferUpdateDocumentArgs<TTransfer>, 'clientId'>[];
|
|
118
|
+
}
|
|
53
119
|
|
|
54
120
|
/**
|
|
55
121
|
* Identifies a per-document watch on the data server. Shared by both
|
|
56
122
|
* `watchModelDocument` and `unwatchModelDocument` — the `(uri, clientId)`
|
|
57
123
|
* pair is the watch key, so unwatching names the same watch that was
|
|
58
124
|
* started. The `clientId` identifies the originator the same way it does
|
|
59
|
-
* on
|
|
60
|
-
* `
|
|
61
|
-
* 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
|
|
62
128
|
* each watcher recognise its own echo on inbound `onDocumentUpdated` events
|
|
63
129
|
* (the wire shape's `sourceClientId` carries the originating mutation's
|
|
64
130
|
* `clientId`).
|