@porulle/core 0.64.0 → 0.65.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/email-render.d.ts +18 -0
- package/dist/adapters/email-render.d.ts.map +1 -0
- package/dist/adapters/email-render.js +37 -0
- package/dist/auth/actor.d.ts.map +1 -1
- package/dist/auth/actor.js +11 -0
- package/dist/auth/auth-failure.d.ts +0 -2
- package/dist/auth/auth-failure.d.ts.map +1 -1
- package/dist/auth/auth-failure.js +0 -4
- package/dist/auth/middleware.d.ts +0 -1
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +7 -6
- package/dist/auth/permissions.d.ts +2 -0
- package/dist/auth/permissions.d.ts.map +1 -1
- package/dist/auth/permissions.js +8 -6
- package/dist/auth/role-authority.d.ts +0 -1
- package/dist/auth/role-authority.d.ts.map +1 -1
- package/dist/auth/role-authority.js +1 -8
- package/dist/auth/setup.d.ts.map +1 -1
- package/dist/auth/setup.js +5 -0
- package/dist/auth/strict-org-resolution.d.ts +8 -1
- package/dist/auth/strict-org-resolution.d.ts.map +1 -1
- package/dist/auth/strict-org-resolution.js +9 -19
- package/dist/auth/system-actor.d.ts +3 -2
- package/dist/auth/system-actor.d.ts.map +1 -1
- package/dist/auth/system-actor.js +3 -3
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +3 -20
- package/dist/config/define-config.d.ts +2 -2
- package/dist/config/define-config.d.ts.map +1 -1
- package/dist/config/define-config.js +3 -2
- package/dist/config/types.d.ts +2 -3
- package/dist/config/types.d.ts.map +1 -1
- package/dist/hooks/checkout.d.ts +2 -15
- package/dist/hooks/checkout.d.ts.map +1 -1
- package/dist/hooks/checkout.js +2 -51
- package/dist/index.d.ts +11 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -12
- package/dist/interfaces/rest/router.js +3 -3
- package/dist/interfaces/rest/routes/admin/compensation-failures.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/admin/compensation-failures.js +5 -5
- package/dist/interfaces/rest/routes/admin/entity-field-definitions.js +5 -5
- package/dist/interfaces/rest/routes/admin/staff.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/admin/staff.js +2 -3
- package/dist/interfaces/rest/routes/analytics.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/analytics.js +2 -2
- package/dist/interfaces/rest/routes/carts.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/carts.js +12 -12
- package/dist/interfaces/rest/routes/catalog.js +37 -37
- package/dist/interfaces/rest/routes/checkout.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/checkout.js +9 -10
- package/dist/interfaces/rest/routes/customers.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/customers.js +12 -12
- package/dist/interfaces/rest/routes/documents.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/documents.js +9 -9
- package/dist/interfaces/rest/routes/inventory.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/inventory.js +8 -8
- package/dist/interfaces/rest/routes/media.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/media.js +5 -5
- package/dist/interfaces/rest/routes/orders.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/orders.js +32 -32
- package/dist/interfaces/rest/routes/payments.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/payments.js +2 -2
- package/dist/interfaces/rest/routes/pricing.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/pricing.js +8 -8
- package/dist/interfaces/rest/routes/promotions.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/promotions.js +7 -7
- package/dist/interfaces/rest/routes/search.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/search.js +3 -3
- package/dist/interfaces/rest/routes/settings.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/settings.js +4 -4
- package/dist/interfaces/rest/routes/shipping.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/shipping.js +9 -9
- package/dist/interfaces/rest/routes/tax.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/tax.js +9 -9
- package/dist/interfaces/rest/routes/webhooks.d.ts.map +1 -1
- package/dist/interfaces/rest/routes/webhooks.js +4 -4
- package/dist/interfaces/rest/utils.d.ts +1 -1
- package/dist/interfaces/rest/utils.d.ts.map +1 -1
- package/dist/interfaces/rest/utils.js +4 -13
- package/dist/jobs.d.ts +1 -0
- package/dist/jobs.d.ts.map +1 -1
- package/dist/jobs.js +1 -0
- package/dist/kernel/database/adapter.d.ts +9 -0
- package/dist/kernel/database/adapter.d.ts.map +1 -1
- package/dist/kernel/database/adapter.js +1 -1
- package/dist/kernel/database/migrate.d.ts +0 -4
- package/dist/kernel/database/migrate.d.ts.map +1 -1
- package/dist/kernel/database/migrate.js +2 -14
- package/dist/kernel/database/pglite-transaction.d.ts +28 -0
- package/dist/kernel/database/pglite-transaction.d.ts.map +1 -0
- package/dist/kernel/database/pglite-transaction.js +52 -0
- package/dist/kernel/database/tx-context.d.ts +0 -1
- package/dist/kernel/database/tx-context.d.ts.map +1 -1
- package/dist/kernel/database/tx-context.js +2 -14
- package/dist/kernel/database/unique-violation.d.ts +3 -0
- package/dist/kernel/database/unique-violation.d.ts.map +1 -0
- package/dist/kernel/database/unique-violation.js +9 -0
- package/dist/kernel/error-mapper.d.ts.map +1 -1
- package/dist/kernel/error-mapper.js +1 -0
- package/dist/kernel/errors.d.ts +12 -0
- package/dist/kernel/errors.d.ts.map +1 -1
- package/dist/kernel/errors.js +16 -0
- package/dist/kernel/hooks/create-context.d.ts +18 -9
- package/dist/kernel/hooks/create-context.d.ts.map +1 -1
- package/dist/kernel/hooks/create-context.js +24 -3
- package/dist/kernel/hooks/registry.d.ts +0 -19
- package/dist/kernel/hooks/registry.d.ts.map +1 -1
- package/dist/kernel/hooks/registry.js +0 -32
- package/dist/kernel/jobs/drizzle-adapter.d.ts.map +1 -1
- package/dist/kernel/jobs/drizzle-adapter.js +3 -10
- package/dist/kernel/jobs/prepare-enqueue.d.ts +20 -0
- package/dist/kernel/jobs/prepare-enqueue.d.ts.map +1 -0
- package/dist/kernel/jobs/prepare-enqueue.js +24 -0
- package/dist/kernel/jobs/types.d.ts +0 -4
- package/dist/kernel/jobs/types.d.ts.map +1 -1
- package/dist/kernel/jobs/types.js +0 -4
- package/dist/kernel/local-api.d.ts +0 -33
- package/dist/kernel/local-api.d.ts.map +1 -1
- package/dist/kernel/local-api.js +0 -36
- package/dist/kernel/plugin/manifest.d.ts +3 -5
- package/dist/kernel/plugin/manifest.d.ts.map +1 -1
- package/dist/modules/analytics/service.d.ts +0 -6
- package/dist/modules/analytics/service.d.ts.map +1 -1
- package/dist/modules/analytics/service.js +0 -32
- package/dist/modules/cart/service.d.ts.map +1 -1
- package/dist/modules/cart/service.js +5 -17
- package/dist/modules/catalog/entity-service.d.ts.map +1 -1
- package/dist/modules/catalog/entity-service.js +9 -17
- package/dist/modules/catalog/import-service.d.ts.map +1 -1
- package/dist/modules/catalog/import-service.js +4 -13
- package/dist/modules/catalog/service.d.ts +1 -81
- package/dist/modules/catalog/service.d.ts.map +1 -1
- package/dist/modules/catalog/service.js +1 -8
- package/dist/modules/customers/service.d.ts.map +1 -1
- package/dist/modules/customers/service.js +5 -17
- package/dist/modules/documents/render.d.ts +0 -3
- package/dist/modules/documents/render.d.ts.map +1 -1
- package/dist/modules/documents/render.js +2 -17
- package/dist/modules/fulfillment/service.d.ts.map +1 -1
- package/dist/modules/fulfillment/service.js +8 -26
- package/dist/modules/inventory/service.d.ts.map +1 -1
- package/dist/modules/inventory/service.js +3 -20
- package/dist/modules/media/service.d.ts.map +1 -1
- package/dist/modules/media/service.js +2 -10
- package/dist/modules/orders/quote.d.ts.map +1 -1
- package/dist/modules/orders/quote.js +1 -2
- package/dist/modules/orders/service.d.ts.map +1 -1
- package/dist/modules/orders/service.js +4 -17
- package/dist/modules/pricing/service.d.ts.map +1 -1
- package/dist/modules/pricing/service.js +7 -18
- package/dist/modules/promotions/service.d.ts.map +1 -1
- package/dist/modules/promotions/service.js +4 -16
- package/dist/modules/tax/service.d.ts +1 -3
- package/dist/modules/tax/service.d.ts.map +1 -1
- package/dist/modules/tax/service.js +16 -52
- package/dist/modules/webhooks/hook.d.ts.map +1 -1
- package/dist/modules/webhooks/hook.js +3 -2
- package/dist/modules/webhooks/service.d.ts.map +1 -1
- package/dist/modules/webhooks/service.js +1 -50
- package/dist/runtime/commerce.d.ts.map +1 -1
- package/dist/runtime/commerce.js +4 -11
- package/dist/runtime/kernel-modules.d.ts +38 -1799
- package/dist/runtime/kernel-modules.d.ts.map +1 -1
- package/dist/runtime/kernel-modules.js +160 -66
- package/dist/runtime/kernel-types.d.ts +3 -15
- package/dist/runtime/kernel-types.d.ts.map +1 -1
- package/dist/runtime/kernel-types.js +0 -10
- package/dist/runtime/kernel.d.ts +2 -3
- package/dist/runtime/kernel.d.ts.map +1 -1
- package/dist/runtime/kernel.js +10 -51
- package/dist/runtime/server.d.ts +1 -1
- package/dist/runtime/server.d.ts.map +1 -1
- package/dist/test-utils/create-pglite-adapter.d.ts.map +1 -1
- package/dist/test-utils/create-pglite-adapter.js +5 -62
- package/dist/test-utils/create-plugin-test-app.d.ts.map +1 -1
- package/dist/test-utils/create-plugin-test-app.js +13 -32
- package/dist/test-utils/rest-api-test-utils.d.ts +0 -12
- package/dist/test-utils/rest-api-test-utils.d.ts.map +1 -1
- package/dist/test-utils/rest-api-test-utils.js +3 -70
- package/dist/test-utils/test-actors.d.ts +9 -0
- package/dist/test-utils/test-actors.d.ts.map +1 -1
- package/dist/test-utils/test-actors.js +62 -0
- package/dist/testing.d.ts +1 -4
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +1 -4
- package/dist/utils/escape-html.d.ts +3 -0
- package/dist/utils/escape-html.d.ts.map +1 -0
- package/dist/utils/escape-html.js +9 -0
- package/dist/utils/id.d.ts +0 -1
- package/dist/utils/id.d.ts.map +1 -1
- package/dist/utils/id.js +0 -3
- package/dist/utils/logger.d.ts +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +1 -1
- package/dist/utils/money.d.ts +13 -0
- package/dist/utils/money.d.ts.map +1 -0
- package/dist/utils/money.js +58 -0
- package/package.json +26 -29
- package/src/adapters/email-render.ts +63 -0
- package/src/auth/actor.ts +14 -0
- package/src/auth/auth-failure.ts +0 -5
- package/src/auth/middleware.ts +7 -6
- package/src/auth/permissions.ts +12 -6
- package/src/auth/role-authority.ts +1 -10
- package/src/auth/setup.ts +8 -0
- package/src/auth/strict-org-resolution.ts +9 -16
- package/src/auth/system-actor.ts +3 -3
- package/src/config/defaults.ts +3 -20
- package/src/config/define-config.ts +5 -4
- package/src/config/types.ts +2 -2
- package/src/hooks/checkout.ts +2 -86
- package/src/index.ts +9 -36
- package/src/interfaces/rest/router.ts +3 -3
- package/src/interfaces/rest/routes/admin/compensation-failures.ts +5 -5
- package/src/interfaces/rest/routes/admin/entity-field-definitions.ts +5 -5
- package/src/interfaces/rest/routes/admin/staff.ts +2 -3
- package/src/interfaces/rest/routes/analytics.ts +2 -2
- package/src/interfaces/rest/routes/carts.ts +12 -12
- package/src/interfaces/rest/routes/catalog.ts +37 -37
- package/src/interfaces/rest/routes/checkout.ts +8 -10
- package/src/interfaces/rest/routes/customers.ts +12 -12
- package/src/interfaces/rest/routes/documents.ts +9 -9
- package/src/interfaces/rest/routes/inventory.ts +8 -8
- package/src/interfaces/rest/routes/media.ts +5 -5
- package/src/interfaces/rest/routes/orders.ts +32 -32
- package/src/interfaces/rest/routes/payments.ts +2 -2
- package/src/interfaces/rest/routes/pricing.ts +8 -8
- package/src/interfaces/rest/routes/promotions.ts +7 -7
- package/src/interfaces/rest/routes/search.ts +3 -3
- package/src/interfaces/rest/routes/settings.ts +4 -4
- package/src/interfaces/rest/routes/shipping.ts +9 -9
- package/src/interfaces/rest/routes/tax.ts +9 -9
- package/src/interfaces/rest/routes/webhooks.ts +4 -4
- package/src/interfaces/rest/utils.ts +4 -14
- package/src/jobs.ts +2 -1
- package/src/kernel/database/adapter.ts +1 -1
- package/src/kernel/database/migrate.ts +2 -17
- package/src/kernel/database/pglite-transaction.ts +61 -0
- package/src/kernel/database/tx-context.ts +2 -20
- package/src/kernel/database/unique-violation.ts +7 -0
- package/src/kernel/error-mapper.ts +1 -0
- package/src/kernel/errors.ts +18 -0
- package/src/kernel/hooks/create-context.ts +38 -8
- package/src/kernel/hooks/registry.ts +0 -37
- package/src/kernel/jobs/drizzle-adapter.ts +4 -15
- package/src/kernel/jobs/prepare-enqueue.ts +42 -0
- package/src/kernel/jobs/types.ts +0 -5
- package/src/kernel/local-api.ts +0 -44
- package/src/kernel/plugin/manifest.ts +3 -5
- package/src/modules/analytics/service.ts +0 -36
- package/src/modules/cart/service.ts +6 -29
- package/src/modules/catalog/entity-service.ts +9 -19
- package/src/modules/catalog/import-service.ts +4 -11
- package/src/modules/catalog/service.ts +2 -286
- package/src/modules/customers/service.ts +6 -27
- package/src/modules/documents/render.ts +2 -19
- package/src/modules/fulfillment/service.ts +8 -27
- package/src/modules/inventory/service.ts +3 -21
- package/src/modules/media/service.ts +2 -8
- package/src/modules/orders/quote.ts +1 -2
- package/src/modules/orders/service.ts +5 -30
- package/src/modules/pricing/service.ts +12 -30
- package/src/modules/promotions/service.ts +5 -28
- package/src/modules/tax/service.ts +20 -48
- package/src/modules/webhooks/hook.ts +3 -2
- package/src/modules/webhooks/service.ts +1 -42
- package/src/runtime/commerce.ts +4 -11
- package/src/runtime/kernel-modules.ts +191 -67
- package/src/runtime/kernel-types.ts +3 -26
- package/src/runtime/kernel.ts +11 -66
- package/src/runtime/server.ts +1 -3
- package/src/test-utils/create-pglite-adapter.ts +5 -67
- package/src/test-utils/create-plugin-test-app.ts +13 -52
- package/src/test-utils/rest-api-test-utils.ts +3 -70
- package/src/test-utils/test-actors.ts +66 -0
- package/src/testing.ts +1 -3
- package/src/utils/escape-html.ts +9 -0
- package/src/utils/id.ts +0 -4
- package/src/utils/logger.ts +1 -1
- package/src/utils/money.ts +62 -0
- package/dist/auth/access.d.ts +0 -101
- package/dist/auth/access.d.ts.map +0 -1
- package/dist/auth/access.js +0 -128
- package/dist/generated/plugin-manifest.d.ts +0 -51
- package/dist/generated/plugin-manifest.d.ts.map +0 -1
- package/dist/generated/plugin-manifest.js +0 -21
- package/dist/kernel/factory/repository-factory.d.ts +0 -71
- package/dist/kernel/factory/repository-factory.d.ts.map +0 -1
- package/dist/kernel/factory/repository-factory.js +0 -138
- package/dist/kernel/http-error.d.ts +0 -30
- package/dist/kernel/http-error.d.ts.map +0 -1
- package/dist/kernel/http-error.js +0 -35
- package/dist/kernel/jobs/builtin-job-tasks.d.ts +0 -3
- package/dist/kernel/jobs/builtin-job-tasks.d.ts.map +0 -1
- package/dist/kernel/jobs/builtin-job-tasks.js +0 -6
- package/dist/kernel/module/define.d.ts +0 -21
- package/dist/kernel/module/define.d.ts.map +0 -1
- package/dist/kernel/module/define.js +0 -3
- package/dist/kernel/module/index.d.ts +0 -4
- package/dist/kernel/module/index.d.ts.map +0 -1
- package/dist/kernel/module/index.js +0 -2
- package/dist/kernel/module/topo-sort.d.ts +0 -7
- package/dist/kernel/module/topo-sort.d.ts.map +0 -1
- package/dist/kernel/module/topo-sort.js +0 -89
- package/dist/kernel/query/executor.d.ts +0 -21
- package/dist/kernel/query/executor.d.ts.map +0 -1
- package/dist/kernel/query/executor.js +0 -128
- package/dist/kernel/query/registry.d.ts +0 -33
- package/dist/kernel/query/registry.d.ts.map +0 -1
- package/dist/kernel/query/registry.js +0 -20
- package/dist/kernel/service-registry.d.ts +0 -109
- package/dist/kernel/service-registry.d.ts.map +0 -1
- package/dist/kernel/service-registry.js +0 -26
- package/dist/modules/analytics/hooks.d.ts +0 -13
- package/dist/modules/analytics/hooks.d.ts.map +0 -1
- package/dist/modules/analytics/hooks.js +0 -12
- package/dist/modules/analytics/module.d.ts +0 -3
- package/dist/modules/analytics/module.d.ts.map +0 -1
- package/dist/modules/analytics/module.js +0 -24
- package/dist/modules/analytics/repository/index.d.ts +0 -5
- package/dist/modules/analytics/repository/index.d.ts.map +0 -1
- package/dist/modules/analytics/repository/index.js +0 -1
- package/dist/modules/audit/index.d.ts +0 -2
- package/dist/modules/audit/index.d.ts.map +0 -1
- package/dist/modules/audit/index.js +0 -1
- package/dist/modules/audit/module.d.ts +0 -180
- package/dist/modules/audit/module.d.ts.map +0 -1
- package/dist/modules/audit/module.js +0 -8
- package/dist/modules/cart/access.d.ts +0 -11
- package/dist/modules/cart/access.d.ts.map +0 -1
- package/dist/modules/cart/access.js +0 -18
- package/dist/modules/cart/module.d.ts +0 -14
- package/dist/modules/cart/module.d.ts.map +0 -1
- package/dist/modules/cart/module.js +0 -17
- package/dist/modules/catalog/module.d.ts +0 -26
- package/dist/modules/catalog/module.d.ts.map +0 -1
- package/dist/modules/catalog/module.js +0 -33
- package/dist/modules/customers/index.d.ts +0 -2
- package/dist/modules/customers/index.d.ts.map +0 -1
- package/dist/modules/customers/index.js +0 -1
- package/dist/modules/customers/module.d.ts +0 -563
- package/dist/modules/customers/module.d.ts.map +0 -1
- package/dist/modules/customers/module.js +0 -20
- package/dist/modules/documents/module.d.ts +0 -7
- package/dist/modules/documents/module.d.ts.map +0 -1
- package/dist/modules/documents/module.js +0 -13
- package/dist/modules/fulfillment/module.d.ts +0 -13
- package/dist/modules/fulfillment/module.d.ts.map +0 -1
- package/dist/modules/fulfillment/module.js +0 -23
- package/dist/modules/inventory/module.d.ts +0 -13
- package/dist/modules/inventory/module.d.ts.map +0 -1
- package/dist/modules/inventory/module.js +0 -20
- package/dist/modules/media/index.d.ts +0 -2
- package/dist/modules/media/index.d.ts.map +0 -1
- package/dist/modules/media/index.js +0 -1
- package/dist/modules/media/module.d.ts +0 -360
- package/dist/modules/media/module.d.ts.map +0 -1
- package/dist/modules/media/module.js +0 -24
- package/dist/modules/orders/module.d.ts +0 -25
- package/dist/modules/orders/module.d.ts.map +0 -1
- package/dist/modules/orders/module.js +0 -33
- package/dist/modules/organization/index.d.ts +0 -2
- package/dist/modules/organization/index.d.ts.map +0 -1
- package/dist/modules/organization/index.js +0 -1
- package/dist/modules/organization/module.d.ts +0 -205
- package/dist/modules/organization/module.d.ts.map +0 -1
- package/dist/modules/organization/module.js +0 -8
- package/dist/modules/payments/module.d.ts +0 -3
- package/dist/modules/payments/module.d.ts.map +0 -1
- package/dist/modules/payments/module.js +0 -7
- package/dist/modules/payments/repository/index.d.ts +0 -5
- package/dist/modules/payments/repository/index.d.ts.map +0 -1
- package/dist/modules/payments/repository/index.js +0 -1
- package/dist/modules/pricing/index.d.ts +0 -2
- package/dist/modules/pricing/index.d.ts.map +0 -1
- package/dist/modules/pricing/index.js +0 -1
- package/dist/modules/pricing/module.d.ts +0 -14
- package/dist/modules/pricing/module.d.ts.map +0 -1
- package/dist/modules/pricing/module.js +0 -17
- package/dist/modules/promotions/module.d.ts +0 -14
- package/dist/modules/promotions/module.d.ts.map +0 -1
- package/dist/modules/promotions/module.js +0 -19
- package/dist/modules/search/module.d.ts +0 -8
- package/dist/modules/search/module.d.ts.map +0 -1
- package/dist/modules/search/module.js +0 -22
- package/dist/modules/search/repository/index.d.ts +0 -5
- package/dist/modules/search/repository/index.d.ts.map +0 -1
- package/dist/modules/search/repository/index.js +0 -1
- package/dist/modules/settings/module.d.ts +0 -6
- package/dist/modules/settings/module.d.ts.map +0 -1
- package/dist/modules/settings/module.js +0 -12
- package/dist/modules/shipping/module.d.ts +0 -12
- package/dist/modules/shipping/module.d.ts.map +0 -1
- package/dist/modules/shipping/module.js +0 -14
- package/dist/modules/tax/module.d.ts +0 -7
- package/dist/modules/tax/module.d.ts.map +0 -1
- package/dist/modules/tax/module.js +0 -13
- package/dist/modules/webhooks/index.d.ts +0 -2
- package/dist/modules/webhooks/index.d.ts.map +0 -1
- package/dist/modules/webhooks/index.js +0 -1
- package/dist/modules/webhooks/module.d.ts +0 -403
- package/dist/modules/webhooks/module.d.ts.map +0 -1
- package/dist/modules/webhooks/module.js +0 -16
- package/dist/test-utils/create-repository-test-harness.d.ts +0 -8
- package/dist/test-utils/create-repository-test-harness.d.ts.map +0 -1
- package/dist/test-utils/create-repository-test-harness.js +0 -7
- package/dist/test-utils/create-test-plugin-context.d.ts +0 -38
- package/dist/test-utils/create-test-plugin-context.d.ts.map +0 -1
- package/dist/test-utils/create-test-plugin-context.js +0 -39
- package/dist/test-utils/typed-hooks.d.ts +0 -44
- package/dist/test-utils/typed-hooks.d.ts.map +0 -1
- package/dist/test-utils/typed-hooks.js +0 -36
- package/dist/types/commerce-types.d.ts +0 -34
- package/dist/types/commerce-types.d.ts.map +0 -1
- package/dist/types/commerce-types.js +0 -1
- package/src/auth/access.ts +0 -187
- package/src/generated/plugin-capabilities.d.ts +0 -21
- package/src/generated/plugin-manifest.ts +0 -24
- package/src/generated/plugin-repositories.d.ts +0 -21
- package/src/kernel/factory/repository-factory.ts +0 -244
- package/src/kernel/http-error.ts +0 -44
- package/src/kernel/jobs/builtin-job-tasks.ts +0 -17
- package/src/kernel/module/define.ts +0 -36
- package/src/kernel/module/index.ts +0 -3
- package/src/kernel/module/topo-sort.ts +0 -99
- package/src/kernel/query/executor.ts +0 -184
- package/src/kernel/query/registry.ts +0 -46
- package/src/kernel/service-registry.ts +0 -76
- package/src/modules/analytics/hooks.ts +0 -11
- package/src/modules/analytics/module.ts +0 -35
- package/src/modules/analytics/repository/index.ts +0 -5
- package/src/modules/audit/index.ts +0 -1
- package/src/modules/audit/module.ts +0 -11
- package/src/modules/cart/access.ts +0 -27
- package/src/modules/cart/module.ts +0 -32
- package/src/modules/catalog/module.ts +0 -80
- package/src/modules/customers/index.ts +0 -1
- package/src/modules/customers/module.ts +0 -29
- package/src/modules/documents/module.ts +0 -21
- package/src/modules/fulfillment/module.ts +0 -44
- package/src/modules/inventory/module.ts +0 -37
- package/src/modules/media/index.ts +0 -1
- package/src/modules/media/module.ts +0 -27
- package/src/modules/orders/module.ts +0 -67
- package/src/modules/organization/index.ts +0 -1
- package/src/modules/organization/module.ts +0 -11
- package/src/modules/payments/module.ts +0 -14
- package/src/modules/payments/repository/index.ts +0 -5
- package/src/modules/pricing/index.ts +0 -1
- package/src/modules/pricing/module.ts +0 -32
- package/src/modules/promotions/module.ts +0 -34
- package/src/modules/search/module.ts +0 -32
- package/src/modules/search/repository/index.ts +0 -5
- package/src/modules/settings/module.ts +0 -20
- package/src/modules/shipping/module.ts +0 -27
- package/src/modules/tax/module.ts +0 -21
- package/src/modules/webhooks/index.ts +0 -1
- package/src/modules/webhooks/module.ts +0 -24
- package/src/test-utils/create-repository-test-harness.ts +0 -16
- package/src/test-utils/create-test-plugin-context.ts +0 -66
- package/src/test-utils/typed-hooks.ts +0 -55
- package/src/types/commerce-types.ts +0 -34
package/src/auth/permissions.ts
CHANGED
|
@@ -17,13 +17,19 @@ export function isUnauthenticatedActor(
|
|
|
17
17
|
return actor === null || (actor.type === "user" && actor.userId === null);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
/** Whether a permission list grants `required`: an exact entry, `resource:*`, or `*:*`. */
|
|
21
|
+
export function hasPermissionFromList(
|
|
22
|
+
granted: readonly string[],
|
|
23
|
+
required: string,
|
|
24
|
+
): boolean {
|
|
25
|
+
if (granted.includes("*:*")) return true;
|
|
24
26
|
const [resource] = required.split(":");
|
|
25
|
-
if (resource &&
|
|
26
|
-
return
|
|
27
|
+
if (resource && granted.includes(`${resource}:*`)) return true;
|
|
28
|
+
return granted.includes(required);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function hasPermission(actor: Actor | null, required: string): boolean {
|
|
32
|
+
return actor !== null && hasPermissionFromList(actor.permissions, required);
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
export function assertPermission(actor: Actor | null, required: string): void {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CommerceConfig } from "../config/types.js";
|
|
2
|
+
import { hasPermissionFromList } from "./permissions.js";
|
|
2
3
|
|
|
3
4
|
const BUILTIN_ROLE_RANK: Record<string, number> = {
|
|
4
5
|
owner: 3,
|
|
@@ -42,16 +43,6 @@ export function permissionsForRole(config: CommerceConfig, role: string): string
|
|
|
42
43
|
return config.auth?.roles?.[role]?.permissions ?? [];
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
export function hasPermissionFromList(
|
|
46
|
-
actorPermissions: readonly string[],
|
|
47
|
-
required: string,
|
|
48
|
-
): boolean {
|
|
49
|
-
if (actorPermissions.includes("*:*")) return true;
|
|
50
|
-
|
|
51
|
-
const [resource] = required.split(":");
|
|
52
|
-
if (resource && actorPermissions.includes(`${resource}:*`)) return true;
|
|
53
|
-
return actorPermissions.includes(required);
|
|
54
|
-
}
|
|
55
46
|
|
|
56
47
|
/**
|
|
57
48
|
* The role's privilege rank. A composite role ranks as its strongest part, so
|
package/src/auth/setup.ts
CHANGED
|
@@ -91,6 +91,14 @@ export function createAuth(
|
|
|
91
91
|
jwt(),
|
|
92
92
|
];
|
|
93
93
|
|
|
94
|
+
// Requiring a second factor while the plugin that enrols one is off would lock
|
|
95
|
+
// every listed role out with no way back in.
|
|
96
|
+
if ((config.auth?.twoFactor?.requiredForRoles?.length ?? 0) > 0 && !config.auth?.twoFactor?.enabled) {
|
|
97
|
+
throw new Error(
|
|
98
|
+
"auth.twoFactor.requiredForRoles needs auth.twoFactor.enabled: true — members of those roles could never enrol.",
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
94
102
|
if (config.auth?.twoFactor?.enabled) {
|
|
95
103
|
plugins.push(twoFactor({ issuer: config.storeName ?? "UnifiedCommerce" }));
|
|
96
104
|
}
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
import type { CommerceConfig } from "../config/types.js";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Whether a request with no actor must fail rather than resolve to a default
|
|
5
|
+
* organization. Fail closed by default: without an actor there is no tenant,
|
|
6
|
+
* and silently resolving to a default organization served one merchant's data
|
|
7
|
+
* to unauthenticated callers on every unguarded or allowlisted read path.
|
|
8
|
+
* Single-tenant deployments that relied on that fallback opt out explicitly
|
|
9
|
+
* with `auth.strictOrgResolution: false` or `STRICT_ORG_RESOLUTION=false`.
|
|
10
|
+
*/
|
|
9
11
|
export function isStrictOrgResolution(config?: CommerceConfig | null): boolean {
|
|
10
|
-
|
|
11
|
-
// resolving to a default organization served one merchant's data to
|
|
12
|
-
// unauthenticated callers on every unguarded or allowlisted read path.
|
|
13
|
-
// Single-tenant deployments that relied on that fallback opt out explicitly.
|
|
14
|
-
if (config?.auth?.strictOrgResolution === false) return false;
|
|
15
|
-
if (process.env.STRICT_ORG_RESOLUTION === "false") return false;
|
|
16
|
-
if (config?.auth?.strictOrgResolution === true) return true;
|
|
17
|
-
if (process.env.STRICT_ORG_RESOLUTION === "true") return true;
|
|
18
|
-
if ((config === undefined || config === null) && _bootStrictOrgResolution) return true;
|
|
19
|
-
return true;
|
|
12
|
+
return config?.auth?.strictOrgResolution !== false && process.env.STRICT_ORG_RESOLUTION !== "false";
|
|
20
13
|
}
|
package/src/auth/system-actor.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Actor } from "./types.js";
|
|
2
|
-
import { DEFAULT_ORG_ID } from "./org.js";
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Creates a system actor for internal operations (webhooks, jobs, compensation chains).
|
|
6
|
-
* System actors have full permissions
|
|
5
|
+
* System actors have full permissions, so the organization they act in is
|
|
6
|
+
* always named by the caller — there is no default tenant to fall back to.
|
|
7
7
|
*/
|
|
8
|
-
export function createSystemActor(orgId: string
|
|
8
|
+
export function createSystemActor(orgId: string): Actor {
|
|
9
9
|
return {
|
|
10
10
|
type: "api_key",
|
|
11
11
|
userId: "system:internal",
|
package/src/config/defaults.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CommerceConfig } from "./types.js";
|
|
2
|
+
import { DEFAULT_CUSTOMER_PERMISSIONS } from "../auth/actor.js";
|
|
2
3
|
|
|
3
4
|
export const defaultConfig: Partial<CommerceConfig> = {
|
|
4
5
|
version: "0.0.1",
|
|
@@ -44,28 +45,10 @@ export const defaultConfig: Partial<CommerceConfig> = {
|
|
|
44
45
|
],
|
|
45
46
|
},
|
|
46
47
|
customer: {
|
|
47
|
-
permissions: [
|
|
48
|
-
"catalog:read",
|
|
49
|
-
"cart:create",
|
|
50
|
-
"cart:read",
|
|
51
|
-
"cart:update",
|
|
52
|
-
"orders:create",
|
|
53
|
-
"orders:read:own",
|
|
54
|
-
"customers:read:self",
|
|
55
|
-
"customers:update:self",
|
|
56
|
-
],
|
|
48
|
+
permissions: [...DEFAULT_CUSTOMER_PERMISSIONS],
|
|
57
49
|
},
|
|
58
50
|
},
|
|
59
|
-
customerPermissions: [
|
|
60
|
-
"catalog:read",
|
|
61
|
-
"cart:create",
|
|
62
|
-
"cart:read",
|
|
63
|
-
"cart:update",
|
|
64
|
-
"orders:create",
|
|
65
|
-
"orders:read:own",
|
|
66
|
-
"customers:read:self",
|
|
67
|
-
"customers:update:self",
|
|
68
|
-
],
|
|
51
|
+
customerPermissions: [...DEFAULT_CUSTOMER_PERMISSIONS],
|
|
69
52
|
},
|
|
70
53
|
cart: {
|
|
71
54
|
ttlMinutes: 60 * 24 * 7,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { defaultConfig } from "./defaults.js";
|
|
2
|
-
import type { CommerceConfig
|
|
2
|
+
import type { CommerceConfig } from "./types.js";
|
|
3
3
|
import type { TaskDefinition } from "../kernel/jobs/types.js";
|
|
4
|
-
import {
|
|
4
|
+
import { staleJobReaperTask } from "../kernel/jobs/reaper.js";
|
|
5
|
+
import { webhookDeliveryTask } from "../modules/webhooks/tasks.js";
|
|
5
6
|
import { _resetRegisteredPlugins } from "../kernel/plugin/manifest.js";
|
|
6
7
|
import { noopStorageAdapter } from "../modules/media/noop-adapter.js";
|
|
7
8
|
|
|
@@ -14,7 +15,7 @@ function mergeBuiltinJobTasks(
|
|
|
14
15
|
): NonNullable<CommerceConfig["jobs"]> {
|
|
15
16
|
const userTasks = jobs?.tasks ?? [];
|
|
16
17
|
const bySlug = new Map<string, TaskDefinition>();
|
|
17
|
-
for (const t of
|
|
18
|
+
for (const t of [webhookDeliveryTask, staleJobReaperTask] as TaskDefinition[]) {
|
|
18
19
|
bySlug.set(t.slug, t);
|
|
19
20
|
}
|
|
20
21
|
for (const t of userTasks) {
|
|
@@ -56,7 +57,7 @@ function merge<T extends object>(base: T, next: Partial<T>): T {
|
|
|
56
57
|
* 4. Freezing the result to prevent runtime mutation
|
|
57
58
|
*/
|
|
58
59
|
export async function defineConfig(
|
|
59
|
-
input:
|
|
60
|
+
input: CommerceConfig,
|
|
60
61
|
): Promise<CommerceConfig> {
|
|
61
62
|
let config = merge(defaultConfig as CommerceConfig, input);
|
|
62
63
|
|
package/src/config/types.ts
CHANGED
|
@@ -442,7 +442,6 @@ export interface CommerceConfig {
|
|
|
442
442
|
version?: string;
|
|
443
443
|
database: {
|
|
444
444
|
provider: "postgresql";
|
|
445
|
-
options?: Record<string, unknown>;
|
|
446
445
|
};
|
|
447
446
|
databaseAdapter?: DatabaseAdapter;
|
|
448
447
|
auth?: AuthConfig;
|
|
@@ -570,7 +569,6 @@ export interface CommerceConfig {
|
|
|
570
569
|
};
|
|
571
570
|
}
|
|
572
571
|
|
|
573
|
-
export interface DefineConfigInput extends CommerceConfig {}
|
|
574
572
|
|
|
575
573
|
export interface AuthSessionLike {
|
|
576
574
|
user: {
|
|
@@ -578,6 +576,8 @@ export interface AuthSessionLike {
|
|
|
578
576
|
email?: string | null;
|
|
579
577
|
name?: string | null;
|
|
580
578
|
vendorId?: string | null;
|
|
579
|
+
/** Set by Better Auth's twoFactor plugin once the user has enrolled. */
|
|
580
|
+
twoFactorEnabled?: boolean | null;
|
|
581
581
|
};
|
|
582
582
|
session: {
|
|
583
583
|
activeOrganizationId?: string | null;
|
package/src/hooks/checkout.ts
CHANGED
|
@@ -573,93 +573,9 @@ export const authorizePayment: BeforeHook<CheckoutData> = async ({
|
|
|
573
573
|
return data;
|
|
574
574
|
};
|
|
575
575
|
|
|
576
|
-
export const capturePayment: AfterHook<OrderResult> = async ({ context }) => {
|
|
577
|
-
const payments = context.services.payments as {
|
|
578
|
-
capture(paymentIntentId: string, amount?: number, paymentMethodId?: string): Promise<unknown>;
|
|
579
|
-
};
|
|
580
|
-
const paymentIntentId = context.context.paymentIntentId as string | undefined;
|
|
581
|
-
const paymentMethodId = context.context.paymentMethodId as string | undefined;
|
|
582
|
-
if (!paymentIntentId) return;
|
|
583
|
-
await payments.capture(paymentIntentId, undefined, paymentMethodId);
|
|
584
|
-
};
|
|
585
|
-
|
|
586
|
-
export const reserveInventory: AfterHook<OrderResult> = async ({ result, context }) => {
|
|
587
|
-
const inventory = context.services.inventory as {
|
|
588
|
-
reserve(input: {
|
|
589
|
-
entityId: string;
|
|
590
|
-
variantId?: string;
|
|
591
|
-
quantity: number;
|
|
592
|
-
orderId: string;
|
|
593
|
-
performedBy: string;
|
|
594
|
-
}, actor?: unknown): Promise<unknown>;
|
|
595
|
-
};
|
|
596
|
-
for (const lineItem of result.lineItems ?? []) {
|
|
597
|
-
await inventory.reserve(
|
|
598
|
-
{
|
|
599
|
-
entityId: lineItem.entityId,
|
|
600
|
-
...(lineItem.variantId != null ? { variantId: lineItem.variantId } : {}),
|
|
601
|
-
quantity: lineItem.quantity,
|
|
602
|
-
orderId: result.id,
|
|
603
|
-
performedBy: context.actor?.userId ?? "system",
|
|
604
|
-
},
|
|
605
|
-
context.actor,
|
|
606
|
-
);
|
|
607
|
-
}
|
|
608
|
-
};
|
|
609
|
-
|
|
610
|
-
export const initiateFulfillment: AfterHook<OrderResult> = async ({
|
|
611
|
-
result,
|
|
612
|
-
context,
|
|
613
|
-
}) => {
|
|
614
|
-
const fulfillment = context.services.fulfillment as {
|
|
615
|
-
fulfillOrder(orderId: string, actor?: unknown): Promise<unknown>;
|
|
616
|
-
};
|
|
617
|
-
await fulfillment.fulfillOrder(result.id, context.actor);
|
|
618
|
-
};
|
|
619
|
-
|
|
620
|
-
export const sendConfirmation: AfterHook<OrderResult> = async ({ result, context }) => {
|
|
621
|
-
const customers = context.services.customers as {
|
|
622
|
-
getByUserId(
|
|
623
|
-
userId: string,
|
|
624
|
-
actor?: unknown,
|
|
625
|
-
): Promise<{ ok: boolean; value?: { email?: string } }>;
|
|
626
|
-
};
|
|
627
|
-
const email = context.services.email as
|
|
628
|
-
| {
|
|
629
|
-
send(input: {
|
|
630
|
-
template: string;
|
|
631
|
-
to: string;
|
|
632
|
-
data?: Record<string, unknown>;
|
|
633
|
-
}): Promise<void>;
|
|
634
|
-
}
|
|
635
|
-
| undefined;
|
|
636
|
-
|
|
637
|
-
if (!result.customerId || !email?.send) return;
|
|
638
|
-
const customer = await customers.getByUserId(result.customerId, context.actor);
|
|
639
|
-
if (!customer.ok || !customer.value?.email) return;
|
|
640
|
-
|
|
641
|
-
await email.send({
|
|
642
|
-
template: "order-confirmation",
|
|
643
|
-
to: customer.value.email,
|
|
644
|
-
data: { order: result },
|
|
645
|
-
});
|
|
646
|
-
};
|
|
647
|
-
|
|
648
|
-
/**
|
|
649
|
-
* Analytics event recording — intentional no-op.
|
|
650
|
-
*
|
|
651
|
-
* The DrizzleAnalyticsAdapter queries source tables (orders, inventory)
|
|
652
|
-
* directly via SQL, so no separate event recording is needed. The export
|
|
653
|
-
* is preserved for backwards compatibility with checkout route imports.
|
|
654
|
-
*/
|
|
655
|
-
export const recordAnalyticsEvent: AfterHook<OrderResult> = async () => {
|
|
656
|
-
// No-op: source tables ARE the analytics events.
|
|
657
|
-
};
|
|
658
|
-
|
|
659
576
|
/**
|
|
660
|
-
*
|
|
661
|
-
*
|
|
662
|
-
* if any step fails.
|
|
577
|
+
* Completes a placed order as one compensation chain that can roll back
|
|
578
|
+
* completed steps if any step fails.
|
|
663
579
|
*
|
|
664
580
|
* Order of steps:
|
|
665
581
|
* 1. Reserve inventory — if this fails, no money is charged
|
package/src/index.ts
CHANGED
|
@@ -53,17 +53,6 @@ export {
|
|
|
53
53
|
isUnauthenticatedActor,
|
|
54
54
|
requireUserId,
|
|
55
55
|
} from "./auth/permissions.js";
|
|
56
|
-
export type { AccessResult, AccessContext, AccessFn, WhereClause } from "./auth/access.js";
|
|
57
|
-
export {
|
|
58
|
-
accessOR,
|
|
59
|
-
accessAND,
|
|
60
|
-
conditional,
|
|
61
|
-
isAdmin,
|
|
62
|
-
isAuthenticated,
|
|
63
|
-
isDocumentOwner,
|
|
64
|
-
publicAccess,
|
|
65
|
-
denyAll,
|
|
66
|
-
} from "./auth/access.js";
|
|
67
56
|
|
|
68
57
|
export { HookRegistry } from "./kernel/hooks/registry.js";
|
|
69
58
|
export type {
|
|
@@ -89,6 +78,7 @@ export type {
|
|
|
89
78
|
} from "./kernel/jobs/adapter.js";
|
|
90
79
|
export { NullJobsAdapter } from "./kernel/jobs/adapter.js";
|
|
91
80
|
export { DrizzleJobsAdapter } from "./kernel/jobs/drizzle-adapter.js";
|
|
81
|
+
export { prepareEnqueue, type PreparedEnqueue } from "./kernel/jobs/prepare-enqueue.js";
|
|
92
82
|
export { runPendingJobs } from "./kernel/jobs/runner.js";
|
|
93
83
|
export type { RunPendingJobsArgs } from "./kernel/jobs/runner.js";
|
|
94
84
|
export type {
|
|
@@ -102,7 +92,7 @@ export type {
|
|
|
102
92
|
JobProcessingOrderField,
|
|
103
93
|
JobProcessingOrderRecord,
|
|
104
94
|
} from "./kernel/jobs/types.js";
|
|
105
|
-
export {
|
|
95
|
+
export { TaskNonRetryableError } from "./kernel/jobs/types.js";
|
|
106
96
|
export { createPassThroughTaskStep } from "./kernel/jobs/step.js";
|
|
107
97
|
export {
|
|
108
98
|
staleJobReaperTask,
|
|
@@ -111,7 +101,7 @@ export {
|
|
|
111
101
|
getJobsReaperIntervalMs,
|
|
112
102
|
} from "./kernel/jobs/reaper.js";
|
|
113
103
|
|
|
114
|
-
export { createLocalAPI
|
|
104
|
+
export { createLocalAPI } from "./kernel/local-api.js";
|
|
115
105
|
export type { CommerceLocalAPI, LocalAPIOptions } from "./kernel/local-api.js";
|
|
116
106
|
export { createCommerce } from "./runtime/commerce.js";
|
|
117
107
|
export type { CommerceInstance } from "./runtime/commerce.js";
|
|
@@ -127,10 +117,6 @@ export type {
|
|
|
127
117
|
export type { Result, PluginResult, PluginResultErr } from "./kernel/result.js";
|
|
128
118
|
export { Ok, Err, PluginErr } from "./kernel/result.js";
|
|
129
119
|
export type { PluginDb, PluginTxFn } from "./kernel/database/plugin-types.js";
|
|
130
|
-
export type { ServiceRegistry } from "./kernel/service-registry.js";
|
|
131
|
-
export { defineModule } from "./kernel/module/index.js";
|
|
132
|
-
export type { AppModule, ModuleDeps, ServiceMap } from "./kernel/module/index.js";
|
|
133
|
-
export { toHttpError, type HttpErrorResponse } from "./kernel/http-error.js";
|
|
134
120
|
export { withTiming } from "./kernel/service-timing.js";
|
|
135
121
|
|
|
136
122
|
export {
|
|
@@ -139,6 +125,7 @@ export {
|
|
|
139
125
|
CommerceForbiddenError,
|
|
140
126
|
CommerceUnauthorizedError,
|
|
141
127
|
CommerceReauthRequiredError,
|
|
128
|
+
CommerceTwoFactorRequiredError,
|
|
142
129
|
CommerceConflictError,
|
|
143
130
|
CommerceInvalidTransitionError,
|
|
144
131
|
OrgResolutionError,
|
|
@@ -213,6 +200,8 @@ export type {
|
|
|
213
200
|
SearchSuggestParams,
|
|
214
201
|
} from "./modules/search/adapter.js";
|
|
215
202
|
export type { DatabaseAdapter } from "./kernel/database/adapter.js";
|
|
203
|
+
export { normalizeExecuteShape } from "./kernel/database/adapter.js";
|
|
204
|
+
export { createPGliteTransaction, type PGliteExec } from "./kernel/database/pglite-transaction.js";
|
|
216
205
|
export { isValidFieldPath, validateFieldPath } from "./modules/catalog/ownership.js";
|
|
217
206
|
export type { FieldPath, FieldOwner } from "./modules/catalog/ownership.js";
|
|
218
207
|
export type {
|
|
@@ -240,7 +229,6 @@ export type {
|
|
|
240
229
|
} from "./kernel/database/tx-context.js";
|
|
241
230
|
export {
|
|
242
231
|
createTxContext,
|
|
243
|
-
reuseOrCreateTxContext,
|
|
244
232
|
withTransaction,
|
|
245
233
|
isWriteContextTransactional,
|
|
246
234
|
resolveWriteContextHookContext,
|
|
@@ -258,11 +246,13 @@ export type {
|
|
|
258
246
|
export {
|
|
259
247
|
getSchema,
|
|
260
248
|
buildSchema,
|
|
261
|
-
getTableNames,
|
|
262
249
|
getSchemaFiles,
|
|
263
250
|
pushSchema,
|
|
264
251
|
} from "./kernel/database/migrate.js";
|
|
265
252
|
export { consoleEmailAdapter } from "./adapters/console-email.js";
|
|
253
|
+
export { renderEmail, type EmailData, type EmailTemplateMap, type RenderEmailOptions } from "./adapters/email-render.js";
|
|
254
|
+
export { escapeHtml } from "./utils/escape-html.js";
|
|
255
|
+
export { currencyExponent, formatAmount, toMinorUnits } from "./utils/money.js";
|
|
266
256
|
|
|
267
257
|
export { promotionTypeEnum, type PromotionType } from "./modules/promotions/schemas.js";
|
|
268
258
|
|
|
@@ -278,28 +268,11 @@ export type {
|
|
|
278
268
|
Step,
|
|
279
269
|
} from "./kernel/compensation/types.js";
|
|
280
270
|
|
|
281
|
-
export { createRepository } from "./kernel/factory/repository-factory.js";
|
|
282
|
-
export type {
|
|
283
|
-
BaseRepository,
|
|
284
|
-
SoftDeletableRepository,
|
|
285
|
-
RepositoryFor,
|
|
286
|
-
Filters,
|
|
287
|
-
FindOptions,
|
|
288
|
-
} from "./kernel/factory/repository-factory.js";
|
|
289
271
|
|
|
290
272
|
export type { CartItemMatcher } from "./modules/cart/matcher.js";
|
|
291
273
|
export { defaultCartItemMatcher } from "./modules/cart/matcher.js";
|
|
292
|
-
export { canAccessCart } from "./modules/cart/access.js";
|
|
293
274
|
|
|
294
|
-
export { QueryRegistry } from "./kernel/query/registry.js";
|
|
295
|
-
export { executeQuery } from "./kernel/query/executor.js";
|
|
296
|
-
export type {
|
|
297
|
-
RelationDefinition,
|
|
298
|
-
EntityDefinition,
|
|
299
|
-
} from "./kernel/query/registry.js";
|
|
300
|
-
export type { QueryInput, QueryResult } from "./kernel/query/executor.js";
|
|
301
275
|
|
|
302
|
-
export type { CommerceModuleTypes } from "./types/commerce-types.js";
|
|
303
276
|
|
|
304
277
|
export { staleOrderCleanupTask } from "./modules/orders/stale-order-cleanup.js";
|
|
305
278
|
export {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
import { createRoute, z } from "@hono/zod-openapi";
|
|
30
30
|
import { ErrorSchema } from "./schemas/shared.js";
|
|
31
|
-
import {
|
|
31
|
+
import { errorBody, mapErrorToStatus, markRoutePermissionGuard } from "./utils.js";
|
|
32
32
|
import type { CommerceConfig } from "../../config/types.js";
|
|
33
33
|
import type { PluginRouteRegistration } from "../../kernel/plugin/manifest.js";
|
|
34
34
|
import { createScopedDb } from "../../kernel/database/scoped-db.js";
|
|
@@ -302,11 +302,11 @@ class RouteChain {
|
|
|
302
302
|
} catch (error: unknown) {
|
|
303
303
|
try {
|
|
304
304
|
return ctx.json(
|
|
305
|
-
|
|
305
|
+
errorBody(error),
|
|
306
306
|
mapErrorToStatus(error) as number,
|
|
307
307
|
);
|
|
308
308
|
} catch {
|
|
309
|
-
// Fallback if
|
|
309
|
+
// Fallback if errorBody/mapErrorToStatus themselves throw
|
|
310
310
|
return ctx.json(
|
|
311
311
|
{ error: { code: "INTERNAL_ERROR", message: "An unexpected error occurred." } },
|
|
312
312
|
500,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
listCompensationFailuresRoute,
|
|
10
10
|
resolveCompensationFailureRoute,
|
|
11
11
|
} from "../../schemas/compensation-failures.js";
|
|
12
|
-
import { type AppEnv,
|
|
12
|
+
import { type AppEnv, errorBody, mapErrorToStatus, requirePerm } from "../../utils.js";
|
|
13
13
|
|
|
14
14
|
function toIso(d: Date | null | undefined): string | null {
|
|
15
15
|
if (d == null) return null;
|
|
@@ -78,7 +78,7 @@ export function compensationFailureAdminRoutes(kernel: Kernel) {
|
|
|
78
78
|
const resolvedParsed = parseResolvedFilter(c.req.query("resolved"));
|
|
79
79
|
if (!resolvedParsed.ok) {
|
|
80
80
|
return c.json(
|
|
81
|
-
|
|
81
|
+
errorBody(
|
|
82
82
|
new CommerceValidationError(
|
|
83
83
|
'Query "resolved" must be true, false, or all.',
|
|
84
84
|
),
|
|
@@ -105,7 +105,7 @@ export function compensationFailureAdminRoutes(kernel: Kernel) {
|
|
|
105
105
|
: {}),
|
|
106
106
|
});
|
|
107
107
|
if (!listed.ok) {
|
|
108
|
-
return c.json(
|
|
108
|
+
return c.json(errorBody(listed.error), mapErrorToStatus(listed.error));
|
|
109
109
|
}
|
|
110
110
|
return c.json({
|
|
111
111
|
items: listed.value.items.map(digestFailure),
|
|
@@ -125,7 +125,7 @@ export function compensationFailureAdminRoutes(kernel: Kernel) {
|
|
|
125
125
|
|
|
126
126
|
const found = await kernel.services.compensationFailures.findById(id);
|
|
127
127
|
if (!found.ok) {
|
|
128
|
-
return c.json(
|
|
128
|
+
return c.json(errorBody(found.error), mapErrorToStatus(found.error));
|
|
129
129
|
}
|
|
130
130
|
const row = found.value;
|
|
131
131
|
if (!row) {
|
|
@@ -154,7 +154,7 @@ export function compensationFailureAdminRoutes(kernel: Kernel) {
|
|
|
154
154
|
...(body.notes !== undefined ? { notes: body.notes } : {}),
|
|
155
155
|
});
|
|
156
156
|
if (!resolved.ok) {
|
|
157
|
-
return c.json(
|
|
157
|
+
return c.json(errorBody(resolved.error), mapErrorToStatus(resolved.error));
|
|
158
158
|
}
|
|
159
159
|
return c.json({ failure: digestFailure(resolved.value) });
|
|
160
160
|
});
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "../../schemas/admin-entity-field-definitions.js";
|
|
13
13
|
import {
|
|
14
14
|
type AppEnv,
|
|
15
|
-
|
|
15
|
+
errorBody,
|
|
16
16
|
mapErrorToStatus,
|
|
17
17
|
requirePerm,
|
|
18
18
|
} from "../../utils.js";
|
|
@@ -35,7 +35,7 @@ export function adminEntityFieldDefinitionRoutes(kernel: Kernel) {
|
|
|
35
35
|
);
|
|
36
36
|
if (!result.ok)
|
|
37
37
|
return c.json(
|
|
38
|
-
|
|
38
|
+
errorBody(result.error),
|
|
39
39
|
mapErrorToStatus(result.error),
|
|
40
40
|
);
|
|
41
41
|
return c.json({ data: result.value }, 201);
|
|
@@ -50,7 +50,7 @@ export function adminEntityFieldDefinitionRoutes(kernel: Kernel) {
|
|
|
50
50
|
);
|
|
51
51
|
if (!result.ok)
|
|
52
52
|
return c.json(
|
|
53
|
-
|
|
53
|
+
errorBody(result.error),
|
|
54
54
|
mapErrorToStatus(result.error),
|
|
55
55
|
);
|
|
56
56
|
return c.json({ data: result.value });
|
|
@@ -65,7 +65,7 @@ export function adminEntityFieldDefinitionRoutes(kernel: Kernel) {
|
|
|
65
65
|
);
|
|
66
66
|
if (!result.ok)
|
|
67
67
|
return c.json(
|
|
68
|
-
|
|
68
|
+
errorBody(result.error),
|
|
69
69
|
mapErrorToStatus(result.error),
|
|
70
70
|
);
|
|
71
71
|
return c.json({ data: result.value });
|
|
@@ -79,7 +79,7 @@ export function adminEntityFieldDefinitionRoutes(kernel: Kernel) {
|
|
|
79
79
|
);
|
|
80
80
|
if (!result.ok)
|
|
81
81
|
return c.json(
|
|
82
|
-
|
|
82
|
+
errorBody(result.error),
|
|
83
83
|
mapErrorToStatus(result.error),
|
|
84
84
|
);
|
|
85
85
|
return c.json({ data: result.value });
|
|
@@ -5,7 +5,6 @@ import type { CommerceConfig } from "../../../../config/types.js";
|
|
|
5
5
|
import type { DrizzleDatabase } from "../../../../kernel/database/drizzle-db.js";
|
|
6
6
|
import { member, user, invitation } from "../../../../auth/auth-schema.js";
|
|
7
7
|
import { resolveOrgIdForCommerce } from "../../../../auth/org.js";
|
|
8
|
-
import { makeId } from "../../../../utils/id.js";
|
|
9
8
|
import {
|
|
10
9
|
listStaffRoute,
|
|
11
10
|
createStaffRoute,
|
|
@@ -200,7 +199,7 @@ export function adminStaffRoutes(kernel: Kernel) {
|
|
|
200
199
|
const rows = await db
|
|
201
200
|
.insert(member)
|
|
202
201
|
.values({
|
|
203
|
-
id:
|
|
202
|
+
id: crypto.randomUUID(),
|
|
204
203
|
organizationId: orgId,
|
|
205
204
|
userId: body.userId,
|
|
206
205
|
role: body.role,
|
|
@@ -221,7 +220,7 @@ export function adminStaffRoutes(kernel: Kernel) {
|
|
|
221
220
|
const rows = await db
|
|
222
221
|
.insert(invitation)
|
|
223
222
|
.values({
|
|
224
|
-
id:
|
|
223
|
+
id: crypto.randomUUID(),
|
|
225
224
|
organizationId: orgId,
|
|
226
225
|
email: body.email,
|
|
227
226
|
role: body.role,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
2
|
import type { Kernel } from "../../../runtime/kernel.js";
|
|
3
3
|
import { getReportRoute, listReportsRoute } from "../schemas/analytics.js";
|
|
4
|
-
import { type AppEnv,
|
|
4
|
+
import { type AppEnv, errorBody, mapErrorToStatus, requirePerm } from "../utils.js";
|
|
5
5
|
|
|
6
6
|
export function analyticsRoutes(kernel: Kernel) {
|
|
7
7
|
const router = new OpenAPIHono<AppEnv>();
|
|
@@ -25,7 +25,7 @@ export function analyticsRoutes(kernel: Kernel) {
|
|
|
25
25
|
},
|
|
26
26
|
c.get("actor"),
|
|
27
27
|
);
|
|
28
|
-
if (!result.ok) return c.json(
|
|
28
|
+
if (!result.ok) return c.json(errorBody(result.error), mapErrorToStatus(result.error));
|
|
29
29
|
return c.json({ data: result.value });
|
|
30
30
|
});
|
|
31
31
|
|