@react-pakistan/util-functions 1.25.90 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (412) 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 +20 -18
  313. package/storybook/generate-sitemap.d.ts +3 -1
  314. package/storybook/generate-sitemap.js +17 -26
  315. package/storybook/preview.d.ts +4 -2
  316. package/storybook/preview.js +1 -62
  317. package/storybook/react-design-story-script.d.ts +3 -1
  318. package/storybook/react-design-story-script.js +5 -27
  319. package/storybook/react-emoji-collection.d.ts +3 -1
  320. package/storybook/react-emoji-collection.js +10 -55
  321. package/storybook/react-emoji-story-script.d.ts +3 -1
  322. package/storybook/react-emoji-story-script.js +5 -31
  323. package/storybook/react-emoji-story-template.d.ts +3 -1
  324. package/storybook/react-emoji-story-template.js +45 -15
  325. package/storybook/react-icon-collection.d.ts +3 -1
  326. package/storybook/react-icon-collection.js +10 -42
  327. package/storybook/react-icon-story-script.d.ts +3 -1
  328. package/storybook/react-icon-story-script.js +5 -27
  329. package/storybook/react-icon-story-template.d.ts +3 -1
  330. package/storybook/react-icon-story-template.js +45 -14
  331. package/storybook/react-logo-collection.d.ts +3 -1
  332. package/storybook/react-logo-collection.js +10 -42
  333. package/storybook/react-logo-story-script.d.ts +3 -1
  334. package/storybook/react-logo-story-script.js +5 -27
  335. package/storybook/react-logo-story-template.d.ts +3 -1
  336. package/storybook/react-logo-story-template.js +45 -14
  337. package/storybook/react-pakistan-theme.d.ts +3 -1
  338. package/storybook/react-pakistan-theme.js +1 -31
  339. package/storybook/responsive-args.d.ts +11 -10
  340. package/storybook/responsive-args.js +1 -19
  341. package/storybook/responsive-component.d.ts +4 -2
  342. package/storybook/responsive-component.js +37 -23
  343. package/storybook/responsive-screens.d.ts +3 -1
  344. package/storybook/responsive-screens.js +1 -109
  345. package/storybook/theme.d.ts +17 -15
  346. package/storybook/theme.js +1 -1022
  347. package/api/stellar-solutions/app-user/index.d.ts +0 -51
  348. package/api/stellar-solutions/app-user/index.js +0 -210
  349. package/api/stellar-solutions/bank/index.d.ts +0 -59
  350. package/api/stellar-solutions/bank/index.js +0 -210
  351. package/api/stellar-solutions/branch/index.d.ts +0 -58
  352. package/api/stellar-solutions/branch/index.js +0 -220
  353. package/api/stellar-solutions/company/index.d.ts +0 -57
  354. package/api/stellar-solutions/company/index.js +0 -218
  355. package/api/stellar-solutions/company-report/index.d.ts +0 -15
  356. package/api/stellar-solutions/company-report/index.js +0 -74
  357. package/api/stellar-solutions/constants.d.ts +0 -19
  358. package/api/stellar-solutions/constants.js +0 -22
  359. package/api/stellar-solutions/contact/index.d.ts +0 -56
  360. package/api/stellar-solutions/contact/index.js +0 -217
  361. package/api/stellar-solutions/currency/index.d.ts +0 -55
  362. package/api/stellar-solutions/currency/index.js +0 -212
  363. package/api/stellar-solutions/customer/index.d.ts +0 -68
  364. package/api/stellar-solutions/customer/index.js +0 -249
  365. package/api/stellar-solutions/expense/index.d.ts +0 -58
  366. package/api/stellar-solutions/expense/index.js +0 -229
  367. package/api/stellar-solutions/expense-category/index.d.ts +0 -53
  368. package/api/stellar-solutions/expense-category/index.js +0 -214
  369. package/api/stellar-solutions/lead/index.d.ts +0 -51
  370. package/api/stellar-solutions/lead/index.js +0 -206
  371. package/api/stellar-solutions/menu-order/index.d.ts +0 -53
  372. package/api/stellar-solutions/menu-order/index.js +0 -202
  373. package/api/stellar-solutions/payment/index.d.ts +0 -65
  374. package/api/stellar-solutions/payment/index.js +0 -230
  375. package/api/stellar-solutions/payment-mode/index.d.ts +0 -53
  376. package/api/stellar-solutions/payment-mode/index.js +0 -191
  377. package/api/stellar-solutions/preference/index.d.ts +0 -25
  378. package/api/stellar-solutions/preference/index.js +0 -114
  379. package/api/stellar-solutions/product/index.d.ts +0 -64
  380. package/api/stellar-solutions/product/index.js +0 -235
  381. package/api/stellar-solutions/product-category/index.d.ts +0 -51
  382. package/api/stellar-solutions/product-category/index.js +0 -212
  383. package/api/stellar-solutions/profile/index.d.ts +0 -78
  384. package/api/stellar-solutions/profile/index.js +0 -234
  385. package/api/stellar-solutions/quote-invoice/index.d.ts +0 -97
  386. package/api/stellar-solutions/quote-invoice/index.js +0 -369
  387. package/api/stellar-solutions/quote-invoice-report/index.d.ts +0 -15
  388. package/api/stellar-solutions/quote-invoice-report/index.js +0 -74
  389. package/api/stellar-solutions/tax/index.d.ts +0 -55
  390. package/api/stellar-solutions/tax/index.js +0 -224
  391. package/api/stellar-solutions/types/common.d.ts +0 -24
  392. package/api/stellar-solutions/types/common.js +0 -22
  393. package/api/stellar-solutions/types/erp.d.ts +0 -302
  394. package/api/stellar-solutions/types/erp.js +0 -73
  395. package/api/stellar-solutions/types/index.d.ts +0 -3
  396. package/api/stellar-solutions/types/index.js +0 -19
  397. package/api/stellar-solutions/types/pos.d.ts +0 -176
  398. package/api/stellar-solutions/types/pos.js +0 -61
  399. package/constants/index.d.ts +0 -12
  400. package/constants/index.js +0 -28
  401. package/factory/index.d.ts +0 -2
  402. package/factory/index.js +0 -18
  403. package/general/index.d.ts +0 -95
  404. package/general/index.js +0 -111
  405. package/index.d.ts +0 -28
  406. package/index.js +0 -44
  407. package/local-storage/index.d.ts +0 -4
  408. package/local-storage/index.js +0 -20
  409. package/setupTests.d.ts +0 -1
  410. package/setupTests.js +0 -52
  411. package/storybook/index.d.ts +0 -17
  412. package/storybook/index.js +0 -33
@@ -1,133 +1 @@
1
- "use strict";
2
- /**
3
- * Generate schema.org JSON-LD for a `CreativeWork` representing a
4
- * Subscription.
5
- *
6
- * Supports author/publisher, reviews and aggregate ratings, accessibility
7
- * flags and keywords. Only provided fields are emitted in the returned
8
- * object.
9
- *
10
- * See `SubscriptionOptions` for accepted properties.
11
- * @returns A JSON-LD compatible `CreativeWork` (Subscription) 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.generateSubscriptionSchema = 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 formatOrganization = function (o) {
44
- if (!o)
45
- return undefined;
46
- if (typeof o === 'string')
47
- return { '@type': 'Organization', name: o };
48
- var out = { '@type': 'Organization', name: o.name };
49
- if (o.url)
50
- out.url = o.url;
51
- return out;
52
- };
53
- var formatReview = function (r) {
54
- var out = { '@type': 'Review' };
55
- if (r.author)
56
- out.author = formatPerson(r.author);
57
- if (r.datePublished)
58
- out.datePublished = r.datePublished;
59
- if (r.reviewBody)
60
- out.reviewBody = r.reviewBody;
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 generateSubscriptionSchema = function (_a) {
71
- var name = _a.name, description = _a.description, image = _a.image, url = _a.url, author = _a.author, publisher = _a.publisher, datePublished = _a.datePublished, dateModified = _a.dateModified, isAccessibleForFree = _a.isAccessibleForFree, genre = _a.genre, keywords = _a.keywords, reviews = _a.reviews, aggregateRating = _a.aggregateRating;
72
- var schema = {
73
- '@context': 'https://schema.org',
74
- '@type': 'CreativeWork',
75
- name: name,
76
- };
77
- if (description)
78
- schema.description = description;
79
- var img = formatImage(image);
80
- if (img)
81
- schema.image = img;
82
- if (url)
83
- schema.url = url;
84
- var a = formatPerson(author);
85
- if (a)
86
- schema.author = a;
87
- var p = formatOrganization(publisher);
88
- if (p)
89
- schema.publisher = p;
90
- if (datePublished)
91
- schema.datePublished = datePublished;
92
- if (dateModified)
93
- schema.dateModified = dateModified;
94
- if (isAccessibleForFree != null)
95
- schema.isAccessibleForFree = isAccessibleForFree;
96
- if (genre)
97
- schema.genre = Array.isArray(genre) ? genre.join(', ') : genre;
98
- if (keywords)
99
- schema.keywords = Array.isArray(keywords) ? keywords.join(', ') : keywords;
100
- // Reviews -> map and compute aggregateRating if possible
101
- if (reviews && reviews.length > 0) {
102
- var mapped = reviews.map(formatReview);
103
- schema.review = mapped;
104
- if (!aggregateRating) {
105
- var ratings = reviews
106
- .map(function (r) { return (r.reviewRating ? Number(r.reviewRating.ratingValue) : NaN); })
107
- .filter(function (n) { return !Number.isNaN(n); });
108
- if (ratings.length > 0) {
109
- var sum = ratings.reduce(function (a, b) { return a + b; }, 0);
110
- schema.aggregateRating = {
111
- '@type': 'AggregateRating',
112
- ratingValue: sum / ratings.length,
113
- reviewCount: reviews.length,
114
- ratingCount: ratings.length,
115
- };
116
- }
117
- }
118
- }
119
- if (aggregateRating) {
120
- schema.aggregateRating = __assign(__assign(__assign(__assign({ '@type': 'AggregateRating', ratingValue: aggregateRating.ratingValue }, (aggregateRating.reviewCount != null && {
121
- reviewCount: aggregateRating.reviewCount,
122
- })), (aggregateRating.ratingCount != null && {
123
- ratingCount: aggregateRating.ratingCount,
124
- })), (aggregateRating.bestRating != null && {
125
- bestRating: aggregateRating.bestRating,
126
- })), (aggregateRating.worstRating != null && {
127
- worstRating: aggregateRating.worstRating,
128
- }));
129
- }
130
- return schema;
131
- };
132
- exports.generateSubscriptionSchema = generateSubscriptionSchema;
133
- exports.default = exports.generateSubscriptionSchema;
1
+ var R=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var N=(t,n)=>{for(var a in n)R(t,a,{get:n[a],enumerable:!0})},B=(t,n,a,u)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of A(n))!V.call(t,r)&&r!==a&&R(t,r,{get:()=>n[r],enumerable:!(u=I(n,r))||u.enumerable});return t};var S=t=>B(R({},"__esModule",{value:!0}),t);var M={};N(M,{default:()=>F,generateSubscriptionSchema:()=>p});module.exports=S(M);const j=t=>{if(t)return typeof t=="string"?t:{"@type":"ImageObject",url:t.url,...t.width&&{width:t.width},...t.height&&{height:t.height}}},y=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},x=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},z=t=>{const n={"@type":"Review"};return t.author&&(n.author=y(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},p=({name:t,description:n,image:a,url:u,author:r,publisher:v,datePublished:m,dateModified:c,isAccessibleForFree:h,genre:o,keywords:f,reviews:g,aggregateRating:i})=>{const e={"@context":"https://schema.org","@type":"CreativeWork",name:t};n&&(e.description=n);const b=j(a);b&&(e.image=b),u&&(e.url=u);const w=y(r);w&&(e.author=w);const d=x(v);if(d&&(e.publisher=d),m&&(e.datePublished=m),c&&(e.dateModified=c),h!=null&&(e.isAccessibleForFree=h),o&&(e.genre=Array.isArray(o)?o.join(", "):o),f&&(e.keywords=Array.isArray(f)?f.join(", "):f),g&&g.length>0){const P=g.map(z);if(e.review=P,!i){const l=g.map(s=>s.reviewRating?Number(s.reviewRating.ratingValue):NaN).filter(s=>!Number.isNaN(s));if(l.length>0){const s=l.reduce((C,O)=>C+O,0);e.aggregateRating={"@type":"AggregateRating",ratingValue:s/l.length,reviewCount:g.length,ratingCount:l.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 F=p;0&&(module.exports={generateSubscriptionSchema});
@@ -62,5 +62,6 @@ interface VacationRentalOptions {
62
62
  aggregateRating?: AggregateRatingOptions;
63
63
  keywords?: string | string[];
64
64
  }
65
- export declare const generateVacationRentalSchema: ({ name, description, image, url, address, geo, numberOfRooms, numberOfBeds, priceRange, host, reviews, aggregateRating, keywords, }: VacationRentalOptions) => any;
66
- export default generateVacationRentalSchema;
65
+ declare const generateVacationRentalSchema: ({ name, description, image, url, address, geo, numberOfRooms, numberOfBeds, priceRange, host, reviews, aggregateRating, keywords, }: VacationRentalOptions) => any;
66
+
67
+ export { generateVacationRentalSchema as default, generateVacationRentalSchema };
@@ -1,135 +1 @@
1
- "use strict";
2
- /**
3
- * Generate schema.org `VacationRental` JSON-LD including optional reviews
4
- * and `AggregateRating`.
5
- *
6
- * The function accepts address or geo information, images, host references,
7
- * and occupancy data. Reviews and aggregate ratings are formatted into
8
- * `Review` and `AggregateRating` objects when provided.
9
- *
10
- * See `VacationRentalOptions` below for supported inputs.
11
- * @returns A JSON-LD compatible `VacationRental` 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.generateVacationRentalSchema = void 0;
26
- var formatImage = function (image) {
27
- if (!image)
28
- return undefined;
29
- if (Array.isArray(image))
30
- return image.map(function (i) {
31
- return typeof i === 'string'
32
- ? i
33
- : __assign(__assign({ '@type': 'ImageObject', url: i.url }, (i.width && { width: i.width })), (i.height && { height: i.height }));
34
- });
35
- if (typeof image === 'string')
36
- return image;
37
- return __assign(__assign({ '@type': 'ImageObject', url: image.url }, (image.width && { width: image.width })), (image.height && { height: image.height }));
38
- };
39
- var formatPerson = function (p) {
40
- if (!p)
41
- return undefined;
42
- if (typeof p === 'string')
43
- return { '@type': 'Person', name: p };
44
- var out = { '@type': 'Person', name: p.name };
45
- if (p.url)
46
- out.url = p.url;
47
- return out;
48
- };
49
- var formatAddress = function (a) {
50
- if (!a)
51
- return undefined;
52
- if (typeof a === 'string')
53
- return a;
54
- return __assign(__assign(__assign(__assign(__assign({ '@type': 'PostalAddress' }, (a.streetAddress && { streetAddress: a.streetAddress })), (a.addressLocality && { addressLocality: a.addressLocality })), (a.addressRegion && { addressRegion: a.addressRegion })), (a.postalCode && { postalCode: a.postalCode })), (a.addressCountry && { addressCountry: a.addressCountry }));
55
- };
56
- var formatReview = function (r) {
57
- var out = { '@type': 'Review' };
58
- if (r.author)
59
- out.author = formatPerson(r.author);
60
- if (r.datePublished)
61
- out.datePublished = r.datePublished;
62
- if (r.reviewBody)
63
- out.reviewBody = r.reviewBody;
64
- if (r.reviewRating) {
65
- out.reviewRating = __assign(__assign({ '@type': 'Rating', ratingValue: r.reviewRating.ratingValue }, (r.reviewRating.bestRating != null && {
66
- bestRating: r.reviewRating.bestRating,
67
- })), (r.reviewRating.worstRating != null && {
68
- worstRating: r.reviewRating.worstRating,
69
- }));
70
- }
71
- return out;
72
- };
73
- var generateVacationRentalSchema = function (_a) {
74
- var name = _a.name, description = _a.description, image = _a.image, url = _a.url, address = _a.address, geo = _a.geo, numberOfRooms = _a.numberOfRooms, numberOfBeds = _a.numberOfBeds, priceRange = _a.priceRange, host = _a.host, reviews = _a.reviews, aggregateRating = _a.aggregateRating, keywords = _a.keywords;
75
- var schema = {
76
- '@context': 'https://schema.org',
77
- '@type': 'VacationRental',
78
- name: name,
79
- };
80
- if (description)
81
- schema.description = description;
82
- var img = formatImage(image);
83
- if (img)
84
- schema.image = img;
85
- if (url)
86
- schema.url = url;
87
- var a = formatAddress(address);
88
- if (a)
89
- schema.address = a;
90
- if (geo)
91
- schema.geo = __assign(__assign({ '@type': 'GeoCoordinates' }, (geo.latitude != null && { latitude: geo.latitude })), (geo.longitude != null && { longitude: geo.longitude }));
92
- if (numberOfRooms != null)
93
- schema.numberOfRooms = numberOfRooms;
94
- if (numberOfBeds != null)
95
- schema.numberOfBeds = numberOfBeds;
96
- if (priceRange)
97
- schema.priceRange = priceRange;
98
- var h = formatPerson(host);
99
- if (h)
100
- schema.host = h;
101
- if (keywords)
102
- schema.keywords = Array.isArray(keywords) ? keywords.join(', ') : keywords;
103
- if (reviews && reviews.length > 0) {
104
- var mapped = reviews.map(formatReview);
105
- schema.review = mapped;
106
- if (!aggregateRating) {
107
- var ratings = reviews
108
- .map(function (r) { return (r.reviewRating ? Number(r.reviewRating.ratingValue) : NaN); })
109
- .filter(function (n) { return !Number.isNaN(n); });
110
- if (ratings.length > 0) {
111
- var sum = ratings.reduce(function (x, y) { return x + y; }, 0);
112
- schema.aggregateRating = {
113
- '@type': 'AggregateRating',
114
- ratingValue: sum / ratings.length,
115
- reviewCount: reviews.length,
116
- ratingCount: ratings.length,
117
- };
118
- }
119
- }
120
- }
121
- if (aggregateRating) {
122
- schema.aggregateRating = __assign(__assign(__assign(__assign({ '@type': 'AggregateRating', ratingValue: aggregateRating.ratingValue }, (aggregateRating.reviewCount != null && {
123
- reviewCount: aggregateRating.reviewCount,
124
- })), (aggregateRating.ratingCount != null && {
125
- ratingCount: aggregateRating.ratingCount,
126
- })), (aggregateRating.bestRating != null && {
127
- bestRating: aggregateRating.bestRating,
128
- })), (aggregateRating.worstRating != null && {
129
- worstRating: aggregateRating.worstRating,
130
- }));
131
- }
132
- return schema;
133
- };
134
- exports.generateVacationRentalSchema = generateVacationRentalSchema;
135
- exports.default = exports.generateVacationRentalSchema;
1
+ var f=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var N=(t,e)=>{for(var s in e)f(t,s,{get:e[s],enumerable:!0})},B=(t,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of V(e))!O.call(t,i)&&i!==s&&f(t,i,{get:()=>e[i],enumerable:!(o=P(e,i))||o.enumerable});return t};var L=t=>B(f({},"__esModule",{value:!0}),t);var q={};N(q,{default:()=>S,generateVacationRentalSchema:()=>p});module.exports=L(q);const j=t=>{if(t)return Array.isArray(t)?t.map(e=>typeof e=="string"?e:{"@type":"ImageObject",url:e.url,...e.width&&{width:e.width},...e.height&&{height:e.height}}):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 e={"@type":"Person",name:t.name};return t.url&&(e.url=t.url),e},x=t=>{if(t)return typeof t=="string"?t:{"@type":"PostalAddress",...t.streetAddress&&{streetAddress:t.streetAddress},...t.addressLocality&&{addressLocality:t.addressLocality},...t.addressRegion&&{addressRegion:t.addressRegion},...t.postalCode&&{postalCode:t.postalCode},...t.addressCountry&&{addressCountry:t.addressCountry}}},G=t=>{const e={"@type":"Review"};return t.author&&(e.author=b(t.author)),t.datePublished&&(e.datePublished=t.datePublished),t.reviewBody&&(e.reviewBody=t.reviewBody),t.reviewRating&&(e.reviewRating={"@type":"Rating",ratingValue:t.reviewRating.ratingValue,...t.reviewRating.bestRating!=null&&{bestRating:t.reviewRating.bestRating},...t.reviewRating.worstRating!=null&&{worstRating:t.reviewRating.worstRating}}),e},p=({name:t,description:e,image:s,url:o,address:i,geo:u,numberOfRooms:R,numberOfBeds:m,priceRange:h,host:v,reviews:g,aggregateRating:r,keywords:d})=>{const n={"@context":"https://schema.org","@type":"VacationRental",name:t};e&&(n.description=e);const c=j(s);c&&(n.image=c),o&&(n.url=o);const y=x(i);y&&(n.address=y),u&&(n.geo={"@type":"GeoCoordinates",...u.latitude!=null&&{latitude:u.latitude},...u.longitude!=null&&{longitude:u.longitude}}),R!=null&&(n.numberOfRooms=R),m!=null&&(n.numberOfBeds=m),h&&(n.priceRange=h);const w=b(v);if(w&&(n.host=w),d&&(n.keywords=Array.isArray(d)?d.join(", "):d),g&&g.length>0){const C=g.map(G);if(n.review=C,!r){const l=g.map(a=>a.reviewRating?Number(a.reviewRating.ratingValue):NaN).filter(a=>!Number.isNaN(a));if(l.length>0){const a=l.reduce((A,I)=>A+I,0);n.aggregateRating={"@type":"AggregateRating",ratingValue:a/l.length,reviewCount:g.length,ratingCount:l.length}}}}return r&&(n.aggregateRating={"@type":"AggregateRating",ratingValue:r.ratingValue,...r.reviewCount!=null&&{reviewCount:r.reviewCount},...r.ratingCount!=null&&{ratingCount:r.ratingCount},...r.bestRating!=null&&{bestRating:r.bestRating},...r.worstRating!=null&&{worstRating:r.worstRating}}),n};var S=p;0&&(module.exports={generateVacationRentalSchema});
@@ -70,5 +70,6 @@ interface VideoOptions {
70
70
  reviews?: ReviewItem[];
71
71
  aggregateRating?: AggregateRatingOptions;
72
72
  }
73
- export declare const generateVideoSchema: ({ type, name, description, thumbnail, uploadDate, duration, contentUrl, embedUrl, clip, broadcastEvent, publisher, author, reviews, aggregateRating, }: VideoOptions) => any;
74
- export default generateVideoSchema;
73
+ declare const generateVideoSchema: ({ type, name, description, thumbnail, uploadDate, duration, contentUrl, embedUrl, clip, broadcastEvent, publisher, author, reviews, aggregateRating, }: VideoOptions) => any;
74
+
75
+ export { generateVideoSchema as default, generateVideoSchema };
@@ -1,163 +1 @@
1
- "use strict";
2
- /**
3
- * Generate schema.org structured data for `VideoObject`, `Clip`, or
4
- * `BroadcastEvent`.
5
- *
6
- * The `VideoOptions` input controls which type is produced and supports
7
- * optional fields like `aggregateRating`, `reviews`, thumbnails and
8
- * associated `Clip` or `BroadcastEvent` metadata. The result is a plain
9
- * object ready to be stringified as JSON-LD for inclusion in a page.
10
- *
11
- * See `VideoOptions` below for accepted fields and shapes.
12
- * @returns A JSON-LD compatible Video/Clip/BroadcastEvent 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.generateVideoSchema = void 0;
27
- var formatImage = function (i) {
28
- if (!i)
29
- return undefined;
30
- if (Array.isArray(i))
31
- return i.map(function (item) {
32
- return typeof item === 'string'
33
- ? item
34
- : __assign(__assign({ '@type': 'ImageObject', url: item.url }, (item.width && { width: item.width })), (item.height && { height: item.height }));
35
- });
36
- if (typeof i === 'string')
37
- return i;
38
- return __assign(__assign({ '@type': 'ImageObject', url: i.url }, (i.width && { width: i.width })), (i.height && { height: i.height }));
39
- };
40
- var formatPerson = function (p) {
41
- if (!p)
42
- return undefined;
43
- if (typeof p === 'string')
44
- return { '@type': 'Person', name: p };
45
- var out = { '@type': 'Person', name: p.name };
46
- if (p.url)
47
- out.url = p.url;
48
- return out;
49
- };
50
- var formatOrg = function (o) {
51
- if (!o)
52
- return undefined;
53
- if (typeof o === 'string')
54
- return { '@type': 'Organization', name: o };
55
- var out = { '@type': 'Organization', name: o.name };
56
- if (o.url)
57
- out.url = o.url;
58
- return out;
59
- };
60
- var formatReview = function (r) {
61
- var out = { '@type': 'Review' };
62
- if (r.author)
63
- out.author = formatPerson(r.author);
64
- if (r.datePublished)
65
- out.datePublished = r.datePublished;
66
- if (r.reviewBody)
67
- out.reviewBody = r.reviewBody;
68
- if (r.reviewRating) {
69
- out.reviewRating = __assign(__assign({ '@type': 'Rating', ratingValue: r.reviewRating.ratingValue }, (r.reviewRating.bestRating != null && {
70
- bestRating: r.reviewRating.bestRating,
71
- })), (r.reviewRating.worstRating != null && {
72
- worstRating: r.reviewRating.worstRating,
73
- }));
74
- }
75
- return out;
76
- };
77
- var generateVideoSchema = function (_a) {
78
- var _b = _a.type, type = _b === void 0 ? 'VideoObject' : _b, name = _a.name, description = _a.description, thumbnail = _a.thumbnail, uploadDate = _a.uploadDate, duration = _a.duration, contentUrl = _a.contentUrl, embedUrl = _a.embedUrl, clip = _a.clip, broadcastEvent = _a.broadcastEvent, publisher = _a.publisher, author = _a.author, reviews = _a.reviews, aggregateRating = _a.aggregateRating;
79
- var schema = {
80
- '@context': 'https://schema.org',
81
- '@type': type,
82
- name: name,
83
- };
84
- if (description)
85
- schema.description = description;
86
- var thumb = formatImage(thumbnail);
87
- if (thumb)
88
- schema.thumbnail = thumb;
89
- if (uploadDate)
90
- schema.uploadDate = uploadDate;
91
- if (duration)
92
- schema.duration = duration;
93
- if (contentUrl)
94
- schema.contentUrl = contentUrl;
95
- if (embedUrl)
96
- schema.embedUrl = embedUrl;
97
- var a = formatOrg(publisher);
98
- if (a)
99
- schema.publisher = a;
100
- var au = formatPerson(author);
101
- if (au)
102
- schema.author = au;
103
- if (clip) {
104
- var c = { '@type': 'Clip' };
105
- if (clip.name)
106
- c.name = clip.name;
107
- if (clip.startOffset != null)
108
- c.startOffset = clip.startOffset;
109
- if (clip.endOffset != null)
110
- c.endOffset = clip.endOffset;
111
- if (clip.url)
112
- c.url = clip.url;
113
- schema.clip = c;
114
- }
115
- if (broadcastEvent) {
116
- var b = { '@type': 'BroadcastEvent' };
117
- if (broadcastEvent.name)
118
- b.name = broadcastEvent.name;
119
- if (broadcastEvent.startDate)
120
- b.startDate = broadcastEvent.startDate;
121
- if (broadcastEvent.endDate)
122
- b.endDate = broadcastEvent.endDate;
123
- if (broadcastEvent.isLiveBroadcast != null)
124
- b.isLiveBroadcast = broadcastEvent.isLiveBroadcast;
125
- if (broadcastEvent.url)
126
- b.url = broadcastEvent.url;
127
- schema.broadcaster = b;
128
- }
129
- // Reviews
130
- if (reviews && reviews.length > 0) {
131
- var mapped = reviews.map(formatReview);
132
- schema.review = mapped;
133
- // compute aggregate rating if not supplied
134
- if (!aggregateRating) {
135
- var ratings = reviews
136
- .map(function (r) { return (r.reviewRating ? Number(r.reviewRating.ratingValue) : NaN); })
137
- .filter(function (n) { return !Number.isNaN(n); });
138
- if (ratings.length > 0) {
139
- var sum = ratings.reduce(function (x, y) { return x + y; }, 0);
140
- schema.aggregateRating = {
141
- '@type': 'AggregateRating',
142
- ratingValue: sum / ratings.length,
143
- reviewCount: reviews.length,
144
- ratingCount: ratings.length,
145
- };
146
- }
147
- }
148
- }
149
- if (aggregateRating) {
150
- schema.aggregateRating = __assign(__assign(__assign(__assign({ '@type': 'AggregateRating', ratingValue: aggregateRating.ratingValue }, (aggregateRating.reviewCount != null && {
151
- reviewCount: aggregateRating.reviewCount,
152
- })), (aggregateRating.ratingCount != null && {
153
- ratingCount: aggregateRating.ratingCount,
154
- })), (aggregateRating.bestRating != null && {
155
- bestRating: aggregateRating.bestRating,
156
- })), (aggregateRating.worstRating != null && {
157
- worstRating: aggregateRating.worstRating,
158
- }));
159
- }
160
- return schema;
161
- };
162
- exports.generateVideoSchema = generateVideoSchema;
163
- exports.default = exports.generateVideoSchema;
1
+ var d=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var A=(t,e)=>{for(var g in e)d(t,g,{get:e[g],enumerable:!0})},N=(t,e,g,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let u of P(e))!D.call(t,u)&&u!==g&&d(t,u,{get:()=>e[u],enumerable:!(l=B(e,u))||l.enumerable});return t};var j=t=>N(d({},"__esModule",{value:!0}),t);var S={};A(S,{default:()=>U,generateVideoSchema:()=>O});module.exports=j(S);const L=t=>{if(t)return Array.isArray(t)?t.map(e=>typeof e=="string"?e:{"@type":"ImageObject",url:e.url,...e.width&&{width:e.width},...e.height&&{height:e.height}}):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 e={"@type":"Person",name:t.name};return t.url&&(e.url=t.url),e},x=t=>{if(!t)return;if(typeof t=="string")return{"@type":"Organization",name:t};const e={"@type":"Organization",name:t.name};return t.url&&(e.url=t.url),e},z=t=>{const e={"@type":"Review"};return t.author&&(e.author=b(t.author)),t.datePublished&&(e.datePublished=t.datePublished),t.reviewBody&&(e.reviewBody=t.reviewBody),t.reviewRating&&(e.reviewRating={"@type":"Rating",ratingValue:t.reviewRating.ratingValue,...t.reviewRating.bestRating!=null&&{bestRating:t.reviewRating.bestRating},...t.reviewRating.worstRating!=null&&{worstRating:t.reviewRating.worstRating}}),e},O=({type:t="VideoObject",name:e,description:g,thumbnail:l,uploadDate:u,duration:h,contentUrl:R,embedUrl:w,clip:s,broadcastEvent:r,publisher:v,author:C,reviews:o,aggregateRating:a})=>{const n={"@context":"https://schema.org","@type":t,name:e};g&&(n.description=g);const y=L(l);y&&(n.thumbnail=y),u&&(n.uploadDate=u),h&&(n.duration=h),R&&(n.contentUrl=R),w&&(n.embedUrl=w);const c=x(v);c&&(n.publisher=c);const p=b(C);if(p&&(n.author=p),s){const i={"@type":"Clip"};s.name&&(i.name=s.name),s.startOffset!=null&&(i.startOffset=s.startOffset),s.endOffset!=null&&(i.endOffset=s.endOffset),s.url&&(i.url=s.url),n.clip=i}if(r){const i={"@type":"BroadcastEvent"};r.name&&(i.name=r.name),r.startDate&&(i.startDate=r.startDate),r.endDate&&(i.endDate=r.endDate),r.isLiveBroadcast!=null&&(i.isLiveBroadcast=r.isLiveBroadcast),r.url&&(i.url=r.url),n.broadcaster=i}if(o&&o.length>0){const i=o.map(z);if(n.review=i,!a){const m=o.map(f=>f.reviewRating?Number(f.reviewRating.ratingValue):NaN).filter(f=>!Number.isNaN(f));if(m.length>0){const f=m.reduce((I,V)=>I+V,0);n.aggregateRating={"@type":"AggregateRating",ratingValue:f/m.length,reviewCount:o.length,ratingCount:m.length}}}}return a&&(n.aggregateRating={"@type":"AggregateRating",ratingValue:a.ratingValue,...a.reviewCount!=null&&{reviewCount:a.reviewCount},...a.ratingCount!=null&&{ratingCount:a.ratingCount},...a.bestRating!=null&&{bestRating:a.bestRating},...a.worstRating!=null&&{worstRating:a.worstRating}}),n};var U=O;0&&(module.exports={generateVideoSchema});
@@ -23,29 +23,29 @@
23
23
  * - Single Item Cache Functions
24
24
  * - Cache Utilities
25
25
  */
26
- export interface CacheConfig {
26
+ interface CacheConfig {
27
27
  cacheKey: string;
28
28
  apiUrl: string;
29
29
  expirationMs?: number;
30
30
  responseKey?: string;
31
31
  params?: Record<string, unknown>;
32
32
  }
33
- export interface GetCachedDataOptions {
33
+ interface GetCachedDataOptions {
34
34
  config: CacheConfig;
35
35
  params?: Record<string, unknown>;
36
36
  headers?: Record<string, string>;
37
37
  }
38
- export interface CachedData<T> {
38
+ interface CachedData<T> {
39
39
  items: Record<string, T>;
40
40
  cachedAt: string;
41
41
  count: number;
42
42
  currentPage?: number;
43
43
  }
44
- export interface CachedSingleData<T> {
44
+ interface CachedSingleData<T> {
45
45
  item: T;
46
46
  cachedAt: string;
47
47
  }
48
- export interface ListResponse<T> {
48
+ interface ListResponse<T> {
49
49
  count: number;
50
50
  items: T[];
51
51
  currentPage?: number;
@@ -64,7 +64,7 @@ export interface ListResponse<T> {
64
64
  * console.log(users.items[0].name);
65
65
  * }
66
66
  */
67
- export declare const getCachedDataSync: <T>(cacheKey: string, expirationMs?: number) => ListResponse<T>;
67
+ declare const getCachedDataSync: <T>(cacheKey: string, expirationMs?: number) => ListResponse<T>;
68
68
  /**
69
69
  * Get cached data with API fallback for a module
70
70
  *
@@ -87,7 +87,7 @@ export declare const getCachedDataSync: <T>(cacheKey: string, expirationMs?: num
87
87
  * // With filters and custom page limit
88
88
  * const active = await getCachedData<UserBE>({ config, filters: { enabled: true }, pageLimit: 200 });
89
89
  */
90
- export declare const getCachedData: <T>(opts: GetCachedDataOptions) => Promise<ListResponse<T>>;
90
+ declare const getCachedData: <T>(opts: GetCachedDataOptions) => Promise<ListResponse<T>>;
91
91
  /**
92
92
  * Get single cached item by ID from a list cache
93
93
  *
@@ -101,7 +101,7 @@ export declare const getCachedData: <T>(opts: GetCachedDataOptions) => Promise<L
101
101
  * console.log(user.name);
102
102
  * }
103
103
  */
104
- export declare const getCachedItemById: <T extends {
104
+ declare const getCachedItemById: <T extends {
105
105
  id: string;
106
106
  }>(cacheKey: string, itemId: string) => T | null;
107
107
  /**
@@ -118,7 +118,7 @@ export declare const getCachedItemById: <T extends {
118
118
  * console.log(workspace.name);
119
119
  * }
120
120
  */
121
- export declare const getCachedSingleItemSync: <T>(cacheKey: string, expirationMs?: number) => T | null;
121
+ declare const getCachedSingleItemSync: <T>(cacheKey: string, expirationMs?: number) => T | null;
122
122
  /**
123
123
  * Get cached single item with API fallback
124
124
  * Useful for workspace, profile, settings, etc.
@@ -131,7 +131,7 @@ export declare const getCachedSingleItemSync: <T>(cacheKey: string, expirationMs
131
131
  * const config = { cacheKey: LS_KEYS.WORKSPACE, apiUrl: '/api/workspace', responseKey: 'workspace' };
132
132
  * const workspace = await getCachedSingleItem<WorkspaceBE>(config, { subdomain: 'school1' });
133
133
  */
134
- export declare const getCachedSingleItem: <T>(config: CacheConfig, params?: Record<string, string>, headers?: Record<string, string>) => Promise<T | null>;
134
+ declare const getCachedSingleItem: <T>(config: CacheConfig, params?: Record<string, string>, headers?: Record<string, string>) => Promise<T | null>;
135
135
  /**
136
136
  * Get cached data but fall back to the API when sync cache is empty.
137
137
  *
@@ -141,7 +141,7 @@ export declare const getCachedSingleItem: <T>(config: CacheConfig, params?: Reco
141
141
  * the result. Use this when callers want a fast-path cache read but also
142
142
  * need the ability to recall the API transparently when cache is missing.
143
143
  */
144
- export declare const getCachedDataWithFallback: <T>(config: CacheConfig, params?: Record<string, unknown>, headers?: Record<string, string>) => Promise<ListResponse<T>>;
144
+ declare const getCachedDataWithFallback: <T>(config: CacheConfig, params?: Record<string, unknown>, headers?: Record<string, string>) => Promise<ListResponse<T>>;
145
145
  /**
146
146
  * Async variant to get a single item by ID with API fallback.
147
147
  *
@@ -150,7 +150,7 @@ export declare const getCachedDataWithFallback: <T>(config: CacheConfig, params?
150
150
  * the local cache. Requires a full `CacheConfig` so the API URL is
151
151
  * available for fetching.
152
152
  */
153
- export declare const getCachedItemByIdAsync: <T extends {
153
+ declare const getCachedItemByIdAsync: <T extends {
154
154
  id: string;
155
155
  }>(config: CacheConfig, itemId: string, params?: Record<string, unknown>, headers?: Record<string, string>) => Promise<T | null>;
156
156
  /**
@@ -163,7 +163,7 @@ export declare const getCachedItemByIdAsync: <T extends {
163
163
  * invalidateCache(LS_KEYS.USERS);
164
164
  * const freshUsers = await getCachedData(config);
165
165
  */
166
- export declare const invalidateCache: (cacheKey: string) => void;
166
+ declare const invalidateCache: (cacheKey: string) => void;
167
167
  /**
168
168
  * Preload cache for a module
169
169
  * Useful to call on app initialization or login
@@ -175,7 +175,7 @@ export declare const invalidateCache: (cacheKey: string) => void;
175
175
  * const config = { cacheKey: LS_KEYS.USERS, apiUrl: USER_API_ROUTES.LIST, responseKey: 'users' };
176
176
  * await preloadCache(config);
177
177
  */
178
- export declare const preloadCache: <T>(config: CacheConfig) => Promise<ListResponse<T>>;
178
+ declare const preloadCache: <T>(config: CacheConfig) => Promise<ListResponse<T>>;
179
179
  /**
180
180
  * Check if cache is stale (older than expiration time)
181
181
  *
@@ -188,4 +188,6 @@ export declare const preloadCache: <T>(config: CacheConfig) => Promise<ListRespo
188
188
  * await getCachedData(config); // This will fetch fresh data
189
189
  * }
190
190
  */
191
- export declare const isCacheStale: (cacheKey: string, expirationMs?: number) => boolean;
191
+ declare const isCacheStale: (cacheKey: string, expirationMs?: number) => boolean;
192
+
193
+ export { type CacheConfig, type CachedData, type CachedSingleData, type GetCachedDataOptions, type ListResponse, getCachedData, getCachedDataSync, getCachedDataWithFallback, getCachedItemById, getCachedItemByIdAsync, getCachedSingleItem, getCachedSingleItemSync, invalidateCache, isCacheStale, preloadCache };