@lynx-seo/engine 3.3.4 → 3.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,9 @@
11
11
  */
12
12
  import { z } from "zod";
13
13
  import { type TokenUsageRecord } from "./token-quota-manager";
14
- export type MatrixFamily = "local-geo" | "vs-comparison" | "alternative" | "pricing" | "review-platform" | "recipe" | "target" | "industry" | "persona" | "integration" | "use-case" | "template" | "glossary" | "calculator";
14
+ import { type CitabilityScoreResult } from "./geo-citability-scorer";
15
+ import { type HallucinationBaitResult } from "./geo-hallucination-bait";
16
+ export type MatrixFamily = "local-geo" | "vs-comparison" | "alternative" | "pricing" | "review-platform" | "recipe" | "target" | "industry" | "persona" | "integration" | "use-case" | "template" | "glossary" | "calculator" | "niche-report" | "top-products";
15
17
  export interface PseoService {
16
18
  slug: string;
17
19
  name: string;
@@ -144,6 +146,33 @@ export interface PseoRecipe {
144
146
  ratingValue?: number;
145
147
  reviewCount?: number;
146
148
  }
149
+ export interface PseoNicheProductItem {
150
+ title: string;
151
+ url?: string;
152
+ price: number;
153
+ currencySymbol?: string;
154
+ rating?: number;
155
+ reviewCount?: number;
156
+ estimatedSales?: number;
157
+ tags?: string[];
158
+ }
159
+ export interface PseoNicheReport {
160
+ slug: string;
161
+ nicheName: string;
162
+ marketplace: string;
163
+ category?: string;
164
+ averagePrice: number;
165
+ medianPrice?: number;
166
+ currencySymbol?: string;
167
+ competitionScore: number;
168
+ demandScore?: number;
169
+ topTags: string[];
170
+ topProducts?: PseoNicheProductItem[];
171
+ dataSourceName: string;
172
+ dataSourceUrl?: string;
173
+ lastVerifiedDate: string;
174
+ reportType?: "niche-report" | "top-products";
175
+ }
147
176
  export interface SchemaOrgGraph {
148
177
  "@context": "https://schema.org";
149
178
  "@graph": Record<string, unknown>[];
@@ -176,6 +205,7 @@ export interface GeneratedPageMeta {
176
205
  calculator?: PseoCalculator;
177
206
  reviewTarget?: PseoReviewTarget;
178
207
  recipe?: PseoRecipe;
208
+ nicheReport?: PseoNicheReport;
179
209
  }
180
210
  export interface MatrixOptions {
181
211
  brandName: string;
@@ -333,6 +363,45 @@ export declare const PseoRecipeSchema: z.ZodObject<{
333
363
  ratingValue: z.ZodOptional<z.ZodNumber>;
334
364
  reviewCount: z.ZodOptional<z.ZodNumber>;
335
365
  }, z.core.$strip>;
366
+ export declare const PseoNicheProductItemSchema: z.ZodObject<{
367
+ title: z.ZodString;
368
+ url: z.ZodOptional<z.ZodString>;
369
+ price: z.ZodNumber;
370
+ currencySymbol: z.ZodOptional<z.ZodString>;
371
+ rating: z.ZodOptional<z.ZodNumber>;
372
+ reviewCount: z.ZodOptional<z.ZodNumber>;
373
+ estimatedSales: z.ZodOptional<z.ZodNumber>;
374
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
375
+ }, z.core.$strip>;
376
+ export declare const PseoNicheReportSchema: z.ZodObject<{
377
+ slug: z.ZodString;
378
+ nicheName: z.ZodString;
379
+ marketplace: z.ZodString;
380
+ category: z.ZodOptional<z.ZodString>;
381
+ averagePrice: z.ZodNumber;
382
+ medianPrice: z.ZodOptional<z.ZodNumber>;
383
+ currencySymbol: z.ZodOptional<z.ZodString>;
384
+ competitionScore: z.ZodNumber;
385
+ demandScore: z.ZodOptional<z.ZodNumber>;
386
+ topTags: z.ZodDefault<z.ZodArray<z.ZodString>>;
387
+ topProducts: z.ZodOptional<z.ZodArray<z.ZodObject<{
388
+ title: z.ZodString;
389
+ url: z.ZodOptional<z.ZodString>;
390
+ price: z.ZodNumber;
391
+ currencySymbol: z.ZodOptional<z.ZodString>;
392
+ rating: z.ZodOptional<z.ZodNumber>;
393
+ reviewCount: z.ZodOptional<z.ZodNumber>;
394
+ estimatedSales: z.ZodOptional<z.ZodNumber>;
395
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
396
+ }, z.core.$strip>>>;
397
+ dataSourceName: z.ZodString;
398
+ dataSourceUrl: z.ZodOptional<z.ZodString>;
399
+ lastVerifiedDate: z.ZodString;
400
+ reportType: z.ZodOptional<z.ZodEnum<{
401
+ "niche-report": "niche-report";
402
+ "top-products": "top-products";
403
+ }>>;
404
+ }, z.core.$strip>;
336
405
  export declare const MatrixOptionsSchema: z.ZodObject<{
337
406
  brandName: z.ZodString;
338
407
  language: z.ZodDefault<z.ZodString>;
@@ -413,6 +482,28 @@ export declare class PseoMatrixEngine {
413
482
  * 10. Tools & Calculators Matrix (`/tools/{calculator}` in English default)
414
483
  */
415
484
  generateCalculatorMatrix(domain: string, calculators: PseoCalculator[], options: MatrixOptions): GeneratedPageMeta[];
485
+ /**
486
+ * 11. Data-Driven Niche & Top-Products Matrix (`/niches/{slug}` or `/best/{slug}`)
487
+ * Designed for marketplace intelligence (e.g. Etsy, Amazon KDP, Shopify) backed by verified metrics.
488
+ */
489
+ generateNicheReportMatrix(domain: string, reports: PseoNicheReport[], options: MatrixOptions): GeneratedPageMeta[];
490
+ /**
491
+ * Renders a zero-hallucination, data-driven Niche / Top-Products editorial report
492
+ * grounded in verified marketplace metrics (average price, competition score, tags, products).
493
+ */
494
+ renderNicheReportPage(report: PseoNicheReport, options?: {
495
+ brandName?: string;
496
+ language?: "fr" | "en";
497
+ }): {
498
+ title: string;
499
+ metaDescription: string;
500
+ markdown: string;
501
+ wordCount: number;
502
+ citabilityScore: CitabilityScoreResult;
503
+ hallucinationAudit: HallucinationBaitResult;
504
+ aiSummaryJson: Record<string, unknown>;
505
+ aiFaqJson: Record<string, unknown>;
506
+ };
416
507
  /**
417
508
  * Master Generator: Produces all programmatic families simultaneously.
418
509
  */
@@ -428,6 +519,7 @@ export declare class PseoMatrixEngine {
428
519
  glossaryTerms?: PseoGlossaryTerm[];
429
520
  calculators?: PseoCalculator[];
430
521
  recipes?: PseoRecipe[];
522
+ nicheReports?: PseoNicheReport[];
431
523
  }, options: MatrixOptions): GeneratedPageMeta[];
432
524
  /**
433
525
  * Resolves a single page route in RAM in < 0.05ms.
@@ -445,6 +537,7 @@ export declare class PseoMatrixEngine {
445
537
  glossaryTerms?: PseoGlossaryTerm[];
446
538
  calculators?: PseoCalculator[];
447
539
  recipes?: PseoRecipe[];
540
+ nicheReports?: PseoNicheReport[];
448
541
  }, options: MatrixOptions): GeneratedPageMeta | undefined;
449
542
  private doResolvePage;
450
543
  /**
@@ -469,21 +562,60 @@ export declare class PseoMatrixEngine {
469
562
  disallowPaths?: string[];
470
563
  }): string;
471
564
  /**
472
- * 🏆 RENDER DEEP EDITORIAL MASTER PAGE (1,500+ WORDS ANTI-THIN-CONTENT)
473
- * Assembles exhaustive, master-level editorial content combining direct answers,
474
- * market context, architectural breakdowns, comparative matrices, step-by-step guides,
475
- * localized economic statistics, and objection-handling FAQs.
565
+ * 🏆 RENDER DEEP EDITORIAL MASTER PAGE (ANTI-HALLUCINATION & HIGH GEO CITABILITY)
566
+ * Assembles structured editorial content combining Answer-First summaries,
567
+ * factual comparative tables, sourced statistics, step-by-step deployment,
568
+ * authoritative citations, and FAQ blocks. Automatically audits output with
569
+ * GeoCitabilityScorer and GeoHallucinationBaitDetector.
476
570
  */
477
571
  renderDeepEditorialPage(params: {
478
572
  serviceName: string;
479
573
  locationName: string;
480
574
  industryName?: string;
575
+ targetIndustry?: string;
481
576
  brandName?: string;
482
577
  monthlyPrice?: number;
578
+ priceMonthly?: number;
483
579
  currencySymbol?: string;
580
+ currency?: string;
581
+ serviceSlug?: string;
582
+ locationSlug?: string;
583
+ language?: "fr" | "en";
484
584
  sourceParagraphs?: string[];
485
585
  enableAiSmartLinking?: boolean;
486
586
  tier?: "starter" | "growth" | "enterprise";
587
+ directAnswer?: string;
588
+ comparativeTable?: {
589
+ headers?: [string, string, string];
590
+ rows: Array<{
591
+ criterion: string;
592
+ primaryValue: string;
593
+ baselineValue: string;
594
+ }>;
595
+ };
596
+ sourcedStats?: Array<{
597
+ label: string;
598
+ value: string;
599
+ sourceName: string;
600
+ sourceUrl?: string;
601
+ year?: string | number;
602
+ }>;
603
+ faqs?: Array<{
604
+ question: string;
605
+ answer: string;
606
+ }>;
607
+ citations?: Array<{
608
+ sourceName: string;
609
+ url: string;
610
+ description?: string;
611
+ }>;
612
+ expertQuote?: {
613
+ quote: string;
614
+ author: string;
615
+ role: string;
616
+ organization?: string;
617
+ year?: string;
618
+ };
487
619
  }): {
488
620
  title: string;
489
621
  metaDescription: string;
@@ -492,6 +624,8 @@ export declare class PseoMatrixEngine {
492
624
  linksInjected: number;
493
625
  tokensConsumed: number;
494
626
  tokenUsage?: TokenUsageRecord;
627
+ citabilityScore: CitabilityScoreResult;
628
+ hallucinationAudit: HallucinationBaitResult;
495
629
  aiSummaryJson?: Record<string, any>;
496
630
  aiFaqJson?: Record<string, any>;
497
631
  };
@@ -73093,17 +73093,40 @@ function executeSeoQuery(query, datasetRows) {
73093
73093
  filtered = filtered.slice(0, query.limit);
73094
73094
  }
73095
73095
  const sampleRow = filtered[0] || {};
73096
- const columns = Object.keys(sampleRow).map((key) => {
73097
- const matchedField = datasetDef?.fields.find((f) => f.id === key);
73098
- if (matchedField) {
73099
- return { key, name: matchedField.name, type: matchedField.type };
73096
+ const sampleKeys = Object.keys(sampleRow);
73097
+ let columns = [];
73098
+ if (sampleKeys.length > 0) {
73099
+ columns = sampleKeys.map((key) => {
73100
+ const matchedField = datasetDef?.fields.find((f) => f.id === key);
73101
+ if (matchedField) {
73102
+ return { key, name: matchedField.name, type: matchedField.type };
73103
+ }
73104
+ return {
73105
+ key,
73106
+ name: key.replace(/_/g, " ").toUpperCase(),
73107
+ type: typeof sampleRow[key] === "number" ? "number" : "string"
73108
+ };
73109
+ });
73110
+ } else if (query.groupBy && query.aggregations) {
73111
+ for (const key of query.groupBy) {
73112
+ const field = datasetDef?.fields.find((candidate) => candidate.id === key);
73113
+ columns.push({ key, name: field?.name ?? key, type: field?.type ?? "string" });
73114
+ }
73115
+ for (const aggregation of query.aggregations) {
73116
+ const key = aggregation.as || `${aggregation.function}_${aggregation.field}`;
73117
+ columns.push({
73118
+ key,
73119
+ name: key.replace(/_/g, " ").toUpperCase(),
73120
+ type: "number"
73121
+ });
73100
73122
  }
73101
- return {
73102
- key,
73103
- name: key.replace(/_/g, " ").toUpperCase(),
73104
- type: typeof sampleRow[key] === "number" ? "number" : "string"
73105
- };
73106
- });
73123
+ } else {
73124
+ columns = (datasetDef?.fields ?? []).map((field) => ({
73125
+ key: field.id,
73126
+ name: field.name,
73127
+ type: field.type
73128
+ }));
73129
+ }
73107
73130
  return {
73108
73131
  columns,
73109
73132
  rows: [...filtered],
@@ -24,16 +24,18 @@ export interface AccountAnalyticsReport {
24
24
  };
25
25
  accounts: B2BAccount[];
26
26
  }
27
+ /**
28
+ * Dérive le statut d'un compte de son score de santé (0–100). Le statut
29
+ * `churned` reste une décision métier explicite : il ne se déduit pas d'un
30
+ * score et doit être persisté tel quel quand un caller le fournit.
31
+ */
32
+ export declare function accountStatusForHealthScore(healthScore: number): Exclude<B2BAccount["status"], "churned">;
33
+ /**
34
+ * Agrégateur pur : le store serveur fournit les comptes persistés du projet,
35
+ * ce plugin ne fabrique ni seed ni repli en mémoire.
36
+ */
27
37
  export declare class AccountAnalyticsPlugin implements LynxSeoPlugin {
28
38
  manifest: PluginManifest;
29
- private accounts;
30
- constructor();
31
- private seedDefaultAccounts;
32
39
  init(_context: PluginContext): Promise<void>;
33
- getReport(projectId: string): AccountAnalyticsReport;
34
- upsertAccount(account: Omit<B2BAccount, "id" | "lastActivityAt"> & {
35
- id?: string;
36
- }): B2BAccount;
37
- updateAccountHealth(id: string, healthScore: number): B2BAccount | null;
38
- deleteAccount(id: string): boolean;
40
+ getReport(projectId: string, accounts: readonly B2BAccount[]): AccountAnalyticsReport;
39
41
  }
@@ -61,5 +61,4 @@ export declare class GroupAnalyticsPlugin implements LynxSeoPlugin {
61
61
  search?: string;
62
62
  plan?: string;
63
63
  }): GroupAnalyticsReport;
64
- private getDefaultGroups;
65
64
  }
@@ -66,10 +66,32 @@ export declare class SqlQueryBuilderClass {
66
66
  }
67
67
  /** Créer une requête à partir d'un schéma structuré */
68
68
  export declare function buildQueryFromSchema(schema: BuiltSqlQuery): string;
69
- /** Exécuter une requête SQL (placeholder - la vraie exécution via Drizzle/Hyperdrive) */
70
- export declare function executeQuery<T = any>(query: string, parameters?: unknown[]): Promise<T[]>;
71
- /** Obtenir les métadonnées d'une table */
72
- export declare function getTableMetadata(tableName: string): Promise<{
69
+ /** Interface d'un exécuteur de requêtes SQL (ex: Drizzle, Hyperdrive, sqlite3 ou driver mémoire) */
70
+ export type QueryExecutor<T = unknown> = (query: string, parameters?: unknown[]) => Promise<T[]>;
71
+ /** Enregistrer un exécuteur de requêtes personnalisé pour l'environnement hôte */
72
+ export declare function setQueryExecutor(executor: QueryExecutor | null): void;
73
+ /** Enregistrer ou déclarer les métadonnées d'une table */
74
+ export declare function registerTableMetadata(tableName: string, metadata: {
75
+ columns: {
76
+ name: string;
77
+ type: string;
78
+ nullable: boolean;
79
+ }[];
80
+ primaryKey?: string[];
81
+ }): void;
82
+ /**
83
+ * Exécuter une requête SQL via l'exécuteur configuré ou renvoyer un jeu de données typé.
84
+ */
85
+ export declare function executeQuery<T = any>(query: string, parameters?: unknown[], executor?: QueryExecutor<T>): Promise<T[]>;
86
+ /** Obtenir les métadonnées d'une table (depuis le registre local ou les définitions déclarées) */
87
+ export declare function getTableMetadata(tableName: string, fetcher?: (name: string) => Promise<{
88
+ columns: {
89
+ name: string;
90
+ type: string;
91
+ nullable: boolean;
92
+ }[];
93
+ primaryKey?: string[];
94
+ }>): Promise<{
73
95
  columns: {
74
96
  name: string;
75
97
  type: string;
@@ -48,3 +48,12 @@ export declare function exportCsv(options: WhiteLabelExportOptions): Promise<{
48
48
  size: number;
49
49
  data: string;
50
50
  }>;
51
+ /** Interface pour un convertisseur HTML vers PDF externe ou personnalisé */
52
+ export type HtmlToPdfConverter = (html: string) => Promise<Buffer>;
53
+ /** Enregistrer un convertisseur HTML vers PDF (ex: Puppeteer, Playwright, service headless ou microservice Gotenberg) */
54
+ export declare function setHtmlToPdfConverter(converter: HtmlToPdfConverter | null): void;
55
+ /**
56
+ * Convertir du HTML en PDF.
57
+ * Utilise le convertisseur injecté s'il est configuré, ou renvoie le buffer encodé UTF-8 de l'HTML.
58
+ */
59
+ export declare function convertHtmlToPdf(html: string, converter?: HtmlToPdfConverter): Promise<Buffer>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-seo/engine",
3
- "version": "3.3.4",
3
+ "version": "3.3.5",
4
4
  "description": "High-Performance Universal Programmatic SEO & AI Search Engine SDK",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",