@fatagnus/dink-sdk 2.6.0 → 2.8.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.
- package/dist/center/client.d.ts +72 -1
- package/dist/center/client.d.ts.map +1 -1
- package/dist/center/client.js +197 -0
- package/dist/center/client.js.map +1 -1
- package/dist/index.d.ts +5 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +197 -54
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +22 -1
- package/dist/types.js.map +1 -1
- package/package.json +5 -1
- package/dist/generated/index.d.ts +0 -8
- package/dist/generated/index.d.ts.map +0 -1
- package/dist/generated/index.js +0 -7
- package/dist/generated/index.js.map +0 -1
- package/dist/generated/jobservice.client.d.ts +0 -19
- package/dist/generated/jobservice.client.d.ts.map +0 -1
- package/dist/generated/jobservice.client.js +0 -39
- package/dist/generated/jobservice.client.js.map +0 -1
- package/dist/generated/jobservice.handler.d.ts +0 -21
- package/dist/generated/jobservice.handler.d.ts.map +0 -1
- package/dist/generated/jobservice.handler.js +0 -62
- package/dist/generated/jobservice.handler.js.map +0 -1
- package/dist/generated/sensorservice.client.d.ts +0 -17
- package/dist/generated/sensorservice.client.d.ts.map +0 -1
- package/dist/generated/sensorservice.client.js +0 -31
- package/dist/generated/sensorservice.client.js.map +0 -1
- package/dist/generated/sensorservice.handler.d.ts +0 -17
- package/dist/generated/sensorservice.handler.d.ts.map +0 -1
- package/dist/generated/sensorservice.handler.js +0 -53
- package/dist/generated/sensorservice.handler.js.map +0 -1
- package/dist/generated/types.d.ts +0 -99
- package/dist/generated/types.d.ts.map +0 -1
- package/dist/generated/types.js +0 -12
- package/dist/generated/types.js.map +0 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,101 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service definition metadata
|
|
3
|
+
*/
|
|
4
|
+
export interface ServiceDefinition {
|
|
5
|
+
name: string;
|
|
6
|
+
version: string;
|
|
7
|
+
methods: string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Interface for implementing a service handler on the edge
|
|
11
|
+
*/
|
|
12
|
+
export interface ServiceHandler {
|
|
13
|
+
definition(): ServiceDefinition;
|
|
14
|
+
handleRequest(method: string, data: Uint8Array): Promise<Uint8Array>;
|
|
15
|
+
handleStream?(method: string, data: Uint8Array, emit: (data: Uint8Array) => Promise<void>): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Interface for making RPC calls to edge services
|
|
19
|
+
*/
|
|
20
|
+
export interface ServiceCaller {
|
|
21
|
+
call<Req, Resp>(edgeId: string, service: string, method: string, req: Req): Promise<Resp>;
|
|
22
|
+
subscribe<Req, Resp>(edgeId: string, service: string, method: string, req: Req, handler: (resp: Resp) => void): Promise<Subscription>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Interface for streaming subscriptions
|
|
26
|
+
*/
|
|
27
|
+
export interface Subscription {
|
|
28
|
+
unsubscribe(): void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Helper to extract payload from dinkd request format.
|
|
32
|
+
* dinkd sends: { payload: {...}, metadata: {...} }
|
|
33
|
+
*/
|
|
34
|
+
export declare function extractPayload<T>(req: unknown): T;
|
|
35
|
+
/**
|
|
36
|
+
* Helper to wrap response in dinkd expected format.
|
|
37
|
+
* dinkd expects: { result: {...}, success: true }
|
|
38
|
+
*/
|
|
39
|
+
export declare function wrapResponse<T>(resp: T): {
|
|
40
|
+
result: T;
|
|
41
|
+
success: boolean;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Connection quality level
|
|
45
|
+
*/
|
|
46
|
+
export type ConnectionQualityLevel = 'excellent' | 'good' | 'fair' | 'poor' | 'unknown';
|
|
47
|
+
/**
|
|
48
|
+
* Connection state
|
|
49
|
+
*/
|
|
50
|
+
export type ConnectionState = 'connecting' | 'connected' | 'reconnecting' | 'disconnected';
|
|
51
|
+
/**
|
|
52
|
+
* Connection quality metrics
|
|
53
|
+
*/
|
|
54
|
+
export interface ConnectionQuality {
|
|
55
|
+
state: ConnectionState;
|
|
56
|
+
latencyMs: number | null;
|
|
57
|
+
avgLatencyMs: number | null;
|
|
58
|
+
messagesSentPerSecond: number;
|
|
59
|
+
messagesReceivedPerSecond: number;
|
|
60
|
+
totalMessagesSent: number;
|
|
61
|
+
totalMessagesReceived: number;
|
|
62
|
+
lastPingAt: number | null;
|
|
63
|
+
qualityLevel: ConnectionQualityLevel;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Configuration for connection quality monitoring
|
|
67
|
+
*/
|
|
68
|
+
export interface ConnectionQualityConfig {
|
|
69
|
+
/** Latency threshold for "excellent" quality in ms (default: 50) */
|
|
70
|
+
excellentLatencyMs?: number;
|
|
71
|
+
/** Latency threshold for "good" quality in ms (default: 150) */
|
|
72
|
+
goodLatencyMs?: number;
|
|
73
|
+
/** Latency threshold for "fair" quality in ms (default: 300) */
|
|
74
|
+
fairLatencyMs?: number;
|
|
75
|
+
/** Ping interval in milliseconds (default: 30000) */
|
|
76
|
+
pingIntervalMs?: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Configuration for EdgeClient
|
|
80
|
+
*/
|
|
1
81
|
export interface EdgeConfig {
|
|
2
|
-
|
|
82
|
+
/** Edge API key (required, format: dk_<env>_ed_<appID>_<edgeID>_<random>) */
|
|
3
83
|
apiKey: string;
|
|
84
|
+
/** dinkd server URL (e.g., "nats://localhost:4222") */
|
|
85
|
+
serverUrl: string;
|
|
86
|
+
/** Optional display name for the edge */
|
|
4
87
|
edgeName?: string;
|
|
88
|
+
/** Optional labels for edge discovery */
|
|
5
89
|
labels?: Record<string, string>;
|
|
90
|
+
/** Optional version string */
|
|
6
91
|
version?: string;
|
|
92
|
+
/** Optional hostname (auto-detected in Node.js) */
|
|
7
93
|
hostname?: string;
|
|
94
|
+
/** Optional IP address */
|
|
8
95
|
ipAddress?: string;
|
|
96
|
+
/** Heartbeat interval in ms (default: 30000) */
|
|
9
97
|
heartbeatInterval?: number;
|
|
98
|
+
/** Reconnect wait time in ms (default: 2000) */
|
|
10
99
|
reconnectWait?: number;
|
|
100
|
+
/** Max reconnect attempts, -1 for infinite (default: -1) */
|
|
11
101
|
maxReconnects?: number;
|
|
102
|
+
/** Connection quality configuration */
|
|
103
|
+
qualityConfig?: ConnectionQualityConfig;
|
|
12
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Configuration for CenterClient
|
|
107
|
+
*/
|
|
13
108
|
export interface CenterConfig {
|
|
109
|
+
/** dinkd server URL (e.g., "nats://localhost:4222") */
|
|
14
110
|
serverUrl: string;
|
|
111
|
+
/** App API key for authentication */
|
|
15
112
|
apiKey?: string;
|
|
113
|
+
/** App ID (optional, defaults to 'platform') */
|
|
16
114
|
appId?: string;
|
|
115
|
+
/** Request timeout in ms (default: 30000) */
|
|
17
116
|
timeout?: number;
|
|
117
|
+
/** Reconnect wait time in ms (default: 2000) */
|
|
18
118
|
reconnectWait?: number;
|
|
119
|
+
/** Max reconnect attempts, -1 for infinite (default: -1) */
|
|
19
120
|
maxReconnects?: number;
|
|
121
|
+
/** Connection quality configuration */
|
|
122
|
+
qualityConfig?: ConnectionQualityConfig;
|
|
20
123
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
methods: string[];
|
|
25
|
-
}
|
|
26
|
-
export interface ServiceHandler {
|
|
27
|
-
definition(): ServiceDefinition;
|
|
28
|
-
handleRequest(method: string, data: Uint8Array): Promise<Uint8Array>;
|
|
29
|
-
handleStream?(method: string, data: Uint8Array, emit: (data: Uint8Array) => Promise<void>): Promise<void>;
|
|
30
|
-
}
|
|
31
|
-
export interface ServiceCaller {
|
|
32
|
-
call<Req, Resp>(edgeId: string, service: string, method: string, req: Req): Promise<Resp>;
|
|
33
|
-
subscribe<Req, Resp>(edgeId: string, service: string, method: string, req: Req, handler: (resp: Resp) => void): Promise<Subscription>;
|
|
34
|
-
}
|
|
35
|
-
export interface Subscription {
|
|
36
|
-
unsubscribe(): void;
|
|
37
|
-
}
|
|
124
|
+
/**
|
|
125
|
+
* Information about a discovered edge
|
|
126
|
+
*/
|
|
38
127
|
export interface EdgeInfo {
|
|
128
|
+
/** Unique edge identifier */
|
|
39
129
|
id: string;
|
|
130
|
+
/** Display name of the edge */
|
|
40
131
|
name: string;
|
|
132
|
+
/** Online status */
|
|
41
133
|
status: 'online' | 'offline';
|
|
134
|
+
/** Labels attached to the edge */
|
|
42
135
|
labels: Record<string, string>;
|
|
136
|
+
/** Services exposed by this edge */
|
|
43
137
|
services: string[];
|
|
44
|
-
lastSeen?: Date;
|
|
45
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Options for discovering edges
|
|
141
|
+
*/
|
|
46
142
|
export interface DiscoverOptions {
|
|
143
|
+
/** Filter by service name */
|
|
47
144
|
serviceName?: string;
|
|
145
|
+
/** Filter by labels */
|
|
48
146
|
labels?: Record<string, string>;
|
|
147
|
+
/** Only return online edges (default: true) */
|
|
49
148
|
onlineOnly?: boolean;
|
|
50
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Options for RPC calls
|
|
152
|
+
*/
|
|
51
153
|
export interface CallOptions {
|
|
154
|
+
/** Request timeout in ms */
|
|
52
155
|
timeout?: number;
|
|
156
|
+
/** Number of retries on failure (default: 0) */
|
|
53
157
|
retries?: number;
|
|
158
|
+
/** Delay between retries in ms (default: 1000) */
|
|
54
159
|
retryDelay?: number;
|
|
55
160
|
}
|
|
56
161
|
/**
|
|
57
|
-
*
|
|
162
|
+
* Type of API key
|
|
58
163
|
*/
|
|
59
|
-
export type
|
|
164
|
+
export type KeyType = 'edge' | 'center' | 'client' | 'admin' | 'app_master' | 'sync_key';
|
|
60
165
|
/**
|
|
61
|
-
*
|
|
166
|
+
* Status of an API key
|
|
62
167
|
*/
|
|
63
|
-
export type
|
|
168
|
+
export type KeyStatus = 'active' | 'expired' | 'revoked' | 'disabled';
|
|
64
169
|
/**
|
|
65
|
-
*
|
|
66
|
-
* Provides real-time information about the health and performance of the connection.
|
|
170
|
+
* Metadata about an API key
|
|
67
171
|
*/
|
|
68
|
-
export interface
|
|
69
|
-
/**
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
172
|
+
export interface KeyMetadata {
|
|
173
|
+
/** Unique key identifier */
|
|
174
|
+
id: string;
|
|
175
|
+
/** App ID this key belongs to */
|
|
176
|
+
appId: string;
|
|
177
|
+
/** Display name of the key */
|
|
178
|
+
name: string;
|
|
179
|
+
/** Type of the key */
|
|
180
|
+
type: KeyType;
|
|
181
|
+
/** Edge ID (for edge keys) */
|
|
182
|
+
edgeId?: string;
|
|
183
|
+
/** Scopes granted to this key */
|
|
184
|
+
scopes: string[];
|
|
185
|
+
/** Resource restrictions */
|
|
186
|
+
resources?: {
|
|
187
|
+
services?: string[];
|
|
188
|
+
streams?: string[];
|
|
189
|
+
kvBuckets?: string[];
|
|
190
|
+
events?: string[];
|
|
191
|
+
};
|
|
192
|
+
/** Labels attached to the key */
|
|
193
|
+
labels?: Record<string, string>;
|
|
194
|
+
/** Current status of the key */
|
|
195
|
+
status: KeyStatus;
|
|
196
|
+
/** When the key was created */
|
|
197
|
+
createdAt: Date;
|
|
198
|
+
/** When the key expires (if set) */
|
|
199
|
+
expiresAt?: Date;
|
|
200
|
+
/** When the key was last used */
|
|
201
|
+
lastUsedAt?: Date;
|
|
202
|
+
/** When the key was revoked (if revoked) */
|
|
203
|
+
revokedAt?: Date;
|
|
204
|
+
/** Reason for revocation (if revoked) */
|
|
205
|
+
revokeReason?: string;
|
|
87
206
|
}
|
|
88
207
|
/**
|
|
89
|
-
*
|
|
208
|
+
* Options for creating an API key
|
|
90
209
|
*/
|
|
91
|
-
export interface
|
|
92
|
-
/**
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
|
|
210
|
+
export interface CreateKeyOptions {
|
|
211
|
+
/** Display name for the key */
|
|
212
|
+
name: string;
|
|
213
|
+
/** Type of key to create */
|
|
214
|
+
type: KeyType;
|
|
215
|
+
/** Edge ID (optional for edge keys, auto-generated if not provided) */
|
|
216
|
+
edgeId?: string;
|
|
217
|
+
/** Scopes to grant (optional, defaults based on type) */
|
|
218
|
+
scopes?: string[];
|
|
219
|
+
/** Scope bundle to use (e.g., 'bundle:edge') */
|
|
220
|
+
scopeBundle?: string;
|
|
221
|
+
/** Expiration time (e.g., '24h', '7d', '30d') */
|
|
222
|
+
expiresIn?: string;
|
|
223
|
+
/** Labels to attach to the key */
|
|
224
|
+
labels?: Record<string, string>;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Result from creating an API key
|
|
228
|
+
*/
|
|
229
|
+
export interface CreateKeyResult {
|
|
230
|
+
/** Key metadata */
|
|
231
|
+
key: KeyMetadata;
|
|
232
|
+
/** The actual API key (only shown once!) */
|
|
233
|
+
apiKey: string;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Options for listing keys
|
|
237
|
+
*/
|
|
238
|
+
export interface ListKeysOptions {
|
|
239
|
+
/** Filter by key type */
|
|
240
|
+
type?: KeyType;
|
|
241
|
+
/** Filter by labels */
|
|
242
|
+
labels?: Record<string, string>;
|
|
100
243
|
}
|
|
101
244
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts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ACzC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,IAAI,EAAE,OAAO,CAAC;IACd,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,mBAAmB;IACnB,GAAG,EAAE,WAAW,CAAC;IACjB,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,yBAAyB;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,uBAAuB;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC"}
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
// @fatagnus/dink-sdk - Core TypeScript SDK types for dink Edge RPC
|
|
2
|
+
// This file contains base types used by both edge and center clients
|
|
3
|
+
// ============================
|
|
4
|
+
// Helper Functions
|
|
5
|
+
// ============================
|
|
6
|
+
/**
|
|
7
|
+
* Helper to extract payload from dinkd request format.
|
|
8
|
+
* dinkd sends: { payload: {...}, metadata: {...} }
|
|
9
|
+
*/
|
|
10
|
+
export function extractPayload(req) {
|
|
11
|
+
if (req && typeof req === 'object' && 'payload' in req) {
|
|
12
|
+
return (req.payload || {});
|
|
13
|
+
}
|
|
14
|
+
return req;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Helper to wrap response in dinkd expected format.
|
|
18
|
+
* dinkd expects: { result: {...}, success: true }
|
|
19
|
+
*/
|
|
20
|
+
export function wrapResponse(resp) {
|
|
21
|
+
return { result: resp, success: true };
|
|
22
|
+
}
|
|
2
23
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,qEAAqE;AA6CrE,+BAA+B;AAC/B,mBAAmB;AACnB,+BAA+B;AAE/B;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAI,GAAY;IAC5C,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,SAAS,IAAI,GAAG,EAAE,CAAC;QACvD,OAAO,CAAE,GAA4B,CAAC,OAAO,IAAI,EAAE,CAAM,CAAC;IAC5D,CAAC;IACD,OAAO,GAAQ,CAAC;AAClB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAI,IAAO;IACrC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACzC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fatagnus/dink-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "TypeScript SDK for Dink edge mesh platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"import": "./dist/index.js"
|
|
12
12
|
},
|
|
13
|
+
"./types": {
|
|
14
|
+
"types": "./dist/types.d.ts",
|
|
15
|
+
"import": "./dist/types.js"
|
|
16
|
+
},
|
|
13
17
|
"./edge": {
|
|
14
18
|
"types": "./dist/edge/index.d.ts",
|
|
15
19
|
"import": "./dist/edge/index.js"
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from './types.js';
|
|
2
|
-
export { JobServiceClient, JobServiceDefinition } from './jobservice.client.js';
|
|
3
|
-
export { JobServiceHandler } from './jobservice.handler.js';
|
|
4
|
-
export type { JobServiceServer } from './jobservice.handler.js';
|
|
5
|
-
export { SensorServiceClient, SensorServiceDefinition } from './sensorservice.client.js';
|
|
6
|
-
export { SensorServiceHandler } from './sensorservice.handler.js';
|
|
7
|
-
export type { SensorServiceServer } from './sensorservice.handler.js';
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generated/index.ts"],"names":[],"mappings":"AAEA,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,YAAY,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/generated/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// Code generated by dink codegen. DO NOT EDIT.
|
|
2
|
-
export * from './types.js';
|
|
3
|
-
export { JobServiceClient, JobServiceDefinition } from './jobservice.client.js';
|
|
4
|
-
export { JobServiceHandler } from './jobservice.handler.js';
|
|
5
|
-
export { SensorServiceClient, SensorServiceDefinition } from './sensorservice.client.js';
|
|
6
|
-
export { SensorServiceHandler } from './sensorservice.handler.js';
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generated/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAE/C,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ServiceCaller, Subscription } from '../types.js';
|
|
2
|
-
import type { JobStartRequest, JobStartResponse, JobStatusRequest, JobStatusResponse, JobCancelRequest, JobCancelResponse, JobLogsRequest, JobLogLine, JobProgressRequest, JobProgress } from './types.js';
|
|
3
|
-
export declare class JobServiceClient {
|
|
4
|
-
private edgeId;
|
|
5
|
-
private caller;
|
|
6
|
-
constructor(edgeId: string, caller: ServiceCaller);
|
|
7
|
-
getEdgeId(): string;
|
|
8
|
-
Start(req: JobStartRequest): Promise<JobStartResponse>;
|
|
9
|
-
Status(req: JobStatusRequest): Promise<JobStatusResponse>;
|
|
10
|
-
Cancel(req: JobCancelRequest): Promise<JobCancelResponse>;
|
|
11
|
-
StreamLogs(req: JobLogsRequest, handler: (resp: JobLogLine) => void): Promise<Subscription>;
|
|
12
|
-
StreamProgress(req: JobProgressRequest, handler: (resp: JobProgress) => void): Promise<Subscription>;
|
|
13
|
-
}
|
|
14
|
-
export declare const JobServiceDefinition: {
|
|
15
|
-
name: string;
|
|
16
|
-
version: string;
|
|
17
|
-
methods: string[];
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=jobservice.client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jobservice.client.d.ts","sourceRoot":"","sources":["../../src/generated/jobservice.client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE3M,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAgB;gBAElB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa;IAKjD,SAAS,IAAI,MAAM;IAKb,KAAK,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAUtD,MAAM,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAUzD,MAAM,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAUzD,UAAU,CAAC,GAAG,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;IAW3F,cAAc,CAAC,GAAG,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;CAW3G;AAED,eAAO,MAAM,oBAAoB;;;;CAUhC,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// Code generated by dink codegen. DO NOT EDIT.
|
|
2
|
-
export class JobServiceClient {
|
|
3
|
-
edgeId;
|
|
4
|
-
caller;
|
|
5
|
-
constructor(edgeId, caller) {
|
|
6
|
-
this.edgeId = edgeId;
|
|
7
|
-
this.caller = caller;
|
|
8
|
-
}
|
|
9
|
-
getEdgeId() {
|
|
10
|
-
return this.edgeId;
|
|
11
|
-
}
|
|
12
|
-
async Start(req) {
|
|
13
|
-
return this.caller.call(this.edgeId, 'JobService', 'Start', req);
|
|
14
|
-
}
|
|
15
|
-
async Status(req) {
|
|
16
|
-
return this.caller.call(this.edgeId, 'JobService', 'Status', req);
|
|
17
|
-
}
|
|
18
|
-
async Cancel(req) {
|
|
19
|
-
return this.caller.call(this.edgeId, 'JobService', 'Cancel', req);
|
|
20
|
-
}
|
|
21
|
-
async StreamLogs(req, handler) {
|
|
22
|
-
return this.caller.subscribe(this.edgeId, 'JobService', 'StreamLogs', req, handler);
|
|
23
|
-
}
|
|
24
|
-
async StreamProgress(req, handler) {
|
|
25
|
-
return this.caller.subscribe(this.edgeId, 'JobService', 'StreamProgress', req, handler);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export const JobServiceDefinition = {
|
|
29
|
-
name: 'JobService',
|
|
30
|
-
version: '1.0.0',
|
|
31
|
-
methods: [
|
|
32
|
-
'Start',
|
|
33
|
-
'Status',
|
|
34
|
-
'Cancel',
|
|
35
|
-
'StreamLogs',
|
|
36
|
-
'StreamProgress',
|
|
37
|
-
],
|
|
38
|
-
};
|
|
39
|
-
//# sourceMappingURL=jobservice.client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jobservice.client.js","sourceRoot":"","sources":["../../src/generated/jobservice.client.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAK/C,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAAS;IACf,MAAM,CAAgB;IAE9B,YAAY,MAAc,EAAE,MAAqB;QAC/C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAGD,KAAK,CAAC,KAAK,CAAC,GAAoB;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CACrB,IAAI,CAAC,MAAM,EACX,YAAY,EACZ,OAAO,EACP,GAAG,CACJ,CAAC;IACJ,CAAC;IAGD,KAAK,CAAC,MAAM,CAAC,GAAqB;QAChC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CACrB,IAAI,CAAC,MAAM,EACX,YAAY,EACZ,QAAQ,EACR,GAAG,CACJ,CAAC;IACJ,CAAC;IAGD,KAAK,CAAC,MAAM,CAAC,GAAqB;QAChC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CACrB,IAAI,CAAC,MAAM,EACX,YAAY,EACZ,QAAQ,EACR,GAAG,CACJ,CAAC;IACJ,CAAC;IAGD,KAAK,CAAC,UAAU,CAAC,GAAmB,EAAE,OAAmC;QACvE,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAC1B,IAAI,CAAC,MAAM,EACX,YAAY,EACZ,YAAY,EACZ,GAAG,EACH,OAAO,CACR,CAAC;IACJ,CAAC;IAGD,KAAK,CAAC,cAAc,CAAC,GAAuB,EAAE,OAAoC;QAChF,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAC1B,IAAI,CAAC,MAAM,EACX,YAAY,EACZ,gBAAgB,EAChB,GAAG,EACH,OAAO,CACR,CAAC;IACJ,CAAC;CAGF;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,IAAI,EAAE,YAAY;IAClB,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE;QACP,OAAO;QACP,QAAQ;QACR,QAAQ;QACR,YAAY;QACZ,gBAAgB;KACjB;CACF,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { ServiceHandler, ServiceDefinition } from '../types.js';
|
|
2
|
-
import type { JobStartRequest, JobStartResponse, JobStatusRequest, JobStatusResponse, JobCancelRequest, JobCancelResponse, JobLogsRequest, JobLogLine, JobProgressRequest, JobProgress } from './types.js';
|
|
3
|
-
export interface JobServiceServer {
|
|
4
|
-
Start(req: JobStartRequest): Promise<JobStartResponse>;
|
|
5
|
-
Status(req: JobStatusRequest): Promise<JobStatusResponse>;
|
|
6
|
-
Cancel(req: JobCancelRequest): Promise<JobCancelResponse>;
|
|
7
|
-
StreamLogs(req: JobLogsRequest, stream: {
|
|
8
|
-
send: (msg: JobLogLine) => Promise<void>;
|
|
9
|
-
}): Promise<void>;
|
|
10
|
-
StreamProgress(req: JobProgressRequest, stream: {
|
|
11
|
-
send: (msg: JobProgress) => Promise<void>;
|
|
12
|
-
}): Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
export declare class JobServiceHandler implements ServiceHandler {
|
|
15
|
-
private impl;
|
|
16
|
-
constructor(impl: JobServiceServer);
|
|
17
|
-
definition(): ServiceDefinition;
|
|
18
|
-
handleRequest(method: string, data: Uint8Array): Promise<Uint8Array>;
|
|
19
|
-
handleStream(method: string, data: Uint8Array, emit: (data: Uint8Array) => Promise<void>): Promise<void>;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=jobservice.handler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jobservice.handler.d.ts","sourceRoot":"","sources":["../../src/generated/jobservice.handler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE3M,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACvD,MAAM,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC1D,MAAM,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC1D,UAAU,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE;QAAE,IAAI,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrG,cAAc,CAAC,GAAG,EAAE,kBAAkB,EAAE,MAAM,EAAE;QAAE,IAAI,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/G;AAED,qBAAa,iBAAkB,YAAW,cAAc;IACtD,OAAO,CAAC,IAAI,CAAmB;gBAEnB,IAAI,EAAE,gBAAgB;IAIlC,UAAU,IAAI,iBAAiB;IAczB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAuBpE,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAsB/G"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
// Code generated by dink codegen. DO NOT EDIT.
|
|
2
|
-
export class JobServiceHandler {
|
|
3
|
-
impl;
|
|
4
|
-
constructor(impl) {
|
|
5
|
-
this.impl = impl;
|
|
6
|
-
}
|
|
7
|
-
definition() {
|
|
8
|
-
return {
|
|
9
|
-
name: 'JobService',
|
|
10
|
-
version: '1.0.0',
|
|
11
|
-
methods: [
|
|
12
|
-
'Start',
|
|
13
|
-
'Status',
|
|
14
|
-
'Cancel',
|
|
15
|
-
'StreamLogs',
|
|
16
|
-
'StreamProgress',
|
|
17
|
-
],
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
async handleRequest(method, data) {
|
|
21
|
-
const decoder = new TextDecoder();
|
|
22
|
-
const encoder = new TextEncoder();
|
|
23
|
-
const req = data.length > 0 ? JSON.parse(decoder.decode(data)) : {};
|
|
24
|
-
switch (method) {
|
|
25
|
-
case 'Start': {
|
|
26
|
-
const resp = await this.impl.Start(req);
|
|
27
|
-
return encoder.encode(JSON.stringify(resp));
|
|
28
|
-
}
|
|
29
|
-
case 'Status': {
|
|
30
|
-
const resp = await this.impl.Status(req);
|
|
31
|
-
return encoder.encode(JSON.stringify(resp));
|
|
32
|
-
}
|
|
33
|
-
case 'Cancel': {
|
|
34
|
-
const resp = await this.impl.Cancel(req);
|
|
35
|
-
return encoder.encode(JSON.stringify(resp));
|
|
36
|
-
}
|
|
37
|
-
default:
|
|
38
|
-
throw new Error(`Unknown method: ${method}`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
async handleStream(method, data, emit) {
|
|
42
|
-
const decoder = new TextDecoder();
|
|
43
|
-
const encoder = new TextEncoder();
|
|
44
|
-
const req = data.length > 0 ? JSON.parse(decoder.decode(data)) : {};
|
|
45
|
-
const stream = {
|
|
46
|
-
send: async (msg) => {
|
|
47
|
-
await emit(encoder.encode(JSON.stringify(msg)));
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
switch (method) {
|
|
51
|
-
case 'StreamLogs':
|
|
52
|
-
await this.impl.StreamLogs(req, stream);
|
|
53
|
-
break;
|
|
54
|
-
case 'StreamProgress':
|
|
55
|
-
await this.impl.StreamProgress(req, stream);
|
|
56
|
-
break;
|
|
57
|
-
default:
|
|
58
|
-
throw new Error(`Unknown streaming method: ${method}`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=jobservice.handler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jobservice.handler.js","sourceRoot":"","sources":["../../src/generated/jobservice.handler.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAa/C,MAAM,OAAO,iBAAiB;IACpB,IAAI,CAAmB;IAE/B,YAAY,IAAsB;QAChC,IAA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AC;YACD;gBACE,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,EAAE,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,MAAc,EAAE,IAAgB,EAAE,IAAyC;QAC5F,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAClC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAEpE,MAAM,MAAM,GAAG;YACb,IAAI,EAAE,KAAK,EAAE,GAAY,EAAE,EAAE;gBAC3B,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAClD,CAAC;SACF,CAAC;QAEF,QAAQ,MAAM,EAAE,CAAC;YACjB,KAAK,YAAY;gBACf,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAqB,EAAE,MAAM,CAAC,CAAC;gBAC1D,MAAM;YACR,KAAK,gBAAgB;gBACnB,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,GAAyB,EAAE,MAAM,CAAC,CAAC;gBAClE,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,6BAA6B,MAAM,EAAE,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ServiceCaller, Subscription } from '../types.js';
|
|
2
|
-
import type { ReadTemperatureRequest, Temperature, SetpointRequest, SetpointResponse, StreamReadingsRequest } from './types.js';
|
|
3
|
-
export declare class SensorServiceClient {
|
|
4
|
-
private edgeId;
|
|
5
|
-
private caller;
|
|
6
|
-
constructor(edgeId: string, caller: ServiceCaller);
|
|
7
|
-
getEdgeId(): string;
|
|
8
|
-
ReadTemperature(req: ReadTemperatureRequest): Promise<Temperature>;
|
|
9
|
-
SetSetpoint(req: SetpointRequest): Promise<SetpointResponse>;
|
|
10
|
-
StreamReadings(req: StreamReadingsRequest, handler: (resp: Temperature) => void): Promise<Subscription>;
|
|
11
|
-
}
|
|
12
|
-
export declare const SensorServiceDefinition: {
|
|
13
|
-
name: string;
|
|
14
|
-
version: string;
|
|
15
|
-
methods: string[];
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=sensorservice.client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sensorservice.client.d.ts","sourceRoot":"","sources":["../../src/generated/sensorservice.client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,eAAe,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEhI,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAgB;gBAElB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa;IAKjD,SAAS,IAAI,MAAM;IAKb,eAAe,CAAC,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAAC,WAAW,CAAC;IAUlE,WAAW,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAU5D,cAAc,CAAC,GAAG,EAAE,qBAAqB,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;CAW9G;AAED,eAAO,MAAM,uBAAuB;;;;CAQnC,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// Code generated by dink codegen. DO NOT EDIT.
|
|
2
|
-
export class SensorServiceClient {
|
|
3
|
-
edgeId;
|
|
4
|
-
caller;
|
|
5
|
-
constructor(edgeId, caller) {
|
|
6
|
-
this.edgeId = edgeId;
|
|
7
|
-
this.caller = caller;
|
|
8
|
-
}
|
|
9
|
-
getEdgeId() {
|
|
10
|
-
return this.edgeId;
|
|
11
|
-
}
|
|
12
|
-
async ReadTemperature(req) {
|
|
13
|
-
return this.caller.call(this.edgeId, 'SensorService', 'ReadTemperature', req);
|
|
14
|
-
}
|
|
15
|
-
async SetSetpoint(req) {
|
|
16
|
-
return this.caller.call(this.edgeId, 'SensorService', 'SetSetpoint', req);
|
|
17
|
-
}
|
|
18
|
-
async StreamReadings(req, handler) {
|
|
19
|
-
return this.caller.subscribe(this.edgeId, 'SensorService', 'StreamReadings', req, handler);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export const SensorServiceDefinition = {
|
|
23
|
-
name: 'SensorService',
|
|
24
|
-
version: '1.0.0',
|
|
25
|
-
methods: [
|
|
26
|
-
'ReadTemperature',
|
|
27
|
-
'SetSetpoint',
|
|
28
|
-
'StreamReadings',
|
|
29
|
-
],
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=sensorservice.client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sensorservice.client.js","sourceRoot":"","sources":["../../src/generated/sensorservice.client.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAK/C,MAAM,OAAO,mBAAmB;IACtB,MAAM,CAAS;IACf,MAAM,CAAgB;IAE9B,YAAY,MAAc,EAAE,MAAqB;QAC/C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAGD,KAAK,CAAC,eAAe,CAAC,GAA2B;QAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CACrB,IAAI,CAAC,MAAM,EACX,eAAe,EACf,iBAAiB,EACjB,GAAG,CACJ,CAAC;IACJ,CAAC;IAGD,KAAK,CAAC,WAAW,CAAC,GAAoB;QACpC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CACrB,IAAI,CAAC,MAAM,EACX,eAAe,EACf,aAAa,EACb,GAAG,CACJ,CAAC;IACJ,CAAC;IAGD,KAAK,CAAC,cAAc,CAAC,GAA0B,EAAE,OAAoC;QACnF,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAC1B,IAAI,CAAC,MAAM,EACX,eAAe,EACf,gBAAgB,EAChB,GAAG,EACH,OAAO,CACR,CAAC;IACJ,CAAC;CAGF;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE;QACP,iBAAiB;QACjB,aAAa;QACb,gBAAgB;KACjB;CACF,CAAC"}
|