phenoml 11.4.0 → 12.0.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.
- 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/authtoken/resources/auth/client/Client.d.ts +0 -17
- package/dist/cjs/api/resources/authtoken/resources/auth/client/Client.js +0 -60
- package/dist/cjs/api/resources/authtoken/resources/auth/client/requests/index.d.ts +0 -1
- package/dist/cjs/api/resources/authtoken/resources/auth/index.d.ts +0 -1
- package/dist/cjs/api/resources/authtoken/resources/auth/index.js +0 -1
- package/dist/cjs/api/resources/authtoken/resources/index.d.ts +0 -1
- package/dist/cjs/api/resources/authtoken/resources/index.js +0 -1
- package/dist/cjs/api/resources/authtoken/types/index.d.ts +0 -2
- package/dist/cjs/api/resources/authtoken/types/index.js +0 -2
- package/dist/cjs/api/resources/fhir/client/Client.d.ts +2 -23
- package/dist/cjs/api/resources/fhir/client/Client.js +2 -23
- package/dist/cjs/api/resources/fhir/client/requests/FhirCreateRequest.d.ts +1 -11
- package/dist/cjs/api/resources/fhir/client/requests/FhirSearchRequest.d.ts +1 -1
- package/dist/cjs/api/resources/fhir/client/requests/FhirUpsertRequest.d.ts +1 -12
- package/dist/cjs/core/fetcher/BinaryResponse.d.ts +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/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/authtoken/resources/auth/client/Client.d.mts +0 -17
- package/dist/esm/api/resources/authtoken/resources/auth/client/Client.mjs +0 -60
- package/dist/esm/api/resources/authtoken/resources/auth/client/requests/index.d.mts +0 -1
- package/dist/esm/api/resources/authtoken/resources/auth/index.d.mts +0 -1
- package/dist/esm/api/resources/authtoken/resources/auth/index.mjs +0 -1
- package/dist/esm/api/resources/authtoken/resources/index.d.mts +0 -1
- package/dist/esm/api/resources/authtoken/resources/index.mjs +0 -1
- package/dist/esm/api/resources/authtoken/types/index.d.mts +0 -2
- package/dist/esm/api/resources/authtoken/types/index.mjs +0 -2
- package/dist/esm/api/resources/fhir/client/Client.d.mts +2 -23
- package/dist/esm/api/resources/fhir/client/Client.mjs +2 -23
- package/dist/esm/api/resources/fhir/client/requests/FhirCreateRequest.d.mts +1 -11
- package/dist/esm/api/resources/fhir/client/requests/FhirSearchRequest.d.mts +1 -1
- package/dist/esm/api/resources/fhir/client/requests/FhirUpsertRequest.d.mts +1 -12
- package/dist/esm/core/fetcher/BinaryResponse.d.mts +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/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +7 -7
- package/reference.md +2 -89
- package/dist/cjs/api/resources/authtoken/resources/auth/client/requests/AuthGenerateTokenRequest.d.ts +0 -13
- package/dist/cjs/api/resources/authtoken/resources/auth/client/requests/AuthGenerateTokenRequest.js +0 -3
- package/dist/cjs/api/resources/authtoken/resources/auth/types/AuthGenerateTokenResponse.d.ts +0 -4
- package/dist/cjs/api/resources/authtoken/resources/auth/types/AuthGenerateTokenResponse.js +0 -3
- package/dist/cjs/api/resources/authtoken/resources/auth/types/index.d.ts +0 -1
- package/dist/cjs/api/resources/authtoken/resources/auth/types/index.js +0 -17
- package/dist/cjs/api/resources/authtoken/types/BadRequestErrorBody.d.ts +0 -5
- package/dist/cjs/api/resources/authtoken/types/BadRequestErrorBody.js +0 -3
- package/dist/cjs/api/resources/authtoken/types/UnauthorizedErrorBody.d.ts +0 -5
- package/dist/cjs/api/resources/authtoken/types/UnauthorizedErrorBody.js +0 -3
- package/dist/esm/api/resources/authtoken/resources/auth/client/requests/AuthGenerateTokenRequest.d.mts +0 -13
- package/dist/esm/api/resources/authtoken/resources/auth/client/requests/AuthGenerateTokenRequest.mjs +0 -2
- package/dist/esm/api/resources/authtoken/resources/auth/types/AuthGenerateTokenResponse.d.mts +0 -4
- package/dist/esm/api/resources/authtoken/resources/auth/types/AuthGenerateTokenResponse.mjs +0 -2
- package/dist/esm/api/resources/authtoken/resources/auth/types/index.d.mts +0 -1
- package/dist/esm/api/resources/authtoken/resources/auth/types/index.mjs +0 -1
- package/dist/esm/api/resources/authtoken/types/BadRequestErrorBody.d.mts +0 -5
- package/dist/esm/api/resources/authtoken/types/BadRequestErrorBody.mjs +0 -2
- package/dist/esm/api/resources/authtoken/types/UnauthorizedErrorBody.d.mts +0 -5
- package/dist/esm/api/resources/authtoken/types/UnauthorizedErrorBody.mjs +0 -2
package/dist/esm/Client.d.mts
CHANGED
|
@@ -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
|
}
|
package/dist/esm/Client.mjs
CHANGED
|
@@ -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
|
}
|
|
@@ -10,23 +10,6 @@ export declare namespace AuthClient {
|
|
|
10
10
|
export declare class AuthClient {
|
|
11
11
|
protected readonly _options: NormalizedClientOptionsWithAuth<AuthClient.Options>;
|
|
12
12
|
constructor(options?: AuthClient.Options);
|
|
13
|
-
/**
|
|
14
|
-
* Obtain an access token using client credentials
|
|
15
|
-
*
|
|
16
|
-
* @param {phenoml.authtoken.AuthGenerateTokenRequest} request
|
|
17
|
-
* @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
18
|
-
*
|
|
19
|
-
* @throws {@link phenoml.authtoken.BadRequestError}
|
|
20
|
-
* @throws {@link phenoml.authtoken.UnauthorizedError}
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* await client.authtoken.auth.generateToken({
|
|
24
|
-
* username: "username",
|
|
25
|
-
* password: "password"
|
|
26
|
-
* })
|
|
27
|
-
*/
|
|
28
|
-
generateToken(request: phenoml.authtoken.AuthGenerateTokenRequest, requestOptions?: AuthClient.RequestOptions): core.HttpResponsePromise<phenoml.authtoken.AuthGenerateTokenResponse>;
|
|
29
|
-
private __generateToken;
|
|
30
13
|
/**
|
|
31
14
|
* OAuth 2.0 client credentials token endpoint (RFC 6749 §4.4).
|
|
32
15
|
* Accepts client_id and client_secret in the request body (JSON or
|
|
@@ -19,66 +19,6 @@ export class AuthClient {
|
|
|
19
19
|
constructor(options = {}) {
|
|
20
20
|
this._options = normalizeClientOptionsWithAuth(options);
|
|
21
21
|
}
|
|
22
|
-
/**
|
|
23
|
-
* Obtain an access token using client credentials
|
|
24
|
-
*
|
|
25
|
-
* @param {phenoml.authtoken.AuthGenerateTokenRequest} request
|
|
26
|
-
* @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
27
|
-
*
|
|
28
|
-
* @throws {@link phenoml.authtoken.BadRequestError}
|
|
29
|
-
* @throws {@link phenoml.authtoken.UnauthorizedError}
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* await client.authtoken.auth.generateToken({
|
|
33
|
-
* username: "username",
|
|
34
|
-
* password: "password"
|
|
35
|
-
* })
|
|
36
|
-
*/
|
|
37
|
-
generateToken(request, requestOptions) {
|
|
38
|
-
return core.HttpResponsePromise.fromPromise(this.__generateToken(request, requestOptions));
|
|
39
|
-
}
|
|
40
|
-
__generateToken(request, requestOptions) {
|
|
41
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
43
|
-
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
44
|
-
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
45
|
-
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
46
|
-
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.phenomlEnvironment.Default, "auth/token"),
|
|
47
|
-
method: "POST",
|
|
48
|
-
headers: _headers,
|
|
49
|
-
contentType: "application/json",
|
|
50
|
-
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
51
|
-
requestType: "json",
|
|
52
|
-
body: request,
|
|
53
|
-
timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
|
|
54
|
-
maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
|
|
55
|
-
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
56
|
-
fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
|
|
57
|
-
logging: this._options.logging,
|
|
58
|
-
});
|
|
59
|
-
if (_response.ok) {
|
|
60
|
-
return {
|
|
61
|
-
data: _response.body,
|
|
62
|
-
rawResponse: _response.rawResponse,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
if (_response.error.reason === "status-code") {
|
|
66
|
-
switch (_response.error.statusCode) {
|
|
67
|
-
case 400:
|
|
68
|
-
throw new phenoml.authtoken.BadRequestError(_response.error.body, _response.rawResponse);
|
|
69
|
-
case 401:
|
|
70
|
-
throw new phenoml.authtoken.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
71
|
-
default:
|
|
72
|
-
throw new errors.phenomlError({
|
|
73
|
-
statusCode: _response.error.statusCode,
|
|
74
|
-
body: _response.error.body,
|
|
75
|
-
rawResponse: _response.rawResponse,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/auth/token");
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
22
|
/**
|
|
83
23
|
* OAuth 2.0 client credentials token endpoint (RFC 6749 §4.4).
|
|
84
24
|
* Accepts client_id and client_secret in the request body (JSON or
|
|
@@ -70,17 +70,7 @@ export declare class FhirClient {
|
|
|
70
70
|
* "X-Phenoml-On-Behalf-Of": "Patient/550e8400-e29b-41d4-a716-446655440000",
|
|
71
71
|
* "X-Phenoml-Fhir-Provider": "550e8400-e29b-41d4-a716-446655440000:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c...",
|
|
72
72
|
* body: {
|
|
73
|
-
* resourceType: "Patient"
|
|
74
|
-
* name: [
|
|
75
|
-
* {
|
|
76
|
-
* "family": "Doe",
|
|
77
|
-
* "given": [
|
|
78
|
-
* "Jane"
|
|
79
|
-
* ]
|
|
80
|
-
* }
|
|
81
|
-
* ],
|
|
82
|
-
* gender: "female",
|
|
83
|
-
* birthDate: "1990-01-01"
|
|
73
|
+
* resourceType: "Patient"
|
|
84
74
|
* }
|
|
85
75
|
* })
|
|
86
76
|
*/
|
|
@@ -115,18 +105,7 @@ export declare class FhirClient {
|
|
|
115
105
|
* "X-Phenoml-Fhir-Provider": "550e8400-e29b-41d4-a716-446655440000:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c...",
|
|
116
106
|
* body: {
|
|
117
107
|
* resourceType: "Patient",
|
|
118
|
-
* id: "123"
|
|
119
|
-
* name: [
|
|
120
|
-
* {
|
|
121
|
-
* "family": "Doe",
|
|
122
|
-
* "given": [
|
|
123
|
-
* "John",
|
|
124
|
-
* "Updated"
|
|
125
|
-
* ]
|
|
126
|
-
* }
|
|
127
|
-
* ],
|
|
128
|
-
* gender: "male",
|
|
129
|
-
* birthDate: "1985-05-15"
|
|
108
|
+
* id: "123"
|
|
130
109
|
* }
|
|
131
110
|
* })
|
|
132
111
|
*/
|
|
@@ -134,17 +134,7 @@ export class FhirClient {
|
|
|
134
134
|
* "X-Phenoml-On-Behalf-Of": "Patient/550e8400-e29b-41d4-a716-446655440000",
|
|
135
135
|
* "X-Phenoml-Fhir-Provider": "550e8400-e29b-41d4-a716-446655440000:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c...",
|
|
136
136
|
* body: {
|
|
137
|
-
* resourceType: "Patient"
|
|
138
|
-
* name: [
|
|
139
|
-
* {
|
|
140
|
-
* "family": "Doe",
|
|
141
|
-
* "given": [
|
|
142
|
-
* "Jane"
|
|
143
|
-
* ]
|
|
144
|
-
* }
|
|
145
|
-
* ],
|
|
146
|
-
* gender: "female",
|
|
147
|
-
* birthDate: "1990-01-01"
|
|
137
|
+
* resourceType: "Patient"
|
|
148
138
|
* }
|
|
149
139
|
* })
|
|
150
140
|
*/
|
|
@@ -231,18 +221,7 @@ export class FhirClient {
|
|
|
231
221
|
* "X-Phenoml-Fhir-Provider": "550e8400-e29b-41d4-a716-446655440000:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c...",
|
|
232
222
|
* body: {
|
|
233
223
|
* resourceType: "Patient",
|
|
234
|
-
* id: "123"
|
|
235
|
-
* name: [
|
|
236
|
-
* {
|
|
237
|
-
* "family": "Doe",
|
|
238
|
-
* "given": [
|
|
239
|
-
* "John",
|
|
240
|
-
* "Updated"
|
|
241
|
-
* ]
|
|
242
|
-
* }
|
|
243
|
-
* ],
|
|
244
|
-
* gender: "male",
|
|
245
|
-
* birthDate: "1985-05-15"
|
|
224
|
+
* id: "123"
|
|
246
225
|
* }
|
|
247
226
|
* })
|
|
248
227
|
*/
|
|
@@ -5,17 +5,7 @@ import type * as phenoml from "../../../../index.mjs";
|
|
|
5
5
|
* "X-Phenoml-On-Behalf-Of": "Patient/550e8400-e29b-41d4-a716-446655440000",
|
|
6
6
|
* "X-Phenoml-Fhir-Provider": "550e8400-e29b-41d4-a716-446655440000:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c...",
|
|
7
7
|
* body: {
|
|
8
|
-
* resourceType: "Patient"
|
|
9
|
-
* name: [
|
|
10
|
-
* {
|
|
11
|
-
* "family": "Doe",
|
|
12
|
-
* "given": [
|
|
13
|
-
* "Jane"
|
|
14
|
-
* ]
|
|
15
|
-
* }
|
|
16
|
-
* ],
|
|
17
|
-
* gender: "female",
|
|
18
|
-
* birthDate: "1990-01-01"
|
|
8
|
+
* resourceType: "Patient"
|
|
19
9
|
* }
|
|
20
10
|
* }
|
|
21
11
|
*/
|
|
@@ -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
|
|
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}
|
|
@@ -6,18 +6,7 @@ import type * as phenoml from "../../../../index.mjs";
|
|
|
6
6
|
* "X-Phenoml-Fhir-Provider": "550e8400-e29b-41d4-a716-446655440000:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c...",
|
|
7
7
|
* body: {
|
|
8
8
|
* resourceType: "Patient",
|
|
9
|
-
* id: "123"
|
|
10
|
-
* name: [
|
|
11
|
-
* {
|
|
12
|
-
* "family": "Doe",
|
|
13
|
-
* "given": [
|
|
14
|
-
* "John",
|
|
15
|
-
* "Updated"
|
|
16
|
-
* ]
|
|
17
|
-
* }
|
|
18
|
-
* ],
|
|
19
|
-
* gender: "male",
|
|
20
|
-
* birthDate: "1985-05-15"
|
|
9
|
+
* id: "123"
|
|
21
10
|
* }
|
|
22
11
|
* }
|
|
23
12
|
*/
|
|
@@ -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?():
|
|
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
|
+
}
|
package/dist/esm/version.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "
|
|
1
|
+
export declare const SDK_VERSION = "12.0.0";
|
package/dist/esm/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "
|
|
1
|
+
export const SDK_VERSION = "12.0.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phenoml",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.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.
|
|
204
|
-
"ts-loader": "^9.5.
|
|
205
|
-
"vitest": "^
|
|
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.
|
|
209
|
-
"@biomejs/biome": "2.4.
|
|
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.
|
|
218
|
+
"packageManager": "pnpm@10.33.0",
|
|
219
219
|
"engines": {
|
|
220
220
|
"node": ">=18.0.0"
|
|
221
221
|
},
|