@laioutr/app-shopware 0.17.0 → 0.18.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/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laioutr/app-shopware",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "configKey": "@laioutr/app-shopware",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.1",
package/dist/module.mjs CHANGED
@@ -4,7 +4,7 @@ import { CHECKOUT_ENDPOINT_PATH, ADOPT_SESSION_ENDPOINT_PATH, ORDER_HANDOFF_ENDP
4
4
  import { registerLaioutrApp } from '@laioutr-core/kit';
5
5
 
6
6
  const name = "@laioutr/app-shopware";
7
- const version = "0.17.0";
7
+ const version = "0.18.0";
8
8
 
9
9
  const module$1 = defineNuxtModule({
10
10
  meta: {
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Send a visitor asking for their account to Shopware's own login page. Shopware authenticates
3
+ * with credentials rather than an OAuth handshake, so this answers the union's `account` arm and
4
+ * the storefront navigates there.
5
+ *
6
+ * `returnTo` is dropped: Shopware's login redirect takes one of its own route names, not a URL,
7
+ * so a laioutr path cannot travel through it.
8
+ */
9
+ declare const _default: any;
10
+ export default _default;
@@ -0,0 +1,13 @@
1
+ import { useRuntimeConfig } from "#imports";
2
+ import { AuthLoginOauthAction } from "@laioutr-core/canonical-types/ecommerce";
3
+ import { defineShopwareAction } from "../../middleware/defineShopware.js";
4
+ export default defineShopwareAction(AuthLoginOauthAction, async () => {
5
+ const { storefrontUrl } = useRuntimeConfig()["@laioutr/app-shopware"];
6
+ if (!storefrontUrl) {
7
+ throw new Error("storefrontUrl is not configured, so there is no Shopware login page to send the customer to");
8
+ }
9
+ return {
10
+ type: "account",
11
+ link: { type: "url", href: new URL("/account/login", storefrontUrl).toString() }
12
+ };
13
+ });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Read the customer behind the request's context token. Shopware answers `403` when the token
3
+ * belongs to a guest context, which is the signal callers use to tell a session from none.
4
+ *
5
+ * `addresses` stays empty: Shopware returns addresses only as an association, and each one needs
6
+ * its `countryId` resolved to the ISO code `MailingAddress` requires. Nothing reads them yet, so
7
+ * the lookup is not made — extend this handler before relying on the field.
8
+ */
9
+ declare const _default: any;
10
+ export default _default;
@@ -0,0 +1,22 @@
1
+ import { CustomerGetCurrentAction, UnauthenticatedError } from "@laioutr-core/canonical-types/ecommerce";
2
+ import { defineShopwareAction } from "../../middleware/defineShopware.js";
3
+ export default defineShopwareAction(CustomerGetCurrentAction, async ({ context }) => {
4
+ let customer;
5
+ try {
6
+ customer = await context.storefrontClient.invoke("readCustomer post /account/customer", {});
7
+ } catch {
8
+ throw new UnauthenticatedError();
9
+ }
10
+ const firstName = customer.firstName ?? "";
11
+ const lastName = customer.lastName ?? "";
12
+ const displayName = `${firstName} ${lastName}`.trim();
13
+ return {
14
+ customer: {
15
+ id: customer.id,
16
+ email: customer.email,
17
+ displayName: displayName || (customer.email ?? ""),
18
+ person: { firstName, lastName, salutation: customer.salutation?.salutationKey, title: customer.title ?? void 0 },
19
+ addresses: []
20
+ }
21
+ };
22
+ });
@@ -2,7 +2,7 @@ import { MenuByAliasQuery } from "@laioutr-core/canonical-types/ecommerce";
2
2
  import { defineShopwareQueryTemplateProvider } from "../../middleware/defineShopware.js";
3
3
  export default defineShopwareQueryTemplateProvider({
4
4
  for: MenuByAliasQuery,
5
- run: async ({ input, context }) => [
5
+ run: async () => [
6
6
  {
7
7
  input: {
8
8
  alias: "main-navigation"
@@ -1,8 +1,17 @@
1
1
  import { ProductReviewsLink } from "@laioutr-core/canonical-types/ecommerce";
2
2
  import { currentProductIdsToken } from "../../const/passthroughTokens.js";
3
3
  import { defineShopwareLink } from "../../middleware/defineShopware.js";
4
- export default defineShopwareLink(ProductReviewsLink, async ({ entityIds, context, pagination, passthrough }) => {
4
+ const REVIEW_SORTINGS = {
5
+ newest: { field: "createdAt", order: "DESC" },
6
+ oldest: { field: "createdAt", order: "ASC" },
7
+ "rating-high": { field: "points", order: "DESC" },
8
+ "rating-low": { field: "points", order: "ASC" }
9
+ };
10
+ export default defineShopwareLink(ProductReviewsLink, async ({ entityIds, context, pagination, sorting, filter, passthrough }) => {
5
11
  const { storefrontClient } = context;
12
+ const sort = sorting ? REVIEW_SORTINGS[sorting] : void 0;
13
+ const points = Number(filter?.points);
14
+ const criteriaFilter = Number.isFinite(points) ? [{ type: "equals", field: "points", value: points }] : void 0;
6
15
  const productToReviews = {};
7
16
  await Promise.all(
8
17
  entityIds.map(async (entityId) => {
@@ -11,6 +20,8 @@ export default defineShopwareLink(ProductReviewsLink, async ({ entityIds, contex
11
20
  body: {
12
21
  page: pagination.page,
13
22
  limit: pagination.limit,
23
+ ...sort ? { sort: [sort] } : {},
24
+ ...criteriaFilter ? { filter: criteriaFilter } : {},
14
25
  includes: {
15
26
  product_review: ["id"]
16
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laioutr/app-shopware",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "Laioutr integration with Shopware 6",
5
5
  "repository": "github:laioutr/app-shopware",
6
6
  "license": "MIT",