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,152 @@
1
+ # Aggregates Funifier
2
+
3
+ A plataforma Funifier utiliza o MongoDB como banco de dados, permitindo consultas avançadas por meio de **aggregates**. Esta funcionalidade é fundamental para extrair relatórios, gerar indicadores personalizados e construir dashboards.
4
+
5
+ ## Como Executar
6
+
7
+ **Método:** POST
8
+ **Endpoint:** `/v3/database/{collection}/aggregate`
9
+ **Body:** Pipeline JSON com comandos aggregate
10
+
11
+ ## Principais Coleções
12
+
13
+ ### player
14
+ Jogadores da gamificação.
15
+ ```json
16
+ {"_id": "john", "name": "John Travolta", "email": "john@funifier.com", "teams": ["sales"], "extra": {"country": "USA", "department": "IT"}, "created": {"$date": "2023-07-05T20:57:25.776Z"}}
17
+ ```
18
+
19
+ ### action
20
+ Configurações dos tipos de ações.
21
+ ```json
22
+ {"_id": "sell", "action": "Sell", "attributes": [{"name": "product", "type": "String"}, {"name": "price", "type": "Number"}], "active": true}
23
+ ```
24
+
25
+ ### action_log
26
+ Ações executadas pelos jogadores. Campo `userId` → `player._id`. Campo `actionId` → `action._id`.
27
+ ```json
28
+ {"_id": "64a5d92", "actionId": "sell", "userId": "john", "time": {"$date": "2023-07-05T20:57:33.303Z"}, "attributes": {"product": "book", "price": 120}}
29
+ ```
30
+
31
+ ### achievement
32
+ Conquistas dos jogadores. Campo `type`: 0=Point, 1=Challenge, 2=Virtual Good, 3=Level. Campo `player` → `player._id`.
33
+ ```json
34
+ {"_id": "64a5d2", "player": "john", "total": 25.0, "type": 0, "item": "xp", "time": {"$date": "2023-07-05T20:57:33.303Z"}}
35
+ ```
36
+
37
+ ### challenge
38
+ Desafios da gamificação.
39
+ ```json
40
+ {"challenge": "Watch Video", "active": true, "_id": "DTo8dS3", "rules": [{"actionId": "watch_video", "operator": 5, "total": 0}], "points": [{"total": 10.0, "category": "xp", "operation": 0}]}
41
+ ```
42
+
43
+ ### point_category
44
+ Tipos de pontos.
45
+ ```json
46
+ {"_id": "xp", "category": "Experience Points", "shortName": "XP", "extra": {}}
47
+ ```
48
+
49
+ ### catalog_item
50
+ Itens da loja virtual.
51
+ ```json
52
+ {"_id": "prd1", "catalogId": "gifts", "name": "T-shirt", "amount": 100, "active": true, "requires": [{"total": 15, "type": 0, "item": "coin", "operation": 1}]}
53
+ ```
54
+
55
+ ## Expressões de Data (Funifier Syntax)
56
+
57
+ Formato: `[sinal][quantidade][unidade][ajuste opcional]`
58
+
59
+ | Expressão | Significado |
60
+ |-----------|------------|
61
+ | `-0d` | Agora |
62
+ | `-0d-` | Início do dia atual (00:00:00) |
63
+ | `-0d+` | Fim do dia atual (23:59:59) |
64
+ | `-1d` | Exatamente um dia atrás |
65
+ | `-1d-` | Início do dia anterior (00:00:00) |
66
+ | `-1d+` | Fim do dia anterior (23:59:59) |
67
+ | `-0w-` | Início da semana atual |
68
+ | `-0w+` | Fim da semana atual |
69
+ | `-1w` | Exatamente uma semana atrás |
70
+ | `-0M-` | Início do mês atual |
71
+ | `-0M+` | Fim do mês atual |
72
+ | `-1M` | Exatamente um mês atrás |
73
+ | `-1M-` | Início do mês anterior |
74
+ | `-0y-` | Início do ano atual |
75
+ | `-0y+` | Fim do ano atual |
76
+
77
+ **Unidades:** `m`=minuto, `h`=hora, `d`=dia, `w`=semana, `M`=mês, `y`=ano
78
+
79
+ **Uso em filtros:**
80
+ ```json
81
+ {"$date": "-0M-"}
82
+ ```
83
+
84
+ ## Operadores Suportados
85
+
86
+ `$match`, `$group`, `$sort`, `$limit`, `$lookup`, `$project`, `$unwind`, `$addFields`, `$count`
87
+
88
+ ## Exemplos Práticos
89
+
90
+ ### Exemplo 1: Top 10 jogadores com mais pontos XP no mês atual
91
+
92
+ ```json
93
+ // POST /v3/database/achievement/aggregate
94
+ [
95
+ {"$match": {"type": 0, "item": "xp", "time": {"$gte": {"$date": "-0M-"}, "$lte": {"$date": "-0M+"}}}},
96
+ {"$group": {"_id": "$player", "total": {"$sum": "$total"}}},
97
+ {"$sort": {"total": -1}},
98
+ {"$lookup": {"from": "player", "localField": "_id", "foreignField": "_id", "as": "p"}},
99
+ {"$unwind": "$p"},
100
+ {"$project": {"_id": 1, "player": "$p.name", "total": 1}},
101
+ {"$limit": 10}
102
+ ]
103
+ ```
104
+
105
+ ### Exemplo 2: Quantos jogadores distintos completaram um desafio
106
+
107
+ ```json
108
+ // POST /v3/database/achievement/aggregate
109
+ [
110
+ {"$match": {"type": 1, "item": "DTo8dS3"}},
111
+ {"$group": {"_id": "$player", "challenge": {"$first": "$item"}}},
112
+ {"$group": {"_id": "$challenge", "total_players": {"$sum": 1}}},
113
+ {"$lookup": {"from": "challenge", "localField": "_id", "foreignField": "_id", "as": "c"}},
114
+ {"$project": {"_id": 1, "total_players": 1, "challenge_name": {"$first": "$c.challenge"}}}
115
+ ]
116
+ ```
117
+
118
+ ### Exemplo 3: Média de pontos XP por jogador em um mês específico
119
+
120
+ ```json
121
+ // POST /v3/database/achievement/aggregate
122
+ [
123
+ {"$match": {"type": 0, "item": "xp", "time": {"$gte": {"$date": "2023-08-01T00:00:00.000Z"}, "$lte": {"$date": "2023-08-31T23:59:59.999Z"}}}},
124
+ {"$group": {"_id": "$player", "averageXP": {"$avg": "$total"}}}
125
+ ]
126
+ ```
127
+
128
+ ### Exemplo 4: Top 3 itens mais vendidos na loja virtual este ano
129
+
130
+ ```json
131
+ // POST /v3/database/achievement/aggregate
132
+ [
133
+ {"$match": {"type": 2, "time": {"$gte": {"$date": "-0y-"}, "$lte": {"$date": "-0y+"}}}},
134
+ {"$group": {"_id": "$item", "totalSold": {"$sum": "$total"}}},
135
+ {"$lookup": {"from": "catalog_item", "localField": "_id", "foreignField": "_id", "as": "ci"}},
136
+ {"$project": {"_id": 1, "catalogItemName": {"$first": "$ci.name"}, "totalSold": 1}},
137
+ {"$sort": {"totalSold": -1}},
138
+ {"$limit": 3}
139
+ ]
140
+ ```
141
+
142
+ ### Exemplo 5: Jogadores que executaram ações ontem
143
+
144
+ ```json
145
+ // POST /v3/database/action_log/aggregate
146
+ [
147
+ {"$match": {"time": {"$gte": {"$date": "-1d-"}, "$lte": {"$date": "-1d+"}}}},
148
+ {"$group": {"_id": "$userId"}},
149
+ {"$lookup": {"from": "player", "localField": "_id", "foreignField": "_id", "as": "p"}},
150
+ {"$project": {"_id": 1, "playerName": {"$first": "$p.name"}}}
151
+ ]
152
+ ```
@@ -0,0 +1,132 @@
1
+ # Acesso ao Banco de Dados Funifier
2
+
3
+ A plataforma Funifier oferece duas formas principais de acessar e manipular os dados da gamificação:
4
+
5
+ 1. **Via API REST** — endpoint `/v3/database`
6
+ 2. **Via código Java** — objeto `manager` em triggers, schedulers e public endpoints
7
+
8
+ Ambas utilizam **MongoDB** como banco de dados.
9
+
10
+ ---
11
+
12
+ ## 1. Acesso via API — Endpoint `/v3/database`
13
+
14
+ ### 1.1 Listar Coleções Disponíveis
15
+
16
+ **Método:** GET
17
+ **Endpoint:** `/v3/database/collections`
18
+
19
+ **Resposta:**
20
+ ```json
21
+ ["player", "action_log", "achievement", "challenge", "car__c", "email__c"]
22
+ ```
23
+
24
+ ### 1.2 Operações CRUD
25
+
26
+ | Operação | Método | Endpoint | Descrição |
27
+ |----------|--------|----------|-----------|
28
+ | Create | POST | `/v3/database/:collection` | Cria um novo registro |
29
+ | Read | GET | `/v3/database/:collection` | Lista registros da coleção |
30
+ | Update | PUT | `/v3/database/:collection` | Atualiza registro existente (via `_id`) |
31
+ | Delete | DELETE | `/v3/database/:collection?q=...` | Remove registros com filtro |
32
+ | Bulk Insert | POST | `/v3/database/:collection/bulk` | Cria/atualiza múltiplos registros |
33
+
34
+ **Exemplo — Criar item na coleção `car__c`:**
35
+ ```
36
+ POST /v3/database/car__c
37
+ ```
38
+ ```json
39
+ {
40
+ "_id": "car001",
41
+ "name": "Civic",
42
+ "brand": "Honda",
43
+ "price": 50000
44
+ }
45
+ ```
46
+
47
+ ### 1.3 Executar Aggregates
48
+
49
+ **Método:** POST
50
+ **Endpoint:** `/v3/database/:collection/aggregate`
51
+
52
+ **Body (pipeline JSON):**
53
+ ```json
54
+ [
55
+ { "$match": { "player": "john", "type": 0, "item": "xp" } },
56
+ { "$group": { "_id": null, "totalXP": { "$sum": "$total" } } }
57
+ ]
58
+ ```
59
+
60
+ **Resultado:**
61
+ ```json
62
+ [{ "totalXP": 250 }]
63
+ ```
64
+
65
+ **Operadores suportados:** `$match`, `$group`, `$sort`, `$limit`, `$lookup`, `$project`, `$unwind`, `$addFields`, `$count`
66
+
67
+ ### 1.4 Índices
68
+
69
+ | Operação | Método | Endpoint |
70
+ |----------|--------|----------|
71
+ | Listar | GET | `/v3/database/:collection/index` |
72
+ | Criar | POST | `/v3/database/:collection/index` |
73
+ | Excluir | DELETE | `/v3/database/:collection/index/:index_name` |
74
+
75
+ **Exemplo — Criar índice:**
76
+ ```json
77
+ { "fuel": 1 }
78
+ ```
79
+
80
+ ---
81
+
82
+ ## 2. Acesso via Código Java (Triggers, Schedulers, Public Endpoints)
83
+
84
+ Módulos que executam código Java têm acesso ao objeto `manager`, que provê conexão direta com o MongoDB através do driver Jongo.
85
+
86
+ ### 2.1 Estrutura de Acesso
87
+
88
+ ```java
89
+ manager.getJongoConnection().getCollection("nome_da_colecao").operacao(...);
90
+ ```
91
+
92
+ ### 2.2 Operações
93
+
94
+ #### Salvar (Insert/Update)
95
+ ```java
96
+ manager.getJongoConnection()
97
+ .getCollection("email__c")
98
+ .save(payload);
99
+ ```
100
+
101
+ #### Buscar (Find)
102
+ ```java
103
+ Object result = manager.getJongoConnection()
104
+ .getCollection("player")
105
+ .findOne("{_id: 'john'}")
106
+ .as(Map.class);
107
+ ```
108
+
109
+ #### Deletar
110
+ ```java
111
+ manager.getJongoConnection()
112
+ .getCollection("car__c")
113
+ .remove("{_id: 'car001'}");
114
+ ```
115
+
116
+ #### Aggregate
117
+ ```java
118
+ Iterable<Map> resultado = manager.getJongoConnection()
119
+ .getCollection("action_log")
120
+ .aggregate("[{ $match: { item: 'xp' } }, { $group: { _id: '$player', total: { $sum: '$total' } } }]")
121
+ .as(Map.class);
122
+ ```
123
+
124
+ ---
125
+
126
+ ## 3. Considerações de Segurança e Boas Práticas
127
+
128
+ - As operações via API devem ser protegidas por **token de autenticação**
129
+ - Endpoints públicos não requerem token — usar com cautela
130
+ - Manipulação direta do banco afeta dados em **tempo real**
131
+ - Sempre testar em **ambiente de homologação** antes de aplicar em produção
132
+ - Coleções customizadas usam sufixo `__c` (ex: `car__c`, `email__c`)
@@ -0,0 +1,373 @@
1
+ # Java Entities — Referência
2
+
3
+ As entidades são os objetos Java (POJOs) que representam os dados armazenados no MongoDB. Cada entidade mapeia para uma coleção no banco de dados.
4
+
5
+ ---
6
+
7
+ ## Entidades Principais
8
+
9
+ ### Player
10
+
11
+ **Coleção MongoDB:** `player`
12
+ **Classe:** `com.funifier.engine.player.Player`
13
+
14
+ ```java
15
+ // Campos principais
16
+ String _id; // ID do jogador (ex: "john")
17
+ String name; // Nome do jogador
18
+ String email; // Email
19
+ String password; // Senha (hash)
20
+ Map<String, Object> extra; // Campos customizados (ex: department, country)
21
+ List<String> teams; // IDs das equipes
22
+ List<String> friends; // IDs dos amigos
23
+ ImageSet image; // Imagens (small, medium, original)
24
+ Date created; // Data de cadastro
25
+ ```
26
+
27
+ ```json
28
+ {"_id": "john", "name": "John Travolta", "email": "john@funifier.com", "teams": ["sales"], "extra": {"country": "USA", "department": "IT"}, "image": {"small": {"url": "..."}, "medium": {"url": "..."}, "original": {"url": "..."}}}
29
+ ```
30
+
31
+ ---
32
+
33
+ ### Achievement
34
+
35
+ **Coleção MongoDB:** `achievement`
36
+ **Classe:** `com.funifier.engine.achievement.Achievement`
37
+
38
+ Representa qualquer conquista do jogador: pontos ganhos, desafios completados, itens comprados, níveis alcançados.
39
+
40
+ ```java
41
+ // Campos principais
42
+ String _id; // ID da conquista
43
+ String player; // ID do jogador
44
+ double total; // Quantidade (pontos, unidades)
45
+ int type; // Tipo (0=Point, 1=Challenge, 2=VirtualGood, 3=Level)
46
+ String item; // ID do item (point_category, challenge, catalog_item, level)
47
+ Date time; // Data da conquista
48
+
49
+ // Constantes de tipo
50
+ static final int TYPE_POINT = 0;
51
+ static final int TYPE_CHALLENGE = 1;
52
+ static final int TYPE_VIRTUAL_GOOD = 2;
53
+ static final int TYPE_LEVEL = 3;
54
+ ```
55
+
56
+ ```json
57
+ {"_id": "64a5d2", "player": "john", "total": 25.0, "type": 0, "item": "xp", "time": {"$date": "2023-07-05T20:57:33.303Z"}}
58
+ ```
59
+
60
+ ---
61
+
62
+ ### ActionLog
63
+
64
+ **Coleção MongoDB:** `action_log`
65
+ **Classe:** `com.funifier.engine.action.ActionLog`
66
+
67
+ Registo de uma ação executada por um jogador.
68
+
69
+ ```java
70
+ // Campos principais
71
+ String _id; // ID do log
72
+ String actionId; // ID da ação (ex: "sell")
73
+ String userId; // ID do jogador (ex: "john")
74
+ Date time; // Data da execução
75
+ Map<String, Object> attributes; // Atributos da ação (ex: product, price)
76
+ ```
77
+
78
+ ```json
79
+ {"_id": "64a5d92", "actionId": "sell", "userId": "john", "time": {"$date": "2023-07-05T20:57:33.303Z"}, "attributes": {"product": "book", "price": 120}}
80
+ ```
81
+
82
+ ---
83
+
84
+ ### Action
85
+
86
+ **Coleção MongoDB:** `action`
87
+ **Classe:** `com.funifier.engine.action.Action`
88
+
89
+ Definição de um tipo de ação.
90
+
91
+ ```java
92
+ // Campos principais
93
+ String _id; // ID da ação (ex: "sell")
94
+ String action; // Nome da ação (ex: "Sell")
95
+ boolean active; // Se está ativa
96
+ List<ActionAttribute> attributes; // Definição dos atributos (name, type)
97
+ ```
98
+
99
+ ```json
100
+ {"_id": "sell", "action": "Sell", "attributes": [{"name": "product", "type": "String"}, {"name": "price", "type": "Number"}], "active": true}
101
+ ```
102
+
103
+ ---
104
+
105
+ ### Challenge
106
+
107
+ **Coleção MongoDB:** `challenge`
108
+ **Classe:** `com.funifier.engine.challenge.Challenge`
109
+
110
+ Definição de um desafio.
111
+
112
+ ```java
113
+ // Campos principais
114
+ String _id; // ID do desafio
115
+ String challenge; // Nome do desafio
116
+ boolean active; // Se está ativo
117
+ List<Rule> rules; // Regras (ação, operador, total)
118
+ List<Reward> points; // Recompensas (pontos, operação)
119
+ ```
120
+
121
+ ```json
122
+ {"_id": "DTo8dS3", "challenge": "Watch Video", "active": true, "rules": [{"actionId": "watch_video", "operator": 5, "total": 0}], "points": [{"total": 10.0, "category": "xp", "operation": 0}]}
123
+ ```
124
+
125
+ ---
126
+
127
+ ### CatalogItem
128
+
129
+ **Coleção MongoDB:** `catalog_item`
130
+ **Classe:** `com.funifier.engine.catalog.CatalogItem`
131
+
132
+ Item da loja virtual.
133
+
134
+ ```java
135
+ // Campos principais
136
+ String _id; // ID do item
137
+ String catalogId; // ID do catálogo
138
+ String name; // Nome do item
139
+ int amount; // Quantidade disponível
140
+ boolean active; // Se está ativo
141
+ Requirement[] requires; // Requisitos para compra (pontos necessários)
142
+ ```
143
+
144
+ ```json
145
+ {"_id": "prd1", "catalogId": "gifts", "name": "T-shirt", "amount": 100, "active": true, "requires": [{"total": 15, "type": 0, "item": "coin", "operation": 1}]}
146
+ ```
147
+
148
+ ---
149
+
150
+ ### Team
151
+
152
+ **Coleção MongoDB:** `team`
153
+ **Classe:** `com.funifier.engine.team.Team`
154
+
155
+ ```java
156
+ String _id; // ID da equipe
157
+ String name; // Nome da equipe
158
+ ```
159
+
160
+ ---
161
+
162
+ ### Level
163
+
164
+ **Coleção MongoDB:** `level`
165
+ **Classe:** `com.funifier.engine.level.Level`
166
+
167
+ ```java
168
+ String _id; // ID do nível
169
+ String level; // Nome do nível
170
+ int position; // Posição (ordem)
171
+ ```
172
+
173
+ ---
174
+
175
+ ### PointCategory
176
+
177
+ **Coleção MongoDB:** `point_category`
178
+ **Classe:** `com.funifier.engine.point.PointCategory`
179
+
180
+ ```java
181
+ String _id; // ID da categoria (ex: "xp")
182
+ String category; // Nome (ex: "Experience Points")
183
+ String shortName; // Abreviação (ex: "XP")
184
+ Map extra; // Campos extras
185
+ ```
186
+
187
+ ---
188
+
189
+ ### Lottery
190
+
191
+ **Coleção MongoDB:** `lottery`
192
+ **Classe:** `com.funifier.engine.lottery.Lottery`
193
+
194
+ ```java
195
+ String _id; // ID do sorteio
196
+ String title; // Título
197
+ boolean active; // Se está ativo
198
+ ```
199
+
200
+ ---
201
+
202
+ ### LotteryTicket
203
+
204
+ **Coleção MongoDB:** `lottery_ticket`
205
+ **Classe:** `com.funifier.engine.lottery.LotteryTicket`
206
+
207
+ ```java
208
+ String _id; // ID do ticket
209
+ String lottery; // ID do sorteio
210
+ String player; // ID do jogador
211
+ ```
212
+
213
+ ---
214
+
215
+ ### MysteryBox
216
+
217
+ **Coleção MongoDB:** `mystery_box`
218
+ **Classe:** `com.funifier.engine.mystery.MysteryBox`
219
+
220
+ ```java
221
+ String _id; // ID da caixa
222
+ String title; // Título
223
+ boolean active; // Se está ativa
224
+ ```
225
+
226
+ ---
227
+
228
+ ### Competition
229
+
230
+ **Coleção MongoDB:** `competition`
231
+ **Classe:** `com.funifier.engine.competition.Competition`
232
+
233
+ ```java
234
+ String _id; // ID da competição
235
+ boolean active; // Se está ativa
236
+ ```
237
+
238
+ ---
239
+
240
+ ### Question
241
+
242
+ **Coleção MongoDB:** `question`
243
+ **Classe:** `com.funifier.engine.question.Question`
244
+
245
+ ```java
246
+ String _id; // ID da pergunta
247
+ String question; // Texto da pergunta
248
+ ```
249
+
250
+ ---
251
+
252
+ ### QuestionLog
253
+
254
+ **Coleção MongoDB:** `question_log`
255
+ **Classe:** `com.funifier.engine.question.QuestionLog`
256
+
257
+ ```java
258
+ String _id; // ID do log
259
+ String player; // ID do jogador
260
+ String question; // ID da pergunta
261
+ ```
262
+
263
+ ---
264
+
265
+ ### Quiz / QuizLog
266
+
267
+ **Coleções:** `quiz` / `quiz_log`
268
+
269
+ ---
270
+
271
+ ### Notification
272
+
273
+ **Coleção MongoDB:** `notification`
274
+ **Classe:** `com.funifier.engine.notify.Notification`
275
+
276
+ ```java
277
+ String _id; // ID da notificação
278
+ String player; // ID do jogador destino
279
+ String title; // Título
280
+ String message; // Mensagem
281
+ Date time; // Data
282
+ ```
283
+
284
+ ---
285
+
286
+ ### Swap
287
+
288
+ **Coleção MongoDB:** `swap`
289
+ **Classe:** `com.funifier.engine.swap.Swap`
290
+
291
+ ---
292
+
293
+ ### Trigger
294
+
295
+ **Coleção MongoDB:** `trigger`
296
+ **Classe:** `com.funifier.engine.integration.trigger.Trigger`
297
+
298
+ ```java
299
+ String _id; // ID da trigger
300
+ String name; // Nome
301
+ String entity; // Entidade (ex: "player", "achievement")
302
+ String event; // Evento (ex: "before_create", "after_win")
303
+ String script; // Código Java
304
+ ```
305
+
306
+ ---
307
+
308
+ ### SchedulerConfig
309
+
310
+ **Coleção MongoDB:** `scheduler`
311
+ **Classe:** `com.funifier.engine.integration.scheduler.SchedulerConfig`
312
+
313
+ ---
314
+
315
+ ### PublicEndpoint
316
+
317
+ **Coleção MongoDB:** `public_endpoint`
318
+ **Classe:** `com.funifier.engine.pub.PublicEndpoint`
319
+
320
+ ---
321
+
322
+ ### Webhook
323
+
324
+ **Coleção MongoDB:** `webhook`
325
+ **Classe:** `com.funifier.engine.webhook.Webhook`
326
+
327
+ ---
328
+
329
+ ## Mapeamento Completo Entidade → Coleção
330
+
331
+ | Entidade | Coleção MongoDB | Classe Java |
332
+ |----------|----------------|-------------|
333
+ | PLAYER | `player` | Player |
334
+ | PLAYER_STATUS | `player_status` | PlayerStatus |
335
+ | TEAM | `team` | Team |
336
+ | TEAM_PLAYER | `team_player` | TeamLink |
337
+ | ACHIEVEMENT | `achievement` | Achievement |
338
+ | CHALLENGE | `challenge` | Challenge |
339
+ | ACTION_LOG | `action_log` | ActionLog |
340
+ | ACTION | `action` | Action |
341
+ | CATALOG | `catalog` | Catalog |
342
+ | CATALOG_ITEM | `catalog_item` | CatalogItem |
343
+ | PURCHASE | `purchase` | Purchase |
344
+ | POINT_CATEGORY | `point_category` | PointCategory |
345
+ | LEVEL | `level` | Level |
346
+ | LEVEL_CONFIG | `level_config` | LevelConfig |
347
+ | LEADERBOARD | `leaderboard` | LeaderBoard_V2 |
348
+ | LEADER | `leader` | Leader |
349
+ | LOTTERY | `lottery` | Lottery |
350
+ | LOTTERY_TICKET | `lottery_ticket` | LotteryTicket |
351
+ | MYSTERY_BOX | `mystery_box` | MysteryBox |
352
+ | MYSTERY_BOX_LOG | `mystery_box_log` | MysteryBoxLog |
353
+ | NOTIFICATION | `notification` | Notification |
354
+ | QUESTION | `question` | Question |
355
+ | QUESTION_LOG | `question_log` | QuestionLog |
356
+ | QUIZ | `quiz` | Quiz |
357
+ | QUIZ_LOG | `quiz_log` | QuizLog |
358
+ | COMPETITION | `competition` | Competition |
359
+ | COMPETITION_JOIN | `competition_join` | CompetitionJoin |
360
+ | SWAP | `swap` | Swap |
361
+ | FOLDER | `folder` | Folder |
362
+ | TRIGGER | `trigger` | Trigger |
363
+ | TRIGGER_LOG | `trigger_log` | TriggerLog |
364
+ | SCHEDULER | `scheduler` | SchedulerConfig |
365
+ | SCHEDULER_LOG | `scheduler_log` | SchedulerLog |
366
+ | PUBLIC_ENDPOINT | `public_endpoint` | PublicEndpoint |
367
+ | WEBHOOK | `webhook` | Webhook |
368
+ | WEBSOCKET | `websocket` | WebSocket |
369
+ | STUDIO_PAGE | `studio_page` | StudioPage |
370
+ | BACKUP | `backup` | Backup |
371
+ | COMPACT | `compact` | Compact |
372
+
373
+ > **Nota:** Coleções customizadas (Custom Objects) usam o sufixo `__c` (ex: `car__c`, `email__c`) e são acessadas como `HashMap`.