mitra-interactions-sdk 1.0.53 → 1.0.55

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 CHANGED
@@ -256,6 +256,40 @@ const result = await stopServerFunctionExecutionMitra({
256
256
  // result: { status, result: { executionId, executionStatus: "CANCELLED" | "ALREADY_FINISHED" } }
257
257
  ```
258
258
 
259
+ ### Public Server Functions (sem autenticação)
260
+
261
+ Para Server Functions com `publicExecution = true`. Não requerem token.
262
+
263
+ ```typescript
264
+ import {
265
+ executePublicServerFunctionMitra,
266
+ executePublicServerFunctionAsyncMitra,
267
+ getPublicServerFunctionExecutionMitra
268
+ } from 'mitra-interactions-sdk';
269
+
270
+ // Sync — retorna resultado inline (timeout 5min)
271
+ const result = await executePublicServerFunctionMitra({
272
+ projectId: 123,
273
+ serverFunctionId: 49,
274
+ input: { param1: 'value' }
275
+ });
276
+ // result: { executionId, status, output, logs, error, durationMs }
277
+
278
+ // Async — retorna executionId imediatamente
279
+ const { executionId } = await executePublicServerFunctionAsyncMitra({
280
+ projectId: 123,
281
+ serverFunctionId: 50,
282
+ input: { heavyParam: true }
283
+ });
284
+
285
+ // Polling — consulta status/resultado
286
+ const execution = await getPublicServerFunctionExecutionMitra({
287
+ projectId: 123,
288
+ executionId
289
+ });
290
+ // execution: { executionId, status, output, logs, error, durationMs }
291
+ ```
292
+
259
293
  ### executeDataLoaderMitra
260
294
 
261
295
  Executa um Data Loader cadastrado no projeto.
package/dist/index.js CHANGED
@@ -60,7 +60,8 @@ function autoConfigureFromLogin(response, authUrl, projectId) {
60
60
  }
61
61
  function buildAuthUrl(authUrl, method, projectId, opts) {
62
62
  const base = authUrl.endsWith("/") ? authUrl : authUrl + "/";
63
- let url = `${base}?method=${method}&projectId=${encodeURIComponent(projectId)}`;
63
+ const separator = base.includes("?") ? "&" : "?";
64
+ let url = `${base}${separator}method=${method}&projectId=${encodeURIComponent(projectId)}`;
64
65
  if (opts == null ? void 0 : opts.returnTo) url += `&returnTo=${encodeURIComponent(opts.returnTo)}`;
65
66
  if (opts == null ? void 0 : opts.create) url += `&create=true`;
66
67
  if (opts == null ? void 0 : opts.title) url += `&title=${encodeURIComponent(opts.title)}`;
@@ -169,7 +170,8 @@ function openSilentAuthIframe(authUrl, projectId, credentials) {
169
170
  return new Promise((resolve, reject) => {
170
171
  const origin = getOriginFromUrl(authUrl);
171
172
  const base = authUrl.endsWith("/") ? authUrl : authUrl + "/";
172
- let url = `${base}?mode=silent&projectId=${encodeURIComponent(projectId)}`;
173
+ const separator = base.includes("?") ? "&" : "?";
174
+ let url = `${base}${separator}mode=silent&projectId=${encodeURIComponent(projectId)}`;
173
175
  if (typeof window !== "undefined") {
174
176
  url += `&originUrl=${encodeURIComponent(window.location.href)}`;
175
177
  }