@openedc/sdk 3.8.2-next.1 → 3.8.2-next.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/README.md +1 -1
- package/openedc-sdk.d.ts +12 -5
- package/openedc-sdk.js +12 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -100,7 +100,7 @@ await subject.set({ subjectKey: "Patient-003" }).commit();
|
|
|
100
100
|
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
101
|
|
|
102
102
|
```ts
|
|
103
|
-
import { Location, SubjectData } from "@openedc/sdk";
|
|
103
|
+
import { scope, Location, SubjectData } from "@openedc/sdk";
|
|
104
104
|
|
|
105
105
|
// Scope subsequent queries and commits
|
|
106
106
|
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:
|
|
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
|
|
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
|
-
|
|
811
|
+
startDateUTC: string;
|
|
805
812
|
private startTimeUTC?;
|
|
806
|
-
|
|
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 (
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
|
|
9842
|
-
|
|
9843
|
-
|
|
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(
|
|
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(
|
|
20784
|
+
const s = await fetch(new URL("/api/auth/token", t), {
|
|
20783
20785
|
method: "POST",
|
|
20784
20786
|
headers: {
|
|
20785
20787
|
Authorization: `Bearer ${e}`
|