@porulle/core 0.64.0 → 0.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/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 +5 -6
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
2
|
import { createTaxRateRoute, listTaxRatesRoute, updateTaxRateRoute, deleteTaxRateRoute, createTaxClassRoute, listTaxClassesRoute, updateTaxClassRoute, deleteTaxClassRoute, } from "../schemas/tax.js";
|
|
3
|
-
import {
|
|
3
|
+
import { errorBody, mapErrorToStatus, requirePerm } from "../utils.js";
|
|
4
4
|
export function taxRoutes(kernel) {
|
|
5
5
|
const router = new OpenAPIHono();
|
|
6
6
|
router.use("/rates", requirePerm("tax:manage"));
|
|
@@ -11,28 +11,28 @@ export function taxRoutes(kernel) {
|
|
|
11
11
|
router.openapi(createTaxRateRoute, async (c) => {
|
|
12
12
|
const result = await kernel.services.tax.createTaxRate(c.req.valid("json"), c.get("actor"));
|
|
13
13
|
if (!result.ok)
|
|
14
|
-
return c.json(
|
|
14
|
+
return c.json(errorBody(result.error), mapErrorToStatus(result.error));
|
|
15
15
|
return c.json({ data: result.value }, 201);
|
|
16
16
|
});
|
|
17
17
|
// @ts-expect-error -- openapi handler union return type
|
|
18
18
|
router.openapi(listTaxRatesRoute, async (c) => {
|
|
19
19
|
const result = await kernel.services.tax.listTaxRates(c.get("actor"));
|
|
20
20
|
if (!result.ok)
|
|
21
|
-
return c.json(
|
|
21
|
+
return c.json(errorBody(result.error), mapErrorToStatus(result.error));
|
|
22
22
|
return c.json({ data: result.value });
|
|
23
23
|
});
|
|
24
24
|
// @ts-expect-error -- openapi handler union return type
|
|
25
25
|
router.openapi(updateTaxRateRoute, async (c) => {
|
|
26
26
|
const result = await kernel.services.tax.updateTaxRate(c.req.param("id"), c.req.valid("json"), c.get("actor"));
|
|
27
27
|
if (!result.ok)
|
|
28
|
-
return c.json(
|
|
28
|
+
return c.json(errorBody(result.error), mapErrorToStatus(result.error));
|
|
29
29
|
return c.json({ data: result.value });
|
|
30
30
|
});
|
|
31
31
|
// @ts-expect-error -- openapi handler union return type
|
|
32
32
|
router.openapi(deleteTaxRateRoute, async (c) => {
|
|
33
33
|
const result = await kernel.services.tax.deleteTaxRate(c.req.param("id"), c.get("actor"));
|
|
34
34
|
if (!result.ok)
|
|
35
|
-
return c.json(
|
|
35
|
+
return c.json(errorBody(result.error), mapErrorToStatus(result.error));
|
|
36
36
|
return c.json({ data: result.value });
|
|
37
37
|
});
|
|
38
38
|
// ── Product tax classes (issue #57) ───────────────────────────────
|
|
@@ -40,28 +40,28 @@ export function taxRoutes(kernel) {
|
|
|
40
40
|
router.openapi(createTaxClassRoute, async (c) => {
|
|
41
41
|
const result = await kernel.services.tax.createTaxClass(c.req.valid("json"), c.get("actor"));
|
|
42
42
|
if (!result.ok)
|
|
43
|
-
return c.json(
|
|
43
|
+
return c.json(errorBody(result.error), mapErrorToStatus(result.error));
|
|
44
44
|
return c.json({ data: result.value }, 201);
|
|
45
45
|
});
|
|
46
46
|
// @ts-expect-error -- openapi handler union return type
|
|
47
47
|
router.openapi(listTaxClassesRoute, async (c) => {
|
|
48
48
|
const result = await kernel.services.tax.listTaxClasses(c.get("actor"));
|
|
49
49
|
if (!result.ok)
|
|
50
|
-
return c.json(
|
|
50
|
+
return c.json(errorBody(result.error), mapErrorToStatus(result.error));
|
|
51
51
|
return c.json({ data: result.value });
|
|
52
52
|
});
|
|
53
53
|
// @ts-expect-error -- openapi handler union return type
|
|
54
54
|
router.openapi(updateTaxClassRoute, async (c) => {
|
|
55
55
|
const result = await kernel.services.tax.updateTaxClass(c.req.param("id"), c.req.valid("json"), c.get("actor"));
|
|
56
56
|
if (!result.ok)
|
|
57
|
-
return c.json(
|
|
57
|
+
return c.json(errorBody(result.error), mapErrorToStatus(result.error));
|
|
58
58
|
return c.json({ data: result.value });
|
|
59
59
|
});
|
|
60
60
|
// @ts-expect-error -- openapi handler union return type
|
|
61
61
|
router.openapi(deleteTaxClassRoute, async (c) => {
|
|
62
62
|
const result = await kernel.services.tax.deleteTaxClass(c.req.param("id"), c.get("actor"));
|
|
63
63
|
if (!result.ok)
|
|
64
|
-
return c.json(
|
|
64
|
+
return c.json(errorBody(result.error), mapErrorToStatus(result.error));
|
|
65
65
|
return c.json({ data: result.value });
|
|
66
66
|
});
|
|
67
67
|
return router;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/rest/routes/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/rest/routes/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,KAAK,MAAM,EAA4C,MAAM,aAAa,CAAC;AAEpF,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,gCA2C3C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
2
|
import { createWebhookEndpointRoute, listWebhookEndpointsRoute, deleteWebhookEndpointRoute } from "../schemas/webhooks.js";
|
|
3
|
-
import {
|
|
3
|
+
import { errorBody, mapErrorToStatus, requirePerm } from "../utils.js";
|
|
4
4
|
export function webhookRoutes(kernel) {
|
|
5
5
|
const router = new OpenAPIHono();
|
|
6
6
|
router.use("/*", requirePerm("webhooks:manage"));
|
|
@@ -14,7 +14,7 @@ export function webhookRoutes(kernel) {
|
|
|
14
14
|
const actor = c.get("actor");
|
|
15
15
|
const result = await kernel.services.webhooks.createEndpoint(body, actor);
|
|
16
16
|
if (!result.ok) {
|
|
17
|
-
return c.json(
|
|
17
|
+
return c.json(errorBody(result.error), mapErrorToStatus(result.error));
|
|
18
18
|
}
|
|
19
19
|
return c.json({ data: result.value }, 201);
|
|
20
20
|
});
|
|
@@ -22,7 +22,7 @@ export function webhookRoutes(kernel) {
|
|
|
22
22
|
router.openapi(listWebhookEndpointsRoute, async (c) => {
|
|
23
23
|
const result = await kernel.services.webhooks.listEndpoints(c.get("actor"));
|
|
24
24
|
if (!result.ok) {
|
|
25
|
-
return c.json(
|
|
25
|
+
return c.json(errorBody(result.error), mapErrorToStatus(result.error));
|
|
26
26
|
}
|
|
27
27
|
const sanitized = result.value.map(({ secret: _secret, ...rest }) => rest);
|
|
28
28
|
return c.json({ data: sanitized });
|
|
@@ -31,7 +31,7 @@ export function webhookRoutes(kernel) {
|
|
|
31
31
|
router.openapi(deleteWebhookEndpointRoute, async (c) => {
|
|
32
32
|
const result = await kernel.services.webhooks.deleteEndpoint(c.req.param("id"), c.get("actor"));
|
|
33
33
|
if (!result.ok) {
|
|
34
|
-
return c.json(
|
|
34
|
+
return c.json(errorBody(result.error), mapErrorToStatus(result.error));
|
|
35
35
|
}
|
|
36
36
|
return c.json({ data: { deleted: true } });
|
|
37
37
|
});
|
|
@@ -32,7 +32,7 @@ export declare function parseInclude(value?: string): Set<string>;
|
|
|
32
32
|
* Map an error to a safe client response. Internal errors are sanitized
|
|
33
33
|
* to prevent leaking SQL, schema, or stack trace details.
|
|
34
34
|
*/
|
|
35
|
-
export declare function
|
|
35
|
+
export declare function errorBody(error: unknown): {
|
|
36
36
|
error: {
|
|
37
37
|
code: string;
|
|
38
38
|
message: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/interfaces/rest/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/interfaces/rest/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAOjD,eAAO,MAAM,sBAAsB,eAAyC,CAAC;AAM7E,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,CAAC,CAKtF;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,CAAC,CAE7E;AAED,KAAK,iBAAiB,GAAG;IACvB,GAAG,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,aAAa,CAAC,GAAG,IAAI,CAAC;IACzE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7C,GAAG,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CACzB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,SAAS,EAAE;QACT,KAAK,EAAE,KAA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,CASZ;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE7C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mapErrorToStatus } from "../../kernel/error-mapper.js";
|
|
2
2
|
import { toCommerceError } from "../../kernel/errors.js";
|
|
3
|
-
import { AUTHENTICATION_REQUIRED_MESSAGE, isUnauthenticatedActor, } from "../../auth/permissions.js";
|
|
3
|
+
import { AUTHENTICATION_REQUIRED_MESSAGE, isUnauthenticatedActor, hasPermissionFromList, } from "../../auth/permissions.js";
|
|
4
4
|
export const ROUTE_PERMISSION_GUARD = Symbol("porulle.routePermissionGuard");
|
|
5
5
|
export function markRoutePermissionGuard(handler, methods) {
|
|
6
6
|
if (typeof handler === "function") {
|
|
@@ -32,7 +32,7 @@ export function parseInclude(value) {
|
|
|
32
32
|
* Map an error to a safe client response. Internal errors are sanitized
|
|
33
33
|
* to prevent leaking SQL, schema, or stack trace details.
|
|
34
34
|
*/
|
|
35
|
-
export function
|
|
35
|
+
export function errorBody(error) {
|
|
36
36
|
const ce = toCommerceError(error);
|
|
37
37
|
if (ce.code === "INTERNAL_ERROR") {
|
|
38
38
|
// Sanitize internal errors -- do not expose raw messages to clients
|
|
@@ -49,14 +49,7 @@ export { mapErrorToStatus };
|
|
|
49
49
|
export function requirePerm(permission) {
|
|
50
50
|
const middleware = async (c, next) => {
|
|
51
51
|
const actor = c.get("actor");
|
|
52
|
-
|
|
53
|
-
if (perms.includes(permission) || perms.includes("*:*")) {
|
|
54
|
-
await next();
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
// Check resource-level wildcard (e.g., "catalog:*" matches "catalog:create")
|
|
58
|
-
const [resource] = permission.split(":");
|
|
59
|
-
if (resource && perms.includes(`${resource}:*`)) {
|
|
52
|
+
if (hasPermissionFromList(actor?.permissions ?? [], permission)) {
|
|
60
53
|
await next();
|
|
61
54
|
return;
|
|
62
55
|
}
|
|
@@ -71,9 +64,7 @@ export function requireAnyPerm(permissions) {
|
|
|
71
64
|
const middleware = async (c, next) => {
|
|
72
65
|
const actor = c.get("actor");
|
|
73
66
|
const granted = actor?.permissions ?? [];
|
|
74
|
-
const allowed = permissions.some((permission) => granted
|
|
75
|
-
granted.includes("*:*") ||
|
|
76
|
-
granted.includes(`${permission.split(":")[0]}:*`));
|
|
67
|
+
const allowed = permissions.some((permission) => hasPermissionFromList(granted, permission));
|
|
77
68
|
if (allowed) {
|
|
78
69
|
await next();
|
|
79
70
|
return;
|
package/dist/jobs.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type { JobInstanceStatus, TaskContext, TaskDefinition, TaskJobMeta, TaskRetryConfig, TaskStep, } from "./kernel/jobs/types.js";
|
|
2
2
|
export { TaskNonRetryableError } from "./kernel/jobs/types.js";
|
|
3
3
|
export { createPassThroughTaskStep } from "./kernel/jobs/step.js";
|
|
4
|
+
export { prepareEnqueue, type PreparedEnqueue } from "./kernel/jobs/prepare-enqueue.js";
|
|
4
5
|
export type { EnqueueOptions, ExecutionEngine, ExecutionEngineSetup, JobsAdapter, } from "./kernel/jobs/adapter.js";
|
|
5
6
|
//# sourceMappingURL=jobs.d.ts.map
|
package/dist/jobs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs.d.ts","sourceRoot":"","sources":["../src/jobs.ts"],"names":[],"mappings":"AAEA,YAAY,EACV,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,WAAW,EACX,eAAe,EACf,QAAQ,GACT,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,YAAY,EACV,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,WAAW,GACZ,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"jobs.d.ts","sourceRoot":"","sources":["../src/jobs.ts"],"names":[],"mappings":"AAEA,YAAY,EACV,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,WAAW,EACX,eAAe,EACf,QAAQ,GACT,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACxF,YAAY,EACV,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,WAAW,GACZ,MAAM,0BAA0B,CAAC"}
|
package/dist/jobs.js
CHANGED
|
@@ -28,5 +28,14 @@ export interface DatabaseConnectionFactoryInput {
|
|
|
28
28
|
* drizzle-kit (`pushSchema`/introspection), which needs the native result shape.
|
|
29
29
|
*/
|
|
30
30
|
export declare function unwrapDb<T>(db: T): T;
|
|
31
|
+
/**
|
|
32
|
+
* Normalize `db.execute()` so it returns a row array regardless of the
|
|
33
|
+
* underlying driver. postgres-js returns the rows directly, while neon-http
|
|
34
|
+
* and node-postgres (and PGlite) return `{ rows, command, rowCount }`.
|
|
35
|
+
* Without this, raw-SQL code that destructures the result as an array breaks
|
|
36
|
+
* on the `{ rows }` drivers. We intercept only `execute`; every other method
|
|
37
|
+
* is bound to the real driver instance so its internals are untouched.
|
|
38
|
+
*/
|
|
39
|
+
export declare function normalizeExecuteShape<T extends object>(db: T): T;
|
|
31
40
|
export declare function createDatabaseConnection(input: DatabaseConnectionFactoryInput): DatabaseAdapter;
|
|
32
41
|
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/kernel/database/adapter.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe,CAAC,SAAS,GAAG,OAAO,EAAE,YAAY,GAAG,OAAO;IAC1E,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,SAAS,CAAC;IACd,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACjE;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,eAAe,CAAC;CAC1B;AASD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAMpC;
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/kernel/database/adapter.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe,CAAC,SAAS,GAAG,OAAO,EAAE,YAAY,GAAG,OAAO;IAC1E,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,SAAS,CAAC;IACd,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACjE;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,eAAe,CAAC;CAC1B;AASD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAMpC;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CA4ChE;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,8BAA8B,GAAG,eAAe,CAY/F"}
|
|
@@ -26,7 +26,7 @@ export function unwrapDb(db) {
|
|
|
26
26
|
* on the `{ rows }` drivers. We intercept only `execute`; every other method
|
|
27
27
|
* is bound to the real driver instance so its internals are untouched.
|
|
28
28
|
*/
|
|
29
|
-
function normalizeExecuteShape(db) {
|
|
29
|
+
export function normalizeExecuteShape(db) {
|
|
30
30
|
return new Proxy(db, {
|
|
31
31
|
get(target, prop, receiver) {
|
|
32
32
|
if (prop === RAW_DB)
|
|
@@ -31,10 +31,6 @@ export declare function getSchema(): typeof schema;
|
|
|
31
31
|
* Throws if a plugin table name collides with a core table name.
|
|
32
32
|
*/
|
|
33
33
|
export declare function buildSchema(config?: CommerceConfig): Record<string, unknown>;
|
|
34
|
-
/**
|
|
35
|
-
* Returns a list of all schema table names defined by the commerce engine.
|
|
36
|
-
*/
|
|
37
|
-
export declare function getTableNames(): string[];
|
|
38
34
|
/**
|
|
39
35
|
* Returns the absolute filesystem path(s) of the combined schema module for
|
|
40
36
|
* use as drizzle-kit's `schema` option in a consumer's `drizzle.config.ts`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../src/kernel/database/migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC;;;GAGG;AACH,wBAAgB,SAAS,kBAExB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAwB5E;
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../src/kernel/database/migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC;;;GAGG;AACH,wBAAgB,SAAS,kBAExB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAwB5E;AAGD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,MAAM,EAAE,CAKzC;AAED;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAC9B,eAAe,EAAE,OAAO,EACxB,MAAM,CAAC,EAAE,cAAc,GACtB,OAAO,CAAC,IAAI,CAAC,CAmBf"}
|
|
@@ -52,16 +52,6 @@ export function buildSchema(config) {
|
|
|
52
52
|
}
|
|
53
53
|
return merged;
|
|
54
54
|
}
|
|
55
|
-
/**
|
|
56
|
-
* Returns a list of all schema table names defined by the commerce engine.
|
|
57
|
-
*/
|
|
58
|
-
export function getTableNames() {
|
|
59
|
-
return Object.entries(schema)
|
|
60
|
-
.filter(([_, value]) => value != null &&
|
|
61
|
-
typeof value === "object" &&
|
|
62
|
-
"getSQL" in value)
|
|
63
|
-
.map(([key]) => key);
|
|
64
|
-
}
|
|
65
55
|
/**
|
|
66
56
|
* Returns the absolute filesystem path(s) of the combined schema module for
|
|
67
57
|
* use as drizzle-kit's `schema` option in a consumer's `drizzle.config.ts`.
|
|
@@ -95,10 +85,8 @@ export async function pushSchema(drizzleInstance, config) {
|
|
|
95
85
|
catch {
|
|
96
86
|
throw new Error("pushSchema() requires `drizzle-kit` to be installed. Add it to your project: bun add -d drizzle-kit");
|
|
97
87
|
}
|
|
98
|
-
//
|
|
99
|
-
// tables are created too; without one, push core only (backward compatible).
|
|
100
|
-
const schemaToApply = config ? buildSchema(config) : getSchema();
|
|
88
|
+
// Core plus any plugin-declared tables in `config.customSchemas`.
|
|
101
89
|
// drizzle-kit needs the native driver result shape; unwrap a normalized db.
|
|
102
|
-
const { apply } = await drizzleKit.pushSchema(
|
|
90
|
+
const { apply } = await drizzleKit.pushSchema(buildSchema(config), unwrapDb(drizzleInstance));
|
|
103
91
|
await apply();
|
|
104
92
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** The one PGlite capability a transaction needs: run a statement on the connection. */
|
|
2
|
+
export interface PGliteExec {
|
|
3
|
+
exec(statement: string): Promise<unknown>;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* `DatabaseAdapter.transaction` for a PGlite instance.
|
|
7
|
+
*
|
|
8
|
+
* Drizzle's own `transaction()` can hang on PGlite, so this drives
|
|
9
|
+
* BEGIN/COMMIT/ROLLBACK directly and hands the body the same `db` handle.
|
|
10
|
+
*
|
|
11
|
+
* PGlite is a single connection, so two bodies awaiting concurrently would
|
|
12
|
+
* otherwise interleave their statements between one BEGIN and one COMMIT —
|
|
13
|
+
* the second BEGIN is a no-op Postgres only warns about — and share a snapshot,
|
|
14
|
+
* each other's row locks and each other's rollback. Bodies are queued instead,
|
|
15
|
+
* which is what a connection pool does to two transactions competing for the
|
|
16
|
+
* same rows.
|
|
17
|
+
*
|
|
18
|
+
* Only a call made from INSIDE a running body joins it (without savepoints that
|
|
19
|
+
* is the only sound reading of a nested call). "Inside" is decided by the async
|
|
20
|
+
* context the call runs in, never by whether some transaction happens to be
|
|
21
|
+
* open: an unrelated request that arrives mid-body queues behind it.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createPGliteTransaction(pg: PGliteExec, db: unknown): {
|
|
24
|
+
transaction<T>(fn: (tx: unknown) => Promise<T>): Promise<T>;
|
|
25
|
+
/** Whether a transaction body is executing right now. */
|
|
26
|
+
inTransaction(): boolean;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=pglite-transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pglite-transaction.d.ts","sourceRoot":"","sources":["../../../src/kernel/database/pglite-transaction.ts"],"names":[],"mappings":"AAEA,wFAAwF;AACxF,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,OAAO,GAAG;IACpE,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5D,yDAAyD;IACzD,aAAa,IAAI,OAAO,CAAC;CAC1B,CA+BA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
/**
|
|
3
|
+
* `DatabaseAdapter.transaction` for a PGlite instance.
|
|
4
|
+
*
|
|
5
|
+
* Drizzle's own `transaction()` can hang on PGlite, so this drives
|
|
6
|
+
* BEGIN/COMMIT/ROLLBACK directly and hands the body the same `db` handle.
|
|
7
|
+
*
|
|
8
|
+
* PGlite is a single connection, so two bodies awaiting concurrently would
|
|
9
|
+
* otherwise interleave their statements between one BEGIN and one COMMIT —
|
|
10
|
+
* the second BEGIN is a no-op Postgres only warns about — and share a snapshot,
|
|
11
|
+
* each other's row locks and each other's rollback. Bodies are queued instead,
|
|
12
|
+
* which is what a connection pool does to two transactions competing for the
|
|
13
|
+
* same rows.
|
|
14
|
+
*
|
|
15
|
+
* Only a call made from INSIDE a running body joins it (without savepoints that
|
|
16
|
+
* is the only sound reading of a nested call). "Inside" is decided by the async
|
|
17
|
+
* context the call runs in, never by whether some transaction happens to be
|
|
18
|
+
* open: an unrelated request that arrives mid-body queues behind it.
|
|
19
|
+
*/
|
|
20
|
+
export function createPGliteTransaction(pg, db) {
|
|
21
|
+
// Each transaction gets its own token; a call joins only when it runs inside
|
|
22
|
+
// the body of the transaction that is open right now (work a body started
|
|
23
|
+
// but did not await may outlive it, and must not join a closed transaction).
|
|
24
|
+
const body = new AsyncLocalStorage();
|
|
25
|
+
let queue = Promise.resolve();
|
|
26
|
+
let current = null;
|
|
27
|
+
async function transaction(fn) {
|
|
28
|
+
const caller = body.getStore();
|
|
29
|
+
if (caller !== undefined && caller === current)
|
|
30
|
+
return fn(db);
|
|
31
|
+
const run = queue.then(async () => {
|
|
32
|
+
await pg.exec("BEGIN");
|
|
33
|
+
const token = {};
|
|
34
|
+
current = token;
|
|
35
|
+
try {
|
|
36
|
+
const result = await body.run(token, () => fn(db));
|
|
37
|
+
await pg.exec("COMMIT");
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
await pg.exec("ROLLBACK");
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
current = null;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
queue = run.catch(() => undefined);
|
|
49
|
+
return run;
|
|
50
|
+
}
|
|
51
|
+
return { transaction, inTransaction: () => current !== null };
|
|
52
|
+
}
|
|
@@ -17,7 +17,6 @@ export interface WithTransactionOptions {
|
|
|
17
17
|
}
|
|
18
18
|
export declare function createTxContext<TTx>(tx: TTx, options: WithTransactionOptions): TxContext<TTx>;
|
|
19
19
|
export declare function withTransaction<TDb, TTx, TResult>(database: DatabaseAdapter<TDb, TTx>, options: WithTransactionOptions, fn: (ctx: TxContext<TTx>) => Promise<TResult>): Promise<TResult>;
|
|
20
|
-
export declare function reuseOrCreateTxContext<TTx>(tx: TTx, options: WithTransactionOptions, existing?: TxContext<TTx> | null): TxContext<TTx>;
|
|
21
20
|
export declare function resolveWriteContextHookContext(ctx?: CatalogWriteContext): Record<string, unknown> | undefined;
|
|
22
21
|
export declare function isWriteContextTransactional<TTx>(ctx?: CatalogWriteContext<TTx>): ctx is TxContext<TTx>;
|
|
23
22
|
//# sourceMappingURL=tx-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx-context.d.ts","sourceRoot":"","sources":["../../../src/kernel/database/tx-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,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12,21 +12,9 @@ export async function withTransaction(database, options, fn) {
|
|
|
12
12
|
return fn(createTxContext(tx, options));
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
export function reuseOrCreateTxContext(tx, options, existing) {
|
|
16
|
-
if (existing) {
|
|
17
|
-
return existing;
|
|
18
|
-
}
|
|
19
|
-
return createTxContext(tx, options);
|
|
20
|
-
}
|
|
21
|
-
function hookContextFromWriteContext(ctx) {
|
|
22
|
-
return ctx?.hookContext;
|
|
23
|
-
}
|
|
24
|
-
function isTransactionalWriteContext(ctx) {
|
|
25
|
-
return "tx" in ctx && ctx.tx != null;
|
|
26
|
-
}
|
|
27
15
|
export function resolveWriteContextHookContext(ctx) {
|
|
28
|
-
return
|
|
16
|
+
return ctx?.hookContext;
|
|
29
17
|
}
|
|
30
18
|
export function isWriteContextTransactional(ctx) {
|
|
31
|
-
return ctx != null &&
|
|
19
|
+
return ctx != null && "tx" in ctx && ctx.tx != null;
|
|
32
20
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unique-violation.d.ts","sourceRoot":"","sources":["../../../src/kernel/database/unique-violation.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAKzD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Whether a database error (or any error it wraps) is a Postgres unique violation (23505). */
|
|
2
|
+
export function isUniqueViolation(error) {
|
|
3
|
+
if (error == null || typeof error !== "object")
|
|
4
|
+
return false;
|
|
5
|
+
const value = error;
|
|
6
|
+
if (value.code === "23505")
|
|
7
|
+
return true;
|
|
8
|
+
return isUniqueViolation(value.cause);
|
|
9
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-mapper.d.ts","sourceRoot":"","sources":["../../src/kernel/error-mapper.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"error-mapper.d.ts","sourceRoot":"","sources":["../../src/kernel/error-mapper.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAkBnD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,CAGrE;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE;QAAE,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IACnD,MAAM,EAAE,oBAAoB,CAAC;CAC9B;AAaD,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,OAAO,EACf,MAAM,CAAC,EAAE,MAAM,GACd,YAAY,CA8Ed"}
|
package/dist/kernel/errors.d.ts
CHANGED
|
@@ -42,6 +42,18 @@ export declare class CommerceReauthRequiredError extends Error implements Commer
|
|
|
42
42
|
code: "REAUTH_REQUIRED";
|
|
43
43
|
constructor(message: string, details?: unknown | undefined);
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Raised for a signed-in member whose role is listed in
|
|
47
|
+
* `auth.twoFactor.requiredForRoles` but who has not enabled two-factor
|
|
48
|
+
* authentication. The client discriminates on `code === "TWO_FACTOR_REQUIRED"`
|
|
49
|
+
* to send the member to enrolment (`/api/auth/two-factor/enable`) rather than
|
|
50
|
+
* treating it as a plain refusal.
|
|
51
|
+
*/
|
|
52
|
+
export declare class CommerceTwoFactorRequiredError extends Error implements CommerceError {
|
|
53
|
+
details?: unknown | undefined;
|
|
54
|
+
code: "TWO_FACTOR_REQUIRED";
|
|
55
|
+
constructor(message: string, details?: unknown | undefined);
|
|
56
|
+
}
|
|
45
57
|
export declare class CommerceForbiddenError extends Error implements CommerceError {
|
|
46
58
|
details?: unknown | undefined;
|
|
47
59
|
code: "FORBIDDEN";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/kernel/errors.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,qBAAsB,SAAQ,KAAM,YAAW,aAAa;IAI9D,OAAO,CAAC,EAAE,OAAO;IAH1B,IAAI,EAAG,WAAW,CAAU;gBAE1B,OAAO,EAAE,MAAM,EACR,OAAO,CAAC,EAAE,OAAO,YAAA;CAK3B;AAED,qBAAa,uBAAwB,SAAQ,KAAM,YAAW,aAAa;IAIhE,WAAW,CAAC,EAAE,UAAU,EAAE;IAC1B,OAAO,CAAC,EAAE,OAAO;IAJ1B,IAAI,EAAG,mBAAmB,CAAU;gBAElC,OAAO,EAAE,MAAM,EACR,WAAW,CAAC,EAAE,UAAU,EAAE,YAAA,EAC1B,OAAO,CAAC,EAAE,OAAO,YAAA;CAK3B;AAED;mEACmE;AACnE,eAAO,MAAM,kCAAkC,+CACD,CAAC;AAE/C;;;qBAGqB;AACrB,qBAAa,oCAAqC,SAAQ,KAAM,YAAW,aAAa;IAI7E,OAAO,CAAC,EAAE,OAAO;IAH1B,IAAI,EAAG,4BAA4B,CAAU;gBAE3C,OAAO,GAAE,MAA2C,EAC7C,OAAO,CAAC,EAAE,OAAO,YAAA;CAK3B;AAED;;;;;;GAMG;AACH,qBAAa,2BAA4B,SAAQ,KAAM,YAAW,aAAa;IAIpE,OAAO,CAAC,EAAE,OAAO;IAH1B,IAAI,EAAG,iBAAiB,CAAU;gBAEhC,O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A;CAK3B;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAGtE;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAgB7D"}
|
package/dist/kernel/errors.js
CHANGED
|
@@ -50,6 +50,22 @@ export class CommerceReauthRequiredError extends Error {
|
|
|
50
50
|
this.name = "CommerceReauthRequiredError";
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Raised for a signed-in member whose role is listed in
|
|
55
|
+
* `auth.twoFactor.requiredForRoles` but who has not enabled two-factor
|
|
56
|
+
* authentication. The client discriminates on `code === "TWO_FACTOR_REQUIRED"`
|
|
57
|
+
* to send the member to enrolment (`/api/auth/two-factor/enable`) rather than
|
|
58
|
+
* treating it as a plain refusal.
|
|
59
|
+
*/
|
|
60
|
+
export class CommerceTwoFactorRequiredError extends Error {
|
|
61
|
+
details;
|
|
62
|
+
code = "TWO_FACTOR_REQUIRED";
|
|
63
|
+
constructor(message, details) {
|
|
64
|
+
super(message);
|
|
65
|
+
this.details = details;
|
|
66
|
+
this.name = "CommerceTwoFactorRequiredError";
|
|
67
|
+
}
|
|
68
|
+
}
|
|
53
69
|
export class CommerceForbiddenError extends Error {
|
|
54
70
|
details;
|
|
55
71
|
code = "FORBIDDEN";
|
|
@@ -13,22 +13,31 @@ export interface CreateHookContextArgs {
|
|
|
13
13
|
origin?: HookOrigin;
|
|
14
14
|
jobs?: JobsAdapter;
|
|
15
15
|
db?: PluginDb;
|
|
16
|
-
/** Prefer this over {@link CreateHookContextArgs.kernel}. */
|
|
17
16
|
database?: {
|
|
18
17
|
db: PluginDb;
|
|
19
18
|
};
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Pass {@link CreateHookContextArgs.database} or {@link CreateHookContextArgs.db} instead.
|
|
22
|
-
*/
|
|
23
|
-
kernel?: {
|
|
24
|
-
database: {
|
|
25
|
-
db: PluginDb;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
19
|
commerceConfig?: CommerceConfig | null;
|
|
29
20
|
}
|
|
30
21
|
/**
|
|
31
22
|
* Creates a HookContext with sensible defaults.
|
|
32
23
|
*/
|
|
33
24
|
export declare function createHookContext(args: CreateHookContextArgs): HookContext;
|
|
25
|
+
/** What a core module service already holds that its hook context is built from. */
|
|
26
|
+
export interface ModuleHookDeps {
|
|
27
|
+
services: ServiceContainer;
|
|
28
|
+
database: {
|
|
29
|
+
db: unknown;
|
|
30
|
+
};
|
|
31
|
+
config: CommerceConfig;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The hook context a core module hands its hooks. Every module builds it the
|
|
35
|
+
* same way — its name as `context.moduleName` (which webhook event names are
|
|
36
|
+
* derived from), a logger scoped to it, the kernel's services (and through them
|
|
37
|
+
* the jobs engine), the database and the config — so none can leave a field out.
|
|
38
|
+
*/
|
|
39
|
+
export declare function createModuleHookContext(moduleName: string, deps: ModuleHookDeps, actor: Actor | null, tx?: unknown, options?: {
|
|
40
|
+
logScope?: string;
|
|
41
|
+
context?: Record<string, unknown>;
|
|
42
|
+
}): HookContext;
|
|
34
43
|
//# sourceMappingURL=create-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-context.d.ts","sourceRoot":"","sources":["../../../src/kernel/hooks/create-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"create-context.d.ts","sourceRoot":"","sources":["../../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AI,EACnB,EAAE,GAAE,OAAc,EAClB,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAO,GACrE,WAAW,CAUb"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { NullJobsAdapter } from "../jobs/adapter.js";
|
|
3
|
+
import { createConsoleLogger } from "../../utils/logger.js";
|
|
3
4
|
const nullJobs = new NullJobsAdapter();
|
|
4
5
|
/**
|
|
5
6
|
* Creates a HookContext with sensible defaults.
|
|
6
7
|
*/
|
|
7
8
|
export function createHookContext(args) {
|
|
8
|
-
const db = args.db ?? args.database?.db ??
|
|
9
|
+
const db = args.db ?? args.database?.db ?? null;
|
|
9
10
|
if (db == null) {
|
|
10
|
-
throw new Error("createHookContext requires a database: pass `db
|
|
11
|
+
throw new Error("createHookContext requires a database: pass `db` or `database: { db }`.");
|
|
11
12
|
}
|
|
12
13
|
return {
|
|
13
14
|
actor: args.actor,
|
|
@@ -17,8 +18,28 @@ export function createHookContext(args) {
|
|
|
17
18
|
context: args.context ?? {},
|
|
18
19
|
requestId: args.requestId ?? randomUUID(),
|
|
19
20
|
origin: args.origin ?? "rest",
|
|
20
|
-
|
|
21
|
+
// The kernel installs its engine as `services.jobs` before any module is
|
|
22
|
+
// built, so a context that names no engine still enqueues for real. The
|
|
23
|
+
// null adapter is for a context with no kernel behind it at all.
|
|
24
|
+
jobs: args.jobs ?? args.services.jobs ?? nullJobs,
|
|
21
25
|
db,
|
|
22
26
|
...(args.commerceConfig !== undefined ? { commerceConfig: args.commerceConfig } : {}),
|
|
23
27
|
};
|
|
24
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* The hook context a core module hands its hooks. Every module builds it the
|
|
31
|
+
* same way — its name as `context.moduleName` (which webhook event names are
|
|
32
|
+
* derived from), a logger scoped to it, the kernel's services (and through them
|
|
33
|
+
* the jobs engine), the database and the config — so none can leave a field out.
|
|
34
|
+
*/
|
|
35
|
+
export function createModuleHookContext(moduleName, deps, actor, tx = null, options = {}) {
|
|
36
|
+
return createHookContext({
|
|
37
|
+
actor,
|
|
38
|
+
tx,
|
|
39
|
+
logger: createConsoleLogger(options.logScope ?? moduleName),
|
|
40
|
+
services: deps.services,
|
|
41
|
+
context: { moduleName, ...options.context },
|
|
42
|
+
database: { db: deps.database.db },
|
|
43
|
+
commerceConfig: deps.config,
|
|
44
|
+
});
|
|
45
|
+
}
|