@timardex/cluemart-shared 1.5.599 → 1.5.601
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/dist/{chunk-YV2JDG4R.mjs → chunk-3VUHAHP7.mjs} +5 -86
- package/dist/chunk-3VUHAHP7.mjs.map +1 -0
- package/dist/chunk-X4VPNOHX.mjs +88 -0
- package/dist/chunk-X4VPNOHX.mjs.map +1 -0
- package/dist/{chunk-HBVPPRHO.mjs → chunk-Y6OS3HDB.mjs} +119 -80
- package/dist/chunk-Y6OS3HDB.mjs.map +1 -0
- package/dist/{chunk-2NQUR2AV.mjs → chunk-ZDDWPO5Y.mjs} +2 -2
- package/dist/formFields/index.mjs +3 -2
- package/dist/hooks/index.cjs +6 -0
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.mjs +8 -6
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.cjs +121 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +36 -6
- package/dist/index.d.ts +36 -6
- package/dist/index.mjs +107 -72
- package/dist/index.mjs.map +1 -1
- package/dist/sharing/index.cjs +162 -74
- package/dist/sharing/index.cjs.map +1 -1
- package/dist/sharing/index.d.mts +36 -6
- package/dist/sharing/index.d.ts +36 -6
- package/dist/sharing/index.mjs +32 -3
- package/dist/utils/index.mjs +13 -11
- package/package.json +1 -1
- package/dist/chunk-HBVPPRHO.mjs.map +0 -1
- package/dist/chunk-YV2JDG4R.mjs.map +0 -1
- /package/dist/{chunk-2NQUR2AV.mjs.map → chunk-ZDDWPO5Y.mjs.map} +0 -0
package/dist/sharing/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ type ShareStallType = {
|
|
|
30
30
|
type ShareEventInfoForInvitation = {
|
|
31
31
|
applicationDeadlineHours: number;
|
|
32
32
|
dateTime: Array<{
|
|
33
|
+
startDate: string;
|
|
33
34
|
stallTypes: ShareStallType[];
|
|
34
35
|
}>;
|
|
35
36
|
requirements?: Array<{
|
|
@@ -57,7 +58,15 @@ type ShareVendorInfoForApplication = {
|
|
|
57
58
|
};
|
|
58
59
|
};
|
|
59
60
|
|
|
61
|
+
/** Formats event `startDate` (`DD-MM-YYYY`) for share copy — same as share preview UI. */
|
|
62
|
+
declare function formatShareMarketDate(dateStr: string): string;
|
|
60
63
|
declare function formatStallCapacityLabel(stallCapacity: number): string;
|
|
64
|
+
/** Nested market dates + per-date stall lines for invitation share copy. */
|
|
65
|
+
declare function formatShareInvitationMarketDatesSection(dateTime: ShareEventInfoForInvitation["dateTime"]): string;
|
|
66
|
+
/** Bulleted requirements list for invitation share copy. */
|
|
67
|
+
declare function formatShareInvitationRequirementsSection(requirementLabels: string[]): string;
|
|
68
|
+
/** Bulleted categories list for application share copy. */
|
|
69
|
+
declare function formatShareApplicationCategoriesSection(categoryLabels: string[]): string;
|
|
61
70
|
declare function buildInvitationShareDescription(event: ShareEventForInvitation, eventInfo: ShareEventInfoForInvitation | null | undefined): string;
|
|
62
71
|
declare function buildApplicationShareDescription(vendor: ShareVendorForApplication, vendorInfo: ShareVendorInfoForApplication | null | undefined): string;
|
|
63
72
|
|
|
@@ -80,6 +89,15 @@ declare const SHARE_TYPE_PATH_REGEX: string;
|
|
|
80
89
|
declare function buildShareUrl(type: ShareType, id: string): string;
|
|
81
90
|
|
|
82
91
|
declare const SHARE_SITE_URL = "https://cluemart.co.nz";
|
|
92
|
+
/** Calendar marker for invitation market-dates share copy (U+1F4C5 📅). */
|
|
93
|
+
declare const SHARE_CALENDAR_ICON = "\uD83D\uDCC5";
|
|
94
|
+
declare const SHARE_MARKET_DATES_SECTION_HEADING = "\uD83D\uDCC5 Market dates:";
|
|
95
|
+
/** Check mark for invitation requirements share copy (U+2705 ✅). */
|
|
96
|
+
declare const SHARE_CHECKMARK_ICON = "\u2705";
|
|
97
|
+
declare const SHARE_REQUIREMENTS_SECTION_HEADING = "\u2705 Requirements:";
|
|
98
|
+
/** Label tag for application categories share copy (U+1F3F7 🏷️). */
|
|
99
|
+
declare const SHARE_CATEGORY_ICON = "\uD83C\uDFF7\uFE0F";
|
|
100
|
+
declare const SHARE_CATEGORIES_SECTION_HEADING = "\uD83C\uDFF7\uFE0F Categories:";
|
|
83
101
|
declare const DEFAULT_SHARE_OG_IMAGE = "https://cluemart.co.nz/assets/logo.webp";
|
|
84
102
|
declare const RESOURCE_SHARE_TYPES: readonly ["market", "stallholder", "partner"];
|
|
85
103
|
type ResourceShareType = (typeof RESOURCE_SHARE_TYPES)[number];
|
|
@@ -95,8 +113,16 @@ declare function formatCategoryLabel(category: ShareVendorCategory): string;
|
|
|
95
113
|
declare const SHARE_DESCRIPTION_SECTION_SEPARATOR = " \u00B7 ";
|
|
96
114
|
/** Blank line between share sections — title, address, dates, URL, etc. */
|
|
97
115
|
declare const SHARE_DESCRIPTION_SECTION_BREAK = "\n\n";
|
|
116
|
+
/**
|
|
117
|
+
* Line break for `og:description` meta content. Use instead of `\n` — Next.js
|
|
118
|
+
* HTML serialisation collapses literal newlines to spaces; Facebook reads ` `.
|
|
119
|
+
*/
|
|
120
|
+
declare const OG_DESCRIPTION_LINE_BREAK = " ";
|
|
121
|
+
/** Joins OG description sections for Facebook link cards (and Twitter). */
|
|
122
|
+
declare function joinShareOgDescriptionSections(sections: ReadonlyArray<string | false | null | undefined>): string;
|
|
98
123
|
declare function joinShareDescriptionSections(sections: ReadonlyArray<string | false | null | undefined>): string;
|
|
99
124
|
|
|
125
|
+
declare function splitShareDescriptionSections(value: string): string[];
|
|
100
126
|
/**
|
|
101
127
|
* Share copy with a blank line between each section (share sheet message, previews).
|
|
102
128
|
*/
|
|
@@ -106,8 +132,8 @@ declare function formatShareSectionsForMultilineDisplay(value: string): string;
|
|
|
106
132
|
*/
|
|
107
133
|
declare function formatShareSectionsForCompactDisplay(value: string): string;
|
|
108
134
|
/**
|
|
109
|
-
* Formats share descriptions for Open Graph / Twitter meta tags
|
|
110
|
-
*
|
|
135
|
+
* Formats share descriptions for Open Graph / Twitter meta tags.
|
|
136
|
+
* Sections are joined with {@link OG_DESCRIPTION_LINE_BREAK} (` `).
|
|
111
137
|
*/
|
|
112
138
|
declare function normalizeShareOgDescription(value: string): string;
|
|
113
139
|
/**
|
|
@@ -118,13 +144,17 @@ declare function normalizeShareOgDescription(value: string): string;
|
|
|
118
144
|
*/
|
|
119
145
|
declare function buildFacebookShareQuote(title: string, description: string): string | undefined;
|
|
120
146
|
/**
|
|
121
|
-
* Open Graph / Twitter description
|
|
122
|
-
*
|
|
123
|
-
|
|
147
|
+
* Open Graph / Twitter description from pre-built section strings.
|
|
148
|
+
* Prefer {@link joinShareOgDescriptionSections} when sections are already known.
|
|
149
|
+
*/
|
|
150
|
+
declare function buildShareOgDescriptionFromSections(sections: ReadonlyArray<string | false | null | undefined>): string;
|
|
151
|
+
/**
|
|
152
|
+
* Open Graph / Twitter description — body sections only (`og:title` is separate).
|
|
153
|
+
* Multiline / legacy ` · ` input is split into sections, then joined with ` `.
|
|
124
154
|
*/
|
|
125
155
|
declare function buildShareOgDescription(_title: string, description: string): string;
|
|
126
156
|
|
|
127
157
|
declare function normalizeShareRouteId(id: string): string;
|
|
128
158
|
declare function buildSharePagePath(resourceType: ShareResourceType, rawId: string): string;
|
|
129
159
|
|
|
130
|
-
export { DEFAULT_SHARE_OG_IMAGE, POST_SHARE_RESOURCE_TYPES, PUBLIC_SHARE_PATH_TYPES, type PostShareResourceType, type PublicSharePathType, RELATION_SHARE_APPLICATION, RELATION_SHARE_INVITATION, RELATION_SHARE_RESOURCE_TYPES, RESOURCE_SHARE_TYPES, RESOURCE_SHARE_TYPES_FOR_URL, type RelationSharePathType, type RelationShareResourceType, type ResourceShareType, SHARE_DESCRIPTION_SECTION_BREAK, SHARE_DESCRIPTION_SECTION_SEPARATOR, SHARE_RESOURCE_LABEL, SHARE_SITE_URL, SHARE_TYPE_PATH_REGEX, type ShareEventDateTime, type ShareEventForInvitation, type ShareEventInfoForInvitation, type ShareResourceType, type ShareStallType, type ShareType, type ShareVendorCategory, type ShareVendorForApplication, type ShareVendorInfoForApplication, buildApplicationShareDescription, buildFacebookShareQuote, buildInvitationShareDescription, buildShareOgDescription, buildSharePagePath, buildShareUrl, formatCategoryLabel, formatShareSectionsForCompactDisplay, formatShareSectionsForMultilineDisplay, formatStallCapacityLabel, isPostShareResourceType, isRelationShareResourceType, joinShareDescriptionSections, normalizeShareOgDescription, normalizeShareRouteId };
|
|
160
|
+
export { DEFAULT_SHARE_OG_IMAGE, OG_DESCRIPTION_LINE_BREAK, POST_SHARE_RESOURCE_TYPES, PUBLIC_SHARE_PATH_TYPES, type PostShareResourceType, type PublicSharePathType, RELATION_SHARE_APPLICATION, RELATION_SHARE_INVITATION, RELATION_SHARE_RESOURCE_TYPES, RESOURCE_SHARE_TYPES, RESOURCE_SHARE_TYPES_FOR_URL, type RelationSharePathType, type RelationShareResourceType, type ResourceShareType, SHARE_CALENDAR_ICON, SHARE_CATEGORIES_SECTION_HEADING, SHARE_CATEGORY_ICON, SHARE_CHECKMARK_ICON, SHARE_DESCRIPTION_SECTION_BREAK, SHARE_DESCRIPTION_SECTION_SEPARATOR, SHARE_MARKET_DATES_SECTION_HEADING, SHARE_REQUIREMENTS_SECTION_HEADING, SHARE_RESOURCE_LABEL, SHARE_SITE_URL, SHARE_TYPE_PATH_REGEX, type ShareEventDateTime, type ShareEventForInvitation, type ShareEventInfoForInvitation, type ShareResourceType, type ShareStallType, type ShareType, type ShareVendorCategory, type ShareVendorForApplication, type ShareVendorInfoForApplication, buildApplicationShareDescription, buildFacebookShareQuote, buildInvitationShareDescription, buildShareOgDescription, buildShareOgDescriptionFromSections, buildSharePagePath, buildShareUrl, formatCategoryLabel, formatShareApplicationCategoriesSection, formatShareInvitationMarketDatesSection, formatShareInvitationRequirementsSection, formatShareMarketDate, formatShareSectionsForCompactDisplay, formatShareSectionsForMultilineDisplay, formatStallCapacityLabel, isPostShareResourceType, isRelationShareResourceType, joinShareDescriptionSections, joinShareOgDescriptionSections, normalizeShareOgDescription, normalizeShareRouteId, splitShareDescriptionSections };
|
package/dist/sharing/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_SHARE_OG_IMAGE,
|
|
3
|
+
OG_DESCRIPTION_LINE_BREAK,
|
|
3
4
|
POST_SHARE_RESOURCE_TYPES,
|
|
4
5
|
PUBLIC_SHARE_PATH_TYPES,
|
|
5
6
|
RELATION_SHARE_APPLICATION,
|
|
@@ -7,8 +8,14 @@ import {
|
|
|
7
8
|
RELATION_SHARE_RESOURCE_TYPES,
|
|
8
9
|
RESOURCE_SHARE_TYPES,
|
|
9
10
|
RESOURCE_SHARE_TYPES_FOR_URL,
|
|
11
|
+
SHARE_CALENDAR_ICON,
|
|
12
|
+
SHARE_CATEGORIES_SECTION_HEADING,
|
|
13
|
+
SHARE_CATEGORY_ICON,
|
|
14
|
+
SHARE_CHECKMARK_ICON,
|
|
10
15
|
SHARE_DESCRIPTION_SECTION_BREAK,
|
|
11
16
|
SHARE_DESCRIPTION_SECTION_SEPARATOR,
|
|
17
|
+
SHARE_MARKET_DATES_SECTION_HEADING,
|
|
18
|
+
SHARE_REQUIREMENTS_SECTION_HEADING,
|
|
12
19
|
SHARE_RESOURCE_LABEL,
|
|
13
20
|
SHARE_SITE_URL,
|
|
14
21
|
SHARE_TYPE_PATH_REGEX,
|
|
@@ -16,20 +23,29 @@ import {
|
|
|
16
23
|
buildFacebookShareQuote,
|
|
17
24
|
buildInvitationShareDescription,
|
|
18
25
|
buildShareOgDescription,
|
|
26
|
+
buildShareOgDescriptionFromSections,
|
|
19
27
|
buildSharePagePath,
|
|
20
28
|
buildShareUrl,
|
|
21
29
|
formatCategoryLabel,
|
|
30
|
+
formatShareApplicationCategoriesSection,
|
|
31
|
+
formatShareInvitationMarketDatesSection,
|
|
32
|
+
formatShareInvitationRequirementsSection,
|
|
33
|
+
formatShareMarketDate,
|
|
22
34
|
formatShareSectionsForCompactDisplay,
|
|
23
35
|
formatShareSectionsForMultilineDisplay,
|
|
24
36
|
formatStallCapacityLabel,
|
|
25
37
|
isPostShareResourceType,
|
|
26
38
|
isRelationShareResourceType,
|
|
27
39
|
joinShareDescriptionSections,
|
|
40
|
+
joinShareOgDescriptionSections,
|
|
28
41
|
normalizeShareOgDescription,
|
|
29
|
-
normalizeShareRouteId
|
|
30
|
-
|
|
42
|
+
normalizeShareRouteId,
|
|
43
|
+
splitShareDescriptionSections
|
|
44
|
+
} from "../chunk-Y6OS3HDB.mjs";
|
|
45
|
+
import "../chunk-X4VPNOHX.mjs";
|
|
31
46
|
export {
|
|
32
47
|
DEFAULT_SHARE_OG_IMAGE,
|
|
48
|
+
OG_DESCRIPTION_LINE_BREAK,
|
|
33
49
|
POST_SHARE_RESOURCE_TYPES,
|
|
34
50
|
PUBLIC_SHARE_PATH_TYPES,
|
|
35
51
|
RELATION_SHARE_APPLICATION,
|
|
@@ -37,8 +53,14 @@ export {
|
|
|
37
53
|
RELATION_SHARE_RESOURCE_TYPES,
|
|
38
54
|
RESOURCE_SHARE_TYPES,
|
|
39
55
|
RESOURCE_SHARE_TYPES_FOR_URL,
|
|
56
|
+
SHARE_CALENDAR_ICON,
|
|
57
|
+
SHARE_CATEGORIES_SECTION_HEADING,
|
|
58
|
+
SHARE_CATEGORY_ICON,
|
|
59
|
+
SHARE_CHECKMARK_ICON,
|
|
40
60
|
SHARE_DESCRIPTION_SECTION_BREAK,
|
|
41
61
|
SHARE_DESCRIPTION_SECTION_SEPARATOR,
|
|
62
|
+
SHARE_MARKET_DATES_SECTION_HEADING,
|
|
63
|
+
SHARE_REQUIREMENTS_SECTION_HEADING,
|
|
42
64
|
SHARE_RESOURCE_LABEL,
|
|
43
65
|
SHARE_SITE_URL,
|
|
44
66
|
SHARE_TYPE_PATH_REGEX,
|
|
@@ -46,16 +68,23 @@ export {
|
|
|
46
68
|
buildFacebookShareQuote,
|
|
47
69
|
buildInvitationShareDescription,
|
|
48
70
|
buildShareOgDescription,
|
|
71
|
+
buildShareOgDescriptionFromSections,
|
|
49
72
|
buildSharePagePath,
|
|
50
73
|
buildShareUrl,
|
|
51
74
|
formatCategoryLabel,
|
|
75
|
+
formatShareApplicationCategoriesSection,
|
|
76
|
+
formatShareInvitationMarketDatesSection,
|
|
77
|
+
formatShareInvitationRequirementsSection,
|
|
78
|
+
formatShareMarketDate,
|
|
52
79
|
formatShareSectionsForCompactDisplay,
|
|
53
80
|
formatShareSectionsForMultilineDisplay,
|
|
54
81
|
formatStallCapacityLabel,
|
|
55
82
|
isPostShareResourceType,
|
|
56
83
|
isRelationShareResourceType,
|
|
57
84
|
joinShareDescriptionSections,
|
|
85
|
+
joinShareOgDescriptionSections,
|
|
58
86
|
normalizeShareOgDescription,
|
|
59
|
-
normalizeShareRouteId
|
|
87
|
+
normalizeShareRouteId,
|
|
88
|
+
splitShareDescriptionSections
|
|
60
89
|
};
|
|
61
90
|
//# sourceMappingURL=index.mjs.map
|
package/dist/utils/index.mjs
CHANGED
|
@@ -8,27 +8,29 @@ import {
|
|
|
8
8
|
capitalizeFirstLetter,
|
|
9
9
|
cluemartSocialMedia,
|
|
10
10
|
computeDailyClueState,
|
|
11
|
-
dateFormat,
|
|
12
|
-
formatDate,
|
|
13
|
-
formatTimestamp,
|
|
14
|
-
getCurrentAndFutureDates,
|
|
15
|
-
isFutureDatesBeforeThreshold,
|
|
16
|
-
isIsoDateString,
|
|
17
11
|
licenseNiceNames,
|
|
18
12
|
mapArrayToOptions,
|
|
19
13
|
normalizeUrl,
|
|
20
|
-
nzStartOfDay,
|
|
21
14
|
paymentMethodOptions,
|
|
22
15
|
removeTypename,
|
|
23
16
|
seededShuffle,
|
|
24
|
-
sortDatesChronologically,
|
|
25
17
|
statusOptions,
|
|
26
|
-
timeFormat,
|
|
27
|
-
toNZTime,
|
|
28
18
|
truncateText
|
|
29
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-3VUHAHP7.mjs";
|
|
30
20
|
import "../chunk-SBY5HTAP.mjs";
|
|
31
21
|
import "../chunk-ZR4TGWTS.mjs";
|
|
22
|
+
import {
|
|
23
|
+
dateFormat,
|
|
24
|
+
formatDate,
|
|
25
|
+
formatTimestamp,
|
|
26
|
+
getCurrentAndFutureDates,
|
|
27
|
+
isFutureDatesBeforeThreshold,
|
|
28
|
+
isIsoDateString,
|
|
29
|
+
nzStartOfDay,
|
|
30
|
+
sortDatesChronologically,
|
|
31
|
+
timeFormat,
|
|
32
|
+
toNZTime
|
|
33
|
+
} from "../chunk-X4VPNOHX.mjs";
|
|
32
34
|
export {
|
|
33
35
|
ANDROID_URL,
|
|
34
36
|
IOS_URL,
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sharing/formatCategoryLabel.ts","../src/sharing/joinShareDescriptionSections.ts","../src/sharing/buildRelationShareDescription.ts","../src/sharing/relationShareTypes.ts","../src/sharing/constants.ts","../src/sharing/buildShareUrl.ts","../src/sharing/normalizeShareDescription.ts","../src/sharing/normalizeShareRouteId.ts"],"sourcesContent":["import type { ShareVendorCategory } from \"./shareRelationTypes\";\n\nexport function formatCategoryLabel(category: ShareVendorCategory): string {\n const subcategoryNames = category.subcategories\n .map((subcategory) => subcategory.name)\n .filter(Boolean);\n\n if (subcategoryNames.length === 0) {\n return category.name;\n }\n\n return `${category.name} (${subcategoryNames.join(\", \")})`;\n}\n","/** Visible separator for multi-block share text when line breaks are stripped (legacy OG). */\nexport const SHARE_DESCRIPTION_SECTION_SEPARATOR = \" · \";\n\n/** Blank line between share sections — title, address, dates, URL, etc. */\nexport const SHARE_DESCRIPTION_SECTION_BREAK = \"\\n\\n\";\n\nexport function joinShareDescriptionSections(\n sections: ReadonlyArray<string | false | null | undefined>,\n): string {\n return sections\n .filter((section): section is string => Boolean(section))\n .join(SHARE_DESCRIPTION_SECTION_BREAK);\n}\n","import { formatCategoryLabel } from \"./formatCategoryLabel\";\nimport { joinShareDescriptionSections } from \"./joinShareDescriptionSections\";\nimport type {\n ShareEventForInvitation,\n ShareEventInfoForInvitation,\n ShareVendorForApplication,\n ShareVendorInfoForApplication,\n} from \"./shareRelationTypes\";\n\nexport type {\n ShareEventDateTime,\n ShareEventForInvitation,\n ShareEventInfoForInvitation,\n ShareStallType,\n ShareVendorCategory,\n ShareVendorForApplication,\n ShareVendorInfoForApplication,\n} from \"./shareRelationTypes\";\n\nfunction formatShareDate(isoDate: string): string {\n try {\n return new Intl.DateTimeFormat(\"en-NZ\", {\n day: \"numeric\",\n month: \"short\",\n year: \"numeric\",\n }).format(new Date(isoDate));\n } catch {\n return isoDate;\n }\n}\n\nexport function formatStallCapacityLabel(stallCapacity: number): string {\n return stallCapacity > 0 ? ` (${stallCapacity} spaces available)` : \" - Full\";\n}\n\nexport function buildInvitationShareDescription(\n event: ShareEventForInvitation,\n eventInfo: ShareEventInfoForInvitation | null | undefined,\n): string {\n const stallTypes =\n eventInfo?.dateTime?.flatMap((date) => date.stallTypes) ?? [];\n\n if (!eventInfo || stallTypes.length === 0) {\n return event.description?.trim() || \"\";\n }\n\n const requirementLabels = (eventInfo.requirements ?? [])\n .filter((item) => item.value)\n .map((item) => item.label);\n\n const sections = [\n event.location.fullAddress,\n ...event.dateTime.map((date) => {\n const start = formatShareDate(date.startDate);\n // DO NOT share end date for now, we will add it later if needed\n return `Market date: ${start}`;\n }),\n `Application deadline: vendors must apply at least ${eventInfo.applicationDeadlineHours} hours before each market date.`,\n ...stallTypes.map(\n (stall) =>\n `Stall: ${stall.label} — $${stall.price}${formatStallCapacityLabel(stall.stallCapacity)}`,\n ),\n requirementLabels.length > 0 &&\n `Requirements: ${requirementLabels.join(\", \")}`,\n ];\n\n return joinShareDescriptionSections(sections);\n}\n\nexport function buildApplicationShareDescription(\n vendor: ShareVendorForApplication,\n vendorInfo: ShareVendorInfoForApplication | null | undefined,\n): string {\n const categoryLabels = vendor.categories.map((category) =>\n formatCategoryLabel(category),\n );\n\n if (!vendorInfo) {\n return vendor.description?.trim() || \"\";\n }\n\n const compliance = vendorInfo.compliance;\n const complianceLabels = [\n compliance?.liabilityInsurance && \"Liability insurance\",\n compliance?.foodBeverageLicense && \"Food & beverage licence\",\n ].filter(Boolean);\n\n const profileDescription = vendor.description?.trim();\n\n const sections = [\n categoryLabels.length > 0 && `Categories: ${categoryLabels.join(\", \")}`,\n `Stall size: ${vendorInfo.stallInfo.size.width}m × ${vendorInfo.stallInfo.size.depth}m`,\n `Compliance: ${complianceLabels.length > 0 ? complianceLabels.join(\", \") : \"Not specified\"}`,\n `Price range: $${vendorInfo.product.priceRange.min} – $${vendorInfo.product.priceRange.max}`,\n profileDescription,\n ];\n\n return joinShareDescriptionSections(sections);\n}\n","/** Path segments for relation share URLs — must match mobile `RelationTitle` values. */\nexport const RELATION_SHARE_INVITATION = \"invitation\" as const;\nexport const RELATION_SHARE_APPLICATION = \"application\" as const;\n\nexport const RELATION_SHARE_RESOURCE_TYPES = [\n RELATION_SHARE_INVITATION,\n RELATION_SHARE_APPLICATION,\n] as const;\n\nexport type RelationShareResourceType =\n (typeof RELATION_SHARE_RESOURCE_TYPES)[number];\n\nexport function isRelationShareResourceType(\n resourceType: string,\n): resourceType is RelationShareResourceType {\n return (RELATION_SHARE_RESOURCE_TYPES as readonly string[]).includes(\n resourceType,\n );\n}\n","import {\n RELATION_SHARE_APPLICATION,\n RELATION_SHARE_INVITATION,\n type RelationShareResourceType,\n} from \"./relationShareTypes\";\n\nexport {\n RELATION_SHARE_APPLICATION,\n RELATION_SHARE_INVITATION,\n RELATION_SHARE_RESOURCE_TYPES,\n isRelationShareResourceType,\n type RelationShareResourceType,\n} from \"./relationShareTypes\";\n\nexport const SHARE_SITE_URL = \"https://cluemart.co.nz\";\n\nexport const DEFAULT_SHARE_OG_IMAGE = `${SHARE_SITE_URL}/assets/logo.webp`;\n\nexport const RESOURCE_SHARE_TYPES = [\n \"market\",\n \"stallholder\",\n \"partner\",\n] as const;\n\nexport type ResourceShareType = (typeof RESOURCE_SHARE_TYPES)[number];\n\nexport const POST_SHARE_RESOURCE_TYPES = [\n \"daily_meets\",\n \"daily_tips\",\n \"daily_games\",\n] as const;\n\nexport type PostShareResourceType = (typeof POST_SHARE_RESOURCE_TYPES)[number];\n\nexport type ShareResourceType =\n | ResourceShareType\n | PostShareResourceType\n | RelationShareResourceType;\n\nexport const SHARE_RESOURCE_LABEL: Record<ShareResourceType, string> = {\n [RELATION_SHARE_APPLICATION]: \"Application\",\n [RELATION_SHARE_INVITATION]: \"Invitation\",\n daily_games: \"Daily Game\",\n daily_meets: \"Daily Meet\",\n daily_tips: \"Daily Tip\",\n market: \"Market\",\n partner: \"Partner\",\n stallholder: \"Stallholder\",\n};\n\nexport function isPostShareResourceType(\n resourceType: ShareResourceType,\n): resourceType is PostShareResourceType {\n return (POST_SHARE_RESOURCE_TYPES as readonly string[]).includes(\n resourceType,\n );\n}\n","import {\n POST_SHARE_RESOURCE_TYPES,\n RESOURCE_SHARE_TYPES,\n SHARE_SITE_URL,\n} from \"./constants\";\nimport {\n RELATION_SHARE_APPLICATION,\n RELATION_SHARE_INVITATION,\n} from \"./relationShareTypes\";\n\n/** Path segments for public resource share URLs (markets, posts, etc.). */\nexport const PUBLIC_SHARE_PATH_TYPES = [\n ...RESOURCE_SHARE_TYPES,\n ...POST_SHARE_RESOURCE_TYPES,\n] as const;\n\nexport type PublicSharePathType = (typeof PUBLIC_SHARE_PATH_TYPES)[number];\n\n/** @deprecated Use {@link PUBLIC_SHARE_PATH_TYPES} — kept for mobile deep-link helpers. */\nexport const RESOURCE_SHARE_TYPES_FOR_URL = PUBLIC_SHARE_PATH_TYPES;\n\nexport type RelationSharePathType =\n | typeof RELATION_SHARE_INVITATION\n | typeof RELATION_SHARE_APPLICATION;\n\nexport type ShareType = PublicSharePathType | RelationSharePathType;\n\n/** Alternation for deep-link regexes — keep in sync with {@link ShareType}. */\nexport const SHARE_TYPE_PATH_REGEX = [\n ...PUBLIC_SHARE_PATH_TYPES,\n RELATION_SHARE_APPLICATION,\n RELATION_SHARE_INVITATION,\n].join(\"|\");\n\nexport function buildShareUrl(type: ShareType, id: string): string {\n return `${SHARE_SITE_URL}/share/${type}/${encodeURIComponent(id)}`;\n}\n","import {\n SHARE_DESCRIPTION_SECTION_BREAK,\n SHARE_DESCRIPTION_SECTION_SEPARATOR,\n} from \"./joinShareDescriptionSections\";\n\nconst LEGACY_BULLET_PREFIX = \"• \";\n\n/** Trims a share section and collapses spaces per line; preserves line breaks. */\nfunction normalizeShareSection(value: string | null | undefined): string {\n if (value == null) {\n return \"\";\n }\n return value\n .trim()\n .split(\"\\n\")\n .map((line) => line.trim().replace(/[ \\t]+/g, \" \"))\n .join(\"\\n\")\n .replace(/\\n{3,}/g, \"\\n\\n\");\n}\n\nfunction stripLegacyBulletPrefix(section: string): string {\n return section.startsWith(LEGACY_BULLET_PREFIX)\n ? section.slice(LEGACY_BULLET_PREFIX.length)\n : section;\n}\n\nfunction splitShareDescriptionSections(value: string): string[] {\n const trimmed = value.trim();\n if (!trimmed) {\n return [];\n }\n\n if (trimmed.includes(SHARE_DESCRIPTION_SECTION_SEPARATOR)) {\n return trimmed\n .split(SHARE_DESCRIPTION_SECTION_SEPARATOR)\n .map((section) => stripLegacyBulletPrefix(normalizeShareSection(section)))\n .filter((section) => section.length > 0);\n }\n\n if (/\\n\\n/.test(trimmed)) {\n return trimmed\n .split(/\\n\\n+/)\n .map((section) => stripLegacyBulletPrefix(normalizeShareSection(section)))\n .filter((section) => section.length > 0);\n }\n\n if (/\\n/.test(trimmed)) {\n return trimmed\n .split(/\\n+/)\n .map((section) => stripLegacyBulletPrefix(normalizeShareSection(section)))\n .filter((section) => section.length > 0);\n }\n\n return [stripLegacyBulletPrefix(normalizeShareSection(trimmed))];\n}\n\nfunction collapseExcessiveBlankLines(value: string): string {\n return value.replace(/\\n{4,}/g, \"\\n\\n\\n\").trim();\n}\n\n/**\n * Share copy with a blank line between each section (share sheet message, previews).\n */\nexport function formatShareSectionsForMultilineDisplay(value: string): string {\n return collapseExcessiveBlankLines(\n splitShareDescriptionSections(value).join(SHARE_DESCRIPTION_SECTION_BREAK),\n );\n}\n\n/**\n * Formats multiline share copy for UIs that strip line breaks (legacy OG one-liners).\n */\nexport function formatShareSectionsForCompactDisplay(value: string): string {\n return splitShareDescriptionSections(value).join(\n SHARE_DESCRIPTION_SECTION_SEPARATOR,\n );\n}\n\n/**\n * Formats share descriptions for Open Graph / Twitter meta tags when crawlers\n * collapse line breaks.\n */\nexport function normalizeShareOgDescription(value: string): string {\n const trimmed = value.trim();\n if (!trimmed) {\n return \"\";\n }\n\n if (\n /\\n\\n/.test(trimmed) ||\n trimmed.includes(SHARE_DESCRIPTION_SECTION_SEPARATOR)\n ) {\n return formatShareSectionsForCompactDisplay(trimmed);\n }\n\n return trimmed.replace(/\\s+/g, \" \").trim();\n}\n\n/**\n * Quote text for Facebook ShareDialog on iOS (`ShareLinkContent.quote`).\n *\n * Title + blank lines + body sections. URL is omitted — `contentUrl` supplies\n * the link card (OG on `/share/*` controls card title/image).\n */\nexport function buildFacebookShareQuote(\n title: string,\n description: string,\n): string | undefined {\n const titleSection = normalizeShareSection(title);\n const body = formatShareSectionsForMultilineDisplay(\n normalizeShareSection(description),\n );\n const sections = [titleSection, body].filter((section) => section.length > 0);\n const quote = sections.join(SHARE_DESCRIPTION_SECTION_BREAK).trim();\n return quote.length > 0 ? quote : undefined;\n}\n\n/**\n * Open Graph / Twitter description — single line, no repeated `og:title`.\n *\n * Facebook's link card does not render `\\n`; sections are joined with ` · `.\n */\nexport function buildShareOgDescription(\n _title: string,\n description: string,\n): string {\n return normalizeShareOgDescription(description);\n}\n","import type { ShareResourceType } from \"./constants\";\n\nexport function normalizeShareRouteId(id: string): string {\n try {\n return decodeURIComponent(id);\n } catch {\n return id;\n }\n}\n\nexport function buildSharePagePath(\n resourceType: ShareResourceType,\n rawId: string,\n): string {\n return `/share/${resourceType}/${encodeURIComponent(normalizeShareRouteId(rawId))}`;\n}\n"],"mappings":";AAEO,SAAS,oBAAoB,UAAuC;AACzE,QAAM,mBAAmB,SAA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AAOO,SAAS,wBACd,QACA,aACQ;AACR,SAAO,4BAA4B,WAAW;AAChD;;;AC7HO,SAAS,sBAAsB,IAAoB;AACxD,MAAI;AACF,WAAO,mBAAmB,EAAE;AAAA,EAC9B,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,SAAS,mBACd,cACA,OACQ;AACR,SAAO,UAAU,YAAY,IAAI,mBAAmB,sBAAsB,KAAK,CAAC,CAAC;AACnF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/date.ts","../src/utils/dailyClueGame.ts","../src/utils/utils.ts","../src/utils/school.ts"],"sourcesContent":["import dayjs from \"dayjs\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat.js\";\nimport isSameOrAfter from \"dayjs/plugin/isSameOrAfter.js\";\nimport timezone from \"dayjs/plugin/timezone.js\";\nimport utc from \"dayjs/plugin/utc.js\";\n\nexport const dateFormat = \"DD-MM-YYYY\";\nexport const timeFormat = \"HH:mm\";\n\n// Enable custom format parsing\ndayjs.extend(customParseFormat);\ndayjs.extend(utc);\ndayjs.extend(timezone);\ndayjs.extend(isSameOrAfter);\n\nconst NZ_TZ = \"Pacific/Auckland\";\n\nexport function toNZTime(date?: Date | string) {\n return date ? dayjs(date).tz(NZ_TZ) : dayjs().tz(NZ_TZ);\n}\n\n/** Start of the calendar day in Pacific/Auckland (daily games, streaks, etc.). */\nexport function nzStartOfDay(\n input?: Date | string | number | null,\n): dayjs.Dayjs {\n if (input == null) {\n return dayjs().tz(NZ_TZ).startOf(\"day\");\n }\n return dayjs.tz(input, NZ_TZ).startOf(\"day\");\n}\n\ntype DateFormat = \"date\" | \"time\" | \"datetime\";\n\n/**\n * Format a date string to a more readable format.\n * @param dateStr - the date string\n * @param timeStr - optional time string\n * @param display - 'date' | 'time' | 'datetime'\n * @returns formatted string based on display option\n */\nexport const formatDate = (\n dateStr: string,\n display: DateFormat = \"datetime\",\n timeStr?: string,\n) => {\n // Combine date and time into a single string if time is provided\n const dateTimeStr = timeStr ? `${dateStr} ${timeStr}` : dateStr;\n\n // Parse with formats\n const dateTime = timeStr\n ? dayjs(dateTimeStr, `${dateFormat} ${timeFormat}`)\n : dayjs(dateStr, dateFormat);\n\n // Format parts\n const formattedDate = dateTime.format(\"dddd, D MMMM, YYYY\");\n const formattedTime = dateTime.format(\"h:mm a\");\n\n // Return based on display option\n switch (display) {\n case \"date\":\n return formattedDate;\n case \"time\":\n return formattedTime;\n case \"datetime\":\n return `${formattedDate} at ${formattedTime}`;\n default:\n return formattedDate;\n }\n};\n\nexport const getCurrentAndFutureDates = <\n T extends { startDate: string; startTime: string },\n>(\n dates: T[],\n): T[] => {\n const now = dayjs(); // current date and time\n\n return dates.filter((dateObj) => {\n const dateTime = dayjs(\n `${dateObj.startDate} ${dateObj.startTime}`,\n `${dateFormat} ${timeFormat}`,\n );\n return dateTime.isSameOrAfter(now);\n });\n};\n\nexport const isFutureDatesBeforeThreshold = (\n date: {\n startDate: string;\n startTime: string;\n },\n minHoursFromNow: number,\n): boolean => {\n const threshold = minHoursFromNow\n ? dayjs().add(minHoursFromNow, \"hour\")\n : dayjs().startOf(\"day\");\n\n const dateTime = dayjs(\n `${date.startDate} ${date.startTime}`,\n `${dateFormat} ${timeFormat}`,\n );\n\n return dateTime.isSameOrAfter(threshold);\n};\n\nexport const formatTimestamp = (timestamp: string) => {\n const formattedDate = toNZTime(timestamp).format(dateFormat);\n\n return formatDate(formattedDate, \"date\");\n};\n\nexport const isIsoDateString = (value: unknown): value is string => {\n return typeof value === \"string\" && !isNaN(Date.parse(value));\n};\n\n/**\n * Sort an array of date strings by their proximity to the current date.\n * @param dates - The array of date strings to sort.\n * @returns - The sorted array of date strings.\n */\nexport function sortDatesChronologically<\n T extends { startDate: string; startTime: string },\n>(dates: T[]): T[] {\n if (!dates || !dates.length) {\n return [];\n }\n\n return [...dates].sort((a, b) => {\n const dateTimeFormat = `${dateFormat} ${timeFormat}`;\n const dateA = dayjs(`${a.startDate} ${a.startTime}`, dateTimeFormat);\n const dateB = dayjs(`${b.startDate} ${b.startTime}`, dateTimeFormat);\n return dateA.valueOf() - dateB.valueOf(); // chronological order\n });\n}\n","import type { Dayjs } from \"dayjs\";\n\nimport {\n DailyClueGameData,\n GamePlacement,\n GamePlacementClue,\n gameScreenIdentifierList,\n} from \"../types/game/dailyClue\";\n\nimport { nzStartOfDay } from \"./date\";\n\nfunction createSeededRng(seed: number) {\n let t = seed >>> 0;\n\n return function random() {\n t += 0x6d2b79f5;\n let x = t;\n\n x = Math.imul(x ^ (x >>> 15), x | 1);\n x ^= x + Math.imul(x ^ (x >>> 7), x | 61);\n\n return ((x ^ (x >>> 14)) >>> 0) / 4294967296;\n };\n}\n\nfunction hashStringToNumber(seed: string): number {\n let hash = 2166136261;\n\n for (let i = 0; i < seed.length; i++) {\n hash ^= seed.codePointAt(i) ?? 0;\n hash = Math.imul(hash, 16777619);\n }\n\n return hash >>> 0;\n}\n\n/** Seeded shuffle so all players see the same letter order / placements for a game. */\nexport function seededShuffle<T>(array: readonly T[], seed: string): T[] {\n const rng = createSeededRng(hashStringToNumber(seed));\n const result = [...array];\n\n for (let i = result.length - 1; i > 0; i--) {\n const j = Math.floor(rng() * (i + 1));\n [result[i], result[j]] = [result[j], result[i]];\n }\n\n return result;\n}\n\nfunction getDayIndex(start: Dayjs, today: Dayjs): number {\n return today.diff(start, \"day\");\n}\n\nexport function computeDailyClueState(dailyClue: DailyClueGameData): {\n todaysClue: GamePlacementClue | null;\n todaysLetter: string | null;\n todaysPlacement: GamePlacement | null;\n} | null {\n const { startDate, endDate } = dailyClue.gameFields.gameDate;\n const { solutionShuffled, collected } = dailyClue.letterInfo;\n\n const today = nzStartOfDay();\n const start = nzStartOfDay(startDate);\n const end = nzStartOfDay(endDate);\n\n // Before game starts\n if (today.isBefore(start)) {\n return null;\n }\n\n const shuffledPlacements = seededShuffle(\n gameScreenIdentifierList,\n start.toISOString(),\n );\n\n const index = getDayIndex(start, today);\n\n // After game ends\n if (today.isAfter(end)) {\n return {\n todaysClue: null,\n todaysLetter: null,\n todaysPlacement: null,\n };\n }\n\n // Safety: index must exist in BOTH arrays\n if (\n index < 0 ||\n index >= solutionShuffled.length ||\n index >= shuffledPlacements.length\n ) {\n return null;\n }\n\n const letterToday = solutionShuffled[index];\n const placement = shuffledPlacements[index];\n\n if (!letterToday || !placement) return null;\n\n const alreadyCollectedToday = (collected ?? []).includes(letterToday);\n\n // Already completed today\n if (alreadyCollectedToday) {\n return {\n todaysClue: null,\n todaysLetter: null,\n todaysPlacement: null,\n };\n }\n\n // Active state\n return {\n todaysClue: placement.clue,\n todaysLetter: letterToday,\n todaysPlacement: placement.id,\n };\n}\n","import {\n EnumInviteStatus,\n EnumPaymentMethod,\n EnumRegions,\n EnumSocialMedia,\n EnumUserLicence,\n} from \"src/enums\";\nimport { OptionItem, SocialMediaType } from \"src/types\";\n\nimport { isIsoDateString } from \"./date\";\n\nexport const removeTypename = (obj: any): any => {\n // Preserve Date objects\n if (obj instanceof Date) {\n return obj;\n }\n\n // Preserve File objects (for apollo-upload-client)\n if (obj instanceof File) {\n return obj;\n }\n\n // Preserve ISO date strings\n if (isIsoDateString(obj)) {\n return obj;\n }\n\n // Handle arrays\n if (Array.isArray(obj)) {\n return obj.map(removeTypename);\n }\n\n // Handle plain objects only\n if (obj !== null && typeof obj === \"object\") {\n const { __typename, ...cleanedObj } = obj;\n\n return Object.keys(cleanedObj).reduce((acc: any, key) => {\n acc[key] = removeTypename(cleanedObj[key]);\n return acc;\n }, {});\n }\n\n // Primitives\n return obj;\n};\n\n/**\n * Truncate text to a specified length and append ellipsis if necessary.\n * @param text\n * @param maxLength\n * @returns\n */\nexport const truncateText = (text: string, maxLength: number = 30): string => {\n return text.length > maxLength ? text.substring(0, maxLength) + \"...\" : text;\n};\n\n/**\n * Convert an array of strings to an array of objects with label and value properties.\n * @param items - The array of strings to convert.\n * @returns - The converted array of objects.\n */\nexport const mapArrayToOptions = (items: string[]): OptionItem[] =>\n items.map((item) => ({\n label: item,\n value: item,\n }));\n\nexport const capitalizeFirstLetter = (str: string): string => {\n return str\n .split(\" \")\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(\" \");\n};\n\nexport const statusOptions = [\n ...Object.values(EnumInviteStatus)\n .map((status) => ({\n label: status,\n value: status,\n }))\n .sort((a, b) => a.label.localeCompare(b.label)), // Sort the options alphabetically\n];\n\nexport const availableRegionTypes = Object.values(EnumRegions);\nexport const availableRegionOptions: OptionItem[] =\n mapArrayToOptions(availableRegionTypes);\n\nexport const paymentMethodOptions: OptionItem[] = mapArrayToOptions(\n Object.values(EnumPaymentMethod),\n);\n\nexport function normalizeUrl(url: string): string {\n if (!url.startsWith(\"http://\") && !url.startsWith(\"https://\")) {\n return `https://${url}`;\n }\n return url;\n}\n\nexport const licenseNiceNames: Record<EnumUserLicence, string> = {\n [EnumUserLicence.PRO_EVENT]: \"Pro Event\",\n [EnumUserLicence.PRO_VENDOR]: \"Pro Stallholder\",\n [EnumUserLicence.STANDARD_EVENT]: \"Standard Event\",\n [EnumUserLicence.STANDARD_VENDOR]: \"Standard Stallholder\",\n [EnumUserLicence.PRO_PLUS_EVENT]: \"Pro+Ads Event\",\n [EnumUserLicence.PRO_PLUS_VENDOR]: \"Pro+Ads Stallholder\",\n [EnumUserLicence.STANDARD_PARTNER]: \"Partner\",\n};\n\nexport const cluemartSocialMedia: SocialMediaType[] = [\n {\n link: \"https://www.facebook.com/ClueMartApp\",\n name: EnumSocialMedia.FACEBOOK,\n },\n {\n link: \"https://www.instagram.com/cluemart_app\",\n name: EnumSocialMedia.INSTAGRAM,\n },\n {\n link: \"https://www.tiktok.com/@cluemart\",\n name: EnumSocialMedia.TIKTOK,\n },\n {\n link: \"https://www.youtube.com/@ClueMart-App-NZ\",\n name: EnumSocialMedia.YOUTUBE,\n },\n];\n\nexport const IOS_URL = \"https://apps.apple.com/nz/app/cluemart/id6747251008\";\nexport const ANDROID_URL =\n \"https://play.google.com/store/ap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