@react-pakistan/util-functions 1.25.89 → 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.
- package/README.md +74 -315
- package/constants/api-methods.d.ts +3 -1
- package/constants/api-methods.js +1 -15
- package/constants/cache-time.d.ts +7 -5
- package/constants/cache-time.js +1 -8
- package/constants/countries-timezones.d.ts +4 -2
- package/constants/countries-timezones.js +1 -1411
- package/constants/currencies.d.ts +4 -2
- package/constants/currencies.js +1 -1076
- package/constants/dial-codes.d.ts +5 -3
- package/constants/dial-codes.js +1 -1216
- package/constants/layout-direction.d.ts +3 -1
- package/constants/layout-direction.js +1 -8
- package/constants/react-pakistan-meta.d.ts +4 -2
- package/constants/react-pakistan-meta.js +1 -35
- package/constants/react-pakistan.d.ts +5 -3
- package/constants/react-pakistan.js +12 -104
- package/constants/select-value-delimiter.d.ts +3 -1
- package/constants/select-value-delimiter.js +1 -13
- package/constants/social-media-colors.d.ts +3 -1
- package/constants/social-media-colors.js +1 -42
- package/constants/social-media-sizes.d.ts +6 -4
- package/constants/social-media-sizes.js +1 -327
- package/constants/user-roles.d.ts +3 -1
- package/constants/user-roles.js +1 -9
- package/edu-pilot-pro/types/academics.d.ts +2 -0
- package/edu-pilot-pro/types/academics.js +1 -0
- package/edu-pilot-pro/types/admission.d.ts +878 -0
- package/edu-pilot-pro/types/admission.js +1 -0
- package/edu-pilot-pro/types/communication.d.ts +2 -0
- package/edu-pilot-pro/types/communication.js +1 -0
- package/edu-pilot-pro/types/enums.d.ts +413 -0
- package/edu-pilot-pro/types/enums.js +1 -0
- package/edu-pilot-pro/types/finance.d.ts +2 -0
- package/edu-pilot-pro/types/finance.js +1 -0
- package/edu-pilot-pro/types/index.d.ts +2 -0
- package/edu-pilot-pro/types/index.js +1 -0
- package/edu-pilot-pro/types/user-management.d.ts +2 -0
- package/edu-pilot-pro/types/user-management.js +1 -0
- package/factory/generic-component-factory.d.ts +12 -9
- package/factory/generic-component-factory.js +1 -131
- package/factory/generic-module-factory.d.ts +14 -10
- package/factory/generic-module-factory.js +1 -190
- package/general/basic-get.d.ts +8 -1
- package/general/basic-get.js +1 -83
- package/general/basic-post.d.ts +8 -1
- package/general/basic-post.js +1 -70
- package/general/calculate-pages.d.ts +9 -1
- package/general/calculate-pages.js +1 -7
- package/general/camel-to-sentence-case.d.ts +3 -1
- package/general/camel-to-sentence-case.js +1 -20
- package/general/check-even-odd-length.d.ts +3 -1
- package/general/check-even-odd-length.js +1 -17
- package/general/clear-cache.d.ts +7 -2
- package/general/clear-cache.js +1 -12
- package/general/cnic-formatter.d.ts +16 -3
- package/general/cnic-formatter.js +1 -53
- package/general/convert-url-to-base64.d.ts +8 -6
- package/general/convert-url-to-base64.js +1 -231
- package/general/countries.d.ts +5 -3
- package/general/countries.js +1 -514
- package/general/create-date.d.ts +3 -1
- package/general/create-date.js +1 -22
- package/general/crypto.d.ts +4 -2
- package/general/crypto.js +1 -45
- package/general/currencies.d.ts +2 -0
- package/general/currencies.js +0 -1077
- package/general/delete-image-from-private-supabase.d.ts +10 -2
- package/general/delete-image-from-private-supabase.js +1 -66
- package/general/delete-image-from-public-supabase.d.ts +10 -2
- package/general/delete-image-from-public-supabase.js +1 -66
- package/general/download-from-url.d.ts +8 -1
- package/general/download-from-url.js +1 -82
- package/general/dynamic-page-limit.d.ts +9 -3
- package/general/dynamic-page-limit.js +1 -7
- package/general/enum-to-text.d.ts +8 -1
- package/general/enum-to-text.js +1 -11
- package/general/fetch-data.d.ts +16 -4
- package/general/fetch-data.js +1 -95
- package/general/fetch-supabase-image.d.ts +11 -2
- package/general/fetch-supabase-image.js +1 -67
- package/general/fetch-supabase-private-assets.d.ts +11 -2
- package/general/fetch-supabase-private-assets.js +1 -69
- package/general/format-date.d.ts +10 -2
- package/general/format-date.js +1 -49
- package/general/format-number.d.ts +12 -2
- package/general/format-number.js +1 -35
- package/general/format-phone-display.d.ts +9 -1
- package/general/format-phone-display.js +1 -32
- package/general/format-phone.d.ts +10 -2
- package/general/format-phone.js +1 -20
- package/general/format-pricing.d.ts +8 -1
- package/general/format-pricing.js +1 -23
- package/general/format-secs.d.ts +8 -1
- package/general/format-secs.js +1 -21
- package/general/format-time.d.ts +8 -2
- package/general/format-time.js +1 -38
- package/general/format-value.d.ts +8 -1
- package/general/format-value.js +1 -7
- package/general/full-month-range.d.ts +3 -2
- package/general/full-month-range.js +1 -24
- package/general/full-year-range.d.ts +3 -2
- package/general/full-year-range.js +1 -20
- package/general/generate-article-schema.d.ts +3 -2
- package/general/generate-article-schema.js +1 -100
- package/general/generate-blog-schema.d.ts +3 -2
- package/general/generate-blog-schema.js +1 -32
- package/general/generate-book-schema.d.ts +3 -2
- package/general/generate-book-schema.js +1 -109
- package/general/generate-breadcrumb-schema.d.ts +3 -2
- package/general/generate-breadcrumb-schema.js +1 -34
- package/general/generate-carousel-schema.d.ts +3 -2
- package/general/generate-carousel-schema.js +1 -172
- package/general/generate-course-schema.d.ts +3 -2
- package/general/generate-course-schema.js +1 -124
- package/general/generate-dataset-schema.d.ts +3 -2
- package/general/generate-dataset-schema.js +1 -156
- package/general/generate-discussion-forum-schema.d.ts +3 -2
- package/general/generate-discussion-forum-schema.js +1 -67
- package/general/generate-education-schema.d.ts +3 -2
- package/general/generate-education-schema.js +1 -137
- package/general/generate-employer-aggregate-rating-schema.d.ts +3 -2
- package/general/generate-employer-aggregate-rating-schema.js +1 -64
- package/general/generate-event-schema.d.ts +3 -2
- package/general/generate-event-schema.js +1 -214
- package/general/generate-faq-schema.d.ts +3 -2
- package/general/generate-faq-schema.js +1 -43
- package/general/generate-grid.d.ts +3 -2
- package/general/generate-grid.js +1 -55
- package/general/generate-image-metadata-schema.d.ts +3 -2
- package/general/generate-image-metadata-schema.js +1 -73
- package/general/generate-job-posting-schema.d.ts +3 -2
- package/general/generate-job-posting-schema.js +1 -120
- package/general/generate-local-business-schema.d.ts +3 -2
- package/general/generate-local-business-schema.js +1 -75
- package/general/generate-math-solver-schema.d.ts +3 -2
- package/general/generate-math-solver-schema.js +1 -83
- package/general/generate-movie-carousel-schema.d.ts +3 -2
- package/general/generate-movie-carousel-schema.js +1 -160
- package/general/generate-organization-schema.d.ts +3 -2
- package/general/generate-organization-schema.js +1 -39
- package/general/generate-profile-page-schema.d.ts +3 -2
- package/general/generate-profile-page-schema.js +1 -82
- package/general/generate-qa-page-schema.d.ts +3 -2
- package/general/generate-qa-page-schema.js +1 -67
- package/general/generate-recipe-schema.d.ts +3 -2
- package/general/generate-recipe-schema.js +1 -104
- package/general/generate-ref.d.ts +8 -2
- package/general/generate-ref.js +1 -12
- package/general/generate-review-snippet-schema.d.ts +3 -2
- package/general/generate-review-snippet-schema.js +1 -137
- package/general/generate-shopping-loyalty-program-schema.d.ts +3 -2
- package/general/generate-shopping-loyalty-program-schema.js +1 -59
- package/general/generate-shopping-merchant-listing-schema.d.ts +3 -2
- package/general/generate-shopping-merchant-listing-schema.js +1 -153
- package/general/generate-shopping-merchant-return-policy-schema.d.ts +3 -2
- package/general/generate-shopping-merchant-return-policy-schema.js +1 -68
- package/general/generate-shopping-merchant-shipping-policy-schema.d.ts +3 -2
- package/general/generate-shopping-merchant-shipping-policy-schema.js +1 -74
- package/general/generate-shopping-overview-schema.d.ts +3 -2
- package/general/generate-shopping-overview-schema.js +1 -157
- package/general/generate-shopping-product-snippet-schema.d.ts +3 -2
- package/general/generate-shopping-product-snippet-schema.js +1 -167
- package/general/generate-shopping-variants-schema.d.ts +3 -2
- package/general/generate-shopping-variants-schema.js +1 -143
- package/general/generate-software-app-schema.d.ts +3 -2
- package/general/generate-software-app-schema.js +1 -143
- package/general/generate-speakable-schema.d.ts +3 -2
- package/general/generate-speakable-schema.js +1 -139
- package/general/generate-subscription-schema.d.ts +3 -2
- package/general/generate-subscription-schema.js +1 -133
- package/general/generate-vacation-rental-schema.d.ts +3 -2
- package/general/generate-vacation-rental-schema.js +1 -135
- package/general/generate-video-schema.d.ts +3 -2
- package/general/generate-video-schema.js +1 -163
- package/general/generic-cache.d.ts +17 -15
- package/general/generic-cache.js +1 -659
- package/general/get-available-page-limit.d.ts +8 -2
- package/general/get-available-page-limit.js +1 -31
- package/general/get-calendar-current-month.d.ts +11 -3
- package/general/get-calendar-current-month.js +1 -31
- package/general/get-calendar-dates.d.ts +11 -3
- package/general/get-calendar-dates.js +1 -42
- package/general/get-calendar-next-month.d.ts +12 -3
- package/general/get-calendar-next-month.js +1 -32
- package/general/get-calendar-previous-month.d.ts +12 -3
- package/general/get-calendar-previous-month.js +1 -36
- package/general/get-current-year.d.ts +7 -1
- package/general/get-current-year.js +1 -5
- package/general/get-day-name.d.ts +5 -3
- package/general/get-day-name.js +1 -14
- package/general/get-dial-code.d.ts +8 -1
- package/general/get-dial-code.js +1 -8
- package/general/get-full-name.d.ts +9 -2
- package/general/get-full-name.js +1 -8
- package/general/get-href.d.ts +3 -1
- package/general/get-href.js +1 -13
- package/general/get-month-name.d.ts +5 -3
- package/general/get-month-name.js +1 -19
- package/general/get-month-number.d.ts +5 -3
- package/general/get-month-number.js +1 -29
- package/general/get-number-of-days-in-month.d.ts +9 -2
- package/general/get-number-of-days-in-month.js +1 -12
- package/general/get-pathname.d.ts +3 -1
- package/general/get-pathname.js +1 -16
- package/general/get-week-day.d.ts +8 -1
- package/general/get-week-day.js +1 -9
- package/general/image-url-to-base64.d.ts +3 -1
- package/general/image-url-to-base64.js +1 -80
- package/general/is-created-or-updated.d.ts +3 -1
- package/general/is-created-or-updated.js +1 -26
- package/general/is-next-button-disabled.d.ts +9 -1
- package/general/is-next-button-disabled.js +1 -5
- package/general/is-odd.d.ts +3 -1
- package/general/is-odd.js +1 -13
- package/general/is-previous-button-disabled.d.ts +8 -1
- package/general/is-previous-button-disabled.js +1 -7
- package/general/linear-gradients.d.ts +4 -2
- package/general/linear-gradients.js +1 -52
- package/general/multi-part-search.d.ts +10 -2
- package/general/multi-part-search.js +1 -16
- package/general/normalize-phone.d.ts +15 -2
- package/general/normalize-phone.js +1 -40
- package/general/parse-frontmatter.d.ts +11 -4
- package/general/parse-frontmatter.js +2 -35
- package/general/remove-data-image-prefix.d.ts +8 -1
- package/general/remove-data-image-prefix.js +1 -7
- package/general/repeat-times.d.ts +3 -1
- package/general/repeat-times.js +1 -21
- package/general/resolve-anchor-link.d.ts +3 -1
- package/general/resolve-anchor-link.js +1 -26
- package/general/resolve-current-date.d.ts +3 -1
- package/general/resolve-current-date.js +1 -22
- package/general/resolve-grid.d.ts +3 -1
- package/general/resolve-grid.js +1 -18
- package/general/resolve-initials.d.ts +3 -1
- package/general/resolve-initials.js +1 -17
- package/general/set-timezone.d.ts +11 -1
- package/general/set-timezone.js +1 -12
- package/general/slugify.d.ts +3 -1
- package/general/slugify.js +1 -24
- package/general/text-to-enum.d.ts +8 -1
- package/general/text-to-enum.js +1 -10
- package/general/text-to-sentence-case.d.ts +3 -1
- package/general/text-to-sentence-case.js +1 -16
- package/general/time-out.d.ts +3 -1
- package/general/time-out.js +1 -16
- package/general/time-zones.d.ts +3 -1
- package/general/time-zones.js +1 -437
- package/general/truncate-text.d.ts +3 -1
- package/general/truncate-text.js +1 -18
- package/general/type.d.ts +3 -1
- package/general/type.js +1 -2
- package/general/upload-blob-to-private-supabase.d.ts +14 -2
- package/general/upload-blob-to-private-supabase.js +1 -62
- package/general/upload-blob-to-public-supabase.d.ts +14 -2
- package/general/upload-blob-to-public-supabase.js +1 -62
- package/general/upload-image-to-private-supabase.d.ts +15 -3
- package/general/upload-image-to-private-supabase.js +1 -66
- package/general/upload-image-to-public-supabase.d.ts +15 -3
- package/general/upload-image-to-public-supabase.js +1 -66
- package/general/url-to-sentence-case.d.ts +3 -1
- package/general/url-to-sentence-case.js +1 -19
- package/general/validate-comment.d.ts +3 -1
- package/general/validate-comment.js +1 -21
- package/general/validate-email.d.ts +3 -1
- package/general/validate-email.js +1 -24
- package/general/validate-form.d.ts +12 -3
- package/general/validate-form.js +1 -29
- package/general/validate-name.d.ts +3 -1
- package/general/validate-name.js +1 -21
- package/hooks/use-change.d.ts +11 -2
- package/hooks/use-change.js +1 -23
- package/hooks/use-debounce.d.ts +10 -1
- package/hooks/use-debounce.js +1 -14
- package/hooks/use-fetch.d.ts +7 -5
- package/hooks/use-fetch.js +1 -239
- package/hooks/use-force-render.d.ts +6 -2
- package/hooks/use-force-render.js +1 -17
- package/hooks/use-ip-geo-location.d.ts +8 -1
- package/hooks/use-ip-geo-location.js +1 -79
- package/hooks/use-is-mobile.d.ts +8 -1
- package/hooks/use-is-mobile.js +1 -22
- package/hooks/use-module-entity-v2.d.ts +7 -4
- package/hooks/use-module-entity-v2.js +1 -188
- package/hooks/use-module-entity.d.ts +7 -4
- package/hooks/use-module-entity.js +1 -177
- package/hooks/use-phone-formatter.d.ts +10 -2
- package/hooks/use-phone-formatter.js +1 -23
- package/hooks/use-position.d.ts +6 -3
- package/hooks/use-position.js +1 -43
- package/hooks/use-rtl.d.ts +4 -2
- package/hooks/use-rtl.js +1 -84
- package/hooks/use-sticky.d.ts +3 -1
- package/hooks/use-sticky.js +1 -39
- package/hooks/use-toggle-state.d.ts +3 -2
- package/hooks/use-toggle-state.js +1 -26
- package/hooks/use-window-event-listener.d.ts +9 -1
- package/hooks/use-window-event-listener.js +1 -11
- package/hooks/with-seo.d.ts +11 -2
- package/hooks/with-seo.js +1 -37
- package/local-storage/get-storage-value.d.ts +5 -2
- package/local-storage/get-storage-value.js +1 -20
- package/local-storage/remove-storage-value.d.ts +3 -1
- package/local-storage/remove-storage-value.js +1 -14
- package/local-storage/set-storage-value.d.ts +3 -1
- package/local-storage/set-storage-value.js +1 -14
- package/local-storage/type.d.ts +3 -1
- package/local-storage/type.js +1 -2
- package/npm.d.d.ts +2 -0
- package/npm.d.js +0 -0
- package/package.json +20 -18
- package/storybook/generate-sitemap.d.ts +3 -1
- package/storybook/generate-sitemap.js +17 -26
- package/storybook/preview.d.ts +4 -2
- package/storybook/preview.js +1 -62
- package/storybook/react-design-story-script.d.ts +3 -1
- package/storybook/react-design-story-script.js +5 -27
- package/storybook/react-emoji-collection.d.ts +3 -1
- package/storybook/react-emoji-collection.js +10 -55
- package/storybook/react-emoji-story-script.d.ts +3 -1
- package/storybook/react-emoji-story-script.js +5 -31
- package/storybook/react-emoji-story-template.d.ts +3 -1
- package/storybook/react-emoji-story-template.js +45 -15
- package/storybook/react-icon-collection.d.ts +3 -1
- package/storybook/react-icon-collection.js +10 -42
- package/storybook/react-icon-story-script.d.ts +3 -1
- package/storybook/react-icon-story-script.js +5 -27
- package/storybook/react-icon-story-template.d.ts +3 -1
- package/storybook/react-icon-story-template.js +45 -14
- package/storybook/react-logo-collection.d.ts +3 -1
- package/storybook/react-logo-collection.js +10 -42
- package/storybook/react-logo-story-script.d.ts +3 -1
- package/storybook/react-logo-story-script.js +5 -27
- package/storybook/react-logo-story-template.d.ts +3 -1
- package/storybook/react-logo-story-template.js +45 -14
- package/storybook/react-pakistan-theme.d.ts +3 -1
- package/storybook/react-pakistan-theme.js +1 -31
- package/storybook/responsive-args.d.ts +11 -10
- package/storybook/responsive-args.js +1 -19
- package/storybook/responsive-component.d.ts +4 -2
- package/storybook/responsive-component.js +37 -23
- package/storybook/responsive-screens.d.ts +3 -1
- package/storybook/responsive-screens.js +1 -109
- package/storybook/theme.d.ts +17 -15
- package/storybook/theme.js +1 -1022
- package/api/stellar-solutions/app-user/index.d.ts +0 -51
- package/api/stellar-solutions/app-user/index.js +0 -210
- package/api/stellar-solutions/bank/index.d.ts +0 -59
- package/api/stellar-solutions/bank/index.js +0 -210
- package/api/stellar-solutions/branch/index.d.ts +0 -58
- package/api/stellar-solutions/branch/index.js +0 -220
- package/api/stellar-solutions/company/index.d.ts +0 -57
- package/api/stellar-solutions/company/index.js +0 -218
- package/api/stellar-solutions/company-report/index.d.ts +0 -15
- package/api/stellar-solutions/company-report/index.js +0 -74
- package/api/stellar-solutions/constants.d.ts +0 -19
- package/api/stellar-solutions/constants.js +0 -22
- package/api/stellar-solutions/contact/index.d.ts +0 -56
- package/api/stellar-solutions/contact/index.js +0 -217
- package/api/stellar-solutions/currency/index.d.ts +0 -55
- package/api/stellar-solutions/currency/index.js +0 -212
- package/api/stellar-solutions/customer/index.d.ts +0 -68
- package/api/stellar-solutions/customer/index.js +0 -249
- package/api/stellar-solutions/expense/index.d.ts +0 -58
- package/api/stellar-solutions/expense/index.js +0 -229
- package/api/stellar-solutions/expense-category/index.d.ts +0 -53
- package/api/stellar-solutions/expense-category/index.js +0 -214
- package/api/stellar-solutions/lead/index.d.ts +0 -51
- package/api/stellar-solutions/lead/index.js +0 -206
- package/api/stellar-solutions/menu-order/index.d.ts +0 -53
- package/api/stellar-solutions/menu-order/index.js +0 -202
- package/api/stellar-solutions/payment/index.d.ts +0 -65
- package/api/stellar-solutions/payment/index.js +0 -230
- package/api/stellar-solutions/payment-mode/index.d.ts +0 -53
- package/api/stellar-solutions/payment-mode/index.js +0 -191
- package/api/stellar-solutions/preference/index.d.ts +0 -25
- package/api/stellar-solutions/preference/index.js +0 -114
- package/api/stellar-solutions/product/index.d.ts +0 -64
- package/api/stellar-solutions/product/index.js +0 -235
- package/api/stellar-solutions/product-category/index.d.ts +0 -51
- package/api/stellar-solutions/product-category/index.js +0 -212
- package/api/stellar-solutions/profile/index.d.ts +0 -78
- package/api/stellar-solutions/profile/index.js +0 -234
- package/api/stellar-solutions/quote-invoice/index.d.ts +0 -97
- package/api/stellar-solutions/quote-invoice/index.js +0 -369
- package/api/stellar-solutions/quote-invoice-report/index.d.ts +0 -15
- package/api/stellar-solutions/quote-invoice-report/index.js +0 -74
- package/api/stellar-solutions/tax/index.d.ts +0 -55
- package/api/stellar-solutions/tax/index.js +0 -224
- package/api/stellar-solutions/types/common.d.ts +0 -24
- package/api/stellar-solutions/types/common.js +0 -22
- package/api/stellar-solutions/types/erp.d.ts +0 -302
- package/api/stellar-solutions/types/erp.js +0 -73
- package/api/stellar-solutions/types/index.d.ts +0 -3
- package/api/stellar-solutions/types/index.js +0 -19
- package/api/stellar-solutions/types/pos.d.ts +0 -176
- package/api/stellar-solutions/types/pos.js +0 -61
- package/constants/index.d.ts +0 -12
- package/constants/index.js +0 -28
- package/factory/index.d.ts +0 -2
- package/factory/index.js +0 -18
- package/general/index.d.ts +0 -95
- package/general/index.js +0 -111
- package/index.d.ts +0 -28
- package/index.js +0 -44
- package/local-storage/index.d.ts +0 -4
- package/local-storage/index.js +0 -20
- package/setupTests.d.ts +0 -1
- package/setupTests.js +0 -52
- package/storybook/index.d.ts +0 -17
- package/storybook/index.js +0 -33
|
@@ -1,109 +1 @@
|
|
|
1
|
-
"
|
|
2
|
-
/**
|
|
3
|
-
* Generate schema.org `Book` JSON-LD for use in page <script type="application/ld+json">.
|
|
4
|
-
*
|
|
5
|
-
* This helper accepts a compact `BookSchemaOptions` input and returns a
|
|
6
|
-
* plain object ready to be stringified and inlined on a page. Common
|
|
7
|
-
* fields supported:
|
|
8
|
-
*
|
|
9
|
-
* - `title` → maps to `name`
|
|
10
|
-
* - `author` → accepts a `string`, an `{ name, url? }` object, or an array of
|
|
11
|
-
* those; these are formatted as `Person` objects
|
|
12
|
-
* - `publisher` → `{ name, logo? }` formatted as an `Organization` with
|
|
13
|
-
* an optional `ImageObject` logo
|
|
14
|
-
* - `image` → accepts a `string`, `BookImage` or arrays; non-string images are
|
|
15
|
-
* converted to `ImageObject` entries
|
|
16
|
-
* - `url` → attached to `mainEntityOfPage.@id` when provided
|
|
17
|
-
* - `keywords` → joined into a comma-separated string
|
|
18
|
-
*
|
|
19
|
-
* The implementation intentionally produces minimal output (only provided
|
|
20
|
-
* fields are added) so the result can be safely merged into other page
|
|
21
|
-
* metadata.
|
|
22
|
-
*
|
|
23
|
-
* @param options.book title, author, publisher and optional metadata
|
|
24
|
-
* @returns A JSON-LD compatible `Book` object
|
|
25
|
-
*/
|
|
26
|
-
var __assign = (this && this.__assign) || function () {
|
|
27
|
-
__assign = Object.assign || function(t) {
|
|
28
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
29
|
-
s = arguments[i];
|
|
30
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
31
|
-
t[p] = s[p];
|
|
32
|
-
}
|
|
33
|
-
return t;
|
|
34
|
-
};
|
|
35
|
-
return __assign.apply(this, arguments);
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.generateBookSchema = void 0;
|
|
39
|
-
var formatAuthor = function (author) {
|
|
40
|
-
if (typeof author === 'string') {
|
|
41
|
-
return {
|
|
42
|
-
'@type': 'Person',
|
|
43
|
-
name: author,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
if (Array.isArray(author)) {
|
|
47
|
-
return author.map(function (a) { return (__assign({ '@type': 'Person', name: a.name }, (a.url && { url: a.url }))); });
|
|
48
|
-
}
|
|
49
|
-
return __assign({ '@type': 'Person', name: author.name }, (author.url && { url: author.url }));
|
|
50
|
-
};
|
|
51
|
-
var formatImage = function (image) {
|
|
52
|
-
if (!image)
|
|
53
|
-
return undefined;
|
|
54
|
-
if (typeof image === 'string')
|
|
55
|
-
return image;
|
|
56
|
-
if (Array.isArray(image)) {
|
|
57
|
-
return image.map(function (img) {
|
|
58
|
-
if (typeof img === 'string')
|
|
59
|
-
return img;
|
|
60
|
-
return __assign(__assign({ '@type': 'ImageObject', url: img.url }, (img.width && { width: img.width })), (img.height && { height: img.height }));
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
return __assign(__assign({ '@type': 'ImageObject', url: image.url }, (image.width && { width: image.width })), (image.height && { height: image.height }));
|
|
64
|
-
};
|
|
65
|
-
var formatPublisher = function (publisher) {
|
|
66
|
-
var out = {
|
|
67
|
-
'@type': 'Organization',
|
|
68
|
-
name: publisher.name,
|
|
69
|
-
};
|
|
70
|
-
if (publisher.logo) {
|
|
71
|
-
out.logo = __assign(__assign({ '@type': 'ImageObject', url: publisher.logo.url }, (publisher.logo.width && { width: publisher.logo.width })), (publisher.logo.height && { height: publisher.logo.height }));
|
|
72
|
-
}
|
|
73
|
-
return out;
|
|
74
|
-
};
|
|
75
|
-
var generateBookSchema = function (_a) {
|
|
76
|
-
var title = _a.title, author = _a.author, isbn = _a.isbn, numberOfPages = _a.numberOfPages, inLanguage = _a.inLanguage, publisher = _a.publisher, datePublished = _a.datePublished, image = _a.image, description = _a.description, url = _a.url, keywords = _a.keywords, bookFormat = _a.bookFormat;
|
|
77
|
-
var schema = {
|
|
78
|
-
'@context': 'https://schema.org',
|
|
79
|
-
'@type': 'Book',
|
|
80
|
-
name: title,
|
|
81
|
-
author: formatAuthor(author),
|
|
82
|
-
publisher: formatPublisher(publisher),
|
|
83
|
-
};
|
|
84
|
-
if (isbn)
|
|
85
|
-
schema.isbn = isbn;
|
|
86
|
-
if (numberOfPages)
|
|
87
|
-
schema.numberOfPages = numberOfPages;
|
|
88
|
-
if (inLanguage)
|
|
89
|
-
schema.inLanguage = inLanguage;
|
|
90
|
-
if (datePublished)
|
|
91
|
-
schema.datePublished = datePublished;
|
|
92
|
-
if (description)
|
|
93
|
-
schema.description = description;
|
|
94
|
-
if (bookFormat)
|
|
95
|
-
schema.bookFormat = bookFormat;
|
|
96
|
-
var img = formatImage(image);
|
|
97
|
-
if (img)
|
|
98
|
-
schema.image = img;
|
|
99
|
-
if (url) {
|
|
100
|
-
schema.mainEntityOfPage = {
|
|
101
|
-
'@type': 'WebPage',
|
|
102
|
-
'@id': url,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
if (keywords && keywords.length > 0)
|
|
106
|
-
schema.keywords = keywords.join(', ');
|
|
107
|
-
return schema;
|
|
108
|
-
};
|
|
109
|
-
exports.generateBookSchema = generateBookSchema;
|
|
1
|
+
var h=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var B=(t,r)=>{for(var o in r)h(t,o,{get:r[o],enumerable:!0})},p=(t,r,o,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of k(r))!d.call(t,n)&&n!==o&&h(t,n,{get:()=>r[n],enumerable:!(i=y(r,n))||i.enumerable});return t};var b=t=>p(h({},"__esModule",{value:!0}),t);var O={};B(O,{generateBookSchema:()=>I});module.exports=b(O);const w=t=>typeof t=="string"?{"@type":"Person",name:t}:Array.isArray(t)?t.map(r=>({"@type":"Person",name:r.name,...r.url&&{url:r.url}})):{"@type":"Person",name:t.name,...t.url&&{url:t.url}},P=t=>{if(t)return typeof t=="string"?t:Array.isArray(t)?t.map(r=>typeof r=="string"?r:{"@type":"ImageObject",url:r.url,...r.width&&{width:r.width},...r.height&&{height:r.height}}):{"@type":"ImageObject",url:t.url,...t.width&&{width:t.width},...t.height&&{height:t.height}}},A=t=>{const r={"@type":"Organization",name:t.name};return t.logo&&(r.logo={"@type":"ImageObject",url:t.logo.url,...t.logo.width&&{width:t.logo.width},...t.logo.height&&{height:t.logo.height}}),r},I=({title:t,author:r,isbn:o,numberOfPages:i,inLanguage:n,publisher:m,datePublished:s,image:c,description:u,url:a,keywords:g,bookFormat:f})=>{const e={"@context":"https://schema.org","@type":"Book",name:t,author:w(r),publisher:A(m)};o&&(e.isbn=o),i&&(e.numberOfPages=i),n&&(e.inLanguage=n),s&&(e.datePublished=s),u&&(e.description=u),f&&(e.bookFormat=f);const l=P(c);return l&&(e.image=l),a&&(e.mainEntityOfPage={"@type":"WebPage","@id":a}),g&&g.length>0&&(e.keywords=g.join(", ")),e};0&&(module.exports={generateBookSchema});
|
|
@@ -23,7 +23,7 @@ interface Props {
|
|
|
23
23
|
data: Array<string | Crumb>;
|
|
24
24
|
baseUrl: string;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
declare const generateBreadcrumbSchema: ({ data, baseUrl }: Props) => {
|
|
27
27
|
'@context': string;
|
|
28
28
|
'@type': string;
|
|
29
29
|
itemListElement: {
|
|
@@ -36,4 +36,5 @@ export declare const generateBreadcrumbSchema: ({ data, baseUrl }: Props) => {
|
|
|
36
36
|
};
|
|
37
37
|
}[];
|
|
38
38
|
};
|
|
39
|
-
|
|
39
|
+
|
|
40
|
+
export { generateBreadcrumbSchema };
|
|
@@ -1,34 +1 @@
|
|
|
1
|
-
"
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateBreadcrumbSchema = void 0;
|
|
4
|
-
var slugify_1 = require("./slugify");
|
|
5
|
-
var generateBreadcrumbSchema = function (_a) {
|
|
6
|
-
var data = _a.data, baseUrl = _a.baseUrl;
|
|
7
|
-
var urlItem = baseUrl;
|
|
8
|
-
var items = data.map(function (entry, index) {
|
|
9
|
-
var name = typeof entry === 'string' ? entry : entry.name;
|
|
10
|
-
if (typeof entry !== 'string' && entry.url) {
|
|
11
|
-
// use provided absolute url
|
|
12
|
-
urlItem = entry.url;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
var segment = typeof entry === 'string' ? entry : entry.path || entry.name;
|
|
16
|
-
urlItem += "/".concat((0, slugify_1.slugify)(segment));
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
'@type': 'ListItem',
|
|
20
|
-
position: index + 1,
|
|
21
|
-
name: name,
|
|
22
|
-
item: {
|
|
23
|
-
'@id': urlItem,
|
|
24
|
-
name: name,
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
return {
|
|
29
|
-
'@context': 'https://schema.org',
|
|
30
|
-
'@type': 'BreadcrumbList',
|
|
31
|
-
itemListElement: items,
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
exports.generateBreadcrumbSchema = generateBreadcrumbSchema;
|
|
1
|
+
var m=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var l=(s,e)=>{for(var r in e)m(s,r,{get:e[r],enumerable:!0})},f=(s,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of c(e))!u.call(s,t)&&t!==r&&m(s,t,{get:()=>e[t],enumerable:!(i=g(e,t))||i.enumerable});return s};var b=s=>f(m({},"__esModule",{value:!0}),s);var d={};l(d,{generateBreadcrumbSchema:()=>h});module.exports=b(d);var n=require("./slugify");const h=({data:s,baseUrl:e})=>{let r=e;return{"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:s.map((t,o)=>{const a=typeof t=="string"?t:t.name;if(typeof t!="string"&&t.url)r=t.url;else{const p=typeof t=="string"?t:t.path||t.name;r+=`/${(0,n.slugify)(p)}`}return{"@type":"ListItem",position:o+1,name:a,item:{"@id":r,name:a}}})}};0&&(module.exports={generateBreadcrumbSchema});
|
|
@@ -47,5 +47,6 @@ interface CarouselSchemaOptions {
|
|
|
47
47
|
items: CarouselItem[];
|
|
48
48
|
skipInvalidCurrency?: boolean;
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
declare const generateCarouselSchema: ({ name, url, items, skipInvalidCurrency, }: CarouselSchemaOptions) => any;
|
|
51
|
+
|
|
52
|
+
export { generateCarouselSchema };
|
|
@@ -1,172 +1 @@
|
|
|
1
|
-
"
|
|
2
|
-
/**
|
|
3
|
-
* Generate schema.org `ItemList` JSON-LD for a carousel of items.
|
|
4
|
-
*
|
|
5
|
-
* Each carousel item is emitted as a `ListItem` containing a `Thing`
|
|
6
|
-
* (Product, Article, Movie, etc.) depending on the provided item fields.
|
|
7
|
-
* Currency and availability values are normalized where applicable; use
|
|
8
|
-
* `skipInvalidCurrency` to bypass currency validation.
|
|
9
|
-
*
|
|
10
|
-
* See `CarouselSchemaOptions` and `CarouselItem` for input details.
|
|
11
|
-
* @returns A JSON-LD compatible `ItemList` 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.generateCarouselSchema = 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 isValidCurrency = function (code) {
|
|
34
|
-
if (!code)
|
|
35
|
-
return false;
|
|
36
|
-
return /^[A-Z]{3}$/.test(code);
|
|
37
|
-
};
|
|
38
|
-
var AVAILABILITIES = [
|
|
39
|
-
'InStock',
|
|
40
|
-
'OutOfStock',
|
|
41
|
-
'PreOrder',
|
|
42
|
-
'PreSale',
|
|
43
|
-
'Discontinued',
|
|
44
|
-
'OnlineOnly',
|
|
45
|
-
'InStoreOnly',
|
|
46
|
-
'LimitedAvailability',
|
|
47
|
-
'BackOrder',
|
|
48
|
-
];
|
|
49
|
-
var normalizeAvailability = function (val) {
|
|
50
|
-
if (!val)
|
|
51
|
-
return undefined;
|
|
52
|
-
// accept full https://schema.org/InStock or short 'InStock'
|
|
53
|
-
try {
|
|
54
|
-
var asUrl = String(val);
|
|
55
|
-
if (asUrl.startsWith('http')) {
|
|
56
|
-
var token = asUrl.replace(/https?:\/\/schema\.org\//i, '');
|
|
57
|
-
if (AVAILABILITIES.includes(token))
|
|
58
|
-
return "https://schema.org/".concat(token);
|
|
59
|
-
return undefined;
|
|
60
|
-
}
|
|
61
|
-
if (AVAILABILITIES.includes(asUrl))
|
|
62
|
-
return "https://schema.org/".concat(asUrl);
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
catch (_a) {
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
var generateCarouselSchema = function (_a) {
|
|
70
|
-
var name = _a.name, url = _a.url, items = _a.items, _b = _a.skipInvalidCurrency, skipInvalidCurrency = _b === void 0 ? false : _b;
|
|
71
|
-
var itemList = items.map(function (it, index) {
|
|
72
|
-
var itemObj = {
|
|
73
|
-
'@type': it.type || 'Thing',
|
|
74
|
-
name: it.name,
|
|
75
|
-
};
|
|
76
|
-
if (it.url)
|
|
77
|
-
itemObj.url = it.url;
|
|
78
|
-
if (it.id)
|
|
79
|
-
itemObj['@id'] = it.id;
|
|
80
|
-
var img = formatImage(it.image);
|
|
81
|
-
if (img)
|
|
82
|
-
itemObj.image = img;
|
|
83
|
-
if (it.description)
|
|
84
|
-
itemObj.description = it.description;
|
|
85
|
-
// offers: support multiple offers or single price fallback
|
|
86
|
-
if (it.offers && Array.isArray(it.offers) && it.offers.length > 0) {
|
|
87
|
-
var mapped = it.offers
|
|
88
|
-
.map(function (o) {
|
|
89
|
-
if (o.priceCurrency && !isValidCurrency(o.priceCurrency)) {
|
|
90
|
-
// either skip or throw depending on top-level option
|
|
91
|
-
return { __invalidCurrency: o.priceCurrency };
|
|
92
|
-
}
|
|
93
|
-
var offer = {
|
|
94
|
-
'@type': 'Offer',
|
|
95
|
-
};
|
|
96
|
-
if (o.price !== undefined)
|
|
97
|
-
offer.price = o.price;
|
|
98
|
-
if (o.priceCurrency)
|
|
99
|
-
offer.priceCurrency = o.priceCurrency;
|
|
100
|
-
if (o.availability) {
|
|
101
|
-
var norm = normalizeAvailability(o.availability);
|
|
102
|
-
if (norm)
|
|
103
|
-
offer.availability = norm;
|
|
104
|
-
// if invalid availability, skip the field silently
|
|
105
|
-
}
|
|
106
|
-
if (o.url)
|
|
107
|
-
offer.url = o.url;
|
|
108
|
-
if (o.priceValidUntil)
|
|
109
|
-
offer.priceValidUntil = o.priceValidUntil;
|
|
110
|
-
if (o.priceRange) {
|
|
111
|
-
var pr = o.priceRange;
|
|
112
|
-
offer.priceSpecification = __assign(__assign(__assign({ '@type': 'PriceSpecification' }, (pr.low != null && { minPrice: pr.low })), (pr.high != null && { maxPrice: pr.high })), (o.priceCurrency && { priceCurrency: o.priceCurrency }));
|
|
113
|
-
}
|
|
114
|
-
return offer;
|
|
115
|
-
})
|
|
116
|
-
.filter(function (x) { return x && !('__invalidCurrency' in x); });
|
|
117
|
-
// if any invalid currency markers were present and skipInvalidCurrency is false, throw
|
|
118
|
-
var hadInvalid = it.offers.some(function (o) { return o.priceCurrency && !isValidCurrency(o.priceCurrency); });
|
|
119
|
-
if (hadInvalid && !skipInvalidCurrency) {
|
|
120
|
-
var bad = it.offers.find(function (o) { return o.priceCurrency && !isValidCurrency(o.priceCurrency); });
|
|
121
|
-
throw new Error("Invalid currency code: ".concat(bad === null || bad === void 0 ? void 0 : bad.priceCurrency));
|
|
122
|
-
}
|
|
123
|
-
if (mapped.length > 0)
|
|
124
|
-
itemObj.offers = mapped;
|
|
125
|
-
}
|
|
126
|
-
else if (it.price !== undefined) {
|
|
127
|
-
if (it.priceCurrency && !isValidCurrency(it.priceCurrency)) {
|
|
128
|
-
if (!skipInvalidCurrency) {
|
|
129
|
-
throw new Error("Invalid currency code: ".concat(it.priceCurrency));
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
var offer = {
|
|
134
|
-
'@type': 'Offer',
|
|
135
|
-
price: it.price,
|
|
136
|
-
};
|
|
137
|
-
if (it.priceCurrency)
|
|
138
|
-
offer.priceCurrency = it.priceCurrency;
|
|
139
|
-
itemObj.offers = offer;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
if (it.aggregateRating) {
|
|
143
|
-
itemObj.aggregateRating = __assign(__assign(__assign({ '@type': 'AggregateRating', ratingValue: it.aggregateRating.ratingValue }, (it.aggregateRating.reviewCount != null && {
|
|
144
|
-
reviewCount: it.aggregateRating.reviewCount,
|
|
145
|
-
})), (it.aggregateRating.bestRating != null && {
|
|
146
|
-
bestRating: it.aggregateRating.bestRating,
|
|
147
|
-
})), (it.aggregateRating.worstRating != null && {
|
|
148
|
-
worstRating: it.aggregateRating.worstRating,
|
|
149
|
-
}));
|
|
150
|
-
}
|
|
151
|
-
return {
|
|
152
|
-
'@type': 'ListItem',
|
|
153
|
-
position: index + 1,
|
|
154
|
-
item: itemObj,
|
|
155
|
-
};
|
|
156
|
-
});
|
|
157
|
-
var schema = {
|
|
158
|
-
'@context': 'https://schema.org',
|
|
159
|
-
'@type': 'ItemList',
|
|
160
|
-
itemListElement: itemList,
|
|
161
|
-
};
|
|
162
|
-
if (name)
|
|
163
|
-
schema.name = name;
|
|
164
|
-
if (url) {
|
|
165
|
-
schema.mainEntityOfPage = {
|
|
166
|
-
'@type': 'WebPage',
|
|
167
|
-
'@id': url,
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
return schema;
|
|
171
|
-
};
|
|
172
|
-
exports.generateCarouselSchema = generateCarouselSchema;
|
|
1
|
+
var o=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var R=(r,i)=>{for(var a in i)o(r,a,{get:i[a],enumerable:!0})},w=(r,i,a,u)=>{if(i&&typeof i=="object"||typeof i=="function")for(let g of C(i))!b.call(r,g)&&g!==a&&o(r,g,{get:()=>i[g],enumerable:!(u=h(i,g))||u.enumerable});return r};var I=r=>w(o({},"__esModule",{value:!0}),r);var A={};R(A,{generateCarouselSchema:()=>S});module.exports=I(A);const v=r=>{if(r)return typeof r=="string"?r:{"@type":"ImageObject",url:r.url,...r.width&&{width:r.width},...r.height&&{height:r.height}}},f=r=>r?/^[A-Z]{3}$/.test(r):!1,d=["InStock","OutOfStock","PreOrder","PreSale","Discontinued","OnlineOnly","InStoreOnly","LimitedAvailability","BackOrder"],O=r=>{if(r)try{const i=String(r);if(i.startsWith("http")){const a=i.replace(/https?:\/\/schema\.org\//i,"");return d.includes(a)?`https://schema.org/${a}`:void 0}return d.includes(i)?`https://schema.org/${i}`:void 0}catch{return}},S=({name:r,url:i,items:a,skipInvalidCurrency:u=!1})=>{const p={"@context":"https://schema.org","@type":"ItemList",itemListElement:a.map((e,m)=>{const c={"@type":e.type||"Thing",name:e.name};e.url&&(c.url=e.url),e.id&&(c["@id"]=e.id);const y=v(e.image);if(y&&(c.image=y),e.description&&(c.description=e.description),e.offers&&Array.isArray(e.offers)&&e.offers.length>0){const l=e.offers.map(n=>{if(n.priceCurrency&&!f(n.priceCurrency))return{__invalidCurrency:n.priceCurrency};const t={"@type":"Offer"};if(n.price!==void 0&&(t.price=n.price),n.priceCurrency&&(t.priceCurrency=n.priceCurrency),n.availability){const s=O(n.availability);s&&(t.availability=s)}if(n.url&&(t.url=n.url),n.priceValidUntil&&(t.priceValidUntil=n.priceValidUntil),n.priceRange){const s=n.priceRange;t.priceSpecification={"@type":"PriceSpecification",...s.low!=null&&{minPrice:s.low},...s.high!=null&&{maxPrice:s.high},...n.priceCurrency&&{priceCurrency:n.priceCurrency}}}return t}).filter(n=>n&&!("__invalidCurrency"in n));if(e.offers.some(n=>n.priceCurrency&&!f(n.priceCurrency))&&!u){const n=e.offers.find(t=>t.priceCurrency&&!f(t.priceCurrency));throw new Error(`Invalid currency code: ${n?.priceCurrency}`)}l.length>0&&(c.offers=l)}else if(e.price!==void 0)if(e.priceCurrency&&!f(e.priceCurrency)){if(!u)throw new Error(`Invalid currency code: ${e.priceCurrency}`)}else{const l={"@type":"Offer",price:e.price};e.priceCurrency&&(l.priceCurrency=e.priceCurrency),c.offers=l}return e.aggregateRating&&(c.aggregateRating={"@type":"AggregateRating",ratingValue:e.aggregateRating.ratingValue,...e.aggregateRating.reviewCount!=null&&{reviewCount:e.aggregateRating.reviewCount},...e.aggregateRating.bestRating!=null&&{bestRating:e.aggregateRating.bestRating},...e.aggregateRating.worstRating!=null&&{worstRating:e.aggregateRating.worstRating}}),{"@type":"ListItem",position:m+1,item:c}})};return r&&(p.name=r),i&&(p.mainEntityOfPage={"@type":"WebPage","@id":i}),p};0&&(module.exports={generateCarouselSchema});
|
|
@@ -48,5 +48,6 @@ interface CourseSchema {
|
|
|
48
48
|
hasCourseInstance?: CourseInstance | CourseInstance[];
|
|
49
49
|
keywords?: string[];
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
declare const generateCourseSchema: ({ name, description, courseCode, educationalCredentialAwarded, provider, image, url, hasCourseInstance, keywords, }: CourseSchema) => any;
|
|
52
|
+
|
|
53
|
+
export { generateCourseSchema };
|
|
@@ -1,124 +1 @@
|
|
|
1
|
-
"
|
|
2
|
-
/**
|
|
3
|
-
* Generate schema.org `Course` JSON-LD.
|
|
4
|
-
*
|
|
5
|
-
* Accepts metadata for a course and optional `CourseInstance` objects
|
|
6
|
-
* including offers and locations. Provider can be a string or a structured
|
|
7
|
-
* object with `logo` support. Only provided fields are emitted.
|
|
8
|
-
*
|
|
9
|
-
* See `CourseSchema` and `CourseInstance` for field details.
|
|
10
|
-
* @returns A JSON-LD compatible `Course` object
|
|
11
|
-
*/
|
|
12
|
-
var __assign = (this && this.__assign) || function () {
|
|
13
|
-
__assign = Object.assign || function(t) {
|
|
14
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
15
|
-
s = arguments[i];
|
|
16
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
17
|
-
t[p] = s[p];
|
|
18
|
-
}
|
|
19
|
-
return t;
|
|
20
|
-
};
|
|
21
|
-
return __assign.apply(this, arguments);
|
|
22
|
-
};
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.generateCourseSchema = void 0;
|
|
25
|
-
var formatProvider = function (provider) {
|
|
26
|
-
if (typeof provider === 'string') {
|
|
27
|
-
return {
|
|
28
|
-
'@type': 'Organization',
|
|
29
|
-
name: provider,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
var out = {
|
|
33
|
-
'@type': 'Organization',
|
|
34
|
-
name: provider.name,
|
|
35
|
-
};
|
|
36
|
-
if (provider.url)
|
|
37
|
-
out.url = provider.url;
|
|
38
|
-
if (provider.logo) {
|
|
39
|
-
out.logo = __assign(__assign({ '@type': 'ImageObject', url: provider.logo.url }, (provider.logo.width && { width: provider.logo.width })), (provider.logo.height && { height: provider.logo.height }));
|
|
40
|
-
}
|
|
41
|
-
return out;
|
|
42
|
-
};
|
|
43
|
-
var formatImage = function (img) {
|
|
44
|
-
if (!img)
|
|
45
|
-
return undefined;
|
|
46
|
-
if (typeof img === 'string')
|
|
47
|
-
return img;
|
|
48
|
-
if (Array.isArray(img)) {
|
|
49
|
-
return img.map(function (i) {
|
|
50
|
-
return typeof i === 'string'
|
|
51
|
-
? i
|
|
52
|
-
: __assign(__assign({ '@type': 'ImageObject', url: i.url }, (i.width && { width: i.width })), (i.height && { height: i.height }));
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
return __assign(__assign({ '@type': 'ImageObject', url: img.url }, (img.width && { width: img.width })), (img.height && { height: img.height }));
|
|
56
|
-
};
|
|
57
|
-
var formatOffer = function (o) {
|
|
58
|
-
if (!o)
|
|
59
|
-
return undefined;
|
|
60
|
-
var mk = function (x) {
|
|
61
|
-
var out = { '@type': 'Offer' };
|
|
62
|
-
if (x.price !== undefined)
|
|
63
|
-
out.price = x.price;
|
|
64
|
-
if (x.priceCurrency)
|
|
65
|
-
out.priceCurrency = x.priceCurrency;
|
|
66
|
-
if (x.availability)
|
|
67
|
-
out.availability = x.availability;
|
|
68
|
-
if (x.url)
|
|
69
|
-
out.url = x.url;
|
|
70
|
-
return out;
|
|
71
|
-
};
|
|
72
|
-
if (Array.isArray(o))
|
|
73
|
-
return o.map(mk);
|
|
74
|
-
return mk(o);
|
|
75
|
-
};
|
|
76
|
-
var generateCourseSchema = function (_a) {
|
|
77
|
-
var name = _a.name, description = _a.description, courseCode = _a.courseCode, educationalCredentialAwarded = _a.educationalCredentialAwarded, provider = _a.provider, image = _a.image, url = _a.url, hasCourseInstance = _a.hasCourseInstance, keywords = _a.keywords;
|
|
78
|
-
var schema = {
|
|
79
|
-
'@context': 'https://schema.org',
|
|
80
|
-
'@type': 'Course',
|
|
81
|
-
name: name,
|
|
82
|
-
};
|
|
83
|
-
if (description)
|
|
84
|
-
schema.description = description;
|
|
85
|
-
if (courseCode)
|
|
86
|
-
schema.courseCode = courseCode;
|
|
87
|
-
if (educationalCredentialAwarded)
|
|
88
|
-
schema.educationalCredentialAwarded = educationalCredentialAwarded;
|
|
89
|
-
schema.provider = formatProvider(provider);
|
|
90
|
-
var img = formatImage(image);
|
|
91
|
-
if (img)
|
|
92
|
-
schema.image = img;
|
|
93
|
-
if (url)
|
|
94
|
-
schema.url = url;
|
|
95
|
-
if (keywords && keywords.length > 0)
|
|
96
|
-
schema.keywords = keywords.join(', ');
|
|
97
|
-
if (hasCourseInstance) {
|
|
98
|
-
var fmtInstance = function (inst) {
|
|
99
|
-
var out = { '@type': 'CourseInstance' };
|
|
100
|
-
if (inst.name)
|
|
101
|
-
out.name = inst.name;
|
|
102
|
-
if (inst.description)
|
|
103
|
-
out.description = inst.description;
|
|
104
|
-
if (inst.courseMode)
|
|
105
|
-
out.courseMode = inst.courseMode;
|
|
106
|
-
if (inst.startDate)
|
|
107
|
-
out.startDate = inst.startDate;
|
|
108
|
-
if (inst.endDate)
|
|
109
|
-
out.endDate = inst.endDate;
|
|
110
|
-
if (inst.location)
|
|
111
|
-
out.location = inst.location;
|
|
112
|
-
var offers = formatOffer(inst.offers);
|
|
113
|
-
if (offers)
|
|
114
|
-
out.offers = offers;
|
|
115
|
-
return out;
|
|
116
|
-
};
|
|
117
|
-
if (Array.isArray(hasCourseInstance))
|
|
118
|
-
schema.hasCourseInstance = hasCourseInstance.map(fmtInstance);
|
|
119
|
-
else
|
|
120
|
-
schema.hasCourseInstance = fmtInstance(hasCourseInstance);
|
|
121
|
-
}
|
|
122
|
-
return schema;
|
|
123
|
-
};
|
|
124
|
-
exports.generateCourseSchema = generateCourseSchema;
|
|
1
|
+
var c=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var I=(e,r)=>{for(var t in r)c(e,t,{get:r[t],enumerable:!0})},O=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of C(r))!p.call(e,o)&&o!==t&&c(e,o,{get:()=>r[o],enumerable:!(i=m(r,o))||i.enumerable});return e};var b=e=>O(c({},"__esModule",{value:!0}),e);var M={};I(M,{generateCourseSchema:()=>j});module.exports=b(M);const w=e=>{if(typeof e=="string")return{"@type":"Organization",name:e};const r={"@type":"Organization",name:e.name};return e.url&&(r.url=e.url),e.logo&&(r.logo={"@type":"ImageObject",url:e.logo.url,...e.logo.width&&{width:e.logo.width},...e.logo.height&&{height:e.logo.height}}),r},A=e=>{if(e)return typeof e=="string"?e:Array.isArray(e)?e.map(r=>typeof r=="string"?r:{"@type":"ImageObject",url:r.url,...r.width&&{width:r.width},...r.height&&{height:r.height}}):{"@type":"ImageObject",url:e.url,...e.width&&{width:e.width},...e.height&&{height:e.height}}},D=e=>{if(!e)return;const r=t=>{const i={"@type":"Offer"};return t.price!==void 0&&(i.price=t.price),t.priceCurrency&&(i.priceCurrency=t.priceCurrency),t.availability&&(i.availability=t.availability),t.url&&(i.url=t.url),i};return Array.isArray(e)?e.map(r):r(e)},j=({name:e,description:r,courseCode:t,educationalCredentialAwarded:i,provider:o,image:y,url:g,hasCourseInstance:u,keywords:f})=>{const a={"@context":"https://schema.org","@type":"Course",name:e};r&&(a.description=r),t&&(a.courseCode=t),i&&(a.educationalCredentialAwarded=i),a.provider=w(o);const l=A(y);if(l&&(a.image=l),g&&(a.url=g),f&&f.length>0&&(a.keywords=f.join(", ")),u){const h=n=>{const s={"@type":"CourseInstance"};n.name&&(s.name=n.name),n.description&&(s.description=n.description),n.courseMode&&(s.courseMode=n.courseMode),n.startDate&&(s.startDate=n.startDate),n.endDate&&(s.endDate=n.endDate),n.location&&(s.location=n.location);const d=D(n.offers);return d&&(s.offers=d),s};Array.isArray(u)?a.hasCourseInstance=u.map(h):a.hasCourseInstance=h(u)}return a};0&&(module.exports={generateCourseSchema});
|
|
@@ -60,5 +60,6 @@ interface DatasetOptions {
|
|
|
60
60
|
skipInvalidEncoding?: boolean;
|
|
61
61
|
datasets?: DatasetOptions[];
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
declare const generateDatasetSchema: ({ type, name, description, url, datePublished, dateModified, publisher, keywords, license, version, variableMeasured, spatialCoverage, distribution, datasets, skipInvalidEncoding, }: DatasetOptions) => any;
|
|
64
|
+
|
|
65
|
+
export { generateDatasetSchema };
|
|
@@ -1,156 +1 @@
|
|
|
1
|
-
"
|
|
2
|
-
/**
|
|
3
|
-
* Generate schema.org JSON-LD for `Dataset`, `DataCatalog`, or
|
|
4
|
-
* `DataDownload` distributions.
|
|
5
|
-
*
|
|
6
|
-
* Supports publisher formatting, distribution normalization (including
|
|
7
|
-
* encoding format validation with `skipInvalidEncoding`), variable
|
|
8
|
-
* measurement metadata and nested datasets for `DataCatalog`.
|
|
9
|
-
*
|
|
10
|
-
* See `DatasetOptions` for the input shape and available flags.
|
|
11
|
-
* @returns A JSON-LD compatible `Dataset` or `DataCatalog` 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.generateDatasetSchema = void 0;
|
|
26
|
-
var formatPublisher = function (p) {
|
|
27
|
-
if (typeof p === 'string')
|
|
28
|
-
return { '@type': 'Organization', name: p };
|
|
29
|
-
var out = { '@type': 'Organization', name: p.name };
|
|
30
|
-
if (p.url)
|
|
31
|
-
out.url = p.url;
|
|
32
|
-
if (p.logo) {
|
|
33
|
-
out.logo = { '@type': 'ImageObject', url: p.logo.url };
|
|
34
|
-
if (p.logo.width)
|
|
35
|
-
out.logo.width = p.logo.width;
|
|
36
|
-
if (p.logo.height)
|
|
37
|
-
out.logo.height = p.logo.height;
|
|
38
|
-
}
|
|
39
|
-
return out;
|
|
40
|
-
};
|
|
41
|
-
var formatDistribution = function (d, skipInvalidEncoding) {
|
|
42
|
-
if (skipInvalidEncoding === void 0) { skipInvalidEncoding = false; }
|
|
43
|
-
var out = {
|
|
44
|
-
'@type': 'DataDownload',
|
|
45
|
-
contentUrl: d.contentUrl,
|
|
46
|
-
};
|
|
47
|
-
if (d.name)
|
|
48
|
-
out.name = d.name;
|
|
49
|
-
if (d.encodingFormat) {
|
|
50
|
-
var enc = normalizeEncodingFormat(d.encodingFormat, skipInvalidEncoding);
|
|
51
|
-
if (enc)
|
|
52
|
-
out.encodingFormat = enc;
|
|
53
|
-
}
|
|
54
|
-
if (d.byteSize != null)
|
|
55
|
-
out.byteSize = d.byteSize;
|
|
56
|
-
if (d.datePublished)
|
|
57
|
-
out.datePublished = d.datePublished;
|
|
58
|
-
if (d.license)
|
|
59
|
-
out.license = d.license;
|
|
60
|
-
if (d.measurementTechnique)
|
|
61
|
-
out.measurementTechnique = d.measurementTechnique;
|
|
62
|
-
return out;
|
|
63
|
-
};
|
|
64
|
-
var ENCODING_ALIASES = {
|
|
65
|
-
csv: 'text/csv',
|
|
66
|
-
json: 'application/json',
|
|
67
|
-
geojson: 'application/geo+json',
|
|
68
|
-
xml: 'application/xml',
|
|
69
|
-
txt: 'text/plain',
|
|
70
|
-
zip: 'application/zip',
|
|
71
|
-
gzip: 'application/gzip',
|
|
72
|
-
};
|
|
73
|
-
var isValidMime = function (v) {
|
|
74
|
-
return /^[a-z0-9!#$&.+\-_]+\/[a-z0-9!#$&.+\-_]+$/i.test(v);
|
|
75
|
-
};
|
|
76
|
-
var normalizeEncodingFormat = function (val, skipInvalid) {
|
|
77
|
-
if (skipInvalid === void 0) { skipInvalid = false; }
|
|
78
|
-
if (!val)
|
|
79
|
-
return undefined;
|
|
80
|
-
var s = String(val).trim();
|
|
81
|
-
var lower = s.toLowerCase();
|
|
82
|
-
if (ENCODING_ALIASES[lower])
|
|
83
|
-
return ENCODING_ALIASES[lower];
|
|
84
|
-
if (isValidMime(s))
|
|
85
|
-
return s;
|
|
86
|
-
if (skipInvalid)
|
|
87
|
-
return undefined;
|
|
88
|
-
throw new Error("Invalid encodingFormat: ".concat(val));
|
|
89
|
-
};
|
|
90
|
-
var generateDatasetSchema = function (_a) {
|
|
91
|
-
var _b = _a.type, type = _b === void 0 ? 'Dataset' : _b, name = _a.name, description = _a.description, url = _a.url, datePublished = _a.datePublished, dateModified = _a.dateModified, publisher = _a.publisher, keywords = _a.keywords, license = _a.license, version = _a.version, variableMeasured = _a.variableMeasured, spatialCoverage = _a.spatialCoverage, distribution = _a.distribution, datasets = _a.datasets,
|
|
92
|
-
// citation,
|
|
93
|
-
// funding,
|
|
94
|
-
_c = _a.skipInvalidEncoding,
|
|
95
|
-
// citation,
|
|
96
|
-
// funding,
|
|
97
|
-
skipInvalidEncoding = _c === void 0 ? false : _c;
|
|
98
|
-
if (type === 'DataCatalog') {
|
|
99
|
-
var catalog = {
|
|
100
|
-
'@context': 'https://schema.org',
|
|
101
|
-
'@type': 'DataCatalog',
|
|
102
|
-
};
|
|
103
|
-
if (name)
|
|
104
|
-
catalog.name = name;
|
|
105
|
-
if (description)
|
|
106
|
-
catalog.description = description;
|
|
107
|
-
if (url)
|
|
108
|
-
catalog.url = url;
|
|
109
|
-
if (publisher)
|
|
110
|
-
catalog.publisher = formatPublisher(publisher);
|
|
111
|
-
if (keywords && keywords.length)
|
|
112
|
-
catalog.keywords = keywords.join(', ');
|
|
113
|
-
if (datasets && Array.isArray(datasets)) {
|
|
114
|
-
catalog.dataset = datasets.map(function (ds) {
|
|
115
|
-
var out = (0, exports.generateDatasetSchema)(__assign(__assign({}, ds), { type: 'Dataset', skipInvalidEncoding: skipInvalidEncoding }));
|
|
116
|
-
return out;
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
return catalog;
|
|
120
|
-
}
|
|
121
|
-
// default Dataset
|
|
122
|
-
var schema = {
|
|
123
|
-
'@context': 'https://schema.org',
|
|
124
|
-
'@type': 'Dataset',
|
|
125
|
-
};
|
|
126
|
-
if (name)
|
|
127
|
-
schema.name = name;
|
|
128
|
-
if (description)
|
|
129
|
-
schema.description = description;
|
|
130
|
-
if (url)
|
|
131
|
-
schema.url = url;
|
|
132
|
-
if (datePublished)
|
|
133
|
-
schema.datePublished = datePublished;
|
|
134
|
-
if (dateModified)
|
|
135
|
-
schema.dateModified = dateModified;
|
|
136
|
-
if (publisher)
|
|
137
|
-
schema.publisher = formatPublisher(publisher);
|
|
138
|
-
if (keywords && keywords.length)
|
|
139
|
-
schema.keywords = keywords.join(', ');
|
|
140
|
-
if (license)
|
|
141
|
-
schema.license = license;
|
|
142
|
-
if (version)
|
|
143
|
-
schema.version = version;
|
|
144
|
-
if (variableMeasured)
|
|
145
|
-
schema.variableMeasured = variableMeasured;
|
|
146
|
-
if (spatialCoverage)
|
|
147
|
-
schema.spatialCoverage = spatialCoverage;
|
|
148
|
-
if (distribution) {
|
|
149
|
-
var dists = Array.isArray(distribution) ? distribution : [distribution];
|
|
150
|
-
schema.distribution = dists.map(function (d) {
|
|
151
|
-
return formatDistribution(d, skipInvalidEncoding);
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
return schema;
|
|
155
|
-
};
|
|
156
|
-
exports.generateDatasetSchema = generateDatasetSchema;
|
|
1
|
+
var f=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var j=(t,i)=>{for(var n in i)f(t,n,{get:i[n],enumerable:!0})},w=(t,i,n,e)=>{if(i&&typeof i=="object"||typeof i=="function")for(let s of A(i))!S.call(t,s)&&s!==n&&f(t,s,{get:()=>i[s],enumerable:!(e=x(i,s))||e.enumerable});return t};var O=t=>w(f({},"__esModule",{value:!0}),t);var T={};j(T,{generateDatasetSchema:()=>P});module.exports=O(T);const D=t=>{if(typeof t=="string")return{"@type":"Organization",name:t};const i={"@type":"Organization",name:t.name};return t.url&&(i.url=t.url),t.logo&&(i.logo={"@type":"ImageObject",url:t.logo.url},t.logo.width&&(i.logo.width=t.logo.width),t.logo.height&&(i.logo.height=t.logo.height)),i},C=(t,i=!1)=>{const n={"@type":"DataDownload",contentUrl:t.contentUrl};if(t.name&&(n.name=t.name),t.encodingFormat){const e=v(t.encodingFormat,i);e&&(n.encodingFormat=e)}return t.byteSize!=null&&(n.byteSize=t.byteSize),t.datePublished&&(n.datePublished=t.datePublished),t.license&&(n.license=t.license),t.measurementTechnique&&(n.measurementTechnique=t.measurementTechnique),n},z={csv:"text/csv",json:"application/json",geojson:"application/geo+json",xml:"application/xml",txt:"text/plain",zip:"application/zip",gzip:"application/gzip"},F=t=>/^[a-z0-9!#$&.+\-_]+\/[a-z0-9!#$&.+\-_]+$/i.test(t),v=(t,i=!1)=>{if(!t)return;const n=String(t).trim(),e=n.toLowerCase();if(z[e])return z[e];if(F(n))return n;if(!i)throw new Error(`Invalid encodingFormat: ${t}`)},P=({type:t="Dataset",name:i,description:n,url:e,datePublished:s,dateModified:m,publisher:g,keywords:o,license:h,version:b,variableMeasured:y,spatialCoverage:p,distribution:l,datasets:u,skipInvalidEncoding:d=!1})=>{if(t==="DataCatalog"){const a={"@context":"https://schema.org","@type":"DataCatalog"};return i&&(a.name=i),n&&(a.description=n),e&&(a.url=e),g&&(a.publisher=D(g)),o&&o.length&&(a.keywords=o.join(", ")),u&&Array.isArray(u)&&(a.dataset=u.map(c=>P({...c,type:"Dataset",skipInvalidEncoding:d}))),a}const r={"@context":"https://schema.org","@type":"Dataset"};if(i&&(r.name=i),n&&(r.description=n),e&&(r.url=e),s&&(r.datePublished=s),m&&(r.dateModified=m),g&&(r.publisher=D(g)),o&&o.length&&(r.keywords=o.join(", ")),h&&(r.license=h),b&&(r.version=b),y&&(r.variableMeasured=y),p&&(r.spatialCoverage=p),l){const a=Array.isArray(l)?l:[l];r.distribution=a.map(c=>C(c,d))}return r};0&&(module.exports={generateDatasetSchema});
|