@clinia/context-engine-js 0.6.0-rc.0 → 0.6.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @clinia/context-engine-js
2
2
 
3
+ ## 0.6.0-rc.2
4
+
5
+ ### Minor Changes
6
+
7
+ - b704c4a: Expose each area of the API as a resource property on `ContextEngineClient` — `client.patients`, `client.ingest`, `client.graph`, `client.sessions`, `client.vfs`, `client.info` — alongside the existing low-level `http` client. The resource classes are exported too, for constructing one on its own.
8
+
9
+ Add `ingest.ingestCdaR2Multipart()`, which submits several CDA documents in one request as `multipart/form-data`. `ingest.ingestCdaR2()` continues to submit a single document as `application/cda+xml`. A route offering more than one request media type now gets one method per media type rather than only its first.
10
+
11
+ ## 0.6.0-rc.1
12
+
3
13
  ## 0.6.0-rc.0
4
14
 
5
15
  ## 0.5.0
package/README.md CHANGED
@@ -27,14 +27,16 @@ npm install @clinia/context-engine-js@rc
27
27
 
28
28
  ## Exports
29
29
 
30
- | Export | Description |
31
- | ------------------------------------------ | --------------------------------------------------------------------------- |
32
- | `ContextEngineClient` | Entry point. Holds a low-level `http` client. |
33
- | `HttpClient` | Typed `openapi-fetch` wrapper (`GET`/`POST`/`PUT`/`PATCH`/`DELETE`, `use`). |
34
- | `ContextEngineClientOptions` | Constructor options (alias of `HttpClientOptions`). |
35
- | `createClientCredentialsTokenProvider` | Builds a caching OAuth2 client-credentials token provider. |
36
- | `TokenProvider`, `ClientCredentialsConfig` | Auth types. |
37
- | `paths`, generated request/response types | Emitted from the OpenAPI spec. |
30
+ | Export | Description |
31
+ | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
32
+ | `ContextEngineClient` | Entry point. One resource property per API area, plus a low-level `http` client. |
33
+ | Resource classes | `InfoResource`, `PatientsResource`, `IngestResource`, `SessionsResource`, `VFSResource`, `GraphResource` — to construct one on its own over an `HttpClient`. |
34
+ | `Resources`, `createResources` | The resource set as an interface, and a builder for one of each over a shared `HttpClient`. |
35
+ | `HttpClient` | Typed `openapi-fetch` wrapper (`GET`/`POST`/`PUT`/`PATCH`/`DELETE`, `use`). |
36
+ | `ContextEngineClientOptions` | Constructor options (alias of `HttpClientOptions`). |
37
+ | `createClientCredentialsTokenProvider` | Builds a caching OAuth2 client-credentials token provider. |
38
+ | `TokenProvider`, `ClientCredentialsConfig` | Auth types. |
39
+ | `paths`, generated request/response types | Emitted from the OpenAPI spec. |
38
40
 
39
41
  ## Usage
40
42
 
@@ -54,7 +56,7 @@ const client = new ContextEngineClient({
54
56
  },
55
57
  });
56
58
 
57
- const { data, error } = await client.http.GET("/v1/patients");
59
+ const { data, error } = await client.patients.listPatients();
58
60
  ```
59
61
 
60
62
  That is the whole configuration. The client resolves Clinia's authorization
@@ -62,8 +64,24 @@ server, acquires a bearer token, caches it, refreshes it before expiry, and
62
64
  attaches `Authorization: Bearer <token>` to every request. Tokens last an hour;
63
65
  you do not manage them.
64
66
 
65
- The `http` client exposes the typed verbs directly, and the path, path params,
66
- query, and body are all checked against the OpenAPI contract:
67
+ ### Resources
68
+
69
+ Each area of the API is a property on the client, with one method per operation:
70
+
71
+ ```ts
72
+ await client.patients.getPatient("abc");
73
+ await client.graph.listNodes("abc", "fact", { query: { perPage: 50 } });
74
+ await client.ingest.ingestCdaR2("abc", cdaXml);
75
+ await client.ingest.ingestCdaR2Multipart("abc", { documents: [firstCda, secondCda] });
76
+ ```
77
+
78
+ Responses are `{ data, error }` — nothing throws on a non-2xx.
79
+
80
+ ### The `http` client
81
+
82
+ `client.http` covers anything the resource methods do not. It exposes the typed
83
+ verbs directly, with the path, path params, query, and body all checked against
84
+ the OpenAPI contract:
67
85
 
68
86
  ```ts
69
87
  await client.http.GET("/v1/patients/{patientId}/read", {
@@ -71,8 +89,6 @@ await client.http.GET("/v1/patients/{patientId}/read", {
71
89
  });
72
90
  ```
73
91
 
74
- Responses are `{ data, error }` — nothing throws on a non-2xx.
75
-
76
92
  ### Without authentication
77
93
 
78
94
  Omit `auth` entirely and the client sends no `Authorization` header. Useful
@@ -1,14 +1,26 @@
1
1
  import { HttpClient, type HttpClientOptions } from "./http-client";
2
+ import { GraphResource, InfoResource, IngestResource, PatientsResource, SessionsResource, VFSResource, type Resources } from "./resources";
2
3
  export type ContextEngineClientOptions = HttpClientOptions;
3
4
  /**
4
5
  * Client for the Clinia Context Engine API.
5
6
  *
6
- * For now this client only exposes a low-level `http` client for making requests to the API. Higher-level resource methods can be added as the API surface stabilizes.
7
+ * Each area of the API is a resource property — `client.patients`, `client.ingest`,
8
+ * `client.graph` — and `http` stays available underneath for anything a resource method does
9
+ * not cover. Every resource shares that one http client, so authentication is configured once.
10
+ *
11
+ * `implements Resources` is what keeps this list honest: the resources are generated from the
12
+ * API spec, and a new one is a compile error here until it is named.
7
13
  */
8
- export declare class ContextEngineClient {
14
+ export declare class ContextEngineClient implements Resources {
9
15
  /**
10
16
  * Low-level http client. Use when a resource method does not cover your use case.
11
17
  */
12
18
  readonly http: HttpClient;
19
+ readonly info: InfoResource;
20
+ readonly patients: PatientsResource;
21
+ readonly ingest: IngestResource;
22
+ readonly sessions: SessionsResource;
23
+ readonly vfs: VFSResource;
24
+ readonly graph: GraphResource;
13
25
  constructor(options: ContextEngineClientOptions);
14
26
  }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * A `multipart/form-data` request body, built from the object form of the schema.
3
+ *
4
+ * An array-valued field becomes one part per item under the same field name — how a schema
5
+ * declaring an array of items is sent — and every other field becomes a single part. A field
6
+ * left `undefined` or `null` is omitted rather than sent as the string `"undefined"` or `"null"`.
7
+ *
8
+ * Values are appended as given, so a string is sent as text and a `Blob` or `File` keeps the
9
+ * filename and content type it was created with.
10
+ *
11
+ * No `Content-Type` is set anywhere: the header carries the multipart boundary, which only
12
+ * the runtime sending the request can know.
13
+ */
14
+ export declare function toFormData(body: unknown): FormData;