@ampless/backend 0.2.0-alpha.6 → 0.2.0-alpha.8

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.
Files changed (3) hide show
  1. package/README.ja.md +130 -0
  2. package/README.md +3 -0
  3. package/package.json +2 -2
package/README.ja.md ADDED
@@ -0,0 +1,130 @@
1
+ > English: [README.md](./README.md)
2
+ >
3
+
4
+ # @ampless/backend
5
+
6
+ [ampless](https://github.com/heavymoons/ampless) 向け Amplify Gen 2 バックエンドファクトリー。IAM / SQS / DynamoDB ストリームの配線、認証 / データ / ストレージの定義、およびすべてのイベント処理 Lambda を `defineAmplessBackend(...)` ひとつのファクトリーにまとめます。
7
+
8
+ > **プレリリース / アルファ版。** v1.0 まではマイナーバージョンでも破壊的変更が入る可能性があります。
9
+
10
+ テンプレートから切り出すことで、スキャフォールダーを再実行せずに `npm update @ampless/backend` でアップデートできます。バックエンドのバグ修正やインフラ改善はパッケージ経由で届きます。ユーザー側の `amplify/` ツリーは、ファクトリーを組み合わせる 1〜5 行のシェルだけで済みます。
11
+
12
+ ## インストール
13
+
14
+ ```bash
15
+ npm install @ampless/backend@alpha ampless@alpha
16
+ ```
17
+
18
+ ピア依存: `@aws-amplify/backend`(^1)、`aws-cdk-lib`(^2)。CLI スキャフォールダーがテンプレートの `package.json` に互換バージョンをピン留めします。
19
+
20
+ ## 使い方
21
+
22
+ ### `amplify/backend.ts`
23
+
24
+ ```ts
25
+ import { defineAmplessBackend } from '@ampless/backend'
26
+ import { auth } from './auth/resource'
27
+ import { data } from './data/resource'
28
+ import { storage } from './storage/resource'
29
+ import { postConfirmation } from './auth/post-confirmation/resource'
30
+ import { eventDispatcher } from './events/dispatcher/resource'
31
+ import { processorTrusted } from './events/processor-trusted/resource'
32
+ import { processorUntrusted } from './events/processor-untrusted/resource'
33
+ import { apiKeyRenewer } from './functions/api-key-renewer/resource'
34
+
35
+ export default defineAmplessBackend({
36
+ auth, data, storage, postConfirmation,
37
+ eventDispatcher, processorTrusted, processorUntrusted, apiKeyRenewer,
38
+ })
39
+ ```
40
+
41
+ ### `amplify/auth/resource.ts`
42
+
43
+ ```ts
44
+ import { defineAuth } from '@aws-amplify/backend'
45
+ import { amplessAuthConfig } from '@ampless/backend'
46
+ import { postConfirmation } from './post-confirmation/resource'
47
+
48
+ export const auth = defineAuth(amplessAuthConfig({ postConfirmation }))
49
+ ```
50
+
51
+ > `defineAuth` は `amplify/auth/resource.ts` 自体に記述する必要があります。Amplify Gen 2 のインポートパス検証機能が `defineAuth` / `defineData` / `defineStorage` の呼び出し元を検査し、他のファイル(`node_modules/@ampless/backend/...` 配下のラッパーを含む)から呼び出された場合に `Amplify Auth must be defined in amplify/auth/resource.ts` というエラーを投げます。`amplessAuthConfig` は props オブジェクトを返すため、ampless のデフォルト設定を失わずにこのファイルで `defineAuth(...)` を呼び出せます。
52
+
53
+ ### `amplify/data/resource.ts`
54
+
55
+ ```ts
56
+ import { a, defineData, type ClientSchema } from '@aws-amplify/backend'
57
+ import { amplessSchemaModels, defaultAuthorizationModes } from '@ampless/backend'
58
+
59
+ const schema = a.schema({
60
+ ...amplessSchemaModels(a),
61
+ // カスタムモデルをここに追加 — 組み込みモデルと同居します:
62
+ // MyCustomModel: a.model({ ... }).authorization((allow) => [...]),
63
+ })
64
+
65
+ export type Schema = ClientSchema<typeof schema>
66
+ export const data = defineData({ schema, authorizationModes: defaultAuthorizationModes })
67
+ ```
68
+
69
+ 3 つの AppSync JS リゾルバーファイル(`list-published-posts.js`、`get-published-post.js`、`list-posts-by-tag.js`)はテンプレート内に残ります — AppSync がリゾルバーの `entry` パスを CDK synth 時に `defineData` を呼び出すファイルからの相対パスで解決するため、pnpm でシンボリックリンクされた `node_modules` パスは解決を通過できません。`amplify/data/` 以外の場所に移動する場合は、`amplessSchemaModels(a, { resolverPaths })` で新しいパスを渡してください。
70
+
71
+ ### `amplify/storage/resource.ts`
72
+
73
+ ```ts
74
+ import { defineStorage } from '@aws-amplify/backend'
75
+ import { amplessStorageConfig } from '@ampless/backend'
76
+ export const storage = defineStorage(amplessStorageConfig())
77
+ ```
78
+
79
+ > 認証と同じインポートパス制約があります — `defineStorage` はこのファイルから直接呼び出す必要があります。`amplessStorageConfig` は props オブジェクトを返します。
80
+
81
+ ### Lambda 薄型シェル
82
+
83
+ `amplify/auth/`、`amplify/events/`、`amplify/functions/` 内の各ハンドラーファイルは 1〜3 行の re-export になります。Amplify の esbuild がこのパッケージへのインポートを追跡し、実際のハンドラーコードを Lambda アーティファクトにバンドルします。
84
+
85
+ ```ts
86
+ // amplify/auth/post-confirmation/handler.ts
87
+ export { handler } from '@ampless/backend/auth/post-confirmation'
88
+
89
+ // amplify/events/dispatcher/handler.ts
90
+ export { handler } from '@ampless/backend/events/dispatcher'
91
+
92
+ // amplify/events/processor-trusted/handler.ts
93
+ import config from '../../../cms.config'
94
+ import { createProcessorTrustedHandler } from '@ampless/backend/events/processor-trusted'
95
+ export const handler = createProcessorTrustedHandler({
96
+ plugins: config.plugins,
97
+ site: config.site,
98
+ })
99
+
100
+ // amplify/events/processor-untrusted/handler.ts
101
+ import config from '../../../cms.config'
102
+ import { createProcessorUntrustedHandler } from '@ampless/backend/events/processor-untrusted'
103
+ export const handler = createProcessorUntrustedHandler({
104
+ plugins: config.plugins,
105
+ site: config.site,
106
+ })
107
+
108
+ // amplify/functions/api-key-renewer/handler.ts
109
+ export { handler } from '@ampless/backend/functions/api-key-renewer'
110
+ ```
111
+
112
+ ## サブパス
113
+
114
+ - `@ampless/backend` — `defineAmplessBackend`、`amplessAuthConfig`、`amplessStorageConfig`、`amplessSchemaModels`、`extendAmplessSchema`、`defaultAuthorizationModes`
115
+ - `@ampless/backend/auth/post-confirmation` — Lambda ハンドラー
116
+ - `@ampless/backend/events/dispatcher` — Lambda ハンドラー
117
+ - `@ampless/backend/events/processor-trusted` — `createProcessorTrustedHandler({ plugins, site })`
118
+ - `@ampless/backend/events/processor-untrusted` — `createProcessorUntrustedHandler({ plugins, site })`
119
+ - `@ampless/backend/functions/api-key-renewer` — Lambda ハンドラー
120
+
121
+ ## テンプレートに残るもの
122
+
123
+ - `amplify/data/*.js` — AppSync JS リゾルバー(ファイルパス制約のため)。
124
+ - すべての `resource.ts` と `handler.ts` — 薄型シェルですが、Amplify の CDK synth がユーザー側で解決する `entry: './handler.ts'` パスを保持しています。
125
+ - `cms.config.ts` と `themes-registry.ts` — ユーザーが所有するカスタマイズサーフェス。
126
+ - `templates/<theme>/` 以下のテーマコンポーネント — ユーザーが所有。
127
+
128
+ ## ライセンス
129
+
130
+ MIT
package/README.md CHANGED
@@ -1,3 +1,6 @@
1
+ > 日本語版: [README.ja.md](./README.ja.md)
2
+ >
3
+
1
4
  # @ampless/backend
2
5
 
3
6
  Amplify Gen 2 backend factories for [ampless](https://github.com/heavymoons/ampless). Bundles the IAM / SQS / DynamoDB-stream wiring, the auth / data / storage definitions, and every event-processing Lambda behind one `defineAmplessBackend(...)` factory.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampless/backend",
3
- "version": "0.2.0-alpha.6",
3
+ "version": "0.2.0-alpha.8",
4
4
  "description": "Amplify Gen 2 backend factories for ampless: auth, data, storage, event processors, API key renewer",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -56,7 +56,7 @@
56
56
  "@aws-sdk/client-sqs": "^3.717.0",
57
57
  "@aws-sdk/lib-dynamodb": "^3.717.0",
58
58
  "@aws-sdk/util-dynamodb": "^3.717.0",
59
- "ampless": "0.2.0-alpha.4"
59
+ "ampless": "0.2.0-alpha.6"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "@aws-amplify/backend": "^1",