diff --git a/blog/mod.ts b/blog/mod.ts index f62f1b3..7b446f8 100644 --- a/blog/mod.ts +++ b/blog/mod.ts @@ -9,11 +9,19 @@ import type { AppDefinition, ResolveSecretFn } from "../commerce/app-types"; import manifest from "./manifest.gen"; // ------------------------------------------------------------------------- -// State +// CMS Props // ------------------------------------------------------------------------- -// biome-ignore lint/complexity/noBannedTypes: empty state placeholder for future use -export type BlogState = {}; +/** @title Deco Blog */ +export interface Props { + /** + * @title Page Slug + * @description The slug of the BlogPostPage to embed. Use :category and :slug. + */ + pageSlug?: string; +} + +export type BlogState = Props; // ------------------------------------------------------------------------- // Configure @@ -31,9 +39,14 @@ export async function configure( return { name: "blog", manifest, - state: {}, + state: { pageSlug: _block?.pageSlug }, }; } /** Placeholder preview for CMS editor. */ export const preview = undefined; + +/** Default export for schema generation and Deno-style app bridges. */ +export default function Blog(state: Props) { + return { state }; +} diff --git a/vtex/mod.ts b/vtex/mod.ts index b897f38..117a667 100644 --- a/vtex/mod.ts +++ b/vtex/mod.ts @@ -16,10 +16,73 @@ */ import type { AppDefinition, AppMiddleware, ResolveSecretFn } from "../commerce/app-types"; +import type { Secret } from "../website/mod"; import { configureVtex, type VtexConfig } from "./client"; import manifest from "./manifest.gen"; import { extractVtexContext, propagateISCookies, vtexCacheControl } from "./middleware"; +// ------------------------------------------------------------------------- +// CMS Props (mirrors deco-cx/apps/vtex/mod.ts) +// ------------------------------------------------------------------------- + +/** @title VTEX */ +export interface Props { + /** + * @description VTEX Account name + */ + account: string; + + /** + * @title Public store URL + * @description Domain registered on License Manager (e.g. secure.mystore.com.br) + */ + publicUrl: string; + + /** @title App Key */ + appKey?: Secret; + + /** + * @title App Token + * @format password + */ + appToken?: Secret; + + /** + * @title Default Sales Channel + * @deprecated + */ + salesChannel?: string; + + /** + * @title Set Refresh Token + * @default false + */ + setRefreshToken?: boolean; + + defaultSegment?: Record; + + usePortalSitemap?: boolean; + + /** + * @hide true + * @default vtex + */ + platform?: "vtex"; + + advancedConfigs?: { + doNotFetchVariantsForRelatedProducts?: boolean; + removeUTMFromCacheKey?: boolean; + }; + + /** @title Cached Search Terms */ + cachedSearchTerms?: { + terms?: unknown; + extraTerms?: string[]; + }; +} + +export type { Secret }; + // ------------------------------------------------------------------------- // State // ------------------------------------------------------------------------- @@ -49,6 +112,7 @@ const vtexMiddleware: AppMiddleware = async (request, next) => { * Returns an AppDefinition or null if required fields are missing. */ export async function configure( + // biome-ignore lint/suspicious/noExplicitAny: block data comes from CMS with no fixed schema block: any, resolveSecret: ResolveSecretFn, ): Promise | null> { @@ -81,3 +145,8 @@ export async function configure( /** Placeholder preview for CMS editor — evolves when admin supports it. */ export const preview = undefined; + +/** Default export for schema generation and Deno-style app bridges. */ +export default function VTEX(_props: Props) { + return { state: _props }; +} diff --git a/website/mod.ts b/website/mod.ts index 7bf2aa7..cef152e 100644 --- a/website/mod.ts +++ b/website/mod.ts @@ -7,9 +7,115 @@ import type { AppDefinition, ResolveSecretFn } from "../commerce/app-types"; import { configureWebsite } from "./client"; +import type { Props as SecretProps } from "./loaders/secret"; import manifest from "./manifest.gen"; import type { WebsiteConfig } from "./types"; +// ------------------------------------------------------------------------- +// CMS Props (mirrors deco-cx/apps/website/mod.ts) +// ------------------------------------------------------------------------- + +export type Script = { src: string }; + +export interface CacheDirectiveBase { + name: string; + value: number; +} + +export interface StaleWhileRevalidate extends CacheDirectiveBase { + name: "stale-while-revalidate"; +} + +export interface MaxAge extends CacheDirectiveBase { + name: "max-age"; +} + +export type CacheDirective = StaleWhileRevalidate | MaxAge; + +export interface Caching { + enabled?: boolean; + directives?: CacheDirective[]; +} + +export interface AbTesting { + enabled?: boolean; + /** @description The name of the A/B test — appears in cookies */ + name?: string; + matcher?: unknown; + /** @description URL to run the A/B test against */ + urlToRunAgainst?: string; + replaces?: unknown[]; + includeScriptsToHead?: { includes?: Script[] }; + includeScriptsToBody?: { includes?: Script[] }; +} + +/** @titleBy framework */ +export interface FreshFlavor { + /** @default fresh */ + framework: "fresh"; +} + +/** @titleBy framework */ +export interface HtmxFlavor { + /** @default htmx */ + framework: "htmx"; +} + +/** @title Website */ +export interface Props { + /** @title Routes Map */ + routes?: unknown[]; + + /** @title Global Sections */ + global?: unknown[]; + + /** @title Error Page */ + errorPage?: unknown; + + /** @title Caching configuration of pages */ + caching?: Caching; + + /** + * @title Global Async Rendering (Deprecated) + * @deprecated true + * @default false + */ + firstByteThresholdMS?: boolean; + + /** @title Avoid redirecting to editor */ + avoidRedirectingToEditor?: boolean; + + /** @title AB Testing */ + abTesting?: AbTesting; + + /** @title Flavor */ + flavor?: FreshFlavor | HtmxFlavor; + + /** @title Seo */ + seo?: Record; + + /** @title Theme */ + theme?: unknown; + + /** @hide true */ + sendToClickHouse?: boolean; + + /** @title Default Image Quality */ + defaultImageQuality?: string; + + /** @title Disable image/asset proxy for this site */ + disableProxy?: boolean; + + /** @title Whilelist URL Patterns */ + whilelistURLs?: string[]; +} + +/** Alias for site app bridges that extend website Props. */ +export type WebsiteProps = Props; + +/** Secret block shape in decofile (website/loaders/secret.ts). */ +export type Secret = SecretProps; + // ------------------------------------------------------------------------- // State // -------------------------------------------------------------------------