@prezly/sdk 18.1.0 → 18.2.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/api/constants.cjs
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.DEFAULT_USER_AGENT = void 0;
|
|
7
|
-
const VERSION = "18.
|
|
7
|
+
const VERSION = "18.1.1";
|
|
8
8
|
const URL = 'https://github.com/prezly/javascript-sdk';
|
|
9
9
|
const DEFAULT_USER_AGENT = `prezly-javascript-sdk/${VERSION} (+${URL})`;
|
|
10
10
|
exports.DEFAULT_USER_AGENT = DEFAULT_USER_AGENT;
|
package/dist/api/constants.js
CHANGED
package/dist/types/Category.cjs
CHANGED
|
@@ -6,4 +6,38 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.Category = void 0;
|
|
7
7
|
let Category;
|
|
8
8
|
exports.Category = Category;
|
|
9
|
-
(function (_Category) {
|
|
9
|
+
(function (_Category) {
|
|
10
|
+
function isTranslated(category, locale) {
|
|
11
|
+
const translation = category.i18n[localeCode(locale)];
|
|
12
|
+
return isNonEmpty(translation);
|
|
13
|
+
}
|
|
14
|
+
_Category.isTranslated = isTranslated;
|
|
15
|
+
function translation(category, locale) {
|
|
16
|
+
const [translation] = Category.translations(category, locale);
|
|
17
|
+
return translation;
|
|
18
|
+
}
|
|
19
|
+
_Category.translation = translation;
|
|
20
|
+
function translations(input, locale) {
|
|
21
|
+
const code = locale ? localeCode(locale) : undefined;
|
|
22
|
+
const categories = Array.isArray(input) ? input : [input];
|
|
23
|
+
return categories.reduce((result, category) => {
|
|
24
|
+
const translated = (code ? [category.i18n[code]] : Object.values(category.i18n)).filter(isNonEmpty).map(translation => {
|
|
25
|
+
return {
|
|
26
|
+
id: category.id,
|
|
27
|
+
locale: translation.locale.code,
|
|
28
|
+
slug: translation.slug,
|
|
29
|
+
name: translation.name,
|
|
30
|
+
description: translation.description
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
return [...result, ...translated];
|
|
34
|
+
}, []);
|
|
35
|
+
}
|
|
36
|
+
_Category.translations = translations;
|
|
37
|
+
})(Category || (exports.Category = Category = {}));
|
|
38
|
+
function isNonEmpty(translation) {
|
|
39
|
+
return Boolean(translation && translation.name && translation.slug);
|
|
40
|
+
}
|
|
41
|
+
function localeCode(locale) {
|
|
42
|
+
return typeof locale === 'string' ? locale : locale.code;
|
|
43
|
+
}
|
package/dist/types/Category.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ export interface CategoryRef {
|
|
|
3
3
|
id: number;
|
|
4
4
|
display_name: string;
|
|
5
5
|
display_description: string | null;
|
|
6
|
-
i18n:
|
|
6
|
+
i18n: {
|
|
7
7
|
[localeCode: Culture.Code]: Category.Translation;
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
9
|
stories_number: number;
|
|
10
10
|
}
|
|
11
11
|
export interface Category extends CategoryRef {
|
|
@@ -19,4 +19,28 @@ export declare namespace Category {
|
|
|
19
19
|
name: string;
|
|
20
20
|
description: string | null;
|
|
21
21
|
}
|
|
22
|
+
function isTranslated<T extends Category, LocaleCode extends Culture['code']>(category: T, locale: LocaleIdentifier<LocaleCode>): category is WithNonEmptyTranslation<T, LocaleCode>;
|
|
23
|
+
function translation<T extends Category, LocaleCode extends Culture['code']>(category: T, locale: LocaleIdentifier<LocaleCode>): T extends WithNonEmptyTranslation<Category, LocaleCode> ? TranslatedCategory : TranslatedCategory | undefined;
|
|
24
|
+
function translations(category: Category, locale?: LocaleIdentifier): TranslatedCategory[];
|
|
25
|
+
function translations(categories: Category[], locale?: LocaleIdentifier): TranslatedCategory[];
|
|
22
26
|
}
|
|
27
|
+
export interface TranslatedCategory {
|
|
28
|
+
id: Category['id'];
|
|
29
|
+
locale: Culture['code'];
|
|
30
|
+
slug: NonNullable<Category.Translation['slug']>;
|
|
31
|
+
name: Category.Translation['name'];
|
|
32
|
+
description: Category.Translation['description'];
|
|
33
|
+
}
|
|
34
|
+
declare type LocaleIdentifier<Locale extends Culture['code'] = Culture['code']> = Locale | {
|
|
35
|
+
code: Locale;
|
|
36
|
+
};
|
|
37
|
+
declare type NonEmptyTranslation = Category.Translation & {
|
|
38
|
+
slug: NonNullable<Category.Translation['slug']>;
|
|
39
|
+
name: Exclude<Category.Translation['name'], ''>;
|
|
40
|
+
};
|
|
41
|
+
declare type WithNonEmptyTranslation<T extends Category, LocaleCode extends Culture['code']> = T & {
|
|
42
|
+
i18n: {
|
|
43
|
+
[localeCode in LocaleCode]: NonEmptyTranslation;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export {};
|
package/dist/types/Category.js
CHANGED
|
@@ -1,2 +1,36 @@
|
|
|
1
1
|
export let Category;
|
|
2
|
-
(function (_Category) {
|
|
2
|
+
(function (_Category) {
|
|
3
|
+
function isTranslated(category, locale) {
|
|
4
|
+
const translation = category.i18n[localeCode(locale)];
|
|
5
|
+
return isNonEmpty(translation);
|
|
6
|
+
}
|
|
7
|
+
_Category.isTranslated = isTranslated;
|
|
8
|
+
function translation(category, locale) {
|
|
9
|
+
const [translation] = Category.translations(category, locale);
|
|
10
|
+
return translation;
|
|
11
|
+
}
|
|
12
|
+
_Category.translation = translation;
|
|
13
|
+
function translations(input, locale) {
|
|
14
|
+
const code = locale ? localeCode(locale) : undefined;
|
|
15
|
+
const categories = Array.isArray(input) ? input : [input];
|
|
16
|
+
return categories.reduce((result, category) => {
|
|
17
|
+
const translated = (code ? [category.i18n[code]] : Object.values(category.i18n)).filter(isNonEmpty).map(translation => {
|
|
18
|
+
return {
|
|
19
|
+
id: category.id,
|
|
20
|
+
locale: translation.locale.code,
|
|
21
|
+
slug: translation.slug,
|
|
22
|
+
name: translation.name,
|
|
23
|
+
description: translation.description
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
return [...result, ...translated];
|
|
27
|
+
}, []);
|
|
28
|
+
}
|
|
29
|
+
_Category.translations = translations;
|
|
30
|
+
})(Category || (Category = {}));
|
|
31
|
+
function isNonEmpty(translation) {
|
|
32
|
+
return Boolean(translation && translation.name && translation.slug);
|
|
33
|
+
}
|
|
34
|
+
function localeCode(locale) {
|
|
35
|
+
return typeof locale === 'string' ? locale : locale.code;
|
|
36
|
+
}
|
package/dist/types/SortOrder.cjs
CHANGED
|
@@ -91,7 +91,7 @@ function toObject(sortOrder) {
|
|
|
91
91
|
}
|
|
92
92
|
function parseColumn(column) {
|
|
93
93
|
if (column.startsWith('+')) {
|
|
94
|
-
const [, name] = column.split('+');
|
|
94
|
+
const [, name = ''] = column.split('+');
|
|
95
95
|
validateColumnName(name);
|
|
96
96
|
return {
|
|
97
97
|
name,
|
|
@@ -99,7 +99,7 @@ function parseColumn(column) {
|
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
if (column.startsWith('-')) {
|
|
102
|
-
const [, name] = column.split('-');
|
|
102
|
+
const [, name = ''] = column.split('-');
|
|
103
103
|
validateColumnName(name);
|
|
104
104
|
return {
|
|
105
105
|
name,
|
package/dist/types/SortOrder.js
CHANGED
|
@@ -84,7 +84,7 @@ function toObject(sortOrder) {
|
|
|
84
84
|
}
|
|
85
85
|
function parseColumn(column) {
|
|
86
86
|
if (column.startsWith('+')) {
|
|
87
|
-
const [, name] = column.split('+');
|
|
87
|
+
const [, name = ''] = column.split('+');
|
|
88
88
|
validateColumnName(name);
|
|
89
89
|
return {
|
|
90
90
|
name,
|
|
@@ -92,7 +92,7 @@ function parseColumn(column) {
|
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
if (column.startsWith('-')) {
|
|
95
|
-
const [, name] = column.split('-');
|
|
95
|
+
const [, name = ''] = column.split('-');
|
|
96
96
|
validateColumnName(name);
|
|
97
97
|
return {
|
|
98
98
|
name,
|