@platformatic/client
Advanced tools
Comparing version 1.47.0 to 1.48.0
@@ -33,2 +33,4 @@ import { FastifyPluginAsync, FastifyReply, FastifyRequest } from 'fastify' | ||
headers?: Headers; | ||
bodyTimeout?: number; | ||
headersTimeout?: number; | ||
validateResponse?: boolean; | ||
@@ -35,0 +37,0 @@ queryParser?: (query: URLSearchParams) => string |
33
index.js
@@ -90,3 +90,3 @@ 'use strict' | ||
let { fullRequest, fullResponse, throwOnError } = options | ||
let { fullRequest, fullResponse, throwOnError, bodyTimeout, headersTimeout } = options | ||
const generatedOperationIds = [] | ||
@@ -118,3 +118,3 @@ for (const path of Object.keys(spec.paths)) { | ||
client[kOperationIdMap][operationId] = { path, method } | ||
client[operationId] = await buildCallFunction(spec, baseUrl, path, method, methodMeta, throwOnError, openTelemetry, fullRequest, fullResponse, validateResponse, queryParser) | ||
client[operationId] = await buildCallFunction(spec, baseUrl, path, method, methodMeta, throwOnError, openTelemetry, fullRequest, fullResponse, validateResponse, queryParser, bodyTimeout, headersTimeout) | ||
} | ||
@@ -142,3 +142,3 @@ } | ||
async function buildCallFunction (spec, baseUrl, path, method, methodMeta, throwOnError, openTelemetry, fullRequest, fullResponse, validateResponse, queryParser) { | ||
async function buildCallFunction (spec, baseUrl, path, method, methodMeta, throwOnError, openTelemetry, fullRequest, fullResponse, validateResponse, queryParser, bodyTimeout, headersTimeout) { | ||
await $RefParser.dereference(spec) | ||
@@ -219,2 +219,3 @@ const ajv = new Ajv() | ||
const { span, telemetryHeaders } = openTelemetry?.startSpanClient(urlToCall.toString(), method, telemetryContext) || { span: null, telemetryHeaders: {} } | ||
const telemetryId = openTelemetry?.tracer?.resource?._attributes?.['service.name'] | ||
@@ -226,2 +227,6 @@ if (this[kGetHeaders]) { | ||
if (telemetryId) { | ||
headers['x-telemetry-id'] = telemetryId | ||
} | ||
let res | ||
@@ -235,3 +240,5 @@ try { | ||
}, | ||
throwOnError | ||
throwOnError, | ||
bodyTimeout, | ||
headersTimeout | ||
} | ||
@@ -330,2 +337,14 @@ if (canHaveBody) { | ||
const { span, telemetryHeaders } = openTelemetry?.startSpanClient(url.toString(), 'POST', telemetryContext) || { span: null, telemetryHeaders: {} } | ||
const telemetryId = openTelemetry?.tracer?.resource?._attributes?.['service.name'] | ||
headers = { | ||
...headers, | ||
...telemetryHeaders, | ||
'content-type': 'application/json; charset=utf-8' | ||
} | ||
if (telemetryId) { | ||
headers['x-telemetry-id'] = telemetryId | ||
} | ||
let res | ||
@@ -335,7 +354,3 @@ try { | ||
method: 'POST', | ||
headers: { | ||
...headers, | ||
...telemetryHeaders, | ||
'content-type': 'application/json; charset=utf-8' | ||
}, | ||
headers, | ||
body: JSON.stringify({ | ||
@@ -342,0 +357,0 @@ query, |
@@ -76,2 +76,4 @@ import { | ||
headers: { foo: 'bar' }, | ||
bodyTimeout: 900000, | ||
headersTimeout: 900000, | ||
getHeaders: async (options: GetHeadersOptions) => { | ||
@@ -78,0 +80,0 @@ const { url } = options; |
{ | ||
"name": "@platformatic/client", | ||
"version": "1.47.0", | ||
"version": "1.48.0", | ||
"description": "A client for all platformatic backends", | ||
@@ -18,3 +18,3 @@ "main": "index.js", | ||
"borp": "^0.15.0", | ||
"c8": "^9.1.0", | ||
"c8": "^10.0.0", | ||
"execa": "^8.0.1", | ||
@@ -27,3 +27,3 @@ "fastify": "^4.26.2", | ||
"typescript": "^5.4.2", | ||
"@platformatic/telemetry": "1.47.0" | ||
"@platformatic/telemetry": "1.48.0" | ||
}, | ||
@@ -30,0 +30,0 @@ "dependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35259
634