@science-corporation/synapse 2.2.5 → 2.2.6

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.
@@ -453,6 +453,10 @@
453
453
  "responseType": "AppDeployResponse",
454
454
  "responseStream": true
455
455
  },
456
+ "ListApps": {
457
+ "requestType": "ListAppsRequest",
458
+ "responseType": "ListAppsResponse"
459
+ },
456
460
  "ListFiles": {
457
461
  "requestType": "google.protobuf.Empty",
458
462
  "responseType": "ListFilesResponse"
@@ -1416,6 +1420,30 @@
1416
1420
  }
1417
1421
  }
1418
1422
  },
1423
+ "AppInfo": {
1424
+ "fields": {
1425
+ "name": {
1426
+ "type": "string",
1427
+ "id": 1
1428
+ },
1429
+ "version": {
1430
+ "type": "string",
1431
+ "id": 2
1432
+ }
1433
+ }
1434
+ },
1435
+ "ListAppsRequest": {
1436
+ "fields": {}
1437
+ },
1438
+ "ListAppsResponse": {
1439
+ "fields": {
1440
+ "apps": {
1441
+ "rule": "repeated",
1442
+ "type": "AppInfo",
1443
+ "id": 1
1444
+ }
1445
+ }
1446
+ },
1419
1447
  "FunctionProfile": {
1420
1448
  "fields": {
1421
1449
  "name": {
package/src/device.ts CHANGED
@@ -183,6 +183,65 @@ class Device {
183
183
  return call;
184
184
  }
185
185
 
186
+ // Apps
187
+
188
+ async listApps(options: CallOptions = {}): Promise<{ status: Status; response?: synapse.ListAppsResponse }> {
189
+ return new Promise((resolve, reject) => {
190
+ this.rpc.listApps({}, options, (err: ServiceError, res: synapse.ListAppsResponse) => {
191
+ if (err) {
192
+ reject(err);
193
+ } else if (!res) {
194
+ reject(new Error("No response from listApps"));
195
+ } else {
196
+ resolve({ status: new Status(), response: res });
197
+ }
198
+ });
199
+ });
200
+ }
201
+
202
+ deployApp(
203
+ options: CallOptions = {},
204
+ callbacks: {
205
+ onData: (data: synapse.AppDeployResponse) => void;
206
+ onEnd?: () => void;
207
+ onError?: (err: Error) => void;
208
+ onStatus?: (status: Status) => void;
209
+ }
210
+ ) {
211
+ const { onData, onEnd, onError, onStatus } = callbacks;
212
+ const call = this.rpc.deployApp(options);
213
+
214
+ call.on("data", (data: synapse.AppDeployResponse) => {
215
+ onData(data);
216
+ });
217
+ if (onEnd) {
218
+ call.on("end", onEnd);
219
+ }
220
+ if (onError) {
221
+ call.on("error", (err: ServiceError) => {
222
+ onError(err);
223
+ });
224
+ }
225
+ if (onStatus) {
226
+ call.on("status", (grpcStatus) => {
227
+ onStatus?.(new Status(grpcStatus.code, grpcStatus.details));
228
+ });
229
+ }
230
+
231
+ return {
232
+ call,
233
+ sendMetadata: (metadata: synapse.IPackageMetadata) => {
234
+ call.write({ metadata });
235
+ },
236
+ sendChunk: (fileChunk: Uint8Array) => {
237
+ call.write({ fileChunk });
238
+ },
239
+ end: () => {
240
+ call.end();
241
+ },
242
+ };
243
+ }
244
+
186
245
  _handleStatusResponse(status: synapse.IStatus): Status {
187
246
  const { code, message } = status;
188
247
  if (code !== synapse.StatusCode.kOk) {
@@ -53,3 +53,19 @@ message AppPerformanceSummary {
53
53
  uint64 timestamp_ns = 1;
54
54
  repeated FunctionProfile function_profiles = 2;
55
55
  }
56
+
57
+ // Information about an installed application
58
+ message AppInfo {
59
+ // Application name (e.g., "synapse-example-app")
60
+ string name = 1;
61
+
62
+ // Installed version
63
+ string version = 2;
64
+ }
65
+
66
+ message ListAppsRequest {
67
+ }
68
+
69
+ message ListAppsResponse {
70
+ repeated AppInfo apps = 1;
71
+ }
@@ -20,6 +20,7 @@ service SynapseDevice {
20
20
  rpc StreamQuery(StreamQueryRequest) returns (stream StreamQueryResponse) {}
21
21
 
22
22
  rpc DeployApp(stream AppPackageChunk) returns (stream AppDeployResponse) {}
23
+ rpc ListApps(ListAppsRequest) returns (ListAppsResponse) {}
23
24
 
24
25
  rpc ListFiles(google.protobuf.Empty) returns (ListFilesResponse) {}
25
26
  rpc WriteFile(WriteFileRequest) returns (WriteFileResponse) {}