create-skybridge 0.0.0-dev.94c22d0 → 0.0.0-dev.9520814
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 +107 -17
- package/package.json +2 -2
- package/templates/blank/README.md +2 -1
- package/templates/blank/node_modules/.bin/alpic +2 -2
- package/templates/blank/node_modules/.bin/tsx +2 -2
- package/templates/blank/node_modules/.bin/vite +2 -2
- package/templates/blank/package.json +8 -7
- package/templates/blank/src/index.ts +3 -0
- package/templates/blank/src/server.ts +7 -11
- package/templates/blank/vite.config.ts +7 -1
- package/templates/demo/README.md +3 -1
- package/templates/demo/evals/start.eval.ts +11 -0
- package/templates/demo/node_modules/.bin/alpic +2 -2
- package/templates/demo/node_modules/.bin/tsx +2 -2
- package/templates/demo/node_modules/.bin/vite +2 -2
- package/templates/demo/node_modules/.bin/vitest +21 -0
- package/templates/demo/package.json +19 -13
- package/templates/demo/src/index.ts +3 -0
- package/templates/demo/src/server.ts +86 -88
- package/templates/demo/src/views/onboarding.tsx +3 -3
- package/templates/demo/tsconfig.evals.json +11 -0
- package/templates/demo/vite.config.ts +9 -3
- package/templates/ecom/.env.template +5 -0
- package/templates/ecom/README.md +2 -1
- package/templates/ecom/node_modules/.bin/alpic +2 -2
- package/templates/ecom/node_modules/.bin/ladle +2 -2
- package/templates/ecom/node_modules/.bin/vite +2 -2
- package/templates/ecom/package.json +3 -2
- package/templates/ecom/src/catalog/index.ts +19 -0
- package/templates/ecom/src/catalog/mock.ts +134 -0
- package/templates/ecom/src/catalog/shopify.ts +264 -0
- package/templates/ecom/src/components/chip.css.ts +15 -8
- package/templates/ecom/src/components/chip.stories.tsx +2 -1
- package/templates/ecom/src/components/chip.tsx +16 -8
- package/templates/ecom/src/components/product-card.tsx +2 -2
- package/templates/ecom/src/components/variant-picker.stories.tsx +7 -4
- package/templates/ecom/src/components/variant-picker.tsx +17 -29
- package/templates/ecom/src/components/view-frame.tsx +4 -4
- package/templates/ecom/src/i18n.ts +1 -1
- package/templates/ecom/src/index.ts +3 -0
- package/templates/ecom/src/lib/variants.ts +100 -29
- package/templates/ecom/src/server.ts +17 -21
- package/templates/ecom/src/tools/render-carousel.ts +5 -85
- package/templates/ecom/src/tools/search-products.ts +32 -21
- package/templates/ecom/src/types.ts +72 -0
- package/templates/ecom/src/views/carousel/detail/detail.css.ts +2 -2
- package/templates/ecom/src/views/carousel/detail/detail.stories.tsx +26 -8
- package/templates/ecom/src/views/carousel/detail/index.tsx +43 -29
- package/templates/ecom/src/views/carousel/index.tsx +1 -2
- package/templates/ecom/vite.config.ts +1 -1
|
@@ -1,94 +1,92 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Skybridge } from "skybridge/server";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
4
|
+
export const app = new Skybridge({
|
|
5
|
+
name: "alpic-openai-app",
|
|
6
|
+
version: "0.0.1",
|
|
7
|
+
handler: (server) =>
|
|
8
|
+
server
|
|
9
|
+
.registerTool(
|
|
10
|
+
{
|
|
11
|
+
name: "start",
|
|
12
|
+
description: "Onboard Skybridge",
|
|
13
|
+
inputSchema: {
|
|
14
|
+
name: z.string().optional().describe("The user name."),
|
|
15
|
+
},
|
|
16
|
+
annotations: {
|
|
17
|
+
title: "Start Skybridge onboarding",
|
|
18
|
+
readOnlyHint: true,
|
|
19
|
+
destructiveHint: false,
|
|
20
|
+
openWorldHint: false,
|
|
21
|
+
},
|
|
22
|
+
_meta: {
|
|
23
|
+
"openai/toolInvocation/invoking":
|
|
24
|
+
"Starting the Skybridge onboarding…",
|
|
25
|
+
"openai/toolInvocation/invoked": "Onboarding ready.",
|
|
26
|
+
},
|
|
27
|
+
view: {
|
|
28
|
+
component: "onboarding",
|
|
29
|
+
// Replace with the URL your widget will be served from in production.
|
|
30
|
+
domain: "https://skybridge.tech",
|
|
31
|
+
description: "Onboarding deck",
|
|
32
|
+
csp: {
|
|
33
|
+
resourceDomains: [
|
|
34
|
+
"https://fonts.googleapis.com",
|
|
35
|
+
"https://fonts.gstatic.com",
|
|
36
|
+
],
|
|
37
|
+
redirectDomains: ["https://docs.skybridge.tech"],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
39
40
|
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const prediction =
|
|
79
|
-
predictions[Math.floor(Math.random() * predictions.length)];
|
|
80
|
-
|
|
81
|
-
// simulate backend work
|
|
82
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
41
|
+
async ({ name }) => {
|
|
42
|
+
return {
|
|
43
|
+
structuredContent: { name },
|
|
44
|
+
content: [{ type: "text", text: `User name: ${name ?? "friend"}` }],
|
|
45
|
+
isError: false,
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
)
|
|
49
|
+
.registerTool(
|
|
50
|
+
{
|
|
51
|
+
name: "get-fortune-cookie",
|
|
52
|
+
description: "Get fortune cookie",
|
|
53
|
+
annotations: {
|
|
54
|
+
title: "Get a fortune cookie",
|
|
55
|
+
readOnlyHint: true,
|
|
56
|
+
destructiveHint: false,
|
|
57
|
+
openWorldHint: false,
|
|
58
|
+
},
|
|
59
|
+
_meta: {
|
|
60
|
+
"openai/toolInvocation/invoking": "Cracking open a fortune cookie…",
|
|
61
|
+
"openai/toolInvocation/invoked": "Fortune revealed.",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
async () => {
|
|
65
|
+
const predictions = [
|
|
66
|
+
"A pleasant surprise is waiting for you.",
|
|
67
|
+
"Your hard work will soon pay off.",
|
|
68
|
+
"An unexpected friendship will brighten your week.",
|
|
69
|
+
"The best is yet to come.",
|
|
70
|
+
"A small step today leads to a giant leap tomorrow.",
|
|
71
|
+
"Trust your instincts: they are sharper than you think.",
|
|
72
|
+
"Adventure awaits just around the corner.",
|
|
73
|
+
"A long-forgotten idea will return with great success.",
|
|
74
|
+
"Kindness given today will be returned threefold.",
|
|
75
|
+
"Something you lost will soon be found.",
|
|
76
|
+
];
|
|
77
|
+
const prediction =
|
|
78
|
+
predictions[Math.floor(Math.random() * predictions.length)];
|
|
83
79
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
content: [{ type: "text", text: prediction }],
|
|
87
|
-
isError: false,
|
|
88
|
-
};
|
|
89
|
-
},
|
|
90
|
-
);
|
|
80
|
+
// simulate backend work
|
|
81
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
91
82
|
|
|
92
|
-
|
|
83
|
+
return {
|
|
84
|
+
structuredContent: { prediction },
|
|
85
|
+
content: [{ type: "text", text: prediction }],
|
|
86
|
+
isError: false,
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
),
|
|
90
|
+
});
|
|
93
91
|
|
|
94
|
-
export type AppType = typeof
|
|
92
|
+
export type AppType = typeof app;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@/index.css";
|
|
2
2
|
|
|
3
3
|
import { useState } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { useUser } from "skybridge/web";
|
|
5
5
|
import Nav from "./components/nav.js";
|
|
6
6
|
import Progress from "./components/progress.js";
|
|
7
7
|
import Outro from "./components/steps/outro.js";
|
|
@@ -18,8 +18,8 @@ const STEPS = [
|
|
|
18
18
|
] as const;
|
|
19
19
|
|
|
20
20
|
export default function Onboarding() {
|
|
21
|
-
//
|
|
22
|
-
const { theme } =
|
|
21
|
+
// useUser: read user environment info (theme, locale, user agent).
|
|
22
|
+
const { theme } = useUser();
|
|
23
23
|
|
|
24
24
|
const [step, setStep] = useState(0);
|
|
25
25
|
const { img } = useMascot();
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { skybridge } from "@skybridge/vite-plugin";
|
|
2
3
|
import tailwindcss from "@tailwindcss/vite";
|
|
3
4
|
import react from "@vitejs/plugin-react";
|
|
4
|
-
import { skybridge } from "skybridge/vite";
|
|
5
5
|
import { defineConfig } from "vite";
|
|
6
6
|
|
|
7
7
|
export default defineConfig({
|
|
8
|
-
plugins: [skybridge(), react(), tailwindcss()],
|
|
8
|
+
plugins: [skybridge({ evals: {} }), react(), tailwindcss()],
|
|
9
|
+
server: {
|
|
10
|
+
forwardConsole: {
|
|
11
|
+
unhandledErrors: true,
|
|
12
|
+
logLevels: ["error"],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
9
15
|
resolve: {
|
|
10
16
|
alias: {
|
|
11
|
-
"@": path.resolve(
|
|
17
|
+
"@": path.resolve(import.meta.dirname, "./src"),
|
|
12
18
|
},
|
|
13
19
|
},
|
|
14
20
|
});
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
# Copy to .env and fill in. Sourced by the server at startup.
|
|
2
2
|
API_KEY=
|
|
3
|
+
|
|
4
|
+
# Only for the Shopify catalog provider (src/catalog/shopify.ts).
|
|
5
|
+
# The token is the public Storefront API access token, not an Admin key.
|
|
6
|
+
SHOPIFY_STORE_DOMAIN=
|
|
7
|
+
SHOPIFY_STOREFRONT_TOKEN=
|
package/templates/ecom/README.md
CHANGED
|
@@ -48,7 +48,8 @@ This command starts:
|
|
|
48
48
|
|
|
49
49
|
```
|
|
50
50
|
├── src/
|
|
51
|
-
│ ├──
|
|
51
|
+
│ ├── index.ts # Entry point (starts the app)
|
|
52
|
+
│ ├── server.ts # App definition (tools, views)
|
|
52
53
|
│ └── helpers.ts # Shared utilities
|
|
53
54
|
├── vite.config.ts
|
|
54
55
|
├── alpic.json # Deployment config
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/alpic@1.
|
|
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
14
|
else
|
|
15
|
-
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/alpic@1.
|
|
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
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../alpic/bin/run.js" "$@"
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
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.
|
|
13
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/@ladle+react@5.1.1_@swc+helpers@0.5.23_@types+node@24.13.3_@types+react@19.2.17_jiti@2._9105ecfa2ac4b29fe87a036530c3844f/node_modules/@ladle/react/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/@ladle+react@5.1.1_@swc+helpers@0.5.23_@types+node@24.13.3_@types+react@19.2.17_jiti@2._9105ecfa2ac4b29fe87a036530c3844f/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/@ladle+react@5.1.1_@types+node@24.13.
|
|
15
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/@ladle+react@5.1.1_@swc+helpers@0.5.23_@types+node@24.13.3_@types+react@19.2.17_jiti@2._9105ecfa2ac4b29fe87a036530c3844f/node_modules/@ladle/react/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/@ladle+react@5.1.1_@swc+helpers@0.5.23_@types+node@24.13.3_@types+react@19.2.17_jiti@2._9105ecfa2ac4b29fe87a036530c3844f/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../@ladle/react/lib/cli/cli.js" "$@"
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@8.1.
|
|
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
14
|
else
|
|
15
|
-
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@8.1.
|
|
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
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../vite/bin/vite.js" "$@"
|
|
@@ -16,13 +16,14 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"react": "^19.2.4",
|
|
18
18
|
"react-dom": "^19.2.4",
|
|
19
|
-
"skybridge": "^0.0.0-dev.
|
|
19
|
+
"skybridge": "^0.0.0-dev.9520814",
|
|
20
20
|
"vite": "^8.1.3",
|
|
21
21
|
"zod": "^4.4.3"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@ladle/react": "^5.1.1",
|
|
25
|
-
"@skybridge/devtools": "^
|
|
25
|
+
"@skybridge/devtools": "^0.0.0-dev.9520814",
|
|
26
|
+
"@skybridge/vite-plugin": "^0.0.0-dev.9520814",
|
|
26
27
|
"@types/node": "^24.13.2",
|
|
27
28
|
"@types/react": "^19.2.14",
|
|
28
29
|
"@types/react-dom": "^19.2.3",
|
|
@@ -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
|
+
}
|