forlogic-core 1.15.2 → 1.15.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/assets/index.d.ts +6 -0
- package/dist/auth/components/ProtectedRoute.d.ts +6 -0
- package/dist/auth/components/UserInfo.d.ts +10 -0
- package/dist/auth/contexts/AuthContext.d.ts +84 -0
- package/dist/auth/pages/CallbackPage.d.ts +1 -0
- package/dist/auth/pages/LoginPage.d.ts +2 -0
- package/dist/auth/services/AuthService.d.ts +40 -0
- package/dist/auth/services/SupabaseTokenService.d.ts +3 -0
- package/dist/auth/services/TokenManager.d.ts +51 -0
- package/dist/auth/services/TokenRegenerationService.d.ts +12 -0
- package/dist/auth/services/TokenService.d.ts +42 -0
- package/dist/auth/utils/AuthUtils.d.ts +4 -0
- package/dist/auth/utils/ErrorInterceptor.d.ts +15 -0
- package/dist/components/ErrorBoundary.d.ts +19 -0
- package/dist/components/layout/AppHeader.d.ts +63 -0
- package/dist/components/layout/AppLayout.d.ts +10 -0
- package/dist/components/layout/AppSidebar.d.ts +10 -0
- package/dist/components/layout/BodyContent.d.ts +60 -0
- package/dist/components/layout/SidebarActionTrigger.d.ts +34 -0
- package/dist/components/layout/SidebarHeader.d.ts +5 -0
- package/dist/components/layout/sidebar-utils.d.ts +12 -0
- package/dist/components/modules/ModuleGrid.d.ts +9 -0
- package/dist/components/modules/ModulesDialog.d.ts +3 -0
- package/dist/components/modules/icons/ModulesCardIcons.d.ts +19 -0
- package/dist/components/modules/index.d.ts +4 -0
- package/dist/components/modules/modulesData.d.ts +6 -0
- package/dist/components/modules/types.d.ts +35 -0
- package/dist/components/ui/accordion.d.ts +7 -0
- package/dist/components/ui/action-button.d.ts +43 -0
- package/dist/components/ui/alert-dialog.d.ts +20 -0
- package/dist/components/ui/alert.d.ts +12 -0
- package/dist/components/ui/avatar.d.ts +6 -0
- package/dist/components/ui/badge.d.ts +9 -0
- package/dist/components/ui/breadcrumb.d.ts +19 -0
- package/dist/components/ui/button-group.d.ts +9 -0
- package/dist/components/ui/button.d.ts +11 -0
- package/dist/components/ui/calendar.d.ts +8 -0
- package/dist/components/ui/card.d.ts +8 -0
- package/dist/components/ui/chart.d.ts +62 -0
- package/dist/components/ui/checkbox.d.ts +4 -0
- package/dist/components/ui/collapsible.d.ts +5 -0
- package/dist/components/ui/color-picker.d.ts +8 -0
- package/dist/components/ui/combobox.d.ts +33 -0
- package/dist/components/ui/command.d.ts +23 -0
- package/dist/components/ui/context-menu.d.ts +27 -0
- package/dist/components/ui/data-list.d.ts +86 -0
- package/dist/components/ui/date-picker.d.ts +9 -0
- package/dist/components/ui/dialog.d.ts +36 -0
- package/dist/components/ui/disabled-menu-item.d.ts +25 -0
- package/dist/components/ui/drawer.d.ts +22 -0
- package/dist/components/ui/dropdown-menu.d.ts +27 -0
- package/dist/components/ui/empty-state.d.ts +79 -0
- package/dist/components/ui/form.d.ts +23 -0
- package/dist/components/ui/grid.d.ts +53 -0
- package/dist/components/ui/hover-card.d.ts +6 -0
- package/dist/components/ui/icon-picker.d.ts +8 -0
- package/dist/components/ui/input-group.d.ts +97 -0
- package/dist/components/ui/input.d.ts +37 -0
- package/dist/components/ui/label.d.ts +23 -0
- package/dist/components/ui/loading-state.d.ts +52 -0
- package/dist/components/ui/menubar.d.ts +33 -0
- package/dist/components/ui/navigation-menu.d.ts +12 -0
- package/dist/components/ui/onboarding-dialog.d.ts +43 -0
- package/dist/components/ui/page-breadcrumb.d.ts +77 -0
- package/dist/components/ui/pagination.d.ts +28 -0
- package/dist/components/ui/popover.d.ts +49 -0
- package/dist/components/ui/progress.d.ts +22 -0
- package/dist/components/ui/radio-group.d.ts +63 -0
- package/dist/components/ui/resizable.d.ts +23 -0
- package/dist/components/ui/rich-text-editor.d.ts +45 -0
- package/dist/components/ui/scroll-area.d.ts +37 -0
- package/dist/components/ui/select.d.ts +16 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/sheet.d.ts +32 -0
- package/dist/components/ui/sidebar.d.ts +66 -0
- package/dist/components/ui/skeleton-variants.d.ts +16 -0
- package/dist/components/ui/skeleton.d.ts +2 -0
- package/dist/components/ui/slider.d.ts +4 -0
- package/dist/components/ui/sonner.d.ts +3 -0
- package/dist/components/ui/spinner.d.ts +6 -0
- package/dist/components/ui/split-button.d.ts +70 -0
- package/dist/components/ui/stack.d.ts +12 -0
- package/dist/components/ui/step-selector.d.ts +39 -0
- package/dist/components/ui/switch.d.ts +4 -0
- package/dist/components/ui/tab-page-layout.d.ts +19 -0
- package/dist/components/ui/table-resize-handle.d.ts +15 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/components/ui/tabs.d.ts +7 -0
- package/dist/components/ui/textarea.d.ts +5 -0
- package/dist/components/ui/toggle-group.d.ts +12 -0
- package/dist/components/ui/toggle.d.ts +12 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/components/ui/truncated-cell.d.ts +7 -0
- package/dist/components/ui/typography.d.ts +16 -0
- package/dist/config/index.d.ts +53 -0
- package/dist/contexts/LocaleContext.d.ts +15 -0
- package/dist/contexts/ModalStateContext.d.ts +57 -0
- package/dist/contexts/NavigationContext.d.ts +13 -0
- package/dist/contexts/PageMetadataContext.d.ts +43 -0
- package/dist/crud/components/ActionMenuItems.d.ts +17 -0
- package/dist/crud/components/BaseForm.d.ts +6 -0
- package/dist/crud/components/ContextMenu.d.ts +21 -0
- package/dist/crud/components/CrudActionBar.d.ts +38 -0
- package/dist/crud/components/CrudGrid.d.ts +43 -0
- package/dist/crud/components/CrudPagination.d.ts +12 -0
- package/dist/crud/components/CrudTable.d.ts +41 -0
- package/dist/crud/components/FilterBar.d.ts +136 -0
- package/dist/crud/components/TableFooter.d.ts +14 -0
- package/dist/crud/components/TableRowActions.d.ts +14 -0
- package/dist/crud/createCrudPage.d.ts +99 -0
- package/dist/crud/createSimpleService.d.ts +85 -0
- package/dist/crud/generateCrudConfig.d.ts +73 -0
- package/dist/crud/hooks/useBaseForm.d.ts +8 -0
- package/dist/crud/hooks/useCrud.d.ts +117 -0
- package/dist/crud/primitives/ActionMenu.d.ts +28 -0
- package/dist/crud/primitives/FilterBar.d.ts +24 -0
- package/dist/crud/primitives/Pagination.d.ts +24 -0
- package/dist/crud/primitives/Table.d.ts +26 -0
- package/dist/crud/primitives/index.d.ts +11 -0
- package/dist/crud/primitives/types.d.ts +76 -0
- package/dist/crud/utils/routingHelpers.d.ts +30 -0
- package/dist/exports/crud.d.ts +21 -0
- package/dist/exports/integrations.d.ts +13 -0
- package/dist/exports/ui.d.ts +73 -0
- package/dist/hooks/useActiveModules.d.ts +45 -0
- package/dist/hooks/useColumnResize.d.ts +21 -0
- package/dist/hooks/useDebounce.d.ts +56 -0
- package/dist/hooks/useI18nFormatters.d.ts +40 -0
- package/dist/hooks/usePageTitle.d.ts +4 -0
- package/dist/hooks/usePermissionQuery.d.ts +49 -0
- package/dist/hooks/useRowResize.d.ts +19 -0
- package/dist/hooks/useSidebarResize.d.ts +19 -0
- package/dist/hooks/useWizard.d.ts +40 -0
- package/dist/i18n/DatabaseBackend.d.ts +9 -0
- package/dist/i18n/components/TranslationLoader.d.ts +10 -0
- package/dist/i18n/config.d.ts +2 -0
- package/dist/i18n/constants.d.ts +126 -0
- package/dist/i18n/index.d.ts +21 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/leadership/components/LeaderRow.d.ts +9 -0
- package/dist/leadership/components/LeadershipDialog.d.ts +10 -0
- package/dist/leadership/components/LeadershipForm.d.ts +8 -0
- package/dist/leadership/components/LeadershipPage.d.ts +1 -0
- package/dist/leadership/hooks/useLeadershipApi.d.ts +2 -0
- package/dist/leadership/hooks/useLeadershipMutations.d.ts +30 -0
- package/dist/leadership/index.d.ts +14 -0
- package/dist/leadership/types.d.ts +17 -0
- package/dist/leadership/utils/leadershipUtils.d.ts +8 -0
- package/dist/media/components/ImageEditor.d.ts +22 -0
- package/dist/media/components/ImageRenderer.d.ts +23 -0
- package/dist/media/components/VideoEditor.d.ts +22 -0
- package/dist/media/components/VideoRenderer.d.ts +8 -0
- package/dist/media/hooks/useMediaUpload.d.ts +20 -0
- package/dist/media/index.d.ts +49 -0
- package/dist/media/types.d.ts +66 -0
- package/dist/media/utils/imageHelpers.d.ts +28 -0
- package/dist/media/utils/videoHelpers.d.ts +35 -0
- package/dist/places/components/ManageAccessModal.d.ts +11 -0
- package/dist/places/components/PlaceCard.d.ts +12 -0
- package/dist/places/components/PlacesList.d.ts +12 -0
- package/dist/places/index.d.ts +8 -0
- package/dist/places/services/PlaceService.d.ts +9 -0
- package/dist/places/types.d.ts +10 -0
- package/dist/providers/CoreProviders.d.ts +66 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/qualiex/components/QualiexUserField.d.ts +125 -0
- package/dist/qualiex/hooks/useQualiexUsers.d.ts +51 -0
- package/dist/qualiex/services/qualiexApi.d.ts +21 -0
- package/dist/qualiex/utils/QualiexErrorInterceptor.d.ts +15 -0
- package/dist/qualiex/utils/userPlaceUtils.d.ts +16 -0
- package/dist/services/BaseService.d.ts +51 -0
- package/dist/services/EmailService.d.ts +110 -0
- package/dist/services/ErrorService.d.ts +19 -0
- package/dist/services/QualiexEnrichmentService.d.ts +65 -0
- package/dist/services/QualiexFieldHelpers.d.ts +17 -0
- package/dist/services/TranslationService.d.ts +20 -0
- package/dist/setup.d.ts +14 -0
- package/dist/sign/components/D4SignWidget.d.ts +2 -0
- package/dist/sign/components/DocumentSigner.d.ts +2 -0
- package/dist/sign/components/SignConfigForm.d.ts +2 -0
- package/dist/sign/components/SignWidget.d.ts +21 -0
- package/dist/sign/hooks/useSignConfig.d.ts +6 -0
- package/dist/sign/index.d.ts +7 -0
- package/dist/sign/services/signService.d.ts +23 -0
- package/dist/sign/types.d.ts +53 -0
- package/dist/supabase/SupabaseSingleton.d.ts +3 -0
- package/dist/supabase/client.d.ts +2 -0
- package/dist/supabase/publicClient.d.ts +2 -0
- package/dist/supabase/types.d.ts +377 -0
- package/dist/types/sidebar.d.ts +49 -0
- package/dist/types.d.ts +499 -0
- package/dist/utils/formatters/currencyFormatters.d.ts +1 -0
- package/dist/utils/formatters/dateFormatters.d.ts +52 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/linkHelpers.d.ts +4 -0
- package/package.json +1 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { QualiexUser } from '../../types';
|
|
2
|
+
interface UseQualiexUsersOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Controla se a query executa.
|
|
5
|
+
*
|
|
6
|
+
* **Padrão: `true`** - A query executa automaticamente!
|
|
7
|
+
*
|
|
8
|
+
* - `true`: Busca imediata e automática (padrão)
|
|
9
|
+
* - `false`: Não busca (use com `refetch()` para lazy loading)
|
|
10
|
+
* - Condicional: `enabled: isModalOpen` (busca só quando aberto)
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // ✅ Uso padrão (busca automática)
|
|
14
|
+
* useQualiexUsers()
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // ✅ Modal condicional
|
|
18
|
+
* useQualiexUsers({ enabled: isModalOpen })
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // ✅ Lazy loading
|
|
22
|
+
* const { refetch } = useQualiexUsers({ enabled: false });
|
|
23
|
+
* await refetch(); // Chama quando necessário
|
|
24
|
+
*/
|
|
25
|
+
enabled?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Hook para buscar usuários da API Qualiex.
|
|
29
|
+
*
|
|
30
|
+
* Por padrão, a query executa automaticamente quando o hook é montado.
|
|
31
|
+
*
|
|
32
|
+
* @param options - Opções de configuração
|
|
33
|
+
* @param options.enabled - Controla se a query executa (padrão: `true`)
|
|
34
|
+
*
|
|
35
|
+
* @returns Objeto com dados, loading, error e refetch
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* // ✅ Uso padrão - Busca automática
|
|
39
|
+
* const { data: users, isLoading } = useQualiexUsers();
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // ✅ Busca condicional (modal)
|
|
43
|
+
* const { data: users } = useQualiexUsers({ enabled: isModalOpen });
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // ✅ Lazy loading com controle manual
|
|
47
|
+
* const { data: users, refetch } = useQualiexUsers({ enabled: false });
|
|
48
|
+
* await refetch(); // Chamar quando necessário
|
|
49
|
+
*/
|
|
50
|
+
export declare const useQualiexUsers: (options?: UseQualiexUsersOptions) => import("@tanstack/react-query").UseQueryResult<QualiexUser[], Error>;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { QualiexUser } from '../../types';
|
|
2
|
+
declare class QualiexApiService {
|
|
3
|
+
private baseUrl;
|
|
4
|
+
/**
|
|
5
|
+
* Faz uma chamada para a API do Qualiex
|
|
6
|
+
* IMPORTANTE: O header 'un-alias' é OBRIGATÓRIO para todas as requisições da API common-v4
|
|
7
|
+
* Sem este header, a API retorna erro 401 "ID not found"
|
|
8
|
+
*/
|
|
9
|
+
private makeApiCall;
|
|
10
|
+
private mapToQualiexUser;
|
|
11
|
+
fetchUsers(alias: string, companyId: string): Promise<QualiexUser[]>;
|
|
12
|
+
fetchUserById(userId: string, alias: string, companyId: string): Promise<QualiexUser | null>;
|
|
13
|
+
fetchActiveUsersMap(alias: string, companyId: string): Promise<Map<string, QualiexUser>>;
|
|
14
|
+
getUsers(alias: string): Promise<QualiexUser[]>;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use getUsers() instead. Este método agora retorna apenas usuários ativos.
|
|
17
|
+
*/
|
|
18
|
+
getAllUsers(alias: string): Promise<QualiexUser[]>;
|
|
19
|
+
}
|
|
20
|
+
export declare const qualiexApi: QualiexApiService;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class QualiexErrorInterceptor {
|
|
2
|
+
private static isRetrying;
|
|
3
|
+
/**
|
|
4
|
+
* Intercepta erros da API Qualiex e tenta resolver automaticamente
|
|
5
|
+
* @returns true se o erro foi resolvido e a operação pode ser retentada
|
|
6
|
+
*/
|
|
7
|
+
static handleApiError(error: any): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Valida se o token OAuth está válido antes de fazer chamadas
|
|
10
|
+
*/
|
|
11
|
+
static validateToken(): {
|
|
12
|
+
valid: boolean;
|
|
13
|
+
message?: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { QualiexUser } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Extrai placeId de um QualiexUser
|
|
4
|
+
*/
|
|
5
|
+
export declare const getUserPlaceId: (user: QualiexUser | null | undefined) => string | null;
|
|
6
|
+
/**
|
|
7
|
+
* Extrai placeName de um QualiexUser
|
|
8
|
+
*/
|
|
9
|
+
export declare const getUserPlaceName: (user: QualiexUser | null | undefined) => string | null;
|
|
10
|
+
/**
|
|
11
|
+
* Extrai placeId e placeName de um QualiexUser
|
|
12
|
+
*/
|
|
13
|
+
export declare const getUserPlaceData: (user: QualiexUser | null | undefined) => {
|
|
14
|
+
placeId: string | null;
|
|
15
|
+
placeName: string | null;
|
|
16
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { PaginatedResponse, QueryParams } from '../types';
|
|
2
|
+
import { QualiexUserFieldMapping } from '../types';
|
|
3
|
+
export interface ServiceOptions {
|
|
4
|
+
tableName: string;
|
|
5
|
+
searchFields?: string[];
|
|
6
|
+
selectFields?: string;
|
|
7
|
+
schemaName?: string;
|
|
8
|
+
entityName?: string;
|
|
9
|
+
enableQualiexEnrichment?: boolean;
|
|
10
|
+
userIdFields?: string[];
|
|
11
|
+
userFieldsMapping?: QualiexUserFieldMapping[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Factory para criar serviço CRUD com Supabase
|
|
15
|
+
*
|
|
16
|
+
* Implementa soft delete automático e integração com RLS.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const service = createService<Employee>({
|
|
21
|
+
* tableName: 'employees',
|
|
22
|
+
* searchFields: ['name', 'email'],
|
|
23
|
+
* enableQualiexEnrichment: true
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* Ver README para documentação completa
|
|
28
|
+
*
|
|
29
|
+
* @see createSimpleService - Método recomendado (mais simples)
|
|
30
|
+
*/
|
|
31
|
+
export declare function createService<T extends {
|
|
32
|
+
id_user?: string | null;
|
|
33
|
+
} = any, TInsert = any, TUpdate = any>(options: ServiceOptions | string, // Mantém compatibilidade com API antiga
|
|
34
|
+
searchFields?: string[], schemaName?: string): {
|
|
35
|
+
getAll(params?: QueryParams): Promise<PaginatedResponse<T & {
|
|
36
|
+
responsible_name?: string;
|
|
37
|
+
}>>;
|
|
38
|
+
getById(id: string): Promise<T | null>;
|
|
39
|
+
create(payload: TInsert): Promise<T>;
|
|
40
|
+
update(id: string, payload: TUpdate): Promise<T>;
|
|
41
|
+
/**
|
|
42
|
+
* Delete a record by ID using SOFT DELETE
|
|
43
|
+
*
|
|
44
|
+
* IMPORTANT: This performs a SOFT DELETE by setting is_removed = true
|
|
45
|
+
* - No physical DELETE is performed
|
|
46
|
+
* - Record remains in database but filtered from queries
|
|
47
|
+
* - RLS policies should NOT include DELETE policies
|
|
48
|
+
* - Compatible with audit trails and data recovery
|
|
49
|
+
*/
|
|
50
|
+
delete(id: string): Promise<void>;
|
|
51
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
export interface SendEmailParams {
|
|
2
|
+
/**
|
|
3
|
+
* Código do template cadastrado no banco de dados (common.email_templates)
|
|
4
|
+
* Exemplo: 'WELCOME', 'PASSWORD_RESET', 'NOTIFICATION'
|
|
5
|
+
*/
|
|
6
|
+
templateCode: string;
|
|
7
|
+
/**
|
|
8
|
+
* Email(s) do(s) destinatário(s)
|
|
9
|
+
*/
|
|
10
|
+
to: string | string[];
|
|
11
|
+
/**
|
|
12
|
+
* Variáveis para substituição no template
|
|
13
|
+
* As chaves devem corresponder aos placeholders no template: {{variableName}}
|
|
14
|
+
* Exemplo: { userName: 'João', activationLink: 'https://...' }
|
|
15
|
+
*/
|
|
16
|
+
variables: Record<string, any>;
|
|
17
|
+
/**
|
|
18
|
+
* Emails em cópia (opcional)
|
|
19
|
+
*/
|
|
20
|
+
cc?: string[];
|
|
21
|
+
/**
|
|
22
|
+
* Emails em cópia oculta (opcional)
|
|
23
|
+
*/
|
|
24
|
+
bcc?: string[];
|
|
25
|
+
/**
|
|
26
|
+
* Email para resposta (opcional)
|
|
27
|
+
*/
|
|
28
|
+
replyTo?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Serviço para envio de emails usando templates do banco de dados
|
|
32
|
+
*
|
|
33
|
+
* O serviço busca automaticamente o template cadastrado na tabela common.email_templates
|
|
34
|
+
* pelo alias da empresa e pelo template_code fornecido, e substitui as variáveis
|
|
35
|
+
* pelos valores fornecidos.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* import { emailService } from 'forlogic-core';
|
|
40
|
+
*
|
|
41
|
+
* // Enviar email de boas-vindas
|
|
42
|
+
* await emailService.sendEmail({
|
|
43
|
+
* templateCode: 'WELCOME',
|
|
44
|
+
* to: 'usuario@exemplo.com',
|
|
45
|
+
* variables: {
|
|
46
|
+
* userName: 'João Silva',
|
|
47
|
+
* activationLink: 'https://app.com/activate',
|
|
48
|
+
* companyName: 'Minha Empresa'
|
|
49
|
+
* }
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* // Enviar notificação genérica
|
|
53
|
+
* await emailService.sendEmail({
|
|
54
|
+
* templateCode: 'NOTIFICATION',
|
|
55
|
+
* to: ['usuario1@exemplo.com', 'usuario2@exemplo.com'],
|
|
56
|
+
* variables: {
|
|
57
|
+
* title: 'Novo documento disponível',
|
|
58
|
+
* message: 'Um novo documento foi compartilhado com você',
|
|
59
|
+
* actionUrl: 'https://app.com/documents/123',
|
|
60
|
+
* actionLabel: 'Ver Documento'
|
|
61
|
+
* },
|
|
62
|
+
* cc: ['gestor@exemplo.com']
|
|
63
|
+
* });
|
|
64
|
+
*
|
|
65
|
+
* // Template personalizado
|
|
66
|
+
* await emailService.sendEmail({
|
|
67
|
+
* templateCode: 'CUSTOM_REPORT',
|
|
68
|
+
* to: 'gerente@exemplo.com',
|
|
69
|
+
* variables: {
|
|
70
|
+
* reportTitle: 'Relatório Mensal',
|
|
71
|
+
* period: 'Janeiro/2024',
|
|
72
|
+
* totalSales: 'R$ 50.000,00',
|
|
73
|
+
* downloadLink: 'https://app.com/reports/jan-2024.pdf'
|
|
74
|
+
* }
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare class EmailService {
|
|
79
|
+
/**
|
|
80
|
+
* Envia email usando template do banco de dados
|
|
81
|
+
*
|
|
82
|
+
* A edge function irá:
|
|
83
|
+
* 1. Buscar o template na tabela common.email_templates usando o alias da empresa
|
|
84
|
+
* 2. Substituir as variáveis {{variableName}} pelos valores fornecidos
|
|
85
|
+
* 3. Enviar o email via SMTP
|
|
86
|
+
* 4. Registrar o log em common.email_logs
|
|
87
|
+
*
|
|
88
|
+
* @param params - Parâmetros do email
|
|
89
|
+
* @throws Error se o template não for encontrado ou se houver erro no envio
|
|
90
|
+
* @returns Dados da resposta da edge function (message_id, etc)
|
|
91
|
+
*/
|
|
92
|
+
static sendEmail(params: SendEmailParams): Promise<any>;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Instância singleton do serviço de email
|
|
96
|
+
*
|
|
97
|
+
* Use este export para enviar emails através de templates cadastrados no banco.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* import { emailService } from 'forlogic-core';
|
|
102
|
+
*
|
|
103
|
+
* await emailService.sendEmail({
|
|
104
|
+
* templateCode: 'WELCOME',
|
|
105
|
+
* to: 'usuario@exemplo.com',
|
|
106
|
+
* variables: { userName: 'João' }
|
|
107
|
+
* });
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export declare const emailService: typeof EmailService;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface ErrorEntry {
|
|
2
|
+
id: string;
|
|
3
|
+
message: string;
|
|
4
|
+
timestamp: number;
|
|
5
|
+
count: number;
|
|
6
|
+
}
|
|
7
|
+
declare class ErrorService {
|
|
8
|
+
private errors;
|
|
9
|
+
private toastCount;
|
|
10
|
+
private lastToastTime;
|
|
11
|
+
handleError(error: Error | string, showToast?: boolean): void;
|
|
12
|
+
private getErrorTitle;
|
|
13
|
+
success(title: string, description?: string): void;
|
|
14
|
+
private shouldShowToast;
|
|
15
|
+
getErrors(): ErrorEntry[];
|
|
16
|
+
clearErrors(): void;
|
|
17
|
+
}
|
|
18
|
+
export declare const errorService: ErrorService;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { QualiexUserFieldMapping } from '../types';
|
|
2
|
+
export interface QualiexEnrichmentOptions {
|
|
3
|
+
entityName: string;
|
|
4
|
+
userIdFields?: string[];
|
|
5
|
+
userFieldsMapping?: QualiexUserFieldMapping[];
|
|
6
|
+
}
|
|
7
|
+
export declare class QualiexEnrichmentService {
|
|
8
|
+
/**
|
|
9
|
+
* Busca usuários Qualiex com cache inteligente
|
|
10
|
+
*/
|
|
11
|
+
private static fetchQualiexUsers;
|
|
12
|
+
/**
|
|
13
|
+
* Extrai todos os IDs únicos das entidades baseado nos mapeamentos
|
|
14
|
+
*/
|
|
15
|
+
private static extractUserIds;
|
|
16
|
+
/**
|
|
17
|
+
* Cria índice duplo de usuários (por id e userId)
|
|
18
|
+
*/
|
|
19
|
+
private static indexUsers;
|
|
20
|
+
/**
|
|
21
|
+
* Aplica enrichment em uma única entidade
|
|
22
|
+
*/
|
|
23
|
+
private static enrichEntity;
|
|
24
|
+
/**
|
|
25
|
+
* Enriquece entidades com múltiplos campos de usuário do Qualiex
|
|
26
|
+
*
|
|
27
|
+
* Suporta:
|
|
28
|
+
* - Múltiplos campos de ID arbitrários (userIdFields ou userFieldsMapping)
|
|
29
|
+
* - Campos de saída customizados (name, email, username)
|
|
30
|
+
* - Cache inteligente (5min TTL)
|
|
31
|
+
* - Resiliência: não quebra em caso de falha
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* // Uso simples (lista de campos)
|
|
36
|
+
* enrichWithUserData(evaluations, {
|
|
37
|
+
* entityName: 'Avaliações',
|
|
38
|
+
* userIdFields: ['target_user_id', 'evaluator_user_id']
|
|
39
|
+
* });
|
|
40
|
+
* // Resultado: target_user_name, evaluator_user_name preenchidos
|
|
41
|
+
*
|
|
42
|
+
* // Uso avançado (mapeamento customizado)
|
|
43
|
+
* enrichWithUserData(evaluations, {
|
|
44
|
+
* entityName: 'Avaliações',
|
|
45
|
+
* userFieldsMapping: [
|
|
46
|
+
* { idField: 'target_user_id', nameField: 'avaliado_nome' },
|
|
47
|
+
* { idField: 'evaluator_user_id', nameField: 'avaliador_nome', emailField: 'avaliador_email' }
|
|
48
|
+
* ]
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
static enrichWithUserData<T>(entities: T[], options: QualiexEnrichmentOptions): Promise<T[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Método legado (retrocompatibilidade)
|
|
55
|
+
*
|
|
56
|
+
* @deprecated Use enrichWithUserData() para maior flexibilidade
|
|
57
|
+
*/
|
|
58
|
+
static enrichWithResponsibleNames<T extends {
|
|
59
|
+
id_user?: string | null;
|
|
60
|
+
}>(entities: T[], options: {
|
|
61
|
+
entityName: string;
|
|
62
|
+
}): Promise<(T & {
|
|
63
|
+
responsible_name?: string;
|
|
64
|
+
})[]>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { QualiexUserFieldMapping } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Deriva o nome do campo de saída baseado no campo de ID e sufixo
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* deriveNameField("target_user_id", "_name") => "target_user_name"
|
|
7
|
+
* deriveNameField("id_user", "_name") => "id_user_name"
|
|
8
|
+
*/
|
|
9
|
+
export declare function deriveNameField(idField: string, suffix?: string): string;
|
|
10
|
+
export declare function deriveEmailField(idField: string, suffix?: string): string;
|
|
11
|
+
export declare function deriveUsernameField(idField: string, suffix?: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Converte lista de campos de ID + mapeamentos explícitos em lista unificada
|
|
14
|
+
*
|
|
15
|
+
* Prioridade: userFieldsMapping > userIdFields
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveFieldMappings(userIdFields?: string[], userFieldsMapping?: QualiexUserFieldMapping[]): QualiexUserFieldMapping[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare class TranslationService {
|
|
2
|
+
private cache;
|
|
3
|
+
private cacheTimestamps;
|
|
4
|
+
private readonly CACHE_TTL;
|
|
5
|
+
private loadingPromises;
|
|
6
|
+
private isCacheValid;
|
|
7
|
+
loadTranslations(locale: string): Promise<Record<string, string>>;
|
|
8
|
+
private fetchTranslations;
|
|
9
|
+
upsertTranslation(key: string, pt: string, en?: string, es?: string): Promise<void>;
|
|
10
|
+
bulkUpsertTranslations(translations: Array<{
|
|
11
|
+
key: string;
|
|
12
|
+
pt: string;
|
|
13
|
+
en?: string;
|
|
14
|
+
es?: string;
|
|
15
|
+
}>): Promise<void>;
|
|
16
|
+
clearCache(): void;
|
|
17
|
+
clearCacheForLocale(locale: string): void;
|
|
18
|
+
}
|
|
19
|
+
export declare const translationService: TranslationService;
|
|
20
|
+
export {};
|
package/dist/setup.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
2
|
+
interface QualiexCoreConfig {
|
|
3
|
+
supabase: {
|
|
4
|
+
url: string;
|
|
5
|
+
anonKey: string;
|
|
6
|
+
};
|
|
7
|
+
theme?: 'light' | 'dark' | 'system';
|
|
8
|
+
queryClient?: QueryClient;
|
|
9
|
+
}
|
|
10
|
+
export declare function setupQualiexCore(config: QualiexCoreConfig): {
|
|
11
|
+
queryClient: QueryClient;
|
|
12
|
+
config: QualiexCoreConfig;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
Clicksign: new (signerId: string) => ClicksignInstance;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
interface ClicksignInstance {
|
|
7
|
+
endpoint: string;
|
|
8
|
+
origin: string;
|
|
9
|
+
on: (event: string, callback: (data: unknown) => void) => void;
|
|
10
|
+
mount: (containerId: string) => void;
|
|
11
|
+
unmount: () => void;
|
|
12
|
+
}
|
|
13
|
+
interface SignWidgetProps {
|
|
14
|
+
signerId: string;
|
|
15
|
+
environment?: 'sandbox' | 'production';
|
|
16
|
+
onSign?: () => void;
|
|
17
|
+
onError?: (error: unknown) => void;
|
|
18
|
+
onClose?: () => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function SignWidget({ signerId, environment, onSign, onError, onClose }: SignWidgetProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { DocumentSigner } from './components/DocumentSigner';
|
|
2
|
+
export { SignWidget } from './components/SignWidget';
|
|
3
|
+
export { D4SignWidget } from './components/D4SignWidget';
|
|
4
|
+
export { SignConfigForm } from './components/SignConfigForm';
|
|
5
|
+
export { useSignConfig } from './hooks/useSignConfig';
|
|
6
|
+
export { signService } from './services/signService';
|
|
7
|
+
export type { SignProvider, SignConfig, SignEnvelopeResult, SignedDocumentResult, DocumentSignerProps, SignWidgetProps, D4SignWidgetProps, SignConfigFormProps, } from './types';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SignEnvelopeResult, SignedDocumentResult, SignProvider } from '../types';
|
|
2
|
+
export declare const signService: {
|
|
3
|
+
/**
|
|
4
|
+
* Resolve qual provedor está configurado para o alias.
|
|
5
|
+
* Tenta clicksign primeiro (backward compat), depois d4sign.
|
|
6
|
+
* Retorna o provedor resolvido.
|
|
7
|
+
*/
|
|
8
|
+
resolveProvider(alias: string): Promise<SignProvider>;
|
|
9
|
+
createEnvelopeWithSigner(params: {
|
|
10
|
+
alias: string;
|
|
11
|
+
contentBase64: string;
|
|
12
|
+
filename: string;
|
|
13
|
+
signerEmail: string;
|
|
14
|
+
signerName: string;
|
|
15
|
+
provider?: SignProvider;
|
|
16
|
+
}): Promise<SignEnvelopeResult>;
|
|
17
|
+
getSignedDocument(params: {
|
|
18
|
+
alias: string;
|
|
19
|
+
envelopeId: string;
|
|
20
|
+
documentId: string;
|
|
21
|
+
provider?: SignProvider;
|
|
22
|
+
}): Promise<SignedDocumentResult>;
|
|
23
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type SignProvider = 'clicksign' | 'd4sign';
|
|
2
|
+
export interface SignConfig {
|
|
3
|
+
id: string;
|
|
4
|
+
alias: string;
|
|
5
|
+
provider: SignProvider;
|
|
6
|
+
api_key: string;
|
|
7
|
+
crypt_key: string | null;
|
|
8
|
+
uuid_safe: string | null;
|
|
9
|
+
environment: 'sandbox' | 'production';
|
|
10
|
+
monthly_limit: number | null;
|
|
11
|
+
created_at: string;
|
|
12
|
+
updated_at: string;
|
|
13
|
+
deleted_at: string | null;
|
|
14
|
+
}
|
|
15
|
+
export interface SignEnvelopeResult {
|
|
16
|
+
success: boolean;
|
|
17
|
+
provider: SignProvider;
|
|
18
|
+
envelope_id: string;
|
|
19
|
+
document_id: string;
|
|
20
|
+
signer_id: string;
|
|
21
|
+
signer_email?: string;
|
|
22
|
+
environment: 'sandbox' | 'production';
|
|
23
|
+
}
|
|
24
|
+
export interface SignedDocumentResult {
|
|
25
|
+
success: boolean;
|
|
26
|
+
download_url: string | null;
|
|
27
|
+
document: Record<string, unknown> | null;
|
|
28
|
+
}
|
|
29
|
+
export interface DocumentSignerProps {
|
|
30
|
+
file?: File;
|
|
31
|
+
onDocumentSigned?: (data: SignEnvelopeResult) => void;
|
|
32
|
+
onError?: (error: Error) => void;
|
|
33
|
+
showEventLog?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface SignWidgetProps {
|
|
36
|
+
signerId: string;
|
|
37
|
+
environment: 'sandbox' | 'production';
|
|
38
|
+
onSign?: () => void;
|
|
39
|
+
onError?: (error: Error) => void;
|
|
40
|
+
onClose?: () => void;
|
|
41
|
+
}
|
|
42
|
+
export interface D4SignWidgetProps {
|
|
43
|
+
documentKey: string;
|
|
44
|
+
signerEmail: string;
|
|
45
|
+
signerName?: string;
|
|
46
|
+
keySigner?: string;
|
|
47
|
+
environment: 'sandbox' | 'production';
|
|
48
|
+
onSign?: () => void;
|
|
49
|
+
onError?: (error: Error) => void;
|
|
50
|
+
}
|
|
51
|
+
export interface SignConfigFormProps {
|
|
52
|
+
onSaved?: () => void;
|
|
53
|
+
}
|