@open-mercato/cli 0.9.1-develop.7574.1.837288eec1 → 0.10.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/.turbo/turbo-build.log +12 -2
- package/build.mjs +1 -0
- package/dist/agentic/claude-code/mcp.json.example +5 -1
- package/dist/agentic/codex/mcp.json.example +3 -0
- package/dist/agentic/cursor/mcp.json.example +4 -1
- package/dist/agentic/github-copilot/mcp.json.example +5 -1
- package/dist/agentic/guides/ai-workflows.md +1 -0
- package/dist/agentic/guides/architecture.md +7 -5
- package/dist/agentic/guides/module-facts.json +17621 -2604
- package/dist/agentic/guides/module-facts.v2.json +17710 -2604
- package/dist/agentic/guides/module-tool.md +21 -0
- package/dist/agentic/guides/modules/agent_orchestrator/acl-features.md +2 -1
- package/dist/agentic/guides/modules/agent_orchestrator/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/agent_orchestrator/backend-pages.md +3 -0
- package/dist/agentic/guides/modules/agent_orchestrator/cli-commands.md +4 -0
- package/dist/agentic/guides/modules/agent_orchestrator/contribution-resolutions.md +6 -0
- package/dist/agentic/guides/modules/agent_orchestrator/di-registrations-rich.md +32 -32
- package/dist/agentic/guides/modules/agent_orchestrator/di-service-tokens.md +14 -14
- package/dist/agentic/guides/modules/agent_orchestrator/domain-commands.md +3 -0
- package/dist/agentic/guides/modules/agent_orchestrator/events.md +30 -29
- package/dist/agentic/guides/modules/agent_orchestrator/exact-override-targets.md +104 -35
- package/dist/agentic/guides/modules/agent_orchestrator/index.md +17 -6
- package/dist/agentic/guides/modules/agent_orchestrator/setup.md +1 -1
- package/dist/agentic/guides/modules/agent_orchestrator/umes-contributions.md +6 -0
- package/dist/agentic/guides/modules/agent_orchestrator/umes-hosts.md +2 -1
- package/dist/agentic/guides/modules/agent_orchestrator/workers.md +2 -0
- package/dist/agentic/guides/modules/ai_assistant/acl-features.md +4 -1
- package/dist/agentic/guides/modules/ai_assistant/ai-tools-mcp-capabilities.md +1 -0
- package/dist/agentic/guides/modules/ai_assistant/backend-pages.md +4 -0
- package/dist/agentic/guides/modules/ai_assistant/cli-commands.md +1 -0
- package/dist/agentic/guides/modules/ai_assistant/contribution-resolutions.md +3 -0
- package/dist/agentic/guides/modules/ai_assistant/di-registrations-rich.md +5 -3
- package/dist/agentic/guides/modules/ai_assistant/di-service-tokens.md +4 -2
- package/dist/agentic/guides/modules/ai_assistant/encryption.md +3 -0
- package/dist/agentic/guides/modules/ai_assistant/entities.md +3 -0
- package/dist/agentic/guides/modules/ai_assistant/events.md +9 -8
- package/dist/agentic/guides/modules/ai_assistant/exact-override-targets.md +23 -6
- package/dist/agentic/guides/modules/ai_assistant/index.md +9 -9
- package/dist/agentic/guides/modules/ai_assistant/notifications.md +1 -0
- package/dist/agentic/guides/modules/ai_assistant/setup.md +1 -1
- package/dist/agentic/guides/modules/ai_assistant/umes-contributions.md +3 -0
- package/dist/agentic/guides/modules/ai_assistant/umes-hosts.md +4 -0
- package/dist/agentic/guides/modules/ai_assistant/workers.md +2 -1
- package/dist/agentic/guides/modules/api_docs/index.md +1 -1
- package/dist/agentic/guides/modules/api_keys/index.md +1 -1
- package/dist/agentic/guides/modules/attachments/active-extension-bindings.md +12 -0
- package/dist/agentic/guides/modules/attachments/ai-tools-mcp-capabilities.md +11 -0
- package/dist/agentic/guides/modules/attachments/backend-pages.md +1 -0
- package/dist/agentic/guides/modules/attachments/cli-commands.md +1 -0
- package/dist/agentic/guides/modules/attachments/contribution-resolutions.md +13 -0
- package/dist/agentic/guides/modules/attachments/di-registrations-rich.md +6 -6
- package/dist/agentic/guides/modules/attachments/di-service-tokens.md +5 -5
- package/dist/agentic/guides/modules/attachments/domain-commands.md +11 -0
- package/dist/agentic/guides/modules/attachments/encryption.md +12 -0
- package/dist/agentic/guides/modules/attachments/entities.md +2 -0
- package/dist/agentic/guides/modules/attachments/events.md +3 -3
- package/dist/agentic/guides/modules/attachments/exact-override-targets.md +17 -7
- package/dist/agentic/guides/modules/attachments/generator-plugins.md +11 -0
- package/dist/agentic/guides/modules/attachments/index.md +13 -5
- package/dist/agentic/guides/modules/attachments/search-entities.md +11 -0
- package/dist/agentic/guides/modules/attachments/setup.md +1 -1
- package/dist/agentic/guides/modules/attachments/umes-contributions.md +13 -0
- package/dist/agentic/guides/modules/attachments/umes-hosts.md +4 -0
- package/dist/agentic/guides/modules/attachments/workers.md +2 -0
- package/dist/agentic/guides/modules/audit_logs/active-extension-bindings.md +11 -0
- package/dist/agentic/guides/modules/audit_logs/incoming-installed-contributions.md +12 -0
- package/dist/agentic/guides/modules/audit_logs/index.md +4 -2
- package/dist/agentic/guides/modules/auth/events.md +12 -12
- package/dist/agentic/guides/modules/auth/index.md +1 -1
- package/dist/agentic/guides/modules/availability/events.md +3 -3
- package/dist/agentic/guides/modules/availability/index.md +1 -1
- package/dist/agentic/guides/modules/business_rules/events.md +1 -1
- package/dist/agentic/guides/modules/business_rules/index.md +1 -1
- package/dist/agentic/guides/modules/carrier_inpost/acl-features.md +12 -0
- package/dist/agentic/guides/modules/carrier_inpost/contribution-resolutions.md +13 -0
- package/dist/agentic/guides/modules/carrier_inpost/di-registrations-rich.md +11 -0
- package/dist/agentic/guides/modules/carrier_inpost/exact-override-targets.md +16 -0
- package/dist/agentic/guides/modules/carrier_inpost/index.md +18 -0
- package/dist/agentic/guides/modules/carrier_inpost/owned-contract-module-metadata.md +11 -0
- package/dist/agentic/guides/modules/carrier_inpost/setup.md +11 -0
- package/dist/agentic/guides/modules/carrier_inpost/umes-contributions.md +13 -0
- package/dist/agentic/guides/modules/cart/acl-features.md +19 -0
- package/dist/agentic/guides/modules/cart/contribution-resolutions.md +24 -0
- package/dist/agentic/guides/modules/cart/di-registrations-rich.md +11 -0
- package/dist/agentic/guides/modules/cart/di-service-tokens.md +11 -0
- package/dist/agentic/guides/modules/cart/domain-commands.md +24 -0
- package/dist/agentic/guides/modules/cart/encryption.md +11 -0
- package/dist/agentic/guides/modules/cart/entities.md +15 -0
- package/dist/agentic/guides/modules/cart/events.md +35 -0
- package/dist/agentic/guides/modules/cart/exact-override-targets.md +27 -0
- package/dist/agentic/guides/modules/cart/index.md +25 -0
- package/dist/agentic/guides/modules/cart/owned-contract-module-metadata.md +11 -0
- package/dist/agentic/guides/modules/cart/setup.md +11 -0
- package/dist/agentic/guides/modules/cart/umes-contributions.md +24 -0
- package/dist/agentic/guides/modules/cart/umes-hosts.md +40 -0
- package/dist/agentic/guides/modules/cart/workers.md +14 -0
- package/dist/agentic/guides/modules/catalog/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/catalog/di-registrations-rich.md +7 -5
- package/dist/agentic/guides/modules/catalog/di-service-tokens.md +4 -2
- package/dist/agentic/guides/modules/catalog/events.md +18 -18
- package/dist/agentic/guides/modules/catalog/exact-override-targets.md +7 -5
- package/dist/agentic/guides/modules/catalog/index.md +2 -2
- package/dist/agentic/guides/modules/catalog/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
- package/dist/agentic/guides/modules/channel_discord/index.md +1 -1
- package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
- package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
- package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
- package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
- package/dist/agentic/guides/modules/channel_resend/index.md +1 -1
- package/dist/agentic/guides/modules/channel_ses/index.md +1 -1
- package/dist/agentic/guides/modules/channel_smtp/acl-features.md +12 -0
- package/dist/agentic/guides/modules/channel_smtp/contribution-resolutions.md +11 -0
- package/dist/agentic/guides/modules/channel_smtp/di-registrations-rich.md +12 -0
- package/dist/agentic/guides/modules/channel_smtp/exact-override-targets.md +16 -0
- package/dist/agentic/guides/modules/channel_smtp/index.md +18 -0
- package/dist/agentic/guides/modules/channel_smtp/owned-contract-module-metadata.md +11 -0
- package/dist/agentic/guides/modules/channel_smtp/setup.md +11 -0
- package/dist/agentic/guides/modules/channel_smtp/umes-contributions.md +11 -0
- package/dist/agentic/guides/modules/checkout/events.md +16 -16
- package/dist/agentic/guides/modules/checkout/exact-override-targets.md +5 -4
- package/dist/agentic/guides/modules/checkout/index.md +1 -1
- package/dist/agentic/guides/modules/checkout/setup.md +1 -1
- package/dist/agentic/guides/modules/checkout/workers.md +1 -1
- package/dist/agentic/guides/modules/communication_channels/events.md +17 -17
- package/dist/agentic/guides/modules/communication_channels/exact-override-targets.md +5 -4
- package/dist/agentic/guides/modules/communication_channels/index.md +2 -2
- package/dist/agentic/guides/modules/communication_channels/setup.md +1 -1
- package/dist/agentic/guides/modules/communication_channels/workers.md +2 -2
- package/dist/agentic/guides/modules/configs/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/configs/index.md +1 -1
- package/dist/agentic/guides/modules/content/index.md +1 -1
- package/dist/agentic/guides/modules/currencies/di-registrations-rich.md +11 -0
- package/dist/agentic/guides/modules/currencies/di-service-tokens.md +11 -0
- package/dist/agentic/guides/modules/currencies/events.md +6 -6
- package/dist/agentic/guides/modules/currencies/exact-override-targets.md +1 -0
- package/dist/agentic/guides/modules/currencies/index.md +4 -2
- package/dist/agentic/guides/modules/customer_accounts/active-extension-bindings.md +1 -0
- package/dist/agentic/guides/modules/customer_accounts/contribution-resolutions.md +2 -2
- package/dist/agentic/guides/modules/customer_accounts/domain-commands.md +11 -0
- package/dist/agentic/guides/modules/customer_accounts/events.md +27 -26
- package/dist/agentic/guides/modules/customer_accounts/exact-override-targets.md +1 -1
- package/dist/agentic/guides/modules/customer_accounts/index.md +5 -4
- package/dist/agentic/guides/modules/customer_accounts/umes-contributions.md +2 -2
- package/dist/agentic/guides/modules/customer_accounts/umes-hosts.md +1 -0
- package/dist/agentic/guides/modules/customer_groups/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/customer_groups/contribution-resolutions.md +2 -2
- package/dist/agentic/guides/modules/customer_groups/events.md +7 -7
- package/dist/agentic/guides/modules/customer_groups/index.md +1 -1
- package/dist/agentic/guides/modules/customer_groups/umes-contributions.md +2 -2
- package/dist/agentic/guides/modules/customers/active-extension-bindings.md +9 -10
- package/dist/agentic/guides/modules/customers/di-registrations-rich.md +6 -5
- package/dist/agentic/guides/modules/customers/encryption.md +1 -1
- package/dist/agentic/guides/modules/customers/events.md +51 -51
- package/dist/agentic/guides/modules/customers/exact-override-targets.md +6 -5
- package/dist/agentic/guides/modules/customers/incoming-installed-contributions.md +12 -8
- package/dist/agentic/guides/modules/customers/index.md +12 -4
- package/dist/agentic/guides/modules/customers/umes-hosts.md +46 -0
- package/dist/agentic/guides/modules/dashboards/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/dashboards/index.md +1 -1
- package/dist/agentic/guides/modules/data_sync/events.md +4 -4
- package/dist/agentic/guides/modules/data_sync/index.md +1 -1
- package/dist/agentic/guides/modules/design_system/index.md +1 -1
- package/dist/agentic/guides/modules/devices/events.md +5 -5
- package/dist/agentic/guides/modules/devices/index.md +1 -1
- package/dist/agentic/guides/modules/dictionaries/events.md +3 -3
- package/dist/agentic/guides/modules/dictionaries/index.md +1 -1
- package/dist/agentic/guides/modules/directory/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/directory/contribution-resolutions.md +1 -0
- package/dist/agentic/guides/modules/directory/events.md +6 -6
- package/dist/agentic/guides/modules/directory/exact-override-targets.md +1 -0
- package/dist/agentic/guides/modules/directory/incoming-installed-contributions.md +4 -0
- package/dist/agentic/guides/modules/directory/index.md +2 -2
- package/dist/agentic/guides/modules/directory/umes-contributions.md +1 -0
- package/dist/agentic/guides/modules/documents/contribution-resolutions.md +3 -3
- package/dist/agentic/guides/modules/documents/events.md +15 -15
- package/dist/agentic/guides/modules/documents/index.md +1 -1
- package/dist/agentic/guides/modules/documents/umes-contributions.md +5 -5
- package/dist/agentic/guides/modules/ecommerce/contribution-resolutions.md +1 -0
- package/dist/agentic/guides/modules/ecommerce/events.md +12 -12
- package/dist/agentic/guides/modules/ecommerce/exact-override-targets.md +1 -0
- package/dist/agentic/guides/modules/ecommerce/index.md +3 -3
- package/dist/agentic/guides/modules/ecommerce/umes-contributions.md +1 -0
- package/dist/agentic/guides/modules/entities/contribution-resolutions.md +14 -0
- package/dist/agentic/guides/modules/entities/exact-override-targets.md +4 -0
- package/dist/agentic/guides/modules/entities/index.md +5 -3
- package/dist/agentic/guides/modules/entities/umes-contributions.md +14 -0
- package/dist/agentic/guides/modules/eudr/events.md +23 -23
- package/dist/agentic/guides/modules/eudr/index.md +1 -1
- package/dist/agentic/guides/modules/eudr/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/events/index.md +1 -1
- package/dist/agentic/guides/modules/feature_toggles/index.md +1 -1
- package/dist/agentic/guides/modules/forms/events.md +18 -18
- package/dist/agentic/guides/modules/forms/index.md +1 -1
- package/dist/agentic/guides/modules/forms/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/gateway_autopay/acl-features.md +12 -0
- package/dist/agentic/guides/modules/gateway_autopay/cli-commands.md +12 -0
- package/dist/agentic/guides/modules/gateway_autopay/contribution-resolutions.md +12 -0
- package/dist/agentic/guides/modules/gateway_autopay/di-registrations-rich.md +11 -0
- package/dist/agentic/guides/modules/gateway_autopay/exact-override-targets.md +17 -0
- package/dist/agentic/guides/modules/gateway_autopay/index.md +19 -0
- package/dist/agentic/guides/modules/gateway_autopay/owned-contract-module-metadata.md +11 -0
- package/dist/agentic/guides/modules/gateway_autopay/setup.md +11 -0
- package/dist/agentic/guides/modules/gateway_autopay/umes-contributions.md +12 -0
- package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_tpay/contribution-resolutions.md +1 -0
- package/dist/agentic/guides/modules/gateway_tpay/di-registrations-rich.md +1 -1
- package/dist/agentic/guides/modules/gateway_tpay/exact-override-targets.md +6 -3
- package/dist/agentic/guides/modules/gateway_tpay/index.md +5 -4
- package/dist/agentic/guides/modules/gateway_tpay/setup.md +1 -1
- package/dist/agentic/guides/modules/gateway_tpay/umes-contributions.md +1 -0
- package/dist/agentic/guides/modules/gateway_tpay/workers.md +11 -0
- package/dist/agentic/guides/modules/generators/index.md +1 -1
- package/dist/agentic/guides/modules/inbox_ops/events.md +13 -13
- package/dist/agentic/guides/modules/inbox_ops/index.md +2 -2
- package/dist/agentic/guides/modules/integrations/events.md +4 -4
- package/dist/agentic/guides/modules/integrations/exact-override-targets.md +3 -2
- package/dist/agentic/guides/modules/integrations/incoming-installed-contributions.md +11 -0
- package/dist/agentic/guides/modules/integrations/index.md +3 -2
- package/dist/agentic/guides/modules/integrations/setup.md +1 -1
- package/dist/agentic/guides/modules/messages/entities.md +2 -0
- package/dist/agentic/guides/modules/messages/events.md +9 -9
- package/dist/agentic/guides/modules/messages/index.md +1 -1
- package/dist/agentic/guides/modules/messages/umes-hosts.md +2 -0
- package/dist/agentic/guides/modules/notifications/index.md +1 -1
- package/dist/agentic/guides/modules/onboarding/index.md +1 -1
- package/dist/agentic/guides/modules/payment_gateways/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/payment_gateways/di-registrations-rich.md +4 -4
- package/dist/agentic/guides/modules/payment_gateways/di-service-tokens.md +2 -2
- package/dist/agentic/guides/modules/payment_gateways/events.md +9 -9
- package/dist/agentic/guides/modules/payment_gateways/exact-override-targets.md +5 -4
- package/dist/agentic/guides/modules/payment_gateways/index.md +1 -1
- package/dist/agentic/guides/modules/payment_gateways/setup.md +1 -1
- package/dist/agentic/guides/modules/perspectives/index.md +1 -1
- package/dist/agentic/guides/modules/phone_calls/events.md +3 -3
- package/dist/agentic/guides/modules/phone_calls/index.md +1 -1
- package/dist/agentic/guides/modules/planner/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/planner/events.md +6 -6
- package/dist/agentic/guides/modules/planner/exact-override-targets.md +3 -3
- package/dist/agentic/guides/modules/planner/index.md +1 -1
- package/dist/agentic/guides/modules/planner/setup.md +1 -1
- package/dist/agentic/guides/modules/portal/exact-override-targets.md +1 -0
- package/dist/agentic/guides/modules/portal/frontend-pages.md +1 -0
- package/dist/agentic/guides/modules/portal/index.md +1 -1
- package/dist/agentic/guides/modules/progress/events.md +6 -6
- package/dist/agentic/guides/modules/progress/index.md +2 -2
- package/dist/agentic/guides/modules/promotions/acl-features.md +18 -0
- package/dist/agentic/guides/modules/promotions/active-extension-bindings.md +12 -0
- package/dist/agentic/guides/modules/promotions/backend-pages.md +16 -0
- package/dist/agentic/guides/modules/promotions/contribution-resolutions.md +18 -0
- package/dist/agentic/guides/modules/promotions/di-registrations-rich.md +15 -0
- package/dist/agentic/guides/modules/promotions/di-service-tokens.md +15 -0
- package/dist/agentic/guides/modules/promotions/domain-commands.md +23 -0
- package/dist/agentic/guides/modules/promotions/entities.md +19 -0
- package/dist/agentic/guides/modules/promotions/events.md +24 -0
- package/dist/agentic/guides/modules/promotions/exact-override-targets.md +41 -0
- package/dist/agentic/guides/modules/promotions/index.md +26 -0
- package/dist/agentic/guides/modules/promotions/owned-contract-module-metadata.md +11 -0
- package/dist/agentic/guides/modules/promotions/setup.md +11 -0
- package/dist/agentic/guides/modules/promotions/umes-contributions.md +18 -0
- package/dist/agentic/guides/modules/promotions/umes-hosts.md +33 -0
- package/dist/agentic/guides/modules/promotions/workers.md +12 -0
- package/dist/agentic/guides/modules/push_notifications/active-extension-bindings.md +11 -0
- package/dist/agentic/guides/modules/push_notifications/events.md +2 -2
- package/dist/agentic/guides/modules/push_notifications/index.md +3 -2
- package/dist/agentic/guides/modules/query_index/events.md +8 -8
- package/dist/agentic/guides/modules/query_index/index.md +1 -1
- package/dist/agentic/guides/modules/record_locks/events.md +10 -10
- package/dist/agentic/guides/modules/record_locks/index.md +1 -1
- package/dist/agentic/guides/modules/resources/events.md +15 -15
- package/dist/agentic/guides/modules/resources/index.md +1 -1
- package/dist/agentic/guides/modules/sales/active-extension-bindings.md +5 -0
- package/dist/agentic/guides/modules/sales/di-registrations-rich.md +30 -30
- package/dist/agentic/guides/modules/sales/di-service-tokens.md +5 -5
- package/dist/agentic/guides/modules/sales/domain-commands.md +1 -0
- package/dist/agentic/guides/modules/sales/events.md +44 -44
- package/dist/agentic/guides/modules/sales/exact-override-targets.md +30 -30
- package/dist/agentic/guides/modules/sales/incoming-installed-contributions.md +3 -1
- package/dist/agentic/guides/modules/sales/index.md +4 -4
- package/dist/agentic/guides/modules/sales/umes-hosts.md +5 -2
- package/dist/agentic/guides/modules/scheduler/events.md +4 -4
- package/dist/agentic/guides/modules/scheduler/index.md +1 -1
- package/dist/agentic/guides/modules/search/events.md +1 -1
- package/dist/agentic/guides/modules/search/exact-override-targets.md +1 -1
- package/dist/agentic/guides/modules/search/index.md +1 -1
- package/dist/agentic/guides/modules/search/workers.md +1 -1
- package/dist/agentic/guides/modules/security/contribution-resolutions.md +2 -0
- package/dist/agentic/guides/modules/security/events.md +22 -21
- package/dist/agentic/guides/modules/security/exact-override-targets.md +2 -0
- package/dist/agentic/guides/modules/security/index.md +2 -2
- package/dist/agentic/guides/modules/security/notifications.md +1 -0
- package/dist/agentic/guides/modules/security/umes-contributions.md +2 -0
- package/dist/agentic/guides/modules/security/umes-hosts.md +1 -0
- package/dist/agentic/guides/modules/seeds/index.md +1 -1
- package/dist/agentic/guides/modules/shipping_carriers/contribution-resolutions.md +1 -1
- package/dist/agentic/guides/modules/shipping_carriers/events.md +7 -7
- package/dist/agentic/guides/modules/shipping_carriers/index.md +1 -1
- package/dist/agentic/guides/modules/shipping_carriers/umes-contributions.md +1 -1
- package/dist/agentic/guides/modules/sso/di-registrations-rich.md +8 -7
- package/dist/agentic/guides/modules/sso/di-service-tokens.md +7 -6
- package/dist/agentic/guides/modules/sso/events.md +12 -12
- package/dist/agentic/guides/modules/sso/exact-override-targets.md +8 -7
- package/dist/agentic/guides/modules/sso/index.md +1 -1
- package/dist/agentic/guides/modules/staff/active-extension-bindings.md +5 -3
- package/dist/agentic/guides/modules/staff/backend-pages.md +1 -0
- package/dist/agentic/guides/modules/staff/cli-commands.md +1 -0
- package/dist/agentic/guides/modules/staff/contribution-resolutions.md +23 -0
- package/dist/agentic/guides/modules/staff/di-registrations-rich.md +8 -8
- package/dist/agentic/guides/modules/staff/domain-commands.md +2 -0
- package/dist/agentic/guides/modules/staff/encryption.md +1 -0
- package/dist/agentic/guides/modules/staff/entities.md +3 -0
- package/dist/agentic/guides/modules/staff/events.md +75 -70
- package/dist/agentic/guides/modules/staff/exact-override-targets.md +99 -12
- package/dist/agentic/guides/modules/staff/frontend-pages.md +3 -0
- package/dist/agentic/guides/modules/staff/index.md +26 -13
- package/dist/agentic/guides/modules/staff/notifications.md +4 -0
- package/dist/agentic/guides/modules/staff/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/staff/setup.md +1 -1
- package/dist/agentic/guides/modules/staff/umes-contributions.md +24 -1
- package/dist/agentic/guides/modules/staff/umes-hosts.md +9 -0
- package/dist/agentic/guides/modules/storage_s3/di-registrations-rich.md +3 -3
- package/dist/agentic/guides/modules/storage_s3/di-service-tokens.md +1 -1
- package/dist/agentic/guides/modules/storage_s3/exact-override-targets.md +3 -3
- package/dist/agentic/guides/modules/storage_s3/index.md +1 -1
- package/dist/agentic/guides/modules/sync_akeneo/index.md +1 -1
- package/dist/agentic/guides/modules/sync_excel/index.md +1 -1
- package/dist/agentic/guides/modules/sync_excel/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/system_status_overlays/index.md +1 -1
- package/dist/agentic/guides/modules/telemetry/index.md +1 -1
- package/dist/agentic/guides/modules/tillio/index.md +1 -1
- package/dist/agentic/guides/modules/translations/active-extension-bindings.md +1 -1
- package/dist/agentic/guides/modules/translations/events.md +2 -2
- package/dist/agentic/guides/modules/translations/index.md +1 -1
- package/dist/agentic/guides/modules/warranty_claims/contribution-resolutions.md +2 -2
- package/dist/agentic/guides/modules/warranty_claims/events.md +14 -14
- package/dist/agentic/guides/modules/warranty_claims/exact-override-targets.md +5 -4
- package/dist/agentic/guides/modules/warranty_claims/index.md +2 -2
- package/dist/agentic/guides/modules/warranty_claims/setup.md +1 -1
- package/dist/agentic/guides/modules/warranty_claims/umes-contributions.md +2 -2
- package/dist/agentic/guides/modules/warranty_claims/workers.md +1 -1
- package/dist/agentic/guides/modules/webhooks/events.md +12 -12
- package/dist/agentic/guides/modules/webhooks/index.md +1 -1
- package/dist/agentic/guides/modules/wms/acl-features.md +3 -1
- package/dist/agentic/guides/modules/wms/backend-pages.md +4 -0
- package/dist/agentic/guides/modules/wms/contribution-resolutions.md +7 -1
- package/dist/agentic/guides/modules/wms/custom-entities.md +3 -0
- package/dist/agentic/guides/modules/wms/domain-commands.md +16 -0
- package/dist/agentic/guides/modules/wms/entities.md +3 -0
- package/dist/agentic/guides/modules/wms/events.md +40 -29
- package/dist/agentic/guides/modules/wms/exact-override-targets.md +10 -0
- package/dist/agentic/guides/modules/wms/host-extension-points.md +1 -1
- package/dist/agentic/guides/modules/wms/index.md +14 -10
- package/dist/agentic/guides/modules/wms/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/wms/search-entities.md +2 -0
- package/dist/agentic/guides/modules/wms/umes-contributions.md +7 -1
- package/dist/agentic/guides/modules/wms/umes-diagnostics.md +2 -0
- package/dist/agentic/guides/modules/wms/umes-hosts.md +53 -0
- package/dist/agentic/guides/modules/workflows/contribution-resolutions.md +3 -3
- package/dist/agentic/guides/modules/workflows/events.md +32 -32
- package/dist/agentic/guides/modules/workflows/exact-override-targets.md +2 -1
- package/dist/agentic/guides/modules/workflows/index.md +1 -1
- package/dist/agentic/guides/modules/workflows/setup.md +1 -1
- package/dist/agentic/guides/modules/workflows/umes-contributions.md +3 -3
- package/dist/agentic/guides/production-deployment.md +82 -0
- package/dist/agentic/guides/reference-module-facts.json +384 -16
- package/dist/agentic/guides/reference-modules/example/contribution-resolutions.md +6 -0
- package/dist/agentic/guides/reference-modules/example/di-registrations-rich.md +3 -3
- package/dist/agentic/guides/reference-modules/example/di-service-tokens.md +1 -1
- package/dist/agentic/guides/reference-modules/example/events.md +5 -5
- package/dist/agentic/guides/reference-modules/example/exact-override-targets.md +12 -8
- package/dist/agentic/guides/reference-modules/example/index.md +4 -4
- package/dist/agentic/guides/reference-modules/example/setup.md +1 -1
- package/dist/agentic/guides/reference-modules/example/umes-contributions.md +6 -0
- package/dist/agentic/guides/template-tool.md +38 -0
- package/dist/agentic/guides/testing-debugging.md +2 -2
- package/dist/agentic/guides/upstream/AGENTS.md +3 -3
- package/dist/agentic/guides/upstream/BACKWARD_COMPATIBILITY.md +321 -230
- package/dist/agentic/guides/upstream/manifest.json +3 -3
- package/dist/agentic/shared/AGENTS.md.template +16 -11
- package/dist/agentic/shared/ai/harness/README.md +6 -2
- package/dist/agentic/shared/ai/harness/RELEASE.md +4 -4
- package/dist/agentic/shared/ai/harness/cases.json +282 -19
- package/dist/agentic/shared/ai/harness/cases.schema.json +4 -4
- package/dist/agentic/shared/ai/harness/source-link-inventory.json +204 -4
- package/dist/agentic/shared/ai/harness/validators.json +1 -1
- package/dist/agentic/shared/ai/qa/tests/playwright.config.ts +1 -0
- package/dist/agentic/shared/ai/skills/om-auto-upgrade-0.9.0-to-0.10.0/SKILL.md +269 -0
- package/dist/agentic/shared/ai/skills/om-create-ai-agent/SKILL.md +6 -5
- package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/surface-selector.md +27 -0
- package/dist/agentic/shared/ai/skills/om-data-model-design/references/integrity-and-concurrency.md +1 -1
- package/dist/agentic/shared/ai/skills/om-data-model-design/references/sensitive-data.md +13 -1
- package/dist/agentic/shared/ai/skills/om-find-module/SKILL.md +52 -0
- package/dist/agentic/shared/ai/skills/om-help/references/task-families.md +1 -0
- package/dist/agentic/shared/ai/skills/om-implement-spec/SKILL.md +1 -0
- package/dist/agentic/shared/ai/skills/om-module-scaffold/references/api-and-domain.md +7 -5
- package/dist/agentic/shared/ai/skills/om-setup-ci/SKILL.md +42 -0
- package/dist/agentic/shared/ai/skills/om-setup-ci/scripts/setup-ci.mjs +525 -0
- package/dist/agentic/shared/ai/skills/om-setup-ci/scripts/verify-semgrep-rules.mjs +54 -0
- package/dist/agentic/shared/ai/skills/om-setup-ci/templates/docs/README.md +463 -0
- package/dist/agentic/shared/ai/skills/om-setup-ci/templates/github/actions/gitleaks/action.yml +25 -0
- package/dist/agentic/shared/ai/skills/om-setup-ci/templates/github/actions/playwright/action.yml +31 -0
- package/dist/agentic/shared/ai/skills/om-setup-ci/templates/github/actions/setup/action.yml +55 -0
- package/dist/agentic/shared/ai/skills/om-setup-ci/templates/github/dependabot.yml +27 -0
- package/dist/agentic/shared/ai/skills/om-setup-ci/templates/github/workflows/audit.yml +193 -0
- package/dist/agentic/shared/ai/skills/om-setup-ci/templates/github/workflows/ci.yml +477 -0
- package/dist/agentic/shared/ai/skills/om-setup-ci/templates/github/workflows/codeql.yml +63 -0
- package/dist/agentic/shared/ai/skills/om-setup-ci/templates/github/workflows/security.yml +254 -0
- package/dist/agentic/shared/ai/skills/om-setup-ci/templates/scripts/ci/audit-ci-allowlist.json +4 -0
- package/dist/agentic/shared/ai/skills/om-setup-ci/templates/scripts/ci/audit-ci.mjs +283 -0
- package/dist/agentic/shared/ai/skills/om-setup-ci/templates/scripts/ci/semgrep/open-mercato.fixture.txt +89 -0
- package/dist/agentic/shared/ai/skills/om-setup-ci/templates/scripts/ci/semgrep/open-mercato.yml +146 -0
- package/dist/agentic/shared/ai/skills/om-setup-ci/templates/scripts/ci/time-bomb-scanner.mjs +286 -0
- package/dist/agentic/shared/ai/skills/om-setup-ci/templates/scripts/ci/zap-rules.tsv +11 -0
- package/dist/agentic/shared/ai/skills/om-system-extension/references/unified-overrides.md +1 -1
- package/dist/agentic/shared/ai/skills/tiers.json +5 -2
- package/dist/agentic/shared/ai/trackers/github.md +314 -44
- package/dist/agentic/shared/scripts/execution-sandbox.mjs +1 -0
- package/dist/agentic/shared/scripts/run-agent-harness-release.mjs +3 -3
- package/dist/i18n/de.json +4 -0
- package/dist/i18n/en.json +4 -0
- package/dist/i18n/es.json +4 -0
- package/dist/i18n/ko.json +4 -0
- package/dist/i18n/pl.json +4 -0
- package/dist/lib/__fixtures__/module-search/built-in.json +235 -0
- package/dist/lib/__fixtures__/module-search/catalog-parity.json +4076 -0
- package/dist/lib/__fixtures__/module-search/modules-index.json +1980 -0
- package/dist/lib/__fixtures__/official-module-package/package.json +33 -0
- package/dist/lib/__integration__/TC-INT-007.spec.js +241 -21
- package/dist/lib/__integration__/TC-INT-007.spec.js.map +2 -2
- package/dist/lib/__integration__/TC-INT-009.spec.js +267 -0
- package/dist/lib/__integration__/TC-INT-009.spec.js.map +7 -0
- package/dist/lib/db/commands.js +2 -0
- package/dist/lib/db/commands.js.map +2 -2
- package/dist/lib/db/numeric-snapshots.js +13 -0
- package/dist/lib/db/numeric-snapshots.js.map +7 -0
- package/dist/lib/eject.js +25 -9
- package/dist/lib/eject.js.map +2 -2
- package/dist/lib/env-example.js +25 -0
- package/dist/lib/env-example.js.map +7 -0
- package/dist/lib/generate-child-process.js +23 -0
- package/dist/lib/generate-child-process.js.map +7 -0
- package/dist/lib/generators/ast/imports.js +9 -4
- package/dist/lib/generators/ast/imports.js.map +2 -2
- package/dist/lib/generators/entity-ids.js +12 -12
- package/dist/lib/generators/entity-ids.js.map +2 -2
- package/dist/lib/generators/extensions/agent-files.js +119 -4
- package/dist/lib/generators/extensions/agent-files.js.map +2 -2
- package/dist/lib/generators/module-di.js +8 -9
- package/dist/lib/generators/module-di.js.map +2 -2
- package/dist/lib/generators/module-entities.js +8 -9
- package/dist/lib/generators/module-entities.js.map +2 -2
- package/dist/lib/generators/module-facts.js +7 -5
- package/dist/lib/generators/module-facts.js.map +2 -2
- package/dist/lib/generators/module-override-targets.js +6 -1
- package/dist/lib/generators/module-override-targets.js.map +2 -2
- package/dist/lib/generators/module-package-sources.js +6 -4
- package/dist/lib/generators/module-package-sources.js.map +2 -2
- package/dist/lib/generators/module-registry.js +157 -144
- package/dist/lib/generators/module-registry.js.map +2 -2
- package/dist/lib/generators/openapi.js +9 -2
- package/dist/lib/generators/openapi.js.map +2 -2
- package/dist/lib/generators/source-exports.js +73 -0
- package/dist/lib/generators/source-exports.js.map +7 -0
- package/dist/lib/in-process-generate-watcher.js +11 -5
- package/dist/lib/in-process-generate-watcher.js.map +2 -2
- package/dist/lib/init-existing-database.js +26 -0
- package/dist/lib/init-existing-database.js.map +7 -0
- package/dist/lib/init-secrets.js +33 -1
- package/dist/lib/init-secrets.js.map +2 -2
- package/dist/lib/init-summary.js +44 -0
- package/dist/lib/init-summary.js.map +7 -0
- package/dist/lib/module-github.js +98 -0
- package/dist/lib/module-github.js.map +7 -0
- package/dist/lib/module-identity.js +131 -0
- package/dist/lib/module-identity.js.map +7 -0
- package/dist/lib/module-inspection.js +124 -0
- package/dist/lib/module-inspection.js.map +7 -0
- package/dist/lib/module-install.js +186 -19
- package/dist/lib/module-install.js.map +3 -3
- package/dist/lib/module-package.js +205 -15
- package/dist/lib/module-package.js.map +2 -2
- package/dist/lib/module-search-args.js +97 -0
- package/dist/lib/module-search-args.js.map +7 -0
- package/dist/lib/module-search-index.js +681 -0
- package/dist/lib/module-search-index.js.map +7 -0
- package/dist/lib/module-search.js +727 -0
- package/dist/lib/module-search.js.map +7 -0
- package/dist/lib/modules-config.js +210 -66
- package/dist/lib/modules-config.js.map +2 -2
- package/dist/lib/queue-worker-supervisor.js +3 -0
- package/dist/lib/queue-worker-supervisor.js.map +2 -2
- package/dist/lib/resolver.js +54 -35
- package/dist/lib/resolver.js.map +2 -2
- package/dist/lib/telemetry-init.js +1 -1
- package/dist/lib/telemetry-init.js.map +1 -1
- package/dist/lib/testing/integration-discovery.js +61 -21
- package/dist/lib/testing/integration-discovery.js.map +2 -2
- package/dist/lib/testing/integration.js +33 -4
- package/dist/lib/testing/integration.js.map +2 -2
- package/dist/mercato.js +126 -66
- package/dist/mercato.js.map +2 -2
- package/jest.config.cjs +1 -1
- package/package.json +9 -9
- package/src/__tests__/documented-queue-subcommands.test.ts +63 -0
- package/src/__tests__/mercato.test.ts +429 -4
- package/src/i18n/de.json +4 -0
- package/src/i18n/en.json +4 -0
- package/src/i18n/es.json +4 -0
- package/src/i18n/ko.json +4 -0
- package/src/i18n/pl.json +4 -0
- package/src/lib/__fixtures__/module-search/README.md +97 -0
- package/src/lib/__fixtures__/module-search/built-in.json +235 -0
- package/src/lib/__fixtures__/module-search/catalog-parity.json +4076 -0
- package/src/lib/__fixtures__/module-search/modules-index.json +1980 -0
- package/src/lib/__fixtures__/official-module-package/dist/modules/test_package/widgets/injection/test/widget.js +1 -0
- package/src/lib/__integration__/TC-INT-007.spec.ts +259 -21
- package/src/lib/__integration__/TC-INT-009.spec.ts +279 -0
- package/src/lib/__tests__/agentic-setup.ownership.test.ts +4 -0
- package/src/lib/__tests__/eject.test.ts +98 -4
- package/src/lib/__tests__/env-example.test.ts +58 -0
- package/src/lib/__tests__/generate-child-process.test.ts +185 -0
- package/src/lib/__tests__/generate-quiet-entrypoint.test.ts +47 -0
- package/src/lib/__tests__/in-process-generate-watcher.test.ts +91 -0
- package/src/lib/__tests__/init-existing-database.test.ts +27 -0
- package/src/lib/__tests__/init-secrets.test.ts +85 -1
- package/src/lib/__tests__/init-summary.test.ts +50 -0
- package/src/lib/__tests__/module-github.test.ts +108 -0
- package/src/lib/__tests__/module-identity.test.ts +144 -0
- package/src/lib/__tests__/module-inspection.test.ts +195 -0
- package/src/lib/__tests__/module-install.test.ts +614 -19
- package/src/lib/__tests__/module-package.test.ts +154 -0
- package/src/lib/__tests__/module-search.test.ts +1040 -0
- package/src/lib/__tests__/modules-config.test.ts +453 -1
- package/src/lib/__tests__/queue-worker-supervisor.test.ts +145 -1
- package/src/lib/__tests__/resolver.enterprise.test.ts +60 -0
- package/src/lib/__tests__/resolver.packages.test.ts +29 -0
- package/src/lib/__tests__/telemetry-init.test.ts +1 -1
- package/src/lib/db/__tests__/identifiers.test.ts +19 -0
- package/src/lib/db/__tests__/numeric-snapshots.test.ts +79 -0
- package/src/lib/db/commands.ts +2 -0
- package/src/lib/db/numeric-snapshots.ts +12 -0
- package/src/lib/eject.ts +28 -10
- package/src/lib/env-example.ts +31 -0
- package/src/lib/generate-child-process.ts +35 -0
- package/src/lib/generators/__tests__/agent-files-extension.test.ts +178 -0
- package/src/lib/generators/__tests__/attachment-access.test.ts +70 -0
- package/src/lib/generators/__tests__/module-extension-activations.test.ts +42 -18
- package/src/lib/generators/__tests__/module-facts.bc-guard.test.ts +9 -8
- package/src/lib/generators/__tests__/module-facts.owned-contracts.test.ts +5 -1
- package/src/lib/generators/__tests__/module-id-collisions.test.ts +146 -0
- package/src/lib/generators/__tests__/module-override-targets.test.ts +8 -2
- package/src/lib/generators/__tests__/module-package-sources.test.ts +26 -6
- package/src/lib/generators/__tests__/module-registry-requires-enforcement.test.ts +130 -0
- package/src/lib/generators/__tests__/module-requirements.test.ts +56 -0
- package/src/lib/generators/__tests__/module-requires.test.ts +242 -0
- package/src/lib/generators/__tests__/module-subset.test.ts +103 -0
- package/src/lib/generators/__tests__/openapi.test.ts +24 -0
- package/src/lib/generators/ast/imports.ts +14 -4
- package/src/lib/generators/entity-ids.ts +12 -12
- package/src/lib/generators/extensions/agent-files.ts +154 -4
- package/src/lib/generators/module-di.ts +8 -9
- package/src/lib/generators/module-entities.ts +8 -9
- package/src/lib/generators/module-facts.ts +9 -5
- package/src/lib/generators/module-override-targets.ts +6 -1
- package/src/lib/generators/module-package-sources.ts +7 -5
- package/src/lib/generators/module-registry.ts +224 -182
- package/src/lib/generators/openapi.ts +10 -2
- package/src/lib/generators/source-exports.ts +93 -0
- package/src/lib/in-process-generate-watcher.ts +14 -6
- package/src/lib/init-existing-database.ts +24 -0
- package/src/lib/init-secrets.ts +37 -0
- package/src/lib/init-summary.ts +54 -0
- package/src/lib/module-github.ts +109 -0
- package/src/lib/module-identity.ts +145 -0
- package/src/lib/module-inspection.ts +133 -0
- package/src/lib/module-install.ts +214 -22
- package/src/lib/module-package.ts +243 -16
- package/src/lib/module-search-args.ts +116 -0
- package/src/lib/module-search-index.ts +1037 -0
- package/src/lib/module-search.ts +1013 -0
- package/src/lib/modules-config.ts +278 -80
- package/src/lib/queue-worker-supervisor.ts +3 -0
- package/src/lib/resolver.ts +58 -40
- package/src/lib/telemetry-init.ts +1 -1
- package/src/lib/testing/__tests__/integration-discovery.test.ts +89 -0
- package/src/lib/testing/__tests__/integration.test.ts +55 -0
- package/src/lib/testing/integration-discovery.ts +101 -32
- package/src/lib/testing/integration.ts +34 -4
- package/src/mercato.ts +167 -84
- package/src/types/cross-spawn.d.ts +2 -2
- package/src/lib/__tests__/agentic-build-artifacts.test.ts +0 -28
|
@@ -0,0 +1,1040 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import os from 'node:os'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import { parseModuleInfoArgs, parseModuleSearchArgs } from '../module-search-args'
|
|
5
|
+
import {
|
|
6
|
+
createCatalogSearcher,
|
|
7
|
+
resolveLine,
|
|
8
|
+
searchModules,
|
|
9
|
+
type BuiltInIndex,
|
|
10
|
+
type BuiltInModule,
|
|
11
|
+
type CatalogEntry,
|
|
12
|
+
type CatalogIndex,
|
|
13
|
+
type SearchModulesInput,
|
|
14
|
+
type SearchModulesOutput,
|
|
15
|
+
} from '../module-search-index'
|
|
16
|
+
import {
|
|
17
|
+
buildInfoView,
|
|
18
|
+
buildSearchView,
|
|
19
|
+
DEFAULT_MODULES_INDEX_URL,
|
|
20
|
+
defaultBuiltInUrl,
|
|
21
|
+
loadIndex,
|
|
22
|
+
MODULE_INDEX_CACHE_FILE,
|
|
23
|
+
MODULE_INDEX_MAX_BYTES,
|
|
24
|
+
MODULE_INDEX_UNAVAILABLE_EXIT_CODE,
|
|
25
|
+
MODULE_INDEX_UNAVAILABLE_MESSAGE,
|
|
26
|
+
BUILT_IN_UNAVAILABLE_MESSAGE,
|
|
27
|
+
parseBuiltInIndex,
|
|
28
|
+
parseCatalogIndex,
|
|
29
|
+
renderInfoHuman,
|
|
30
|
+
runModuleInfo,
|
|
31
|
+
withFollowUpSteps,
|
|
32
|
+
runModuleSearch,
|
|
33
|
+
type FetchLike,
|
|
34
|
+
type FetchResponseLike,
|
|
35
|
+
type ModuleSearchDeps,
|
|
36
|
+
} from '../module-search'
|
|
37
|
+
import { readEnabledModules } from '../modules-config'
|
|
38
|
+
|
|
39
|
+
const FIXTURES = path.join(__dirname, '..', '__fixtures__', 'module-search')
|
|
40
|
+
const readFixture = (name: string): unknown => JSON.parse(fs.readFileSync(path.join(FIXTURES, name), 'utf8'))
|
|
41
|
+
|
|
42
|
+
const index = parseCatalogIndex(readFixture('modules-index.json')) as CatalogIndex
|
|
43
|
+
const builtIn = parseBuiltInIndex(readFixture('built-in.json')) as BuiltInIndex
|
|
44
|
+
|
|
45
|
+
type ParityInfo =
|
|
46
|
+
| { ref: string; ok: true; locator: string | null; candidates: string[]; warnings: string[]; card: string | null }
|
|
47
|
+
| { ref: string; ok: false; error: string; candidates: string[] }
|
|
48
|
+
|
|
49
|
+
type ParityCases = {
|
|
50
|
+
search: { input: SearchModulesInput; output: SearchModulesOutput }[]
|
|
51
|
+
info: ParityInfo[]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
type ParityPatch = {
|
|
55
|
+
dataAsOf?: Partial<NonNullable<CatalogIndex['dataAsOf']>>
|
|
56
|
+
addEntries?: CatalogEntry[]
|
|
57
|
+
entries?: Record<string, { compat?: Partial<CatalogEntry['compat']> }>
|
|
58
|
+
builtIn?: Record<string, Partial<BuiltInModule>>
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const parity = readFixture('catalog-parity.json') as ParityCases & {
|
|
62
|
+
now: string
|
|
63
|
+
variants: (ParityCases & { name: string; patch: ParityPatch })[]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// The same merge the golden generator applies before it runs the catalog (see the fixture README).
|
|
67
|
+
function patchedFixture(patch: ParityPatch): { index: CatalogIndex; builtIn: BuiltInIndex } {
|
|
68
|
+
const patchedIndex = structuredClone(index)
|
|
69
|
+
const patchedBuiltIn = structuredClone(builtIn)
|
|
70
|
+
if (patch.dataAsOf) patchedIndex.dataAsOf = { ...patchedIndex.dataAsOf, ...patch.dataAsOf }
|
|
71
|
+
for (const entry of patchedIndex.entries) {
|
|
72
|
+
const compat = patch.entries?.[entry.locator]?.compat
|
|
73
|
+
if (compat) entry.compat = { ...entry.compat, ...compat }
|
|
74
|
+
}
|
|
75
|
+
if (patch.addEntries) patchedIndex.entries.push(...structuredClone(patch.addEntries))
|
|
76
|
+
patchedBuiltIn.modules = patchedBuiltIn.modules.map((coreModule) => ({ ...coreModule, ...(patch.builtIn?.[coreModule.id] ?? {}) }))
|
|
77
|
+
return { index: patchedIndex, builtIn: patchedBuiltIn }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const parityRuns = [
|
|
81
|
+
{ name: 'fixture', cases: parity as ParityCases, data: { index, builtIn } },
|
|
82
|
+
...parity.variants.map((variant) => ({ name: variant.name, cases: variant as ParityCases, data: patchedFixture(variant.patch) })),
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
const BUILT_IN_CARD_KEYS = ['category', 'description', 'enabled', 'id', 'install', 'matchedOn', 'page', 'presetNote', 'title']
|
|
86
|
+
const MODULE_CARD_KEYS = [
|
|
87
|
+
'agentPolicy',
|
|
88
|
+
'card',
|
|
89
|
+
'category',
|
|
90
|
+
'install',
|
|
91
|
+
'installableFrom',
|
|
92
|
+
'kind',
|
|
93
|
+
'license',
|
|
94
|
+
'line',
|
|
95
|
+
'locator',
|
|
96
|
+
'matchedOn',
|
|
97
|
+
'omQuality',
|
|
98
|
+
'path',
|
|
99
|
+
'status',
|
|
100
|
+
'summary',
|
|
101
|
+
'tier',
|
|
102
|
+
'title',
|
|
103
|
+
'type',
|
|
104
|
+
'verifiedOn',
|
|
105
|
+
'whenToUse',
|
|
106
|
+
]
|
|
107
|
+
|
|
108
|
+
const GOLDEN_IN_FIXTURE: [string, string[], string[]][] = [
|
|
109
|
+
['exchange rates', [], ['currencies']],
|
|
110
|
+
['ksef', ['@fastwhitecat/integration-ksef-direct'], []],
|
|
111
|
+
['e-invoicing poland', ['@fastwhitecat/integration-ksef-direct'], []],
|
|
112
|
+
['stripe', ['@open-mercato/gateway-stripe'], []],
|
|
113
|
+
['card payments', ['@open-mercato/gateway-stripe'], []],
|
|
114
|
+
['tpay', ['@open-mercato/gateway-tpay'], []],
|
|
115
|
+
['durable jobs', ['@fullstackhouse/open-mercato-durable-work'], []],
|
|
116
|
+
['data_sync', ['@fullstackhouse/open-mercato-data-sync-durable'], ['data_sync']],
|
|
117
|
+
['warehouse', [], ['wms']],
|
|
118
|
+
]
|
|
119
|
+
|
|
120
|
+
function jsonResponse(status: number, body: unknown, etag: string | null = null): FetchResponseLike {
|
|
121
|
+
return {
|
|
122
|
+
status,
|
|
123
|
+
ok: status >= 200 && status < 300,
|
|
124
|
+
headers: { get: (name: string) => (name.toLowerCase() === 'etag' ? etag : null) },
|
|
125
|
+
body: status === 304 ? null : new Response(JSON.stringify(body)).body,
|
|
126
|
+
json: async () => body,
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
type FetchCall = { url: string; headers: Record<string, string> }
|
|
131
|
+
|
|
132
|
+
function fixtureFetch(
|
|
133
|
+
options: { fail?: boolean; failFirst?: number; notModified?: boolean; noBuiltIn?: boolean; patch?: ParityPatch } = {},
|
|
134
|
+
) {
|
|
135
|
+
const data = options.patch ? patchedFixture(options.patch) : null
|
|
136
|
+
const calls: FetchCall[] = []
|
|
137
|
+
let failuresLeft = options.failFirst ?? 0
|
|
138
|
+
const fetchImpl: FetchLike = async (url, init) => {
|
|
139
|
+
calls.push({ url, headers: init?.headers ?? {} })
|
|
140
|
+
if (options.fail) throw new Error('getaddrinfo ENOTFOUND modules.openmercato.com')
|
|
141
|
+
if (failuresLeft > 0) {
|
|
142
|
+
failuresLeft -= 1
|
|
143
|
+
throw new Error('socket hang up')
|
|
144
|
+
}
|
|
145
|
+
if (options.notModified && init?.headers?.['if-none-match']) return jsonResponse(304, null)
|
|
146
|
+
if (url.endsWith('/modules.json')) return jsonResponse(200, data?.index ?? readFixture('modules-index.json'), '"idx-1"')
|
|
147
|
+
if (url.endsWith('/built-in.json') && !options.noBuiltIn) {
|
|
148
|
+
return jsonResponse(200, data?.builtIn ?? readFixture('built-in.json'), '"bi-1"')
|
|
149
|
+
}
|
|
150
|
+
return jsonResponse(404, null)
|
|
151
|
+
}
|
|
152
|
+
return { fetchImpl, calls }
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function tempApp(options: { coreVersion?: string; coreRange?: string; modulesTs?: string } = {}): string {
|
|
156
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'om-module-search-'))
|
|
157
|
+
const dependencies: Record<string, string> = {}
|
|
158
|
+
if (options.coreRange) dependencies['@open-mercato/core'] = options.coreRange
|
|
159
|
+
fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify({ name: 'app', dependencies }))
|
|
160
|
+
if (options.coreVersion) {
|
|
161
|
+
const coreDir = path.join(root, 'node_modules', '@open-mercato', 'core')
|
|
162
|
+
fs.mkdirSync(coreDir, { recursive: true })
|
|
163
|
+
fs.writeFileSync(path.join(coreDir, 'package.json'), JSON.stringify({ name: '@open-mercato/core', version: options.coreVersion }))
|
|
164
|
+
}
|
|
165
|
+
if (options.modulesTs) {
|
|
166
|
+
fs.mkdirSync(path.join(root, 'src'), { recursive: true })
|
|
167
|
+
fs.writeFileSync(path.join(root, 'src', 'modules.ts'), options.modulesTs)
|
|
168
|
+
}
|
|
169
|
+
return root
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function capture() {
|
|
173
|
+
const stdout: string[] = []
|
|
174
|
+
const stderr: string[] = []
|
|
175
|
+
return { stdout, stderr, out: (line: string) => stdout.push(line), err: (line: string) => stderr.push(line) }
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const NOW = Date.parse(parity.now)
|
|
179
|
+
|
|
180
|
+
function deps(appRoot: string, fetchImpl: FetchLike, io: ReturnType<typeof capture>, now = NOW): ModuleSearchDeps {
|
|
181
|
+
return { appRoot, env: {}, fetchImpl, now: () => now, stdout: io.out, stderr: io.err, readEnabledModules }
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
describe('module search fixture', () => {
|
|
185
|
+
it('parses the published modules.json and built-in.json of the catalog', () => {
|
|
186
|
+
expect(index).not.toBeNull()
|
|
187
|
+
expect(builtIn).not.toBeNull()
|
|
188
|
+
expect(index.site).toBe('https://modules.openmercato.com')
|
|
189
|
+
expect(index.entries).toHaveLength(8)
|
|
190
|
+
expect(builtIn.modules.map((module) => module.id)).toEqual(['currencies', 'data_sync', 'wms'])
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
it('rejects data that is not a modules-1 index', () => {
|
|
194
|
+
expect(parseCatalogIndex({ schemaVersion: 2, entries: [] })).toBeNull()
|
|
195
|
+
expect(parseCatalogIndex({ ...index, entries: [{ locator: 'npm:x' }] })).toBeNull()
|
|
196
|
+
expect(parseBuiltInIndex({ schemaVersion: 1, coreVersion: '0.9.0', modules: [{ id: 'x' }] })).toBeNull()
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
it('ignores a line source or a receipt source this CLI does not know yet', () => {
|
|
200
|
+
const parsed = parseCatalogIndex({
|
|
201
|
+
...index,
|
|
202
|
+
lines: [...index.lines, { key: '0.7', version: '0.7.4', source: 'lts' }],
|
|
203
|
+
dataAsOf: { source: 'nightly' },
|
|
204
|
+
}) as CatalogIndex
|
|
205
|
+
expect(parsed.lines.map((line) => line.key)).toEqual(index.lines.map((line) => line.key))
|
|
206
|
+
expect(searchModules(createCatalogSearcher(parsed, builtIn), { query: 'ksef' }).receiptSource).toBeNull()
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
it('rejects an index whose nested fields search or module info would trip over', () => {
|
|
210
|
+
const ksef = index.entries.find((entry) => entry.locator === 'npm:@fastwhitecat/integration-ksef-direct') as CatalogEntry
|
|
211
|
+
const anatomy = ksef.anatomy as NonNullable<CatalogEntry['anatomy']>
|
|
212
|
+
const broken: Record<string, unknown>[] = [
|
|
213
|
+
{ providers: [null] },
|
|
214
|
+
{ providers: [{ name: 'ksef' }] },
|
|
215
|
+
{ agentPolicy: { '0.9': { decision: 'allow', reasons: null } } },
|
|
216
|
+
{ version: { ...ksef.version, recommended: { '0.9': 7 } } },
|
|
217
|
+
{ compat: { ...ksef.compat, lines: { '0.9': null } } },
|
|
218
|
+
{ anatomy: { ...anatomy, lists: { ...anatomy.lists, credentials: [null] } } },
|
|
219
|
+
{ anatomy: { ...anatomy, lists: { ...anatomy.lists, hosts: 'api.ksef.mf.gov.pl' } } },
|
|
220
|
+
{ signals: { supplyChain: { status: 'warn', reasons: null } } },
|
|
221
|
+
{ license: { spdx: 1, kind: 'osi' } },
|
|
222
|
+
]
|
|
223
|
+
for (const change of broken) {
|
|
224
|
+
const entries = index.entries.map((entry) => (entry === ksef ? { ...entry, ...change } : entry))
|
|
225
|
+
expect(parseCatalogIndex({ ...index, entries })).toBeNull()
|
|
226
|
+
}
|
|
227
|
+
const core = builtIn.modules[0] as BuiltInModule
|
|
228
|
+
expect(parseBuiltInIndex({ ...builtIn, modules: [{ ...core, anatomy: { lists: { tables: [1] } } }] })).toBeNull()
|
|
229
|
+
})
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
describe.each(parityRuns)('parity with the catalog search_modules tool (tools@1), $name', ({ cases, data }) => {
|
|
233
|
+
const searcher = createCatalogSearcher(data.index, data.builtIn)
|
|
234
|
+
|
|
235
|
+
it.each(cases.search.map((item) => [JSON.stringify(item.input), item] as const))('%s', (_label, item) => {
|
|
236
|
+
expect(searchModules(searcher, item.input)).toEqual(item.output)
|
|
237
|
+
})
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
describe('golden queries of the catalog spec', () => {
|
|
241
|
+
const searcher = createCatalogSearcher(index, builtIn)
|
|
242
|
+
|
|
243
|
+
it.each(GOLDEN_IN_FIXTURE)('golden query "%s" keeps its expected result in the top 3', (query, modules, builtIns) => {
|
|
244
|
+
const result = searchModules(searcher, { query })
|
|
245
|
+
const top = result.results.slice(0, 3).map((card) => card.locator.replace(/^npm:/, ''))
|
|
246
|
+
const topBuiltIn = result.builtIn.slice(0, 3).map((card) => card.id)
|
|
247
|
+
for (const name of modules) expect(top).toContain(name)
|
|
248
|
+
for (const id of builtIns) expect(topBuiltIn).toContain(id)
|
|
249
|
+
})
|
|
250
|
+
})
|
|
251
|
+
|
|
252
|
+
describe.each(parityRuns)('parity with the catalog get_module tool (tools@1), $name', ({ cases, data }) => {
|
|
253
|
+
const searcher = createCatalogSearcher(data.index, data.builtIn)
|
|
254
|
+
const today = parity.now.slice(0, 10)
|
|
255
|
+
|
|
256
|
+
it.each(cases.info.map((item) => [item.ref, item] as const))('%s', (ref, expected) => {
|
|
257
|
+
const view = buildInfoView(searcher, ref, { omVersion: null, enabledModules: null }, today)
|
|
258
|
+
if (!expected.ok) {
|
|
259
|
+
expect(view.found).toBe(false)
|
|
260
|
+
expect(view.json).toEqual({ schemaVersion: 1, error: expected.error, candidates: expected.candidates })
|
|
261
|
+
return
|
|
262
|
+
}
|
|
263
|
+
expect(view.found).toBe(true)
|
|
264
|
+
if ('error' in view.json) throw new Error('expected an entry')
|
|
265
|
+
expect(view.json.entry?.locator ?? null).toBe(expected.locator)
|
|
266
|
+
expect(view.json.candidates).toEqual(expected.candidates)
|
|
267
|
+
expect(view.json.warnings).toEqual(expected.warnings)
|
|
268
|
+
expect(view.json.card).toBe(expected.card)
|
|
269
|
+
})
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
describe('resolveLine', () => {
|
|
273
|
+
it('maps exact, major.minor, ranges and develop builds to catalog lines', () => {
|
|
274
|
+
expect(resolveLine('0.9.0', index.lines).line).toBe('0.9')
|
|
275
|
+
expect(resolveLine('^0.8.0', index.lines).line).toBe('0.8')
|
|
276
|
+
expect(resolveLine('0.9', index.lines).line).toBe('0.9')
|
|
277
|
+
expect(resolveLine('0.10.1-develop.7590.1.abc', index.lines).line).toBe('next')
|
|
278
|
+
expect(resolveLine('0.7.4', index.lines)).toEqual({ line: null, version: null, note: 'Line 0.7 is not tested by the catalog.' })
|
|
279
|
+
expect(resolveLine(null, index.lines).line).toBe('0.9')
|
|
280
|
+
})
|
|
281
|
+
})
|
|
282
|
+
|
|
283
|
+
describe('module search catalog version forms', () => {
|
|
284
|
+
it.each([
|
|
285
|
+
'0.10.1-develop.1+build', '0.9.0+build', '0.9.0-rc.01', '0.10.1-develop.01',
|
|
286
|
+
'00.9.0', '0.09.0', '0.9.00', '0.9.0-rc..1', '0.9.0-rc.', '0.9-rc.1',
|
|
287
|
+
])('rejects non-catalog version %s', (version) => {
|
|
288
|
+
expect(resolveLine(version, index.lines)).toEqual({ line: null, version: null, note: 'Unknown Open Mercato version.' })
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
it.each(['0.9.0-rc.0', '0.9.0-rc.1a', '~0.9.2', 'v0.9.0'])('keeps valid version %s', (version) => {
|
|
292
|
+
expect(resolveLine(version, index.lines).line).toBe('0.9')
|
|
293
|
+
})
|
|
294
|
+
})
|
|
295
|
+
|
|
296
|
+
describe('module search visibility regressions', () => {
|
|
297
|
+
function entry(locator: string, title: string, verified: boolean, kind: CatalogEntry['kind'] = 'module'): CatalogEntry {
|
|
298
|
+
const base = structuredClone(index.entries[0])
|
|
299
|
+
return {
|
|
300
|
+
...base, locator, title, kind, npm: locator, summary: '', whenToUse: '', tags: [], providers: [],
|
|
301
|
+
moduleIds: [], renamedFrom: [], anatomy: null, _meta: {}, listed: true,
|
|
302
|
+
version: { ...base.version, recommended: verified ? { '0.9': '0.9.0' } : {} },
|
|
303
|
+
compat: { ...base.compat, lines: {}, verifiedOn: verified ? ['0.9'] : [] },
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
it.each([0, 1])('fills verified partial matches despite three hidden AND hits (%s visible AND)', (visibleAnd) => {
|
|
308
|
+
const entries = [
|
|
309
|
+
...[1, 2, 3].map((number) => entry(`hidden-${number}`, 'quantum zebra', false)),
|
|
310
|
+
entry('partial', 'quantum', true),
|
|
311
|
+
...(visibleAnd ? [entry('exact', 'quantum zebra', true)] : []),
|
|
312
|
+
]
|
|
313
|
+
const searcher = createCatalogSearcher({ ...index, entries }, null)
|
|
314
|
+
const view = buildSearchView(searcher, { query: 'quantum zebra' }, { omVersion: '0.9.0', enabledModules: null })
|
|
315
|
+
expect(view.json.results.map((card) => card.locator)).toContain('partial')
|
|
316
|
+
expect(view.json.results.every((card) => !card.locator.startsWith('hidden-'))).toBe(true)
|
|
317
|
+
expect(view.json.hidden).toBe(3)
|
|
318
|
+
expect(view.json.total).toBe(3 + visibleAnd)
|
|
319
|
+
const all = buildSearchView(searcher, { query: 'quantum zebra', allLines: true }, { omVersion: '0.9.0', enabledModules: null })
|
|
320
|
+
expect(all.json.results.map((card) => card.locator)).toContain('hidden-1')
|
|
321
|
+
expect(all.json.hidden).toBe(0)
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
it('retries a typo when only unverified modules match the original spelling', () => {
|
|
325
|
+
const searcher = createCatalogSearcher({ ...index, entries: [
|
|
326
|
+
entry('hidden', 'stirpe', false), entry('visible', 'stripe', true),
|
|
327
|
+
] }, null)
|
|
328
|
+
const view = buildSearchView(searcher, { query: 'stirpe' }, { omVersion: '0.9.0', enabledModules: null })
|
|
329
|
+
expect(view.json.results.map((card) => card.locator)).toEqual(['visible'])
|
|
330
|
+
expect(view.json.didYouMean).toBe('stripe')
|
|
331
|
+
expect(view.json.hidden).toBe(1)
|
|
332
|
+
})
|
|
333
|
+
|
|
334
|
+
it('retains unverified providers, libraries and tools while filtering modules before ranking', () => {
|
|
335
|
+
const entries = (['provider', 'library', 'tool', 'module'] as const).map((kind) => entry(kind, 'quantum', false, kind))
|
|
336
|
+
const view = buildSearchView(createCatalogSearcher({ ...index, entries }, null), { query: 'quantum' }, { omVersion: '0.9.0', enabledModules: null })
|
|
337
|
+
expect(view.json.results.map((card) => card.kind).sort()).toEqual(['library', 'provider', 'tool'])
|
|
338
|
+
expect(view.json.hidden).toBe(1)
|
|
339
|
+
})
|
|
340
|
+
})
|
|
341
|
+
|
|
342
|
+
describe('yarn mercato module search', () => {
|
|
343
|
+
it('prints the tools@1 contract for "ksef" --json', async () => {
|
|
344
|
+
const io = capture()
|
|
345
|
+
const { fetchImpl } = fixtureFetch()
|
|
346
|
+
const code = await runModuleSearch(['ksef', '--json'], deps(tempApp({ coreVersion: '0.9.0' }), fetchImpl, io))
|
|
347
|
+
expect(code).toBe(0)
|
|
348
|
+
const json = JSON.parse(io.stdout.join('\n'))
|
|
349
|
+
expect(Object.keys(json).sort()).toEqual(
|
|
350
|
+
[
|
|
351
|
+
'builtIn',
|
|
352
|
+
'dataVersion',
|
|
353
|
+
'generatedAt',
|
|
354
|
+
'hidden',
|
|
355
|
+
'line',
|
|
356
|
+
'omVersion',
|
|
357
|
+
'query',
|
|
358
|
+
'receiptSource',
|
|
359
|
+
'results',
|
|
360
|
+
'schemaVersion',
|
|
361
|
+
'total',
|
|
362
|
+
],
|
|
363
|
+
)
|
|
364
|
+
expect(json).toMatchObject({ schemaVersion: 1, query: 'ksef', line: '0.9', omVersion: '0.9.0', hidden: 0 })
|
|
365
|
+
expect(json.dataVersion).toBe(index.dataVersion)
|
|
366
|
+
expect(json.results[0].locator).toBe('npm:@fastwhitecat/integration-ksef-direct')
|
|
367
|
+
expect(Object.keys(json.results[0]).sort()).toEqual(MODULE_CARD_KEYS)
|
|
368
|
+
expect(json.results[0].install).toBe('yarn mercato module add @fastwhitecat/integration-ksef-direct@0.1.8 --allow-third-party')
|
|
369
|
+
expect(json.results[0].card).toBe('https://modules.openmercato.com/m/@fastwhitecat/integration-ksef-direct')
|
|
370
|
+
})
|
|
371
|
+
|
|
372
|
+
it('shows built-in modules first with the enable command, or "Already enabled." when src/modules.ts has them', async () => {
|
|
373
|
+
const first = capture()
|
|
374
|
+
const { fetchImpl } = fixtureFetch()
|
|
375
|
+
await runModuleSearch(['exchange', 'rates'], deps(tempApp({ coreVersion: '0.9.0' }), fetchImpl, first))
|
|
376
|
+
expect(first.stdout[0]).toBe('Already in Open Mercato core:')
|
|
377
|
+
expect(first.stdout[1]).toContain('yarn mercato module enable @open-mercato/core --module currencies')
|
|
378
|
+
|
|
379
|
+
const second = capture()
|
|
380
|
+
const app = tempApp({
|
|
381
|
+
coreVersion: '0.9.0',
|
|
382
|
+
modulesTs: "export const enabledModules = [\n { id: 'auth', from: '@open-mercato/core' },\n { id: 'currencies' },\n]\n",
|
|
383
|
+
})
|
|
384
|
+
await runModuleSearch(['exchange rates', '--json'], deps(app, fetchImpl, second))
|
|
385
|
+
expect(JSON.parse(second.stdout.join('\n')).builtIn[0]).toMatchObject({ id: 'currencies', enabled: true })
|
|
386
|
+
const third = capture()
|
|
387
|
+
await runModuleSearch(['exchange rates'], deps(app, fetchImpl, third))
|
|
388
|
+
expect(third.stdout[1]).toContain('Already enabled.')
|
|
389
|
+
expect(Object.keys(JSON.parse(second.stdout.join('\n')).builtIn[0]).sort()).toEqual(BUILT_IN_CARD_KEYS)
|
|
390
|
+
})
|
|
391
|
+
|
|
392
|
+
it('hides modules not verified on the app line unless --all-lines is passed', async () => {
|
|
393
|
+
const { fetchImpl } = fixtureFetch()
|
|
394
|
+
const app = tempApp({ coreVersion: '0.9.0' })
|
|
395
|
+
const human = capture()
|
|
396
|
+
await runModuleSearch(['gateway'], deps(app, fetchImpl, human))
|
|
397
|
+
const text = human.stdout.join('\n')
|
|
398
|
+
expect(text).toContain('@open-mercato/gateway-stripe 0.9.0 VERIFIED · 0.9 official · MIT')
|
|
399
|
+
expect(text).not.toContain('@open-mercato/gateway-tpay')
|
|
400
|
+
expect(text).toContain('1 more module is listed but not verified on 0.9. Use --all-lines.')
|
|
401
|
+
|
|
402
|
+
const all = capture()
|
|
403
|
+
await runModuleSearch(['gateway', '--all-lines', '--json'], deps(app, fetchImpl, all))
|
|
404
|
+
const json = JSON.parse(all.stdout.join('\n'))
|
|
405
|
+
expect(json.hidden).toBe(0)
|
|
406
|
+
expect(json.results.map((card: { locator: string }) => card.locator)).toEqual([
|
|
407
|
+
'npm:@open-mercato/gateway-stripe',
|
|
408
|
+
'npm:@open-mercato/gateway-tpay',
|
|
409
|
+
])
|
|
410
|
+
})
|
|
411
|
+
|
|
412
|
+
it('says that nothing verified on the app line matched when every match is hidden', async () => {
|
|
413
|
+
const io = capture()
|
|
414
|
+
await runModuleSearch(['ksef'], deps(tempApp({ coreVersion: '0.8.0' }), fixtureFetch().fetchImpl, io))
|
|
415
|
+
expect(io.stdout).toEqual([
|
|
416
|
+
'No modules verified on 0.8 matched "ksef".',
|
|
417
|
+
'1 more module is listed but not verified on 0.8. Use --all-lines.',
|
|
418
|
+
'Browse the catalog: https://modules.openmercato.com',
|
|
419
|
+
])
|
|
420
|
+
})
|
|
421
|
+
|
|
422
|
+
it('prints installable from only while the date is still ahead', async () => {
|
|
423
|
+
const app = tempApp({ coreVersion: '0.8.0' })
|
|
424
|
+
const past = capture()
|
|
425
|
+
await runModuleSearch(['ksef', '--all-lines'], deps(app, fixtureFetch().fetchImpl, past))
|
|
426
|
+
expect(past.stdout.join('\n')).toContain('@fastwhitecat/integration-ksef-direct 0.1.8')
|
|
427
|
+
expect(past.stdout.join('\n')).not.toContain('installable from')
|
|
428
|
+
|
|
429
|
+
const ahead = capture()
|
|
430
|
+
await runModuleSearch(['ksef', '--all-lines'], deps(tempApp({ coreVersion: '0.8.0' }), fixtureFetch().fetchImpl, ahead, Date.parse('2026-10-15T12:00:00Z')))
|
|
431
|
+
expect(ahead.stdout).toContain(' installable from: 2026-10-20')
|
|
432
|
+
})
|
|
433
|
+
|
|
434
|
+
it('uses the line of the installed @open-mercato/core, then the package.json range', async () => {
|
|
435
|
+
const { fetchImpl } = fixtureFetch()
|
|
436
|
+
const installed = capture()
|
|
437
|
+
await runModuleSearch(['ksef', '--json', '--all-lines'], deps(tempApp({ coreVersion: '0.8.0' }), fetchImpl, installed))
|
|
438
|
+
expect(JSON.parse(installed.stdout.join('\n'))).toMatchObject({ line: '0.8', omVersion: '0.8.0' })
|
|
439
|
+
const ranged = capture()
|
|
440
|
+
await runModuleSearch(['ksef', '--json'], deps(tempApp({ coreRange: '^0.9.0' }), fetchImpl, ranged))
|
|
441
|
+
expect(JSON.parse(ranged.stdout.join('\n'))).toMatchObject({ line: '0.9', omVersion: '0.9.0' })
|
|
442
|
+
})
|
|
443
|
+
|
|
444
|
+
it('shows every line with a note when the app runs a version the catalog does not test', async () => {
|
|
445
|
+
const { fetchImpl } = fixtureFetch()
|
|
446
|
+
const io = capture()
|
|
447
|
+
await runModuleSearch(['gateway'], deps(tempApp({ coreVersion: '0.7.2' }), fetchImpl, io))
|
|
448
|
+
expect(io.stdout[0]).toContain('Open Mercato 0.7.2 is not a line the catalog tests')
|
|
449
|
+
expect(io.stdout.join('\n')).toContain('@open-mercato/gateway-tpay')
|
|
450
|
+
})
|
|
451
|
+
|
|
452
|
+
it('applies --category, --kind and --limit', async () => {
|
|
453
|
+
const { fetchImpl } = fixtureFetch()
|
|
454
|
+
const io = capture()
|
|
455
|
+
await runModuleSearch(
|
|
456
|
+
['sync', '--kind', 'module', '--limit=1', '--all-lines', '--json', '--category', 'integrations-sync'],
|
|
457
|
+
deps(tempApp({ coreVersion: '0.9.0' }), fetchImpl, io),
|
|
458
|
+
)
|
|
459
|
+
const json = JSON.parse(io.stdout.join('\n'))
|
|
460
|
+
expect(json.results).toHaveLength(1)
|
|
461
|
+
expect(json.results[0].category).toBe('integrations-sync')
|
|
462
|
+
expect(json.builtIn).toEqual([])
|
|
463
|
+
})
|
|
464
|
+
|
|
465
|
+
it('lists what --category picks without a query', async () => {
|
|
466
|
+
const io = capture()
|
|
467
|
+
const { fetchImpl } = fixtureFetch()
|
|
468
|
+
const code = await runModuleSearch(['--category', 'payments-finance', '--json'], deps(tempApp({ coreVersion: '0.9.0' }), fetchImpl, io))
|
|
469
|
+
expect(code).toBe(0)
|
|
470
|
+
const json = JSON.parse(io.stdout.join('\n'))
|
|
471
|
+
expect(json.query).toBe('')
|
|
472
|
+
expect(json.results.map((card: { locator: string }) => card.locator)).toEqual(['npm:@open-mercato/gateway-stripe'])
|
|
473
|
+
expect(json.results[0].matchedOn).toEqual(['category payments-finance'])
|
|
474
|
+
expect(json.builtIn.map((card: { id: string }) => card.id)).toEqual(['currencies'])
|
|
475
|
+
expect(json.hidden).toBe(1)
|
|
476
|
+
})
|
|
477
|
+
|
|
478
|
+
it('ignores stop words, so "when a deal is won" lists nothing', async () => {
|
|
479
|
+
const io = capture()
|
|
480
|
+
const { fetchImpl } = fixtureFetch()
|
|
481
|
+
await runModuleSearch(['when a deal is won', '--all-lines'], deps(tempApp({ coreVersion: '0.9.0' }), fetchImpl, io))
|
|
482
|
+
expect(io.stdout[0]).toBe('No modules matched "when a deal is won".')
|
|
483
|
+
})
|
|
484
|
+
|
|
485
|
+
it('names the spelling it searched when one swap of two letters is undone', async () => {
|
|
486
|
+
const io = capture()
|
|
487
|
+
const { fetchImpl } = fixtureFetch()
|
|
488
|
+
await runModuleSearch(['stirpe'], deps(tempApp({ coreVersion: '0.9.0' }), fetchImpl, io))
|
|
489
|
+
expect(io.stdout[0]).toBe('Nothing matched "stirpe". Showing results for "stripe".')
|
|
490
|
+
expect(io.stdout.join('\n')).toContain('@open-mercato/gateway-stripe 0.9.0')
|
|
491
|
+
})
|
|
492
|
+
|
|
493
|
+
it('says there is nothing to install where a new app already registers the package or has the core module on', async () => {
|
|
494
|
+
const patch = parity.variants[0]?.patch as ParityPatch
|
|
495
|
+
const app = tempApp({ coreVersion: '0.9.0' })
|
|
496
|
+
const stripe = capture()
|
|
497
|
+
await runModuleSearch(['stripe'], deps(app, fixtureFetch({ patch }).fetchImpl, stripe))
|
|
498
|
+
expect(stripe.stdout).toContain(
|
|
499
|
+
' install: Nothing to install: a new app already registers gateway_stripe in src/modules.ts. In an app from the empty preset: yarn mercato module add @open-mercato/gateway-stripe@0.9.0',
|
|
500
|
+
)
|
|
501
|
+
const rates = capture()
|
|
502
|
+
await runModuleSearch(['exchange rates'], deps(tempApp({ coreVersion: '0.9.0' }), fixtureFetch({ patch }).fetchImpl, rates))
|
|
503
|
+
expect(rates.stdout[1]).toContain('On in a new app on 0.9: nothing to enable.')
|
|
504
|
+
const info = capture()
|
|
505
|
+
await runModuleInfo(['currencies'], deps(tempApp({ coreVersion: '0.9.0' }), fixtureFetch({ patch }).fetchImpl, info))
|
|
506
|
+
expect(info.stdout).toContain(
|
|
507
|
+
' On in a new app on 0.9: nothing to enable. In an app from the empty preset: yarn mercato module enable @open-mercato/core --module currencies',
|
|
508
|
+
)
|
|
509
|
+
})
|
|
510
|
+
|
|
511
|
+
it('prints usage without a query or a filter', async () => {
|
|
512
|
+
const io = capture()
|
|
513
|
+
expect(await runModuleSearch([], deps(tempApp(), fixtureFetch().fetchImpl, io))).toBe(1)
|
|
514
|
+
expect(io.stderr[0]).toContain('Usage: yarn mercato module search [<query>]')
|
|
515
|
+
})
|
|
516
|
+
})
|
|
517
|
+
|
|
518
|
+
describe('providers, libraries and tools, follow-up steps and the app line', () => {
|
|
519
|
+
const variant = parity.variants.find((item) => item.name === 'adapters, libraries and tools') as (typeof parity.variants)[number]
|
|
520
|
+
const patch = variant.patch
|
|
521
|
+
|
|
522
|
+
it.each([
|
|
523
|
+
['0.8.0', '0.8.0'],
|
|
524
|
+
['0.10.1-develop.7590.1.abc', '0.10.1-develop.7583.1.0c886d0a14'],
|
|
525
|
+
])('adds the library an adapter needs to its yarn add on %s', async (coreVersion, version) => {
|
|
526
|
+
const app = tempApp({ coreVersion })
|
|
527
|
+
const human = capture()
|
|
528
|
+
await runModuleSearch(['web research', '--all-lines'], deps(app, fixtureFetch({ patch }).fetchImpl, human))
|
|
529
|
+
expect(human.stdout).toContain(
|
|
530
|
+
` install: yarn add @open-mercato/web-research@${version} @open-mercato/web-research-model@${version} && yarn generate`,
|
|
531
|
+
)
|
|
532
|
+
const json = capture()
|
|
533
|
+
await runModuleSearch(['web research', '--all-lines', '--json'], deps(app, fixtureFetch({ patch }).fetchImpl, json))
|
|
534
|
+
const model = JSON.parse(json.stdout.join('\n')).results.find(
|
|
535
|
+
(card: { locator: string }) => card.locator === 'npm:@open-mercato/web-research-model',
|
|
536
|
+
)
|
|
537
|
+
expect(model.install).toBe(`yarn add @open-mercato/web-research@${version} @open-mercato/web-research-model@${version}`)
|
|
538
|
+
})
|
|
539
|
+
|
|
540
|
+
it('lists providers, libraries and tools on the app line with their status, not as hidden', async () => {
|
|
541
|
+
const app = tempApp({ coreVersion: '0.9.0' })
|
|
542
|
+
const provider = capture()
|
|
543
|
+
await runModuleSearch(['--kind', 'provider'], deps(app, fixtureFetch({ patch }).fetchImpl, provider))
|
|
544
|
+
expect(provider.stdout).toContain('@open-mercato/web-research-model 0.9.0 LISTED · untested on 0.9 official · MIT')
|
|
545
|
+
expect(provider.stdout.join('\n')).not.toContain('Use --all-lines.')
|
|
546
|
+
|
|
547
|
+
const query = capture()
|
|
548
|
+
await runModuleSearch(['web research', '--json'], deps(app, fixtureFetch({ patch }).fetchImpl, query))
|
|
549
|
+
const json = JSON.parse(query.stdout.join('\n'))
|
|
550
|
+
expect(json.hidden).toBe(0)
|
|
551
|
+
expect(json.results.map((card: { locator: string }) => card.locator)).toEqual([
|
|
552
|
+
'npm:@open-mercato/web-research',
|
|
553
|
+
'npm:@open-mercato/web-research-model',
|
|
554
|
+
])
|
|
555
|
+
expect(json.results[0].install).toBe('yarn add @open-mercato/web-research@0.9.0')
|
|
556
|
+
|
|
557
|
+
const library = capture()
|
|
558
|
+
await runModuleSearch(['--kind', 'library'], deps(app, fixtureFetch({ patch }).fetchImpl, library))
|
|
559
|
+
expect(library.stdout).toContain(' install: yarn add @open-mercato/web-research@0.9.0 && yarn generate')
|
|
560
|
+
|
|
561
|
+
const tool = capture()
|
|
562
|
+
await runModuleSearch(['--kind', 'tool'], deps(app, fixtureFetch({ patch }).fetchImpl, tool))
|
|
563
|
+
expect(tool.stdout).toContain(' install: npx create-mercato-module@0.4.2')
|
|
564
|
+
})
|
|
565
|
+
|
|
566
|
+
it('still hides modules not verified on the app line and counts only those', async () => {
|
|
567
|
+
const io = capture()
|
|
568
|
+
await runModuleSearch(['--category', 'payments-finance', '--json'], deps(tempApp({ coreVersion: '0.9.0' }), fixtureFetch({ patch }).fetchImpl, io))
|
|
569
|
+
expect(JSON.parse(io.stdout.join('\n')).hidden).toBe(1)
|
|
570
|
+
})
|
|
571
|
+
|
|
572
|
+
it('prints generate after create-mercato-module and db:migrate after a module install that adds tables', async () => {
|
|
573
|
+
const app = tempApp({ coreVersion: '0.9.0' })
|
|
574
|
+
const treg = capture()
|
|
575
|
+
await runModuleInfo(['github:Chmarusso/open-mercato-enrichment-treg'], deps(app, fixtureFetch().fetchImpl, treg))
|
|
576
|
+
expect(treg.stdout).toContain(
|
|
577
|
+
' install: npx create-mercato-module install Chmarusso/open-mercato-enrichment-treg && yarn generate && yarn db:migrate',
|
|
578
|
+
)
|
|
579
|
+
const ksef = capture()
|
|
580
|
+
await runModuleInfo(['@fastwhitecat/integration-ksef-direct'], deps(app, fixtureFetch().fetchImpl, ksef))
|
|
581
|
+
expect(ksef.stdout).toContain(
|
|
582
|
+
' install: yarn mercato module add @fastwhitecat/integration-ksef-direct@0.1.8 --allow-third-party && yarn db:migrate',
|
|
583
|
+
)
|
|
584
|
+
const stripe = capture()
|
|
585
|
+
await runModuleSearch(['stripe'], deps(app, fixtureFetch().fetchImpl, stripe))
|
|
586
|
+
expect(stripe.stdout).toContain(' install: yarn mercato module add @open-mercato/gateway-stripe@0.9.0')
|
|
587
|
+
const enterprise = capture()
|
|
588
|
+
await runModuleInfo(['@open-mercato/enterprise'], deps(app, fixtureFetch().fetchImpl, enterprise))
|
|
589
|
+
expect(enterprise.stdout.filter((line) => line.startsWith(' install:')).join('\n')).not.toMatch(/yarn generate.*yarn generate/)
|
|
590
|
+
const json = capture()
|
|
591
|
+
await runModuleInfo(['@fastwhitecat/integration-ksef-direct', '--json'], deps(app, fixtureFetch().fetchImpl, json))
|
|
592
|
+
expect(JSON.parse(json.stdout.join('\n')).entry.install.cli).toBe(
|
|
593
|
+
'yarn mercato module add @fastwhitecat/integration-ksef-direct@0.1.8 --allow-third-party',
|
|
594
|
+
)
|
|
595
|
+
})
|
|
596
|
+
|
|
597
|
+
it('adds the steps once to multi-module, enterprise and empty-preset commands', () => {
|
|
598
|
+
const ksef = index.entries.find((entry) => entry.locator === 'npm:@fastwhitecat/integration-ksef-direct') as CatalogEntry
|
|
599
|
+
const enterprise = index.entries.find((entry) => entry.locator === 'npm:@open-mercato/enterprise') as CatalogEntry
|
|
600
|
+
const several = 'yarn mercato module add x@1.0.0 --module a && yarn mercato module add x@1.0.0 --module b'
|
|
601
|
+
expect(withFollowUpSteps(several, ksef)).toBe(`${several} && yarn db:migrate`)
|
|
602
|
+
const step = 'echo OM_ENABLE_ENTERPRISE_MODULES=true >> .env && yarn generate'
|
|
603
|
+
expect(withFollowUpSteps(step, enterprise)).toBe(`${step} && yarn db:migrate`)
|
|
604
|
+
const migrationsOnly = { ...ksef, anatomy: { version: '1.0.0', counts: { migrations: 2 }, lists: { tables: [] } } }
|
|
605
|
+
expect(withFollowUpSteps('yarn mercato module add x@1.0.0', migrationsOnly)).toBe('yarn mercato module add x@1.0.0 && yarn db:migrate')
|
|
606
|
+
const githubLibrary = { ...ksef, kind: 'library' as const, anatomy: null }
|
|
607
|
+
expect(withFollowUpSteps('npx create-mercato-module install o/r', githubLibrary)).toBe(
|
|
608
|
+
'npx create-mercato-module install o/r && yarn generate',
|
|
609
|
+
)
|
|
610
|
+
})
|
|
611
|
+
|
|
612
|
+
it('adds db:migrate to the empty-preset command of a preset note', async () => {
|
|
613
|
+
const patch: ParityPatch = { entries: { 'npm:@fastwhitecat/integration-ksef-direct': { compat: { inPresets: ['0.9'] } } } }
|
|
614
|
+
const io = capture()
|
|
615
|
+
await runModuleSearch(['ksef'], deps(tempApp({ coreVersion: '0.9.0' }), fixtureFetch({ patch }).fetchImpl, io))
|
|
616
|
+
expect(io.stdout).toContain(
|
|
617
|
+
' install: Nothing to install: a new app already registers integration_ksef_direct in src/modules.ts. In an app from the empty preset: yarn mercato module add @fastwhitecat/integration-ksef-direct@0.1.8 --allow-third-party && yarn db:migrate',
|
|
618
|
+
)
|
|
619
|
+
})
|
|
620
|
+
|
|
621
|
+
it('reads conditional registrations in src/modules.ts with the injected environment', async () => {
|
|
622
|
+
const modulesTs = [
|
|
623
|
+
"export const enabledModules = [{ id: 'auth', from: '@open-mercato/core' }]",
|
|
624
|
+
"if (process.env.OM_TEST_CURRENCIES) enabledModules.push({ id: 'currencies', from: '@open-mercato/core' })",
|
|
625
|
+
'',
|
|
626
|
+
].join('\n')
|
|
627
|
+
const app = tempApp({ coreVersion: '0.9.0', modulesTs })
|
|
628
|
+
const off = capture()
|
|
629
|
+
await runModuleSearch(['exchange rates'], deps(app, fixtureFetch().fetchImpl, off))
|
|
630
|
+
expect(off.stdout.join('\n')).not.toContain('Already enabled.')
|
|
631
|
+
const offInfo = capture()
|
|
632
|
+
await runModuleInfo(['currencies'], deps(app, fixtureFetch().fetchImpl, offInfo))
|
|
633
|
+
expect(offInfo.stdout.join('\n')).not.toContain('Already enabled.')
|
|
634
|
+
|
|
635
|
+
const env = { OM_TEST_CURRENCIES: 'true' }
|
|
636
|
+
const on = capture()
|
|
637
|
+
await runModuleSearch(['exchange rates'], { ...deps(app, fixtureFetch().fetchImpl, on), env })
|
|
638
|
+
expect(on.stdout[1]).toContain('Already enabled.')
|
|
639
|
+
const onInfo = capture()
|
|
640
|
+
await runModuleInfo(['currencies'], { ...deps(app, fixtureFetch().fetchImpl, onInfo), env })
|
|
641
|
+
expect(onInfo.stdout).toContain(' Already enabled.')
|
|
642
|
+
})
|
|
643
|
+
|
|
644
|
+
it('gives module info --json the preset advice of the app line', () => {
|
|
645
|
+
const data = patchedFixture({ builtIn: { currencies: { inPresets: ['0.8', '0.9', 'next'], inEmptyPreset: ['0.9', 'next'] } } })
|
|
646
|
+
const searcher = createCatalogSearcher(data.index, data.builtIn)
|
|
647
|
+
const today = parity.now.slice(0, 10)
|
|
648
|
+
const enable = 'yarn mercato module enable @open-mercato/core --module currencies'
|
|
649
|
+
|
|
650
|
+
const older = buildInfoView(searcher, 'currencies', { omVersion: '0.8.0', enabledModules: null }, today)
|
|
651
|
+
if ('error' in older.json) throw new Error('expected a built-in module')
|
|
652
|
+
const presetNote = `On in a new app on 0.8: nothing to enable. In an app from the empty preset: ${enable}`
|
|
653
|
+
expect(older.json.warnings).toEqual(['Built into Open Mercato core as currencies.', presetNote])
|
|
654
|
+
expect(renderInfoHuman(older, searcher)).toContain(` ${presetNote}`)
|
|
655
|
+
|
|
656
|
+
const untested = buildInfoView(searcher, 'currencies', { omVersion: '0.7.4', enabledModules: null }, today)
|
|
657
|
+
if ('error' in untested.json) throw new Error('expected a built-in module')
|
|
658
|
+
expect(untested.json.warnings).toEqual([`Built into Open Mercato core as currencies. Enable it: ${enable}`])
|
|
659
|
+
expect(renderInfoHuman(untested, searcher)).toContain(` enable: ${enable}`)
|
|
660
|
+
})
|
|
661
|
+
})
|
|
662
|
+
|
|
663
|
+
describe('module search app-root resolution', () => {
|
|
664
|
+
it.each([
|
|
665
|
+
{ name: 'search', run: runModuleSearch, directory: '' },
|
|
666
|
+
{ name: 'info', run: runModuleInfo, directory: '' },
|
|
667
|
+
{ name: 'search', run: runModuleSearch, directory: 'nested/working' },
|
|
668
|
+
{ name: 'info', run: runModuleInfo, directory: 'nested/working' },
|
|
669
|
+
])('uses the resolved app for $name metadata and cache from "$directory"', async ({ run, directory }) => {
|
|
670
|
+
const root = tempApp({ coreVersion: '0.8.0' })
|
|
671
|
+
const app = path.join(root, 'apps', 'mercato')
|
|
672
|
+
fs.mkdirSync(path.join(root, 'packages', 'core', 'src', 'modules'), { recursive: true })
|
|
673
|
+
fs.mkdirSync(path.join(app, 'src'), { recursive: true })
|
|
674
|
+
fs.writeFileSync(path.join(app, 'package.json'), JSON.stringify({ dependencies: { '@open-mercato/core': '^0.9.0' } }))
|
|
675
|
+
fs.writeFileSync(path.join(app, 'src', 'modules.ts'), "export const enabledModules = [{ id: 'currencies', from: '@open-mercato/core' }]")
|
|
676
|
+
const cwd = process.cwd()
|
|
677
|
+
const workingDirectory = path.join(root, directory)
|
|
678
|
+
fs.mkdirSync(workingDirectory, { recursive: true })
|
|
679
|
+
process.chdir(workingDirectory)
|
|
680
|
+
const io = capture()
|
|
681
|
+
try {
|
|
682
|
+
const options = deps(root, fixtureFetch().fetchImpl, io)
|
|
683
|
+
delete options.appRoot
|
|
684
|
+
expect(await run(['currencies', '--json'], options)).toBe(0)
|
|
685
|
+
expect(JSON.parse(io.stdout.join('')).line).toBe('0.9')
|
|
686
|
+
if (run === runModuleSearch) expect(JSON.parse(io.stdout.join('')).builtIn[0].enabled).toBe(true)
|
|
687
|
+
expect(fs.existsSync(path.join(app, MODULE_INDEX_CACHE_FILE))).toBe(true)
|
|
688
|
+
expect(fs.existsSync(path.join(root, MODULE_INDEX_CACHE_FILE))).toBe(false)
|
|
689
|
+
} finally {
|
|
690
|
+
process.chdir(cwd)
|
|
691
|
+
fs.rmSync(root, { recursive: true, force: true })
|
|
692
|
+
}
|
|
693
|
+
})
|
|
694
|
+
|
|
695
|
+
it('keeps cwd outside an app and honors an explicit appRoot', async () => {
|
|
696
|
+
const root = tempApp()
|
|
697
|
+
const existsSync = fs.existsSync
|
|
698
|
+
const exists = jest.spyOn(fs, 'existsSync').mockImplementation((file) =>
|
|
699
|
+
String(file).endsWith(path.join('node_modules', '@open-mercato', 'core')) ? false : existsSync(file),
|
|
700
|
+
)
|
|
701
|
+
const explicit = tempApp({ coreVersion: '0.8.0' })
|
|
702
|
+
const cwd = process.cwd()
|
|
703
|
+
process.chdir(root)
|
|
704
|
+
try {
|
|
705
|
+
const io = capture()
|
|
706
|
+
const options = deps(root, fixtureFetch().fetchImpl, io)
|
|
707
|
+
delete options.appRoot
|
|
708
|
+
expect(await runModuleSearch(['stripe', '--json'], options)).toBe(0)
|
|
709
|
+
expect(fs.existsSync(path.join(root, MODULE_INDEX_CACHE_FILE))).toBe(true)
|
|
710
|
+
const override = capture()
|
|
711
|
+
await runModuleSearch(['stripe', '--json'], deps(explicit, fixtureFetch().fetchImpl, override))
|
|
712
|
+
expect(JSON.parse(override.stdout.join('')).line).toBe('0.8')
|
|
713
|
+
expect(fs.existsSync(path.join(explicit, MODULE_INDEX_CACHE_FILE))).toBe(true)
|
|
714
|
+
} finally {
|
|
715
|
+
process.chdir(cwd)
|
|
716
|
+
fs.rmSync(root, { recursive: true, force: true })
|
|
717
|
+
fs.rmSync(explicit, { recursive: true, force: true })
|
|
718
|
+
exists.mockRestore()
|
|
719
|
+
}
|
|
720
|
+
})
|
|
721
|
+
})
|
|
722
|
+
|
|
723
|
+
describe('module index transport bounds', () => {
|
|
724
|
+
it.each(['http://catalog.example/modules.json', 'ftp://localhost/modules.json', 'http://localhost.example/modules.json'])('rejects unsafe URL %s before fetching', async (url) => {
|
|
725
|
+
const fetchImpl = jest.fn(fixtureFetch().fetchImpl)
|
|
726
|
+
await expect(loadIndex({ appRoot: tempApp(), url, fetchImpl })).rejects.toThrow('HTTPS')
|
|
727
|
+
expect(fetchImpl).not.toHaveBeenCalled()
|
|
728
|
+
})
|
|
729
|
+
|
|
730
|
+
it.each(['localhost', '127.0.0.1', '[::1]'])('allows local HTTP on %s', async (host) => {
|
|
731
|
+
const loaded = await loadIndex({ appRoot: tempApp(), url: `http://${host}/modules.json`, fetchImpl: fixtureFetch().fetchImpl })
|
|
732
|
+
expect(loaded.source).toBe('network')
|
|
733
|
+
})
|
|
734
|
+
|
|
735
|
+
it('validates the built-in override too', async () => {
|
|
736
|
+
const fetchImpl = jest.fn(fixtureFetch().fetchImpl)
|
|
737
|
+
await expect(loadIndex({ appRoot: tempApp(), builtInUrl: 'http://remote.example/built-in.json', fetchImpl })).rejects.toThrow('HTTPS')
|
|
738
|
+
expect(fetchImpl).not.toHaveBeenCalled()
|
|
739
|
+
})
|
|
740
|
+
|
|
741
|
+
it('refuses HTTPS downgrades before requesting the redirect target', async () => {
|
|
742
|
+
const fetchImpl = jest.fn<ReturnType<FetchLike>, Parameters<FetchLike>>(async () => new Response(null, {
|
|
743
|
+
status: 302, headers: { location: 'http://remote.example/modules.json' },
|
|
744
|
+
}))
|
|
745
|
+
await expect(loadIndex({ appRoot: tempApp(), fetchImpl })).rejects.toThrow('HTTPS')
|
|
746
|
+
expect(fetchImpl.mock.calls.every(([url, init]) => url === DEFAULT_MODULES_INDEX_URL && init?.redirect === 'manual')).toBe(true)
|
|
747
|
+
})
|
|
748
|
+
|
|
749
|
+
it('follows HTTPS redirects', async () => {
|
|
750
|
+
const fixtures = fixtureFetch().fetchImpl
|
|
751
|
+
const fetchImpl: FetchLike = async (url, init) => url === DEFAULT_MODULES_INDEX_URL
|
|
752
|
+
? new Response(null, { status: 302, headers: { location: 'https://mirror.example/modules.json' } })
|
|
753
|
+
: fixtures(url, init)
|
|
754
|
+
expect((await loadIndex({ appRoot: tempApp(), fetchImpl })).source).toBe('network')
|
|
755
|
+
})
|
|
756
|
+
|
|
757
|
+
it('rejects oversized Content-Length before consuming the body', async () => {
|
|
758
|
+
const cancel = jest.fn()
|
|
759
|
+
const fetchImpl: FetchLike = async () => new Response(new ReadableStream({ cancel }), {
|
|
760
|
+
headers: { 'content-length': String(MODULE_INDEX_MAX_BYTES + 1) },
|
|
761
|
+
})
|
|
762
|
+
await expect(loadIndex({ appRoot: tempApp(), fetchImpl })).rejects.toThrow('exceeds')
|
|
763
|
+
expect(cancel).toHaveBeenCalledTimes(1)
|
|
764
|
+
})
|
|
765
|
+
|
|
766
|
+
it.each([undefined, '1'])('caps streamed bytes regardless of Content-Length (%s), cancels and keeps stale cache', async (length) => {
|
|
767
|
+
const app = tempApp()
|
|
768
|
+
await loadIndex({ appRoot: app, fetchImpl: fixtureFetch().fetchImpl, now: () => NOW })
|
|
769
|
+
const cache = fs.readFileSync(path.join(app, MODULE_INDEX_CACHE_FILE), 'utf8')
|
|
770
|
+
const cancel = jest.fn()
|
|
771
|
+
const fetchImpl: FetchLike = async () => new Response(new ReadableStream({
|
|
772
|
+
start(controller) {
|
|
773
|
+
controller.enqueue(new Uint8Array(MODULE_INDEX_MAX_BYTES))
|
|
774
|
+
controller.enqueue(new Uint8Array(1))
|
|
775
|
+
},
|
|
776
|
+
cancel,
|
|
777
|
+
}), { headers: length ? { 'content-length': length } : {} })
|
|
778
|
+
const loaded = await loadIndex({ appRoot: app, fetchImpl, now: () => NOW + 60 * 60 * 1000 })
|
|
779
|
+
expect(loaded.source).toBe('stale-cache')
|
|
780
|
+
expect(cancel).toHaveBeenCalledTimes(1)
|
|
781
|
+
expect(fs.readFileSync(path.join(app, MODULE_INDEX_CACHE_FILE), 'utf8')).toBe(cache)
|
|
782
|
+
})
|
|
783
|
+
|
|
784
|
+
it('accepts a streamed index exactly at the size limit', async () => {
|
|
785
|
+
const serialized = JSON.stringify(index)
|
|
786
|
+
const padded = serialized + ' '.repeat(MODULE_INDEX_MAX_BYTES - Buffer.byteLength(serialized))
|
|
787
|
+
const fetchImpl: FetchLike = async (url) => url.endsWith('/modules.json')
|
|
788
|
+
? new Response(padded)
|
|
789
|
+
: jsonResponse(200, builtIn)
|
|
790
|
+
expect((await loadIndex({ appRoot: tempApp(), fetchImpl })).source).toBe('network')
|
|
791
|
+
})
|
|
792
|
+
|
|
793
|
+
it('bounds redirect loops', async () => {
|
|
794
|
+
const fetchImpl = jest.fn<ReturnType<FetchLike>, Parameters<FetchLike>>(async () => new Response(null, {
|
|
795
|
+
status: 302, headers: { location: DEFAULT_MODULES_INDEX_URL },
|
|
796
|
+
}))
|
|
797
|
+
await expect(loadIndex({ appRoot: tempApp(), fetchImpl })).rejects.toThrow('redirects')
|
|
798
|
+
expect(fetchImpl).toHaveBeenCalledTimes(12)
|
|
799
|
+
})
|
|
800
|
+
|
|
801
|
+
it('reports an unsafe override through the normal unavailable exit code', async () => {
|
|
802
|
+
const io = capture()
|
|
803
|
+
const options = { ...deps(tempApp(), fixtureFetch().fetchImpl, io), env: { OM_MODULES_INDEX_URL: 'http://remote.example/modules.json' } }
|
|
804
|
+
expect(await runModuleSearch(['stripe'], options)).toBe(MODULE_INDEX_UNAVAILABLE_EXIT_CODE)
|
|
805
|
+
expect(io.stderr.join(' ')).toContain('HTTPS')
|
|
806
|
+
expect(io.stdout).toEqual([])
|
|
807
|
+
})
|
|
808
|
+
|
|
809
|
+
it('applies the cap to the built-in index', async () => {
|
|
810
|
+
const fetchImpl: FetchLike = async (url) => url.endsWith('/modules.json')
|
|
811
|
+
? jsonResponse(200, index)
|
|
812
|
+
: new Response('too large', { headers: { 'content-length': String(MODULE_INDEX_MAX_BYTES + 1) } })
|
|
813
|
+
const loaded = await loadIndex({ appRoot: tempApp(), fetchImpl })
|
|
814
|
+
expect(loaded.builtIn).toBeNull()
|
|
815
|
+
expect(loaded.builtInUnavailable).toContain('exceeds')
|
|
816
|
+
})
|
|
817
|
+
})
|
|
818
|
+
|
|
819
|
+
describe('module index download and offline cache', () => {
|
|
820
|
+
it('downloads modules.json and built-in.json from modules.openmercato.com and caches them', async () => {
|
|
821
|
+
const app = tempApp()
|
|
822
|
+
const { fetchImpl, calls } = fixtureFetch()
|
|
823
|
+
const loaded = await loadIndex({ appRoot: app, fetchImpl, now: () => NOW })
|
|
824
|
+
expect(loaded.source).toBe('network')
|
|
825
|
+
expect(calls.map((call) => call.url)).toEqual([
|
|
826
|
+
'https://modules.openmercato.com/modules.json',
|
|
827
|
+
'https://modules.openmercato.com/built-in.json',
|
|
828
|
+
])
|
|
829
|
+
expect(fs.existsSync(path.join(app, MODULE_INDEX_CACHE_FILE))).toBe(true)
|
|
830
|
+
expect(DEFAULT_MODULES_INDEX_URL).toBe('https://modules.openmercato.com/modules.json')
|
|
831
|
+
expect(defaultBuiltInUrl('https://mirror.example.com/catalog/modules.json?x=1')).toBe(
|
|
832
|
+
'https://mirror.example.com/catalog/built-in.json',
|
|
833
|
+
)
|
|
834
|
+
})
|
|
835
|
+
|
|
836
|
+
it('serves the cache within 10 minutes without touching the network', async () => {
|
|
837
|
+
const app = tempApp()
|
|
838
|
+
await loadIndex({ appRoot: app, fetchImpl: fixtureFetch().fetchImpl, now: () => NOW })
|
|
839
|
+
const offline = fixtureFetch({ fail: true })
|
|
840
|
+
const loaded = await loadIndex({ appRoot: app, fetchImpl: offline.fetchImpl, now: () => NOW + 9 * 60 * 1000 })
|
|
841
|
+
expect(loaded.source).toBe('cache')
|
|
842
|
+
expect(offline.calls).toHaveLength(0)
|
|
843
|
+
})
|
|
844
|
+
|
|
845
|
+
it('revalidates with the ETag after 10 minutes and keeps the copy on 304', async () => {
|
|
846
|
+
const app = tempApp()
|
|
847
|
+
await loadIndex({ appRoot: app, fetchImpl: fixtureFetch().fetchImpl, now: () => NOW })
|
|
848
|
+
const revalidate = fixtureFetch({ notModified: true })
|
|
849
|
+
const loaded = await loadIndex({ appRoot: app, fetchImpl: revalidate.fetchImpl, now: () => NOW + 11 * 60 * 1000 })
|
|
850
|
+
expect(loaded.source).toBe('network')
|
|
851
|
+
expect(revalidate.calls[0]?.headers['if-none-match']).toBe('"idx-1"')
|
|
852
|
+
expect(loaded.index.entries).toHaveLength(8)
|
|
853
|
+
})
|
|
854
|
+
|
|
855
|
+
it('retries once after a network error', async () => {
|
|
856
|
+
const flaky = fixtureFetch({ failFirst: 1 })
|
|
857
|
+
const loaded = await loadIndex({ appRoot: tempApp(), fetchImpl: flaky.fetchImpl, now: () => NOW })
|
|
858
|
+
expect(loaded.source).toBe('network')
|
|
859
|
+
expect(flaky.calls.filter((call) => call.url.endsWith('/modules.json'))).toHaveLength(2)
|
|
860
|
+
})
|
|
861
|
+
|
|
862
|
+
it('falls back to the stale cache offline and says so', async () => {
|
|
863
|
+
const app = tempApp({ coreVersion: '0.9.0' })
|
|
864
|
+
await loadIndex({ appRoot: app, fetchImpl: fixtureFetch().fetchImpl, now: () => NOW })
|
|
865
|
+
const io = capture()
|
|
866
|
+
const code = await runModuleSearch(['ksef'], deps(app, fixtureFetch({ fail: true }).fetchImpl, io, NOW + 60 * 60 * 1000))
|
|
867
|
+
expect(code).toBe(0)
|
|
868
|
+
expect(io.stderr).toEqual([`Using cached module index from ${new Date(NOW).toISOString()}.`])
|
|
869
|
+
expect(io.stdout[0]).toContain('@fastwhitecat/integration-ksef-direct 0.1.8')
|
|
870
|
+
})
|
|
871
|
+
|
|
872
|
+
it('keeps the cached copy when a new index is malformed or cannot be searched', async () => {
|
|
873
|
+
const app = tempApp({ coreVersion: '0.9.0' })
|
|
874
|
+
await loadIndex({ appRoot: app, fetchImpl: fixtureFetch().fetchImpl, now: () => NOW })
|
|
875
|
+
const cacheFile = path.join(app, MODULE_INDEX_CACHE_FILE)
|
|
876
|
+
const healthy = fs.readFileSync(cacheFile, 'utf8')
|
|
877
|
+
const body = readFixture('modules-index.json') as CatalogIndex
|
|
878
|
+
const [first] = body.entries as [CatalogEntry]
|
|
879
|
+
const responses = [
|
|
880
|
+
{ ...body, entries: body.entries.map((entry) => (entry === first ? { ...entry, providers: [null] } : entry)) },
|
|
881
|
+
// passes validation, but MiniSearch refuses a second document with the same locator
|
|
882
|
+
{ ...body, entries: [...body.entries, first] },
|
|
883
|
+
]
|
|
884
|
+
for (const response of responses) {
|
|
885
|
+
const fetchImpl: FetchLike = async (url) =>
|
|
886
|
+
url.endsWith('/modules.json') ? jsonResponse(200, response, '"idx-2"') : jsonResponse(200, readFixture('built-in.json'), '"bi-1"')
|
|
887
|
+
const io = capture()
|
|
888
|
+
const code = await runModuleSearch(['ksef'], deps(app, fetchImpl, io, NOW + 60 * 60 * 1000))
|
|
889
|
+
expect(code).toBe(0)
|
|
890
|
+
expect(io.stderr).toEqual([`Using cached module index from ${new Date(NOW).toISOString()}.`])
|
|
891
|
+
expect(io.stdout[0]).toContain('@fastwhitecat/integration-ksef-direct 0.1.8')
|
|
892
|
+
expect(fs.readFileSync(cacheFile, 'utf8')).toBe(healthy)
|
|
893
|
+
}
|
|
894
|
+
})
|
|
895
|
+
|
|
896
|
+
it('downloads a new copy when the cached one was written with fields this CLI cannot read', async () => {
|
|
897
|
+
const app = tempApp()
|
|
898
|
+
await loadIndex({ appRoot: app, fetchImpl: fixtureFetch().fetchImpl, now: () => NOW })
|
|
899
|
+
const cacheFile = path.join(app, MODULE_INDEX_CACHE_FILE)
|
|
900
|
+
const cache = JSON.parse(fs.readFileSync(cacheFile, 'utf8'))
|
|
901
|
+
cache.index.entries[0].providers = [null]
|
|
902
|
+
fs.writeFileSync(cacheFile, JSON.stringify(cache))
|
|
903
|
+
const { fetchImpl, calls } = fixtureFetch()
|
|
904
|
+
const loaded = await loadIndex({ appRoot: app, fetchImpl, now: () => NOW + 60 * 1000 })
|
|
905
|
+
expect(loaded.source).toBe('network')
|
|
906
|
+
expect(calls[0]?.headers['if-none-match']).toBeUndefined()
|
|
907
|
+
expect(loaded.searcher.modules.size).toBeGreaterThan(0)
|
|
908
|
+
})
|
|
909
|
+
|
|
910
|
+
it('exits with code 2 and a readable message offline without a cache', async () => {
|
|
911
|
+
const io = capture()
|
|
912
|
+
const code = await runModuleSearch(['ksef', '--json'], deps(tempApp(), fixtureFetch({ fail: true }).fetchImpl, io))
|
|
913
|
+
expect(code).toBe(MODULE_INDEX_UNAVAILABLE_EXIT_CODE)
|
|
914
|
+
expect(io.stderr).toEqual([MODULE_INDEX_UNAVAILABLE_MESSAGE, 'Reason: getaddrinfo ENOTFOUND modules.openmercato.com'])
|
|
915
|
+
expect(io.stdout).toEqual([])
|
|
916
|
+
})
|
|
917
|
+
|
|
918
|
+
it('names the URL and the HTTP status when OM_MODULES_INDEX_URL points to a missing file', async () => {
|
|
919
|
+
const io = capture()
|
|
920
|
+
const options = { ...deps(tempApp(), fixtureFetch().fetchImpl, io), env: { OM_MODULES_INDEX_URL: 'https://mirror.example.com/nope.json' } }
|
|
921
|
+
const code = await runModuleSearch(['ksef'], options)
|
|
922
|
+
expect(code).toBe(MODULE_INDEX_UNAVAILABLE_EXIT_CODE)
|
|
923
|
+
expect(io.stderr).toEqual([MODULE_INDEX_UNAVAILABLE_MESSAGE, 'Reason: https://mirror.example.com/nope.json answered 404'])
|
|
924
|
+
})
|
|
925
|
+
|
|
926
|
+
it('says so when built-in.json is missing and asks for it again on the next run', async () => {
|
|
927
|
+
const app = tempApp({ coreVersion: '0.9.0' })
|
|
928
|
+
const io = capture()
|
|
929
|
+
const code = await runModuleSearch(['exchange rates', '--json'], deps(app, fixtureFetch({ noBuiltIn: true }).fetchImpl, io))
|
|
930
|
+
expect(code).toBe(0)
|
|
931
|
+
expect(io.stderr).toEqual([BUILT_IN_UNAVAILABLE_MESSAGE, 'Reason: https://modules.openmercato.com/built-in.json answered 404'])
|
|
932
|
+
const json = JSON.parse(io.stdout.join('\n'))
|
|
933
|
+
expect(json.builtInUnavailable).toBe(true)
|
|
934
|
+
expect(json.builtIn).toEqual([])
|
|
935
|
+
|
|
936
|
+
const next = fixtureFetch()
|
|
937
|
+
const again = capture()
|
|
938
|
+
await runModuleSearch(['exchange', 'rates'], deps(app, next.fetchImpl, again, NOW + 60 * 1000))
|
|
939
|
+
expect(next.calls.map((call) => call.url)).toContain('https://modules.openmercato.com/built-in.json')
|
|
940
|
+
expect(again.stderr).toEqual([])
|
|
941
|
+
expect(again.stdout[0]).toBe('Already in Open Mercato core:')
|
|
942
|
+
})
|
|
943
|
+
|
|
944
|
+
it('keeps the cached built-in list when only built-in.json fails', async () => {
|
|
945
|
+
const app = tempApp()
|
|
946
|
+
await loadIndex({ appRoot: app, fetchImpl: fixtureFetch().fetchImpl, now: () => NOW })
|
|
947
|
+
const loaded = await loadIndex({
|
|
948
|
+
appRoot: app,
|
|
949
|
+
fetchImpl: fixtureFetch({ noBuiltIn: true }).fetchImpl,
|
|
950
|
+
now: () => NOW + 11 * 60 * 1000,
|
|
951
|
+
})
|
|
952
|
+
expect(loaded.source).toBe('network')
|
|
953
|
+
expect(loaded.builtIn).not.toBeNull()
|
|
954
|
+
expect(loaded.builtInUnavailable).toBeNull()
|
|
955
|
+
})
|
|
956
|
+
|
|
957
|
+
it('reads OM_MODULES_INDEX_URL', async () => {
|
|
958
|
+
const io = capture()
|
|
959
|
+
const { fetchImpl, calls } = fixtureFetch()
|
|
960
|
+
await runModuleSearch(['ksef', '--json'], {
|
|
961
|
+
...deps(tempApp(), fetchImpl, io),
|
|
962
|
+
env: { OM_MODULES_INDEX_URL: 'https://mirror.example.com/om/modules.json' },
|
|
963
|
+
})
|
|
964
|
+
expect(calls[0]?.url).toBe('https://mirror.example.com/om/modules.json')
|
|
965
|
+
expect(calls[1]?.url).toBe('https://mirror.example.com/om/built-in.json')
|
|
966
|
+
})
|
|
967
|
+
})
|
|
968
|
+
|
|
969
|
+
describe('yarn mercato module info', () => {
|
|
970
|
+
it('prints the card, line statuses, agent policy and install command', async () => {
|
|
971
|
+
const io = capture()
|
|
972
|
+
const code = await runModuleInfo(
|
|
973
|
+
['@fastwhitecat/integration-ksef-direct'],
|
|
974
|
+
deps(tempApp({ coreVersion: '0.9.0' }), fixtureFetch().fetchImpl, io),
|
|
975
|
+
)
|
|
976
|
+
expect(code).toBe(0)
|
|
977
|
+
const text = io.stdout.join('\n')
|
|
978
|
+
expect(text).toContain('@fastwhitecat/integration-ksef-direct 0.1.8 VERIFIED · 0.9 3rd-party · MIT')
|
|
979
|
+
expect(text).toContain('lines: 0.9 verified · 0.8 untested · next verified')
|
|
980
|
+
expect(text).toContain('agent policy on 0.9: ask')
|
|
981
|
+
expect(text).toContain('install: yarn mercato module add @fastwhitecat/integration-ksef-direct@0.1.8 --allow-third-party')
|
|
982
|
+
expect(text).toContain('install plan: https://modules.openmercato.com/m/@fastwhitecat/integration-ksef-direct.md')
|
|
983
|
+
})
|
|
984
|
+
|
|
985
|
+
it('returns the get_module shape with --json', async () => {
|
|
986
|
+
const io = capture()
|
|
987
|
+
await runModuleInfo(['integration_ksef_direct', '--json'], deps(tempApp(), fixtureFetch().fetchImpl, io))
|
|
988
|
+
const json = JSON.parse(io.stdout.join('\n'))
|
|
989
|
+
expect(Object.keys(json).sort()).toEqual(['anatomy', 'candidates', 'card', 'entry', 'line', 'schemaVersion', 'untrusted', 'warnings'])
|
|
990
|
+
expect(json.entry.locator).toBe('npm:@fastwhitecat/integration-ksef-direct')
|
|
991
|
+
})
|
|
992
|
+
|
|
993
|
+
it('points built-in module ids to module enable', async () => {
|
|
994
|
+
const io = capture()
|
|
995
|
+
await runModuleInfo(['currencies'], deps(tempApp(), fixtureFetch().fetchImpl, io))
|
|
996
|
+
expect(io.stdout[0]).toBe('currencies is built into Open Mercato core: Currencies.')
|
|
997
|
+
expect(io.stdout.join('\n')).toContain('enable: yarn mercato module enable @open-mercato/core --module currencies')
|
|
998
|
+
})
|
|
999
|
+
|
|
1000
|
+
it('exits with 1 and candidates for an unknown module', async () => {
|
|
1001
|
+
const io = capture()
|
|
1002
|
+
const code = await runModuleInfo(['stripe'], deps(tempApp(), fixtureFetch().fetchImpl, io))
|
|
1003
|
+
expect(code).toBe(1)
|
|
1004
|
+
expect(io.stderr).toEqual(['Unknown module "stripe". Did you mean: npm:@open-mercato/gateway-stripe?'])
|
|
1005
|
+
})
|
|
1006
|
+
})
|
|
1007
|
+
|
|
1008
|
+
describe('argument parsing', () => {
|
|
1009
|
+
it('joins words into one query and reads flags in both forms', () => {
|
|
1010
|
+
expect(parseModuleSearchArgs(['exchange', 'rates', '--limit', '5', '--kind=module,built-in', '--json'])).toEqual({
|
|
1011
|
+
query: 'exchange rates',
|
|
1012
|
+
category: null,
|
|
1013
|
+
kinds: ['module', 'built-in'],
|
|
1014
|
+
allLines: false,
|
|
1015
|
+
limit: 5,
|
|
1016
|
+
json: true,
|
|
1017
|
+
})
|
|
1018
|
+
expect(parseModuleSearchArgs(['ksef', '--category=payments-finance', '--all-lines'])).toMatchObject({
|
|
1019
|
+
category: 'payments-finance',
|
|
1020
|
+
allLines: true,
|
|
1021
|
+
limit: 10,
|
|
1022
|
+
})
|
|
1023
|
+
})
|
|
1024
|
+
|
|
1025
|
+
it('rejects bad values', () => {
|
|
1026
|
+
expect(() => parseModuleSearchArgs(['x', '--limit', '0'])).toThrow('--limit must be a whole number between 1 and 20')
|
|
1027
|
+
expect(() => parseModuleSearchArgs(['x', '--limit', '21'])).toThrow('--limit must be a whole number between 1 and 20')
|
|
1028
|
+
expect(() => parseModuleSearchArgs(['x', '--kind', 'plugin'])).toThrow('--kind must be one of')
|
|
1029
|
+
expect(() => parseModuleSearchArgs(['x', '--category'])).toThrow('--category requires a value')
|
|
1030
|
+
expect(() => parseModuleSearchArgs(['x', '--json=1'])).toThrow('--json does not accept a value')
|
|
1031
|
+
expect(() => parseModuleSearchArgs(['x', '--verbose'])).toThrow('Unsupported option: --verbose')
|
|
1032
|
+
expect(() => parseModuleSearchArgs(['x'.repeat(201)])).toThrow('longer than 200 characters')
|
|
1033
|
+
})
|
|
1034
|
+
|
|
1035
|
+
it('takes one ref for module info', () => {
|
|
1036
|
+
expect(parseModuleInfoArgs(['@acme/foo@1.2.3', '--json'])).toEqual({ ref: '@acme/foo@1.2.3', json: true })
|
|
1037
|
+
expect(parseModuleInfoArgs([])).toEqual({ ref: null, json: false })
|
|
1038
|
+
expect(() => parseModuleInfoArgs(['a', 'b'])).toThrow('module info takes one package name or module id')
|
|
1039
|
+
})
|
|
1040
|
+
})
|