@unifiedcommerce/core 0.4.4 → 0.5.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/adapters/console-email.d.ts +23 -0
- package/dist/adapters/console-email.d.ts.map +1 -0
- package/dist/adapters/console-email.js +38 -0
- package/dist/auth/access.d.ts +101 -0
- package/dist/auth/access.d.ts.map +1 -0
- package/dist/auth/access.js +128 -0
- package/dist/auth/auth-schema.d.ts +1475 -0
- package/dist/auth/auth-schema.d.ts.map +1 -0
- package/dist/auth/auth-schema.js +124 -0
- package/dist/auth/middleware.d.ts +5 -0
- package/dist/auth/middleware.d.ts.map +1 -0
- package/dist/auth/middleware.js +141 -0
- package/dist/auth/org.d.ts +22 -0
- package/dist/auth/org.d.ts.map +1 -0
- package/dist/auth/org.js +36 -0
- package/dist/auth/permissions.d.ts +4 -0
- package/dist/auth/permissions.d.ts.map +1 -0
- package/dist/auth/permissions.js +24 -0
- package/dist/auth/setup.d.ts +29 -0
- package/dist/auth/setup.d.ts.map +1 -0
- package/dist/auth/setup.js +144 -0
- package/dist/auth/system-actor.d.ts +7 -0
- package/dist/auth/system-actor.d.ts.map +1 -0
- package/dist/auth/system-actor.js +17 -0
- package/dist/auth/types.d.ts +11 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +1 -0
- package/dist/config/defaults.d.ts +3 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +80 -0
- package/dist/config/define-config.d.ts +9 -0
- package/dist/config/define-config.d.ts.map +1 -0
- package/dist/config/define-config.js +44 -0
- package/dist/config/types.d.ts +327 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +1 -0
- package/dist/generated/plugin-manifest.d.ts +48 -0
- package/dist/generated/plugin-manifest.d.ts.map +1 -0
- package/dist/generated/plugin-manifest.js +20 -0
- package/dist/hooks/checkout-completion.d.ts +58 -0
- package/dist/hooks/checkout-completion.d.ts.map +1 -0
- package/dist/hooks/checkout-completion.js +137 -0
- package/dist/hooks/checkout.d.ts +99 -0
- package/dist/hooks/checkout.d.ts.map +1 -0
- package/dist/hooks/checkout.js +317 -0
- package/dist/hooks/order-emails.d.ts +16 -0
- package/dist/hooks/order-emails.d.ts.map +1 -0
- package/dist/hooks/order-emails.js +44 -0
- package/dist/index.d.ts +77 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -0
- package/dist/interfaces/mcp/agent-prompt.d.ts +16 -0
- package/dist/interfaces/mcp/agent-prompt.d.ts.map +1 -0
- package/dist/interfaces/mcp/agent-prompt.js +172 -0
- package/dist/interfaces/mcp/context-enrichment.d.ts +39 -0
- package/dist/interfaces/mcp/context-enrichment.d.ts.map +1 -0
- package/dist/interfaces/mcp/context-enrichment.js +119 -0
- package/dist/interfaces/mcp/server.d.ts +5 -0
- package/dist/interfaces/mcp/server.d.ts.map +1 -0
- package/dist/interfaces/mcp/server.js +30 -0
- package/dist/interfaces/mcp/tool-builder.d.ts +120 -0
- package/dist/interfaces/mcp/tool-builder.d.ts.map +1 -0
- package/dist/interfaces/mcp/tool-builder.js +224 -0
- package/dist/interfaces/mcp/tools/analytics.d.ts +42 -0
- package/dist/interfaces/mcp/tools/analytics.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/analytics.js +70 -0
- package/dist/interfaces/mcp/tools/cart.d.ts +14 -0
- package/dist/interfaces/mcp/tools/cart.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/cart.js +47 -0
- package/dist/interfaces/mcp/tools/catalog.d.ts +53 -0
- package/dist/interfaces/mcp/tools/catalog.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/catalog.js +284 -0
- package/dist/interfaces/mcp/tools/index.d.ts +3 -0
- package/dist/interfaces/mcp/tools/index.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/index.js +20 -0
- package/dist/interfaces/mcp/tools/inventory.d.ts +27 -0
- package/dist/interfaces/mcp/tools/inventory.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/inventory.js +143 -0
- package/dist/interfaces/mcp/tools/orders.d.ts +18 -0
- package/dist/interfaces/mcp/tools/orders.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/orders.js +82 -0
- package/dist/interfaces/mcp/tools/pricing.d.ts +29 -0
- package/dist/interfaces/mcp/tools/pricing.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/pricing.js +90 -0
- package/dist/interfaces/mcp/tools/promotions.d.ts +44 -0
- package/dist/interfaces/mcp/tools/promotions.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/promotions.js +109 -0
- package/dist/interfaces/mcp/tools/registry.d.ts +32 -0
- package/dist/interfaces/mcp/tools/registry.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/registry.js +55 -0
- package/dist/interfaces/mcp/tools/search.d.ts +14 -0
- package/dist/interfaces/mcp/tools/search.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/search.js +39 -0
- package/dist/interfaces/mcp/tools/webhooks.d.ts +15 -0
- package/dist/interfaces/mcp/tools/webhooks.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/webhooks.js +48 -0
- package/dist/interfaces/mcp/transport.d.ts +20 -0
- package/dist/interfaces/mcp/transport.d.ts.map +1 -0
- package/dist/interfaces/mcp/transport.js +99 -0
- package/dist/interfaces/rest/customer-portal.d.ts +5 -0
- package/dist/interfaces/rest/customer-portal.d.ts.map +1 -0
- package/dist/interfaces/rest/customer-portal.js +206 -0
- package/dist/interfaces/rest/router.d.ts +164 -0
- package/dist/interfaces/rest/router.d.ts.map +1 -0
- package/dist/interfaces/rest/router.js +259 -0
- package/dist/interfaces/rest/routes/admin-jobs.d.ts +5 -0
- package/dist/interfaces/rest/routes/admin-jobs.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/admin-jobs.js +48 -0
- package/dist/interfaces/rest/routes/audit.d.ts +5 -0
- package/dist/interfaces/rest/routes/audit.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/audit.js +43 -0
- package/dist/interfaces/rest/routes/carts.d.ts +5 -0
- package/dist/interfaces/rest/routes/carts.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/carts.js +55 -0
- package/dist/interfaces/rest/routes/catalog.d.ts +5 -0
- package/dist/interfaces/rest/routes/catalog.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/catalog.js +256 -0
- package/dist/interfaces/rest/routes/checkout.d.ts +5 -0
- package/dist/interfaces/rest/routes/checkout.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/checkout.js +216 -0
- package/dist/interfaces/rest/routes/customers.d.ts +5 -0
- package/dist/interfaces/rest/routes/customers.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/customers.js +78 -0
- package/dist/interfaces/rest/routes/entity-aliases.d.ts +18 -0
- package/dist/interfaces/rest/routes/entity-aliases.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/entity-aliases.js +39 -0
- package/dist/interfaces/rest/routes/inventory.d.ts +5 -0
- package/dist/interfaces/rest/routes/inventory.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/inventory.js +74 -0
- package/dist/interfaces/rest/routes/media.d.ts +5 -0
- package/dist/interfaces/rest/routes/media.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/media.js +65 -0
- package/dist/interfaces/rest/routes/orders.d.ts +5 -0
- package/dist/interfaces/rest/routes/orders.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/orders.js +64 -0
- package/dist/interfaces/rest/routes/payments.d.ts +5 -0
- package/dist/interfaces/rest/routes/payments.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/payments.js +45 -0
- package/dist/interfaces/rest/routes/pricing.d.ts +5 -0
- package/dist/interfaces/rest/routes/pricing.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/pricing.js +48 -0
- package/dist/interfaces/rest/routes/promotions.d.ts +5 -0
- package/dist/interfaces/rest/routes/promotions.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/promotions.js +76 -0
- package/dist/interfaces/rest/routes/search.d.ts +5 -0
- package/dist/interfaces/rest/routes/search.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/search.js +60 -0
- package/dist/interfaces/rest/routes/webhooks.d.ts +5 -0
- package/dist/interfaces/rest/routes/webhooks.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/webhooks.js +39 -0
- package/dist/interfaces/rest/schemas/admin-jobs.d.ts +327 -0
- package/dist/interfaces/rest/schemas/admin-jobs.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/admin-jobs.js +37 -0
- package/dist/interfaces/rest/schemas/audit.d.ts +59 -0
- package/dist/interfaces/rest/schemas/audit.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/audit.js +43 -0
- package/dist/interfaces/rest/schemas/carts.d.ts +1456 -0
- package/dist/interfaces/rest/schemas/carts.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/carts.js +109 -0
- package/dist/interfaces/rest/schemas/catalog.d.ts +5452 -0
- package/dist/interfaces/rest/schemas/catalog.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/catalog.js +397 -0
- package/dist/interfaces/rest/schemas/checkout.d.ts +160 -0
- package/dist/interfaces/rest/schemas/checkout.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/checkout.js +60 -0
- package/dist/interfaces/rest/schemas/customer-portal.d.ts +2203 -0
- package/dist/interfaces/rest/schemas/customer-portal.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/customer-portal.js +177 -0
- package/dist/interfaces/rest/schemas/customers.d.ts +422 -0
- package/dist/interfaces/rest/schemas/customers.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/customers.js +150 -0
- package/dist/interfaces/rest/schemas/inventory.d.ts +561 -0
- package/dist/interfaces/rest/schemas/inventory.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/inventory.js +148 -0
- package/dist/interfaces/rest/schemas/media.d.ts +303 -0
- package/dist/interfaces/rest/schemas/media.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/media.js +69 -0
- package/dist/interfaces/rest/schemas/orders.d.ts +1792 -0
- package/dist/interfaces/rest/schemas/orders.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/orders.js +93 -0
- package/dist/interfaces/rest/schemas/pricing.d.ts +256 -0
- package/dist/interfaces/rest/schemas/pricing.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/pricing.js +72 -0
- package/dist/interfaces/rest/schemas/promotions.d.ts +374 -0
- package/dist/interfaces/rest/schemas/promotions.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/promotions.js +104 -0
- package/dist/interfaces/rest/schemas/responses.d.ts +4086 -0
- package/dist/interfaces/rest/schemas/responses.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/responses.js +74 -0
- package/dist/interfaces/rest/schemas/search.d.ts +247 -0
- package/dist/interfaces/rest/schemas/search.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/search.js +55 -0
- package/dist/interfaces/rest/schemas/shared.d.ts +95 -0
- package/dist/interfaces/rest/schemas/shared.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/shared.js +51 -0
- package/dist/interfaces/rest/schemas/webhooks.d.ts +221 -0
- package/dist/interfaces/rest/schemas/webhooks.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/webhooks.js +62 -0
- package/dist/interfaces/rest/utils.d.ts +45 -0
- package/dist/interfaces/rest/utils.d.ts.map +1 -0
- package/dist/interfaces/rest/utils.js +71 -0
- package/dist/interfaces/rest/webhook-router.d.ts +41 -0
- package/dist/interfaces/rest/webhook-router.d.ts.map +1 -0
- package/dist/interfaces/rest/webhook-router.js +36 -0
- package/dist/kernel/compensation/executor.d.ts +21 -0
- package/dist/kernel/compensation/executor.d.ts.map +1 -0
- package/dist/kernel/compensation/executor.js +36 -0
- package/dist/kernel/compensation/types.d.ts +25 -0
- package/dist/kernel/compensation/types.d.ts.map +1 -0
- package/dist/kernel/compensation/types.js +1 -0
- package/dist/kernel/database/adapter.d.ts +18 -0
- package/dist/kernel/database/adapter.d.ts.map +1 -0
- package/dist/kernel/database/adapter.js +3 -0
- package/dist/kernel/database/drizzle-db.d.ts +49 -0
- package/dist/kernel/database/drizzle-db.d.ts.map +1 -0
- package/dist/kernel/database/drizzle-db.js +20 -0
- package/dist/kernel/database/migrate.d.ts +38 -0
- package/dist/kernel/database/migrate.d.ts.map +1 -0
- package/dist/kernel/database/migrate.js +61 -0
- package/dist/kernel/database/plugin-types.d.ts +32 -0
- package/dist/kernel/database/plugin-types.d.ts.map +1 -0
- package/dist/kernel/database/plugin-types.js +10 -0
- package/dist/kernel/database/schema.d.ts +24 -0
- package/dist/kernel/database/schema.d.ts.map +1 -0
- package/dist/kernel/database/schema.js +36 -0
- package/dist/kernel/database/scoped-db.d.ts +20 -0
- package/dist/kernel/database/scoped-db.d.ts.map +1 -0
- package/dist/kernel/database/scoped-db.js +62 -0
- package/dist/kernel/database/tx-context.d.ts +15 -0
- package/dist/kernel/database/tx-context.d.ts.map +1 -0
- package/dist/kernel/database/tx-context.js +19 -0
- package/dist/kernel/error-mapper.d.ts +3 -0
- package/dist/kernel/error-mapper.d.ts.map +1 -0
- package/dist/kernel/error-mapper.js +12 -0
- package/dist/kernel/errors.d.ts +38 -0
- package/dist/kernel/errors.d.ts.map +1 -0
- package/dist/kernel/errors.js +69 -0
- package/dist/kernel/factory/repository-factory.d.ts +71 -0
- package/dist/kernel/factory/repository-factory.d.ts.map +1 -0
- package/dist/kernel/factory/repository-factory.js +138 -0
- package/dist/kernel/hooks/create-context.d.ts +25 -0
- package/dist/kernel/hooks/create-context.d.ts.map +1 -0
- package/dist/kernel/hooks/create-context.js +22 -0
- package/dist/kernel/hooks/executor.d.ts +12 -0
- package/dist/kernel/hooks/executor.d.ts.map +1 -0
- package/dist/kernel/hooks/executor.js +50 -0
- package/dist/kernel/hooks/registry.d.ts +28 -0
- package/dist/kernel/hooks/registry.d.ts.map +1 -0
- package/dist/kernel/hooks/registry.js +58 -0
- package/dist/kernel/hooks/types.d.ts +37 -0
- package/dist/kernel/hooks/types.d.ts.map +1 -0
- package/dist/kernel/hooks/types.js +1 -0
- package/dist/kernel/http-error.d.ts +30 -0
- package/dist/kernel/http-error.d.ts.map +1 -0
- package/dist/kernel/http-error.js +35 -0
- package/dist/kernel/jobs/adapter.d.ts +25 -0
- package/dist/kernel/jobs/adapter.d.ts.map +1 -0
- package/dist/kernel/jobs/adapter.js +9 -0
- package/dist/kernel/jobs/drizzle-adapter.d.ts +15 -0
- package/dist/kernel/jobs/drizzle-adapter.d.ts.map +1 -0
- package/dist/kernel/jobs/drizzle-adapter.js +42 -0
- package/dist/kernel/jobs/runner.d.ts +24 -0
- package/dist/kernel/jobs/runner.d.ts.map +1 -0
- package/dist/kernel/jobs/runner.js +114 -0
- package/dist/kernel/jobs/schema.d.ts +280 -0
- package/dist/kernel/jobs/schema.d.ts.map +1 -0
- package/dist/kernel/jobs/schema.js +37 -0
- package/dist/kernel/jobs/types.d.ts +30 -0
- package/dist/kernel/jobs/types.d.ts.map +1 -0
- package/dist/kernel/jobs/types.js +1 -0
- package/dist/kernel/local-api.d.ts +103 -0
- package/dist/kernel/local-api.d.ts.map +1 -0
- package/dist/kernel/local-api.js +89 -0
- package/dist/kernel/plugin/manifest.d.ts +90 -0
- package/dist/kernel/plugin/manifest.d.ts.map +1 -0
- package/dist/kernel/plugin/manifest.js +169 -0
- package/dist/kernel/query/executor.d.ts +21 -0
- package/dist/kernel/query/executor.d.ts.map +1 -0
- package/dist/kernel/query/executor.js +128 -0
- package/dist/kernel/query/registry.d.ts +33 -0
- package/dist/kernel/query/registry.d.ts.map +1 -0
- package/dist/kernel/query/registry.js +20 -0
- package/dist/kernel/result.d.ts +36 -0
- package/dist/kernel/result.d.ts.map +1 -0
- package/dist/kernel/result.js +16 -0
- package/dist/kernel/schema/extra-columns.d.ts +23 -0
- package/dist/kernel/schema/extra-columns.d.ts.map +1 -0
- package/dist/kernel/schema/extra-columns.js +10 -0
- package/dist/kernel/service-registry.d.ts +109 -0
- package/dist/kernel/service-registry.d.ts.map +1 -0
- package/dist/kernel/service-registry.js +26 -0
- package/dist/kernel/service-timing.d.ts +25 -0
- package/dist/kernel/service-timing.d.ts.map +1 -0
- package/dist/kernel/service-timing.js +62 -0
- package/dist/kernel/state-machine/machine.d.ts +24 -0
- package/dist/kernel/state-machine/machine.d.ts.map +1 -0
- package/dist/kernel/state-machine/machine.js +70 -0
- package/dist/modules/analytics/drizzle-adapter.d.ts +13 -0
- package/dist/modules/analytics/drizzle-adapter.d.ts.map +1 -0
- package/dist/modules/analytics/drizzle-adapter.js +358 -0
- package/dist/modules/analytics/hooks.d.ts +13 -0
- package/dist/modules/analytics/hooks.d.ts.map +1 -0
- package/dist/modules/analytics/hooks.js +12 -0
- package/dist/modules/analytics/models.d.ts +14 -0
- package/dist/modules/analytics/models.d.ts.map +1 -0
- package/dist/modules/analytics/models.js +118 -0
- package/dist/modules/analytics/repository/index.d.ts +5 -0
- package/dist/modules/analytics/repository/index.d.ts.map +1 -0
- package/dist/modules/analytics/repository/index.js +1 -0
- package/dist/modules/analytics/service.d.ts +45 -0
- package/dist/modules/analytics/service.d.ts.map +1 -0
- package/dist/modules/analytics/service.js +196 -0
- package/dist/modules/analytics/types.d.ts +119 -0
- package/dist/modules/analytics/types.d.ts.map +1 -0
- package/dist/modules/analytics/types.js +25 -0
- package/dist/modules/audit/hooks.d.ts +7 -0
- package/dist/modules/audit/hooks.d.ts.map +1 -0
- package/dist/modules/audit/hooks.js +67 -0
- package/dist/modules/audit/schema.d.ts +178 -0
- package/dist/modules/audit/schema.d.ts.map +1 -0
- package/dist/modules/audit/schema.js +21 -0
- package/dist/modules/audit/service.d.ts +38 -0
- package/dist/modules/audit/service.d.ts.map +1 -0
- package/dist/modules/audit/service.js +109 -0
- package/dist/modules/cart/access.d.ts +11 -0
- package/dist/modules/cart/access.d.ts.map +1 -0
- package/dist/modules/cart/access.js +18 -0
- package/dist/modules/cart/matcher.d.ts +20 -0
- package/dist/modules/cart/matcher.d.ts.map +1 -0
- package/dist/modules/cart/matcher.js +2 -0
- package/dist/modules/cart/repository/index.d.ts +45 -0
- package/dist/modules/cart/repository/index.d.ts.map +1 -0
- package/dist/modules/cart/repository/index.js +158 -0
- package/dist/modules/cart/schema.d.ts +359 -0
- package/dist/modules/cart/schema.d.ts.map +1 -0
- package/dist/modules/cart/schema.js +40 -0
- package/dist/modules/cart/schemas.d.ts +29 -0
- package/dist/modules/cart/schemas.d.ts.map +1 -0
- package/dist/modules/cart/schemas.js +14 -0
- package/dist/modules/cart/service.d.ts +63 -0
- package/dist/modules/cart/service.d.ts.map +1 -0
- package/dist/modules/cart/service.js +339 -0
- package/dist/modules/catalog/repository/index.d.ts +106 -0
- package/dist/modules/catalog/repository/index.d.ts.map +1 -0
- package/dist/modules/catalog/repository/index.js +455 -0
- package/dist/modules/catalog/schema.d.ts +1193 -0
- package/dist/modules/catalog/schema.d.ts.map +1 -0
- package/dist/modules/catalog/schema.js +149 -0
- package/dist/modules/catalog/schemas.d.ts +81 -0
- package/dist/modules/catalog/schemas.d.ts.map +1 -0
- package/dist/modules/catalog/schemas.js +62 -0
- package/dist/modules/catalog/service.d.ts +165 -0
- package/dist/modules/catalog/service.d.ts.map +1 -0
- package/dist/modules/catalog/service.js +775 -0
- package/dist/modules/customers/repository/index.d.ts +47 -0
- package/dist/modules/customers/repository/index.d.ts.map +1 -0
- package/dist/modules/customers/repository/index.js +206 -0
- package/dist/modules/customers/schema.d.ts +560 -0
- package/dist/modules/customers/schema.d.ts.map +1 -0
- package/dist/modules/customers/schema.js +60 -0
- package/dist/modules/customers/service.d.ts +27 -0
- package/dist/modules/customers/service.d.ts.map +1 -0
- package/dist/modules/customers/service.js +106 -0
- package/dist/modules/fulfillment/repository/index.d.ts +63 -0
- package/dist/modules/fulfillment/repository/index.d.ts.map +1 -0
- package/dist/modules/fulfillment/repository/index.js +268 -0
- package/dist/modules/fulfillment/schema.d.ts +655 -0
- package/dist/modules/fulfillment/schema.d.ts.map +1 -0
- package/dist/modules/fulfillment/schema.js +83 -0
- package/dist/modules/fulfillment/service.d.ts +58 -0
- package/dist/modules/fulfillment/service.d.ts.map +1 -0
- package/dist/modules/fulfillment/service.js +338 -0
- package/dist/modules/fulfillment/types.d.ts +44 -0
- package/dist/modules/fulfillment/types.d.ts.map +1 -0
- package/dist/modules/fulfillment/types.js +1 -0
- package/dist/modules/inventory/repository/index.d.ts +81 -0
- package/dist/modules/inventory/repository/index.d.ts.map +1 -0
- package/dist/modules/inventory/repository/index.js +310 -0
- package/dist/modules/inventory/schema.d.ts +570 -0
- package/dist/modules/inventory/schema.d.ts.map +1 -0
- package/dist/modules/inventory/schema.js +69 -0
- package/dist/modules/inventory/schemas.d.ts +31 -0
- package/dist/modules/inventory/schemas.d.ts.map +1 -0
- package/dist/modules/inventory/schemas.js +28 -0
- package/dist/modules/inventory/service.d.ts +69 -0
- package/dist/modules/inventory/service.d.ts.map +1 -0
- package/dist/modules/inventory/service.js +283 -0
- package/dist/modules/media/adapter.d.ts +16 -0
- package/dist/modules/media/adapter.d.ts.map +1 -0
- package/dist/modules/media/adapter.js +1 -0
- package/dist/modules/media/repository/index.d.ts +35 -0
- package/dist/modules/media/repository/index.d.ts.map +1 -0
- package/dist/modules/media/repository/index.js +176 -0
- package/dist/modules/media/schema.d.ts +289 -0
- package/dist/modules/media/schema.d.ts.map +1 -0
- package/dist/modules/media/schema.js +35 -0
- package/dist/modules/media/service.d.ts +42 -0
- package/dist/modules/media/service.d.ts.map +1 -0
- package/dist/modules/media/service.js +89 -0
- package/dist/modules/orders/repository/index.d.ts +48 -0
- package/dist/modules/orders/repository/index.d.ts.map +1 -0
- package/dist/modules/orders/repository/index.js +199 -0
- package/dist/modules/orders/schema.d.ts +672 -0
- package/dist/modules/orders/schema.d.ts.map +1 -0
- package/dist/modules/orders/schema.js +63 -0
- package/dist/modules/orders/service.d.ts +85 -0
- package/dist/modules/orders/service.d.ts.map +1 -0
- package/dist/modules/orders/service.js +313 -0
- package/dist/modules/orders/stale-order-cleanup.d.ts +27 -0
- package/dist/modules/orders/stale-order-cleanup.d.ts.map +1 -0
- package/dist/modules/orders/stale-order-cleanup.js +55 -0
- package/dist/modules/organization/service.d.ts +53 -0
- package/dist/modules/organization/service.d.ts.map +1 -0
- package/dist/modules/organization/service.js +151 -0
- package/dist/modules/payments/adapter.d.ts +42 -0
- package/dist/modules/payments/adapter.d.ts.map +1 -0
- package/dist/modules/payments/adapter.js +1 -0
- package/dist/modules/payments/repository/index.d.ts +5 -0
- package/dist/modules/payments/repository/index.d.ts.map +1 -0
- package/dist/modules/payments/repository/index.js +1 -0
- package/dist/modules/payments/service.d.ts +23 -0
- package/dist/modules/payments/service.d.ts.map +1 -0
- package/dist/modules/payments/service.js +72 -0
- package/dist/modules/pricing/repository/index.d.ts +34 -0
- package/dist/modules/pricing/repository/index.d.ts.map +1 -0
- package/dist/modules/pricing/repository/index.js +176 -0
- package/dist/modules/pricing/schema.d.ts +565 -0
- package/dist/modules/pricing/schema.d.ts.map +1 -0
- package/dist/modules/pricing/schema.js +57 -0
- package/dist/modules/pricing/schemas.d.ts +37 -0
- package/dist/modules/pricing/schemas.d.ts.map +1 -0
- package/dist/modules/pricing/schemas.js +30 -0
- package/dist/modules/pricing/service.d.ts +62 -0
- package/dist/modules/pricing/service.d.ts.map +1 -0
- package/dist/modules/pricing/service.js +308 -0
- package/dist/modules/promotions/repository/index.d.ts +41 -0
- package/dist/modules/promotions/repository/index.d.ts.map +1 -0
- package/dist/modules/promotions/repository/index.js +204 -0
- package/dist/modules/promotions/schema.d.ts +427 -0
- package/dist/modules/promotions/schema.d.ts.map +1 -0
- package/dist/modules/promotions/schema.js +52 -0
- package/dist/modules/promotions/schemas.d.ts +33 -0
- package/dist/modules/promotions/schemas.d.ts.map +1 -0
- package/dist/modules/promotions/schemas.js +32 -0
- package/dist/modules/promotions/service.d.ts +85 -0
- package/dist/modules/promotions/service.d.ts.map +1 -0
- package/dist/modules/promotions/service.js +368 -0
- package/dist/modules/search/adapter.d.ts +51 -0
- package/dist/modules/search/adapter.d.ts.map +1 -0
- package/dist/modules/search/adapter.js +1 -0
- package/dist/modules/search/hooks.d.ts +8 -0
- package/dist/modules/search/hooks.d.ts.map +1 -0
- package/dist/modules/search/hooks.js +6 -0
- package/dist/modules/search/repository/index.d.ts +5 -0
- package/dist/modules/search/repository/index.d.ts.map +1 -0
- package/dist/modules/search/repository/index.js +1 -0
- package/dist/modules/search/service.d.ts +24 -0
- package/dist/modules/search/service.d.ts.map +1 -0
- package/dist/modules/search/service.js +217 -0
- package/dist/modules/shipping/calculator.d.ts +42 -0
- package/dist/modules/shipping/calculator.d.ts.map +1 -0
- package/dist/modules/shipping/calculator.js +91 -0
- package/dist/modules/shipping/repository/index.d.ts +5 -0
- package/dist/modules/shipping/repository/index.d.ts.map +1 -0
- package/dist/modules/shipping/repository/index.js +1 -0
- package/dist/modules/shipping/service.d.ts +28 -0
- package/dist/modules/shipping/service.d.ts.map +1 -0
- package/dist/modules/shipping/service.js +20 -0
- package/dist/modules/tax/adapter.d.ts +58 -0
- package/dist/modules/tax/adapter.d.ts.map +1 -0
- package/dist/modules/tax/adapter.js +1 -0
- package/dist/modules/tax/repository/index.d.ts +5 -0
- package/dist/modules/tax/repository/index.d.ts.map +1 -0
- package/dist/modules/tax/repository/index.js +1 -0
- package/dist/modules/tax/service.d.ts +19 -0
- package/dist/modules/tax/service.d.ts.map +1 -0
- package/dist/modules/tax/service.js +34 -0
- package/dist/modules/webhooks/hook.d.ts +13 -0
- package/dist/modules/webhooks/hook.d.ts.map +1 -0
- package/dist/modules/webhooks/hook.js +29 -0
- package/dist/modules/webhooks/repository/index.d.ts +40 -0
- package/dist/modules/webhooks/repository/index.d.ts.map +1 -0
- package/dist/modules/webhooks/repository/index.js +175 -0
- package/dist/modules/webhooks/schema.d.ts +404 -0
- package/dist/modules/webhooks/schema.d.ts.map +1 -0
- package/dist/modules/webhooks/schema.js +40 -0
- package/dist/modules/webhooks/service.d.ts +23 -0
- package/dist/modules/webhooks/service.d.ts.map +1 -0
- package/dist/modules/webhooks/service.js +92 -0
- package/dist/modules/webhooks/signing.d.ts +2 -0
- package/dist/modules/webhooks/signing.d.ts.map +1 -0
- package/dist/modules/webhooks/signing.js +5 -0
- package/dist/modules/webhooks/ssrf-guard.d.ts +19 -0
- package/dist/modules/webhooks/ssrf-guard.d.ts.map +1 -0
- package/dist/modules/webhooks/ssrf-guard.js +79 -0
- package/dist/modules/webhooks/tasks.d.ts +16 -0
- package/dist/modules/webhooks/tasks.d.ts.map +1 -0
- package/dist/modules/webhooks/tasks.js +35 -0
- package/dist/modules/webhooks/worker.d.ts +21 -0
- package/dist/modules/webhooks/worker.d.ts.map +1 -0
- package/dist/modules/webhooks/worker.js +113 -0
- package/dist/runtime/commerce.d.ts +110 -0
- package/dist/runtime/commerce.d.ts.map +1 -0
- package/dist/runtime/commerce.js +37 -0
- package/dist/runtime/kernel.d.ts +71 -0
- package/dist/runtime/kernel.d.ts.map +1 -0
- package/dist/runtime/kernel.js +306 -0
- package/dist/runtime/logger.d.ts +11 -0
- package/dist/runtime/logger.d.ts.map +1 -0
- package/dist/runtime/logger.js +32 -0
- package/dist/runtime/shutdown.d.ts +15 -0
- package/dist/runtime/shutdown.d.ts.map +1 -0
- package/dist/runtime/shutdown.js +34 -0
- package/dist/test-utils/create-pglite-adapter.d.ts +32 -0
- package/dist/test-utils/create-pglite-adapter.d.ts.map +1 -0
- package/dist/test-utils/create-pglite-adapter.js +107 -0
- package/dist/test-utils/create-plugin-test-app.d.ts +50 -0
- package/dist/test-utils/create-plugin-test-app.d.ts.map +1 -0
- package/dist/test-utils/create-plugin-test-app.js +74 -0
- package/dist/test-utils/create-repository-test-harness.d.ts +8 -0
- package/dist/test-utils/create-repository-test-harness.d.ts.map +1 -0
- package/dist/test-utils/create-repository-test-harness.js +7 -0
- package/dist/test-utils/create-test-config.d.ts +18 -0
- package/dist/test-utils/create-test-config.d.ts.map +1 -0
- package/dist/test-utils/create-test-config.js +172 -0
- package/dist/test-utils/create-test-kernel.d.ts +3 -0
- package/dist/test-utils/create-test-kernel.d.ts.map +1 -0
- package/dist/test-utils/create-test-kernel.js +5 -0
- package/dist/test-utils/create-test-plugin-context.d.ts +42 -0
- package/dist/test-utils/create-test-plugin-context.d.ts.map +1 -0
- package/dist/test-utils/create-test-plugin-context.js +46 -0
- package/dist/test-utils/rest-api-test-utils.d.ts +64 -0
- package/dist/test-utils/rest-api-test-utils.d.ts.map +1 -0
- package/dist/test-utils/rest-api-test-utils.js +207 -0
- package/dist/test-utils/test-actors.d.ts +15 -0
- package/dist/test-utils/test-actors.d.ts.map +1 -0
- package/dist/test-utils/test-actors.js +57 -0
- package/dist/test-utils/typed-hooks.d.ts +43 -0
- package/dist/test-utils/typed-hooks.d.ts.map +1 -0
- package/dist/test-utils/typed-hooks.js +35 -0
- package/dist/testing.d.ts +14 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +13 -0
- package/dist/types/commerce-types.d.ts +34 -0
- package/dist/types/commerce-types.d.ts.map +1 -0
- package/dist/types/commerce-types.js +1 -0
- package/dist/utils/id.d.ts +2 -0
- package/dist/utils/id.d.ts.map +1 -0
- package/dist/utils/id.js +3 -0
- package/dist/utils/logger.d.ts +3 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +16 -0
- package/dist/utils/pagination.d.ts +11 -0
- package/dist/utils/pagination.d.ts.map +1 -0
- package/dist/utils/pagination.js +15 -0
- package/package.json +2 -2
- package/src/auth/setup.ts +26 -0
- package/src/interfaces/rest/routes/customers.ts +7 -1
- package/src/interfaces/rest/routes/inventory.ts +4 -1
- package/src/interfaces/rest/routes/promotions.ts +12 -9
- package/src/interfaces/rest/schemas/promotions.ts +10 -4
- package/src/modules/catalog/service.ts +19 -0
- package/src/modules/promotions/service.ts +32 -0
- package/src/runtime/commerce.ts +1 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Actor } from "../auth/types.js";
|
|
2
|
+
/** Admin with wildcard permissions. Use for setup operations in beforeAll. */
|
|
3
|
+
export declare const testAdminActor: Actor;
|
|
4
|
+
/** Staff with common operational permissions. */
|
|
5
|
+
export declare const testStaffActor: Actor;
|
|
6
|
+
/** Customer with minimal read/write-own permissions. */
|
|
7
|
+
export declare const testCustomerActor: Actor;
|
|
8
|
+
/** Actor with zero permissions. Use for negative auth/perm tests. */
|
|
9
|
+
export declare const testNoPermActor: Actor;
|
|
10
|
+
/**
|
|
11
|
+
* Builds request headers with optional test actor injection.
|
|
12
|
+
* The x-test-actor header is parsed by createPluginTestApp's middleware.
|
|
13
|
+
*/
|
|
14
|
+
export declare function jsonHeaders(actor?: Actor): Record<string, string>;
|
|
15
|
+
//# sourceMappingURL=test-actors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-actors.d.ts","sourceRoot":"","sources":["../../src/test-utils/test-actors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,8EAA8E;AAC9E,eAAO,MAAM,cAAc,EAAE,KAS5B,CAAC;AAEF,iDAAiD;AACjD,eAAO,MAAM,cAAc,EAAE,KAY5B,CAAC;AAEF,wDAAwD;AACxD,eAAO,MAAM,iBAAiB,EAAE,KAS/B,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,eAAe,EAAE,KAS7B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAIjE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** Admin with wildcard permissions. Use for setup operations in beforeAll. */
|
|
2
|
+
export const testAdminActor = {
|
|
3
|
+
type: "user",
|
|
4
|
+
userId: "test-admin-1",
|
|
5
|
+
email: "admin@test.local",
|
|
6
|
+
name: "Test Admin",
|
|
7
|
+
vendorId: null,
|
|
8
|
+
organizationId: "org_default",
|
|
9
|
+
role: "admin",
|
|
10
|
+
permissions: ["*:*"],
|
|
11
|
+
};
|
|
12
|
+
/** Staff with common operational permissions. */
|
|
13
|
+
export const testStaffActor = {
|
|
14
|
+
type: "user",
|
|
15
|
+
userId: "test-staff-1",
|
|
16
|
+
email: "staff@test.local",
|
|
17
|
+
name: "Test Staff",
|
|
18
|
+
vendorId: null,
|
|
19
|
+
organizationId: "org_default",
|
|
20
|
+
role: "staff",
|
|
21
|
+
permissions: [
|
|
22
|
+
"catalog:read", "catalog:create", "catalog:update",
|
|
23
|
+
"inventory:adjust", "orders:read", "orders:create", "orders:update",
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
/** Customer with minimal read/write-own permissions. */
|
|
27
|
+
export const testCustomerActor = {
|
|
28
|
+
type: "user",
|
|
29
|
+
userId: "test-customer-1",
|
|
30
|
+
email: "customer@test.local",
|
|
31
|
+
name: "Test Customer",
|
|
32
|
+
vendorId: null,
|
|
33
|
+
organizationId: "org_default",
|
|
34
|
+
role: "customer",
|
|
35
|
+
permissions: ["catalog:read", "cart:create", "cart:read", "orders:read:own"],
|
|
36
|
+
};
|
|
37
|
+
/** Actor with zero permissions. Use for negative auth/perm tests. */
|
|
38
|
+
export const testNoPermActor = {
|
|
39
|
+
type: "user",
|
|
40
|
+
userId: "test-noperm-1",
|
|
41
|
+
email: "noperm@test.local",
|
|
42
|
+
name: "No Permissions",
|
|
43
|
+
vendorId: null,
|
|
44
|
+
organizationId: "org_default",
|
|
45
|
+
role: "customer",
|
|
46
|
+
permissions: [],
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Builds request headers with optional test actor injection.
|
|
50
|
+
* The x-test-actor header is parsed by createPluginTestApp's middleware.
|
|
51
|
+
*/
|
|
52
|
+
export function jsonHeaders(actor) {
|
|
53
|
+
const headers = { "Content-Type": "application/json" };
|
|
54
|
+
if (actor)
|
|
55
|
+
headers["x-test-actor"] = JSON.stringify(actor);
|
|
56
|
+
return headers;
|
|
57
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { PluginHookRegistration } from "../kernel/plugin/manifest.js";
|
|
2
|
+
import type { HookContext, HookOperation } from "../kernel/hooks/types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a typed before-hook registration for plugins.
|
|
5
|
+
*
|
|
6
|
+
* Narrows the handler signature from the loose `(...args: unknown[]) => unknown`
|
|
7
|
+
* on PluginHookRegistration to the actual `{ data, operation, context }` shape,
|
|
8
|
+
* providing autocomplete on context.jobs.enqueue(), context.logger.info(), etc.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* hooks: () => [
|
|
13
|
+
* beforeHook<{ customerId: string }>("orders.beforeCreate", async ({ data, context }) => {
|
|
14
|
+
* context.logger.info("order_creating", { customerId: data.customerId });
|
|
15
|
+
* return data;
|
|
16
|
+
* }),
|
|
17
|
+
* ],
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function beforeHook<TData>(key: string, handler: (args: {
|
|
21
|
+
data: TData;
|
|
22
|
+
operation: HookOperation;
|
|
23
|
+
context: HookContext;
|
|
24
|
+
}) => Promise<TData> | TData): PluginHookRegistration;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a typed after-hook registration for plugins.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* hooks: () => [
|
|
31
|
+
* afterHook<{ id: string; grandTotal: number }>("orders.afterCreate", async ({ result, context }) => {
|
|
32
|
+
* await context.jobs.enqueue("loyalty:award-points", { orderId: result.id });
|
|
33
|
+
* }),
|
|
34
|
+
* ],
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function afterHook<TData>(key: string, handler: (args: {
|
|
38
|
+
data: TData | null;
|
|
39
|
+
result: TData;
|
|
40
|
+
operation: HookOperation;
|
|
41
|
+
context: HookContext;
|
|
42
|
+
}) => Promise<void> | void): PluginHookRegistration;
|
|
43
|
+
//# sourceMappingURL=typed-hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-hooks.d.ts","sourceRoot":"","sources":["../../src/test-utils/typed-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE3E;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAC9B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,CAAC,IAAI,EAAE;IACd,IAAI,EAAE,KAAK,CAAC;IACZ,SAAS,EAAE,aAAa,CAAC;IACzB,OAAO,EAAE,WAAW,CAAC;CACtB,KAAK,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,GAC3B,sBAAsB,CAExB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAC7B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,CAAC,IAAI,EAAE;IACd,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;IACnB,MAAM,EAAE,KAAK,CAAC;IACd,SAAS,EAAE,aAAa,CAAC;IACzB,OAAO,EAAE,WAAW,CAAC;CACtB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,GACzB,sBAAsB,CAExB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a typed before-hook registration for plugins.
|
|
3
|
+
*
|
|
4
|
+
* Narrows the handler signature from the loose `(...args: unknown[]) => unknown`
|
|
5
|
+
* on PluginHookRegistration to the actual `{ data, operation, context }` shape,
|
|
6
|
+
* providing autocomplete on context.jobs.enqueue(), context.logger.info(), etc.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* hooks: () => [
|
|
11
|
+
* beforeHook<{ customerId: string }>("orders.beforeCreate", async ({ data, context }) => {
|
|
12
|
+
* context.logger.info("order_creating", { customerId: data.customerId });
|
|
13
|
+
* return data;
|
|
14
|
+
* }),
|
|
15
|
+
* ],
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export function beforeHook(key, handler) {
|
|
19
|
+
return { key, handler: handler };
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates a typed after-hook registration for plugins.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* hooks: () => [
|
|
27
|
+
* afterHook<{ id: string; grandTotal: number }>("orders.afterCreate", async ({ result, context }) => {
|
|
28
|
+
* await context.jobs.enqueue("loyalty:award-points", { orderId: result.id });
|
|
29
|
+
* }),
|
|
30
|
+
* ],
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function afterHook(key, handler) {
|
|
34
|
+
return { key, handler: handler };
|
|
35
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test utilities for UnifiedCommerce plugins and apps.
|
|
3
|
+
*
|
|
4
|
+
* Import from "@unifiedcommerce/core/testing" — NOT from "@unifiedcommerce/core".
|
|
5
|
+
* This sub-path is isolated from the main barrel to avoid pulling drizzle-kit,
|
|
6
|
+
* tsx, esbuild, and other heavy dev-only deps into bundlers like Turbopack.
|
|
7
|
+
*/
|
|
8
|
+
export { createTestKernel } from "./test-utils/create-test-kernel.js";
|
|
9
|
+
export { createTestPluginContext } from "./test-utils/create-test-plugin-context.js";
|
|
10
|
+
export { createRepositoryTestHarness } from "./test-utils/create-repository-test-harness.js";
|
|
11
|
+
export { createPluginTestApp, type PluginTestApp, type TestAppEnv } from "./test-utils/create-plugin-test-app.js";
|
|
12
|
+
export { testAdminActor, testStaffActor, testCustomerActor, testNoPermActor, jsonHeaders, } from "./test-utils/test-actors.js";
|
|
13
|
+
export { beforeHook, afterHook } from "./test-utils/typed-hooks.js";
|
|
14
|
+
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AACrF,OAAO,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAClH,OAAO,EACL,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,eAAe,EAClE,WAAW,GACZ,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC"}
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test utilities for UnifiedCommerce plugins and apps.
|
|
3
|
+
*
|
|
4
|
+
* Import from "@unifiedcommerce/core/testing" — NOT from "@unifiedcommerce/core".
|
|
5
|
+
* This sub-path is isolated from the main barrel to avoid pulling drizzle-kit,
|
|
6
|
+
* tsx, esbuild, and other heavy dev-only deps into bundlers like Turbopack.
|
|
7
|
+
*/
|
|
8
|
+
export { createTestKernel } from "./test-utils/create-test-kernel.js";
|
|
9
|
+
export { createTestPluginContext } from "./test-utils/create-test-plugin-context.js";
|
|
10
|
+
export { createRepositoryTestHarness } from "./test-utils/create-repository-test-harness.js";
|
|
11
|
+
export { createPluginTestApp } from "./test-utils/create-plugin-test-app.js";
|
|
12
|
+
export { testAdminActor, testStaffActor, testCustomerActor, testNoPermActor, jsonHeaders, } from "./test-utils/test-actors.js";
|
|
13
|
+
export { beforeHook, afterHook } from "./test-utils/typed-hooks.js";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { sellableEntities } from "../modules/catalog/schema.js";
|
|
2
|
+
import type { orders } from "../modules/orders/schema.js";
|
|
3
|
+
import type { carts } from "../modules/cart/schema.js";
|
|
4
|
+
import type { customers } from "../modules/customers/schema.js";
|
|
5
|
+
import type { inventoryLevels } from "../modules/inventory/schema.js";
|
|
6
|
+
/**
|
|
7
|
+
* Central type map for all commerce entities.
|
|
8
|
+
*
|
|
9
|
+
* Plugins can augment this interface via TypeScript module augmentation:
|
|
10
|
+
*
|
|
11
|
+
* ```typescript
|
|
12
|
+
* declare module "@unifiedcommerce/core" {
|
|
13
|
+
* interface CommerceModuleTypes {
|
|
14
|
+
* LoyaltyPoints: {
|
|
15
|
+
* id: string;
|
|
16
|
+
* customerId: string;
|
|
17
|
+
* points: number;
|
|
18
|
+
* tier: "bronze" | "silver" | "gold";
|
|
19
|
+
* };
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* This enables plugin types to be referenced without importing
|
|
25
|
+
* internal schema modules.
|
|
26
|
+
*/
|
|
27
|
+
export interface CommerceModuleTypes {
|
|
28
|
+
Product: typeof sellableEntities.$inferSelect;
|
|
29
|
+
Order: typeof orders.$inferSelect;
|
|
30
|
+
Cart: typeof carts.$inferSelect;
|
|
31
|
+
Customer: typeof customers.$inferSelect;
|
|
32
|
+
InventoryLevel: typeof inventoryLevels.$inferSelect;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=commerce-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commerce-types.d.ts","sourceRoot":"","sources":["../../src/types/commerce-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,gBAAgB,CAAC,YAAY,CAAC;IAC9C,KAAK,EAAE,OAAO,MAAM,CAAC,YAAY,CAAC;IAClC,IAAI,EAAE,OAAO,KAAK,CAAC,YAAY,CAAC;IAChC,QAAQ,EAAE,OAAO,SAAS,CAAC,YAAY,CAAC;IACxC,cAAc,EAAE,OAAO,eAAe,CAAC,YAAY,CAAC;CACrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../src/utils/id.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,IAAI,MAAM,CAE/B"}
|
package/dist/utils/id.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAEvD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAelD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function createLogger(scope) {
|
|
2
|
+
return {
|
|
3
|
+
info(message, data) {
|
|
4
|
+
// eslint-disable-next-line no-console
|
|
5
|
+
console.info(`[${scope}] ${message}`, data ?? "");
|
|
6
|
+
},
|
|
7
|
+
warn(message, data) {
|
|
8
|
+
// eslint-disable-next-line no-console
|
|
9
|
+
console.warn(`[${scope}] ${message}`, data ?? "");
|
|
10
|
+
},
|
|
11
|
+
error(message, data) {
|
|
12
|
+
// eslint-disable-next-line no-console
|
|
13
|
+
console.error(`[${scope}] ${message}`, data ?? "");
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface Pagination {
|
|
2
|
+
page: number;
|
|
3
|
+
limit: number;
|
|
4
|
+
total: number;
|
|
5
|
+
totalPages: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function paginate<T>(items: T[], page: number, limit: number): {
|
|
8
|
+
items: T[];
|
|
9
|
+
pagination: Pagination;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/utils/pagination.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,CAc3G"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function paginate(items, page, limit) {
|
|
2
|
+
const safeLimit = Math.max(1, limit);
|
|
3
|
+
const safePage = Math.max(1, page);
|
|
4
|
+
const start = (safePage - 1) * safeLimit;
|
|
5
|
+
const sliced = items.slice(start, start + safeLimit);
|
|
6
|
+
return {
|
|
7
|
+
items: sliced,
|
|
8
|
+
pagination: {
|
|
9
|
+
page: safePage,
|
|
10
|
+
limit: safeLimit,
|
|
11
|
+
total: items.length,
|
|
12
|
+
totalPages: Math.max(1, Math.ceil(items.length / safeLimit)),
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unifiedcommerce/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"scripts": {
|
|
38
38
|
"generate:plugins": "node ./scripts/generate-plugin-types.mjs",
|
|
39
39
|
"check:store-guard": "node ./scripts/check-store-guard.mjs",
|
|
40
|
-
"build": "npm run generate:plugins && npm run check:store-guard && tsc -p tsconfig.build.json",
|
|
40
|
+
"build": "rm -rf dist tsconfig.build.tsbuildinfo && npm run generate:plugins && npm run check:store-guard && tsc -p tsconfig.build.json",
|
|
41
41
|
"check-types": "npm run generate:plugins && npm run check:store-guard && tsc --noEmit",
|
|
42
42
|
"lint": "eslint . --max-warnings 1000",
|
|
43
43
|
"test": "vitest run"
|
package/src/auth/setup.ts
CHANGED
|
@@ -105,6 +105,32 @@ export function createAuth(
|
|
|
105
105
|
provider: resolveAuthDbProvider(db.provider),
|
|
106
106
|
schema: authSchema,
|
|
107
107
|
}),
|
|
108
|
+
databaseHooks: {
|
|
109
|
+
user: {
|
|
110
|
+
create: {
|
|
111
|
+
after: async (user: { id: string; email?: string | null; name?: string | null }) => {
|
|
112
|
+
// Auto-create customer record on signup. Uses the Drizzle db
|
|
113
|
+
// directly because the kernel isn't fully initialized yet during
|
|
114
|
+
// auth setup. Best-effort — getByUserId() lazy-creates as fallback.
|
|
115
|
+
try {
|
|
116
|
+
const { customers } = await import("../kernel/database/schema.js");
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
118
|
+
const drizzle = db.db as any;
|
|
119
|
+
await drizzle.insert(customers).values({
|
|
120
|
+
organizationId: "org_default",
|
|
121
|
+
userId: user.id,
|
|
122
|
+
email: user.email ?? null,
|
|
123
|
+
firstName: user.name?.split(" ")[0] ?? null,
|
|
124
|
+
lastName: user.name?.split(" ").slice(1).join(" ") ?? null,
|
|
125
|
+
metadata: {},
|
|
126
|
+
}).onConflictDoNothing();
|
|
127
|
+
} catch {
|
|
128
|
+
// Silent — lazy creation in getByUserId() is the fallback
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
},
|
|
108
134
|
trustedOrigins: config.auth?.trustedOrigins ?? [],
|
|
109
135
|
emailAndPassword: {
|
|
110
136
|
enabled: true,
|
|
@@ -7,11 +7,15 @@ import {
|
|
|
7
7
|
getCustomerOrdersRoute,
|
|
8
8
|
getCustomerAddressesRoute,
|
|
9
9
|
} from "../schemas/customers.js";
|
|
10
|
-
import { type AppEnv, mapErrorToResponse, mapErrorToStatus, parsePagination } from "../utils.js";
|
|
10
|
+
import { type AppEnv, mapErrorToResponse, mapErrorToStatus, parsePagination, requirePerm } from "../utils.js";
|
|
11
11
|
|
|
12
12
|
export function customerRoutes(kernel: Kernel) {
|
|
13
13
|
const router = new OpenAPIHono<AppEnv>();
|
|
14
14
|
|
|
15
|
+
// All customer admin routes require authentication + customers:read
|
|
16
|
+
router.use("/*", requirePerm("customers:read"));
|
|
17
|
+
router.use("/", requirePerm("customers:read"));
|
|
18
|
+
|
|
15
19
|
// @ts-expect-error -- openapi handler union return type
|
|
16
20
|
router.openapi(listCustomersRoute, async (c) => {
|
|
17
21
|
const actor = c.get("actor");
|
|
@@ -42,6 +46,8 @@ export function customerRoutes(kernel: Kernel) {
|
|
|
42
46
|
return c.json({ data: result.value });
|
|
43
47
|
});
|
|
44
48
|
|
|
49
|
+
// PATCH requires customers:update (checked in handler since middleware can't distinguish methods)
|
|
50
|
+
|
|
45
51
|
// @ts-expect-error -- openapi handler union return type
|
|
46
52
|
router.openapi(updateCustomerRoute, async (c) => {
|
|
47
53
|
const { id } = c.req.valid("param");
|
|
@@ -9,11 +9,14 @@ import {
|
|
|
9
9
|
listWarehousesRoute,
|
|
10
10
|
listInventoryLevelsRoute,
|
|
11
11
|
} from "../schemas/inventory.js";
|
|
12
|
-
import { type AppEnv, mapErrorToResponse, mapErrorToStatus } from "../utils.js";
|
|
12
|
+
import { type AppEnv, mapErrorToResponse, mapErrorToStatus, requirePerm } from "../utils.js";
|
|
13
13
|
|
|
14
14
|
export function inventoryRoutes(kernel: Kernel) {
|
|
15
15
|
const router = new OpenAPIHono<AppEnv>();
|
|
16
16
|
|
|
17
|
+
// Inventory levels listing requires inventory:read
|
|
18
|
+
router.use("/levels", requirePerm("inventory:read"));
|
|
19
|
+
|
|
17
20
|
// @ts-expect-error -- openapi handler union return type
|
|
18
21
|
router.openapi(listInventoryLevelsRoute, async (c) => {
|
|
19
22
|
const actor = c.get("actor");
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
2
|
import { rateLimiter } from "hono-rate-limiter";
|
|
3
3
|
import type { Kernel } from "../../../runtime/kernel.js";
|
|
4
|
-
import { createPromotionRoute, validatePromotionRoute, deactivatePromotionRoute,
|
|
4
|
+
import { createPromotionRoute, validatePromotionRoute, deactivatePromotionRoute, listPromotionsRoute } from "../schemas/promotions.js";
|
|
5
|
+
import type { PromotionStatusFilter } from "../../../modules/promotions/service.js";
|
|
5
6
|
import { type AppEnv, mapErrorToResponse, mapErrorToStatus, requirePerm } from "../utils.js";
|
|
6
7
|
import { resolveOrgId } from "../../../auth/org.js";
|
|
7
8
|
|
|
@@ -37,17 +38,19 @@ export function promotionRoutes(kernel: Kernel) {
|
|
|
37
38
|
return c.json({ data: result.value }, 201);
|
|
38
39
|
});
|
|
39
40
|
|
|
40
|
-
// List
|
|
41
|
-
router.use("/active", requirePerm("promotions:read"));
|
|
42
|
-
|
|
41
|
+
// List promotions — supports ?status= filter (active/inactive/expired/scheduled)
|
|
43
42
|
// @ts-expect-error -- openapi handler union return type
|
|
44
|
-
router.openapi(
|
|
45
|
-
const actor =
|
|
46
|
-
const
|
|
43
|
+
router.openapi(listPromotionsRoute, async (c) => {
|
|
44
|
+
const actor = c.get("actor");
|
|
45
|
+
const status = c.req.query("status") as PromotionStatusFilter | undefined;
|
|
46
|
+
const result = await kernel.services.promotions.list(
|
|
47
|
+
status ? { status } : undefined,
|
|
48
|
+
actor,
|
|
49
|
+
);
|
|
47
50
|
if (!result.ok) {
|
|
48
|
-
return
|
|
51
|
+
return c.json(mapErrorToResponse(result.error), mapErrorToStatus(result.error));
|
|
49
52
|
}
|
|
50
|
-
return
|
|
53
|
+
return c.json({ data: result.value });
|
|
51
54
|
});
|
|
52
55
|
|
|
53
56
|
// @ts-expect-error -- openapi() enforces strict response typing but our handler
|
|
@@ -35,15 +35,21 @@ const PromotionIdParam = z.object({
|
|
|
35
35
|
|
|
36
36
|
// ─── Route Definitions ──────────────────────────────────────────────────────
|
|
37
37
|
|
|
38
|
-
export const
|
|
38
|
+
export const listPromotionsRoute = createRoute({
|
|
39
39
|
method: "get",
|
|
40
40
|
path: "/",
|
|
41
41
|
tags: ["Promotions"],
|
|
42
|
-
summary: "List
|
|
42
|
+
summary: "List promotions",
|
|
43
|
+
description: "Lists promotions. Filter by status: active (currently valid), inactive (deactivated), expired (past validUntil), scheduled (future validFrom). Omit status to return all.",
|
|
44
|
+
request: {
|
|
45
|
+
query: z.object({
|
|
46
|
+
status: z.enum(["active", "inactive", "expired", "scheduled"]).optional().openapi({ example: "active" }),
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
43
49
|
responses: {
|
|
44
50
|
200: {
|
|
45
|
-
content: { "application/json": { schema:
|
|
46
|
-
description: "
|
|
51
|
+
content: { "application/json": { schema: z.object({ data: z.array(z.record(z.string(), z.unknown())) }) } },
|
|
52
|
+
description: "Promotions list",
|
|
47
53
|
},
|
|
48
54
|
},
|
|
49
55
|
});
|
|
@@ -120,6 +120,7 @@ export interface CatalogEntityHydrated extends SellableEntity {
|
|
|
120
120
|
categories?: EntityCategory[];
|
|
121
121
|
brands?: EntityBrand[];
|
|
122
122
|
media?: Array<{ mediaAssetId: string; role: string; variantId?: string }>;
|
|
123
|
+
pricing?: Array<{ currency: string; amount: number; compareAtAmount?: number | null }>;
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
export interface CatalogService {
|
|
@@ -482,6 +483,24 @@ export class CatalogServiceImpl implements CatalogService {
|
|
|
482
483
|
hydrated.media = [];
|
|
483
484
|
}
|
|
484
485
|
|
|
486
|
+
if (options?.includePricing) {
|
|
487
|
+
try {
|
|
488
|
+
const pricingService = this.deps.services.pricing as {
|
|
489
|
+
listPrices: (filter: { entityId: string }) => Promise<{ ok: boolean; value?: { prices: Array<{ currency: string; amount: number; compareAtAmount?: number | null }> } }>;
|
|
490
|
+
};
|
|
491
|
+
const priceResult = await pricingService.listPrices({ entityId: entity.id });
|
|
492
|
+
if (priceResult.ok && priceResult.value) {
|
|
493
|
+
hydrated.pricing = priceResult.value.prices.map((p) => ({
|
|
494
|
+
currency: p.currency,
|
|
495
|
+
amount: p.amount,
|
|
496
|
+
compareAtAmount: p.compareAtAmount ?? null,
|
|
497
|
+
}));
|
|
498
|
+
}
|
|
499
|
+
} catch {
|
|
500
|
+
// Pricing service may not be initialized — leave pricing undefined
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
485
504
|
return hydrated;
|
|
486
505
|
}
|
|
487
506
|
|
|
@@ -23,6 +23,9 @@ export type PromotionType =
|
|
|
23
23
|
| "free_shipping"
|
|
24
24
|
| "buy_x_get_y";
|
|
25
25
|
|
|
26
|
+
/** Filter status for listing promotions. Used by the REST API and service layer. */
|
|
27
|
+
export type PromotionStatusFilter = "active" | "inactive" | "expired" | "scheduled";
|
|
28
|
+
|
|
26
29
|
interface PromotionServiceDeps {
|
|
27
30
|
repository: PromotionsRepository;
|
|
28
31
|
catalogRepository: CatalogRepository;
|
|
@@ -222,6 +225,35 @@ export class PromotionService {
|
|
|
222
225
|
return Ok(updated);
|
|
223
226
|
}
|
|
224
227
|
|
|
228
|
+
async list(
|
|
229
|
+
filter?: { status?: PromotionStatusFilter },
|
|
230
|
+
actor?: Actor | null,
|
|
231
|
+
ctx?: TxContext,
|
|
232
|
+
): Promise<Result<Promotion[]>> {
|
|
233
|
+
const orgId = resolveOrgId(actor ?? ctx?.actor ?? null);
|
|
234
|
+
const all = await this.repo.findAll(orgId, ctx);
|
|
235
|
+
const now = new Date();
|
|
236
|
+
|
|
237
|
+
if (!filter?.status) return Ok(sortByPriority(all));
|
|
238
|
+
|
|
239
|
+
const filtered = all.filter((p) => {
|
|
240
|
+
const isActive = p.isActive && matchesWindow(p, now);
|
|
241
|
+
const isExpired = p.isActive && p.validUntil && new Date(p.validUntil) < now;
|
|
242
|
+
const isScheduled = p.isActive && p.validFrom && new Date(p.validFrom) > now;
|
|
243
|
+
const isInactive = !p.isActive;
|
|
244
|
+
|
|
245
|
+
switch (filter.status) {
|
|
246
|
+
case "active": return isActive;
|
|
247
|
+
case "inactive": return isInactive;
|
|
248
|
+
case "expired": return isExpired;
|
|
249
|
+
case "scheduled": return isScheduled;
|
|
250
|
+
default: return true;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
return Ok(sortByPriority(filtered));
|
|
255
|
+
}
|
|
256
|
+
|
|
225
257
|
async listActive(
|
|
226
258
|
actor?: Actor | null,
|
|
227
259
|
timestamp = new Date(),
|
package/src/runtime/commerce.ts
CHANGED
|
@@ -121,6 +121,7 @@ export async function createCommerce(
|
|
|
121
121
|
): Promise<CommerceInstance> {
|
|
122
122
|
const kernel = createKernel(config);
|
|
123
123
|
await ensureDefaultOrg(kernel.database.db);
|
|
124
|
+
|
|
124
125
|
const auth = createAuth(kernel.database, config);
|
|
125
126
|
const logger = createLogger(config);
|
|
126
127
|
|