mitra-interactions-sdk 1.0.27 → 1.0.29
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 +47 -49
- package/dist/index.d.mts +60 -1
- package/dist/index.d.ts +60 -1
- package/dist/index.js +70 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,21 +64,6 @@ const result = await loginMitra('microsoft', {
|
|
|
64
64
|
|
|
65
65
|
## Métodos Disponíveis
|
|
66
66
|
|
|
67
|
-
### runQueryMitra
|
|
68
|
-
|
|
69
|
-
Executa uma query SQL (SELECT) em um projeto.
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
import { runQueryMitra } from 'mitra-interactions-sdk';
|
|
73
|
-
|
|
74
|
-
const result = await runQueryMitra({
|
|
75
|
-
projectId: 123,
|
|
76
|
-
sql: 'SELECT * FROM usuarios LIMIT 10',
|
|
77
|
-
jdbcId: 1 // Opcional, usa autoConnect se não informado
|
|
78
|
-
});
|
|
79
|
-
// result: { status, result: { rows: Record<string, any>[], rowCount: number } }
|
|
80
|
-
```
|
|
81
|
-
|
|
82
67
|
### executeDbActionMitra
|
|
83
68
|
|
|
84
69
|
Executa uma DBAction (DML) cadastrada.
|
|
@@ -160,34 +145,6 @@ const integrations = await listIntegrationsMitra({ projectId: 123 });
|
|
|
160
145
|
// result: IntegrationResponse[] — [{ id (UUID), projectId, name, slug, blueprintId, blueprintType, authType, credentials, status, lastCheckedAt, createdAt, updatedAt }]
|
|
161
146
|
```
|
|
162
147
|
|
|
163
|
-
#### callIntegrationMitra
|
|
164
|
-
|
|
165
|
-
Chama uma API externa via serviço de integrações do Mitra. O serviço cuida de autenticação, tokens e refresh automaticamente.
|
|
166
|
-
|
|
167
|
-
```typescript
|
|
168
|
-
import { callIntegrationMitra } from 'mitra-interactions-sdk';
|
|
169
|
-
|
|
170
|
-
// POST para API externa
|
|
171
|
-
const result = await callIntegrationMitra({
|
|
172
|
-
projectId: 123,
|
|
173
|
-
connection: 'meu-erp-sankhya',
|
|
174
|
-
method: 'POST',
|
|
175
|
-
endpoint: '/api/v1/pedidos',
|
|
176
|
-
params: { status: 'aberto' }, // Opcional - query parameters
|
|
177
|
-
body: { campo: 'valor' } // Opcional - body da requisição
|
|
178
|
-
});
|
|
179
|
-
// result: { statusCode: 200, body: { ...resposta da API externa... } }
|
|
180
|
-
|
|
181
|
-
// GET simples
|
|
182
|
-
const result2 = await callIntegrationMitra({
|
|
183
|
-
projectId: 123,
|
|
184
|
-
connection: 'api-vendas',
|
|
185
|
-
method: 'GET',
|
|
186
|
-
endpoint: '/v1/pedidos',
|
|
187
|
-
params: { status: 'aberto', page: 1 }
|
|
188
|
-
});
|
|
189
|
-
```
|
|
190
|
-
|
|
191
148
|
### setFileStatusMitra
|
|
192
149
|
|
|
193
150
|
Move arquivo do chat para PUBLIC ou LOADABLE.
|
|
@@ -218,6 +175,45 @@ const result = await setVariableMitra({
|
|
|
218
175
|
// result: { status, result: { key, value } }
|
|
219
176
|
```
|
|
220
177
|
|
|
178
|
+
### listVariablesMitra
|
|
179
|
+
|
|
180
|
+
Lista variáveis de um projeto.
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
import { listVariablesMitra } from 'mitra-interactions-sdk';
|
|
184
|
+
|
|
185
|
+
const result = await listVariablesMitra({ projectId: 123 });
|
|
186
|
+
// result: { status, projectId, result: [{ key, value }] }
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### getVariableMitra
|
|
190
|
+
|
|
191
|
+
Busca o valor de uma variável específica.
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
import { getVariableMitra } from 'mitra-interactions-sdk';
|
|
195
|
+
|
|
196
|
+
const result = await getVariableMitra({ projectId: 123, key: 'minhaVariavel' });
|
|
197
|
+
// result: { status, result: { key, value } }
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### runActionMitra
|
|
201
|
+
|
|
202
|
+
Executa uma Action (fluxo de ação Low-Code) cadastrada.
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
import { runActionMitra } from 'mitra-interactions-sdk';
|
|
206
|
+
|
|
207
|
+
const result = await runActionMitra({
|
|
208
|
+
projectId: 123,
|
|
209
|
+
actionId: 456,
|
|
210
|
+
params: { // Opcional
|
|
211
|
+
campo1: 'valor1'
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
// result: { status, executionTime, result: { stepsExecuted, message } }
|
|
215
|
+
```
|
|
216
|
+
|
|
221
217
|
### Dynamic Schema CRUD
|
|
222
218
|
|
|
223
219
|
CRUD completo em tabelas do projeto via Dynamic Schema (usa header `X-TenantID`).
|
|
@@ -280,15 +276,16 @@ import type {
|
|
|
280
276
|
LoginOptions,
|
|
281
277
|
LoginResponse,
|
|
282
278
|
// Options
|
|
283
|
-
RunQueryOptions,
|
|
284
279
|
ExecuteDbActionOptions,
|
|
285
280
|
ExecuteServerFunctionOptions,
|
|
286
281
|
ExecuteServerFunctionAsyncOptions,
|
|
287
282
|
ListIntegrationsOptions,
|
|
288
|
-
CallIntegrationOptions,
|
|
289
283
|
StopServerFunctionExecutionOptions,
|
|
290
284
|
SetFileStatusOptions,
|
|
291
285
|
SetVariableOptions,
|
|
286
|
+
ListVariablesOptions,
|
|
287
|
+
GetVariableOptions,
|
|
288
|
+
RunActionOptions,
|
|
292
289
|
ListRecordsOptions,
|
|
293
290
|
GetRecordOptions,
|
|
294
291
|
CreateRecordOptions,
|
|
@@ -297,14 +294,15 @@ import type {
|
|
|
297
294
|
DeleteRecordOptions,
|
|
298
295
|
CreateRecordsBatchOptions,
|
|
299
296
|
// Responses
|
|
300
|
-
RunQueryResponse,
|
|
301
297
|
ExecuteDbActionResponse,
|
|
302
298
|
SetFileStatusResponse,
|
|
303
299
|
SetVariableResponse,
|
|
300
|
+
ListVariablesResponse,
|
|
301
|
+
GetVariableResponse,
|
|
302
|
+
RunActionResponse,
|
|
304
303
|
ExecuteServerFunctionResponse,
|
|
305
304
|
ExecuteServerFunctionAsyncResponse,
|
|
306
305
|
IntegrationResponse,
|
|
307
|
-
CallIntegrationResponse,
|
|
308
306
|
StopServerFunctionExecutionResponse,
|
|
309
307
|
ListRecordsResponse
|
|
310
308
|
} from 'mitra-interactions-sdk';
|
|
@@ -314,9 +312,9 @@ import type {
|
|
|
314
312
|
|
|
315
313
|
```typescript
|
|
316
314
|
try {
|
|
317
|
-
const result = await
|
|
315
|
+
const result = await executeDbActionMitra({
|
|
318
316
|
projectId: 123,
|
|
319
|
-
|
|
317
|
+
dbActionId: 456
|
|
320
318
|
});
|
|
321
319
|
} catch (error) {
|
|
322
320
|
console.log('Erro:', error.message);
|
package/dist/index.d.mts
CHANGED
|
@@ -163,6 +163,47 @@ interface CreateRecordsBatchOptions {
|
|
|
163
163
|
records: Record<string, unknown>[];
|
|
164
164
|
jdbcConnectionConfigId?: number;
|
|
165
165
|
}
|
|
166
|
+
interface ListVariablesOptions {
|
|
167
|
+
/** ID do projeto (opcional se já configurado via configureSdkMitra) */
|
|
168
|
+
projectId?: number;
|
|
169
|
+
}
|
|
170
|
+
interface ListVariablesResponse {
|
|
171
|
+
status: string;
|
|
172
|
+
projectId: number;
|
|
173
|
+
result: {
|
|
174
|
+
key: string;
|
|
175
|
+
value: string;
|
|
176
|
+
}[];
|
|
177
|
+
}
|
|
178
|
+
interface GetVariableOptions {
|
|
179
|
+
/** ID do projeto (opcional se já configurado via configureSdkMitra) */
|
|
180
|
+
projectId?: number;
|
|
181
|
+
/** Nome da variável (com ou sem :VAR_) */
|
|
182
|
+
key: string;
|
|
183
|
+
}
|
|
184
|
+
interface GetVariableResponse {
|
|
185
|
+
status: string;
|
|
186
|
+
result: {
|
|
187
|
+
key: string;
|
|
188
|
+
value: string;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
interface RunActionOptions {
|
|
192
|
+
/** ID do projeto (opcional se já configurado via configureSdkMitra) */
|
|
193
|
+
projectId?: number;
|
|
194
|
+
/** ID da Action a executar */
|
|
195
|
+
actionId: number;
|
|
196
|
+
/** Variáveis para a action (opcional) */
|
|
197
|
+
params?: Record<string, unknown>;
|
|
198
|
+
}
|
|
199
|
+
interface RunActionResponse {
|
|
200
|
+
status: string;
|
|
201
|
+
executionTime?: string;
|
|
202
|
+
result: {
|
|
203
|
+
stepsExecuted: number;
|
|
204
|
+
message: string;
|
|
205
|
+
};
|
|
206
|
+
}
|
|
166
207
|
interface CallIntegrationOptions {
|
|
167
208
|
/** ID do projeto (opcional se já configurado via configureSdkMitra) */
|
|
168
209
|
projectId?: number;
|
|
@@ -231,6 +272,9 @@ interface MitraInstance {
|
|
|
231
272
|
executeDbAction(options: ExecuteDbActionOptions): Promise<ExecuteDbActionResponse>;
|
|
232
273
|
setFileStatus(options: SetFileStatusOptions): Promise<SetFileStatusResponse>;
|
|
233
274
|
setVariable(options: SetVariableOptions): Promise<SetVariableResponse>;
|
|
275
|
+
listVariables(options?: ListVariablesOptions): Promise<ListVariablesResponse>;
|
|
276
|
+
getVariable(options: GetVariableOptions): Promise<GetVariableResponse>;
|
|
277
|
+
runAction(options: RunActionOptions): Promise<RunActionResponse>;
|
|
234
278
|
executeServerFunction(options: ExecuteServerFunctionOptions): Promise<ExecuteServerFunctionResponse>;
|
|
235
279
|
executeServerFunctionAsync(options: ExecuteServerFunctionAsyncOptions): Promise<ExecuteServerFunctionAsyncResponse>;
|
|
236
280
|
stopServerFunctionExecution(options: StopServerFunctionExecutionOptions): Promise<StopServerFunctionExecutionResponse>;
|
|
@@ -333,6 +377,21 @@ declare function setFileStatusMitra(options: SetFileStatusOptions): Promise<SetF
|
|
|
333
377
|
* Cria ou atualiza uma variável customizada
|
|
334
378
|
*/
|
|
335
379
|
declare function setVariableMitra(options: SetVariableOptions): Promise<SetVariableResponse>;
|
|
380
|
+
/**
|
|
381
|
+
* GET /agentAiShortcut/listVariables?projectId={id}
|
|
382
|
+
* Lista variáveis de um projeto
|
|
383
|
+
*/
|
|
384
|
+
declare function listVariablesMitra(options?: ListVariablesOptions): Promise<ListVariablesResponse>;
|
|
385
|
+
/**
|
|
386
|
+
* GET /agentAiShortcut/getVariable?projectId={id}&key={key}
|
|
387
|
+
* Busca o valor de uma variável específica
|
|
388
|
+
*/
|
|
389
|
+
declare function getVariableMitra(options: GetVariableOptions): Promise<GetVariableResponse>;
|
|
390
|
+
/**
|
|
391
|
+
* POST /agentAiShortcut/runAction
|
|
392
|
+
* Executa uma Action (fluxo de ação) cadastrada
|
|
393
|
+
*/
|
|
394
|
+
declare function runActionMitra(options: RunActionOptions): Promise<RunActionResponse>;
|
|
336
395
|
/**
|
|
337
396
|
* POST /agentAiShortcut/executeServerFunction
|
|
338
397
|
* Executa uma Server Function de forma SÍNCRONA (timeout 60s no backend)
|
|
@@ -367,4 +426,4 @@ declare function patchRecordMitra(options: PatchRecordOptions): Promise<Record<s
|
|
|
367
426
|
declare function deleteRecordMitra(options: DeleteRecordOptions): Promise<void>;
|
|
368
427
|
declare function createRecordsBatchMitra(options: CreateRecordsBatchOptions): Promise<Record<string, any>[]>;
|
|
369
428
|
|
|
370
|
-
export { type CallIntegrationOptions, type CallIntegrationResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type DeleteRecordOptions, type ExecuteDbActionOptions, type ExecuteDbActionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetRecordOptions, type IntegrationResponse, type ListIntegrationsOptions, type ListRecordsOptions, type ListRecordsResponse, type LoginOptions, type LoginResponse, type MitraConfig, type MitraInstance, type PatchRecordOptions, type RunQueryOptions, type RunQueryResponse, type SetFileStatusOptions, type SetFileStatusResponse, type SetVariableOptions, type SetVariableResponse, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateRecordOptions, callIntegrationMitra, configureSdkMitra, createMitraInstance, createRecordMitra, createRecordsBatchMitra, deleteRecordMitra, executeDbActionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getConfig, getRecordMitra, listIntegrationsMitra, listRecordsMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, patchRecordMitra, resolveProjectId, runQueryMitra, setFileStatusMitra, setVariableMitra, stopServerFunctionExecutionMitra, updateRecordMitra };
|
|
429
|
+
export { type CallIntegrationOptions, type CallIntegrationResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type DeleteRecordOptions, 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, callIntegrationMitra, configureSdkMitra, createMitraInstance, createRecordMitra, createRecordsBatchMitra, deleteRecordMitra, executeDbActionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getConfig, getRecordMitra, getVariableMitra, listIntegrationsMitra, listRecordsMitra, listVariablesMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, patchRecordMitra, resolveProjectId, runActionMitra, runQueryMitra, setFileStatusMitra, setVariableMitra, stopServerFunctionExecutionMitra, updateRecordMitra };
|
package/dist/index.d.ts
CHANGED
|
@@ -163,6 +163,47 @@ interface CreateRecordsBatchOptions {
|
|
|
163
163
|
records: Record<string, unknown>[];
|
|
164
164
|
jdbcConnectionConfigId?: number;
|
|
165
165
|
}
|
|
166
|
+
interface ListVariablesOptions {
|
|
167
|
+
/** ID do projeto (opcional se já configurado via configureSdkMitra) */
|
|
168
|
+
projectId?: number;
|
|
169
|
+
}
|
|
170
|
+
interface ListVariablesResponse {
|
|
171
|
+
status: string;
|
|
172
|
+
projectId: number;
|
|
173
|
+
result: {
|
|
174
|
+
key: string;
|
|
175
|
+
value: string;
|
|
176
|
+
}[];
|
|
177
|
+
}
|
|
178
|
+
interface GetVariableOptions {
|
|
179
|
+
/** ID do projeto (opcional se já configurado via configureSdkMitra) */
|
|
180
|
+
projectId?: number;
|
|
181
|
+
/** Nome da variável (com ou sem :VAR_) */
|
|
182
|
+
key: string;
|
|
183
|
+
}
|
|
184
|
+
interface GetVariableResponse {
|
|
185
|
+
status: string;
|
|
186
|
+
result: {
|
|
187
|
+
key: string;
|
|
188
|
+
value: string;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
interface RunActionOptions {
|
|
192
|
+
/** ID do projeto (opcional se já configurado via configureSdkMitra) */
|
|
193
|
+
projectId?: number;
|
|
194
|
+
/** ID da Action a executar */
|
|
195
|
+
actionId: number;
|
|
196
|
+
/** Variáveis para a action (opcional) */
|
|
197
|
+
params?: Record<string, unknown>;
|
|
198
|
+
}
|
|
199
|
+
interface RunActionResponse {
|
|
200
|
+
status: string;
|
|
201
|
+
executionTime?: string;
|
|
202
|
+
result: {
|
|
203
|
+
stepsExecuted: number;
|
|
204
|
+
message: string;
|
|
205
|
+
};
|
|
206
|
+
}
|
|
166
207
|
interface CallIntegrationOptions {
|
|
167
208
|
/** ID do projeto (opcional se já configurado via configureSdkMitra) */
|
|
168
209
|
projectId?: number;
|
|
@@ -231,6 +272,9 @@ interface MitraInstance {
|
|
|
231
272
|
executeDbAction(options: ExecuteDbActionOptions): Promise<ExecuteDbActionResponse>;
|
|
232
273
|
setFileStatus(options: SetFileStatusOptions): Promise<SetFileStatusResponse>;
|
|
233
274
|
setVariable(options: SetVariableOptions): Promise<SetVariableResponse>;
|
|
275
|
+
listVariables(options?: ListVariablesOptions): Promise<ListVariablesResponse>;
|
|
276
|
+
getVariable(options: GetVariableOptions): Promise<GetVariableResponse>;
|
|
277
|
+
runAction(options: RunActionOptions): Promise<RunActionResponse>;
|
|
234
278
|
executeServerFunction(options: ExecuteServerFunctionOptions): Promise<ExecuteServerFunctionResponse>;
|
|
235
279
|
executeServerFunctionAsync(options: ExecuteServerFunctionAsyncOptions): Promise<ExecuteServerFunctionAsyncResponse>;
|
|
236
280
|
stopServerFunctionExecution(options: StopServerFunctionExecutionOptions): Promise<StopServerFunctionExecutionResponse>;
|
|
@@ -333,6 +377,21 @@ declare function setFileStatusMitra(options: SetFileStatusOptions): Promise<SetF
|
|
|
333
377
|
* Cria ou atualiza uma variável customizada
|
|
334
378
|
*/
|
|
335
379
|
declare function setVariableMitra(options: SetVariableOptions): Promise<SetVariableResponse>;
|
|
380
|
+
/**
|
|
381
|
+
* GET /agentAiShortcut/listVariables?projectId={id}
|
|
382
|
+
* Lista variáveis de um projeto
|
|
383
|
+
*/
|
|
384
|
+
declare function listVariablesMitra(options?: ListVariablesOptions): Promise<ListVariablesResponse>;
|
|
385
|
+
/**
|
|
386
|
+
* GET /agentAiShortcut/getVariable?projectId={id}&key={key}
|
|
387
|
+
* Busca o valor de uma variável específica
|
|
388
|
+
*/
|
|
389
|
+
declare function getVariableMitra(options: GetVariableOptions): Promise<GetVariableResponse>;
|
|
390
|
+
/**
|
|
391
|
+
* POST /agentAiShortcut/runAction
|
|
392
|
+
* Executa uma Action (fluxo de ação) cadastrada
|
|
393
|
+
*/
|
|
394
|
+
declare function runActionMitra(options: RunActionOptions): Promise<RunActionResponse>;
|
|
336
395
|
/**
|
|
337
396
|
* POST /agentAiShortcut/executeServerFunction
|
|
338
397
|
* Executa uma Server Function de forma SÍNCRONA (timeout 60s no backend)
|
|
@@ -367,4 +426,4 @@ declare function patchRecordMitra(options: PatchRecordOptions): Promise<Record<s
|
|
|
367
426
|
declare function deleteRecordMitra(options: DeleteRecordOptions): Promise<void>;
|
|
368
427
|
declare function createRecordsBatchMitra(options: CreateRecordsBatchOptions): Promise<Record<string, any>[]>;
|
|
369
428
|
|
|
370
|
-
export { type CallIntegrationOptions, type CallIntegrationResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type DeleteRecordOptions, type ExecuteDbActionOptions, type ExecuteDbActionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetRecordOptions, type IntegrationResponse, type ListIntegrationsOptions, type ListRecordsOptions, type ListRecordsResponse, type LoginOptions, type LoginResponse, type MitraConfig, type MitraInstance, type PatchRecordOptions, type RunQueryOptions, type RunQueryResponse, type SetFileStatusOptions, type SetFileStatusResponse, type SetVariableOptions, type SetVariableResponse, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateRecordOptions, callIntegrationMitra, configureSdkMitra, createMitraInstance, createRecordMitra, createRecordsBatchMitra, deleteRecordMitra, executeDbActionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getConfig, getRecordMitra, listIntegrationsMitra, listRecordsMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, patchRecordMitra, resolveProjectId, runQueryMitra, setFileStatusMitra, setVariableMitra, stopServerFunctionExecutionMitra, updateRecordMitra };
|
|
429
|
+
export { type CallIntegrationOptions, type CallIntegrationResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type DeleteRecordOptions, 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, callIntegrationMitra, configureSdkMitra, createMitraInstance, createRecordMitra, createRecordsBatchMitra, deleteRecordMitra, executeDbActionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getConfig, getRecordMitra, getVariableMitra, listIntegrationsMitra, listRecordsMitra, listVariablesMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, patchRecordMitra, resolveProjectId, runActionMitra, runQueryMitra, setFileStatusMitra, setVariableMitra, stopServerFunctionExecutionMitra, updateRecordMitra };
|
package/dist/index.js
CHANGED
|
@@ -78,7 +78,7 @@ function createMitraInstance(initialConfig) {
|
|
|
78
78
|
"Content-Type": "application/json"
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
|
-
async function
|
|
81
|
+
async function handleResponse2(response) {
|
|
82
82
|
const text = await response.text();
|
|
83
83
|
const data = text ? JSON.parse(text) : null;
|
|
84
84
|
if (!response.ok) {
|
|
@@ -99,7 +99,7 @@ function createMitraInstance(initialConfig) {
|
|
|
99
99
|
headers: authHeaders(),
|
|
100
100
|
body: (opts == null ? void 0 : opts.body) !== void 0 ? JSON.stringify(opts.body) : void 0
|
|
101
101
|
});
|
|
102
|
-
return
|
|
102
|
+
return handleResponse2(response);
|
|
103
103
|
}
|
|
104
104
|
async function requestIntegrations2(method, endpoint, opts) {
|
|
105
105
|
if (!_config.integrationURL) throw new Error("integrationURL n\xE3o configurado.");
|
|
@@ -114,7 +114,7 @@ function createMitraInstance(initialConfig) {
|
|
|
114
114
|
headers: authHeaders(),
|
|
115
115
|
body: (opts == null ? void 0 : opts.body) !== void 0 ? JSON.stringify(opts.body) : void 0
|
|
116
116
|
});
|
|
117
|
-
return
|
|
117
|
+
return handleResponse2(response);
|
|
118
118
|
}
|
|
119
119
|
async function requestTenant(method, endpoint, tenantId, opts) {
|
|
120
120
|
let url = `${_config.baseURL}${endpoint}`;
|
|
@@ -127,7 +127,7 @@ function createMitraInstance(initialConfig) {
|
|
|
127
127
|
headers: { ...authHeaders(), "X-TenantID": String(tenantId) },
|
|
128
128
|
body: (opts == null ? void 0 : opts.body) !== void 0 ? JSON.stringify(opts.body) : void 0
|
|
129
129
|
});
|
|
130
|
-
return
|
|
130
|
+
return handleResponse2(response);
|
|
131
131
|
}
|
|
132
132
|
async function doLogin(method, options) {
|
|
133
133
|
var _a2;
|
|
@@ -182,6 +182,17 @@ function createMitraInstance(initialConfig) {
|
|
|
182
182
|
if (options.value !== void 0) body.value = options.value;
|
|
183
183
|
return request("POST", "/agentAiShortcut/setVariable", { body });
|
|
184
184
|
},
|
|
185
|
+
async listVariables(options = {}) {
|
|
186
|
+
return request("GET", "/agentAiShortcut/listVariables", { params: { projectId: resolveProjectId2(options.projectId) } });
|
|
187
|
+
},
|
|
188
|
+
async getVariable(options) {
|
|
189
|
+
return request("GET", "/agentAiShortcut/getVariable", { params: { projectId: resolveProjectId2(options.projectId), key: options.key } });
|
|
190
|
+
},
|
|
191
|
+
async runAction(options) {
|
|
192
|
+
const body = { projectId: resolveProjectId2(options.projectId), actionId: options.actionId };
|
|
193
|
+
if (options.params !== void 0) body.params = options.params;
|
|
194
|
+
return request("POST", "/agentAiShortcut/runAction", { body });
|
|
195
|
+
},
|
|
185
196
|
async executeServerFunction(options) {
|
|
186
197
|
const body = { projectId: resolveProjectId2(options.projectId), serverFunctionId: options.serverFunctionId };
|
|
187
198
|
if (options.input !== void 0) body.input = options.input;
|
|
@@ -421,7 +432,29 @@ function buildUrl(endpoint, params) {
|
|
|
421
432
|
}
|
|
422
433
|
return url;
|
|
423
434
|
}
|
|
435
|
+
async function handleResponse(response) {
|
|
436
|
+
const text = await response.text();
|
|
437
|
+
const data = text ? JSON.parse(text) : null;
|
|
438
|
+
if (!response.ok) {
|
|
439
|
+
const base = (data == null ? void 0 : data.message) || (data == null ? void 0 : data.error) || `HTTP ${response.status}`;
|
|
440
|
+
const msg = (data == null ? void 0 : data.hint) ? `${base} \u2014 ${data.hint}` : base;
|
|
441
|
+
throw {
|
|
442
|
+
message: msg,
|
|
443
|
+
status: response.status,
|
|
444
|
+
details: data
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
return data;
|
|
448
|
+
}
|
|
424
449
|
var http = {
|
|
450
|
+
async get(endpoint, params) {
|
|
451
|
+
const fetchFn = getFetch2();
|
|
452
|
+
const response = await fetchFn(buildUrl(endpoint, params), {
|
|
453
|
+
method: "GET",
|
|
454
|
+
headers: buildHeaders()
|
|
455
|
+
});
|
|
456
|
+
return handleResponse(response);
|
|
457
|
+
},
|
|
425
458
|
async post(endpoint, body) {
|
|
426
459
|
const fetchFn = getFetch2();
|
|
427
460
|
const response = await fetchFn(buildUrl(endpoint), {
|
|
@@ -429,18 +462,15 @@ var http = {
|
|
|
429
462
|
headers: buildHeaders(),
|
|
430
463
|
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
431
464
|
});
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
return data;
|
|
465
|
+
return handleResponse(response);
|
|
466
|
+
},
|
|
467
|
+
async del(endpoint, params) {
|
|
468
|
+
const fetchFn = getFetch2();
|
|
469
|
+
const response = await fetchFn(buildUrl(endpoint, params), {
|
|
470
|
+
method: "DELETE",
|
|
471
|
+
headers: buildHeaders()
|
|
472
|
+
});
|
|
473
|
+
return handleResponse(response);
|
|
444
474
|
}
|
|
445
475
|
};
|
|
446
476
|
async function requestWithTenant(method, endpoint, tenantId, options) {
|
|
@@ -564,6 +594,27 @@ async function setVariableMitra(options) {
|
|
|
564
594
|
}
|
|
565
595
|
return http.post("/agentAiShortcut/setVariable", body);
|
|
566
596
|
}
|
|
597
|
+
async function listVariablesMitra(options = {}) {
|
|
598
|
+
return http.get("/agentAiShortcut/listVariables", {
|
|
599
|
+
projectId: resolveProjectId(options.projectId)
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
async function getVariableMitra(options) {
|
|
603
|
+
return http.get("/agentAiShortcut/getVariable", {
|
|
604
|
+
projectId: resolveProjectId(options.projectId),
|
|
605
|
+
key: options.key
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
async function runActionMitra(options) {
|
|
609
|
+
const body = {
|
|
610
|
+
projectId: resolveProjectId(options.projectId),
|
|
611
|
+
actionId: options.actionId
|
|
612
|
+
};
|
|
613
|
+
if (options.params !== void 0) {
|
|
614
|
+
body.params = options.params;
|
|
615
|
+
}
|
|
616
|
+
return http.post("/agentAiShortcut/runAction", body);
|
|
617
|
+
}
|
|
567
618
|
async function executeServerFunctionMitra(options) {
|
|
568
619
|
const body = {
|
|
569
620
|
projectId: resolveProjectId(options.projectId),
|
|
@@ -659,14 +710,17 @@ exports.executeServerFunctionAsyncMitra = executeServerFunctionAsyncMitra;
|
|
|
659
710
|
exports.executeServerFunctionMitra = executeServerFunctionMitra;
|
|
660
711
|
exports.getConfig = getConfig;
|
|
661
712
|
exports.getRecordMitra = getRecordMitra;
|
|
713
|
+
exports.getVariableMitra = getVariableMitra;
|
|
662
714
|
exports.listIntegrationsMitra = listIntegrationsMitra;
|
|
663
715
|
exports.listRecordsMitra = listRecordsMitra;
|
|
716
|
+
exports.listVariablesMitra = listVariablesMitra;
|
|
664
717
|
exports.loginMitra = loginMitra;
|
|
665
718
|
exports.loginWithEmailMitra = loginWithEmailMitra;
|
|
666
719
|
exports.loginWithGoogleMitra = loginWithGoogleMitra;
|
|
667
720
|
exports.loginWithMicrosoftMitra = loginWithMicrosoftMitra;
|
|
668
721
|
exports.patchRecordMitra = patchRecordMitra;
|
|
669
722
|
exports.resolveProjectId = resolveProjectId;
|
|
723
|
+
exports.runActionMitra = runActionMitra;
|
|
670
724
|
exports.runQueryMitra = runQueryMitra;
|
|
671
725
|
exports.setFileStatusMitra = setFileStatusMitra;
|
|
672
726
|
exports.setVariableMitra = setVariableMitra;
|