@better-i18n/sdk 2.0.0 → 2.0.1

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
@@ -43,7 +43,7 @@ const { items, total, hasMore } = await client.getEntries("blog-posts", {
43
43
  const post = await client.getEntry("blog-posts", "hello-world", {
44
44
  language: "fr",
45
45
  });
46
- console.log(post.title, post.bodyMarkdown);
46
+ console.log(post.title, post.body);
47
47
  ```
48
48
 
49
49
  ## API
@@ -64,12 +64,16 @@ console.log(post.title, post.bodyMarkdown);
64
64
  | `order` | `"asc" \| "desc"` | `"desc"` | Sort direction |
65
65
  | `page` | `number` | `1` | Page number (1-based) |
66
66
  | `limit` | `number` | `50` | Entries per page (1-100) |
67
+ | `fields` | `string[]` | all fields | Fields to include in response |
68
+ | `expand` | `string[]` | none | Relation field names to expand |
67
69
 
68
70
  ### `getEntry` Options
69
71
 
70
72
  | Option | Type | Default | Description |
71
73
  | --- | --- | --- | --- |
72
74
  | `language` | `string` | source language | Language code for localized content |
75
+ | `fields` | `string[]` | all fields | Fields to include in response |
76
+ | `expand` | `string[]` | none | Relation field names to expand |
73
77
 
74
78
  ### Response Types
75
79
 
@@ -77,7 +81,7 @@ console.log(post.title, post.bodyMarkdown);
77
81
 
78
82
  ```typescript
79
83
  {
80
- items: ContentEntryListItem[]; // slug, title, excerpt, publishedAt, tags, author
84
+ items: ContentEntryListItem[]; // id, slug, title, publishedAt, customFields, relations?
81
85
  total: number; // total matching entries
82
86
  hasMore: boolean; // more pages available
83
87
  }
@@ -88,9 +92,7 @@ console.log(post.title, post.bodyMarkdown);
88
92
  ```typescript
89
93
  {
90
94
  id, slug, status, publishedAt, sourceLanguage, availableLanguages,
91
- featuredImage, tags, author, customFields,
92
- title, excerpt, body, bodyHtml, bodyMarkdown,
93
- metaTitle, metaDescription
95
+ title, body, customFields, relations?
94
96
  }
95
97
  ```
96
98
 
@@ -109,13 +111,41 @@ post.customFields.readingTime; // string | null (typed!)
109
111
  post.customFields.category; // string | null (typed!)
110
112
  ```
111
113
 
114
+ ## Expanding Relations
115
+
116
+ Use `expand` to resolve related entries in a single request. Expanded relations are available under the `relations` key.
117
+
118
+ ```typescript
119
+ const { items } = await client.getEntries("blog-posts", {
120
+ expand: ["author", "category"],
121
+ });
122
+
123
+ // Access expanded relation fields
124
+ items[0].relations?.author?.title; // "Alice Johnson"
125
+ items[0].relations?.author?.modelSlug; // "users"
126
+ items[0].relations?.author?.customFields?.avatar; // "https://..."
127
+ items[0].relations?.category?.title; // "Engineering"
128
+ ```
129
+
130
+ Each expanded relation is a `RelationValue` object:
131
+
132
+ ```typescript
133
+ interface RelationValue {
134
+ id: string;
135
+ slug: string;
136
+ title: string;
137
+ modelSlug: string;
138
+ customFields?: Record<string, string | null>;
139
+ }
140
+ ```
141
+
112
142
  ## Configuration
113
143
 
114
144
  | Option | Required | Description |
115
145
  | --- | --- | --- |
116
146
  | `project` | Yes | Project identifier in `org/project` format (e.g., `"acme/web-app"`) |
117
147
  | `apiKey` | Yes | API key from [dashboard](https://dash.better-i18n.com) |
118
- | `apiBase` | No | API base URL (default: `https://dash.better-i18n.com`) |
148
+ | `apiBase` | No | API base URL (default: `https://content.better-i18n.com`) |
119
149
 
120
150
  ## Documentation
121
151
 
package/dist/types.d.ts CHANGED
@@ -4,7 +4,7 @@ export interface ClientConfig {
4
4
  project: string;
5
5
  /** API key for authenticating content requests. Required. */
6
6
  apiKey: string;
7
- /** REST API base URL. Defaults to `https://dash.better-i18n.com`. */
7
+ /** REST API base URL. Defaults to `https://content.better-i18n.com`. */
8
8
  apiBase?: string;
9
9
  /** Enable debug logging to see request URLs, headers, and responses. */
10
10
  debug?: boolean;
@@ -19,6 +19,8 @@ export interface RelationValue {
19
19
  title: string;
20
20
  /** Target model slug */
21
21
  modelSlug: string;
22
+ /** The related entry's own custom field values (or user profile fields for _users). */
23
+ customFields?: Record<string, string | null>;
22
24
  }
23
25
  /**
24
26
  * A full content entry with all localized fields.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EAAE,CAAC;CACnB;AAED,sDAAsD;AACtD,MAAM,WAAW,aAAa;IAC5B,8CAA8C;IAC9C,SAAS,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IACrC,wDAAwD;IACxD,UAAU,CACR,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC,CAAC;IACpD,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,EAC/E,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC;CAC9B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-i18n/sdk",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Content SDK for Better i18n - headless CMS client for fetching content models and entries",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",