Files
template-app/modules/branding/module.convex.ts
T

33 lines
1.2 KiB
TypeScript

// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
// Convex-safe half of branding. Logo decoding and Blob access run in brandingActions.ts;
// database-only reads and writes stay in one Convex transaction through these handlers.
import { defineModule, implement } from "@conusai-kit/core"
import { DATA_SOURCE } from "@conusai-kit/data"
import { BRAND_CHANGED, brandGet, brandSet } from "./contract/index.js"
import { getBrand, setBrand } from "./core/brand-data.js"
import { en, lt } from "./i18n/index.js"
const brandGetImpl = implement(brandGet, async ({ ctx }) => getBrand(ctx.container.resolve(DATA_SOURCE), ctx.scope))
const brandSetImpl = implement(brandSet, async ({ input, ctx }) =>
setBrand(ctx.container.resolve(DATA_SOURCE), ctx.scope, {
displayName: input.displayName,
primary: input.primary,
accent: input.accent,
}),
)
export const convexBrandingModule = defineModule({
id: "branding",
version: "0.1.0",
kit: "^0.1.0",
requires: ["tenancy"],
permissions: {
"branding.brand.read": "viewer",
"branding.brand.write": "admin",
},
procedures: [brandGetImpl, brandSetImpl],
audit: [BRAND_CHANGED],
i18n: { en, lt },
})