Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions blog/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 };
}
69 changes: 69 additions & 0 deletions vtex/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown>;

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
// -------------------------------------------------------------------------
Expand Down Expand Up @@ -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<AppDefinition<VtexState> | null> {
Expand Down Expand Up @@ -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 };
}
106 changes: 106 additions & 0 deletions website/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown>;

/** @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
// -------------------------------------------------------------------------
Expand Down
Loading