@ohm_studio/sdk-core 0.1.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/client.d.ts +33 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +173 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +62 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +60 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/retry.d.ts +4 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +10 -0
- package/dist/retry.js.map +1 -0
- package/dist/types.d.ts +81 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +35 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { AudioExtractInput, AudioExtractResult, AudioTranscribeInput, AudioTranscribeResult, ExtractInput, ExtractResult, InsightsInput, InsightsResult, OHMClientOptions, SummarizeInput, SummarizeResult, UsageEvent } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Platform-agnostic core client. Subclasses (sdk-js, sdk-react-native)
|
|
4
|
+
* supply the platform-specific multipart/audio adapter via the `attachAudio`
|
|
5
|
+
* hook so audio.transcribe + audio.extract can be shared.
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class OHMCoreClient {
|
|
8
|
+
protected readonly baseUrl: string;
|
|
9
|
+
protected readonly apiKey?: string;
|
|
10
|
+
protected readonly jwt?: string;
|
|
11
|
+
protected readonly timeoutMs: number;
|
|
12
|
+
protected readonly maxRetries: number;
|
|
13
|
+
protected readonly fetchImpl: typeof fetch;
|
|
14
|
+
protected readonly onUsage?: (e: UsageEvent) => void;
|
|
15
|
+
constructor(opts: OHMClientOptions);
|
|
16
|
+
/** Audio surface — subclasses fill in the multipart adapter. */
|
|
17
|
+
audio: {
|
|
18
|
+
transcribe: (input: AudioTranscribeInput) => Promise<AudioTranscribeResult>;
|
|
19
|
+
extract: <T = Record<string, unknown>>(input: AudioExtractInput) => Promise<AudioExtractResult<T>>;
|
|
20
|
+
};
|
|
21
|
+
extract<T = Record<string, unknown>>(input: ExtractInput): Promise<ExtractResult<T>>;
|
|
22
|
+
summarize(input: SummarizeInput): Promise<SummarizeResult>;
|
|
23
|
+
insights<T = unknown>(input: InsightsInput): Promise<InsightsResult<T>>;
|
|
24
|
+
protected requestJson<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
25
|
+
protected abstract runMultipart<T>(opts: {
|
|
26
|
+
path: string;
|
|
27
|
+
file: any;
|
|
28
|
+
fields?: Record<string, string>;
|
|
29
|
+
}): Promise<T>;
|
|
30
|
+
protected requestRaw<T>(method: string, path: string, init: RequestInit): Promise<T>;
|
|
31
|
+
private parseError;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,UAAU,EACX,MAAM,SAAS,CAAC;AAMjB;;;;GAIG;AACH,8BAAsB,aAAa;IACjC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACnC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACnC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAChC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IACrC,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IACtC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,KAAK,CAAC;IAC3C,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;gBAEzC,IAAI,EAAE,gBAAgB;IAelC,gEAAgE;IAChE,KAAK;4BACiB,oBAAoB;kBAM9B,CAAC,mCAAmC,iBAAiB;MAS/D;IAEI,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAYtB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAQ1D,QAAQ,CAAC,CAAC,GAAG,OAAO,EACxB,KAAK,EAAE,aAAa,GACnB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;cAab,WAAW,CAAC,CAAC,EAC3B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,GACb,OAAO,CAAC,CAAC,CAAC;IAOb,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE;QACvC,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,GAAG,CAAC;QACV,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACjC,GAAG,OAAO,CAAC,CAAC,CAAC;cAEE,UAAU,CAAC,CAAC,EAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,WAAW,GAChB,OAAO,CAAC,CAAC,CAAC;YA4DC,UAAU;CAkCzB"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { OHMAuthError, OHMConfigError, OHMError, OHMRateLimitError, OHMServerError, OHMValidationError, } from "./errors";
|
|
2
|
+
import { backoffMs, isRetriableStatus } from "./retry";
|
|
3
|
+
const DEFAULT_BASE_URL = "https://api.ohm.doctor";
|
|
4
|
+
const DEFAULT_TIMEOUT_MS = 60_000;
|
|
5
|
+
const DEFAULT_MAX_RETRIES = 2;
|
|
6
|
+
/**
|
|
7
|
+
* Platform-agnostic core client. Subclasses (sdk-js, sdk-react-native)
|
|
8
|
+
* supply the platform-specific multipart/audio adapter via the `attachAudio`
|
|
9
|
+
* hook so audio.transcribe + audio.extract can be shared.
|
|
10
|
+
*/
|
|
11
|
+
export class OHMCoreClient {
|
|
12
|
+
baseUrl;
|
|
13
|
+
apiKey;
|
|
14
|
+
jwt;
|
|
15
|
+
timeoutMs;
|
|
16
|
+
maxRetries;
|
|
17
|
+
fetchImpl;
|
|
18
|
+
onUsage;
|
|
19
|
+
constructor(opts) {
|
|
20
|
+
if (!opts.apiKey && !opts.jwt) {
|
|
21
|
+
throw new OHMConfigError({
|
|
22
|
+
message: "OHM client requires either `apiKey` or `jwt`",
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
this.baseUrl = (opts.baseUrl || DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
26
|
+
this.apiKey = opts.apiKey;
|
|
27
|
+
this.jwt = opts.jwt;
|
|
28
|
+
this.timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
29
|
+
this.maxRetries = opts.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
30
|
+
this.fetchImpl = opts.fetch ?? globalThis.fetch.bind(globalThis);
|
|
31
|
+
this.onUsage = opts.onUsage;
|
|
32
|
+
}
|
|
33
|
+
/** Audio surface — subclasses fill in the multipart adapter. */
|
|
34
|
+
audio = {
|
|
35
|
+
transcribe: (input) => this.runMultipart({
|
|
36
|
+
path: "/api/studio/v1/audio/transcribe",
|
|
37
|
+
file: input.file,
|
|
38
|
+
fields: input.language ? { language: input.language } : undefined,
|
|
39
|
+
}),
|
|
40
|
+
extract: (input) => this.runMultipart({
|
|
41
|
+
path: `/api/studio/v1/audio/extract/${encodeURIComponent(input.apiSlug)}`,
|
|
42
|
+
file: input.file,
|
|
43
|
+
fields: {
|
|
44
|
+
...(input.language ? { language: input.language } : {}),
|
|
45
|
+
...(input.inputs ? { inputs: JSON.stringify(input.inputs) } : {}),
|
|
46
|
+
},
|
|
47
|
+
}),
|
|
48
|
+
};
|
|
49
|
+
async extract(input) {
|
|
50
|
+
return this.requestJson("POST", `/api/studio/v1/extract/${encodeURIComponent(input.apiSlug)}`, {
|
|
51
|
+
text: input.text,
|
|
52
|
+
inputs: input.inputs,
|
|
53
|
+
includeInsights: input.includeInsights,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async summarize(input) {
|
|
57
|
+
return this.requestJson("POST", "/api/studio/v1/summarize", input);
|
|
58
|
+
}
|
|
59
|
+
async insights(input) {
|
|
60
|
+
return this.requestJson("POST", `/api/studio/v1/insights/${encodeURIComponent(input.apiSlug)}`, {
|
|
61
|
+
transcript: input.transcript,
|
|
62
|
+
priorNoteSummary: input.priorNoteSummary,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
// ─── HTTP plumbing ───────────────────────────────────────────────────────
|
|
66
|
+
async requestJson(method, path, body) {
|
|
67
|
+
return this.requestRaw(method, path, {
|
|
68
|
+
headers: { "Content-Type": "application/json" },
|
|
69
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
async requestRaw(method, path, init) {
|
|
73
|
+
const url = `${this.baseUrl}${path}`;
|
|
74
|
+
const headers = new Headers(init.headers || {});
|
|
75
|
+
if (this.apiKey)
|
|
76
|
+
headers.set("Authorization", `Bearer ${this.apiKey}`);
|
|
77
|
+
else if (this.jwt)
|
|
78
|
+
headers.set("Authorization", `Bearer ${this.jwt}`);
|
|
79
|
+
if (!headers.has("X-OHM-Client")) {
|
|
80
|
+
headers.set("X-OHM-Client", "@ohm_studio/sdk@0.1.0");
|
|
81
|
+
}
|
|
82
|
+
let lastError;
|
|
83
|
+
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
84
|
+
const ac = new AbortController();
|
|
85
|
+
const t = setTimeout(() => ac.abort(), this.timeoutMs);
|
|
86
|
+
const tStart = Date.now();
|
|
87
|
+
try {
|
|
88
|
+
const res = await this.fetchImpl(url, {
|
|
89
|
+
...init,
|
|
90
|
+
method,
|
|
91
|
+
headers,
|
|
92
|
+
signal: ac.signal,
|
|
93
|
+
});
|
|
94
|
+
const latencyMs = Date.now() - tStart;
|
|
95
|
+
this.onUsage?.({
|
|
96
|
+
endpoint: path,
|
|
97
|
+
method,
|
|
98
|
+
ok: res.ok,
|
|
99
|
+
status: res.status,
|
|
100
|
+
latencyMs,
|
|
101
|
+
retries: attempt,
|
|
102
|
+
});
|
|
103
|
+
if (res.ok) {
|
|
104
|
+
// 204 no-content tolerance
|
|
105
|
+
if (res.status === 204)
|
|
106
|
+
return undefined;
|
|
107
|
+
return (await res.json());
|
|
108
|
+
}
|
|
109
|
+
if (isRetriableStatus(res.status) && attempt < this.maxRetries) {
|
|
110
|
+
await sleep(backoffMs(attempt));
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
throw await this.parseError(res);
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
clearTimeout(t);
|
|
117
|
+
if (err instanceof OHMError)
|
|
118
|
+
throw err;
|
|
119
|
+
lastError = err;
|
|
120
|
+
if (attempt < this.maxRetries) {
|
|
121
|
+
await sleep(backoffMs(attempt));
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
finally {
|
|
126
|
+
clearTimeout(t);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (lastError instanceof OHMError)
|
|
130
|
+
throw lastError;
|
|
131
|
+
throw new OHMServerError({
|
|
132
|
+
message: lastError?.message || "Request failed after retries",
|
|
133
|
+
status: 0,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
async parseError(res) {
|
|
137
|
+
let body = {};
|
|
138
|
+
try {
|
|
139
|
+
body = await res.json();
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
// body wasn't JSON; that's fine for the error path
|
|
143
|
+
}
|
|
144
|
+
const requestId = res.headers.get("x-request-id") || res.headers.get("x-ohm-request-id") || undefined;
|
|
145
|
+
const message = body?.message || `HTTP ${res.status}`;
|
|
146
|
+
if (res.status === 401 || res.status === 403) {
|
|
147
|
+
return new OHMAuthError({ message, status: res.status, requestId });
|
|
148
|
+
}
|
|
149
|
+
if (res.status === 422 || res.status === 400) {
|
|
150
|
+
return new OHMValidationError({
|
|
151
|
+
message,
|
|
152
|
+
status: res.status,
|
|
153
|
+
requestId,
|
|
154
|
+
fields: body?.fields,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
if (res.status === 429) {
|
|
158
|
+
return new OHMRateLimitError({
|
|
159
|
+
message,
|
|
160
|
+
status: res.status,
|
|
161
|
+
requestId,
|
|
162
|
+
retryAfterSec: Number(res.headers.get("retry-after")) ||
|
|
163
|
+
body?.retryAfterSec ||
|
|
164
|
+
undefined,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
return new OHMServerError({ message, status: res.status, requestId });
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function sleep(ms) {
|
|
171
|
+
return new Promise((r) => setTimeout(r, ms));
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAgBvD,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAClD,MAAM,kBAA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AC3B,OAAO;gBACP,MAAM,EAAE,GAAG,CAAC,MAAM;gBAClB,SAAS;gBACT,aAAa,EACX,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;oBACtC,IAAI,EAAE,aAAa;oBACnB,SAAS;aACZ,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,cAAc,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IACxE,CAAC;CACF;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAO,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AACrD,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hierarchy chosen so customers can pattern-match by class:
|
|
3
|
+
*
|
|
4
|
+
* try { await ohm.extract(...) }
|
|
5
|
+
* catch (e) {
|
|
6
|
+
* if (e instanceof OHMRateLimitError) ...
|
|
7
|
+
* if (e instanceof OHMAuthError) ...
|
|
8
|
+
* }
|
|
9
|
+
*
|
|
10
|
+
* Every error carries a stable `code`, the HTTP status, the request id (for
|
|
11
|
+
* audit-log lookups), and a human message. Validation errors include the
|
|
12
|
+
* failing field paths.
|
|
13
|
+
*/
|
|
14
|
+
export declare class OHMError extends Error {
|
|
15
|
+
readonly code: string;
|
|
16
|
+
readonly status: number;
|
|
17
|
+
readonly requestId?: string;
|
|
18
|
+
constructor(opts: {
|
|
19
|
+
code: string;
|
|
20
|
+
message: string;
|
|
21
|
+
status: number;
|
|
22
|
+
requestId?: string;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export declare class OHMAuthError extends OHMError {
|
|
26
|
+
constructor(opts: {
|
|
27
|
+
message: string;
|
|
28
|
+
status: number;
|
|
29
|
+
requestId?: string;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export declare class OHMRateLimitError extends OHMError {
|
|
33
|
+
readonly retryAfterSec?: number;
|
|
34
|
+
constructor(opts: {
|
|
35
|
+
message: string;
|
|
36
|
+
status: number;
|
|
37
|
+
requestId?: string;
|
|
38
|
+
retryAfterSec?: number;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export declare class OHMValidationError extends OHMError {
|
|
42
|
+
readonly fields?: string[];
|
|
43
|
+
constructor(opts: {
|
|
44
|
+
message: string;
|
|
45
|
+
status: number;
|
|
46
|
+
requestId?: string;
|
|
47
|
+
fields?: string[];
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export declare class OHMServerError extends OHMError {
|
|
51
|
+
constructor(opts: {
|
|
52
|
+
message: string;
|
|
53
|
+
status: number;
|
|
54
|
+
requestId?: string;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export declare class OHMConfigError extends OHMError {
|
|
58
|
+
constructor(opts: {
|
|
59
|
+
message: string;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;gBAChB,IAAI,EAAE;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB;CAOF;AAED,qBAAa,YAAa,SAAQ,QAAQ;gBAC5B,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;CAI1E;AAED,qBAAa,iBAAkB,SAAQ,QAAQ;IAC7C,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;gBACpB,IAAI,EAAE;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB;CAKF;AAED,qBAAa,kBAAmB,SAAQ,QAAQ;IAC9C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;gBACf,IAAI,EAAE;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;KACnB;CAKF;AAED,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;CAI1E;AAED,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE;CAItC"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hierarchy chosen so customers can pattern-match by class:
|
|
3
|
+
*
|
|
4
|
+
* try { await ohm.extract(...) }
|
|
5
|
+
* catch (e) {
|
|
6
|
+
* if (e instanceof OHMRateLimitError) ...
|
|
7
|
+
* if (e instanceof OHMAuthError) ...
|
|
8
|
+
* }
|
|
9
|
+
*
|
|
10
|
+
* Every error carries a stable `code`, the HTTP status, the request id (for
|
|
11
|
+
* audit-log lookups), and a human message. Validation errors include the
|
|
12
|
+
* failing field paths.
|
|
13
|
+
*/
|
|
14
|
+
export class OHMError extends Error {
|
|
15
|
+
code;
|
|
16
|
+
status;
|
|
17
|
+
requestId;
|
|
18
|
+
constructor(opts) {
|
|
19
|
+
super(opts.message);
|
|
20
|
+
this.name = "OHMError";
|
|
21
|
+
this.code = opts.code;
|
|
22
|
+
this.status = opts.status;
|
|
23
|
+
this.requestId = opts.requestId;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export class OHMAuthError extends OHMError {
|
|
27
|
+
constructor(opts) {
|
|
28
|
+
super({ code: "auth_error", ...opts });
|
|
29
|
+
this.name = "OHMAuthError";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export class OHMRateLimitError extends OHMError {
|
|
33
|
+
retryAfterSec;
|
|
34
|
+
constructor(opts) {
|
|
35
|
+
super({ code: "rate_limited", ...opts });
|
|
36
|
+
this.name = "OHMRateLimitError";
|
|
37
|
+
this.retryAfterSec = opts.retryAfterSec;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export class OHMValidationError extends OHMError {
|
|
41
|
+
fields;
|
|
42
|
+
constructor(opts) {
|
|
43
|
+
super({ code: "validation_error", ...opts });
|
|
44
|
+
this.name = "OHMValidationError";
|
|
45
|
+
this.fields = opts.fields;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class OHMServerError extends OHMError {
|
|
49
|
+
constructor(opts) {
|
|
50
|
+
super({ code: "server_error", ...opts });
|
|
51
|
+
this.name = "OHMServerError";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export class OHMConfigError extends OHMError {
|
|
55
|
+
constructor(opts) {
|
|
56
|
+
super({ code: "config_error", message: opts.message, status: 0 });
|
|
57
|
+
this.name = "OHMConfigError";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;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GAAG,IAAI,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,QAAQ;IAC1C,YAAY,IAAyB;QACnC,KAAK,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;QAClE,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ohm_studio/sdk-core
|
|
3
|
+
*
|
|
4
|
+
* Shared core for the OHM Studio SDK. Imported by both @ohm_studio/sdk
|
|
5
|
+
* (web/Node + React) and @ohm_studio/sdk-react-native. Types and behaviour are
|
|
6
|
+
* identical across platforms — the only divergence is in how each wrapper
|
|
7
|
+
* adapts file uploads (Blob vs RN { uri, name, type }) and streaming
|
|
8
|
+
* (browser SSE vs react-native-sse).
|
|
9
|
+
*/
|
|
10
|
+
export * from "./types";
|
|
11
|
+
export * from "./errors";
|
|
12
|
+
export * from "./client";
|
|
13
|
+
export * from "./retry";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ohm_studio/sdk-core
|
|
3
|
+
*
|
|
4
|
+
* Shared core for the OHM Studio SDK. Imported by both @ohm_studio/sdk
|
|
5
|
+
* (web/Node + React) and @ohm_studio/sdk-react-native. Types and behaviour are
|
|
6
|
+
* identical across platforms — the only divergence is in how each wrapper
|
|
7
|
+
* adapts file uploads (Blob vs RN { uri, name, type }) and streaming
|
|
8
|
+
* (browser SSE vs react-native-sse).
|
|
9
|
+
*/
|
|
10
|
+
export * from "./types";
|
|
11
|
+
export * from "./errors";
|
|
12
|
+
export * from "./client";
|
|
13
|
+
export * from "./retry";
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
package/dist/retry.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGjD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAGzD"}
|
package/dist/retry.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Exponential backoff with full jitter, capped at 8 seconds. */
|
|
2
|
+
export function backoffMs(attempt) {
|
|
3
|
+
const base = Math.min(8000, 250 * Math.pow(2, attempt));
|
|
4
|
+
return Math.floor(Math.random() * base);
|
|
5
|
+
}
|
|
6
|
+
export function isRetriableStatus(status) {
|
|
7
|
+
// 408 = request timeout, 429 = rate-limited, 5xx = server-side.
|
|
8
|
+
return status === 408 || status === 429 || (status >= 500 && status < 600);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,MAAM,UAAU,SAAS,CAAC,OAAe;IACvC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IACxD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,gEAAgE;IAChE,OAAO,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG,CAAC,CAAC;AAC7E,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** Public option bag for the OHM client. */
|
|
2
|
+
export interface OHMClientOptions {
|
|
3
|
+
/** API key issued from the Studio Keys page. */
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
/** Alternate auth — JWT from a logged-in Studio user (for management endpoints). */
|
|
6
|
+
jwt?: string;
|
|
7
|
+
/** Base URL of the OHM API. Defaults to https://api.ohm.doctor */
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
/** Per-request timeout (default 60s). */
|
|
10
|
+
timeoutMs?: number;
|
|
11
|
+
/** Max automatic retries on retriable errors (default 2). */
|
|
12
|
+
maxRetries?: number;
|
|
13
|
+
/** Custom fetch — useful for tests, proxies, or RN polyfills. */
|
|
14
|
+
fetch?: typeof fetch;
|
|
15
|
+
/**
|
|
16
|
+
* Optional telemetry hook. Called on every request with timing info.
|
|
17
|
+
* Use this to plug into Sentry / Datadog / your own logger.
|
|
18
|
+
*/
|
|
19
|
+
onUsage?: (event: UsageEvent) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Required when initialising with a `ohms_live_*` key in a React Native
|
|
22
|
+
* runtime. Documented at docs.ohm.doctor/security/rn-key-handling.
|
|
23
|
+
*/
|
|
24
|
+
acknowledgeBundledKey?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface UsageEvent {
|
|
27
|
+
endpoint: string;
|
|
28
|
+
method: string;
|
|
29
|
+
ok: boolean;
|
|
30
|
+
status: number;
|
|
31
|
+
latencyMs: number;
|
|
32
|
+
retries: number;
|
|
33
|
+
}
|
|
34
|
+
export interface ExtractInput {
|
|
35
|
+
apiSlug: string;
|
|
36
|
+
text: string;
|
|
37
|
+
inputs?: Record<string, unknown>;
|
|
38
|
+
includeInsights?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface ExtractResult<T = Record<string, unknown>> {
|
|
41
|
+
data: T;
|
|
42
|
+
apiSlug: string;
|
|
43
|
+
version?: string;
|
|
44
|
+
insights?: unknown;
|
|
45
|
+
}
|
|
46
|
+
export interface AudioTranscribeInput {
|
|
47
|
+
/** Platform-specific file shape resolved by the wrapper. */
|
|
48
|
+
file: any;
|
|
49
|
+
language?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface AudioTranscribeResult {
|
|
52
|
+
transcript: string;
|
|
53
|
+
language?: string;
|
|
54
|
+
durationSec?: number;
|
|
55
|
+
}
|
|
56
|
+
export interface AudioExtractInput extends AudioTranscribeInput {
|
|
57
|
+
apiSlug: string;
|
|
58
|
+
inputs?: Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
export interface AudioExtractResult<T = Record<string, unknown>> extends AudioTranscribeResult {
|
|
61
|
+
data: T;
|
|
62
|
+
apiSlug: string;
|
|
63
|
+
}
|
|
64
|
+
export interface SummarizeInput {
|
|
65
|
+
text: string;
|
|
66
|
+
style: "patient" | "handover" | "executive" | "progress-note";
|
|
67
|
+
maxLines?: number;
|
|
68
|
+
language?: string;
|
|
69
|
+
}
|
|
70
|
+
export interface SummarizeResult {
|
|
71
|
+
summary: string;
|
|
72
|
+
}
|
|
73
|
+
export interface InsightsInput {
|
|
74
|
+
apiSlug: string;
|
|
75
|
+
transcript: string;
|
|
76
|
+
priorNoteSummary?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface InsightsResult<T = unknown> {
|
|
79
|
+
insights: T;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oFAAoF;IACpF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iEAAiE;IACjE,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACxD,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,MAAM,CA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|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ohm_studio/sdk-core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared core for @ohm/sdk and @ohm/sdk-react-native — http client, types, errors, retry, streaming. Use one of the platform wrappers instead of consuming this directly.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://docs.ohm.doctor",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/aivfkesavan/OHM_Products",
|
|
13
|
+
"directory": "packages/sdk-core"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"module": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"typescript": "^5.8.3"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc -p tsconfig.json",
|
|
33
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
34
|
+
}
|
|
35
|
+
}
|