@unifiedcommerce/core 0.4.4 → 0.5.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/console-email.d.ts +23 -0
- package/dist/adapters/console-email.d.ts.map +1 -0
- package/dist/adapters/console-email.js +38 -0
- package/dist/auth/access.d.ts +101 -0
- package/dist/auth/access.d.ts.map +1 -0
- package/dist/auth/access.js +128 -0
- package/dist/auth/auth-schema.d.ts +1475 -0
- package/dist/auth/auth-schema.d.ts.map +1 -0
- package/dist/auth/auth-schema.js +124 -0
- package/dist/auth/middleware.d.ts +5 -0
- package/dist/auth/middleware.d.ts.map +1 -0
- package/dist/auth/middleware.js +141 -0
- package/dist/auth/org.d.ts +22 -0
- package/dist/auth/org.d.ts.map +1 -0
- package/dist/auth/org.js +36 -0
- package/dist/auth/permissions.d.ts +4 -0
- package/dist/auth/permissions.d.ts.map +1 -0
- package/dist/auth/permissions.js +24 -0
- package/dist/auth/setup.d.ts +29 -0
- package/dist/auth/setup.d.ts.map +1 -0
- package/dist/auth/setup.js +144 -0
- package/dist/auth/system-actor.d.ts +7 -0
- package/dist/auth/system-actor.d.ts.map +1 -0
- package/dist/auth/system-actor.js +17 -0
- package/dist/auth/types.d.ts +11 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +1 -0
- package/dist/config/defaults.d.ts +3 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +80 -0
- package/dist/config/define-config.d.ts +9 -0
- package/dist/config/define-config.d.ts.map +1 -0
- package/dist/config/define-config.js +44 -0
- package/dist/config/types.d.ts +327 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +1 -0
- package/dist/generated/plugin-manifest.d.ts +48 -0
- package/dist/generated/plugin-manifest.d.ts.map +1 -0
- package/dist/generated/plugin-manifest.js +20 -0
- package/dist/hooks/checkout-completion.d.ts +58 -0
- package/dist/hooks/checkout-completion.d.ts.map +1 -0
- package/dist/hooks/checkout-completion.js +137 -0
- package/dist/hooks/checkout.d.ts +99 -0
- package/dist/hooks/checkout.d.ts.map +1 -0
- package/dist/hooks/checkout.js +317 -0
- package/dist/hooks/order-emails.d.ts +16 -0
- package/dist/hooks/order-emails.d.ts.map +1 -0
- package/dist/hooks/order-emails.js +44 -0
- package/dist/index.d.ts +77 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -0
- package/dist/interfaces/mcp/agent-prompt.d.ts +16 -0
- package/dist/interfaces/mcp/agent-prompt.d.ts.map +1 -0
- package/dist/interfaces/mcp/agent-prompt.js +172 -0
- package/dist/interfaces/mcp/context-enrichment.d.ts +39 -0
- package/dist/interfaces/mcp/context-enrichment.d.ts.map +1 -0
- package/dist/interfaces/mcp/context-enrichment.js +119 -0
- package/dist/interfaces/mcp/server.d.ts +5 -0
- package/dist/interfaces/mcp/server.d.ts.map +1 -0
- package/dist/interfaces/mcp/server.js +30 -0
- package/dist/interfaces/mcp/tool-builder.d.ts +120 -0
- package/dist/interfaces/mcp/tool-builder.d.ts.map +1 -0
- package/dist/interfaces/mcp/tool-builder.js +224 -0
- package/dist/interfaces/mcp/tools/analytics.d.ts +42 -0
- package/dist/interfaces/mcp/tools/analytics.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/analytics.js +70 -0
- package/dist/interfaces/mcp/tools/cart.d.ts +14 -0
- package/dist/interfaces/mcp/tools/cart.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/cart.js +47 -0
- package/dist/interfaces/mcp/tools/catalog.d.ts +53 -0
- package/dist/interfaces/mcp/tools/catalog.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/catalog.js +284 -0
- package/dist/interfaces/mcp/tools/index.d.ts +3 -0
- package/dist/interfaces/mcp/tools/index.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/index.js +20 -0
- package/dist/interfaces/mcp/tools/inventory.d.ts +27 -0
- package/dist/interfaces/mcp/tools/inventory.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/inventory.js +143 -0
- package/dist/interfaces/mcp/tools/orders.d.ts +18 -0
- package/dist/interfaces/mcp/tools/orders.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/orders.js +82 -0
- package/dist/interfaces/mcp/tools/pricing.d.ts +29 -0
- package/dist/interfaces/mcp/tools/pricing.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/pricing.js +90 -0
- package/dist/interfaces/mcp/tools/promotions.d.ts +44 -0
- package/dist/interfaces/mcp/tools/promotions.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/promotions.js +109 -0
- package/dist/interfaces/mcp/tools/registry.d.ts +32 -0
- package/dist/interfaces/mcp/tools/registry.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/registry.js +55 -0
- package/dist/interfaces/mcp/tools/search.d.ts +14 -0
- package/dist/interfaces/mcp/tools/search.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/search.js +39 -0
- package/dist/interfaces/mcp/tools/webhooks.d.ts +15 -0
- package/dist/interfaces/mcp/tools/webhooks.d.ts.map +1 -0
- package/dist/interfaces/mcp/tools/webhooks.js +48 -0
- package/dist/interfaces/mcp/transport.d.ts +20 -0
- package/dist/interfaces/mcp/transport.d.ts.map +1 -0
- package/dist/interfaces/mcp/transport.js +99 -0
- package/dist/interfaces/rest/customer-portal.d.ts +5 -0
- package/dist/interfaces/rest/customer-portal.d.ts.map +1 -0
- package/dist/interfaces/rest/customer-portal.js +206 -0
- package/dist/interfaces/rest/router.d.ts +164 -0
- package/dist/interfaces/rest/router.d.ts.map +1 -0
- package/dist/interfaces/rest/router.js +259 -0
- package/dist/interfaces/rest/routes/admin-jobs.d.ts +5 -0
- package/dist/interfaces/rest/routes/admin-jobs.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/admin-jobs.js +48 -0
- package/dist/interfaces/rest/routes/audit.d.ts +5 -0
- package/dist/interfaces/rest/routes/audit.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/audit.js +43 -0
- package/dist/interfaces/rest/routes/carts.d.ts +5 -0
- package/dist/interfaces/rest/routes/carts.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/carts.js +55 -0
- package/dist/interfaces/rest/routes/catalog.d.ts +5 -0
- package/dist/interfaces/rest/routes/catalog.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/catalog.js +256 -0
- package/dist/interfaces/rest/routes/checkout.d.ts +5 -0
- package/dist/interfaces/rest/routes/checkout.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/checkout.js +216 -0
- package/dist/interfaces/rest/routes/customers.d.ts +5 -0
- package/dist/interfaces/rest/routes/customers.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/customers.js +78 -0
- package/dist/interfaces/rest/routes/entity-aliases.d.ts +18 -0
- package/dist/interfaces/rest/routes/entity-aliases.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/entity-aliases.js +39 -0
- package/dist/interfaces/rest/routes/inventory.d.ts +5 -0
- package/dist/interfaces/rest/routes/inventory.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/inventory.js +74 -0
- package/dist/interfaces/rest/routes/media.d.ts +5 -0
- package/dist/interfaces/rest/routes/media.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/media.js +65 -0
- package/dist/interfaces/rest/routes/orders.d.ts +5 -0
- package/dist/interfaces/rest/routes/orders.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/orders.js +64 -0
- package/dist/interfaces/rest/routes/payments.d.ts +5 -0
- package/dist/interfaces/rest/routes/payments.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/payments.js +45 -0
- package/dist/interfaces/rest/routes/pricing.d.ts +5 -0
- package/dist/interfaces/rest/routes/pricing.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/pricing.js +48 -0
- package/dist/interfaces/rest/routes/promotions.d.ts +5 -0
- package/dist/interfaces/rest/routes/promotions.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/promotions.js +76 -0
- package/dist/interfaces/rest/routes/search.d.ts +5 -0
- package/dist/interfaces/rest/routes/search.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/search.js +60 -0
- package/dist/interfaces/rest/routes/webhooks.d.ts +5 -0
- package/dist/interfaces/rest/routes/webhooks.d.ts.map +1 -0
- package/dist/interfaces/rest/routes/webhooks.js +39 -0
- package/dist/interfaces/rest/schemas/admin-jobs.d.ts +327 -0
- package/dist/interfaces/rest/schemas/admin-jobs.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/admin-jobs.js +37 -0
- package/dist/interfaces/rest/schemas/audit.d.ts +59 -0
- package/dist/interfaces/rest/schemas/audit.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/audit.js +43 -0
- package/dist/interfaces/rest/schemas/carts.d.ts +1456 -0
- package/dist/interfaces/rest/schemas/carts.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/carts.js +109 -0
- package/dist/interfaces/rest/schemas/catalog.d.ts +5452 -0
- package/dist/interfaces/rest/schemas/catalog.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/catalog.js +397 -0
- package/dist/interfaces/rest/schemas/checkout.d.ts +160 -0
- package/dist/interfaces/rest/schemas/checkout.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/checkout.js +60 -0
- package/dist/interfaces/rest/schemas/customer-portal.d.ts +2203 -0
- package/dist/interfaces/rest/schemas/customer-portal.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/customer-portal.js +177 -0
- package/dist/interfaces/rest/schemas/customers.d.ts +422 -0
- package/dist/interfaces/rest/schemas/customers.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/customers.js +150 -0
- package/dist/interfaces/rest/schemas/inventory.d.ts +561 -0
- package/dist/interfaces/rest/schemas/inventory.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/inventory.js +148 -0
- package/dist/interfaces/rest/schemas/media.d.ts +303 -0
- package/dist/interfaces/rest/schemas/media.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/media.js +69 -0
- package/dist/interfaces/rest/schemas/orders.d.ts +1792 -0
- package/dist/interfaces/rest/schemas/orders.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/orders.js +93 -0
- package/dist/interfaces/rest/schemas/pricing.d.ts +256 -0
- package/dist/interfaces/rest/schemas/pricing.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/pricing.js +72 -0
- package/dist/interfaces/rest/schemas/promotions.d.ts +374 -0
- package/dist/interfaces/rest/schemas/promotions.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/promotions.js +104 -0
- package/dist/interfaces/rest/schemas/responses.d.ts +4086 -0
- package/dist/interfaces/rest/schemas/responses.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/responses.js +74 -0
- package/dist/interfaces/rest/schemas/search.d.ts +247 -0
- package/dist/interfaces/rest/schemas/search.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/search.js +55 -0
- package/dist/interfaces/rest/schemas/shared.d.ts +95 -0
- package/dist/interfaces/rest/schemas/shared.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/shared.js +51 -0
- package/dist/interfaces/rest/schemas/webhooks.d.ts +221 -0
- package/dist/interfaces/rest/schemas/webhooks.d.ts.map +1 -0
- package/dist/interfaces/rest/schemas/webhooks.js +62 -0
- package/dist/interfaces/rest/utils.d.ts +45 -0
- package/dist/interfaces/rest/utils.d.ts.map +1 -0
- package/dist/interfaces/rest/utils.js +71 -0
- package/dist/interfaces/rest/webhook-router.d.ts +41 -0
- package/dist/interfaces/rest/webhook-router.d.ts.map +1 -0
- package/dist/interfaces/rest/webhook-router.js +36 -0
- package/dist/kernel/compensation/executor.d.ts +21 -0
- package/dist/kernel/compensation/executor.d.ts.map +1 -0
- package/dist/kernel/compensation/executor.js +36 -0
- package/dist/kernel/compensation/types.d.ts +25 -0
- package/dist/kernel/compensation/types.d.ts.map +1 -0
- package/dist/kernel/compensation/types.js +1 -0
- package/dist/kernel/database/adapter.d.ts +18 -0
- package/dist/kernel/database/adapter.d.ts.map +1 -0
- package/dist/kernel/database/adapter.js +3 -0
- package/dist/kernel/database/drizzle-db.d.ts +49 -0
- package/dist/kernel/database/drizzle-db.d.ts.map +1 -0
- package/dist/kernel/database/drizzle-db.js +20 -0
- package/dist/kernel/database/migrate.d.ts +38 -0
- package/dist/kernel/database/migrate.d.ts.map +1 -0
- package/dist/kernel/database/migrate.js +61 -0
- package/dist/kernel/database/plugin-types.d.ts +32 -0
- package/dist/kernel/database/plugin-types.d.ts.map +1 -0
- package/dist/kernel/database/plugin-types.js +10 -0
- package/dist/kernel/database/schema.d.ts +24 -0
- package/dist/kernel/database/schema.d.ts.map +1 -0
- package/dist/kernel/database/schema.js +36 -0
- package/dist/kernel/database/scoped-db.d.ts +20 -0
- package/dist/kernel/database/scoped-db.d.ts.map +1 -0
- package/dist/kernel/database/scoped-db.js +62 -0
- package/dist/kernel/database/tx-context.d.ts +15 -0
- package/dist/kernel/database/tx-context.d.ts.map +1 -0
- package/dist/kernel/database/tx-context.js +19 -0
- package/dist/kernel/error-mapper.d.ts +3 -0
- package/dist/kernel/error-mapper.d.ts.map +1 -0
- package/dist/kernel/error-mapper.js +12 -0
- package/dist/kernel/errors.d.ts +38 -0
- package/dist/kernel/errors.d.ts.map +1 -0
- package/dist/kernel/errors.js +69 -0
- package/dist/kernel/factory/repository-factory.d.ts +71 -0
- package/dist/kernel/factory/repository-factory.d.ts.map +1 -0
- package/dist/kernel/factory/repository-factory.js +138 -0
- package/dist/kernel/hooks/create-context.d.ts +25 -0
- package/dist/kernel/hooks/create-context.d.ts.map +1 -0
- package/dist/kernel/hooks/create-context.js +22 -0
- package/dist/kernel/hooks/executor.d.ts +12 -0
- package/dist/kernel/hooks/executor.d.ts.map +1 -0
- package/dist/kernel/hooks/executor.js +50 -0
- package/dist/kernel/hooks/registry.d.ts +28 -0
- package/dist/kernel/hooks/registry.d.ts.map +1 -0
- package/dist/kernel/hooks/registry.js +58 -0
- package/dist/kernel/hooks/types.d.ts +37 -0
- package/dist/kernel/hooks/types.d.ts.map +1 -0
- package/dist/kernel/hooks/types.js +1 -0
- package/dist/kernel/http-error.d.ts +30 -0
- package/dist/kernel/http-error.d.ts.map +1 -0
- package/dist/kernel/http-error.js +35 -0
- package/dist/kernel/jobs/adapter.d.ts +25 -0
- package/dist/kernel/jobs/adapter.d.ts.map +1 -0
- package/dist/kernel/jobs/adapter.js +9 -0
- package/dist/kernel/jobs/drizzle-adapter.d.ts +15 -0
- package/dist/kernel/jobs/drizzle-adapter.d.ts.map +1 -0
- package/dist/kernel/jobs/drizzle-adapter.js +42 -0
- package/dist/kernel/jobs/runner.d.ts +24 -0
- package/dist/kernel/jobs/runner.d.ts.map +1 -0
- package/dist/kernel/jobs/runner.js +114 -0
- package/dist/kernel/jobs/schema.d.ts +280 -0
- package/dist/kernel/jobs/schema.d.ts.map +1 -0
- package/dist/kernel/jobs/schema.js +37 -0
- package/dist/kernel/jobs/types.d.ts +30 -0
- package/dist/kernel/jobs/types.d.ts.map +1 -0
- package/dist/kernel/jobs/types.js +1 -0
- package/dist/kernel/local-api.d.ts +103 -0
- package/dist/kernel/local-api.d.ts.map +1 -0
- package/dist/kernel/local-api.js +89 -0
- package/dist/kernel/plugin/manifest.d.ts +90 -0
- package/dist/kernel/plugin/manifest.d.ts.map +1 -0
- package/dist/kernel/plugin/manifest.js +169 -0
- package/dist/kernel/query/executor.d.ts +21 -0
- package/dist/kernel/query/executor.d.ts.map +1 -0
- package/dist/kernel/query/executor.js +128 -0
- package/dist/kernel/query/registry.d.ts +33 -0
- package/dist/kernel/query/registry.d.ts.map +1 -0
- package/dist/kernel/query/registry.js +20 -0
- package/dist/kernel/result.d.ts +36 -0
- package/dist/kernel/result.d.ts.map +1 -0
- package/dist/kernel/result.js +16 -0
- package/dist/kernel/schema/extra-columns.d.ts +23 -0
- package/dist/kernel/schema/extra-columns.d.ts.map +1 -0
- package/dist/kernel/schema/extra-columns.js +10 -0
- package/dist/kernel/service-registry.d.ts +109 -0
- package/dist/kernel/service-registry.d.ts.map +1 -0
- package/dist/kernel/service-registry.js +26 -0
- package/dist/kernel/service-timing.d.ts +25 -0
- package/dist/kernel/service-timing.d.ts.map +1 -0
- package/dist/kernel/service-timing.js +62 -0
- package/dist/kernel/state-machine/machine.d.ts +24 -0
- package/dist/kernel/state-machine/machine.d.ts.map +1 -0
- package/dist/kernel/state-machine/machine.js +70 -0
- package/dist/modules/analytics/drizzle-adapter.d.ts +13 -0
- package/dist/modules/analytics/drizzle-adapter.d.ts.map +1 -0
- package/dist/modules/analytics/drizzle-adapter.js +358 -0
- package/dist/modules/analytics/hooks.d.ts +13 -0
- package/dist/modules/analytics/hooks.d.ts.map +1 -0
- package/dist/modules/analytics/hooks.js +12 -0
- package/dist/modules/analytics/models.d.ts +14 -0
- package/dist/modules/analytics/models.d.ts.map +1 -0
- package/dist/modules/analytics/models.js +118 -0
- package/dist/modules/analytics/repository/index.d.ts +5 -0
- package/dist/modules/analytics/repository/index.d.ts.map +1 -0
- package/dist/modules/analytics/repository/index.js +1 -0
- package/dist/modules/analytics/service.d.ts +45 -0
- package/dist/modules/analytics/service.d.ts.map +1 -0
- package/dist/modules/analytics/service.js +196 -0
- package/dist/modules/analytics/types.d.ts +119 -0
- package/dist/modules/analytics/types.d.ts.map +1 -0
- package/dist/modules/analytics/types.js +25 -0
- package/dist/modules/audit/hooks.d.ts +7 -0
- package/dist/modules/audit/hooks.d.ts.map +1 -0
- package/dist/modules/audit/hooks.js +67 -0
- package/dist/modules/audit/schema.d.ts +178 -0
- package/dist/modules/audit/schema.d.ts.map +1 -0
- package/dist/modules/audit/schema.js +21 -0
- package/dist/modules/audit/service.d.ts +38 -0
- package/dist/modules/audit/service.d.ts.map +1 -0
- package/dist/modules/audit/service.js +109 -0
- package/dist/modules/cart/access.d.ts +11 -0
- package/dist/modules/cart/access.d.ts.map +1 -0
- package/dist/modules/cart/access.js +18 -0
- package/dist/modules/cart/matcher.d.ts +20 -0
- package/dist/modules/cart/matcher.d.ts.map +1 -0
- package/dist/modules/cart/matcher.js +2 -0
- package/dist/modules/cart/repository/index.d.ts +45 -0
- package/dist/modules/cart/repository/index.d.ts.map +1 -0
- package/dist/modules/cart/repository/index.js +158 -0
- package/dist/modules/cart/schema.d.ts +359 -0
- package/dist/modules/cart/schema.d.ts.map +1 -0
- package/dist/modules/cart/schema.js +40 -0
- package/dist/modules/cart/schemas.d.ts +29 -0
- package/dist/modules/cart/schemas.d.ts.map +1 -0
- package/dist/modules/cart/schemas.js +14 -0
- package/dist/modules/cart/service.d.ts +63 -0
- package/dist/modules/cart/service.d.ts.map +1 -0
- package/dist/modules/cart/service.js +339 -0
- package/dist/modules/catalog/repository/index.d.ts +106 -0
- package/dist/modules/catalog/repository/index.d.ts.map +1 -0
- package/dist/modules/catalog/repository/index.js +455 -0
- package/dist/modules/catalog/schema.d.ts +1193 -0
- package/dist/modules/catalog/schema.d.ts.map +1 -0
- package/dist/modules/catalog/schema.js +149 -0
- package/dist/modules/catalog/schemas.d.ts +81 -0
- package/dist/modules/catalog/schemas.d.ts.map +1 -0
- package/dist/modules/catalog/schemas.js +62 -0
- package/dist/modules/catalog/service.d.ts +165 -0
- package/dist/modules/catalog/service.d.ts.map +1 -0
- package/dist/modules/catalog/service.js +775 -0
- package/dist/modules/customers/repository/index.d.ts +47 -0
- package/dist/modules/customers/repository/index.d.ts.map +1 -0
- package/dist/modules/customers/repository/index.js +206 -0
- package/dist/modules/customers/schema.d.ts +560 -0
- package/dist/modules/customers/schema.d.ts.map +1 -0
- package/dist/modules/customers/schema.js +60 -0
- package/dist/modules/customers/service.d.ts +27 -0
- package/dist/modules/customers/service.d.ts.map +1 -0
- package/dist/modules/customers/service.js +106 -0
- package/dist/modules/fulfillment/repository/index.d.ts +63 -0
- package/dist/modules/fulfillment/repository/index.d.ts.map +1 -0
- package/dist/modules/fulfillment/repository/index.js +268 -0
- package/dist/modules/fulfillment/schema.d.ts +655 -0
- package/dist/modules/fulfillment/schema.d.ts.map +1 -0
- package/dist/modules/fulfillment/schema.js +83 -0
- package/dist/modules/fulfillment/service.d.ts +58 -0
- package/dist/modules/fulfillment/service.d.ts.map +1 -0
- package/dist/modules/fulfillment/service.js +338 -0
- package/dist/modules/fulfillment/types.d.ts +44 -0
- package/dist/modules/fulfillment/types.d.ts.map +1 -0
- package/dist/modules/fulfillment/types.js +1 -0
- package/dist/modules/inventory/repository/index.d.ts +81 -0
- package/dist/modules/inventory/repository/index.d.ts.map +1 -0
- package/dist/modules/inventory/repository/index.js +310 -0
- package/dist/modules/inventory/schema.d.ts +570 -0
- package/dist/modules/inventory/schema.d.ts.map +1 -0
- package/dist/modules/inventory/schema.js +69 -0
- package/dist/modules/inventory/schemas.d.ts +31 -0
- package/dist/modules/inventory/schemas.d.ts.map +1 -0
- package/dist/modules/inventory/schemas.js +28 -0
- package/dist/modules/inventory/service.d.ts +69 -0
- package/dist/modules/inventory/service.d.ts.map +1 -0
- package/dist/modules/inventory/service.js +283 -0
- package/dist/modules/media/adapter.d.ts +16 -0
- package/dist/modules/media/adapter.d.ts.map +1 -0
- package/dist/modules/media/adapter.js +1 -0
- package/dist/modules/media/repository/index.d.ts +35 -0
- package/dist/modules/media/repository/index.d.ts.map +1 -0
- package/dist/modules/media/repository/index.js +176 -0
- package/dist/modules/media/schema.d.ts +289 -0
- package/dist/modules/media/schema.d.ts.map +1 -0
- package/dist/modules/media/schema.js +35 -0
- package/dist/modules/media/service.d.ts +42 -0
- package/dist/modules/media/service.d.ts.map +1 -0
- package/dist/modules/media/service.js +89 -0
- package/dist/modules/orders/repository/index.d.ts +48 -0
- package/dist/modules/orders/repository/index.d.ts.map +1 -0
- package/dist/modules/orders/repository/index.js +199 -0
- package/dist/modules/orders/schema.d.ts +672 -0
- package/dist/modules/orders/schema.d.ts.map +1 -0
- package/dist/modules/orders/schema.js +63 -0
- package/dist/modules/orders/service.d.ts +85 -0
- package/dist/modules/orders/service.d.ts.map +1 -0
- package/dist/modules/orders/service.js +313 -0
- package/dist/modules/orders/stale-order-cleanup.d.ts +27 -0
- package/dist/modules/orders/stale-order-cleanup.d.ts.map +1 -0
- package/dist/modules/orders/stale-order-cleanup.js +55 -0
- package/dist/modules/organization/service.d.ts +53 -0
- package/dist/modules/organization/service.d.ts.map +1 -0
- package/dist/modules/organization/service.js +151 -0
- package/dist/modules/payments/adapter.d.ts +42 -0
- package/dist/modules/payments/adapter.d.ts.map +1 -0
- package/dist/modules/payments/adapter.js +1 -0
- package/dist/modules/payments/repository/index.d.ts +5 -0
- package/dist/modules/payments/repository/index.d.ts.map +1 -0
- package/dist/modules/payments/repository/index.js +1 -0
- package/dist/modules/payments/service.d.ts +23 -0
- package/dist/modules/payments/service.d.ts.map +1 -0
- package/dist/modules/payments/service.js +72 -0
- package/dist/modules/pricing/repository/index.d.ts +34 -0
- package/dist/modules/pricing/repository/index.d.ts.map +1 -0
- package/dist/modules/pricing/repository/index.js +176 -0
- package/dist/modules/pricing/schema.d.ts +565 -0
- package/dist/modules/pricing/schema.d.ts.map +1 -0
- package/dist/modules/pricing/schema.js +57 -0
- package/dist/modules/pricing/schemas.d.ts +37 -0
- package/dist/modules/pricing/schemas.d.ts.map +1 -0
- package/dist/modules/pricing/schemas.js +30 -0
- package/dist/modules/pricing/service.d.ts +62 -0
- package/dist/modules/pricing/service.d.ts.map +1 -0
- package/dist/modules/pricing/service.js +308 -0
- package/dist/modules/promotions/repository/index.d.ts +41 -0
- package/dist/modules/promotions/repository/index.d.ts.map +1 -0
- package/dist/modules/promotions/repository/index.js +204 -0
- package/dist/modules/promotions/schema.d.ts +427 -0
- package/dist/modules/promotions/schema.d.ts.map +1 -0
- package/dist/modules/promotions/schema.js +52 -0
- package/dist/modules/promotions/schemas.d.ts +33 -0
- package/dist/modules/promotions/schemas.d.ts.map +1 -0
- package/dist/modules/promotions/schemas.js +32 -0
- package/dist/modules/promotions/service.d.ts +85 -0
- package/dist/modules/promotions/service.d.ts.map +1 -0
- package/dist/modules/promotions/service.js +368 -0
- package/dist/modules/search/adapter.d.ts +51 -0
- package/dist/modules/search/adapter.d.ts.map +1 -0
- package/dist/modules/search/adapter.js +1 -0
- package/dist/modules/search/hooks.d.ts +8 -0
- package/dist/modules/search/hooks.d.ts.map +1 -0
- package/dist/modules/search/hooks.js +6 -0
- package/dist/modules/search/repository/index.d.ts +5 -0
- package/dist/modules/search/repository/index.d.ts.map +1 -0
- package/dist/modules/search/repository/index.js +1 -0
- package/dist/modules/search/service.d.ts +24 -0
- package/dist/modules/search/service.d.ts.map +1 -0
- package/dist/modules/search/service.js +217 -0
- package/dist/modules/shipping/calculator.d.ts +42 -0
- package/dist/modules/shipping/calculator.d.ts.map +1 -0
- package/dist/modules/shipping/calculator.js +91 -0
- package/dist/modules/shipping/repository/index.d.ts +5 -0
- package/dist/modules/shipping/repository/index.d.ts.map +1 -0
- package/dist/modules/shipping/repository/index.js +1 -0
- package/dist/modules/shipping/service.d.ts +28 -0
- package/dist/modules/shipping/service.d.ts.map +1 -0
- package/dist/modules/shipping/service.js +20 -0
- package/dist/modules/tax/adapter.d.ts +58 -0
- package/dist/modules/tax/adapter.d.ts.map +1 -0
- package/dist/modules/tax/adapter.js +1 -0
- package/dist/modules/tax/repository/index.d.ts +5 -0
- package/dist/modules/tax/repository/index.d.ts.map +1 -0
- package/dist/modules/tax/repository/index.js +1 -0
- package/dist/modules/tax/service.d.ts +19 -0
- package/dist/modules/tax/service.d.ts.map +1 -0
- package/dist/modules/tax/service.js +34 -0
- package/dist/modules/webhooks/hook.d.ts +13 -0
- package/dist/modules/webhooks/hook.d.ts.map +1 -0
- package/dist/modules/webhooks/hook.js +29 -0
- package/dist/modules/webhooks/repository/index.d.ts +40 -0
- package/dist/modules/webhooks/repository/index.d.ts.map +1 -0
- package/dist/modules/webhooks/repository/index.js +175 -0
- package/dist/modules/webhooks/schema.d.ts +404 -0
- package/dist/modules/webhooks/schema.d.ts.map +1 -0
- package/dist/modules/webhooks/schema.js +40 -0
- package/dist/modules/webhooks/service.d.ts +23 -0
- package/dist/modules/webhooks/service.d.ts.map +1 -0
- package/dist/modules/webhooks/service.js +92 -0
- package/dist/modules/webhooks/signing.d.ts +2 -0
- package/dist/modules/webhooks/signing.d.ts.map +1 -0
- package/dist/modules/webhooks/signing.js +5 -0
- package/dist/modules/webhooks/ssrf-guard.d.ts +19 -0
- package/dist/modules/webhooks/ssrf-guard.d.ts.map +1 -0
- package/dist/modules/webhooks/ssrf-guard.js +79 -0
- package/dist/modules/webhooks/tasks.d.ts +16 -0
- package/dist/modules/webhooks/tasks.d.ts.map +1 -0
- package/dist/modules/webhooks/tasks.js +35 -0
- package/dist/modules/webhooks/worker.d.ts +21 -0
- package/dist/modules/webhooks/worker.d.ts.map +1 -0
- package/dist/modules/webhooks/worker.js +113 -0
- package/dist/runtime/commerce.d.ts +110 -0
- package/dist/runtime/commerce.d.ts.map +1 -0
- package/dist/runtime/commerce.js +37 -0
- package/dist/runtime/kernel.d.ts +71 -0
- package/dist/runtime/kernel.d.ts.map +1 -0
- package/dist/runtime/kernel.js +306 -0
- package/dist/runtime/logger.d.ts +11 -0
- package/dist/runtime/logger.d.ts.map +1 -0
- package/dist/runtime/logger.js +32 -0
- package/dist/runtime/shutdown.d.ts +15 -0
- package/dist/runtime/shutdown.d.ts.map +1 -0
- package/dist/runtime/shutdown.js +34 -0
- package/dist/test-utils/create-pglite-adapter.d.ts +32 -0
- package/dist/test-utils/create-pglite-adapter.d.ts.map +1 -0
- package/dist/test-utils/create-pglite-adapter.js +107 -0
- package/dist/test-utils/create-plugin-test-app.d.ts +50 -0
- package/dist/test-utils/create-plugin-test-app.d.ts.map +1 -0
- package/dist/test-utils/create-plugin-test-app.js +74 -0
- package/dist/test-utils/create-repository-test-harness.d.ts +8 -0
- package/dist/test-utils/create-repository-test-harness.d.ts.map +1 -0
- package/dist/test-utils/create-repository-test-harness.js +7 -0
- package/dist/test-utils/create-test-config.d.ts +18 -0
- package/dist/test-utils/create-test-config.d.ts.map +1 -0
- package/dist/test-utils/create-test-config.js +172 -0
- package/dist/test-utils/create-test-kernel.d.ts +3 -0
- package/dist/test-utils/create-test-kernel.d.ts.map +1 -0
- package/dist/test-utils/create-test-kernel.js +5 -0
- package/dist/test-utils/create-test-plugin-context.d.ts +42 -0
- package/dist/test-utils/create-test-plugin-context.d.ts.map +1 -0
- package/dist/test-utils/create-test-plugin-context.js +46 -0
- package/dist/test-utils/rest-api-test-utils.d.ts +64 -0
- package/dist/test-utils/rest-api-test-utils.d.ts.map +1 -0
- package/dist/test-utils/rest-api-test-utils.js +207 -0
- package/dist/test-utils/test-actors.d.ts +15 -0
- package/dist/test-utils/test-actors.d.ts.map +1 -0
- package/dist/test-utils/test-actors.js +57 -0
- package/dist/test-utils/typed-hooks.d.ts +43 -0
- package/dist/test-utils/typed-hooks.d.ts.map +1 -0
- package/dist/test-utils/typed-hooks.js +35 -0
- package/dist/testing.d.ts +14 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +13 -0
- package/dist/types/commerce-types.d.ts +34 -0
- package/dist/types/commerce-types.d.ts.map +1 -0
- package/dist/types/commerce-types.js +1 -0
- package/dist/utils/id.d.ts +2 -0
- package/dist/utils/id.d.ts.map +1 -0
- package/dist/utils/id.js +3 -0
- package/dist/utils/logger.d.ts +3 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +16 -0
- package/dist/utils/pagination.d.ts +11 -0
- package/dist/utils/pagination.d.ts.map +1 -0
- package/dist/utils/pagination.js +15 -0
- package/package.json +2 -2
- package/src/auth/setup.ts +26 -0
- package/src/interfaces/rest/routes/customers.ts +7 -1
- package/src/interfaces/rest/routes/inventory.ts +4 -1
- package/src/interfaces/rest/routes/promotions.ts +12 -9
- package/src/interfaces/rest/schemas/promotions.ts +10 -4
- package/src/modules/catalog/service.ts +19 -0
- package/src/modules/promotions/service.ts +32 -0
- package/src/runtime/commerce.ts +1 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { RouteConfig } from "@hono/zod-openapi";
|
|
2
|
+
import type { PluginDb } from "../database/plugin-types.js";
|
|
3
|
+
import type { CommerceConfig, CommercePlugin, MCPTool } from "../../config/types.js";
|
|
4
|
+
export interface PluginLogger {
|
|
5
|
+
info(message: string, data?: unknown): void;
|
|
6
|
+
warn(message: string, data?: unknown): void;
|
|
7
|
+
error(message: string, data?: unknown): void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Plugin route registration. Supports two modes:
|
|
11
|
+
*
|
|
12
|
+
* 1. Legacy: { method, path, handler } — works, but invisible to OpenAPI spec.
|
|
13
|
+
* 2. OpenAPI: { openapi, handler } — validated by Zod, appears in /api/doc.
|
|
14
|
+
*
|
|
15
|
+
* Use mode 2 for any route that accepts a request body or returns structured data.
|
|
16
|
+
* Mode 1 is acceptable for simple routes (health checks, redirects, file serving).
|
|
17
|
+
*/
|
|
18
|
+
export type PluginRouteRegistration = {
|
|
19
|
+
method: string;
|
|
20
|
+
path: string;
|
|
21
|
+
handler: (...args: unknown[]) => unknown;
|
|
22
|
+
} | {
|
|
23
|
+
openapi: RouteConfig;
|
|
24
|
+
handler: (...args: unknown[]) => unknown;
|
|
25
|
+
};
|
|
26
|
+
export interface PluginHookRegistration {
|
|
27
|
+
key: string;
|
|
28
|
+
handler: (...args: unknown[]) => unknown;
|
|
29
|
+
}
|
|
30
|
+
export interface PluginContext {
|
|
31
|
+
config: CommerceConfig;
|
|
32
|
+
services: Record<string, unknown>;
|
|
33
|
+
database: {
|
|
34
|
+
/** Drizzle database instance — use for queries, inserts, updates, deletes */
|
|
35
|
+
db: PluginDb;
|
|
36
|
+
transaction<T>(fn: (tx: PluginDb) => Promise<T>): Promise<T>;
|
|
37
|
+
};
|
|
38
|
+
logger: PluginLogger;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Permission scope declared by a plugin.
|
|
42
|
+
* Collected at boot time and available via GET /api/admin/permissions.
|
|
43
|
+
*/
|
|
44
|
+
export interface PluginPermission {
|
|
45
|
+
/** Permission scope string, e.g., "wishlist:write", "marketplace:admin" */
|
|
46
|
+
scope: string;
|
|
47
|
+
/** Human-readable description for admin UIs */
|
|
48
|
+
description: string;
|
|
49
|
+
}
|
|
50
|
+
export interface CommercePluginManifest {
|
|
51
|
+
id: string;
|
|
52
|
+
version: string;
|
|
53
|
+
/**
|
|
54
|
+
* IDs of plugins that must be registered before this one.
|
|
55
|
+
* If any required plugin is missing at registration time,
|
|
56
|
+
* defineCommercePlugin will throw with a clear message.
|
|
57
|
+
*/
|
|
58
|
+
requires?: string[];
|
|
59
|
+
/**
|
|
60
|
+
* Permission scopes this plugin introduces.
|
|
61
|
+
* Used by admin UIs to build role editors, and validated at boot time
|
|
62
|
+
* against .permission() calls in routes.
|
|
63
|
+
*/
|
|
64
|
+
permissions?: PluginPermission[];
|
|
65
|
+
/**
|
|
66
|
+
* Returns Drizzle `pgTable` objects that this plugin needs.
|
|
67
|
+
* These are collected into `config.customSchemas[]` and merged with core
|
|
68
|
+
* schema by `buildSchema(config)`. Each key becomes a named export in the
|
|
69
|
+
* merged schema; names must not collide with core table exports.
|
|
70
|
+
*/
|
|
71
|
+
schema?: () => Record<string, unknown>;
|
|
72
|
+
hooks?: () => PluginHookRegistration[];
|
|
73
|
+
routes?: (ctx: PluginContext) => PluginRouteRegistration[];
|
|
74
|
+
mcpTools?: (ctx: PluginContext) => MCPTool[];
|
|
75
|
+
analyticsModels?: () => unknown[];
|
|
76
|
+
}
|
|
77
|
+
export declare const _registeredPlugins: Set<string>;
|
|
78
|
+
/** @internal — called by defineConfig() before applying plugins */
|
|
79
|
+
export declare function _resetRegisteredPlugins(): void;
|
|
80
|
+
/**
|
|
81
|
+
* Converts a plugin manifest into a config transform function.
|
|
82
|
+
*
|
|
83
|
+
* - `schema` → pushed into `config.customSchemas`
|
|
84
|
+
* - `hooks` → merged into `config.hooks` flat map
|
|
85
|
+
* - `routes` → chained onto `config.routes` (evaluated at boot with kernel)
|
|
86
|
+
* - `mcpTools` → chained onto `config.mcpTools` (evaluated at boot with kernel)
|
|
87
|
+
* - `analyticsModels` → pushed into `config.analytics.models`
|
|
88
|
+
*/
|
|
89
|
+
export declare function defineCommercePlugin(manifest: CommercePluginManifest): CommercePlugin;
|
|
90
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/kernel/plugin/manifest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,OAAO,EACR,MAAM,uBAAuB,CAAC;AAI/B,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9C;AAID;;;;;;;;GAQG;AACH,MAAM,MAAM,uBAAuB,GAC/B;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAA;CAAE,GAC1E;IAAE,OAAO,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAA;CAAE,CAAC;AAEvE,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;CAC1C;AAID,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,cAAc,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,QAAQ,EAAE;QACR,6EAA6E;QAC7E,EAAE,EAAE,QAAQ,CAAC;QACb,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;KAC9D,CAAC;IACF,MAAM,EAAE,YAAY,CAAC;CACtB;AAID;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,2EAA2E;IAC3E,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB;;;;OAIG;IACH,WAAW,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACjC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,KAAK,CAAC,EAAE,MAAM,sBAAsB,EAAE,CAAC;IACvC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,aAAa,KAAK,uBAAuB,EAAE,CAAC;IAC3D,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,aAAa,KAAK,OAAO,EAAE,CAAC;IAC7C,eAAe,CAAC,EAAE,MAAM,OAAO,EAAE,CAAC;CACnC;AAKD,eAAO,MAAM,kBAAkB,aAAoB,CAAC;AAEpD,mEAAmE;AACnE,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,sBAAsB,GAC/B,cAAc,CA6JhB"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// ─── Plugin Dependency Tracking ──────────────────────────────────────
|
|
2
|
+
// Accumulates plugin IDs as they register during defineConfig().
|
|
3
|
+
// Reset at the start of each defineConfig() call.
|
|
4
|
+
export const _registeredPlugins = new Set();
|
|
5
|
+
/** @internal — called by defineConfig() before applying plugins */
|
|
6
|
+
export function _resetRegisteredPlugins() {
|
|
7
|
+
_registeredPlugins.clear();
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Converts a plugin manifest into a config transform function.
|
|
11
|
+
*
|
|
12
|
+
* - `schema` → pushed into `config.customSchemas`
|
|
13
|
+
* - `hooks` → merged into `config.hooks` flat map
|
|
14
|
+
* - `routes` → chained onto `config.routes` (evaluated at boot with kernel)
|
|
15
|
+
* - `mcpTools` → chained onto `config.mcpTools` (evaluated at boot with kernel)
|
|
16
|
+
* - `analyticsModels` → pushed into `config.analytics.models`
|
|
17
|
+
*/
|
|
18
|
+
export function defineCommercePlugin(manifest) {
|
|
19
|
+
return (config) => {
|
|
20
|
+
// ── Dependency check ───────────────────────────────────────────
|
|
21
|
+
// In test/development, warn instead of throwing so plugins can be
|
|
22
|
+
// tested in isolation via createPluginTestApp() without installing
|
|
23
|
+
// all dependencies. In production, this is a hard error.
|
|
24
|
+
if (manifest.requires) {
|
|
25
|
+
for (const dep of manifest.requires) {
|
|
26
|
+
if (!_registeredPlugins.has(dep)) {
|
|
27
|
+
const msg = `Plugin "${manifest.id}" requires "${dep}" to be installed before it. Add ${dep}Plugin() before ${manifest.id}Plugin() in your config.plugins array.`;
|
|
28
|
+
if (process.env.NODE_ENV === "production") {
|
|
29
|
+
throw new Error(msg);
|
|
30
|
+
}
|
|
31
|
+
// Non-production: log warning but continue (allows isolated testing)
|
|
32
|
+
console.warn(`[plugin:${manifest.id}] WARNING: ${msg}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
_registeredPlugins.add(manifest.id);
|
|
37
|
+
let result = { ...config };
|
|
38
|
+
// 1. Schema — push into customSchemas for kernel to register
|
|
39
|
+
if (manifest.schema) {
|
|
40
|
+
const schemas = manifest.schema();
|
|
41
|
+
result = {
|
|
42
|
+
...result,
|
|
43
|
+
customSchemas: [...(result.customSchemas ?? []), schemas],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
// 2. Hooks — merge into flat hooks map (kernel registers at boot)
|
|
47
|
+
if (manifest.hooks) {
|
|
48
|
+
const registrations = manifest.hooks();
|
|
49
|
+
const hookMap = {
|
|
50
|
+
...(result.hooks ?? {}),
|
|
51
|
+
};
|
|
52
|
+
for (const reg of registrations) {
|
|
53
|
+
hookMap[reg.key] = [...(hookMap[reg.key] ?? []), reg.handler];
|
|
54
|
+
}
|
|
55
|
+
result = { ...result, hooks: hookMap };
|
|
56
|
+
}
|
|
57
|
+
// 3. Routes — chain onto config.routes (deferred: needs kernel at boot)
|
|
58
|
+
if (manifest.routes) {
|
|
59
|
+
const existingRoutes = result.routes;
|
|
60
|
+
const pluginRoutes = manifest.routes;
|
|
61
|
+
result = {
|
|
62
|
+
...result,
|
|
63
|
+
routes: (app, kernel) => {
|
|
64
|
+
existingRoutes?.(app, kernel);
|
|
65
|
+
const k = kernel;
|
|
66
|
+
// Narrow DatabaseAdapter<unknown> → PluginContext.database once here.
|
|
67
|
+
// All plugin code receives typed PluginDb — no casts downstream.
|
|
68
|
+
const regs = pluginRoutes({
|
|
69
|
+
config: k.config,
|
|
70
|
+
services: k.services,
|
|
71
|
+
database: {
|
|
72
|
+
db: k.database.db,
|
|
73
|
+
transaction: k.database.transaction,
|
|
74
|
+
},
|
|
75
|
+
logger: k.logger,
|
|
76
|
+
});
|
|
77
|
+
for (const route of regs) {
|
|
78
|
+
// ── Error boundary: wrap handler with plugin context ──
|
|
79
|
+
const originalHandler = route.handler;
|
|
80
|
+
const wrappedHandler = async (...args) => {
|
|
81
|
+
try {
|
|
82
|
+
return await originalHandler(...args);
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
// Try to extract logger from Hono context
|
|
86
|
+
const c = args[0];
|
|
87
|
+
const logger = c?.get?.("logger");
|
|
88
|
+
logger?.error?.({ err, plugin: manifest.id }, `[plugin:${manifest.id}] route handler error`);
|
|
89
|
+
throw err; // re-throw so global handler still catches
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
if ("openapi" in route) {
|
|
93
|
+
// OpenAPI route: validated by Zod, appears in /api/doc
|
|
94
|
+
// Hono type interop — OpenAPIHono.openapi() expects strict RouteConfig+Handler
|
|
95
|
+
// generics that can't be statically resolved for dynamic plugin routes.
|
|
96
|
+
// @ts-expect-error -- dynamic plugin routes cannot satisfy Hono's strict handler generics
|
|
97
|
+
app.openapi(route.openapi, wrappedHandler);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
// Legacy route: raw handler, invisible to OpenAPI spec.
|
|
101
|
+
// Explicit dispatch avoids casting Hono to a Record.
|
|
102
|
+
// Handler cast is a single `as any` (Hono's overloaded method
|
|
103
|
+
// signatures can't unify with our generic handler shape).
|
|
104
|
+
const h = wrappedHandler;
|
|
105
|
+
switch (route.method.toLowerCase()) {
|
|
106
|
+
case "get":
|
|
107
|
+
app.get(route.path, h);
|
|
108
|
+
break;
|
|
109
|
+
case "post":
|
|
110
|
+
app.post(route.path, h);
|
|
111
|
+
break;
|
|
112
|
+
case "put":
|
|
113
|
+
app.put(route.path, h);
|
|
114
|
+
break;
|
|
115
|
+
case "patch":
|
|
116
|
+
app.patch(route.path, h);
|
|
117
|
+
break;
|
|
118
|
+
case "delete":
|
|
119
|
+
app.delete(route.path, h);
|
|
120
|
+
break;
|
|
121
|
+
case "options":
|
|
122
|
+
app.options(route.path, h);
|
|
123
|
+
break;
|
|
124
|
+
default:
|
|
125
|
+
console.warn(`[plugin:${manifest.id}] unsupported HTTP method "${route.method}" for ${route.path}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
// 4. MCP Tools — chain onto config.mcpTools (deferred: needs kernel)
|
|
133
|
+
if (manifest.mcpTools) {
|
|
134
|
+
const existingMcpTools = result.mcpTools;
|
|
135
|
+
const pluginMcpTools = manifest.mcpTools;
|
|
136
|
+
result = {
|
|
137
|
+
...result,
|
|
138
|
+
mcpTools: (kernel) => {
|
|
139
|
+
const existing = existingMcpTools?.(kernel) ?? [];
|
|
140
|
+
const k = kernel;
|
|
141
|
+
return [
|
|
142
|
+
...existing,
|
|
143
|
+
...pluginMcpTools({
|
|
144
|
+
config: k.config,
|
|
145
|
+
services: k.services,
|
|
146
|
+
database: {
|
|
147
|
+
db: k.database.db,
|
|
148
|
+
transaction: k.database.transaction,
|
|
149
|
+
},
|
|
150
|
+
logger: k.logger,
|
|
151
|
+
}),
|
|
152
|
+
];
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
// 5. Analytics models — push into config.analytics.models
|
|
157
|
+
if (manifest.analyticsModels) {
|
|
158
|
+
const models = manifest.analyticsModels();
|
|
159
|
+
result = {
|
|
160
|
+
...result,
|
|
161
|
+
analytics: {
|
|
162
|
+
...result.analytics,
|
|
163
|
+
models: [...(result.analytics?.models ?? []), ...models],
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
return result;
|
|
168
|
+
};
|
|
169
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { QueryRegistry } from "./registry.js";
|
|
2
|
+
export interface QueryInput {
|
|
3
|
+
entity: string;
|
|
4
|
+
id?: string;
|
|
5
|
+
filters?: Record<string, unknown>;
|
|
6
|
+
include?: string[];
|
|
7
|
+
pagination?: {
|
|
8
|
+
limit?: number;
|
|
9
|
+
offset?: number;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface QueryResult<T = Record<string, unknown>> {
|
|
13
|
+
data: T[];
|
|
14
|
+
total?: number | undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Executes a query against the registry, resolving includes via
|
|
18
|
+
* batched dataloader-style fetches (one WHERE IN per relation).
|
|
19
|
+
*/
|
|
20
|
+
export declare function executeQuery<T = Record<string, unknown>>(registry: QueryRegistry, services: Record<string, unknown>, input: QueryInput): Promise<QueryResult<T>>;
|
|
21
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/kernel/query/executor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EAGd,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAClD;AAED,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACtD,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5D,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,KAAK,EAAE,UAAU,GAChB,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAgDzB"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { CommerceNotFoundError } from "../errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* Executes a query against the registry, resolving includes via
|
|
4
|
+
* batched dataloader-style fetches (one WHERE IN per relation).
|
|
5
|
+
*/
|
|
6
|
+
export async function executeQuery(registry, services, input) {
|
|
7
|
+
const definition = registry.get(input.entity);
|
|
8
|
+
if (!definition) {
|
|
9
|
+
throw new CommerceNotFoundError(`No entity registered with name "${input.entity}".`);
|
|
10
|
+
}
|
|
11
|
+
const service = services[definition.service];
|
|
12
|
+
// 1. Fetch primary records
|
|
13
|
+
let rows;
|
|
14
|
+
let total;
|
|
15
|
+
if (input.id) {
|
|
16
|
+
const result = (await service[definition.getByIdMethod](input.id));
|
|
17
|
+
const value = result?.value ?? result;
|
|
18
|
+
rows = value != null ? [value] : [];
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const result = (await service[definition.listMethod](input.filters ?? {}, input.pagination));
|
|
22
|
+
const resolved = result?.value ?? result;
|
|
23
|
+
if (resolved && typeof resolved === "object" && "items" in resolved) {
|
|
24
|
+
rows = (resolved.items ?? []);
|
|
25
|
+
total = resolved.total;
|
|
26
|
+
}
|
|
27
|
+
else if (Array.isArray(resolved)) {
|
|
28
|
+
rows = resolved;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
rows = [];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// 2. Resolve includes
|
|
35
|
+
if (input.include?.length) {
|
|
36
|
+
await resolveIncludes(rows, input.include, definition, services, registry);
|
|
37
|
+
}
|
|
38
|
+
return { data: rows, total };
|
|
39
|
+
}
|
|
40
|
+
async function resolveIncludes(rows, includes, definition, services, registry) {
|
|
41
|
+
// Group includes by top-level segment
|
|
42
|
+
const topLevel = new Map();
|
|
43
|
+
for (const path of includes) {
|
|
44
|
+
const dot = path.indexOf(".");
|
|
45
|
+
if (dot === -1) {
|
|
46
|
+
if (!topLevel.has(path))
|
|
47
|
+
topLevel.set(path, []);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
const parent = path.substring(0, dot);
|
|
51
|
+
const child = path.substring(dot + 1);
|
|
52
|
+
const existing = topLevel.get(parent) ?? [];
|
|
53
|
+
existing.push(child);
|
|
54
|
+
topLevel.set(parent, existing);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
for (const [relationName, nestedIncludes] of topLevel) {
|
|
58
|
+
const relation = definition.relations[relationName];
|
|
59
|
+
if (!relation)
|
|
60
|
+
continue;
|
|
61
|
+
const targetService = services[relation.targetService];
|
|
62
|
+
if (!targetService)
|
|
63
|
+
continue;
|
|
64
|
+
// Collect foreign key values (deduplicated)
|
|
65
|
+
const ids = [
|
|
66
|
+
...new Set(rows
|
|
67
|
+
.map((r) => r[relation.foreignKey])
|
|
68
|
+
.filter((v) => v != null && typeof v === "string")),
|
|
69
|
+
];
|
|
70
|
+
if (ids.length === 0)
|
|
71
|
+
continue;
|
|
72
|
+
// One batched query
|
|
73
|
+
const batchFn = targetService[relation.batchMethod];
|
|
74
|
+
if (!batchFn)
|
|
75
|
+
continue;
|
|
76
|
+
const relatedResult = await batchFn(ids);
|
|
77
|
+
const relatedRows = extractRows(relatedResult);
|
|
78
|
+
// Build lookup
|
|
79
|
+
const map = new Map();
|
|
80
|
+
for (const related of relatedRows) {
|
|
81
|
+
const rec = related;
|
|
82
|
+
if (relation.isList) {
|
|
83
|
+
const key = rec[relation.foreignKey];
|
|
84
|
+
if (!map.has(key))
|
|
85
|
+
map.set(key, []);
|
|
86
|
+
map.get(key).push(rec);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
map.set(rec["id"], rec);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Attach to parent rows
|
|
93
|
+
for (const row of rows) {
|
|
94
|
+
const fkValue = row[relation.foreignKey];
|
|
95
|
+
if (!fkValue)
|
|
96
|
+
continue;
|
|
97
|
+
row[relation.attachAs] =
|
|
98
|
+
map.get(fkValue) ?? (relation.isList ? [] : null);
|
|
99
|
+
}
|
|
100
|
+
// Resolve nested includes
|
|
101
|
+
if (nestedIncludes.length > 0) {
|
|
102
|
+
const targetDef = registry.get(relation.targetService);
|
|
103
|
+
if (targetDef) {
|
|
104
|
+
const nestedRows = relation.isList
|
|
105
|
+
? rows.flatMap((r) => r[relation.attachAs] ?? [])
|
|
106
|
+
: rows
|
|
107
|
+
.map((r) => r[relation.attachAs])
|
|
108
|
+
.filter(Boolean);
|
|
109
|
+
await resolveIncludes(nestedRows, nestedIncludes, targetDef, services, registry);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function extractRows(result) {
|
|
115
|
+
if (Array.isArray(result))
|
|
116
|
+
return result;
|
|
117
|
+
if (result && typeof result === "object") {
|
|
118
|
+
const r = result;
|
|
119
|
+
if (r.value != null) {
|
|
120
|
+
if (Array.isArray(r.value))
|
|
121
|
+
return r.value;
|
|
122
|
+
if (typeof r.value === "object" && "items" in r.value) {
|
|
123
|
+
return r.value.items;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return [];
|
|
128
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
* Defines an entity that can be queried via kernel.query().
|
|
14
|
+
*/
|
|
15
|
+
export interface EntityDefinition {
|
|
16
|
+
service: string;
|
|
17
|
+
getByIdMethod: string;
|
|
18
|
+
listMethod: string;
|
|
19
|
+
relations: Record<string, RelationDefinition>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Registry of queryable entities and their relations.
|
|
23
|
+
* Modules register their entities at kernel boot.
|
|
24
|
+
* Plugins can register additional entities.
|
|
25
|
+
*/
|
|
26
|
+
export declare class QueryRegistry {
|
|
27
|
+
private entities;
|
|
28
|
+
register(name: string, definition: EntityDefinition): void;
|
|
29
|
+
get(name: string): EntityDefinition | undefined;
|
|
30
|
+
has(name: string): boolean;
|
|
31
|
+
listEntities(): string[];
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/kernel/query/registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;CAC/C;AAED;;;;GAIG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAuC;IAEvD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,gBAAgB,GAAG,IAAI;IAI1D,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAI/C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,YAAY,IAAI,MAAM,EAAE;CAGzB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry of queryable entities and their relations.
|
|
3
|
+
* Modules register their entities at kernel boot.
|
|
4
|
+
* Plugins can register additional entities.
|
|
5
|
+
*/
|
|
6
|
+
export class QueryRegistry {
|
|
7
|
+
entities = new Map();
|
|
8
|
+
register(name, definition) {
|
|
9
|
+
this.entities.set(name, definition);
|
|
10
|
+
}
|
|
11
|
+
get(name) {
|
|
12
|
+
return this.entities.get(name);
|
|
13
|
+
}
|
|
14
|
+
has(name) {
|
|
15
|
+
return this.entities.has(name);
|
|
16
|
+
}
|
|
17
|
+
listEntities() {
|
|
18
|
+
return [...this.entities.keys()];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { CommerceError } from "./errors.js";
|
|
2
|
+
export type Result<T, E = CommerceError> = {
|
|
3
|
+
ok: true;
|
|
4
|
+
value: T;
|
|
5
|
+
meta?: Record<string, unknown>;
|
|
6
|
+
} | {
|
|
7
|
+
ok: false;
|
|
8
|
+
error: E;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Simplified Result types for plugin services.
|
|
12
|
+
* Plugin services return `PluginResult<T>` instead of `Result<T, CommerceError>`.
|
|
13
|
+
* This matches the `{ ok: true; value: T } | { ok: false; error: string }` pattern
|
|
14
|
+
* that every plugin has been copy-pasting.
|
|
15
|
+
*/
|
|
16
|
+
export type PluginResult<T> = {
|
|
17
|
+
ok: true;
|
|
18
|
+
value: T;
|
|
19
|
+
} | {
|
|
20
|
+
ok: false;
|
|
21
|
+
error: string;
|
|
22
|
+
code?: string;
|
|
23
|
+
};
|
|
24
|
+
export type PluginResultErr = {
|
|
25
|
+
ok: false;
|
|
26
|
+
error: string;
|
|
27
|
+
code?: string;
|
|
28
|
+
};
|
|
29
|
+
export declare function Ok<T>(value: T, meta?: Record<string, unknown>): Result<T, never>;
|
|
30
|
+
export declare function Err<E>(error: E): Result<never, E>;
|
|
31
|
+
/**
|
|
32
|
+
* String-based Err for plugin services.
|
|
33
|
+
* Usage: `return PluginErr("Not found", "NOT_FOUND")`
|
|
34
|
+
*/
|
|
35
|
+
export declare function PluginErr(error: string, code?: string): PluginResultErr;
|
|
36
|
+
//# sourceMappingURL=result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../src/kernel/result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,aAAa,IACnC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GACtD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC;AAE5B;;;;;GAKG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AACnG,MAAM,MAAM,eAAe,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1E,wBAAgB,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAKhF;AAED,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAEjD;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,eAAe,CAEvE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function Ok(value, meta) {
|
|
2
|
+
if (meta !== undefined) {
|
|
3
|
+
return { ok: true, value, meta };
|
|
4
|
+
}
|
|
5
|
+
return { ok: true, value };
|
|
6
|
+
}
|
|
7
|
+
export function Err(error) {
|
|
8
|
+
return { ok: false, error };
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* String-based Err for plugin services.
|
|
12
|
+
* Usage: `return PluginErr("Not found", "NOT_FOUND")`
|
|
13
|
+
*/
|
|
14
|
+
export function PluginErr(error, code) {
|
|
15
|
+
return code ? { ok: false, error, code } : { ok: false, error };
|
|
16
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PgColumnBuilderBase } from "drizzle-orm/pg-core";
|
|
2
|
+
/**
|
|
3
|
+
* Options for modules that support schema extension via extra columns.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const catalogModule = createCatalogModule({
|
|
8
|
+
* extraColumns: (base) => ({
|
|
9
|
+
* supplierCode: text("supplier_code"),
|
|
10
|
+
* gtin: text("gtin").unique(),
|
|
11
|
+
* }),
|
|
12
|
+
* });
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export interface ExtraColumnsOption<TBaseColumns extends Record<string, unknown>> {
|
|
16
|
+
extraColumns?: (baseColumns: TBaseColumns) => Record<string, PgColumnBuilderBase>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Merges base columns with optional extra columns from configuration.
|
|
20
|
+
* Returns the combined column definitions for use in `pgTable()`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function mergeExtraColumns<TBase extends Record<string, unknown>>(baseColumns: TBase, extraColumnsFn?: (base: TBase) => Record<string, PgColumnBuilderBase>): TBase & Record<string, PgColumnBuilderBase>;
|
|
23
|
+
//# sourceMappingURL=extra-columns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extra-columns.d.ts","sourceRoot":"","sources":["../../../src/kernel/schema/extra-columns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,kBAAkB,CAAC,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC9E,YAAY,CAAC,EAAE,CACb,WAAW,EAAE,YAAY,KACtB,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;CAC1C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAErC,WAAW,EAAE,KAAK,EAClB,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,GACpE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAI7C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merges base columns with optional extra columns from configuration.
|
|
3
|
+
* Returns the combined column definitions for use in `pgTable()`.
|
|
4
|
+
*/
|
|
5
|
+
export function mergeExtraColumns(baseColumns, extraColumnsFn) {
|
|
6
|
+
if (!extraColumnsFn)
|
|
7
|
+
return baseColumns;
|
|
8
|
+
const extra = extraColumnsFn(baseColumns);
|
|
9
|
+
return { ...baseColumns, ...extra };
|
|
10
|
+
}
|