@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,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate schema.org `VacationRental` JSON-LD including optional reviews
|
|
3
|
+
* and `AggregateRating`.
|
|
4
|
+
*
|
|
5
|
+
* The function accepts address or geo information, images, host references,
|
|
6
|
+
* and occupancy data. Reviews and aggregate ratings are formatted into
|
|
7
|
+
* `Review` and `AggregateRating` objects when provided.
|
|
8
|
+
*
|
|
9
|
+
* See `VacationRentalOptions` below for supported inputs.
|
|
10
|
+
* @returns A JSON-LD compatible `VacationRental` object
|
|
11
|
+
*/
|
|
12
|
+
interface ImageRef {
|
|
13
|
+
url: string;
|
|
14
|
+
width?: number;
|
|
15
|
+
height?: number;
|
|
16
|
+
}
|
|
17
|
+
interface PersonRef {
|
|
18
|
+
name: string;
|
|
19
|
+
url?: string;
|
|
20
|
+
}
|
|
21
|
+
interface AddressRef {
|
|
22
|
+
streetAddress?: string;
|
|
23
|
+
addressLocality?: string;
|
|
24
|
+
addressRegion?: string;
|
|
25
|
+
postalCode?: string;
|
|
26
|
+
addressCountry?: string;
|
|
27
|
+
}
|
|
28
|
+
interface GeoRef {
|
|
29
|
+
latitude?: number | string;
|
|
30
|
+
longitude?: number | string;
|
|
31
|
+
}
|
|
32
|
+
interface RatingItem {
|
|
33
|
+
ratingValue: number | string;
|
|
34
|
+
bestRating?: number | string;
|
|
35
|
+
worstRating?: number | string;
|
|
36
|
+
}
|
|
37
|
+
interface ReviewItem {
|
|
38
|
+
author?: string | PersonRef;
|
|
39
|
+
datePublished?: string;
|
|
40
|
+
reviewBody?: string;
|
|
41
|
+
reviewRating?: RatingItem;
|
|
42
|
+
}
|
|
43
|
+
interface AggregateRatingOptions {
|
|
44
|
+
ratingValue: number | string;
|
|
45
|
+
reviewCount?: number;
|
|
46
|
+
ratingCount?: number;
|
|
47
|
+
bestRating?: number | string;
|
|
48
|
+
worstRating?: number | string;
|
|
49
|
+
}
|
|
50
|
+
interface VacationRentalOptions {
|
|
51
|
+
name: string;
|
|
52
|
+
description?: string;
|
|
53
|
+
image?: string | ImageRef | (string | ImageRef)[];
|
|
54
|
+
url?: string;
|
|
55
|
+
address?: string | AddressRef;
|
|
56
|
+
geo?: GeoRef;
|
|
57
|
+
numberOfRooms?: number;
|
|
58
|
+
numberOfBeds?: number;
|
|
59
|
+
priceRange?: string;
|
|
60
|
+
host?: string | PersonRef;
|
|
61
|
+
reviews?: ReviewItem[];
|
|
62
|
+
aggregateRating?: AggregateRatingOptions;
|
|
63
|
+
keywords?: string | string[];
|
|
64
|
+
}
|
|
65
|
+
declare const generateVacationRentalSchema: ({ name, description, image, url, address, geo, numberOfRooms, numberOfBeds, priceRange, host, reviews, aggregateRating, keywords, }: VacationRentalOptions) => any;
|
|
66
|
+
|
|
67
|
+
export { generateVacationRentalSchema as default, generateVacationRentalSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const A=t=>{if(t)return Array.isArray(t)?t.map(e=>typeof e=="string"?e:{"@type":"ImageObject",url:e.url,...e.width&&{width:e.width},...e.height&&{height:e.height}}):typeof t=="string"?t:{"@type":"ImageObject",url:t.url,...t.width&&{width:t.width},...t.height&&{height:t.height}}},c=t=>{if(!t)return;if(typeof t=="string")return{"@type":"Person",name:t};const e={"@type":"Person",name:t.name};return t.url&&(e.url=t.url),e},I=t=>{if(t)return typeof t=="string"?t:{"@type":"PostalAddress",...t.streetAddress&&{streetAddress:t.streetAddress},...t.addressLocality&&{addressLocality:t.addressLocality},...t.addressRegion&&{addressRegion:t.addressRegion},...t.postalCode&&{postalCode:t.postalCode},...t.addressCountry&&{addressCountry:t.addressCountry}}},P=t=>{const e={"@type":"Review"};return t.author&&(e.author=c(t.author)),t.datePublished&&(e.datePublished=t.datePublished),t.reviewBody&&(e.reviewBody=t.reviewBody),t.reviewRating&&(e.reviewRating={"@type":"Rating",ratingValue:t.reviewRating.ratingValue,...t.reviewRating.bestRating!=null&&{bestRating:t.reviewRating.bestRating},...t.reviewRating.worstRating!=null&&{worstRating:t.reviewRating.worstRating}}),e},V=({name:t,description:e,image:y,url:g,address:w,geo:s,numberOfRooms:d,numberOfBeds:l,priceRange:f,host:b,reviews:a,aggregateRating:r,keywords:o})=>{const n={"@context":"https://schema.org","@type":"VacationRental",name:t};e&&(n.description=e);const R=A(y);R&&(n.image=R),g&&(n.url=g);const m=I(w);m&&(n.address=m),s&&(n.geo={"@type":"GeoCoordinates",...s.latitude!=null&&{latitude:s.latitude},...s.longitude!=null&&{longitude:s.longitude}}),d!=null&&(n.numberOfRooms=d),l!=null&&(n.numberOfBeds=l),f&&(n.priceRange=f);const h=c(b);if(h&&(n.host=h),o&&(n.keywords=Array.isArray(o)?o.join(", "):o),a&&a.length>0){const p=a.map(P);if(n.review=p,!r){const u=a.map(i=>i.reviewRating?Number(i.reviewRating.ratingValue):NaN).filter(i=>!Number.isNaN(i));if(u.length>0){const i=u.reduce((v,C)=>v+C,0);n.aggregateRating={"@type":"AggregateRating",ratingValue:i/u.length,reviewCount:a.length,ratingCount:u.length}}}}return r&&(n.aggregateRating={"@type":"AggregateRating",ratingValue:r.ratingValue,...r.reviewCount!=null&&{reviewCount:r.reviewCount},...r.ratingCount!=null&&{ratingCount:r.ratingCount},...r.bestRating!=null&&{bestRating:r.bestRating},...r.worstRating!=null&&{worstRating:r.worstRating}}),n};var O=V;export{O as default,V as generateVacationRentalSchema};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate schema.org structured data for `VideoObject`, `Clip`, or
|
|
3
|
+
* `BroadcastEvent`.
|
|
4
|
+
*
|
|
5
|
+
* The `VideoOptions` input controls which type is produced and supports
|
|
6
|
+
* optional fields like `aggregateRating`, `reviews`, thumbnails and
|
|
7
|
+
* associated `Clip` or `BroadcastEvent` metadata. The result is a plain
|
|
8
|
+
* object ready to be stringified as JSON-LD for inclusion in a page.
|
|
9
|
+
*
|
|
10
|
+
* See `VideoOptions` below for accepted fields and shapes.
|
|
11
|
+
* @returns A JSON-LD compatible Video/Clip/BroadcastEvent object
|
|
12
|
+
*/
|
|
13
|
+
interface ImageRef {
|
|
14
|
+
url: string;
|
|
15
|
+
width?: number;
|
|
16
|
+
height?: number;
|
|
17
|
+
}
|
|
18
|
+
interface PersonRef {
|
|
19
|
+
name: string;
|
|
20
|
+
url?: string;
|
|
21
|
+
}
|
|
22
|
+
interface OrgRef {
|
|
23
|
+
name: string;
|
|
24
|
+
url?: string;
|
|
25
|
+
}
|
|
26
|
+
interface RatingItem {
|
|
27
|
+
ratingValue: number | string;
|
|
28
|
+
bestRating?: number | string;
|
|
29
|
+
worstRating?: number | string;
|
|
30
|
+
}
|
|
31
|
+
interface ReviewItem {
|
|
32
|
+
author?: string | PersonRef;
|
|
33
|
+
datePublished?: string;
|
|
34
|
+
reviewBody?: string;
|
|
35
|
+
reviewRating?: RatingItem;
|
|
36
|
+
}
|
|
37
|
+
interface ClipOptions {
|
|
38
|
+
name?: string;
|
|
39
|
+
startOffset?: number;
|
|
40
|
+
endOffset?: number;
|
|
41
|
+
url?: string;
|
|
42
|
+
}
|
|
43
|
+
interface BroadcastEventOptions {
|
|
44
|
+
name?: string;
|
|
45
|
+
startDate?: string;
|
|
46
|
+
endDate?: string;
|
|
47
|
+
isLiveBroadcast?: boolean;
|
|
48
|
+
url?: string;
|
|
49
|
+
}
|
|
50
|
+
interface AggregateRatingOptions {
|
|
51
|
+
ratingValue: number | string;
|
|
52
|
+
reviewCount?: number;
|
|
53
|
+
ratingCount?: number;
|
|
54
|
+
bestRating?: number | string;
|
|
55
|
+
worstRating?: number | string;
|
|
56
|
+
}
|
|
57
|
+
interface VideoOptions {
|
|
58
|
+
type?: 'VideoObject' | 'Clip' | 'BroadcastEvent';
|
|
59
|
+
name: string;
|
|
60
|
+
description?: string;
|
|
61
|
+
thumbnail?: string | ImageRef | (string | ImageRef)[];
|
|
62
|
+
uploadDate?: string;
|
|
63
|
+
duration?: string;
|
|
64
|
+
contentUrl?: string;
|
|
65
|
+
embedUrl?: string;
|
|
66
|
+
clip?: ClipOptions;
|
|
67
|
+
broadcastEvent?: BroadcastEventOptions;
|
|
68
|
+
publisher?: string | OrgRef;
|
|
69
|
+
author?: string | PersonRef;
|
|
70
|
+
reviews?: ReviewItem[];
|
|
71
|
+
aggregateRating?: AggregateRatingOptions;
|
|
72
|
+
}
|
|
73
|
+
declare const generateVideoSchema: ({ type, name, description, thumbnail, uploadDate, duration, contentUrl, embedUrl, clip, broadcastEvent, publisher, author, reviews, aggregateRating, }: VideoOptions) => any;
|
|
74
|
+
|
|
75
|
+
export { generateVideoSchema as default, generateVideoSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const I=t=>{if(t)return Array.isArray(t)?t.map(e=>typeof e=="string"?e:{"@type":"ImageObject",url:e.url,...e.width&&{width:e.width},...e.height&&{height:e.height}}):typeof t=="string"?t:{"@type":"ImageObject",url:t.url,...t.width&&{width:t.width},...t.height&&{height:t.height}}},c=t=>{if(!t)return;if(typeof t=="string")return{"@type":"Person",name:t};const e={"@type":"Person",name:t.name};return t.url&&(e.url=t.url),e},V=t=>{if(!t)return;if(typeof t=="string")return{"@type":"Organization",name:t};const e={"@type":"Organization",name:t.name};return t.url&&(e.url=t.url),e},B=t=>{const e={"@type":"Review"};return t.author&&(e.author=c(t.author)),t.datePublished&&(e.datePublished=t.datePublished),t.reviewBody&&(e.reviewBody=t.reviewBody),t.reviewRating&&(e.reviewRating={"@type":"Rating",ratingValue:t.reviewRating.ratingValue,...t.reviewRating.bestRating!=null&&{bestRating:t.reviewRating.bestRating},...t.reviewRating.worstRating!=null&&{worstRating:t.reviewRating.worstRating}}),e},P=({type:t="VideoObject",name:e,description:o,thumbnail:p,uploadDate:l,duration:m,contentUrl:d,embedUrl:h,clip:s,broadcastEvent:r,publisher:b,author:O,reviews:g,aggregateRating:a})=>{const n={"@context":"https://schema.org","@type":t,name:e};o&&(n.description=o);const R=I(p);R&&(n.thumbnail=R),l&&(n.uploadDate=l),m&&(n.duration=m),d&&(n.contentUrl=d),h&&(n.embedUrl=h);const w=V(b);w&&(n.publisher=w);const y=c(O);if(y&&(n.author=y),s){const i={"@type":"Clip"};s.name&&(i.name=s.name),s.startOffset!=null&&(i.startOffset=s.startOffset),s.endOffset!=null&&(i.endOffset=s.endOffset),s.url&&(i.url=s.url),n.clip=i}if(r){const i={"@type":"BroadcastEvent"};r.name&&(i.name=r.name),r.startDate&&(i.startDate=r.startDate),r.endDate&&(i.endDate=r.endDate),r.isLiveBroadcast!=null&&(i.isLiveBroadcast=r.isLiveBroadcast),r.url&&(i.url=r.url),n.broadcaster=i}if(g&&g.length>0){const i=g.map(B);if(n.review=i,!a){const f=g.map(u=>u.reviewRating?Number(u.reviewRating.ratingValue):NaN).filter(u=>!Number.isNaN(u));if(f.length>0){const u=f.reduce((v,C)=>v+C,0);n.aggregateRating={"@type":"AggregateRating",ratingValue:u/f.length,reviewCount:g.length,ratingCount:f.length}}}}return a&&(n.aggregateRating={"@type":"AggregateRating",ratingValue:a.ratingValue,...a.reviewCount!=null&&{reviewCount:a.reviewCount},...a.ratingCount!=null&&{ratingCount:a.ratingCount},...a.bestRating!=null&&{bestRating:a.bestRating},...a.worstRating!=null&&{worstRating:a.worstRating}}),n};var D=P;export{D as default,P as generateVideoSchema};
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic Cache Utilities
|
|
3
|
+
*
|
|
4
|
+
* A lightweight localStorage-backed cache used by module-level cache wrappers.
|
|
5
|
+
* Key behaviors:
|
|
6
|
+
* - Default expiration: 1 day (configurable per cache)
|
|
7
|
+
* - Search and filter requests bypass the cache and always fetch fresh data
|
|
8
|
+
* - Lists are stored as a normalized map (id -> item) for fast lookups
|
|
9
|
+
* - Provides both synchronous reads (`getCachedDataSync`) and async reads
|
|
10
|
+
* with API fallback (`getCachedData`)
|
|
11
|
+
* - Single-item helpers available (`getCachedSingleItem`, `getCachedSingleItemSync`)
|
|
12
|
+
*
|
|
13
|
+
* The main async helper `getCachedData` now accepts a single options object
|
|
14
|
+
* (`GetCachedDataOptions`) which includes `config`, optional `searchQuery`,
|
|
15
|
+
* `filters`, `pageLimit` and extra `params` for the list API. Module cache
|
|
16
|
+
* wrappers should call `getCachedData({ config, searchQuery, filters, pageLimit, params, headers })`.
|
|
17
|
+
* Both `getCachedData` and `getCachedSingleItem` accept an optional `headers`
|
|
18
|
+
* object which will be forwarded to the underlying `fetchData` calls.
|
|
19
|
+
*
|
|
20
|
+
* Organization:
|
|
21
|
+
* - Types
|
|
22
|
+
* - List Cache Functions
|
|
23
|
+
* - Single Item Cache Functions
|
|
24
|
+
* - Cache Utilities
|
|
25
|
+
*/
|
|
26
|
+
interface CacheConfig {
|
|
27
|
+
cacheKey: string;
|
|
28
|
+
apiUrl: string;
|
|
29
|
+
expirationMs?: number;
|
|
30
|
+
responseKey?: string;
|
|
31
|
+
params?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
interface GetCachedDataOptions {
|
|
34
|
+
config: CacheConfig;
|
|
35
|
+
params?: Record<string, unknown>;
|
|
36
|
+
headers?: Record<string, string>;
|
|
37
|
+
}
|
|
38
|
+
interface CachedData<T> {
|
|
39
|
+
items: Record<string, T>;
|
|
40
|
+
cachedAt: string;
|
|
41
|
+
count: number;
|
|
42
|
+
currentPage?: number;
|
|
43
|
+
}
|
|
44
|
+
interface CachedSingleData<T> {
|
|
45
|
+
item: T;
|
|
46
|
+
cachedAt: string;
|
|
47
|
+
}
|
|
48
|
+
interface ListResponse<T> {
|
|
49
|
+
count: number;
|
|
50
|
+
items: T[];
|
|
51
|
+
currentPage?: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get synchronous cached data for a module
|
|
55
|
+
* Returns empty result if cache is missing or stale
|
|
56
|
+
*
|
|
57
|
+
* @param cacheKey - localStorage key for the cache
|
|
58
|
+
* @param expirationMs - Cache expiration time in milliseconds (default: 1 day)
|
|
59
|
+
* @returns {count: number, items: T[]} - Cached data or empty array
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* const users = getCachedDataSync<UserBE>(LS_KEYS.USERS);
|
|
63
|
+
* if (users.items.length > 0) {
|
|
64
|
+
* console.log(users.items[0].name);
|
|
65
|
+
* }
|
|
66
|
+
*/
|
|
67
|
+
declare const getCachedDataSync: <T>(cacheKey: string, expirationMs?: number) => ListResponse<T>;
|
|
68
|
+
/**
|
|
69
|
+
* Get cached data with API fallback for a module
|
|
70
|
+
*
|
|
71
|
+
* Accepts a single `GetCachedDataOptions` object. The function will return
|
|
72
|
+
* cached results when fresh, or fetch from the API when the cache is stale
|
|
73
|
+
* or when `searchQuery`/`filters` are present (those always bypass cache).
|
|
74
|
+
*
|
|
75
|
+
* @param opts - `GetCachedDataOptions` containing `config`, optional
|
|
76
|
+
* `searchQuery`, `filters`, `pageLimit`, and extra `params`
|
|
77
|
+
* @returns Promise<{count: number, items: T[]}> - Cached or fresh data
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* const config = { cacheKey: LS_KEYS.USERS, apiUrl: USER_API_ROUTES.LIST, responseKey: 'users' };
|
|
81
|
+
* // Basic usage (reads cache if fresh)
|
|
82
|
+
* const users = await getCachedData<UserBE>({ config });
|
|
83
|
+
*
|
|
84
|
+
* // With search (bypasses cache)
|
|
85
|
+
* const filtered = await getCachedData<UserBE>({ config, searchQuery: 'John' });
|
|
86
|
+
*
|
|
87
|
+
* // With filters and custom page limit
|
|
88
|
+
* const active = await getCachedData<UserBE>({ config, filters: { enabled: true }, pageLimit: 200 });
|
|
89
|
+
*/
|
|
90
|
+
declare const getCachedData: <T>(opts: GetCachedDataOptions) => Promise<ListResponse<T>>;
|
|
91
|
+
/**
|
|
92
|
+
* Get single cached item by ID from a list cache
|
|
93
|
+
*
|
|
94
|
+
* @param cacheKey - localStorage key for the cache
|
|
95
|
+
* @param itemId - ID of the item to retrieve
|
|
96
|
+
* @returns T | null - Cached item or null
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* const user = getCachedItemById<UserBE>(LS_KEYS.USERS, 'user-123');
|
|
100
|
+
* if (user) {
|
|
101
|
+
* console.log(user.name);
|
|
102
|
+
* }
|
|
103
|
+
*/
|
|
104
|
+
declare const getCachedItemById: <T extends {
|
|
105
|
+
id: string;
|
|
106
|
+
}>(cacheKey: string, itemId: string) => T | null;
|
|
107
|
+
/**
|
|
108
|
+
* Get synchronous cached single item
|
|
109
|
+
* Returns null if cache is missing or stale
|
|
110
|
+
*
|
|
111
|
+
* @param cacheKey - localStorage key for the cache
|
|
112
|
+
* @param expirationMs - Cache expiration time in milliseconds (default: 1 day)
|
|
113
|
+
* @returns T | null - Cached item or null
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* const workspace = getCachedSingleItemSync<WorkspaceBE>(LS_KEYS.WORKSPACE);
|
|
117
|
+
* if (workspace) {
|
|
118
|
+
* console.log(workspace.name);
|
|
119
|
+
* }
|
|
120
|
+
*/
|
|
121
|
+
declare const getCachedSingleItemSync: <T>(cacheKey: string, expirationMs?: number) => T | null;
|
|
122
|
+
/**
|
|
123
|
+
* Get cached single item with API fallback
|
|
124
|
+
* Useful for workspace, profile, settings, etc.
|
|
125
|
+
*
|
|
126
|
+
* @param config - Cache configuration (cacheKey, apiUrl, expirationMs, responseKey)
|
|
127
|
+
* @param params - Optional query parameters for API request
|
|
128
|
+
* @returns Promise<T | null> - Cached or fresh item
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* const config = { cacheKey: LS_KEYS.WORKSPACE, apiUrl: '/api/workspace', responseKey: 'workspace' };
|
|
132
|
+
* const workspace = await getCachedSingleItem<WorkspaceBE>(config, { subdomain: 'school1' });
|
|
133
|
+
*/
|
|
134
|
+
declare const getCachedSingleItem: <T>(config: CacheConfig, params?: Record<string, string>, headers?: Record<string, string>) => Promise<T | null>;
|
|
135
|
+
/**
|
|
136
|
+
* Get cached data but fall back to the API when sync cache is empty.
|
|
137
|
+
*
|
|
138
|
+
* This helper first performs a quick synchronous cache check via
|
|
139
|
+
* `getCachedDataSync`. If that returns an empty result it will call
|
|
140
|
+
* the async `getCachedData` to fetch fresh data from the API and return
|
|
141
|
+
* the result. Use this when callers want a fast-path cache read but also
|
|
142
|
+
* need the ability to recall the API transparently when cache is missing.
|
|
143
|
+
*/
|
|
144
|
+
declare const getCachedDataWithFallback: <T>(config: CacheConfig, params?: Record<string, unknown>, headers?: Record<string, string>) => Promise<ListResponse<T>>;
|
|
145
|
+
/**
|
|
146
|
+
* Async variant to get a single item by ID with API fallback.
|
|
147
|
+
*
|
|
148
|
+
* Unlike `getCachedItemById` (sync), this function will call the API
|
|
149
|
+
* (via `getCachedDataWithFallback`) when the item is not available in
|
|
150
|
+
* the local cache. Requires a full `CacheConfig` so the API URL is
|
|
151
|
+
* available for fetching.
|
|
152
|
+
*/
|
|
153
|
+
declare const getCachedItemByIdAsync: <T extends {
|
|
154
|
+
id: string;
|
|
155
|
+
}>(config: CacheConfig, itemId: string, params?: Record<string, unknown>, headers?: Record<string, string>) => Promise<T | null>;
|
|
156
|
+
/**
|
|
157
|
+
* Invalidate (remove) cache for a module
|
|
158
|
+
* Useful after create/update/delete operations
|
|
159
|
+
*
|
|
160
|
+
* @param cacheKey - localStorage key for the cache
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* invalidateCache(LS_KEYS.USERS);
|
|
164
|
+
* const freshUsers = await getCachedData(config);
|
|
165
|
+
*/
|
|
166
|
+
declare const invalidateCache: (cacheKey: string) => void;
|
|
167
|
+
/**
|
|
168
|
+
* Preload cache for a module
|
|
169
|
+
* Useful to call on app initialization or login
|
|
170
|
+
*
|
|
171
|
+
* @param config - Cache configuration
|
|
172
|
+
* @returns Promise<ListResponse<T>> - Preloaded data
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* const config = { cacheKey: LS_KEYS.USERS, apiUrl: USER_API_ROUTES.LIST, responseKey: 'users' };
|
|
176
|
+
* await preloadCache(config);
|
|
177
|
+
*/
|
|
178
|
+
declare const preloadCache: <T>(config: CacheConfig) => Promise<ListResponse<T>>;
|
|
179
|
+
/**
|
|
180
|
+
* Check if cache is stale (older than expiration time)
|
|
181
|
+
*
|
|
182
|
+
* @param cacheKey - localStorage key for the cache
|
|
183
|
+
* @param expirationMs - Cache expiration time in milliseconds (default: 1 day)
|
|
184
|
+
* @returns boolean - True if cache is stale or doesn't exist
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* if (isCacheStale(LS_KEYS.USERS)) {
|
|
188
|
+
* await getCachedData(config); // This will fetch fresh data
|
|
189
|
+
* }
|
|
190
|
+
*/
|
|
191
|
+
declare const isCacheStale: (cacheKey: string, expirationMs?: number) => boolean;
|
|
192
|
+
|
|
193
|
+
export { type CacheConfig, type CachedData, type CachedSingleData, type GetCachedDataOptions, type ListResponse, getCachedData, getCachedDataSync, getCachedDataWithFallback, getCachedItemById, getCachedItemByIdAsync, getCachedSingleItem, getCachedSingleItemSync, invalidateCache, isCacheStale, preloadCache };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{API_METHODS as x}from"../constants/api-methods";import{ONE_DAY_IN_MS as A}from"../constants/cache-time";import{fetchData as O}from"./fetch-data";import{getStorageValue as w}from"../local-storage/get-storage-value";import{setStorageValue as q}from"../local-storage/set-storage-value";function k(t){if(!t||typeof t!="object")return!1;const n=t;return Array.isArray(n.items)&&typeof n.cachedAt=="string"&&typeof n.count=="number"}function M(t){if(!t||typeof t!="object")return!1;const n=t;return n.items!==void 0&&typeof n.items=="object"&&!Array.isArray(n.items)&&typeof n.cachedAt=="string"}const z=(t,n=A)=>{try{const e=w(t);if(e==null)return{count:0,items:[]};const s=new Date().getTime();if(k(e)){const r=new Date(e.cachedAt).getTime();return s-r<n?{count:e.count??e.items.length,items:e.items,currentPage:e.currentPage??void 0}:{count:0,items:[]}}if(M(e)){const r=new Date(e.cachedAt).getTime();if(s-r<n){const a=Object.values(e.items||{});return{count:e.count??a.length,items:a,currentPage:e.currentPage??void 0}}return{count:0,items:[]}}return{count:0,items:[]}}catch(e){return console.error(`Error getting cached data for ${t}:`,e),{count:0,items:[]}}},J=async t=>{const{config:n,params:e,headers:s}=t,{cacheKey:r,apiUrl:u,responseKey:a}=n,T=n.expirationMs??A,D=e?.pageLimit?.toString()??"100",$=e?.currentPage?.toString()??"1",p=e?.filters,l=e?.searchQuery;try{if(l&&l.trim()||e?.filters){const o={...e||{}};o.filters!==void 0&&delete o.filters;const f=Object.keys(o).reduce((i,h)=>(i[h]=String(o[h]),i),{}),y={pageLimit:D,currentPage:$,...l&&{searchQuery:l},...p?Object.keys(p).reduce((i,h)=>(i[h]=String(p[h]),i),{}):{},...f},P=new URLSearchParams(y),d=await O({url:`${u}?${P.toString()}`,method:x.GET,headers:s}),g=a?d?.data?.[a]:d?.data?.items||d?.data,m=Array.isArray(g)?g:[],R=d?.data?.currentPage,L=R==null?void 0:Number(R),N=e?.currentPage?Number(e.currentPage):void 0;return{count:d?.data?.count||m.length,items:m,currentPage:L??N}}const c=w(r),U=new Date().getTime();if(k(c)){const o=new Date(c.cachedAt).getTime();if(U-o<T)return{count:c.count,items:c.items,currentPage:c.currentPage??void 0}}if(M(c)){const o=new Date(c.cachedAt).getTime();if(U-o<T){const y=Object.values(c.items||{}),P=c.count,d=c.currentPage,g=e?.currentPage?Number(e.currentPage):void 0;if(g!==void 0&&g!==d){const m={...e||{}};m.filters!==void 0&&delete m.filters;const R=Object.keys(m).reduce((C,S)=>(C[S]=String(m[S]),C),{}),L={pageLimit:D,currentPage:String(g),...R},N=new URLSearchParams(L),i=await O({url:`${u}?${N.toString()}`,method:x.GET,headers:s}),h=(a?i?.data?.[a]:i?.data?.items)||i?.data,te=Array.isArray(h)?h:[],W=i?.data?.count,_=i?.data?.currentPage,ne=_==null?void 0:Number(_),re=te.reduce((C,S,se)=>{const Y=S,ae=Y?.id??Y?.uid??se,ce=String(ae);return C[ce]=S,C},{}),K=Object.assign({},c.items||{},re),Q=Object.values(K),V=W??Q.length,H=ne??g;if(Array.isArray(h)&&typeof W=="number"){const C={items:K,cachedAt:new Date().toISOString(),count:V,currentPage:H};q(r,C)}return{count:V,items:Q,currentPage:H}}return{count:P??y.length,items:y,currentPage:c.currentPage??void 0}}}const I={...e||{}};I.filters!==void 0&&delete I.filters;const X=Object.keys(I).reduce((o,f)=>(o[f]=String(I[f]),o),{}),Z={pageLimit:D,currentPage:$,...X},ee=new URLSearchParams(Z),b=await O({url:`${u}?${ee.toString()}`,method:x.GET,headers:s}),j=(a?b?.data?.[a]:b?.data?.items)||b?.data,G=Array.isArray(j)?j:[],E=b?.data?.count,v=b?.data?.currentPage,B=v==null?void 0:Number(v),F=e?.currentPage?Number(e.currentPage):void 0;if(Array.isArray(j)&&typeof E=="number"){const f={items:G.reduce((y,P,d)=>{const g=P,m=g?.id??g?.uid??d,R=String(m);return y[R]=P,y},{}),cachedAt:new Date().toISOString(),count:E,currentPage:B??F};q(r,f)}return{count:E,items:G,currentPage:B??F}}catch(c){return console.error(`Error fetching data for ${r}:`,c),{count:0,items:[]}}},fe=(t,n)=>{if(!n)return null;try{const e=w(t);if(k(e))return e.items.find(r=>r.id===n)||null;if(M(e))return e.items&&e.items[n]||null;const{items:s}=z(t);return s.find(r=>r.id===n)||null}catch(e){return console.error(`Error getting cached item by ID for ${t}:`,e),null}},Te=(t,n=A)=>{try{const e=w(t);if(!e)return null;const s=new Date().getTime(),r=new Date(e.cachedAt).getTime();return s-r<n?e.item:null}catch(e){return console.error(`Error getting cached single item for ${t}:`,e),null}},pe=async(t,n,e)=>{const{cacheKey:s,apiUrl:r}=t,u=t.expirationMs??A;try{const a=w(s),T=new Date().getTime();if(a){const l=new Date(a.cachedAt).getTime();if(T-l<u)return a.item}const D=n?`?${new URLSearchParams(n).toString()}`:"",p=(await O({url:`${r}${D}`,method:x.GET,headers:e}))?.data||null;if(p){const l={item:p,cachedAt:new Date().toISOString()};q(s,l)}return p}catch(a){return console.error(`Error fetching single item for ${s}:`,a),null}},oe=async(t,n,e)=>{const s=t.expirationMs??A;try{const r=z(t.cacheKey,s);return r&&r.count>0&&Array.isArray(r.items)&&r.items.length>0?r:await J({config:t,params:n,headers:e})}catch(r){return console.error(`Error in getCachedDataWithFallback for ${t.cacheKey}:`,r),{count:0,items:[]}}},ye=async(t,n,e,s)=>{if(!n)return null;try{const r=w(t.cacheKey);if(k(r)){const a=r.items.find(T=>T.id===n);if(a)return a}return M(r)&&r.items&&r.items[n]?r.items[n]:(await oe(t,e,s)).items.find(a=>a.id===n)||null}catch(r){return console.error(`Error in getCachedItemByIdAsync for ${t.cacheKey}:`,r),null}},Ce=t=>{try{localStorage.removeItem(t)}catch(n){console.error(`Error invalidating cache for ${t}:`,n)}},we=async t=>J({config:t}),Pe=(t,n=A)=>{try{const e=w(t);if(e==null)return!0;if(k(e)||M(e)){const s=new Date(e.cachedAt).getTime();return new Date().getTime()-s>=n}return!0}catch(e){return console.error(`Error checking cache staleness for ${t}:`,e),!0}};export{J as getCachedData,z as getCachedDataSync,oe as getCachedDataWithFallback,fe as getCachedItemById,ye as getCachedItemByIdAsync,pe as getCachedSingleItem,Te as getCachedSingleItemSync,Ce as invalidateCache,Pe as isCacheStale,we as preloadCache};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface Return {
|
|
2
|
+
option: string;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Returns available page-limit dropdown options based on total record count.
|
|
6
|
+
* @param totalRecords - Total number of records.
|
|
7
|
+
* @returns Array of page-limit option objects.
|
|
8
|
+
*/
|
|
9
|
+
declare const getAvailablePageLimits: (totalRecords: number) => Array<Return>;
|
|
10
|
+
|
|
11
|
+
export { getAvailablePageLimits };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dynamicPageLimit as o}from"./dynamic-page-limit";const s=n=>{const i=[10,15,25,100];if(n<i[0])return o([i[0]]);const a=i.filter(r=>r<n),t=i.find(r=>r>=n),e=[...a];return t&&!e.includes(t)&&e.push(t),o(e)};export{s as getAvailablePageLimits};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CalendarDay } from './type.mjs';
|
|
2
|
+
|
|
3
|
+
interface Params {
|
|
4
|
+
month: number;
|
|
5
|
+
year: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Generates an array of CalendarDay objects for the current month.
|
|
9
|
+
* @param params.month - Month number (1-based).
|
|
10
|
+
* @param params.year - Full year number.
|
|
11
|
+
* @returns Array of CalendarDay objects for the month.
|
|
12
|
+
*/
|
|
13
|
+
declare const getCalendarCurrentMonth: ({ month, year, }: Params) => Array<CalendarDay>;
|
|
14
|
+
|
|
15
|
+
export { getCalendarCurrentMonth };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var m=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var d=(a,r)=>{for(var t in r)m(a,t,{get:r[t],enumerable:!0})},f=(a,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of u(r))!D.call(a,e)&&e!==t&&m(a,e,{get:()=>r[e],enumerable:!(n=y(r,e))||n.enumerable});return a};var M=a=>f(m({},"__esModule",{value:!0}),a);var c={};d(c,{getCalendarCurrentMonth:()=>C});module.exports=M(c);var s=require("./get-number-of-days-in-month");const C=({month:a,year:r})=>{const t=require("dayjs"),n=new Date().getDate();return[...Array((0,s.getNumberOfDaysInMonth)({year:r,month:a}))].map((e,o)=>({date:t(`${r}-${a}-${o+1}`).format("YYYY-MM-DD"),dayOfMonth:o+1,isCurrentMonth:!0,isToday:n===o+1}))};0&&(module.exports={getCalendarCurrentMonth});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getNumberOfDaysInMonth as o}from"./get-number-of-days-in-month";const D=({month:a,year:t})=>{const e=require("dayjs"),n=new Date().getDate();return[...Array(o({year:t,month:a}))].map((m,r)=>({date:e(`${t}-${a}-${r+1}`).format("YYYY-MM-DD"),dayOfMonth:r+1,isCurrentMonth:!0,isToday:n===r+1}))};export{D as getCalendarCurrentMonth};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CalendarDay } from './type.mjs';
|
|
2
|
+
|
|
3
|
+
interface Params {
|
|
4
|
+
month: number;
|
|
5
|
+
year: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Generates a full calendar month grid including overflow days from adjacent months.
|
|
9
|
+
* @param params.month - Month index (0-based).
|
|
10
|
+
* @param params.year - Full year number.
|
|
11
|
+
* @returns Array of CalendarDay objects for the entire grid.
|
|
12
|
+
*/
|
|
13
|
+
declare const getCalendarDates: ({ month, year, }: Params) => Array<CalendarDay>;
|
|
14
|
+
|
|
15
|
+
export { getCalendarDates };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var s=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var C=(n,t)=>{for(var e in t)s(n,e,{get:t[e],enumerable:!0})},M=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of y(t))!p.call(n,r)&&r!==e&&s(n,r,{get:()=>t[r],enumerable:!(o=i(t,r))||o.enumerable});return n};var l=n=>M(s({},"__esModule",{value:!0}),n);var f={};C(f,{getCalendarDates:()=>D});module.exports=l(f);var m=require("./get-calendar-previous-month"),d=require("./get-calendar-next-month"),h=require("./get-calendar-current-month");const D=({month:n,year:t})=>{const e=require("dayjs"),o=require("dayjs/plugin/weekday");e.extend(o);const r=n+1,a=(0,h.getCalendarCurrentMonth)({month:r,year:t}),c=(0,m.getCalendarPreviousMonth)({currentMonthDays:a,month:r,year:t}),u=(0,d.getCalendarNextMonth)({currentMonthDays:a,month:r,year:t});return[...c,...a,...u]};0&&(module.exports={getCalendarDates});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getCalendarPreviousMonth as d}from"./get-calendar-previous-month";import{getCalendarNextMonth as h}from"./get-calendar-next-month";import{getCalendarCurrentMonth as c}from"./get-calendar-current-month";const l=({month:e,year:t})=>{const o=require("dayjs"),a=require("dayjs/plugin/weekday");o.extend(a);const n=e+1,r=c({month:n,year:t}),s=d({currentMonthDays:r,month:n,year:t}),m=h({currentMonthDays:r,month:n,year:t});return[...s,...r,...m]};export{l as getCalendarDates};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CalendarDay } from './type.mjs';
|
|
2
|
+
|
|
3
|
+
interface Params {
|
|
4
|
+
currentMonthDays: Array<CalendarDay>;
|
|
5
|
+
month: number;
|
|
6
|
+
year: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Generates the overflow CalendarDay entries from the next month to fill the grid.
|
|
10
|
+
* @param params.currentMonthDays - Days of the current month.
|
|
11
|
+
* @param params.month - Month number (1-based).
|
|
12
|
+
* @param params.year - Full year number.
|
|
13
|
+
* @returns Array of CalendarDay objects for the overflow days.
|
|
14
|
+
*/
|
|
15
|
+
declare const getCalendarNextMonth: ({ year, month, currentMonthDays, }: Params) => Array<CalendarDay>;
|
|
16
|
+
|
|
17
|
+
export { getCalendarNextMonth };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var o=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var M=(r,a)=>{for(var t in a)o(r,t,{get:a[t],enumerable:!0})},D=(r,a,t,n)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of f(a))!l.call(r,e)&&e!==t&&o(r,e,{get:()=>a[e],enumerable:!(n=h(a,e))||n.enumerable});return r};var $=r=>D(o({},"__esModule",{value:!0}),r);var i={};M(i,{getCalendarNextMonth:()=>c});module.exports=$(i);var m=require("./get-week-day");const c=({year:r,month:a,currentMonthDays:t})=>{const n=require("dayjs"),e=(0,m.getWeekday)(`${r}-${a}-${t.length}`),s=n(`${r}-${a}-01`).add(1,"month"),d=e&&7-e;return[...Array(d)].map((u,y)=>({date:n(`${s.year()}-${s.month()+1}-${y+1}`).format("YYYY-MM-DD"),dayOfMonth:y+1,isCurrentMonth:!1,isToday:!1}))};0&&(module.exports={getCalendarNextMonth});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getWeekday as m}from"./get-week-day";const M=({year:r,month:e,currentMonthDays:s})=>{const t=require("dayjs"),a=m(`${r}-${e}-${s.length}`),n=t(`${r}-${e}-01`).add(1,"month"),y=a&&7-a;return[...Array(y)].map((d,o)=>({date:t(`${n.year()}-${n.month()+1}-${o+1}`).format("YYYY-MM-DD"),dayOfMonth:o+1,isCurrentMonth:!1,isToday:!1}))};export{M as getCalendarNextMonth};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CalendarDay } from './type.mjs';
|
|
2
|
+
|
|
3
|
+
interface Params {
|
|
4
|
+
currentMonthDays: Array<CalendarDay>;
|
|
5
|
+
month: number;
|
|
6
|
+
year: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Generates the overflow CalendarDay entries from the previous month to fill the grid.
|
|
10
|
+
* @param params.currentMonthDays - Days of the current month.
|
|
11
|
+
* @param params.month - Month number (1-based).
|
|
12
|
+
* @param params.year - Full year number.
|
|
13
|
+
* @returns Array of CalendarDay objects for the overflow days.
|
|
14
|
+
*/
|
|
15
|
+
declare const getCalendarPreviousMonth: ({ currentMonthDays, month, year, }: Params) => Array<CalendarDay>;
|
|
16
|
+
|
|
17
|
+
export { getCalendarPreviousMonth };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var M=(r,a)=>{for(var e in a)n(r,e,{get:a[e],enumerable:!0})},c=(r,a,e,o)=>{if(a&&typeof a=="object"||typeof a=="function")for(let t of u(a))!f.call(r,t)&&t!==e&&n(r,t,{get:()=>a[t],enumerable:!(o=i(a,t))||o.enumerable});return r};var D=r=>c(n({},"__esModule",{value:!0}),r);var b={};M(b,{getCalendarPreviousMonth:()=>l});module.exports=D(b);var h=require("./get-week-day");const l=({currentMonthDays:r,month:a,year:e})=>{const o=require("dayjs"),t=(0,h.getWeekday)(r[0].date),s=o(`${e}-${a}-01`).subtract(1,"month"),y=t?t-1:6,d=o(r[0].date).subtract(y,"day").date();return[...Array(y)].map((p,m)=>({date:o(`${s.year()}-${s.month()+1}-${d+m}`).format("YYYY-MM-DD"),dayOfMonth:d+m,isCurrentMonth:!1,isToday:!1}))};0&&(module.exports={getCalendarPreviousMonth});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getWeekday as m}from"./get-week-day";const M=({currentMonthDays:r,month:y,year:d})=>{const a=require("dayjs"),t=m(r[0].date),e=a(`${d}-${y}-01`).subtract(1,"month"),o=t?t-1:6,n=a(r[0].date).subtract(o,"day").date();return[...Array(o)].map((h,s)=>({date:a(`${e.year()}-${e.month()+1}-${n+s}`).format("YYYY-MM-DD"),dayOfMonth:n+s,isCurrentMonth:!1,isToday:!1}))};export{M as getCalendarPreviousMonth};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=()=>new Date().getFullYear();export{e as getCurrentYear};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={0:"Sunday",1:"Monday",2:"Tuesday",3:"Wednesday",4:"Thursday",5:"Friday",6:"Saturday"},y=a=>e[a];export{e as dayMap,y as getDayName};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the dial code for a given ISO country code.
|
|
3
|
+
* @param countryCode - The ISO country code.
|
|
4
|
+
* @returns The dial code string, or undefined if not found.
|
|
5
|
+
*/
|
|
6
|
+
declare const getDialCode: (countryCode: string) => string | undefined;
|
|
7
|
+
|
|
8
|
+
export { getDialCode };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dialCodeMap as t}from"../constants/dial-codes";const i=e=>t.get(e);export{i as getDialCode};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface Params {
|
|
2
|
+
firstName: string;
|
|
3
|
+
lastName: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Combines first and last name into a full name string.
|
|
7
|
+
* @param params.firstName - The first name.
|
|
8
|
+
* @param params.lastName - The last name.
|
|
9
|
+
* @returns The combined full name.
|
|
10
|
+
*/
|
|
11
|
+
declare const getFullName: ({ firstName, lastName }: Params) => string;
|
|
12
|
+
|
|
13
|
+
export { getFullName };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const r=({firstName:a,lastName:t})=>`${a} ${t}`;export{r as getFullName};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o=()=>window&&window.location.href;export{o as getHref};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const r={0:"January",1:"February",2:"March",3:"April",4:"May",5:"June",6:"July",7:"August",8:"September",9:"October",10:"November",11:"December"},t=e=>r[e];export{t as getMonthName,r as monthMap};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface IMonthNameMap {
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
[key: string]: number;
|
|
6
|
+
}
|
|
7
|
+
declare const monthNameMap: IMonthNameMap;
|
|
8
|
+
/**
|
|
9
|
+
* Get the UTC month number (0-11) from a month name
|
|
10
|
+
* @param monthName - The name of the month (case-insensitive)
|
|
11
|
+
* @returns The UTC month number (0-11), or -1 if the month name is invalid
|
|
12
|
+
*/
|
|
13
|
+
declare const getMonthNumber: (monthName: string) => number;
|
|
14
|
+
|
|
15
|
+
export { type IMonthNameMap, getMonthNumber, monthNameMap };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const r={january:0,february:1,march:2,april:3,may:4,june:5,july:6,august:7,september:8,october:9,november:10,december:11},n=t=>{const e=t.toLowerCase().trim();return r[e]!==void 0?r[e]:-1};export{n as getMonthNumber,r as monthNameMap};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface Params {
|
|
2
|
+
year: number;
|
|
3
|
+
month: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Returns the number of days in a given month and year.
|
|
7
|
+
* @param params.year - The year.
|
|
8
|
+
* @param params.month - The month number (1-based).
|
|
9
|
+
* @returns Number of days in the month.
|
|
10
|
+
*/
|
|
11
|
+
declare const getNumberOfDaysInMonth: ({ year, month }: Params) => number;
|
|
12
|
+
|
|
13
|
+
export { getNumberOfDaysInMonth };
|