create-ampless 1.0.0-alpha.60 → 1.0.0-alpha.62

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 CHANGED
@@ -1756,7 +1756,8 @@ var AMPLESS_PACKAGES = /* @__PURE__ */ new Set([
1756
1756
  "@ampless/plugin-seo",
1757
1757
  "@ampless/plugin-rss",
1758
1758
  "@ampless/plugin-webhook",
1759
- "@ampless/plugin-og-image"
1759
+ "@ampless/plugin-og-image",
1760
+ "@ampless/plugin-analytics-ga4"
1760
1761
  ]);
1761
1762
  var AMPLESS_MANAGED_SCRIPTS = /* @__PURE__ */ new Set([
1762
1763
  "sandbox",
@@ -0,0 +1,45 @@
1
+ import { util } from '@aws-appsync/utils'
2
+
3
+ // AppSync JS resolver: returns a single Media row by S3 key.
4
+ //
5
+ // Reads the Media table's `bySrc` GSI: PK = src. The src is the full
6
+ // S3 key (`public/media/...`) and is unique across the table (uploads
7
+ // use a timestamp-prefixed naming scheme), so this is an O(1) PK
8
+ // Query with `limit: 1` — no scan, no filter.
9
+ //
10
+ // Returns null when no row matches (orphan / legacy assets); the
11
+ // caller (the `/api/media/...` route handler) falls back to an
12
+ // Amplify SSR HEAD via `getProperties` in that case.
13
+ //
14
+ // Authorisation is enforced by AppSync (`allow.publicApiKey()` on
15
+ // the schema declaration). The resolver itself only encodes the
16
+ // partition condition.
17
+ export function request(ctx) {
18
+ const src = ctx.args.src
19
+ return {
20
+ operation: 'Query',
21
+ index: 'bySrc',
22
+ query: {
23
+ expression: '#src = :src',
24
+ expressionNames: { '#src': 'src' },
25
+ expressionValues: util.dynamodb.toMapValues({ ':src': src }),
26
+ },
27
+ limit: 1,
28
+ }
29
+ }
30
+
31
+ export function response(ctx) {
32
+ if (ctx.error) util.error(ctx.error.message, ctx.error.type)
33
+ const items = ctx.result.items ?? []
34
+ if (items.length === 0) return null
35
+ const item = items[0]
36
+ // Project explicitly onto the PublicMedia shape — drop mediaId /
37
+ // delivery / anything else that might be added to the Media model
38
+ // later so guests never see fields they shouldn't.
39
+ return {
40
+ src: item.src,
41
+ size: item.size ?? null,
42
+ mimeType: item.mimeType ?? null,
43
+ metadata: item.metadata ?? null,
44
+ }
45
+ }
@@ -20,8 +20,9 @@ import { customSchemaModels } from './resource.custom.js'
20
20
  const __dirname = dirname(fileURLToPath(import.meta.url))
21
21
 
22
22
  // Ampless's built-in models (Post / Page / Media / Taxonomy / PostTag /
23
- // KvStore) plus the three public-read custom queries
24
- // (listPublishedPosts / getPublishedPost / listPostsByTag).
23
+ // KvStore) plus the public-read custom queries
24
+ // (listPublishedPosts / getPublishedPost / listPostsByTag /
25
+ // getMediaBySrc).
25
26
  //
26
27
  // Add project-specific models in `amplify/data/resource.custom.ts` —
27
28
  // that file is never overwritten by `create-ampless upgrade`.
@@ -29,6 +30,7 @@ const resolverPaths = {
29
30
  listPublishedPosts: resolve(__dirname, 'list-published-posts.js'),
30
31
  getPublishedPost: resolve(__dirname, 'get-published-post.js'),
31
32
  listPostsByTag: resolve(__dirname, 'list-posts-by-tag.js'),
33
+ getMediaBySrc: resolve(__dirname, 'get-media-by-src.js'),
32
34
  }
33
35
 
34
36
  const schema = a
@@ -45,6 +45,12 @@ export default async function RootLayout({ children }: { children: React.ReactNo
45
45
  against the static defaults. Validated values only — see
46
46
  ampless `validateThemeValue`. */}
47
47
  {themeCss && <style dangerouslySetInnerHTML={{ __html: themeCss }} />}
48
+ {/* Descriptor-based plugin head injection (Phase 1). Each
49
+ active plugin's `publicHead()` runs validation here; the
50
+ output is a `<Fragment>` of `<script>` / `<meta>` / `<link>`
51
+ / `<noscript>` elements. Placed after the theme style so
52
+ plugin-emitted overrides win on the rare collision. */}
53
+ {ampless.publicHead()}
48
54
  </head>
49
55
  {/* `data-theme` selects which theme's `tokens.css` block matches.
50
56
  The active theme is resolved from `theme.active` site setting,
@@ -55,6 +61,10 @@ export default async function RootLayout({ children }: { children: React.ReactNo
55
61
  {children}
56
62
  </I18nProvider>
57
63
  </Providers>
64
+ {/* Descriptor-based body-end injection (Phase 1). GTM
65
+ no-script iframe / chat widgets / analytics tail snippets
66
+ land here. */}
67
+ {ampless.publicBodyEnd()}
58
68
  </body>
59
69
  </html>
60
70
  )
@@ -25,15 +25,15 @@
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-og-image": "^0.2.0-alpha.15",
29
- "@ampless/plugin-rss": "^0.2.0-alpha.15",
30
- "@ampless/plugin-seo": "^0.2.0-alpha.15",
31
- "@ampless/plugin-webhook": "^0.2.0-alpha.15",
32
- "@ampless/admin": "^1.0.0-alpha.39",
33
- "@ampless/backend": "^1.0.0-alpha.30",
34
- "@ampless/runtime": "^1.0.0-alpha.21",
28
+ "@ampless/plugin-og-image": "^0.2.0-alpha.17",
29
+ "@ampless/plugin-rss": "^0.2.0-alpha.17",
30
+ "@ampless/plugin-seo": "^0.2.0-alpha.17",
31
+ "@ampless/plugin-webhook": "^0.2.0-alpha.17",
32
+ "@ampless/admin": "^1.0.0-alpha.41",
33
+ "@ampless/backend": "^1.0.0-alpha.32",
34
+ "@ampless/runtime": "^1.0.0-alpha.23",
35
35
  "@digital-go-jp/tailwind-theme-plugin": "^0.3.4",
36
- "ampless": "^1.0.0-alpha.15",
36
+ "ampless": "^1.0.0-alpha.17",
37
37
  "aws-amplify": "^6.17.0",
38
38
  "class-variance-authority": "^0.7.1",
39
39
  "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.60",
3
+ "version": "1.0.0-alpha.62",
4
4
  "description": "Create a new ampless project",
5
5
  "license": "MIT",
6
6
  "type": "module",