Add 17 features: My Work view, card copy/numbering, calendar, bulk ops, custom fields, automations, webhooks, invites, import/export, and more
Features implemented across 6 batches: - Batch A: Fix ColorPicker gradient sync, tenant custom logo, unarchive cards, board backgrounds - Batch B: My Work view, card copy/duplicate, card numbering (BOARD-123) - Batch C: Due date reminders (cron), card watching with notifications - Batch D: Bulk card operations, column sorting, calendar view - Batch E: Invite by link, board import/export (Pounce + Trello JSON) - Batch F: Webhooks with HMAC signing, custom fields, automation rules engine Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { json, error } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types.js';
|
||||
import { withTenant } from '$lib/server/rls.js';
|
||||
import { requireTenantAdmin } from '$lib/server/guards.js';
|
||||
import crypto from 'crypto';
|
||||
|
||||
// List all invites for the current tenant
|
||||
export const GET: RequestHandler = async ({ locals }) => {
|
||||
const tenant = locals.tenant;
|
||||
if (!tenant) throw error(400, 'Unknown tenant');
|
||||
requireTenantAdmin(locals.user);
|
||||
|
||||
const invites = await withTenant(tenant.id, async (tx) => {
|
||||
return tx.tenantInvite.findMany({
|
||||
where: { tenantId: tenant.id },
|
||||
orderBy: { expiresAt: 'desc' }
|
||||
});
|
||||
});
|
||||
|
||||
return json({ invites });
|
||||
};
|
||||
|
||||
// Create a new invite
|
||||
export const POST: RequestHandler = async ({ locals, request }) => {
|
||||
const tenant = locals.tenant;
|
||||
if (!tenant) throw error(400, 'Unknown tenant');
|
||||
requireTenantAdmin(locals.user);
|
||||
|
||||
const body = await request.json().catch(() => ({}));
|
||||
const role = body.role === 'ADMIN' ? 'ADMIN' : 'MEMBER';
|
||||
const maxUses = typeof body.maxUses === 'number' && body.maxUses > 0 ? body.maxUses : null;
|
||||
const expiresInDays = typeof body.expiresInDays === 'number' && body.expiresInDays > 0 ? body.expiresInDays : 7;
|
||||
|
||||
const code = crypto.randomBytes(9).toString('base64url');
|
||||
const expiresAt = new Date(Date.now() + expiresInDays * 24 * 60 * 60 * 1000);
|
||||
|
||||
const invite = await withTenant(tenant.id, async (tx) => {
|
||||
return tx.tenantInvite.create({
|
||||
data: {
|
||||
tenantId: tenant.id,
|
||||
code,
|
||||
role,
|
||||
expiresAt,
|
||||
createdBy: locals.user!.id,
|
||||
maxUses
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return json({ invite }, { status: 201 });
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
import { json, error } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types.js';
|
||||
import { withTenant } from '$lib/server/rls.js';
|
||||
import { requireTenantAdmin } from '$lib/server/guards.js';
|
||||
|
||||
// Delete an invite
|
||||
export const DELETE: RequestHandler = async ({ params, locals }) => {
|
||||
const tenant = locals.tenant;
|
||||
if (!tenant) throw error(400, 'Unknown tenant');
|
||||
requireTenantAdmin(locals.user);
|
||||
|
||||
await withTenant(tenant.id, async (tx) => {
|
||||
const invite = await tx.tenantInvite.findFirst({
|
||||
where: { id: params.inviteId, tenantId: tenant.id }
|
||||
});
|
||||
if (!invite) throw error(404, 'Invite not found');
|
||||
|
||||
await tx.tenantInvite.delete({
|
||||
where: { id: params.inviteId }
|
||||
});
|
||||
});
|
||||
|
||||
return json({ success: true });
|
||||
};
|
||||
Reference in New Issue
Block a user