mitra-interactions-sdk 1.0.60-beta.1 → 1.0.60

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,7 +61,7 @@ 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
  }
@@ -96,14 +94,14 @@ interface ResetPasswordOptions {
96
94
  authApiURL?: string;
97
95
  }
98
96
  interface ExecuteDataLoaderOptions {
99
- projectId?: number | string;
100
- dataLoaderId: number | string;
97
+ projectId?: number;
98
+ dataLoaderId: number;
101
99
  input?: Record<string, unknown>;
102
100
  }
103
101
  interface ExecuteDataLoaderResponse {
104
102
  status: string;
105
103
  result: {
106
- dataLoaderId: number | string;
104
+ dataLoaderId: number;
107
105
  executionLog: {
108
106
  timestamp: string;
109
107
  rowCount: number;
@@ -117,9 +115,9 @@ interface ExecuteDataLoaderResponse {
117
115
  }
118
116
  interface ExecuteDbActionOptions {
119
117
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
120
- projectId?: number | string;
118
+ projectId?: number;
121
119
  /** ID da DBAction cadastrada */
122
- dbActionId: number | string;
120
+ dbActionId: number;
123
121
  /** Parâmetros de entrada (opcional) — substituição de variáveis no SQL (ex: { "nome": "João" } substitui :nome) */
124
122
  input?: Record<string, unknown>;
125
123
  }
@@ -131,7 +129,7 @@ interface ExecuteDbActionResponse {
131
129
  }
132
130
  interface SetFileStatusOptions {
133
131
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
134
- projectId?: number | string;
132
+ projectId?: number;
135
133
  /** Nome do arquivo */
136
134
  fileName: string;
137
135
  /** Caminho de destino: "PUBLIC" ou "LOADABLE" */
@@ -148,7 +146,7 @@ interface SetFileStatusResponse {
148
146
  }
149
147
  interface SetVariableOptions {
150
148
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
151
- projectId?: number | string;
149
+ projectId?: number;
152
150
  /** Nome da variável (key) */
153
151
  key: string;
154
152
  /** Valor da variável (opcional) */
@@ -163,9 +161,9 @@ interface SetVariableResponse {
163
161
  }
164
162
  interface ExecuteServerFunctionOptions {
165
163
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
166
- projectId?: number | string;
164
+ projectId?: number;
167
165
  /** ID da Server Function cadastrada */
168
- serverFunctionId: number | string;
166
+ serverFunctionId: number;
169
167
  /** Objeto de entrada para a função (opcional) */
170
168
  input?: Record<string, unknown>;
171
169
  }
@@ -182,9 +180,9 @@ interface ExecuteServerFunctionResponse {
182
180
  }
183
181
  interface ExecuteServerFunctionAsyncOptions {
184
182
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
185
- projectId?: number | string;
183
+ projectId?: number;
186
184
  /** ID da Server Function cadastrada */
187
- serverFunctionId: number | string;
185
+ serverFunctionId: number;
188
186
  /** Objeto de entrada para a função (opcional) */
189
187
  input?: Record<string, unknown>;
190
188
  }
@@ -197,9 +195,9 @@ interface ExecuteServerFunctionAsyncResponse {
197
195
  }
198
196
  interface ExecutePublicServerFunctionOptions {
199
197
  /** ID do projeto (tenant) */
200
- projectId: number | string;
198
+ projectId: number;
201
199
  /** ID da Server Function (deve ter publicExecution = true) */
202
- serverFunctionId: number | string;
200
+ serverFunctionId: number;
203
201
  /** Objeto de entrada para a função (opcional) */
204
202
  input?: Record<string, unknown>;
205
203
  }
@@ -216,7 +214,7 @@ interface ExecutePublicServerFunctionAsyncResponse {
216
214
  status: string;
217
215
  }
218
216
  interface GetPublicServerFunctionExecutionOptions {
219
- projectId: number | string;
217
+ projectId: number;
220
218
  executionId: string;
221
219
  }
222
220
  interface GetPublicServerFunctionExecutionResponse {
@@ -235,54 +233,54 @@ interface ListRecordsResponse {
235
233
  totalPages: number;
236
234
  }
237
235
  interface ListRecordsOptions {
238
- projectId?: number | string;
236
+ projectId?: number;
239
237
  tableName: string;
240
238
  page?: number;
241
239
  size?: number;
242
240
  filters?: Record<string, unknown>;
243
- jdbcConnectionConfigId?: number | string;
241
+ jdbcConnectionConfigId?: number;
244
242
  }
245
243
  interface GetRecordOptions {
246
- projectId?: number | string;
244
+ projectId?: number;
247
245
  tableName: string;
248
- id: number | string;
249
- jdbcConnectionConfigId?: number | string;
246
+ id: number;
247
+ jdbcConnectionConfigId?: number;
250
248
  }
251
249
  interface CreateRecordOptions {
252
- projectId?: number | string;
250
+ projectId?: number;
253
251
  tableName: string;
254
252
  data: Record<string, unknown>;
255
- jdbcConnectionConfigId?: number | string;
253
+ jdbcConnectionConfigId?: number;
256
254
  }
257
255
  interface UpdateRecordOptions {
258
- projectId?: number | string;
256
+ projectId?: number;
259
257
  tableName: string;
260
- id: number | string;
258
+ id: number;
261
259
  data: Record<string, unknown>;
262
- jdbcConnectionConfigId?: number | string;
260
+ jdbcConnectionConfigId?: number;
263
261
  }
264
262
  interface PatchRecordOptions {
265
- projectId?: number | string;
263
+ projectId?: number;
266
264
  tableName: string;
267
- id: number | string;
265
+ id: number;
268
266
  data: Record<string, unknown>;
269
- jdbcConnectionConfigId?: number | string;
267
+ jdbcConnectionConfigId?: number;
270
268
  }
271
269
  interface DeleteRecordOptions {
272
- projectId?: number | string;
270
+ projectId?: number;
273
271
  tableName: string;
274
- id: number | string;
275
- jdbcConnectionConfigId?: number | string;
272
+ id: number;
273
+ jdbcConnectionConfigId?: number;
276
274
  }
277
275
  interface CreateRecordsBatchOptions {
278
- projectId?: number | string;
276
+ projectId?: number;
279
277
  tableName: string;
280
278
  records: Record<string, unknown>[];
281
- jdbcConnectionConfigId?: number | string;
279
+ jdbcConnectionConfigId?: number;
282
280
  }
283
281
  interface UploadFileOptions {
284
282
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
285
- projectId?: number | string;
283
+ projectId?: number;
286
284
  /** Arquivo a ser enviado (File ou Blob) */
287
285
  file: File | Blob;
288
286
  /** Habilitar debug (opcional) */
@@ -299,11 +297,11 @@ interface UploadFileResponse {
299
297
  }
300
298
  interface ListVariablesOptions {
301
299
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
302
- projectId?: number | string;
300
+ projectId?: number;
303
301
  }
304
302
  interface ListVariablesResponse {
305
303
  status: string;
306
- projectId: number | string;
304
+ projectId: number;
307
305
  result: {
308
306
  key: string;
309
307
  value: string;
@@ -311,7 +309,7 @@ interface ListVariablesResponse {
311
309
  }
312
310
  interface GetVariableOptions {
313
311
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
314
- projectId?: number | string;
312
+ projectId?: number;
315
313
  /** Nome da variável (com ou sem :VAR_) */
316
314
  key: string;
317
315
  }
@@ -324,9 +322,9 @@ interface GetVariableResponse {
324
322
  }
325
323
  interface RunActionOptions {
326
324
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
327
- projectId?: number | string;
325
+ projectId?: number;
328
326
  /** ID da Action a executar */
329
- actionId: number | string;
327
+ actionId: number;
330
328
  /** Parâmetros de entrada para a action (opcional) */
331
329
  input?: Record<string, unknown>;
332
330
  }
@@ -340,7 +338,7 @@ interface RunActionResponse {
340
338
  }
341
339
  interface CallIntegrationOptions {
342
340
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
343
- projectId?: number | string;
341
+ projectId?: number;
344
342
  /** Slug da integração configurada no painel */
345
343
  connection: string;
346
344
  /** Método HTTP: GET, POST, PUT, DELETE */
@@ -360,11 +358,11 @@ interface CallIntegrationResponse {
360
358
  }
361
359
  interface ListIntegrationsOptions {
362
360
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
363
- projectId?: number | string;
361
+ projectId?: number;
364
362
  }
365
363
  interface IntegrationResponse {
366
364
  id: string;
367
- projectId: number | string;
365
+ projectId: number;
368
366
  name: string;
369
367
  slug: string;
370
368
  blueprintId: string | null;
@@ -378,7 +376,7 @@ interface IntegrationResponse {
378
376
  }
379
377
  interface StopServerFunctionExecutionOptions {
380
378
  /** ID do projeto (opcional se já configurado via configureSdkMitra) */
381
- projectId?: number | string;
379
+ projectId?: number;
382
380
  /** ID da execução a ser parada */
383
381
  executionId: string;
384
382
  }
@@ -390,87 +388,87 @@ interface StopServerFunctionExecutionResponse {
390
388
  };
391
389
  }
392
390
  interface ListProfilesOptions {
393
- projectId?: number | string;
391
+ projectId?: number;
394
392
  }
395
393
  interface ListProfilesResponse {
396
394
  status: string;
397
- projectId: number | string;
395
+ projectId: number;
398
396
  result: {
399
- id: number | string;
397
+ id: number;
400
398
  name: string;
401
399
  color: string;
402
- homeScreenId: number | string;
400
+ homeScreenId: number;
403
401
  }[];
404
402
  }
405
403
  interface GetProfileDetailsOptions {
406
- projectId?: number | string;
407
- profileId: number | string;
404
+ projectId?: number;
405
+ profileId: number;
408
406
  }
409
407
  interface GetProfileDetailsResponse {
410
408
  status: string;
411
- projectId: number | string;
409
+ projectId: number;
412
410
  result: {
413
- id: number | string;
411
+ id: number;
414
412
  name: string;
415
413
  users: {
416
- id: number | string;
414
+ id: number;
417
415
  name: string;
418
416
  email: string;
419
417
  }[];
420
418
  selectTables: {
421
419
  tableName: string;
422
- jdbcConnectionConfigId?: number | string;
420
+ jdbcConnectionConfigId?: number;
423
421
  }[];
424
422
  dmlTables: {
425
423
  tableName: string;
426
- jdbcConnectionConfigId?: number | string;
424
+ jdbcConnectionConfigId?: number;
427
425
  }[];
428
426
  actions: {
429
- id: number | string;
427
+ id: number;
430
428
  name: string;
431
429
  }[];
432
430
  screens: {
433
- id: number | string;
431
+ id: number;
434
432
  name: string;
435
433
  }[];
436
434
  serverFunctions: {
437
- id: number | string;
435
+ id: number;
438
436
  name: string;
439
437
  }[];
440
438
  };
441
439
  }
442
440
  interface CreateProfileOptions {
443
- projectId?: number | string;
441
+ projectId?: number;
444
442
  name: string;
445
443
  color?: string;
446
- homeScreenId?: number | string;
444
+ homeScreenId?: number;
447
445
  }
448
446
  interface CreateProfileResponse {
449
447
  status: string;
450
448
  result: {
451
- id: number | string;
449
+ id: number;
452
450
  name: string;
453
451
  message: string;
454
452
  };
455
453
  }
456
454
  interface UpdateProfileOptions {
457
- projectId?: number | string;
458
- profileId: number | string;
455
+ projectId?: number;
456
+ profileId: number;
459
457
  name?: string;
460
458
  color?: string;
461
- homeScreenId?: number | string;
459
+ homeScreenId?: number;
462
460
  }
463
461
  interface UpdateProfileResponse {
464
462
  status: string;
465
463
  result: {
466
- id: number | string;
464
+ id: number;
467
465
  name: string;
468
466
  message: string;
469
467
  };
470
468
  }
471
469
  interface DeleteProfileOptions {
472
- projectId?: number | string;
473
- profileId: number | string;
470
+ projectId?: number;
471
+ profileId: number;
474
472
  }
475
473
  interface DeleteProfileResponse {
476
474
  status: string;
@@ -479,44 +477,44 @@ interface DeleteProfileResponse {
479
477
  };
480
478
  }
481
479
  interface SetProfileUsersOptions {
482
- projectId?: number | string;
483
- profileId: number | string;
480
+ projectId?: number;
481
+ profileId: number;
484
482
  userIds: number[];
485
483
  }
486
484
  interface ProfileTableRef {
487
485
  tableName: string;
488
486
  }
489
487
  interface SetProfileSelectTablesOptions {
490
- projectId?: number | string;
491
- profileId: number | string;
492
- jdbcConnectionConfigId?: number | string;
488
+ projectId?: number;
489
+ profileId: number;
490
+ jdbcConnectionConfigId?: number;
493
491
  tables: ProfileTableRef[];
494
492
  }
495
493
  interface SetProfileDmlTablesOptions {
496
- projectId?: number | string;
497
- profileId: number | string;
498
- jdbcConnectionConfigId?: number | string;
494
+ projectId?: number;
495
+ profileId: number;
496
+ jdbcConnectionConfigId?: number;
499
497
  tables: ProfileTableRef[];
500
498
  }
501
499
  interface SetProfileActionsOptions {
502
- projectId?: number | string;
503
- profileId: number | string;
500
+ projectId?: number;
501
+ profileId: number;
504
502
  actionIds: number[];
505
503
  }
506
504
  interface SetProfileScreensOptions {
507
- projectId?: number | string;
508
- profileId: number | string;
505
+ projectId?: number;
506
+ profileId: number;
509
507
  screenIds: number[];
510
508
  }
511
509
  interface SetProfileServerFunctionsOptions {
512
- projectId?: number | string;
513
- profileId: number | string;
510
+ projectId?: number;
511
+ profileId: number;
514
512
  serverFunctionIds: number[];
515
513
  }
516
514
  interface SetProfilePermissionResponse {
517
515
  status: string;
518
516
  result: {
519
- profileId: number | string;
517
+ profileId: number;
520
518
  message: string;
521
519
  [key: string]: unknown;
522
520
  };
@@ -542,7 +540,7 @@ type ChatManageAction = 'list' | 'rename' | 'delete';
542
540
  interface ManageAgentChatListOptions {
543
541
  action: 'list';
544
542
  /** Sobrescreve o projectId configurado globalmente. */
545
- projectId?: number | string;
543
+ projectId?: number;
546
544
  }
547
545
  interface ManageAgentChatRenameOptions {
548
546
  action: 'rename';
@@ -566,7 +564,7 @@ interface GetAgentTaskCreateOptions {
566
564
  /** Cria chat novo. taskId é preenchido depois do primeiro send(). */
567
565
  create: true;
568
566
  /** Sobrescreve projectId global. */
569
- projectId?: number | string;
567
+ projectId?: number;
570
568
  /** Tipo do agente. Default: 'claudecode'. */
571
569
  agentType?: AgentType;
572
570
  /**
@@ -911,14 +909,12 @@ interface MitraConfig {
911
909
  baseURL?: string;
912
910
  /** Token JWT para autenticação (opcional para Server Functions públicas) */
913
911
  token?: string;
914
- /** Refresh token (novo Mitra). Necessário para refresh automático no novo mundo. */
915
- refreshToken?: string;
916
912
  /** URL base do serviço de integrações (ex: https://api0.mitraecp.com:1003) */
917
913
  integrationURL?: string;
918
914
  /** URL da página de autenticação Mitra (ex: https://coder.mitralab.io/sdk-auth/) */
919
915
  authUrl?: string;
920
916
  /** ID do projeto (usado como fallback nos métodos de login e serviços) */
921
- projectId?: number | string;
917
+ projectId?: number;
922
918
  /** Callback chamado quando o token é renovado automaticamente (após 401/403). Recebe a nova sessão. */
923
919
  onTokenRefresh?: (session: LoginResponse) => void;
924
920
  }
@@ -937,7 +933,7 @@ declare function getConfig(): MitraConfig;
937
933
  /**
938
934
  * Resolve projectId: usa o valor passado, senão pega do config salvo.
939
935
  */
940
- declare function resolveProjectId(projectId?: number | string): number | string;
936
+ declare function resolveProjectId(projectId?: number): number;
941
937
 
942
938
  /**
943
939
  * Mitra Interactions SDK - Chat Integration
@@ -956,24 +952,56 @@ declare function openChatMitra(): void;
956
952
  declare function closeChatMitra(): void;
957
953
 
958
954
  /**
959
- * Mitra Interactions SDK - Autenticação (Router)
960
- *
961
- * Roteia chamadas de auth para a implementação correta com base no `authUrl`:
962
- * - URLs legadas (`coder.mitralab.io/sdk-auth/`, `agent.mitralab.io/sdk-auth/`) → auth-legacy.ts
963
- * - Qualquer outro authUrl → auth-new.ts (novo Mitra: Kong gateway + IAM service)
955
+ * Mitra Interactions SDK - Autenticação
964
956
  *
965
- * A API pública é idêntica à legacy. Consumers não precisam alterar código.
957
+ * Login via popup seguro hospedado no domínio Mitra.
958
+ * Credenciais nunca passam pelo código do desenvolvedor.
966
959
  */
967
960
 
968
- declare function loginMitra(method: 'email' | 'google' | 'microsoft' | 'mitra', options?: LoginOptions): Promise<LoginResponse>;
961
+ /**
962
+ * Login com email e senha via popup/redirect seguro Mitra.
963
+ */
969
964
  declare function loginWithEmailMitra(options?: LoginOptions): Promise<LoginResponse>;
965
+ /**
966
+ * Login com Google via popup/redirect seguro Mitra.
967
+ */
970
968
  declare function loginWithGoogleMitra(options?: LoginOptions): Promise<LoginResponse>;
969
+ /**
970
+ * Login com Microsoft via popup/redirect seguro Mitra.
971
+ */
971
972
  declare function loginWithMicrosoftMitra(options?: LoginOptions): Promise<LoginResponse>;
973
+ /**
974
+ * Login genérico via popup/redirect seguro Mitra.
975
+ */
976
+ declare function loginMitra(method: 'email' | 'google' | 'microsoft' | 'mitra', options?: LoginOptions): Promise<LoginResponse>;
977
+ /**
978
+ * Renova o token silenciosamente via iframe invisível.
979
+ * Se já houver um refresh em andamento, reaproveita a mesma promise.
980
+ */
981
+ declare function refreshTokenSilently(authUrl: string, projectId: number): Promise<LoginResponse>;
982
+ /**
983
+ * Cria conta via email usando iframe silencioso.
984
+ * Após sucesso, o usuário recebe um código de verificação por email.
985
+ * Fluxo: emailSignupMitra → emailVerifyCodeMitra → emailLoginMitra
986
+ */
972
987
  declare function emailSignupMitra(options: EmailSignupOptions): Promise<void>;
973
- declare function emailLoginMitra(options: EmailLoginOptions): Promise<LoginResponse>;
988
+ /**
989
+ * Verifica o código de 6 dígitos enviado por email após signup.
990
+ * Após verificação, faz login automático e retorna LoginResponse.
991
+ * Auto-configura o SDK após sucesso.
992
+ */
974
993
  declare function emailVerifyCodeMitra(options: EmailVerifyCodeOptions): Promise<LoginResponse>;
994
+ /**
995
+ * Reenvia o código de verificação para o email.
996
+ */
975
997
  declare function emailResendCodeMitra(options: EmailResendCodeOptions): Promise<void>;
976
- declare function refreshTokenSilently(authUrl: string, projectId: number | string): Promise<LoginResponse>;
998
+ /**
999
+ * Login via email e senha usando iframe silencioso.
1000
+ * O HTML de auth faz a chamada à API e resolve as credenciais do projeto.
1001
+ * Retorna LoginResponse com token, baseURL e integrationURL.
1002
+ * Auto-configura o SDK após sucesso.
1003
+ */
1004
+ declare function emailLoginMitra(options: EmailLoginOptions): Promise<LoginResponse>;
977
1005
 
978
1006
  /**
979
1007
  * Mitra Interactions SDK - Password Reset (legacy backend)