@hydranium/protocol 1.0.0-next.38 → 1.0.0-next.380
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 +11 -0
- package/lib/abstract-logger.d.ts.map +1 -1
- package/lib/abstract-logger.js +16 -0
- package/lib/abstract-logger.js.map +1 -1
- package/lib/client/data-connection.d.ts +303 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +534 -0
- package/lib/client/data-connection.js.map +1 -0
- package/lib/client/data-events.d.ts +18 -1
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +26 -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 +694 -89
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +1158 -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 +6 -4
- package/lib/client/message-relay.d.ts.map +1 -1
- 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 +69 -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 +173 -0
- package/lib/client/rpc-connection.d.ts.map +1 -0
- package/lib/client/rpc-connection.js +225 -0
- package/lib/client/rpc-connection.js.map +1 -0
- package/lib/client/worker-handshake.d.ts +94 -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 +176 -49
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +144 -33
- package/lib/data/events.d.ts.map +1 -1
- package/lib/data/requests.d.ts +84 -11
- package/lib/data/requests.d.ts.map +1 -1
- package/lib/debouncer.d.ts +7 -4
- package/lib/debouncer.d.ts.map +1 -1
- package/lib/debouncer.js +10 -10
- package/lib/debouncer.js.map +1 -1
- package/lib/errors.d.ts +243 -41
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +400 -55
- package/lib/errors.js.map +1 -1
- package/lib/format-log-arg.d.ts +33 -0
- package/lib/format-log-arg.d.ts.map +1 -0
- package/lib/format-log-arg.js +158 -0
- package/lib/format-log-arg.js.map +1 -0
- package/lib/glsp-edits-settled-actions.d.ts +54 -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 +55 -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 +11 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -1
- package/lib/latency-collector.d.ts +10 -4
- package/lib/latency-collector.d.ts.map +1 -1
- package/lib/latency-collector.js +2 -0
- 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 +17 -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 +30 -0
- package/lib/pending-work-tracker.d.ts.map +1 -0
- package/lib/pending-work-tracker.js +47 -0
- package/lib/pending-work-tracker.js.map +1 -0
- package/lib/profile-session.d.ts +24 -8
- package/lib/profile-session.d.ts.map +1 -1
- package/lib/profile-session.js +13 -4
- package/lib/profile-session.js.map +1 -1
- package/lib/profiling.d.ts +15 -2
- package/lib/profiling.d.ts.map +1 -1
- package/lib/profiling.js.map +1 -1
- package/lib/project.d.ts +6 -2
- 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 +70 -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.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.d.ts +11 -0
- package/lib/transfer-diagnostic.d.ts.map +1 -1
- package/lib/transfer-diagnostic.js +17 -0
- package/lib/transfer-diagnostic.js.map +1 -1
- package/lib/transfer-document.d.ts +96 -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 +18 -0
- package/src/client/data-connection.ts +654 -0
- package/src/client/data-events.ts +38 -1
- package/src/client/data-port.ts +36 -25
- package/src/client/data-session.ts +1479 -137
- package/src/client/index.ts +15 -9
- package/src/client/message-relay.ts +6 -4
- package/src/client/post-message-transport.ts +224 -4
- package/src/client/rpc-connection.ts +302 -0
- package/src/client/worker-handshake.ts +121 -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 +203 -49
- package/src/data/events.ts +150 -33
- package/src/data/requests.ts +90 -11
- package/src/debouncer.ts +11 -11
- package/src/errors.ts +500 -65
- package/src/format-log-arg.ts +176 -0
- package/src/glsp-edits-settled-actions.ts +62 -0
- package/src/glsp-request-model-args.ts +16 -0
- package/src/glsp-save-model-actions.ts +64 -0
- package/src/index.ts +11 -0
- package/src/latency-collector.ts +10 -3
- package/src/logger.ts +44 -8
- package/src/messages/index.ts +12 -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 +47 -0
- package/src/profile-session.ts +31 -11
- package/src/profiling.ts +15 -2
- package/src/project.ts +6 -2
- package/src/random-uuid.ts +21 -0
- package/src/reconcile-write.ts +131 -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/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-diagnostic.ts +17 -0
- package/src/transfer-document.ts +116 -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
package/lib/errors.js
CHANGED
|
@@ -8,48 +8,92 @@
|
|
|
8
8
|
* SPDX-License-Identifier: MIT
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.ConflictError = exports.CONFLICT_ERROR_CODE = exports.
|
|
11
|
+
exports.DocumentSyntaxError = exports.DOCUMENT_SYNTAX_ERROR = exports.SaveFailedError = exports.SAVE_FAILED = exports.ReservedClientIdError = exports.DuplicateClientIdError = exports.DUPLICATE_CLIENT_ID = exports.DocumentNotOpenError = exports.DOCUMENT_NOT_OPEN = exports.SessionClosedError = exports.SESSION_CLOSED = exports.DOCUMENT_SYNTAX_ERROR_CODE = exports.SAVE_FAILED_ERROR_CODE = 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_BASE_VERSION_SAVE = exports.STALE_BASE_VERSION_UPDATE = void 0;
|
|
12
|
+
exports.isResponseError = isResponseError;
|
|
13
|
+
exports.reviveProtocolError = reviveProtocolError;
|
|
14
|
+
exports.reviveProtocolErrorJson = reviveProtocolErrorJson;
|
|
15
|
+
exports.isSessionClosedError = isSessionClosedError;
|
|
16
|
+
exports.isDocumentNotOpenError = isDocumentNotOpenError;
|
|
17
|
+
exports.isDuplicateClientIdError = isDuplicateClientIdError;
|
|
18
|
+
exports.isReservedClientIdError = isReservedClientIdError;
|
|
19
|
+
exports.isSaveFailedError = isSaveFailedError;
|
|
20
|
+
exports.isDocumentSyntaxError = isDocumentSyntaxError;
|
|
12
21
|
exports.isConflictError = isConflictError;
|
|
13
22
|
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
14
23
|
const primitives_1 = require("./messages/primitives");
|
|
24
|
+
const base_version_1 = require("./model-service/base-version");
|
|
25
|
+
/*
|
|
26
|
+
* Every error here is a typed error: a caller reacts to it, so it has a class,
|
|
27
|
+
* a JSON-RPC code and an `is*` guard, and an English message. A typed error
|
|
28
|
+
* also carries a message identity where the framework can write an end-user
|
|
29
|
+
* sentence that needs no context. A URI may stay in that sentence; a client id
|
|
30
|
+
* or a raw version stays out of it, worded or left to `data`.
|
|
31
|
+
*
|
|
32
|
+
* An error nothing reacts to does not belong here: it stays a plain `Error`, or
|
|
33
|
+
* a named subclass without a code, at its throw site, since a code and a guard
|
|
34
|
+
* are public API that no caller would use.
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* The catalogue declaration behind {@link ConflictError}'s sentence. It words
|
|
38
|
+
* the version mismatch rather than stating it: the two numbers mean nothing to
|
|
39
|
+
* an end user, and they stay in {@link ConflictErrorData}.
|
|
40
|
+
*/
|
|
41
|
+
exports.STALE_BASE_VERSION_UPDATE = (0, primitives_1.defineMessage)('hydranium/protocol/stale-base-version-update', 'The edit to {uri} was not applied: it was made to an older version of the document.');
|
|
42
|
+
/**
|
|
43
|
+
* {@link STALE_BASE_VERSION_UPDATE}'s counterpart for an editor's save the
|
|
44
|
+
* server refused, since the editor's buffer is not the text it holds.
|
|
45
|
+
*/
|
|
46
|
+
exports.STALE_BASE_VERSION_SAVE = (0, primitives_1.defineMessage)('hydranium/protocol/stale-base-version-save', 'The save of {uri} was not applied: it was made to an older version of the document.');
|
|
15
47
|
/**
|
|
16
|
-
*
|
|
48
|
+
* Every JSON-RPC error code the framework raises, from any package, keyed by
|
|
49
|
+
* the error it identifies.
|
|
17
50
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
51
|
+
* The framework reserves the block 42000 to 42999 for these, and an adopter's
|
|
52
|
+
* own codes stay outside it: after an RPC the proxy revives an error by its
|
|
53
|
+
* code, so an adopter's error carrying one of these can read as the
|
|
54
|
+
* framework's. A new code takes the next unused number in the block, whichever
|
|
55
|
+
* package raises it, and is declared here, where tests hold every code distinct
|
|
56
|
+
* and inside the block.
|
|
57
|
+
* The block sits clear of the range JSON-RPC 2.0 reserves for itself, -32768
|
|
58
|
+
* to -32000.
|
|
22
59
|
*/
|
|
23
|
-
exports.
|
|
60
|
+
exports.HYDRANIUM_ERROR_CODES = {
|
|
61
|
+
conflict: 42001,
|
|
62
|
+
noActiveProfile: 42002,
|
|
63
|
+
referenceSettleTimeout: 42003,
|
|
64
|
+
sessionClosed: 42004,
|
|
65
|
+
documentNotOpen: 42005,
|
|
66
|
+
duplicateClientId: 42006,
|
|
67
|
+
reservedClientId: 42007,
|
|
68
|
+
saveFailed: 42008,
|
|
69
|
+
documentSyntaxError: 42009
|
|
70
|
+
};
|
|
24
71
|
/**
|
|
25
|
-
*
|
|
26
|
-
* Outside the reserved range (-32768 .. -32000) per JSON-RPC 2.0.
|
|
72
|
+
* JSON-RPC error code for {@link ConflictError}.
|
|
27
73
|
*
|
|
28
74
|
* The code is the load-bearing identifier across realm boundaries —
|
|
29
75
|
* `code` is a first-class field on the JSON-RPC error envelope and
|
|
30
76
|
* survives wire reconstruction; the custom `Error` subclass name does
|
|
31
77
|
* not.
|
|
32
78
|
*/
|
|
33
|
-
exports.CONFLICT_ERROR_CODE =
|
|
79
|
+
exports.CONFLICT_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.conflict;
|
|
34
80
|
/**
|
|
35
|
-
* Thrown by `
|
|
36
|
-
* supplied
|
|
81
|
+
* Thrown by a client session's `update` / `save` when the caller-
|
|
82
|
+
* supplied base version no longer matches the server's current text-
|
|
37
83
|
* document version for the same URI — i.e. the snapshot the caller
|
|
38
84
|
* authored against has been superseded by an intervening edit.
|
|
39
85
|
*
|
|
40
86
|
* Extends vscode-jsonrpc's {@link ResponseError} so the typed
|
|
41
87
|
* {@link ConflictErrorData} payload rides on the standard JSON-RPC
|
|
42
88
|
* error envelope (`code`, `message`, `data`) — all three fields are
|
|
43
|
-
* preserved by RPC reconstruction.
|
|
44
|
-
* the receiving side
|
|
45
|
-
* `err.data`
|
|
46
|
-
*
|
|
89
|
+
* preserved by RPC reconstruction. `createRpcProxy` revives it into
|
|
90
|
+
* this class on the receiving side; a path that does not leaves a
|
|
91
|
+
* plain `ResponseError`, readable through `err.data` only and refused
|
|
92
|
+
* by {@link isConflictError}.
|
|
47
93
|
*
|
|
48
|
-
* Detection is
|
|
49
|
-
*
|
|
50
|
-
* no gating.
|
|
51
|
-
* posture, so headless / CLI / batch tooling with no meaningful based-on
|
|
52
|
-
* version can opt out explicitly.
|
|
94
|
+
* Detection is driven by the required `baseVersion` field of every write
|
|
95
|
+
* request; a caller with no meaningful base version passes
|
|
96
|
+
* `'any'` and gets no gating.
|
|
53
97
|
*
|
|
54
98
|
* Three reasonable adopter recovery strategies:
|
|
55
99
|
*
|
|
@@ -63,61 +107,362 @@ exports.CONFLICT_ERROR_CODE = 1001;
|
|
|
63
107
|
* No auto-retry or auto-merge ships by default.
|
|
64
108
|
*/
|
|
65
109
|
class ConflictError extends vscode_jsonrpc_1.ResponseError {
|
|
66
|
-
|
|
67
|
-
|
|
110
|
+
/** `message` words what was refused: an edit, or with {@link STALE_BASE_VERSION_SAVE} a save. */
|
|
111
|
+
constructor(uri, baseVersion, actualVersion, message = exports.STALE_BASE_VERSION_UPDATE) {
|
|
68
112
|
// The identity rides alongside the typed payload rather than replacing
|
|
69
|
-
// it
|
|
70
|
-
//
|
|
71
|
-
super(exports.CONFLICT_ERROR_CODE,
|
|
113
|
+
// it. The getters, the guard and the reviver read the payload's fields,
|
|
114
|
+
// so adding the identity widens the payload rather than reshaping it.
|
|
115
|
+
super(exports.CONFLICT_ERROR_CODE, message.format({ uri }), {
|
|
116
|
+
uri,
|
|
117
|
+
baseVersion,
|
|
118
|
+
actualVersion,
|
|
119
|
+
...(0, primitives_1.messageData)(message, { uri })
|
|
120
|
+
});
|
|
72
121
|
this.name = 'ConflictError';
|
|
73
122
|
// ResponseError's constructor calls `Object.setPrototypeOf(this,
|
|
74
123
|
// ResponseError.prototype)` to keep its own prototype chain intact across
|
|
75
124
|
// transpilation targets; that resets us to ResponseError, hiding the
|
|
76
125
|
// ConflictError-specific getters. Restore the prototype here so
|
|
77
|
-
// `err.uri` / `.
|
|
126
|
+
// `err.uri` / `.baseVersion` / `.actualVersion` resolve through this
|
|
127
|
+
// class.
|
|
78
128
|
Object.setPrototypeOf(this, ConflictError.prototype);
|
|
79
129
|
}
|
|
130
|
+
/** The document whose version moved, see {@link ConflictErrorData.uri}. */
|
|
80
131
|
get uri() {
|
|
81
132
|
return this.data.uri;
|
|
82
133
|
}
|
|
83
|
-
|
|
84
|
-
|
|
134
|
+
/**
|
|
135
|
+
* The base version the caller authored against. Not `expected`, and its
|
|
136
|
+
* sibling not `actual`: a test reporter reads that pair as an assertion
|
|
137
|
+
* failure and reports nothing of the real one.
|
|
138
|
+
*/
|
|
139
|
+
get baseVersion() {
|
|
140
|
+
return this.data.baseVersion;
|
|
85
141
|
}
|
|
86
|
-
|
|
87
|
-
|
|
142
|
+
/** The server's version at the time of the throw. Not `actual`, see {@link baseVersion}. */
|
|
143
|
+
get actualVersion() {
|
|
144
|
+
return this.data.actualVersion;
|
|
88
145
|
}
|
|
89
146
|
}
|
|
90
147
|
exports.ConflictError = ConflictError;
|
|
91
|
-
/** Marker substring present in every {@link ConflictError} message, used by
|
|
92
|
-
* {@link isConflictError} as a fallback when a transport re-wraps the error
|
|
93
|
-
* and drops the JSON-RPC code. */
|
|
94
|
-
const CONFLICT_ERROR_MESSAGE_MARKER = 'Stale-based update for ';
|
|
95
148
|
/**
|
|
96
|
-
*
|
|
149
|
+
* JSON-RPC code for {@link SessionClosedError}, beside {@link CONFLICT_ERROR_CODE}
|
|
150
|
+
* and for the same reason: the code survives reconstruction, the class does not.
|
|
151
|
+
*/
|
|
152
|
+
exports.SESSION_CLOSED_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.sessionClosed;
|
|
153
|
+
/** JSON-RPC code for {@link DocumentNotOpenError}. */
|
|
154
|
+
exports.DOCUMENT_NOT_OPEN_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.documentNotOpen;
|
|
155
|
+
/** JSON-RPC code for {@link DuplicateClientIdError}. */
|
|
156
|
+
exports.DUPLICATE_CLIENT_ID_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.duplicateClientId;
|
|
157
|
+
/** JSON-RPC code for {@link ReservedClientIdError}. */
|
|
158
|
+
exports.RESERVED_CLIENT_ID_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.reservedClientId;
|
|
159
|
+
/** JSON-RPC code for {@link SaveFailedError}. */
|
|
160
|
+
exports.SAVE_FAILED_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.saveFailed;
|
|
161
|
+
/** JSON-RPC code for {@link DocumentSyntaxError}. */
|
|
162
|
+
exports.DOCUMENT_SYNTAX_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.documentSyntaxError;
|
|
163
|
+
/**
|
|
164
|
+
* The catalogue declaration behind {@link SessionClosedError}'s default
|
|
165
|
+
* sentence. It names no client id: the sentence can reach an end user, and the
|
|
166
|
+
* id stays in {@link SessionClosedErrorData.clientId} for whoever needs it.
|
|
167
|
+
*/
|
|
168
|
+
exports.SESSION_CLOSED = (0, primitives_1.defineMessage)('hydranium/protocol/session-closed', 'The editing session has ended.');
|
|
169
|
+
/**
|
|
170
|
+
* Thrown by every call on a client session after it ended, and by an open that
|
|
171
|
+
* was still in flight when its session ended: by the server for its sessions,
|
|
172
|
+
* and by a client-side `DataSession` once disposed, so a caller handles both
|
|
173
|
+
* the same way. A caller recognises it with {@link isSessionClosedError}, never
|
|
174
|
+
* by its sentence.
|
|
175
|
+
*/
|
|
176
|
+
class SessionClosedError extends vscode_jsonrpc_1.ResponseError {
|
|
177
|
+
/**
|
|
178
|
+
* `message` replaces the default English, for a caller that knows more than
|
|
179
|
+
* that the session is gone. The identity stays {@link SESSION_CLOSED}'s, so a
|
|
180
|
+
* translating renderer renders the catalogue sentence in its place.
|
|
181
|
+
*/
|
|
182
|
+
constructor(clientId, message = exports.SESSION_CLOSED.format()) {
|
|
183
|
+
super(exports.SESSION_CLOSED_ERROR_CODE, message, { clientId, ...(0, primitives_1.messageData)(exports.SESSION_CLOSED) });
|
|
184
|
+
this.name = 'SessionClosedError';
|
|
185
|
+
// `ResponseError` resets the prototype to its own; see `ConflictError`.
|
|
186
|
+
Object.setPrototypeOf(this, SessionClosedError.prototype);
|
|
187
|
+
}
|
|
188
|
+
get clientId() {
|
|
189
|
+
return this.data.clientId;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
exports.SessionClosedError = SessionClosedError;
|
|
193
|
+
/**
|
|
194
|
+
* The catalogue declaration behind {@link DocumentNotOpenError}'s sentence. The
|
|
195
|
+
* client id stays in {@link DocumentNotOpenErrorData.clientId}.
|
|
196
|
+
*/
|
|
197
|
+
exports.DOCUMENT_NOT_OPEN = (0, primitives_1.defineMessage)('hydranium/protocol/document-not-open', 'The document {uri} is not open in this editing session.');
|
|
198
|
+
/**
|
|
199
|
+
* Thrown when a client session writes a document it does not have open.
|
|
97
200
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
201
|
+
* A session writes only what it has open, so this is the answer both to a write
|
|
202
|
+
* that never opened and to one whose open was closed underneath it — by the
|
|
203
|
+
* session itself, or by the document being deleted.
|
|
204
|
+
*/
|
|
205
|
+
class DocumentNotOpenError extends vscode_jsonrpc_1.ResponseError {
|
|
206
|
+
constructor(uri, clientId) {
|
|
207
|
+
super(exports.DOCUMENT_NOT_OPEN_ERROR_CODE, exports.DOCUMENT_NOT_OPEN.format({ uri }), {
|
|
208
|
+
uri,
|
|
209
|
+
clientId,
|
|
210
|
+
...(0, primitives_1.messageData)(exports.DOCUMENT_NOT_OPEN, { uri })
|
|
211
|
+
});
|
|
212
|
+
this.name = 'DocumentNotOpenError';
|
|
213
|
+
Object.setPrototypeOf(this, DocumentNotOpenError.prototype);
|
|
214
|
+
}
|
|
215
|
+
get uri() {
|
|
216
|
+
return this.data.uri;
|
|
217
|
+
}
|
|
218
|
+
get clientId() {
|
|
219
|
+
return this.data.clientId;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
exports.DocumentNotOpenError = DocumentNotOpenError;
|
|
223
|
+
/**
|
|
224
|
+
* The catalogue declaration behind {@link DuplicateClientIdError}'s sentence.
|
|
225
|
+
* The client id stays in {@link DuplicateClientIdErrorData.clientId}.
|
|
226
|
+
*/
|
|
227
|
+
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.');
|
|
228
|
+
/**
|
|
229
|
+
* Thrown when a client session is started under an id that is already live in
|
|
230
|
+
* the process. The id frees up once its holder ends or closes its last
|
|
231
|
+
* document, so a caller may retry.
|
|
106
232
|
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
233
|
+
* Ids are unique process-wide because the id is also the author label on every
|
|
234
|
+
* version and the key a client recognises its own echoes by; two participants
|
|
235
|
+
* sharing one would each take the other's writes for their own.
|
|
109
236
|
*/
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
237
|
+
class DuplicateClientIdError extends vscode_jsonrpc_1.ResponseError {
|
|
238
|
+
constructor(clientId) {
|
|
239
|
+
super(exports.DUPLICATE_CLIENT_ID_ERROR_CODE, exports.DUPLICATE_CLIENT_ID.format(), { clientId, ...(0, primitives_1.messageData)(exports.DUPLICATE_CLIENT_ID) });
|
|
240
|
+
this.name = 'DuplicateClientIdError';
|
|
241
|
+
Object.setPrototypeOf(this, DuplicateClientIdError.prototype);
|
|
113
242
|
}
|
|
114
|
-
|
|
115
|
-
return
|
|
243
|
+
get clientId() {
|
|
244
|
+
return this.data.clientId;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
exports.DuplicateClientIdError = DuplicateClientIdError;
|
|
248
|
+
/**
|
|
249
|
+
* Thrown when a client session is started under an id the framework reserves
|
|
250
|
+
* for one of its own participants. A reserved id never frees up, so a caller
|
|
251
|
+
* that retries on {@link DuplicateClientIdError} stops on this one.
|
|
252
|
+
*
|
|
253
|
+
* It carries no message identity: a host that picks a reserved id has a bug,
|
|
254
|
+
* and no sentence addressed to an end user is true for it.
|
|
255
|
+
*/
|
|
256
|
+
class ReservedClientIdError extends vscode_jsonrpc_1.ResponseError {
|
|
257
|
+
constructor(clientId) {
|
|
258
|
+
super(exports.RESERVED_CLIENT_ID_ERROR_CODE, `Client id ${clientId} is reserved for a framework participant`, { clientId });
|
|
259
|
+
this.name = 'ReservedClientIdError';
|
|
260
|
+
Object.setPrototypeOf(this, ReservedClientIdError.prototype);
|
|
116
261
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return true;
|
|
262
|
+
get clientId() {
|
|
263
|
+
return this.data.clientId;
|
|
120
264
|
}
|
|
121
|
-
|
|
265
|
+
}
|
|
266
|
+
exports.ReservedClientIdError = ReservedClientIdError;
|
|
267
|
+
/**
|
|
268
|
+
* The catalogue declaration behind {@link SaveFailedError}'s message. Its
|
|
269
|
+
* `failures` names each document with the writer's own reason, which stays as
|
|
270
|
+
* written.
|
|
271
|
+
*/
|
|
272
|
+
exports.SAVE_FAILED = (0, primitives_1.defineMessage)('hydranium/protocol/save-failed', 'Could not save {failures}.');
|
|
273
|
+
/**
|
|
274
|
+
* Thrown by a save that could not write one or more of its documents. A save
|
|
275
|
+
* of several documents writes the others, so the files on disk can be a mix
|
|
276
|
+
* until a later save succeeds.
|
|
277
|
+
*/
|
|
278
|
+
class SaveFailedError extends vscode_jsonrpc_1.ResponseError {
|
|
279
|
+
constructor(failures) {
|
|
280
|
+
const named = failures.map(failure => `${failure.uri} (${failure.reason})`).join(', ');
|
|
281
|
+
super(exports.SAVE_FAILED_ERROR_CODE, exports.SAVE_FAILED.format({ failures: named }), {
|
|
282
|
+
failures,
|
|
283
|
+
...(0, primitives_1.messageData)(exports.SAVE_FAILED, { failures: named })
|
|
284
|
+
});
|
|
285
|
+
this.name = 'SaveFailedError';
|
|
286
|
+
Object.setPrototypeOf(this, SaveFailedError.prototype);
|
|
287
|
+
}
|
|
288
|
+
get failures() {
|
|
289
|
+
return this.data.failures;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
exports.SaveFailedError = SaveFailedError;
|
|
293
|
+
/** The catalogue declaration behind {@link DocumentSyntaxError}'s sentence. */
|
|
294
|
+
exports.DOCUMENT_SYNTAX_ERROR = (0, primitives_1.defineMessage)('hydranium/protocol/document-syntax-error', 'The edit to {uri} was not applied: the document has a syntax error. Fix it in the text first.');
|
|
295
|
+
/**
|
|
296
|
+
* Thrown when a write would serialize a model over text that does not parse.
|
|
297
|
+
* A model read from a build with lexer or parser errors lacks what the parser
|
|
298
|
+
* skipped, so writing it would delete that text. A client session refuses a
|
|
299
|
+
* model write while the document's last build has such errors and its text
|
|
300
|
+
* is not blank, unless the write is a `restore`. A diagram refuses an edit,
|
|
301
|
+
* undo or redo that would write such a document, or whose merge or collision
|
|
302
|
+
* reads one. A client's write of text is not refused, since that is how the
|
|
303
|
+
* text is repaired.
|
|
304
|
+
*/
|
|
305
|
+
class DocumentSyntaxError extends vscode_jsonrpc_1.ResponseError {
|
|
306
|
+
constructor(uri) {
|
|
307
|
+
super(exports.DOCUMENT_SYNTAX_ERROR_CODE, exports.DOCUMENT_SYNTAX_ERROR.format({ uri }), { uri, ...(0, primitives_1.messageData)(exports.DOCUMENT_SYNTAX_ERROR, { uri }) });
|
|
308
|
+
this.name = 'DocumentSyntaxError';
|
|
309
|
+
Object.setPrototypeOf(this, DocumentSyntaxError.prototype);
|
|
310
|
+
}
|
|
311
|
+
get uri() {
|
|
312
|
+
return this.data.uri;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
exports.DocumentSyntaxError = DocumentSyntaxError;
|
|
316
|
+
/** One entry per typed error class, keyed by its code; a class without one reaches a caller as a plain `ResponseError`. */
|
|
317
|
+
const PROTOCOL_ERROR_REVIVERS = new Map([
|
|
318
|
+
[
|
|
319
|
+
exports.CONFLICT_ERROR_CODE,
|
|
320
|
+
data => (hasConflictFields(data) ? new ConflictError(data.uri, (0, base_version_1.asModelVersion)(data.baseVersion), data.actualVersion) : undefined)
|
|
321
|
+
],
|
|
322
|
+
[exports.SESSION_CLOSED_ERROR_CODE, data => (hasClientId(data) ? new SessionClosedError(data.clientId) : undefined)],
|
|
323
|
+
[exports.DOCUMENT_NOT_OPEN_ERROR_CODE, data => (hasDocumentNotOpenFields(data) ? new DocumentNotOpenError(data.uri, data.clientId) : undefined)],
|
|
324
|
+
[exports.DUPLICATE_CLIENT_ID_ERROR_CODE, data => (hasClientId(data) ? new DuplicateClientIdError(data.clientId) : undefined)],
|
|
325
|
+
[exports.RESERVED_CLIENT_ID_ERROR_CODE, data => (hasClientId(data) ? new ReservedClientIdError(data.clientId) : undefined)],
|
|
326
|
+
[exports.SAVE_FAILED_ERROR_CODE, data => (hasSaveFailures(data) ? new SaveFailedError(data.failures) : undefined)],
|
|
327
|
+
[exports.DOCUMENT_SYNTAX_ERROR_CODE, data => (hasUri(data) ? new DocumentSyntaxError(data.uri) : undefined)]
|
|
328
|
+
]);
|
|
329
|
+
// One check per class of the fields its getters read, run by its reviver on
|
|
330
|
+
// `data` and by its guard on the error, through the getters.
|
|
331
|
+
function hasConflictFields(value) {
|
|
332
|
+
return (isRecord(value) && typeof value.uri === 'string' && typeof value.baseVersion === 'number' && typeof value.actualVersion === 'number');
|
|
333
|
+
}
|
|
334
|
+
function hasClientId(value) {
|
|
335
|
+
return isRecord(value) && typeof value.clientId === 'string';
|
|
336
|
+
}
|
|
337
|
+
function hasDocumentNotOpenFields(value) {
|
|
338
|
+
return isRecord(value) && typeof value.uri === 'string' && typeof value.clientId === 'string';
|
|
339
|
+
}
|
|
340
|
+
function hasUri(value) {
|
|
341
|
+
return isRecord(value) && typeof value.uri === 'string';
|
|
342
|
+
}
|
|
343
|
+
function hasSaveFailures(value) {
|
|
344
|
+
return isRecord(value) && isSaveFailureList(value.failures);
|
|
345
|
+
}
|
|
346
|
+
function isRecord(value) {
|
|
347
|
+
return typeof value === 'object' && value !== null;
|
|
348
|
+
}
|
|
349
|
+
function isSaveFailureList(value) {
|
|
350
|
+
return (Array.isArray(value) &&
|
|
351
|
+
value.every((failure) => typeof failure === 'object' &&
|
|
352
|
+
failure !== null &&
|
|
353
|
+
'uri' in failure &&
|
|
354
|
+
typeof failure.uri === 'string' &&
|
|
355
|
+
'reason' in failure &&
|
|
356
|
+
typeof failure.reason === 'string'));
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Whether `error` is a `ResponseError` from any copy of `vscode-jsonrpc`. An
|
|
360
|
+
* install holds several copies, and `instanceof` recognises only its own. An
|
|
361
|
+
* error that merely carries an integer `code` has no `toJson`, and is not one.
|
|
362
|
+
*/
|
|
363
|
+
function isResponseError(error) {
|
|
364
|
+
return (error instanceof Error && 'code' in error && Number.isInteger(error.code) && 'toJson' in error && typeof error.toJson === 'function');
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* `error` as an instance of the typed error class its code names, with its
|
|
368
|
+
* message, data and stack kept, or `error` itself when its code names none or
|
|
369
|
+
* its data lacks the fields that class reads.
|
|
370
|
+
* An RPC reconstructs every rejection as a plain `ResponseError`, which has
|
|
371
|
+
* none of the class getters.
|
|
372
|
+
*/
|
|
373
|
+
function reviveProtocolError(error) {
|
|
374
|
+
if (!isResponseError(error) || error.data === null || typeof error.data !== 'object') {
|
|
375
|
+
return error;
|
|
376
|
+
}
|
|
377
|
+
const revived = PROTOCOL_ERROR_REVIVERS.get(error.code)?.({ ...error.data });
|
|
378
|
+
if (!revived) {
|
|
379
|
+
return error;
|
|
380
|
+
}
|
|
381
|
+
return Object.assign(revived, { message: error.message, data: error.data, stack: error.stack });
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* The error the JSON text `json` describes, as `JSON.stringify(error.toJson())`
|
|
385
|
+
* writes it, revived to its typed class as {@link reviveProtocolError} does, or
|
|
386
|
+
* `undefined` when `json` is not a JSON-RPC error envelope. For a transport
|
|
387
|
+
* that carries the error as text, such as a GLSP `RejectAction`'s `detail`.
|
|
388
|
+
*/
|
|
389
|
+
function reviveProtocolErrorJson(json) {
|
|
390
|
+
let envelope;
|
|
391
|
+
try {
|
|
392
|
+
envelope = JSON.parse(json);
|
|
393
|
+
}
|
|
394
|
+
catch {
|
|
395
|
+
return undefined;
|
|
396
|
+
}
|
|
397
|
+
if (typeof envelope !== 'object' || envelope === null || !('code' in envelope) || !('message' in envelope)) {
|
|
398
|
+
return undefined;
|
|
399
|
+
}
|
|
400
|
+
const { code, message } = envelope;
|
|
401
|
+
if (typeof code !== 'number' || !Number.isInteger(code) || typeof message !== 'string') {
|
|
402
|
+
return undefined;
|
|
403
|
+
}
|
|
404
|
+
const revived = reviveProtocolError(new vscode_jsonrpc_1.ResponseError(code, message, 'data' in envelope ? envelope.data : undefined));
|
|
405
|
+
return isResponseError(revived) ? revived : undefined;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Mark `errorClass`'s prototype with a brand its guard checks, so every
|
|
409
|
+
* instance and every subclass carries it, and nothing else does. `Symbol.for`
|
|
410
|
+
* gives each copy of this package the same symbol, which `instanceof` does
|
|
411
|
+
* not, so the key must stay the same across releases.
|
|
412
|
+
*/
|
|
413
|
+
function brand(errorClass, name) {
|
|
414
|
+
const key = Symbol.for(`hydranium/protocol/${name}`);
|
|
415
|
+
Object.defineProperty(errorClass.prototype, key, { value: true });
|
|
416
|
+
return key;
|
|
417
|
+
}
|
|
418
|
+
const CONFLICT_BRAND = brand(ConflictError, 'ConflictError');
|
|
419
|
+
const SESSION_CLOSED_BRAND = brand(SessionClosedError, 'SessionClosedError');
|
|
420
|
+
const DOCUMENT_NOT_OPEN_BRAND = brand(DocumentNotOpenError, 'DocumentNotOpenError');
|
|
421
|
+
const DUPLICATE_CLIENT_ID_BRAND = brand(DuplicateClientIdError, 'DuplicateClientIdError');
|
|
422
|
+
const RESERVED_CLIENT_ID_BRAND = brand(ReservedClientIdError, 'ReservedClientIdError');
|
|
423
|
+
const SAVE_FAILED_BRAND = brand(SaveFailedError, 'SaveFailedError');
|
|
424
|
+
const DOCUMENT_SYNTAX_ERROR_BRAND = brand(DocumentSyntaxError, 'DocumentSyntaxError');
|
|
425
|
+
/**
|
|
426
|
+
* Whether `error` is a {@link SessionClosedError} whose getters read valid
|
|
427
|
+
* fields: one thrown, or one {@link reviveProtocolError revived}, from any
|
|
428
|
+
* copy of this package, or a subclass. A bare `ResponseError` is not one,
|
|
429
|
+
* whatever its name and fields, since it lacks the class's brand.
|
|
430
|
+
* `createRpcProxy` revives every rejection, so only a caller on a connection
|
|
431
|
+
* of its own needs to revive first. Each guard below works the same way.
|
|
432
|
+
*/
|
|
433
|
+
function isSessionClosedError(error) {
|
|
434
|
+
return hasBrand(error, SESSION_CLOSED_BRAND) && hasClientId(error);
|
|
435
|
+
}
|
|
436
|
+
/** Whether `error` is a {@link DocumentNotOpenError}. See {@link isSessionClosedError}. */
|
|
437
|
+
function isDocumentNotOpenError(error) {
|
|
438
|
+
return hasBrand(error, DOCUMENT_NOT_OPEN_BRAND) && hasDocumentNotOpenFields(error);
|
|
439
|
+
}
|
|
440
|
+
/** Whether `error` is a {@link DuplicateClientIdError}. See {@link isSessionClosedError}. */
|
|
441
|
+
function isDuplicateClientIdError(error) {
|
|
442
|
+
return hasBrand(error, DUPLICATE_CLIENT_ID_BRAND) && hasClientId(error);
|
|
443
|
+
}
|
|
444
|
+
/** Whether `error` is a {@link ReservedClientIdError}. See {@link isSessionClosedError}. */
|
|
445
|
+
function isReservedClientIdError(error) {
|
|
446
|
+
return hasBrand(error, RESERVED_CLIENT_ID_BRAND) && hasClientId(error);
|
|
447
|
+
}
|
|
448
|
+
/** Whether `error` is a {@link SaveFailedError}. See {@link isSessionClosedError}. */
|
|
449
|
+
function isSaveFailedError(error) {
|
|
450
|
+
return hasBrand(error, SAVE_FAILED_BRAND) && hasSaveFailures(error);
|
|
451
|
+
}
|
|
452
|
+
/** Whether `error` is a {@link DocumentSyntaxError}. See {@link isSessionClosedError}. */
|
|
453
|
+
function isDocumentSyntaxError(error) {
|
|
454
|
+
return hasBrand(error, DOCUMENT_SYNTAX_ERROR_BRAND) && hasUri(error);
|
|
455
|
+
}
|
|
456
|
+
/** Whether `error` is a {@link ConflictError}. See {@link isSessionClosedError}. */
|
|
457
|
+
function isConflictError(error) {
|
|
458
|
+
return hasBrand(error, CONFLICT_BRAND) && hasConflictFields(error);
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Whether `error` carries the brand `key` and the `data` record its getters
|
|
462
|
+
* read, so a guard can check the fields through them. A copy whose class
|
|
463
|
+
* lacks a getter fails that check, since the brand alone is public.
|
|
464
|
+
*/
|
|
465
|
+
function hasBrand(error, key) {
|
|
466
|
+
return isResponseError(error) && Reflect.get(error, key) === true && isRecord(error.data);
|
|
122
467
|
}
|
|
123
468
|
//# sourceMappingURL=errors.js.map
|
package/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAyHlF,0CAYC;AAnID,mDAA+C;AAC/C,sDAA8F;AAE9F;;;;;;;GAOG;AACU,QAAA,kBAAkB,GAAG,IAAA,0BAAa,EAC5C,uCAAuC,EACvC,4EAA4E,CAC9E,CAAC;AAEF;;;;;;;;GAQG;AACU,QAAA,mBAAmB,GAAG,IAAI,CAAC;AAcxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAa,aAAc,SAAQ,8BAAgC;IAChE,YAAY,GAAW,EAAE,QAAgB,EAAE,MAAc;QACtD,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;QACzC,uEAAuE;QACvE,0EAA0E;QAC1E,yEAAyE;QACzE,KAAK,CAAC,2BAAmB,EAAE,0BAAkB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,IAAA,wBAAW,EAAC,0BAAkB,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;QACzH,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,iEAAiE;QACjE,0EAA0E;QAC1E,qEAAqE;QACrE,gEAAgE;QAChE,kEAAkE;QAClE,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,GAAG;QACJ,OAAO,IAAI,CAAC,IAAK,CAAC,GAAG,CAAC;IACzB,CAAC;IAED,IAAI,QAAQ;QACT,OAAO,IAAI,CAAC,IAAK,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED,IAAI,MAAM;QACP,OAAO,IAAI,CAAC,IAAK,CAA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AAE,2BAA2B,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;AACxE,CAAC;AAED,oFAAoF;AACpF,yBAAgC,KAAc;IAC3C,OAAO,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC;AAED;;;;GAIG;AACH,SAAS,QAAQ,CAAC,KAAc,EAAE,GAAW;IAC1C,OAAO,eAAe,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC7F,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 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
|
+
/** Options of {@link formatLogArg}. An object, so that a `map` index cannot be passed as one. */
|
|
10
|
+
export interface FormatLogArgOptions {
|
|
11
|
+
/** The `space` argument of `JSON.stringify`; compact where omitted. */
|
|
12
|
+
readonly indent?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Render a log argument as text for a log line:
|
|
16
|
+
* - a string as it is;
|
|
17
|
+
* - an error by its stack and causes;
|
|
18
|
+
* - another object as JSON, cut to a bounded size;
|
|
19
|
+
* - anything else by its description, as is an object JSON renders as nothing
|
|
20
|
+
* or cannot render.
|
|
21
|
+
*
|
|
22
|
+
* The cut is needed because the log call serialises synchronously and every
|
|
23
|
+
* Langium AST node is cyclic. The JSON stops at `LOG_ARG_DEPTH` levels,
|
|
24
|
+
* `LOG_ARG_ITEMS` items or keys and `LOG_ARG_STRING_LENGTH` characters per
|
|
25
|
+
* string or key, and at about `LOG_ARG_LENGTH` in all. A reference back to an
|
|
26
|
+
* object that contains it reads `[Circular]`, and a BigInt its digits; the
|
|
27
|
+
* markers are JSON strings. `util.inspect` would cut too, but is Node-only.
|
|
28
|
+
*
|
|
29
|
+
* Never throws, since a log call that throws loses the line and interrupts its
|
|
30
|
+
* caller. A `%s`-style specifier is not substituted.
|
|
31
|
+
*/
|
|
32
|
+
export declare function formatLogArg(value: unknown, options?: FormatLogArgOptions): string;
|
|
33
|
+
//# sourceMappingURL=format-log-arg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-log-arg.d.ts","sourceRoot":"","sources":["../src/format-log-arg.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAgBlF,iGAAiG;AACjG,MAAM,WAAW,mBAAmB;IACjC,uEAAuE;IACvE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,mBAAwB,GAAG,MAAM,CAiBtF"}
|