mitra-interactions-sdk 1.0.36 → 1.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -159
- package/dist/index.d.mts +217 -33
- package/dist/index.d.ts +217 -33
- package/dist/index.js +199 -117
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +189 -117
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Mitra Interactions SDK
|
|
2
2
|
|
|
3
|
-
SDK para interações com a plataforma Mitra via endpoints `/
|
|
3
|
+
SDK para interações com a plataforma Mitra via endpoints `/interactions/`.
|
|
4
4
|
|
|
5
5
|
## Instalação
|
|
6
6
|
|
|
@@ -46,7 +46,7 @@ await instance.executeServerFunction({ serverFunctionId: 42 }); // OK — sem to
|
|
|
46
46
|
`configureSdkMitra` retorna uma `MitraInstance` que também pode ser usada diretamente:
|
|
47
47
|
|
|
48
48
|
```typescript
|
|
49
|
-
await instance.
|
|
49
|
+
await instance.executeServerFunction({ serverFunctionId: 42 }); // projectId já vem do configureSdkMitra
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
## Autenticação (Login)
|
|
@@ -91,7 +91,7 @@ await loginMitra('mitra', {
|
|
|
91
91
|
Navega o usuário para a página de auth. Após o login, redireciona de volta com token nos query params.
|
|
92
92
|
|
|
93
93
|
```typescript
|
|
94
|
-
import { loginMitra
|
|
94
|
+
import { loginMitra } from 'mitra-interactions-sdk';
|
|
95
95
|
|
|
96
96
|
// Iniciar login — o navegador navega para fora da página
|
|
97
97
|
await loginMitra('google', {
|
|
@@ -114,25 +114,6 @@ await loginMitra('mitra', {
|
|
|
114
114
|
});
|
|
115
115
|
```
|
|
116
116
|
|
|
117
|
-
### Processar Retorno do Redirect
|
|
118
|
-
|
|
119
|
-
Após o redirect, a página de destino deve chamar `handleAuthRedirect()` para capturar o token:
|
|
120
|
-
|
|
121
|
-
```typescript
|
|
122
|
-
import { handleAuthRedirect, configureSdkMitra } from 'mitra-interactions-sdk';
|
|
123
|
-
|
|
124
|
-
// No mounted/onLoad da página de retorno
|
|
125
|
-
const session = handleAuthRedirect();
|
|
126
|
-
if (session) {
|
|
127
|
-
// Login OK — session: { token, baseURL, integrationURL? }
|
|
128
|
-
configureSdkMitra({
|
|
129
|
-
baseURL: session.baseURL,
|
|
130
|
-
token: session.token,
|
|
131
|
-
integrationURL: session.integrationURL
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
117
|
### Token Refresh Automático
|
|
137
118
|
|
|
138
119
|
Quando qualquer requisição retorna **403**, o SDK tenta renovar o token automaticamente via iframe invisível (usa o cookie de sessão do provider). Se o refresh funcionar, a requisição é retentada com o novo token — transparente para o desenvolvedor.
|
|
@@ -227,24 +208,6 @@ await executeDbActionMitra({ dbActionId: 1 });
|
|
|
227
208
|
|
|
228
209
|
## Métodos Disponíveis
|
|
229
210
|
|
|
230
|
-
### executeDbActionMitra
|
|
231
|
-
|
|
232
|
-
Executa uma DBAction (DML) cadastrada.
|
|
233
|
-
|
|
234
|
-
```typescript
|
|
235
|
-
import { executeDbActionMitra } from 'mitra-interactions-sdk';
|
|
236
|
-
|
|
237
|
-
const result = await executeDbActionMitra({
|
|
238
|
-
projectId: 123,
|
|
239
|
-
dbActionId: 456,
|
|
240
|
-
params: { // Opcional
|
|
241
|
-
campo1: 'valor1',
|
|
242
|
-
campo2: 'valor2'
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
// result: { status, result: { rowsAffected: number } }
|
|
246
|
-
```
|
|
247
|
-
|
|
248
211
|
### executeServerFunctionMitra
|
|
249
212
|
|
|
250
213
|
Executa uma Server Function de forma **síncrona** (timeout de 60s no backend). Retorna o resultado diretamente.
|
|
@@ -293,39 +256,6 @@ const result = await stopServerFunctionExecutionMitra({
|
|
|
293
256
|
// result: { status, result: { executionId, executionStatus: "CANCELLED" | "ALREADY_FINISHED" } }
|
|
294
257
|
```
|
|
295
258
|
|
|
296
|
-
### Integrações
|
|
297
|
-
|
|
298
|
-
> **Requisito:** A `integrationURL` deve ser configurada via `configureSdkMitra({ ..., integrationURL: 'https://api0.mitraecp.com:1003' })`.
|
|
299
|
-
|
|
300
|
-
#### listIntegrationsMitra
|
|
301
|
-
|
|
302
|
-
Lista as integrações configuradas no projeto.
|
|
303
|
-
|
|
304
|
-
```typescript
|
|
305
|
-
import { listIntegrationsMitra } from 'mitra-interactions-sdk';
|
|
306
|
-
|
|
307
|
-
const integrations = await listIntegrationsMitra({ projectId: 123 });
|
|
308
|
-
// result: IntegrationResponse[] — [{ id, projectId, name, slug, blueprintId, blueprintType, authType, credentials, status, lastCheckedAt, createdAt, updatedAt }]
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
#### callIntegrationMitra
|
|
312
|
-
|
|
313
|
-
Chama uma integração configurada, delegando a requisição ao serviço externo.
|
|
314
|
-
|
|
315
|
-
```typescript
|
|
316
|
-
import { callIntegrationMitra } from 'mitra-interactions-sdk';
|
|
317
|
-
|
|
318
|
-
const result = await callIntegrationMitra({
|
|
319
|
-
projectId: 123,
|
|
320
|
-
connection: 'meu-erp', // Slug da integração
|
|
321
|
-
method: 'GET', // GET, POST, PUT, DELETE
|
|
322
|
-
endpoint: '/api/v1/pedidos', // Path no serviço externo (opcional)
|
|
323
|
-
params: { status: 'ativo' }, // Query params (opcional)
|
|
324
|
-
body: { nome: 'Teste' } // Body para POST/PUT (opcional)
|
|
325
|
-
});
|
|
326
|
-
// result: { statusCode: number, body: any }
|
|
327
|
-
```
|
|
328
|
-
|
|
329
259
|
### uploadFilePublicMitra / uploadFileLoadableMitra
|
|
330
260
|
|
|
331
261
|
Faz upload de um arquivo diretamente para a pasta PUBLIC ou LOADABLE do projeto. Usa `multipart/form-data`.
|
|
@@ -348,75 +278,6 @@ const result2 = await uploadFileLoadableMitra({
|
|
|
348
278
|
// result2: { status, result: { fileName, currentPath, publicUrl: null, message } }
|
|
349
279
|
```
|
|
350
280
|
|
|
351
|
-
### setFileStatusMitra
|
|
352
|
-
|
|
353
|
-
Move arquivo do chat para PUBLIC ou LOADABLE.
|
|
354
|
-
|
|
355
|
-
```typescript
|
|
356
|
-
import { setFileStatusMitra } from 'mitra-interactions-sdk';
|
|
357
|
-
|
|
358
|
-
const result = await setFileStatusMitra({
|
|
359
|
-
projectId: 123,
|
|
360
|
-
fileName: 'arquivo.jpg',
|
|
361
|
-
targetPath: 'PUBLIC' // 'PUBLIC' ou 'LOADABLE'
|
|
362
|
-
});
|
|
363
|
-
// result: { status, result: { fileName, currentPath, publicUrl, message } }
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
### setVariableMitra
|
|
367
|
-
|
|
368
|
-
Cria ou atualiza uma variável customizada.
|
|
369
|
-
|
|
370
|
-
```typescript
|
|
371
|
-
import { setVariableMitra } from 'mitra-interactions-sdk';
|
|
372
|
-
|
|
373
|
-
const result = await setVariableMitra({
|
|
374
|
-
projectId: 123,
|
|
375
|
-
key: 'minhaVariavel',
|
|
376
|
-
value: 'meuValor' // Opcional
|
|
377
|
-
});
|
|
378
|
-
// result: { status, result: { key, value } }
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
### listVariablesMitra
|
|
382
|
-
|
|
383
|
-
Lista variáveis de um projeto.
|
|
384
|
-
|
|
385
|
-
```typescript
|
|
386
|
-
import { listVariablesMitra } from 'mitra-interactions-sdk';
|
|
387
|
-
|
|
388
|
-
const result = await listVariablesMitra({ projectId: 123 });
|
|
389
|
-
// result: { status, projectId, result: [{ key, value }] }
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
### getVariableMitra
|
|
393
|
-
|
|
394
|
-
Busca o valor de uma variável específica.
|
|
395
|
-
|
|
396
|
-
```typescript
|
|
397
|
-
import { getVariableMitra } from 'mitra-interactions-sdk';
|
|
398
|
-
|
|
399
|
-
const result = await getVariableMitra({ projectId: 123, key: 'minhaVariavel' });
|
|
400
|
-
// result: { status, result: { key, value } }
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
### runActionMitra
|
|
404
|
-
|
|
405
|
-
Executa uma Action (fluxo de ação Low-Code) cadastrada.
|
|
406
|
-
|
|
407
|
-
```typescript
|
|
408
|
-
import { runActionMitra } from 'mitra-interactions-sdk';
|
|
409
|
-
|
|
410
|
-
const result = await runActionMitra({
|
|
411
|
-
projectId: 123,
|
|
412
|
-
actionId: 456,
|
|
413
|
-
params: { // Opcional
|
|
414
|
-
campo1: 'valor1'
|
|
415
|
-
}
|
|
416
|
-
});
|
|
417
|
-
// result: { status, executionTime, result: { stepsExecuted, message } }
|
|
418
|
-
```
|
|
419
|
-
|
|
420
281
|
### Dynamic Schema CRUD
|
|
421
282
|
|
|
422
283
|
CRUD completo em tabelas do projeto via Dynamic Schema (usa header `X-TenantID`).
|
|
@@ -468,6 +329,65 @@ const result2 = await listRecordsMitra({
|
|
|
468
329
|
});
|
|
469
330
|
```
|
|
470
331
|
|
|
332
|
+
### Profile Management
|
|
333
|
+
|
|
334
|
+
Gerenciamento de perfis de acesso. Permite gestão de quem pode acessar quais recursos no projeto.
|
|
335
|
+
|
|
336
|
+
#### CRUD de Perfis
|
|
337
|
+
|
|
338
|
+
- `listProfilesMitra({ projectId? })` → `ListProfilesResponse` - Lista todos os perfis do projeto
|
|
339
|
+
- `getProfileDetailsMitra({ projectId?, profileId })` → `GetProfileDetailsResponse` - Detalhes de um perfil (usuários, tabelas, actions, screens, server functions)
|
|
340
|
+
- `createProfileMitra({ projectId?, name, color?, homeScreenId? })` → `CreateProfileResponse` - Cria um novo perfil
|
|
341
|
+
- `updateProfileMitra({ projectId?, profileId, name?, color?, homeScreenId? })` → `UpdateProfileResponse` - Atualiza um perfil existente
|
|
342
|
+
- `deleteProfileMitra({ projectId?, profileId })` → `DeleteProfileResponse` - Deleta um perfil
|
|
343
|
+
|
|
344
|
+
```typescript
|
|
345
|
+
import { listProfilesMitra, createProfileMitra, getProfileDetailsMitra } from 'mitra-interactions-sdk';
|
|
346
|
+
|
|
347
|
+
// Listar perfis
|
|
348
|
+
const profiles = await listProfilesMitra({ projectId: 123 });
|
|
349
|
+
// { status, projectId, result: [{ id, name, color, homeScreenId }] }
|
|
350
|
+
|
|
351
|
+
// Criar perfil
|
|
352
|
+
const created = await createProfileMitra({ projectId: 123, name: 'Vendedores', color: '#FF5733' });
|
|
353
|
+
// { status, result: { id, name, message } }
|
|
354
|
+
|
|
355
|
+
// Detalhes do perfil
|
|
356
|
+
const details = await getProfileDetailsMitra({ projectId: 123, profileId: 1 });
|
|
357
|
+
// { status, projectId, result: { id, name, users, selectTables, dmlTables, actions, screens, serverFunctions } }
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
#### Permissões de Perfil
|
|
361
|
+
|
|
362
|
+
Define quais recursos cada perfil pode acessar. Todas substituem a lista atual (não fazem append).
|
|
363
|
+
|
|
364
|
+
- `setProfileUsersMitra({ projectId?, profileId, userIds })` - Define os usuários do perfil
|
|
365
|
+
- `setProfileSelectTablesMitra({ projectId?, profileId, tables })` - Define tabelas SELECT permitidas
|
|
366
|
+
- `setProfileDmlTablesMitra({ projectId?, profileId, tables })` - Define tabelas DML permitidas
|
|
367
|
+
- `setProfileActionsMitra({ projectId?, profileId, actionIds })` - Define actions permitidas
|
|
368
|
+
- `setProfileScreensMitra({ projectId?, profileId, screenIds })` - Define screens permitidas
|
|
369
|
+
- `setProfileServerFunctionsMitra({ projectId?, profileId, serverFunctionIds })` - Define server functions permitidas
|
|
370
|
+
|
|
371
|
+
```typescript
|
|
372
|
+
import { setProfileUsersMitra, setProfileSelectTablesMitra, setProfileServerFunctionsMitra } from 'mitra-interactions-sdk';
|
|
373
|
+
|
|
374
|
+
// Definir usuários do perfil
|
|
375
|
+
await setProfileUsersMitra({ projectId: 123, profileId: 1, userIds: [10, 20, 30] });
|
|
376
|
+
|
|
377
|
+
// Definir tabelas SELECT
|
|
378
|
+
await setProfileSelectTablesMitra({
|
|
379
|
+
projectId: 123,
|
|
380
|
+
profileId: 1,
|
|
381
|
+
tables: [
|
|
382
|
+
{ tableName: 'clientes', jdbcConnectionConfigId: 1 },
|
|
383
|
+
{ tableName: 'pedidos', jdbcConnectionConfigId: 1 }
|
|
384
|
+
]
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
// Definir server functions
|
|
388
|
+
await setProfileServerFunctionsMitra({ projectId: 123, profileId: 1, serverFunctionIds: [5, 8, 12] });
|
|
389
|
+
```
|
|
390
|
+
|
|
471
391
|
## Tipos TypeScript
|
|
472
392
|
|
|
473
393
|
Todos os tipos estão incluídos:
|
|
@@ -484,18 +404,10 @@ import type {
|
|
|
484
404
|
EmailVerifyCodeOptions,
|
|
485
405
|
EmailResendCodeOptions,
|
|
486
406
|
// Options
|
|
487
|
-
ExecuteDbActionOptions,
|
|
488
407
|
ExecuteServerFunctionOptions,
|
|
489
408
|
ExecuteServerFunctionAsyncOptions,
|
|
490
|
-
ListIntegrationsOptions,
|
|
491
|
-
CallIntegrationOptions,
|
|
492
409
|
UploadFileOptions,
|
|
493
410
|
StopServerFunctionExecutionOptions,
|
|
494
|
-
SetFileStatusOptions,
|
|
495
|
-
SetVariableOptions,
|
|
496
|
-
ListVariablesOptions,
|
|
497
|
-
GetVariableOptions,
|
|
498
|
-
RunActionOptions,
|
|
499
411
|
ListRecordsOptions,
|
|
500
412
|
GetRecordOptions,
|
|
501
413
|
CreateRecordOptions,
|
|
@@ -504,19 +416,30 @@ import type {
|
|
|
504
416
|
DeleteRecordOptions,
|
|
505
417
|
CreateRecordsBatchOptions,
|
|
506
418
|
// Responses
|
|
507
|
-
ExecuteDbActionResponse,
|
|
508
|
-
SetFileStatusResponse,
|
|
509
|
-
SetVariableResponse,
|
|
510
|
-
ListVariablesResponse,
|
|
511
|
-
GetVariableResponse,
|
|
512
|
-
RunActionResponse,
|
|
513
419
|
ExecuteServerFunctionResponse,
|
|
514
420
|
ExecuteServerFunctionAsyncResponse,
|
|
515
|
-
IntegrationResponse,
|
|
516
|
-
CallIntegrationResponse,
|
|
517
421
|
UploadFileResponse,
|
|
518
422
|
StopServerFunctionExecutionResponse,
|
|
519
|
-
ListRecordsResponse
|
|
423
|
+
ListRecordsResponse,
|
|
424
|
+
// Profile Management
|
|
425
|
+
ListProfilesOptions,
|
|
426
|
+
ListProfilesResponse,
|
|
427
|
+
GetProfileDetailsOptions,
|
|
428
|
+
GetProfileDetailsResponse,
|
|
429
|
+
CreateProfileOptions,
|
|
430
|
+
CreateProfileResponse,
|
|
431
|
+
UpdateProfileOptions,
|
|
432
|
+
UpdateProfileResponse,
|
|
433
|
+
DeleteProfileOptions,
|
|
434
|
+
DeleteProfileResponse,
|
|
435
|
+
SetProfileUsersOptions,
|
|
436
|
+
SetProfileSelectTablesOptions,
|
|
437
|
+
SetProfileDmlTablesOptions,
|
|
438
|
+
SetProfileActionsOptions,
|
|
439
|
+
SetProfileScreensOptions,
|
|
440
|
+
SetProfileServerFunctionsOptions,
|
|
441
|
+
ProfileTableRef,
|
|
442
|
+
SetProfilePermissionResponse
|
|
520
443
|
} from 'mitra-interactions-sdk';
|
|
521
444
|
```
|
|
522
445
|
|
package/dist/index.d.mts
CHANGED
|
@@ -85,8 +85,8 @@ interface ExecuteDbActionOptions {
|
|
|
85
85
|
projectId?: number;
|
|
86
86
|
/** ID da DBAction cadastrada */
|
|
87
87
|
dbActionId: number;
|
|
88
|
-
/**
|
|
89
|
-
|
|
88
|
+
/** Parâmetros de entrada (opcional) — substituição de variáveis no SQL (ex: { "nome": "João" } substitui :nome) */
|
|
89
|
+
input?: Record<string, unknown>;
|
|
90
90
|
}
|
|
91
91
|
interface ExecuteDbActionResponse {
|
|
92
92
|
status: string;
|
|
@@ -260,8 +260,8 @@ interface RunActionOptions {
|
|
|
260
260
|
projectId?: number;
|
|
261
261
|
/** ID da Action a executar */
|
|
262
262
|
actionId: number;
|
|
263
|
-
/**
|
|
264
|
-
|
|
263
|
+
/** Parâmetros de entrada para a action (opcional) */
|
|
264
|
+
input?: Record<string, unknown>;
|
|
265
265
|
}
|
|
266
266
|
interface RunActionResponse {
|
|
267
267
|
status: string;
|
|
@@ -322,6 +322,137 @@ interface StopServerFunctionExecutionResponse {
|
|
|
322
322
|
executionStatus: string;
|
|
323
323
|
};
|
|
324
324
|
}
|
|
325
|
+
interface ListProfilesOptions {
|
|
326
|
+
projectId?: number;
|
|
327
|
+
}
|
|
328
|
+
interface ListProfilesResponse {
|
|
329
|
+
status: string;
|
|
330
|
+
projectId: number;
|
|
331
|
+
result: {
|
|
332
|
+
id: number;
|
|
333
|
+
name: string;
|
|
334
|
+
color: string;
|
|
335
|
+
homeScreenId: number;
|
|
336
|
+
}[];
|
|
337
|
+
}
|
|
338
|
+
interface GetProfileDetailsOptions {
|
|
339
|
+
projectId?: number;
|
|
340
|
+
profileId: number;
|
|
341
|
+
}
|
|
342
|
+
interface GetProfileDetailsResponse {
|
|
343
|
+
status: string;
|
|
344
|
+
projectId: number;
|
|
345
|
+
result: {
|
|
346
|
+
id: number;
|
|
347
|
+
name: string;
|
|
348
|
+
users: {
|
|
349
|
+
id: number;
|
|
350
|
+
name: string;
|
|
351
|
+
email: string;
|
|
352
|
+
}[];
|
|
353
|
+
selectTables: {
|
|
354
|
+
tableName: string;
|
|
355
|
+
jdbcConnectionConfigId?: number;
|
|
356
|
+
}[];
|
|
357
|
+
dmlTables: {
|
|
358
|
+
tableName: string;
|
|
359
|
+
jdbcConnectionConfigId?: number;
|
|
360
|
+
}[];
|
|
361
|
+
actions: {
|
|
362
|
+
id: number;
|
|
363
|
+
name: string;
|
|
364
|
+
}[];
|
|
365
|
+
screens: {
|
|
366
|
+
id: number;
|
|
367
|
+
name: string;
|
|
368
|
+
}[];
|
|
369
|
+
serverFunctions: {
|
|
370
|
+
id: number;
|
|
371
|
+
name: string;
|
|
372
|
+
}[];
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
interface CreateProfileOptions {
|
|
376
|
+
projectId?: number;
|
|
377
|
+
name: string;
|
|
378
|
+
color?: string;
|
|
379
|
+
homeScreenId?: number;
|
|
380
|
+
}
|
|
381
|
+
interface CreateProfileResponse {
|
|
382
|
+
status: string;
|
|
383
|
+
result: {
|
|
384
|
+
id: number;
|
|
385
|
+
name: string;
|
|
386
|
+
message: string;
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
interface UpdateProfileOptions {
|
|
390
|
+
projectId?: number;
|
|
391
|
+
profileId: number;
|
|
392
|
+
name?: string;
|
|
393
|
+
color?: string;
|
|
394
|
+
homeScreenId?: number;
|
|
395
|
+
}
|
|
396
|
+
interface UpdateProfileResponse {
|
|
397
|
+
status: string;
|
|
398
|
+
result: {
|
|
399
|
+
id: number;
|
|
400
|
+
name: string;
|
|
401
|
+
message: string;
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
interface DeleteProfileOptions {
|
|
405
|
+
projectId?: number;
|
|
406
|
+
profileId: number;
|
|
407
|
+
}
|
|
408
|
+
interface DeleteProfileResponse {
|
|
409
|
+
status: string;
|
|
410
|
+
result: {
|
|
411
|
+
message: string;
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
interface SetProfileUsersOptions {
|
|
415
|
+
projectId?: number;
|
|
416
|
+
profileId: number;
|
|
417
|
+
userIds: number[];
|
|
418
|
+
}
|
|
419
|
+
interface ProfileTableRef {
|
|
420
|
+
tableName: string;
|
|
421
|
+
jdbcConnectionConfigId: number;
|
|
422
|
+
}
|
|
423
|
+
interface SetProfileSelectTablesOptions {
|
|
424
|
+
projectId?: number;
|
|
425
|
+
profileId: number;
|
|
426
|
+
tables: ProfileTableRef[];
|
|
427
|
+
}
|
|
428
|
+
interface SetProfileDmlTablesOptions {
|
|
429
|
+
projectId?: number;
|
|
430
|
+
profileId: number;
|
|
431
|
+
tables: ProfileTableRef[];
|
|
432
|
+
}
|
|
433
|
+
interface SetProfileActionsOptions {
|
|
434
|
+
projectId?: number;
|
|
435
|
+
profileId: number;
|
|
436
|
+
actionIds: number[];
|
|
437
|
+
}
|
|
438
|
+
interface SetProfileScreensOptions {
|
|
439
|
+
projectId?: number;
|
|
440
|
+
profileId: number;
|
|
441
|
+
screenIds: number[];
|
|
442
|
+
}
|
|
443
|
+
interface SetProfileServerFunctionsOptions {
|
|
444
|
+
projectId?: number;
|
|
445
|
+
profileId: number;
|
|
446
|
+
serverFunctionIds: number[];
|
|
447
|
+
}
|
|
448
|
+
interface SetProfilePermissionResponse {
|
|
449
|
+
status: string;
|
|
450
|
+
result: {
|
|
451
|
+
profileId: number;
|
|
452
|
+
message: string;
|
|
453
|
+
[key: string]: unknown;
|
|
454
|
+
};
|
|
455
|
+
}
|
|
325
456
|
|
|
326
457
|
/**
|
|
327
458
|
* Mitra Interactions SDK - Instance
|
|
@@ -352,6 +483,17 @@ interface MitraInstance {
|
|
|
352
483
|
patchRecord(options: PatchRecordOptions): Promise<Record<string, any>>;
|
|
353
484
|
deleteRecord(options: DeleteRecordOptions): Promise<void>;
|
|
354
485
|
createRecordsBatch(options: CreateRecordsBatchOptions): Promise<Record<string, any>[]>;
|
|
486
|
+
listProfiles(options?: ListProfilesOptions): Promise<ListProfilesResponse>;
|
|
487
|
+
getProfileDetails(options: GetProfileDetailsOptions): Promise<GetProfileDetailsResponse>;
|
|
488
|
+
createProfile(options: CreateProfileOptions): Promise<CreateProfileResponse>;
|
|
489
|
+
updateProfile(options: UpdateProfileOptions): Promise<UpdateProfileResponse>;
|
|
490
|
+
deleteProfile(options: DeleteProfileOptions): Promise<DeleteProfileResponse>;
|
|
491
|
+
setProfileUsers(options: SetProfileUsersOptions): Promise<SetProfilePermissionResponse>;
|
|
492
|
+
setProfileSelectTables(options: SetProfileSelectTablesOptions): Promise<SetProfilePermissionResponse>;
|
|
493
|
+
setProfileDmlTables(options: SetProfileDmlTablesOptions): Promise<SetProfilePermissionResponse>;
|
|
494
|
+
setProfileActions(options: SetProfileActionsOptions): Promise<SetProfilePermissionResponse>;
|
|
495
|
+
setProfileScreens(options: SetProfileScreensOptions): Promise<SetProfilePermissionResponse>;
|
|
496
|
+
setProfileServerFunctions(options: SetProfileServerFunctionsOptions): Promise<SetProfilePermissionResponse>;
|
|
355
497
|
}
|
|
356
498
|
declare function createMitraInstance(initialConfig: Partial<MitraConfig>): MitraInstance;
|
|
357
499
|
|
|
@@ -405,19 +547,6 @@ declare function loginWithMicrosoftMitra(options?: LoginOptions): Promise<LoginR
|
|
|
405
547
|
* Login genérico via popup/redirect seguro Mitra.
|
|
406
548
|
*/
|
|
407
549
|
declare function loginMitra(method: 'email' | 'google' | 'microsoft' | 'mitra', options?: LoginOptions): Promise<LoginResponse>;
|
|
408
|
-
/**
|
|
409
|
-
* Processa o retorno de um login com mode 'redirect'.
|
|
410
|
-
*
|
|
411
|
-
* Após o redirect, a página de auth redireciona de volta com query params:
|
|
412
|
-
* ?tokenMitra={token}&backURLMitra={baseURL}&integrationURLMitra={integrationURL}
|
|
413
|
-
*
|
|
414
|
-
* Esta função:
|
|
415
|
-
* - Lê os query params da URL atual
|
|
416
|
-
* - Se `tokenMitra=error`, lança erro
|
|
417
|
-
* - Se encontrou tokens, limpa a URL e retorna LoginResponse
|
|
418
|
-
* - Se não encontrou nada, retorna null
|
|
419
|
-
*/
|
|
420
|
-
declare function handleAuthRedirect(): LoginResponse | null;
|
|
421
550
|
/**
|
|
422
551
|
* Renova o token silenciosamente via iframe invisível.
|
|
423
552
|
* Se já houver um refresh em andamento, reaproveita a mesma promise.
|
|
@@ -452,73 +581,73 @@ declare function emailLoginMitra(options: EmailLoginOptions): Promise<LoginRespo
|
|
|
452
581
|
*/
|
|
453
582
|
|
|
454
583
|
/**
|
|
455
|
-
* POST /
|
|
584
|
+
* POST /interactions/runQuery
|
|
456
585
|
* Executa query SELECT em um projeto
|
|
457
586
|
*/
|
|
458
587
|
declare function runQueryMitra(options: RunQueryOptions): Promise<RunQueryResponse>;
|
|
459
588
|
/**
|
|
460
|
-
* POST /
|
|
589
|
+
* POST /interactions/executeDbAction
|
|
461
590
|
* Executa uma DBAction (DML) cadastrada
|
|
462
591
|
*/
|
|
463
592
|
declare function executeDbActionMitra(options: ExecuteDbActionOptions): Promise<ExecuteDbActionResponse>;
|
|
464
593
|
/**
|
|
465
|
-
* POST /
|
|
594
|
+
* POST /interactions/setFileStatus
|
|
466
595
|
* Move arquivo do chat para PUBLIC ou LOADABLE
|
|
467
596
|
*/
|
|
468
597
|
declare function setFileStatusMitra(options: SetFileStatusOptions): Promise<SetFileStatusResponse>;
|
|
469
598
|
/**
|
|
470
|
-
* POST /
|
|
599
|
+
* POST /interactions/setVariable
|
|
471
600
|
* Cria ou atualiza uma variável customizada
|
|
472
601
|
*/
|
|
473
602
|
declare function setVariableMitra(options: SetVariableOptions): Promise<SetVariableResponse>;
|
|
474
603
|
/**
|
|
475
|
-
* GET /
|
|
604
|
+
* GET /interactions/listVariables?projectId={id}
|
|
476
605
|
* Lista variáveis de um projeto
|
|
477
606
|
*/
|
|
478
607
|
declare function listVariablesMitra(options?: ListVariablesOptions): Promise<ListVariablesResponse>;
|
|
479
608
|
/**
|
|
480
|
-
* GET /
|
|
609
|
+
* GET /interactions/getVariable?projectId={id}&key={key}
|
|
481
610
|
* Busca o valor de uma variável específica
|
|
482
611
|
*/
|
|
483
612
|
declare function getVariableMitra(options: GetVariableOptions): Promise<GetVariableResponse>;
|
|
484
613
|
/**
|
|
485
|
-
* POST /
|
|
614
|
+
* POST /interactions/runAction
|
|
486
615
|
* Executa uma Action (fluxo de ação) cadastrada
|
|
487
616
|
*/
|
|
488
617
|
declare function runActionMitra(options: RunActionOptions): Promise<RunActionResponse>;
|
|
489
618
|
/**
|
|
490
|
-
* POST /
|
|
619
|
+
* POST /interactions/executeServerFunction
|
|
491
620
|
* Executa uma Server Function de forma SÍNCRONA (timeout 60s no backend)
|
|
492
621
|
*/
|
|
493
622
|
declare function executeServerFunctionMitra(options: ExecuteServerFunctionOptions): Promise<ExecuteServerFunctionResponse>;
|
|
494
623
|
/**
|
|
495
|
-
* POST /
|
|
624
|
+
* POST /interactions/executeServerFunctionAsync
|
|
496
625
|
* Executa uma Server Function de forma ASSÍNCRONA (retorna executionId imediatamente)
|
|
497
626
|
*/
|
|
498
627
|
declare function executeServerFunctionAsyncMitra(options: ExecuteServerFunctionAsyncOptions): Promise<ExecuteServerFunctionAsyncResponse>;
|
|
499
628
|
/**
|
|
500
|
-
* GET /
|
|
629
|
+
* GET /interactions/integrations?projectId=X
|
|
501
630
|
* Lista integrações configuradas no projeto
|
|
502
631
|
*/
|
|
503
632
|
declare function listIntegrationsMitra(options?: ListIntegrationsOptions): Promise<IntegrationResponse[]>;
|
|
504
633
|
/**
|
|
505
|
-
* POST /
|
|
506
|
-
* Chama uma API externa via serviço de integrações
|
|
634
|
+
* POST /interactions/integrations/call
|
|
635
|
+
* Chama uma API externa via serviço de integrações
|
|
507
636
|
* Mapeia connection → integrationSlug no body
|
|
508
637
|
*/
|
|
509
638
|
declare function callIntegrationMitra(options: CallIntegrationOptions): Promise<CallIntegrationResponse>;
|
|
510
639
|
/**
|
|
511
|
-
* POST /
|
|
640
|
+
* POST /interactions/stopServerFunctionExecution
|
|
512
641
|
* Para a execução de uma Server Function em andamento
|
|
513
642
|
*/
|
|
514
643
|
declare function stopServerFunctionExecutionMitra(options: StopServerFunctionExecutionOptions): Promise<StopServerFunctionExecutionResponse>;
|
|
515
644
|
/**
|
|
516
|
-
* POST /
|
|
645
|
+
* POST /interactions/uploadFilePublic (multipart/form-data)
|
|
517
646
|
* Faz upload de um arquivo para a pasta PUBLIC do projeto.
|
|
518
647
|
*/
|
|
519
648
|
declare function uploadFilePublicMitra(options: UploadFileOptions): Promise<UploadFileResponse>;
|
|
520
649
|
/**
|
|
521
|
-
* POST /
|
|
650
|
+
* POST /interactions/uploadFileLoadable (multipart/form-data)
|
|
522
651
|
* Faz upload de um arquivo para a pasta LOADABLE do projeto.
|
|
523
652
|
*/
|
|
524
653
|
declare function uploadFileLoadableMitra(options: UploadFileOptions): Promise<UploadFileResponse>;
|
|
@@ -529,5 +658,60 @@ declare function updateRecordMitra(options: UpdateRecordOptions): Promise<Record
|
|
|
529
658
|
declare function patchRecordMitra(options: PatchRecordOptions): Promise<Record<string, any>>;
|
|
530
659
|
declare function deleteRecordMitra(options: DeleteRecordOptions): Promise<void>;
|
|
531
660
|
declare function createRecordsBatchMitra(options: CreateRecordsBatchOptions): Promise<Record<string, any>[]>;
|
|
661
|
+
/**
|
|
662
|
+
* GET /interactions/profiles?projectId={id}
|
|
663
|
+
* Lista todos os perfis do projeto
|
|
664
|
+
*/
|
|
665
|
+
declare function listProfilesMitra(options?: ListProfilesOptions): Promise<ListProfilesResponse>;
|
|
666
|
+
/**
|
|
667
|
+
* GET /interactions/profiles/{profileId}?projectId={id}
|
|
668
|
+
* Detalhes de um perfil (usuários, tabelas, actions, screens, server functions)
|
|
669
|
+
*/
|
|
670
|
+
declare function getProfileDetailsMitra(options: GetProfileDetailsOptions): Promise<GetProfileDetailsResponse>;
|
|
671
|
+
/**
|
|
672
|
+
* POST /interactions/profiles
|
|
673
|
+
* Cria um novo perfil
|
|
674
|
+
*/
|
|
675
|
+
declare function createProfileMitra(options: CreateProfileOptions): Promise<CreateProfileResponse>;
|
|
676
|
+
/**
|
|
677
|
+
* PUT /interactions/profiles
|
|
678
|
+
* Atualiza um perfil existente
|
|
679
|
+
*/
|
|
680
|
+
declare function updateProfileMitra(options: UpdateProfileOptions): Promise<UpdateProfileResponse>;
|
|
681
|
+
/**
|
|
682
|
+
* DELETE /interactions/profiles
|
|
683
|
+
* Deleta um perfil
|
|
684
|
+
*/
|
|
685
|
+
declare function deleteProfileMitra(options: DeleteProfileOptions): Promise<DeleteProfileResponse>;
|
|
686
|
+
/**
|
|
687
|
+
* POST /interactions/profiles/users
|
|
688
|
+
* Define os usuários de um perfil (substitui lista atual)
|
|
689
|
+
*/
|
|
690
|
+
declare function setProfileUsersMitra(options: SetProfileUsersOptions): Promise<SetProfilePermissionResponse>;
|
|
691
|
+
/**
|
|
692
|
+
* POST /interactions/profiles/selectTables
|
|
693
|
+
* Define as tabelas SELECT permitidas por perfil
|
|
694
|
+
*/
|
|
695
|
+
declare function setProfileSelectTablesMitra(options: SetProfileSelectTablesOptions): Promise<SetProfilePermissionResponse>;
|
|
696
|
+
/**
|
|
697
|
+
* POST /interactions/profiles/dmlTables
|
|
698
|
+
* Define as tabelas DML permitidas por perfil
|
|
699
|
+
*/
|
|
700
|
+
declare function setProfileDmlTablesMitra(options: SetProfileDmlTablesOptions): Promise<SetProfilePermissionResponse>;
|
|
701
|
+
/**
|
|
702
|
+
* POST /interactions/profiles/actions
|
|
703
|
+
* Define as actions permitidas por perfil
|
|
704
|
+
*/
|
|
705
|
+
declare function setProfileActionsMitra(options: SetProfileActionsOptions): Promise<SetProfilePermissionResponse>;
|
|
706
|
+
/**
|
|
707
|
+
* POST /interactions/profiles/screens
|
|
708
|
+
* Define as screens permitidas por perfil
|
|
709
|
+
*/
|
|
710
|
+
declare function setProfileScreensMitra(options: SetProfileScreensOptions): Promise<SetProfilePermissionResponse>;
|
|
711
|
+
/**
|
|
712
|
+
* POST /interactions/profiles/serverFunctions
|
|
713
|
+
* Define as server functions permitidas por perfil
|
|
714
|
+
*/
|
|
715
|
+
declare function setProfileServerFunctionsMitra(options: SetProfileServerFunctionsOptions): Promise<SetProfilePermissionResponse>;
|
|
532
716
|
|
|
533
|
-
export { type CallIntegrationOptions, type CallIntegrationResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type DeleteRecordOptions, type EmailLoginOptions, type EmailResendCodeOptions, type EmailSignupOptions, type EmailVerifyCodeOptions, type ExecuteDbActionOptions, type ExecuteDbActionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetRecordOptions, type GetVariableOptions, type GetVariableResponse, type IntegrationResponse, type ListIntegrationsOptions, type ListRecordsOptions, type ListRecordsResponse, type ListVariablesOptions, type ListVariablesResponse, type LoginOptions, type LoginResponse, type MitraConfig, type MitraInstance, type PatchRecordOptions, type RunActionOptions, type RunActionResponse, type RunQueryOptions, type RunQueryResponse, type SetFileStatusOptions, type SetFileStatusResponse, type SetVariableOptions, type SetVariableResponse, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateRecordOptions, type UploadFileOptions, type UploadFileResponse, callIntegrationMitra, configureSdkMitra, createMitraInstance, createRecordMitra, createRecordsBatchMitra, deleteRecordMitra, emailLoginMitra, emailResendCodeMitra, emailSignupMitra, emailVerifyCodeMitra, executeDbActionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getConfig, getRecordMitra, getVariableMitra,
|
|
717
|
+
export { type CallIntegrationOptions, type CallIntegrationResponse, type CreateProfileOptions, type CreateProfileResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type DeleteProfileOptions, type DeleteProfileResponse, type DeleteRecordOptions, type EmailLoginOptions, type EmailResendCodeOptions, type EmailSignupOptions, type EmailVerifyCodeOptions, type ExecuteDbActionOptions, type ExecuteDbActionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetProfileDetailsOptions, type GetProfileDetailsResponse, type GetRecordOptions, type GetVariableOptions, type GetVariableResponse, type IntegrationResponse, type ListIntegrationsOptions, type ListProfilesOptions, type ListProfilesResponse, type ListRecordsOptions, type ListRecordsResponse, type ListVariablesOptions, type ListVariablesResponse, type LoginOptions, type LoginResponse, type MitraConfig, type MitraInstance, type PatchRecordOptions, type ProfileTableRef, type RunActionOptions, type RunActionResponse, type RunQueryOptions, type RunQueryResponse, type SetFileStatusOptions, type SetFileStatusResponse, type SetProfileActionsOptions, type SetProfileDmlTablesOptions, type SetProfilePermissionResponse, type SetProfileScreensOptions, type SetProfileSelectTablesOptions, type SetProfileServerFunctionsOptions, type SetProfileUsersOptions, type SetVariableOptions, type SetVariableResponse, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateProfileOptions, type UpdateProfileResponse, type UpdateRecordOptions, type UploadFileOptions, type UploadFileResponse, callIntegrationMitra, configureSdkMitra, createMitraInstance, createProfileMitra, createRecordMitra, createRecordsBatchMitra, deleteProfileMitra, deleteRecordMitra, emailLoginMitra, emailResendCodeMitra, emailSignupMitra, emailVerifyCodeMitra, executeDbActionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getConfig, getProfileDetailsMitra, getRecordMitra, getVariableMitra, listIntegrationsMitra, listProfilesMitra, listRecordsMitra, listVariablesMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, patchRecordMitra, refreshTokenSilently, resolveProjectId, runActionMitra, runQueryMitra, setFileStatusMitra, setProfileActionsMitra, setProfileDmlTablesMitra, setProfileScreensMitra, setProfileSelectTablesMitra, setProfileServerFunctionsMitra, setProfileUsersMitra, setVariableMitra, stopServerFunctionExecutionMitra, updateProfileMitra, updateRecordMitra, uploadFileLoadableMitra, uploadFilePublicMitra };
|