@pipefy/pipefy-process-coder 0.1.0

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 (92) hide show
  1. package/.agents/skills/ppc-pipefy-flow-authoring/SKILL.md +262 -0
  2. package/.agents/skills/ppc-pipefy-flow-authoring/examples/01-main-2-danfe-consulta.json +247 -0
  3. package/.agents/skills/ppc-pipefy-flow-authoring/examples/01-main-2-webhook-retorno-consulta.json +589 -0
  4. package/.agents/skills/ppc-pipefy-flow-authoring/examples/01-main-4-recebimento-barramento.json +1391 -0
  5. package/.agents/skills/ppc-pipefy-flow-authoring/examples/02-subflow-2-danfe-retorno.json +623 -0
  6. package/.agents/skills/ppc-pipefy-flow-authoring/examples/02-subflow-4-criacao-operacao.json +636 -0
  7. package/.agents/skills/ppc-pipefy-flow-authoring/examples/03-subflow-4-criacao-titulo.json +3642 -0
  8. package/.agents/skills/ppc-pipefy-flow-authoring/examples/04-subflow-4-criacao-cedente.json +863 -0
  9. package/.agents/skills/ppc-pipefy-flow-authoring/examples/04-subflow-4-criacao-sacado.json +799 -0
  10. package/.agents/skills/ppc-pipefy-flow-authoring/examples/README.md +42 -0
  11. package/.agents/skills/ppc-pipefy-flow-authoring/examples/hml-01-subflow-1-titulo-acompanhamento-cobranca.json +581 -0
  12. package/.agents/skills/ppc-pipefy-flow-authoring/examples/hml-01-subflow-1-titulo-nfe-monitoramento.json +503 -0
  13. package/.agents/skills/ppc-pipefy-flow-authoring/examples/hml-01-subflow-1-titulo-retorno-bancario.json +562 -0
  14. package/.agents/skills/ppc-pipefy-flow-authoring/examples/hml-02-subflow-2-retorno-consulta-cedente.json +557 -0
  15. package/.agents/skills/ppc-pipefy-flow-authoring/examples/hml-02-subflow-2-retorno-consulta-sacado.json +609 -0
  16. package/.agents/skills/ppc-pipefy-pipe-authoring/SKILL.md +146 -0
  17. package/.agents/skills/ppc-pipefy-process-design/SKILL.md +127 -0
  18. package/.agents/skills/ppc-pipefy-workspace/SKILL.md +91 -0
  19. package/AGENTS.md +456 -0
  20. package/README.md +808 -0
  21. package/bin/pipe.js +13 -0
  22. package/package.json +35 -0
  23. package/src/apply/adopt.ts +150 -0
  24. package/src/apply/agentops.ts +71 -0
  25. package/src/apply/compile.ts +875 -0
  26. package/src/apply/execute.ts +336 -0
  27. package/src/apply/flowops.ts +399 -0
  28. package/src/apply/idmap.ts +241 -0
  29. package/src/apply/mutations.ts +955 -0
  30. package/src/apply/registry.ts +430 -0
  31. package/src/apply/types.ts +134 -0
  32. package/src/cli/args.ts +88 -0
  33. package/src/cli.ts +211 -0
  34. package/src/codec/flow.ts +199 -0
  35. package/src/codec/pack.ts +103 -0
  36. package/src/codec/roundtrip.ts +94 -0
  37. package/src/codec/unpack.ts +198 -0
  38. package/src/commands/agents.ts +184 -0
  39. package/src/commands/apply.ts +1144 -0
  40. package/src/commands/context.ts +119 -0
  41. package/src/commands/create.ts +79 -0
  42. package/src/commands/diff.ts +314 -0
  43. package/src/commands/flows.ts +414 -0
  44. package/src/commands/misc.ts +644 -0
  45. package/src/commands/plan.ts +331 -0
  46. package/src/commands/pull.ts +567 -0
  47. package/src/commands/runs.ts +83 -0
  48. package/src/commands/skills.ts +137 -0
  49. package/src/commands/verify.ts +253 -0
  50. package/src/config.ts +168 -0
  51. package/src/diff/agents.ts +122 -0
  52. package/src/diff/diff.ts +1130 -0
  53. package/src/diff/flow.ts +318 -0
  54. package/src/diff/html.ts +322 -0
  55. package/src/diff/render.ts +101 -0
  56. package/src/model/payload.ts +154 -0
  57. package/src/model/tree.ts +99 -0
  58. package/src/model/volatile.ts +55 -0
  59. package/src/pipefy/agents.ts +165 -0
  60. package/src/pipefy/automations.ts +219 -0
  61. package/src/pipefy/capability.ts +119 -0
  62. package/src/pipefy/client.ts +267 -0
  63. package/src/pipefy/discovery.ts +209 -0
  64. package/src/pipefy/internal.ts +380 -0
  65. package/src/pipefy/ipaas.ts +365 -0
  66. package/src/pipefy/reconstruct.ts +775 -0
  67. package/src/pipefy/reference.ts +251 -0
  68. package/src/pipefy/snapshot.ts +245 -0
  69. package/src/pipefy/toolkit.ts +200 -0
  70. package/src/pipefy/toolkit_bearer.py +137 -0
  71. package/src/report/integrations.ts +231 -0
  72. package/src/report/run.ts +475 -0
  73. package/src/util/fsx.ts +45 -0
  74. package/src/util/git.ts +32 -0
  75. package/src/util/json.ts +55 -0
  76. package/src/util/log.ts +76 -0
  77. package/src/util/pool.ts +48 -0
  78. package/src/util/slug.ts +26 -0
  79. package/src/util/tui.ts +335 -0
  80. package/src/validate/index.ts +123 -0
  81. package/src/validate/integrity.ts +387 -0
  82. package/src/validate/reference.ts +136 -0
  83. package/src/validate/schema.ts +328 -0
  84. package/src/workspace/agents.ts +290 -0
  85. package/src/workspace/docs.ts +407 -0
  86. package/src/workspace/flows.ts +191 -0
  87. package/src/workspace/layout.ts +165 -0
  88. package/src/workspace/lock.ts +148 -0
  89. package/src/workspace/read.ts +165 -0
  90. package/src/workspace/reference.ts +24 -0
  91. package/src/workspace/stamp.ts +301 -0
  92. package/src/workspace/write.ts +225 -0
@@ -0,0 +1,799 @@
1
+ {
2
+ "name": "✅[PRD][4/4 SUBFLOW][CRIAÇÃO] SACADO",
3
+ "type": "SHARED",
4
+ "summary": "",
5
+ "description": "",
6
+ "tags": [],
7
+ "blogUrl": "",
8
+ "metadata": {
9
+ "externalId": "exampleFlowId12aaaaaa"
10
+ },
11
+ "author": "IntegraçÔes Ipaas 000000000",
12
+ "categories": [],
13
+ "pieces": [
14
+ "@activepieces/piece-subflows",
15
+ "@activepieces/piece-pipefy",
16
+ "@activepieces/piece-date-helper",
17
+ "@activepieces/piece-http-oauth2"
18
+ ],
19
+ "flows": [
20
+ {
21
+ "displayName": "✅[PRD][4/4 SUBFLOW][CRIAÇÃO] SACADO",
22
+ "trigger": {
23
+ "name": "trigger",
24
+ "valid": true,
25
+ "displayName": "Callable Flow",
26
+ "nextAction": {
27
+ "name": "step_2",
28
+ "type": "PIECE",
29
+ "valid": true,
30
+ "settings": {
31
+ "input": {
32
+ "auth": "{{connections['exampleConnectionId3']}}",
33
+ "pipeId": "200000005",
34
+ "fieldId": "idsacado",
35
+ "comments": [],
36
+ "assignees": [],
37
+ "card_info": [
38
+ "uuid",
39
+ "suid",
40
+ "age",
41
+ "title",
42
+ "comments_count",
43
+ "createdAt",
44
+ "current_phase_age",
45
+ "done",
46
+ "due_date",
47
+ "emailMessagingAddress",
48
+ "expired",
49
+ "late",
50
+ "started_current_phase_at",
51
+ "updated_at",
52
+ "url",
53
+ "creatorEmail",
54
+ "current_phase"
55
+ ],
56
+ "created_by": [],
57
+ "fieldValue": "{{trigger['output']['data']['sacado']['idSacado']}}",
58
+ "attachments": [],
59
+ "inbox_emails": [
60
+ "bcc",
61
+ "body",
62
+ "cc",
63
+ "from",
64
+ "fromName",
65
+ "id",
66
+ "main_to",
67
+ "message_id",
68
+ "sent_via_automation",
69
+ "state",
70
+ "subject",
71
+ "to",
72
+ "updated_at",
73
+ "user",
74
+ "attachments"
75
+ ],
76
+ "organizationId": "100000001",
77
+ "phases_history": [],
78
+ "child_relations": [],
79
+ "parent_relations": []
80
+ },
81
+ "pieceName": "@activepieces/piece-pipefy",
82
+ "actionName": "getCardsByFieldValue",
83
+ "pieceVersion": "0.2.0",
84
+ "propertySettings": {
85
+ "pipeId": {
86
+ "type": "MANUAL"
87
+ },
88
+ "fieldId": {
89
+ "type": "MANUAL"
90
+ },
91
+ "fieldValue": {
92
+ "type": "MANUAL"
93
+ },
94
+ "organizationId": {
95
+ "type": "MANUAL"
96
+ }
97
+ },
98
+ "errorHandlingOptions": {
99
+ "retryOnFailure": {
100
+ "value": false
101
+ },
102
+ "continueOnFailure": {
103
+ "value": false
104
+ }
105
+ }
106
+ },
107
+ "nextAction": {
108
+ "name": "step_11",
109
+ "skip": false,
110
+ "type": "CODE",
111
+ "valid": true,
112
+ "settings": {
113
+ "input": {
114
+ "cards": "{{step_2['output']['data']['cards']}}",
115
+ "empresaCodigo": "{{trigger['output']['data']['empresaCodigo']}}"
116
+ },
117
+ "sampleData": {},
118
+ "sourceCode": {
119
+ "code": "export const code = async (inputs) => {\n const alvo = String(inputs.empresaCodigo ?? '').trim();\n\n const card = inputs.cards.find(\n c => String(c.fields?.empresacodigo?.value ?? '').trim() === alvo\n );\n\n // Compara datas no fuso de SĂŁo Paulo (dia Ăștil BR)\n const emSaoPaulo = (data) =>\n new Intl.DateTimeFormat('en-CA', {\n timeZone: 'America/Sao_Paulo',\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n }).format(data); // => \"YYYY-MM-DD\"\n\n let atualizadoHoje = false;\n if (card?.updated_at) {\n const dataAtualizacao = new Date(card.updated_at);\n if (!isNaN(dataAtualizacao)) {\n atualizadoHoje = emSaoPaulo(dataAtualizacao) === emSaoPaulo(new Date());\n }\n }\n\n return {\n cardId: card?.id ?? null,\n encontrado: !!card,\n // Se foi atualizado hoje, nĂŁo precisa consultar o cedente novamente\n consultarCedente: card ? !atualizadoHoje : true,\n };\n};",
120
+ "packageJson": "{}"
121
+ },
122
+ "errorHandlingOptions": {
123
+ "retryOnFailure": {
124
+ "value": false
125
+ },
126
+ "continueOnFailure": {
127
+ "value": false
128
+ }
129
+ }
130
+ },
131
+ "nextAction": {
132
+ "name": "step_17",
133
+ "skip": false,
134
+ "type": "PIECE",
135
+ "valid": true,
136
+ "settings": {
137
+ "input": {
138
+ "timeZone": "America/Sao_Paulo",
139
+ "timeFormat": "YYYY-MM-DDTHH:mm:ss"
140
+ },
141
+ "pieceName": "@activepieces/piece-date-helper",
142
+ "actionName": "get_current_date",
143
+ "sampleData": {},
144
+ "pieceVersion": "0.1.28",
145
+ "propertySettings": {
146
+ "timeZone": {
147
+ "type": "MANUAL"
148
+ },
149
+ "timeFormat": {
150
+ "type": "MANUAL"
151
+ }
152
+ },
153
+ "errorHandlingOptions": {
154
+ "retryOnFailure": {
155
+ "value": false
156
+ },
157
+ "continueOnFailure": {
158
+ "value": false
159
+ }
160
+ }
161
+ },
162
+ "nextAction": {
163
+ "name": "step_3",
164
+ "skip": false,
165
+ "type": "ROUTER",
166
+ "valid": true,
167
+ "children": [
168
+ {
169
+ "name": "step_18",
170
+ "skip": false,
171
+ "type": "PIECE",
172
+ "valid": true,
173
+ "settings": {
174
+ "input": {
175
+ "url": "{{variables['PRD_BASE_URL']}}/v1/orderby/consultations/sacados/{{trigger['output']['data']['sacado']['idSacado']}}?codigoEmpresa={{trigger['output']['data']['empresaCodigo']}}&origem={{trigger['output']['data']['origem']}}",
176
+ "auth": "{{connections['exampleConnectionId1']}}",
177
+ "body": {},
178
+ "method": "GET",
179
+ "headers": {
180
+ "timestamp": "{{step_17['output']['result']}}",
181
+ "Content-Type": "application/json",
182
+ "correlation-id": "123e4567-e89b-12d3-a456-426614174000"
183
+ },
184
+ "failsafe": false,
185
+ "body_type": "none",
186
+ "use_proxy": false,
187
+ "queryParams": {},
188
+ "proxy_settings": {}
189
+ },
190
+ "pieceName": "@activepieces/piece-http-oauth2",
191
+ "actionName": "send-oauth2-request",
192
+ "sampleData": {},
193
+ "pieceVersion": "0.2.5",
194
+ "propertySettings": {
195
+ "url": {
196
+ "type": "MANUAL"
197
+ },
198
+ "body": {
199
+ "type": "MANUAL",
200
+ "schema": {}
201
+ },
202
+ "method": {
203
+ "type": "MANUAL"
204
+ },
205
+ "headers": {
206
+ "type": "MANUAL"
207
+ },
208
+ "timeout": {
209
+ "type": "MANUAL"
210
+ },
211
+ "failsafe": {
212
+ "type": "MANUAL"
213
+ },
214
+ "body_type": {
215
+ "type": "MANUAL"
216
+ },
217
+ "use_proxy": {
218
+ "type": "MANUAL"
219
+ },
220
+ "queryParams": {
221
+ "type": "MANUAL"
222
+ },
223
+ "proxy_settings": {
224
+ "type": "MANUAL",
225
+ "schema": {}
226
+ }
227
+ },
228
+ "errorHandlingOptions": {
229
+ "retryOnFailure": {
230
+ "value": false
231
+ },
232
+ "continueOnFailure": {
233
+ "value": false
234
+ }
235
+ }
236
+ },
237
+ "nextAction": {
238
+ "name": "step_15",
239
+ "skip": false,
240
+ "type": "PIECE",
241
+ "valid": true,
242
+ "settings": {
243
+ "input": {
244
+ "mode": "simple",
245
+ "response": {
246
+ "response": {
247
+ "cardId": "{{step_11['output']['cardId']}}"
248
+ }
249
+ }
250
+ },
251
+ "pieceName": "@activepieces/piece-subflows",
252
+ "actionName": "returnResponse",
253
+ "sampleData": {},
254
+ "pieceVersion": "0.4.12",
255
+ "propertySettings": {
256
+ "mode": {
257
+ "type": "MANUAL"
258
+ },
259
+ "response": {
260
+ "type": "MANUAL",
261
+ "schema": {
262
+ "response": {
263
+ "type": "OBJECT",
264
+ "required": true,
265
+ "displayName": "Response"
266
+ }
267
+ }
268
+ }
269
+ },
270
+ "errorHandlingOptions": {
271
+ "retryOnFailure": {
272
+ "value": false
273
+ },
274
+ "continueOnFailure": {
275
+ "value": false
276
+ }
277
+ }
278
+ },
279
+ "displayName": "Retornar cardId",
280
+ "lastUpdatedDate": "2026-08-26T16:14:32.886Z"
281
+ },
282
+ "displayName": "Consulta Sacado",
283
+ "lastUpdatedDate": "2026-08-26T16:14:32.886Z"
284
+ },
285
+ {
286
+ "name": "step_5",
287
+ "skip": false,
288
+ "type": "PIECE",
289
+ "valid": true,
290
+ "settings": {
291
+ "input": {
292
+ "mode": "simple",
293
+ "response": {
294
+ "response": {
295
+ "cardId": "{{step_11['output']['cardId']}}"
296
+ }
297
+ }
298
+ },
299
+ "pieceName": "@activepieces/piece-subflows",
300
+ "actionName": "returnResponse",
301
+ "sampleData": {},
302
+ "pieceVersion": "0.4.12",
303
+ "propertySettings": {
304
+ "mode": {
305
+ "type": "MANUAL"
306
+ },
307
+ "response": {
308
+ "type": "MANUAL",
309
+ "schema": {
310
+ "response": {
311
+ "type": "OBJECT",
312
+ "required": true,
313
+ "displayName": "Response"
314
+ }
315
+ }
316
+ }
317
+ },
318
+ "errorHandlingOptions": {
319
+ "retryOnFailure": {
320
+ "value": false
321
+ },
322
+ "continueOnFailure": {
323
+ "value": false
324
+ }
325
+ }
326
+ },
327
+ "displayName": "Retornar cardId Copy",
328
+ "lastUpdatedDate": "2026-08-26T16:14:32.886Z"
329
+ },
330
+ {
331
+ "name": "step_13",
332
+ "skip": false,
333
+ "type": "CODE",
334
+ "valid": true,
335
+ "settings": {
336
+ "input": {
337
+ "email": "{{trigger['output']['data']['sacado']['email']}}",
338
+ "cnpjOuCpf": "{{trigger['output']['data']['sacado']['cnpjOuCpf']}}",
339
+ "bodyBarramento ": "{{trigger['output']['data']['sacado']}}",
340
+ "telefoneContato ": "{{trigger['output']['data']['sacado']['telefoneContato']}}"
341
+ },
342
+ "sampleData": {},
343
+ "sourceCode": {
344
+ "code": "export const code = async (inputs) => {\n // Normaliza chaves removendo espaços extras\n const normalizedInputs = {};\n for (const key in inputs) {\n normalizedInputs[key.trim()] = inputs[key];\n }\n inputs = normalizedInputs;\n\n // ===== Helper para arredondar nĂșmeros com 2 casas decimais =====\n const round2 = (n) => Math.round((Number(n) || 0) * 100) / 100;\n\n // ===== Normaliza telefone =====\n let telefoneContato = '';\n let telefoneContatoFormatado = '';\n if (inputs.telefoneContato) {\n let numeros = String(inputs.telefoneContato).replace(/\\D/g, '');\n // Remove o 55 inicial se jĂĄ vier com cĂłdigo do paĂ­s\n if ((numeros.length === 12 || numeros.length === 13) && numeros.startsWith('55')) {\n numeros = numeros.substring(2);\n }\n if (numeros.length === 11) {\n // Celular com DDD\n const ddd = numeros.substring(0, 2);\n const parte1 = numeros.substring(2, 7);\n const parte2 = numeros.substring(7);\n telefoneContato = `55${numeros}`;\n telefoneContatoFormatado = `+55 (${ddd}) ${parte1}-${parte2}`;\n } else if (numeros.length === 10) {\n // Fixo com DDD\n const ddd = numeros.substring(0, 2);\n const parte1 = numeros.substring(2, 6);\n const parte2 = numeros.substring(6);\n telefoneContato = `55${numeros}`;\n telefoneContatoFormatado = `+55 (${ddd}) ${parte1}-${parte2}`;\n } else {\n telefoneContato = numeros;\n telefoneContatoFormatado = numeros;\n }\n }\n\n // ===== Normaliza e-mails =====\n // Se nĂŁo houver nenhum '@' no input, devolve o valor original e marca emailCheck = false.\n // Caso contrĂĄrio, considera apenas e-mails vĂĄlidos (com @ e domĂ­nio com TLD),\n // aceitando separação por ; , espaço ou quebra de linha, e devolve separados por vĂ­rgula.\n let email = '';\n let emailCheck = true;\n if (inputs.email) {\n const emailStr = String(inputs.email);\n if (!emailStr.includes('@')) {\n // Nenhum @ encontrado - retorna valor original\n email = emailStr;\n emailCheck = false;\n } else {\n const emailRegex = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$/;\n const validos = emailStr\n .split(/[;,\\s]+/)\n .map((e) => e.trim())\n .filter((e) => e && emailRegex.test(e));\n // Remove duplicatas mantendo a ordem\n email = Array.from(new Set(validos)).join(', ');\n }\n }\n\n // ===== Identifica e formata CPF/CNPJ =====\n let cpf = '';\n let cnpj = '';\n let tipo = '';\n if (inputs.cnpjOuCpf) {\n const doc = String(inputs.cnpjOuCpf).replace(/\\D/g, '');\n if (doc.length === 11) {\n cpf = `${doc.substring(0, 3)}.${doc.substring(3, 6)}.${doc.substring(6, 9)}-${doc.substring(9)}`;\n tipo = 'cpf';\n } else if (doc.length === 14) {\n cnpj = `${doc.substring(0, 2)}.${doc.substring(2, 5)}.${doc.substring(5, 8)}/${doc.substring(8, 12)}-${doc.substring(12)}`;\n tipo = 'cnpj';\n }\n }\n\n // ===== Helpers de formatação numĂ©rica =====\n const formatBRL = (valor) => {\n const num = Number(valor) || 0;\n return num.toLocaleString('pt-BR', {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n });\n };\n\n const formatInt = (valor) => {\n const num = Number(valor) || 0;\n return num.toLocaleString('pt-BR');\n };\n\n // Formata nĂșmero como percentual no padrĂŁo pt-BR (ex.: \"12,34%\")\n const formatPerc = (valor) => {\n const num = Number(valor) || 0;\n return (\n num.toLocaleString('pt-BR', {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n }) + '%'\n );\n };\n\n // HeurĂ­stica: campos de contagem/cĂłdigo nĂŁo levam casas decimais\n const isCountField = (key) => {\n const lower = String(key).toLowerCase();\n return (\n lower.endsWith('qtd') ||\n lower.includes('quantidade') ||\n lower.includes('codigo') ||\n lower.includes('numero')\n );\n };\n\n // Labels amigĂĄveis para campos conhecidos\n const labelMap = {\n totalTitulosLiquidados: 'Total de TĂ­tulos Liquidados',\n totalTitulosLiquidadosPagoDia: 'TĂ­tulos Liquidados Pagos no Dia',\n totalTitulosLiquidadosPagoAtraso: 'TĂ­tulos Liquidados Pagos em Atraso',\n totalOpeNaoEfetivadas: 'OperaçÔes NĂŁo Efetivadas',\n totalTitulosLiquidadosChequeDevolvido: 'TĂ­tulos Liquidados com Cheque Devolvido',\n totalTitulosAbertos: 'Total de TĂ­tulos em Aberto',\n totalTitulosAbertosVencidos: 'TĂ­tulos em Aberto Vencidos',\n totalTitulosAbertosVencer: 'TĂ­tulos em Aberto a Vencer',\n totPresente: 'Total Presente',\n totSac: 'Total Sacado',\n totQtd: 'Total Quantidade',\n totNegativa: 'Total Negativa',\n codigoEvento: 'CĂłdigo do Evento',\n descricao: 'Descrição',\n totalLiquidado: 'Total Liquidado',\n quantidadeTitulos: 'Quantidade de TĂ­tulos',\n historicoValorLiquidado: 'HistĂłrico de Valores Liquidados',\n historicoValorAberto: 'HistĂłrico de Valores em Aberto',\n liquidacaoPorEvento: 'Liquidação por Evento',\n percHPre: 'Percentual HistĂłrico - Presente',\n percHNeg: 'Percentual HistĂłrico - Negativo',\n };\n\n const camelToTitle = (str) =>\n String(str)\n .replace(/([A-Z])/g, ' $1')\n .replace(/^./, (s) => s.toUpperCase())\n .trim();\n\n const getLabel = (key) => labelMap[key] || camelToTitle(key);\n\n // ===== Converte objeto em tabela markdown =====\n // Detecta pares X / XQtd e gera 3 colunas (Indicador | Valor | Quantidade)\n // Caso contrĂĄrio gera 2 colunas (Campo | Valor)\n const objToMarkdown = (obj) => {\n if (!obj || typeof obj !== 'object' || Array.isArray(obj)) return '';\n const keys = Object.keys(obj);\n if (keys.length === 0) return '';\n\n const temPares = keys.some(\n (k) => !k.endsWith('Qtd') && keys.includes(`${k}Qtd`)\n );\n\n if (temPares) {\n const usados = new Set();\n const linhas = [];\n\n keys.forEach((k) => {\n if (usados.has(k)) return;\n\n if (k.endsWith('Qtd')) {\n // Qtd ĂłrfĂŁo (sem par valor)\n const baseKey = k.substring(0, k.length - 3);\n if (!keys.includes(baseKey)) {\n linhas.push({\n label: getLabel(baseKey),\n valor: '-',\n qtd: formatInt(obj[k]),\n });\n usados.add(k);\n }\n } else {\n const qtdKey = `${k}Qtd`;\n if (keys.includes(qtdKey)) {\n linhas.push({\n label: getLabel(k),\n valor: formatBRL(obj[k]),\n qtd: formatInt(obj[qtdKey]),\n });\n usados.add(k);\n usados.add(qtdKey);\n } else {\n linhas.push({\n label: getLabel(k),\n valor: formatBRL(obj[k]),\n qtd: '-',\n });\n usados.add(k);\n }\n }\n });\n\n let md = '| Indicador | Valor (R$) | Quantidade |\\n';\n md += '|-----------|-----------:|-----------:|\\n';\n linhas.forEach((l) => {\n md += `| ${l.label} | ${l.valor} | ${l.qtd} |\\n`;\n });\n return md.trim();\n }\n\n // Tabela simples Campo / Valor\n let md = '| Campo | Valor |\\n';\n md += '|-------|------:|\\n';\n keys.forEach((k) => {\n const v = obj[k];\n let formatado;\n if (typeof v === 'number') {\n formatado = isCountField(k) ? formatInt(v) : formatBRL(v);\n } else {\n formatado = v === null || v === undefined ? '' : String(v);\n }\n md += `| ${getLabel(k)} | ${formatado} |\\n`;\n });\n return md.trim();\n };\n\n // ===== Converte array de objetos em tabela markdown =====\n const arrayToMarkdown = (arr) => {\n if (!Array.isArray(arr) || arr.length === 0) return '';\n const itensValidos = arr.filter((i) => i && typeof i === 'object');\n if (itensValidos.length === 0) return '';\n\n const colunas = Array.from(\n itensValidos.reduce((set, item) => {\n Object.keys(item).forEach((k) => set.add(k));\n return set;\n }, new Set())\n );\n\n let md = '| ' + colunas.map(getLabel).join(' | ') + ' |\\n';\n md += '|' + colunas.map(() => '------').join('|') + '|\\n';\n itensValidos.forEach((item) => {\n md +=\n '| ' +\n colunas\n .map((c) => {\n const v = item[c];\n if (v === undefined || v === null) return '';\n if (typeof v === 'number') {\n return isCountField(c) ? formatInt(v) : formatBRL(v);\n }\n return String(v);\n })\n .join(' | ') +\n ' |\\n';\n });\n return md.trim();\n };\n\n // ===== Processa bodyBarramento =====\n const objetosMarkdown = {};\n const partesMarkdown = [];\n\n // Valores calculados de %Hpre e %Hneg (default zerado)\n let percHPre = '0,00%';\n let percHNeg = '0,00%';\n let percHPreNum = 0;\n let percHNegNum = 0;\n\n if (inputs.bodyBarramento && typeof inputs.bodyBarramento === 'object') {\n // Aceita tanto o payload completo (com data.sacado) quanto o objeto direto\n const root =\n (inputs.bodyBarramento.data && inputs.bodyBarramento.data.sacado) ||\n inputs.bodyBarramento;\n\n // ===== Calcula %Hpre e %Hneg =====\n // %Hpre = totPresente / totSac (valor histĂłrico de presente / valor histĂłrico total do sacado)\n if (root.percHPre && typeof root.percHPre === 'object') {\n const totPresente = Number(root.percHPre.totPresente) || 0;\n const totSac = Number(root.percHPre.totSac) || 0;\n const rawHPre = totSac > 0 ? (totPresente / totSac) * 100 : 0;\n percHPreNum = round2(rawHPre);\n percHPre = formatPerc(percHPreNum);\n }\n\n // %Hneg = totNegativa / totSac (valor histĂłrico negativo / valor histĂłrico total do sacado)\n if (root.percHNeg && typeof root.percHNeg === 'object') {\n const totNegativa = Number(root.percHNeg.totNegativa) || 0;\n const totSac = Number(root.percHNeg.totSac) || 0;\n const rawHNeg = totSac > 0 ? (totNegativa / totSac) * 100 : 0;\n percHNegNum = round2(rawHNeg);\n percHNeg = formatPerc(percHNegNum);\n }\n\n // ===== Demais objetos em markdown =====\n for (const key in root) {\n const value = root[key];\n\n // Objeto aninhado com mais de um parĂąmetro\n if (\n value &&\n typeof value === 'object' &&\n !Array.isArray(value) &&\n Object.keys(value).length > 1\n ) {\n const md = objToMarkdown(value);\n if (md) {\n objetosMarkdown[key] = md;\n partesMarkdown.push(`### ${getLabel(key)}\\n\\n${md}`);\n }\n }\n // Array de objetos\n else if (\n Array.isArray(value) &&\n value.length > 0 &&\n typeof value[0] === 'object'\n ) {\n const md = arrayToMarkdown(value);\n if (md) {\n objetosMarkdown[key] = md;\n partesMarkdown.push(`### ${getLabel(key)}\\n\\n${md}`);\n }\n }\n }\n }\n\n const markdownCompleto = partesMarkdown.join('\\n\\n');\n\n return {\n telefoneContato,\n telefoneContatoFormatado,\n email,\n emailCheck,\n tipo,\n cpf,\n cnpj,\n percHPre,\n percHNeg,\n percHPreNum,\n percHNegNum,\n objetosMarkdown,\n markdownCompleto,\n };\n};",
345
+ "packageJson": "{}"
346
+ },
347
+ "errorHandlingOptions": {
348
+ "retryOnFailure": {
349
+ "value": false
350
+ },
351
+ "continueOnFailure": {
352
+ "value": false
353
+ }
354
+ }
355
+ },
356
+ "nextAction": {
357
+ "name": "step_10",
358
+ "skip": false,
359
+ "type": "PIECE",
360
+ "valid": true,
361
+ "settings": {
362
+ "input": {
363
+ "url": {
364
+ "url": "https://api.pipefy.com/graphql"
365
+ },
366
+ "auth": "{{connections['exampleConnectionId3']}}",
367
+ "body": {
368
+ "data": {
369
+ "query": "mutation {\n createCard(input: {\n pipe_id: \"200000005\"\n fields_attributes: [\n { field_id: \"idsacado\", field_value: \"{{trigger['output']['data']['sacado']['idSacado']}}\" }\n { field_id: \"empresacodigo\", field_value: \"{{trigger['output']['data']['empresaCodigo']}}\" }\n { field_id: \"base\", field_value: \"{{trigger['output']['data']['origem']}}\" }\n\t\t\t{ field_id: \"card_id_titulo\", field_value: \"{{trigger['output']['data']['cardIdTitulo']}}\" }\n ]\n }) {\n card { id title createdAt }\n }\n}",
370
+ "variables": null
371
+ }
372
+ },
373
+ "method": "POST",
374
+ "headers": {},
375
+ "failsafe": false,
376
+ "body_type": "json",
377
+ "queryParams": {},
378
+ "followRedirects": false,
379
+ "response_is_binary": false
380
+ },
381
+ "pieceName": "@activepieces/piece-pipefy",
382
+ "actionName": "custom_api_call",
383
+ "sampleData": {},
384
+ "pieceVersion": "0.2.0",
385
+ "propertySettings": {
386
+ "url": {
387
+ "type": "MANUAL",
388
+ "schema": {
389
+ "url": {
390
+ "type": "SHORT_TEXT",
391
+ "required": true,
392
+ "description": "You can either use the full URL or the relative path to the base URL\ni.e https://api.pipefy.com/graphql/resource or /resource",
393
+ "displayName": "URL",
394
+ "defaultValue": "https://api.pipefy.com/graphql"
395
+ }
396
+ }
397
+ },
398
+ "body": {
399
+ "type": "MANUAL",
400
+ "schema": {
401
+ "data": {
402
+ "type": "JSON",
403
+ "required": true,
404
+ "displayName": "JSON Body"
405
+ }
406
+ }
407
+ },
408
+ "method": {
409
+ "type": "MANUAL"
410
+ },
411
+ "headers": {
412
+ "type": "MANUAL"
413
+ },
414
+ "timeout": {
415
+ "type": "MANUAL"
416
+ },
417
+ "failsafe": {
418
+ "type": "MANUAL"
419
+ },
420
+ "body_type": {
421
+ "type": "MANUAL"
422
+ },
423
+ "queryParams": {
424
+ "type": "MANUAL"
425
+ },
426
+ "followRedirects": {
427
+ "type": "MANUAL"
428
+ },
429
+ "response_is_binary": {
430
+ "type": "MANUAL"
431
+ }
432
+ },
433
+ "errorHandlingOptions": {
434
+ "retryOnFailure": {
435
+ "value": false
436
+ },
437
+ "continueOnFailure": {
438
+ "value": false
439
+ }
440
+ }
441
+ },
442
+ "nextAction": {
443
+ "name": "step_1",
444
+ "skip": false,
445
+ "type": "PIECE",
446
+ "valid": true,
447
+ "settings": {
448
+ "input": {
449
+ "url": {
450
+ "url": "https://api.pipefy.com/graphql"
451
+ },
452
+ "auth": "{{connections['exampleConnectionId3']}}",
453
+ "body": {
454
+ "data": {
455
+ "query": "mutation {\n updateCardField(\n input: {card_id: \"{{step_4['output']['data']['createCard']['card']['id']}}\", field_id:\"telefone_de_contato\",new_value:\"{{step_13['output']['telefoneContatoFormatado']}}\"}\n ) {\n clientMutationId\n }\n}\n",
456
+ "variables": null
457
+ }
458
+ },
459
+ "method": "POST",
460
+ "headers": {},
461
+ "failsafe": false,
462
+ "body_type": "json",
463
+ "queryParams": {},
464
+ "followRedirects": false,
465
+ "response_is_binary": false
466
+ },
467
+ "pieceName": "@activepieces/piece-pipefy",
468
+ "actionName": "custom_api_call",
469
+ "sampleData": {},
470
+ "pieceVersion": "0.1.7",
471
+ "propertySettings": {
472
+ "url": {
473
+ "type": "MANUAL",
474
+ "schema": {
475
+ "url": {
476
+ "type": "SHORT_TEXT",
477
+ "required": true,
478
+ "description": "You can either use the full URL or the relative path to the base URL\ni.e https://api.pipefy.com/graphql/resource or /resource",
479
+ "displayName": "URL",
480
+ "defaultValue": "https://api.pipefy.com/graphql"
481
+ }
482
+ }
483
+ },
484
+ "body": {
485
+ "type": "MANUAL",
486
+ "schema": {
487
+ "data": {
488
+ "type": "JSON",
489
+ "required": true,
490
+ "displayName": "JSON Body"
491
+ }
492
+ }
493
+ },
494
+ "method": {
495
+ "type": "MANUAL"
496
+ },
497
+ "headers": {
498
+ "type": "MANUAL"
499
+ },
500
+ "timeout": {
501
+ "type": "MANUAL"
502
+ },
503
+ "failsafe": {
504
+ "type": "MANUAL"
505
+ },
506
+ "body_type": {
507
+ "type": "MANUAL"
508
+ },
509
+ "queryParams": {
510
+ "type": "MANUAL"
511
+ },
512
+ "followRedirects": {
513
+ "type": "MANUAL"
514
+ },
515
+ "response_is_binary": {
516
+ "type": "MANUAL"
517
+ }
518
+ },
519
+ "errorHandlingOptions": {
520
+ "retryOnFailure": {
521
+ "value": false
522
+ },
523
+ "continueOnFailure": {
524
+ "value": false
525
+ }
526
+ }
527
+ },
528
+ "nextAction": {
529
+ "name": "step_9",
530
+ "skip": false,
531
+ "type": "PIECE",
532
+ "valid": true,
533
+ "settings": {
534
+ "input": {
535
+ "mode": "simple",
536
+ "response": {
537
+ "response": {
538
+ "cardId": "{{step_10['output']['body']['data']['createCard']['card']['id']}}"
539
+ }
540
+ }
541
+ },
542
+ "pieceName": "@activepieces/piece-subflows",
543
+ "actionName": "returnResponse",
544
+ "sampleData": {},
545
+ "pieceVersion": "0.4.12",
546
+ "propertySettings": {
547
+ "mode": {
548
+ "type": "MANUAL"
549
+ },
550
+ "response": {
551
+ "type": "MANUAL",
552
+ "schema": {
553
+ "response": {
554
+ "type": "OBJECT",
555
+ "required": true,
556
+ "displayName": "Response"
557
+ }
558
+ }
559
+ }
560
+ },
561
+ "errorHandlingOptions": {
562
+ "retryOnFailure": {
563
+ "value": false
564
+ },
565
+ "continueOnFailure": {
566
+ "value": false
567
+ }
568
+ }
569
+ },
570
+ "nextAction": {
571
+ "name": "step_16",
572
+ "skip": false,
573
+ "type": "PIECE",
574
+ "valid": true,
575
+ "settings": {
576
+ "input": {
577
+ "url": "{{variables['PRD_BASE_URL']}}/v1/orderby/consultations/sacados/{{trigger['output']['data']['sacado']['idSacado']}}?codigoEmpresa={{trigger['output']['data']['empresaCodigo']}}&origem={{trigger['output']['data']['origem']}}",
578
+ "auth": "{{connections['exampleConnectionId1']}}",
579
+ "body": {},
580
+ "method": "GET",
581
+ "headers": {
582
+ "timestamp": "{{step_17['output']['result']}}",
583
+ "Content-Type": "application/json",
584
+ "correlation-id": "123e4567-e89b-12d3-a456-426614174000"
585
+ },
586
+ "failsafe": false,
587
+ "body_type": "none",
588
+ "use_proxy": false,
589
+ "queryParams": {},
590
+ "proxy_settings": {}
591
+ },
592
+ "pieceName": "@activepieces/piece-http-oauth2",
593
+ "actionName": "send-oauth2-request",
594
+ "sampleData": {},
595
+ "pieceVersion": "0.2.5",
596
+ "propertySettings": {
597
+ "url": {
598
+ "type": "MANUAL"
599
+ },
600
+ "body": {
601
+ "type": "MANUAL",
602
+ "schema": {}
603
+ },
604
+ "method": {
605
+ "type": "MANUAL"
606
+ },
607
+ "headers": {
608
+ "type": "MANUAL"
609
+ },
610
+ "timeout": {
611
+ "type": "MANUAL"
612
+ },
613
+ "failsafe": {
614
+ "type": "MANUAL"
615
+ },
616
+ "body_type": {
617
+ "type": "MANUAL"
618
+ },
619
+ "use_proxy": {
620
+ "type": "MANUAL"
621
+ },
622
+ "queryParams": {
623
+ "type": "MANUAL"
624
+ },
625
+ "proxy_settings": {
626
+ "type": "MANUAL",
627
+ "schema": {}
628
+ }
629
+ },
630
+ "errorHandlingOptions": {
631
+ "retryOnFailure": {
632
+ "value": false
633
+ },
634
+ "continueOnFailure": {
635
+ "value": false
636
+ }
637
+ }
638
+ },
639
+ "displayName": "Consulta Sacado",
640
+ "lastUpdatedDate": "2026-08-26T16:14:32.887Z"
641
+ },
642
+ "displayName": "Retornar cardId",
643
+ "lastUpdatedDate": "2026-08-26T16:14:32.887Z"
644
+ },
645
+ "displayName": "atualização Telefone",
646
+ "lastUpdatedDate": "2026-08-26T16:14:32.887Z"
647
+ },
648
+ "displayName": "Criar card",
649
+ "lastUpdatedDate": "2026-08-26T16:14:40.613Z"
650
+ },
651
+ "displayName": "Normalização",
652
+ "lastUpdatedDate": "2026-08-26T16:14:32.886Z"
653
+ }
654
+ ],
655
+ "settings": {
656
+ "branches": [
657
+ {
658
+ "branchName": "Existe e atualizar",
659
+ "branchType": "CONDITION",
660
+ "conditions": [
661
+ [
662
+ {
663
+ "operator": "BOOLEAN_IS_TRUE",
664
+ "firstValue": "{{step_11['output']['encontrado']}}"
665
+ },
666
+ {
667
+ "operator": "BOOLEAN_IS_TRUE",
668
+ "firstValue": "{{step_13['output']['consultarCedente']}}"
669
+ }
670
+ ]
671
+ ]
672
+ },
673
+ {
674
+ "branchName": "Existe e atualizado",
675
+ "branchType": "CONDITION",
676
+ "conditions": [
677
+ [
678
+ {
679
+ "operator": "BOOLEAN_IS_TRUE",
680
+ "firstValue": "{{step_11['output']['encontrado']}}"
681
+ },
682
+ {
683
+ "operator": "BOOLEAN_IS_FALSE",
684
+ "firstValue": "{{step_13['output']['consultarCedente']}}"
685
+ }
686
+ ]
687
+ ]
688
+ },
689
+ {
690
+ "branchName": "Otherwise",
691
+ "branchType": "FALLBACK"
692
+ }
693
+ ],
694
+ "sampleData": {},
695
+ "executionType": "EXECUTE_FIRST_MATCH"
696
+ },
697
+ "displayName": "Lista Sacado",
698
+ "lastUpdatedDate": "2026-08-26T16:14:32.885Z"
699
+ },
700
+ "displayName": "Get Current Date",
701
+ "lastUpdatedDate": "2026-08-26T16:14:32.885Z"
702
+ },
703
+ "displayName": "ConferĂȘncia id e codigoEmpresa Copy",
704
+ "lastUpdatedDate": "2026-08-26T16:14:32.885Z"
705
+ },
706
+ "displayName": "Buscar Sacado",
707
+ "lastUpdatedDate": "2026-08-26T16:14:32.884Z"
708
+ },
709
+ "lastUpdatedDate": "2026-08-26T16:14:32.884Z",
710
+ "type": "PIECE_TRIGGER",
711
+ "settings": {
712
+ "sampleData": {},
713
+ "propertySettings": {
714
+ "mode": {
715
+ "type": "MANUAL"
716
+ },
717
+ "exampleData": {
718
+ "type": "MANUAL",
719
+ "schema": {
720
+ "sampleData": {
721
+ "type": "example",
722
+ "required": false,
723
+ "displayName": "example"
724
+ }
725
+ }
726
+ }
727
+ },
728
+ "pieceName": "@activepieces/piece-subflows",
729
+ "pieceVersion": "0.4.11",
730
+ "triggerName": "callableFlow",
731
+ "input": {
732
+ "mode": "advanced",
733
+ "exampleData": {
734
+ "sampleData": {
735
+ "origem": "example",
736
+ "sacado": {
737
+ "nome": "example",
738
+ "email": "example",
739
+ "endereco": "example",
740
+ "idSacado": 0,
741
+ "percHNeg": {
742
+ "totQtd": 0,
743
+ "totSac": 0,
744
+ "totNegativa": 0
745
+ },
746
+ "percHPre": {
747
+ "totQtd": 0,
748
+ "totSac": 0,
749
+ "totPresente": 0
750
+ },
751
+ "cnpjOuCpf": "example",
752
+ "idCedente": 0,
753
+ "razaoSocial": "example",
754
+ "nomeFantasia": "example",
755
+ "codigoEmpresa": 0,
756
+ "telefoneContato": "example",
757
+ "liquidacaoPorEvento": [
758
+ {
759
+ "descricao": "example",
760
+ "codigoEvento": 0,
761
+ "totalLiquidado": 0,
762
+ "quantidadeTitulos": 0
763
+ }
764
+ ],
765
+ "historicoValorAberto": {
766
+ "totalTitulosAbertos": 0,
767
+ "totalTitulosAbertosQtd": 0,
768
+ "totalTitulosAbertosVencer": 0,
769
+ "totalTitulosAbertosVencidos": 0,
770
+ "totalTitulosAbertosVencerQtd": 0,
771
+ "totalTitulosAbertosVencidosQtd": 0
772
+ },
773
+ "historicoValorLiquidado": {
774
+ "totalOpeNaoEfetivadas": 0,
775
+ "totalTitulosLiquidados": 0,
776
+ "totalOpeNaoEfetivadasQtd": 0,
777
+ "totalTitulosLiquidadosQtd": 0,
778
+ "totalTitulosLiquidadosPagoDia": 0,
779
+ "totalTitulosLiquidadosPagoAtraso": 0,
780
+ "totalTitulosLiquidadosPagoDiaQtd": 0,
781
+ "totalTitulosLiquidadosPagoAtrasoQtd": 0,
782
+ "totalTitulosLiquidadosChequeDevolvido": 0,
783
+ "totalTitulosLiquidadosChequeDevolvidoQtd": 0
784
+ }
785
+ },
786
+ "cardIdTitulo": "example",
787
+ "empresaCodigo": 0
788
+ }
789
+ }
790
+ }
791
+ }
792
+ },
793
+ "valid": true,
794
+ "schemaVersion": "22",
795
+ "notes": []
796
+ }
797
+ ],
798
+ "status": "PUBLISHED"
799
+ }