@hydranium/protocol 1.0.0-next.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +81 -0
  3. package/lib/abstract-logger.d.ts +66 -0
  4. package/lib/abstract-logger.d.ts.map +1 -0
  5. package/lib/abstract-logger.js +110 -0
  6. package/lib/abstract-logger.js.map +1 -0
  7. package/lib/browser-runtime.d.ts +124 -0
  8. package/lib/browser-runtime.d.ts.map +1 -0
  9. package/lib/browser-runtime.js +11 -0
  10. package/lib/browser-runtime.js.map +1 -0
  11. package/lib/client/data-events.d.ts +49 -0
  12. package/lib/client/data-events.d.ts.map +1 -0
  13. package/lib/client/data-events.js +60 -0
  14. package/lib/client/data-events.js.map +1 -0
  15. package/lib/client/data-port.d.ts +95 -0
  16. package/lib/client/data-port.d.ts.map +1 -0
  17. package/lib/client/data-port.js +11 -0
  18. package/lib/client/data-port.js.map +1 -0
  19. package/lib/client/data-session.d.ts +129 -0
  20. package/lib/client/data-session.d.ts.map +1 -0
  21. package/lib/client/data-session.js +179 -0
  22. package/lib/client/data-session.js.map +1 -0
  23. package/lib/client/index.d.ts +39 -0
  24. package/lib/client/index.d.ts.map +1 -0
  25. package/lib/client/index.js +55 -0
  26. package/lib/client/index.js.map +1 -0
  27. package/lib/client/message-relay.d.ts +111 -0
  28. package/lib/client/message-relay.d.ts.map +1 -0
  29. package/lib/client/message-relay.js +139 -0
  30. package/lib/client/message-relay.js.map +1 -0
  31. package/lib/client/post-message-transport.d.ts +77 -0
  32. package/lib/client/post-message-transport.d.ts.map +1 -0
  33. package/lib/client/post-message-transport.js +95 -0
  34. package/lib/client/post-message-transport.js.map +1 -0
  35. package/lib/clock.d.ts +111 -0
  36. package/lib/clock.d.ts.map +1 -0
  37. package/lib/clock.js +74 -0
  38. package/lib/clock.js.map +1 -0
  39. package/lib/data/data-protocol-methods.d.ts +39 -0
  40. package/lib/data/data-protocol-methods.d.ts.map +1 -0
  41. package/lib/data/data-protocol-methods.js +61 -0
  42. package/lib/data/data-protocol-methods.js.map +1 -0
  43. package/lib/data/data-server-protocol.d.ts +264 -0
  44. package/lib/data/data-server-protocol.d.ts.map +1 -0
  45. package/lib/data/data-server-protocol.js +11 -0
  46. package/lib/data/data-server-protocol.js.map +1 -0
  47. package/lib/data/diagnostics.d.ts +97 -0
  48. package/lib/data/diagnostics.d.ts.map +1 -0
  49. package/lib/data/diagnostics.js +25 -0
  50. package/lib/data/diagnostics.js.map +1 -0
  51. package/lib/data/events.d.ts +107 -0
  52. package/lib/data/events.d.ts.map +1 -0
  53. package/lib/data/events.js +11 -0
  54. package/lib/data/events.js.map +1 -0
  55. package/lib/data/index.d.ts +15 -0
  56. package/lib/data/index.d.ts.map +1 -0
  57. package/lib/data/index.js +38 -0
  58. package/lib/data/index.js.map +1 -0
  59. package/lib/data/methods.d.ts +57 -0
  60. package/lib/data/methods.d.ts.map +1 -0
  61. package/lib/data/methods.js +60 -0
  62. package/lib/data/methods.js.map +1 -0
  63. package/lib/data/requests.d.ts +65 -0
  64. package/lib/data/requests.d.ts.map +1 -0
  65. package/lib/data/requests.js +11 -0
  66. package/lib/data/requests.js.map +1 -0
  67. package/lib/debouncer.d.ts +75 -0
  68. package/lib/debouncer.d.ts.map +1 -0
  69. package/lib/debouncer.js +91 -0
  70. package/lib/debouncer.js.map +1 -0
  71. package/lib/errors.d.ts +84 -0
  72. package/lib/errors.d.ts.map +1 -0
  73. package/lib/errors.js +113 -0
  74. package/lib/errors.js.map +1 -0
  75. package/lib/host-diagnostics.d.ts +58 -0
  76. package/lib/host-diagnostics.d.ts.map +1 -0
  77. package/lib/host-diagnostics.js +18 -0
  78. package/lib/host-diagnostics.js.map +1 -0
  79. package/lib/index.d.ts +34 -0
  80. package/lib/index.d.ts.map +1 -0
  81. package/lib/index.js +56 -0
  82. package/lib/index.js.map +1 -0
  83. package/lib/latency-collector.d.ts +126 -0
  84. package/lib/latency-collector.d.ts.map +1 -0
  85. package/lib/latency-collector.js +137 -0
  86. package/lib/latency-collector.js.map +1 -0
  87. package/lib/logger.d.ts +119 -0
  88. package/lib/logger.d.ts.map +1 -0
  89. package/lib/logger.js +126 -0
  90. package/lib/logger.js.map +1 -0
  91. package/lib/model-server.d.ts +352 -0
  92. package/lib/model-server.d.ts.map +1 -0
  93. package/lib/model-server.js +160 -0
  94. package/lib/model-server.js.map +1 -0
  95. package/lib/model-service/args.d.ts +64 -0
  96. package/lib/model-service/args.d.ts.map +1 -0
  97. package/lib/model-service/args.js +11 -0
  98. package/lib/model-service/args.js.map +1 -0
  99. package/lib/model-service/index.d.ts +11 -0
  100. package/lib/model-service/index.d.ts.map +1 -0
  101. package/lib/model-service/index.js +31 -0
  102. package/lib/model-service/index.js.map +1 -0
  103. package/lib/model-service/reference-candidate.d.ts +56 -0
  104. package/lib/model-service/reference-candidate.d.ts.map +1 -0
  105. package/lib/model-service/reference-candidate.js +11 -0
  106. package/lib/model-service/reference-candidate.js.map +1 -0
  107. package/lib/noop-logger.d.ts +25 -0
  108. package/lib/noop-logger.d.ts.map +1 -0
  109. package/lib/noop-logger.js +36 -0
  110. package/lib/noop-logger.js.map +1 -0
  111. package/lib/observable-value.d.ts +72 -0
  112. package/lib/observable-value.d.ts.map +1 -0
  113. package/lib/observable-value.js +52 -0
  114. package/lib/observable-value.js.map +1 -0
  115. package/lib/patch-merge.d.ts +123 -0
  116. package/lib/patch-merge.d.ts.map +1 -0
  117. package/lib/patch-merge.js +104 -0
  118. package/lib/patch-merge.js.map +1 -0
  119. package/lib/profile-session.d.ts +87 -0
  120. package/lib/profile-session.d.ts.map +1 -0
  121. package/lib/profile-session.js +98 -0
  122. package/lib/profile-session.js.map +1 -0
  123. package/lib/profiling.d.ts +83 -0
  124. package/lib/profiling.d.ts.map +1 -0
  125. package/lib/profiling.js +20 -0
  126. package/lib/profiling.js.map +1 -0
  127. package/lib/project.d.ts +121 -0
  128. package/lib/project.d.ts.map +1 -0
  129. package/lib/project.js +34 -0
  130. package/lib/project.js.map +1 -0
  131. package/lib/rpc/bind-rpc-methods.d.ts +100 -0
  132. package/lib/rpc/bind-rpc-methods.d.ts.map +1 -0
  133. package/lib/rpc/bind-rpc-methods.js +110 -0
  134. package/lib/rpc/bind-rpc-methods.js.map +1 -0
  135. package/lib/rpc/create-rpc-proxy.d.ts +188 -0
  136. package/lib/rpc/create-rpc-proxy.d.ts.map +1 -0
  137. package/lib/rpc/create-rpc-proxy.js +158 -0
  138. package/lib/rpc/create-rpc-proxy.js.map +1 -0
  139. package/lib/rpc/index.d.ts +12 -0
  140. package/lib/rpc/index.d.ts.map +1 -0
  141. package/lib/rpc/index.js +31 -0
  142. package/lib/rpc/index.js.map +1 -0
  143. package/lib/rpc/wire-prefix.d.ts +37 -0
  144. package/lib/rpc/wire-prefix.d.ts.map +1 -0
  145. package/lib/rpc/wire-prefix.js +49 -0
  146. package/lib/rpc/wire-prefix.js.map +1 -0
  147. package/lib/testing/data-doubles.d.ts +121 -0
  148. package/lib/testing/data-doubles.d.ts.map +1 -0
  149. package/lib/testing/data-doubles.js +102 -0
  150. package/lib/testing/data-doubles.js.map +1 -0
  151. package/lib/testing/fake-clock.d.ts +35 -0
  152. package/lib/testing/fake-clock.d.ts.map +1 -0
  153. package/lib/testing/fake-clock.js +86 -0
  154. package/lib/testing/fake-clock.js.map +1 -0
  155. package/lib/testing/harness.d.ts +24 -0
  156. package/lib/testing/harness.d.ts.map +1 -0
  157. package/lib/testing/harness.js +11 -0
  158. package/lib/testing/harness.js.map +1 -0
  159. package/lib/testing/index.d.ts +13 -0
  160. package/lib/testing/index.d.ts.map +1 -0
  161. package/lib/testing/index.js +41 -0
  162. package/lib/testing/index.js.map +1 -0
  163. package/lib/testing/node/duplex-connection.d.ts +25 -0
  164. package/lib/testing/node/duplex-connection.d.ts.map +1 -0
  165. package/lib/testing/node/duplex-connection.js +34 -0
  166. package/lib/testing/node/duplex-connection.js.map +1 -0
  167. package/lib/testing/node/duplex-stream.d.ts +32 -0
  168. package/lib/testing/node/duplex-stream.d.ts.map +1 -0
  169. package/lib/testing/node/duplex-stream.js +35 -0
  170. package/lib/testing/node/duplex-stream.js.map +1 -0
  171. package/lib/testing/node/index.d.ts +11 -0
  172. package/lib/testing/node/index.d.ts.map +1 -0
  173. package/lib/testing/node/index.js +37 -0
  174. package/lib/testing/node/index.js.map +1 -0
  175. package/lib/testing/wait-for.d.ts +69 -0
  176. package/lib/testing/wait-for.d.ts.map +1 -0
  177. package/lib/testing/wait-for.js +67 -0
  178. package/lib/testing/wait-for.js.map +1 -0
  179. package/lib/tracer.d.ts +115 -0
  180. package/lib/tracer.d.ts.map +1 -0
  181. package/lib/tracer.js +205 -0
  182. package/lib/tracer.js.map +1 -0
  183. package/lib/transfer-diagnostic.d.ts +73 -0
  184. package/lib/transfer-diagnostic.d.ts.map +1 -0
  185. package/lib/transfer-diagnostic.js +45 -0
  186. package/lib/transfer-diagnostic.js.map +1 -0
  187. package/lib/transfer-document.d.ts +73 -0
  188. package/lib/transfer-document.d.ts.map +1 -0
  189. package/lib/transfer-document.js +46 -0
  190. package/lib/transfer-document.js.map +1 -0
  191. package/lib/transfer-element.d.ts +39 -0
  192. package/lib/transfer-element.d.ts.map +1 -0
  193. package/lib/transfer-element.js +11 -0
  194. package/lib/transfer-element.js.map +1 -0
  195. package/lib/uri.d.ts +62 -0
  196. package/lib/uri.d.ts.map +1 -0
  197. package/lib/uri.js +28 -0
  198. package/lib/uri.js.map +1 -0
  199. package/lib/util.d.ts +147 -0
  200. package/lib/util.d.ts.map +1 -0
  201. package/lib/util.js +211 -0
  202. package/lib/util.js.map +1 -0
  203. package/package.json +100 -0
  204. package/src/abstract-logger.ts +120 -0
  205. package/src/browser-runtime.ts +135 -0
  206. package/src/client/data-events.ts +71 -0
  207. package/src/client/data-port.ts +99 -0
  208. package/src/client/data-session.ts +209 -0
  209. package/src/client/index.ts +40 -0
  210. package/src/client/message-relay.ts +216 -0
  211. package/src/client/post-message-transport.ts +167 -0
  212. package/src/clock.ts +173 -0
  213. package/src/data/data-protocol-methods.ts +79 -0
  214. package/src/data/data-server-protocol.ts +296 -0
  215. package/src/data/diagnostics.ts +116 -0
  216. package/src/data/events.ts +127 -0
  217. package/src/data/index.ts +23 -0
  218. package/src/data/methods.ts +59 -0
  219. package/src/data/requests.ts +70 -0
  220. package/src/debouncer.ts +118 -0
  221. package/src/errors.ts +127 -0
  222. package/src/host-diagnostics.ts +63 -0
  223. package/src/index.ts +41 -0
  224. package/src/latency-collector.ts +231 -0
  225. package/src/logger.ts +172 -0
  226. package/src/model-server.ts +479 -0
  227. package/src/model-service/args.ts +67 -0
  228. package/src/model-service/index.ts +16 -0
  229. package/src/model-service/reference-candidate.ts +58 -0
  230. package/src/noop-logger.ts +36 -0
  231. package/src/observable-value.ts +92 -0
  232. package/src/patch-merge.ts +165 -0
  233. package/src/profile-session.ts +164 -0
  234. package/src/profiling.ts +113 -0
  235. package/src/project.ts +125 -0
  236. package/src/rpc/README.md +163 -0
  237. package/src/rpc/bind-rpc-methods.ts +180 -0
  238. package/src/rpc/create-rpc-proxy.ts +292 -0
  239. package/src/rpc/index.ts +16 -0
  240. package/src/rpc/wire-prefix.ts +48 -0
  241. package/src/testing/data-doubles.ts +178 -0
  242. package/src/testing/fake-clock.ts +106 -0
  243. package/src/testing/harness.ts +24 -0
  244. package/src/testing/index.ts +26 -0
  245. package/src/testing/node/duplex-connection.ts +50 -0
  246. package/src/testing/node/duplex-stream.ts +51 -0
  247. package/src/testing/node/index.ts +22 -0
  248. package/src/testing/wait-for.ts +94 -0
  249. package/src/tracer.ts +277 -0
  250. package/src/transfer-diagnostic.ts +92 -0
  251. package/src/transfer-document.ts +99 -0
  252. package/src/transfer-element.ts +43 -0
  253. package/src/uri.ts +61 -0
  254. package/src/util.ts +250 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AA0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AC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IAC3E,CAAC;IAFe,cAAO,UAEtB,CAAA;IAED,6EAA6E;IAC7E,SAAgB,KAAK,CAAC,KAAa;QAChC,IAAI,KAAK,GAAG,IAAI,EAAE,CAAC;YAChB,OAAO,GAAG,KAAK,GAAG,CAAC;QACtB,CAAC;QACD,MAAM,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACvC,IAAI,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC;QACzB,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,OAAO,KAAK,IAAI,IAAI,IAAI,IAAI,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/C,KAAK,IAAI,IAAI,CAAC;YACd,IAAI,EAAE,CAAC;QACV,CAAC;QACD,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;IACnF,CAAC;IAZe,YAAK,QAYpB,CAAA;AACJ,CAAC,EA7BgB,MAAM,sBAAN,MAAM,QA6BtB"}
@@ -0,0 +1,352 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2023 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
+ * Generic model-server protocol types: lifecycle arguments, events, and
11
+ * cross-reference shapes. Free of any specific grammar, AST type, or
12
+ * language identifier — consumers parameterise the document/root types
13
+ * over `TRoot`.
14
+ */
15
+ import type { TransferClientArgs } from './model-service/args';
16
+ import type { ReferenceCandidate } from './model-service/reference-candidate';
17
+ /** Open a document on behalf of a client. */
18
+ export interface OpenModelArgs extends TransferClientArgs {
19
+ /**
20
+ * Overrides the language the URI's extension would resolve to. Supply it
21
+ * only when the extension does not decide — an unregistered extension, or a
22
+ * document being opened under a language other than its own. A wrong value
23
+ * routes the document to the wrong grammar and it parses as garbage rather
24
+ * than failing.
25
+ */
26
+ languageId?: string;
27
+ /**
28
+ * Seeds the shared version sequence, defaulting to `0`. Only the FIRST open
29
+ * of a URI consumes it; after that the server owns the sequence and advances
30
+ * it itself, so callers never fabricate later numbers.
31
+ */
32
+ version?: number;
33
+ /**
34
+ * Content to open the document with instead of reading the file. Absent
35
+ * means read from the filesystem, which is the normal case.
36
+ *
37
+ * Honoured only on the first open of a URI: opening an already-open document
38
+ * is a no-op, so passing `text` for one silently changes nothing. Write
39
+ * through the update path instead.
40
+ */
41
+ text?: string;
42
+ }
43
+ /** Close a previously-opened document for the client. */
44
+ export interface CloseModelArgs extends TransferClientArgs {
45
+ }
46
+ export interface TransferUpdatedEvent<TDocument> {
47
+ document: TDocument;
48
+ sourceClientId: string;
49
+ /** See `ModelDocumentUpdateReason` in `./data/events` for the canonical reason set + semantics. */
50
+ reason: 'changed' | 'deleted' | 'rebuilt' | 'saved';
51
+ }
52
+ export interface TransferSavedEvent<TDocument> {
53
+ /** The document as persisted — the state that reached disk, not the state at request time. */
54
+ document: TDocument;
55
+ /**
56
+ * The client whose save produced this. Every co-editing client receives the
57
+ * event including the originator, so a recipient compares it against its own
58
+ * id to recognise its own echo; acting on that echo is how an update loop
59
+ * starts.
60
+ */
61
+ sourceClientId: string;
62
+ }
63
+ /**
64
+ * The source-side address for a reference query: where the lookup is asked
65
+ * from. One of three shapes — a {@link DocumentSource} (the root of a
66
+ * document at the given URI), an {@link ElementSource} (an element resolved
67
+ * by its qualified name), or a {@link SyntheticSource} (a transient
68
+ * element that does not yet exist on disk, used during element-creation
69
+ * flows).
70
+ *
71
+ * Construct via the {@link ReferenceSource} namespace factories
72
+ * (`ReferenceSource.document(uri)` / `.element(name, type?)` /
73
+ * `.synthetic(uri, type)`) rather than tag-field literals — the factories
74
+ * surface the three variants via autocomplete and centralise any future
75
+ * shape changes.
76
+ */
77
+ export type ReferenceSource = DocumentSource | ElementSource | SyntheticSource;
78
+ /** A reference anchored at the root element of a document, identified by URI. */
79
+ export interface DocumentSource {
80
+ uri: string;
81
+ }
82
+ /**
83
+ * Narrow an unknown value to a {@link DocumentSource}. Not exclusive within
84
+ * {@link ReferenceSource}: a {@link SyntheticSource} also carries `uri`, so
85
+ * discriminating the union must try {@link isSyntheticSource} first.
86
+ */
87
+ export declare function isDocumentSource(object: unknown): object is DocumentSource;
88
+ /**
89
+ * A reference to an element identified by its **qualified name**, optionally
90
+ * narrowed by type.
91
+ *
92
+ * The name is the form a source-text writer would type — normally the
93
+ * project-qualified name (see `NameProvider.getProjectQualifiedName`). It is
94
+ * **not** rename-stable and is distinct from an element *key*: rename the
95
+ * element and this address changes. Clients that need a handle surviving
96
+ * renames address the element some other way; this shape addresses by name.
97
+ */
98
+ export interface ElementSource {
99
+ /**
100
+ * The qualified name as a source-text writer would spell it — normally the
101
+ * project-qualified form. Resolution is by exact match against the index, so
102
+ * a partially-qualified or differently-cased spelling simply finds nothing
103
+ * rather than falling back to a looser search.
104
+ */
105
+ name: string;
106
+ /**
107
+ * Disambiguates when one name is claimed by several AST types. Absent means
108
+ * "any type", which for an ambiguous name resolves arbitrarily rather than
109
+ * failing — pass it whenever the caller knows what it is addressing.
110
+ */
111
+ type?: string;
112
+ }
113
+ export declare function isElementSource(object: unknown): object is ElementSource;
114
+ /** An element of a document that does not yet exist on disk — used during element creation flows. */
115
+ export interface SyntheticSource {
116
+ /**
117
+ * The document the element would belong to. That document must already be
118
+ * LOADED — the default resolution takes its parse root as the synthetic
119
+ * node's container and answers `undefined` when it is not, so a URI for a
120
+ * file that exists on disk but was never opened resolves to nothing.
121
+ */
122
+ uri: string;
123
+ /**
124
+ * The AST type the element will have. Required here, unlike on an
125
+ * {@link ElementSource}, because no node exists yet from which to infer it —
126
+ * it is what scoping filters candidates against.
127
+ */
128
+ type: string;
129
+ }
130
+ export declare function isSyntheticSource(object: unknown): object is SyntheticSource;
131
+ /**
132
+ * Factory helpers for the {@link ReferenceSource} variants. Use instead of
133
+ * tag-field literals so a future shape change lands in one place.
134
+ */
135
+ export declare namespace ReferenceSource {
136
+ function document(uri: string): DocumentSource;
137
+ function element(name: string, type?: string): ElementSource;
138
+ function synthetic(uri: string, type: string): SyntheticSource;
139
+ }
140
+ /**
141
+ * One step in a synthetic navigation path from a {@link ReferenceSource}
142
+ * toward the property whose references we want to query. Each step describes
143
+ * a transient AST node that does not yet exist in the document — e.g. an
144
+ * element being created via UI flow — and is spliced into the chain so the
145
+ * scope provider sees the world *as if* the synthetic child were already
146
+ * placed at that slot.
147
+ *
148
+ * The field names mirror Langium's `$type` / `$containerProperty` so adopter
149
+ * callsites read consistently with AST-side code.
150
+ *
151
+ * Construct via {@link SyntheticStep.of} rather than a tag-field literal.
152
+ */
153
+ export interface SyntheticStep {
154
+ /**
155
+ * The AST `$type` the spliced node claims. Scoping filters candidates
156
+ * against it, so a type the grammar does not declare yields an empty scope
157
+ * rather than an error.
158
+ */
159
+ type: string;
160
+ /**
161
+ * The containment slot on the parent step, or on the source for the first
162
+ * step. It must name a real containment property of that parent: the walk
163
+ * builds the node unconditionally, so a wrong slot produces a plausible node
164
+ * in a place the grammar has no rule for, and the emptiness surfaces later
165
+ * as "no candidates".
166
+ */
167
+ containerProperty: string;
168
+ /**
169
+ * Which element of an array-valued {@link containerProperty} the step
170
+ * addresses. **Mandatory for an array slot** on the resolving read
171
+ * (`ScopeProvider.resolveReferenceSource` given a whole context), which
172
+ * stops rather than descend into the array itself; a scope query reads it
173
+ * only as the stub's `$containerIndex`, since a fabricated node has no
174
+ * siblings to sit between.
175
+ *
176
+ * Absent means the slot holds a single node. Naming an out-of-range element
177
+ * resolves to nothing rather than failing.
178
+ */
179
+ index?: number;
180
+ }
181
+ /**
182
+ * Narrow an unknown value to a {@link SyntheticStep} — for a consumer
183
+ * validating a step that arrived over the wire. Framework code builds steps
184
+ * through {@link SyntheticStep.of} and never needs the check, so the absent
185
+ * in-repo caller is the seam working rather than unused surface.
186
+ */
187
+ export declare function isSyntheticStep(object: unknown): object is SyntheticStep;
188
+ export declare namespace SyntheticStep {
189
+ /**
190
+ * Construct a single {@link SyntheticStep} — "which slot of the parent, of
191
+ * which AST type". Pass `index` to pin the step to an existing array
192
+ * element instead of a transient synthetic node.
193
+ */
194
+ function of(containerProperty: string, type: string, index?: number): SyntheticStep;
195
+ /**
196
+ * Construct a sequence of {@link SyntheticStep}s from `(containerProperty,
197
+ * type)` tuples. Convenience for 3+ step paths where repeating
198
+ * `SyntheticStep.of(...)` per entry is visually noisy. For 1-2 step paths
199
+ * the per-step factory typically reads more clearly.
200
+ */
201
+ function chain(...steps: ReadonlyArray<Parameters<typeof of>>): SyntheticStep[];
202
+ }
203
+ /**
204
+ * Describes the question "what reachable elements are valid for this property
205
+ * of this (possibly synthetic) source-side element?". The server resolves it
206
+ * to a list of reference candidates ({@link ReferenceCandidate} in
207
+ * `@hydranium/protocol/model-service`).
208
+ *
209
+ * Build via {@link ReferenceContext.builder} — the staged builder enforces
210
+ * the `source -> path -> property` order at compile time.
211
+ */
212
+ export interface ReferenceContext {
213
+ /** Where the query originates — the source-side {@link ReferenceSource} the lookup is anchored at. */
214
+ source: ReferenceSource;
215
+ /**
216
+ * Synthetic navigation path from the source toward the leaf whose
217
+ * references we want. Each entry is a transient AST node spliced into
218
+ * the navigation chain — useful for elements that are being created or
219
+ * that cannot yet be identified canonically. Empty / absent for queries
220
+ * whose source IS the leaf.
221
+ */
222
+ syntheticPath?: SyntheticStep[];
223
+ /**
224
+ * The property of the leaf element (final step in {@link syntheticPath},
225
+ * or the source when the path is empty) whose reachable references we
226
+ * want to retrieve.
227
+ */
228
+ property: string;
229
+ }
230
+ /**
231
+ * Narrow a value to a {@link ReferenceContext}, discriminating it from a bare
232
+ * {@link ReferenceSource}. No source variant carries either `source` or
233
+ * `property`, so the pair is unambiguous — which is what lets one resolver
234
+ * accept both an anchor and a whole context.
235
+ */
236
+ export declare function isReferenceContext(object: unknown): object is ReferenceContext;
237
+ /**
238
+ * A concrete reference-resolution request: a {@link ReferenceContext} plus the
239
+ * written value to resolve. Extending the context makes resolution literally
240
+ * "the candidate query, narrowed to one value" — and a request carries a
241
+ * `syntheticPath` for free, so a reference anchored at a nested synthetic
242
+ * source resolves the same way it lists candidates.
243
+ *
244
+ * Build via {@link ReferenceRequest.builder} — same staged order as
245
+ * {@link ReferenceContext.builder}, ending with a mandatory `value`.
246
+ */
247
+ export interface ReferenceRequest extends ReferenceContext {
248
+ /** The textual value (the `$refText`) of the reference we are resolving. */
249
+ value: string;
250
+ }
251
+ /**
252
+ * First builder stage: pick the {@link ReferenceSource} variant. Generic over
253
+ * the stage that `property()` lands on, so the context and request builders
254
+ * share the source/path stages and differ only at the terminal.
255
+ */
256
+ export interface ReferenceSourceStage<TAfterProperty> {
257
+ /** Anchor at the semantic root of a loaded document — a {@link DocumentSource}. */
258
+ document(uri: string): ReferencePathStage<TAfterProperty>;
259
+ /** Anchor at an element addressed by qualified name — an {@link ElementSource}. */
260
+ element(name: string, type?: string): ReferencePathStage<TAfterProperty>;
261
+ /** Anchor at an element that does not exist yet — a {@link SyntheticSource}. */
262
+ synthetic(uri: string, type: string): ReferencePathStage<TAfterProperty>;
263
+ }
264
+ /**
265
+ * Second builder stage: append synthetic {@link SyntheticStep}s (repeatable,
266
+ * optional), then close on the leaf property. `step()` is unavailable after
267
+ * `property()`, which enforces the `source -> path -> property` order.
268
+ */
269
+ export interface ReferencePathStage<TAfterProperty> {
270
+ /**
271
+ * Append one {@link SyntheticStep}, outermost first, and return a new stage
272
+ * carrying the extended path. The builder is persistent, so a stage held in
273
+ * a variable is a reusable prefix: stepping off it twice builds two paths,
274
+ * and neither can be changed afterwards by the other.
275
+ */
276
+ step(containerProperty: string, type: string, index?: number): ReferencePathStage<TAfterProperty>;
277
+ /** Name the leaf property and close the builder. */
278
+ property(property: string): TAfterProperty;
279
+ }
280
+ /** Context terminal — `property()` closed the chain; build the context. */
281
+ export interface ReferenceContextBuildStage {
282
+ build(): ReferenceContext;
283
+ }
284
+ /** Request value stage — the value is mandatory before {@link ReferenceRequestBuildStage.build}. */
285
+ export interface ReferenceRequestValueStage {
286
+ value(value: string): ReferenceRequestBuildStage;
287
+ }
288
+ /** Request terminal — build the request. */
289
+ export interface ReferenceRequestBuildStage {
290
+ build(): ReferenceRequest;
291
+ }
292
+ export declare namespace ReferenceContext {
293
+ /** Staged builder entry — `source -> path -> property -> build`. */
294
+ function builder(): ReferenceSourceStage<ReferenceContextBuildStage>;
295
+ }
296
+ export declare namespace ReferenceRequest {
297
+ /** Staged builder entry — `source -> path -> property -> value -> build`. */
298
+ function builder(): ReferenceSourceStage<ReferenceRequestValueStage>;
299
+ /**
300
+ * Promote a {@link ReferenceContext} to a request using a selected
301
+ * candidate's value — the find -> select -> resolve flow. The candidate
302
+ * supplies only the value (it is target-side); the source / property /
303
+ * synthetic path come from the context the candidates were listed for.
304
+ * Accepts any {@link ReferenceCandidate} (a `ReferenceTarget` works too).
305
+ */
306
+ function from(context: ReferenceContext, candidate: ReferenceCandidate): ReferenceRequest;
307
+ }
308
+ /**
309
+ * Naming tier for `findNextName`-style lookups — which uniqueness
310
+ * scope a proposed name must be unique within. This is NOT the
311
+ * name-qualification axis, which decides how a name is spelled; the two are
312
+ * independent even though each spells two of its members `local` and
313
+ * `project`, and conflating them reads as an argument to rename `tier`.
314
+ *
315
+ * - `'local'` — unique within the document (the document root is the
316
+ * uniqueness container).
317
+ * - `'project'` — unique within the owning project's document-qualified
318
+ * namespace.
319
+ * - `'public'` — unique within the project-qualified (cross-project)
320
+ * namespace.
321
+ */
322
+ export type NameTier = 'local' | 'project' | 'public';
323
+ /** Arguments for a next-free-name lookup. */
324
+ export interface FindNextNameArgs {
325
+ /**
326
+ * Locates the document, and via its project the qualification context. The
327
+ * create-element flow is the main caller, so this may name a document that
328
+ * does not exist yet; only the `'local'` tier needs it to resolve to one.
329
+ */
330
+ uri: string;
331
+ /**
332
+ * The AST `$type` of the element being named. Collisions are only looked for
333
+ * among elements of that same type, so the returned name may still be taken
334
+ * by an element of another type.
335
+ */
336
+ type: string;
337
+ /**
338
+ * The desired base name, returned unchanged when it is already free and
339
+ * otherwise used as the stem a suffix is appended to. Any occurrence of the
340
+ * name separator is replaced first, so a proposal cannot smuggle in a
341
+ * qualified name.
342
+ */
343
+ proposal: string;
344
+ /**
345
+ * Which uniqueness scope the returned name must be free in — how wide a net
346
+ * to check for collisions. The result is always a bare own-name whatever the
347
+ * tier; this never changes how the name is spelled. Defaults to `'project'`.
348
+ * See {@link NameTier} for what each tier covers.
349
+ */
350
+ tier?: NameTier;
351
+ }
352
+ //# sourceMappingURL=model-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-server.d.ts","sourceRoot":"","sources":["../src/model-server.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAW9E,6CAA6C;AAC7C,MAAM,WAAW,aAAc,SAAQ,kBAAkB;IACtD;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,yDAAyD;AAEzD,MAAM,WAAW,cAAe,SAAQ,kBAAkB;CAAG;AAM7D,MAAM,WAAW,oBAAoB,CAAC,SAAS;IAC5C,QAAQ,EAAE,SAAS,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,mGAAmG;IACnG,MAAM,EAA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B;;;;;OAKG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;CAClB"}
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ /********************************************************************************
3
+ * Copyright (c) 2023 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.ReferenceRequest = exports.ReferenceContext = exports.SyntheticStep = exports.ReferenceSource = void 0;
12
+ exports.isDocumentSource = isDocumentSource;
13
+ exports.isElementSource = isElementSource;
14
+ exports.isSyntheticSource = isSyntheticSource;
15
+ exports.isSyntheticStep = isSyntheticStep;
16
+ exports.isReferenceContext = isReferenceContext;
17
+ /**
18
+ * Narrow an unknown value to a {@link DocumentSource}. Not exclusive within
19
+ * {@link ReferenceSource}: a {@link SyntheticSource} also carries `uri`, so
20
+ * discriminating the union must try {@link isSyntheticSource} first.
21
+ */
22
+ function isDocumentSource(object) {
23
+ return !!object && typeof object === 'object' && 'uri' in object && typeof object.uri === 'string';
24
+ }
25
+ function isElementSource(object) {
26
+ return !!object && typeof object === 'object' && 'name' in object && typeof object.name === 'string';
27
+ }
28
+ function isSyntheticSource(object) {
29
+ return (!!object &&
30
+ typeof object === 'object' &&
31
+ 'uri' in object &&
32
+ typeof object.uri === 'string' &&
33
+ 'type' in object &&
34
+ typeof object.type === 'string');
35
+ }
36
+ /**
37
+ * Factory helpers for the {@link ReferenceSource} variants. Use instead of
38
+ * tag-field literals so a future shape change lands in one place.
39
+ */
40
+ var ReferenceSource;
41
+ (function (ReferenceSource) {
42
+ function document(uri) {
43
+ return { uri };
44
+ }
45
+ ReferenceSource.document = document;
46
+ function element(name, type) {
47
+ return { name, type };
48
+ }
49
+ ReferenceSource.element = element;
50
+ function synthetic(uri, type) {
51
+ return { uri, type };
52
+ }
53
+ ReferenceSource.synthetic = synthetic;
54
+ })(ReferenceSource || (exports.ReferenceSource = ReferenceSource = {}));
55
+ /**
56
+ * Narrow an unknown value to a {@link SyntheticStep} — for a consumer
57
+ * validating a step that arrived over the wire. Framework code builds steps
58
+ * through {@link SyntheticStep.of} and never needs the check, so the absent
59
+ * in-repo caller is the seam working rather than unused surface.
60
+ */
61
+ function isSyntheticStep(object) {
62
+ return (!!object &&
63
+ typeof object === 'object' &&
64
+ 'type' in object &&
65
+ typeof object.type === 'string' &&
66
+ 'containerProperty' in object &&
67
+ typeof object.containerProperty === 'string');
68
+ }
69
+ var SyntheticStep;
70
+ (function (SyntheticStep) {
71
+ /**
72
+ * Construct a single {@link SyntheticStep} — "which slot of the parent, of
73
+ * which AST type". Pass `index` to pin the step to an existing array
74
+ * element instead of a transient synthetic node.
75
+ */
76
+ function of(containerProperty, type, index) {
77
+ return { containerProperty, type, index };
78
+ }
79
+ SyntheticStep.of = of;
80
+ /**
81
+ * Construct a sequence of {@link SyntheticStep}s from `(containerProperty,
82
+ * type)` tuples. Convenience for 3+ step paths where repeating
83
+ * `SyntheticStep.of(...)` per entry is visually noisy. For 1-2 step paths
84
+ * the per-step factory typically reads more clearly.
85
+ */
86
+ function chain(...steps) {
87
+ return steps.map(step => of(...step));
88
+ }
89
+ SyntheticStep.chain = chain;
90
+ })(SyntheticStep || (exports.SyntheticStep = SyntheticStep = {}));
91
+ /**
92
+ * Narrow a value to a {@link ReferenceContext}, discriminating it from a bare
93
+ * {@link ReferenceSource}. No source variant carries either `source` or
94
+ * `property`, so the pair is unambiguous — which is what lets one resolver
95
+ * accept both an anchor and a whole context.
96
+ */
97
+ function isReferenceContext(object) {
98
+ return (!!object &&
99
+ typeof object === 'object' &&
100
+ 'source' in object &&
101
+ 'property' in object &&
102
+ typeof object.property === 'string');
103
+ }
104
+ /**
105
+ * Shared builder engine for both reference builders. Accumulates the source
106
+ * and the synthetic path, then hands the assembled {@link ReferenceContext} to
107
+ * `onProperty`, which produces the builder-specific terminal stage.
108
+ *
109
+ * **Persistent, not accumulating.** Each `step()` returns a NEW stage over a
110
+ * copied path, and `property()` copies again into the context it emits. A
111
+ * mutable builder would make a held stage a shared cursor — two branches off it
112
+ * would build one path between them, and two contexts built from it would alias
113
+ * a single array that a later `step()` could still change underneath both.
114
+ * Copying a path of two or three entries costs nothing next to a scope query.
115
+ */
116
+ function referenceBuilder(onProperty) {
117
+ const pathStageFor = (source, steps) => ({
118
+ step(containerProperty, type, index) {
119
+ return pathStageFor(source, [...steps, { containerProperty, type, index }]);
120
+ },
121
+ property(property) {
122
+ return onProperty(steps.length > 0 ? { source, property, syntheticPath: [...steps] } : { source, property });
123
+ }
124
+ });
125
+ return {
126
+ document: uri => pathStageFor({ uri }, []),
127
+ element: (name, type) => pathStageFor({ name, type }, []),
128
+ synthetic: (uri, type) => pathStageFor({ uri, type }, [])
129
+ };
130
+ }
131
+ var ReferenceContext;
132
+ (function (ReferenceContext) {
133
+ /** Staged builder entry — `source -> path -> property -> build`. */
134
+ function builder() {
135
+ return referenceBuilder(context => ({ build: () => context }));
136
+ }
137
+ ReferenceContext.builder = builder;
138
+ })(ReferenceContext || (exports.ReferenceContext = ReferenceContext = {}));
139
+ var ReferenceRequest;
140
+ (function (ReferenceRequest) {
141
+ /** Staged builder entry — `source -> path -> property -> value -> build`. */
142
+ function builder() {
143
+ return referenceBuilder(context => ({
144
+ value: (value) => ({ build: () => ({ ...context, value }) })
145
+ }));
146
+ }
147
+ ReferenceRequest.builder = builder;
148
+ /**
149
+ * Promote a {@link ReferenceContext} to a request using a selected
150
+ * candidate's value — the find -> select -> resolve flow. The candidate
151
+ * supplies only the value (it is target-side); the source / property /
152
+ * synthetic path come from the context the candidates were listed for.
153
+ * Accepts any {@link ReferenceCandidate} (a `ReferenceTarget` works too).
154
+ */
155
+ function from(context, candidate) {
156
+ return { ...context, value: candidate.value };
157
+ }
158
+ ReferenceRequest.from = from;
159
+ })(ReferenceRequest || (exports.ReferenceRequest = ReferenceRequest = {}));
160
+ //# sourceMappingURL=model-server.js.map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EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;SACtE,CAAC,CAAC,CAAC;IACP,CAAC;IAJe,wBAAO,UAItB,CAAA;IAED;;;;;;OAMG;IACH,SAAgB,IAAI,CAAC,OAAyB,EAAE,SAA6B;QAC1E,OAAO,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC;IACjD,CAAC;IAFe,qBAAI,OAEnB,CAAA;AACJ,CAAC,EAlBgB,gBAAgB,gCAAhB,gBAAgB,QAkBhC"}
@@ -0,0 +1,64 @@
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
+ * Argument shapes for the in-process `ModelService` facade — the
11
+ * canonical home for the lifecycle operation signatures. Implementation
12
+ * lives in `@hydranium/core/langium/model-service`; this protocol
13
+ * package owns the types so wire-side projections (the data-server
14
+ * protocol in `./data`) can structurally extend them rather than
15
+ * mirroring them by hand.
16
+ *
17
+ * `./model-server.ts` re-exports them, so an import from either path
18
+ * resolves.
19
+ */
20
+ /** Identifies a client-document binding. Every facade operation carries these fields. */
21
+ export interface TransferClientArgs {
22
+ /** Document URI. */
23
+ uri: string;
24
+ /** Stable identifier for the client invoking the operation. */
25
+ clientId: string;
26
+ }
27
+ /**
28
+ * Update a document's content via the in-process facade. `model` may be
29
+ * the structured (transfer-model or AST) root or its serialised textual
30
+ * form — implementations decide which is faster on their transport.
31
+ * Generic over `T` so adopters parameterise the structured shape against
32
+ * their grammar's transfer-model overlay; passing a string is always
33
+ * allowed.
34
+ */
35
+ export interface TransferUpdateArgs<T> extends TransferClientArgs {
36
+ /** Structured model root or its serialised textual form. */
37
+ model: T | string;
38
+ /**
39
+ * Optional based-on version: the text-document version this update
40
+ * was authored against. When set, the server compares against its
41
+ * current text-document version for `uri` and throws
42
+ * `ConflictError` on mismatch. Omit to opt out of the gate — mirrors
43
+ * LSP's `OptionalVersionedTextDocumentIdentifier` posture, intended
44
+ * for headless / CLI / batch tooling without a meaningful based-on
45
+ * version.
46
+ */
47
+ baseVersion?: number;
48
+ }
49
+ /**
50
+ * Persist a document to disk via the in-process facade. Same `model`
51
+ * shape as {@link TransferUpdateArgs}.
52
+ */
53
+ export interface TransferSaveArgs<T> extends TransferClientArgs {
54
+ /** Structured model root or its serialised textual form. */
55
+ model: T | string;
56
+ /**
57
+ * Optional based-on version — same semantics as
58
+ * {@link TransferUpdateArgs.baseVersion}. `save` delegates the gating
59
+ * check to its inner `update`, so this field threads through to the
60
+ * same `ConflictError` site.
61
+ */
62
+ baseVersion?: number;
63
+ }
64
+ //# sourceMappingURL=args.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/model-service/args.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;GAUG;AAEH,yFAAyF;AACzF,MAAM,WAAW,kBAAkB;IAChC,oBAAoB;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,CAAE,SAAQ,kBAAkB;IAC9D,4DAA4D;IAC5D,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC;IAClB;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,CAAE,SAAQ,kBAAkB;IAC5D,4DAA4D;IAC5D,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC;IAClB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACvB"}
@@ -0,0 +1,11 @@
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
+ //# sourceMappingURL=args.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.js","sourceRoot":"","sources":["../../src/model-service/args.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF"}
@@ -0,0 +1,11 @@
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
+ export * from './args';
10
+ export * from './reference-candidate';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model-service/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAOlF,cAAc,QAAQ,CAAC;AACvB,cAAc,uBAAuB,CAAC"}