lynkow 3.8.69 → 3.8.71

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.
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Official TypeScript SDK for [Lynkow](https://lynkow.com) Headless CMS.
4
4
 
5
+ > **FOR LLMs:** Full documentation at [lynkow.com/docs](https://lynkow.com/docs). **Start with the [Complete Integration Checklist](https://lynkow.com/docs/getting-started/integration-checklist)** — it lists every feature to implement with links to detailed guides. Machine-readable: [`/llms.txt`](https://lynkow.com/docs/llms.txt) (index), [`/llms-full.txt`](https://lynkow.com/docs/llms-full.txt) (complete content). Append `.md` to any page URL for Markdown. Search: `GET https://lynkow.com/docs/api/search?q={query}`
6
+
5
7
  ## Features
6
8
 
7
9
  - **Zero dependencies** - Uses native `fetch()` API
package/dist/index.d.mts CHANGED
@@ -1224,75 +1224,212 @@ declare class PathsService extends BaseService {
1224
1224
  clearCache(): void;
1225
1225
  }
1226
1226
 
1227
+ /**
1228
+ * A single search result (hit) returned by Lynkow Instant Search.
1229
+ *
1230
+ * Contains article metadata, URL path, and optional highlighted matches.
1231
+ * Only published content appears in search results.
1232
+ */
1227
1233
  interface SearchHit {
1234
+ /** Content UUID */
1228
1235
  id: string;
1236
+ /** Article title */
1229
1237
  title: string;
1238
+ /** URL slug */
1230
1239
  slug: string;
1240
+ /** Short summary / excerpt */
1231
1241
  excerpt: string;
1242
+ /** SEO meta title */
1232
1243
  metaTitle: string;
1244
+ /** SEO meta description */
1233
1245
  metaDescription: string;
1246
+ /** Content locale code (e.g. `'fr'`, `'en'`) */
1234
1247
  locale: string;
1248
+ /** Full URL path including locale and category prefix (e.g. `'/fr/guides/forms'`) */
1235
1249
  path: string;
1250
+ /** Content type (e.g. `'post'`) */
1236
1251
  type: string;
1252
+ /** Categories assigned to this content */
1237
1253
  categories: Array<{
1238
1254
  name: string;
1239
1255
  slug: string;
1240
1256
  }>;
1257
+ /** Tags assigned to this content */
1241
1258
  tags: Array<{
1242
1259
  name: string;
1243
1260
  slug: string;
1244
1261
  }>;
1262
+ /** Full name of the content author */
1245
1263
  authorName: string;
1264
+ /** Featured image URL, or `null` if none */
1246
1265
  featuredImage: string | null;
1266
+ /** Publication date as Unix timestamp (seconds) */
1247
1267
  publishedAt: number;
1268
+ /** Last update date as Unix timestamp (seconds) */
1248
1269
  updatedAt: number;
1270
+ /**
1271
+ * Highlighted matches with `<em>` tags around matching terms.
1272
+ * Only present when the search engine returns formatted results.
1273
+ * Keys match the field names (e.g. `title`, `excerpt`, `body`).
1274
+ *
1275
+ * @example
1276
+ * ```typescript
1277
+ * hit._formatted?.title // "Getting Started with <em>Pagination</em>"
1278
+ * ```
1279
+ */
1249
1280
  _formatted?: Record<string, string>;
1250
1281
  }
1282
+ /**
1283
+ * Response from `lynkow.search.search()`.
1284
+ *
1285
+ * Contains an array of matching articles and pagination metadata.
1286
+ */
1251
1287
  interface SearchResponse {
1288
+ /** Array of matching articles, ordered by relevance */
1252
1289
  data: SearchHit[];
1290
+ /** Pagination and query metadata */
1253
1291
  meta: {
1292
+ /** Total number of matching results across all pages */
1254
1293
  total: number;
1294
+ /** Current page number (1-based) */
1255
1295
  page: number;
1296
+ /** Total number of pages */
1256
1297
  totalPages: number;
1298
+ /** Number of results per page */
1257
1299
  perPage: number;
1300
+ /** The search query as received */
1258
1301
  query: string;
1302
+ /** Search engine processing time in milliseconds */
1259
1303
  processingTimeMs: number;
1260
1304
  };
1261
1305
  }
1306
+ /**
1307
+ * Options for `lynkow.search.search()`.
1308
+ *
1309
+ * All filters are optional. When omitted, searches across all published
1310
+ * content in all locales.
1311
+ */
1262
1312
  interface SearchOptions extends BaseRequestOptions {
1313
+ /** Filter by locale code (e.g. `'fr'`, `'en'`). Omit to search all locales. */
1263
1314
  locale?: string;
1315
+ /** Filter by category slug (e.g. `'guides'`). Omit to search all categories. */
1264
1316
  category?: string;
1317
+ /** Filter by tag slug (e.g. `'featured'`). Omit to search all tags. */
1265
1318
  tag?: string;
1319
+ /** Page number (1-based). Defaults to `1`. */
1266
1320
  page?: number;
1321
+ /** Results per page (1--100). Defaults to `20`. */
1267
1322
  limit?: number;
1268
1323
  }
1324
+ /**
1325
+ * Configuration for client-side direct search.
1326
+ *
1327
+ * Returned by `lynkow.search.getConfig()`. Use these values to initialize
1328
+ * a search client in the browser for instant autocomplete without
1329
+ * round-tripping through your server.
1330
+ */
1269
1331
  interface SearchConfig {
1332
+ /** Public search host URL (e.g. `'https://search.lynkow.com'`) */
1270
1333
  host: string;
1334
+ /** Short-lived tenant token (JWT, 1-hour expiry) scoped to your site's index */
1271
1335
  apiKey: string;
1336
+ /** Your site's search index name */
1272
1337
  indexName: string;
1273
1338
  }
1274
1339
  /**
1275
- * Service for full-text search across published content.
1340
+ * Lynkow Instant Search service.
1341
+ *
1342
+ * Accessible via `lynkow.search`. Provides full-text search with typo
1343
+ * tolerance across all published content. Results are not cached (search
1344
+ * queries are dynamic by nature).
1345
+ *
1346
+ * Search must be enabled in the admin dashboard (**Settings > SEO > Search**)
1347
+ * before it can be used. When disabled, all methods return a 503 error.
1276
1348
  *
1277
1349
  * @example
1278
1350
  * ```typescript
1279
- * // Server-side search via Lynkow API
1280
- * const results = await lynkow.search.search('pagination', { locale: 'en' })
1351
+ * const lynkow = createClient({ siteId: '...' })
1352
+ *
1353
+ * // Search with filters
1354
+ * const { data, meta } = await lynkow.search.search('pagination', {
1355
+ * locale: 'en',
1356
+ * category: 'guides',
1357
+ * limit: 10,
1358
+ * })
1281
1359
  *
1282
- * // Get config for client-side direct search
1283
- * const config = await lynkow.search.getConfig()
1284
- * // Use config.host, config.apiKey, config.indexName with react-instantsearch
1360
+ * // Iterate results
1361
+ * for (const hit of data) {
1362
+ * console.log(hit.title, hit.path, hit._formatted?.title)
1363
+ * }
1285
1364
  * ```
1286
1365
  */
1287
1366
  declare class SearchService extends BaseService {
1288
1367
  /**
1289
- * Search published content.
1368
+ * Search published content with typo tolerance.
1369
+ *
1370
+ * Queries the search index for articles matching the given query string.
1371
+ * Results are ordered by relevance and include highlighted matches in
1372
+ * the `_formatted` field.
1373
+ *
1374
+ * @param query - The search query string. Typos are handled automatically
1375
+ * (e.g. `'pagniation'` finds articles about pagination).
1376
+ * @param options - Optional filters and pagination:
1377
+ * - `locale` — filter by locale code (e.g. `'fr'`)
1378
+ * - `category` — filter by category slug (e.g. `'guides'`)
1379
+ * - `tag` — filter by tag slug (e.g. `'featured'`)
1380
+ * - `page` — page number, 1-based (default: `1`)
1381
+ * - `limit` — results per page, 1--100 (default: `20`)
1382
+ * @returns A `SearchResponse` containing `data` (array of `SearchHit`)
1383
+ * and `meta` (pagination info with total, page, totalPages, perPage,
1384
+ * query, processingTimeMs)
1385
+ * @throws {LynkowError} With code `'NETWORK_ERROR'` if the API is unreachable
1386
+ * @throws {LynkowError} With status `503` if search is not enabled for this site
1387
+ *
1388
+ * @example
1389
+ * ```typescript
1390
+ * // Basic search
1391
+ * const results = await lynkow.search.search('forms')
1392
+ *
1393
+ * // With filters
1394
+ * const results = await lynkow.search.search('formulaire', {
1395
+ * locale: 'fr',
1396
+ * category: 'guides',
1397
+ * page: 1,
1398
+ * limit: 5,
1399
+ * })
1400
+ *
1401
+ * // Access highlighted results
1402
+ * results.data.forEach(hit => {
1403
+ * console.log(hit._formatted?.title || hit.title)
1404
+ * })
1405
+ * ```
1290
1406
  */
1291
1407
  search(query: string, options?: SearchOptions): Promise<SearchResponse>;
1292
1408
  /**
1293
- * Get search config for client-side direct search.
1294
- * Returns host URL, tenant token, and index name.
1295
- * Cached for 10 minutes.
1409
+ * Get search configuration for client-side direct search.
1410
+ *
1411
+ * Returns the search host URL, a short-lived tenant token (JWT, 1-hour
1412
+ * expiry), and the index name for your site. Use these values to query
1413
+ * the search engine directly from the browser without round-tripping
1414
+ * through your server.
1415
+ *
1416
+ * The response is cached for 10 minutes. Tenant tokens expire after
1417
+ * 1 hour — for long-lived pages, call this method periodically to
1418
+ * refresh the token.
1419
+ *
1420
+ * @param options - Base request options (custom fetch options)
1421
+ * @returns A `SearchConfig` with `host`, `apiKey` (tenant token), and `indexName`
1422
+ * @throws {LynkowError} With status `503` if search is not enabled for this site
1423
+ *
1424
+ * @example
1425
+ * ```typescript
1426
+ * const config = await lynkow.search.getConfig()
1427
+ * // {
1428
+ * // host: 'https://search.lynkow.com',
1429
+ * // apiKey: 'eyJhbGciOi...',
1430
+ * // indexName: 'site_abc123_def4_...'
1431
+ * // }
1432
+ * ```
1296
1433
  */
1297
1434
  getConfig(options?: BaseRequestOptions): Promise<SearchConfig>;
1298
1435
  }
package/dist/index.d.ts CHANGED
@@ -1224,75 +1224,212 @@ declare class PathsService extends BaseService {
1224
1224
  clearCache(): void;
1225
1225
  }
1226
1226
 
1227
+ /**
1228
+ * A single search result (hit) returned by Lynkow Instant Search.
1229
+ *
1230
+ * Contains article metadata, URL path, and optional highlighted matches.
1231
+ * Only published content appears in search results.
1232
+ */
1227
1233
  interface SearchHit {
1234
+ /** Content UUID */
1228
1235
  id: string;
1236
+ /** Article title */
1229
1237
  title: string;
1238
+ /** URL slug */
1230
1239
  slug: string;
1240
+ /** Short summary / excerpt */
1231
1241
  excerpt: string;
1242
+ /** SEO meta title */
1232
1243
  metaTitle: string;
1244
+ /** SEO meta description */
1233
1245
  metaDescription: string;
1246
+ /** Content locale code (e.g. `'fr'`, `'en'`) */
1234
1247
  locale: string;
1248
+ /** Full URL path including locale and category prefix (e.g. `'/fr/guides/forms'`) */
1235
1249
  path: string;
1250
+ /** Content type (e.g. `'post'`) */
1236
1251
  type: string;
1252
+ /** Categories assigned to this content */
1237
1253
  categories: Array<{
1238
1254
  name: string;
1239
1255
  slug: string;
1240
1256
  }>;
1257
+ /** Tags assigned to this content */
1241
1258
  tags: Array<{
1242
1259
  name: string;
1243
1260
  slug: string;
1244
1261
  }>;
1262
+ /** Full name of the content author */
1245
1263
  authorName: string;
1264
+ /** Featured image URL, or `null` if none */
1246
1265
  featuredImage: string | null;
1266
+ /** Publication date as Unix timestamp (seconds) */
1247
1267
  publishedAt: number;
1268
+ /** Last update date as Unix timestamp (seconds) */
1248
1269
  updatedAt: number;
1270
+ /**
1271
+ * Highlighted matches with `<em>` tags around matching terms.
1272
+ * Only present when the search engine returns formatted results.
1273
+ * Keys match the field names (e.g. `title`, `excerpt`, `body`).
1274
+ *
1275
+ * @example
1276
+ * ```typescript
1277
+ * hit._formatted?.title // "Getting Started with <em>Pagination</em>"
1278
+ * ```
1279
+ */
1249
1280
  _formatted?: Record<string, string>;
1250
1281
  }
1282
+ /**
1283
+ * Response from `lynkow.search.search()`.
1284
+ *
1285
+ * Contains an array of matching articles and pagination metadata.
1286
+ */
1251
1287
  interface SearchResponse {
1288
+ /** Array of matching articles, ordered by relevance */
1252
1289
  data: SearchHit[];
1290
+ /** Pagination and query metadata */
1253
1291
  meta: {
1292
+ /** Total number of matching results across all pages */
1254
1293
  total: number;
1294
+ /** Current page number (1-based) */
1255
1295
  page: number;
1296
+ /** Total number of pages */
1256
1297
  totalPages: number;
1298
+ /** Number of results per page */
1257
1299
  perPage: number;
1300
+ /** The search query as received */
1258
1301
  query: string;
1302
+ /** Search engine processing time in milliseconds */
1259
1303
  processingTimeMs: number;
1260
1304
  };
1261
1305
  }
1306
+ /**
1307
+ * Options for `lynkow.search.search()`.
1308
+ *
1309
+ * All filters are optional. When omitted, searches across all published
1310
+ * content in all locales.
1311
+ */
1262
1312
  interface SearchOptions extends BaseRequestOptions {
1313
+ /** Filter by locale code (e.g. `'fr'`, `'en'`). Omit to search all locales. */
1263
1314
  locale?: string;
1315
+ /** Filter by category slug (e.g. `'guides'`). Omit to search all categories. */
1264
1316
  category?: string;
1317
+ /** Filter by tag slug (e.g. `'featured'`). Omit to search all tags. */
1265
1318
  tag?: string;
1319
+ /** Page number (1-based). Defaults to `1`. */
1266
1320
  page?: number;
1321
+ /** Results per page (1--100). Defaults to `20`. */
1267
1322
  limit?: number;
1268
1323
  }
1324
+ /**
1325
+ * Configuration for client-side direct search.
1326
+ *
1327
+ * Returned by `lynkow.search.getConfig()`. Use these values to initialize
1328
+ * a search client in the browser for instant autocomplete without
1329
+ * round-tripping through your server.
1330
+ */
1269
1331
  interface SearchConfig {
1332
+ /** Public search host URL (e.g. `'https://search.lynkow.com'`) */
1270
1333
  host: string;
1334
+ /** Short-lived tenant token (JWT, 1-hour expiry) scoped to your site's index */
1271
1335
  apiKey: string;
1336
+ /** Your site's search index name */
1272
1337
  indexName: string;
1273
1338
  }
1274
1339
  /**
1275
- * Service for full-text search across published content.
1340
+ * Lynkow Instant Search service.
1341
+ *
1342
+ * Accessible via `lynkow.search`. Provides full-text search with typo
1343
+ * tolerance across all published content. Results are not cached (search
1344
+ * queries are dynamic by nature).
1345
+ *
1346
+ * Search must be enabled in the admin dashboard (**Settings > SEO > Search**)
1347
+ * before it can be used. When disabled, all methods return a 503 error.
1276
1348
  *
1277
1349
  * @example
1278
1350
  * ```typescript
1279
- * // Server-side search via Lynkow API
1280
- * const results = await lynkow.search.search('pagination', { locale: 'en' })
1351
+ * const lynkow = createClient({ siteId: '...' })
1352
+ *
1353
+ * // Search with filters
1354
+ * const { data, meta } = await lynkow.search.search('pagination', {
1355
+ * locale: 'en',
1356
+ * category: 'guides',
1357
+ * limit: 10,
1358
+ * })
1281
1359
  *
1282
- * // Get config for client-side direct search
1283
- * const config = await lynkow.search.getConfig()
1284
- * // Use config.host, config.apiKey, config.indexName with react-instantsearch
1360
+ * // Iterate results
1361
+ * for (const hit of data) {
1362
+ * console.log(hit.title, hit.path, hit._formatted?.title)
1363
+ * }
1285
1364
  * ```
1286
1365
  */
1287
1366
  declare class SearchService extends BaseService {
1288
1367
  /**
1289
- * Search published content.
1368
+ * Search published content with typo tolerance.
1369
+ *
1370
+ * Queries the search index for articles matching the given query string.
1371
+ * Results are ordered by relevance and include highlighted matches in
1372
+ * the `_formatted` field.
1373
+ *
1374
+ * @param query - The search query string. Typos are handled automatically
1375
+ * (e.g. `'pagniation'` finds articles about pagination).
1376
+ * @param options - Optional filters and pagination:
1377
+ * - `locale` — filter by locale code (e.g. `'fr'`)
1378
+ * - `category` — filter by category slug (e.g. `'guides'`)
1379
+ * - `tag` — filter by tag slug (e.g. `'featured'`)
1380
+ * - `page` — page number, 1-based (default: `1`)
1381
+ * - `limit` — results per page, 1--100 (default: `20`)
1382
+ * @returns A `SearchResponse` containing `data` (array of `SearchHit`)
1383
+ * and `meta` (pagination info with total, page, totalPages, perPage,
1384
+ * query, processingTimeMs)
1385
+ * @throws {LynkowError} With code `'NETWORK_ERROR'` if the API is unreachable
1386
+ * @throws {LynkowError} With status `503` if search is not enabled for this site
1387
+ *
1388
+ * @example
1389
+ * ```typescript
1390
+ * // Basic search
1391
+ * const results = await lynkow.search.search('forms')
1392
+ *
1393
+ * // With filters
1394
+ * const results = await lynkow.search.search('formulaire', {
1395
+ * locale: 'fr',
1396
+ * category: 'guides',
1397
+ * page: 1,
1398
+ * limit: 5,
1399
+ * })
1400
+ *
1401
+ * // Access highlighted results
1402
+ * results.data.forEach(hit => {
1403
+ * console.log(hit._formatted?.title || hit.title)
1404
+ * })
1405
+ * ```
1290
1406
  */
1291
1407
  search(query: string, options?: SearchOptions): Promise<SearchResponse>;
1292
1408
  /**
1293
- * Get search config for client-side direct search.
1294
- * Returns host URL, tenant token, and index name.
1295
- * Cached for 10 minutes.
1409
+ * Get search configuration for client-side direct search.
1410
+ *
1411
+ * Returns the search host URL, a short-lived tenant token (JWT, 1-hour
1412
+ * expiry), and the index name for your site. Use these values to query
1413
+ * the search engine directly from the browser without round-tripping
1414
+ * through your server.
1415
+ *
1416
+ * The response is cached for 10 minutes. Tenant tokens expire after
1417
+ * 1 hour — for long-lived pages, call this method periodically to
1418
+ * refresh the token.
1419
+ *
1420
+ * @param options - Base request options (custom fetch options)
1421
+ * @returns A `SearchConfig` with `host`, `apiKey` (tenant token), and `indexName`
1422
+ * @throws {LynkowError} With status `503` if search is not enabled for this site
1423
+ *
1424
+ * @example
1425
+ * ```typescript
1426
+ * const config = await lynkow.search.getConfig()
1427
+ * // {
1428
+ * // host: 'https://search.lynkow.com',
1429
+ * // apiKey: 'eyJhbGciOi...',
1430
+ * // indexName: 'site_abc123_def4_...'
1431
+ * // }
1432
+ * ```
1296
1433
  */
1297
1434
  getConfig(options?: BaseRequestOptions): Promise<SearchConfig>;
1298
1435
  }