@wealthreach/site-kit 0.0.0-stage → 1.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.
Files changed (42) hide show
  1. package/README.md +20 -2
  2. package/dist/a11y/client.d.ts +23 -0
  3. package/dist/a11y/client.js +72 -0
  4. package/dist/a11y/index.d.ts +43 -0
  5. package/dist/a11y/index.js +194 -0
  6. package/dist/a11y/shell-client.d.ts +19 -0
  7. package/dist/a11y/shell-client.js +45 -0
  8. package/dist/analytics/index.d.ts +47 -0
  9. package/dist/analytics/index.js +122 -0
  10. package/dist/attribution-DQaAWtA5.d.ts +41 -0
  11. package/dist/blog/index.d.ts +131 -0
  12. package/dist/blog/index.js +259 -0
  13. package/dist/chunk-4YRCSRZZ.js +32 -0
  14. package/dist/chunk-7GDXQ6UB.js +772 -0
  15. package/dist/chunk-QQP7VG2C.js +231 -0
  16. package/dist/chunk-Y77ARZE4.js +214 -0
  17. package/dist/config/index.d.ts +20 -0
  18. package/dist/config/index.js +445 -0
  19. package/dist/consent/index.d.ts +103 -0
  20. package/dist/consent/index.js +61 -0
  21. package/dist/disclosures/index.d.ts +57 -0
  22. package/dist/disclosures/index.js +361 -0
  23. package/dist/forms/index.d.ts +128 -0
  24. package/dist/forms/index.js +449 -0
  25. package/dist/mdx/index.d.ts +15 -0
  26. package/dist/mdx/index.js +45 -0
  27. package/dist/next/config.cjs +140 -0
  28. package/dist/next/config.d.cts +36 -0
  29. package/dist/next/config.d.ts +36 -0
  30. package/dist/next/config.js +111 -0
  31. package/dist/next/draft-route.d.ts +10 -0
  32. package/dist/next/draft-route.js +49 -0
  33. package/dist/next/leads-route.d.ts +138 -0
  34. package/dist/next/leads-route.js +771 -0
  35. package/dist/next/privacy-mode.d.ts +14 -0
  36. package/dist/next/privacy-mode.js +86 -0
  37. package/dist/next/proxy.d.ts +19 -0
  38. package/dist/next/proxy.js +93 -0
  39. package/dist/regulatory-schema-uDKNJ7q8.d.ts +1301 -0
  40. package/dist/schema-C1ixytx2.d.ts +2911 -0
  41. package/dist/schema-DD0nDOD0.d.ts +1744 -0
  42. package/package.json +85 -3
@@ -0,0 +1,131 @@
1
+ import { z } from 'zod';
2
+ import { SiteConfig } from '../config/index.js';
3
+ import React from 'react';
4
+ import '../regulatory-schema-uDKNJ7q8.js';
5
+
6
+ /**
7
+ * Contract 3.5 blog post frontmatter schema:
8
+ * - Accepts `date` or `publishedAt` (normalizing `date` from `publishedAt` when omitted).
9
+ * - Holds are marked `status: "waiting"` (or legacy `published: false`).
10
+ * - Unknown `status` values fail closed in `isPostLive`.
11
+ */
12
+ declare const postFrontmatterSchema: z.ZodPipe<z.ZodObject<{
13
+ title: z.ZodString;
14
+ description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
15
+ excerpt: z.ZodOptional<z.ZodString>;
16
+ date: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodDate]>, z.ZodTransform<string, string | Date>>>;
17
+ publishedAt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodDate]>, z.ZodTransform<string, string | Date>>>;
18
+ updatedAt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodDate]>, z.ZodTransform<string, string | Date>>>;
19
+ author: z.ZodOptional<z.ZodString>;
20
+ category: z.ZodOptional<z.ZodString>;
21
+ tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
22
+ image: z.ZodOptional<z.ZodString>;
23
+ videoUrl: z.ZodOptional<z.ZodString>;
24
+ transcript: z.ZodOptional<z.ZodString>;
25
+ status: z.ZodOptional<z.ZodEnum<{
26
+ waiting: "waiting";
27
+ live: "live";
28
+ }>>;
29
+ published: z.ZodOptional<z.ZodBoolean>;
30
+ }, z.core.$loose>, z.ZodTransform<{
31
+ date: string;
32
+ title: string;
33
+ description: string;
34
+ tags: string[];
35
+ excerpt?: string | undefined;
36
+ publishedAt?: string | undefined;
37
+ updatedAt?: string | undefined;
38
+ author?: string | undefined;
39
+ category?: string | undefined;
40
+ image?: string | undefined;
41
+ videoUrl?: string | undefined;
42
+ transcript?: string | undefined;
43
+ status?: "waiting" | "live" | undefined;
44
+ published?: boolean | undefined;
45
+ }, {
46
+ [x: string]: unknown;
47
+ title: string;
48
+ description: string;
49
+ tags: string[];
50
+ excerpt?: string | undefined;
51
+ date?: string | undefined;
52
+ publishedAt?: string | undefined;
53
+ updatedAt?: string | undefined;
54
+ author?: string | undefined;
55
+ category?: string | undefined;
56
+ image?: string | undefined;
57
+ videoUrl?: string | undefined;
58
+ transcript?: string | undefined;
59
+ status?: "waiting" | "live" | undefined;
60
+ published?: boolean | undefined;
61
+ }>>;
62
+ type PostFrontmatter = z.infer<typeof postFrontmatterSchema>;
63
+ interface BlogPost {
64
+ slug: string;
65
+ filePath: string;
66
+ frontmatter: PostFrontmatter;
67
+ content: string;
68
+ }
69
+
70
+ /** Exact Contract 3.5 rule: `published: false`, `status: "waiting"`, or any unknown status is not live. */
71
+ declare function isPostLive(postOrFrontmatter: Pick<BlogPost, "frontmatter"> | PostFrontmatter): boolean;
72
+ /**
73
+ * Exact log format parsed by WealthReach / Eve `post_not_served` diagnostics
74
+ * (`hiding "<slug>": <reason>`).
75
+ */
76
+ declare function logHiddenPost(slug: string, reason: string): void;
77
+ /**
78
+ * Synchronous visibility guard for post routes (call BEFORE rendering — never
79
+ * inside a streaming `<Suspense>` fallback, so hidden posts always 404).
80
+ */
81
+ declare function assertPostReadable(post: BlogPost | null | undefined, options: {
82
+ isDraftMode?: boolean;
83
+ onNotFound: () => never;
84
+ }): BlogPost;
85
+
86
+ /**
87
+ * Pluggable post source seam so Phase 4 can swap git-committed MDX for a
88
+ * WealthReach Content API without touching any client blog page UI.
89
+ */
90
+ interface PostSource {
91
+ loadAll(options?: {
92
+ includeWaiting?: boolean;
93
+ }): BlogPost[];
94
+ getBySlug(slug: string, options?: {
95
+ includeWaiting?: boolean;
96
+ }): BlogPost | null;
97
+ }
98
+ declare function createFileSystemPostSource(options?: {
99
+ postsDir?: string;
100
+ cwd?: string;
101
+ }): PostSource;
102
+ declare function loadPosts(options?: {
103
+ postsDir?: string;
104
+ cwd?: string;
105
+ includeWaiting?: boolean;
106
+ }): BlogPost[];
107
+ declare function getPostBySlug(slug: string, options?: {
108
+ postsDir?: string;
109
+ cwd?: string;
110
+ includeWaiting?: boolean;
111
+ }): BlogPost | null;
112
+
113
+ declare function buildPostJsonLd(post: BlogPost, config: SiteConfig): Record<string, unknown>;
114
+
115
+ declare const DRAFT_AUDIENCE_COOKIE = "wr_draft_audience";
116
+ declare function isOwnerAudienceCookie(cookieValue: string | undefined): boolean;
117
+ declare function isDraftViewEnabled(isDraftMode: boolean): boolean;
118
+ declare function isOwnerDraftAudience(cookieValue: string | undefined): boolean;
119
+
120
+ /**
121
+ * Owner-only draft preview banner for `status: "waiting"` posts.
122
+ * Stamps exact `data-wr-hidden-post="not-live"` contract attribute expected by
123
+ * Eve's post verifier and WealthReach's draft-view flow.
124
+ */
125
+ declare function DraftOwnerBanner({ slug, className, }: {
126
+ slug?: string;
127
+ className?: string;
128
+ }): React.JSX.Element;
129
+
130
+ export { DRAFT_AUDIENCE_COOKIE, DraftOwnerBanner, assertPostReadable, buildPostJsonLd, createFileSystemPostSource, getPostBySlug, isDraftViewEnabled, isOwnerAudienceCookie, isOwnerDraftAudience, isPostLive, loadPosts, logHiddenPost, postFrontmatterSchema };
131
+ export type { BlogPost, PostFrontmatter, PostSource };
@@ -0,0 +1,259 @@
1
+ // src/blog/frontmatter.ts
2
+ import { z } from "zod";
3
+ var dateField = z.union([z.string().trim().min(1), z.date()]).transform((v) => v instanceof Date ? v.toISOString().slice(0, 10) : v);
4
+ var postFrontmatterSchema = z.object({
5
+ title: z.string().trim().min(1),
6
+ description: z.string().trim().optional().default(""),
7
+ excerpt: z.string().trim().optional(),
8
+ date: dateField.optional(),
9
+ publishedAt: dateField.optional(),
10
+ updatedAt: dateField.optional(),
11
+ author: z.string().trim().optional(),
12
+ category: z.string().trim().optional(),
13
+ tags: z.array(z.string().trim().min(1)).optional().default([]),
14
+ image: z.string().trim().optional(),
15
+ videoUrl: z.string().trim().optional(),
16
+ transcript: z.string().optional(),
17
+ status: z.enum(["waiting", "live"]).optional(),
18
+ published: z.boolean().optional()
19
+ }).passthrough().superRefine((data, ctx) => {
20
+ if (!data.date && !data.publishedAt) {
21
+ ctx.addIssue({
22
+ code: z.ZodIssueCode.custom,
23
+ path: ["date"],
24
+ message: "Post frontmatter requires either `date` or `publishedAt`."
25
+ });
26
+ }
27
+ }).transform((data) => ({
28
+ ...data,
29
+ date: data.date ?? data.publishedAt
30
+ }));
31
+
32
+ // src/blog/visibility.ts
33
+ function isPostLive(postOrFrontmatter) {
34
+ const fm = "frontmatter" in postOrFrontmatter && postOrFrontmatter.frontmatter !== null && typeof postOrFrontmatter.frontmatter === "object" ? postOrFrontmatter.frontmatter : postOrFrontmatter;
35
+ if (fm.published === false) return false;
36
+ if (fm.status !== void 0 && fm.status !== "live") return false;
37
+ return true;
38
+ }
39
+ function logHiddenPost(slug, reason) {
40
+ console.warn(`hiding "${slug}": ${reason}`);
41
+ }
42
+ function assertPostReadable(post, options) {
43
+ if (!post) {
44
+ options.onNotFound();
45
+ }
46
+ if (!isPostLive(post) && !options.isDraftMode) {
47
+ logHiddenPost(post.slug, 'status is "waiting" and draft mode is not active');
48
+ options.onNotFound();
49
+ }
50
+ return post;
51
+ }
52
+
53
+ // src/blog/source.ts
54
+ import fs from "fs";
55
+ import path from "path";
56
+ import matter from "gray-matter";
57
+ var POST_EXT_RE = /\.(?:mdx|md)$/i;
58
+ function createFileSystemPostSource(options) {
59
+ const baseDir = path.resolve(
60
+ options?.cwd ?? process.cwd(),
61
+ options?.postsDir ?? "data/blog"
62
+ );
63
+ function parseFile(filePath, slug) {
64
+ try {
65
+ const raw = fs.readFileSync(
66
+ /*turbopackIgnore: true*/
67
+ filePath,
68
+ "utf8"
69
+ );
70
+ const { data, content } = matter(raw);
71
+ const parsed = postFrontmatterSchema.safeParse(data);
72
+ if (!parsed.success) {
73
+ logHiddenPost(
74
+ slug,
75
+ `invalid frontmatter (${parsed.error.issues.map((i) => i.path.join(".") || i.message).join(", ")})`
76
+ );
77
+ return null;
78
+ }
79
+ return {
80
+ slug,
81
+ filePath,
82
+ frontmatter: parsed.data,
83
+ content
84
+ };
85
+ } catch (error) {
86
+ logHiddenPost(
87
+ slug,
88
+ error instanceof Error ? error.message : "unreadable post file"
89
+ );
90
+ return null;
91
+ }
92
+ }
93
+ return {
94
+ loadAll(loadOptions) {
95
+ if (!fs.existsSync(
96
+ /*turbopackIgnore: true*/
97
+ baseDir
98
+ )) return [];
99
+ const includeWaiting = loadOptions?.includeWaiting ?? false;
100
+ const entries = fs.readdirSync(
101
+ /*turbopackIgnore: true*/
102
+ baseDir,
103
+ {
104
+ withFileTypes: true
105
+ }
106
+ );
107
+ const posts = [];
108
+ for (const entry of entries) {
109
+ if (!entry.isFile() || !POST_EXT_RE.test(entry.name)) continue;
110
+ const slug = entry.name.replace(POST_EXT_RE, "");
111
+ const post = parseFile(
112
+ path.join(
113
+ /*turbopackIgnore: true*/
114
+ baseDir,
115
+ entry.name
116
+ ),
117
+ slug
118
+ );
119
+ if (!post) continue;
120
+ if (!includeWaiting && !isPostLive(post)) continue;
121
+ posts.push(post);
122
+ }
123
+ posts.sort(
124
+ (a, b) => b.frontmatter.date.localeCompare(a.frontmatter.date)
125
+ );
126
+ return posts;
127
+ },
128
+ getBySlug(slug, getOptions) {
129
+ const includeWaiting = getOptions?.includeWaiting ?? false;
130
+ const cleanSlug = slug.replace(/[^a-zA-Z0-9-_]/g, "");
131
+ if (!cleanSlug || cleanSlug !== slug) return null;
132
+ for (const ext of [".mdx", ".md"]) {
133
+ const candidate = path.join(
134
+ /*turbopackIgnore: true*/
135
+ baseDir,
136
+ `${cleanSlug}${ext}`
137
+ );
138
+ if (fs.existsSync(
139
+ /*turbopackIgnore: true*/
140
+ candidate
141
+ )) {
142
+ const post = parseFile(candidate, cleanSlug);
143
+ if (!post) return null;
144
+ if (!includeWaiting && !isPostLive(post)) return null;
145
+ return post;
146
+ }
147
+ }
148
+ return null;
149
+ }
150
+ };
151
+ }
152
+ function loadPosts(options) {
153
+ return createFileSystemPostSource(options).loadAll({
154
+ includeWaiting: options?.includeWaiting
155
+ });
156
+ }
157
+ function getPostBySlug(slug, options) {
158
+ return createFileSystemPostSource(options).getBySlug(slug, {
159
+ includeWaiting: options?.includeWaiting
160
+ });
161
+ }
162
+
163
+ // src/blog/json-ld.ts
164
+ function buildPostJsonLd(post, config) {
165
+ const siteUrl = config.seo?.siteUrl?.replace(/\/$/, "") || "";
166
+ const routeSegment = config.blog?.routeSegment || "blog";
167
+ const url = siteUrl ? `${siteUrl}/${routeSegment}/${post.slug}` : void 0;
168
+ const article = {
169
+ "@context": "https://schema.org",
170
+ "@type": "Article",
171
+ headline: post.frontmatter.title,
172
+ description: post.frontmatter.description || post.frontmatter.excerpt || void 0,
173
+ datePublished: post.frontmatter.date,
174
+ ...post.frontmatter.updatedAt ? { dateModified: post.frontmatter.updatedAt } : {},
175
+ ...url ? { mainEntityOfPage: url, url } : {},
176
+ ...post.frontmatter.image ? { image: post.frontmatter.image } : {},
177
+ author: {
178
+ "@type": post.frontmatter.author ? "Person" : "Organization",
179
+ name: post.frontmatter.author || config.brand.legalName
180
+ },
181
+ publisher: {
182
+ "@type": "Organization",
183
+ name: config.brand.legalName,
184
+ ...config.brand.logoUrl ? { logo: { "@type": "ImageObject", url: config.brand.logoUrl } } : {}
185
+ }
186
+ };
187
+ if (post.frontmatter.videoUrl) {
188
+ article.video = {
189
+ "@type": "VideoObject",
190
+ name: post.frontmatter.title,
191
+ description: post.frontmatter.description || post.frontmatter.title,
192
+ contentUrl: post.frontmatter.videoUrl,
193
+ uploadDate: post.frontmatter.date,
194
+ ...post.frontmatter.image ? { thumbnailUrl: post.frontmatter.image } : {},
195
+ ...post.frontmatter.transcript ? { transcript: post.frontmatter.transcript } : {}
196
+ };
197
+ }
198
+ return article;
199
+ }
200
+
201
+ // src/blog/draft-view.ts
202
+ var DRAFT_AUDIENCE_COOKIE = "wr_draft_audience";
203
+ function isOwnerAudienceCookie(cookieValue) {
204
+ return cookieValue === "owner";
205
+ }
206
+ function isDraftViewEnabled(isDraftMode) {
207
+ return process.env.NODE_ENV === "development" || isDraftMode;
208
+ }
209
+ function isOwnerDraftAudience(cookieValue) {
210
+ return process.env.NODE_ENV === "development" || isOwnerAudienceCookie(cookieValue);
211
+ }
212
+
213
+ // src/blog/draft-banner.tsx
214
+ import { jsx, jsxs } from "react/jsx-runtime";
215
+ function DraftOwnerBanner({
216
+ slug,
217
+ className
218
+ }) {
219
+ return /* @__PURE__ */ jsxs(
220
+ "aside",
221
+ {
222
+ role: "status",
223
+ "data-wr-hidden-post": "not-live",
224
+ className,
225
+ style: className ? void 0 : {
226
+ padding: "0.75rem 1rem",
227
+ marginBottom: "1.5rem",
228
+ borderRadius: "var(--wr-radius, 0.375rem)",
229
+ border: "1px solid #d97706",
230
+ backgroundColor: "#fffbeb",
231
+ color: "#92400e",
232
+ fontSize: "0.875rem",
233
+ fontWeight: 500
234
+ },
235
+ children: [
236
+ /* @__PURE__ */ jsx("span", { children: "Draft \u2014 not on your live site." }),
237
+ " ",
238
+ "Visitors can't see this post yet",
239
+ slug ? ` (${slug})` : "",
240
+ "."
241
+ ]
242
+ }
243
+ );
244
+ }
245
+ export {
246
+ DRAFT_AUDIENCE_COOKIE,
247
+ DraftOwnerBanner,
248
+ assertPostReadable,
249
+ buildPostJsonLd,
250
+ createFileSystemPostSource,
251
+ getPostBySlug,
252
+ isDraftViewEnabled,
253
+ isOwnerAudienceCookie,
254
+ isOwnerDraftAudience,
255
+ isPostLive,
256
+ loadPosts,
257
+ logHiddenPost,
258
+ postFrontmatterSchema
259
+ };
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import {
3
+ captureAttributionOnLanding,
4
+ trackPageView
5
+ } from "./chunk-QQP7VG2C.js";
6
+ import {
7
+ useConsent
8
+ } from "./chunk-7GDXQ6UB.js";
9
+
10
+ // src/analytics/page-tracker.tsx
11
+ import { useEffect, useRef } from "react";
12
+ import { usePathname } from "next/navigation";
13
+ function PageTracker() {
14
+ const pathname = usePathname();
15
+ const { config, allowed, ready } = useConsent();
16
+ const lastTrackedPath = useRef(null);
17
+ useEffect(() => {
18
+ captureAttributionOnLanding();
19
+ }, [pathname]);
20
+ useEffect(() => {
21
+ if (!ready || !allowed || !pathname) return;
22
+ if (config.visitors?.enabled) return;
23
+ if (lastTrackedPath.current === pathname) return;
24
+ lastTrackedPath.current = pathname;
25
+ trackPageView(pathname, config);
26
+ }, [ready, allowed, pathname, config]);
27
+ return null;
28
+ }
29
+
30
+ export {
31
+ PageTracker
32
+ };