@open-mercato/core 0.4.5-develop-f4858e0ef3 → 0.4.5-develop-4849712ccb
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/generated/entities/catalog_product/index.js +16 -0
- package/dist/generated/entities/catalog_product/index.js.map +2 -2
- package/dist/generated/entities/catalog_product_unit_conversion/index.js +27 -0
- package/dist/generated/entities/catalog_product_unit_conversion/index.js.map +7 -0
- package/dist/generated/entities/sales_credit_memo_line/index.js +7 -1
- package/dist/generated/entities/sales_credit_memo_line/index.js.map +2 -2
- package/dist/generated/entities/sales_invoice_line/index.js +7 -1
- package/dist/generated/entities/sales_invoice_line/index.js.map +2 -2
- package/dist/generated/entities/sales_order_line/index.js +6 -0
- package/dist/generated/entities/sales_order_line/index.js.map +2 -2
- package/dist/generated/entities/sales_quote_line/index.js +6 -0
- package/dist/generated/entities/sales_quote_line/index.js.map +2 -2
- package/dist/generated/entities.ids.generated.js +1 -0
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +2 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/modules/catalog/api/prices/route.js +123 -8
- package/dist/modules/catalog/api/prices/route.js.map +2 -2
- package/dist/modules/catalog/api/product-unit-conversions/route.js +194 -0
- package/dist/modules/catalog/api/product-unit-conversions/route.js.map +7 -0
- package/dist/modules/catalog/api/products/route.js +351 -201
- package/dist/modules/catalog/api/products/route.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/[id]/page.js +1267 -497
- package/dist/modules/catalog/backend/catalog/products/[id]/page.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/create/page.js +733 -210
- package/dist/modules/catalog/backend/catalog/products/create/page.js.map +2 -2
- package/dist/modules/catalog/commands/index.js +1 -0
- package/dist/modules/catalog/commands/index.js.map +2 -2
- package/dist/modules/catalog/commands/productUnitConversions.js +503 -0
- package/dist/modules/catalog/commands/productUnitConversions.js.map +7 -0
- package/dist/modules/catalog/commands/products.js +355 -73
- package/dist/modules/catalog/commands/products.js.map +2 -2
- package/dist/modules/catalog/commands/shared.js +18 -4
- package/dist/modules/catalog/commands/shared.js.map +2 -2
- package/dist/modules/catalog/components/products/ProductUomSection.js +591 -0
- package/dist/modules/catalog/components/products/ProductUomSection.js.map +7 -0
- package/dist/modules/catalog/components/products/productForm.js +66 -5
- package/dist/modules/catalog/components/products/productForm.js.map +2 -2
- package/dist/modules/catalog/components/products/productFormUtils.js +68 -0
- package/dist/modules/catalog/components/products/productFormUtils.js.map +7 -0
- package/dist/modules/catalog/data/entities.js +86 -0
- package/dist/modules/catalog/data/entities.js.map +2 -2
- package/dist/modules/catalog/data/validators.js +65 -3
- package/dist/modules/catalog/data/validators.js.map +2 -2
- package/dist/modules/catalog/events.js +3 -0
- package/dist/modules/catalog/events.js.map +2 -2
- package/dist/modules/catalog/lib/unitCodes.js +7 -0
- package/dist/modules/catalog/lib/unitCodes.js.map +7 -0
- package/dist/modules/catalog/lib/unitResolution.js +53 -0
- package/dist/modules/catalog/lib/unitResolution.js.map +7 -0
- package/dist/modules/catalog/migrations/Migration20260218225422.js +19 -0
- package/dist/modules/catalog/migrations/Migration20260218225422.js.map +7 -0
- package/dist/modules/catalog/migrations/Migration20260219084500.js +27 -0
- package/dist/modules/catalog/migrations/Migration20260219084500.js.map +7 -0
- package/dist/modules/catalog/search.js +69 -1
- package/dist/modules/catalog/search.js.map +2 -2
- package/dist/modules/catalog/seed/examples.js +91 -42
- package/dist/modules/catalog/seed/examples.js.map +2 -2
- package/dist/modules/dashboards/seed/analytics.js +3 -0
- package/dist/modules/dashboards/seed/analytics.js.map +2 -2
- package/dist/modules/sales/api/order-lines/route.js +98 -15
- package/dist/modules/sales/api/order-lines/route.js.map +2 -2
- package/dist/modules/sales/api/quote-lines/route.js +101 -14
- package/dist/modules/sales/api/quote-lines/route.js.map +2 -2
- package/dist/modules/sales/api/quotes/public/[token]/route.js +87 -12
- package/dist/modules/sales/api/quotes/public/[token]/route.js.map +2 -2
- package/dist/modules/sales/commands/documents.js +1424 -260
- package/dist/modules/sales/commands/documents.js.map +3 -3
- package/dist/modules/sales/commands/shared.js +6 -2
- package/dist/modules/sales/commands/shared.js.map +2 -2
- package/dist/modules/sales/components/documents/ItemsSection.js +216 -86
- package/dist/modules/sales/components/documents/ItemsSection.js.map +2 -2
- package/dist/modules/sales/components/documents/LineItemDialog.js +913 -241
- package/dist/modules/sales/components/documents/LineItemDialog.js.map +3 -3
- package/dist/modules/sales/components/documents/ShipmentsSection.js +15 -3
- package/dist/modules/sales/components/documents/ShipmentsSection.js.map +2 -2
- package/dist/modules/sales/data/entities.js +59 -3
- package/dist/modules/sales/data/entities.js.map +2 -2
- package/dist/modules/sales/data/validators.js +35 -0
- package/dist/modules/sales/data/validators.js.map +2 -2
- package/dist/modules/sales/frontend/quote/[token]/page.js +15 -1
- package/dist/modules/sales/frontend/quote/[token]/page.js.map +2 -2
- package/dist/modules/sales/migrations/Migration20260218225423.js +31 -0
- package/dist/modules/sales/migrations/Migration20260218225423.js.map +7 -0
- package/dist/modules/sales/migrations/Migration20260219084501.js +71 -0
- package/dist/modules/sales/migrations/Migration20260219084501.js.map +7 -0
- package/dist/modules/sales/search.js +28 -0
- package/dist/modules/sales/search.js.map +2 -2
- package/dist/modules/sales/seed/examples.js +14 -1
- package/dist/modules/sales/seed/examples.js.map +2 -2
- package/dist/modules/sales/widgets/injection/document-history/widget.client.js +1 -1
- package/dist/modules/sales/widgets/injection/document-history/widget.client.js.map +2 -2
- package/generated/entities/catalog_product/index.ts +8 -0
- package/generated/entities/catalog_product_unit_conversion/index.ts +12 -0
- package/generated/entities/sales_credit_memo_line/index.ts +3 -0
- package/generated/entities/sales_invoice_line/index.ts +3 -0
- package/generated/entities/sales_order_line/index.ts +3 -0
- package/generated/entities/sales_quote_line/index.ts +3 -0
- package/generated/entities.ids.generated.ts +1 -0
- package/generated/entity-fields-registry.ts +2 -0
- package/package.json +2 -2
- package/src/modules/auth/i18n/de.json +1 -1
- package/src/modules/auth/i18n/en.json +1 -1
- package/src/modules/auth/i18n/es.json +1 -1
- package/src/modules/auth/i18n/pl.json +1 -1
- package/src/modules/catalog/api/prices/route.ts +213 -81
- package/src/modules/catalog/api/product-unit-conversions/route.ts +195 -0
- package/src/modules/catalog/api/products/route.ts +638 -402
- package/src/modules/catalog/backend/catalog/products/[id]/page.tsx +2085 -1072
- package/src/modules/catalog/backend/catalog/products/create/page.tsx +1288 -593
- package/src/modules/catalog/commands/index.ts +1 -0
- package/src/modules/catalog/commands/productUnitConversions.ts +626 -0
- package/src/modules/catalog/commands/products.ts +1151 -693
- package/src/modules/catalog/commands/shared.ts +19 -5
- package/src/modules/catalog/components/products/ProductUomSection.tsx +745 -0
- package/src/modules/catalog/components/products/productForm.ts +369 -256
- package/src/modules/catalog/components/products/productFormUtils.ts +82 -0
- package/src/modules/catalog/data/entities.ts +82 -1
- package/src/modules/catalog/data/validators.ts +118 -34
- package/src/modules/catalog/events.ts +3 -0
- package/src/modules/catalog/i18n/de.json +56 -0
- package/src/modules/catalog/i18n/en.json +56 -0
- package/src/modules/catalog/i18n/es.json +56 -0
- package/src/modules/catalog/i18n/pl.json +56 -0
- package/src/modules/catalog/lib/unitCodes.ts +1 -0
- package/src/modules/catalog/lib/unitResolution.ts +62 -0
- package/src/modules/catalog/migrations/.snapshot-open-mercato.json +245 -0
- package/src/modules/catalog/migrations/Migration20260218225422.ts +21 -0
- package/src/modules/catalog/migrations/Migration20260219084500.ts +26 -0
- package/src/modules/catalog/search.ts +73 -1
- package/src/modules/catalog/seed/examples.ts +552 -479
- package/src/modules/dashboards/i18n/de.json +1 -1
- package/src/modules/dashboards/i18n/en.json +1 -1
- package/src/modules/dashboards/i18n/es.json +1 -1
- package/src/modules/dashboards/i18n/pl.json +1 -1
- package/src/modules/dashboards/seed/analytics.ts +3 -0
- package/src/modules/sales/api/order-lines/route.ts +158 -68
- package/src/modules/sales/api/quote-lines/route.ts +161 -67
- package/src/modules/sales/api/quotes/public/[token]/route.ts +122 -36
- package/src/modules/sales/commands/documents.ts +4250 -2424
- package/src/modules/sales/commands/shared.ts +7 -2
- package/src/modules/sales/components/documents/ItemsSection.tsx +580 -310
- package/src/modules/sales/components/documents/LineItemDialog.tsx +1988 -833
- package/src/modules/sales/components/documents/ShipmentsSection.tsx +17 -3
- package/src/modules/sales/components/documents/lineItemTypes.ts +6 -0
- package/src/modules/sales/data/entities.ts +53 -0
- package/src/modules/sales/data/validators.ts +36 -0
- package/src/modules/sales/frontend/quote/[token]/page.tsx +25 -1
- package/src/modules/sales/i18n/de.json +23 -3
- package/src/modules/sales/i18n/en.json +23 -3
- package/src/modules/sales/i18n/es.json +23 -3
- package/src/modules/sales/i18n/pl.json +23 -3
- package/src/modules/sales/lib/types.ts +30 -0
- package/src/modules/sales/migrations/.snapshot-open-mercato.json +172 -0
- package/src/modules/sales/migrations/Migration20260218225423.ts +37 -0
- package/src/modules/sales/migrations/Migration20260219084501.ts +73 -0
- package/src/modules/sales/search.ts +28 -0
- package/src/modules/sales/seed/examples.ts +20 -1
- package/src/modules/sales/widgets/injection/document-history/widget.client.tsx +1 -1
- package/src/modules/workflows/i18n/de.json +4 -4
- package/src/modules/workflows/i18n/en.json +4 -4
- package/src/modules/workflows/i18n/es.json +4 -4
- package/src/modules/workflows/i18n/pl.json +4 -4
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { makeCrudRoute } from "@open-mercato/shared/lib/crud/factory";
|
|
3
|
+
import { CrudHttpError } from "@open-mercato/shared/lib/crud/errors";
|
|
4
|
+
import { resolveTranslations } from "@open-mercato/shared/lib/i18n/server";
|
|
5
|
+
import { CatalogProductUnitConversion } from "../../data/entities";
|
|
6
|
+
import {
|
|
7
|
+
productUnitConversionCreateSchema,
|
|
8
|
+
productUnitConversionUpdateSchema,
|
|
9
|
+
productUnitConversionDeleteSchema,
|
|
10
|
+
} from "../../data/validators";
|
|
11
|
+
import { parseScopedCommandInput } from "../utils";
|
|
12
|
+
import {
|
|
13
|
+
createCatalogCrudOpenApi,
|
|
14
|
+
createPagedListResponseSchema,
|
|
15
|
+
defaultCreateResponseSchema,
|
|
16
|
+
defaultOkResponseSchema,
|
|
17
|
+
} from "../openapi";
|
|
18
|
+
import { canonicalizeUnitCode } from "../../lib/unitCodes";
|
|
19
|
+
import { E } from "#generated/entities.ids.generated";
|
|
20
|
+
|
|
21
|
+
const rawBodySchema = z.object({}).passthrough();
|
|
22
|
+
|
|
23
|
+
const listSchema = z
|
|
24
|
+
.object({
|
|
25
|
+
page: z.coerce.number().min(1).default(1),
|
|
26
|
+
pageSize: z.coerce.number().min(1).max(100).default(50),
|
|
27
|
+
id: z.string().uuid().optional(),
|
|
28
|
+
productId: z.string().uuid().optional(),
|
|
29
|
+
unitCode: z.string().trim().max(50).optional(),
|
|
30
|
+
isActive: z.coerce.boolean().optional(),
|
|
31
|
+
sortField: z.string().optional(),
|
|
32
|
+
sortDir: z.enum(["asc", "desc"]).optional(),
|
|
33
|
+
})
|
|
34
|
+
.passthrough();
|
|
35
|
+
|
|
36
|
+
const routeMetadata = {
|
|
37
|
+
GET: { requireAuth: true, requireFeatures: ["catalog.products.view"] },
|
|
38
|
+
POST: { requireAuth: true, requireFeatures: ["catalog.products.manage"] },
|
|
39
|
+
PUT: { requireAuth: true, requireFeatures: ["catalog.products.manage"] },
|
|
40
|
+
DELETE: { requireAuth: true, requireFeatures: ["catalog.products.manage"] },
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const metadata = routeMetadata;
|
|
44
|
+
|
|
45
|
+
const crud = makeCrudRoute({
|
|
46
|
+
metadata: routeMetadata,
|
|
47
|
+
orm: {
|
|
48
|
+
entity: CatalogProductUnitConversion,
|
|
49
|
+
idField: "id",
|
|
50
|
+
orgField: "organizationId",
|
|
51
|
+
tenantField: "tenantId",
|
|
52
|
+
softDeleteField: "deletedAt",
|
|
53
|
+
},
|
|
54
|
+
indexer: {
|
|
55
|
+
entityType: E.catalog.catalog_product_unit_conversion,
|
|
56
|
+
},
|
|
57
|
+
list: {
|
|
58
|
+
schema: listSchema,
|
|
59
|
+
entityId: E.catalog.catalog_product_unit_conversion,
|
|
60
|
+
fields: [
|
|
61
|
+
"id",
|
|
62
|
+
"product_id",
|
|
63
|
+
"unit_code",
|
|
64
|
+
"to_base_factor",
|
|
65
|
+
"sort_order",
|
|
66
|
+
"is_active",
|
|
67
|
+
"metadata",
|
|
68
|
+
"created_at",
|
|
69
|
+
"updated_at",
|
|
70
|
+
],
|
|
71
|
+
sortFieldMap: {
|
|
72
|
+
createdAt: "created_at",
|
|
73
|
+
updatedAt: "updated_at",
|
|
74
|
+
sortOrder: "sort_order",
|
|
75
|
+
unitCode: "unit_code",
|
|
76
|
+
},
|
|
77
|
+
buildFilters: async (query) => {
|
|
78
|
+
const filters: Record<string, unknown> = {};
|
|
79
|
+
if (query.id) filters.id = { $eq: query.id };
|
|
80
|
+
if (query.productId) filters.product_id = { $eq: query.productId };
|
|
81
|
+
const unitCode = canonicalizeUnitCode(query.unitCode);
|
|
82
|
+
if (unitCode) {
|
|
83
|
+
filters.unit_code = { $eq: unitCode };
|
|
84
|
+
}
|
|
85
|
+
if (typeof query.isActive === "boolean") {
|
|
86
|
+
filters.is_active = query.isActive;
|
|
87
|
+
}
|
|
88
|
+
return filters;
|
|
89
|
+
},
|
|
90
|
+
transformItem: (item: Record<string, unknown> | null | undefined) => {
|
|
91
|
+
if (!item) return item;
|
|
92
|
+
const unitCode = canonicalizeUnitCode(
|
|
93
|
+
item["unit_code"] ?? item["unitCode"],
|
|
94
|
+
);
|
|
95
|
+
return {
|
|
96
|
+
...item,
|
|
97
|
+
unit_code: unitCode,
|
|
98
|
+
unitCode,
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
actions: {
|
|
103
|
+
create: {
|
|
104
|
+
commandId: "catalog.product-unit-conversions.create",
|
|
105
|
+
schema: rawBodySchema,
|
|
106
|
+
mapInput: async ({ raw, ctx }) => {
|
|
107
|
+
const { translate } = await resolveTranslations();
|
|
108
|
+
return parseScopedCommandInput(
|
|
109
|
+
productUnitConversionCreateSchema,
|
|
110
|
+
raw ?? {},
|
|
111
|
+
ctx,
|
|
112
|
+
translate,
|
|
113
|
+
);
|
|
114
|
+
},
|
|
115
|
+
response: ({ result }) => ({ id: result?.conversionId ?? null }),
|
|
116
|
+
status: 201,
|
|
117
|
+
},
|
|
118
|
+
update: {
|
|
119
|
+
commandId: "catalog.product-unit-conversions.update",
|
|
120
|
+
schema: rawBodySchema,
|
|
121
|
+
mapInput: async ({ raw, ctx }) => {
|
|
122
|
+
const { translate } = await resolveTranslations();
|
|
123
|
+
return parseScopedCommandInput(
|
|
124
|
+
productUnitConversionUpdateSchema,
|
|
125
|
+
raw ?? {},
|
|
126
|
+
ctx,
|
|
127
|
+
translate,
|
|
128
|
+
);
|
|
129
|
+
},
|
|
130
|
+
response: () => ({ ok: true }),
|
|
131
|
+
},
|
|
132
|
+
delete: {
|
|
133
|
+
commandId: "catalog.product-unit-conversions.delete",
|
|
134
|
+
schema: rawBodySchema,
|
|
135
|
+
mapInput: async ({ raw, ctx }) => {
|
|
136
|
+
const { translate } = await resolveTranslations();
|
|
137
|
+
const parsed = parseScopedCommandInput(
|
|
138
|
+
productUnitConversionDeleteSchema,
|
|
139
|
+
raw ?? {},
|
|
140
|
+
ctx,
|
|
141
|
+
translate,
|
|
142
|
+
);
|
|
143
|
+
if (!parsed.id) {
|
|
144
|
+
throw new CrudHttpError(400, {
|
|
145
|
+
error: translate(
|
|
146
|
+
"catalog.errors.id_required",
|
|
147
|
+
"Record identifier is required.",
|
|
148
|
+
),
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return parsed;
|
|
152
|
+
},
|
|
153
|
+
response: () => ({ ok: true }),
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
export const GET = crud.GET;
|
|
159
|
+
export const POST = crud.POST;
|
|
160
|
+
export const PUT = crud.PUT;
|
|
161
|
+
export const DELETE = crud.DELETE;
|
|
162
|
+
|
|
163
|
+
const conversionListItemSchema = z.object({
|
|
164
|
+
id: z.string().uuid(),
|
|
165
|
+
product_id: z.string().uuid(),
|
|
166
|
+
unit_code: z.string(),
|
|
167
|
+
to_base_factor: z.number(),
|
|
168
|
+
sort_order: z.number().nullable().optional(),
|
|
169
|
+
is_active: z.boolean().nullable().optional(),
|
|
170
|
+
metadata: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
171
|
+
created_at: z.string().nullable().optional(),
|
|
172
|
+
updated_at: z.string().nullable().optional(),
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
export const openApi = createCatalogCrudOpenApi({
|
|
176
|
+
resourceName: "Product unit conversion",
|
|
177
|
+
pluralName: "Product unit conversions",
|
|
178
|
+
querySchema: listSchema,
|
|
179
|
+
listResponseSchema: createPagedListResponseSchema(conversionListItemSchema),
|
|
180
|
+
create: {
|
|
181
|
+
schema: productUnitConversionCreateSchema,
|
|
182
|
+
responseSchema: defaultCreateResponseSchema,
|
|
183
|
+
description: "Creates a product unit conversion.",
|
|
184
|
+
},
|
|
185
|
+
update: {
|
|
186
|
+
schema: productUnitConversionUpdateSchema,
|
|
187
|
+
responseSchema: defaultOkResponseSchema,
|
|
188
|
+
description: "Updates an existing product unit conversion by id.",
|
|
189
|
+
},
|
|
190
|
+
del: {
|
|
191
|
+
schema: productUnitConversionDeleteSchema,
|
|
192
|
+
responseSchema: defaultOkResponseSchema,
|
|
193
|
+
description: "Deletes a product unit conversion by id.",
|
|
194
|
+
},
|
|
195
|
+
});
|