@localess/js-client 0.5.2-next.20250330-190534.0 → 0.6.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/dist/index.d.mts CHANGED
@@ -133,20 +133,24 @@ interface ContentMetadata {
133
133
  }
134
134
 
135
135
  /**
136
- * Content define shared object for all possible Content Types.
136
+ * Key-Value Object. Where Key is Unique identifier for the Content object and Value is Content Metadata.
137
137
  */
138
- interface Content extends ContentMetadata {
139
- /**
140
- * Content Data
141
- */
142
- data?: ContentData;
138
+ interface Links {
139
+ [key: string]: ContentMetadata;
143
140
  }
144
141
 
145
142
  /**
146
- * Key-Value Object. Where Key is Unique identifier for the Content object and Value is Content Metadata.
143
+ * Content define shared object for all possible Content Types.
147
144
  */
148
- interface Links {
149
- [key: string]: ContentMetadata;
145
+ interface Content<T extends ContentData = ContentData> extends ContentMetadata {
146
+ /**
147
+ * Content Data
148
+ */
149
+ data?: T;
150
+ /**
151
+ * References of all links used in the content.
152
+ */
153
+ links?: Links;
150
154
  }
151
155
 
152
156
  /**
@@ -210,11 +214,7 @@ type ContentFetchParams = {
210
214
  */
211
215
  locale?: string;
212
216
  };
213
- /**
214
- * Create a Localess API Client
215
- * @param {LocalessClientOptions} options connection details
216
- */
217
- declare function localessClient(options: LocalessClientOptions): {
217
+ interface LocalessClient {
218
218
  /**
219
219
  * Get all links
220
220
  * @param params{LinksFetchParams} - Fetch parameters
@@ -227,14 +227,14 @@ declare function localessClient(options: LocalessClientOptions): {
227
227
  * @param params{ContentFetchParams} - Fetch parameters
228
228
  * @returns {Promise<Content>}
229
229
  */
230
- getContentBySlug(slug: string, params?: ContentFetchParams): Promise<Content>;
230
+ getContentBySlug<T extends ContentData = ContentData>(slug: string, params?: ContentFetchParams): Promise<Content<T>>;
231
231
  /**
232
232
  * Get content by ID
233
233
  * @param id{string} - Content ID
234
234
  * @param params{ContentFetchParams} - Fetch parameters
235
235
  * @returns {Promise<Content>}
236
236
  */
237
- getContentById(id: string, params?: ContentFetchParams): Promise<Content>;
237
+ getContentById<T extends ContentData = ContentData>(id: string, params?: ContentFetchParams): Promise<Content<T>>;
238
238
  /**
239
239
  * Get translations for the given locale
240
240
  * @param locale{string} - Locale identifier (ISO 639-1)
@@ -242,7 +242,12 @@ declare function localessClient(options: LocalessClientOptions): {
242
242
  getTranslations(locale: string): Promise<Translations>;
243
243
  syncScriptUrl(): string;
244
244
  assetLink(asset: ContentAsset | string): string;
245
- };
245
+ }
246
+ /**
247
+ * Create a Localess API Client
248
+ * @param {LocalessClientOptions} options connection details
249
+ */
250
+ declare function localessClient(options: LocalessClientOptions): LocalessClient;
246
251
 
247
252
  declare function llEditable(content: ContentDataSchema): {
248
253
  'data-ll-id': string;
@@ -276,4 +281,4 @@ declare global {
276
281
  }
277
282
  }
278
283
 
279
- export { type Content, type ContentAsset, type ContentData, type ContentDataField, type ContentDataSchema, type ContentFetchParams, type ContentLink, type ContentMetadata, type ContentReference, type ContentRichText, type EventCallback, type EventToApp, type EventToAppType, type Links, type LinksFetchParams, type LocalessClientOptions, type LocalessSync, type Translations, llEditable, loadLocalessSync, localessClient };
284
+ export { type Content, type ContentAsset, type ContentData, type ContentDataField, type ContentDataSchema, type ContentFetchParams, type ContentLink, type ContentMetadata, type ContentReference, type ContentRichText, type EventCallback, type EventToApp, type EventToAppType, type Links, type LinksFetchParams, type LocalessClient, type LocalessClientOptions, type LocalessSync, type Translations, llEditable, loadLocalessSync, localessClient };
package/dist/index.d.ts CHANGED
@@ -133,20 +133,24 @@ interface ContentMetadata {
133
133
  }
134
134
 
135
135
  /**
136
- * Content define shared object for all possible Content Types.
136
+ * Key-Value Object. Where Key is Unique identifier for the Content object and Value is Content Metadata.
137
137
  */
138
- interface Content extends ContentMetadata {
139
- /**
140
- * Content Data
141
- */
142
- data?: ContentData;
138
+ interface Links {
139
+ [key: string]: ContentMetadata;
143
140
  }
144
141
 
145
142
  /**
146
- * Key-Value Object. Where Key is Unique identifier for the Content object and Value is Content Metadata.
143
+ * Content define shared object for all possible Content Types.
147
144
  */
148
- interface Links {
149
- [key: string]: ContentMetadata;
145
+ interface Content<T extends ContentData = ContentData> extends ContentMetadata {
146
+ /**
147
+ * Content Data
148
+ */
149
+ data?: T;
150
+ /**
151
+ * References of all links used in the content.
152
+ */
153
+ links?: Links;
150
154
  }
151
155
 
152
156
  /**
@@ -210,11 +214,7 @@ type ContentFetchParams = {
210
214
  */
211
215
  locale?: string;
212
216
  };
213
- /**
214
- * Create a Localess API Client
215
- * @param {LocalessClientOptions} options connection details
216
- */
217
- declare function localessClient(options: LocalessClientOptions): {
217
+ interface LocalessClient {
218
218
  /**
219
219
  * Get all links
220
220
  * @param params{LinksFetchParams} - Fetch parameters
@@ -227,14 +227,14 @@ declare function localessClient(options: LocalessClientOptions): {
227
227
  * @param params{ContentFetchParams} - Fetch parameters
228
228
  * @returns {Promise<Content>}
229
229
  */
230
- getContentBySlug(slug: string, params?: ContentFetchParams): Promise<Content>;
230
+ getContentBySlug<T extends ContentData = ContentData>(slug: string, params?: ContentFetchParams): Promise<Content<T>>;
231
231
  /**
232
232
  * Get content by ID
233
233
  * @param id{string} - Content ID
234
234
  * @param params{ContentFetchParams} - Fetch parameters
235
235
  * @returns {Promise<Content>}
236
236
  */
237
- getContentById(id: string, params?: ContentFetchParams): Promise<Content>;
237
+ getContentById<T extends ContentData = ContentData>(id: string, params?: ContentFetchParams): Promise<Content<T>>;
238
238
  /**
239
239
  * Get translations for the given locale
240
240
  * @param locale{string} - Locale identifier (ISO 639-1)
@@ -242,7 +242,12 @@ declare function localessClient(options: LocalessClientOptions): {
242
242
  getTranslations(locale: string): Promise<Translations>;
243
243
  syncScriptUrl(): string;
244
244
  assetLink(asset: ContentAsset | string): string;
245
- };
245
+ }
246
+ /**
247
+ * Create a Localess API Client
248
+ * @param {LocalessClientOptions} options connection details
249
+ */
250
+ declare function localessClient(options: LocalessClientOptions): LocalessClient;
246
251
 
247
252
  declare function llEditable(content: ContentDataSchema): {
248
253
  'data-ll-id': string;
@@ -276,4 +281,4 @@ declare global {
276
281
  }
277
282
  }
278
283
 
279
- export { type Content, type ContentAsset, type ContentData, type ContentDataField, type ContentDataSchema, type ContentFetchParams, type ContentLink, type ContentMetadata, type ContentReference, type ContentRichText, type EventCallback, type EventToApp, type EventToAppType, type Links, type LinksFetchParams, type LocalessClientOptions, type LocalessSync, type Translations, llEditable, loadLocalessSync, localessClient };
284
+ export { type Content, type ContentAsset, type ContentData, type ContentDataField, type ContentDataSchema, type ContentFetchParams, type ContentLink, type ContentMetadata, type ContentReference, type ContentRichText, type EventCallback, type EventToApp, type EventToAppType, type Links, type LinksFetchParams, type LocalessClient, type LocalessClientOptions, type LocalessSync, type Translations, llEditable, loadLocalessSync, localessClient };
package/dist/index.js CHANGED
@@ -42,15 +42,10 @@ function localessClient(options) {
42
42
  "Content-Type": "application/json",
43
43
  "Accept": "application/json",
44
44
  "X-Localess-Agent": "Localess-JS-Client",
45
- "X-Localess-Agent-Version": "0.3.0"
45
+ "X-Localess-Agent-Version": "0.6.0"
46
46
  }
47
47
  };
48
48
  return {
49
- /**
50
- * Get all links
51
- * @param params{LinksFetchParams} - Fetch parameters
52
- * @returns {Promise<Links>}
53
- */
54
49
  async getLinks(params) {
55
50
  if (options.debug) {
56
51
  console.log(LOG_GROUP, "getLinks() params : " + params);
@@ -83,12 +78,6 @@ function localessClient(options) {
83
78
  return {};
84
79
  }
85
80
  },
86
- /**
87
- * Get content by SLUG
88
- * @param slug{string} - Content SLUG
89
- * @param params{ContentFetchParams} - Fetch parameters
90
- * @returns {Promise<Content>}
91
- */
92
81
  async getContentBySlug(slug, params) {
93
82
  if (options.debug) {
94
83
  console.log(LOG_GROUP, "getContentBySlug() slug : ", slug);
@@ -118,12 +107,6 @@ function localessClient(options) {
118
107
  return {};
119
108
  }
120
109
  },
121
- /**
122
- * Get content by ID
123
- * @param id{string} - Content ID
124
- * @param params{ContentFetchParams} - Fetch parameters
125
- * @returns {Promise<Content>}
126
- */
127
110
  async getContentById(id, params) {
128
111
  if (options.debug) {
129
112
  console.log(LOG_GROUP, "getContentById() id : ", id);
@@ -148,15 +131,11 @@ function localessClient(options) {
148
131
  const data = await response.json();
149
132
  return data;
150
133
  },
151
- /**
152
- * Get translations for the given locale
153
- * @param locale{string} - Locale identifier (ISO 639-1)
154
- */
155
134
  async getTranslations(locale) {
156
135
  if (options.debug) {
157
136
  console.log(LOG_GROUP, "getTranslations() locale : ", locale);
158
137
  }
159
- let url = `${options.origin}/api/v1/spaces/${options.spaceId}/translations/${locale}`;
138
+ let url = `${options.origin}/api/v1/spaces/${options.spaceId}/translations/${locale}?token=${options.token}`;
160
139
  if (options.debug) {
161
140
  console.log(LOG_GROUP, "getTranslations fetch url : ", url);
162
141
  }
package/dist/index.mjs CHANGED
@@ -14,15 +14,10 @@ function localessClient(options) {
14
14
  "Content-Type": "application/json",
15
15
  "Accept": "application/json",
16
16
  "X-Localess-Agent": "Localess-JS-Client",
17
- "X-Localess-Agent-Version": "0.3.0"
17
+ "X-Localess-Agent-Version": "0.6.0"
18
18
  }
19
19
  };
20
20
  return {
21
- /**
22
- * Get all links
23
- * @param params{LinksFetchParams} - Fetch parameters
24
- * @returns {Promise<Links>}
25
- */
26
21
  async getLinks(params) {
27
22
  if (options.debug) {
28
23
  console.log(LOG_GROUP, "getLinks() params : " + params);
@@ -55,12 +50,6 @@ function localessClient(options) {
55
50
  return {};
56
51
  }
57
52
  },
58
- /**
59
- * Get content by SLUG
60
- * @param slug{string} - Content SLUG
61
- * @param params{ContentFetchParams} - Fetch parameters
62
- * @returns {Promise<Content>}
63
- */
64
53
  async getContentBySlug(slug, params) {
65
54
  if (options.debug) {
66
55
  console.log(LOG_GROUP, "getContentBySlug() slug : ", slug);
@@ -90,12 +79,6 @@ function localessClient(options) {
90
79
  return {};
91
80
  }
92
81
  },
93
- /**
94
- * Get content by ID
95
- * @param id{string} - Content ID
96
- * @param params{ContentFetchParams} - Fetch parameters
97
- * @returns {Promise<Content>}
98
- */
99
82
  async getContentById(id, params) {
100
83
  if (options.debug) {
101
84
  console.log(LOG_GROUP, "getContentById() id : ", id);
@@ -120,15 +103,11 @@ function localessClient(options) {
120
103
  const data = await response.json();
121
104
  return data;
122
105
  },
123
- /**
124
- * Get translations for the given locale
125
- * @param locale{string} - Locale identifier (ISO 639-1)
126
- */
127
106
  async getTranslations(locale) {
128
107
  if (options.debug) {
129
108
  console.log(LOG_GROUP, "getTranslations() locale : ", locale);
130
109
  }
131
- let url = `${options.origin}/api/v1/spaces/${options.spaceId}/translations/${locale}`;
110
+ let url = `${options.origin}/api/v1/spaces/${options.spaceId}/translations/${locale}?token=${options.token}`;
132
111
  if (options.debug) {
133
112
  console.log(LOG_GROUP, "getTranslations fetch url : ", url);
134
113
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localess/js-client",
3
- "version": "0.5.2-next.20250330-190534.0",
3
+ "version": "0.6.0",
4
4
  "description": "Universal JavaScript/TypeScript SDK for Localess's API.",
5
5
  "keywords": [
6
6
  "localess",
@@ -34,10 +34,7 @@
34
34
  "url": "https://github.com/Lessify/localess-js-client/issues"
35
35
  },
36
36
  "scripts": {
37
- "build": "npm run build:tsc && npm run build:cjs",
38
- "build:tsc": "tsc -p tsconfig.json",
39
- "build:cjs": "tsc -p tsconfig.cjs.json",
40
- "build:tsup": "tsup src/index.ts --format cjs,esm --dts"
37
+ "build": "tsup src/index.ts --format cjs,esm --dts"
41
38
  },
42
39
  "license": "MIT",
43
40
  "devDependencies": {