@porulle/core 0.10.8 → 0.13.0
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/auth/auth-schema-guard.d.ts +2444 -0
- package/dist/auth/auth-schema-guard.d.ts.map +1 -0
- package/dist/auth/auth-schema-guard.js +113 -0
- package/dist/auth/auth-schema.d.ts +228 -0
- package/dist/auth/auth-schema.d.ts.map +1 -1
- package/dist/auth/auth-schema.js +24 -2
- package/dist/auth/middleware.d.ts +1 -0
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +13 -5
- package/dist/auth/org.d.ts +8 -2
- package/dist/auth/org.d.ts.map +1 -1
- package/dist/auth/org.js +12 -4
- package/dist/auth/organization-guard.d.ts +5 -0
- package/dist/auth/organization-guard.d.ts.map +1 -0
- package/dist/auth/organization-guard.js +124 -0
- package/dist/auth/permissions.d.ts +10 -0
- package/dist/auth/permissions.d.ts.map +1 -1
- package/dist/auth/permissions.js +31 -7
- package/dist/auth/role-authority.d.ts +44 -0
- package/dist/auth/role-authority.d.ts.map +1 -0
- package/dist/auth/role-authority.js +85 -0
- package/dist/auth/setup.d.ts.map +1 -1
- package/dist/auth/setup.js +17 -0
- package/dist/auth/strict-org-resolution.d.ts.map +1 -1
- package/dist/auth/strict-org-resolution.js +9 -1
- package/dist/auth/types.d.ts +1 -1
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +2 -0
- package/dist/config/types.d.ts +33 -4
- package/dist/config/types.d.ts.map +1 -1
- package/dist/hooks/checkout.d.ts.map +1 -1
- package/dist/hooks/checkout.js +10 -9
- package/dist/index.d.ts +9 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/interfaces/rest/audit-middleware.d.ts.map +1 -1
- package/dist/interfaces/rest/audit-middleware.js +2 -0
- package/dist/interfaces/rest/customer-portal.d.ts.map +1 -1
- package/dist/interfaces/rest/customer-portal.js +9 -8
- package/dist/interfaces/rest/index.d.ts.map +1 -1
- package/dist/interfaces/rest/index.js +4 -0
- package/dist/interfaces/rest/route-coverage.d.ts +14 -0
- package/dist/interfaces/rest/route-coverage.d.ts.map +1 -0
- package/dist/interfaces/rest/route-coverage.js +81 -0
- package/dist/interfaces/rest/router.d.ts +7 -2
- package/dist/interfaces/rest/router.d.ts.map +1 -1
- package/dist/interfaces/rest/router.js +8 -4
- package/dist/interfaces/rest/routes/admin/compensation-failures.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/admin/compensation-failures.js +7 -5
- package/dist/interfaces/rest/routes/admin/custom-field-proposals.d.ts +5 -0
- package/dist/interfaces/rest/routes/admin/custom-field-proposals.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/admin/custom-field-proposals.js +22 -0
- package/dist/interfaces/rest/routes/admin/entity-field-definitions.d.ts +5 -0
- package/dist/interfaces/rest/routes/admin/entity-field-definitions.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/admin/entity-field-definitions.js +39 -0
- package/dist/interfaces/rest/routes/admin/permissions.d.ts +1 -1
- package/dist/interfaces/rest/routes/admin/permissions.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/admin/permissions.js +2 -0
- package/dist/interfaces/rest/routes/admin/staff.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/admin/staff.js +126 -66
- package/dist/interfaces/rest/routes/admin-jobs.js +3 -3
- package/dist/interfaces/rest/routes/audit.js +3 -3
- package/dist/interfaces/rest/routes/carts.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/carts.js +13 -10
- package/dist/interfaces/rest/routes/catalog.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/catalog.js +47 -4
- package/dist/interfaces/rest/routes/checkout.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/checkout.js +30 -35
- package/dist/interfaces/rest/routes/documents.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/documents.js +10 -5
- package/dist/interfaces/rest/routes/inventory.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/inventory.js +2 -0
- package/dist/interfaces/rest/routes/media.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/media.js +7 -3
- package/dist/interfaces/rest/routes/orders.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/orders.js +26 -8
- package/dist/interfaces/rest/routes/pricing.js +2 -2
- package/dist/interfaces/rest/routes/promotions.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/promotions.js +13 -10
- package/dist/interfaces/rest/routes/search.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/search.js +14 -1
- package/dist/interfaces/rest/schemas/admin-custom-field-proposals.d.ts +134 -0
- package/dist/interfaces/rest/schemas/admin-custom-field-proposals.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/admin-custom-field-proposals.js +26 -0
- package/dist/interfaces/rest/schemas/admin-entity-field-definitions.d.ts +592 -0
- package/dist/interfaces/rest/schemas/admin-entity-field-definitions.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/admin-entity-field-definitions.js +109 -0
- package/dist/interfaces/rest/schemas/carts.d.ts +7 -0
- package/dist/interfaces/rest/schemas/carts.d.ts.map +1 -1
- package/dist/interfaces/rest/schemas/catalog.d.ts +1364 -401
- package/dist/interfaces/rest/schemas/catalog.d.ts.map +1 -1
- package/dist/interfaces/rest/schemas/catalog.js +86 -0
- package/dist/interfaces/rest/schemas/customer-portal.d.ts +35 -0
- package/dist/interfaces/rest/schemas/customer-portal.d.ts.map +1 -1
- package/dist/interfaces/rest/schemas/orders.d.ts +204 -0
- package/dist/interfaces/rest/schemas/orders.d.ts.map +1 -1
- package/dist/interfaces/rest/schemas/pricing.d.ts +1 -0
- package/dist/interfaces/rest/schemas/pricing.d.ts.map +1 -1
- package/dist/interfaces/rest/schemas/responses.d.ts +71 -0
- package/dist/interfaces/rest/schemas/responses.d.ts.map +1 -1
- package/dist/interfaces/rest/schemas/search.d.ts +1 -0
- package/dist/interfaces/rest/schemas/search.d.ts.map +1 -1
- package/dist/interfaces/rest/schemas/search.js +1 -0
- package/dist/interfaces/rest/utils.d.ts +15 -0
- package/dist/interfaces/rest/utils.d.ts.map +1 -1
- package/dist/interfaces/rest/utils.js +45 -2
- package/dist/kernel/compensation/executor.js +2 -2
- package/dist/kernel/database/tx-context.d.ts +8 -0
- package/dist/kernel/database/tx-context.d.ts.map +1 -1
- package/dist/kernel/database/tx-context.js +13 -0
- package/dist/kernel/hooks/create-context.d.ts +2 -0
- package/dist/kernel/hooks/create-context.d.ts.map +1 -1
- package/dist/kernel/hooks/create-context.js +1 -0
- package/dist/kernel/hooks/types.d.ts +2 -0
- package/dist/kernel/hooks/types.d.ts.map +1 -1
- package/dist/kernel/plugin/manifest.d.ts.map +1 -1
- package/dist/kernel/plugin/manifest.js +9 -5
- package/dist/modules/analytics/service.js +2 -2
- package/dist/modules/audit/service.js +3 -3
- package/dist/modules/cart/repository/index.d.ts +13 -7
- package/dist/modules/cart/repository/index.d.ts.map +1 -1
- package/dist/modules/cart/repository/index.js +16 -10
- package/dist/modules/cart/schema.d.ts +17 -0
- package/dist/modules/cart/schema.d.ts.map +1 -1
- package/dist/modules/cart/schema.js +4 -0
- package/dist/modules/cart/service.d.ts +22 -9
- package/dist/modules/cart/service.d.ts.map +1 -1
- package/dist/modules/cart/service.js +57 -33
- package/dist/modules/catalog/brand-service.js +7 -7
- package/dist/modules/catalog/category-service.js +7 -7
- package/dist/modules/catalog/entity-service.d.ts +19 -10
- package/dist/modules/catalog/entity-service.d.ts.map +1 -1
- package/dist/modules/catalog/entity-service.js +180 -51
- package/dist/modules/catalog/module.d.ts +6 -1
- package/dist/modules/catalog/module.d.ts.map +1 -1
- package/dist/modules/catalog/module.js +6 -1
- package/dist/modules/catalog/ownership.d.ts +5 -0
- package/dist/modules/catalog/ownership.d.ts.map +1 -0
- package/dist/modules/catalog/ownership.js +11 -0
- package/dist/modules/catalog/read-policy.d.ts +9 -0
- package/dist/modules/catalog/read-policy.d.ts.map +1 -0
- package/dist/modules/catalog/read-policy.js +8 -0
- package/dist/modules/catalog/repository/index.d.ts +55 -3
- package/dist/modules/catalog/repository/index.d.ts.map +1 -1
- package/dist/modules/catalog/repository/index.js +335 -6
- package/dist/modules/catalog/revision.d.ts +4 -0
- package/dist/modules/catalog/revision.d.ts.map +1 -0
- package/dist/modules/catalog/revision.js +33 -0
- package/dist/modules/catalog/schema.d.ts +979 -110
- package/dist/modules/catalog/schema.d.ts.map +1 -1
- package/dist/modules/catalog/schema.js +112 -2
- package/dist/modules/catalog/schemas.d.ts +2 -0
- package/dist/modules/catalog/schemas.d.ts.map +1 -1
- package/dist/modules/catalog/schemas.js +2 -0
- package/dist/modules/catalog/service.d.ts +80 -15
- package/dist/modules/catalog/service.d.ts.map +1 -1
- package/dist/modules/catalog/service.js +522 -14
- package/dist/modules/channels/adapter.d.ts +85 -0
- package/dist/modules/channels/adapter.d.ts.map +1 -1
- package/dist/modules/channels/adapter.js +9 -1
- package/dist/modules/customers/module.d.ts.map +1 -1
- package/dist/modules/customers/module.js +1 -0
- package/dist/modules/customers/service.d.ts +2 -0
- package/dist/modules/customers/service.d.ts.map +1 -1
- package/dist/modules/customers/service.js +21 -20
- package/dist/modules/documents/module.d.ts.map +1 -1
- package/dist/modules/documents/module.js +1 -0
- package/dist/modules/documents/service.d.ts +18 -4
- package/dist/modules/documents/service.d.ts.map +1 -1
- package/dist/modules/documents/service.js +54 -16
- package/dist/modules/fulfillment/module.d.ts.map +1 -1
- package/dist/modules/fulfillment/module.js +1 -0
- package/dist/modules/fulfillment/service.d.ts +2 -0
- package/dist/modules/fulfillment/service.d.ts.map +1 -1
- package/dist/modules/fulfillment/service.js +15 -6
- package/dist/modules/inventory/service.d.ts.map +1 -1
- package/dist/modules/inventory/service.js +15 -14
- package/dist/modules/media/module.d.ts +68 -0
- package/dist/modules/media/module.d.ts.map +1 -1
- package/dist/modules/media/module.js +2 -0
- package/dist/modules/media/schema.d.ts +70 -0
- package/dist/modules/media/schema.d.ts.map +1 -1
- package/dist/modules/media/schema.js +20 -2
- package/dist/modules/media/service.d.ts +8 -1
- package/dist/modules/media/service.d.ts.map +1 -1
- package/dist/modules/media/service.js +71 -23
- package/dist/modules/orders/guest-access.d.ts +27 -0
- package/dist/modules/orders/guest-access.d.ts.map +1 -0
- package/dist/modules/orders/guest-access.js +46 -0
- package/dist/modules/orders/module.d.ts.map +1 -1
- package/dist/modules/orders/module.js +1 -0
- package/dist/modules/orders/quote.d.ts.map +1 -1
- package/dist/modules/orders/quote.js +1 -0
- package/dist/modules/orders/repository/index.d.ts +1 -1
- package/dist/modules/orders/repository/index.d.ts.map +1 -1
- package/dist/modules/orders/repository/index.js +2 -2
- package/dist/modules/orders/schema.d.ts +17 -0
- package/dist/modules/orders/schema.d.ts.map +1 -1
- package/dist/modules/orders/schema.js +5 -3
- package/dist/modules/orders/service.d.ts +16 -7
- package/dist/modules/orders/service.d.ts.map +1 -1
- package/dist/modules/orders/service.js +184 -55
- package/dist/modules/pricing/module.d.ts.map +1 -1
- package/dist/modules/pricing/module.js +1 -0
- package/dist/modules/pricing/schema.d.ts +17 -0
- package/dist/modules/pricing/schema.d.ts.map +1 -1
- package/dist/modules/pricing/schema.js +1 -0
- package/dist/modules/pricing/schemas.d.ts +1 -0
- package/dist/modules/pricing/schemas.d.ts.map +1 -1
- package/dist/modules/pricing/schemas.js +1 -0
- package/dist/modules/pricing/service.d.ts +2 -0
- package/dist/modules/pricing/service.d.ts.map +1 -1
- package/dist/modules/pricing/service.js +18 -12
- package/dist/modules/promotions/module.d.ts.map +1 -1
- package/dist/modules/promotions/module.js +1 -0
- package/dist/modules/promotions/service.d.ts +3 -0
- package/dist/modules/promotions/service.d.ts.map +1 -1
- package/dist/modules/promotions/service.js +19 -11
- package/dist/modules/search/adapter.d.ts +8 -0
- package/dist/modules/search/adapter.d.ts.map +1 -1
- package/dist/modules/search/module.d.ts.map +1 -1
- package/dist/modules/search/module.js +3 -0
- package/dist/modules/search/service.d.ts +5 -0
- package/dist/modules/search/service.d.ts.map +1 -1
- package/dist/modules/search/service.js +131 -11
- package/dist/modules/settings/module.d.ts.map +1 -1
- package/dist/modules/settings/module.js +1 -0
- package/dist/modules/settings/service.d.ts +3 -0
- package/dist/modules/settings/service.d.ts.map +1 -1
- package/dist/modules/settings/service.js +6 -4
- package/dist/modules/shipping/service.js +9 -9
- package/dist/modules/tax/module.d.ts.map +1 -1
- package/dist/modules/tax/module.js +1 -0
- package/dist/modules/tax/service.d.ts +3 -0
- package/dist/modules/tax/service.d.ts.map +1 -1
- package/dist/modules/tax/service.js +11 -9
- package/dist/modules/webhooks/hook.js +2 -2
- package/dist/modules/webhooks/module.d.ts.map +1 -1
- package/dist/modules/webhooks/module.js +1 -0
- package/dist/modules/webhooks/service.d.ts +2 -0
- package/dist/modules/webhooks/service.d.ts.map +1 -1
- package/dist/modules/webhooks/service.js +4 -4
- package/dist/runtime/kernel-modules.d.ts +73 -0
- package/dist/runtime/kernel-modules.d.ts.map +1 -1
- package/dist/runtime/server.d.ts.map +1 -1
- package/dist/runtime/server.js +10 -2
- package/dist/test-utils/create-pglite-adapter.d.ts.map +1 -1
- package/dist/test-utils/create-pglite-adapter.js +35 -13
- package/dist/test-utils/create-test-config.d.ts.map +1 -1
- package/dist/test-utils/create-test-config.js +4 -0
- package/dist/test-utils/rest-api-test-utils.d.ts.map +1 -1
- package/dist/test-utils/rest-api-test-utils.js +2 -0
- package/dist/test-utils/test-actors.js +2 -2
- package/dist/utils/id.d.ts +2 -0
- package/dist/utils/id.d.ts.map +1 -1
- package/dist/utils/id.js +11 -0
- package/package.json +6 -5
- package/src/auth/auth-schema-guard.ts +143 -0
- package/src/auth/auth-schema.ts +50 -19
- package/src/auth/middleware.ts +17 -5
- package/src/auth/org.ts +15 -3
- package/src/auth/organization-guard.ts +158 -0
- package/src/auth/permissions.ts +31 -8
- package/src/auth/role-authority.ts +107 -0
- package/src/auth/setup.ts +17 -0
- package/src/auth/strict-org-resolution.ts +7 -1
- package/src/auth/types.ts +1 -1
- package/src/config/defaults.ts +2 -0
- package/src/config/types.ts +32 -4
- package/src/hooks/checkout.ts +19 -12
- package/src/index.ts +30 -6
- package/src/interfaces/rest/audit-middleware.ts +2 -0
- package/src/interfaces/rest/customer-portal.ts +31 -24
- package/src/interfaces/rest/index.ts +4 -0
- package/src/interfaces/rest/route-coverage.ts +103 -0
- package/src/interfaces/rest/router.ts +16 -10
- package/src/interfaces/rest/routes/admin/compensation-failures.ts +8 -5
- package/src/interfaces/rest/routes/admin/custom-field-proposals.ts +37 -0
- package/src/interfaces/rest/routes/admin/entity-field-definitions.ts +89 -0
- package/src/interfaces/rest/routes/admin/permissions.ts +3 -1
- package/src/interfaces/rest/routes/admin/staff.ts +161 -72
- package/src/interfaces/rest/routes/admin-jobs.ts +3 -3
- package/src/interfaces/rest/routes/audit.ts +3 -3
- package/src/interfaces/rest/routes/carts.ts +17 -7
- package/src/interfaces/rest/routes/catalog.ts +96 -0
- package/src/interfaces/rest/routes/checkout.ts +41 -38
- package/src/interfaces/rest/routes/documents.ts +15 -1
- package/src/interfaces/rest/routes/inventory.ts +2 -0
- package/src/interfaces/rest/routes/media.ts +8 -3
- package/src/interfaces/rest/routes/orders.ts +27 -8
- package/src/interfaces/rest/routes/pricing.ts +2 -2
- package/src/interfaces/rest/routes/promotions.ts +12 -9
- package/src/interfaces/rest/routes/search.ts +19 -1
- package/src/interfaces/rest/schemas/admin-custom-field-proposals.ts +29 -0
- package/src/interfaces/rest/schemas/admin-entity-field-definitions.ts +120 -0
- package/src/interfaces/rest/schemas/catalog.ts +92 -0
- package/src/interfaces/rest/schemas/search.ts +2 -0
- package/src/interfaces/rest/utils.ts +61 -2
- package/src/kernel/compensation/executor.ts +2 -2
- package/src/kernel/database/tx-context.ts +25 -0
- package/src/kernel/hooks/create-context.ts +3 -0
- package/src/kernel/hooks/types.ts +2 -0
- package/src/kernel/plugin/manifest.ts +9 -5
- package/src/modules/analytics/service.ts +2 -2
- package/src/modules/audit/service.ts +3 -3
- package/src/modules/cart/repository/index.ts +22 -8
- package/src/modules/cart/schema.ts +4 -0
- package/src/modules/cart/service.ts +62 -27
- package/src/modules/catalog/brand-service.ts +7 -7
- package/src/modules/catalog/category-service.ts +7 -7
- package/src/modules/catalog/entity-service.ts +188 -53
- package/src/modules/catalog/module.ts +15 -0
- package/src/modules/catalog/ownership.ts +17 -0
- package/src/modules/catalog/read-policy.ts +16 -0
- package/src/modules/catalog/repository/index.ts +566 -4
- package/src/modules/catalog/revision.ts +35 -0
- package/src/modules/catalog/schema.ts +169 -1
- package/src/modules/catalog/schemas.ts +2 -0
- package/src/modules/catalog/service.ts +766 -26
- package/src/modules/channels/adapter.ts +107 -1
- package/src/modules/customers/module.ts +2 -0
- package/src/modules/customers/service.ts +23 -22
- package/src/modules/documents/module.ts +2 -0
- package/src/modules/documents/service.ts +74 -11
- package/src/modules/fulfillment/module.ts +2 -0
- package/src/modules/fulfillment/service.ts +17 -6
- package/src/modules/inventory/service.ts +15 -24
- package/src/modules/media/module.ts +2 -0
- package/src/modules/media/schema.ts +23 -2
- package/src/modules/media/service.ts +89 -28
- package/src/modules/orders/guest-access.ts +55 -0
- package/src/modules/orders/module.ts +1 -0
- package/src/modules/orders/quote.ts +1 -0
- package/src/modules/orders/repository/index.ts +2 -0
- package/src/modules/orders/schema.ts +5 -3
- package/src/modules/orders/service.ts +302 -52
- package/src/modules/pricing/module.ts +2 -0
- package/src/modules/pricing/schema.ts +1 -0
- package/src/modules/pricing/schemas.ts +1 -0
- package/src/modules/pricing/service.ts +21 -18
- package/src/modules/promotions/module.ts +2 -0
- package/src/modules/promotions/service.ts +25 -16
- package/src/modules/search/adapter.ts +8 -0
- package/src/modules/search/module.ts +3 -0
- package/src/modules/search/service.ts +142 -12
- package/src/modules/settings/module.ts +2 -0
- package/src/modules/settings/service.ts +8 -4
- package/src/modules/shipping/service.ts +9 -9
- package/src/modules/tax/module.ts +1 -0
- package/src/modules/tax/service.ts +13 -9
- package/src/modules/webhooks/hook.ts +2 -2
- package/src/modules/webhooks/module.ts +2 -0
- package/src/modules/webhooks/service.ts +6 -4
- package/src/runtime/server.ts +16 -2
- package/src/test-utils/create-pglite-adapter.ts +34 -12
- package/src/test-utils/create-test-config.ts +10 -6
- package/src/test-utils/rest-api-test-utils.ts +2 -0
- package/src/test-utils/test-actors.ts +2 -2
- package/src/utils/id.ts +20 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
2
|
import { emailInvoiceRoute, invoiceHtmlRoute, invoicePdfRoute, receiptHtmlRoute, } from "../schemas/documents.js";
|
|
3
|
-
import { mapErrorToResponse, mapErrorToStatus } from "../utils.js";
|
|
3
|
+
import { mapErrorToResponse, mapErrorToStatus, requireAnyPerm } from "../utils.js";
|
|
4
4
|
/**
|
|
5
5
|
* Order document rendering (issue #47). Mounted under /orders. Access
|
|
6
6
|
* control rides on OrderService.getById (orders:read, or orders:read:own
|
|
@@ -8,8 +8,10 @@ import { mapErrorToResponse, mapErrorToStatus } from "../utils.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export function documentRoutes(kernel) {
|
|
10
10
|
const router = new OpenAPIHono();
|
|
11
|
+
router.use("/*", requireAnyPerm(["orders:read", "orders:read:own"]));
|
|
11
12
|
router.openapi(invoicePdfRoute, async (c) => {
|
|
12
|
-
const
|
|
13
|
+
const guestCredential = c.req.header("x-cart-secret") ?? c.req.header("X-Cart-Secret") ?? undefined;
|
|
14
|
+
const result = await kernel.services.documents.renderInvoicePdf(c.req.param("id"), c.get("actor"), undefined, guestCredential);
|
|
13
15
|
if (!result.ok)
|
|
14
16
|
return c.json(mapErrorToResponse(result.error), mapErrorToStatus(result.error));
|
|
15
17
|
return c.body(result.value.pdf.slice().buffer, 200, {
|
|
@@ -18,20 +20,23 @@ export function documentRoutes(kernel) {
|
|
|
18
20
|
});
|
|
19
21
|
});
|
|
20
22
|
router.openapi(invoiceHtmlRoute, async (c) => {
|
|
21
|
-
const
|
|
23
|
+
const guestCredential = c.req.header("x-cart-secret") ?? c.req.header("X-Cart-Secret") ?? undefined;
|
|
24
|
+
const result = await kernel.services.documents.renderInvoiceHtml(c.req.param("id"), c.get("actor"), undefined, guestCredential);
|
|
22
25
|
if (!result.ok)
|
|
23
26
|
return c.json(mapErrorToResponse(result.error), mapErrorToStatus(result.error));
|
|
24
27
|
return c.html(result.value.html);
|
|
25
28
|
});
|
|
26
29
|
router.openapi(receiptHtmlRoute, async (c) => {
|
|
27
|
-
const
|
|
30
|
+
const guestCredential = c.req.header("x-cart-secret") ?? c.req.header("X-Cart-Secret") ?? undefined;
|
|
31
|
+
const result = await kernel.services.documents.renderReceiptHtml(c.req.param("id"), c.get("actor"), undefined, guestCredential);
|
|
28
32
|
if (!result.ok)
|
|
29
33
|
return c.json(mapErrorToResponse(result.error), mapErrorToStatus(result.error));
|
|
30
34
|
return c.html(result.value.html);
|
|
31
35
|
});
|
|
32
36
|
// @ts-expect-error -- openapi handler union return type
|
|
33
37
|
router.openapi(emailInvoiceRoute, async (c) => {
|
|
34
|
-
const
|
|
38
|
+
const guestCredential = c.req.header("x-cart-secret") ?? c.req.header("X-Cart-Secret") ?? undefined;
|
|
39
|
+
const result = await kernel.services.documents.emailInvoice(c.req.param("id"), c.req.valid("json").to, c.get("actor"), undefined, guestCredential);
|
|
35
40
|
if (!result.ok)
|
|
36
41
|
return c.json(mapErrorToResponse(result.error), mapErrorToStatus(result.error));
|
|
37
42
|
return c.json({ data: result.value });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inventory.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/rest/routes/inventory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAUzD,OAAO,EAAE,KAAK,MAAM,EAAqD,MAAM,aAAa,CAAC;AAE7F,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"inventory.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/rest/routes/inventory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAUzD,OAAO,EAAE,KAAK,MAAM,EAAqD,MAAM,aAAa,CAAC;AAE7F,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,gCAiG7C"}
|
|
@@ -12,6 +12,8 @@ export function inventoryRoutes(kernel) {
|
|
|
12
12
|
router.use("/warehouses", requirePerm("inventory:read"));
|
|
13
13
|
router.use("/reserve", requirePerm("inventory:adjust"));
|
|
14
14
|
router.use("/release", requirePerm("inventory:adjust"));
|
|
15
|
+
router.use("/check", requirePerm("inventory:read"));
|
|
16
|
+
router.use("/adjust", requirePerm("inventory:adjust"));
|
|
15
17
|
// @ts-expect-error -- openapi handler union return type
|
|
16
18
|
router.openapi(listInventoryLevelsRoute, async (c) => {
|
|
17
19
|
const actor = c.get("actor");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/rest/routes/media.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGzD,OAAO,EAAE,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/rest/routes/media.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGzD,OAAO,EAAE,KAAK,MAAM,EAAwE,MAAM,aAAa,CAAC;AAEhH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,gCA4FzC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
2
|
import { attachMediaRoute, getMediaRoute, deleteMediaRoute } from "../schemas/media.js";
|
|
3
|
-
import { mapErrorToResponse, mapErrorToStatus, requirePerm } from "../utils.js";
|
|
3
|
+
import { mapErrorToResponse, mapErrorToStatus, requireMethodPerm, requirePerm } from "../utils.js";
|
|
4
4
|
export function mediaRoutes(kernel) {
|
|
5
5
|
const router = new OpenAPIHono();
|
|
6
6
|
// Upload requires authentication + media:write permission
|
|
7
7
|
router.use("/upload", requirePerm("media:write"));
|
|
8
|
+
router.use("/:id", requireMethodPerm(["DELETE"], "media:write"));
|
|
8
9
|
router.post("/upload", async (c) => {
|
|
9
10
|
// No storage configured (the default no-op adapter) → media is disabled.
|
|
10
11
|
if (kernel.config.storage?.providerId === "noop") {
|
|
@@ -32,11 +33,14 @@ export function mediaRoutes(kernel) {
|
|
|
32
33
|
});
|
|
33
34
|
router.openapi(getMediaRoute, async (c) => {
|
|
34
35
|
const signed = c.req.query("signed") === "true";
|
|
36
|
+
const actor = c.get("actor");
|
|
37
|
+
if (!actor && !signed) {
|
|
38
|
+
return c.json({ error: { code: "NOT_FOUND", message: "Media not found." } }, 404);
|
|
39
|
+
}
|
|
35
40
|
// Signed URLs require authentication
|
|
36
|
-
if (signed && !
|
|
41
|
+
if (signed && !actor) {
|
|
37
42
|
return c.json({ error: { code: "UNAUTHORIZED", message: "Authentication required for signed URLs." } }, 401);
|
|
38
43
|
}
|
|
39
|
-
const actor = c.get("actor");
|
|
40
44
|
const result = signed
|
|
41
45
|
? await kernel.services.media.getSignedUrl(c.req.param("id"), undefined, actor)
|
|
42
46
|
: await kernel.services.media.getUrl(c.req.param("id"), actor);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orders.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/rest/routes/orders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"orders.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/rest/routes/orders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,KAAK,MAAM,EAAiH,MAAM,aAAa,CAAC;AAKzJ,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,gCAqUzC"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
2
|
import { changeOrderStatusRoute, listOrdersRoute, orderLookupRoute, getOrderRoute, getOrderFulfillmentsRoute, createOrderRoute, quoteOrderRoute, refundOrderRoute, captureOrderRoute, createOrderFulfillmentRoute, addOrderLineItemRoute, updateOrderLineItemRoute, removeOrderLineItemRoute, refundOrderLinesRoute, undoOrderRefundRoute, listOrderRefundsRoute, refundCapStatusRoute, createOrderNoteRoute, listOrderNotesRoute, deleteOrderNoteRoute, orderTimelineRoute } from "../schemas/orders.js";
|
|
3
|
-
import { isUUID, mapErrorToResponse, mapErrorToStatus, parsePagination } from "../utils.js";
|
|
3
|
+
import { isUUID, mapErrorToResponse, mapErrorToStatus, parsePagination, requireAnyPerm, requireMethodPerm, requirePerm } from "../utils.js";
|
|
4
4
|
import { computeOrderPricing } from "../../../modules/orders/quote.js";
|
|
5
5
|
import { assertPermission } from "../../../auth/permissions.js";
|
|
6
6
|
export function orderRoutes(kernel) {
|
|
7
7
|
const router = new OpenAPIHono();
|
|
8
|
+
router.use("/", requireMethodPerm(["GET"], "orders:read"));
|
|
9
|
+
router.use("/", requireMethodPerm(["POST"], "orders:create"));
|
|
10
|
+
router.use("/lookup", requirePerm("orders:read"));
|
|
11
|
+
router.use("/:idOrNumber", requireAnyPerm(["orders:read", "orders:read:own"]));
|
|
12
|
+
router.use("/:id/*", requireAnyPerm(["orders:read", "orders:read:own", "orders:update", "orders:manage"]));
|
|
13
|
+
router.use("/refunds/cap", requirePerm("orders:read"));
|
|
8
14
|
// @ts-expect-error -- openapi handler union return type
|
|
9
15
|
router.openapi(listOrdersRoute, async (c) => {
|
|
10
16
|
const pagination = parsePagination(c.req.query());
|
|
@@ -48,9 +54,10 @@ export function orderRoutes(kernel) {
|
|
|
48
54
|
// @ts-expect-error -- openapi handler union return type
|
|
49
55
|
router.openapi(getOrderRoute, async (c) => {
|
|
50
56
|
const idOrNumber = c.req.param("idOrNumber");
|
|
57
|
+
const guestCredential = c.req.header("x-cart-secret") ?? c.req.header("X-Cart-Secret") ?? undefined;
|
|
51
58
|
const result = isUUID(idOrNumber)
|
|
52
|
-
? await kernel.services.orders.getById(idOrNumber, c.get("actor"))
|
|
53
|
-
: await kernel.services.orders.getByNumber(idOrNumber, c.get("actor"));
|
|
59
|
+
? await kernel.services.orders.getById(idOrNumber, c.get("actor"), undefined, guestCredential)
|
|
60
|
+
: await kernel.services.orders.getByNumber(idOrNumber, c.get("actor"), undefined, guestCredential);
|
|
54
61
|
if (!result.ok)
|
|
55
62
|
return c.json(mapErrorToResponse(result.error), mapErrorToStatus(result.error));
|
|
56
63
|
return c.json({ data: result.value });
|
|
@@ -58,13 +65,16 @@ export function orderRoutes(kernel) {
|
|
|
58
65
|
// @ts-expect-error -- openapi handler union return type
|
|
59
66
|
router.openapi(createOrderRoute, async (c) => {
|
|
60
67
|
try {
|
|
61
|
-
assertPermission(c.get("actor"), "orders:
|
|
68
|
+
assertPermission(c.get("actor"), "orders:create");
|
|
62
69
|
}
|
|
63
70
|
catch (error) {
|
|
64
71
|
return c.json(mapErrorToResponse(error), mapErrorToStatus(error));
|
|
65
72
|
}
|
|
66
73
|
const body = c.req.valid("json");
|
|
67
|
-
const
|
|
74
|
+
const guestCredential = c.req.header("x-cart-secret") ?? c.req.header("X-Cart-Secret") ?? undefined;
|
|
75
|
+
const result = await kernel.services.orders.create(body, c.get("actor"), undefined, {
|
|
76
|
+
...(guestCredential !== undefined ? { guestCredential } : {}),
|
|
77
|
+
});
|
|
68
78
|
if (!result.ok)
|
|
69
79
|
return c.json(mapErrorToResponse(result.error), mapErrorToStatus(result.error));
|
|
70
80
|
return c.json({ data: result.value }, 201);
|
|
@@ -216,8 +226,15 @@ export function orderRoutes(kernel) {
|
|
|
216
226
|
router.openapi(createOrderFulfillmentRoute, async (c) => {
|
|
217
227
|
const actor = c.get("actor");
|
|
218
228
|
const orderId = c.req.param("id");
|
|
229
|
+
try {
|
|
230
|
+
assertPermission(actor, "orders:update");
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
return c.json(mapErrorToResponse(error), mapErrorToStatus(error));
|
|
234
|
+
}
|
|
235
|
+
const guestCredential = c.req.header("x-cart-secret") ?? c.req.header("X-Cart-Secret") ?? undefined;
|
|
219
236
|
// Verify the order exists and the actor has access before recording
|
|
220
|
-
const orderResult = await kernel.services.orders.getById(orderId, actor);
|
|
237
|
+
const orderResult = await kernel.services.orders.getById(orderId, actor, undefined, guestCredential);
|
|
221
238
|
if (!orderResult.ok)
|
|
222
239
|
return c.json(mapErrorToResponse(orderResult.error), mapErrorToStatus(orderResult.error));
|
|
223
240
|
const body = c.req.valid("json");
|
|
@@ -230,10 +247,11 @@ export function orderRoutes(kernel) {
|
|
|
230
247
|
router.openapi(getOrderFulfillmentsRoute, async (c) => {
|
|
231
248
|
const orderId = c.req.param("id");
|
|
232
249
|
const actor = c.get("actor");
|
|
250
|
+
const guestCredential = c.req.header("x-cart-secret") ?? c.req.header("X-Cart-Secret") ?? undefined;
|
|
233
251
|
// Verify the order exists and the actor has access before returning fulfillments
|
|
234
252
|
const orderResult = isUUID(orderId)
|
|
235
|
-
? await kernel.services.orders.getById(orderId, actor)
|
|
236
|
-
: await kernel.services.orders.getByNumber(orderId, actor);
|
|
253
|
+
? await kernel.services.orders.getById(orderId, actor, undefined, guestCredential)
|
|
254
|
+
: await kernel.services.orders.getByNumber(orderId, actor, undefined, guestCredential);
|
|
237
255
|
if (!orderResult.ok)
|
|
238
256
|
return c.json(mapErrorToResponse(orderResult.error), mapErrorToStatus(orderResult.error));
|
|
239
257
|
const result = await kernel.services.fulfillment.getByOrderId(orderResult.value.id);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import {
|
|
2
|
+
import { resolveOrgIdForCommerce } from "../../../auth/org.js";
|
|
3
3
|
import { CommerceValidationError } from "../../../kernel/errors.js";
|
|
4
4
|
import { CatalogRepository } from "../../../modules/catalog/repository/index.js";
|
|
5
5
|
import { setBasePriceRoute, createModifierRoute, listPricesRoute, listModifiersRoute, updateModifierRoute, deleteModifierRoute } from "../schemas/pricing.js";
|
|
@@ -80,7 +80,7 @@ export function pricingRoutes(kernel) {
|
|
|
80
80
|
const input = c.req.valid("json");
|
|
81
81
|
if (input.entityId) {
|
|
82
82
|
const catalogRepo = new CatalogRepository(kernel.database.db);
|
|
83
|
-
const orgId =
|
|
83
|
+
const orgId = resolveOrgIdForCommerce(actor, kernel.config);
|
|
84
84
|
const entity = await catalogRepo.findEntityById(input.entityId);
|
|
85
85
|
if (!entity || entity.organizationId !== orgId) {
|
|
86
86
|
return c.json(mapErrorToResponse(new CommerceValidationError("entityId does not belong to this organization.")), 422);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promotions.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/rest/routes/promotions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGzD,OAAO,EAAE,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"promotions.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/rest/routes/promotions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGzD,OAAO,EAAE,KAAK,MAAM,EAAwE,MAAM,aAAa,CAAC;AAIhH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,gCAmH7C"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
2
|
import { rateLimiter } from "hono-rate-limiter";
|
|
3
3
|
import { createPromotionRoute, updatePromotionRoute, validatePromotionRoute, deactivatePromotionRoute, listPromotionsRoute } from "../schemas/promotions.js";
|
|
4
|
-
import { mapErrorToResponse, mapErrorToStatus, requirePerm } from "../utils.js";
|
|
5
|
-
import {
|
|
4
|
+
import { mapErrorToResponse, mapErrorToStatus, requireMethodPerm, requirePerm } from "../utils.js";
|
|
5
|
+
import { resolveOrgIdForCommerce } from "../../../auth/org.js";
|
|
6
|
+
import { assertPermission } from "../../../auth/permissions.js";
|
|
6
7
|
export function promotionRoutes(kernel) {
|
|
7
8
|
const router = new OpenAPIHono();
|
|
8
9
|
// Rate limit promo code validation — prevents brute-force code enumeration
|
|
@@ -45,7 +46,7 @@ export function promotionRoutes(kernel) {
|
|
|
45
46
|
router.openapi(validatePromotionRoute, async (c) => {
|
|
46
47
|
const payload = c.req.valid("json");
|
|
47
48
|
const actor = c.get("actor");
|
|
48
|
-
const orgId =
|
|
49
|
+
const orgId = resolveOrgIdForCommerce(actor, kernel.config);
|
|
49
50
|
// Apply (not just validate) so the response carries the authoritative
|
|
50
51
|
// discount the cart would receive — the same computation checkout runs.
|
|
51
52
|
// Returning only the promotion forces callers to re-derive the amount, which
|
|
@@ -66,18 +67,20 @@ export function promotionRoutes(kernel) {
|
|
|
66
67
|
});
|
|
67
68
|
// Guard inline (not via router.use("/:id")) because a "/:id" middleware
|
|
68
69
|
// would also match single-segment routes like POST /validate.
|
|
69
|
-
router.use("/:id",
|
|
70
|
-
if (c.req.method !== "PATCH")
|
|
71
|
-
return next();
|
|
72
|
-
return requirePerm("promotions:manage")(c, next);
|
|
73
|
-
});
|
|
70
|
+
router.use("/:id", requireMethodPerm(["PATCH"], "promotions:manage"));
|
|
74
71
|
// @ts-expect-error -- openapi() enforces strict response typing but our handler
|
|
75
72
|
// returns union responses (200 | 400 | 404 | 422). The route definition
|
|
76
73
|
// documents the contract; the handler returns dynamic status.
|
|
77
74
|
router.openapi(updatePromotionRoute, async (c) => {
|
|
78
75
|
const body = c.req.valid("json");
|
|
79
76
|
const actor = c.get("actor");
|
|
80
|
-
|
|
77
|
+
try {
|
|
78
|
+
assertPermission(actor, "promotions:manage");
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
return c.json(mapErrorToResponse(error), mapErrorToStatus(error));
|
|
82
|
+
}
|
|
83
|
+
const orgId = resolveOrgIdForCommerce(actor, kernel.config);
|
|
81
84
|
const result = await kernel.services.promotions.update(orgId, c.req.param("id"), body, actor);
|
|
82
85
|
if (!result.ok) {
|
|
83
86
|
return c.json(mapErrorToResponse(result.error), mapErrorToStatus(result.error));
|
|
@@ -90,7 +93,7 @@ export function promotionRoutes(kernel) {
|
|
|
90
93
|
// contract; the handler returns dynamic status.
|
|
91
94
|
router.openapi(deactivatePromotionRoute, async (c) => {
|
|
92
95
|
const actor = c.get("actor");
|
|
93
|
-
const orgId =
|
|
96
|
+
const orgId = resolveOrgIdForCommerce(actor, kernel.config);
|
|
94
97
|
const result = await kernel.services.promotions.deactivate(orgId, c.req.param("id"));
|
|
95
98
|
if (!result.ok) {
|
|
96
99
|
return c.json(mapErrorToResponse(result.error), mapErrorToStatus(result.error));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/rest/routes/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/rest/routes/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,KAAK,MAAM,EAAqD,MAAM,aAAa,CAAC;AAI7F,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,gCA2F1C"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
2
|
import { searchRoute, suggestRoute } from "../schemas/search.js";
|
|
3
|
-
import { mapErrorToResponse, mapErrorToStatus } from "../utils.js";
|
|
3
|
+
import { mapErrorToResponse, mapErrorToStatus, requirePerm } from "../utils.js";
|
|
4
|
+
const SAFE_ATTRIBUTE_NAME = /^[A-Za-z0-9_-]+$/;
|
|
4
5
|
export function searchRoutes(kernel) {
|
|
5
6
|
const router = new OpenAPIHono();
|
|
7
|
+
router.use("/*", requirePerm("catalog:read"));
|
|
6
8
|
// @ts-expect-error -- openapi handler union return type
|
|
7
9
|
router.openapi(searchRoute, async (c) => {
|
|
8
10
|
try {
|
|
@@ -17,6 +19,16 @@ export function searchRoutes(kernel) {
|
|
|
17
19
|
.split(",")
|
|
18
20
|
.map((facet) => facet.trim())
|
|
19
21
|
.filter(Boolean);
|
|
22
|
+
const attributes = {};
|
|
23
|
+
for (const [key, values] of Object.entries(c.req.queries())) {
|
|
24
|
+
if (!key.startsWith("attr."))
|
|
25
|
+
continue;
|
|
26
|
+
const name = key.slice("attr.".length);
|
|
27
|
+
if (!SAFE_ATTRIBUTE_NAME.test(name)) {
|
|
28
|
+
return c.json({ error: "invalid_argument", field: key, message: `Invalid attribute filter name: ${name}` }, 422);
|
|
29
|
+
}
|
|
30
|
+
attributes[name] = values.length === 1 ? values[0] : values;
|
|
31
|
+
}
|
|
20
32
|
const result = await kernel.services.search.query({
|
|
21
33
|
query: q,
|
|
22
34
|
page,
|
|
@@ -26,6 +38,7 @@ export function searchRoutes(kernel) {
|
|
|
26
38
|
...(category ? { category } : {}),
|
|
27
39
|
...(brand ? { brand } : {}),
|
|
28
40
|
...(status ? { status } : {}),
|
|
41
|
+
...(Object.keys(attributes).length > 0 ? { attributes } : {}),
|
|
29
42
|
},
|
|
30
43
|
...(facets.length > 0 ? { facets } : {}),
|
|
31
44
|
}, { actor: c.get("actor"), tx: null, requestId: "" });
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
export declare const listCustomFieldProposalsRoute: {
|
|
3
|
+
method: "get";
|
|
4
|
+
path: "/custom-field-proposals";
|
|
5
|
+
tags: string[];
|
|
6
|
+
summary: string;
|
|
7
|
+
request: {
|
|
8
|
+
query: z.ZodObject<{
|
|
9
|
+
entityType: z.ZodOptional<z.ZodString>;
|
|
10
|
+
page: z.ZodOptional<z.ZodString>;
|
|
11
|
+
limit: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
};
|
|
14
|
+
responses: {
|
|
15
|
+
400: {
|
|
16
|
+
readonly content: {
|
|
17
|
+
readonly "application/json": {
|
|
18
|
+
readonly schema: z.ZodObject<{
|
|
19
|
+
error: z.ZodObject<{
|
|
20
|
+
code: z.ZodString;
|
|
21
|
+
message: z.ZodString;
|
|
22
|
+
details: z.ZodOptional<z.ZodObject<{
|
|
23
|
+
issues: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
24
|
+
path: z.ZodString;
|
|
25
|
+
message: z.ZodString;
|
|
26
|
+
code: z.ZodString;
|
|
27
|
+
}, z.core.$strip>>>;
|
|
28
|
+
}, z.core.$strip>>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
readonly description: "Business logic error.";
|
|
34
|
+
};
|
|
35
|
+
401: {
|
|
36
|
+
readonly content: {
|
|
37
|
+
readonly "application/json": {
|
|
38
|
+
readonly schema: z.ZodObject<{
|
|
39
|
+
error: z.ZodObject<{
|
|
40
|
+
code: z.ZodString;
|
|
41
|
+
message: z.ZodString;
|
|
42
|
+
details: z.ZodOptional<z.ZodObject<{
|
|
43
|
+
issues: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
44
|
+
path: z.ZodString;
|
|
45
|
+
message: z.ZodString;
|
|
46
|
+
code: z.ZodString;
|
|
47
|
+
}, z.core.$strip>>>;
|
|
48
|
+
}, z.core.$strip>>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
readonly description: "Authentication required.";
|
|
54
|
+
};
|
|
55
|
+
403: {
|
|
56
|
+
readonly content: {
|
|
57
|
+
readonly "application/json": {
|
|
58
|
+
readonly schema: z.ZodObject<{
|
|
59
|
+
error: z.ZodObject<{
|
|
60
|
+
code: z.ZodString;
|
|
61
|
+
message: z.ZodString;
|
|
62
|
+
details: z.ZodOptional<z.ZodObject<{
|
|
63
|
+
issues: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
64
|
+
path: z.ZodString;
|
|
65
|
+
message: z.ZodString;
|
|
66
|
+
code: z.ZodString;
|
|
67
|
+
}, z.core.$strip>>>;
|
|
68
|
+
}, z.core.$strip>>;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
readonly description: "Insufficient permissions.";
|
|
74
|
+
};
|
|
75
|
+
404: {
|
|
76
|
+
readonly content: {
|
|
77
|
+
readonly "application/json": {
|
|
78
|
+
readonly schema: z.ZodObject<{
|
|
79
|
+
error: z.ZodObject<{
|
|
80
|
+
code: z.ZodString;
|
|
81
|
+
message: z.ZodString;
|
|
82
|
+
details: z.ZodOptional<z.ZodObject<{
|
|
83
|
+
issues: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
84
|
+
path: z.ZodString;
|
|
85
|
+
message: z.ZodString;
|
|
86
|
+
code: z.ZodString;
|
|
87
|
+
}, z.core.$strip>>>;
|
|
88
|
+
}, z.core.$strip>>;
|
|
89
|
+
}, z.core.$strip>;
|
|
90
|
+
}, z.core.$strip>;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
readonly description: "Resource not found.";
|
|
94
|
+
};
|
|
95
|
+
422: {
|
|
96
|
+
readonly content: {
|
|
97
|
+
readonly "application/json": {
|
|
98
|
+
readonly schema: z.ZodObject<{
|
|
99
|
+
error: z.ZodObject<{
|
|
100
|
+
code: z.ZodString;
|
|
101
|
+
message: z.ZodString;
|
|
102
|
+
details: z.ZodOptional<z.ZodObject<{
|
|
103
|
+
issues: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
104
|
+
path: z.ZodString;
|
|
105
|
+
message: z.ZodString;
|
|
106
|
+
code: z.ZodString;
|
|
107
|
+
}, z.core.$strip>>>;
|
|
108
|
+
}, z.core.$strip>>;
|
|
109
|
+
}, z.core.$strip>;
|
|
110
|
+
}, z.core.$strip>;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
readonly description: "Validation error.";
|
|
114
|
+
};
|
|
115
|
+
200: {
|
|
116
|
+
content: {
|
|
117
|
+
"application/json": {
|
|
118
|
+
schema: z.ZodObject<{
|
|
119
|
+
data: z.ZodObject<{
|
|
120
|
+
items: z.ZodArray<z.ZodAny>;
|
|
121
|
+
total: z.ZodNumber;
|
|
122
|
+
page: z.ZodNumber;
|
|
123
|
+
limit: z.ZodNumber;
|
|
124
|
+
}, z.core.$strip>;
|
|
125
|
+
}, z.core.$strip>;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
description: string;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
} & {
|
|
132
|
+
getRoutingPath(): "/custom-field-proposals";
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=admin-custom-field-proposals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-custom-field-proposals.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/rest/schemas/admin-custom-field-proposals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAkBnD,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAUxC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createRoute, z } from "@hono/zod-openapi";
|
|
2
|
+
import { errorResponses } from "./shared.js";
|
|
3
|
+
const ProposalResponse = z.object({
|
|
4
|
+
data: z.object({
|
|
5
|
+
items: z.array(z.any()),
|
|
6
|
+
total: z.number(),
|
|
7
|
+
page: z.number(),
|
|
8
|
+
limit: z.number(),
|
|
9
|
+
}),
|
|
10
|
+
});
|
|
11
|
+
const ListQuery = z.object({
|
|
12
|
+
entityType: z.string().min(1).optional(),
|
|
13
|
+
page: z.string().max(10).optional(),
|
|
14
|
+
limit: z.string().max(10).optional(),
|
|
15
|
+
});
|
|
16
|
+
export const listCustomFieldProposalsRoute = createRoute({
|
|
17
|
+
method: "get",
|
|
18
|
+
path: "/custom-field-proposals",
|
|
19
|
+
tags: ["Admin"],
|
|
20
|
+
summary: "List proposed custom-field values",
|
|
21
|
+
request: { query: ListQuery },
|
|
22
|
+
responses: {
|
|
23
|
+
200: { content: { "application/json": { schema: ProposalResponse } }, description: "Proposed custom fields." },
|
|
24
|
+
...errorResponses,
|
|
25
|
+
},
|
|
26
|
+
});
|