@react-pakistan/util-functions 1.25.90 → 2.0.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.
Files changed (417) hide show
  1. package/README.md +74 -315
  2. package/constants/api-methods.d.ts +3 -1
  3. package/constants/api-methods.js +1 -15
  4. package/constants/cache-time.d.ts +7 -5
  5. package/constants/cache-time.js +1 -8
  6. package/constants/countries-timezones.d.ts +4 -2
  7. package/constants/countries-timezones.js +1 -1411
  8. package/constants/currencies.d.ts +4 -2
  9. package/constants/currencies.js +1 -1076
  10. package/constants/dial-codes.d.ts +5 -3
  11. package/constants/dial-codes.js +1 -1216
  12. package/constants/layout-direction.d.ts +3 -1
  13. package/constants/layout-direction.js +1 -8
  14. package/constants/react-pakistan-meta.d.ts +4 -2
  15. package/constants/react-pakistan-meta.js +1 -35
  16. package/constants/react-pakistan.d.ts +5 -3
  17. package/constants/react-pakistan.js +12 -104
  18. package/constants/select-value-delimiter.d.ts +3 -1
  19. package/constants/select-value-delimiter.js +1 -13
  20. package/constants/social-media-colors.d.ts +3 -1
  21. package/constants/social-media-colors.js +1 -42
  22. package/constants/social-media-sizes.d.ts +6 -4
  23. package/constants/social-media-sizes.js +1 -327
  24. package/constants/user-roles.d.ts +3 -1
  25. package/constants/user-roles.js +1 -9
  26. package/edu-pilot-pro/types/academics.d.ts +2 -266
  27. package/edu-pilot-pro/types/academics.js +1 -9
  28. package/edu-pilot-pro/types/admission.d.ts +803 -10
  29. package/edu-pilot-pro/types/admission.js +1 -7
  30. package/edu-pilot-pro/types/communication.d.ts +2 -165
  31. package/edu-pilot-pro/types/communication.js +1 -8
  32. package/edu-pilot-pro/types/enums.d.ts +30 -28
  33. package/edu-pilot-pro/types/enums.js +1 -445
  34. package/edu-pilot-pro/types/finance.d.ts +2 -128
  35. package/edu-pilot-pro/types/finance.js +1 -8
  36. package/edu-pilot-pro/types/index.d.ts +2 -12
  37. package/edu-pilot-pro/types/index.js +1 -28
  38. package/edu-pilot-pro/types/user-management.d.ts +2 -236
  39. package/edu-pilot-pro/types/user-management.js +1 -8
  40. package/factory/generic-component-factory.d.ts +12 -9
  41. package/factory/generic-component-factory.js +1 -131
  42. package/factory/generic-module-factory.d.ts +14 -10
  43. package/factory/generic-module-factory.js +1 -190
  44. package/general/basic-get.d.ts +8 -1
  45. package/general/basic-get.js +1 -83
  46. package/general/basic-post.d.ts +8 -1
  47. package/general/basic-post.js +1 -70
  48. package/general/calculate-pages.d.ts +9 -1
  49. package/general/calculate-pages.js +1 -7
  50. package/general/camel-to-sentence-case.d.ts +3 -1
  51. package/general/camel-to-sentence-case.js +1 -20
  52. package/general/check-even-odd-length.d.ts +3 -1
  53. package/general/check-even-odd-length.js +1 -17
  54. package/general/clear-cache.d.ts +7 -2
  55. package/general/clear-cache.js +1 -12
  56. package/general/cnic-formatter.d.ts +16 -3
  57. package/general/cnic-formatter.js +1 -53
  58. package/general/convert-url-to-base64.d.ts +8 -6
  59. package/general/convert-url-to-base64.js +1 -231
  60. package/general/countries.d.ts +5 -3
  61. package/general/countries.js +1 -514
  62. package/general/create-date.d.ts +3 -1
  63. package/general/create-date.js +1 -22
  64. package/general/crypto.d.ts +4 -2
  65. package/general/crypto.js +1 -45
  66. package/general/currencies.d.ts +2 -0
  67. package/general/currencies.js +0 -1077
  68. package/general/delete-image-from-private-supabase.d.ts +10 -2
  69. package/general/delete-image-from-private-supabase.js +1 -66
  70. package/general/delete-image-from-public-supabase.d.ts +10 -2
  71. package/general/delete-image-from-public-supabase.js +1 -66
  72. package/general/download-from-url.d.ts +8 -1
  73. package/general/download-from-url.js +1 -82
  74. package/general/dynamic-page-limit.d.ts +9 -3
  75. package/general/dynamic-page-limit.js +1 -7
  76. package/general/enum-to-text.d.ts +8 -1
  77. package/general/enum-to-text.js +1 -11
  78. package/general/fetch-data.d.ts +16 -4
  79. package/general/fetch-data.js +1 -95
  80. package/general/fetch-supabase-image.d.ts +11 -2
  81. package/general/fetch-supabase-image.js +1 -67
  82. package/general/fetch-supabase-private-assets.d.ts +11 -2
  83. package/general/fetch-supabase-private-assets.js +1 -69
  84. package/general/format-date.d.ts +10 -2
  85. package/general/format-date.js +1 -49
  86. package/general/format-number.d.ts +12 -2
  87. package/general/format-number.js +1 -35
  88. package/general/format-phone-display.d.ts +9 -1
  89. package/general/format-phone-display.js +1 -32
  90. package/general/format-phone.d.ts +10 -2
  91. package/general/format-phone.js +1 -20
  92. package/general/format-pricing.d.ts +8 -1
  93. package/general/format-pricing.js +1 -23
  94. package/general/format-secs.d.ts +8 -1
  95. package/general/format-secs.js +1 -21
  96. package/general/format-time.d.ts +8 -2
  97. package/general/format-time.js +1 -38
  98. package/general/format-value.d.ts +8 -1
  99. package/general/format-value.js +1 -7
  100. package/general/full-month-range.d.ts +3 -2
  101. package/general/full-month-range.js +1 -24
  102. package/general/full-year-range.d.ts +3 -2
  103. package/general/full-year-range.js +1 -20
  104. package/general/generate-article-schema.d.ts +3 -2
  105. package/general/generate-article-schema.js +1 -100
  106. package/general/generate-blog-schema.d.ts +3 -2
  107. package/general/generate-blog-schema.js +1 -32
  108. package/general/generate-book-schema.d.ts +3 -2
  109. package/general/generate-book-schema.js +1 -109
  110. package/general/generate-breadcrumb-schema.d.ts +3 -2
  111. package/general/generate-breadcrumb-schema.js +1 -34
  112. package/general/generate-carousel-schema.d.ts +3 -2
  113. package/general/generate-carousel-schema.js +1 -172
  114. package/general/generate-course-schema.d.ts +3 -2
  115. package/general/generate-course-schema.js +1 -124
  116. package/general/generate-dataset-schema.d.ts +3 -2
  117. package/general/generate-dataset-schema.js +1 -156
  118. package/general/generate-discussion-forum-schema.d.ts +3 -2
  119. package/general/generate-discussion-forum-schema.js +1 -67
  120. package/general/generate-education-schema.d.ts +3 -2
  121. package/general/generate-education-schema.js +1 -137
  122. package/general/generate-employer-aggregate-rating-schema.d.ts +3 -2
  123. package/general/generate-employer-aggregate-rating-schema.js +1 -64
  124. package/general/generate-event-schema.d.ts +3 -2
  125. package/general/generate-event-schema.js +1 -214
  126. package/general/generate-faq-schema.d.ts +3 -2
  127. package/general/generate-faq-schema.js +1 -43
  128. package/general/generate-grid.d.ts +3 -2
  129. package/general/generate-grid.js +1 -55
  130. package/general/generate-image-metadata-schema.d.ts +3 -2
  131. package/general/generate-image-metadata-schema.js +1 -73
  132. package/general/generate-job-posting-schema.d.ts +3 -2
  133. package/general/generate-job-posting-schema.js +1 -120
  134. package/general/generate-local-business-schema.d.ts +3 -2
  135. package/general/generate-local-business-schema.js +1 -75
  136. package/general/generate-math-solver-schema.d.ts +3 -2
  137. package/general/generate-math-solver-schema.js +1 -83
  138. package/general/generate-movie-carousel-schema.d.ts +3 -2
  139. package/general/generate-movie-carousel-schema.js +1 -160
  140. package/general/generate-organization-schema.d.ts +3 -2
  141. package/general/generate-organization-schema.js +1 -39
  142. package/general/generate-profile-page-schema.d.ts +3 -2
  143. package/general/generate-profile-page-schema.js +1 -82
  144. package/general/generate-qa-page-schema.d.ts +3 -2
  145. package/general/generate-qa-page-schema.js +1 -67
  146. package/general/generate-recipe-schema.d.ts +3 -2
  147. package/general/generate-recipe-schema.js +1 -104
  148. package/general/generate-ref.d.ts +8 -2
  149. package/general/generate-ref.js +1 -12
  150. package/general/generate-review-snippet-schema.d.ts +3 -2
  151. package/general/generate-review-snippet-schema.js +1 -137
  152. package/general/generate-shopping-loyalty-program-schema.d.ts +3 -2
  153. package/general/generate-shopping-loyalty-program-schema.js +1 -59
  154. package/general/generate-shopping-merchant-listing-schema.d.ts +3 -2
  155. package/general/generate-shopping-merchant-listing-schema.js +1 -153
  156. package/general/generate-shopping-merchant-return-policy-schema.d.ts +3 -2
  157. package/general/generate-shopping-merchant-return-policy-schema.js +1 -68
  158. package/general/generate-shopping-merchant-shipping-policy-schema.d.ts +3 -2
  159. package/general/generate-shopping-merchant-shipping-policy-schema.js +1 -74
  160. package/general/generate-shopping-overview-schema.d.ts +3 -2
  161. package/general/generate-shopping-overview-schema.js +1 -157
  162. package/general/generate-shopping-product-snippet-schema.d.ts +3 -2
  163. package/general/generate-shopping-product-snippet-schema.js +1 -167
  164. package/general/generate-shopping-variants-schema.d.ts +3 -2
  165. package/general/generate-shopping-variants-schema.js +1 -143
  166. package/general/generate-software-app-schema.d.ts +3 -2
  167. package/general/generate-software-app-schema.js +1 -143
  168. package/general/generate-speakable-schema.d.ts +3 -2
  169. package/general/generate-speakable-schema.js +1 -139
  170. package/general/generate-subscription-schema.d.ts +3 -2
  171. package/general/generate-subscription-schema.js +1 -133
  172. package/general/generate-vacation-rental-schema.d.ts +3 -2
  173. package/general/generate-vacation-rental-schema.js +1 -135
  174. package/general/generate-video-schema.d.ts +3 -2
  175. package/general/generate-video-schema.js +1 -163
  176. package/general/generic-cache.d.ts +17 -15
  177. package/general/generic-cache.js +1 -659
  178. package/general/get-available-page-limit.d.ts +8 -2
  179. package/general/get-available-page-limit.js +1 -31
  180. package/general/get-calendar-current-month.d.ts +11 -3
  181. package/general/get-calendar-current-month.js +1 -31
  182. package/general/get-calendar-dates.d.ts +11 -3
  183. package/general/get-calendar-dates.js +1 -42
  184. package/general/get-calendar-next-month.d.ts +12 -3
  185. package/general/get-calendar-next-month.js +1 -32
  186. package/general/get-calendar-previous-month.d.ts +12 -3
  187. package/general/get-calendar-previous-month.js +1 -36
  188. package/general/get-current-year.d.ts +7 -1
  189. package/general/get-current-year.js +1 -5
  190. package/general/get-day-name.d.ts +5 -3
  191. package/general/get-day-name.js +1 -14
  192. package/general/get-dial-code.d.ts +8 -1
  193. package/general/get-dial-code.js +1 -8
  194. package/general/get-full-name.d.ts +9 -2
  195. package/general/get-full-name.js +1 -8
  196. package/general/get-href.d.ts +3 -1
  197. package/general/get-href.js +1 -13
  198. package/general/get-month-name.d.ts +5 -3
  199. package/general/get-month-name.js +1 -19
  200. package/general/get-month-number.d.ts +5 -3
  201. package/general/get-month-number.js +1 -29
  202. package/general/get-number-of-days-in-month.d.ts +9 -2
  203. package/general/get-number-of-days-in-month.js +1 -12
  204. package/general/get-pathname.d.ts +3 -1
  205. package/general/get-pathname.js +1 -16
  206. package/general/get-week-day.d.ts +8 -1
  207. package/general/get-week-day.js +1 -9
  208. package/general/image-url-to-base64.d.ts +3 -1
  209. package/general/image-url-to-base64.js +1 -80
  210. package/general/is-created-or-updated.d.ts +3 -1
  211. package/general/is-created-or-updated.js +1 -26
  212. package/general/is-next-button-disabled.d.ts +9 -1
  213. package/general/is-next-button-disabled.js +1 -5
  214. package/general/is-odd.d.ts +3 -1
  215. package/general/is-odd.js +1 -13
  216. package/general/is-previous-button-disabled.d.ts +8 -1
  217. package/general/is-previous-button-disabled.js +1 -7
  218. package/general/linear-gradients.d.ts +4 -2
  219. package/general/linear-gradients.js +1 -52
  220. package/general/multi-part-search.d.ts +10 -2
  221. package/general/multi-part-search.js +1 -16
  222. package/general/normalize-phone.d.ts +15 -2
  223. package/general/normalize-phone.js +1 -40
  224. package/general/parse-frontmatter.d.ts +11 -4
  225. package/general/parse-frontmatter.js +2 -35
  226. package/general/remove-data-image-prefix.d.ts +8 -1
  227. package/general/remove-data-image-prefix.js +1 -7
  228. package/general/repeat-times.d.ts +3 -1
  229. package/general/repeat-times.js +1 -21
  230. package/general/resolve-anchor-link.d.ts +3 -1
  231. package/general/resolve-anchor-link.js +1 -26
  232. package/general/resolve-current-date.d.ts +3 -1
  233. package/general/resolve-current-date.js +1 -22
  234. package/general/resolve-grid.d.ts +3 -1
  235. package/general/resolve-grid.js +1 -18
  236. package/general/resolve-initials.d.ts +3 -1
  237. package/general/resolve-initials.js +1 -17
  238. package/general/set-timezone.d.ts +11 -1
  239. package/general/set-timezone.js +1 -12
  240. package/general/slugify.d.ts +3 -1
  241. package/general/slugify.js +1 -24
  242. package/general/text-to-enum.d.ts +8 -1
  243. package/general/text-to-enum.js +1 -10
  244. package/general/text-to-sentence-case.d.ts +3 -1
  245. package/general/text-to-sentence-case.js +1 -16
  246. package/general/time-out.d.ts +3 -1
  247. package/general/time-out.js +1 -16
  248. package/general/time-zones.d.ts +3 -1
  249. package/general/time-zones.js +1 -437
  250. package/general/truncate-text.d.ts +3 -1
  251. package/general/truncate-text.js +1 -18
  252. package/general/type.d.ts +3 -1
  253. package/general/type.js +1 -2
  254. package/general/upload-blob-to-private-supabase.d.ts +14 -2
  255. package/general/upload-blob-to-private-supabase.js +1 -62
  256. package/general/upload-blob-to-public-supabase.d.ts +14 -2
  257. package/general/upload-blob-to-public-supabase.js +1 -62
  258. package/general/upload-image-to-private-supabase.d.ts +15 -3
  259. package/general/upload-image-to-private-supabase.js +1 -66
  260. package/general/upload-image-to-public-supabase.d.ts +15 -3
  261. package/general/upload-image-to-public-supabase.js +1 -66
  262. package/general/url-to-sentence-case.d.ts +3 -1
  263. package/general/url-to-sentence-case.js +1 -19
  264. package/general/validate-comment.d.ts +3 -1
  265. package/general/validate-comment.js +1 -21
  266. package/general/validate-email.d.ts +3 -1
  267. package/general/validate-email.js +1 -24
  268. package/general/validate-form.d.ts +12 -3
  269. package/general/validate-form.js +1 -29
  270. package/general/validate-name.d.ts +3 -1
  271. package/general/validate-name.js +1 -21
  272. package/hooks/use-change.d.ts +11 -2
  273. package/hooks/use-change.js +1 -23
  274. package/hooks/use-debounce.d.ts +10 -1
  275. package/hooks/use-debounce.js +1 -14
  276. package/hooks/use-fetch.d.ts +7 -5
  277. package/hooks/use-fetch.js +1 -239
  278. package/hooks/use-force-render.d.ts +6 -2
  279. package/hooks/use-force-render.js +1 -17
  280. package/hooks/use-ip-geo-location.d.ts +8 -1
  281. package/hooks/use-ip-geo-location.js +1 -79
  282. package/hooks/use-is-mobile.d.ts +8 -1
  283. package/hooks/use-is-mobile.js +1 -22
  284. package/hooks/use-module-entity-v2.d.ts +7 -4
  285. package/hooks/use-module-entity-v2.js +1 -188
  286. package/hooks/use-module-entity.d.ts +7 -4
  287. package/hooks/use-module-entity.js +1 -177
  288. package/hooks/use-phone-formatter.d.ts +10 -2
  289. package/hooks/use-phone-formatter.js +1 -23
  290. package/hooks/use-position.d.ts +6 -3
  291. package/hooks/use-position.js +1 -43
  292. package/hooks/use-rtl.d.ts +4 -2
  293. package/hooks/use-rtl.js +1 -84
  294. package/hooks/use-sticky.d.ts +3 -1
  295. package/hooks/use-sticky.js +1 -39
  296. package/hooks/use-toggle-state.d.ts +3 -2
  297. package/hooks/use-toggle-state.js +1 -26
  298. package/hooks/use-window-event-listener.d.ts +9 -1
  299. package/hooks/use-window-event-listener.js +1 -11
  300. package/hooks/with-seo.d.ts +11 -2
  301. package/hooks/with-seo.js +1 -37
  302. package/local-storage/get-storage-value.d.ts +5 -2
  303. package/local-storage/get-storage-value.js +1 -20
  304. package/local-storage/remove-storage-value.d.ts +3 -1
  305. package/local-storage/remove-storage-value.js +1 -14
  306. package/local-storage/set-storage-value.d.ts +3 -1
  307. package/local-storage/set-storage-value.js +1 -14
  308. package/local-storage/type.d.ts +3 -1
  309. package/local-storage/type.js +1 -2
  310. package/npm.d.d.ts +2 -0
  311. package/npm.d.js +0 -0
  312. package/package.json +21 -19
  313. package/{api/stellar-solutions → stellar-solution}/types/common.d.ts +4 -2
  314. package/stellar-solution/types/common.js +1 -0
  315. package/{api/stellar-solutions → stellar-solution}/types/erp.d.ts +36 -33
  316. package/stellar-solution/types/erp.js +1 -0
  317. package/stellar-solution/types/index.d.ts +3 -0
  318. package/stellar-solution/types/index.js +1 -0
  319. package/{api/stellar-solutions → stellar-solution}/types/pos.d.ts +27 -24
  320. package/stellar-solution/types/pos.js +1 -0
  321. package/storybook/generate-sitemap.d.ts +3 -1
  322. package/storybook/generate-sitemap.js +17 -26
  323. package/storybook/preview.d.ts +4 -2
  324. package/storybook/preview.js +1 -62
  325. package/storybook/react-design-story-script.d.ts +3 -1
  326. package/storybook/react-design-story-script.js +5 -27
  327. package/storybook/react-emoji-collection.d.ts +3 -1
  328. package/storybook/react-emoji-collection.js +10 -55
  329. package/storybook/react-emoji-story-script.d.ts +3 -1
  330. package/storybook/react-emoji-story-script.js +5 -31
  331. package/storybook/react-emoji-story-template.d.ts +3 -1
  332. package/storybook/react-emoji-story-template.js +45 -15
  333. package/storybook/react-icon-collection.d.ts +3 -1
  334. package/storybook/react-icon-collection.js +10 -42
  335. package/storybook/react-icon-story-script.d.ts +3 -1
  336. package/storybook/react-icon-story-script.js +5 -27
  337. package/storybook/react-icon-story-template.d.ts +3 -1
  338. package/storybook/react-icon-story-template.js +45 -14
  339. package/storybook/react-logo-collection.d.ts +3 -1
  340. package/storybook/react-logo-collection.js +10 -42
  341. package/storybook/react-logo-story-script.d.ts +3 -1
  342. package/storybook/react-logo-story-script.js +5 -27
  343. package/storybook/react-logo-story-template.d.ts +3 -1
  344. package/storybook/react-logo-story-template.js +45 -14
  345. package/storybook/react-pakistan-theme.d.ts +3 -1
  346. package/storybook/react-pakistan-theme.js +1 -31
  347. package/storybook/responsive-args.d.ts +11 -10
  348. package/storybook/responsive-args.js +1 -19
  349. package/storybook/responsive-component.d.ts +4 -2
  350. package/storybook/responsive-component.js +37 -23
  351. package/storybook/responsive-screens.d.ts +3 -1
  352. package/storybook/responsive-screens.js +1 -109
  353. package/storybook/theme.d.ts +17 -15
  354. package/storybook/theme.js +1 -1022
  355. package/api/stellar-solutions/app-user/index.d.ts +0 -51
  356. package/api/stellar-solutions/app-user/index.js +0 -210
  357. package/api/stellar-solutions/bank/index.d.ts +0 -59
  358. package/api/stellar-solutions/bank/index.js +0 -210
  359. package/api/stellar-solutions/branch/index.d.ts +0 -58
  360. package/api/stellar-solutions/branch/index.js +0 -220
  361. package/api/stellar-solutions/company/index.d.ts +0 -57
  362. package/api/stellar-solutions/company/index.js +0 -218
  363. package/api/stellar-solutions/company-report/index.d.ts +0 -15
  364. package/api/stellar-solutions/company-report/index.js +0 -74
  365. package/api/stellar-solutions/constants.d.ts +0 -19
  366. package/api/stellar-solutions/constants.js +0 -22
  367. package/api/stellar-solutions/contact/index.d.ts +0 -56
  368. package/api/stellar-solutions/contact/index.js +0 -217
  369. package/api/stellar-solutions/currency/index.d.ts +0 -55
  370. package/api/stellar-solutions/currency/index.js +0 -212
  371. package/api/stellar-solutions/customer/index.d.ts +0 -68
  372. package/api/stellar-solutions/customer/index.js +0 -249
  373. package/api/stellar-solutions/expense/index.d.ts +0 -58
  374. package/api/stellar-solutions/expense/index.js +0 -229
  375. package/api/stellar-solutions/expense-category/index.d.ts +0 -53
  376. package/api/stellar-solutions/expense-category/index.js +0 -214
  377. package/api/stellar-solutions/lead/index.d.ts +0 -51
  378. package/api/stellar-solutions/lead/index.js +0 -206
  379. package/api/stellar-solutions/menu-order/index.d.ts +0 -53
  380. package/api/stellar-solutions/menu-order/index.js +0 -202
  381. package/api/stellar-solutions/payment/index.d.ts +0 -65
  382. package/api/stellar-solutions/payment/index.js +0 -230
  383. package/api/stellar-solutions/payment-mode/index.d.ts +0 -53
  384. package/api/stellar-solutions/payment-mode/index.js +0 -191
  385. package/api/stellar-solutions/preference/index.d.ts +0 -25
  386. package/api/stellar-solutions/preference/index.js +0 -114
  387. package/api/stellar-solutions/product/index.d.ts +0 -64
  388. package/api/stellar-solutions/product/index.js +0 -235
  389. package/api/stellar-solutions/product-category/index.d.ts +0 -51
  390. package/api/stellar-solutions/product-category/index.js +0 -212
  391. package/api/stellar-solutions/profile/index.d.ts +0 -78
  392. package/api/stellar-solutions/profile/index.js +0 -234
  393. package/api/stellar-solutions/quote-invoice/index.d.ts +0 -97
  394. package/api/stellar-solutions/quote-invoice/index.js +0 -369
  395. package/api/stellar-solutions/quote-invoice-report/index.d.ts +0 -15
  396. package/api/stellar-solutions/quote-invoice-report/index.js +0 -74
  397. package/api/stellar-solutions/tax/index.d.ts +0 -55
  398. package/api/stellar-solutions/tax/index.js +0 -224
  399. package/api/stellar-solutions/types/common.js +0 -22
  400. package/api/stellar-solutions/types/erp.js +0 -73
  401. package/api/stellar-solutions/types/index.d.ts +0 -3
  402. package/api/stellar-solutions/types/index.js +0 -19
  403. package/api/stellar-solutions/types/pos.js +0 -61
  404. package/constants/index.d.ts +0 -12
  405. package/constants/index.js +0 -28
  406. package/factory/index.d.ts +0 -2
  407. package/factory/index.js +0 -18
  408. package/general/index.d.ts +0 -95
  409. package/general/index.js +0 -111
  410. package/index.d.ts +0 -28
  411. package/index.js +0 -44
  412. package/local-storage/index.d.ts +0 -4
  413. package/local-storage/index.js +0 -20
  414. package/setupTests.d.ts +0 -1
  415. package/setupTests.js +0 -52
  416. package/storybook/index.d.ts +0 -17
  417. package/storybook/index.js +0 -33
@@ -1,39 +1 @@
1
- "use strict";
2
- /**
3
- * Generate schema.org `Organization` JSON-LD.
4
- *
5
- * This helper builds a minimal `Organization` object including `address`,
6
- * `logo`, `image`, `email`, and `telephone`. The input shape is an
7
- * application-specific `Organization` interface defined below — the
8
- * function emits only the provided properties to keep the result
9
- * compact.
10
- *
11
- * @param options - Organization properties (see interface below)
12
- * @returns A JSON-LD compatible `Organization` object
13
- */
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.generateOrganizationSchema = void 0;
16
- var generateOrganizationSchema = function (_a) {
17
- var addressCountry = _a.addressCountry, addressLocality = _a.addressLocality, addressRegion = _a.addressRegion, appName = _a.appName, baseUrl = _a.baseUrl, description = _a.description, email = _a.email, image = _a.image, logo = _a.logo, postalCode = _a.postalCode, sameAsArr = _a.sameAsArr, streetAddress = _a.streetAddress, telephone = _a.telephone;
18
- return {
19
- '@context': 'https://schema.org',
20
- '@type': 'Organization',
21
- image: "".concat(image),
22
- url: "".concat(baseUrl),
23
- sameAs: sameAsArr,
24
- logo: "".concat(logo),
25
- name: "".concat(appName),
26
- description: "".concat(description),
27
- email: "".concat(email),
28
- telephone: "".concat(telephone),
29
- address: {
30
- '@type': 'PostalAddress',
31
- streetAddress: "".concat(streetAddress),
32
- addressLocality: "".concat(addressLocality),
33
- addressCountry: "".concat(addressCountry),
34
- addressRegion: "".concat(addressRegion),
35
- postalCode: "".concat(postalCode),
36
- },
37
- };
38
- };
39
- exports.generateOrganizationSchema = generateOrganizationSchema;
1
+ var n=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var h=(e,s)=>{for(var t in s)n(e,t,{get:s[t],enumerable:!0})},u=(e,s,t,a)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of y(s))!A.call(e,r)&&r!==t&&n(e,r,{get:()=>s[r],enumerable:!(a=c(s,r))||a.enumerable});return e};var z=e=>u(n({},"__esModule",{value:!0}),e);var O={};h(O,{generateOrganizationSchema:()=>C});module.exports=z(O);const C=({addressCountry:e,addressLocality:s,addressRegion:t,appName:a,baseUrl:r,description:i,email:o,image:g,logo:d,postalCode:l,sameAsArr:p,streetAddress:$,telephone:m})=>({"@context":"https://schema.org","@type":"Organization",image:`${g}`,url:`${r}`,sameAs:p,logo:`${d}`,name:`${a}`,description:`${i}`,email:`${o}`,telephone:`${m}`,address:{"@type":"PostalAddress",streetAddress:`${$}`,addressLocality:`${s}`,addressCountry:`${e}`,addressRegion:`${t}`,postalCode:`${l}`}});0&&(module.exports={generateOrganizationSchema});
@@ -32,5 +32,6 @@ interface ProfilePageOptions {
32
32
  author?: PersonRef | OrgRef;
33
33
  about?: string[];
34
34
  }
35
- export declare const generateProfilePageSchema: ({ name, headline, url, description, mainEntity, author, about, }: ProfilePageOptions) => any;
36
- export {};
35
+ declare const generateProfilePageSchema: ({ name, headline, url, description, mainEntity, author, about, }: ProfilePageOptions) => any;
36
+
37
+ export { generateProfilePageSchema };
@@ -1,82 +1 @@
1
- "use strict";
2
- /**
3
- * Generate schema.org `ProfilePage` JSON-LD describing a person or profile.
4
- *
5
- * Accepts a `mainEntity` person object along with optional author or
6
- * organization metadata. Images are normalized to `ImageObject` entries.
7
- *
8
- * See `ProfilePageOptions` and `PersonRef` for the input shape.
9
- * @returns A JSON-LD compatible `ProfilePage` object
10
- */
11
- var __assign = (this && this.__assign) || function () {
12
- __assign = Object.assign || function(t) {
13
- for (var s, i = 1, n = arguments.length; i < n; i++) {
14
- s = arguments[i];
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
16
- t[p] = s[p];
17
- }
18
- return t;
19
- };
20
- return __assign.apply(this, arguments);
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.generateProfilePageSchema = void 0;
24
- var formatImage = function (image) {
25
- if (!image)
26
- return undefined;
27
- if (typeof image === 'string')
28
- return image;
29
- return __assign(__assign({ '@type': 'ImageObject', url: image.url }, (image.width && { width: image.width })), (image.height && { height: image.height }));
30
- };
31
- var formatPerson = function (p) {
32
- if (!p)
33
- return undefined;
34
- var out = { '@type': 'Person', name: p.name };
35
- if (p.url)
36
- out.url = p.url;
37
- if (p.sameAs)
38
- out.sameAs = p.sameAs;
39
- if (p.jobTitle)
40
- out.jobTitle = p.jobTitle;
41
- var img = formatImage(p.image);
42
- if (img)
43
- out.image = img;
44
- return out;
45
- };
46
- var formatAuthor = function (a) {
47
- if (!a)
48
- return undefined;
49
- var isPerson = a.jobTitle !== undefined ||
50
- a.sameAs !== undefined;
51
- if (isPerson)
52
- return formatPerson(a);
53
- var out = { '@type': 'Organization', name: a.name };
54
- if (a.url)
55
- out.url = a.url;
56
- return out;
57
- };
58
- var generateProfilePageSchema = function (_a) {
59
- var name = _a.name, headline = _a.headline, url = _a.url, description = _a.description, mainEntity = _a.mainEntity, author = _a.author, about = _a.about;
60
- var schema = {
61
- '@context': 'https://schema.org',
62
- '@type': 'ProfilePage',
63
- };
64
- if (name)
65
- schema.name = name;
66
- if (headline)
67
- schema.headline = headline;
68
- if (url)
69
- schema.mainEntityOfPage = { '@type': 'WebPage', '@id': url };
70
- if (description)
71
- schema.description = description;
72
- var me = formatPerson(mainEntity);
73
- if (me)
74
- schema.mainEntity = me;
75
- var a = formatAuthor(author);
76
- if (a)
77
- schema.author = a;
78
- if (about && about.length > 0)
79
- schema.about = about;
80
- return schema;
81
- };
82
- exports.generateProfilePageSchema = generateProfilePageSchema;
1
+ var a=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var h=(e,n)=>{for(var t in n)a(e,t,{get:n[t],enumerable:!0})},d=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of P(n))!c.call(e,i)&&i!==t&&a(e,i,{get:()=>n[i],enumerable:!(s=l(n,i))||s.enumerable});return e};var R=e=>d(a({},"__esModule",{value:!0}),e);var j={};h(j,{generateProfilePageSchema:()=>b});module.exports=R(j);const y=e=>{if(e)return typeof e=="string"?e:{"@type":"ImageObject",url:e.url,...e.width&&{width:e.width},...e.height&&{height:e.height}}},u=e=>{if(!e)return;const n={"@type":"Person",name:e.name};e.url&&(n.url=e.url),e.sameAs&&(n.sameAs=e.sameAs),e.jobTitle&&(n.jobTitle=e.jobTitle);const t=y(e.image);return t&&(n.image=t),n},O=e=>{if(!e)return;if(e.jobTitle!==void 0||e.sameAs!==void 0)return u(e);const t={"@type":"Organization",name:e.name};return e.url&&(t.url=e.url),t},b=({name:e,headline:n,url:t,description:s,mainEntity:i,author:m,about:f})=>{const r={"@context":"https://schema.org","@type":"ProfilePage"};e&&(r.name=e),n&&(r.headline=n),t&&(r.mainEntityOfPage={"@type":"WebPage","@id":t}),s&&(r.description=s);const o=u(i);o&&(r.mainEntity=o);const g=O(m);return g&&(r.author=g),f&&f.length>0&&(r.about=f),r};0&&(module.exports={generateProfilePageSchema});
@@ -29,5 +29,6 @@ interface QAPageOptions {
29
29
  headline?: string;
30
30
  mainEntity: QuestionItem;
31
31
  }
32
- export declare const generateQAPageSchema: ({ headline, mainEntity, }: QAPageOptions) => any;
33
- export {};
32
+ declare const generateQAPageSchema: ({ headline, mainEntity, }: QAPageOptions) => any;
33
+
34
+ export { generateQAPageSchema };
@@ -1,67 +1 @@
1
- "use strict";
2
- /**
3
- * Generate schema.org `QAPage` JSON-LD (Question + Answers).
4
- *
5
- * The helper formats a single `Question` and its `Answer` entries,
6
- * including author references and date fields. Use `acceptedAnswer` and
7
- * `suggestedAnswer` to provide preferred or additional answers.
8
- *
9
- * See `QAPageOptions` and related types for the input contract.
10
- * @returns A JSON-LD compatible `QAPage` object
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.generateQAPageSchema = void 0;
14
- var formatPerson = function (p) {
15
- if (!p)
16
- return undefined;
17
- if (typeof p === 'string')
18
- return { '@type': 'Person', name: p };
19
- var out = { '@type': 'Person', name: p.name };
20
- if (p.url)
21
- out.url = p.url;
22
- return out;
23
- };
24
- var formatAnswer = function (a) {
25
- var out = { '@type': 'Answer' };
26
- if (a.text)
27
- out.text = a.text;
28
- if (a.author)
29
- out.author = formatPerson(a.author);
30
- if (a.datePublished)
31
- out.datePublished = a.datePublished;
32
- return out;
33
- };
34
- var generateQAPageSchema = function (_a) {
35
- var headline = _a.headline, mainEntity = _a.mainEntity;
36
- var question = {
37
- '@type': 'Question',
38
- name: mainEntity.name,
39
- };
40
- if (mainEntity.text)
41
- question.text = mainEntity.text;
42
- if (mainEntity.author)
43
- question.author = formatPerson(mainEntity.author);
44
- if (mainEntity.datePublished)
45
- question.datePublished = mainEntity.datePublished;
46
- if (mainEntity.answers && mainEntity.answers.length > 0) {
47
- question.answerCount = mainEntity.answers.length;
48
- question.acceptedAnswer = mainEntity.acceptedAnswer
49
- ? formatAnswer(mainEntity.acceptedAnswer)
50
- : undefined;
51
- question.suggestedAnswer = mainEntity.answers
52
- .filter(function (a) {
53
- return !mainEntity.acceptedAnswer ||
54
- a.text !== mainEntity.acceptedAnswer.text;
55
- })
56
- .map(function (a) { return formatAnswer(a); });
57
- }
58
- var schema = {
59
- '@context': 'https://schema.org',
60
- '@type': 'QAPage',
61
- mainEntity: question,
62
- };
63
- if (headline)
64
- schema.headline = headline;
65
- return schema;
66
- };
67
- exports.generateQAPageSchema = generateQAPageSchema;
1
+ var a=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var h=(t,e)=>{for(var s in e)a(t,s,{get:e[s],enumerable:!0})},g=(t,e,s,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of c(e))!f.call(t,r)&&r!==s&&a(t,r,{get:()=>e[r],enumerable:!(n=d(e,r))||n.enumerable});return t};var i=t=>g(a({},"__esModule",{value:!0}),t);var P={};h(P,{generateQAPageSchema:()=>w});module.exports=i(P);const o=t=>{if(!t)return;if(typeof t=="string")return{"@type":"Person",name:t};const e={"@type":"Person",name:t.name};return t.url&&(e.url=t.url),e},u=t=>{const e={"@type":"Answer"};return t.text&&(e.text=t.text),t.author&&(e.author=o(t.author)),t.datePublished&&(e.datePublished=t.datePublished),e},w=({headline:t,mainEntity:e})=>{const s={"@type":"Question",name:e.name};e.text&&(s.text=e.text),e.author&&(s.author=o(e.author)),e.datePublished&&(s.datePublished=e.datePublished),e.answers&&e.answers.length>0&&(s.answerCount=e.answers.length,s.acceptedAnswer=e.acceptedAnswer?u(e.acceptedAnswer):void 0,s.suggestedAnswer=e.answers.filter(r=>!e.acceptedAnswer||r.text!==e.acceptedAnswer.text).map(r=>u(r)));const n={"@context":"https://schema.org","@type":"QAPage",mainEntity:s};return t&&(n.headline=t),n};0&&(module.exports={generateQAPageSchema});
@@ -44,5 +44,6 @@ interface RecipeOptions {
44
44
  recipeInstructions?: HowToStep[];
45
45
  aggregateRating?: AggregateRating;
46
46
  }
47
- export declare const generateRecipeSchema: ({ name, description, image, author, recipeYield, prepTime, cookTime, totalTime, recipeCategory, recipeCuisine, keywords, recipeIngredient, recipeInstructions, aggregateRating, }: RecipeOptions) => any;
48
- export {};
47
+ declare const generateRecipeSchema: ({ name, description, image, author, recipeYield, prepTime, cookTime, totalTime, recipeCategory, recipeCuisine, keywords, recipeIngredient, recipeInstructions, aggregateRating, }: RecipeOptions) => any;
48
+
49
+ export { generateRecipeSchema };
@@ -1,104 +1 @@
1
- "use strict";
2
- /**
3
- * Generate schema.org `Recipe` JSON-LD, with support for `HowToStep`
4
- * instructions and `ItemList` ingredients.
5
- *
6
- * Accepts recipe metadata (times, yields, cuisine, ingredients, steps)
7
- * and will format steps as `HowToStep` objects and images as `ImageObject`
8
- * entries when provided.
9
- *
10
- * See `RecipeOptions` for the accepted input shape.
11
- * @returns A JSON-LD compatible `Recipe` object
12
- */
13
- var __assign = (this && this.__assign) || function () {
14
- __assign = Object.assign || function(t) {
15
- for (var s, i = 1, n = arguments.length; i < n; i++) {
16
- s = arguments[i];
17
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
18
- t[p] = s[p];
19
- }
20
- return t;
21
- };
22
- return __assign.apply(this, arguments);
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.generateRecipeSchema = void 0;
26
- var formatImage = function (image) {
27
- if (!image)
28
- return undefined;
29
- if (typeof image === 'string')
30
- return image;
31
- return __assign(__assign({ '@type': 'ImageObject', url: image.url }, (image.width && { width: image.width })), (image.height && { height: image.height }));
32
- };
33
- var formatPerson = function (p) {
34
- if (!p)
35
- return undefined;
36
- if (typeof p === 'string')
37
- return { '@type': 'Person', name: p };
38
- var out = { '@type': 'Person', name: p.name };
39
- if (p.url)
40
- out.url = p.url;
41
- return out;
42
- };
43
- var formatHowToStep = function (s) {
44
- var out = { '@type': 'HowToStep' };
45
- if (s.name)
46
- out.name = s.name;
47
- if (s.text)
48
- out.text = s.text;
49
- if (s.url)
50
- out.url = s.url;
51
- var img = formatImage(s.image);
52
- if (img)
53
- out.image = img;
54
- return out;
55
- };
56
- var generateRecipeSchema = function (_a) {
57
- var name = _a.name, description = _a.description, image = _a.image, author = _a.author, recipeYield = _a.recipeYield, prepTime = _a.prepTime, cookTime = _a.cookTime, totalTime = _a.totalTime, recipeCategory = _a.recipeCategory, recipeCuisine = _a.recipeCuisine, keywords = _a.keywords, recipeIngredient = _a.recipeIngredient, recipeInstructions = _a.recipeInstructions, aggregateRating = _a.aggregateRating;
58
- var schema = {
59
- '@context': 'https://schema.org',
60
- '@type': 'Recipe',
61
- name: name,
62
- };
63
- if (description)
64
- schema.description = description;
65
- var img = formatImage(image);
66
- if (img)
67
- schema.image = img;
68
- var a = formatPerson(author);
69
- if (a)
70
- schema.author = a;
71
- if (recipeYield)
72
- schema.recipeYield = recipeYield;
73
- if (prepTime)
74
- schema.prepTime = prepTime;
75
- if (cookTime)
76
- schema.cookTime = cookTime;
77
- if (totalTime)
78
- schema.totalTime = totalTime;
79
- if (recipeCategory)
80
- schema.recipeCategory = Array.isArray(recipeCategory)
81
- ? recipeCategory.join(', ')
82
- : recipeCategory;
83
- if (recipeCuisine)
84
- schema.recipeCuisine = Array.isArray(recipeCuisine)
85
- ? recipeCuisine.join(', ')
86
- : recipeCuisine;
87
- if (keywords)
88
- schema.keywords = Array.isArray(keywords) ? keywords.join(', ') : keywords;
89
- if (recipeIngredient && recipeIngredient.length > 0)
90
- schema.recipeIngredient = recipeIngredient;
91
- if (recipeInstructions && recipeInstructions.length > 0) {
92
- schema.recipeInstructions = recipeInstructions.map(formatHowToStep);
93
- }
94
- if (aggregateRating) {
95
- schema.aggregateRating = {
96
- '@type': 'AggregateRating',
97
- ratingValue: aggregateRating.ratingValue,
98
- };
99
- if (aggregateRating.reviewCount != null)
100
- schema.aggregateRating.reviewCount = aggregateRating.reviewCount;
101
- }
102
- return schema;
103
- };
104
- exports.generateRecipeSchema = generateRecipeSchema;
1
+ var c=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var x=(t,e)=>{for(var r in e)c(t,r,{get:e[r],enumerable:!0})},I=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of A(e))!T.call(t,i)&&i!==r&&c(t,i,{get:()=>e[i],enumerable:!(a=d(e,i))||a.enumerable});return t};var P=t=>I(c({},"__esModule",{value:!0}),t);var j={};x(j,{generateRecipeSchema:()=>H});module.exports=P(j);const w=t=>{if(t)return typeof t=="string"?t:{"@type":"ImageObject",url:t.url,...t.width&&{width:t.width},...t.height&&{height:t.height}}},S=t=>{if(!t)return;if(typeof t=="string")return{"@type":"Person",name:t};const e={"@type":"Person",name:t.name};return t.url&&(e.url=t.url),e},b=t=>{const e={"@type":"HowToStep"};t.name&&(e.name=t.name),t.text&&(e.text=t.text),t.url&&(e.url=t.url);const r=w(t.image);return r&&(e.image=r),e},H=({name:t,description:e,image:r,author:a,recipeYield:i,prepTime:h,cookTime:l,totalTime:p,recipeCategory:g,recipeCuisine:o,keywords:s,recipeIngredient:u,recipeInstructions:m,aggregateRating:f})=>{const n={"@context":"https://schema.org","@type":"Recipe",name:t};e&&(n.description=e);const y=w(r);y&&(n.image=y);const R=S(a);return R&&(n.author=R),i&&(n.recipeYield=i),h&&(n.prepTime=h),l&&(n.cookTime=l),p&&(n.totalTime=p),g&&(n.recipeCategory=Array.isArray(g)?g.join(", "):g),o&&(n.recipeCuisine=Array.isArray(o)?o.join(", "):o),s&&(n.keywords=Array.isArray(s)?s.join(", "):s),u&&u.length>0&&(n.recipeIngredient=u),m&&m.length>0&&(n.recipeInstructions=m.map(b)),f&&(n.aggregateRating={"@type":"AggregateRating",ratingValue:f.ratingValue},f.reviewCount!=null&&(n.aggregateRating.reviewCount=f.reviewCount)),n};0&&(module.exports={generateRecipeSchema});
@@ -1,5 +1,11 @@
1
1
  interface Params {
2
2
  refLength: number;
3
3
  }
4
- export declare const generateRef: ({ refLength }: Params) => string;
5
- export {};
4
+ /**
5
+ * Generates a short reference code from a UUID slice and the current 2-digit year.
6
+ * @param params.refLength - Length of the UUID slice (default 5).
7
+ * @returns The generated reference string.
8
+ */
9
+ declare const generateRef: ({ refLength }: Params) => string;
10
+
11
+ export { generateRef };
@@ -1,12 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateRef = void 0;
4
- var uuid_1 = require("uuid");
5
- var constants_1 = require("../constants");
6
- var generateRef = function (_a) {
7
- var _b = _a.refLength, refLength = _b === void 0 ? 5 : _b;
8
- var ref = (0, uuid_1.v4)().toUpperCase().slice(0, refLength);
9
- var currentYear = new Date().getFullYear().toString().slice(-2);
10
- return "".concat(ref).concat(constants_1.VALUE_DELIMITER.SLASH).concat(currentYear);
11
- };
12
- exports.generateRef = generateRef;
1
+ var a=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var u=(r,e)=>{for(var t in e)a(r,t,{get:e[t],enumerable:!0})},g=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of m(e))!f.call(r,n)&&n!==t&&a(r,n,{get:()=>e[n],enumerable:!(o=c(e,n))||o.enumerable});return r};var p=r=>g(a({},"__esModule",{value:!0}),r);var L={};u(L,{generateRef:()=>l});module.exports=p(L);var s=require("uuid"),i=require("../constants/select-value-delimiter");const l=({refLength:r=5})=>{const e=(0,s.v4)().toUpperCase().slice(0,r),t=new Date().getFullYear().toString().slice(-2);return`${e}${i.VALUE_DELIMITER.SLASH}${t}`};0&&(module.exports={generateRef});
@@ -47,5 +47,6 @@ interface ReviewSnippetOptions {
47
47
  reviews?: ReviewItem[];
48
48
  aggregateRating?: AggregateRatingOptions;
49
49
  }
50
- export declare const generateReviewSnippetSchema: ({ itemReviewed, reviews, aggregateRating, }: ReviewSnippetOptions) => any;
51
- export default generateReviewSnippetSchema;
50
+ declare const generateReviewSnippetSchema: ({ itemReviewed, reviews, aggregateRating, }: ReviewSnippetOptions) => any;
51
+
52
+ export { generateReviewSnippetSchema as default, generateReviewSnippetSchema };
@@ -1,137 +1 @@
1
- "use strict";
2
- /**
3
- * Generate structured data for Review snippets and `AggregateRating`.
4
- *
5
- * Accepts a compact `ReviewSnippetOptions` object and returns a plain object
6
- * compatible with schema.org JSON-LD for embedding in a page. The function
7
- * supports formatting `Person` and `Organization` references and can produce
8
- * an `AggregateRating` object either from supplied options or derived from
9
- * reviews.
10
- *
11
- * See the TypeScript interfaces below for the exact input shape.
12
- * @returns A JSON-LD compatible Review / ReviewSnippet object
13
- */
14
- var __assign = (this && this.__assign) || function () {
15
- __assign = Object.assign || function(t) {
16
- for (var s, i = 1, n = arguments.length; i < n; i++) {
17
- s = arguments[i];
18
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
19
- t[p] = s[p];
20
- }
21
- return t;
22
- };
23
- return __assign.apply(this, arguments);
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.generateReviewSnippetSchema = void 0;
27
- var formatPerson = function (p) {
28
- if (!p)
29
- return undefined;
30
- if (typeof p === 'string')
31
- return { '@type': 'Person', name: p };
32
- var out = { '@type': 'Person', name: p.name };
33
- if (p.url)
34
- out.url = p.url;
35
- return out;
36
- };
37
- var formatOrganization = function (o) {
38
- if (!o)
39
- return undefined;
40
- if (typeof o === 'string')
41
- return { '@type': 'Organization', name: o };
42
- var out = { '@type': 'Organization', name: o.name };
43
- if (o.url)
44
- out.url = o.url;
45
- return out;
46
- };
47
- var formatReview = function (r) {
48
- var out = { '@type': 'Review' };
49
- if (r.author)
50
- out.author = formatPerson(r.author);
51
- if (r.datePublished)
52
- out.datePublished = r.datePublished;
53
- if (r.reviewBody)
54
- out.reviewBody = r.reviewBody;
55
- if (r.name)
56
- out.name = r.name;
57
- if (r.url)
58
- out.url = r.url;
59
- if (r.publisher)
60
- out.publisher = formatOrganization(r.publisher);
61
- if (r.reviewRating) {
62
- out.reviewRating = __assign(__assign({ '@type': 'Rating', ratingValue: r.reviewRating.ratingValue }, (r.reviewRating.bestRating != null && {
63
- bestRating: r.reviewRating.bestRating,
64
- })), (r.reviewRating.worstRating != null && {
65
- worstRating: r.reviewRating.worstRating,
66
- }));
67
- }
68
- return out;
69
- };
70
- var generateReviewSnippetSchema = function (_a) {
71
- var itemReviewed = _a.itemReviewed, reviews = _a.reviews, aggregateRating = _a.aggregateRating;
72
- // If an itemReviewed is provided we return that item with nested review(s)
73
- var hasItem = !!itemReviewed;
74
- // Map reviews if present
75
- var mappedReviews = reviews && reviews.length > 0 ? reviews.map(formatReview) : undefined;
76
- // Compute aggregate rating from provided aggregateRating or from reviews
77
- var agg = undefined;
78
- if (aggregateRating) {
79
- agg = __assign(__assign(__assign(__assign({ '@type': 'AggregateRating', ratingValue: aggregateRating.ratingValue }, (aggregateRating.reviewCount != null && {
80
- reviewCount: aggregateRating.reviewCount,
81
- })), (aggregateRating.ratingCount != null && {
82
- ratingCount: aggregateRating.ratingCount,
83
- })), (aggregateRating.bestRating != null && {
84
- bestRating: aggregateRating.bestRating,
85
- })), (aggregateRating.worstRating != null && {
86
- worstRating: aggregateRating.worstRating,
87
- }));
88
- }
89
- else if (reviews && reviews.length > 0) {
90
- var ratings = reviews
91
- .map(function (r) { return (r.reviewRating ? Number(r.reviewRating.ratingValue) : NaN); })
92
- .filter(function (n) { return !Number.isNaN(n); });
93
- if (ratings.length > 0) {
94
- var sum = ratings.reduce(function (a, b) { return a + b; }, 0);
95
- agg = {
96
- '@type': 'AggregateRating',
97
- ratingValue: sum / ratings.length,
98
- reviewCount: reviews.length,
99
- ratingCount: ratings.length,
100
- };
101
- }
102
- }
103
- if (hasItem) {
104
- var item = {
105
- '@context': 'https://schema.org',
106
- '@type': typeof itemReviewed === 'string'
107
- ? 'Thing'
108
- : (itemReviewed === null || itemReviewed === void 0 ? void 0 : itemReviewed['@type']) || 'Thing',
109
- name: typeof itemReviewed === 'string'
110
- ? itemReviewed
111
- : itemReviewed.name,
112
- };
113
- if (mappedReviews)
114
- item.review = mappedReviews;
115
- if (agg)
116
- item.aggregateRating = agg;
117
- return item;
118
- }
119
- // No itemReviewed -> if single review return a Review object, else return an array wrapper
120
- if (mappedReviews && mappedReviews.length === 1) {
121
- var r = mappedReviews[0];
122
- var schema_1 = __assign({ '@context': 'https://schema.org' }, r);
123
- if (agg)
124
- schema_1.aggregateRating = agg;
125
- return schema_1;
126
- }
127
- var schema = {
128
- '@context': 'https://schema.org',
129
- };
130
- if (mappedReviews)
131
- schema.review = mappedReviews;
132
- if (agg)
133
- schema.aggregateRating = agg;
134
- return schema;
135
- };
136
- exports.generateReviewSnippetSchema = generateReviewSnippetSchema;
137
- exports.default = exports.generateReviewSnippetSchema;
1
+ var o=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var h=(t,n)=>{for(var e in n)o(t,e,{get:n[e],enumerable:!0})},w=(t,n,e,g)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of p(n))!c.call(t,i)&&i!==e&&o(t,i,{get:()=>n[i],enumerable:!(g=R(n,i))||g.enumerable});return t};var y=t=>w(o({},"__esModule",{value:!0}),t);var O={};h(O,{default:()=>C,generateReviewSnippetSchema:()=>l});module.exports=y(O);const 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},v=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},d=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.name&&(n.name=t.name),t.url&&(n.url=t.url),t.publisher&&(n.publisher=v(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},l=({itemReviewed:t,reviews:n,aggregateRating:e})=>{const g=!!t,i=n&&n.length>0?n.map(d):void 0;let a;if(e)a={"@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 r=n.map(s=>s.reviewRating?Number(s.reviewRating.ratingValue):NaN).filter(s=>!Number.isNaN(s));r.length>0&&(a={"@type":"AggregateRating",ratingValue:r.reduce((f,m)=>f+m,0)/r.length,reviewCount:n.length,ratingCount:r.length})}if(g){const r={"@context":"https://schema.org","@type":typeof t=="string"?"Thing":t?.["@type"]||"Thing",name:typeof t=="string"?t:t.name};return i&&(r.review=i),a&&(r.aggregateRating=a),r}if(i&&i.length===1){const s={"@context":"https://schema.org",...i[0]};return a&&(s.aggregateRating=a),s}const u={"@context":"https://schema.org"};return i&&(u.review=i),a&&(u.aggregateRating=a),u};var C=l;0&&(module.exports={generateReviewSnippetSchema});
@@ -33,5 +33,6 @@ interface LoyaltyOptions {
33
33
  benefits?: string[];
34
34
  offers?: LoyaltyOffer[];
35
35
  }
36
- export declare const generateShoppingLoyaltyProgramSchema: ({ programName, programUrl, programId, member, membershipNumber, enrollmentDate, pointsBalance, pointsEarned, benefits, offers, }: LoyaltyOptions) => any;
37
- export {};
36
+ declare const generateShoppingLoyaltyProgramSchema: ({ programName, programUrl, programId, member, membershipNumber, enrollmentDate, pointsBalance, pointsEarned, benefits, offers, }: LoyaltyOptions) => any;
37
+
38
+ export { generateShoppingLoyaltyProgramSchema };
@@ -1,59 +1 @@
1
- "use strict";
2
- /**
3
- * Generate schema.org structured data for a loyalty or membership program
4
- * (`ProgramMembership`).
5
- *
6
- * The helper formats membership details, member references, points and
7
- * optional offers into a `ProgramMembership` object. Only supplied fields
8
- * are emitted.
9
- *
10
- * See `LoyaltyOptions` for the accepted input properties.
11
- * @returns A JSON-LD compatible `ProgramMembership` object
12
- */
13
- var __assign = (this && this.__assign) || function () {
14
- __assign = Object.assign || function(t) {
15
- for (var s, i = 1, n = arguments.length; i < n; i++) {
16
- s = arguments[i];
17
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
18
- t[p] = s[p];
19
- }
20
- return t;
21
- };
22
- return __assign.apply(this, arguments);
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.generateShoppingLoyaltyProgramSchema = void 0;
26
- var formatAgent = function (a) {
27
- if (!a)
28
- return undefined;
29
- return __assign({ name: a.name }, (a.url && { url: a.url }));
30
- };
31
- var generateShoppingLoyaltyProgramSchema = function (_a) {
32
- var programName = _a.programName, programUrl = _a.programUrl, programId = _a.programId, member = _a.member, membershipNumber = _a.membershipNumber, enrollmentDate = _a.enrollmentDate, pointsBalance = _a.pointsBalance, pointsEarned = _a.pointsEarned, benefits = _a.benefits, offers = _a.offers;
33
- var schema = {
34
- '@context': 'https://schema.org',
35
- '@type': 'ProgramMembership',
36
- programName: programName,
37
- };
38
- if (programUrl)
39
- schema.url = programUrl;
40
- if (programId)
41
- schema['@id'] = programId;
42
- if (member)
43
- schema.member = formatAgent(member);
44
- if (membershipNumber)
45
- schema.membershipNumber = membershipNumber;
46
- if (enrollmentDate)
47
- schema.enrollmentDate = enrollmentDate;
48
- if (typeof pointsBalance === 'number')
49
- schema.pointsBalance = pointsBalance;
50
- if (typeof pointsEarned === 'number')
51
- schema.pointsEarned = pointsEarned;
52
- if (benefits && benefits.length > 0)
53
- schema.benefits = benefits;
54
- if (offers && offers.length > 0) {
55
- schema.offers = offers.map(function (o) { return (__assign(__assign({ '@type': 'Offer' }, (o.description && { description: o.description })), (o.url && { url: o.url }))); });
56
- }
57
- return schema;
58
- };
59
- exports.generateShoppingLoyaltyProgramSchema = generateShoppingLoyaltyProgramSchema;
1
+ var o=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var b=(e,r)=>{for(var i in r)o(e,i,{get:r[i],enumerable:!0})},h=(e,r,i,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of c(r))!y.call(e,t)&&t!==i&&o(e,t,{get:()=>r[t],enumerable:!(a=u(r,t))||a.enumerable});return e};var d=e=>h(o({},"__esModule",{value:!0}),e);var L={};b(L,{generateShoppingLoyaltyProgramSchema:()=>R});module.exports=d(L);const O=e=>{if(e)return{name:e.name,...e.url&&{url:e.url}}},R=({programName:e,programUrl:r,programId:i,member:a,membershipNumber:t,enrollmentDate:g,pointsBalance:l,pointsEarned:p,benefits:s,offers:m})=>{const n={"@context":"https://schema.org","@type":"ProgramMembership",programName:e};return r&&(n.url=r),i&&(n["@id"]=i),a&&(n.member=O(a)),t&&(n.membershipNumber=t),g&&(n.enrollmentDate=g),typeof l=="number"&&(n.pointsBalance=l),typeof p=="number"&&(n.pointsEarned=p),s&&s.length>0&&(n.benefits=s),m&&m.length>0&&(n.offers=m.map(f=>({"@type":"Offer",...f.description&&{description:f.description},...f.url&&{url:f.url}}))),n};0&&(module.exports={generateShoppingLoyaltyProgramSchema});
@@ -48,5 +48,6 @@ interface MerchantListingOptions {
48
48
  products: MerchantProduct[];
49
49
  skipInvalidCurrency?: boolean;
50
50
  }
51
- export declare const generateShoppingMerchantListingSchema: ({ merchant, name, url, products, skipInvalidCurrency, }: MerchantListingOptions) => any;
52
- export {};
51
+ declare const generateShoppingMerchantListingSchema: ({ merchant, name, url, products, skipInvalidCurrency, }: MerchantListingOptions) => any;
52
+
53
+ export { generateShoppingMerchantListingSchema };