@commerce-blocks/sdk 2.0.0-alpha.2 → 2.0.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/README.md +310 -850
- package/dist/index.d.ts +345 -581
- package/dist/index.js +1343 -2004
- package/package.json +2 -7
package/dist/index.d.ts
CHANGED
|
@@ -7,39 +7,46 @@ import { signal } from '@preact/signals-core';
|
|
|
7
7
|
|
|
8
8
|
export declare function and(...expressions: (FilterExpression | FilterGroup)[]): FilterGroup;
|
|
9
9
|
|
|
10
|
+
declare interface ApiClientConfig extends ApiFetchConfig {
|
|
11
|
+
sorts: Sort[];
|
|
12
|
+
facets: Facet[];
|
|
13
|
+
attributes?: string[];
|
|
14
|
+
}
|
|
15
|
+
|
|
10
16
|
export declare interface ApiError {
|
|
11
17
|
readonly _tag: 'ApiError';
|
|
12
18
|
readonly code: ApiErrorCode;
|
|
13
19
|
readonly source: ApiSource;
|
|
14
20
|
readonly message: string;
|
|
15
|
-
readonly timestamp: string;
|
|
16
21
|
readonly status?: number;
|
|
17
|
-
readonly retryable: boolean;
|
|
18
22
|
readonly retryAfterMs?: number;
|
|
19
|
-
readonly request?: RequestContext;
|
|
20
|
-
readonly response?: ResponseContext;
|
|
21
23
|
readonly cause?: unknown;
|
|
22
|
-
readonly details?: {
|
|
23
|
-
readonly graphqlErrors?: GraphQLErrorDetail[];
|
|
24
|
-
readonly requestId?: string;
|
|
25
|
-
readonly shop?: string;
|
|
26
|
-
};
|
|
27
24
|
}
|
|
28
25
|
|
|
29
|
-
declare type ApiErrorCode = 'UNAUTHORIZED' | 'FORBIDDEN' | 'NOT_FOUND' | 'NOT_READY' | 'RATE_LIMITED' | 'SERVICE_UNAVAILABLE' | '
|
|
26
|
+
declare type ApiErrorCode = 'UNAUTHORIZED' | 'FORBIDDEN' | 'NOT_FOUND' | 'NOT_READY' | 'RATE_LIMITED' | 'SERVICE_UNAVAILABLE' | 'PARSE_ERROR' | 'UNKNOWN';
|
|
30
27
|
|
|
31
|
-
declare
|
|
28
|
+
declare interface ApiFetchConfig {
|
|
29
|
+
token: string;
|
|
30
|
+
baseUrl?: string;
|
|
31
|
+
fetch?: CustomFetch;
|
|
32
|
+
}
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
declare type ApiSource = 'layers';
|
|
35
|
+
|
|
36
|
+
export declare interface Article {
|
|
37
|
+
title: string;
|
|
38
|
+
handle: string;
|
|
39
|
+
summary: string;
|
|
40
|
+
author: string;
|
|
41
|
+
tags: string[];
|
|
42
|
+
image: ArticleImage | null;
|
|
43
|
+
publishedAt: string;
|
|
38
44
|
}
|
|
39
45
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
declare interface ArticleImage {
|
|
47
|
+
url: string;
|
|
48
|
+
width: number;
|
|
49
|
+
height: number;
|
|
43
50
|
}
|
|
44
51
|
|
|
45
52
|
export { batch }
|
|
@@ -58,16 +65,7 @@ declare interface BlocksContext {
|
|
|
58
65
|
custom?: Record<string, unknown>;
|
|
59
66
|
}
|
|
60
67
|
|
|
61
|
-
export declare
|
|
62
|
-
readonly state: ReadonlySignal<QueryState<BlocksResult<P>>>;
|
|
63
|
-
execute(query?: BlocksQuery): Promise<Result<BlocksResult<P>, SdkError>>;
|
|
64
|
-
subscribe(callback: (state: QueryState<BlocksResult<P>>) => void): Unsubscribe;
|
|
65
|
-
dispose(): void;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export declare type BlocksExtender<P extends Product = Product> = (result: BlocksResult<P>, raw: LayersResponse & {
|
|
69
|
-
block?: BlocksInfo;
|
|
70
|
-
}) => BlocksResult<P>;
|
|
68
|
+
export declare type BlocksController = Controller<BlocksResult, BlocksQuery>;
|
|
71
69
|
|
|
72
70
|
declare interface BlocksInfo {
|
|
73
71
|
id: string;
|
|
@@ -80,73 +78,92 @@ declare interface BlocksInfo {
|
|
|
80
78
|
|
|
81
79
|
export declare interface BlocksOptions {
|
|
82
80
|
blockId: string;
|
|
83
|
-
|
|
81
|
+
anchor?: string;
|
|
84
82
|
}
|
|
85
83
|
|
|
86
84
|
export declare interface BlocksQuery extends QueryParams {
|
|
87
|
-
|
|
85
|
+
discounts?: DiscountEntitlement[];
|
|
88
86
|
context?: BlocksContext;
|
|
89
87
|
}
|
|
90
88
|
|
|
91
|
-
export declare interface BlocksResult
|
|
89
|
+
export declare interface BlocksResult extends QueryResult {
|
|
92
90
|
block?: BlocksInfo;
|
|
93
91
|
}
|
|
94
92
|
|
|
95
|
-
|
|
93
|
+
declare interface Cache_2 {
|
|
94
|
+
get(key: string): CacheEntry<CacheValue> | null;
|
|
95
|
+
set(key: string, result: CacheValue): void;
|
|
96
|
+
isExpired(key: string): boolean;
|
|
97
|
+
invalidate(pattern: string): void;
|
|
98
|
+
persist(): void;
|
|
99
|
+
restore(): void;
|
|
100
|
+
clear(): void;
|
|
101
|
+
readonly stats: {
|
|
102
|
+
entries: number;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
declare type CacheData = Record<string, CacheValue>;
|
|
96
107
|
|
|
97
108
|
declare interface CacheEntry<T> {
|
|
98
109
|
data: T;
|
|
99
110
|
timestamp: number;
|
|
100
111
|
}
|
|
101
112
|
|
|
102
|
-
export declare interface
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
113
|
+
export declare interface CacheOptions {
|
|
114
|
+
ttl?: number;
|
|
115
|
+
maxEntries?: number;
|
|
116
|
+
storageKey?: string;
|
|
117
|
+
/** Custom storage adapter. Defaults to localStorage in browser. */
|
|
118
|
+
storageAdapter?: StorageAdapter;
|
|
107
119
|
}
|
|
108
120
|
|
|
109
|
-
|
|
121
|
+
declare type CacheValue = QueryResult | ContentResult;
|
|
110
122
|
|
|
111
|
-
declare interface
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
export declare interface Client {
|
|
124
|
+
collection: (options: CollectionOptions) => CollectionController;
|
|
125
|
+
blocks: (options: BlocksOptions) => BlocksController;
|
|
126
|
+
suggest: (options?: SuggestOptions) => SuggestController;
|
|
127
|
+
search: (options?: SearchQuery) => SearchController;
|
|
128
|
+
uploadImage: (options: UploadImageOptions) => UploadImageController;
|
|
129
|
+
searchByImage: (options: SearchByImageQuery) => SearchByImageController;
|
|
130
|
+
searchContent: (options?: SearchContentQuery) => SearchContentController;
|
|
131
|
+
config: ClientConfig;
|
|
132
|
+
cache: Cache_2;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export declare interface ClientConfig extends ApiClientConfig {
|
|
136
|
+
includeMeta?: boolean;
|
|
137
|
+
currency?: string;
|
|
138
|
+
formatPrice?: FormatPriceFn;
|
|
139
|
+
swatches?: Swatch[];
|
|
140
|
+
cacheLimit?: number;
|
|
141
|
+
cacheLifetime?: number;
|
|
142
|
+
/** Custom storage adapter for cache persistence. Defaults to localStorage in browser. */
|
|
143
|
+
storage?: StorageAdapter;
|
|
144
|
+
transforms?: Transforms;
|
|
145
|
+
filterAliases?: FilterAliases;
|
|
146
|
+
/** Initial data to hydrate into the cache */
|
|
147
|
+
initialData?: CacheData;
|
|
148
|
+
/** Restore cache from storage on init (default: true) */
|
|
149
|
+
restoreCache?: boolean;
|
|
128
150
|
}
|
|
129
151
|
|
|
152
|
+
export declare type ClientError = ServiceError | ConfigError;
|
|
153
|
+
|
|
154
|
+
export declare type CollectionController = Controller<CollectionResult, CollectionQuery>;
|
|
155
|
+
|
|
130
156
|
export declare interface CollectionOptions {
|
|
131
157
|
handle: string;
|
|
132
158
|
defaultSort?: string;
|
|
133
159
|
}
|
|
134
160
|
|
|
135
161
|
export declare interface CollectionQuery extends QueryParams {
|
|
136
|
-
|
|
162
|
+
sort?: string;
|
|
137
163
|
includeMeta?: boolean;
|
|
138
|
-
collectionMetafields?: {
|
|
139
|
-
namespace: string;
|
|
140
|
-
key: string;
|
|
141
|
-
}[];
|
|
142
|
-
includeFilters?: boolean;
|
|
143
164
|
}
|
|
144
165
|
|
|
145
|
-
export declare
|
|
146
|
-
collection?: StorefrontCollection;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
declare type Collections = Record<string, Omit<CollectionMeta, 'handle'>>;
|
|
166
|
+
export declare type CollectionResult = QueryResult;
|
|
150
167
|
|
|
151
168
|
declare type CommerceBlocksID = `${CommerceBlocksType}-${OptionSegment}` | `${CommerceBlocksType}-${OptionSegment}-${OptionSegment}` | `${CommerceBlocksType}-${OptionSegment}-${OptionSegment}-${OptionSegment}`;
|
|
152
169
|
|
|
@@ -158,7 +175,6 @@ export declare interface ConfigError {
|
|
|
158
175
|
readonly _tag: 'ConfigError';
|
|
159
176
|
readonly code: ConfigErrorCode;
|
|
160
177
|
readonly message: string;
|
|
161
|
-
readonly timestamp: string;
|
|
162
178
|
readonly field: string;
|
|
163
179
|
readonly value?: unknown;
|
|
164
180
|
readonly expected?: string;
|
|
@@ -166,24 +182,53 @@ export declare interface ConfigError {
|
|
|
166
182
|
|
|
167
183
|
declare type ConfigErrorCode = 'MISSING_CONFIG' | 'INVALID_CONFIG';
|
|
168
184
|
|
|
185
|
+
declare interface ContentArticleRaw {
|
|
186
|
+
title: string;
|
|
187
|
+
handle: string;
|
|
188
|
+
summary_text: string;
|
|
189
|
+
author: string;
|
|
190
|
+
tags: string[];
|
|
191
|
+
image: {
|
|
192
|
+
url: string;
|
|
193
|
+
width: number;
|
|
194
|
+
height: number;
|
|
195
|
+
} | null;
|
|
196
|
+
published_at: string;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
declare interface ContentResult {
|
|
200
|
+
articles: unknown[];
|
|
201
|
+
query: string;
|
|
202
|
+
contentType: string | null;
|
|
203
|
+
totalResults: number;
|
|
204
|
+
page: number;
|
|
205
|
+
resultsPerPage: number;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
declare interface ContentSearchResponse {
|
|
209
|
+
results: ContentArticleRaw[];
|
|
210
|
+
query: string;
|
|
211
|
+
contentType: string | null;
|
|
212
|
+
totalResults: number;
|
|
213
|
+
totalPages: number;
|
|
214
|
+
page: number;
|
|
215
|
+
resultsPerPage: number;
|
|
216
|
+
}
|
|
217
|
+
|
|
169
218
|
export declare interface Controller<TData, TQuery = void> {
|
|
170
219
|
readonly state: ReadonlySignal<QueryState<TData>>;
|
|
171
|
-
execute(query
|
|
220
|
+
execute(query?: TQuery): Promise<Result<TData, ClientError>>;
|
|
172
221
|
subscribe(callback: (state: QueryState<TData>) => void): Unsubscribe;
|
|
173
222
|
dispose(): void;
|
|
174
223
|
}
|
|
175
224
|
|
|
176
|
-
export declare function
|
|
225
|
+
export declare function createClient(config: ClientConfig): Result<Client, ConfigError>;
|
|
177
226
|
|
|
178
|
-
export declare
|
|
179
|
-
product: Product | ExtendedProduct;
|
|
180
|
-
selectedOptions?: ProductOption[];
|
|
181
|
-
breakoutOptions?: ProductOption[];
|
|
182
|
-
}
|
|
227
|
+
export declare type CreateClientResult = Result<Client, ConfigError>;
|
|
183
228
|
|
|
184
|
-
export declare function
|
|
229
|
+
export declare function createProductCard({ product, selectedOptions: initialSelectedOptions, breakoutOptions: initialBreakoutOptions, }: ProductCardOptions): ProductCardController;
|
|
185
230
|
|
|
186
|
-
declare type CustomFetch = (url: string, init?: RequestInit) => Promise<Response>;
|
|
231
|
+
export declare type CustomFetch = (url: string, init?: RequestInit) => Promise<Response>;
|
|
187
232
|
|
|
188
233
|
declare interface DiscountEntitlement {
|
|
189
234
|
entitled: {
|
|
@@ -204,10 +249,6 @@ export declare function eq(property: string, value: FilterValue): FilterExpressi
|
|
|
204
249
|
|
|
205
250
|
export declare function exists(property: string): FilterExpression;
|
|
206
251
|
|
|
207
|
-
declare interface ExtendedProduct extends Product {
|
|
208
|
-
_base: Product;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
252
|
declare interface Facet {
|
|
212
253
|
name: string;
|
|
213
254
|
code: string;
|
|
@@ -222,13 +263,16 @@ declare interface FeaturedMedia {
|
|
|
222
263
|
}
|
|
223
264
|
|
|
224
265
|
declare interface FeaturedMedia_2 {
|
|
225
|
-
|
|
226
|
-
alt: string;
|
|
266
|
+
id: number;
|
|
227
267
|
src: string;
|
|
268
|
+
alt: string | null;
|
|
269
|
+
media_type: string;
|
|
228
270
|
width: number;
|
|
229
271
|
height: number;
|
|
230
272
|
}
|
|
231
273
|
|
|
274
|
+
export declare function fileStorage(filePath: string, fs: FileSystem_2): StorageAdapter;
|
|
275
|
+
|
|
232
276
|
declare interface FileSystem_2 {
|
|
233
277
|
readFileSync(path: string, encoding: 'utf-8'): string;
|
|
234
278
|
writeFileSync(path: string, data: string, encoding: 'utf-8'): void;
|
|
@@ -238,6 +282,13 @@ export { FileSystem_2 as FileSystem }
|
|
|
238
282
|
|
|
239
283
|
export declare function filter(expression: FilterExpression | FilterGroup): FilterGroup;
|
|
240
284
|
|
|
285
|
+
export declare type FilterAlias = string | {
|
|
286
|
+
property: string;
|
|
287
|
+
values?: Record<string, string>;
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
export declare type FilterAliases = Record<string, FilterAlias>;
|
|
291
|
+
|
|
241
292
|
declare enum FilterConditional {
|
|
242
293
|
And = "AND",
|
|
243
294
|
Or = "OR"
|
|
@@ -254,13 +305,6 @@ export declare interface FilterGroup {
|
|
|
254
305
|
expressions: (FilterExpression | FilterGroup)[];
|
|
255
306
|
}
|
|
256
307
|
|
|
257
|
-
export declare type FilterMap = Record<string, FilterMapEntry>;
|
|
258
|
-
|
|
259
|
-
export declare type FilterMapEntry = string | {
|
|
260
|
-
property: string;
|
|
261
|
-
values?: Record<string, string>;
|
|
262
|
-
};
|
|
263
|
-
|
|
264
308
|
declare enum FilterOperator {
|
|
265
309
|
Equal = "eq",
|
|
266
310
|
NotEqual = "not_eq",
|
|
@@ -274,58 +318,16 @@ declare enum FilterOperator {
|
|
|
274
318
|
NotExists = "not_exists"
|
|
275
319
|
}
|
|
276
320
|
|
|
277
|
-
declare interface FilterResult {
|
|
278
|
-
id: string;
|
|
279
|
-
label: string;
|
|
280
|
-
type: 'LIST' | 'PRICE_RANGE' | 'BOOLEAN';
|
|
281
|
-
values: FilterValueResult[];
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
export declare type FilterTransformer = (filters: unknown) => FilterGroup | undefined;
|
|
285
|
-
|
|
286
321
|
declare type FilterValue = string | number | boolean;
|
|
287
322
|
|
|
288
|
-
declare
|
|
289
|
-
id: string;
|
|
290
|
-
label: string;
|
|
291
|
-
count: number;
|
|
292
|
-
input: string;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
export declare interface FireAndForgetController<TData, TQuery = void> {
|
|
296
|
-
readonly state: ReadonlySignal<QueryState<TData>>;
|
|
297
|
-
execute(query: TQuery): void;
|
|
298
|
-
subscribe(callback: (state: QueryState<TData>) => void): Unsubscribe;
|
|
299
|
-
dispose(): void;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
export declare function getSdk(): Result<Sdk, ConfigError>;
|
|
323
|
+
declare type FormatPriceFn = (amount: number, currencyCode: string) => string;
|
|
303
324
|
|
|
304
|
-
declare
|
|
305
|
-
readonly message: string;
|
|
306
|
-
readonly locations?: {
|
|
307
|
-
line: number;
|
|
308
|
-
column: number;
|
|
309
|
-
}[];
|
|
310
|
-
readonly path?: (string | number)[];
|
|
311
|
-
readonly extensions?: Record<string, unknown>;
|
|
312
|
-
}
|
|
325
|
+
export declare function getClient(): Result<Client, ConfigError>;
|
|
313
326
|
|
|
314
327
|
export declare function gt(property: string, value: number): FilterExpression;
|
|
315
328
|
|
|
316
329
|
export declare function gte(property: string, value: number): FilterExpression;
|
|
317
330
|
|
|
318
|
-
/**
|
|
319
|
-
* Minimal SDK Error Types
|
|
320
|
-
*
|
|
321
|
-
* 4 error types cover all scenarios:
|
|
322
|
-
* - NetworkError: Connection failed before response
|
|
323
|
-
* - ApiError: API returned an error response
|
|
324
|
-
* - ValidationError: Pre-request validation failed
|
|
325
|
-
* - ConfigError: SDK misconfigured
|
|
326
|
-
*/
|
|
327
|
-
declare type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
328
|
-
|
|
329
331
|
declare interface Image_2 {
|
|
330
332
|
url: string;
|
|
331
333
|
alt: string;
|
|
@@ -336,36 +338,16 @@ declare interface Image_2 {
|
|
|
336
338
|
}
|
|
337
339
|
export { Image_2 as Image }
|
|
338
340
|
|
|
339
|
-
declare interface ImageResult {
|
|
340
|
-
url: string;
|
|
341
|
-
altText: string | null;
|
|
342
|
-
width: number;
|
|
343
|
-
height: number;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
export declare interface ImageSearchQuery extends QueryParams {
|
|
347
|
-
imageId: string;
|
|
348
|
-
tuning?: LayersTuning;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
341
|
export declare function inValues(property: string, values: FilterValue[]): FilterExpression;
|
|
352
342
|
|
|
353
343
|
/** Map of location ID to available quantity */
|
|
354
344
|
declare type InventoryLevels = Record<string, number>;
|
|
355
345
|
|
|
356
|
-
export declare function
|
|
346
|
+
export declare function isClientError(error: unknown): error is ClientError;
|
|
357
347
|
|
|
358
|
-
export declare function
|
|
359
|
-
|
|
360
|
-
export declare function isSdkError(error: unknown): error is SdkError;
|
|
348
|
+
export declare function isInitialized(): boolean;
|
|
361
349
|
|
|
362
|
-
export declare function
|
|
363
|
-
|
|
364
|
-
declare interface LayersClientConfig extends LayersFetchConfig {
|
|
365
|
-
sorts: Sort[];
|
|
366
|
-
facets: Facet[];
|
|
367
|
-
attributes?: string[];
|
|
368
|
-
}
|
|
350
|
+
export declare function isRetryable(error: ClientError): boolean;
|
|
369
351
|
|
|
370
352
|
declare interface LayersFacets {
|
|
371
353
|
facets?: Record<string, Record<string, number>>;
|
|
@@ -375,12 +357,6 @@ declare interface LayersFacets {
|
|
|
375
357
|
}>;
|
|
376
358
|
}
|
|
377
359
|
|
|
378
|
-
declare interface LayersFetchConfig {
|
|
379
|
-
layersPublicToken: string;
|
|
380
|
-
layersBaseUrl?: string;
|
|
381
|
-
fetch?: CustomFetch;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
360
|
declare interface LayersMeta {
|
|
385
361
|
experimentsRan?: {
|
|
386
362
|
id: string;
|
|
@@ -418,36 +394,20 @@ declare interface LayersResponse extends LayersPagination, LayersFacets {
|
|
|
418
394
|
|
|
419
395
|
declare type LayersResult = ProductResult | VariantResult;
|
|
420
396
|
|
|
421
|
-
declare interface LayersTuning {
|
|
422
|
-
textualWeight?: number;
|
|
423
|
-
visualWeight?: number;
|
|
424
|
-
multipleFactor?: number;
|
|
425
|
-
minimumMatch?: number;
|
|
426
|
-
missingEmbeddingScore?: number;
|
|
427
|
-
highSignalWeight?: number;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
397
|
declare interface LayersVariant {
|
|
431
398
|
id: number;
|
|
432
399
|
title: string;
|
|
433
|
-
available: boolean;
|
|
434
|
-
sku: string;
|
|
435
400
|
price: string;
|
|
436
|
-
|
|
437
|
-
selected_options: {
|
|
438
|
-
name: string;
|
|
439
|
-
value: string;
|
|
440
|
-
optionValue?: {
|
|
441
|
-
swatch?: unknown | null;
|
|
442
|
-
linkedMetafieldValue?: unknown | null;
|
|
443
|
-
};
|
|
444
|
-
}[];
|
|
401
|
+
sku: string | null;
|
|
445
402
|
position: number;
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
403
|
+
compare_at_price: string | null;
|
|
404
|
+
selected_options: SelectedOption[];
|
|
405
|
+
created_at: string;
|
|
406
|
+
updated_at: string;
|
|
407
|
+
available: boolean;
|
|
408
|
+
featured_media: FeaturedMedia_2 | null;
|
|
409
|
+
requires_selling_plan: boolean | null;
|
|
410
|
+
has_selling_plan: boolean | null;
|
|
451
411
|
inventory_levels?: InventoryLevels;
|
|
452
412
|
in_stock_location_ids?: number[];
|
|
453
413
|
}
|
|
@@ -466,41 +426,11 @@ declare interface MatchedVariant extends LayersVariant {
|
|
|
466
426
|
rn?: number;
|
|
467
427
|
}
|
|
468
428
|
|
|
469
|
-
export declare interface Metafield extends MetafieldIdentifier {
|
|
470
|
-
value: string;
|
|
471
|
-
type: string;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
declare interface MetafieldIdentifier {
|
|
475
|
-
namespace: string;
|
|
476
|
-
key: string;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
declare interface MetafieldResult {
|
|
480
|
-
namespace: string;
|
|
481
|
-
key: string;
|
|
482
|
-
value: string;
|
|
483
|
-
type: string;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
declare interface MoneyResult {
|
|
487
|
-
amount: string;
|
|
488
|
-
currencyCode: string;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
declare interface NamedTag {
|
|
492
|
-
name: string;
|
|
493
|
-
value: string | number | boolean | string[];
|
|
494
|
-
}
|
|
495
|
-
|
|
496
429
|
export declare interface NetworkError {
|
|
497
430
|
readonly _tag: 'NetworkError';
|
|
498
431
|
readonly code: NetworkErrorCode;
|
|
499
432
|
readonly message: string;
|
|
500
|
-
readonly timestamp: string;
|
|
501
|
-
readonly retryable: boolean;
|
|
502
433
|
readonly retryAfterMs?: number;
|
|
503
|
-
readonly request?: RequestContext;
|
|
504
434
|
readonly cause?: unknown;
|
|
505
435
|
}
|
|
506
436
|
|
|
@@ -512,10 +442,15 @@ export declare function notExists(property: string): FilterExpression;
|
|
|
512
442
|
|
|
513
443
|
export declare function notIn(property: string, values: FilterValue[]): FilterExpression;
|
|
514
444
|
|
|
515
|
-
declare
|
|
445
|
+
export declare interface OptionGroup {
|
|
446
|
+
name: string;
|
|
447
|
+
values: OptionValue[];
|
|
448
|
+
}
|
|
516
449
|
|
|
517
450
|
declare type OptionSegment = `${string}:${string}`;
|
|
518
451
|
|
|
452
|
+
export declare type OptionStatus = 'available' | 'backorderable' | 'sold-out' | 'unavailable';
|
|
453
|
+
|
|
519
454
|
declare interface OptionV2 {
|
|
520
455
|
name: string;
|
|
521
456
|
code: string;
|
|
@@ -524,127 +459,109 @@ declare interface OptionV2 {
|
|
|
524
459
|
swatch: {
|
|
525
460
|
color: string | null;
|
|
526
461
|
image: {
|
|
527
|
-
alt: string;
|
|
528
|
-
url: string;
|
|
462
|
+
alt: string | null;
|
|
463
|
+
url: string | null;
|
|
529
464
|
} | null;
|
|
530
465
|
} | null;
|
|
531
|
-
linked_metafield_value: unknown
|
|
466
|
+
linked_metafield_value: unknown;
|
|
532
467
|
}[];
|
|
533
468
|
}
|
|
534
469
|
|
|
535
|
-
declare interface
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
470
|
+
export declare interface OptionValue {
|
|
471
|
+
value: string;
|
|
472
|
+
status: OptionStatus;
|
|
473
|
+
selected: boolean;
|
|
474
|
+
swatch: Swatch | null;
|
|
539
475
|
}
|
|
540
476
|
|
|
541
477
|
export declare function or(...expressions: (FilterExpression | FilterGroup)[]): FilterGroup;
|
|
542
478
|
|
|
543
|
-
declare interface PageMeta {
|
|
544
|
-
handle: string;
|
|
545
|
-
title?: string;
|
|
546
|
-
body?: string;
|
|
547
|
-
bodySummary?: string;
|
|
548
|
-
lastFetched: number;
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
export declare type ParamDefinition = (key: string) => unknown | undefined | null;
|
|
552
|
-
|
|
553
|
-
export declare type ParamDefinitions = Record<string, ParamDefinition>;
|
|
554
|
-
|
|
555
|
-
declare interface PredictiveSearchResponse {
|
|
556
|
-
matchedQueries: {
|
|
557
|
-
query_text: string;
|
|
558
|
-
num_searches: number;
|
|
559
|
-
}[];
|
|
560
|
-
originalQuery: string;
|
|
561
|
-
normalizedQuery: string;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
export declare interface PreparableController<TData, TQuery, TPrepareResult> extends Controller<TData, TQuery> {
|
|
565
|
-
prepare(query: TQuery): Promise<Result<TPrepareResult, SdkError>>;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
export declare interface PrepareSearchResult {
|
|
569
|
-
searchId: string;
|
|
570
|
-
}
|
|
571
|
-
|
|
572
479
|
export declare interface Price {
|
|
573
480
|
amount: number;
|
|
574
481
|
currencyCode: string;
|
|
575
482
|
formatted: string;
|
|
576
483
|
}
|
|
577
484
|
|
|
485
|
+
export declare interface PriceData {
|
|
486
|
+
price: Price | null;
|
|
487
|
+
compareAtPrice: Price | null;
|
|
488
|
+
isOnSale: boolean;
|
|
489
|
+
}
|
|
490
|
+
|
|
578
491
|
export declare interface PriceRange {
|
|
579
492
|
min: Price;
|
|
580
493
|
max: Price;
|
|
581
494
|
}
|
|
582
495
|
|
|
583
|
-
declare interface
|
|
584
|
-
|
|
585
|
-
|
|
496
|
+
export declare interface PriceRangeData {
|
|
497
|
+
priceRange: PriceRange;
|
|
498
|
+
compareAtPriceRange: PriceRange | null;
|
|
586
499
|
}
|
|
587
500
|
|
|
588
|
-
export declare
|
|
501
|
+
export declare type Product = ProductBase & Record<string, unknown>;
|
|
502
|
+
|
|
503
|
+
export declare interface ProductBase {
|
|
589
504
|
id: CommerceBlocksID;
|
|
590
505
|
gid: ProductGID;
|
|
591
506
|
numericId: number;
|
|
592
507
|
title: string;
|
|
593
508
|
handle: string;
|
|
594
|
-
type: string;
|
|
595
509
|
vendor: string;
|
|
596
|
-
|
|
510
|
+
type: string;
|
|
597
511
|
availableForSale: boolean;
|
|
512
|
+
tags: string[];
|
|
598
513
|
images: Image_2[];
|
|
514
|
+
featuredMedia: FeaturedMedia | null;
|
|
599
515
|
priceRange: PriceRange;
|
|
600
|
-
compareAtPriceRange
|
|
516
|
+
compareAtPriceRange: PriceRange | null;
|
|
601
517
|
options: RichProductOption[];
|
|
602
|
-
tags: string[];
|
|
603
|
-
variants: ProductVariant[];
|
|
604
518
|
selectedOptions: ProductOption[];
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
519
|
+
variants: ProductVariant[];
|
|
520
|
+
selectedVariant: ProductVariant | null;
|
|
521
|
+
metafields: Record<string, Record<string, unknown>>;
|
|
522
|
+
calculated: Record<string, unknown>;
|
|
608
523
|
category: ProductCategory | null;
|
|
609
|
-
createdAt: string | null;
|
|
610
|
-
publishedAt: string | null;
|
|
611
|
-
updatedAt: string | null;
|
|
612
|
-
featuredMedia: FeaturedMedia | null;
|
|
613
|
-
namedTags?: NamedTag[];
|
|
614
524
|
combinedListingParentProductId: number | null;
|
|
615
525
|
combinedListingRole: string | null;
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
selectedVariant: ProductVariant | null;
|
|
619
|
-
breakoutOptions?: ProductOption[];
|
|
620
|
-
breakoutVariantId?: number;
|
|
526
|
+
breakoutOptions: ProductOption[];
|
|
527
|
+
breakoutVariantId: number | null;
|
|
621
528
|
}
|
|
622
529
|
|
|
623
530
|
export declare interface ProductCardController {
|
|
624
531
|
product: Product;
|
|
625
532
|
variants: ReadonlySignal<ProductVariant[]>;
|
|
626
533
|
selectedVariant: ReadonlySignal<ProductVariant | null>;
|
|
627
|
-
|
|
628
|
-
options: ReadonlySignal<RichProductOption[]>;
|
|
629
|
-
optionNames: ReadonlySignal<string[]>;
|
|
630
|
-
swatchOptionName: ReadonlySignal<string | null>;
|
|
534
|
+
options: ReadonlySignal<OptionGroup[]>;
|
|
631
535
|
images: ReadonlySignal<Image_2[]>;
|
|
632
|
-
|
|
633
|
-
|
|
536
|
+
price: ReadonlySignal<PriceData>;
|
|
537
|
+
priceRange: ReadonlySignal<PriceRangeData>;
|
|
538
|
+
carouselPosition: ReadonlySignal<number>;
|
|
634
539
|
isSelectionComplete: ReadonlySignal<boolean>;
|
|
635
|
-
selectOption(
|
|
540
|
+
selectOption(option: ProductOption): void;
|
|
636
541
|
setSelectedOptions(options: ProductOption[]): void;
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
getVariantByOptions(options: ProductOption[]): ProductVariant | null;
|
|
641
|
-
getCarouselIndexForVariant(variant: ProductVariant): number;
|
|
642
|
-
isOptionAvailable(name: string, value: string): boolean;
|
|
643
|
-
isVariantAvailable(variant: ProductVariant): boolean;
|
|
644
|
-
getOptionAvailabilityStatus(name: string, value: string): OptionAvailabilityStatus;
|
|
542
|
+
setSelectedVariant(variantId: number): void;
|
|
543
|
+
setCarouselPosition(position: number): void;
|
|
544
|
+
subscribe(callback: (state: ProductCardState) => void): Unsubscribe;
|
|
645
545
|
dispose(): void;
|
|
646
546
|
}
|
|
647
547
|
|
|
548
|
+
export declare interface ProductCardOptions {
|
|
549
|
+
product: Product;
|
|
550
|
+
selectedOptions?: ProductOption[];
|
|
551
|
+
breakoutOptions?: ProductOption[];
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
export declare interface ProductCardState {
|
|
555
|
+
variants: ProductVariant[];
|
|
556
|
+
selectedVariant: ProductVariant | null;
|
|
557
|
+
options: OptionGroup[];
|
|
558
|
+
images: Image_2[];
|
|
559
|
+
price: PriceData;
|
|
560
|
+
priceRange: PriceRangeData;
|
|
561
|
+
carouselPosition: number;
|
|
562
|
+
isSelectionComplete: boolean;
|
|
563
|
+
}
|
|
564
|
+
|
|
648
565
|
declare interface ProductCategory {
|
|
649
566
|
id: string;
|
|
650
567
|
name: string;
|
|
@@ -661,19 +578,19 @@ declare interface ProductCategory_2 {
|
|
|
661
578
|
is_root: boolean;
|
|
662
579
|
}
|
|
663
580
|
|
|
664
|
-
declare type ProductExtender
|
|
581
|
+
declare type ProductExtender = (input: ProductExtenderInput) => Record<string, unknown>;
|
|
665
582
|
|
|
666
583
|
declare interface ProductExtenderInput {
|
|
667
584
|
base: Product;
|
|
668
585
|
raw: LayersResult;
|
|
669
|
-
storefront: StorefrontProduct | null;
|
|
670
586
|
}
|
|
671
587
|
|
|
672
588
|
declare type ProductGID = ShopifyGID<'Product'>;
|
|
673
589
|
|
|
674
590
|
declare interface ProductImage {
|
|
675
|
-
|
|
591
|
+
id: number;
|
|
676
592
|
src: string;
|
|
593
|
+
alt: string | null;
|
|
677
594
|
width: number;
|
|
678
595
|
height: number;
|
|
679
596
|
position?: number;
|
|
@@ -685,45 +602,39 @@ export declare interface ProductOption {
|
|
|
685
602
|
value: string;
|
|
686
603
|
}
|
|
687
604
|
|
|
688
|
-
declare interface ProductOptionResult {
|
|
689
|
-
id: string;
|
|
690
|
-
name: string;
|
|
691
|
-
optionValues: OptionValueResult[];
|
|
692
|
-
}
|
|
693
|
-
|
|
694
605
|
declare interface ProductResult {
|
|
695
606
|
__typename?: 'Product';
|
|
696
607
|
id: number;
|
|
697
608
|
title: string;
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
metafields
|
|
710
|
-
calculated
|
|
711
|
-
|
|
712
|
-
first_or_matched_variant?: MatchedVariant;
|
|
713
|
-
featured_media?: FeaturedMedia_2 | null;
|
|
714
|
-
available?: boolean;
|
|
715
|
-
price_range?: {
|
|
609
|
+
handle: string;
|
|
610
|
+
available: boolean;
|
|
611
|
+
vendor: string | null;
|
|
612
|
+
product_type: string | null;
|
|
613
|
+
combined_listing_role: string | null;
|
|
614
|
+
combined_listing_parent_product_id: number | null;
|
|
615
|
+
featured_media: FeaturedMedia_2 | null;
|
|
616
|
+
category: ProductCategory_2 | null;
|
|
617
|
+
tags: string[];
|
|
618
|
+
images: ProductImage[];
|
|
619
|
+
collection_titles: string[];
|
|
620
|
+
metafields: Record<string, Record<string, unknown>>;
|
|
621
|
+
calculated: Record<string, unknown>;
|
|
622
|
+
price_range: {
|
|
716
623
|
from: number;
|
|
717
624
|
to: number;
|
|
718
|
-
compare_at_price
|
|
625
|
+
compare_at_price: number;
|
|
719
626
|
};
|
|
720
|
-
|
|
627
|
+
options_v2: OptionV2[];
|
|
628
|
+
body_html?: string | null;
|
|
629
|
+
is_gift_card?: boolean | null;
|
|
630
|
+
has_variants_that_require_components?: boolean | null;
|
|
631
|
+
named_tags?: Record<string, string[]>;
|
|
721
632
|
original_options?: Record<string, string[]>;
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
variants
|
|
633
|
+
created_at?: string;
|
|
634
|
+
updated_at?: string;
|
|
635
|
+
published_at?: string;
|
|
636
|
+
first_or_matched_variant?: MatchedVariant;
|
|
637
|
+
variants: LayersVariant[];
|
|
727
638
|
}
|
|
728
639
|
|
|
729
640
|
export declare interface ProductVariant {
|
|
@@ -731,15 +642,13 @@ export declare interface ProductVariant {
|
|
|
731
642
|
gid: VariantGID;
|
|
732
643
|
numericId: number;
|
|
733
644
|
title: string;
|
|
734
|
-
availableForSale: boolean;
|
|
735
|
-
currentlyNotInStock: boolean;
|
|
736
645
|
sku: string | null;
|
|
737
646
|
position: number;
|
|
647
|
+
availableForSale: boolean;
|
|
738
648
|
price: Price;
|
|
739
649
|
compareAtPrice: Price | null;
|
|
740
650
|
image: Image_2 | null;
|
|
741
651
|
selectedOptions: ProductOption[];
|
|
742
|
-
metafields: Metafield[];
|
|
743
652
|
inventoryLevels: InventoryLevels;
|
|
744
653
|
inventoryPolicy: 'DENY' | 'CONTINUE' | null;
|
|
745
654
|
inStockLocationIds: number[];
|
|
@@ -747,45 +656,30 @@ export declare interface ProductVariant {
|
|
|
747
656
|
hasSellingPlan: boolean;
|
|
748
657
|
}
|
|
749
658
|
|
|
750
|
-
declare type Queries<P extends Product = Product> = Record<string, QueryResult<P>>;
|
|
751
|
-
|
|
752
659
|
export declare interface QueryParams {
|
|
753
660
|
page?: number;
|
|
754
661
|
limit?: number;
|
|
755
662
|
filters?: unknown;
|
|
756
663
|
signal?: AbortSignal;
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
paramDefinitions?: ParamDefinitions;
|
|
760
|
-
transformBody?: BodyTransformer;
|
|
664
|
+
linking?: Record<string, string | number | (string | number)[]>;
|
|
665
|
+
transformRequest?: RequestTransformer;
|
|
761
666
|
}
|
|
762
667
|
|
|
763
|
-
declare interface QueryResult
|
|
764
|
-
products:
|
|
668
|
+
declare interface QueryResult extends Omit<LayersResponse, 'results' | 'facets'> {
|
|
669
|
+
products: Product[];
|
|
765
670
|
facets: Record<string, Record<string, number>>;
|
|
766
671
|
priceRange?: PriceRange;
|
|
767
672
|
}
|
|
768
673
|
|
|
769
674
|
export declare interface QueryState<T> {
|
|
770
675
|
data: T | null;
|
|
771
|
-
error:
|
|
676
|
+
error: ClientError | null;
|
|
772
677
|
isFetching: boolean;
|
|
773
678
|
}
|
|
774
679
|
|
|
775
680
|
export { ReadonlySignal }
|
|
776
681
|
|
|
777
|
-
declare
|
|
778
|
-
readonly method: HttpMethod;
|
|
779
|
-
readonly url: string;
|
|
780
|
-
readonly headers?: Record<string, string>;
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
declare interface ResponseContext {
|
|
784
|
-
readonly status: number;
|
|
785
|
-
readonly statusText: string;
|
|
786
|
-
readonly headers?: Record<string, string>;
|
|
787
|
-
readonly body?: string;
|
|
788
|
-
}
|
|
682
|
+
export declare type RequestTransformer = (body: Record<string, unknown>) => Record<string, unknown>;
|
|
789
683
|
|
|
790
684
|
declare type Result<T, E = Error> = {
|
|
791
685
|
data: T;
|
|
@@ -796,95 +690,93 @@ declare type Result<T, E = Error> = {
|
|
|
796
690
|
};
|
|
797
691
|
|
|
798
692
|
export declare interface RichProductOption extends ProductOption {
|
|
693
|
+
code: string;
|
|
799
694
|
swatch?: Swatch;
|
|
800
695
|
}
|
|
801
696
|
|
|
802
|
-
export declare interface
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
search: (options?: SearchQuery) => SearchController<P>;
|
|
807
|
-
storefront: (query: StorefrontQuery) => ReadonlySignal<QueryState<StorefrontResult<P>>>;
|
|
808
|
-
uploadImage: (options: UploadImageOptions) => ReadonlySignal<QueryState<UploadImageResult>>;
|
|
809
|
-
imageSearch: (options: ImageSearchQuery) => ReadonlySignal<QueryState<SearchResult<P>>>;
|
|
810
|
-
config: SdkConfig<P>;
|
|
811
|
-
store: Store<P>;
|
|
697
|
+
export declare interface SearchByImageController {
|
|
698
|
+
readonly state: ReadonlySignal<QueryState<SearchResult>>;
|
|
699
|
+
subscribe(callback: (state: QueryState<SearchResult>) => void): Unsubscribe;
|
|
700
|
+
dispose(): void;
|
|
812
701
|
}
|
|
813
702
|
|
|
814
|
-
export declare interface
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
currencyCode?: string;
|
|
818
|
-
formatPrice?: (amount: number, currencyCode: string) => string;
|
|
819
|
-
swatches?: Swatch[];
|
|
820
|
-
options?: string[];
|
|
821
|
-
productMetafields?: {
|
|
822
|
-
namespace: string;
|
|
823
|
-
key: string;
|
|
824
|
-
}[];
|
|
825
|
-
variantMetafields?: {
|
|
826
|
-
namespace: string;
|
|
827
|
-
key: string;
|
|
828
|
-
}[];
|
|
829
|
-
collectionMetafields?: {
|
|
830
|
-
namespace: string;
|
|
831
|
-
key: string;
|
|
832
|
-
}[];
|
|
833
|
-
pageMetafields?: {
|
|
834
|
-
namespace: string;
|
|
835
|
-
key: string;
|
|
836
|
-
}[];
|
|
837
|
-
storefrontApiVersion?: string;
|
|
838
|
-
cacheMaxProducts?: number;
|
|
839
|
-
cacheMaxEntries?: number;
|
|
840
|
-
cacheTtl?: number;
|
|
841
|
-
/** Custom storage adapter for cache persistence. Defaults to localStorage in browser. */
|
|
842
|
-
storageAdapter?: StorageAdapter;
|
|
843
|
-
extendProduct?: ProductExtender<P>;
|
|
844
|
-
transformFilters?: FilterTransformer;
|
|
845
|
-
filterMap?: FilterMap;
|
|
846
|
-
extendCollection?: CollectionExtender<P>;
|
|
847
|
-
extendSearch?: SearchExtender<P>;
|
|
848
|
-
extendBlock?: BlocksExtender<P>;
|
|
849
|
-
/** Initial data to hydrate into the store */
|
|
850
|
-
initialData?: {
|
|
851
|
-
products?: P[];
|
|
852
|
-
queries?: Queries<P>;
|
|
853
|
-
collections?: Collections;
|
|
854
|
-
};
|
|
855
|
-
/** Restore cache from storage on init (default: true) */
|
|
856
|
-
restoreFromStorage?: boolean;
|
|
703
|
+
export declare interface SearchByImageQuery extends QueryParams {
|
|
704
|
+
imageId: string;
|
|
705
|
+
tuning?: SearchTuning;
|
|
857
706
|
}
|
|
858
707
|
|
|
859
|
-
export declare
|
|
708
|
+
export declare interface SearchContentController {
|
|
709
|
+
readonly state: ReadonlySignal<QueryState<SearchContentResult>>;
|
|
710
|
+
execute(query?: SearchContentQuery): Promise<Result<SearchContentResult, ClientError>>;
|
|
711
|
+
subscribe(callback: (state: QueryState<SearchContentResult>) => void): Unsubscribe;
|
|
712
|
+
dispose(): void;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
export declare interface SearchContentQuery {
|
|
716
|
+
query?: string;
|
|
717
|
+
contentType?: string;
|
|
718
|
+
page?: number;
|
|
719
|
+
limit?: number;
|
|
720
|
+
tuning?: SearchTuning;
|
|
721
|
+
signal?: AbortSignal;
|
|
722
|
+
transformRequest?: RequestTransformer;
|
|
723
|
+
temporary?: boolean;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
export declare interface SearchContentResult {
|
|
727
|
+
articles: Article[];
|
|
728
|
+
query: string;
|
|
729
|
+
contentType: string | null;
|
|
730
|
+
totalResults: number;
|
|
731
|
+
page: number;
|
|
732
|
+
resultsPerPage: number;
|
|
733
|
+
}
|
|
860
734
|
|
|
861
|
-
export declare interface SearchController
|
|
862
|
-
readonly state: ReadonlySignal<QueryState<SearchResult
|
|
863
|
-
prepare(query?: SearchQuery): Promise<Result<
|
|
864
|
-
execute(query?: SearchQuery): Promise<Result<SearchResult
|
|
865
|
-
subscribe(callback: (state: QueryState<SearchResult
|
|
735
|
+
export declare interface SearchController {
|
|
736
|
+
readonly state: ReadonlySignal<QueryState<SearchResult>>;
|
|
737
|
+
prepare(query?: SearchQuery): Promise<Result<SearchPrepareResult, ClientError>>;
|
|
738
|
+
execute(query?: SearchQuery): Promise<Result<SearchResult, ClientError>>;
|
|
739
|
+
subscribe(callback: (state: QueryState<SearchResult>) => void): Unsubscribe;
|
|
866
740
|
dispose(): void;
|
|
867
741
|
}
|
|
868
742
|
|
|
869
|
-
export declare
|
|
743
|
+
export declare interface SearchPrepareResult {
|
|
744
|
+
searchId: string;
|
|
745
|
+
}
|
|
870
746
|
|
|
871
747
|
export declare interface SearchQuery extends QueryParams {
|
|
872
748
|
query?: string;
|
|
873
749
|
searchId?: string;
|
|
874
|
-
tuning?:
|
|
875
|
-
|
|
750
|
+
tuning?: SearchTuning;
|
|
751
|
+
temporary?: boolean;
|
|
876
752
|
}
|
|
877
753
|
|
|
878
|
-
export declare type SearchResult
|
|
754
|
+
export declare type SearchResult = QueryResult;
|
|
879
755
|
|
|
880
|
-
declare interface
|
|
881
|
-
|
|
882
|
-
|
|
756
|
+
declare interface SearchTuning {
|
|
757
|
+
textualWeight?: number;
|
|
758
|
+
visualWeight?: number;
|
|
759
|
+
multipleFactor?: number;
|
|
760
|
+
minimumMatch?: number;
|
|
761
|
+
missingEmbeddingScore?: number;
|
|
762
|
+
highSignalWeight?: number;
|
|
883
763
|
}
|
|
884
764
|
|
|
885
|
-
declare interface
|
|
886
|
-
|
|
887
|
-
|
|
765
|
+
declare interface SelectedOption {
|
|
766
|
+
name: string;
|
|
767
|
+
value: string;
|
|
768
|
+
optionValue?: {
|
|
769
|
+
swatch?: {
|
|
770
|
+
color: string | null;
|
|
771
|
+
image: {
|
|
772
|
+
image: {
|
|
773
|
+
url: string;
|
|
774
|
+
altText: string | null;
|
|
775
|
+
};
|
|
776
|
+
} | null;
|
|
777
|
+
};
|
|
778
|
+
linkedMetafieldValue?: unknown;
|
|
779
|
+
};
|
|
888
780
|
}
|
|
889
781
|
|
|
890
782
|
declare type ServiceError = NetworkError | ApiError | ValidationError;
|
|
@@ -912,149 +804,31 @@ export declare interface StorageAdapter {
|
|
|
912
804
|
remove(): void;
|
|
913
805
|
}
|
|
914
806
|
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
cached: P[];
|
|
920
|
-
missing: ProductGID[];
|
|
921
|
-
};
|
|
922
|
-
set(products: P | P[]): void;
|
|
923
|
-
has(gid: ProductGID): boolean;
|
|
924
|
-
};
|
|
925
|
-
queries: {
|
|
926
|
-
get(key: string): ReadonlySignal<CacheEntry<QueryResult<P>> | null>;
|
|
927
|
-
set(key: string, result: QueryResult<P>): void;
|
|
928
|
-
isExpired(key: string): boolean;
|
|
929
|
-
invalidate(pattern: string): void;
|
|
930
|
-
};
|
|
931
|
-
collections: {
|
|
932
|
-
get(handle: string): CollectionMeta | undefined;
|
|
933
|
-
set(handle: string, meta: Omit<CollectionMeta, 'handle'>): void;
|
|
934
|
-
delete(handle: string): void;
|
|
935
|
-
};
|
|
936
|
-
pages: {
|
|
937
|
-
get(handle: string): PageMeta | undefined;
|
|
938
|
-
set(handle: string, meta: Omit<PageMeta, 'handle'>): void;
|
|
939
|
-
delete(handle: string): void;
|
|
940
|
-
};
|
|
941
|
-
persist(): void;
|
|
942
|
-
restore(): void;
|
|
943
|
-
clear(): void;
|
|
944
|
-
readonly stats: {
|
|
945
|
-
products: number;
|
|
946
|
-
queries: number;
|
|
947
|
-
collections: number;
|
|
948
|
-
pages: number;
|
|
949
|
-
};
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
declare interface StorefrontClientConfig {
|
|
953
|
-
shop: string;
|
|
954
|
-
storefrontPublicToken: string;
|
|
955
|
-
storefrontApiVersion?: string;
|
|
956
|
-
fetch?: CustomFetch;
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
declare interface StorefrontCollection {
|
|
960
|
-
id: string;
|
|
961
|
-
handle: string;
|
|
962
|
-
title: string;
|
|
963
|
-
description: string;
|
|
964
|
-
descriptionHtml: string;
|
|
965
|
-
image: ImageResult | null;
|
|
966
|
-
seo: SeoResult;
|
|
967
|
-
updatedAt: string;
|
|
968
|
-
metafields?: (MetafieldResult | null)[];
|
|
969
|
-
products?: {
|
|
970
|
-
filters: FilterResult[];
|
|
971
|
-
};
|
|
972
|
-
}
|
|
807
|
+
/**
|
|
808
|
+
* Subscribe to state changes. Callback fires immediately, then on every change.
|
|
809
|
+
*/
|
|
810
|
+
export declare function subscribe<T>(state: ReadonlySignal<T>, callback: (value: T) => void): () => void;
|
|
973
811
|
|
|
974
|
-
declare interface
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
bodySummary: string;
|
|
980
|
-
seo: SeoResult;
|
|
981
|
-
createdAt: string;
|
|
982
|
-
updatedAt: string;
|
|
983
|
-
onlineStoreUrl: string | null;
|
|
984
|
-
metafields?: (MetafieldResult | null)[];
|
|
812
|
+
export declare interface SuggestController {
|
|
813
|
+
readonly state: ReadonlySignal<QueryState<Suggestions>>;
|
|
814
|
+
execute(query: string): void;
|
|
815
|
+
subscribe(callback: (state: QueryState<Suggestions>) => void): Unsubscribe;
|
|
816
|
+
dispose(): void;
|
|
985
817
|
}
|
|
986
818
|
|
|
987
|
-
declare interface
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
description: string;
|
|
992
|
-
descriptionHtml: string;
|
|
993
|
-
vendor: string;
|
|
994
|
-
productType: string;
|
|
995
|
-
tags: string[];
|
|
996
|
-
availableForSale: boolean;
|
|
997
|
-
isGiftCard: boolean;
|
|
998
|
-
featuredImage: ImageResult | null;
|
|
999
|
-
images: {
|
|
1000
|
-
nodes: ImageResult[];
|
|
1001
|
-
};
|
|
1002
|
-
priceRange: PriceRangeResult;
|
|
1003
|
-
compareAtPriceRange: PriceRangeResult;
|
|
1004
|
-
options: ProductOptionResult[];
|
|
1005
|
-
variants: {
|
|
1006
|
-
nodes: VariantResult_2[];
|
|
1007
|
-
};
|
|
1008
|
-
selectedOrFirstAvailableVariant: VariantResult_2 | null;
|
|
1009
|
-
metafields?: (MetafieldResult | null)[];
|
|
819
|
+
declare interface Suggestions {
|
|
820
|
+
matchedQueries: string[];
|
|
821
|
+
originalQuery: string;
|
|
822
|
+
normalizedQuery: string;
|
|
1010
823
|
}
|
|
1011
824
|
|
|
1012
|
-
export declare interface
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
page?: string;
|
|
1017
|
-
includeFilters?: boolean;
|
|
1018
|
-
};
|
|
1019
|
-
productMetafields?: {
|
|
1020
|
-
namespace: string;
|
|
1021
|
-
key: string;
|
|
1022
|
-
}[];
|
|
1023
|
-
variantMetafields?: {
|
|
1024
|
-
namespace: string;
|
|
1025
|
-
key: string;
|
|
1026
|
-
}[];
|
|
1027
|
-
collectionMetafields?: {
|
|
1028
|
-
namespace: string;
|
|
1029
|
-
key: string;
|
|
1030
|
-
}[];
|
|
1031
|
-
pageMetafields?: {
|
|
1032
|
-
namespace: string;
|
|
1033
|
-
key: string;
|
|
1034
|
-
}[];
|
|
825
|
+
export declare interface SuggestOptions {
|
|
826
|
+
debounce?: number;
|
|
827
|
+
excludeInputQuery?: boolean;
|
|
828
|
+
excludeQueries?: string[];
|
|
1035
829
|
signal?: AbortSignal;
|
|
1036
830
|
}
|
|
1037
831
|
|
|
1038
|
-
export declare interface StorefrontResult<P extends Product = Product> {
|
|
1039
|
-
products: P[];
|
|
1040
|
-
collection?: StorefrontCollection;
|
|
1041
|
-
page?: StorefrontPage;
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
export declare interface StoreOptions {
|
|
1045
|
-
ttl?: number;
|
|
1046
|
-
maxProducts?: number;
|
|
1047
|
-
maxQueries?: number;
|
|
1048
|
-
storageKey?: string;
|
|
1049
|
-
/** Custom storage adapter. Defaults to localStorage in browser. */
|
|
1050
|
-
storageAdapter?: StorageAdapter;
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
/**
|
|
1054
|
-
* Subscribe to state changes. Callback fires immediately, then on every change.
|
|
1055
|
-
*/
|
|
1056
|
-
export declare function subscribe<T>(state: ReadonlySignal<QueryState<T>>, callback: (state: QueryState<T>) => void): Unsubscribe;
|
|
1057
|
-
|
|
1058
832
|
export declare interface Swatch {
|
|
1059
833
|
name: string | null;
|
|
1060
834
|
value: string;
|
|
@@ -1062,17 +836,25 @@ export declare interface Swatch {
|
|
|
1062
836
|
imageUrl: string | null;
|
|
1063
837
|
}
|
|
1064
838
|
|
|
1065
|
-
declare interface
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
}
|
|
839
|
+
export declare interface Transforms {
|
|
840
|
+
product?: ProductExtender;
|
|
841
|
+
collection?: (result: CollectionResult, raw: LayersResponse) => CollectionResult;
|
|
842
|
+
search?: (result: SearchResult, raw: LayersResponse) => SearchResult;
|
|
843
|
+
block?: (result: BlocksResult, raw: LayersResponse & {
|
|
844
|
+
block?: BlocksInfo;
|
|
845
|
+
}) => BlocksResult;
|
|
846
|
+
searchContent?: (result: SearchContentResult, raw: ContentSearchResponse) => SearchContentResult;
|
|
847
|
+
filters?: (filters: unknown) => FilterGroup | undefined;
|
|
1072
848
|
}
|
|
1073
849
|
|
|
1074
850
|
export declare type Unsubscribe = () => void;
|
|
1075
851
|
|
|
852
|
+
export declare interface UploadImageController {
|
|
853
|
+
readonly state: ReadonlySignal<QueryState<UploadImageResult>>;
|
|
854
|
+
subscribe(callback: (state: QueryState<UploadImageResult>) => void): Unsubscribe;
|
|
855
|
+
dispose(): void;
|
|
856
|
+
}
|
|
857
|
+
|
|
1076
858
|
export declare interface UploadImageOptions {
|
|
1077
859
|
image: File | Blob;
|
|
1078
860
|
signal?: AbortSignal;
|
|
@@ -1086,28 +868,21 @@ export declare interface ValidationError {
|
|
|
1086
868
|
readonly _tag: 'ValidationError';
|
|
1087
869
|
readonly code: 'VALIDATION_FAILED';
|
|
1088
870
|
readonly message: string;
|
|
1089
|
-
readonly timestamp: string;
|
|
1090
871
|
readonly operation: string;
|
|
1091
872
|
readonly fields: ValidationFieldError[];
|
|
1092
873
|
readonly input?: unknown;
|
|
1093
874
|
}
|
|
1094
875
|
|
|
1095
|
-
declare type ValidationErrorCode = 'REQUIRED_FIELD' | '
|
|
876
|
+
declare type ValidationErrorCode = 'REQUIRED_FIELD' | 'OUT_OF_RANGE';
|
|
1096
877
|
|
|
1097
878
|
declare interface ValidationFieldError {
|
|
1098
|
-
readonly path: string[];
|
|
1099
879
|
readonly field: string;
|
|
1100
880
|
readonly code: ValidationErrorCode;
|
|
1101
881
|
readonly message: string;
|
|
1102
882
|
readonly value?: unknown;
|
|
1103
|
-
readonly expected?: string;
|
|
1104
883
|
readonly constraints?: {
|
|
1105
884
|
min?: number;
|
|
1106
885
|
max?: number;
|
|
1107
|
-
minLength?: number;
|
|
1108
|
-
maxLength?: number;
|
|
1109
|
-
pattern?: string;
|
|
1110
|
-
allowedValues?: string[];
|
|
1111
886
|
};
|
|
1112
887
|
}
|
|
1113
888
|
|
|
@@ -1129,17 +904,6 @@ declare interface VariantResult extends Omit<ProductResult, '__typename'> {
|
|
|
1129
904
|
variant_id: number;
|
|
1130
905
|
}
|
|
1131
906
|
|
|
1132
|
-
declare
|
|
1133
|
-
id: string;
|
|
1134
|
-
title: string;
|
|
1135
|
-
availableForSale: boolean;
|
|
1136
|
-
currentlyNotInStock: boolean;
|
|
1137
|
-
sku: string | null;
|
|
1138
|
-
price: MoneyResult;
|
|
1139
|
-
compareAtPrice: MoneyResult | null;
|
|
1140
|
-
selectedOptions: SelectedOptionResult[];
|
|
1141
|
-
image: ImageResult | null;
|
|
1142
|
-
metafields?: (MetafieldResult | null)[];
|
|
1143
|
-
}
|
|
907
|
+
export declare function xhrFetch(url: string, init?: RequestInit): Promise<Response>;
|
|
1144
908
|
|
|
1145
909
|
export { }
|