@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,127 @@
|
|
|
1
|
+
import { resolveOrgId } from "../../auth/org.js";
|
|
2
|
+
import type { Actor } from "../../auth/types.js";
|
|
3
|
+
import { CommerceNotFoundError, CommerceValidationError } from "../../kernel/errors.js";
|
|
4
|
+
import { Err, Ok, type Result } from "../../kernel/result.js";
|
|
5
|
+
import type { TxContext } from "../../kernel/database/tx-context.js";
|
|
6
|
+
import type { WebhooksRepository, WebhookEndpoint } from "./repository/index.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Checks whether a URL points to a private/internal IP address.
|
|
10
|
+
* Blocks: loopback (127.x), link-local (169.254.x), private (10.x, 172.16-31.x, 192.168.x),
|
|
11
|
+
* cloud metadata (169.254.169.254, metadata.google.internal), and localhost.
|
|
12
|
+
*/
|
|
13
|
+
function isPrivateUrl(urlStr: string): boolean {
|
|
14
|
+
try {
|
|
15
|
+
const parsed = new URL(urlStr);
|
|
16
|
+
// Strip IPv6 brackets: URL.hostname returns "[::1]" not "::1"
|
|
17
|
+
const hostname = parsed.hostname.toLowerCase().replace(/^\[|\]$/g, "");
|
|
18
|
+
|
|
19
|
+
// Loopback (IPv4 + IPv6)
|
|
20
|
+
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1") return true;
|
|
21
|
+
if (hostname.endsWith(".localhost")) return true;
|
|
22
|
+
|
|
23
|
+
// IPv6 loopback and link-local patterns
|
|
24
|
+
if (hostname.startsWith("::ffff:")) return true; // IPv6-mapped IPv4 (e.g., ::ffff:127.0.0.1)
|
|
25
|
+
if (hostname.startsWith("fe80:")) return true; // IPv6 link-local
|
|
26
|
+
if (hostname === "::") return true; // Unspecified address
|
|
27
|
+
|
|
28
|
+
// Cloud metadata endpoints
|
|
29
|
+
if (hostname === "169.254.169.254") return true;
|
|
30
|
+
if (hostname === "metadata.google.internal") return true;
|
|
31
|
+
|
|
32
|
+
// Private IP ranges (RFC 1918 + link-local)
|
|
33
|
+
const parts = hostname.split(".").map(Number);
|
|
34
|
+
if (parts.length === 4 && parts.every((n) => !isNaN(n))) {
|
|
35
|
+
const [a, b] = parts;
|
|
36
|
+
if (a === 10) return true;
|
|
37
|
+
if (a === 172 && b !== undefined && b >= 16 && b <= 31) return true;
|
|
38
|
+
if (a === 192 && b === 168) return true;
|
|
39
|
+
if (a === 169 && b === 254) return true;
|
|
40
|
+
if (a === 127) return true; // Full 127.0.0.0/8 range
|
|
41
|
+
if (a === 0) return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return false;
|
|
45
|
+
} catch {
|
|
46
|
+
return true; // Invalid URLs are blocked
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface WebhookServiceDeps {
|
|
51
|
+
repository: WebhooksRepository;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export class WebhookService {
|
|
55
|
+
private readonly repo: WebhooksRepository;
|
|
56
|
+
|
|
57
|
+
constructor(private deps: WebhookServiceDeps) {
|
|
58
|
+
this.repo = deps.repository;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async createEndpoint(
|
|
62
|
+
input: {
|
|
63
|
+
url: string;
|
|
64
|
+
secret: string;
|
|
65
|
+
events: string[];
|
|
66
|
+
metadata?: Record<string, unknown>;
|
|
67
|
+
},
|
|
68
|
+
actor?: Actor | null,
|
|
69
|
+
ctx?: TxContext,
|
|
70
|
+
): Promise<Result<WebhookEndpoint>> {
|
|
71
|
+
if (isPrivateUrl(input.url)) {
|
|
72
|
+
return Err(
|
|
73
|
+
new CommerceValidationError(
|
|
74
|
+
"Webhook URL must not point to a private or internal address.",
|
|
75
|
+
),
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const orgId = resolveOrgId(actor ?? ctx?.actor ?? null);
|
|
80
|
+
|
|
81
|
+
const endpoint = await this.repo.createEndpoint(
|
|
82
|
+
{
|
|
83
|
+
organizationId: orgId,
|
|
84
|
+
url: input.url,
|
|
85
|
+
secret: input.secret,
|
|
86
|
+
events: input.events,
|
|
87
|
+
isActive: true,
|
|
88
|
+
metadata: input.metadata ?? {},
|
|
89
|
+
},
|
|
90
|
+
ctx,
|
|
91
|
+
);
|
|
92
|
+
return Ok(endpoint);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async listEndpoints(
|
|
96
|
+
actor?: Actor | null,
|
|
97
|
+
ctx?: TxContext,
|
|
98
|
+
): Promise<Result<WebhookEndpoint[]>> {
|
|
99
|
+
const orgId = resolveOrgId(actor ?? ctx?.actor ?? null);
|
|
100
|
+
const endpoints = await this.repo.findAllEndpoints(orgId, ctx);
|
|
101
|
+
return Ok(endpoints);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async deleteEndpoint(
|
|
105
|
+
id: string,
|
|
106
|
+
actor?: Actor | null,
|
|
107
|
+
ctx?: TxContext,
|
|
108
|
+
): Promise<Result<void>> {
|
|
109
|
+
const orgId = resolveOrgId(actor ?? ctx?.actor ?? null);
|
|
110
|
+
const existing = await this.repo.findEndpointById(id, orgId, ctx);
|
|
111
|
+
if (!existing) {
|
|
112
|
+
return Err(new CommerceNotFoundError("Webhook endpoint not found."));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
await this.repo.deleteEndpoint(id, ctx);
|
|
116
|
+
return Ok(undefined);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async getEndpointsForEvent(
|
|
120
|
+
eventName: string,
|
|
121
|
+
orgId: string,
|
|
122
|
+
ctx?: TxContext,
|
|
123
|
+
): Promise<Result<WebhookEndpoint[]>> {
|
|
124
|
+
const endpoints = await this.repo.findEndpointsForEvent(eventName, orgId, ctx);
|
|
125
|
+
return Ok(endpoints);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createHmac } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
export function signWebhookPayload(secret: string, payload: unknown): string {
|
|
4
|
+
const body = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
5
|
+
return createHmac("sha256", secret).update(body).digest("hex");
|
|
6
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared SSRF prevention utilities.
|
|
3
|
+
*
|
|
4
|
+
* Used by both webhook delivery (DNS rebinding check) and connector URL
|
|
5
|
+
* validation (store URL check) to reject private/internal IP addresses.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Returns true if the given IP address falls within a private, loopback,
|
|
10
|
+
* link-local, or otherwise non-routable range.
|
|
11
|
+
*/
|
|
12
|
+
export function isPrivateIp(ip: string): boolean {
|
|
13
|
+
// IPv6 loopback / link-local / mapped
|
|
14
|
+
if (ip === "::1" || ip === "::") return true;
|
|
15
|
+
if (ip.startsWith("fe80:")) return true;
|
|
16
|
+
|
|
17
|
+
// IPv6-mapped IPv4 (e.g. ::ffff:127.0.0.1) — extract the IPv4 portion
|
|
18
|
+
const mappedMatch = ip.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/i);
|
|
19
|
+
if (mappedMatch) {
|
|
20
|
+
return isPrivateIpv4(mappedMatch[1]!);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return isPrivateIpv4(ip);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function isPrivateIpv4(ip: string): boolean {
|
|
27
|
+
const parts = ip.split(".").map(Number);
|
|
28
|
+
if (parts.length !== 4 || parts.some((n) => isNaN(n))) return false;
|
|
29
|
+
|
|
30
|
+
const [a, b] = parts;
|
|
31
|
+
if (a === undefined || b === undefined) return false;
|
|
32
|
+
|
|
33
|
+
if (a === 127) return true; // loopback 127.0.0.0/8
|
|
34
|
+
if (a === 10) return true; // RFC 1918 class A
|
|
35
|
+
if (a === 172 && b >= 16 && b <= 31) return true; // RFC 1918 class B
|
|
36
|
+
if (a === 192 && b === 168) return true; // RFC 1918 class C
|
|
37
|
+
if (a === 169 && b === 254) return true; // link-local / AWS IMDS
|
|
38
|
+
if (a === 0) return true; // unspecified
|
|
39
|
+
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Checks whether a URL string points to a private/internal IP address or
|
|
45
|
+
* hostname. This performs a string-level check only (no DNS resolution).
|
|
46
|
+
*
|
|
47
|
+
* For DNS rebinding protection, use `isPrivateIp` after resolving the hostname.
|
|
48
|
+
*/
|
|
49
|
+
export function isPrivateUrl(urlStr: string): boolean {
|
|
50
|
+
try {
|
|
51
|
+
const parsed = new URL(urlStr);
|
|
52
|
+
const hostname = parsed.hostname.toLowerCase().replace(/^\[|\]$/g, "");
|
|
53
|
+
|
|
54
|
+
// Direct hostname matches
|
|
55
|
+
if (hostname === "localhost" || hostname.endsWith(".localhost")) return true;
|
|
56
|
+
if (hostname === "::1" || hostname === "::") return true;
|
|
57
|
+
if (hostname.startsWith("::ffff:")) return true;
|
|
58
|
+
if (hostname.startsWith("fe80:")) return true;
|
|
59
|
+
if (hostname.endsWith(".local")) return true;
|
|
60
|
+
if (hostname.endsWith(".internal")) return true;
|
|
61
|
+
|
|
62
|
+
// Cloud metadata endpoints
|
|
63
|
+
if (hostname === "169.254.169.254") return true;
|
|
64
|
+
if (hostname === "metadata.google.internal") return true;
|
|
65
|
+
|
|
66
|
+
// Check if hostname is a raw IP in private ranges
|
|
67
|
+
return isPrivateIpv4(hostname);
|
|
68
|
+
} catch {
|
|
69
|
+
return true; // Invalid URLs are blocked
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { TaskDefinition } from "../../kernel/jobs/types.js";
|
|
2
|
+
import { WebhookDeliveryWorker } from "./worker.js";
|
|
3
|
+
import type { WebhooksRepository } from "./repository/index.js";
|
|
4
|
+
|
|
5
|
+
const WEBHOOK_DELIVERY_RETRY_BACKOFF = {
|
|
6
|
+
type: "exponential" as const,
|
|
7
|
+
delay: 2000,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Background task for async webhook delivery.
|
|
12
|
+
*
|
|
13
|
+
* Instead of blocking the HTTP response with inline webhook HTTP calls,
|
|
14
|
+
* the deliverWebhooks hook enqueues this task. The job runner picks it up
|
|
15
|
+
* and delivers asynchronously with retries.
|
|
16
|
+
*/
|
|
17
|
+
export const webhookDeliveryTask: TaskDefinition<{
|
|
18
|
+
endpointId: string;
|
|
19
|
+
endpointUrl: string;
|
|
20
|
+
endpointSecret: string;
|
|
21
|
+
eventName: string;
|
|
22
|
+
payload: unknown;
|
|
23
|
+
}> = {
|
|
24
|
+
slug: "webhooks/deliver",
|
|
25
|
+
|
|
26
|
+
async handler({ input, ctx, job }) {
|
|
27
|
+
const webhooksService = ctx.services.webhooks as {
|
|
28
|
+
repository?: WebhooksRepository;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// Build a minimal worker — the repository is needed for delivery tracking
|
|
32
|
+
const repository = webhooksService?.repository;
|
|
33
|
+
if (!repository) {
|
|
34
|
+
ctx.logger.warn("Webhook delivery skipped: no webhooks repository available");
|
|
35
|
+
return { output: {} };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const worker = new WebhookDeliveryWorker({ repository });
|
|
39
|
+
|
|
40
|
+
await worker.deliver({
|
|
41
|
+
endpoint: {
|
|
42
|
+
id: input.endpointId,
|
|
43
|
+
url: input.endpointUrl,
|
|
44
|
+
secret: input.endpointSecret,
|
|
45
|
+
},
|
|
46
|
+
eventName: input.eventName,
|
|
47
|
+
payload: input.payload,
|
|
48
|
+
jobAttempt: job?.attemptNumber ?? 1,
|
|
49
|
+
jobMaxAttempts: job?.maxAttempts ?? 1,
|
|
50
|
+
retryBackoff: WEBHOOK_DELIVERY_RETRY_BACKOFF,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return { output: {} };
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
retries: {
|
|
57
|
+
attempts: 5,
|
|
58
|
+
backoff: WEBHOOK_DELIVERY_RETRY_BACKOFF,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { signWebhookPayload } from "./signing.js";
|
|
2
|
+
import { isPrivateIp } from "./ssrf-guard.js";
|
|
3
|
+
import type { WebhooksRepository } from "./repository/index.js";
|
|
4
|
+
import type { TaskRetryConfig } from "../../kernel/jobs/types.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* SSRF prevention: reject webhook URLs targeting private/internal hosts.
|
|
8
|
+
* Blocks RFC 1918, loopback, link-local, and common internal domains.
|
|
9
|
+
*/
|
|
10
|
+
const PRIVATE_HOST_PATTERNS = [
|
|
11
|
+
/^127\./, // loopback
|
|
12
|
+
/^10\./, // RFC 1918 class A
|
|
13
|
+
/^172\.(1[6-9]|2[0-9]|3[01])\./, // RFC 1918 class B
|
|
14
|
+
/^192\.168\./, // RFC 1918 class C
|
|
15
|
+
/^169\.254\./, // link-local / AWS IMDS
|
|
16
|
+
/^0\.0\.0\.0/, // unspecified
|
|
17
|
+
/^localhost$/i,
|
|
18
|
+
/\.local$/i,
|
|
19
|
+
/\.internal$/i,
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
function validateWebhookUrl(url: string): void {
|
|
23
|
+
const parsed = new URL(url);
|
|
24
|
+
|
|
25
|
+
if (process.env.NODE_ENV === "production" && parsed.protocol !== "https:") {
|
|
26
|
+
throw new Error("Webhook URLs must use HTTPS in production.");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const hostname = parsed.hostname;
|
|
30
|
+
for (const pattern of PRIVATE_HOST_PATTERNS) {
|
|
31
|
+
if (pattern.test(hostname)) {
|
|
32
|
+
throw new Error(`Webhook URLs cannot target private hosts: ${hostname}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Resolve the webhook URL hostname via DNS and verify the resolved IP is not
|
|
39
|
+
* private. This closes the DNS rebinding gap where a hostname initially
|
|
40
|
+
* resolves to a public IP but later rebinds to an internal address.
|
|
41
|
+
*/
|
|
42
|
+
async function validateResolvedIp(url: string): Promise<void> {
|
|
43
|
+
const { lookup } = await import("node:dns/promises");
|
|
44
|
+
const parsed = new URL(url);
|
|
45
|
+
const hostname = parsed.hostname.replace(/^\[|\]$/g, "");
|
|
46
|
+
|
|
47
|
+
// Skip DNS resolution for raw IP addresses — they are already checked
|
|
48
|
+
// by validateWebhookUrl via PRIVATE_HOST_PATTERNS.
|
|
49
|
+
const isIpLiteral = /^[\d.]+$/.test(hostname) || hostname.includes(":");
|
|
50
|
+
if (isIpLiteral) return;
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
const { address } = await lookup(hostname);
|
|
54
|
+
if (isPrivateIp(address)) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`Webhook URL hostname "${hostname}" resolved to private IP ${address}`,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
} catch (err) {
|
|
60
|
+
if (err instanceof Error && err.message.includes("resolved to private")) {
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
63
|
+
throw new Error(`Failed to resolve webhook URL hostname "${hostname}": ${err}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function deliveryBackoffDelayMs(
|
|
68
|
+
jobAttempt: number,
|
|
69
|
+
backoff: TaskRetryConfig["backoff"] | undefined,
|
|
70
|
+
): number | undefined {
|
|
71
|
+
if (!backoff || jobAttempt >= Number.MAX_SAFE_INTEGER) return undefined;
|
|
72
|
+
if (backoff.type === "exponential") {
|
|
73
|
+
return backoff.delay * 2 ** (jobAttempt - 1);
|
|
74
|
+
}
|
|
75
|
+
return backoff.delay;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
class HttpResponseWebhookError extends Error {
|
|
79
|
+
readonly status: number;
|
|
80
|
+
|
|
81
|
+
constructor(status: number) {
|
|
82
|
+
super(`Webhook delivery failed: HTTP ${status}`);
|
|
83
|
+
this.name = "HttpResponseWebhookError";
|
|
84
|
+
this.status = status;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface WorkerDeps {
|
|
89
|
+
repository: WebhooksRepository;
|
|
90
|
+
fetchImpl?: typeof fetch;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export class WebhookDeliveryWorker {
|
|
94
|
+
private fetchImpl: typeof fetch;
|
|
95
|
+
|
|
96
|
+
constructor(private deps: WorkerDeps) {
|
|
97
|
+
this.fetchImpl = deps.fetchImpl ?? fetch;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async deliver(args: {
|
|
101
|
+
endpoint: { id: string; url: string; secret: string };
|
|
102
|
+
eventName: string;
|
|
103
|
+
payload: unknown;
|
|
104
|
+
/** Job runner attempt index (1-based). Defaults to 1 for non-job callers (e.g. inline enqueue). */
|
|
105
|
+
jobAttempt?: number;
|
|
106
|
+
/** Max attempts for this job; defaults to 1 when unknown so `nextRetryAt` is not set for standalone runs. */
|
|
107
|
+
jobMaxAttempts?: number;
|
|
108
|
+
/** Matches task retry backoff so delivery rows align with `commerce_jobs.waitUntil`. */
|
|
109
|
+
retryBackoff?: TaskRetryConfig["backoff"];
|
|
110
|
+
}): Promise<void> {
|
|
111
|
+
const jobAttempt = args.jobAttempt ?? 1;
|
|
112
|
+
const jobMaxAttempts = args.jobMaxAttempts ?? 1;
|
|
113
|
+
|
|
114
|
+
validateWebhookUrl(args.endpoint.url);
|
|
115
|
+
await validateResolvedIp(args.endpoint.url);
|
|
116
|
+
|
|
117
|
+
const signature = signWebhookPayload(args.endpoint.secret, args.payload);
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
const response = await this.fetchImpl(args.endpoint.url, {
|
|
121
|
+
method: "POST",
|
|
122
|
+
headers: {
|
|
123
|
+
"content-type": "application/json",
|
|
124
|
+
"x-commerce-signature": signature,
|
|
125
|
+
"x-commerce-event": args.eventName,
|
|
126
|
+
},
|
|
127
|
+
body: JSON.stringify(args.payload),
|
|
128
|
+
signal: AbortSignal.timeout(10_000),
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const delayMs = deliveryBackoffDelayMs(jobAttempt, args.retryBackoff);
|
|
132
|
+
const willRetryJob = jobAttempt < jobMaxAttempts;
|
|
133
|
+
|
|
134
|
+
await this.deps.repository.createDelivery({
|
|
135
|
+
endpointId: args.endpoint.id,
|
|
136
|
+
eventName: args.eventName,
|
|
137
|
+
payload: args.payload,
|
|
138
|
+
statusCode: response.status,
|
|
139
|
+
attemptCount: jobAttempt,
|
|
140
|
+
...(response.ok ? { deliveredAt: new Date() } : { failedAt: new Date() }),
|
|
141
|
+
...(!response.ok && willRetryJob && delayMs !== undefined
|
|
142
|
+
? { nextRetryAt: new Date(Date.now() + delayMs) }
|
|
143
|
+
: {}),
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
if (response.ok) return;
|
|
147
|
+
|
|
148
|
+
throw new HttpResponseWebhookError(response.status);
|
|
149
|
+
} catch (err) {
|
|
150
|
+
if (err instanceof HttpResponseWebhookError) {
|
|
151
|
+
throw err;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const delayMs = deliveryBackoffDelayMs(jobAttempt, args.retryBackoff);
|
|
155
|
+
const willRetryJob = jobAttempt < jobMaxAttempts;
|
|
156
|
+
|
|
157
|
+
await this.deps.repository.createDelivery({
|
|
158
|
+
endpointId: args.endpoint.id,
|
|
159
|
+
eventName: args.eventName,
|
|
160
|
+
payload: args.payload,
|
|
161
|
+
attemptCount: jobAttempt,
|
|
162
|
+
failedAt: new Date(),
|
|
163
|
+
...(willRetryJob && delayMs !== undefined
|
|
164
|
+
? { nextRetryAt: new Date(Date.now() + delayMs) }
|
|
165
|
+
: {}),
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
throw err;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { Actor } from "../auth/types.js";
|
|
2
|
+
import type { CommerceConfig } from "../config/types.js";
|
|
3
|
+
import type { Kernel } from "./kernel.js";
|
|
4
|
+
import { createKernel } from "./kernel.js";
|
|
5
|
+
import { ensureDefaultOrg, setBootDefaultOrgId } from "../auth/org.js";
|
|
6
|
+
import { setBootStrictOrgResolution } from "../auth/strict-org-resolution.js";
|
|
7
|
+
import { createAuth, type AuthInstance } from "../auth/setup.js";
|
|
8
|
+
import { createLogger, type Logger } from "./logger.js";
|
|
9
|
+
import { createLocalAPI, type CommerceLocalAPI, type LocalAPIOptions } from "../kernel/local-api.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The commerce instance returned by `createCommerce()`.
|
|
13
|
+
*
|
|
14
|
+
* This is the headless, framework-agnostic entry point.
|
|
15
|
+
* No HTTP server, no Hono — just typed services and a local API.
|
|
16
|
+
*
|
|
17
|
+
* ## Usage with Next.js App Router:
|
|
18
|
+
*
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // lib/commerce.ts
|
|
21
|
+
* import { createCommerce } from "@porulle/core";
|
|
22
|
+
* import config from "../commerce.config.js";
|
|
23
|
+
*
|
|
24
|
+
* export const commerce = await createCommerce(config);
|
|
25
|
+
*
|
|
26
|
+
* // app/products/page.tsx (Server Component)
|
|
27
|
+
* import { commerce } from "@/lib/commerce";
|
|
28
|
+
*
|
|
29
|
+
* export default async function ProductsPage() {
|
|
30
|
+
* const products = await commerce.api.catalog.list({ limit: 20 });
|
|
31
|
+
* if (!products.ok) return <div>Error</div>;
|
|
32
|
+
* return <ProductGrid items={products.value.items} />;
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* ## Usage with TanStack Start:
|
|
37
|
+
*
|
|
38
|
+
* ```typescript
|
|
39
|
+
* // app/routes/products.tsx
|
|
40
|
+
* import { createServerFn } from "@tanstack/start";
|
|
41
|
+
* import { commerce } from "../lib/commerce.js";
|
|
42
|
+
*
|
|
43
|
+
* const getProducts = createServerFn("GET", async () => {
|
|
44
|
+
* return commerce.api.catalog.list({ limit: 20 });
|
|
45
|
+
* });
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* ## Usage with SvelteKit:
|
|
49
|
+
*
|
|
50
|
+
* ```typescript
|
|
51
|
+
* // src/lib/server/commerce.ts
|
|
52
|
+
* import { createCommerce } from "@porulle/core";
|
|
53
|
+
* import config from "./commerce.config.js";
|
|
54
|
+
* export const commerce = await createCommerce(config);
|
|
55
|
+
*
|
|
56
|
+
* // src/routes/products/+page.server.ts
|
|
57
|
+
* import { commerce } from "$lib/server/commerce";
|
|
58
|
+
* export async function load() {
|
|
59
|
+
* const products = await commerce.api.catalog.list({ limit: 20 });
|
|
60
|
+
* return { products: products.ok ? products.value : { items: [] } };
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export interface CommerceInstance {
|
|
65
|
+
/** Proxy-based local API — auto-injects actor/tx to every service call */
|
|
66
|
+
api: CommerceLocalAPI;
|
|
67
|
+
|
|
68
|
+
/** Raw kernel for advanced usage (hooks, database, config) */
|
|
69
|
+
kernel: Kernel;
|
|
70
|
+
|
|
71
|
+
/** Drizzle database instance for direct queries */
|
|
72
|
+
db: unknown;
|
|
73
|
+
|
|
74
|
+
/** Auth instance (Better Auth) for session management */
|
|
75
|
+
auth: AuthInstance;
|
|
76
|
+
|
|
77
|
+
/** Logger */
|
|
78
|
+
logger: Logger;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Create a scoped API for a specific user/actor.
|
|
82
|
+
* Use this in authenticated routes to scope data access.
|
|
83
|
+
*
|
|
84
|
+
* ```typescript
|
|
85
|
+
* // In a Next.js server action:
|
|
86
|
+
* const userApi = commerce.withActor({
|
|
87
|
+
* type: "user", userId: session.userId, ...
|
|
88
|
+
* });
|
|
89
|
+
* const orders = await userApi.orders.list({ limit: 10 });
|
|
90
|
+
* // Only returns orders for this user's org
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
withActor(actor: Actor): CommerceLocalAPI;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Create a scoped API within a database transaction.
|
|
97
|
+
*
|
|
98
|
+
* ```typescript
|
|
99
|
+
* await commerce.kernel.database.transaction(async (tx) => {
|
|
100
|
+
* const txApi = commerce.withTransaction(tx, actor);
|
|
101
|
+
* await txApi.inventory.adjust({ entityId, adjustment: -1, reason: "sold" });
|
|
102
|
+
* await txApi.orders.create({ ... });
|
|
103
|
+
* });
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
withTransaction(tx: unknown, actor?: Actor | null): CommerceLocalAPI;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Create a headless commerce instance.
|
|
111
|
+
*
|
|
112
|
+
* This is the primary entry point for using UnifiedCommerce without an HTTP server.
|
|
113
|
+
* It initializes the kernel, database, auth, and returns a local API that works
|
|
114
|
+
* exactly like the REST API but without HTTP overhead.
|
|
115
|
+
*
|
|
116
|
+
* The Hono server (`createServer`) is optional — use it only when you need
|
|
117
|
+
* a standalone HTTP API. For Next.js, TanStack Start, SvelteKit, Nuxt, etc.,
|
|
118
|
+
* use `createCommerce()` directly.
|
|
119
|
+
*/
|
|
120
|
+
export async function createCommerce(
|
|
121
|
+
config: CommerceConfig,
|
|
122
|
+
): Promise<CommerceInstance> {
|
|
123
|
+
const kernel = createKernel(config);
|
|
124
|
+
|
|
125
|
+
setBootStrictOrgResolution(config.auth?.strictOrgResolution === true);
|
|
126
|
+
|
|
127
|
+
// Register the config-driven org ID so resolveOrgId() can use it
|
|
128
|
+
// without requiring every service to have config access.
|
|
129
|
+
if (config.auth?.defaultOrganizationId) {
|
|
130
|
+
setBootDefaultOrgId(config.auth.defaultOrganizationId);
|
|
131
|
+
} else {
|
|
132
|
+
// Legacy fallback: auto-create org_default for deployments
|
|
133
|
+
// that haven't migrated to seed-based org creation yet.
|
|
134
|
+
await ensureDefaultOrg(kernel.database.db, config.storeName);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const auth = createAuth(kernel.database, config);
|
|
138
|
+
const logger = createLogger(config);
|
|
139
|
+
|
|
140
|
+
// Default API: no actor (public access), no transaction
|
|
141
|
+
const api = createLocalAPI(kernel);
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
api,
|
|
145
|
+
kernel,
|
|
146
|
+
db: kernel.database.db,
|
|
147
|
+
auth,
|
|
148
|
+
logger,
|
|
149
|
+
|
|
150
|
+
withActor(actor: Actor): CommerceLocalAPI {
|
|
151
|
+
return createLocalAPI(kernel, { actor });
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
withTransaction(tx: unknown, actor?: Actor | null): CommerceLocalAPI {
|
|
155
|
+
return createLocalAPI(kernel, { actor: actor ?? null, tx });
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { AppModule } from "../kernel/module/index.js";
|
|
2
|
+
import { topoSortModules } from "../kernel/module/index.js";
|
|
3
|
+
import { auditModule } from "../modules/audit/index.js";
|
|
4
|
+
import { analyticsModule } from "../modules/analytics/module.js";
|
|
5
|
+
import { cartModule } from "../modules/cart/module.js";
|
|
6
|
+
import { catalogModule } from "../modules/catalog/module.js";
|
|
7
|
+
import { customersModule } from "../modules/customers/index.js";
|
|
8
|
+
import { fulfillmentModule } from "../modules/fulfillment/module.js";
|
|
9
|
+
import { inventoryModule } from "../modules/inventory/module.js";
|
|
10
|
+
import { mediaModule } from "../modules/media/index.js";
|
|
11
|
+
import { ordersModule } from "../modules/orders/module.js";
|
|
12
|
+
import { organizationModule } from "../modules/organization/index.js";
|
|
13
|
+
import { paymentsModule } from "../modules/payments/module.js";
|
|
14
|
+
import { pricingModule } from "../modules/pricing/index.js";
|
|
15
|
+
import { promotionsModule } from "../modules/promotions/module.js";
|
|
16
|
+
import { searchModule } from "../modules/search/module.js";
|
|
17
|
+
import { shippingModule } from "../modules/shipping/module.js";
|
|
18
|
+
import { taxModule } from "../modules/tax/module.js";
|
|
19
|
+
import { webhooksModule } from "../modules/webhooks/index.js";
|
|
20
|
+
|
|
21
|
+
export const KERNEL_ALL_MODULES = {
|
|
22
|
+
audit: auditModule,
|
|
23
|
+
webhooks: webhooksModule,
|
|
24
|
+
media: mediaModule,
|
|
25
|
+
organization: organizationModule,
|
|
26
|
+
customers: customersModule,
|
|
27
|
+
pricing: pricingModule,
|
|
28
|
+
catalog: catalogModule,
|
|
29
|
+
inventory: inventoryModule,
|
|
30
|
+
cart: cartModule,
|
|
31
|
+
orders: ordersModule,
|
|
32
|
+
fulfillment: fulfillmentModule,
|
|
33
|
+
promotions: promotionsModule,
|
|
34
|
+
search: searchModule,
|
|
35
|
+
shipping: shippingModule,
|
|
36
|
+
tax: taxModule,
|
|
37
|
+
payments: paymentsModule,
|
|
38
|
+
analytics: analyticsModule,
|
|
39
|
+
} as const;
|
|
40
|
+
|
|
41
|
+
/** Strip symmetric/lazy manifest edges so topo sort reflects constructor-safe ordering. */
|
|
42
|
+
export function kernelModulesForTopoSort(): Record<string, AppModule> {
|
|
43
|
+
return {
|
|
44
|
+
...KERNEL_ALL_MODULES,
|
|
45
|
+
catalog: { ...catalogModule, dependencies: [] },
|
|
46
|
+
promotions: {
|
|
47
|
+
...promotionsModule,
|
|
48
|
+
dependencies: ["catalog"],
|
|
49
|
+
},
|
|
50
|
+
orders: {
|
|
51
|
+
...ordersModule,
|
|
52
|
+
dependencies: [
|
|
53
|
+
"cart",
|
|
54
|
+
"inventory",
|
|
55
|
+
"payments",
|
|
56
|
+
"pricing",
|
|
57
|
+
"fulfillment",
|
|
58
|
+
"tax",
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
} as unknown as Record<string, AppModule>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function kernelModuleInstantiationOrder(): readonly string[] {
|
|
65
|
+
return topoSortModules(kernelModulesForTopoSort());
|
|
66
|
+
}
|