@lynxflow/seo-engine 1.7.5 → 1.7.7

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.
@@ -0,0 +1,280 @@
1
+ export interface GoogleBusinessProfileConfig {
2
+ placeId?: string;
3
+ businessName: string;
4
+ category: string;
5
+ streetAddress: string;
6
+ addressLocality: string;
7
+ postalCode: string;
8
+ addressCountry: string;
9
+ telephone: string;
10
+ priceRange?: string;
11
+ latitude?: number;
12
+ longitude?: number;
13
+ openingHours?: string[]; // e.g. ["Mo-Fr 09:00-18:00", "Sa 10:00-16:00"]
14
+ ratingValue?: number;
15
+ reviewCount?: number;
16
+ googleMapsUrl?: string;
17
+ }
18
+
19
+ export interface GbpAuditResult {
20
+ score: number;
21
+ grade: "A+" | "A" | "B" | "C" | "D";
22
+ passedChecks: number;
23
+ totalChecks: number;
24
+ checks: Array<{
25
+ name: string;
26
+ status: "pass" | "warn" | "fail";
27
+ points: number;
28
+ description: string;
29
+ recommendation?: string;
30
+ }>;
31
+ summary: string;
32
+ localPackEligibility: "Excellente" | "Moyenne" | "Faible";
33
+ }
34
+
35
+ export class GoogleBusinessProfileEngine {
36
+ /**
37
+ * Generates Schema.org LocalBusiness JSON-LD structure matching Google specifications
38
+ */
39
+ static generateLocalBusinessSchema(config: GoogleBusinessProfileConfig) {
40
+ const schema: Record<string, any> = {
41
+ "@context": "https://schema.org",
42
+ "@type": config.category || "LocalBusiness",
43
+ "name": config.businessName,
44
+ "address": {
45
+ "@type": "PostalAddress",
46
+ "streetAddress": config.streetAddress,
47
+ "addressLocality": config.addressLocality,
48
+ "postalCode": config.postalCode,
49
+ "addressCountry": config.addressCountry || "FR"
50
+ },
51
+ "telephone": config.telephone,
52
+ "priceRange": config.priceRange || "€€"
53
+ };
54
+
55
+ if (config.latitude && config.longitude) {
56
+ schema.geo = {
57
+ "@type": "GeoCoordinates",
58
+ "latitude": config.latitude,
59
+ "longitude": config.longitude
60
+ };
61
+ }
62
+
63
+ if (config.openingHours && config.openingHours.length > 0) {
64
+ schema.openingHours = config.openingHours;
65
+ }
66
+
67
+ if (config.ratingValue && config.reviewCount) {
68
+ schema.aggregateRating = {
69
+ "@type": "AggregateRating",
70
+ "ratingValue": config.ratingValue.toString(),
71
+ "reviewCount": config.reviewCount.toString(),
72
+ "bestRating": "5",
73
+ "worstRating": "1"
74
+ };
75
+ }
76
+
77
+ if (config.googleMapsUrl || config.placeId) {
78
+ schema.hasMap = config.googleMapsUrl || `https://www.google.com/maps/place/?q=place_id:${config.placeId}`;
79
+ }
80
+
81
+ return schema;
82
+ }
83
+
84
+ /**
85
+ * Generates interactive HTML Badge with Google Review stars and direct Maps link
86
+ */
87
+ static generateGbpBadgeHtml(config: GoogleBusinessProfileConfig): string {
88
+ const stars = "★".repeat(Math.round(config.ratingValue || 5)) + "☆".repeat(5 - Math.round(config.ratingValue || 5));
89
+ const mapsUrl = config.googleMapsUrl || (config.placeId ? `https://www.google.com/maps/place/?q=place_id:${config.placeId}` : "#");
90
+
91
+ return `
92
+ <div style="background:#ffffff;border:1px solid #e2e8f0;border-radius:12px;padding:16px 20px;max-width:420px;box-shadow:0 2px 4px rgba(0,0,0,0.04);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;">
93
+ <div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:8px;">
94
+ <div style="display:flex;align-items:center;gap:8px;">
95
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="#4285F4"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"/></svg>
96
+ <strong style="font-size:15px;color:#0f172a;">${config.businessName}</strong>
97
+ </div>
98
+ <span style="font-size:11px;font-weight:700;color:#166534;background:#dcfce7;padding:2px 8px;border-radius:999px;">Vérifié Google</span>
99
+ </div>
100
+ <div style="font-size:13px;color:#475569;margin-bottom:8px;">
101
+ ${config.streetAddress}, ${config.postalCode} ${config.addressLocality}
102
+ </div>
103
+ <div style="display:flex;align-items:center;justify-content:space-between;border-top:1px solid #f1f5f9;padding-top:10px;">
104
+ <div style="display:flex;align-items:center;gap:6px;">
105
+ <span style="color:#f59e0b;letter-spacing:1px;font-size:14px;">${stars}</span>
106
+ <strong style="font-size:13px;color:#0f172a;">${config.ratingValue || "4.9"}/5</strong>
107
+ <span style="font-size:12px;color:#64748b;">(${config.reviewCount || "128"} avis)</span>
108
+ </div>
109
+ <a href="${mapsUrl}" target="_blank" rel="noopener noreferrer" style="font-size:12px;color:#2563eb;font-weight:600;text-decoration:none;">Voir sur Google Maps &rarr;</a>
110
+ </div>
111
+ </div>
112
+ `.trim();
113
+ }
114
+
115
+ /**
116
+ * Complete Diagnostic & Audit of a Google Business Profile / Local SEO setup
117
+ */
118
+ static auditProfile(config: GoogleBusinessProfileConfig): GbpAuditResult {
119
+ const checks: GbpAuditResult["checks"] = [];
120
+ let score = 0;
121
+
122
+ // 1. Nom d'établissement
123
+ if (config.businessName && config.businessName.length >= 3) {
124
+ checks.push({
125
+ name: "Nom de l'établissement (NAP)",
126
+ status: "pass",
127
+ points: 15,
128
+ description: `Nom correctement configuré : "${config.businessName}".`
129
+ });
130
+ score += 15;
131
+ } else {
132
+ checks.push({
133
+ name: "Nom de l'établissement (NAP)",
134
+ status: "fail",
135
+ points: 15,
136
+ description: "Nom d'établissement manquant ou trop court.",
137
+ recommendation: "Renseignez le nom exact de votre entreprise tel qu'affiché sur Google Maps."
138
+ });
139
+ }
140
+
141
+ // 2. Adresse & Code Postal
142
+ if (config.streetAddress && config.postalCode && config.addressLocality) {
143
+ checks.push({
144
+ name: "Adresse physique complète",
145
+ status: "pass",
146
+ points: 20,
147
+ description: `Adresse géolocalisée : ${config.streetAddress}, ${config.postalCode} ${config.addressLocality}.`
148
+ });
149
+ score += 20;
150
+ } else {
151
+ checks.push({
152
+ name: "Adresse physique complète",
153
+ status: "fail",
154
+ points: 20,
155
+ description: "Adresse ou code postal incomplet.",
156
+ recommendation: "Renseignez la rue, le code postal et la ville pour le ciblage Google Maps Local Pack."
157
+ });
158
+ }
159
+
160
+ // 3. Téléphone
161
+ if (config.telephone && config.telephone.length >= 8) {
162
+ checks.push({
163
+ name: "Téléphone direct vérifié",
164
+ status: "pass",
165
+ points: 10,
166
+ description: `Numéro de contact : ${config.telephone}.`
167
+ });
168
+ score += 10;
169
+ } else {
170
+ checks.push({
171
+ name: "Téléphone direct vérifié",
172
+ status: "warn",
173
+ points: 10,
174
+ description: "Numéro de téléphone absent.",
175
+ recommendation: "Ajoutez un numéro de téléphone fixe ou mobile local pour permettre les appels directs depuis les SERP."
176
+ });
177
+ }
178
+
179
+ // 4. Coordonnées GPS
180
+ if (config.latitude && config.longitude && !isNaN(config.latitude) && !isNaN(config.longitude)) {
181
+ checks.push({
182
+ name: "Coordonnées GPS (Lat / Long)",
183
+ status: "pass",
184
+ points: 15,
185
+ description: `Positionnement précis : ${config.latitude}, ${config.longitude}.`
186
+ });
187
+ score += 15;
188
+ } else {
189
+ checks.push({
190
+ name: "Coordonnées GPS (Lat / Long)",
191
+ status: "fail",
192
+ points: 15,
193
+ description: "Coordonnées GPS manquantes dans le schéma.",
194
+ recommendation: "Ajoutez les coordonnées de latitude/longitude exactes pour optimiser l'affichage dans le Google 3-Pack."
195
+ });
196
+ }
197
+
198
+ // 5. Horaires d'ouverture
199
+ if (config.openingHours && config.openingHours.length > 0) {
200
+ checks.push({
201
+ name: "Horaires d'ouverture",
202
+ status: "pass",
203
+ points: 10,
204
+ description: `${config.openingHours.length} créneau(x) d'ouverture configuré(s).`
205
+ });
206
+ score += 10;
207
+ } else {
208
+ checks.push({
209
+ name: "Horaires d'ouverture",
210
+ status: "warn",
211
+ points: 10,
212
+ description: "Horaires d'ouverture non spécifiés.",
213
+ recommendation: "Indiquez vos horaires (ex: Mo-Fr 09:00-18:00) pour rassurer les clients et éviter le statut 'Fermé'."
214
+ });
215
+ }
216
+
217
+ // 6. Note Google & Volume d'Avis
218
+ const rating = config.ratingValue || 0;
219
+ const reviews = config.reviewCount || 0;
220
+ if (rating >= 4.5 && reviews >= 20) {
221
+ checks.push({
222
+ name: "Réputation & Preuve Sociale",
223
+ status: "pass",
224
+ points: 20,
225
+ description: `Excellente réputation : ${rating}/5 étoiles sur ${reviews} avis.`
226
+ });
227
+ score += 20;
228
+ } else if (rating >= 4.0 && reviews > 0) {
229
+ checks.push({
230
+ name: "Réputation & Preuve Sociale",
231
+ status: "warn",
232
+ points: 10,
233
+ description: `Note de ${rating}/5 avec ${reviews} avis.`,
234
+ recommendation: "Augmentez le volume d'avis certifiés au-delà de 20 avis pour maximiser le taux de conversion."
235
+ });
236
+ score += 10;
237
+ } else {
238
+ checks.push({
239
+ name: "Réputation & Preuve Sociale",
240
+ status: "fail",
241
+ points: 20,
242
+ description: "Avis clients absents ou note inférieure à 4.0.",
243
+ recommendation: "Activez la collecte d'avis clients réels pour afficher les étoiles dorées dans Google."
244
+ });
245
+ }
246
+
247
+ // 7. Lien Google Maps ou Place ID
248
+ if (config.placeId || config.googleMapsUrl) {
249
+ checks.push({
250
+ name: "Lien Google Place ID officiel",
251
+ status: "pass",
252
+ points: 10,
253
+ description: "Lien direct vers la fiche Maps configuré."
254
+ });
255
+ score += 10;
256
+ } else {
257
+ checks.push({
258
+ name: "Lien Google Place ID officiel",
259
+ status: "warn",
260
+ points: 10,
261
+ description: "Place ID Google non renseigné.",
262
+ recommendation: "Associez votre Place ID Google pour faciliter l'indexation par Google Maps."
263
+ });
264
+ }
265
+
266
+ const passedChecks = checks.filter(c => c.status === "pass").length;
267
+ const grade: GbpAuditResult["grade"] = score >= 90 ? "A+" : score >= 75 ? "A" : score >= 60 ? "B" : score >= 40 ? "C" : "D";
268
+ const eligibility: GbpAuditResult["localPackEligibility"] = score >= 80 ? "Excellente" : score >= 50 ? "Moyenne" : "Faible";
269
+
270
+ return {
271
+ score,
272
+ grade,
273
+ passedChecks,
274
+ totalChecks: checks.length,
275
+ checks,
276
+ summary: `Score Local SEO de ${score}/100 (Grade ${grade}) — Éligibilité Google Local 3-Pack : ${eligibility}.`,
277
+ localPackEligibility: eligibility
278
+ };
279
+ }
280
+ }
package/src/index.ts CHANGED
@@ -63,6 +63,8 @@ export * from "./yoast-parity";
63
63
  export * from "./social-growth-suite";
64
64
  export * from "./team-rbac";
65
65
  export * from "./real-reviews-sync";
66
+ export * from "./google-business-profile";
67
+ export * from "./video-youtube-analyzer";
66
68
 
67
69
  import { LynxSeoEngine, type EngineConfig } from "./engine";
68
70
  import { ApiKeyGuardian } from "./auth-key";
@@ -0,0 +1,81 @@
1
+ export interface YouTubeVideoMetadata {
2
+ videoId: string;
3
+ title: string;
4
+ description: string;
5
+ uploadDate?: string;
6
+ duration?: string; // ISO 8601 e.g. "PT5M30S"
7
+ thumbnailUrl?: string;
8
+ embedUrl?: string;
9
+ hasChapters?: boolean;
10
+ chapters?: Array<{ time: number; title: string }>;
11
+ }
12
+
13
+ export class VideoYouTubeAnalyzer {
14
+ /**
15
+ * Extracts YouTube Video ID from any standard URL or iframe string
16
+ */
17
+ static extractVideoId(urlOrIframe: string): string | null {
18
+ const regExp = /(?:youtube(?:-nocookie)?\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/;
19
+ const match = urlOrIframe.match(regExp);
20
+ return match ? match[1] : null;
21
+ }
22
+
23
+ /**
24
+ * Generates Schema.org VideoObject JSON-LD for rich snippets on Google Video Carousel
25
+ */
26
+ static generateVideoObjectSchema(meta: YouTubeVideoMetadata) {
27
+ const videoId = meta.videoId;
28
+ const thumbnail = meta.thumbnailUrl || `https://img.youtube.com/vi/${videoId}/maxresdefault.jpg`;
29
+ const embedUrl = meta.embedUrl || `https://www.youtube.com/embed/${videoId}`;
30
+
31
+ const schema: Record<string, any> = {
32
+ "@context": "https://schema.org",
33
+ "@type": "VideoObject",
34
+ "name": meta.title,
35
+ "description": meta.description,
36
+ "thumbnailUrl": [thumbnail],
37
+ "uploadDate": meta.uploadDate || new Date().toISOString().split("T")[0],
38
+ "embedUrl": embedUrl,
39
+ "contentUrl": `https://www.youtube.com/watch?v=${videoId}`
40
+ };
41
+
42
+ if (meta.duration) {
43
+ schema.duration = meta.duration;
44
+ }
45
+
46
+ if (meta.chapters && meta.chapters.length > 0) {
47
+ schema.hasPart = meta.chapters.map(c => ({
48
+ "@type": "Clip",
49
+ "name": c.title,
50
+ "startOffset": c.time,
51
+ "url": `https://www.youtube.com/watch?v=${videoId}&t=${c.time}s`
52
+ }));
53
+ }
54
+
55
+ return schema;
56
+ }
57
+
58
+ /**
59
+ * Generates responsive, lazy-loaded, SEO-optimized HTML embed with Schema markup
60
+ */
61
+ static generateSeoVideoEmbedHtml(meta: YouTubeVideoMetadata): string {
62
+ const videoId = meta.videoId;
63
+ const jsonLd = JSON.stringify(this.generateVideoObjectSchema(meta));
64
+
65
+ return `
66
+ <div class="lynxseo-video-wrapper" style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;border-radius:12px;box-shadow:0 4px 12px rgba(0,0,0,0.08);margin:24px 0;">
67
+ <iframe
68
+ src="https://www.youtube.com/embed/${videoId}"
69
+ title="${meta.title.replace(/"/g, '&quot;')}"
70
+ style="position:absolute;top:0;left:0;width:100%;height:100%;border:0;"
71
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
72
+ allowfullscreen
73
+ loading="lazy">
74
+ </iframe>
75
+ </div>
76
+ <script type="application/ld+json">
77
+ ${jsonLd}
78
+ </script>
79
+ `.trim();
80
+ }
81
+ }