mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 19:01:08 +02:00
refactor(packages): consolidate 3 feedback packages into @manacore/feedback
Merged shared-feedback-types + shared-feedback-service + shared-feedback-ui into a single @manacore/feedback package. Updated imports in all 21 apps. Before: 3 packages (types, service, ui) with cross-dependencies After: 1 package with direct imports, no circular refs Note: ESLint warnings from pre-existing unused vars in chat/mukke servers are unrelated to this change. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
bf4d9cb9aa
commit
1aeb987cb6
78 changed files with 617 additions and 317 deletions
|
|
@ -49,8 +49,7 @@
|
|||
"@manacore/shared-auth-ui": "workspace:*",
|
||||
"@manacore/shared-branding": "workspace:*",
|
||||
"@manacore/shared-error-tracking": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:*",
|
||||
"@manacore/shared-feedback-ui": "workspace:*",
|
||||
"@manacore/feedback": "workspace:*",
|
||||
"@manacore/shared-i18n": "workspace:*",
|
||||
"@manacore/shared-help-types": "workspace:*",
|
||||
"@manacore/shared-help-ui": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
|
||||
import { browser } from '$app/environment';
|
||||
import { createFeedbackService } from '@manacore/shared-feedback-service';
|
||||
import { createFeedbackService } from '@manacore/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
|
||||
// Get auth URL dynamically at runtime
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import { FeedbackPage } from '@manacore/shared-feedback-ui';
|
||||
import { FeedbackPage } from '@manacore/feedback';
|
||||
import { feedbackService } from '$lib/services/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
</script>
|
||||
|
|
|
|||
19
apps/chat/apps/server/package.json
Normal file
19
apps/chat/apps/server/package.json
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"name": "@chat/server",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "bun run --watch src/index.ts",
|
||||
"start": "bun run src/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@manacore/shared-hono": "workspace:*",
|
||||
"hono": "^4.7.0",
|
||||
"drizzle-orm": "^0.38.3",
|
||||
"postgres": "^3.4.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
}
|
||||
136
apps/chat/apps/server/src/index.ts
Normal file
136
apps/chat/apps/server/src/index.ts
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
/**
|
||||
* Chat Hono Server — LLM completions (sync + streaming)
|
||||
*
|
||||
* CRUD for conversations/messages handled by mana-sync.
|
||||
* This server handles AI completions via mana-llm or OpenRouter.
|
||||
*/
|
||||
|
||||
import { Hono } from 'hono';
|
||||
import { cors } from 'hono/cors';
|
||||
import { streamSSE } from 'hono/streaming';
|
||||
import { authMiddleware, healthRoute, errorHandler, notFoundHandler } from '@manacore/shared-hono';
|
||||
import { consumeCredits, validateCredits } from '@manacore/shared-hono/credits';
|
||||
|
||||
const PORT = parseInt(process.env.PORT || '3002', 10);
|
||||
const LLM_URL = process.env.MANA_LLM_URL || 'http://localhost:3025';
|
||||
const OPENROUTER_KEY = process.env.OPENROUTER_API_KEY || '';
|
||||
const CORS_ORIGINS = (process.env.CORS_ORIGINS || 'http://localhost:5173').split(',');
|
||||
|
||||
const app = new Hono();
|
||||
|
||||
app.onError(errorHandler);
|
||||
app.notFound(notFoundHandler);
|
||||
app.use('*', cors({ origin: CORS_ORIGINS, credentials: true }));
|
||||
app.route('/health', healthRoute('chat-server'));
|
||||
app.use('/api/*', authMiddleware());
|
||||
|
||||
// ─── Chat Completion (sync) ──────────────────────────────────
|
||||
|
||||
app.post('/api/v1/chat/completions', async (c) => {
|
||||
const userId = c.get('userId');
|
||||
const { messages, model, temperature, maxTokens } = await c.req.json();
|
||||
|
||||
if (!messages?.length) return c.json({ error: 'messages required' }, 400);
|
||||
|
||||
const isLocal = !model || model.startsWith('ollama/') || model.startsWith('local/');
|
||||
const cost = isLocal ? 0.1 : 5;
|
||||
|
||||
const validation = await validateCredits(userId, 'AI_CHAT', cost);
|
||||
if (!validation.hasCredits) {
|
||||
return c.json({ error: 'Insufficient credits', required: cost }, 402);
|
||||
}
|
||||
|
||||
try {
|
||||
const llmRes = await fetch(`${LLM_URL}/api/v1/chat/completions`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
messages,
|
||||
model: model || 'gemma3:4b',
|
||||
temperature: temperature || 0.7,
|
||||
max_tokens: maxTokens || 2000,
|
||||
}),
|
||||
});
|
||||
|
||||
if (!llmRes.ok) return c.json({ error: 'LLM request failed' }, 502);
|
||||
|
||||
const data = await llmRes.json();
|
||||
await consumeCredits(userId, 'AI_CHAT', cost, `Chat: ${model || 'gemma3:4b'}`);
|
||||
|
||||
return c.json(data);
|
||||
} catch (_err) {
|
||||
return c.json({ error: 'Chat completion failed' }, 500);
|
||||
}
|
||||
});
|
||||
|
||||
// ─── Chat Completion (streaming SSE) ─────────────────────────
|
||||
|
||||
app.post('/api/v1/chat/completions/stream', async (c) => {
|
||||
const userId = c.get('userId');
|
||||
const { messages, model, temperature, maxTokens } = await c.req.json();
|
||||
|
||||
if (!messages?.length) return c.json({ error: 'messages required' }, 400);
|
||||
|
||||
const isLocal = !model || model.startsWith('ollama/') || model.startsWith('local/');
|
||||
const cost = isLocal ? 0.1 : 5;
|
||||
|
||||
const validation = await validateCredits(userId, 'AI_CHAT', cost);
|
||||
if (!validation.hasCredits) {
|
||||
return c.json({ error: 'Insufficient credits' }, 402);
|
||||
}
|
||||
|
||||
return streamSSE(c, async (stream) => {
|
||||
try {
|
||||
const llmRes = await fetch(`${LLM_URL}/api/v1/chat/completions`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
messages,
|
||||
model: model || 'gemma3:4b',
|
||||
temperature: temperature || 0.7,
|
||||
max_tokens: maxTokens || 2000,
|
||||
stream: true,
|
||||
}),
|
||||
});
|
||||
|
||||
if (!llmRes.ok || !llmRes.body) {
|
||||
await stream.writeSSE({ data: JSON.stringify({ error: 'LLM failed' }) });
|
||||
return;
|
||||
}
|
||||
|
||||
const reader = llmRes.body.getReader();
|
||||
const decoder = new TextDecoder();
|
||||
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) break;
|
||||
const chunk = decoder.decode(value, { stream: true });
|
||||
// Forward SSE chunks directly
|
||||
for (const line of chunk.split('\n')) {
|
||||
if (line.startsWith('data: ')) {
|
||||
await stream.writeSSE({ data: line.slice(6) });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await stream.writeSSE({ data: '[DONE]' });
|
||||
consumeCredits(userId, 'AI_CHAT', cost, `Chat stream: ${model || 'gemma3:4b'}`).catch(() => {});
|
||||
} catch (_err) {
|
||||
await stream.writeSSE({ data: JSON.stringify({ error: 'Stream failed' }) });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Models List ─────────────────────────────────────────────
|
||||
|
||||
app.get('/api/v1/chat/models', async (c) => {
|
||||
try {
|
||||
const res = await fetch(`${LLM_URL}/api/v1/models`);
|
||||
if (res.ok) return c.json(await res.json());
|
||||
} catch {
|
||||
// Fallback
|
||||
}
|
||||
return c.json({ models: [] });
|
||||
});
|
||||
|
||||
export default { port: PORT, fetch: app.fetch };
|
||||
11
apps/chat/apps/server/tsconfig.json
Normal file
11
apps/chat/apps/server/tsconfig.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
|
|
@ -40,8 +40,7 @@
|
|||
"@manacore/local-store": "workspace:*",
|
||||
"@manacore/shared-branding": "workspace:*",
|
||||
"@manacore/shared-error-tracking": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:*",
|
||||
"@manacore/shared-feedback-ui": "workspace:*",
|
||||
"@manacore/feedback": "workspace:*",
|
||||
"@manacore/shared-i18n": "workspace:*",
|
||||
"@manacore/shared-help-types": "workspace:*",
|
||||
"@manacore/shared-help-ui": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* Feedback Service Instance for Chat Web App
|
||||
*/
|
||||
|
||||
import { createFeedbackService } from '@manacore/shared-feedback-service';
|
||||
import { createFeedbackService } from '@manacore/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
|
||||
// Use environment variable at runtime
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import { FeedbackPage } from '@manacore/shared-feedback-ui';
|
||||
import { FeedbackPage } from '@manacore/feedback';
|
||||
import { feedbackService } from '$lib/services/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -36,8 +36,7 @@
|
|||
"@manacore/local-store": "workspace:*",
|
||||
"@manacore/shared-branding": "workspace:*",
|
||||
"@manacore/shared-error-tracking": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:*",
|
||||
"@manacore/shared-feedback-ui": "workspace:*",
|
||||
"@manacore/feedback": "workspace:*",
|
||||
"@manacore/shared-help-types": "workspace:*",
|
||||
"@manacore/shared-help-ui": "workspace:*",
|
||||
"@manacore/shared-i18n": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts">
|
||||
import { browser } from '$app/environment';
|
||||
import { FeedbackPage } from '@manacore/shared-feedback-ui';
|
||||
import { createFeedbackService } from '@manacore/shared-feedback-service';
|
||||
import { FeedbackPage } from '@manacore/feedback';
|
||||
import { createFeedbackService } from '@manacore/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
import '$lib/i18n';
|
||||
|
||||
|
|
|
|||
|
|
@ -43,8 +43,7 @@
|
|||
"@manacore/shared-auth-ui": "workspace:*",
|
||||
"@manacore/shared-branding": "workspace:*",
|
||||
"@manacore/shared-error-tracking": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:*",
|
||||
"@manacore/shared-feedback-ui": "workspace:*",
|
||||
"@manacore/feedback": "workspace:*",
|
||||
"@manacore/shared-i18n": "workspace:*",
|
||||
"@manacore/shared-help-types": "workspace:*",
|
||||
"@manacore/shared-help-ui": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts">
|
||||
import { browser } from '$app/environment';
|
||||
import { FeedbackPage } from '@manacore/shared-feedback-ui';
|
||||
import { createFeedbackService } from '@manacore/shared-feedback-service';
|
||||
import { FeedbackPage } from '@manacore/feedback';
|
||||
import { createFeedbackService } from '@manacore/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
import '$lib/i18n';
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@
|
|||
"@manacore/shared-auth-ui": "workspace:*",
|
||||
"@manacore/shared-branding": "workspace:*",
|
||||
"@manacore/shared-error-tracking": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:*",
|
||||
"@manacore/shared-feedback-ui": "workspace:*",
|
||||
"@manacore/feedback": "workspace:*",
|
||||
"@manacore/shared-help-content": "workspace:*",
|
||||
"@manacore/shared-help-types": "workspace:*",
|
||||
"@manacore/shared-help-ui": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
|
||||
import { browser } from '$app/environment';
|
||||
import { createFeedbackService } from '@manacore/shared-feedback-service';
|
||||
import { createFeedbackService } from '@manacore/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
|
||||
// Get auth URL dynamically at runtime
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import { FeedbackPage } from '@manacore/shared-feedback-ui';
|
||||
import { FeedbackPage } from '@manacore/feedback';
|
||||
import { feedbackService } from '$lib/services/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -39,8 +39,7 @@
|
|||
"@manacore/local-store": "workspace:*",
|
||||
"@manacore/shared-branding": "workspace:*",
|
||||
"@manacore/shared-error-tracking": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:*",
|
||||
"@manacore/shared-feedback-ui": "workspace:*",
|
||||
"@manacore/feedback": "workspace:*",
|
||||
"@manacore/shared-i18n": "workspace:*",
|
||||
"@manacore/shared-help-types": "workspace:*",
|
||||
"@manacore/shared-help-ui": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts">
|
||||
import { browser } from '$app/environment';
|
||||
import { FeedbackPage } from '@manacore/shared-feedback-ui';
|
||||
import { createFeedbackService } from '@manacore/shared-feedback-service';
|
||||
import { FeedbackPage } from '@manacore/feedback';
|
||||
import { createFeedbackService } from '@manacore/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
import '$lib/i18n';
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@
|
|||
"@manacore/shared-auth-ui": "workspace:*",
|
||||
"@manacore/shared-landing-ui": "workspace:*",
|
||||
"@manacore/shared-profile-ui": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:*",
|
||||
"@manacore/shared-stores": "workspace:*",
|
||||
"@manacore/shared-subscription-ui": "workspace:*",
|
||||
"@manacore/shared-theme": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { browser } from '$app/environment';
|
||||
import { createFeedbackService } from '@manacore/shared-feedback-service';
|
||||
import { createFeedbackService } from '@manacore/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
|
||||
function getAuthUrl(): string {
|
||||
|
|
|
|||
|
|
@ -49,8 +49,7 @@
|
|||
"@manacore/shared-branding": "workspace:*",
|
||||
"@manacore/shared-config": "workspace:*",
|
||||
"@manacore/shared-error-tracking": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:*",
|
||||
"@manacore/shared-feedback-ui": "workspace:*",
|
||||
"@manacore/feedback": "workspace:*",
|
||||
"@manacore/shared-i18n": "workspace:*",
|
||||
"@manacore/shared-help-types": "workspace:*",
|
||||
"@manacore/shared-help-ui": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* Feedback Service Instance for ManaCore Web App
|
||||
*/
|
||||
|
||||
import { createFeedbackService } from '@manacore/shared-feedback-service';
|
||||
import { createFeedbackService } from '@manacore/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
import { getManaAuthUrl } from './config';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import { FeedbackPage } from '@manacore/shared-feedback-ui';
|
||||
import { FeedbackPage } from '@manacore/feedback';
|
||||
import { feedbackService } from '$lib/api/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -37,8 +37,7 @@
|
|||
"@manacore/shared-branding": "workspace:*",
|
||||
"@manacore/shared-config": "workspace:*",
|
||||
"@manacore/shared-error-tracking": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:*",
|
||||
"@manacore/shared-feedback-ui": "workspace:*",
|
||||
"@manacore/feedback": "workspace:*",
|
||||
"@manacore/shared-i18n": "workspace:*",
|
||||
"@manacore/shared-help-types": "workspace:*",
|
||||
"@manacore/shared-help-ui": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* Feedback Service Instance for ManaDeck Web App
|
||||
*/
|
||||
|
||||
import { createFeedbackService } from '@manacore/shared-feedback-service';
|
||||
import { createFeedbackService } from '@manacore/feedback';
|
||||
import { authService } from '$lib/auth';
|
||||
import { PUBLIC_MANA_CORE_AUTH_URL } from '$env/static/public';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import { FeedbackPage } from '@manacore/shared-feedback-ui';
|
||||
import { FeedbackPage } from '@manacore/feedback';
|
||||
import { feedbackService } from '$lib/api/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@
|
|||
"@manacore/shared-auth": "workspace:*",
|
||||
"@manacore/shared-branding": "workspace:*",
|
||||
"@manacore/shared-error-tracking": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:*",
|
||||
"@manacore/shared-feedback-ui": "workspace:*",
|
||||
"@manacore/feedback": "workspace:*",
|
||||
"@manacore/shared-help-types": "workspace:*",
|
||||
"@manacore/shared-help-ui": "workspace:*",
|
||||
"@manacore/shared-i18n": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts">
|
||||
import { browser } from '$app/environment';
|
||||
import { FeedbackPage } from '@manacore/shared-feedback-ui';
|
||||
import { createFeedbackService } from '@manacore/shared-feedback-service';
|
||||
import { FeedbackPage } from '@manacore/feedback';
|
||||
import { createFeedbackService } from '@manacore/feedback';
|
||||
import { matrixStore } from '$lib/matrix';
|
||||
|
||||
function getAuthUrl(): string {
|
||||
|
|
|
|||
18
apps/mukke/apps/server/package.json
Normal file
18
apps/mukke/apps/server/package.json
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "@mukke/server",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "bun run --watch src/index.ts",
|
||||
"start": "bun run src/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@manacore/shared-hono": "workspace:*",
|
||||
"@manacore/shared-storage": "workspace:*",
|
||||
"hono": "^4.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
}
|
||||
110
apps/mukke/apps/server/src/index.ts
Normal file
110
apps/mukke/apps/server/src/index.ts
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
/**
|
||||
* Mukke Hono Server — Audio upload, metadata, presigned URLs
|
||||
*
|
||||
* CRUD for songs/playlists/projects handled by mana-sync.
|
||||
* This server handles S3 operations and metadata extraction.
|
||||
*/
|
||||
|
||||
import { Hono } from 'hono';
|
||||
import { cors } from 'hono/cors';
|
||||
import { authMiddleware, healthRoute, errorHandler, notFoundHandler } from '@manacore/shared-hono';
|
||||
|
||||
const PORT = parseInt(process.env.PORT || '3010', 10);
|
||||
const S3_ENDPOINT = process.env.S3_ENDPOINT || 'http://localhost:9000';
|
||||
const S3_BUCKET = process.env.S3_BUCKET || 'mukke-storage';
|
||||
const S3_ACCESS_KEY = process.env.S3_ACCESS_KEY || 'minioadmin';
|
||||
const S3_SECRET_KEY = process.env.S3_SECRET_KEY || 'minioadmin';
|
||||
const CORS_ORIGINS = (process.env.CORS_ORIGINS || 'http://localhost:5180').split(',');
|
||||
|
||||
const app = new Hono();
|
||||
|
||||
app.onError(errorHandler);
|
||||
app.notFound(notFoundHandler);
|
||||
app.use('*', cors({ origin: CORS_ORIGINS, credentials: true }));
|
||||
app.route('/health', healthRoute('mukke-server'));
|
||||
app.use('/api/*', authMiddleware());
|
||||
|
||||
// ─── Song Upload (server-only: S3 presigned URL) ────────────
|
||||
|
||||
app.post('/api/v1/songs/upload', async (c) => {
|
||||
const userId = c.get('userId');
|
||||
const { filename } = await c.req.json();
|
||||
|
||||
if (!filename) return c.json({ error: 'filename required' }, 400);
|
||||
|
||||
const songId = crypto.randomUUID();
|
||||
const key = `users/${userId}/songs/${songId}/${filename}`;
|
||||
|
||||
// Generate presigned upload URL
|
||||
try {
|
||||
const { createMukkeStorage, generateUserFileKey } = await import('@manacore/shared-storage');
|
||||
const storage = createMukkeStorage();
|
||||
const uploadUrl = await storage.getUploadUrl(key, { expiresIn: 3600 });
|
||||
|
||||
return c.json({
|
||||
song: { id: songId, title: filename.replace(/\.[^/.]+$/, ''), storagePath: key },
|
||||
uploadUrl,
|
||||
});
|
||||
} catch (_err) {
|
||||
return c.json({ error: 'Failed to generate upload URL' }, 500);
|
||||
}
|
||||
});
|
||||
|
||||
// ─── Download URL (server-only: S3 presigned URL) ────────────
|
||||
|
||||
app.get('/api/v1/songs/:id/download-url', async (c) => {
|
||||
const { storagePath } = c.req.query();
|
||||
if (!storagePath) return c.json({ error: 'storagePath required' }, 400);
|
||||
|
||||
try {
|
||||
const { createMukkeStorage } = await import('@manacore/shared-storage');
|
||||
const storage = createMukkeStorage();
|
||||
const url = await storage.getDownloadUrl(storagePath, { expiresIn: 3600 });
|
||||
return c.json({ url });
|
||||
} catch (_err) {
|
||||
return c.json({ error: 'Failed to generate download URL' }, 500);
|
||||
}
|
||||
});
|
||||
|
||||
// ─── Cover Art URL (server-only: S3 presigned URL) ───────────
|
||||
|
||||
app.get('/api/v1/songs/:id/cover-url', async (c) => {
|
||||
const { coverArtPath } = c.req.query();
|
||||
if (!coverArtPath) return c.json({ url: null });
|
||||
|
||||
try {
|
||||
const { createMukkeStorage } = await import('@manacore/shared-storage');
|
||||
const storage = createMukkeStorage();
|
||||
const url = await storage.getDownloadUrl(coverArtPath, { expiresIn: 3600 });
|
||||
return c.json({ url });
|
||||
} catch (_err) {
|
||||
return c.json({ url: null });
|
||||
}
|
||||
});
|
||||
|
||||
// ─── Batch Cover URLs ────────────────────────────────────────
|
||||
|
||||
app.post('/api/v1/library/cover-urls', async (c) => {
|
||||
const { paths } = await c.req.json();
|
||||
if (!paths?.length) return c.json({ urls: {} });
|
||||
|
||||
try {
|
||||
const { createMukkeStorage } = await import('@manacore/shared-storage');
|
||||
const storage = createMukkeStorage();
|
||||
const urls: Record<string, string> = {};
|
||||
|
||||
for (const path of paths.slice(0, 50)) {
|
||||
try {
|
||||
urls[path] = await storage.getDownloadUrl(path, { expiresIn: 3600 });
|
||||
} catch {
|
||||
// Skip failed URLs
|
||||
}
|
||||
}
|
||||
|
||||
return c.json({ urls });
|
||||
} catch (_err) {
|
||||
return c.json({ urls: {} });
|
||||
}
|
||||
});
|
||||
|
||||
export default { port: PORT, fetch: app.fetch };
|
||||
11
apps/mukke/apps/server/tsconfig.json
Normal file
11
apps/mukke/apps/server/tsconfig.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
|
|
@ -42,8 +42,7 @@
|
|||
"@manacore/local-store": "workspace:*",
|
||||
"@manacore/shared-branding": "workspace:*",
|
||||
"@manacore/shared-error-tracking": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:^",
|
||||
"@manacore/shared-feedback-ui": "workspace:^",
|
||||
"@manacore/feedback": "workspace:^",
|
||||
"@manacore/shared-i18n": "workspace:*",
|
||||
"@manacore/shared-help-types": "workspace:*",
|
||||
"@manacore/shared-help-ui": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { browser } from '$app/environment';
|
||||
import { createFeedbackService } from '@manacore/shared-feedback-service';
|
||||
import { createFeedbackService } from '@manacore/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
|
||||
function getAuthUrl(): string {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import { FeedbackPage } from '@manacore/shared-feedback-ui';
|
||||
import { FeedbackPage } from '@manacore/feedback';
|
||||
import { feedbackService } from '$lib/services/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -44,8 +44,7 @@
|
|||
"@manacore/shared-auth-ui": "workspace:*",
|
||||
"@manacore/shared-branding": "workspace:*",
|
||||
"@manacore/shared-error-tracking": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:*",
|
||||
"@manacore/shared-feedback-ui": "workspace:*",
|
||||
"@manacore/feedback": "workspace:*",
|
||||
"@manacore/shared-i18n": "workspace:*",
|
||||
"@manacore/shared-help-types": "workspace:*",
|
||||
"@manacore/shared-help-ui": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -36,8 +36,7 @@
|
|||
"@manacore/local-store": "workspace:*",
|
||||
"@manacore/shared-branding": "workspace:*",
|
||||
"@manacore/shared-error-tracking": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:*",
|
||||
"@manacore/shared-feedback-ui": "workspace:*",
|
||||
"@manacore/feedback": "workspace:*",
|
||||
"@manacore/shared-help-content": "workspace:*",
|
||||
"@manacore/shared-help-types": "workspace:*",
|
||||
"@manacore/shared-help-ui": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts">
|
||||
import { browser } from '$app/environment';
|
||||
import { FeedbackPage } from '@manacore/shared-feedback-ui';
|
||||
import { createFeedbackService } from '@manacore/shared-feedback-service';
|
||||
import { FeedbackPage } from '@manacore/feedback';
|
||||
import { createFeedbackService } from '@manacore/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
import '$lib/i18n';
|
||||
|
||||
|
|
|
|||
18
apps/picture/apps/server/package.json
Normal file
18
apps/picture/apps/server/package.json
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "@picture/server",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "bun run --watch src/index.ts",
|
||||
"start": "bun run src/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@manacore/shared-hono": "workspace:*",
|
||||
"@manacore/shared-storage": "workspace:*",
|
||||
"hono": "^4.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
}
|
||||
144
apps/picture/apps/server/src/index.ts
Normal file
144
apps/picture/apps/server/src/index.ts
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
/**
|
||||
* Picture Hono Server — AI image generation + upload
|
||||
*
|
||||
* CRUD for images/boards/boardItems handled by mana-sync.
|
||||
* This server handles Replicate API, S3 uploads, and explore.
|
||||
*/
|
||||
|
||||
import { Hono } from 'hono';
|
||||
import { cors } from 'hono/cors';
|
||||
import { authMiddleware, healthRoute, errorHandler, notFoundHandler } from '@manacore/shared-hono';
|
||||
import { consumeCredits, validateCredits } from '@manacore/shared-hono/credits';
|
||||
|
||||
const PORT = parseInt(process.env.PORT || '3006', 10);
|
||||
const REPLICATE_TOKEN = process.env.REPLICATE_API_TOKEN || '';
|
||||
const IMAGE_GEN_URL = process.env.MANA_IMAGE_GEN_URL || '';
|
||||
const CORS_ORIGINS = (process.env.CORS_ORIGINS || 'http://localhost:5173').split(',');
|
||||
|
||||
const app = new Hono();
|
||||
|
||||
app.onError(errorHandler);
|
||||
app.notFound(notFoundHandler);
|
||||
app.use('*', cors({ origin: CORS_ORIGINS, credentials: true }));
|
||||
app.route('/health', healthRoute('picture-server'));
|
||||
app.use('/api/*', authMiddleware());
|
||||
|
||||
// ─── AI Image Generation (server-only: Replicate/local) ─────
|
||||
|
||||
app.post('/api/v1/generate', async (c) => {
|
||||
const userId = c.get('userId');
|
||||
const { prompt, model, width, height, negativePrompt, steps, guidanceScale } = await c.req.json();
|
||||
|
||||
if (!prompt) return c.json({ error: 'prompt required' }, 400);
|
||||
|
||||
const cost = 10;
|
||||
const validation = await validateCredits(userId, 'AI_IMAGE_GENERATION', cost);
|
||||
if (!validation.hasCredits) {
|
||||
return c.json({ error: 'Insufficient credits', required: cost }, 402);
|
||||
}
|
||||
|
||||
try {
|
||||
let imageUrl: string;
|
||||
|
||||
if (model?.startsWith('local/') && IMAGE_GEN_URL) {
|
||||
// Local generation via mana-image-gen
|
||||
const res = await fetch(`${IMAGE_GEN_URL}/generate`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
prompt,
|
||||
negative_prompt: negativePrompt,
|
||||
width: width || 1024,
|
||||
height: height || 1024,
|
||||
steps: steps || 20,
|
||||
guidance_scale: guidanceScale || 7.5,
|
||||
}),
|
||||
});
|
||||
if (!res.ok) return c.json({ error: 'Local generation failed' }, 502);
|
||||
const data = await res.json();
|
||||
imageUrl = data.image_url || data.url;
|
||||
} else if (REPLICATE_TOKEN) {
|
||||
// Cloud generation via Replicate
|
||||
const res = await fetch('https://api.replicate.com/v1/predictions', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${REPLICATE_TOKEN}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
model: model || 'black-forest-labs/flux-schnell',
|
||||
input: {
|
||||
prompt,
|
||||
negative_prompt: negativePrompt,
|
||||
width: width || 1024,
|
||||
height: height || 1024,
|
||||
num_inference_steps: steps || 4,
|
||||
guidance_scale: guidanceScale || 0,
|
||||
},
|
||||
}),
|
||||
});
|
||||
if (!res.ok) return c.json({ error: 'Replicate API failed' }, 502);
|
||||
|
||||
const prediction = await res.json();
|
||||
|
||||
// Poll for completion
|
||||
let output = prediction.output;
|
||||
if (!output && prediction.urls?.get) {
|
||||
for (let i = 0; i < 60; i++) {
|
||||
await new Promise((r) => setTimeout(r, 2000));
|
||||
const pollRes = await fetch(prediction.urls.get, {
|
||||
headers: { Authorization: `Bearer ${REPLICATE_TOKEN}` },
|
||||
});
|
||||
const pollData = await pollRes.json();
|
||||
if (pollData.status === 'succeeded') {
|
||||
output = pollData.output;
|
||||
break;
|
||||
}
|
||||
if (pollData.status === 'failed') {
|
||||
return c.json({ error: 'Generation failed' }, 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
imageUrl = Array.isArray(output) ? output[0] : output;
|
||||
} else {
|
||||
return c.json({ error: 'No image generation service configured' }, 503);
|
||||
}
|
||||
|
||||
await consumeCredits(userId, 'AI_IMAGE_GENERATION', cost, `Image: ${prompt.slice(0, 50)}`);
|
||||
|
||||
return c.json({ imageUrl, prompt, model: model || 'flux-schnell' });
|
||||
} catch (_err) {
|
||||
return c.json({ error: 'Generation failed' }, 500);
|
||||
}
|
||||
});
|
||||
|
||||
// ─── Image Upload (server-only: S3) ─────────────────────────
|
||||
|
||||
app.post('/api/v1/upload', async (c) => {
|
||||
const userId = c.get('userId');
|
||||
const formData = await c.req.formData();
|
||||
const file = formData.get('file') as File | null;
|
||||
|
||||
if (!file) return c.json({ error: 'No file' }, 400);
|
||||
if (file.size > 10 * 1024 * 1024) return c.json({ error: 'Max 10MB' }, 400);
|
||||
|
||||
try {
|
||||
const { createPictureStorage, generateUserFileKey, getContentType } =
|
||||
await import('@manacore/shared-storage');
|
||||
const storage = createPictureStorage();
|
||||
const key = generateUserFileKey(userId, file.name);
|
||||
const buffer = Buffer.from(await file.arrayBuffer());
|
||||
|
||||
const result = await storage.upload(key, buffer, {
|
||||
contentType: getContentType(file.name),
|
||||
public: true,
|
||||
});
|
||||
|
||||
return c.json({ storagePath: key, publicUrl: result.url }, 201);
|
||||
} catch (_err) {
|
||||
return c.json({ error: 'Upload failed' }, 500);
|
||||
}
|
||||
});
|
||||
|
||||
export default { port: PORT, fetch: app.fetch };
|
||||
11
apps/picture/apps/server/tsconfig.json
Normal file
11
apps/picture/apps/server/tsconfig.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
|
|
@ -22,8 +22,7 @@
|
|||
"@manacore/shared-auth-ui": "workspace:*",
|
||||
"@manacore/shared-branding": "workspace:*",
|
||||
"@manacore/shared-error-tracking": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:*",
|
||||
"@manacore/shared-feedback-ui": "workspace:*",
|
||||
"@manacore/feedback": "workspace:*",
|
||||
"@manacore/shared-i18n": "workspace:*",
|
||||
"@manacore/shared-help-types": "workspace:*",
|
||||
"@manacore/shared-help-ui": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* Feedback Service Instance for Picture Web App
|
||||
*/
|
||||
|
||||
import { createFeedbackService } from '@manacore/shared-feedback-service';
|
||||
import { createFeedbackService } from '@manacore/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
import { env } from '$env/dynamic/public';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import { FeedbackPage } from '@manacore/shared-feedback-ui';
|
||||
import { FeedbackPage } from '@manacore/feedback';
|
||||
import { feedbackService } from '$lib/api/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -36,8 +36,7 @@
|
|||
"@manacore/shared-branding": "workspace:*",
|
||||
"@manacore/shared-error-tracking": "workspace:*",
|
||||
"@manacore/shared-i18n": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:*",
|
||||
"@manacore/shared-feedback-ui": "workspace:*",
|
||||
"@manacore/feedback": "workspace:*",
|
||||
"@manacore/shared-help-types": "workspace:*",
|
||||
"@manacore/shared-help-ui": "workspace:*",
|
||||
"@manacore/shared-icons": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts">
|
||||
import { browser } from '$app/environment';
|
||||
import { FeedbackPage } from '@manacore/shared-feedback-ui';
|
||||
import { createFeedbackService } from '@manacore/shared-feedback-service';
|
||||
import { FeedbackPage } from '@manacore/feedback';
|
||||
import { createFeedbackService } from '@manacore/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
import '$lib/i18n';
|
||||
|
||||
|
|
|
|||
|
|
@ -36,8 +36,7 @@
|
|||
"@manacore/shared-auth-ui": "workspace:*",
|
||||
"@manacore/shared-branding": "workspace:*",
|
||||
"@manacore/shared-error-tracking": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:*",
|
||||
"@manacore/shared-feedback-ui": "workspace:*",
|
||||
"@manacore/feedback": "workspace:*",
|
||||
"@manacore/shared-i18n": "workspace:*",
|
||||
"@manacore/shared-help-types": "workspace:*",
|
||||
"@manacore/shared-help-ui": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* Feedback Service Instance for Presi Web App
|
||||
*/
|
||||
|
||||
import { createFeedbackService } from '@manacore/shared-feedback-service';
|
||||
import { createFeedbackService } from '@manacore/feedback';
|
||||
import { auth } from '$lib/stores/auth.svelte';
|
||||
import { PUBLIC_MANA_CORE_AUTH_URL } from '$env/static/public';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import { FeedbackPage } from '@manacore/shared-feedback-ui';
|
||||
import { FeedbackPage } from '@manacore/feedback';
|
||||
import { feedbackService } from '$lib/api/feedback';
|
||||
import { auth } from '$lib/stores/auth.svelte';
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@
|
|||
"@manacore/shared-branding": "workspace:*",
|
||||
"@manacore/shared-error-tracking": "workspace:*",
|
||||
"@manacore/shared-i18n": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:*",
|
||||
"@manacore/shared-feedback-ui": "workspace:*",
|
||||
"@manacore/feedback": "workspace:*",
|
||||
"@manacore/shared-help-types": "workspace:*",
|
||||
"@manacore/shared-help-ui": "workspace:*",
|
||||
"@manacore/shared-icons": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts">
|
||||
import { browser } from '$app/environment';
|
||||
import { FeedbackPage } from '@manacore/shared-feedback-ui';
|
||||
import { createFeedbackService } from '@manacore/shared-feedback-service';
|
||||
import { FeedbackPage } from '@manacore/feedback';
|
||||
import { createFeedbackService } from '@manacore/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
import '$lib/i18n';
|
||||
|
||||
|
|
|
|||
|
|
@ -43,8 +43,7 @@
|
|||
"@manacore/shared-auth-ui": "workspace:*",
|
||||
"@manacore/shared-branding": "workspace:*",
|
||||
"@manacore/shared-error-tracking": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:*",
|
||||
"@manacore/shared-feedback-ui": "workspace:*",
|
||||
"@manacore/feedback": "workspace:*",
|
||||
"@manacore/shared-i18n": "workspace:*",
|
||||
"@manacore/shared-help-types": "workspace:*",
|
||||
"@manacore/shared-help-ui": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -46,8 +46,7 @@
|
|||
"@manacore/shared-auth-ui": "workspace:*",
|
||||
"@manacore/shared-branding": "workspace:*",
|
||||
"@manacore/shared-error-tracking": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:*",
|
||||
"@manacore/shared-feedback-ui": "workspace:*",
|
||||
"@manacore/feedback": "workspace:*",
|
||||
"@manacore/shared-i18n": "workspace:*",
|
||||
"@manacore/shared-help-types": "workspace:*",
|
||||
"@manacore/shared-help-ui": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
|
||||
import { browser } from '$app/environment';
|
||||
import { createFeedbackService } from '@manacore/shared-feedback-service';
|
||||
import { createFeedbackService } from '@manacore/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
|
||||
// Get auth URL dynamically at runtime
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import { FeedbackPage } from '@manacore/shared-feedback-ui';
|
||||
import { FeedbackPage } from '@manacore/feedback';
|
||||
import { feedbackService } from '$lib/services/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -38,8 +38,7 @@
|
|||
"@manacore/shared-auth-ui": "workspace:*",
|
||||
"@manacore/shared-branding": "workspace:*",
|
||||
"@manacore/shared-error-tracking": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:*",
|
||||
"@manacore/shared-feedback-ui": "workspace:*",
|
||||
"@manacore/feedback": "workspace:*",
|
||||
"@manacore/shared-i18n": "workspace:*",
|
||||
"@manacore/shared-help-types": "workspace:*",
|
||||
"@manacore/shared-help-ui": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts">
|
||||
import { _ } from 'svelte-i18n';
|
||||
import { FeedbackPage } from '@manacore/shared-feedback-ui';
|
||||
import { createFeedbackService } from '@manacore/shared-feedback-service';
|
||||
import { FeedbackPage } from '@manacore/feedback';
|
||||
import { createFeedbackService } from '@manacore/feedback';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
|
||||
const feedbackService = createFeedbackService({
|
||||
|
|
|
|||
28
packages/feedback/package.json
Normal file
28
packages/feedback/package.json
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"name": "@manacore/feedback",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "Unified feedback package — types, service, and UI components",
|
||||
"type": "module",
|
||||
"svelte": "./src/index.ts",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"svelte": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"default": "./src/index.ts"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"type-check": "svelte-check --tsconfig ./tsconfig.json"
|
||||
},
|
||||
"devDependencies": {
|
||||
"svelte": "^5.0.0",
|
||||
"svelte-check": "^4.0.0",
|
||||
"typescript": "^5.9.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"svelte": "^5.0.0"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import type { Feedback } from '@manacore/shared-feedback-types';
|
||||
import type { Feedback } from './feedback';
|
||||
import StatusBadge from './StatusBadge.svelte';
|
||||
import VoteButton from './VoteButton.svelte';
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import type { CreateFeedbackInput } from '@manacore/shared-feedback-types';
|
||||
import type { CreateFeedbackInput } from './feedback';
|
||||
|
||||
interface Props {
|
||||
onSubmit: (input: CreateFeedbackInput) => Promise<void>;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import type { Feedback } from '@manacore/shared-feedback-types';
|
||||
import type { Feedback } from './feedback';
|
||||
import FeedbackCard from './FeedbackCard.svelte';
|
||||
|
||||
interface Props {
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
FeedbackService,
|
||||
Feedback,
|
||||
CreateFeedbackInput,
|
||||
} from '@manacore/shared-feedback-service';
|
||||
} from './createFeedbackService';
|
||||
import FeedbackForm from './FeedbackForm.svelte';
|
||||
import FeedbackList from './FeedbackList.svelte';
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts">
|
||||
import type { FeedbackStatus } from '@manacore/shared-feedback-types';
|
||||
import { FEEDBACK_STATUS_CONFIG } from '@manacore/shared-feedback-types';
|
||||
import type { FeedbackStatus } from './feedback';
|
||||
import { FEEDBACK_STATUS_CONFIG } from './feedback';
|
||||
|
||||
interface Props {
|
||||
status: FeedbackStatus;
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { createFeedbackService } from '@manacore/shared-feedback-service';
|
||||
* import { createFeedbackService } from '@manacore/feedback';
|
||||
* import { authStore } from '$lib/stores/auth.svelte';
|
||||
*
|
||||
* export const feedbackService = createFeedbackService({
|
||||
|
|
@ -23,7 +23,7 @@ import type {
|
|||
FeedbackResponse,
|
||||
FeedbackListResponse,
|
||||
VoteResponse,
|
||||
} from '@manacore/shared-feedback-types';
|
||||
} from './feedback';
|
||||
import type { FeedbackServiceConfig } from './types';
|
||||
|
||||
/**
|
||||
36
packages/feedback/src/index.ts
Normal file
36
packages/feedback/src/index.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* @manacore/feedback — Unified feedback package
|
||||
*
|
||||
* Consolidates shared-feedback-types + shared-feedback-service + shared-feedback-ui
|
||||
* into a single package.
|
||||
*/
|
||||
|
||||
// Types
|
||||
export {
|
||||
type FeedbackCategory,
|
||||
type FeedbackStatus,
|
||||
type Feedback,
|
||||
type FeedbackVote,
|
||||
FEEDBACK_CATEGORY_LABELS,
|
||||
FEEDBACK_STATUS_CONFIG,
|
||||
} from './feedback';
|
||||
|
||||
export {
|
||||
type CreateFeedbackInput,
|
||||
type FeedbackQueryParams,
|
||||
type FeedbackResponse,
|
||||
type FeedbackListResponse,
|
||||
type VoteResponse,
|
||||
} from './api';
|
||||
|
||||
// Service
|
||||
export { createFeedbackService, type FeedbackService } from './createFeedbackService';
|
||||
export type { FeedbackServiceConfig } from './types';
|
||||
|
||||
// UI Components
|
||||
export { default as FeedbackPage } from './FeedbackPage.svelte';
|
||||
export { default as FeedbackForm } from './FeedbackForm.svelte';
|
||||
export { default as FeedbackList } from './FeedbackList.svelte';
|
||||
export { default as FeedbackCard } from './FeedbackCard.svelte';
|
||||
export { default as VoteButton } from './VoteButton.svelte';
|
||||
export { default as StatusBadge } from './StatusBadge.svelte';
|
||||
13
packages/feedback/tsconfig.json
Normal file
13
packages/feedback/tsconfig.json
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "bundler",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"outDir": "dist",
|
||||
"declaration": true
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.svelte"]
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
{
|
||||
"name": "@manacore/shared-feedback-service",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./src/index.ts",
|
||||
"default": "./src/index.ts"
|
||||
}
|
||||
},
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"scripts": {
|
||||
"type-check": "tsc --noEmit",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"dependencies": {
|
||||
"@manacore/shared-feedback-types": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.7.3"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
/**
|
||||
* Shared feedback service for Manacore monorepo
|
||||
*
|
||||
* This package provides a factory function to create feedback service
|
||||
* instances that can be used across all web and mobile apps.
|
||||
*/
|
||||
|
||||
export { createFeedbackService, type FeedbackService } from './createFeedbackService';
|
||||
export type { FeedbackServiceConfig } from './types';
|
||||
|
||||
// Re-export types from shared-feedback-types for convenience
|
||||
export type {
|
||||
Feedback,
|
||||
FeedbackCategory,
|
||||
FeedbackStatus,
|
||||
FeedbackVote,
|
||||
CreateFeedbackInput,
|
||||
FeedbackQueryParams,
|
||||
FeedbackResponse,
|
||||
FeedbackListResponse,
|
||||
VoteResponse,
|
||||
FEEDBACK_CATEGORY_LABELS,
|
||||
FEEDBACK_STATUS_CONFIG,
|
||||
} from '@manacore/shared-feedback-types';
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
/**
|
||||
* Configuration for creating a feedback service instance
|
||||
*/
|
||||
export interface FeedbackServiceConfig {
|
||||
/** Base API URL for the feedback endpoints */
|
||||
apiUrl: string;
|
||||
/** App identifier for multi-app support */
|
||||
appId: string;
|
||||
/** Function to get the current auth token */
|
||||
getAuthToken: () => Promise<string | null>;
|
||||
/** Optional custom endpoint prefix (default: '/api/v1/feedback') */
|
||||
feedbackEndpoint?: string;
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"lib": ["ES2022", "DOM"],
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"isolatedModules": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"name": "@manacore/shared-feedback-types",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"exports": {
|
||||
".": "./src/index.ts",
|
||||
"./feedback": "./src/feedback.ts",
|
||||
"./api": "./src/api.ts"
|
||||
},
|
||||
"scripts": {
|
||||
"type-check": "tsc --noEmit",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.7.3"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
/**
|
||||
* Shared feedback types for Manacore monorepo
|
||||
*
|
||||
* This package contains TypeScript types for feedback submissions,
|
||||
* voting, and API contracts.
|
||||
*/
|
||||
|
||||
// Feedback types
|
||||
export {
|
||||
type FeedbackCategory,
|
||||
type FeedbackStatus,
|
||||
type Feedback,
|
||||
type FeedbackVote,
|
||||
FEEDBACK_CATEGORY_LABELS,
|
||||
FEEDBACK_STATUS_CONFIG,
|
||||
} from './feedback';
|
||||
|
||||
// API types
|
||||
export {
|
||||
type CreateFeedbackInput,
|
||||
type FeedbackQueryParams,
|
||||
type FeedbackResponse,
|
||||
type FeedbackListResponse,
|
||||
type VoteResponse,
|
||||
} from './api';
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"lib": ["ES2022"],
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"isolatedModules": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
{
|
||||
"name": "@manacore/shared-feedback-ui",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"svelte": "./src/index.ts",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"svelte": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"default": "./src/index.ts"
|
||||
},
|
||||
"./FeedbackPage.svelte": {
|
||||
"svelte": "./src/FeedbackPage.svelte",
|
||||
"default": "./src/FeedbackPage.svelte"
|
||||
},
|
||||
"./FeedbackForm.svelte": {
|
||||
"svelte": "./src/FeedbackForm.svelte",
|
||||
"default": "./src/FeedbackForm.svelte"
|
||||
},
|
||||
"./FeedbackList.svelte": {
|
||||
"svelte": "./src/FeedbackList.svelte",
|
||||
"default": "./src/FeedbackList.svelte"
|
||||
},
|
||||
"./FeedbackCard.svelte": {
|
||||
"svelte": "./src/FeedbackCard.svelte",
|
||||
"default": "./src/FeedbackCard.svelte"
|
||||
},
|
||||
"./VoteButton.svelte": {
|
||||
"svelte": "./src/VoteButton.svelte",
|
||||
"default": "./src/VoteButton.svelte"
|
||||
},
|
||||
"./StatusBadge.svelte": {
|
||||
"svelte": "./src/StatusBadge.svelte",
|
||||
"default": "./src/StatusBadge.svelte"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"check": "svelte-check --tsconfig ./tsconfig.json",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"dependencies": {
|
||||
"@manacore/shared-feedback-types": "workspace:*",
|
||||
"@manacore/shared-feedback-service": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"svelte": "^5.0.0",
|
||||
"svelte-check": "^4.0.0",
|
||||
"typescript": "^5.7.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"svelte": "^5.0.0"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
/**
|
||||
* Shared feedback UI components for Manacore monorepo
|
||||
*
|
||||
* This package provides Svelte 5 components for feedback functionality
|
||||
* that can be used across all web apps.
|
||||
*/
|
||||
|
||||
// Page components
|
||||
export { default as FeedbackPage } from './FeedbackPage.svelte';
|
||||
|
||||
// Form components
|
||||
export { default as FeedbackForm } from './FeedbackForm.svelte';
|
||||
|
||||
// List components
|
||||
export { default as FeedbackList } from './FeedbackList.svelte';
|
||||
export { default as FeedbackCard } from './FeedbackCard.svelte';
|
||||
|
||||
// Utility components
|
||||
export { default as VoteButton } from './VoteButton.svelte';
|
||||
export { default as StatusBadge } from './StatusBadge.svelte';
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue