mitra-interactions-sdk 1.0.57 → 1.0.58-beta.0

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
@@ -5,7 +5,7 @@ interface LoginOptions {
5
5
  /** URL da página de autenticação Mitra (ex: https://coder.mitralab.io/sdk-auth/). Opcional se já configurado via configureSdkMitra. */
6
6
  authUrl?: string;
7
7
  /** ID do projeto. Opcional se já configurado via configureSdkMitra. */
8
- projectId?: number;
8
+ projectId?: number | string;
9
9
  /** Modo de login: 'popup' (default) abre popup, 'redirect' navega para a página de auth. */
10
10
  mode?: 'popup' | 'redirect';
11
11
  /** URL de retorno após login com mode 'redirect'. A página de auth redirecionará de volta para esta URL com token nos query params. */
@@ -18,6 +18,8 @@ interface LoginOptions {
18
18
  interface LoginResponse {
19
19
  /** Token JWT (já com prefixo Bearer) */
20
20
  token: string;
21
+ /** Refresh token (novo Mitra). Presente apenas no novo mundo. */
22
+ refreshToken?: string;
21
23
  /** URL base da API */
22
24
  baseURL: string;
23
25
  /** URL do serviço de integrações (opcional) */
@@ -27,7 +29,7 @@ interface EmailSignupOptions {
27
29
  /** URL da página de auth (ex: https://validacao.mitralab.io/sdk-auth/). Opcional se já configurado via configureSdkMitra. */
28
30
  authUrl?: string;
29
31
  /** ID do projeto. Opcional se já configurado via configureSdkMitra. */
30
- projectId?: number;
32
+ projectId?: number | string;
31
33
  /** Nome completo do usuário */
32
34
  name: string;
33
35
  /** Email do usuário */
@@ -39,7 +41,7 @@ interface EmailLoginOptions {
39
41
  /** URL da página de auth (ex: https://validacao.mitralab.io/sdk-auth/). Opcional se já configurado via configureSdkMitra. */
40
42
  authUrl?: string;
41
43
  /** ID do projeto. Opcional se já configurado via configureSdkMitra. */
42
- projectId?: number;
44
+ projectId?: number | string;
43
45
  /** Email do usuário */
44
46
  email: string;
45
47
  /** Senha */
@@ -49,7 +51,7 @@ interface EmailVerifyCodeOptions {
49
51
  /** URL da página de auth. Opcional se já configurado via configureSdkMitra. */
50
52
  authUrl?: string;
51
53
  /** ID do projeto. Opcional se já configurado via configureSdkMitra. */
52
- projectId?: number;
54
+ projectId?: number | string;
53
55
  /** Email do usuário */
54
56
  email: string;
55
57
  /** Código de verificação de 6 dígitos */
@@ -61,7 +63,7 @@ interface EmailResendCodeOptions {
61
63
  /** URL da página de auth. Opcional se já configurado via configureSdkMitra. */
62
64
  authUrl?: string;
63
65
  /** ID do projeto. Opcional se já configurado via configureSdkMitra. */
64
- projectId?: number;
66
+ projectId?: number | string;
65
67
  /** Email do usuário */
66
68
  email: string;
67
69
  }
@@ -94,14 +96,14 @@ interface ResetPasswordOptions {
94
96
  authApiURL?: string;
95
97
  }
96
98
  interface ExecuteDataLoaderOptions {
97
- projectId?: number;
98
- dataLoaderId: number;
99
+ projectId?: number | string;
100
+ dataLoaderId: number | string;
99
101
  input?: Record<string, unknown>;
100
102
  }
101
103
  interface ExecuteDataLoaderResponse {
102
104
  status: string;
103
105
  result: {
104
- dataLoaderId: number;
106
+ dataLoaderId: number | string;
105
107
  executionLog: {
106
108
  timestamp: string;
107
109
  rowCount: number;
@@ -115,9 +117,9 @@ interface ExecuteDataLoaderResponse {
115
117
  }
116
118
  interface ExecuteDbActionOptions {
117
119
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
118
- projectId?: number;
120
+ projectId?: number | string;
119
121
  /** ID da DBAction cadastrada */
120
- dbActionId: number;
122
+ dbActionId: number | string;
121
123
  /** Parâmetros de entrada (opcional) — substituição de variáveis no SQL (ex: { "nome": "João" } substitui :nome) */
122
124
  input?: Record<string, unknown>;
123
125
  }
@@ -129,7 +131,7 @@ interface ExecuteDbActionResponse {
129
131
  }
130
132
  interface SetFileStatusOptions {
131
133
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
132
- projectId?: number;
134
+ projectId?: number | string;
133
135
  /** Nome do arquivo */
134
136
  fileName: string;
135
137
  /** Caminho de destino: "PUBLIC" ou "LOADABLE" */
@@ -146,7 +148,7 @@ interface SetFileStatusResponse {
146
148
  }
147
149
  interface SetVariableOptions {
148
150
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
149
- projectId?: number;
151
+ projectId?: number | string;
150
152
  /** Nome da variável (key) */
151
153
  key: string;
152
154
  /** Valor da variável (opcional) */
@@ -161,9 +163,9 @@ interface SetVariableResponse {
161
163
  }
162
164
  interface ExecuteServerFunctionOptions {
163
165
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
164
- projectId?: number;
166
+ projectId?: number | string;
165
167
  /** ID da Server Function cadastrada */
166
- serverFunctionId: number;
168
+ serverFunctionId: number | string;
167
169
  /** Objeto de entrada para a função (opcional) */
168
170
  input?: Record<string, unknown>;
169
171
  }
@@ -180,9 +182,9 @@ interface ExecuteServerFunctionResponse {
180
182
  }
181
183
  interface ExecuteServerFunctionAsyncOptions {
182
184
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
183
- projectId?: number;
185
+ projectId?: number | string;
184
186
  /** ID da Server Function cadastrada */
185
- serverFunctionId: number;
187
+ serverFunctionId: number | string;
186
188
  /** Objeto de entrada para a função (opcional) */
187
189
  input?: Record<string, unknown>;
188
190
  }
@@ -195,9 +197,9 @@ interface ExecuteServerFunctionAsyncResponse {
195
197
  }
196
198
  interface ExecutePublicServerFunctionOptions {
197
199
  /** ID do projeto (tenant) */
198
- projectId: number;
200
+ projectId: number | string;
199
201
  /** ID da Server Function (deve ter publicExecution = true) */
200
- serverFunctionId: number;
202
+ serverFunctionId: number | string;
201
203
  /** Objeto de entrada para a função (opcional) */
202
204
  input?: Record<string, unknown>;
203
205
  }
@@ -214,7 +216,7 @@ interface ExecutePublicServerFunctionAsyncResponse {
214
216
  status: string;
215
217
  }
216
218
  interface GetPublicServerFunctionExecutionOptions {
217
- projectId: number;
219
+ projectId: number | string;
218
220
  executionId: string;
219
221
  }
220
222
  interface GetPublicServerFunctionExecutionResponse {
@@ -233,54 +235,54 @@ interface ListRecordsResponse {
233
235
  totalPages: number;
234
236
  }
235
237
  interface ListRecordsOptions {
236
- projectId?: number;
238
+ projectId?: number | string;
237
239
  tableName: string;
238
240
  page?: number;
239
241
  size?: number;
240
242
  filters?: Record<string, unknown>;
241
- jdbcConnectionConfigId?: number;
243
+ jdbcConnectionConfigId?: number | string;
242
244
  }
243
245
  interface GetRecordOptions {
244
- projectId?: number;
246
+ projectId?: number | string;
245
247
  tableName: string;
246
- id: number;
247
- jdbcConnectionConfigId?: number;
248
+ id: number | string;
249
+ jdbcConnectionConfigId?: number | string;
248
250
  }
249
251
  interface CreateRecordOptions {
250
- projectId?: number;
252
+ projectId?: number | string;
251
253
  tableName: string;
252
254
  data: Record<string, unknown>;
253
- jdbcConnectionConfigId?: number;
255
+ jdbcConnectionConfigId?: number | string;
254
256
  }
255
257
  interface UpdateRecordOptions {
256
- projectId?: number;
258
+ projectId?: number | string;
257
259
  tableName: string;
258
- id: number;
260
+ id: number | string;
259
261
  data: Record<string, unknown>;
260
- jdbcConnectionConfigId?: number;
262
+ jdbcConnectionConfigId?: number | string;
261
263
  }
262
264
  interface PatchRecordOptions {
263
- projectId?: number;
265
+ projectId?: number | string;
264
266
  tableName: string;
265
- id: number;
267
+ id: number | string;
266
268
  data: Record<string, unknown>;
267
- jdbcConnectionConfigId?: number;
269
+ jdbcConnectionConfigId?: number | string;
268
270
  }
269
271
  interface DeleteRecordOptions {
270
- projectId?: number;
272
+ projectId?: number | string;
271
273
  tableName: string;
272
- id: number;
273
- jdbcConnectionConfigId?: number;
274
+ id: number | string;
275
+ jdbcConnectionConfigId?: number | string;
274
276
  }
275
277
  interface CreateRecordsBatchOptions {
276
- projectId?: number;
278
+ projectId?: number | string;
277
279
  tableName: string;
278
280
  records: Record<string, unknown>[];
279
- jdbcConnectionConfigId?: number;
281
+ jdbcConnectionConfigId?: number | string;
280
282
  }
281
283
  interface UploadFileOptions {
282
284
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
283
- projectId?: number;
285
+ projectId?: number | string;
284
286
  /** Arquivo a ser enviado (File ou Blob) */
285
287
  file: File | Blob;
286
288
  /** Habilitar debug (opcional) */
@@ -297,11 +299,11 @@ interface UploadFileResponse {
297
299
  }
298
300
  interface ListVariablesOptions {
299
301
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
300
- projectId?: number;
302
+ projectId?: number | string;
301
303
  }
302
304
  interface ListVariablesResponse {
303
305
  status: string;
304
- projectId: number;
306
+ projectId: number | string;
305
307
  result: {
306
308
  key: string;
307
309
  value: string;
@@ -309,7 +311,7 @@ interface ListVariablesResponse {
309
311
  }
310
312
  interface GetVariableOptions {
311
313
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
312
- projectId?: number;
314
+ projectId?: number | string;
313
315
  /** Nome da variável (com ou sem :VAR_) */
314
316
  key: string;
315
317
  }
@@ -322,9 +324,9 @@ interface GetVariableResponse {
322
324
  }
323
325
  interface RunActionOptions {
324
326
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
325
- projectId?: number;
327
+ projectId?: number | string;
326
328
  /** ID da Action a executar */
327
- actionId: number;
329
+ actionId: number | string;
328
330
  /** Parâmetros de entrada para a action (opcional) */
329
331
  input?: Record<string, unknown>;
330
332
  }
@@ -338,7 +340,7 @@ interface RunActionResponse {
338
340
  }
339
341
  interface CallIntegrationOptions {
340
342
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
341
- projectId?: number;
343
+ projectId?: number | string;
342
344
  /** Slug da integração configurada no painel */
343
345
  connection: string;
344
346
  /** Método HTTP: GET, POST, PUT, DELETE */
@@ -358,11 +360,11 @@ interface CallIntegrationResponse {
358
360
  }
359
361
  interface ListIntegrationsOptions {
360
362
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
361
- projectId?: number;
363
+ projectId?: number | string;
362
364
  }
363
365
  interface IntegrationResponse {
364
366
  id: string;
365
- projectId: number;
367
+ projectId: number | string;
366
368
  name: string;
367
369
  slug: string;
368
370
  blueprintId: string | null;
@@ -376,7 +378,7 @@ interface IntegrationResponse {
376
378
  }
377
379
  interface StopServerFunctionExecutionOptions {
378
380
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
379
- projectId?: number;
381
+ projectId?: number | string;
380
382
  /** ID da execução a ser parada */
381
383
  executionId: string;
382
384
  }
@@ -388,87 +390,87 @@ interface StopServerFunctionExecutionResponse {
388
390
  };
389
391
  }
390
392
  interface ListProfilesOptions {
391
- projectId?: number;
393
+ projectId?: number | string;
392
394
  }
393
395
  interface ListProfilesResponse {
394
396
  status: string;
395
- projectId: number;
397
+ projectId: number | string;
396
398
  result: {
397
- id: number;
399
+ id: number | string;
398
400
  name: string;
399
401
  color: string;
400
- homeScreenId: number;
402
+ homeScreenId: number | string;
401
403
  }[];
402
404
  }
403
405
  interface GetProfileDetailsOptions {
404
- projectId?: number;
405
- profileId: number;
406
+ projectId?: number | string;
407
+ profileId: number | string;
406
408
  }
407
409
  interface GetProfileDetailsResponse {
408
410
  status: string;
409
- projectId: number;
411
+ projectId: number | string;
410
412
  result: {
411
- id: number;
413
+ id: number | string;
412
414
  name: string;
413
415
  users: {
414
- id: number;
416
+ id: number | string;
415
417
  name: string;
416
418
  email: string;
417
419
  }[];
418
420
  selectTables: {
419
421
  tableName: string;
420
- jdbcConnectionConfigId?: number;
422
+ jdbcConnectionConfigId?: number | string;
421
423
  }[];
422
424
  dmlTables: {
423
425
  tableName: string;
424
- jdbcConnectionConfigId?: number;
426
+ jdbcConnectionConfigId?: number | string;
425
427
  }[];
426
428
  actions: {
427
- id: number;
429
+ id: number | string;
428
430
  name: string;
429
431
  }[];
430
432
  screens: {
431
- id: number;
433
+ id: number | string;
432
434
  name: string;
433
435
  }[];
434
436
  serverFunctions: {
435
- id: number;
437
+ id: number | string;
436
438
  name: string;
437
439
  }[];
438
440
  };
439
441
  }
440
442
  interface CreateProfileOptions {
441
- projectId?: number;
443
+ projectId?: number | string;
442
444
  name: string;
443
445
  color?: string;
444
- homeScreenId?: number;
446
+ homeScreenId?: number | string;
445
447
  }
446
448
  interface CreateProfileResponse {
447
449
  status: string;
448
450
  result: {
449
- id: number;
451
+ id: number | string;
450
452
  name: string;
451
453
  message: string;
452
454
  };
453
455
  }
454
456
  interface UpdateProfileOptions {
455
- projectId?: number;
456
- profileId: number;
457
+ projectId?: number | string;
458
+ profileId: number | string;
457
459
  name?: string;
458
460
  color?: string;
459
- homeScreenId?: number;
461
+ homeScreenId?: number | string;
460
462
  }
461
463
  interface UpdateProfileResponse {
462
464
  status: string;
463
465
  result: {
464
- id: number;
466
+ id: number | string;
465
467
  name: string;
466
468
  message: string;
467
469
  };
468
470
  }
469
471
  interface DeleteProfileOptions {
470
- projectId?: number;
471
- profileId: number;
472
+ projectId?: number | string;
473
+ profileId: number | string;
472
474
  }
473
475
  interface DeleteProfileResponse {
474
476
  status: string;
@@ -477,44 +479,44 @@ interface DeleteProfileResponse {
477
479
  };
478
480
  }
479
481
  interface SetProfileUsersOptions {
480
- projectId?: number;
481
- profileId: number;
482
+ projectId?: number | string;
483
+ profileId: number | string;
482
484
  userIds: number[];
483
485
  }
484
486
  interface ProfileTableRef {
485
487
  tableName: string;
486
488
  }
487
489
  interface SetProfileSelectTablesOptions {
488
- projectId?: number;
489
- profileId: number;
490
- jdbcConnectionConfigId?: number;
490
+ projectId?: number | string;
491
+ profileId: number | string;
492
+ jdbcConnectionConfigId?: number | string;
491
493
  tables: ProfileTableRef[];
492
494
  }
493
495
  interface SetProfileDmlTablesOptions {
494
- projectId?: number;
495
- profileId: number;
496
- jdbcConnectionConfigId?: number;
496
+ projectId?: number | string;
497
+ profileId: number | string;
498
+ jdbcConnectionConfigId?: number | string;
497
499
  tables: ProfileTableRef[];
498
500
  }
499
501
  interface SetProfileActionsOptions {
500
- projectId?: number;
501
- profileId: number;
502
+ projectId?: number | string;
503
+ profileId: number | string;
502
504
  actionIds: number[];
503
505
  }
504
506
  interface SetProfileScreensOptions {
505
- projectId?: number;
506
- profileId: number;
507
+ projectId?: number | string;
508
+ profileId: number | string;
507
509
  screenIds: number[];
508
510
  }
509
511
  interface SetProfileServerFunctionsOptions {
510
- projectId?: number;
511
- profileId: number;
512
+ projectId?: number | string;
513
+ profileId: number | string;
512
514
  serverFunctionIds: number[];
513
515
  }
514
516
  interface SetProfilePermissionResponse {
515
517
  status: string;
516
518
  result: {
517
- profileId: number;
519
+ profileId: number | string;
518
520
  message: string;
519
521
  [key: string]: unknown;
520
522
  };
@@ -576,12 +578,14 @@ interface MitraConfig {
576
578
  baseURL: string;
577
579
  /** Token JWT para autenticação (opcional para Server Functions públicas) */
578
580
  token?: string;
581
+ /** Refresh token (novo Mitra). Necessário para refresh automático no novo mundo. */
582
+ refreshToken?: string;
579
583
  /** URL base do serviço de integrações (ex: https://api0.mitraecp.com:1003) */
580
584
  integrationURL?: string;
581
585
  /** URL da página de autenticação Mitra (ex: https://coder.mitralab.io/sdk-auth/) */
582
586
  authUrl?: string;
583
587
  /** ID do projeto (usado como fallback nos métodos de login e serviços) */
584
- projectId?: number;
588
+ projectId?: number | string;
585
589
  /** Callback chamado quando o token é renovado automaticamente (após 401/403). Recebe a nova sessão. */
586
590
  onTokenRefresh?: (session: LoginResponse) => void;
587
591
  }
@@ -596,7 +600,7 @@ declare function getConfig(): MitraConfig;
596
600
  /**
597
601
  * Resolve projectId: usa o valor passado, senão pega do config salvo.
598
602
  */
599
- declare function resolveProjectId(projectId?: number): number;
603
+ declare function resolveProjectId(projectId?: number | string): number | string;
600
604
 
601
605
  /**
602
606
  * Mitra Interactions SDK - Chat Integration
@@ -615,56 +619,24 @@ declare function openChatMitra(): void;
615
619
  declare function closeChatMitra(): void;
616
620
 
617
621
  /**
618
- * Mitra Interactions SDK - Autenticação
622
+ * Mitra Interactions SDK - Autenticação (Router)
623
+ *
624
+ * Roteia chamadas de auth para a implementação correta com base no `authUrl`:
625
+ * - URLs legadas (`coder.mitralab.io/sdk-auth/`, `agent.mitralab.io/sdk-auth/`) → auth-legacy.ts
626
+ * - Qualquer outro authUrl → auth-new.ts (novo Mitra: Kong gateway + IAM service)
619
627
  *
620
- * Login via popup seguro hospedado no domínio Mitra.
621
- * Credenciais nunca passam pelo código do desenvolvedor.
628
+ * A API pública é idêntica à legacy. Consumers não precisam alterar código.
622
629
  */
623
630
 
624
- /**
625
- * Login com email e senha via popup/redirect seguro Mitra.
626
- */
631
+ declare function loginMitra(method: 'email' | 'google' | 'microsoft' | 'mitra', options?: LoginOptions): Promise<LoginResponse>;
627
632
  declare function loginWithEmailMitra(options?: LoginOptions): Promise<LoginResponse>;
628
- /**
629
- * Login com Google via popup/redirect seguro Mitra.
630
- */
631
633
  declare function loginWithGoogleMitra(options?: LoginOptions): Promise<LoginResponse>;
632
- /**
633
- * Login com Microsoft via popup/redirect seguro Mitra.
634
- */
635
634
  declare function loginWithMicrosoftMitra(options?: LoginOptions): Promise<LoginResponse>;
636
- /**
637
- * Login genérico via popup/redirect seguro Mitra.
638
- */
639
- declare function loginMitra(method: 'email' | 'google' | 'microsoft' | 'mitra', options?: LoginOptions): Promise<LoginResponse>;
640
- /**
641
- * Renova o token silenciosamente via iframe invisível.
642
- * Se já houver um refresh em andamento, reaproveita a mesma promise.
643
- */
644
- declare function refreshTokenSilently(authUrl: string, projectId: number): Promise<LoginResponse>;
645
- /**
646
- * Cria conta via email usando iframe silencioso.
647
- * Após sucesso, o usuário recebe um código de verificação por email.
648
- * Fluxo: emailSignupMitra → emailVerifyCodeMitra → emailLoginMitra
649
- */
650
635
  declare function emailSignupMitra(options: EmailSignupOptions): Promise<void>;
651
- /**
652
- * Verifica o código de 6 dígitos enviado por email após signup.
653
- * Após verificação, faz login automático e retorna LoginResponse.
654
- * Auto-configura o SDK após sucesso.
655
- */
636
+ declare function emailLoginMitra(options: EmailLoginOptions): Promise<LoginResponse>;
656
637
  declare function emailVerifyCodeMitra(options: EmailVerifyCodeOptions): Promise<LoginResponse>;
657
- /**
658
- * Reenvia o código de verificação para o email.
659
- */
660
638
  declare function emailResendCodeMitra(options: EmailResendCodeOptions): Promise<void>;
661
- /**
662
- * Login via email e senha usando iframe silencioso.
663
- * O HTML de auth faz a chamada à API e resolve as credenciais do projeto.
664
- * Retorna LoginResponse com token, baseURL e integrationURL.
665
- * Auto-configura o SDK após sucesso.
666
- */
667
- declare function emailLoginMitra(options: EmailLoginOptions): Promise<LoginResponse>;
639
+ declare function refreshTokenSilently(authUrl: string, projectId: number | string): Promise<LoginResponse>;
668
640
 
669
641
  /**
670
642
  * Mitra Interactions SDK - Password Reset (legacy backend)