@opentap/runner-client 2.31.1 → 2.32.0-alpha.1.1.14247806004

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.
@@ -256,6 +256,6 @@ export declare class BaseClient {
256
256
  * @param subject The subject to send the request to
257
257
  * @returns Promise<T> The response from the request
258
258
  */
259
- dispatchRequest<T>(subject: string): Promise<T>;
259
+ dispatchRequest<T>(subject: string, payload?: any, options?: BaseClientRequestOptions): Promise<T>;
260
260
  }
261
261
  export {};
@@ -113,11 +113,11 @@ var BaseClient = /** @class */ (function () {
113
113
  * @returns Promise of an object
114
114
  */
115
115
  BaseClient.prototype.request = function (subject, payload, options) {
116
- var _a, _b;
116
+ var _a, _b, _c, _d;
117
117
  return __awaiter(this, void 0, void 0, function () {
118
118
  var data, headers, timeout, replySubject, serverMaxPayload, chunkSize, requestId, opts, fileDescriptor, chunkNumber, getChunk, subscription, responsePromise, chunk, i;
119
119
  var _this = this;
120
- return __generator(this, function (_c) {
120
+ return __generator(this, function (_e) {
121
121
  // Prepend the base subject if the given subject does not start with that
122
122
  if (!(options === null || options === void 0 ? void 0 : options.fullSubject)) {
123
123
  subject = "".concat(this.baseSubject, ".Request.").concat(subject);
@@ -129,14 +129,14 @@ var BaseClient = /** @class */ (function () {
129
129
  data = this.encode(payload);
130
130
  headers = this.buildHeaders();
131
131
  timeout = (options === null || options === void 0 ? void 0 : options.timeout) || this.timeout;
132
- replySubject = "".concat(subject, ".Reply.").concat((0, uuid_1.v4)());
133
- serverMaxPayload = (_b = (_a = this.connection) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.max_payload;
132
+ replySubject = (_b = (_a = options === null || options === void 0 ? void 0 : options.publishOptions) === null || _a === void 0 ? void 0 : _a.reply) !== null && _b !== void 0 ? _b : "".concat(subject, ".Reply.").concat((0, uuid_1.v4)());
133
+ serverMaxPayload = (_d = (_c = this.connection) === null || _c === void 0 ? void 0 : _c.info) === null || _d === void 0 ? void 0 : _d.max_payload;
134
134
  chunkSize = serverMaxPayload ? serverMaxPayload - 50000 : 512000;
135
135
  // The Session and the Client need to agree on the chunk size. Put it in a header.
136
136
  headers.append('ChunkSize', chunkSize.toString());
137
137
  requestId = (0, uuid_1.v4)();
138
138
  headers.append('RequestId', requestId);
139
- opts = __assign(__assign({}, options === null || options === void 0 ? void 0 : options.publishOptions), { headers: headers, reply: replySubject });
139
+ opts = __assign({ headers: headers, reply: replySubject }, options === null || options === void 0 ? void 0 : options.publishOptions);
140
140
  fileDescriptor = new DTOs_1.FileDescriptor(data.length, chunkSize);
141
141
  chunkNumber = 1;
142
142
  headers.set('ChunkNumber', chunkNumber.toString());
@@ -688,10 +688,10 @@ var BaseClient = /** @class */ (function () {
688
688
  * @param subject The subject to send the request to
689
689
  * @returns Promise<T> The response from the request
690
690
  */
691
- BaseClient.prototype.dispatchRequest = function (subject) {
691
+ BaseClient.prototype.dispatchRequest = function (subject, payload, options) {
692
692
  return __awaiter(this, void 0, void 0, function () {
693
693
  return __generator(this, function (_a) {
694
- return [2 /*return*/, this.request(subject)];
694
+ return [2 /*return*/, this.request(subject, payload, options)];
695
695
  });
696
696
  });
697
697
  };
@@ -256,6 +256,6 @@ export declare class BaseClient {
256
256
  * @param subject The subject to send the request to
257
257
  * @returns Promise<T> The response from the request
258
258
  */
259
- dispatchRequest<T>(subject: string): Promise<T>;
259
+ dispatchRequest<T>(subject: string, payload?: any, options?: BaseClientRequestOptions): Promise<T>;
260
260
  }
261
261
  export {};
@@ -60,7 +60,7 @@ export class BaseClient {
60
60
  * @returns Promise of an object
61
61
  */
62
62
  request(subject, payload, options) {
63
- var _a, _b;
63
+ var _a, _b, _c, _d;
64
64
  return __awaiter(this, void 0, void 0, function* () {
65
65
  // Prepend the base subject if the given subject does not start with that
66
66
  if (!(options === null || options === void 0 ? void 0 : options.fullSubject)) {
@@ -74,7 +74,7 @@ export class BaseClient {
74
74
  const headers = this.buildHeaders();
75
75
  const timeout = (options === null || options === void 0 ? void 0 : options.timeout) || this.timeout;
76
76
  // Generate a unique reply subject that we can subscribe to
77
- const replySubject = `${subject}.Reply.${uuidv4()}`;
77
+ const replySubject = (_b = (_a = options === null || options === void 0 ? void 0 : options.publishOptions) === null || _a === void 0 ? void 0 : _a.reply) !== null && _b !== void 0 ? _b : `${subject}.Reply.${uuidv4()}`;
78
78
  // Larger payloads are always faster because the request time is bound
79
79
  // by the number of chunks roundtrips we need to make.
80
80
  // 99% of requests will fit in a single chunk which is ideal,
@@ -82,14 +82,14 @@ export class BaseClient {
82
82
  // If serverMaxPayload is not available for some reason, we just use a default chunk size of 512000.
83
83
  // We subtract 50000 from max_payload in order to leave room for headers, which
84
84
  // can be quite large since they can contain jwt tokens, which may contain all sorts of information.
85
- const serverMaxPayload = (_b = (_a = this.connection) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.max_payload;
85
+ const serverMaxPayload = (_d = (_c = this.connection) === null || _c === void 0 ? void 0 : _c.info) === null || _d === void 0 ? void 0 : _d.max_payload;
86
86
  const chunkSize = serverMaxPayload ? serverMaxPayload - 50000 : 512000;
87
87
  // The Session and the Client need to agree on the chunk size. Put it in a header.
88
88
  headers.append('ChunkSize', chunkSize.toString());
89
89
  // Generate a unique request ID which the Session needs to associate chunks
90
90
  const requestId = uuidv4();
91
91
  headers.append('RequestId', requestId);
92
- const opts = Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.publishOptions), { headers, reply: replySubject });
92
+ const opts = Object.assign({ headers, reply: replySubject }, options === null || options === void 0 ? void 0 : options.publishOptions);
93
93
  const fileDescriptor = new FileDescriptor(data.length, chunkSize);
94
94
  // Put the chunk sequence number in a header so the session knows if a chunk is missing
95
95
  let chunkNumber = 1;
@@ -611,9 +611,9 @@ export class BaseClient {
611
611
  * @param subject The subject to send the request to
612
612
  * @returns Promise<T> The response from the request
613
613
  */
614
- dispatchRequest(subject) {
614
+ dispatchRequest(subject, payload, options) {
615
615
  return __awaiter(this, void 0, void 0, function* () {
616
- return this.request(subject);
616
+ return this.request(subject, payload, options);
617
617
  });
618
618
  }
619
619
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentap/runner-client",
3
- "version": "2.31.1",
3
+ "version": "2.32.0-alpha.1.1.14247806004",
4
4
  "description": "This is the web client for the OpenTAP Runner.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/mjs/index.js",