@tier0/sdk-v2 0.9.10 → 0.10.0

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 (237) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/LICENSE +21 -21
  3. package/README.md +160 -24
  4. package/dist/cjs/client.d.ts +79 -3
  5. package/dist/cjs/client.js +4 -6
  6. package/dist/cjs/client.js.map +1 -1
  7. package/dist/cjs/cloud-server.d.ts +33 -26
  8. package/dist/cjs/cloud-server.js +102 -100
  9. package/dist/cjs/cloud-server.js.map +1 -1
  10. package/dist/cjs/cloud-transport.d.ts +15 -20
  11. package/dist/cjs/cloud-transport.js +87 -68
  12. package/dist/cjs/cloud-transport.js.map +1 -1
  13. package/dist/cjs/data/bootstrap.js +3 -4
  14. package/dist/cjs/data/bootstrap.js.map +1 -1
  15. package/dist/cjs/data/call.d.ts +1 -3
  16. package/dist/cjs/data/call.js +8 -12
  17. package/dist/cjs/data/call.js.map +1 -1
  18. package/dist/cjs/data/client.d.ts +8 -7
  19. package/dist/cjs/data/client.js +24 -11
  20. package/dist/cjs/data/client.js.map +1 -1
  21. package/dist/cjs/data/collection.d.ts +3 -5
  22. package/dist/cjs/data/collection.js +3 -4
  23. package/dist/cjs/data/collection.js.map +1 -1
  24. package/dist/cjs/data/context.d.ts +5 -11
  25. package/dist/cjs/data/context.js +21 -36
  26. package/dist/cjs/data/context.js.map +1 -1
  27. package/dist/cjs/data/error.js +1 -1
  28. package/dist/cjs/data/error.js.map +1 -1
  29. package/dist/cjs/data/index.d.ts +5 -3
  30. package/dist/cjs/data/index.js +5 -5
  31. package/dist/cjs/data/index.js.map +1 -1
  32. package/dist/cjs/data/relay.d.ts +51 -0
  33. package/dist/cjs/data/relay.js +371 -0
  34. package/dist/cjs/data/relay.js.map +1 -0
  35. package/dist/cjs/data/subscribe.d.ts +22 -38
  36. package/dist/cjs/data/subscribe.js +22 -28
  37. package/dist/cjs/data/subscribe.js.map +1 -1
  38. package/dist/cjs/event-stream.d.ts +28 -0
  39. package/dist/cjs/event-stream.js +222 -0
  40. package/dist/cjs/event-stream.js.map +1 -0
  41. package/dist/cjs/mq/client.d.ts +32 -1
  42. package/dist/cjs/mq/client.js +404 -69
  43. package/dist/cjs/mq/client.js.map +1 -1
  44. package/dist/cjs/mq/index.d.ts +1 -0
  45. package/dist/cjs/mq/index.js +3 -1
  46. package/dist/cjs/mq/index.js.map +1 -1
  47. package/dist/cjs/mq/topic.d.ts +29 -0
  48. package/dist/cjs/mq/topic.js +48 -0
  49. package/dist/cjs/mq/topic.js.map +1 -0
  50. package/dist/cjs/mq/types.d.ts +21 -1
  51. package/dist/cjs/mq/types.js.map +1 -1
  52. package/dist/cjs/openapi/api.generated.d.ts +20 -0
  53. package/dist/cjs/openapi/api.generated.js +11 -0
  54. package/dist/cjs/openapi/api.generated.js.map +1 -1
  55. package/dist/cjs/openapi/client.d.ts +46 -0
  56. package/dist/cjs/openapi/client.js +158 -10
  57. package/dist/cjs/openapi/client.js.map +1 -1
  58. package/dist/cjs/openapi/codecs.generated.d.ts +74 -0
  59. package/dist/cjs/openapi/codecs.generated.js +1 -1
  60. package/dist/cjs/openapi/codecs.generated.js.map +1 -1
  61. package/dist/cjs/openapi/types.generated.d.ts +205 -1
  62. package/dist/cjs/openapi/types.generated.js.map +1 -1
  63. package/dist/cjs/page-runtime.d.ts +48 -0
  64. package/dist/cjs/page-runtime.js +74 -0
  65. package/dist/cjs/page-runtime.js.map +1 -0
  66. package/dist/cjs/platform-proxy.d.ts +17 -0
  67. package/dist/cjs/platform-proxy.js +52 -0
  68. package/dist/cjs/platform-proxy.js.map +1 -0
  69. package/dist/cjs/runtime-context.d.ts +2 -1
  70. package/dist/cjs/runtime-context.js +6 -2
  71. package/dist/cjs/runtime-context.js.map +1 -1
  72. package/dist/cjs/runtime-env.js.map +1 -1
  73. package/dist/cjs/source.d.ts +19 -1
  74. package/dist/cjs/source.js +9 -3
  75. package/dist/cjs/source.js.map +1 -1
  76. package/dist/cjs/stream.js +3 -2
  77. package/dist/cjs/stream.js.map +1 -1
  78. package/dist/cjs/streams/contract.generated.d.ts +7 -1
  79. package/dist/cjs/streams/contract.generated.js.map +1 -1
  80. package/dist/cjs/streams/messages.js +1 -10
  81. package/dist/cjs/streams/messages.js.map +1 -1
  82. package/dist/cjs/streams/requests.d.ts +3 -0
  83. package/dist/cjs/streams/requests.js +5 -2
  84. package/dist/cjs/streams/requests.js.map +1 -1
  85. package/dist/cjs/streams/transport.d.ts +1 -13
  86. package/dist/cjs/streams/transport.js +2 -18
  87. package/dist/cjs/streams/transport.js.map +1 -1
  88. package/dist/cjs/uns-v2/client.d.ts +1 -6
  89. package/dist/cjs/uns-v2/client.js +30 -6
  90. package/dist/cjs/uns-v2/client.js.map +1 -1
  91. package/dist/cjs/uns-v2/data-client.d.ts +5 -2
  92. package/dist/cjs/uns-v2/data-client.js +7 -4
  93. package/dist/cjs/uns-v2/data-client.js.map +1 -1
  94. package/dist/cjs/uns-v2/generated.d.ts +6783 -4655
  95. package/dist/cjs/uns-v2/generated.js +221 -65
  96. package/dist/cjs/uns-v2/generated.js.map +1 -1
  97. package/dist/cjs/uns-v2/sse.d.ts +7 -1
  98. package/dist/cjs/uns-v2/sse.js +12 -2
  99. package/dist/cjs/uns-v2/sse.js.map +1 -1
  100. package/dist/esm/client.d.ts +79 -3
  101. package/dist/esm/client.js +5 -7
  102. package/dist/esm/client.js.map +1 -1
  103. package/dist/esm/cloud-server.d.ts +33 -26
  104. package/dist/esm/cloud-server.js +99 -97
  105. package/dist/esm/cloud-server.js.map +1 -1
  106. package/dist/esm/cloud-transport.d.ts +15 -20
  107. package/dist/esm/cloud-transport.js +86 -67
  108. package/dist/esm/cloud-transport.js.map +1 -1
  109. package/dist/esm/data/bootstrap.js +3 -4
  110. package/dist/esm/data/bootstrap.js.map +1 -1
  111. package/dist/esm/data/call.d.ts +1 -3
  112. package/dist/esm/data/call.js +9 -13
  113. package/dist/esm/data/call.js.map +1 -1
  114. package/dist/esm/data/client.d.ts +8 -7
  115. package/dist/esm/data/client.js +22 -9
  116. package/dist/esm/data/client.js.map +1 -1
  117. package/dist/esm/data/collection.d.ts +3 -5
  118. package/dist/esm/data/collection.js +3 -4
  119. package/dist/esm/data/collection.js.map +1 -1
  120. package/dist/esm/data/context.d.ts +5 -11
  121. package/dist/esm/data/context.js +19 -33
  122. package/dist/esm/data/context.js.map +1 -1
  123. package/dist/esm/data/error.js +1 -1
  124. package/dist/esm/data/error.js.map +1 -1
  125. package/dist/esm/data/index.d.ts +5 -3
  126. package/dist/esm/data/index.js +3 -2
  127. package/dist/esm/data/index.js.map +1 -1
  128. package/dist/esm/data/relay.d.ts +51 -0
  129. package/dist/esm/data/relay.js +368 -0
  130. package/dist/esm/data/relay.js.map +1 -0
  131. package/dist/esm/data/subscribe.d.ts +22 -38
  132. package/dist/esm/data/subscribe.js +22 -27
  133. package/dist/esm/data/subscribe.js.map +1 -1
  134. package/dist/esm/event-stream.d.ts +28 -0
  135. package/dist/esm/event-stream.js +217 -0
  136. package/dist/esm/event-stream.js.map +1 -0
  137. package/dist/esm/mq/client.d.ts +32 -1
  138. package/dist/esm/mq/client.js +404 -69
  139. package/dist/esm/mq/client.js.map +1 -1
  140. package/dist/esm/mq/index.d.ts +1 -0
  141. package/dist/esm/mq/index.js +1 -0
  142. package/dist/esm/mq/index.js.map +1 -1
  143. package/dist/esm/mq/topic.d.ts +29 -0
  144. package/dist/esm/mq/topic.js +44 -0
  145. package/dist/esm/mq/topic.js.map +1 -0
  146. package/dist/esm/mq/types.d.ts +21 -1
  147. package/dist/esm/mq/types.js.map +1 -1
  148. package/dist/esm/openapi/api.generated.d.ts +20 -0
  149. package/dist/esm/openapi/api.generated.js +11 -0
  150. package/dist/esm/openapi/api.generated.js.map +1 -1
  151. package/dist/esm/openapi/client.d.ts +46 -0
  152. package/dist/esm/openapi/client.js +157 -10
  153. package/dist/esm/openapi/client.js.map +1 -1
  154. package/dist/esm/openapi/codecs.generated.d.ts +74 -0
  155. package/dist/esm/openapi/codecs.generated.js +1 -1
  156. package/dist/esm/openapi/codecs.generated.js.map +1 -1
  157. package/dist/esm/openapi/types.generated.d.ts +205 -1
  158. package/dist/esm/openapi/types.generated.js.map +1 -1
  159. package/dist/esm/page-runtime.d.ts +48 -0
  160. package/dist/esm/page-runtime.js +65 -0
  161. package/dist/esm/page-runtime.js.map +1 -0
  162. package/dist/esm/platform-proxy.d.ts +17 -0
  163. package/dist/esm/platform-proxy.js +47 -0
  164. package/dist/esm/platform-proxy.js.map +1 -0
  165. package/dist/esm/runtime-context.d.ts +2 -1
  166. package/dist/esm/runtime-context.js +6 -2
  167. package/dist/esm/runtime-context.js.map +1 -1
  168. package/dist/esm/runtime-env.js.map +1 -1
  169. package/dist/esm/source.d.ts +19 -1
  170. package/dist/esm/source.js +10 -4
  171. package/dist/esm/source.js.map +1 -1
  172. package/dist/esm/stream.js +4 -3
  173. package/dist/esm/stream.js.map +1 -1
  174. package/dist/esm/streams/contract.generated.d.ts +7 -1
  175. package/dist/esm/streams/contract.generated.js.map +1 -1
  176. package/dist/esm/streams/messages.js +1 -10
  177. package/dist/esm/streams/messages.js.map +1 -1
  178. package/dist/esm/streams/requests.d.ts +3 -0
  179. package/dist/esm/streams/requests.js +5 -2
  180. package/dist/esm/streams/requests.js.map +1 -1
  181. package/dist/esm/streams/transport.d.ts +1 -13
  182. package/dist/esm/streams/transport.js +1 -17
  183. package/dist/esm/streams/transport.js.map +1 -1
  184. package/dist/esm/uns-v2/client.d.ts +1 -6
  185. package/dist/esm/uns-v2/client.js +30 -6
  186. package/dist/esm/uns-v2/client.js.map +1 -1
  187. package/dist/esm/uns-v2/data-client.d.ts +5 -2
  188. package/dist/esm/uns-v2/data-client.js +8 -5
  189. package/dist/esm/uns-v2/data-client.js.map +1 -1
  190. package/dist/esm/uns-v2/generated.d.ts +6783 -4655
  191. package/dist/esm/uns-v2/generated.js +221 -65
  192. package/dist/esm/uns-v2/generated.js.map +1 -1
  193. package/dist/esm/uns-v2/sse.d.ts +7 -1
  194. package/dist/esm/uns-v2/sse.js +12 -2
  195. package/dist/esm/uns-v2/sse.js.map +1 -1
  196. package/package.json +25 -12
  197. package/skills/tier0-sdk-v2/SKILL.md +11 -5
  198. package/skills/tier0-sdk-v2/references/integration.md +14 -24
  199. package/skills/tier0-sdk-v2/tier0-sdk-v2-data/SKILL.md +11 -5
  200. package/skills/tier0-sdk-v2/tier0-sdk-v2-data/references/consistency.md +6 -10
  201. package/skills/tier0-sdk-v2/tier0-sdk-v2-data/references/errors.md +20 -3
  202. package/skills/tier0-sdk-v2/tier0-sdk-v2-data/references/read-write.md +46 -13
  203. package/skills/tier0-sdk-v2/tier0-sdk-v2-members/SKILL.md +2 -2
  204. package/skills/tier0-sdk-v2/tier0-sdk-v2-members/references/app-members.md +5 -1
  205. package/skills/tier0-sdk-v2/tier0-sdk-v2-mq/SKILL.md +25 -0
  206. package/skills/tier0-sdk-v2/tier0-sdk-v2-mq/references/quickstart.md +1 -1
  207. package/skills/tier0-sdk-v2/tier0-sdk-v2-notifications/SKILL.md +3 -3
  208. package/skills/tier0-sdk-v2/tier0-sdk-v2-notifications/references/send.md +6 -6
  209. package/skills/tier0-sdk-v2/tier0-sdk-v2-source/SKILL.md +4 -4
  210. package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/changes.md +2 -2
  211. package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/create.md +26 -36
  212. package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/delete.md +9 -23
  213. package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/protocols.md +12 -29
  214. package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/read.md +4 -5
  215. package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/update.md +5 -5
  216. package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/SKILL.md +3 -3
  217. package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/create.md +23 -9
  218. package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/deploy.md +14 -12
  219. package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/http-server.md +4 -4
  220. package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/read.md +4 -3
  221. package/skills/tier0-sdk-v2/tier0-sdk-v2-streams/SKILL.md +12 -12
  222. package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/SKILL.md +2 -1
  223. package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/references/create.md +2 -2
  224. package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/references/delete.md +22 -1
  225. package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/references/read.md +5 -6
  226. package/dist/cjs/app-identity-contract.generated.d.ts +0 -22
  227. package/dist/cjs/app-identity-contract.generated.js +0 -51
  228. package/dist/cjs/app-identity-contract.generated.js.map +0 -1
  229. package/dist/cjs/runtime.d.ts +0 -13
  230. package/dist/cjs/runtime.js +0 -51
  231. package/dist/cjs/runtime.js.map +0 -1
  232. package/dist/esm/app-identity-contract.generated.d.ts +0 -22
  233. package/dist/esm/app-identity-contract.generated.js +0 -48
  234. package/dist/esm/app-identity-contract.generated.js.map +0 -1
  235. package/dist/esm/runtime.d.ts +0 -13
  236. package/dist/esm/runtime.js +0 -46
  237. package/dist/esm/runtime.js.map +0 -1
@@ -14,7 +14,13 @@ export interface ServerSentEvent {
14
14
  export declare const SSE_MAX_LINE_BYTES: number;
15
15
  export declare class ServerSentEventsError extends Error {
16
16
  }
17
- /** Yields each dispatched event and each comment line; `retry:` is ignored. Throws ServerSentEventsError on an oversized line. */
17
+ /**
18
+ * Yields each dispatched event and each comment line, plus `{ id }` for a frame
19
+ * that only moves the position; `retry:` is ignored. Throws
20
+ * ServerSentEventsError on an oversized line.
21
+ */
18
22
  export declare function parseServerSentEvents(stream: ReadableStream<Uint8Array>): AsyncGenerator<ServerSentEvent | {
19
23
  comment: string;
24
+ } | {
25
+ id: string;
20
26
  }>;
@@ -12,7 +12,11 @@ exports.SSE_MAX_LINE_BYTES = 1 << 20;
12
12
  class ServerSentEventsError extends Error {
13
13
  }
14
14
  exports.ServerSentEventsError = ServerSentEventsError;
15
- /** Yields each dispatched event and each comment line; `retry:` is ignored. Throws ServerSentEventsError on an oversized line. */
15
+ /**
16
+ * Yields each dispatched event and each comment line, plus `{ id }` for a frame
17
+ * that only moves the position; `retry:` is ignored. Throws
18
+ * ServerSentEventsError on an oversized line.
19
+ */
16
20
  async function* parseServerSentEvents(stream) {
17
21
  const reader = stream.getReader();
18
22
  const decoder = new TextDecoder();
@@ -20,6 +24,7 @@ async function* parseServerSentEvents(stream) {
20
24
  let event = '';
21
25
  let data = [];
22
26
  let id;
27
+ let moved = false;
23
28
  try {
24
29
  while (true) {
25
30
  const { done, value } = await reader.read();
@@ -34,6 +39,9 @@ async function* parseServerSentEvents(stream) {
34
39
  if (line === '') {
35
40
  if (data.length > 0 || event)
36
41
  yield { event: event || 'message', data: data.join('\n'), ...(id === undefined ? {} : { id }) };
42
+ else if (moved && id !== undefined)
43
+ yield { id };
44
+ moved = false;
37
45
  event = '';
38
46
  data = [];
39
47
  continue;
@@ -50,8 +58,10 @@ async function* parseServerSentEvents(stream) {
50
58
  event = text;
51
59
  else if (field === 'data')
52
60
  data.push(text);
53
- else if (field === 'id' && !text.includes('\u0000'))
61
+ else if (field === 'id' && !text.includes('\u0000')) {
54
62
  id = text;
63
+ moved = true;
64
+ }
55
65
  }
56
66
  if (done)
57
67
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"sse.js","sourceRoot":"","sources":["../../../src/uns-v2/sse.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAgBH,sDAyCC;AA/CD,2FAA2F;AAC9E,QAAA,kBAAkB,GAAG,CAAC,IAAI,EAAE,CAAC;AAE1C,MAAa,qBAAsB,SAAQ,KAAK;CAAG;AAAnD,sDAAmD;AAEnD,kIAAkI;AAC3H,KAAK,SAAS,CAAC,CAAC,qBAAqB,CAAC,MAAkC;IAC7E,MAAM,MAAM,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`text/event-stream` parser (WHATWG server-sent events). Unlike\n * EventSource it also dispatches a named event without data lines, and\n * reports comment lines, so a keep-alive in either form is visible.\n */\n\nexport interface ServerSentEvent {\n /** `message` when the server names no event. */\n event: string;\n data: string;\n /** Last `id:` seen on the stream so far, as EventSource keeps it. */\n id?: string;\n}\n\n/** A line longer than this is not an event stream (e.g. a proxy page without newlines). */\nexport const SSE_MAX_LINE_BYTES = 1 << 20;\n\nexport class ServerSentEventsError extends Error {}\n\n/** Yields each dispatched event and each comment line; `retry:` is ignored. Throws ServerSentEventsError on an oversized line. */\nexport async function* parseServerSentEvents(stream: ReadableStream<Uint8Array>): AsyncGenerator<ServerSentEvent | { comment: string }> {\n const reader = stream.getReader();\n const decoder = new TextDecoder();\n let buffer = '';\n let event = '';\n let data: string[] = [];\n let id: string | undefined;\n try {\n while (true) {\n const { done, value } = await reader.read();\n buffer += done ? decoder.decode() : decoder.decode(value, { stream: true });\n // A trailing \"\\r\" may be the first half of \"\\r\\n\": keep it for the next chunk.\n const lines = buffer.split(/\\r\\n|\\n|\\r(?!$)/);\n buffer = done ? '' : (lines.pop() ?? '');\n // UTF-16 length bounds the UTF-8 size from below; good enough to stop runaway input.\n if (buffer.length > SSE_MAX_LINE_BYTES) throw new ServerSentEventsError('Server-sent event line too long.');\n for (const line of lines) {\n if (line === '') {\n if (data.length > 0 || event) yield { event: event || 'message', data: data.join('\\n'), ...(id === undefined ? {} : { id }) };\n event = '';\n data = [];\n continue;\n }\n if (line.startsWith(':')) {\n yield { comment: line.slice(1).trimStart() };\n continue;\n }\n const colon = line.indexOf(':');\n const field = colon < 0 ? line : line.slice(0, colon);\n const raw = colon < 0 ? '' : line.slice(colon + 1);\n const text = raw.startsWith(' ') ? raw.slice(1) : raw;\n if (field === 'event') event = text;\n else if (field === 'data') data.push(text);\n else if (field === 'id' && !text.includes('\\u0000')) id = text;\n }\n if (done) return;\n }\n } finally {\n await reader.cancel().catch(() => undefined);\n reader.releaseLock();\n }\n}\n"]}
1
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,GAAG,IAAI,CAAC;qBAC/B,IAAI,KAAK,KAAK,MAAM;oBAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;qBACtC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;oBACpD,EAAE,GAAG,IAAI,CAAC;oBACV,KAAK,GAAG,IAAI,CAAC;gBACf,CAAC;YACH,CAAC;YACD,IAAI,IAAI;gBAAE,OAAO;QACnB,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC7C,MAAM,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;AACH,CAAC","sourcesContent":["/**\n * Minimal `text/event-stream` parser (WHATWG server-sent events). Unlike\n * EventSource it also dispatches a named event without data lines, and\n * reports comment lines, so a keep-alive in either form is visible.\n */\n\nexport interface ServerSentEvent {\n /** `message` when the server names no event. */\n event: string;\n data: string;\n /** Last `id:` seen on the stream so far, as EventSource keeps it. */\n id?: string;\n}\n\n/** A line longer than this is not an event stream (e.g. a proxy page without newlines). */\nexport const SSE_MAX_LINE_BYTES = 1 << 20;\n\nexport class ServerSentEventsError extends Error {}\n\n/**\n * Yields each dispatched event and each comment line, plus `{ id }` for a frame\n * that only moves the position; `retry:` is ignored. Throws\n * ServerSentEventsError on an oversized line.\n */\nexport async function* parseServerSentEvents(stream: ReadableStream<Uint8Array>): AsyncGenerator<ServerSentEvent | { comment: string } | { id: string }> {\n const reader = stream.getReader();\n const decoder = new TextDecoder();\n let buffer = '';\n let event = '';\n let data: string[] = [];\n let id: string | undefined;\n let moved = false;\n try {\n while (true) {\n const { done, value } = await reader.read();\n buffer += done ? decoder.decode() : decoder.decode(value, { stream: true });\n // A trailing \"\\r\" may be the first half of \"\\r\\n\": keep it for the next chunk.\n const lines = buffer.split(/\\r\\n|\\n|\\r(?!$)/);\n buffer = done ? '' : (lines.pop() ?? '');\n // UTF-16 length bounds the UTF-8 size from below; good enough to stop runaway input.\n if (buffer.length > SSE_MAX_LINE_BYTES) throw new ServerSentEventsError('Server-sent event line too long.');\n for (const line of lines) {\n if (line === '') {\n if (data.length > 0 || event) yield { event: event || 'message', data: data.join('\\n'), ...(id === undefined ? {} : { id }) };\n else if (moved && id !== undefined) yield { id };\n moved = false;\n event = '';\n data = [];\n continue;\n }\n if (line.startsWith(':')) {\n yield { comment: line.slice(1).trimStart() };\n continue;\n }\n const colon = line.indexOf(':');\n const field = colon < 0 ? line : line.slice(0, colon);\n const raw = colon < 0 ? '' : line.slice(colon + 1);\n const text = raw.startsWith(' ') ? raw.slice(1) : raw;\n if (field === 'event') event = text;\n else if (field === 'data') data.push(text);\n else if (field === 'id' && !text.includes('\\u0000')) {\n id = text;\n moved = true;\n }\n }\n if (done) return;\n }\n } finally {\n await reader.cancel().catch(() => undefined);\n reader.releaseLock();\n }\n}\n"]}
@@ -8,7 +8,7 @@ import type { CloudTransportConfig } from './cloud-transport.js';
8
8
  export interface Tier0ClientConfig extends ClientConfig, CloudTransportConfig {
9
9
  }
10
10
  export type Tier0Client = ReturnType<typeof createClient>;
11
- /** 现役服务端和数据客户端保留独立配置;浏览器交互仅使用受信宿主。 */
11
+ /** 每个实例持有独立配置;带 Key 的客户端只在服务端使用。 */
12
12
  export declare function createClient(config?: Tier0ClientConfig): Readonly<{
13
13
  streams: {
14
14
  requests: StreamRequestsClient;
@@ -59,6 +59,8 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
59
59
  send: (body: import("./index.js").components["schemas"]["SdknotificationsSendRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
60
60
  createdAt: string;
61
61
  messageId: string;
62
+ recipientName?: string;
63
+ recipientUserId: string;
62
64
  status: string;
63
65
  }>;
64
66
  get: (body: import("./index.js").components["schemas"]["SdknotificationsGetRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
@@ -68,9 +70,17 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
68
70
  errorCode?: string;
69
71
  message?: string;
70
72
  messageId: string;
73
+ recipientName?: string;
74
+ recipientUserId: string;
71
75
  status: string;
72
76
  type: string;
73
77
  }>;
78
+ list: (body?: import("./index.js").components["schemas"]["SdknotificationsListRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
79
+ list: import("./index.js").components["schemas"]["NotificationListItem"][];
80
+ page: number | bigint;
81
+ size: number | bigint;
82
+ total: number | bigint;
83
+ }>;
74
84
  };
75
85
  mqttAuth: {
76
86
  create: (body: import("./index.js").components["schemas"]["SdkmqttAuthCreateRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
@@ -210,7 +220,6 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
210
220
  files: FilesClient;
211
221
  capabilities: CapabilitiesClient;
212
222
  source: Readonly<{
213
- delete: (request: import("./index.js").CloudSourceDeleteReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDeleteResponse>;
214
223
  validate: (request: import("./index.js").UnsV2SourceValidateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceValidateResponse>;
215
224
  probe: (request: import("./index.js").UnsV2SourceProbeReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceProbeResponse>;
216
225
  discover: (request: import("./index.js").CloudSourceDiscoverReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDiscoverResponse>;
@@ -225,11 +234,30 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
225
234
  observations: Readonly<{
226
235
  get: (request: import("./index.js").CloudSourceObservationsGetReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceObservationsGetResponse>;
227
236
  }>;
237
+ resources: Readonly<{
238
+ catalog: (request: import("./index.js").CloudSourceResourceCatalogReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceResourceCatalogResponse>;
239
+ preview: (request: import("./index.js").CloudSourceResourceReadReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceResourceReadResponse>;
240
+ scan: (request: import("./index.js").CloudSourceResourceScanReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceResourceScanResponse>;
241
+ }>;
242
+ devices: Readonly<{
243
+ list: (request: import("./index.js").CloudSourceDevicesListReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDevicesListResponse>;
244
+ }>;
228
245
  documents: Readonly<{
229
246
  list: (request: import("./index.js").CloudSourceDocumentListReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentListResponse>;
230
247
  get: (request: import("./index.js").CloudSourceDocumentGetReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentGetResponse>;
231
248
  create: (request: import("./index.js").CloudSourceDocumentCreateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentCreateResponse>;
232
249
  update: (request: import("./index.js").CloudSourceDocumentUpdateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentUpdateResponse>;
250
+ delete: (request: import("./index.js").UnsV2SourceDocumentDeleteReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceDocumentDeleteResponse>;
251
+ credentials: Readonly<{
252
+ update: (request: import("./index.js").UnsV2SourceNativeCredentialsUpdateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceNativeCredentialsUpdateResponse>;
253
+ }>;
254
+ state: Readonly<{
255
+ update: (request: import("./index.js").CloudEdgeSourceStateUpdateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudEdgeSourceStateUpdateResponse>;
256
+ }>;
257
+ oauth: Readonly<{
258
+ start: (request: import("./index.js").UnsV2SourceNativeOAuthStartReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceNativeOAuthStartResponse>;
259
+ complete: (request: import("./index.js").UnsV2SourceNativeOAuthCompleteReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceNativeOAuthCompleteResponse>;
260
+ }>;
233
261
  }>;
234
262
  }>;
235
263
  stream: Readonly<{
@@ -335,6 +363,8 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
335
363
  send: (body: import("./index.js").components["schemas"]["SdknotificationsSendRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
336
364
  createdAt: string;
337
365
  messageId: string;
366
+ recipientName?: string;
367
+ recipientUserId: string;
338
368
  status: string;
339
369
  }>;
340
370
  get: (body: import("./index.js").components["schemas"]["SdknotificationsGetRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
@@ -344,9 +374,17 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
344
374
  errorCode?: string;
345
375
  message?: string;
346
376
  messageId: string;
377
+ recipientName?: string;
378
+ recipientUserId: string;
347
379
  status: string;
348
380
  type: string;
349
381
  }>;
382
+ list: (body?: import("./index.js").components["schemas"]["SdknotificationsListRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
383
+ list: import("./index.js").components["schemas"]["NotificationListItem"][];
384
+ page: number | bigint;
385
+ size: number | bigint;
386
+ total: number | bigint;
387
+ }>;
350
388
  };
351
389
  members: {
352
390
  listWorkspace: (body?: import("./index.js").components["schemas"]["SdkmembersListWorkspaceRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
@@ -570,6 +608,8 @@ export declare const client: Readonly<{
570
608
  send: (body: import("./index.js").components["schemas"]["SdknotificationsSendRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
571
609
  createdAt: string;
572
610
  messageId: string;
611
+ recipientName?: string;
612
+ recipientUserId: string;
573
613
  status: string;
574
614
  }>;
575
615
  get: (body: import("./index.js").components["schemas"]["SdknotificationsGetRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
@@ -579,9 +619,17 @@ export declare const client: Readonly<{
579
619
  errorCode?: string;
580
620
  message?: string;
581
621
  messageId: string;
622
+ recipientName?: string;
623
+ recipientUserId: string;
582
624
  status: string;
583
625
  type: string;
584
626
  }>;
627
+ list: (body?: import("./index.js").components["schemas"]["SdknotificationsListRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
628
+ list: import("./index.js").components["schemas"]["NotificationListItem"][];
629
+ page: number | bigint;
630
+ size: number | bigint;
631
+ total: number | bigint;
632
+ }>;
585
633
  };
586
634
  mqttAuth: {
587
635
  create: (body: import("./index.js").components["schemas"]["SdkmqttAuthCreateRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
@@ -721,7 +769,6 @@ export declare const client: Readonly<{
721
769
  files: FilesClient;
722
770
  capabilities: CapabilitiesClient;
723
771
  source: Readonly<{
724
- delete: (request: import("./index.js").CloudSourceDeleteReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDeleteResponse>;
725
772
  validate: (request: import("./index.js").UnsV2SourceValidateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceValidateResponse>;
726
773
  probe: (request: import("./index.js").UnsV2SourceProbeReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceProbeResponse>;
727
774
  discover: (request: import("./index.js").CloudSourceDiscoverReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDiscoverResponse>;
@@ -736,11 +783,30 @@ export declare const client: Readonly<{
736
783
  observations: Readonly<{
737
784
  get: (request: import("./index.js").CloudSourceObservationsGetReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceObservationsGetResponse>;
738
785
  }>;
786
+ resources: Readonly<{
787
+ catalog: (request: import("./index.js").CloudSourceResourceCatalogReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceResourceCatalogResponse>;
788
+ preview: (request: import("./index.js").CloudSourceResourceReadReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceResourceReadResponse>;
789
+ scan: (request: import("./index.js").CloudSourceResourceScanReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceResourceScanResponse>;
790
+ }>;
791
+ devices: Readonly<{
792
+ list: (request: import("./index.js").CloudSourceDevicesListReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDevicesListResponse>;
793
+ }>;
739
794
  documents: Readonly<{
740
795
  list: (request: import("./index.js").CloudSourceDocumentListReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentListResponse>;
741
796
  get: (request: import("./index.js").CloudSourceDocumentGetReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentGetResponse>;
742
797
  create: (request: import("./index.js").CloudSourceDocumentCreateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentCreateResponse>;
743
798
  update: (request: import("./index.js").CloudSourceDocumentUpdateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentUpdateResponse>;
799
+ delete: (request: import("./index.js").UnsV2SourceDocumentDeleteReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceDocumentDeleteResponse>;
800
+ credentials: Readonly<{
801
+ update: (request: import("./index.js").UnsV2SourceNativeCredentialsUpdateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceNativeCredentialsUpdateResponse>;
802
+ }>;
803
+ state: Readonly<{
804
+ update: (request: import("./index.js").CloudEdgeSourceStateUpdateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudEdgeSourceStateUpdateResponse>;
805
+ }>;
806
+ oauth: Readonly<{
807
+ start: (request: import("./index.js").UnsV2SourceNativeOAuthStartReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceNativeOAuthStartResponse>;
808
+ complete: (request: import("./index.js").UnsV2SourceNativeOAuthCompleteReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceNativeOAuthCompleteResponse>;
809
+ }>;
744
810
  }>;
745
811
  }>;
746
812
  stream: Readonly<{
@@ -846,6 +912,8 @@ export declare const client: Readonly<{
846
912
  send: (body: import("./index.js").components["schemas"]["SdknotificationsSendRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
847
913
  createdAt: string;
848
914
  messageId: string;
915
+ recipientName?: string;
916
+ recipientUserId: string;
849
917
  status: string;
850
918
  }>;
851
919
  get: (body: import("./index.js").components["schemas"]["SdknotificationsGetRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
@@ -855,9 +923,17 @@ export declare const client: Readonly<{
855
923
  errorCode?: string;
856
924
  message?: string;
857
925
  messageId: string;
926
+ recipientName?: string;
927
+ recipientUserId: string;
858
928
  status: string;
859
929
  type: string;
860
930
  }>;
931
+ list: (body?: import("./index.js").components["schemas"]["SdknotificationsListRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
932
+ list: import("./index.js").components["schemas"]["NotificationListItem"][];
933
+ page: number | bigint;
934
+ size: number | bigint;
935
+ total: number | bigint;
936
+ }>;
861
937
  };
862
938
  members: {
863
939
  listWorkspace: (body?: import("./index.js").components["schemas"]["SdkmembersListWorkspaceRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
@@ -2,7 +2,7 @@ import { StreamRequestsClient } from './streams/requests.js';
2
2
  import { StreamMessagesClient } from './streams/messages.js';
3
3
  import { StreamTransport } from './streams/transport.js';
4
4
  import { StreamCapabilitiesClient } from './streams/capabilities.js';
5
- import { getClient, HttpClient } from './openapi/client.js';
5
+ import { getClient, HttpClient, snapshotClientConfig } from './openapi/client.js';
6
6
  import { createOpenAPI } from './openapi/api.generated.js';
7
7
  import { createUnsV2Client } from './uns-v2/client.js';
8
8
  import { bindUnsDataClient } from './uns-v2/data-client.js';
@@ -10,9 +10,7 @@ import { bindSourceClient } from './source.js';
10
10
  import { bindStreamClient } from './stream.js';
11
11
  import { CapabilitiesClient } from './capabilities.js';
12
12
  import { FilesClient } from './files.js';
13
- /** Use a fresh instance per incoming request when supplying employee data delegation. */
14
- function assemble(resolve, snapshot) {
15
- const http = resolve();
13
+ function assemble(resolve, snapshot, http = resolve()) {
16
14
  const api = createOpenAPI(http);
17
15
  const transport = new StreamTransport(resolve, snapshot);
18
16
  const messages = new StreamMessagesClient(transport);
@@ -33,9 +31,9 @@ function assemble(resolve, snapshot) {
33
31
  api,
34
32
  });
35
33
  }
36
- /** 现役服务端和数据客户端保留独立配置;浏览器交互仅使用受信宿主。 */
34
+ /** 每个实例持有独立配置;带 Key 的客户端只在服务端使用。 */
37
35
  export function createClient(config = {}) {
38
- const snapshot = Object.freeze({ ...config });
36
+ const snapshot = Object.freeze(snapshotClientConfig(config));
39
37
  const http = new HttpClient(snapshot);
40
38
  return assemble(() => http, snapshot);
41
39
  }
@@ -48,5 +46,5 @@ const defaultHttp = new Proxy(new HttpClient(), {
48
46
  },
49
47
  });
50
48
  /** App 默认交互客户端在调用时解析宿主,无需在浏览器配置密钥。 */
51
- export const client = assemble(() => defaultHttp, {});
49
+ export const client = assemble(getClient, {}, defaultHttp);
52
50
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAqB,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC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EAAE,gBAAgB,CAAC,GAAG,CAAC;QAC7B,MAAM,EAAE,gBAAgB,CAAC,GAAG,CAAC;QAC7B,GAAG,EAAE,iBAAiB,CAAC,GAAG,CAAC;QAC3B,GAAG;KACJ,CAAC,CAAC;AACL,CAAC;AAGD,sCAAsC;AACtC,MAAM,UAAU,YAAY,CAAC,SAA4B,EAAE;IACzD,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IAC9C,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC;IACtC,OAAO,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACxC,CAAC;AAED,6CAA6C;AAC7C,MAAM,WAAW,GAAG,IAAI,KAAK,CAAC,IAAI,UAAU,EAAE,EAAE;IAC9C,GAAG,CAAC,OAAO,EAAE,GAAG;QACd,MAAM,OAAO,GAAG,SAAS,EAAE,CAAC;QAC5B,MAAM,KAAK,GAAY,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACjD,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACnE,CAAC;CACF,CAAC,CAAC;AACH,sCAAsC;AACtC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC","sourcesContent":["import { StreamRequestsClient } from './streams/requests.js';\nimport { StreamMessagesClient } from './streams/messages.js';\nimport { StreamTransport } from './streams/transport.js';\nimport { StreamCapabilitiesClient } from './streams/capabilities.js';\nimport { getClient, HttpClient, type ClientConfig } from './openapi/client.js';\nimport { createOpenAPI } from './openapi/api.generated.js';\nimport { createUnsV2Client } from './uns-v2/client.js';\nimport { bindUnsDataClient } from './uns-v2/data-client.js';\nimport { bindSourceClient } from './source.js';\nimport { bindStreamClient } from './stream.js';\nimport { CapabilitiesClient } from './capabilities.js';\nimport { FilesClient } from './files.js';\nimport type { CloudTransportConfig } from './cloud-transport.js';\n\nexport interface Tier0ClientConfig extends ClientConfig, CloudTransportConfig {}\n/** Use a fresh instance per incoming request when supplying employee data delegation. */\nfunction assemble(resolve: () => HttpClient, snapshot: Tier0ClientConfig) {\n const http = resolve();\n const api = createOpenAPI(http);\n const transport = new StreamTransport(resolve, snapshot);\n const messages = new StreamMessagesClient(transport);\n const raw = createUnsV2Client(resolve, snapshot);\n return Object.freeze({\n streams: { requests: new StreamRequestsClient(transport), messages, capabilities: new StreamCapabilitiesClient(resolve, snapshot) },\n dispose: () => messages.dispose(),\n system: api.system,\n members: api.members,\n notifications: api.notifications,\n mqttAuth: api.mqttAuth,\n agent: api.agent,\n files: new FilesClient(http),\n capabilities: new CapabilitiesClient(resolve, snapshot),\n source: bindSourceClient(raw),\n stream: bindStreamClient(raw),\n uns: bindUnsDataClient(raw),\n api,\n });\n}\nexport type Tier0Client = ReturnType<typeof createClient>;\n\n/** 现役服务端和数据客户端保留独立配置;浏览器交互仅使用受信宿主。 */\nexport function createClient(config: Tier0ClientConfig = {}) {\n const snapshot = Object.freeze({ ...config });\n const http = new HttpClient(snapshot);\n return assemble(() => http, snapshot);\n}\n\n// 全局兼容入口也在调用时读取 configureClient,不固化模块导入时的配置。\nconst defaultHttp = new Proxy(new HttpClient(), {\n get(_target, key) {\n const current = getClient();\n const value: unknown = Reflect.get(current, key);\n return typeof value === 'function' ? value.bind(current) : value;\n },\n});\n/** App 默认交互客户端在调用时解析宿主,无需在浏览器配置密钥。 */\nexport const client = assemble(() => defaultHttp, {});\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AA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{ StreamTransport } from './streams/transport.js';\nimport { StreamCapabilitiesClient } from './streams/capabilities.js';\nimport { getClient, HttpClient, snapshotClientConfig, type ClientConfig } from './openapi/client.js';\nimport { createOpenAPI } from './openapi/api.generated.js';\nimport { createUnsV2Client } from './uns-v2/client.js';\nimport { bindUnsDataClient } from './uns-v2/data-client.js';\nimport { bindSourceClient } from './source.js';\nimport { bindStreamClient } from './stream.js';\nimport { CapabilitiesClient } from './capabilities.js';\nimport { FilesClient } from './files.js';\nimport type { CloudTransportConfig } from './cloud-transport.js';\n\nexport interface Tier0ClientConfig extends ClientConfig, CloudTransportConfig {}\nfunction assemble(resolve: () => HttpClient, snapshot: Tier0ClientConfig, http = resolve()) {\n const api = createOpenAPI(http);\n const transport = new StreamTransport(resolve, snapshot);\n const messages = new StreamMessagesClient(transport);\n const raw = createUnsV2Client(resolve, snapshot);\n return Object.freeze({\n streams: { requests: new StreamRequestsClient(transport), messages, capabilities: new StreamCapabilitiesClient(resolve, snapshot) },\n dispose: () => messages.dispose(),\n system: api.system,\n members: api.members,\n notifications: api.notifications,\n mqttAuth: api.mqttAuth,\n agent: api.agent,\n files: new FilesClient(http),\n capabilities: new CapabilitiesClient(resolve, snapshot),\n source: bindSourceClient(raw),\n stream: bindStreamClient(raw),\n uns: bindUnsDataClient(raw),\n api,\n });\n}\nexport type Tier0Client = ReturnType<typeof createClient>;\n\n/** 每个实例持有独立配置;带 Key 的客户端只在服务端使用。 */\nexport function createClient(config: Tier0ClientConfig = {}) {\n const snapshot = Object.freeze(snapshotClientConfig(config));\n const http = new HttpClient(snapshot);\n return assemble(() => http, snapshot);\n}\n\n// 全局兼容入口也在调用时读取 configureClient,不固化模块导入时的配置。\nconst defaultHttp = new Proxy(new HttpClient(), {\n get(_target, key) {\n const current = getClient();\n const value: unknown = Reflect.get(current, key);\n return typeof value === 'function' ? value.bind(current) : value;\n },\n});\n/** App 默认交互客户端在调用时解析宿主,无需在浏览器配置密钥。 */\nexport const client = assemble(getClient, {}, defaultHttp);\n"]}
@@ -1,31 +1,38 @@
1
- export declare const APP_REQUEST_IDENTITY_HEADER: "X-Tier0-App-Identity";
2
- export declare class AppRequestIdentityError extends Error {
3
- readonly code: 'APP_IDENTITY_INVALID' | 'APP_IDENTITY_CONFIGURATION_INVALID';
4
- constructor(code: 'APP_IDENTITY_INVALID' | 'APP_IDENTITY_CONFIGURATION_INVALID');
1
+ /** Set by the front door on every request it forwards to the App, after stripping any `X-Tier0-*` the client sent. */
2
+ export declare const VISITOR_HEADER = "X-Tier0-Visitor";
3
+ export type VisitorErrorCode = 'VISITOR_HEADER_INVALID' | 'VISITOR_CONFIGURATION_INVALID';
4
+ export declare class VisitorError extends Error {
5
+ readonly code: VisitorErrorCode;
6
+ constructor(code: VisitorErrorCode);
5
7
  }
6
- export interface VerifiedCloudAppUser {
7
- readonly kind: 'gateway-user';
8
- readonly userID: string;
8
+ /** The visitor of a request, from `X-Tier0-Visitor`. */
9
+ export interface Visitor {
10
+ readonly subType: 'employee' | 'machine';
11
+ /** Employee user ID, or the call token ID of a machine visitor. */
12
+ readonly subject: string;
13
+ /** Grant of an employee's access; empty for a machine visitor. */
14
+ readonly grant: string;
9
15
  readonly workspaceID: string;
10
16
  readonly appID: string;
11
- readonly roleKeys: readonly string[];
12
- readonly requestID: string;
13
- readonly issuedAt: number;
14
- readonly expiresAt: number;
15
- readonly verificationKeyID: string;
17
+ readonly runtime: 'deployed' | 'preview';
18
+ /** Roles of this visitor in the App; in Preview, the roles selected in "view as". */
19
+ readonly appRoles: readonly string[];
20
+ /** Only in Preview's "view as". */
21
+ readonly activeRole?: string;
16
22
  }
17
- export interface CloudAppIdentityAuthority {
18
- appID: string;
19
- workspaceID: string;
20
- /** Pinned server configuration, never a key or URL taken from the request. */
21
- publicKeys: unknown;
23
+ export interface ParseVisitorOptions {
24
+ /** The App the header must name. Defaults to `TIER0_APP_ID`. */
25
+ appID?: string;
22
26
  }
23
- export interface CloudAppIdentityRequest {
24
- assertion: string | undefined;
25
- method: string;
26
- requestURI: string;
27
- /** Exact bytes received from the gateway, before JSON parsing or normalization. */
28
- body: Uint8Array;
29
- }
30
- /** Verifies request provenance, not business authorization or delegated UNS permissions. */
31
- export declare function createCloudAppRequestVerifier(authority: CloudAppIdentityAuthority): (request: CloudAppIdentityRequest) => VerifiedCloudAppUser;
27
+ /**
28
+ * Parses `X-Tier0-Visitor`: the unpadded base64url (RFC 4648 §5) of a UTF-8
29
+ * JSON object of at most 8192 bytes. The header is not signed; the front door
30
+ * is the only way into the App and replaces whatever the client sent. Parsing
31
+ * is strict: a byte order mark, a duplicate key, a lone UTF-16 surrogate
32
+ * (e.g. `"\ud800"`), an unknown or missing field, a wrong type or length, a `ws` that
33
+ * is not a positive decimal ID without sign or leading zero, an employee
34
+ * without a grant or a machine visitor with one, or an `app` other than this
35
+ * App's throws `VISITOR_HEADER_INVALID`. Without an App ID
36
+ * (`TIER0_APP_ID` unset) it throws `VISITOR_CONFIGURATION_INVALID`.
37
+ */
38
+ export declare function parseVisitorHeader(value: string | null | undefined, options?: ParseVisitorOptions): Visitor;