@informedai/react 0.4.16 → 0.4.17
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/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +9 -4
- package/dist/index.mjs +9 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -82,6 +82,8 @@ interface InformedAssistantConfig {
|
|
|
82
82
|
documentTypeId: string;
|
|
83
83
|
/** API base URL (defaults to https://api.informedassistant.ai/api/v1) */
|
|
84
84
|
apiUrl?: string;
|
|
85
|
+
/** Pool access key (pak_*) for authentication */
|
|
86
|
+
accessKey?: string;
|
|
85
87
|
/**
|
|
86
88
|
* External ID for idempotency - your object's ID in your system.
|
|
87
89
|
* If provided, the widget will find or create a document linked to this ID.
|
|
@@ -347,7 +349,8 @@ interface ApplyResponse {
|
|
|
347
349
|
}
|
|
348
350
|
declare class InformedAIClient {
|
|
349
351
|
private apiUrl;
|
|
350
|
-
|
|
352
|
+
private accessKey?;
|
|
353
|
+
constructor(apiUrl?: string, accessKey?: string);
|
|
351
354
|
private getHeaders;
|
|
352
355
|
private request;
|
|
353
356
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -82,6 +82,8 @@ interface InformedAssistantConfig {
|
|
|
82
82
|
documentTypeId: string;
|
|
83
83
|
/** API base URL (defaults to https://api.informedassistant.ai/api/v1) */
|
|
84
84
|
apiUrl?: string;
|
|
85
|
+
/** Pool access key (pak_*) for authentication */
|
|
86
|
+
accessKey?: string;
|
|
85
87
|
/**
|
|
86
88
|
* External ID for idempotency - your object's ID in your system.
|
|
87
89
|
* If provided, the widget will find or create a document linked to this ID.
|
|
@@ -347,7 +349,8 @@ interface ApplyResponse {
|
|
|
347
349
|
}
|
|
348
350
|
declare class InformedAIClient {
|
|
349
351
|
private apiUrl;
|
|
350
|
-
|
|
352
|
+
private accessKey?;
|
|
353
|
+
constructor(apiUrl?: string, accessKey?: string);
|
|
351
354
|
private getHeaders;
|
|
352
355
|
private request;
|
|
353
356
|
/**
|
package/dist/index.js
CHANGED
|
@@ -40,13 +40,18 @@ var import_react_dom = require("react-dom");
|
|
|
40
40
|
// src/utils/api-client.ts
|
|
41
41
|
var DEFAULT_API_URL = "https://api.informedassistant.ai/api/v1";
|
|
42
42
|
var InformedAIClient = class {
|
|
43
|
-
constructor(apiUrl) {
|
|
43
|
+
constructor(apiUrl, accessKey) {
|
|
44
44
|
this.apiUrl = apiUrl || DEFAULT_API_URL;
|
|
45
|
+
this.accessKey = accessKey;
|
|
45
46
|
}
|
|
46
47
|
getHeaders() {
|
|
47
|
-
|
|
48
|
+
const headers = {
|
|
48
49
|
"Content-Type": "application/json"
|
|
49
50
|
};
|
|
51
|
+
if (this.accessKey) {
|
|
52
|
+
headers["Authorization"] = `Bearer ${this.accessKey}`;
|
|
53
|
+
}
|
|
54
|
+
return headers;
|
|
50
55
|
}
|
|
51
56
|
async request(endpoint, options = {}) {
|
|
52
57
|
const response = await fetch(`${this.apiUrl}${endpoint}`, {
|
|
@@ -304,8 +309,8 @@ function InformedAIProvider({ config, children }) {
|
|
|
304
309
|
const shouldPersist = config.persistSession ?? true;
|
|
305
310
|
const storageKey = getStorageKey(config.documentTypeId, config.externalId);
|
|
306
311
|
(0, import_react.useEffect)(() => {
|
|
307
|
-
clientRef.current = new InformedAIClient(config.apiUrl);
|
|
308
|
-
}, [config.apiUrl]);
|
|
312
|
+
clientRef.current = new InformedAIClient(config.apiUrl, config.accessKey);
|
|
313
|
+
}, [config.apiUrl, config.accessKey]);
|
|
309
314
|
const createNewSession = (0, import_react.useCallback)(async () => {
|
|
310
315
|
if (!clientRef.current) return null;
|
|
311
316
|
const result = await clientRef.current.createSession(
|
package/dist/index.mjs
CHANGED
|
@@ -8,13 +8,18 @@ import { flushSync } from "react-dom";
|
|
|
8
8
|
// src/utils/api-client.ts
|
|
9
9
|
var DEFAULT_API_URL = "https://api.informedassistant.ai/api/v1";
|
|
10
10
|
var InformedAIClient = class {
|
|
11
|
-
constructor(apiUrl) {
|
|
11
|
+
constructor(apiUrl, accessKey) {
|
|
12
12
|
this.apiUrl = apiUrl || DEFAULT_API_URL;
|
|
13
|
+
this.accessKey = accessKey;
|
|
13
14
|
}
|
|
14
15
|
getHeaders() {
|
|
15
|
-
|
|
16
|
+
const headers = {
|
|
16
17
|
"Content-Type": "application/json"
|
|
17
18
|
};
|
|
19
|
+
if (this.accessKey) {
|
|
20
|
+
headers["Authorization"] = `Bearer ${this.accessKey}`;
|
|
21
|
+
}
|
|
22
|
+
return headers;
|
|
18
23
|
}
|
|
19
24
|
async request(endpoint, options = {}) {
|
|
20
25
|
const response = await fetch(`${this.apiUrl}${endpoint}`, {
|
|
@@ -272,8 +277,8 @@ function InformedAIProvider({ config, children }) {
|
|
|
272
277
|
const shouldPersist = config.persistSession ?? true;
|
|
273
278
|
const storageKey = getStorageKey(config.documentTypeId, config.externalId);
|
|
274
279
|
useEffect(() => {
|
|
275
|
-
clientRef.current = new InformedAIClient(config.apiUrl);
|
|
276
|
-
}, [config.apiUrl]);
|
|
280
|
+
clientRef.current = new InformedAIClient(config.apiUrl, config.accessKey);
|
|
281
|
+
}, [config.apiUrl, config.accessKey]);
|
|
277
282
|
const createNewSession = useCallback(async () => {
|
|
278
283
|
if (!clientRef.current) return null;
|
|
279
284
|
const result = await clientRef.current.createSession(
|