@enricai/barnacle 1.12.20 → 1.12.22

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.
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FOLD_RETURN_WILDCARD_SCALABLE_SPEC = exports.FOLD_RETURN_SCALABLE_SPEC = void 0;
3
4
  exports.buildCapture = buildCapture;
4
5
  exports.buildStep = buildStep;
5
6
  exports.buildMulticallHeterogeneousActionSteps = buildMulticallHeterogeneousActionSteps;
@@ -32,6 +33,8 @@ exports.buildMulticallSingleShotSearchDrillDownMultiMatchActionSteps = buildMult
32
33
  exports.buildMulticallSingleShotSearchDrillDownTypeMismatchJoinActionSteps = buildMulticallSingleShotSearchDrillDownTypeMismatchJoinActionSteps;
33
34
  exports.buildMulticallSingleShotSearchDrillDownChainedDependentMultipartChainStepActionSteps = buildMulticallSingleShotSearchDrillDownChainedDependentMultipartChainStepActionSteps;
34
35
  exports.buildMulticallSingleShotSearchDrillDownChainedDependentActionSteps = buildMulticallSingleShotSearchDrillDownChainedDependentActionSteps;
36
+ exports.buildMulticallSingleShotSearchDrillDownHeaderMintedChainedResponseValueActionSteps = buildMulticallSingleShotSearchDrillDownHeaderMintedChainedResponseValueActionSteps;
37
+ exports.buildMulticallSingleShotSearchDrillDownBooleanChainedResponseValueActionSteps = buildMulticallSingleShotSearchDrillDownBooleanChainedResponseValueActionSteps;
35
38
  exports.buildMulticallSingleShotSearchDrillDownNestedJoinFieldChainedDependentActionSteps = buildMulticallSingleShotSearchDrillDownNestedJoinFieldChainedDependentActionSteps;
36
39
  exports.buildMulticallSingleShotSearchDrillDownRequeriedPrimaryOverlapActionSteps = buildMulticallSingleShotSearchDrillDownRequeriedPrimaryOverlapActionSteps;
37
40
  exports.buildMulticallSingleShotSearchTwoIndependentArraysActionSteps = buildMulticallSingleShotSearchTwoIndependentArraysActionSteps;
@@ -41,18 +44,27 @@ exports.buildMulticallSingleShotSearchDrillDownOpaqueIntermediateChainedDependen
41
44
  exports.buildMulticallSingleShotSearchDrillDownRichnessTiedConfirmationHopChainedDependentActionSteps = buildMulticallSingleShotSearchDrillDownRichnessTiedConfirmationHopChainedDependentActionSteps;
42
45
  exports.buildMulticallSingleShotSearchDrillDownArrayWrappedChainedDependentActionSteps = buildMulticallSingleShotSearchDrillDownArrayWrappedChainedDependentActionSteps;
43
46
  exports.buildMulticallSingleShotSearchDrillDownArrayWrappedNumericChainedJoinFieldActionSteps = buildMulticallSingleShotSearchDrillDownArrayWrappedNumericChainedJoinFieldActionSteps;
47
+ exports.buildMulticallSingleShotSearchDrillDownShortNumericChainedJoinFieldActionSteps = buildMulticallSingleShotSearchDrillDownShortNumericChainedJoinFieldActionSteps;
48
+ exports.buildMulticallSingleShotSearchDrillDownShortCookieChainedJoinFieldActionSteps = buildMulticallSingleShotSearchDrillDownShortCookieChainedJoinFieldActionSteps;
44
49
  exports.buildMulticallSingleShotSearchDrillDownArrayWrappedImmediateJoinFieldActionSteps = buildMulticallSingleShotSearchDrillDownArrayWrappedImmediateJoinFieldActionSteps;
45
50
  exports.buildMulticallSingleShotSearchDrillDownArrayWrappedNumericImmediateJoinFieldActionSteps = buildMulticallSingleShotSearchDrillDownArrayWrappedNumericImmediateJoinFieldActionSteps;
51
+ exports.buildMulticallSingleShotSearchDrillDownArrayWrappedBooleanImmediateJoinFieldActionSteps = buildMulticallSingleShotSearchDrillDownArrayWrappedBooleanImmediateJoinFieldActionSteps;
52
+ exports.buildMulticallSingleShotSearchDrillDownHeaderThreadedJoinChainedDependentActionSteps = buildMulticallSingleShotSearchDrillDownHeaderThreadedJoinChainedDependentActionSteps;
53
+ exports.buildMulticallSingleShotSearchDrillDownGetEntryHopChainedDependentActionSteps = buildMulticallSingleShotSearchDrillDownGetEntryHopChainedDependentActionSteps;
54
+ exports.buildMulticallSingleShotSearchDrillDownResponseHeaderThreadedJoinChainedDependentActionSteps = buildMulticallSingleShotSearchDrillDownResponseHeaderThreadedJoinChainedDependentActionSteps;
55
+ exports.buildFoldReturnScalableActionSequence = buildFoldReturnScalableActionSequence;
56
+ exports.buildFoldReturnWildcardScalableActionSequence = buildFoldReturnWildcardScalableActionSequence;
57
+ const date_fns_1 = require("date-fns");
46
58
  function buildCapture(overrides) {
47
59
  return {
48
60
  timestamp: overrides.timestamp,
49
61
  phase: "action",
50
- method: "POST",
62
+ method: overrides.method ?? "POST",
51
63
  url: overrides.url,
52
64
  status: 200,
53
65
  requestHeaders: overrides.requestHeaders ?? { "Content-Type": "application/json" },
54
66
  requestPostData: overrides.requestPostData,
55
- responseHeaders: { "content-type": "application/json" },
67
+ responseHeaders: overrides.responseHeaders ?? { "content-type": "application/json" },
56
68
  responseBody: overrides.responseBody,
57
69
  operationName: null,
58
70
  query: null,
@@ -1102,6 +1114,84 @@ function buildMulticallSingleShotSearchDrillDownChainedDependentActionSteps() {
1102
1114
  }),
1103
1115
  ];
1104
1116
  }
1117
+ /**
1118
+ * A response-header sibling of {@link buildMulticallSingleShotSearchDrillDownChainedDependentActionSteps}:
1119
+ * the drill step's (`r1`) response mints its join token (`tok-a1`) ONLY in a
1120
+ * custom response HEADER (`X-Price-Token`) — its body is empty, unlike the
1121
+ * sibling's `priceToken` body field. A third step (`r2`) threads that header
1122
+ * value into its own request body and carries the real per-item `history[]`
1123
+ * array. `computeFoldChain`'s `dependsOnChain` check must walk `r1`'s
1124
+ * response headers (not just its body) to see the shared value, extending
1125
+ * the chain to `[drillStepIndex, historyStepIndex]` rather than stopping at
1126
+ * `r1`.
1127
+ */
1128
+ function buildMulticallSingleShotSearchDrillDownHeaderMintedChainedResponseValueActionSteps() {
1129
+ return [
1130
+ buildStep("r0", {
1131
+ url: CATALOG_SEARCH_URL,
1132
+ requestPostData: '{"page":1}',
1133
+ responseBody: {
1134
+ results: [{ sku: "sku-a" }, { sku: "sku-b" }],
1135
+ },
1136
+ timestamp: "2024-11-16T00:00:00Z",
1137
+ }),
1138
+ buildStep("r1", {
1139
+ url: CATALOG_PRICING_URL,
1140
+ requestPostData: '{"sku":"sku-a"}',
1141
+ responseBody: {},
1142
+ responseHeaders: { "content-type": "application/json", "X-Price-Token": "tok-a1" },
1143
+ timestamp: "2024-11-16T00:00:01Z",
1144
+ }),
1145
+ buildStep("r2", {
1146
+ url: CATALOG_PRICE_HISTORY_URL,
1147
+ requestPostData: '{"priceToken":"tok-a1"}',
1148
+ responseBody: {
1149
+ history: [{ sku: "sku-a", amount: 18.5, asOf: "2024-11-01" }],
1150
+ },
1151
+ timestamp: "2024-11-16T00:00:02Z",
1152
+ }),
1153
+ ];
1154
+ }
1155
+ const CATALOG_VERIFICATION_STATUS_URL = "https://api.example.com/catalog/verification-status";
1156
+ /**
1157
+ * A boolean-threading sibling of {@link buildMulticallSingleShotSearchDrillDownChainedDependentActionSteps}:
1158
+ * the drill step's (`r1`) response mints ONLY a boolean value
1159
+ * (`{ verified: true }`) and carries no array of its own — unlike the
1160
+ * `priceToken`/`prices[]` sibling, this drill step is NOT foldable in
1161
+ * isolation. A third step (`r2`) threads that boolean (rendered as the
1162
+ * string `"true"`) into its request and carries the real per-item
1163
+ * `history[]` array in its response. `computeFoldChain` must recognize the
1164
+ * boolean leaf as a genuine chain-dependency source and extend the chain to
1165
+ * `[drillStepIndex, historyStepIndex]` rather than stopping at `r1`.
1166
+ */
1167
+ function buildMulticallSingleShotSearchDrillDownBooleanChainedResponseValueActionSteps() {
1168
+ return [
1169
+ buildStep("r0", {
1170
+ url: CATALOG_SEARCH_URL,
1171
+ requestPostData: '{"page":1}',
1172
+ responseBody: {
1173
+ results: [{ sku: "sku-a" }, { sku: "sku-b" }],
1174
+ },
1175
+ timestamp: "2024-12-01T00:00:00Z",
1176
+ }),
1177
+ buildStep("r1", {
1178
+ url: CATALOG_PRICING_URL,
1179
+ requestPostData: '{"sku":"sku-a"}',
1180
+ responseBody: {
1181
+ verified: true,
1182
+ },
1183
+ timestamp: "2024-12-01T00:00:01Z",
1184
+ }),
1185
+ buildStep("r2", {
1186
+ url: CATALOG_VERIFICATION_STATUS_URL,
1187
+ requestPostData: '{"verified":"true"}',
1188
+ responseBody: {
1189
+ history: [{ sku: "sku-a", amount: 18.5, asOf: "2024-11-01" }],
1190
+ },
1191
+ timestamp: "2024-12-01T00:00:02Z",
1192
+ }),
1193
+ ];
1194
+ }
1105
1195
  /**
1106
1196
  * A nested-join-key sibling of {@link buildMulticallSingleShotSearchDrillDownChainedDependentActionSteps}:
1107
1197
  * each primary `results[]` item carries its join key under a nested
@@ -1505,6 +1595,90 @@ function buildMulticallSingleShotSearchDrillDownArrayWrappedNumericChainedJoinFi
1505
1595
  }),
1506
1596
  ];
1507
1597
  }
1598
+ /**
1599
+ * A sibling of
1600
+ * {@link buildMulticallSingleShotSearchDrillDownArrayWrappedNumericChainedJoinFieldActionSteps}
1601
+ * isolating a DIFFERENT gap in the numeric chain-produced join field family:
1602
+ * `r1`'s produced token is a bare (non-array-wrapped) JSON number, and — the
1603
+ * shape that matters here — it is SHORT (`42`/`43`, two digits) rather than
1604
+ * an 8-digit token. `indexStateValues` gates every candidate state value on
1605
+ * `MIN_STATE_VALUE_LENGTH` (8 chars), a threshold sized to keep an unrelated
1606
+ * short STRING (an enum code, a page number) from colliding with arbitrary
1607
+ * substrings elsewhere; applied uniformly to a bare NUMBER's stringified
1608
+ * length, it also silently excludes a short numeric id/token — exactly the
1609
+ * common shape for an order/account/status id — from ever being indexed as
1610
+ * producible state. Without that index entry, `compileActionSteps` never
1611
+ * emits a `produces[]` accessor for `r1`'s response, so `r2`'s templated
1612
+ * body has nothing to substitute and falls back to treating `{"token":...}`
1613
+ * as an opaque caller-supplied payload field (`payload.token`) instead of
1614
+ * the per-item threaded value — every iteration would send whatever (or
1615
+ * nothing) the caller passed, not each primary item's own token.
1616
+ */
1617
+ function buildMulticallSingleShotSearchDrillDownShortNumericChainedJoinFieldActionSteps() {
1618
+ return [
1619
+ buildStep("r0", {
1620
+ url: CATALOG_SEARCH_URL,
1621
+ requestPostData: '{"page":1}',
1622
+ responseBody: {
1623
+ results: [{ orderId: "order-a" }, { orderId: "order-b" }],
1624
+ },
1625
+ timestamp: "2024-10-04T00:00:00Z",
1626
+ }),
1627
+ buildStep("r1", {
1628
+ url: CATALOG_ORDER_STATUS_URL,
1629
+ requestPostData: '{"orderId":"order-a"}',
1630
+ responseBody: [42],
1631
+ timestamp: "2024-10-04T00:00:01Z",
1632
+ }),
1633
+ buildStep("r2", {
1634
+ url: ORDER_HISTORY_URL,
1635
+ requestPostData: '{"token":42}',
1636
+ responseBody: {
1637
+ entries: [{ token: 42, ts: "2024-10-04T00:00:02Z", event: "shipped" }],
1638
+ },
1639
+ timestamp: "2024-10-04T00:00:02Z",
1640
+ }),
1641
+ ];
1642
+ }
1643
+ /**
1644
+ * Cookie-origin sibling of
1645
+ * {@link buildMulticallSingleShotSearchDrillDownShortNumericChainedJoinFieldActionSteps}:
1646
+ * here `r1` mints the short chain-produced token (`tok1`, under
1647
+ * `MIN_STATE_VALUE_LENGTH`) via `Set-Cookie` rather than the response body,
1648
+ * AND echoes the same value in its response body (the "body-level echo" that
1649
+ * lets {@link collectDependentDrillDownChainValues} confirm the cookie value
1650
+ * is chain-produced, exactly as a body-sourced token would be). `r2` threads
1651
+ * `tok1` back via its request body. Exercises `indexStateValues`' Set-Cookie
1652
+ * branch's `chainForceIncludeValues`/`forceIncludeValues` exemption, mirroring
1653
+ * the body-value floor exemption.
1654
+ */
1655
+ function buildMulticallSingleShotSearchDrillDownShortCookieChainedJoinFieldActionSteps() {
1656
+ return [
1657
+ buildStep("r0", {
1658
+ url: CATALOG_SEARCH_URL,
1659
+ requestPostData: '{"page":1}',
1660
+ responseBody: {
1661
+ results: [{ orderId: "order-a" }, { orderId: "order-b" }],
1662
+ },
1663
+ timestamp: "2024-10-05T00:00:00Z",
1664
+ }),
1665
+ buildStep("r1", {
1666
+ url: CATALOG_ORDER_STATUS_URL,
1667
+ requestPostData: '{"orderId":"order-a"}',
1668
+ responseHeaders: { "set-cookie": "sess=tok1; Path=/; HttpOnly" },
1669
+ responseBody: { echoedToken: "tok1" },
1670
+ timestamp: "2024-10-05T00:00:01Z",
1671
+ }),
1672
+ buildStep("r2", {
1673
+ url: ORDER_HISTORY_URL,
1674
+ requestPostData: '{"token":"tok1"}',
1675
+ responseBody: {
1676
+ entries: [{ token: "tok1", ts: "2024-10-05T00:00:02Z", event: "shipped" }],
1677
+ },
1678
+ timestamp: "2024-10-05T00:00:02Z",
1679
+ }),
1680
+ ];
1681
+ }
1508
1682
  /**
1509
1683
  * A different sibling of the same array-wrapped-join-field failure family:
1510
1684
  * here it's the IMMEDIATE drill step (`r1`), not a later chain hop, whose
@@ -1585,4 +1759,331 @@ function buildMulticallSingleShotSearchDrillDownArrayWrappedNumericImmediateJoin
1585
1759
  }),
1586
1760
  ];
1587
1761
  }
1762
+ /**
1763
+ * Same array-wrapped-immediate-join-field shape as
1764
+ * {@link buildMulticallSingleShotSearchDrillDownArrayWrappedNumericImmediateJoinFieldActionSteps},
1765
+ * but the primary item's join field is a bare JSON BOOLEAN (`flag: true`)
1766
+ * rather than a number or string. `walkStringLeaves` (used by the spare
1767
+ * check in `applyStructuredValuePayloadSubstitutions`) silently skips
1768
+ * boolean leaves the same way it skips number leaves, so a boolean join
1769
+ * value wrapped in `{"flags":[true]}` was frozen into an opaque
1770
+ * `${JSON.stringify(payload.flags)}` blob instead of being spared for the
1771
+ * fold-loop's later per-item `parameterize` pass.
1772
+ */
1773
+ function buildMulticallSingleShotSearchDrillDownArrayWrappedBooleanImmediateJoinFieldActionSteps() {
1774
+ return [
1775
+ buildStep("r0", {
1776
+ url: CATALOG_SEARCH_URL,
1777
+ requestPostData: '{"page":1}',
1778
+ responseBody: {
1779
+ results: [{ flag: true }, { flag: false }],
1780
+ },
1781
+ timestamp: "2024-10-03T00:00:00Z",
1782
+ }),
1783
+ buildStep("r1", {
1784
+ url: CATALOG_ORDER_STATUS_URL,
1785
+ requestPostData: '{"flags":[true]}',
1786
+ responseBody: ["status-token-true"],
1787
+ timestamp: "2024-10-03T00:00:01Z",
1788
+ }),
1789
+ buildStep("r2", {
1790
+ url: ORDER_HISTORY_BULK_URL,
1791
+ requestPostData: '{"tokens":["status-token-true"]}',
1792
+ responseBody: {
1793
+ entries: [
1794
+ { statusToken: "status-token-true", ts: "2024-10-03T00:00:02Z", event: "shipped" },
1795
+ ],
1796
+ },
1797
+ timestamp: "2024-10-03T00:00:02Z",
1798
+ }),
1799
+ ];
1800
+ }
1801
+ const ACCOUNT_STATUS_URL = "https://api.example.com/accounts/status";
1802
+ const ACCOUNT_TRANSACTIONS_URL = "https://api.example.com/accounts/transactions";
1803
+ /**
1804
+ * A dependent (chained) drill-down whose join key is threaded ONLY through a
1805
+ * request HEADER (`API-Token`) on the chain's ENTRY hop (`r1`) — invisible to
1806
+ * `detectDrillDownFoldPlan`'s structural heuristic exactly like
1807
+ * {@link buildMulticallSingleShotSearchDrillDownHeaderThreadedJoinActionSteps}
1808
+ * — so only a flow-declared `foldReturn` can resolve this fold at all. Unlike
1809
+ * every existing header-threaded-join fixture, though, a site author writing
1810
+ * that `foldReturn` naturally points `endpointPattern` at `r2`
1811
+ * (`/accounts/transactions`) — the call whose OWN response actually carries
1812
+ * the per-item data (`transactions[]`) they want folded — not at `r1`
1813
+ * (`/accounts/status`), the opaque intermediate hop that merely carries the
1814
+ * `accountId`→`API-Token` header thread onward as a `statusToken`. `r2`'s own
1815
+ * request only ever carries that threaded `statusToken`, never `accountId`
1816
+ * in any form (body, URL, or header) — the join key is resolvable only by
1817
+ * walking back to `r1`, exactly the way `computeFoldChain` already walks
1818
+ * FORWARD from a resolved entry hop to a richer terminal. `resultsPath`
1819
+ * anchors on `accounts`, `joinFields` on `accountId`.
1820
+ */
1821
+ function buildMulticallSingleShotSearchDrillDownHeaderThreadedJoinChainedDependentActionSteps() {
1822
+ return [
1823
+ buildStep("r0", {
1824
+ url: ACCOUNT_SEARCH_URL,
1825
+ requestPostData: JSON.stringify({ page: 1 }),
1826
+ responseBody: {
1827
+ accounts: [
1828
+ { accountId: 42, name: "Acme" },
1829
+ { accountId: 43, name: "Globex" },
1830
+ ],
1831
+ },
1832
+ timestamp: "2024-08-01T00:00:00Z",
1833
+ }),
1834
+ buildStep("r1", {
1835
+ url: ACCOUNT_STATUS_URL,
1836
+ requestPostData: null,
1837
+ requestHeaders: { "Content-Type": "application/json", "API-Token": "42" },
1838
+ responseBody: { statusToken: "status-token-42" },
1839
+ timestamp: "2024-08-01T00:00:01Z",
1840
+ }),
1841
+ buildStep("r2", {
1842
+ url: ACCOUNT_TRANSACTIONS_URL,
1843
+ requestPostData: JSON.stringify({ statusToken: "status-token-42" }),
1844
+ responseBody: {
1845
+ transactions: [{ statusToken: "status-token-42", transactionId: "t-42", amount: 19.99 }],
1846
+ },
1847
+ timestamp: "2024-08-01T00:00:02Z",
1848
+ }),
1849
+ ];
1850
+ }
1851
+ const ORDER_STATUS_LOOKUP_URL = "https://api.example.com/orders/status-lookup";
1852
+ const ORDER_EVENTS_URL = "https://api.example.com/orders/events";
1853
+ /**
1854
+ * A dependent (chained) drill-down whose ENTRY hop (`r1`) is a `GET`
1855
+ * request — not the `POST` every other chained-dependent fixture in this
1856
+ * file uses — and whose response produces the chain's join value
1857
+ * (`statusToken`) as a non-UUID string. `indexStateValues` indexes a `GET`
1858
+ * capture's response leaves ONLY when they are UUID-shaped
1859
+ * (`isGet && !UUID_REGEX.test(value)` skips everything else, a filter aimed
1860
+ * at excluding noisy short non-UUID strings a GET-only telemetry/schema
1861
+ * fetch surfaces); that filter runs unconditionally, with no exemption for a
1862
+ * value `collectDependentDrillDownChainValues` has already confirmed is
1863
+ * threaded from this exact hop into a later chain hop's own request — unlike
1864
+ * the `MIN_STATE_VALUE_LENGTH` floor a few lines above it, which DOES carry
1865
+ * that exemption. So a chain-produced token minted by a GET response is
1866
+ * never indexed as producible state at all, `compileActionSteps` never
1867
+ * emits a `produces[]` accessor for it, and `r2`'s templated body has
1868
+ * nothing to substitute — every iteration renders the literal string
1869
+ * `"undefined"` instead of threading each primary item's own token.
1870
+ */
1871
+ function buildMulticallSingleShotSearchDrillDownGetEntryHopChainedDependentActionSteps() {
1872
+ return [
1873
+ buildStep("r0", {
1874
+ url: CATALOG_SEARCH_URL,
1875
+ requestPostData: '{"page":1}',
1876
+ responseBody: {
1877
+ results: [{ orderId: "order-a" }, { orderId: "order-b" }],
1878
+ },
1879
+ timestamp: "2024-10-05T00:00:00Z",
1880
+ }),
1881
+ buildStep("r1", {
1882
+ method: "GET",
1883
+ url: `${ORDER_STATUS_LOOKUP_URL}?orderId=order-a`,
1884
+ requestPostData: null,
1885
+ responseBody: { statusToken: "status-token-order-a" },
1886
+ timestamp: "2024-10-05T00:00:01Z",
1887
+ }),
1888
+ buildStep("r2", {
1889
+ url: ORDER_EVENTS_URL,
1890
+ requestPostData: '{"token":"status-token-order-a"}',
1891
+ responseBody: {
1892
+ entries: [{ token: "status-token-order-a", ts: "2024-10-05T00:00:02Z", event: "shipped" }],
1893
+ },
1894
+ timestamp: "2024-10-05T00:00:02Z",
1895
+ }),
1896
+ ];
1897
+ }
1898
+ /**
1899
+ * A response-header sibling of {@link buildMulticallSingleShotSearchDrillDownGetEntryHopChainedDependentActionSteps}:
1900
+ * the chain's drill hop (`r1`) mints its join token (`tok-a1`) ONLY in a
1901
+ * custom response HEADER (`X-Price-Token`) — its body is empty ({}), unlike
1902
+ * {@link buildMulticallSingleShotSearchDrillDownHeaderMintedChainedResponseValueActionSteps}'s
1903
+ * body-echo-free sibling, which threads the header value forward via the
1904
+ * request BODY. Here the terminal hop (`r2`) instead threads that value back
1905
+ * as a REQUEST HEADER of its own (also named `X-Price-Token`) — the only
1906
+ * shape `createHttpClient`'s `bind` option can actually thread a
1907
+ * header-origin value into, since the emitted response variable never
1908
+ * exposes response headers to the rest of the generated code. Exercises
1909
+ * `compileActionSteps`' non-cookie response-header produce block: without it,
1910
+ * `tok-a1` is never captured into a `produces[]`/`bind` entry at all, and
1911
+ * `r2`'s per-item call goes out with no `X-Price-Token` header, so the
1912
+ * terminal `history[]` fold silently collapses to whichever primary item the
1913
+ * stub happens to answer first instead of each item's own token.
1914
+ */
1915
+ function buildMulticallSingleShotSearchDrillDownResponseHeaderThreadedJoinChainedDependentActionSteps() {
1916
+ return [
1917
+ buildStep("r0", {
1918
+ url: CATALOG_SEARCH_URL,
1919
+ requestPostData: '{"page":1}',
1920
+ responseBody: {
1921
+ results: [{ sku: "sku-a" }, { sku: "sku-b" }],
1922
+ },
1923
+ timestamp: "2024-12-10T00:00:00Z",
1924
+ }),
1925
+ buildStep("r1", {
1926
+ url: CATALOG_PRICING_URL,
1927
+ requestPostData: '{"sku":"sku-a"}',
1928
+ responseBody: {},
1929
+ responseHeaders: { "content-type": "application/json", "X-Price-Token": "tok-a1" },
1930
+ timestamp: "2024-12-10T00:00:01Z",
1931
+ }),
1932
+ buildStep("r2", {
1933
+ url: CATALOG_PRICE_HISTORY_URL,
1934
+ requestPostData: "{}",
1935
+ requestHeaders: { "Content-Type": "application/json", "X-Price-Token": "tok-a1" },
1936
+ responseBody: {
1937
+ history: [{ sku: "sku-a", amount: 18.5, asOf: "2024-11-01" }],
1938
+ },
1939
+ timestamp: "2024-12-10T00:00:02Z",
1940
+ }),
1941
+ ];
1942
+ }
1943
+ /**
1944
+ * The declared `foldReturn` matching {@link buildFoldReturnScalableActionSequence}'s
1945
+ * lone real primary/drill-down pair. The join value is threaded only through
1946
+ * a request HEADER (never the URL or body), mirroring the header-threaded
1947
+ * fixtures used elsewhere in this module — `detectDrillDownFoldPlan`'s
1948
+ * structural heuristic never scans headers, so resolving this pair is only
1949
+ * reachable through `buildFoldPlanFromSpec`, the exact code path the
1950
+ * incident's large-capture-set hang was traced to.
1951
+ */
1952
+ exports.FOLD_RETURN_SCALABLE_SPEC = {
1953
+ endpointPattern: "/catalog/pricing/",
1954
+ resultsPath: "results",
1955
+ joinFields: ["sku"],
1956
+ };
1957
+ const FOLD_RETURN_SCALABLE_BASE_TIMESTAMP = new Date("2024-11-01T00:00:00.000Z");
1958
+ /**
1959
+ * Generates `n` {@link MulticallFixtureStep} entries reproducing the reported
1960
+ * incident's shape at any scale: a large capture set dominated by noise
1961
+ * candidates, with exactly one primary/drill-down pair that actually
1962
+ * satisfies {@link FOLD_RETURN_SCALABLE_SPEC}. The real primary is placed
1963
+ * first and the real drill-down last, so every noise step sits between them
1964
+ * and `buildFoldPlanFromSpec`'s primary×drill scan has to walk the full
1965
+ * candidate set to find the one true match — the same "one eligible pair
1966
+ * buried among many candidates" shape the incident's 2000+-capture run hit.
1967
+ *
1968
+ * Noise steps alternate between two shapes that are each independently
1969
+ * eligible for one side of the scan without ever completing a match:
1970
+ * - a "noise primary" re-hitting the same search endpoint with its own
1971
+ * unique `sku`, so `objectItemsAtPath` treats it as a valid primary
1972
+ * candidate at every even noise slot;
1973
+ * - a "noise drill" re-hitting the same pricing endpoint (so it passes
1974
+ * `compileFoldReturnEndpointMatcher`) with its own unique, non-matching
1975
+ * `X-Item-Sku` header, so every real primary/noise-drill and noise-
1976
+ * primary/real-drill combination is scanned and rejected.
1977
+ *
1978
+ * Since no noise step's join value ever matches another step's, none of
1979
+ * them can complete a fold — `resolveFoldPlan` still returns exactly the one
1980
+ * plan for the real pair, regardless of how large `n` is.
1981
+ */
1982
+ function buildFoldReturnScalableActionSequence(n) {
1983
+ if (n < 2)
1984
+ throw new Error(`buildFoldReturnScalableActionSequence requires n >= 2, got ${n}`);
1985
+ const timestampAt = (index) => (0, date_fns_1.addSeconds)(FOLD_RETURN_SCALABLE_BASE_TIMESTAMP, index).toISOString();
1986
+ const realPrimary = buildStep("primary", {
1987
+ url: CATALOG_SEARCH_URL,
1988
+ requestPostData: '{"page":1}',
1989
+ responseBody: { results: [{ sku: "sku-real" }] },
1990
+ timestamp: timestampAt(0),
1991
+ });
1992
+ const realDrill = buildStep("drill", {
1993
+ url: CATALOG_PRICING_URL,
1994
+ requestPostData: '{"lookup":true}',
1995
+ responseBody: { prices: [{ sku: "sku-real", amount: 19.99 }] },
1996
+ timestamp: timestampAt(n - 1),
1997
+ requestHeaders: { "Content-Type": "application/json", "X-Item-Sku": "sku-real" },
1998
+ });
1999
+ const noiseSteps = Array.from({ length: n - 2 }, (_, i) => {
2000
+ const index = i + 1;
2001
+ return i % 2 === 0
2002
+ ? buildStep(`noise-primary-${i}`, {
2003
+ url: CATALOG_SEARCH_URL,
2004
+ requestPostData: `{"page":${index + 1}}`,
2005
+ responseBody: { results: [{ sku: `sku-noise-primary-${i}` }] },
2006
+ timestamp: timestampAt(index),
2007
+ })
2008
+ : buildStep(`noise-drill-${i}`, {
2009
+ url: CATALOG_PRICING_URL,
2010
+ requestPostData: '{"lookup":true}',
2011
+ responseBody: { prices: [{ sku: `sku-noise-drill-${i}`, amount: 9.99 }] },
2012
+ timestamp: timestampAt(index),
2013
+ requestHeaders: {
2014
+ "Content-Type": "application/json",
2015
+ "X-Item-Sku": `sku-noise-drill-${i}`,
2016
+ },
2017
+ });
2018
+ });
2019
+ return [realPrimary, ...noiseSteps, realDrill];
2020
+ }
2021
+ /**
2022
+ * A wildcard-`resultsPath` sibling of {@link FOLD_RETURN_SCALABLE_SPEC}: the
2023
+ * primary item lives under a single nested array-of-objects hop
2024
+ * (`groups.*.items`) rather than a flat top-level array, exercising
2025
+ * {@link objectItemsAtPath}'s `ARRAY_WILDCARD_SEGMENT` flatMap branch instead
2026
+ * of its flat-path branch. Pairs with
2027
+ * {@link buildFoldReturnWildcardScalableActionSequence}, which reproduces the
2028
+ * same "one real pair buried among many candidates" shape as
2029
+ * {@link buildFoldReturnScalableActionSequence} but with every primary's
2030
+ * items nested one `groups[]` level deep.
2031
+ */
2032
+ exports.FOLD_RETURN_WILDCARD_SCALABLE_SPEC = {
2033
+ endpointPattern: "/catalog/pricing/",
2034
+ resultsPath: "groups.*.items",
2035
+ joinFields: ["sku"],
2036
+ };
2037
+ /**
2038
+ * Wildcard-`resultsPath` sibling of {@link buildFoldReturnScalableActionSequence}:
2039
+ * identical noise/real-pair shape and scale, except every primary response
2040
+ * (real and noise alike) nests its item under a single-element `groups[]`
2041
+ * array (`{ groups: [ { items: [...] } ] }`) instead of a flat top-level
2042
+ * array, so `objectItemsAtPath` must resolve {@link
2043
+ * FOLD_RETURN_WILDCARD_SCALABLE_SPEC}'s `groups.*.items` wildcard path
2044
+ * across the full candidate set rather than a flat `resultsPath`. Proves the
2045
+ * value-indexed pruning `buildFoldPlanFromSpec` relies on (keyed on join
2046
+ * VALUES, not on `resultsPath` shape) stays linear at scale under the
2047
+ * wildcard branch too.
2048
+ */
2049
+ function buildFoldReturnWildcardScalableActionSequence(n) {
2050
+ if (n < 2) {
2051
+ throw new Error(`buildFoldReturnWildcardScalableActionSequence requires n >= 2, got ${n}`);
2052
+ }
2053
+ const timestampAt = (index) => (0, date_fns_1.addSeconds)(FOLD_RETURN_SCALABLE_BASE_TIMESTAMP, index).toISOString();
2054
+ const realPrimary = buildStep("primary", {
2055
+ url: CATALOG_SEARCH_URL,
2056
+ requestPostData: '{"page":1}',
2057
+ responseBody: { groups: [{ items: [{ sku: "sku-real" }] }] },
2058
+ timestamp: timestampAt(0),
2059
+ });
2060
+ const realDrill = buildStep("drill", {
2061
+ url: CATALOG_PRICING_URL,
2062
+ requestPostData: '{"lookup":true}',
2063
+ responseBody: { prices: [{ sku: "sku-real", amount: 19.99 }] },
2064
+ timestamp: timestampAt(n - 1),
2065
+ requestHeaders: { "Content-Type": "application/json", "X-Item-Sku": "sku-real" },
2066
+ });
2067
+ const noiseSteps = Array.from({ length: n - 2 }, (_, i) => {
2068
+ const index = i + 1;
2069
+ return i % 2 === 0
2070
+ ? buildStep(`noise-primary-${i}`, {
2071
+ url: CATALOG_SEARCH_URL,
2072
+ requestPostData: `{"page":${index + 1}}`,
2073
+ responseBody: { groups: [{ items: [{ sku: `sku-noise-primary-${i}` }] }] },
2074
+ timestamp: timestampAt(index),
2075
+ })
2076
+ : buildStep(`noise-drill-${i}`, {
2077
+ url: CATALOG_PRICING_URL,
2078
+ requestPostData: '{"lookup":true}',
2079
+ responseBody: { prices: [{ sku: `sku-noise-drill-${i}`, amount: 9.99 }] },
2080
+ timestamp: timestampAt(index),
2081
+ requestHeaders: {
2082
+ "Content-Type": "application/json",
2083
+ "X-Item-Sku": `sku-noise-drill-${i}`,
2084
+ },
2085
+ });
2086
+ });
2087
+ return [realPrimary, ...noiseSteps, realDrill];
2088
+ }
1588
2089
  //# sourceMappingURL=recon-generate-multicall-fixture.js.map