feat(plugins): in-repo country plugin system - #147
Conversation
8c395eb to
65a0898
Compare
Stage 1 of the proposal at docs/plugin-proposal.md: manifests + runtimes for AR, IN, TH, and a global default tax engine, with Settings → Integraciones managing install/activation/connector config through the new /api/plugins/* routes. Shared contract (shared/plugin-api.ts) owns both browser-safe types and Zod schemas, including the catalog/install/connector/payment-method wire shapes. Backend adds the SQLite state (migration v34) and activation- aware tax resolution; frontend renders capability display text and configuration field metadata straight from each manifest, so adding a country or provider no longer needs frontend changes. Backend: activation-aware tax dispatcher, runtime registry with hosted/in-process capability enforcement, connector handler dispatch, provisionBuiltinTaxPackage for first-run setup and idle restarts, reinstall from 'uninstalled' status, 32 KiB connector config cap, 32-byte secret-field detection with camelCase normalization, 256 KiB envelope cap, host-provider must list 'hosted' providers in connectorIds, and a shared Zod envelope bundle validator. Frontend: Zod-validated API responses, generic capability-configuration form driven by capability.configuration.fields, manifest-derived localized labels/descriptions, plugin-driven payment method list with QrCode icon, shared InstallationStatus / InstallationFeature / PaymentMethod types in @flo-plugin-api, and Settings → Integraciones tab on AR store showing 2 packages, 5 AR capabilities, manifest permissions, and the per-capability activation gate. Tests: npm test green (lint, tsc, full suite including plugin-contracts, plugin-routes, plugin-default; npm test wired the plugin-default suite into the cors chain). Docs: docs/plugin-architecture.md, docs/plugin-authoring.md, docs/plugin-proposal.md, docs/plugin-references.md. Note: migration v34 ships without plugin_packages / plugin_outbox tables (speculative schema surface removed); the activation gate now treats hosted fiscal the same as hosted payment/delivery (requires authorized + broker-verified connector); review comments from review-risk / review-reliability / oracle agents addressed. Refs: docs/plugin-proposal.md, docs/plugin-authoring.md
65a0898 to
3c377d1
Compare
|
Thanks for putting real effort into this, @carvalab — the manifest-driven capability/connector/installation framework (Settings → Integraciones, per-capability activation gate, Two things stand in the way of merging as-is, both around tax specifically:
Could you pull the current Also very open to your take on sequencing here — if you see a better way to fold this in than what I've outlined, or think the split doesn't make sense for some reason I'm missing, let me know. Would rather build on what you've already done than have you redo it from scratch. |
Summary
Stage 1 of the plugin proposal: a country plugin system that lives in the repo, with a Settings → Integraciones UI to install, activate, and configure each capability.
What's in this PR:
global.defaultpackage for countries without one. Each country package owns its own Zod config schema and the in-process tax math; payment/delivery/fiscal stay declared-only (hosted) for the Stage 3 broker. Some of that are examples, I will delete before the final PR.shared/plugin-api.tsthat both sides import. Browser-safe Zod schemas cover the manifest, runtime bundle, request/result envelopes, the catalog response, installation, feature, connector, and payment-method wire shapes, plus a typedPluginRegistryanddefinePluginRuntimeBundle(). The sharedinstallationFeatureSchemanow allowsinstallationId: nullso unactivated features don't carry an empty string.active. AR/IN win overglobal.default; the global default wins for everything else.connector_verification_hostedinstead of a local "verified" stamp.main/plugins/connector-handlers.tsis the only file that knows provider names. The route dispatches tovalidate/summarizebycapability.provider. Unknown providers get 400, never a silent generic store.plugin_packages/plugin_outboxspeculative tables were dropped because nothing reads them.npm testis green;test:plugin-contracts,test:plugin-routes, andtest:plugin-defaultare wired into the test chain. Semver range parser now covers||and prerelease forms.docs/plugin-architecture.md,docs/plugin-authoring.md,docs/plugin-proposal.md,docs/plugin-references.md.Visual
Settings → Integraciones on a fresh AR store (
/settings/?tab=plugins):plugin_installations+plugin_featuresSelf-review notes
ascasts.uninstalledworks (deletes child features/connector rows + resets status).Test plan (asking for help)
This PR is draft for proposal. I want to merge after two things:
test:plugin-defaultis now wired intotest:corsso it runs in CI; please check the test pipeline on your end@itsbkm @khaira777 — could you run through the country packages on a fresh DB please?
then open Settings → Integraciones on the AR/IN/TH seeded stores. And also no broke taxes.
Out of scope (Stage 2 / Stage 3)
docs/plugin-proposal.md)utility_processABI executionRefs:
docs/plugin-proposal.md,docs/plugin-authoring.md,docs/plugin-architecture.md