@lazycatcloud/sdk 0.1.142 → 0.1.144
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/common/box.ts +545 -0
- package/common/browseronly.ts +520 -0
- package/common/end_device.ts +635 -0
- package/common/file_handler.ts +485 -0
- package/common/filetrans.ts +1936 -0
- package/common/gateway.ts +663 -0
- package/common/media_meta.ts +319 -0
- package/common/message.ts +242 -0
- package/common/peripheral_device.ts +783 -0
- package/common/security_context.ts +729 -0
- package/common/users.ts +1044 -0
- package/dist/common/box.d.ts +1 -1
- package/dist/common/box.d.ts.map +1 -1
- package/dist/common/box.js +21 -37
- package/dist/common/box.js.map +1 -1
- package/dist/common/browseronly.d.ts +2 -2
- package/dist/common/browseronly.d.ts.map +1 -1
- package/dist/common/browseronly.js +12 -23
- package/dist/common/browseronly.js.map +1 -1
- package/dist/common/end_device.d.ts +2 -2
- package/dist/common/end_device.d.ts.map +1 -1
- package/dist/common/end_device.js +18 -41
- package/dist/common/end_device.js.map +1 -1
- package/dist/common/file_handler.d.ts.map +1 -1
- package/dist/common/file_handler.js +5 -15
- package/dist/common/file_handler.js.map +1 -1
- package/dist/common/filetrans.d.ts +2 -2
- package/dist/common/filetrans.d.ts.map +1 -1
- package/dist/common/filetrans.js +94 -221
- package/dist/common/filetrans.js.map +1 -1
- package/dist/common/gateway.d.ts +1 -1
- package/dist/common/gateway.d.ts.map +1 -1
- package/dist/common/gateway.js +14 -33
- package/dist/common/gateway.js.map +1 -1
- package/dist/common/media_meta.d.ts +85 -0
- package/dist/common/media_meta.d.ts.map +1 -0
- package/dist/common/media_meta.js +233 -0
- package/dist/common/media_meta.js.map +1 -0
- package/dist/common/message.d.ts.map +1 -1
- package/dist/common/message.js +13 -23
- package/dist/common/message.js.map +1 -1
- package/dist/common/peripheral_device.d.ts +2 -2
- package/dist/common/peripheral_device.d.ts.map +1 -1
- package/dist/common/peripheral_device.js +22 -39
- package/dist/common/peripheral_device.js.map +1 -1
- package/dist/common/security_context.d.ts.map +1 -1
- package/dist/common/security_context.js +11 -33
- package/dist/common/security_context.js.map +1 -1
- package/dist/common/users.d.ts +2 -2
- package/dist/common/users.d.ts.map +1 -1
- package/dist/common/users.js +10 -24
- package/dist/common/users.js.map +1 -1
- package/dist/dlna/dlna.d.ts +2 -2
- package/dist/dlna/dlna.d.ts.map +1 -1
- package/dist/dlna/dlna.js +23 -58
- package/dist/dlna/dlna.js.map +1 -1
- package/dist/extentions/app_common.d.ts +1 -1
- package/dist/extentions/app_common.d.ts.map +1 -1
- package/dist/extentions/app_common.js +21 -8
- package/dist/extentions/app_common.js.map +1 -1
- package/dist/extentions/index.d.ts +1 -1
- package/dist/extentions/index.d.ts.map +1 -1
- package/dist/extentions/unsafe_app.d.ts +3 -0
- package/dist/extentions/unsafe_app.d.ts.map +1 -1
- package/dist/extentions/unsafe_app.js +21 -0
- package/dist/extentions/unsafe_app.js.map +1 -1
- package/dist/google/protobuf/descriptor.d.ts +0 -1
- package/dist/google/protobuf/descriptor.d.ts.map +1 -1
- package/dist/google/protobuf/descriptor.js +176 -406
- package/dist/google/protobuf/descriptor.js.map +1 -1
- package/dist/google/protobuf/empty.d.ts.map +1 -1
- package/dist/google/protobuf/empty.js.map +1 -1
- package/dist/google/protobuf/timestamp.d.ts +0 -2
- package/dist/google/protobuf/timestamp.d.ts.map +1 -1
- package/dist/google/protobuf/timestamp.js +9 -6
- package/dist/google/protobuf/timestamp.js.map +1 -1
- package/dist/lanforward/lanforward.d.ts +1 -1
- package/dist/lanforward/lanforward.d.ts.map +1 -1
- package/dist/lanforward/lanforward.js +7 -12
- package/dist/lanforward/lanforward.js.map +1 -1
- package/dist/localdevice/clipboard.d.ts +1 -1
- package/dist/localdevice/clipboard.d.ts.map +1 -1
- package/dist/localdevice/clipboard.js +17 -25
- package/dist/localdevice/clipboard.js.map +1 -1
- package/dist/localdevice/config.d.ts.map +1 -1
- package/dist/localdevice/config.js +3 -8
- package/dist/localdevice/config.js.map +1 -1
- package/dist/localdevice/device.d.ts +1 -1
- package/dist/localdevice/device.d.ts.map +1 -1
- package/dist/localdevice/device.js +4 -9
- package/dist/localdevice/device.js.map +1 -1
- package/dist/localdevice/dialog.d.ts +1 -1
- package/dist/localdevice/dialog.d.ts.map +1 -1
- package/dist/localdevice/dialog.js +8 -22
- package/dist/localdevice/dialog.js.map +1 -1
- package/dist/localdevice/local-launch.d.ts.map +1 -1
- package/dist/localdevice/local-launch.js +9 -32
- package/dist/localdevice/local-launch.js.map +1 -1
- package/dist/localdevice/network.d.ts +1 -1
- package/dist/localdevice/network.d.ts.map +1 -1
- package/dist/localdevice/network.js +3 -6
- package/dist/localdevice/network.js.map +1 -1
- package/dist/localdevice/permission.d.ts +1 -1
- package/dist/localdevice/permission.d.ts.map +1 -1
- package/dist/localdevice/permission.js +18 -35
- package/dist/localdevice/permission.js.map +1 -1
- package/dist/localdevice/photo.d.ts +1 -1
- package/dist/localdevice/photo.d.ts.map +1 -1
- package/dist/localdevice/photo.js +64 -156
- package/dist/localdevice/photo.js.map +1 -1
- package/dist/package.json +1 -5
- package/dist/ssdp/ssdp.d.ts +1 -1
- package/dist/ssdp/ssdp.d.ts.map +1 -1
- package/dist/ssdp/ssdp.js +6 -9
- package/dist/ssdp/ssdp.js.map +1 -1
- package/dist/sys/OS_daemon.d.ts +1 -1
- package/dist/sys/OS_daemon.d.ts.map +1 -1
- package/dist/sys/OS_daemon.js +5 -14
- package/dist/sys/OS_daemon.js.map +1 -1
- package/dist/sys/OS_snapshot.d.ts +1 -1
- package/dist/sys/OS_snapshot.d.ts.map +1 -1
- package/dist/sys/OS_snapshot.js +41 -81
- package/dist/sys/OS_snapshot.js.map +1 -1
- package/dist/sys/OS_upgrader.d.ts +1 -1
- package/dist/sys/OS_upgrader.d.ts.map +1 -1
- package/dist/sys/OS_upgrader.js +22 -39
- package/dist/sys/OS_upgrader.js.map +1 -1
- package/dist/sys/btrfs.d.ts +1 -1
- package/dist/sys/btrfs.d.ts.map +1 -1
- package/dist/sys/btrfs.js +14 -22
- package/dist/sys/btrfs.js.map +1 -1
- package/dist/sys/devopt.d.ts +1 -1
- package/dist/sys/devopt.d.ts.map +1 -1
- package/dist/sys/devopt.js +9 -25
- package/dist/sys/devopt.js.map +1 -1
- package/dist/sys/event.d.ts +2 -2
- package/dist/sys/event.d.ts.map +1 -1
- package/dist/sys/event.js +15 -30
- package/dist/sys/event.js.map +1 -1
- package/dist/sys/hc-core/hc-core.d.ts +2 -2
- package/dist/sys/hc-core/hc-core.d.ts.map +1 -1
- package/dist/sys/hc-core/hc-core.js +32 -65
- package/dist/sys/hc-core/hc-core.js.map +1 -1
- package/dist/sys/ingress.d.ts +1 -1
- package/dist/sys/ingress.d.ts.map +1 -1
- package/dist/sys/ingress.js +19 -36
- package/dist/sys/ingress.js.map +1 -1
- package/dist/sys/network_manager.d.ts +1 -1
- package/dist/sys/network_manager.d.ts.map +1 -1
- package/dist/sys/network_manager.js +22 -66
- package/dist/sys/network_manager.js.map +1 -1
- package/dist/sys/package_manager.d.ts +1 -1
- package/dist/sys/package_manager.d.ts.map +1 -1
- package/dist/sys/package_manager.js +36 -73
- package/dist/sys/package_manager.js.map +1 -1
- package/dist/sys/portal-server/portal-server.d.ts +2 -2
- package/dist/sys/portal-server/portal-server.d.ts.map +1 -1
- package/dist/sys/portal-server/portal-server.js +62 -157
- package/dist/sys/portal-server/portal-server.js.map +1 -1
- package/dist/sys/snapd.d.ts +1 -1
- package/dist/sys/snapd.d.ts.map +1 -1
- package/dist/sys/snapd.js +20 -50
- package/dist/sys/snapd.js.map +1 -1
- package/dlna/dlna.ts +895 -0
- package/docs/contribute.md +40 -0
- package/docs/extentions/AppCommon.md +30 -0
- package/extentions/app_common.ts +63 -0
- package/extentions/base.ts +459 -0
- package/extentions/index.ts +27 -0
- package/extentions/safe_app.ts +60 -0
- package/extentions/unsafe_app.ts +107 -0
- package/google/protobuf/descriptor.ts +3778 -0
- package/google/protobuf/empty.ts +64 -0
- package/google/protobuf/timestamp.ts +214 -0
- package/grpcweb.ts +106 -0
- package/index.ts +204 -0
- package/lanforward/lanforward.ts +301 -0
- package/localdevice/clipboard.ts +499 -0
- package/localdevice/config.ts +268 -0
- package/localdevice/device.ts +218 -0
- package/localdevice/dialog.ts +707 -0
- package/localdevice/local-launch.ts +954 -0
- package/localdevice/network.ts +273 -0
- package/localdevice/permission.ts +733 -0
- package/localdevice/photo.ts +1497 -0
- package/package.json +1 -5
- package/ssdp/ssdp.ts +332 -0
- package/sys/OS_daemon.ts +325 -0
- package/sys/OS_snapshot.ts +1714 -0
- package/sys/OS_upgrader.ts +782 -0
- package/sys/btrfs.ts +530 -0
- package/sys/devopt.ts +250 -0
- package/sys/event.ts +787 -0
- package/sys/hc-core/hc-core.ts +1582 -0
- package/sys/ingress.ts +953 -0
- package/sys/network_manager.ts +874 -0
- package/sys/package_manager.ts +1931 -0
- package/sys/portal-server/portal-server.ts +2934 -0
- package/sys/snapd.ts +861 -0
- package/tsconfig.json +15 -0
- package/dist/API.d.ts +0 -24
- package/dist/API.d.ts.map +0 -1
- package/dist/API.js +0 -117
- package/dist/API.js.map +0 -1
- package/dist/google/protobuf/wrappers.d.ts +0 -182
- package/dist/google/protobuf/wrappers.d.ts.map +0 -1
- package/dist/google/protobuf/wrappers.js +0 -458
- package/dist/google/protobuf/wrappers.js.map +0 -1
- package/dist/sys/message.d.ts +0 -186
- package/dist/sys/message.d.ts.map +0 -1
- package/dist/sys/message.js +0 -493
- package/dist/sys/message.js.map +0 -1
- package/dist/sys/settings.d.ts +0 -68
- package/dist/sys/settings.d.ts.map +0 -1
- package/dist/sys/settings.js +0 -183
- package/dist/sys/settings.js.map +0 -1
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import { grpc } from "@improbable-eng/grpc-web";
|
|
3
|
+
import { BrowserHeaders } from "browser-headers";
|
|
4
|
+
import _m0 from "protobufjs/minimal";
|
|
5
|
+
import { Observable } from "rxjs";
|
|
6
|
+
import { share } from "rxjs/operators";
|
|
7
|
+
import { Empty } from "../google/protobuf/empty";
|
|
8
|
+
import { Timestamp } from "../google/protobuf/timestamp";
|
|
9
|
+
|
|
10
|
+
export interface APIServerInfo {
|
|
11
|
+
frontendVersion: string;
|
|
12
|
+
backendVersion: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface SessionInfo {
|
|
16
|
+
/** 当前登陆用户 */
|
|
17
|
+
uid: string;
|
|
18
|
+
/** 当前登陆设备 */
|
|
19
|
+
deviceId: string;
|
|
20
|
+
when: Date | undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface AppInfo {
|
|
24
|
+
boxId: string;
|
|
25
|
+
appId: string;
|
|
26
|
+
appDomain: string;
|
|
27
|
+
/**
|
|
28
|
+
* APIGateway对所有而http service服务强制要求设置http header类型的
|
|
29
|
+
* AuthInfo. 但有些场景无法使用XHR去设置自定义的http header,导致访问
|
|
30
|
+
* 这些服务很困难,因此由/usr/bin/lzcapp统一提供一个代理服务来设置这个
|
|
31
|
+
* header. 此字段即是对应代理出来的URL前缀。默认为"/_lzc",可以通过启动
|
|
32
|
+
* 参数调整。
|
|
33
|
+
*/
|
|
34
|
+
httpApiProxyPath: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function createBaseAPIServerInfo(): APIServerInfo {
|
|
38
|
+
return { frontendVersion: "", backendVersion: "" };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const APIServerInfo = {
|
|
42
|
+
encode(message: APIServerInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
43
|
+
if (message.frontendVersion !== "") {
|
|
44
|
+
writer.uint32(10).string(message.frontendVersion);
|
|
45
|
+
}
|
|
46
|
+
if (message.backendVersion !== "") {
|
|
47
|
+
writer.uint32(18).string(message.backendVersion);
|
|
48
|
+
}
|
|
49
|
+
return writer;
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): APIServerInfo {
|
|
53
|
+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
54
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
55
|
+
const message = createBaseAPIServerInfo();
|
|
56
|
+
while (reader.pos < end) {
|
|
57
|
+
const tag = reader.uint32();
|
|
58
|
+
switch (tag >>> 3) {
|
|
59
|
+
case 1:
|
|
60
|
+
message.frontendVersion = reader.string();
|
|
61
|
+
break;
|
|
62
|
+
case 2:
|
|
63
|
+
message.backendVersion = reader.string();
|
|
64
|
+
break;
|
|
65
|
+
default:
|
|
66
|
+
reader.skipType(tag & 7);
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return message;
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
fromJSON(object: any): APIServerInfo {
|
|
74
|
+
return {
|
|
75
|
+
frontendVersion: isSet(object.frontendVersion) ? String(object.frontendVersion) : "",
|
|
76
|
+
backendVersion: isSet(object.backendVersion) ? String(object.backendVersion) : "",
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
toJSON(message: APIServerInfo): unknown {
|
|
81
|
+
const obj: any = {};
|
|
82
|
+
message.frontendVersion !== undefined && (obj.frontendVersion = message.frontendVersion);
|
|
83
|
+
message.backendVersion !== undefined && (obj.backendVersion = message.backendVersion);
|
|
84
|
+
return obj;
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
fromPartial<I extends Exact<DeepPartial<APIServerInfo>, I>>(object: I): APIServerInfo {
|
|
88
|
+
const message = createBaseAPIServerInfo();
|
|
89
|
+
message.frontendVersion = object.frontendVersion ?? "";
|
|
90
|
+
message.backendVersion = object.backendVersion ?? "";
|
|
91
|
+
return message;
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
function createBaseSessionInfo(): SessionInfo {
|
|
96
|
+
return { uid: "", deviceId: "", when: undefined };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export const SessionInfo = {
|
|
100
|
+
encode(message: SessionInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
101
|
+
if (message.uid !== "") {
|
|
102
|
+
writer.uint32(10).string(message.uid);
|
|
103
|
+
}
|
|
104
|
+
if (message.deviceId !== "") {
|
|
105
|
+
writer.uint32(18).string(message.deviceId);
|
|
106
|
+
}
|
|
107
|
+
if (message.when !== undefined) {
|
|
108
|
+
Timestamp.encode(toTimestamp(message.when), writer.uint32(26).fork()).ldelim();
|
|
109
|
+
}
|
|
110
|
+
return writer;
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): SessionInfo {
|
|
114
|
+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
115
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
116
|
+
const message = createBaseSessionInfo();
|
|
117
|
+
while (reader.pos < end) {
|
|
118
|
+
const tag = reader.uint32();
|
|
119
|
+
switch (tag >>> 3) {
|
|
120
|
+
case 1:
|
|
121
|
+
message.uid = reader.string();
|
|
122
|
+
break;
|
|
123
|
+
case 2:
|
|
124
|
+
message.deviceId = reader.string();
|
|
125
|
+
break;
|
|
126
|
+
case 3:
|
|
127
|
+
message.when = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
|
|
128
|
+
break;
|
|
129
|
+
default:
|
|
130
|
+
reader.skipType(tag & 7);
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return message;
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
fromJSON(object: any): SessionInfo {
|
|
138
|
+
return {
|
|
139
|
+
uid: isSet(object.uid) ? String(object.uid) : "",
|
|
140
|
+
deviceId: isSet(object.deviceId) ? String(object.deviceId) : "",
|
|
141
|
+
when: isSet(object.when) ? fromJsonTimestamp(object.when) : undefined,
|
|
142
|
+
};
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
toJSON(message: SessionInfo): unknown {
|
|
146
|
+
const obj: any = {};
|
|
147
|
+
message.uid !== undefined && (obj.uid = message.uid);
|
|
148
|
+
message.deviceId !== undefined && (obj.deviceId = message.deviceId);
|
|
149
|
+
message.when !== undefined && (obj.when = message.when.toISOString());
|
|
150
|
+
return obj;
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
fromPartial<I extends Exact<DeepPartial<SessionInfo>, I>>(object: I): SessionInfo {
|
|
154
|
+
const message = createBaseSessionInfo();
|
|
155
|
+
message.uid = object.uid ?? "";
|
|
156
|
+
message.deviceId = object.deviceId ?? "";
|
|
157
|
+
message.when = object.when ?? undefined;
|
|
158
|
+
return message;
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
function createBaseAppInfo(): AppInfo {
|
|
163
|
+
return { boxId: "", appId: "", appDomain: "", httpApiProxyPath: "" };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export const AppInfo = {
|
|
167
|
+
encode(message: AppInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
168
|
+
if (message.boxId !== "") {
|
|
169
|
+
writer.uint32(10).string(message.boxId);
|
|
170
|
+
}
|
|
171
|
+
if (message.appId !== "") {
|
|
172
|
+
writer.uint32(18).string(message.appId);
|
|
173
|
+
}
|
|
174
|
+
if (message.appDomain !== "") {
|
|
175
|
+
writer.uint32(26).string(message.appDomain);
|
|
176
|
+
}
|
|
177
|
+
if (message.httpApiProxyPath !== "") {
|
|
178
|
+
writer.uint32(34).string(message.httpApiProxyPath);
|
|
179
|
+
}
|
|
180
|
+
return writer;
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): AppInfo {
|
|
184
|
+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
185
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
186
|
+
const message = createBaseAppInfo();
|
|
187
|
+
while (reader.pos < end) {
|
|
188
|
+
const tag = reader.uint32();
|
|
189
|
+
switch (tag >>> 3) {
|
|
190
|
+
case 1:
|
|
191
|
+
message.boxId = reader.string();
|
|
192
|
+
break;
|
|
193
|
+
case 2:
|
|
194
|
+
message.appId = reader.string();
|
|
195
|
+
break;
|
|
196
|
+
case 3:
|
|
197
|
+
message.appDomain = reader.string();
|
|
198
|
+
break;
|
|
199
|
+
case 4:
|
|
200
|
+
message.httpApiProxyPath = reader.string();
|
|
201
|
+
break;
|
|
202
|
+
default:
|
|
203
|
+
reader.skipType(tag & 7);
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return message;
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
fromJSON(object: any): AppInfo {
|
|
211
|
+
return {
|
|
212
|
+
boxId: isSet(object.boxId) ? String(object.boxId) : "",
|
|
213
|
+
appId: isSet(object.appId) ? String(object.appId) : "",
|
|
214
|
+
appDomain: isSet(object.appDomain) ? String(object.appDomain) : "",
|
|
215
|
+
httpApiProxyPath: isSet(object.httpApiProxyPath) ? String(object.httpApiProxyPath) : "",
|
|
216
|
+
};
|
|
217
|
+
},
|
|
218
|
+
|
|
219
|
+
toJSON(message: AppInfo): unknown {
|
|
220
|
+
const obj: any = {};
|
|
221
|
+
message.boxId !== undefined && (obj.boxId = message.boxId);
|
|
222
|
+
message.appId !== undefined && (obj.appId = message.appId);
|
|
223
|
+
message.appDomain !== undefined && (obj.appDomain = message.appDomain);
|
|
224
|
+
message.httpApiProxyPath !== undefined && (obj.httpApiProxyPath = message.httpApiProxyPath);
|
|
225
|
+
return obj;
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
fromPartial<I extends Exact<DeepPartial<AppInfo>, I>>(object: I): AppInfo {
|
|
229
|
+
const message = createBaseAppInfo();
|
|
230
|
+
message.boxId = object.boxId ?? "";
|
|
231
|
+
message.appId = object.appId ?? "";
|
|
232
|
+
message.appDomain = object.appDomain ?? "";
|
|
233
|
+
message.httpApiProxyPath = object.httpApiProxyPath ?? "";
|
|
234
|
+
return message;
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
/** this service is provied by frontend server, backend code shouldn't use it. */
|
|
239
|
+
export interface BrowserOnlyProxy {
|
|
240
|
+
/** 查询当前登陆用户对应信息 */
|
|
241
|
+
QuerySessionInfo(request: DeepPartial<Empty>, metadata?: grpc.Metadata): Promise<SessionInfo>;
|
|
242
|
+
/** 查询当前访问的lzcapp对应信息 */
|
|
243
|
+
QueryAppInfo(request: DeepPartial<Empty>, metadata?: grpc.Metadata): Promise<AppInfo>;
|
|
244
|
+
/** 对devices.proto:_PairAllDeivces的自动封装 */
|
|
245
|
+
PairAllDevices(request: DeepPartial<Empty>, metadata?: grpc.Metadata): Observable<Empty>;
|
|
246
|
+
QueryAPIServerInfo(request: DeepPartial<Empty>, metadata?: grpc.Metadata): Promise<APIServerInfo>;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export class BrowserOnlyProxyClientImpl implements BrowserOnlyProxy {
|
|
250
|
+
private readonly rpc: Rpc;
|
|
251
|
+
|
|
252
|
+
constructor(rpc: Rpc) {
|
|
253
|
+
this.rpc = rpc;
|
|
254
|
+
this.QuerySessionInfo = this.QuerySessionInfo.bind(this);
|
|
255
|
+
this.QueryAppInfo = this.QueryAppInfo.bind(this);
|
|
256
|
+
this.PairAllDevices = this.PairAllDevices.bind(this);
|
|
257
|
+
this.QueryAPIServerInfo = this.QueryAPIServerInfo.bind(this);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
QuerySessionInfo(request: DeepPartial<Empty>, metadata?: grpc.Metadata): Promise<SessionInfo> {
|
|
261
|
+
return this.rpc.unary(BrowserOnlyProxyQuerySessionInfoDesc, Empty.fromPartial(request), metadata);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
QueryAppInfo(request: DeepPartial<Empty>, metadata?: grpc.Metadata): Promise<AppInfo> {
|
|
265
|
+
return this.rpc.unary(BrowserOnlyProxyQueryAppInfoDesc, Empty.fromPartial(request), metadata);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
PairAllDevices(request: DeepPartial<Empty>, metadata?: grpc.Metadata): Observable<Empty> {
|
|
269
|
+
return this.rpc.invoke(BrowserOnlyProxyPairAllDevicesDesc, Empty.fromPartial(request), metadata);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
QueryAPIServerInfo(request: DeepPartial<Empty>, metadata?: grpc.Metadata): Promise<APIServerInfo> {
|
|
273
|
+
return this.rpc.unary(BrowserOnlyProxyQueryAPIServerInfoDesc, Empty.fromPartial(request), metadata);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export const BrowserOnlyProxyDesc = { serviceName: "cloud.lazycat.apis.common.BrowserOnlyProxy" };
|
|
278
|
+
|
|
279
|
+
export const BrowserOnlyProxyQuerySessionInfoDesc: UnaryMethodDefinitionish = {
|
|
280
|
+
methodName: "QuerySessionInfo",
|
|
281
|
+
service: BrowserOnlyProxyDesc,
|
|
282
|
+
requestStream: false,
|
|
283
|
+
responseStream: false,
|
|
284
|
+
requestType: {
|
|
285
|
+
serializeBinary() {
|
|
286
|
+
return Empty.encode(this).finish();
|
|
287
|
+
},
|
|
288
|
+
} as any,
|
|
289
|
+
responseType: {
|
|
290
|
+
deserializeBinary(data: Uint8Array) {
|
|
291
|
+
return {
|
|
292
|
+
...SessionInfo.decode(data),
|
|
293
|
+
toObject() {
|
|
294
|
+
return this;
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
},
|
|
298
|
+
} as any,
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
export const BrowserOnlyProxyQueryAppInfoDesc: UnaryMethodDefinitionish = {
|
|
302
|
+
methodName: "QueryAppInfo",
|
|
303
|
+
service: BrowserOnlyProxyDesc,
|
|
304
|
+
requestStream: false,
|
|
305
|
+
responseStream: false,
|
|
306
|
+
requestType: {
|
|
307
|
+
serializeBinary() {
|
|
308
|
+
return Empty.encode(this).finish();
|
|
309
|
+
},
|
|
310
|
+
} as any,
|
|
311
|
+
responseType: {
|
|
312
|
+
deserializeBinary(data: Uint8Array) {
|
|
313
|
+
return {
|
|
314
|
+
...AppInfo.decode(data),
|
|
315
|
+
toObject() {
|
|
316
|
+
return this;
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
},
|
|
320
|
+
} as any,
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
export const BrowserOnlyProxyPairAllDevicesDesc: UnaryMethodDefinitionish = {
|
|
324
|
+
methodName: "PairAllDevices",
|
|
325
|
+
service: BrowserOnlyProxyDesc,
|
|
326
|
+
requestStream: false,
|
|
327
|
+
responseStream: true,
|
|
328
|
+
requestType: {
|
|
329
|
+
serializeBinary() {
|
|
330
|
+
return Empty.encode(this).finish();
|
|
331
|
+
},
|
|
332
|
+
} as any,
|
|
333
|
+
responseType: {
|
|
334
|
+
deserializeBinary(data: Uint8Array) {
|
|
335
|
+
return {
|
|
336
|
+
...Empty.decode(data),
|
|
337
|
+
toObject() {
|
|
338
|
+
return this;
|
|
339
|
+
},
|
|
340
|
+
};
|
|
341
|
+
},
|
|
342
|
+
} as any,
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
export const BrowserOnlyProxyQueryAPIServerInfoDesc: UnaryMethodDefinitionish = {
|
|
346
|
+
methodName: "QueryAPIServerInfo",
|
|
347
|
+
service: BrowserOnlyProxyDesc,
|
|
348
|
+
requestStream: false,
|
|
349
|
+
responseStream: false,
|
|
350
|
+
requestType: {
|
|
351
|
+
serializeBinary() {
|
|
352
|
+
return Empty.encode(this).finish();
|
|
353
|
+
},
|
|
354
|
+
} as any,
|
|
355
|
+
responseType: {
|
|
356
|
+
deserializeBinary(data: Uint8Array) {
|
|
357
|
+
return {
|
|
358
|
+
...APIServerInfo.decode(data),
|
|
359
|
+
toObject() {
|
|
360
|
+
return this;
|
|
361
|
+
},
|
|
362
|
+
};
|
|
363
|
+
},
|
|
364
|
+
} as any,
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
interface UnaryMethodDefinitionishR extends grpc.UnaryMethodDefinition<any, any> {
|
|
368
|
+
requestStream: any;
|
|
369
|
+
responseStream: any;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
type UnaryMethodDefinitionish = UnaryMethodDefinitionishR;
|
|
373
|
+
|
|
374
|
+
interface Rpc {
|
|
375
|
+
unary<T extends UnaryMethodDefinitionish>(
|
|
376
|
+
methodDesc: T,
|
|
377
|
+
request: any,
|
|
378
|
+
metadata: grpc.Metadata | undefined,
|
|
379
|
+
): Promise<any>;
|
|
380
|
+
invoke<T extends UnaryMethodDefinitionish>(
|
|
381
|
+
methodDesc: T,
|
|
382
|
+
request: any,
|
|
383
|
+
metadata: grpc.Metadata | undefined,
|
|
384
|
+
): Observable<any>;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export class GrpcWebImpl {
|
|
388
|
+
private host: string;
|
|
389
|
+
private options: {
|
|
390
|
+
transport?: grpc.TransportFactory;
|
|
391
|
+
streamingTransport?: grpc.TransportFactory;
|
|
392
|
+
debug?: boolean;
|
|
393
|
+
metadata?: grpc.Metadata;
|
|
394
|
+
upStreamRetryCodes?: number[];
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
constructor(
|
|
398
|
+
host: string,
|
|
399
|
+
options: {
|
|
400
|
+
transport?: grpc.TransportFactory;
|
|
401
|
+
streamingTransport?: grpc.TransportFactory;
|
|
402
|
+
debug?: boolean;
|
|
403
|
+
metadata?: grpc.Metadata;
|
|
404
|
+
upStreamRetryCodes?: number[];
|
|
405
|
+
},
|
|
406
|
+
) {
|
|
407
|
+
this.host = host;
|
|
408
|
+
this.options = options;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
unary<T extends UnaryMethodDefinitionish>(
|
|
412
|
+
methodDesc: T,
|
|
413
|
+
_request: any,
|
|
414
|
+
metadata: grpc.Metadata | undefined,
|
|
415
|
+
): Promise<any> {
|
|
416
|
+
const request = { ..._request, ...methodDesc.requestType };
|
|
417
|
+
const maybeCombinedMetadata = metadata && this.options.metadata
|
|
418
|
+
? new BrowserHeaders({ ...this.options?.metadata.headersMap, ...metadata?.headersMap })
|
|
419
|
+
: metadata || this.options.metadata;
|
|
420
|
+
return new Promise((resolve, reject) => {
|
|
421
|
+
grpc.unary(methodDesc, {
|
|
422
|
+
request,
|
|
423
|
+
host: this.host,
|
|
424
|
+
metadata: maybeCombinedMetadata,
|
|
425
|
+
transport: this.options.transport,
|
|
426
|
+
debug: this.options.debug,
|
|
427
|
+
onEnd: function (response) {
|
|
428
|
+
if (response.status === grpc.Code.OK) {
|
|
429
|
+
resolve(response.message);
|
|
430
|
+
} else {
|
|
431
|
+
const err = new GrpcWebError(response.statusMessage, response.status, response.trailers);
|
|
432
|
+
reject(err);
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
invoke<T extends UnaryMethodDefinitionish>(
|
|
440
|
+
methodDesc: T,
|
|
441
|
+
_request: any,
|
|
442
|
+
metadata: grpc.Metadata | undefined,
|
|
443
|
+
): Observable<any> {
|
|
444
|
+
const upStreamCodes = this.options.upStreamRetryCodes || [];
|
|
445
|
+
const DEFAULT_TIMEOUT_TIME: number = 3_000;
|
|
446
|
+
const request = { ..._request, ...methodDesc.requestType };
|
|
447
|
+
const maybeCombinedMetadata = metadata && this.options.metadata
|
|
448
|
+
? new BrowserHeaders({ ...this.options?.metadata.headersMap, ...metadata?.headersMap })
|
|
449
|
+
: metadata || this.options.metadata;
|
|
450
|
+
return new Observable((observer) => {
|
|
451
|
+
const upStream = (() => {
|
|
452
|
+
const client = grpc.invoke(methodDesc, {
|
|
453
|
+
host: this.host,
|
|
454
|
+
request,
|
|
455
|
+
transport: this.options.streamingTransport || this.options.transport,
|
|
456
|
+
metadata: maybeCombinedMetadata,
|
|
457
|
+
debug: this.options.debug,
|
|
458
|
+
onMessage: (next) => observer.next(next),
|
|
459
|
+
onEnd: (code: grpc.Code, message: string, trailers: grpc.Metadata) => {
|
|
460
|
+
if (code === 0) {
|
|
461
|
+
observer.complete();
|
|
462
|
+
} else if (upStreamCodes.includes(code)) {
|
|
463
|
+
setTimeout(upStream, DEFAULT_TIMEOUT_TIME);
|
|
464
|
+
} else {
|
|
465
|
+
const err = new Error(message) as any;
|
|
466
|
+
err.code = code;
|
|
467
|
+
err.metadata = trailers;
|
|
468
|
+
observer.error(err);
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
});
|
|
472
|
+
observer.add(() => client.close());
|
|
473
|
+
});
|
|
474
|
+
upStream();
|
|
475
|
+
}).pipe(share());
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
480
|
+
|
|
481
|
+
type DeepPartial<T> = T extends Builtin ? T
|
|
482
|
+
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
|
483
|
+
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
484
|
+
: Partial<T>;
|
|
485
|
+
|
|
486
|
+
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
487
|
+
type Exact<P, I extends P> = P extends Builtin ? P
|
|
488
|
+
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
|
|
489
|
+
|
|
490
|
+
function toTimestamp(date: Date): Timestamp {
|
|
491
|
+
const seconds = date.getTime() / 1_000;
|
|
492
|
+
const nanos = (date.getTime() % 1_000) * 1_000_000;
|
|
493
|
+
return { seconds, nanos };
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function fromTimestamp(t: Timestamp): Date {
|
|
497
|
+
let millis = t.seconds * 1_000;
|
|
498
|
+
millis += t.nanos / 1_000_000;
|
|
499
|
+
return new Date(millis);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function fromJsonTimestamp(o: any): Date {
|
|
503
|
+
if (o instanceof Date) {
|
|
504
|
+
return o;
|
|
505
|
+
} else if (typeof o === "string") {
|
|
506
|
+
return new Date(o);
|
|
507
|
+
} else {
|
|
508
|
+
return fromTimestamp(Timestamp.fromJSON(o));
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
function isSet(value: any): boolean {
|
|
513
|
+
return value !== null && value !== undefined;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
export class GrpcWebError extends Error {
|
|
517
|
+
constructor(message: string, public code: grpc.Code, public metadata: grpc.Metadata) {
|
|
518
|
+
super(message);
|
|
519
|
+
}
|
|
520
|
+
}
|