ampless 0.2.0-alpha.1 → 0.2.0-alpha.3
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 +52 -7
- package/dist/index.js +2 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -166,8 +166,51 @@ interface AmplessPlugin {
|
|
|
166
166
|
}
|
|
167
167
|
declare function definePlugin(p: AmplessPlugin): AmplessPlugin;
|
|
168
168
|
|
|
169
|
-
type ContentFormat = 'tiptap' | 'markdown' | 'html';
|
|
169
|
+
type ContentFormat = 'tiptap' | 'markdown' | 'html' | 'static';
|
|
170
|
+
/**
|
|
171
|
+
* Body shape for `format: 'static'` posts. The actual asset bytes
|
|
172
|
+
* live under S3 at `public/static/<siteId>/<slug>/<files...>` — the
|
|
173
|
+
* body here is the manifest describing which entrypoint to serve and
|
|
174
|
+
* which files are part of the bundle.
|
|
175
|
+
*
|
|
176
|
+
* Stored as JSON in the `body` column (same encoding pattern as the
|
|
177
|
+
* tiptap doc / html string / markdown string for the other formats).
|
|
178
|
+
*
|
|
179
|
+
* Hard constraint enforced at upload time: every asset must reference
|
|
180
|
+
* other assets in the bundle by **relative path** only. Absolute paths
|
|
181
|
+
* (`/foo`) and protocol-relative paths (`//cdn.example/foo`) inside
|
|
182
|
+
* referenced HTML / CSS are rejected so a bundle stays portable across
|
|
183
|
+
* any URL prefix without rewriting at serve time. See the admin's
|
|
184
|
+
* StaticUploader for the validation logic.
|
|
185
|
+
*/
|
|
186
|
+
interface StaticPostBody {
|
|
187
|
+
/** Relative path to the entrypoint inside the bundle (default 'index.html'). */
|
|
188
|
+
entrypoint: string;
|
|
189
|
+
/** Every file in the bundle (relative paths). Used for delete cleanup and admin display. */
|
|
190
|
+
files: string[];
|
|
191
|
+
/** ISO 8601 timestamp of the most recent upload. */
|
|
192
|
+
uploadedAt: string;
|
|
193
|
+
}
|
|
170
194
|
type PostStatus = 'draft' | 'published';
|
|
195
|
+
/**
|
|
196
|
+
* Free-form per-post metadata. The `metadata` JSON column carries
|
|
197
|
+
* arbitrary key/value pairs; the runtime / themes / plugins each pick
|
|
198
|
+
* the keys they care about. A handful of well-known keys are owned by
|
|
199
|
+
* ampless itself and documented here.
|
|
200
|
+
*
|
|
201
|
+
* Well-known keys:
|
|
202
|
+
* - `no_layout`: when true, the public page is served as bare HTML
|
|
203
|
+
* (no theme chrome). The runtime's post dispatcher checks this
|
|
204
|
+
* before rendering and redirects to the raw route handler.
|
|
205
|
+
*
|
|
206
|
+
* Additional keys are passed through unchanged — themes and plugins
|
|
207
|
+
* are free to store their own per-post state here (e.g. SEO overrides,
|
|
208
|
+
* feature flags, A/B variants).
|
|
209
|
+
*/
|
|
210
|
+
interface PostMetadata {
|
|
211
|
+
no_layout?: boolean;
|
|
212
|
+
[key: string]: unknown;
|
|
213
|
+
}
|
|
171
214
|
interface Post {
|
|
172
215
|
postId: string;
|
|
173
216
|
siteId: string;
|
|
@@ -179,6 +222,7 @@ interface Post {
|
|
|
179
222
|
status: PostStatus;
|
|
180
223
|
publishedAt?: string;
|
|
181
224
|
tags?: string[];
|
|
225
|
+
metadata?: PostMetadata;
|
|
182
226
|
}
|
|
183
227
|
interface Page {
|
|
184
228
|
pageId: string;
|
|
@@ -351,11 +395,12 @@ declare const DEFAULT_SITE_ID = "default";
|
|
|
351
395
|
/**
|
|
352
396
|
* Resolve a hostname to a configured siteId.
|
|
353
397
|
*
|
|
354
|
-
* - Single-site mode (no `sites` defined
|
|
355
|
-
*
|
|
356
|
-
* every request.
|
|
357
|
-
* - Multi-site mode: looks up the host in each site's
|
|
358
|
-
* Returns `null` if the host is not registered
|
|
398
|
+
* - Single-site mode (no `sites` defined / empty / exactly one entry):
|
|
399
|
+
* returns that site's id regardless of host. The single site catches
|
|
400
|
+
* every request. Matches `isMultiSite` (≥2 entries = multi).
|
|
401
|
+
* - Multi-site mode (2+ entries): looks up the host in each site's
|
|
402
|
+
* `domains` list. Returns `null` if the host is not registered
|
|
403
|
+
* (caller should 404).
|
|
359
404
|
*
|
|
360
405
|
* The host comparison is case-insensitive; ports are not stripped here
|
|
361
406
|
* — pass the bare hostname (e.g. `'site-a.example.com'`).
|
|
@@ -645,4 +690,4 @@ declare function resolveThemeValues(manifest: ThemeManifest, stored: Record<stri
|
|
|
645
690
|
|
|
646
691
|
declare const VERSION = "0.0.1";
|
|
647
692
|
|
|
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 };
|
|
693
|
+
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 StaticPostBody, 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;
|