సూచిక

Pain001 సాంకేతిక సూచిక: CLI, Python API, REST

pain001 v0.0.90 యొక్క ప్రతి ఫ్లాగ్, ఎండ్‌పాయింట్, ప్రవర్తన. ఆకాంక్ష నుండి కాదు, షిప్ అయిన కోడ్ నుండి తీసుకున్నవి.

ఈ సూచిక pain001 v0.0.90 యొక్క కమాండ్-లైన్ ఇంటర్‌ఫేస్, Python API, REST మైక్రోసర్వీస్, ధృవీకరణ పైప్‌లైన్‌లను నమోదు చేస్తుంది. ఇక్కడ పేర్కొన్న ప్రతి ఫ్లాగ్, ఎండ్‌పాయింట్, ప్రవర్తన షిప్ అయిన కోడ్ నుండి తీసుకున్నవే, ఆకాంక్ష నుండి కాదు.

Pain001 13 ISO 20022 సందేశ నిర్వచనాలకు మద్దతిస్తుంది: pain.001.001.03 నుండి pain.001.001.13 వరకు (Customer Credit Transfer Initiation, పదకొండు వెర్షన్లు) మరియు pain.008.001.02 / pain.008.001.08 (Customer Direct Debit Initiation).


1. కమాండ్-లైన్ ఇంటర్‌ఫేస్#

pain001 ఎగ్జిక్యూటబుల్ తన కార్యాచరణను సబ్‌కమాండ్లుగా విభజిస్తుంది. కేవలం జనరేషన్ ఫ్లాగ్‌లతో నడిపితే generate అవ్యక్తంగా అమలవుతుంది, కాబట్టి ఇప్పటికే ఉన్న ఆటోమేషన్ యథావిధిగా పనిచేస్తుంది.

సబ్‌కమాండ్ ప్రయోజనం
generate డేటా ఫైల్‌ను స్కీమా-ధృవీకృత ISO 20022 XMLగా మారుస్తుంది (డిఫాల్ట్ కమాండ్).
validate XML రాయకుండా ఇన్‌పుట్ డేటాను ధృవీకరిస్తుంది.
check <file>... [--scheme] [--format] Check pain.001 or pain.008 files you already have: the XSD of the message type each file declares, the message definition's cross-element rules, and any scheme profiles, policy or Schematron rulebook you name.
verify-signature <file>... --cert <PEM> Verify the XML-DSig signature on each file against the signer's certificate or public key; --trust-embedded-cert checks integrity only (requires the sign extra).
versions [--format json] మద్దతున్న మొత్తం 13 సందేశ నిర్వచనాలను జాబితా చేస్తుంది.
inspect <type> [--format json] ఒక సందేశ రకానికి జతగా వచ్చే టెంప్లేట్, స్కీమా, ఉదాహరణ డేటా మరియు ఆమోదించే ఇన్‌పుట్ ఫార్మాట్‌లను చూపుతుంది.
init <type> [-o FILE] ఒక సందేశ రకానికి ప్రారంభ CSV టెంప్లేట్‌ను సిద్ధం చేస్తుంది.
serve [--host] [--port] [--reload] FastAPI REST మైక్రోసర్వీస్‌ను ప్రారంభిస్తుంది (api ఎక్స్‌ట్రా అవసరం).
mcp కోర్ లైబ్రరీలోని అంతర్నిర్మిత Model Context Protocol సర్వర్‌ను stdio ద్వారా ప్రారంభిస్తుంది (mcp ఎక్స్‌ట్రా అవసరం); పూర్తి సర్వర్ pain001-mcp గా లభిస్తుంది.
plugins list / show / disable కనుగొన్న లోడర్, వాలిడేటర్, స్కీమ్ మరియు రైటర్ ప్లగిన్‌లను జాబితా చేస్తుంది, ఒకదాన్ని చూపుతుంది, లేదా మూడవ పక్ష ప్లగిన్‌ల గుర్తింపును ఎలా ఆపాలో చెబుతుంది.
face <file> [--face] [--bindings] [-o] [--loss-report] Project a pain.001 XML file into another standard's JSON shape, with a report of every element not carried.
upload [<file>] --sftp <url> Deliver a file atomically to an SFTP server you trust explicitly (requires the upload extra).

generate ఎంపికలు

ఫ్లాగ్ వివరణ
-t, --xml-message-type <TYPE> సందేశ నిర్వచనం, ఉదా. pain.001.001.09.
-d, --data <FILE> ఇన్‌పుట్ డేటా: .csv, .json, .jsonl, .db / .sqlite, .parquet, లేదా PGP-ఎన్‌క్రిప్టెడ్ .gpg / .asc.
-o, --output-dir <DIR> జనరేట్ అయిన XMLను అందుకునే డైరెక్టరీ.
-m, --template <FILE> / -s, --schema <FILE> బండిల్ చేసిన Jinja2 టెంప్లేట్ లేదా XSD స్కీమాను భర్తీ చేస్తుంది.
-c, --config <FILE> కాన్ఫిగరేషన్ ప్రొఫైల్ నుండి డిఫాల్ట్‌లను లోడ్ చేస్తుంది (--profile, --show-config).
--dry-run (అలియాస్ --validate-only) అవుట్‌పుట్ రాయకుండా JSON Schema, XSD, స్కీమ్ రూల్‌బుక్‌లకు వ్యతిరేకంగా ఇన్‌పుట్‌ను ధృవీకరిస్తుంది.
--scheme <NAME[,NAME]> కామాలతో వేరుచేసిన ఒకటి లేదా అంతకంటే ఎక్కువ స్కీమ్ నియమపుస్తకాలను అమలు చేస్తుంది. pain001 plugins list ఇన్‌స్టాల్ అయిన ప్రతి నియమపుస్తకం పేరు చెబుతుంది.
--explain / --format json --scheme తో, ప్రతి ఉల్లంఘనకు ఒక సవరణ సూచనను టెక్స్ట్ లేదా JSON గా ముద్రిస్తుంది.
--rules <FILE> Enforce a private YAML CEL policy before generation (requires the rules extra).
--schematron <PRESET or FILE> Apply Schematron business rules: the sepa, fednow or cbpr preset, or your own .sch file.
--decrypt-key <FILE> / --decrypt-passphrase-env <VAR> Import a GPG private key, and name the variable that holds its passphrase, for .gpg / .asc input (requires the gpg extra).
--streaming / --chunk-size <N> పెద్ద బ్యాచ్‌లకు మెమరీ-పరిమిత చంక్డ్ ప్రాసెసింగ్ (డిఫాల్ట్ చంక్‌కు 1,000 లావాదేవీలు; ప్రతి చంక్ తిరిగి లెక్కించిన NbOfTxs మరియు CtrlSumతో సొంత XML ఫైల్ అవుతుంది).
--emit-metrics అబ్జర్వబిలిటీ పైప్‌లైన్ల కోసం యంత్రాలు చదవగలిగే రన్ మెట్రిక్స్‌ను విడుదల చేస్తుంది.
--envelop-bah Wrap generated payment XML into an ISO 20022 Business Application Header (head.001.001.03) and BizData (head.003.001.01) envelope.
--bah-sender <BIC/ID> Sender financial institution BIC or organisation identifier for BAH <Fr>.
--bah-receiver <BIC/ID> Receiver financial institution BIC or organisation identifier for BAH <To>.
--bah-msg-id <ID> Business Message Identifier for BAH <BizMsgIdr> (defaults to generated UUID).
--xml-sign-key <FILE> PEM private key (RSA, or EC P-256/P-384) for a W3C XML Digital Signature (XML-DSig); the algorithm follows the key.
--xml-sign-cert <FILE> Optional PEM X.509 certificate to embed in XML-DSig <ds:KeyInfo>.
--xml-sign-alg <ALG> rsa-sha256, rsa-pss-sha256, ecdsa-sha256 or ecdsa-sha384; by default an RSA key signs rsa-sha256.
--xml-sign-passphrase-env <VAR> Environment variable holding the passphrase for --xml-sign-key.
--list-templates / --show-template <TYPE> List the bundled templates, or show one template's metadata, and exit.

నిష్క్రమణ కోడ్‌లు CI-అనుకూలం: 0 విజయం, 1 ధృవీకరణ వైఫల్యం, 2 వినియోగ లోపం.

XML signing and verify-signature need the sign extra (pip install "pain001[sign]", which installs cryptography and lxml).

Signatures: pain001 verify-signature

pain001 verify-signature checks the signature on files you received or wrote. Pass the signer's certificate or public key with --cert; that is the trust anchor. --trust-embedded-cert verifies with each file's own certificate instead, which proves the file is unchanged since it was signed but not who signed it. It exits 0 when every file verifies, 1 when any does not, and 2 when it cannot run; --format json prints one report per file. Verification uses exclusive C14N 1.0 and accepts only RSA-SHA256, RSA-PSS and ECDSA signatures with SHA-256 to SHA-512 digests over the whole document; the certificate's chain and validity dates are not checked.

Faces: pain001 face

A face projects a validated pain.001 document into another standard's JSON request body. --face uk_open_banking targets the Open Banking Read/Write API v4.0.1 domestic payment, --face berlin_group targets NextGenPSD2 v1.3.16 payment initiation, and --face iso_2018 renames every element to its ISO 20022 name in snake_case. A face refuses a document that lacks an element its target requires instead of inventing a value; --loss-report lists every source element it did not carry. Faces are outbound only.

Delivery: pain001 upload

pain001 upload sends a finished file to an SFTP server you name, and only after you have trusted its host key: from a known_hosts file (--known-hosts) or an OpenSSH SHA256 fingerprint you verified independently (--accept-host-key). --print-host-key shows the server's fingerprint without logging in. It logs in with a private key (--identity-file, with --passphrase-env), a password read from an environment variable (--password-env), or your SSH agent. The file is written under a temporary name and renamed on the server, so the receiving side never sees a partial file.


2. Python API#

from pain001.core.core import process_files

# Generate a validated pain.001.001.09 file from CSV
process_files(
    xml_message_type="pain.001.001.09",
    xml_template_file_path="template.xml",
    xsd_schema_file_path="schema.xsd",
    data_file_path="payments.csv",
    output_path="out/payments.xml",
)

జనరేట్ అయిన ప్రతి పత్రం రాయబడే ముందు మూడు పొరలను దాటుతుంది:

  1. ఇన్‌పుట్ ధృవీకరణ: ప్రతి రికార్డు సందేశ రకపు JSON Schemaకు వ్యతిరేకంగా తనిఖీ అవుతుంది, ఫీల్డ్-అలియాస్ సాధారణీకరణ మరియు IBAN/BIC సింటాక్స్ తనిఖీలతో సహా.
  2. స్కీమ్ రూల్‌బుక్ (ఐచ్ఛికం): మీరు పేర్కొన్న చెల్లింపు వ్యవస్థ నియమాలు, SEPA (SCT, Instant, SDD Core, B2B) నుండి UK Faster Payments, CHAPS మరియు Bacs, అమెరికా ACH మరియు వైర్ వంటి జాతీయ వ్యవస్థలు మరియు Swift CBPR+ వరకు; pain001 plugins list అన్నింటి పేర్లు చెబుతుంది.
  3. XSD ధృవీకరణ: రెండర్ అయిన XML ఒక్క బైట్ కూడా డిస్క్‌కు రాయబడక ముందే xmlschema ద్వారా అధికారిక ISO 20022 స్కీమాకు వ్యతిరేకంగా ధృవీకరించబడుతుంది. ఐచ్ఛిక fast ఎక్స్‌ట్రా (lxml) ఇన్‌స్టాల్ అయి ఉంటే libxml2 చెల్లుబాటయ్యే పత్రాలను వేగంగా అంగీకరిస్తుంది; అది తిరస్కరించిన పత్రాన్ని xmlschema మళ్లీ తనిఖీ చేస్తుంది, దాని తీర్పే తుది.

ద్రవ్య మొత్తాలు XML జనరేషన్ మరియు స్కీమ్ ధృవీకరణ సమయంలో decimal.Decimalగా నిర్వహించబడతాయి (ఎప్పుడూ IEEE 754 ఫ్లోట్లుగా కాదు), మరియు NbOfTxs / CtrlSum నియంత్రణ మొత్తాలు ఇన్‌పుట్‌ను నమ్మకుండా ధృవీకృత రికార్డుల నుండి తిరిగి లెక్కించబడతాయి.

pain.001 జనరేషన్‌కు మించి, కోర్ లైబ్రరీ ఒక pain.002 స్టేటస్-రిపోర్ట్ పార్సర్ మరియు జనరేటర్ను (బ్యాంకు అంగీకార/తిరస్కరణ స్పందనను చదవడానికి), రోజు-చివరి సమన్వయానికి ఒక camt.053 స్టేట్‌మెంట్ పార్సర్ మరియు జనరేటర్ను, అలాగే సందేశ వెర్షన్ల మధ్య రికార్డులను మార్చే VersionMapperను కూడా అందిస్తుంది.

pain001.faces.project_face is the Python entry point for faces. sign_xml_document signs a document with XML-DSig, and verify_signature(signed_xml, trust_anchor=cert_pem) verifies one and returns a SignatureReport (valid, trust, algorithm, signer, reason); both need the sign extra. verify_xml_signature without a key or certificate still trusts the certificate inside the document, with a DeprecationWarning; pain001 0.0.90 refuses it.

Runnable, self-checking scripts for the public API and the CLI live in the library's examples/ directory.


3. REST మైక్రోసర్వీస్#

pip install "pain001[api]"
pain001 serve --host 0.0.0.0 --port 8000

అన్ని ఎండ్‌పాయింట్లు /api/v1 కింద మౌంట్ చేయబడ్డాయి (వెర్షన్ లేని /api అలియాస్‌తో):

మెథడ్ & పాత్ ప్రయోజనం
GET /api/v1/health లైవ్‌నెస్ ప్రోబ్.
POST /api/v1/validate రికార్డులను ధృవీకరిస్తుంది; ఫీల్డ్-స్థాయి లోపాలను తిరిగి ఇస్తుంది.
POST /api/v1/generate సింక్రొనస్ XML జనరేషన్.
POST /api/v1/generate/async పెద్ద బ్యాచ్‌ను నేపథ్య జనరేషన్ కోసం క్యూలో ఉంచుతుంది.
GET /api/v1/status/{job_id} అసింక్ జాబ్‌ను పోల్ చేస్తుంది.
GET /api/v1/download/{job_id} పూర్తయిన XMLను డౌన్‌లోడ్ చేస్తుంది.
DELETE /api/v1/jobs/{job_id} పూర్తయిన జాబ్‌ను శుభ్రం చేస్తుంది.
GET /api/v1/faces List the faces and the binding keys each accepts.
POST /api/v1/faces/{face} Project a pain.001 document sent as XML text; returns the payload and the loss report, or 422 with the reason the face refused it.
GET /metrics Prometheus మెట్రిక్స్.

ఇంటరాక్టివ్ డాక్యుమెంటేషన్ /api/docs (Swagger UI), /api/redoc, మరియు /api/reference (Scalar) వద్ద అందించబడుతుంది; OpenAPI పత్రం /openapi.json వద్ద ఉంది.

When the PAIN001_API_KEY environment variable is set, every endpoint except /health and /metrics requires it as a bearer token; when it is unset, the API is open. pain001 serve binds to 127.0.0.1 unless you pass --host.


4. ఇన్‌పుట్ సాధారణీకరణ#

Pain001 వాస్తవ-ప్రపంచ ఎగుమతులను ధృవీకరణకు ముందు చెల్లుబాటు అయ్యే రికార్డులుగా మలుస్తుంది:

  • ఫీల్డ్ అలియాస్‌లు: సాధారణ ERP కాలమ్ పేర్లు ప్రామాణిక ఫీల్డ్‌లకు మ్యాప్ అవుతాయి (ఉదాహరణకు amount → payment_amount).
  • IBAN / BIC సాధారణీకరణ: ఖాళీలు తొలగించి, కేస్ సరిచేసి, ఆపై తనిఖీ (IBANలకు ISO 13616 mod-97, BICలకు ISO 9362 నిర్మాణం).
  • తేదీలు: అమలు తేదీలకు ISO 8601 YYYY-MM-DD పార్సింగ్.
  • మొత్తాలు: decimal.Decimal ద్వారా మళ్లించబడతాయి; తప్పుడు మొత్తాలు నిశ్శబ్దంగా రౌండ్ కాకుండా ధృవీకరణలో విఫలమవుతాయి.
  • అక్షర సమితి: ట్రాన్స్‌లిటరేషన్ సహాయకాలు కంటెంట్‌ను SWIFT మరియు SEPA అంగీకరించే ISO 20022 లాటిన్ అక్షర సమితికి తగ్గిస్తాయి.
  • Formula cells: CSV cells that start with =, +, - or @ are kept as supplied by default, so phone numbers and references survive; load_csv_data(path, sanitize_formula=True) escapes them with a leading quote instead.

5. ప్లగిన్ నిర్మాణం#

ఈ సూట్ నాలుగు ఎంట్రీ-పాయింట్ గ్రూపుల ద్వారా విస్తరించదగినది: pain001.loaders, pain001.validators, pain001.schemes, మరియు pain001.writers. pain001-loader-xlsx ఈ యంత్రాంగం ద్వారా నమోదవుతుంది మరియు ఇన్‌స్టాల్ చేసినప్పుడు స్వయంచాలకంగా కనుగొనబడుతుంది; pain001-loader-mt101 నేరుగా వినియోగించే స్వతంత్ర పార్సింగ్ లైబ్రరీ (MCP సర్వర్ యొక్క convert_mt101 సాధనం కూడా దీన్ని వాడుతుంది). ఒక కిల్ స్విచ్, PAIN001_DISABLE_PLUGINS=1, లాక్-డౌన్ వాతావరణాల్లో మూడవ-పక్ష ప్లగిన్ డిస్కవరీని పూర్తిగా నిలిపేస్తుంది.


6. నాణ్యతా గేట్లు#

కోర్ లైబ్రరీ కఠినమైన, ధృవీకరించదగిన గేట్లకు వ్యతిరేకంగా అభివృద్ధి చేయబడుతుంది: CIలో అమలయ్యే 100% లైన్ మరియు బ్రాంచ్ కవరేజ్ (--cov-fail-under=100), కఠినమైన mypy టైపింగ్, 100% డాక్‌స్ట్రింగ్ కవరేజ్, మరియు సెక్యూరిటీ లింటింగ్ (Bandit, pip-audit). ప్రతి విడుదల బిల్డ్‌కు ఒక CycloneDX SBOM జనరేట్ అవుతుంది.

ఇన్‌స్టాలేషన్ గైడ్, AI ఏజెంట్ల కోసం MCP సర్వర్, లేదా చెల్లింపుల పదకోశంతో కొనసాగండి.