@dronedeploy/rocos-js-sdk 3.1.1 → 3.1.3-rc1
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/README.md +128 -0
- package/cjs/api/streams/telemetry/FetchInjectingGrpcWebTransport.d.ts +28 -0
- package/cjs/api/streams/telemetry/FetchInjectingGrpcWebTransport.js +49 -0
- package/cjs/api/streams/telemetry/TelemetryStream.js +6 -2
- package/esm/api/streams/telemetry/FetchInjectingGrpcWebTransport.d.ts +28 -0
- package/esm/api/streams/telemetry/FetchInjectingGrpcWebTransport.js +45 -0
- package/esm/api/streams/telemetry/TelemetryStream.js +6 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,6 +19,134 @@ yarn add @dronedeploy/rocos-js-sdk rxjs@^7
|
|
|
19
19
|
|
|
20
20
|
## What's new
|
|
21
21
|
|
|
22
|
+
### 3.1.2
|
|
23
|
+
|
|
24
|
+
* Use the optional `fetch` implementation for the gRPC-web transport too, so a custom `fetch` can be supplied consistently across transports.
|
|
25
|
+
|
|
26
|
+
### 3.1.1
|
|
27
|
+
|
|
28
|
+
* Allow an optional `fetch` implementation to be supplied to the Connect transport.
|
|
29
|
+
|
|
30
|
+
### 3.1.0
|
|
31
|
+
|
|
32
|
+
* Add a Connect-RPC telemetry transport variant.
|
|
33
|
+
* Upgrade `connectrpc` and `bufbuild` to the latest versions and move to TypeScript 6.
|
|
34
|
+
* Prune unused and trivially-replaceable dependencies.
|
|
35
|
+
|
|
36
|
+
### 3.0.30
|
|
37
|
+
|
|
38
|
+
* *MapService*
|
|
39
|
+
* Add a `create` API and fix the `copy` API.
|
|
40
|
+
|
|
41
|
+
### 3.0.29
|
|
42
|
+
|
|
43
|
+
* Add new APIs for setting map content and metadata.
|
|
44
|
+
|
|
45
|
+
### 3.0.28
|
|
46
|
+
|
|
47
|
+
* Add `base_floor_plan` to `Level`.
|
|
48
|
+
|
|
49
|
+
### 3.0.27
|
|
50
|
+
|
|
51
|
+
* Add `staticAttributes` field to `AssetSyncDefinitionModel`.
|
|
52
|
+
|
|
53
|
+
### 3.0.25
|
|
54
|
+
|
|
55
|
+
* *IntegrationService*
|
|
56
|
+
* Add `getLevels` method.
|
|
57
|
+
|
|
58
|
+
### 3.0.23
|
|
59
|
+
|
|
60
|
+
* Add `metadata` field to device credentials.
|
|
61
|
+
|
|
62
|
+
### 3.0.21
|
|
63
|
+
|
|
64
|
+
* Export types for device credentials.
|
|
65
|
+
|
|
66
|
+
### 3.0.20
|
|
67
|
+
|
|
68
|
+
* Add library list/import endpoints.
|
|
69
|
+
|
|
70
|
+
### 3.0.19
|
|
71
|
+
|
|
72
|
+
* *CallerService*
|
|
73
|
+
* Add a cancel observable to service calls.
|
|
74
|
+
|
|
75
|
+
### 3.0.18
|
|
76
|
+
|
|
77
|
+
* *CallerService*
|
|
78
|
+
* Add a `rawPayload` option to service calls.
|
|
79
|
+
|
|
80
|
+
### 3.0.17
|
|
81
|
+
|
|
82
|
+
* *RobotService*
|
|
83
|
+
* List robots by account/org.
|
|
84
|
+
|
|
85
|
+
### 3.0.16
|
|
86
|
+
|
|
87
|
+
* Add missing types for `EventService` and `ProfileService`.
|
|
88
|
+
|
|
89
|
+
### 3.0.15
|
|
90
|
+
|
|
91
|
+
* *ProfileService*
|
|
92
|
+
* Change the profile export type to `Blob`.
|
|
93
|
+
|
|
94
|
+
### 3.0.14
|
|
95
|
+
|
|
96
|
+
* *Utils*
|
|
97
|
+
* Expose `splitRobotTopic`.
|
|
98
|
+
|
|
99
|
+
### 3.0.13
|
|
100
|
+
|
|
101
|
+
* *kscript*
|
|
102
|
+
* Additional support for custom widgets.
|
|
103
|
+
|
|
104
|
+
### 3.0.11
|
|
105
|
+
|
|
106
|
+
* Improve the accuracy of file sync types.
|
|
107
|
+
|
|
108
|
+
### 3.0.10
|
|
109
|
+
|
|
110
|
+
* *MapService*
|
|
111
|
+
* Add a system parameter to the list maps endpoint.
|
|
112
|
+
|
|
113
|
+
### 3.0.9
|
|
114
|
+
|
|
115
|
+
* *WorkflowService*
|
|
116
|
+
* Add methods for importing/exporting workflows.
|
|
117
|
+
|
|
118
|
+
### 3.0.8
|
|
119
|
+
|
|
120
|
+
* Add an HTTP listener/hook.
|
|
121
|
+
|
|
122
|
+
### 3.0.7
|
|
123
|
+
|
|
124
|
+
* *MapService*
|
|
125
|
+
* Add `lastModifiedTimestamp` to list maps.
|
|
126
|
+
|
|
127
|
+
### 3.0.6
|
|
128
|
+
|
|
129
|
+
* *WorkflowService*
|
|
130
|
+
* Add a function to delete an asset.
|
|
131
|
+
|
|
132
|
+
### 3.0.5
|
|
133
|
+
|
|
134
|
+
* Add `name` to the `Locations` type.
|
|
135
|
+
|
|
136
|
+
### 3.0.4
|
|
137
|
+
|
|
138
|
+
* *Panorama*
|
|
139
|
+
* Allow `any` type on the `data` prop.
|
|
140
|
+
|
|
141
|
+
### 3.0.3
|
|
142
|
+
|
|
143
|
+
* *MapService*
|
|
144
|
+
* Add a `hash` property to the cloud map object.
|
|
145
|
+
|
|
146
|
+
### 3.0.2
|
|
147
|
+
|
|
148
|
+
* Add a delete assets endpoint.
|
|
149
|
+
|
|
22
150
|
### 3.0.1
|
|
23
151
|
|
|
24
152
|
#### Breaking Changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { GrpcWebFetchTransport, GrpcWebOptions } from '@protobuf-ts/grpcweb-transport';
|
|
2
|
+
import type { MethodInfo, RpcOptions, ServerStreamingCall, UnaryCall } from '@protobuf-ts/runtime-rpc';
|
|
3
|
+
/**
|
|
4
|
+
* A {@link GrpcWebFetchTransport} that issues its requests through a caller-supplied `fetch` instead
|
|
5
|
+
* of the global one.
|
|
6
|
+
*
|
|
7
|
+
* Why: `@protobuf-ts/grpcweb-transport` calls `globalThis.fetch(...)` directly and exposes no option
|
|
8
|
+
* to inject a custom fetch. Datadog RUM (and similar agents) monkey-patch `window.fetch` and
|
|
9
|
+
* `clone()` + read every response to measure timing; on the long-lived grpc-web telemetry stream
|
|
10
|
+
* (`RegisterReceiver`) that clone-read can stall the client's read of the body. Reading the stream
|
|
11
|
+
* through a `fetch` captured before RUM patched the global avoids that.
|
|
12
|
+
*
|
|
13
|
+
* How: the parent transport invokes `globalThis.fetch(...)` **synchronously** while starting a call
|
|
14
|
+
* (it builds the request body synchronously, then calls fetch and returns the call object). We swap
|
|
15
|
+
* `globalThis.fetch` for that synchronous window only. JavaScript is single-threaded, so no other
|
|
16
|
+
* code — and therefore no other request — runs between the swap and the `finally` restore; the
|
|
17
|
+
* custom fetch cannot leak to unrelated requests. Reading the response happens later, but the
|
|
18
|
+
* `Response`/stream is already bound to the custom fetch by then.
|
|
19
|
+
*
|
|
20
|
+
* When `customFetch` is undefined this behaves exactly like {@link GrpcWebFetchTransport}.
|
|
21
|
+
*/
|
|
22
|
+
export declare class FetchInjectingGrpcWebTransport extends GrpcWebFetchTransport {
|
|
23
|
+
private readonly customFetch;
|
|
24
|
+
constructor(customFetch: typeof globalThis.fetch | undefined, options: GrpcWebOptions);
|
|
25
|
+
private withFetch;
|
|
26
|
+
unary<I extends object, O extends object>(method: MethodInfo<I, O>, input: I, options: RpcOptions): UnaryCall<I, O>;
|
|
27
|
+
serverStreaming<I extends object, O extends object>(method: MethodInfo<I, O>, input: I, options: RpcOptions): ServerStreamingCall<I, O>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FetchInjectingGrpcWebTransport = void 0;
|
|
4
|
+
const grpcweb_transport_1 = require("@protobuf-ts/grpcweb-transport");
|
|
5
|
+
/**
|
|
6
|
+
* A {@link GrpcWebFetchTransport} that issues its requests through a caller-supplied `fetch` instead
|
|
7
|
+
* of the global one.
|
|
8
|
+
*
|
|
9
|
+
* Why: `@protobuf-ts/grpcweb-transport` calls `globalThis.fetch(...)` directly and exposes no option
|
|
10
|
+
* to inject a custom fetch. Datadog RUM (and similar agents) monkey-patch `window.fetch` and
|
|
11
|
+
* `clone()` + read every response to measure timing; on the long-lived grpc-web telemetry stream
|
|
12
|
+
* (`RegisterReceiver`) that clone-read can stall the client's read of the body. Reading the stream
|
|
13
|
+
* through a `fetch` captured before RUM patched the global avoids that.
|
|
14
|
+
*
|
|
15
|
+
* How: the parent transport invokes `globalThis.fetch(...)` **synchronously** while starting a call
|
|
16
|
+
* (it builds the request body synchronously, then calls fetch and returns the call object). We swap
|
|
17
|
+
* `globalThis.fetch` for that synchronous window only. JavaScript is single-threaded, so no other
|
|
18
|
+
* code — and therefore no other request — runs between the swap and the `finally` restore; the
|
|
19
|
+
* custom fetch cannot leak to unrelated requests. Reading the response happens later, but the
|
|
20
|
+
* `Response`/stream is already bound to the custom fetch by then.
|
|
21
|
+
*
|
|
22
|
+
* When `customFetch` is undefined this behaves exactly like {@link GrpcWebFetchTransport}.
|
|
23
|
+
*/
|
|
24
|
+
class FetchInjectingGrpcWebTransport extends grpcweb_transport_1.GrpcWebFetchTransport {
|
|
25
|
+
constructor(customFetch, options) {
|
|
26
|
+
super(options);
|
|
27
|
+
this.customFetch = customFetch;
|
|
28
|
+
}
|
|
29
|
+
withFetch(start) {
|
|
30
|
+
if (!this.customFetch) {
|
|
31
|
+
return start();
|
|
32
|
+
}
|
|
33
|
+
const original = globalThis.fetch;
|
|
34
|
+
globalThis.fetch = this.customFetch;
|
|
35
|
+
try {
|
|
36
|
+
return start();
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
globalThis.fetch = original;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
unary(method, input, options) {
|
|
43
|
+
return this.withFetch(() => super.unary(method, input, options));
|
|
44
|
+
}
|
|
45
|
+
serverStreaming(method, input, options) {
|
|
46
|
+
return this.withFetch(() => super.serverStreaming(method, input, options));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.FetchInjectingGrpcWebTransport = FetchInjectingGrpcWebTransport;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TelemetryStream = void 0;
|
|
4
4
|
const models_1 = require("../../../models");
|
|
5
5
|
const teletubby_pb_1 = require("../../../grpc/teletubby_pb");
|
|
6
|
-
const
|
|
6
|
+
const FetchInjectingGrpcWebTransport_1 = require("./FetchInjectingGrpcWebTransport");
|
|
7
7
|
const RocosLogger_1 = require("../../../logger/RocosLogger");
|
|
8
8
|
const teletubby_pb_client_1 = require("../../../grpc/teletubby_pb.client");
|
|
9
9
|
const TelemetryStreamAbstract_1 = require("./TelemetryStreamAbstract");
|
|
@@ -13,7 +13,11 @@ class TelemetryStream extends TelemetryStreamAbstract_1.TelemetryStreamAbstract
|
|
|
13
13
|
this.logger = RocosLogger_1.RocosLogger.getInstance(`TelemetryStreamWeb(${this.identifier})`);
|
|
14
14
|
const protocol = config.insecure ? 'http' : 'https';
|
|
15
15
|
const port = config.port ? `:${config.port}` : '';
|
|
16
|
-
|
|
16
|
+
// Optional caller-supplied fetch (e.g. captured before Datadog RUM patches window.fetch, whose
|
|
17
|
+
// response cloning otherwise stalls this long-lived stream). When omitted, the transport uses
|
|
18
|
+
// the global fetch. @protobuf-ts/grpcweb-transport has no fetch option, so the injection happens
|
|
19
|
+
// in FetchInjectingGrpcWebTransport.
|
|
20
|
+
const transport = new FetchInjectingGrpcWebTransport_1.FetchInjectingGrpcWebTransport(config.fetch, {
|
|
17
21
|
baseUrl: `${protocol}://${this.url}${port}`,
|
|
18
22
|
format: config.grpcWebFormat,
|
|
19
23
|
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { GrpcWebFetchTransport, GrpcWebOptions } from '@protobuf-ts/grpcweb-transport';
|
|
2
|
+
import type { MethodInfo, RpcOptions, ServerStreamingCall, UnaryCall } from '@protobuf-ts/runtime-rpc';
|
|
3
|
+
/**
|
|
4
|
+
* A {@link GrpcWebFetchTransport} that issues its requests through a caller-supplied `fetch` instead
|
|
5
|
+
* of the global one.
|
|
6
|
+
*
|
|
7
|
+
* Why: `@protobuf-ts/grpcweb-transport` calls `globalThis.fetch(...)` directly and exposes no option
|
|
8
|
+
* to inject a custom fetch. Datadog RUM (and similar agents) monkey-patch `window.fetch` and
|
|
9
|
+
* `clone()` + read every response to measure timing; on the long-lived grpc-web telemetry stream
|
|
10
|
+
* (`RegisterReceiver`) that clone-read can stall the client's read of the body. Reading the stream
|
|
11
|
+
* through a `fetch` captured before RUM patched the global avoids that.
|
|
12
|
+
*
|
|
13
|
+
* How: the parent transport invokes `globalThis.fetch(...)` **synchronously** while starting a call
|
|
14
|
+
* (it builds the request body synchronously, then calls fetch and returns the call object). We swap
|
|
15
|
+
* `globalThis.fetch` for that synchronous window only. JavaScript is single-threaded, so no other
|
|
16
|
+
* code — and therefore no other request — runs between the swap and the `finally` restore; the
|
|
17
|
+
* custom fetch cannot leak to unrelated requests. Reading the response happens later, but the
|
|
18
|
+
* `Response`/stream is already bound to the custom fetch by then.
|
|
19
|
+
*
|
|
20
|
+
* When `customFetch` is undefined this behaves exactly like {@link GrpcWebFetchTransport}.
|
|
21
|
+
*/
|
|
22
|
+
export declare class FetchInjectingGrpcWebTransport extends GrpcWebFetchTransport {
|
|
23
|
+
private readonly customFetch;
|
|
24
|
+
constructor(customFetch: typeof globalThis.fetch | undefined, options: GrpcWebOptions);
|
|
25
|
+
private withFetch;
|
|
26
|
+
unary<I extends object, O extends object>(method: MethodInfo<I, O>, input: I, options: RpcOptions): UnaryCall<I, O>;
|
|
27
|
+
serverStreaming<I extends object, O extends object>(method: MethodInfo<I, O>, input: I, options: RpcOptions): ServerStreamingCall<I, O>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { GrpcWebFetchTransport } from '@protobuf-ts/grpcweb-transport';
|
|
2
|
+
/**
|
|
3
|
+
* A {@link GrpcWebFetchTransport} that issues its requests through a caller-supplied `fetch` instead
|
|
4
|
+
* of the global one.
|
|
5
|
+
*
|
|
6
|
+
* Why: `@protobuf-ts/grpcweb-transport` calls `globalThis.fetch(...)` directly and exposes no option
|
|
7
|
+
* to inject a custom fetch. Datadog RUM (and similar agents) monkey-patch `window.fetch` and
|
|
8
|
+
* `clone()` + read every response to measure timing; on the long-lived grpc-web telemetry stream
|
|
9
|
+
* (`RegisterReceiver`) that clone-read can stall the client's read of the body. Reading the stream
|
|
10
|
+
* through a `fetch` captured before RUM patched the global avoids that.
|
|
11
|
+
*
|
|
12
|
+
* How: the parent transport invokes `globalThis.fetch(...)` **synchronously** while starting a call
|
|
13
|
+
* (it builds the request body synchronously, then calls fetch and returns the call object). We swap
|
|
14
|
+
* `globalThis.fetch` for that synchronous window only. JavaScript is single-threaded, so no other
|
|
15
|
+
* code — and therefore no other request — runs between the swap and the `finally` restore; the
|
|
16
|
+
* custom fetch cannot leak to unrelated requests. Reading the response happens later, but the
|
|
17
|
+
* `Response`/stream is already bound to the custom fetch by then.
|
|
18
|
+
*
|
|
19
|
+
* When `customFetch` is undefined this behaves exactly like {@link GrpcWebFetchTransport}.
|
|
20
|
+
*/
|
|
21
|
+
export class FetchInjectingGrpcWebTransport extends GrpcWebFetchTransport {
|
|
22
|
+
constructor(customFetch, options) {
|
|
23
|
+
super(options);
|
|
24
|
+
this.customFetch = customFetch;
|
|
25
|
+
}
|
|
26
|
+
withFetch(start) {
|
|
27
|
+
if (!this.customFetch) {
|
|
28
|
+
return start();
|
|
29
|
+
}
|
|
30
|
+
const original = globalThis.fetch;
|
|
31
|
+
globalThis.fetch = this.customFetch;
|
|
32
|
+
try {
|
|
33
|
+
return start();
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
globalThis.fetch = original;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
unary(method, input, options) {
|
|
40
|
+
return this.withFetch(() => super.unary(method, input, options));
|
|
41
|
+
}
|
|
42
|
+
serverStreaming(method, input, options) {
|
|
43
|
+
return this.withFetch(() => super.serverStreaming(method, input, options));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SubscriberStatusEnum } from '../../../models';
|
|
2
2
|
import { RegistrationMessage, } from '../../../grpc/teletubby_pb';
|
|
3
|
-
import {
|
|
3
|
+
import { FetchInjectingGrpcWebTransport } from './FetchInjectingGrpcWebTransport';
|
|
4
4
|
import { RocosLogger } from '../../../logger/RocosLogger';
|
|
5
5
|
import { TelemetryGatewayClient } from '../../../grpc/teletubby_pb.client';
|
|
6
6
|
import { TelemetryStreamAbstract } from './TelemetryStreamAbstract';
|
|
@@ -10,7 +10,11 @@ export class TelemetryStream extends TelemetryStreamAbstract {
|
|
|
10
10
|
this.logger = RocosLogger.getInstance(`TelemetryStreamWeb(${this.identifier})`);
|
|
11
11
|
const protocol = config.insecure ? 'http' : 'https';
|
|
12
12
|
const port = config.port ? `:${config.port}` : '';
|
|
13
|
-
|
|
13
|
+
// Optional caller-supplied fetch (e.g. captured before Datadog RUM patches window.fetch, whose
|
|
14
|
+
// response cloning otherwise stalls this long-lived stream). When omitted, the transport uses
|
|
15
|
+
// the global fetch. @protobuf-ts/grpcweb-transport has no fetch option, so the injection happens
|
|
16
|
+
// in FetchInjectingGrpcWebTransport.
|
|
17
|
+
const transport = new FetchInjectingGrpcWebTransport(config.fetch, {
|
|
14
18
|
baseUrl: `${protocol}://${this.url}${port}`,
|
|
15
19
|
format: config.grpcWebFormat,
|
|
16
20
|
});
|