mitra-interactions-sdk 1.0.60-beta.17 → 1.0.60-beta.19

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/index.d.mts CHANGED
@@ -25,48 +25,6 @@ interface LoginResponse {
25
25
  /** URL do serviço de integrações (opcional) */
26
26
  integrationURL?: string;
27
27
  }
28
- interface EmailSignupOptions {
29
- /** URL da página de auth (ex: https://validacao.mitralab.io/sdk-auth/). Opcional se já configurado via configureSdkMitra. */
30
- authUrl?: string;
31
- /** ID do projeto. Opcional se já configurado via configureSdkMitra. */
32
- projectId?: number | string;
33
- /** Nome completo do usuário */
34
- name: string;
35
- /** Email do usuário */
36
- email: string;
37
- /** Senha */
38
- password: string;
39
- }
40
- interface EmailLoginOptions {
41
- /** URL da página de auth (ex: https://validacao.mitralab.io/sdk-auth/). Opcional se já configurado via configureSdkMitra. */
42
- authUrl?: string;
43
- /** ID do projeto. Opcional se já configurado via configureSdkMitra. */
44
- projectId?: number | string;
45
- /** Email do usuário */
46
- email: string;
47
- /** Senha */
48
- password: string;
49
- }
50
- interface ExecuteDataLoaderOptions {
51
- projectId?: number | string;
52
- dataLoaderId: number | string;
53
- input?: Record<string, unknown>;
54
- }
55
- interface ExecuteDataLoaderResponse {
56
- status: string;
57
- result: {
58
- dataLoaderId: number | string;
59
- executionLog: {
60
- timestamp: string;
61
- rowCount: number;
62
- query: string;
63
- status: string;
64
- fileSize?: string;
65
- duration?: string;
66
- };
67
- message: string;
68
- };
69
- }
70
28
  interface ExecuteServerFunctionOptions {
71
29
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
72
30
  projectId?: number | string;
@@ -101,6 +59,38 @@ interface ExecuteServerFunctionAsyncResponse {
101
59
  executionStatus: string;
102
60
  };
103
61
  }
62
+ interface ExecutePublicServerFunctionOptions {
63
+ /** ID do projeto (tenant) */
64
+ projectId: number | string;
65
+ /** ID da Server Function (deve ter publicExecution = true) */
66
+ serverFunctionId: number | string;
67
+ /** Objeto de entrada para a função (opcional) */
68
+ input?: Record<string, unknown>;
69
+ }
70
+ interface ExecutePublicServerFunctionResponse {
71
+ executionId: string;
72
+ status: string;
73
+ output: any | null;
74
+ logs: string | null;
75
+ error: string | null;
76
+ durationMs: number | null;
77
+ }
78
+ interface ExecutePublicServerFunctionAsyncResponse {
79
+ executionId: string;
80
+ status: string;
81
+ }
82
+ interface GetPublicServerFunctionExecutionOptions {
83
+ projectId: number | string;
84
+ executionId: string;
85
+ }
86
+ interface GetPublicServerFunctionExecutionResponse {
87
+ executionId: string;
88
+ status: string;
89
+ output: any | null;
90
+ logs: string | null;
91
+ error: string | null;
92
+ durationMs: number | null;
93
+ }
104
94
  interface ListRecordsResponse {
105
95
  content: Record<string, any>[];
106
96
  page: number;
@@ -214,9 +204,11 @@ interface StopServerFunctionExecutionResponse {
214
204
 
215
205
  interface MitraInstance {
216
206
  readonly config: MitraConfig;
217
- executeDataLoader(options: ExecuteDataLoaderOptions): Promise<ExecuteDataLoaderResponse>;
218
207
  executeServerFunction(options: ExecuteServerFunctionOptions): Promise<ExecuteServerFunctionResponse>;
219
208
  executeServerFunctionAsync(options: ExecuteServerFunctionAsyncOptions): Promise<ExecuteServerFunctionAsyncResponse>;
209
+ executePublicServerFunction(options: ExecutePublicServerFunctionOptions): Promise<ExecutePublicServerFunctionResponse>;
210
+ executePublicServerFunctionAsync(options: ExecutePublicServerFunctionOptions): Promise<ExecutePublicServerFunctionAsyncResponse>;
211
+ getPublicServerFunctionExecution(options: GetPublicServerFunctionExecutionOptions): Promise<GetPublicServerFunctionExecutionResponse>;
220
212
  stopServerFunctionExecution(options: StopServerFunctionExecutionOptions): Promise<StopServerFunctionExecutionResponse>;
221
213
  listIntegrations(options?: ListIntegrationsOptions): Promise<IntegrationResponse[]>;
222
214
  callIntegration(options: CallIntegrationOptions): Promise<CallIntegrationResponse>;
@@ -274,11 +266,8 @@ declare function resolveProjectId(projectId?: number | string): number | string;
274
266
  */
275
267
 
276
268
  declare function loginMitra(method: 'email' | 'google' | 'microsoft' | 'mitra', options?: LoginOptions): Promise<LoginResponse>;
277
- declare function loginWithEmailMitra(options?: LoginOptions): Promise<LoginResponse>;
278
269
  declare function loginWithGoogleMitra(options?: LoginOptions): Promise<LoginResponse>;
279
270
  declare function loginWithMicrosoftMitra(options?: LoginOptions): Promise<LoginResponse>;
280
- declare function emailSignupMitra(options: EmailSignupOptions): Promise<void>;
281
- declare function emailLoginMitra(options: EmailLoginOptions): Promise<LoginResponse>;
282
271
  declare function refreshTokenSilently(authUrl: string, projectId: number | string): Promise<LoginResponse>;
283
272
  /**
284
273
  * Gera o JWT a partir do code do SSO (novo Mitra). O app lê codeMitra/stateMitra
@@ -295,11 +284,6 @@ declare function exchangeSsoCodeMitra(options: {
295
284
  * Mitra Interactions SDK - Services
296
285
  */
297
286
 
298
- /**
299
- * POST /interactions/executeDataLoader
300
- * Executa um Data Loader
301
- */
302
- declare function executeDataLoaderMitra(options: ExecuteDataLoaderOptions): Promise<ExecuteDataLoaderResponse>;
303
287
  /**
304
288
  * POST /interactions/executeServerFunction
305
289
  * Executa uma Server Function de forma SÍNCRONA (timeout 60s no backend)
@@ -310,6 +294,23 @@ declare function executeServerFunctionMitra(options: ExecuteServerFunctionOption
310
294
  * Executa uma Server Function de forma ASSÍNCRONA (retorna executionId imediatamente)
311
295
  */
312
296
  declare function executeServerFunctionAsyncMitra(options: ExecuteServerFunctionAsyncOptions): Promise<ExecuteServerFunctionAsyncResponse>;
297
+ /**
298
+ * POST /public/serverFunction/{projectId}/{serverFunctionId}/execute
299
+ * Executa uma Server Function pública de forma SÍNCRONA (sem autenticação).
300
+ * A SF deve ter publicExecution = true. Timeout 5min.
301
+ */
302
+ declare function executePublicServerFunctionMitra(options: ExecutePublicServerFunctionOptions): Promise<ExecutePublicServerFunctionResponse>;
303
+ /**
304
+ * POST /public/serverFunction/{projectId}/{serverFunctionId}/executeAsync
305
+ * Executa uma Server Function pública de forma ASSÍNCRONA (sem autenticação).
306
+ * Retorna executionId imediatamente. Use getPublicServerFunctionExecutionMitra para polling.
307
+ */
308
+ declare function executePublicServerFunctionAsyncMitra(options: ExecutePublicServerFunctionOptions): Promise<ExecutePublicServerFunctionAsyncResponse>;
309
+ /**
310
+ * GET /public/serverFunction/{projectId}/execution/{executionId}
311
+ * Consulta o status/resultado de uma execução pública de SF (sem autenticação).
312
+ */
313
+ declare function getPublicServerFunctionExecutionMitra(options: GetPublicServerFunctionExecutionOptions): Promise<GetPublicServerFunctionExecutionResponse>;
313
314
  /**
314
315
  * GET /interactions/integrations?projectId=X
315
316
  * Lista integrações configuradas no projeto
@@ -334,4 +335,4 @@ declare function patchRecordMitra(options: PatchRecordOptions): Promise<Record<s
334
335
  declare function deleteRecordMitra(options: DeleteRecordOptions): Promise<void>;
335
336
  declare function createRecordsBatchMitra(options: CreateRecordsBatchOptions): Promise<Record<string, any>[]>;
336
337
 
337
- export { type CallIntegrationOptions, type CallIntegrationResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type DeleteRecordOptions, type EmailLoginOptions, type EmailSignupOptions, type ExecuteDataLoaderOptions, type ExecuteDataLoaderResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetRecordOptions, type IntegrationResponse, type ListIntegrationsOptions, type ListRecordsOptions, type ListRecordsResponse, type LoginOptions, type LoginResponse, type MitraConfig, type MitraInstance, type PatchRecordOptions, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateRecordOptions, callIntegrationMitra, configureSdkMitra, createMitraInstance, createRecordMitra, createRecordsBatchMitra, deleteRecordMitra, emailLoginMitra, emailSignupMitra, exchangeSsoCodeMitra, executeDataLoaderMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getConfig, getRecordMitra, listIntegrationsMitra, listRecordsMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, patchRecordMitra, refreshTokenSilently, resolveProjectId, stopServerFunctionExecutionMitra, updateRecordMitra };
338
+ export { type CallIntegrationOptions, type CallIntegrationResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type DeleteRecordOptions, type ExecutePublicServerFunctionAsyncResponse, type ExecutePublicServerFunctionOptions, type ExecutePublicServerFunctionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetPublicServerFunctionExecutionOptions, type GetPublicServerFunctionExecutionResponse, type GetRecordOptions, type IntegrationResponse, type ListIntegrationsOptions, type ListRecordsOptions, type ListRecordsResponse, type LoginOptions, type LoginResponse, type MitraConfig, type MitraInstance, type PatchRecordOptions, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateRecordOptions, callIntegrationMitra, configureSdkMitra, createMitraInstance, createRecordMitra, createRecordsBatchMitra, deleteRecordMitra, exchangeSsoCodeMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getConfig, getPublicServerFunctionExecutionMitra, getRecordMitra, listIntegrationsMitra, listRecordsMitra, loginMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, patchRecordMitra, refreshTokenSilently, resolveProjectId, stopServerFunctionExecutionMitra, updateRecordMitra };
package/dist/index.d.ts CHANGED
@@ -25,48 +25,6 @@ interface LoginResponse {
25
25
  /** URL do serviço de integrações (opcional) */
26
26
  integrationURL?: string;
27
27
  }
28
- interface EmailSignupOptions {
29
- /** URL da página de auth (ex: https://validacao.mitralab.io/sdk-auth/). Opcional se já configurado via configureSdkMitra. */
30
- authUrl?: string;
31
- /** ID do projeto. Opcional se já configurado via configureSdkMitra. */
32
- projectId?: number | string;
33
- /** Nome completo do usuário */
34
- name: string;
35
- /** Email do usuário */
36
- email: string;
37
- /** Senha */
38
- password: string;
39
- }
40
- interface EmailLoginOptions {
41
- /** URL da página de auth (ex: https://validacao.mitralab.io/sdk-auth/). Opcional se já configurado via configureSdkMitra. */
42
- authUrl?: string;
43
- /** ID do projeto. Opcional se já configurado via configureSdkMitra. */
44
- projectId?: number | string;
45
- /** Email do usuário */
46
- email: string;
47
- /** Senha */
48
- password: string;
49
- }
50
- interface ExecuteDataLoaderOptions {
51
- projectId?: number | string;
52
- dataLoaderId: number | string;
53
- input?: Record<string, unknown>;
54
- }
55
- interface ExecuteDataLoaderResponse {
56
- status: string;
57
- result: {
58
- dataLoaderId: number | string;
59
- executionLog: {
60
- timestamp: string;
61
- rowCount: number;
62
- query: string;
63
- status: string;
64
- fileSize?: string;
65
- duration?: string;
66
- };
67
- message: string;
68
- };
69
- }
70
28
  interface ExecuteServerFunctionOptions {
71
29
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
72
30
  projectId?: number | string;
@@ -101,6 +59,38 @@ interface ExecuteServerFunctionAsyncResponse {
101
59
  executionStatus: string;
102
60
  };
103
61
  }
62
+ interface ExecutePublicServerFunctionOptions {
63
+ /** ID do projeto (tenant) */
64
+ projectId: number | string;
65
+ /** ID da Server Function (deve ter publicExecution = true) */
66
+ serverFunctionId: number | string;
67
+ /** Objeto de entrada para a função (opcional) */
68
+ input?: Record<string, unknown>;
69
+ }
70
+ interface ExecutePublicServerFunctionResponse {
71
+ executionId: string;
72
+ status: string;
73
+ output: any | null;
74
+ logs: string | null;
75
+ error: string | null;
76
+ durationMs: number | null;
77
+ }
78
+ interface ExecutePublicServerFunctionAsyncResponse {
79
+ executionId: string;
80
+ status: string;
81
+ }
82
+ interface GetPublicServerFunctionExecutionOptions {
83
+ projectId: number | string;
84
+ executionId: string;
85
+ }
86
+ interface GetPublicServerFunctionExecutionResponse {
87
+ executionId: string;
88
+ status: string;
89
+ output: any | null;
90
+ logs: string | null;
91
+ error: string | null;
92
+ durationMs: number | null;
93
+ }
104
94
  interface ListRecordsResponse {
105
95
  content: Record<string, any>[];
106
96
  page: number;
@@ -214,9 +204,11 @@ interface StopServerFunctionExecutionResponse {
214
204
 
215
205
  interface MitraInstance {
216
206
  readonly config: MitraConfig;
217
- executeDataLoader(options: ExecuteDataLoaderOptions): Promise<ExecuteDataLoaderResponse>;
218
207
  executeServerFunction(options: ExecuteServerFunctionOptions): Promise<ExecuteServerFunctionResponse>;
219
208
  executeServerFunctionAsync(options: ExecuteServerFunctionAsyncOptions): Promise<ExecuteServerFunctionAsyncResponse>;
209
+ executePublicServerFunction(options: ExecutePublicServerFunctionOptions): Promise<ExecutePublicServerFunctionResponse>;
210
+ executePublicServerFunctionAsync(options: ExecutePublicServerFunctionOptions): Promise<ExecutePublicServerFunctionAsyncResponse>;
211
+ getPublicServerFunctionExecution(options: GetPublicServerFunctionExecutionOptions): Promise<GetPublicServerFunctionExecutionResponse>;
220
212
  stopServerFunctionExecution(options: StopServerFunctionExecutionOptions): Promise<StopServerFunctionExecutionResponse>;
221
213
  listIntegrations(options?: ListIntegrationsOptions): Promise<IntegrationResponse[]>;
222
214
  callIntegration(options: CallIntegrationOptions): Promise<CallIntegrationResponse>;
@@ -274,11 +266,8 @@ declare function resolveProjectId(projectId?: number | string): number | string;
274
266
  */
275
267
 
276
268
  declare function loginMitra(method: 'email' | 'google' | 'microsoft' | 'mitra', options?: LoginOptions): Promise<LoginResponse>;
277
- declare function loginWithEmailMitra(options?: LoginOptions): Promise<LoginResponse>;
278
269
  declare function loginWithGoogleMitra(options?: LoginOptions): Promise<LoginResponse>;
279
270
  declare function loginWithMicrosoftMitra(options?: LoginOptions): Promise<LoginResponse>;
280
- declare function emailSignupMitra(options: EmailSignupOptions): Promise<void>;
281
- declare function emailLoginMitra(options: EmailLoginOptions): Promise<LoginResponse>;
282
271
  declare function refreshTokenSilently(authUrl: string, projectId: number | string): Promise<LoginResponse>;
283
272
  /**
284
273
  * Gera o JWT a partir do code do SSO (novo Mitra). O app lê codeMitra/stateMitra
@@ -295,11 +284,6 @@ declare function exchangeSsoCodeMitra(options: {
295
284
  * Mitra Interactions SDK - Services
296
285
  */
297
286
 
298
- /**
299
- * POST /interactions/executeDataLoader
300
- * Executa um Data Loader
301
- */
302
- declare function executeDataLoaderMitra(options: ExecuteDataLoaderOptions): Promise<ExecuteDataLoaderResponse>;
303
287
  /**
304
288
  * POST /interactions/executeServerFunction
305
289
  * Executa uma Server Function de forma SÍNCRONA (timeout 60s no backend)
@@ -310,6 +294,23 @@ declare function executeServerFunctionMitra(options: ExecuteServerFunctionOption
310
294
  * Executa uma Server Function de forma ASSÍNCRONA (retorna executionId imediatamente)
311
295
  */
312
296
  declare function executeServerFunctionAsyncMitra(options: ExecuteServerFunctionAsyncOptions): Promise<ExecuteServerFunctionAsyncResponse>;
297
+ /**
298
+ * POST /public/serverFunction/{projectId}/{serverFunctionId}/execute
299
+ * Executa uma Server Function pública de forma SÍNCRONA (sem autenticação).
300
+ * A SF deve ter publicExecution = true. Timeout 5min.
301
+ */
302
+ declare function executePublicServerFunctionMitra(options: ExecutePublicServerFunctionOptions): Promise<ExecutePublicServerFunctionResponse>;
303
+ /**
304
+ * POST /public/serverFunction/{projectId}/{serverFunctionId}/executeAsync
305
+ * Executa uma Server Function pública de forma ASSÍNCRONA (sem autenticação).
306
+ * Retorna executionId imediatamente. Use getPublicServerFunctionExecutionMitra para polling.
307
+ */
308
+ declare function executePublicServerFunctionAsyncMitra(options: ExecutePublicServerFunctionOptions): Promise<ExecutePublicServerFunctionAsyncResponse>;
309
+ /**
310
+ * GET /public/serverFunction/{projectId}/execution/{executionId}
311
+ * Consulta o status/resultado de uma execução pública de SF (sem autenticação).
312
+ */
313
+ declare function getPublicServerFunctionExecutionMitra(options: GetPublicServerFunctionExecutionOptions): Promise<GetPublicServerFunctionExecutionResponse>;
313
314
  /**
314
315
  * GET /interactions/integrations?projectId=X
315
316
  * Lista integrações configuradas no projeto
@@ -334,4 +335,4 @@ declare function patchRecordMitra(options: PatchRecordOptions): Promise<Record<s
334
335
  declare function deleteRecordMitra(options: DeleteRecordOptions): Promise<void>;
335
336
  declare function createRecordsBatchMitra(options: CreateRecordsBatchOptions): Promise<Record<string, any>[]>;
336
337
 
337
- export { type CallIntegrationOptions, type CallIntegrationResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type DeleteRecordOptions, type EmailLoginOptions, type EmailSignupOptions, type ExecuteDataLoaderOptions, type ExecuteDataLoaderResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetRecordOptions, type IntegrationResponse, type ListIntegrationsOptions, type ListRecordsOptions, type ListRecordsResponse, type LoginOptions, type LoginResponse, type MitraConfig, type MitraInstance, type PatchRecordOptions, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateRecordOptions, callIntegrationMitra, configureSdkMitra, createMitraInstance, createRecordMitra, createRecordsBatchMitra, deleteRecordMitra, emailLoginMitra, emailSignupMitra, exchangeSsoCodeMitra, executeDataLoaderMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getConfig, getRecordMitra, listIntegrationsMitra, listRecordsMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, patchRecordMitra, refreshTokenSilently, resolveProjectId, stopServerFunctionExecutionMitra, updateRecordMitra };
338
+ export { type CallIntegrationOptions, type CallIntegrationResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type DeleteRecordOptions, type ExecutePublicServerFunctionAsyncResponse, type ExecutePublicServerFunctionOptions, type ExecutePublicServerFunctionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetPublicServerFunctionExecutionOptions, type GetPublicServerFunctionExecutionResponse, type GetRecordOptions, type IntegrationResponse, type ListIntegrationsOptions, type ListRecordsOptions, type ListRecordsResponse, type LoginOptions, type LoginResponse, type MitraConfig, type MitraInstance, type PatchRecordOptions, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateRecordOptions, callIntegrationMitra, configureSdkMitra, createMitraInstance, createRecordMitra, createRecordsBatchMitra, deleteRecordMitra, exchangeSsoCodeMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getConfig, getPublicServerFunctionExecutionMitra, getRecordMitra, listIntegrationsMitra, listRecordsMitra, loginMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, patchRecordMitra, refreshTokenSilently, resolveProjectId, stopServerFunctionExecutionMitra, updateRecordMitra };
package/dist/index.js CHANGED
@@ -107,9 +107,6 @@ async function doLogin(method, options) {
107
107
  autoConfigureFromLogin(response, authUrl, projectId);
108
108
  return response;
109
109
  }
110
- async function loginWithEmailMitra(options) {
111
- return doLogin("email", options);
112
- }
113
110
  async function loginWithGoogleMitra(options) {
114
111
  return doLogin("google", options);
115
112
  }
@@ -163,74 +160,6 @@ async function refreshTokenSilently(authUrl, projectId) {
163
160
  })();
164
161
  return _refreshPromise;
165
162
  }
166
- var SILENT_TIMEOUT_MS = 2e4;
167
- var AUTH_READY_TYPE = "mitra-auth-ready";
168
- var AUTH_CREDENTIALS_TYPE = "mitra-auth-credentials";
169
- function openSilentAuthIframe(authUrl, projectId, credentials) {
170
- return new Promise((resolve, reject) => {
171
- const origin = getOriginFromUrl(authUrl);
172
- const base = authUrl.endsWith("/") ? authUrl : authUrl + "/";
173
- const separator = base.includes("?") ? "&" : "?";
174
- let url = `${base}${separator}mode=silent&projectId=${encodeURIComponent(projectId)}`;
175
- if (typeof window !== "undefined") {
176
- url += `&originUrl=${encodeURIComponent(window.location.href)}`;
177
- }
178
- const iframe = document.createElement("iframe");
179
- iframe.style.display = "none";
180
- const timer = setTimeout(() => {
181
- cleanup();
182
- reject(new Error("Timeout na autentica\xE7\xE3o silenciosa"));
183
- }, SILENT_TIMEOUT_MS);
184
- function onMessage(event) {
185
- var _a, _b, _c;
186
- if (event.origin !== origin) return;
187
- if (((_a = event.data) == null ? void 0 : _a.type) === AUTH_READY_TYPE) {
188
- (_b = iframe.contentWindow) == null ? void 0 : _b.postMessage({
189
- type: AUTH_CREDENTIALS_TYPE,
190
- ...credentials
191
- }, origin);
192
- return;
193
- }
194
- if (((_c = event.data) == null ? void 0 : _c.type) !== AUTH_MESSAGE_TYPE) return;
195
- cleanup();
196
- if (event.data.success) {
197
- resolve(event.data.data);
198
- } else {
199
- reject(new Error(event.data.error || "Erro na autentica\xE7\xE3o"));
200
- }
201
- }
202
- function cleanup() {
203
- window.removeEventListener("message", onMessage);
204
- clearTimeout(timer);
205
- if (iframe.parentNode) iframe.parentNode.removeChild(iframe);
206
- }
207
- window.addEventListener("message", onMessage);
208
- iframe.src = url;
209
- document.body.appendChild(iframe);
210
- });
211
- }
212
- async function emailSignupMitra(options) {
213
- const { authUrl, projectId } = resolveLoginOptions(options);
214
- const result = await openSilentAuthIframe(authUrl, projectId, {
215
- action: "signup",
216
- name: options.name,
217
- email: options.email,
218
- password: options.password
219
- });
220
- if (!result.needsVerification) {
221
- throw new Error("Resposta inesperada do signup");
222
- }
223
- }
224
- async function emailLoginMitra(options) {
225
- const { authUrl, projectId } = resolveLoginOptions(options);
226
- const response = await openSilentAuthIframe(authUrl, projectId, {
227
- action: "login",
228
- email: options.email,
229
- password: options.password
230
- });
231
- autoConfigureFromLogin(response, authUrl, projectId);
232
- return response;
233
- }
234
163
 
235
164
  // src/auth-new.ts
236
165
  function getFetch() {
@@ -288,7 +217,7 @@ function normalizeResponse(tokens, authUrl) {
288
217
  baseURL: authUrl
289
218
  };
290
219
  }
291
- var NOT_SUPPORTED_POPUP = 'Login via popup (loginWithEmailMitra/loginMitra com method "email" ou "mitra") ainda n\xE3o suportado no novo Mitra. Use emailLoginMitra({ email, password }).';
220
+ var NOT_SUPPORTED_POPUP = 'loginMitra com method "email" ou "mitra" n\xE3o \xE9 suportado no novo Mitra. Use SSO (loginWithGoogleMitra).';
292
221
  var OAUTH_RESULT_TYPE = "mitra-oauth-result";
293
222
  var POPUP_W = 480;
294
223
  var POPUP_H = 600;
@@ -488,9 +417,6 @@ async function exchangeSsoCodeMitra(options) {
488
417
  }
489
418
  return exchangeSsoCode(ctx.authUrl, ctx.provider, options.code, ctx.redirectUri, ctx.projectId);
490
419
  }
491
- async function loginWithEmailMitra2(_options) {
492
- throw new Error(NOT_SUPPORTED_POPUP);
493
- }
494
420
  async function loginWithGoogleMitra2(options) {
495
421
  return loginWithProvider("google", options);
496
422
  }
@@ -502,33 +428,6 @@ async function loginMitra2(method, options) {
502
428
  if (method === "microsoft") return loginWithProvider("microsoft", options);
503
429
  throw new Error(NOT_SUPPORTED_POPUP);
504
430
  }
505
- async function emailLoginMitra2(options) {
506
- const { authUrl, projectId } = resolveLoginOptions2(options);
507
- const data = await postBffAuth(buildBffAuthEndpoint(authUrl, "/email/login"), {
508
- projectId: String(projectId),
509
- email: options.email,
510
- password: options.password
511
- });
512
- const response = {
513
- token: data.token,
514
- // baseURL = authUrl (o gateway configurado). O BFF não devolve baseURL/integrationURL;
515
- // a base é sempre o gateway, resolvido no lado do SDK.
516
- baseURL: authUrl,
517
- // Guarda o refreshToken do login — é ele que vai no body do refresh depois.
518
- ...data.refreshToken ? { refreshToken: data.refreshToken } : {}
519
- };
520
- autoConfigureFromLogin2(response, authUrl, projectId);
521
- return response;
522
- }
523
- async function emailSignupMitra2(options) {
524
- const { authUrl, projectId } = resolveLoginOptions2(options);
525
- await postBffAuth(buildBffAuthEndpoint(authUrl, "/email/signup"), {
526
- projectId: String(projectId),
527
- name: options.name,
528
- email: options.email,
529
- password: options.password
530
- });
531
- }
532
431
  var _refreshPromise2 = null;
533
432
  async function refreshTokenSilently2(authUrl, _projectId) {
534
433
  if (_refreshPromise2) return _refreshPromise2;
@@ -580,10 +479,6 @@ async function loginMitra3(method, options) {
580
479
  const authUrl = resolveAuthUrlFromOptions(options);
581
480
  return isLegacyAuthUrl(authUrl) ? loginMitra(method, options) : loginMitra2(method, options);
582
481
  }
583
- async function loginWithEmailMitra3(options) {
584
- const authUrl = resolveAuthUrlFromOptions(options);
585
- return isLegacyAuthUrl(authUrl) ? loginWithEmailMitra(options) : loginWithEmailMitra2();
586
- }
587
482
  async function loginWithGoogleMitra3(options) {
588
483
  const authUrl = resolveAuthUrlFromOptions(options);
589
484
  return isLegacyAuthUrl(authUrl) ? loginWithGoogleMitra(options) : loginWithGoogleMitra2(options);
@@ -592,14 +487,6 @@ async function loginWithMicrosoftMitra3(options) {
592
487
  const authUrl = resolveAuthUrlFromOptions(options);
593
488
  return isLegacyAuthUrl(authUrl) ? loginWithMicrosoftMitra(options) : loginWithMicrosoftMitra2(options);
594
489
  }
595
- async function emailSignupMitra3(options) {
596
- const authUrl = resolveAuthUrlFromOptions(options);
597
- return isLegacyAuthUrl(authUrl) ? emailSignupMitra(options) : emailSignupMitra2(options);
598
- }
599
- async function emailLoginMitra3(options) {
600
- const authUrl = resolveAuthUrlFromOptions(options);
601
- return isLegacyAuthUrl(authUrl) ? emailLoginMitra(options) : emailLoginMitra2(options);
602
- }
603
490
  async function refreshTokenSilently3(authUrl, projectId) {
604
491
  return isLegacyAuthUrl(authUrl) ? refreshTokenSilently(authUrl, projectId) : refreshTokenSilently2(authUrl);
605
492
  }
@@ -740,11 +627,6 @@ function createMitraInstance(initialConfig) {
740
627
  _config = { ..._config, token };
741
628
  },
742
629
  // Services
743
- async executeDataLoader(options) {
744
- const body = { projectId: resolveProjectId2(options.projectId), dataLoaderId: options.dataLoaderId };
745
- if (options.input !== void 0) body.input = options.input;
746
- return request("POST", "/interactions/executeDataLoader", { body });
747
- },
748
630
  async executeServerFunction(options) {
749
631
  const body = { projectId: resolveProjectId2(options.projectId), serverFunctionId: options.serverFunctionId };
750
632
  if (options.input !== void 0) body.input = options.input;
@@ -755,6 +637,38 @@ function createMitraInstance(initialConfig) {
755
637
  if (options.input !== void 0) body.input = options.input;
756
638
  return request("POST", "/interactions/executeServerFunctionAsync", { body });
757
639
  },
640
+ async executePublicServerFunction(options) {
641
+ const { projectId, serverFunctionId, input } = options;
642
+ const url = `${_config.baseURL}/public/serverFunction/${projectId}/${serverFunctionId}/execute`;
643
+ const fetchFn = getFetch2();
644
+ const response = await fetchFn(url, {
645
+ method: "POST",
646
+ headers: { "Content-Type": "application/json" },
647
+ body: JSON.stringify(input || {})
648
+ });
649
+ return handleResponse2(response);
650
+ },
651
+ async executePublicServerFunctionAsync(options) {
652
+ const { projectId, serverFunctionId, input } = options;
653
+ const url = `${_config.baseURL}/public/serverFunction/${projectId}/${serverFunctionId}/executeAsync`;
654
+ const fetchFn = getFetch2();
655
+ const response = await fetchFn(url, {
656
+ method: "POST",
657
+ headers: { "Content-Type": "application/json" },
658
+ body: JSON.stringify(input || {})
659
+ });
660
+ return handleResponse2(response);
661
+ },
662
+ async getPublicServerFunctionExecution(options) {
663
+ const { projectId, executionId } = options;
664
+ const url = `${_config.baseURL}/public/serverFunction/${projectId}/execution/${executionId}`;
665
+ const fetchFn = getFetch2();
666
+ const response = await fetchFn(url, {
667
+ method: "GET",
668
+ headers: { "Content-Type": "application/json" }
669
+ });
670
+ return handleResponse2(response);
671
+ },
758
672
  async stopServerFunctionExecution(options) {
759
673
  return request("POST", "/interactions/stopServerFunctionExecution", {
760
674
  body: { projectId: resolveProjectId2(options.projectId), executionId: options.executionId }
@@ -1090,14 +1004,6 @@ var httpTenant = {
1090
1004
  };
1091
1005
 
1092
1006
  // src/services.ts
1093
- async function executeDataLoaderMitra(options) {
1094
- const body = {
1095
- projectId: resolveProjectId(options.projectId),
1096
- dataLoaderId: options.dataLoaderId
1097
- };
1098
- if (options.input !== void 0) body.input = options.input;
1099
- return http.post("/interactions/executeDataLoader", body);
1100
- }
1101
1007
  async function executeServerFunctionMitra(options) {
1102
1008
  const body = {
1103
1009
  projectId: resolveProjectId(options.projectId),
@@ -1118,6 +1024,53 @@ async function executeServerFunctionAsyncMitra(options) {
1118
1024
  }
1119
1025
  return http.post("/interactions/executeServerFunctionAsync", body);
1120
1026
  }
1027
+ async function executePublicServerFunctionMitra(options) {
1028
+ const { projectId, serverFunctionId, input } = options;
1029
+ const baseURL = getConfig().baseURL;
1030
+ const url = `${baseURL}/public/serverFunction/${projectId}/${serverFunctionId}/execute`;
1031
+ const response = await fetch(url, {
1032
+ method: "POST",
1033
+ headers: { "Content-Type": "application/json" },
1034
+ body: JSON.stringify(input || {})
1035
+ });
1036
+ if (!response.ok) {
1037
+ const data = await response.json().catch(() => null);
1038
+ const msg = (data == null ? void 0 : data.message) || (data == null ? void 0 : data.error) || `HTTP ${response.status}`;
1039
+ throw { message: msg, status: response.status, details: data };
1040
+ }
1041
+ return response.json();
1042
+ }
1043
+ async function executePublicServerFunctionAsyncMitra(options) {
1044
+ const { projectId, serverFunctionId, input } = options;
1045
+ const baseURL = getConfig().baseURL;
1046
+ const url = `${baseURL}/public/serverFunction/${projectId}/${serverFunctionId}/executeAsync`;
1047
+ const response = await fetch(url, {
1048
+ method: "POST",
1049
+ headers: { "Content-Type": "application/json" },
1050
+ body: JSON.stringify(input || {})
1051
+ });
1052
+ if (!response.ok) {
1053
+ const data = await response.json().catch(() => null);
1054
+ const msg = (data == null ? void 0 : data.message) || (data == null ? void 0 : data.error) || `HTTP ${response.status}`;
1055
+ throw { message: msg, status: response.status, details: data };
1056
+ }
1057
+ return response.json();
1058
+ }
1059
+ async function getPublicServerFunctionExecutionMitra(options) {
1060
+ const { projectId, executionId } = options;
1061
+ const baseURL = getConfig().baseURL;
1062
+ const url = `${baseURL}/public/serverFunction/${projectId}/execution/${executionId}`;
1063
+ const response = await fetch(url, {
1064
+ method: "GET",
1065
+ headers: { "Content-Type": "application/json" }
1066
+ });
1067
+ if (!response.ok) {
1068
+ const data = await response.json().catch(() => null);
1069
+ const msg = (data == null ? void 0 : data.message) || (data == null ? void 0 : data.error) || `HTTP ${response.status}`;
1070
+ throw { message: msg, status: response.status, details: data };
1071
+ }
1072
+ return response.json();
1073
+ }
1121
1074
  async function listIntegrationsMitra(options = {}) {
1122
1075
  return http.get("/interactions/integrations", {
1123
1076
  projectId: resolveProjectId(options.projectId)
@@ -1188,18 +1141,17 @@ exports.createMitraInstance = createMitraInstance;
1188
1141
  exports.createRecordMitra = createRecordMitra;
1189
1142
  exports.createRecordsBatchMitra = createRecordsBatchMitra;
1190
1143
  exports.deleteRecordMitra = deleteRecordMitra;
1191
- exports.emailLoginMitra = emailLoginMitra3;
1192
- exports.emailSignupMitra = emailSignupMitra3;
1193
1144
  exports.exchangeSsoCodeMitra = exchangeSsoCodeMitra2;
1194
- exports.executeDataLoaderMitra = executeDataLoaderMitra;
1145
+ exports.executePublicServerFunctionAsyncMitra = executePublicServerFunctionAsyncMitra;
1146
+ exports.executePublicServerFunctionMitra = executePublicServerFunctionMitra;
1195
1147
  exports.executeServerFunctionAsyncMitra = executeServerFunctionAsyncMitra;
1196
1148
  exports.executeServerFunctionMitra = executeServerFunctionMitra;
1197
1149
  exports.getConfig = getConfig;
1150
+ exports.getPublicServerFunctionExecutionMitra = getPublicServerFunctionExecutionMitra;
1198
1151
  exports.getRecordMitra = getRecordMitra;
1199
1152
  exports.listIntegrationsMitra = listIntegrationsMitra;
1200
1153
  exports.listRecordsMitra = listRecordsMitra;
1201
1154
  exports.loginMitra = loginMitra3;
1202
- exports.loginWithEmailMitra = loginWithEmailMitra3;
1203
1155
  exports.loginWithGoogleMitra = loginWithGoogleMitra3;
1204
1156
  exports.loginWithMicrosoftMitra = loginWithMicrosoftMitra3;
1205
1157
  exports.patchRecordMitra = patchRecordMitra;