saferx-pharma-sdk 1.4.0 → 1.4.2
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/cjs/BaseClient.js +2 -2
- package/dist/cjs/Client.d.ts +12 -0
- package/dist/cjs/Client.js +67 -0
- package/dist/cjs/api/resources/developers/client/Client.d.ts +1 -1
- package/dist/cjs/api/resources/developers/client/Client.js +1 -1
- package/dist/cjs/api/resources/developers/exports.d.ts +2 -0
- package/dist/cjs/api/resources/developers/exports.js +21 -0
- package/dist/cjs/api/resources/drugSafety/client/Client.d.ts +39 -5
- package/dist/cjs/api/resources/drugSafety/client/Client.js +39 -5
- package/dist/cjs/api/resources/drugSafety/client/requests/DrugSafetyCheckRequest.d.ts +38 -4
- package/dist/cjs/api/resources/drugSafety/exports.d.ts +2 -0
- package/dist/cjs/api/resources/drugSafety/exports.js +21 -0
- package/dist/cjs/api/resources/drugSafety/types/GetDrugSafetyHealthResponse.d.ts +2 -14
- package/dist/cjs/api/resources/drugSafety/types/GetDrugSafetyHealthResponse.js +0 -11
- package/dist/cjs/api/types/Alert.d.ts +8 -2
- package/dist/cjs/api/types/Alert.js +5 -1
- package/dist/cjs/api/types/AllergyCrossReactivityReference.d.ts +16 -0
- package/dist/cjs/api/types/AllergyCrossReactivityReference.js +3 -0
- package/dist/cjs/api/types/AllergyData.d.ts +24 -0
- package/dist/cjs/api/types/AllergyData.js +11 -0
- package/dist/cjs/api/types/AllergyFamilyReference.d.ts +10 -0
- package/dist/cjs/api/types/AllergyFamilyReference.js +3 -0
- package/dist/cjs/api/types/AllergyInputEntry.d.ts +10 -0
- package/dist/cjs/api/types/AllergyInputEntry.js +3 -0
- package/dist/cjs/api/types/AllergyProductFamilyReference.d.ts +9 -0
- package/dist/cjs/api/types/AllergyProductFamilyReference.js +3 -0
- package/dist/cjs/api/types/AllergySummary.d.ts +14 -0
- package/dist/cjs/api/types/AllergySummary.js +3 -0
- package/dist/cjs/api/types/AllergyWarning.d.ts +30 -0
- package/dist/cjs/api/types/AllergyWarning.js +11 -0
- package/dist/cjs/api/types/ClinicalAlert.d.ts +8 -0
- package/dist/cjs/api/types/ClinicalContextApplied.d.ts +10 -0
- package/dist/cjs/api/types/ClinicalContextApplied.js +3 -0
- package/dist/cjs/api/types/ClinicalData.d.ts +7 -4
- package/dist/cjs/api/types/DailyLimit.d.ts +1 -1
- package/dist/cjs/api/types/DomainCode.d.ts +4 -2
- package/dist/cjs/api/types/DomainCode.js +4 -2
- package/dist/cjs/api/types/DosingData.d.ts +22 -12
- package/dist/cjs/api/types/DosingData.js +3 -3
- package/dist/cjs/api/types/DrugSafetyCheckResponse.d.ts +1 -0
- package/dist/cjs/api/types/ErrorResponse.d.ts +5 -0
- package/dist/cjs/api/types/IdentityMatch.d.ts +13 -0
- package/dist/cjs/api/types/IdentityMatch.js +3 -0
- package/dist/cjs/api/types/IntelligenceClinicalProfile.d.ts +24 -0
- package/dist/cjs/api/types/IntelligenceClinicalProfile.js +13 -0
- package/dist/cjs/api/types/IntelligenceContext.d.ts +17 -0
- package/dist/cjs/api/types/IntelligenceContext.js +3 -0
- package/dist/cjs/api/types/IntelligenceProcessorError.d.ts +4 -0
- package/dist/cjs/api/types/IntelligenceProcessorError.js +3 -0
- package/dist/cjs/api/types/IntelligenceResult.d.ts +16 -0
- package/dist/cjs/api/types/IntelligenceResult.js +3 -0
- package/dist/cjs/api/types/IntelligenceSynthesis.d.ts +6 -0
- package/dist/cjs/api/types/IntelligenceSynthesis.js +3 -0
- package/dist/cjs/api/types/Interaction.d.ts +0 -2
- package/dist/cjs/api/types/InteractionSummary.d.ts +4 -4
- package/dist/cjs/api/types/MedicationHistoryItem.d.ts +22 -0
- package/dist/cjs/api/types/MedicationHistoryItem.js +15 -0
- package/dist/cjs/api/types/Meta.d.ts +2 -0
- package/dist/cjs/api/types/Meta.js +1 -0
- package/dist/cjs/api/types/MetadataResponse.d.ts +14 -6
- package/dist/cjs/api/types/MetadataResponse.js +1 -0
- package/dist/cjs/api/types/PatientProfile.d.ts +31 -0
- package/dist/cjs/api/types/PatientProfile.js +17 -0
- package/dist/cjs/api/types/QuotaMeta.d.ts +11 -0
- package/dist/cjs/api/types/QuotaMeta.js +3 -0
- package/dist/cjs/api/types/RateLimitResponse.d.ts +11 -0
- package/dist/cjs/api/types/RateLimitResponse.js +1 -0
- package/dist/cjs/api/types/ResolvedDrug.d.ts +26 -0
- package/dist/cjs/api/types/SafetyData.d.ts +1 -0
- package/dist/cjs/api/types/index.d.ts +16 -0
- package/dist/cjs/api/types/index.js +16 -0
- package/dist/cjs/core/fetcher/BinaryResponse.d.ts +1 -1
- package/dist/cjs/core/fetcher/Fetcher.js +1 -1
- package/dist/cjs/core/fetcher/index.d.ts +2 -0
- package/dist/cjs/core/fetcher/index.js +3 -1
- package/dist/cjs/core/fetcher/makePassthroughRequest.d.ts +49 -0
- package/dist/cjs/core/fetcher/makePassthroughRequest.js +135 -0
- package/dist/cjs/core/fetcher/makeRequest.d.ts +6 -1
- package/dist/cjs/core/fetcher/makeRequest.js +30 -9
- package/dist/cjs/core/runtime/runtime.js +8 -7
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/Client.d.mts +12 -0
- package/dist/esm/Client.mjs +34 -0
- package/dist/esm/api/resources/developers/client/Client.d.mts +1 -1
- package/dist/esm/api/resources/developers/client/Client.mjs +1 -1
- package/dist/esm/api/resources/developers/exports.d.mts +2 -0
- package/dist/esm/api/resources/developers/exports.mjs +3 -0
- package/dist/esm/api/resources/drugSafety/client/Client.d.mts +39 -5
- package/dist/esm/api/resources/drugSafety/client/Client.mjs +39 -5
- package/dist/esm/api/resources/drugSafety/client/requests/DrugSafetyCheckRequest.d.mts +38 -4
- package/dist/esm/api/resources/drugSafety/exports.d.mts +2 -0
- package/dist/esm/api/resources/drugSafety/exports.mjs +3 -0
- package/dist/esm/api/resources/drugSafety/types/GetDrugSafetyHealthResponse.d.mts +2 -14
- package/dist/esm/api/resources/drugSafety/types/GetDrugSafetyHealthResponse.mjs +0 -11
- package/dist/esm/api/types/Alert.d.mts +8 -2
- package/dist/esm/api/types/Alert.mjs +5 -1
- package/dist/esm/api/types/AllergyCrossReactivityReference.d.mts +16 -0
- package/dist/esm/api/types/AllergyCrossReactivityReference.mjs +2 -0
- package/dist/esm/api/types/AllergyData.d.mts +24 -0
- package/dist/esm/api/types/AllergyData.mjs +8 -0
- package/dist/esm/api/types/AllergyFamilyReference.d.mts +10 -0
- package/dist/esm/api/types/AllergyFamilyReference.mjs +2 -0
- package/dist/esm/api/types/AllergyInputEntry.d.mts +10 -0
- package/dist/esm/api/types/AllergyInputEntry.mjs +2 -0
- package/dist/esm/api/types/AllergyProductFamilyReference.d.mts +9 -0
- package/dist/esm/api/types/AllergyProductFamilyReference.mjs +2 -0
- package/dist/esm/api/types/AllergySummary.d.mts +14 -0
- package/dist/esm/api/types/AllergySummary.mjs +2 -0
- package/dist/esm/api/types/AllergyWarning.d.mts +30 -0
- package/dist/esm/api/types/AllergyWarning.mjs +8 -0
- package/dist/esm/api/types/ClinicalAlert.d.mts +8 -0
- package/dist/esm/api/types/ClinicalContextApplied.d.mts +10 -0
- package/dist/esm/api/types/ClinicalContextApplied.mjs +2 -0
- package/dist/esm/api/types/ClinicalData.d.mts +7 -4
- package/dist/esm/api/types/DailyLimit.d.mts +1 -1
- package/dist/esm/api/types/DomainCode.d.mts +4 -2
- package/dist/esm/api/types/DomainCode.mjs +4 -2
- package/dist/esm/api/types/DosingData.d.mts +22 -12
- package/dist/esm/api/types/DosingData.mjs +3 -3
- package/dist/esm/api/types/DrugSafetyCheckResponse.d.mts +1 -0
- package/dist/esm/api/types/ErrorResponse.d.mts +5 -0
- package/dist/esm/api/types/IdentityMatch.d.mts +13 -0
- package/dist/esm/api/types/IdentityMatch.mjs +2 -0
- package/dist/esm/api/types/IntelligenceClinicalProfile.d.mts +24 -0
- package/dist/esm/api/types/IntelligenceClinicalProfile.mjs +10 -0
- package/dist/esm/api/types/IntelligenceContext.d.mts +17 -0
- package/dist/esm/api/types/IntelligenceContext.mjs +2 -0
- package/dist/esm/api/types/IntelligenceProcessorError.d.mts +4 -0
- package/dist/esm/api/types/IntelligenceProcessorError.mjs +2 -0
- package/dist/esm/api/types/IntelligenceResult.d.mts +16 -0
- package/dist/esm/api/types/IntelligenceResult.mjs +2 -0
- package/dist/esm/api/types/IntelligenceSynthesis.d.mts +6 -0
- package/dist/esm/api/types/IntelligenceSynthesis.mjs +2 -0
- package/dist/esm/api/types/Interaction.d.mts +0 -2
- package/dist/esm/api/types/InteractionSummary.d.mts +4 -4
- package/dist/esm/api/types/MedicationHistoryItem.d.mts +22 -0
- package/dist/esm/api/types/MedicationHistoryItem.mjs +12 -0
- package/dist/esm/api/types/Meta.d.mts +2 -0
- package/dist/esm/api/types/Meta.mjs +1 -0
- package/dist/esm/api/types/MetadataResponse.d.mts +14 -6
- package/dist/esm/api/types/MetadataResponse.mjs +1 -0
- package/dist/esm/api/types/PatientProfile.d.mts +31 -0
- package/dist/esm/api/types/PatientProfile.mjs +16 -1
- package/dist/esm/api/types/QuotaMeta.d.mts +11 -0
- package/dist/esm/api/types/QuotaMeta.mjs +2 -0
- package/dist/esm/api/types/RateLimitResponse.d.mts +11 -0
- package/dist/esm/api/types/RateLimitResponse.mjs +1 -0
- package/dist/esm/api/types/ResolvedDrug.d.mts +26 -0
- package/dist/esm/api/types/SafetyData.d.mts +1 -0
- package/dist/esm/api/types/index.d.mts +16 -0
- package/dist/esm/api/types/index.mjs +16 -0
- package/dist/esm/core/fetcher/BinaryResponse.d.mts +1 -1
- package/dist/esm/core/fetcher/Fetcher.mjs +1 -1
- package/dist/esm/core/fetcher/index.d.mts +2 -0
- package/dist/esm/core/fetcher/index.mjs +1 -0
- package/dist/esm/core/fetcher/makePassthroughRequest.d.mts +49 -0
- package/dist/esm/core/fetcher/makePassthroughRequest.mjs +132 -0
- package/dist/esm/core/fetcher/makeRequest.d.mts +6 -1
- package/dist/esm/core/fetcher/makeRequest.mjs +28 -9
- package/dist/esm/core/runtime/runtime.mjs +8 -7
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +31 -9
|
@@ -202,7 +202,7 @@ export function fetcherImpl(args) {
|
|
|
202
202
|
}
|
|
203
203
|
try {
|
|
204
204
|
const response = yield requestWithRetries(() => __awaiter(this, void 0, void 0, function* () {
|
|
205
|
-
return makeRequest(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex);
|
|
205
|
+
return makeRequest(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex, args.responseType === "streaming" || args.responseType === "sse");
|
|
206
206
|
}), args.maxRetries);
|
|
207
207
|
if (response.status >= 200 && response.status < 400) {
|
|
208
208
|
if (logger.isDebug()) {
|
|
@@ -6,6 +6,8 @@ export type { Fetcher, FetchFunction } from "./Fetcher.mjs";
|
|
|
6
6
|
export { fetcher } from "./Fetcher.mjs";
|
|
7
7
|
export { getHeader } from "./getHeader.mjs";
|
|
8
8
|
export { HttpResponsePromise } from "./HttpResponsePromise.mjs";
|
|
9
|
+
export type { PassthroughRequest } from "./makePassthroughRequest.mjs";
|
|
10
|
+
export { makePassthroughRequest } from "./makePassthroughRequest.mjs";
|
|
9
11
|
export type { RawResponse, WithRawResponse } from "./RawResponse.mjs";
|
|
10
12
|
export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.mjs";
|
|
11
13
|
export { Supplier } from "./Supplier.mjs";
|
|
@@ -2,5 +2,6 @@ export { EndpointSupplier } from "./EndpointSupplier.mjs";
|
|
|
2
2
|
export { fetcher } from "./Fetcher.mjs";
|
|
3
3
|
export { getHeader } from "./getHeader.mjs";
|
|
4
4
|
export { HttpResponsePromise } from "./HttpResponsePromise.mjs";
|
|
5
|
+
export { makePassthroughRequest } from "./makePassthroughRequest.mjs";
|
|
5
6
|
export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.mjs";
|
|
6
7
|
export { Supplier } from "./Supplier.mjs";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type LogConfig, type Logger } from "../logging/logger.mjs";
|
|
2
|
+
import { Supplier } from "./Supplier.mjs";
|
|
3
|
+
export declare namespace PassthroughRequest {
|
|
4
|
+
/**
|
|
5
|
+
* Per-request options that can override the SDK client defaults.
|
|
6
|
+
*/
|
|
7
|
+
interface RequestOptions {
|
|
8
|
+
/** Override the default timeout for this request (in seconds). */
|
|
9
|
+
timeoutInSeconds?: number;
|
|
10
|
+
/** Override the default number of retries for this request. */
|
|
11
|
+
maxRetries?: number;
|
|
12
|
+
/** Additional headers to include in this request. */
|
|
13
|
+
headers?: Record<string, string>;
|
|
14
|
+
/** Abort signal for this request. */
|
|
15
|
+
abortSignal?: AbortSignal;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* SDK client configuration used by the passthrough fetch method.
|
|
19
|
+
*/
|
|
20
|
+
interface ClientOptions {
|
|
21
|
+
/** The base URL or environment for the client. */
|
|
22
|
+
environment?: Supplier<string>;
|
|
23
|
+
/** Override the base URL. */
|
|
24
|
+
baseUrl?: Supplier<string>;
|
|
25
|
+
/** Default headers to include in requests. */
|
|
26
|
+
headers?: Record<string, unknown>;
|
|
27
|
+
/** Default maximum time to wait for a response in seconds. */
|
|
28
|
+
timeoutInSeconds?: number;
|
|
29
|
+
/** Default number of times to retry the request. Defaults to 2. */
|
|
30
|
+
maxRetries?: number;
|
|
31
|
+
/** A custom fetch function. */
|
|
32
|
+
fetch?: typeof fetch;
|
|
33
|
+
/** Logging configuration. */
|
|
34
|
+
logging?: LogConfig | Logger;
|
|
35
|
+
/** A function that returns auth headers. */
|
|
36
|
+
getAuthHeaders?: () => Promise<Record<string, string>>;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Makes a passthrough HTTP request using the SDK's configuration (auth, retry, logging, etc.)
|
|
41
|
+
* while mimicking the standard `fetch` API.
|
|
42
|
+
*
|
|
43
|
+
* @param input - The URL, path, or Request object. If a relative path, it will be resolved against the configured base URL.
|
|
44
|
+
* @param init - Standard RequestInit options (method, headers, body, signal, etc.)
|
|
45
|
+
* @param clientOptions - SDK client options (auth, default headers, logging, etc.)
|
|
46
|
+
* @param requestOptions - Per-request overrides (timeout, retries, extra headers, abort signal).
|
|
47
|
+
* @returns A standard Response object.
|
|
48
|
+
*/
|
|
49
|
+
export declare function makePassthroughRequest(input: Request | string | URL, init: RequestInit | undefined, clientOptions: PassthroughRequest.ClientOptions, requestOptions?: PassthroughRequest.RequestOptions): Promise<Response>;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { createLogger } from "../logging/logger.mjs";
|
|
11
|
+
import { join } from "../url/join.mjs";
|
|
12
|
+
import { EndpointSupplier } from "./EndpointSupplier.mjs";
|
|
13
|
+
import { getFetchFn } from "./getFetchFn.mjs";
|
|
14
|
+
import { makeRequest } from "./makeRequest.mjs";
|
|
15
|
+
import { requestWithRetries } from "./requestWithRetries.mjs";
|
|
16
|
+
import { Supplier } from "./Supplier.mjs";
|
|
17
|
+
/**
|
|
18
|
+
* Makes a passthrough HTTP request using the SDK's configuration (auth, retry, logging, etc.)
|
|
19
|
+
* while mimicking the standard `fetch` API.
|
|
20
|
+
*
|
|
21
|
+
* @param input - The URL, path, or Request object. If a relative path, it will be resolved against the configured base URL.
|
|
22
|
+
* @param init - Standard RequestInit options (method, headers, body, signal, etc.)
|
|
23
|
+
* @param clientOptions - SDK client options (auth, default headers, logging, etc.)
|
|
24
|
+
* @param requestOptions - Per-request overrides (timeout, retries, extra headers, abort signal).
|
|
25
|
+
* @returns A standard Response object.
|
|
26
|
+
*/
|
|
27
|
+
export function makePassthroughRequest(input, init, clientOptions, requestOptions) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
30
|
+
const logger = createLogger(clientOptions.logging);
|
|
31
|
+
// Extract URL and default init properties from Request object if provided
|
|
32
|
+
let url;
|
|
33
|
+
let effectiveInit = init;
|
|
34
|
+
if (input instanceof Request) {
|
|
35
|
+
url = input.url;
|
|
36
|
+
// If no explicit init provided, extract properties from the Request object
|
|
37
|
+
if (init == null) {
|
|
38
|
+
effectiveInit = {
|
|
39
|
+
method: input.method,
|
|
40
|
+
headers: Object.fromEntries(input.headers.entries()),
|
|
41
|
+
body: input.body,
|
|
42
|
+
signal: input.signal,
|
|
43
|
+
credentials: input.credentials,
|
|
44
|
+
cache: input.cache,
|
|
45
|
+
redirect: input.redirect,
|
|
46
|
+
referrer: input.referrer,
|
|
47
|
+
integrity: input.integrity,
|
|
48
|
+
mode: input.mode,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
url = input instanceof URL ? input.toString() : input;
|
|
54
|
+
}
|
|
55
|
+
// Resolve the base URL
|
|
56
|
+
const baseUrl = (_a = (clientOptions.baseUrl != null ? yield Supplier.get(clientOptions.baseUrl) : undefined)) !== null && _a !== void 0 ? _a : (clientOptions.environment != null ? yield Supplier.get(clientOptions.environment) : undefined);
|
|
57
|
+
// Determine the full URL
|
|
58
|
+
let fullUrl;
|
|
59
|
+
if (url.startsWith("http://") || url.startsWith("https://")) {
|
|
60
|
+
fullUrl = url;
|
|
61
|
+
}
|
|
62
|
+
else if (baseUrl != null) {
|
|
63
|
+
fullUrl = join(baseUrl, url);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
fullUrl = url;
|
|
67
|
+
}
|
|
68
|
+
// Merge headers: SDK default headers -> auth headers -> user-provided headers
|
|
69
|
+
const mergedHeaders = {};
|
|
70
|
+
// Apply SDK default headers (resolve suppliers)
|
|
71
|
+
if (clientOptions.headers != null) {
|
|
72
|
+
for (const [key, value] of Object.entries(clientOptions.headers)) {
|
|
73
|
+
const resolved = yield EndpointSupplier.get(value, { endpointMetadata: {} });
|
|
74
|
+
if (resolved != null) {
|
|
75
|
+
mergedHeaders[key.toLowerCase()] = `${resolved}`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Apply auth headers
|
|
80
|
+
if (clientOptions.getAuthHeaders != null) {
|
|
81
|
+
const authHeaders = yield clientOptions.getAuthHeaders();
|
|
82
|
+
for (const [key, value] of Object.entries(authHeaders)) {
|
|
83
|
+
mergedHeaders[key.toLowerCase()] = value;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Apply user-provided headers from init
|
|
87
|
+
if ((effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.headers) != null) {
|
|
88
|
+
const initHeaders = effectiveInit.headers instanceof Headers
|
|
89
|
+
? Object.fromEntries(effectiveInit.headers.entries())
|
|
90
|
+
: Array.isArray(effectiveInit.headers)
|
|
91
|
+
? Object.fromEntries(effectiveInit.headers)
|
|
92
|
+
: effectiveInit.headers;
|
|
93
|
+
for (const [key, value] of Object.entries(initHeaders)) {
|
|
94
|
+
if (value != null) {
|
|
95
|
+
mergedHeaders[key.toLowerCase()] = value;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Apply per-request option headers (highest priority)
|
|
100
|
+
if ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers) != null) {
|
|
101
|
+
for (const [key, value] of Object.entries(requestOptions.headers)) {
|
|
102
|
+
mergedHeaders[key.toLowerCase()] = value;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const method = (_b = effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.method) !== null && _b !== void 0 ? _b : "GET";
|
|
106
|
+
const body = effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.body;
|
|
107
|
+
const timeoutInSeconds = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _c !== void 0 ? _c : clientOptions.timeoutInSeconds;
|
|
108
|
+
const timeoutMs = timeoutInSeconds != null ? timeoutInSeconds * 1000 : undefined;
|
|
109
|
+
const maxRetries = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _d !== void 0 ? _d : clientOptions.maxRetries;
|
|
110
|
+
const abortSignal = (_f = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal) !== null && _e !== void 0 ? _e : effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.signal) !== null && _f !== void 0 ? _f : undefined;
|
|
111
|
+
const fetchFn = (_g = clientOptions.fetch) !== null && _g !== void 0 ? _g : (yield getFetchFn());
|
|
112
|
+
if (logger.isDebug()) {
|
|
113
|
+
logger.debug("Making passthrough HTTP request", {
|
|
114
|
+
method,
|
|
115
|
+
url: fullUrl,
|
|
116
|
+
hasBody: body != null,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
const response = yield requestWithRetries(() => __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
return makeRequest(fetchFn, fullUrl, method, mergedHeaders, body !== null && body !== void 0 ? body : undefined, timeoutMs, abortSignal, (effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.credentials) === "include", undefined, // duplex
|
|
121
|
+
false);
|
|
122
|
+
}), maxRetries);
|
|
123
|
+
if (logger.isDebug()) {
|
|
124
|
+
logger.debug("Passthrough HTTP request completed", {
|
|
125
|
+
method,
|
|
126
|
+
url: fullUrl,
|
|
127
|
+
statusCode: response.status,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return response;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function isCacheNoStoreSupported(): boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Reset the cached result of `isCacheNoStoreSupported`. Exposed for testing only.
|
|
4
|
+
*/
|
|
5
|
+
export declare function resetCacheNoStoreSupported(): void;
|
|
6
|
+
export declare const makeRequest: (fetchFn: (url: string, init: RequestInit) => Promise<Response>, url: string, method: string, headers: Headers | Record<string, string>, requestBody: BodyInit | undefined, timeoutMs?: number, abortSignal?: AbortSignal, withCredentials?: boolean, duplex?: "half", disableCache?: boolean) => Promise<Response>;
|
|
@@ -8,7 +8,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { anySignal, getTimeoutSignal } from "./signals.mjs";
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Cached result of checking whether the current runtime supports
|
|
13
|
+
* the `cache` option in `Request`. Some runtimes (e.g. Cloudflare Workers)
|
|
14
|
+
* throw a TypeError when this option is used.
|
|
15
|
+
*/
|
|
16
|
+
let _cacheNoStoreSupported;
|
|
17
|
+
export function isCacheNoStoreSupported() {
|
|
18
|
+
if (_cacheNoStoreSupported != null) {
|
|
19
|
+
return _cacheNoStoreSupported;
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
new Request("http://localhost", { cache: "no-store" });
|
|
23
|
+
_cacheNoStoreSupported = true;
|
|
24
|
+
}
|
|
25
|
+
catch (_a) {
|
|
26
|
+
_cacheNoStoreSupported = false;
|
|
27
|
+
}
|
|
28
|
+
return _cacheNoStoreSupported;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Reset the cached result of `isCacheNoStoreSupported`. Exposed for testing only.
|
|
32
|
+
*/
|
|
33
|
+
export function resetCacheNoStoreSupported() {
|
|
34
|
+
_cacheNoStoreSupported = undefined;
|
|
35
|
+
}
|
|
36
|
+
export const makeRequest = (fetchFn, url, method, headers, requestBody, timeoutMs, abortSignal, withCredentials, duplex, disableCache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
37
|
const signals = [];
|
|
13
38
|
let timeoutAbortId;
|
|
14
39
|
if (timeoutMs != null) {
|
|
@@ -20,15 +45,9 @@ export const makeRequest = (fetchFn, url, method, headers, requestBody, timeoutM
|
|
|
20
45
|
signals.push(abortSignal);
|
|
21
46
|
}
|
|
22
47
|
const newSignals = anySignal(signals);
|
|
23
|
-
const response = yield fetchFn(url, {
|
|
24
|
-
method: method,
|
|
25
|
-
headers,
|
|
26
|
-
body: requestBody,
|
|
27
|
-
signal: newSignals,
|
|
28
|
-
credentials: withCredentials ? "include" : undefined,
|
|
48
|
+
const response = yield fetchFn(url, Object.assign({ method: method, headers, body: requestBody, signal: newSignals, credentials: withCredentials ? "include" : undefined,
|
|
29
49
|
// @ts-ignore
|
|
30
|
-
duplex,
|
|
31
|
-
});
|
|
50
|
+
duplex }, (disableCache && isCacheNoStoreSupported() ? { cache: "no-store" } : {})));
|
|
32
51
|
if (timeoutAbortId != null) {
|
|
33
52
|
clearTimeout(timeoutAbortId);
|
|
34
53
|
}
|
|
@@ -81,17 +81,18 @@ function evaluateRuntime() {
|
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* A constant that indicates whether the environment the code is running is Node.JS.
|
|
84
|
+
*
|
|
85
|
+
* We assign `process` to a local variable first to avoid being flagged by
|
|
86
|
+
* bundlers that perform static analysis on `process.versions` (e.g. Next.js
|
|
87
|
+
* Edge Runtime warns about Node.js APIs even when they are guarded).
|
|
84
88
|
*/
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
!!process.version &&
|
|
88
|
-
"versions" in process &&
|
|
89
|
-
!!((_e = process.versions) === null || _e === void 0 ? void 0 : _e.node);
|
|
89
|
+
const _process = typeof process !== "undefined" ? process : undefined;
|
|
90
|
+
const isNode = typeof _process !== "undefined" && typeof ((_e = _process.versions) === null || _e === void 0 ? void 0 : _e.node) === "string";
|
|
90
91
|
if (isNode) {
|
|
91
92
|
return {
|
|
92
93
|
type: "node",
|
|
93
|
-
version:
|
|
94
|
-
parsedVersion: Number(
|
|
94
|
+
version: _process.versions.node,
|
|
95
|
+
parsedVersion: Number(_process.versions.node.split(".")[0]),
|
|
95
96
|
};
|
|
96
97
|
}
|
|
97
98
|
return {
|
package/dist/esm/version.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.4.
|
|
1
|
+
export declare const SDK_VERSION = "1.4.2";
|
package/dist/esm/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.4.
|
|
1
|
+
export const SDK_VERSION = "1.4.2";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "saferx-pharma-sdk",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"types": "./dist/cjs/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"types": "./dist/cjs/index.d.ts",
|
|
12
11
|
"import": {
|
|
13
12
|
"types": "./dist/esm/index.d.mts",
|
|
14
13
|
"default": "./dist/esm/index.mjs"
|
|
@@ -19,6 +18,28 @@
|
|
|
19
18
|
},
|
|
20
19
|
"default": "./dist/cjs/index.js"
|
|
21
20
|
},
|
|
21
|
+
"./drugSafety": {
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/esm/api/resources/drugSafety/exports.d.mts",
|
|
24
|
+
"default": "./dist/esm/api/resources/drugSafety/exports.mjs"
|
|
25
|
+
},
|
|
26
|
+
"require": {
|
|
27
|
+
"types": "./dist/cjs/api/resources/drugSafety/exports.d.ts",
|
|
28
|
+
"default": "./dist/cjs/api/resources/drugSafety/exports.js"
|
|
29
|
+
},
|
|
30
|
+
"default": "./dist/cjs/api/resources/drugSafety/exports.js"
|
|
31
|
+
},
|
|
32
|
+
"./developers": {
|
|
33
|
+
"import": {
|
|
34
|
+
"types": "./dist/esm/api/resources/developers/exports.d.mts",
|
|
35
|
+
"default": "./dist/esm/api/resources/developers/exports.mjs"
|
|
36
|
+
},
|
|
37
|
+
"require": {
|
|
38
|
+
"types": "./dist/cjs/api/resources/developers/exports.d.ts",
|
|
39
|
+
"default": "./dist/cjs/api/resources/developers/exports.js"
|
|
40
|
+
},
|
|
41
|
+
"default": "./dist/cjs/api/resources/developers/exports.js"
|
|
42
|
+
},
|
|
22
43
|
"./package.json": "./package.json"
|
|
23
44
|
},
|
|
24
45
|
"files": [
|
|
@@ -43,21 +64,22 @@
|
|
|
43
64
|
},
|
|
44
65
|
"dependencies": {},
|
|
45
66
|
"devDependencies": {
|
|
46
|
-
"webpack": "^5.
|
|
47
|
-
"ts-loader": "^9.5.
|
|
48
|
-
"vitest": "^
|
|
67
|
+
"webpack": "^5.105.4",
|
|
68
|
+
"ts-loader": "^9.5.4",
|
|
69
|
+
"vitest": "^4.1.1",
|
|
49
70
|
"msw": "2.11.2",
|
|
50
71
|
"@types/node": "^18.19.70",
|
|
51
|
-
"typescript": "~5.
|
|
52
|
-
"@biomejs/biome": "2.
|
|
72
|
+
"typescript": "~5.9.3",
|
|
73
|
+
"@biomejs/biome": "2.4.10"
|
|
53
74
|
},
|
|
54
75
|
"browser": {
|
|
55
76
|
"fs": false,
|
|
56
77
|
"os": false,
|
|
57
78
|
"path": false,
|
|
58
|
-
"stream": false
|
|
79
|
+
"stream": false,
|
|
80
|
+
"crypto": false
|
|
59
81
|
},
|
|
60
|
-
"packageManager": "pnpm@10.
|
|
82
|
+
"packageManager": "pnpm@10.33.0",
|
|
61
83
|
"engines": {
|
|
62
84
|
"node": ">=18.0.0"
|
|
63
85
|
},
|