Sprint 8: add widget manifest and data source engine
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Type } from '@angular/core';
|
||||
import { SectionConfig } from '../../shared/models/config';
|
||||
|
||||
export interface WidgetRenderContext {
|
||||
pageId: string;
|
||||
@@ -16,5 +17,6 @@ export interface ResolvedWidget {
|
||||
type: string;
|
||||
version: string;
|
||||
component: Type<unknown>;
|
||||
props: Record<string, unknown>;
|
||||
section: SectionConfig;
|
||||
data: unknown;
|
||||
}
|
||||
|
||||
48
src/app/widgets/contracts/widget-data.contract.ts
Normal file
48
src/app/widgets/contracts/widget-data.contract.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { Category } from '../../core/categories/models/category-domain.model';
|
||||
import { Product } from '../../core/products/models/product-domain.model';
|
||||
import { SectionConfig } from '../../shared/models/config';
|
||||
|
||||
export interface WidgetResolvedContext {
|
||||
section: SectionConfig;
|
||||
settings: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface HeroWidgetData extends WidgetResolvedContext {
|
||||
title: string;
|
||||
subtitle?: string;
|
||||
ctaLabel?: string;
|
||||
}
|
||||
|
||||
export interface CategoriesWidgetData extends WidgetResolvedContext {
|
||||
title: string;
|
||||
categories: Category[];
|
||||
emptyMessage?: string;
|
||||
}
|
||||
|
||||
export interface ProductCollectionWidgetData extends WidgetResolvedContext {
|
||||
title: string;
|
||||
products: Product[];
|
||||
actionLabel?: string;
|
||||
emptyMessage?: string;
|
||||
}
|
||||
|
||||
export interface BannerWidgetData extends WidgetResolvedContext {
|
||||
title?: string;
|
||||
subtitle?: string;
|
||||
imageUrl?: string;
|
||||
ctaLabel?: string;
|
||||
ctaHref?: string;
|
||||
}
|
||||
|
||||
export interface HtmlWidgetData extends WidgetResolvedContext {
|
||||
html: string;
|
||||
}
|
||||
|
||||
export interface PartnersWidgetData extends WidgetResolvedContext {
|
||||
title?: string;
|
||||
logos: Array<{ id: string; label: string; imageUrl: string; href?: string }>;
|
||||
}
|
||||
|
||||
export interface FooterWidgetData extends WidgetResolvedContext {
|
||||
links: Array<{ id: string; label: string; href: string }>;
|
||||
}
|
||||
24
src/app/widgets/contracts/widget-manifest.contract.ts
Normal file
24
src/app/widgets/contracts/widget-manifest.contract.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
export type WidgetLayoutSupport = 'stack' | 'grid' | 'hero' | 'carousel' | 'split';
|
||||
|
||||
export type WidgetDataSourceName = 'featured' | 'latest' | 'category' | 'manual' | 'related' | 'future' | 'root' | 'parent';
|
||||
|
||||
export interface WidgetSettingsSchema {
|
||||
type: 'object';
|
||||
properties: Record<string, unknown>;
|
||||
required?: string[];
|
||||
}
|
||||
|
||||
export interface WidgetManifestEntry {
|
||||
type: string;
|
||||
version: string;
|
||||
componentKey: string;
|
||||
supportedLayouts: WidgetLayoutSupport[];
|
||||
supportedDataSources: WidgetDataSourceName[];
|
||||
settingsSchema: WidgetSettingsSchema;
|
||||
defaultSettings: Record<string, unknown>;
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
export interface WidgetManifestFile {
|
||||
widgets: WidgetManifestEntry[];
|
||||
}
|
||||
Reference in New Issue
Block a user