@unifiedcommerce/core 0.2.0 → 0.2.1
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/package.json +2 -1
- package/src/adapters/console-email.ts +43 -0
- package/src/auth/access.ts +187 -0
- package/src/auth/auth-schema.ts +139 -0
- package/src/auth/middleware.ts +161 -0
- package/src/auth/org.ts +41 -0
- package/src/auth/permissions.ts +28 -0
- package/src/auth/setup.ts +171 -0
- package/src/auth/system-actor.ts +19 -0
- package/src/auth/types.ts +10 -0
- package/src/config/defaults.ts +82 -0
- package/src/config/define-config.ts +53 -0
- package/src/config/types.ts +301 -0
- package/src/generated/plugin-capabilities.d.ts +20 -0
- package/src/generated/plugin-manifest.ts +23 -0
- package/src/generated/plugin-repositories.d.ts +20 -0
- package/src/hooks/checkout-completion.ts +262 -0
- package/src/hooks/checkout.ts +677 -0
- package/src/hooks/order-emails.ts +62 -0
- package/src/index.ts +215 -0
- package/src/interfaces/mcp/agent-prompt.ts +174 -0
- package/src/interfaces/mcp/context-enrichment.ts +177 -0
- package/src/interfaces/mcp/server.ts +47 -0
- package/src/interfaces/mcp/tool-builder.ts +261 -0
- package/src/interfaces/mcp/tools/analytics.ts +76 -0
- package/src/interfaces/mcp/tools/cart.ts +57 -0
- package/src/interfaces/mcp/tools/catalog.ts +299 -0
- package/src/interfaces/mcp/tools/index.ts +22 -0
- package/src/interfaces/mcp/tools/inventory.ts +161 -0
- package/src/interfaces/mcp/tools/orders.ts +104 -0
- package/src/interfaces/mcp/tools/pricing.ts +94 -0
- package/src/interfaces/mcp/tools/promotions.ts +106 -0
- package/src/interfaces/mcp/tools/registry.ts +101 -0
- package/src/interfaces/mcp/tools/search.ts +42 -0
- package/src/interfaces/mcp/tools/webhooks.ts +48 -0
- package/src/interfaces/mcp/transport.ts +128 -0
- package/src/interfaces/rest/customer-portal.ts +299 -0
- package/src/interfaces/rest/index.ts +74 -0
- package/src/interfaces/rest/router.ts +333 -0
- package/src/interfaces/rest/routes/admin-jobs.ts +58 -0
- package/src/interfaces/rest/routes/audit.ts +50 -0
- package/src/interfaces/rest/routes/carts.ts +89 -0
- package/src/interfaces/rest/routes/catalog.ts +493 -0
- package/src/interfaces/rest/routes/checkout.ts +284 -0
- package/src/interfaces/rest/routes/inventory.ts +70 -0
- package/src/interfaces/rest/routes/media.ts +86 -0
- package/src/interfaces/rest/routes/orders.ts +78 -0
- package/src/interfaces/rest/routes/payments.ts +60 -0
- package/src/interfaces/rest/routes/pricing.ts +57 -0
- package/src/interfaces/rest/routes/promotions.ts +93 -0
- package/src/interfaces/rest/routes/search.ts +71 -0
- package/src/interfaces/rest/routes/webhooks.ts +46 -0
- package/src/interfaces/rest/schemas/admin-jobs.ts +40 -0
- package/src/interfaces/rest/schemas/audit.ts +46 -0
- package/src/interfaces/rest/schemas/carts.ts +125 -0
- package/src/interfaces/rest/schemas/catalog.ts +450 -0
- package/src/interfaces/rest/schemas/checkout.ts +66 -0
- package/src/interfaces/rest/schemas/customer-portal.ts +195 -0
- package/src/interfaces/rest/schemas/inventory.ts +138 -0
- package/src/interfaces/rest/schemas/media.ts +75 -0
- package/src/interfaces/rest/schemas/orders.ts +104 -0
- package/src/interfaces/rest/schemas/pricing.ts +80 -0
- package/src/interfaces/rest/schemas/promotions.ts +110 -0
- package/src/interfaces/rest/schemas/responses.ts +85 -0
- package/src/interfaces/rest/schemas/search.ts +58 -0
- package/src/interfaces/rest/schemas/shared.ts +62 -0
- package/src/interfaces/rest/schemas/webhooks.ts +68 -0
- package/src/interfaces/rest/utils.ts +104 -0
- package/src/interfaces/rest/webhook-router.ts +50 -0
- package/src/kernel/compensation/executor.ts +61 -0
- package/src/kernel/compensation/types.ts +26 -0
- package/src/kernel/database/adapter.ts +21 -0
- package/src/kernel/database/drizzle-db.ts +56 -0
- package/src/kernel/database/migrate.ts +76 -0
- package/src/kernel/database/plugin-types.ts +34 -0
- package/src/kernel/database/schema.ts +49 -0
- package/src/kernel/database/scoped-db.ts +68 -0
- package/src/kernel/database/tx-context.ts +46 -0
- package/src/kernel/error-mapper.ts +15 -0
- package/src/kernel/errors.ts +89 -0
- package/src/kernel/factory/repository-factory.ts +244 -0
- package/src/kernel/hooks/create-context.ts +43 -0
- package/src/kernel/hooks/executor.ts +88 -0
- package/src/kernel/hooks/registry.ts +74 -0
- package/src/kernel/hooks/types.ts +52 -0
- package/src/kernel/http-error.ts +44 -0
- package/src/kernel/jobs/adapter.ts +36 -0
- package/src/kernel/jobs/drizzle-adapter.ts +58 -0
- package/src/kernel/jobs/runner.ts +153 -0
- package/src/kernel/jobs/schema.ts +46 -0
- package/src/kernel/jobs/types.ts +30 -0
- package/src/kernel/local-api.ts +187 -0
- package/src/kernel/plugin/manifest.ts +271 -0
- package/src/kernel/query/executor.ts +184 -0
- package/src/kernel/query/registry.ts +46 -0
- package/src/kernel/result.ts +33 -0
- package/src/kernel/schema/extra-columns.ts +37 -0
- package/src/kernel/service-registry.ts +76 -0
- package/src/kernel/service-timing.ts +89 -0
- package/src/kernel/state-machine/machine.ts +101 -0
- package/src/modules/analytics/drizzle-adapter.ts +426 -0
- package/src/modules/analytics/hooks.ts +11 -0
- package/src/modules/analytics/models.ts +125 -0
- package/src/modules/analytics/repository/index.ts +6 -0
- package/src/modules/analytics/service.ts +245 -0
- package/src/modules/analytics/types.ts +180 -0
- package/src/modules/audit/hooks.ts +78 -0
- package/src/modules/audit/schema.ts +33 -0
- package/src/modules/audit/service.ts +151 -0
- package/src/modules/cart/access.ts +27 -0
- package/src/modules/cart/matcher.ts +26 -0
- package/src/modules/cart/repository/index.ts +234 -0
- package/src/modules/cart/schema.ts +42 -0
- package/src/modules/cart/schemas.ts +38 -0
- package/src/modules/cart/service.ts +541 -0
- package/src/modules/catalog/repository/index.ts +772 -0
- package/src/modules/catalog/schema.ts +203 -0
- package/src/modules/catalog/schemas.ts +104 -0
- package/src/modules/catalog/service.ts +1544 -0
- package/src/modules/customers/repository/index.ts +327 -0
- package/src/modules/customers/schema.ts +64 -0
- package/src/modules/customers/service.ts +171 -0
- package/src/modules/fulfillment/repository/index.ts +426 -0
- package/src/modules/fulfillment/schema.ts +101 -0
- package/src/modules/fulfillment/service.ts +555 -0
- package/src/modules/fulfillment/types.ts +59 -0
- package/src/modules/inventory/repository/index.ts +509 -0
- package/src/modules/inventory/schema.ts +94 -0
- package/src/modules/inventory/schemas.ts +38 -0
- package/src/modules/inventory/service.ts +490 -0
- package/src/modules/media/adapter.ts +17 -0
- package/src/modules/media/repository/index.ts +274 -0
- package/src/modules/media/schema.ts +41 -0
- package/src/modules/media/service.ts +151 -0
- package/src/modules/orders/repository/index.ts +287 -0
- package/src/modules/orders/schema.ts +66 -0
- package/src/modules/orders/service.ts +619 -0
- package/src/modules/orders/stale-order-cleanup.ts +76 -0
- package/src/modules/organization/service.ts +191 -0
- package/src/modules/payments/adapter.ts +47 -0
- package/src/modules/payments/repository/index.ts +6 -0
- package/src/modules/payments/service.ts +107 -0
- package/src/modules/pricing/repository/index.ts +291 -0
- package/src/modules/pricing/schema.ts +71 -0
- package/src/modules/pricing/schemas.ts +38 -0
- package/src/modules/pricing/service.ts +494 -0
- package/src/modules/promotions/repository/index.ts +325 -0
- package/src/modules/promotions/schema.ts +62 -0
- package/src/modules/promotions/schemas.ts +38 -0
- package/src/modules/promotions/service.ts +598 -0
- package/src/modules/search/adapter.ts +57 -0
- package/src/modules/search/hooks.ts +12 -0
- package/src/modules/search/repository/index.ts +6 -0
- package/src/modules/search/service.ts +315 -0
- package/src/modules/shipping/calculator.ts +188 -0
- package/src/modules/shipping/repository/index.ts +6 -0
- package/src/modules/shipping/service.ts +51 -0
- package/src/modules/tax/adapter.ts +60 -0
- package/src/modules/tax/repository/index.ts +6 -0
- package/src/modules/tax/service.ts +53 -0
- package/src/modules/webhooks/hook.ts +34 -0
- package/src/modules/webhooks/repository/index.ts +278 -0
- package/src/modules/webhooks/schema.ts +56 -0
- package/src/modules/webhooks/service.ts +117 -0
- package/src/modules/webhooks/signing.ts +6 -0
- package/src/modules/webhooks/ssrf-guard.ts +71 -0
- package/src/modules/webhooks/tasks.ts +52 -0
- package/src/modules/webhooks/worker.ts +134 -0
- package/src/runtime/commerce.ts +145 -0
- package/src/runtime/kernel.ts +426 -0
- package/src/runtime/logger.ts +36 -0
- package/src/runtime/server.ts +355 -0
- package/src/runtime/shutdown.ts +43 -0
- package/src/test-utils/create-pglite-adapter.ts +129 -0
- package/src/test-utils/create-plugin-test-app.ts +128 -0
- package/src/test-utils/create-repository-test-harness.ts +16 -0
- package/src/test-utils/create-test-config.ts +190 -0
- package/src/test-utils/create-test-kernel.ts +7 -0
- package/src/test-utils/create-test-plugin-context.ts +75 -0
- package/src/test-utils/rest-api-test-utils.ts +265 -0
- package/src/test-utils/test-actors.ts +62 -0
- package/src/test-utils/typed-hooks.ts +54 -0
- package/src/types/commerce-types.ts +34 -0
- package/src/utils/id.ts +3 -0
- package/src/utils/logger.ts +18 -0
- package/src/utils/pagination.ts +22 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import type { AnyPgColumn } from "drizzle-orm/pg-core";
|
|
2
|
+
import {
|
|
3
|
+
boolean,
|
|
4
|
+
index,
|
|
5
|
+
integer,
|
|
6
|
+
jsonb,
|
|
7
|
+
pgTable,
|
|
8
|
+
text,
|
|
9
|
+
timestamp,
|
|
10
|
+
uniqueIndex,
|
|
11
|
+
uuid,
|
|
12
|
+
} from "drizzle-orm/pg-core";
|
|
13
|
+
import { organization } from "../../auth/auth-schema.js";
|
|
14
|
+
|
|
15
|
+
export const sellableEntities = pgTable(
|
|
16
|
+
"sellable_entities",
|
|
17
|
+
{
|
|
18
|
+
id: uuid("id").defaultRandom().primaryKey(),
|
|
19
|
+
organizationId: text("organization_id").notNull().references(() => organization.id, { onDelete: "cascade" }),
|
|
20
|
+
type: text("type").notNull(),
|
|
21
|
+
slug: text("slug").notNull(),
|
|
22
|
+
status: text("status", {
|
|
23
|
+
enum: ["draft", "active", "archived", "discontinued"],
|
|
24
|
+
})
|
|
25
|
+
.notNull()
|
|
26
|
+
.default("draft"),
|
|
27
|
+
isVisible: boolean("is_visible").notNull().default(false),
|
|
28
|
+
metadata: jsonb("metadata").$type<Record<string, unknown>>().default({}),
|
|
29
|
+
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
|
|
30
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow().notNull(),
|
|
31
|
+
publishedAt: timestamp("published_at", { withTimezone: true }),
|
|
32
|
+
},
|
|
33
|
+
(table) => ({
|
|
34
|
+
typeIdx: index("idx_sellable_entities_type").on(table.type),
|
|
35
|
+
statusIdx: index("idx_sellable_entities_status").on(table.status),
|
|
36
|
+
slugIdx: index("idx_sellable_entities_slug").on(table.slug),
|
|
37
|
+
orgIdx: index("idx_sellable_entities_org").on(table.organizationId),
|
|
38
|
+
orgSlugUnique: uniqueIndex("sellable_entities_org_slug_unique").on(table.organizationId, table.slug),
|
|
39
|
+
}),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
export const sellableAttributes = pgTable(
|
|
43
|
+
"sellable_attributes",
|
|
44
|
+
{
|
|
45
|
+
id: uuid("id").defaultRandom().primaryKey(),
|
|
46
|
+
entityId: uuid("entity_id")
|
|
47
|
+
.references(() => sellableEntities.id, { onDelete: "cascade" })
|
|
48
|
+
.notNull(),
|
|
49
|
+
locale: text("locale").notNull().default("en"),
|
|
50
|
+
title: text("title").notNull(),
|
|
51
|
+
subtitle: text("subtitle"),
|
|
52
|
+
description: text("description"),
|
|
53
|
+
richDescription: jsonb("rich_description"),
|
|
54
|
+
seoTitle: text("seo_title"),
|
|
55
|
+
seoDescription: text("seo_description"),
|
|
56
|
+
},
|
|
57
|
+
(table) => ({
|
|
58
|
+
entityLocaleIdx: index("idx_sellable_attrs_entity_locale").on(
|
|
59
|
+
table.entityId,
|
|
60
|
+
table.locale,
|
|
61
|
+
),
|
|
62
|
+
}),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
export const sellableCustomFields = pgTable(
|
|
66
|
+
"sellable_custom_fields",
|
|
67
|
+
{
|
|
68
|
+
id: uuid("id").defaultRandom().primaryKey(),
|
|
69
|
+
entityId: uuid("entity_id")
|
|
70
|
+
.references(() => sellableEntities.id, { onDelete: "cascade" })
|
|
71
|
+
.notNull(),
|
|
72
|
+
fieldName: text("field_name").notNull(),
|
|
73
|
+
fieldType: text("field_type", {
|
|
74
|
+
enum: ["text", "number", "boolean", "date", "json", "relation"],
|
|
75
|
+
}).notNull(),
|
|
76
|
+
textValue: text("text_value"),
|
|
77
|
+
numberValue: integer("number_value"),
|
|
78
|
+
booleanValue: boolean("boolean_value"),
|
|
79
|
+
dateValue: timestamp("date_value", { withTimezone: true }),
|
|
80
|
+
jsonValue: jsonb("json_value"),
|
|
81
|
+
},
|
|
82
|
+
(table) => ({
|
|
83
|
+
entityFieldIdx: index("idx_custom_fields_entity_field").on(
|
|
84
|
+
table.entityId,
|
|
85
|
+
table.fieldName,
|
|
86
|
+
),
|
|
87
|
+
textValueIdx: index("idx_custom_fields_text").on(
|
|
88
|
+
table.fieldName,
|
|
89
|
+
table.textValue,
|
|
90
|
+
),
|
|
91
|
+
numberValueIdx: index("idx_custom_fields_number").on(
|
|
92
|
+
table.fieldName,
|
|
93
|
+
table.numberValue,
|
|
94
|
+
),
|
|
95
|
+
}),
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
export const categories = pgTable(
|
|
99
|
+
"categories",
|
|
100
|
+
{
|
|
101
|
+
id: uuid("id").defaultRandom().primaryKey(),
|
|
102
|
+
organizationId: text("organization_id").notNull().references(() => organization.id, { onDelete: "cascade" }),
|
|
103
|
+
// Self-referential FK — Drizzle requires AnyPgColumn for circular references.
|
|
104
|
+
parentId: uuid("parent_id").references((): AnyPgColumn => categories.id, {
|
|
105
|
+
onDelete: "set null",
|
|
106
|
+
}),
|
|
107
|
+
slug: text("slug").notNull(),
|
|
108
|
+
sortOrder: integer("sort_order").notNull().default(0),
|
|
109
|
+
metadata: jsonb("metadata").$type<Record<string, unknown>>().default({}),
|
|
110
|
+
},
|
|
111
|
+
(table) => ({
|
|
112
|
+
orgIdx: index("idx_categories_org").on(table.organizationId),
|
|
113
|
+
orgSlugUnique: uniqueIndex("categories_org_slug_unique").on(table.organizationId, table.slug),
|
|
114
|
+
}),
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
export const entityCategories = pgTable("entity_categories", {
|
|
118
|
+
entityId: uuid("entity_id")
|
|
119
|
+
.references(() => sellableEntities.id, { onDelete: "cascade" })
|
|
120
|
+
.notNull(),
|
|
121
|
+
categoryId: uuid("category_id")
|
|
122
|
+
.references(() => categories.id, { onDelete: "cascade" })
|
|
123
|
+
.notNull(),
|
|
124
|
+
sortOrder: integer("sort_order").notNull().default(0),
|
|
125
|
+
}, (table) => ({
|
|
126
|
+
entityCategoryUnique: uniqueIndex("entity_categories_entity_category_unique").on(table.entityId, table.categoryId),
|
|
127
|
+
}));
|
|
128
|
+
|
|
129
|
+
export const brands = pgTable(
|
|
130
|
+
"brands",
|
|
131
|
+
{
|
|
132
|
+
id: uuid("id").defaultRandom().primaryKey(),
|
|
133
|
+
organizationId: text("organization_id").notNull().references(() => organization.id, { onDelete: "cascade" }),
|
|
134
|
+
slug: text("slug").notNull(),
|
|
135
|
+
displayName: text("display_name").notNull(),
|
|
136
|
+
metadata: jsonb("metadata").$type<Record<string, unknown>>().default({}),
|
|
137
|
+
},
|
|
138
|
+
(table) => ({
|
|
139
|
+
orgIdx: index("idx_brands_org").on(table.organizationId),
|
|
140
|
+
orgSlugUnique: uniqueIndex("brands_org_slug_unique").on(table.organizationId, table.slug),
|
|
141
|
+
}),
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
export const entityBrands = pgTable("entity_brands", {
|
|
145
|
+
entityId: uuid("entity_id")
|
|
146
|
+
.references(() => sellableEntities.id, { onDelete: "cascade" })
|
|
147
|
+
.notNull(),
|
|
148
|
+
brandId: uuid("brand_id")
|
|
149
|
+
.references(() => brands.id, { onDelete: "cascade" })
|
|
150
|
+
.notNull(),
|
|
151
|
+
sortOrder: integer("sort_order").notNull().default(0),
|
|
152
|
+
}, (table) => ({
|
|
153
|
+
entityBrandUnique: uniqueIndex("entity_brands_entity_brand_unique").on(table.entityId, table.brandId),
|
|
154
|
+
}));
|
|
155
|
+
|
|
156
|
+
export const optionTypes = pgTable("option_types", {
|
|
157
|
+
id: uuid("id").defaultRandom().primaryKey(),
|
|
158
|
+
entityId: uuid("entity_id")
|
|
159
|
+
.references(() => sellableEntities.id, { onDelete: "cascade" })
|
|
160
|
+
.notNull(),
|
|
161
|
+
name: text("name").notNull(),
|
|
162
|
+
displayName: text("display_name").notNull(),
|
|
163
|
+
sortOrder: integer("sort_order").notNull().default(0),
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
export const optionValues = pgTable("option_values", {
|
|
167
|
+
id: uuid("id").defaultRandom().primaryKey(),
|
|
168
|
+
optionTypeId: uuid("option_type_id")
|
|
169
|
+
.references(() => optionTypes.id, { onDelete: "cascade" })
|
|
170
|
+
.notNull(),
|
|
171
|
+
value: text("value").notNull(),
|
|
172
|
+
displayValue: text("display_value").notNull(),
|
|
173
|
+
sortOrder: integer("sort_order").notNull().default(0),
|
|
174
|
+
metadata: jsonb("metadata").$type<Record<string, unknown>>().default({}),
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
export const variants = pgTable("variants", {
|
|
178
|
+
id: uuid("id").defaultRandom().primaryKey(),
|
|
179
|
+
entityId: uuid("entity_id")
|
|
180
|
+
.references(() => sellableEntities.id, { onDelete: "cascade" })
|
|
181
|
+
.notNull(),
|
|
182
|
+
sku: text("sku").unique(),
|
|
183
|
+
barcode: text("barcode"),
|
|
184
|
+
status: text("status", { enum: ["active", "discontinued"] })
|
|
185
|
+
.notNull()
|
|
186
|
+
.default("active"),
|
|
187
|
+
sortOrder: integer("sort_order").notNull().default(0),
|
|
188
|
+
metadata: jsonb("metadata").$type<Record<string, unknown>>().default({}),
|
|
189
|
+
}, (table) => ({
|
|
190
|
+
barcodeIdx: index("idx_variants_barcode").on(table.barcode),
|
|
191
|
+
skuIdx: index("idx_variants_sku").on(table.sku),
|
|
192
|
+
}));
|
|
193
|
+
|
|
194
|
+
export const variantOptionValues = pgTable("variant_option_values", {
|
|
195
|
+
variantId: uuid("variant_id")
|
|
196
|
+
.references(() => variants.id, { onDelete: "cascade" })
|
|
197
|
+
.notNull(),
|
|
198
|
+
optionValueId: uuid("option_value_id")
|
|
199
|
+
.references(() => optionValues.id, { onDelete: "cascade" })
|
|
200
|
+
.notNull(),
|
|
201
|
+
}, (table) => ({
|
|
202
|
+
variantOptionValueUnique: uniqueIndex("variant_option_values_variant_option_unique").on(table.variantId, table.optionValueId),
|
|
203
|
+
}));
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
|
|
3
|
+
// ─── Catalog Body Schemas (single source of truth) ──────────────────────────
|
|
4
|
+
|
|
5
|
+
export const CreateEntityBodySchema = z.object({
|
|
6
|
+
type: z.string().openapi({ example: "physicalGood" }),
|
|
7
|
+
slug: z.string().openapi({ example: "my-product" }),
|
|
8
|
+
status: z.string().optional().openapi({ example: "draft" }),
|
|
9
|
+
basePrice: z.number().optional().openapi({ example: 29.99 }),
|
|
10
|
+
currency: z.string().optional().openapi({ example: "USD" }),
|
|
11
|
+
metadata: z.record(z.string(), z.unknown()).optional().openapi({ example: { title: "My Product" } }),
|
|
12
|
+
attributes: z.object({
|
|
13
|
+
locale: z.string().optional(),
|
|
14
|
+
title: z.string(),
|
|
15
|
+
subtitle: z.string().optional(),
|
|
16
|
+
description: z.string().optional(),
|
|
17
|
+
richDescription: z.record(z.string(), z.unknown()).optional(),
|
|
18
|
+
seoTitle: z.string().optional(),
|
|
19
|
+
seoDescription: z.string().optional(),
|
|
20
|
+
}).optional(),
|
|
21
|
+
customFields: z.record(z.string(), z.unknown()).optional(),
|
|
22
|
+
}).openapi("CreateEntityBody");
|
|
23
|
+
|
|
24
|
+
export const UpdateEntityBodySchema = z.object({
|
|
25
|
+
slug: z.string().optional(),
|
|
26
|
+
status: z.string().optional(),
|
|
27
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
28
|
+
isVisible: z.boolean().optional(),
|
|
29
|
+
}).openapi("UpdateEntityBody");
|
|
30
|
+
|
|
31
|
+
export const SetAttributesBodySchema = z.record(z.string(), z.unknown()).openapi("SetAttributesBody");
|
|
32
|
+
|
|
33
|
+
export const CreateCategoryBodySchema = z.object({
|
|
34
|
+
slug: z.string().openapi({ example: "shoes" }),
|
|
35
|
+
parentId: z.uuid().optional(),
|
|
36
|
+
sortOrder: z.number().optional(),
|
|
37
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
38
|
+
}).openapi("CreateCategoryBody");
|
|
39
|
+
|
|
40
|
+
export const UpdateCategoryBodySchema = z.object({
|
|
41
|
+
slug: z.string().optional(),
|
|
42
|
+
parentId: z.uuid().nullable().optional(),
|
|
43
|
+
sortOrder: z.number().optional(),
|
|
44
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
45
|
+
}).openapi("UpdateCategoryBody");
|
|
46
|
+
|
|
47
|
+
export const CreateBrandBodySchema = z.object({
|
|
48
|
+
slug: z.string().openapi({ example: "nike" }),
|
|
49
|
+
displayName: z.string().openapi({ example: "Nike" }),
|
|
50
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
51
|
+
}).openapi("CreateBrandBody");
|
|
52
|
+
|
|
53
|
+
export const UpdateBrandBodySchema = z.object({
|
|
54
|
+
slug: z.string().optional(),
|
|
55
|
+
displayName: z.string().optional(),
|
|
56
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
57
|
+
}).openapi("UpdateBrandBody");
|
|
58
|
+
|
|
59
|
+
export const CreateOptionTypeBodySchema = z.object({
|
|
60
|
+
name: z.string().openapi({ example: "Color" }),
|
|
61
|
+
values: z.array(z.string()).optional().openapi({ example: ["Red", "Blue"] }),
|
|
62
|
+
}).openapi("CreateOptionTypeBody");
|
|
63
|
+
|
|
64
|
+
export const CreateOptionValueBodySchema = z.object({
|
|
65
|
+
value: z.string().openapi({ example: "Green" }),
|
|
66
|
+
}).openapi("CreateOptionValueBody");
|
|
67
|
+
|
|
68
|
+
export const CreateVariantBodySchema = z.object({
|
|
69
|
+
sku: z.string().optional().openapi({ example: "SKU-001" }),
|
|
70
|
+
options: z.record(z.string(), z.string()).openapi({ example: { Color: "Red" } }),
|
|
71
|
+
price: z.number().optional().openapi({ example: 34.99 }),
|
|
72
|
+
}).openapi("CreateVariantBody");
|
|
73
|
+
|
|
74
|
+
export const GenerateVariantsBodySchema = z.object({}).passthrough().openapi("GenerateVariantsBody");
|
|
75
|
+
|
|
76
|
+
// ─── Derived Input Types ─────────────────────────────────────────────────────
|
|
77
|
+
|
|
78
|
+
export type CreateEntityInput = z.infer<typeof CreateEntityBodySchema>;
|
|
79
|
+
|
|
80
|
+
export type UpdateEntityInput = z.infer<typeof UpdateEntityBodySchema>;
|
|
81
|
+
|
|
82
|
+
export type CreateCategoryInput = z.infer<typeof CreateCategoryBodySchema> & {
|
|
83
|
+
id?: string;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export type UpdateCategoryInput = z.infer<typeof UpdateCategoryBodySchema>;
|
|
87
|
+
|
|
88
|
+
export type CreateBrandInput = z.infer<typeof CreateBrandBodySchema> & {
|
|
89
|
+
id?: string;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export type UpdateBrandInput = z.infer<typeof UpdateBrandBodySchema>;
|
|
93
|
+
|
|
94
|
+
export type CreateOptionTypeInput = z.infer<typeof CreateOptionTypeBodySchema> & {
|
|
95
|
+
entityId: string;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export type CreateOptionValueInput = z.infer<typeof CreateOptionValueBodySchema> & {
|
|
99
|
+
optionTypeId: string;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export type CreateVariantInput = z.infer<typeof CreateVariantBodySchema> & {
|
|
103
|
+
entityId: string;
|
|
104
|
+
};
|