ampless 0.2.0-alpha.0 → 0.2.0-alpha.2

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/index.d.ts CHANGED
@@ -168,6 +168,25 @@ declare function definePlugin(p: AmplessPlugin): AmplessPlugin;
168
168
 
169
169
  type ContentFormat = 'tiptap' | 'markdown' | 'html';
170
170
  type PostStatus = 'draft' | 'published';
171
+ /**
172
+ * Free-form per-post metadata. The `metadata` JSON column carries
173
+ * arbitrary key/value pairs; the runtime / themes / plugins each pick
174
+ * the keys they care about. A handful of well-known keys are owned by
175
+ * ampless itself and documented here.
176
+ *
177
+ * Well-known keys:
178
+ * - `no_layout`: when true, the public page is served as bare HTML
179
+ * (no theme chrome). The runtime's post dispatcher checks this
180
+ * before rendering and redirects to the raw route handler.
181
+ *
182
+ * Additional keys are passed through unchanged — themes and plugins
183
+ * are free to store their own per-post state here (e.g. SEO overrides,
184
+ * feature flags, A/B variants).
185
+ */
186
+ interface PostMetadata {
187
+ no_layout?: boolean;
188
+ [key: string]: unknown;
189
+ }
171
190
  interface Post {
172
191
  postId: string;
173
192
  siteId: string;
@@ -179,6 +198,7 @@ interface Post {
179
198
  status: PostStatus;
180
199
  publishedAt?: string;
181
200
  tags?: string[];
201
+ metadata?: PostMetadata;
182
202
  }
183
203
  interface Page {
184
204
  pageId: string;
@@ -351,11 +371,12 @@ declare const DEFAULT_SITE_ID = "default";
351
371
  /**
352
372
  * Resolve a hostname to a configured siteId.
353
373
  *
354
- * - Single-site mode (no `sites` defined or empty): always returns
355
- * `DEFAULT_SITE_ID` regardless of host. The single site catches
356
- * every request.
357
- * - Multi-site mode: looks up the host in each site's `domains` list.
358
- * Returns `null` if the host is not registered (caller should 404).
374
+ * - Single-site mode (no `sites` defined / empty / exactly one entry):
375
+ * returns that site's id regardless of host. The single site catches
376
+ * every request. Matches `isMultiSite` (≥2 entries = multi).
377
+ * - Multi-site mode (2+ entries): looks up the host in each site's
378
+ * `domains` list. Returns `null` if the host is not registered
379
+ * (caller should 404).
359
380
  *
360
381
  * The host comparison is case-insensitive; ports are not stripped here
361
382
  * — pass the bare hostname (e.g. `'site-a.example.com'`).
@@ -645,4 +666,4 @@ declare function resolveThemeValues(manifest: ThemeManifest, stored: Record<stri
645
666
 
646
667
  declare const VERSION = "0.0.1";
647
668
 
648
- export { type AmplessEvent, type AmplessPlugin, type AuthContext, type Config, type ContentEventPayload, type ContentEventType, type ContentFormat, type ContentTypeDefinition, type CreatePostInput, DEFAULT_SITE_ID, type DateFormat, type EventPayloadOf, type EventType, type FieldDefinition, type FieldType, type ImageDisplay, type KvItem, type KvStore, type LinkListItem, type ListOptions, type LocalizedString, type Media, type MediaEventPayload, type MediaEventType, type MediaProcessingDefaults, type OgImageConfig, type OgImageFont, type OgImageRenderContext, type Page, type PluginEventHandler, type PluginMetadata, type PluginRuntimeContext, type Post, type PostStatus, type PostsProvider, type Role, SITE_CONFIG_PK, type SiteConfig, type SiteSettingsEventPayload, type SiteSettingsEventType, type StreamEventName, type ThemeColorField, type ThemeField, type ThemeFieldType, type ThemeFontFamilyField, type ThemeImageField, type ThemeLengthField, type ThemeLinkListField, type ThemeManifest, type ThemeModule, type ThemeRouteContext, type ThemeSelectField, type ThemeTextField, type TrustLevel, VERSION, composeSiteIdSlug, composeSiteIdStatus, createPost, defineConfig, definePlugin, defineSchema, defineTheme, defineThemeModule, deletePost, deleteSiteSetting, detectContentEvents, escapeXml, extractFirstImageUrl, flattenSettings, formatDate, formatPublicAssetUrl, getPost, getPostById, getSiteSetting, hasKvStore, hasPostsProvider, isMultiSite, isTagListUrl, listPosts, listSiteSettings, parseLinkList, resolveLocalized, resolveSiteId, resolveThemeValues, setKvStore, setPostsProvider, setSiteSetting, siteFor, stringifyLinkList, themeSettingKey, unflattenSettings, updatePost, validateThemeValue };
669
+ export { type AmplessEvent, type AmplessPlugin, type AuthContext, type Config, type ContentEventPayload, type ContentEventType, type ContentFormat, type ContentTypeDefinition, type CreatePostInput, DEFAULT_SITE_ID, type DateFormat, type EventPayloadOf, type EventType, type FieldDefinition, type FieldType, type ImageDisplay, type KvItem, type KvStore, type LinkListItem, type ListOptions, type LocalizedString, type Media, type MediaEventPayload, type MediaEventType, type MediaProcessingDefaults, type OgImageConfig, type OgImageFont, type OgImageRenderContext, type Page, type PluginEventHandler, type PluginMetadata, type PluginRuntimeContext, type Post, type PostMetadata, type PostStatus, type PostsProvider, type Role, SITE_CONFIG_PK, type SiteConfig, type SiteSettingsEventPayload, type SiteSettingsEventType, type StreamEventName, type ThemeColorField, type ThemeField, type ThemeFieldType, type ThemeFontFamilyField, type ThemeImageField, type ThemeLengthField, type ThemeLinkListField, type ThemeManifest, type ThemeModule, type ThemeRouteContext, type ThemeSelectField, type ThemeTextField, type TrustLevel, VERSION, composeSiteIdSlug, composeSiteIdStatus, createPost, defineConfig, definePlugin, defineSchema, defineTheme, defineThemeModule, deletePost, deleteSiteSetting, detectContentEvents, escapeXml, extractFirstImageUrl, flattenSettings, formatDate, formatPublicAssetUrl, getPost, getPostById, getSiteSetting, hasKvStore, hasPostsProvider, isMultiSite, isTagListUrl, listPosts, listSiteSettings, parseLinkList, resolveLocalized, resolveSiteId, resolveThemeValues, setKvStore, setPostsProvider, setSiteSetting, siteFor, stringifyLinkList, themeSettingKey, unflattenSettings, updatePost, validateThemeValue };
package/dist/index.js CHANGED
@@ -96,6 +96,8 @@ function resolveSiteId(host, config) {
96
96
  if (!sites || Object.keys(sites).length === 0) {
97
97
  return DEFAULT_SITE_ID;
98
98
  }
99
+ const ids = Object.keys(sites);
100
+ if (ids.length === 1) return ids[0];
99
101
  const lower = host.toLowerCase();
100
102
  for (const [id, site] of Object.entries(sites)) {
101
103
  if (site.domains.some((d) => d.toLowerCase() === lower)) return id;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ampless",
3
- "version": "0.2.0-alpha.0",
3
+ "version": "0.2.0-alpha.2",
4
4
  "description": "Serverless CMS for AWS Amplify",
5
5
  "license": "MIT",
6
6
  "type": "module",