lynkow 1.33.0 → 1.40.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.
package/README.md CHANGED
@@ -39,7 +39,7 @@ const lynkow = createClient({
39
39
  // Fetch blog posts
40
40
  const { data: posts, meta } = await lynkow.contents.list({
41
41
  page: 1,
42
- perPage: 10,
42
+ limit: 10,
43
43
  category: 'tech',
44
44
  })
45
45
 
@@ -153,7 +153,7 @@ The SDK is isomorphic and works on both browser and server environments. Some fe
153
153
  // List contents with filters
154
154
  const { data, meta } = await lynkow.contents.list({
155
155
  page: 1,
156
- perPage: 10,
156
+ limit: 10,
157
157
  category: 'tech',
158
158
  tag: 'javascript',
159
159
  search: 'tutorial',
@@ -169,15 +169,15 @@ const content = await lynkow.contents.getBySlug('my-article')
169
169
 
170
170
  ```typescript
171
171
  // List all categories
172
- const { data } = await lynkow.categories.list()
172
+ const { categories } = await lynkow.categories.list()
173
173
 
174
174
  // Get category tree (nested)
175
- const { data: tree } = await lynkow.categories.tree()
175
+ const { tree } = await lynkow.categories.tree()
176
176
 
177
177
  // Get category with its contents
178
178
  const { category, contents } = await lynkow.categories.getBySlug('tech', {
179
179
  page: 1,
180
- perPage: 10,
180
+ limit: 10,
181
181
  })
182
182
  ```
183
183
 
@@ -248,7 +248,7 @@ const result = await lynkow.forms.submit(
248
248
  // List approved reviews
249
249
  const { data, meta } = await lynkow.reviews.list({
250
250
  minRating: 4,
251
- perPage: 10,
251
+ limit: 10,
252
252
  })
253
253
 
254
254
  // Get review settings
package/dist/index.d.mts CHANGED
@@ -29,6 +29,8 @@ type Cache = ReturnType<typeof createCache>;
29
29
  interface InternalConfig {
30
30
  siteId: string;
31
31
  baseUrl: string;
32
+ /** Optional publishable key sent as the `X-Lynkow-Pk` header on every storefront API request. */
33
+ publishableKey?: string;
32
34
  locale?: string;
33
35
  fetchOptions: RequestInit;
34
36
  /** Optional cache manager for caching responses */
@@ -105,7 +107,7 @@ declare class ContentsService extends BaseService {
105
107
  * 5 minutes per unique filter combination.
106
108
  *
107
109
  * @param filters - Optional filters to narrow down results:
108
- * - `page` / `limit` pagination (defaults to page 1, 15 items)
110
+ * - `page` / `limit` - pagination (defaults to page 1, 20 items)
109
111
  * - `category` — filter by category slug (e.g. `'tech'`, `'news'`)
110
112
  * - `tag` — filter by tag slug (e.g. `'featured'`)
111
113
  * - `search` — full-text search across title and body
@@ -185,10 +187,10 @@ declare class ContentsService extends BaseService {
185
187
  * const lynkow = createClient({ siteId: '...' })
186
188
  *
187
189
  * // Flat list with content counts
188
- * const { data } = await lynkow.categories.list()
190
+ * const { categories } = await lynkow.categories.list()
189
191
  *
190
192
  * // Hierarchical tree
191
- * const { data } = await lynkow.categories.tree()
193
+ * const { tree } = await lynkow.categories.tree()
192
194
  *
193
195
  * // Category detail with paginated articles
194
196
  * const { category, contents } = await lynkow.categories.getBySlug('tech')
@@ -201,13 +203,13 @@ declare class CategoriesService extends BaseService {
201
203
  * Cached for 5 minutes per locale.
202
204
  *
203
205
  * @param options - Request options; use `locale` to fetch localized category names
204
- * @returns An object containing `data` (array of `CategoryWithCount` with name, slug, path,
206
+ * @returns An object containing `categories` (array of `CategoryWithCount` with name, slug, path,
205
207
  * contentCount, image, description), `blogUrlMode` (`'flat'` or `'nested'`), and `locale`
206
208
  *
207
209
  * @example
208
210
  * ```typescript
209
- * const { data, blogUrlMode } = await lynkow.categories.list()
210
- * data.forEach(cat => {
211
+ * const { categories, blogUrlMode } = await lynkow.categories.list()
212
+ * categories.forEach(cat => {
211
213
  * console.log(`${cat.name} (${cat.contentCount} articles)`)
212
214
  * })
213
215
  * ```
@@ -220,14 +222,14 @@ declare class CategoriesService extends BaseService {
220
222
  * hierarchical navigation or breadcrumbs. Cached for 5 minutes per locale.
221
223
  *
222
224
  * @param options - Request options; use `locale` to fetch localized category names
223
- * @returns An object containing `data` (array of `CategoryTreeNode`, each with a
225
+ * @returns An object containing `tree` (array of `CategoryTreeNode`, each with a
224
226
  * `children` array of nested subcategories), `blogUrlMode`, and `locale`
225
227
  *
226
228
  * @example
227
229
  * ```typescript
228
- * const { data } = await lynkow.categories.tree()
230
+ * const { tree } = await lynkow.categories.tree()
229
231
  * // Iterate root categories and their children
230
- * data.forEach(root => {
232
+ * tree.forEach(root => {
231
233
  * console.log(root.name)
232
234
  * root.children.forEach(child => {
233
235
  * console.log(` - ${child.name}`)
@@ -1800,11 +1802,22 @@ interface LynkowConfig {
1800
1802
  * UUID of the Lynkow site to connect to.
1801
1803
  * Found in the admin dashboard under Site Settings.
1802
1804
  * Must be a valid UUID v4 format (lowercase hex with dashes).
1803
- * Sent as the `X-Site-Id` header on every API request.
1805
+ * Interpolated into the path of every request (`/storefront/:siteId/...`)
1806
+ * to identify the tenant. It is not sent as a header.
1804
1807
  *
1805
1808
  * @example '550e8400-e29b-41d4-a716-446655440000'
1806
1809
  */
1807
1810
  siteId: string;
1811
+ /**
1812
+ * Optional publishable key that identifies this client to the Lynkow
1813
+ * storefront API. Copied from the admin dashboard under Site Settings.
1814
+ * It has the form `lkw_pk_` followed by 24 characters.
1815
+ * When set, it is sent as the `X-Lynkow-Pk` header on every storefront API request the client makes.
1816
+ * Optional on CMS content routes; required on future commerce routes.
1817
+ *
1818
+ * @example 'lkw_pk_9f8g7h6j5k4w3m2n1p0qrstv'
1819
+ */
1820
+ publishableKey?: string;
1808
1821
  /**
1809
1822
  * Base URL of the Lynkow API.
1810
1823
  * Must not include a trailing slash.
@@ -2356,10 +2369,11 @@ interface JsonLdGraphConfig {
2356
2369
  */
2357
2370
  interface Category {
2358
2371
  /**
2359
- * Unique numeric category ID. Auto-incremented.
2360
- * Use this for API calls like `GET /public/categories/:id`.
2372
+ * Unique category ID (UUID, e.g. `'550e8400-e29b-41d4-a716-446655440000'`).
2373
+ * Stable across renames and slug changes, so it is safe to use as a cache
2374
+ * or list key. Public category endpoints are addressed by slug, not by ID.
2361
2375
  */
2362
- id: number;
2376
+ id: string;
2363
2377
  /**
2364
2378
  * Category display name in the requested locale (e.g. `'Technology'`, `'Tutorials'`).
2365
2379
  * Max 255 characters.
@@ -2381,13 +2395,13 @@ interface Category {
2381
2395
  * - `'standard'`: articles use the TipTap rich text editor (stored in `Content.body`)
2382
2396
  * - `'structured'`: articles use custom fields defined by the category's schema (stored in `Content.customData`)
2383
2397
  *
2384
- * Only present in detail responses (`GET /public/categories/:id`), not in lightweight
2398
+ * Only present in detail responses (`GET /storefront/categories/:id`), not in lightweight
2385
2399
  * list projections (e.g. when categories are embedded in content responses).
2386
2400
  */
2387
2401
  contentMode?: 'standard' | 'structured';
2388
2402
  /**
2389
2403
  * Parent category in the hierarchy. Present when the API eagerly loads
2390
- * the parent relation (e.g. `GET /public/contents/slug/:slug` returns
2404
+ * the parent relation (e.g. `GET /storefront/contents/slug/:slug` returns
2391
2405
  * each category's parent so consumers can build a breadcrumb in a single
2392
2406
  * request). `null` for root-level categories. `undefined` when the
2393
2407
  * endpoint did not include parent data.
@@ -2400,7 +2414,7 @@ interface Category {
2400
2414
  }
2401
2415
  /**
2402
2416
  * Category with URL path, description, image, and content count.
2403
- * Returned by list endpoints (`GET /public/categories`).
2417
+ * Returned by list endpoints (`GET /storefront/categories`).
2404
2418
  *
2405
2419
  * Extends {@link Category} with display-oriented fields useful for rendering
2406
2420
  * category listing pages, navigation menus, and sidebar widgets.
@@ -2436,6 +2450,13 @@ interface CategoryWithCount extends Category {
2436
2450
  * Does not include content from child categories — each category counts independently.
2437
2451
  */
2438
2452
  contentCount: number;
2453
+ /**
2454
+ * Manual sort position configured in the admin. Defaults to `0`.
2455
+ * List and tree endpoints return categories sorted alphabetically by name;
2456
+ * use this value to apply the admin-defined ordering client-side
2457
+ * (lower values first).
2458
+ */
2459
+ displayOrder: number;
2439
2460
  /**
2440
2461
  * CDN-optimized image variants of the category image at multiple preset sizes.
2441
2462
  * `undefined` when no image is set or the site has no image transformations configured.
@@ -2470,18 +2491,18 @@ interface CategoryWithCount extends Category {
2470
2491
  }
2471
2492
  /**
2472
2493
  * Full category detail with parent relationship.
2473
- * Returned by single-category endpoints (`GET /public/categories/:id`).
2494
+ * Returned by single-category endpoints (`GET /storefront/categories/:id`).
2474
2495
  *
2475
2496
  * Extends {@link CategoryWithCount} with the parent category reference,
2476
2497
  * enabling you to reconstruct the category hierarchy.
2477
2498
  */
2478
2499
  interface CategoryDetail extends CategoryWithCount {
2479
2500
  /**
2480
- * ID of the parent category, or `null` for root-level categories.
2501
+ * UUID of the parent category, or `null` for root-level categories.
2481
2502
  * Use this to build breadcrumbs or reconstruct the category tree.
2482
2503
  * Categories support unlimited nesting depth.
2483
2504
  */
2484
- parentId: number | null;
2505
+ parentId: string | null;
2485
2506
  /**
2486
2507
  * Category-level JSON-LD cascade nodes. Inherited by every content
2487
2508
  * attached to the category. Merged server-side into the content's
@@ -2497,7 +2518,7 @@ interface CategoryDetail extends CategoryWithCount {
2497
2518
  jsonLdExclusions?: string[];
2498
2519
  }
2499
2520
  /**
2500
- * Recursive category tree node, returned by the tree endpoint (`GET /public/categories/tree`).
2521
+ * Recursive category tree node, returned by the tree endpoint (`GET /storefront/categories/tree`).
2501
2522
  *
2502
2523
  * Each node contains its full {@link CategoryWithCount} data plus a `children` array
2503
2524
  * of nested sub-categories. The tree is pre-sorted by the API.
@@ -2830,15 +2851,15 @@ interface TipTapNode {
2830
2851
  type ContentBody = string;
2831
2852
  /**
2832
2853
  * Lightweight content representation returned in paginated list endpoints
2833
- * (`GET /public/contents`).
2854
+ * (`GET /storefront/contents`).
2834
2855
  *
2835
2856
  * Omits the full body, SEO fields, and relations to minimize payload size.
2836
- * Use `Content` (from `GET /public/contents/:idOrSlug`) for the complete data.
2857
+ * Use `Content` (from `GET /storefront/contents/:idOrSlug`) for the complete data.
2837
2858
  */
2838
2859
  interface ContentSummary {
2839
2860
  /**
2840
2861
  * Unique numeric content ID. Auto-incremented.
2841
- * Use this for API calls like `GET /public/contents/:id`.
2862
+ * Use this for API calls like `GET /storefront/contents/:id`.
2842
2863
  */
2843
2864
  id: number;
2844
2865
  /**
@@ -2849,7 +2870,7 @@ interface ContentSummary {
2849
2870
  /**
2850
2871
  * URL-friendly slug, unique within the site for this locale.
2851
2872
  * Lowercase, hyphenated (e.g. `'my-article-title'`). Max 500 characters.
2852
- * Can be used instead of `id` in API calls: `GET /public/contents/:slug`.
2873
+ * Can be used instead of `id` in API calls: `GET /storefront/contents/:slug`.
2853
2874
  */
2854
2875
  slug: string;
2855
2876
  /**
@@ -2909,7 +2930,7 @@ interface ContentSummary {
2909
2930
  }
2910
2931
  /**
2911
2932
  * Full content item with body, SEO metadata, structured data, and relations.
2912
- * Returned by single-content endpoints (`GET /public/contents/:idOrSlug`).
2933
+ * Returned by single-content endpoints (`GET /storefront/contents/:idOrSlug`).
2913
2934
  *
2914
2935
  * Extends {@link ContentSummary} with all the fields omitted from list responses.
2915
2936
  */
@@ -3179,19 +3200,19 @@ interface Alternate {
3179
3200
  * Lightweight page representation returned in list endpoints.
3180
3201
  * Contains basic identification and routing information.
3181
3202
  *
3182
- * Use {@link Page} (from `GET /public/pages/:idOrSlug`) for the full page
3203
+ * Use {@link Page} (from `GET /storefront/pages/:idOrSlug`) for the full page
3183
3204
  * including resolved data, SEO settings, and alternates.
3184
3205
  */
3185
3206
  interface PageSummary {
3186
3207
  /**
3187
3208
  * Unique numeric page ID. Auto-incremented.
3188
- * Use this for API calls like `GET /public/pages/:id`.
3209
+ * Use this for API calls like `GET /storefront/pages/:id`.
3189
3210
  */
3190
3211
  id: number;
3191
3212
  /**
3192
3213
  * URL-friendly slug, unique within the site for this locale.
3193
3214
  * Lowercase, hyphenated (e.g. `'about-us'`). Max 255 characters.
3194
- * Can be used instead of `id` in API calls: `GET /public/pages/:slug`.
3215
+ * Can be used instead of `id` in API calls: `GET /storefront/pages/:slug`.
3195
3216
  */
3196
3217
  slug: string;
3197
3218
  /**
@@ -3220,7 +3241,7 @@ interface PageSummary {
3220
3241
  }
3221
3242
  /**
3222
3243
  * Full page with resolved data sources, SEO settings, and locale alternates.
3223
- * Returned by single-page endpoints (`GET /public/pages/:idOrSlug`).
3244
+ * Returned by single-page endpoints (`GET /storefront/pages/:idOrSlug`).
3224
3245
  *
3225
3246
  * Pages are layout-driven containers whose content comes from **DataSources** —
3226
3247
  * configurable queries that fetch content, categories, forms, or other data.
@@ -3279,7 +3300,7 @@ interface Page extends PageSummary {
3279
3300
  *
3280
3301
  * `undefined` on responses from older API versions that do not populate
3281
3302
  * the cascade; in that case, fall back to the dedicated
3282
- * `/public/:siteId/pages/:slug/json-ld` endpoint which always returns
3303
+ * `/storefront/:siteId/pages/:slug/json-ld` endpoint which always returns
3283
3304
  * the array directly under `data`.
3284
3305
  */
3285
3306
  structuredData?: {
@@ -3696,7 +3717,7 @@ interface FormSchema {
3696
3717
  }
3697
3718
  /**
3698
3719
  * A public form available for submission.
3699
- * Returned by `GET /public/{siteId}/forms/{slug}` and unwrapped from the
3720
+ * Returned by `GET /storefront/{siteId}/forms/{slug}` and unwrapped from the
3700
3721
  * `{ data }` envelope by `forms.getBySlug()`.
3701
3722
  *
3702
3723
  * Use `schema.fields` to dynamically render the form fields, `schema.settings`
@@ -3718,8 +3739,8 @@ interface Form {
3718
3739
  /**
3719
3740
  * URL-friendly slug, unique within the site.
3720
3741
  * Lowercase, hyphenated (e.g. `'contact-us'`). Max 255 characters.
3721
- * Used to fetch the form: `GET /public/{siteId}/forms/{slug}`.
3722
- * Also used as the submission endpoint: `POST /public/{siteId}/forms/{slug}/submissions`.
3742
+ * Used to fetch the form: `GET /storefront/{siteId}/forms/{slug}`.
3743
+ * Also used as the submission endpoint: `POST /storefront/{siteId}/forms/{slug}/submissions`.
3723
3744
  */
3724
3745
  slug: string;
3725
3746
  /**
@@ -3839,7 +3860,7 @@ interface ReviewResponse {
3839
3860
  interface Review {
3840
3861
  /**
3841
3862
  * Unique numeric review ID. Auto-incremented.
3842
- * Use this for API calls like `GET /public/reviews/:id`.
3863
+ * Use this for API calls like `GET /storefront/reviews/:id`.
3843
3864
  */
3844
3865
  id: number;
3845
3866
  /**
@@ -3906,7 +3927,7 @@ interface Review {
3906
3927
  }
3907
3928
  /**
3908
3929
  * Public review settings for a site.
3909
- * Returned by `GET /public/reviews/settings`.
3930
+ * Returned by `GET /storefront/reviews/settings`.
3910
3931
  *
3911
3932
  * Use these settings to:
3912
3933
  * - Check if reviews are enabled before rendering a review form
@@ -3975,7 +3996,7 @@ interface ReviewSettings {
3975
3996
  };
3976
3997
  }
3977
3998
  /**
3978
- * Data payload for submitting a new review via `POST /public/reviews`.
3999
+ * Data payload for submitting a new review via `POST /storefront/reviews`.
3979
4000
  *
3980
4001
  * Required fields: `authorName`, `rating`, `content`.
3981
4002
  * Optional fields depend on `ReviewSettings.fields` configuration.
@@ -4709,7 +4730,7 @@ interface CategoriesListResponse {
4709
4730
  * Flat array of all categories with their published content count.
4710
4731
  * Not paginated -- all categories are returned in a single response.
4711
4732
  */
4712
- data: CategoryWithCount[];
4733
+ categories: CategoryWithCount[];
4713
4734
  /**
4714
4735
  * How blog content URLs are constructed for this site:
4715
4736
  * - `'flat'`: URLs use slug only, e.g. `/blog/my-article`
@@ -4734,7 +4755,7 @@ interface CategoryTreeResponse {
4734
4755
  * Root-level category nodes, each containing nested `children` arrays.
4735
4756
  * Categories with a `parentId` appear as children of their parent node.
4736
4757
  */
4737
- data: CategoryTreeNode[];
4758
+ tree: CategoryTreeNode[];
4738
4759
  /**
4739
4760
  * How blog content URLs are constructed for this site:
4740
4761
  * - `'flat'`: URLs use slug only, e.g. `/blog/my-article`
@@ -4788,7 +4809,7 @@ interface CategoryDetailResponse {
4788
4809
  * Response from `tags.list()`.
4789
4810
  * Paginated since SDK 1.32.2 (the wire was already returning `meta`; the SDK
4790
4811
  * type now exposes it). Server-side default is 20 items per page on
4791
- * `/v1/tags` and `/public/.../tags`, with `maxLimit=100` (ADR-0022 D3).
4812
+ * `/v1/tags` and `/storefront/.../tags`, with `maxLimit=100` (ADR-0022 D3).
4792
4813
  */
4793
4814
  interface TagsListResponse {
4794
4815
  /**
@@ -5079,9 +5100,9 @@ interface BaseRequestOptions {
5079
5100
  * Pagination options for list endpoints.
5080
5101
  *
5081
5102
  * All values are 1-based integers. The server default is 20 items per page
5082
- * on public-tier endpoints (`/public`, `/v1`) and 50 on admin-tier
5103
+ * on public-tier endpoints (`/storefront`, `/v1`) and 50 on admin-tier
5083
5104
  * endpoints (`/api`, `/admin`), per ADR-0022 D3. Documented exceptions:
5084
- * SSG endpoints like `/public/.../categories/:slug` default to 500.
5105
+ * SSG endpoints like `/storefront/.../categories/:slug` default to 500.
5085
5106
  */
5086
5107
  interface PaginationOptions {
5087
5108
  /**
@@ -5092,9 +5113,9 @@ interface PaginationOptions {
5092
5113
  page?: number;
5093
5114
  /**
5094
5115
  * Maximum number of items per page.
5095
- * Server default is 20 on public-tier endpoints (`/public`, `/v1`).
5116
+ * Server default is 20 on public-tier endpoints (`/storefront`, `/v1`).
5096
5117
  * Maximum allowed value is 100 (except documented SSG exceptions like
5097
- * `/public/.../categories/:slug` which permit up to 500).
5118
+ * `/storefront/.../categories/:slug` which permit up to 500).
5098
5119
  * Values above the per-endpoint maximum are silently capped by the API.
5099
5120
  */
5100
5121
  limit?: number;
@@ -5187,7 +5208,7 @@ interface CategoryOptions extends PaginationOptions {
5187
5208
  *
5188
5209
  * Pagination + locale. The public `/v1/tags` endpoint does not expose
5189
5210
  * search or sort on its public surface. `limit` defaults to 20 server-side
5190
- * on the public-tier mounts (`/public/.../tags`, `/v1/tags`) per
5211
+ * on the public-tier mounts (`/storefront/.../tags`, `/v1/tags`) per
5191
5212
  * ADR-0022 D3, with `maxLimit=100`.
5192
5213
  */
5193
5214
  interface TagsListFilters extends PaginationOptions {