@lookiero/checkout 0.8.21 → 0.8.22

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/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import { EndpointFunction } from "@lookiero/i18n";
2
2
  import { ComponentType } from "react";
3
3
  import { CheckoutStatus } from "./domain/checkout/model/checkout";
4
4
  import { RootProps } from "./infrastructure/ui/Root";
5
+ import { translationEndpoint, translationExternalEndpoint } from "./infrastructure/ui/i18n/translationEndpoint";
5
6
  import { CheckoutProjection } from "./projection/checkout/checkout";
6
7
  import { IsCheckoutAccessibleByCustomerIdProjection } from "./projection/checkout/viewIsCheckoutAccessibleByCustomerId";
7
8
  import { SentryEnvironment } from "./shared/logging/SentryLogger";
@@ -32,4 +33,4 @@ interface BootstrapFunction {
32
33
  (args: BootstrapFunctionArgs): BootstrapFunctionReturn;
33
34
  }
34
35
  declare const bootstrap: BootstrapFunction;
35
- export { bootstrap, CheckoutStatus };
36
+ export { bootstrap, translationEndpoint, translationExternalEndpoint, CheckoutStatus };
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import { CheckoutStatus } from "./domain/checkout/model/checkout";
3
3
  import { bootstrap as checkoutBootstrap } from "./infrastructure/delivery/bootstrap";
4
4
  import { root } from "./infrastructure/ui/Root";
5
5
  import { fetchTranslations } from "./infrastructure/ui/i18n/fetchTranslations";
6
+ import { translationEndpoint, translationExternalEndpoint } from "./infrastructure/ui/i18n/translationEndpoint";
6
7
  import { viewFirstAvailableCheckoutByCustomerId } from "./projection/checkout/viewFirstAvailableCheckoutByCustomerId";
7
8
  import { viewIsCheckoutAccessibleByCustomerId, } from "./projection/checkout/viewIsCheckoutAccessibleByCustomerId";
8
9
  const bootstrap = ({ apiUrl, getAuthToken, translations, sentry }) => {
@@ -20,4 +21,4 @@ const bootstrap = ({ apiUrl, getAuthToken, translations, sentry }) => {
20
21
  firstAvailableCheckoutByCustomerId,
21
22
  };
22
23
  };
23
- export { bootstrap, CheckoutStatus };
24
+ export { bootstrap, translationEndpoint, translationExternalEndpoint, CheckoutStatus };
@@ -7,4 +7,13 @@ interface TranslationEndpointFunction {
7
7
  (args: TranslationEndpointFunctionArgs): EndpointFunction;
8
8
  }
9
9
  declare const translationEndpoint: TranslationEndpointFunction;
10
- export { translationEndpoint };
10
+ type Project = "user-area-front" | "inventory-catalog";
11
+ interface TranslationExternalEndpointFunctionArgs {
12
+ readonly translationsUrl: string;
13
+ readonly projects: [project: Project, filter?: string][];
14
+ }
15
+ interface TranslationExternalEndpointFunction {
16
+ (args: TranslationExternalEndpointFunctionArgs): EndpointFunction;
17
+ }
18
+ declare const translationExternalEndpoint: TranslationExternalEndpointFunction;
19
+ export { translationEndpoint, translationExternalEndpoint };
@@ -1,2 +1,20 @@
1
+ import { Country } from "../../../projection/shared/country";
2
+ import { Locale } from "../../../projection/shared/locale";
1
3
  const translationEndpoint = ({ translationsUrl, translationsApiKey }) => (locale) => `${translationsUrl}/${locale}?key=${translationsApiKey}&no-folding=true`;
2
- export { translationEndpoint };
4
+ const COUNTRY = {
5
+ [Locale.ES]: Country.ES,
6
+ [Locale.FR]: Country.FR,
7
+ [Locale.EN]: Country.GB,
8
+ [Locale.IT]: Country.IT,
9
+ [Locale.PT]: Country.PT,
10
+ [Locale.DE]: Country.DE,
11
+ [Locale.AT]: Country.AT,
12
+ [Locale.NL]: Country.NL,
13
+ };
14
+ const translationExternalEndpoint = ({ translationsUrl, projects }) => (locale) => {
15
+ const projectsQueryParam = projects
16
+ .map(([project, filter]) => `projectFilter=${project}${filter ? `:${filter}` : ""}`)
17
+ .join("&");
18
+ return `${translationsUrl}/${locale}/${COUNTRY[locale]}?${projectsQueryParam}`;
19
+ };
20
+ export { translationEndpoint, translationExternalEndpoint };
@@ -1,9 +1,9 @@
1
- import { invariant } from "@remix-run/router";
2
1
  import React, { createContext, useContext } from "react";
2
+ import invariant from "tiny-invariant";
3
3
  const BasePathContext = createContext(null);
4
4
  export const BasePathProvider = ({ basePath, children }) => (React.createElement(BasePathContext.Provider, { value: basePath }, children));
5
5
  export const useBasePath = () => {
6
6
  const basePath = useContext(BasePathContext);
7
- invariant(basePath, "Your are trying to use the useBasePath hook without wrapping your app with the <BasePathProvider>.");
7
+ invariant(basePath !== null, "Your are trying to use the useBasePath hook without wrapping your app with the <BasePathProvider>.");
8
8
  return basePath;
9
9
  };
@@ -1,13 +1,13 @@
1
1
  declare enum Country {
2
- "ES" = "ES",
3
- "FR" = "FR",
4
- "GB" = "GB",
5
- "BE" = "BE",
6
- "LU" = "LU",
7
- "IT" = "IT",
8
- "PT" = "PT",
9
- "DE" = "DE",
10
- "AT" = "AT",
11
- "NL" = "NL"
2
+ ES = "ES",
3
+ FR = "FR",
4
+ GB = "GB",
5
+ BE = "BE",
6
+ LU = "LU",
7
+ IT = "IT",
8
+ PT = "PT",
9
+ DE = "DE",
10
+ AT = "AT",
11
+ NL = "NL"
12
12
  }
13
13
  export { Country };
@@ -0,0 +1,11 @@
1
+ declare enum Locale {
2
+ ES = "es",
3
+ FR = "fr",
4
+ EN = "en",
5
+ IT = "it",
6
+ PT = "pt",
7
+ DE = "de",
8
+ AT = "at",
9
+ NL = "nl"
10
+ }
11
+ export { Locale };
@@ -0,0 +1,12 @@
1
+ var Locale;
2
+ (function (Locale) {
3
+ Locale["ES"] = "es";
4
+ Locale["FR"] = "fr";
5
+ Locale["EN"] = "en";
6
+ Locale["IT"] = "it";
7
+ Locale["PT"] = "pt";
8
+ Locale["DE"] = "de";
9
+ Locale["AT"] = "at";
10
+ Locale["NL"] = "nl";
11
+ })(Locale || (Locale = {}));
12
+ export { Locale };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.8.21",
3
+ "version": "0.8.22",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [