@aimee.shop/sdk 0.16.0 → 0.18.0-dev.114
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/core/errors/checkout-refusal.d.ts +4 -0
- package/dist/core/errors/checkout-refusal.d.ts.map +1 -1
- package/dist/core/errors/checkout-refusal.js +2 -0
- package/dist/core/errors/checkout-refusal.js.map +1 -1
- package/dist/core/events/event-names.d.ts +144 -147
- package/dist/core/events/event-names.d.ts.map +1 -1
- package/dist/core/events/event-names.js +143 -146
- package/dist/core/events/event-names.js.map +1 -1
- package/dist/index.d.ts +16 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/services/core/assets.client.d.ts +2 -8
- package/dist/services/core/assets.client.d.ts.map +1 -1
- package/dist/services/core/assets.client.js.map +1 -1
- package/dist/services/core/base-resource.d.ts +7 -2
- package/dist/services/core/base-resource.d.ts.map +1 -1
- package/dist/services/core/base-resource.js +27 -20
- package/dist/services/core/base-resource.js.map +1 -1
- package/dist/services/core/cart-messages/cart-messages.client.d.ts +14 -4
- package/dist/services/core/cart-messages/cart-messages.client.d.ts.map +1 -1
- package/dist/services/core/cart-messages/cart-messages.client.js +37 -4
- package/dist/services/core/cart-messages/cart-messages.client.js.map +1 -1
- package/dist/services/core/cart-messages/index.d.ts +1 -1
- package/dist/services/core/cart-messages/index.d.ts.map +1 -1
- package/dist/services/core/cart-messages/types.d.ts +17 -0
- package/dist/services/core/cart-messages/types.d.ts.map +1 -1
- package/dist/services/core/carts.client.d.ts +25 -4
- package/dist/services/core/carts.client.d.ts.map +1 -1
- package/dist/services/core/carts.client.js +18 -0
- package/dist/services/core/carts.client.js.map +1 -1
- package/dist/services/core/categories.client.d.ts +13 -7
- package/dist/services/core/categories.client.d.ts.map +1 -1
- package/dist/services/core/categories.client.js.map +1 -1
- package/dist/services/core/checkout.client.d.ts +74 -35
- package/dist/services/core/checkout.client.d.ts.map +1 -1
- package/dist/services/core/checkout.client.js +3 -2
- package/dist/services/core/checkout.client.js.map +1 -1
- package/dist/services/core/cms/cms.client.d.ts +1 -1
- package/dist/services/core/cms/cms.client.js +1 -1
- package/dist/services/core/cms/entries.client.d.ts +4 -2
- package/dist/services/core/cms/entries.client.d.ts.map +1 -1
- package/dist/services/core/cms/entries.client.js +8 -2
- package/dist/services/core/cms/entries.client.js.map +1 -1
- package/dist/services/core/cms/types.d.ts +95 -53
- package/dist/services/core/cms/types.d.ts.map +1 -1
- package/dist/services/core/cms/types.js.map +1 -1
- package/dist/services/core/customers.client.d.ts +79 -62
- package/dist/services/core/customers.client.d.ts.map +1 -1
- package/dist/services/core/customers.client.js +27 -13
- package/dist/services/core/customers.client.js.map +1 -1
- package/dist/services/core/discounts.client.d.ts +187 -79
- package/dist/services/core/discounts.client.d.ts.map +1 -1
- package/dist/services/core/discounts.client.js +80 -43
- package/dist/services/core/discounts.client.js.map +1 -1
- package/dist/services/core/exports/types.d.ts +1 -1
- package/dist/services/core/exports/types.d.ts.map +1 -1
- package/dist/services/core/exports/types.js +1 -0
- package/dist/services/core/exports/types.js.map +1 -1
- package/dist/services/core/facets.client.d.ts +6 -4
- package/dist/services/core/facets.client.d.ts.map +1 -1
- package/dist/services/core/facets.client.js.map +1 -1
- package/dist/services/core/fulfillments.client.d.ts +51 -27
- package/dist/services/core/fulfillments.client.d.ts.map +1 -1
- package/dist/services/core/fulfillments.client.js +30 -18
- package/dist/services/core/fulfillments.client.js.map +1 -1
- package/dist/services/core/inventory/adjustments.client.d.ts +12 -2
- package/dist/services/core/inventory/adjustments.client.d.ts.map +1 -1
- package/dist/services/core/inventory/adjustments.client.js.map +1 -1
- package/dist/services/core/inventory/index.d.ts +1 -1
- package/dist/services/core/inventory/index.d.ts.map +1 -1
- package/dist/services/core/inventory/reservations.client.d.ts +3 -3
- package/dist/services/core/inventory/reservations.client.d.ts.map +1 -1
- package/dist/services/core/inventory/reservations.client.js +2 -2
- package/dist/services/core/inventory/reservations.client.js.map +1 -1
- package/dist/services/core/inventory/types.d.ts +29 -6
- package/dist/services/core/inventory/types.d.ts.map +1 -1
- package/dist/services/core/inventory/types.js +1 -0
- package/dist/services/core/inventory/types.js.map +1 -1
- package/dist/services/core/invoices.client.d.ts +1 -6
- package/dist/services/core/invoices.client.d.ts.map +1 -1
- package/dist/services/core/invoices.client.js +1 -1
- package/dist/services/core/invoices.client.js.map +1 -1
- package/dist/services/core/openai-feed.client.d.ts +34 -3
- package/dist/services/core/openai-feed.client.d.ts.map +1 -1
- package/dist/services/core/openai-feed.client.js.map +1 -1
- package/dist/services/core/option-types.client.d.ts +6 -7
- package/dist/services/core/option-types.client.d.ts.map +1 -1
- package/dist/services/core/option-types.client.js +7 -8
- package/dist/services/core/option-types.client.js.map +1 -1
- package/dist/services/core/option-values.client.d.ts +2 -1
- package/dist/services/core/option-values.client.d.ts.map +1 -1
- package/dist/services/core/option-values.client.js +2 -1
- package/dist/services/core/option-values.client.js.map +1 -1
- package/dist/services/core/order-edits.client.d.ts +5 -7
- package/dist/services/core/order-edits.client.d.ts.map +1 -1
- package/dist/services/core/order-edits.client.js +1 -1
- package/dist/services/core/order-edits.client.js.map +1 -1
- package/dist/services/core/orders.client.d.ts +120 -40
- package/dist/services/core/orders.client.d.ts.map +1 -1
- package/dist/services/core/orders.client.js +41 -10
- package/dist/services/core/orders.client.js.map +1 -1
- package/dist/services/core/pricing/currencies.client.d.ts +9 -23
- package/dist/services/core/pricing/currencies.client.d.ts.map +1 -1
- package/dist/services/core/pricing/currencies.client.js +12 -30
- package/dist/services/core/pricing/currencies.client.js.map +1 -1
- package/dist/services/core/pricing/pricing.client.d.ts +1 -1
- package/dist/services/core/pricing/pricing.client.d.ts.map +1 -1
- package/dist/services/core/pricing/pricing.client.js.map +1 -1
- package/dist/services/core/pricing/store-markets.client.d.ts +2 -5
- package/dist/services/core/pricing/store-markets.client.d.ts.map +1 -1
- package/dist/services/core/pricing/store-markets.client.js +1 -7
- package/dist/services/core/pricing/store-markets.client.js.map +1 -1
- package/dist/services/core/pricing/types.d.ts +41 -57
- package/dist/services/core/pricing/types.d.ts.map +1 -1
- package/dist/services/core/pricing/variant-prices.client.d.ts +2 -2
- package/dist/services/core/pricing/variant-prices.client.d.ts.map +1 -1
- package/dist/services/core/pricing/variant-prices.client.js +2 -6
- package/dist/services/core/pricing/variant-prices.client.js.map +1 -1
- package/dist/services/core/products.client.d.ts +71 -13
- package/dist/services/core/products.client.d.ts.map +1 -1
- package/dist/services/core/products.client.js.map +1 -1
- package/dist/services/core/returns.client.d.ts +21 -6
- package/dist/services/core/returns.client.d.ts.map +1 -1
- package/dist/services/core/returns.client.js +12 -6
- package/dist/services/core/returns.client.js.map +1 -1
- package/dist/services/core/reviews.client.d.ts +17 -15
- package/dist/services/core/reviews.client.d.ts.map +1 -1
- package/dist/services/core/reviews.client.js.map +1 -1
- package/dist/services/core/search.client.d.ts +26 -11
- package/dist/services/core/search.client.d.ts.map +1 -1
- package/dist/services/core/search.client.js.map +1 -1
- package/dist/services/core/shipping/classes.client.d.ts +2 -5
- package/dist/services/core/shipping/classes.client.d.ts.map +1 -1
- package/dist/services/core/shipping/classes.client.js +4 -0
- package/dist/services/core/shipping/classes.client.js.map +1 -1
- package/dist/services/core/shipping/labels.client.d.ts +3 -6
- package/dist/services/core/shipping/labels.client.d.ts.map +1 -1
- package/dist/services/core/shipping/labels.client.js +5 -1
- package/dist/services/core/shipping/labels.client.js.map +1 -1
- package/dist/services/core/shipping/providers.client.d.ts +2 -5
- package/dist/services/core/shipping/providers.client.d.ts.map +1 -1
- package/dist/services/core/shipping/providers.client.js +6 -2
- package/dist/services/core/shipping/providers.client.js.map +1 -1
- package/dist/services/core/shipping/rules.client.d.ts +2 -5
- package/dist/services/core/shipping/rules.client.d.ts.map +1 -1
- package/dist/services/core/shipping/rules.client.js +4 -2
- package/dist/services/core/shipping/rules.client.js.map +1 -1
- package/dist/services/core/shipping/shipping.client.d.ts +4 -4
- package/dist/services/core/shipping/shipping.client.d.ts.map +1 -1
- package/dist/services/core/shipping/shipping.client.js +7 -5
- package/dist/services/core/shipping/shipping.client.js.map +1 -1
- package/dist/services/core/shipping/store-providers.client.d.ts +5 -5
- package/dist/services/core/shipping/store-providers.client.d.ts.map +1 -1
- package/dist/services/core/shipping/store-providers.client.js +1 -1
- package/dist/services/core/shipping/store-providers.client.js.map +1 -1
- package/dist/services/core/shipping/types.d.ts +192 -65
- package/dist/services/core/shipping/types.d.ts.map +1 -1
- package/dist/services/core/shipping/zones.client.d.ts +2 -5
- package/dist/services/core/shipping/zones.client.d.ts.map +1 -1
- package/dist/services/core/shipping/zones.client.js +4 -0
- package/dist/services/core/shipping/zones.client.js.map +1 -1
- package/dist/services/core/storefront/index.d.ts +1 -1
- package/dist/services/core/storefront/index.d.ts.map +1 -1
- package/dist/services/core/storefront/index.js.map +1 -1
- package/dist/services/core/storefront/storefront-auth.client.d.ts +9 -4
- package/dist/services/core/storefront/storefront-auth.client.d.ts.map +1 -1
- package/dist/services/core/storefront/storefront-auth.client.js +7 -2
- package/dist/services/core/storefront/storefront-auth.client.js.map +1 -1
- package/dist/services/core/storefront/storefront-subscriptions.client.d.ts +3 -1
- package/dist/services/core/storefront/storefront-subscriptions.client.d.ts.map +1 -1
- package/dist/services/core/storefront/storefront-subscriptions.client.js.map +1 -1
- package/dist/services/core/storefront/storefront.client.d.ts +4 -1
- package/dist/services/core/storefront/storefront.client.d.ts.map +1 -1
- package/dist/services/core/storefront/storefront.client.js +4 -1
- package/dist/services/core/storefront/storefront.client.js.map +1 -1
- package/dist/services/core/storefront/types.d.ts +10 -0
- package/dist/services/core/storefront/types.d.ts.map +1 -1
- package/dist/services/core/stores/configuration.client.d.ts +21 -18
- package/dist/services/core/stores/configuration.client.d.ts.map +1 -1
- package/dist/services/core/stores/configuration.client.js.map +1 -1
- package/dist/services/core/stores/index.d.ts +1 -1
- package/dist/services/core/stores/index.d.ts.map +1 -1
- package/dist/services/core/stores/index.js.map +1 -1
- package/dist/services/core/stores/stores.client.d.ts +42 -14
- package/dist/services/core/stores/stores.client.d.ts.map +1 -1
- package/dist/services/core/stores/stores.client.js +9 -5
- package/dist/services/core/stores/stores.client.js.map +1 -1
- package/dist/services/core/taxes/jurisdictions.client.d.ts +4 -4
- package/dist/services/core/taxes/jurisdictions.client.d.ts.map +1 -1
- package/dist/services/core/taxes/jurisdictions.client.js +7 -4
- package/dist/services/core/taxes/jurisdictions.client.js.map +1 -1
- package/dist/services/core/taxes/providers.client.d.ts +1 -1
- package/dist/services/core/taxes/providers.client.d.ts.map +1 -1
- package/dist/services/core/taxes/providers.client.js.map +1 -1
- package/dist/services/core/taxes/store-providers.client.d.ts +5 -5
- package/dist/services/core/taxes/store-providers.client.d.ts.map +1 -1
- package/dist/services/core/taxes/store-providers.client.js +1 -1
- package/dist/services/core/taxes/store-providers.client.js.map +1 -1
- package/dist/services/core/taxes/taxes.client.d.ts +6 -3
- package/dist/services/core/taxes/taxes.client.d.ts.map +1 -1
- package/dist/services/core/taxes/taxes.client.js +5 -2
- package/dist/services/core/taxes/taxes.client.js.map +1 -1
- package/dist/services/core/taxes/types.d.ts +238 -131
- package/dist/services/core/taxes/types.d.ts.map +1 -1
- package/dist/services/core/variants.client.d.ts +72 -9
- package/dist/services/core/variants.client.d.ts.map +1 -1
- package/dist/services/core/variants.client.js.map +1 -1
- package/dist/services/core/wishlists.client.d.ts +31 -25
- package/dist/services/core/wishlists.client.d.ts.map +1 -1
- package/dist/services/core/wishlists.client.js +4 -2
- package/dist/services/core/wishlists.client.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HttpClientTransport as HttpClient } from '../../core/http-client.js';
|
|
2
|
+
import type { ListOptions, PaginatedResponse } from '../../core/types/pagination.js';
|
|
2
3
|
import { BaseResourceClient } from './base-resource.js';
|
|
3
4
|
/**
|
|
4
5
|
* Discount type enum values (camelCase to match backend naming convention)
|
|
@@ -15,43 +16,71 @@ export interface BogoConfig {
|
|
|
15
16
|
/** Discount percentage for the "get" items (100 = free, 50 = half off) */
|
|
16
17
|
getDiscountPercent: number;
|
|
17
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* A discount holds the rules; its codes are `DiscountCode` rows
|
|
21
|
+
* (`sdk.discounts.codes`). One discount has many codes.
|
|
22
|
+
*/
|
|
18
23
|
export interface Discount {
|
|
19
24
|
id: string;
|
|
20
25
|
tenantId: string;
|
|
21
26
|
storeId: string;
|
|
22
|
-
|
|
27
|
+
/** Number of live (not deleted) codes. */
|
|
28
|
+
codeCount: number;
|
|
29
|
+
/** Oldest live code, or `null` when the discount has none (auto-applied). */
|
|
30
|
+
primaryCode: string | null;
|
|
23
31
|
name: string;
|
|
24
|
-
description
|
|
32
|
+
description: string | null;
|
|
25
33
|
discountType: DiscountType;
|
|
26
34
|
discountValue: number;
|
|
27
|
-
currency
|
|
28
|
-
minimumOrderAmount
|
|
29
|
-
minimumOrderQuantity
|
|
30
|
-
usageLimit
|
|
31
|
-
usageLimitPerCustomer
|
|
35
|
+
currency: string;
|
|
36
|
+
minimumOrderAmount: number | null;
|
|
37
|
+
minimumOrderQuantity: number | null;
|
|
38
|
+
usageLimit: number | null;
|
|
39
|
+
usageLimitPerCustomer: number | null;
|
|
32
40
|
usageCount: number;
|
|
33
|
-
applicableProducts
|
|
34
|
-
applicableCategories
|
|
35
|
-
applicableVariants
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
applicableProducts: string[];
|
|
42
|
+
applicableCategories: string[];
|
|
43
|
+
applicableVariants: string[];
|
|
44
|
+
customerEligibility: Record<string, unknown> | null;
|
|
45
|
+
requiredCustomerTags: string[];
|
|
46
|
+
excludedCustomerTags: string[];
|
|
47
|
+
startsAt: string;
|
|
48
|
+
endsAt: string | null;
|
|
40
49
|
isActive: boolean;
|
|
41
|
-
isAutoApplied
|
|
42
|
-
canCombineWithOthers
|
|
43
|
-
priority
|
|
44
|
-
|
|
50
|
+
isAutoApplied: boolean;
|
|
51
|
+
canCombineWithOthers: boolean;
|
|
52
|
+
priority: number;
|
|
53
|
+
/** BOGO discounts carry their `bogoConfig` here. */
|
|
54
|
+
metadata: Record<string, unknown> | null;
|
|
45
55
|
createdAt: string;
|
|
46
56
|
updatedAt: string;
|
|
57
|
+
deletedAt: string | null;
|
|
47
58
|
}
|
|
48
59
|
export interface DiscountCondition {
|
|
49
60
|
type: 'product' | 'category' | 'customer' | 'minimumQuantity';
|
|
50
61
|
operator: 'in' | 'notIn' | 'equals' | 'greaterThan';
|
|
51
62
|
value: string | string[] | number;
|
|
52
63
|
}
|
|
64
|
+
/** Batch of unique codes generated for a discount. */
|
|
65
|
+
export interface GenerateDiscountCodesDto {
|
|
66
|
+
/** Exact number of codes to create (1-10000). */
|
|
67
|
+
count: number;
|
|
68
|
+
/** Letters, digits, `-` and `_` only. */
|
|
69
|
+
prefix?: string;
|
|
70
|
+
/** Random part length, 4-16 (server default 6). */
|
|
71
|
+
codeLength?: number;
|
|
72
|
+
/** Usage limit applied to each generated code. */
|
|
73
|
+
usageLimitPerCode?: number;
|
|
74
|
+
}
|
|
53
75
|
export interface CreateDiscountDto {
|
|
54
|
-
|
|
76
|
+
/**
|
|
77
|
+
* One code for the discount. Send exactly one of `code` or `generate`;
|
|
78
|
+
* neither only when `isAutoApplied` is true (codes on an auto-applied
|
|
79
|
+
* discount are a 400).
|
|
80
|
+
*/
|
|
81
|
+
code?: string;
|
|
82
|
+
/** Generate a batch of unique codes with the discount, in one transaction. */
|
|
83
|
+
generate?: GenerateDiscountCodesDto;
|
|
55
84
|
name: string;
|
|
56
85
|
description?: string;
|
|
57
86
|
discountType: DiscountType;
|
|
@@ -65,6 +94,7 @@ export interface CreateDiscountDto {
|
|
|
65
94
|
applicableProducts?: string[];
|
|
66
95
|
applicableCategories?: string[];
|
|
67
96
|
applicableVariants?: string[];
|
|
97
|
+
customerEligibility?: Record<string, unknown>;
|
|
68
98
|
requiredCustomerTags?: string[];
|
|
69
99
|
excludedCustomerTags?: string[];
|
|
70
100
|
startsAt?: string;
|
|
@@ -77,7 +107,9 @@ export interface CreateDiscountDto {
|
|
|
77
107
|
/** Configuration for Buy X Get Y discounts. Required when discountType is buyXGetY. */
|
|
78
108
|
bogoConfig?: BogoConfig;
|
|
79
109
|
}
|
|
110
|
+
/** PATCH body: every CreateDiscountDto field is optional (including code). */
|
|
80
111
|
export interface UpdateDiscountDto {
|
|
112
|
+
code?: string;
|
|
81
113
|
name?: string;
|
|
82
114
|
description?: string;
|
|
83
115
|
discountType?: DiscountType;
|
|
@@ -90,6 +122,7 @@ export interface UpdateDiscountDto {
|
|
|
90
122
|
applicableProducts?: string[];
|
|
91
123
|
applicableCategories?: string[];
|
|
92
124
|
applicableVariants?: string[];
|
|
125
|
+
customerEligibility?: Record<string, unknown>;
|
|
93
126
|
requiredCustomerTags?: string[];
|
|
94
127
|
excludedCustomerTags?: string[];
|
|
95
128
|
startsAt?: string;
|
|
@@ -101,60 +134,158 @@ export interface UpdateDiscountDto {
|
|
|
101
134
|
metadata?: Record<string, unknown>;
|
|
102
135
|
bogoConfig?: BogoConfig;
|
|
103
136
|
}
|
|
137
|
+
/** Query filters read by GET /v1/discounts. */
|
|
104
138
|
export interface DiscountFilters extends Record<string, unknown> {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
139
|
+
/** Case-insensitive match on code or name. */
|
|
140
|
+
search?: string;
|
|
141
|
+
active?: boolean;
|
|
142
|
+
type?: DiscountType;
|
|
143
|
+
}
|
|
144
|
+
/** Response of GET /v1/discounts (`page` is 0-based). */
|
|
145
|
+
export interface DiscountListResponse {
|
|
146
|
+
data: Discount[];
|
|
147
|
+
total: number;
|
|
148
|
+
page: number;
|
|
149
|
+
limit: number;
|
|
150
|
+
}
|
|
151
|
+
/** Body for POST /v1/discounts/validate and POST /v1/discounts/calculate. */
|
|
152
|
+
export interface ValidateDiscountDto {
|
|
153
|
+
code: string;
|
|
154
|
+
customerId?: string;
|
|
155
|
+
/** Guest shopper email for the per-customer limit (matched trimmed and lowercased). */
|
|
156
|
+
customerEmail?: string;
|
|
157
|
+
orderAmount?: number;
|
|
158
|
+
orderQuantity?: number;
|
|
159
|
+
shippingAmount?: number;
|
|
160
|
+
cartItems?: {
|
|
161
|
+
items: Array<{
|
|
162
|
+
productId: string;
|
|
163
|
+
variantId?: string;
|
|
164
|
+
categoryIds?: string[];
|
|
165
|
+
quantity: number;
|
|
166
|
+
price: number;
|
|
167
|
+
}>;
|
|
168
|
+
};
|
|
108
169
|
}
|
|
109
170
|
export interface DiscountValidation {
|
|
110
171
|
isValid: boolean;
|
|
111
|
-
|
|
112
|
-
|
|
172
|
+
/** Why the code is invalid (when `isValid` is false). */
|
|
173
|
+
reason?: string;
|
|
174
|
+
discount?: Record<string, unknown>;
|
|
175
|
+
/** Id of the matched code (the code row, not the discount). */
|
|
176
|
+
discountCodeId?: string;
|
|
113
177
|
discountAmount?: number;
|
|
178
|
+
remainingUses?: number;
|
|
179
|
+
remainingUsesPerCustomer?: number;
|
|
114
180
|
}
|
|
115
|
-
export
|
|
116
|
-
|
|
117
|
-
export interface BulkGenerateDiscountDto {
|
|
118
|
-
baseDiscount: Omit<CreateDiscountDto, 'code'>;
|
|
181
|
+
export interface DiscountUsageByDate {
|
|
182
|
+
date: string;
|
|
119
183
|
count: number;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
184
|
+
amountSaved: number;
|
|
185
|
+
}
|
|
186
|
+
export interface DiscountTopCustomer {
|
|
187
|
+
customerId: string;
|
|
188
|
+
usageCount: number;
|
|
189
|
+
totalSaved: number;
|
|
190
|
+
}
|
|
191
|
+
export interface DiscountUsageStats {
|
|
192
|
+
discountId: string;
|
|
193
|
+
code: string;
|
|
194
|
+
totalUsages: number;
|
|
195
|
+
totalAmountSaved: number;
|
|
196
|
+
uniqueCustomers: number;
|
|
197
|
+
usageByDate?: DiscountUsageByDate[];
|
|
198
|
+
topCustomers?: DiscountTopCustomer[];
|
|
199
|
+
}
|
|
200
|
+
/** One code of a discount (`/v1/discounts/:id/codes`). */
|
|
201
|
+
export interface DiscountCode {
|
|
202
|
+
id: string;
|
|
203
|
+
discountId: string;
|
|
204
|
+
code: string;
|
|
205
|
+
/** Per-code usage limit, `null` for unlimited. */
|
|
206
|
+
usageLimit: number | null;
|
|
207
|
+
usageCount: number;
|
|
208
|
+
isActive: boolean;
|
|
209
|
+
createdAt: string;
|
|
210
|
+
updatedAt: string;
|
|
211
|
+
}
|
|
212
|
+
export interface CreateDiscountCodeDto {
|
|
213
|
+
code: string;
|
|
214
|
+
usageLimit?: number;
|
|
215
|
+
}
|
|
216
|
+
export interface UpdateDiscountCodeDto {
|
|
217
|
+
isActive?: boolean;
|
|
218
|
+
/** `null` removes the limit. */
|
|
219
|
+
usageLimit?: number | null;
|
|
220
|
+
}
|
|
221
|
+
export interface DiscountCodeFilters extends Record<string, unknown> {
|
|
222
|
+
/** Code contains (case-insensitive). */
|
|
223
|
+
search?: string;
|
|
124
224
|
}
|
|
125
|
-
/** Response from `POST /v1/discounts/
|
|
126
|
-
export interface
|
|
225
|
+
/** Response from `POST /v1/discounts/:id/codes/generate`. */
|
|
226
|
+
export interface GenerateDiscountCodesResult {
|
|
127
227
|
count: number;
|
|
128
|
-
|
|
129
|
-
baseDiscountId: string;
|
|
228
|
+
discountId: string;
|
|
130
229
|
}
|
|
131
230
|
/**
|
|
132
|
-
*
|
|
231
|
+
* Codes of one discount (`/v1/discounts/:discountId/codes`), reached as
|
|
232
|
+
* `sdk.discounts.codes`.
|
|
233
|
+
*/
|
|
234
|
+
export declare class DiscountCodesClient {
|
|
235
|
+
private readonly http;
|
|
236
|
+
private readonly baseUrl;
|
|
237
|
+
constructor(http: HttpClient, baseUrl: string);
|
|
238
|
+
private endpoint;
|
|
239
|
+
/**
|
|
240
|
+
* List the codes of a discount. `page` is 1-based (default 1, `limit` default 50).
|
|
241
|
+
*/
|
|
242
|
+
list(discountId: string, options?: Pick<ListOptions<DiscountCodeFilters>, 'page' | 'limit'> & {
|
|
243
|
+
search?: string;
|
|
244
|
+
}): Promise<PaginatedResponse<DiscountCode>>;
|
|
245
|
+
/**
|
|
246
|
+
* Add one code. 409 when the code already exists, including a deleted one.
|
|
247
|
+
*/
|
|
248
|
+
add(discountId: string, data: CreateDiscountCodeDto): Promise<DiscountCode>;
|
|
249
|
+
/**
|
|
250
|
+
* Generate exactly `count` unique codes. 409 when unique codes cannot be found.
|
|
251
|
+
* Returns the count, not the codes: read them with `list`.
|
|
252
|
+
*/
|
|
253
|
+
generate(discountId: string, data: GenerateDiscountCodesDto): Promise<GenerateDiscountCodesResult>;
|
|
254
|
+
/**
|
|
255
|
+
* Activate, deactivate or re-limit a code.
|
|
256
|
+
*/
|
|
257
|
+
update(discountId: string, codeId: string, data: UpdateDiscountCodeDto): Promise<DiscountCode>;
|
|
258
|
+
/**
|
|
259
|
+
* Delete an unused code (soft delete). 409 once the code has been used:
|
|
260
|
+
* deactivate it instead.
|
|
261
|
+
*/
|
|
262
|
+
delete(discountId: string, codeId: string): Promise<{
|
|
263
|
+
success: boolean;
|
|
264
|
+
}>;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Discounts (`/v1/discounts`): master rules with many codes (`codes`).
|
|
133
268
|
*
|
|
134
269
|
* `list()` `page` is 0-based (server default `page=0`). Most other SDK list
|
|
135
|
-
* helpers document 1-indexed pages.
|
|
270
|
+
* helpers document 1-indexed pages. `codes.list()` is 1-based.
|
|
136
271
|
*/
|
|
137
|
-
export declare class DiscountsClient extends BaseResourceClient<Discount, CreateDiscountDto, UpdateDiscountDto, DiscountFilters> {
|
|
272
|
+
export declare class DiscountsClient extends BaseResourceClient<Discount, CreateDiscountDto, UpdateDiscountDto, DiscountFilters, DiscountListResponse> {
|
|
273
|
+
/** Sub-client for the codes of a discount */
|
|
274
|
+
readonly codes: DiscountCodesClient;
|
|
138
275
|
constructor(httpClient: HttpClient, baseUrl: string);
|
|
139
276
|
/**
|
|
140
|
-
* Get discount
|
|
277
|
+
* Get the discount a code belongs to
|
|
141
278
|
*/
|
|
142
279
|
getByCode(code: string): Promise<Discount>;
|
|
143
280
|
/**
|
|
144
|
-
* Validate a discount code
|
|
281
|
+
* Validate a discount code against order context (amount, quantity, items).
|
|
145
282
|
*/
|
|
146
|
-
validate(
|
|
283
|
+
validate(data: ValidateDiscountDto): Promise<DiscountValidation>;
|
|
147
284
|
/**
|
|
148
|
-
* Calculate discount amount for
|
|
285
|
+
* Calculate the discount amount for order context. Same body and response
|
|
286
|
+
* as validate().
|
|
149
287
|
*/
|
|
150
|
-
calculate(
|
|
151
|
-
productId: string;
|
|
152
|
-
quantity: number;
|
|
153
|
-
price: number;
|
|
154
|
-
}[]): Promise<{
|
|
155
|
-
discountAmount: number;
|
|
156
|
-
newTotal: number;
|
|
157
|
-
}>;
|
|
288
|
+
calculate(data: ValidateDiscountDto): Promise<DiscountValidation>;
|
|
158
289
|
/**
|
|
159
290
|
* Activate a discount
|
|
160
291
|
*/
|
|
@@ -164,34 +295,11 @@ export declare class DiscountsClient extends BaseResourceClient<Discount, Create
|
|
|
164
295
|
*/
|
|
165
296
|
deactivate(discountId: string): Promise<Discount>;
|
|
166
297
|
/**
|
|
167
|
-
* Get discount usage statistics
|
|
168
|
-
*/
|
|
169
|
-
getUsageStats(discountId: string): Promise<{
|
|
170
|
-
totalUsage: number;
|
|
171
|
-
totalDiscountAmount: number;
|
|
172
|
-
uniqueCustomers: number;
|
|
173
|
-
}>;
|
|
174
|
-
/**
|
|
175
|
-
* Generate unique discount codes in bulk (`POST /v1/discounts/bulk-generate`).
|
|
176
|
-
*
|
|
177
|
-
* Body matches core-api `BulkGenerateDiscountDto`. Returns
|
|
178
|
-
* `{ count, codes, baseDiscountId }`, not the created discount rows.
|
|
179
|
-
*
|
|
180
|
-
* @example
|
|
181
|
-
* ```typescript
|
|
182
|
-
* const { count, codes, baseDiscountId } = await sdk.discounts.generateCodes({
|
|
183
|
-
* baseDiscount: {
|
|
184
|
-
* name: 'SoClean single-use',
|
|
185
|
-
* discountType: 'percent',
|
|
186
|
-
* discountValue: 10,
|
|
187
|
-
* usageLimit: 1,
|
|
188
|
-
* },
|
|
189
|
-
* count: 5,
|
|
190
|
-
* generationType: 'prefix',
|
|
191
|
-
* prefix: 'SOCLEAN',
|
|
192
|
-
* });
|
|
193
|
-
* ```
|
|
298
|
+
* Get discount usage statistics, optionally bounded by ISO dates.
|
|
194
299
|
*/
|
|
195
|
-
|
|
300
|
+
getUsageStats(discountId: string, range?: {
|
|
301
|
+
startDate?: string;
|
|
302
|
+
endDate?: string;
|
|
303
|
+
}): Promise<DiscountUsageStats>;
|
|
196
304
|
}
|
|
197
305
|
//# sourceMappingURL=discounts.client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discounts.client.d.ts","sourceRoot":"","sources":["../../../../../src/services/core/discounts.client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,IAAI,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAIxD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,aAAa,GAAG,cAAc,GAAG,UAAU,CAAC;AAEnF;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,
|
|
1
|
+
{"version":3,"file":"discounts.client.d.ts","sourceRoot":"","sources":["../../../../../src/services/core/discounts.client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,IAAI,UAAU,EAAE,MAAM,2BAA2B,CAA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-resource.js';
|
|
2
2
|
// ==================== Client ====================
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Codes of one discount (`/v1/discounts/:discountId/codes`), reached as
|
|
5
|
+
* `sdk.discounts.codes`.
|
|
6
|
+
*/
|
|
7
|
+
export class DiscountCodesClient {
|
|
8
|
+
http;
|
|
9
|
+
baseUrl;
|
|
10
|
+
constructor(http, baseUrl) {
|
|
11
|
+
this.http = http;
|
|
12
|
+
this.baseUrl = baseUrl;
|
|
13
|
+
}
|
|
14
|
+
endpoint(discountId) {
|
|
15
|
+
return `${this.baseUrl}/v1/discounts/${discountId}/codes`;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* List the codes of a discount. `page` is 1-based (default 1, `limit` default 50).
|
|
19
|
+
*/
|
|
20
|
+
async list(discountId, options = {}) {
|
|
21
|
+
const params = {};
|
|
22
|
+
if (options.page !== undefined) {
|
|
23
|
+
params.page = String(options.page);
|
|
24
|
+
}
|
|
25
|
+
if (options.limit !== undefined) {
|
|
26
|
+
params.limit = String(options.limit);
|
|
27
|
+
}
|
|
28
|
+
if (options.search !== undefined) {
|
|
29
|
+
params.search = options.search;
|
|
30
|
+
}
|
|
31
|
+
return this.http.get(this.endpoint(discountId), { params });
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Add one code. 409 when the code already exists, including a deleted one.
|
|
35
|
+
*/
|
|
36
|
+
async add(discountId, data) {
|
|
37
|
+
return this.http.post(this.endpoint(discountId), data);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Generate exactly `count` unique codes. 409 when unique codes cannot be found.
|
|
41
|
+
* Returns the count, not the codes: read them with `list`.
|
|
42
|
+
*/
|
|
43
|
+
async generate(discountId, data) {
|
|
44
|
+
return this.http.post(`${this.endpoint(discountId)}/generate`, data);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Activate, deactivate or re-limit a code.
|
|
48
|
+
*/
|
|
49
|
+
async update(discountId, codeId, data) {
|
|
50
|
+
return this.http.patch(`${this.endpoint(discountId)}/${codeId}`, data);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Delete an unused code (soft delete). 409 once the code has been used:
|
|
54
|
+
* deactivate it instead.
|
|
55
|
+
*/
|
|
56
|
+
async delete(discountId, codeId) {
|
|
57
|
+
return this.http.delete(`${this.endpoint(discountId)}/${codeId}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Discounts (`/v1/discounts`): master rules with many codes (`codes`).
|
|
5
62
|
*
|
|
6
63
|
* `list()` `page` is 0-based (server default `page=0`). Most other SDK list
|
|
7
|
-
* helpers document 1-indexed pages.
|
|
64
|
+
* helpers document 1-indexed pages. `codes.list()` is 1-based.
|
|
8
65
|
*/
|
|
9
66
|
export class DiscountsClient extends BaseResourceClient {
|
|
67
|
+
/** Sub-client for the codes of a discount */
|
|
68
|
+
codes;
|
|
10
69
|
constructor(httpClient, baseUrl) {
|
|
11
70
|
super({ httpClient, baseUrl, resourcePath: 'discounts' });
|
|
71
|
+
this.codes = new DiscountCodesClient(httpClient, baseUrl);
|
|
12
72
|
}
|
|
13
73
|
/**
|
|
14
|
-
* Get discount
|
|
74
|
+
* Get the discount a code belongs to
|
|
15
75
|
*/
|
|
16
76
|
async getByCode(code) {
|
|
17
77
|
return this.http.get(`${this.endpoint}/code/${code}`);
|
|
18
78
|
}
|
|
19
79
|
/**
|
|
20
|
-
* Validate a discount code
|
|
80
|
+
* Validate a discount code against order context (amount, quantity, items).
|
|
21
81
|
*/
|
|
22
|
-
async validate(
|
|
23
|
-
return this.http.post(`${this.endpoint}/validate`,
|
|
24
|
-
code,
|
|
25
|
-
cartId,
|
|
26
|
-
});
|
|
82
|
+
async validate(data) {
|
|
83
|
+
return this.http.post(`${this.endpoint}/validate`, data);
|
|
27
84
|
}
|
|
28
85
|
/**
|
|
29
|
-
* Calculate discount amount for
|
|
86
|
+
* Calculate the discount amount for order context. Same body and response
|
|
87
|
+
* as validate().
|
|
30
88
|
*/
|
|
31
|
-
async calculate(
|
|
32
|
-
return this.http.post(`${this.endpoint}/calculate`,
|
|
33
|
-
code,
|
|
34
|
-
cartTotal,
|
|
35
|
-
items,
|
|
36
|
-
});
|
|
89
|
+
async calculate(data) {
|
|
90
|
+
return this.http.post(`${this.endpoint}/calculate`, data);
|
|
37
91
|
}
|
|
38
92
|
/**
|
|
39
93
|
* Activate a discount
|
|
@@ -48,34 +102,17 @@ export class DiscountsClient extends BaseResourceClient {
|
|
|
48
102
|
return this.http.post(`${this.endpoint}/${discountId}/deactivate`, {});
|
|
49
103
|
}
|
|
50
104
|
/**
|
|
51
|
-
* Get discount usage statistics
|
|
52
|
-
*/
|
|
53
|
-
async getUsageStats(discountId) {
|
|
54
|
-
return this.http.get(`${this.endpoint}/${discountId}/stats`);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Generate unique discount codes in bulk (`POST /v1/discounts/bulk-generate`).
|
|
58
|
-
*
|
|
59
|
-
* Body matches core-api `BulkGenerateDiscountDto`. Returns
|
|
60
|
-
* `{ count, codes, baseDiscountId }`, not the created discount rows.
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```typescript
|
|
64
|
-
* const { count, codes, baseDiscountId } = await sdk.discounts.generateCodes({
|
|
65
|
-
* baseDiscount: {
|
|
66
|
-
* name: 'SoClean single-use',
|
|
67
|
-
* discountType: 'percent',
|
|
68
|
-
* discountValue: 10,
|
|
69
|
-
* usageLimit: 1,
|
|
70
|
-
* },
|
|
71
|
-
* count: 5,
|
|
72
|
-
* generationType: 'prefix',
|
|
73
|
-
* prefix: 'SOCLEAN',
|
|
74
|
-
* });
|
|
75
|
-
* ```
|
|
105
|
+
* Get discount usage statistics, optionally bounded by ISO dates.
|
|
76
106
|
*/
|
|
77
|
-
async
|
|
78
|
-
|
|
107
|
+
async getUsageStats(discountId, range = {}) {
|
|
108
|
+
const params = {};
|
|
109
|
+
if (range.startDate !== undefined)
|
|
110
|
+
params.startDate = range.startDate;
|
|
111
|
+
if (range.endDate !== undefined)
|
|
112
|
+
params.endDate = range.endDate;
|
|
113
|
+
return this.http.get(`${this.endpoint}/${discountId}/usage-stats`, {
|
|
114
|
+
params,
|
|
115
|
+
});
|
|
79
116
|
}
|
|
80
117
|
}
|
|
81
118
|
//# sourceMappingURL=discounts.client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discounts.client.js","sourceRoot":"","sources":["../../../../../src/services/core/discounts.client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"discounts.client.js","sourceRoot":"","sources":["../../../../../src/services/core/discounts.client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAyPxD,mDAAmD;AAEnD;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAEX;IACA;IAFnB,YACmB,IAAgB,EAChB,OAAe;QADf,SAAI,GAAJ,IAAI,CAAY;QAChB,YAAO,GAAP,OAAO,CAAQ;IAC/B,CAAC;IAEI,QAAQ,CAAC,UAAkB;QACjC,OAAO,GAAG,IAAI,CAAC,OAAO,iBAAiB,UAAU,QAAQ,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI,CACR,UAAkB,EAClB,UAA0F,EAAE;QAE5F,MAAM,MAAM,GAA2B,EAAE,CAAC;QAC1C,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC/B,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC;QACD,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAChC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACjC,MAAM,CAAC,MAAM,GAAG,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,CAAqB,GAAG,IAAI,CAAC,QAAQ,IAAI,UAAU,cAAc,EAAE;YACrF,MAAM;SACP,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const EXPORT_ENTITIES: readonly ["orders", "products", "customers", "inventory", "discounts", "reviews"];
|
|
1
|
+
export declare const EXPORT_ENTITIES: readonly ["orders", "products", "customers", "inventory", "discounts", "discountCodes", "reviews"];
|
|
2
2
|
export type ExportEntity = (typeof EXPORT_ENTITIES)[number];
|
|
3
3
|
export declare const ORDER_EXPORT_INCLUDES: readonly ["items", "fulfillments", "payments", "refunds", "discounts", "notes"];
|
|
4
4
|
export type OrderExportInclude = (typeof ORDER_EXPORT_INCLUDES)[number];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/services/core/exports/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/services/core/exports/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,oGAQlB,CAAC;AACX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5D,eAAO,MAAM,qBAAqB,iFAOxB,CAAC;AACX,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAExE,eAAO,MAAM,kBAAkB,gCAAiC,CAAC;AACjE,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAElE,eAAO,MAAM,mBAAmB,qEAMtB,CAAC;AACX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnE,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK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AE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/services/core/exports/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,QAAQ;IACR,UAAU;IACV,WAAW;IACX,WAAW;IACX,WAAW;IACX,SAAS;CACD,CAAC;AAGX,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,OAAO;IACP,cAAc;IACd,UAAU;IACV,SAAS;IACT,WAAW;IACX,OAAO;CACC,CAAC;AAGX,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAU,CAAC;AAGjE,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,SAAS;IACT,SAAS;IACT,WAAW;IACX,QAAQ;IACR,WAAW;CACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/services/core/exports/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,QAAQ;IACR,UAAU;IACV,WAAW;IACX,WAAW;IACX,WAAW;IACX,eAAe;IACf,SAAS;CACD,CAAC;AAGX,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,OAAO;IACP,cAAc;IACd,UAAU;IACV,SAAS;IACT,WAAW;IACX,OAAO;CACC,CAAC;AAGX,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAU,CAAC;AAGjE,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,SAAS;IACT,SAAS;IACT,WAAW;IACX,QAAQ;IACR,WAAW;CACH,CAAC"}
|
|
@@ -2,12 +2,13 @@ import type { HttpClientTransport as HttpClient } from '../../core/http-client.j
|
|
|
2
2
|
export type FacetValueType = 'boolean' | 'integer' | 'float' | 'string' | 'image' | 'color';
|
|
3
3
|
export interface ProductFacet {
|
|
4
4
|
id: string;
|
|
5
|
+
tenantId: string;
|
|
5
6
|
productId: string;
|
|
6
7
|
key: string;
|
|
7
8
|
value: unknown;
|
|
8
|
-
valueUnit
|
|
9
|
-
valueType
|
|
10
|
-
enumValues
|
|
9
|
+
valueUnit: string | null;
|
|
10
|
+
valueType: FacetValueType | null;
|
|
11
|
+
enumValues: string[];
|
|
11
12
|
isSearchable: boolean;
|
|
12
13
|
isFilterable: boolean;
|
|
13
14
|
isFacetable: boolean;
|
|
@@ -60,7 +61,8 @@ export interface FacetSearchProduct {
|
|
|
60
61
|
updatedAt: string;
|
|
61
62
|
}
|
|
62
63
|
export interface FacetOptions {
|
|
63
|
-
|
|
64
|
+
/** Unique facet values per key. Values are the stored JSON facet values (string, number, boolean, object, array). */
|
|
65
|
+
facets: Record<string, unknown[]>;
|
|
64
66
|
}
|
|
65
67
|
/**
|
|
66
68
|
* FacetsClient manages product facets for filtering and search.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facets.client.d.ts","sourceRoot":"","sources":["../../../../../src/services/core/facets.client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,IAAI,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAInF,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;AAE5F,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,
|
|
1
|
+
{"version":3,"file":"fac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AAG,OAAO,CAAC,YAAY,CAAC;IAI5E;;OAEG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAI/C;;OAEG;IACG,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,YAAY,CAAC;IAI7F;;OAEG;IACG,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAI/D;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIxE;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,YAAY,CAAC;CAG1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facets.client.js","sourceRoot":"","sources":["../../../../../src/services/core/facets.client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"facets.client.js","sourceRoot":"","sources":["../../../../../src/services/core/facets.client.ts"],"names":[],"mappings":"AA6EA,mDAAmD;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,YAAY;IAEJ;IACA;IAFnB,YACmB,IAAgB,EAChB,OAAe;QADf,SAAI,GAAJ,IAAI,CAAY;QAChB,YAAO,GAAP,OAAO,CAAQ;IAC/B,CAAC;IAEJ;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAe,GAAG,IAAI,CAAC,OAAO,cAAc,EAAE,EAAE,CAAC,CAAC;IACxE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,IAA2B;QAClD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAe,GAAG,IAAI,CAAC,OAAO,cAAc,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IAC9E,CAAC;IAED;;OAEG;IACH,KAAK,CAAC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