@cubejs-client/core 1.8.3 → 1.8.5

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.
@@ -27,7 +27,6 @@ export class HttpTransport {
27
27
  const requestMethod = method ?? this.method ?? (url.length < 2000 ? 'GET' : 'POST');
28
28
  if (requestMethod === 'POST') {
29
29
  url = `${this.apiUrl}/${apiMethod}`;
30
- this.headers['Content-Type'] = 'application/json';
31
30
  }
32
31
  const effectiveFetchTimeout = fetchTimeout ?? this.fetchTimeout;
33
32
  const actualSignal = signal ||
@@ -43,6 +42,7 @@ export class HttpTransport {
43
42
  Authorization: this.authorization,
44
43
  'x-request-id': baseRequestId && `${baseRequestId}-span-${spanCounter++}`,
45
44
  ...this.headers,
45
+ ...(requestMethod === 'POST' ? { 'Content-Type': 'application/json' } : {}),
46
46
  },
47
47
  credentials: this.credentials,
48
48
  body: requestMethod === 'POST' ? JSON.stringify(params) : null,
@@ -88,7 +88,6 @@ export class HttpTransport {
88
88
  const requestMethod = method ?? this.method ?? 'POST';
89
89
  if (requestMethod === 'POST') {
90
90
  url = `${this.apiUrl}/${apiMethod}`;
91
- this.headers['Content-Type'] = 'application/json';
92
91
  }
93
92
  const effectiveFetchTimeout = fetchTimeout ?? this.fetchTimeout;
94
93
  let controller;
@@ -106,6 +105,7 @@ export class HttpTransport {
106
105
  Authorization: this.authorization,
107
106
  'x-request-id': baseRequestId || 'stream-request',
108
107
  ...this.headers,
108
+ ...(requestMethod === 'POST' ? { 'Content-Type': 'application/json' } : {}),
109
109
  },
110
110
  credentials: this.credentials,
111
111
  body: requestMethod === 'POST' ? JSON.stringify(params || {}) : null,
@@ -1 +1 @@
1
- {"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["../../src/streaming.ts"],"names":[],"mappings":"AAAA,wBAAuB,cAAc,CAAC,GAAG,EAAE,QAAQ,GAAG,aAAa,CAAC,UAAU,CAAC,CAgB9E"}
1
+ {"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["../../src/streaming.ts"],"names":[],"mappings":"AAAA,wBAAuB,cAAc,CAAC,GAAG,EAAE,QAAQ,GAAG,aAAa,CAAC,UAAU,CAAC,CAoB9E"}
@@ -6,10 +6,12 @@ export async function* responseChunks(res) {
6
6
  try {
7
7
  while (true) {
8
8
  const { done, value } = await reader.read();
9
- if (done)
9
+ if (done) {
10
10
  break;
11
- if (value)
11
+ }
12
+ if (value) {
12
13
  yield value;
14
+ }
13
15
  }
14
16
  }
15
17
  finally {
@@ -10,8 +10,9 @@ describe('HttpTransport', () => {
10
10
  const queryUrlEncoded = '%7B%22measures%22%3A%5B%22Orders.count%22%5D%2C%22dimensions%22%3A%5B%22Users.country%22%5D%7D';
11
11
  const queryJson = '{"query":{"measures":["Orders.count"],"dimensions":["Users.country"]}}';
12
12
  const ids = [];
13
- for (let i = 0; i < 40; i++)
13
+ for (let i = 0; i < 40; i++) {
14
14
  ids.push('a40b2052-4137-11eb-b378-0242ac130002');
15
+ }
15
16
  const LargeQuery = {
16
17
  measures: ['Orders.count'],
17
18
  dimensions: ['Users.country'],
@@ -129,6 +130,19 @@ describe('HttpTransport', () => {
129
130
  body: largeQueryJson
130
131
  });
131
132
  });
133
+ test('it does not add Content-Type to the shared headers on POST', async () => {
134
+ const headers = { 'X-Custom': 'value' };
135
+ const transport = new HttpTransport({
136
+ authorization: 'token',
137
+ apiUrl,
138
+ headers,
139
+ });
140
+ await transport.request('load', { query: LargeQuery }).subscribe(() => undefined);
141
+ await transport.request('load', { query }).subscribe(() => undefined);
142
+ expect(headers).toEqual({ 'X-Custom': 'value' });
143
+ expect(mockedFetch.mock.calls[0]?.[1]?.headers).toMatchObject({ 'Content-Type': 'application/json' });
144
+ expect(mockedFetch.mock.calls[1]?.[1]?.headers).not.toHaveProperty('Content-Type');
145
+ });
132
146
  // Signal tests from src/tests/HttpTransport.test.js
133
147
  describe('Signal functionality', () => {
134
148
  beforeEach(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubejs-client/core",
3
- "version": "1.8.3",
3
+ "version": "1.8.5",
4
4
  "engines": {
5
5
  "node": ">=20.0.0"
6
6
  },
@@ -57,7 +57,7 @@
57
57
  ],
58
58
  "license": "MIT",
59
59
  "devDependencies": {
60
- "@cubejs-backend/linter": "1.8.3",
60
+ "@cubejs-backend/linter": "1.8.5",
61
61
  "@types/d3-format": "^3",
62
62
  "@types/d3-time-format": "^4",
63
63
  "@types/moment-range": "^4.0.0",
@@ -66,5 +66,5 @@
66
66
  "typescript": "~6.0.3",
67
67
  "vitest": "^4"
68
68
  },
69
- "gitHead": "e15efc589083e85b0912056bea6d1ae2eb68c720"
69
+ "gitHead": "d01994a71e64f2e8074ee04fefa3a0d9f369cc81"
70
70
  }