@jant/core 0.3.6 → 0.3.8
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/app.js +11 -21
- package/dist/client.js +1 -0
- package/dist/db/schema.js +15 -0
- package/dist/i18n/locales/en.js +1 -1
- package/dist/i18n/locales/zh-Hans.js +1 -1
- package/dist/i18n/locales/zh-Hant.js +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/image.js +3 -3
- package/dist/lib/media-helpers.js +43 -0
- package/dist/lib/nav-reorder.js +27 -0
- package/dist/lib/navigation.js +35 -0
- package/dist/lib/schemas.js +32 -2
- package/dist/lib/sse.js +7 -8
- package/dist/lib/theme-components.js +49 -0
- package/dist/routes/api/posts.js +101 -5
- package/dist/routes/api/timeline.js +115 -0
- package/dist/routes/api/upload.js +9 -5
- package/dist/routes/dash/media.js +38 -0
- package/dist/routes/dash/navigation.js +274 -0
- package/dist/routes/dash/posts.js +45 -6
- package/dist/routes/feed/rss.js +10 -1
- package/dist/routes/pages/archive.js +14 -27
- package/dist/routes/pages/collection.js +10 -19
- package/dist/routes/pages/home.js +88 -98
- package/dist/routes/pages/page.js +19 -38
- package/dist/routes/pages/post.js +61 -48
- package/dist/routes/pages/search.js +13 -26
- package/dist/services/collection.js +13 -0
- package/dist/services/index.js +3 -1
- package/dist/services/media.js +55 -2
- package/dist/services/navigation.js +115 -0
- package/dist/services/post.js +26 -1
- package/dist/theme/components/MediaGallery.js +107 -0
- package/dist/theme/components/PostForm.js +158 -2
- package/dist/theme/components/PostList.js +5 -0
- package/dist/theme/components/index.js +3 -0
- package/dist/theme/components/timeline/ArticleCard.js +50 -0
- package/dist/theme/components/timeline/ImageCard.js +86 -0
- package/dist/theme/components/timeline/LinkCard.js +62 -0
- package/dist/theme/components/timeline/NoteCard.js +37 -0
- package/dist/theme/components/timeline/QuoteCard.js +51 -0
- package/dist/theme/components/timeline/ThreadPreview.js +52 -0
- package/dist/theme/components/timeline/TimelineFeed.js +43 -0
- package/dist/theme/components/timeline/TimelineItem.js +25 -0
- package/dist/theme/components/timeline/index.js +8 -0
- package/dist/theme/layouts/DashLayout.js +8 -0
- package/dist/theme/layouts/SiteLayout.js +160 -0
- package/dist/theme/layouts/index.js +1 -0
- package/dist/types/sortablejs.d.js +5 -0
- package/dist/types.js +27 -0
- package/package.json +3 -2
- package/src/__tests__/helpers/app.ts +6 -1
- package/src/__tests__/helpers/db.ts +20 -0
- package/src/app.tsx +11 -25
- package/src/client.ts +1 -0
- package/src/db/migrations/0002_add_media_attachments.sql +3 -0
- package/src/db/migrations/0003_add_navigation_links.sql +8 -0
- package/src/db/migrations/meta/0003_snapshot.json +821 -0
- package/src/db/migrations/meta/_journal.json +14 -0
- package/src/db/schema.ts +15 -0
- package/src/i18n/locales/en.po +170 -58
- package/src/i18n/locales/en.ts +1 -1
- package/src/i18n/locales/zh-Hans.po +162 -71
- package/src/i18n/locales/zh-Hans.ts +1 -1
- package/src/i18n/locales/zh-Hant.po +162 -71
- package/src/i18n/locales/zh-Hant.ts +1 -1
- package/src/index.ts +13 -1
- package/src/lib/__tests__/schemas.test.ts +89 -1
- package/src/lib/__tests__/sse.test.ts +13 -1
- package/src/lib/__tests__/theme-components.test.ts +107 -0
- package/src/lib/image.ts +3 -3
- package/src/lib/media-helpers.ts +54 -0
- package/src/lib/nav-reorder.ts +26 -0
- package/src/lib/navigation.ts +46 -0
- package/src/lib/schemas.ts +47 -1
- package/src/lib/sse.ts +10 -11
- package/src/lib/theme-components.ts +76 -0
- package/src/routes/api/__tests__/posts.test.ts +239 -0
- package/src/routes/api/__tests__/timeline.test.ts +242 -0
- package/src/routes/api/posts.ts +134 -5
- package/src/routes/api/timeline.tsx +145 -0
- package/src/routes/api/upload.ts +9 -5
- package/src/routes/dash/media.tsx +50 -0
- package/src/routes/dash/navigation.tsx +306 -0
- package/src/routes/dash/posts.tsx +79 -7
- package/src/routes/feed/rss.ts +14 -1
- package/src/routes/pages/archive.tsx +15 -23
- package/src/routes/pages/collection.tsx +8 -15
- package/src/routes/pages/home.tsx +121 -88
- package/src/routes/pages/page.tsx +17 -30
- package/src/routes/pages/post.tsx +64 -40
- package/src/routes/pages/search.tsx +18 -22
- package/src/services/__tests__/collection.test.ts +102 -0
- package/src/services/__tests__/media.test.ts +282 -7
- package/src/services/__tests__/navigation.test.ts +213 -0
- package/src/services/__tests__/post-timeline.test.ts +220 -0
- package/src/services/collection.ts +19 -0
- package/src/services/index.ts +7 -0
- package/src/services/media.ts +78 -2
- package/src/services/navigation.ts +165 -0
- package/src/services/post.ts +48 -1
- package/src/styles/components.css +59 -0
- package/src/theme/components/MediaGallery.tsx +128 -0
- package/src/theme/components/PostForm.tsx +170 -2
- package/src/theme/components/PostList.tsx +7 -0
- package/src/theme/components/index.ts +13 -0
- package/src/theme/components/timeline/ArticleCard.tsx +57 -0
- package/src/theme/components/timeline/ImageCard.tsx +80 -0
- package/src/theme/components/timeline/LinkCard.tsx +66 -0
- package/src/theme/components/timeline/NoteCard.tsx +41 -0
- package/src/theme/components/timeline/QuoteCard.tsx +55 -0
- package/src/theme/components/timeline/ThreadPreview.tsx +49 -0
- package/src/theme/components/timeline/TimelineFeed.tsx +52 -0
- package/src/theme/components/timeline/TimelineItem.tsx +39 -0
- package/src/theme/components/timeline/index.ts +8 -0
- package/src/theme/layouts/DashLayout.tsx +10 -0
- package/src/theme/layouts/SiteLayout.tsx +184 -0
- package/src/theme/layouts/index.ts +1 -0
- package/src/types/sortablejs.d.ts +23 -0
- package/src/types.ts +97 -0
- package/dist/app.d.ts +0 -38
- package/dist/app.d.ts.map +0 -1
- package/dist/auth.d.ts +0 -25
- package/dist/auth.d.ts.map +0 -1
- package/dist/db/index.d.ts +0 -10
- package/dist/db/index.d.ts.map +0 -1
- package/dist/db/schema.d.ts +0 -1507
- package/dist/db/schema.d.ts.map +0 -1
- package/dist/i18n/Trans.d.ts +0 -25
- package/dist/i18n/Trans.d.ts.map +0 -1
- package/dist/i18n/context.d.ts +0 -69
- package/dist/i18n/context.d.ts.map +0 -1
- package/dist/i18n/detect.d.ts +0 -20
- package/dist/i18n/detect.d.ts.map +0 -1
- package/dist/i18n/i18n.d.ts +0 -32
- package/dist/i18n/i18n.d.ts.map +0 -1
- package/dist/i18n/index.d.ts +0 -41
- package/dist/i18n/index.d.ts.map +0 -1
- package/dist/i18n/locales/en.d.ts +0 -3
- package/dist/i18n/locales/en.d.ts.map +0 -1
- package/dist/i18n/locales/zh-Hans.d.ts +0 -3
- package/dist/i18n/locales/zh-Hans.d.ts.map +0 -1
- package/dist/i18n/locales/zh-Hant.d.ts +0 -3
- package/dist/i18n/locales/zh-Hant.d.ts.map +0 -1
- package/dist/i18n/locales.d.ts +0 -11
- package/dist/i18n/locales.d.ts.map +0 -1
- package/dist/i18n/middleware.d.ts +0 -21
- package/dist/i18n/middleware.d.ts.map +0 -1
- package/dist/index.d.ts +0 -16
- package/dist/index.d.ts.map +0 -1
- package/dist/lib/config.d.ts +0 -83
- package/dist/lib/config.d.ts.map +0 -1
- package/dist/lib/constants.d.ts +0 -37
- package/dist/lib/constants.d.ts.map +0 -1
- package/dist/lib/image.d.ts +0 -73
- package/dist/lib/image.d.ts.map +0 -1
- package/dist/lib/index.d.ts +0 -9
- package/dist/lib/index.d.ts.map +0 -1
- package/dist/lib/markdown.d.ts +0 -60
- package/dist/lib/markdown.d.ts.map +0 -1
- package/dist/lib/schemas.d.ts +0 -113
- package/dist/lib/schemas.d.ts.map +0 -1
- package/dist/lib/sqid.d.ts +0 -60
- package/dist/lib/sqid.d.ts.map +0 -1
- package/dist/lib/sse.d.ts +0 -192
- package/dist/lib/sse.d.ts.map +0 -1
- package/dist/lib/theme.d.ts +0 -44
- package/dist/lib/theme.d.ts.map +0 -1
- package/dist/lib/time.d.ts +0 -90
- package/dist/lib/time.d.ts.map +0 -1
- package/dist/lib/url.d.ts +0 -82
- package/dist/lib/url.d.ts.map +0 -1
- package/dist/middleware/auth.d.ts +0 -24
- package/dist/middleware/auth.d.ts.map +0 -1
- package/dist/middleware/onboarding.d.ts +0 -26
- package/dist/middleware/onboarding.d.ts.map +0 -1
- package/dist/routes/api/posts.d.ts +0 -13
- package/dist/routes/api/posts.d.ts.map +0 -1
- package/dist/routes/api/search.d.ts +0 -13
- package/dist/routes/api/search.d.ts.map +0 -1
- package/dist/routes/api/upload.d.ts +0 -16
- package/dist/routes/api/upload.d.ts.map +0 -1
- package/dist/routes/dash/collections.d.ts +0 -13
- package/dist/routes/dash/collections.d.ts.map +0 -1
- package/dist/routes/dash/index.d.ts +0 -15
- package/dist/routes/dash/index.d.ts.map +0 -1
- package/dist/routes/dash/media.d.ts +0 -16
- package/dist/routes/dash/media.d.ts.map +0 -1
- package/dist/routes/dash/pages.d.ts +0 -15
- package/dist/routes/dash/pages.d.ts.map +0 -1
- package/dist/routes/dash/posts.d.ts +0 -13
- package/dist/routes/dash/posts.d.ts.map +0 -1
- package/dist/routes/dash/redirects.d.ts +0 -13
- package/dist/routes/dash/redirects.d.ts.map +0 -1
- package/dist/routes/dash/settings.d.ts +0 -15
- package/dist/routes/dash/settings.d.ts.map +0 -1
- package/dist/routes/feed/rss.d.ts +0 -13
- package/dist/routes/feed/rss.d.ts.map +0 -1
- package/dist/routes/feed/sitemap.d.ts +0 -13
- package/dist/routes/feed/sitemap.d.ts.map +0 -1
- package/dist/routes/pages/archive.d.ts +0 -15
- package/dist/routes/pages/archive.d.ts.map +0 -1
- package/dist/routes/pages/collection.d.ts +0 -13
- package/dist/routes/pages/collection.d.ts.map +0 -1
- package/dist/routes/pages/home.d.ts +0 -13
- package/dist/routes/pages/home.d.ts.map +0 -1
- package/dist/routes/pages/page.d.ts +0 -15
- package/dist/routes/pages/page.d.ts.map +0 -1
- package/dist/routes/pages/post.d.ts +0 -13
- package/dist/routes/pages/post.d.ts.map +0 -1
- package/dist/routes/pages/search.d.ts +0 -13
- package/dist/routes/pages/search.d.ts.map +0 -1
- package/dist/services/collection.d.ts +0 -31
- package/dist/services/collection.d.ts.map +0 -1
- package/dist/services/index.d.ts +0 -28
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/media.d.ts +0 -27
- package/dist/services/media.d.ts.map +0 -1
- package/dist/services/post.d.ts +0 -31
- package/dist/services/post.d.ts.map +0 -1
- package/dist/services/redirect.d.ts +0 -15
- package/dist/services/redirect.d.ts.map +0 -1
- package/dist/services/search.d.ts +0 -26
- package/dist/services/search.d.ts.map +0 -1
- package/dist/services/settings.d.ts +0 -18
- package/dist/services/settings.d.ts.map +0 -1
- package/dist/theme/color-themes.d.ts +0 -30
- package/dist/theme/color-themes.d.ts.map +0 -1
- package/dist/theme/components/ActionButtons.d.ts +0 -43
- package/dist/theme/components/ActionButtons.d.ts.map +0 -1
- package/dist/theme/components/CrudPageHeader.d.ts +0 -23
- package/dist/theme/components/CrudPageHeader.d.ts.map +0 -1
- package/dist/theme/components/DangerZone.d.ts +0 -36
- package/dist/theme/components/DangerZone.d.ts.map +0 -1
- package/dist/theme/components/EmptyState.d.ts +0 -27
- package/dist/theme/components/EmptyState.d.ts.map +0 -1
- package/dist/theme/components/ListItemRow.d.ts +0 -15
- package/dist/theme/components/ListItemRow.d.ts.map +0 -1
- package/dist/theme/components/PageForm.d.ts +0 -14
- package/dist/theme/components/PageForm.d.ts.map +0 -1
- package/dist/theme/components/Pagination.d.ts +0 -46
- package/dist/theme/components/Pagination.d.ts.map +0 -1
- package/dist/theme/components/PostForm.d.ts +0 -11
- package/dist/theme/components/PostForm.d.ts.map +0 -1
- package/dist/theme/components/PostList.d.ts +0 -10
- package/dist/theme/components/PostList.d.ts.map +0 -1
- package/dist/theme/components/ThreadView.d.ts +0 -15
- package/dist/theme/components/ThreadView.d.ts.map +0 -1
- package/dist/theme/components/TypeBadge.d.ts +0 -12
- package/dist/theme/components/TypeBadge.d.ts.map +0 -1
- package/dist/theme/components/VisibilityBadge.d.ts +0 -12
- package/dist/theme/components/VisibilityBadge.d.ts.map +0 -1
- package/dist/theme/components/index.d.ts +0 -13
- package/dist/theme/components/index.d.ts.map +0 -1
- package/dist/theme/index.d.ts +0 -21
- package/dist/theme/index.d.ts.map +0 -1
- package/dist/theme/layouts/BaseLayout.d.ts +0 -23
- package/dist/theme/layouts/BaseLayout.d.ts.map +0 -1
- package/dist/theme/layouts/DashLayout.d.ts +0 -17
- package/dist/theme/layouts/DashLayout.d.ts.map +0 -1
- package/dist/theme/layouts/index.d.ts +0 -3
- package/dist/theme/layouts/index.d.ts.map +0 -1
- package/dist/types.d.ts +0 -213
- package/dist/types.d.ts.map +0 -1
package/dist/lib/schemas.d.ts
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared Zod schemas for validation
|
|
3
|
-
*
|
|
4
|
-
* These schemas ensure type-safe validation of user input
|
|
5
|
-
* from forms, API requests, and other external sources.
|
|
6
|
-
*
|
|
7
|
-
* IMPORTANT: Types are defined in types.ts as the single source of truth.
|
|
8
|
-
* This file only defines Zod validation schemas based on those types.
|
|
9
|
-
*/
|
|
10
|
-
import { z } from "zod";
|
|
11
|
-
/**
|
|
12
|
-
* Post type enum schema
|
|
13
|
-
* Based on POST_TYPES from types.ts
|
|
14
|
-
*/
|
|
15
|
-
export declare const PostTypeSchema: z.ZodEnum<{
|
|
16
|
-
note: "note";
|
|
17
|
-
article: "article";
|
|
18
|
-
link: "link";
|
|
19
|
-
quote: "quote";
|
|
20
|
-
image: "image";
|
|
21
|
-
page: "page";
|
|
22
|
-
}>;
|
|
23
|
-
/**
|
|
24
|
-
* Visibility enum schema
|
|
25
|
-
* Based on VISIBILITY_LEVELS from types.ts
|
|
26
|
-
*/
|
|
27
|
-
export declare const VisibilitySchema: z.ZodEnum<{
|
|
28
|
-
featured: "featured";
|
|
29
|
-
quiet: "quiet";
|
|
30
|
-
unlisted: "unlisted";
|
|
31
|
-
draft: "draft";
|
|
32
|
-
}>;
|
|
33
|
-
/**
|
|
34
|
-
* Redirect type enum schema
|
|
35
|
-
* Form input validation for redirect type (stored as number in DB)
|
|
36
|
-
*/
|
|
37
|
-
export declare const RedirectTypeSchema: z.ZodEnum<{
|
|
38
|
-
301: "301";
|
|
39
|
-
302: "302";
|
|
40
|
-
}>;
|
|
41
|
-
/**
|
|
42
|
-
* API request body schema for creating a post
|
|
43
|
-
*/
|
|
44
|
-
export declare const CreatePostSchema: z.ZodObject<{
|
|
45
|
-
type: z.ZodEnum<{
|
|
46
|
-
note: "note";
|
|
47
|
-
article: "article";
|
|
48
|
-
link: "link";
|
|
49
|
-
quote: "quote";
|
|
50
|
-
image: "image";
|
|
51
|
-
page: "page";
|
|
52
|
-
}>;
|
|
53
|
-
title: z.ZodOptional<z.ZodString>;
|
|
54
|
-
content: z.ZodString;
|
|
55
|
-
visibility: z.ZodEnum<{
|
|
56
|
-
featured: "featured";
|
|
57
|
-
quiet: "quiet";
|
|
58
|
-
unlisted: "unlisted";
|
|
59
|
-
draft: "draft";
|
|
60
|
-
}>;
|
|
61
|
-
sourceUrl: z.ZodUnion<[z.ZodOptional<z.ZodURL>, z.ZodLiteral<"">]>;
|
|
62
|
-
sourceName: z.ZodOptional<z.ZodString>;
|
|
63
|
-
path: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
|
|
64
|
-
replyToId: z.ZodOptional<z.ZodString>;
|
|
65
|
-
publishedAt: z.ZodOptional<z.ZodNumber>;
|
|
66
|
-
}, z.core.$strip>;
|
|
67
|
-
/**
|
|
68
|
-
* API request body schema for updating a post
|
|
69
|
-
*/
|
|
70
|
-
export declare const UpdatePostSchema: z.ZodObject<{
|
|
71
|
-
type: z.ZodOptional<z.ZodEnum<{
|
|
72
|
-
note: "note";
|
|
73
|
-
article: "article";
|
|
74
|
-
link: "link";
|
|
75
|
-
quote: "quote";
|
|
76
|
-
image: "image";
|
|
77
|
-
page: "page";
|
|
78
|
-
}>>;
|
|
79
|
-
title: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
80
|
-
content: z.ZodOptional<z.ZodString>;
|
|
81
|
-
visibility: z.ZodOptional<z.ZodEnum<{
|
|
82
|
-
featured: "featured";
|
|
83
|
-
quiet: "quiet";
|
|
84
|
-
unlisted: "unlisted";
|
|
85
|
-
draft: "draft";
|
|
86
|
-
}>>;
|
|
87
|
-
sourceUrl: z.ZodOptional<z.ZodUnion<[z.ZodOptional<z.ZodURL>, z.ZodLiteral<"">]>>;
|
|
88
|
-
sourceName: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
89
|
-
path: z.ZodOptional<z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>>;
|
|
90
|
-
replyToId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
91
|
-
publishedAt: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
92
|
-
}, z.core.$strip>;
|
|
93
|
-
/**
|
|
94
|
-
* Form data helper: safely parse a FormData value with a schema
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* ```ts
|
|
98
|
-
* const type = parseFormData(formData, "type", PostTypeSchema);
|
|
99
|
-
* // type is PostType, throws if invalid
|
|
100
|
-
* ```
|
|
101
|
-
*/
|
|
102
|
-
export declare function parseFormData<T>(formData: FormData, key: string, schema: z.ZodSchema<T>): T;
|
|
103
|
-
/**
|
|
104
|
-
* Form data helper: safely parse optional FormData value with a schema
|
|
105
|
-
*
|
|
106
|
-
* @example
|
|
107
|
-
* ```ts
|
|
108
|
-
* const slug = parseFormDataOptional(formData, "slug", z.string());
|
|
109
|
-
* // slug is string | undefined
|
|
110
|
-
* ```
|
|
111
|
-
*/
|
|
112
|
-
export declare function parseFormDataOptional<T>(formData: FormData, key: string, schema: z.ZodSchema<T>): T | undefined;
|
|
113
|
-
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/lib/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;;;EAAqB,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;EAA4B,CAAC;AAE1D;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;EAAyB,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;iBAc3B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;iBAA6B,CAAC;AAE3D;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GACrB,CAAC,CAMH;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GACrB,CAAC,GAAG,SAAS,CAMf"}
|
package/dist/lib/sqid.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sqids - Short unique IDs for URLs
|
|
3
|
-
*
|
|
4
|
-
* Encodes numeric IDs to short strings like "jR3k"
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Encodes a numeric database ID to a short, URL-friendly string.
|
|
8
|
-
*
|
|
9
|
-
* Uses the Sqids library to generate short unique identifiers with a minimum length of 4 characters.
|
|
10
|
-
* These are used in URLs (e.g., `/p/jR3k`) to obscure sequential integer IDs while maintaining
|
|
11
|
-
* uniqueness and reversibility.
|
|
12
|
-
*
|
|
13
|
-
* @param id - The numeric database ID to encode
|
|
14
|
-
* @returns A short string representation of the ID (minimum 4 characters)
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```ts
|
|
18
|
-
* const sqid = encode(123);
|
|
19
|
-
* // Returns: "jR3k" (or similar short string)
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export declare function encode(id: number): string;
|
|
23
|
-
/**
|
|
24
|
-
* Decodes a sqid string back to the original numeric database ID.
|
|
25
|
-
*
|
|
26
|
-
* Attempts to decode a sqid string generated by the `encode()` function. Returns the original
|
|
27
|
-
* numeric ID if valid, or `null` if the string is not a valid sqid. This is used to extract
|
|
28
|
-
* database IDs from URL parameters.
|
|
29
|
-
*
|
|
30
|
-
* @param str - The sqid string to decode
|
|
31
|
-
* @returns The original numeric ID if valid, or `null` if decoding fails
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```ts
|
|
35
|
-
* const id = decode("jR3k");
|
|
36
|
-
* // Returns: 123
|
|
37
|
-
*
|
|
38
|
-
* const invalid = decode("invalid");
|
|
39
|
-
* // Returns: null
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export declare function decode(str: string): number | null;
|
|
43
|
-
/**
|
|
44
|
-
* Checks if a string is a valid sqid that can be decoded.
|
|
45
|
-
*
|
|
46
|
-
* Validates whether a string can be successfully decoded to a numeric ID.
|
|
47
|
-
* Useful for route validation and input sanitization.
|
|
48
|
-
*
|
|
49
|
-
* @param str - The string to validate
|
|
50
|
-
* @returns `true` if the string is a valid sqid, `false` otherwise
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```ts
|
|
54
|
-
* if (isValidSqid("jR3k")) {
|
|
55
|
-
* // Process the valid sqid
|
|
56
|
-
* }
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
export declare function isValidSqid(str: string): boolean;
|
|
60
|
-
//# sourceMappingURL=sqid.d.ts.map
|
package/dist/lib/sqid.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sqid.d.ts","sourceRoot":"","sources":["../../src/lib/sqid.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOjD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEhD"}
|
package/dist/lib/sse.d.ts
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Datastar response utilities for v1.0.0-RC.7
|
|
3
|
-
*
|
|
4
|
-
* Provides both SSE (multi-event) and plain HTTP (single-event) response helpers.
|
|
5
|
-
*
|
|
6
|
-
* **Non-SSE helpers** (preferred for single operations):
|
|
7
|
-
* - `dsRedirect(url)` — redirect via text/html
|
|
8
|
-
* - `dsToast(message, type)` — toast notification via text/html
|
|
9
|
-
* - `dsSignals(signals)` — signal patch via application/json
|
|
10
|
-
*
|
|
11
|
-
* **SSE** (for multiple operations in one response):
|
|
12
|
-
* - `sse(c, handler)` — streaming SSE with full stream API
|
|
13
|
-
*
|
|
14
|
-
* Datastar auto-detects response type by Content-Type:
|
|
15
|
-
* - `text/html` → dispatches as `datastar-patch-elements`
|
|
16
|
-
* - `application/json` → dispatches as `datastar-patch-signals`
|
|
17
|
-
*
|
|
18
|
-
* @see https://data-star.dev/
|
|
19
|
-
*/
|
|
20
|
-
import type { Context } from "hono";
|
|
21
|
-
/**
|
|
22
|
-
* Patch modes for DOM element updates
|
|
23
|
-
*
|
|
24
|
-
* @see https://data-star.dev/reference/action_plugins/backend/sse
|
|
25
|
-
*/
|
|
26
|
-
export type PatchMode = "outer" | "inner" | "replace" | "prepend" | "append" | "before" | "after" | "remove";
|
|
27
|
-
/**
|
|
28
|
-
* SSE stream writer for Datastar events
|
|
29
|
-
*/
|
|
30
|
-
export interface SSEStream {
|
|
31
|
-
/**
|
|
32
|
-
* Update reactive signals on the client
|
|
33
|
-
*
|
|
34
|
-
* @param signals - Object containing signal values to update
|
|
35
|
-
* @param options - Optional settings (e.g. onlyIfMissing)
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```ts
|
|
39
|
-
* await stream.patchSignals({ count: 42, loading: false });
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
patchSignals(signals: Record<string, unknown>, options?: {
|
|
43
|
-
onlyIfMissing?: boolean;
|
|
44
|
-
}): void;
|
|
45
|
-
/**
|
|
46
|
-
* Update DOM elements via patching
|
|
47
|
-
*
|
|
48
|
-
* @param html - HTML content (must include element with id for targeting)
|
|
49
|
-
* @param options - Optional patch mode, selector, and view transition
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```ts
|
|
53
|
-
* // Outer patch element with matching id (default)
|
|
54
|
-
* await stream.patchElements('<div id="content">New content</div>');
|
|
55
|
-
*
|
|
56
|
-
* // Append to a container
|
|
57
|
-
* await stream.patchElements('<div>New item</div>', {
|
|
58
|
-
* mode: 'append',
|
|
59
|
-
* selector: '#list'
|
|
60
|
-
* });
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
patchElements(html: string, options?: {
|
|
64
|
-
mode?: PatchMode;
|
|
65
|
-
selector?: string;
|
|
66
|
-
useViewTransition?: boolean;
|
|
67
|
-
}): void;
|
|
68
|
-
/**
|
|
69
|
-
* Redirect the client to a new URL
|
|
70
|
-
*
|
|
71
|
-
* Uses patchElements internally to inject a script that navigates the client.
|
|
72
|
-
*
|
|
73
|
-
* @param url - The URL to redirect to
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```ts
|
|
77
|
-
* await stream.redirect('/dash/posts');
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
redirect(url: string): void;
|
|
81
|
-
/**
|
|
82
|
-
* Remove elements matching a CSS selector
|
|
83
|
-
*
|
|
84
|
-
* @param selector - CSS selector for elements to remove
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```ts
|
|
88
|
-
* await stream.remove('#placeholder');
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
remove(selector: string): void;
|
|
92
|
-
/**
|
|
93
|
-
* Show a toast notification
|
|
94
|
-
*
|
|
95
|
-
* Appends a toast element to `#toast-container` with auto-dismiss after 3s.
|
|
96
|
-
*
|
|
97
|
-
* @param message - The message to display
|
|
98
|
-
* @param type - Toast type: "success" (default) or "error"
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* ```ts
|
|
102
|
-
* await stream.toast("Settings saved successfully.");
|
|
103
|
-
* await stream.toast("Something went wrong.", "error");
|
|
104
|
-
* ```
|
|
105
|
-
*/
|
|
106
|
-
toast(message: string, type?: "success" | "error"): void;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Create an SSE response for Datastar
|
|
110
|
-
*
|
|
111
|
-
* @param c - Hono context
|
|
112
|
-
* @param handler - Async function that writes to the SSE stream
|
|
113
|
-
* @param options - Optional response options (e.g. headers for cookie forwarding)
|
|
114
|
-
* @returns Response with SSE content-type
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* ```ts
|
|
118
|
-
* app.post("/api/upload", (c) => {
|
|
119
|
-
* return sse(c, async (stream) => {
|
|
120
|
-
* await stream.patchSignals({ uploading: false });
|
|
121
|
-
* await stream.patchElements('<div id="new-item">...</div>', {
|
|
122
|
-
* mode: 'append',
|
|
123
|
-
* selector: '#items'
|
|
124
|
-
* });
|
|
125
|
-
* });
|
|
126
|
-
* });
|
|
127
|
-
*
|
|
128
|
-
* // With cookie forwarding (for auth)
|
|
129
|
-
* app.post("/signin", (c) => {
|
|
130
|
-
* return sse(c, async (stream) => {
|
|
131
|
-
* await stream.redirect('/dash');
|
|
132
|
-
* }, { headers: { 'Set-Cookie': cookieValue } });
|
|
133
|
-
* });
|
|
134
|
-
* ```
|
|
135
|
-
*/
|
|
136
|
-
export declare function sse(c: Context, handler: (stream: SSEStream) => Promise<void>, options?: {
|
|
137
|
-
headers?: Record<string, string>;
|
|
138
|
-
}): Response;
|
|
139
|
-
/**
|
|
140
|
-
* Datastar redirect via text/html
|
|
141
|
-
*
|
|
142
|
-
* Returns a plain HTML response that Datastar dispatches as `datastar-patch-elements`.
|
|
143
|
-
* Use instead of `sse()` when the only action is a redirect.
|
|
144
|
-
*
|
|
145
|
-
* @param url - The URL to redirect to
|
|
146
|
-
* @param options - Optional extra headers (e.g. Set-Cookie for auth)
|
|
147
|
-
* @returns Response with text/html content-type
|
|
148
|
-
*
|
|
149
|
-
* @example
|
|
150
|
-
* ```ts
|
|
151
|
-
* return dsRedirect("/dash/posts");
|
|
152
|
-
*
|
|
153
|
-
* // With cookie forwarding (for auth)
|
|
154
|
-
* return dsRedirect("/dash", { headers: { "Set-Cookie": cookie } });
|
|
155
|
-
* ```
|
|
156
|
-
*/
|
|
157
|
-
export declare function dsRedirect(url: string, options?: {
|
|
158
|
-
headers?: Record<string, string>;
|
|
159
|
-
}): Response;
|
|
160
|
-
/**
|
|
161
|
-
* Datastar toast notification via text/html
|
|
162
|
-
*
|
|
163
|
-
* Returns a plain HTML response that Datastar dispatches as `datastar-patch-elements`.
|
|
164
|
-
* Use instead of `sse()` when the only action is showing a toast.
|
|
165
|
-
*
|
|
166
|
-
* @param message - The message to display
|
|
167
|
-
* @param type - Toast type: "success" (default) or "error"
|
|
168
|
-
* @returns Response with text/html content-type
|
|
169
|
-
*
|
|
170
|
-
* @example
|
|
171
|
-
* ```ts
|
|
172
|
-
* return dsToast("Settings saved successfully.");
|
|
173
|
-
* return dsToast("Something went wrong.", "error");
|
|
174
|
-
* ```
|
|
175
|
-
*/
|
|
176
|
-
export declare function dsToast(message: string, type?: "success" | "error"): Response;
|
|
177
|
-
/**
|
|
178
|
-
* Datastar signal patch via application/json
|
|
179
|
-
*
|
|
180
|
-
* Returns a JSON response that Datastar dispatches as `datastar-patch-signals`.
|
|
181
|
-
* Use instead of `sse()` when the only action is updating signals.
|
|
182
|
-
*
|
|
183
|
-
* @param signals - Object containing signal values to update
|
|
184
|
-
* @returns Response with application/json content-type
|
|
185
|
-
*
|
|
186
|
-
* @example
|
|
187
|
-
* ```ts
|
|
188
|
-
* return dsSignals({ _uploadError: "File too large" });
|
|
189
|
-
* ```
|
|
190
|
-
*/
|
|
191
|
-
export declare function dsSignals(signals: Record<string, unknown>): Response;
|
|
192
|
-
//# sourceMappingURL=sse.d.ts.map
|
package/dist/lib/sse.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../src/lib/sse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC;;;;GAIG;AACH,MAAM,MAAM,SAAS,GACjB,OAAO,GACP,OAAO,GACP,SAAS,GACT,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,QAAQ,CAAC;AAEb;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;;;;;;;;;OAUG;IACH,YAAY,CACV,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,GACpC,IAAI,CAAC;IAER;;;;;;;;;;;;;;;;;OAiBG;IACH,aAAa,CACX,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,SAAS,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,iBAAiB,CAAC,EAAE,OAAO,CAAC;KAC7B,GACA,IAAI,CAAC;IAER;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B;;;;;;;;;OASG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAE/B;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,IAAI,CAAC;CAC1D;AA+CD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,GAAG,CACjB,CAAC,EAAE,OAAO,EACV,OAAO,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,EAC7C,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAC7C,QAAQ,CAoFV;AAMD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAC7C,QAAQ,CASV;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,OAAO,CACrB,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,SAAS,GAAG,OAAmB,GACpC,QAAQ,CAQV;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,QAAQ,CAIpE"}
|
package/dist/lib/theme.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Theme Resolution Helpers
|
|
3
|
-
*
|
|
4
|
-
* Resolves the active color theme and builds CSS for injection into `<head>`.
|
|
5
|
-
*/
|
|
6
|
-
import type { ColorTheme } from "../theme/color-themes.js";
|
|
7
|
-
import type { JantConfig } from "../types.js";
|
|
8
|
-
/**
|
|
9
|
-
* Get the list of available color themes.
|
|
10
|
-
*
|
|
11
|
-
* Returns `config.theme.colorThemes` if provided, otherwise the built-in list.
|
|
12
|
-
*
|
|
13
|
-
* @param config - The Jant configuration
|
|
14
|
-
* @returns Array of available color themes
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const themes = getAvailableThemes(c.var.config);
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export declare function getAvailableThemes(config: JantConfig): ColorTheme[];
|
|
22
|
-
/**
|
|
23
|
-
* Build a `<style>` CSS string from a color theme and optional cssVariables overlay.
|
|
24
|
-
*
|
|
25
|
-
* Priority (lowest → highest):
|
|
26
|
-
* BaseCoat defaults → selected theme → cssVariables
|
|
27
|
-
*
|
|
28
|
-
* @param theme - The active color theme (undefined = no theme overrides)
|
|
29
|
-
* @param cssVariables - Extra CSS variable overrides from `createApp({ theme: { cssVariables } })`
|
|
30
|
-
* @returns CSS string to inject in `<head>`, or empty string if nothing to inject
|
|
31
|
-
*
|
|
32
|
-
* Uses `:root:root` and `:root.dark` selectors for higher specificity than
|
|
33
|
-
* BaseCoat defaults (`:root` and `.dark`). This ensures theme overrides win
|
|
34
|
-
* regardless of source order — important because Vite dev mode injects CSS
|
|
35
|
-
* as `<style>` tags after the theme `<style>`.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```typescript
|
|
39
|
-
* const css = buildThemeStyle(blueTheme, { "--radius": "0.5rem" });
|
|
40
|
-
* // => ":root:root { --primary: oklch(...); ... }\n:root.dark { ... }"
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
export declare function buildThemeStyle(theme: ColorTheme | undefined, cssVariables?: Record<string, string>): string;
|
|
44
|
-
//# sourceMappingURL=theme.d.ts.map
|
package/dist/lib/theme.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/lib/theme.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,EAAE,CAEnE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,UAAU,GAAG,SAAS,EAC7B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,MAAM,CAkCR"}
|
package/dist/lib/time.d.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Time Utilities
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Gets the current Unix timestamp in seconds.
|
|
6
|
-
*
|
|
7
|
-
* Returns the number of seconds since the Unix epoch (January 1, 1970 00:00:00 UTC).
|
|
8
|
-
* This is the standard time format used throughout the application for consistency
|
|
9
|
-
* and database storage.
|
|
10
|
-
*
|
|
11
|
-
* @returns Current Unix timestamp in seconds (not milliseconds)
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* const timestamp = now();
|
|
16
|
-
* // Returns: 1706745600 (example value for Feb 1, 2024)
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export declare function now(): number;
|
|
20
|
-
/**
|
|
21
|
-
* Checks if a Unix timestamp is within the last 30 days.
|
|
22
|
-
*
|
|
23
|
-
* Compares the given timestamp to the current time to determine if it falls within
|
|
24
|
-
* the last month (defined as 30 days). Useful for highlighting recent posts or
|
|
25
|
-
* filtering time-sensitive content.
|
|
26
|
-
*
|
|
27
|
-
* @param timestamp - Unix timestamp in seconds to check
|
|
28
|
-
* @returns `true` if the timestamp is within the last 30 days, `false` otherwise
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* const recentPost = 1706745600; // Recent timestamp
|
|
33
|
-
* if (isWithinMonth(recentPost)) {
|
|
34
|
-
* // Show "new" badge
|
|
35
|
-
* }
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export declare function isWithinMonth(timestamp: number): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Converts a Unix timestamp to an ISO 8601 date-time string.
|
|
41
|
-
*
|
|
42
|
-
* Formats a Unix timestamp (in seconds) as an ISO 8601 string suitable for HTML
|
|
43
|
-
* `datetime` attributes and API responses. The output includes full date, time,
|
|
44
|
-
* and timezone information in UTC.
|
|
45
|
-
*
|
|
46
|
-
* @param timestamp - Unix timestamp in seconds to convert
|
|
47
|
-
* @returns ISO 8601 formatted string (e.g., "2024-02-01T12:00:00.000Z")
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* ```ts
|
|
51
|
-
* const isoDate = toISOString(1706745600);
|
|
52
|
-
* // Returns: "2024-02-01T00:00:00.000Z"
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
export declare function toISOString(timestamp: number): string;
|
|
56
|
-
/**
|
|
57
|
-
* Formats a Unix timestamp as a human-readable date string.
|
|
58
|
-
*
|
|
59
|
-
* Converts a Unix timestamp (in seconds) to a localized date string in the format
|
|
60
|
-
* "MMM DD, YYYY" (e.g., "Jan 15, 2024"). Always uses UTC timezone to ensure
|
|
61
|
-
* consistent display regardless of server or client location.
|
|
62
|
-
*
|
|
63
|
-
* @param timestamp - Unix timestamp in seconds to format
|
|
64
|
-
* @returns Formatted date string in "MMM DD, YYYY" format
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* ```ts
|
|
68
|
-
* const readable = formatDate(1706745600);
|
|
69
|
-
* // Returns: "Feb 1, 2024"
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
export declare function formatDate(timestamp: number): string;
|
|
73
|
-
/**
|
|
74
|
-
* Formats a Unix timestamp as a year-month string for grouping.
|
|
75
|
-
*
|
|
76
|
-
* Converts a Unix timestamp (in seconds) to a "YYYY-MM" format string, useful for
|
|
77
|
-
* grouping posts by month in archives or creating month-based URLs. Always uses
|
|
78
|
-
* UTC timezone for consistency.
|
|
79
|
-
*
|
|
80
|
-
* @param timestamp - Unix timestamp in seconds to format
|
|
81
|
-
* @returns Year-month string in "YYYY-MM" format
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* ```ts
|
|
85
|
-
* const yearMonth = formatYearMonth(1706745600);
|
|
86
|
-
* // Returns: "2024-02"
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
export declare function formatYearMonth(timestamp: number): string;
|
|
90
|
-
//# sourceMappingURL=time.d.ts.map
|
package/dist/lib/time.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/lib/time.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,GAAG,IAAI,MAAM,CAE5B;AAOD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAOpD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAKzD"}
|
package/dist/lib/url.d.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* URL Utilities
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Extracts the hostname (domain) from a URL string.
|
|
6
|
-
*
|
|
7
|
-
* Parses a full URL and returns just the hostname portion (e.g., "example.com" from
|
|
8
|
-
* "https://example.com/path"). Returns `null` if the URL is malformed or cannot be parsed.
|
|
9
|
-
*
|
|
10
|
-
* @param url - The full URL string to extract the domain from
|
|
11
|
-
* @returns The hostname/domain if valid, or `null` if parsing fails
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* const domain = extractDomain("https://www.example.com/path");
|
|
16
|
-
* // Returns: "www.example.com"
|
|
17
|
-
*
|
|
18
|
-
* const invalid = extractDomain("not-a-url");
|
|
19
|
-
* // Returns: null
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export declare function extractDomain(url: string): string | null;
|
|
23
|
-
/**
|
|
24
|
-
* Normalizes a path by removing slashes and converting to lowercase.
|
|
25
|
-
*
|
|
26
|
-
* Trims whitespace, converts to lowercase, removes leading and trailing slashes,
|
|
27
|
-
* and collapses multiple consecutive slashes into single slashes. Used to create
|
|
28
|
-
* consistent path representations for routing and storage.
|
|
29
|
-
*
|
|
30
|
-
* @param path - The path string to normalize
|
|
31
|
-
* @returns The normalized path string
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```ts
|
|
35
|
-
* const normalized = normalizePath(" /About/Contact// ");
|
|
36
|
-
* // Returns: "about/contact"
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export declare function normalizePath(path: string): string;
|
|
40
|
-
/**
|
|
41
|
-
* Checks if a string is a full URL with HTTP or HTTPS protocol.
|
|
42
|
-
*
|
|
43
|
-
* Validates whether a string starts with "http://" or "https://", indicating it's
|
|
44
|
-
* a full URL rather than a relative path. Useful for distinguishing between internal
|
|
45
|
-
* paths and external URLs.
|
|
46
|
-
*
|
|
47
|
-
* @param str - The string to check
|
|
48
|
-
* @returns `true` if the string starts with http:// or https://, `false` otherwise
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```ts
|
|
52
|
-
* isFullUrl("https://example.com"); // Returns: true
|
|
53
|
-
* isFullUrl("/about"); // Returns: false
|
|
54
|
-
* isFullUrl("example.com"); // Returns: false
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
export declare function isFullUrl(str: string): boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Converts text to a URL-friendly slug.
|
|
60
|
-
*
|
|
61
|
-
* Transforms text into a lowercase, hyphen-separated slug by:
|
|
62
|
-
* - Converting to lowercase
|
|
63
|
-
* - Removing special characters (keeping only word characters, spaces, and hyphens)
|
|
64
|
-
* - Replacing whitespace and underscores with hyphens
|
|
65
|
-
* - Removing leading and trailing hyphens
|
|
66
|
-
*
|
|
67
|
-
* Used for generating clean URLs from titles and names.
|
|
68
|
-
*
|
|
69
|
-
* @param text - The text to convert to a slug
|
|
70
|
-
* @returns The slugified string
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* ```ts
|
|
74
|
-
* const slug = slugify("Hello World! This is a Test.");
|
|
75
|
-
* // Returns: "hello-world-this-is-a-test"
|
|
76
|
-
*
|
|
77
|
-
* const slug = slugify(" Multiple Spaces ");
|
|
78
|
-
* // Returns: "multiple-spaces"
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
81
|
-
export declare function slugify(text: string): string;
|
|
82
|
-
//# sourceMappingURL=url.d.ts.map
|
package/dist/lib/url.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/lib/url.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOxD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMlD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE9C;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO5C"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Authentication Middleware
|
|
3
|
-
*
|
|
4
|
-
* Protects routes by requiring authentication
|
|
5
|
-
*/
|
|
6
|
-
import type { MiddlewareHandler } from "hono";
|
|
7
|
-
import type { Bindings } from "../types.js";
|
|
8
|
-
import type { AppVariables } from "../app.js";
|
|
9
|
-
type Env = {
|
|
10
|
-
Bindings: Bindings;
|
|
11
|
-
Variables: AppVariables;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Middleware that requires authentication.
|
|
15
|
-
* Redirects to signin page if not authenticated.
|
|
16
|
-
*/
|
|
17
|
-
export declare function requireAuth(redirectTo?: string): MiddlewareHandler<Env>;
|
|
18
|
-
/**
|
|
19
|
-
* Middleware for API routes that requires authentication.
|
|
20
|
-
* Returns 401 if not authenticated.
|
|
21
|
-
*/
|
|
22
|
-
export declare function requireAuthApi(): MiddlewareHandler<Env>;
|
|
23
|
-
export {};
|
|
24
|
-
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C,KAAK,GAAG,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,YAAY,CAAA;CAAE,CAAC;AAE3D;;;GAGG;AACH,wBAAgB,WAAW,CAAC,UAAU,SAAY,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAoB1E;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,iBAAiB,CAAC,GAAG,CAAC,CAoBvD"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Onboarding Middleware
|
|
3
|
-
*
|
|
4
|
-
* Redirects all requests to /setup if onboarding hasn't been completed.
|
|
5
|
-
* Caches the result in memory so the DB is only queried once per isolate lifetime.
|
|
6
|
-
*/
|
|
7
|
-
import type { MiddlewareHandler } from "hono";
|
|
8
|
-
import type { Bindings } from "../types.js";
|
|
9
|
-
import type { AppVariables } from "../app.js";
|
|
10
|
-
type Env = {
|
|
11
|
-
Bindings: Bindings;
|
|
12
|
-
Variables: AppVariables;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Middleware that redirects to /setup if onboarding is not complete.
|
|
16
|
-
* Uses module-level caching: once onboarding is confirmed complete,
|
|
17
|
-
* no further DB queries are made for the lifetime of the Worker isolate.
|
|
18
|
-
*/
|
|
19
|
-
export declare function requireOnboarding(): MiddlewareHandler<Env>;
|
|
20
|
-
/**
|
|
21
|
-
* Reset the onboarding cache. Only for testing.
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
export declare function resetOnboardingCache(): void;
|
|
25
|
-
export {};
|
|
26
|
-
//# sourceMappingURL=onboarding.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"onboarding.d.ts","sourceRoot":"","sources":["../../src/middleware/onboarding.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C,KAAK,GAAG,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,YAAY,CAAA;CAAE,CAAC;AAK3D;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,iBAAiB,CAAC,GAAG,CAAC,CAmB1D;AAaD;;;GAGG;AACH,wBAAgB,oBAAoB,SAEnC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Posts API Routes
|
|
3
|
-
*/
|
|
4
|
-
import { Hono } from "hono";
|
|
5
|
-
import type { Bindings } from "../../types.js";
|
|
6
|
-
import type { AppVariables } from "../../app.js";
|
|
7
|
-
type Env = {
|
|
8
|
-
Bindings: Bindings;
|
|
9
|
-
Variables: AppVariables;
|
|
10
|
-
};
|
|
11
|
-
export declare const postsApiRoutes: Hono<Env, import("hono/types").BlankSchema, "/">;
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=posts.d.ts.map
|