mitra-interactions-sdk 1.0.64 → 1.0.65
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 +30 -3
- package/dist/index.d.mts +44 -1
- package/dist/index.d.ts +44 -1
- package/dist/index.js +92 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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,25 @@ 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 deleteFileMitra(options) {
|
|
726
|
+
return http.del("/interactions/deleteFile", {
|
|
727
|
+
projectId: resolveProjectId2(options.projectId),
|
|
728
|
+
key: options.key
|
|
729
|
+
});
|
|
730
|
+
}
|
|
684
731
|
async function listRecordsMitra(options) {
|
|
685
732
|
const { tableName, page, size, filters, jdbcConnectionConfigId } = options;
|
|
686
733
|
const pid = resolveProjectId2(options.projectId);
|
|
@@ -1869,6 +1916,30 @@ function createMitraInstance(initialConfig) {
|
|
|
1869
1916
|
body: formData
|
|
1870
1917
|
});
|
|
1871
1918
|
}
|
|
1919
|
+
async function requestDownload(endpoint, params) {
|
|
1920
|
+
let url = `${_config.baseURL}${endpoint}`;
|
|
1921
|
+
if (params) {
|
|
1922
|
+
const q = buildQuery(params);
|
|
1923
|
+
if (q) url += `?${q}`;
|
|
1924
|
+
}
|
|
1925
|
+
const fetchFn = getFetch3();
|
|
1926
|
+
let response = await fetchFn(url, { method: "GET", headers: authHeaders() });
|
|
1927
|
+
if (response.status === 403) {
|
|
1928
|
+
const refreshed = await tryRefreshToken2();
|
|
1929
|
+
if (refreshed) response = await fetchFn(url, { method: "GET", headers: authHeaders() });
|
|
1930
|
+
}
|
|
1931
|
+
if (!response.ok) {
|
|
1932
|
+
const text = await response.text();
|
|
1933
|
+
let data = null;
|
|
1934
|
+
try {
|
|
1935
|
+
data = text ? JSON.parse(text) : null;
|
|
1936
|
+
} catch (e) {
|
|
1937
|
+
}
|
|
1938
|
+
const base = (data == null ? void 0 : data.message) || (data == null ? void 0 : data.error) || `HTTP ${response.status}`;
|
|
1939
|
+
throw { message: (data == null ? void 0 : data.hint) ? `${base} \u2014 ${data.hint}` : base, status: response.status, details: data };
|
|
1940
|
+
}
|
|
1941
|
+
return response.blob();
|
|
1942
|
+
}
|
|
1872
1943
|
async function requestTenant(method, endpoint, tenantId, opts) {
|
|
1873
1944
|
let url = `${_config.baseURL}${endpoint}`;
|
|
1874
1945
|
if (opts == null ? void 0 : opts.params) {
|
|
@@ -1976,6 +2047,13 @@ function createMitraInstance(initialConfig) {
|
|
|
1976
2047
|
if (options.debug !== void 0) formData.append("debug", String(options.debug));
|
|
1977
2048
|
return requestUpload("/interactions/uploadFilePublic", formData);
|
|
1978
2049
|
},
|
|
2050
|
+
async uploadFilePrivate(options) {
|
|
2051
|
+
const formData = new FormData();
|
|
2052
|
+
formData.append("file", options.file);
|
|
2053
|
+
formData.append("projectId", String(resolveProjectId4(options.projectId)));
|
|
2054
|
+
if (options.debug !== void 0) formData.append("debug", String(options.debug));
|
|
2055
|
+
return requestUpload("/interactions/uploadFilePrivate", formData);
|
|
2056
|
+
},
|
|
1979
2057
|
async uploadFileLoadable(options) {
|
|
1980
2058
|
const formData = new FormData();
|
|
1981
2059
|
formData.append("file", options.file);
|
|
@@ -1983,6 +2061,17 @@ function createMitraInstance(initialConfig) {
|
|
|
1983
2061
|
if (options.debug !== void 0) formData.append("debug", String(options.debug));
|
|
1984
2062
|
return requestUpload("/interactions/uploadFileLoadable", formData);
|
|
1985
2063
|
},
|
|
2064
|
+
async downloadFilePrivate(options) {
|
|
2065
|
+
return requestDownload("/interactions/downloadFile", {
|
|
2066
|
+
projectId: resolveProjectId4(options.projectId),
|
|
2067
|
+
key: options.key
|
|
2068
|
+
});
|
|
2069
|
+
},
|
|
2070
|
+
async deleteFile(options) {
|
|
2071
|
+
return request("DELETE", "/interactions/deleteFile", {
|
|
2072
|
+
params: { projectId: resolveProjectId4(options.projectId), key: options.key }
|
|
2073
|
+
});
|
|
2074
|
+
},
|
|
1986
2075
|
// Integrations
|
|
1987
2076
|
async listIntegrations(options = {}) {
|
|
1988
2077
|
return request("GET", "/interactions/integrations", { params: { projectId: resolveProjectId4(options.projectId) } });
|
|
@@ -2203,6 +2292,6 @@ function resolveProjectId2(projectId) {
|
|
|
2203
2292
|
throw new Error("projectId \xE9 obrigat\xF3rio. Passe nas options ou configure via configureSdkMitra({ projectId }).");
|
|
2204
2293
|
}
|
|
2205
2294
|
|
|
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 };
|
|
2295
|
+
export { callIntegrationMitra, closeChatMitra, configureSdkMitra, createMitraInstance, createProfileMitra, createRecordMitra, createRecordsBatchMitra, deleteFileMitra, deleteProfileMitra, deleteRecordMitra, downloadFilePrivateMitra, 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, uploadFilePrivateMitra, uploadFilePublicMitra, validatePasswordResetCodeMitra };
|
|
2207
2296
|
//# sourceMappingURL=index.mjs.map
|
|
2208
2297
|
//# sourceMappingURL=index.mjs.map
|