create-skybridge 0.0.0-dev.ecfdeac → 0.0.0-dev.ed29eee

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 (87) hide show
  1. package/dist/index.js +52 -26
  2. package/package.json +4 -4
  3. package/templates/blank/Dockerfile +2 -2
  4. package/templates/blank/node_modules/.bin/alpic +2 -2
  5. package/templates/blank/node_modules/.bin/tsc +2 -2
  6. package/templates/blank/node_modules/.bin/tsserver +2 -2
  7. package/templates/blank/node_modules/.bin/tsx +2 -2
  8. package/templates/blank/node_modules/.bin/vite +2 -2
  9. package/templates/blank/package.json +8 -8
  10. package/templates/blank/vite.config.ts +6 -0
  11. package/templates/demo/Dockerfile +2 -2
  12. package/templates/demo/node_modules/.bin/alpic +2 -2
  13. package/templates/demo/node_modules/.bin/tsc +2 -2
  14. package/templates/demo/node_modules/.bin/tsserver +2 -2
  15. package/templates/demo/node_modules/.bin/tsx +2 -2
  16. package/templates/demo/node_modules/.bin/vite +2 -2
  17. package/templates/demo/package.json +17 -17
  18. package/templates/demo/vite.config.ts +6 -0
  19. package/templates/ecom/.dockerignore +4 -0
  20. package/templates/ecom/.env.template +7 -0
  21. package/templates/ecom/.ladle/components.tsx +26 -0
  22. package/templates/ecom/.ladle/config.mjs +11 -0
  23. package/templates/ecom/.ladle/vite.config.ts +11 -0
  24. package/templates/ecom/AGENTS.md +2 -0
  25. package/templates/ecom/Dockerfile +53 -0
  26. package/templates/ecom/README.md +92 -0
  27. package/templates/ecom/_gitignore +9 -0
  28. package/templates/ecom/alpic.json +3 -0
  29. package/templates/ecom/node_modules/.bin/alpic +21 -0
  30. package/templates/ecom/node_modules/.bin/ladle +21 -0
  31. package/templates/ecom/node_modules/.bin/sb +21 -0
  32. package/templates/ecom/node_modules/.bin/skybridge +21 -0
  33. package/templates/ecom/node_modules/.bin/tsc +21 -0
  34. package/templates/ecom/node_modules/.bin/tsserver +21 -0
  35. package/templates/ecom/node_modules/.bin/tsx +21 -0
  36. package/templates/ecom/node_modules/.bin/vite +21 -0
  37. package/templates/ecom/package.json +41 -0
  38. package/templates/ecom/src/catalog/index.ts +19 -0
  39. package/templates/ecom/src/catalog/mock.ts +134 -0
  40. package/templates/ecom/src/catalog/shopify.ts +264 -0
  41. package/templates/ecom/src/components/chip.css.ts +63 -0
  42. package/templates/ecom/src/components/chip.stories.tsx +27 -0
  43. package/templates/ecom/src/components/chip.tsx +49 -0
  44. package/templates/ecom/src/components/empty-state.stories.tsx +3 -0
  45. package/templates/ecom/src/components/empty-state.tsx +12 -0
  46. package/templates/ecom/src/components/expandable-text.css.ts +49 -0
  47. package/templates/ecom/src/components/expandable-text.stories.tsx +20 -0
  48. package/templates/ecom/src/components/expandable-text.tsx +53 -0
  49. package/templates/ecom/src/components/image-gallery.css.ts +172 -0
  50. package/templates/ecom/src/components/image-gallery.stories.tsx +30 -0
  51. package/templates/ecom/src/components/image-gallery.tsx +163 -0
  52. package/templates/ecom/src/components/product-card.css.ts +159 -0
  53. package/templates/ecom/src/components/product-card.stories.tsx +58 -0
  54. package/templates/ecom/src/components/product-card.tsx +102 -0
  55. package/templates/ecom/src/components/product-carousel.css.ts +134 -0
  56. package/templates/ecom/src/components/product-carousel.stories.tsx +64 -0
  57. package/templates/ecom/src/components/product-carousel.tsx +202 -0
  58. package/templates/ecom/src/components/variant-picker.css.ts +27 -0
  59. package/templates/ecom/src/components/variant-picker.stories.tsx +67 -0
  60. package/templates/ecom/src/components/variant-picker.tsx +70 -0
  61. package/templates/ecom/src/components/view-frame.css.ts +22 -0
  62. package/templates/ecom/src/components/view-frame.tsx +27 -0
  63. package/templates/ecom/src/config.ts +12 -0
  64. package/templates/ecom/src/design/contract.css.ts +39 -0
  65. package/templates/ecom/src/design/fonts.css +15 -0
  66. package/templates/ecom/src/design/primitives.css.ts +101 -0
  67. package/templates/ecom/src/design/recipes/typography.css.ts +75 -0
  68. package/templates/ecom/src/design/sprinkles.css.ts +128 -0
  69. package/templates/ecom/src/design/themes/dark.css.ts +36 -0
  70. package/templates/ecom/src/design/themes/light.css.ts +36 -0
  71. package/templates/ecom/src/design/tokens.ts +8 -0
  72. package/templates/ecom/src/helpers.ts +4 -0
  73. package/templates/ecom/src/i18n.ts +35 -0
  74. package/templates/ecom/src/index.css +9 -0
  75. package/templates/ecom/src/lib/cx.ts +9 -0
  76. package/templates/ecom/src/lib/format.ts +9 -0
  77. package/templates/ecom/src/lib/variants.ts +150 -0
  78. package/templates/ecom/src/server.ts +43 -0
  79. package/templates/ecom/src/tools/render-carousel.ts +161 -0
  80. package/templates/ecom/src/tools/search-products.ts +196 -0
  81. package/templates/ecom/src/types.ts +87 -0
  82. package/templates/ecom/src/views/carousel/detail/detail.css.ts +115 -0
  83. package/templates/ecom/src/views/carousel/detail/detail.stories.tsx +133 -0
  84. package/templates/ecom/src/views/carousel/detail/index.tsx +254 -0
  85. package/templates/ecom/src/views/carousel/index.tsx +233 -0
  86. package/templates/ecom/tsconfig.json +11 -0
  87. package/templates/ecom/vite.config.ts +8 -0
@@ -0,0 +1,92 @@
1
+ # Skybridge Boilerplate
2
+
3
+ A minimal TypeScript boilerplate for building MCP and ChatGPT Apps with the [Skybridge](https://docs.skybridge.tech) framework.
4
+
5
+ ## Getting Started
6
+
7
+ ### Prerequisites
8
+
9
+ - Node.js 24+
10
+
11
+ ### Local Development
12
+
13
+ #### 1. Install
14
+
15
+ ```bash
16
+ npm install
17
+ # or
18
+ pnpm install
19
+ # or
20
+ bun install
21
+ # or
22
+ deno install
23
+ # or
24
+ yarn install
25
+ ```
26
+
27
+ #### 2. Start your local server
28
+
29
+ Run the development server from the root directory:
30
+
31
+ ```bash
32
+ npm run dev
33
+ # or
34
+ pnpm dev
35
+ # or
36
+ bun dev
37
+ # or
38
+ deno task dev
39
+ # or
40
+ yarn dev
41
+ ```
42
+
43
+ This command starts:
44
+ - Your MCP server at `http://localhost:3000/mcp`.
45
+ - Skybridge DevTools UI at `http://localhost:3000`.
46
+
47
+ #### 3. Project structure
48
+
49
+ ```
50
+ ├── src/
51
+ │ ├── server.ts # Server entry point
52
+ │ └── helpers.ts # Shared utilities
53
+ ├── vite.config.ts
54
+ ├── alpic.json # Deployment config
55
+ └── package.json
56
+ ```
57
+
58
+ ### Create your first view
59
+
60
+ #### 1. Add a new view
61
+
62
+ - Register a tool in `src/server.ts` with a unique name (e.g., `my-view`) using [`registerTool`](https://docs.skybridge.tech/api-reference/register-tool) and a `view` config.
63
+ - Create a matching React component at `src/views/my-view.tsx`. **The file name must match the view name exactly**.
64
+
65
+ #### 2. Edit views with Hot Module Replacement (HMR)
66
+
67
+ Edit and save components in `src/views/` — changes will appear instantly inside your App.
68
+
69
+ #### 3. Edit server code
70
+
71
+ Modify files in `src/` and refresh the tool list with your MCP Client to see the changes.
72
+
73
+ ### Testing your App
74
+
75
+ You can test your app locally by using our DevTools UI on `http://localhost:3000` while running the `dev` command.
76
+
77
+ To connect your app with web clients like ChatGPT or Claude, expose your server on the internet by adding the `--tunnel` flag.
78
+ By enabling the tunnel, you'll also be able to access a playground to chat with your app and a real LLM. Learn more by reading the [test guide](https://docs.skybridge.tech/quickstart/test-your-app).
79
+
80
+
81
+ ## Deploy to Production
82
+
83
+ Skybridge is infrastructure vendor agnostic, and your app can be deployed on any cloud platform supporting MCP.
84
+
85
+ The simplest way to deploy your app is by running the `deploy` command, which will push your MCP server to the [Alpic](https://alpic.ai/) cloud for free.
86
+
87
+ ## Resources
88
+ - [Skybridge Documentation](https://docs.skybridge.tech/)
89
+ - [Apps SDK Documentation](https://developers.openai.com/apps-sdk)
90
+ - [MCP Apps Documentation](https://github.com/modelcontextprotocol/ext-apps/tree/main)
91
+ - [Model Context Protocol Documentation](https://modelcontextprotocol.io/)
92
+ - [Alpic Documentation](https://docs.alpic.ai/)
@@ -0,0 +1,9 @@
1
+ node_modules/
2
+ dist/
3
+ build/
4
+ .env*
5
+ !.env.template
6
+ .DS_store
7
+ *.tsbuildinfo
8
+ .skybridge/
9
+ .vercel/
@@ -0,0 +1,3 @@
1
+ {
2
+ "$schema": "https://assets.alpic.ai/alpic.json"
3
+ }
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/alpic@1.157.0_@opentelemetry+api@1.9.1_@opentelemetry+core@2.9.0_@opentelemetry+api@1.9_8f13b9696a5fc8688953a3b2ccd28385/node_modules/alpic/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/alpic@1.157.0_@opentelemetry+api@1.9.1_@opentelemetry+core@2.9.0_@opentelemetry+api@1.9_8f13b9696a5fc8688953a3b2ccd28385/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/alpic@1.157.0_@opentelemetry+api@1.9.1_@opentelemetry+core@2.9.0_@opentelemetry+api@1.9_8f13b9696a5fc8688953a3b2ccd28385/node_modules/alpic/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/alpic@1.157.0_@opentelemetry+api@1.9.1_@opentelemetry+core@2.9.0_@opentelemetry+api@1.9_8f13b9696a5fc8688953a3b2ccd28385/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../alpic/bin/run.js" "$@"
19
+ else
20
+ exec node "$basedir/../alpic/bin/run.js" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/@ladle+react@5.1.1_@types+node@24.13.3_@types+react@19.2.17_jiti@2.7.0_lightningcss@1.3_8c0d7eb4f29a667fc68ef4c081ca0a73/node_modules/@ladle/react/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/@ladle+react@5.1.1_@types+node@24.13.3_@types+react@19.2.17_jiti@2.7.0_lightningcss@1.3_8c0d7eb4f29a667fc68ef4c081ca0a73/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/@ladle+react@5.1.1_@types+node@24.13.3_@types+react@19.2.17_jiti@2.7.0_lightningcss@1.3_8c0d7eb4f29a667fc68ef4c081ca0a73/node_modules/@ladle/react/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/@ladle+react@5.1.1_@types+node@24.13.3_@types+react@19.2.17_jiti@2.7.0_lightningcss@1.3_8c0d7eb4f29a667fc68ef4c081ca0a73/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../@ladle/react/lib/cli/cli.js" "$@"
19
+ else
20
+ exec node "$basedir/../@ladle/react/lib/cli/cli.js" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../skybridge/bin/run.js" "$@"
19
+ else
20
+ exec node "$basedir/../skybridge/bin/run.js" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../skybridge/bin/run.js" "$@"
19
+ else
20
+ exec node "$basedir/../skybridge/bin/run.js" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@6.0.3/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@6.0.3/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../typescript/bin/tsc" "$@"
19
+ else
20
+ exec node "$basedir/../typescript/bin/tsc" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@6.0.3/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@6.0.3/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../typescript/bin/tsserver" "$@"
19
+ else
20
+ exec node "$basedir/../typescript/bin/tsserver" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/tsx@4.23.0/node_modules/tsx/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/tsx@4.23.0/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/tsx@4.23.0/node_modules/tsx/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/tsx@4.23.0/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../tsx/dist/cli.mjs" "$@"
19
+ else
20
+ exec node "$basedir/../tsx/dist/cli.mjs" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@8.1.5_@types+node@24.13.3_esbuild@0.28.1_jiti@2.7.0_terser@5.44.1_tsx@4.23.0_yaml@2.9.0/node_modules/vite/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@8.1.5_@types+node@24.13.3_esbuild@0.28.1_jiti@2.7.0_terser@5.44.1_tsx@4.23.0_yaml@2.9.0/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@8.1.5_@types+node@24.13.3_esbuild@0.28.1_jiti@2.7.0_terser@5.44.1_tsx@4.23.0_yaml@2.9.0/node_modules/vite/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@8.1.5_@types+node@24.13.3_esbuild@0.28.1_jiti@2.7.0_terser@5.44.1_tsx@4.23.0_yaml@2.9.0/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../vite/bin/vite.js" "$@"
19
+ else
20
+ exec node "$basedir/../vite/bin/vite.js" "$@"
21
+ fi
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "skybridge-ecom",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "description": "Skybridge MCP ecommerce template",
6
+ "type": "module",
7
+ "scripts": {
8
+ "dev": "skybridge dev",
9
+ "dev:tunnel": "skybridge dev --tunnel",
10
+ "build": "skybridge build",
11
+ "start": "skybridge start",
12
+ "deploy": "alpic deploy",
13
+ "ladle": "ladle serve",
14
+ "ladle:build": "ladle build"
15
+ },
16
+ "dependencies": {
17
+ "react": "^19.2.4",
18
+ "react-dom": "^19.2.4",
19
+ "skybridge": "^0.0.0-dev.ed29eee",
20
+ "vite": "^8.1.3",
21
+ "zod": "^4.4.3"
22
+ },
23
+ "devDependencies": {
24
+ "@ladle/react": "^5.1.1",
25
+ "@skybridge/devtools": "^1.2.4",
26
+ "@types/node": "^24.13.2",
27
+ "@types/react": "^19.2.14",
28
+ "@types/react-dom": "^19.2.3",
29
+ "@vanilla-extract/css": "^1.20.1",
30
+ "@vanilla-extract/recipes": "^0.5.7",
31
+ "@vanilla-extract/sprinkles": "^1.6.5",
32
+ "@vanilla-extract/vite-plugin": "^5.2.2",
33
+ "@vitejs/plugin-react": "^6.0.1",
34
+ "alpic": "^1.147.1",
35
+ "tsx": "^4.23.0",
36
+ "typescript": "^6.0.3"
37
+ },
38
+ "engines": {
39
+ "node": ">=24.18.0"
40
+ }
41
+ }
@@ -0,0 +1,19 @@
1
+ // The catalog: the app's single data seam. Both tools read products through
2
+ // these two functions, and nothing else in the app touches a backend.
3
+ //
4
+ // @todo: pick your provider. Ship one of the modules next to this file, or add
5
+ // your own (same two exports, same types) and re-export it here:
6
+ // ./mock.js placeholder catalog, no backend needed (default)
7
+ // ./shopify.js Shopify Storefront API, set the SHOPIFY_* vars in .env
8
+ //
9
+ // Writing your own: `search(input)` returns a `SearchResult`, `getProducts(ids)`
10
+ // resolves ids in the requested order (that is the display order, so resolve by
11
+ // id, never by catalog order). Both map your backend's rows into `Product`s, and
12
+ // how you group them depends on your catalog:
13
+ // - simple products: one `Product` with a single variant, `options: []`
14
+ // - grouped: one `Product` per product, `card` = union of its variants
15
+ // - one card per variant: `card` = that variant
16
+ // Either way `variants` holds ALL variants the source returns for the product;
17
+ // the detail view reads them so the client can switch variant. Order `options`
18
+ // with the imagery-driving axis first (see `Product`: order is semantic).
19
+ export { getProducts, search } from "./mock.js";
@@ -0,0 +1,134 @@
1
+ import type { SearchInput } from "../tools/search-products.js";
2
+ import type { Product, SearchResult, Spec } from "../types.js";
3
+
4
+ // Placeholder catalog provider, so both tools answer before a backend exists.
5
+ // Images are inline SVG placeholders, so no CSP domain is needed.
6
+ // @todo: delete this module once you point `./index.js` at a real provider.
7
+
8
+ function shot(fill: string): string {
9
+ return `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Crect width='400' height='400' fill='%23${fill}'/%3E%3C/svg%3E`;
10
+ }
11
+
12
+ const JACKET_SPECS: Spec[] = [
13
+ { label: "Material", value: "Water-repellent cotton" },
14
+ { label: "Fit", value: "Relaxed" },
15
+ ];
16
+
17
+ // Deliberately long, to exercise the detail page's scroll and "read more".
18
+ const JACKET_DESCRIPTION = "Relaxed-fit jacket in water-repellent cotton.";
19
+
20
+ const MOCK_PRODUCTS: Product[] = [
21
+ {
22
+ id: "field-jacket",
23
+ options: [
24
+ {
25
+ id: "color",
26
+ label: "Color",
27
+ values: [
28
+ { id: "black", label: "Black", media: shot("2b2b2b") },
29
+ { id: "sand", label: "Sand", media: shot("d8c7a8") },
30
+ ],
31
+ },
32
+ ],
33
+ variants: [
34
+ {
35
+ id: "fj-black",
36
+ selection: { color: "black" },
37
+ title: "Field jacket — Black",
38
+ description: JACKET_DESCRIPTION,
39
+ price: { amount: 229, currency: "EUR" },
40
+ media: [shot("2b2b2b")],
41
+ url: "https://example.com/field-jacket-black",
42
+ specs: JACKET_SPECS,
43
+ },
44
+ {
45
+ id: "fj-sand",
46
+ selection: { color: "sand" },
47
+ title: "Field jacket — Sand",
48
+ description: JACKET_DESCRIPTION,
49
+ price: { amount: 249, currency: "EUR" },
50
+ media: [shot("d8c7a8")],
51
+ url: "https://example.com/field-jacket-sand",
52
+ specs: JACKET_SPECS,
53
+ },
54
+ ],
55
+ card: {
56
+ title: "Field jacket",
57
+ description: "Relaxed-fit jacket in water-repellent cotton.",
58
+ price: { amount: 229, currency: "EUR" },
59
+ media: [shot("2b2b2b")],
60
+ specs: JACKET_SPECS,
61
+ },
62
+ },
63
+ {
64
+ id: "canvas-tote",
65
+ options: [],
66
+ variants: [
67
+ {
68
+ id: "canvas-tote",
69
+ selection: {},
70
+ title: "Canvas tote",
71
+ description: "Sturdy everyday tote with an inner pocket.",
72
+ price: { amount: 39, currency: "EUR" },
73
+ media: [shot("e1e1e1")],
74
+ url: "https://example.com/canvas-tote",
75
+ specs: [{ label: "Material", value: "Cotton canvas" }],
76
+ },
77
+ ],
78
+ card: {
79
+ title: "Canvas tote",
80
+ description: "Sturdy everyday tote with an inner pocket.",
81
+ price: { amount: 39, currency: "EUR" },
82
+ media: [shot("e1e1e1")],
83
+ specs: [{ label: "Material", value: "Cotton canvas" }],
84
+ },
85
+ },
86
+ {
87
+ id: "wool-beanie",
88
+ options: [],
89
+ variants: [
90
+ {
91
+ id: "wool-beanie",
92
+ selection: {},
93
+ title: "Wool beanie",
94
+ description: "Ribbed merino beanie with a folded brim.",
95
+ price: { amount: 45, currency: "EUR" },
96
+ media: [shot("6b7f9e")],
97
+ url: "https://example.com/wool-beanie",
98
+ outOfStock: true,
99
+ specs: [{ label: "Material", value: "Merino wool" }],
100
+ },
101
+ ],
102
+ card: {
103
+ title: "Wool beanie",
104
+ description: "Ribbed merino beanie with a folded brim.",
105
+ price: { amount: 45, currency: "EUR" },
106
+ media: [shot("6b7f9e")],
107
+ outOfStock: true,
108
+ specs: [{ label: "Material", value: "Merino wool" }],
109
+ },
110
+ },
111
+ ];
112
+
113
+ // Ignores the input: every mock product matches every query.
114
+ export async function search(_input: SearchInput): Promise<SearchResult> {
115
+ return {
116
+ products: MOCK_PRODUCTS,
117
+ pages: { current: 1, total: 1 },
118
+ totalHits: MOCK_PRODUCTS.length,
119
+ };
120
+ }
121
+
122
+ // Requested order is the display order, so resolve by id, not catalog order.
123
+ export async function getProducts(ids: string[]): Promise<Product[]> {
124
+ const products: Product[] = [];
125
+ for (const id of ids) {
126
+ for (const product of MOCK_PRODUCTS) {
127
+ if (product.id === id) {
128
+ products.push(product);
129
+ break;
130
+ }
131
+ }
132
+ }
133
+ return products;
134
+ }