@prezly/sdk 17.1.0 → 18.0.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
@@ -100,3 +100,15 @@ const { createPrezlyClient } = require('@prezly/sdk');
100
100
 
101
101
  We recommend referring to the [official `cross-fetch` module documentation](https://www.npmjs.com/package/cross-fetch) for more information.
102
102
 
103
+ #### Custom `fetch` implementation
104
+
105
+ Additionally, you can initialize the API client with your own implementation of `fetch`:
106
+
107
+ ```js
108
+ import { createPrezlyClient } = from '@prezly/sdk';
109
+
110
+ const prezlyClient = createPrezlyClient({
111
+ accessToken: 'your-access-token',
112
+ fetch: customFetch,
113
+ });
114
+ ```
@@ -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 = "17.0.0";
7
+ const VERSION = "17.1.0";
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;
@@ -1,3 +1,3 @@
1
- const VERSION = "17.0.0";
1
+ const VERSION = "17.1.0";
2
2
  const URL = 'https://github.com/prezly/javascript-sdk';
3
3
  export const DEFAULT_USER_AGENT = `prezly-javascript-sdk/${VERSION} (+${URL})`;
@@ -4,7 +4,7 @@ export interface CategoryRef {
4
4
  display_name: string;
5
5
  display_description: string | null;
6
6
  i18n: {
7
- [localeCode: string]: {
7
+ [localeCode: CultureRef['code']]: {
8
8
  description: string | null;
9
9
  locale: CultureRef;
10
10
  name: string;
@@ -13,4 +13,8 @@ exports.Culture = Culture;
13
13
  TextDirection["RTL"] = "rtl";
14
14
  })(TextDirection || (TextDirection = {}));
15
15
  _Culture.TextDirection = TextDirection;
16
+ function isoCode(code) {
17
+ return code.replace('_', '-');
18
+ }
19
+ _Culture.isoCode = isoCode;
16
20
  })(Culture || (exports.Culture = Culture = {}));
@@ -1,10 +1,10 @@
1
1
  export interface CultureRef {
2
- code: string;
3
- locale: string;
2
+ code: Culture.Code;
3
+ locale: Culture.Code;
4
4
  name: string;
5
5
  native_name: string;
6
- direction: Culture.TextDirection;
7
- language_code: string;
6
+ direction: `${Culture.TextDirection}`;
7
+ language_code: Culture.LangCode;
8
8
  }
9
9
  export declare type Culture = CultureRef;
10
10
  export declare namespace Culture {
@@ -12,4 +12,16 @@ export declare namespace Culture {
12
12
  LTR = "ltr",
13
13
  RTL = "rtl"
14
14
  }
15
+ /**
16
+ * Primary locale code used everywhere in the Prezly app.
17
+ */
18
+ type Code = `${LangCode}` | `${LangCode}_${RegionCode}` | `${LangCode}_${ScriptCode}` | `${LangCode}_${ScriptCode}_${RegionCode}`;
19
+ /**
20
+ * Locale ISO code to be used in HTML attributes.
21
+ */
22
+ type IsoCode = `${LangCode}` | `${LangCode}-${RegionCode}` | `${LangCode}-${ScriptCode}` | `${LangCode}-${ScriptCode}-${RegionCode}`;
23
+ type LangCode = `${Lowercase<string>}`;
24
+ type ScriptCode = string;
25
+ type RegionCode = `${Uppercase<string>}`;
26
+ function isoCode(code: Code): IsoCode;
15
27
  }
@@ -6,4 +6,8 @@ export let Culture;
6
6
  TextDirection["RTL"] = "rtl";
7
7
  })(TextDirection || (TextDirection = {}));
8
8
  _Culture.TextDirection = TextDirection;
9
+ function isoCode(code) {
10
+ return code.replace('_', '-');
11
+ }
12
+ _Culture.isoCode = isoCode;
9
13
  })(Culture || (Culture = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prezly/sdk",
3
- "version": "17.1.0",
3
+ "version": "18.0.0",
4
4
  "description": "Prezly API SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",