@react-pakistan/util-functions 2.0.2 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constants/api-methods.d.mts +13 -0
- package/constants/api-methods.mjs +1 -0
- package/constants/cache-time.d.mts +7 -0
- package/constants/cache-time.mjs +1 -0
- package/constants/countries-timezones.d.mts +8 -0
- package/constants/countries-timezones.mjs +1 -0
- package/constants/currencies.d.mts +14 -0
- package/constants/currencies.mjs +1 -0
- package/constants/dial-codes.d.mts +9 -0
- package/constants/dial-codes.mjs +1 -0
- package/constants/layout-direction.d.mts +6 -0
- package/constants/layout-direction.mjs +1 -0
- package/constants/react-pakistan-meta.d.mts +32 -0
- package/constants/react-pakistan-meta.mjs +1 -0
- package/constants/react-pakistan.d.mts +15 -0
- package/constants/react-pakistan.mjs +12 -0
- package/constants/select-value-delimiter.d.mts +12 -0
- package/constants/select-value-delimiter.mjs +1 -0
- package/constants/social-media-colors.d.mts +40 -0
- package/constants/social-media-colors.mjs +1 -0
- package/constants/social-media-sizes.d.mts +323 -0
- package/constants/social-media-sizes.mjs +1 -0
- package/constants/user-roles.d.mts +7 -0
- package/constants/user-roles.mjs +1 -0
- package/factory/generic-component-factory.d.mts +78 -0
- package/factory/generic-component-factory.mjs +1 -0
- package/factory/generic-module-factory.d.mts +80 -0
- package/factory/generic-module-factory.mjs +1 -0
- package/general/basic-get.d.mts +8 -0
- package/general/basic-get.mjs +1 -0
- package/general/basic-post.d.mts +8 -0
- package/general/basic-post.mjs +1 -0
- package/general/calculate-pages.d.mts +9 -0
- package/general/calculate-pages.mjs +1 -0
- package/general/camel-to-sentence-case.d.mts +12 -0
- package/general/camel-to-sentence-case.mjs +1 -0
- package/general/check-even-odd-length.d.mts +13 -0
- package/general/check-even-odd-length.mjs +1 -0
- package/general/clear-cache.d.mts +10 -0
- package/general/clear-cache.mjs +1 -0
- package/general/cnic-formatter.d.mts +20 -0
- package/general/cnic-formatter.mjs +1 -0
- package/general/convert-url-to-base64.d.mts +57 -0
- package/general/convert-url-to-base64.mjs +1 -0
- package/general/countries.d.mts +268 -0
- package/general/countries.mjs +1 -0
- package/general/create-date.d.mts +12 -0
- package/general/create-date.js +1 -1
- package/general/create-date.mjs +1 -0
- package/general/crypto.d.mts +11 -0
- package/general/crypto.mjs +1 -0
- package/general/currencies.d.mts +2 -0
- package/general/currencies.mjs +0 -0
- package/general/delete-image-from-private-supabase.d.mts +16 -0
- package/general/delete-image-from-private-supabase.mjs +1 -0
- package/general/delete-image-from-public-supabase.d.mts +16 -0
- package/general/delete-image-from-public-supabase.mjs +1 -0
- package/general/download-from-url.d.mts +8 -0
- package/general/download-from-url.mjs +1 -0
- package/general/dynamic-page-limit.d.mts +12 -0
- package/general/dynamic-page-limit.mjs +1 -0
- package/general/enum-to-text.d.mts +8 -0
- package/general/enum-to-text.mjs +1 -0
- package/general/fetch-data.d.mts +25 -0
- package/general/fetch-data.mjs +1 -0
- package/general/fetch-supabase-image.d.mts +16 -0
- package/general/fetch-supabase-image.mjs +1 -0
- package/general/fetch-supabase-private-assets.d.mts +15 -0
- package/general/fetch-supabase-private-assets.mjs +1 -0
- package/general/format-date.d.mts +18 -0
- package/general/format-date.mjs +1 -0
- package/general/format-number.d.mts +16 -0
- package/general/format-number.mjs +1 -0
- package/general/format-phone-display.d.mts +9 -0
- package/general/format-phone-display.js +1 -1
- package/general/format-phone-display.mjs +1 -0
- package/general/format-phone.d.mts +13 -0
- package/general/format-phone.d.ts +1 -3
- package/general/format-phone.js +1 -1
- package/general/format-phone.mjs +1 -0
- package/general/format-pricing.d.mts +8 -0
- package/general/format-pricing.mjs +1 -0
- package/general/format-secs.d.mts +8 -0
- package/general/format-secs.mjs +1 -0
- package/general/format-time.d.mts +11 -0
- package/general/format-time.mjs +1 -0
- package/general/format-value.d.mts +8 -0
- package/general/format-value.mjs +1 -0
- package/general/full-month-range.d.mts +13 -0
- package/general/full-month-range.mjs +1 -0
- package/general/full-year-range.d.mts +12 -0
- package/general/full-year-range.mjs +1 -0
- package/general/generate-article-schema.d.mts +50 -0
- package/general/generate-article-schema.mjs +1 -0
- package/general/generate-blog-schema.d.mts +37 -0
- package/general/generate-blog-schema.mjs +1 -0
- package/general/generate-book-schema.d.mts +58 -0
- package/general/generate-book-schema.mjs +1 -0
- package/general/generate-breadcrumb-schema.d.mts +40 -0
- package/general/generate-breadcrumb-schema.mjs +1 -0
- package/general/generate-carousel-schema.d.mts +52 -0
- package/general/generate-carousel-schema.mjs +1 -0
- package/general/generate-course-schema.d.mts +53 -0
- package/general/generate-course-schema.mjs +1 -0
- package/general/generate-dataset-schema.d.mts +65 -0
- package/general/generate-dataset-schema.mjs +1 -0
- package/general/generate-discussion-forum-schema.d.mts +39 -0
- package/general/generate-discussion-forum-schema.mjs +1 -0
- package/general/generate-education-schema.d.mts +68 -0
- package/general/generate-education-schema.mjs +1 -0
- package/general/generate-employer-aggregate-rating-schema.d.mts +29 -0
- package/general/generate-employer-aggregate-rating-schema.mjs +1 -0
- package/general/generate-event-schema.d.mts +63 -0
- package/general/generate-event-schema.mjs +1 -0
- package/general/generate-faq-schema.d.mts +32 -0
- package/general/generate-faq-schema.mjs +1 -0
- package/general/generate-grid.d.mts +17 -0
- package/general/generate-grid.mjs +1 -0
- package/general/generate-image-metadata-schema.d.mts +36 -0
- package/general/generate-image-metadata-schema.mjs +1 -0
- package/general/generate-job-posting-schema.d.mts +49 -0
- package/general/generate-job-posting-schema.mjs +1 -0
- package/general/generate-local-business-schema.d.mts +42 -0
- package/general/generate-local-business-schema.mjs +1 -0
- package/general/generate-math-solver-schema.d.mts +45 -0
- package/general/generate-math-solver-schema.mjs +1 -0
- package/general/generate-movie-carousel-schema.d.mts +51 -0
- package/general/generate-movie-carousel-schema.mjs +1 -0
- package/general/generate-organization-schema.d.mts +49 -0
- package/general/generate-organization-schema.mjs +1 -0
- package/general/generate-profile-page-schema.d.mts +37 -0
- package/general/generate-profile-page-schema.mjs +1 -0
- package/general/generate-qa-page-schema.d.mts +34 -0
- package/general/generate-qa-page-schema.mjs +1 -0
- package/general/generate-recipe-schema.d.mts +49 -0
- package/general/generate-recipe-schema.mjs +1 -0
- package/general/generate-ref.d.mts +11 -0
- package/general/generate-ref.js +1 -1
- package/general/generate-ref.mjs +1 -0
- package/general/generate-review-snippet-schema.d.mts +52 -0
- package/general/generate-review-snippet-schema.mjs +1 -0
- package/general/generate-shopping-loyalty-program-schema.d.mts +38 -0
- package/general/generate-shopping-loyalty-program-schema.mjs +1 -0
- package/general/generate-shopping-merchant-listing-schema.d.mts +53 -0
- package/general/generate-shopping-merchant-listing-schema.mjs +1 -0
- package/general/generate-shopping-merchant-return-policy-schema.d.mts +32 -0
- package/general/generate-shopping-merchant-return-policy-schema.mjs +1 -0
- package/general/generate-shopping-merchant-shipping-policy-schema.d.mts +36 -0
- package/general/generate-shopping-merchant-shipping-policy-schema.mjs +1 -0
- package/general/generate-shopping-overview-schema.d.mts +52 -0
- package/general/generate-shopping-overview-schema.mjs +1 -0
- package/general/generate-shopping-product-snippet-schema.d.mts +57 -0
- package/general/generate-shopping-product-snippet-schema.mjs +1 -0
- package/general/generate-shopping-variants-schema.d.mts +46 -0
- package/general/generate-shopping-variants-schema.mjs +1 -0
- package/general/generate-software-app-schema.d.mts +62 -0
- package/general/generate-software-app-schema.mjs +1 -0
- package/general/generate-speakable-schema.d.mts +64 -0
- package/general/generate-speakable-schema.mjs +1 -0
- package/general/generate-subscription-schema.d.mts +60 -0
- package/general/generate-subscription-schema.mjs +1 -0
- package/general/generate-vacation-rental-schema.d.mts +67 -0
- package/general/generate-vacation-rental-schema.mjs +1 -0
- package/general/generate-video-schema.d.mts +75 -0
- package/general/generate-video-schema.mjs +1 -0
- package/general/generic-cache.d.mts +193 -0
- package/general/generic-cache.mjs +1 -0
- package/general/get-available-page-limit.d.mts +11 -0
- package/general/get-available-page-limit.mjs +1 -0
- package/general/get-calendar-current-month.d.mts +15 -0
- package/general/get-calendar-current-month.js +1 -1
- package/general/get-calendar-current-month.mjs +1 -0
- package/general/get-calendar-dates.d.mts +15 -0
- package/general/get-calendar-dates.js +1 -1
- package/general/get-calendar-dates.mjs +1 -0
- package/general/get-calendar-next-month.d.mts +17 -0
- package/general/get-calendar-next-month.js +1 -1
- package/general/get-calendar-next-month.mjs +1 -0
- package/general/get-calendar-previous-month.d.mts +17 -0
- package/general/get-calendar-previous-month.js +1 -1
- package/general/get-calendar-previous-month.mjs +1 -0
- package/general/get-current-year.d.mts +7 -0
- package/general/get-current-year.mjs +1 -0
- package/general/get-day-name.d.mts +10 -0
- package/general/get-day-name.mjs +1 -0
- package/general/get-dial-code.d.mts +8 -0
- package/general/get-dial-code.mjs +1 -0
- package/general/get-full-name.d.mts +13 -0
- package/general/get-full-name.mjs +1 -0
- package/general/get-href.d.mts +11 -0
- package/general/get-href.mjs +1 -0
- package/general/get-month-name.d.mts +10 -0
- package/general/get-month-name.mjs +1 -0
- package/general/get-month-number.d.mts +15 -0
- package/general/get-month-number.mjs +1 -0
- package/general/get-number-of-days-in-month.d.mts +13 -0
- package/general/get-number-of-days-in-month.js +1 -1
- package/general/get-number-of-days-in-month.mjs +1 -0
- package/general/get-pathname.d.mts +11 -0
- package/general/get-pathname.mjs +1 -0
- package/general/get-week-day.d.mts +8 -0
- package/general/get-week-day.js +1 -1
- package/general/get-week-day.mjs +1 -0
- package/general/image-url-to-base64.d.mts +9 -0
- package/general/image-url-to-base64.mjs +1 -0
- package/general/is-created-or-updated.d.mts +13 -0
- package/general/is-created-or-updated.mjs +1 -0
- package/general/is-next-button-disabled.d.mts +9 -0
- package/general/is-next-button-disabled.mjs +1 -0
- package/general/is-odd.d.mts +11 -0
- package/general/is-odd.mjs +1 -0
- package/general/is-previous-button-disabled.d.mts +8 -0
- package/general/is-previous-button-disabled.mjs +1 -0
- package/general/linear-gradients.d.mts +14 -0
- package/general/linear-gradients.mjs +1 -0
- package/general/multi-part-search.d.mts +22 -0
- package/general/multi-part-search.mjs +1 -0
- package/general/normalize-phone.d.mts +15 -0
- package/general/normalize-phone.js +1 -1
- package/general/normalize-phone.mjs +1 -0
- package/general/parse-frontmatter.d.mts +36 -0
- package/general/parse-frontmatter.mjs +2 -0
- package/general/remove-data-image-prefix.d.mts +8 -0
- package/general/remove-data-image-prefix.mjs +1 -0
- package/general/repeat-times.d.mts +15 -0
- package/general/repeat-times.mjs +1 -0
- package/general/resolve-anchor-link.d.mts +13 -0
- package/general/resolve-anchor-link.mjs +1 -0
- package/general/resolve-current-date.d.mts +12 -0
- package/general/resolve-current-date.mjs +1 -0
- package/general/resolve-grid.d.mts +14 -0
- package/general/resolve-grid.mjs +1 -0
- package/general/resolve-initials.d.mts +12 -0
- package/general/resolve-initials.mjs +1 -0
- package/general/set-timezone.d.mts +9 -0
- package/general/set-timezone.d.ts +1 -3
- package/general/set-timezone.js +1 -1
- package/general/set-timezone.mjs +1 -0
- package/general/slugify.d.mts +12 -0
- package/general/slugify.mjs +1 -0
- package/general/text-to-enum.d.mts +8 -0
- package/general/text-to-enum.mjs +1 -0
- package/general/text-to-sentence-case.d.mts +12 -0
- package/general/text-to-sentence-case.mjs +1 -0
- package/general/time-out.d.mts +12 -0
- package/general/time-out.mjs +1 -0
- package/general/time-zones.d.mts +11 -0
- package/general/time-zones.mjs +1 -0
- package/general/truncate-text.d.mts +14 -0
- package/general/truncate-text.mjs +1 -0
- package/general/type.d.mts +8 -0
- package/general/type.mjs +0 -0
- package/general/upload-blob-to-private-supabase.d.mts +24 -0
- package/general/upload-blob-to-private-supabase.mjs +1 -0
- package/general/upload-blob-to-public-supabase.d.mts +24 -0
- package/general/upload-blob-to-public-supabase.mjs +1 -0
- package/general/upload-image-to-private-supabase.d.mts +26 -0
- package/general/upload-image-to-private-supabase.mjs +1 -0
- package/general/upload-image-to-public-supabase.d.mts +26 -0
- package/general/upload-image-to-public-supabase.mjs +1 -0
- package/general/url-to-sentence-case.d.mts +12 -0
- package/general/url-to-sentence-case.mjs +1 -0
- package/general/validate-comment.d.mts +14 -0
- package/general/validate-comment.mjs +1 -0
- package/general/validate-email.d.mts +15 -0
- package/general/validate-email.mjs +1 -0
- package/general/validate-form.d.mts +18 -0
- package/general/validate-form.mjs +1 -0
- package/general/validate-name.d.mts +14 -0
- package/general/validate-name.mjs +1 -0
- package/hooks/use-change.d.mts +11 -0
- package/hooks/use-change.mjs +1 -0
- package/hooks/use-debounce.d.mts +10 -0
- package/hooks/use-debounce.mjs +1 -0
- package/hooks/use-fetch.d.mts +42 -0
- package/hooks/use-fetch.mjs +1 -0
- package/hooks/use-force-render.d.mts +14 -0
- package/hooks/use-force-render.mjs +1 -0
- package/hooks/use-ip-geo-location.d.mts +12 -0
- package/hooks/use-ip-geo-location.mjs +1 -0
- package/hooks/use-is-mobile.d.mts +8 -0
- package/hooks/use-is-mobile.mjs +1 -0
- package/hooks/use-module-entity-v2.d.mts +105 -0
- package/hooks/use-module-entity-v2.mjs +1 -0
- package/hooks/use-module-entity.d.mts +98 -0
- package/hooks/use-module-entity.mjs +1 -0
- package/hooks/use-phone-formatter.d.mts +17 -0
- package/hooks/use-phone-formatter.d.ts +1 -3
- package/hooks/use-phone-formatter.js +1 -1
- package/hooks/use-phone-formatter.mjs +1 -0
- package/hooks/use-position.d.mts +29 -0
- package/hooks/use-position.mjs +1 -0
- package/hooks/use-rtl.d.mts +46 -0
- package/hooks/use-rtl.mjs +1 -0
- package/hooks/use-sticky.d.mts +13 -0
- package/hooks/use-sticky.mjs +1 -0
- package/hooks/use-toggle-state.d.mts +14 -0
- package/hooks/use-toggle-state.mjs +1 -0
- package/hooks/use-window-event-listener.d.mts +9 -0
- package/hooks/use-window-event-listener.mjs +1 -0
- package/hooks/with-seo.d.mts +19 -0
- package/hooks/with-seo.mjs +1 -0
- package/local-storage/get-storage-value.d.mts +5 -0
- package/local-storage/get-storage-value.mjs +1 -0
- package/local-storage/remove-storage-value.d.mts +3 -0
- package/local-storage/remove-storage-value.mjs +1 -0
- package/local-storage/set-storage-value.d.mts +3 -0
- package/local-storage/set-storage-value.mjs +1 -0
- package/local-storage/type.d.mts +3 -0
- package/local-storage/type.mjs +0 -0
- package/npm.d.d.mts +2 -0
- package/npm.d.mjs +0 -0
- package/package.json +1 -10
- package/edu-pilot-pro/types/academics.d.ts +0 -2
- package/edu-pilot-pro/types/academics.js +0 -1
- package/edu-pilot-pro/types/admission.d.ts +0 -878
- package/edu-pilot-pro/types/admission.js +0 -1
- package/edu-pilot-pro/types/communication.d.ts +0 -2
- package/edu-pilot-pro/types/communication.js +0 -1
- package/edu-pilot-pro/types/enums.d.ts +0 -413
- package/edu-pilot-pro/types/enums.js +0 -1
- package/edu-pilot-pro/types/finance.d.ts +0 -2
- package/edu-pilot-pro/types/finance.js +0 -1
- package/edu-pilot-pro/types/index.d.ts +0 -2
- package/edu-pilot-pro/types/index.js +0 -1
- package/edu-pilot-pro/types/user-management.d.ts +0 -2
- package/edu-pilot-pro/types/user-management.js +0 -1
- package/stellar-solution/types/common.d.ts +0 -26
- package/stellar-solution/types/common.js +0 -1
- package/stellar-solution/types/erp.d.ts +0 -305
- package/stellar-solution/types/erp.js +0 -1
- package/stellar-solution/types/index.d.ts +0 -3
- package/stellar-solution/types/index.js +0 -1
- package/stellar-solution/types/pos.d.ts +0 -179
- package/stellar-solution/types/pos.js +0 -1
- package/storybook/generate-sitemap.d.ts +0 -16
- package/storybook/generate-sitemap.js +0 -17
- package/storybook/preview.d.ts +0 -148
- package/storybook/preview.js +0 -1
- package/storybook/react-design-story-script.d.ts +0 -12
- package/storybook/react-design-story-script.js +0 -5
- package/storybook/react-emoji-collection.d.ts +0 -13
- package/storybook/react-emoji-collection.js +0 -11
- package/storybook/react-emoji-story-script.d.ts +0 -12
- package/storybook/react-emoji-story-script.js +0 -5
- package/storybook/react-emoji-story-template.d.ts +0 -14
- package/storybook/react-emoji-story-template.js +0 -46
- package/storybook/react-icon-collection.d.ts +0 -13
- package/storybook/react-icon-collection.js +0 -11
- package/storybook/react-icon-story-script.d.ts +0 -12
- package/storybook/react-icon-story-script.js +0 -5
- package/storybook/react-icon-story-template.d.ts +0 -13
- package/storybook/react-icon-story-template.js +0 -46
- package/storybook/react-logo-collection.d.ts +0 -13
- package/storybook/react-logo-collection.js +0 -11
- package/storybook/react-logo-story-script.d.ts +0 -12
- package/storybook/react-logo-story-script.js +0 -5
- package/storybook/react-logo-story-template.d.ts +0 -13
- package/storybook/react-logo-story-template.js +0 -46
- package/storybook/react-pakistan-theme.d.ts +0 -25
- package/storybook/react-pakistan-theme.js +0 -1
- package/storybook/responsive-args.d.ts +0 -22
- package/storybook/responsive-args.js +0 -1
- package/storybook/responsive-component.d.ts +0 -33
- package/storybook/responsive-component.js +0 -37
- package/storybook/responsive-screens.d.ts +0 -108
- package/storybook/responsive-screens.js +0 -1
- package/storybook/theme.d.ts +0 -96
- package/storybook/theme.js +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface FormattedPhoneNumber {
|
|
2
|
+
e164: string;
|
|
3
|
+
international: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Parses and formats a phone number into E.164 and international formats.
|
|
7
|
+
* @param phone - The phone number string.
|
|
8
|
+
* @param defaultCountry - Default country code (default 'US').
|
|
9
|
+
* @returns Object with `e164` and `international` strings, or null if invalid.
|
|
10
|
+
*/
|
|
11
|
+
declare const formatPhone: (phone: string, defaultCountry?: string) => FormattedPhoneNumber | null;
|
|
12
|
+
|
|
13
|
+
export { formatPhone };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { CountryCode } from 'libphonenumber-js';
|
|
2
|
-
|
|
3
1
|
interface FormattedPhoneNumber {
|
|
4
2
|
e164: string;
|
|
5
3
|
international: string;
|
|
@@ -10,6 +8,6 @@ interface FormattedPhoneNumber {
|
|
|
10
8
|
* @param defaultCountry - Default country code (default 'US').
|
|
11
9
|
* @returns Object with `e164` and `international` strings, or null if invalid.
|
|
12
10
|
*/
|
|
13
|
-
declare const formatPhone: (phone: string, defaultCountry?:
|
|
11
|
+
declare const formatPhone: (phone: string, defaultCountry?: string) => FormattedPhoneNumber | null;
|
|
14
12
|
|
|
15
13
|
export { formatPhone };
|
package/general/format-phone.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var o=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var u=(t,r)=>{for(var e in r)o(t,e,{get:r[e],enumerable:!0})},l=(t,r,e,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of s(r))!m.call(t,n)&&n!==e&&o(t,n,{get:()=>r[n],enumerable:!(i=a(r,n))||i.enumerable});return t};var f=t=>l(o({},"__esModule",{value:!0}),t);var g={};u(g,{formatPhone:()=>d});module.exports=f(g);const d=(t,r="US")=>{const{parsePhoneNumberFromString:e}=require("libphonenumber-js");let i=t;t.startsWith("+")||(i=`+${t}`);const n=e(i,r);return n&&n.isValid()?{e164:n.format("E.164"),international:n.formatInternational()}:null};0&&(module.exports={formatPhone});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o=(r,e="US")=>{const{parsePhoneNumberFromString:i}=require("libphonenumber-js");let n=r;r.startsWith("+")||(n=`+${r}`);const t=i(n,e);return t&&t.isValid()?{e164:t.format("E.164"),international:t.formatInternational()}:null};export{o as formatPhone};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats a number or numeric string as a USD price with 2 decimal places.
|
|
3
|
+
* @param value - The price value as a number or string.
|
|
4
|
+
* @returns The formatted price string.
|
|
5
|
+
*/
|
|
6
|
+
declare const formatPricing: (value: string | number) => string;
|
|
7
|
+
|
|
8
|
+
export { formatPricing };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const n=t=>{let r="";if(typeof t=="string"){const i=Number(t).toFixed(2);r=new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(i))}return typeof t=="number"&&(r=new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(t))),r};export{n as formatPricing};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=t=>{if(t>=0){const o=Math.floor(t/3600),s=Math.floor(t%3600/60),n=t%60;return`${o}h ${s}m ${n}s`}else{const o=Math.abs(t),s=-Math.ceil(o/3600),n=o%3600,r=Math.floor((3600-n)/60)%60,c=(60-o%60)%60;return`${s}h ${r}m ${c}s`}};export{e as formatSecs};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface Params {
|
|
2
|
+
seconds: number;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Formats a duration in seconds into a human-friendly string (e.g. "2 mins and 30 secs").
|
|
6
|
+
* @param params.seconds - Duration in seconds (non-negative integer).
|
|
7
|
+
* @returns The formatted duration string.
|
|
8
|
+
*/
|
|
9
|
+
declare const formatDuration: ({ seconds }: Params) => string;
|
|
10
|
+
|
|
11
|
+
export { formatDuration };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s=[{divisor:86400,singular:"day",plural:"days"},{divisor:3600,singular:"hour",plural:"hours"},{divisor:60,singular:"min",plural:"mins"},{divisor:1,singular:"sec",plural:"secs"}],l=({seconds:n})=>{if(typeof n!="number"||n<0||!Number.isInteger(n))throw new Error("Invalid input: must be a non-negative integer");let a=n;const r=[];for(const i of s){const t=Math.floor(a/i.divisor);a%=i.divisor,t>0&&r.push(`${t} ${t===1?i.singular:i.plural}`)}return r.length===0?`0 ${s[s.length-1].plural}`:r.length>1?`${r.slice(0,-1).join(", ")} and ${r[r.length-1]}`:r[0]};export{l as formatDuration};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a string representation of a value, or an em dash if null/undefined/empty.
|
|
3
|
+
* @param v - The value to format.
|
|
4
|
+
* @returns The string representation or '—'.
|
|
5
|
+
*/
|
|
6
|
+
declare const formatValue: (v?: string | number | null) => string;
|
|
7
|
+
|
|
8
|
+
export { formatValue };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=n=>n==null||n===""?"\u2014":String(n);export{e as formatValue};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface Return {
|
|
2
|
+
startOfMonth: Date;
|
|
3
|
+
endOfMonth: Date;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Get the full month range for a given month and year
|
|
7
|
+
* @param month - The month (0-11, where 0 is January). Defaults to current month.
|
|
8
|
+
* @param year - The year. Defaults to current year.
|
|
9
|
+
* @returns An object containing startOfMonth and endOfMonth dates in UTC
|
|
10
|
+
*/
|
|
11
|
+
declare const fullMonthRange: (month?: number, year?: number) => Return;
|
|
12
|
+
|
|
13
|
+
export { fullMonthRange };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const c=(a,o)=>{const t=new Date,e=o??t.getUTCFullYear(),n=a??t.getUTCMonth(),r=new Date(Date.UTC(e,n,1,0,0,0,0)),s=new Date(Date.UTC(e,n+1,0,23,59,59,999));return{startOfMonth:r,endOfMonth:s}};export{c as fullMonthRange};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface Return {
|
|
2
|
+
startOfYear: Date;
|
|
3
|
+
endOfYear: Date;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Get the full year range for a given year
|
|
7
|
+
* @param year - The year. Defaults to current year.
|
|
8
|
+
* @returns An object containing startOfYear and endOfYear dates
|
|
9
|
+
*/
|
|
10
|
+
declare const fullYearRange: (year?: number) => Return;
|
|
11
|
+
|
|
12
|
+
export { fullYearRange };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const n=t=>{const e=t??new Date().getUTCFullYear(),a=new Date(Date.UTC(e,0,1,0,0,0,0)),r=new Date(Date.UTC(e,11,31,23,59,59,999));return{startOfYear:a,endOfYear:r}};export{n as fullYearRange};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate schema.org JSON-LD for `Article`, `NewsArticle`, or `BlogPosting`.
|
|
3
|
+
*
|
|
4
|
+
* This helper accepts `ArticleSchema` inputs and formats authors,
|
|
5
|
+
* publisher/logo, images, and optional fields such as `keywords`,
|
|
6
|
+
* `articleSection`, and `wordCount`. Only supplied fields are emitted in
|
|
7
|
+
* the resulting object, making the output safe to merge into page
|
|
8
|
+
* metadata bundles.
|
|
9
|
+
*
|
|
10
|
+
* Examples are provided in the interface comments below — consult the
|
|
11
|
+
* `ArticleSchema` type for full details of supported inputs.
|
|
12
|
+
*
|
|
13
|
+
* @param options - Article metadata and optional fields
|
|
14
|
+
* @returns A JSON-LD compatible Article/NewsArticle/BlogPosting object
|
|
15
|
+
*/
|
|
16
|
+
type ArticleType = 'Article' | 'NewsArticle' | 'BlogPosting';
|
|
17
|
+
interface ArticleAuthor {
|
|
18
|
+
name: string;
|
|
19
|
+
url?: string;
|
|
20
|
+
}
|
|
21
|
+
interface ArticleImage {
|
|
22
|
+
url: string;
|
|
23
|
+
width?: number;
|
|
24
|
+
height?: number;
|
|
25
|
+
}
|
|
26
|
+
interface ArticlePublisher {
|
|
27
|
+
name: string;
|
|
28
|
+
logo?: {
|
|
29
|
+
url: string;
|
|
30
|
+
width?: number;
|
|
31
|
+
height?: number;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
interface ArticleSchema {
|
|
35
|
+
type?: ArticleType;
|
|
36
|
+
headline: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
image: string | string[] | ArticleImage | ArticleImage[];
|
|
39
|
+
author: string | ArticleAuthor | ArticleAuthor[];
|
|
40
|
+
publisher: ArticlePublisher;
|
|
41
|
+
datePublished: string;
|
|
42
|
+
dateModified?: string;
|
|
43
|
+
url?: string;
|
|
44
|
+
keywords?: string[];
|
|
45
|
+
articleSection?: string;
|
|
46
|
+
wordCount?: number;
|
|
47
|
+
}
|
|
48
|
+
declare const generateArticleSchema: ({ type, headline, description, image, author, publisher, datePublished, dateModified, url, keywords, articleSection, wordCount, }: ArticleSchema) => any;
|
|
49
|
+
|
|
50
|
+
export { generateArticleSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const A=t=>typeof t=="string"?{"@type":"Person",name:t}:Array.isArray(t)?t.map(e=>({"@type":"Person",name:e.name,...e.url&&{url:e.url}})):{"@type":"Person",name:t.name,...t.url&&{url:t.url}},f=t=>typeof t=="string"?t: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}}):{"@type":"ImageObject",url:t.url,...t.width&&{width:t.width},...t.height&&{height:t.height}},y=t=>{const e={"@type":"Organization",name:t.name};return t.logo&&(e.logo={"@type":"ImageObject",url:t.logo.url,...t.logo.width&&{width:t.logo.width},...t.logo.height&&{height:t.logo.height}}),e},m=({type:t="Article",headline:e,description:n,image:c,author:s,publisher:a,datePublished:u,dateModified:l,url:g,keywords:i,articleSection:h,wordCount:o})=>{const r={"@context":"https://schema.org","@type":t,headline:e,image:f(c),author:A(s),publisher:y(a),datePublished:u};return n&&(r.description=n),l&&(r.dateModified=l),g&&(r.mainEntityOfPage={"@type":"WebPage","@id":g}),i&&i.length>0&&(r.keywords=i.join(", ")),h&&(r.articleSection=h),o&&(r.wordCount=o),r};export{m as generateArticleSchema};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate schema.org `BlogPosting` JSON-LD for a blog entry.
|
|
3
|
+
*
|
|
4
|
+
* Produces a compact `BlogPosting` object using headline, dates, image and
|
|
5
|
+
* author information. Only provided fields are emitted, and the returned
|
|
6
|
+
* object is ready to be stringified as JSON-LD.
|
|
7
|
+
*
|
|
8
|
+
* See the `Blog` interface below for the accepted properties.
|
|
9
|
+
* @returns A JSON-LD compatible `BlogPosting` object
|
|
10
|
+
*/
|
|
11
|
+
interface Blog {
|
|
12
|
+
authorImage: string;
|
|
13
|
+
authorName: string;
|
|
14
|
+
banner: string;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
excerpt: string;
|
|
17
|
+
title: string;
|
|
18
|
+
updatedAt: string;
|
|
19
|
+
url: string;
|
|
20
|
+
}
|
|
21
|
+
declare const generateBlogSchema: ({ authorImage, authorName, banner, createdAt, excerpt, title, updatedAt, url, }: Blog) => {
|
|
22
|
+
'@context': string;
|
|
23
|
+
'@type': string;
|
|
24
|
+
headline: string;
|
|
25
|
+
dateModified: string;
|
|
26
|
+
datePublished: string;
|
|
27
|
+
description: string;
|
|
28
|
+
image: string;
|
|
29
|
+
url: string;
|
|
30
|
+
author: {
|
|
31
|
+
'@type': string;
|
|
32
|
+
name: string;
|
|
33
|
+
url: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { generateBlogSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s=({authorImage:t,authorName:e,banner:r,createdAt:n,excerpt:i,title:a,updatedAt:g,url:o})=>({"@context":"https://schema.org","@type":"BlogPosting",headline:`${a}`,dateModified:`${g}`,datePublished:`${n}`,description:`${i}`,image:`${r}`,url:`${o}`,author:{"@type":"Person",name:`${e}`,url:`${t}`}});export{s as generateBlogSchema};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate schema.org `Book` JSON-LD for use in page <script type="application/ld+json">.
|
|
3
|
+
*
|
|
4
|
+
* This helper accepts a compact `BookSchemaOptions` input and returns a
|
|
5
|
+
* plain object ready to be stringified and inlined on a page. Common
|
|
6
|
+
* fields supported:
|
|
7
|
+
*
|
|
8
|
+
* - `title` → maps to `name`
|
|
9
|
+
* - `author` → accepts a `string`, an `{ name, url? }` object, or an array of
|
|
10
|
+
* those; these are formatted as `Person` objects
|
|
11
|
+
* - `publisher` → `{ name, logo? }` formatted as an `Organization` with
|
|
12
|
+
* an optional `ImageObject` logo
|
|
13
|
+
* - `image` → accepts a `string`, `BookImage` or arrays; non-string images are
|
|
14
|
+
* converted to `ImageObject` entries
|
|
15
|
+
* - `url` → attached to `mainEntityOfPage.@id` when provided
|
|
16
|
+
* - `keywords` → joined into a comma-separated string
|
|
17
|
+
*
|
|
18
|
+
* The implementation intentionally produces minimal output (only provided
|
|
19
|
+
* fields are added) so the result can be safely merged into other page
|
|
20
|
+
* metadata.
|
|
21
|
+
*
|
|
22
|
+
* @param options.book title, author, publisher and optional metadata
|
|
23
|
+
* @returns A JSON-LD compatible `Book` object
|
|
24
|
+
*/
|
|
25
|
+
interface BookAuthor {
|
|
26
|
+
name: string;
|
|
27
|
+
url?: string;
|
|
28
|
+
}
|
|
29
|
+
interface BookImage {
|
|
30
|
+
url: string;
|
|
31
|
+
width?: number;
|
|
32
|
+
height?: number;
|
|
33
|
+
}
|
|
34
|
+
interface BookPublisher {
|
|
35
|
+
name: string;
|
|
36
|
+
logo?: {
|
|
37
|
+
url: string;
|
|
38
|
+
width?: number;
|
|
39
|
+
height?: number;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
interface BookSchemaOptions {
|
|
43
|
+
title: string;
|
|
44
|
+
author: string | BookAuthor | BookAuthor[];
|
|
45
|
+
isbn?: string;
|
|
46
|
+
numberOfPages?: number;
|
|
47
|
+
inLanguage?: string;
|
|
48
|
+
publisher: BookPublisher;
|
|
49
|
+
datePublished?: string;
|
|
50
|
+
image?: string | string[] | BookImage | BookImage[];
|
|
51
|
+
description?: string;
|
|
52
|
+
url?: string;
|
|
53
|
+
keywords?: string[];
|
|
54
|
+
bookFormat?: string;
|
|
55
|
+
}
|
|
56
|
+
declare const generateBookSchema: ({ title, author, isbn, numberOfPages, inLanguage, publisher, datePublished, image, description, url, keywords, bookFormat, }: BookSchemaOptions) => any;
|
|
57
|
+
|
|
58
|
+
export { generateBookSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const c=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}},y=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}}},k=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},d=({title:t,author:r,isbn:o,numberOfPages:i,inLanguage:g,publisher:l,datePublished:h,image:m,description:s,url:u,keywords:n,bookFormat:a})=>{const e={"@context":"https://schema.org","@type":"Book",name:t,author:c(r),publisher:k(l)};o&&(e.isbn=o),i&&(e.numberOfPages=i),g&&(e.inLanguage=g),h&&(e.datePublished=h),s&&(e.description=s),a&&(e.bookFormat=a);const f=y(m);return f&&(e.image=f),u&&(e.mainEntityOfPage={"@type":"WebPage","@id":u}),n&&n.length>0&&(e.keywords=n.join(", ")),e};export{d as generateBookSchema};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate a schema.org `BreadcrumbList` JSON-LD object.
|
|
3
|
+
*
|
|
4
|
+
* The `data` array may contain either strings or `Crumb` objects. If an
|
|
5
|
+
* entry is a string it will be treated as a path segment and slugified when
|
|
6
|
+
* appended to `baseUrl`. A `Crumb` object may provide an explicit `path` to
|
|
7
|
+
* use when building the segment, or an absolute `url` to use directly.
|
|
8
|
+
*
|
|
9
|
+
* Output: each list item will include an `item` object with `@id` (the URL)
|
|
10
|
+
* and `name` (the breadcrumb label).
|
|
11
|
+
*
|
|
12
|
+
* @param props.data - Array of path segments or Crumb objects
|
|
13
|
+
* @param props.baseUrl - The base URL to build breadcrumb URLs from
|
|
14
|
+
* @returns A JSON-LD `BreadcrumbList` object
|
|
15
|
+
* @author Taimoor Khan
|
|
16
|
+
*/
|
|
17
|
+
interface Crumb {
|
|
18
|
+
name: string;
|
|
19
|
+
path?: string;
|
|
20
|
+
url?: string;
|
|
21
|
+
}
|
|
22
|
+
interface Props {
|
|
23
|
+
data: Array<string | Crumb>;
|
|
24
|
+
baseUrl: string;
|
|
25
|
+
}
|
|
26
|
+
declare const generateBreadcrumbSchema: ({ data, baseUrl }: Props) => {
|
|
27
|
+
'@context': string;
|
|
28
|
+
'@type': string;
|
|
29
|
+
itemListElement: {
|
|
30
|
+
'@type': string;
|
|
31
|
+
position: number;
|
|
32
|
+
name: string;
|
|
33
|
+
item: {
|
|
34
|
+
'@id': string;
|
|
35
|
+
name: string;
|
|
36
|
+
};
|
|
37
|
+
}[];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { generateBreadcrumbSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{slugify as n}from"./slugify";const g=({data:r,baseUrl:i})=>{let e=i;return{"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:r.map((t,m)=>{const s=typeof t=="string"?t:t.name;if(typeof t!="string"&&t.url)e=t.url;else{const a=typeof t=="string"?t:t.path||t.name;e+=`/${n(a)}`}return{"@type":"ListItem",position:m+1,name:s,item:{"@id":e,name:s}}})}};export{g as generateBreadcrumbSchema};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate schema.org `ItemList` JSON-LD for a carousel of items.
|
|
3
|
+
*
|
|
4
|
+
* Each carousel item is emitted as a `ListItem` containing a `Thing`
|
|
5
|
+
* (Product, Article, Movie, etc.) depending on the provided item fields.
|
|
6
|
+
* Currency and availability values are normalized where applicable; use
|
|
7
|
+
* `skipInvalidCurrency` to bypass currency validation.
|
|
8
|
+
*
|
|
9
|
+
* See `CarouselSchemaOptions` and `CarouselItem` for input details.
|
|
10
|
+
* @returns A JSON-LD compatible `ItemList` object
|
|
11
|
+
*/
|
|
12
|
+
interface CarouselImage {
|
|
13
|
+
url: string;
|
|
14
|
+
width?: number;
|
|
15
|
+
height?: number;
|
|
16
|
+
}
|
|
17
|
+
interface CarouselItem {
|
|
18
|
+
id?: string;
|
|
19
|
+
name: string;
|
|
20
|
+
url?: string;
|
|
21
|
+
image?: string | CarouselImage;
|
|
22
|
+
description?: string;
|
|
23
|
+
type?: string;
|
|
24
|
+
price?: string | number;
|
|
25
|
+
priceCurrency?: string;
|
|
26
|
+
aggregateRating?: {
|
|
27
|
+
ratingValue: number | string;
|
|
28
|
+
reviewCount?: number;
|
|
29
|
+
bestRating?: number;
|
|
30
|
+
worstRating?: number;
|
|
31
|
+
};
|
|
32
|
+
offers?: Array<{
|
|
33
|
+
price: string | number;
|
|
34
|
+
priceCurrency?: string;
|
|
35
|
+
availability?: string;
|
|
36
|
+
url?: string;
|
|
37
|
+
priceValidUntil?: string;
|
|
38
|
+
priceRange?: {
|
|
39
|
+
low?: string | number;
|
|
40
|
+
high?: string | number;
|
|
41
|
+
};
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
44
|
+
interface CarouselSchemaOptions {
|
|
45
|
+
name?: string;
|
|
46
|
+
url?: string;
|
|
47
|
+
items: CarouselItem[];
|
|
48
|
+
skipInvalidCurrency?: boolean;
|
|
49
|
+
}
|
|
50
|
+
declare const generateCarouselSchema: ({ name, url, items, skipInvalidCurrency, }: CarouselSchemaOptions) => any;
|
|
51
|
+
|
|
52
|
+
export { generateCarouselSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const d=n=>{if(n)return typeof n=="string"?n:{"@type":"ImageObject",url:n.url,...n.width&&{width:n.width},...n.height&&{height:n.height}}},u=n=>n?/^[A-Z]{3}$/.test(n):!1,o=["InStock","OutOfStock","PreOrder","PreSale","Discontinued","OnlineOnly","InStoreOnly","LimitedAvailability","BackOrder"],m=n=>{if(n)try{const a=String(n);if(a.startsWith("http")){const g=a.replace(/https?:\/\/schema\.org\//i,"");return o.includes(g)?`https://schema.org/${g}`:void 0}return o.includes(a)?`https://schema.org/${a}`:void 0}catch{return}},b=({name:n,url:a,items:g,skipInvalidCurrency:f=!1})=>{const l={"@context":"https://schema.org","@type":"ItemList",itemListElement:g.map((e,y)=>{const t={"@type":e.type||"Thing",name:e.name};e.url&&(t.url=e.url),e.id&&(t["@id"]=e.id);const p=d(e.image);if(p&&(t.image=p),e.description&&(t.description=e.description),e.offers&&Array.isArray(e.offers)&&e.offers.length>0){const s=e.offers.map(r=>{if(r.priceCurrency&&!u(r.priceCurrency))return{__invalidCurrency:r.priceCurrency};const i={"@type":"Offer"};if(r.price!==void 0&&(i.price=r.price),r.priceCurrency&&(i.priceCurrency=r.priceCurrency),r.availability){const c=m(r.availability);c&&(i.availability=c)}if(r.url&&(i.url=r.url),r.priceValidUntil&&(i.priceValidUntil=r.priceValidUntil),r.priceRange){const c=r.priceRange;i.priceSpecification={"@type":"PriceSpecification",...c.low!=null&&{minPrice:c.low},...c.high!=null&&{maxPrice:c.high},...r.priceCurrency&&{priceCurrency:r.priceCurrency}}}return i}).filter(r=>r&&!("__invalidCurrency"in r));if(e.offers.some(r=>r.priceCurrency&&!u(r.priceCurrency))&&!f){const r=e.offers.find(i=>i.priceCurrency&&!u(i.priceCurrency));throw new Error(`Invalid currency code: ${r?.priceCurrency}`)}s.length>0&&(t.offers=s)}else if(e.price!==void 0)if(e.priceCurrency&&!u(e.priceCurrency)){if(!f)throw new Error(`Invalid currency code: ${e.priceCurrency}`)}else{const s={"@type":"Offer",price:e.price};e.priceCurrency&&(s.priceCurrency=e.priceCurrency),t.offers=s}return e.aggregateRating&&(t.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:y+1,item:t}})};return n&&(l.name=n),a&&(l.mainEntityOfPage={"@type":"WebPage","@id":a}),l};export{b as generateCarouselSchema};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate schema.org `Course` JSON-LD.
|
|
3
|
+
*
|
|
4
|
+
* Accepts metadata for a course and optional `CourseInstance` objects
|
|
5
|
+
* including offers and locations. Provider can be a string or a structured
|
|
6
|
+
* object with `logo` support. Only provided fields are emitted.
|
|
7
|
+
*
|
|
8
|
+
* See `CourseSchema` and `CourseInstance` for field details.
|
|
9
|
+
* @returns A JSON-LD compatible `Course` object
|
|
10
|
+
*/
|
|
11
|
+
interface CourseProvider {
|
|
12
|
+
name: string;
|
|
13
|
+
url?: string;
|
|
14
|
+
logo?: {
|
|
15
|
+
url: string;
|
|
16
|
+
width?: number;
|
|
17
|
+
height?: number;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
interface CourseImage {
|
|
21
|
+
url: string;
|
|
22
|
+
width?: number;
|
|
23
|
+
height?: number;
|
|
24
|
+
}
|
|
25
|
+
interface CourseInstanceOffer {
|
|
26
|
+
price?: string | number;
|
|
27
|
+
priceCurrency?: string;
|
|
28
|
+
availability?: string;
|
|
29
|
+
url?: string;
|
|
30
|
+
}
|
|
31
|
+
interface CourseInstance {
|
|
32
|
+
name?: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
courseMode?: string;
|
|
35
|
+
startDate?: string;
|
|
36
|
+
endDate?: string;
|
|
37
|
+
location?: string;
|
|
38
|
+
offers?: CourseInstanceOffer | CourseInstanceOffer[];
|
|
39
|
+
}
|
|
40
|
+
interface CourseSchema {
|
|
41
|
+
name: string;
|
|
42
|
+
description?: string;
|
|
43
|
+
courseCode?: string;
|
|
44
|
+
educationalCredentialAwarded?: string;
|
|
45
|
+
provider: string | CourseProvider;
|
|
46
|
+
image?: string | CourseImage | Array<string | CourseImage>;
|
|
47
|
+
url?: string;
|
|
48
|
+
hasCourseInstance?: CourseInstance | CourseInstance[];
|
|
49
|
+
keywords?: string[];
|
|
50
|
+
}
|
|
51
|
+
declare const generateCourseSchema: ({ name, description, courseCode, educationalCredentialAwarded, provider, image, url, hasCourseInstance, keywords, }: CourseSchema) => any;
|
|
52
|
+
|
|
53
|
+
export { generateCourseSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const y=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},m=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}}},C=e=>{if(!e)return;const r=n=>{const a={"@type":"Offer"};return n.price!==void 0&&(a.price=n.price),n.priceCurrency&&(a.priceCurrency=n.priceCurrency),n.availability&&(a.availability=n.availability),n.url&&(a.url=n.url),a};return Array.isArray(e)?e.map(r):r(e)},p=({name:e,description:r,courseCode:n,educationalCredentialAwarded:a,provider:h,image:d,url:f,hasCourseInstance:o,keywords:u})=>{const i={"@context":"https://schema.org","@type":"Course",name:e};r&&(i.description=r),n&&(i.courseCode=n),a&&(i.educationalCredentialAwarded=a),i.provider=y(h);const c=m(d);if(c&&(i.image=c),f&&(i.url=f),u&&u.length>0&&(i.keywords=u.join(", ")),o){const g=t=>{const s={"@type":"CourseInstance"};t.name&&(s.name=t.name),t.description&&(s.description=t.description),t.courseMode&&(s.courseMode=t.courseMode),t.startDate&&(s.startDate=t.startDate),t.endDate&&(s.endDate=t.endDate),t.location&&(s.location=t.location);const l=C(t.offers);return l&&(s.offers=l),s};Array.isArray(o)?i.hasCourseInstance=o.map(g):i.hasCourseInstance=g(o)}return i};export{p as generateCourseSchema};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate schema.org JSON-LD for `Dataset`, `DataCatalog`, or
|
|
3
|
+
* `DataDownload` distributions.
|
|
4
|
+
*
|
|
5
|
+
* Supports publisher formatting, distribution normalization (including
|
|
6
|
+
* encoding format validation with `skipInvalidEncoding`), variable
|
|
7
|
+
* measurement metadata and nested datasets for `DataCatalog`.
|
|
8
|
+
*
|
|
9
|
+
* See `DatasetOptions` for the input shape and available flags.
|
|
10
|
+
* @returns A JSON-LD compatible `Dataset` or `DataCatalog` object
|
|
11
|
+
*/
|
|
12
|
+
interface PublisherLogo {
|
|
13
|
+
url: string;
|
|
14
|
+
width?: number;
|
|
15
|
+
height?: number;
|
|
16
|
+
}
|
|
17
|
+
interface Publisher {
|
|
18
|
+
name: string;
|
|
19
|
+
url?: string;
|
|
20
|
+
logo?: PublisherLogo;
|
|
21
|
+
}
|
|
22
|
+
interface Distribution {
|
|
23
|
+
name?: string;
|
|
24
|
+
contentUrl: string;
|
|
25
|
+
encodingFormat?: string;
|
|
26
|
+
byteSize?: number | string;
|
|
27
|
+
datePublished?: string;
|
|
28
|
+
license?: string;
|
|
29
|
+
measurementTechnique?: string;
|
|
30
|
+
}
|
|
31
|
+
interface DatasetOptions {
|
|
32
|
+
type?: 'Dataset' | 'DataCatalog';
|
|
33
|
+
name?: string;
|
|
34
|
+
description?: string;
|
|
35
|
+
url?: string;
|
|
36
|
+
datePublished?: string;
|
|
37
|
+
dateModified?: string;
|
|
38
|
+
publisher: string | Publisher;
|
|
39
|
+
keywords?: string[];
|
|
40
|
+
license?: string;
|
|
41
|
+
version?: string;
|
|
42
|
+
variableMeasured?: string | string[] | Array<{
|
|
43
|
+
name: string;
|
|
44
|
+
value?: string | number;
|
|
45
|
+
unitText?: string;
|
|
46
|
+
}>;
|
|
47
|
+
spatialCoverage?: string;
|
|
48
|
+
distribution?: Distribution | Distribution[];
|
|
49
|
+
citation?: string | {
|
|
50
|
+
text?: string;
|
|
51
|
+
url?: string;
|
|
52
|
+
};
|
|
53
|
+
funding?: string | {
|
|
54
|
+
name: string;
|
|
55
|
+
funder?: string;
|
|
56
|
+
} | Array<string | {
|
|
57
|
+
name: string;
|
|
58
|
+
funder?: string;
|
|
59
|
+
}>;
|
|
60
|
+
skipInvalidEncoding?: boolean;
|
|
61
|
+
datasets?: DatasetOptions[];
|
|
62
|
+
}
|
|
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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const d=t=>{if(typeof t=="string")return{"@type":"Organization",name:t};const n={"@type":"Organization",name:t.name};return t.url&&(n.url=t.url),t.logo&&(n.logo={"@type":"ImageObject",url:t.logo.url},t.logo.width&&(n.logo.width=t.logo.width),t.logo.height&&(n.logo.height=t.logo.height)),n},z=(t,n=!1)=>{const i={"@type":"DataDownload",contentUrl:t.contentUrl};if(t.name&&(i.name=t.name),t.encodingFormat){const r=x(t.encodingFormat,n);r&&(i.encodingFormat=r)}return t.byteSize!=null&&(i.byteSize=t.byteSize),t.datePublished&&(i.datePublished=t.datePublished),t.license&&(i.license=t.license),t.measurementTechnique&&(i.measurementTechnique=t.measurementTechnique),i},D={csv:"text/csv",json:"application/json",geojson:"application/geo+json",xml:"application/xml",txt:"text/plain",zip:"application/zip",gzip:"application/gzip"},P=t=>/^[a-z0-9!#$&.+\-_]+\/[a-z0-9!#$&.+\-_]+$/i.test(t),x=(t,n=!1)=>{if(!t)return;const i=String(t).trim(),r=i.toLowerCase();if(D[r])return D[r];if(P(i))return i;if(!n)throw new Error(`Invalid encodingFormat: ${t}`)},A=({type:t="Dataset",name:n,description:i,url:r,datePublished:c,dateModified:f,publisher:o,keywords:s,license:m,version:h,variableMeasured:b,spatialCoverage:y,distribution:g,datasets:l,skipInvalidEncoding:p=!1})=>{if(t==="DataCatalog"){const a={"@context":"https://schema.org","@type":"DataCatalog"};return n&&(a.name=n),i&&(a.description=i),r&&(a.url=r),o&&(a.publisher=d(o)),s&&s.length&&(a.keywords=s.join(", ")),l&&Array.isArray(l)&&(a.dataset=l.map(u=>A({...u,type:"Dataset",skipInvalidEncoding:p}))),a}const e={"@context":"https://schema.org","@type":"Dataset"};if(n&&(e.name=n),i&&(e.description=i),r&&(e.url=r),c&&(e.datePublished=c),f&&(e.dateModified=f),o&&(e.publisher=d(o)),s&&s.length&&(e.keywords=s.join(", ")),m&&(e.license=m),h&&(e.version=h),b&&(e.variableMeasured=b),y&&(e.spatialCoverage=y),g){const a=Array.isArray(g)?g:[g];e.distribution=a.map(u=>z(u,p))}return e};export{A as generateDatasetSchema};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate schema.org JSON-LD for `DiscussionForumPosting`.
|
|
3
|
+
*
|
|
4
|
+
* Formats author and publisher references, optional interaction statistics,
|
|
5
|
+
* and content fields into a compact `DiscussionForumPosting` object ready
|
|
6
|
+
* for JSON-LD embedding.
|
|
7
|
+
*
|
|
8
|
+
* See `DiscussionForumOptions` for supported inputs.
|
|
9
|
+
* @returns A JSON-LD compatible `DiscussionForumPosting` object
|
|
10
|
+
*/
|
|
11
|
+
interface PersonRef {
|
|
12
|
+
name?: string;
|
|
13
|
+
url?: string;
|
|
14
|
+
}
|
|
15
|
+
interface DiscussionForumOptions {
|
|
16
|
+
headline?: string;
|
|
17
|
+
articleBody?: string;
|
|
18
|
+
url?: string;
|
|
19
|
+
datePublished?: string;
|
|
20
|
+
dateModified?: string;
|
|
21
|
+
author?: string | PersonRef;
|
|
22
|
+
publisher?: string | {
|
|
23
|
+
name: string;
|
|
24
|
+
url?: string;
|
|
25
|
+
};
|
|
26
|
+
about?: string | {
|
|
27
|
+
'@type': string;
|
|
28
|
+
name?: string;
|
|
29
|
+
};
|
|
30
|
+
discussionUrl?: string;
|
|
31
|
+
interactionStatistic?: Array<{
|
|
32
|
+
'@type': string;
|
|
33
|
+
interactionType?: string;
|
|
34
|
+
userInteractionCount?: number;
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
37
|
+
declare const generateDiscussionForumSchema: ({ headline, articleBody, url, datePublished, dateModified, author, publisher, about, discussionUrl, interactionStatistic, }?: DiscussionForumOptions) => any;
|
|
38
|
+
|
|
39
|
+
export { generateDiscussionForumSchema as default, generateDiscussionForumSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const y=n=>{if(!n)return;if(typeof n=="string")return{"@type":"Person",name:n};const t={"@type":"Person"};return n.name&&(t.name=n.name),n.url&&(t.url=n.url),t},l=n=>{if(!n)return;if(typeof n=="string")return{"@type":"Organization",name:n};const t={"@type":"Organization",name:n.name};return n.url&&(t.url=n.url),t},d=({headline:n,articleBody:t,url:e,datePublished:s,dateModified:o,author:c,publisher:m,about:a,discussionUrl:u,interactionStatistic:i}={})=>{const r={"@context":"https://schema.org","@type":"DiscussionForumPosting"};n&&(r.headline=n),t&&(r.articleBody=t),e&&(r.url=e),s&&(r.datePublished=s),o&&(r.dateModified=o);const f=y(c);f&&(r.author=f);const g=l(m);return g&&(r.publisher=g),a&&(r.about=a),u&&(r.discussionUrl=u),i&&Array.isArray(i)&&(r.interactionStatistic=i),r};var h=d;export{h as default,d as generateDiscussionForumSchema};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate schema.org JSON-LD for a Quiz (Question and Answer items).
|
|
3
|
+
*
|
|
4
|
+
* Supports author and publisher metadata along with detailed `Question`
|
|
5
|
+
* and `Answer` structures (including accepted/suggested answers,
|
|
6
|
+
* feedback and scoring fields). Only provided values are emitted.
|
|
7
|
+
*
|
|
8
|
+
* See `QuizOptions`, `Question`, and `Answer` types for the available
|
|
9
|
+
* fields and formats.
|
|
10
|
+
* @returns A JSON-LD compatible `Quiz` object
|
|
11
|
+
*/
|
|
12
|
+
interface PersonRef {
|
|
13
|
+
name?: string;
|
|
14
|
+
url?: string;
|
|
15
|
+
}
|
|
16
|
+
interface PublisherRef {
|
|
17
|
+
name: string;
|
|
18
|
+
url?: string;
|
|
19
|
+
}
|
|
20
|
+
interface Answer {
|
|
21
|
+
text: string;
|
|
22
|
+
url?: string;
|
|
23
|
+
author?: string | PersonRef;
|
|
24
|
+
upvoteCount?: number;
|
|
25
|
+
feedback?: string | {
|
|
26
|
+
text?: string;
|
|
27
|
+
score?: number;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
interface Question {
|
|
31
|
+
name?: string;
|
|
32
|
+
text?: string;
|
|
33
|
+
acceptedAnswer?: Answer | Answer[];
|
|
34
|
+
suggestedAnswer?: Answer | Answer[];
|
|
35
|
+
answerCount?: number;
|
|
36
|
+
upvoteCount?: number;
|
|
37
|
+
difficulty?: string;
|
|
38
|
+
points?: number;
|
|
39
|
+
score?: number;
|
|
40
|
+
timeLimit?: string;
|
|
41
|
+
attempts?: number;
|
|
42
|
+
tags?: string[];
|
|
43
|
+
hints?: string[];
|
|
44
|
+
learningObjective?: string | string[];
|
|
45
|
+
timeRecommended?: string;
|
|
46
|
+
isRequired?: boolean;
|
|
47
|
+
}
|
|
48
|
+
interface QuizOptions {
|
|
49
|
+
name?: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
url?: string;
|
|
52
|
+
datePublished?: string;
|
|
53
|
+
author?: string | PersonRef;
|
|
54
|
+
publisher?: string | PublisherRef;
|
|
55
|
+
difficulty?: string;
|
|
56
|
+
learningResourceType?: string;
|
|
57
|
+
educationalLevel?: string;
|
|
58
|
+
timeRequired?: string;
|
|
59
|
+
typicalAgeRange?: string | number;
|
|
60
|
+
inLanguage?: string;
|
|
61
|
+
keywords?: string[];
|
|
62
|
+
learningOutcome?: string | string[];
|
|
63
|
+
isAccessibleForFree?: boolean;
|
|
64
|
+
questions?: Question[];
|
|
65
|
+
}
|
|
66
|
+
declare const generateEducationSchema: ({ name, description, url, datePublished, author, publisher, difficulty, learningResourceType, educationalLevel, timeRequired, typicalAgeRange, inLanguage, keywords, learningOutcome, isAccessibleForFree, questions, }?: QuizOptions) => any;
|
|
67
|
+
|
|
68
|
+
export { generateEducationSchema as default, generateEducationSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const b=e=>{if(!e)return;if(typeof e=="string")return{"@type":"Person",name:e};const t={"@type":"Person"};return e.name&&(t.name=e.name),e.url&&(t.url=e.url),t},R=e=>{if(!e)return;if(typeof e=="string")return{"@type":"Organization",name:e};const t={"@type":"Organization",name:e.name};return e.url&&(t.url=e.url),t},i=e=>{const t={"@type":"Answer",text:e.text};return e.url&&(t.url=e.url),e.author&&(t.author=b(e.author)),e.upvoteCount!=null&&(t.upvoteCount=e.upvoteCount),e.feedback&&(t.feedback=e.feedback),t},v=e=>{const t={"@type":"Question"};if(e.name&&(t.name=e.name),e.text&&(t.text=e.text),e.answerCount!=null&&(t.answerCount=e.answerCount),e.upvoteCount!=null&&(t.upvoteCount=e.upvoteCount),e.difficulty&&(t.difficulty=e.difficulty),e.points!=null&&(t.points=e.points),e.score!=null&&(t.score=e.score),e.timeLimit&&(t.timeLimit=e.timeLimit),e.attempts!=null&&(t.attempts=e.attempts),e.tags&&Array.isArray(e.tags)&&(t.tags=e.tags),e.hints&&Array.isArray(e.hints)&&(t.hints=e.hints),e.learningObjective&&(t.learningObjective=e.learningObjective),e.timeRecommended&&(t.timeRecommended=e.timeRecommended),e.isRequired!=null&&(t.isRequired=e.isRequired),e.acceptedAnswer){const r=Array.isArray(e.acceptedAnswer)?e.acceptedAnswer.map(i):i(e.acceptedAnswer);t.acceptedAnswer=r}if(e.suggestedAnswer){const r=Array.isArray(e.suggestedAnswer)?e.suggestedAnswer.map(i):i(e.suggestedAnswer);t.suggestedAnswer=r}return t},C=({name:e,description:t,url:r,datePublished:a,author:w,publisher:h,difficulty:o,learningResourceType:f,educationalLevel:g,timeRequired:c,typicalAgeRange:m,inLanguage:l,keywords:s,learningOutcome:d,isAccessibleForFree:y,questions:u}={})=>{const n={"@context":"https://schema.org","@type":"Quiz"};e&&(n.name=e),t&&(n.description=t),r&&(n.url=r),a&&(n.datePublished=a);const A=b(w);A&&(n.author=A);const p=R(h);return p&&(n.publisher=p),o&&(n.difficulty=o),f&&(n.learningResourceType=f),g&&(n.educationalLevel=g),c&&(n.timeRequired=c),m!=null&&(n.typicalAgeRange=m),l&&(n.inLanguage=l),s&&Array.isArray(s)&&(n.keywords=s.join(", ")),d&&(n.learningOutcome=d),y!=null&&(n.isAccessibleForFree=y),u&&Array.isArray(u)&&(n.question=u.map(v)),n};var P=C;export{P as default,C as generateEducationSchema};
|