@lynxflow/seo-engine 1.0.0 → 1.2.0

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.
Files changed (52) hide show
  1. package/README.md +333 -82
  2. package/connectors/cloudflare-worker/worker.js +54 -26
  3. package/connectors/laravel/LynxSeoController.php +8 -8
  4. package/connectors/wordpress/lynxseo-connector.php +296 -53
  5. package/dist/ai-copilot-client.d.ts +36 -0
  6. package/dist/analytics-client.d.ts +53 -0
  7. package/dist/auth-key.d.ts +57 -0
  8. package/dist/backlinks-client.d.ts +31 -0
  9. package/dist/engine.d.ts +73 -0
  10. package/dist/i18n-dictionary.d.ts +30 -0
  11. package/dist/index.d.ts +42 -0
  12. package/dist/index.js +1265 -169
  13. package/dist/index.mjs +1463 -0
  14. package/dist/indexnow-client.d.ts +25 -0
  15. package/dist/lago-token-meter.d.ts +36 -0
  16. package/dist/schema-builder.d.ts +27 -0
  17. package/dist/serp-client.d.ts +42 -0
  18. package/dist/site-auditor.d.ts +29 -0
  19. package/dist/src/ai-copilot-client.d.ts +36 -0
  20. package/dist/src/analytics-client.d.ts +53 -0
  21. package/dist/src/auth-key.d.ts +57 -0
  22. package/dist/src/backlinks-client.d.ts +31 -0
  23. package/dist/src/engine.d.ts +72 -0
  24. package/dist/src/i18n-dictionary.d.ts +30 -0
  25. package/dist/src/index.d.ts +42 -0
  26. package/dist/src/indexnow-client.d.ts +25 -0
  27. package/dist/src/lago-token-meter.d.ts +36 -0
  28. package/dist/src/schema-builder.d.ts +27 -0
  29. package/dist/src/serp-client.d.ts +42 -0
  30. package/dist/src/site-auditor.d.ts +29 -0
  31. package/dist/src/token-quota-manager.d.ts +37 -0
  32. package/dist/src/types.d.ts +145 -0
  33. package/dist/token-quota-manager.d.ts +37 -0
  34. package/dist/types.d.ts +162 -0
  35. package/lynxflow-seo-engine-1.2.0.tgz +0 -0
  36. package/package.json +1 -1
  37. package/src/ai-copilot-client.ts +84 -0
  38. package/src/analytics-client.ts +141 -0
  39. package/src/auth-key.ts +203 -0
  40. package/src/backlinks-client.ts +85 -0
  41. package/src/engine.ts +499 -85
  42. package/src/i18n-dictionary.ts +362 -0
  43. package/src/index.ts +18 -4
  44. package/src/indexnow-client.ts +94 -0
  45. package/src/lago-token-meter.ts +7 -2
  46. package/src/schema-builder.ts +87 -0
  47. package/src/serp-client.ts +89 -0
  48. package/src/site-auditor.ts +83 -0
  49. package/src/types.ts +148 -28
  50. package/tsconfig.json +14 -0
  51. package/lynxflow-seo-engine-1.0.0.tgz +0 -0
  52. package/src/licensing.ts +0 -138
package/src/engine.ts CHANGED
@@ -1,148 +1,562 @@
1
1
  /**
2
- * ⚡ LynxSEO High-Speed Dynamic Page Engine
3
- * Computes rich SEO pages on-demand in < 0.05ms on client servers.
2
+ * ⚡ LynxSEO High-Speed Universal Dynamic Page Engine (Internationalized)
3
+ *
4
+ * Computes 8 Rich Programmatic Matrix Types on-demand in < 0.05ms with
5
+ * automatic multi-language i18n support & Google Hreflang alternates:
6
+ * 1. 📍 Local / GEO : `/solutions/{service}/{country}/{city}`
7
+ * 2. 🥊 VS Comparisons : `/comparatif/{competitor}` (ex: `/comparatif/hubspot`)
8
+ * 3. 🔄 Alternatives : `/alternatives/alternative-a-{competitor}`
9
+ * 4. 🔌 Integrations : `/integrations/{software}` (ex: `/integrations/shopify`)
10
+ * 5. 🏢 Industry / Verticals : `/secteurs/{industry}` (ex: `/secteurs/avocats`)
11
+ * 6. 👤 Personas / Roles : `/metiers/{role}` (ex: `/metiers/directeur-commercial`)
12
+ * 7. 🎯 Use Cases : `/cas-usage/{useCase}` (ex: `/cas-usage/relance-devis`)
13
+ * 8. 🧮 Calculators / ROI Tools : `/outils/simulateur-roi`
4
14
  */
5
15
 
6
- import type { LynxSeoConfig, LynxResolvedPage } from "./types";
7
- import { LicenseGuardian } from "./licensing";
16
+ import type { LynxSeoConfig, LynxResolvedPage, LynxServiceDefinition } from "./types";
17
+ import { ApiKeyGuardian, type ApiKeyValidationResult } from "./auth-key";
18
+ import { getDictionary, isSupportedLanguage } from "./i18n-dictionary";
19
+ import { IndexNowClient, type IndexNowResponse } from "./indexnow-client";
20
+ import { LynxAnalyticsClient } from "./analytics-client";
21
+ import { SerpClient } from "./serp-client";
22
+ import { BacklinksClient } from "./backlinks-client";
23
+ import { AiCopilotClient } from "./ai-copilot-client";
24
+ import { LagoTokenMeter } from "./lago-token-meter";
25
+ import { SiteAuditor } from "./site-auditor";
26
+ import { SchemaGraphBuilder } from "./schema-builder";
27
+
28
+ export type EngineConfig = LynxSeoConfig;
8
29
 
9
30
  export class LynxSeoEngine {
10
31
  private config: LynxSeoConfig;
11
- private servicesMap: Map<string, any>;
12
- private licenseStatus: any;
32
+ private servicesMap: Map<string, LynxServiceDefinition>;
33
+ private authStatus: ApiKeyValidationResult;
34
+
35
+ // Embedded Sub-Clients for complete in-app autonomy
36
+ public readonly analytics: LynxAnalyticsClient;
37
+ public readonly serp: SerpClient;
38
+ public readonly backlinks: BacklinksClient;
39
+ public readonly ai: AiCopilotClient;
40
+ public readonly tokenMeter: LagoTokenMeter;
41
+ public readonly auditor = SiteAuditor;
42
+ public readonly schema = SchemaGraphBuilder;
43
+ public readonly indexNow = IndexNowClient;
13
44
 
14
45
  constructor(config: LynxSeoConfig) {
15
46
  this.config = {
16
47
  currency: "EUR",
17
48
  currencySymbol: "€",
49
+ defaultLocale: "fr",
50
+ supportedLocales: ["fr", "en", "es", "de", "ar"],
18
51
  ...config,
19
52
  };
20
- this.servicesMap = new Map(config.services.map((s) => [s.slug, s]));
21
- this.licenseStatus = LicenseGuardian.validateKey(config.licenseKey);
53
+ this.servicesMap = new Map((config.services || []).map((s) => [s.slug, s]));
54
+ const rawKey = config.apiKey || config.licenseKey || "";
55
+ this.authStatus = ApiKeyGuardian.validate(rawKey, config.domain);
56
+
57
+ this.analytics = new LynxAnalyticsClient(rawKey);
58
+ this.serp = new SerpClient(rawKey);
59
+ this.backlinks = new BacklinksClient(rawKey);
60
+ this.ai = new AiCopilotClient(rawKey);
61
+ this.tokenMeter = new LagoTokenMeter();
22
62
  }
23
63
 
24
64
  /**
25
- * Resolves a dynamic programmatic URL in < 0.05ms.
26
- * e.g. engine.resolve("/solutions/droit-immobilier/fr/lyon")
65
+ * Submits generated URLs to Bing, Yandex, Seznam, and Naver via IndexNow.
27
66
  */
28
- resolve(urlPath: string): LynxResolvedPage | null {
67
+ async submitToIndexNow(urls: string[], indexNowKey = this.config.apiKey || this.config.licenseKey || ""): Promise<IndexNowResponse> {
68
+ const host = this.config.domain.replace(/^https?:\/\//, "").replace(/\/.*$/, "");
69
+ return IndexNowClient.submitUrls({
70
+ host,
71
+ key: indexNowKey,
72
+ urlList: urls,
73
+ });
74
+ }
75
+
76
+ /**
77
+ * Universal resolver: supports both path strings e.g. "/comparatif/hubspot"
78
+ * and structured object params { slug, language, country, city, type, competitor, industry }.
79
+ */
80
+ resolve(input: string | { slug?: string; language?: string; locale?: string; country?: string; city?: string; type?: string; competitor?: string; industry?: string; role?: string }): LynxResolvedPage | null {
29
81
  const t0 = performance.now();
30
82
 
31
- if (!this.licenseStatus.isValid) {
32
- console.warn(`[@lynxflow/seo-engine] Invalid License: ${this.licenseStatus.errorMessage}`);
83
+ if (!this.authStatus.isValid) {
84
+ console.warn(`[@lynxflow/seo-engine] Authentication / Domain Limit Error: ${this.authStatus.errorMessage}`);
33
85
  return null;
34
86
  }
35
87
 
36
- const cleanPath = urlPath.toLowerCase().replace(/^\//, "").replace(/\/$/, "");
88
+ const rawKey = this.config.apiKey || this.config.licenseKey || "";
89
+ const targetPath = typeof input === "string" ? input.replace(/^\/+/, "").replace(/\/+$/, "") : `${input.type || "solutions"}/${input.slug || ""}`;
90
+ const quota = ApiKeyGuardian.trackAndCheckUniquePage(rawKey, targetPath, this.authStatus.maxPages);
91
+ if (!quota.allowed) {
92
+ console.warn(`[@lynxflow/seo-engine] Unique Page Quota Exceeded: Your plan allows up to ${this.authStatus.maxPages.toLocaleString()} unique pages (Current active catalog: ${quota.uniqueCount}). Please upgrade to a higher plan.`);
93
+ return null;
94
+ }
95
+
96
+ const domain = this.config.domain.replace(/\/$/, "");
97
+ const defaultService = this.config.services?.[0] || {
98
+ slug: "crm-pipeline",
99
+ name: "CRM Pipeline Commercial",
100
+ pricePerMonth: 49,
101
+ category: "Automatisation Commerciale",
102
+ features: ["Pipeline Kanban", "Relances IA 24/7", "WhatsApp Sync"],
103
+ faqs: [
104
+ { question: "Combien de temps prend la mise en place ?", answer: "Déploiement immédiat en moins de 10 minutes." },
105
+ { question: "Est-ce sans engagement ?", answer: "Oui, vous pouvez résilier à tout moment sans frais." }
106
+ ],
107
+ };
108
+
109
+ // -------------------------------------------------------------
110
+ // CASE A : Structured Object Input (e.g. Next.js Route Params)
111
+ // -------------------------------------------------------------
112
+ if (typeof input === "object") {
113
+ const locale = (input.locale || input.language || this.config.defaultLocale || "fr").toLowerCase();
114
+ const type = input.type || (input.competitor ? "comparison" : input.city ? "geo" : "industry");
115
+ const service = (input.slug ? this.servicesMap.get(input.slug) : null) || defaultService;
116
+
117
+ if (type === "comparison" && input.competitor) {
118
+ return this.buildComparisonPage(service, input.competitor, domain, t0, locale);
119
+ }
120
+ if (type === "industry" && input.industry) {
121
+ return this.buildIndustryPage(service, input.industry, domain, t0, locale);
122
+ }
123
+ if (type === "role" && input.role) {
124
+ return this.buildRolePage(service, input.role, domain, t0, locale);
125
+ }
126
+
127
+ // Default to Local GEO
128
+ const country = (input.country || locale.toUpperCase() || "FR").toUpperCase();
129
+ const city = input.city || "Paris";
130
+ return this.buildGeoPage(service, country, city, domain, t0, locale);
131
+ }
132
+
133
+ // -------------------------------------------------------------
134
+ // CASE B : Raw URL Path String (e.g. WordPress, Cloudflare Worker, Laravel)
135
+ // -------------------------------------------------------------
136
+ const cleanPath = input.toLowerCase().replace(/^\//, "").replace(/\/$/, "");
37
137
  const parts = cleanPath.split("/");
38
138
 
39
- if (parts.length < 4 || parts[0] !== "solutions") {
40
- return null;
139
+ // Detect language prefix if present (e.g. /en/solutions/..., /ja/solutions/..., etc.)
140
+ let locale = this.config.defaultLocale || "fr";
141
+ let pathParts = parts;
142
+
143
+ if (parts.length > 1 && isSupportedLanguage(parts[0])) {
144
+ locale = parts[0];
145
+ pathParts = parts.slice(1);
41
146
  }
42
147
 
43
- const serviceSlug = parts[1];
44
- const countryCode = parts[2].toUpperCase();
45
- const citySlug = parts[3];
46
- const cityName = citySlug.charAt(0).toUpperCase() + citySlug.slice(1);
148
+ // 1. GEO & Multi-Slug Combined Matrix:
149
+ // Pattern A : /solutions/{service}/{country}/{city} (3-4 parts)
150
+ // Pattern B : /solutions/{service}/{industry}/{competitor}/{software}/{role}/{city}/{tool} (5-8 parts)
151
+ if (pathParts[0] === "solutions") {
152
+ if (pathParts.length >= 5) {
153
+ // Hyper-combined 8-slug page
154
+ const service = this.servicesMap.get(pathParts[1]) || defaultService;
155
+ const industry = (pathParts[2] || "").replace(/-/g, " ");
156
+ const competitor = (pathParts[3] || "").replace(/-/g, " ");
157
+ const software = (pathParts[4] || "").replace(/-/g, " ");
158
+ const role = (pathParts[5] || "").replace(/-/g, " ");
159
+ const city = (pathParts[6] || "Paris").replace(/-/g, " ");
160
+ const tool = (pathParts[7] || "").replace(/-/g, " ");
47
161
 
48
- const service = this.servicesMap.get(serviceSlug) || this.config.services[0];
49
- if (!service) return null;
162
+ return this.buildHyperCombinedPage({
163
+ service,
164
+ industry,
165
+ competitor,
166
+ software,
167
+ role,
168
+ city,
169
+ tool,
170
+ domain,
171
+ t0,
172
+ locale,
173
+ path: cleanPath,
174
+ });
175
+ }
50
176
 
51
- const domain = this.config.domain.replace(/\/$/, "");
52
- const fullUrl = `${domain}/${cleanPath}`;
177
+ // 4-part: /solutions/{service}/{country}/{city} (e.g. /solutions/crm/us/new-york)
178
+ if (pathParts.length >= 4) {
179
+ const service = this.servicesMap.get(pathParts[1]) || defaultService;
180
+ const country = pathParts[2].toUpperCase();
181
+ const cityName = pathParts[3].charAt(0).toUpperCase() + pathParts[3].slice(1);
182
+ return this.buildGeoPage(service, country, cityName, domain, t0, locale, cleanPath);
183
+ }
53
184
 
54
- const title = `${service.name} à ${cityName} (${countryCode}) ${this.config.brandName}`;
55
- const description = `Découvrez notre solution de ${service.name} dédiée aux professionnels et entreprises à ${cityName}. Note 4.9/5 étoiles et déploiement immédiat.`;
56
- const h1 = `${service.name} à ${cityName}`;
185
+ // 3-part (Clean standard URL): /solutions/{service}/{city} (e.g. /solutions/crm/lyon, /fr/solutions/crm/paris)
186
+ if (pathParts.length >= 3) {
187
+ const service = this.servicesMap.get(pathParts[1]) || defaultService;
188
+ const defaultCountry = locale.toUpperCase();
189
+ const cityName = pathParts[2].charAt(0).toUpperCase() + pathParts[2].slice(1);
190
+ return this.buildGeoPage(service, defaultCountry, cityName, domain, t0, locale, cleanPath);
191
+ }
192
+ }
193
+
194
+ // Helper: Find service mentioned in slug
195
+ const detectServiceFromSlug = (slug: string): { service: LynxServiceDefinition; remainder: string } => {
196
+ for (const [sSlug, sDef] of this.servicesMap.entries()) {
197
+ if (slug.startsWith(`${sSlug}-`)) {
198
+ return { service: sDef, remainder: slug.substring(sSlug.length + 1) };
199
+ }
200
+ }
201
+ return { service: defaultService, remainder: slug };
202
+ };
203
+
204
+ // 2. VS Comparison Matrix: /comparatif/{service}-vs-{competitor} OR /comparatif/{competitor}
205
+ if ((pathParts[0] === "comparatif" || pathParts[0] === "comparison" || pathParts[0] === "vs") && pathParts.length >= 2) {
206
+ const raw = pathParts[1];
207
+ const vsMatch = raw.match(/^(.*?)-vs-(.*?)$/);
208
+ let targetService = defaultService;
209
+ let competitor = raw;
210
+
211
+ if (vsMatch) {
212
+ targetService = this.servicesMap.get(vsMatch[1]) || defaultService;
213
+ competitor = vsMatch[2];
214
+ } else {
215
+ const detected = detectServiceFromSlug(raw);
216
+ targetService = detected.service;
217
+ competitor = detected.remainder;
218
+ }
219
+
220
+ return this.buildComparisonPage(targetService, competitor.replace(/-/g, " "), domain, t0, locale, cleanPath);
221
+ }
222
+
223
+ // 3. Alternative To Matrix: /alternatives/alternative-a-{competitor}
224
+ if (pathParts[0] === "alternatives" && pathParts.length >= 2) {
225
+ const raw = pathParts[1].replace(/^alternative-(a-|to-)?/i, "");
226
+ const { service, remainder } = detectServiceFromSlug(raw);
227
+ return this.buildAlternativePage(service, remainder.replace(/-/g, " "), domain, t0, locale, cleanPath);
228
+ }
229
+
230
+ // 4. Industry / Vertical Matrix: /secteurs/{service}-pour-{industry} OR /secteurs/{industry}
231
+ if ((pathParts[0] === "secteurs" || pathParts[0] === "industries") && pathParts.length >= 2) {
232
+ const raw = pathParts[1].replace(/-(pour|for)-/i, "-");
233
+ const { service, remainder } = detectServiceFromSlug(raw);
234
+ return this.buildIndustryPage(service, remainder.replace(/-/g, " "), domain, t0, locale, cleanPath);
235
+ }
236
+
237
+ // 5. Integrations Matrix: /integrations/{service}-avec-{software} OR /integrations/{software}
238
+ if (pathParts[0] === "integrations" && pathParts.length >= 2) {
239
+ const raw = pathParts[1].replace(/-(avec|with)-/i, "-");
240
+ const { service, remainder } = detectServiceFromSlug(raw);
241
+ return this.buildIntegrationPage(service, remainder.replace(/-/g, " "), domain, t0, locale, cleanPath);
242
+ }
243
+
244
+ // 6. Personas / Roles: /metiers/{service}-pour-{role} OR /metiers/{role}
245
+ if ((pathParts[0] === "metiers" || pathParts[0] === "roles") && pathParts.length >= 2) {
246
+ const raw = pathParts[1].replace(/-(pour|for)-/i, "-");
247
+ const { service, remainder } = detectServiceFromSlug(raw);
248
+ return this.buildRolePage(service, remainder.replace(/-/g, " "), domain, t0, locale, cleanPath);
249
+ }
57
250
 
58
- const directAnswerGeoHtml = `
59
- <div class="geo-direct-answer" data-geo-extract="true">
60
- <p><strong>${this.config.brandName}</strong> est la solution de référence pour <strong>${service.name}</strong> à <strong>${cityName}</strong>. Déploiement en quelques minutes à partir de <strong>${service.pricePerMonth} ${this.config.currencySymbol} / mois</strong> avec note moyenne de 4.9/5 étoiles.</p>
61
- </div>
62
- `.trim();
251
+ // 7. Use Cases: /cas-usage/{topic}
252
+ if ((pathParts[0] === "cas-usage" || pathParts[0] === "use-cases") && pathParts.length >= 2) {
253
+ const { service, remainder } = detectServiceFromSlug(pathParts[1]);
254
+ return this.buildGeoPage(service, "FR", remainder.replace(/-/g, " "), domain, t0, locale, cleanPath);
255
+ }
63
256
 
64
- const markdownBody = `
65
- # ${h1}
257
+ // 8. Tools / Calculators: /outils/{tool}
258
+ if ((pathParts[0] === "outils" || pathParts[0] === "tools") && pathParts.length >= 2) {
259
+ const { service } = detectServiceFromSlug(pathParts[1]);
260
+ return this.buildGeoPage(service, "FR", "Calculateur ROI", domain, t0, locale, cleanPath);
261
+ }
66
262
 
67
- > **${description}**
263
+ // Fallback: local geo
264
+ return this.buildGeoPage(defaultService, "FR", "Paris", domain, t0, locale, cleanPath);
265
+ }
68
266
 
69
- ${directAnswerGeoHtml}
267
+ // ---------------- Localized Builder Helpers ----------------
70
268
 
71
- ---
269
+ private buildHyperCombinedPage(opts: {
270
+ service: LynxServiceDefinition;
271
+ industry: string;
272
+ competitor: string;
273
+ software: string;
274
+ role: string;
275
+ city: string;
276
+ tool: string;
277
+ domain: string;
278
+ t0: number;
279
+ locale: string;
280
+ path: string;
281
+ }): LynxResolvedPage {
282
+ const { service, industry, competitor, software, role, city, tool, domain, t0, locale, path } = opts;
283
+ const currentYear = new Date().getFullYear();
72
284
 
73
- ## 🛑 Pourquoi choisir ${this.config.brandName} à ${cityName} ?
74
- Les professionnels et entreprises à ${cityName} bénéficient d'un accompagnement sur mesure, d'une disponibilité continue et d'une technologie éprouvée.
285
+ const indStr = industry ? ` pour ${industry}` : "";
286
+ const compStr = competitor ? ` (Alternative à ${competitor})` : "";
287
+ const softStr = software ? ` connecté avec ${software}` : "";
288
+ const roleStr = role ? ` pour ${role}` : "";
289
+ const cityStr = city ? ` à ${city}` : "";
290
+ const toolStr = tool ? ` | Simulateur ROI` : "";
75
291
 
76
- ---
292
+ const title = `${service.name}${indStr}${roleStr}${cityStr}${compStr}${toolStr} — ${this.config.brandName}`;
293
+ const description = `Découvrez la solution de ${service.name}${indStr}${cityStr}. Automatisez vos flux, gagnez 10h/semaine${softStr}. Déploiement en 10 minutes. Note 4.9/5★.`;
294
+ const h1 = `${service.name}${indStr}${cityStr}`;
295
+ const directAnswer = `${this.config.brandName} propose le meilleur ${service.name}${indStr}${roleStr}${cityStr}${compStr}${softStr}. Mise en service immédiate dès ${service.pricePerMonth} ${this.config.currencySymbol || "€"}/mois sans engagement.`;
77
296
 
78
- ## 💎 Vos Avantages Concrets :
79
- * ✦ **Performance Maximale** : Réponses instantanées et flux automatisés.
80
- * ✦ **Simplicité d'Usage** : Aucun prérequis technique, prise en main en 2 minutes.
81
- * ✦ **Rentabilité Garantie** : Rentabilisé dès la première opportunité signée.
297
+ return this.assemblePage({
298
+ url: `${domain}/${path}`,
299
+ title,
300
+ description,
301
+ h1,
302
+ directAnswer,
303
+ service,
304
+ locale,
305
+ path,
306
+ t0,
307
+ });
308
+ }
82
309
 
83
- ---
310
+ private buildGeoPage(service: LynxServiceDefinition, country: string, city: string, domain: string, t0: number, locale = "fr", path = `solutions/${service.slug}/${country.toLowerCase()}/${city.toLowerCase()}`): LynxResolvedPage {
311
+ const dict = getDictionary(locale);
312
+ const title = dict.geoTitle(service.name, city, country, this.config.brandName);
313
+ const description = dict.geoDesc(service.name, city, this.config.brandName);
314
+ const h1 = `${service.name} à ${city}`;
315
+ const directAnswer = dict.geoDirectAnswer(this.config.brandName, service.name, city, country, service.pricePerMonth, this.config.currencySymbol || "€");
84
316
 
85
- ## 🛠️ Déploiement en 3 Étapes à ${cityName} :
86
- 1. **Étape 1** : Activez votre compte en 30 secondes.
87
- 2. **Étape 2** : Configurez vos préférences et règles métier.
88
- 3. **Étape 3** : Vos premières demandes sont traitées 24/7.
89
- `.trim();
317
+ return this.assemblePage({
318
+ url: `${domain}/${path}`,
319
+ title,
320
+ description,
321
+ h1,
322
+ directAnswer,
323
+ service,
324
+ locale,
325
+ path,
326
+ t0,
327
+ });
328
+ }
90
329
 
91
- const schemaJsonLd = {
330
+ private buildComparisonPage(service: LynxServiceDefinition, competitor: string, domain: string, t0: number, locale = "fr", path = `comparatif/${competitor.toLowerCase().replace(/\s+/g, "-")}`): LynxResolvedPage {
331
+ const dict = getDictionary(locale);
332
+ const compName = competitor.charAt(0).toUpperCase() + competitor.slice(1);
333
+ const currentYear = new Date().getFullYear();
334
+ const title = `${service.name} : ${this.config.brandName} vs ${compName} (${currentYear})`;
335
+ const description = dict.vsDesc(this.config.brandName, compName);
336
+ const h1 = `${service.name} : ${this.config.brandName} vs ${compName}`;
337
+ const directAnswer = dict.vsDirectAnswer(this.config.brandName, compName);
338
+
339
+ return this.assemblePage({
340
+ url: `${domain}/${path}`,
341
+ title,
342
+ description,
343
+ h1,
344
+ directAnswer,
345
+ service,
346
+ locale,
347
+ path,
348
+ t0,
349
+ });
350
+ }
351
+
352
+ private buildAlternativePage(service: LynxServiceDefinition, competitor: string, domain: string, t0: number, locale = "fr", path = `alternatives/alternative-a-${competitor.toLowerCase().replace(/\s+/g, "-")}`): LynxResolvedPage {
353
+ const dict = getDictionary(locale);
354
+ const compName = competitor.charAt(0).toUpperCase() + competitor.slice(1);
355
+ const currentYear = new Date().getFullYear();
356
+ const title = `Meilleure Alternative à ${compName} (${service.name}) en ${currentYear} — ${this.config.brandName}`;
357
+ const description = dict.altDesc(compName, this.config.brandName);
358
+ const h1 = `Alternative à ${compName} pour votre ${service.name}`;
359
+ const directAnswer = dict.altDirectAnswer(this.config.brandName, compName);
360
+
361
+ return this.assemblePage({
362
+ url: `${domain}/${path}`,
363
+ title,
364
+ description,
365
+ h1,
366
+ directAnswer,
367
+ service,
368
+ locale,
369
+ path,
370
+ t0,
371
+ });
372
+ }
373
+
374
+ private buildIndustryPage(service: LynxServiceDefinition, industry: string, domain: string, t0: number, locale = "fr", path = `secteurs/${industry.toLowerCase().replace(/\s+/g, "-")}`): LynxResolvedPage {
375
+ const dict = getDictionary(locale);
376
+ const indName = industry.charAt(0).toUpperCase() + industry.slice(1);
377
+ const title = dict.industryTitle(service.name, indName, this.config.brandName);
378
+ const description = dict.industryDesc(service.name, indName);
379
+ const h1 = `${service.name} pour ${indName}`;
380
+ const directAnswer = `${this.config.brandName} propose une solution de ${service.name} conçue sur mesure pour les ${indName}, avec processus métiers et automatisations optimisés.`;
381
+
382
+ return this.assemblePage({
383
+ url: `${domain}/${path}`,
384
+ title,
385
+ description,
386
+ h1,
387
+ directAnswer,
388
+ service,
389
+ locale,
390
+ path,
391
+ t0,
392
+ });
393
+ }
394
+
395
+ private buildRolePage(service: LynxServiceDefinition, role: string, domain: string, t0: number, locale = "fr", path = `metiers/${role.toLowerCase().replace(/\s+/g, "-")}`): LynxResolvedPage {
396
+ const roleName = role.charAt(0).toUpperCase() + role.slice(1);
397
+ const title = `${service.name} pour ${roleName} — ${this.config.brandName}`;
398
+ const description = `Optimisez votre quotidien de ${roleName} grâce à notre solution de ${service.name}. Gagnez 10h par semaine.`;
399
+ const h1 = `${service.name} pour ${roleName}`;
400
+ const directAnswer = `En tant que ${roleName}, ${this.config.brandName} (${service.name}) vous libère des tâches manuelles grâce à des relances intelligentes et un suivi d'activité en temps réel.`;
401
+
402
+ return this.assemblePage({
403
+ url: `${domain}/${path}`,
404
+ title,
405
+ description,
406
+ h1,
407
+ directAnswer,
408
+ service,
409
+ locale,
410
+ path,
411
+ t0,
412
+ });
413
+ }
414
+
415
+ private buildIntegrationPage(service: LynxServiceDefinition, software: string, domain: string, t0: number, locale = "fr", path = `integrations/${software.toLowerCase().replace(/\s+/g, "-")}`): LynxResolvedPage {
416
+ const softName = software.charAt(0).toUpperCase() + software.slice(1);
417
+ const title = `Intégration ${softName} & ${service.name} — ${this.config.brandName}`;
418
+ const description = `Connectez facilement votre compte ${softName} à notre ${service.name}. Synchronisation bidirectionnelle instantanée.`;
419
+ const h1 = `Intégration ${softName} & ${service.name}`;
420
+ const directAnswer = `L'intégration native entre ${softName} et ${this.config.brandName} (${service.name}) permet de synchroniser contacts, événements et transactions en temps réel sans code.`;
421
+
422
+ return this.assemblePage({
423
+ url: `${domain}/${path}`,
424
+ title,
425
+ description,
426
+ h1,
427
+ directAnswer,
428
+ service,
429
+ locale,
430
+ path,
431
+ t0,
432
+ });
433
+ }
434
+
435
+ private assemblePage(opts: { url: string; title: string; description: string; h1: string; directAnswer: string; service: LynxServiceDefinition; locale: string; path: string; t0: number }): LynxResolvedPage {
436
+ const dict = getDictionary(opts.locale);
437
+ const domain = this.config.domain.replace(/\/$/, "");
438
+
439
+ // 🌐 Google Hreflang alternates for International SEO Indexing
440
+ const supportedLocales = this.config.supportedLocales || ["fr", "en", "es", "de", "ar"];
441
+ const hreflangs = supportedLocales.map((l) => ({
442
+ lang: l,
443
+ url: l === this.config.defaultLocale ? `${domain}/${opts.path}` : `${domain}/${l}/${opts.path}`,
444
+ }));
445
+
446
+ const localizedFaqs = opts.service.faqs?.length ? opts.service.faqs : [
447
+ { question: dict.faqDeploymentQ, answer: dict.faqDeploymentA },
448
+ { question: dict.faqCommitmentQ, answer: dict.faqCommitmentA },
449
+ ];
450
+
451
+ const ogImageUrl = `${domain}/api/og?title=${encodeURIComponent(opts.h1)}&brand=${encodeURIComponent(this.config.brandName)}&service=${encodeURIComponent(opts.service.name)}`;
452
+
453
+ const jsonLd = {
92
454
  "@context": "https://schema.org",
93
455
  "@graph": [
94
456
  {
95
- "@type": "Service",
96
- name: `${service.name} à ${cityName}`,
97
- provider: {
98
- "@type": "LocalBusiness",
99
- name: this.config.brandName,
100
- url: domain,
101
- },
102
- areaServed: {
103
- "@type": "City",
104
- name: cityName,
105
- },
457
+ "@type": "Product",
458
+ "@id": `${opts.url}#product`,
459
+ name: opts.title,
460
+ description: opts.description,
461
+ inLanguage: opts.locale,
462
+ image: ogImageUrl,
463
+ brand: { "@type": "Brand", name: this.config.brandName },
106
464
  aggregateRating: {
107
465
  "@type": "AggregateRating",
108
466
  ratingValue: "4.9",
109
467
  reviewCount: "1280",
468
+ bestRating: "5",
469
+ worstRating: "1",
470
+ },
471
+ offers: {
472
+ "@type": "Offer",
473
+ price: opts.service.pricePerMonth.toString(),
474
+ priceCurrency: this.config.currency,
475
+ availability: "https://schema.org/InStock",
476
+ url: opts.url,
477
+ },
478
+ },
479
+ {
480
+ "@type": "FAQPage",
481
+ "@id": `${opts.url}#faq`,
482
+ inLanguage: opts.locale,
483
+ mainEntity: localizedFaqs.map((faq) => ({
484
+ "@type": "Question",
485
+ name: faq.question,
486
+ acceptedAnswer: {
487
+ "@type": "Answer",
488
+ text: faq.answer,
489
+ },
490
+ })),
491
+ },
492
+ {
493
+ "@type": "WebPage",
494
+ "@id": `${opts.url}#webpage`,
495
+ url: opts.url,
496
+ name: opts.title,
497
+ description: opts.description,
498
+ speakable: {
499
+ "@type": "SpeakableSpecification",
500
+ cssSelector: [".geo-direct-answer", "h1"],
110
501
  },
111
502
  },
112
503
  ],
113
504
  };
114
505
 
115
- const faqList = [
116
- { question: `Pourquoi choisir ${service.name} à ${cityName} ?`, answer: `Pour notre proximité, notre rapidité d'exécution et notre satisfaction client de 4.9/5.` },
117
- { question: `Comment démarrer ?`, answer: `Inscrivez-vous en 30 secondes sans engagement pour tester la solution.` },
118
- ];
119
-
120
- const executionTimeMs = parseFloat((performance.now() - t0).toFixed(3));
506
+ const directAnswerHtml = `<div class="geo-direct-answer" data-geo-extract="true"><p>${opts.directAnswer}</p></div>`;
121
507
 
122
508
  return {
123
- urlPath: `/${cleanPath}`,
124
- fullUrl,
509
+ url: opts.url,
510
+ title: opts.title,
511
+ description: opts.description,
512
+ h1: opts.h1,
513
+ directAnswer: opts.directAnswer,
514
+ service: opts.service,
515
+ locale: opts.locale,
516
+ hreflangs,
517
+ faqs: localizedFaqs,
518
+ jsonLd,
519
+ htmlBody: `<h1>${opts.h1}</h1><p>${opts.description}</p>${directAnswerHtml}`,
520
+ markdownBody: `# ${opts.h1}\n\n${opts.description}\n\n> ${opts.directAnswer}`,
521
+ executionTimeMs: parseFloat((performance.now() - opts.t0).toFixed(3)),
522
+
523
+ // Backward compatibility bindings
524
+ fullUrl: opts.url,
125
525
  meta: {
126
- title,
127
- description,
128
- h1,
129
- canonical: fullUrl,
130
- openGraphImageUrl: `${domain}/api/og?service=${encodeURIComponent(service.name)}&city=${encodeURIComponent(cityName)}`,
526
+ title: opts.title,
527
+ description: opts.description,
528
+ h1: opts.h1,
529
+ canonical: opts.url,
131
530
  },
132
- schemaJsonLd,
133
531
  content: {
134
- directAnswerGeoHtml,
135
- heroHeadline: h1,
136
- heroSubheadline: description,
137
- markdownBody,
138
- faqList,
139
- neighboringLinks: [],
532
+ directAnswerGeoHtml: directAnswerHtml,
533
+ heroHeadline: opts.h1,
534
+ heroSubheadline: opts.description,
535
+ markdownBody: `# ${opts.h1}\n\n${opts.description}\n\n> ${opts.directAnswer}`,
536
+ faqList: localizedFaqs,
140
537
  },
538
+ schemaJsonLd: jsonLd,
141
539
  pricing: {
142
- priceNumber: service.pricePerMonth,
143
- priceFormatted: `${service.pricePerMonth} ${this.config.currencySymbol} / mois`,
540
+ priceNumber: opts.service.pricePerMonth,
541
+ priceFormatted: `${opts.service.pricePerMonth} ${this.config.currencySymbol}`,
542
+ currency: this.config.currency || "EUR",
144
543
  },
145
- executionTimeMs,
146
544
  };
147
545
  }
546
+
547
+ /**
548
+ * Returns the exact count of distinct unique programmatic pages currently active.
549
+ */
550
+ getUniquePageCount(): number {
551
+ const rawKey = this.config.apiKey || this.config.licenseKey || "";
552
+ return ApiKeyGuardian.getUniquePageCount(rawKey);
553
+ }
554
+
555
+ /**
556
+ * Returns the list of all distinct unique URL paths generated so far.
557
+ */
558
+ getUniquePageList(): string[] {
559
+ const rawKey = this.config.apiKey || this.config.licenseKey || "";
560
+ return ApiKeyGuardian.getUniquePageList(rawKey);
561
+ }
148
562
  }