mitra-interactions-sdk 1.0.56-beta.1 → 1.0.56-beta.2

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