forlogic-core 2.1.2 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/README.md +1079 -0
- package/dist/bin/bootstrap.js +40 -0
- package/dist/bin/pull-docs.js +186 -0
- package/dist/components/ui/icon-picker.d.ts +2 -6
- package/dist/docs/KNOWLEDGE.md +109 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/docs/design-system/selectors.md +5 -8
- package/package.json +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import * as fs from 'fs';
|
|
5
|
+
|
|
6
|
+
const skipUpdate = process.argv.includes("--skip-update");
|
|
7
|
+
if (!skipUpdate) {
|
|
8
|
+
try {
|
|
9
|
+
console.log("\u{1F504} Verificando atualiza\xE7\xF5es do forlogic-core...");
|
|
10
|
+
execSync("npm install forlogic-core@latest", { stdio: "inherit" });
|
|
11
|
+
console.log("\u2705 forlogic-core atualizado com sucesso!\n");
|
|
12
|
+
} catch {
|
|
13
|
+
console.warn("\u26A0\uFE0F N\xE3o foi poss\xEDvel atualizar o forlogic-core automaticamente.");
|
|
14
|
+
console.warn(" Continuando com a vers\xE3o instalada...\n");
|
|
15
|
+
}
|
|
16
|
+
} else {
|
|
17
|
+
console.log("\u23ED\uFE0F --skip-update: pulando atualiza\xE7\xE3o do pacote.\n");
|
|
18
|
+
}
|
|
19
|
+
const syncScript = path.join(
|
|
20
|
+
process.cwd(),
|
|
21
|
+
"node_modules",
|
|
22
|
+
"forlogic-core",
|
|
23
|
+
"dist",
|
|
24
|
+
"bin",
|
|
25
|
+
"pull-docs.js"
|
|
26
|
+
);
|
|
27
|
+
if (!fs.existsSync(syncScript)) {
|
|
28
|
+
console.error(`\u274C Script de sync n\xE3o encontrado: ${syncScript}`);
|
|
29
|
+
console.error(" Verifique se forlogic-core est\xE1 instalado: npm install forlogic-core");
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
execSync(`node "${syncScript}"`, {
|
|
34
|
+
stdio: "inherit",
|
|
35
|
+
cwd: process.cwd()
|
|
36
|
+
});
|
|
37
|
+
} catch {
|
|
38
|
+
console.error("\u274C Falha ao executar o sync. Verifique os logs acima.");
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
|
|
5
|
+
function resolvePackagePath() {
|
|
6
|
+
const directPath = path.join(process.cwd(), "node_modules", "forlogic-core");
|
|
7
|
+
if (fs.existsSync(path.join(directPath, "package.json"))) {
|
|
8
|
+
return directPath;
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
const pkgJsonPath = require.resolve("forlogic-core/package.json", {
|
|
12
|
+
paths: [process.cwd()]
|
|
13
|
+
});
|
|
14
|
+
return path.dirname(pkgJsonPath);
|
|
15
|
+
} catch {
|
|
16
|
+
throw new Error(
|
|
17
|
+
"Pacote forlogic-core n\xE3o encontrado.\nExecute: npm install forlogic-core"
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function copyFile(src, dest) {
|
|
22
|
+
if (!fs.existsSync(src)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const destDir = path.dirname(dest);
|
|
26
|
+
if (!fs.existsSync(destDir)) {
|
|
27
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
28
|
+
}
|
|
29
|
+
fs.copyFileSync(src, dest);
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
const README_MARKER = "<!-- managed by lib-update -->";
|
|
33
|
+
function generateProjectReadme(readmePath, projectName, coreVersion) {
|
|
34
|
+
const template = `${README_MARKER}
|
|
35
|
+
# ${projectName}
|
|
36
|
+
|
|
37
|
+
> Projeto baseado em [forlogic-core](https://www.npmjs.com/package/forlogic-core) v${coreVersion}
|
|
38
|
+
|
|
39
|
+
## Setup
|
|
40
|
+
|
|
41
|
+
\`\`\`bash
|
|
42
|
+
# Instalar depend\xEAncias
|
|
43
|
+
npm install
|
|
44
|
+
|
|
45
|
+
# Rodar em desenvolvimento
|
|
46
|
+
npm run dev
|
|
47
|
+
|
|
48
|
+
# Build de produ\xE7\xE3o
|
|
49
|
+
npm run build
|
|
50
|
+
\`\`\`
|
|
51
|
+
|
|
52
|
+
## Scripts Dispon\xEDveis
|
|
53
|
+
|
|
54
|
+
| Comando | Descri\xE7\xE3o |
|
|
55
|
+
|---------|-----------|
|
|
56
|
+
| \`npm run dev\` | Servidor de desenvolvimento (Vite) |
|
|
57
|
+
| \`npm run build\` | Build de produ\xE7\xE3o |
|
|
58
|
+
| \`npm run preview\` | Preview do build |
|
|
59
|
+
| \`npx lib-update\` | Sincronizar regras e docs do forlogic-core |
|
|
60
|
+
|
|
61
|
+
## Documenta\xE7\xE3o
|
|
62
|
+
|
|
63
|
+
- \u{1F4D6} **Regras do projeto**: \`docs/KNOWLEDGE.md\`
|
|
64
|
+
- \u{1F916} **Mem\xF3rias da IA**: \`.note/memory/\`
|
|
65
|
+
- \u{1F3A8} **Design System**: Rota \`/ds\` no app (projeto Admin)
|
|
66
|
+
- \u{1F4E6} **forlogic-core**: [README no npm](https://www.npmjs.com/package/forlogic-core)
|
|
67
|
+
|
|
68
|
+
## Conven\xE7\xF5es
|
|
69
|
+
|
|
70
|
+
- Schema Supabase: \`common\` (nunca \`public\`)
|
|
71
|
+
- Soft delete obrigat\xF3rio (coluna \`deleted_at\`)
|
|
72
|
+
- Sempre usar componentes do \`forlogic-core\` antes de criar novos
|
|
73
|
+
- RLS policies: nunca \`FOR DELETE\`
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
*Gerado automaticamente por \`lib-update\`. \xDAltima sync: forlogic-core v${coreVersion}*
|
|
77
|
+
${README_MARKER}`;
|
|
78
|
+
if (fs.existsSync(readmePath)) {
|
|
79
|
+
const existing = fs.readFileSync(readmePath, "utf-8");
|
|
80
|
+
if (existing.includes(README_MARKER)) {
|
|
81
|
+
const markerRegex = new RegExp(
|
|
82
|
+
`${README_MARKER.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}[\\s\\S]*?${README_MARKER.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`,
|
|
83
|
+
"m"
|
|
84
|
+
);
|
|
85
|
+
const updated2 = existing.replace(markerRegex, template);
|
|
86
|
+
fs.writeFileSync(readmePath, updated2, "utf-8");
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
const updated = template + "\n\n" + existing;
|
|
90
|
+
fs.writeFileSync(readmePath, updated, "utf-8");
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
const destDir = path.dirname(readmePath);
|
|
94
|
+
if (!fs.existsSync(destDir)) {
|
|
95
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
96
|
+
}
|
|
97
|
+
fs.writeFileSync(readmePath, template, "utf-8");
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
async function syncDocs() {
|
|
101
|
+
console.log("\u{1F4E5} Sincronizando regras e conven\xE7\xF5es do forlogic-core...\n");
|
|
102
|
+
console.log("\u2139\uFE0F Detalhes de componentes, props e tipos s\xE3o lidos via cross-project.\n");
|
|
103
|
+
let pkgPath;
|
|
104
|
+
try {
|
|
105
|
+
pkgPath = resolvePackagePath();
|
|
106
|
+
} catch (err) {
|
|
107
|
+
console.error(`\u274C ${err.message}`);
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
const pkgJson = JSON.parse(fs.readFileSync(path.join(pkgPath, "package.json"), "utf-8"));
|
|
111
|
+
console.log(`\u{1F4E6} forlogic-core v${pkgJson.version}
|
|
112
|
+
`);
|
|
113
|
+
const projectRoot = process.cwd();
|
|
114
|
+
let successCount = 0;
|
|
115
|
+
let errorCount = 0;
|
|
116
|
+
const filesToCopy = [
|
|
117
|
+
{ src: path.join(pkgPath, "docs", "KNOWLEDGE.md"), dest: path.join(projectRoot, "docs", "KNOWLEDGE.md"), label: "docs/KNOWLEDGE.md" }
|
|
118
|
+
];
|
|
119
|
+
for (const file of filesToCopy) {
|
|
120
|
+
if (copyFile(file.src, file.dest)) {
|
|
121
|
+
const size = fs.statSync(file.dest).size;
|
|
122
|
+
console.log(`\u2705 ${file.label} (${(size / 1024).toFixed(2)} KB)`);
|
|
123
|
+
successCount++;
|
|
124
|
+
} else {
|
|
125
|
+
console.warn(`\u26A0\uFE0F ${file.label} \u2014 n\xE3o encontrado no pacote`);
|
|
126
|
+
errorCount++;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const obsoleteFiles = [
|
|
130
|
+
"docs/DESIGN_SYSTEM.md",
|
|
131
|
+
"docs/COMPONENTS.md",
|
|
132
|
+
"docs/PATTERNS.md",
|
|
133
|
+
".note/memory/rules/supabase-schema-rule.md",
|
|
134
|
+
".note/memory/rules/supabase-import-rule.md",
|
|
135
|
+
".note/memory/rules/lib-first-rule.md",
|
|
136
|
+
".note/memory/rules/no-auto-index-rule.md",
|
|
137
|
+
".note/memory/rules/no-delete-policy-rule.md",
|
|
138
|
+
".note/memory/rules/no-env-modification-rule.md",
|
|
139
|
+
".note/memory/rules/rls-syntax-rule.md",
|
|
140
|
+
".note/memory/rules/sql-naming-rule.md",
|
|
141
|
+
".note/memory/rules/i18n-import-rule.md",
|
|
142
|
+
".note/memory/patterns/deprecated-patterns.md",
|
|
143
|
+
".note/memory/patterns/spa-navigation-pattern.md",
|
|
144
|
+
".note/memory/architecture/documentation-strategy.md",
|
|
145
|
+
// Pastas reestruturadas (v2 — padronização 3 pastas)
|
|
146
|
+
".note/memory/rules/doc-sync-rule.md",
|
|
147
|
+
".note/memory/ui/components/combo-tree.md",
|
|
148
|
+
".note/memory/ui/design-system/documentation-standard.md",
|
|
149
|
+
".note/memory/documentation/consolidated-components-registry.md"
|
|
150
|
+
];
|
|
151
|
+
let cleanedCount = 0;
|
|
152
|
+
for (const relPath of obsoleteFiles) {
|
|
153
|
+
const fullPath = path.join(projectRoot, relPath);
|
|
154
|
+
if (fs.existsSync(fullPath)) {
|
|
155
|
+
fs.unlinkSync(fullPath);
|
|
156
|
+
console.log(`\u{1F5D1}\uFE0F ${relPath} (removido \u2014 obsoleto)`);
|
|
157
|
+
cleanedCount++;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (cleanedCount > 0) {
|
|
161
|
+
successCount++;
|
|
162
|
+
}
|
|
163
|
+
const projectReadmePath = path.join(projectRoot, "README.md");
|
|
164
|
+
const projectName = path.basename(projectRoot);
|
|
165
|
+
const readmeGenerated = generateProjectReadme(projectReadmePath, projectName, pkgJson.version);
|
|
166
|
+
if (readmeGenerated) {
|
|
167
|
+
console.log(`\u2705 README.md (gerado/atualizado)`);
|
|
168
|
+
successCount++;
|
|
169
|
+
}
|
|
170
|
+
console.log("\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501");
|
|
171
|
+
console.log(`\u{1F389} Sincroniza\xE7\xE3o conclu\xEDda!`);
|
|
172
|
+
console.log(` \u2705 Sucesso: ${successCount}`);
|
|
173
|
+
if (errorCount > 0) {
|
|
174
|
+
console.log(` \u26A0\uFE0F Avisos: ${errorCount}`);
|
|
175
|
+
}
|
|
176
|
+
console.log("");
|
|
177
|
+
if (successCount > 0) {
|
|
178
|
+
console.log("\u{1F4A1} Arquivos sincronizados:");
|
|
179
|
+
console.log(" docs/KNOWLEDGE.md \u2014 Regras cr\xEDticas + mapa de m\xF3dulos (fonte \xFAnica de verdade)");
|
|
180
|
+
console.log(" README.md \u2014 Template com setup, scripts e links");
|
|
181
|
+
console.log("");
|
|
182
|
+
console.log("\u{1F4D6} Documenta\xE7\xE3o de componentes, props e padr\xF5es s\xE3o lidos");
|
|
183
|
+
console.log(" diretamente do forlogic-core via cross-project.\n");
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
syncDocs();
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export interface IconPickerIcon {
|
|
3
|
-
name: string;
|
|
4
|
-
filled: boolean;
|
|
5
|
-
}
|
|
6
2
|
interface IconPickerProps {
|
|
7
|
-
value?:
|
|
8
|
-
onChange?: (icon:
|
|
3
|
+
value?: string | null;
|
|
4
|
+
onChange?: (icon: string | null) => void;
|
|
9
5
|
label?: string;
|
|
10
6
|
/** i18n: No icon label (default: "SEM ÍCONE") */
|
|
11
7
|
noIconLabel?: string;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# KNOWLEDGE — Regras Críticas do Projeto
|
|
2
|
+
|
|
3
|
+
> 🤖 **Para IA**: Detalhes de componentes, props e tipos → ler do projeto **Admin** via cross-project.
|
|
4
|
+
> Consulte `.note/memory/` para padrões de layout e componentes.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 0. Schema do Projeto
|
|
9
|
+
|
|
10
|
+
**SCHEMA = `common`**
|
|
11
|
+
|
|
12
|
+
☝️ Este é o **único local** onde o schema é definido. Toda query Supabase
|
|
13
|
+
**DEVE** usar `.schema('<valor acima>')`. Altere **apenas aqui** ao configurar
|
|
14
|
+
um novo projeto.
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
// ✅ usar o schema definido acima
|
|
18
|
+
supabase.schema('common').from('tabela').select('*');
|
|
19
|
+
// ❌ vai falhar (sem schema)
|
|
20
|
+
supabase.from('tabela').select('*');
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 1. Regras Invioláveis
|
|
26
|
+
|
|
27
|
+
| Regra | Detalhe |
|
|
28
|
+
|-------|---------|
|
|
29
|
+
| Schema obrigatório | `.schema()` com o schema do projeto (seção 0) em toda query |
|
|
30
|
+
| Sem DELETE físico | Soft delete com `deleted_at` + policy `FOR UPDATE` |
|
|
31
|
+
| Sem índices automáticos | Apenas com aprovação explícita |
|
|
32
|
+
| Sem modificar `.env` | Apenas com autorização do usuário |
|
|
33
|
+
| Sem hardcoded admin | Nunca localStorage/sessionStorage para roles |
|
|
34
|
+
| Lib-first | Usar `forlogic-core` antes de criar componente |
|
|
35
|
+
| Import do Supabase | Sempre `getSupabaseClient()` de `forlogic-core`, nunca `@/integrations/supabase/client` |
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 2. RLS — Resumo de Sintaxe
|
|
40
|
+
|
|
41
|
+
- `SELECT` → `USING` | `INSERT` → `WITH CHECK` | `UPDATE` → `USING` + `WITH CHECK`
|
|
42
|
+
- **Nunca** `FOR DELETE`
|
|
43
|
+
- **Sempre** `(SELECT auth.jwt())` com parênteses (evita re-execução por linha)
|
|
44
|
+
- Padrão multi-tenant: `((SELECT auth.jwt()) ->> 'alias'::text) = alias`
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 3. Convenções SQL
|
|
49
|
+
|
|
50
|
+
| Tipo | Padrão | Exemplo |
|
|
51
|
+
|------|--------|---------|
|
|
52
|
+
| FK | `id_<singular>` | `id_process` |
|
|
53
|
+
| Boolean | `is_` / `has_` | `is_active` |
|
|
54
|
+
| Timestamps | `created_at`, `updated_at`, `deleted_at` | — |
|
|
55
|
+
| Tabelas | plural, snake_case | `processes` |
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 4. Mapa de Módulos (forlogic-core)
|
|
60
|
+
|
|
61
|
+
> Para props, tipos e implementação: ler do projeto **Admin** (forlogic-core) via cross-project.
|
|
62
|
+
|
|
63
|
+
| Módulo | Caminho | O que contém |
|
|
64
|
+
|--------|---------|--------------|
|
|
65
|
+
| **UI Components** | `lib/components/ui/` | Button, Dialog, Input, Select, Combobox, Badge, Tabs, etc. |
|
|
66
|
+
| **Layout** | `lib/components/layout/` | AppLayout, AppHeader, AppSidebar, BodyContent |
|
|
67
|
+
| **CRUD** | `lib/crud/` | createCrudPage, CrudTable, CrudGrid, BaseForm, ActionBar |
|
|
68
|
+
| **CRUD Primitives** | `lib/crud/primitives/` | Table, FilterBar, Pagination, ActionMenu, TreeTable |
|
|
69
|
+
| **Auth** | `lib/auth/` | AuthContext, ProtectedRoute, LoginPage, TokenManager |
|
|
70
|
+
| **Módulos** | `lib/components/modules/` | ModulesDialog, ModuleGrid, ModuleAccessGuard |
|
|
71
|
+
| **Places** | `lib/places/` | PlacesList, PlaceCard, ManageAccessModal |
|
|
72
|
+
| **Leadership** | `lib/leadership/` | LeadershipPage, LeadershipDialog |
|
|
73
|
+
| **Media** | `lib/media/` | ImageEditor, VideoEditor, useMediaUpload |
|
|
74
|
+
| **Sign** | `lib/sign/` | SignWidget, D4SignWidget, SignConfigForm |
|
|
75
|
+
| **Qualiex** | `lib/qualiex/` | QualiexUserField, useQualiexUsers |
|
|
76
|
+
| **i18n** | `lib/i18n/` | Namespaces core/app, JSONs por idioma, addAppTranslations, formatadores |
|
|
77
|
+
| **Config** | `lib/config/` | Environments, CRUD defaults, mensagens |
|
|
78
|
+
| **Services** | `lib/services/` | BaseService, EmailService, ErrorService |
|
|
79
|
+
| **Hooks** | `lib/hooks/` | useDebounce, useWizard, useModuleAccess, useColumnResize |
|
|
80
|
+
| **Providers** | `lib/providers/` | CoreProviders (setup simplificado) |
|
|
81
|
+
| **Vite** | `lib/vite/` | create-config, CSP, security headers |
|
|
82
|
+
| **Tailwind** | `lib/tailwind/` | Preset compartilhado |
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 5. Padrões Deprecated
|
|
87
|
+
|
|
88
|
+
| ❌ Não usar | ✅ Usar |
|
|
89
|
+
|------------|--------|
|
|
90
|
+
| `BulkActionBar` separado | Dropdown no `CrudActionBar` |
|
|
91
|
+
| `<MoreHorizontal>` genérico | `ActionButton` |
|
|
92
|
+
| Paginação manual | `CrudPrimitivePagination` |
|
|
93
|
+
| `StatusSelect` | `Combobox` |
|
|
94
|
+
| `DeleteConfirmationDialog` | `Dialog` |
|
|
95
|
+
| `Searchbar` | `Input` com ícone |
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 6. Fontes de Contexto
|
|
100
|
+
|
|
101
|
+
| Fonte | Caminho | Conteúdo |
|
|
102
|
+
|-------|---------|----------|
|
|
103
|
+
| Memory components | `.note/memory/components/` | Props, variantes e exemplos de componentes |
|
|
104
|
+
| Memory patterns | `.note/memory/patterns/` | Layouts, setup, convenções, regras do projeto |
|
|
105
|
+
| Memory features | `.note/memory/features/` | Contexto de features específicas do projeto |
|
|
106
|
+
| Código-fonte da lib | Cross-project → projeto **Admin** (forlogic-core) | Props, tipos, implementação |
|
|
107
|
+
| Design System (visual) | Rota `/ds` no app do projeto **Admin** | Documentação interativa |
|
|
108
|
+
|
|
109
|
+
> ℹ️ `.note/memory/` usa 3 pastas padronizadas: `components/`, `patterns/`, `features/`. `KNOWLEDGE.md` é a fonte única de verdade para regras e convenções.
|