create-ampless 0.2.0-alpha.27 → 0.2.0-alpha.29

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.
@@ -1,7 +1,11 @@
1
1
  import { fileURLToPath } from 'node:url'
2
2
  import { dirname, resolve } from 'node:path'
3
3
  import { a, defineData, type ClientSchema } from '@aws-amplify/backend'
4
- import { amplessSchemaModels, defaultAuthorizationModes } from '@ampless/backend'
4
+ import {
5
+ amplessSchemaModels,
6
+ amplessSchemaAuthorization,
7
+ defaultAuthorizationModes,
8
+ } from '@ampless/backend'
5
9
  import { userAdmin } from '../functions/user-admin/resource.js'
6
10
  import { mcpHandler } from '../functions/mcp-handler/resource.js'
7
11
  import { customSchemaModels } from './resource.custom.js'
@@ -27,18 +31,22 @@ const resolverPaths = {
27
31
  listPostsByTag: resolve(__dirname, 'list-posts-by-tag.js'),
28
32
  }
29
33
 
30
- const schema = a.schema({
31
- ...amplessSchemaModels(a, {
32
- resolverPaths,
33
- userAdminFunction: userAdmin,
34
- // Grants the MCP Lambda IAM auth on Post / PostTag so the HTTP
35
- // transport can dispatch the post CRUD tools without sharing a
36
- // Cognito identity or API key. See `@ampless/backend` data/index.ts
37
- // for the exact authorization clause.
34
+ const schema = a
35
+ .schema({
36
+ ...amplessSchemaModels(a, {
37
+ resolverPaths,
38
+ userAdminFunction: userAdmin,
39
+ }),
40
+ ...customSchemaModels(a),
41
+ })
42
+ // Schema-level `.authorization()` is the only place resource auth is
43
+ // honoured in `@aws-amplify/data-schema` — model-level callbacks have
44
+ // `resource` destructured out of `allow`. The helper returns an empty
45
+ // array when no Lambda refs are supplied, so the schema stays
46
+ // unaffected if MCP is later removed.
47
+ .authorization((allow) => amplessSchemaAuthorization(allow, {
38
48
  mcpHandlerFunction: mcpHandler,
39
- }),
40
- ...customSchemaModels(a),
41
- })
49
+ }))
42
50
 
43
51
  export type Schema = ClientSchema<typeof schema>
44
52
  export const data = defineData({
@@ -27,7 +27,7 @@
27
27
  "@ampless/plugin-seo": "^0.2.0-alpha.6",
28
28
  "@ampless/plugin-webhook": "^0.2.0-alpha.6",
29
29
  "@ampless/admin": "^0.2.0-alpha.21",
30
- "@ampless/backend": "^0.2.0-alpha.11",
30
+ "@ampless/backend": "^0.2.0-alpha.12",
31
31
  "@ampless/runtime": "^0.2.0-alpha.9",
32
32
  "@digital-go-jp/tailwind-theme-plugin": "^0.3.4",
33
33
  "ampless": "^0.2.0-alpha.6",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ampless",
3
- "version": "0.2.0-alpha.27",
3
+ "version": "0.2.0-alpha.29",
4
4
  "description": "Create a new ampless project",
5
5
  "license": "MIT",
6
6
  "type": "module",