Docker Compose with 24+ services: - PostgreSQL (PostGIS), Valkey, MinIO, Qdrant - Vault (PKI/TLS), Nginx (Reverse Proxy) - Backend Core API, Consent Service, Billing Service - RAG Service, Embedding Service - Gitea, Woodpecker CI/CD - Night Scheduler, Health Aggregator - Jitsi (Web/XMPP/JVB/Jicofo), Mailpit Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
391 lines
12 KiB
TypeScript
391 lines
12 KiB
TypeScript
/**
|
|
* Consent SDK Types
|
|
*
|
|
* DSGVO/TTDSG-konforme Typdefinitionen für das Consent Management System.
|
|
*/
|
|
/**
|
|
* Standard-Consent-Kategorien nach IAB TCF 2.2
|
|
*/
|
|
type ConsentCategory = 'essential' | 'functional' | 'analytics' | 'marketing' | 'social';
|
|
/**
|
|
* Consent-Status pro Kategorie
|
|
*/
|
|
type ConsentCategories = Record<ConsentCategory, boolean>;
|
|
/**
|
|
* Consent-Status pro Vendor
|
|
*/
|
|
type ConsentVendors = Record<string, boolean>;
|
|
/**
|
|
* Aktueller Consent-Zustand
|
|
*/
|
|
interface ConsentState {
|
|
/** Consent pro Kategorie */
|
|
categories: ConsentCategories;
|
|
/** Consent pro Vendor (optional, für granulare Kontrolle) */
|
|
vendors: ConsentVendors;
|
|
/** Zeitstempel der letzten Aenderung */
|
|
timestamp: string;
|
|
/** SDK-Version bei Erstellung */
|
|
version: string;
|
|
/** Eindeutige Consent-ID vom Backend */
|
|
consentId?: string;
|
|
/** Ablaufdatum */
|
|
expiresAt?: string;
|
|
/** IAB TCF String (falls aktiviert) */
|
|
tcfString?: string;
|
|
}
|
|
/**
|
|
* UI-Position des Banners
|
|
*/
|
|
type BannerPosition = 'bottom' | 'top' | 'center';
|
|
/**
|
|
* Banner-Layout
|
|
*/
|
|
type BannerLayout = 'bar' | 'modal' | 'floating';
|
|
/**
|
|
* Farbschema
|
|
*/
|
|
type BannerTheme = 'light' | 'dark' | 'auto';
|
|
/**
|
|
* UI-Konfiguration
|
|
*/
|
|
interface ConsentUIConfig {
|
|
/** Position des Banners */
|
|
position?: BannerPosition;
|
|
/** Layout-Typ */
|
|
layout?: BannerLayout;
|
|
/** Farbschema */
|
|
theme?: BannerTheme;
|
|
/** Pfad zu Custom CSS */
|
|
customCss?: string;
|
|
/** z-index fuer Banner */
|
|
zIndex?: number;
|
|
/** Scroll blockieren bei Modal */
|
|
blockScrollOnModal?: boolean;
|
|
/** Custom Container-ID */
|
|
containerId?: string;
|
|
}
|
|
/**
|
|
* Consent-Verhaltens-Konfiguration
|
|
*/
|
|
interface ConsentBehaviorConfig {
|
|
/** Muss Nutzer interagieren? */
|
|
required?: boolean;
|
|
/** "Alle ablehnen" Button sichtbar */
|
|
rejectAllVisible?: boolean;
|
|
/** "Alle akzeptieren" Button sichtbar */
|
|
acceptAllVisible?: boolean;
|
|
/** Einzelne Kategorien waehlbar */
|
|
granularControl?: boolean;
|
|
/** Einzelne Vendors waehlbar */
|
|
vendorControl?: boolean;
|
|
/** Auswahl speichern */
|
|
rememberChoice?: boolean;
|
|
/** Speicherdauer in Tagen */
|
|
rememberDays?: number;
|
|
/** Nur in EU anzeigen (Geo-Targeting) */
|
|
geoTargeting?: boolean;
|
|
/** Erneut nachfragen nach X Tagen */
|
|
recheckAfterDays?: number;
|
|
}
|
|
/**
|
|
* TCF 2.2 Konfiguration
|
|
*/
|
|
interface TCFConfig {
|
|
/** TCF aktivieren */
|
|
enabled?: boolean;
|
|
/** CMP ID */
|
|
cmpId?: number;
|
|
/** CMP Version */
|
|
cmpVersion?: number;
|
|
}
|
|
/**
|
|
* PWA-spezifische Konfiguration
|
|
*/
|
|
interface PWAConfig {
|
|
/** Offline-Unterstuetzung aktivieren */
|
|
offlineSupport?: boolean;
|
|
/** Bei Reconnect synchronisieren */
|
|
syncOnReconnect?: boolean;
|
|
/** Cache-Strategie */
|
|
cacheStrategy?: 'stale-while-revalidate' | 'network-first' | 'cache-first';
|
|
}
|
|
/**
|
|
* Haupt-Konfiguration fuer ConsentManager
|
|
*/
|
|
interface ConsentConfig {
|
|
/** API-Endpunkt fuer Consent-Backend */
|
|
apiEndpoint: string;
|
|
/** Site-ID */
|
|
siteId: string;
|
|
/** Sprache (ISO 639-1) */
|
|
language?: string;
|
|
/** Fallback-Sprache */
|
|
fallbackLanguage?: string;
|
|
/** UI-Konfiguration */
|
|
ui?: ConsentUIConfig;
|
|
/** Consent-Verhaltens-Konfiguration */
|
|
consent?: ConsentBehaviorConfig;
|
|
/** Aktive Kategorien */
|
|
categories?: ConsentCategory[];
|
|
/** TCF 2.2 Konfiguration */
|
|
tcf?: TCFConfig;
|
|
/** PWA-Konfiguration */
|
|
pwa?: PWAConfig;
|
|
/** Callback bei Consent-Aenderung */
|
|
onConsentChange?: (consent: ConsentState) => void;
|
|
/** Callback wenn Banner angezeigt wird */
|
|
onBannerShow?: () => void;
|
|
/** Callback wenn Banner geschlossen wird */
|
|
onBannerHide?: () => void;
|
|
/** Callback bei Fehler */
|
|
onError?: (error: Error) => void;
|
|
/** Debug-Modus aktivieren */
|
|
debug?: boolean;
|
|
}
|
|
|
|
/**
|
|
* Angular Integration fuer @breakpilot/consent-sdk
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* // app.module.ts
|
|
* import { ConsentModule } from '@breakpilot/consent-sdk/angular';
|
|
*
|
|
* @NgModule({
|
|
* imports: [
|
|
* ConsentModule.forRoot({
|
|
* apiEndpoint: 'https://consent.example.com/api/v1',
|
|
* siteId: 'site_abc123',
|
|
* }),
|
|
* ],
|
|
* })
|
|
* export class AppModule {}
|
|
* ```
|
|
*/
|
|
|
|
/**
|
|
* ConsentService Interface fuer Angular DI
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* @Component({...})
|
|
* export class MyComponent {
|
|
* constructor(private consent: ConsentService) {
|
|
* if (this.consent.hasConsent('analytics')) {
|
|
* // Analytics laden
|
|
* }
|
|
* }
|
|
* }
|
|
* ```
|
|
*/
|
|
interface IConsentService {
|
|
/** Initialisiert? */
|
|
readonly isInitialized: boolean;
|
|
/** Laedt noch? */
|
|
readonly isLoading: boolean;
|
|
/** Banner sichtbar? */
|
|
readonly isBannerVisible: boolean;
|
|
/** Aktueller Consent-Zustand */
|
|
readonly consent: ConsentState | null;
|
|
/** Muss Consent eingeholt werden? */
|
|
readonly needsConsent: boolean;
|
|
/** Prueft Consent fuer Kategorie */
|
|
hasConsent(category: ConsentCategory): boolean;
|
|
/** Alle akzeptieren */
|
|
acceptAll(): Promise<void>;
|
|
/** Alle ablehnen */
|
|
rejectAll(): Promise<void>;
|
|
/** Auswahl speichern */
|
|
saveSelection(categories: Partial<ConsentCategories>): Promise<void>;
|
|
/** Banner anzeigen */
|
|
showBanner(): void;
|
|
/** Banner ausblenden */
|
|
hideBanner(): void;
|
|
/** Einstellungen oeffnen */
|
|
showSettings(): void;
|
|
}
|
|
/**
|
|
* ConsentService - Angular Service Wrapper
|
|
*
|
|
* Diese Klasse kann als Angular Service registriert werden:
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* // consent.service.ts
|
|
* import { Injectable } from '@angular/core';
|
|
* import { ConsentServiceBase } from '@breakpilot/consent-sdk/angular';
|
|
*
|
|
* @Injectable({ providedIn: 'root' })
|
|
* export class ConsentService extends ConsentServiceBase {
|
|
* constructor() {
|
|
* super({
|
|
* apiEndpoint: environment.consentApiEndpoint,
|
|
* siteId: environment.siteId,
|
|
* });
|
|
* }
|
|
* }
|
|
* ```
|
|
*/
|
|
declare class ConsentServiceBase implements IConsentService {
|
|
private manager;
|
|
private _consent;
|
|
private _isInitialized;
|
|
private _isLoading;
|
|
private _isBannerVisible;
|
|
private changeCallbacks;
|
|
private bannerShowCallbacks;
|
|
private bannerHideCallbacks;
|
|
constructor(config: ConsentConfig);
|
|
get isInitialized(): boolean;
|
|
get isLoading(): boolean;
|
|
get isBannerVisible(): boolean;
|
|
get consent(): ConsentState | null;
|
|
get needsConsent(): boolean;
|
|
hasConsent(category: ConsentCategory): boolean;
|
|
acceptAll(): Promise<void>;
|
|
rejectAll(): Promise<void>;
|
|
saveSelection(categories: Partial<ConsentCategories>): Promise<void>;
|
|
showBanner(): void;
|
|
hideBanner(): void;
|
|
showSettings(): void;
|
|
/**
|
|
* Registriert Callback fuer Consent-Aenderungen
|
|
* (fuer Angular Change Detection)
|
|
*/
|
|
onConsentChange(callback: (consent: ConsentState) => void): () => void;
|
|
/**
|
|
* Registriert Callback wenn Banner angezeigt wird
|
|
*/
|
|
onBannerShow(callback: () => void): () => void;
|
|
/**
|
|
* Registriert Callback wenn Banner ausgeblendet wird
|
|
*/
|
|
onBannerHide(callback: () => void): () => void;
|
|
private setupEventListeners;
|
|
private initialize;
|
|
}
|
|
/**
|
|
* Konfiguration fuer ConsentModule.forRoot()
|
|
*/
|
|
interface ConsentModuleConfig extends ConsentConfig {
|
|
}
|
|
/**
|
|
* Token fuer Dependency Injection
|
|
* Verwendung mit Angular @Inject():
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* constructor(@Inject(CONSENT_CONFIG) private config: ConsentConfig) {}
|
|
* ```
|
|
*/
|
|
declare const CONSENT_CONFIG = "CONSENT_CONFIG";
|
|
declare const CONSENT_SERVICE = "CONSENT_SERVICE";
|
|
/**
|
|
* Factory fuer ConsentService
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* // app.module.ts
|
|
* providers: [
|
|
* { provide: CONSENT_CONFIG, useValue: { apiEndpoint: '...', siteId: '...' } },
|
|
* { provide: CONSENT_SERVICE, useFactory: consentServiceFactory, deps: [CONSENT_CONFIG] },
|
|
* ]
|
|
* ```
|
|
*/
|
|
declare function consentServiceFactory(config: ConsentConfig): ConsentServiceBase;
|
|
/**
|
|
* ConsentModule - Angular Module
|
|
*
|
|
* Dies ist eine Template-Definition. Fuer echte Angular-Nutzung
|
|
* muss ein separates Angular Library Package erstellt werden.
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* // In einem Angular Library Package:
|
|
* @NgModule({
|
|
* declarations: [ConsentBannerComponent, ConsentGateDirective],
|
|
* exports: [ConsentBannerComponent, ConsentGateDirective],
|
|
* })
|
|
* export class ConsentModule {
|
|
* static forRoot(config: ConsentModuleConfig): ModuleWithProviders<ConsentModule> {
|
|
* return {
|
|
* ngModule: ConsentModule,
|
|
* providers: [
|
|
* { provide: CONSENT_CONFIG, useValue: config },
|
|
* { provide: CONSENT_SERVICE, useFactory: consentServiceFactory, deps: [CONSENT_CONFIG] },
|
|
* ],
|
|
* };
|
|
* }
|
|
* }
|
|
* ```
|
|
*/
|
|
declare const ConsentModuleDefinition: {
|
|
/**
|
|
* Providers fuer Root-Module
|
|
*/
|
|
forRoot: (config: ConsentModuleConfig) => {
|
|
provide: string;
|
|
useValue: ConsentModuleConfig;
|
|
};
|
|
};
|
|
/**
|
|
* ConsentBannerComponent Template
|
|
*
|
|
* Fuer Angular Library Implementation:
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* @Component({
|
|
* selector: 'bp-consent-banner',
|
|
* template: CONSENT_BANNER_TEMPLATE,
|
|
* styles: [CONSENT_BANNER_STYLES],
|
|
* })
|
|
* export class ConsentBannerComponent {
|
|
* constructor(public consent: ConsentService) {}
|
|
* }
|
|
* ```
|
|
*/
|
|
declare const CONSENT_BANNER_TEMPLATE = "\n<div\n *ngIf=\"consent.isBannerVisible\"\n class=\"bp-consent-banner\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Cookie-Einstellungen\"\n>\n <div class=\"bp-consent-banner-content\">\n <h2>Datenschutzeinstellungen</h2>\n <p>\n Wir nutzen Cookies und \u00E4hnliche Technologien, um Ihnen ein optimales\n Nutzererlebnis zu bieten.\n </p>\n <div class=\"bp-consent-banner-actions\">\n <button\n type=\"button\"\n class=\"bp-consent-btn bp-consent-btn-reject\"\n (click)=\"consent.rejectAll()\"\n >\n Alle ablehnen\n </button>\n <button\n type=\"button\"\n class=\"bp-consent-btn bp-consent-btn-settings\"\n (click)=\"consent.showSettings()\"\n >\n Einstellungen\n </button>\n <button\n type=\"button\"\n class=\"bp-consent-btn bp-consent-btn-accept\"\n (click)=\"consent.acceptAll()\"\n >\n Alle akzeptieren\n </button>\n </div>\n </div>\n</div>\n";
|
|
/**
|
|
* ConsentGateDirective Template
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* @Directive({
|
|
* selector: '[bpConsentGate]',
|
|
* })
|
|
* export class ConsentGateDirective implements OnInit, OnDestroy {
|
|
* @Input('bpConsentGate') category!: ConsentCategory;
|
|
*
|
|
* private unsubscribe?: () => void;
|
|
*
|
|
* constructor(
|
|
* private templateRef: TemplateRef<any>,
|
|
* private viewContainer: ViewContainerRef,
|
|
* private consent: ConsentService
|
|
* ) {}
|
|
*
|
|
* ngOnInit() {
|
|
* this.updateView();
|
|
* this.unsubscribe = this.consent.onConsentChange(() => this.updateView());
|
|
* }
|
|
*
|
|
* ngOnDestroy() {
|
|
* this.unsubscribe?.();
|
|
* }
|
|
*
|
|
* private updateView() {
|
|
* if (this.consent.hasConsent(this.category)) {
|
|
* this.viewContainer.createEmbeddedView(this.templateRef);
|
|
* } else {
|
|
* this.viewContainer.clear();
|
|
* }
|
|
* }
|
|
* }
|
|
* ```
|
|
*/
|
|
declare const CONSENT_GATE_USAGE = "\n<!-- Verwendung in Templates -->\n<div *bpConsentGate=\"'analytics'\">\n <analytics-component></analytics-component>\n</div>\n\n<!-- Mit else Template -->\n<ng-container *bpConsentGate=\"'marketing'; else placeholder\">\n <marketing-component></marketing-component>\n</ng-container>\n<ng-template #placeholder>\n <p>Bitte akzeptieren Sie Marketing-Cookies.</p>\n</ng-template>\n";
|
|
|
|
export { CONSENT_BANNER_TEMPLATE, CONSENT_CONFIG, CONSENT_GATE_USAGE, CONSENT_SERVICE, type ConsentCategories, type ConsentCategory, type ConsentConfig, type ConsentModuleConfig, ConsentModuleDefinition, ConsentServiceBase, type ConsentState, type IConsentService, consentServiceFactory };
|