ampless 1.0.0-alpha.14 → 1.0.0-alpha.16
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 +66 -7
- package/dist/index.js +1 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
type ContentEventType = 'content.created' | 'content.updated' | 'content.published' | 'content.unpublished' | 'content.deleted';
|
|
2
2
|
type MediaEventType = 'media.uploaded' | 'media.deleted';
|
|
3
3
|
type SiteSettingsEventType = 'site.settings.updated';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Emitted on every Post mutation (INSERT / MODIFY / REMOVE) with both
|
|
6
|
+
* the previous and the next projection of the row. Drives index-style
|
|
7
|
+
* derivation: the built-in trusted-processor handler uses it to keep
|
|
8
|
+
* the `PostTag` denormalized index in sync without making every write
|
|
9
|
+
* path (admin, MCP, future REST clients) remember to call a helper.
|
|
10
|
+
*
|
|
11
|
+
* Plugins that maintain their own indexes (custom search, sitemaps
|
|
12
|
+
* with per-tag pages, etc.) can subscribe through the same hook
|
|
13
|
+
* surface as the other event types — the diff payload is already in
|
|
14
|
+
* the right shape for "compute add/remove/update".
|
|
15
|
+
*/
|
|
16
|
+
type PostIndexEventType = 'post.index.refresh';
|
|
17
|
+
type EventType = ContentEventType | MediaEventType | SiteSettingsEventType | PostIndexEventType;
|
|
5
18
|
/** Minimal projection of a Post item carried in events (no body, to keep payloads small). */
|
|
6
19
|
interface ContentEventPayload {
|
|
7
20
|
postId: string;
|
|
@@ -23,7 +36,17 @@ interface MediaEventPayload {
|
|
|
23
36
|
*/
|
|
24
37
|
interface SiteSettingsEventPayload {
|
|
25
38
|
}
|
|
26
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Diff payload for `post.index.refresh`. `previous` is null on INSERT;
|
|
41
|
+
* `next` is null on REMOVE; both populated on MODIFY. Subscribers
|
|
42
|
+
* compute the add / remove / update set from this — see the trusted
|
|
43
|
+
* processor's `rebuildPostTags` handler for the canonical example.
|
|
44
|
+
*/
|
|
45
|
+
interface PostIndexEventPayload {
|
|
46
|
+
previous: ContentEventPayload | null;
|
|
47
|
+
next: ContentEventPayload | null;
|
|
48
|
+
}
|
|
49
|
+
type EventPayloadOf<T extends EventType> = T extends ContentEventType ? ContentEventPayload : T extends MediaEventType ? MediaEventPayload : T extends SiteSettingsEventType ? SiteSettingsEventPayload : T extends PostIndexEventType ? PostIndexEventPayload : never;
|
|
27
50
|
interface AmplessEvent<T extends EventType = EventType> {
|
|
28
51
|
type: T;
|
|
29
52
|
payload: EventPayloadOf<T>;
|
|
@@ -223,9 +246,33 @@ type CacheStrategy = 'auto' | 'deep' | 'hot';
|
|
|
223
246
|
* are free to store their own per-post state here (e.g. SEO overrides,
|
|
224
247
|
* feature flags, A/B variants).
|
|
225
248
|
*/
|
|
249
|
+
/**
|
|
250
|
+
* Per-file metadata recorded on a static post. The static route
|
|
251
|
+
* reads this to decide whether to stream the bytes back through
|
|
252
|
+
* Lambda (small files → cached by CloudFront) or to 302-redirect
|
|
253
|
+
* to a presigned URL (large files → bypass the Lambda response
|
|
254
|
+
* size envelope). Populated by `upload_static_bundle` /
|
|
255
|
+
* `commit_static_post` at upload time so the read path never
|
|
256
|
+
* issues a HEAD round-trip.
|
|
257
|
+
*
|
|
258
|
+
* `body.files` (the manifest's flat list) stays the source of truth
|
|
259
|
+
* for "what's in the bundle"; this map is purely a delivery hint and
|
|
260
|
+
* may be sparse when older bundles predate the migration.
|
|
261
|
+
*/
|
|
262
|
+
interface StaticPostFileMeta {
|
|
263
|
+
size: number;
|
|
264
|
+
mimeType: string;
|
|
265
|
+
}
|
|
226
266
|
interface PostMetadata {
|
|
227
267
|
no_layout?: boolean;
|
|
228
268
|
cache?: CacheStrategy;
|
|
269
|
+
/**
|
|
270
|
+
* For `format: 'static'` posts only. Keyed by the bundle-relative
|
|
271
|
+
* path (same shape as `body.files` entries). Older bundles may
|
|
272
|
+
* lack this map — readers MUST treat a missing entry as
|
|
273
|
+
* "fall back to a HEAD lookup".
|
|
274
|
+
*/
|
|
275
|
+
files?: Record<string, StaticPostFileMeta>;
|
|
229
276
|
[key: string]: unknown;
|
|
230
277
|
}
|
|
231
278
|
interface Post {
|
|
@@ -258,12 +305,25 @@ interface Page {
|
|
|
258
305
|
status: PostStatus;
|
|
259
306
|
publishedAt?: string;
|
|
260
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* Asset metadata recorded on the Media row. Currently the only
|
|
310
|
+
* well-known key is `etag` (the S3 object ETag, captured at upload
|
|
311
|
+
* time so the media-proxy route can emit it back to the client
|
|
312
|
+
* without a HEAD round-trip). Free-form by design — themes and
|
|
313
|
+
* plugins can add their own keys (image dimensions, EXIF strip
|
|
314
|
+
* status, etc.) without a schema change.
|
|
315
|
+
*/
|
|
316
|
+
interface MediaMetadata {
|
|
317
|
+
etag?: string;
|
|
318
|
+
[key: string]: unknown;
|
|
319
|
+
}
|
|
261
320
|
interface Media {
|
|
262
321
|
mediaId: string;
|
|
263
322
|
src: string;
|
|
264
323
|
mimeType: string;
|
|
265
324
|
size: number;
|
|
266
325
|
delivery: 'nextjs' | 's3-direct';
|
|
326
|
+
metadata?: MediaMetadata;
|
|
267
327
|
}
|
|
268
328
|
type ImageDisplay = 'inline' | 'lightbox';
|
|
269
329
|
/**
|
|
@@ -477,9 +537,8 @@ declare function escapeXml(s: string): string;
|
|
|
477
537
|
* from DynamoDB (the path used by the trusted processor and the
|
|
478
538
|
* MCP Lambda).
|
|
479
539
|
*
|
|
480
|
-
* `decodeAwsJson`
|
|
481
|
-
* everything else as-is
|
|
482
|
-
* so bare-string rows aren't lost.
|
|
540
|
+
* `decodeAwsJson` handles both: pass strings through `JSON.parse`,
|
|
541
|
+
* everything else as-is.
|
|
483
542
|
*/
|
|
484
543
|
/**
|
|
485
544
|
* Serialise a value for an AWSJSON variable. `undefined` / `null` both
|
|
@@ -490,7 +549,7 @@ declare function encodeAwsJson(value: unknown): string;
|
|
|
490
549
|
/**
|
|
491
550
|
* Deserialise an AWSJSON value from a GraphQL / DynamoDB read.
|
|
492
551
|
* Tolerates both the wire-string shape and the auto-unmarshalled
|
|
493
|
-
* native value.
|
|
552
|
+
* native value. Throws if the string is not valid JSON.
|
|
494
553
|
*/
|
|
495
554
|
declare function decodeAwsJson(value: unknown): unknown;
|
|
496
555
|
|
|
@@ -814,4 +873,4 @@ declare function resolveThemeValues(manifest: ThemeManifest, stored: Record<stri
|
|
|
814
873
|
|
|
815
874
|
declare const VERSION = "0.0.1";
|
|
816
875
|
|
|
817
|
-
export { type AmplessEvent, type AmplessPlugin, type AuthContext, type BundleExtractResult, type CacheConfig, type CacheStrategy, type Config, type ContentEventPayload, type ContentEventType, type ContentFormat, type ContentTypeDefinition, type CreatePostInput, DEFAULT_ENTRYPOINT, type DateFormat, type EventPayloadOf, type EventType, type ExtractedFile, type FieldDefinition, type FieldType, type ImageDisplay, type KvItem, type KvStore, type LinkListItem, type ListOptions, type LocalizedString, MAX_BUNDLE_BYTES, 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 SiteSettingsEventPayload, type SiteSettingsEventType, type StaticPostBody, type StreamEventName, TEXT_EXTENSIONS, 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, type ValidationIssue, bundlePrefix, createPost, decodeAwsJson, defineConfig, definePlugin, defineSchema, defineTheme, defineThemeModule, deletePost, deleteSiteSetting, detectContentEvents, encodeAwsJson, escapeXml, extractFirstImageUrl, findAbsolutePathRefs, flattenSettings, formatColorPair, formatDate, formatPublicAssetUrl, getKvStore, getPost, getPostById, getSiteSetting, hasKvStore, hasPostsProvider, isTagListUrl, listPosts, listSiteSettings, mimeTypeFor, parseColorPair, parseLinkList, pickDefaultEntrypoint, resolveLocalized, resolveThemeValues, setKvStore, setPostsProvider, setSiteSetting, stringifyLinkList, stripCommonPrefix, themeSettingKey, unflattenSettings, updatePost, validateBundle, validateBundlePath, validateThemeValue };
|
|
876
|
+
export { type AmplessEvent, type AmplessPlugin, type AuthContext, type BundleExtractResult, type CacheConfig, type CacheStrategy, type Config, type ContentEventPayload, type ContentEventType, type ContentFormat, type ContentTypeDefinition, type CreatePostInput, DEFAULT_ENTRYPOINT, type DateFormat, type EventPayloadOf, type EventType, type ExtractedFile, type FieldDefinition, type FieldType, type ImageDisplay, type KvItem, type KvStore, type LinkListItem, type ListOptions, type LocalizedString, MAX_BUNDLE_BYTES, type Media, type MediaEventPayload, type MediaEventType, type MediaMetadata, type MediaProcessingDefaults, type OgImageConfig, type OgImageFont, type OgImageRenderContext, type Page, type PluginEventHandler, type PluginMetadata, type PluginRuntimeContext, type Post, type PostIndexEventPayload, type PostIndexEventType, type PostMetadata, type PostStatus, type PostsProvider, type Role, SITE_CONFIG_PK, type SiteSettingsEventPayload, type SiteSettingsEventType, type StaticPostBody, type StaticPostFileMeta, type StreamEventName, TEXT_EXTENSIONS, 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, type ValidationIssue, bundlePrefix, createPost, decodeAwsJson, defineConfig, definePlugin, defineSchema, defineTheme, defineThemeModule, deletePost, deleteSiteSetting, detectContentEvents, encodeAwsJson, escapeXml, extractFirstImageUrl, findAbsolutePathRefs, flattenSettings, formatColorPair, formatDate, formatPublicAssetUrl, getKvStore, getPost, getPostById, getSiteSetting, hasKvStore, hasPostsProvider, isTagListUrl, listPosts, listSiteSettings, mimeTypeFor, parseColorPair, parseLinkList, pickDefaultEntrypoint, resolveLocalized, resolveThemeValues, setKvStore, setPostsProvider, setSiteSetting, stringifyLinkList, stripCommonPrefix, themeSettingKey, unflattenSettings, updatePost, validateBundle, validateBundlePath, validateThemeValue };
|
package/dist/index.js
CHANGED
|
@@ -202,11 +202,7 @@ function encodeAwsJson(value) {
|
|
|
202
202
|
}
|
|
203
203
|
function decodeAwsJson(value) {
|
|
204
204
|
if (typeof value !== "string") return value;
|
|
205
|
-
|
|
206
|
-
return JSON.parse(value);
|
|
207
|
-
} catch {
|
|
208
|
-
return value;
|
|
209
|
-
}
|
|
205
|
+
return JSON.parse(value);
|
|
210
206
|
}
|
|
211
207
|
|
|
212
208
|
// src/storage.ts
|