@thorprovider/types 5.7.10 → 5.8.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/AGENTS.md +1 -1
- package/README.md +8 -0
- package/dist/index.d.mts +425 -144
- package/dist/index.d.ts +425 -144
- package/dist/index.js +0 -138
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -125
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/admin/DropshippingAdmin.ts +0 -57
- package/src/cart.ts +40 -0
- package/src/catalog.ts +210 -0
- package/src/collection.ts +10 -0
- package/src/commerce-provider.ts +58 -1
- package/src/commerce.ts +88 -0
- package/src/index.ts +32 -18
- package/src/order.ts +33 -0
- package/src/product.ts +1 -0
- package/src/provider.ts +14 -178
- package/src/storefront.ts +5 -32
package/src/catalog.ts
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @thorprovider/types — Canonical catalog query, truthful results, and facet support.
|
|
3
|
+
*
|
|
4
|
+
* Type-only module: no runtime code, constants, or schemas. These types are shared by
|
|
5
|
+
* the URL boundary, the runtime commerce bridge, and the adapters so every product
|
|
6
|
+
* listing asks the backend one well-formed question and reports truthfully what was
|
|
7
|
+
* applied. Validation (Zod) lives in `@thorprovider/runtime/contracts`; translation to
|
|
8
|
+
* backend parameters lives in the adapters.
|
|
9
|
+
*
|
|
10
|
+
* E2 `storefront-catalog-search-filters`. The canonical URL parameter contract is:
|
|
11
|
+
* `q` (text), the route category scope plus `categories`/`collections`, `sort`
|
|
12
|
+
* (`featured` | `name` | `newest`), `page`/`pageSize`, and the optional requested
|
|
13
|
+
* facets `priceMin`/`priceMax`/`inStock`/`attr.<name>`.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { Product } from './product';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Canonical, backend-verified sort keys.
|
|
20
|
+
*
|
|
21
|
+
* Only these three are verified against Medusa v2: `featured` (server default),
|
|
22
|
+
* `name` (translated to `title`), and `newest` (translated to `-created_at`). Global
|
|
23
|
+
* price ordering and rating are not verified and are rejected by the boundary as a
|
|
24
|
+
* typed unsupported-query error. An adapter advertises the subset it can actually
|
|
25
|
+
* apply; the listing never offers a sort the backend cannot perform.
|
|
26
|
+
*/
|
|
27
|
+
export type CatalogSortKey = 'featured' | 'name' | 'newest';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Canonical catalog query crossing the URL boundary, the runtime bridge, and the
|
|
31
|
+
* adapters.
|
|
32
|
+
*
|
|
33
|
+
* Fields mirror the fixed, lowercase URL namespace. They are optional because
|
|
34
|
+
* documented defaults (`sort` = `featured`, `page` = `1`, `pageSize` = the chosen
|
|
35
|
+
* target default) are resolved by the URL boundary and apply only to absent
|
|
36
|
+
* parameters, never to invalid present values.
|
|
37
|
+
*/
|
|
38
|
+
export interface CatalogQuery {
|
|
39
|
+
/** Free-text term (`q`). Trimmed, bounded, and empty treated as absent. */
|
|
40
|
+
text?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Category scope supplied by the route path (`/categories/[[...slug]]`). The route
|
|
43
|
+
* scope is always retained, even when both optional features are removed.
|
|
44
|
+
*/
|
|
45
|
+
categoryScope?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Category handles requested by the `category-filters` feature. The effective
|
|
48
|
+
* scope is `categoryScope ∩ categories`; an empty intersection is a valid
|
|
49
|
+
* zero-result query, never an invalid-query error.
|
|
50
|
+
*/
|
|
51
|
+
categories?: string[];
|
|
52
|
+
/** Collection handles requested by the `category-filters` feature. */
|
|
53
|
+
collections?: string[];
|
|
54
|
+
/** Canonical sort key; defaults are resolved at the URL boundary, not here. */
|
|
55
|
+
sort?: CatalogSortKey;
|
|
56
|
+
/** 1-based page; bounds are enforced at the URL boundary. */
|
|
57
|
+
page?: number;
|
|
58
|
+
/** Page size; bounds are enforced at the URL boundary. */
|
|
59
|
+
pageSize?: number;
|
|
60
|
+
/** Minimum price in major units; honored only when the price facet is demonstrated. */
|
|
61
|
+
priceMin?: number;
|
|
62
|
+
/** Maximum price in major units; honored only when the price facet is demonstrated. */
|
|
63
|
+
priceMax?: number;
|
|
64
|
+
/** In-stock only; honored only when demonstrated, otherwise a typed unsupported error. */
|
|
65
|
+
inStock?: boolean;
|
|
66
|
+
/** Requested attribute filters keyed by attribute name (`attr.<name>`). */
|
|
67
|
+
attributes?: Record<string, string[]>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Filters the backend actually applied to a successful result.
|
|
72
|
+
*
|
|
73
|
+
* A result is reported as success only when every requested filter appears here.
|
|
74
|
+
*/
|
|
75
|
+
export interface CatalogAppliedFilters {
|
|
76
|
+
/** Text term applied within the current scope. */
|
|
77
|
+
text?: string;
|
|
78
|
+
/** Category handles applied (the effective intersected scope). */
|
|
79
|
+
categories?: string[];
|
|
80
|
+
/** Collection handles applied. */
|
|
81
|
+
collections?: string[];
|
|
82
|
+
/** Minimum price applied. */
|
|
83
|
+
priceMin?: number;
|
|
84
|
+
/** Maximum price applied. */
|
|
85
|
+
priceMax?: number;
|
|
86
|
+
/** In-stock constraint applied. */
|
|
87
|
+
inStock?: boolean;
|
|
88
|
+
/** Attribute filters applied, keyed by attribute name. */
|
|
89
|
+
attributes?: Record<string, string[]>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Canonical filter identifiers used by the support descriptor.
|
|
94
|
+
*
|
|
95
|
+
* `attr.<name>` covers backend-advertised filterable attributes.
|
|
96
|
+
*/
|
|
97
|
+
export type CatalogFacetId =
|
|
98
|
+
| 'categories'
|
|
99
|
+
| 'collections'
|
|
100
|
+
| 'price'
|
|
101
|
+
| 'inStock'
|
|
102
|
+
| `attr.${string}`;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Real-endpoint demonstration source for an offered facet.
|
|
106
|
+
*
|
|
107
|
+
* Records the actual backend endpoint demonstrated with the applied query for the
|
|
108
|
+
* current scope, not a capability flag or returned facet metadata.
|
|
109
|
+
*/
|
|
110
|
+
export interface CatalogFacetDemonstrationSource {
|
|
111
|
+
/** Real backend endpoint demonstrated with the applied query (e.g. `/store/products`). */
|
|
112
|
+
endpoint: string;
|
|
113
|
+
/** The query and scope the endpoint was demonstrated with. */
|
|
114
|
+
appliedQuery?: CatalogQuery;
|
|
115
|
+
/** Store/scope the demonstration applies to. */
|
|
116
|
+
scope?: string;
|
|
117
|
+
/** ISO-8601 timestamp of when support was demonstrated. */
|
|
118
|
+
demonstratedAt?: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Truthful facet support descriptor: which filters the backend has demonstrated
|
|
123
|
+
* (offered) versus which are undemonstrated and held, plus the demonstration source
|
|
124
|
+
* for each offered filter.
|
|
125
|
+
*
|
|
126
|
+
* Contains no counts or ranges. Facet option counts and numeric ranges come only from
|
|
127
|
+
* backend data returned for the current query and are never synthesized here.
|
|
128
|
+
*/
|
|
129
|
+
export interface FacetSupport {
|
|
130
|
+
/** Filters demonstrated against the real endpoint for the current scope. */
|
|
131
|
+
offered: CatalogFacetId[];
|
|
132
|
+
/** Filters not demonstrated; held and diagnosed, never silently offered. */
|
|
133
|
+
held: CatalogFacetId[];
|
|
134
|
+
/** Real-endpoint demonstration source per offered filter, keyed by filter id. */
|
|
135
|
+
demonstrations?: Record<string, CatalogFacetDemonstrationSource>;
|
|
136
|
+
/** Diagnostic reason per held filter, keyed by filter id. */
|
|
137
|
+
heldReasons?: Record<string, string>;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Truthful catalog result for a fully applied query.
|
|
142
|
+
*
|
|
143
|
+
* When any requested filter cannot be applied, the query MUST return a typed
|
|
144
|
+
* unsupported-query error (defined in `@thorprovider/runtime/contracts`) instead of
|
|
145
|
+
* this shape; a partial result is never labelled success. `total` is present only
|
|
146
|
+
* when the backend supplies it and is never manufactured.
|
|
147
|
+
*/
|
|
148
|
+
export interface CatalogResults {
|
|
149
|
+
/** Matching products for the requested scope, sort, and page. */
|
|
150
|
+
products: Product[];
|
|
151
|
+
/** Total matches supplied by the backend; absent when the backend returns none. */
|
|
152
|
+
total?: number;
|
|
153
|
+
/** Filters the backend actually applied. */
|
|
154
|
+
appliedFilters: CatalogAppliedFilters;
|
|
155
|
+
/** Facet support descriptor for the query and scope. */
|
|
156
|
+
facetSupport?: FacetSupport;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Adapter-seam typed failure code for a canonical catalog query.
|
|
161
|
+
*
|
|
162
|
+
* `unsupported-query` is the code an adapter returns when a requested filter
|
|
163
|
+
* cannot be applied to the backend. `invalid-query` and `unmounted-capability`
|
|
164
|
+
* are produced by the URL boundary (`@thorprovider/runtime/contracts`); the
|
|
165
|
+
* adapter seam mirrors them so the runtime bridge can surface either shape
|
|
166
|
+
* without a translation layer.
|
|
167
|
+
*/
|
|
168
|
+
export type CatalogQueryFailureCode =
|
|
169
|
+
| 'invalid-query'
|
|
170
|
+
| 'unsupported-query'
|
|
171
|
+
| 'unmounted-capability';
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Compact, structured repair metadata: the raw parameter names a host must drop
|
|
175
|
+
* to reach a valid query. Structurally identical to the URL boundary's repair.
|
|
176
|
+
*/
|
|
177
|
+
export interface CatalogQueryFailureRepair {
|
|
178
|
+
/** Raw URL parameter names to remove (exactly the offending fields). */
|
|
179
|
+
remove: string[];
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Typed catalog-query failure returned across the adapter seam.
|
|
184
|
+
*
|
|
185
|
+
* Structurally identical to `CatalogQueryError` in
|
|
186
|
+
* `@thorprovider/runtime/contracts`, so the two are mutually assignable and the
|
|
187
|
+
* runtime bridge can pass one through as the other. `fields` names the
|
|
188
|
+
* offending raw parameters; `feature` is present only for
|
|
189
|
+
* `unmounted-capability`.
|
|
190
|
+
*/
|
|
191
|
+
export interface CatalogQueryFailure {
|
|
192
|
+
code: CatalogQueryFailureCode;
|
|
193
|
+
fields: string[];
|
|
194
|
+
message: string;
|
|
195
|
+
repair: CatalogQueryFailureRepair;
|
|
196
|
+
feature?: 'catalog-search' | 'category-filters';
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Discriminated outcome of a canonical catalog query against a provider.
|
|
201
|
+
*
|
|
202
|
+
* A provider returns `{ ok: true, results }` **only** when every requested
|
|
203
|
+
* filter was applied. When any requested filter cannot be applied it returns
|
|
204
|
+
* `{ ok: false, error }` with `code: 'unsupported-query'` naming the
|
|
205
|
+
* unappliable fields; a partial result is never returned as success and a
|
|
206
|
+
* requested filter is never silently dropped.
|
|
207
|
+
*/
|
|
208
|
+
export type CatalogQueryOutcome =
|
|
209
|
+
| { ok: true; results: CatalogResults }
|
|
210
|
+
| { ok: false; error: CatalogQueryFailure };
|
package/src/collection.ts
CHANGED
|
@@ -26,6 +26,16 @@ export interface GetCollectionsOptions {
|
|
|
26
26
|
limit?: number;
|
|
27
27
|
/** Search query to filter collections by title */
|
|
28
28
|
query?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Scope results to a specific sales channel / storefront channel.
|
|
31
|
+
* When provided, only collections that contain at least one product available
|
|
32
|
+
* in the given channel will be returned.
|
|
33
|
+
*
|
|
34
|
+
* Maps to: Medusa `sales_channel_id`, Shopify Sales Channel, etc.
|
|
35
|
+
* Adapters that support native server-side filtering should prefer it;
|
|
36
|
+
* others may fall back to a client-side post-filter pass.
|
|
37
|
+
*/
|
|
38
|
+
salesChannelId?: string;
|
|
29
39
|
}
|
|
30
40
|
|
|
31
41
|
/**
|
package/src/commerce-provider.ts
CHANGED
|
@@ -32,7 +32,12 @@ import type {
|
|
|
32
32
|
GetCategoriesOptions
|
|
33
33
|
} from './category';
|
|
34
34
|
import type { Customer, Address, GetCustomersOptions } from './customer';
|
|
35
|
-
import type {
|
|
35
|
+
import type {
|
|
36
|
+
Order,
|
|
37
|
+
GetOrdersOptions,
|
|
38
|
+
GetCustomerOrdersPageOptions,
|
|
39
|
+
CustomerOrdersPage,
|
|
40
|
+
} from './order';
|
|
36
41
|
import type { Region } from './region';
|
|
37
42
|
import type { PaymentMethod, PaymentMethodsOptions } from './payment';
|
|
38
43
|
import type { AuthProvider } from './auth';
|
|
@@ -40,6 +45,7 @@ import type { StorefrontContext } from './storefront';
|
|
|
40
45
|
import type { StockLocation, InventoryLevel, StockValidation, FulfillmentOption } from './stock-location';
|
|
41
46
|
import type { StorefrontConfig } from './storefront-config';
|
|
42
47
|
import type { DesignerConfig, DesignerHistoryEntry } from './designer-config';
|
|
48
|
+
import type { CatalogQuery, CatalogQueryOutcome, CatalogSortKey } from './catalog';
|
|
43
49
|
|
|
44
50
|
/**
|
|
45
51
|
* Backend capabilities interface
|
|
@@ -213,6 +219,22 @@ export interface CommerceProvider {
|
|
|
213
219
|
*/
|
|
214
220
|
readonly capabilities: BackendCapabilities;
|
|
215
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Canonical catalog sort keys this provider can actually apply at the query
|
|
224
|
+
* level (E2 `storefront-catalog-search-filters`, design Decision 6).
|
|
225
|
+
*
|
|
226
|
+
* Advertises only backend-verified orderings — for Medusa, `featured`
|
|
227
|
+
* (server default), `name` (translated to `title`), and `newest` (translated
|
|
228
|
+
* to `-created_at`). A global price or rating sort is never advertised. The
|
|
229
|
+
* runtime query boundary consumes this set as `supportedSortKeys` and turns a
|
|
230
|
+
* requested sort outside it into a typed unsupported-query error, so the
|
|
231
|
+
* listing never offers an ordering the backend cannot perform.
|
|
232
|
+
*
|
|
233
|
+
* Optional and additive: when absent, no ordering beyond the canonical default
|
|
234
|
+
* is assumed from the advertisement.
|
|
235
|
+
*/
|
|
236
|
+
readonly supportedCatalogSortKeys?: readonly CatalogSortKey[];
|
|
237
|
+
|
|
216
238
|
/**
|
|
217
239
|
* Whether this provider is backed by fixture/mock data instead of a live backend.
|
|
218
240
|
*
|
|
@@ -247,6 +269,25 @@ export interface CommerceProvider {
|
|
|
247
269
|
* for layout/design workflows until a real backend is configured.
|
|
248
270
|
*/
|
|
249
271
|
getProducts(options?: GetProductsOptions): Promise<Product[]>;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Run a canonical, validated catalog query against the real listing endpoint
|
|
275
|
+
* (OPTIONAL — E2 `storefront-catalog-search-filters`, task 2.2).
|
|
276
|
+
*
|
|
277
|
+
* The adapter translates the canonical `CatalogQuery` (text, the route
|
|
278
|
+
* category scope plus `categories`/`collections`, sort, pagination, and
|
|
279
|
+
* requested filters) into its backend's parameters and returns a truthful
|
|
280
|
+
* `CatalogQueryOutcome`: `{ ok: true, results }` only when **every** requested
|
|
281
|
+
* filter was applied, or `{ ok: false, error }` with `code:
|
|
282
|
+
* 'unsupported-query'` naming the fields it cannot apply. It never returns a
|
|
283
|
+
* partial result labelled success and never silently drops a requested filter.
|
|
284
|
+
*
|
|
285
|
+
* Optional and additive: providers that cannot forward a canonical query omit
|
|
286
|
+
* it and callers fall back to `getProducts`/`getCategoryProducts`. The legacy
|
|
287
|
+
* zero-argument and options-based methods keep their `Product[]` return and
|
|
288
|
+
* are unchanged. This is the typed seam the runtime catalog bridge consumes.
|
|
289
|
+
*/
|
|
290
|
+
getCatalogProducts?(query: CatalogQuery): Promise<CatalogQueryOutcome>;
|
|
250
291
|
|
|
251
292
|
/**
|
|
252
293
|
* Get product recommendations for a given product
|
|
@@ -826,6 +867,22 @@ export interface CommerceProvider {
|
|
|
826
867
|
* @returns Array of orders
|
|
827
868
|
*/
|
|
828
869
|
getOrders?(options: GetOrdersOptions): Promise<Order[]>;
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* Get the authenticated customer's order history as a paginated window
|
|
873
|
+
* (OPTIONAL, additive).
|
|
874
|
+
*
|
|
875
|
+
* Returns `{ orders, count, limit, offset }`, where `count` is the backend's
|
|
876
|
+
* real total for the authenticated customer and the store's sales channel,
|
|
877
|
+
* computed after the server-side customer+channel filter and before
|
|
878
|
+
* pagination. The legacy array-returning `getOrders` stays unchanged for
|
|
879
|
+
* existing callers.
|
|
880
|
+
*
|
|
881
|
+
* A provider that does not implement this method (for example the mock data
|
|
882
|
+
* source) fails closed at the runtime boundary rather than pretending an
|
|
883
|
+
* empty history.
|
|
884
|
+
*/
|
|
885
|
+
customerOrdersPage?(options: GetCustomerOrdersPageOptions): Promise<CustomerOrdersPage>;
|
|
829
886
|
|
|
830
887
|
// ============================================
|
|
831
888
|
// Payment Operations
|
package/src/commerce.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @thorprovider/types — Commerce contracts (type-only)
|
|
3
|
+
*
|
|
4
|
+
* Single-tenant, guest-only commerce shapes owned once by this module.
|
|
5
|
+
* Validation lives in `@thorprovider/runtime/contracts` (pure Zod); this
|
|
6
|
+
* module exports types only and emits no runtime values.
|
|
7
|
+
*
|
|
8
|
+
* Canonical product/variant/Money/cart/order shapes are NOT redefined here —
|
|
9
|
+
* they stay owned by `./common`, `./product`, `./cart` and `./order`.
|
|
10
|
+
*
|
|
11
|
+
* @module commerce
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { Money } from './common';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The validated single-store context — the multitenancy seam.
|
|
18
|
+
*
|
|
19
|
+
* Declares store identity, sales channel, region, and currency once and is
|
|
20
|
+
* validated at the boundary before any commerce call. Multitenancy is
|
|
21
|
+
* post-MVP; a future tenancy layer varies these values without redefining
|
|
22
|
+
* the commerce shapes.
|
|
23
|
+
*/
|
|
24
|
+
export interface StoreContext {
|
|
25
|
+
/** Stable store identity. */
|
|
26
|
+
storeId: string;
|
|
27
|
+
|
|
28
|
+
/** Sales channel the store is scoped to (Medusa `sales_channel_id`). */
|
|
29
|
+
salesChannelId: string;
|
|
30
|
+
|
|
31
|
+
/** Backend region that supplies currency, countries and shipping. */
|
|
32
|
+
regionId: string;
|
|
33
|
+
|
|
34
|
+
/** ISO 4217 currency code from the validated context — never hardcoded. */
|
|
35
|
+
currencyCode: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Issued guest shopper identity, scoped to a store.
|
|
40
|
+
*
|
|
41
|
+
* Backed by a cookie the Next host owns; it maps to a persisted backend guest
|
|
42
|
+
* cart so a reload reattaches to the same cart and two shoppers stay isolated.
|
|
43
|
+
*/
|
|
44
|
+
export interface ShopperIdentity {
|
|
45
|
+
/** Opaque shopper identity issued by the host cookie. */
|
|
46
|
+
shopperId: string;
|
|
47
|
+
|
|
48
|
+
/** Store the identity is scoped to. */
|
|
49
|
+
storeId: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A persisted backend guest cart session bound to a shopper identity.
|
|
54
|
+
*/
|
|
55
|
+
export interface CartSession {
|
|
56
|
+
/** Backend cart identifier. */
|
|
57
|
+
cartId: string;
|
|
58
|
+
|
|
59
|
+
/** Owning shopper identity. */
|
|
60
|
+
shopperId: string;
|
|
61
|
+
|
|
62
|
+
/** Store the session is scoped to. */
|
|
63
|
+
storeId: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Safe, buyer/store-authorized order receipt projection.
|
|
68
|
+
*
|
|
69
|
+
* A minimal recoverable subset of the canonical `Order` (`./order`), used by
|
|
70
|
+
* the guest receipt protocol. Access is authorized for the buyer or the
|
|
71
|
+
* store; it is never granted by possession of a bare public order id.
|
|
72
|
+
*/
|
|
73
|
+
export interface OrderReceipt {
|
|
74
|
+
/** Backend order identifier. */
|
|
75
|
+
orderId: string;
|
|
76
|
+
|
|
77
|
+
/** Human-readable order number. */
|
|
78
|
+
orderNumber: string;
|
|
79
|
+
|
|
80
|
+
/** Buyer email the order was placed with. */
|
|
81
|
+
email: string;
|
|
82
|
+
|
|
83
|
+
/** Order total in major units. */
|
|
84
|
+
total: Money;
|
|
85
|
+
|
|
86
|
+
/** ISO 8601 creation timestamp. */
|
|
87
|
+
createdAt: string;
|
|
88
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -20,6 +20,16 @@ export type {
|
|
|
20
20
|
Country,
|
|
21
21
|
} from './common';
|
|
22
22
|
|
|
23
|
+
// ============================================
|
|
24
|
+
// Commerce Contracts (single-store context + guest shapes)
|
|
25
|
+
// ============================================
|
|
26
|
+
export type {
|
|
27
|
+
StoreContext,
|
|
28
|
+
ShopperIdentity,
|
|
29
|
+
CartSession,
|
|
30
|
+
OrderReceipt,
|
|
31
|
+
} from './commerce';
|
|
32
|
+
|
|
23
33
|
export type {
|
|
24
34
|
AuthorConfig,
|
|
25
35
|
BrandConfig,
|
|
@@ -43,6 +53,23 @@ export type {
|
|
|
43
53
|
QueryResponse,
|
|
44
54
|
} from './query';
|
|
45
55
|
|
|
56
|
+
// ============================================
|
|
57
|
+
// Catalog Query & Facet Support Types
|
|
58
|
+
// ============================================
|
|
59
|
+
export type {
|
|
60
|
+
CatalogSortKey,
|
|
61
|
+
CatalogQuery,
|
|
62
|
+
CatalogAppliedFilters,
|
|
63
|
+
CatalogFacetId,
|
|
64
|
+
CatalogFacetDemonstrationSource,
|
|
65
|
+
FacetSupport,
|
|
66
|
+
CatalogResults,
|
|
67
|
+
CatalogQueryFailureCode,
|
|
68
|
+
CatalogQueryFailureRepair,
|
|
69
|
+
CatalogQueryFailure,
|
|
70
|
+
CatalogQueryOutcome,
|
|
71
|
+
} from './catalog';
|
|
72
|
+
|
|
46
73
|
// ============================================
|
|
47
74
|
// Product Types
|
|
48
75
|
// ============================================
|
|
@@ -139,18 +166,15 @@ export type {
|
|
|
139
166
|
FulfillmentStatus,
|
|
140
167
|
GetOrdersOptions,
|
|
141
168
|
GetOrdersCallback,
|
|
169
|
+
GetCustomerOrdersPageOptions,
|
|
170
|
+
CustomerOrdersPage,
|
|
142
171
|
} from './order';
|
|
143
172
|
|
|
144
173
|
// ============================================
|
|
145
|
-
// Provider Types (L1 -
|
|
174
|
+
// Provider Types (L1 - type-only)
|
|
175
|
+
// Runtime provider registry lives in @thorprovider/adapters
|
|
146
176
|
// ============================================
|
|
147
|
-
export {
|
|
148
|
-
|
|
149
|
-
export {
|
|
150
|
-
isSupportedProviderType,
|
|
151
|
-
getProviderMetadata,
|
|
152
|
-
PROVIDER_METADATA,
|
|
153
|
-
} from './provider';
|
|
177
|
+
export type { ProviderTypeString } from './provider';
|
|
154
178
|
|
|
155
179
|
// ============================================
|
|
156
180
|
// Storefront Types
|
|
@@ -160,10 +184,6 @@ export type {
|
|
|
160
184
|
StorefrontPlatformType,
|
|
161
185
|
} from './storefront';
|
|
162
186
|
|
|
163
|
-
export {
|
|
164
|
-
StorefrontConfigError,
|
|
165
|
-
} from './storefront';
|
|
166
|
-
|
|
167
187
|
// ============================================
|
|
168
188
|
// Storefront Configuration Types
|
|
169
189
|
// ============================================
|
|
@@ -332,8 +352,6 @@ export type {
|
|
|
332
352
|
SetPaymentCollectorResponse,
|
|
333
353
|
SetPaymentMethodBody,
|
|
334
354
|
SetPaymentMethodResponse,
|
|
335
|
-
ValidateGiftCardBody,
|
|
336
|
-
ValidateGiftCardResponse,
|
|
337
355
|
DropshipperCategory,
|
|
338
356
|
GetDropshipperCategoriesOptions,
|
|
339
357
|
GetDropshipperCategoriesResponse,
|
|
@@ -423,10 +441,6 @@ export type {
|
|
|
423
441
|
ConvertDropshipperDraftOrderBody,
|
|
424
442
|
ConvertDropshipperDraftOrderResponse,
|
|
425
443
|
DeleteDropshipperDraftOrderResponse,
|
|
426
|
-
// Order totals preview
|
|
427
|
-
PreviewDropshipperOrderItem,
|
|
428
|
-
PreviewDropshipperOrderTotalsBody,
|
|
429
|
-
PreviewDropshipperOrderTotalsResponse,
|
|
430
444
|
// Dropshipper addresses (channel-scoped)
|
|
431
445
|
DropshipperAddressBody,
|
|
432
446
|
DropshipperAddressResponse,
|
package/src/order.ts
CHANGED
|
@@ -186,3 +186,36 @@ export interface GetOrdersOptions {
|
|
|
186
186
|
*/
|
|
187
187
|
customFetcher?: GetOrdersCallback;
|
|
188
188
|
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Options for the additive paginated order-history contract.
|
|
192
|
+
*
|
|
193
|
+
* Unlike {@link GetOrdersOptions}, this carries an explicit 1-based `page` and
|
|
194
|
+
* `pageSize` so a caller can request a bounded window of the authenticated
|
|
195
|
+
* customer's channel-scoped history. `salesChannelId` is the store's configured
|
|
196
|
+
* channel and is validated against the backend's channel scoping; a provider
|
|
197
|
+
* MUST NOT fall back to a blind first channel id when it is absent.
|
|
198
|
+
*/
|
|
199
|
+
export interface GetCustomerOrdersPageOptions {
|
|
200
|
+
/** 1-based page number (default 1). */
|
|
201
|
+
page?: number;
|
|
202
|
+
/** Rows per page (default 10, bounded by the provider's canonical limit). */
|
|
203
|
+
pageSize?: number;
|
|
204
|
+
/** The store's configured sales channel id (explicit; never a blind first id). */
|
|
205
|
+
salesChannelId?: string;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* The additive paginated order-history result.
|
|
210
|
+
*
|
|
211
|
+
* `count` is the backend's real total for the authenticated customer and the
|
|
212
|
+
* store's sales channel, computed after the server-side customer+channel filter
|
|
213
|
+
* and before pagination — never a page length or a `limit`-floored estimate.
|
|
214
|
+
* `limit`/`offset` echo the backend's applied window.
|
|
215
|
+
*/
|
|
216
|
+
export interface CustomerOrdersPage {
|
|
217
|
+
orders: Order[];
|
|
218
|
+
count: number;
|
|
219
|
+
limit: number;
|
|
220
|
+
offset: number;
|
|
221
|
+
}
|
package/src/product.ts
CHANGED
|
@@ -92,6 +92,7 @@ export interface Product {
|
|
|
92
92
|
|
|
93
93
|
// Organization (optional, platform-dependent)
|
|
94
94
|
collections?: Array<{ id: string; title: string; handle: string }>; // Shopify/Medusa: collections, WooCommerce/Magento: categories
|
|
95
|
+
categories?: Array<{ id: string; name: string; handle: string; parentCategoryId?: string }>; // Product's category references (Medusa: categories; carries hierarchy for breadcrumbs)
|
|
95
96
|
productType?: string; // Shopify: productType, Medusa: type, WooCommerce: type (simple/variable)
|
|
96
97
|
vendor?: string; // Shopify-specific, stored in metadata for others
|
|
97
98
|
tags?: string[];
|