@tier0/sdk-v2 0.9.10 → 0.10.1
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/CHANGELOG.md +102 -0
- package/LICENSE +21 -21
- package/README.md +162 -24
- package/dist/cjs/client.d.ts +83 -3
- package/dist/cjs/client.js +4 -6
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/cloud-server.d.ts +33 -26
- package/dist/cjs/cloud-server.js +102 -100
- package/dist/cjs/cloud-server.js.map +1 -1
- package/dist/cjs/cloud-transport.d.ts +15 -20
- package/dist/cjs/cloud-transport.js +87 -68
- package/dist/cjs/cloud-transport.js.map +1 -1
- package/dist/cjs/data/bootstrap.js +3 -4
- package/dist/cjs/data/bootstrap.js.map +1 -1
- package/dist/cjs/data/call.d.ts +1 -3
- package/dist/cjs/data/call.js +8 -12
- package/dist/cjs/data/call.js.map +1 -1
- package/dist/cjs/data/client.d.ts +8 -7
- package/dist/cjs/data/client.js +24 -11
- package/dist/cjs/data/client.js.map +1 -1
- package/dist/cjs/data/collection.d.ts +3 -5
- package/dist/cjs/data/collection.js +3 -4
- package/dist/cjs/data/collection.js.map +1 -1
- package/dist/cjs/data/context.d.ts +5 -11
- package/dist/cjs/data/context.js +21 -36
- package/dist/cjs/data/context.js.map +1 -1
- package/dist/cjs/data/error.js +1 -1
- package/dist/cjs/data/error.js.map +1 -1
- package/dist/cjs/data/index.d.ts +5 -3
- package/dist/cjs/data/index.js +5 -5
- package/dist/cjs/data/index.js.map +1 -1
- package/dist/cjs/data/relay.d.ts +51 -0
- package/dist/cjs/data/relay.js +371 -0
- package/dist/cjs/data/relay.js.map +1 -0
- package/dist/cjs/data/subscribe.d.ts +22 -38
- package/dist/cjs/data/subscribe.js +22 -28
- package/dist/cjs/data/subscribe.js.map +1 -1
- package/dist/cjs/event-stream.d.ts +28 -0
- package/dist/cjs/event-stream.js +222 -0
- package/dist/cjs/event-stream.js.map +1 -0
- package/dist/cjs/mq/client.d.ts +32 -1
- package/dist/cjs/mq/client.js +404 -69
- package/dist/cjs/mq/client.js.map +1 -1
- package/dist/cjs/mq/index.d.ts +1 -0
- package/dist/cjs/mq/index.js +3 -1
- package/dist/cjs/mq/index.js.map +1 -1
- package/dist/cjs/mq/topic.d.ts +29 -0
- package/dist/cjs/mq/topic.js +48 -0
- package/dist/cjs/mq/topic.js.map +1 -0
- package/dist/cjs/mq/types.d.ts +21 -1
- package/dist/cjs/mq/types.js.map +1 -1
- package/dist/cjs/openapi/api.generated.d.ts +21 -0
- package/dist/cjs/openapi/api.generated.js +11 -0
- package/dist/cjs/openapi/api.generated.js.map +1 -1
- package/dist/cjs/openapi/client.d.ts +46 -0
- package/dist/cjs/openapi/client.js +158 -10
- package/dist/cjs/openapi/client.js.map +1 -1
- package/dist/cjs/openapi/codecs.generated.d.ts +75 -0
- package/dist/cjs/openapi/codecs.generated.js +1 -1
- package/dist/cjs/openapi/codecs.generated.js.map +1 -1
- package/dist/cjs/openapi/types.generated.d.ts +206 -1
- package/dist/cjs/openapi/types.generated.js.map +1 -1
- package/dist/cjs/page-runtime.d.ts +48 -0
- package/dist/cjs/page-runtime.js +74 -0
- package/dist/cjs/page-runtime.js.map +1 -0
- package/dist/cjs/platform-proxy.d.ts +17 -0
- package/dist/cjs/platform-proxy.js +52 -0
- package/dist/cjs/platform-proxy.js.map +1 -0
- package/dist/cjs/runtime-context.d.ts +2 -1
- package/dist/cjs/runtime-context.js +6 -2
- package/dist/cjs/runtime-context.js.map +1 -1
- package/dist/cjs/runtime-env.js.map +1 -1
- package/dist/cjs/source.d.ts +19 -1
- package/dist/cjs/source.js +9 -3
- package/dist/cjs/source.js.map +1 -1
- package/dist/cjs/stream.js +3 -2
- package/dist/cjs/stream.js.map +1 -1
- package/dist/cjs/streams/contract.generated.d.ts +7 -1
- package/dist/cjs/streams/contract.generated.js.map +1 -1
- package/dist/cjs/streams/messages.js +1 -10
- package/dist/cjs/streams/messages.js.map +1 -1
- package/dist/cjs/streams/requests.d.ts +3 -0
- package/dist/cjs/streams/requests.js +5 -2
- package/dist/cjs/streams/requests.js.map +1 -1
- package/dist/cjs/streams/transport.d.ts +1 -13
- package/dist/cjs/streams/transport.js +2 -18
- package/dist/cjs/streams/transport.js.map +1 -1
- package/dist/cjs/uns-v2/client.d.ts +1 -6
- package/dist/cjs/uns-v2/client.js +30 -6
- package/dist/cjs/uns-v2/client.js.map +1 -1
- package/dist/cjs/uns-v2/data-client.d.ts +5 -2
- package/dist/cjs/uns-v2/data-client.js +7 -4
- package/dist/cjs/uns-v2/data-client.js.map +1 -1
- package/dist/cjs/uns-v2/generated.d.ts +6783 -4655
- package/dist/cjs/uns-v2/generated.js +221 -65
- package/dist/cjs/uns-v2/generated.js.map +1 -1
- package/dist/cjs/uns-v2/sse.d.ts +7 -1
- package/dist/cjs/uns-v2/sse.js +12 -2
- package/dist/cjs/uns-v2/sse.js.map +1 -1
- package/dist/esm/client.d.ts +83 -3
- package/dist/esm/client.js +5 -7
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/cloud-server.d.ts +33 -26
- package/dist/esm/cloud-server.js +99 -97
- package/dist/esm/cloud-server.js.map +1 -1
- package/dist/esm/cloud-transport.d.ts +15 -20
- package/dist/esm/cloud-transport.js +86 -67
- package/dist/esm/cloud-transport.js.map +1 -1
- package/dist/esm/data/bootstrap.js +3 -4
- package/dist/esm/data/bootstrap.js.map +1 -1
- package/dist/esm/data/call.d.ts +1 -3
- package/dist/esm/data/call.js +9 -13
- package/dist/esm/data/call.js.map +1 -1
- package/dist/esm/data/client.d.ts +8 -7
- package/dist/esm/data/client.js +22 -9
- package/dist/esm/data/client.js.map +1 -1
- package/dist/esm/data/collection.d.ts +3 -5
- package/dist/esm/data/collection.js +3 -4
- package/dist/esm/data/collection.js.map +1 -1
- package/dist/esm/data/context.d.ts +5 -11
- package/dist/esm/data/context.js +19 -33
- package/dist/esm/data/context.js.map +1 -1
- package/dist/esm/data/error.js +1 -1
- package/dist/esm/data/error.js.map +1 -1
- package/dist/esm/data/index.d.ts +5 -3
- package/dist/esm/data/index.js +3 -2
- package/dist/esm/data/index.js.map +1 -1
- package/dist/esm/data/relay.d.ts +51 -0
- package/dist/esm/data/relay.js +368 -0
- package/dist/esm/data/relay.js.map +1 -0
- package/dist/esm/data/subscribe.d.ts +22 -38
- package/dist/esm/data/subscribe.js +22 -27
- package/dist/esm/data/subscribe.js.map +1 -1
- package/dist/esm/event-stream.d.ts +28 -0
- package/dist/esm/event-stream.js +217 -0
- package/dist/esm/event-stream.js.map +1 -0
- package/dist/esm/mq/client.d.ts +32 -1
- package/dist/esm/mq/client.js +404 -69
- package/dist/esm/mq/client.js.map +1 -1
- package/dist/esm/mq/index.d.ts +1 -0
- package/dist/esm/mq/index.js +1 -0
- package/dist/esm/mq/index.js.map +1 -1
- package/dist/esm/mq/topic.d.ts +29 -0
- package/dist/esm/mq/topic.js +44 -0
- package/dist/esm/mq/topic.js.map +1 -0
- package/dist/esm/mq/types.d.ts +21 -1
- package/dist/esm/mq/types.js.map +1 -1
- package/dist/esm/openapi/api.generated.d.ts +21 -0
- package/dist/esm/openapi/api.generated.js +11 -0
- package/dist/esm/openapi/api.generated.js.map +1 -1
- package/dist/esm/openapi/client.d.ts +46 -0
- package/dist/esm/openapi/client.js +157 -10
- package/dist/esm/openapi/client.js.map +1 -1
- package/dist/esm/openapi/codecs.generated.d.ts +75 -0
- package/dist/esm/openapi/codecs.generated.js +1 -1
- package/dist/esm/openapi/codecs.generated.js.map +1 -1
- package/dist/esm/openapi/types.generated.d.ts +206 -1
- package/dist/esm/openapi/types.generated.js.map +1 -1
- package/dist/esm/page-runtime.d.ts +48 -0
- package/dist/esm/page-runtime.js +65 -0
- package/dist/esm/page-runtime.js.map +1 -0
- package/dist/esm/platform-proxy.d.ts +17 -0
- package/dist/esm/platform-proxy.js +47 -0
- package/dist/esm/platform-proxy.js.map +1 -0
- package/dist/esm/runtime-context.d.ts +2 -1
- package/dist/esm/runtime-context.js +6 -2
- package/dist/esm/runtime-context.js.map +1 -1
- package/dist/esm/runtime-env.js.map +1 -1
- package/dist/esm/source.d.ts +19 -1
- package/dist/esm/source.js +10 -4
- package/dist/esm/source.js.map +1 -1
- package/dist/esm/stream.js +4 -3
- package/dist/esm/stream.js.map +1 -1
- package/dist/esm/streams/contract.generated.d.ts +7 -1
- package/dist/esm/streams/contract.generated.js.map +1 -1
- package/dist/esm/streams/messages.js +1 -10
- package/dist/esm/streams/messages.js.map +1 -1
- package/dist/esm/streams/requests.d.ts +3 -0
- package/dist/esm/streams/requests.js +5 -2
- package/dist/esm/streams/requests.js.map +1 -1
- package/dist/esm/streams/transport.d.ts +1 -13
- package/dist/esm/streams/transport.js +1 -17
- package/dist/esm/streams/transport.js.map +1 -1
- package/dist/esm/uns-v2/client.d.ts +1 -6
- package/dist/esm/uns-v2/client.js +30 -6
- package/dist/esm/uns-v2/client.js.map +1 -1
- package/dist/esm/uns-v2/data-client.d.ts +5 -2
- package/dist/esm/uns-v2/data-client.js +8 -5
- package/dist/esm/uns-v2/data-client.js.map +1 -1
- package/dist/esm/uns-v2/generated.d.ts +6783 -4655
- package/dist/esm/uns-v2/generated.js +221 -65
- package/dist/esm/uns-v2/generated.js.map +1 -1
- package/dist/esm/uns-v2/sse.d.ts +7 -1
- package/dist/esm/uns-v2/sse.js +12 -2
- package/dist/esm/uns-v2/sse.js.map +1 -1
- package/package.json +25 -12
- package/skills/tier0-sdk-v2/SKILL.md +11 -5
- package/skills/tier0-sdk-v2/references/integration.md +14 -24
- package/skills/tier0-sdk-v2/tier0-sdk-v2-data/SKILL.md +11 -5
- package/skills/tier0-sdk-v2/tier0-sdk-v2-data/references/consistency.md +6 -10
- package/skills/tier0-sdk-v2/tier0-sdk-v2-data/references/errors.md +20 -3
- package/skills/tier0-sdk-v2/tier0-sdk-v2-data/references/read-write.md +46 -13
- package/skills/tier0-sdk-v2/tier0-sdk-v2-members/SKILL.md +2 -2
- package/skills/tier0-sdk-v2/tier0-sdk-v2-members/references/app-members.md +5 -1
- package/skills/tier0-sdk-v2/tier0-sdk-v2-mq/SKILL.md +25 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-mq/references/quickstart.md +1 -1
- package/skills/tier0-sdk-v2/tier0-sdk-v2-notifications/SKILL.md +3 -3
- package/skills/tier0-sdk-v2/tier0-sdk-v2-notifications/references/send.md +6 -6
- package/skills/tier0-sdk-v2/tier0-sdk-v2-source/SKILL.md +4 -4
- package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/changes.md +2 -2
- package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/create.md +26 -36
- package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/delete.md +9 -23
- package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/protocols.md +12 -29
- package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/read.md +4 -5
- package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/update.md +5 -5
- package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/SKILL.md +3 -3
- package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/create.md +23 -9
- package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/deploy.md +14 -12
- package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/http-server.md +4 -4
- package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/read.md +4 -3
- package/skills/tier0-sdk-v2/tier0-sdk-v2-streams/SKILL.md +14 -12
- package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/SKILL.md +3 -1
- package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/references/create.md +2 -2
- package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/references/delete.md +22 -1
- package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/references/read.md +5 -6
- package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/references/update.md +11 -0
- package/dist/cjs/app-identity-contract.generated.d.ts +0 -22
- package/dist/cjs/app-identity-contract.generated.js +0 -51
- package/dist/cjs/app-identity-contract.generated.js.map +0 -1
- package/dist/cjs/runtime.d.ts +0 -13
- package/dist/cjs/runtime.js +0 -51
- package/dist/cjs/runtime.js.map +0 -1
- package/dist/esm/app-identity-contract.generated.d.ts +0 -22
- package/dist/esm/app-identity-contract.generated.js +0 -48
- package/dist/esm/app-identity-contract.generated.js.map +0 -1
- package/dist/esm/runtime.d.ts +0 -13
- package/dist/esm/runtime.js +0 -46
- package/dist/esm/runtime.js.map +0 -1
package/dist/cjs/uns-v2/sse.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
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
|
}>;
|
package/dist/cjs/uns-v2/sse.js
CHANGED
|
@@ -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
|
-
/**
|
|
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;;;
|
|
1
|
+
{"version":3,"file":"sse.js","sourceRoot":"","sources":["../../../src/uns-v2/sse.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAoBH,sDA+CC;AAzDD,2FAA2F;AAC9E,QAAA,kBAAkB,GAAG,CAAC,IAAI,EAAE,CAAC;AAE1C,MAAa,qBAAsB,SAAQ,KAAK;CAAG;AAAnD,sDAAmD;AAEnD;;;;GAIG;AACI,KAAK,SAAS,CAAC,CAAC,qBAAqB,CAAC,MAAkC;IAC7E,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;IAClC,MAAM,OAAO,GAAG,IAAI,WAAW,EAA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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"]}
|
package/dist/esm/client.d.ts
CHANGED
|
@@ -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;
|
|
@@ -28,6 +28,7 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
|
|
|
28
28
|
email: string;
|
|
29
29
|
keyPrefix: string;
|
|
30
30
|
keyType: string;
|
|
31
|
+
permission?: string;
|
|
31
32
|
permissions: string[];
|
|
32
33
|
roles: string[];
|
|
33
34
|
userID: number | bigint;
|
|
@@ -59,6 +60,8 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
|
|
|
59
60
|
send: (body: import("./index.js").components["schemas"]["SdknotificationsSendRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
|
|
60
61
|
createdAt: string;
|
|
61
62
|
messageId: string;
|
|
63
|
+
recipientName?: string;
|
|
64
|
+
recipientUserId: string;
|
|
62
65
|
status: string;
|
|
63
66
|
}>;
|
|
64
67
|
get: (body: import("./index.js").components["schemas"]["SdknotificationsGetRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
|
|
@@ -68,9 +71,17 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
|
|
|
68
71
|
errorCode?: string;
|
|
69
72
|
message?: string;
|
|
70
73
|
messageId: string;
|
|
74
|
+
recipientName?: string;
|
|
75
|
+
recipientUserId: string;
|
|
71
76
|
status: string;
|
|
72
77
|
type: string;
|
|
73
78
|
}>;
|
|
79
|
+
list: (body?: import("./index.js").components["schemas"]["SdknotificationsListRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
|
|
80
|
+
list: import("./index.js").components["schemas"]["NotificationListItem"][];
|
|
81
|
+
page: number | bigint;
|
|
82
|
+
size: number | bigint;
|
|
83
|
+
total: number | bigint;
|
|
84
|
+
}>;
|
|
74
85
|
};
|
|
75
86
|
mqttAuth: {
|
|
76
87
|
create: (body: import("./index.js").components["schemas"]["SdkmqttAuthCreateRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
|
|
@@ -210,7 +221,6 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
|
|
|
210
221
|
files: FilesClient;
|
|
211
222
|
capabilities: CapabilitiesClient;
|
|
212
223
|
source: Readonly<{
|
|
213
|
-
delete: (request: import("./index.js").CloudSourceDeleteReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDeleteResponse>;
|
|
214
224
|
validate: (request: import("./index.js").UnsV2SourceValidateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceValidateResponse>;
|
|
215
225
|
probe: (request: import("./index.js").UnsV2SourceProbeReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceProbeResponse>;
|
|
216
226
|
discover: (request: import("./index.js").CloudSourceDiscoverReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDiscoverResponse>;
|
|
@@ -225,11 +235,30 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
|
|
|
225
235
|
observations: Readonly<{
|
|
226
236
|
get: (request: import("./index.js").CloudSourceObservationsGetReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceObservationsGetResponse>;
|
|
227
237
|
}>;
|
|
238
|
+
resources: Readonly<{
|
|
239
|
+
catalog: (request: import("./index.js").CloudSourceResourceCatalogReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceResourceCatalogResponse>;
|
|
240
|
+
preview: (request: import("./index.js").CloudSourceResourceReadReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceResourceReadResponse>;
|
|
241
|
+
scan: (request: import("./index.js").CloudSourceResourceScanReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceResourceScanResponse>;
|
|
242
|
+
}>;
|
|
243
|
+
devices: Readonly<{
|
|
244
|
+
list: (request: import("./index.js").CloudSourceDevicesListReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDevicesListResponse>;
|
|
245
|
+
}>;
|
|
228
246
|
documents: Readonly<{
|
|
229
247
|
list: (request: import("./index.js").CloudSourceDocumentListReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentListResponse>;
|
|
230
248
|
get: (request: import("./index.js").CloudSourceDocumentGetReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentGetResponse>;
|
|
231
249
|
create: (request: import("./index.js").CloudSourceDocumentCreateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentCreateResponse>;
|
|
232
250
|
update: (request: import("./index.js").CloudSourceDocumentUpdateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentUpdateResponse>;
|
|
251
|
+
delete: (request: import("./index.js").UnsV2SourceDocumentDeleteReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceDocumentDeleteResponse>;
|
|
252
|
+
credentials: Readonly<{
|
|
253
|
+
update: (request: import("./index.js").UnsV2SourceNativeCredentialsUpdateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceNativeCredentialsUpdateResponse>;
|
|
254
|
+
}>;
|
|
255
|
+
state: Readonly<{
|
|
256
|
+
update: (request: import("./index.js").CloudEdgeSourceStateUpdateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudEdgeSourceStateUpdateResponse>;
|
|
257
|
+
}>;
|
|
258
|
+
oauth: Readonly<{
|
|
259
|
+
start: (request: import("./index.js").UnsV2SourceNativeOAuthStartReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceNativeOAuthStartResponse>;
|
|
260
|
+
complete: (request: import("./index.js").UnsV2SourceNativeOAuthCompleteReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceNativeOAuthCompleteResponse>;
|
|
261
|
+
}>;
|
|
233
262
|
}>;
|
|
234
263
|
}>;
|
|
235
264
|
stream: Readonly<{
|
|
@@ -271,6 +300,7 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
|
|
|
271
300
|
email: string;
|
|
272
301
|
keyPrefix: string;
|
|
273
302
|
keyType: string;
|
|
303
|
+
permission?: string;
|
|
274
304
|
permissions: string[];
|
|
275
305
|
roles: string[];
|
|
276
306
|
userID: number | bigint;
|
|
@@ -335,6 +365,8 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
|
|
|
335
365
|
send: (body: import("./index.js").components["schemas"]["SdknotificationsSendRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
|
|
336
366
|
createdAt: string;
|
|
337
367
|
messageId: string;
|
|
368
|
+
recipientName?: string;
|
|
369
|
+
recipientUserId: string;
|
|
338
370
|
status: string;
|
|
339
371
|
}>;
|
|
340
372
|
get: (body: import("./index.js").components["schemas"]["SdknotificationsGetRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
|
|
@@ -344,9 +376,17 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
|
|
|
344
376
|
errorCode?: string;
|
|
345
377
|
message?: string;
|
|
346
378
|
messageId: string;
|
|
379
|
+
recipientName?: string;
|
|
380
|
+
recipientUserId: string;
|
|
347
381
|
status: string;
|
|
348
382
|
type: string;
|
|
349
383
|
}>;
|
|
384
|
+
list: (body?: import("./index.js").components["schemas"]["SdknotificationsListRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
|
|
385
|
+
list: import("./index.js").components["schemas"]["NotificationListItem"][];
|
|
386
|
+
page: number | bigint;
|
|
387
|
+
size: number | bigint;
|
|
388
|
+
total: number | bigint;
|
|
389
|
+
}>;
|
|
350
390
|
};
|
|
351
391
|
members: {
|
|
352
392
|
listWorkspace: (body?: import("./index.js").components["schemas"]["SdkmembersListWorkspaceRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
|
|
@@ -539,6 +579,7 @@ export declare const client: Readonly<{
|
|
|
539
579
|
email: string;
|
|
540
580
|
keyPrefix: string;
|
|
541
581
|
keyType: string;
|
|
582
|
+
permission?: string;
|
|
542
583
|
permissions: string[];
|
|
543
584
|
roles: string[];
|
|
544
585
|
userID: number | bigint;
|
|
@@ -570,6 +611,8 @@ export declare const client: Readonly<{
|
|
|
570
611
|
send: (body: import("./index.js").components["schemas"]["SdknotificationsSendRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
|
|
571
612
|
createdAt: string;
|
|
572
613
|
messageId: string;
|
|
614
|
+
recipientName?: string;
|
|
615
|
+
recipientUserId: string;
|
|
573
616
|
status: string;
|
|
574
617
|
}>;
|
|
575
618
|
get: (body: import("./index.js").components["schemas"]["SdknotificationsGetRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
|
|
@@ -579,9 +622,17 @@ export declare const client: Readonly<{
|
|
|
579
622
|
errorCode?: string;
|
|
580
623
|
message?: string;
|
|
581
624
|
messageId: string;
|
|
625
|
+
recipientName?: string;
|
|
626
|
+
recipientUserId: string;
|
|
582
627
|
status: string;
|
|
583
628
|
type: string;
|
|
584
629
|
}>;
|
|
630
|
+
list: (body?: import("./index.js").components["schemas"]["SdknotificationsListRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
|
|
631
|
+
list: import("./index.js").components["schemas"]["NotificationListItem"][];
|
|
632
|
+
page: number | bigint;
|
|
633
|
+
size: number | bigint;
|
|
634
|
+
total: number | bigint;
|
|
635
|
+
}>;
|
|
585
636
|
};
|
|
586
637
|
mqttAuth: {
|
|
587
638
|
create: (body: import("./index.js").components["schemas"]["SdkmqttAuthCreateRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
|
|
@@ -721,7 +772,6 @@ export declare const client: Readonly<{
|
|
|
721
772
|
files: FilesClient;
|
|
722
773
|
capabilities: CapabilitiesClient;
|
|
723
774
|
source: Readonly<{
|
|
724
|
-
delete: (request: import("./index.js").CloudSourceDeleteReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDeleteResponse>;
|
|
725
775
|
validate: (request: import("./index.js").UnsV2SourceValidateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceValidateResponse>;
|
|
726
776
|
probe: (request: import("./index.js").UnsV2SourceProbeReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceProbeResponse>;
|
|
727
777
|
discover: (request: import("./index.js").CloudSourceDiscoverReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDiscoverResponse>;
|
|
@@ -736,11 +786,30 @@ export declare const client: Readonly<{
|
|
|
736
786
|
observations: Readonly<{
|
|
737
787
|
get: (request: import("./index.js").CloudSourceObservationsGetReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceObservationsGetResponse>;
|
|
738
788
|
}>;
|
|
789
|
+
resources: Readonly<{
|
|
790
|
+
catalog: (request: import("./index.js").CloudSourceResourceCatalogReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceResourceCatalogResponse>;
|
|
791
|
+
preview: (request: import("./index.js").CloudSourceResourceReadReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceResourceReadResponse>;
|
|
792
|
+
scan: (request: import("./index.js").CloudSourceResourceScanReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceResourceScanResponse>;
|
|
793
|
+
}>;
|
|
794
|
+
devices: Readonly<{
|
|
795
|
+
list: (request: import("./index.js").CloudSourceDevicesListReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDevicesListResponse>;
|
|
796
|
+
}>;
|
|
739
797
|
documents: Readonly<{
|
|
740
798
|
list: (request: import("./index.js").CloudSourceDocumentListReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentListResponse>;
|
|
741
799
|
get: (request: import("./index.js").CloudSourceDocumentGetReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentGetResponse>;
|
|
742
800
|
create: (request: import("./index.js").CloudSourceDocumentCreateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentCreateResponse>;
|
|
743
801
|
update: (request: import("./index.js").CloudSourceDocumentUpdateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentUpdateResponse>;
|
|
802
|
+
delete: (request: import("./index.js").UnsV2SourceDocumentDeleteReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceDocumentDeleteResponse>;
|
|
803
|
+
credentials: Readonly<{
|
|
804
|
+
update: (request: import("./index.js").UnsV2SourceNativeCredentialsUpdateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceNativeCredentialsUpdateResponse>;
|
|
805
|
+
}>;
|
|
806
|
+
state: Readonly<{
|
|
807
|
+
update: (request: import("./index.js").CloudEdgeSourceStateUpdateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudEdgeSourceStateUpdateResponse>;
|
|
808
|
+
}>;
|
|
809
|
+
oauth: Readonly<{
|
|
810
|
+
start: (request: import("./index.js").UnsV2SourceNativeOAuthStartReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceNativeOAuthStartResponse>;
|
|
811
|
+
complete: (request: import("./index.js").UnsV2SourceNativeOAuthCompleteReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceNativeOAuthCompleteResponse>;
|
|
812
|
+
}>;
|
|
744
813
|
}>;
|
|
745
814
|
}>;
|
|
746
815
|
stream: Readonly<{
|
|
@@ -782,6 +851,7 @@ export declare const client: Readonly<{
|
|
|
782
851
|
email: string;
|
|
783
852
|
keyPrefix: string;
|
|
784
853
|
keyType: string;
|
|
854
|
+
permission?: string;
|
|
785
855
|
permissions: string[];
|
|
786
856
|
roles: string[];
|
|
787
857
|
userID: number | bigint;
|
|
@@ -846,6 +916,8 @@ export declare const client: Readonly<{
|
|
|
846
916
|
send: (body: import("./index.js").components["schemas"]["SdknotificationsSendRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
|
|
847
917
|
createdAt: string;
|
|
848
918
|
messageId: string;
|
|
919
|
+
recipientName?: string;
|
|
920
|
+
recipientUserId: string;
|
|
849
921
|
status: string;
|
|
850
922
|
}>;
|
|
851
923
|
get: (body: import("./index.js").components["schemas"]["SdknotificationsGetRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
|
|
@@ -855,9 +927,17 @@ export declare const client: Readonly<{
|
|
|
855
927
|
errorCode?: string;
|
|
856
928
|
message?: string;
|
|
857
929
|
messageId: string;
|
|
930
|
+
recipientName?: string;
|
|
931
|
+
recipientUserId: string;
|
|
858
932
|
status: string;
|
|
859
933
|
type: string;
|
|
860
934
|
}>;
|
|
935
|
+
list: (body?: import("./index.js").components["schemas"]["SdknotificationsListRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
|
|
936
|
+
list: import("./index.js").components["schemas"]["NotificationListItem"][];
|
|
937
|
+
page: number | bigint;
|
|
938
|
+
size: number | bigint;
|
|
939
|
+
total: number | bigint;
|
|
940
|
+
}>;
|
|
861
941
|
};
|
|
862
942
|
members: {
|
|
863
943
|
listWorkspace: (body?: import("./index.js").components["schemas"]["SdkmembersListWorkspaceRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
|
package/dist/esm/client.js
CHANGED
|
@@ -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
|
-
|
|
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(
|
|
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(
|
|
49
|
+
export const client = assemble(getClient, {}, defaultHttp);
|
|
52
50
|
//# sourceMappingURL=client.js.map
|
package/dist/esm/client.js.map
CHANGED
|
@@ -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;
|
|
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,EAAE,oBAAoB,EAAqB,MAAM,qBAAqB,CAAC;AACrG,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM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AE;IACzD,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7D,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,SAAS,EAAE,EAAE,EAAE,WAAW,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, 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
|
-
|
|
2
|
-
export declare
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
readonly
|
|
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
|
|
12
|
-
|
|
13
|
-
readonly
|
|
14
|
-
|
|
15
|
-
readonly
|
|
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
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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;
|