mitra-sdk 1.0.1 → 1.0.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.
Files changed (2) hide show
  1. package/README.md +158 -36
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -16,76 +16,198 @@ import { configureSdkMitra } from 'mitra-sdk';
16
16
  configureSdkMitra({
17
17
  baseURL: 'https://api.mitra.com',
18
18
  token: 'seu-jwt-token',
19
- projectId: 123
19
+ timeout: 30000 // Opcional, padrão: 30000ms
20
20
  });
21
21
  ```
22
22
 
23
23
  ## Métodos incluídos do mitra-interactions-sdk
24
24
 
25
- - `runQueryMitra` - Executa query SQL
26
- - `executeDbActionMitra` - Executa DBAction
27
- - `executeActionMitra` - Executa Action
25
+ - `runQueryMitra` - Executa query SQL (SELECT)
26
+ - `executeDbActionMitra` - Executa DBAction (DML)
27
+ - `executeActionMitra` - Executa Action (fluxo)
28
28
  - `executeServerFunctionMitra` - Executa Server Function
29
29
  - `setFileStatusMitra` - Move arquivo para PUBLIC/LOADABLE
30
30
  - `setVariableMitra` - Cria/atualiza variável
31
31
 
32
+ > Para exemplos detalhados destes métodos, consulte a documentação do [mitra-interactions-sdk](https://www.npmjs.com/package/mitra-interactions-sdk).
33
+
32
34
  ## Métodos do Mitra SDK
33
35
 
34
36
  ### Navegação
35
37
 
36
- - `listWorkspacesMitra` - Lista workspaces
37
- - `listProjectsMitra` - Lista projetos de um workspace
38
- - `createProjectMitra` - Cria um projeto
39
- - `getProjectContextMitra` - Detalhes de um projeto
38
+ - `listWorkspacesMitra()` - Lista workspaces
39
+ - `listProjectsMitra({ workspaceId })` - Lista projetos de um workspace
40
+ - `createProjectMitra({ workspaceId, name, description? })` - Cria um projeto
41
+ - `getProjectContextMitra({ projectId })` - Detalhes e inventário de um projeto
42
+
43
+ ```typescript
44
+ import { listWorkspacesMitra, listProjectsMitra } from 'mitra-sdk';
45
+
46
+ const workspaces = await listWorkspacesMitra();
47
+ const projects = await listProjectsMitra({ workspaceId: 1 });
48
+ ```
40
49
 
41
50
  ### Variáveis
42
51
 
43
- - `listVariablesMitra` - Lista variáveis de um projeto
44
- - `getVariableMitra` - Obtém uma variável por key
45
- - `deleteVariableMitra` - Deleta uma variável
52
+ - `listVariablesMitra({ projectId })` - Lista variáveis
53
+ - `getVariableMitra({ projectId, key })` - Obtém variável por key
54
+ - `deleteVariableMitra({ projectId, key })` - Deleta variável
55
+
56
+ ```typescript
57
+ import { listVariablesMitra, getVariableMitra } from 'mitra-sdk';
58
+
59
+ const vars = await listVariablesMitra({ projectId: 123 });
60
+ const v = await getVariableMitra({ projectId: 123, key: 'minhaVar' });
61
+ ```
46
62
 
47
63
  ### JDBC
48
64
 
49
- - `listJdbcConnectionsMitra` - Lista conexões JDBC
50
- - `createJdbcConnectionMitra` - Cria conexão JDBC
51
- - `updateJdbcConnectionMitra` - Atualiza conexão JDBC
65
+ - `listJdbcConnectionsMitra({ projectId })` - Lista conexões JDBC
66
+ - `createJdbcConnectionMitra({ projectId, name, type, host, port, database, user, password })` - Cria conexão
67
+ - `updateJdbcConnectionMitra({ projectId, jdbcId, name, type, host, port, database, user, password })` - Atualiza conexão
68
+
69
+ ```typescript
70
+ import { createJdbcConnectionMitra } from 'mitra-sdk';
71
+
72
+ const result = await createJdbcConnectionMitra({
73
+ projectId: 123,
74
+ name: 'Meu Banco',
75
+ type: 'PostgreSQL',
76
+ host: 'localhost',
77
+ port: 5432,
78
+ database: 'mydb',
79
+ user: 'admin',
80
+ password: 'senha123'
81
+ });
82
+ ```
52
83
 
53
84
  ### SQL
54
85
 
55
- - `runDdlMitra` - Executa DDL (CREATE, ALTER, DROP)
56
- - `runDmlMitra` - Executa DML (INSERT, UPDATE, DELETE)
57
- - `createOnlineTableMitra` - Cria online table
58
- - `updateOnlineTableMitra` - Atualiza online table
86
+ - `runDdlMitra({ projectId, sql, jdbcId? })` - Executa DDL (CREATE, ALTER, DROP)
87
+ - `runDmlMitra({ projectId, sql, jdbcId? })` - Executa DML (INSERT, UPDATE, DELETE)
88
+ - `createOnlineTableMitra({ projectId, jdbcId, name, sql_query })` - Cria online table
89
+ - `updateOnlineTableMitra({ projectId, tableName, sql_query })` - Atualiza online table
90
+
91
+ ```typescript
92
+ import { runDdlMitra, runDmlMitra } from 'mitra-sdk';
93
+
94
+ await runDdlMitra({ projectId: 123, sql: 'CREATE TABLE users (id INT, name VARCHAR(100))' });
95
+ await runDmlMitra({ projectId: 123, sql: "INSERT INTO users VALUES (1, 'João')" });
96
+ ```
59
97
 
60
98
  ### DBActions
61
99
 
62
- - `listDbActionsMitra` - Lista DBActions
63
- - `createDbActionMitra` - Cria DBAction
64
- - `updateDbActionMitra` - Atualiza DBAction
65
- - `deleteDbActionMitra` - Deleta DBAction
100
+ - `listDbActionsMitra({ projectId })` - Lista DBActions
101
+ - `createDbActionMitra({ projectId, name, sql })` - Cria DBAction
102
+ - `updateDbActionMitra({ projectId, dbactionId, sql })` - Atualiza DBAction
103
+ - `deleteDbActionMitra({ projectId, dbactionId })` - Deleta DBAction
104
+
105
+ ```typescript
106
+ import { createDbActionMitra } from 'mitra-sdk';
107
+
108
+ const result = await createDbActionMitra({
109
+ projectId: 123,
110
+ name: 'Inserir Usuário',
111
+ sql: "INSERT INTO users (name) VALUES (':VAR_NOME')"
112
+ });
113
+ ```
66
114
 
67
115
  ### Actions
68
116
 
69
- - `listActionsMitra` - Lista Actions
70
- - `createActionMitra` - Cria Action
71
- - `updateActionStepsMitra` - Atualiza steps de uma Action
72
- - `deleteActionMitra` - Deleta Action
117
+ - `listActionsMitra({ projectId })` - Lista Actions com steps
118
+ - `createActionMitra({ projectId, name, steps?, params? })` - Cria Action
119
+ - `updateActionStepsMitra({ projectId, actionId, steps?, params? })` - Atualiza steps
120
+ - `deleteActionMitra({ projectId, actionId })` - Deleta Action
121
+
122
+ ```typescript
123
+ import { createActionMitra } from 'mitra-sdk';
124
+
125
+ const result = await createActionMitra({
126
+ projectId: 123,
127
+ name: 'Fluxo de Cadastro',
128
+ steps: [
129
+ { type: 'DB_ACTION', dmlActionsIds: [1, 2] },
130
+ { type: 'SHOW_MESSAGE', message: 'Cadastro realizado!', title: 'Sucesso' }
131
+ ]
132
+ });
133
+ ```
73
134
 
74
135
  ### Screens
75
136
 
76
- - `listScreensMitra` - Lista telas
77
- - `deleteScreenMitra` - Deleta tela
78
- - `updateScreenMetadataMitra` - Atualiza metadados de uma tela
79
- - `createScreenNativeMitra` - Cria tela nativa
80
- - `updateScreenNativeMitra` - Atualiza tela nativa
81
- - `getScreenStructureMitra` - Obtém estrutura de uma tela
82
- - `listAvailableComponentsMitra` - Lista componentes disponíveis
137
+ - `listScreensMitra({ projectId })` - Lista telas
138
+ - `deleteScreenMitra({ projectId, screenId })` - Deleta tela
139
+ - `updateScreenMetadataMitra({ projectId, screenId, name?, public? })` - Atualiza metadados
140
+ - `createScreenNativeMitra({ projectId, name, public?, moduleId? })` - Cria tela nativa
141
+ - `updateScreenNativeMitra({ projectId, screenId, name, moduleId?, public? })` - Atualiza tela nativa
142
+ - `getScreenStructureMitra({ projectId, screenId })` - Obtém estrutura (árvore de componentes)
143
+ - `listAvailableComponentsMitra()` - Lista tipos de componentes disponíveis
144
+
145
+ ```typescript
146
+ import { createScreenNativeMitra, getScreenStructureMitra } from 'mitra-sdk';
147
+
148
+ const screen = await createScreenNativeMitra({ projectId: 123, name: 'Dashboard', public: true });
149
+ const structure = await getScreenStructureMitra({ projectId: 123, screenId: 1 });
150
+ ```
83
151
 
84
152
  ### Componentes
85
153
 
86
- - `addComponentMitra` - Adiciona componente a uma tela
87
- - `updateComponentMitra` - Atualiza componente
88
- - `deleteComponentMitra` - Deleta componente
154
+ - `addComponentMitra({ projectId, screenId, type, props?, sizes? })` - Adiciona componente
155
+ - `updateComponentMitra({ projectId, componentId, props?, sizes? })` - Atualiza componente
156
+ - `deleteComponentMitra({ projectId, componentId })` - Deleta componente
157
+
158
+ ```typescript
159
+ import { addComponentMitra } from 'mitra-sdk';
160
+
161
+ const result = await addComponentMitra({
162
+ projectId: 123,
163
+ screenId: 1,
164
+ type: 'CARD_GROUP',
165
+ props: {
166
+ query: "SELECT 1 AS ID, 'Vendas' AS DESC, COUNT(*) AS VALOR FROM VENDAS",
167
+ jdbcId: 1,
168
+ idColumn: 'ID',
169
+ cardTitle: 'VALOR',
170
+ cardDescription: 'DESC'
171
+ },
172
+ sizes: { left: '10px', top: '10px', width: '600px', height: '150px', z: 1 }
173
+ });
174
+ ```
175
+
176
+ ### Arquivos
177
+
178
+ - `listProjectFilesMitra({ projectId })` - Lista arquivos do projeto (CHAT, PUBLIC, LOADABLE)
179
+ - `getFilePreviewMitra({ projectId, fileName, maxLines? })` - Preview de arquivo (CSV, texto, imagem)
180
+
181
+ ```typescript
182
+ import { listProjectFilesMitra, getFilePreviewMitra } from 'mitra-sdk';
183
+
184
+ const files = await listProjectFilesMitra({ projectId: 123 });
185
+ const preview = await getFilePreviewMitra({ projectId: 123, fileName: 'dados.csv', maxLines: 10 });
186
+ ```
187
+
188
+ ### Formulários
189
+
190
+ - `listFormsMitra({ projectId })` - Lista formulários
191
+ - `getFormDetailsMitra({ projectId, formId })` - Detalhes de um formulário (campos, botões)
192
+
193
+ ```typescript
194
+ import { listFormsMitra, getFormDetailsMitra } from 'mitra-sdk';
195
+
196
+ const forms = await listFormsMitra({ projectId: 123 });
197
+ const details = await getFormDetailsMitra({ projectId: 123, formId: 1 });
198
+ ```
199
+
200
+ ### Tabelas
201
+
202
+ - `listTablesMitra({ projectId })` - Lista tabelas físicas com colunas e tipos
203
+ - `listOnlineTablesMitra({ projectId })` - Lista tabelas online (QueryAlias) com queries
204
+
205
+ ```typescript
206
+ import { listTablesMitra, listOnlineTablesMitra } from 'mitra-sdk';
207
+
208
+ const tables = await listTablesMitra({ projectId: 123 });
209
+ const onlineTables = await listOnlineTablesMitra({ projectId: 123 });
210
+ ```
89
211
 
90
212
  ## Licença
91
213
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mitra-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "SDK completo para a plataforma Mitra ECP",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",