@sleekcms/client 2.2.1 → 2.3.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
@@ -1,7 +1,9 @@
1
- # SleekCMS Client
1
+ # @sleekcms/client
2
2
 
3
3
  Official JavaScript/TypeScript client for [SleekCMS](https://sleekcms.com) - a headless CMS that lets you manage content and deliver it via API.
4
4
 
5
+ Sign in at [sleekcms.com](https://sleekcms.com), create your content models, add your content, then grab your site token and use this library to integrate content in your apps.
6
+
5
7
  ## Installation
6
8
 
7
9
  ```bash
@@ -211,12 +213,12 @@ const logo = client.getImage('logo');
211
213
  // { url: 'https://...', alt: '...', ... }
212
214
  ```
213
215
 
214
- ### `getList(name)`
216
+ ### `getOptionSet(name)`
215
217
 
216
- Get a list (array of label/value pairs).
218
+ Get a option set (array of label/value pairs).
217
219
 
218
220
  ```typescript
219
- const categories = client.getList('categories');
221
+ const categories = client.getOptionSet('categories');
220
222
  // [{ label: 'Tech', value: 'tech' }, ...]
221
223
  ```
222
224
 
@@ -325,7 +327,7 @@ import type {
325
327
  Page,
326
328
  Entry,
327
329
  Image,
328
- List
330
+ Options
329
331
  } from '@sleekcms/client';
330
332
  ```
331
333
 
package/index.cjs CHANGED
@@ -209,11 +209,11 @@ async function createClient(options) {
209
209
  if (!name) return null;
210
210
  return data.images ? data.images[name] : null;
211
211
  }
212
- function getList(name) {
212
+ function getOptionSet(name) {
213
213
  if (!name) return null;
214
- const lists = data.lists ?? {};
215
- const list = lists[name];
216
- return Array.isArray(list) ? list : null;
214
+ const options2 = data.options ?? {};
215
+ const optionSet = options2[name];
216
+ return Array.isArray(optionSet) ? optionSet : null;
217
217
  }
218
218
  return {
219
219
  getContent,
@@ -222,7 +222,7 @@ async function createClient(options) {
222
222
  getEntry,
223
223
  getSlugs,
224
224
  getImage,
225
- getList
225
+ getOptionSet
226
226
  };
227
227
  }
228
228
  function createAsyncClient(options) {
@@ -274,12 +274,12 @@ function createAsyncClient(options) {
274
274
  const images = await fetchSiteContent({ siteToken, env: tag ?? env, search: "images", lang, cache });
275
275
  return images ? images[name] : null;
276
276
  }
277
- async function getList(name) {
277
+ async function getOptionSet(name) {
278
278
  if (cdn && !tag) tag = await fetchEnvTag({ siteToken, env });
279
- if (syncClient) return syncClient.getList(name);
280
- const lists = await fetchSiteContent({ siteToken, env: tag ?? env, search: "lists", lang, cache });
281
- const list = lists[name];
282
- return Array.isArray(list) ? list : null;
279
+ if (syncClient) return syncClient.getOptionSet(name);
280
+ const options2 = await fetchSiteContent({ siteToken, env: tag ?? env, search: "options", lang, cache });
281
+ const optionSet = options2[name];
282
+ return Array.isArray(optionSet) ? optionSet : null;
283
283
  }
284
284
  async function _getEnvTag() {
285
285
  let resp = await fetchEnvTag({ siteToken, env });
@@ -295,7 +295,7 @@ function createAsyncClient(options) {
295
295
  getEntry,
296
296
  getSlugs,
297
297
  getImage,
298
- getList,
298
+ getOptionSet,
299
299
  _getFetchUrl,
300
300
  _getEnvTag
301
301
  };
package/index.d.cts CHANGED
@@ -7,7 +7,7 @@ type Image = {
7
7
  url: string;
8
8
  [key: string]: unknown;
9
9
  };
10
- type List = Array<{
10
+ type Options = Array<{
11
11
  label: string;
12
12
  value: string;
13
13
  }>;
@@ -17,7 +17,7 @@ interface SleekSiteContent {
17
17
  };
18
18
  pages?: Array<Page>;
19
19
  images?: Record<string, Image>;
20
- lists?: Record<string, List>;
20
+ options?: Record<string, Options>;
21
21
  config?: {
22
22
  title?: string;
23
23
  };
@@ -45,7 +45,7 @@ interface SleekClient {
45
45
  getEntry(handle: string): Entry | Entry[] | null;
46
46
  getSlugs(path: string): string[];
47
47
  getImage(name: string): Image | null;
48
- getList(name: string): List | null;
48
+ getOptionSet(name: string): Options | null;
49
49
  }
50
50
  interface SleekAsyncClient {
51
51
  getContent(query?: string): Promise<SleekSiteContent>;
@@ -54,7 +54,7 @@ interface SleekAsyncClient {
54
54
  getEntry(handle: string): Promise<Entry | Entry[] | null>;
55
55
  getSlugs(path: string): Promise<string[]>;
56
56
  getImage(name: string): Promise<Image | null>;
57
- getList(name: string): Promise<List | null>;
57
+ getOptionSet(name: string): Promise<Options | null>;
58
58
  _getFetchUrl(): string;
59
59
  _getEnvTag(): Promise<string>;
60
60
  }
@@ -62,4 +62,4 @@ interface SleekAsyncClient {
62
62
  declare function createClient(options: ClientOptions): Promise<SleekClient>;
63
63
  declare function createAsyncClient(options: ClientOptions): SleekAsyncClient | any;
64
64
 
65
- export { type AsyncCacheAdapter, type ClientOptions, type Entry, type Image, type List, type Page, type SleekAsyncClient, type SleekClient, type SleekSiteContent, type SyncCacheAdapter, createAsyncClient, createClient };
65
+ export { type AsyncCacheAdapter, type ClientOptions, type Entry, type Image, type Options, type Page, type SleekAsyncClient, type SleekClient, type SleekSiteContent, type SyncCacheAdapter, createAsyncClient, createClient };
package/index.d.ts CHANGED
@@ -7,7 +7,7 @@ type Image = {
7
7
  url: string;
8
8
  [key: string]: unknown;
9
9
  };
10
- type List = Array<{
10
+ type Options = Array<{
11
11
  label: string;
12
12
  value: string;
13
13
  }>;
@@ -17,7 +17,7 @@ interface SleekSiteContent {
17
17
  };
18
18
  pages?: Array<Page>;
19
19
  images?: Record<string, Image>;
20
- lists?: Record<string, List>;
20
+ options?: Record<string, Options>;
21
21
  config?: {
22
22
  title?: string;
23
23
  };
@@ -45,7 +45,7 @@ interface SleekClient {
45
45
  getEntry(handle: string): Entry | Entry[] | null;
46
46
  getSlugs(path: string): string[];
47
47
  getImage(name: string): Image | null;
48
- getList(name: string): List | null;
48
+ getOptionSet(name: string): Options | null;
49
49
  }
50
50
  interface SleekAsyncClient {
51
51
  getContent(query?: string): Promise<SleekSiteContent>;
@@ -54,7 +54,7 @@ interface SleekAsyncClient {
54
54
  getEntry(handle: string): Promise<Entry | Entry[] | null>;
55
55
  getSlugs(path: string): Promise<string[]>;
56
56
  getImage(name: string): Promise<Image | null>;
57
- getList(name: string): Promise<List | null>;
57
+ getOptionSet(name: string): Promise<Options | null>;
58
58
  _getFetchUrl(): string;
59
59
  _getEnvTag(): Promise<string>;
60
60
  }
@@ -62,4 +62,4 @@ interface SleekAsyncClient {
62
62
  declare function createClient(options: ClientOptions): Promise<SleekClient>;
63
63
  declare function createAsyncClient(options: ClientOptions): SleekAsyncClient | any;
64
64
 
65
- export { type AsyncCacheAdapter, type ClientOptions, type Entry, type Image, type List, type Page, type SleekAsyncClient, type SleekClient, type SleekSiteContent, type SyncCacheAdapter, createAsyncClient, createClient };
65
+ export { type AsyncCacheAdapter, type ClientOptions, type Entry, type Image, type Options, type Page, type SleekAsyncClient, type SleekClient, type SleekSiteContent, type SyncCacheAdapter, createAsyncClient, createClient };
package/index.mjs CHANGED
@@ -173,11 +173,11 @@ async function createClient(options) {
173
173
  if (!name) return null;
174
174
  return data.images ? data.images[name] : null;
175
175
  }
176
- function getList(name) {
176
+ function getOptionSet(name) {
177
177
  if (!name) return null;
178
- const lists = data.lists ?? {};
179
- const list = lists[name];
180
- return Array.isArray(list) ? list : null;
178
+ const options2 = data.options ?? {};
179
+ const optionSet = options2[name];
180
+ return Array.isArray(optionSet) ? optionSet : null;
181
181
  }
182
182
  return {
183
183
  getContent,
@@ -186,7 +186,7 @@ async function createClient(options) {
186
186
  getEntry,
187
187
  getSlugs,
188
188
  getImage,
189
- getList
189
+ getOptionSet
190
190
  };
191
191
  }
192
192
  function createAsyncClient(options) {
@@ -238,12 +238,12 @@ function createAsyncClient(options) {
238
238
  const images = await fetchSiteContent({ siteToken, env: tag ?? env, search: "images", lang, cache });
239
239
  return images ? images[name] : null;
240
240
  }
241
- async function getList(name) {
241
+ async function getOptionSet(name) {
242
242
  if (cdn && !tag) tag = await fetchEnvTag({ siteToken, env });
243
- if (syncClient) return syncClient.getList(name);
244
- const lists = await fetchSiteContent({ siteToken, env: tag ?? env, search: "lists", lang, cache });
245
- const list = lists[name];
246
- return Array.isArray(list) ? list : null;
243
+ if (syncClient) return syncClient.getOptionSet(name);
244
+ const options2 = await fetchSiteContent({ siteToken, env: tag ?? env, search: "options", lang, cache });
245
+ const optionSet = options2[name];
246
+ return Array.isArray(optionSet) ? optionSet : null;
247
247
  }
248
248
  async function _getEnvTag() {
249
249
  let resp = await fetchEnvTag({ siteToken, env });
@@ -259,7 +259,7 @@ function createAsyncClient(options) {
259
259
  getEntry,
260
260
  getSlugs,
261
261
  getImage,
262
- getList,
262
+ getOptionSet,
263
263
  _getFetchUrl,
264
264
  _getEnvTag
265
265
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sleekcms/client",
3
- "version": "2.2.1",
3
+ "version": "2.3.0",
4
4
  "description": "Official SleekCMS content client for Node 18+ and browser",
5
5
  "type": "module",
6
6
  "main": "index.cjs",