@unchainedshop/cockpit-api 2.1.0 → 2.1.1

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.
@@ -13,9 +13,8 @@ export interface CockpitAPIOptions {
13
13
  /**
14
14
  * Default language that maps to Cockpit's "default" locale.
15
15
  * When a request uses this language, it will be sent as "default" to Cockpit.
16
- * @default "de"
17
16
  */
18
- defaultLanguage?: string;
17
+ defaultLanguage?: string | null;
19
18
  /** Cache configuration */
20
19
  cache?: {
21
20
  /** Max entries (falls back to COCKPIT_CACHE_MAX env var, default: 100) */
@@ -36,7 +35,7 @@ export interface CockpitConfig {
36
35
  readonly tenant?: string;
37
36
  readonly apiKey?: string;
38
37
  readonly useAdminAccess: boolean;
39
- readonly defaultLanguage: string;
38
+ readonly defaultLanguage: string | null;
40
39
  readonly cachePrefix: string;
41
40
  }
42
41
  /**
@@ -23,7 +23,7 @@ export function createConfig(options = {}) {
23
23
  const config = Object.freeze({
24
24
  endpoint,
25
25
  useAdminAccess: options.useAdminAccess ?? false,
26
- defaultLanguage: options.defaultLanguage ?? "de",
26
+ defaultLanguage: options.defaultLanguage ?? null,
27
27
  cachePrefix: `${endpointStr}:${options.tenant ?? "default"}:`,
28
28
  ...(options.tenant !== undefined && { tenant: options.tenant }),
29
29
  ...(apiKey !== undefined && { apiKey }),
@@ -5,7 +5,7 @@
5
5
  * Creates a locale normalizer for the given default language.
6
6
  * Maps the default language to Cockpit's "default" locale.
7
7
  *
8
- * @param defaultLanguage - The language that should map to "default"
8
+ * @param defaultLanguage - The language that should map to "default", or null to disable mapping
9
9
  * @returns A function that normalizes locale strings
10
10
  */
11
- export declare function createLocaleNormalizer(defaultLanguage: string): (locale?: string) => string;
11
+ export declare function createLocaleNormalizer(defaultLanguage: string | null): (locale?: string) => string;
@@ -5,12 +5,14 @@
5
5
  * Creates a locale normalizer for the given default language.
6
6
  * Maps the default language to Cockpit's "default" locale.
7
7
  *
8
- * @param defaultLanguage - The language that should map to "default"
8
+ * @param defaultLanguage - The language that should map to "default", or null to disable mapping
9
9
  * @returns A function that normalizes locale strings
10
10
  */
11
11
  export function createLocaleNormalizer(defaultLanguage) {
12
12
  return (locale) => {
13
- if (locale === undefined || locale === defaultLanguage)
13
+ if (locale === undefined)
14
+ return "default";
15
+ if (defaultLanguage !== null && locale === defaultLanguage)
14
16
  return "default";
15
17
  return locale;
16
18
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unchainedshop/cockpit-api",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "A package to interact with the Cockpit CMS API, including functionalities to handle GraphQL requests and various CMS content manipulations.",
5
5
  "main": "dist/index.js",
6
6
  "homepage": "https://unchained.shop",