@valerypopoff/rivet2-core 2.10.0 → 2.11.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.
@@ -60,16 +60,12 @@ export class GetGlobalNodeImpl extends NodeImpl {
60
60
  return [
61
61
  {
62
62
  type: 'custom',
63
- label: 'Search Global Variables',
64
- customEditorId: 'GetGlobalVariableSelector',
65
- autoFocus: true,
66
- },
67
- {
68
- type: 'string',
69
63
  label: 'Variable ID',
64
+ customEditorId: 'GetGlobalVariableSelector',
70
65
  dataKey: 'id',
71
66
  useInputToggleDataKey: 'useIdInput',
72
67
  includeInGraphSearch: true,
68
+ autoFocus: true,
73
69
  },
74
70
  {
75
71
  type: 'dataTypeSelector',
@@ -9,6 +9,7 @@ import { getError } from '../../utils/errors.js';
9
9
  const REQUEST_FAILED_OUTPUT_ID = 'requestFailed';
10
10
  const REQUEST_ERROR_OUTPUT_ID = 'requestError';
11
11
  const STATUS_CODE_OUTPUT_ID = 'statusCode';
12
+ const RESPONSE_HEADERS_OUTPUT_ID = 'res_headers';
12
13
  const DEFAULT_RETRY_ON_NON_200_REPEAT_TIMES = 1;
13
14
  const DEFAULT_RETRY_ON_NON_200_COOLDOWN_MS = 0;
14
15
  function isAbortError(error, signal) {
@@ -54,13 +55,18 @@ function formatCaughtRequestFailureError(error, seen = new Set()) {
54
55
  function createHttpCallRequestAttempts() {
55
56
  return {
56
57
  statusCodeValues: [],
58
+ responseHeaderValues: [],
57
59
  requestFailedValues: [],
58
60
  requestErrorMessages: [],
59
61
  };
60
62
  }
63
+ function getHttpCallResponseHeaders(response) {
64
+ return Object.fromEntries(response.headers.entries());
65
+ }
61
66
  function recordHttpCallResponseAttempt(attempts, response) {
62
67
  const requestFailed = response.status !== 200;
63
68
  attempts.statusCodeValues.push(response.status);
69
+ attempts.responseHeaderValues.push(getHttpCallResponseHeaders(response));
64
70
  attempts.requestFailedValues.push(requestFailed);
65
71
  if (requestFailed) {
66
72
  attempts.requestErrorMessages.push(formatCaughtRequestFailureError(buildNon2xxStatusCodeError(response.status)));
@@ -84,6 +90,22 @@ function buildRetryAttemptOutput(type, values) {
84
90
  value: undefined,
85
91
  };
86
92
  }
93
+ function buildHttpCallResponseMetadataOutputs(response, requestAttempts) {
94
+ return {
95
+ [STATUS_CODE_OUTPUT_ID]: requestAttempts
96
+ ? buildRetryAttemptOutput('number[]', requestAttempts.statusCodeValues)
97
+ : {
98
+ type: 'number',
99
+ value: response.status,
100
+ },
101
+ [RESPONSE_HEADERS_OUTPUT_ID]: requestAttempts
102
+ ? buildRetryAttemptOutput('object[]', requestAttempts.responseHeaderValues)
103
+ : {
104
+ type: 'object',
105
+ value: getHttpCallResponseHeaders(response),
106
+ },
107
+ };
108
+ }
87
109
  function isCaughtFailureAlreadyRecorded(attempts, error) {
88
110
  const formattedError = formatCaughtRequestFailureError(error);
89
111
  if (attempts.requestErrorMessages.at(-1) === formattedError) {
@@ -104,7 +126,7 @@ function withCaughtFailureAttemptFallback(attempts, error) {
104
126
  const requestFailedValues = attempts.requestFailedValues.length > 0 ? [...attempts.requestFailedValues] : [true];
105
127
  requestFailedValues[requestFailedValues.length - 1] = true;
106
128
  return {
107
- statusCodeValues: attempts.statusCodeValues,
129
+ ...attempts,
108
130
  requestFailedValues,
109
131
  requestErrorMessages: [...attempts.requestErrorMessages, formatCaughtRequestFailureError(error)],
110
132
  };
@@ -156,7 +178,7 @@ function buildRequestFailedOutputs(params) {
156
178
  type: 'control-flow-excluded',
157
179
  value: undefined,
158
180
  },
159
- ['res_headers']: {
181
+ [RESPONSE_HEADERS_OUTPUT_ID]: {
160
182
  type: 'control-flow-excluded',
161
183
  value: undefined,
162
184
  },
@@ -321,8 +343,8 @@ export class HttpCallNodeImpl extends NodeImpl {
321
343
  id: STATUS_CODE_OUTPUT_ID,
322
344
  title: 'Status Code',
323
345
  }, {
324
- dataType: 'object',
325
- id: 'res_headers',
346
+ dataType: this.data.retryOnNon200 ? 'object[]' : 'object',
347
+ id: RESPONSE_HEADERS_OUTPUT_ID,
326
348
  title: 'Headers',
327
349
  });
328
350
  if (this.data.catchRequestFailed || this.data.retryOnNon200) {
@@ -411,6 +433,9 @@ export class HttpCallNodeImpl extends NodeImpl {
411
433
  type: 'toggle',
412
434
  label: 'Fail on non-2XX status code',
413
435
  dataKey: 'errorOnNon200',
436
+ helperMessage: (data) => data.retryOnNon200
437
+ ? 'With Retry on non-200 enabled, only the final response after all retries is checked.'
438
+ : undefined,
414
439
  },
415
440
  {
416
441
  type: 'toggle',
@@ -520,21 +545,27 @@ export class HttpCallNodeImpl extends NodeImpl {
520
545
  response = await performTrackedRequest();
521
546
  }
522
547
  }
548
+ const responseMetadataOutputs = buildHttpCallResponseMetadataOutputs(response, requestAttempts);
523
549
  if (this.data.errorOnNon200 && !response.ok) {
550
+ // The request reached the server, so retain its response metadata for
551
+ // display on the terminal nodeError. It remains inspection evidence,
552
+ // never a successful graph output. Caught failures return their
553
+ // existing normal output contract instead and must not leave a stale
554
+ // failure checkpoint behind.
555
+ if (!this.data.catchRequestFailed) {
556
+ // GraphProcessor supplies the durable terminal channel. Direct/custom
557
+ // node consumers receive the same metadata through their ordinary
558
+ // live-output callback when that channel is unavailable.
559
+ if (context.setFailureOutputs) {
560
+ context.setFailureOutputs(responseMetadataOutputs);
561
+ }
562
+ else {
563
+ context.onPartialOutputs?.(responseMetadataOutputs);
564
+ }
565
+ }
524
566
  throw buildNon2xxStatusCodeError(response.status);
525
567
  }
526
- const output = {
527
- [STATUS_CODE_OUTPUT_ID]: requestAttempts
528
- ? buildRetryAttemptOutput('number[]', requestAttempts.statusCodeValues)
529
- : {
530
- type: 'number',
531
- value: response.status,
532
- },
533
- ['res_headers']: {
534
- type: 'object',
535
- value: Object.fromEntries(response.headers.entries()),
536
- },
537
- };
568
+ const output = responseMetadataOutputs;
538
569
  if (this.data.isBinaryOutput) {
539
570
  const responseBlob = await response.blob();
540
571
  output['binary'] = {
@@ -87,7 +87,7 @@ export class MatchNodeImpl extends NodeImpl {
87
87
  return outputs;
88
88
  }
89
89
  getBody() {
90
- return this.data.exclusive ? 'Trigger the first matching case only' : 'Trigger all matching cases';
90
+ return this.data.exclusive ? 'Trigger: First matching case only' : 'Trigger: All matching cases';
91
91
  }
92
92
  getEditors() {
93
93
  return [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valerypopoff/rivet2-core",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/cjs/bundle.cjs",
6
6
  "module": "dist/esm/index.js",