@intuned/browser-dev 0.1.12-dev.0 → 0.1.14-dev.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/helpers/export.d.ts +5 -5
- package/dist/helpers/index.d.ts +5 -5
- package/dist/helpers/tests/testInjectAttachmentType.spec.js +5 -3
- package/dist/intunedServices/ApiGateway/aiApiGateway.js +14 -4
- package/dist/intunedServices/ApiGateway/tests/testApiGateway.spec.js +9 -9
- package/package.json +1 -1
package/dist/helpers/export.d.ts
CHANGED
|
@@ -104,7 +104,7 @@ export declare function sanitizeHtml(options: SanitizeHtmlOptions): string;
|
|
|
104
104
|
* page,
|
|
105
105
|
* trigger: "https://intuned-docs-public-images.s3.amazonaws.com/32UP83A_ENG_US.pdf"
|
|
106
106
|
* });
|
|
107
|
-
* file_name = download.suggestedFilename();
|
|
107
|
+
* const file_name = download.suggestedFilename();
|
|
108
108
|
* return file_name;
|
|
109
109
|
*
|
|
110
110
|
* }
|
|
@@ -123,7 +123,7 @@ export declare function sanitizeHtml(options: SanitizeHtmlOptions): string;
|
|
|
123
123
|
* page,
|
|
124
124
|
* trigger: page.locator("xpath=//tbody/tr[1]//*[name()='svg']")
|
|
125
125
|
* });
|
|
126
|
-
* file_name = download.suggestedFilename();
|
|
126
|
+
* const file_name = download.suggestedFilename();
|
|
127
127
|
* return file_name;
|
|
128
128
|
* }
|
|
129
129
|
* ```
|
|
@@ -143,7 +143,7 @@ export declare function sanitizeHtml(options: SanitizeHtmlOptions): string;
|
|
|
143
143
|
* await page.locator("xpath=//tbody/tr[1]//*[name()='svg']").click();
|
|
144
144
|
* }
|
|
145
145
|
* });
|
|
146
|
-
* file_name = download.suggestedFilename();
|
|
146
|
+
* const file_name = download.suggestedFilename();
|
|
147
147
|
* return file_name;
|
|
148
148
|
* }
|
|
149
149
|
* ```
|
|
@@ -752,7 +752,7 @@ export declare function withNetworkSettledWait<T>(
|
|
|
752
752
|
page: Page;
|
|
753
753
|
timeoutInMs?: number;
|
|
754
754
|
maxInflightRequests?: number;
|
|
755
|
-
}
|
|
755
|
+
},
|
|
756
756
|
): Promise<T>;
|
|
757
757
|
|
|
758
758
|
/**
|
|
@@ -1292,7 +1292,7 @@ export type FileType = Download | Uint8Array | Buffer | ReadStream;
|
|
|
1292
1292
|
* export default async function handler(params: Params, page: Page, context: BrowserContext){
|
|
1293
1293
|
* const uploadedFile = await saveFileToS3({
|
|
1294
1294
|
* page,
|
|
1295
|
-
* trigger: "https://
|
|
1295
|
+
* trigger: "https://intuned-docs-public-images.s3.amazonaws.com/27UP600_27UP650_ENG_US.pdf",
|
|
1296
1296
|
* configs: {
|
|
1297
1297
|
* bucket: 'document-storage',
|
|
1298
1298
|
* region: 'us-east-1',
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -104,7 +104,7 @@ export declare function sanitizeHtml(options: SanitizeHtmlOptions): string;
|
|
|
104
104
|
* page,
|
|
105
105
|
* trigger: "https://intuned-docs-public-images.s3.amazonaws.com/32UP83A_ENG_US.pdf"
|
|
106
106
|
* });
|
|
107
|
-
* file_name = download.suggestedFilename();
|
|
107
|
+
* const file_name = download.suggestedFilename();
|
|
108
108
|
* return file_name;
|
|
109
109
|
*
|
|
110
110
|
* }
|
|
@@ -123,7 +123,7 @@ export declare function sanitizeHtml(options: SanitizeHtmlOptions): string;
|
|
|
123
123
|
* page,
|
|
124
124
|
* trigger: page.locator("xpath=//tbody/tr[1]//*[name()='svg']")
|
|
125
125
|
* });
|
|
126
|
-
* file_name = download.suggestedFilename();
|
|
126
|
+
* const file_name = download.suggestedFilename();
|
|
127
127
|
* return file_name;
|
|
128
128
|
* }
|
|
129
129
|
* ```
|
|
@@ -143,7 +143,7 @@ export declare function sanitizeHtml(options: SanitizeHtmlOptions): string;
|
|
|
143
143
|
* await page.locator("xpath=//tbody/tr[1]//*[name()='svg']").click();
|
|
144
144
|
* }
|
|
145
145
|
* });
|
|
146
|
-
* file_name = download.suggestedFilename();
|
|
146
|
+
* const file_name = download.suggestedFilename();
|
|
147
147
|
* return file_name;
|
|
148
148
|
* }
|
|
149
149
|
* ```
|
|
@@ -752,7 +752,7 @@ export declare function withNetworkSettledWait<T>(
|
|
|
752
752
|
page: Page;
|
|
753
753
|
timeoutInMs?: number;
|
|
754
754
|
maxInflightRequests?: number;
|
|
755
|
-
}
|
|
755
|
+
},
|
|
756
756
|
): Promise<T>;
|
|
757
757
|
|
|
758
758
|
/**
|
|
@@ -1292,7 +1292,7 @@ export type FileType = Download | Uint8Array | Buffer | ReadStream;
|
|
|
1292
1292
|
* export default async function handler(params: Params, page: Page, context: BrowserContext){
|
|
1293
1293
|
* const uploadedFile = await saveFileToS3({
|
|
1294
1294
|
* page,
|
|
1295
|
-
* trigger: "https://
|
|
1295
|
+
* trigger: "https://intuned-docs-public-images.s3.amazonaws.com/27UP600_27UP650_ENG_US.pdf",
|
|
1296
1296
|
* configs: {
|
|
1297
1297
|
* bucket: 'document-storage',
|
|
1298
1298
|
* region: 'us-east-1',
|
|
@@ -477,13 +477,15 @@ var _validateDataUsingSchema = require("../validateDataUsingSchema");
|
|
|
477
477
|
(0, _extendedTest.expect)(attachmentProps.suggestedFileName).toBeDefined();
|
|
478
478
|
(0, _extendedTest.expect)(baseSchema.required).toBeDefined();
|
|
479
479
|
(0, _extendedTest.expect)(baseSchema.required).toContain("fileName");
|
|
480
|
-
(0, _extendedTest.expect)(baseSchema.required).toContain("bucket");
|
|
481
|
-
(0, _extendedTest.expect)(baseSchema.required).toContain("region");
|
|
480
|
+
(0, _extendedTest.expect)(baseSchema.required).not.toContain("bucket");
|
|
481
|
+
(0, _extendedTest.expect)(baseSchema.required).not.toContain("region");
|
|
482
482
|
(0, _extendedTest.expect)(baseSchema.required).toContain("key");
|
|
483
483
|
(0, _extendedTest.expect)(baseSchema.required).toContain("suggestedFileName");
|
|
484
|
+
(0, _extendedTest.expect)(attachmentProps.bucket).toBeDefined();
|
|
485
|
+
(0, _extendedTest.expect)(attachmentProps.region).toBeDefined();
|
|
484
486
|
const signedUrlSchema = result.$defs.attachment.anyOf[0];
|
|
485
487
|
(0, _extendedTest.expect)(signedUrlSchema.type).toBe("object");
|
|
486
|
-
(0, _extendedTest.expect)(signedUrlSchema.properties.
|
|
488
|
+
(0, _extendedTest.expect)(signedUrlSchema.properties.signedUrl).toBeDefined();
|
|
487
489
|
});
|
|
488
490
|
});
|
|
489
491
|
});
|
|
@@ -10,6 +10,8 @@ var _OpenAI = require("./providers/OpenAI");
|
|
|
10
10
|
var _Gemini = require("./providers/Gemini");
|
|
11
11
|
var _dotenv = require("dotenv");
|
|
12
12
|
var _loadRuntime = require("../../common/loadRuntime");
|
|
13
|
+
var _jwtTokenManager = require("../../common/jwtTokenManager");
|
|
14
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
15
|
(0, _dotenv.config)();
|
|
14
16
|
class APIGateway {
|
|
15
17
|
useGateway = false;
|
|
@@ -39,6 +41,15 @@ class APIGateway {
|
|
|
39
41
|
this.config = this.getDefaultConfig();
|
|
40
42
|
this.validateGatewayConfig(this.config);
|
|
41
43
|
this.useGateway = true;
|
|
44
|
+
try {
|
|
45
|
+
const runtime = await Promise.resolve().then(() => _interopRequireWildcard(require("@intuned/runtime")));
|
|
46
|
+
const {
|
|
47
|
+
apiKey
|
|
48
|
+
} = runtime.getAiGatewayConfig();
|
|
49
|
+
if (apiKey) {
|
|
50
|
+
_jwtTokenManager.backendFunctionsTokenManager.token = apiKey;
|
|
51
|
+
}
|
|
52
|
+
} catch {}
|
|
42
53
|
this.isInitialized = true;
|
|
43
54
|
}
|
|
44
55
|
getApiKeyFromEnv(provider) {
|
|
@@ -88,16 +99,15 @@ class APIGateway {
|
|
|
88
99
|
const modelLower = model.toLowerCase();
|
|
89
100
|
return (0, _getModelProvider.getModelProvider)(modelLower);
|
|
90
101
|
}
|
|
91
|
-
buildGatewayUrl(
|
|
102
|
+
buildGatewayUrl() {
|
|
92
103
|
var _this$config$function;
|
|
93
104
|
if (!this.config) {
|
|
94
105
|
throw new Error("Gateway configuration not initialized");
|
|
95
106
|
}
|
|
96
107
|
const baseDomain = (_this$config$function = this.config.functionsDomain) === null || _this$config$function === void 0 ? void 0 : _this$config$function.replace(/\/$/, "");
|
|
97
|
-
return `${baseDomain}/api/${this.config.workspaceId}/functions/${this.config.integrationId}
|
|
108
|
+
return `${baseDomain}/api/${this.config.workspaceId}/functions/${this.config.integrationId}/intuned-ai-gateway`;
|
|
98
109
|
}
|
|
99
110
|
getModelConfig(extraHeaders) {
|
|
100
|
-
const provider = this.detectProvider(this.model);
|
|
101
111
|
if (!this.useGateway && this.apiKey) {
|
|
102
112
|
return {
|
|
103
113
|
model: this.model,
|
|
@@ -106,7 +116,7 @@ class APIGateway {
|
|
|
106
116
|
baseUrl: undefined
|
|
107
117
|
};
|
|
108
118
|
}
|
|
109
|
-
const baseUrl = this.buildGatewayUrl(
|
|
119
|
+
const baseUrl = this.buildGatewayUrl();
|
|
110
120
|
return {
|
|
111
121
|
model: this.model,
|
|
112
122
|
apiKey: "--THIS_VALUE_WILL_BE_REPLACED_BY_INTUNED_BE--",
|
|
@@ -118,8 +118,8 @@ const mockLoadRuntime = _vitest.vi.mocked(_loadRuntime.loadRuntime);
|
|
|
118
118
|
model: "claude-3-sonnet"
|
|
119
119
|
});
|
|
120
120
|
await gateway["ensureInitialized"]();
|
|
121
|
-
const result = gateway["buildGatewayUrl"](
|
|
122
|
-
(0, _extendedTest.expect)(result).toBe("https://functions.example.com/api/workspace123/functions/integration456/
|
|
121
|
+
const result = gateway["buildGatewayUrl"]();
|
|
122
|
+
(0, _extendedTest.expect)(result).toBe("https://functions.example.com/api/workspace123/functions/integration456/intuned-ai-gateway");
|
|
123
123
|
});
|
|
124
124
|
(0, _extendedTest.it)("should build correct URL for google_vertexai", async () => {
|
|
125
125
|
mockGetModelProvider.mockReturnValue("google_vertexai");
|
|
@@ -130,8 +130,8 @@ const mockLoadRuntime = _vitest.vi.mocked(_loadRuntime.loadRuntime);
|
|
|
130
130
|
model: "gemini-pro"
|
|
131
131
|
});
|
|
132
132
|
await gateway["ensureInitialized"]();
|
|
133
|
-
const result = gateway["buildGatewayUrl"](
|
|
134
|
-
(0, _extendedTest.expect)(result).toBe("https://functions.example.com/api/workspace123/functions/integration456/
|
|
133
|
+
const result = gateway["buildGatewayUrl"]();
|
|
134
|
+
(0, _extendedTest.expect)(result).toBe("https://functions.example.com/api/workspace123/functions/integration456/intuned-ai-gateway");
|
|
135
135
|
});
|
|
136
136
|
(0, _extendedTest.it)("should build correct URL for other providers", async () => {
|
|
137
137
|
mockGetModelProvider.mockReturnValue("openai");
|
|
@@ -142,8 +142,8 @@ const mockLoadRuntime = _vitest.vi.mocked(_loadRuntime.loadRuntime);
|
|
|
142
142
|
model: "gpt-4"
|
|
143
143
|
});
|
|
144
144
|
await gateway["ensureInitialized"]();
|
|
145
|
-
const result = gateway["buildGatewayUrl"](
|
|
146
|
-
(0, _extendedTest.expect)(result).toBe("https://functions.example.com/api/workspace123/functions/integration456/
|
|
145
|
+
const result = gateway["buildGatewayUrl"]();
|
|
146
|
+
(0, _extendedTest.expect)(result).toBe("https://functions.example.com/api/workspace123/functions/integration456/intuned-ai-gateway");
|
|
147
147
|
});
|
|
148
148
|
(0, _extendedTest.it)("should strip trailing slash from domain", async () => {
|
|
149
149
|
process.env.FUNCTIONS_DOMAIN = "https://functions.example.com/";
|
|
@@ -155,8 +155,8 @@ const mockLoadRuntime = _vitest.vi.mocked(_loadRuntime.loadRuntime);
|
|
|
155
155
|
model: "gpt-4"
|
|
156
156
|
});
|
|
157
157
|
await newGateway["ensureInitialized"]();
|
|
158
|
-
const result = newGateway["buildGatewayUrl"](
|
|
159
|
-
(0, _extendedTest.expect)(result).toBe("https://functions.example.com/api/workspace123/functions/integration456/
|
|
158
|
+
const result = newGateway["buildGatewayUrl"]();
|
|
159
|
+
(0, _extendedTest.expect)(result).toBe("https://functions.example.com/api/workspace123/functions/integration456/intuned-ai-gateway");
|
|
160
160
|
});
|
|
161
161
|
});
|
|
162
162
|
(0, _extendedTest.describe)("ensureInitialized", () => {
|
|
@@ -236,7 +236,7 @@ const mockLoadRuntime = _vitest.vi.mocked(_loadRuntime.loadRuntime);
|
|
|
236
236
|
apiKey: "--THIS_VALUE_WILL_BE_REPLACED_BY_INTUNED_BE--",
|
|
237
237
|
headers: undefined,
|
|
238
238
|
model: "claude-3-sonnet",
|
|
239
|
-
baseUrl: "https://functions.example.com/api/workspace123/functions/integration456/
|
|
239
|
+
baseUrl: "https://functions.example.com/api/workspace123/functions/integration456/intuned-ai-gateway"
|
|
240
240
|
});
|
|
241
241
|
(0, _extendedTest.expect)(result).toBe(mockInstance);
|
|
242
242
|
});
|