mirror of
https://github.com/jjbrunton/Sauci.git
synced 2026-10-31 18:19:43 +00:00
Update
This commit is contained in:
1 parent
d8f2f10418
commit
c902763f9c
2 files changed
+20
-13
No files matched your search
@@ -20,6 +20,7 @@ type AuditAction = 'INSERT' | 'UPDATE' | 'DELETE';
|
|||||||
async function logAction(
|
async function logAction(
|
||||||
tableName: string,
|
tableName: string,
|
||||||
action: AuditAction,
|
action: AuditAction,
|
||||||
|
recordId: string | null,
|
||||||
oldValues?: Record<string, unknown> | null,
|
oldValues?: Record<string, unknown> | null,
|
||||||
newValues?: Record<string, unknown> | null
|
newValues?: Record<string, unknown> | null
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
@@ -29,6 +30,7 @@ async function logAction(
|
|||||||
const { error } = await supabase.rpc('log_admin_action', {
|
const { error } = await supabase.rpc('log_admin_action', {
|
||||||
p_table_name: tableName,
|
p_table_name: tableName,
|
||||||
p_action: action,
|
p_action: action,
|
||||||
|
p_record_id: recordId,
|
||||||
p_old_values: oldValues || null,
|
p_old_values: oldValues || null,
|
||||||
p_new_values: newValues || null,
|
p_new_values: newValues || null,
|
||||||
});
|
});
|
||||||
@@ -72,7 +74,7 @@ export const auditedSupabase = {
|
|||||||
if (!error && data) {
|
if (!error && data) {
|
||||||
// Log each inserted record
|
// Log each inserted record
|
||||||
for (const record of data as T[]) {
|
for (const record of data as T[]) {
|
||||||
await logAction(table, 'INSERT', null, record as Record<string, unknown>);
|
await logAction(table, 'INSERT', record.id, null, record as Record<string, unknown>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +108,7 @@ export const auditedSupabase = {
|
|||||||
.single();
|
.single();
|
||||||
|
|
||||||
if (!error && data) {
|
if (!error && data) {
|
||||||
await logAction(table, 'UPDATE', oldValues, data as Record<string, unknown>);
|
await logAction(table, 'UPDATE', id, oldValues, data as Record<string, unknown>);
|
||||||
}
|
}
|
||||||
|
|
||||||
return { data: data as T | null, error };
|
return { data: data as T | null, error };
|
||||||
@@ -140,7 +142,7 @@ export const auditedSupabase = {
|
|||||||
// Log each updated record
|
// Log each updated record
|
||||||
for (const record of data as T[]) {
|
for (const record of data as T[]) {
|
||||||
const oldRecord = oldRecords.find(r => r.id === record.id);
|
const oldRecord = oldRecords.find(r => r.id === record.id);
|
||||||
await logAction(table, 'UPDATE', oldRecord || null, record as Record<string, unknown>);
|
await logAction(table, 'UPDATE', record.id, oldRecord || null, record as Record<string, unknown>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,7 +173,7 @@ export const auditedSupabase = {
|
|||||||
.eq('id', id);
|
.eq('id', id);
|
||||||
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
await logAction(table, 'DELETE', oldValues, null);
|
await logAction(table, 'DELETE', id, oldValues, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return { error };
|
return { error };
|
||||||
@@ -202,7 +204,7 @@ export const auditedSupabase = {
|
|||||||
if (!error) {
|
if (!error) {
|
||||||
// Log each deletion
|
// Log each deletion
|
||||||
for (const record of oldRecords) {
|
for (const record of oldRecords) {
|
||||||
await logAction(table, 'DELETE', record, null);
|
await logAction(table, 'DELETE', record.id as string, record, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +236,7 @@ export const auditedSupabase = {
|
|||||||
.eq(field, value);
|
.eq(field, value);
|
||||||
|
|
||||||
if (!error && oldValues) {
|
if (!error && oldValues) {
|
||||||
await logAction(table, 'DELETE', oldValues, null);
|
await logAction(table, 'DELETE', (oldValues.id as string) || null, oldValues, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return { error };
|
return { error };
|
||||||
|
|||||||
@@ -312,21 +312,26 @@ Mix distinct symmetric and asymmetric proposals.`;
|
|||||||
|
|
||||||
export async function generateCategory(): Promise<{ name: string; description: string; icon: string }> {
|
export async function generateCategory(): Promise<{ name: string; description: string; icon: string }> {
|
||||||
const openai = getOpenAI();
|
const openai = getOpenAI();
|
||||||
const prompt = `Generate a unique category for organizing question packs in a couples' intimacy/connection app.
|
const prompt = `Generate a unique category for organizing activity packs in a couples' intimacy/connection app.
|
||||||
|
|
||||||
Return a JSON object with:
|
This is an ACTIVITY-FOCUSED app where couples swipe on activity proposals.
|
||||||
- name: Category name (1-3 words, e.g., "Romance", "Adventure", "Communication")
|
Each partner independently swipes Like/Dislike/Maybe, and when both swipe positively they "match".
|
||||||
- description: Brief description of what packs in this category explore (1 sentence)
|
Categories organize collections of activity packs (date ideas, intimate experiences, adventures, challenges, etc.).
|
||||||
- icon: A single emoji that represents this category
|
This is NOT a Q&A app - it's about discovering shared interests in activities.
|
||||||
|
|
||||||
Be creative and think of categories that help couples explore different aspects of their relationship.`;
|
Return a JSON object with:
|
||||||
|
- name: Category name (1-3 words, e.g., "Romance", "Adventure", "Date Nights")
|
||||||
|
- description: Brief description of what activity packs in this category contain (1 sentence)
|
||||||
|
- icon: A single emoji that represents this category
|
||||||
|
|
||||||
|
Be creative and think of categories that help couples explore different types of activities together.`;
|
||||||
|
|
||||||
const response = await openai.chat.completions.create({
|
const response = await openai.chat.completions.create({
|
||||||
model: getModel('generate'),
|
model: getModel('generate'),
|
||||||
messages: [
|
messages: [
|
||||||
{
|
{
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content: 'You are a creative content organizer for a couples relationship app. Generate engaging category ideas. Always respond with valid JSON only.',
|
content: 'You are a creative content organizer for a couples activity/intimacy app. The app helps couples discover shared interests by swiping on activity proposals. Generate engaging category ideas for organizing activity packs. Always respond with valid JSON only.',
|
||||||
},
|
},
|
||||||
{ role: 'user', content: prompt },
|
{ role: 'user', content: prompt },
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in new issue
Block a user