@porulle/core 0.1.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/README.md +56 -0
- 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 +220 -0
- package/dist/auth/org.d.ts +28 -0
- package/dist/auth/org.d.ts.map +1 -0
- package/dist/auth/org.js +68 -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 +137 -0
- package/dist/auth/strict-org-resolution.d.ts +4 -0
- package/dist/auth/strict-org-resolution.d.ts.map +1 -0
- package/dist/auth/strict-org-resolution.js +13 -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 +83 -0
- package/dist/config/define-config.d.ts +10 -0
- package/dist/config/define-config.d.ts.map +1 -0
- package/dist/config/define-config.js +64 -0
- package/dist/config/types.d.ts +412 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +1 -0
- package/dist/drizzle.d.ts +28 -0
- package/dist/drizzle.d.ts.map +1 -0
- package/dist/drizzle.js +24 -0
- package/dist/generated/plugin-manifest.d.ts +45 -0
- package/dist/generated/plugin-manifest.d.ts.map +1 -0
- package/dist/generated/plugin-manifest.js +19 -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 +146 -0
- package/dist/hooks/checkout.d.ts +99 -0
- package/dist/hooks/checkout.d.ts.map +1 -0
- package/dist/hooks/checkout.js +331 -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 +79 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -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/index.d.ts +5 -0
- package/dist/interfaces/rest/index.d.ts.map +1 -0
- package/dist/interfaces/rest/index.js +94 -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/compensation-failures.d.ts +5 -0
- package/dist/interfaces/rest/routes/admin/compensation-failures.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/admin/compensation-failures.js +114 -0
- package/dist/interfaces/rest/routes/admin/permissions.d.ts +5 -0
- package/dist/interfaces/rest/routes/admin/permissions.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/admin/permissions.js +28 -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 +61 -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 +269 -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 +220 -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/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 +66 -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 +61 -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 +72 -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/admin-permissions.d.ts +27 -0
- package/dist/interfaces/rest/schemas/admin-permissions.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/admin-permissions.js +25 -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/compensation-failures.d.ts +122 -0
- package/dist/interfaces/rest/schemas/compensation-failures.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/compensation-failures.js +84 -0
- package/dist/interfaces/rest/schemas/customer-portal.d.ts +2237 -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 +1877 -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 +4138 -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 +80 -0
- package/dist/kernel/compensation/repository.d.ts +47 -0
- package/dist/kernel/compensation/repository.d.ts.map +1 -0
- package/dist/kernel/compensation/repository.js +93 -0
- package/dist/kernel/compensation/schema.d.ts +217 -0
- package/dist/kernel/compensation/schema.d.ts.map +1 -0
- package/dist/kernel/compensation/schema.js +29 -0
- package/dist/kernel/compensation/types.d.ts +29 -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-db-context.d.ts +3 -0
- package/dist/kernel/database/plugin-db-context.d.ts.map +1 -0
- package/dist/kernel/database/plugin-db-context.js +8 -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 +26 -0
- package/dist/kernel/database/schema.d.ts.map +1 -0
- package/dist/kernel/database/schema.js +39 -0
- package/dist/kernel/database/scoped-db.d.ts +14 -0
- package/dist/kernel/database/scoped-db.d.ts.map +1 -0
- package/dist/kernel/database/scoped-db.js +103 -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 +14 -0
- package/dist/kernel/error-mapper.d.ts.map +1 -0
- package/dist/kernel/error-mapper.js +93 -0
- package/dist/kernel/errors.d.ts +43 -0
- package/dist/kernel/errors.d.ts.map +1 -0
- package/dist/kernel/errors.js +78 -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 +32 -0
- package/dist/kernel/hooks/create-context.d.ts.map +1 -0
- package/dist/kernel/hooks/create-context.js +23 -0
- package/dist/kernel/hooks/executor.d.ts +13 -0
- package/dist/kernel/hooks/executor.d.ts.map +1 -0
- package/dist/kernel/hooks/executor.js +56 -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 +40 -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/builtin-job-tasks.d.ts +3 -0
- package/dist/kernel/jobs/builtin-job-tasks.d.ts.map +1 -0
- package/dist/kernel/jobs/builtin-job-tasks.js +6 -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 +46 -0
- package/dist/kernel/jobs/reaper.d.ts +12 -0
- package/dist/kernel/jobs/reaper.d.ts.map +1 -0
- package/dist/kernel/jobs/reaper.js +62 -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 +118 -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 +40 -0
- package/dist/kernel/jobs/types.d.ts.map +1 -0
- package/dist/kernel/jobs/types.js +4 -0
- package/dist/kernel/local-api.d.ts +104 -0
- package/dist/kernel/local-api.d.ts.map +1 -0
- package/dist/kernel/local-api.js +89 -0
- package/dist/kernel/module/define.d.ts +21 -0
- package/dist/kernel/module/define.d.ts.map +1 -0
- package/dist/kernel/module/define.js +3 -0
- package/dist/kernel/module/index.d.ts +4 -0
- package/dist/kernel/module/index.d.ts.map +1 -0
- package/dist/kernel/module/index.js +2 -0
- package/dist/kernel/module/topo-sort.d.ts +7 -0
- package/dist/kernel/module/topo-sort.d.ts.map +1 -0
- package/dist/kernel/module/topo-sort.js +89 -0
- package/dist/kernel/plugin/manifest.d.ts +84 -0
- package/dist/kernel/plugin/manifest.d.ts.map +1 -0
- package/dist/kernel/plugin/manifest.js +196 -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/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/module.d.ts +3 -0
- package/dist/modules/analytics/module.d.ts.map +1 -0
- package/dist/modules/analytics/module.js +18 -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/index.d.ts +2 -0
- package/dist/modules/audit/index.d.ts.map +1 -0
- package/dist/modules/audit/index.js +1 -0
- package/dist/modules/audit/module.d.ts +180 -0
- package/dist/modules/audit/module.d.ts.map +1 -0
- package/dist/modules/audit/module.js +8 -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/module.d.ts +14 -0
- package/dist/modules/cart/module.d.ts.map +1 -0
- package/dist/modules/cart/module.js +17 -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 +87 -0
- package/dist/modules/cart/service.d.ts.map +1 -0
- package/dist/modules/cart/service.js +454 -0
- package/dist/modules/catalog/brand-service.d.ts +18 -0
- package/dist/modules/catalog/brand-service.d.ts.map +1 -0
- package/dist/modules/catalog/brand-service.js +126 -0
- package/dist/modules/catalog/category-service.d.ts +17 -0
- package/dist/modules/catalog/category-service.d.ts.map +1 -0
- package/dist/modules/catalog/category-service.js +128 -0
- package/dist/modules/catalog/entity-service.d.ts +30 -0
- package/dist/modules/catalog/entity-service.d.ts.map +1 -0
- package/dist/modules/catalog/entity-service.js +481 -0
- package/dist/modules/catalog/module.d.ts +21 -0
- package/dist/modules/catalog/module.d.ts.map +1 -0
- package/dist/modules/catalog/module.js +28 -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 +459 -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 +167 -0
- package/dist/modules/catalog/service.d.ts.map +1 -0
- package/dist/modules/catalog/service.js +96 -0
- package/dist/modules/customers/index.d.ts +2 -0
- package/dist/modules/customers/index.d.ts.map +1 -0
- package/dist/modules/customers/index.js +1 -0
- package/dist/modules/customers/module.d.ts +563 -0
- package/dist/modules/customers/module.d.ts.map +1 -0
- package/dist/modules/customers/module.js +19 -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 +32 -0
- package/dist/modules/customers/service.d.ts.map +1 -0
- package/dist/modules/customers/service.js +132 -0
- package/dist/modules/fulfillment/module.d.ts +13 -0
- package/dist/modules/fulfillment/module.d.ts.map +1 -0
- package/dist/modules/fulfillment/module.js +22 -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 +63 -0
- package/dist/modules/fulfillment/service.d.ts.map +1 -0
- package/dist/modules/fulfillment/service.js +351 -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/module.d.ts +13 -0
- package/dist/modules/inventory/module.d.ts.map +1 -0
- package/dist/modules/inventory/module.js +20 -0
- package/dist/modules/inventory/repository/index.d.ts +96 -0
- package/dist/modules/inventory/repository/index.d.ts.map +1 -0
- package/dist/modules/inventory/repository/index.js +361 -0
- package/dist/modules/inventory/schema.d.ts +604 -0
- package/dist/modules/inventory/schema.d.ts.map +1 -0
- package/dist/modules/inventory/schema.js +78 -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 +70 -0
- package/dist/modules/inventory/service.d.ts.map +1 -0
- package/dist/modules/inventory/service.js +284 -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/index.d.ts +2 -0
- package/dist/modules/media/index.d.ts.map +1 -0
- package/dist/modules/media/index.js +1 -0
- package/dist/modules/media/module.d.ts +292 -0
- package/dist/modules/media/module.d.ts.map +1 -0
- package/dist/modules/media/module.js +22 -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 +45 -0
- package/dist/modules/media/service.d.ts.map +1 -0
- package/dist/modules/media/service.js +149 -0
- package/dist/modules/orders/module.d.ts +25 -0
- package/dist/modules/orders/module.d.ts.map +1 -0
- package/dist/modules/orders/module.js +32 -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 +204 -0
- package/dist/modules/orders/schema.d.ts +689 -0
- package/dist/modules/orders/schema.d.ts.map +1 -0
- package/dist/modules/orders/schema.js +64 -0
- package/dist/modules/orders/sequences.d.ts +2 -0
- package/dist/modules/orders/sequences.d.ts.map +1 -0
- package/dist/modules/orders/sequences.js +5 -0
- package/dist/modules/orders/service.d.ts +81 -0
- package/dist/modules/orders/service.d.ts.map +1 -0
- package/dist/modules/orders/service.js +325 -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/index.d.ts +2 -0
- package/dist/modules/organization/index.d.ts.map +1 -0
- package/dist/modules/organization/index.js +1 -0
- package/dist/modules/organization/module.d.ts +205 -0
- package/dist/modules/organization/module.d.ts.map +1 -0
- package/dist/modules/organization/module.js +8 -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 +40 -0
- package/dist/modules/payments/adapter.d.ts.map +1 -0
- package/dist/modules/payments/adapter.js +1 -0
- package/dist/modules/payments/module.d.ts +3 -0
- package/dist/modules/payments/module.d.ts.map +1 -0
- package/dist/modules/payments/module.js +7 -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/index.d.ts +2 -0
- package/dist/modules/pricing/index.d.ts.map +1 -0
- package/dist/modules/pricing/index.js +1 -0
- package/dist/modules/pricing/module.d.ts +14 -0
- package/dist/modules/pricing/module.d.ts.map +1 -0
- package/dist/modules/pricing/module.js +16 -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 +179 -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 +67 -0
- package/dist/modules/pricing/service.d.ts.map +1 -0
- package/dist/modules/pricing/service.js +329 -0
- package/dist/modules/promotions/module.d.ts +14 -0
- package/dist/modules/promotions/module.d.ts.map +1 -0
- package/dist/modules/promotions/module.js +18 -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 +90 -0
- package/dist/modules/promotions/service.d.ts.map +1 -0
- package/dist/modules/promotions/service.js +387 -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/module.d.ts +8 -0
- package/dist/modules/search/module.d.ts.map +1 -0
- package/dist/modules/search/module.js +17 -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 +243 -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/module.d.ts +8 -0
- package/dist/modules/shipping/module.d.ts.map +1 -0
- package/dist/modules/shipping/module.js +11 -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/module.d.ts +3 -0
- package/dist/modules/tax/module.d.ts.map +1 -0
- package/dist/modules/tax/module.js +9 -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 +35 -0
- package/dist/modules/webhooks/index.d.ts +2 -0
- package/dist/modules/webhooks/index.d.ts.map +1 -0
- package/dist/modules/webhooks/index.js +1 -0
- package/dist/modules/webhooks/module.d.ts +403 -0
- package/dist/modules/webhooks/module.d.ts.map +1 -0
- package/dist/modules/webhooks/module.js +15 -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 +183 -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 +94 -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 +42 -0
- package/dist/modules/webhooks/worker.d.ts +28 -0
- package/dist/modules/webhooks/worker.d.ts.map +1 -0
- package/dist/modules/webhooks/worker.js +133 -0
- package/dist/runtime/commerce.d.ts +110 -0
- package/dist/runtime/commerce.d.ts.map +1 -0
- package/dist/runtime/commerce.js +48 -0
- package/dist/runtime/kernel-modules.d.ts +1714 -0
- package/dist/runtime/kernel-modules.d.ts.map +1 -0
- package/dist/runtime/kernel-modules.js +62 -0
- package/dist/runtime/kernel-register-hooks.d.ts +4 -0
- package/dist/runtime/kernel-register-hooks.d.ts.map +1 -0
- package/dist/runtime/kernel-register-hooks.js +46 -0
- package/dist/runtime/kernel-types.d.ts +65 -0
- package/dist/runtime/kernel-types.d.ts.map +1 -0
- package/dist/runtime/kernel-types.js +36 -0
- package/dist/runtime/kernel.d.ts +6 -0
- package/dist/runtime/kernel.d.ts.map +1 -0
- package/dist/runtime/kernel.js +113 -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/server.d.ts +37 -0
- package/dist/runtime/server.d.ts.map +1 -0
- package/dist/runtime/server.js +398 -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/runtime/url-alias-rewrite.d.ts +3 -0
- package/dist/runtime/url-alias-rewrite.d.ts.map +1 -0
- package/dist/runtime/url-alias-rewrite.js +33 -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 +90 -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 +38 -0
- package/dist/test-utils/create-test-plugin-context.d.ts.map +1 -0
- package/dist/test-utils/create-test-plugin-context.js +39 -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 +208 -0
- package/dist/test-utils/test-actors.d.ts +21 -0
- package/dist/test-utils/test-actors.d.ts.map +1 -0
- package/dist/test-utils/test-actors.js +64 -0
- package/dist/test-utils/typed-hooks.d.ts +44 -0
- package/dist/test-utils/typed-hooks.d.ts.map +1 -0
- package/dist/test-utils/typed-hooks.js +36 -0
- package/dist/testing.d.ts +15 -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/agent-prompt.d.ts +2 -0
- package/dist/utils/agent-prompt.d.ts.map +1 -0
- package/dist/utils/agent-prompt.js +12 -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 +89 -0
- package/src/adapters/console-email.ts +43 -0
- package/src/auth/access.ts +187 -0
- package/src/auth/auth-schema.ts +139 -0
- package/src/auth/middleware.ts +257 -0
- package/src/auth/org.ts +83 -0
- package/src/auth/permissions.ts +28 -0
- package/src/auth/setup.ts +187 -0
- package/src/auth/strict-org-resolution.ts +14 -0
- package/src/auth/system-actor.ts +19 -0
- package/src/auth/types.ts +10 -0
- package/src/config/defaults.ts +85 -0
- package/src/config/define-config.ts +81 -0
- package/src/config/types.ts +417 -0
- package/src/drizzle.ts +95 -0
- package/src/generated/plugin-capabilities.d.ts +19 -0
- package/src/generated/plugin-manifest.ts +22 -0
- package/src/generated/plugin-repositories.d.ts +19 -0
- package/src/hooks/checkout-completion.ts +285 -0
- package/src/hooks/checkout.ts +695 -0
- package/src/hooks/order-emails.ts +62 -0
- package/src/index.ts +213 -0
- package/src/interfaces/rest/customer-portal.ts +299 -0
- package/src/interfaces/rest/index.ts +105 -0
- package/src/interfaces/rest/router.ts +333 -0
- package/src/interfaces/rest/routes/admin/compensation-failures.ts +160 -0
- package/src/interfaces/rest/routes/admin/permissions.ts +37 -0
- package/src/interfaces/rest/routes/admin-jobs.ts +58 -0
- package/src/interfaces/rest/routes/audit.ts +50 -0
- package/src/interfaces/rest/routes/carts.ts +100 -0
- package/src/interfaces/rest/routes/catalog.ts +508 -0
- package/src/interfaces/rest/routes/checkout.ts +289 -0
- package/src/interfaces/rest/routes/customers.ts +100 -0
- package/src/interfaces/rest/routes/inventory.ts +93 -0
- package/src/interfaces/rest/routes/media.ts +87 -0
- package/src/interfaces/rest/routes/orders.ts +78 -0
- package/src/interfaces/rest/routes/payments.ts +60 -0
- package/src/interfaces/rest/routes/pricing.ts +78 -0
- package/src/interfaces/rest/routes/promotions.ts +96 -0
- package/src/interfaces/rest/routes/search.ts +81 -0
- package/src/interfaces/rest/routes/webhooks.ts +49 -0
- package/src/interfaces/rest/schemas/admin-jobs.ts +40 -0
- package/src/interfaces/rest/schemas/admin-permissions.ts +27 -0
- package/src/interfaces/rest/schemas/audit.ts +46 -0
- package/src/interfaces/rest/schemas/carts.ts +125 -0
- package/src/interfaces/rest/schemas/catalog.ts +450 -0
- package/src/interfaces/rest/schemas/checkout.ts +66 -0
- package/src/interfaces/rest/schemas/compensation-failures.ts +89 -0
- package/src/interfaces/rest/schemas/customer-portal.ts +195 -0
- package/src/interfaces/rest/schemas/customers.ts +155 -0
- package/src/interfaces/rest/schemas/inventory.ts +159 -0
- package/src/interfaces/rest/schemas/media.ts +75 -0
- package/src/interfaces/rest/schemas/orders.ts +104 -0
- package/src/interfaces/rest/schemas/pricing.ts +80 -0
- package/src/interfaces/rest/schemas/promotions.ts +116 -0
- package/src/interfaces/rest/schemas/responses.ts +96 -0
- package/src/interfaces/rest/schemas/search.ts +58 -0
- package/src/interfaces/rest/schemas/shared.ts +62 -0
- package/src/interfaces/rest/schemas/webhooks.ts +68 -0
- package/src/interfaces/rest/utils.ts +104 -0
- package/src/interfaces/rest/webhook-router.ts +50 -0
- package/src/kernel/compensation/executor.ts +123 -0
- package/src/kernel/compensation/repository.ts +157 -0
- package/src/kernel/compensation/schema.ts +45 -0
- package/src/kernel/compensation/types.ts +30 -0
- package/src/kernel/database/adapter.ts +21 -0
- package/src/kernel/database/drizzle-db.ts +56 -0
- package/src/kernel/database/migrate.ts +76 -0
- package/src/kernel/database/plugin-db-context.ts +14 -0
- package/src/kernel/database/plugin-types.ts +34 -0
- package/src/kernel/database/schema.ts +53 -0
- package/src/kernel/database/scoped-db.ts +112 -0
- package/src/kernel/database/tx-context.ts +46 -0
- package/src/kernel/error-mapper.ts +118 -0
- package/src/kernel/errors.ts +100 -0
- package/src/kernel/factory/repository-factory.ts +244 -0
- package/src/kernel/hooks/create-context.ts +52 -0
- package/src/kernel/hooks/executor.ts +95 -0
- package/src/kernel/hooks/registry.ts +74 -0
- package/src/kernel/hooks/types.ts +55 -0
- package/src/kernel/http-error.ts +44 -0
- package/src/kernel/jobs/adapter.ts +36 -0
- package/src/kernel/jobs/builtin-job-tasks.ts +17 -0
- package/src/kernel/jobs/drizzle-adapter.ts +65 -0
- package/src/kernel/jobs/reaper.ts +95 -0
- package/src/kernel/jobs/runner.ts +157 -0
- package/src/kernel/jobs/schema.ts +46 -0
- package/src/kernel/jobs/types.ts +42 -0
- package/src/kernel/local-api.ts +188 -0
- package/src/kernel/module/define.ts +36 -0
- package/src/kernel/module/index.ts +3 -0
- package/src/kernel/module/topo-sort.ts +99 -0
- package/src/kernel/plugin/manifest.ts +310 -0
- package/src/kernel/query/executor.ts +184 -0
- package/src/kernel/query/registry.ts +46 -0
- package/src/kernel/result.ts +33 -0
- package/src/kernel/service-registry.ts +76 -0
- package/src/kernel/service-timing.ts +89 -0
- package/src/kernel/state-machine/machine.ts +101 -0
- package/src/modules/analytics/drizzle-adapter.ts +426 -0
- package/src/modules/analytics/hooks.ts +11 -0
- package/src/modules/analytics/models.ts +125 -0
- package/src/modules/analytics/module.ts +25 -0
- package/src/modules/analytics/repository/index.ts +6 -0
- package/src/modules/analytics/service.ts +245 -0
- package/src/modules/analytics/types.ts +180 -0
- package/src/modules/audit/hooks.ts +78 -0
- package/src/modules/audit/index.ts +1 -0
- package/src/modules/audit/module.ts +11 -0
- package/src/modules/audit/schema.ts +33 -0
- package/src/modules/audit/service.ts +151 -0
- package/src/modules/cart/access.ts +27 -0
- package/src/modules/cart/matcher.ts +26 -0
- package/src/modules/cart/module.ts +32 -0
- package/src/modules/cart/repository/index.ts +234 -0
- package/src/modules/cart/schema.ts +42 -0
- package/src/modules/cart/schemas.ts +38 -0
- package/src/modules/cart/service.ts +710 -0
- package/src/modules/catalog/brand-service.ts +101 -0
- package/src/modules/catalog/category-service.ts +103 -0
- package/src/modules/catalog/entity-service.ts +469 -0
- package/src/modules/catalog/module.ts +65 -0
- package/src/modules/catalog/repository/index.ts +777 -0
- package/src/modules/catalog/schema.ts +203 -0
- package/src/modules/catalog/schemas.ts +104 -0
- package/src/modules/catalog/service.ts +392 -0
- package/src/modules/customers/index.ts +1 -0
- package/src/modules/customers/module.ts +27 -0
- package/src/modules/customers/repository/index.ts +327 -0
- package/src/modules/customers/schema.ts +64 -0
- package/src/modules/customers/service.ts +276 -0
- package/src/modules/fulfillment/module.ts +42 -0
- package/src/modules/fulfillment/repository/index.ts +426 -0
- package/src/modules/fulfillment/schema.ts +101 -0
- package/src/modules/fulfillment/service.ts +581 -0
- package/src/modules/fulfillment/types.ts +59 -0
- package/src/modules/inventory/module.ts +37 -0
- package/src/modules/inventory/repository/index.ts +677 -0
- package/src/modules/inventory/schema.ts +107 -0
- package/src/modules/inventory/schemas.ts +38 -0
- package/src/modules/inventory/service.ts +567 -0
- package/src/modules/media/adapter.ts +17 -0
- package/src/modules/media/index.ts +1 -0
- package/src/modules/media/module.ts +25 -0
- package/src/modules/media/repository/index.ts +274 -0
- package/src/modules/media/schema.ts +41 -0
- package/src/modules/media/service.ts +237 -0
- package/src/modules/orders/module.ts +66 -0
- package/src/modules/orders/repository/index.ts +290 -0
- package/src/modules/orders/schema.ts +67 -0
- package/src/modules/orders/sequences.ts +6 -0
- package/src/modules/orders/service.ts +639 -0
- package/src/modules/orders/stale-order-cleanup.ts +76 -0
- package/src/modules/organization/index.ts +1 -0
- package/src/modules/organization/module.ts +11 -0
- package/src/modules/organization/service.ts +191 -0
- package/src/modules/payments/adapter.ts +45 -0
- package/src/modules/payments/module.ts +14 -0
- package/src/modules/payments/repository/index.ts +6 -0
- package/src/modules/payments/service.ts +107 -0
- package/src/modules/pricing/index.ts +1 -0
- package/src/modules/pricing/module.ts +30 -0
- package/src/modules/pricing/repository/index.ts +305 -0
- package/src/modules/pricing/schema.ts +71 -0
- package/src/modules/pricing/schemas.ts +38 -0
- package/src/modules/pricing/service.ts +557 -0
- package/src/modules/promotions/module.ts +32 -0
- package/src/modules/promotions/repository/index.ts +325 -0
- package/src/modules/promotions/schema.ts +62 -0
- package/src/modules/promotions/schemas.ts +38 -0
- package/src/modules/promotions/service.ts +674 -0
- package/src/modules/search/adapter.ts +57 -0
- package/src/modules/search/hooks.ts +12 -0
- package/src/modules/search/module.ts +26 -0
- package/src/modules/search/repository/index.ts +6 -0
- package/src/modules/search/service.ts +341 -0
- package/src/modules/shipping/calculator.ts +188 -0
- package/src/modules/shipping/module.ts +23 -0
- package/src/modules/shipping/repository/index.ts +6 -0
- package/src/modules/shipping/service.ts +51 -0
- package/src/modules/tax/adapter.ts +60 -0
- package/src/modules/tax/module.ts +16 -0
- package/src/modules/tax/repository/index.ts +6 -0
- package/src/modules/tax/service.ts +53 -0
- package/src/modules/webhooks/hook.ts +41 -0
- package/src/modules/webhooks/index.ts +1 -0
- package/src/modules/webhooks/module.ts +22 -0
- package/src/modules/webhooks/repository/index.ts +304 -0
- package/src/modules/webhooks/schema.ts +56 -0
- package/src/modules/webhooks/service.ts +127 -0
- package/src/modules/webhooks/signing.ts +6 -0
- package/src/modules/webhooks/ssrf-guard.ts +71 -0
- package/src/modules/webhooks/tasks.ts +60 -0
- package/src/modules/webhooks/worker.ts +171 -0
- package/src/runtime/commerce.ts +158 -0
- package/src/runtime/kernel-modules.ts +66 -0
- package/src/runtime/kernel-register-hooks.ts +63 -0
- package/src/runtime/kernel-types.ts +109 -0
- package/src/runtime/kernel.ts +159 -0
- package/src/runtime/logger.ts +36 -0
- package/src/runtime/server.ts +470 -0
- package/src/runtime/shutdown.ts +43 -0
- package/src/runtime/url-alias-rewrite.ts +40 -0
- package/src/test-utils/create-pglite-adapter.ts +129 -0
- package/src/test-utils/create-plugin-test-app.ts +151 -0
- package/src/test-utils/create-repository-test-harness.ts +16 -0
- package/src/test-utils/create-test-config.ts +188 -0
- package/src/test-utils/create-test-kernel.ts +7 -0
- package/src/test-utils/create-test-plugin-context.ts +66 -0
- package/src/test-utils/rest-api-test-utils.ts +266 -0
- package/src/test-utils/test-actors.ts +70 -0
- package/src/test-utils/typed-hooks.ts +55 -0
- package/src/testing.ts +21 -0
- package/src/types/commerce-types.ts +34 -0
- package/src/utils/agent-prompt.ts +12 -0
- package/src/utils/id.ts +3 -0
- package/src/utils/logger.ts +18 -0
- package/src/utils/pagination.ts +22 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
// ─── Zod Body Schemas (single source of truth) ─────────────────────────────
|
|
3
|
+
export const SetBasePriceBodySchema = z.object({
|
|
4
|
+
entityId: z.string().openapi({ example: "product-uuid" }),
|
|
5
|
+
variantId: z.string().optional().openapi({ example: "variant-uuid" }),
|
|
6
|
+
currency: z.string().length(3).openapi({ example: "USD" }),
|
|
7
|
+
amount: z.number().openapi({ example: 29.99 }),
|
|
8
|
+
customerGroupId: z.string().optional(),
|
|
9
|
+
minQuantity: z.number().int().optional(),
|
|
10
|
+
maxQuantity: z.number().int().optional(),
|
|
11
|
+
validFrom: z.coerce.date().optional(),
|
|
12
|
+
validUntil: z.coerce.date().optional(),
|
|
13
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
14
|
+
}).openapi("SetBasePriceRequest");
|
|
15
|
+
export const CreateModifierBodySchema = z.object({
|
|
16
|
+
name: z.string().openapi({ example: "Summer Sale" }),
|
|
17
|
+
type: z.enum(["percentage_discount", "fixed_discount", "markup", "override"]).openapi({ example: "percentage_discount" }),
|
|
18
|
+
value: z.number().openapi({ example: 10 }),
|
|
19
|
+
priority: z.number().int().optional(),
|
|
20
|
+
entityId: z.string().optional(),
|
|
21
|
+
variantId: z.string().optional(),
|
|
22
|
+
customerGroupId: z.string().optional(),
|
|
23
|
+
currency: z.string().length(3).optional().openapi({ example: "USD" }),
|
|
24
|
+
minQuantity: z.number().int().optional(),
|
|
25
|
+
maxQuantity: z.number().int().optional(),
|
|
26
|
+
conditions: z.record(z.string(), z.unknown()).optional(),
|
|
27
|
+
validFrom: z.coerce.date().optional(),
|
|
28
|
+
validUntil: z.coerce.date().optional(),
|
|
29
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
30
|
+
}).openapi("CreateModifierRequest");
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Actor } from "../../auth/types.js";
|
|
2
|
+
import type { DatabaseAdapter } from "../../kernel/database/adapter.js";
|
|
3
|
+
import type { TxContext } from "../../kernel/database/tx-context.js";
|
|
4
|
+
import type { HookRegistry } from "../../kernel/hooks/registry.js";
|
|
5
|
+
import { type Result } from "../../kernel/result.js";
|
|
6
|
+
import type { PricingRepository, Price, PriceModifier } from "./repository/index.js";
|
|
7
|
+
import type { CatalogRepository } from "../catalog/repository/index.js";
|
|
8
|
+
export type PriceModifierType = "percentage_discount" | "fixed_discount" | "markup" | "override";
|
|
9
|
+
interface PricingServiceDeps {
|
|
10
|
+
repository: PricingRepository;
|
|
11
|
+
catalogRepository: CatalogRepository;
|
|
12
|
+
hooks: HookRegistry;
|
|
13
|
+
services: Record<string, unknown>;
|
|
14
|
+
database: DatabaseAdapter;
|
|
15
|
+
}
|
|
16
|
+
export interface PriceResolutionContext {
|
|
17
|
+
entityId: string;
|
|
18
|
+
variantId?: string;
|
|
19
|
+
currency: string;
|
|
20
|
+
quantity: number;
|
|
21
|
+
customerId?: string;
|
|
22
|
+
customerGroupIds?: string[];
|
|
23
|
+
timestamp?: Date;
|
|
24
|
+
}
|
|
25
|
+
export interface PriceBreakdownStep {
|
|
26
|
+
label: string;
|
|
27
|
+
amountBefore: number;
|
|
28
|
+
delta: number;
|
|
29
|
+
amountAfter: number;
|
|
30
|
+
metadata?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
export interface ResolvedPrice {
|
|
33
|
+
baseAmount: number;
|
|
34
|
+
finalAmount: number;
|
|
35
|
+
currency: string;
|
|
36
|
+
appliedModifiers: Array<{
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
type: PriceModifierType;
|
|
40
|
+
delta: number;
|
|
41
|
+
value: number;
|
|
42
|
+
priority: number;
|
|
43
|
+
}>;
|
|
44
|
+
breakdown: PriceBreakdownStep[];
|
|
45
|
+
basePriceId: string;
|
|
46
|
+
}
|
|
47
|
+
export type { SetBasePriceInput, CreatePriceModifierInput } from "./schemas.js";
|
|
48
|
+
import type { SetBasePriceInput, CreatePriceModifierInput } from "./schemas.js";
|
|
49
|
+
export declare class PricingService {
|
|
50
|
+
private deps;
|
|
51
|
+
private readonly repo;
|
|
52
|
+
private readonly catalogRepo;
|
|
53
|
+
constructor(deps: PricingServiceDeps);
|
|
54
|
+
setBasePrice(input: SetBasePriceInput, actor?: Actor | null, ctx?: TxContext): Promise<Result<Price>>;
|
|
55
|
+
createModifier(input: CreatePriceModifierInput, actor?: Actor | null, ctx?: TxContext): Promise<Result<PriceModifier>>;
|
|
56
|
+
listPrices(filter?: {
|
|
57
|
+
entityId?: string;
|
|
58
|
+
variantId?: string;
|
|
59
|
+
currency?: string;
|
|
60
|
+
customerGroupId?: string;
|
|
61
|
+
}, actor?: Actor | null, ctx?: TxContext): Promise<Result<{
|
|
62
|
+
prices: Price[];
|
|
63
|
+
modifiers: PriceModifier[];
|
|
64
|
+
}>>;
|
|
65
|
+
resolve(input: PriceResolutionContext, actor?: Actor | null, ctx?: TxContext): Promise<Result<ResolvedPrice>>;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/modules/pricing/service.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { resolveOrgId } from "../../auth/org.js";
|
|
2
|
+
import { CommerceNotFoundError, CommerceValidationError, } from "../../kernel/errors.js";
|
|
3
|
+
import { runAfterHooks } from "../../kernel/hooks/executor.js";
|
|
4
|
+
import { createHookContext } from "../../kernel/hooks/create-context.js";
|
|
5
|
+
import { Err, Ok } from "../../kernel/result.js";
|
|
6
|
+
import { createLogger } from "../../utils/logger.js";
|
|
7
|
+
function hookContext(actor, services, database, tx) {
|
|
8
|
+
return createHookContext({
|
|
9
|
+
actor,
|
|
10
|
+
tx,
|
|
11
|
+
logger: createLogger("pricing"),
|
|
12
|
+
services,
|
|
13
|
+
context: { moduleName: "pricing" },
|
|
14
|
+
database: { db: database.db },
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function matchesQuantity(min, max, quantity) {
|
|
18
|
+
if (min != null && quantity < min)
|
|
19
|
+
return false;
|
|
20
|
+
if (max != null && quantity > max)
|
|
21
|
+
return false;
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
function matchesWindow(validFrom, validUntil, timestamp) {
|
|
25
|
+
if (validFrom && timestamp < validFrom)
|
|
26
|
+
return false;
|
|
27
|
+
if (validUntil && timestamp > validUntil)
|
|
28
|
+
return false;
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
function durationScore(validFrom, validUntil) {
|
|
32
|
+
if (validFrom && validUntil)
|
|
33
|
+
return validUntil.getTime() - validFrom.getTime();
|
|
34
|
+
if (validFrom || validUntil)
|
|
35
|
+
return Number.MAX_SAFE_INTEGER - 1;
|
|
36
|
+
return Number.MAX_SAFE_INTEGER;
|
|
37
|
+
}
|
|
38
|
+
function quantityRangeWidth(min, max) {
|
|
39
|
+
if (min != null && max != null)
|
|
40
|
+
return Math.max(0, max - min);
|
|
41
|
+
if (min != null || max != null)
|
|
42
|
+
return Number.MAX_SAFE_INTEGER - 1;
|
|
43
|
+
return Number.MAX_SAFE_INTEGER;
|
|
44
|
+
}
|
|
45
|
+
function compareBasePriceSpecificity(a, b, context) {
|
|
46
|
+
const aVariant = context.variantId !== undefined && a.variantId === context.variantId
|
|
47
|
+
? 1
|
|
48
|
+
: 0;
|
|
49
|
+
const bVariant = context.variantId !== undefined && b.variantId === context.variantId
|
|
50
|
+
? 1
|
|
51
|
+
: 0;
|
|
52
|
+
if (aVariant !== bVariant)
|
|
53
|
+
return bVariant - aVariant;
|
|
54
|
+
const hasGroupA = a.customerGroupId ? 1 : 0;
|
|
55
|
+
const hasGroupB = b.customerGroupId ? 1 : 0;
|
|
56
|
+
if (hasGroupA !== hasGroupB)
|
|
57
|
+
return hasGroupB - hasGroupA;
|
|
58
|
+
const aRange = quantityRangeWidth(a.minQuantity, a.maxQuantity);
|
|
59
|
+
const bRange = quantityRangeWidth(b.minQuantity, b.maxQuantity);
|
|
60
|
+
if (aRange !== bRange)
|
|
61
|
+
return aRange - bRange;
|
|
62
|
+
const aDuration = durationScore(a.validFrom, a.validUntil);
|
|
63
|
+
const bDuration = durationScore(b.validFrom, b.validUntil);
|
|
64
|
+
if (aDuration !== bDuration)
|
|
65
|
+
return aDuration - bDuration;
|
|
66
|
+
return b.createdAt.getTime() - a.createdAt.getTime();
|
|
67
|
+
}
|
|
68
|
+
function resolveModifierDelta(type, value, amountBefore) {
|
|
69
|
+
switch (type) {
|
|
70
|
+
case "percentage_discount":
|
|
71
|
+
return -Math.round((amountBefore * value) / 100);
|
|
72
|
+
case "fixed_discount":
|
|
73
|
+
return -value;
|
|
74
|
+
case "markup":
|
|
75
|
+
return value;
|
|
76
|
+
case "override":
|
|
77
|
+
return value - amountBefore;
|
|
78
|
+
default:
|
|
79
|
+
return 0;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function toGroupSet(context) {
|
|
83
|
+
return new Set(context.customerGroupIds ?? []);
|
|
84
|
+
}
|
|
85
|
+
function normalizeCurrency(currency) {
|
|
86
|
+
return currency.trim().toUpperCase();
|
|
87
|
+
}
|
|
88
|
+
export class PricingService {
|
|
89
|
+
deps;
|
|
90
|
+
repo;
|
|
91
|
+
catalogRepo;
|
|
92
|
+
constructor(deps) {
|
|
93
|
+
this.deps = deps;
|
|
94
|
+
this.repo = deps.repository;
|
|
95
|
+
this.catalogRepo = deps.catalogRepository;
|
|
96
|
+
}
|
|
97
|
+
async setBasePrice(input, actor, ctx) {
|
|
98
|
+
if (input.amount < 0) {
|
|
99
|
+
return Err(new CommerceValidationError("Base price amount cannot be negative."));
|
|
100
|
+
}
|
|
101
|
+
const entity = await this.catalogRepo.findEntityById(input.entityId, ctx);
|
|
102
|
+
if (!entity) {
|
|
103
|
+
return Err(new CommerceNotFoundError("Entity not found for price assignment."));
|
|
104
|
+
}
|
|
105
|
+
const orgId = resolveOrgId(actor ?? ctx?.actor ?? null);
|
|
106
|
+
const priceData = {
|
|
107
|
+
organizationId: orgId,
|
|
108
|
+
entityId: input.entityId,
|
|
109
|
+
currency: normalizeCurrency(input.currency),
|
|
110
|
+
amount: input.amount,
|
|
111
|
+
metadata: input.metadata ?? {},
|
|
112
|
+
variantId: input.variantId ?? null,
|
|
113
|
+
customerGroupId: input.customerGroupId ?? null,
|
|
114
|
+
minQuantity: input.minQuantity ?? null,
|
|
115
|
+
maxQuantity: input.maxQuantity ?? null,
|
|
116
|
+
validFrom: input.validFrom ?? null,
|
|
117
|
+
validUntil: input.validUntil ?? null,
|
|
118
|
+
};
|
|
119
|
+
const record = await this.repo.createPrice(priceData, ctx);
|
|
120
|
+
const afterHooks = this.deps.hooks.resolve("pricing.afterCreate");
|
|
121
|
+
const hctx = hookContext(actor ?? ctx?.actor ?? null, this.deps.services, this.deps.database, ctx?.tx ?? null);
|
|
122
|
+
await runAfterHooks(afterHooks, null, record, "create", hctx);
|
|
123
|
+
return Ok(record);
|
|
124
|
+
}
|
|
125
|
+
async createModifier(input, actor, ctx) {
|
|
126
|
+
if (!input.name) {
|
|
127
|
+
return Err(new CommerceValidationError("Modifier name is required."));
|
|
128
|
+
}
|
|
129
|
+
// Validate modifier type
|
|
130
|
+
const validTypes = [
|
|
131
|
+
"percentage_discount",
|
|
132
|
+
"fixed_discount",
|
|
133
|
+
"markup",
|
|
134
|
+
"override",
|
|
135
|
+
];
|
|
136
|
+
if (!validTypes.includes(input.type)) {
|
|
137
|
+
return Err(new CommerceValidationError(`Invalid modifier type "${input.type}". Must be one of: ${validTypes.join(", ")}`));
|
|
138
|
+
}
|
|
139
|
+
const orgId = resolveOrgId(actor ?? ctx?.actor ?? null);
|
|
140
|
+
const modifierData = {
|
|
141
|
+
organizationId: orgId,
|
|
142
|
+
name: input.name,
|
|
143
|
+
type: input.type,
|
|
144
|
+
value: input.value,
|
|
145
|
+
priority: input.priority ?? 100,
|
|
146
|
+
conditions: input.conditions ?? {},
|
|
147
|
+
metadata: input.metadata ?? {},
|
|
148
|
+
entityId: input.entityId ?? null,
|
|
149
|
+
variantId: input.variantId ?? null,
|
|
150
|
+
customerGroupId: input.customerGroupId ?? null,
|
|
151
|
+
currency: input.currency ? normalizeCurrency(input.currency) : null,
|
|
152
|
+
minQuantity: input.minQuantity ?? null,
|
|
153
|
+
maxQuantity: input.maxQuantity ?? null,
|
|
154
|
+
validFrom: input.validFrom ?? null,
|
|
155
|
+
validUntil: input.validUntil ?? null,
|
|
156
|
+
};
|
|
157
|
+
const modifier = await this.repo.createModifier(modifierData, ctx);
|
|
158
|
+
const afterHooks = this.deps.hooks.resolve("pricing.afterCreate");
|
|
159
|
+
const hctx = hookContext(actor ?? ctx?.actor ?? null, this.deps.services, this.deps.database, ctx?.tx ?? null);
|
|
160
|
+
await runAfterHooks(afterHooks, null, modifier, "create", hctx);
|
|
161
|
+
return Ok(modifier);
|
|
162
|
+
}
|
|
163
|
+
async listPrices(filter, actor, ctx) {
|
|
164
|
+
const orgId = resolveOrgId(actor ?? ctx?.actor ?? null);
|
|
165
|
+
// Get all prices for the entity if specified, or filter after retrieval
|
|
166
|
+
let prices = [];
|
|
167
|
+
if (filter?.entityId) {
|
|
168
|
+
prices = await this.repo.findPricesByEntityId(orgId, filter.entityId, ctx);
|
|
169
|
+
}
|
|
170
|
+
// Note: For full list without entityId, we'd need a findAll method
|
|
171
|
+
// For now, entityId is typically required for practical use
|
|
172
|
+
// Apply additional filters
|
|
173
|
+
if (filter?.variantId !== undefined) {
|
|
174
|
+
prices = prices.filter((p) => p.variantId === filter.variantId);
|
|
175
|
+
}
|
|
176
|
+
if (filter?.currency !== undefined) {
|
|
177
|
+
const normalizedCurrency = normalizeCurrency(filter.currency);
|
|
178
|
+
prices = prices.filter((p) => p.currency === normalizedCurrency);
|
|
179
|
+
}
|
|
180
|
+
if (filter?.customerGroupId !== undefined) {
|
|
181
|
+
prices = prices.filter((p) => p.customerGroupId === filter.customerGroupId);
|
|
182
|
+
}
|
|
183
|
+
// Get modifiers for the entity
|
|
184
|
+
let modifiers = [];
|
|
185
|
+
if (filter?.entityId) {
|
|
186
|
+
modifiers = await this.repo.findModifiersByEntityId(orgId, filter.entityId, ctx);
|
|
187
|
+
}
|
|
188
|
+
// Apply additional filters
|
|
189
|
+
if (filter?.variantId !== undefined) {
|
|
190
|
+
modifiers = modifiers.filter((m) => m.variantId === filter.variantId);
|
|
191
|
+
}
|
|
192
|
+
if (filter?.currency !== undefined) {
|
|
193
|
+
const normalizedCurrency = normalizeCurrency(filter.currency);
|
|
194
|
+
modifiers = modifiers.filter((m) => m.currency === null || m.currency === normalizedCurrency);
|
|
195
|
+
}
|
|
196
|
+
if (filter?.customerGroupId !== undefined) {
|
|
197
|
+
modifiers = modifiers.filter((m) => m.customerGroupId === null ||
|
|
198
|
+
m.customerGroupId === filter.customerGroupId);
|
|
199
|
+
}
|
|
200
|
+
return Ok({ prices, modifiers });
|
|
201
|
+
}
|
|
202
|
+
async resolve(input, actor, ctx) {
|
|
203
|
+
const entity = await this.catalogRepo.findEntityById(input.entityId, ctx);
|
|
204
|
+
if (!entity) {
|
|
205
|
+
return Err(new CommerceNotFoundError(`Entity ${input.entityId} not found.`));
|
|
206
|
+
}
|
|
207
|
+
if (input.quantity <= 0) {
|
|
208
|
+
return Err(new CommerceValidationError("Quantity must be greater than zero for price resolution."));
|
|
209
|
+
}
|
|
210
|
+
const timestamp = input.timestamp ?? new Date();
|
|
211
|
+
const currency = normalizeCurrency(input.currency);
|
|
212
|
+
const groupSet = toGroupSet(input);
|
|
213
|
+
// Get matching prices from repository
|
|
214
|
+
const orgId = resolveOrgId(actor ?? ctx?.actor ?? null);
|
|
215
|
+
const allPrices = await this.repo.findPricesByEntityId(orgId, input.entityId, ctx);
|
|
216
|
+
const matchingPrices = allPrices.filter((price) => {
|
|
217
|
+
if (input.variantId !== undefined) {
|
|
218
|
+
if (price.variantId !== null && price.variantId !== input.variantId)
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
else if (price.variantId !== null) {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
if (price.currency !== currency)
|
|
225
|
+
return false;
|
|
226
|
+
if (!matchesQuantity(price.minQuantity, price.maxQuantity, input.quantity))
|
|
227
|
+
return false;
|
|
228
|
+
if (!matchesWindow(price.validFrom, price.validUntil, timestamp))
|
|
229
|
+
return false;
|
|
230
|
+
if (price.customerGroupId !== null &&
|
|
231
|
+
!groupSet.has(price.customerGroupId))
|
|
232
|
+
return false;
|
|
233
|
+
return true;
|
|
234
|
+
});
|
|
235
|
+
if (matchingPrices.length === 0) {
|
|
236
|
+
const metadataPrice = typeof entity.metadata?.basePrice === "number"
|
|
237
|
+
? Math.round(entity.metadata.basePrice)
|
|
238
|
+
: undefined;
|
|
239
|
+
if (metadataPrice === undefined) {
|
|
240
|
+
return Err(new CommerceNotFoundError(`No base price configured for ${entity.slug} (${currency}).`));
|
|
241
|
+
}
|
|
242
|
+
const fallback = {
|
|
243
|
+
baseAmount: metadataPrice,
|
|
244
|
+
finalAmount: metadataPrice,
|
|
245
|
+
currency,
|
|
246
|
+
basePriceId: "metadata:basePrice",
|
|
247
|
+
appliedModifiers: [],
|
|
248
|
+
breakdown: [
|
|
249
|
+
{
|
|
250
|
+
label: "Base price (entity metadata)",
|
|
251
|
+
amountBefore: metadataPrice,
|
|
252
|
+
delta: 0,
|
|
253
|
+
amountAfter: metadataPrice,
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
};
|
|
257
|
+
return Ok(fallback);
|
|
258
|
+
}
|
|
259
|
+
const selectedBase = [...matchingPrices].sort((a, b) => compareBasePriceSpecificity(a, b, input))[0];
|
|
260
|
+
if (!selectedBase) {
|
|
261
|
+
return Err(new CommerceNotFoundError("No matching base price could be selected."));
|
|
262
|
+
}
|
|
263
|
+
let runningAmount = selectedBase.amount;
|
|
264
|
+
const breakdown = [
|
|
265
|
+
{
|
|
266
|
+
label: "Base price",
|
|
267
|
+
amountBefore: selectedBase.amount,
|
|
268
|
+
delta: 0,
|
|
269
|
+
amountAfter: selectedBase.amount,
|
|
270
|
+
metadata: {
|
|
271
|
+
priceId: selectedBase.id,
|
|
272
|
+
customerGroupId: selectedBase.customerGroupId,
|
|
273
|
+
minQuantity: selectedBase.minQuantity,
|
|
274
|
+
maxQuantity: selectedBase.maxQuantity,
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
];
|
|
278
|
+
const appliedModifiers = [];
|
|
279
|
+
// Get matching modifiers (includes both entity-specific and global)
|
|
280
|
+
const firstGroupId = groupSet.size > 0 ? [...groupSet][0] : undefined;
|
|
281
|
+
const activeModifiers = await this.repo.findActiveModifiers(orgId, input.entityId, input.variantId, firstGroupId, currency, input.quantity, ctx);
|
|
282
|
+
// Additional filtering for multiple customer groups and conditions
|
|
283
|
+
const modifiers = activeModifiers
|
|
284
|
+
.filter((modifier) => {
|
|
285
|
+
// Re-check customer group for multi-group support
|
|
286
|
+
if (modifier.customerGroupId !== null &&
|
|
287
|
+
!groupSet.has(modifier.customerGroupId))
|
|
288
|
+
return false;
|
|
289
|
+
const conditions = modifier.conditions;
|
|
290
|
+
const minSubtotal = conditions?.minSubtotal;
|
|
291
|
+
if (typeof minSubtotal === "number" && runningAmount < minSubtotal)
|
|
292
|
+
return false;
|
|
293
|
+
return true;
|
|
294
|
+
})
|
|
295
|
+
.sort((a, b) => a.priority - b.priority);
|
|
296
|
+
for (const modifier of modifiers) {
|
|
297
|
+
const amountBefore = runningAmount;
|
|
298
|
+
const rawDelta = resolveModifierDelta(modifier.type, modifier.value, amountBefore);
|
|
299
|
+
const delta = Math.max(-amountBefore, rawDelta);
|
|
300
|
+
runningAmount = Math.max(0, amountBefore + delta);
|
|
301
|
+
appliedModifiers.push({
|
|
302
|
+
id: modifier.id,
|
|
303
|
+
name: modifier.name,
|
|
304
|
+
type: modifier.type,
|
|
305
|
+
delta,
|
|
306
|
+
value: modifier.value,
|
|
307
|
+
priority: modifier.priority,
|
|
308
|
+
});
|
|
309
|
+
breakdown.push({
|
|
310
|
+
label: `Modifier: ${modifier.name}`,
|
|
311
|
+
amountBefore,
|
|
312
|
+
delta,
|
|
313
|
+
amountAfter: runningAmount,
|
|
314
|
+
metadata: {
|
|
315
|
+
type: modifier.type,
|
|
316
|
+
priority: modifier.priority,
|
|
317
|
+
},
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
return Ok({
|
|
321
|
+
baseAmount: selectedBase.amount,
|
|
322
|
+
finalAmount: runningAmount,
|
|
323
|
+
currency,
|
|
324
|
+
basePriceId: selectedBase.id,
|
|
325
|
+
appliedModifiers,
|
|
326
|
+
breakdown,
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CatalogServiceImpl } from "../catalog/service.js";
|
|
2
|
+
import type { OrderService } from "../orders/service.js";
|
|
3
|
+
import { promotionUsages, promotions } from "./schema.js";
|
|
4
|
+
import { PromotionService } from "./service.js";
|
|
5
|
+
type PromotionsModuleDeps = {
|
|
6
|
+
catalog: CatalogServiceImpl;
|
|
7
|
+
orders: OrderService;
|
|
8
|
+
};
|
|
9
|
+
export declare const promotionsModule: import("../../kernel/module/define.js").AppModule<{
|
|
10
|
+
promotions: typeof promotions;
|
|
11
|
+
promotionUsages: typeof promotionUsages;
|
|
12
|
+
}, PromotionService, PromotionsModuleDeps>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/modules/promotions/module.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,KAAK,oBAAoB,GAAG;IAC1B,OAAO,EAAE,kBAAkB,CAAC;IAC5B,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,gBAAgB;gBACb,OAAO,UAAU;qBAAmB,OAAO,eAAe;0CAgBxE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineModule } from "../../kernel/module/index.js";
|
|
2
|
+
import { OrdersRepository } from "../orders/repository/index.js";
|
|
3
|
+
import { PromotionsRepository } from "./repository/index.js";
|
|
4
|
+
import { promotionUsages, promotions } from "./schema.js";
|
|
5
|
+
import { PromotionService } from "./service.js";
|
|
6
|
+
export const promotionsModule = defineModule({
|
|
7
|
+
id: "promotions",
|
|
8
|
+
dependencies: ["catalog", "orders"],
|
|
9
|
+
schema: () => ({ promotions, promotionUsages }),
|
|
10
|
+
service: (deps) => new PromotionService({
|
|
11
|
+
repository: new PromotionsRepository(deps.db.db),
|
|
12
|
+
catalogRepository: deps.services.catalog.repository,
|
|
13
|
+
ordersRepository: new OrdersRepository(deps.db.db),
|
|
14
|
+
hooks: deps.hooks,
|
|
15
|
+
services: deps.services,
|
|
16
|
+
database: deps.db,
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { TxContext } from "../../../kernel/database/tx-context.js";
|
|
2
|
+
import type { DrizzleDatabase } from "../../../kernel/database/drizzle-db.js";
|
|
3
|
+
import { promotions, promotionUsages } from "../schema.js";
|
|
4
|
+
export type Promotion = typeof promotions.$inferSelect;
|
|
5
|
+
export type PromotionInsert = typeof promotions.$inferInsert;
|
|
6
|
+
export type PromotionUsage = typeof promotionUsages.$inferSelect;
|
|
7
|
+
export type PromotionUsageInsert = typeof promotionUsages.$inferInsert;
|
|
8
|
+
/**
|
|
9
|
+
* PromotionsRepository provides type-safe database operations for promotions.
|
|
10
|
+
*
|
|
11
|
+
* This repository manages promotions and their usage tracking.
|
|
12
|
+
* All methods support an optional TxContext parameter for transaction participation.
|
|
13
|
+
*/
|
|
14
|
+
export declare class PromotionsRepository {
|
|
15
|
+
private readonly db;
|
|
16
|
+
constructor(db: DrizzleDatabase);
|
|
17
|
+
private getDb;
|
|
18
|
+
findById(orgId: string, id: string, ctx?: TxContext): Promise<Promotion | undefined>;
|
|
19
|
+
findByCode(orgId: string, code: string, ctx?: TxContext): Promise<Promotion | undefined>;
|
|
20
|
+
findAll(orgId: string, ctx?: TxContext): Promise<Promotion[]>;
|
|
21
|
+
findActive(orgId: string, ctx?: TxContext): Promise<Promotion[]>;
|
|
22
|
+
findAutomatic(orgId: string, ctx?: TxContext): Promise<Promotion[]>;
|
|
23
|
+
create(data: PromotionInsert, ctx?: TxContext): Promise<Promotion>;
|
|
24
|
+
update(id: string, data: Partial<Omit<PromotionInsert, "id">>, ctx?: TxContext): Promise<Promotion | undefined>;
|
|
25
|
+
delete(id: string, ctx?: TxContext): Promise<boolean>;
|
|
26
|
+
activate(id: string, ctx?: TxContext): Promise<Promotion | undefined>;
|
|
27
|
+
deactivate(id: string, ctx?: TxContext): Promise<Promotion | undefined>;
|
|
28
|
+
findUsageById(id: string, ctx?: TxContext): Promise<PromotionUsage | undefined>;
|
|
29
|
+
findUsagesByPromotionId(promotionId: string, ctx?: TxContext): Promise<PromotionUsage[]>;
|
|
30
|
+
findUsagesByCustomerId(customerId: string, ctx?: TxContext): Promise<PromotionUsage[]>;
|
|
31
|
+
createUsage(data: PromotionUsageInsert, ctx?: TxContext): Promise<PromotionUsage>;
|
|
32
|
+
countUsages(promotionId: string, ctx?: TxContext): Promise<number>;
|
|
33
|
+
countUsagesByCustomer(promotionId: string, customerId: string, ctx?: TxContext): Promise<number>;
|
|
34
|
+
isUsageLimitReached(orgId: string, promotionId: string, ctx?: TxContext): Promise<boolean>;
|
|
35
|
+
isCustomerUsageLimitReached(orgId: string, promotionId: string, customerId: string, ctx?: TxContext): Promise<boolean>;
|
|
36
|
+
isPromotionValid(orgId: string, promotionId: string, customerId?: string, ctx?: TxContext): Promise<{
|
|
37
|
+
valid: boolean;
|
|
38
|
+
reason?: string;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/promotions/repository/index.ts"],"names":[],"mappings":"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"}
|