@hydranium/protocol 1.0.0-next.16 → 1.0.0-next.160
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 +35 -1
- package/lib/client/data-connection.d.ts +157 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +236 -0
- package/lib/client/data-connection.js.map +1 -0
- package/lib/client/data-events.d.ts +13 -1
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +21 -0
- package/lib/client/data-events.js.map +1 -1
- package/lib/client/data-port.d.ts +17 -22
- package/lib/client/data-port.d.ts.map +1 -1
- package/lib/client/data-session.d.ts +440 -78
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +697 -106
- package/lib/client/data-session.js.map +1 -1
- package/lib/client/index.d.ts +13 -8
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +13 -8
- package/lib/client/index.js.map +1 -1
- package/lib/client/message-relay.d.ts +9 -3
- package/lib/client/message-relay.d.ts.map +1 -1
- package/lib/client/message-relay.js +11 -5
- 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 +149 -0
- package/lib/client/rpc-connection.d.ts.map +1 -0
- package/lib/client/rpc-connection.js +179 -0
- package/lib/client/rpc-connection.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 +38 -0
- package/lib/clock.d.ts.map +1 -1
- package/lib/clock.js +36 -1
- package/lib/clock.js.map +1 -1
- 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 +11 -1
- package/lib/data/data-protocol-methods.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +111 -31
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +103 -14
- package/lib/data/events.d.ts.map +1 -1
- package/lib/data/requests.d.ts +67 -11
- package/lib/data/requests.d.ts.map +1 -1
- package/lib/errors.d.ts +163 -17
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +219 -22
- package/lib/errors.js.map +1 -1
- 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 +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +6 -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/messages/index.d.ts +29 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +58 -0
- package/lib/messages/index.js.map +1 -0
- package/lib/messages/primitives.d.ts +188 -0
- package/lib/messages/primitives.d.ts.map +1 -0
- package/lib/messages/primitives.js +161 -0
- package/lib/messages/primitives.js.map +1 -0
- 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/based-on.d.ts +57 -0
- package/lib/model-service/based-on.d.ts.map +1 -0
- package/lib/model-service/based-on.js +37 -0
- package/lib/model-service/based-on.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/patch-merge.d.ts +28 -27
- package/lib/patch-merge.d.ts.map +1 -1
- package/lib/patch-merge.js +66 -22
- package/lib/patch-merge.js.map +1 -1
- 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/rpc/bind-rpc-methods.d.ts +29 -3
- package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.js +22 -3
- package/lib/rpc/bind-rpc-methods.js.map +1 -1
- package/lib/rpc/create-rpc-proxy.d.ts +7 -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/testing/catalogue-audit.d.ts +80 -0
- package/lib/testing/catalogue-audit.d.ts.map +1 -0
- package/lib/testing/catalogue-audit.js +94 -0
- package/lib/testing/catalogue-audit.js.map +1 -0
- package/lib/testing/data-doubles.d.ts +13 -12
- package/lib/testing/data-doubles.d.ts.map +1 -1
- package/lib/testing/data-doubles.js +19 -5
- package/lib/testing/data-doubles.js.map +1 -1
- package/lib/testing/fake-clock.d.ts +9 -1
- package/lib/testing/fake-clock.d.ts.map +1 -1
- package/lib/testing/fake-clock.js +54 -45
- 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 -1
- package/lib/testing/index.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/transfer-diagnostic.d.ts +33 -0
- package/lib/transfer-diagnostic.d.ts.map +1 -1
- package/lib/transfer-diagnostic.js +23 -0
- package/lib/transfer-diagnostic.js.map +1 -1
- package/lib/transfer-document.d.ts +34 -5
- package/lib/transfer-document.d.ts.map +1 -1
- package/lib/transfer-document.js +14 -1
- package/lib/transfer-document.js.map +1 -1
- package/lib/util.d.ts +8 -0
- package/lib/util.d.ts.map +1 -1
- package/lib/util.js +32 -0
- package/lib/util.js.map +1 -1
- package/package.json +11 -2
- package/src/client/data-connection.ts +314 -0
- package/src/client/data-events.ts +33 -1
- package/src/client/data-port.ts +17 -23
- package/src/client/data-session.ts +880 -123
- package/src/client/index.ts +13 -8
- package/src/client/message-relay.ts +29 -7
- package/src/client/post-message-transport.ts +219 -4
- package/src/client/rpc-connection.ts +244 -0
- package/src/client-ids.ts +49 -0
- package/src/clock.ts +56 -0
- package/src/data/data-protocol-methods.ts +11 -3
- package/src/data/data-server-protocol.ts +132 -31
- package/src/data/events.ts +109 -14
- package/src/data/requests.ts +71 -11
- package/src/errors.ts +259 -24
- package/src/glsp-save-model-actions.ts +59 -0
- package/src/index.ts +6 -0
- package/src/latency-collector.ts +8 -3
- package/src/messages/index.ts +36 -0
- package/src/messages/primitives.ts +271 -0
- package/src/model-server.ts +63 -18
- package/src/model-service/based-on.ts +63 -0
- package/src/model-service/index.ts +4 -5
- package/src/patch-merge.ts +90 -37
- package/src/profile-session.ts +9 -4
- package/src/rpc/bind-rpc-methods.ts +49 -4
- package/src/rpc/create-rpc-proxy.ts +14 -1
- package/src/testing/catalogue-audit.ts +111 -0
- package/src/testing/data-doubles.ts +42 -17
- package/src/testing/fake-clock.ts +62 -47
- package/src/testing/index.ts +4 -1
- package/src/testing/node/index.ts +2 -2
- package/src/testing/node/message-port-pair.ts +40 -0
- package/src/transfer-diagnostic.ts +40 -0
- package/src/transfer-document.ts +41 -6
- package/src/util.ts +33 -0
- 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 +0 -11
- package/lib/model-service/args.js.map +0 -1
- package/src/model-service/args.ts +0 -67
package/lib/errors.d.ts
CHANGED
|
@@ -7,29 +7,61 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { ResponseError } from 'vscode-jsonrpc';
|
|
10
|
+
import { type HydraniumMessageData } from './messages/primitives';
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
12
|
+
* The catalogue declaration behind {@link ConflictError}'s sentence. It words
|
|
13
|
+
* the version mismatch rather than stating it: the two numbers mean nothing to
|
|
14
|
+
* an end user, and they stay in {@link ConflictErrorData}.
|
|
15
|
+
*
|
|
16
|
+
* Its English must keep containing {@link CONFLICT_ERROR_MESSAGE_MARKER}: the
|
|
17
|
+
* marker is tier 3 of {@link isConflictError}'s ladder, and it matches on text.
|
|
18
|
+
* That tier only ever works untranslated, which is why it is the last resort
|
|
19
|
+
* behind the numeric code rather than the primary check.
|
|
20
|
+
*/
|
|
21
|
+
export declare const STALE_BASED_UPDATE: import("./messages/primitives").MessageDefinition<"The edit to {uri} was not applied: it was made to an older version of the document.">;
|
|
22
|
+
/**
|
|
23
|
+
* Every JSON-RPC error code the framework raises, from any package, keyed by
|
|
24
|
+
* the error it identifies.
|
|
25
|
+
*
|
|
26
|
+
* The framework reserves the block 42000 to 42999 for these, and an adopter's
|
|
27
|
+
* own codes stay outside it: after an RPC a guard matches on the code alone, so
|
|
28
|
+
* an adopter's error carrying one of these reads as the framework's. A new code
|
|
29
|
+
* takes the next unused number in the block, whichever package raises it, and
|
|
30
|
+
* is declared here, where tests hold every code distinct and inside the block.
|
|
31
|
+
* The block sits clear of the range JSON-RPC 2.0 reserves for itself, -32768
|
|
32
|
+
* to -32000.
|
|
33
|
+
*/
|
|
34
|
+
export declare const HYDRANIUM_ERROR_CODES: {
|
|
35
|
+
readonly conflict: 42001;
|
|
36
|
+
readonly noActiveProfile: 42002;
|
|
37
|
+
readonly referenceSettleTimeout: 42003;
|
|
38
|
+
readonly sessionClosed: 42004;
|
|
39
|
+
readonly documentNotOpen: 42005;
|
|
40
|
+
readonly duplicateClientId: 42006;
|
|
41
|
+
readonly reservedClientId: 42007;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* JSON-RPC error code for {@link ConflictError}.
|
|
13
45
|
*
|
|
14
46
|
* The code is the load-bearing identifier across realm boundaries —
|
|
15
47
|
* `code` is a first-class field on the JSON-RPC error envelope and
|
|
16
48
|
* survives wire reconstruction; the custom `Error` subclass name does
|
|
17
49
|
* not.
|
|
18
50
|
*/
|
|
19
|
-
export declare const CONFLICT_ERROR_CODE
|
|
51
|
+
export declare const CONFLICT_ERROR_CODE: 42001;
|
|
20
52
|
/**
|
|
21
53
|
* Structured payload carried in {@link ConflictError.data}, and the only place
|
|
22
54
|
* a post-RPC caller can read the version mismatch from.
|
|
23
55
|
*/
|
|
24
|
-
export interface ConflictErrorData {
|
|
56
|
+
export interface ConflictErrorData extends HydraniumMessageData {
|
|
25
57
|
readonly uri: string;
|
|
26
58
|
/** The based-on version the caller authored against. */
|
|
27
|
-
readonly
|
|
59
|
+
readonly expectedVersion: number;
|
|
28
60
|
/** The server's current text-document version at the time of the throw. */
|
|
29
|
-
readonly
|
|
61
|
+
readonly actualVersion: number;
|
|
30
62
|
}
|
|
31
63
|
/**
|
|
32
|
-
* Thrown by `
|
|
64
|
+
* Thrown by a client session's `update` / `save` when the caller-
|
|
33
65
|
* supplied based-on version no longer matches the server's current text-
|
|
34
66
|
* document version for the same URI — i.e. the snapshot the caller
|
|
35
67
|
* authored against has been superseded by an intervening edit.
|
|
@@ -42,11 +74,9 @@ export interface ConflictErrorData {
|
|
|
42
74
|
* `err.data` (the instance is reconstructed as a generic
|
|
43
75
|
* `ResponseError`, so subclass getters / fields do not survive).
|
|
44
76
|
*
|
|
45
|
-
* Detection is
|
|
46
|
-
*
|
|
47
|
-
* no gating.
|
|
48
|
-
* posture, so headless / CLI / batch tooling with no meaningful based-on
|
|
49
|
-
* version can opt out explicitly.
|
|
77
|
+
* Detection is driven by the required `basedOn` field of every write
|
|
78
|
+
* request; a caller with no meaningful based-on version passes
|
|
79
|
+
* `'anything'` and gets no gating.
|
|
50
80
|
*
|
|
51
81
|
* Three reasonable adopter recovery strategies:
|
|
52
82
|
*
|
|
@@ -60,11 +90,126 @@ export interface ConflictErrorData {
|
|
|
60
90
|
* No auto-retry or auto-merge ships by default.
|
|
61
91
|
*/
|
|
62
92
|
export declare class ConflictError extends ResponseError<ConflictErrorData> {
|
|
63
|
-
constructor(uri: string,
|
|
93
|
+
constructor(uri: string, expectedVersion: number, actualVersion: number);
|
|
94
|
+
get uri(): string;
|
|
95
|
+
/**
|
|
96
|
+
* The based-on version the caller authored against.
|
|
97
|
+
*
|
|
98
|
+
* Must not be renamed to `expected`, nor its sibling to `actual`: a test
|
|
99
|
+
* reporter reads an error carrying both as an assertion failure, and
|
|
100
|
+
* vitest's formatter then ASSIGNS to them, which throws on an accessor and
|
|
101
|
+
* replaces the real failure with a `TypeError`.
|
|
102
|
+
*/
|
|
103
|
+
get expectedVersion(): number;
|
|
104
|
+
/** The server's version at the time of the throw. Not `actual` — see {@link expectedVersion}. */
|
|
105
|
+
get actualVersion(): number;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* JSON-RPC code for {@link SessionClosedError}, beside {@link CONFLICT_ERROR_CODE}
|
|
109
|
+
* and for the same reason: the code survives reconstruction, the class does not.
|
|
110
|
+
*/
|
|
111
|
+
export declare const SESSION_CLOSED_ERROR_CODE: 42004;
|
|
112
|
+
/** JSON-RPC code for {@link DocumentNotOpenError}. */
|
|
113
|
+
export declare const DOCUMENT_NOT_OPEN_ERROR_CODE: 42005;
|
|
114
|
+
/** JSON-RPC code for {@link DuplicateClientIdError}. */
|
|
115
|
+
export declare const DUPLICATE_CLIENT_ID_ERROR_CODE: 42006;
|
|
116
|
+
/** JSON-RPC code for {@link ReservedClientIdError}. */
|
|
117
|
+
export declare const RESERVED_CLIENT_ID_ERROR_CODE: 42007;
|
|
118
|
+
/**
|
|
119
|
+
* The catalogue declaration behind {@link SessionClosedError}'s default
|
|
120
|
+
* sentence. It names no client id: the sentence can reach an end user, and the
|
|
121
|
+
* id stays in {@link SessionClosedErrorData.clientId} for whoever needs it.
|
|
122
|
+
*/
|
|
123
|
+
export declare const SESSION_CLOSED: import("./messages/primitives").MessageDefinition<"The editing session has ended.">;
|
|
124
|
+
/** Structured payload carried in {@link SessionClosedError.data}. */
|
|
125
|
+
export interface SessionClosedErrorData extends HydraniumMessageData {
|
|
126
|
+
readonly clientId: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Thrown by every call on a client session after it ended, and by an open that
|
|
130
|
+
* was still in flight when its session ended: by the server for its sessions,
|
|
131
|
+
* and by a client-side `DataSession` once disposed, so a caller handles both
|
|
132
|
+
* the same way. A caller recognises it with {@link isSessionClosedError}, never
|
|
133
|
+
* by its sentence.
|
|
134
|
+
*/
|
|
135
|
+
export declare class SessionClosedError extends ResponseError<SessionClosedErrorData> {
|
|
136
|
+
/**
|
|
137
|
+
* `message` replaces the default English, for a caller that knows more than
|
|
138
|
+
* that the session is gone. The identity stays {@link SESSION_CLOSED}'s, so a
|
|
139
|
+
* translating renderer renders the catalogue sentence in its place.
|
|
140
|
+
*/
|
|
141
|
+
constructor(clientId: string, message?: string);
|
|
142
|
+
get clientId(): string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The catalogue declaration behind {@link DocumentNotOpenError}'s sentence. The
|
|
146
|
+
* client id stays in {@link DocumentNotOpenErrorData.clientId}.
|
|
147
|
+
*/
|
|
148
|
+
export declare const DOCUMENT_NOT_OPEN: import("./messages/primitives").MessageDefinition<"The document {uri} is not open in this editing session.">;
|
|
149
|
+
/** Structured payload carried in {@link DocumentNotOpenError.data}. */
|
|
150
|
+
export interface DocumentNotOpenErrorData extends HydraniumMessageData {
|
|
151
|
+
readonly uri: string;
|
|
152
|
+
readonly clientId: string;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Thrown when a client session writes a document it does not have open.
|
|
156
|
+
*
|
|
157
|
+
* A session writes only what it has open, so this is the answer both to a write
|
|
158
|
+
* that never opened and to one whose open was closed underneath it — by the
|
|
159
|
+
* session itself, or by the document being deleted.
|
|
160
|
+
*/
|
|
161
|
+
export declare class DocumentNotOpenError extends ResponseError<DocumentNotOpenErrorData> {
|
|
162
|
+
constructor(uri: string, clientId: string);
|
|
64
163
|
get uri(): string;
|
|
65
|
-
get
|
|
66
|
-
|
|
164
|
+
get clientId(): string;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* The catalogue declaration behind {@link DuplicateClientIdError}'s sentence.
|
|
168
|
+
* The client id stays in {@link DuplicateClientIdErrorData.clientId}.
|
|
169
|
+
*/
|
|
170
|
+
export declare const DUPLICATE_CLIENT_ID: import("./messages/primitives").MessageDefinition<"Could not start an editing session: its identifier is still in use by another editor.">;
|
|
171
|
+
/** Structured payload carried in {@link DuplicateClientIdError.data}. */
|
|
172
|
+
export interface DuplicateClientIdErrorData extends HydraniumMessageData {
|
|
173
|
+
readonly clientId: string;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Thrown when a client session is started under an id that is already live in
|
|
177
|
+
* the process. The id frees up once its holder ends or closes its last
|
|
178
|
+
* document, so a caller may retry.
|
|
179
|
+
*
|
|
180
|
+
* Ids are unique process-wide because the id is also the author label on every
|
|
181
|
+
* version and the key a client recognises its own echoes by; two participants
|
|
182
|
+
* sharing one would each take the other's writes for their own.
|
|
183
|
+
*/
|
|
184
|
+
export declare class DuplicateClientIdError extends ResponseError<DuplicateClientIdErrorData> {
|
|
185
|
+
constructor(clientId: string);
|
|
186
|
+
get clientId(): string;
|
|
67
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* Thrown when a client session is started under an id the framework reserves
|
|
190
|
+
* for one of its own participants. A reserved id never frees up, so a caller
|
|
191
|
+
* that retries on {@link DuplicateClientIdError} stops on this one.
|
|
192
|
+
*
|
|
193
|
+
* It carries no message identity: a host that picks a reserved id has a bug,
|
|
194
|
+
* and no sentence addressed to an end user is true for it.
|
|
195
|
+
*/
|
|
196
|
+
export declare class ReservedClientIdError extends ResponseError<{
|
|
197
|
+
readonly clientId: string;
|
|
198
|
+
}> {
|
|
199
|
+
constructor(clientId: string);
|
|
200
|
+
get clientId(): string;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Whether `error` is a {@link SessionClosedError}: by name in-process, by code
|
|
204
|
+
* after an RPC, where it arrives as a plain `ResponseError`.
|
|
205
|
+
*/
|
|
206
|
+
export declare function isSessionClosedError(error: unknown): error is SessionClosedError;
|
|
207
|
+
/** Whether `error` is a {@link DocumentNotOpenError}; see {@link isSessionClosedError}. */
|
|
208
|
+
export declare function isDocumentNotOpenError(error: unknown): error is DocumentNotOpenError;
|
|
209
|
+
/** Whether `error` is a {@link DuplicateClientIdError}; see {@link isSessionClosedError}. */
|
|
210
|
+
export declare function isDuplicateClientIdError(error: unknown): error is DuplicateClientIdError;
|
|
211
|
+
/** Whether `error` is a {@link ReservedClientIdError}; see {@link isSessionClosedError}. */
|
|
212
|
+
export declare function isReservedClientIdError(error: unknown): error is ReservedClientIdError;
|
|
68
213
|
/**
|
|
69
214
|
* Type guard for {@link ConflictError}. Detection ladder:
|
|
70
215
|
*
|
|
@@ -74,8 +219,9 @@ export declare class ConflictError extends ResponseError<ConflictErrorData> {
|
|
|
74
219
|
* canonical wire-side check; the JSON-RPC `code` field is preserved
|
|
75
220
|
* across reconstruction, so any adopter catching after an RPC call
|
|
76
221
|
* hits this branch.
|
|
77
|
-
* 3. `error.message
|
|
78
|
-
* for transports that re-wrap the message
|
|
222
|
+
* 3. `error.message` contains the marker {@link STALE_BASED_UPDATE}'s
|
|
223
|
+
* English carries — fallback for transports that re-wrap the message
|
|
224
|
+
* and drop the code (rare).
|
|
79
225
|
*
|
|
80
226
|
* `instanceof ConflictError` alone would silently return `false` on the
|
|
81
227
|
* reconstructed shape, so callers do not use it.
|
package/lib/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"A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;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAEhF;AAED,2FAA2F;AAC3F,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAEpF;AAED,6FAA6F;AAC7F,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,sBAAsB,CAExF;AAED,4FAA4F;AAC5F,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,qBAAqB,CAEtF;AAWD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAYtE"}
|
package/lib/errors.js
CHANGED
|
@@ -8,21 +8,68 @@
|
|
|
8
8
|
* SPDX-License-Identifier: MIT
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.ConflictError = exports.CONFLICT_ERROR_CODE = void 0;
|
|
11
|
+
exports.ReservedClientIdError = exports.DuplicateClientIdError = exports.DUPLICATE_CLIENT_ID = exports.DocumentNotOpenError = exports.DOCUMENT_NOT_OPEN = exports.SessionClosedError = exports.SESSION_CLOSED = exports.RESERVED_CLIENT_ID_ERROR_CODE = exports.DUPLICATE_CLIENT_ID_ERROR_CODE = exports.DOCUMENT_NOT_OPEN_ERROR_CODE = exports.SESSION_CLOSED_ERROR_CODE = exports.ConflictError = exports.CONFLICT_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES = exports.STALE_BASED_UPDATE = void 0;
|
|
12
|
+
exports.isSessionClosedError = isSessionClosedError;
|
|
13
|
+
exports.isDocumentNotOpenError = isDocumentNotOpenError;
|
|
14
|
+
exports.isDuplicateClientIdError = isDuplicateClientIdError;
|
|
15
|
+
exports.isReservedClientIdError = isReservedClientIdError;
|
|
12
16
|
exports.isConflictError = isConflictError;
|
|
13
17
|
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
18
|
+
const primitives_1 = require("./messages/primitives");
|
|
19
|
+
/*
|
|
20
|
+
* Every error here is a typed error: a caller reacts to it, so it has a class,
|
|
21
|
+
* a JSON-RPC code and an `is*` guard, and an English message. A typed error
|
|
22
|
+
* also carries a message identity where the framework can write an end-user
|
|
23
|
+
* sentence that needs no context. A URI may stay in that sentence; a client id
|
|
24
|
+
* or a raw version stays out of it, worded or left to `data`.
|
|
25
|
+
*
|
|
26
|
+
* An error nothing reacts to does not belong here: it stays a plain `Error`, or
|
|
27
|
+
* a named subclass without a code, at its throw site, since a code and a guard
|
|
28
|
+
* are public API that no caller would use.
|
|
29
|
+
*/
|
|
14
30
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
31
|
+
* The catalogue declaration behind {@link ConflictError}'s sentence. It words
|
|
32
|
+
* the version mismatch rather than stating it: the two numbers mean nothing to
|
|
33
|
+
* an end user, and they stay in {@link ConflictErrorData}.
|
|
34
|
+
*
|
|
35
|
+
* Its English must keep containing {@link CONFLICT_ERROR_MESSAGE_MARKER}: the
|
|
36
|
+
* marker is tier 3 of {@link isConflictError}'s ladder, and it matches on text.
|
|
37
|
+
* That tier only ever works untranslated, which is why it is the last resort
|
|
38
|
+
* behind the numeric code rather than the primary check.
|
|
39
|
+
*/
|
|
40
|
+
exports.STALE_BASED_UPDATE = (0, primitives_1.defineMessage)('hydranium/protocol/stale-based-update', 'The edit to {uri} was not applied: it was made to an older version of the document.');
|
|
41
|
+
/**
|
|
42
|
+
* Every JSON-RPC error code the framework raises, from any package, keyed by
|
|
43
|
+
* the error it identifies.
|
|
44
|
+
*
|
|
45
|
+
* The framework reserves the block 42000 to 42999 for these, and an adopter's
|
|
46
|
+
* own codes stay outside it: after an RPC a guard matches on the code alone, so
|
|
47
|
+
* an adopter's error carrying one of these reads as the framework's. A new code
|
|
48
|
+
* takes the next unused number in the block, whichever package raises it, and
|
|
49
|
+
* is declared here, where tests hold every code distinct and inside the block.
|
|
50
|
+
* The block sits clear of the range JSON-RPC 2.0 reserves for itself, -32768
|
|
51
|
+
* to -32000.
|
|
52
|
+
*/
|
|
53
|
+
exports.HYDRANIUM_ERROR_CODES = {
|
|
54
|
+
conflict: 42001,
|
|
55
|
+
noActiveProfile: 42002,
|
|
56
|
+
referenceSettleTimeout: 42003,
|
|
57
|
+
sessionClosed: 42004,
|
|
58
|
+
documentNotOpen: 42005,
|
|
59
|
+
duplicateClientId: 42006,
|
|
60
|
+
reservedClientId: 42007
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* JSON-RPC error code for {@link ConflictError}.
|
|
17
64
|
*
|
|
18
65
|
* The code is the load-bearing identifier across realm boundaries —
|
|
19
66
|
* `code` is a first-class field on the JSON-RPC error envelope and
|
|
20
67
|
* survives wire reconstruction; the custom `Error` subclass name does
|
|
21
68
|
* not.
|
|
22
69
|
*/
|
|
23
|
-
exports.CONFLICT_ERROR_CODE =
|
|
70
|
+
exports.CONFLICT_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.conflict;
|
|
24
71
|
/**
|
|
25
|
-
* Thrown by `
|
|
72
|
+
* Thrown by a client session's `update` / `save` when the caller-
|
|
26
73
|
* supplied based-on version no longer matches the server's current text-
|
|
27
74
|
* document version for the same URI — i.e. the snapshot the caller
|
|
28
75
|
* authored against has been superseded by an intervening edit.
|
|
@@ -35,11 +82,9 @@ exports.CONFLICT_ERROR_CODE = 1001;
|
|
|
35
82
|
* `err.data` (the instance is reconstructed as a generic
|
|
36
83
|
* `ResponseError`, so subclass getters / fields do not survive).
|
|
37
84
|
*
|
|
38
|
-
* Detection is
|
|
39
|
-
*
|
|
40
|
-
* no gating.
|
|
41
|
-
* posture, so headless / CLI / batch tooling with no meaningful based-on
|
|
42
|
-
* version can opt out explicitly.
|
|
85
|
+
* Detection is driven by the required `basedOn` field of every write
|
|
86
|
+
* request; a caller with no meaningful based-on version passes
|
|
87
|
+
* `'anything'` and gets no gating.
|
|
43
88
|
*
|
|
44
89
|
* Three reasonable adopter recovery strategies:
|
|
45
90
|
*
|
|
@@ -53,35 +98,186 @@ exports.CONFLICT_ERROR_CODE = 1001;
|
|
|
53
98
|
* No auto-retry or auto-merge ships by default.
|
|
54
99
|
*/
|
|
55
100
|
class ConflictError extends vscode_jsonrpc_1.ResponseError {
|
|
56
|
-
constructor(uri,
|
|
57
|
-
|
|
101
|
+
constructor(uri, expectedVersion, actualVersion) {
|
|
102
|
+
// The identity rides alongside the typed payload rather than replacing
|
|
103
|
+
// it: `isConflictError`'s name check is surface an adopter may bind, so
|
|
104
|
+
// adding the identity widens the payload rather than reshaping it.
|
|
105
|
+
super(exports.CONFLICT_ERROR_CODE, exports.STALE_BASED_UPDATE.format({ uri }), {
|
|
58
106
|
uri,
|
|
59
|
-
|
|
60
|
-
|
|
107
|
+
expectedVersion,
|
|
108
|
+
actualVersion,
|
|
109
|
+
...(0, primitives_1.messageData)(exports.STALE_BASED_UPDATE, { uri })
|
|
61
110
|
});
|
|
62
111
|
this.name = 'ConflictError';
|
|
63
112
|
// ResponseError's constructor calls `Object.setPrototypeOf(this,
|
|
64
113
|
// ResponseError.prototype)` to keep its own prototype chain intact across
|
|
65
114
|
// transpilation targets; that resets us to ResponseError, hiding the
|
|
66
115
|
// ConflictError-specific getters. Restore the prototype here so
|
|
67
|
-
// `err.uri` / `.
|
|
116
|
+
// `err.uri` / `.expectedVersion` / `.actualVersion` resolve through this
|
|
117
|
+
// class.
|
|
68
118
|
Object.setPrototypeOf(this, ConflictError.prototype);
|
|
69
119
|
}
|
|
70
120
|
get uri() {
|
|
71
121
|
return this.data.uri;
|
|
72
122
|
}
|
|
73
|
-
|
|
74
|
-
|
|
123
|
+
/**
|
|
124
|
+
* The based-on version the caller authored against.
|
|
125
|
+
*
|
|
126
|
+
* Must not be renamed to `expected`, nor its sibling to `actual`: a test
|
|
127
|
+
* reporter reads an error carrying both as an assertion failure, and
|
|
128
|
+
* vitest's formatter then ASSIGNS to them, which throws on an accessor and
|
|
129
|
+
* replaces the real failure with a `TypeError`.
|
|
130
|
+
*/
|
|
131
|
+
get expectedVersion() {
|
|
132
|
+
return this.data.expectedVersion;
|
|
75
133
|
}
|
|
76
|
-
|
|
77
|
-
|
|
134
|
+
/** The server's version at the time of the throw. Not `actual` — see {@link expectedVersion}. */
|
|
135
|
+
get actualVersion() {
|
|
136
|
+
return this.data.actualVersion;
|
|
78
137
|
}
|
|
79
138
|
}
|
|
80
139
|
exports.ConflictError = ConflictError;
|
|
140
|
+
/**
|
|
141
|
+
* JSON-RPC code for {@link SessionClosedError}, beside {@link CONFLICT_ERROR_CODE}
|
|
142
|
+
* and for the same reason: the code survives reconstruction, the class does not.
|
|
143
|
+
*/
|
|
144
|
+
exports.SESSION_CLOSED_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.sessionClosed;
|
|
145
|
+
/** JSON-RPC code for {@link DocumentNotOpenError}. */
|
|
146
|
+
exports.DOCUMENT_NOT_OPEN_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.documentNotOpen;
|
|
147
|
+
/** JSON-RPC code for {@link DuplicateClientIdError}. */
|
|
148
|
+
exports.DUPLICATE_CLIENT_ID_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.duplicateClientId;
|
|
149
|
+
/** JSON-RPC code for {@link ReservedClientIdError}. */
|
|
150
|
+
exports.RESERVED_CLIENT_ID_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.reservedClientId;
|
|
151
|
+
/**
|
|
152
|
+
* The catalogue declaration behind {@link SessionClosedError}'s default
|
|
153
|
+
* sentence. It names no client id: the sentence can reach an end user, and the
|
|
154
|
+
* id stays in {@link SessionClosedErrorData.clientId} for whoever needs it.
|
|
155
|
+
*/
|
|
156
|
+
exports.SESSION_CLOSED = (0, primitives_1.defineMessage)('hydranium/protocol/session-closed', 'The editing session has ended.');
|
|
157
|
+
/**
|
|
158
|
+
* Thrown by every call on a client session after it ended, and by an open that
|
|
159
|
+
* was still in flight when its session ended: by the server for its sessions,
|
|
160
|
+
* and by a client-side `DataSession` once disposed, so a caller handles both
|
|
161
|
+
* the same way. A caller recognises it with {@link isSessionClosedError}, never
|
|
162
|
+
* by its sentence.
|
|
163
|
+
*/
|
|
164
|
+
class SessionClosedError extends vscode_jsonrpc_1.ResponseError {
|
|
165
|
+
/**
|
|
166
|
+
* `message` replaces the default English, for a caller that knows more than
|
|
167
|
+
* that the session is gone. The identity stays {@link SESSION_CLOSED}'s, so a
|
|
168
|
+
* translating renderer renders the catalogue sentence in its place.
|
|
169
|
+
*/
|
|
170
|
+
constructor(clientId, message = exports.SESSION_CLOSED.format()) {
|
|
171
|
+
super(exports.SESSION_CLOSED_ERROR_CODE, message, { clientId, ...(0, primitives_1.messageData)(exports.SESSION_CLOSED) });
|
|
172
|
+
this.name = 'SessionClosedError';
|
|
173
|
+
// `ResponseError` resets the prototype to its own; see `ConflictError`.
|
|
174
|
+
Object.setPrototypeOf(this, SessionClosedError.prototype);
|
|
175
|
+
}
|
|
176
|
+
get clientId() {
|
|
177
|
+
return this.data.clientId;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
exports.SessionClosedError = SessionClosedError;
|
|
181
|
+
/**
|
|
182
|
+
* The catalogue declaration behind {@link DocumentNotOpenError}'s sentence. The
|
|
183
|
+
* client id stays in {@link DocumentNotOpenErrorData.clientId}.
|
|
184
|
+
*/
|
|
185
|
+
exports.DOCUMENT_NOT_OPEN = (0, primitives_1.defineMessage)('hydranium/protocol/document-not-open', 'The document {uri} is not open in this editing session.');
|
|
186
|
+
/**
|
|
187
|
+
* Thrown when a client session writes a document it does not have open.
|
|
188
|
+
*
|
|
189
|
+
* A session writes only what it has open, so this is the answer both to a write
|
|
190
|
+
* that never opened and to one whose open was closed underneath it — by the
|
|
191
|
+
* session itself, or by the document being deleted.
|
|
192
|
+
*/
|
|
193
|
+
class DocumentNotOpenError extends vscode_jsonrpc_1.ResponseError {
|
|
194
|
+
constructor(uri, clientId) {
|
|
195
|
+
super(exports.DOCUMENT_NOT_OPEN_ERROR_CODE, exports.DOCUMENT_NOT_OPEN.format({ uri }), {
|
|
196
|
+
uri,
|
|
197
|
+
clientId,
|
|
198
|
+
...(0, primitives_1.messageData)(exports.DOCUMENT_NOT_OPEN, { uri })
|
|
199
|
+
});
|
|
200
|
+
this.name = 'DocumentNotOpenError';
|
|
201
|
+
Object.setPrototypeOf(this, DocumentNotOpenError.prototype);
|
|
202
|
+
}
|
|
203
|
+
get uri() {
|
|
204
|
+
return this.data.uri;
|
|
205
|
+
}
|
|
206
|
+
get clientId() {
|
|
207
|
+
return this.data.clientId;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
exports.DocumentNotOpenError = DocumentNotOpenError;
|
|
211
|
+
/**
|
|
212
|
+
* The catalogue declaration behind {@link DuplicateClientIdError}'s sentence.
|
|
213
|
+
* The client id stays in {@link DuplicateClientIdErrorData.clientId}.
|
|
214
|
+
*/
|
|
215
|
+
exports.DUPLICATE_CLIENT_ID = (0, primitives_1.defineMessage)('hydranium/protocol/duplicate-client-id', 'Could not start an editing session: its identifier is still in use by another editor.');
|
|
216
|
+
/**
|
|
217
|
+
* Thrown when a client session is started under an id that is already live in
|
|
218
|
+
* the process. The id frees up once its holder ends or closes its last
|
|
219
|
+
* document, so a caller may retry.
|
|
220
|
+
*
|
|
221
|
+
* Ids are unique process-wide because the id is also the author label on every
|
|
222
|
+
* version and the key a client recognises its own echoes by; two participants
|
|
223
|
+
* sharing one would each take the other's writes for their own.
|
|
224
|
+
*/
|
|
225
|
+
class DuplicateClientIdError extends vscode_jsonrpc_1.ResponseError {
|
|
226
|
+
constructor(clientId) {
|
|
227
|
+
super(exports.DUPLICATE_CLIENT_ID_ERROR_CODE, exports.DUPLICATE_CLIENT_ID.format(), { clientId, ...(0, primitives_1.messageData)(exports.DUPLICATE_CLIENT_ID) });
|
|
228
|
+
this.name = 'DuplicateClientIdError';
|
|
229
|
+
Object.setPrototypeOf(this, DuplicateClientIdError.prototype);
|
|
230
|
+
}
|
|
231
|
+
get clientId() {
|
|
232
|
+
return this.data.clientId;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
exports.DuplicateClientIdError = DuplicateClientIdError;
|
|
236
|
+
/**
|
|
237
|
+
* Thrown when a client session is started under an id the framework reserves
|
|
238
|
+
* for one of its own participants. A reserved id never frees up, so a caller
|
|
239
|
+
* that retries on {@link DuplicateClientIdError} stops on this one.
|
|
240
|
+
*
|
|
241
|
+
* It carries no message identity: a host that picks a reserved id has a bug,
|
|
242
|
+
* and no sentence addressed to an end user is true for it.
|
|
243
|
+
*/
|
|
244
|
+
class ReservedClientIdError extends vscode_jsonrpc_1.ResponseError {
|
|
245
|
+
constructor(clientId) {
|
|
246
|
+
super(exports.RESERVED_CLIENT_ID_ERROR_CODE, `Client id ${clientId} is reserved for a framework participant`, { clientId });
|
|
247
|
+
this.name = 'ReservedClientIdError';
|
|
248
|
+
Object.setPrototypeOf(this, ReservedClientIdError.prototype);
|
|
249
|
+
}
|
|
250
|
+
get clientId() {
|
|
251
|
+
return this.data.clientId;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
exports.ReservedClientIdError = ReservedClientIdError;
|
|
255
|
+
/**
|
|
256
|
+
* Whether `error` is a {@link SessionClosedError}: by name in-process, by code
|
|
257
|
+
* after an RPC, where it arrives as a plain `ResponseError`.
|
|
258
|
+
*/
|
|
259
|
+
function isSessionClosedError(error) {
|
|
260
|
+
return hasErrorIdentity(error, 'SessionClosedError', exports.SESSION_CLOSED_ERROR_CODE);
|
|
261
|
+
}
|
|
262
|
+
/** Whether `error` is a {@link DocumentNotOpenError}; see {@link isSessionClosedError}. */
|
|
263
|
+
function isDocumentNotOpenError(error) {
|
|
264
|
+
return hasErrorIdentity(error, 'DocumentNotOpenError', exports.DOCUMENT_NOT_OPEN_ERROR_CODE);
|
|
265
|
+
}
|
|
266
|
+
/** Whether `error` is a {@link DuplicateClientIdError}; see {@link isSessionClosedError}. */
|
|
267
|
+
function isDuplicateClientIdError(error) {
|
|
268
|
+
return hasErrorIdentity(error, 'DuplicateClientIdError', exports.DUPLICATE_CLIENT_ID_ERROR_CODE);
|
|
269
|
+
}
|
|
270
|
+
/** Whether `error` is a {@link ReservedClientIdError}; see {@link isSessionClosedError}. */
|
|
271
|
+
function isReservedClientIdError(error) {
|
|
272
|
+
return hasErrorIdentity(error, 'ReservedClientIdError', exports.RESERVED_CLIENT_ID_ERROR_CODE);
|
|
273
|
+
}
|
|
274
|
+
function hasErrorIdentity(error, name, code) {
|
|
275
|
+
return error instanceof Error && (error.name === name || error.code === code);
|
|
276
|
+
}
|
|
81
277
|
/** Marker substring present in every {@link ConflictError} message, used by
|
|
82
278
|
* {@link isConflictError} as a fallback when a transport re-wraps the error
|
|
83
279
|
* and drops the JSON-RPC code. */
|
|
84
|
-
const CONFLICT_ERROR_MESSAGE_MARKER = '
|
|
280
|
+
const CONFLICT_ERROR_MESSAGE_MARKER = ': it was made to an older version of the document';
|
|
85
281
|
/**
|
|
86
282
|
* Type guard for {@link ConflictError}. Detection ladder:
|
|
87
283
|
*
|
|
@@ -91,8 +287,9 @@ const CONFLICT_ERROR_MESSAGE_MARKER = 'Stale-based update for ';
|
|
|
91
287
|
* canonical wire-side check; the JSON-RPC `code` field is preserved
|
|
92
288
|
* across reconstruction, so any adopter catching after an RPC call
|
|
93
289
|
* hits this branch.
|
|
94
|
-
* 3. `error.message
|
|
95
|
-
* for transports that re-wrap the message
|
|
290
|
+
* 3. `error.message` contains the marker {@link STALE_BASED_UPDATE}'s
|
|
291
|
+
* English carries — fallback for transports that re-wrap the message
|
|
292
|
+
* and drop the code (rare).
|
|
96
293
|
*
|
|
97
294
|
* `instanceof ConflictError` alone would silently return `false` on the
|
|
98
295
|
* reconstructed shape, so callers do not use it.
|
package/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;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K,CAAC;IAChB,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACf,CAAC;IACD,MAAM,IAAI,GAAI,KAAyC,CAAC,IAAI,CAAC;IAC7D,IAAI,IAAI,KAAK,2BAAmB,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC;IACf,CAAC;IACD,OAAO,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CAAC;AACrG,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
/**
|
|
10
|
+
* A save of a diagram's model that the server answers, with a
|
|
11
|
+
* {@link ModelSavedAction} once the save has finished or a GLSP
|
|
12
|
+
* `RejectAction` when it fails.
|
|
13
|
+
*
|
|
14
|
+
* It carries what GLSP's `SaveModelAction` carries, and the server saves it the
|
|
15
|
+
* same way. GLSP's `SaveModelAction` is not answered: the server's only
|
|
16
|
+
* reply is a dirty-state change, which the client drops when the dirty flag
|
|
17
|
+
* does not change, so a client cannot tell which save an answer belongs to or
|
|
18
|
+
* whether a save failed.
|
|
19
|
+
*/
|
|
20
|
+
export interface RequestSaveModelAction {
|
|
21
|
+
kind: typeof RequestSaveModelAction.KIND;
|
|
22
|
+
/** The id the response echoes as its `responseId`. Empty until the dispatcher assigns one. */
|
|
23
|
+
requestId: string;
|
|
24
|
+
/** How long the receiver waits for its own handler, in milliseconds. */
|
|
25
|
+
timeout?: number;
|
|
26
|
+
/** The file to save to, as in GLSP's `SaveModelAction`; absent saves to the diagram's source. */
|
|
27
|
+
fileUri?: string;
|
|
28
|
+
/** GLSP's typing marker for the response. Never set. */
|
|
29
|
+
readonly _?: ModelSavedAction;
|
|
30
|
+
}
|
|
31
|
+
export declare namespace RequestSaveModelAction {
|
|
32
|
+
const KIND = "hydraniumRequestSaveModel";
|
|
33
|
+
function create(options?: {
|
|
34
|
+
fileUri?: string;
|
|
35
|
+
requestId?: string;
|
|
36
|
+
}): RequestSaveModelAction;
|
|
37
|
+
}
|
|
38
|
+
/** The server's answer to a {@link RequestSaveModelAction} that saved. */
|
|
39
|
+
export interface ModelSavedAction {
|
|
40
|
+
kind: typeof ModelSavedAction.KIND;
|
|
41
|
+
/** The `requestId` of the save this answers. The server's dispatcher sets it. */
|
|
42
|
+
responseId: string;
|
|
43
|
+
}
|
|
44
|
+
export declare namespace ModelSavedAction {
|
|
45
|
+
const KIND = "hydraniumModelSaved";
|
|
46
|
+
function create(options?: {
|
|
47
|
+
responseId?: string;
|
|
48
|
+
}): ModelSavedAction;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=glsp-save-model-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glsp-save-model-actions.d.ts","sourceRoot":"","sources":["../src/glsp-save-model-actions.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAOlF;;;;;;;;;;GAUG;AACH,MAAM,WAAW,sBAAsB;IACpC,IAAI,EAAE,OAAO,sBAAsB,CAAC,IAAI,CAAC;IACzC,8FAA8F;IAC9F,SAAS,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iGAAiG;IACjG,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,QAAQ,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC;CAChC;AAED,yBAAiB,sBAAsB,CAAC;IAC9B,MAAM,IAAI,8BAA8B,CAAC;IAEhD,SAAgB,MAAM,CAAC,OAAO,GAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,sBAAsB,CAErG;CACH;AAED,0EAA0E;AAC1E,MAAM,WAAW,gBAAgB;IAC9B,IAAI,EAAE,OAAO,gBAAgB,CAAC,IAAI,CAAC;IACnC,iFAAiF;IACjF,UAAU,EAAE,MAAM,CAAC;CACrB;AAED,yBAAiB,gBAAgB,CAAC;IACxB,MAAM,IAAI,wBAAwB,CAAC;IAE1C,SAAgB,MAAM,CAAC,OAAO,GAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,gBAAgB,CAE9E;CACH"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made available under the
|
|
6
|
+
* terms of the MIT License which is available in the project root.
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: MIT
|
|
9
|
+
********************************************************************************/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.ModelSavedAction = exports.RequestSaveModelAction = void 0;
|
|
12
|
+
var RequestSaveModelAction;
|
|
13
|
+
(function (RequestSaveModelAction) {
|
|
14
|
+
RequestSaveModelAction.KIND = 'hydraniumRequestSaveModel';
|
|
15
|
+
function create(options = {}) {
|
|
16
|
+
return { kind: RequestSaveModelAction.KIND, requestId: '', ...options };
|
|
17
|
+
}
|
|
18
|
+
RequestSaveModelAction.create = create;
|
|
19
|
+
})(RequestSaveModelAction || (exports.RequestSaveModelAction = RequestSaveModelAction = {}));
|
|
20
|
+
var ModelSavedAction;
|
|
21
|
+
(function (ModelSavedAction) {
|
|
22
|
+
ModelSavedAction.KIND = 'hydraniumModelSaved';
|
|
23
|
+
function create(options = {}) {
|
|
24
|
+
return { kind: ModelSavedAction.KIND, responseId: '', ...options };
|
|
25
|
+
}
|
|
26
|
+
ModelSavedAction.create = create;
|
|
27
|
+
})(ModelSavedAction || (exports.ModelSavedAction = ModelSavedAction = {}));
|
|
28
|
+
//# sourceMappingURL=glsp-save-model-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glsp-save-model-actions.js","sourceRoot":"","sources":["../src/glsp-save-model-actions.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AA8BlF,IAAiB,sBAAsB,CAMtC;AAND,WAAiB,sBAAsB;IACvB,2BAAI,GAAG,2BAA2B,CAAC;IAEhD,SAAgB,MAAM,CAAC,UAAoD,EAAE;QAC1E,OAAO,EAAE,IAAI,EAAE,uBAAA,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC;IACpD,CAAC;IAFe,6BAAM,SAErB,CAAA;AACJ,CAAC,EANgB,sBAAsB,sCAAtB,sBAAsB,QAMtC;AASD,IAAiB,gBAAgB,CAMhC;AAND,WAAiB,gBAAgB;IACjB,qBAAI,GAAG,qBAAqB,CAAC;IAE1C,SAAgB,MAAM,CAAC,UAAmC,EAAE;QACzD,OAAO,EAAE,IAAI,EAAE,iBAAA,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC;IACrD,CAAC;IAFe,uBAAM,SAErB,CAAA;AACJ,CAAC,EANgB,gBAAgB,gCAAhB,gBAAgB,QAMhC"}
|