create-ampless 1.0.0-alpha.66 → 1.0.0-alpha.69

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.
@@ -139,7 +139,7 @@ analyticsGa4Plugin({ instanceId: 'product' })
139
139
  | 階層 | IAM | 用途 |
140
140
  |---|---|---|
141
141
  | `untrusted` | なし (SQS consume のみ) | head/body descriptor、webhook 配送、コンテンツ変換 |
142
- | `trusted` | 投稿読み出し、`public/plugins/<name>/...` への書き込み | RSS フィード、sitemap、計算済み JSON インデックス |
142
+ | `trusted` | 投稿読み出し、`public/plugins/<instanceId ?? name>/...` への書き込み | RSS フィード、sitemap、計算済み JSON インデックス |
143
143
  | `privileged` | 予約 | 将来: SES、secret、private S3 |
144
144
 
145
145
  決め方の目安:
@@ -273,6 +273,26 @@ hooks: {
273
273
  }
274
274
  ```
275
275
 
276
+ ### `writePublicAsset`
277
+
278
+ 公開生成ファイルを書き出す trusted plugin は capability を宣言してください:
279
+
280
+ ```ts
281
+ capabilities: ['eventHooks', 'writePublicAsset']
282
+ ```
283
+
284
+ 同じ plugin が `metadata()` または `siteMetadata()` も実装する場合は、`metadata` も宣言します。この capability 名は両方の metadata 関数をまとめて表し、別個の `siteMetadata` capability はありません。
285
+
286
+ trusted processor は次の場所に書き込みます:
287
+
288
+ ```txt
289
+ public/plugins/<instanceId ?? name>/<key>
290
+ ```
291
+
292
+ `key` は allowlist `[A-Za-z0-9._/-]+` に一致する必要があります。それ以外(スペース、URL 予約文字 `#` `?` `&` `=` `+`、非 ASCII 文字 (`日本語.xml` 等)、空文字、絶対パス(`/` 始まり)、`.` / `..` path segment、backslash、制御文字、256 文字超)は S3 呼び出し前に拒否されます。`indexes/posts.json` のような nested path や `feed.v2.xml` のような複数 dot は許可されます。allowlist を厳しく絞っているのは、返却 URL と実 S3 key を byte 等しい文字列に保つため — URL 予約文字は S3 では生バイトとして通るが、URL を consumer が parse すると別 object を指す状態になる。user 由来の文字を key に入れたい場合は事前に sanitize (hash、slugify 等) してから `ctx.writePublicAsset()` を呼んでください。戻り値は書き込まれた object の public URL です。
293
+
294
+ 移行期間中、`capabilities` フィールドが無い plugin はそのまま動きます。`capabilities` を宣言しているのに `writePublicAsset` を省いた plugin は、実際に `ctx.writePublicAsset()` を呼んだ時に 1 回だけ warn します。
295
+
276
296
  ### ベストプラクティス
277
297
 
278
298
  - **冪等にする**。SQS は at-least-once 配送 — 同じイベントが 2 回 fire する可能性があります。同じ入力で同じ出力 (決定論的なフィード等) を生成するようにしてください
@@ -168,7 +168,7 @@ touch IAM):
168
168
  | Tier | IAM | Used by |
169
169
  |---|---|---|
170
170
  | `untrusted` | none (SQS consume only) | head/body descriptors, webhook delivery, content transforms |
171
- | `trusted` | read posts, write `public/plugins/<name>/...` | RSS feed, sitemap, computed JSON indexes |
171
+ | `trusted` | read posts, write `public/plugins/<instanceId ?? name>/...` | RSS feed, sitemap, computed JSON indexes |
172
172
  | `privileged` | reserved | future: SES, secrets, private S3 |
173
173
 
174
174
  Rule of thumb:
@@ -332,6 +332,44 @@ hooks: {
332
332
  }
333
333
  ```
334
334
 
335
+ ### `writePublicAsset`
336
+
337
+ Trusted plugins that write public generated files should declare the
338
+ capability:
339
+
340
+ ```ts
341
+ capabilities: ['eventHooks', 'writePublicAsset']
342
+ ```
343
+
344
+ If the same plugin implements `metadata()` or `siteMetadata()`, also
345
+ declare `metadata`. That capability name covers both metadata
346
+ functions; there is no separate `siteMetadata` capability.
347
+
348
+ The trusted processor writes under:
349
+
350
+ ```txt
351
+ public/plugins/<instanceId ?? name>/<key>
352
+ ```
353
+
354
+ `key` must match the allowlist `[A-Za-z0-9._/-]+`. Anything outside
355
+ that — spaces, URL-reserved characters (`#`, `?`, `&`, `=`, `+`),
356
+ non-ASCII (`日本語.xml`), empty strings, absolute paths (leading `/`),
357
+ `.` / `..` path segments, backslashes, control characters, or keys
358
+ over 256 characters — is rejected before S3 is called. Nested paths
359
+ such as `indexes/posts.json` and dotted extensions such as
360
+ `feed.v2.xml` are allowed. The allowlist is deliberately tight so
361
+ the returned public URL and the underlying S3 key are byte-identical
362
+ strings; URL-reserved characters would survive S3 but reshape the URL
363
+ when a consumer parses it. If you need to include user-supplied
364
+ characters in a key, sanitize first (e.g. hash, slugify) before
365
+ calling `ctx.writePublicAsset()`. The return value is the public URL
366
+ for the written object.
367
+
368
+ During the migration period, plugins with no `capabilities` field
369
+ keep working. Plugins that do declare `capabilities` but omit
370
+ `writePublicAsset` warn once when they actually call
371
+ `ctx.writePublicAsset()`.
372
+
335
373
  ### Best practices
336
374
 
337
375
  - **Be idempotent.** SQS delivery is at-least-once: the same event
@@ -25,18 +25,18 @@
25
25
  "@tiptap/pm": "^3.23.6",
26
26
  "@tiptap/react": "^3.23.6",
27
27
  "@tiptap/starter-kit": "^3.23.6",
28
- "@ampless/plugin-analytics-ga4": "^0.2.0-alpha.1",
29
- "@ampless/plugin-gtm": "^0.1.1-alpha.0",
30
- "@ampless/plugin-og-image": "^0.2.0-alpha.18",
31
- "@ampless/plugin-plausible": "^0.1.1-alpha.0",
32
- "@ampless/plugin-rss": "^0.2.0-alpha.18",
33
- "@ampless/plugin-seo": "^0.2.0-alpha.18",
34
- "@ampless/plugin-webhook": "^0.2.0-alpha.18",
35
- "@ampless/admin": "^1.0.0-alpha.42",
36
- "@ampless/backend": "^1.0.0-alpha.33",
37
- "@ampless/runtime": "^1.0.0-alpha.24",
28
+ "@ampless/plugin-analytics-ga4": "^0.2.0-alpha.3",
29
+ "@ampless/plugin-gtm": "^0.1.1-alpha.2",
30
+ "@ampless/plugin-og-image": "^0.2.0-alpha.20",
31
+ "@ampless/plugin-plausible": "^0.1.1-alpha.2",
32
+ "@ampless/plugin-rss": "^0.2.0-alpha.20",
33
+ "@ampless/plugin-seo": "^0.2.0-alpha.20",
34
+ "@ampless/plugin-webhook": "^0.2.0-alpha.20",
35
+ "@ampless/admin": "^1.0.0-alpha.44",
36
+ "@ampless/backend": "^1.0.0-alpha.35",
37
+ "@ampless/runtime": "^1.0.0-alpha.26",
38
38
  "@digital-go-jp/tailwind-theme-plugin": "^0.3.4",
39
- "ampless": "^1.0.0-alpha.18",
39
+ "ampless": "^1.0.0-alpha.20",
40
40
  "aws-amplify": "^6.17.0",
41
41
  "class-variance-authority": "^0.7.1",
42
42
  "clsx": "^2.1.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ampless",
3
- "version": "1.0.0-alpha.66",
3
+ "version": "1.0.0-alpha.69",
4
4
  "description": "Create a new ampless project",
5
5
  "license": "MIT",
6
6
  "type": "module",