@unifiedcommerce/core 0.4.3 → 0.4.5
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/interfaces/mcp/tools/analytics.d.ts +2 -2
- package/dist/interfaces/mcp/tools/catalog.d.ts +1 -1
- package/dist/interfaces/mcp/tools/pricing.d.ts +1 -1
- package/dist/interfaces/mcp/tools/webhooks.d.ts +1 -1
- package/dist/interfaces/rest/index.d.ts.map +1 -1
- package/dist/interfaces/rest/index.js +4 -17
- package/dist/runtime/server.d.ts.map +1 -1
- package/dist/runtime/server.js +33 -0
- package/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -6,9 +6,9 @@ export declare const analyticsQuery: ToolDefinition<z.ZodObject<{
|
|
|
6
6
|
timeDimensions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
7
7
|
dimension: z.ZodString;
|
|
8
8
|
granularity: z.ZodOptional<z.ZodEnum<{
|
|
9
|
-
month: "month";
|
|
10
9
|
day: "day";
|
|
11
10
|
week: "week";
|
|
11
|
+
month: "month";
|
|
12
12
|
year: "year";
|
|
13
13
|
}>>;
|
|
14
14
|
dateRange: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodTuple<[z.ZodString, z.ZodString], null>]>>;
|
|
@@ -16,11 +16,11 @@ export declare const analyticsQuery: ToolDefinition<z.ZodObject<{
|
|
|
16
16
|
filters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
17
17
|
member: z.ZodString;
|
|
18
18
|
operator: z.ZodEnum<{
|
|
19
|
-
in: "in";
|
|
20
19
|
gt: "gt";
|
|
21
20
|
gte: "gte";
|
|
22
21
|
lt: "lt";
|
|
23
22
|
lte: "lte";
|
|
23
|
+
in: "in";
|
|
24
24
|
contains: "contains";
|
|
25
25
|
equals: "equals";
|
|
26
26
|
notEquals: "notEquals";
|
|
@@ -23,10 +23,10 @@ export declare const catalogGet: ToolDefinition<z.ZodObject<{
|
|
|
23
23
|
}, z.core.$strip>>;
|
|
24
24
|
export declare const catalogManage: ToolDefinition<z.ZodObject<{
|
|
25
25
|
action: z.ZodEnum<{
|
|
26
|
+
update: "update";
|
|
26
27
|
delete: "delete";
|
|
27
28
|
publish: "publish";
|
|
28
29
|
archive: "archive";
|
|
29
|
-
update: "update";
|
|
30
30
|
discontinue: "discontinue";
|
|
31
31
|
set_attributes: "set_attributes";
|
|
32
32
|
assign_category: "assign_category";
|
|
@@ -17,10 +17,10 @@ export declare const pricingManage: ToolDefinition<z.ZodObject<{
|
|
|
17
17
|
validUntil: z.ZodOptional<z.ZodString>;
|
|
18
18
|
name: z.ZodOptional<z.ZodString>;
|
|
19
19
|
type: z.ZodOptional<z.ZodEnum<{
|
|
20
|
-
override: "override";
|
|
21
20
|
percentage_discount: "percentage_discount";
|
|
22
21
|
fixed_discount: "fixed_discount";
|
|
23
22
|
markup: "markup";
|
|
23
|
+
override: "override";
|
|
24
24
|
}>>;
|
|
25
25
|
value: z.ZodOptional<z.ZodNumber>;
|
|
26
26
|
priority: z.ZodOptional<z.ZodNumber>;
|
|
@@ -2,8 +2,8 @@ import { z } from "zod";
|
|
|
2
2
|
import type { ToolDefinition } from "./registry.js";
|
|
3
3
|
export declare const webhooksManage: ToolDefinition<z.ZodObject<{
|
|
4
4
|
action: z.ZodEnum<{
|
|
5
|
-
delete: "delete";
|
|
6
5
|
create: "create";
|
|
6
|
+
delete: "delete";
|
|
7
7
|
list: "list";
|
|
8
8
|
}>;
|
|
9
9
|
url: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/interfaces/rest/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/interfaces/rest/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAkBzC,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,gCAsE9C"}
|
|
@@ -15,7 +15,8 @@ import { searchRoutes } from "./routes/search.js";
|
|
|
15
15
|
import { auditRoutes } from "./routes/audit.js";
|
|
16
16
|
import { adminJobRoutes } from "./routes/admin-jobs.js";
|
|
17
17
|
import { customerRoutes } from "./routes/customers.js";
|
|
18
|
-
|
|
18
|
+
// Entity aliases are registered in server.ts on the top-level app (not this sub-router)
|
|
19
|
+
// because internal re-dispatch requires app.fetch(), not router.fetch().
|
|
19
20
|
export function createRestRoutes(kernel) {
|
|
20
21
|
const router = new OpenAPIHono({
|
|
21
22
|
// Standardize Zod validation error responses across all routes
|
|
@@ -62,22 +63,8 @@ export function createRestRoutes(kernel) {
|
|
|
62
63
|
router.route("/customers", customerRoutes(kernel));
|
|
63
64
|
router.route("/audit", auditRoutes(kernel));
|
|
64
65
|
router.route("/admin", adminJobRoutes(kernel));
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
registerEntityAliases(router, kernel);
|
|
68
|
-
// Static aliases: shorter paths for catalog sub-resources
|
|
69
|
-
for (const [shortcut, target] of [["categories", "catalog/categories"], ["brands", "catalog/brands"]]) {
|
|
70
|
-
router.all(`/${shortcut}`, (c) => {
|
|
71
|
-
const url = new URL(c.req.url);
|
|
72
|
-
url.pathname = `/api/${target}`;
|
|
73
|
-
return router.fetch(new Request(url.toString(), c.req.raw));
|
|
74
|
-
});
|
|
75
|
-
router.all(`/${shortcut}/*`, (c) => {
|
|
76
|
-
const url = new URL(c.req.url);
|
|
77
|
-
url.pathname = url.pathname.replace(`/api/${shortcut}`, `/api/${target}`);
|
|
78
|
-
return router.fetch(new Request(url.toString(), c.req.raw));
|
|
79
|
-
});
|
|
80
|
-
}
|
|
66
|
+
// Aliases (entity + categories/brands) are registered in server.ts on the
|
|
67
|
+
// top-level app, not here, because re-dispatch requires app.fetch().
|
|
81
68
|
// API Reference (Scalar) — disabled in production unless config.exposeOpenApiSpec is true
|
|
82
69
|
const exposeSpec = kernel.config.exposeOpenApiSpec ?? (process.env.NODE_ENV !== "production");
|
|
83
70
|
if (exposeSpec) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/runtime/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKhD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAOzD,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtE,KAAK,SAAS,GAAG;IACf,SAAS,EAAE;QACT,IAAI,EAAE,YAAY,CAAC;QACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,cAAc;;;;;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/runtime/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKhD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAOzD,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtE,KAAK,SAAS,GAAG;IACf,SAAS,EAAE;QACT,IAAI,EAAE,YAAY,CAAC;QACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,cAAc;;;;;GAwYxD"}
|
package/dist/runtime/server.js
CHANGED
|
@@ -194,6 +194,39 @@ export async function createServer(config) {
|
|
|
194
194
|
app.route("/api", createRestRoutes(kernel));
|
|
195
195
|
app.route("/mcp", createMCPHandler(kernel));
|
|
196
196
|
app.route("/api/me", createCustomerPortalRoutes(kernel));
|
|
197
|
+
// ─── Entity aliases (e.g., /api/products → /api/catalog/entities?type=product) ──
|
|
198
|
+
for (const [entityType, entityConfig] of Object.entries(config.entities ?? {})) {
|
|
199
|
+
if (!entityConfig.alias)
|
|
200
|
+
continue;
|
|
201
|
+
const alias = entityConfig.alias;
|
|
202
|
+
// List: inject type filter
|
|
203
|
+
app.all(`/api/${alias}`, async (c) => {
|
|
204
|
+
const url = new URL(c.req.url);
|
|
205
|
+
url.pathname = "/api/catalog/entities";
|
|
206
|
+
if (c.req.method === "GET")
|
|
207
|
+
url.searchParams.set("type", entityType);
|
|
208
|
+
return app.fetch(new Request(url.toString(), c.req.raw));
|
|
209
|
+
});
|
|
210
|
+
// Sub-paths: rewrite /api/{alias}/... → /api/catalog/entities/...
|
|
211
|
+
app.all(`/api/${alias}/:rest{.+}`, async (c) => {
|
|
212
|
+
const url = new URL(c.req.url);
|
|
213
|
+
url.pathname = url.pathname.replace(`/api/${alias}`, "/api/catalog/entities");
|
|
214
|
+
return app.fetch(new Request(url.toString(), c.req.raw));
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
// Static aliases
|
|
218
|
+
for (const [shortcut, target] of [["categories", "catalog/categories"], ["brands", "catalog/brands"]]) {
|
|
219
|
+
app.all(`/api/${shortcut}`, (c) => {
|
|
220
|
+
const url = new URL(c.req.url);
|
|
221
|
+
url.pathname = `/api/${target}`;
|
|
222
|
+
return app.fetch(new Request(url.toString(), c.req.raw));
|
|
223
|
+
});
|
|
224
|
+
app.all(`/api/${shortcut}/:rest{.+}`, (c) => {
|
|
225
|
+
const url = new URL(c.req.url);
|
|
226
|
+
url.pathname = url.pathname.replace(`/api/${shortcut}`, `/api/${target}`);
|
|
227
|
+
return app.fetch(new Request(url.toString(), c.req.raw));
|
|
228
|
+
});
|
|
229
|
+
}
|
|
197
230
|
if (config.routes) {
|
|
198
231
|
config.routes(app, kernel);
|
|
199
232
|
}
|