@sleekcms/client 2.2.2 → 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 +4 -4
- package/index.cjs +11 -11
- package/index.d.cts +5 -5
- package/index.d.ts +5 -5
- package/index.mjs +11 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -213,12 +213,12 @@ const logo = client.getImage('logo');
|
|
|
213
213
|
// { url: 'https://...', alt: '...', ... }
|
|
214
214
|
```
|
|
215
215
|
|
|
216
|
-
### `
|
|
216
|
+
### `getOptionSet(name)`
|
|
217
217
|
|
|
218
|
-
Get a
|
|
218
|
+
Get a option set (array of label/value pairs).
|
|
219
219
|
|
|
220
220
|
```typescript
|
|
221
|
-
const categories = client.
|
|
221
|
+
const categories = client.getOptionSet('categories');
|
|
222
222
|
// [{ label: 'Tech', value: 'tech' }, ...]
|
|
223
223
|
```
|
|
224
224
|
|
|
@@ -327,7 +327,7 @@ import type {
|
|
|
327
327
|
Page,
|
|
328
328
|
Entry,
|
|
329
329
|
Image,
|
|
330
|
-
|
|
330
|
+
Options
|
|
331
331
|
} from '@sleekcms/client';
|
|
332
332
|
```
|
|
333
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
|
|
212
|
+
function getOptionSet(name) {
|
|
213
213
|
if (!name) return null;
|
|
214
|
-
const
|
|
215
|
-
const
|
|
216
|
-
return Array.isArray(
|
|
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
|
-
|
|
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
|
|
277
|
+
async function getOptionSet(name) {
|
|
278
278
|
if (cdn && !tag) tag = await fetchEnvTag({ siteToken, env });
|
|
279
|
-
if (syncClient) return syncClient.
|
|
280
|
-
const
|
|
281
|
-
const
|
|
282
|
-
return Array.isArray(
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
176
|
+
function getOptionSet(name) {
|
|
177
177
|
if (!name) return null;
|
|
178
|
-
const
|
|
179
|
-
const
|
|
180
|
-
return Array.isArray(
|
|
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
|
-
|
|
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
|
|
241
|
+
async function getOptionSet(name) {
|
|
242
242
|
if (cdn && !tag) tag = await fetchEnvTag({ siteToken, env });
|
|
243
|
-
if (syncClient) return syncClient.
|
|
244
|
-
const
|
|
245
|
-
const
|
|
246
|
-
return Array.isArray(
|
|
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
|
-
|
|
262
|
+
getOptionSet,
|
|
263
263
|
_getFetchUrl,
|
|
264
264
|
_getEnvTag
|
|
265
265
|
};
|