@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,99 +0,0 @@
|
|
|
1
|
-
import type { AppModule } from "./define.js";
|
|
2
|
-
|
|
3
|
-
export class ModuleCycleError extends Error {
|
|
4
|
-
readonly cycle: string[];
|
|
5
|
-
|
|
6
|
-
constructor(cycle: string[]) {
|
|
7
|
-
const label = cycle.join(" → ");
|
|
8
|
-
super(`Module dependency cycle: ${label}`);
|
|
9
|
-
this.name = "ModuleCycleError";
|
|
10
|
-
this.cycle = cycle;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function topoSortModules(modules: Record<string, AppModule>): string[] {
|
|
15
|
-
const keys = Object.keys(modules);
|
|
16
|
-
const keySet = new Set(keys);
|
|
17
|
-
|
|
18
|
-
for (const [id, mod] of Object.entries(modules)) {
|
|
19
|
-
for (const dep of mod.dependencies ?? []) {
|
|
20
|
-
const depKey = dep as string;
|
|
21
|
-
if (!keySet.has(depKey)) {
|
|
22
|
-
throw new Error(`Module "${id}" declares unknown dependency "${depKey}"`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const remaining = new Map<string, Set<string>>();
|
|
28
|
-
for (const k of keys) {
|
|
29
|
-
const mod = modules[k]!;
|
|
30
|
-
remaining.set(k, new Set((mod.dependencies ?? []) as string[]));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const waitingOn = new Map<string, string[]>();
|
|
34
|
-
for (const m of keys) {
|
|
35
|
-
const mod = modules[m]!;
|
|
36
|
-
for (const d of (mod.dependencies ?? []) as string[]) {
|
|
37
|
-
const list = waitingOn.get(d);
|
|
38
|
-
if (list) list.push(m);
|
|
39
|
-
else waitingOn.set(d, [m]);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const order: string[] = [];
|
|
44
|
-
const queue = keys.filter((k) => remaining.get(k)!.size === 0);
|
|
45
|
-
|
|
46
|
-
while (queue.length > 0) {
|
|
47
|
-
const n = queue.shift()!;
|
|
48
|
-
order.push(n);
|
|
49
|
-
for (const m of waitingOn.get(n) ?? []) {
|
|
50
|
-
const set = remaining.get(m)!;
|
|
51
|
-
if (set.delete(n) && set.size === 0) {
|
|
52
|
-
queue.push(m);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (order.length !== keys.length) {
|
|
58
|
-
const cycle = findCycleKeys(modules, keys);
|
|
59
|
-
throw new ModuleCycleError(cycle);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return order;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function findCycleKeys(modules: Record<string, AppModule>, keys: string[]): string[] {
|
|
66
|
-
const WHITE = 0;
|
|
67
|
-
const GRAY = 1;
|
|
68
|
-
const BLACK = 2;
|
|
69
|
-
const mark = new Map<string, number>();
|
|
70
|
-
const stack: string[] = [];
|
|
71
|
-
|
|
72
|
-
function dfs(u: string): string[] | null {
|
|
73
|
-
mark.set(u, GRAY);
|
|
74
|
-
stack.push(u);
|
|
75
|
-
const mod = modules[u]!;
|
|
76
|
-
for (const v of (mod.dependencies ?? []) as string[]) {
|
|
77
|
-
const mv = mark.get(v) ?? WHITE;
|
|
78
|
-
if (mv === WHITE) {
|
|
79
|
-
const found = dfs(v);
|
|
80
|
-
if (found) return found;
|
|
81
|
-
} else if (mv === GRAY) {
|
|
82
|
-
const idx = stack.indexOf(v);
|
|
83
|
-
return [...stack.slice(idx), v];
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
stack.pop();
|
|
87
|
-
mark.set(u, BLACK);
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
for (const k of keys) {
|
|
92
|
-
if ((mark.get(k) ?? WHITE) === WHITE) {
|
|
93
|
-
const found = dfs(k);
|
|
94
|
-
if (found) return found;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
throw new Error("topoSortModules: expected a cycle but DFS did not find one");
|
|
99
|
-
}
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { CommerceNotFoundError } from "../errors.js";
|
|
2
|
-
import type {
|
|
3
|
-
QueryRegistry,
|
|
4
|
-
EntityDefinition,
|
|
5
|
-
RelationDefinition,
|
|
6
|
-
} from "./registry.js";
|
|
7
|
-
|
|
8
|
-
export interface QueryInput {
|
|
9
|
-
entity: string;
|
|
10
|
-
id?: string;
|
|
11
|
-
filters?: Record<string, unknown>;
|
|
12
|
-
include?: string[];
|
|
13
|
-
pagination?: { limit?: number; offset?: number };
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface QueryResult<T = Record<string, unknown>> {
|
|
17
|
-
data: T[];
|
|
18
|
-
total?: number | undefined;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Executes a query against the registry, resolving includes via
|
|
23
|
-
* batched dataloader-style fetches (one WHERE IN per relation).
|
|
24
|
-
*/
|
|
25
|
-
export async function executeQuery<T = Record<string, unknown>>(
|
|
26
|
-
registry: QueryRegistry,
|
|
27
|
-
services: Record<string, unknown>,
|
|
28
|
-
input: QueryInput,
|
|
29
|
-
): Promise<QueryResult<T>> {
|
|
30
|
-
const definition = registry.get(input.entity);
|
|
31
|
-
if (!definition) {
|
|
32
|
-
throw new CommerceNotFoundError(
|
|
33
|
-
`No entity registered with name "${input.entity}".`,
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const service = services[definition.service] as Record<
|
|
38
|
-
string,
|
|
39
|
-
(...args: unknown[]) => Promise<unknown>
|
|
40
|
-
>;
|
|
41
|
-
|
|
42
|
-
// 1. Fetch primary records
|
|
43
|
-
let rows: Record<string, unknown>[];
|
|
44
|
-
let total: number | undefined;
|
|
45
|
-
|
|
46
|
-
if (input.id) {
|
|
47
|
-
const result = (await service[definition.getByIdMethod]!(
|
|
48
|
-
input.id,
|
|
49
|
-
)) as { ok?: boolean; value?: unknown };
|
|
50
|
-
const value = result?.value ?? result;
|
|
51
|
-
rows = value != null ? [value as Record<string, unknown>] : [];
|
|
52
|
-
} else {
|
|
53
|
-
const result = (await service[definition.listMethod]!(
|
|
54
|
-
input.filters ?? {},
|
|
55
|
-
input.pagination,
|
|
56
|
-
)) as {
|
|
57
|
-
ok?: boolean;
|
|
58
|
-
value?: { items?: unknown[]; total?: number };
|
|
59
|
-
};
|
|
60
|
-
const resolved = result?.value ?? result;
|
|
61
|
-
if (resolved && typeof resolved === "object" && "items" in resolved) {
|
|
62
|
-
rows = (resolved.items ?? []) as Record<string, unknown>[];
|
|
63
|
-
total = resolved.total;
|
|
64
|
-
} else if (Array.isArray(resolved)) {
|
|
65
|
-
rows = resolved as Record<string, unknown>[];
|
|
66
|
-
} else {
|
|
67
|
-
rows = [];
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// 2. Resolve includes
|
|
72
|
-
if (input.include?.length) {
|
|
73
|
-
await resolveIncludes(rows, input.include, definition, services, registry);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return { data: rows as T[], total };
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
async function resolveIncludes(
|
|
80
|
-
rows: Record<string, unknown>[],
|
|
81
|
-
includes: string[],
|
|
82
|
-
definition: EntityDefinition,
|
|
83
|
-
services: Record<string, unknown>,
|
|
84
|
-
registry: QueryRegistry,
|
|
85
|
-
): Promise<void> {
|
|
86
|
-
// Group includes by top-level segment
|
|
87
|
-
const topLevel = new Map<string, string[]>();
|
|
88
|
-
for (const path of includes) {
|
|
89
|
-
const dot = path.indexOf(".");
|
|
90
|
-
if (dot === -1) {
|
|
91
|
-
if (!topLevel.has(path)) topLevel.set(path, []);
|
|
92
|
-
} else {
|
|
93
|
-
const parent = path.substring(0, dot);
|
|
94
|
-
const child = path.substring(dot + 1);
|
|
95
|
-
const existing = topLevel.get(parent) ?? [];
|
|
96
|
-
existing.push(child);
|
|
97
|
-
topLevel.set(parent, existing);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
for (const [relationName, nestedIncludes] of topLevel) {
|
|
102
|
-
const relation = definition.relations[relationName];
|
|
103
|
-
if (!relation) continue;
|
|
104
|
-
|
|
105
|
-
const targetService = services[relation.targetService] as
|
|
106
|
-
| Record<string, (...args: unknown[]) => Promise<unknown>>
|
|
107
|
-
| undefined;
|
|
108
|
-
if (!targetService) continue;
|
|
109
|
-
|
|
110
|
-
// Collect foreign key values (deduplicated)
|
|
111
|
-
const ids = [
|
|
112
|
-
...new Set(
|
|
113
|
-
rows
|
|
114
|
-
.map((r) => r[relation.foreignKey])
|
|
115
|
-
.filter((v): v is string => v != null && typeof v === "string"),
|
|
116
|
-
),
|
|
117
|
-
];
|
|
118
|
-
if (ids.length === 0) continue;
|
|
119
|
-
|
|
120
|
-
// One batched query
|
|
121
|
-
const batchFn = targetService[relation.batchMethod];
|
|
122
|
-
if (!batchFn) continue;
|
|
123
|
-
|
|
124
|
-
const relatedResult = await batchFn(ids);
|
|
125
|
-
const relatedRows = extractRows(relatedResult);
|
|
126
|
-
|
|
127
|
-
// Build lookup
|
|
128
|
-
const map = new Map<string, unknown>();
|
|
129
|
-
for (const related of relatedRows) {
|
|
130
|
-
const rec = related as Record<string, unknown>;
|
|
131
|
-
if (relation.isList) {
|
|
132
|
-
const key = rec[relation.foreignKey] as string;
|
|
133
|
-
if (!map.has(key)) map.set(key, []);
|
|
134
|
-
(map.get(key) as unknown[]).push(rec);
|
|
135
|
-
} else {
|
|
136
|
-
map.set(rec["id"] as string, rec);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Attach to parent rows
|
|
141
|
-
for (const row of rows) {
|
|
142
|
-
const fkValue = row[relation.foreignKey] as string | undefined;
|
|
143
|
-
if (!fkValue) continue;
|
|
144
|
-
row[relation.attachAs] =
|
|
145
|
-
map.get(fkValue) ?? (relation.isList ? [] : null);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Resolve nested includes
|
|
149
|
-
if (nestedIncludes.length > 0) {
|
|
150
|
-
const targetDef = registry.get(relation.targetService);
|
|
151
|
-
if (targetDef) {
|
|
152
|
-
const nestedRows = relation.isList
|
|
153
|
-
? rows.flatMap(
|
|
154
|
-
(r) =>
|
|
155
|
-
(r[relation.attachAs] as Record<string, unknown>[]) ?? [],
|
|
156
|
-
)
|
|
157
|
-
: rows
|
|
158
|
-
.map((r) => r[relation.attachAs] as Record<string, unknown>)
|
|
159
|
-
.filter(Boolean);
|
|
160
|
-
await resolveIncludes(
|
|
161
|
-
nestedRows,
|
|
162
|
-
nestedIncludes,
|
|
163
|
-
targetDef,
|
|
164
|
-
services,
|
|
165
|
-
registry,
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function extractRows(result: unknown): unknown[] {
|
|
173
|
-
if (Array.isArray(result)) return result;
|
|
174
|
-
if (result && typeof result === "object") {
|
|
175
|
-
const r = result as { ok?: boolean; value?: unknown };
|
|
176
|
-
if (r.value != null) {
|
|
177
|
-
if (Array.isArray(r.value)) return r.value;
|
|
178
|
-
if (typeof r.value === "object" && "items" in r.value) {
|
|
179
|
-
return (r.value as { items: unknown[] }).items;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return [];
|
|
184
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines a relation from a parent entity to a related entity.
|
|
3
|
-
* Used by the query executor to batch-load related records.
|
|
4
|
-
*/
|
|
5
|
-
export interface RelationDefinition {
|
|
6
|
-
foreignKey: string;
|
|
7
|
-
targetService: string;
|
|
8
|
-
batchMethod: string;
|
|
9
|
-
attachAs: string;
|
|
10
|
-
isList?: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Defines an entity that can be queried via kernel.query().
|
|
15
|
-
*/
|
|
16
|
-
export interface EntityDefinition {
|
|
17
|
-
service: string;
|
|
18
|
-
getByIdMethod: string;
|
|
19
|
-
listMethod: string;
|
|
20
|
-
relations: Record<string, RelationDefinition>;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Registry of queryable entities and their relations.
|
|
25
|
-
* Modules register their entities at kernel boot.
|
|
26
|
-
* Plugins can register additional entities.
|
|
27
|
-
*/
|
|
28
|
-
export class QueryRegistry {
|
|
29
|
-
private entities = new Map<string, EntityDefinition>();
|
|
30
|
-
|
|
31
|
-
register(name: string, definition: EntityDefinition): void {
|
|
32
|
-
this.entities.set(name, definition);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
get(name: string): EntityDefinition | undefined {
|
|
36
|
-
return this.entities.get(name);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
has(name: string): boolean {
|
|
40
|
-
return this.entities.has(name);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
listEntities(): string[] {
|
|
44
|
-
return [...this.entities.keys()];
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ServiceRegistry -- typed surface of the kernel service container
|
|
3
|
-
* for plugin-to-plugin communication.
|
|
4
|
-
*
|
|
5
|
-
* Plugin services accept this as an optional constructor parameter
|
|
6
|
-
* to call core services without resorting to raw SQL.
|
|
7
|
-
*
|
|
8
|
-
* Core services are loosely typed here (method signatures use `unknown`)
|
|
9
|
-
* to avoid plugin packages depending on core's internal service types.
|
|
10
|
-
* Plugin authors cast the return values at the call site.
|
|
11
|
-
*
|
|
12
|
-
* Usage in a plugin service:
|
|
13
|
-
*
|
|
14
|
-
* import type { ServiceRegistry } from "@porulle/core";
|
|
15
|
-
*
|
|
16
|
-
* class MyService {
|
|
17
|
-
* constructor(private db: PluginDb, private services?: ServiceRegistry) {}
|
|
18
|
-
*
|
|
19
|
-
* async doWork() {
|
|
20
|
-
* const result = await this.services?.inventory.adjust({
|
|
21
|
-
* entityId: "...", adjustment: -5, reason: "recipe deduction"
|
|
22
|
-
* }, actor);
|
|
23
|
-
* }
|
|
24
|
-
* }
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
export interface ServiceRegistry {
|
|
28
|
-
inventory: {
|
|
29
|
-
adjust(
|
|
30
|
-
input: {
|
|
31
|
-
entityId: string;
|
|
32
|
-
variantId?: string;
|
|
33
|
-
warehouseId?: string;
|
|
34
|
-
adjustment: number;
|
|
35
|
-
reason?: string;
|
|
36
|
-
},
|
|
37
|
-
actor?: unknown,
|
|
38
|
-
): Promise<{ ok: boolean; value?: unknown; error?: unknown }>;
|
|
39
|
-
createWarehouse(
|
|
40
|
-
input: { name: string; code: string },
|
|
41
|
-
actor?: unknown,
|
|
42
|
-
): Promise<{ ok: boolean; value?: unknown; error?: unknown }>;
|
|
43
|
-
reserve(input: unknown, actor?: unknown): Promise<unknown>;
|
|
44
|
-
release(input: unknown, actor?: unknown): Promise<unknown>;
|
|
45
|
-
getAvailable(input: unknown, actor?: unknown): Promise<unknown>;
|
|
46
|
-
[method: string]: unknown;
|
|
47
|
-
};
|
|
48
|
-
catalog: {
|
|
49
|
-
create(input: unknown, actor?: unknown): Promise<{ ok: boolean; value?: unknown; error?: unknown }>;
|
|
50
|
-
getById(id: string, options?: unknown): Promise<{ ok: boolean; value?: unknown; error?: unknown }>;
|
|
51
|
-
publish(id: string, actor?: unknown): Promise<unknown>;
|
|
52
|
-
list(input?: unknown): Promise<unknown>;
|
|
53
|
-
[method: string]: unknown;
|
|
54
|
-
};
|
|
55
|
-
customers: {
|
|
56
|
-
getByUserId(userId: string, actor?: unknown): Promise<{ ok: boolean; value?: unknown; error?: unknown }>;
|
|
57
|
-
getById(id: string, actor?: unknown): Promise<{ ok: boolean; value?: unknown; error?: unknown }>;
|
|
58
|
-
[method: string]: unknown;
|
|
59
|
-
};
|
|
60
|
-
orders: {
|
|
61
|
-
create(input: unknown, actor?: unknown): Promise<{ ok: boolean; value?: unknown; error?: unknown }>;
|
|
62
|
-
changeStatus(input: unknown, actor?: unknown): Promise<unknown>;
|
|
63
|
-
[method: string]: unknown;
|
|
64
|
-
};
|
|
65
|
-
cart: {
|
|
66
|
-
create(input: unknown, actor?: unknown): Promise<{ ok: boolean; value?: unknown; error?: unknown }>;
|
|
67
|
-
[method: string]: unknown;
|
|
68
|
-
};
|
|
69
|
-
organization: {
|
|
70
|
-
create(input: unknown): Promise<{ ok: boolean; value?: unknown; error?: unknown }>;
|
|
71
|
-
getById(id: string): Promise<unknown>;
|
|
72
|
-
[method: string]: unknown;
|
|
73
|
-
};
|
|
74
|
-
/** Access plugin-registered services by plugin ID or service name */
|
|
75
|
-
[key: string]: unknown;
|
|
76
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Analytics hooks — legacy compatibility surface.
|
|
3
|
-
*
|
|
4
|
-
* The in-memory event recording hooks (recordOrderAnalyticsEvent,
|
|
5
|
-
* recordInventoryAnalyticsEvent) have been removed. The source tables
|
|
6
|
-
* (orders, inventory_levels, customers) ARE the source of truth; the
|
|
7
|
-
* DrizzleAnalyticsAdapter queries them directly via SQL.
|
|
8
|
-
*
|
|
9
|
-
* The empty exports below preserve backwards compatibility for code
|
|
10
|
-
* still importing from this module.
|
|
11
|
-
*/
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { CommerceConfig } from "../../config/types.js";
|
|
2
|
-
import type { DrizzleDatabase } from "../../kernel/database/drizzle-db.js";
|
|
3
|
-
import { defineModule } from "../../kernel/module/index.js";
|
|
4
|
-
import type { SettingsService } from "../settings/service.js";
|
|
5
|
-
import { DrizzleAnalyticsAdapter } from "./drizzle-adapter.js";
|
|
6
|
-
import { BUILTIN_ANALYTICS_MODELS } from "./models.js";
|
|
7
|
-
import { RetailReportsEngine } from "./reports.js";
|
|
8
|
-
import { AnalyticsService } from "./service.js";
|
|
9
|
-
|
|
10
|
-
export const analyticsModule = defineModule<
|
|
11
|
-
Record<string, never>,
|
|
12
|
-
AnalyticsService,
|
|
13
|
-
Record<string, never>
|
|
14
|
-
>({
|
|
15
|
-
id: "analytics",
|
|
16
|
-
schema: () => ({}),
|
|
17
|
-
service: (deps) => {
|
|
18
|
-
const adapter = new DrizzleAnalyticsAdapter(deps.db.db as DrizzleDatabase);
|
|
19
|
-
for (const model of BUILTIN_ANALYTICS_MODELS) {
|
|
20
|
-
adapter.registerModel(model);
|
|
21
|
-
}
|
|
22
|
-
// Settings is resolved lazily from the shared service container — the
|
|
23
|
-
// settings module may instantiate after analytics.
|
|
24
|
-
const services = deps.services as Record<string, unknown>;
|
|
25
|
-
const reports = new RetailReportsEngine(
|
|
26
|
-
deps.db.db as DrizzleDatabase,
|
|
27
|
-
(orgId, group) => (services.settings as SettingsService).read(orgId, group),
|
|
28
|
-
);
|
|
29
|
-
return new AnalyticsService({
|
|
30
|
-
adapter,
|
|
31
|
-
config: deps.config as CommerceConfig,
|
|
32
|
-
reports,
|
|
33
|
-
});
|
|
34
|
-
},
|
|
35
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { auditModule } from "./module.js";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { defineModule } from "../../kernel/module/index.js";
|
|
2
|
-
import type { DrizzleDatabase } from "../../kernel/database/drizzle-db.js";
|
|
3
|
-
import { auditLog } from "./schema.js";
|
|
4
|
-
import { createAuditService } from "./service.js";
|
|
5
|
-
|
|
6
|
-
export const auditModule = defineModule({
|
|
7
|
-
id: "audit",
|
|
8
|
-
schema: () => ({ auditLog }),
|
|
9
|
-
service: (deps) =>
|
|
10
|
-
createAuditService(deps.db.db as DrizzleDatabase),
|
|
11
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { Actor } from "../../auth/types.js";
|
|
2
|
-
import type { Cart } from "./repository/index.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Determines whether an actor can access a cart.
|
|
6
|
-
*
|
|
7
|
-
* Access is granted if:
|
|
8
|
-
* 1. The actor is authenticated and owns the cart (customerId match)
|
|
9
|
-
* 2. The provided secret matches the cart's secret (guest access)
|
|
10
|
-
*/
|
|
11
|
-
export function canAccessCart(
|
|
12
|
-
actor: Actor | null,
|
|
13
|
-
cart: Cart,
|
|
14
|
-
providedSecret?: string,
|
|
15
|
-
): boolean {
|
|
16
|
-
// Authenticated owner
|
|
17
|
-
if (actor && cart.customerId && actor.userId === cart.customerId) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Valid secret (guest access)
|
|
22
|
-
if (providedSecret && cart.secret && providedSecret === cart.secret) {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { CommerceConfig } from "../../config/types.js";
|
|
2
|
-
import type { DrizzleDatabase } from "../../kernel/database/drizzle-db.js";
|
|
3
|
-
import { defineModule } from "../../kernel/module/index.js";
|
|
4
|
-
import type { CatalogServiceImpl } from "../catalog/service.js";
|
|
5
|
-
import type { InventoryService } from "../inventory/service.js";
|
|
6
|
-
import { CartRepository } from "./repository/index.js";
|
|
7
|
-
import { cartLineItems, carts } from "./schema.js";
|
|
8
|
-
import { CartService } from "./service.js";
|
|
9
|
-
|
|
10
|
-
type CartModuleDeps = {
|
|
11
|
-
catalog: CatalogServiceImpl;
|
|
12
|
-
inventory: InventoryService;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const cartModule = defineModule<
|
|
16
|
-
{ carts: typeof carts; cartLineItems: typeof cartLineItems },
|
|
17
|
-
CartService,
|
|
18
|
-
CartModuleDeps
|
|
19
|
-
>({
|
|
20
|
-
id: "cart",
|
|
21
|
-
dependencies: ["catalog", "inventory"],
|
|
22
|
-
schema: () => ({ carts, cartLineItems }),
|
|
23
|
-
service: (deps) =>
|
|
24
|
-
new CartService({
|
|
25
|
-
repository: new CartRepository(deps.db.db as DrizzleDatabase),
|
|
26
|
-
catalogRepository: deps.services.catalog.repository,
|
|
27
|
-
hooks: deps.hooks,
|
|
28
|
-
config: deps.config as CommerceConfig,
|
|
29
|
-
services: deps.services,
|
|
30
|
-
database: deps.db,
|
|
31
|
-
}),
|
|
32
|
-
});
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import type { CommerceConfig } from "../../config/types.js";
|
|
2
|
-
import type { DrizzleDatabase } from "../../kernel/database/drizzle-db.js";
|
|
3
|
-
import { defineModule } from "../../kernel/module/index.js";
|
|
4
|
-
import type { PricingService } from "../pricing/service.js";
|
|
5
|
-
import { CatalogRepository } from "./repository/index.js";
|
|
6
|
-
import {
|
|
7
|
-
brands,
|
|
8
|
-
categories,
|
|
9
|
-
tags,
|
|
10
|
-
entityTags,
|
|
11
|
-
entityBrands,
|
|
12
|
-
entityCategories,
|
|
13
|
-
optionTypes,
|
|
14
|
-
optionValues,
|
|
15
|
-
sellableAttributes,
|
|
16
|
-
sellableCustomFields,
|
|
17
|
-
entityFieldDefinitions,
|
|
18
|
-
sellableEntityRevisions,
|
|
19
|
-
sellableEntities,
|
|
20
|
-
variantOptionValues,
|
|
21
|
-
variants,
|
|
22
|
-
catalogFieldOwnership,
|
|
23
|
-
} from "./schema.js";
|
|
24
|
-
import { CatalogServiceImpl } from "./service.js";
|
|
25
|
-
|
|
26
|
-
type CatalogModuleDeps = {
|
|
27
|
-
pricing: PricingService;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const catalogModule = defineModule<
|
|
31
|
-
{
|
|
32
|
-
sellableEntities: typeof sellableEntities;
|
|
33
|
-
sellableAttributes: typeof sellableAttributes;
|
|
34
|
-
sellableCustomFields: typeof sellableCustomFields;
|
|
35
|
-
entityFieldDefinitions: typeof entityFieldDefinitions;
|
|
36
|
-
sellableEntityRevisions: typeof sellableEntityRevisions;
|
|
37
|
-
categories: typeof categories;
|
|
38
|
-
entityCategories: typeof entityCategories;
|
|
39
|
-
brands: typeof brands;
|
|
40
|
-
entityBrands: typeof entityBrands;
|
|
41
|
-
tags: typeof tags;
|
|
42
|
-
entityTags: typeof entityTags;
|
|
43
|
-
optionTypes: typeof optionTypes;
|
|
44
|
-
optionValues: typeof optionValues;
|
|
45
|
-
variants: typeof variants;
|
|
46
|
-
variantOptionValues: typeof variantOptionValues;
|
|
47
|
-
catalogFieldOwnership: typeof catalogFieldOwnership;
|
|
48
|
-
},
|
|
49
|
-
CatalogServiceImpl,
|
|
50
|
-
CatalogModuleDeps
|
|
51
|
-
>({
|
|
52
|
-
id: "catalog",
|
|
53
|
-
dependencies: ["pricing"],
|
|
54
|
-
schema: () => ({
|
|
55
|
-
sellableEntities,
|
|
56
|
-
sellableAttributes,
|
|
57
|
-
sellableCustomFields,
|
|
58
|
-
entityFieldDefinitions,
|
|
59
|
-
sellableEntityRevisions,
|
|
60
|
-
categories,
|
|
61
|
-
entityCategories,
|
|
62
|
-
brands,
|
|
63
|
-
entityBrands,
|
|
64
|
-
tags,
|
|
65
|
-
entityTags,
|
|
66
|
-
optionTypes,
|
|
67
|
-
optionValues,
|
|
68
|
-
variants,
|
|
69
|
-
variantOptionValues,
|
|
70
|
-
catalogFieldOwnership,
|
|
71
|
-
}),
|
|
72
|
-
service: (deps) =>
|
|
73
|
-
new CatalogServiceImpl({
|
|
74
|
-
repository: new CatalogRepository(deps.db.db as DrizzleDatabase),
|
|
75
|
-
hooks: deps.hooks,
|
|
76
|
-
config: deps.config as CommerceConfig,
|
|
77
|
-
services: deps.services,
|
|
78
|
-
database: deps.db,
|
|
79
|
-
}),
|
|
80
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { customersModule } from "./module.js";
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { CommerceConfig } from "../../config/types.js";
|
|
2
|
-
import type { DrizzleDatabase } from "../../kernel/database/drizzle-db.js";
|
|
3
|
-
import { defineModule } from "../../kernel/module/index.js";
|
|
4
|
-
import { CustomersRepository } from "./repository/index.js";
|
|
5
|
-
import { CustomerService } from "./service.js";
|
|
6
|
-
import {
|
|
7
|
-
customerAddresses,
|
|
8
|
-
customerGroupMembers,
|
|
9
|
-
customerGroups,
|
|
10
|
-
customers,
|
|
11
|
-
} from "./schema.js";
|
|
12
|
-
|
|
13
|
-
export const customersModule = defineModule({
|
|
14
|
-
id: "customers",
|
|
15
|
-
schema: () => ({
|
|
16
|
-
customers,
|
|
17
|
-
customerAddresses,
|
|
18
|
-
customerGroups,
|
|
19
|
-
customerGroupMembers,
|
|
20
|
-
}),
|
|
21
|
-
service: (deps) =>
|
|
22
|
-
new CustomerService({
|
|
23
|
-
repository: new CustomersRepository(deps.db.db as DrizzleDatabase),
|
|
24
|
-
hooks: deps.hooks,
|
|
25
|
-
config: deps.config as CommerceConfig,
|
|
26
|
-
services: deps.services,
|
|
27
|
-
database: deps.db,
|
|
28
|
-
}),
|
|
29
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { CommerceConfig } from "../../config/types.js";
|
|
2
|
-
import type { DrizzleDatabase } from "../../kernel/database/drizzle-db.js";
|
|
3
|
-
import { defineModule } from "../../kernel/module/index.js";
|
|
4
|
-
import { DocumentsRepository } from "./repository/index.js";
|
|
5
|
-
import { invoiceSequences, orderDocuments } from "./schema.js";
|
|
6
|
-
import { DocumentsService } from "./service.js";
|
|
7
|
-
|
|
8
|
-
export const documentsModule = defineModule<
|
|
9
|
-
{ invoiceSequences: typeof invoiceSequences; orderDocuments: typeof orderDocuments },
|
|
10
|
-
DocumentsService,
|
|
11
|
-
Record<string, never>
|
|
12
|
-
>({
|
|
13
|
-
id: "documents",
|
|
14
|
-
schema: () => ({ invoiceSequences, orderDocuments }),
|
|
15
|
-
service: (deps) =>
|
|
16
|
-
new DocumentsService({
|
|
17
|
-
repository: new DocumentsRepository(deps.db.db as DrizzleDatabase),
|
|
18
|
-
services: deps.services as Record<string, unknown>,
|
|
19
|
-
config: deps.config as CommerceConfig,
|
|
20
|
-
}),
|
|
21
|
-
});
|