@commercejs/types 0.1.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/adapter.d.ts +310 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +12 -0
- package/dist/adapter.js.map +1 -0
- package/dist/auction.d.ts +59 -0
- package/dist/auction.d.ts.map +1 -0
- package/dist/auction.js +5 -0
- package/dist/auction.js.map +1 -0
- package/dist/brand.d.ts +16 -0
- package/dist/brand.d.ts.map +1 -0
- package/dist/brand.js +5 -0
- package/dist/brand.js.map +1 -0
- package/dist/cart.d.ts +42 -0
- package/dist/cart.d.ts.map +1 -0
- package/dist/cart.js +5 -0
- package/dist/cart.js.map +1 -0
- package/dist/category.d.ts +13 -0
- package/dist/category.d.ts.map +1 -0
- package/dist/category.js +5 -0
- package/dist/category.js.map +1 -0
- package/dist/common.d.ts +81 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/common.js +27 -0
- package/dist/common.js.map +1 -0
- package/dist/country.d.ts +16 -0
- package/dist/country.d.ts.map +1 -0
- package/dist/country.js +5 -0
- package/dist/country.js.map +1 -0
- package/dist/customer.d.ts +48 -0
- package/dist/customer.d.ts.map +1 -0
- package/dist/customer.js +5 -0
- package/dist/customer.js.map +1 -0
- package/dist/gift-card.d.ts +64 -0
- package/dist/gift-card.d.ts.map +1 -0
- package/dist/gift-card.js +5 -0
- package/dist/gift-card.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/location.d.ts +56 -0
- package/dist/location.d.ts.map +1 -0
- package/dist/location.js +5 -0
- package/dist/location.js.map +1 -0
- package/dist/order-input.d.ts +46 -0
- package/dist/order-input.d.ts.map +1 -0
- package/dist/order-input.js +9 -0
- package/dist/order-input.js.map +1 -0
- package/dist/order-status.d.ts +55 -0
- package/dist/order-status.d.ts.map +1 -0
- package/dist/order-status.js +5 -0
- package/dist/order-status.js.map +1 -0
- package/dist/order.d.ts +62 -0
- package/dist/order.d.ts.map +1 -0
- package/dist/order.js +5 -0
- package/dist/order.js.map +1 -0
- package/dist/payment-provider.d.ts +117 -0
- package/dist/payment-provider.d.ts.map +1 -0
- package/dist/payment-provider.js +10 -0
- package/dist/payment-provider.js.map +1 -0
- package/dist/payment.d.ts +22 -0
- package/dist/payment.d.ts.map +1 -0
- package/dist/payment.js +5 -0
- package/dist/payment.js.map +1 -0
- package/dist/product.d.ts +162 -0
- package/dist/product.d.ts.map +1 -0
- package/dist/product.js +5 -0
- package/dist/product.js.map +1 -0
- package/dist/promotion.d.ts +65 -0
- package/dist/promotion.d.ts.map +1 -0
- package/dist/promotion.js +5 -0
- package/dist/promotion.js.map +1 -0
- package/dist/rental.d.ts +84 -0
- package/dist/rental.d.ts.map +1 -0
- package/dist/rental.js +5 -0
- package/dist/rental.js.map +1 -0
- package/dist/return.d.ts +64 -0
- package/dist/return.d.ts.map +1 -0
- package/dist/return.js +5 -0
- package/dist/return.js.map +1 -0
- package/dist/review.d.ts +31 -0
- package/dist/review.d.ts.map +1 -0
- package/dist/review.js +5 -0
- package/dist/review.js.map +1 -0
- package/dist/search.d.ts +38 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +5 -0
- package/dist/search.js.map +1 -0
- package/dist/shipping.d.ts +17 -0
- package/dist/shipping.d.ts.map +1 -0
- package/dist/shipping.js +5 -0
- package/dist/shipping.js.map +1 -0
- package/dist/store.d.ts +36 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +5 -0
- package/dist/store.js.map +1 -0
- package/dist/wholesale.d.ts +89 -0
- package/dist/wholesale.d.ts.map +1 -0
- package/dist/wholesale.js +5 -0
- package/dist/wholesale.js.map +1 -0
- package/dist/wishlist.d.ts +18 -0
- package/dist/wishlist.d.ts.map +1 -0
- package/dist/wishlist.js +5 -0
- package/dist/wishlist.js.map +1 -0
- package/package.json +27 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { Maybe } from './common.js';
|
|
2
|
+
/** Status of a payment session through its lifecycle */
|
|
3
|
+
export type PaymentSessionStatus = 'pending' | 'requires_action' | 'processing' | 'authorized' | 'captured' | 'failed' | 'cancelled' | 'refunded' | 'partially_refunded';
|
|
4
|
+
/**
|
|
5
|
+
* A payment session — the unit of work for a payment.
|
|
6
|
+
*
|
|
7
|
+
* Created by `PaymentProvider.createSession()`, progressed through
|
|
8
|
+
* confirm → capture, and optionally refunded.
|
|
9
|
+
*/
|
|
10
|
+
export interface PaymentSession {
|
|
11
|
+
/** Unique session identifier (provider-scoped) */
|
|
12
|
+
id: string;
|
|
13
|
+
/** Which provider created this session */
|
|
14
|
+
providerId: string;
|
|
15
|
+
/** Current status */
|
|
16
|
+
status: PaymentSessionStatus;
|
|
17
|
+
/** Payment amount (in major currency units, e.g., 99.99) */
|
|
18
|
+
amount: number;
|
|
19
|
+
/** ISO 4217 currency code */
|
|
20
|
+
currency: string;
|
|
21
|
+
/** Provider-specific data (e.g., Stripe PaymentIntent ID, Tap charge ID) */
|
|
22
|
+
providerData: Maybe<Record<string, unknown>>;
|
|
23
|
+
/** URL to redirect customer for 3DS / authentication / hosted page */
|
|
24
|
+
redirectUrl: Maybe<string>;
|
|
25
|
+
/** When the session was created */
|
|
26
|
+
createdAt: string;
|
|
27
|
+
}
|
|
28
|
+
/** Input to create a payment session */
|
|
29
|
+
export interface CreatePaymentSessionInput {
|
|
30
|
+
/** Payment amount (major currency units) */
|
|
31
|
+
amount: number;
|
|
32
|
+
/** ISO 4217 currency code (e.g., 'SAR', 'USD') */
|
|
33
|
+
currency: string;
|
|
34
|
+
/** Client-side token from gateway SDK (e.g., Tap tok_xxx, Stripe pm_xxx) */
|
|
35
|
+
sourceToken?: string;
|
|
36
|
+
/** Order ID to associate with this payment */
|
|
37
|
+
orderId?: string;
|
|
38
|
+
/** Customer ID (if authenticated) */
|
|
39
|
+
customerId?: string;
|
|
40
|
+
/** Customer details — required by Tap and most gateways */
|
|
41
|
+
customer?: {
|
|
42
|
+
email?: string;
|
|
43
|
+
firstName?: string;
|
|
44
|
+
lastName?: string;
|
|
45
|
+
phone?: string;
|
|
46
|
+
};
|
|
47
|
+
/** Where to redirect after 3DS / hosted payment page */
|
|
48
|
+
returnUrl?: string;
|
|
49
|
+
/** Cancel URL for hosted payment pages */
|
|
50
|
+
cancelUrl?: string;
|
|
51
|
+
/** Per-transaction webhook URL — Tap sends charge events to this URL as `post.url` */
|
|
52
|
+
webhookUrl?: string;
|
|
53
|
+
/** Idempotency key to prevent duplicate charges on retries */
|
|
54
|
+
idempotencyKey?: string;
|
|
55
|
+
/** Arbitrary metadata passed to the gateway */
|
|
56
|
+
metadata?: Record<string, unknown>;
|
|
57
|
+
}
|
|
58
|
+
/** Input for refunds */
|
|
59
|
+
export interface RefundInput {
|
|
60
|
+
/** Session ID of the payment to refund */
|
|
61
|
+
sessionId: string;
|
|
62
|
+
/** Partial refund amount; omit for full refund */
|
|
63
|
+
amount?: number;
|
|
64
|
+
/** Reason for the refund */
|
|
65
|
+
reason?: string;
|
|
66
|
+
}
|
|
67
|
+
/** Parsed webhook event from a payment provider */
|
|
68
|
+
export interface PaymentWebhookEvent {
|
|
69
|
+
/** Event type (e.g., 'payment.captured', 'refund.created') */
|
|
70
|
+
type: string;
|
|
71
|
+
/** Related payment session ID */
|
|
72
|
+
sessionId: string;
|
|
73
|
+
/** Raw event data from the provider */
|
|
74
|
+
data: Record<string, unknown>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Pluggable payment gateway interface.
|
|
78
|
+
*
|
|
79
|
+
* Each gateway (Stripe, Tap, SoftPOS) implements this interface.
|
|
80
|
+
* The core lifecycle is: `create → confirm → refund`.
|
|
81
|
+
* Optional methods (`captureSession`, `cancelSession`, `verifyWebhook`)
|
|
82
|
+
* support auth+capture gateways and webhook-driven flows.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* const tap = new TapPaymentProvider({ secretKey: 'sk_test_...' })
|
|
87
|
+
* const session = await tap.createSession({
|
|
88
|
+
* amount: 99.99,
|
|
89
|
+
* currency: 'SAR',
|
|
90
|
+
* sourceToken: 'tok_xxx', // from goSell.js
|
|
91
|
+
* returnUrl: 'https://store.com/checkout/confirm',
|
|
92
|
+
* })
|
|
93
|
+
* // redirect customer to session.redirectUrl for 3DS...
|
|
94
|
+
* const confirmed = await tap.confirmSession(session.id)
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export interface PaymentProvider {
|
|
98
|
+
/** Unique provider identifier (e.g., 'stripe', 'tap') */
|
|
99
|
+
readonly id: string;
|
|
100
|
+
/** Human-readable provider name (e.g., 'Stripe', 'Tap Payments') */
|
|
101
|
+
readonly name: string;
|
|
102
|
+
/** Create a payment session (charge or redirect) */
|
|
103
|
+
createSession(input: CreatePaymentSessionInput): Promise<PaymentSession>;
|
|
104
|
+
/** Confirm a payment after customer action (3DS redirect, OTP) */
|
|
105
|
+
confirmSession(sessionId: string, data?: Record<string, unknown>): Promise<PaymentSession>;
|
|
106
|
+
/** Get current status of a payment session */
|
|
107
|
+
getSession(sessionId: string): Promise<PaymentSession>;
|
|
108
|
+
/** Refund a captured payment (full or partial) */
|
|
109
|
+
refund(input: RefundInput): Promise<PaymentSession>;
|
|
110
|
+
/** Capture an authorized payment — only for auth+capture gateways */
|
|
111
|
+
captureSession?(sessionId: string, amount?: number): Promise<PaymentSession>;
|
|
112
|
+
/** Cancel/void a pending or authorized session */
|
|
113
|
+
cancelSession?(sessionId: string): Promise<PaymentSession>;
|
|
114
|
+
/** Verify webhook signature and parse event (server-side only) */
|
|
115
|
+
verifyWebhook?(payload: string | Uint8Array, signature: string): Promise<PaymentWebhookEvent>;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=payment-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-provider.d.ts","sourceRoot":"","sources":["../src/payment-provider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,CAAA;IAEnD,qEAAqE;IACrE,cAAc,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;IAE5E,kDAAkD;IAClD,aAAa,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;IAE1D,kEAAkE;IAClE,aAAa,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;CAC9F"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// PaymentProvider — pluggable gateway interface (Strategy pattern)
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
//
|
|
5
|
+
// Each payment gateway (Stripe, Tap, Salla, SoftPOS) implements this
|
|
6
|
+
// interface. The Universal Checkout engine will use a PaymentProviderRegistry
|
|
7
|
+
// to select the right provider at runtime.
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=payment-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-provider.js","sourceRoot":"","sources":["../src/payment-provider.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,mEAAmE;AACnE,8EAA8E;AAC9E,EAAE;AACF,qEAAqE;AACrE,8EAA8E;AAC9E,2CAA2C;AAC3C,8EAA8E"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Id, LocalizedString, Maybe } from './common.js';
|
|
2
|
+
/** Known GCC and international payment types */
|
|
3
|
+
export type PaymentType = 'card' | 'mada' | 'apple_pay' | 'google_pay' | 'stc_pay' | 'tamara' | 'tabby' | 'tap' | 'cash_on_delivery' | 'bank_transfer' | 'sadad' | 'paypal' | 'custom';
|
|
4
|
+
/** Buy Now Pay Later installment details */
|
|
5
|
+
export interface Installment {
|
|
6
|
+
count: number;
|
|
7
|
+
/** Amount per installment in smallest currency unit */
|
|
8
|
+
amount: number;
|
|
9
|
+
currency: string;
|
|
10
|
+
}
|
|
11
|
+
/** Payment method option */
|
|
12
|
+
export interface PaymentMethod {
|
|
13
|
+
id: Id;
|
|
14
|
+
type: PaymentType | string;
|
|
15
|
+
name: LocalizedString;
|
|
16
|
+
provider: string;
|
|
17
|
+
/** BNPL installment info (for Tamara, Tabby, etc.) */
|
|
18
|
+
installments: Maybe<Installment>;
|
|
19
|
+
/** Icon/logo URL */
|
|
20
|
+
icon: Maybe<string>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=payment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../src/payment.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAE7D,gDAAgD;AAChD,MAAM,MAAM,WAAW,GACnB,MAAM,GACN,MAAM,GACN,WAAW,GACX,YAAY,GACZ,SAAS,GACT,QAAQ,GACR,OAAO,GACP,KAAK,GACL,kBAAkB,GAClB,eAAe,GACf,OAAO,GACP,QAAQ,GACR,QAAQ,CAAA;AAEZ,4CAA4C;AAC5C,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,4BAA4B;AAC5B,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,EAAE,CAAA;IACN,IAAI,EAAE,WAAW,GAAG,MAAM,CAAA;IAC1B,IAAI,EAAE,eAAe,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,sDAAsD;IACtD,YAAY,EAAE,KAAK,CAAC,WAAW,CAAC,CAAA;IAChC,oBAAoB;IACpB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;CACpB"}
|
package/dist/payment.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.js","sourceRoot":"","sources":["../src/payment.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,uBAAuB;AACvB,8EAA8E"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import type { DiscountablePrice, Id, Image, LocalizedString, Maybe, Price } from './common.js';
|
|
2
|
+
import type { Category } from './category.js';
|
|
3
|
+
import type { PriceTier, CustomerGroupPrice } from './wholesale.js';
|
|
4
|
+
import type { AuctionProductMeta } from './auction.js';
|
|
5
|
+
import type { RentalProductMeta } from './rental.js';
|
|
6
|
+
/** Product attribute (e.g., color, size, material) */
|
|
7
|
+
export interface Attribute {
|
|
8
|
+
/** Machine-readable code (e.g., "color") */
|
|
9
|
+
code: string;
|
|
10
|
+
/** Human-readable name */
|
|
11
|
+
name: LocalizedString;
|
|
12
|
+
/** Display value */
|
|
13
|
+
value: LocalizedString;
|
|
14
|
+
}
|
|
15
|
+
/** A selectable product option group (e.g. Size, Color) */
|
|
16
|
+
export interface ProductOption {
|
|
17
|
+
/** Machine-readable identifier */
|
|
18
|
+
id: Id;
|
|
19
|
+
/** Human-readable option name (e.g. "Size", "Color") */
|
|
20
|
+
name: LocalizedString;
|
|
21
|
+
/** Possible values for this option */
|
|
22
|
+
values: {
|
|
23
|
+
id: Id;
|
|
24
|
+
name: LocalizedString;
|
|
25
|
+
}[];
|
|
26
|
+
}
|
|
27
|
+
/** A specific variant of a product (e.g., "Red / XL") */
|
|
28
|
+
export interface ProductVariant {
|
|
29
|
+
id: Id;
|
|
30
|
+
sku: Maybe<string>;
|
|
31
|
+
name: Maybe<LocalizedString>;
|
|
32
|
+
price: Maybe<DiscountablePrice>;
|
|
33
|
+
attributes: Attribute[];
|
|
34
|
+
inStock: boolean;
|
|
35
|
+
inventoryQuantity: Maybe<number>;
|
|
36
|
+
}
|
|
37
|
+
/** Classifies the product for fulfillment logic and UI rendering */
|
|
38
|
+
export type ProductType = 'physical' | 'digital' | 'service' | 'event' | 'subscription' | 'auction' | 'rental' | 'gift_card';
|
|
39
|
+
/** Metadata for digital products (ebooks, software, courses, etc.) */
|
|
40
|
+
export interface DigitalProductMeta {
|
|
41
|
+
/** Download URL (populated after purchase) */
|
|
42
|
+
downloadUrl: Maybe<string>;
|
|
43
|
+
/** File size in bytes (for display) */
|
|
44
|
+
fileSize: Maybe<number>;
|
|
45
|
+
/** File format / MIME type (e.g., "application/pdf") */
|
|
46
|
+
fileType: Maybe<string>;
|
|
47
|
+
/** License key (populated after purchase) */
|
|
48
|
+
licenseKey: Maybe<string>;
|
|
49
|
+
/** Maximum number of downloads allowed (null = unlimited) */
|
|
50
|
+
maxDownloads: Maybe<number>;
|
|
51
|
+
/** Download link expiry duration in hours (null = never) */
|
|
52
|
+
expiresInHours: Maybe<number>;
|
|
53
|
+
}
|
|
54
|
+
/** Metadata for service products (consulting, repairs, bookings) */
|
|
55
|
+
export interface ServiceProductMeta {
|
|
56
|
+
/** Estimated duration in minutes */
|
|
57
|
+
durationMinutes: Maybe<number>;
|
|
58
|
+
/** Whether the service requires scheduling / booking */
|
|
59
|
+
requiresBooking: boolean;
|
|
60
|
+
/** Service delivery mode */
|
|
61
|
+
deliveryMode: 'in_person' | 'remote' | 'hybrid';
|
|
62
|
+
}
|
|
63
|
+
/** Metadata for event/ticket products (concerts, conferences, classes) */
|
|
64
|
+
export interface EventProductMeta {
|
|
65
|
+
/** Event start date/time (ISO 8601) */
|
|
66
|
+
startDate: string;
|
|
67
|
+
/** Event end date/time (ISO 8601) */
|
|
68
|
+
endDate: Maybe<string>;
|
|
69
|
+
/** Venue name */
|
|
70
|
+
venue: Maybe<LocalizedString>;
|
|
71
|
+
/** Venue address or online meeting URL */
|
|
72
|
+
location: Maybe<string>;
|
|
73
|
+
/** Whether the event is virtual / online */
|
|
74
|
+
isVirtual: boolean;
|
|
75
|
+
/** Seat or section information */
|
|
76
|
+
seatInfo: Maybe<string>;
|
|
77
|
+
/** Total available seats / capacity (null = unlimited) */
|
|
78
|
+
capacity: Maybe<number>;
|
|
79
|
+
}
|
|
80
|
+
/** Metadata for subscription products (recurring billing) */
|
|
81
|
+
export interface SubscriptionProductMeta {
|
|
82
|
+
/** Billing interval */
|
|
83
|
+
interval: 'daily' | 'weekly' | 'monthly' | 'quarterly' | 'yearly';
|
|
84
|
+
/** Number of intervals between billings (e.g., 2 = every 2 months) */
|
|
85
|
+
intervalCount: number;
|
|
86
|
+
/** Free trial period in days (0 = no trial) */
|
|
87
|
+
trialDays: number;
|
|
88
|
+
/** Price per billing cycle (may differ from product.price for introductory offers) */
|
|
89
|
+
recurringPrice: Price;
|
|
90
|
+
}
|
|
91
|
+
/** Pre-order availability information */
|
|
92
|
+
export interface PreOrderMeta {
|
|
93
|
+
/** Whether this product is available for pre-order */
|
|
94
|
+
enabled: boolean;
|
|
95
|
+
/** Expected release / availability date (ISO 8601) */
|
|
96
|
+
releaseDate: Maybe<string>;
|
|
97
|
+
/** Optional deposit amount (null = full price required) */
|
|
98
|
+
depositAmount: Maybe<Price>;
|
|
99
|
+
/** Pre-order message to display (e.g., "Ships by March 2026") */
|
|
100
|
+
message: Maybe<LocalizedString>;
|
|
101
|
+
}
|
|
102
|
+
/** Core product entity */
|
|
103
|
+
export interface Product {
|
|
104
|
+
id: Id;
|
|
105
|
+
sku: Maybe<string>;
|
|
106
|
+
/** Bilingual product name */
|
|
107
|
+
name: LocalizedString;
|
|
108
|
+
slug: string;
|
|
109
|
+
/** Bilingual product description (may contain HTML) */
|
|
110
|
+
description: Maybe<LocalizedString>;
|
|
111
|
+
/** Short description for listings */
|
|
112
|
+
shortDescription: Maybe<LocalizedString>;
|
|
113
|
+
price: Maybe<DiscountablePrice>;
|
|
114
|
+
primaryImage: Maybe<Image>;
|
|
115
|
+
gallery: Image[];
|
|
116
|
+
rating: Maybe<{
|
|
117
|
+
average: number;
|
|
118
|
+
count: number;
|
|
119
|
+
}>;
|
|
120
|
+
variants: ProductVariant[];
|
|
121
|
+
/** Selectable option groups (Size, Color, etc.) */
|
|
122
|
+
options: ProductOption[];
|
|
123
|
+
attributes: Attribute[];
|
|
124
|
+
/** Maximum purchasable quantity (null = unlimited) */
|
|
125
|
+
quantityLimit: Maybe<number>;
|
|
126
|
+
categories: Category[];
|
|
127
|
+
inStock: boolean;
|
|
128
|
+
/** Whether the displayed price includes VAT */
|
|
129
|
+
vatIncluded: boolean;
|
|
130
|
+
/** VAT rate as a decimal (e.g., 0.15 for KSA 15%) */
|
|
131
|
+
vatRate: Maybe<number>;
|
|
132
|
+
tags: string[];
|
|
133
|
+
createdAt: string;
|
|
134
|
+
updatedAt: string;
|
|
135
|
+
/** Product classification — drives fulfillment logic and UI. Defaults to 'physical' */
|
|
136
|
+
productType: ProductType;
|
|
137
|
+
/** Digital product metadata (present when productType === 'digital') */
|
|
138
|
+
digital: Maybe<DigitalProductMeta>;
|
|
139
|
+
/** Service product metadata (present when productType === 'service') */
|
|
140
|
+
service: Maybe<ServiceProductMeta>;
|
|
141
|
+
/** Event/ticket metadata (present when productType === 'event') */
|
|
142
|
+
event: Maybe<EventProductMeta>;
|
|
143
|
+
/** Subscription metadata (present when productType === 'subscription') */
|
|
144
|
+
subscription: Maybe<SubscriptionProductMeta>;
|
|
145
|
+
/** Auction metadata (present when productType === 'auction') */
|
|
146
|
+
auction: Maybe<AuctionProductMeta>;
|
|
147
|
+
/** Rental metadata (present when productType === 'rental') */
|
|
148
|
+
rental: Maybe<RentalProductMeta>;
|
|
149
|
+
/** Pre-order information (present on any productType) */
|
|
150
|
+
preOrder: Maybe<PreOrderMeta>;
|
|
151
|
+
/** Whether this product requires shipping (false for digital, services, events) */
|
|
152
|
+
requiresShipping: boolean;
|
|
153
|
+
/** Minimum order quantity for this product (null = 1) */
|
|
154
|
+
minOrderQuantity: Maybe<number>;
|
|
155
|
+
/** Volume-based pricing tiers (null = single price) */
|
|
156
|
+
priceTiers: Maybe<PriceTier[]>;
|
|
157
|
+
/** Per-customer-group price overrides */
|
|
158
|
+
customerGroupPricing: Maybe<CustomerGroupPrice[]>;
|
|
159
|
+
/** Whether this product is fulfilled by a third-party / dropshipper */
|
|
160
|
+
isDropshipped: boolean;
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=product.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product.d.ts","sourceRoot":"","sources":["../src/product.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC9F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpD,sDAAsD;AACtD,MAAM,WAAW,SAAS;IACxB,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAA;IACZ,0BAA0B;IAC1B,IAAI,EAAE,eAAe,CAAA;IACrB,oBAAoB;IACpB,KAAK,EAAE,eAAe,CAAA;CACvB;AAED,2DAA2D;AAC3D,MAAM,WAAW,aAAa;IAC5B,kCAAkC;IAClC,EAAE,EAAE,EAAE,CAAA;IACN,wDAAwD;IACxD,IAAI,EAAE,eAAe,CAAA;IACrB,sCAAsC;IACtC,MAAM,EAAE;QAAE,EAAE,EAAE,EAAE,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,EAAE,CAAA;CAC5C;AAED,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,EAAE,CAAA;IACN,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAClB,IAAI,EAAE,KAAK,CAAC,eAA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AS,EAAE,CAAC,CAAA;IAE9B,yCAAyC;IACzC,oBAAoB,EAAE,KAAK,CAAC,kBAAkB,EAAE,CAAC,CAAA;IAIjD,uEAAuE;IACvE,aAAa,EAAE,OAAO,CAAA;CACvB"}
|
package/dist/product.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product.js","sourceRoot":"","sources":["../src/product.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,uBAAuB;AACvB,8EAA8E"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Id, LocalizedString, Maybe, Price } from './common.js';
|
|
2
|
+
/** How the discount value is applied */
|
|
3
|
+
export type DiscountType = 'percentage' | 'fixed_amount' | 'free_shipping' | 'buy_x_get_y' | 'bundle';
|
|
4
|
+
/** What the promotion applies to */
|
|
5
|
+
export type PromotionTarget = 'order' | 'product' | 'category' | 'shipping' | 'customer';
|
|
6
|
+
/** Minimum requirements to qualify for a promotion */
|
|
7
|
+
export interface PromotionCondition {
|
|
8
|
+
/** Minimum order subtotal */
|
|
9
|
+
minPurchaseAmount: Maybe<Price>;
|
|
10
|
+
/** Minimum item count in cart */
|
|
11
|
+
minItemCount: Maybe<number>;
|
|
12
|
+
/** Required product IDs (for product-specific promos) */
|
|
13
|
+
productIds: Maybe<string[]>;
|
|
14
|
+
/** Required category IDs (for category-specific promos) */
|
|
15
|
+
categoryIds: Maybe<string[]>;
|
|
16
|
+
/** First-time customer only */
|
|
17
|
+
firstOrderOnly: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** A promotion / discount campaign */
|
|
20
|
+
export interface Promotion {
|
|
21
|
+
id: Id;
|
|
22
|
+
/** Display name */
|
|
23
|
+
name: LocalizedString;
|
|
24
|
+
/** Description / terms */
|
|
25
|
+
description: Maybe<LocalizedString>;
|
|
26
|
+
/** Discount mechanism */
|
|
27
|
+
discountType: DiscountType;
|
|
28
|
+
/** Discount value — percentage (0–100) or fixed amount */
|
|
29
|
+
discountValue: number;
|
|
30
|
+
/** Currency for fixed_amount discounts */
|
|
31
|
+
currency: Maybe<string>;
|
|
32
|
+
/** Maximum discount cap for percentage discounts (null = uncapped) */
|
|
33
|
+
maxDiscount: Maybe<Price>;
|
|
34
|
+
/** What does this promotion apply to */
|
|
35
|
+
target: PromotionTarget;
|
|
36
|
+
/** Conditions that must be met */
|
|
37
|
+
conditions: PromotionCondition;
|
|
38
|
+
/** Start date (ISO 8601) */
|
|
39
|
+
startsAt: string;
|
|
40
|
+
/** End date (ISO 8601, null = no end) */
|
|
41
|
+
endsAt: Maybe<string>;
|
|
42
|
+
/** Whether this promotion is currently active */
|
|
43
|
+
isActive: boolean;
|
|
44
|
+
/** Whether a coupon code is required to activate */
|
|
45
|
+
requiresCoupon: boolean;
|
|
46
|
+
/** Usage limit per customer (null = unlimited) */
|
|
47
|
+
usageLimitPerCustomer: Maybe<number>;
|
|
48
|
+
/** Total usage limit (null = unlimited) */
|
|
49
|
+
usageLimitTotal: Maybe<number>;
|
|
50
|
+
}
|
|
51
|
+
/** A redeemable coupon code */
|
|
52
|
+
export interface Coupon {
|
|
53
|
+
id: Id;
|
|
54
|
+
/** The code the customer enters (e.g., "SAVE20") */
|
|
55
|
+
code: string;
|
|
56
|
+
/** Associated promotion */
|
|
57
|
+
promotion: Promotion;
|
|
58
|
+
/** Whether this coupon is still valid */
|
|
59
|
+
isValid: boolean;
|
|
60
|
+
/** Reason if invalid (e.g., "expired", "usage_limit_reached") */
|
|
61
|
+
invalidReason: Maybe<string>;
|
|
62
|
+
/** Number of times this coupon has been used */
|
|
63
|
+
timesUsed: number;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=promotion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promotion.d.ts","sourceRoot":"","sources":["../src/promotion.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AA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c,EAAE,OAAO,CAAA;IACvB,kDAAkD;IAClD,qBAAqB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACpC,2CAA2C;IAC3C,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;CAC/B;AAED,+BAA+B;AAC/B,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,EAAE,CAAA;IACN,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAA;IACZ,2BAA2B;IAC3B,SAAS,EAAE,SAAS,CAAA;IACpB,yCAAyC;IACzC,OAAO,EAAE,OAAO,CAAA;IAChB,iEAAiE;IACjE,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC5B,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAA;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promotion.js","sourceRoot":"","sources":["../src/promotion.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,6BAA6B;AAC7B,8EAA8E"}
|
package/dist/rental.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Id, LocalizedString, Maybe, Price } from './common.js';
|
|
2
|
+
/** Rental pricing unit */
|
|
3
|
+
export type RentalPricingUnit = 'hourly' | 'daily' | 'weekly' | 'monthly';
|
|
4
|
+
/** Rental product metadata */
|
|
5
|
+
export interface RentalProductMeta {
|
|
6
|
+
/** Primary pricing unit */
|
|
7
|
+
pricingUnit: RentalPricingUnit;
|
|
8
|
+
/** Price per unit */
|
|
9
|
+
pricePerUnit: Price;
|
|
10
|
+
/** Discounted pricing for longer durations */
|
|
11
|
+
pricingTiers: Maybe<RentalPricingTier[]>;
|
|
12
|
+
/** Security deposit amount (null = no deposit) */
|
|
13
|
+
securityDeposit: Maybe<Price>;
|
|
14
|
+
/** Minimum rental duration (in pricingUnit units) */
|
|
15
|
+
minDuration: number;
|
|
16
|
+
/** Maximum rental duration (null = unlimited) */
|
|
17
|
+
maxDuration: Maybe<number>;
|
|
18
|
+
/** Whether pickup/delivery is required (vs. fully digital) */
|
|
19
|
+
requiresPickup: boolean;
|
|
20
|
+
/** Pickup / return location */
|
|
21
|
+
location: Maybe<LocalizedString>;
|
|
22
|
+
/** Late return fee per unit */
|
|
23
|
+
lateFeePerUnit: Maybe<Price>;
|
|
24
|
+
/** Preparation time before item is available (hours) */
|
|
25
|
+
preparationTime: Maybe<number>;
|
|
26
|
+
}
|
|
27
|
+
/** Pricing tier for longer rental durations */
|
|
28
|
+
export interface RentalPricingTier {
|
|
29
|
+
/** Minimum # of units to qualify */
|
|
30
|
+
minUnits: number;
|
|
31
|
+
/** Price per unit at this tier */
|
|
32
|
+
pricePerUnit: Price;
|
|
33
|
+
/** Optional label (e.g., "Weekly Rate") */
|
|
34
|
+
label: Maybe<LocalizedString>;
|
|
35
|
+
}
|
|
36
|
+
/** A time slot for availability */
|
|
37
|
+
export interface AvailabilitySlot {
|
|
38
|
+
/** Start time (ISO 8601) */
|
|
39
|
+
startDate: string;
|
|
40
|
+
/** End time (ISO 8601) */
|
|
41
|
+
endDate: string;
|
|
42
|
+
/** Number of units available in this slot */
|
|
43
|
+
availableQuantity: number;
|
|
44
|
+
/** Whether this slot is fully booked */
|
|
45
|
+
isBooked: boolean;
|
|
46
|
+
}
|
|
47
|
+
/** Rental booking status */
|
|
48
|
+
export type RentalBookingStatus = 'pending' | 'confirmed' | 'active' | 'returned' | 'overdue' | 'cancelled';
|
|
49
|
+
/** A rental booking entity */
|
|
50
|
+
export interface RentalBooking {
|
|
51
|
+
id: Id;
|
|
52
|
+
productId: Id;
|
|
53
|
+
customerId: Id;
|
|
54
|
+
status: RentalBookingStatus;
|
|
55
|
+
/** Rental start (ISO 8601) */
|
|
56
|
+
startDate: string;
|
|
57
|
+
/** Rental end (ISO 8601) */
|
|
58
|
+
endDate: string;
|
|
59
|
+
/** Actual return date (ISO 8601, null if not yet returned) */
|
|
60
|
+
returnedAt: Maybe<string>;
|
|
61
|
+
/** Pricing unit used */
|
|
62
|
+
pricingUnit: RentalPricingUnit;
|
|
63
|
+
/** Number of pricing units */
|
|
64
|
+
duration: number;
|
|
65
|
+
/** Total rental cost */
|
|
66
|
+
totalPrice: Price;
|
|
67
|
+
/** Security deposit amount held */
|
|
68
|
+
depositAmount: Maybe<Price>;
|
|
69
|
+
/** Whether deposit has been refunded */
|
|
70
|
+
depositRefunded: boolean;
|
|
71
|
+
/** Late fees accrued */
|
|
72
|
+
lateFees: Maybe<Price>;
|
|
73
|
+
/** Related order ID */
|
|
74
|
+
orderId: Maybe<Id>;
|
|
75
|
+
createdAt: string;
|
|
76
|
+
}
|
|
77
|
+
/** Input for creating a rental booking */
|
|
78
|
+
export interface CreateRentalBookingInput {
|
|
79
|
+
productId: string;
|
|
80
|
+
startDate: string;
|
|
81
|
+
endDate: string;
|
|
82
|
+
quantity?: number;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=rental.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rental.d.ts","sourceRoot":"","sources":["../src/rental.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEpE,0BAA0B;AAC1B,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAA;AAEzE,8BAA8B;AAC9B,MAAM,WAAW,iBAAiB;IAChC,2BAA2B;IAC3B,WAAW,EAAE,iBAAiB,CAAA;IAC9B,qBAAqB;IACrB,YAAY,EAAE,KAAK,CAAA;IACnB,8CAA8C;IAC9C,YAAY,EAAE,KAAK,CAAC,iBAAiB,EAAE,CAAC,CAAA;IACxC,kDAAkD;IAClD,eAAe,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IAC7B,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAA;IACnB,iDAAiD;IACjD,WAAW,EAAE,KAAK,CAAC,MAAM,CAA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B,UAAU,EAAE,KAAK,CAAA;IACjB,mCAAmC;IACnC,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IAC3B,wCAAwC;IACxC,eAAe,EAAE,OAAO,CAAA;IACxB,wBAAwB;IACxB,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IACtB,uBAAuB;IACvB,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,0CAA0C;AAC1C,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB"}
|
package/dist/rental.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rental.js","sourceRoot":"","sources":["../src/rental.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,yBAAyB;AACzB,8EAA8E"}
|
package/dist/return.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Id, Image, LocalizedString, Maybe, Price } from './common.js';
|
|
2
|
+
/** Reason for returning an item */
|
|
3
|
+
export type ReturnReason = 'defective' | 'wrong_item' | 'not_as_described' | 'changed_mind' | 'size_fit' | 'arrived_late' | 'damaged_in_shipping' | 'other';
|
|
4
|
+
/** Return request status lifecycle */
|
|
5
|
+
export type ReturnStatus = 'requested' | 'approved' | 'rejected' | 'shipped' | 'received' | 'refunded' | 'cancelled';
|
|
6
|
+
/** Refund method — how the money is returned */
|
|
7
|
+
export type RefundMethod = 'original_payment' | 'store_credit' | 'bank_transfer' | 'wallet';
|
|
8
|
+
/** A single item within a return request */
|
|
9
|
+
export interface ReturnItem {
|
|
10
|
+
id: Id;
|
|
11
|
+
/** Original order item ID */
|
|
12
|
+
orderItemId: Id;
|
|
13
|
+
productId: Id;
|
|
14
|
+
variantId: Maybe<Id>;
|
|
15
|
+
name: LocalizedString;
|
|
16
|
+
image: Maybe<Image>;
|
|
17
|
+
/** Quantity being returned */
|
|
18
|
+
quantity: number;
|
|
19
|
+
/** Reason for this item's return */
|
|
20
|
+
reason: ReturnReason;
|
|
21
|
+
/** Customer's description of the issue */
|
|
22
|
+
reasonNote: Maybe<string>;
|
|
23
|
+
/** Photos of damage / issue (customer-uploaded) */
|
|
24
|
+
evidenceImages: Image[];
|
|
25
|
+
}
|
|
26
|
+
/** Input for creating a return request */
|
|
27
|
+
export interface CreateReturnInput {
|
|
28
|
+
/** Order ID to return items from */
|
|
29
|
+
orderId: string;
|
|
30
|
+
/** Items to return */
|
|
31
|
+
items: Array<{
|
|
32
|
+
orderItemId: string;
|
|
33
|
+
quantity: number;
|
|
34
|
+
reason: ReturnReason;
|
|
35
|
+
reasonNote?: string;
|
|
36
|
+
}>;
|
|
37
|
+
/** Preferred refund method */
|
|
38
|
+
preferredRefundMethod?: RefundMethod;
|
|
39
|
+
}
|
|
40
|
+
/** A return request entity */
|
|
41
|
+
export interface ReturnRequest {
|
|
42
|
+
id: Id;
|
|
43
|
+
/** Original order ID */
|
|
44
|
+
orderId: Id;
|
|
45
|
+
/** Original order number (for display) */
|
|
46
|
+
orderNumber: string;
|
|
47
|
+
status: ReturnStatus;
|
|
48
|
+
items: ReturnItem[];
|
|
49
|
+
/** Total refund amount */
|
|
50
|
+
refundAmount: Maybe<Price>;
|
|
51
|
+
/** How the refund will be processed */
|
|
52
|
+
refundMethod: Maybe<RefundMethod>;
|
|
53
|
+
/** Return shipping label URL (provided by merchant) */
|
|
54
|
+
returnShippingLabel: Maybe<string>;
|
|
55
|
+
/** Tracking number for return shipment */
|
|
56
|
+
returnTrackingNumber: Maybe<string>;
|
|
57
|
+
/** Merchant notes (e.g., rejection reason) */
|
|
58
|
+
merchantNote: Maybe<string>;
|
|
59
|
+
/** Customer notes */
|
|
60
|
+
customerNote: Maybe<string>;
|
|
61
|
+
createdAt: string;
|
|
62
|
+
updatedAt: string;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=return.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"return.d.ts","sourceRoot":"","sources":["../src/return.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAE3E,mCAAmC;AACnC,MAAM,MAAM,YAAY,GACpB,WAAW,GACX,YAAY,GACZ,kBAAkB,GAClB,cAAc,GACd,UAAU,GACV,cAAc,GACd,qBAAqB,GACrB,OAAO,CAAA;AAEX,sCAAsC;AACtC,MAAM,MAAM,YAAY,GACpB,WAAW,GACX,UAAU,GACV,UAAU,GACV,SAAS,GACT,UAAU,GACV,UAAU,GACV,WAAW,CAAA;AAEf,gDAAgD;AAChD,MAAM,MAAM,YAAY,GACpB,kBAAkB,GAClB,cAAc,GACd,eAAe,GACf,QAAQ,CAAA;AAEZ,4CAA4C;AAC5C,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,EAAE,CAAA;IACN,6BAA6B;IAC7B,WAAW,EAAE,EAAE,CAAA;IACf,SAAS,EAAE,EAAE,CAAA;IACb,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,CAAA;IACpB,IAAI,EAAE,eAAe,CAAA;IACrB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IACnB,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAA;IAChB,oCAAoC;IACpC,MAAM,EAAE,YAAY,CAAA;IACpB,0CAA0C;IAC1C,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACzB,mDAAmD;IACnD,cAAc,EAAE,KAAK,EAAE,CAAA;CACxB;AAED,0CAA0C;AAC1C,MAAM,WAAW,iBAAiB;IAChC,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAA;IACf,sBAAsB;IACtB,KAAK,EAAE,KAAK,CAAC;QACX,WAAW,E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