@stacksjs/commerce 0.75.41 → 0.75.43

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.
@@ -0,0 +1,89 @@
1
+ import type { AccountAdapter, AccountCustomer, AccountOrder, MappedAccountRecord } from './account-types';
2
+ import type { AdminRequestOptions } from './admin-http';
3
+ import type { OrderStatus } from '../orders/events';
4
+ /** One Admin API customer as a normalized customer, or null with the reason. Pure. */
5
+ export declare function mapShopwareCustomer(raw: ShopwareCustomerPayload, context?: { currency?: string }): MappedAccountRecord<AccountCustomer>;
6
+ /**
7
+ * The Stacks status for a Shopware order, from its three state machines:
8
+ * the order (open, in_progress, completed, cancelled), the delivery (open,
9
+ * shipped, shipped_partially, returned, ...) and the payment (open, paid,
10
+ * refunded, ...).
11
+ */
12
+ export declare function shopwareOrderStatus(raw: Pick<ShopwareOrderPayload, 'stateMachineState' | 'deliveries' | 'transactions'>): { status: OrderStatus, mapped: boolean, sourceStatus: string };
13
+ /**
14
+ * A variant line's label with its options, `Bio T-Shirt - Blau, M`. Shopware
15
+ * labels every variant with the parent's name and keeps the options in the
16
+ * payload, so two sizes of one shirt would otherwise read the same.
17
+ */
18
+ export declare function shopwareLineLabel(label: string, options: unknown): string;
19
+ /** One Admin API order as a normalized order, or null with the reason. Pure. */
20
+ export declare function mapShopwareOrder(raw: ShopwareOrderPayload, context?: { currency?: string }): MappedAccountRecord<AccountOrder>;
21
+ /**
22
+ * The shop's base URL, from the storefront URL or an API endpoint
23
+ * (`.../api`, `.../store-api`). HTTPS only, except on this machine.
24
+ */
25
+ export declare function shopwareAdminBase(storeUrl: string, adminUrl?: string): string;
26
+ /** Criteria for one page of customers. */
27
+ export declare function shopwareCustomerCriteria(page: number, limit: number): Record<string, unknown>;
28
+ /** Criteria for one page of orders, with their line items and addresses. */
29
+ export declare function shopwareOrderCriteria(page: number, limit: number): Record<string, unknown>;
30
+ /** A bearer token for the integration, from the client_credentials grant. */
31
+ export declare function shopwareAccessToken(base: string, clientId: string, clientSecret: string, request: Omit<AdminRequestOptions, 'json' | 'method' | 'headers'>): Promise<string>;
32
+ export declare const shopwareAccountAdapter: AccountAdapter;
33
+ export declare interface ShopwareAddressPayload {
34
+ id?: string | null
35
+ firstName?: string | null
36
+ lastName?: string | null
37
+ company?: string | null
38
+ street?: string | null
39
+ additionalAddressLine1?: string | null
40
+ zipcode?: string | null
41
+ city?: string | null
42
+ phoneNumber?: string | null
43
+ country?: { iso?: string | null, name?: string | null } | null
44
+ }
45
+ export declare interface ShopwareCustomerPayload {
46
+ id: string
47
+ customerNumber?: string | null
48
+ email?: string | null
49
+ firstName?: string | null
50
+ lastName?: string | null
51
+ company?: string | null
52
+ active?: boolean | null
53
+ guest?: boolean | null
54
+ orderTotalAmount?: number | null
55
+ lastOrderDate?: string | null
56
+ createdAt?: string | null
57
+ defaultBillingAddress?: ShopwareAddressPayload | null
58
+ }
59
+ export declare interface ShopwareLineItemPayload {
60
+ id: string
61
+ parentId?: string | null
62
+ productId?: string | null
63
+ referencedId?: string | null
64
+ label?: string | null
65
+ quantity?: number | null
66
+ unitPrice?: number | null
67
+ totalPrice?: number | null
68
+ type?: string | null
69
+ payload?: { productNumber?: string | null, parentId?: string | null, options?: Array<{ group?: string | null, option?: string | null }> | null } | unknown[] | null
70
+ }
71
+ declare interface StatePayload {
72
+ stateMachineState?: { technicalName?: string | null } | null
73
+ }
74
+ export declare interface ShopwareOrderPayload extends StatePayload {
75
+ id: string
76
+ orderNumber?: string | null
77
+ orderDateTime?: string | null
78
+ amountTotal?: number | null
79
+ amountNet?: number | null
80
+ shippingTotal?: number | null
81
+ customerComment?: string | null
82
+ billingAddressId?: string | null
83
+ currency?: { isoCode?: string | null } | null
84
+ orderCustomer?: { customerId?: string | null, email?: string | null, firstName?: string | null, lastName?: string | null } | null
85
+ lineItems?: ShopwareLineItemPayload[] | null
86
+ addresses?: ShopwareAddressPayload[] | null
87
+ deliveries?: Array<StatePayload & { shippingOrderAddress?: ShopwareAddressPayload | null }> | null
88
+ transactions?: Array<StatePayload & { createdAt?: string | null }> | null
89
+ }
@@ -0,0 +1,66 @@
1
+ import type { AccountAdapter, AccountCustomer, AccountOrder, MappedAccountRecord } from './account-types';
2
+ import type { OrderStatus } from '../orders/events';
3
+ /** The Stacks status for a WooCommerce status, and whether it was a known one. */
4
+ export declare function wooOrderStatus(status: string | null | undefined): { status: OrderStatus, mapped: boolean };
5
+ /** One REST API customer as a normalized customer, or null with the reason. Pure. */
6
+ export declare function mapWooCustomer(raw: WooCustomerPayload): MappedAccountRecord<AccountCustomer>;
7
+ /** One REST API order as a normalized order, or null with the reason. Pure. */
8
+ export declare function mapWooOrder(raw: WooOrderPayload, context?: { currency?: string }): MappedAccountRecord<AccountOrder>;
9
+ /** The REST API base for a store URL. HTTPS only: Basic auth over HTTP sends the secret in the clear. */
10
+ export declare function wooAdminBase(storeUrl: string, adminUrl?: string): string;
11
+ /** `Authorization: Basic ...` for a consumer key and secret. */
12
+ export declare function wooAuthorization(consumerKey: string, consumerSecret: string): string;
13
+ export declare const wooCommerceAccountAdapter: AccountAdapter;
14
+ export declare interface WooAddressPayload {
15
+ first_name?: string | null
16
+ last_name?: string | null
17
+ company?: string | null
18
+ address_1?: string | null
19
+ address_2?: string | null
20
+ city?: string | null
21
+ state?: string | null
22
+ postcode?: string | null
23
+ country?: string | null
24
+ email?: string | null
25
+ phone?: string | null
26
+ }
27
+ export declare interface WooCustomerPayload {
28
+ id: number | string
29
+ email?: string | null
30
+ first_name?: string | null
31
+ last_name?: string | null
32
+ username?: string | null
33
+ role?: string | null
34
+ date_created_gmt?: string | null
35
+ billing?: WooAddressPayload | null
36
+ shipping?: WooAddressPayload | null
37
+ avatar_url?: string | null
38
+ }
39
+ export declare interface WooOrderLinePayload {
40
+ id: number | string
41
+ name?: string | null
42
+ product_id?: number | null
43
+ variation_id?: number | null
44
+ quantity?: number | null
45
+ subtotal?: string | null
46
+ total?: string | null
47
+ sku?: string | null
48
+ }
49
+ export declare interface WooOrderPayload {
50
+ id: number | string
51
+ number?: string | null
52
+ status?: string | null
53
+ currency?: string | null
54
+ date_created_gmt?: string | null
55
+ discount_total?: string | null
56
+ shipping_total?: string | null
57
+ total?: string | null
58
+ total_tax?: string | null
59
+ customer_id?: number | null
60
+ customer_note?: string | null
61
+ billing?: WooAddressPayload | null
62
+ shipping?: WooAddressPayload | null
63
+ line_items?: WooOrderLinePayload[] | null
64
+ fee_lines?: Array<{ id?: number | string, name?: string | null, total?: string | null }> | null
65
+ refunds?: Array<{ id?: number | string, reason?: string | null, total?: string | null }> | null
66
+ }
@@ -9,6 +9,12 @@ import type { CatalogAdapter, MappedProduct } from './types';
9
9
  */
10
10
  export declare function wooPrices(prices: WooPricesPayload | null | undefined): Prices;
11
11
  declare function terms(list: WooTermPayload[] | null | undefined): Array<{ name: string, slug: string }>;
12
+ /**
13
+ * A product slug as the shopper reads it. WordPress stores a non-ASCII slug
14
+ * percent-encoded (`sencha-%e7%b7%91%e8%8c%b6-100g`) and the Store API hands
15
+ * it over that way; a malformed escape is kept as sent.
16
+ */
17
+ export declare function wooSlug(value: unknown): string | null;
12
18
  /** One Store API product, plus its fetched variations, as a catalog product. Pure. */
13
19
  export declare function mapWooProduct(raw: WooProductPayload, context?: WooMapContext): MappedProduct;
14
20
  export declare const wooCommerceAdapter: CatalogAdapter;