@commerce-blocks/sdk 2.0.0-alpha.2 → 2.0.0-alpha.3
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 +313 -850
- package/dist/index.d.ts +278 -573
- package/dist/index.js +1156 -1980
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,40 +7,32 @@ 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
22
|
readonly retryable: boolean;
|
|
18
23
|
readonly retryAfterMs?: number;
|
|
19
|
-
readonly request?: RequestContext;
|
|
20
|
-
readonly response?: ResponseContext;
|
|
21
24
|
readonly cause?: unknown;
|
|
22
|
-
readonly details?: {
|
|
23
|
-
readonly graphqlErrors?: GraphQLErrorDetail[];
|
|
24
|
-
readonly requestId?: string;
|
|
25
|
-
readonly shop?: string;
|
|
26
|
-
};
|
|
27
25
|
}
|
|
28
26
|
|
|
29
|
-
declare type ApiErrorCode = 'UNAUTHORIZED' | 'FORBIDDEN' | 'NOT_FOUND' | 'NOT_READY' | 'RATE_LIMITED' | 'SERVICE_UNAVAILABLE' | '
|
|
27
|
+
declare type ApiErrorCode = 'UNAUTHORIZED' | 'FORBIDDEN' | 'NOT_FOUND' | 'NOT_READY' | 'RATE_LIMITED' | 'SERVICE_UNAVAILABLE' | 'PARSE_ERROR' | 'UNKNOWN';
|
|
30
28
|
|
|
31
|
-
declare
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
execute(query: string): void;
|
|
36
|
-
subscribe(callback: (state: QueryState<PredictiveSearchResponse>) => void): Unsubscribe;
|
|
37
|
-
dispose(): void;
|
|
29
|
+
declare interface ApiFetchConfig {
|
|
30
|
+
token: string;
|
|
31
|
+
baseUrl?: string;
|
|
32
|
+
fetch?: CustomFetch;
|
|
38
33
|
}
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
debounceMs?: number;
|
|
42
|
-
signal?: AbortSignal;
|
|
43
|
-
}
|
|
35
|
+
declare type ApiSource = 'layers';
|
|
44
36
|
|
|
45
37
|
export { batch }
|
|
46
38
|
|
|
@@ -58,16 +50,7 @@ declare interface BlocksContext {
|
|
|
58
50
|
custom?: Record<string, unknown>;
|
|
59
51
|
}
|
|
60
52
|
|
|
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>;
|
|
53
|
+
export declare type BlocksController = Controller<BlocksResult, BlocksQuery>;
|
|
71
54
|
|
|
72
55
|
declare interface BlocksInfo {
|
|
73
56
|
id: string;
|
|
@@ -80,73 +63,98 @@ declare interface BlocksInfo {
|
|
|
80
63
|
|
|
81
64
|
export declare interface BlocksOptions {
|
|
82
65
|
blockId: string;
|
|
83
|
-
|
|
66
|
+
anchor?: string;
|
|
84
67
|
}
|
|
85
68
|
|
|
86
69
|
export declare interface BlocksQuery extends QueryParams {
|
|
87
|
-
|
|
70
|
+
discounts?: DiscountEntitlement[];
|
|
88
71
|
context?: BlocksContext;
|
|
89
72
|
}
|
|
90
73
|
|
|
91
|
-
export declare interface BlocksResult
|
|
74
|
+
export declare interface BlocksResult extends QueryResult {
|
|
92
75
|
block?: BlocksInfo;
|
|
93
76
|
}
|
|
94
77
|
|
|
95
|
-
|
|
78
|
+
declare interface Cache_2 {
|
|
79
|
+
get(key: string): CacheEntry<QueryResult> | null;
|
|
80
|
+
set(key: string, result: QueryResult): void;
|
|
81
|
+
isExpired(key: string): boolean;
|
|
82
|
+
invalidate(pattern: string): void;
|
|
83
|
+
persist(): void;
|
|
84
|
+
restore(): void;
|
|
85
|
+
clear(): void;
|
|
86
|
+
readonly stats: {
|
|
87
|
+
entries: number;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
declare type CacheData = Record<string, QueryResult>;
|
|
96
92
|
|
|
97
93
|
declare interface CacheEntry<T> {
|
|
98
94
|
data: T;
|
|
99
95
|
timestamp: number;
|
|
100
96
|
}
|
|
101
97
|
|
|
102
|
-
export declare interface
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
98
|
+
export declare interface CacheOptions {
|
|
99
|
+
ttl?: number;
|
|
100
|
+
maxEntries?: number;
|
|
101
|
+
storageKey?: string;
|
|
102
|
+
/** Custom storage adapter. Defaults to localStorage in browser. */
|
|
103
|
+
storageAdapter?: StorageAdapter;
|
|
107
104
|
}
|
|
108
105
|
|
|
109
|
-
export declare
|
|
106
|
+
export declare interface Client {
|
|
107
|
+
collection: (options: CollectionOptions) => CollectionController;
|
|
108
|
+
blocks: (options: BlocksOptions) => BlocksController;
|
|
109
|
+
suggest: (options?: SuggestOptions) => SuggestController;
|
|
110
|
+
search: (options?: SearchQuery) => SearchController;
|
|
111
|
+
uploadImage: (options: UploadImageOptions) => UploadImageController;
|
|
112
|
+
searchByImage: (options: SearchByImageQuery) => SearchByImageController;
|
|
113
|
+
config: ClientConfig;
|
|
114
|
+
cache: Cache_2;
|
|
115
|
+
}
|
|
110
116
|
|
|
111
|
-
declare interface
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
117
|
+
export declare interface ClientConfig extends ApiClientConfig {
|
|
118
|
+
includeMeta?: boolean;
|
|
119
|
+
currency?: string;
|
|
120
|
+
formatPrice?: (amount: number, currencyCode: string) => string;
|
|
121
|
+
swatches?: Swatch[];
|
|
122
|
+
options?: string[];
|
|
123
|
+
productMetafields?: {
|
|
124
|
+
namespace: string;
|
|
125
|
+
key: string;
|
|
126
|
+
}[];
|
|
127
|
+
variantMetafields?: {
|
|
128
|
+
namespace: string;
|
|
129
|
+
key: string;
|
|
130
|
+
}[];
|
|
131
|
+
cacheLimit?: number;
|
|
132
|
+
cacheLifetime?: number;
|
|
133
|
+
/** Custom storage adapter for cache persistence. Defaults to localStorage in browser. */
|
|
134
|
+
storage?: StorageAdapter;
|
|
135
|
+
transforms?: Transforms;
|
|
136
|
+
filterAliases?: FilterAliases;
|
|
137
|
+
/** Initial data to hydrate into the cache */
|
|
138
|
+
initialData?: CacheData;
|
|
139
|
+
/** Restore cache from storage on init (default: true) */
|
|
140
|
+
restoreCache?: boolean;
|
|
128
141
|
}
|
|
129
142
|
|
|
143
|
+
export declare type ClientError = ServiceError | ConfigError;
|
|
144
|
+
|
|
145
|
+
export declare type CollectionController = Controller<CollectionResult, CollectionQuery>;
|
|
146
|
+
|
|
130
147
|
export declare interface CollectionOptions {
|
|
131
148
|
handle: string;
|
|
132
149
|
defaultSort?: string;
|
|
133
150
|
}
|
|
134
151
|
|
|
135
152
|
export declare interface CollectionQuery extends QueryParams {
|
|
136
|
-
|
|
153
|
+
sort?: string;
|
|
137
154
|
includeMeta?: boolean;
|
|
138
|
-
collectionMetafields?: {
|
|
139
|
-
namespace: string;
|
|
140
|
-
key: string;
|
|
141
|
-
}[];
|
|
142
|
-
includeFilters?: boolean;
|
|
143
155
|
}
|
|
144
156
|
|
|
145
|
-
export declare
|
|
146
|
-
collection?: StorefrontCollection;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
declare type Collections = Record<string, Omit<CollectionMeta, 'handle'>>;
|
|
157
|
+
export declare type CollectionResult = QueryResult;
|
|
150
158
|
|
|
151
159
|
declare type CommerceBlocksID = `${CommerceBlocksType}-${OptionSegment}` | `${CommerceBlocksType}-${OptionSegment}-${OptionSegment}` | `${CommerceBlocksType}-${OptionSegment}-${OptionSegment}-${OptionSegment}`;
|
|
152
160
|
|
|
@@ -158,7 +166,6 @@ export declare interface ConfigError {
|
|
|
158
166
|
readonly _tag: 'ConfigError';
|
|
159
167
|
readonly code: ConfigErrorCode;
|
|
160
168
|
readonly message: string;
|
|
161
|
-
readonly timestamp: string;
|
|
162
169
|
readonly field: string;
|
|
163
170
|
readonly value?: unknown;
|
|
164
171
|
readonly expected?: string;
|
|
@@ -168,22 +175,18 @@ declare type ConfigErrorCode = 'MISSING_CONFIG' | 'INVALID_CONFIG';
|
|
|
168
175
|
|
|
169
176
|
export declare interface Controller<TData, TQuery = void> {
|
|
170
177
|
readonly state: ReadonlySignal<QueryState<TData>>;
|
|
171
|
-
execute(query
|
|
178
|
+
execute(query?: TQuery): Promise<Result<TData, ClientError>>;
|
|
172
179
|
subscribe(callback: (state: QueryState<TData>) => void): Unsubscribe;
|
|
173
180
|
dispose(): void;
|
|
174
181
|
}
|
|
175
182
|
|
|
176
|
-
export declare function
|
|
183
|
+
export declare function createClient(config: ClientConfig): Result<Client, ConfigError>;
|
|
177
184
|
|
|
178
|
-
export declare
|
|
179
|
-
product: Product | ExtendedProduct;
|
|
180
|
-
selectedOptions?: ProductOption[];
|
|
181
|
-
breakoutOptions?: ProductOption[];
|
|
182
|
-
}
|
|
185
|
+
export declare type CreateClientResult = Result<Client, ConfigError>;
|
|
183
186
|
|
|
184
|
-
export declare function
|
|
187
|
+
export declare function createProductCard({ product, selectedOptions: initialSelectedOptions, breakoutOptions: initialBreakoutOptions, }: ProductCardOptions): ProductCardController;
|
|
185
188
|
|
|
186
|
-
declare type CustomFetch = (url: string, init?: RequestInit) => Promise<Response>;
|
|
189
|
+
export declare type CustomFetch = (url: string, init?: RequestInit) => Promise<Response>;
|
|
187
190
|
|
|
188
191
|
declare interface DiscountEntitlement {
|
|
189
192
|
entitled: {
|
|
@@ -204,10 +207,6 @@ export declare function eq(property: string, value: FilterValue): FilterExpressi
|
|
|
204
207
|
|
|
205
208
|
export declare function exists(property: string): FilterExpression;
|
|
206
209
|
|
|
207
|
-
declare interface ExtendedProduct extends Product {
|
|
208
|
-
_base: Product;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
210
|
declare interface Facet {
|
|
212
211
|
name: string;
|
|
213
212
|
code: string;
|
|
@@ -222,13 +221,16 @@ declare interface FeaturedMedia {
|
|
|
222
221
|
}
|
|
223
222
|
|
|
224
223
|
declare interface FeaturedMedia_2 {
|
|
225
|
-
|
|
226
|
-
alt: string;
|
|
224
|
+
id: number;
|
|
227
225
|
src: string;
|
|
226
|
+
alt: string | null;
|
|
227
|
+
media_type: string;
|
|
228
228
|
width: number;
|
|
229
229
|
height: number;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
+
export declare function fileStorage(filePath: string, fs: FileSystem_2): StorageAdapter;
|
|
233
|
+
|
|
232
234
|
declare interface FileSystem_2 {
|
|
233
235
|
readFileSync(path: string, encoding: 'utf-8'): string;
|
|
234
236
|
writeFileSync(path: string, data: string, encoding: 'utf-8'): void;
|
|
@@ -238,6 +240,13 @@ export { FileSystem_2 as FileSystem }
|
|
|
238
240
|
|
|
239
241
|
export declare function filter(expression: FilterExpression | FilterGroup): FilterGroup;
|
|
240
242
|
|
|
243
|
+
export declare type FilterAlias = string | {
|
|
244
|
+
property: string;
|
|
245
|
+
values?: Record<string, string>;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export declare type FilterAliases = Record<string, FilterAlias>;
|
|
249
|
+
|
|
241
250
|
declare enum FilterConditional {
|
|
242
251
|
And = "AND",
|
|
243
252
|
Or = "OR"
|
|
@@ -254,13 +263,6 @@ export declare interface FilterGroup {
|
|
|
254
263
|
expressions: (FilterExpression | FilterGroup)[];
|
|
255
264
|
}
|
|
256
265
|
|
|
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
266
|
declare enum FilterOperator {
|
|
265
267
|
Equal = "eq",
|
|
266
268
|
NotEqual = "not_eq",
|
|
@@ -274,58 +276,14 @@ declare enum FilterOperator {
|
|
|
274
276
|
NotExists = "not_exists"
|
|
275
277
|
}
|
|
276
278
|
|
|
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
279
|
declare type FilterValue = string | number | boolean;
|
|
287
280
|
|
|
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>;
|
|
303
|
-
|
|
304
|
-
declare interface GraphQLErrorDetail {
|
|
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
|
-
}
|
|
281
|
+
export declare function getClient(): Result<Client, ConfigError>;
|
|
313
282
|
|
|
314
283
|
export declare function gt(property: string, value: number): FilterExpression;
|
|
315
284
|
|
|
316
285
|
export declare function gte(property: string, value: number): FilterExpression;
|
|
317
286
|
|
|
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
287
|
declare interface Image_2 {
|
|
330
288
|
url: string;
|
|
331
289
|
alt: string;
|
|
@@ -336,36 +294,16 @@ declare interface Image_2 {
|
|
|
336
294
|
}
|
|
337
295
|
export { Image_2 as Image }
|
|
338
296
|
|
|
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
297
|
export declare function inValues(property: string, values: FilterValue[]): FilterExpression;
|
|
352
298
|
|
|
353
299
|
/** Map of location ID to available quantity */
|
|
354
300
|
declare type InventoryLevels = Record<string, number>;
|
|
355
301
|
|
|
356
|
-
export declare function
|
|
357
|
-
|
|
358
|
-
export declare function isRetryable(error: SdkError): boolean;
|
|
302
|
+
export declare function isClientError(error: unknown): error is ClientError;
|
|
359
303
|
|
|
360
|
-
export declare function
|
|
361
|
-
|
|
362
|
-
export declare function jsonFileAdapter(filePath: string, fs: FileSystem_2): StorageAdapter;
|
|
304
|
+
export declare function isInitialized(): boolean;
|
|
363
305
|
|
|
364
|
-
declare
|
|
365
|
-
sorts: Sort[];
|
|
366
|
-
facets: Facet[];
|
|
367
|
-
attributes?: string[];
|
|
368
|
-
}
|
|
306
|
+
export declare function isRetryable(error: ClientError): boolean;
|
|
369
307
|
|
|
370
308
|
declare interface LayersFacets {
|
|
371
309
|
facets?: Record<string, Record<string, number>>;
|
|
@@ -375,12 +313,6 @@ declare interface LayersFacets {
|
|
|
375
313
|
}>;
|
|
376
314
|
}
|
|
377
315
|
|
|
378
|
-
declare interface LayersFetchConfig {
|
|
379
|
-
layersPublicToken: string;
|
|
380
|
-
layersBaseUrl?: string;
|
|
381
|
-
fetch?: CustomFetch;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
316
|
declare interface LayersMeta {
|
|
385
317
|
experimentsRan?: {
|
|
386
318
|
id: string;
|
|
@@ -418,36 +350,20 @@ declare interface LayersResponse extends LayersPagination, LayersFacets {
|
|
|
418
350
|
|
|
419
351
|
declare type LayersResult = ProductResult | VariantResult;
|
|
420
352
|
|
|
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
353
|
declare interface LayersVariant {
|
|
431
354
|
id: number;
|
|
432
355
|
title: string;
|
|
433
|
-
available: boolean;
|
|
434
|
-
sku: string;
|
|
435
356
|
price: string;
|
|
436
|
-
|
|
437
|
-
selected_options: {
|
|
438
|
-
name: string;
|
|
439
|
-
value: string;
|
|
440
|
-
optionValue?: {
|
|
441
|
-
swatch?: unknown | null;
|
|
442
|
-
linkedMetafieldValue?: unknown | null;
|
|
443
|
-
};
|
|
444
|
-
}[];
|
|
357
|
+
sku: string | null;
|
|
445
358
|
position: number;
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
359
|
+
compare_at_price: string | null;
|
|
360
|
+
selected_options: SelectedOption[];
|
|
361
|
+
created_at: string;
|
|
362
|
+
updated_at: string;
|
|
363
|
+
available: boolean;
|
|
364
|
+
featured_media: FeaturedMedia_2 | null;
|
|
365
|
+
requires_selling_plan: boolean | null;
|
|
366
|
+
has_selling_plan: boolean | null;
|
|
451
367
|
inventory_levels?: InventoryLevels;
|
|
452
368
|
in_stock_location_ids?: number[];
|
|
453
369
|
}
|
|
@@ -476,31 +392,12 @@ declare interface MetafieldIdentifier {
|
|
|
476
392
|
key: string;
|
|
477
393
|
}
|
|
478
394
|
|
|
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
395
|
export declare interface NetworkError {
|
|
497
396
|
readonly _tag: 'NetworkError';
|
|
498
397
|
readonly code: NetworkErrorCode;
|
|
499
398
|
readonly message: string;
|
|
500
|
-
readonly timestamp: string;
|
|
501
399
|
readonly retryable: boolean;
|
|
502
400
|
readonly retryAfterMs?: number;
|
|
503
|
-
readonly request?: RequestContext;
|
|
504
401
|
readonly cause?: unknown;
|
|
505
402
|
}
|
|
506
403
|
|
|
@@ -512,10 +409,15 @@ export declare function notExists(property: string): FilterExpression;
|
|
|
512
409
|
|
|
513
410
|
export declare function notIn(property: string, values: FilterValue[]): FilterExpression;
|
|
514
411
|
|
|
515
|
-
declare
|
|
412
|
+
export declare interface OptionGroup {
|
|
413
|
+
name: string;
|
|
414
|
+
values: OptionValue[];
|
|
415
|
+
}
|
|
516
416
|
|
|
517
417
|
declare type OptionSegment = `${string}:${string}`;
|
|
518
418
|
|
|
419
|
+
export declare type OptionStatus = 'available' | 'backorderable' | 'sold-out' | 'unavailable';
|
|
420
|
+
|
|
519
421
|
declare interface OptionV2 {
|
|
520
422
|
name: string;
|
|
521
423
|
code: string;
|
|
@@ -524,127 +426,109 @@ declare interface OptionV2 {
|
|
|
524
426
|
swatch: {
|
|
525
427
|
color: string | null;
|
|
526
428
|
image: {
|
|
527
|
-
alt: string;
|
|
528
|
-
url: string;
|
|
429
|
+
alt: string | null;
|
|
430
|
+
url: string | null;
|
|
529
431
|
} | null;
|
|
530
432
|
} | null;
|
|
531
|
-
linked_metafield_value: unknown
|
|
433
|
+
linked_metafield_value: unknown;
|
|
532
434
|
}[];
|
|
533
435
|
}
|
|
534
436
|
|
|
535
|
-
declare interface
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
437
|
+
export declare interface OptionValue {
|
|
438
|
+
value: string;
|
|
439
|
+
status: OptionStatus;
|
|
440
|
+
selected: boolean;
|
|
441
|
+
swatch: Swatch | null;
|
|
539
442
|
}
|
|
540
443
|
|
|
541
444
|
export declare function or(...expressions: (FilterExpression | FilterGroup)[]): FilterGroup;
|
|
542
445
|
|
|
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
446
|
export declare interface Price {
|
|
573
447
|
amount: number;
|
|
574
448
|
currencyCode: string;
|
|
575
449
|
formatted: string;
|
|
576
450
|
}
|
|
577
451
|
|
|
452
|
+
export declare interface PriceData {
|
|
453
|
+
price: Price | null;
|
|
454
|
+
compareAtPrice: Price | null;
|
|
455
|
+
isOnSale: boolean;
|
|
456
|
+
}
|
|
457
|
+
|
|
578
458
|
export declare interface PriceRange {
|
|
579
459
|
min: Price;
|
|
580
460
|
max: Price;
|
|
581
461
|
}
|
|
582
462
|
|
|
583
|
-
declare interface
|
|
584
|
-
|
|
585
|
-
|
|
463
|
+
export declare interface PriceRangeData {
|
|
464
|
+
priceRange: PriceRange;
|
|
465
|
+
compareAtPriceRange: PriceRange | null;
|
|
586
466
|
}
|
|
587
467
|
|
|
588
|
-
export declare
|
|
468
|
+
export declare type Product<T extends Record<string, unknown> = Record<string, unknown>> = ProductBase & T;
|
|
469
|
+
|
|
470
|
+
export declare interface ProductBase {
|
|
589
471
|
id: CommerceBlocksID;
|
|
590
472
|
gid: ProductGID;
|
|
591
473
|
numericId: number;
|
|
592
474
|
title: string;
|
|
593
475
|
handle: string;
|
|
594
|
-
type: string;
|
|
595
476
|
vendor: string;
|
|
596
|
-
|
|
477
|
+
type: string;
|
|
597
478
|
availableForSale: boolean;
|
|
479
|
+
tags: string[];
|
|
598
480
|
images: Image_2[];
|
|
481
|
+
featuredMedia: FeaturedMedia | null;
|
|
599
482
|
priceRange: PriceRange;
|
|
600
|
-
compareAtPriceRange
|
|
483
|
+
compareAtPriceRange: PriceRange | undefined;
|
|
601
484
|
options: RichProductOption[];
|
|
602
|
-
tags: string[];
|
|
603
|
-
variants: ProductVariant[];
|
|
604
485
|
selectedOptions: ProductOption[];
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
486
|
+
variants: ProductVariant[];
|
|
487
|
+
selectedVariant: ProductVariant | null;
|
|
488
|
+
metafields: Record<string, Record<string, unknown>>;
|
|
489
|
+
calculated: Record<string, unknown>;
|
|
608
490
|
category: ProductCategory | null;
|
|
609
|
-
createdAt: string | null;
|
|
610
|
-
publishedAt: string | null;
|
|
611
|
-
updatedAt: string | null;
|
|
612
|
-
featuredMedia: FeaturedMedia | null;
|
|
613
|
-
namedTags?: NamedTag[];
|
|
614
491
|
combinedListingParentProductId: number | null;
|
|
615
492
|
combinedListingRole: string | null;
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
selectedVariant: ProductVariant | null;
|
|
619
|
-
breakoutOptions?: ProductOption[];
|
|
620
|
-
breakoutVariantId?: number;
|
|
493
|
+
breakoutOptions: ProductOption[];
|
|
494
|
+
breakoutVariantId: number | null;
|
|
621
495
|
}
|
|
622
496
|
|
|
623
497
|
export declare interface ProductCardController {
|
|
624
498
|
product: Product;
|
|
625
499
|
variants: ReadonlySignal<ProductVariant[]>;
|
|
626
500
|
selectedVariant: ReadonlySignal<ProductVariant | null>;
|
|
627
|
-
|
|
628
|
-
options: ReadonlySignal<RichProductOption[]>;
|
|
629
|
-
optionNames: ReadonlySignal<string[]>;
|
|
630
|
-
swatchOptionName: ReadonlySignal<string | null>;
|
|
501
|
+
options: ReadonlySignal<OptionGroup[]>;
|
|
631
502
|
images: ReadonlySignal<Image_2[]>;
|
|
632
|
-
|
|
633
|
-
|
|
503
|
+
price: ReadonlySignal<PriceData>;
|
|
504
|
+
priceRange: ReadonlySignal<PriceRangeData>;
|
|
505
|
+
carouselPosition: ReadonlySignal<number>;
|
|
634
506
|
isSelectionComplete: ReadonlySignal<boolean>;
|
|
635
|
-
selectOption(
|
|
507
|
+
selectOption(option: ProductOption): void;
|
|
636
508
|
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;
|
|
509
|
+
setSelectedVariant(variantId: number): void;
|
|
510
|
+
setCarouselPosition(position: number): void;
|
|
511
|
+
subscribe(callback: (state: ProductCardState) => void): Unsubscribe_2;
|
|
645
512
|
dispose(): void;
|
|
646
513
|
}
|
|
647
514
|
|
|
515
|
+
export declare interface ProductCardOptions {
|
|
516
|
+
product: Product;
|
|
517
|
+
selectedOptions?: ProductOption[];
|
|
518
|
+
breakoutOptions?: ProductOption[];
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
export declare interface ProductCardState {
|
|
522
|
+
variants: ProductVariant[];
|
|
523
|
+
selectedVariant: ProductVariant | null;
|
|
524
|
+
options: OptionGroup[];
|
|
525
|
+
images: Image_2[];
|
|
526
|
+
price: PriceData;
|
|
527
|
+
priceRange: PriceRangeData;
|
|
528
|
+
carouselPosition: number;
|
|
529
|
+
isSelectionComplete: boolean;
|
|
530
|
+
}
|
|
531
|
+
|
|
648
532
|
declare interface ProductCategory {
|
|
649
533
|
id: string;
|
|
650
534
|
name: string;
|
|
@@ -661,19 +545,19 @@ declare interface ProductCategory_2 {
|
|
|
661
545
|
is_root: boolean;
|
|
662
546
|
}
|
|
663
547
|
|
|
664
|
-
declare type ProductExtender
|
|
548
|
+
declare type ProductExtender = (input: ProductExtenderInput) => Record<string, unknown>;
|
|
665
549
|
|
|
666
550
|
declare interface ProductExtenderInput {
|
|
667
551
|
base: Product;
|
|
668
552
|
raw: LayersResult;
|
|
669
|
-
storefront: StorefrontProduct | null;
|
|
670
553
|
}
|
|
671
554
|
|
|
672
555
|
declare type ProductGID = ShopifyGID<'Product'>;
|
|
673
556
|
|
|
674
557
|
declare interface ProductImage {
|
|
675
|
-
|
|
558
|
+
id: number;
|
|
676
559
|
src: string;
|
|
560
|
+
alt: string | null;
|
|
677
561
|
width: number;
|
|
678
562
|
height: number;
|
|
679
563
|
position?: number;
|
|
@@ -685,45 +569,40 @@ export declare interface ProductOption {
|
|
|
685
569
|
value: string;
|
|
686
570
|
}
|
|
687
571
|
|
|
688
|
-
declare interface ProductOptionResult {
|
|
689
|
-
id: string;
|
|
690
|
-
name: string;
|
|
691
|
-
optionValues: OptionValueResult[];
|
|
692
|
-
}
|
|
693
|
-
|
|
694
572
|
declare interface ProductResult {
|
|
695
573
|
__typename?: 'Product';
|
|
696
574
|
id: number;
|
|
697
575
|
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?: {
|
|
576
|
+
handle: string;
|
|
577
|
+
available: boolean;
|
|
578
|
+
vendor: string | null;
|
|
579
|
+
product_type: string | null;
|
|
580
|
+
combined_listing_role: string | null;
|
|
581
|
+
combined_listing_parent_product_id: number | null;
|
|
582
|
+
featured_media: FeaturedMedia_2 | null;
|
|
583
|
+
category: ProductCategory_2 | null;
|
|
584
|
+
tags: string[];
|
|
585
|
+
images: ProductImage[];
|
|
586
|
+
collection_titles: string[];
|
|
587
|
+
metafields: Record<string, Record<string, unknown>>;
|
|
588
|
+
calculated: Record<string, unknown>;
|
|
589
|
+
price_range: {
|
|
716
590
|
from: number;
|
|
717
591
|
to: number;
|
|
718
|
-
compare_at_price
|
|
592
|
+
compare_at_price: number;
|
|
719
593
|
};
|
|
720
|
-
options
|
|
594
|
+
options: Record<string, string[]>;
|
|
595
|
+
options_v2: OptionV2[];
|
|
596
|
+
body_html?: string | null;
|
|
597
|
+
is_gift_card?: boolean | null;
|
|
598
|
+
has_variants_that_require_components?: boolean | null;
|
|
599
|
+
named_tags?: Record<string, string[]>;
|
|
721
600
|
original_options?: Record<string, string[]>;
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
variants
|
|
601
|
+
created_at?: string;
|
|
602
|
+
updated_at?: string;
|
|
603
|
+
published_at?: string;
|
|
604
|
+
first_or_matched_variant?: MatchedVariant;
|
|
605
|
+
variants: LayersVariant[];
|
|
727
606
|
}
|
|
728
607
|
|
|
729
608
|
export declare interface ProductVariant {
|
|
@@ -731,15 +610,13 @@ export declare interface ProductVariant {
|
|
|
731
610
|
gid: VariantGID;
|
|
732
611
|
numericId: number;
|
|
733
612
|
title: string;
|
|
734
|
-
availableForSale: boolean;
|
|
735
|
-
currentlyNotInStock: boolean;
|
|
736
613
|
sku: string | null;
|
|
737
614
|
position: number;
|
|
615
|
+
availableForSale: boolean;
|
|
738
616
|
price: Price;
|
|
739
617
|
compareAtPrice: Price | null;
|
|
740
618
|
image: Image_2 | null;
|
|
741
619
|
selectedOptions: ProductOption[];
|
|
742
|
-
metafields: Metafield[];
|
|
743
620
|
inventoryLevels: InventoryLevels;
|
|
744
621
|
inventoryPolicy: 'DENY' | 'CONTINUE' | null;
|
|
745
622
|
inStockLocationIds: number[];
|
|
@@ -747,45 +624,30 @@ export declare interface ProductVariant {
|
|
|
747
624
|
hasSellingPlan: boolean;
|
|
748
625
|
}
|
|
749
626
|
|
|
750
|
-
declare type Queries<P extends Product = Product> = Record<string, QueryResult<P>>;
|
|
751
|
-
|
|
752
627
|
export declare interface QueryParams {
|
|
753
628
|
page?: number;
|
|
754
629
|
limit?: number;
|
|
755
630
|
filters?: unknown;
|
|
756
631
|
signal?: AbortSignal;
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
paramDefinitions?: ParamDefinitions;
|
|
760
|
-
transformBody?: BodyTransformer;
|
|
632
|
+
linking?: Record<string, string | number | (string | number)[]>;
|
|
633
|
+
transformRequest?: RequestTransformer;
|
|
761
634
|
}
|
|
762
635
|
|
|
763
|
-
declare interface QueryResult
|
|
764
|
-
products:
|
|
636
|
+
declare interface QueryResult extends Omit<LayersResponse, 'results' | 'facets'> {
|
|
637
|
+
products: Product[];
|
|
765
638
|
facets: Record<string, Record<string, number>>;
|
|
766
639
|
priceRange?: PriceRange;
|
|
767
640
|
}
|
|
768
641
|
|
|
769
642
|
export declare interface QueryState<T> {
|
|
770
643
|
data: T | null;
|
|
771
|
-
error:
|
|
644
|
+
error: ClientError | null;
|
|
772
645
|
isFetching: boolean;
|
|
773
646
|
}
|
|
774
647
|
|
|
775
648
|
export { ReadonlySignal }
|
|
776
649
|
|
|
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
|
-
}
|
|
650
|
+
export declare type RequestTransformer = (body: Record<string, unknown>) => Record<string, unknown>;
|
|
789
651
|
|
|
790
652
|
declare type Result<T, E = Error> = {
|
|
791
653
|
data: T;
|
|
@@ -799,92 +661,62 @@ export declare interface RichProductOption extends ProductOption {
|
|
|
799
661
|
swatch?: Swatch;
|
|
800
662
|
}
|
|
801
663
|
|
|
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>;
|
|
664
|
+
export declare interface SearchByImageController {
|
|
665
|
+
readonly state: ReadonlySignal<QueryState<SearchResult>>;
|
|
666
|
+
subscribe(callback: (state: QueryState<SearchResult>) => void): Unsubscribe;
|
|
667
|
+
dispose(): void;
|
|
812
668
|
}
|
|
813
669
|
|
|
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;
|
|
670
|
+
export declare interface SearchByImageQuery extends QueryParams {
|
|
671
|
+
imageId: string;
|
|
672
|
+
tuning?: SearchTuning;
|
|
857
673
|
}
|
|
858
674
|
|
|
859
|
-
export declare
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
execute(query?: SearchQuery): Promise<Result<SearchResult<P>, SdkError>>;
|
|
865
|
-
subscribe(callback: (state: QueryState<SearchResult<P>>) => void): Unsubscribe;
|
|
675
|
+
export declare interface SearchController {
|
|
676
|
+
readonly state: ReadonlySignal<QueryState<SearchResult>>;
|
|
677
|
+
prepare(query?: SearchQuery): Promise<Result<SearchPrepareResult, ClientError>>;
|
|
678
|
+
execute(query?: SearchQuery): Promise<Result<SearchResult, ClientError>>;
|
|
679
|
+
subscribe(callback: (state: QueryState<SearchResult>) => void): Unsubscribe;
|
|
866
680
|
dispose(): void;
|
|
867
681
|
}
|
|
868
682
|
|
|
869
|
-
export declare
|
|
683
|
+
export declare interface SearchPrepareResult {
|
|
684
|
+
searchId: string;
|
|
685
|
+
}
|
|
870
686
|
|
|
871
687
|
export declare interface SearchQuery extends QueryParams {
|
|
872
688
|
query?: string;
|
|
873
689
|
searchId?: string;
|
|
874
|
-
tuning?:
|
|
875
|
-
|
|
690
|
+
tuning?: SearchTuning;
|
|
691
|
+
temporary?: boolean;
|
|
876
692
|
}
|
|
877
693
|
|
|
878
|
-
export declare type SearchResult
|
|
694
|
+
export declare type SearchResult = QueryResult;
|
|
879
695
|
|
|
880
|
-
declare interface
|
|
881
|
-
|
|
882
|
-
|
|
696
|
+
declare interface SearchTuning {
|
|
697
|
+
textualWeight?: number;
|
|
698
|
+
visualWeight?: number;
|
|
699
|
+
multipleFactor?: number;
|
|
700
|
+
minimumMatch?: number;
|
|
701
|
+
missingEmbeddingScore?: number;
|
|
702
|
+
highSignalWeight?: number;
|
|
883
703
|
}
|
|
884
704
|
|
|
885
|
-
declare interface
|
|
886
|
-
|
|
887
|
-
|
|
705
|
+
declare interface SelectedOption {
|
|
706
|
+
name: string;
|
|
707
|
+
value: string;
|
|
708
|
+
optionValue?: {
|
|
709
|
+
swatch?: {
|
|
710
|
+
color: string | null;
|
|
711
|
+
image: {
|
|
712
|
+
image: {
|
|
713
|
+
url: string;
|
|
714
|
+
altText: string | null;
|
|
715
|
+
};
|
|
716
|
+
} | null;
|
|
717
|
+
};
|
|
718
|
+
linkedMetafieldValue?: unknown;
|
|
719
|
+
};
|
|
888
720
|
}
|
|
889
721
|
|
|
890
722
|
declare type ServiceError = NetworkError | ApiError | ValidationError;
|
|
@@ -912,149 +744,31 @@ export declare interface StorageAdapter {
|
|
|
912
744
|
remove(): void;
|
|
913
745
|
}
|
|
914
746
|
|
|
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
|
-
}
|
|
747
|
+
/**
|
|
748
|
+
* Subscribe to state changes. Callback fires immediately, then on every change.
|
|
749
|
+
*/
|
|
750
|
+
export declare function subscribe<T>(state: ReadonlySignal<T>, callback: (value: T) => void): () => void;
|
|
973
751
|
|
|
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)[];
|
|
752
|
+
export declare interface SuggestController {
|
|
753
|
+
readonly state: ReadonlySignal<QueryState<Suggestions>>;
|
|
754
|
+
execute(query: string): void;
|
|
755
|
+
subscribe(callback: (state: QueryState<Suggestions>) => void): Unsubscribe;
|
|
756
|
+
dispose(): void;
|
|
985
757
|
}
|
|
986
758
|
|
|
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)[];
|
|
759
|
+
declare interface Suggestions {
|
|
760
|
+
matchedQueries: string[];
|
|
761
|
+
originalQuery: string;
|
|
762
|
+
normalizedQuery: string;
|
|
1010
763
|
}
|
|
1011
764
|
|
|
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
|
-
}[];
|
|
765
|
+
export declare interface SuggestOptions {
|
|
766
|
+
debounce?: number;
|
|
767
|
+
excludeInputQuery?: boolean;
|
|
768
|
+
excludeQueries?: string[];
|
|
1035
769
|
signal?: AbortSignal;
|
|
1036
770
|
}
|
|
1037
771
|
|
|
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
772
|
export declare interface Swatch {
|
|
1059
773
|
name: string | null;
|
|
1060
774
|
value: string;
|
|
@@ -1062,17 +776,26 @@ export declare interface Swatch {
|
|
|
1062
776
|
imageUrl: string | null;
|
|
1063
777
|
}
|
|
1064
778
|
|
|
1065
|
-
declare interface
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
}
|
|
779
|
+
export declare interface Transforms {
|
|
780
|
+
product?: ProductExtender;
|
|
781
|
+
collection?: (result: CollectionResult, raw: LayersResponse) => CollectionResult;
|
|
782
|
+
search?: (result: SearchResult, raw: LayersResponse) => SearchResult;
|
|
783
|
+
block?: (result: BlocksResult, raw: LayersResponse & {
|
|
784
|
+
block?: BlocksInfo;
|
|
785
|
+
}) => BlocksResult;
|
|
786
|
+
filters?: (filters: unknown) => FilterGroup | undefined;
|
|
1072
787
|
}
|
|
1073
788
|
|
|
1074
789
|
export declare type Unsubscribe = () => void;
|
|
1075
790
|
|
|
791
|
+
declare type Unsubscribe_2 = () => void;
|
|
792
|
+
|
|
793
|
+
export declare interface UploadImageController {
|
|
794
|
+
readonly state: ReadonlySignal<QueryState<UploadImageResult>>;
|
|
795
|
+
subscribe(callback: (state: QueryState<UploadImageResult>) => void): Unsubscribe;
|
|
796
|
+
dispose(): void;
|
|
797
|
+
}
|
|
798
|
+
|
|
1076
799
|
export declare interface UploadImageOptions {
|
|
1077
800
|
image: File | Blob;
|
|
1078
801
|
signal?: AbortSignal;
|
|
@@ -1086,28 +809,21 @@ export declare interface ValidationError {
|
|
|
1086
809
|
readonly _tag: 'ValidationError';
|
|
1087
810
|
readonly code: 'VALIDATION_FAILED';
|
|
1088
811
|
readonly message: string;
|
|
1089
|
-
readonly timestamp: string;
|
|
1090
812
|
readonly operation: string;
|
|
1091
813
|
readonly fields: ValidationFieldError[];
|
|
1092
814
|
readonly input?: unknown;
|
|
1093
815
|
}
|
|
1094
816
|
|
|
1095
|
-
declare type ValidationErrorCode = 'REQUIRED_FIELD' | '
|
|
817
|
+
declare type ValidationErrorCode = 'REQUIRED_FIELD' | 'OUT_OF_RANGE';
|
|
1096
818
|
|
|
1097
819
|
declare interface ValidationFieldError {
|
|
1098
|
-
readonly path: string[];
|
|
1099
820
|
readonly field: string;
|
|
1100
821
|
readonly code: ValidationErrorCode;
|
|
1101
822
|
readonly message: string;
|
|
1102
823
|
readonly value?: unknown;
|
|
1103
|
-
readonly expected?: string;
|
|
1104
824
|
readonly constraints?: {
|
|
1105
825
|
min?: number;
|
|
1106
826
|
max?: number;
|
|
1107
|
-
minLength?: number;
|
|
1108
|
-
maxLength?: number;
|
|
1109
|
-
pattern?: string;
|
|
1110
|
-
allowedValues?: string[];
|
|
1111
827
|
};
|
|
1112
828
|
}
|
|
1113
829
|
|
|
@@ -1129,17 +845,6 @@ declare interface VariantResult extends Omit<ProductResult, '__typename'> {
|
|
|
1129
845
|
variant_id: number;
|
|
1130
846
|
}
|
|
1131
847
|
|
|
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
|
-
}
|
|
848
|
+
export declare function xhrFetch(url: string, init?: RequestInit): Promise<Response>;
|
|
1144
849
|
|
|
1145
850
|
export { }
|