mitra-interactions-sdk 1.0.64 → 1.0.66
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 +769 -698
- package/dist/index.d.mts +103 -1
- package/dist/index.d.ts +103 -1
- package/dist/index.js +109 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +106 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +52 -52
package/dist/index.mjs
CHANGED
|
@@ -484,6 +484,34 @@ var http = {
|
|
|
484
484
|
headers,
|
|
485
485
|
body: formData
|
|
486
486
|
});
|
|
487
|
+
},
|
|
488
|
+
// Download binário (Blob). Usado para baixar arquivos privados com credencial,
|
|
489
|
+
// já que a resposta não é JSON. Mesma lógica de refresh-on-403 do fetchWithRefresh.
|
|
490
|
+
async download(endpoint, params) {
|
|
491
|
+
const fetchFn = getFetch2();
|
|
492
|
+
const url = buildUrl(endpoint, params);
|
|
493
|
+
let response = await fetchFn(url, { method: "GET", headers: buildHeaders() });
|
|
494
|
+
if (response.status === 403) {
|
|
495
|
+
const refreshed = await tryRefreshToken();
|
|
496
|
+
if (refreshed) {
|
|
497
|
+
response = await fetchFn(url, { method: "GET", headers: buildHeaders() });
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
if (!response.ok) {
|
|
501
|
+
const text = await response.text();
|
|
502
|
+
let data = null;
|
|
503
|
+
try {
|
|
504
|
+
data = text ? JSON.parse(text) : null;
|
|
505
|
+
} catch (e) {
|
|
506
|
+
}
|
|
507
|
+
const base = (data == null ? void 0 : data.message) || (data == null ? void 0 : data.error) || `HTTP ${response.status}`;
|
|
508
|
+
throw {
|
|
509
|
+
message: (data == null ? void 0 : data.hint) ? `${base} \u2014 ${data.hint}` : base,
|
|
510
|
+
status: response.status,
|
|
511
|
+
details: data
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
return response.blob();
|
|
487
515
|
}
|
|
488
516
|
};
|
|
489
517
|
async function requestWithTenant(method, endpoint, tenantId, options) {
|
|
@@ -681,6 +709,32 @@ async function uploadFileLoadableMitra(options) {
|
|
|
681
709
|
if (options.debug !== void 0) formData.append("debug", String(options.debug));
|
|
682
710
|
return http.upload("/interactions/uploadFileLoadable", formData);
|
|
683
711
|
}
|
|
712
|
+
async function uploadFilePrivateMitra(options) {
|
|
713
|
+
const formData = new FormData();
|
|
714
|
+
formData.append("file", options.file);
|
|
715
|
+
formData.append("projectId", String(resolveProjectId2(options.projectId)));
|
|
716
|
+
if (options.debug !== void 0) formData.append("debug", String(options.debug));
|
|
717
|
+
return http.upload("/interactions/uploadFilePrivate", formData);
|
|
718
|
+
}
|
|
719
|
+
async function downloadFilePrivateMitra(options) {
|
|
720
|
+
return http.download("/interactions/downloadFile", {
|
|
721
|
+
projectId: resolveProjectId2(options.projectId),
|
|
722
|
+
key: options.key
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
async function getFileLinkMitra(options) {
|
|
726
|
+
return http.get("/interactions/fileLink", {
|
|
727
|
+
projectId: resolveProjectId2(options.projectId),
|
|
728
|
+
key: options.key,
|
|
729
|
+
...options.ttlSeconds !== void 0 ? { ttlSeconds: options.ttlSeconds } : {}
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
async function deleteFileMitra(options) {
|
|
733
|
+
return http.del("/interactions/deleteFile", {
|
|
734
|
+
projectId: resolveProjectId2(options.projectId),
|
|
735
|
+
key: options.key
|
|
736
|
+
});
|
|
737
|
+
}
|
|
684
738
|
async function listRecordsMitra(options) {
|
|
685
739
|
const { tableName, page, size, filters, jdbcConnectionConfigId } = options;
|
|
686
740
|
const pid = resolveProjectId2(options.projectId);
|
|
@@ -1869,6 +1923,30 @@ function createMitraInstance(initialConfig) {
|
|
|
1869
1923
|
body: formData
|
|
1870
1924
|
});
|
|
1871
1925
|
}
|
|
1926
|
+
async function requestDownload(endpoint, params) {
|
|
1927
|
+
let url = `${_config.baseURL}${endpoint}`;
|
|
1928
|
+
if (params) {
|
|
1929
|
+
const q = buildQuery(params);
|
|
1930
|
+
if (q) url += `?${q}`;
|
|
1931
|
+
}
|
|
1932
|
+
const fetchFn = getFetch3();
|
|
1933
|
+
let response = await fetchFn(url, { method: "GET", headers: authHeaders() });
|
|
1934
|
+
if (response.status === 403) {
|
|
1935
|
+
const refreshed = await tryRefreshToken2();
|
|
1936
|
+
if (refreshed) response = await fetchFn(url, { method: "GET", headers: authHeaders() });
|
|
1937
|
+
}
|
|
1938
|
+
if (!response.ok) {
|
|
1939
|
+
const text = await response.text();
|
|
1940
|
+
let data = null;
|
|
1941
|
+
try {
|
|
1942
|
+
data = text ? JSON.parse(text) : null;
|
|
1943
|
+
} catch (e) {
|
|
1944
|
+
}
|
|
1945
|
+
const base = (data == null ? void 0 : data.message) || (data == null ? void 0 : data.error) || `HTTP ${response.status}`;
|
|
1946
|
+
throw { message: (data == null ? void 0 : data.hint) ? `${base} \u2014 ${data.hint}` : base, status: response.status, details: data };
|
|
1947
|
+
}
|
|
1948
|
+
return response.blob();
|
|
1949
|
+
}
|
|
1872
1950
|
async function requestTenant(method, endpoint, tenantId, opts) {
|
|
1873
1951
|
let url = `${_config.baseURL}${endpoint}`;
|
|
1874
1952
|
if (opts == null ? void 0 : opts.params) {
|
|
@@ -1976,6 +2054,13 @@ function createMitraInstance(initialConfig) {
|
|
|
1976
2054
|
if (options.debug !== void 0) formData.append("debug", String(options.debug));
|
|
1977
2055
|
return requestUpload("/interactions/uploadFilePublic", formData);
|
|
1978
2056
|
},
|
|
2057
|
+
async uploadFilePrivate(options) {
|
|
2058
|
+
const formData = new FormData();
|
|
2059
|
+
formData.append("file", options.file);
|
|
2060
|
+
formData.append("projectId", String(resolveProjectId4(options.projectId)));
|
|
2061
|
+
if (options.debug !== void 0) formData.append("debug", String(options.debug));
|
|
2062
|
+
return requestUpload("/interactions/uploadFilePrivate", formData);
|
|
2063
|
+
},
|
|
1979
2064
|
async uploadFileLoadable(options) {
|
|
1980
2065
|
const formData = new FormData();
|
|
1981
2066
|
formData.append("file", options.file);
|
|
@@ -1983,6 +2068,26 @@ function createMitraInstance(initialConfig) {
|
|
|
1983
2068
|
if (options.debug !== void 0) formData.append("debug", String(options.debug));
|
|
1984
2069
|
return requestUpload("/interactions/uploadFileLoadable", formData);
|
|
1985
2070
|
},
|
|
2071
|
+
async downloadFilePrivate(options) {
|
|
2072
|
+
return requestDownload("/interactions/downloadFile", {
|
|
2073
|
+
projectId: resolveProjectId4(options.projectId),
|
|
2074
|
+
key: options.key
|
|
2075
|
+
});
|
|
2076
|
+
},
|
|
2077
|
+
async getFileLink(options) {
|
|
2078
|
+
return request("GET", "/interactions/fileLink", {
|
|
2079
|
+
params: {
|
|
2080
|
+
projectId: resolveProjectId4(options.projectId),
|
|
2081
|
+
key: options.key,
|
|
2082
|
+
...options.ttlSeconds !== void 0 ? { ttlSeconds: options.ttlSeconds } : {}
|
|
2083
|
+
}
|
|
2084
|
+
});
|
|
2085
|
+
},
|
|
2086
|
+
async deleteFile(options) {
|
|
2087
|
+
return request("DELETE", "/interactions/deleteFile", {
|
|
2088
|
+
params: { projectId: resolveProjectId4(options.projectId), key: options.key }
|
|
2089
|
+
});
|
|
2090
|
+
},
|
|
1986
2091
|
// Integrations
|
|
1987
2092
|
async listIntegrations(options = {}) {
|
|
1988
2093
|
return request("GET", "/interactions/integrations", { params: { projectId: resolveProjectId4(options.projectId) } });
|
|
@@ -2203,6 +2308,6 @@ function resolveProjectId2(projectId) {
|
|
|
2203
2308
|
throw new Error("projectId \xE9 obrigat\xF3rio. Passe nas options ou configure via configureSdkMitra({ projectId }).");
|
|
2204
2309
|
}
|
|
2205
2310
|
|
|
2206
|
-
export { callIntegrationMitra, closeChatMitra, configureSdkMitra, createMitraInstance, createProfileMitra, createRecordMitra, createRecordsBatchMitra, deleteProfileMitra, deleteRecordMitra, emailLoginMitra, emailResendCodeMitra, emailSignupMitra, emailVerifyCodeMitra, executeDataLoaderMitra, executeDbActionMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getAgentTaskMitra, getConfig, getProfileDetailsMitra, getPublicServerFunctionExecutionMitra, getRecordMitra, getVariableMitra, listIntegrationsMitra, listProfilesMitra, listRecordsMitra, listVariablesMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, manageAgentChatMitra, manageAgentCredentialMitra, openChatMitra, patchRecordMitra, refreshTokenSilently, resetPasswordMitra, resolveProjectId2 as resolveProjectId, runActionMitra, sendPasswordResetCodeMitra, setFileStatusMitra, setProfileActionsMitra, setProfileDmlTablesMitra, setProfileScreensMitra, setProfileSelectTablesMitra, setProfileServerFunctionsMitra, setProfileUsersMitra, setVariableMitra, stopServerFunctionExecutionMitra, updateProfileMitra, updateRecordMitra, uploadFileLoadableMitra, uploadFilePublicMitra, validatePasswordResetCodeMitra };
|
|
2311
|
+
export { callIntegrationMitra, closeChatMitra, configureSdkMitra, createMitraInstance, createProfileMitra, createRecordMitra, createRecordsBatchMitra, deleteFileMitra, deleteProfileMitra, deleteRecordMitra, downloadFilePrivateMitra, emailLoginMitra, emailResendCodeMitra, emailSignupMitra, emailVerifyCodeMitra, executeDataLoaderMitra, executeDbActionMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getAgentTaskMitra, getConfig, getFileLinkMitra, getProfileDetailsMitra, getPublicServerFunctionExecutionMitra, getRecordMitra, getVariableMitra, listIntegrationsMitra, listProfilesMitra, listRecordsMitra, listVariablesMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, manageAgentChatMitra, manageAgentCredentialMitra, openChatMitra, patchRecordMitra, refreshTokenSilently, resetPasswordMitra, resolveProjectId2 as resolveProjectId, runActionMitra, sendPasswordResetCodeMitra, setFileStatusMitra, setProfileActionsMitra, setProfileDmlTablesMitra, setProfileScreensMitra, setProfileSelectTablesMitra, setProfileServerFunctionsMitra, setProfileUsersMitra, setVariableMitra, stopServerFunctionExecutionMitra, updateProfileMitra, updateRecordMitra, uploadFileLoadableMitra, uploadFilePrivateMitra, uploadFilePublicMitra, validatePasswordResetCodeMitra };
|
|
2207
2312
|
//# sourceMappingURL=index.mjs.map
|
|
2208
2313
|
//# sourceMappingURL=index.mjs.map
|