Compare commits

...

2 Commits

Author SHA1 Message Date
Lucas Santana
be340d132e fix: Corrigindo separação silábica
Some checks are pending
Docker Build and Push / build (push) Waiting to run
2025-02-05 16:59:12 -03:00
Lucas Santana
75c1e6f9f2 fix: adicionando mais contexto na geração das histórias 2025-02-05 12:08:05 -03:00
8 changed files with 1166 additions and 1122 deletions

View File

@ -9,6 +9,7 @@ interface AdaptiveTextProps extends React.HTMLAttributes<HTMLSpanElement> {
as?: keyof JSX.IntrinsicElements;
preserveWhitespace?: boolean;
highlightSyllables?: boolean;
formattedText?: string;
}
export const AdaptiveText = React.memo(({
@ -17,11 +18,14 @@ export const AdaptiveText = React.memo(({
as: Component = 'span',
preserveWhitespace = false,
highlightSyllables = false,
formattedText,
className,
...props
}: AdaptiveTextProps) => {
const formattedText = formatTextWithSyllables(text, highlightSyllables);
const finalText = isUpperCase ? formattedText.toUpperCase() : formattedText;
// Se tiver texto formatado (com sílabas), usa ele
// Senão, formata o texto normal
const finalText = formattedText || formatTextWithSyllables(text, highlightSyllables);
const displayText = isUpperCase ? finalText.toUpperCase() : finalText;
return React.createElement(
Component,
@ -32,7 +36,7 @@ export const AdaptiveText = React.memo(({
),
...props
},
finalText
displayText
);
});

View File

@ -1,10 +1,40 @@
import { useState } from 'react';
import { formatTextWithSyllables } from '../utils/syllableSplitter';
export function useSyllables() {
interface UseSyllablesProps {
text: string;
textSyllables?: string | null;
}
export function useSyllables({ text, textSyllables }: UseSyllablesProps) {
const [isHighlighted, setIsHighlighted] = useState(false);
// Se não estiver destacado, mostra o texto normal
if (!isHighlighted) {
return {
isHighlighted,
toggleHighlight: () => setIsHighlighted(!isHighlighted),
displayText: text,
isUsingDatabaseText: false
};
}
// Se estiver destacado e tiver texto com sílabas do banco, usa ele
if (textSyllables) {
return {
isHighlighted,
toggleHighlight: () => setIsHighlighted(!isHighlighted),
displayText: textSyllables,
isUsingDatabaseText: true
};
}
// Se estiver destacado mas não tiver texto com sílabas do banco,
// gera usando o syllableSplitter
return {
isHighlighted,
toggleHighlight: () => setIsHighlighted(!isHighlighted)
toggleHighlight: () => setIsHighlighted(!isHighlighted),
displayText: formatTextWithSyllables(text, true),
isUsingDatabaseText: false
};
}

View File

@ -1,5 +1,5 @@
import React, { useState, useEffect } from 'react';
import { ArrowLeft, ArrowRight, Share2, ChevronDown, ChevronUp, Loader2, Download, RefreshCw, Trash2, Type, Eye, EyeOff } from 'lucide-react';
import { ArrowLeft, ArrowRight, ChevronDown, ChevronUp, Loader2, Download, RefreshCw, Trash2, Eye, EyeOff } from 'lucide-react';
import { useParams, useNavigate } from 'react-router-dom';
import { supabase } from '../../lib/supabase';
import { AudioRecorder } from '../../components/story/AudioRecorder';
@ -8,7 +8,6 @@ import { StoryMetrics } from '../../components/story/StoryMetrics';
import { convertWebmToMp3 } from '../../utils/audioConverter';
import * as Dialog from '@radix-ui/react-dialog';
import { ExerciseSuggestions } from '../../components/learning/ExerciseSuggestions';
import { TextCaseToggle } from '../../components/ui/text-case-toggle';
import { AdaptiveText } from '../../components/ui/adaptive-text';
import { useSession } from '../../hooks/useSession';
import { useSyllables } from '../../features/syllables/hooks/useSyllables';
@ -56,7 +55,10 @@ function RecordingHistoryCard({ recording }: { recording: StoryRecording }) {
const [conversionError, setConversionError] = React.useState<string | null>(null);
const { session } = useSession();
const { isUpperCase } = useUppercasePreference(session?.user?.id);
const { isHighlighted } = useSyllables();
const { isHighlighted, displayText } = useSyllables({
text: recording.transcription || '',
textSyllables: null
});
// Verificar suporte ao formato WebM
React.useEffect(() => {
@ -293,6 +295,7 @@ function RecordingHistoryCard({ recording }: { recording: StoryRecording }) {
isUpperCase={isUpperCase}
className="text-sm text-gray-600 whitespace-pre-wrap"
highlightSyllables={isHighlighted}
formattedText={displayText}
/>
</div>
</div>
@ -393,7 +396,10 @@ export function StoryPage() {
const [isDeleting, setIsDeleting] = useState(false);
const { session } = useSession();
const { isUpperCase, toggleUppercase, isLoading } = useUppercasePreference(session?.user?.id);
const { isHighlighted: isSyllablesEnabled, toggleHighlight: toggleSyllables } = useSyllables();
const { isHighlighted: isSyllablesEnabled, toggleHighlight: toggleSyllables, displayText } = useSyllables({
text: story?.content?.pages?.[currentPage]?.text || '',
textSyllables: story?.content?.pages?.[currentPage]?.text_syllables || null
});
const [fontSize, setFontSize] = useState(24);
const [readingSpeed, setReadingSpeed] = useState(60); // 60 palavras por minuto
const [letterSpacing, setLetterSpacing] = useState(0);
@ -450,14 +456,15 @@ export function StoryPage() {
if (!text || currentWordIndex === -1) {
return (
<AdaptiveText
text={text}
text={displayText}
isUpperCase={isUpperCase}
highlightSyllables={isSyllablesEnabled}
formattedText={displayText}
/>
);
}
const words = getWords(text);
const words = getWords(displayText);
return (
<div className="leading-relaxed whitespace-pre-wrap break-words">
{words.map((word, index) => (
@ -473,6 +480,7 @@ export function StoryPage() {
text={word}
isUpperCase={isUpperCase}
highlightSyllables={isSyllablesEnabled}
formattedText={word}
/>
{' '}
</span>
@ -495,6 +503,7 @@ export function StoryPage() {
id,
page_number,
text,
text_syllables,
image_url
)
`)
@ -508,8 +517,9 @@ export function StoryPage() {
setStory({
...storyData,
content: {
pages: orderedPages.map((page: { text: string; image_url: string }) => ({
pages: orderedPages.map((page: { text: string; text_syllables: string | null; image_url: string }) => ({
text: page.text,
text_syllables: page.text_syllables,
image: page.image_url
}))
}
@ -557,20 +567,6 @@ export function StoryPage() {
fetchRecordings();
}, [story?.id]);
const handleShare = async () => {
if (navigator.share) {
try {
await navigator.share({
title: story?.title,
text: 'Confira minha história!',
url: window.location.href
});
} catch (err) {
console.error('Erro ao compartilhar:', err);
}
}
};
const getLatestRecording = () => recordings[0];
const formatMetricsData = (recording: StoryRecording) => ({
@ -802,18 +798,6 @@ export function StoryPage() {
focusModeActive={focusMode.isActive}
onFocusModeToggle={handleFocusModeToggle}
/>
{/*
<button
onClick={handleShare}
className="flex items-center gap-2 px-4 py-2 text-gray-600 hover:text-gray-900"
>
<Share2 className="h-5 w-5" />
Compartilhar
</button>
*/}
</div>
</div>

View File

@ -76,7 +76,11 @@ export interface Story extends BaseEntity {
title: string;
theme: string;
content: {
pages: StoryPage[];
pages: Array<{
text: string;
text_syllables?: string | null;
image: string;
}>;
currentPage?: number;
lastModified?: string;
};
@ -88,6 +92,11 @@ export interface Story extends BaseEntity {
students?: {
name: string;
};
theme_id?: string;
subject_id?: string;
character_id?: string;
setting_id?: string;
context?: string;
}
export interface StoryRecording extends BaseEntity {

View File

@ -1,34 +1,105 @@
| table_schema | table_name | column_name | constraint_type |
| ------------------- | ------------------------------- | --------------------- | --------------- |
| public | story_exercise_words | id | PRIMARY KEY |
| public | story_exercise_words | story_id | FOREIGN KEY |
| public | story_exercise_words | story_id | UNIQUE |
| public | story_exercise_words | word | UNIQUE |
| public | story_exercise_words | exercise_type | UNIQUE |
| public | story_exercise_words | | CHECK |
| public | story_pages | story_id | FOREIGN KEY |
| public | story_pages | story_id | FOREIGN KEY |
| public | story_pages | id | PRIMARY KEY |
| public | story_generations | id | PRIMARY KEY |
| public | story_generations | story_id | FOREIGN KEY |
| auth | users | id | PRIMARY KEY |
| public | schools | id | PRIMARY KEY |
| public | teachers | email | UNIQUE |
| auth | refresh_tokens | id | PRIMARY KEY |
| auth | instances | id | PRIMARY KEY |
| auth | audit_log_entries | id | PRIMARY KEY |
| auth | schema_migrations | version | PRIMARY KEY |
| storage | buckets | id | PRIMARY KEY |
| public | teachers | id | PRIMARY KEY |
| storage | objects | id | PRIMARY KEY |
| storage | objects | bucket_id | FOREIGN KEY |
| public | teachers | email | UNIQUE |
| storage | migrations | id | PRIMARY KEY |
| storage | migrations | name | UNIQUE |
| pgsodium | key | id | PRIMARY KEY |
| pgsodium | key | parent_key | FOREIGN KEY |
| pgsodium | key | name | UNIQUE |
| public | teachers | school_id | FOREIGN KEY |
| public | teachers | | CHECK |
| public | classes | id | PRIMARY KEY |
| public | classes | school_id | FOREIGN KEY |
| public | classes | teacher_id | FOREIGN KEY |
| public | teacher_classes | class_id | FOREIGN KEY |
| vault | secrets | id | PRIMARY KEY |
| vault | secrets | key_id | FOREIGN KEY |
| public | students | id | PRIMARY KEY |
| public | students | email | UNIQUE |
| public | students | class_id | FOREIGN KEY |
| public | teacher_classes | id | PRIMARY KEY |
| public | teacher_classes | teacher_id | UNIQUE |
| public | teacher_classes | class_id | UNIQUE |
| public | teacher_classes | teacher_id | FOREIGN KEY |
| public | students | class_id | FOREIGN KEY |
| public | students | email | UNIQUE |
| public | students | id | PRIMARY KEY |
| public | teacher_classes | class_id | FOREIGN KEY |
| public | student_achievements_old | id | PRIMARY KEY |
| public | student_achievements_old | student_id | FOREIGN KEY |
| public | student_achievements_old | achievement_id | FOREIGN KEY |
| public | phonics_exercise_types | id | PRIMARY KEY |
| public | phonics_exercises | id | PRIMARY KEY |
| public | phonics_exercises | type_id | FOREIGN KEY |
| public | story_exercise_words | id | PRIMARY KEY |
| public | story_exercise_words | story_id | UNIQUE |
| public | story_exercise_words | word | UNIQUE |
| public | story_exercise_words | exercise_type | UNIQUE |
| public | story_exercise_words | story_id | FOREIGN KEY |
| public | phonics_words | id | PRIMARY KEY |
| public | phonics_exercise_words | id | PRIMARY KEY |
| public | phonics_exercise_words | exercise_id | UNIQUE |
| public | phonics_exercise_words | word_id | UNIQUE |
| public | phonics_exercise_words | exercise_id | FOREIGN KEY |
| public | phonics_exercise_words | word_id | FOREIGN KEY |
| public | stories | id | PRIMARY KEY |
| public | stories | student_id | FOREIGN KEY |
| public | student_achievements | id | PRIMARY KEY |
| public | student_achievements | student_id | FOREIGN KEY |
| public | student_achievements | achievement_id | FOREIGN KEY |
| public | media_types | id | PRIMARY KEY |
| public | phonics_exercise_media | id | PRIMARY KEY |
| public | phonics_exercise_media | exercise_id | FOREIGN KEY |
| public | phonics_exercise_media | media_type_id | FOREIGN KEY |
| public | student_phonics_progress | id | PRIMARY KEY |
| public | student_phonics_progress | student_id | UNIQUE |
| public | student_phonics_progress | exercise_id | UNIQUE |
| public | student_phonics_progress | student_id | FOREIGN KEY |
| public | student_phonics_progress | exercise_id | FOREIGN KEY |
| public | student_phonics_attempts | id | PRIMARY KEY |
| public | student_phonics_attempts | student_id | FOREIGN KEY |
| public | student_phonics_attempts | exercise_id | FOREIGN KEY |
| public | student_phonics_attempt_answers | id | PRIMARY KEY |
| public | student_phonics_attempt_answers | attempt_id | FOREIGN KEY |
| public | student_phonics_attempt_answers | word_id | FOREIGN KEY |
| public | achievement_types | id | PRIMARY KEY |
| public | phonics_achievements | id | PRIMARY KEY |
| public | phonics_achievements | type_id | FOREIGN KEY |
| public | student_phonics_achievements | id | PRIMARY KEY |
| public | student_phonics_achievements | student_id | UNIQUE |
| public | student_phonics_achievements | achievement_id | UNIQUE |
| public | student_phonics_achievements | student_id | FOREIGN KEY |
| public | student_phonics_achievements | achievement_id | FOREIGN KEY |
| public | teacher_invites | id | PRIMARY KEY |
| public | teacher_invites | token | UNIQUE |
| public | teacher_invites | school_id | FOREIGN KEY |
| public | classes | teacher_id | FOREIGN KEY |
| public | story_pages | id | PRIMARY KEY |
| public | languages | id | PRIMARY KEY |
| public | story_generations | id | PRIMARY KEY |
| public | story_generations | story_id | FOREIGN KEY |
| public | interests | id | PRIMARY KEY |
| public | interests | student_id | UNIQUE |
| public | interests | category | UNIQUE |
| public | interests | item | UNIQUE |
| public | interests | student_id | FOREIGN KEY |
| public | languages | code | UNIQUE |
| supabase_migrations | schema_migrations | version | PRIMARY KEY |
| supabase_migrations | seed_files | path | PRIMARY KEY |
| public | phonics_categories | id | PRIMARY KEY |
| public | students | school_id | FOREIGN KEY |
| public | students | | CHECK |
| public | story_pages | story_id | FOREIGN KEY |
| public | story_recordings | story_id | FOREIGN KEY |
| public | story_pages | story_id | FOREIGN KEY |
| public | story_recordings | story_id | FOREIGN KEY |
| public | phonics_word_audio | id | PRIMARY KEY |
| public | phonics_word_audio | word | UNIQUE |
| public | story_recordings | id | PRIMARY KEY |
| public | story_recordings | student_id | FOREIGN KEY |
| public | story_themes | id | PRIMARY KEY |
| public | story_themes | slug | UNIQUE |
| public | story_subjects | id | PRIMARY KEY |
@ -37,381 +108,310 @@
| public | story_characters | slug | UNIQUE |
| public | story_settings | id | PRIMARY KEY |
| public | story_settings | slug | UNIQUE |
| public | stories | theme_id | FOREIGN KEY |
| public | stories | subject_id | FOREIGN KEY |
| public | stories | character_id | FOREIGN KEY |
| public | stories | setting_id | FOREIGN KEY |
| public | stories | subject_id | FOREIGN KEY |
| public | stories | theme_id | FOREIGN KEY |
| public | stories | character_id | FOREIGN KEY |
| public | stories | id | PRIMARY KEY |
| public | stories | setting_id | FOREIGN KEY |
| public | stories | | CHECK |
| public | stories | student_id | FOREIGN KEY |
| public | stories | subject_id | FOREIGN KEY |
| public | stories | theme_id | FOREIGN KEY |
| public | teacher_invites | id | PRIMARY KEY |
| public | teacher_invites | school_id | FOREIGN KEY |
| public | teacher_invites | | CHECK |
| public | teacher_invites | token | UNIQUE |
| public | phonics_exercise_types | id | PRIMARY KEY |
| public | phonics_exercises | id | PRIMARY KEY |
| public | phonics_exercises | type_id | FOREIGN KEY |
| public | phonics_words | id | PRIMARY KEY |
| public | phonics_exercise_words | exercise_id | FOREIGN KEY |
| public | phonics_exercise_words | exercise_id | UNIQUE |
| public | phonics_exercise_words | word_id | UNIQUE |
| public | phonics_exercise_words | id | PRIMARY KEY |
| public | phonics_exercise_words | word_id | FOREIGN KEY |
| public | phonics_categories | id | PRIMARY KEY |
| public | phonics_exercise_media | exercise_id | FOREIGN KEY |
| public | phonics_exercise_media | media_type_id | FOREIGN KEY |
| public | phonics_exercise_media | id | PRIMARY KEY |
| public | student_phonics_attempt_answers | attempt_id | FOREIGN KEY |
| public | student_phonics_attempt_answers | id | PRIMARY KEY |
| public | student_phonics_attempt_answers | word_id | FOREIGN KEY |
| public | media_types | id | PRIMARY KEY |
| public | student_phonics_progress | exercise_id | FOREIGN KEY |
| public | student_phonics_progress | id | PRIMARY KEY |
| public | student_phonics_progress | student_id | UNIQUE |
| public | student_phonics_progress | exercise_id | UNIQUE |
| public | student_phonics_progress | student_id | FOREIGN KEY |
| public | student_phonics_attempts | exercise_id | FOREIGN KEY |
| public | student_phonics_attempts | id | PRIMARY KEY |
| public | student_phonics_attempts | student_id | FOREIGN KEY |
| public | achievement_types | id | PRIMARY KEY |
| public | phonics_achievements | id | PRIMARY KEY |
| public | phonics_achievements | type_id | FOREIGN KEY |
| public | student_phonics_achievements | achievement_id | FOREIGN KEY |
| public | student_phonics_achievements | id | PRIMARY KEY |
| public | student_phonics_achievements | student_id | UNIQUE |
| public | student_phonics_achievements | achievement_id | UNIQUE |
| public | student_phonics_achievements | student_id | FOREIGN KEY |
| public | phonics_word_audio | id | PRIMARY KEY |
| public | phonics_word_audio | word | UNIQUE |
| public | languages | code | UNIQUE |
| public | languages | id | PRIMARY KEY |
| public | story_recordings | story_id | FOREIGN KEY |
| public | story_recordings | story_id | FOREIGN KEY |
| public | story_recordings | | CHECK |
| public | story_recordings | | CHECK |
| public | story_recordings | | CHECK |
| public | story_recordings | id | PRIMARY KEY |
| public | story_recordings | | CHECK |
| public | story_recordings | student_id | FOREIGN KEY |
| public | interests | id | PRIMARY KEY |
| public | interests | student_id | UNIQUE |
| public | interests | category | UNIQUE |
| public | interests | item | UNIQUE |
| public | interests | student_id | FOREIGN KEY |
| public | achievements | id | PRIMARY KEY |
| public | student_achievements_old | achievement_id | FOREIGN KEY |
| public | student_achievements_old | id | PRIMARY KEY |
| public | student_achievements_old | student_id | FOREIGN KEY |
| public | student_achievements | achievement_id | FOREIGN KEY |
| public | student_achievements | id | PRIMARY KEY |
| public | student_achievements | student_id | FOREIGN KEY |
| storage | buckets | id | PRIMARY KEY |
| storage | migrations | name | UNIQUE |
| storage | migrations | id | PRIMARY KEY |
| storage | objects | bucket_id | FOREIGN KEY |
| storage | objects | id | PRIMARY KEY |
| storage | s3_multipart_uploads | bucket_id | FOREIGN KEY |
| storage | s3_multipart_uploads | id | PRIMARY KEY |
| storage | s3_multipart_uploads_parts | bucket_id | FOREIGN KEY |
| storage | s3_multipart_uploads_parts | id | PRIMARY KEY |
| storage | s3_multipart_uploads_parts | upload_id | FOREIGN KEY |
| auth | refresh_tokens | id | PRIMARY KEY |
| auth | refresh_tokens | session_id | FOREIGN KEY |
| auth | identities | user_id | FOREIGN KEY |
| auth | refresh_tokens | token | UNIQUE |
| auth | instances | id | PRIMARY KEY |
| auth | schema_migrations | version | PRIMARY KEY |
| auth | users | | CHECK |
| auth | users | phone | UNIQUE |
| auth | users | id | PRIMARY KEY |
| auth | sso_providers | | CHECK |
| auth | sso_providers | id | PRIMARY KEY |
| auth | saml_relay_states | | CHECK |
| auth | saml_relay_states | flow_state_id | FOREIGN KEY |
| auth | saml_relay_states | id | PRIMARY KEY |
| auth | saml_relay_states | sso_provider_id | FOREIGN KEY |
| auth | flow_state | id | PRIMARY KEY |
| auth | one_time_tokens | id | PRIMARY KEY |
| auth | one_time_tokens | | CHECK |
| auth | one_time_tokens | user_id | FOREIGN KEY |
| auth | audit_log_entries | id | PRIMARY KEY |
| auth | mfa_factors | last_challenged_at | UNIQUE |
| auth | mfa_factors | id | PRIMARY KEY |
| auth | mfa_factors | user_id | FOREIGN KEY |
| auth | sessions | id | PRIMARY KEY |
| auth | sessions | user_id | FOREIGN KEY |
| auth | sso_domains | | CHECK |
| auth | sso_domains | id | PRIMARY KEY |
| auth | sso_domains | sso_provider_id | FOREIGN KEY |
| auth | mfa_challenges | factor_id | FOREIGN KEY |
| auth | refresh_tokens | session_id | FOREIGN KEY |
| auth | mfa_factors | id | PRIMARY KEY |
| auth | mfa_factors | user_id | FOREIGN KEY |
| auth | mfa_challenges | id | PRIMARY KEY |
| auth | mfa_amr_claims | id | PRIMARY KEY |
| auth | mfa_challenges | factor_id | FOREIGN KEY |
| auth | mfa_amr_claims | session_id | UNIQUE |
| auth | mfa_amr_claims | authentication_method | UNIQUE |
| auth | mfa_amr_claims | session_id | FOREIGN KEY |
| auth | saml_providers | | CHECK |
| auth | saml_providers | | CHECK |
| auth | saml_providers | | CHECK |
| auth | saml_providers | entity_id | UNIQUE |
| auth | mfa_amr_claims | id | PRIMARY KEY |
| auth | sso_providers | id | PRIMARY KEY |
| auth | sso_domains | id | PRIMARY KEY |
| auth | sso_domains | sso_provider_id | FOREIGN KEY |
| auth | saml_providers | id | PRIMARY KEY |
| auth | saml_providers | entity_id | UNIQUE |
| auth | saml_providers | sso_provider_id | FOREIGN KEY |
| auth | saml_relay_states | id | PRIMARY KEY |
| auth | saml_relay_states | sso_provider_id | FOREIGN KEY |
| auth | users | phone | UNIQUE |
| auth | flow_state | id | PRIMARY KEY |
| auth | saml_relay_states | flow_state_id | FOREIGN KEY |
| auth | identities | id | PRIMARY KEY |
| auth | identities | provider | UNIQUE |
| auth | identities | provider_id | UNIQUE |
| auth | identities | user_id | FOREIGN KEY |
| auth | identities | provider | UNIQUE |
| auth | one_time_tokens | id | PRIMARY KEY |
| auth | one_time_tokens | user_id | FOREIGN KEY |
| public | achievements | id | PRIMARY KEY |
| auth | mfa_factors | last_challenged_at | UNIQUE |
| storage | s3_multipart_uploads | id | PRIMARY KEY |
| storage | s3_multipart_uploads | bucket_id | FOREIGN KEY |
| storage | s3_multipart_uploads_parts | id | PRIMARY KEY |
| storage | s3_multipart_uploads_parts | upload_id | FOREIGN KEY |
| storage | s3_multipart_uploads_parts | bucket_id | FOREIGN KEY |
| realtime | schema_migrations | version | PRIMARY KEY |
| realtime | subscription | id | PRIMARY KEY |
| public | stories | theme_id | FOREIGN KEY |
| public | stories | subject_id | FOREIGN KEY |
| public | stories | character_id | FOREIGN KEY |
| public | stories | setting_id | FOREIGN KEY |
| realtime | messages | id | PRIMARY KEY |
| realtime | messages | inserted_at | PRIMARY KEY |
| pgsodium | key | | CHECK |
| pgsodium | key | parent_key | FOREIGN KEY |
| pgsodium | key | id | PRIMARY KEY |
| pgsodium | key | name | UNIQUE |
| pgsodium | key | | CHECK |
| vault | secrets | key_id | FOREIGN KEY |
| vault | secrets | id | PRIMARY KEY |
| supabase_migrations | schema_migrations | version | PRIMARY KEY |
| supabase_migrations | seed_files | path | PRIMARY KEY |
| public | story_exercise_words | | CHECK |
| public | story_exercise_words | | CHECK |
| public | story_exercise_words | | CHECK |
| public | story_pages | | CHECK |
| public | story_pages | | CHECK |
| public | story_pages | | CHECK |
| public | story_pages | | CHECK |
| public | story_pages | | CHECK |
| public | story_generations | | CHECK |
| public | story_generations | | CHECK |
| public | story_generations | | CHECK |
| public | story_generations | | CHECK |
| public | story_generations | | CHECK |
| public | story_generations | | CHECK |
| public | schools | | CHECK |
| public | schools | | CHECK |
| public | schools | | CHECK |
| public | schools | | CHECK |
| public | schools | | CHECK |
| public | teachers | | CHECK |
| public | teachers | | CHECK |
| public | teachers | | CHECK |
| public | teachers | | CHECK |
| public | teachers | | CHECK |
| public | teachers | | CHECK |
| public | classes | | CHECK |
| public | classes | | CHECK |
| public | classes | | CHECK |
| public | classes | | CHECK |
| public | classes | | CHECK |
| public | classes | | CHECK |
| public | classes | | CHECK |
| public | teacher_classes | | CHECK |
| public | teacher_classes | | CHECK |
| public | teacher_classes | | CHECK |
| public | teacher_classes | | CHECK |
| public | students | | CHECK |
| public | students | | CHECK |
| public | students | | CHECK |
| public | students | | CHECK |
| public | students | | CHECK |
| public | students | | CHECK |
| public | students | | CHECK |
| public | students | | CHECK |
| public | story_themes | | CHECK |
| public | story_themes | | CHECK |
| public | story_themes | | CHECK |
| public | story_themes | | CHECK |
| public | story_themes | | CHECK |
| public | story_themes | | CHECK |
| public | story_themes | | CHECK |
| public | story_subjects | | CHECK |
| public | story_subjects | | CHECK |
| public | story_subjects | | CHECK |
| public | story_subjects | | CHECK |
| public | story_subjects | | CHECK |
| public | story_subjects | | CHECK |
| public | story_subjects | | CHECK |
| public | story_characters | | CHECK |
| public | story_characters | | CHECK |
| public | story_characters | | CHECK |
| public | story_characters | | CHECK |
| public | story_characters | | CHECK |
| public | story_characters | | CHECK |
| public | story_characters | | CHECK |
| public | story_settings | | CHECK |
| public | story_settings | | CHECK |
| public | story_settings | | CHECK |
| public | story_settings | | CHECK |
| public | story_settings | | CHECK |
| public | story_settings | | CHECK |
| public | story_settings | | CHECK |
| public | stories | | CHECK |
| public | stories | | CHECK |
| public | stories | | CHECK |
| public | stories | | CHECK |
| public | stories | | CHECK |
| public | stories | | CHECK |
| public | stories | | CHECK |
| public | teacher_invites | | CHECK |
| public | teacher_invites | | CHECK |
| public | teacher_invites | | CHECK |
| public | teacher_invites | | CHECK |
| public | teacher_invites | | CHECK |
| public | teacher_invites | | CHECK |
| public | teacher_invites | | CHECK |
| public | phonics_exercise_types | | CHECK |
| public | phonics_exercise_types | | CHECK |
| public | phonics_exercises | | CHECK |
| public | phonics_exercises | | CHECK |
| public | phonics_exercises | | CHECK |
| public | phonics_exercises | | CHECK |
| public | phonics_words | | CHECK |
| public | phonics_words | | CHECK |
| public | phonics_words | | CHECK |
| public | phonics_exercise_words | | CHECK |
| public | phonics_categories | | CHECK |
| public | phonics_categories | | CHECK |
| public | phonics_categories | | CHECK |
| public | phonics_categories | | CHECK |
| public | phonics_exercise_media | | CHECK |
| public | phonics_exercise_media | | CHECK |
| public | student_phonics_attempt_answers | | CHECK |
| public | student_phonics_attempt_answers | | CHECK |
| public | media_types | | CHECK |
| public | media_types | | CHECK |
| public | student_phonics_progress | | CHECK |
| public | student_phonics_attempts | | CHECK |
| public | student_phonics_attempts | | CHECK |
| public | achievement_types | | CHECK |
| public | achievement_types | | CHECK |
| public | phonics_achievements | | CHECK |
| public | phonics_achievements | | CHECK |
| public | student_phonics_achievements | | CHECK |
| public | phonics_word_audio | | CHECK |
| public | phonics_word_audio | | CHECK |
| public | phonics_word_audio | | CHECK |
| public | phonics_word_audio | | CHECK |
| public | languages | | CHECK |
| public | languages | | CHECK |
| public | languages | | CHECK |
| public | languages | | CHECK |
| public | languages | | CHECK |
| public | story_recordings | | CHECK |
| public | story_recordings | | CHECK |
| public | story_recordings | | CHECK |
| public | interests | | CHECK |
| public | interests | | CHECK |
| public | interests | | CHECK |
| public | interests | | CHECK |
| public | interests | | CHECK |
| public | interests | | CHECK |
| public | achievements | | CHECK |
| public | student_achievements_old | | CHECK |
| public | student_achievements | | CHECK |
| storage | buckets | | CHECK |
| storage | buckets | | CHECK |
| storage | migrations | | CHECK |
| storage | migrations | | CHECK |
| storage | migrations | | CHECK |
| storage | objects | | CHECK |
| storage | s3_multipart_uploads | | CHECK |
| storage | s3_multipart_uploads | | CHECK |
| storage | s3_multipart_uploads | | CHECK |
| storage | s3_multipart_uploads | | CHECK |
| storage | s3_multipart_uploads | | CHECK |
| storage | s3_multipart_uploads | | CHECK |
| storage | s3_multipart_uploads | | CHECK |
| storage | s3_multipart_uploads_parts | | CHECK |
| storage | s3_multipart_uploads_parts | | CHECK |
| storage | s3_multipart_uploads_parts | | CHECK |
| storage | s3_multipart_uploads_parts | | CHECK |
| storage | s3_multipart_uploads_parts | | CHECK |
| storage | s3_multipart_uploads_parts | | CHECK |
| storage | s3_multipart_uploads_parts | | CHECK |
| storage | s3_multipart_uploads_parts | | CHECK |
| storage | s3_multipart_uploads_parts | | CHECK |
| auth | refresh_tokens | | CHECK |
| auth | instances | | CHECK |
| auth | schema_migrations | | CHECK |
| auth | users | | CHECK |
| auth | users | | CHECK |
| auth | users | | CHECK |
| auth | sso_providers | | CHECK |
| auth | saml_relay_states | | CHECK |
| auth | saml_relay_states | | CHECK |
| auth | saml_relay_states | | CHECK |
| auth | flow_state | | CHECK |
| auth | flow_state | | CHECK |
| auth | flow_state | | CHECK |
| auth | flow_state | | CHECK |
| auth | flow_state | | CHECK |
| auth | flow_state | | CHECK |
| auth | one_time_tokens | | CHECK |
| auth | one_time_tokens | | CHECK |
| auth | one_time_tokens | | CHECK |
| auth | one_time_tokens | | CHECK |
| auth | one_time_tokens | | CHECK |
| auth | one_time_tokens | | CHECK |
| auth | one_time_tokens | | CHECK |
| auth | audit_log_entries | | CHECK |
| auth | audit_log_entries | | CHECK |
| auth | mfa_factors | | CHECK |
| auth | mfa_factors | | CHECK |
| auth | mfa_factors | | CHECK |
| auth | mfa_factors | | CHECK |
| auth | mfa_factors | | CHECK |
| auth | mfa_factors | | CHECK |
| auth | sessions | | CHECK |
| auth | sessions | | CHECK |
| auth | sso_domains | | CHECK |
| auth | sso_domains | | CHECK |
| auth | sso_domains | | CHECK |
| auth | mfa_challenges | | CHECK |
| auth | mfa_challenges | | CHECK |
| auth | mfa_challenges | | CHECK |
| auth | mfa_challenges | | CHECK |
| auth | mfa_amr_claims | | CHECK |
| auth | mfa_amr_claims | | CHECK |
| auth | mfa_amr_claims | | CHECK |
| auth | mfa_amr_claims | | CHECK |
| auth | mfa_amr_claims | | CHECK |
| auth | saml_providers | | CHECK |
| auth | saml_providers | | CHECK |
| auth | saml_providers | | CHECK |
| auth | saml_providers | | CHECK |
| auth | identities | | CHECK |
| auth | identities | | CHECK |
| auth | identities | | CHECK |
| auth | identities | | CHECK |
| auth | identities | | CHECK |
| realtime | schema_migrations | | CHECK |
| realtime | subscription | | CHECK |
| realtime | subscription | | CHECK |
| realtime | subscription | | CHECK |
| realtime | subscription | | CHECK |
| realtime | subscription | | CHECK |
| realtime | subscription | | CHECK |
| realtime | subscription | | CHECK |
| realtime | messages | | CHECK |
| realtime | messages | | CHECK |
| realtime | messages | | CHECK |
| realtime | messages | | CHECK |
| realtime | messages | | CHECK |
| pgsodium | key | | CHECK |
| pgsodium | key | | CHECK |
| vault | secrets | | CHECK |
| vault | secrets | | CHECK |
| vault | secrets | | CHECK |
| vault | secrets | | CHECK |
| vault | secrets | | CHECK |
| supabase_migrations | schema_migrations | | CHECK |
| supabase_migrations | seed_files | | CHECK |
| supabase_migrations | seed_files | | CHECK |
| net | http_request_queue | | CHECK |
| net | http_request_queue | | CHECK |
| net | http_request_queue | | CHECK |
| net | http_request_queue | | CHECK |
| net | http_request_queue | | CHECK |
| net | _http_response | | CHECK |
| public | story_subjects | null | CHECK |
| public | story_recordings | null | CHECK |
| public | story_characters | null | CHECK |
| public | schools | null | CHECK |
| public | story_themes | null | CHECK |
| auth | mfa_amr_claims | null | CHECK |
| public | phonics_exercises | null | CHECK |
| public | teacher_invites | null | CHECK |
| storage | migrations | null | CHECK |
| public | story_settings | null | CHECK |
| realtime | subscription | null | CHECK |
| public | students | null | CHECK |
| public | stories | null | CHECK |
| auth | mfa_amr_claims | null | CHECK |
| public | story_recordings | null | CHECK |
| public | students | null | CHECK |
| public | phonics_word_audio | null | CHECK |
| public | languages | null | CHECK |
| pgsodium | key | null | CHECK |
| public | phonics_word_audio | null | CHECK |
| realtime | messages | null | CHECK |
| public | achievements | null | CHECK |
| public | phonics_exercise_types | null | CHECK |
| public | teacher_invites | null | CHECK |
| auth | users | null | CHECK |
| supabase_migrations | seed_files | null | CHECK |
| public | students | null | CHECK |
| auth | refresh_tokens | null | CHECK |
| pgsodium | key | null | CHECK |
| public | student_phonics_attempt_answers | null | CHECK |
| auth | identities | null | CHECK |
| storage | s3_multipart_uploads | null | CHECK |
| auth | flow_state | null | CHECK |
| auth | mfa_factors | null | CHECK |
| public | phonics_words | null | CHECK |
| public | stories | null | CHECK |
| public | story_subjects | null | CHECK |
| auth | flow_state | null | CHECK |
| public | phonics_words | null | CHECK |
| realtime | subscription | null | CHECK |
| auth | sso_domains | null | CHECK |
| public | story_settings | null | CHECK |
| auth | users | null | CHECK |
| public | phonics_categories | null | CHECK |
| public | teacher_invites | null | CHECK |
| public | stories | null | CHECK |
| public | story_themes | null | CHECK |
| storage | s3_multipart_uploads_parts | null | CHECK |
| public | teachers | null | CHECK |
| public | teachers | null | CHECK |
| public | story_themes | null | CHECK |
| public | phonics_exercise_words | null | CHECK |
| public | students | null | CHECK |
| realtime | subscription | null | CHECK |
| auth | mfa_amr_claims | null | CHECK |
| public | teacher_classes | null | CHECK |
| auth | flow_state | null | CHECK |
| public | students | null | CHECK |
| public | story_characters | null | CHECK |
| auth | mfa_factors | null | CHECK |
| realtime | schema_migrations | null | CHECK |
| public | languages | null | CHECK |
| public | stories | null | CHECK |
| public | phonics_word_audio | null | CHECK |
| pgsodium | key | null | CHECK |
| storage | s3_multipart_uploads | null | CHECK |
| auth | saml_providers | null | CHECK |
| auth | saml_providers | null | CHECK |
| storage | s3_multipart_uploads_parts | null | CHECK |
| public | story_characters | null | CHECK |
| storage | s3_multipart_uploads | null | CHECK |
| public | interests | null | CHECK |
| public | story_generations | null | CHECK |
| vault | secrets | null | CHECK |
| public | students | null | CHECK |
| vault | secrets | null | CHECK |
| auth | users | null | CHECK |
| public | story_themes | null | CHECK |
| public | classes | null | CHECK |
| auth | mfa_amr_claims | null | CHECK |
| auth | identities | null | CHECK |
| public | story_generations | null | CHECK |
| public | story_exercise_words | null | CHECK |
| public | achievement_types | null | CHECK |
| realtime | messages | null | CHECK |
| auth | one_time_tokens | null | CHECK |
| auth | mfa_challenges | null | CHECK |
| public | teachers | null | CHECK |
| auth | mfa_amr_claims | null | CHECK |
| public | teacher_invites | null | CHECK |
| storage | s3_multipart_uploads_parts | null | CHECK |
| public | teachers | null | CHECK |
| public | phonics_categories | null | CHECK |
| public | story_settings | null | CHECK |
| public | schools | null | CHECK |
| realtime | subscription | null | CHECK |
| public | story_recordings | null | CHECK |
| public | stories | null | CHECK |
| public | story_pages | null | CHECK |
| auth | identities | null | CHECK |
| public | interests | null | CHECK |
| auth | flow_state | null | CHECK |
| auth | one_time_tokens | null | CHECK |
| public | teacher_invites | null | CHECK |
| auth | schema_migrations | null | CHECK |
| auth | mfa_challenges | null | CHECK |
| public | student_phonics_attempts | null | CHECK |
| public | story_settings | null | CHECK |
| public | teachers | null | CHECK |
| pgsodium | key | null | CHECK |
| public | interests | null | CHECK |
| auth | instances | null | CHECK |
| public | schools | null | CHECK |
| public | student_phonics_achievements | null | CHECK |
| storage | migrations | null | CHECK |
| public | classes | null | CHECK |
| public | story_exercise_words | null | CHECK |
| public | phonics_word_audio | null | CHECK |
| public | media_types | null | CHECK |
| public | languages | null | CHECK |
| public | story_themes | null | CHECK |
| auth | one_time_tokens | null | CHECK |
| auth | one_time_tokens | null | CHECK |
| realtime | messages | null | CHECK |
| realtime | messages | null | CHECK |
| public | story_characters | null | CHECK |
| public | story_subjects | null | CHECK |
| storage | s3_multipart_uploads_parts | null | CHECK |
| auth | sso_domains | null | CHECK |
| storage | s3_multipart_uploads_parts | null | CHECK |
| public | teacher_invites | null | CHECK |
| public | students | null | CHECK |
| auth | saml_relay_states | null | CHECK |
| public | stories | null | CHECK |
| public | story_settings | null | CHECK |
| public | story_exercise_words | null | CHECK |
| auth | mfa_challenges | null | CHECK |
| auth | one_time_tokens | null | CHECK |
| auth | saml_providers | null | CHECK |
| public | story_recordings | null | CHECK |
| public | phonics_words | null | CHECK |
| public | classes | null | CHECK |
| public | phonics_achievements | null | CHECK |
| public | phonics_exercises | null | CHECK |
| public | story_pages | null | CHECK |
| public | student_phonics_progress | null | CHECK |
| auth | saml_providers | null | CHECK |
| realtime | subscription | null | CHECK |
| public | story_subjects | null | CHECK |
| auth | sso_providers | null | CHECK |
| public | media_types | null | CHECK |
| storage | s3_multipart_uploads | null | CHECK |
| auth | one_time_tokens | null | CHECK |
| public | story_generations | null | CHECK |
| auth | saml_relay_states | null | CHECK |
| public | story_themes | null | CHECK |
| storage | buckets | null | CHECK |
| storage | s3_multipart_uploads_parts | null | CHECK |
| vault | secrets | null | CHECK |
| public | teacher_classes | null | CHECK |
| public | phonics_categories | null | CHECK |
| auth | mfa_factors | null | CHECK |
| auth | audit_log_entries | null | CHECK |
| auth | mfa_factors | null | CHECK |
| public | classes | null | CHECK |
| auth | saml_providers | null | CHECK |
| public | story_subjects | null | CHECK |
| public | story_settings | null | CHECK |
| public | phonics_categories | null | CHECK |
| public | story_subjects | null | CHECK |
| auth | flow_state | null | CHECK |
| public | student_phonics_attempts | null | CHECK |
| public | story_generations | null | CHECK |
| public | phonics_exercises | null | CHECK |
| auth | sso_domains | null | CHECK |
| storage | s3_multipart_uploads | null | CHECK |
| public | schools | null | CHECK |
| auth | users | null | CHECK |
| public | interests | null | CHECK |
| realtime | messages | null | CHECK |
| public | phonics_exercise_types | null | CHECK |
| public | story_exercise_words | null | CHECK |
| auth | audit_log_entries | null | CHECK |
| public | story_characters | null | CHECK |
| public | student_achievements_old | null | CHECK |
| net | http_request_queue | null | CHECK |
| auth | saml_providers | null | CHECK |
| storage | s3_multipart_uploads | null | CHECK |
| supabase_migrations | seed_files | null | CHECK |
| public | phonics_achievements | null | CHECK |
| public | story_pages | null | CHECK |
| public | phonics_exercises | null | CHECK |
| storage | objects | null | CHECK |
| public | student_phonics_attempt_answers | null | CHECK |
| storage | migrations | null | CHECK |
| auth | sso_domains | null | CHECK |
| public | story_recordings | null | CHECK |
| public | classes | null | CHECK |
| net | _http_response | null | CHECK |
| realtime | subscription | null | CHECK |
| public | teacher_invites | null | CHECK |
| auth | sessions | null | CHECK |
| public | phonics_exercise_media | null | CHECK |
| public | schools | null | CHECK |
| net | http_request_queue | null | CHECK |
| public | classes | null | CHECK |
| auth | sso_providers | null | CHECK |
| public | story_subjects | null | CHECK |
| auth | one_time_tokens | null | CHECK |
| public | story_recordings | null | CHECK |
| public | students | null | CHECK |
| realtime | subscription | null | CHECK |
| public | story_recordings | null | CHECK |
| net | http_request_queue | null | CHECK |
| auth | identities | null | CHECK |
| storage | s3_multipart_uploads | null | CHECK |
| public | story_themes | null | CHECK |
| auth | saml_relay_states | null | CHECK |
| public | teacher_invites | null | CHECK |
| auth | mfa_factors | null | CHECK |
| auth | identities | null | CHECK |
| public | stories | null | CHECK |
| public | story_pages | null | CHECK |
| vault | secrets | null | CHECK |
| vault | secrets | null | CHECK |
| public | achievement_types | null | CHECK |
| auth | saml_relay_states | null | CHECK |
| public | classes | null | CHECK |
| public | interests | null | CHECK |
| supabase_migrations | schema_migrations | null | CHECK |
| public | stories | null | CHECK |
| public | phonics_exercise_media | null | CHECK |
| auth | mfa_challenges | null | CHECK |
| public | story_characters | null | CHECK |
| storage | s3_multipart_uploads_parts | null | CHECK |
| public | languages | null | CHECK |
| public | teachers | null | CHECK |
| public | teachers | null | CHECK |
| storage | buckets | null | CHECK |
| public | story_settings | null | CHECK |
| public | interests | null | CHECK |
| public | languages | null | CHECK |
| auth | sessions | null | CHECK |
| public | story_pages | null | CHECK |
| net | http_request_queue | null | CHECK |
| auth | saml_providers | null | CHECK |
| public | teacher_classes | null | CHECK |
| public | story_generations | null | CHECK |
| auth | flow_state | null | CHECK |
| public | story_characters | null | CHECK |
| storage | s3_multipart_uploads_parts | null | CHECK |
| public | student_achievements | null | CHECK |
| public | students | null | CHECK |
| public | story_generations | null | CHECK |
| auth | one_time_tokens | null | CHECK |
| net | http_request_queue | null | CHECK |
| auth | mfa_factors | null | CHECK |
| storage | s3_multipart_uploads_parts | null | CHECK |
| public | teacher_classes | null | CHECK |

File diff suppressed because it is too large Load Diff

View File

@ -1,29 +1,29 @@
| policy_id | schema_name | table_name | policy_name | command | policy_using | policy_check |
| --------- | ----------- | ---------------------- | ------------------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| 29823 | auth | users | Validate user metadata | * | (((raw_user_meta_data ->> 'role'::text))::user_role IS NOT NULL) | |
| 29615 | public | classes | Schools can create classes | a | | (school_id = auth.uid()) |
| 29823 | auth | users | Validate user metadata | * | (((raw_user_meta_data ->> 'role'::text))::user_role IS NOT NULL) | null |
| 29615 | public | classes | Schools can create classes | a | null | (school_id = auth.uid()) |
| 29616 | public | classes | Schools can update their classes | w | (school_id = auth.uid()) | (school_id = auth.uid()) |
| 29614 | public | classes | Schools can view their classes | r | (school_id = auth.uid()) | |
| 29301 | public | classes | Turmas visíveis para usuários autenticados | r | true | |
| 65878 | public | interests | Students can delete their own interests | d | (auth.uid() = student_id) | |
| 65876 | public | interests | Students can insert their own interests | a | | (auth.uid() = student_id) |
| 29614 | public | classes | Schools can view their classes | r | (school_id = auth.uid()) | null |
| 29301 | public | classes | Turmas visíveis para usuários autenticados | r | true | null |
| 65878 | public | interests | Students can delete their own interests | d | (auth.uid() = student_id) | null |
| 65876 | public | interests | Students can insert their own interests | a | null | (auth.uid() = student_id) |
| 65877 | public | interests | Students can update their own interests | w | (auth.uid() = student_id) | (auth.uid() = student_id) |
| 65875 | public | interests | Students can view their own interests | r | (auth.uid() = student_id) | |
| 65875 | public | interests | Students can view their own interests | r | (auth.uid() = student_id) | null |
| 104599 | public | languages | Allow insert/update for admins only | * | ((auth.jwt() ->> 'role'::text) = 'admin'::text) | ((auth.jwt() ->> 'role'::text) = 'admin'::text) |
| 104598 | public | languages | Allow read access for all authenticated users | r | true | |
| 79931 | public | phonics_categories | Permitir leitura de categorias fonéticas para usuários autent | r | true | |
| 79932 | public | phonics_exercise_types | Permitir leitura de tipos de exercícios fonéticos para usuár | r | true | |
| 79934 | public | phonics_exercise_words | Permitir leitura de relações exercício-palavra para usuário | r | true | |
| 79930 | public | phonics_exercises | Permitir leitura de exercícios fonéticos para usuários auten | r | true | |
| 79933 | public | phonics_words | Permitir leitura de palavras fonéticas para usuários autentic | r | true | |
| 29440 | public | schools | Enable insert for registration | a | | true |
| 29299 | public | schools | Escolas visíveis para usuários autenticados | r | true | |
| 104598 | public | languages | Allow read access for all authenticated users | r | true | null |
| 79931 | public | phonics_categories | Permitir leitura de categorias fonéticas para usuários autent | r | true | null |
| 79932 | public | phonics_exercise_types | Permitir leitura de tipos de exercícios fonéticos para usuár | r | true | null |
| 79934 | public | phonics_exercise_words | Permitir leitura de relações exercício-palavra para usuário | r | true | null |
| 79930 | public | phonics_exercises | Permitir leitura de exercícios fonéticos para usuários auten | r | true | null |
| 79933 | public | phonics_words | Permitir leitura de palavras fonéticas para usuários autentic | r | true | null |
| 29440 | public | schools | Enable insert for registration | a | null | true |
| 29299 | public | schools | Escolas visíveis para usuários autenticados | r | true | null |
| 29442 | public | schools | Schools can update own data | w | (auth.uid() = id) | (auth.uid() = id) |
| 29441 | public | schools | Schools can view own data | r | (auth.uid() = id) | |
| 29441 | public | schools | Schools can view own data | r | (auth.uid() = id) | null |
| 29347 | public | stories | Alunos podem atualizar suas próprias histórias | w | (student_id IN ( SELECT students.id
FROM students
WHERE (students.email = auth.email()))) | |
| 29346 | public | stories | Alunos podem criar suas próprias histórias | a | | (student_id IN ( SELECT students.id
WHERE (students.email = auth.email()))) | null |
| 29346 | public | stories | Alunos podem criar suas próprias histórias | a | null | (student_id IN ( SELECT students.id
FROM students
WHERE (students.email = auth.email()))) |
| 36241 | public | stories | Estudantes podem ver suas próprias histórias | r | ((auth.uid() = student_id) AND (EXISTS ( SELECT 1
@ -34,60 +34,60 @@
FROM story_characters
WHERE ((story_characters.id = stories.character_id) AND (story_characters.active = true)))) AND (EXISTS ( SELECT 1
FROM story_settings
WHERE ((story_settings.id = stories.setting_id) AND (story_settings.active = true))))) | |
| 29345 | public | stories | Histórias visíveis para usuários autenticados | r | true | |
| 53384 | public | stories | Permitir deleção pelo dono | d | (auth.uid() = student_id) | |
| 34952 | public | story_characters | Permitir leitura pública dos personagens | r | (active = true) | |
| 53955 | public | story_exercise_words | Apenas sistema pode inserir | a | | (auth.role() = 'service_role'::text) |
| 53954 | public | story_exercise_words | Leitura pública das palavras | r | true | |
| 37664 | public | story_generations | Apenas service_role pode inserir metadados | a | | true |
| 37663 | public | story_generations | Metadados são visíveis para todos | r | true | |
| 37662 | public | story_pages | Apenas service_role pode inserir páginas | a | | true |
| 37661 | public | story_pages | Páginas são visíveis para todos | r | true | |
WHERE ((story_settings.id = stories.setting_id) AND (story_settings.active = true))))) | null |
| 29345 | public | stories | Histórias visíveis para usuários autenticados | r | true | null |
| 53384 | public | stories | Permitir deleção pelo dono | d | (auth.uid() = student_id) | null |
| 34952 | public | story_characters | Permitir leitura pública dos personagens | r | (active = true) | null |
| 53955 | public | story_exercise_words | Apenas sistema pode inserir | a | null | (auth.role() = 'service_role'::text) |
| 53954 | public | story_exercise_words | Leitura pública das palavras | r | true | null |
| 37664 | public | story_generations | Apenas service_role pode inserir metadados | a | null | true |
| 37663 | public | story_generations | Metadados são visíveis para todos | r | true | null |
| 37662 | public | story_pages | Apenas service_role pode inserir páginas | a | null | true |
| 37661 | public | story_pages | Páginas são visíveis para todos | r | true | null |
| 31560 | public | story_recordings | Escolas podem ver todas as gravações | r | (EXISTS ( SELECT 1
FROM students s
WHERE ((s.id = story_recordings.student_id) AND (s.school_id = auth.uid())))) | |
| 30092 | public | story_recordings | Estudantes podem gravar áudios | a | | (auth.uid() = student_id) |
| 31511 | public | story_recordings | Estudantes podem ver suas próprias gravações | r | (auth.uid() = student_id) | |
WHERE ((s.id = story_recordings.student_id) AND (s.school_id = auth.uid())))) | null |
| 30092 | public | story_recordings | Estudantes podem gravar áudios | a | null | (auth.uid() = student_id) |
| 31511 | public | story_recordings | Estudantes podem ver suas próprias gravações | r | (auth.uid() = student_id) | null |
| 31558 | public | story_recordings | Professores podem ver gravações de seus alunos | r | (EXISTS ( SELECT 1
FROM (classes c
JOIN students s ON ((s.class_id = c.id)))
WHERE ((s.id = story_recordings.student_id) AND (c.teacher_id = auth.uid())))) | |
| 29748 | public | story_recordings | Students can insert their own recordings | a | | (auth.uid() = student_id) |
| 29749 | public | story_recordings | Students can view their own recordings | r | (auth.uid() = student_id) | |
| 34953 | public | story_settings | Permitir leitura pública dos cenários | r | (active = true) | |
| 34951 | public | story_subjects | Permitir leitura pública das disciplinas | r | (active = true) | |
| 34950 | public | story_themes | Permitir leitura pública das categorias | r | (active = true) | |
| 29302 | public | students | Alunos visíveis para usuários autenticados | r | true | |
| 29638 | public | students | Escolas podem inserir seus próprios alunos | a | | (auth.uid() IN ( SELECT schools.id
WHERE ((s.id = story_recordings.student_id) AND (c.teacher_id = auth.uid())))) | null |
| 29748 | public | story_recordings | Students can insert their own recordings | a | null | (auth.uid() = student_id) |
| 29749 | public | story_recordings | Students can view their own recordings | r | (auth.uid() = student_id) | null |
| 34953 | public | story_settings | Permitir leitura pública dos cenários | r | (active = true) | null |
| 34951 | public | story_subjects | Permitir leitura pública das disciplinas | r | (active = true) | null |
| 34950 | public | story_themes | Permitir leitura pública das categorias | r | (active = true) | null |
| 29302 | public | students | Alunos visíveis para usuários autenticados | r | true | null |
| 29638 | public | students | Escolas podem inserir seus próprios alunos | a | null | (auth.uid() IN ( SELECT schools.id
FROM schools
WHERE (schools.id = students.school_id))) |
| 29639 | public | students | Escolas podem ver seus próprios alunos | r | (auth.uid() IN ( SELECT schools.id
FROM schools
WHERE (schools.id = students.school_id))) | |
| 29584 | public | students | Schools can view their students | r | (school_id = auth.uid()) | |
| 29511 | public | teacher_invites | Schools can invite teachers | a | | (school_id IN ( SELECT schools.id
WHERE (schools.id = students.school_id))) | null |
| 29584 | public | students | Schools can view their students | r | (school_id = auth.uid()) | null |
| 29511 | public | teacher_invites | Schools can invite teachers | a | null | (school_id IN ( SELECT schools.id
FROM schools
WHERE (schools.id = auth.uid()))) |
| 29300 | public | teachers | Professores visíveis para usuários autenticados | r | true | |
| 29300 | public | teachers | Professores visíveis para usuários autenticados | r | true | null |
| 29510 | public | teachers | Schools can view their teachers | r | (school_id IN ( SELECT schools.id
FROM schools
WHERE (schools.id = auth.uid()))) | |
| 29509 | public | teachers | Teachers can view own data | r | (auth.uid() = id) | |
| 29717 | storage | objects | Anyone can read recordings | r | (bucket_id = 'recordings'::text) | |
| 30136 | storage | objects | Estudantes podem fazer upload de áudios | a | | ((bucket_id = 'recordings'::text) AND ((auth.uid())::text = (storage.foldername(name))[1])) |
| 75352 | storage | objects | Imagens são publicamente acessíveis | r | (bucket_id = 'story-images'::text) | |
| 43940 | storage | objects | Permitir acesso da Edge Function | r | ((bucket_id = 'recordings'::text) AND ((auth.jwt() ->> 'role'::text) = 'service_role'::text)) | |
| 52098 | storage | objects | Permitir acesso público para leitura | r | (bucket_id = 'recordings'::text) | |
| 37570 | storage | objects | Permitir acesso público para leitura de imagens de histórias | r | (bucket_id = 'story-images'::text) | |
| 37573 | storage | objects | Permitir delete pela edge function | d | (bucket_id = 'story-images'::text) | |
WHERE (schools.id = auth.uid()))) | null |
| 29509 | public | teachers | Teachers can view own data | r | (auth.uid() = id) | null |
| 29717 | storage | objects | Anyone can read recordings | r | (bucket_id = 'recordings'::text) | null |
| 30136 | storage | objects | Estudantes podem fazer upload de áudios | a | null | ((bucket_id = 'recordings'::text) AND ((auth.uid())::text = (storage.foldername(name))[1])) |
| 75352 | storage | objects | Imagens são publicamente acessíveis | r | (bucket_id = 'story-images'::text) | null |
| 43940 | storage | objects | Permitir acesso da Edge Function | r | ((bucket_id = 'recordings'::text) AND ((auth.jwt() ->> 'role'::text) = 'service_role'::text)) | null |
| 52098 | storage | objects | Permitir acesso público para leitura | r | (bucket_id = 'recordings'::text) | null |
| 37570 | storage | objects | Permitir acesso público para leitura de imagens de histórias | r | (bucket_id = 'story-images'::text) | null |
| 37573 | storage | objects | Permitir delete pela edge function | d | (bucket_id = 'story-images'::text) | null |
| 53468 | storage | objects | Permitir deleção de imagens pelo dono da história | d | ((bucket_id = 'story-images'::text) AND (EXISTS ( SELECT 1
FROM stories s
WHERE ((s.id = ((storage.foldername(objects.name))[1])::uuid) AND (s.student_id = auth.uid()))))) | |
| 53426 | storage | objects | Permitir deleção pelo dono do arquivo | d | ((bucket_id = 'recordings'::text) AND ((storage.foldername(name))[1] = (auth.uid())::text)) | |
| 52099 | storage | objects | Permitir download público | r | (bucket_id = 'recordings'::text) | |
| 37572 | storage | objects | Permitir update pela edge function | w | (bucket_id = 'story-images'::text) | |
| 43939 | storage | objects | Permitir upload de áudios autenticado | a | | ((bucket_id = 'recordings'::text) AND (auth.role() = 'authenticated'::text)) |
| 37571 | storage | objects | Permitir upload pela edge function | a | | (bucket_id = 'story-images'::text) |
| 29716 | storage | objects | Students can upload their recordings | a | | ((bucket_id = 'recordings'::text) AND (auth.role() = 'student'::text)) |
| 74045 | storage | objects | Áudios públicos | r | (bucket_id = 'phonics-audio'::text) | |
WHERE ((s.id = ((storage.foldername(objects.name))[1])::uuid) AND (s.student_id = auth.uid()))))) | null |
| 53426 | storage | objects | Permitir deleção pelo dono do arquivo | d | ((bucket_id = 'recordings'::text) AND ((storage.foldername(name))[1] = (auth.uid())::text)) | null |
| 52099 | storage | objects | Permitir download público | r | (bucket_id = 'recordings'::text) | null |
| 37572 | storage | objects | Permitir update pela edge function | w | (bucket_id = 'story-images'::text) | null |
| 43939 | storage | objects | Permitir upload de áudios autenticado | a | null | ((bucket_id = 'recordings'::text) AND (auth.role() = 'authenticated'::text)) |
| 37571 | storage | objects | Permitir upload pela edge function | a | null | (bucket_id = 'story-images'::text) |
| 29716 | storage | objects | Students can upload their recordings | a | null | ((bucket_id = 'recordings'::text) AND (auth.role() = 'student'::text)) |
| 74045 | storage | objects | Áudios públicos | r | (bucket_id = 'phonics-audio'::text) | null |

View File

@ -34,6 +34,7 @@ interface StoryPayload {
const ALLOWED_ORIGINS = [
'http://localhost:5173', // Vite dev server
'http://localhost', // Vite dev server
'http://localhost:3000', // Caso use outro port
'https://leiturama.ai', // Produção
'https://leiturama.netlify.app'
@ -71,6 +72,7 @@ serve(async (req) => {
'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
'Access-Control-Max-Age': '86400', // 24 horas
'Cross-Origin-Embedder-Policy': 'credentialless'
};
// Preflight request
@ -142,7 +144,6 @@ serve(async (req) => {
content: prompt
}
],
store: true,
response_format: {
type: "json_schema",
json_schema: {
@ -177,19 +178,22 @@ serve(async (req) => {
keywords: {
type: "array",
items: {
type: "string"
type: "string",
description: "Palavras chaves da página"
}
},
phonemes: {
type: "array",
items: {
type: "string"
type: "string",
description: "Fonemas da página"
}
},
syllablePatterns: {
type: "array",
items: {
type: "string",
description: "Padrões silábicos da página",
enum: ["CV", "CVC", "CCVC"]
}
}
@ -206,10 +210,13 @@ serve(async (req) => {
type: "object",
properties: {
targetAge: {
type: "number"
type: "number",
description: "Idade alvo da história"
},
difficulty: {
type: "string"
type: "string",
description: "Dificuldade da história",
enum: ["easy", "medium", "hard"]
},
exerciseWords: {
type: "object",
@ -319,6 +326,7 @@ serve(async (req) => {
return {
text: page.text,
text_syllables: page.text_syllables,
image: publicUrl.publicUrl, // Salvar apenas o caminho do arquivo
image_path: fileName
};
@ -480,12 +488,20 @@ function buildPrompt(base: StoryPrompt, voice?: string) {
- ${selectedLanguage.instructions}
- Linguagem clara e envolvente
- 3-8 páginas de conteúdo
- Cada página deve ter um texto curto, o mesmo texto separado em sílabas e uma sugestão para uma imagem
- Cada página deve ter um texto, o mesmo texto separado em sílabas e uma sugestão para uma imagem
- Evitar conteúdo sensível ou inadequado
- Incluir elementos de ${base.theme_id}
- Ambientado em ${base.setting_id}
- Personagem principal baseado em ${base.character_id}
- Use a jornada no héroi para escrever as histórias.
- O personagem principal deve ter um objetivo e uma jornada.
- O personagem principal deve ser um heroi que resolve um problema.
- O personagem principal deve ser um heroi que encontra um tesouro.
- O personagem principal deve ser um heroi que encontra um amigo.
- O personagem principal deve ser um heroi que encontra um inimigo.
- O personagem principal deve ser um heroi que encontra um mentor.
- Faça uma média de 50 a 70 palavras por página.
Requisitos específicos para exercícios:
1. Para o exercício de completar frases: