@shopify/hydrogen-react 2022.10.1 → 2022.10.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/dist/dev/AddToCartButton.js +70 -0
- package/dist/dev/AddToCartButton.js.map +1 -0
- package/dist/dev/AddToCartButton.mjs +70 -0
- package/dist/dev/AddToCartButton.mjs.map +1 -0
- package/dist/dev/BaseButton.js +31 -0
- package/dist/dev/BaseButton.js.map +1 -0
- package/dist/dev/BaseButton.mjs +31 -0
- package/dist/dev/BaseButton.mjs.map +1 -0
- package/dist/dev/BuyNowButton.js +45 -0
- package/dist/dev/BuyNowButton.js.map +1 -0
- package/dist/dev/BuyNowButton.mjs +45 -0
- package/dist/dev/BuyNowButton.mjs.map +1 -0
- package/dist/dev/CartCheckoutButton.js +30 -0
- package/dist/dev/CartCheckoutButton.js.map +1 -0
- package/dist/dev/CartCheckoutButton.mjs +30 -0
- package/dist/dev/CartCheckoutButton.mjs.map +1 -0
- package/dist/dev/MediaFile.js.map +1 -1
- package/dist/dev/MediaFile.mjs.map +1 -1
- package/dist/dev/Metafield.js +6 -0
- package/dist/dev/Metafield.js.map +1 -1
- package/dist/dev/Metafield.mjs +6 -0
- package/dist/dev/Metafield.mjs.map +1 -1
- package/dist/dev/ProductPrice.js.map +1 -1
- package/dist/dev/ProductPrice.mjs.map +1 -1
- package/dist/dev/cart-hooks.js +2 -2
- package/dist/dev/cart-hooks.js.map +1 -1
- package/dist/dev/cart-hooks.mjs +3 -3
- package/dist/dev/cart-hooks.mjs.map +1 -1
- package/dist/dev/index.js +8 -0
- package/dist/dev/index.js.map +1 -1
- package/dist/dev/index.mjs +8 -0
- package/dist/dev/index.mjs.map +1 -1
- package/dist/dev/metafield-parser.js +103 -0
- package/dist/dev/metafield-parser.js.map +1 -0
- package/dist/dev/metafield-parser.mjs +103 -0
- package/dist/dev/metafield-parser.mjs.map +1 -0
- package/dist/prod/AddToCartButton.js +70 -0
- package/dist/prod/AddToCartButton.js.map +1 -0
- package/dist/prod/AddToCartButton.mjs +70 -0
- package/dist/prod/AddToCartButton.mjs.map +1 -0
- package/dist/prod/BaseButton.js +31 -0
- package/dist/prod/BaseButton.js.map +1 -0
- package/dist/prod/BaseButton.mjs +31 -0
- package/dist/prod/BaseButton.mjs.map +1 -0
- package/dist/prod/BuyNowButton.js +45 -0
- package/dist/prod/BuyNowButton.js.map +1 -0
- package/dist/prod/BuyNowButton.mjs +45 -0
- package/dist/prod/BuyNowButton.mjs.map +1 -0
- package/dist/prod/CartCheckoutButton.js +30 -0
- package/dist/prod/CartCheckoutButton.js.map +1 -0
- package/dist/prod/CartCheckoutButton.mjs +30 -0
- package/dist/prod/CartCheckoutButton.mjs.map +1 -0
- package/dist/prod/MediaFile.js.map +1 -1
- package/dist/prod/MediaFile.mjs.map +1 -1
- package/dist/prod/Metafield.js.map +1 -1
- package/dist/prod/Metafield.mjs.map +1 -1
- package/dist/prod/ProductPrice.js.map +1 -1
- package/dist/prod/ProductPrice.mjs.map +1 -1
- package/dist/prod/cart-hooks.js +2 -2
- package/dist/prod/cart-hooks.js.map +1 -1
- package/dist/prod/cart-hooks.mjs +3 -3
- package/dist/prod/cart-hooks.mjs.map +1 -1
- package/dist/prod/index.js +8 -0
- package/dist/prod/index.js.map +1 -1
- package/dist/prod/index.mjs +8 -0
- package/dist/prod/index.mjs.map +1 -1
- package/dist/prod/metafield-parser.js +114 -0
- package/dist/prod/metafield-parser.js.map +1 -0
- package/dist/prod/metafield-parser.mjs +114 -0
- package/dist/prod/metafield-parser.mjs.map +1 -0
- package/dist/types/AddToCartButton.d.ts +22 -0
- package/dist/types/BaseButton.d.ts +15 -0
- package/dist/types/BuyNowButton.d.ts +15 -0
- package/dist/types/CartCheckoutButton.d.ts +12 -0
- package/dist/types/CartCost.d.ts +13 -0
- package/dist/types/MediaFile.d.ts +3 -1
- package/dist/types/Metafield.d.ts +3 -0
- package/dist/types/ProductPrice.d.ts +1 -2
- package/dist/types/index.d.cts +4 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/metafield-parser.d.ts +222 -0
- package/dist/umd/hydrogen-react.dev.js +482 -203
- package/dist/umd/hydrogen-react.dev.js.map +1 -1
- package/dist/umd/hydrogen-react.prod.js +17 -17
- package/dist/umd/hydrogen-react.prod.js.map +1 -1
- package/package.json +12 -4
- package/dist/dev/node_modules/worktop/cookie/index.js +0 -27
- package/dist/dev/node_modules/worktop/cookie/index.js.map +0 -1
- package/dist/dev/node_modules/worktop/cookie/index.mjs +0 -27
- package/dist/dev/node_modules/worktop/cookie/index.mjs.map +0 -1
- package/dist/prod/node_modules/worktop/cookie/index.js +0 -27
- package/dist/prod/node_modules/worktop/cookie/index.js.map +0 -1
- package/dist/prod/node_modules/worktop/cookie/index.mjs +0 -27
- package/dist/prod/node_modules/worktop/cookie/index.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metafield-parser.mjs","sources":["../../src/metafield-parser.ts"],"sourcesContent":["import type {\n Collection,\n GenericFile,\n Metafield as MetafieldBaseType,\n MoneyV2,\n Page,\n Product,\n ProductVariant,\n} from './storefront-api-types.js';\nimport type {PartialDeep, Simplify} from 'type-fest';\nimport {parseJSON} from './Metafield.js';\nimport {flattenConnection} from './flatten-connection.js';\n\n/**\n * A temporary function that will be renamed to `parseMetafield()` in a future release.\n *\n * A function that uses `metafield.type` to parse the Metafield's `value` or `reference` or `references` (depending on the `type`) and put it in `metafield.parsedValue`\n *\n * TypeScript developers can use the type `ParsedMetafields` from this package to get the returned object's type correct. For example:\n *\n * ```\n * metafieldParser<ParsedMetafields['boolean']>({type: 'boolean', value: 'false'}\n * ```\n */\nexport function metafieldParser<ReturnGeneric>(\n metafield: PartialDeep<MetafieldBaseType, {recurseIntoArrays: true}>\n): ReturnGeneric {\n if (!metafield.type) {\n const noTypeError = `metafieldParser(): The 'type' field is required in order to parse the Metafield.`;\n if (__HYDROGEN_DEV__) {\n throw new Error(noTypeError);\n } else {\n console.error(`${noTypeError} Returning 'parsedValue' of 'null'`);\n return {\n ...metafield,\n parsedValue: null,\n } as ReturnGeneric;\n }\n }\n\n switch (metafield.type) {\n case 'boolean':\n return {\n ...metafield,\n parsedValue: metafield.value === 'true',\n } as ReturnGeneric;\n\n case 'collection_reference':\n case 'file_reference':\n case 'page_reference':\n case 'product_reference':\n case 'variant_reference':\n return {\n ...metafield,\n parsedValue: metafield.reference,\n } as ReturnGeneric;\n\n case 'color':\n case 'multi_line_text_field':\n case 'single_line_text_field':\n case 'url':\n return {\n ...metafield,\n parsedValue: metafield.value,\n } as ReturnGeneric;\n\n // TODO: 'money' should probably be parsed even further to like `useMoney()`, but that logic needs to be extracted first so it's not a hook\n case 'dimension':\n case 'money':\n case 'json':\n case 'rating':\n case 'volume':\n case 'weight':\n case 'list.color':\n case 'list.dimension':\n case 'list.number_integer':\n case 'list.number_decimal':\n case 'list.rating':\n case 'list.single_line_text_field':\n case 'list.url':\n case 'list.volume':\n case 'list.weight': {\n let parsedValue = null;\n try {\n parsedValue = parseJSON(metafield.value ?? '');\n } catch (err) {\n const parseError = `metafieldParser(): attempted to JSON.parse the 'metafield.value' property, but failed.`;\n if (__HYDROGEN_DEV__) {\n throw new Error(parseError);\n } else {\n console.error(`${parseError} Returning 'null' for 'parsedValue'`);\n }\n parsedValue = null;\n }\n return {\n ...metafield,\n parsedValue,\n } as ReturnGeneric;\n }\n\n case 'date':\n case 'date_time':\n return {\n ...metafield,\n parsedValue: new Date(metafield.value ?? ''),\n } as ReturnGeneric;\n\n case 'list.date':\n case 'list.date_time': {\n const jsonParseValue = parseJSON(metafield?.value ?? '') as string[];\n return {\n ...metafield,\n parsedValue: jsonParseValue.map((dateString) => new Date(dateString)),\n } as ReturnGeneric;\n }\n\n case 'number_decimal':\n case 'number_integer':\n return {\n ...metafield,\n parsedValue: Number(metafield.value),\n } as ReturnGeneric;\n\n case 'list.collection_reference':\n case 'list.file_reference':\n case 'list.page_reference':\n case 'list.product_reference':\n case 'list.variant_reference':\n return {\n ...metafield,\n parsedValue: flattenConnection(metafield.references ?? undefined),\n } as ReturnGeneric;\n\n default: {\n const typeNotFoundError = `metafieldParser(): the 'metafield.type' you passed in is not supported. Your type: \"${metafield.type}\". If you believe this is an error, please open an issue on GitHub.`;\n if (__HYDROGEN_DEV__) {\n throw new Error(typeNotFoundError);\n } else {\n console.error(\n `${typeNotFoundError} Returning 'parsedValue' of 'null'`\n );\n return {\n ...metafield,\n parsedValue: null,\n } as ReturnGeneric;\n }\n }\n }\n}\n\n// taken from https://shopify.dev/apps/metafields/types\nexport const allMetafieldTypesArray = [\n 'boolean',\n 'collection_reference',\n 'color',\n 'date',\n 'date_time',\n 'dimension',\n 'file_reference',\n 'json',\n 'money',\n 'multi_line_text_field',\n 'number_decimal',\n 'number_integer',\n 'page_reference',\n 'product_reference',\n 'rating',\n 'single_line_text_field',\n 'url',\n 'variant_reference',\n 'volume',\n 'weight',\n // list metafields\n 'list.collection_reference',\n 'list.color',\n 'list.date',\n 'list.date_time',\n 'list.dimension',\n 'list.file_reference',\n 'list.number_integer',\n 'list.number_decimal',\n 'list.page_reference',\n 'list.product_reference',\n 'list.rating',\n 'list.single_line_text_field',\n 'list.url',\n 'list.variant_reference',\n 'list.volume',\n 'list.weight',\n] as const;\n\n/** A union of all the supported `metafield.type`s */\nexport type MetafieldTypeTypes = typeof allMetafieldTypesArray[number];\n\n/**\n * A mapping of a Metafield's `type` to the TypeScript type that is returned from `metafieldParser()`\n * For example, when using `metafieldParser()`, the type will be correctly returned when used like the following:\n *\n * ```\n * const parsedMetafield = metafieldParser<ParsedMetafields['boolean']>(metafield);`\n * ```\n * `parsedMetafield.parsedValue`'s type is now `boolean`\n */\nexport type ParsedMetafields<ExtraTypeGeneric = void> = {\n /** A Metafield that's been parsed, with a `parsedValue` of `boolean` */\n boolean: Simplify<BooleanParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of a `Collection` object (as defined by the Storefront API) */\n collection_reference: Simplify<CollectionParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `string` */\n color: Simplify<ColorParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Date` */\n date: Simplify<DatesParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Date` */\n date_time: Simplify<DatesParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Measurement` */\n dimension: Simplify<MeasurementParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of a `GenericFile` object (as defined by the Storefront API) */\n file_reference: Simplify<FileRefParsedMetafield>;\n /**\n * A Metafield that's been parsed, with a `parsedValue` of type `unknown`, unless you pass in the type as a generic. For example:\n *\n * ```\n * ParsedMetafields<MyJsonType>['json']\n * ```\n */\n json: Simplify<JsonParsedMetafield<ExtraTypeGeneric>>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Money` */\n money: Simplify<MoneyParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `string` */\n multi_line_text_field: Simplify<TextParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `number` */\n number_decimal: Simplify<NumberParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `number` */\n number_integer: Simplify<NumberParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of a `Page` object (as defined by the Storefront API) */\n page_reference: Simplify<PageParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of a `Product` object (as defined by the Storefront API) */\n product_reference: Simplify<ProductParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Rating` */\n rating: Simplify<RatingParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `string` */\n single_line_text_field: Simplify<TextParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `string` */\n url: Simplify<TextParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of a `ProductVariant` object (as defined by the Storefront API) */\n variant_reference: Simplify<VariantParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Measurement` */\n volume: Simplify<MeasurementParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of type `Measurement` */\n weight: Simplify<MeasurementParsedMetafield>;\n // list metafields\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Collection` objects (as defined by the Storefront API) */\n 'list.collection_reference': Simplify<CollectionListParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of strings */\n 'list.color': Simplify<ColorListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of Date objects */\n 'list.date': Simplify<DatesListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of Date objects */\n 'list.date_time': Simplify<DatesListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Measurement` objects */\n 'list.dimension': Simplify<MeasurementListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `GenericFile` objects (as defined by the Storefront API) */\n 'list.file_reference': Simplify<FileListParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of numbers */\n 'list.number_integer': Simplify<NumberListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of numbers */\n 'list.number_decimal': Simplify<NumberListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Page` objects (as defined by the Storefront API) */\n 'list.page_reference': Simplify<PageListParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Product` objects (as defined by the Storefront API) */\n 'list.product_reference': Simplify<ProductListParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Rating`s */\n 'list.rating': Simplify<RatingListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of strings */\n 'list.single_line_text_field': Simplify<TextListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of strings */\n 'list.url': Simplify<TextListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `ProductVariant` objects (as defined by the Storefront API) */\n 'list.variant_reference': Simplify<VariantListParsedRefMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Measurement`s */\n 'list.volume': Simplify<MeasurementListParsedMetafield>;\n /** A Metafield that's been parsed, with a `parsedValue` of an array of `Measurement`s */\n 'list.weight': Simplify<MeasurementListParsedMetafield>;\n};\n\ninterface ParsedBase extends MetafieldBaseType {\n type: MetafieldTypeTypes;\n parsedValue: unknown;\n}\n\ninterface BooleanParsedMetafield extends ParsedBase {\n type: 'boolean';\n parsedValue: boolean | null;\n}\ntype CollectionParsedRefMetafield = MetafieldBaseType & {\n type: 'collection_reference';\n parsedValue: Collection | null;\n};\ntype ColorParsedMetafield = MetafieldBaseType & {\n type: 'color';\n parsedValue: string | null;\n};\ntype DatesParsedMetafield = MetafieldBaseType & {\n type: 'date' | 'date_time';\n parsedValue: Date | null;\n};\n\ntype MeasurementParsedMetafield = MetafieldBaseType & {\n type: 'dimension' | 'weight' | 'volume';\n parsedValue: Measurement | null;\n};\n\ntype FileRefParsedMetafield = MetafieldBaseType & {\n type: 'file_reference';\n parsedValue: GenericFile | null;\n};\n\ntype JsonParsedMetafield<JsonTypeGeneric = void> = MetafieldBaseType & {\n type: 'json';\n parsedValue: JsonTypeGeneric extends void ? unknown : JsonTypeGeneric | null;\n};\n\ntype MoneyParsedMetafield = MetafieldBaseType & {\n type: 'money';\n parsedValue: MoneyV2 | null;\n};\n\ntype TextParsedMetafield = MetafieldBaseType & {\n type: 'single_line_text_field' | 'multi_line_text_field' | 'url';\n parsedValue: string | null;\n};\n\ntype NumberParsedMetafield = MetafieldBaseType & {\n type: 'number_decimal' | 'number_integer';\n parsedValue: number | null;\n};\n\ntype PageParsedRefMetafield = MetafieldBaseType & {\n type: 'page_reference';\n parsedValue: Page | null;\n};\n\ntype ProductParsedRefMetafield = MetafieldBaseType & {\n type: 'product_reference';\n parsedValue: Product | null;\n};\n\ntype RatingParsedMetafield = MetafieldBaseType & {\n type: 'rating';\n parsedValue: Rating | null;\n};\n\ntype VariantParsedRefMetafield = MetafieldBaseType & {\n type: 'variant_reference';\n parsedValue: ProductVariant | null;\n};\n\ntype CollectionListParsedRefMetafield = MetafieldBaseType & {\n type: 'list.collection_reference';\n parsedValue: Array<Collection> | null;\n};\n\ntype ColorListParsedMetafield = MetafieldBaseType & {\n type: 'list.color';\n parsedValue: Array<string> | null;\n};\n\ntype DatesListParsedMetafield = MetafieldBaseType & {\n type: 'list.date' | 'list.date_time';\n parsedValue: Array<Date> | null;\n};\n\ntype MeasurementListParsedMetafield = MetafieldBaseType & {\n type: 'list.dimension' | 'list.weight' | 'list.volume';\n parsedValue: Array<Measurement> | null;\n};\n\ntype FileListParsedRefMetafield = MetafieldBaseType & {\n type: 'list.file_reference';\n parsedValue: Array<GenericFile> | null;\n};\n\ntype TextListParsedMetafield = MetafieldBaseType & {\n type: 'list.single_line_text_field' | 'list.url';\n parsedValue: Array<string> | null;\n};\n\ntype NumberListParsedMetafield = MetafieldBaseType & {\n type: 'list.number_decimal' | 'list.number_integer';\n parsedValue: Array<number> | null;\n};\n\ntype PageListParsedRefMetafield = MetafieldBaseType & {\n type: 'list.page_reference';\n parsedValue: Array<Page> | null;\n};\n\ntype ProductListParsedRefMetafield = MetafieldBaseType & {\n type: 'list.product_reference';\n parsedValue: Array<Product> | null;\n};\n\ntype RatingListParsedMetafield = MetafieldBaseType & {\n type: 'list.rating';\n parsedValue: Array<Rating> | null;\n};\n\ntype VariantListParsedRefMetafield = MetafieldBaseType & {\n type: 'list.variant_reference';\n parsedValue: Array<ProductVariant> | null;\n};\n\nexport type Measurement = {\n unit: string;\n value: number;\n};\n\nexport interface Rating {\n value: number;\n scale_min: number;\n scale_max: number;\n}\n"],"names":[],"mappings":";;AAwBO,SAAS,gBACd,WACe;;AACX,MAAA,CAAC,UAAU,MAAM;AACnB,UAAM,cAAc;AAGb;AACG,cAAA,MAAM,GAAG,+CAA+C;AACzD,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa;AAAA,MAAA;AAAA,IAEjB;AAAA,EACF;AAEA,UAAQ,UAAU,MAAM;AAAA,IACtB,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,UAAU,UAAU;AAAA,MAAA;AAAA,IAGrC,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,UAAU;AAAA,MAAA;AAAA,IAG3B,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,UAAU;AAAA,MAAA;AAAA,IAI3B,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK,eAAe;AAClB,UAAI,cAAc;AACd,UAAA;AACY,sBAAA,WAAU,eAAU,UAAV,YAAmB,EAAE;AAAA,eACtC;AACP,cAAM,aAAa;AAGZ;AACG,kBAAA,MAAM,GAAG,+CAA+C;AAAA,QAClE;AACc,sBAAA;AAAA,MAChB;AACO,aAAA;AAAA,QACL,GAAG;AAAA,QACH;AAAA,MAAA;AAAA,IAEJ;AAAA,IAEA,KAAK;AAAA,IACL,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,IAAI,MAAK,eAAU,UAAV,YAAmB,EAAE;AAAA,MAAA;AAAA,IAG/C,KAAK;AAAA,IACL,KAAK,kBAAkB;AACrB,YAAM,iBAAiB,WAAU,4CAAW,UAAX,YAAoB,EAAE;AAChD,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,eAAe,IAAI,CAAC,eAAe,IAAI,KAAK,UAAU,CAAC;AAAA,MAAA;AAAA,IAExE;AAAA,IAEA,KAAK;AAAA,IACL,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,OAAO,UAAU,KAAK;AAAA,MAAA;AAAA,IAGvC,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,aAAa,mBAAkB,eAAU,eAAV,YAAwB,MAAS;AAAA,MAAA;AAAA,IAGpE,SAAS;AACD,YAAA,oBAAoB,uFAAuF,UAAU;AAGpH;AACG,gBAAA;AAAA,UACN,GAAG;AAAA,QAAA;AAEE,eAAA;AAAA,UACL,GAAG;AAAA,UACH,aAAa;AAAA,QAAA;AAAA,MAEjB;AAAA,IACF;AAAA,EACF;AACF;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BaseButtonProps } from './BaseButton.js';
|
|
2
|
+
interface AddToCartButtonProps {
|
|
3
|
+
/** An array of cart line attributes that belong to the item being added to the cart. */
|
|
4
|
+
attributes?: {
|
|
5
|
+
key: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}[];
|
|
8
|
+
/** The ID of the variant. */
|
|
9
|
+
variantId?: string | null;
|
|
10
|
+
/** The item quantity. */
|
|
11
|
+
quantity?: number;
|
|
12
|
+
/** The text that is announced by the screen reader when the item is being added to the cart. Used for accessibility purposes only and not displayed on the page. */
|
|
13
|
+
accessibleAddingToCartLabel?: string;
|
|
14
|
+
/** The selling plan ID of the subscription variant */
|
|
15
|
+
sellingPlanId?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The `AddToCartButton` component renders a button that adds an item to the cart when pressed.
|
|
19
|
+
* It must be a descendent of the `CartProvider` component.
|
|
20
|
+
*/
|
|
21
|
+
export declare function AddToCartButton<AsType extends React.ElementType = 'button'>(props: AddToCartButtonProps & BaseButtonProps<AsType>): JSX.Element;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode, Ref } from 'react';
|
|
2
|
+
export interface CustomBaseButtonProps<AsType> {
|
|
3
|
+
/** Provide a React element or component to render as the underlying button. Note: for accessibility compliance, almost always you should use a `button` element, or a component that renders an underlying button. */
|
|
4
|
+
as?: AsType;
|
|
5
|
+
/** Any ReactNode elements. */
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
/** Click event handler. Default behaviour triggers unless prevented */
|
|
8
|
+
onClick?: (event?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void | boolean;
|
|
9
|
+
/** A default onClick behavior */
|
|
10
|
+
defaultOnClick?: (event?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void | boolean;
|
|
11
|
+
/** A ref to the underlying button */
|
|
12
|
+
buttonRef?: Ref<HTMLButtonElement>;
|
|
13
|
+
}
|
|
14
|
+
export declare type BaseButtonProps<AsType extends React.ElementType> = CustomBaseButtonProps<AsType> & Omit<React.ComponentPropsWithoutRef<AsType>, keyof CustomBaseButtonProps<AsType>>;
|
|
15
|
+
export declare function BaseButton<AsType extends React.ElementType = 'button'>(props: BaseButtonProps<AsType>): JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseButtonProps } from './BaseButton.js';
|
|
2
|
+
interface BuyNowButtonProps {
|
|
3
|
+
/** The item quantity. Defaults to 1. */
|
|
4
|
+
quantity?: number;
|
|
5
|
+
/** The ID of the variant. */
|
|
6
|
+
variantId: string;
|
|
7
|
+
/** An array of cart line attributes that belong to the item being added to the cart. */
|
|
8
|
+
attributes?: {
|
|
9
|
+
key: string;
|
|
10
|
+
value: string;
|
|
11
|
+
}[];
|
|
12
|
+
}
|
|
13
|
+
/** The `BuyNowButton` component renders a button that adds an item to the cart and redirects the customer to checkout. */
|
|
14
|
+
export declare function BuyNowButton<AsType extends React.ElementType = 'button'>(props: BuyNowButtonProps & BaseButtonProps<AsType>): JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { BaseButtonProps } from './BaseButton.js';
|
|
3
|
+
declare type PropsWeControl = 'onClick';
|
|
4
|
+
/**
|
|
5
|
+
* The `CartCheckoutButton` component renders a button that redirects to the checkout URL for the cart.
|
|
6
|
+
* It must be a descendent of a `CartProvider` component.
|
|
7
|
+
*/
|
|
8
|
+
export declare function CartCheckoutButton(props: Omit<BaseButtonProps<'button'>, PropsWeControl> & {
|
|
9
|
+
/** A `ReactNode` element. */
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}): JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Money } from './Money.js';
|
|
2
|
+
export interface CartCostProps {
|
|
3
|
+
/** A string type that defines the type of cost needed. Valid values: `total`, `subtotal`, `tax`, or `duty`. */
|
|
4
|
+
amountType?: 'total' | 'subtotal' | 'tax' | 'duty';
|
|
5
|
+
/** Any `ReactNode` elements. */
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The `CartCost` component renders a `Money` component with the
|
|
10
|
+
* cost associated with the `amountType` prop. If no `amountType` prop is specified, then it defaults to `totalAmount`.
|
|
11
|
+
Depends on `useCart()` and must be a child of `<CartProvider/>`
|
|
12
|
+
*/
|
|
13
|
+
export declare function CartCost(props: Omit<React.ComponentProps<typeof Money>, 'data'> & CartCostProps): JSX.Element | null;
|
|
@@ -4,7 +4,9 @@ import { ExternalVideo } from './ExternalVideo.js';
|
|
|
4
4
|
import { ModelViewer } from './ModelViewer.js';
|
|
5
5
|
import type { MediaEdge as MediaEdgeType } from './storefront-api-types.js';
|
|
6
6
|
import type { PartialDeep } from 'type-fest';
|
|
7
|
-
|
|
7
|
+
import type { ModelViewerElement } from '@google/model-viewer/lib/model-viewer.js';
|
|
8
|
+
declare type BaseProps = React.HTMLAttributes<HTMLImageElement | HTMLVideoElement | HTMLIFrameElement | ModelViewerElement>;
|
|
9
|
+
export interface MediaFileProps extends BaseProps {
|
|
8
10
|
/** An object with fields that correspond to the Storefront API's [Media object](https://shopify.dev/api/storefront/reference/products/media). */
|
|
9
11
|
data: PartialDeep<MediaEdgeType['node'], {
|
|
10
12
|
recurseIntoArrays: true;
|
|
@@ -22,6 +22,8 @@ export declare function Metafield<ComponentGeneric extends ElementType>(props: M
|
|
|
22
22
|
* The `parseMetafield` utility transforms a [Metafield](https://shopify.dev/api/storefront/reference/common-objects/Metafield)
|
|
23
23
|
* into a new object whose `values` have been parsed according to the metafield `type`.
|
|
24
24
|
* If the metafield is `null`, then it returns `null` back.
|
|
25
|
+
*
|
|
26
|
+
* Note that `parseMetafield()` will have a breaking change in a future version; it will change to behave like `metafieldParser()`.
|
|
25
27
|
*/
|
|
26
28
|
export declare function parseMetafield(
|
|
27
29
|
/** A [Metafield](https://shopify.dev/api/storefront/reference/common-objects/Metafield) or null */
|
|
@@ -32,6 +34,7 @@ metafield: PartialDeep<MetafieldType, {
|
|
|
32
34
|
}> | null;
|
|
33
35
|
/**
|
|
34
36
|
* The `parseMetafieldValue` function parses a [Metafield](https://shopify.dev/api/storefront/reference/common-objects/metafield)'s `value` from a string into a sensible type corresponding to the [Metafield](https://shopify.dev/api/storefront/reference/common-objects/metafield)'s `type`.
|
|
37
|
+
* @deprecated `parseMetafieldValue()` is unsupported and will be removed in a future version.
|
|
35
38
|
*/
|
|
36
39
|
export declare function parseMetafieldValue(metafield: PartialDeep<MetafieldType, {
|
|
37
40
|
recurseIntoArrays: true;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Product } from './storefront-api-types.js';
|
|
2
2
|
import { type MoneyProps } from './Money.js';
|
|
3
3
|
import type { PartialDeep } from 'type-fest';
|
|
4
|
-
interface ProductPriceProps {
|
|
4
|
+
export interface ProductPriceProps {
|
|
5
5
|
/** A [Product object](https://shopify.dev/api/storefront/reference/products/product). */
|
|
6
6
|
data: PartialDeep<Product, {
|
|
7
7
|
recurseIntoArrays: true;
|
|
@@ -18,4 +18,3 @@ interface ProductPriceProps {
|
|
|
18
18
|
* [`priceRange`](https://shopify.dev/api/storefront/reference/products/productpricerange)'s `maxVariantPrice` or `minVariantPrice`, for either the regular price or compare at price range.
|
|
19
19
|
*/
|
|
20
20
|
export declare function ProductPrice<ComponentGeneric extends React.ElementType>(props: ProductPriceProps & Omit<MoneyProps<ComponentGeneric>, 'data' | 'measurement'>): JSX.Element | null;
|
|
21
|
-
export {};
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
export { AddToCartButton } from './AddToCartButton.js';
|
|
2
|
+
export { BuyNowButton } from './BuyNowButton.js';
|
|
1
3
|
export type { CartState, CartStatus, Cart, CartWithActions, CartAction, } from './cart-types.js';
|
|
4
|
+
export { CartCheckoutButton } from './CartCheckoutButton.js';
|
|
2
5
|
export { CartProvider, useCart } from './CartProvider.js';
|
|
3
6
|
export { ExternalVideo } from './ExternalVideo.js';
|
|
4
7
|
export { flattenConnection } from './flatten-connection.js';
|
|
5
8
|
export { Image } from './Image.js';
|
|
6
9
|
export { MediaFile } from './MediaFile.js';
|
|
10
|
+
export { metafieldParser, type ParsedMetafields } from './metafield-parser.js';
|
|
7
11
|
export { Metafield, parseMetafield, parseMetafieldValue } from './Metafield.js';
|
|
8
12
|
export { ModelViewer } from './ModelViewer.js';
|
|
9
13
|
export { Money } from './Money.js';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
export { AddToCartButton } from './AddToCartButton.js';
|
|
2
|
+
export { BuyNowButton } from './BuyNowButton.js';
|
|
1
3
|
export type { CartState, CartStatus, Cart, CartWithActions, CartAction, } from './cart-types.js';
|
|
4
|
+
export { CartCheckoutButton } from './CartCheckoutButton.js';
|
|
2
5
|
export { CartProvider, useCart } from './CartProvider.js';
|
|
3
6
|
export { ExternalVideo } from './ExternalVideo.js';
|
|
4
7
|
export { flattenConnection } from './flatten-connection.js';
|
|
5
8
|
export { Image } from './Image.js';
|
|
6
9
|
export { MediaFile } from './MediaFile.js';
|
|
10
|
+
export { metafieldParser, type ParsedMetafields } from './metafield-parser.js';
|
|
7
11
|
export { Metafield, parseMetafield, parseMetafieldValue } from './Metafield.js';
|
|
8
12
|
export { ModelViewer } from './ModelViewer.js';
|
|
9
13
|
export { Money } from './Money.js';
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import type { Collection, GenericFile, Metafield as MetafieldBaseType, MoneyV2, Page, Product, ProductVariant } from './storefront-api-types.js';
|
|
2
|
+
import type { PartialDeep, Simplify } from 'type-fest';
|
|
3
|
+
/**
|
|
4
|
+
* A temporary function that will be renamed to `parseMetafield()` in a future release.
|
|
5
|
+
*
|
|
6
|
+
* A function that uses `metafield.type` to parse the Metafield's `value` or `reference` or `references` (depending on the `type`) and put it in `metafield.parsedValue`
|
|
7
|
+
*
|
|
8
|
+
* TypeScript developers can use the type `ParsedMetafields` from this package to get the returned object's type correct. For example:
|
|
9
|
+
*
|
|
10
|
+
* ```
|
|
11
|
+
* metafieldParser<ParsedMetafields['boolean']>({type: 'boolean', value: 'false'}
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function metafieldParser<ReturnGeneric>(metafield: PartialDeep<MetafieldBaseType, {
|
|
15
|
+
recurseIntoArrays: true;
|
|
16
|
+
}>): ReturnGeneric;
|
|
17
|
+
export declare const allMetafieldTypesArray: readonly ["boolean", "collection_reference", "color", "date", "date_time", "dimension", "file_reference", "json", "money", "multi_line_text_field", "number_decimal", "number_integer", "page_reference", "product_reference", "rating", "single_line_text_field", "url", "variant_reference", "volume", "weight", "list.collection_reference", "list.color", "list.date", "list.date_time", "list.dimension", "list.file_reference", "list.number_integer", "list.number_decimal", "list.page_reference", "list.product_reference", "list.rating", "list.single_line_text_field", "list.url", "list.variant_reference", "list.volume", "list.weight"];
|
|
18
|
+
/** A union of all the supported `metafield.type`s */
|
|
19
|
+
export declare type MetafieldTypeTypes = typeof allMetafieldTypesArray[number];
|
|
20
|
+
/**
|
|
21
|
+
* A mapping of a Metafield's `type` to the TypeScript type that is returned from `metafieldParser()`
|
|
22
|
+
* For example, when using `metafieldParser()`, the type will be correctly returned when used like the following:
|
|
23
|
+
*
|
|
24
|
+
* ```
|
|
25
|
+
* const parsedMetafield = metafieldParser<ParsedMetafields['boolean']>(metafield);`
|
|
26
|
+
* ```
|
|
27
|
+
* `parsedMetafield.parsedValue`'s type is now `boolean`
|
|
28
|
+
*/
|
|
29
|
+
export declare type ParsedMetafields<ExtraTypeGeneric = void> = {
|
|
30
|
+
/** A Metafield that's been parsed, with a `parsedValue` of `boolean` */
|
|
31
|
+
boolean: Simplify<BooleanParsedMetafield>;
|
|
32
|
+
/** A Metafield that's been parsed, with a `parsedValue` of a `Collection` object (as defined by the Storefront API) */
|
|
33
|
+
collection_reference: Simplify<CollectionParsedRefMetafield>;
|
|
34
|
+
/** A Metafield that's been parsed, with a `parsedValue` of type `string` */
|
|
35
|
+
color: Simplify<ColorParsedMetafield>;
|
|
36
|
+
/** A Metafield that's been parsed, with a `parsedValue` of type `Date` */
|
|
37
|
+
date: Simplify<DatesParsedMetafield>;
|
|
38
|
+
/** A Metafield that's been parsed, with a `parsedValue` of type `Date` */
|
|
39
|
+
date_time: Simplify<DatesParsedMetafield>;
|
|
40
|
+
/** A Metafield that's been parsed, with a `parsedValue` of type `Measurement` */
|
|
41
|
+
dimension: Simplify<MeasurementParsedMetafield>;
|
|
42
|
+
/** A Metafield that's been parsed, with a `parsedValue` of a `GenericFile` object (as defined by the Storefront API) */
|
|
43
|
+
file_reference: Simplify<FileRefParsedMetafield>;
|
|
44
|
+
/**
|
|
45
|
+
* A Metafield that's been parsed, with a `parsedValue` of type `unknown`, unless you pass in the type as a generic. For example:
|
|
46
|
+
*
|
|
47
|
+
* ```
|
|
48
|
+
* ParsedMetafields<MyJsonType>['json']
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
json: Simplify<JsonParsedMetafield<ExtraTypeGeneric>>;
|
|
52
|
+
/** A Metafield that's been parsed, with a `parsedValue` of type `Money` */
|
|
53
|
+
money: Simplify<MoneyParsedMetafield>;
|
|
54
|
+
/** A Metafield that's been parsed, with a `parsedValue` of type `string` */
|
|
55
|
+
multi_line_text_field: Simplify<TextParsedMetafield>;
|
|
56
|
+
/** A Metafield that's been parsed, with a `parsedValue` of type `number` */
|
|
57
|
+
number_decimal: Simplify<NumberParsedMetafield>;
|
|
58
|
+
/** A Metafield that's been parsed, with a `parsedValue` of type `number` */
|
|
59
|
+
number_integer: Simplify<NumberParsedMetafield>;
|
|
60
|
+
/** A Metafield that's been parsed, with a `parsedValue` of a `Page` object (as defined by the Storefront API) */
|
|
61
|
+
page_reference: Simplify<PageParsedRefMetafield>;
|
|
62
|
+
/** A Metafield that's been parsed, with a `parsedValue` of a `Product` object (as defined by the Storefront API) */
|
|
63
|
+
product_reference: Simplify<ProductParsedRefMetafield>;
|
|
64
|
+
/** A Metafield that's been parsed, with a `parsedValue` of type `Rating` */
|
|
65
|
+
rating: Simplify<RatingParsedMetafield>;
|
|
66
|
+
/** A Metafield that's been parsed, with a `parsedValue` of type `string` */
|
|
67
|
+
single_line_text_field: Simplify<TextParsedMetafield>;
|
|
68
|
+
/** A Metafield that's been parsed, with a `parsedValue` of type `string` */
|
|
69
|
+
url: Simplify<TextParsedMetafield>;
|
|
70
|
+
/** A Metafield that's been parsed, with a `parsedValue` of a `ProductVariant` object (as defined by the Storefront API) */
|
|
71
|
+
variant_reference: Simplify<VariantParsedRefMetafield>;
|
|
72
|
+
/** A Metafield that's been parsed, with a `parsedValue` of type `Measurement` */
|
|
73
|
+
volume: Simplify<MeasurementParsedMetafield>;
|
|
74
|
+
/** A Metafield that's been parsed, with a `parsedValue` of type `Measurement` */
|
|
75
|
+
weight: Simplify<MeasurementParsedMetafield>;
|
|
76
|
+
/** A Metafield that's been parsed, with a `parsedValue` of an array of `Collection` objects (as defined by the Storefront API) */
|
|
77
|
+
'list.collection_reference': Simplify<CollectionListParsedRefMetafield>;
|
|
78
|
+
/** A Metafield that's been parsed, with a `parsedValue` of an array of strings */
|
|
79
|
+
'list.color': Simplify<ColorListParsedMetafield>;
|
|
80
|
+
/** A Metafield that's been parsed, with a `parsedValue` of an array of Date objects */
|
|
81
|
+
'list.date': Simplify<DatesListParsedMetafield>;
|
|
82
|
+
/** A Metafield that's been parsed, with a `parsedValue` of an array of Date objects */
|
|
83
|
+
'list.date_time': Simplify<DatesListParsedMetafield>;
|
|
84
|
+
/** A Metafield that's been parsed, with a `parsedValue` of an array of `Measurement` objects */
|
|
85
|
+
'list.dimension': Simplify<MeasurementListParsedMetafield>;
|
|
86
|
+
/** A Metafield that's been parsed, with a `parsedValue` of an array of `GenericFile` objects (as defined by the Storefront API) */
|
|
87
|
+
'list.file_reference': Simplify<FileListParsedRefMetafield>;
|
|
88
|
+
/** A Metafield that's been parsed, with a `parsedValue` of an array of numbers */
|
|
89
|
+
'list.number_integer': Simplify<NumberListParsedMetafield>;
|
|
90
|
+
/** A Metafield that's been parsed, with a `parsedValue` of an array of numbers */
|
|
91
|
+
'list.number_decimal': Simplify<NumberListParsedMetafield>;
|
|
92
|
+
/** A Metafield that's been parsed, with a `parsedValue` of an array of `Page` objects (as defined by the Storefront API) */
|
|
93
|
+
'list.page_reference': Simplify<PageListParsedRefMetafield>;
|
|
94
|
+
/** A Metafield that's been parsed, with a `parsedValue` of an array of `Product` objects (as defined by the Storefront API) */
|
|
95
|
+
'list.product_reference': Simplify<ProductListParsedRefMetafield>;
|
|
96
|
+
/** A Metafield that's been parsed, with a `parsedValue` of an array of `Rating`s */
|
|
97
|
+
'list.rating': Simplify<RatingListParsedMetafield>;
|
|
98
|
+
/** A Metafield that's been parsed, with a `parsedValue` of an array of strings */
|
|
99
|
+
'list.single_line_text_field': Simplify<TextListParsedMetafield>;
|
|
100
|
+
/** A Metafield that's been parsed, with a `parsedValue` of an array of strings */
|
|
101
|
+
'list.url': Simplify<TextListParsedMetafield>;
|
|
102
|
+
/** A Metafield that's been parsed, with a `parsedValue` of an array of `ProductVariant` objects (as defined by the Storefront API) */
|
|
103
|
+
'list.variant_reference': Simplify<VariantListParsedRefMetafield>;
|
|
104
|
+
/** A Metafield that's been parsed, with a `parsedValue` of an array of `Measurement`s */
|
|
105
|
+
'list.volume': Simplify<MeasurementListParsedMetafield>;
|
|
106
|
+
/** A Metafield that's been parsed, with a `parsedValue` of an array of `Measurement`s */
|
|
107
|
+
'list.weight': Simplify<MeasurementListParsedMetafield>;
|
|
108
|
+
};
|
|
109
|
+
interface ParsedBase extends MetafieldBaseType {
|
|
110
|
+
type: MetafieldTypeTypes;
|
|
111
|
+
parsedValue: unknown;
|
|
112
|
+
}
|
|
113
|
+
interface BooleanParsedMetafield extends ParsedBase {
|
|
114
|
+
type: 'boolean';
|
|
115
|
+
parsedValue: boolean | null;
|
|
116
|
+
}
|
|
117
|
+
declare type CollectionParsedRefMetafield = MetafieldBaseType & {
|
|
118
|
+
type: 'collection_reference';
|
|
119
|
+
parsedValue: Collection | null;
|
|
120
|
+
};
|
|
121
|
+
declare type ColorParsedMetafield = MetafieldBaseType & {
|
|
122
|
+
type: 'color';
|
|
123
|
+
parsedValue: string | null;
|
|
124
|
+
};
|
|
125
|
+
declare type DatesParsedMetafield = MetafieldBaseType & {
|
|
126
|
+
type: 'date' | 'date_time';
|
|
127
|
+
parsedValue: Date | null;
|
|
128
|
+
};
|
|
129
|
+
declare type MeasurementParsedMetafield = MetafieldBaseType & {
|
|
130
|
+
type: 'dimension' | 'weight' | 'volume';
|
|
131
|
+
parsedValue: Measurement | null;
|
|
132
|
+
};
|
|
133
|
+
declare type FileRefParsedMetafield = MetafieldBaseType & {
|
|
134
|
+
type: 'file_reference';
|
|
135
|
+
parsedValue: GenericFile | null;
|
|
136
|
+
};
|
|
137
|
+
declare type JsonParsedMetafield<JsonTypeGeneric = void> = MetafieldBaseType & {
|
|
138
|
+
type: 'json';
|
|
139
|
+
parsedValue: JsonTypeGeneric extends void ? unknown : JsonTypeGeneric | null;
|
|
140
|
+
};
|
|
141
|
+
declare type MoneyParsedMetafield = MetafieldBaseType & {
|
|
142
|
+
type: 'money';
|
|
143
|
+
parsedValue: MoneyV2 | null;
|
|
144
|
+
};
|
|
145
|
+
declare type TextParsedMetafield = MetafieldBaseType & {
|
|
146
|
+
type: 'single_line_text_field' | 'multi_line_text_field' | 'url';
|
|
147
|
+
parsedValue: string | null;
|
|
148
|
+
};
|
|
149
|
+
declare type NumberParsedMetafield = MetafieldBaseType & {
|
|
150
|
+
type: 'number_decimal' | 'number_integer';
|
|
151
|
+
parsedValue: number | null;
|
|
152
|
+
};
|
|
153
|
+
declare type PageParsedRefMetafield = MetafieldBaseType & {
|
|
154
|
+
type: 'page_reference';
|
|
155
|
+
parsedValue: Page | null;
|
|
156
|
+
};
|
|
157
|
+
declare type ProductParsedRefMetafield = MetafieldBaseType & {
|
|
158
|
+
type: 'product_reference';
|
|
159
|
+
parsedValue: Product | null;
|
|
160
|
+
};
|
|
161
|
+
declare type RatingParsedMetafield = MetafieldBaseType & {
|
|
162
|
+
type: 'rating';
|
|
163
|
+
parsedValue: Rating | null;
|
|
164
|
+
};
|
|
165
|
+
declare type VariantParsedRefMetafield = MetafieldBaseType & {
|
|
166
|
+
type: 'variant_reference';
|
|
167
|
+
parsedValue: ProductVariant | null;
|
|
168
|
+
};
|
|
169
|
+
declare type CollectionListParsedRefMetafield = MetafieldBaseType & {
|
|
170
|
+
type: 'list.collection_reference';
|
|
171
|
+
parsedValue: Array<Collection> | null;
|
|
172
|
+
};
|
|
173
|
+
declare type ColorListParsedMetafield = MetafieldBaseType & {
|
|
174
|
+
type: 'list.color';
|
|
175
|
+
parsedValue: Array<string> | null;
|
|
176
|
+
};
|
|
177
|
+
declare type DatesListParsedMetafield = MetafieldBaseType & {
|
|
178
|
+
type: 'list.date' | 'list.date_time';
|
|
179
|
+
parsedValue: Array<Date> | null;
|
|
180
|
+
};
|
|
181
|
+
declare type MeasurementListParsedMetafield = MetafieldBaseType & {
|
|
182
|
+
type: 'list.dimension' | 'list.weight' | 'list.volume';
|
|
183
|
+
parsedValue: Array<Measurement> | null;
|
|
184
|
+
};
|
|
185
|
+
declare type FileListParsedRefMetafield = MetafieldBaseType & {
|
|
186
|
+
type: 'list.file_reference';
|
|
187
|
+
parsedValue: Array<GenericFile> | null;
|
|
188
|
+
};
|
|
189
|
+
declare type TextListParsedMetafield = MetafieldBaseType & {
|
|
190
|
+
type: 'list.single_line_text_field' | 'list.url';
|
|
191
|
+
parsedValue: Array<string> | null;
|
|
192
|
+
};
|
|
193
|
+
declare type NumberListParsedMetafield = MetafieldBaseType & {
|
|
194
|
+
type: 'list.number_decimal' | 'list.number_integer';
|
|
195
|
+
parsedValue: Array<number> | null;
|
|
196
|
+
};
|
|
197
|
+
declare type PageListParsedRefMetafield = MetafieldBaseType & {
|
|
198
|
+
type: 'list.page_reference';
|
|
199
|
+
parsedValue: Array<Page> | null;
|
|
200
|
+
};
|
|
201
|
+
declare type ProductListParsedRefMetafield = MetafieldBaseType & {
|
|
202
|
+
type: 'list.product_reference';
|
|
203
|
+
parsedValue: Array<Product> | null;
|
|
204
|
+
};
|
|
205
|
+
declare type RatingListParsedMetafield = MetafieldBaseType & {
|
|
206
|
+
type: 'list.rating';
|
|
207
|
+
parsedValue: Array<Rating> | null;
|
|
208
|
+
};
|
|
209
|
+
declare type VariantListParsedRefMetafield = MetafieldBaseType & {
|
|
210
|
+
type: 'list.variant_reference';
|
|
211
|
+
parsedValue: Array<ProductVariant> | null;
|
|
212
|
+
};
|
|
213
|
+
export declare type Measurement = {
|
|
214
|
+
unit: string;
|
|
215
|
+
value: number;
|
|
216
|
+
};
|
|
217
|
+
export interface Rating {
|
|
218
|
+
value: number;
|
|
219
|
+
scale_min: number;
|
|
220
|
+
scale_max: number;
|
|
221
|
+
}
|
|
222
|
+
export {};
|