ampless 1.0.0-alpha.37 → 1.0.0-alpha.38

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
@@ -1361,6 +1361,12 @@ interface Config {
1361
1361
  * field is absent.
1362
1362
  */
1363
1363
  cache?: CacheConfig;
1364
+ /**
1365
+ * Post revision-history knobs. The event-dispatcher Lambda snapshots
1366
+ * each post save into the `PostHistory` table; this controls how long
1367
+ * those snapshots are retained.
1368
+ */
1369
+ history?: HistoryConfig;
1364
1370
  }
1365
1371
  /**
1366
1372
  * Tunables for middleware-computed `Cache-Control`. See
@@ -1385,6 +1391,20 @@ interface CacheConfig {
1385
1391
  */
1386
1392
  deepTtlSeconds?: number;
1387
1393
  }
1394
+ /**
1395
+ * Post revision-history tunables, read by the event-dispatcher Lambda
1396
+ * (via the template shell) when snapshotting each post save.
1397
+ */
1398
+ interface HistoryConfig {
1399
+ /**
1400
+ * Days to retain each post revision before DynamoDB TTL deletes it.
1401
+ * Default 0 = keep forever (no `ttl` attribute is written). DynamoDB TTL
1402
+ * deletes within ~48h after expiry, so effective retention is
1403
+ * retentionDays + up to ~2 days. Changing this only affects revisions
1404
+ * written afterward — existing rows keep their original expiry.
1405
+ */
1406
+ retentionDays?: number;
1407
+ }
1388
1408
  type Role = 'reader' | 'editor' | 'admin';
1389
1409
  interface AuthContext {
1390
1410
  userId: string;
@@ -1415,6 +1435,45 @@ interface ListOptions {
1415
1435
  type CreatePostInput = Omit<Post, 'postId'> & {
1416
1436
  postId?: string;
1417
1437
  };
1438
+ /**
1439
+ * One in-memory snapshot of a Post at save time, read back from the
1440
+ * `PostHistory` table (written by the event-dispatcher Lambda on each
1441
+ * Post INSERT/MODIFY — see packages/backend/src/events/dispatcher.ts).
1442
+ *
1443
+ * `body` is already decoded from its AWSJSON wire form (the provider
1444
+ * runs `decodeAwsJson` before handing the row up), so it matches the
1445
+ * `Post['body']` shape for the declared `format`.
1446
+ */
1447
+ interface PostRevision {
1448
+ /** Deterministic id `${postId}#${revisedAt}` — unique per save. */
1449
+ postHistoryId: string;
1450
+ postId: string;
1451
+ /** ISO 8601 save time. Also the `byPost` GSI sort key (newest-first). */
1452
+ revisedAt: string;
1453
+ title?: string;
1454
+ slug?: string;
1455
+ excerpt?: string;
1456
+ format?: ContentFormat;
1457
+ body?: unknown;
1458
+ status?: PostStatus;
1459
+ publishedAt?: string;
1460
+ tags?: string[];
1461
+ metadata?: PostMetadata;
1462
+ }
1463
+ /** Pagination options for `listPostHistory`. */
1464
+ interface ListPostHistoryOptions {
1465
+ limit?: number;
1466
+ nextToken?: string;
1467
+ }
1468
+ /**
1469
+ * A page of revisions newest-first. `nextToken` feeds straight back into
1470
+ * `ListPostHistoryOptions.nextToken` for the next page; `undefined` means
1471
+ * no more rows.
1472
+ */
1473
+ interface PostRevisionConnection {
1474
+ items: PostRevision[];
1475
+ nextToken?: string;
1476
+ }
1418
1477
  interface PostsProvider {
1419
1478
  list(opts?: ListOptions): Promise<Post[]>;
1420
1479
  get(slug: string): Promise<Post | null>;
@@ -1422,6 +1481,7 @@ interface PostsProvider {
1422
1481
  create(data: CreatePostInput): Promise<Post>;
1423
1482
  update(postId: string, data: Partial<Post>): Promise<Post>;
1424
1483
  remove(postId: string): Promise<void>;
1484
+ listPostHistory(postId: string, options?: ListPostHistoryOptions): Promise<PostRevisionConnection>;
1425
1485
  }
1426
1486
  declare function setPostsProvider(p: PostsProvider): void;
1427
1487
  declare function hasPostsProvider(): boolean;
@@ -1431,6 +1491,13 @@ declare function getPostById(postId: string): Promise<Post | null>;
1431
1491
  declare function createPost(data: CreatePostInput): Promise<Post>;
1432
1492
  declare function updatePost(postId: string, data: Partial<Post>): Promise<Post>;
1433
1493
  declare function deletePost(postId: string): Promise<void>;
1494
+ /**
1495
+ * List a post's revision history, newest-first. Backed by the
1496
+ * `PostHistory` `byPost` GSI. Requires a configured provider (the dummy
1497
+ * fallback has no history) — returns an empty connection otherwise so
1498
+ * callers (e.g. the admin history panel) degrade gracefully.
1499
+ */
1500
+ declare function listPostHistory(postId: string, options?: ListPostHistoryOptions): Promise<PostRevisionConnection>;
1434
1501
 
1435
1502
  interface KvItem<T = unknown> {
1436
1503
  pk: string;
@@ -1693,4 +1760,4 @@ declare function pickDefaultEntrypoint(files: readonly {
1693
1760
 
1694
1761
  declare const VERSION = "0.0.1";
1695
1762
 
1696
- 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, PLUGIN_KEY_PATTERN, type Page, type PluginBooleanField, type PluginCapability, type PluginCodeField, type PluginEventHandler, type PluginHookResult, type PluginJsonField, type PluginMetadata, type PluginNumberField, type PluginPackageManifest, type PluginPublicRenderContext, type PluginRepeatableField, type PluginRepeatableSubField, type PluginRuntimeContext, type PluginSecretField, type PluginSelectField, type PluginSettingField, type PluginSettingsManifest, type PluginTextField, type PluginTextareaField, type PluginUninstallContext, type PluginUrlField, type Post, type PostIndexEventPayload, type PostIndexEventType, type PostMetadata, type PostStatus, type PostsProvider, type PublicBodyDescriptor, type PublicHeadDescriptor, type PublicPostBodyDescriptor, type PublicPostHtmlDescriptor, type PublicPostHtmlPosition, type Role, SITE_CONFIG_PK, type ScriptStrategy, 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, type TrustedPluginRuntimeContext, 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, isValidPluginKey, listPosts, listSiteSettings, mimeTypeFor, parseColorPair, parseLinkList, pickDefaultEntrypoint, resolveLocalized, resolvePluginSettings, resolveThemeValues, setKvStore, setPostsProvider, setSiteSetting, stringifyLinkList, stripCommonPrefix, themeSettingKey, unflattenSettings, updatePost, validateBundle, validateBundlePath, validatePluginSettingValue, validatePublicAssetKey, validateThemeValue };
1763
+ 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 HistoryConfig, type ImageDisplay, type KvItem, type KvStore, type LinkListItem, type ListOptions, type ListPostHistoryOptions, type LocalizedString, MAX_BUNDLE_BYTES, type Media, type MediaEventPayload, type MediaEventType, type MediaMetadata, type MediaProcessingDefaults, type OgImageConfig, type OgImageFont, type OgImageRenderContext, PLUGIN_KEY_PATTERN, type Page, type PluginBooleanField, type PluginCapability, type PluginCodeField, type PluginEventHandler, type PluginHookResult, type PluginJsonField, type PluginMetadata, type PluginNumberField, type PluginPackageManifest, type PluginPublicRenderContext, type PluginRepeatableField, type PluginRepeatableSubField, type PluginRuntimeContext, type PluginSecretField, type PluginSelectField, type PluginSettingField, type PluginSettingsManifest, type PluginTextField, type PluginTextareaField, type PluginUninstallContext, type PluginUrlField, type Post, type PostIndexEventPayload, type PostIndexEventType, type PostMetadata, type PostRevision, type PostRevisionConnection, type PostStatus, type PostsProvider, type PublicBodyDescriptor, type PublicHeadDescriptor, type PublicPostBodyDescriptor, type PublicPostHtmlDescriptor, type PublicPostHtmlPosition, type Role, SITE_CONFIG_PK, type ScriptStrategy, 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, type TrustedPluginRuntimeContext, 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, isValidPluginKey, listPostHistory, listPosts, listSiteSettings, mimeTypeFor, parseColorPair, parseLinkList, pickDefaultEntrypoint, resolveLocalized, resolvePluginSettings, resolveThemeValues, setKvStore, setPostsProvider, setSiteSetting, stringifyLinkList, stripCommonPrefix, themeSettingKey, unflattenSettings, updatePost, validateBundle, validateBundlePath, validatePluginSettingValue, validatePublicAssetKey, validateThemeValue };
package/dist/index.js CHANGED
@@ -83,6 +83,10 @@ async function deletePost(postId) {
83
83
  if (!provider) throw new Error("No posts provider configured. Call setPostsProvider() first.");
84
84
  return provider.remove(postId);
85
85
  }
86
+ async function listPostHistory(postId, options) {
87
+ if (!provider) return { items: [] };
88
+ return provider.listPostHistory(postId, options);
89
+ }
86
90
 
87
91
  // src/kv.ts
88
92
  var store = null;
@@ -794,6 +798,7 @@ export {
794
798
  hasPostsProvider,
795
799
  isTagListUrl,
796
800
  isValidPluginKey,
801
+ listPostHistory,
797
802
  listPosts,
798
803
  listSiteSettings,
799
804
  mimeTypeFor,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ampless",
3
- "version": "1.0.0-alpha.37",
3
+ "version": "1.0.0-alpha.38",
4
4
  "description": "Serverless CMS for AWS Amplify",
5
5
  "license": "MIT",
6
6
  "type": "module",