@commerce-blocks/sdk 2.0.0-alpha.1 → 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 +185 -93
- package/dist/index.d.ts +135 -148
- package/dist/index.js +1218 -1164
- package/package.json +1 -1
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,43 +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: PriceRange;
|
|
56
|
-
compareAtPriceRange?: PriceRange;
|
|
57
|
-
options: RichProductOption[];
|
|
58
|
-
tags: string[];
|
|
59
|
-
variants: ProductVariant[];
|
|
60
|
-
selectedOptions: ProductOption[];
|
|
61
|
-
metafields: Record<string, Record<string, unknown>> | unknown[];
|
|
62
|
-
calculated?: Record<string, unknown>;
|
|
63
|
-
isGiftCard: boolean;
|
|
64
|
-
category: ProductCategory | null;
|
|
65
|
-
createdAt: string | null;
|
|
66
|
-
publishedAt: string | null;
|
|
67
|
-
updatedAt: string | null;
|
|
68
|
-
featuredMedia: FeaturedMedia | null;
|
|
69
|
-
namedTags?: NamedTag[];
|
|
70
|
-
combinedListingParentProductId: number | null;
|
|
71
|
-
combinedListingRole: string | null;
|
|
72
|
-
hasVariantsThatRequireComponents: boolean;
|
|
73
|
-
originalOptions: Record<string, string[]>;
|
|
74
|
-
selectedVariant: ProductVariant | null;
|
|
75
|
-
breakoutOptions?: ProductOption[];
|
|
76
|
-
breakoutVariantId?: number;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
declare type BaseResult<P extends Product = Product> = QueryResult<P>;
|
|
80
|
-
|
|
81
45
|
export { batch }
|
|
82
46
|
|
|
83
47
|
declare interface BlocksContext {
|
|
@@ -95,22 +59,10 @@ declare interface BlocksContext {
|
|
|
95
59
|
}
|
|
96
60
|
|
|
97
61
|
export declare interface BlocksController<P extends Product = Product> {
|
|
98
|
-
state: ReadonlySignal<QueryState<BlocksResult<P>>>;
|
|
99
|
-
execute
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
export declare interface BlocksExecuteQuery {
|
|
104
|
-
page?: number;
|
|
105
|
-
limit?: number;
|
|
106
|
-
filters?: unknown;
|
|
107
|
-
signal?: AbortSignal;
|
|
108
|
-
discountEntitlements?: DiscountEntitlement[];
|
|
109
|
-
context?: BlocksContext;
|
|
110
|
-
dynamicLinking?: Record<string, string | number | (string | number)[]>;
|
|
111
|
-
params?: Record<string, unknown>;
|
|
112
|
-
paramDefinitions?: ParamDefinitions;
|
|
113
|
-
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;
|
|
114
66
|
}
|
|
115
67
|
|
|
116
68
|
export declare type BlocksExtender<P extends Product = Product> = (result: BlocksResult<P>, raw: LayersResponse & {
|
|
@@ -129,37 +81,29 @@ declare interface BlocksInfo {
|
|
|
129
81
|
export declare interface BlocksOptions {
|
|
130
82
|
blockId: string;
|
|
131
83
|
anchorId?: string;
|
|
132
|
-
anchorHandle?: string;
|
|
133
84
|
}
|
|
134
85
|
|
|
135
|
-
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> {
|
|
136
92
|
block?: BlocksInfo;
|
|
137
93
|
}
|
|
138
94
|
|
|
139
95
|
export declare type BodyTransformer = (body: Record<string, unknown>) => Record<string, unknown>;
|
|
140
96
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
dispose: () => void;
|
|
97
|
+
declare interface CacheEntry<T> {
|
|
98
|
+
data: T;
|
|
99
|
+
timestamp: number;
|
|
145
100
|
}
|
|
146
101
|
|
|
147
|
-
export declare interface
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
signal?: AbortSignal;
|
|
153
|
-
includeMeta?: boolean;
|
|
154
|
-
collectionMetafields?: {
|
|
155
|
-
namespace: string;
|
|
156
|
-
key: string;
|
|
157
|
-
}[];
|
|
158
|
-
includeFilters?: boolean;
|
|
159
|
-
dynamicLinking?: Record<string, string | number | (string | number)[]>;
|
|
160
|
-
params?: Record<string, unknown>;
|
|
161
|
-
paramDefinitions?: ParamDefinitions;
|
|
162
|
-
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;
|
|
163
107
|
}
|
|
164
108
|
|
|
165
109
|
export declare type CollectionExtender<P extends Product = Product> = (result: CollectionResult<P>, raw: LayersResponse) => CollectionResult<P>;
|
|
@@ -175,7 +119,7 @@ declare interface CollectionMeta {
|
|
|
175
119
|
width?: number;
|
|
176
120
|
height?: number;
|
|
177
121
|
};
|
|
178
|
-
metafields?: (
|
|
122
|
+
metafields?: (Metafield | null)[];
|
|
179
123
|
totalProducts: number;
|
|
180
124
|
totalPages: number;
|
|
181
125
|
lastPageFetched: number;
|
|
@@ -188,7 +132,17 @@ export declare interface CollectionOptions {
|
|
|
188
132
|
defaultSort?: string;
|
|
189
133
|
}
|
|
190
134
|
|
|
191
|
-
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> {
|
|
192
146
|
collection?: StorefrontCollection;
|
|
193
147
|
}
|
|
194
148
|
|
|
@@ -212,6 +166,13 @@ export declare interface ConfigError {
|
|
|
212
166
|
|
|
213
167
|
declare type ConfigErrorCode = 'MISSING_CONFIG' | 'INVALID_CONFIG';
|
|
214
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
|
+
|
|
215
176
|
export declare function createProductCard({ product, selectedOptions: initialSelectedOptions, breakoutOptions: initialBreakoutOptions, }: CreateProductCardParams): ProductCardController;
|
|
216
177
|
|
|
217
178
|
export declare interface CreateProductCardParams {
|
|
@@ -239,17 +200,12 @@ declare interface DiscountEntitlement {
|
|
|
239
200
|
|
|
240
201
|
export { effect }
|
|
241
202
|
|
|
242
|
-
declare interface Entry<T> {
|
|
243
|
-
data: T;
|
|
244
|
-
timestamp: number;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
203
|
export declare function eq(property: string, value: FilterValue): FilterExpression;
|
|
248
204
|
|
|
249
205
|
export declare function exists(property: string): FilterExpression;
|
|
250
206
|
|
|
251
|
-
declare interface ExtendedProduct extends
|
|
252
|
-
_base:
|
|
207
|
+
declare interface ExtendedProduct extends Product {
|
|
208
|
+
_base: Product;
|
|
253
209
|
}
|
|
254
210
|
|
|
255
211
|
declare interface Facet {
|
|
@@ -336,6 +292,13 @@ declare interface FilterValueResult {
|
|
|
336
292
|
input: string;
|
|
337
293
|
}
|
|
338
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
|
+
|
|
339
302
|
export declare function getSdk(): Result<Sdk, ConfigError>;
|
|
340
303
|
|
|
341
304
|
declare interface GraphQLErrorDetail {
|
|
@@ -363,8 +326,6 @@ export declare function gte(property: string, value: number): FilterExpression;
|
|
|
363
326
|
*/
|
|
364
327
|
declare type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
365
328
|
|
|
366
|
-
declare type ID = CommerceBlocksID;
|
|
367
|
-
|
|
368
329
|
declare interface Image_2 {
|
|
369
330
|
url: string;
|
|
370
331
|
alt: string;
|
|
@@ -382,17 +343,9 @@ declare interface ImageResult {
|
|
|
382
343
|
height: number;
|
|
383
344
|
}
|
|
384
345
|
|
|
385
|
-
export declare interface
|
|
346
|
+
export declare interface ImageSearchQuery extends QueryParams {
|
|
386
347
|
imageId: string;
|
|
387
|
-
page?: number;
|
|
388
|
-
limit?: number;
|
|
389
|
-
filters?: unknown;
|
|
390
348
|
tuning?: LayersTuning;
|
|
391
|
-
signal?: AbortSignal;
|
|
392
|
-
dynamicLinking?: Record<string, string | number | (string | number)[]>;
|
|
393
|
-
params?: Record<string, unknown>;
|
|
394
|
-
paramDefinitions?: ParamDefinitions;
|
|
395
|
-
transformBody?: BodyTransformer;
|
|
396
349
|
}
|
|
397
350
|
|
|
398
351
|
export declare function inValues(property: string, values: FilterValue[]): FilterExpression;
|
|
@@ -437,6 +390,16 @@ declare interface LayersMeta {
|
|
|
437
390
|
variantBreakouts?: {
|
|
438
391
|
optionCode: string;
|
|
439
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
|
+
};
|
|
440
403
|
}
|
|
441
404
|
|
|
442
405
|
declare interface LayersPagination {
|
|
@@ -460,6 +423,8 @@ declare interface LayersTuning {
|
|
|
460
423
|
visualWeight?: number;
|
|
461
424
|
multipleFactor?: number;
|
|
462
425
|
minimumMatch?: number;
|
|
426
|
+
missingEmbeddingScore?: number;
|
|
427
|
+
highSignalWeight?: number;
|
|
463
428
|
}
|
|
464
429
|
|
|
465
430
|
declare interface LayersVariant {
|
|
@@ -518,13 +483,6 @@ declare interface MetafieldResult {
|
|
|
518
483
|
type: string;
|
|
519
484
|
}
|
|
520
485
|
|
|
521
|
-
declare interface MetafieldResult_2 {
|
|
522
|
-
namespace: string;
|
|
523
|
-
key: string;
|
|
524
|
-
value: string;
|
|
525
|
-
type: string;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
486
|
declare interface MoneyResult {
|
|
529
487
|
amount: string;
|
|
530
488
|
currencyCode: string;
|
|
@@ -603,15 +561,8 @@ declare interface PredictiveSearchResponse {
|
|
|
603
561
|
normalizedQuery: string;
|
|
604
562
|
}
|
|
605
563
|
|
|
606
|
-
export declare interface
|
|
607
|
-
query:
|
|
608
|
-
filters?: unknown;
|
|
609
|
-
tuning?: LayersTuning;
|
|
610
|
-
signal?: AbortSignal;
|
|
611
|
-
dynamicLinking?: Record<string, string | number | (string | number)[]>;
|
|
612
|
-
params?: Record<string, unknown>;
|
|
613
|
-
paramDefinitions?: ParamDefinitions;
|
|
614
|
-
transformBody?: BodyTransformer;
|
|
564
|
+
export declare interface PreparableController<TData, TQuery, TPrepareResult> extends Controller<TData, TQuery> {
|
|
565
|
+
prepare(query: TQuery): Promise<Result<TPrepareResult, SdkError>>;
|
|
615
566
|
}
|
|
616
567
|
|
|
617
568
|
export declare interface PrepareSearchResult {
|
|
@@ -634,7 +585,40 @@ declare interface PriceRangeResult {
|
|
|
634
585
|
maxVariantPrice: MoneyResult;
|
|
635
586
|
}
|
|
636
587
|
|
|
637
|
-
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
|
+
}
|
|
638
622
|
|
|
639
623
|
export declare interface ProductCardController {
|
|
640
624
|
product: Product;
|
|
@@ -743,7 +727,7 @@ declare interface ProductResult {
|
|
|
743
727
|
}
|
|
744
728
|
|
|
745
729
|
export declare interface ProductVariant {
|
|
746
|
-
id:
|
|
730
|
+
id: CommerceBlocksID;
|
|
747
731
|
gid: VariantGID;
|
|
748
732
|
numericId: number;
|
|
749
733
|
title: string;
|
|
@@ -765,21 +749,21 @@ export declare interface ProductVariant {
|
|
|
765
749
|
|
|
766
750
|
declare type Queries<P extends Product = Product> = Record<string, QueryResult<P>>;
|
|
767
751
|
|
|
768
|
-
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'> {
|
|
769
764
|
products: P[];
|
|
770
|
-
totalResults: number;
|
|
771
|
-
totalPages: number;
|
|
772
|
-
page: number;
|
|
773
|
-
resultsPerPage?: number;
|
|
774
765
|
facets: Record<string, Record<string, number>>;
|
|
775
|
-
facetRanges?: Record<string, {
|
|
776
|
-
min: number;
|
|
777
|
-
max: number;
|
|
778
|
-
}>;
|
|
779
766
|
priceRange?: PriceRange;
|
|
780
|
-
attributionToken?: string;
|
|
781
|
-
_meta?: LayersMeta;
|
|
782
|
-
_workflow?: unknown;
|
|
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;
|