phenoml 6.3.1 → 6.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.
Files changed (56) hide show
  1. package/dist/cjs/Client.js +2 -2
  2. package/dist/cjs/api/resources/agent/client/Client.d.ts +8 -1
  3. package/dist/cjs/api/resources/agent/client/Client.js +82 -1
  4. package/dist/cjs/api/resources/agent/client/requests/AgentStreamChatRequest.d.ts +31 -0
  5. package/dist/cjs/api/resources/agent/client/requests/AgentStreamChatRequest.js +3 -0
  6. package/dist/cjs/api/resources/agent/client/requests/index.d.ts +1 -0
  7. package/dist/cjs/api/resources/agent/types/AgentChatStreamEvent.d.ts +36 -0
  8. package/dist/cjs/api/resources/agent/types/AgentChatStreamEvent.js +16 -0
  9. package/dist/cjs/api/resources/agent/types/index.d.ts +1 -0
  10. package/dist/cjs/api/resources/agent/types/index.js +1 -0
  11. package/dist/cjs/api/resources/fhirProvider/client/requests/FhirProviderAddAuthConfigRequest.d.ts +2 -2
  12. package/dist/cjs/api/resources/fhirProvider/client/requests/FhirProviderCreateRequest.d.ts +4 -2
  13. package/dist/cjs/api/resources/fhirProvider/types/AuthMethod.d.ts +22 -1
  14. package/dist/cjs/api/resources/fhirProvider/types/AuthMethod.js +22 -1
  15. package/dist/cjs/api/resources/fhirProvider/types/Provider.d.ts +1 -0
  16. package/dist/cjs/api/resources/fhirProvider/types/Provider.js +1 -0
  17. package/dist/cjs/api/resources/fhirProvider/types/Role.d.ts +20 -19
  18. package/dist/cjs/api/resources/fhirProvider/types/Role.js +20 -19
  19. package/dist/cjs/core/fetcher/Fetcher.js +2 -6
  20. package/dist/cjs/core/index.d.ts +1 -0
  21. package/dist/cjs/core/index.js +1 -0
  22. package/dist/cjs/core/stream/Stream.d.ts +47 -0
  23. package/dist/cjs/core/stream/Stream.js +172 -0
  24. package/dist/cjs/core/stream/index.d.ts +1 -0
  25. package/dist/cjs/core/stream/index.js +5 -0
  26. package/dist/cjs/version.d.ts +1 -1
  27. package/dist/cjs/version.js +1 -1
  28. package/dist/esm/Client.mjs +2 -2
  29. package/dist/esm/api/resources/agent/client/Client.d.mts +8 -1
  30. package/dist/esm/api/resources/agent/client/Client.mjs +82 -1
  31. package/dist/esm/api/resources/agent/client/requests/AgentStreamChatRequest.d.mts +31 -0
  32. package/dist/esm/api/resources/agent/client/requests/AgentStreamChatRequest.mjs +2 -0
  33. package/dist/esm/api/resources/agent/client/requests/index.d.mts +1 -0
  34. package/dist/esm/api/resources/agent/types/AgentChatStreamEvent.d.mts +36 -0
  35. package/dist/esm/api/resources/agent/types/AgentChatStreamEvent.mjs +13 -0
  36. package/dist/esm/api/resources/agent/types/index.d.mts +1 -0
  37. package/dist/esm/api/resources/agent/types/index.mjs +1 -0
  38. package/dist/esm/api/resources/fhirProvider/client/requests/FhirProviderAddAuthConfigRequest.d.mts +2 -2
  39. package/dist/esm/api/resources/fhirProvider/client/requests/FhirProviderCreateRequest.d.mts +4 -2
  40. package/dist/esm/api/resources/fhirProvider/types/AuthMethod.d.mts +22 -1
  41. package/dist/esm/api/resources/fhirProvider/types/AuthMethod.mjs +22 -1
  42. package/dist/esm/api/resources/fhirProvider/types/Provider.d.mts +1 -0
  43. package/dist/esm/api/resources/fhirProvider/types/Provider.mjs +1 -0
  44. package/dist/esm/api/resources/fhirProvider/types/Role.d.mts +20 -19
  45. package/dist/esm/api/resources/fhirProvider/types/Role.mjs +20 -19
  46. package/dist/esm/core/fetcher/Fetcher.mjs +2 -6
  47. package/dist/esm/core/index.d.mts +1 -0
  48. package/dist/esm/core/index.mjs +1 -0
  49. package/dist/esm/core/stream/Stream.d.mts +47 -0
  50. package/dist/esm/core/stream/Stream.mjs +167 -0
  51. package/dist/esm/core/stream/index.d.mts +1 -0
  52. package/dist/esm/core/stream/index.mjs +1 -0
  53. package/dist/esm/version.d.mts +1 -1
  54. package/dist/esm/version.mjs +1 -1
  55. package/package.json +1 -1
  56. package/reference.md +74 -1
@@ -52,8 +52,8 @@ class phenomlClient {
52
52
  this._options = Object.assign(Object.assign({}, _options), { logging: core.logging.createLogger(_options === null || _options === void 0 ? void 0 : _options.logging), headers: (0, headers_js_1.mergeHeaders)({
53
53
  "X-Fern-Language": "JavaScript",
54
54
  "X-Fern-SDK-Name": "phenoml",
55
- "X-Fern-SDK-Version": "6.3.1",
56
- "User-Agent": "phenoml/6.3.1",
55
+ "X-Fern-SDK-Version": "6.5.0",
56
+ "User-Agent": "phenoml/6.5.0",
57
57
  "X-Fern-Runtime": core.RUNTIME.type,
58
58
  "X-Fern-Runtime-Version": core.RUNTIME.version,
59
59
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -134,7 +134,7 @@ export declare class Agent {
134
134
  patch(id: string, request: phenoml.agent.JsonPatch, requestOptions?: Agent.RequestOptions): core.HttpResponsePromise<phenoml.agent.AgentResponse>;
135
135
  private __patch;
136
136
  /**
137
- * Send a message to an agent and receive a response
137
+ * Send a message to an agent and receive a JSON response.
138
138
  *
139
139
  * @param {phenoml.agent.AgentChatRequest} request
140
140
  * @param {Agent.RequestOptions} requestOptions - Request-specific configuration.
@@ -154,6 +154,13 @@ export declare class Agent {
154
154
  */
155
155
  chat(request: phenoml.agent.AgentChatRequest, requestOptions?: Agent.RequestOptions): core.HttpResponsePromise<phenoml.agent.AgentChatResponse>;
156
156
  private __chat;
157
+ /**
158
+ * Send a message to an agent and receive the response as a Server-Sent Events
159
+ * (SSE) stream. Events include message_start, content_delta, tool_use,
160
+ * tool_result, message_end, and error.
161
+ */
162
+ streamChat(request: phenoml.agent.AgentStreamChatRequest, requestOptions?: Agent.RequestOptions): core.HttpResponsePromise<core.Stream<phenoml.agent.AgentChatStreamEvent>>;
163
+ private __streamChat;
157
164
  /**
158
165
  * Retrieves a list of chat messages for a given chat session
159
166
  *
@@ -530,7 +530,7 @@ class Agent {
530
530
  });
531
531
  }
532
532
  /**
533
- * Send a message to an agent and receive a response
533
+ * Send a message to an agent and receive a JSON response.
534
534
  *
535
535
  * @param {phenoml.agent.AgentChatRequest} request
536
536
  * @param {Agent.RequestOptions} requestOptions - Request-specific configuration.
@@ -612,6 +612,87 @@ class Agent {
612
612
  }
613
613
  });
614
614
  }
615
+ /**
616
+ * Send a message to an agent and receive the response as a Server-Sent Events
617
+ * (SSE) stream. Events include message_start, content_delta, tool_use,
618
+ * tool_result, message_end, and error.
619
+ */
620
+ streamChat(request, requestOptions) {
621
+ return core.HttpResponsePromise.fromPromise(this.__streamChat(request, requestOptions));
622
+ }
623
+ __streamChat(request, requestOptions) {
624
+ return __awaiter(this, void 0, void 0, function* () {
625
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
626
+ const { "X-Phenoml-On-Behalf-Of": phenomlOnBehalfOf, "X-Phenoml-Fhir-Provider": phenomlFhirProvider } = request, _body = __rest(request, ["X-Phenoml-On-Behalf-Of", "X-Phenoml-Fhir-Provider"]);
627
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
628
+ Authorization: yield this._getAuthorizationHeader(),
629
+ "X-Phenoml-On-Behalf-Of": phenomlOnBehalfOf != null ? phenomlOnBehalfOf : undefined,
630
+ "X-Phenoml-Fhir-Provider": phenomlFhirProvider != null ? phenomlFhirProvider : undefined,
631
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
632
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
633
+ 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, "agent/stream-chat"),
634
+ method: "POST",
635
+ headers: _headers,
636
+ contentType: "application/json",
637
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
638
+ requestType: "json",
639
+ body: _body,
640
+ responseType: "sse",
641
+ 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,
642
+ 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,
643
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
644
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
645
+ logging: this._options.logging,
646
+ });
647
+ if (_response.ok) {
648
+ return {
649
+ data: new core.Stream({
650
+ stream: _response.body,
651
+ parse: (data) => data,
652
+ signal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
653
+ eventShape: {
654
+ type: "sse",
655
+ streamTerminator: "[DONE]",
656
+ },
657
+ }),
658
+ rawResponse: _response.rawResponse,
659
+ };
660
+ }
661
+ if (_response.error.reason === "status-code") {
662
+ switch (_response.error.statusCode) {
663
+ case 400:
664
+ throw new phenoml.agent.BadRequestError(_response.error.body, _response.rawResponse);
665
+ case 401:
666
+ throw new phenoml.agent.UnauthorizedError(_response.error.body, _response.rawResponse);
667
+ case 403:
668
+ throw new phenoml.agent.ForbiddenError(_response.error.body, _response.rawResponse);
669
+ case 500:
670
+ throw new phenoml.agent.InternalServerError(_response.error.body, _response.rawResponse);
671
+ default:
672
+ throw new errors.phenomlError({
673
+ statusCode: _response.error.statusCode,
674
+ body: _response.error.body,
675
+ rawResponse: _response.rawResponse,
676
+ });
677
+ }
678
+ }
679
+ switch (_response.error.reason) {
680
+ case "non-json":
681
+ throw new errors.phenomlError({
682
+ statusCode: _response.error.statusCode,
683
+ body: _response.error.rawBody,
684
+ rawResponse: _response.rawResponse,
685
+ });
686
+ case "timeout":
687
+ throw new errors.phenomlTimeoutError("Timeout exceeded when calling POST /agent/stream-chat.");
688
+ case "unknown":
689
+ throw new errors.phenomlError({
690
+ message: _response.error.errorMessage,
691
+ rawResponse: _response.rawResponse,
692
+ });
693
+ }
694
+ });
695
+ }
615
696
  /**
616
697
  * Retrieves a list of chat messages for a given chat session
617
698
  *
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * "X-Phenoml-On-Behalf-Of": "Patient/550e8400-e29b-41d4-a716-446655440000",
5
+ * "X-Phenoml-Fhir-Provider": "550e8400-e29b-41d4-a716-446655440000:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c...",
6
+ * message: "What is the patient's current condition?",
7
+ * agent_id: "agent-123"
8
+ * }
9
+ */
10
+ export interface AgentStreamChatRequest {
11
+ /**
12
+ * Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity.
13
+ * Must be in the format: Patient/{uuid} or Practitioner/{uuid}
14
+ */
15
+ "X-Phenoml-On-Behalf-Of"?: string;
16
+ /**
17
+ * Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}.
18
+ * Multiple FHIR provider integrations can be provided as comma-separated values.
19
+ */
20
+ "X-Phenoml-Fhir-Provider"?: string;
21
+ /** The message to send to the agent */
22
+ message: string;
23
+ /** Optional context for the conversation */
24
+ context?: string;
25
+ /** Optional session ID for conversation continuity */
26
+ session_id?: string;
27
+ /** The ID of the agent to chat with */
28
+ agent_id: string;
29
+ /** Enable enhanced reasoning capabilities, will increase latency but will also improve response quality and reliability. */
30
+ enhanced_reasoning?: boolean;
31
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,4 @@
1
1
  export type { AgentChatRequest } from "./AgentChatRequest.js";
2
2
  export type { AgentGetChatMessagesRequest } from "./AgentGetChatMessagesRequest.js";
3
3
  export type { AgentListRequest } from "./AgentListRequest.js";
4
+ export type { AgentStreamChatRequest } from "./AgentStreamChatRequest.js";
@@ -0,0 +1,36 @@
1
+ /**
2
+ * JSON payload sent in the `data:` line of a Server-Sent Event (SSE) frame for streaming chat responses.
3
+ * Each SSE frame uses the standard `event:` and `data:` lines; this schema describes the JSON object
4
+ * in the `data:` line. The event type is encoded in the top-level `type` property.
5
+ * Event types: message_start, content_delta, tool_use, tool_result, message_end, error.
6
+ */
7
+ export interface AgentChatStreamEvent {
8
+ /** The event type */
9
+ type?: AgentChatStreamEvent.Type;
10
+ /** Chat session ID */
11
+ session_id?: string;
12
+ /** Incremental text content (present in content_delta events) */
13
+ content?: string;
14
+ /** Whether the operation was successful */
15
+ success?: boolean;
16
+ /** Status message */
17
+ message?: string;
18
+ /** Tool/function name (present in tool_use and tool_result events) */
19
+ function_name?: string;
20
+ /** Tool arguments (present in tool_use events) */
21
+ function_args?: Record<string, unknown>;
22
+ /** Tool execution result (present in tool_result events) */
23
+ function_result?: Record<string, unknown>;
24
+ }
25
+ export declare namespace AgentChatStreamEvent {
26
+ /** The event type */
27
+ const Type: {
28
+ readonly MessageStart: "message_start";
29
+ readonly ContentDelta: "content_delta";
30
+ readonly ToolUse: "tool_use";
31
+ readonly ToolResult: "tool_result";
32
+ readonly MessageEnd: "message_end";
33
+ readonly Error: "error";
34
+ };
35
+ type Type = (typeof Type)[keyof typeof Type];
36
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.AgentChatStreamEvent = void 0;
5
+ var AgentChatStreamEvent;
6
+ (function (AgentChatStreamEvent) {
7
+ /** The event type */
8
+ AgentChatStreamEvent.Type = {
9
+ MessageStart: "message_start",
10
+ ContentDelta: "content_delta",
11
+ ToolUse: "tool_use",
12
+ ToolResult: "tool_result",
13
+ MessageEnd: "message_end",
14
+ Error: "error",
15
+ };
16
+ })(AgentChatStreamEvent || (exports.AgentChatStreamEvent = AgentChatStreamEvent = {}));
@@ -1,4 +1,5 @@
1
1
  export * from "./AgentChatResponse.js";
2
+ export * from "./AgentChatStreamEvent.js";
2
3
  export * from "./AgentCreateRequest.js";
3
4
  export * from "./AgentDeleteResponse.js";
4
5
  export * from "./AgentGetChatMessagesRequestOrder.js";
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./AgentChatResponse.js"), exports);
18
+ __exportStar(require("./AgentChatStreamEvent.js"), exports);
18
19
  __exportStar(require("./AgentCreateRequest.js"), exports);
19
20
  __exportStar(require("./AgentDeleteResponse.js"), exports);
20
21
  __exportStar(require("./AgentGetChatMessagesRequestOrder.js"), exports);
@@ -10,9 +10,9 @@ export interface FhirProviderAddAuthConfigRequest {
10
10
  /** OAuth client secret (required for client_secret and on_behalf_of auth methods) */
11
11
  client_secret?: string;
12
12
  service_account_key?: phenoml.fhirProvider.ServiceAccountKey;
13
- /** Expiry time for JWT credentials (only applicable for JWT auth method) */
13
+ /** Expiry time for JWT credentials (only applicable for JWT auth method). If omitted, a default expiry is used. */
14
14
  credential_expiry?: string;
15
15
  role?: phenoml.fhirProvider.Role;
16
- /** OAuth scopes to request. Cannot be specified with role. If neither role nor scopes are specified, the provider-specific default role will be used. You are solely responsible for ensuring the scopes are valid options for the provider being created or updated. */
16
+ /** OAuth scopes to request. Cannot be specified with role. If neither role nor scopes are specified, the provider-specific default role will be used. Only applicable to `client_secret`, `jwt`, and `on_behalf_of` auth methods; specifying scopes for other auth methods will return an error. Make sure the scopes you specify are appropriate for the auth config and provider you are using. */
17
17
  scopes?: string;
18
18
  }
@@ -17,12 +17,14 @@ export interface FhirProviderCreateRequest {
17
17
  auth_method: phenoml.fhirProvider.AuthMethod;
18
18
  /** Base URL of the FHIR server */
19
19
  base_url: string;
20
- /** OAuth client ID (required for most auth methods) */
20
+ /** OAuth client ID (required for jwt, client_secret, and on_behalf_of auth methods) */
21
21
  client_id?: string;
22
22
  /** OAuth client secret (required for client_secret and on_behalf_of auth methods) */
23
23
  client_secret?: string;
24
24
  service_account_key?: phenoml.fhirProvider.ServiceAccountKey;
25
+ /** Expiry time for JWT credentials (only applicable for JWT auth method). If omitted, a default expiry is used. */
26
+ credential_expiry?: string;
25
27
  role?: phenoml.fhirProvider.Role;
26
- /** OAuth scopes to request. Cannot be specified with role. If neither role nor scopes are specified, the provider-specific default role will be used. You are solely responsible for ensuring the scopes are valid options for the provider being created or updated. */
28
+ /** OAuth scopes to request. Cannot be specified with role. If neither role nor scopes are specified, the provider-specific default role will be used. Only applicable to `client_secret`, `jwt`, and `on_behalf_of` auth methods; specifying scopes for other auth methods will return an error. Make sure the scopes you specify are appropriate for the auth config and provider you are using. */
27
29
  scopes?: string;
28
30
  }
@@ -1,4 +1,25 @@
1
- /** Authentication method for the FHIR provider. Only one authentication method can be used at a time, but these can be rotated on the FHIR Provider as needed. For the 'token_passthrough' authentication method, you must provide the token in the X-Phenoml-Fhir-Provider header in the format {fhir_provider_id}:{oauth2_token}. For the 'on_behalf_of' authentication method, you must provide the Patient or Practitioner reference in the X-Phenoml-On-Behalf-Of header in the format Patient/{uuid} or Practitioner/{uuid}. This only works for the medplum provider currently. More on the authentication headers and how to structure them can be found in the FHIR Proxy, Tools and Agent documentation. */
1
+ /**
2
+ * Authentication method for the FHIR provider. Only one authentication method can be used at a time,
3
+ * but these can be rotated on the FHIR Provider as needed.
4
+ *
5
+ * **Scope behavior by auth method:**
6
+ * - `client_secret`, `jwt`, `on_behalf_of`: Scopes are included in the OAuth token request.
7
+ * They can be configured using the `role` or `scopes` field. If neither is specified, provider-specific
8
+ * default scopes derived from a default role are used.
9
+ * - `google_healthcare`: Uses a fixed Google Cloud Healthcare scope. Specifying `role` or `scopes` will
10
+ * return an error.
11
+ * - `token_passthrough`: The caller provides their own bearer token via the X-Phenoml-Fhir-Provider header
12
+ * as one or more comma-separated {fhir_provider_id}:{oauth2_token} pairs. Specifying `role` or `scopes`
13
+ * will return an error.
14
+ * - `none`: No authentication is performed. Specifying `role` or `scopes` will return an error.
15
+ *
16
+ * For the `on_behalf_of` authentication method, you must also provide the Patient or Practitioner reference
17
+ * in the X-Phenoml-On-Behalf-Of header in the format Patient/{uuid} or Practitioner/{uuid}. This only works
18
+ * for the medplum provider currently.
19
+ *
20
+ * More on the authentication headers and how to structure them can be found in the FHIR Proxy, Tools and
21
+ * Agent documentation.
22
+ */
2
23
  export declare const AuthMethod: {
3
24
  readonly ClientSecret: "client_secret";
4
25
  readonly GoogleHealthcare: "google_healthcare";
@@ -2,7 +2,28 @@
2
2
  // This file was auto-generated by Fern from our API Definition.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.AuthMethod = void 0;
5
- /** Authentication method for the FHIR provider. Only one authentication method can be used at a time, but these can be rotated on the FHIR Provider as needed. For the 'token_passthrough' authentication method, you must provide the token in the X-Phenoml-Fhir-Provider header in the format {fhir_provider_id}:{oauth2_token}. For the 'on_behalf_of' authentication method, you must provide the Patient or Practitioner reference in the X-Phenoml-On-Behalf-Of header in the format Patient/{uuid} or Practitioner/{uuid}. This only works for the medplum provider currently. More on the authentication headers and how to structure them can be found in the FHIR Proxy, Tools and Agent documentation. */
5
+ /**
6
+ * Authentication method for the FHIR provider. Only one authentication method can be used at a time,
7
+ * but these can be rotated on the FHIR Provider as needed.
8
+ *
9
+ * **Scope behavior by auth method:**
10
+ * - `client_secret`, `jwt`, `on_behalf_of`: Scopes are included in the OAuth token request.
11
+ * They can be configured using the `role` or `scopes` field. If neither is specified, provider-specific
12
+ * default scopes derived from a default role are used.
13
+ * - `google_healthcare`: Uses a fixed Google Cloud Healthcare scope. Specifying `role` or `scopes` will
14
+ * return an error.
15
+ * - `token_passthrough`: The caller provides their own bearer token via the X-Phenoml-Fhir-Provider header
16
+ * as one or more comma-separated {fhir_provider_id}:{oauth2_token} pairs. Specifying `role` or `scopes`
17
+ * will return an error.
18
+ * - `none`: No authentication is performed. Specifying `role` or `scopes` will return an error.
19
+ *
20
+ * For the `on_behalf_of` authentication method, you must also provide the Patient or Practitioner reference
21
+ * in the X-Phenoml-On-Behalf-Of header in the format Patient/{uuid} or Practitioner/{uuid}. This only works
22
+ * for the medplum provider currently.
23
+ *
24
+ * More on the authentication headers and how to structure them can be found in the FHIR Proxy, Tools and
25
+ * Agent documentation.
26
+ */
6
27
  exports.AuthMethod = {
7
28
  ClientSecret: "client_secret",
8
29
  GoogleHealthcare: "google_healthcare",
@@ -13,6 +13,7 @@ export declare const Provider: {
13
13
  readonly GoogleHealthcare: "google_healthcare";
14
14
  readonly Hapi: "hapi";
15
15
  readonly Medplum: "medplum";
16
+ readonly Phenostore: "phenostore";
16
17
  readonly Sandbox: "sandbox";
17
18
  };
18
19
  export type Provider = (typeof Provider)[keyof typeof Provider];
@@ -17,5 +17,6 @@ exports.Provider = {
17
17
  GoogleHealthcare: "google_healthcare",
18
18
  Hapi: "hapi",
19
19
  Medplum: "medplum",
20
+ Phenostore: "phenostore",
20
21
  Sandbox: "sandbox",
21
22
  };
@@ -1,22 +1,23 @@
1
- /** Predefined role that specifies OAuth scopes. Cannot be specified with scopes. Available roles depend on the provider being created or updated. */
1
+ /**
2
+ * Predefined access level that maps to provider-specific OAuth scopes.
3
+ * Cannot be specified together with `scopes`. Only applicable to
4
+ * `client_secret`, `jwt`, and `on_behalf_of` auth methods.
5
+ *
6
+ * The server resolves each role to the appropriate scopes for the provider:
7
+ * - `admin`: Full CRUD access (create, read, update, delete, search)
8
+ * - `read`: Read and search access only
9
+ * - `write`: Create, update, and delete access (no read)
10
+ *
11
+ * If neither `role` nor `scopes` is specified, the provider-specific default
12
+ * role is used (typically `read`; `admin` for Medplum/sandbox).
13
+ *
14
+ * Canvas does not support system-level roles — use `scopes` directly.
15
+ * Google Healthcare, HAPI, and `none`/`token_passthrough` auth methods
16
+ * do not use scopes at all.
17
+ */
2
18
  export declare const Role: {
3
- readonly SmartV1Admin: "SmartV1Admin";
4
- readonly SmartV1Read: "SmartV1Read";
5
- readonly SmartV1Write: "SmartV1Write";
6
- readonly SmartV2Admin: "SmartV2Admin";
7
- readonly SmartV2Read: "SmartV2Read";
8
- readonly SmartV2Write: "SmartV2Write";
9
- readonly UscdiSmartV1Admin: "USCDISmartV1Admin";
10
- readonly UscdiSmartV1Read: "USCDISmartV1Read";
11
- readonly UscdiSmartV1Write: "USCDISmartV1Write";
12
- readonly UscdiSmartV2Admin: "USCDISmartV2Admin";
13
- readonly UscdiSmartV2Read: "USCDISmartV2Read";
14
- readonly UscdiSmartV2Write: "USCDISmartV2Write";
15
- readonly CernerSmartV1Admin: "CernerSmartV1Admin";
16
- readonly CernerSmartV1Read: "CernerSmartV1Read";
17
- readonly CernerSmartV1Write: "CernerSmartV1Write";
18
- readonly CernerSmartV2Admin: "CernerSmartV2Admin";
19
- readonly CernerSmartV2Read: "CernerSmartV2Read";
20
- readonly CernerSmartV2Write: "CernerSmartV2Write";
19
+ readonly Admin: "admin";
20
+ readonly Read: "read";
21
+ readonly Write: "write";
21
22
  };
22
23
  export type Role = (typeof Role)[keyof typeof Role];
@@ -2,24 +2,25 @@
2
2
  // This file was auto-generated by Fern from our API Definition.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.Role = void 0;
5
- /** Predefined role that specifies OAuth scopes. Cannot be specified with scopes. Available roles depend on the provider being created or updated. */
5
+ /**
6
+ * Predefined access level that maps to provider-specific OAuth scopes.
7
+ * Cannot be specified together with `scopes`. Only applicable to
8
+ * `client_secret`, `jwt`, and `on_behalf_of` auth methods.
9
+ *
10
+ * The server resolves each role to the appropriate scopes for the provider:
11
+ * - `admin`: Full CRUD access (create, read, update, delete, search)
12
+ * - `read`: Read and search access only
13
+ * - `write`: Create, update, and delete access (no read)
14
+ *
15
+ * If neither `role` nor `scopes` is specified, the provider-specific default
16
+ * role is used (typically `read`; `admin` for Medplum/sandbox).
17
+ *
18
+ * Canvas does not support system-level roles — use `scopes` directly.
19
+ * Google Healthcare, HAPI, and `none`/`token_passthrough` auth methods
20
+ * do not use scopes at all.
21
+ */
6
22
  exports.Role = {
7
- SmartV1Admin: "SmartV1Admin",
8
- SmartV1Read: "SmartV1Read",
9
- SmartV1Write: "SmartV1Write",
10
- SmartV2Admin: "SmartV2Admin",
11
- SmartV2Read: "SmartV2Read",
12
- SmartV2Write: "SmartV2Write",
13
- UscdiSmartV1Admin: "USCDISmartV1Admin",
14
- UscdiSmartV1Read: "USCDISmartV1Read",
15
- UscdiSmartV1Write: "USCDISmartV1Write",
16
- UscdiSmartV2Admin: "USCDISmartV2Admin",
17
- UscdiSmartV2Read: "USCDISmartV2Read",
18
- UscdiSmartV2Write: "USCDISmartV2Write",
19
- CernerSmartV1Admin: "CernerSmartV1Admin",
20
- CernerSmartV1Read: "CernerSmartV1Read",
21
- CernerSmartV1Write: "CernerSmartV1Write",
22
- CernerSmartV2Admin: "CernerSmartV2Admin",
23
- CernerSmartV2Read: "CernerSmartV2Read",
24
- CernerSmartV2Write: "CernerSmartV2Write",
23
+ Admin: "admin",
24
+ Read: "read",
25
+ Write: "write",
25
26
  };
@@ -156,11 +156,7 @@ function getHeaders(args) {
156
156
  return __awaiter(this, void 0, void 0, function* () {
157
157
  var _a;
158
158
  const newHeaders = new Headers_js_1.Headers();
159
- newHeaders.set("Accept", args.responseType === "json" || args.responseType == null
160
- ? "application/json"
161
- : args.responseType === "text"
162
- ? "text/plain"
163
- : "*/*");
159
+ newHeaders.set("Accept", args.responseType === "json" ? "application/json" : args.responseType === "text" ? "text/plain" : "*/*");
164
160
  if (args.body !== undefined && args.contentType != null) {
165
161
  newHeaders.set("Content-Type", args.contentType);
166
162
  }
@@ -229,7 +225,7 @@ function fetcherImpl(args) {
229
225
  method: args.method,
230
226
  url: redactUrl(url),
231
227
  statusCode: response.status,
232
- responseHeaders: redactHeaders(response.headers),
228
+ responseHeaders: redactHeaders(Object.fromEntries(response.headers.entries())),
233
229
  };
234
230
  logger.error("HTTP request failed with error status", metadata);
235
231
  }
@@ -3,4 +3,5 @@ export * from "./base64.js";
3
3
  export * from "./fetcher/index.js";
4
4
  export * as logging from "./logging/index.js";
5
5
  export * from "./runtime/index.js";
6
+ export * from "./stream/index.js";
6
7
  export * as url from "./url/index.js";
@@ -42,4 +42,5 @@ __exportStar(require("./base64.js"), exports);
42
42
  __exportStar(require("./fetcher/index.js"), exports);
43
43
  exports.logging = __importStar(require("./logging/index.js"));
44
44
  __exportStar(require("./runtime/index.js"), exports);
45
+ __exportStar(require("./stream/index.js"), exports);
45
46
  exports.url = __importStar(require("./url/index.js"));
@@ -0,0 +1,47 @@
1
+ export declare namespace Stream {
2
+ interface Args {
3
+ /**
4
+ * The HTTP response stream to read from.
5
+ */
6
+ stream: ReadableStream;
7
+ /**
8
+ * The event shape to use for parsing the stream data.
9
+ */
10
+ eventShape: JsonEvent | SseEvent;
11
+ /**
12
+ * An abort signal to stop the stream.
13
+ */
14
+ signal?: AbortSignal;
15
+ }
16
+ interface JsonEvent {
17
+ type: "json";
18
+ messageTerminator: string;
19
+ }
20
+ interface SseEvent {
21
+ type: "sse";
22
+ streamTerminator?: string;
23
+ }
24
+ }
25
+ export declare class Stream<T> implements AsyncIterable<T> {
26
+ private stream;
27
+ private parse;
28
+ /**
29
+ * The prefix to use for each message. For example,
30
+ * for SSE, the prefix is "data: ".
31
+ */
32
+ private prefix;
33
+ private messageTerminator;
34
+ private streamTerminator;
35
+ private controller;
36
+ private decoder;
37
+ constructor({ stream, parse, eventShape, signal }: Stream.Args & {
38
+ parse: (val: unknown) => Promise<T>;
39
+ });
40
+ private iterMessages;
41
+ [Symbol.asyncIterator](): AsyncIterator<T, void, unknown>;
42
+ private decodeChunk;
43
+ }
44
+ /**
45
+ * Browser polyfill for ReadableStream
46
+ */
47
+ export declare function readableStreamAsyncIterable<T>(stream: any): AsyncIterableIterator<T>;