@acms-subir/core 0.1.0 → 0.3.0

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 (237) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/cli/common.mjs +35 -0
  3. package/cli/legacy.mjs +317 -0
  4. package/cli/main.mjs +66 -0
  5. package/cli/palette.mjs +4 -0
  6. package/cli/preview.mjs +50 -0
  7. package/cli/remote.mjs +55 -0
  8. package/cli/themes.mjs +127 -0
  9. package/cli.mjs +2 -315
  10. package/deploy/Caddyfile +8 -0
  11. package/deploy/Dockerfile +34 -0
  12. package/deploy/compose.https.yml +21 -0
  13. package/deploy/compose.yml +46 -0
  14. package/docs/theme-authoring.md +103 -0
  15. package/email-runner.mjs +32 -0
  16. package/integration.mjs +193 -2
  17. package/ops-check.mjs +27 -0
  18. package/package.json +35 -12
  19. package/src/actions/index.ts +744 -38
  20. package/src/components/AiCleaner.tsx +291 -0
  21. package/src/components/AiSettings.tsx +575 -0
  22. package/src/components/CommandPalette.tsx +200 -0
  23. package/src/components/ContentList.astro +246 -0
  24. package/src/components/DesignAccess.tsx +182 -0
  25. package/src/components/DesignManager.tsx +455 -47
  26. package/src/components/EmailSettings.tsx +521 -0
  27. package/src/components/EventPage.astro +178 -0
  28. package/src/components/LegalPage.astro +27 -0
  29. package/src/components/LinksManager.tsx +216 -97
  30. package/src/components/NavManager.tsx +83 -38
  31. package/src/components/ThemeScript.astro +50 -0
  32. package/src/components/ThemeSections.astro +57 -0
  33. package/src/components/ThemeSectionsEditor.tsx +513 -0
  34. package/src/components/booking/BookingFlow.astro +150 -0
  35. package/src/components/booking/HoursEditor.astro +63 -0
  36. package/src/components/builder/PageBuilder.tsx +10 -2
  37. package/src/components/editor/EventPanel.tsx +401 -0
  38. package/src/components/editor/FormatDock.tsx +81 -0
  39. package/src/components/editor/LivePane.tsx +122 -0
  40. package/src/components/editor/MobileToolbar.tsx +93 -0
  41. package/src/components/editor/PostEditor.tsx +826 -271
  42. package/src/components/editor/PreviewOverlay.tsx +242 -43
  43. package/src/components/editor/extensions/calendar.tsx +51 -7
  44. package/src/components/editor/extensions/cards.tsx +17 -1
  45. package/src/components/editor/extensions/codeBlock.tsx +1 -1
  46. package/src/components/editor/extensions/events.tsx +153 -0
  47. package/src/components/editor/extensions/infoCards.tsx +16 -1
  48. package/src/components/editor/extensions/mediaCards.tsx +36 -2
  49. package/src/components/editor/extensions/slash.tsx +77 -9
  50. package/src/components/editor/extensions/toc.tsx +89 -0
  51. package/src/components/editor/extensions/toggle.tsx +70 -0
  52. package/src/components/site/Pager.astro +24 -0
  53. package/src/components/site/PostCard.astro +64 -0
  54. package/src/components/site/TagLabel.astro +11 -0
  55. package/src/layouts/Admin.astro +289 -49
  56. package/src/layouts/Site.astro +331 -57
  57. package/src/lib/agent-api.ts +13 -0
  58. package/src/lib/agent-discovery.ts +40 -0
  59. package/src/lib/agent.ts +114 -0
  60. package/src/lib/ai-config.ts +58 -0
  61. package/src/lib/ai-schema.ts +22 -0
  62. package/src/lib/ai.ts +90 -0
  63. package/src/lib/analytics.ts +121 -0
  64. package/src/lib/api-keys.ts +65 -0
  65. package/src/lib/api.ts +52 -0
  66. package/src/lib/auth.ts +25 -5
  67. package/src/lib/backup/content.ts +36 -0
  68. package/src/lib/backup/unzip.ts +12 -1
  69. package/src/lib/backup/zip.ts +1 -1
  70. package/src/lib/booking/agent.ts +108 -0
  71. package/src/lib/booking/availability.ts +221 -0
  72. package/src/lib/booking/emails.ts +115 -0
  73. package/src/lib/booking/forms.ts +77 -0
  74. package/src/lib/booking/service.ts +277 -0
  75. package/src/lib/booking/view.ts +54 -0
  76. package/src/lib/calendar/agent-schema.ts +48 -0
  77. package/src/lib/calendar/agent.ts +136 -0
  78. package/src/lib/calendar/api.ts +81 -0
  79. package/src/lib/calendar/cards.ts +102 -0
  80. package/src/lib/calendar/config.ts +52 -0
  81. package/src/lib/calendar/data.ts +130 -0
  82. package/src/lib/calendar/events.ts +261 -0
  83. package/src/lib/calendar/feeds.ts +43 -0
  84. package/src/lib/calendar/hooks.ts +38 -0
  85. package/src/lib/calendar/http.ts +30 -0
  86. package/src/lib/calendar/ics-write.ts +120 -0
  87. package/src/lib/calendar/ics.ts +15 -5
  88. package/src/lib/calendar/import.ts +203 -0
  89. package/src/lib/calendar/render.ts +120 -37
  90. package/src/lib/calendar/rrule.ts +149 -0
  91. package/src/lib/calendar/seo.ts +48 -0
  92. package/src/lib/design-service.ts +58 -0
  93. package/src/lib/designDiff.ts +145 -0
  94. package/src/lib/designPreview.ts +112 -0
  95. package/src/lib/documents/cleanup.ts +31 -0
  96. package/src/lib/documents/extract.ts +154 -0
  97. package/src/lib/documents/vendor.d.ts +4 -0
  98. package/src/lib/drafts.ts +131 -0
  99. package/src/lib/dynamicBlocks.ts +79 -7
  100. package/src/lib/email/accounts.ts +55 -0
  101. package/src/lib/email/config.ts +86 -0
  102. package/src/lib/email/migration.ts +24 -0
  103. package/src/lib/email/providers.ts +89 -0
  104. package/src/lib/email/service.ts +78 -0
  105. package/src/lib/email/store.ts +167 -0
  106. package/src/lib/email/templates.ts +18 -0
  107. package/src/lib/email/types.ts +32 -0
  108. package/src/lib/email/webhooks.ts +87 -0
  109. package/src/lib/email.ts +15 -0
  110. package/src/lib/env.ts +1 -1
  111. package/src/lib/legal/index.ts +25 -0
  112. package/src/lib/mobile/bookings.ts +73 -0
  113. package/src/lib/mobile/calendar.ts +85 -0
  114. package/src/lib/mobile/content.ts +85 -0
  115. package/src/lib/mobile/http.ts +63 -0
  116. package/src/lib/mobile/route.ts +20 -0
  117. package/src/lib/ops.ts +8 -0
  118. package/src/lib/preview.ts +21 -1
  119. package/src/lib/repo/migrations.ts +254 -0
  120. package/src/lib/repo/sql.ts +956 -46
  121. package/src/lib/repo/types.ts +140 -3
  122. package/src/lib/scheduler.ts +25 -0
  123. package/src/lib/schema.ts +362 -0
  124. package/src/lib/search-i18n.ts +3 -0
  125. package/src/lib/socialIcons.ts +32 -0
  126. package/src/lib/tagColor.ts +11 -0
  127. package/src/lib/theme.ts +59 -40
  128. package/src/lib/themeTokens.ts +174 -0
  129. package/src/lib/umami.ts +108 -0
  130. package/src/lib/webhooks.ts +139 -0
  131. package/src/middleware.ts +36 -3
  132. package/src/pages/404.astro +23 -0
  133. package/src/pages/[...slug].astro +10 -5
  134. package/src/pages/account/[action].astro +53 -0
  135. package/src/pages/admin/ai.astro +12 -0
  136. package/src/pages/admin/c/[collection]/[id].astro +14 -4
  137. package/src/pages/admin/c/[collection]/index.astro +127 -91
  138. package/src/pages/admin/calendar/bookings.astro +400 -0
  139. package/src/pages/admin/calendar/calendars.astro +265 -0
  140. package/src/pages/admin/calendar/events/[id].astro +56 -0
  141. package/src/pages/admin/calendar/events/index.astro +408 -0
  142. package/src/pages/admin/calendar/index.ts +4 -0
  143. package/src/pages/admin/calendar/integrations.astro +221 -0
  144. package/src/pages/admin/calendar/resources/[id].astro +180 -0
  145. package/src/pages/admin/calendar/resources/index.astro +106 -0
  146. package/src/pages/admin/calendar/resources/link.astro +196 -0
  147. package/src/pages/admin/design.astro +16 -4
  148. package/src/pages/admin/email.astro +13 -0
  149. package/src/pages/admin/index.astro +237 -87
  150. package/src/pages/admin/links.astro +3 -3
  151. package/src/pages/admin/login.astro +14 -10
  152. package/src/pages/admin/navigation.astro +8 -2
  153. package/src/pages/admin/pages/[id].astro +14 -3
  154. package/src/pages/admin/pages/index.astro +41 -47
  155. package/src/pages/admin/settings.astro +475 -276
  156. package/src/pages/admin/tags.astro +4 -4
  157. package/src/pages/admin/users.astro +38 -28
  158. package/src/pages/api/agent/docs.ts +33 -0
  159. package/src/pages/api/agent/index.ts +21 -0
  160. package/src/pages/api/ai/clean.ts +13 -0
  161. package/src/pages/api/ai/draft.ts +14 -0
  162. package/src/pages/api/ai/settings.ts +53 -0
  163. package/src/pages/api/ai/test.ts +12 -0
  164. package/src/pages/api/backup.ts +8 -21
  165. package/src/pages/api/calendar/availability.ts +35 -0
  166. package/src/pages/api/calendar/bookings/[id].ts +49 -0
  167. package/src/pages/api/calendar/bookings/index.ts +73 -0
  168. package/src/pages/api/calendar/calendars.ts +35 -0
  169. package/src/pages/api/calendar/docs.ts +64 -0
  170. package/src/pages/api/calendar/events/[id].ts +63 -0
  171. package/src/pages/api/calendar/events/index.ts +112 -0
  172. package/src/pages/api/calendar/resources.ts +34 -0
  173. package/src/pages/api/design/capabilities.ts +10 -0
  174. package/src/pages/api/design/index.ts +58 -0
  175. package/src/pages/api/design/keys.ts +24 -0
  176. package/src/pages/api/design/media.ts +32 -0
  177. package/src/pages/api/email/run.ts +11 -0
  178. package/src/pages/api/email/settings.ts +61 -0
  179. package/src/pages/api/email/webhooks/[provider].ts +4 -0
  180. package/src/pages/api/mcp.ts +59 -0
  181. package/src/pages/api/media/upload.ts +2 -2
  182. package/src/pages/api/ops/status.ts +39 -0
  183. package/src/pages/api/restore.ts +27 -37
  184. package/src/pages/api/search.ts +18 -4
  185. package/src/pages/api/v1/availability.ts +7 -0
  186. package/src/pages/api/v1/bookings.ts +17 -0
  187. package/src/pages/api/v1/calendars.ts +7 -0
  188. package/src/pages/api/v1/content/[id].ts +7 -0
  189. package/src/pages/api/v1/content/index.ts +7 -0
  190. package/src/pages/api/v1/events.ts +7 -0
  191. package/src/pages/api/v1/resources.ts +7 -0
  192. package/src/pages/author/[slug].astro +43 -35
  193. package/src/pages/blog/[slug].astro +140 -66
  194. package/src/pages/blog/index.astro +95 -30
  195. package/src/pages/blog/tag/[slug].astro +45 -40
  196. package/src/pages/book/[resource]/[link].astro +70 -0
  197. package/src/pages/book/[resource]/index.astro +63 -0
  198. package/src/pages/book/[resource].ics.ts +38 -0
  199. package/src/pages/book/index.astro +47 -0
  200. package/src/pages/book/manage/[token].astro +108 -0
  201. package/src/pages/calendar/[slug].ics.ts +27 -0
  202. package/src/pages/calendar/feed.ics.ts +15 -0
  203. package/src/pages/calendar/index.astro +191 -0
  204. package/src/pages/embed/book/[resource]/[link].astro +33 -0
  205. package/src/pages/embed/calendar/[slug].astro +43 -0
  206. package/src/pages/events/[slug].astro +74 -0
  207. package/src/pages/events/[slug].ics.ts +25 -0
  208. package/src/pages/index.astro +9 -3
  209. package/src/pages/legal/privacy.astro +4 -0
  210. package/src/pages/legal/terms.astro +4 -0
  211. package/src/pages/links.astro +33 -7
  212. package/src/pages/llms.txt.ts +4 -0
  213. package/src/pages/preview/[type]/[id].astro +34 -8
  214. package/src/pages/search.astro +40 -20
  215. package/src/pages/sitemap.xml.ts +16 -1
  216. package/src/styles/admin.css +928 -105
  217. package/src/styles/cards.css +101 -60
  218. package/src/styles/editor.css +532 -102
  219. package/src/styles/email-settings.css +117 -0
  220. package/src/styles/sections.css +12 -0
  221. package/src/styles/site.css +938 -278
  222. package/src/styles/theme-editor.css +135 -0
  223. package/src/theme-sdk/contract.d.mts +619 -0
  224. package/src/theme-sdk/contract.mjs +80 -0
  225. package/src/theme-sdk/index.ts +15 -0
  226. package/src/theme-sdk/tokens.d.mts +148 -0
  227. package/src/theme-sdk/tokens.mjs +52 -0
  228. package/src/themes/editorial/templates/home.astro +4 -4
  229. package/src/themes/editorial/templates/post-minimal.astro +2 -2
  230. package/src/themes/editorial/theme.css +22 -37
  231. package/src/themes/editorial/theme.json +23 -3
  232. package/src/themes/field/theme.json +26 -9
  233. package/src/themes/ink/theme.json +30 -12
  234. package/src/themes/night/theme.css +4 -7
  235. package/src/themes/night/theme.json +27 -10
  236. package/src/virtual.d.ts +14 -0
  237. package/src/worker.ts +5 -1
@@ -6,6 +6,9 @@ import { collectionUrl, tagUrl } from '../lib/content';
6
6
  import { authorSlug } from '../lib/schema';
7
7
  import { I18N, localeFromPath, localeHomeUrl, normalizePageLocale } from '../lib/i18n';
8
8
  import { searchStrings } from '../lib/search-i18n';
9
+ import { CALENDAR, eventUrl } from '../lib/calendar/config';
10
+ import { eventIsPublic, featuredOccurrence, formatOccurrence } from '../lib/calendar/events';
11
+ import { siteLocale } from '../lib/dates';
9
12
 
10
13
  // The no-JS search surface (the modal's form falls back here). Serves both
11
14
  // /search and the locale-prefixed /<locale>/search routes — the locale comes
@@ -20,8 +23,10 @@ const locale = normalizePageLocale(reqLocale);
20
23
  const t = searchStrings((reqLocale || siteLang(settings)).slice(0, 2));
21
24
  const results = q
22
25
  ? await repo.searchPublished(q, { locale })
23
- : { posts: [], pages: [], tags: [], authors: [] };
24
- const total = results.posts.length + results.pages.length + results.tags.length + results.authors.length;
26
+ : { posts: [], pages: [], events: [], tags: [], authors: [] };
27
+ const calMap = new Map((await repo.listCalendars()).map((c) => [c.id, c]));
28
+ const events = CALENDAR.enabled ? results.events.filter(({ doc }) => eventIsPublic(doc, calMap)).slice(0, 10) : [];
29
+ const total = results.posts.length + results.pages.length + events.length + results.tags.length + results.authors.length;
25
30
  ---
26
31
 
27
32
  <Site title={q ? `${t.label}: ${q}` : t.label} description={`${t.label} · ${settings.siteTitle}`} noindex={Boolean(q)}>
@@ -88,6 +93,26 @@ const total = results.posts.length + results.pages.length + results.tags.length
88
93
  </section>
89
94
  )}
90
95
 
96
+ {events.length > 0 && (
97
+ <section class="search-section">
98
+ <h2>{t.events}</h2>
99
+ <ul class="post-list">
100
+ {events.map(({ doc: e, snippet }) => {
101
+ const o = featuredOccurrence(e, settings, Date.now());
102
+ return (
103
+ <li class="post-item">
104
+ <div>
105
+ <a href={eventUrl(e.slug)}>{e.title}</a>
106
+ {o && <span class="search-loc">{formatOccurrence(o, settings.timezone || 'UTC', siteLocale(settings)).range}</span>}
107
+ {snippet && <p class="post-excerpt" set:html={snippet} />}
108
+ </div>
109
+ </li>
110
+ );
111
+ })}
112
+ </ul>
113
+ </section>
114
+ )}
115
+
91
116
  {results.tags.length > 0 && (
92
117
  <section class="search-section">
93
118
  <h2>{t.tags}</h2>
@@ -118,31 +143,26 @@ const total = results.posts.length + results.pages.length + results.tags.length
118
143
  </Site>
119
144
 
120
145
  <style>
121
- .search-hero { margin: 24px 0 8px; }
122
- .search-form { display: flex; gap: 10px; margin: 18px 0; }
123
- .search-form input {
124
- flex: 1; font: inherit; padding: 10px 14px; border: 1px solid var(--line);
125
- border-radius: 9px; background: var(--panel); color: var(--ink);
126
- }
127
- .search-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
146
+ .search-hero { padding: calc(20px * var(--space)) 0 0; }
147
+ .search-hero h1 { font-size: clamp(34px, 5vw, 46px); margin: 0 0 18px; }
148
+ .search-form { display: flex; gap: 6px; padding: 5px; margin: 0 0 18px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--sh-1); }
149
+ .search-form:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
150
+ .search-form input { flex: 1; min-width: 0; font: inherit; padding: 0 12px; border: 0; background: none; color: var(--ink); outline: none; }
128
151
  .search-form button {
129
- font: inherit; font-weight: 600; padding: 10px 20px; border: 0; border-radius: 9px;
130
- background: var(--accent); color: #fff; cursor: pointer;
152
+ font: 550 15px/1 var(--font-body); height: 42px; padding: 0 18px; border: 0; border-radius: 10px;
153
+ background: var(--btn); color: var(--btn-ink); cursor: pointer;
131
154
  }
132
- .search-count { color: var(--muted); }
133
- .search-section h2 { font-size: 1.1rem; margin-top: 2rem; }
155
+ .search-count { color: var(--muted); font-size: 14.5px; margin: 0 0 8px; }
156
+ .search-section h2 { font-size: 13px; font-weight: 550; letter-spacing: 0; color: var(--muted); margin: 36px 0 4px; font-family: var(--font-body); }
157
+ .post-list :global(.post-excerpt) { color: var(--muted); font-size: 15px; margin: 4px 0 0; }
134
158
  /* snippets arrive pre-escaped with <mark> around matches (set:html), so
135
159
  the highlight style must reach into the injected fragment */
136
160
  .post-excerpt :global(mark) {
137
161
  background: color-mix(in srgb, var(--accent) 22%, transparent);
138
162
  color: inherit; border-radius: 3px; padding: 0 1px;
139
163
  }
140
- .search-loc {
141
- font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: var(--muted);
142
- border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; margin-left: 8px;
143
- vertical-align: 2px;
144
- }
145
- .search-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
146
- .search-tag-count { color: var(--muted); }
164
+ .search-loc { font-size: 12.5px; font-weight: 550; color: var(--muted); margin-left: 10px; }
165
+ .search-tags { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; }
166
+ .search-tag-count { color: var(--muted); font-weight: 400; }
147
167
  .search-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none; }
148
168
  </style>
@@ -3,18 +3,24 @@ import { getRepo } from '../lib/repo';
3
3
  import { isInternalTag } from '../lib/schema';
4
4
  import { siteOrigin, xmlEscape } from '../lib/seo';
5
5
  import { CONTENT, collectionUrl, tagUrl } from '../lib/content';
6
+ import { CALENDAR, eventUrl, bookingsEnabled, resourceUrl } from '../lib/calendar/config';
7
+ import { eventIsPublic } from '../lib/calendar/events';
6
8
 
7
9
  // DB-backed sitemap: content lives in D1/libSQL, so this is generated per
8
10
  // request instead of at build time. Draft/scheduled content never appears.
9
11
 
10
12
  export const GET: APIRoute = async ({ locals, url }) => {
11
13
  const repo = await getRepo(locals);
12
- const [settings, pages, posts, tags] = await Promise.all([
14
+ const [settings, pages, posts, tags, events, calendars] = await Promise.all([
13
15
  repo.getSettings(),
14
16
  repo.listPages(),
15
17
  repo.listPublishedPosts(),
16
18
  repo.listTags(),
19
+ CALENDAR.enabled ? repo.listPublishedEvents() : Promise.resolve([]),
20
+ CALENDAR.enabled ? repo.listCalendars() : Promise.resolve([]),
17
21
  ]);
22
+ const calMap = new Map(calendars.map((c) => [c.id, c]));
23
+ const publicEvents = events.filter((e) => eventIsPublic(e, calMap));
18
24
  const origin = siteOrigin(settings, url);
19
25
 
20
26
  const usedTags = new Set(posts.flatMap((p) => p.tags.map((t) => t.toLowerCase())));
@@ -37,6 +43,15 @@ export const GET: APIRoute = async ({ locals, url }) => {
37
43
  .filter((t) => usedTags.has(t.name.toLowerCase()) && !isInternalTag(t.name))
38
44
  .map((t) => ({ loc: tagUrl(t.slug) })),
39
45
  { loc: '/links' },
46
+ ...(CALENDAR.enabled
47
+ ? [
48
+ { loc: CALENDAR.base, lastmod: Math.max(0, ...publicEvents.map((e) => e.updatedAt)) || undefined },
49
+ ...publicEvents.map((e) => ({ loc: eventUrl(e.slug), lastmod: e.updatedAt })),
50
+ ]
51
+ : []),
52
+ ...(bookingsEnabled()
53
+ ? [{ loc: CALENDAR.bookBase }, ...(await repo.listResources()).filter((r) => r.visibility === 'public').map((r) => ({ loc: resourceUrl(r.slug), lastmod: r.updatedAt }))]
54
+ : []),
40
55
  ];
41
56
 
42
57
  const xml = `<?xml version="1.0" encoding="UTF-8"?>