@react-pakistan/util-functions 2.0.2 → 3.0.1

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 (369) hide show
  1. package/constants/api-methods.d.mts +13 -0
  2. package/constants/api-methods.mjs +1 -0
  3. package/constants/cache-time.d.mts +7 -0
  4. package/constants/cache-time.mjs +1 -0
  5. package/constants/countries-timezones.d.mts +8 -0
  6. package/constants/countries-timezones.mjs +1 -0
  7. package/constants/currencies.d.mts +14 -0
  8. package/constants/currencies.mjs +1 -0
  9. package/constants/dial-codes.d.mts +9 -0
  10. package/constants/dial-codes.mjs +1 -0
  11. package/constants/layout-direction.d.mts +6 -0
  12. package/constants/layout-direction.mjs +1 -0
  13. package/constants/react-pakistan-meta.d.mts +32 -0
  14. package/constants/react-pakistan-meta.mjs +1 -0
  15. package/constants/react-pakistan.d.mts +15 -0
  16. package/constants/react-pakistan.mjs +12 -0
  17. package/constants/select-value-delimiter.d.mts +12 -0
  18. package/constants/select-value-delimiter.mjs +1 -0
  19. package/constants/social-media-colors.d.mts +40 -0
  20. package/constants/social-media-colors.mjs +1 -0
  21. package/constants/social-media-sizes.d.mts +323 -0
  22. package/constants/social-media-sizes.mjs +1 -0
  23. package/constants/user-roles.d.mts +7 -0
  24. package/constants/user-roles.mjs +1 -0
  25. package/factory/generic-component-factory.d.mts +78 -0
  26. package/factory/generic-component-factory.mjs +1 -0
  27. package/factory/generic-module-factory.d.mts +80 -0
  28. package/factory/generic-module-factory.mjs +1 -0
  29. package/general/basic-get.d.mts +8 -0
  30. package/general/basic-get.mjs +1 -0
  31. package/general/basic-post.d.mts +8 -0
  32. package/general/basic-post.mjs +1 -0
  33. package/general/calculate-pages.d.mts +9 -0
  34. package/general/calculate-pages.mjs +1 -0
  35. package/general/camel-to-sentence-case.d.mts +12 -0
  36. package/general/camel-to-sentence-case.mjs +1 -0
  37. package/general/check-even-odd-length.d.mts +13 -0
  38. package/general/check-even-odd-length.mjs +1 -0
  39. package/general/clear-cache.d.mts +10 -0
  40. package/general/clear-cache.mjs +1 -0
  41. package/general/cnic-formatter.d.mts +20 -0
  42. package/general/cnic-formatter.mjs +1 -0
  43. package/general/convert-url-to-base64.d.mts +57 -0
  44. package/general/convert-url-to-base64.mjs +1 -0
  45. package/general/countries.d.mts +268 -0
  46. package/general/countries.mjs +1 -0
  47. package/general/create-date.d.mts +12 -0
  48. package/general/create-date.js +1 -1
  49. package/general/create-date.mjs +1 -0
  50. package/general/crypto.d.mts +11 -0
  51. package/general/crypto.mjs +1 -0
  52. package/general/currencies.d.mts +2 -0
  53. package/general/currencies.mjs +0 -0
  54. package/general/delete-image-from-private-supabase.d.mts +16 -0
  55. package/general/delete-image-from-private-supabase.mjs +1 -0
  56. package/general/delete-image-from-public-supabase.d.mts +16 -0
  57. package/general/delete-image-from-public-supabase.mjs +1 -0
  58. package/general/download-from-url.d.mts +8 -0
  59. package/general/download-from-url.mjs +1 -0
  60. package/general/dynamic-page-limit.d.mts +12 -0
  61. package/general/dynamic-page-limit.mjs +1 -0
  62. package/general/enum-to-text.d.mts +8 -0
  63. package/general/enum-to-text.mjs +1 -0
  64. package/general/fetch-data.d.mts +25 -0
  65. package/general/fetch-data.mjs +1 -0
  66. package/general/fetch-supabase-image.d.mts +16 -0
  67. package/general/fetch-supabase-image.mjs +1 -0
  68. package/general/fetch-supabase-private-assets.d.mts +15 -0
  69. package/general/fetch-supabase-private-assets.mjs +1 -0
  70. package/general/format-date.d.mts +18 -0
  71. package/general/format-date.mjs +1 -0
  72. package/general/format-number.d.mts +16 -0
  73. package/general/format-number.mjs +1 -0
  74. package/general/format-phone-display.d.mts +9 -0
  75. package/general/format-phone-display.js +1 -1
  76. package/general/format-phone-display.mjs +1 -0
  77. package/general/format-phone.d.mts +13 -0
  78. package/general/format-phone.d.ts +1 -3
  79. package/general/format-phone.js +1 -1
  80. package/general/format-phone.mjs +1 -0
  81. package/general/format-pricing.d.mts +8 -0
  82. package/general/format-pricing.mjs +1 -0
  83. package/general/format-secs.d.mts +8 -0
  84. package/general/format-secs.mjs +1 -0
  85. package/general/format-time.d.mts +11 -0
  86. package/general/format-time.mjs +1 -0
  87. package/general/format-value.d.mts +8 -0
  88. package/general/format-value.mjs +1 -0
  89. package/general/full-month-range.d.mts +13 -0
  90. package/general/full-month-range.mjs +1 -0
  91. package/general/full-year-range.d.mts +12 -0
  92. package/general/full-year-range.mjs +1 -0
  93. package/general/generate-article-schema.d.mts +50 -0
  94. package/general/generate-article-schema.mjs +1 -0
  95. package/general/generate-blog-schema.d.mts +37 -0
  96. package/general/generate-blog-schema.mjs +1 -0
  97. package/general/generate-book-schema.d.mts +58 -0
  98. package/general/generate-book-schema.mjs +1 -0
  99. package/general/generate-breadcrumb-schema.d.mts +40 -0
  100. package/general/generate-breadcrumb-schema.mjs +1 -0
  101. package/general/generate-carousel-schema.d.mts +52 -0
  102. package/general/generate-carousel-schema.mjs +1 -0
  103. package/general/generate-course-schema.d.mts +53 -0
  104. package/general/generate-course-schema.mjs +1 -0
  105. package/general/generate-dataset-schema.d.mts +65 -0
  106. package/general/generate-dataset-schema.mjs +1 -0
  107. package/general/generate-discussion-forum-schema.d.mts +39 -0
  108. package/general/generate-discussion-forum-schema.mjs +1 -0
  109. package/general/generate-education-schema.d.mts +68 -0
  110. package/general/generate-education-schema.mjs +1 -0
  111. package/general/generate-employer-aggregate-rating-schema.d.mts +29 -0
  112. package/general/generate-employer-aggregate-rating-schema.mjs +1 -0
  113. package/general/generate-event-schema.d.mts +63 -0
  114. package/general/generate-event-schema.mjs +1 -0
  115. package/general/generate-faq-schema.d.mts +32 -0
  116. package/general/generate-faq-schema.mjs +1 -0
  117. package/general/generate-grid.d.mts +17 -0
  118. package/general/generate-grid.mjs +1 -0
  119. package/general/generate-image-metadata-schema.d.mts +36 -0
  120. package/general/generate-image-metadata-schema.mjs +1 -0
  121. package/general/generate-job-posting-schema.d.mts +49 -0
  122. package/general/generate-job-posting-schema.mjs +1 -0
  123. package/general/generate-local-business-schema.d.mts +42 -0
  124. package/general/generate-local-business-schema.mjs +1 -0
  125. package/general/generate-math-solver-schema.d.mts +45 -0
  126. package/general/generate-math-solver-schema.mjs +1 -0
  127. package/general/generate-movie-carousel-schema.d.mts +51 -0
  128. package/general/generate-movie-carousel-schema.mjs +1 -0
  129. package/general/generate-organization-schema.d.mts +49 -0
  130. package/general/generate-organization-schema.mjs +1 -0
  131. package/general/generate-profile-page-schema.d.mts +37 -0
  132. package/general/generate-profile-page-schema.mjs +1 -0
  133. package/general/generate-qa-page-schema.d.mts +34 -0
  134. package/general/generate-qa-page-schema.mjs +1 -0
  135. package/general/generate-recipe-schema.d.mts +49 -0
  136. package/general/generate-recipe-schema.mjs +1 -0
  137. package/general/generate-ref.d.mts +11 -0
  138. package/general/generate-ref.js +1 -1
  139. package/general/generate-ref.mjs +1 -0
  140. package/general/generate-review-snippet-schema.d.mts +52 -0
  141. package/general/generate-review-snippet-schema.mjs +1 -0
  142. package/general/generate-shopping-loyalty-program-schema.d.mts +38 -0
  143. package/general/generate-shopping-loyalty-program-schema.mjs +1 -0
  144. package/general/generate-shopping-merchant-listing-schema.d.mts +53 -0
  145. package/general/generate-shopping-merchant-listing-schema.mjs +1 -0
  146. package/general/generate-shopping-merchant-return-policy-schema.d.mts +32 -0
  147. package/general/generate-shopping-merchant-return-policy-schema.mjs +1 -0
  148. package/general/generate-shopping-merchant-shipping-policy-schema.d.mts +36 -0
  149. package/general/generate-shopping-merchant-shipping-policy-schema.mjs +1 -0
  150. package/general/generate-shopping-overview-schema.d.mts +52 -0
  151. package/general/generate-shopping-overview-schema.mjs +1 -0
  152. package/general/generate-shopping-product-snippet-schema.d.mts +57 -0
  153. package/general/generate-shopping-product-snippet-schema.mjs +1 -0
  154. package/general/generate-shopping-variants-schema.d.mts +46 -0
  155. package/general/generate-shopping-variants-schema.mjs +1 -0
  156. package/general/generate-software-app-schema.d.mts +62 -0
  157. package/general/generate-software-app-schema.mjs +1 -0
  158. package/general/generate-speakable-schema.d.mts +64 -0
  159. package/general/generate-speakable-schema.mjs +1 -0
  160. package/general/generate-subscription-schema.d.mts +60 -0
  161. package/general/generate-subscription-schema.mjs +1 -0
  162. package/general/generate-vacation-rental-schema.d.mts +67 -0
  163. package/general/generate-vacation-rental-schema.mjs +1 -0
  164. package/general/generate-video-schema.d.mts +75 -0
  165. package/general/generate-video-schema.mjs +1 -0
  166. package/general/generic-cache.d.mts +193 -0
  167. package/general/generic-cache.mjs +1 -0
  168. package/general/get-available-page-limit.d.mts +11 -0
  169. package/general/get-available-page-limit.mjs +1 -0
  170. package/general/get-calendar-current-month.d.mts +15 -0
  171. package/general/get-calendar-current-month.js +1 -1
  172. package/general/get-calendar-current-month.mjs +1 -0
  173. package/general/get-calendar-dates.d.mts +15 -0
  174. package/general/get-calendar-dates.js +1 -1
  175. package/general/get-calendar-dates.mjs +1 -0
  176. package/general/get-calendar-next-month.d.mts +17 -0
  177. package/general/get-calendar-next-month.js +1 -1
  178. package/general/get-calendar-next-month.mjs +1 -0
  179. package/general/get-calendar-previous-month.d.mts +17 -0
  180. package/general/get-calendar-previous-month.js +1 -1
  181. package/general/get-calendar-previous-month.mjs +1 -0
  182. package/general/get-current-year.d.mts +7 -0
  183. package/general/get-current-year.mjs +1 -0
  184. package/general/get-day-name.d.mts +10 -0
  185. package/general/get-day-name.mjs +1 -0
  186. package/general/get-dial-code.d.mts +8 -0
  187. package/general/get-dial-code.mjs +1 -0
  188. package/general/get-full-name.d.mts +13 -0
  189. package/general/get-full-name.mjs +1 -0
  190. package/general/get-href.d.mts +11 -0
  191. package/general/get-href.mjs +1 -0
  192. package/general/get-month-name.d.mts +10 -0
  193. package/general/get-month-name.mjs +1 -0
  194. package/general/get-month-number.d.mts +15 -0
  195. package/general/get-month-number.mjs +1 -0
  196. package/general/get-number-of-days-in-month.d.mts +13 -0
  197. package/general/get-number-of-days-in-month.js +1 -1
  198. package/general/get-number-of-days-in-month.mjs +1 -0
  199. package/general/get-pathname.d.mts +11 -0
  200. package/general/get-pathname.mjs +1 -0
  201. package/general/get-week-day.d.mts +8 -0
  202. package/general/get-week-day.js +1 -1
  203. package/general/get-week-day.mjs +1 -0
  204. package/general/image-url-to-base64.d.mts +9 -0
  205. package/general/image-url-to-base64.mjs +1 -0
  206. package/general/is-created-or-updated.d.mts +13 -0
  207. package/general/is-created-or-updated.mjs +1 -0
  208. package/general/is-next-button-disabled.d.mts +9 -0
  209. package/general/is-next-button-disabled.mjs +1 -0
  210. package/general/is-odd.d.mts +11 -0
  211. package/general/is-odd.mjs +1 -0
  212. package/general/is-previous-button-disabled.d.mts +8 -0
  213. package/general/is-previous-button-disabled.mjs +1 -0
  214. package/general/linear-gradients.d.mts +14 -0
  215. package/general/linear-gradients.mjs +1 -0
  216. package/general/multi-part-search.d.mts +22 -0
  217. package/general/multi-part-search.mjs +1 -0
  218. package/general/normalize-phone.d.mts +15 -0
  219. package/general/normalize-phone.js +1 -1
  220. package/general/normalize-phone.mjs +1 -0
  221. package/general/parse-frontmatter.d.mts +36 -0
  222. package/general/parse-frontmatter.mjs +2 -0
  223. package/general/remove-data-image-prefix.d.mts +8 -0
  224. package/general/remove-data-image-prefix.mjs +1 -0
  225. package/general/repeat-times.d.mts +15 -0
  226. package/general/repeat-times.mjs +1 -0
  227. package/general/resolve-anchor-link.d.mts +13 -0
  228. package/general/resolve-anchor-link.mjs +1 -0
  229. package/general/resolve-current-date.d.mts +12 -0
  230. package/general/resolve-current-date.mjs +1 -0
  231. package/general/resolve-grid.d.mts +14 -0
  232. package/general/resolve-grid.mjs +1 -0
  233. package/general/resolve-initials.d.mts +12 -0
  234. package/general/resolve-initials.mjs +1 -0
  235. package/general/set-timezone.d.mts +9 -0
  236. package/general/set-timezone.d.ts +1 -3
  237. package/general/set-timezone.js +1 -1
  238. package/general/set-timezone.mjs +1 -0
  239. package/general/slugify.d.mts +12 -0
  240. package/general/slugify.mjs +1 -0
  241. package/general/text-to-enum.d.mts +8 -0
  242. package/general/text-to-enum.mjs +1 -0
  243. package/general/text-to-sentence-case.d.mts +12 -0
  244. package/general/text-to-sentence-case.mjs +1 -0
  245. package/general/time-out.d.mts +12 -0
  246. package/general/time-out.mjs +1 -0
  247. package/general/time-zones.d.mts +11 -0
  248. package/general/time-zones.mjs +1 -0
  249. package/general/truncate-text.d.mts +14 -0
  250. package/general/truncate-text.mjs +1 -0
  251. package/general/type.d.mts +8 -0
  252. package/general/type.mjs +0 -0
  253. package/general/upload-blob-to-private-supabase.d.mts +24 -0
  254. package/general/upload-blob-to-private-supabase.mjs +1 -0
  255. package/general/upload-blob-to-public-supabase.d.mts +24 -0
  256. package/general/upload-blob-to-public-supabase.mjs +1 -0
  257. package/general/upload-image-to-private-supabase.d.mts +26 -0
  258. package/general/upload-image-to-private-supabase.mjs +1 -0
  259. package/general/upload-image-to-public-supabase.d.mts +26 -0
  260. package/general/upload-image-to-public-supabase.mjs +1 -0
  261. package/general/url-to-sentence-case.d.mts +12 -0
  262. package/general/url-to-sentence-case.mjs +1 -0
  263. package/general/validate-comment.d.mts +14 -0
  264. package/general/validate-comment.mjs +1 -0
  265. package/general/validate-email.d.mts +15 -0
  266. package/general/validate-email.mjs +1 -0
  267. package/general/validate-form.d.mts +18 -0
  268. package/general/validate-form.mjs +1 -0
  269. package/general/validate-name.d.mts +14 -0
  270. package/general/validate-name.mjs +1 -0
  271. package/hooks/use-change.d.mts +11 -0
  272. package/hooks/use-change.mjs +1 -0
  273. package/hooks/use-debounce.d.mts +10 -0
  274. package/hooks/use-debounce.mjs +1 -0
  275. package/hooks/use-fetch.d.mts +42 -0
  276. package/hooks/use-fetch.mjs +1 -0
  277. package/hooks/use-force-render.d.mts +14 -0
  278. package/hooks/use-force-render.mjs +1 -0
  279. package/hooks/use-ip-geo-location.d.mts +12 -0
  280. package/hooks/use-ip-geo-location.mjs +1 -0
  281. package/hooks/use-is-mobile.d.mts +8 -0
  282. package/hooks/use-is-mobile.mjs +1 -0
  283. package/hooks/use-module-entity-v2.d.mts +105 -0
  284. package/hooks/use-module-entity-v2.mjs +1 -0
  285. package/hooks/use-module-entity.d.mts +98 -0
  286. package/hooks/use-module-entity.mjs +1 -0
  287. package/hooks/use-phone-formatter.d.mts +17 -0
  288. package/hooks/use-phone-formatter.d.ts +1 -3
  289. package/hooks/use-phone-formatter.js +1 -1
  290. package/hooks/use-phone-formatter.mjs +1 -0
  291. package/hooks/use-position.d.mts +29 -0
  292. package/hooks/use-position.mjs +1 -0
  293. package/hooks/use-rtl.d.mts +46 -0
  294. package/hooks/use-rtl.mjs +1 -0
  295. package/hooks/use-sticky.d.mts +13 -0
  296. package/hooks/use-sticky.mjs +1 -0
  297. package/hooks/use-toggle-state.d.mts +14 -0
  298. package/hooks/use-toggle-state.mjs +1 -0
  299. package/hooks/use-window-event-listener.d.mts +9 -0
  300. package/hooks/use-window-event-listener.mjs +1 -0
  301. package/hooks/with-seo.d.mts +19 -0
  302. package/hooks/with-seo.mjs +1 -0
  303. package/local-storage/get-storage-value.d.mts +5 -0
  304. package/local-storage/get-storage-value.mjs +1 -0
  305. package/local-storage/remove-storage-value.d.mts +3 -0
  306. package/local-storage/remove-storage-value.mjs +1 -0
  307. package/local-storage/set-storage-value.d.mts +3 -0
  308. package/local-storage/set-storage-value.mjs +1 -0
  309. package/local-storage/type.d.mts +3 -0
  310. package/local-storage/type.mjs +0 -0
  311. package/npm.d.d.mts +2 -0
  312. package/npm.d.mjs +0 -0
  313. package/package.json +1 -10
  314. package/edu-pilot-pro/types/academics.d.ts +0 -2
  315. package/edu-pilot-pro/types/academics.js +0 -1
  316. package/edu-pilot-pro/types/admission.d.ts +0 -878
  317. package/edu-pilot-pro/types/admission.js +0 -1
  318. package/edu-pilot-pro/types/communication.d.ts +0 -2
  319. package/edu-pilot-pro/types/communication.js +0 -1
  320. package/edu-pilot-pro/types/enums.d.ts +0 -413
  321. package/edu-pilot-pro/types/enums.js +0 -1
  322. package/edu-pilot-pro/types/finance.d.ts +0 -2
  323. package/edu-pilot-pro/types/finance.js +0 -1
  324. package/edu-pilot-pro/types/index.d.ts +0 -2
  325. package/edu-pilot-pro/types/index.js +0 -1
  326. package/edu-pilot-pro/types/user-management.d.ts +0 -2
  327. package/edu-pilot-pro/types/user-management.js +0 -1
  328. package/stellar-solution/types/common.d.ts +0 -26
  329. package/stellar-solution/types/common.js +0 -1
  330. package/stellar-solution/types/erp.d.ts +0 -305
  331. package/stellar-solution/types/erp.js +0 -1
  332. package/stellar-solution/types/index.d.ts +0 -3
  333. package/stellar-solution/types/index.js +0 -1
  334. package/stellar-solution/types/pos.d.ts +0 -179
  335. package/stellar-solution/types/pos.js +0 -1
  336. package/storybook/generate-sitemap.d.ts +0 -16
  337. package/storybook/generate-sitemap.js +0 -17
  338. package/storybook/preview.d.ts +0 -148
  339. package/storybook/preview.js +0 -1
  340. package/storybook/react-design-story-script.d.ts +0 -12
  341. package/storybook/react-design-story-script.js +0 -5
  342. package/storybook/react-emoji-collection.d.ts +0 -13
  343. package/storybook/react-emoji-collection.js +0 -11
  344. package/storybook/react-emoji-story-script.d.ts +0 -12
  345. package/storybook/react-emoji-story-script.js +0 -5
  346. package/storybook/react-emoji-story-template.d.ts +0 -14
  347. package/storybook/react-emoji-story-template.js +0 -46
  348. package/storybook/react-icon-collection.d.ts +0 -13
  349. package/storybook/react-icon-collection.js +0 -11
  350. package/storybook/react-icon-story-script.d.ts +0 -12
  351. package/storybook/react-icon-story-script.js +0 -5
  352. package/storybook/react-icon-story-template.d.ts +0 -13
  353. package/storybook/react-icon-story-template.js +0 -46
  354. package/storybook/react-logo-collection.d.ts +0 -13
  355. package/storybook/react-logo-collection.js +0 -11
  356. package/storybook/react-logo-story-script.d.ts +0 -12
  357. package/storybook/react-logo-story-script.js +0 -5
  358. package/storybook/react-logo-story-template.d.ts +0 -13
  359. package/storybook/react-logo-story-template.js +0 -46
  360. package/storybook/react-pakistan-theme.d.ts +0 -25
  361. package/storybook/react-pakistan-theme.js +0 -1
  362. package/storybook/responsive-args.d.ts +0 -22
  363. package/storybook/responsive-args.js +0 -1
  364. package/storybook/responsive-component.d.ts +0 -33
  365. package/storybook/responsive-component.js +0 -37
  366. package/storybook/responsive-screens.d.ts +0 -108
  367. package/storybook/responsive-screens.js +0 -1
  368. package/storybook/theme.d.ts +0 -96
  369. package/storybook/theme.js +0 -1
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Generate structured data for Review snippets and `AggregateRating`.
3
+ *
4
+ * Accepts a compact `ReviewSnippetOptions` object and returns a plain object
5
+ * compatible with schema.org JSON-LD for embedding in a page. The function
6
+ * supports formatting `Person` and `Organization` references and can produce
7
+ * an `AggregateRating` object either from supplied options or derived from
8
+ * reviews.
9
+ *
10
+ * See the TypeScript interfaces below for the exact input shape.
11
+ * @returns A JSON-LD compatible Review / ReviewSnippet object
12
+ */
13
+ interface PersonRef {
14
+ name: string;
15
+ url?: string;
16
+ }
17
+ interface OrgRef {
18
+ name: string;
19
+ url?: string;
20
+ }
21
+ interface RatingItem {
22
+ ratingValue: number | string;
23
+ bestRating?: number | string;
24
+ worstRating?: number | string;
25
+ }
26
+ interface ReviewItem {
27
+ author?: string | PersonRef;
28
+ datePublished?: string;
29
+ reviewBody?: string;
30
+ reviewRating?: RatingItem;
31
+ name?: string;
32
+ url?: string;
33
+ publisher?: string | OrgRef;
34
+ }
35
+ interface AggregateRatingOptions {
36
+ ratingValue: number | string;
37
+ reviewCount?: number;
38
+ ratingCount?: number;
39
+ bestRating?: number | string;
40
+ worstRating?: number | string;
41
+ }
42
+ interface ReviewSnippetOptions {
43
+ itemReviewed?: string | {
44
+ name: string;
45
+ '@type'?: string;
46
+ };
47
+ reviews?: ReviewItem[];
48
+ aggregateRating?: AggregateRatingOptions;
49
+ }
50
+ declare const generateReviewSnippetSchema: ({ itemReviewed, reviews, aggregateRating, }: ReviewSnippetOptions) => any;
51
+
52
+ export { generateReviewSnippetSchema as default, generateReviewSnippetSchema };
@@ -0,0 +1 @@
1
+ const f=t=>{if(!t)return;if(typeof t=="string")return{"@type":"Person",name:t};const n={"@type":"Person",name:t.name};return t.url&&(n.url=t.url),n},m=t=>{if(!t)return;if(typeof t=="string")return{"@type":"Organization",name:t};const n={"@type":"Organization",name:t.name};return t.url&&(n.url=t.url),n},R=t=>{const n={"@type":"Review"};return t.author&&(n.author=f(t.author)),t.datePublished&&(n.datePublished=t.datePublished),t.reviewBody&&(n.reviewBody=t.reviewBody),t.name&&(n.name=t.name),t.url&&(n.url=t.url),t.publisher&&(n.publisher=m(t.publisher)),t.reviewRating&&(n.reviewRating={"@type":"Rating",ratingValue:t.reviewRating.ratingValue,...t.reviewRating.bestRating!=null&&{bestRating:t.reviewRating.bestRating},...t.reviewRating.worstRating!=null&&{worstRating:t.reviewRating.worstRating}}),n},p=({itemReviewed:t,reviews:n,aggregateRating:e})=>{const u=!!t,s=n&&n.length>0?n.map(R):void 0;let r;if(e)r={"@type":"AggregateRating",ratingValue:e.ratingValue,...e.reviewCount!=null&&{reviewCount:e.reviewCount},...e.ratingCount!=null&&{ratingCount:e.ratingCount},...e.bestRating!=null&&{bestRating:e.bestRating},...e.worstRating!=null&&{worstRating:e.worstRating}};else if(n&&n.length>0){const i=n.map(a=>a.reviewRating?Number(a.reviewRating.ratingValue):NaN).filter(a=>!Number.isNaN(a));i.length>0&&(r={"@type":"AggregateRating",ratingValue:i.reduce((o,l)=>o+l,0)/i.length,reviewCount:n.length,ratingCount:i.length})}if(u){const i={"@context":"https://schema.org","@type":typeof t=="string"?"Thing":t?.["@type"]||"Thing",name:typeof t=="string"?t:t.name};return s&&(i.review=s),r&&(i.aggregateRating=r),i}if(s&&s.length===1){const a={"@context":"https://schema.org",...s[0]};return r&&(a.aggregateRating=r),a}const g={"@context":"https://schema.org"};return s&&(g.review=s),r&&(g.aggregateRating=r),g};var c=p;export{c as default,p as generateReviewSnippetSchema};
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Generate schema.org structured data for a loyalty or membership program
3
+ * (`ProgramMembership`).
4
+ *
5
+ * The helper formats membership details, member references, points and
6
+ * optional offers into a `ProgramMembership` object. Only supplied fields
7
+ * are emitted.
8
+ *
9
+ * See `LoyaltyOptions` for the accepted input properties.
10
+ * @returns A JSON-LD compatible `ProgramMembership` object
11
+ */
12
+ interface MemberRef {
13
+ name: string;
14
+ url?: string;
15
+ }
16
+ interface OrganizationRef {
17
+ name: string;
18
+ url?: string;
19
+ }
20
+ interface LoyaltyOffer {
21
+ description?: string;
22
+ url?: string;
23
+ }
24
+ interface LoyaltyOptions {
25
+ programName: string;
26
+ programUrl?: string;
27
+ programId?: string;
28
+ member?: MemberRef | OrganizationRef;
29
+ membershipNumber?: string;
30
+ enrollmentDate?: string;
31
+ pointsBalance?: number;
32
+ pointsEarned?: number;
33
+ benefits?: string[];
34
+ offers?: LoyaltyOffer[];
35
+ }
36
+ declare const generateShoppingLoyaltyProgramSchema: ({ programName, programUrl, programId, member, membershipNumber, enrollmentDate, pointsBalance, pointsEarned, benefits, offers, }: LoyaltyOptions) => any;
37
+
38
+ export { generateShoppingLoyaltyProgramSchema };
@@ -0,0 +1 @@
1
+ const p=r=>{if(r)return{name:r.name,...r.url&&{url:r.url}}},u=({programName:r,programUrl:a,programId:f,member:s,membershipNumber:m,enrollmentDate:o,pointsBalance:g,pointsEarned:l,benefits:t,offers:i})=>{const e={"@context":"https://schema.org","@type":"ProgramMembership",programName:r};return a&&(e.url=a),f&&(e["@id"]=f),s&&(e.member=p(s)),m&&(e.membershipNumber=m),o&&(e.enrollmentDate=o),typeof g=="number"&&(e.pointsBalance=g),typeof l=="number"&&(e.pointsEarned=l),t&&t.length>0&&(e.benefits=t),i&&i.length>0&&(e.offers=i.map(n=>({"@type":"Offer",...n.description&&{description:n.description},...n.url&&{url:n.url}}))),e};export{u as generateShoppingLoyaltyProgramSchema};
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Generate a merchant product listing as schema.org structured data.
3
+ *
4
+ * Returns an `ItemList` where each `ListItem.item` is a `Product` with
5
+ * optional `Offer` entries. Supports brand, seller, images, and basic
6
+ * offer normalization; pass `skipInvalidCurrency` to ignore currency
7
+ * validation for price fields.
8
+ *
9
+ * See `MerchantListingOptions` and `MerchantProduct` types for accepted
10
+ * fields.
11
+ * @returns A JSON-LD compatible `ItemList` of Products
12
+ */
13
+ interface BrandRef {
14
+ name: string;
15
+ url?: string;
16
+ }
17
+ interface MerchantRef {
18
+ name: string;
19
+ url?: string;
20
+ }
21
+ interface OfferItem {
22
+ price?: string | number;
23
+ priceCurrency?: string;
24
+ availability?: string;
25
+ url?: string;
26
+ priceValidUntil?: string;
27
+ itemCondition?: string;
28
+ seller?: MerchantRef;
29
+ }
30
+ interface MerchantProduct {
31
+ id?: string;
32
+ name: string;
33
+ url?: string;
34
+ image?: string | {
35
+ url: string;
36
+ width?: number;
37
+ height?: number;
38
+ };
39
+ description?: string;
40
+ brand?: string | BrandRef;
41
+ sku?: string;
42
+ offers?: OfferItem | OfferItem[];
43
+ }
44
+ interface MerchantListingOptions {
45
+ merchant?: MerchantRef;
46
+ name?: string;
47
+ url?: string;
48
+ products: MerchantProduct[];
49
+ skipInvalidCurrency?: boolean;
50
+ }
51
+ declare const generateShoppingMerchantListingSchema: ({ merchant, name, url, products, skipInvalidCurrency, }: MerchantListingOptions) => any;
52
+
53
+ export { generateShoppingMerchantListingSchema };
@@ -0,0 +1 @@
1
+ const C=e=>{if(e)return typeof e=="string"?e:{"@type":"ImageObject",url:e.url,...e.width&&{width:e.width},...e.height&&{height:e.height}}},I=e=>{if(e)return typeof e=="string"?{"@type":"Brand",name:e}:{"@type":"Brand",name:e.name,...e.url&&{url:e.url}}},l=e=>e?/^[A-Z]{3}$/.test(e):!1,m=["InStock","OutOfStock","PreOrder","PreSale","Discontinued","OnlineOnly","InStoreOnly","LimitedAvailability","BackOrder"],O=e=>{if(e)try{const s=String(e);if(s.startsWith("http")){const a=s.replace(/https?:\/\/schema\.org\//i,"");return m.includes(a)?`https://schema.org/${a}`:void 0}return m.includes(s)?`https://schema.org/${s}`:void 0}catch{return}},L=({merchant:e,name:s,url:a,products:y,skipInvalidCurrency:p=!1})=>{const c={"@context":"https://schema.org","@type":"ItemList",itemListElement:y.map((i,h)=>{const t={"@type":"Product",name:i.name};i.id&&(t["@id"]=i.id),i.url&&(t.url=i.url);const d=C(i.image);d&&(t.image=d),i.description&&(t.description=i.description);const o=I(i.brand);if(o&&(t.brand=o),i.sku&&(t.sku=i.sku),i.offers){const u=Array.isArray(i.offers)?i.offers:[i.offers],f=u.map(r=>{if(r.priceCurrency&&!l(r.priceCurrency))return{__invalidCurrency:r.priceCurrency};const n={"@type":"Offer"};if(r.price!=null&&(n.price=r.price),r.priceCurrency&&(n.priceCurrency=r.priceCurrency),r.availability){const g=O(r.availability);g&&(n.availability=g)}return r.url&&(n.url=r.url),r.seller&&(n.seller={"@type":"Organization",...r.seller.name&&{name:r.seller.name},...r.seller.url&&{url:r.seller.url}}),r.priceValidUntil&&(n.priceValidUntil=r.priceValidUntil),r.itemCondition&&(n.itemCondition=r.itemCondition),n}).filter(r=>r&&!("__invalidCurrency"in r));if(u.some(r=>r.priceCurrency&&!l(r.priceCurrency))&&!p){const r=u.find(n=>n.priceCurrency&&!l(n.priceCurrency));throw new Error(`Invalid currency code: ${r?.priceCurrency}`)}f.length===1?t.offers=f[0]:f.length>1&&(t.offers=f)}return{"@type":"ListItem",position:h+1,item:t}})};return s&&(c.name=s),a&&(c.mainEntityOfPage={"@type":"WebPage","@id":a}),e&&(c.provider={"@type":"Organization",name:e.name,...e.url&&{url:e.url}}),c};export{L as generateShoppingMerchantListingSchema};
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Generate schema.org structured data for a merchant return policy
3
+ * (`MerchantReturnPolicy`).
4
+ *
5
+ * The utility supports normalizing the `returnPolicyCategory` token or
6
+ * URL and optionally validates currency codes for `returnFees`. Set
7
+ * `skipInvalidCurrency` to true to ignore currency validation.
8
+ *
9
+ * See `ReturnPolicyOptions` for available fields.
10
+ * @returns A JSON-LD compatible `MerchantReturnPolicy` object
11
+ */
12
+ interface MerchantRef {
13
+ name: string;
14
+ url?: string;
15
+ }
16
+ interface ReturnFees {
17
+ amount?: number | string;
18
+ currency?: string;
19
+ }
20
+ interface ReturnPolicyOptions {
21
+ name: string;
22
+ description?: string;
23
+ merchant?: MerchantRef;
24
+ returnPolicyCategory?: string;
25
+ returnMethods?: string[];
26
+ inStoreReturns?: boolean;
27
+ returnFees?: ReturnFees;
28
+ skipInvalidCurrency?: boolean;
29
+ }
30
+ declare const generateShoppingReturnPolicySchema: ({ name, description, merchant, returnPolicyCategory, returnMethods, inStoreReturns, returnFees, skipInvalidCurrency, }: ReturnPolicyOptions) => any;
31
+
32
+ export { generateShoppingReturnPolicySchema };
@@ -0,0 +1 @@
1
+ const y=n=>n?/^[A-Z]{3}$/.test(n):!1,l=n=>{if(!n)return;const e=String(n);return e.startsWith("http")?e:`https://schema.org/${e}`},g=({name:n,description:e,merchant:i,returnPolicyCategory:s,returnMethods:c,inStoreReturns:o,returnFees:r,skipInvalidCurrency:u=!1})=>{const t={"@context":"https://schema.org","@type":"MerchantReturnPolicy",name:n};e&&(t.description=e),i&&(t.merchant={"@type":"Organization",name:i.name,...i.url&&{url:i.url}});const a=l(s);if(a&&(t.returnPolicyCategory=a),c&&c.length>0&&(t.returnMethods=c),typeof o=="boolean"&&(t.inStoreReturns=o),r)if(r.currency&&!y(r.currency)){if(!u)throw new Error(`Invalid currency code: ${r.currency}`)}else t.returnShippingFees={"@type":"MonetaryAmount",value:r.amount,...r.currency&&{currency:r.currency}};return t};export{g as generateShoppingReturnPolicySchema};
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Generate schema.org JSON-LD for a merchant shipping policy or service
3
+ * (`ShippingService`).
4
+ *
5
+ * Supports provider information, shipping rates (with currency
6
+ * validation), transit time ranges, free shipping thresholds, and an
7
+ * optional `shippingSettingsLink`.
8
+ *
9
+ * See `ShippingPolicyOptions` for supported fields and the
10
+ * `skipInvalidCurrency` flag behaviour.
11
+ * @returns A JSON-LD compatible `ShippingService` object
12
+ */
13
+ interface MerchantRef {
14
+ name: string;
15
+ url?: string;
16
+ }
17
+ interface ShippingRate {
18
+ price?: number | string;
19
+ currency?: string;
20
+ shippingLabel?: string;
21
+ }
22
+ interface ShippingPolicyOptions {
23
+ name: string;
24
+ provider?: MerchantRef;
25
+ description?: string;
26
+ shippingDestination?: string;
27
+ transitTimeMinDays?: number;
28
+ transitTimeMaxDays?: number;
29
+ shippingRate?: ShippingRate;
30
+ shippingSettingsLink?: string;
31
+ freeShippingThreshold?: number | string;
32
+ skipInvalidCurrency?: boolean;
33
+ }
34
+ declare const generateShoppingShippingPolicySchema: ({ name, provider, description, shippingDestination, transitTimeMinDays, transitTimeMaxDays, shippingRate, shippingSettingsLink, freeShippingThreshold, skipInvalidCurrency, }: ShippingPolicyOptions) => any;
35
+
36
+ export { generateShoppingShippingPolicySchema };
@@ -0,0 +1 @@
1
+ const a=r=>r?/^[A-Z]{3}$/.test(r):!1,f=r=>{if(!r)return;const e=String(r);return e.startsWith("http"),e},h=({name:r,provider:e,description:s,shippingDestination:g,transitTimeMinDays:t,transitTimeMaxDays:c,shippingRate:n,shippingSettingsLink:l,freeShippingThreshold:u,skipInvalidCurrency:o=!1})=>{const i={"@context":"https://schema.org","@type":"ShippingService",name:r};e&&(i.provider={"@type":"Organization",name:e.name,...e.url&&{url:e.url}}),s&&(i.description=s);const p=f(g);if(p&&(i.shippingDestination=p),(t!=null||c!=null)&&(i.shippingDeliveryTime={"@type":"ShippingDeliveryTime",...t!=null&&{transitTimeLabel:`${t}`},...t!=null&&{transitTimeMin:t},...c!=null&&{transitTimeMax:c}}),n)if(n.currency&&!a(n.currency)){if(!o)throw new Error(`Invalid currency code: ${n.currency}`)}else i.shippingRate={"@type":"MonetaryAmount",value:n.price,...n.currency&&{currency:n.currency},...n.shippingLabel&&{name:n.shippingLabel}};return l&&(i.shippingSettingsLink=l),u!=null&&(i.freeShippingThreshold=u),i};export{h as generateShoppingShippingPolicySchema};
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Generate schema.org `ItemList` JSON-LD for a shopping overview (Products).
3
+ *
4
+ * The function emits an `ItemList` where each `ListItem.item` is a
5
+ * `Product` object with optional `offers` and `aggregateRating`. Use
6
+ * `skipInvalidCurrency` to ignore invalid currency codes in offers.
7
+ *
8
+ * See `ShoppingOverviewOptions` and `ProductItem` for accepted fields.
9
+ * @returns A JSON-LD compatible `ItemList` of Product objects
10
+ */
11
+ interface BrandRef {
12
+ name: string;
13
+ url?: string;
14
+ }
15
+ interface ProductOffer {
16
+ price?: string | number;
17
+ priceCurrency?: string;
18
+ availability?: string;
19
+ url?: string;
20
+ }
21
+ interface ProductItem {
22
+ id?: string;
23
+ name: string;
24
+ url?: string;
25
+ image?: string | {
26
+ url: string;
27
+ width?: number;
28
+ height?: number;
29
+ };
30
+ description?: string;
31
+ brand?: string | BrandRef;
32
+ sku?: string;
33
+ aggregateRating?: {
34
+ ratingValue: number | string;
35
+ reviewCount?: number;
36
+ };
37
+ offers?: ProductOffer | ProductOffer[];
38
+ priceRange?: {
39
+ low?: string | number;
40
+ high?: string | number;
41
+ };
42
+ category?: string | string[];
43
+ }
44
+ interface ShoppingOverviewOptions {
45
+ name?: string;
46
+ url?: string;
47
+ products: ProductItem[];
48
+ skipInvalidCurrency?: boolean;
49
+ }
50
+ declare const generateShoppingOverviewSchema: ({ name, url, products, skipInvalidCurrency, }: ShoppingOverviewOptions) => any;
51
+
52
+ export { generateShoppingOverviewSchema };
@@ -0,0 +1 @@
1
+ const p=e=>{if(e)return typeof e=="string"?e:{"@type":"ImageObject",url:e.url,...e.width&&{width:e.width},...e.height&&{height:e.height}}},v=e=>{if(e)return typeof e=="string"?{"@type":"Brand",name:e}:{"@type":"Brand",name:e.name,...e.url&&{url:e.url}}},f=e=>e?/^[A-Z]{3}$/.test(e):!1,y=["InStock","OutOfStock","PreOrder","PreSale","Discontinued","OnlineOnly","InStoreOnly","LimitedAvailability","BackOrder"],C=e=>{if(e)try{const a=String(e);if(a.startsWith("http")){const c=a.replace(/https?:\/\/schema\.org\//i,"");return y.includes(c)?`https://schema.org/${c}`:void 0}return y.includes(a)?`https://schema.org/${a}`:void 0}catch{return}},w=({name:e,url:a,products:c,skipInvalidCurrency:h=!1})=>{const u={"@context":"https://schema.org","@type":"ItemList",itemListElement:c.map((r,m)=>{const n={"@type":"Product",name:r.name};r.id&&(n["@id"]=r.id),r.url&&(n.url=r.url);const o=p(r.image);o&&(n.image=o),r.description&&(n.description=r.description);const l=v(r.brand);if(l&&(n.brand=l),r.sku&&(n.sku=r.sku),r.category&&(n.category=Array.isArray(r.category)?r.category.join(", "):r.category),r.aggregateRating&&(n.aggregateRating={"@type":"AggregateRating",ratingValue:r.aggregateRating.ratingValue,...r.aggregateRating.reviewCount!=null&&{reviewCount:r.aggregateRating.reviewCount}}),r.priceRange&&(n.priceRange=`${r.priceRange.low??""}${r.priceRange.low!=null&&r.priceRange.high!=null?` - ${r.priceRange.high}`:""}`.trim()),r.offers){const g=Array.isArray(r.offers)?r.offers:[r.offers],s=g.map(i=>{if(i.priceCurrency&&!f(i.priceCurrency))return{__invalidCurrency:i.priceCurrency};const t={"@type":"Offer"};if(i.price!=null&&(t.price=i.price),i.priceCurrency&&(t.priceCurrency=i.priceCurrency),i.availability){const d=C(i.availability);d&&(t.availability=d)}return i.url&&(t.url=i.url),t}).filter(i=>i&&!("__invalidCurrency"in i));if(g.some(i=>i.priceCurrency&&!f(i.priceCurrency))&&!h){const i=g.find(t=>t.priceCurrency&&!f(t.priceCurrency));throw new Error(`Invalid currency code: ${i?.priceCurrency}`)}s.length===1?n.offers=s[0]:s.length>1&&(n.offers=s)}return{"@type":"ListItem",position:m+1,item:n}})};return e&&(u.name=e),a&&(u.mainEntityOfPage={"@type":"WebPage","@id":a}),u};export{w as generateShoppingOverviewSchema};
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Create schema.org structured data for a single `Product` with optional
3
+ * `Review` and `Offer` entries.
4
+ *
5
+ * Supports brand and seller references, image normalization, review
6
+ * formatting and simple availability/price handling. Use
7
+ * `skipInvalidCurrency` to avoid throwing on bad currency codes.
8
+ *
9
+ * See `ProductSnippetOptions` for accepted fields.
10
+ * @returns A JSON-LD compatible `Product` object
11
+ */
12
+ interface BrandRef {
13
+ name: string;
14
+ url?: string;
15
+ }
16
+ interface SellerRef {
17
+ name?: string;
18
+ url?: string;
19
+ }
20
+ interface ReviewRating {
21
+ ratingValue: number | string;
22
+ bestRating?: number | string;
23
+ }
24
+ interface ReviewItem {
25
+ author?: string | {
26
+ name: string;
27
+ };
28
+ datePublished?: string;
29
+ reviewBody?: string;
30
+ reviewRating?: ReviewRating;
31
+ }
32
+ interface OfferItem {
33
+ price?: string | number;
34
+ priceCurrency?: string;
35
+ availability?: string;
36
+ url?: string;
37
+ seller?: SellerRef;
38
+ priceValidUntil?: string;
39
+ itemCondition?: string;
40
+ }
41
+ interface ProductSnippetOptions {
42
+ name: string;
43
+ description?: string;
44
+ image?: string | {
45
+ url: string;
46
+ width?: number;
47
+ height?: number;
48
+ };
49
+ sku?: string;
50
+ brand?: string | BrandRef;
51
+ reviews?: ReviewItem[];
52
+ offers?: OfferItem | OfferItem[];
53
+ skipInvalidCurrency?: boolean;
54
+ }
55
+ declare const generateShoppingProductSnippetSchema: ({ name, description, image, sku, brand, reviews, offers, skipInvalidCurrency, }: ProductSnippetOptions) => any;
56
+
57
+ export { generateShoppingProductSnippetSchema };
@@ -0,0 +1 @@
1
+ const R=r=>{if(r)return typeof r=="string"?r:{"@type":"ImageObject",url:r.url,...r.width&&{width:r.width},...r.height&&{height:r.height}}},b=r=>{if(r)return typeof r=="string"?{"@type":"Brand",name:r}:{"@type":"Brand",name:r.name,...r.url&&{url:r.url}}},d=r=>r?/^[A-Z]{3}$/.test(r):!1,h=["InStock","OutOfStock","PreOrder","PreSale","Discontinued","OnlineOnly","InStoreOnly","LimitedAvailability","BackOrder"],w=r=>{if(r)try{const u=String(r);if(u.startsWith("http")){const c=u.replace(/https?:\/\/schema\.org\//i,"");return h.includes(c)?`https://schema.org/${c}`:void 0}return h.includes(u)?`https://schema.org/${u}`:void 0}catch{return}},C=({name:r,description:u,image:c,sku:f,brand:m,reviews:s,offers:g,skipInvalidCurrency:v=!1})=>{const t={"@context":"https://schema.org","@type":"Product",name:r};u&&(t.description=u);const p=R(c);p&&(t.image=p),f&&(t.sku=f);const o=b(m);if(o&&(t.brand=o),s&&s.length>0){const l=s.map(i=>{const e={"@type":"Review"};return i.author&&(e.author=typeof i.author=="string"?{"@type":"Person",name:i.author}:{"@type":"Person",name:i.author.name}),i.datePublished&&(e.datePublished=i.datePublished),i.reviewBody&&(e.reviewBody=i.reviewBody),i.reviewRating&&(e.reviewRating={"@type":"Rating",ratingValue:i.reviewRating.ratingValue,...i.reviewRating.bestRating!=null&&{bestRating:i.reviewRating.bestRating}}),e});t.review=l;const a=s.map(i=>i.reviewRating?Number(i.reviewRating.ratingValue):NaN).filter(i=>!Number.isNaN(i));if(a.length>0){const i=a.reduce((e,n)=>e+n,0);t.aggregateRating={"@type":"AggregateRating",ratingValue:i/a.length,reviewCount:s.length}}}if(g){const l=Array.isArray(g)?g:[g],a=l.map(e=>{if(e.priceCurrency&&!d(e.priceCurrency))return{__invalidCurrency:e.priceCurrency};const n={"@type":"Offer"};if(e.price!=null&&(n.price=e.price),e.priceCurrency&&(n.priceCurrency=e.priceCurrency),e.availability){const y=w(e.availability);y&&(n.availability=y)}return e.url&&(n.url=e.url),e.seller&&(n.seller={"@type":"Organization",...e.seller.name&&{name:e.seller.name},...e.seller.url&&{url:e.seller.url}}),e.priceValidUntil&&(n.priceValidUntil=e.priceValidUntil),e.itemCondition&&(n.itemCondition=e.itemCondition),n}).filter(e=>e&&!("__invalidCurrency"in e));if(l.some(e=>e.priceCurrency&&!d(e.priceCurrency))&&!v){const e=l.find(n=>n.priceCurrency&&!d(n.priceCurrency));throw new Error(`Invalid currency code: ${e?.priceCurrency}`)}a.length===1?t.offers=a[0]:a.length>1&&(t.offers=a)}return t};export{C as generateShoppingProductSnippetSchema};
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Generate schema.org `ProductGroup` (variants) and its `Product` variants
3
+ * JSON-LD.
4
+ *
5
+ * Accepts a parent group name and a list of variant `Product` entries with
6
+ * optional offers. Images and brand references are normalized into the
7
+ * appropriate schema.org objects.
8
+ *
9
+ * See `VariantsOptions` and `VariantProduct` for accepted fields.
10
+ * @returns A JSON-LD compatible `ProductGroup` object
11
+ */
12
+ interface BrandRef {
13
+ name: string;
14
+ url?: string;
15
+ }
16
+ interface OfferItem {
17
+ price?: string | number;
18
+ priceCurrency?: string;
19
+ availability?: string;
20
+ url?: string;
21
+ priceValidUntil?: string;
22
+ itemCondition?: string;
23
+ }
24
+ interface VariantProduct {
25
+ id?: string;
26
+ name: string;
27
+ sku?: string;
28
+ url?: string;
29
+ image?: string | {
30
+ url: string;
31
+ width?: number;
32
+ height?: number;
33
+ };
34
+ description?: string;
35
+ brand?: string | BrandRef;
36
+ offers?: OfferItem | OfferItem[];
37
+ }
38
+ interface VariantsOptions {
39
+ name: string;
40
+ productGroupId?: string;
41
+ variants: VariantProduct[];
42
+ skipInvalidCurrency?: boolean;
43
+ }
44
+ declare const generateShoppingVariantsSchema: ({ name, productGroupId, variants, skipInvalidCurrency, }: VariantsOptions) => any;
45
+
46
+ export { generateShoppingVariantsSchema };
@@ -0,0 +1 @@
1
+ const m=r=>{if(r)return typeof r=="string"?r:{"@type":"ImageObject",url:r.url,...r.width&&{width:r.width},...r.height&&{height:r.height}}},C=r=>{if(r)return typeof r=="string"?{"@type":"Brand",name:r}:{"@type":"Brand",name:r.name,...r.url&&{url:r.url}}},f=r=>r?/^[A-Z]{3}$/.test(r):!1,y=["InStock","OutOfStock","PreOrder","PreSale","Discontinued","OnlineOnly","InStoreOnly","LimitedAvailability","BackOrder"],I=r=>{if(r)try{const a=String(r);if(a.startsWith("http")){const s=a.replace(/https?:\/\/schema\.org\//i,"");return y.includes(s)?`https://schema.org/${s}`:void 0}return y.includes(a)?`https://schema.org/${a}`:void 0}catch{return}},b=({name:r,productGroupId:a,variants:s,skipInvalidCurrency:g=!1})=>{const h=s.map(n=>{const t={"@type":"Product",name:n.name};n.id&&(t["@id"]=n.id),n.url&&(t.url=n.url),n.sku&&(t.sku=n.sku),n.description&&(t.description=n.description);const l=m(n.image);l&&(t.image=l);const o=C(n.brand);if(o&&(t.brand=o),n.offers){const u=Array.isArray(n.offers)?n.offers:[n.offers],c=u.map(i=>{if(i.priceCurrency&&!f(i.priceCurrency))return{__invalidCurrency:i.priceCurrency};const e={"@type":"Offer"};if(i.price!=null&&(e.price=i.price),i.priceCurrency&&(e.priceCurrency=i.priceCurrency),i.availability){const p=I(i.availability);p&&(e.availability=p)}return i.url&&(e.url=i.url),i.priceValidUntil&&(e.priceValidUntil=i.priceValidUntil),i.itemCondition&&(e.itemCondition=i.itemCondition),e}).filter(i=>i&&!("__invalidCurrency"in i));if(u.some(i=>i.priceCurrency&&!f(i.priceCurrency))&&!g){const i=u.find(e=>e.priceCurrency&&!f(e.priceCurrency));throw new Error(`Invalid currency code: ${i?.priceCurrency}`)}c.length===1?t.offers=c[0]:c.length>1&&(t.offers=c)}return t}),d={"@context":"https://schema.org","@type":"ProductGroup",name:r,hasVariant:h};return a&&(d["@id"]=a),d};export{b as generateShoppingVariantsSchema};
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Generate schema.org `SoftwareApplication` JSON-LD, optionally including
3
+ * `Review` and `AggregateRating` data.
4
+ *
5
+ * Accepts application metadata (platforms, versions, downloads), images,
6
+ * author/publisher references, reviews and an aggregate rating. Only
7
+ * provided fields are emitted in the returned object.
8
+ *
9
+ * See `SoftwareAppOptions` below for the input shape.
10
+ * @returns A JSON-LD compatible `SoftwareApplication` object
11
+ */
12
+ interface ImageRef {
13
+ url: string;
14
+ width?: number;
15
+ height?: number;
16
+ }
17
+ interface PersonRef {
18
+ name: string;
19
+ url?: string;
20
+ }
21
+ interface OrgRef {
22
+ name: string;
23
+ url?: string;
24
+ }
25
+ interface RatingItem {
26
+ ratingValue: number | string;
27
+ bestRating?: number | string;
28
+ worstRating?: number | string;
29
+ }
30
+ interface ReviewItem {
31
+ author?: string | PersonRef;
32
+ datePublished?: string;
33
+ reviewBody?: string;
34
+ reviewRating?: RatingItem;
35
+ name?: string;
36
+ url?: string;
37
+ publisher?: string | OrgRef;
38
+ }
39
+ interface AggregateRatingOptions {
40
+ ratingValue: number | string;
41
+ reviewCount?: number;
42
+ ratingCount?: number;
43
+ bestRating?: number | string;
44
+ worstRating?: number | string;
45
+ }
46
+ interface SoftwareAppOptions {
47
+ name: string;
48
+ description?: string;
49
+ image?: string | ImageRef;
50
+ url?: string;
51
+ softwareVersion?: string;
52
+ operatingSystem?: string | string[];
53
+ applicationCategory?: string | string[];
54
+ downloadUrl?: string;
55
+ author?: string | PersonRef;
56
+ publisher?: string | OrgRef;
57
+ reviews?: ReviewItem[];
58
+ aggregateRating?: AggregateRatingOptions;
59
+ }
60
+ declare const generateSoftwareAppSchema: ({ name, description, image, url, softwareVersion, operatingSystem, applicationCategory, downloadUrl, author, publisher, reviews, aggregateRating, }: SoftwareAppOptions) => any;
61
+
62
+ export { generateSoftwareAppSchema as default, generateSoftwareAppSchema };
@@ -0,0 +1 @@
1
+ const O=t=>{if(t)return typeof t=="string"?t:{"@type":"ImageObject",url:t.url,...t.width&&{width:t.width},...t.height&&{height:t.height}}},h=t=>{if(!t)return;if(typeof t=="string")return{"@type":"Person",name:t};const n={"@type":"Person",name:t.name};return t.url&&(n.url=t.url),n},p=t=>{if(!t)return;if(typeof t=="string")return{"@type":"Organization",name:t};const n={"@type":"Organization",name:t.name};return t.url&&(n.url=t.url),n},P=t=>{const n={"@type":"Review"};return t.author&&(n.author=h(t.author)),t.datePublished&&(n.datePublished=t.datePublished),t.reviewBody&&(n.reviewBody=t.reviewBody),t.name&&(n.name=t.name),t.url&&(n.url=t.url),t.publisher&&(n.publisher=p(t.publisher)),t.reviewRating&&(n.reviewRating={"@type":"Rating",ratingValue:t.reviewRating.ratingValue,...t.reviewRating.bestRating!=null&&{bestRating:t.reviewRating.bestRating},...t.reviewRating.worstRating!=null&&{worstRating:t.reviewRating.worstRating}}),n},I=({name:t,description:n,image:b,url:o,softwareVersion:f,operatingSystem:s,applicationCategory:u,downloadUrl:l,author:c,publisher:d,reviews:a,aggregateRating:i})=>{const e={"@context":"https://schema.org","@type":"SoftwareApplication",name:t};n&&(e.description=n);const R=O(b);R&&(e.image=R),o&&(e.url=o),f&&(e.softwareVersion=f),s&&(e.operatingSystem=Array.isArray(s)?s.join(", "):s),u&&(e.applicationCategory=Array.isArray(u)?u.join(", "):u),l&&(e.downloadUrl=l);const m=h(c);m&&(e.author=m);const w=p(d);if(w&&(e.publisher=w),a&&a.length>0){const y=a.map(P);if(e.review=y,!i){const g=a.map(r=>r.reviewRating?Number(r.reviewRating.ratingValue):NaN).filter(r=>!Number.isNaN(r));if(g.length>0){const r=g.reduce((v,A)=>v+A,0);e.aggregateRating={"@type":"AggregateRating",ratingValue:r/g.length,reviewCount:a.length,ratingCount:g.length}}}}return i&&(e.aggregateRating={"@type":"AggregateRating",ratingValue:i.ratingValue,...i.reviewCount!=null&&{reviewCount:i.reviewCount},...i.ratingCount!=null&&{ratingCount:i.ratingCount},...i.bestRating!=null&&{bestRating:i.bestRating},...i.worstRating!=null&&{worstRating:i.worstRating}}),e};var C=I;export{C as default,I as generateSoftwareAppSchema};
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Generate schema.org structured data for an `Article` or `WebPage` with a
3
+ * `SpeakableSpecification`.
4
+ *
5
+ * The `speakable` input may be an array of XPaths/CSS selectors or an
6
+ * object with `xpath`/`cssSelector` arrays. The helper will produce a
7
+ * `SpeakableSpecification` and attach it to the chosen page type.
8
+ *
9
+ * See `SpeakableOptions` for full details.
10
+ * @returns A JSON-LD compatible Article/WebPage object with `speakable`
11
+ * specification when provided.
12
+ */
13
+ type SpeakableInput = string[] | {
14
+ xpath?: string[];
15
+ cssSelector?: string[];
16
+ };
17
+ type PageType = 'Article' | 'WebPage';
18
+ interface PersonRef {
19
+ name: string;
20
+ url?: string;
21
+ }
22
+ interface PublisherRef {
23
+ name: string;
24
+ url?: string;
25
+ logo?: {
26
+ url: string;
27
+ width?: number;
28
+ height?: number;
29
+ };
30
+ }
31
+ interface RatingItem {
32
+ ratingValue: number | string;
33
+ bestRating?: number | string;
34
+ worstRating?: number | string;
35
+ }
36
+ interface ReviewItem {
37
+ author?: string | PersonRef;
38
+ datePublished?: string;
39
+ reviewBody?: string;
40
+ reviewRating?: RatingItem;
41
+ }
42
+ interface AggregateRatingOptions {
43
+ ratingValue: number | string;
44
+ reviewCount?: number;
45
+ ratingCount?: number;
46
+ bestRating?: number | string;
47
+ worstRating?: number | string;
48
+ }
49
+ interface SpeakableOptions {
50
+ type?: PageType;
51
+ headline?: string;
52
+ name?: string;
53
+ description?: string;
54
+ url?: string;
55
+ author?: string | PersonRef;
56
+ publisher?: PublisherRef;
57
+ speakable?: SpeakableInput;
58
+ reviews?: ReviewItem[];
59
+ aggregateRating?: AggregateRatingOptions;
60
+ keywords?: string[];
61
+ }
62
+ declare const generateSpeakableSchema: ({ type, headline, name, description, url, author, publisher, speakable, reviews, aggregateRating, keywords, }: SpeakableOptions) => any;
63
+
64
+ export { generateSpeakableSchema as default, generateSpeakableSchema };
@@ -0,0 +1 @@
1
+ const c=e=>{if(!e)return;if(typeof e=="string")return{"@type":"Person",name:e};const t={"@type":"Person",name:e.name};return e.url&&(t.url=e.url),t},v=e=>{if(!e)return;const t={"@type":"Organization",name:e.name};return e.url&&(t.url=e.url),e.logo&&(t.logo={"@type":"ImageObject",url:e.logo.url,...e.logo.width&&{width:e.logo.width},...e.logo.height&&{height:e.logo.height}}),t},P=e=>{if(!e)return;const t={"@type":"SpeakableSpecification"};return Array.isArray(e)?(t.xpath=e,t):(e.xpath&&e.xpath.length>0&&(t.xpath=e.xpath),e.cssSelector&&e.cssSelector.length>0&&(t.cssSelector=e.cssSelector),t)},S=e=>{const t={"@type":"Review"};return e.author&&(t.author=c(e.author)),e.datePublished&&(t.datePublished=e.datePublished),e.reviewBody&&(t.reviewBody=e.reviewBody),e.reviewRating&&(t.reviewRating={"@type":"Rating",ratingValue:e.reviewRating.ratingValue,...e.reviewRating.bestRating!=null&&{bestRating:e.reviewRating.bestRating},...e.reviewRating.worstRating!=null&&{worstRating:e.reviewRating.worstRating}}),t},k=({type:e="Article",headline:t,name:u,description:g,url:l,author:R,publisher:p,speakable:m,reviews:a,aggregateRating:i,keywords:s})=>{const n={"@context":"https://schema.org","@type":e};e==="Article"&&t&&(n.headline=t),e==="WebPage"&&u&&(n.name=u),g&&(n.description=g),l&&(n.mainEntityOfPage={"@type":"WebPage","@id":l});const f=c(R);f&&(n.author=f);const h=v(p);h&&(n.publisher=h);const b=P(m);if(b&&(n.speakable=b),a&&a.length>0){const w=a.map(S);if(n.review=w,!i){const o=a.map(r=>r.reviewRating?Number(r.reviewRating.ratingValue):NaN).filter(r=>!Number.isNaN(r));if(o.length>0){const r=o.reduce((y,d)=>y+d,0);n.aggregateRating={"@type":"AggregateRating",ratingValue:r/o.length,reviewCount:a.length,ratingCount:o.length}}}}return i&&(n.aggregateRating={"@type":"AggregateRating",ratingValue:i.ratingValue,...i.reviewCount!=null&&{reviewCount:i.reviewCount},...i.ratingCount!=null&&{ratingCount:i.ratingCount},...i.bestRating!=null&&{bestRating:i.bestRating},...i.worstRating!=null&&{worstRating:i.worstRating}}),s&&s.length>0&&(n.keywords=s.join(", ")),n};var C=k;export{C as default,k as generateSpeakableSchema};
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Generate schema.org JSON-LD for a `CreativeWork` representing a
3
+ * Subscription.
4
+ *
5
+ * Supports author/publisher, reviews and aggregate ratings, accessibility
6
+ * flags and keywords. Only provided fields are emitted in the returned
7
+ * object.
8
+ *
9
+ * See `SubscriptionOptions` for accepted properties.
10
+ * @returns A JSON-LD compatible `CreativeWork` (Subscription) object
11
+ */
12
+ interface ImageRef {
13
+ url: string;
14
+ width?: number;
15
+ height?: number;
16
+ }
17
+ interface PersonRef {
18
+ name: string;
19
+ url?: string;
20
+ }
21
+ interface OrgRef {
22
+ name: string;
23
+ url?: string;
24
+ }
25
+ interface RatingItem {
26
+ ratingValue: number | string;
27
+ bestRating?: number | string;
28
+ worstRating?: number | string;
29
+ }
30
+ interface ReviewItem {
31
+ author?: string | PersonRef;
32
+ datePublished?: string;
33
+ reviewBody?: string;
34
+ reviewRating?: RatingItem;
35
+ }
36
+ interface AggregateRatingOptions {
37
+ ratingValue: number | string;
38
+ reviewCount?: number;
39
+ ratingCount?: number;
40
+ bestRating?: number | string;
41
+ worstRating?: number | string;
42
+ }
43
+ interface SubscriptionOptions {
44
+ name: string;
45
+ description?: string;
46
+ image?: string | ImageRef;
47
+ url?: string;
48
+ author?: string | PersonRef;
49
+ publisher?: string | OrgRef;
50
+ datePublished?: string;
51
+ dateModified?: string;
52
+ isAccessibleForFree?: boolean;
53
+ genre?: string | string[];
54
+ keywords?: string | string[];
55
+ reviews?: ReviewItem[];
56
+ aggregateRating?: AggregateRatingOptions;
57
+ }
58
+ declare const generateSubscriptionSchema: ({ name, description, image, url, author, publisher, datePublished, dateModified, isAccessibleForFree, genre, keywords, reviews, aggregateRating, }: SubscriptionOptions) => any;
59
+
60
+ export { generateSubscriptionSchema as default, generateSubscriptionSchema };
@@ -0,0 +1 @@
1
+ const C=t=>{if(t)return typeof t=="string"?t:{"@type":"ImageObject",url:t.url,...t.width&&{width:t.width},...t.height&&{height:t.height}}},b=t=>{if(!t)return;if(typeof t=="string")return{"@type":"Person",name:t};const n={"@type":"Person",name:t.name};return t.url&&(n.url=t.url),n},O=t=>{if(!t)return;if(typeof t=="string")return{"@type":"Organization",name:t};const n={"@type":"Organization",name:t.name};return t.url&&(n.url=t.url),n},I=t=>{const n={"@type":"Review"};return t.author&&(n.author=b(t.author)),t.datePublished&&(n.datePublished=t.datePublished),t.reviewBody&&(n.reviewBody=t.reviewBody),t.reviewRating&&(n.reviewRating={"@type":"Rating",ratingValue:t.reviewRating.ratingValue,...t.reviewRating.bestRating!=null&&{bestRating:t.reviewRating.bestRating},...t.reviewRating.worstRating!=null&&{worstRating:t.reviewRating.worstRating}}),n},A=({name:t,description:n,image:w,url:o,author:d,publisher:y,datePublished:f,dateModified:l,isAccessibleForFree:R,genre:s,keywords:u,reviews:a,aggregateRating:i})=>{const e={"@context":"https://schema.org","@type":"CreativeWork",name:t};n&&(e.description=n);const m=C(w);m&&(e.image=m),o&&(e.url=o);const c=b(d);c&&(e.author=c);const h=O(y);if(h&&(e.publisher=h),f&&(e.datePublished=f),l&&(e.dateModified=l),R!=null&&(e.isAccessibleForFree=R),s&&(e.genre=Array.isArray(s)?s.join(", "):s),u&&(e.keywords=Array.isArray(u)?u.join(", "):u),a&&a.length>0){const p=a.map(I);if(e.review=p,!i){const g=a.map(r=>r.reviewRating?Number(r.reviewRating.ratingValue):NaN).filter(r=>!Number.isNaN(r));if(g.length>0){const r=g.reduce((v,P)=>v+P,0);e.aggregateRating={"@type":"AggregateRating",ratingValue:r/g.length,reviewCount:a.length,ratingCount:g.length}}}}return i&&(e.aggregateRating={"@type":"AggregateRating",ratingValue:i.ratingValue,...i.reviewCount!=null&&{reviewCount:i.reviewCount},...i.ratingCount!=null&&{ratingCount:i.ratingCount},...i.bestRating!=null&&{bestRating:i.bestRating},...i.worstRating!=null&&{worstRating:i.worstRating}}),e};var V=A;export{V as default,A as generateSubscriptionSchema};