ampless 1.0.0-alpha.33 → 1.0.0-alpha.34
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.
|
@@ -563,6 +563,50 @@ React 19 はさらに、クライアントコンポーネントのレンダー
|
|
|
563
563
|
|
|
564
564
|
投稿単位の見える出力には `publicHtmlForPost` を使ってください(Phase 6d — 上の例と §6 の `PublicPostHtmlDescriptor` 参照)。runtime が post 本文の周囲の固定スロットにサーバーサイド HTML を出すので、hydration と競合しません。
|
|
565
565
|
|
|
566
|
+
---
|
|
567
|
+
|
|
568
|
+
## 6a. 予約投稿とコンテンツイベント
|
|
569
|
+
|
|
570
|
+
ampless は**予約投稿**をサポートしています。`status: 'published'` かつ `publishedAt` が未来の投稿は、その時刻まで公開読み出しから隠されます。`publishedAt` を過ぎると、サイトの自然なキャッシュ有効期限(デフォルト ≤ ~5 分)の範囲内で公開されます — 秒単位の正確なトリガーはありません。
|
|
571
|
+
|
|
572
|
+
### イベントは保存時に発火する(`publishedAt` のタイミングではない)
|
|
573
|
+
|
|
574
|
+
`content.published`(および `content.updated`)は DynamoDB Streams 経由で**投稿が保存されたとき**に emit されます。`publishedAt` が到来したときではありません。つまり、`content.published` に反応するプラグインは、投稿が未来日時の場合、**その投稿が公開される前**に実行されます。
|
|
575
|
+
|
|
576
|
+
現在の投稿一覧から公開アセットを再構築する trusted プラグイン(RSS、sitemap、JSON インデックスなど)にとってはこれは問題ありません — `listPublishedPosts()` が未来日時の投稿をすでに除外しているため、再生成されたアセットはその投稿が公開されるまでリストに含まれません。
|
|
577
|
+
|
|
578
|
+
一方、**外部通知プラグイン**(webhook、プッシュ通知、SNS 投稿など)には影響があります。投稿の URL が 404 を返しているまたはホームページにリダイレクトされている間に通知が配信されてしまいます。
|
|
579
|
+
|
|
580
|
+
### 推奨パターン: `publishedAt` でゲートする
|
|
581
|
+
|
|
582
|
+
ディスパッチの前に `event.payload.publishedAt` を確認します。投稿が未来日時の場合はスキップまたは保留します:
|
|
583
|
+
|
|
584
|
+
```ts
|
|
585
|
+
hooks: {
|
|
586
|
+
async 'content.published'(event, ctx) {
|
|
587
|
+
const { publishedAt } = event.payload
|
|
588
|
+
|
|
589
|
+
// 予約投稿には通知を送らない。イベントは保存時に発火するが、
|
|
590
|
+
// 投稿が公開されるのは publishedAt になってから。
|
|
591
|
+
if (publishedAt && new Date(publishedAt) > new Date()) {
|
|
592
|
+
return
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
// 投稿は今すぐ公開状態 — 通知しても安全。
|
|
596
|
+
await sendWebhook(event.payload, ctx)
|
|
597
|
+
},
|
|
598
|
+
}
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
イベントペイロード内の `publishedAt` は UTC ISO 8601 文字列(`...Z`)です。`Date.now()` と比較する前に `new Date()` またはお好みの日付ライブラリでパースしてください。
|
|
602
|
+
|
|
603
|
+
### 今後の対応
|
|
604
|
+
|
|
605
|
+
`content.published` の発火を保存時ではなく `publishedAt` のタイミングに合わせる機能 — EventBridge Scheduler または DynamoDB TTL トリガー Lambda によるスケジューラーコンポーネントが必要 — は計画中の機能強化です。現リリースのスコープには含まれていません。それまでの間は上記のパターンが通知プラグインにおける推奨ガードです。
|
|
606
|
+
|
|
607
|
+
オペレーター視点からの `publishedAt` セマンティクスの全体像は [`docs/scheduled-publishing.md`](https://github.com/heavymoons/ampless/blob/main/docs/scheduled-publishing.ja.md) を参照してください。
|
|
608
|
+
|
|
609
|
+
---
|
|
566
610
|
|
|
567
611
|
### CSP nonce(Phase 1 予約)
|
|
568
612
|
|
|
@@ -719,6 +719,72 @@ the example above and §6's `PublicPostHtmlDescriptor`). The runtime
|
|
|
719
719
|
emits server-side HTML at fixed slots around the post body, so
|
|
720
720
|
nothing races against hydration.
|
|
721
721
|
|
|
722
|
+
---
|
|
723
|
+
|
|
724
|
+
## 6a. Scheduled posts and content events
|
|
725
|
+
|
|
726
|
+
ampless supports **scheduled publishing**: a post with `status:
|
|
727
|
+
'published'` and a future `publishedAt` is hidden from all public
|
|
728
|
+
reads until that time. Once `publishedAt` arrives, the post becomes
|
|
729
|
+
visible within the site's natural cache window (≤ ~5 minutes by
|
|
730
|
+
default) — there is no exact-time trigger.
|
|
731
|
+
|
|
732
|
+
### Events fire at save time, not at `publishedAt`
|
|
733
|
+
|
|
734
|
+
`content.published` (and `content.updated`) are emitted via DynamoDB
|
|
735
|
+
Streams **when the post is saved**, not when `publishedAt` arrives.
|
|
736
|
+
This means a plugin that reacts to `content.published` will run
|
|
737
|
+
**before the post is publicly visible** when the post is future-dated.
|
|
738
|
+
|
|
739
|
+
For trusted plugins that rebuild public assets from the current post
|
|
740
|
+
list (RSS, sitemap, JSON indexes), this is harmless — `listPublishedPosts()`
|
|
741
|
+
already filters out future-dated posts, so the regenerated asset
|
|
742
|
+
simply omits the scheduled post until it goes live.
|
|
743
|
+
|
|
744
|
+
For **outbound-notification plugins** (webhook, push notification,
|
|
745
|
+
social post) the early fire matters: the notification will be
|
|
746
|
+
delivered to subscribers while the post URL still returns 404 or
|
|
747
|
+
redirects to the home page.
|
|
748
|
+
|
|
749
|
+
### Recommended pattern: gate on `publishedAt`
|
|
750
|
+
|
|
751
|
+
Check `event.payload.publishedAt` before dispatching. Skip or defer
|
|
752
|
+
when the post is future-dated:
|
|
753
|
+
|
|
754
|
+
```ts
|
|
755
|
+
hooks: {
|
|
756
|
+
async 'content.published'(event, ctx) {
|
|
757
|
+
const { publishedAt } = event.payload
|
|
758
|
+
|
|
759
|
+
// Skip notification for future-scheduled posts. The event fires
|
|
760
|
+
// at save time, but the post won't be public until publishedAt.
|
|
761
|
+
if (publishedAt && new Date(publishedAt) > new Date()) {
|
|
762
|
+
return
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
// Post is live now — safe to notify.
|
|
766
|
+
await sendWebhook(event.payload, ctx)
|
|
767
|
+
},
|
|
768
|
+
}
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
The `publishedAt` value in the event payload is a UTC ISO 8601 string
|
|
772
|
+
(`...Z`). Parse it with `new Date()` or your preferred date library
|
|
773
|
+
before comparing against `Date.now()`.
|
|
774
|
+
|
|
775
|
+
### Future work
|
|
776
|
+
|
|
777
|
+
Aligning event emission with the scheduled time — so `content.published`
|
|
778
|
+
fires at `publishedAt` rather than at save time — is a planned
|
|
779
|
+
enhancement. It requires a scheduler component (EventBridge Scheduler
|
|
780
|
+
or a DynamoDB TTL-triggered Lambda) and is not yet in scope for the
|
|
781
|
+
current release. Until then, the pattern above is the recommended
|
|
782
|
+
guard for notification plugins.
|
|
783
|
+
|
|
784
|
+
For a full description of `publishedAt` semantics from the operator's
|
|
785
|
+
perspective, see [`docs/scheduled-publishing.md`](https://github.com/heavymoons/ampless/blob/main/docs/scheduled-publishing.md).
|
|
786
|
+
|
|
787
|
+
---
|
|
722
788
|
|
|
723
789
|
### CSP nonce (Phase 1 reservation)
|
|
724
790
|
|