phenoml 11.4.0 → 11.5.0

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.
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
43
43
  const headers = (0, headers_js_1.mergeHeaders)({
44
44
  "X-Fern-Language": "JavaScript",
45
45
  "X-Fern-SDK-Name": "phenoml",
46
- "X-Fern-SDK-Version": "11.4.0",
47
- "User-Agent": "phenoml/11.4.0",
46
+ "X-Fern-SDK-Version": "11.5.0",
47
+ "User-Agent": "phenoml/11.5.0",
48
48
  "X-Fern-Runtime": core.RUNTIME.type,
49
49
  "X-Fern-Runtime-Version": core.RUNTIME.version,
50
50
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -10,6 +10,7 @@ import { ToolsClient } from "./api/resources/tools/client/Client.js";
10
10
  import { WorkflowsClient } from "./api/resources/workflows/client/Client.js";
11
11
  import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
12
12
  import { type NormalizedClientOptionsWithAuth } from "./BaseClient.js";
13
+ import * as core from "./core/index.js";
13
14
  export declare namespace phenomlClient {
14
15
  type Options = BaseClientOptions;
15
16
  interface RequestOptions extends BaseRequestOptions {
@@ -38,4 +39,15 @@ export declare class phenomlClient {
38
39
  get summary(): SummaryClient;
39
40
  get tools(): ToolsClient;
40
41
  get workflows(): WorkflowsClient;
42
+ /**
43
+ * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
44
+ * This is useful for making requests to endpoints not yet supported in the SDK.
45
+ * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
46
+ *
47
+ * @param {Request | string | URL} input - The URL, path, or Request object.
48
+ * @param {RequestInit} init - Standard fetch RequestInit options.
49
+ * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
50
+ * @returns {Promise<Response>} A standard Response object.
51
+ */
52
+ fetch(input: Request | string | URL, init?: RequestInit, requestOptions?: core.PassthroughRequest.RequestOptions): Promise<Response>;
41
53
  }
@@ -1,5 +1,47 @@
1
1
  "use strict";
2
2
  // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
3
45
  Object.defineProperty(exports, "__esModule", { value: true });
4
46
  exports.phenomlClient = void 0;
5
47
  const Client_js_1 = require("./api/resources/agent/client/Client.js");
@@ -13,6 +55,7 @@ const Client_js_8 = require("./api/resources/summary/client/Client.js");
13
55
  const Client_js_9 = require("./api/resources/tools/client/Client.js");
14
56
  const Client_js_10 = require("./api/resources/workflows/client/Client.js");
15
57
  const BaseClient_js_1 = require("./BaseClient.js");
58
+ const core = __importStar(require("./core/index.js"));
16
59
  class phenomlClient {
17
60
  constructor(options = {}) {
18
61
  this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
@@ -57,5 +100,29 @@ class phenomlClient {
57
100
  var _a;
58
101
  return ((_a = this._workflows) !== null && _a !== void 0 ? _a : (this._workflows = new Client_js_10.WorkflowsClient(this._options)));
59
102
  }
103
+ /**
104
+ * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
105
+ * This is useful for making requests to endpoints not yet supported in the SDK.
106
+ * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
107
+ *
108
+ * @param {Request | string | URL} input - The URL, path, or Request object.
109
+ * @param {RequestInit} init - Standard fetch RequestInit options.
110
+ * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
111
+ * @returns {Promise<Response>} A standard Response object.
112
+ */
113
+ fetch(input, init, requestOptions) {
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ var _a;
116
+ return core.makePassthroughRequest(input, init, {
117
+ baseUrl: (_a = this._options.baseUrl) !== null && _a !== void 0 ? _a : this._options.environment,
118
+ headers: this._options.headers,
119
+ timeoutInSeconds: this._options.timeoutInSeconds,
120
+ maxRetries: this._options.maxRetries,
121
+ fetch: this._options.fetch,
122
+ logging: this._options.logging,
123
+ getAuthHeaders: () => __awaiter(this, void 0, void 0, function* () { return (yield this._options.authProvider.getAuthRequest()).headers; }),
124
+ }, requestOptions);
125
+ });
126
+ }
60
127
  }
61
128
  exports.phenomlClient = phenomlClient;
@@ -13,7 +13,7 @@ export interface FhirSearchRequest {
13
13
  * - Result parameters (_count, _offset, _sort, _include, _revinclude, _summary, _elements)
14
14
  * - Search prefixes for dates, numbers, quantities (eq, ne, gt, ge, lt, le, sa, eb, ap)
15
15
  */
16
- query_parameters?: Record<string, string | undefined>;
16
+ query_parameters?: Record<string, string>;
17
17
  /**
18
18
  * Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity.
19
19
  * Must be in the format: Patient/{uuid} or Practitioner/{uuid}
@@ -14,6 +14,6 @@ export type BinaryResponse = {
14
14
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes)
15
15
  * Some versions of the Fetch API may not support this method.
16
16
  */
17
- bytes?(): ReturnType<Response["bytes"]>;
17
+ bytes?(): Promise<Uint8Array>;
18
18
  };
19
19
  export declare function getBinaryResponse(response: Response): BinaryResponse;
@@ -6,6 +6,8 @@ export type { Fetcher, FetchFunction } from "./Fetcher.js";
6
6
  export { fetcher } from "./Fetcher.js";
7
7
  export { getHeader } from "./getHeader.js";
8
8
  export { HttpResponsePromise } from "./HttpResponsePromise.js";
9
+ export type { PassthroughRequest } from "./makePassthroughRequest.js";
10
+ export { makePassthroughRequest } from "./makePassthroughRequest.js";
9
11
  export type { RawResponse, WithRawResponse } from "./RawResponse.js";
10
12
  export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.js";
11
13
  export { Supplier } from "./Supplier.js";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Supplier = exports.unknownRawResponse = exports.toRawResponse = exports.abortRawResponse = exports.HttpResponsePromise = exports.getHeader = exports.fetcher = exports.EndpointSupplier = void 0;
3
+ exports.Supplier = exports.unknownRawResponse = exports.toRawResponse = exports.abortRawResponse = exports.makePassthroughRequest = exports.HttpResponsePromise = exports.getHeader = exports.fetcher = exports.EndpointSupplier = void 0;
4
4
  var EndpointSupplier_js_1 = require("./EndpointSupplier.js");
5
5
  Object.defineProperty(exports, "EndpointSupplier", { enumerable: true, get: function () { return EndpointSupplier_js_1.EndpointSupplier; } });
6
6
  var Fetcher_js_1 = require("./Fetcher.js");
@@ -9,6 +9,8 @@ var getHeader_js_1 = require("./getHeader.js");
9
9
  Object.defineProperty(exports, "getHeader", { enumerable: true, get: function () { return getHeader_js_1.getHeader; } });
10
10
  var HttpResponsePromise_js_1 = require("./HttpResponsePromise.js");
11
11
  Object.defineProperty(exports, "HttpResponsePromise", { enumerable: true, get: function () { return HttpResponsePromise_js_1.HttpResponsePromise; } });
12
+ var makePassthroughRequest_js_1 = require("./makePassthroughRequest.js");
13
+ Object.defineProperty(exports, "makePassthroughRequest", { enumerable: true, get: function () { return makePassthroughRequest_js_1.makePassthroughRequest; } });
12
14
  var RawResponse_js_1 = require("./RawResponse.js");
13
15
  Object.defineProperty(exports, "abortRawResponse", { enumerable: true, get: function () { return RawResponse_js_1.abortRawResponse; } });
14
16
  Object.defineProperty(exports, "toRawResponse", { enumerable: true, get: function () { return RawResponse_js_1.toRawResponse; } });
@@ -0,0 +1,49 @@
1
+ import { type LogConfig, type Logger } from "../logging/logger.js";
2
+ import { Supplier } from "./Supplier.js";
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,135 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.makePassthroughRequest = makePassthroughRequest;
13
+ const logger_js_1 = require("../logging/logger.js");
14
+ const join_js_1 = require("../url/join.js");
15
+ const EndpointSupplier_js_1 = require("./EndpointSupplier.js");
16
+ const getFetchFn_js_1 = require("./getFetchFn.js");
17
+ const makeRequest_js_1 = require("./makeRequest.js");
18
+ const requestWithRetries_js_1 = require("./requestWithRetries.js");
19
+ const Supplier_js_1 = require("./Supplier.js");
20
+ /**
21
+ * Makes a passthrough HTTP request using the SDK's configuration (auth, retry, logging, etc.)
22
+ * while mimicking the standard `fetch` API.
23
+ *
24
+ * @param input - The URL, path, or Request object. If a relative path, it will be resolved against the configured base URL.
25
+ * @param init - Standard RequestInit options (method, headers, body, signal, etc.)
26
+ * @param clientOptions - SDK client options (auth, default headers, logging, etc.)
27
+ * @param requestOptions - Per-request overrides (timeout, retries, extra headers, abort signal).
28
+ * @returns A standard Response object.
29
+ */
30
+ function makePassthroughRequest(input, init, clientOptions, requestOptions) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ var _a, _b, _c, _d, _e, _f, _g;
33
+ const logger = (0, logger_js_1.createLogger)(clientOptions.logging);
34
+ // Extract URL and default init properties from Request object if provided
35
+ let url;
36
+ let effectiveInit = init;
37
+ if (input instanceof Request) {
38
+ url = input.url;
39
+ // If no explicit init provided, extract properties from the Request object
40
+ if (init == null) {
41
+ effectiveInit = {
42
+ method: input.method,
43
+ headers: Object.fromEntries(input.headers.entries()),
44
+ body: input.body,
45
+ signal: input.signal,
46
+ credentials: input.credentials,
47
+ cache: input.cache,
48
+ redirect: input.redirect,
49
+ referrer: input.referrer,
50
+ integrity: input.integrity,
51
+ mode: input.mode,
52
+ };
53
+ }
54
+ }
55
+ else {
56
+ url = input instanceof URL ? input.toString() : input;
57
+ }
58
+ // Resolve the base URL
59
+ const baseUrl = (_a = (clientOptions.baseUrl != null ? yield Supplier_js_1.Supplier.get(clientOptions.baseUrl) : undefined)) !== null && _a !== void 0 ? _a : (clientOptions.environment != null ? yield Supplier_js_1.Supplier.get(clientOptions.environment) : undefined);
60
+ // Determine the full URL
61
+ let fullUrl;
62
+ if (url.startsWith("http://") || url.startsWith("https://")) {
63
+ fullUrl = url;
64
+ }
65
+ else if (baseUrl != null) {
66
+ fullUrl = (0, join_js_1.join)(baseUrl, url);
67
+ }
68
+ else {
69
+ fullUrl = url;
70
+ }
71
+ // Merge headers: SDK default headers -> auth headers -> user-provided headers
72
+ const mergedHeaders = {};
73
+ // Apply SDK default headers (resolve suppliers)
74
+ if (clientOptions.headers != null) {
75
+ for (const [key, value] of Object.entries(clientOptions.headers)) {
76
+ const resolved = yield EndpointSupplier_js_1.EndpointSupplier.get(value, { endpointMetadata: {} });
77
+ if (resolved != null) {
78
+ mergedHeaders[key.toLowerCase()] = `${resolved}`;
79
+ }
80
+ }
81
+ }
82
+ // Apply auth headers
83
+ if (clientOptions.getAuthHeaders != null) {
84
+ const authHeaders = yield clientOptions.getAuthHeaders();
85
+ for (const [key, value] of Object.entries(authHeaders)) {
86
+ mergedHeaders[key.toLowerCase()] = value;
87
+ }
88
+ }
89
+ // Apply user-provided headers from init
90
+ if ((effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.headers) != null) {
91
+ const initHeaders = effectiveInit.headers instanceof Headers
92
+ ? Object.fromEntries(effectiveInit.headers.entries())
93
+ : Array.isArray(effectiveInit.headers)
94
+ ? Object.fromEntries(effectiveInit.headers)
95
+ : effectiveInit.headers;
96
+ for (const [key, value] of Object.entries(initHeaders)) {
97
+ if (value != null) {
98
+ mergedHeaders[key.toLowerCase()] = value;
99
+ }
100
+ }
101
+ }
102
+ // Apply per-request option headers (highest priority)
103
+ if ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers) != null) {
104
+ for (const [key, value] of Object.entries(requestOptions.headers)) {
105
+ mergedHeaders[key.toLowerCase()] = value;
106
+ }
107
+ }
108
+ const method = (_b = effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.method) !== null && _b !== void 0 ? _b : "GET";
109
+ const body = effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.body;
110
+ const timeoutInSeconds = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _c !== void 0 ? _c : clientOptions.timeoutInSeconds;
111
+ const timeoutMs = timeoutInSeconds != null ? timeoutInSeconds * 1000 : undefined;
112
+ const maxRetries = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _d !== void 0 ? _d : clientOptions.maxRetries;
113
+ 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;
114
+ const fetchFn = (_g = clientOptions.fetch) !== null && _g !== void 0 ? _g : (yield (0, getFetchFn_js_1.getFetchFn)());
115
+ if (logger.isDebug()) {
116
+ logger.debug("Making passthrough HTTP request", {
117
+ method,
118
+ url: fullUrl,
119
+ hasBody: body != null,
120
+ });
121
+ }
122
+ const response = yield (0, requestWithRetries_js_1.requestWithRetries)(() => __awaiter(this, void 0, void 0, function* () {
123
+ return (0, makeRequest_js_1.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
124
+ false);
125
+ }), maxRetries);
126
+ if (logger.isDebug()) {
127
+ logger.debug("Passthrough HTTP request completed", {
128
+ method,
129
+ url: fullUrl,
130
+ statusCode: response.status,
131
+ });
132
+ }
133
+ return response;
134
+ });
135
+ }
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "11.4.0";
1
+ export declare const SDK_VERSION = "11.5.0";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "11.4.0";
4
+ exports.SDK_VERSION = "11.5.0";
@@ -6,8 +6,8 @@ export function normalizeClientOptions(options) {
6
6
  const headers = mergeHeaders({
7
7
  "X-Fern-Language": "JavaScript",
8
8
  "X-Fern-SDK-Name": "phenoml",
9
- "X-Fern-SDK-Version": "11.4.0",
10
- "User-Agent": "phenoml/11.4.0",
9
+ "X-Fern-SDK-Version": "11.5.0",
10
+ "User-Agent": "phenoml/11.5.0",
11
11
  "X-Fern-Runtime": core.RUNTIME.type,
12
12
  "X-Fern-Runtime-Version": core.RUNTIME.version,
13
13
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -10,6 +10,7 @@ import { ToolsClient } from "./api/resources/tools/client/Client.mjs";
10
10
  import { WorkflowsClient } from "./api/resources/workflows/client/Client.mjs";
11
11
  import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.mjs";
12
12
  import { type NormalizedClientOptionsWithAuth } from "./BaseClient.mjs";
13
+ import * as core from "./core/index.mjs";
13
14
  export declare namespace phenomlClient {
14
15
  type Options = BaseClientOptions;
15
16
  interface RequestOptions extends BaseRequestOptions {
@@ -38,4 +39,15 @@ export declare class phenomlClient {
38
39
  get summary(): SummaryClient;
39
40
  get tools(): ToolsClient;
40
41
  get workflows(): WorkflowsClient;
42
+ /**
43
+ * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
44
+ * This is useful for making requests to endpoints not yet supported in the SDK.
45
+ * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
46
+ *
47
+ * @param {Request | string | URL} input - The URL, path, or Request object.
48
+ * @param {RequestInit} init - Standard fetch RequestInit options.
49
+ * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
50
+ * @returns {Promise<Response>} A standard Response object.
51
+ */
52
+ fetch(input: Request | string | URL, init?: RequestInit, requestOptions?: core.PassthroughRequest.RequestOptions): Promise<Response>;
41
53
  }
@@ -1,4 +1,13 @@
1
1
  // This file was auto-generated by Fern from our API Definition.
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  import { AgentClient } from "./api/resources/agent/client/Client.mjs";
3
12
  import { AuthtokenClient } from "./api/resources/authtoken/client/Client.mjs";
4
13
  import { CohortClient } from "./api/resources/cohort/client/Client.mjs";
@@ -10,6 +19,7 @@ import { SummaryClient } from "./api/resources/summary/client/Client.mjs";
10
19
  import { ToolsClient } from "./api/resources/tools/client/Client.mjs";
11
20
  import { WorkflowsClient } from "./api/resources/workflows/client/Client.mjs";
12
21
  import { normalizeClientOptionsWithAuth } from "./BaseClient.mjs";
22
+ import * as core from "./core/index.mjs";
13
23
  export class phenomlClient {
14
24
  constructor(options = {}) {
15
25
  this._options = normalizeClientOptionsWithAuth(options);
@@ -54,4 +64,28 @@ export class phenomlClient {
54
64
  var _a;
55
65
  return ((_a = this._workflows) !== null && _a !== void 0 ? _a : (this._workflows = new WorkflowsClient(this._options)));
56
66
  }
67
+ /**
68
+ * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
69
+ * This is useful for making requests to endpoints not yet supported in the SDK.
70
+ * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
71
+ *
72
+ * @param {Request | string | URL} input - The URL, path, or Request object.
73
+ * @param {RequestInit} init - Standard fetch RequestInit options.
74
+ * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
75
+ * @returns {Promise<Response>} A standard Response object.
76
+ */
77
+ fetch(input, init, requestOptions) {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ var _a;
80
+ return core.makePassthroughRequest(input, init, {
81
+ baseUrl: (_a = this._options.baseUrl) !== null && _a !== void 0 ? _a : this._options.environment,
82
+ headers: this._options.headers,
83
+ timeoutInSeconds: this._options.timeoutInSeconds,
84
+ maxRetries: this._options.maxRetries,
85
+ fetch: this._options.fetch,
86
+ logging: this._options.logging,
87
+ getAuthHeaders: () => __awaiter(this, void 0, void 0, function* () { return (yield this._options.authProvider.getAuthRequest()).headers; }),
88
+ }, requestOptions);
89
+ });
90
+ }
57
91
  }
@@ -13,7 +13,7 @@ export interface FhirSearchRequest {
13
13
  * - Result parameters (_count, _offset, _sort, _include, _revinclude, _summary, _elements)
14
14
  * - Search prefixes for dates, numbers, quantities (eq, ne, gt, ge, lt, le, sa, eb, ap)
15
15
  */
16
- query_parameters?: Record<string, string | undefined>;
16
+ query_parameters?: Record<string, string>;
17
17
  /**
18
18
  * Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity.
19
19
  * Must be in the format: Patient/{uuid} or Practitioner/{uuid}
@@ -14,6 +14,6 @@ export type BinaryResponse = {
14
14
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes)
15
15
  * Some versions of the Fetch API may not support this method.
16
16
  */
17
- bytes?(): ReturnType<Response["bytes"]>;
17
+ bytes?(): Promise<Uint8Array>;
18
18
  };
19
19
  export declare function getBinaryResponse(response: Response): BinaryResponse;
@@ -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 @@
1
- export declare const SDK_VERSION = "11.4.0";
1
+ export declare const SDK_VERSION = "11.5.0";
@@ -1 +1 @@
1
- export const SDK_VERSION = "11.4.0";
1
+ export const SDK_VERSION = "11.5.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phenoml",
3
- "version": "11.4.0",
3
+ "version": "11.5.0",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -200,13 +200,13 @@
200
200
  },
201
201
  "dependencies": {},
202
202
  "devDependencies": {
203
- "webpack": "^5.97.1",
204
- "ts-loader": "^9.5.1",
205
- "vitest": "^3.2.4",
203
+ "webpack": "^5.105.4",
204
+ "ts-loader": "^9.5.4",
205
+ "vitest": "^4.1.1",
206
206
  "msw": "2.11.2",
207
207
  "@types/node": "^18.19.70",
208
- "typescript": "~5.7.2",
209
- "@biomejs/biome": "2.4.3"
208
+ "typescript": "~5.9.3",
209
+ "@biomejs/biome": "2.4.10"
210
210
  },
211
211
  "browser": {
212
212
  "fs": false,
@@ -215,7 +215,7 @@
215
215
  "stream": false,
216
216
  "crypto": false
217
217
  },
218
- "packageManager": "pnpm@10.20.0",
218
+ "packageManager": "pnpm@10.33.0",
219
219
  "engines": {
220
220
  "node": ">=18.0.0"
221
221
  },