@revenexx/cover 0.2.43 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revenexx/cover",
3
- "version": "0.2.43",
3
+ "version": "0.3.0",
4
4
  "description": "Cover \u2014 revenexx design system for Nuxt. Distributed as a Nuxt layer: generic UI components, theming tokens and stores shared by the demo shop, custom storefronts and the Blokkli theme.",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
@@ -40,7 +40,7 @@
40
40
  "@formkit/vue": "^1.6.0",
41
41
  "@iconify-json/lucide": "^1.2.111",
42
42
  "@internationalized/date": "^3.12.0",
43
- "@revenexx/sdk": "^0.0.15",
43
+ "@revenexx/sdk": "^0.2.0",
44
44
  "@revenexx/storage-model-viewer": "^0.3.0",
45
45
  "@vueuse/core": "^14.3.0",
46
46
  "typesense": "^3.0.5"
@@ -81,7 +81,7 @@ export default defineEventHandler(async (event) => {
81
81
  ...(firstName ? { firstName } : {}),
82
82
  ...(lastName ? { lastName } : {}),
83
83
  ...(profile?.company ? { organizationName: profile.company } : {}),
84
- locale: resolveLocale(event),
84
+ locale: await resolveStoreLocale(event),
85
85
  }) as unknown as {
86
86
  contact: { id: string; email: string };
87
87
  user_id: string;
@@ -101,7 +101,7 @@ async function resolveLiveOverrides(
101
101
  if (resolveShippingServiceKey(event) === "api") {
102
102
  const method = body.deliveryMethod ?? "standard";
103
103
  try {
104
- const { rates } = await useRevenexxSdk().shipping.shippingRates({
104
+ const { rates } = await useRevenexxSdk().shippingMethods.shippingRates({
105
105
  orderValue: subtotal,
106
106
  country: "",
107
107
  ...(currency ? { currency } : {}),
@@ -12,7 +12,7 @@ export default defineEventHandler(async (event) => {
12
12
  }
13
13
 
14
14
  try {
15
- return await getCheckoutProfileService().getProfile(event, user?.$id ?? null);
15
+ return await getCheckoutProfileService().getProfile(event, user ?? null);
16
16
  }
17
17
  catch (err) {
18
18
  getLogService().error("Service error: checkout/profile", toErrorContext(err));
@@ -1,4 +1,4 @@
1
- import { OrderPaymentStatus } from "@revenexx/sdk";
1
+ import { OrderPaymentStatus, PromotionsRedemptionsReleaseReason } from "@revenexx/sdk";
2
2
  import type { Models } from "@revenexx/sdk";
3
3
 
4
4
  // Method codes are generic — live mode validates them against the
@@ -181,7 +181,7 @@ export default defineEventHandler(async (event) => {
181
181
  if (liveShipping && body.deliveryMethod) {
182
182
  const address = body.address as Record<string, unknown> | undefined;
183
183
  try {
184
- const { rates } = await useRevenexxSdk().shipping.shippingRates({
184
+ const { rates } = await useRevenexxSdk().shippingMethods.shippingRates({
185
185
  orderValue: calculation.totals.find(row => row.key === "subtotal")?.amount
186
186
  ?? calculation.totals.find(row => row.key === "total")?.amount ?? 0,
187
187
  country: String(address?.country ?? ""),
@@ -400,7 +400,7 @@ export default defineEventHandler(async (event) => {
400
400
  // waiting out the expiry — the next buyer should find the code
401
401
  // usable, not blocked by an attempt that failed.
402
402
  if (reserved === "held" && cartId) {
403
- await releaseRedemption(event, { cartId, reason: "order placement failed" });
403
+ await releaseRedemption(event, { cartId, reason: PromotionsRedemptionsReleaseReason.CartReleased });
404
404
  }
405
405
  if (err instanceof RevenexxException && (err.code === 400 || err.code === 422)) {
406
406
  throw createError({ status: 422, message: err.message });
@@ -28,7 +28,7 @@ export default defineEventHandler(async (event) => {
28
28
 
29
29
  if (resolvePaymentServiceKey(event) !== "api") {
30
30
  const user = await getAuthService(event).me(event);
31
- const profile = await getCheckoutProfileService().getProfile(event, user?.$id ?? null);
31
+ const profile = await getCheckoutProfileService().getProfile(event, user ?? null);
32
32
  return {
33
33
  managed: false,
34
34
  methods: profile.availablePaymentMethods,
@@ -38,7 +38,7 @@ export default defineEventHandler(async (event) => {
38
38
 
39
39
  const locale: Locale = resolveLocale(event);
40
40
  try {
41
- const { methods } = await useRevenexxSdk().payments.paymentsMethodsEligible({
41
+ const { methods } = await useRevenexxSdk().paymentsMethods.paymentsMethodsEligible({
42
42
  amount,
43
43
  country,
44
44
  currency,
@@ -32,7 +32,7 @@ export default defineEventHandler(async (event): Promise<QuoteRequestResult> =>
32
32
  throw createError({ statusCode: 401, message: "Sign in to ask for a quote" });
33
33
  }
34
34
 
35
- const profile = await getCheckoutProfileService().getProfile(event, actor.user.$id);
35
+ const profile = await getCheckoutProfileService().getProfile(event, actor.user);
36
36
  const shippingAddress = profile.addresses.find(a => a.id === body.shippingAddressId);
37
37
  const billingAddress = profile.addresses.find(a => a.id === body.billingAddressId);
38
38
  if (!shippingAddress || !billingAddress) {
@@ -104,13 +104,13 @@ export default defineEventHandler(async (event): Promise<QuoteRequestResult> =>
104
104
  const quote = await liveQuoteRequest({
105
105
  currency,
106
106
  items,
107
- ...(cartId ? { cart_id: cartId } : {}),
108
- ...(actor.contactId ? { contact_id: actor.contactId } : {}),
109
- ...(actor.organizationId ? { organization_id: actor.organizationId } : {}),
107
+ ...(cartId ? { cartId } : {}),
108
+ ...(actor.contactId ? { contactId: actor.contactId } : {}),
109
+ ...(actor.organizationId ? { organizationId: actor.organizationId } : {}),
110
110
  buyer,
111
- shipping_address: shippingAddress,
112
- billing_address: billingAddress,
113
- ...(body.note?.trim() ? { buyer_note: body.note.trim() } : {}),
111
+ shippingAddress,
112
+ billingAddress,
113
+ ...(body.note?.trim() ? { buyerNote: body.note.trim() } : {}),
114
114
  ...(body.reason ? { reason: body.reason } : {}),
115
115
  });
116
116
  created = { id: quote.id, number: quote.number };
@@ -37,7 +37,7 @@ export default defineEventHandler(async (event) => {
37
37
 
38
38
  if (resolveShippingServiceKey(event) !== "api") {
39
39
  const user = await getAuthService(event).me(event);
40
- const profile = await getCheckoutProfileService().getProfile(event, user?.$id ?? null);
40
+ const profile = await getCheckoutProfileService().getProfile(event, user ?? null);
41
41
  return {
42
42
  managed: false,
43
43
  methods: profile.availableDeliveryMethods,
@@ -47,7 +47,7 @@ export default defineEventHandler(async (event) => {
47
47
 
48
48
  const locale: Locale = resolveLocale(event);
49
49
  try {
50
- const { rates } = await useRevenexxSdk().shipping.shippingRates({
50
+ const { rates } = await useRevenexxSdk().shippingMethods.shippingRates({
51
51
  orderValue: amount,
52
52
  country,
53
53
  ...(weight !== undefined ? { weight } : {}),
@@ -1,5 +1,6 @@
1
1
  import type { H3Event } from "h3";
2
2
 
3
+ import type { AuthUser } from "../../app/interfaces/auth";
3
4
  import type { CheckoutProfile } from "../../app/interfaces/checkout";
4
5
 
5
6
  export interface ICheckoutProfileService {
@@ -7,6 +8,10 @@ export interface ICheckoutProfileService {
7
8
  * The signed-in user's checkout profile. Addresses come from the
8
9
  * address book service (mock or live per `addressService`); the event
9
10
  * carries the session and the per-request service-mode resolution.
11
+ *
12
+ * The buyer themselves is passed, not just their id: an address book fed
13
+ * by an ERP carries no recipient name, and an order without one is
14
+ * refused — the person placing it is the answer.
10
15
  */
11
- getProfile(event: H3Event, userId: string | null): Promise<CheckoutProfile>;
16
+ getProfile(event: H3Event, user: AuthUser | null): Promise<CheckoutProfile>;
12
17
  }
@@ -1,5 +1,4 @@
1
1
  import type { H3Event } from "h3";
2
- import { AddressType } from "@revenexx/sdk";
3
2
 
4
3
  import type { AccountAddress, AccountAddressFormState } from "../../app/interfaces/account/address-list";
5
4
 
@@ -31,14 +30,18 @@ function splitStreet(street: string): { street: string; streetNumber: string } {
31
30
  : { street: street.trim(), streetNumber: "" };
32
31
  }
33
32
 
34
- function toAccountAddress(row: ApiAddressRow): AccountAddress {
33
+ function toAccountAddress(row: ApiAddressRow, companyFallback = ""): AccountAddress {
35
34
  const name = (row.name ?? "").trim();
36
35
  const [firstName, ...rest] = name.split(/\s+/).filter(Boolean);
37
36
  const streetParts = splitStreet(row.street);
37
+ // An address the ERP hung on the company carries no company line of its
38
+ // own — the file has no such column. The company it belongs to is the
39
+ // answer, and an order will not go through without one.
40
+ const company = row.company || (row.organization_id ? companyFallback : "") || "";
38
41
  return {
39
42
  id: row.id,
40
- company: row.company ?? "",
41
- label: row.company || name || streetParts.street,
43
+ company,
44
+ label: company || name || streetParts.street,
42
45
  firstName: firstName ?? "",
43
46
  lastName: rest.join(" "),
44
47
  street: streetParts.street,
@@ -62,6 +65,27 @@ export class ApiAddressBookService implements IAddressBookService {
62
65
  return sessionOrderRefs(event);
63
66
  }
64
67
 
68
+ /**
69
+ * The company's name, for addresses that carry none. Best effort: a
70
+ * missing name is a worse label, while a failure here would be a checkout
71
+ * that cannot list an address at all.
72
+ */
73
+ private async companyName(organizationId?: string): Promise<string> {
74
+ if (!organizationId) {
75
+ return "";
76
+ }
77
+ try {
78
+ const org = await useRevenexxSdk().customersOrganizations.customersOrganizationsGet({
79
+ id: organizationId,
80
+ }) as unknown as { name?: string };
81
+ return org?.name ?? "";
82
+ }
83
+ catch (err) {
84
+ getLogService().error("API request failed: addresses/company-name", apiErrorContext(err));
85
+ return "";
86
+ }
87
+ }
88
+
65
89
  private requireContact(event: H3Event): string {
66
90
  const { contact_id } = this.contactRef(event);
67
91
  if (!contact_id) {
@@ -97,22 +121,25 @@ export class ApiAddressBookService implements IAddressBookService {
97
121
  const sdk = useRevenexxSdk();
98
122
  const [own, company] = await Promise.all([
99
123
  contact_id
100
- ? sdk.customers.customersAddressesList({ contactId: contact_id, limit: 200 }) as unknown as Promise<{ items: ApiAddressRow[] }>
124
+ ? sdk.customersOrganizations.customersAddressesList({ contactId: contact_id, limit: 200 }) as unknown as Promise<{ items: ApiAddressRow[] }>
101
125
  : Promise.resolve({ items: [] as ApiAddressRow[] }),
102
126
  organization_id
103
- ? sdk.customers.customersAddressesList({ organizationId: organization_id, limit: 200 }) as unknown as Promise<{ items: ApiAddressRow[] }>
127
+ ? sdk.customersOrganizations.customersAddressesList({ organizationId: organization_id, limit: 200 }) as unknown as Promise<{ items: ApiAddressRow[] }>
104
128
  : Promise.resolve({ items: [] as ApiAddressRow[] }),
105
129
  ]);
106
130
  const seen = new Set<string>();
107
- return [...(own.items ?? []), ...(company.items ?? [])]
131
+ const rows = [...(own.items ?? []), ...(company.items ?? [])]
108
132
  .filter((row) => {
109
133
  if (seen.has(row.id)) {
110
134
  return false;
111
135
  }
112
136
  seen.add(row.id);
113
137
  return true;
114
- })
115
- .map(toAccountAddress);
138
+ });
139
+ const companyName = rows.some(row => !row.company && row.organization_id)
140
+ ? await this.companyName(organization_id)
141
+ : "";
142
+ return rows.map(row => toAccountAddress(row, companyName));
116
143
  }
117
144
  catch (err) {
118
145
  getLogService().error("API request failed: addresses/list", apiErrorContext(err));
@@ -124,10 +151,10 @@ export class ApiAddressBookService implements IAddressBookService {
124
151
  const contactId = this.requireContact(event);
125
152
  const { organization_id } = this.contactRef(event);
126
153
  try {
127
- const row = await useRevenexxSdk().customers.customersAddressesCreate({
154
+ const row = await useRevenexxSdk().customersOrganizations.customersAddressesCreate({
128
155
  contactId,
129
156
  ...(organization_id ? { organizationId: organization_id } : {}),
130
- type: input.type === "billing" ? AddressType.Billing : AddressType.Shipping,
157
+ type: input.type === "billing" ? "billing" : "shipping",
131
158
  company: input.company || undefined,
132
159
  name: `${input.firstName} ${input.lastName}`.trim(),
133
160
  street: `${input.street} ${input.streetNumber}`.trim(),
@@ -150,9 +177,9 @@ export class ApiAddressBookService implements IAddressBookService {
150
177
  async update(event: H3Event, id: string, input: AccountAddressFormState): Promise<AccountAddress> {
151
178
  this.requireContact(event);
152
179
  try {
153
- const row = await useRevenexxSdk().customers.customersAddressesUpdate({
180
+ const row = await useRevenexxSdk().customersOrganizations.customersAddressesUpdate({
154
181
  id,
155
- type: input.type === "billing" ? AddressType.Billing : AddressType.Shipping,
182
+ type: input.type === "billing" ? "billing" : "shipping",
156
183
  company: input.company || undefined,
157
184
  name: `${input.firstName} ${input.lastName}`.trim(),
158
185
  street: `${input.street} ${input.streetNumber}`.trim(),
@@ -175,7 +202,7 @@ export class ApiAddressBookService implements IAddressBookService {
175
202
  async remove(event: H3Event, id: string): Promise<AccountAddress[]> {
176
203
  this.requireContact(event);
177
204
  try {
178
- await useRevenexxSdk().customers.customersAddressesDelete({ id });
205
+ await useRevenexxSdk().customersOrganizations.customersAddressesDelete({ id });
179
206
  }
180
207
  catch (err) {
181
208
  getLogService().error("API request failed: addresses/delete", apiErrorContext(err));
@@ -1,5 +1,6 @@
1
- import type { H3Event } from "h3";
1
+ import { CartStatus } from "@revenexx/sdk";
2
2
  import type { Models } from "@revenexx/sdk";
3
+ import type { H3Event } from "h3";
3
4
 
4
5
  import type { CartItem } from "../../app/interfaces/cart-item";
5
6
  import type { StoredSession } from "../../app/interfaces/auth";
@@ -141,10 +142,11 @@ function toSummary(cart: ApiCart): CartSummaryRow {
141
142
  */
142
143
  export class ApiCartService implements ICartService, ICartManager {
143
144
  private async listActive(owner: CartOwner): Promise<ApiCart[]> {
144
- // Typed list filter (carts.list declares its query params — @revenexx/sdk >= 0.0.11).
145
+ // Typed list filter (carts.list declares its query params, and its status
146
+ // is the app's own enum since @revenexx/sdk 0.2.0).
145
147
  const { items } = await useRevenexxSdk().carts.cartsList({
146
148
  ...(owner.contactId ? { contactId: owner.contactId } : { sessionKey: owner.sessionKey }),
147
- status: "active",
149
+ status: CartStatus.Active,
148
150
  limit: 100,
149
151
  order: "updated_at.desc",
150
152
  }) as unknown as { items: ApiCart[] };
@@ -173,14 +175,14 @@ export class ApiCartService implements ICartService, ICartManager {
173
175
  if (!current) {
174
176
  return [];
175
177
  }
176
- const { items } = await useRevenexxSdk().carts.cartsItemsList({ cartId: current.id }) as unknown as { items: ApiCartLine[] };
178
+ const { items } = await useRevenexxSdk().cartsItems.cartsItemsList({ cartId: current.id }) as unknown as { items: ApiCartLine[] };
177
179
  return items.map(toCartItem);
178
180
  }
179
181
 
180
182
  async saveItems(event: H3Event, items: CartItem[]): Promise<void> {
181
183
  const owner = resolveOwner(event);
182
184
  const cart = await this.ensureActiveCart(owner);
183
- await useRevenexxSdk().carts.cartsItemsReplace({
185
+ await useRevenexxSdk().cartsItems.cartsItemsReplace({
184
186
  cartId: cart.id,
185
187
  items: items.map((item, index) => toApiLine(item, index)) as unknown as Models.CartItemCreateRequest[],
186
188
  });
@@ -222,13 +224,13 @@ export class ApiCartService implements ICartService, ICartManager {
222
224
 
223
225
  async activateCart(event: H3Event, id: string): Promise<CartItem[]> {
224
226
  await useRevenexxSdk().carts.cartsActivate({ id });
225
- const { items } = await useRevenexxSdk().carts.cartsItemsList({ cartId: id }) as unknown as { items: ApiCartLine[] };
227
+ const { items } = await useRevenexxSdk().cartsItems.cartsItemsList({ cartId: id }) as unknown as { items: ApiCartLine[] };
226
228
  return items.map(toCartItem);
227
229
  }
228
230
 
229
231
  async addItemToCart(event: H3Event, id: string, item: CartItem): Promise<void> {
230
232
  const line = toApiLine(item, 0);
231
- await useRevenexxSdk().carts.cartsItemsCreate({
233
+ await useRevenexxSdk().cartsItems.cartsItemsCreate({
232
234
  cartId: id,
233
235
  ...(line.product_id ? { productId: String(line.product_id) } : {}),
234
236
  ...(line.sku ? { sku: String(line.sku) } : {}),
@@ -33,7 +33,7 @@ export class ApiOrganizationService implements IOrganizationService {
33
33
  return null;
34
34
  }
35
35
  try {
36
- const row = await useRevenexxSdk().customers.customersOrganizationsGet({
36
+ const row = await useRevenexxSdk().customersOrganizations.customersOrganizationsGet({
37
37
  id: organization_id,
38
38
  }) as unknown as ApiOrgRow;
39
39
  return toAccountOrganization(row);
@@ -50,7 +50,7 @@ export class ApiOrganizationService implements IOrganizationService {
50
50
  throw createError({ statusCode: 401, statusMessage: "No organization in session" });
51
51
  }
52
52
  try {
53
- const row = await useRevenexxSdk().customers.customersOrganizationsUpdate({
53
+ const row = await useRevenexxSdk().customersOrganizations.customersOrganizationsUpdate({
54
54
  id: organization_id,
55
55
  name: input.name,
56
56
  vatId: input.vatId || undefined,
@@ -1,4 +1,3 @@
1
- import type { ContactRole } from "@revenexx/sdk";
2
1
  import type { H3Event } from "h3";
3
2
 
4
3
  import type { AccountTeamMember, AccountTeamMemberFormState, AccountTeamRole, AccountTeamStatus } from "../../app/interfaces/account/team";
@@ -54,7 +53,7 @@ export class ApiTeamService implements ITeamService {
54
53
  try {
55
54
  // Typed list filter (customers.contacts.list declares its query
56
55
  // params — @revenexx/sdk >= 0.0.12), so org scoping is server-side.
57
- const { items } = await useRevenexxSdk().customers.customersContactsList({
56
+ const { items } = await useRevenexxSdk().customersContacts.customersContactsList({
58
57
  organizationId: organization_id,
59
58
  limit: 200,
60
59
  }) as unknown as { items: ApiContactRow[] };
@@ -72,11 +71,11 @@ export class ApiTeamService implements ITeamService {
72
71
  throw createError({ statusCode: 401, statusMessage: "No organization in session" });
73
72
  }
74
73
  try {
75
- const row = await useRevenexxSdk().customers.customersContactsCreate({
74
+ const row = await useRevenexxSdk().customersContacts.customersContactsCreate({
76
75
  email: input.email,
77
76
  firstName: input.firstName || undefined,
78
77
  lastName: input.lastName || undefined,
79
- role: input.role as ContactRole,
78
+ role: input.role,
80
79
  organizationId: organization_id,
81
80
  }) as unknown as ApiContactRow;
82
81
  return toAccountTeamMember(row);
@@ -92,9 +91,9 @@ export class ApiTeamService implements ITeamService {
92
91
 
93
92
  async update(_event: H3Event, id: string, patch: { role: AccountTeamRole }): Promise<AccountTeamMember> {
94
93
  try {
95
- const row = await useRevenexxSdk().customers.customersContactsUpdate({
94
+ const row = await useRevenexxSdk().customersContacts.customersContactsUpdate({
96
95
  id,
97
- role: patch.role as ContactRole,
96
+ role: patch.role,
98
97
  }) as unknown as ApiContactRow;
99
98
  return toAccountTeamMember(row);
100
99
  }
@@ -2,6 +2,7 @@ import type { H3Event } from "h3";
2
2
 
3
3
  import type { AccountAddress } from "../../app/interfaces/account/address-list";
4
4
  import type { Address } from "../../app/interfaces/address";
5
+ import type { AuthUser } from "../../app/interfaces/auth";
5
6
  import type { CheckoutProfile } from "../../app/interfaces/checkout";
6
7
 
7
8
  import type { ICheckoutProfileService } from "../interfaces/checkoutProfile";
@@ -88,16 +89,19 @@ function methodsFor(event: H3Event, mock: MethodBlocks): MethodBlocks {
88
89
  }
89
90
 
90
91
  export class LocalFileCheckoutProfileService implements ICheckoutProfileService {
91
- async getProfile(event: H3Event, userId: string | null): Promise<CheckoutProfile> {
92
- if (!userId) {
92
+ async getProfile(event: H3Event, user: AuthUser | null): Promise<CheckoutProfile> {
93
+ if (!user) {
93
94
  return { ...GUEST_PROFILE, ...methodsFor(event, GUEST_PROFILE) };
94
95
  }
95
96
  try {
96
97
  const entries = await getAddressBookService(event).list(event);
98
+ // A company address out of an ERP names no recipient — the file has
99
+ // no such column — and a business order is refused without one. The
100
+ // person placing the order is who it goes to.
97
101
  const addresses: Address[] = entries.map(entry => ({
98
102
  id: entry.id,
99
103
  companyName: entry.company || `${entry.firstName} ${entry.lastName}`.trim(),
100
- contactName: `${entry.firstName} ${entry.lastName}`.trim(),
104
+ contactName: `${entry.firstName} ${entry.lastName}`.trim() || user.name,
101
105
  street: `${entry.street} ${entry.streetNumber}`.trim(),
102
106
  city: entry.city,
103
107
  postalCode: entry.zip,
@@ -412,7 +412,7 @@ async function loadLiveCategoryRows(): Promise<LiveCategoryRow[]> {
412
412
  // Typed list (products.categories.list declares limit/offset/order —
413
413
  // @revenexx/sdk >= 0.0.11).
414
414
  for (let pageIndex = 0; pageIndex < 25; pageIndex++) {
415
- const page = await sdk.products.productsCategoriesList({
415
+ const page = await sdk.productsCategories.productsCategoriesList({
416
416
  limit: CATEGORY_PAGE_LIMIT,
417
417
  offset,
418
418
  }) as unknown as LiveCategoryPage;
@@ -29,7 +29,7 @@ function toStock(entry: ItemAvailability): { quantity: number; maxOrderQuantity:
29
29
  }
30
30
 
31
31
  async function fetchAvailability(items: Array<{ product_id?: string; sku?: string }>): Promise<Map<string, ItemAvailability>> {
32
- const { availability } = await useRevenexxSdk().inventories.inventoriesAvailability({
32
+ const { availability } = await useRevenexxSdk().inventoriesStock.inventoriesAvailability({
33
33
  items: items as Models.InventoryAvailabilityItem[],
34
34
  }) as unknown as { availability: ItemAvailability[] };
35
35
  const byKey = new Map<string, ItemAvailability>();
@@ -120,7 +120,28 @@ function toItemInput(position: OrderListPosition): Models.OrderListItemInput {
120
120
  * — spreading the snake_case shape there silently dropped product_id/tax_rate/
121
121
  * the *_slug fields (the SDK only reads its declared camelCase params).
122
122
  */
123
- function toItemCreateParams(position: OrderListPosition): Record<string, unknown> {
123
+ /**
124
+ * A position as `orderlists.items.create` takes it. Spelled out rather than
125
+ * widened to a record: the generated method types its parameters, and a
126
+ * record would drop `name` on the way in.
127
+ */
128
+ interface OrderListItemCreateInput {
129
+ name: string;
130
+ quantity: number;
131
+ productId?: string;
132
+ sku?: string;
133
+ image?: string;
134
+ unit?: string;
135
+ price?: number;
136
+ taxRate?: number;
137
+ costCenterId?: string;
138
+ positionTexts?: string[];
139
+ customSku?: string;
140
+ categorySlug?: string;
141
+ subcategorySlug?: string;
142
+ }
143
+
144
+ function toItemCreateParams(position: OrderListPosition): OrderListItemCreateInput {
124
145
  return {
125
146
  name: position.name,
126
147
  quantity: Number(position.quantity) || 1,
@@ -208,7 +229,7 @@ export async function updateOrderList(
208
229
  await sdk.orderlists.orderlistsItemsReplace({ listId: id, items: body.positions.map(toItemInput) });
209
230
  }
210
231
  for (const position of body.appendPositions ?? []) {
211
- await sdk.orderlists.orderlistsItemsCreate({ listId: id, ...toItemCreateParams(position) } as Parameters<typeof sdk.orderlists.orderlistsItemsCreate>[0]);
232
+ await sdk.orderlists.orderlistsItemsCreate({ listId: id, ...toItemCreateParams(position) });
212
233
  }
213
234
 
214
235
  return toCoverList(await sdk.orderlists.orderlistsGet({ id }) as unknown as AppList);
@@ -37,3 +37,31 @@ export function resolveLocale(event: H3Event): Locale {
37
37
  const configDefault = useRuntimeConfig().public.defaultLocale;
38
38
  return (SUPPORTED.has(configDefault as Locale) ? configDefault : "de") as Locale;
39
39
  }
40
+
41
+ /**
42
+ * The locale a CONTACT is stored under, which is not the locale the UI
43
+ * speaks. The storefront works in a language ("de"); the customers app keeps
44
+ * one of the store's own locales ("de-DE") and refuses anything else — and
45
+ * its refusal is a 400 whose message never reaches the form, so a bare
46
+ * language reads to the buyer as a registration that silently breaks.
47
+ *
48
+ * The market is the source of truth for which locales a store has. Falls back
49
+ * to the bare language when markets cannot be read: a registration that
50
+ * reaches the app and may be refused beats one that never leaves.
51
+ */
52
+ export async function resolveStoreLocale(event: H3Event): Promise<string> {
53
+ const language = resolveLocale(event);
54
+ try {
55
+ const markets = await getMarketService(event).listMarkets();
56
+ const selected = resolveSelectedMarket(event);
57
+ const market = markets.find(m => m.code === selected) ?? markets.find(m => m.isDefault) ?? markets[0];
58
+ const locales = market?.locales ?? [];
59
+ const match = locales.find(l => l.language === language)
60
+ ?? locales.find(l => l.isDefault)
61
+ ?? locales[0];
62
+ return match?.code ?? language;
63
+ }
64
+ catch {
65
+ return language;
66
+ }
67
+ }
@@ -1,3 +1,4 @@
1
+ import { PromotionsRedemptionsReleaseReason } from "@revenexx/sdk";
1
2
  import type { H3Event } from "h3";
2
3
 
3
4
  /**
@@ -16,6 +17,18 @@ export function resolvePromotionsServiceKey(event?: H3Event): string {
16
17
  });
17
18
  }
18
19
 
20
+ /**
21
+ * What `promotions/evaluate` answers, in the part the storefront reads. The
22
+ * app declares no response schema yet, so the generated method's return type
23
+ * is empty and this is the contract we hold it to.
24
+ */
25
+ interface PromotionEvaluationAnswer {
26
+ lines?: Array<{ position?: number; discount?: number }>;
27
+ totals?: { discount_total?: number };
28
+ applied?: Array<Record<string, unknown>>;
29
+ rejected_codes?: string[];
30
+ }
31
+
19
32
  /** One line as the promotions app wants to see it: priced, and numbered. */
20
33
  interface PricedLine {
21
34
  position: number;
@@ -77,24 +90,16 @@ export async function evaluatePromotions(
77
90
  return null;
78
91
  }
79
92
  try {
80
- // The escape hatch, not a typed method: the SDK vendored here predates
81
- // the promotions app and carries no namespace for it. Same transport,
82
- // same auth, same error type — it moves to a typed call when the SDK
83
- // next carries one.
84
- const answer = await useRevenexxSdk().call<{
85
- lines?: Array<{ position?: number; discount?: number }>;
86
- totals?: { discount_total?: number };
87
- applied?: Array<Record<string, unknown>>;
88
- rejected_codes?: string[];
89
- }>("POST", "/v1/promotions/evaluate", {
90
- body: {
91
- currency: input.currency,
92
- lines: input.lines,
93
- ...(input.codes?.length ? { codes: input.codes } : {}),
94
- ...(input.contactId ? { contact_id: input.contactId } : {}),
95
- ...(input.organizationId ? { organization_id: input.organizationId } : {}),
96
- },
97
- });
93
+ // The app declares no response schema yet, so the generated method
94
+ // answers `{}` — the request side is typed, the answer is read through
95
+ // the shape this file documents.
96
+ const answer = await useRevenexxSdk().promotionsEvaluation.promotionsEvaluationEvaluate({
97
+ currency: input.currency ?? "",
98
+ lines: input.lines,
99
+ ...(input.codes?.length ? { codes: input.codes } : {}),
100
+ ...(input.contactId ? { contactId: input.contactId } : {}),
101
+ ...(input.organizationId ? { organizationId: input.organizationId } : {}),
102
+ }) as PromotionEvaluationAnswer;
98
103
 
99
104
  const lineDiscounts: Record<number, number> = {};
100
105
  for (const line of answer.lines ?? []) {
@@ -191,14 +196,12 @@ export async function reserveRedemption(
191
196
  return "not_applicable";
192
197
  }
193
198
  try {
194
- await useRevenexxSdk().call("POST", "/v1/promotions/reserve", {
195
- body: {
196
- cart_id: input.cartId,
197
- promotions,
198
- ...(input.currency ? { currency: input.currency } : {}),
199
- ...(input.contactId ? { contact_id: input.contactId } : {}),
200
- ...(input.organizationId ? { organization_id: input.organizationId } : {}),
201
- },
199
+ await useRevenexxSdk().promotionsRedemptions.promotionsRedemptionsReserve({
200
+ cartId: input.cartId,
201
+ promotions,
202
+ ...(input.currency ? { currency: input.currency } : {}),
203
+ ...(input.contactId ? { contactId: input.contactId } : {}),
204
+ ...(input.organizationId ? { organizationId: input.organizationId } : {}),
202
205
  });
203
206
  return "held";
204
207
  }
@@ -235,18 +238,16 @@ export async function commitRedemption(
235
238
  return;
236
239
  }
237
240
  try {
238
- await useRevenexxSdk().call("POST", "/v1/promotions/commit", {
239
- body: {
240
- order_id: input.orderId,
241
- // Commit promotes the cart's held rows; the list is what it falls
242
- // back to when a hold has expired or was never taken, and it is
243
- // what moves a promotion's budget and a voucher's usage_count.
244
- promotions: heldPromotions(input.promotions),
245
- ...(input.cartId ? { cart_id: input.cartId } : {}),
246
- ...(input.currency ? { currency: input.currency } : {}),
247
- ...(input.contactId ? { contact_id: input.contactId } : {}),
248
- ...(input.organizationId ? { organization_id: input.organizationId } : {}),
249
- },
241
+ await useRevenexxSdk().promotionsRedemptions.promotionsRedemptionsCommit({
242
+ orderId: input.orderId,
243
+ // Commit promotes the cart's held rows; the list is what it falls
244
+ // back to when a hold has expired or was never taken, and it is
245
+ // what moves a promotion's budget and a voucher's usage_count.
246
+ promotions: heldPromotions(input.promotions),
247
+ ...(input.cartId ? { cartId: input.cartId } : {}),
248
+ ...(input.currency ? { currency: input.currency } : {}),
249
+ ...(input.contactId ? { contactId: input.contactId } : {}),
250
+ ...(input.organizationId ? { organizationId: input.organizationId } : {}),
250
251
  });
251
252
  }
252
253
  catch (err) {
@@ -259,14 +260,15 @@ export async function commitRedemption(
259
260
 
260
261
  export async function releaseRedemption(
261
262
  event: H3Event,
262
- input: { cartId: string; reason: string },
263
+ input: { cartId: string; reason: PromotionsRedemptionsReleaseReason },
263
264
  ): Promise<void> {
264
265
  if (resolvePromotionsServiceKey(event) !== "api") {
265
266
  return;
266
267
  }
267
268
  try {
268
- await useRevenexxSdk().call("POST", "/v1/promotions/release", {
269
- body: { cart_id: input.cartId, reason: input.reason },
269
+ await useRevenexxSdk().promotionsRedemptions.promotionsRedemptionsRelease({
270
+ cartId: input.cartId,
271
+ reason: input.reason,
270
272
  });
271
273
  }
272
274
  catch (err) {
@@ -1,3 +1,5 @@
1
+ import { Audience } from "@revenexx/sdk";
2
+ import type { Models } from "@revenexx/sdk";
1
3
  import type { H3Event } from "h3";
2
4
 
3
5
  import type { AccountQuote, AccountQuoteLine, AccountQuoteStatus } from "../../app/interfaces/account/quotes";
@@ -184,47 +186,62 @@ export function mapQuote(quote: LiveQuote): AccountQuote {
184
186
 
185
187
  /* ---- live -------------------------------------------------------------- */
186
188
 
189
+ /**
190
+ * What the quotes app takes for a request. The positions keep the app's own
191
+ * field names (the generated line model is snake_case); everything around
192
+ * them is named as the SDK method declares it.
193
+ */
194
+ export interface LiveQuoteRequestInput {
195
+ currency: string;
196
+ items: Models.QuoteLineInput[];
197
+ billingAddress?: object;
198
+ buyer?: object;
199
+ buyerNote?: string;
200
+ cartId?: string;
201
+ contactId?: string;
202
+ organizationId?: string;
203
+ reason?: string;
204
+ shippingAddress?: object;
205
+ }
206
+
207
+ // The generated models describe every field as optional — the gateway only
208
+ // promises what it sends. LiveQuote is the shape this BFF relies on, so each
209
+ // typed answer is narrowed to it once, here, instead of at every reader.
187
210
  export async function liveQuoteList(organizationId: string | undefined, contactId: string | undefined): Promise<LiveQuote[]> {
188
- const query: Record<string, string | number> = { limit: 100, order: "created_at.desc" };
189
- if (organizationId) {
190
- query.organization_id = organizationId;
191
- }
192
- else if (contactId) {
193
- query.contact_id = contactId;
194
- }
195
- else {
211
+ if (!organizationId && !contactId) {
196
212
  return [];
197
213
  }
198
- const { items } = await useRevenexxSdk().call<{ items: LiveQuote[] }>("GET", "/v1/quotes/quotes", { query });
199
- return items ?? [];
214
+ const { items } = await useRevenexxSdk().quotes.quotesQuotesList({
215
+ limit: 100,
216
+ order: "created_at.desc",
217
+ // An organisation sees the whole company's quotes; a contact without
218
+ // one sees only their own.
219
+ ...(organizationId ? { organizationId } : { contactId }),
220
+ });
221
+ return (items ?? []) as LiveQuote[];
200
222
  }
201
223
 
202
224
  export async function liveQuoteDetail(id: string): Promise<LiveQuote> {
203
- return await useRevenexxSdk().call<LiveQuote>("GET", `/v1/quotes/quotes/${encodeURIComponent(id)}/detail`, {
204
- query: { audience: "customer" },
205
- });
225
+ return await useRevenexxSdk().quotes.quotesQuotesDetail({
226
+ id,
227
+ audience: Audience.Customer,
228
+ }) as LiveQuote;
206
229
  }
207
230
 
208
- export async function liveQuoteRequest(body: Record<string, unknown>): Promise<LiveQuote> {
209
- return await useRevenexxSdk().call<LiveQuote>("POST", "/v1/quotes/request", { body });
231
+ export async function liveQuoteRequest(body: LiveQuoteRequestInput): Promise<LiveQuote> {
232
+ return await useRevenexxSdk().quotes.quotesQuotesRequest(body) as LiveQuote;
210
233
  }
211
234
 
212
235
  export async function liveQuoteAccept(id: string): Promise<LiveQuote & { order_draft: LiveOrderDraft }> {
213
- return await useRevenexxSdk().call<LiveQuote & { order_draft: LiveOrderDraft }>(
214
- "POST", `/v1/quotes/quotes/${encodeURIComponent(id)}/accept`, { body: {} },
215
- );
236
+ return await useRevenexxSdk().quotesAcceptance.quotesAcceptanceAccept({ id }) as LiveQuote & { order_draft: LiveOrderDraft };
216
237
  }
217
238
 
218
239
  export async function liveQuoteOrdered(id: string, orderId: string): Promise<void> {
219
- await useRevenexxSdk().call("POST", `/v1/quotes/quotes/${encodeURIComponent(id)}/ordered`, {
220
- body: { order_id: orderId },
221
- });
240
+ await useRevenexxSdk().quotesAcceptance.quotesAcceptanceOrdered({ id, orderId });
222
241
  }
223
242
 
224
243
  export async function liveQuoteDecline(id: string, reason?: string): Promise<void> {
225
- await useRevenexxSdk().call("POST", `/v1/quotes/quotes/${encodeURIComponent(id)}/decline`, {
226
- body: reason ? { reason } : {},
227
- });
244
+ await useRevenexxSdk().quotesAcceptance.quotesAcceptanceDecline({ id, ...(reason ? { reason } : {}) });
228
245
  }
229
246
 
230
247
  /**
@@ -1,18 +1,26 @@
1
1
  import {
2
2
  Carts,
3
+ CartsItems,
3
4
  Client,
4
5
  Customers,
5
- Inventories,
6
+ CustomersContacts,
7
+ CustomersOrganizations,
8
+ InventoriesStock,
6
9
  Markets,
7
10
  Orderlists,
8
11
  Orders,
9
- Payments,
12
+ PaymentsMethods,
10
13
  Prices,
11
14
  Products,
15
+ ProductsCategories,
16
+ PromotionsEvaluation,
17
+ PromotionsRedemptions,
18
+ QuotesAcceptance,
19
+ QuotesQuotes,
12
20
  RevenexxException,
13
21
  Search,
14
22
  Settings,
15
- Shipping,
23
+ ShippingMethods,
16
24
  } from "@revenexx/sdk";
17
25
 
18
26
  /**
@@ -43,17 +51,25 @@ export interface RevenexxSdkCallOptions {
43
51
  export interface RevenexxSdk {
44
52
  readonly client: Client;
45
53
  readonly carts: Carts;
54
+ readonly cartsItems: CartsItems;
46
55
  readonly customers: Customers;
47
- readonly inventories: Inventories;
56
+ readonly customersContacts: CustomersContacts;
57
+ readonly customersOrganizations: CustomersOrganizations;
58
+ readonly inventoriesStock: InventoriesStock;
48
59
  readonly markets: Markets;
49
60
  readonly orderlists: Orderlists;
50
61
  readonly orders: Orders;
51
- readonly payments: Payments;
62
+ readonly paymentsMethods: PaymentsMethods;
52
63
  readonly prices: Prices;
53
64
  readonly products: Products;
65
+ readonly productsCategories: ProductsCategories;
66
+ readonly promotionsEvaluation: PromotionsEvaluation;
67
+ readonly promotionsRedemptions: PromotionsRedemptions;
68
+ readonly quotes: QuotesQuotes;
69
+ readonly quotesAcceptance: QuotesAcceptance;
54
70
  readonly search: Search;
55
71
  readonly settings: Settings;
56
- readonly shipping: Shipping;
72
+ readonly shippingMethods: ShippingMethods;
57
73
  /**
58
74
  * Low-level escape hatch over the SDK transport (same auth, same error
59
75
  * type) for the few operations whose gateway contracts are not complete
@@ -253,17 +269,25 @@ export function useRevenexxSdk(): RevenexxSdk {
253
269
  const instance: RevenexxSdk = {
254
270
  client,
255
271
  carts: new Carts(client),
272
+ cartsItems: new CartsItems(client),
256
273
  customers: new Customers(client),
257
- inventories: new Inventories(client),
274
+ customersContacts: new CustomersContacts(client),
275
+ customersOrganizations: new CustomersOrganizations(client),
276
+ inventoriesStock: new InventoriesStock(client),
258
277
  markets: new Markets(client),
259
278
  orderlists: new Orderlists(client),
260
279
  orders: new Orders(client),
261
- payments: new Payments(client),
280
+ paymentsMethods: new PaymentsMethods(client),
262
281
  prices: new Prices(client),
263
282
  products: new Products(client),
283
+ productsCategories: new ProductsCategories(client),
284
+ promotionsEvaluation: new PromotionsEvaluation(client),
285
+ promotionsRedemptions: new PromotionsRedemptions(client),
286
+ quotes: new QuotesQuotes(client),
287
+ quotesAcceptance: new QuotesAcceptance(client),
264
288
  search: new Search(client),
265
289
  settings: new Settings(client),
266
- shipping: new Shipping(client),
290
+ shippingMethods: new ShippingMethods(client),
267
291
  call,
268
292
  };
269
293
  if (isCacheable) {