@ebay-dt/bonfire-cli 0.1.0 → 0.2.0-alpha.10
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/branch-prepare.d.ts +1 -0
- package/dist/branch-prepare.d.ts.map +1 -1
- package/dist/branch-prepare.js +24 -1
- package/dist/branch-prepare.js.map +1 -1
- package/dist/convert.d.ts.map +1 -1
- package/dist/convert.js +2 -3
- package/dist/convert.js.map +1 -1
- package/dist/release-versions.d.ts +3 -0
- package/dist/release-versions.d.ts.map +1 -0
- package/dist/release-versions.js +4 -0
- package/dist/release-versions.js.map +1 -0
- package/package.json +5 -5
- package/templates/instance/context/PROTOTYPE.md +2 -2
- package/templates/instance/context/skills/color-scheme/SKILL.md +4 -4
- package/templates/instance/context/skills/item-data/SKILL.md +21 -21
- package/templates/instance/context/skills/setup-evomcp/SKILL.md +1 -1
- package/templates/instance/next.config.ts +4 -4
- package/templates/instance/src/actions/agents.ts +5 -5
- package/templates/instance/src/actions/prototypes.ts +14 -10
- package/templates/instance/src/actions/repository.ts +33 -0
- package/templates/instance/src/app/(prototypes)/layout.tsx +11 -11
- package/templates/instance/src/app/(system)/api/prototype-dirty/route.ts +3 -3
- package/templates/instance/src/app/(system)/api/repository/check/route.ts +3 -0
- package/templates/instance/src/app/(system)/api/repository/retry/route.ts +3 -0
- package/templates/instance/src/app/(system)/api/repository/summary/route.ts +3 -0
- package/templates/instance/src/app/(system)/api/repository/update/route.ts +3 -0
- package/templates/instance/src/app/(system)/auth/login/route.ts +3 -3
- package/templates/instance/src/app/(system)/auth/logout/route.ts +3 -3
- package/templates/instance/src/app/(system)/auth/status/route.ts +3 -3
- package/templates/instance/src/app/(system)/layout.tsx +6 -6
- package/templates/instance/src/app/(system)/login/page.tsx +8 -8
- package/templates/instance/src/app/(system)/page.tsx +9 -9
- package/templates/instance/src/app/api/items/[itemId]/route.ts +7 -7
- package/templates/instance/src/app/api/items/route.ts +4 -4
- package/templates/instance/src/app/layout.tsx +38 -16
- package/templates/instance/src/bonfire.ts +11 -11
- package/templates/instance/src/lib/items/gateway-schemas.ts +12 -12
- package/templates/instance/src/lib/items/server.ts +52 -52
- package/templates/instance/src/proxy.ts +4 -4
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
const nullableString = z.string().nullable().optional()
|
|
4
|
-
const nullableNumber = z.number().nullable().optional()
|
|
5
|
-
const gatewayImageSchema = z.object({ imageUrl: nullableString }).nullable()
|
|
3
|
+
const nullableString = z.string().nullable().optional();
|
|
4
|
+
const nullableNumber = z.number().nullable().optional();
|
|
5
|
+
const gatewayImageSchema = z.object({ imageUrl: nullableString }).nullable();
|
|
6
6
|
const gatewayPriceSchema = z
|
|
7
7
|
.object({
|
|
8
8
|
value: z.union([z.string(), z.number()]).nullable().optional(),
|
|
9
9
|
currency: nullableString,
|
|
10
10
|
convertedFromValue: z.union([z.string(), z.number()]).nullable().optional(),
|
|
11
11
|
})
|
|
12
|
-
.nullable()
|
|
12
|
+
.nullable();
|
|
13
13
|
|
|
14
14
|
export const gatewayErrorsSchema = z
|
|
15
15
|
.array(z.object({ message: nullableString }).passthrough())
|
|
16
|
-
.optional()
|
|
16
|
+
.optional();
|
|
17
17
|
|
|
18
18
|
const gatewaySearchItemSchema = z
|
|
19
19
|
.object({
|
|
@@ -28,7 +28,7 @@ const gatewaySearchItemSchema = z
|
|
|
28
28
|
.nullable()
|
|
29
29
|
.optional(),
|
|
30
30
|
})
|
|
31
|
-
.nullable()
|
|
31
|
+
.nullable();
|
|
32
32
|
|
|
33
33
|
export const gatewaySearchResponseSchema = z.object({
|
|
34
34
|
data: z
|
|
@@ -45,7 +45,7 @@ export const gatewaySearchResponseSchema = z.object({
|
|
|
45
45
|
})
|
|
46
46
|
.optional(),
|
|
47
47
|
errors: gatewayErrorsSchema,
|
|
48
|
-
})
|
|
48
|
+
});
|
|
49
49
|
|
|
50
50
|
const gatewayItemSchema = z.object({
|
|
51
51
|
itemId: nullableString,
|
|
@@ -74,7 +74,7 @@ const gatewayItemSchema = z.object({
|
|
|
74
74
|
name: nullableString,
|
|
75
75
|
value: nullableString,
|
|
76
76
|
})
|
|
77
|
-
.nullable()
|
|
77
|
+
.nullable(),
|
|
78
78
|
)
|
|
79
79
|
.nullable()
|
|
80
80
|
.optional(),
|
|
@@ -88,13 +88,13 @@ const gatewayItemSchema = z.object({
|
|
|
88
88
|
trademarkSymbol: nullableString,
|
|
89
89
|
type: nullableString,
|
|
90
90
|
})
|
|
91
|
-
.nullable()
|
|
91
|
+
.nullable(),
|
|
92
92
|
)
|
|
93
93
|
.nullable()
|
|
94
94
|
.optional(),
|
|
95
|
-
})
|
|
95
|
+
});
|
|
96
96
|
|
|
97
97
|
export const gatewayItemResponseSchema = z.object({
|
|
98
98
|
data: z.object({ item: gatewayItemSchema.nullable().optional() }).optional(),
|
|
99
99
|
errors: gatewayErrorsSchema,
|
|
100
|
-
})
|
|
100
|
+
});
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "server-only";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
itemDetailSchema,
|
|
5
5
|
itemSearchPageSchema,
|
|
6
6
|
type ItemDetail,
|
|
7
7
|
type ItemSearchPage,
|
|
8
|
-
} from
|
|
8
|
+
} from "@ebay-dt/bonfire-preset-ebay/data/items";
|
|
9
9
|
import {
|
|
10
10
|
gatewayItemResponseSchema,
|
|
11
11
|
gatewaySearchResponseSchema,
|
|
12
|
-
} from
|
|
12
|
+
} from "./gateway-schemas";
|
|
13
13
|
|
|
14
|
-
const DEFAULT_GATEWAY_URL =
|
|
14
|
+
const DEFAULT_GATEWAY_URL = "https://dtsvc.vip.qa.ebay.com/dt/v1/gateway-gql";
|
|
15
15
|
|
|
16
16
|
const SEARCH_QUERY = `
|
|
17
17
|
query Search($q: String!, $limit: Int!, $offset: Int!) {
|
|
@@ -24,7 +24,7 @@ const SEARCH_QUERY = `
|
|
|
24
24
|
total limit offset
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
`;
|
|
28
28
|
|
|
29
29
|
const ITEM_QUERY = `
|
|
30
30
|
query ItemById($id: String!) {
|
|
@@ -41,82 +41,82 @@ const ITEM_QUERY = `
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
`;
|
|
45
45
|
|
|
46
46
|
async function requestGateway(
|
|
47
47
|
operationName: string,
|
|
48
48
|
query: string,
|
|
49
49
|
variables: Record<string, unknown>,
|
|
50
|
-
signal: AbortSignal
|
|
50
|
+
signal: AbortSignal,
|
|
51
51
|
): Promise<unknown> {
|
|
52
|
-
const endpoint = process.env.DT_GATEWAY_URL?.trim() || DEFAULT_GATEWAY_URL
|
|
53
|
-
const apiKey = process.env.DT_GATEWAY_API_KEY?.trim()
|
|
52
|
+
const endpoint = process.env.DT_GATEWAY_URL?.trim() || DEFAULT_GATEWAY_URL;
|
|
53
|
+
const apiKey = process.env.DT_GATEWAY_API_KEY?.trim();
|
|
54
54
|
const response = await fetch(endpoint, {
|
|
55
|
-
method:
|
|
55
|
+
method: "POST",
|
|
56
56
|
headers: {
|
|
57
|
-
|
|
57
|
+
"Content-Type": "application/json",
|
|
58
58
|
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),
|
|
59
59
|
},
|
|
60
60
|
body: JSON.stringify({ operationName, query, variables }),
|
|
61
|
-
cache:
|
|
61
|
+
cache: "no-store",
|
|
62
62
|
signal,
|
|
63
|
-
})
|
|
63
|
+
});
|
|
64
64
|
|
|
65
|
-
let result: unknown
|
|
65
|
+
let result: unknown;
|
|
66
66
|
try {
|
|
67
|
-
result = await response.json()
|
|
67
|
+
result = await response.json();
|
|
68
68
|
} catch {
|
|
69
|
-
throw new Error(`The item gateway returned HTTP ${response.status}.`)
|
|
69
|
+
throw new Error(`The item gateway returned HTTP ${response.status}.`);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
if (!response.ok) {
|
|
73
|
-
throw new Error(`The item gateway returned HTTP ${response.status}.`)
|
|
73
|
+
throw new Error(`The item gateway returned HTTP ${response.status}.`);
|
|
74
74
|
}
|
|
75
|
-
return result
|
|
75
|
+
return result;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
function graphQLError(errors?: Array<{ message?: string | null }>) {
|
|
79
79
|
return errors
|
|
80
80
|
?.map(({ message }) => message)
|
|
81
81
|
.filter(Boolean)
|
|
82
|
-
.join(
|
|
82
|
+
.join("; ");
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
function optionalNumber(value: string | number | null | undefined) {
|
|
86
|
-
if (value == null || value ===
|
|
87
|
-
const number = typeof value ===
|
|
88
|
-
return Number.isFinite(number) ? number : undefined
|
|
86
|
+
if (value == null || value === "") return undefined;
|
|
87
|
+
const number = typeof value === "number" ? value : Number(value);
|
|
88
|
+
return Number.isFinite(number) ? number : undefined;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
export async function searchItems(
|
|
92
92
|
query: string,
|
|
93
93
|
limit: number,
|
|
94
94
|
offset: number,
|
|
95
|
-
signal: AbortSignal
|
|
95
|
+
signal: AbortSignal,
|
|
96
96
|
): Promise<ItemSearchPage> {
|
|
97
97
|
const result = gatewaySearchResponseSchema.parse(
|
|
98
98
|
await requestGateway(
|
|
99
|
-
|
|
99
|
+
"Search",
|
|
100
100
|
SEARCH_QUERY,
|
|
101
101
|
{ q: query, limit, offset },
|
|
102
|
-
signal
|
|
103
|
-
)
|
|
104
|
-
)
|
|
105
|
-
const message = graphQLError(result.errors)
|
|
106
|
-
if (message) throw new Error(message)
|
|
102
|
+
signal,
|
|
103
|
+
),
|
|
104
|
+
);
|
|
105
|
+
const message = graphQLError(result.errors);
|
|
106
|
+
if (message) throw new Error(message);
|
|
107
107
|
|
|
108
|
-
const search = result.data?.itemsBySearch
|
|
108
|
+
const search = result.data?.itemsBySearch;
|
|
109
109
|
return itemSearchPageSchema.parse({
|
|
110
110
|
total: search?.total ?? 0,
|
|
111
111
|
limit: search?.limit ?? limit,
|
|
112
112
|
offset: search?.offset ?? offset,
|
|
113
113
|
items:
|
|
114
114
|
search?.items?.flatMap((item) => {
|
|
115
|
-
if (!item?.itemId || !item.title || !item.itemWebUrl) return []
|
|
116
|
-
const priceValue = optionalNumber(item.price?.value)
|
|
115
|
+
if (!item?.itemId || !item.title || !item.itemWebUrl) return [];
|
|
116
|
+
const priceValue = optionalNumber(item.price?.value);
|
|
117
117
|
const previousPriceValue = optionalNumber(
|
|
118
|
-
item.marketingPrice?.originalPrice?.value
|
|
119
|
-
)
|
|
118
|
+
item.marketingPrice?.originalPrice?.value,
|
|
119
|
+
);
|
|
120
120
|
return [
|
|
121
121
|
{
|
|
122
122
|
id: item.itemId,
|
|
@@ -137,32 +137,32 @@ export async function searchItems(
|
|
|
137
137
|
}
|
|
138
138
|
: undefined,
|
|
139
139
|
},
|
|
140
|
-
]
|
|
140
|
+
];
|
|
141
141
|
}) ?? [],
|
|
142
|
-
})
|
|
142
|
+
});
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
export async function getItemById(
|
|
146
146
|
itemId: string,
|
|
147
|
-
signal: AbortSignal
|
|
147
|
+
signal: AbortSignal,
|
|
148
148
|
): Promise<ItemDetail | null> {
|
|
149
149
|
const result = gatewayItemResponseSchema.parse(
|
|
150
|
-
await requestGateway(
|
|
151
|
-
)
|
|
152
|
-
const message = graphQLError(result.errors)
|
|
153
|
-
if (message) throw new Error(message)
|
|
154
|
-
const item = result.data?.item
|
|
155
|
-
if (!item) return null
|
|
150
|
+
await requestGateway("ItemById", ITEM_QUERY, { id: itemId }, signal),
|
|
151
|
+
);
|
|
152
|
+
const message = graphQLError(result.errors);
|
|
153
|
+
if (message) throw new Error(message);
|
|
154
|
+
const item = result.data?.item;
|
|
155
|
+
if (!item) return null;
|
|
156
156
|
if (!item.itemId || !item.title) {
|
|
157
|
-
throw new Error(
|
|
157
|
+
throw new Error("The item gateway returned an incomplete item.");
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
const imageUrls = [
|
|
161
161
|
item.image?.imageUrl,
|
|
162
162
|
...(item.additionalImages?.map((image) => image?.imageUrl) ?? []),
|
|
163
|
-
].filter((url): url is string => Boolean(url))
|
|
164
|
-
const priceValue = optionalNumber(item.price?.value)
|
|
165
|
-
const convertedFromValue = optionalNumber(item.price?.convertedFromValue)
|
|
163
|
+
].filter((url): url is string => Boolean(url));
|
|
164
|
+
const priceValue = optionalNumber(item.price?.value);
|
|
165
|
+
const convertedFromValue = optionalNumber(item.price?.convertedFromValue);
|
|
166
166
|
|
|
167
167
|
return itemDetailSchema.parse({
|
|
168
168
|
id: item.itemId,
|
|
@@ -181,12 +181,12 @@ export async function getItemById(
|
|
|
181
181
|
gender: item.gender ?? undefined,
|
|
182
182
|
categoryPath:
|
|
183
183
|
item.categoryPath
|
|
184
|
-
?.split(
|
|
184
|
+
?.split("|")
|
|
185
185
|
.map((part) => part.trim())
|
|
186
186
|
.filter(Boolean) ?? [],
|
|
187
187
|
categoryIds:
|
|
188
188
|
item.categories?.flatMap((category) =>
|
|
189
|
-
category?.categoryId ? [category.categoryId] : []
|
|
189
|
+
category?.categoryId ? [category.categoryId] : [],
|
|
190
190
|
) ?? [],
|
|
191
191
|
aspects:
|
|
192
192
|
item.localizedAspects?.flatMap((aspect) =>
|
|
@@ -198,7 +198,7 @@ export async function getItemById(
|
|
|
198
198
|
type: aspect.type ?? undefined,
|
|
199
199
|
},
|
|
200
200
|
]
|
|
201
|
-
: []
|
|
201
|
+
: [],
|
|
202
202
|
) ?? [],
|
|
203
203
|
shippingOptions:
|
|
204
204
|
item.shippingOptions?.flatMap((option) =>
|
|
@@ -212,9 +212,9 @@ export async function getItemById(
|
|
|
212
212
|
type: option.type ?? undefined,
|
|
213
213
|
},
|
|
214
214
|
]
|
|
215
|
-
: []
|
|
215
|
+
: [],
|
|
216
216
|
) ?? [],
|
|
217
217
|
bidCount: item.bidCount ?? undefined,
|
|
218
218
|
watchCount: item.watchCount ?? undefined,
|
|
219
|
-
})
|
|
219
|
+
});
|
|
220
220
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { bonfire } from
|
|
1
|
+
import { bonfire } from "@/bonfire";
|
|
2
2
|
|
|
3
|
-
export const proxy = bonfire.auth.proxy
|
|
3
|
+
export const proxy = bonfire.auth.proxy;
|
|
4
4
|
|
|
5
5
|
export const config = {
|
|
6
6
|
// Run on all routes except Next.js internals and static assets
|
|
7
|
-
matcher: [
|
|
8
|
-
}
|
|
7
|
+
matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"],
|
|
8
|
+
};
|