conjure-client
Advanced tools
Comparing version 2.4.1 to 2.5.0
@@ -38,3 +38,3 @@ /** | ||
*/ | ||
userAgent: IUserAgent; | ||
userAgent: IUserAgent | IUserAgent[]; | ||
token?: string | Supplier<string>; | ||
@@ -41,0 +41,0 @@ fetch?: FetchFunction; |
@@ -70,2 +70,6 @@ "use strict"; | ||
var blobReadableStreamAdapter_1 = require("./blobReadableStreamAdapter"); | ||
var CONJURE_USER_AGENT = { | ||
productName: "conjure-typescript-runtime", | ||
productVersion: generated_1.IMPLEMENTATION_VERSION, | ||
}; | ||
var FetchBridge = /** @class */ (function () { | ||
@@ -76,5 +80,7 @@ function FetchBridge(params) { | ||
this.fetch = params.fetch; | ||
this.userAgent = new userAgent_1.UserAgent(params.userAgent, [ | ||
{ productName: "conjure-typescript-runtime", productVersion: generated_1.IMPLEMENTATION_VERSION }, | ||
]); | ||
var userAgents = Array.isArray(params.userAgent) ? params.userAgent : [params.userAgent]; | ||
if (userAgents.length === 0) { | ||
throw new Error("At least one user agent must be provided"); | ||
} | ||
this.userAgent = new userAgent_1.UserAgent(userAgents.concat([CONJURE_USER_AGENT])); | ||
} | ||
@@ -81,0 +87,0 @@ FetchBridge.prototype.call = function (serviceName, endpointName, method, endpointPath, data, headers, queryArguments, pathArguments, requestMediaType, responseMediaType) { |
@@ -1,1 +0,1 @@ | ||
export declare const IMPLEMENTATION_VERSION = "2.4.1"; | ||
export declare const IMPLEMENTATION_VERSION = "2.5.0"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.IMPLEMENTATION_VERSION = '2.4.1'; | ||
exports.IMPLEMENTATION_VERSION = '2.5.0'; | ||
//# sourceMappingURL=index.js.map |
@@ -23,9 +23,8 @@ "use strict"; | ||
var UserAgent = /** @class */ (function () { | ||
function UserAgent(primary, informational) { | ||
this.primary = primary; | ||
this.informational = informational; | ||
this.stringValue = [this.primary].concat(this.informational).map(formatUserAgent).join(" "); | ||
function UserAgent(agents) { | ||
this.agents = agents; | ||
this.stringValue = this.agents.slice().map(formatUserAgent).join(" "); | ||
} | ||
UserAgent.prototype.addAgent = function (agent) { | ||
return new UserAgent(this.primary, this.informational.concat([agent])); | ||
return new UserAgent(this.agents.concat([agent])); | ||
}; | ||
@@ -32,0 +31,0 @@ UserAgent.prototype.toString = function () { |
{ | ||
"name": "conjure-client", | ||
"version": "2.4.1", | ||
"version": "2.5.0", | ||
"description": "An HTTP bridge library for use in front end applications and generated conjure code", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
@@ -47,3 +47,3 @@ /** | ||
*/ | ||
userAgent: IUserAgent; | ||
userAgent: IUserAgent | IUserAgent[]; | ||
token?: string | Supplier<string>; | ||
@@ -53,2 +53,7 @@ fetch?: FetchFunction; | ||
const CONJURE_USER_AGENT = { | ||
productName: "conjure-typescript-runtime", | ||
productVersion: IMPLEMENTATION_VERSION, | ||
}; | ||
export class FetchBridge implements IHttpApiBridge { | ||
@@ -66,5 +71,8 @@ private static ACCEPT_HEADER = "accept"; | ||
this.fetch = params.fetch; | ||
this.userAgent = new UserAgent(params.userAgent, [ | ||
{ productName: "conjure-typescript-runtime", productVersion: IMPLEMENTATION_VERSION }, | ||
]); | ||
const userAgents = Array.isArray(params.userAgent) ? params.userAgent : [params.userAgent]; | ||
if (userAgents.length === 0) { | ||
throw new Error("At least one user agent must be provided"); | ||
} | ||
this.userAgent = new UserAgent([...userAgents, CONJURE_USER_AGENT]); | ||
} | ||
@@ -71,0 +79,0 @@ |
@@ -1,1 +0,1 @@ | ||
export const IMPLEMENTATION_VERSION = '2.4.1'; | ||
export const IMPLEMENTATION_VERSION = '2.5.0'; |
@@ -29,8 +29,8 @@ /** | ||
constructor(private readonly primary: IUserAgent, private readonly informational: IUserAgent[]) { | ||
this.stringValue = [this.primary, ...this.informational].map(formatUserAgent).join(" "); | ||
constructor(private readonly agents: IUserAgent[]) { | ||
this.stringValue = [...this.agents].map(formatUserAgent).join(" "); | ||
} | ||
public addAgent(agent: IUserAgent): UserAgent { | ||
return new UserAgent(this.primary, [...this.informational, agent]); | ||
return new UserAgent([...this.agents, agent]); | ||
} | ||
@@ -37,0 +37,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
85754
1659