@openedc/sdk 3.8.2-next.1 → 3.9.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/README.md CHANGED
@@ -9,6 +9,8 @@
9
9
 
10
10
  The official TypeScript SDK for the OpenEDC Health Platform.
11
11
 
12
+ It allows you to integrate our platform into your web or mobile application, reporting pipeline, or any server-side automation or custom tooling built around your study.
13
+
12
14
  Fully typed end-to-end, it runs on any modern JavaScript runtime (Node, Deno, Bun) and gives you a clean, expressive API to work with all aspects of a clinical study:
13
15
 
14
16
  - **Data access:** Query study metadata, clinical data, administrative data, and more, with flexible filtering, sorting, and cross-project support
@@ -100,7 +102,7 @@ await subject.set({ subjectKey: "Patient-003" }).commit();
100
102
  Instead of specifying the project per call, a global scope can be set for all upcoming statements. This works well for linear, sequential flows but should be avoided in parallel or callback-based code that handles multiple projects concurrently. Assumed for the rest of the examples.
101
103
 
102
104
  ```ts
103
- import { Location, SubjectData } from "@openedc/sdk";
105
+ import { scope, Location, SubjectData } from "@openedc/sdk";
104
106
 
105
107
  // Scope subsequent queries and commits
106
108
  scope(project);
package/openedc-sdk.d.ts CHANGED
@@ -196,6 +196,13 @@ export type FieldDefinition = {
196
196
  relation?: typeof DataBlock | typeof DataBlock[];
197
197
  delete?: "unset" | "cascade";
198
198
  };
199
+ export type FieldsOf<T> = {
200
+ [K in keyof T as T[K] extends Function ? never : K]: T[K];
201
+ };
202
+ export type WhereValue<T> = T extends DataBlock ? T | BlockReference<T> : T extends BlockReference<infer U> ? T | U : T extends (infer E)[] ? WhereValue<E>[] : T;
203
+ export type WhereFilter<T> = {
204
+ [K in keyof FieldsOf<T>]?: WhereValue<T[K]>;
205
+ };
199
206
  declare class DataBlock {
200
207
  static adapter: PersistenceAdapter;
201
208
  static fields: Record<string, FieldDefinition>;
@@ -215,8 +222,8 @@ declare class DataBlock {
215
222
  get static(): typeof DataBlock;
216
223
  protected get children(): DataBlock[];
217
224
  static where<T extends typeof DataBlock>(this: T): Collection<T>;
218
- static where<T extends typeof DataBlock>(this: T, value: string): Where<T>;
219
- static where<T extends typeof DataBlock>(this: T, value: Record<string, ExtendedKey>): Collection<T>;
225
+ static where<T extends typeof DataBlock>(this: T, value: keyof WhereFilter<InstanceType<T>> & string): Where<T>;
226
+ static where<T extends typeof DataBlock>(this: T, value: WhereFilter<InstanceType<T>>): Collection<T>;
220
227
  commit(options?: {
221
228
  cascade?: boolean;
222
229
  project?: Project | string;
@@ -243,7 +250,7 @@ declare class DataBlock {
243
250
  }, visited?: Record<string, DataBlock>): this;
244
251
  find<T extends typeof DataBlock>(block: T, key?: string, value?: unknown, all?: boolean, visited?: Set<string>): InstanceType<T> | undefined;
245
252
  find<T extends typeof DataBlock>(block: T, key: string | undefined, value: unknown | undefined, all: true, visited?: Set<string>): InstanceType<T>[] | undefined;
246
- set(values: Partial<this>): this & Partial<this>;
253
+ set(values: Partial<FieldsOf<this>>): this & Partial<FieldsOf<this>>;
247
254
  get uncommitted(): boolean;
248
255
  get reference(): BlockReference<this>;
249
256
  private static withCache;
@@ -801,9 +808,9 @@ export declare class CalendarEvent extends DataBlock {
801
808
  studyEventInstance?: number;
802
809
  name?: string;
803
810
  description?: string;
804
- private startDateUTC;
811
+ startDateUTC: string;
805
812
  private startTimeUTC?;
806
- private endDateUTC;
813
+ endDateUTC: string;
807
814
  private endTimeUTC?;
808
815
  shared?: boolean;
809
816
  constructor(owner: BlockReference<User>, startDate: string);
package/openedc-sdk.js CHANGED
@@ -9833,15 +9833,17 @@ const Gs = (Ve = class {
9833
9833
  static async rebuildBlock(e) {
9834
9834
  const r = Object.assign(new this(), e);
9835
9835
  for (const [n, i] of Object.entries(this.fields)) {
9836
- if (!i.relation) continue;
9837
9836
  const s = Reflect.get(r, n);
9838
- if (Array.isArray(s)) {
9839
- const o = s.map((u) => ke.fromString(u)).filter((u) => !!u), a = i.lazy ? o : await Promise.all(o.map((u) => u.data));
9840
- Reflect.set(r, n, a.filter((u) => u));
9841
- } else {
9842
- const o = ke.fromString(s), a = i.lazy ? o : await (o == null ? void 0 : o.data);
9843
- Reflect.set(r, n, a);
9844
- }
9837
+ if (i.type === Date && s)
9838
+ Reflect.set(r, n, new Date(s));
9839
+ else if (i.relation)
9840
+ if (Array.isArray(s)) {
9841
+ const o = s.map((u) => ke.fromString(u)).filter((u) => !!u), a = i.lazy ? o : await Promise.all(o.map((u) => u.data));
9842
+ Reflect.set(r, n, a.filter(Boolean));
9843
+ } else {
9844
+ const o = ke.fromString(s), a = i.lazy ? o : await (o == null ? void 0 : o.data);
9845
+ Reflect.set(r, n, a);
9846
+ }
9845
9847
  }
9846
9848
  return r.internal.lastState = structuredClone(e), r;
9847
9849
  }
@@ -20768,7 +20770,7 @@ Ze = Et([
20768
20770
  let Yn;
20769
20771
  const xD = async ({ serverUrl: t, apiKey: e }) => {
20770
20772
  var d;
20771
- const r = await fetch(t + "/api/status");
20773
+ const r = await fetch(new URL("/api/status", t));
20772
20774
  if (!r.ok) throw new Error("Server not available");
20773
20775
  const { supabaseUrl: n, supabaseKey: i } = await r.json();
20774
20776
  Yn = ip(n, i, {
@@ -20779,7 +20781,7 @@ const xD = async ({ serverUrl: t, apiKey: e }) => {
20779
20781
  }
20780
20782
  }
20781
20783
  });
20782
- const s = await fetch(t + "/api/auth/token", {
20784
+ const s = await fetch(new URL("/api/auth/token", t), {
20783
20785
  method: "POST",
20784
20786
  headers: {
20785
20787
  Authorization: `Bearer ${e}`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openedc/sdk",
3
- "version": "3.8.2-next.1",
3
+ "version": "3.9.0",
4
4
  "description": "TypeScript SDK for the OpenEDC Health Platform",
5
5
  "type": "module",
6
6
  "main": "./openedc-sdk.js",