funifier-mcp 0.1.0 → 0.2.3

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 (114) hide show
  1. package/.cursor/rules/funifier.mdc +91 -0
  2. package/.github/copilot-instructions.md +83 -0
  3. package/AGENTS.md +97 -0
  4. package/README.md +351 -351
  5. package/datasource-funifier-docs/knowledge/guides/aggregates.md +152 -0
  6. package/datasource-funifier-docs/knowledge/guides/database-access.md +132 -0
  7. package/datasource-funifier-docs/knowledge/guides/java-entities.md +373 -0
  8. package/datasource-funifier-docs/knowledge/guides/java-libraries.md +330 -0
  9. package/datasource-funifier-docs/knowledge/guides/java-managers.md +509 -0
  10. package/datasource-funifier-docs/knowledge/guides/triggers-guide.md +271 -0
  11. package/datasource-funifier-docs/knowledge/index.md +121 -0
  12. package/datasource-funifier-docs/knowledge/modules/achievement.md +46 -0
  13. package/datasource-funifier-docs/knowledge/modules/action-log.md +88 -0
  14. package/datasource-funifier-docs/knowledge/modules/action.md +80 -0
  15. package/datasource-funifier-docs/knowledge/modules/auth.md +104 -0
  16. package/datasource-funifier-docs/knowledge/modules/avatar.md +28 -0
  17. package/datasource-funifier-docs/knowledge/modules/backup.md +40 -0
  18. package/datasource-funifier-docs/knowledge/modules/challenge.md +91 -0
  19. package/datasource-funifier-docs/knowledge/modules/compact.md +40 -0
  20. package/datasource-funifier-docs/knowledge/modules/competition.md +149 -0
  21. package/datasource-funifier-docs/knowledge/modules/crossword.md +41 -0
  22. package/datasource-funifier-docs/knowledge/modules/csv-data.md +30 -0
  23. package/datasource-funifier-docs/knowledge/modules/custom-object.md +53 -0
  24. package/datasource-funifier-docs/knowledge/modules/database.md +241 -0
  25. package/datasource-funifier-docs/knowledge/modules/folder.md +111 -0
  26. package/datasource-funifier-docs/knowledge/modules/kpi-formulas.md +23 -0
  27. package/datasource-funifier-docs/knowledge/modules/lastmile.md +45 -0
  28. package/datasource-funifier-docs/knowledge/modules/leaderboard.md +98 -0
  29. package/datasource-funifier-docs/knowledge/modules/level.md +83 -0
  30. package/datasource-funifier-docs/knowledge/modules/lottery.md +112 -0
  31. package/datasource-funifier-docs/knowledge/modules/marketplace.md +27 -0
  32. package/datasource-funifier-docs/knowledge/modules/mystery.md +82 -0
  33. package/datasource-funifier-docs/knowledge/modules/notification.md +40 -0
  34. package/datasource-funifier-docs/knowledge/modules/patterns.md +1096 -0
  35. package/datasource-funifier-docs/knowledge/modules/player.md +101 -0
  36. package/datasource-funifier-docs/knowledge/modules/point.md +67 -0
  37. package/datasource-funifier-docs/knowledge/modules/public.md +253 -0
  38. package/datasource-funifier-docs/knowledge/modules/question.md +136 -0
  39. package/datasource-funifier-docs/knowledge/modules/quiz.md +163 -0
  40. package/datasource-funifier-docs/knowledge/modules/scheduler.md +58 -0
  41. package/datasource-funifier-docs/knowledge/modules/security.md +169 -0
  42. package/datasource-funifier-docs/knowledge/modules/staging.md +28 -0
  43. package/datasource-funifier-docs/knowledge/modules/static-repo.md +41 -0
  44. package/datasource-funifier-docs/knowledge/modules/story.md +42 -0
  45. package/datasource-funifier-docs/knowledge/modules/studio-page.md +180 -0
  46. package/datasource-funifier-docs/knowledge/modules/swap.md +132 -0
  47. package/datasource-funifier-docs/knowledge/modules/team.md +75 -0
  48. package/datasource-funifier-docs/knowledge/modules/trigger.md +189 -0
  49. package/datasource-funifier-docs/knowledge/modules/upload.md +155 -0
  50. package/datasource-funifier-docs/knowledge/modules/virtual-good.md +99 -0
  51. package/datasource-funifier-docs/knowledge/modules/webhook.md +41 -0
  52. package/datasource-funifier-docs/knowledge/modules/websocket.md +41 -0
  53. package/datasource-funifier-docs/knowledge/modules/widget.md +42 -0
  54. package/datasource-funifier-docs/process-gtm-saas.md +143 -0
  55. package/datasource-funifier-docs/process-instagram.md +88 -0
  56. package/datasource-funifier-docs/process.md +1826 -0
  57. package/datasource-funifier-docs/readme.md +132 -0
  58. package/dist/cli/config-writers.d.ts +15 -0
  59. package/dist/cli/config-writers.d.ts.map +1 -0
  60. package/dist/cli/config-writers.js +55 -0
  61. package/dist/cli/config-writers.js.map +1 -0
  62. package/dist/cli/config-writers.test.d.ts +2 -0
  63. package/dist/cli/config-writers.test.d.ts.map +1 -0
  64. package/dist/cli/config-writers.test.js +55 -0
  65. package/dist/cli/config-writers.test.js.map +1 -0
  66. package/dist/cli/copy.d.ts +6 -0
  67. package/dist/cli/copy.d.ts.map +1 -0
  68. package/dist/cli/copy.js +63 -0
  69. package/dist/cli/copy.js.map +1 -0
  70. package/dist/cli/copy.test.d.ts +2 -0
  71. package/dist/cli/copy.test.d.ts.map +1 -0
  72. package/dist/cli/copy.test.js +94 -0
  73. package/dist/cli/copy.test.js.map +1 -0
  74. package/dist/cli/init.d.ts +2 -0
  75. package/dist/cli/init.d.ts.map +1 -0
  76. package/dist/cli/init.js +167 -0
  77. package/dist/cli/init.js.map +1 -0
  78. package/dist/cli/paths.d.ts +7 -0
  79. package/dist/cli/paths.d.ts.map +1 -0
  80. package/dist/cli/paths.js +62 -0
  81. package/dist/cli/paths.js.map +1 -0
  82. package/dist/cli/paths.test.d.ts +2 -0
  83. package/dist/cli/paths.test.d.ts.map +1 -0
  84. package/dist/cli/paths.test.js +50 -0
  85. package/dist/cli/paths.test.js.map +1 -0
  86. package/dist/cli/platforms.d.ts +22 -0
  87. package/dist/cli/platforms.d.ts.map +1 -0
  88. package/dist/cli/platforms.js +50 -0
  89. package/dist/cli/platforms.js.map +1 -0
  90. package/dist/cli/prompts.d.ts +7 -0
  91. package/dist/cli/prompts.d.ts.map +1 -0
  92. package/dist/cli/prompts.js +49 -0
  93. package/dist/cli/prompts.js.map +1 -0
  94. package/dist/index.js +1 -1
  95. package/dist/index.js.map +1 -1
  96. package/dist/mcp/bundle.js +98 -50
  97. package/dist/mcp/index.js +18 -1
  98. package/dist/mcp/index.js.map +1 -1
  99. package/package.json +70 -65
  100. package/skills/funifier-create-action/SKILL.md +86 -86
  101. package/skills/funifier-create-aggregate/SKILL.md +126 -87
  102. package/skills/funifier-create-challenge/SKILL.md +87 -87
  103. package/skills/funifier-create-custom-page/SKILL.md +126 -87
  104. package/skills/funifier-create-leaderboard/SKILL.md +87 -87
  105. package/skills/funifier-create-level/SKILL.md +86 -86
  106. package/skills/funifier-create-point/SKILL.md +86 -86
  107. package/skills/funifier-create-quiz/SKILL.md +86 -86
  108. package/skills/funifier-create-scheduler/SKILL.md +126 -87
  109. package/skills/funifier-create-trigger/SKILL.md +127 -88
  110. package/skills/funifier-create-virtual-good/SKILL.md +86 -86
  111. package/skills/funifier-debug/SKILL.md +90 -90
  112. package/skills/funifier-help/SKILL.md +85 -85
  113. package/skills/funifier-implement-frontend/SKILL.md +89 -89
  114. package/skills/funifier-index/SKILL.md +50 -50
@@ -0,0 +1,330 @@
1
+ # Java Libraries — Referência
2
+
3
+ Bibliotecas e utilitários disponíveis para uso em **triggers**, **schedulers** e **public endpoints**.
4
+
5
+ ---
6
+
7
+ ## JsonUtil
8
+
9
+ **Classe:** `com.funifier.engine.util.JsonUtil`
10
+
11
+ Utilitário estático para serialização/deserialização JSON (baseado em Jackson).
12
+
13
+ | Método | Retorno | Descrição |
14
+ |--------|---------|-----------|
15
+ | `toJson(Object obj)` | String | Converte objeto para JSON string |
16
+ | `toJsonRemoveNullFields(Object obj)` | String | Converte para JSON excluindo campos null |
17
+ | `fromJson(String json, Class<T> valueType)` | T | Converte JSON string para objeto tipado |
18
+ | `fromJsonToMap(String json)` | Map\<String, Object\> | Converte JSON string para Map |
19
+ | `toBsonStrictMode(Object obj)` | String | Converte para BSON strict mode (MongoDB) |
20
+
21
+ **Exemplos:**
22
+
23
+ ```java
24
+ // Objeto para JSON
25
+ HashMap data = new HashMap();
26
+ data.put("name", "John");
27
+ data.put("score", 100);
28
+ String json = JsonUtil.toJson(data);
29
+ // {"name":"John","score":100}
30
+
31
+ // JSON para Map
32
+ Map<String, Object> map = JsonUtil.fromJsonToMap("{\"name\":\"John\",\"score\":100}");
33
+ String name = (String) map.get("name");
34
+
35
+ // JSON para objeto tipado
36
+ Player player = JsonUtil.fromJson(jsonString, Player.class);
37
+
38
+ // Ignorar campos null
39
+ String cleanJson = JsonUtil.toJsonRemoveNullFields(obj);
40
+ ```
41
+
42
+ ---
43
+
44
+ ## Guid
45
+
46
+ **Classe:** `com.funifier.engine.guid.Guid`
47
+
48
+ Geração de identificadores únicos.
49
+
50
+ | Método | Retorno | Descrição |
51
+ |--------|---------|-----------|
52
+ | `newShortGuid()` | String | Gera ID único (MongoDB ObjectId, 24 chars) |
53
+ | `shortTimeMillis()` | String | Gera código baseado no timestamp (base62, ~7 chars) |
54
+
55
+ **Exemplos:**
56
+
57
+ ```java
58
+ // Gerar ID para novo objeto
59
+ String id = Guid.newShortGuid();
60
+ // Ex: "64a5d92f1b2c3d4e5f6a7b8c"
61
+
62
+ // Gerar código curto baseado no tempo (útil para códigos de convite)
63
+ String code = Guid.shortTimeMillis();
64
+ // Ex: "y6z3D6H"
65
+ ```
66
+
67
+ **Quando usar cada um:**
68
+ - `newShortGuid()` — Para IDs de objetos (achievements, action logs, etc.)
69
+ - `shortTimeMillis()` — Para códigos legíveis (convites, vouchers, etc.)
70
+
71
+ ---
72
+
73
+ ## DateUtil
74
+
75
+ **Classe:** `com.funifier.engine.util.DateUtil`
76
+
77
+ Utilitário para cálculos e parsing de datas, incluindo as **expressões de data Funifier**.
78
+
79
+ ### Expressões de Data (Funifier Syntax)
80
+
81
+ Formato: `[sinal][quantidade][unidade][ajuste]`
82
+
83
+ **Unidades:** `y`=ano, `M`=mês, `w`=semana, `d`=dia, `h`=hora, `m`=minuto, `s`=segundo
84
+
85
+ **Ajuste:** `-` = início da unidade (floor), `+` = fim da unidade (ceil), sem ajuste = exato
86
+
87
+ | Expressão | Significado |
88
+ |-----------|------------|
89
+ | `-0d` | Agora |
90
+ | `-0d-` | Início do dia atual (00:00:00) |
91
+ | `-0d+` | Fim do dia atual (23:59:59) |
92
+ | `-1d` | Exatamente 1 dia atrás |
93
+ | `-1d-` | Início do dia anterior |
94
+ | `-1d+` | Fim do dia anterior |
95
+ | `+1d` | Exatamente 1 dia no futuro |
96
+ | `+1d-` | Início do dia seguinte |
97
+ | `-0w-` | Início da semana atual |
98
+ | `-0w+` | Fim da semana atual |
99
+ | `-0M-` | Primeiro dia do mês (00:00:00) |
100
+ | `-0M+` | Último dia do mês (23:59:59) |
101
+ | `-1M-` | Primeiro dia do mês anterior |
102
+ | `-0y-` | 1 de janeiro do ano atual |
103
+ | `-0y+` | 31 de dezembro do ano atual |
104
+
105
+ **Encadeamento com `|`:**
106
+ ```
107
+ -1d+|GMT+3 → fim do dia anterior no fuso GMT+3
108
+ -0d-|+5h|+30m|GMT-3 → início do dia + 5h30m no fuso GMT-3
109
+ ```
110
+
111
+ ### Métodos
112
+
113
+ | Método | Retorno | Descrição |
114
+ |--------|---------|-----------|
115
+ | `fromKeyword(String keyword)` | Date | Converte expressão Funifier em Date |
116
+ | `fromKeyword(String keyword, Date reference)` | Date | Converte com data de referência |
117
+ | `fromKeyword(String keyword, Date reference, String timezone)` | Date | Converte com referência e timezone |
118
+ | `fromKeywordPeriodExpression(String period)` | Date[] | Converte período (ex: "-0M-;-0M+") em [inicio, fim] |
119
+ | `parse(Object date)` | Date | Parse genérico (Date, Long, String, expressão) |
120
+ | `parse(String date, String pattern)` | Date | Parse com padrão SimpleDateFormat |
121
+ | `format(Date date, String pattern)` | String | Formata data com padrão SimpleDateFormat |
122
+ | `between(Date ref, int scale, int amount)` | Date[] | Intervalo [inicio, fim] da unidade |
123
+ | `add(Date ref, int scale, int amount)` | Date | Adiciona unidades à data |
124
+ | `reset(Date date, int scale)` | Date | Trunca data para o início da unidade |
125
+
126
+ **Escalas (TimeScale):**
127
+ ```java
128
+ TimeScale.MILLISECOND = 0;
129
+ TimeScale.SECOND = 1;
130
+ TimeScale.MINUTE = 2;
131
+ TimeScale.HOUR = 3;
132
+ TimeScale.DAY = 4;
133
+ TimeScale.WEEK = 5;
134
+ TimeScale.MONTH = 6;
135
+ TimeScale.YEAR = 7;
136
+ ```
137
+
138
+ **Exemplos:**
139
+
140
+ ```java
141
+ // Usar expressões Funifier
142
+ Date inicioMes = DateUtil.fromKeyword("-0M-");
143
+ Date fimMes = DateUtil.fromKeyword("-0M+");
144
+ Date ontem = DateUtil.fromKeyword("-1d");
145
+
146
+ // Período completo
147
+ Date[] periodo = DateUtil.fromKeywordPeriodExpression("-0M-;-0M+");
148
+ Date inicio = periodo[0];
149
+ Date fim = periodo[1];
150
+
151
+ // Parse genérico
152
+ Date d1 = DateUtil.parse("2023-07-05T20:57:33.303Z");
153
+ Date d2 = DateUtil.parse("-1d");
154
+
155
+ // Formatar data
156
+ String formatted = DateUtil.format(new Date(), "dd/MM/yyyy HH:mm:ss");
157
+
158
+ // Adicionar tempo
159
+ Date amanha = DateUtil.add(new Date(), TimeScale.DAY, 1);
160
+ Date mesPassado = DateUtil.add(new Date(), TimeScale.MONTH, -1);
161
+ ```
162
+
163
+ > **Referência completa de expressões de data em consultas:** consulte `guides/aggregates.md`.
164
+
165
+ ---
166
+
167
+ ## Unirest
168
+
169
+ **Biblioteca:** `com.mashape.unirest`
170
+
171
+ Cliente HTTP para fazer requisições a APIs externas.
172
+
173
+ **Exemplos:**
174
+
175
+ ```java
176
+ // GET
177
+ HttpResponse<String> response = Unirest.get("https://api.example.com/data")
178
+ .header("Authorization", "Bearer token123")
179
+ .asString();
180
+ String body = response.getBody();
181
+ int status = response.getStatus();
182
+
183
+ // POST com JSON
184
+ HashMap payload = new HashMap();
185
+ payload.put("name", "John");
186
+ payload.put("email", "john@email.com");
187
+
188
+ HttpResponse<String> response = Unirest.post("https://api.example.com/users")
189
+ .header("Content-Type", "application/json")
190
+ .body(JsonUtil.toJson(payload))
191
+ .asString();
192
+
193
+ // POST form
194
+ HttpResponse<String> response = Unirest.post("https://api.example.com/form")
195
+ .field("username", "john")
196
+ .field("password", "secret")
197
+ .asString();
198
+
199
+ // PUT
200
+ HttpResponse<String> response = Unirest.put("https://api.example.com/users/1")
201
+ .header("Content-Type", "application/json")
202
+ .body(JsonUtil.toJson(payload))
203
+ .asString();
204
+
205
+ // DELETE
206
+ HttpResponse<String> response = Unirest.delete("https://api.example.com/users/1")
207
+ .asString();
208
+ ```
209
+
210
+ ---
211
+
212
+ ## EmailBuilder (SimpleJavaMail)
213
+
214
+ **Biblioteca:** `org.simplejavamail`
215
+
216
+ Envio de emails via SMTP.
217
+
218
+ **Exemplos:**
219
+
220
+ ```java
221
+ // Enviar email simples
222
+ Email email = EmailBuilder
223
+ .startingBlank()
224
+ .from("Company", "noreply@company.com")
225
+ .to("John", "john@email.com")
226
+ .withSubject("Welcome!")
227
+ .withPlainText("Welcome to our platform!")
228
+ .buildEmail();
229
+
230
+ MailerBuilder.withSMTPServer("smtp.host.com", 587, "login", "password")
231
+ .buildMailer()
232
+ .sendMail(email);
233
+
234
+ // Email com HTML
235
+ Email email = EmailBuilder
236
+ .startingBlank()
237
+ .from("Company", "noreply@company.com")
238
+ .to("John", "john@email.com")
239
+ .withSubject("Report")
240
+ .withHTMLText("<h1>Hello</h1><p>Your monthly report is ready.</p>")
241
+ .buildEmail();
242
+
243
+ MailerBuilder.withSMTPServer("smtp.host.com", 587, "login", "password")
244
+ .buildMailer()
245
+ .sendMail(email);
246
+ ```
247
+
248
+ ---
249
+
250
+ ## Jongo (Acesso ao MongoDB)
251
+
252
+ **Biblioteca:** `org.jongo`
253
+
254
+ Acesso direto ao MongoDB através do objeto `database` (em triggers) ou `manager.getJongoConnection()`.
255
+
256
+ ### Operações
257
+
258
+ ```java
259
+ // Obter coleção
260
+ org.jongo.MongoCollection collection = database.getCollection("nome_colecao");
261
+
262
+ // --- INSERT / UPDATE ---
263
+ // Save (insere ou atualiza se _id existir)
264
+ database.getCollection("email__c").save(hashMap);
265
+
266
+ // --- FIND ---
267
+ // Buscar um documento
268
+ Object result = database.getCollection("player")
269
+ .findOne("{_id: 'john'}").as(Object.class);
270
+
271
+ // Buscar com parâmetro (#)
272
+ Object result = database.getCollection("product__c")
273
+ .findOne("{_id: #}", productId).as(Object.class);
274
+
275
+ // Buscar vários
276
+ Iterable<Object> results = database.getCollection("action_log")
277
+ .find("{userId: #}", "john").as(Object.class);
278
+
279
+ // Buscar com projeção
280
+ Object result = database.getCollection("player")
281
+ .findOne("{_id: #}", id)
282
+ .projection("{name: 1, email: 1}")
283
+ .as(Object.class);
284
+
285
+ // --- DELETE ---
286
+ database.getCollection("car__c").remove("{_id: 'car001'}");
287
+
288
+ // --- COUNT ---
289
+ long total = database.getCollection("action_log")
290
+ .count("{userId: #}", "john");
291
+
292
+ // --- AGGREGATE ---
293
+ Iterable<Object> result = database.getCollection("achievement")
294
+ .aggregate("{$match: {type: 0, item: 'xp'}}")
295
+ .and("{$group: {_id: '$player', total: {$sum: '$total'}}}")
296
+ .and("{$sort: {total: -1}}")
297
+ .and("{$limit: 10}")
298
+ .as(Object.class);
299
+ ```
300
+
301
+ ### Parâmetros com `#`
302
+
303
+ O Jongo usa `#` como placeholder para parâmetros seguros (evita injection):
304
+
305
+ ```java
306
+ // Um parâmetro
307
+ database.getCollection("player").findOne("{_id: #}", playerId).as(Object.class);
308
+
309
+ // Múltiplos parâmetros
310
+ database.getCollection("action_log")
311
+ .find("{userId: #, actionId: #}", "john", "sell")
312
+ .as(Object.class);
313
+ ```
314
+
315
+ > **Referência completa:** consulte `guides/database-access.md` e `guides/aggregates.md`.
316
+
317
+ ---
318
+
319
+ ## Resumo Rápido
320
+
321
+ | Necessidade | O que usar |
322
+ |------------|-----------|
323
+ | Converter objeto para JSON | `JsonUtil.toJson(obj)` |
324
+ | Converter JSON para objeto | `JsonUtil.fromJson(json, Class)` |
325
+ | Gerar ID único | `Guid.newShortGuid()` |
326
+ | Gerar código curto | `Guid.shortTimeMillis()` |
327
+ | Calcular data com expressão | `DateUtil.fromKeyword("-0M-")` |
328
+ | Fazer requisição HTTP | `Unirest.get/post/put/delete(url)` |
329
+ | Enviar email | `EmailBuilder.startingBlank()...` |
330
+ | Acessar MongoDB | `database.getCollection("nome")` |