@prezly/theme-kit-core 7.5.1 → 7.7.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/build/data-fetching/lib/getSearchSettings.d.ts +4 -0
- package/build/data-fetching/lib/getSearchSettings.js +29 -0
- package/build/data-fetching/lib/getSearchSettings.js.map +1 -0
- package/build/data-fetching/lib/index.d.ts +1 -1
- package/build/data-fetching/lib/index.js +3 -3
- package/build/data-fetching/lib/index.js.map +1 -1
- package/build/data-fetching/types.d.ts +17 -1
- package/build/types.d.ts +6 -5
- package/build/utils/getLocalizedCategoryData.d.ts +3 -3
- package/build/utils/getLocalizedCategoryData.js +2 -2
- package/build/utils/getStoryPublicationDate.d.ts +2 -2
- package/package.json +3 -3
- package/build/data-fetching/lib/getAlgoliaSettings.d.ts +0 -4
- package/build/data-fetching/lib/getAlgoliaSettings.js +0 -21
- package/build/data-fetching/lib/getAlgoliaSettings.js.map +0 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSearchSettings = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const getEnvVariables_1 = require("./getEnvVariables");
|
|
6
|
+
function getSearchSettings(req) {
|
|
7
|
+
(0, utils_1.assertServerEnv)('getSearchSettings');
|
|
8
|
+
// `getEnvVariables` handles both cases for envs parsing - .env and request headers
|
|
9
|
+
const { ALGOLIA_API_KEY = '', ALGOLIA_APP_ID = 'UI4CNRAHQB', ALGOLIA_INDEX = 'public_stories_prod', MEILISEARCH_API_KEY, MEILISEARCH_HOST = 'https://search.prezly.com', MEILISEARCH_INDEX = 'public_stories', } = (0, getEnvVariables_1.getEnvVariables)(req);
|
|
10
|
+
if (MEILISEARCH_API_KEY && MEILISEARCH_HOST && MEILISEARCH_INDEX) {
|
|
11
|
+
return {
|
|
12
|
+
apiKey: MEILISEARCH_API_KEY,
|
|
13
|
+
host: MEILISEARCH_HOST,
|
|
14
|
+
index: MEILISEARCH_INDEX,
|
|
15
|
+
searchBackend: 'meilisearch',
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
if (ALGOLIA_API_KEY && ALGOLIA_APP_ID && ALGOLIA_INDEX) {
|
|
19
|
+
return {
|
|
20
|
+
apiKey: ALGOLIA_API_KEY,
|
|
21
|
+
appId: ALGOLIA_APP_ID,
|
|
22
|
+
index: ALGOLIA_INDEX,
|
|
23
|
+
searchBackend: 'algolia',
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
exports.getSearchSettings = getSearchSettings;
|
|
29
|
+
//# sourceMappingURL=getSearchSettings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSearchSettings.js","sourceRoot":"","sources":["../../../src/data-fetching/lib/getSearchSettings.ts"],"names":[],"mappings":";;;AAEA,uCAA8C;AAG9C,uDAAoD;AAEpD,SAAgB,iBAAiB,CAAC,GAAqB;IACnD,IAAA,uBAAe,EAAC,mBAAmB,CAAC,CAAC;IAErC,mFAAmF;IACnF,MAAM,EACF,eAAe,GAAG,EAAE,EACpB,cAAc,GAAG,YAAY,EAC7B,aAAa,GAAG,qBAAqB,EACrC,mBAAmB,EACnB,gBAAgB,GAAG,2BAA2B,EAC9C,iBAAiB,GAAG,gBAAgB,GACvC,GAAG,IAAA,iCAAe,EAAC,GAAG,CAAC,CAAC;IAEzB,IAAI,mBAAmB,IAAI,gBAAgB,IAAI,iBAAiB,EAAE,CAAC;QAC/D,OAAO;YACH,MAAM,EAAE,mBAAmB;YAC3B,IAAI,EAAE,gBAAgB;YACtB,KAAK,EAAE,iBAAiB;YACxB,aAAa,EAAE,aAAa;SAC/B,CAAC;IACN,CAAC;IAED,IAAI,eAAe,IAAI,cAAc,IAAI,aAAa,EAAE,CAAC;QACrD,OAAO;YACH,MAAM,EAAE,eAAe;YACvB,KAAK,EAAE,cAAc;YACrB,KAAK,EAAE,aAAa;YACpB,aAAa,EAAE,SAAS;SAC3B,CAAC;IACN,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAhCD,8CAgCC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isUuid = exports.
|
|
4
|
-
var getAlgoliaSettings_1 = require("./getAlgoliaSettings");
|
|
5
|
-
Object.defineProperty(exports, "getAlgoliaSettings", { enumerable: true, get: function () { return getAlgoliaSettings_1.getAlgoliaSettings; } });
|
|
3
|
+
exports.isUuid = exports.getSearchSettings = exports.getEnvVariables = void 0;
|
|
6
4
|
var getEnvVariables_1 = require("./getEnvVariables");
|
|
7
5
|
Object.defineProperty(exports, "getEnvVariables", { enumerable: true, get: function () { return getEnvVariables_1.getEnvVariables; } });
|
|
6
|
+
var getSearchSettings_1 = require("./getSearchSettings");
|
|
7
|
+
Object.defineProperty(exports, "getSearchSettings", { enumerable: true, get: function () { return getSearchSettings_1.getSearchSettings; } });
|
|
8
8
|
var isUuid_1 = require("./isUuid");
|
|
9
9
|
Object.defineProperty(exports, "isUuid", { enumerable: true, get: function () { return isUuid_1.isUuid; } });
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/data-fetching/lib/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/data-fetching/lib/index.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAC1B,mCAAkC;AAAzB,gGAAA,MAAM,OAAA"}
|
|
@@ -3,11 +3,27 @@ export interface AlgoliaSettings {
|
|
|
3
3
|
ALGOLIA_APP_ID: string;
|
|
4
4
|
ALGOLIA_INDEX: string;
|
|
5
5
|
}
|
|
6
|
+
export interface MeiliSearchSettings {
|
|
7
|
+
MEILISEARCH_API_KEY: string;
|
|
8
|
+
MEILISEARCH_HOST: string;
|
|
9
|
+
MEILISEARCH_INDEX: string;
|
|
10
|
+
}
|
|
6
11
|
export interface PrezlyNewsroomEnv {
|
|
7
12
|
PREZLY_ACCESS_TOKEN: string;
|
|
8
13
|
PREZLY_NEWSROOM_UUID: string;
|
|
9
14
|
PREZLY_THEME_UUID?: string;
|
|
10
15
|
PREZLY_MODE?: 'preview';
|
|
11
16
|
}
|
|
12
|
-
export interface PrezlyEnv extends PrezlyNewsroomEnv, AlgoliaSettings {
|
|
17
|
+
export interface PrezlyEnv extends PrezlyNewsroomEnv, AlgoliaSettings, MeiliSearchSettings {
|
|
13
18
|
}
|
|
19
|
+
export type SearchSettings = {
|
|
20
|
+
searchBackend: 'algolia';
|
|
21
|
+
appId: string;
|
|
22
|
+
apiKey: string;
|
|
23
|
+
index: string;
|
|
24
|
+
} | {
|
|
25
|
+
searchBackend: 'meilisearch';
|
|
26
|
+
host: string;
|
|
27
|
+
apiKey: string;
|
|
28
|
+
index: string;
|
|
29
|
+
};
|
package/build/types.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import type { CultureRef, Story } from '@prezly/sdk';
|
|
2
|
+
export type StoryWithImage = Story & Pick<Story.ExtraFields, 'thumbnail_image'>;
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* Algolia/MeiliSearch category type
|
|
4
5
|
*/
|
|
5
|
-
export interface
|
|
6
|
+
export interface IndexedCategoryRef {
|
|
6
7
|
id: number;
|
|
7
8
|
name: string;
|
|
8
9
|
slug: string;
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
|
-
* Stories in Algolia index are stored in a simplified format, with only minimal subset of fields.
|
|
12
|
+
* Stories in Algolia/MeiliSearch index are stored in a simplified format, with only minimal subset of fields.
|
|
12
13
|
*/
|
|
13
|
-
export type
|
|
14
|
+
export type IndexedStory = Pick<Story, 'uuid' | 'slug' | 'title' | 'subtitle'> & Pick<Story.ExtraFields, 'thumbnail_image'> & {
|
|
14
15
|
content_text: string;
|
|
15
16
|
updated_at: number;
|
|
16
17
|
published_at: number;
|
|
17
18
|
culture: Pick<CultureRef, 'code' | 'name' | 'native_name' | 'language_code'>;
|
|
18
|
-
categories:
|
|
19
|
+
categories: IndexedCategoryRef[];
|
|
19
20
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Category } from '@prezly/sdk';
|
|
2
2
|
import type { LocaleObject } from '../intl';
|
|
3
|
-
import type {
|
|
3
|
+
import type { IndexedCategoryRef } from '../types';
|
|
4
4
|
interface LocalizedCategoryData {
|
|
5
5
|
description: string | null;
|
|
6
6
|
name: string;
|
|
7
7
|
slug: string | null;
|
|
8
8
|
}
|
|
9
|
-
export declare function getLocalizedCategoryData(category: Pick<Category, 'i18n' | 'display_name'> |
|
|
10
|
-
export declare function getCategoryUrl(category: Pick<Category, 'i18n' | 'display_name'> |
|
|
9
|
+
export declare function getLocalizedCategoryData(category: Pick<Category, 'i18n' | 'display_name'> | IndexedCategoryRef, locale: LocaleObject): LocalizedCategoryData;
|
|
10
|
+
export declare function getCategoryUrl(category: Pick<Category, 'i18n' | 'display_name'> | IndexedCategoryRef, locale: LocaleObject): string;
|
|
11
11
|
export declare function getCategoryHasTranslation(category: Pick<Category, 'i18n'>, locale: LocaleObject): boolean;
|
|
12
12
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCategoryHasTranslation = exports.getCategoryUrl = exports.getLocalizedCategoryData = void 0;
|
|
4
|
-
function
|
|
4
|
+
function isIndexedCategory(category) {
|
|
5
5
|
return 'name' in category && 'slug' in category;
|
|
6
6
|
}
|
|
7
7
|
function getLocalizedCategoryData(category, locale) {
|
|
8
|
-
if (
|
|
8
|
+
if (isIndexedCategory(category)) {
|
|
9
9
|
return {
|
|
10
10
|
description: null,
|
|
11
11
|
name: category.name,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Story } from '@prezly/sdk';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function getStoryPublicationDate(story: Pick<Story, 'published_at'> |
|
|
2
|
+
import type { IndexedStory } from '../types';
|
|
3
|
+
export declare function getStoryPublicationDate(story: Pick<Story, 'published_at'> | IndexedStory): Date | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prezly/theme-kit-core",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.7.0",
|
|
4
4
|
"description": "Data layer and utility library for developing Prezly themes with JavaScript",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"test": "jest"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@prezly/sdk": "21.
|
|
39
|
+
"@prezly/sdk": "21.12.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@prezly/theme-kit-intl": "^7.5.1",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"publishConfig": {
|
|
74
74
|
"access": "public"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "fb14a0f5781687589692182a9815ceca2c85e048"
|
|
77
77
|
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAlgoliaSettings = void 0;
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
const getEnvVariables_1 = require("./getEnvVariables");
|
|
6
|
-
function getAlgoliaSettings(req) {
|
|
7
|
-
(0, utils_1.assertServerEnv)('getAlgoliaSettings');
|
|
8
|
-
// `getEnvVariables` handles both cases for envs parsing - .env and request headers
|
|
9
|
-
const { ALGOLIA_API_KEY = '', ALGOLIA_APP_ID = 'UI4CNRAHQB', ALGOLIA_INDEX = 'public_stories_prod', } = (0, getEnvVariables_1.getEnvVariables)(req);
|
|
10
|
-
if (!ALGOLIA_API_KEY) {
|
|
11
|
-
// eslint-disable-next-line no-console
|
|
12
|
-
console.error('"ALGOLIA_API_KEY" is not set in env variables. Search will not be enabled');
|
|
13
|
-
}
|
|
14
|
-
return {
|
|
15
|
-
ALGOLIA_API_KEY,
|
|
16
|
-
ALGOLIA_APP_ID,
|
|
17
|
-
ALGOLIA_INDEX,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
exports.getAlgoliaSettings = getAlgoliaSettings;
|
|
21
|
-
//# sourceMappingURL=getAlgoliaSettings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getAlgoliaSettings.js","sourceRoot":"","sources":["../../../src/data-fetching/lib/getAlgoliaSettings.ts"],"names":[],"mappings":";;;AAEA,uCAA8C;AAG9C,uDAAoD;AAEpD,SAAgB,kBAAkB,CAAC,GAAqB;IACpD,IAAA,uBAAe,EAAC,oBAAoB,CAAC,CAAC;IAEtC,mFAAmF;IACnF,MAAM,EACF,eAAe,GAAG,EAAE,EACpB,cAAc,GAAG,YAAY,EAC7B,aAAa,GAAG,qBAAqB,GACxC,GAAG,IAAA,iCAAe,EAAC,GAAG,CAAC,CAAC;IAEzB,IAAI,CAAC,eAAe,EAAE,CAAC;QACnB,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,2EAA2E,CAAC,CAAC;IAC/F,CAAC;IAED,OAAO;QACH,eAAe;QACf,cAAc;QACd,aAAa;KAChB,CAAC;AACN,CAAC;AApBD,gDAoBC"}
|