@dx-do/client 7.3.0 → 7.4.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/index.cjs.js CHANGED
@@ -34640,6 +34640,9 @@ function authHeaderValue(captured, options) {
34640
34640
 
34641
34641
  /** Shell variable the emitted script reads the bearer token from. */
34642
34642
  const CURL_TOKEN_VAR = 'DXDO_TOKEN';
34643
+ /** Shell variables holding the gateway host and cohort the run used. */
34644
+ const CURL_HOST_VAR = 'DXDO_HOST';
34645
+ const CURL_COHORT_VAR = 'DXDO_COHORT';
34643
34646
  /**
34644
34647
  * Headers curl must own rather than replay.
34645
34648
  *
@@ -34653,6 +34656,31 @@ const CURL_OWNED_HEADERS = ['content-length', 'accept-encoding'];
34653
34656
  function shellQuote(value) {
34654
34657
  return `'${value.replace(/'/g, `'\\''`)}'`;
34655
34658
  }
34659
+ /** Escape for a double-quoted string, where the shell still expands things. */
34660
+ function doubleQuoteEscape(value) {
34661
+ return value.replace(/[\\"`$]/g, (c) => `\\${c}`);
34662
+ }
34663
+ /**
34664
+ * Renders the request URL, referring to `$DXDO_HOST`/`$DXDO_COHORT` when the
34665
+ * URL was built from them. Both are real values assigned at the top of the
34666
+ * script — hoisting them just means retargeting the whole script at another
34667
+ * tenant is a two-line edit rather than a find-and-replace over every request.
34668
+ *
34669
+ * A URL that does not start with host+cohort (the AXA session host builds its
34670
+ * own) is emitted literally, so nothing is silently mis-parameterised.
34671
+ */
34672
+ function urlExpression(entry) {
34673
+ const url = urlWithParams(entry);
34674
+ const { gatewayHost, cohortId } = entry;
34675
+ if (gatewayHost && cohortId) {
34676
+ const prefix = `${gatewayHost}${cohortId}`;
34677
+ if (url.startsWith(prefix)) {
34678
+ const rest = doubleQuoteEscape(url.slice(prefix.length));
34679
+ return `"$${CURL_HOST_VAR}$${CURL_COHORT_VAR}${rest}"`;
34680
+ }
34681
+ }
34682
+ return shellQuote(url);
34683
+ }
34656
34684
  function urlWithParams(entry) {
34657
34685
  const url = entry.requestConfig.url ?? '';
34658
34686
  const params = entry.requestConfig.params;
@@ -34682,15 +34710,16 @@ function bodyOf(entry) {
34682
34710
  /**
34683
34711
  * Renders one captured request as a runnable curl invocation.
34684
34712
  *
34685
- * The gateway URL is emitted literally — it is not a credential, and baking it
34686
- * in is what makes the output runnable without a dx-do config. The bearer
34687
- * token is referenced through `$DXDO_TOKEN` unless `includeToken` is set.
34713
+ * The tenant is real, not a placeholder — that is what makes the output
34714
+ * runnable without a dx-do config — but it reaches the URL through
34715
+ * `$DXDO_HOST`/`$DXDO_COHORT`, assigned once at the top of the script. The
34716
+ * bearer token is referenced through `$DXDO_TOKEN` unless `includeToken` is set.
34688
34717
  */
34689
34718
  function createCurlCommand(entry, options = {}) {
34690
34719
  const method = (entry.requestConfig.method ?? 'get').toUpperCase();
34691
34720
  const lines = [
34692
34721
  `curl -sS --compressed -X ${method} \\`,
34693
- ` ${shellQuote(urlWithParams(entry))} \\`,
34722
+ ` ${urlExpression(entry)} \\`,
34694
34723
  ];
34695
34724
  let sawAuth = false;
34696
34725
  for (const [key, value] of flattenAxiosHeaders(entry.requestConfig)) {
@@ -34738,7 +34767,19 @@ function createCurlScript(entries, options = {}) {
34738
34767
  header.push('# WARNING: this script contains a live bearer token. Do not attach it to', '# an issue, paste it into chat, or commit it. Re-generate without', '# DXDO_EXPORT_INCLUDE_TOKEN to get a shareable version.', '', 'set -euo pipefail', '');
34739
34768
  }
34740
34769
  else {
34741
- header.push('# The gateway host is baked in; supply your own bearer token:', `# export ${CURL_TOKEN_VAR}='<your DXO2 token>'`, '', 'set -euo pipefail', '', `: "\${${CURL_TOKEN_VAR}:?set ${CURL_TOKEN_VAR} to a DXO2 bearer token}"`, '');
34770
+ header.push('# Tenant is filled in below; supply your own bearer token:', `# export ${CURL_TOKEN_VAR}='<your DXO2 token>'`, '', 'set -euo pipefail', '', `: "\${${CURL_TOKEN_VAR}:?set ${CURL_TOKEN_VAR} to a DXO2 bearer token}"`, '');
34771
+ }
34772
+ // The tenant the run actually used, hoisted so retargeting the script is a
34773
+ // two-line edit rather than a find-and-replace across every request. Values,
34774
+ // not placeholders — the script runs as-is.
34775
+ const target = entries.find((e) => e.gatewayHost && e.cohortId);
34776
+ if (target) {
34777
+ header.push(`${CURL_HOST_VAR}=${shellQuote(target.gatewayHost)}`, `${CURL_COHORT_VAR}=${shellQuote(target.cohortId)}`, '');
34778
+ const mixed = entries.some((e) => e.gatewayHost && e.cohortId &&
34779
+ (e.gatewayHost !== target.gatewayHost || e.cohortId !== target.cohortId));
34780
+ if (mixed) {
34781
+ header.push('# NOTE: this capture spans more than one tenant. Requests that do not', `# match ${CURL_HOST_VAR}/${CURL_COHORT_VAR} keep their URL inline.`, '');
34782
+ }
34742
34783
  }
34743
34784
  const body = entries.map((entry, i) => {
34744
34785
  const path = (() => {
@@ -72302,6 +72343,8 @@ class DxSaasService {
72302
72343
  },
72303
72344
  command: this.postmanMeta,
72304
72345
  at: DateTime.now().toMillis(),
72346
+ gatewayHost: this.dxdoConfiguration.dxConfiguration.dxGatewayHost,
72347
+ cohortId: this.simplifiedCohortId,
72305
72348
  };
72306
72349
  if (process__namespace.env.DXDO_POSTMAN_EXPORT ||
72307
72350
  process__namespace.env.DXDO_CURL_EXPORT) {
@@ -81160,6 +81203,8 @@ exports.BlobSchemaListResponseSchema = BlobSchemaListResponseSchema;
81160
81203
  exports.BlobService = BlobService;
81161
81204
  exports.BlobStoreParamsSchema = BlobStoreParamsSchema;
81162
81205
  exports.BlobStoreResponseSchema = BlobStoreResponseSchema;
81206
+ exports.CURL_COHORT_VAR = CURL_COHORT_VAR;
81207
+ exports.CURL_HOST_VAR = CURL_HOST_VAR;
81163
81208
  exports.CURL_TOKEN_VAR = CURL_TOKEN_VAR;
81164
81209
  exports.CalendarIntervalSchema = CalendarIntervalSchema;
81165
81210
  exports.CancelRevokeRequestSchema = CancelRevokeRequestSchema;