samuel-integrations-sdk 0.0.17 → 0.0.18
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/http-client.d.ts +6 -0
- package/dist/http-client.d.ts.map +1 -1
- package/dist/http-client.js +22 -0
- package/dist/http-client.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/response-type-map.d.ts +19 -0
- package/dist/response-type-map.d.ts.map +1 -0
- package/dist/response-type-map.js +54 -0
- package/dist/response-type-map.js.map +1 -0
- package/package.json +1 -1
package/dist/http-client.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
/**
|
|
3
|
+
* Custom Axios wrapper that handles different response types based on OpenAPI spec
|
|
4
|
+
* - JSON: Returns data directly (backward compatible)
|
|
5
|
+
* - Stream: Returns full AxiosResponse with stream for piping
|
|
6
|
+
* - Binary: Returns full AxiosResponse with arraybuffer
|
|
7
|
+
*/
|
|
2
8
|
export declare const customAxios: <T>(config: AxiosRequestConfig) => Promise<T>;
|
|
3
9
|
//# sourceMappingURL=http-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../src/http-client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../src/http-client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAyBlD;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAU,CAAC,EACjC,QAAQ,kBAAkB,KACzB,OAAO,CAAC,CAAC,CAmBX,CAAC"}
|
package/dist/http-client.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.customAxios = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const response_type_map_1 = require("./response-type-map");
|
|
8
9
|
const axiosInstance = axios_1.default.create();
|
|
9
10
|
axiosInstance.interceptors.request.use(config => {
|
|
10
11
|
const baseURL = process.env['INTEGRATION_BASE_URL'];
|
|
@@ -22,7 +23,28 @@ axiosInstance.interceptors.request.use(config => {
|
|
|
22
23
|
}
|
|
23
24
|
return config;
|
|
24
25
|
});
|
|
26
|
+
/**
|
|
27
|
+
* Custom Axios wrapper that handles different response types based on OpenAPI spec
|
|
28
|
+
* - JSON: Returns data directly (backward compatible)
|
|
29
|
+
* - Stream: Returns full AxiosResponse with stream for piping
|
|
30
|
+
* - Binary: Returns full AxiosResponse with arraybuffer
|
|
31
|
+
*/
|
|
25
32
|
const customAxios = async (config) => {
|
|
33
|
+
// Detect response type from OpenAPI spec via response-type-map
|
|
34
|
+
const responseType = (0, response_type_map_1.getResponseTypeFromUrl)(config.url || '');
|
|
35
|
+
if (responseType === 'stream') {
|
|
36
|
+
// For streaming (SSE): return full response so headers and stream are accessible
|
|
37
|
+
config.responseType = 'stream';
|
|
38
|
+
const response = await axiosInstance(config);
|
|
39
|
+
return response; // Return full AxiosResponse for piping
|
|
40
|
+
}
|
|
41
|
+
else if (responseType === 'arraybuffer') {
|
|
42
|
+
// For binary data (audio, video, images): return full response for headers and arraybuffer
|
|
43
|
+
config.responseType = 'arraybuffer';
|
|
44
|
+
const response = await axiosInstance(config);
|
|
45
|
+
return response; // Return full AxiosResponse
|
|
46
|
+
}
|
|
47
|
+
// For JSON: just return data (existing behavior, backward compatible)
|
|
26
48
|
const { data } = await axiosInstance(config);
|
|
27
49
|
return data;
|
|
28
50
|
};
|
package/dist/http-client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-client.js","sourceRoot":"","sources":["../src/http-client.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OAAO,QAAe,CAAC,CAAC,uCAAuC;IACjE,CAAC;SAAM,IAAI,YAAY,KAAK,aAAa,EAAE,CAAC;QAC1C,2FAA2F;QAC3F,MAAM,CAAC,YAAY,GAAG,aAAa,CAAC;QACpC,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC;QAC7C,OAAO,QAAe,CAAC,CAAC,4BAA4B;IACtD,CAAC;IAED,sEAAsE;IACtE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC;IAC7C,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AArBW,QAAA,WAAW,eAqBtB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CreateStreamBody, GenerateText200, GenerateTextBody, GenerateTextBodyProvider, GetAuthorizationUrl200, GetAuthorizationUrlBody, GetAuthorizationUrlBodyProvider, HandleOAuthCallback200, HandleOAuthCallbackBody } from './generated-api';
|
|
2
|
+
import { AxiosResponse } from 'axios';
|
|
2
3
|
/**
|
|
3
4
|
* UPTIQ Integrations SDK
|
|
4
5
|
*
|
|
@@ -20,7 +21,7 @@ export declare class Llm {
|
|
|
20
21
|
/** Chat with LLM */
|
|
21
22
|
generateText(body: Omit<GenerateTextBody, 'provider'>): Promise<GenerateText200>;
|
|
22
23
|
/** Stream text generation from LLM */
|
|
23
|
-
createStream(body: Omit<CreateStreamBody, 'provider'>): Promise<
|
|
24
|
+
createStream(body: Omit<CreateStreamBody, 'provider'>): Promise<AxiosResponse>;
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* OAuth integration module
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,u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GD,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mDAAuQ;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mDAAuQ;AAGvQ;;;;;GAKG;AAEH;;GAEG;AACH,MAAa,GAAG;IAMd,YAAY,OAEX;QACC,iCAAiC;QACjC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;QACtB,gCAAgC;QAChC,IAAI,CAAC,GAAG,GAAG,IAAA,kCAAkB,GAAE,CAAC;IAClC,CAAC;IAGD,gCAAgC;IAChC,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAGD,oBAAoB;IACpB,YAAY,CAAC,IAAwC;QACnD,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,EAAsB,CAAC,CAAC;IAChF,CAAC;IAGD,sCAAsC;IACtC,YAAY,CAAC,IAAwC;QACnD,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,EAAsB,CAAsC,CAAC;IACrH,CAAC;CACF;AAhCD,kBAgCC;AAED;;GAEG;AACH,MAAa,KAAK;IAMhB,YAAY,OAEX;QACC,iCAAiC;QACjC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;QACtB,gCAAgC;QAChC,IAAI,CAAC,GAAG,GAAG,IAAA,kCAAkB,GAAE,CAAC;IAClC,CAAC;IAGD,gCAAgC;IAChC,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAGD,kCAAkC;IAClC,mBAAmB,CAAC,IAA+C;QACjE,OAAO,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,EAA6B,CAAC,CAAC;IAC9F,CAAC;IAGD,4BAA4B;IAC5B,mBAAmB,CAAC,IAA+C;QACjE,OAAO,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,EAA6B,CAAC,CAAC;IAC9F,CAAC;CACF;AAhCD,sBAgCC;AAED,yCAAyC;AACzC,kDAAgC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Response Type Mapping
|
|
3
|
+
*
|
|
4
|
+
* Auto-generated from OpenAPI specification.
|
|
5
|
+
* Maps operation IDs to their expected Axios response types.
|
|
6
|
+
*
|
|
7
|
+
* DO NOT EDIT - regenerated on each build.
|
|
8
|
+
*/
|
|
9
|
+
export declare const RESPONSE_TYPE_MAP: Record<string, 'json' | 'stream' | 'arraybuffer'>;
|
|
10
|
+
export declare const OPERATION_PATHS: Record<string, string>;
|
|
11
|
+
/**
|
|
12
|
+
* Get the response type for a given operation ID
|
|
13
|
+
*/
|
|
14
|
+
export declare function getResponseType(operationId: string): 'json' | 'stream' | 'arraybuffer';
|
|
15
|
+
/**
|
|
16
|
+
* Get response type from URL by matching against operation paths
|
|
17
|
+
*/
|
|
18
|
+
export declare function getResponseTypeFromUrl(url: string): 'json' | 'stream' | 'arraybuffer';
|
|
19
|
+
//# sourceMappingURL=response-type-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-type-map.d.ts","sourceRoot":"","sources":["../src/response-type-map.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,aAAa,CAK/E,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKlD,CAAC;AAEF;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,aAAa,CAEtF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,aAAa,CAsBrF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Response Type Mapping
|
|
4
|
+
*
|
|
5
|
+
* Auto-generated from OpenAPI specification.
|
|
6
|
+
* Maps operation IDs to their expected Axios response types.
|
|
7
|
+
*
|
|
8
|
+
* DO NOT EDIT - regenerated on each build.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.OPERATION_PATHS = exports.RESPONSE_TYPE_MAP = void 0;
|
|
12
|
+
exports.getResponseType = getResponseType;
|
|
13
|
+
exports.getResponseTypeFromUrl = getResponseTypeFromUrl;
|
|
14
|
+
exports.RESPONSE_TYPE_MAP = {
|
|
15
|
+
"generateText": "json",
|
|
16
|
+
"createStream": "stream",
|
|
17
|
+
"getAuthorizationUrl": "json",
|
|
18
|
+
"handleOAuthCallback": "json"
|
|
19
|
+
};
|
|
20
|
+
exports.OPERATION_PATHS = {
|
|
21
|
+
"generateText": "/llm/generateText",
|
|
22
|
+
"createStream": "/llm/createStream",
|
|
23
|
+
"getAuthorizationUrl": "/oauth/getAuthorizationUrl",
|
|
24
|
+
"handleOAuthCallback": "/oauth/handleOAuthCallback"
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Get the response type for a given operation ID
|
|
28
|
+
*/
|
|
29
|
+
function getResponseType(operationId) {
|
|
30
|
+
return exports.RESPONSE_TYPE_MAP[operationId] || 'json';
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get response type from URL by matching against operation paths
|
|
34
|
+
*/
|
|
35
|
+
function getResponseTypeFromUrl(url) {
|
|
36
|
+
// Clean URL (handle empty or undefined)
|
|
37
|
+
if (!url)
|
|
38
|
+
return 'json';
|
|
39
|
+
const cleanUrl = url.split('?')[0];
|
|
40
|
+
// Try to match by operationId in URL
|
|
41
|
+
for (const [opId, responseType] of Object.entries(exports.RESPONSE_TYPE_MAP)) {
|
|
42
|
+
const opPath = exports.OPERATION_PATHS[opId];
|
|
43
|
+
// Check if URL contains the operation path
|
|
44
|
+
if (opPath && cleanUrl && cleanUrl.includes(opPath)) {
|
|
45
|
+
return responseType;
|
|
46
|
+
}
|
|
47
|
+
// Fallback: check if operationId is in URL
|
|
48
|
+
if (cleanUrl && cleanUrl.includes(opId)) {
|
|
49
|
+
return responseType;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return 'json'; // default fallback
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=response-type-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-type-map.js","sourceRoot":"","sources":["../src/response-type-map.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAmBH,0CAEC;AAKD,wDAsBC;AA9CY,QAAA,iBAAiB,GAAsD;IAClF,cAAc,EAAE,MAAM;IACtB,cAAc,EAAE,QAAQ;IACxB,qBAAqB,EAAE,MAAM;IAC7B,qBAAqB,EAAE,MAAM;CAC9B,CAAC;AAEW,QAAA,eAAe,GAA2B;IACrD,cAAc,EAAE,mBAAmB;IACnC,cAAc,EAAE,mBAAmB;IACnC,qBAAqB,EAAE,4BAA4B;IACnD,qBAAqB,EAAE,4BAA4B;CACpD,CAAC;AAEF;;GAEG;AACH,SAAgB,eAAe,CAAC,WAAmB;IACjD,OAAO,yBAAiB,CAAC,WAAW,CAAC,IAAI,MAAM,CAAC;AAClD,CAAC;AAED;;GAEG;AACH,SAAgB,sBAAsB,CAAC,GAAW;IAChD,wCAAwC;IACxC,IAAI,CAAC,GAAG;QAAE,OAAO,MAAM,CAAC;IAExB,MAAM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