@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
|
@@ -6,31 +6,12 @@ export declare function isHookMarkedInTransaction(handler: unknown): boolean;
|
|
|
6
6
|
export declare class HookRegistry {
|
|
7
7
|
private registry;
|
|
8
8
|
private inTransactionHandlers;
|
|
9
|
-
private logger?;
|
|
10
9
|
registerConfigHooks(hookName: string, handlers: HookHandler[]): void;
|
|
11
10
|
append(hookName: string, handler: HookHandler): void;
|
|
12
11
|
appendInTransaction(hookName: string, handler: HookHandler): void;
|
|
13
12
|
prepend(hookName: string, handler: HookHandler): void;
|
|
14
|
-
prependInTransaction(hookName: string, handler: HookHandler): void;
|
|
15
13
|
runsInTransaction(handler: HookHandler): boolean;
|
|
16
14
|
resolve(hookName: string): HookHandler[];
|
|
17
|
-
/**
|
|
18
|
-
* Emit a plugin event to all registered listeners.
|
|
19
|
-
*
|
|
20
|
-
* Unlike the before/after hook pattern (which transforms data through
|
|
21
|
-
* a pipeline), emit is fire-and-forget notification. Errors in handlers
|
|
22
|
-
* are caught and logged but do not propagate to the emitter.
|
|
23
|
-
*
|
|
24
|
-
* Usage:
|
|
25
|
-
* kernel.hooks.emit("production.afterComplete", { orderId, quantity });
|
|
26
|
-
*
|
|
27
|
-
* Any plugin can listen:
|
|
28
|
-
* hooks: () => [{ key: "production.afterComplete", handler: async (payload) => { ... } }]
|
|
29
|
-
*/
|
|
30
|
-
setLogger(logger: {
|
|
31
|
-
error: (obj: Record<string, unknown>, msg: string) => void;
|
|
32
|
-
}): void;
|
|
33
|
-
emit(key: string, payload: unknown): Promise<void>;
|
|
34
15
|
private ensureEntry;
|
|
35
16
|
}
|
|
36
17
|
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/kernel/hooks/registry.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC;AAgBxD,uGAAuG;AACvG,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAE5D;AAED,iGAAiG;AACjG,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAEnE;AAQD,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAgC;IAChD,OAAO,CAAC,qBAAqB,CAA8B;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/kernel/hooks/registry.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC;AAgBxD,uGAAuG;AACvG,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAE5D;AAED,iGAAiG;AACjG,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAEnE;AAQD,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAgC;IAChD,OAAO,CAAC,qBAAqB,CAA8B;IAE3D,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI;IAKpE,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI;IAKpD,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI;IAKjE,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI;IAKrD,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO;IAIhD,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,EAAE;IAMxC,OAAO,CAAC,WAAW;CASpB"}
|
|
@@ -23,7 +23,6 @@ export function isHookMarkedInTransaction(handler) {
|
|
|
23
23
|
export class HookRegistry {
|
|
24
24
|
registry = new Map();
|
|
25
25
|
inTransactionHandlers = new WeakSet();
|
|
26
|
-
logger;
|
|
27
26
|
registerConfigHooks(hookName, handlers) {
|
|
28
27
|
this.ensureEntry(hookName);
|
|
29
28
|
this.registry.get(hookName).configured = [...handlers];
|
|
@@ -40,10 +39,6 @@ export class HookRegistry {
|
|
|
40
39
|
this.ensureEntry(hookName);
|
|
41
40
|
this.registry.get(hookName).prepended.push(handler);
|
|
42
41
|
}
|
|
43
|
-
prependInTransaction(hookName, handler) {
|
|
44
|
-
this.inTransactionHandlers.add(handler);
|
|
45
|
-
this.prepend(hookName, handler);
|
|
46
|
-
}
|
|
47
42
|
runsInTransaction(handler) {
|
|
48
43
|
return this.inTransactionHandlers.has(handler);
|
|
49
44
|
}
|
|
@@ -53,33 +48,6 @@ export class HookRegistry {
|
|
|
53
48
|
return [];
|
|
54
49
|
return [...entry.prepended, ...entry.configured, ...entry.appended];
|
|
55
50
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Emit a plugin event to all registered listeners.
|
|
58
|
-
*
|
|
59
|
-
* Unlike the before/after hook pattern (which transforms data through
|
|
60
|
-
* a pipeline), emit is fire-and-forget notification. Errors in handlers
|
|
61
|
-
* are caught and logged but do not propagate to the emitter.
|
|
62
|
-
*
|
|
63
|
-
* Usage:
|
|
64
|
-
* kernel.hooks.emit("production.afterComplete", { orderId, quantity });
|
|
65
|
-
*
|
|
66
|
-
* Any plugin can listen:
|
|
67
|
-
* hooks: () => [{ key: "production.afterComplete", handler: async (payload) => { ... } }]
|
|
68
|
-
*/
|
|
69
|
-
setLogger(logger) {
|
|
70
|
-
this.logger = logger;
|
|
71
|
-
}
|
|
72
|
-
async emit(key, payload) {
|
|
73
|
-
const handlers = this.resolve(key);
|
|
74
|
-
for (const handler of handlers) {
|
|
75
|
-
try {
|
|
76
|
-
await handler(payload);
|
|
77
|
-
}
|
|
78
|
-
catch (err) {
|
|
79
|
-
this.logger?.error({ err, hookKey: key }, `Event handler failed for "${key}"`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
51
|
ensureEntry(hookName) {
|
|
84
52
|
if (!this.registry.has(hookName)) {
|
|
85
53
|
this.registry.set(hookName, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drizzle-adapter.d.ts","sourceRoot":"","sources":["../../../src/kernel/jobs/drizzle-adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,cAAc,EACf,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"drizzle-adapter.d.ts","sourceRoot":"","sources":["../../../src/kernel/jobs/drizzle-adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,cAAc,EACf,MAAM,cAAc,CAAC;AAWtB;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,eAAe;IA4CtD,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,KAAK;IA5Cf,OAAO,CAAC,KAAK,CAAmC;IAChD,OAAO,CAAC,oBAAoB,CAAK;IAEjC,QAAQ,CAAC,SAAS;;wBAEK,cAAc;;;;MAmCnC;gBAGQ,EAAE,EAAE,eAAe,EACnB,KAAK,GAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAa;IAGxD,QAAQ,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI;IAKrC,OAAO,CACX,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,MAAM,CAAC;IAqCZ,MAAM,CACV,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;QAAE,MAAM,EAAE,iBAAiB,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAezD;;wDAEoD;IAC9C,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ3C"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { eq, and } from "drizzle-orm";
|
|
2
|
-
import {
|
|
2
|
+
import { CommerceNotFoundError } from "../errors.js";
|
|
3
3
|
import { commerceJobs } from "./schema.js";
|
|
4
|
+
import { prepareEnqueue } from "./prepare-enqueue.js";
|
|
4
5
|
import { runPendingJobs } from "./runner.js";
|
|
5
6
|
import { getJobReapThresholdMs, getJobsReaperIntervalMs, runStaleJobReaper, } from "./reaper.js";
|
|
6
7
|
/**
|
|
@@ -53,21 +54,13 @@ export class DrizzleJobsAdapter {
|
|
|
53
54
|
this.tasks = new Map(setup.tasks);
|
|
54
55
|
}
|
|
55
56
|
async enqueue(taskSlug, input, options) {
|
|
56
|
-
const organizationId = options
|
|
57
|
-
if (!organizationId) {
|
|
58
|
-
throw new OrgResolutionError("Jobs enqueue requires a non-empty organizationId.");
|
|
59
|
-
}
|
|
60
|
-
const task = this.tasks.get(taskSlug);
|
|
61
|
-
const concurrencyKey = options.concurrencyKey ?? task?.concurrency?.key(input);
|
|
62
|
-
const supersedes = options.supersedes ?? task?.concurrency?.supersedes;
|
|
57
|
+
const { organizationId, concurrencyKey, supersedes, maxAttempts } = prepareEnqueue(this.tasks, taskSlug, input, options);
|
|
63
58
|
// If supersedes is set, delete existing pending jobs with the same concurrency key
|
|
64
59
|
if (concurrencyKey && supersedes) {
|
|
65
60
|
await this.db
|
|
66
61
|
.delete(commerceJobs)
|
|
67
62
|
.where(and(eq(commerceJobs.organizationId, organizationId), eq(commerceJobs.taskSlug, taskSlug), eq(commerceJobs.concurrencyKey, concurrencyKey), eq(commerceJobs.status, "pending")));
|
|
68
63
|
}
|
|
69
|
-
// Look up task definition for default retry config
|
|
70
|
-
const maxAttempts = options.maxAttempts ?? task?.retries?.attempts ?? 1;
|
|
71
64
|
const rows = await this.db
|
|
72
65
|
.insert(commerceJobs)
|
|
73
66
|
.values({
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EnqueueOptions } from "./adapter.js";
|
|
2
|
+
import type { TaskDefinition } from "./types.js";
|
|
3
|
+
export interface PreparedEnqueue {
|
|
4
|
+
task: TaskDefinition;
|
|
5
|
+
organizationId: string;
|
|
6
|
+
concurrencyKey: string | undefined;
|
|
7
|
+
/** At most one running job per concurrency key. */
|
|
8
|
+
exclusive: boolean;
|
|
9
|
+
/** A newer enqueue replaces a pending one with the same concurrency key. */
|
|
10
|
+
supersedes: boolean;
|
|
11
|
+
maxAttempts: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The validation and defaulting every execution engine applies before it hands
|
|
15
|
+
* a job to its backend: the task must be registered, the organization must be
|
|
16
|
+
* non-blank, and concurrency/retry settings come from the task unless the
|
|
17
|
+
* enqueue call overrides them.
|
|
18
|
+
*/
|
|
19
|
+
export declare function prepareEnqueue(tasks: ReadonlyMap<string, TaskDefinition>, taskSlug: string, input: Record<string, unknown>, options: EnqueueOptions): PreparedEnqueue;
|
|
20
|
+
//# sourceMappingURL=prepare-enqueue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare-enqueue.d.ts","sourceRoot":"","sources":["../../../src/kernel/jobs/prepare-enqueue.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,cAAc,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,mDAAmD;IACnD,SAAS,EAAE,OAAO,CAAC;IACnB,4EAA4E;IAC5E,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,EAC1C,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,EAAE,cAAc,GACtB,eAAe,CAejB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { OrgResolutionError } from "../errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* The validation and defaulting every execution engine applies before it hands
|
|
4
|
+
* a job to its backend: the task must be registered, the organization must be
|
|
5
|
+
* non-blank, and concurrency/retry settings come from the task unless the
|
|
6
|
+
* enqueue call overrides them.
|
|
7
|
+
*/
|
|
8
|
+
export function prepareEnqueue(tasks, taskSlug, input, options) {
|
|
9
|
+
const task = tasks.get(taskSlug);
|
|
10
|
+
if (!task)
|
|
11
|
+
throw new Error(`Unknown task slug: ${taskSlug}`);
|
|
12
|
+
const organizationId = options.organizationId.trim();
|
|
13
|
+
if (!organizationId) {
|
|
14
|
+
throw new OrgResolutionError("Jobs enqueue requires a non-empty organizationId.");
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
task,
|
|
18
|
+
organizationId,
|
|
19
|
+
concurrencyKey: options.concurrencyKey ?? task.concurrency?.key(input),
|
|
20
|
+
exclusive: Boolean(task.concurrency && task.concurrency.exclusive !== false),
|
|
21
|
+
supersedes: Boolean(options.supersedes ?? task.concurrency?.supersedes),
|
|
22
|
+
maxAttempts: options.maxAttempts ?? task.retries?.attempts ?? 1,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import type { Logger, ServiceContainer } from "../hooks/types.js";
|
|
2
2
|
import type { DrizzleDatabase } from "../database/drizzle-db.js";
|
|
3
|
-
export declare const BUILTIN_JOB_TASK_SLUGS: {
|
|
4
|
-
readonly webhookDeliver: "webhooks/deliver";
|
|
5
|
-
readonly staleJobReaper: "jobs/reap-stale";
|
|
6
|
-
};
|
|
7
3
|
export interface TaskContext {
|
|
8
4
|
logger: Logger;
|
|
9
5
|
db: DrizzleDatabase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/kernel/jobs/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/kernel/jobs/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,eAAe,CAAC;IACpB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B;;8FAE0F;IAC1F,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB;AAED,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wB,EAC9B,KAAK,EAAE,wBAAwB,KAC5B,MAAM,CAAC,CAAC;AAEjB,sFAAsF;AACtF,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc,CAC7B,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAEjE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,IAAI,EAAE;QACd,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,WAAW,CAAC;QACjB,GAAG,CAAC,EAAE,WAAW,CAAC;KACnB,KAAK,OAAO,CAAC;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B;;;;;4EAKwE;IACxE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE;QACZ,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;QAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,UAAU,CAAC,EAAE,OAAO,CAAC;KACtB,CAAC;CACH"}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
export const BUILTIN_JOB_TASK_SLUGS = {
|
|
2
|
-
webhookDeliver: "webhooks/deliver",
|
|
3
|
-
staleJobReaper: "jobs/reap-stale",
|
|
4
|
-
};
|
|
5
1
|
/** Thrown by a task handler (or a step's callback) to signal the failure must not be
|
|
6
2
|
* retried — the Cloudflare engine maps it to `NonRetryableError`; the drizzle runner
|
|
7
3
|
* fails the job immediately regardless of remaining attempts. */
|
|
@@ -67,38 +67,5 @@ export type CommerceLocalAPI<TServices extends Record<string, unknown> = Kernel[
|
|
|
67
67
|
* Every service method gets `actor` and `txCtx` auto-injected.
|
|
68
68
|
*/
|
|
69
69
|
export declare function createLocalAPI(kernel: Kernel, options?: LocalAPIOptions): CommerceLocalAPI;
|
|
70
|
-
/**
|
|
71
|
-
* @deprecated Use `createLocalAPI(kernel, { actor, tx })` instead.
|
|
72
|
-
* Kept for backward compatibility with existing hook code.
|
|
73
|
-
*/
|
|
74
|
-
export declare class LocalAPI {
|
|
75
|
-
private _proxy;
|
|
76
|
-
constructor(ctx: {
|
|
77
|
-
actor: Actor | null;
|
|
78
|
-
tx: unknown;
|
|
79
|
-
requestId: string;
|
|
80
|
-
}, kernel: Kernel);
|
|
81
|
-
get orders(): import("../modules/orders/service.js").OrderService;
|
|
82
|
-
get catalog(): import("../modules/catalog/service.js").CatalogServiceImpl;
|
|
83
|
-
get cart(): import("../modules/cart/service.js").CartService;
|
|
84
|
-
get inventory(): import("../modules/inventory/service.js").InventoryService;
|
|
85
|
-
get customers(): import("../modules/customers/service.js").CustomerService;
|
|
86
|
-
get pricing(): import("../modules/pricing/service.js").PricingService;
|
|
87
|
-
get promotions(): import("../modules/promotions/service.js").PromotionService;
|
|
88
|
-
get media(): import("../modules/media/service.js").MediaService;
|
|
89
|
-
get shipping(): import("../modules/shipping/service.js").ShippingService;
|
|
90
|
-
get search(): import("../modules/search/service.js").SearchService;
|
|
91
|
-
get webhooks(): import("../modules/webhooks/service.js").WebhookService & {
|
|
92
|
-
enqueueDelivery(payload: import("../runtime/kernel-types.js").WebhookDeliveryPayload): Promise<void>;
|
|
93
|
-
};
|
|
94
|
-
get fulfillment(): import("../modules/fulfillment/service.js").FulfillmentService;
|
|
95
|
-
get payments(): import("../modules/payments/service.js").PaymentsService;
|
|
96
|
-
get analytics(): import("../modules/analytics/service.js").AnalyticsService;
|
|
97
|
-
get tax(): import("../modules/tax/service.js").TaxService;
|
|
98
|
-
get audit(): import("../index.js").AuditService;
|
|
99
|
-
get organization(): import("../index.js").OrganizationService;
|
|
100
|
-
/** Resolve a service by name from `kernel.services`. */
|
|
101
|
-
service(name: string): unknown;
|
|
102
|
-
}
|
|
103
70
|
export {};
|
|
104
71
|
//# sourceMappingURL=local-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-api.d.ts","sourceRoot":"","sources":["../../src/kernel/local-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAIH,gDAAgD;AAChD,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,KAAK,YAAY,CAAC,CAAC,IAAI;KACpB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC,GACvD,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,GACzB,CAAC,CAAC,CAAC,CAAC;CACT,CAAC;AAEF,4EAA4E;AAC5E,MAAM,MAAM,gBAAgB,CAC1B,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,IAC5D;KACD,CAAC,IAAI,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChE,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAC1B,SAAS,CAAC,CAAC,CAAC;CACjB,CAAC;AAMF;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,eAAoB,GAC5B,gBAAgB,CAsDlB
|
|
1
|
+
{"version":3,"file":"local-api.d.ts","sourceRoot":"","sources":["../../src/kernel/local-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAIH,gDAAgD;AAChD,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,KAAK,YAAY,CAAC,CAAC,IAAI;KACpB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC,GACvD,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,GACzB,CAAC,CAAC,CAAC,CAAC;CACT,CAAC;AAEF,4EAA4E;AAC5E,MAAM,MAAM,gBAAgB,CAC1B,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,IAC5D;KACD,CAAC,IAAI,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChE,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAC1B,SAAS,CAAC,CAAC,CAAC;CACjB,CAAC;AAMF;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,eAAoB,GAC5B,gBAAgB,CAsDlB"}
|
package/dist/kernel/local-api.js
CHANGED
|
@@ -51,39 +51,3 @@ export function createLocalAPI(kernel, options = {}) {
|
|
|
51
51
|
},
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
// ─── Legacy Class API (backward compat) ─────────────────────────────────────
|
|
55
|
-
/**
|
|
56
|
-
* @deprecated Use `createLocalAPI(kernel, { actor, tx })` instead.
|
|
57
|
-
* Kept for backward compatibility with existing hook code.
|
|
58
|
-
*/
|
|
59
|
-
export class LocalAPI {
|
|
60
|
-
_proxy;
|
|
61
|
-
constructor(ctx, kernel) {
|
|
62
|
-
this._proxy = createLocalAPI(kernel, {
|
|
63
|
-
actor: ctx.actor,
|
|
64
|
-
tx: ctx.tx,
|
|
65
|
-
requestId: ctx.requestId,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
get orders() { return this._proxy.orders; }
|
|
69
|
-
get catalog() { return this._proxy.catalog; }
|
|
70
|
-
get cart() { return this._proxy.cart; }
|
|
71
|
-
get inventory() { return this._proxy.inventory; }
|
|
72
|
-
get customers() { return this._proxy.customers; }
|
|
73
|
-
get pricing() { return this._proxy.pricing; }
|
|
74
|
-
get promotions() { return this._proxy.promotions; }
|
|
75
|
-
get media() { return this._proxy.media; }
|
|
76
|
-
get shipping() { return this._proxy.shipping; }
|
|
77
|
-
get search() { return this._proxy.search; }
|
|
78
|
-
get webhooks() { return this._proxy.webhooks; }
|
|
79
|
-
get fulfillment() { return this._proxy.fulfillment; }
|
|
80
|
-
get payments() { return this._proxy.payments; }
|
|
81
|
-
get analytics() { return this._proxy.analytics; }
|
|
82
|
-
get tax() { return this._proxy.tax; }
|
|
83
|
-
get audit() { return this._proxy.audit; }
|
|
84
|
-
get organization() { return this._proxy.organization; }
|
|
85
|
-
/** Resolve a service by name from `kernel.services`. */
|
|
86
|
-
service(name) {
|
|
87
|
-
return this._proxy[name];
|
|
88
|
-
}
|
|
89
|
-
}
|
|
@@ -3,11 +3,9 @@ import type { PluginDb } from "../database/plugin-types.js";
|
|
|
3
3
|
import type { ConfigRouteKernel, Kernel } from "../../runtime/kernel.js";
|
|
4
4
|
import type { CommerceConfig, CommercePlugin, PluginPermission } from "../../config/types.js";
|
|
5
5
|
import type { TaskDefinition } from "../jobs/types.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
error(message: string, data?: unknown): void;
|
|
10
|
-
}
|
|
6
|
+
import type { Logger } from "../hooks/types.js";
|
|
7
|
+
/** The logger a plugin receives — the same shape every hook and job gets. */
|
|
8
|
+
export type PluginLogger = Logger;
|
|
11
9
|
/**
|
|
12
10
|
* Plugin route registration. Supports two modes:
|
|
13
11
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/kernel/plugin/manifest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAS5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/kernel/plugin/manifest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAS5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,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@ export declare class AnalyticsService {
|
|
|
35
35
|
* Scope is REQUIRED — use buildAnalyticsScope(actor) to construct it.
|
|
36
36
|
*/
|
|
37
37
|
query(params: AnalyticsQueryParams, scope: AnalyticsScope): Promise<Result<AnalyticsQueryResult>>;
|
|
38
|
-
getDashboard(name: string, scope: AnalyticsScope): Promise<Result<AnalyticsQueryResult>>;
|
|
39
38
|
/** The canned retail reports pack (issue #48). */
|
|
40
39
|
listReports(): Array<{
|
|
41
40
|
name: string;
|
|
@@ -44,11 +43,6 @@ export declare class AnalyticsService {
|
|
|
44
43
|
/** Runs a canned retail report (issue #48), org-scoped to the actor. */
|
|
45
44
|
getReport(name: string, params: ReportParams, actor?: Actor | null): Promise<Result<Record<string, unknown>>>;
|
|
46
45
|
getMeta(): Promise<Result<AnalyticsMeta>>;
|
|
47
|
-
meta(): Promise<Result<{
|
|
48
|
-
measures: string[];
|
|
49
|
-
dimensions: string[];
|
|
50
|
-
segments: string[];
|
|
51
|
-
}>>;
|
|
52
46
|
private tryRegisterModel;
|
|
53
47
|
private ensureCustomSchemaModelsLoaded;
|
|
54
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/modules/analytics/service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EAGb,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACf,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,wBAAwB,EACxB,a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,gBAAgB;IAKf,OAAO,CAAC,IAAI;IAJxB,OAAO,CAAC,YAAY,CAAkC;IACtD,OAAO,CAAC,kBAAkB,CAAkC;IAC5D,OAAO,CAAC,kBAAkB,CAAS;gBAEf,IAAI,EAAE,oBAAoB;IAE9C;;;;;;OAMG;IACH,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAiCnC;;;OAGG;IACG,KAAK,CAAC,MAAM,EAAE,oBAAoB,EAAE,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;IAKvG,kDAAkD;IAClD,WAAW,IAAI,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAI3D,wEAAwE;IAClE,SAAS,CACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,YAAY,EACpB,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,GACnB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAQrC,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAyB/C,OAAO,CAAC,gBAAgB;YA0CV,8BAA8B;CAkD7C"}
|
|
@@ -60,28 +60,6 @@ export class AnalyticsService {
|
|
|
60
60
|
async query(params, scope) {
|
|
61
61
|
return this.deps.adapter.query(params, scope);
|
|
62
62
|
}
|
|
63
|
-
async getDashboard(name, scope) {
|
|
64
|
-
const normalized = name.trim().toLowerCase();
|
|
65
|
-
if (normalized === "revenue" || normalized === "revenue-overview") {
|
|
66
|
-
return this.query({
|
|
67
|
-
measures: ["Orders.revenue", "Orders.count"],
|
|
68
|
-
timeDimensions: [{
|
|
69
|
-
dimension: "Orders.placedAt",
|
|
70
|
-
granularity: "month",
|
|
71
|
-
dateRange: "this month",
|
|
72
|
-
}],
|
|
73
|
-
order: { "Orders.placedAt": "asc" },
|
|
74
|
-
}, scope);
|
|
75
|
-
}
|
|
76
|
-
if (normalized === "inventory" || normalized === "inventory-health") {
|
|
77
|
-
return this.query({
|
|
78
|
-
measures: ["Inventory.totalAvailable", "Inventory.lowStockCount"],
|
|
79
|
-
dimensions: ["Inventory.warehouseId"],
|
|
80
|
-
order: { "Inventory.totalAvailable": "desc" },
|
|
81
|
-
}, scope);
|
|
82
|
-
}
|
|
83
|
-
return Err(new CommerceValidationError(`Unknown analytics dashboard: ${name}`));
|
|
84
|
-
}
|
|
85
63
|
/** The canned retail reports pack (issue #48). */
|
|
86
64
|
listReports() {
|
|
87
65
|
return RETAIL_REPORTS.map((r) => ({ name: r.name, description: r.description }));
|
|
@@ -113,16 +91,6 @@ export class AnalyticsService {
|
|
|
113
91
|
segments: allModels.flatMap((m) => m.segments ?? []),
|
|
114
92
|
});
|
|
115
93
|
}
|
|
116
|
-
async meta() {
|
|
117
|
-
const meta = await this.getMeta();
|
|
118
|
-
if (!meta.ok)
|
|
119
|
-
return meta;
|
|
120
|
-
return Ok({
|
|
121
|
-
measures: meta.value.measures,
|
|
122
|
-
dimensions: meta.value.dimensions,
|
|
123
|
-
segments: meta.value.segments,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
94
|
// ─── Private ─────────────────────────────────────────────────────────────
|
|
127
95
|
tryRegisterModel(name, raw) {
|
|
128
96
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/modules/cart/service.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/modules/cart/service.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAA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B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,GAAG,CAAC,EAAE,SAAS,GACd,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAYxB;;;;;;OAMG;IACG,oBAAoB,CACxB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,GAAG,CAAC,EAAE,SAAS,GACd,OAAO,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IAI/B;;;;OAIG;IACG,eAAe,CACnB,QAAQ,SAAQ,EAChB,GAAG,CAAC,EAAE,SAAS,GACd,OAAO,CAAC,MAAM,CAAC;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAsBlD;;;;OAIG;IACG,UAAU,CACd,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,KAAK,EACZ,GAAG,CAAC,EAAE,SAAS,GACd,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IA0CxB;;;;;OAKG;YACW,sBAAsB;IAmBpC;;;;;;;;;;OAUG;YACW,mBAAmB;IAuCjC;;;;;;;;OAQG;YACW,oBAAoB;CA0CnC"}
|
|
@@ -2,22 +2,10 @@ import { resolveOrgIdForCommerce } from "../../auth/org.js";
|
|
|
2
2
|
import { AUTHENTICATION_REQUIRED_MESSAGE, assertPermission, isUnauthenticatedActor, } from "../../auth/permissions.js";
|
|
3
3
|
import { CommerceForbiddenError, CommerceNotFoundError, CommerceUnauthorizedError, CommerceValidationError, toCommerceError, } from "../../kernel/errors.js";
|
|
4
4
|
import { runAfterHooks, runBeforeHooks } from "../../kernel/hooks/executor.js";
|
|
5
|
-
import {
|
|
5
|
+
import { createModuleHookContext } from "../../kernel/hooks/create-context.js";
|
|
6
6
|
import { Err, Ok } from "../../kernel/result.js";
|
|
7
|
-
import { createLogger } from "../../utils/logger.js";
|
|
8
7
|
import { paginate } from "../../utils/pagination.js";
|
|
9
8
|
import { defaultCartItemMatcher } from "./matcher.js";
|
|
10
|
-
function makeContext(actor, services, database, config, tx = null) {
|
|
11
|
-
return createHookContext({
|
|
12
|
-
actor,
|
|
13
|
-
tx,
|
|
14
|
-
logger: createLogger("cart"),
|
|
15
|
-
services,
|
|
16
|
-
context: { moduleName: "cart" },
|
|
17
|
-
database: { db: database.db },
|
|
18
|
-
commerceConfig: config,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
9
|
function isExpired(cart) {
|
|
22
10
|
return cart.expiresAt.getTime() < Date.now();
|
|
23
11
|
}
|
|
@@ -171,7 +159,7 @@ export class CartService {
|
|
|
171
159
|
},
|
|
172
160
|
]));
|
|
173
161
|
}
|
|
174
|
-
const context =
|
|
162
|
+
const context = createModuleHookContext("cart", this.deps, actor ?? null, ctx?.tx);
|
|
175
163
|
const beforeHooks = this.deps.hooks.resolve("cart.beforeAddItem");
|
|
176
164
|
const afterHooks = this.deps.hooks.resolve("cart.afterAddItem");
|
|
177
165
|
const processed = await runBeforeHooks(beforeHooks, input, "addItem", context);
|
|
@@ -267,7 +255,7 @@ export class CartService {
|
|
|
267
255
|
if (!existing || existing.cartId !== cartId) {
|
|
268
256
|
return Err(new CommerceNotFoundError("Cart item not found."));
|
|
269
257
|
}
|
|
270
|
-
const context =
|
|
258
|
+
const context = createModuleHookContext("cart", this.deps, actor ?? null, ctx?.tx);
|
|
271
259
|
const beforeHooks = this.deps.hooks.resolve("cart.beforeRemoveItem");
|
|
272
260
|
const afterHooks = this.deps.hooks.resolve("cart.afterRemoveItem");
|
|
273
261
|
await runBeforeHooks(beforeHooks, existing, "removeItem", context);
|
|
@@ -299,7 +287,7 @@ export class CartService {
|
|
|
299
287
|
if (input.quantity <= 0) {
|
|
300
288
|
return Err(new CommerceValidationError("Quantity must be greater than zero."));
|
|
301
289
|
}
|
|
302
|
-
const context =
|
|
290
|
+
const context = createModuleHookContext("cart", this.deps, actor ?? null, ctx?.tx);
|
|
303
291
|
const beforeHooks = this.deps.hooks.resolve("cart.beforeUpdateQuantity");
|
|
304
292
|
const afterHooks = this.deps.hooks.resolve("cart.afterUpdateQuantity");
|
|
305
293
|
await runBeforeHooks(beforeHooks, input, "update", context);
|
|
@@ -386,7 +374,7 @@ export class CartService {
|
|
|
386
374
|
const expiresAt = new Date(Date.now() + ttlMinutes * 60 * 1000);
|
|
387
375
|
const updated = await this.repo.update(cart.id, { status: "active", secret, expiresAt }, ctx);
|
|
388
376
|
const afterHooks = this.deps.hooks.resolve("cart.afterRecover");
|
|
389
|
-
await runAfterHooks(afterHooks, null, updated ?? cart, "recover",
|
|
377
|
+
await runAfterHooks(afterHooks, null, updated ?? cart, "recover", createModuleHookContext("cart", this.deps, actor ?? null, ctx?.tx ?? null));
|
|
390
378
|
return Ok({
|
|
391
379
|
cartId: cart.id,
|
|
392
380
|
secret,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-service.d.ts","sourceRoot":"","sources":["../../../src/modules/catalog/entity-service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAajD,OAAO,KAAK,EAGV,WAAW,EACZ,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"entity-service.d.ts","sourceRoot":"","sources":["../../../src/modules/catalog/entity-service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAajD,OAAO,KAAK,EAGV,WAAW,EACZ,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAI1F,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,E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1B,kBAAkB,CACtB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,EAClG,KAAK,EAAE,KAAK,GAAG,IAAI,EACnB,GAAG,CAAC,EAAE,SAAS,GACd,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAuCpD,kBAAkB,CACtB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE;QAAE,IAAI,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,EAAE,CAAA;SAAE,CAAC,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,EAC1F,KAAK,EAAE,KAAK,GAAG,IAAI,EACnB,GAAG,CAAC,EAAE,SAAS,GACd,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,EAAE,OAAO,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CA8C5D"}
|
|
@@ -2,27 +2,17 @@ import { resolveOrgIdForCommerce } from "../../auth/org.js";
|
|
|
2
2
|
import { assertPermission } from "../../auth/permissions.js";
|
|
3
3
|
import { CommerceConflictError, CommerceNotFoundError, CommerceValidationError, toCommerceError, } from "../../kernel/errors.js";
|
|
4
4
|
import { mergeHookReports, runAfterHooks, runBeforeHooks, } from "../../kernel/hooks/executor.js";
|
|
5
|
-
import {
|
|
5
|
+
import { createModuleHookContext } from "../../kernel/hooks/create-context.js";
|
|
6
6
|
import { Err, Ok } from "../../kernel/result.js";
|
|
7
|
-
import { createLogger } from "../../utils/logger.js";
|
|
8
7
|
import { paginate } from "../../utils/pagination.js";
|
|
9
8
|
import { createTxContext, isWriteContextTransactional } from "../../kernel/database/tx-context.js";
|
|
10
9
|
import { canReadUnpublishedCatalog, isCatalogEntityVisible } from "./read-policy.js";
|
|
11
10
|
import { isValidFieldPath } from "./ownership.js";
|
|
12
|
-
function hookDatabaseArg(database) {
|
|
13
|
-
return { database: { db: database.db } };
|
|
14
|
-
}
|
|
15
11
|
const attributeFields = ["title", "subtitle", "description", "richDescription", "seoTitle", "seoDescription"];
|
|
16
12
|
export function catalogHookContext(deps, actor, ctx, operation) {
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
logger: createLogger(`catalog.${operation}`),
|
|
21
|
-
services: deps.services,
|
|
22
|
-
...(deps.services.jobs ? { jobs: deps.services.jobs } : {}),
|
|
23
|
-
context: { moduleName: "catalog", ...(ctx?.hookContext ?? {}) },
|
|
24
|
-
...hookDatabaseArg(deps.database),
|
|
25
|
-
commerceConfig: deps.config,
|
|
13
|
+
return createModuleHookContext("catalog", deps, actor, isWriteContextTransactional(ctx) ? ctx.tx : null, {
|
|
14
|
+
logScope: `catalog.${operation}`,
|
|
15
|
+
...(ctx?.hookContext ? { context: ctx.hookContext } : {}),
|
|
26
16
|
});
|
|
27
17
|
}
|
|
28
18
|
function cartesian(arrays) {
|
|
@@ -289,6 +279,8 @@ export class EntityService {
|
|
|
289
279
|
await this.repo.deleteVariantOptionValuesByEntityId(id, ctx);
|
|
290
280
|
await this.repo.deleteVariantsByEntityId(id, ctx);
|
|
291
281
|
await this.repo.deleteEntity(id, ctx);
|
|
282
|
+
const afterHooks = this.deps.hooks.resolve("catalog.afterDelete");
|
|
283
|
+
await runAfterHooks(afterHooks, existing, existing, "delete", catalogHookContext(this.deps, actor, ctx, "delete"), (hook) => this.deps.hooks.runsInTransaction(hook));
|
|
292
284
|
return Ok(undefined);
|
|
293
285
|
}
|
|
294
286
|
catch (error) {
|
|
@@ -298,7 +290,7 @@ export class EntityService {
|
|
|
298
290
|
async getById(id, options, actor, ctx) {
|
|
299
291
|
const resolvedActor = actor ?? ctx?.actor ?? null;
|
|
300
292
|
const orgId = resolveOrgIdForCommerce(resolvedActor, this.deps.config);
|
|
301
|
-
const context =
|
|
293
|
+
const context = createModuleHookContext("catalog", this.deps, resolvedActor, ctx?.tx ?? null, { logScope: "catalog.read" });
|
|
302
294
|
const globalBeforeHooks = this.deps.hooks.resolve("catalog.beforeRead");
|
|
303
295
|
const globalAfterHooks = this.deps.hooks.resolve("catalog.afterRead");
|
|
304
296
|
let processed = await runBeforeHooks(globalBeforeHooks, { id, ...(options !== undefined ? { options } : {}) }, "read", context);
|
|
@@ -344,7 +336,7 @@ export class EntityService {
|
|
|
344
336
|
return Ok(await this.hydrateEntity(entity, options, ctx));
|
|
345
337
|
}
|
|
346
338
|
async getBySlug(slug, options, actor, ctx) {
|
|
347
|
-
const context =
|
|
339
|
+
const context = createModuleHookContext("catalog", this.deps, actor ?? null, ctx?.tx ?? null, { logScope: "catalog.read" });
|
|
348
340
|
const globalBeforeHooks = this.deps.hooks.resolve("catalog.beforeRead");
|
|
349
341
|
const globalAfterHooks = this.deps.hooks.resolve("catalog.afterRead");
|
|
350
342
|
let processed = await runBeforeHooks(globalBeforeHooks, { slug, ...(options !== undefined ? { options } : {}) }, "read", context);
|
|
@@ -385,7 +377,7 @@ export class EntityService {
|
|
|
385
377
|
}
|
|
386
378
|
async list(params, actor, ctx) {
|
|
387
379
|
const resolvedActor = actor ?? ctx?.actor ?? null;
|
|
388
|
-
const context =
|
|
380
|
+
const context = createModuleHookContext("catalog", this.deps, resolvedActor, ctx?.tx ?? null, { logScope: "catalog.list" });
|
|
389
381
|
const globalBeforeHooks = this.deps.hooks.resolve("catalog.beforeList");
|
|
390
382
|
const globalAfterHooks = this.deps.hooks.resolve("catalog.afterList");
|
|
391
383
|
let processed = await runBeforeHooks(globalBeforeHooks, params, "list", context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-service.d.ts","sourceRoot":"","sources":["../../../src/modules/catalog/import-service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAGjD,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAG9D,OAAO,EAAgF,KAAK,mBAAmB,EAAkB,MAAM,qCAAqC,CAAC;AAK7K,OAAO,EAYL,KAAK,4BAA4B,EAElC,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"import-service.d.ts","sourceRoot":"","sources":["../../../src/modules/catalog/import-service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAGjD,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAG9D,OAAO,EAAgF,KAAK,mBAAmB,EAAkB,MAAM,qCAAqC,CAAC;AAK7K,OAAO,EAYL,KAAK,4BAA4B,EAElC,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAIvD;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,oBAAoB;IACnC,6FAA6F;IAC7F,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,mBAAmB;IAClC,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