ampless 1.0.0-alpha.34 → 1.0.0-alpha.35
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.js +8 -0
- package/docs/plugin-author-guide.ja.md +15 -6
- package/docs/plugin-author-guide.md +16 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -224,6 +224,14 @@ function definePlugin(p) {
|
|
|
224
224
|
);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
+
if (p.trust_level === "privileged") {
|
|
228
|
+
const hasHooks = p.hooks && Object.keys(p.hooks).length > 0 || (p.capabilities?.includes("eventHooks") ?? false);
|
|
229
|
+
if (hasHooks) {
|
|
230
|
+
console.warn(
|
|
231
|
+
`[ampless] Plugin "${p.name}" declares trust_level: 'privileged' with event hooks, but no privileged Lambda is provisioned yet. Hooks will not execute. Sync render surfaces (publicHead / metadata / publicBodyForPost / etc.) work normally regardless of trust_level. See docs/architecture/08-plugin-architecture.md#trust-levels for the future plan.`
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
227
235
|
return p;
|
|
228
236
|
}
|
|
229
237
|
|
|
@@ -279,11 +279,20 @@ runtime がチェックする内容:
|
|
|
279
279
|
|
|
280
280
|
3 階層、選択基準は **イベントフック (hooks) が何を必要とするか** で決まります (sync サーフェスは IAM に触れない):
|
|
281
281
|
|
|
282
|
-
| 階層 | IAM | 用途 |
|
|
283
|
-
|
|
284
|
-
| `untrusted` | なし (SQS consume のみ) | head/body descriptor、webhook 配送、コンテンツ変換 |
|
|
285
|
-
| `trusted` | 投稿読み出し、`public/plugins/<instanceId ?? name>/...` への書き込み | RSS フィード、sitemap、計算済み JSON インデックス |
|
|
286
|
-
| `privileged` | 予約 | 将来: SES、secret、private S3 |
|
|
282
|
+
| 階層 | IAM | 今日動くもの | 用途 |
|
|
283
|
+
|---|---|---|---|
|
|
284
|
+
| `untrusted` | なし (SQS consume のみ) | 同期サーフェス + イベントフック | head/body descriptor、webhook 配送、コンテンツ変換 |
|
|
285
|
+
| `trusted` | 投稿読み出し、`public/plugins/<instanceId ?? name>/...` への書き込み | 同期サーフェス + イベントフック | RSS フィード、sitemap、計算済み JSON インデックス |
|
|
286
|
+
| `privileged` | 予約 | 同期サーフェスのみ — イベントフックはサイレントフィルタ(警告ログあり) | 将来: SES、secret、private S3 |
|
|
287
|
+
|
|
288
|
+
> **`privileged` プラグイン作者へ:** `trust_level: 'privileged'` とイベント
|
|
289
|
+
> `hooks` を宣言した場合、**現時点でフックは実行されません**。両 processor が
|
|
290
|
+
> privileged プラグインをフィルタアウトし、一致する SQS イベントごとに
|
|
291
|
+
> `console.warn` を出力するため、サイレントドロップは可視化されます。
|
|
292
|
+
> 同期サーフェス(`publicHead`、`publicBodyEnd`、`metadata`、`publicBodyForPost`、
|
|
293
|
+
> `publicHtmlForPost`)は `trust_level` に関わらず正常に動き、警告も出ません。
|
|
294
|
+
> privileged Lambda が用意された際、`'privileged'` を宣言済みのプラグインは
|
|
295
|
+
> 自動的に新しい tier を使えるようになります — コードの変更は不要です。
|
|
287
296
|
|
|
288
297
|
決め方の目安:
|
|
289
298
|
|
|
@@ -291,7 +300,7 @@ runtime がチェックする内容:
|
|
|
291
300
|
- **hooks から投稿を読みたい (publish 時にフィードを再生成等)** → `trusted`
|
|
292
301
|
- **`public/plugins/*` 以外への S3 PutObject や他の AWS API が必要** → 今はプラグインで ship せず、privileged 層を待つかプラグイン外で実装
|
|
293
302
|
|
|
294
|
-
trust level
|
|
303
|
+
trust level がズレているプラグインは「権限不足でサイレントに fail」または「不要に強い権限を持つ」のどちらか。階層を切り替えて再デプロイすれば直ります。
|
|
295
304
|
|
|
296
305
|
---
|
|
297
306
|
|
|
@@ -341,11 +341,22 @@ Three tiers, picked by what the plugin needs to do **inside
|
|
|
341
341
|
event hooks** (the sync surfaces — metadata, head, body — don't
|
|
342
342
|
touch IAM):
|
|
343
343
|
|
|
344
|
-
| Tier | IAM | Used by |
|
|
345
|
-
|
|
346
|
-
| `untrusted` | none (SQS consume only) | head/body descriptors, webhook delivery, content transforms |
|
|
347
|
-
| `trusted` | read posts, write `public/plugins/<instanceId ?? name>/...` | RSS feed, sitemap, computed JSON indexes |
|
|
348
|
-
| `privileged` | reserved | future: SES, secrets, private S3 |
|
|
344
|
+
| Tier | IAM | What runs today | Used by |
|
|
345
|
+
|---|---|---|---|
|
|
346
|
+
| `untrusted` | none (SQS consume only) | sync surfaces + event hooks | head/body descriptors, webhook delivery, content transforms |
|
|
347
|
+
| `trusted` | read posts, write `public/plugins/<instanceId ?? name>/...` | sync surfaces + event hooks | RSS feed, sitemap, computed JSON indexes |
|
|
348
|
+
| `privileged` | reserved | sync surfaces only — event hooks are silently filtered out (warning logged) | future: SES, secrets, private S3 |
|
|
349
|
+
|
|
350
|
+
> **Warning for `privileged` plugin authors:** If you declare
|
|
351
|
+
> `trust_level: 'privileged'` with event `hooks` today, **your hooks
|
|
352
|
+
> WILL NOT EXECUTE**. Both event processors filter out privileged
|
|
353
|
+
> plugins and emit a `console.warn` on every matching SQS event so
|
|
354
|
+
> the drop is visible. Sync render surfaces (`publicHead`,
|
|
355
|
+
> `publicBodyEnd`, `metadata`, `publicBodyForPost`, `publicHtmlForPost`)
|
|
356
|
+
> work normally regardless of `trust_level` and emit no warning.
|
|
357
|
+
> When the privileged Lambda provisioning PR lands, plugins that
|
|
358
|
+
> already declared `'privileged'` will automatically pick up the new
|
|
359
|
+
> tier — nothing needs to change in your code.
|
|
349
360
|
|
|
350
361
|
Rule of thumb:
|
|
351
362
|
|