@commerce-blocks/sdk 2.0.0-alpha.0 → 2.0.0-alpha.2
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 +199 -93
- package/dist/index.d.ts +141 -154
- package/dist/index.js +1178 -1105
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -26,14 +26,15 @@ export declare interface ApiError {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
declare type ApiErrorCode = 'UNAUTHORIZED' | 'FORBIDDEN' | 'NOT_FOUND' | 'RATE_LIMITED' | 'SERVICE_UNAVAILABLE' | 'GRAPHQL_ERROR' | 'PARSE_ERROR' | 'UNKNOWN';
|
|
29
|
+
declare type ApiErrorCode = 'UNAUTHORIZED' | 'FORBIDDEN' | 'NOT_FOUND' | 'NOT_READY' | 'RATE_LIMITED' | 'SERVICE_UNAVAILABLE' | 'GRAPHQL_ERROR' | 'PARSE_ERROR' | 'UNKNOWN';
|
|
30
30
|
|
|
31
31
|
declare type ApiSource = 'layers' | 'storefront';
|
|
32
32
|
|
|
33
33
|
export declare interface AutocompleteController {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
readonly state: ReadonlySignal<QueryState<PredictiveSearchResponse>>;
|
|
35
|
+
execute(query: string): void;
|
|
36
|
+
subscribe(callback: (state: QueryState<PredictiveSearchResponse>) => void): Unsubscribe;
|
|
37
|
+
dispose(): void;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
export declare interface AutocompleteOptions {
|
|
@@ -41,49 +42,6 @@ export declare interface AutocompleteOptions {
|
|
|
41
42
|
signal?: AbortSignal;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
declare interface BaseProduct {
|
|
45
|
-
id: ID;
|
|
46
|
-
gid: ProductGID;
|
|
47
|
-
numericId: number;
|
|
48
|
-
title: string;
|
|
49
|
-
handle: string;
|
|
50
|
-
type: string;
|
|
51
|
-
vendor: string;
|
|
52
|
-
description: string;
|
|
53
|
-
availableForSale: boolean;
|
|
54
|
-
images: Image_2[];
|
|
55
|
-
priceRange: {
|
|
56
|
-
min: Price;
|
|
57
|
-
max: Price;
|
|
58
|
-
};
|
|
59
|
-
compareAtPriceRange?: {
|
|
60
|
-
min: Price;
|
|
61
|
-
max: Price;
|
|
62
|
-
};
|
|
63
|
-
options: RichProductOption[];
|
|
64
|
-
tags: string[];
|
|
65
|
-
variants: ProductVariant[];
|
|
66
|
-
selectedOptions: ProductOption[];
|
|
67
|
-
metafields: Record<string, Record<string, unknown>> | unknown[];
|
|
68
|
-
calculated?: Record<string, unknown>;
|
|
69
|
-
isGiftCard: boolean;
|
|
70
|
-
category: ProductCategory | null;
|
|
71
|
-
createdAt: string | null;
|
|
72
|
-
publishedAt: string | null;
|
|
73
|
-
updatedAt: string | null;
|
|
74
|
-
featuredMedia: FeaturedMedia | null;
|
|
75
|
-
namedTags?: NamedTag[];
|
|
76
|
-
combinedListingParentProductId: number | null;
|
|
77
|
-
combinedListingRole: string | null;
|
|
78
|
-
hasVariantsThatRequireComponents: boolean;
|
|
79
|
-
originalOptions: Record<string, string[]>;
|
|
80
|
-
selectedVariant: ProductVariant | null;
|
|
81
|
-
breakoutOptions?: ProductOption[];
|
|
82
|
-
breakoutVariantId?: number;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
declare type BaseResult<P extends Product = Product> = QueryResult<P>;
|
|
86
|
-
|
|
87
45
|
export { batch }
|
|
88
46
|
|
|
89
47
|
declare interface BlocksContext {
|
|
@@ -101,22 +59,10 @@ declare interface BlocksContext {
|
|
|
101
59
|
}
|
|
102
60
|
|
|
103
61
|
export declare interface BlocksController<P extends Product = Product> {
|
|
104
|
-
state: ReadonlySignal<QueryState<BlocksResult<P>>>;
|
|
105
|
-
execute
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
export declare interface BlocksExecuteQuery {
|
|
110
|
-
page?: number;
|
|
111
|
-
limit?: number;
|
|
112
|
-
filters?: unknown;
|
|
113
|
-
signal?: AbortSignal;
|
|
114
|
-
discountEntitlements?: DiscountEntitlement[];
|
|
115
|
-
context?: BlocksContext;
|
|
116
|
-
dynamicLinking?: Record<string, string | number | (string | number)[]>;
|
|
117
|
-
params?: Record<string, unknown>;
|
|
118
|
-
paramDefinitions?: ParamDefinitions;
|
|
119
|
-
transformBody?: BodyTransformer;
|
|
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;
|
|
120
66
|
}
|
|
121
67
|
|
|
122
68
|
export declare type BlocksExtender<P extends Product = Product> = (result: BlocksResult<P>, raw: LayersResponse & {
|
|
@@ -135,37 +81,29 @@ declare interface BlocksInfo {
|
|
|
135
81
|
export declare interface BlocksOptions {
|
|
136
82
|
blockId: string;
|
|
137
83
|
anchorId?: string;
|
|
138
|
-
anchorHandle?: string;
|
|
139
84
|
}
|
|
140
85
|
|
|
141
|
-
export declare interface
|
|
86
|
+
export declare interface BlocksQuery extends QueryParams {
|
|
87
|
+
discountEntitlements?: DiscountEntitlement[];
|
|
88
|
+
context?: BlocksContext;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export declare interface BlocksResult<P extends Product = Product> extends QueryResult<P> {
|
|
142
92
|
block?: BlocksInfo;
|
|
143
93
|
}
|
|
144
94
|
|
|
145
95
|
export declare type BodyTransformer = (body: Record<string, unknown>) => Record<string, unknown>;
|
|
146
96
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
dispose: () => void;
|
|
97
|
+
declare interface CacheEntry<T> {
|
|
98
|
+
data: T;
|
|
99
|
+
timestamp: number;
|
|
151
100
|
}
|
|
152
101
|
|
|
153
|
-
export declare interface
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
signal?: AbortSignal;
|
|
159
|
-
includeMeta?: boolean;
|
|
160
|
-
collectionMetafields?: {
|
|
161
|
-
namespace: string;
|
|
162
|
-
key: string;
|
|
163
|
-
}[];
|
|
164
|
-
includeFilters?: boolean;
|
|
165
|
-
dynamicLinking?: Record<string, string | number | (string | number)[]>;
|
|
166
|
-
params?: Record<string, unknown>;
|
|
167
|
-
paramDefinitions?: ParamDefinitions;
|
|
168
|
-
transformBody?: BodyTransformer;
|
|
102
|
+
export declare interface CollectionController<P extends Product = Product> {
|
|
103
|
+
readonly state: ReadonlySignal<QueryState<CollectionResult<P>>>;
|
|
104
|
+
execute(query?: CollectionQuery): Promise<Result<CollectionResult<P>, SdkError>>;
|
|
105
|
+
subscribe(callback: (state: QueryState<CollectionResult<P>>) => void): Unsubscribe;
|
|
106
|
+
dispose(): void;
|
|
169
107
|
}
|
|
170
108
|
|
|
171
109
|
export declare type CollectionExtender<P extends Product = Product> = (result: CollectionResult<P>, raw: LayersResponse) => CollectionResult<P>;
|
|
@@ -181,7 +119,7 @@ declare interface CollectionMeta {
|
|
|
181
119
|
width?: number;
|
|
182
120
|
height?: number;
|
|
183
121
|
};
|
|
184
|
-
metafields?: (
|
|
122
|
+
metafields?: (Metafield | null)[];
|
|
185
123
|
totalProducts: number;
|
|
186
124
|
totalPages: number;
|
|
187
125
|
lastPageFetched: number;
|
|
@@ -194,7 +132,17 @@ export declare interface CollectionOptions {
|
|
|
194
132
|
defaultSort?: string;
|
|
195
133
|
}
|
|
196
134
|
|
|
197
|
-
export declare interface
|
|
135
|
+
export declare interface CollectionQuery extends QueryParams {
|
|
136
|
+
sortOrderCode?: string;
|
|
137
|
+
includeMeta?: boolean;
|
|
138
|
+
collectionMetafields?: {
|
|
139
|
+
namespace: string;
|
|
140
|
+
key: string;
|
|
141
|
+
}[];
|
|
142
|
+
includeFilters?: boolean;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export declare interface CollectionResult<P extends Product = Product> extends QueryResult<P> {
|
|
198
146
|
collection?: StorefrontCollection;
|
|
199
147
|
}
|
|
200
148
|
|
|
@@ -218,6 +166,13 @@ export declare interface ConfigError {
|
|
|
218
166
|
|
|
219
167
|
declare type ConfigErrorCode = 'MISSING_CONFIG' | 'INVALID_CONFIG';
|
|
220
168
|
|
|
169
|
+
export declare interface Controller<TData, TQuery = void> {
|
|
170
|
+
readonly state: ReadonlySignal<QueryState<TData>>;
|
|
171
|
+
execute(query: TQuery): Promise<Result<TData, SdkError>>;
|
|
172
|
+
subscribe(callback: (state: QueryState<TData>) => void): Unsubscribe;
|
|
173
|
+
dispose(): void;
|
|
174
|
+
}
|
|
175
|
+
|
|
221
176
|
export declare function createProductCard({ product, selectedOptions: initialSelectedOptions, breakoutOptions: initialBreakoutOptions, }: CreateProductCardParams): ProductCardController;
|
|
222
177
|
|
|
223
178
|
export declare interface CreateProductCardParams {
|
|
@@ -245,17 +200,12 @@ declare interface DiscountEntitlement {
|
|
|
245
200
|
|
|
246
201
|
export { effect }
|
|
247
202
|
|
|
248
|
-
declare interface Entry<T> {
|
|
249
|
-
data: T;
|
|
250
|
-
timestamp: number;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
203
|
export declare function eq(property: string, value: FilterValue): FilterExpression;
|
|
254
204
|
|
|
255
205
|
export declare function exists(property: string): FilterExpression;
|
|
256
206
|
|
|
257
|
-
declare interface ExtendedProduct extends
|
|
258
|
-
_base:
|
|
207
|
+
declare interface ExtendedProduct extends Product {
|
|
208
|
+
_base: Product;
|
|
259
209
|
}
|
|
260
210
|
|
|
261
211
|
declare interface Facet {
|
|
@@ -342,6 +292,13 @@ declare interface FilterValueResult {
|
|
|
342
292
|
input: string;
|
|
343
293
|
}
|
|
344
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
|
+
|
|
345
302
|
export declare function getSdk(): Result<Sdk, ConfigError>;
|
|
346
303
|
|
|
347
304
|
declare interface GraphQLErrorDetail {
|
|
@@ -369,8 +326,6 @@ export declare function gte(property: string, value: number): FilterExpression;
|
|
|
369
326
|
*/
|
|
370
327
|
declare type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
371
328
|
|
|
372
|
-
declare type ID = CommerceBlocksID;
|
|
373
|
-
|
|
374
329
|
declare interface Image_2 {
|
|
375
330
|
url: string;
|
|
376
331
|
alt: string;
|
|
@@ -388,17 +343,9 @@ declare interface ImageResult {
|
|
|
388
343
|
height: number;
|
|
389
344
|
}
|
|
390
345
|
|
|
391
|
-
export declare interface
|
|
346
|
+
export declare interface ImageSearchQuery extends QueryParams {
|
|
392
347
|
imageId: string;
|
|
393
|
-
page?: number;
|
|
394
|
-
limit?: number;
|
|
395
|
-
filters?: unknown;
|
|
396
348
|
tuning?: LayersTuning;
|
|
397
|
-
signal?: AbortSignal;
|
|
398
|
-
dynamicLinking?: Record<string, string | number | (string | number)[]>;
|
|
399
|
-
params?: Record<string, unknown>;
|
|
400
|
-
paramDefinitions?: ParamDefinitions;
|
|
401
|
-
transformBody?: BodyTransformer;
|
|
402
349
|
}
|
|
403
350
|
|
|
404
351
|
export declare function inValues(property: string, values: FilterValue[]): FilterExpression;
|
|
@@ -443,6 +390,16 @@ declare interface LayersMeta {
|
|
|
443
390
|
variantBreakouts?: {
|
|
444
391
|
optionCode: string;
|
|
445
392
|
}[];
|
|
393
|
+
redirect?: {
|
|
394
|
+
url: string;
|
|
395
|
+
};
|
|
396
|
+
timings?: {
|
|
397
|
+
embedding?: number;
|
|
398
|
+
query_expansion?: number;
|
|
399
|
+
intent_modifiers?: number;
|
|
400
|
+
prepare_total?: number;
|
|
401
|
+
query?: number;
|
|
402
|
+
};
|
|
446
403
|
}
|
|
447
404
|
|
|
448
405
|
declare interface LayersPagination {
|
|
@@ -466,6 +423,8 @@ declare interface LayersTuning {
|
|
|
466
423
|
visualWeight?: number;
|
|
467
424
|
multipleFactor?: number;
|
|
468
425
|
minimumMatch?: number;
|
|
426
|
+
missingEmbeddingScore?: number;
|
|
427
|
+
highSignalWeight?: number;
|
|
469
428
|
}
|
|
470
429
|
|
|
471
430
|
declare interface LayersVariant {
|
|
@@ -524,13 +483,6 @@ declare interface MetafieldResult {
|
|
|
524
483
|
type: string;
|
|
525
484
|
}
|
|
526
485
|
|
|
527
|
-
declare interface MetafieldResult_2 {
|
|
528
|
-
namespace: string;
|
|
529
|
-
key: string;
|
|
530
|
-
value: string;
|
|
531
|
-
type: string;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
486
|
declare interface MoneyResult {
|
|
535
487
|
amount: string;
|
|
536
488
|
currencyCode: string;
|
|
@@ -609,15 +561,8 @@ declare interface PredictiveSearchResponse {
|
|
|
609
561
|
normalizedQuery: string;
|
|
610
562
|
}
|
|
611
563
|
|
|
612
|
-
export declare interface
|
|
613
|
-
query:
|
|
614
|
-
filters?: unknown;
|
|
615
|
-
tuning?: LayersTuning;
|
|
616
|
-
signal?: AbortSignal;
|
|
617
|
-
dynamicLinking?: Record<string, string | number | (string | number)[]>;
|
|
618
|
-
params?: Record<string, unknown>;
|
|
619
|
-
paramDefinitions?: ParamDefinitions;
|
|
620
|
-
transformBody?: BodyTransformer;
|
|
564
|
+
export declare interface PreparableController<TData, TQuery, TPrepareResult> extends Controller<TData, TQuery> {
|
|
565
|
+
prepare(query: TQuery): Promise<Result<TPrepareResult, SdkError>>;
|
|
621
566
|
}
|
|
622
567
|
|
|
623
568
|
export declare interface PrepareSearchResult {
|
|
@@ -630,12 +575,50 @@ export declare interface Price {
|
|
|
630
575
|
formatted: string;
|
|
631
576
|
}
|
|
632
577
|
|
|
578
|
+
export declare interface PriceRange {
|
|
579
|
+
min: Price;
|
|
580
|
+
max: Price;
|
|
581
|
+
}
|
|
582
|
+
|
|
633
583
|
declare interface PriceRangeResult {
|
|
634
584
|
minVariantPrice: MoneyResult;
|
|
635
585
|
maxVariantPrice: MoneyResult;
|
|
636
586
|
}
|
|
637
587
|
|
|
638
|
-
export declare
|
|
588
|
+
export declare interface Product {
|
|
589
|
+
id: CommerceBlocksID;
|
|
590
|
+
gid: ProductGID;
|
|
591
|
+
numericId: number;
|
|
592
|
+
title: string;
|
|
593
|
+
handle: string;
|
|
594
|
+
type: string;
|
|
595
|
+
vendor: string;
|
|
596
|
+
description: string;
|
|
597
|
+
availableForSale: boolean;
|
|
598
|
+
images: Image_2[];
|
|
599
|
+
priceRange: PriceRange;
|
|
600
|
+
compareAtPriceRange?: PriceRange;
|
|
601
|
+
options: RichProductOption[];
|
|
602
|
+
tags: string[];
|
|
603
|
+
variants: ProductVariant[];
|
|
604
|
+
selectedOptions: ProductOption[];
|
|
605
|
+
metafields: Record<string, Record<string, unknown>> | unknown[];
|
|
606
|
+
calculated?: Record<string, unknown>;
|
|
607
|
+
isGiftCard: boolean;
|
|
608
|
+
category: ProductCategory | null;
|
|
609
|
+
createdAt: string | null;
|
|
610
|
+
publishedAt: string | null;
|
|
611
|
+
updatedAt: string | null;
|
|
612
|
+
featuredMedia: FeaturedMedia | null;
|
|
613
|
+
namedTags?: NamedTag[];
|
|
614
|
+
combinedListingParentProductId: number | null;
|
|
615
|
+
combinedListingRole: string | null;
|
|
616
|
+
hasVariantsThatRequireComponents: boolean;
|
|
617
|
+
originalOptions: Record<string, string[]>;
|
|
618
|
+
selectedVariant: ProductVariant | null;
|
|
619
|
+
breakoutOptions?: ProductOption[];
|
|
620
|
+
breakoutVariantId?: number;
|
|
621
|
+
}
|
|
639
622
|
|
|
640
623
|
export declare interface ProductCardController {
|
|
641
624
|
product: Product;
|
|
@@ -744,7 +727,7 @@ declare interface ProductResult {
|
|
|
744
727
|
}
|
|
745
728
|
|
|
746
729
|
export declare interface ProductVariant {
|
|
747
|
-
id:
|
|
730
|
+
id: CommerceBlocksID;
|
|
748
731
|
gid: VariantGID;
|
|
749
732
|
numericId: number;
|
|
750
733
|
title: string;
|
|
@@ -766,20 +749,21 @@ export declare interface ProductVariant {
|
|
|
766
749
|
|
|
767
750
|
declare type Queries<P extends Product = Product> = Record<string, QueryResult<P>>;
|
|
768
751
|
|
|
769
|
-
declare interface
|
|
752
|
+
export declare interface QueryParams {
|
|
753
|
+
page?: number;
|
|
754
|
+
limit?: number;
|
|
755
|
+
filters?: unknown;
|
|
756
|
+
signal?: AbortSignal;
|
|
757
|
+
dynamicLinking?: Record<string, string | number | (string | number)[]>;
|
|
758
|
+
params?: Record<string, unknown>;
|
|
759
|
+
paramDefinitions?: ParamDefinitions;
|
|
760
|
+
transformBody?: BodyTransformer;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
declare interface QueryResult<P extends Product = Product> extends Omit<LayersResponse, 'results' | 'facets'> {
|
|
770
764
|
products: P[];
|
|
771
|
-
totalResults: number;
|
|
772
|
-
totalPages: number;
|
|
773
|
-
page: number;
|
|
774
|
-
resultsPerPage?: number;
|
|
775
765
|
facets: Record<string, Record<string, number>>;
|
|
776
|
-
|
|
777
|
-
min: number;
|
|
778
|
-
max: number;
|
|
779
|
-
}>;
|
|
780
|
-
attributionToken?: string;
|
|
781
|
-
_meta?: LayersMeta;
|
|
782
|
-
_workflow?: unknown;
|
|
766
|
+
priceRange?: PriceRange;
|
|
783
767
|
}
|
|
784
768
|
|
|
785
769
|
export declare interface QueryState<T> {
|
|
@@ -819,10 +803,10 @@ export declare interface Sdk<P extends Product = Product> {
|
|
|
819
803
|
collection: (options: CollectionOptions) => CollectionController<P>;
|
|
820
804
|
blocks: (options: BlocksOptions) => BlocksController<P>;
|
|
821
805
|
autocomplete: (options?: AutocompleteOptions) => AutocompleteController;
|
|
822
|
-
search: () => SearchController<P>;
|
|
806
|
+
search: (options?: SearchQuery) => SearchController<P>;
|
|
823
807
|
storefront: (query: StorefrontQuery) => ReadonlySignal<QueryState<StorefrontResult<P>>>;
|
|
824
808
|
uploadImage: (options: UploadImageOptions) => ReadonlySignal<QueryState<UploadImageResult>>;
|
|
825
|
-
imageSearch: (options:
|
|
809
|
+
imageSearch: (options: ImageSearchQuery) => ReadonlySignal<QueryState<SearchResult<P>>>;
|
|
826
810
|
config: SdkConfig<P>;
|
|
827
811
|
store: Store<P>;
|
|
828
812
|
}
|
|
@@ -872,32 +856,26 @@ export declare interface SdkConfig<P extends Product = Product> extends LayersCl
|
|
|
872
856
|
restoreFromStorage?: boolean;
|
|
873
857
|
}
|
|
874
858
|
|
|
875
|
-
export declare type SdkError =
|
|
859
|
+
export declare type SdkError = ServiceError | ConfigError;
|
|
876
860
|
|
|
877
861
|
export declare interface SearchController<P extends Product = Product> {
|
|
878
|
-
state: ReadonlySignal<QueryState<SearchResult<P>>>;
|
|
879
|
-
prepare
|
|
880
|
-
execute
|
|
881
|
-
|
|
862
|
+
readonly state: ReadonlySignal<QueryState<SearchResult<P>>>;
|
|
863
|
+
prepare(query?: SearchQuery): Promise<Result<PrepareSearchResult, SdkError>>;
|
|
864
|
+
execute(query?: SearchQuery): Promise<Result<SearchResult<P>, SdkError>>;
|
|
865
|
+
subscribe(callback: (state: QueryState<SearchResult<P>>) => void): Unsubscribe;
|
|
866
|
+
dispose(): void;
|
|
882
867
|
}
|
|
883
868
|
|
|
884
869
|
export declare type SearchExtender<P extends Product = Product> = (result: SearchResult<P>, raw: LayersResponse) => SearchResult<P>;
|
|
885
870
|
|
|
886
|
-
export declare interface SearchQuery {
|
|
887
|
-
query
|
|
871
|
+
export declare interface SearchQuery extends QueryParams {
|
|
872
|
+
query?: string;
|
|
888
873
|
searchId?: string;
|
|
889
|
-
page?: number;
|
|
890
|
-
limit?: number;
|
|
891
|
-
filters?: unknown;
|
|
892
874
|
tuning?: LayersTuning;
|
|
893
|
-
|
|
894
|
-
dynamicLinking?: Record<string, string | number | (string | number)[]>;
|
|
895
|
-
params?: Record<string, unknown>;
|
|
896
|
-
paramDefinitions?: ParamDefinitions;
|
|
897
|
-
transformBody?: BodyTransformer;
|
|
875
|
+
transient?: boolean;
|
|
898
876
|
}
|
|
899
877
|
|
|
900
|
-
export declare type SearchResult<P extends Product = Product> =
|
|
878
|
+
export declare type SearchResult<P extends Product = Product> = QueryResult<P>;
|
|
901
879
|
|
|
902
880
|
declare interface SelectedOptionResult {
|
|
903
881
|
name: string;
|
|
@@ -909,6 +887,8 @@ declare interface SeoResult {
|
|
|
909
887
|
description: string | null;
|
|
910
888
|
}
|
|
911
889
|
|
|
890
|
+
declare type ServiceError = NetworkError | ApiError | ValidationError;
|
|
891
|
+
|
|
912
892
|
declare type ShopifyGID<T extends ShopifyType> = `gid://shopify/${T}/${number}`;
|
|
913
893
|
|
|
914
894
|
declare type ShopifyType = 'Product' | 'ProductVariant' | 'Collection';
|
|
@@ -943,7 +923,7 @@ declare interface Store<P extends Product = Product> {
|
|
|
943
923
|
has(gid: ProductGID): boolean;
|
|
944
924
|
};
|
|
945
925
|
queries: {
|
|
946
|
-
get(key: string): ReadonlySignal<
|
|
926
|
+
get(key: string): ReadonlySignal<CacheEntry<QueryResult<P>> | null>;
|
|
947
927
|
set(key: string, result: QueryResult<P>): void;
|
|
948
928
|
isExpired(key: string): boolean;
|
|
949
929
|
invalidate(pattern: string): void;
|
|
@@ -1070,6 +1050,11 @@ export declare interface StoreOptions {
|
|
|
1070
1050
|
storageAdapter?: StorageAdapter;
|
|
1071
1051
|
}
|
|
1072
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
|
+
|
|
1073
1058
|
export declare interface Swatch {
|
|
1074
1059
|
name: string | null;
|
|
1075
1060
|
value: string;
|
|
@@ -1086,6 +1071,8 @@ declare interface SwatchResult {
|
|
|
1086
1071
|
} | null;
|
|
1087
1072
|
}
|
|
1088
1073
|
|
|
1074
|
+
export declare type Unsubscribe = () => void;
|
|
1075
|
+
|
|
1089
1076
|
export declare interface UploadImageOptions {
|
|
1090
1077
|
image: File | Blob;
|
|
1091
1078
|
signal?: AbortSignal;
|