@swishapp/sdk 0.55.0 → 0.56.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.
Files changed (31) hide show
  1. package/dist/dom/dom-utils.d.ts +2 -1
  2. package/dist/index.d.ts +1 -0
  3. package/dist/intents/handlers/create-item-handler.d.ts +29 -0
  4. package/dist/intents/handlers/create-list-handler.d.ts +13 -0
  5. package/dist/intents/handlers/delete-item-handler.d.ts +18 -0
  6. package/dist/intents/handlers/delete-list-handler.d.ts +18 -0
  7. package/dist/intents/handlers/edit-item-lists-handler.d.ts +25 -0
  8. package/dist/intents/handlers/edit-item-variant-handler.d.ts +28 -0
  9. package/dist/intents/handlers/edit-list-handler.d.ts +19 -0
  10. package/dist/intents/handlers/open-home-handler.d.ts +10 -0
  11. package/dist/intents/handlers/open-list-menu-handler.d.ts +18 -0
  12. package/dist/intents/handlers/open-sign-in-handler.d.ts +16 -0
  13. package/dist/intents/hooks/after-create-item-hook.d.ts +6 -0
  14. package/dist/intents/hooks/after-edit-item-lists-hook.d.ts +6 -0
  15. package/dist/intents/intent-handler.d.ts +10 -0
  16. package/dist/intents/intent-hook.d.ts +9 -0
  17. package/dist/intents/intents.d.ts +21 -0
  18. package/dist/intents/types.d.ts +70 -0
  19. package/dist/state/index.d.ts +1 -1
  20. package/dist/state/item-context-signal.d.ts +0 -2
  21. package/dist/state/item-state-signal.d.ts +2 -2
  22. package/dist/storefront-api/load-save-intent-data.d.ts +12 -0
  23. package/dist/storefront-api/queries/fragments.d.ts +3 -2
  24. package/dist/storefront-api/queries/index.d.ts +10 -8
  25. package/dist/storefront-api/storefront-api-client.d.ts +8 -3
  26. package/dist/storefront-api/types/storefront.generated.d.ts +66 -16
  27. package/dist/swish-ui/swish-ui-utils.d.ts +31 -29
  28. package/dist/swish.d.ts +9 -39
  29. package/dist/swish.js +113 -58
  30. package/dist/utils/shopify-gid.d.ts +2 -2
  31. package/package.json +3 -2
@@ -1,5 +1,15 @@
1
1
  import * as StorefrontTypes from './storefront.types';
2
2
  export type ProductImageFieldsFragment = Pick<StorefrontTypes.Image, 'id' | 'altText' | 'url' | 'thumbhash'>;
3
+ export type SaveIntentProductFieldsFragment = (Pick<StorefrontTypes.Product, 'id' | 'availableForSale' | 'handle' | 'title'> & {
4
+ featuredImage?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, 'id' | 'altText' | 'url' | 'thumbhash'>>;
5
+ variantsCount?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Count, 'count'>>;
6
+ selectedOrFirstAvailableVariant?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.ProductVariant, 'id' | 'availableForSale' | 'currentlyNotInStock' | 'title'> & {
7
+ image?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, 'id' | 'altText' | 'url' | 'thumbhash'>>;
8
+ })>;
9
+ });
10
+ export type SaveIntentVariantFieldsFragment = (Pick<StorefrontTypes.ProductVariant, 'id' | 'availableForSale' | 'currentlyNotInStock' | 'title'> & {
11
+ image?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, 'id' | 'altText' | 'url' | 'thumbhash'>>;
12
+ });
3
13
  export type ProductCardDataFieldsFragment = (Pick<StorefrontTypes.Product, 'id' | 'availableForSale' | 'isGiftCard' | 'onlineStoreUrl' | 'description' | 'descriptionHtml' | 'handle' | 'productType' | 'tags' | 'title'> & {
4
14
  category?: StorefrontTypes.Maybe<Pick<StorefrontTypes.TaxonomyCategory, 'id' | 'name'>>;
5
15
  compareAtPriceRange: {
@@ -24,7 +34,7 @@ export type ProductVariantDataFieldsFragment = (Pick<StorefrontTypes.ProductVari
24
34
  export type ProductOptionsVariantFieldsFragment = (Pick<StorefrontTypes.ProductVariant, 'id'> & {
25
35
  selectedOptions: Array<Pick<StorefrontTypes.SelectedOption, 'name' | 'value'>>;
26
36
  });
27
- export type SelectedVariantFieldsFragment = (Pick<StorefrontTypes.Product, 'id' | 'title' | 'handle'> & {
37
+ export type SelectedVariantFieldsFragment = (Pick<StorefrontTypes.Product, 'id' | 'availableForSale' | 'title' | 'handle'> & {
28
38
  featuredImage?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, 'id' | 'altText' | 'url' | 'thumbhash'>>;
29
39
  variantBySelectedOptions?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.ProductVariant, 'id' | 'availableForSale' | 'currentlyNotInStock' | 'title'> & {
30
40
  compareAtPrice?: StorefrontTypes.Maybe<Pick<StorefrontTypes.MoneyV2, 'amount' | 'currencyCode'>>;
@@ -33,7 +43,7 @@ export type SelectedVariantFieldsFragment = (Pick<StorefrontTypes.Product, 'id'
33
43
  selectedOptions: Array<Pick<StorefrontTypes.SelectedOption, 'name' | 'value'>>;
34
44
  })>;
35
45
  });
36
- export type ProductOptionsFieldsFragment = (Pick<StorefrontTypes.Product, 'id' | 'title' | 'encodedVariantAvailability' | 'encodedVariantExistence'> & {
46
+ export type ProductOptionsFieldsFragment = (Pick<StorefrontTypes.Product, 'id' | 'availableForSale' | 'title' | 'encodedVariantAvailability' | 'encodedVariantExistence'> & {
37
47
  featuredImage?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, 'id' | 'altText' | 'url' | 'thumbhash'>>;
38
48
  variantsCount?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Count, 'count' | 'precision'>>;
39
49
  options: Array<(Pick<StorefrontTypes.ProductOption, 'id' | 'name'> & {
@@ -54,6 +64,38 @@ export type ProductImagesFieldsFragment = {
54
64
  nodes: Array<Pick<StorefrontTypes.Image, 'id' | 'altText' | 'url' | 'thumbhash'>>;
55
65
  };
56
66
  };
67
+ export type GetSaveIntentDataQueryVariables = StorefrontTypes.Exact<{
68
+ productId: StorefrontTypes.Scalars['ID']['input'];
69
+ country: StorefrontTypes.CountryCode;
70
+ language: StorefrontTypes.LanguageCode;
71
+ }>;
72
+ export type GetSaveIntentDataQuery = {
73
+ product?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.Product, 'id' | 'availableForSale' | 'handle' | 'title'> & {
74
+ featuredImage?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, 'id' | 'altText' | 'url' | 'thumbhash'>>;
75
+ variantsCount?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Count, 'count'>>;
76
+ selectedOrFirstAvailableVariant?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.ProductVariant, 'id' | 'availableForSale' | 'currentlyNotInStock' | 'title'> & {
77
+ image?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, 'id' | 'altText' | 'url' | 'thumbhash'>>;
78
+ })>;
79
+ })>;
80
+ };
81
+ export type GetSaveIntentDataWithVariantQueryVariables = StorefrontTypes.Exact<{
82
+ productId: StorefrontTypes.Scalars['ID']['input'];
83
+ variantId: StorefrontTypes.Scalars['ID']['input'];
84
+ country: StorefrontTypes.CountryCode;
85
+ language: StorefrontTypes.LanguageCode;
86
+ }>;
87
+ export type GetSaveIntentDataWithVariantQuery = {
88
+ product?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.Product, 'id' | 'availableForSale' | 'handle' | 'title'> & {
89
+ featuredImage?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, 'id' | 'altText' | 'url' | 'thumbhash'>>;
90
+ variantsCount?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Count, 'count'>>;
91
+ selectedOrFirstAvailableVariant?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.ProductVariant, 'id' | 'availableForSale' | 'currentlyNotInStock' | 'title'> & {
92
+ image?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, 'id' | 'altText' | 'url' | 'thumbhash'>>;
93
+ })>;
94
+ })>;
95
+ variant?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.ProductVariant, 'id' | 'availableForSale' | 'currentlyNotInStock' | 'title'> & {
96
+ image?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, 'id' | 'altText' | 'url' | 'thumbhash'>>;
97
+ })>;
98
+ };
57
99
  export type GetProductCardDataQueryVariables = StorefrontTypes.Exact<{
58
100
  productId: StorefrontTypes.Scalars['ID']['input'];
59
101
  productMetafields: Array<StorefrontTypes.HasMetafieldsIdentifier> | StorefrontTypes.HasMetafieldsIdentifier;
@@ -113,7 +155,7 @@ export type GetProductOptionsQueryVariables = StorefrontTypes.Exact<{
113
155
  language: StorefrontTypes.LanguageCode;
114
156
  }>;
115
157
  export type GetProductOptionsQuery = {
116
- product?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.Product, 'id' | 'title' | 'encodedVariantAvailability' | 'encodedVariantExistence'> & {
158
+ product?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.Product, 'id' | 'availableForSale' | 'title' | 'encodedVariantAvailability' | 'encodedVariantExistence'> & {
117
159
  featuredImage?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, 'id' | 'altText' | 'url' | 'thumbhash'>>;
118
160
  variantsCount?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Count, 'count' | 'precision'>>;
119
161
  options: Array<(Pick<StorefrontTypes.ProductOption, 'id' | 'name'> & {
@@ -136,7 +178,7 @@ export type GetProductOptionsByHandleQueryVariables = StorefrontTypes.Exact<{
136
178
  language: StorefrontTypes.LanguageCode;
137
179
  }>;
138
180
  export type GetProductOptionsByHandleQuery = {
139
- product?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.Product, 'id' | 'title' | 'encodedVariantAvailability' | 'encodedVariantExistence'> & {
181
+ product?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.Product, 'id' | 'availableForSale' | 'title' | 'encodedVariantAvailability' | 'encodedVariantExistence'> & {
140
182
  featuredImage?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, 'id' | 'altText' | 'url' | 'thumbhash'>>;
141
183
  variantsCount?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Count, 'count' | 'precision'>>;
142
184
  options: Array<(Pick<StorefrontTypes.ProductOption, 'id' | 'name'> & {
@@ -160,7 +202,7 @@ export type GetProductOptionsWithVariantQueryVariables = StorefrontTypes.Exact<{
160
202
  language: StorefrontTypes.LanguageCode;
161
203
  }>;
162
204
  export type GetProductOptionsWithVariantQuery = {
163
- product?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.Product, 'id' | 'title' | 'encodedVariantAvailability' | 'encodedVariantExistence'> & {
205
+ product?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.Product, 'id' | 'availableForSale' | 'title' | 'encodedVariantAvailability' | 'encodedVariantExistence'> & {
164
206
  featuredImage?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, 'id' | 'altText' | 'url' | 'thumbhash'>>;
165
207
  variantsCount?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Count, 'count' | 'precision'>>;
166
208
  options: Array<(Pick<StorefrontTypes.ProductOption, 'id' | 'name'> & {
@@ -187,7 +229,7 @@ export type GetProductOptionsByHandleWithVariantQueryVariables = StorefrontTypes
187
229
  language: StorefrontTypes.LanguageCode;
188
230
  }>;
189
231
  export type GetProductOptionsByHandleWithVariantQuery = {
190
- product?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.Product, 'id' | 'title' | 'encodedVariantAvailability' | 'encodedVariantExistence'> & {
232
+ product?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.Product, 'id' | 'availableForSale' | 'title' | 'encodedVariantAvailability' | 'encodedVariantExistence'> & {
191
233
  featuredImage?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, 'id' | 'altText' | 'url' | 'thumbhash'>>;
192
234
  variantsCount?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Count, 'count' | 'precision'>>;
193
235
  options: Array<(Pick<StorefrontTypes.ProductOption, 'id' | 'name'> & {
@@ -214,7 +256,7 @@ export type GetSelectedVariantQueryVariables = StorefrontTypes.Exact<{
214
256
  language: StorefrontTypes.LanguageCode;
215
257
  }>;
216
258
  export type GetSelectedVariantQuery = {
217
- product?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.Product, 'id' | 'title' | 'handle'> & {
259
+ product?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.Product, 'id' | 'availableForSale' | 'title' | 'handle'> & {
218
260
  featuredImage?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, 'id' | 'altText' | 'url' | 'thumbhash'>>;
219
261
  variantBySelectedOptions?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.ProductVariant, 'id' | 'availableForSale' | 'currentlyNotInStock' | 'title'> & {
220
262
  compareAtPrice?: StorefrontTypes.Maybe<Pick<StorefrontTypes.MoneyV2, 'amount' | 'currencyCode'>>;
@@ -231,7 +273,7 @@ export type GetSelectedVariantByHandleQueryVariables = StorefrontTypes.Exact<{
231
273
  language: StorefrontTypes.LanguageCode;
232
274
  }>;
233
275
  export type GetSelectedVariantByHandleQuery = {
234
- product?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.Product, 'id' | 'title' | 'handle'> & {
276
+ product?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.Product, 'id' | 'availableForSale' | 'title' | 'handle'> & {
235
277
  featuredImage?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Image, 'id' | 'altText' | 'url' | 'thumbhash'>>;
236
278
  variantBySelectedOptions?: StorefrontTypes.Maybe<(Pick<StorefrontTypes.ProductVariant, 'id' | 'availableForSale' | 'currentlyNotInStock' | 'title'> & {
237
279
  compareAtPrice?: StorefrontTypes.Maybe<Pick<StorefrontTypes.MoneyV2, 'amount' | 'currencyCode'>>;
@@ -392,6 +434,14 @@ export type GetProductIdByHandleQuery = {
392
434
  product?: StorefrontTypes.Maybe<Pick<StorefrontTypes.Product, 'id'>>;
393
435
  };
394
436
  interface GeneratedQueryTypes {
437
+ "\n query GetSaveIntentData(\n $productId: ID!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...saveIntentProductFields\n }\n }\n \n fragment saveIntentProductFields on Product {\n id\n availableForSale\n featuredImage {\n ...productImageFields\n }\n handle\n title\n variantsCount {\n count\n }\n selectedOrFirstAvailableVariant {\n ...saveIntentVariantFields\n }\n }\n fragment saveIntentVariantFields on ProductVariant {\n id\n availableForSale\n currentlyNotInStock\n image {\n ...productImageFields\n }\n title\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
438
+ return: GetSaveIntentDataQuery;
439
+ variables: GetSaveIntentDataQueryVariables;
440
+ };
441
+ "\n query GetSaveIntentDataWithVariant(\n $productId: ID!\n $variantId: ID!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...saveIntentProductFields\n }\n variant: node(id: $variantId) {\n ...saveIntentVariantFields\n }\n }\n \n fragment saveIntentProductFields on Product {\n id\n availableForSale\n featuredImage {\n ...productImageFields\n }\n handle\n title\n variantsCount {\n count\n }\n selectedOrFirstAvailableVariant {\n ...saveIntentVariantFields\n }\n }\n fragment saveIntentVariantFields on ProductVariant {\n id\n availableForSale\n currentlyNotInStock\n image {\n ...productImageFields\n }\n title\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
442
+ return: GetSaveIntentDataWithVariantQuery;
443
+ variables: GetSaveIntentDataWithVariantQueryVariables;
444
+ };
395
445
  "\n query GetProductCardData(\n $productId: ID!\n $productMetafields: [HasMetafieldsIdentifier!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productCardDataFields\n }\n }\n \n fragment productCardDataFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n featuredImage {\n ...productImageFields\n }\n isGiftCard\n onlineStoreUrl\n description\n descriptionHtml\n handle\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n }\n # totalInventory\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
396
446
  return: GetProductCardDataQuery;
397
447
  variables: GetProductCardDataQueryVariables;
@@ -400,35 +450,35 @@ interface GeneratedQueryTypes {
400
450
  return: GetProductCardDataWithVariantQuery;
401
451
  variables: GetProductCardDataWithVariantQueryVariables;
402
452
  };
403
- "\n query GetProductOptions(\n $productId: ID!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productOptionsFields\n }\n }\n \n fragment productOptionsFields on Product {\n id\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
453
+ "\n query GetProductOptions(\n $productId: ID!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productOptionsFields\n }\n }\n \n fragment productOptionsFields on Product {\n id\n availableForSale\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
404
454
  return: GetProductOptionsQuery;
405
455
  variables: GetProductOptionsQueryVariables;
406
456
  };
407
- "\n query GetProductOptionsByHandle(\n $handle: String!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(handle: $handle) {\n ...productOptionsFields\n }\n }\n \n fragment productOptionsFields on Product {\n id\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
457
+ "\n query GetProductOptionsByHandle(\n $handle: String!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(handle: $handle) {\n ...productOptionsFields\n }\n }\n \n fragment productOptionsFields on Product {\n id\n availableForSale\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
408
458
  return: GetProductOptionsByHandleQuery;
409
459
  variables: GetProductOptionsByHandleQueryVariables;
410
460
  };
411
- "\n query GetProductOptionsWithVariant(\n $productId: ID!\n $variantId: ID!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productOptionsFields\n }\n variant: node(id: $variantId) {\n ...productOptionsVariantFields\n }\n }\n \n fragment productOptionsFields on Product {\n id\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productOptionsVariantFields on ProductVariant {\n id\n selectedOptions {\n name\n value\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
461
+ "\n query GetProductOptionsWithVariant(\n $productId: ID!\n $variantId: ID!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productOptionsFields\n }\n variant: node(id: $variantId) {\n ...productOptionsVariantFields\n }\n }\n \n fragment productOptionsFields on Product {\n id\n availableForSale\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productOptionsVariantFields on ProductVariant {\n id\n selectedOptions {\n name\n value\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
412
462
  return: GetProductOptionsWithVariantQuery;
413
463
  variables: GetProductOptionsWithVariantQueryVariables;
414
464
  };
415
- "\n query GetProductOptionsByHandleWithVariant(\n $handle: String!\n $variantId: ID!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(handle: $handle) {\n ...productOptionsFields\n }\n variant: node(id: $variantId) {\n ...productOptionsVariantFields\n }\n }\n \n fragment productOptionsFields on Product {\n id\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productOptionsVariantFields on ProductVariant {\n id\n selectedOptions {\n name\n value\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
465
+ "\n query GetProductOptionsByHandleWithVariant(\n $handle: String!\n $variantId: ID!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(handle: $handle) {\n ...productOptionsFields\n }\n variant: node(id: $variantId) {\n ...productOptionsVariantFields\n }\n }\n \n fragment productOptionsFields on Product {\n id\n availableForSale\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productOptionsVariantFields on ProductVariant {\n id\n selectedOptions {\n name\n value\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
416
466
  return: GetProductOptionsByHandleWithVariantQuery;
417
467
  variables: GetProductOptionsByHandleWithVariantQueryVariables;
418
468
  };
419
- "\n query GetSelectedVariant(\n $productId: ID!\n $selectedOptions: [SelectedOptionInput!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...selectedVariantFields\n }\n }\n \n fragment selectedVariantFields on Product {\n id\n title\n handle\n featuredImage {\n ...productImageFields\n }\n variantBySelectedOptions(selectedOptions: $selectedOptions) {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n title\n selectedOptions {\n name\n value\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
469
+ "\n query GetSelectedVariant(\n $productId: ID!\n $selectedOptions: [SelectedOptionInput!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...selectedVariantFields\n }\n }\n \n fragment selectedVariantFields on Product {\n id\n availableForSale\n title\n handle\n featuredImage {\n ...productImageFields\n }\n variantBySelectedOptions(selectedOptions: $selectedOptions) {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n title\n selectedOptions {\n name\n value\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
420
470
  return: GetSelectedVariantQuery;
421
471
  variables: GetSelectedVariantQueryVariables;
422
472
  };
423
- "\n query GetSelectedVariantByHandle(\n $handle: String!\n $selectedOptions: [SelectedOptionInput!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(handle: $handle) {\n ...selectedVariantFields\n }\n }\n \n fragment selectedVariantFields on Product {\n id\n title\n handle\n featuredImage {\n ...productImageFields\n }\n variantBySelectedOptions(selectedOptions: $selectedOptions) {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n title\n selectedOptions {\n name\n value\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
473
+ "\n query GetSelectedVariantByHandle(\n $handle: String!\n $selectedOptions: [SelectedOptionInput!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(handle: $handle) {\n ...selectedVariantFields\n }\n }\n \n fragment selectedVariantFields on Product {\n id\n availableForSale\n title\n handle\n featuredImage {\n ...productImageFields\n }\n variantBySelectedOptions(selectedOptions: $selectedOptions) {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n title\n selectedOptions {\n name\n value\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
424
474
  return: GetSelectedVariantByHandleQuery;
425
475
  variables: GetSelectedVariantByHandleQueryVariables;
426
476
  };
427
- "\n query GetProductDetailData(\n $productId: ID!\n $productMetafields: [HasMetafieldsIdentifier!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productCardDataFields\n ...productOptionsFields\n ...productImagesFields\n }\n }\n \n fragment productCardDataFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n featuredImage {\n ...productImageFields\n }\n isGiftCard\n onlineStoreUrl\n description\n descriptionHtml\n handle\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n }\n # totalInventory\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productOptionsFields on Product {\n id\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productImagesFields on Product {\n images(first: 20) {\n nodes {\n ...productImageFields\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
477
+ "\n query GetProductDetailData(\n $productId: ID!\n $productMetafields: [HasMetafieldsIdentifier!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productCardDataFields\n ...productOptionsFields\n ...productImagesFields\n }\n }\n \n fragment productCardDataFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n featuredImage {\n ...productImageFields\n }\n isGiftCard\n onlineStoreUrl\n description\n descriptionHtml\n handle\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n }\n # totalInventory\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productOptionsFields on Product {\n id\n availableForSale\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productImagesFields on Product {\n images(first: 20) {\n nodes {\n ...productImageFields\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
428
478
  return: GetProductDetailDataQuery;
429
479
  variables: GetProductDetailDataQueryVariables;
430
480
  };
431
- "\n query GetProductDetailDataWithVariant(\n $productId: ID!\n $variantId: ID!\n $productMetafields: [HasMetafieldsIdentifier!]!\n $variantMetafields: [HasMetafieldsIdentifier!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productCardDataFields\n ...productOptionsFields\n ...productImagesFields\n }\n variant: node(id: $variantId) {\n ...productVariantDataFields\n }\n }\n \n fragment productCardDataFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n featuredImage {\n ...productImageFields\n }\n isGiftCard\n onlineStoreUrl\n description\n descriptionHtml\n handle\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n }\n # totalInventory\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productOptionsFields on Product {\n id\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productVariantDataFields on ProductVariant {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n # quantityAvailable\n selectedOptions {\n name\n value\n }\n sku\n title\n metafields(identifiers: $variantMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productImagesFields on Product {\n images(first: 20) {\n nodes {\n ...productImageFields\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
481
+ "\n query GetProductDetailDataWithVariant(\n $productId: ID!\n $variantId: ID!\n $productMetafields: [HasMetafieldsIdentifier!]!\n $variantMetafields: [HasMetafieldsIdentifier!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productCardDataFields\n ...productOptionsFields\n ...productImagesFields\n }\n variant: node(id: $variantId) {\n ...productVariantDataFields\n }\n }\n \n fragment productCardDataFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n featuredImage {\n ...productImageFields\n }\n isGiftCard\n onlineStoreUrl\n description\n descriptionHtml\n handle\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n }\n # totalInventory\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productOptionsFields on Product {\n id\n availableForSale\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productVariantDataFields on ProductVariant {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n # quantityAvailable\n selectedOptions {\n name\n value\n }\n sku\n title\n metafields(identifiers: $variantMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productImagesFields on Product {\n images(first: 20) {\n nodes {\n ...productImageFields\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n": {
432
482
  return: GetProductDetailDataWithVariantQuery;
433
483
  variables: GetProductDetailDataWithVariantQueryVariables;
434
484
  };
@@ -2,7 +2,7 @@ import type { SwishUiManifest, SwishUiOptions } from "../types";
2
2
  import type { ShopBridge } from "../utils/shop-bridge";
3
3
  import type { Ref, SwishUiElement } from "./swish-ui-element";
4
4
  import "../utils/shop-bridge";
5
- import { Item, ItemDetail } from "@swishapp/api-client";
5
+ import { Item, ItemDetail, List } from "@swishapp/api-client";
6
6
  import { GetProductCardDataWithVariantQuery, GetSelectedVariantQuery } from "../storefront-api/storefront-api-client";
7
7
  export interface ToastManager {
8
8
  show(toast: Toast): string;
@@ -16,36 +16,43 @@ export interface Toast {
16
16
  action?: {
17
17
  label: string;
18
18
  url?: string;
19
- onAction?: () => void;
19
+ onClick?: () => void;
20
20
  };
21
21
  }
22
22
  export declare const setConfig: (opts: SwishUiOptions) => void;
23
23
  export declare const hideModal: (element: string | HTMLElement) => Promise<void>;
24
24
  export declare const showModal: (element: string | HTMLElement) => Promise<void>;
25
- export declare const showSignIn: (options?: {
25
+ export interface SignInOptions {
26
26
  returnTo?: string;
27
- }) => Promise<void>;
27
+ onClose?: () => void;
28
+ }
29
+ export declare const showSignIn: (options?: SignInOptions) => Promise<void>;
28
30
  export interface UnsaveAlertOptions {
29
31
  itemId: string;
30
32
  onSubmit?: (data: UnsaveAlertSubmitData) => void;
31
- onCancel?: () => void;
33
+ onClose?: () => void;
32
34
  }
33
35
  export interface UnsaveAlertSubmitData {
34
36
  itemId: string;
35
37
  }
36
38
  export declare const showUnsaveAlert: (options: UnsaveAlertOptions) => Promise<void>;
37
- export declare const showDeleteListAlert: (options: {
39
+ export interface DeleteListAlertOptions {
38
40
  listId: string;
39
41
  onSubmit?: () => void;
40
- onCancel?: () => void;
41
- }) => Promise<void>;
42
- export declare const showDrawer: () => Promise<void>;
43
- export declare const showListMenu: (options: {
42
+ onClose?: () => void;
43
+ }
44
+ export declare const showDeleteListAlert: (options: DeleteListAlertOptions) => Promise<void>;
45
+ export interface DrawerOptions {
46
+ onClose?: () => void;
47
+ }
48
+ export declare const showDrawer: (options?: DrawerOptions) => Promise<void>;
49
+ export interface ListMenuOptions {
44
50
  listId: string;
45
- onClose?: (data: {
46
- reason: string;
47
- }) => void;
48
- }) => Promise<void>;
51
+ onClose?: () => void;
52
+ onEdit?: (data: ListEditorSubmitData) => void;
53
+ onDelete?: () => void;
54
+ }
55
+ export declare const showListMenu: (options: ListMenuOptions) => Promise<void>;
49
56
  export interface ListSelectOptions {
50
57
  itemId: string;
51
58
  onSubmit?: (data: ListSelectSubmitData) => void | Promise<void>;
@@ -60,24 +67,15 @@ export interface ListSelectSubmitData {
60
67
  variant?: ListSelectVariant;
61
68
  }
62
69
  export declare const showListSelect: (options: ListSelectOptions) => Promise<void>;
63
- export declare const showToast: (options: {
64
- title?: string;
65
- text: string;
66
- image?: string;
67
- action?: {
68
- label: string;
69
- url?: string;
70
- onAction?: () => void;
71
- };
72
- }) => Promise<void>;
70
+ export declare const showToast: (toast: Toast) => Promise<void>;
73
71
  export declare const hideAllToasts: () => Promise<void>;
74
72
  export interface VariantSelectOptions {
75
73
  productId?: string;
76
74
  productHandle?: string;
77
75
  variantId?: string;
78
76
  displayType?: "rows" | "pills";
79
- action?: "none" | "save";
80
77
  onSubmit: (data: VariantSelectSubmitData) => void;
78
+ onClose: () => void;
81
79
  }
82
80
  export type VariantSelectProduct = Exclude<GetSelectedVariantQuery["product"], undefined | null>;
83
81
  export type VariantSelectVariant = Exclude<VariantSelectProduct["variantBySelectedOptions"], undefined | null>;
@@ -87,11 +85,15 @@ export interface VariantSelectSubmitData {
87
85
  variant: VariantSelectVariant;
88
86
  }
89
87
  export declare const showVariantSelect: (options?: VariantSelectOptions) => Promise<void>;
90
- export declare const showListEditor: <TData = unknown>(options?: {
88
+ export interface ListEditorOptions {
91
89
  listId?: string;
92
- variantId?: string;
93
- onSubmit: (data: TData) => void | Promise<void>;
94
- }) => Promise<void>;
90
+ onSubmit: (data: ListEditorSubmitData) => void | Promise<void>;
91
+ onClose: () => void;
92
+ }
93
+ export interface ListEditorSubmitData {
94
+ list: List;
95
+ }
96
+ export declare const showListEditor: (options?: ListEditorOptions) => Promise<void>;
95
97
  export declare const initShopBridge: ({ onShopModalOpen, }: {
96
98
  onShopModalOpen: () => void;
97
99
  }) => Promise<ShopBridge>;
package/dist/swish.d.ts CHANGED
@@ -2,7 +2,8 @@ import type { SwishAppOptions, SwishEmbedData } from "./types";
2
2
  import { AjaxApiClient } from "./ajax-api/ajax-api-client";
3
3
  import { createElementLocator, createLocationObserver } from "./dom/dom-utils";
4
4
  import { EventBus } from "./events/event-bus";
5
- import { effect, signal } from "./state";
5
+ import { Intents } from "./intents/intents";
6
+ import { computed, effect, signal } from "./state";
6
7
  import { StorefrontApiClient } from "./storefront-api/storefront-api-client";
7
8
  import { SwishApi } from "./swish-api/swish-api-client";
8
9
  export declare const VERSION: string;
@@ -16,6 +17,7 @@ export declare class SwishApp {
16
17
  private readonly ajaxApiPublisher;
17
18
  private readonly options;
18
19
  readonly events: EventBus;
20
+ readonly intents: Intents;
19
21
  constructor(options: SwishAppOptions);
20
22
  get customer(): {
21
23
  id: string | null;
@@ -39,45 +41,12 @@ export declare class SwishApp {
39
41
  get ajax(): AjaxApiClient;
40
42
  get shopUrl(): string;
41
43
  readonly ui: {
42
- showSignIn: (options?: {
43
- returnTo?: string;
44
- }) => Promise<void>;
45
- showVariantSelect: (options?: import(".").VariantSelectOptions) => Promise<void>;
44
+ hideModal: (element: string | HTMLElement) => Promise<void>;
45
+ showModal: (element: string | HTMLElement) => Promise<void>;
46
46
  initShopBridge: ({ onShopModalOpen, }: {
47
47
  onShopModalOpen: () => void;
48
48
  }) => Promise<import(".").ShopBridge>;
49
- showToast: (options: {
50
- title?: string;
51
- text: string;
52
- image?: string;
53
- action?: {
54
- label: string;
55
- url?: string;
56
- onAction?: () => void;
57
- };
58
- }) => Promise<void>;
59
- hideAllToasts: () => Promise<void>;
60
- showListSelect: (options: import(".").ListSelectOptions) => Promise<void>;
61
- showDrawer: () => Promise<void>;
62
- showListEditor: <TData = unknown>(options?: {
63
- listId?: string;
64
- variantId?: string;
65
- onSubmit: (data: TData) => void | Promise<void>;
66
- }) => Promise<void>;
67
- showUnsaveAlert: (options: import(".").UnsaveAlertOptions) => Promise<void>;
68
- hideModal: (element: string | HTMLElement) => Promise<void>;
69
- showModal: (element: string | HTMLElement) => Promise<void>;
70
- showListMenu: (options: {
71
- listId: string;
72
- onClose?: (data: {
73
- reason: string;
74
- }) => void;
75
- }) => Promise<void>;
76
- showDeleteListAlert: (options: {
77
- listId: string;
78
- onSubmit?: () => void;
79
- onCancel?: () => void;
80
- }) => Promise<void>;
49
+ showToast: (toast: import(".").Toast) => Promise<void>;
81
50
  };
82
51
  readonly dom: {
83
52
  createElementLocator: typeof createElementLocator;
@@ -96,8 +65,8 @@ export declare class SwishApp {
96
65
  unsaving: boolean;
97
66
  }> & {
98
67
  save: () => Promise<void>;
99
- unsave: () => void;
100
- update: () => void;
68
+ unsave: () => Promise<void>;
69
+ update: () => Promise<void>;
101
70
  toggle: () => Promise<void>;
102
71
  };
103
72
  itemCount: () => import("@preact/signals-core").ReadonlySignal<{
@@ -120,5 +89,6 @@ export declare class SwishApp {
120
89
  };
121
90
  effect: typeof effect;
122
91
  signal: typeof signal;
92
+ computed: typeof computed;
123
93
  };
124
94
  }