@atbas/m-mcp 0.1.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/LICENSE +21 -0
- package/README.md +364 -0
- package/dist/builder/transaction-builder.d.ts +53 -0
- package/dist/builder/transaction-builder.d.ts.map +1 -0
- package/dist/builder/transaction-builder.js +159 -0
- package/dist/builder/transaction-builder.js.map +1 -0
- package/dist/catalogue/default-catalogue.d.ts +18 -0
- package/dist/catalogue/default-catalogue.d.ts.map +1 -0
- package/dist/catalogue/default-catalogue.js +21 -0
- package/dist/catalogue/default-catalogue.js.map +1 -0
- package/dist/catalogue/endpoints.d.ts +22 -0
- package/dist/catalogue/endpoints.d.ts.map +1 -0
- package/dist/catalogue/endpoints.js +24 -0
- package/dist/catalogue/endpoints.js.map +1 -0
- package/dist/catalogue/flows.d.ts +32 -0
- package/dist/catalogue/flows.d.ts.map +1 -0
- package/dist/catalogue/flows.js +64 -0
- package/dist/catalogue/flows.js.map +1 -0
- package/dist/catalogue/hash-options.d.ts +112 -0
- package/dist/catalogue/hash-options.d.ts.map +1 -0
- package/dist/catalogue/hash-options.js +151 -0
- package/dist/catalogue/hash-options.js.map +1 -0
- package/dist/catalogue/types.d.ts +279 -0
- package/dist/catalogue/types.d.ts.map +1 -0
- package/dist/catalogue/types.js +360 -0
- package/dist/catalogue/types.js.map +1 -0
- package/dist/codegen/generate.d.ts +14 -0
- package/dist/codegen/generate.d.ts.map +1 -0
- package/dist/codegen/generate.js +490 -0
- package/dist/codegen/generate.js.map +1 -0
- package/dist/codegen/languages/node.d.ts +3 -0
- package/dist/codegen/languages/node.d.ts.map +1 -0
- package/dist/codegen/languages/node.js +32 -0
- package/dist/codegen/languages/node.js.map +1 -0
- package/dist/codegen/languages/php.d.ts +3 -0
- package/dist/codegen/languages/php.d.ts.map +1 -0
- package/dist/codegen/languages/php.js +27 -0
- package/dist/codegen/languages/php.js.map +1 -0
- package/dist/codegen/languages/python.d.ts +3 -0
- package/dist/codegen/languages/python.d.ts.map +1 -0
- package/dist/codegen/languages/python.js +27 -0
- package/dist/codegen/languages/python.js.map +1 -0
- package/dist/codegen/renderer.d.ts +24 -0
- package/dist/codegen/renderer.d.ts.map +1 -0
- package/dist/codegen/renderer.js +59 -0
- package/dist/codegen/renderer.js.map +1 -0
- package/dist/codegen/types.d.ts +50 -0
- package/dist/codegen/types.d.ts.map +1 -0
- package/dist/codegen/types.js +5 -0
- package/dist/codegen/types.js.map +1 -0
- package/dist/config/credentials.d.ts +64 -0
- package/dist/config/credentials.d.ts.map +1 -0
- package/dist/config/credentials.js +216 -0
- package/dist/config/credentials.js.map +1 -0
- package/dist/config/environment.d.ts +23 -0
- package/dist/config/environment.d.ts.map +1 -0
- package/dist/config/environment.js +54 -0
- package/dist/config/environment.js.map +1 -0
- package/dist/core/dependencies.d.ts +43 -0
- package/dist/core/dependencies.d.ts.map +1 -0
- package/dist/core/dependencies.js +2 -0
- package/dist/core/dependencies.js.map +1 -0
- package/dist/core/registry.d.ts +33 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/registry.js +13 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/server.d.ts +61 -0
- package/dist/core/server.d.ts.map +1 -0
- package/dist/core/server.js +90 -0
- package/dist/core/server.js.map +1 -0
- package/dist/dependencies.d.ts +28 -0
- package/dist/dependencies.d.ts.map +1 -0
- package/dist/dependencies.js +2 -0
- package/dist/dependencies.js.map +1 -0
- package/dist/diagnostics/diagnose.d.ts +43 -0
- package/dist/diagnostics/diagnose.d.ts.map +1 -0
- package/dist/diagnostics/diagnose.js +121 -0
- package/dist/diagnostics/diagnose.js.map +1 -0
- package/dist/domain/amount.d.ts +157 -0
- package/dist/domain/amount.d.ts.map +1 -0
- package/dist/domain/amount.js +275 -0
- package/dist/domain/amount.js.map +1 -0
- package/dist/domain/datetime.d.ts +95 -0
- package/dist/domain/datetime.d.ts.map +1 -0
- package/dist/domain/datetime.js +211 -0
- package/dist/domain/datetime.js.map +1 -0
- package/dist/domain/response-codes.d.ts +116 -0
- package/dist/domain/response-codes.d.ts.map +1 -0
- package/dist/domain/response-codes.js +380 -0
- package/dist/domain/response-codes.js.map +1 -0
- package/dist/domain/secure-hash.d.ts +78 -0
- package/dist/domain/secure-hash.d.ts.map +1 -0
- package/dist/domain/secure-hash.js +69 -0
- package/dist/domain/secure-hash.js.map +1 -0
- package/dist/domain/signature/jazzcash.d.ts +56 -0
- package/dist/domain/signature/jazzcash.d.ts.map +1 -0
- package/dist/domain/signature/jazzcash.js +214 -0
- package/dist/domain/signature/jazzcash.js.map +1 -0
- package/dist/domain/signature/registry.d.ts +69 -0
- package/dist/domain/signature/registry.d.ts.map +1 -0
- package/dist/domain/signature/registry.js +92 -0
- package/dist/domain/signature/registry.js.map +1 -0
- package/dist/domain/signature/scheme.d.ts +349 -0
- package/dist/domain/signature/scheme.d.ts.map +1 -0
- package/dist/domain/signature/scheme.js +398 -0
- package/dist/domain/signature/scheme.js.map +1 -0
- package/dist/domain/txn-ref.d.ts +76 -0
- package/dist/domain/txn-ref.d.ts.map +1 -0
- package/dist/domain/txn-ref.js +126 -0
- package/dist/domain/txn-ref.js.map +1 -0
- package/dist/domain/types.d.ts +45 -0
- package/dist/domain/types.d.ts.map +1 -0
- package/dist/domain/types.js +70 -0
- package/dist/domain/types.js.map +1 -0
- package/dist/errors.d.ts +84 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +87 -0
- package/dist/errors.js.map +1 -0
- package/dist/gateway/checkout-form.d.ts +16 -0
- package/dist/gateway/checkout-form.d.ts.map +1 -0
- package/dist/gateway/checkout-form.js +103 -0
- package/dist/gateway/checkout-form.js.map +1 -0
- package/dist/gateway/checkout-output.d.ts +70 -0
- package/dist/gateway/checkout-output.d.ts.map +1 -0
- package/dist/gateway/checkout-output.js +199 -0
- package/dist/gateway/checkout-output.js.map +1 -0
- package/dist/gateway/guards.d.ts +37 -0
- package/dist/gateway/guards.d.ts.map +1 -0
- package/dist/gateway/guards.js +44 -0
- package/dist/gateway/guards.js.map +1 -0
- package/dist/gateway/http-client.d.ts +42 -0
- package/dist/gateway/http-client.d.ts.map +1 -0
- package/dist/gateway/http-client.js +153 -0
- package/dist/gateway/http-client.js.map +1 -0
- package/dist/gateway/rest-client.d.ts +42 -0
- package/dist/gateway/rest-client.d.ts.map +1 -0
- package/dist/gateway/rest-client.js +241 -0
- package/dist/gateway/rest-client.js.map +1 -0
- package/dist/gateway/transport.d.ts +31 -0
- package/dist/gateway/transport.d.ts.map +1 -0
- package/dist/gateway/transport.js +73 -0
- package/dist/gateway/transport.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +75 -0
- package/dist/index.js.map +1 -0
- package/dist/install/cli.d.ts +38 -0
- package/dist/install/cli.d.ts.map +1 -0
- package/dist/install/cli.js +274 -0
- package/dist/install/cli.js.map +1 -0
- package/dist/install/harnesses.d.ts +74 -0
- package/dist/install/harnesses.d.ts.map +1 -0
- package/dist/install/harnesses.js +263 -0
- package/dist/install/harnesses.js.map +1 -0
- package/dist/knowledge/corpus.d.ts +15 -0
- package/dist/knowledge/corpus.d.ts.map +1 -0
- package/dist/knowledge/corpus.js +129 -0
- package/dist/knowledge/corpus.js.map +1 -0
- package/dist/knowledge/search.d.ts +29 -0
- package/dist/knowledge/search.d.ts.map +1 -0
- package/dist/knowledge/search.js +181 -0
- package/dist/knowledge/search.js.map +1 -0
- package/dist/knowledge/source.d.ts +60 -0
- package/dist/knowledge/source.d.ts.map +1 -0
- package/dist/knowledge/source.js +91 -0
- package/dist/knowledge/source.js.map +1 -0
- package/dist/knowledge/types.d.ts +40 -0
- package/dist/knowledge/types.d.ts.map +1 -0
- package/dist/knowledge/types.js +19 -0
- package/dist/knowledge/types.js.map +1 -0
- package/dist/paths.d.ts +26 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +106 -0
- package/dist/paths.js.map +1 -0
- package/dist/prompts/integration-walkthrough.d.ts +11 -0
- package/dist/prompts/integration-walkthrough.d.ts.map +1 -0
- package/dist/prompts/integration-walkthrough.js +52 -0
- package/dist/prompts/integration-walkthrough.js.map +1 -0
- package/dist/prompts/register.d.ts +4 -0
- package/dist/prompts/register.d.ts.map +1 -0
- package/dist/prompts/register.js +4 -0
- package/dist/prompts/register.js.map +1 -0
- package/dist/registry.d.ts +14 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +2 -0
- package/dist/registry.js.map +1 -0
- package/dist/resources/knowledge-resources.d.ts +5 -0
- package/dist/resources/knowledge-resources.d.ts.map +1 -0
- package/dist/resources/knowledge-resources.js +121 -0
- package/dist/resources/knowledge-resources.js.map +1 -0
- package/dist/resources/register.d.ts +4 -0
- package/dist/resources/register.d.ts.map +1 -0
- package/dist/resources/register.js +8 -0
- package/dist/resources/register.js.map +1 -0
- package/dist/server.d.ts +40 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +56 -0
- package/dist/server.js.map +1 -0
- package/dist/telemetry/logger.d.ts +31 -0
- package/dist/telemetry/logger.d.ts.map +1 -0
- package/dist/telemetry/logger.js +67 -0
- package/dist/telemetry/logger.js.map +1 -0
- package/dist/telemetry/redaction.d.ts +88 -0
- package/dist/telemetry/redaction.d.ts.map +1 -0
- package/dist/telemetry/redaction.js +238 -0
- package/dist/telemetry/redaction.js.map +1 -0
- package/dist/tools/build-transaction-parameters.d.ts +10 -0
- package/dist/tools/build-transaction-parameters.d.ts.map +1 -0
- package/dist/tools/build-transaction-parameters.js +154 -0
- package/dist/tools/build-transaction-parameters.js.map +1 -0
- package/dist/tools/call-context.d.ts +47 -0
- package/dist/tools/call-context.d.ts.map +1 -0
- package/dist/tools/call-context.js +15 -0
- package/dist/tools/call-context.js.map +1 -0
- package/dist/tools/codegen-tools.d.ts +4 -0
- package/dist/tools/codegen-tools.d.ts.map +1 -0
- package/dist/tools/codegen-tools.js +131 -0
- package/dist/tools/codegen-tools.js.map +1 -0
- package/dist/tools/credential-tools.d.ts +32 -0
- package/dist/tools/credential-tools.d.ts.map +1 -0
- package/dist/tools/credential-tools.js +65 -0
- package/dist/tools/credential-tools.js.map +1 -0
- package/dist/tools/descriptor.d.ts +52 -0
- package/dist/tools/descriptor.d.ts.map +1 -0
- package/dist/tools/descriptor.js +2 -0
- package/dist/tools/descriptor.js.map +1 -0
- package/dist/tools/diagnostic-tools.d.ts +3 -0
- package/dist/tools/diagnostic-tools.d.ts.map +1 -0
- package/dist/tools/diagnostic-tools.js +128 -0
- package/dist/tools/diagnostic-tools.js.map +1 -0
- package/dist/tools/gateway-tools.d.ts +6 -0
- package/dist/tools/gateway-tools.d.ts.map +1 -0
- package/dist/tools/gateway-tools.js +381 -0
- package/dist/tools/gateway-tools.js.map +1 -0
- package/dist/tools/hash-tools.d.ts +5 -0
- package/dist/tools/hash-tools.d.ts.map +1 -0
- package/dist/tools/hash-tools.js +238 -0
- package/dist/tools/hash-tools.js.map +1 -0
- package/dist/tools/knowledge-tools.d.ts +7 -0
- package/dist/tools/knowledge-tools.d.ts.map +1 -0
- package/dist/tools/knowledge-tools.js +247 -0
- package/dist/tools/knowledge-tools.js.map +1 -0
- package/dist/tools/onboarding-checklist.d.ts +3 -0
- package/dist/tools/onboarding-checklist.d.ts.map +1 -0
- package/dist/tools/onboarding-checklist.js +141 -0
- package/dist/tools/onboarding-checklist.js.map +1 -0
- package/dist/tools/register.d.ts +60 -0
- package/dist/tools/register.d.ts.map +1 -0
- package/dist/tools/register.js +145 -0
- package/dist/tools/register.js.map +1 -0
- package/dist/tools/tool-kit.d.ts +88 -0
- package/dist/tools/tool-kit.d.ts.map +1 -0
- package/dist/tools/tool-kit.js +297 -0
- package/dist/tools/tool-kit.js.map +1 -0
- package/dist/validation/payload-validator.d.ts +29 -0
- package/dist/validation/payload-validator.d.ts.map +1 -0
- package/dist/validation/payload-validator.js +79 -0
- package/dist/validation/payload-validator.js.map +1 -0
- package/dist/validation/rules/amount.d.ts +3 -0
- package/dist/validation/rules/amount.d.ts.map +1 -0
- package/dist/validation/rules/amount.js +77 -0
- package/dist/validation/rules/amount.js.map +1 -0
- package/dist/validation/rules/bill-reference.d.ts +10 -0
- package/dist/validation/rules/bill-reference.d.ts.map +1 -0
- package/dist/validation/rules/bill-reference.js +34 -0
- package/dist/validation/rules/bill-reference.js.map +1 -0
- package/dist/validation/rules/cnic.d.ts +3 -0
- package/dist/validation/rules/cnic.d.ts.map +1 -0
- package/dist/validation/rules/cnic.js +42 -0
- package/dist/validation/rules/cnic.js.map +1 -0
- package/dist/validation/rules/constants.d.ts +9 -0
- package/dist/validation/rules/constants.d.ts.map +1 -0
- package/dist/validation/rules/constants.js +28 -0
- package/dist/validation/rules/constants.js.map +1 -0
- package/dist/validation/rules/constraints.d.ts +3 -0
- package/dist/validation/rules/constraints.d.ts.map +1 -0
- package/dist/validation/rules/constraints.js +113 -0
- package/dist/validation/rules/constraints.js.map +1 -0
- package/dist/validation/rules/datetime.d.ts +3 -0
- package/dist/validation/rules/datetime.d.ts.map +1 -0
- package/dist/validation/rules/datetime.js +49 -0
- package/dist/validation/rules/datetime.js.map +1 -0
- package/dist/validation/rules/empty-string.d.ts +13 -0
- package/dist/validation/rules/empty-string.d.ts.map +1 -0
- package/dist/validation/rules/empty-string.js +32 -0
- package/dist/validation/rules/empty-string.js.map +1 -0
- package/dist/validation/rules/expiry.d.ts +3 -0
- package/dist/validation/rules/expiry.d.ts.map +1 -0
- package/dist/validation/rules/expiry.js +52 -0
- package/dist/validation/rules/expiry.js.map +1 -0
- package/dist/validation/rules/msisdn.d.ts +3 -0
- package/dist/validation/rules/msisdn.d.ts.map +1 -0
- package/dist/validation/rules/msisdn.js +45 -0
- package/dist/validation/rules/msisdn.js.map +1 -0
- package/dist/validation/rules/presence.d.ts +3 -0
- package/dist/validation/rules/presence.d.ts.map +1 -0
- package/dist/validation/rules/presence.js +90 -0
- package/dist/validation/rules/presence.js.map +1 -0
- package/dist/validation/rules/return-url.d.ts +14 -0
- package/dist/validation/rules/return-url.d.ts.map +1 -0
- package/dist/validation/rules/return-url.js +58 -0
- package/dist/validation/rules/return-url.js.map +1 -0
- package/dist/validation/rules/tool-argument.d.ts +16 -0
- package/dist/validation/rules/tool-argument.d.ts.map +1 -0
- package/dist/validation/rules/tool-argument.js +38 -0
- package/dist/validation/rules/tool-argument.js.map +1 -0
- package/dist/validation/rules/txn-ref.d.ts +3 -0
- package/dist/validation/rules/txn-ref.d.ts.map +1 -0
- package/dist/validation/rules/txn-ref.js +47 -0
- package/dist/validation/rules/txn-ref.js.map +1 -0
- package/dist/validation/rules/unknown-fields.d.ts +10 -0
- package/dist/validation/rules/unknown-fields.d.ts.map +1 -0
- package/dist/validation/rules/unknown-fields.js +29 -0
- package/dist/validation/rules/unknown-fields.js.map +1 -0
- package/dist/validation/types.d.ts +36 -0
- package/dist/validation/types.d.ts.map +1 -0
- package/dist/validation/types.js +12 -0
- package/dist/validation/types.js.map +1 -0
- package/dist/version.d.ts +23 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +23 -0
- package/dist/version.js.map +1 -0
- package/knowledge/diagnostics/symptoms.json +321 -0
- package/knowledge/docs/bnpl-guide.md +77 -0
- package/knowledge/docs/card-page-redirection.md +67 -0
- package/knowledge/docs/card-refund.md +91 -0
- package/knowledge/docs/hmac-sha256-calculation.md +72 -0
- package/knowledge/docs/index.json +189 -0
- package/knowledge/docs/ipn-implementation.md +89 -0
- package/knowledge/docs/mwallet-recurring.md +117 -0
- package/knowledge/docs/mwallet-refund.md +65 -0
- package/knowledge/docs/mwallet-rest-v1-1.md +126 -0
- package/knowledge/docs/mwallet-rest-v2-0-cnic.md +113 -0
- package/knowledge/docs/portal-guide.md +45 -0
- package/knowledge/docs/shopify-guide.md +74 -0
- package/knowledge/docs/status-inquiry-2025-26.md +32 -0
- package/knowledge/docs/status-inquiry.md +111 -0
- package/knowledge/docs/wordpress-guide.md +49 -0
- package/knowledge/flow.schema.json +390 -0
- package/knowledge/flows/bnpl-page-redirection-v1.1.json +211 -0
- package/knowledge/flows/card-page-redirection-v1.1.json +211 -0
- package/knowledge/flows/mwallet-rest-v1.1.json +187 -0
- package/knowledge/flows/mwallet-rest-v2.0-cnic.json +197 -0
- package/knowledge/flows/mwallet-token-pay-v4.0.json +130 -0
- package/knowledge/flows/refund-bnpl.json +105 -0
- package/knowledge/flows/refund-card-v1.1.json +112 -0
- package/knowledge/flows/refund-card-v2.0.json +121 -0
- package/knowledge/flows/refund-mwallet-v1.1.json +106 -0
- package/knowledge/flows/status-inquiry-v1.1.json +102 -0
- package/knowledge/flows/status-inquiry-v2.0.json +103 -0
- package/knowledge/flows/token-delete-v1.json +85 -0
- package/knowledge/flows/token-inquiry-v1.json +85 -0
- package/knowledge/flows/wallet-linking-portal.json +103 -0
- package/knowledge/templates/node/checkout-redirect.tmpl +166 -0
- package/knowledge/templates/node/ipn-handler.tmpl +108 -0
- package/knowledge/templates/node/rest-client.tmpl +197 -0
- package/knowledge/templates/node/wallet-linking.tmpl +147 -0
- package/knowledge/templates/php/checkout-redirect.tmpl +149 -0
- package/knowledge/templates/php/ipn-handler.tmpl +105 -0
- package/knowledge/templates/php/rest-client.tmpl +191 -0
- package/knowledge/templates/php/wallet-linking.tmpl +137 -0
- package/knowledge/templates/python/checkout-redirect.tmpl +148 -0
- package/knowledge/templates/python/ipn-handler.tmpl +110 -0
- package/knowledge/templates/python/rest-client.tmpl +179 -0
- package/knowledge/templates/python/wallet-linking.tmpl +133 -0
- package/package.json +84 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply a list of registrars to a server instance.
|
|
3
|
+
*
|
|
4
|
+
* Generic in the dependency set so that a host serving only the credential tools
|
|
5
|
+
* can apply them with only {@link CoreDependencies} in hand — it holds no corpus
|
|
6
|
+
* to pass, which is the point.
|
|
7
|
+
*/
|
|
8
|
+
export function applyRegistrars(server, deps, registrars) {
|
|
9
|
+
for (const register of registrars) {
|
|
10
|
+
register(server, deps);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/core/registry.ts"],"names":[],"mappings":"AA4BA;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAI,MAAiB,EAAE,IAAO,EAAE,UAAsC;IACnG,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE,CAAC;QAClC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACzB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { CorpusSource } from '../knowledge/source.js';
|
|
3
|
+
import type { CoreDependencies } from './dependencies.js';
|
|
4
|
+
/**
|
|
5
|
+
* Composition root for the half of the server that reads no documentation
|
|
6
|
+
* corpus.
|
|
7
|
+
*
|
|
8
|
+
* `../server.js` builds on this to compose the whole surface; the published
|
|
9
|
+
* connector stops here. Keeping the two in separate modules is what makes that
|
|
10
|
+
* possible: `../server.js` imports the corpus loader, the search-index builder
|
|
11
|
+
* and the symptom base at module scope, so anything importing it inherits the
|
|
12
|
+
* entire knowledge half whether it registers a knowledge tool or not.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Guidance sent to every client, whichever half of the surface it reached.
|
|
16
|
+
*
|
|
17
|
+
* Shared rather than trimmed per surface. A connector serving the credential
|
|
18
|
+
* tools locally proxies the rest to a hosted endpoint and presents one merged
|
|
19
|
+
* tool list, so a client that received abridged guidance from the local half
|
|
20
|
+
* would be told less about tools it can nevertheless call.
|
|
21
|
+
*/
|
|
22
|
+
export declare const SERVER_INSTRUCTIONS: string;
|
|
23
|
+
export interface CoreDependencyOptions {
|
|
24
|
+
/**
|
|
25
|
+
* Where the flow specifications are read from.
|
|
26
|
+
*
|
|
27
|
+
* Required, not defaulted. `../server.js` passes the corpus directory that
|
|
28
|
+
* ships beside the code; the published connector passes a source backed by
|
|
29
|
+
* generated code, because it ships no corpus directory at all — see
|
|
30
|
+
* `memoryCorpusSource` in `../knowledge/source.js`. Making the caller say
|
|
31
|
+
* which is what keeps the package-root walk out of this module's graph.
|
|
32
|
+
*/
|
|
33
|
+
readonly catalogue: CorpusSource | string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Build the dependencies a corpus-free surface needs.
|
|
37
|
+
*
|
|
38
|
+
* Loads the flow catalogue and nothing else from the corpus: the documents, the
|
|
39
|
+
* search index and the symptom base are the knowledge half's, and a host that
|
|
40
|
+
* serves only the credential tools should neither pay to load them nor be able
|
|
41
|
+
* to reach them. `../server.js` calls this and adds the three.
|
|
42
|
+
*
|
|
43
|
+
* @param source - Environment to read configuration and credentials from.
|
|
44
|
+
* @param options - Where the flow catalogue is read from.
|
|
45
|
+
* @returns Dependencies for the credential tools, with logging already configured.
|
|
46
|
+
* @throws {import('../errors.js').JazzCashConfigError} If the environment is malformed or a flow specification is invalid.
|
|
47
|
+
*/
|
|
48
|
+
export declare function createCoreDependencies(source: NodeJS.ProcessEnv, options: CoreDependencyOptions): CoreDependencies;
|
|
49
|
+
/**
|
|
50
|
+
* A server serving exactly the tools that need a merchant credential.
|
|
51
|
+
*
|
|
52
|
+
* No resources and no prompts: those are the corpus's, and are served by the
|
|
53
|
+
* hosted tier where they are metered. Registering them here as well would
|
|
54
|
+
* duplicate the whole knowledge surface on both sides of a connector's bridge
|
|
55
|
+
* and leave the de-duplication rule deciding which copy a merchant sees.
|
|
56
|
+
*
|
|
57
|
+
* @param deps - Dependencies built by {@link createCoreDependencies}.
|
|
58
|
+
* @returns A server with the four credential tools registered.
|
|
59
|
+
*/
|
|
60
|
+
export declare function createCredentialServer(deps: CoreDependencies): McpServer;
|
|
61
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/core/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAI3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAM1D;;;;;;;;;GASG;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,QAgBpB,CAAC;AAEb,MAAM,WAAW,qBAAqB;IACpC;;;;;;;;OAQG;IACH,QAAQ,CAAC,SAAS,EAAE,YAAY,GAAG,MAAM,CAAC;CAC3C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,OAAO,EAAE,qBAAqB,GAAG,gBAAgB,CAclH;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,gBAAgB,GAAG,SAAS,CAYxE"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { loadFlowCatalogue } from '../catalogue/flows.js';
|
|
3
|
+
import { loadCredentialStore } from '../config/credentials.js';
|
|
4
|
+
import { loadEnvironmentConfig } from '../config/environment.js';
|
|
5
|
+
import { createLogger } from '../telemetry/logger.js';
|
|
6
|
+
import { CREDENTIAL_TOOLS } from '../tools/credential-tools.js';
|
|
7
|
+
import { SERVER_NAME, SERVER_VERSION } from '../version.js';
|
|
8
|
+
// `./registry.js` is `src/core/registry.ts`, not `src/registry.ts`. The two
|
|
9
|
+
// exist side by side and must never reach each other; see the note at the top of
|
|
10
|
+
// `../registry.js`.
|
|
11
|
+
import { applyRegistrars } from './registry.js';
|
|
12
|
+
/**
|
|
13
|
+
* Composition root for the half of the server that reads no documentation
|
|
14
|
+
* corpus.
|
|
15
|
+
*
|
|
16
|
+
* `../server.js` builds on this to compose the whole surface; the published
|
|
17
|
+
* connector stops here. Keeping the two in separate modules is what makes that
|
|
18
|
+
* possible: `../server.js` imports the corpus loader, the search-index builder
|
|
19
|
+
* and the symptom base at module scope, so anything importing it inherits the
|
|
20
|
+
* entire knowledge half whether it registers a knowledge tool or not.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Guidance sent to every client, whichever half of the surface it reached.
|
|
24
|
+
*
|
|
25
|
+
* Shared rather than trimmed per surface. A connector serving the credential
|
|
26
|
+
* tools locally proxies the rest to a hosted endpoint and presents one merged
|
|
27
|
+
* tool list, so a client that received abridged guidance from the local half
|
|
28
|
+
* would be told less about tools it can nevertheless call.
|
|
29
|
+
*/
|
|
30
|
+
export const SERVER_INSTRUCTIONS = [
|
|
31
|
+
'This server encodes the official JazzCash payment-gateway integration guides (2026 edition).',
|
|
32
|
+
'',
|
|
33
|
+
'Start with `jazzcash_list_integration_flows` to choose a flow, then',
|
|
34
|
+
'`jazzcash_get_onboarding_checklist` for the setup sequence.',
|
|
35
|
+
'Use `jazzcash_build_transaction_parameters` rather than assembling payloads by hand:',
|
|
36
|
+
'it fills constants, formats Pakistan-time timestamps, converts the amount to minor units,',
|
|
37
|
+
'validates the payload and computes `pp_SecureHash` in one step.',
|
|
38
|
+
'',
|
|
39
|
+
'Safety: sandbox and production share identical gateway URLs, so the environment is a',
|
|
40
|
+
'property of the credentials, not the endpoint. Every network tool requires an explicit',
|
|
41
|
+
'`environment` argument, and production money movement additionally requires the server to',
|
|
42
|
+
'be started with JAZZCASH_ALLOW_LIVE=true and the call to pass `confirmLiveEnvironment: true`.',
|
|
43
|
+
'',
|
|
44
|
+
'Answer merchant questions from `jazzcash_search_docs` results and cite the document,',
|
|
45
|
+
'rather than relying on general knowledge of payment gateways.',
|
|
46
|
+
].join('\n');
|
|
47
|
+
/**
|
|
48
|
+
* Build the dependencies a corpus-free surface needs.
|
|
49
|
+
*
|
|
50
|
+
* Loads the flow catalogue and nothing else from the corpus: the documents, the
|
|
51
|
+
* search index and the symptom base are the knowledge half's, and a host that
|
|
52
|
+
* serves only the credential tools should neither pay to load them nor be able
|
|
53
|
+
* to reach them. `../server.js` calls this and adds the three.
|
|
54
|
+
*
|
|
55
|
+
* @param source - Environment to read configuration and credentials from.
|
|
56
|
+
* @param options - Where the flow catalogue is read from.
|
|
57
|
+
* @returns Dependencies for the credential tools, with logging already configured.
|
|
58
|
+
* @throws {import('../errors.js').JazzCashConfigError} If the environment is malformed or a flow specification is invalid.
|
|
59
|
+
*/
|
|
60
|
+
export function createCoreDependencies(source, options) {
|
|
61
|
+
const config = loadEnvironmentConfig(source);
|
|
62
|
+
const logger = createLogger({ level: config.logLevel }).child({ server: SERVER_NAME });
|
|
63
|
+
const credentials = loadCredentialStore(config, source);
|
|
64
|
+
const catalogue = loadFlowCatalogue(options.catalogue);
|
|
65
|
+
logger.info('Configuration loaded', {
|
|
66
|
+
defaultEnvironment: config.defaultEnvironment,
|
|
67
|
+
allowLive: config.allowLive,
|
|
68
|
+
configuredEnvironments: credentials.configuredEnvironments(),
|
|
69
|
+
flows: catalogue.list().length,
|
|
70
|
+
});
|
|
71
|
+
return { config, logger, credentials, catalogue };
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A server serving exactly the tools that need a merchant credential.
|
|
75
|
+
*
|
|
76
|
+
* No resources and no prompts: those are the corpus's, and are served by the
|
|
77
|
+
* hosted tier where they are metered. Registering them here as well would
|
|
78
|
+
* duplicate the whole knowledge surface on both sides of a connector's bridge
|
|
79
|
+
* and leave the de-duplication rule deciding which copy a merchant sees.
|
|
80
|
+
*
|
|
81
|
+
* @param deps - Dependencies built by {@link createCoreDependencies}.
|
|
82
|
+
* @returns A server with the four credential tools registered.
|
|
83
|
+
*/
|
|
84
|
+
export function createCredentialServer(deps) {
|
|
85
|
+
const server = new McpServer({ name: SERVER_NAME, version: SERVER_VERSION }, { instructions: SERVER_INSTRUCTIONS });
|
|
86
|
+
applyRegistrars(server, deps, CREDENTIAL_TOOLS.map((descriptor) => descriptor.registrar));
|
|
87
|
+
deps.logger.debug('Credential tool surface registered', { tools: CREDENTIAL_TOOLS.length });
|
|
88
|
+
return server;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/core/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE5D,4EAA4E;AAC5E,iFAAiF;AACjF,oBAAoB;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD;;;;;;;;;GASG;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,8FAA8F;IAC9F,EAAE;IACF,qEAAqE;IACrE,6DAA6D;IAC7D,sFAAsF;IACtF,2FAA2F;IAC3F,iEAAiE;IACjE,EAAE;IACF,sFAAsF;IACtF,wFAAwF;IACxF,2FAA2F;IAC3F,+FAA+F;IAC/F,EAAE;IACF,sFAAsF;IACtF,+DAA+D;CAChE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAeb;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAyB,EAAE,OAA8B;IAC9F,MAAM,MAAM,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,YAAY,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;IACvF,MAAM,WAAW,GAAG,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxD,MAAM,SAAS,GAAG,iBAAiB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEvD,MAAM,CAAC,IAAI,CAAC,sBAAsB,EAAE;QAClC,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;QAC7C,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,sBAAsB,EAAE,WAAW,CAAC,sBAAsB,EAAE;QAC5D,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC,MAAM;KAC/B,CAAC,CAAC;IAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;AACpD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAsB;IAC3D,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,YAAY,EAAE,mBAAmB,EAAE,CAAC,CAAC;IAEpH,eAAe,CACb,MAAM,EACN,IAAI,EACJ,gBAAgB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAC3D,CAAC;IAEF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oCAAoC,EAAE,EAAE,KAAK,EAAE,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC;IAE5F,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CoreDependencies } from './core/dependencies.js';
|
|
2
|
+
import type { SymptomKnowledgeBase } from './diagnostics/diagnose.js';
|
|
3
|
+
import type { KnowledgeCorpus } from './knowledge/corpus.js';
|
|
4
|
+
import type { KnowledgeSearchIndex } from './knowledge/search.js';
|
|
5
|
+
export type { CoreDependencies } from './core/dependencies.js';
|
|
6
|
+
/**
|
|
7
|
+
* Everything a tool, resource or prompt registrar may depend on.
|
|
8
|
+
*
|
|
9
|
+
* Passed explicitly rather than reached for through module-level state, so that
|
|
10
|
+
* no singleton is introduced and every unit is testable in isolation
|
|
11
|
+
* (CLAUDE.md, Implementation Protocols §3).
|
|
12
|
+
*
|
|
13
|
+
* Split across two files rather than two interfaces in one: the three fields
|
|
14
|
+
* added here are the corpus-backed half, and their type imports are what pull
|
|
15
|
+
* the corpus loader, the search index and the symptom base into any module graph
|
|
16
|
+
* that reaches this file. `./core/dependencies.js` carries the rest, and is what
|
|
17
|
+
* the credential tools and the published connector are built against. See that
|
|
18
|
+
* module for the full reasoning.
|
|
19
|
+
*/
|
|
20
|
+
export interface ServerDependencies extends CoreDependencies {
|
|
21
|
+
/** Curated documentation, loaded once at start-up. */
|
|
22
|
+
readonly corpus: KnowledgeCorpus;
|
|
23
|
+
/** Offline lexical index over the corpus. */
|
|
24
|
+
readonly search: KnowledgeSearchIndex;
|
|
25
|
+
/** Documented failure modes, loaded once at start-up. */
|
|
26
|
+
readonly symptoms: SymptomKnowledgeBase;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=dependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../src/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IAC1D,sDAAsD;IACtD,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IACtC,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;CACzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../src/dependencies.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type DocRef } from '../errors.js';
|
|
3
|
+
import { type CorpusSource } from '../knowledge/source.js';
|
|
4
|
+
declare const causeSchema: z.ZodObject<{
|
|
5
|
+
cause: z.ZodString;
|
|
6
|
+
check: z.ZodString;
|
|
7
|
+
fix: z.ZodString;
|
|
8
|
+
docRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
9
|
+
docId: z.ZodString;
|
|
10
|
+
sectionId: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, z.core.$strip>>>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
declare const symptomSchema: z.ZodObject<{
|
|
14
|
+
id: z.ZodString;
|
|
15
|
+
title: z.ZodString;
|
|
16
|
+
keywords: z.ZodArray<z.ZodString>;
|
|
17
|
+
causes: z.ZodArray<z.ZodObject<{
|
|
18
|
+
cause: z.ZodString;
|
|
19
|
+
check: z.ZodString;
|
|
20
|
+
fix: z.ZodString;
|
|
21
|
+
docRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
22
|
+
docId: z.ZodString;
|
|
23
|
+
sectionId: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strip>>>;
|
|
25
|
+
}, z.core.$strip>>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export type DiagnosticCause = z.infer<typeof causeSchema>;
|
|
28
|
+
export type DiagnosticSymptom = z.infer<typeof symptomSchema>;
|
|
29
|
+
export interface SymptomMatch {
|
|
30
|
+
readonly symptom: DiagnosticSymptom;
|
|
31
|
+
readonly score: number;
|
|
32
|
+
}
|
|
33
|
+
export interface SymptomKnowledgeBase {
|
|
34
|
+
readonly version: string;
|
|
35
|
+
symptoms(): readonly DiagnosticSymptom[];
|
|
36
|
+
find(id: string): DiagnosticSymptom | undefined;
|
|
37
|
+
/** Rank symptoms against free-text describing what the merchant sees. */
|
|
38
|
+
match(description: string, limit?: number): readonly SymptomMatch[];
|
|
39
|
+
docRefsFor(symptom: DiagnosticSymptom): readonly DocRef[];
|
|
40
|
+
}
|
|
41
|
+
export declare function loadSymptomKnowledgeBase(source?: CorpusSource | string): SymptomKnowledgeBase;
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=diagnose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnose.d.ts","sourceRoot":"","sources":["../../src/diagnostics/diagnose.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAGhE,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAiB9E,QAAA,MAAM,WAAW;;;;;;;;iBAKf,CAAC;AAEH,QAAA,MAAM,aAAa;;;;;;;;;;;;;iBAKjB,CAAC;AAQH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAC1D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAE9D,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,IAAI,SAAS,iBAAiB,EAAE,CAAC;IACzC,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAAC;IAChD,yEAAyE;IACzE,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,YAAY,EAAE,CAAC;IACpE,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,SAAS,MAAM,EAAE,CAAC;CAC3D;AAkBD,wBAAgB,wBAAwB,CACtC,MAAM,GAAE,YAAY,GAAG,MAAqD,GAC3E,oBAAoB,CA8EtB"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { basename, dirname } from 'node:path';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { JazzCashConfigError } from '../errors.js';
|
|
4
|
+
import { knowledgePath } from '../paths.js';
|
|
5
|
+
import { tokenise } from '../knowledge/search.js';
|
|
6
|
+
import { localCorpusSource } from '../knowledge/source.js';
|
|
7
|
+
/**
|
|
8
|
+
* Symptom knowledge base.
|
|
9
|
+
*
|
|
10
|
+
* The questions the resident engineers answer repeatedly, keyed by what the
|
|
11
|
+
* merchant actually observes rather than by what the cause turns out to be.
|
|
12
|
+
* Every cause carries a check and a fix, because a diagnosis without a next
|
|
13
|
+
* action is another support ticket.
|
|
14
|
+
*
|
|
15
|
+
* The file arrives through a `CorpusSource`, so the same loader reads a
|
|
16
|
+
* knowledge base that is not a file on this machine.
|
|
17
|
+
*/
|
|
18
|
+
/** The knowledge base's name within the diagnostics part of the corpus. */
|
|
19
|
+
const SYMPTOMS_ENTRY = 'symptoms.json';
|
|
20
|
+
const causeSchema = z.object({
|
|
21
|
+
cause: z.string().min(1),
|
|
22
|
+
check: z.string().min(1),
|
|
23
|
+
fix: z.string().min(1),
|
|
24
|
+
docRefs: z.array(z.object({ docId: z.string().min(1), sectionId: z.string().min(1).optional() })).default([]),
|
|
25
|
+
});
|
|
26
|
+
const symptomSchema = z.object({
|
|
27
|
+
id: z.string().min(1),
|
|
28
|
+
title: z.string().min(1),
|
|
29
|
+
keywords: z.array(z.string()).min(1),
|
|
30
|
+
causes: z.array(causeSchema).min(1),
|
|
31
|
+
});
|
|
32
|
+
const knowledgeBaseSchema = z.strictObject({
|
|
33
|
+
version: z.string().min(1),
|
|
34
|
+
note: z.string().optional(),
|
|
35
|
+
symptoms: z.array(symptomSchema).min(1),
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Resolve the parameter to a source and the entry to read from it.
|
|
39
|
+
*
|
|
40
|
+
* A string is the path of the knowledge-base file itself, which is the shape
|
|
41
|
+
* this loader has always taken and what lets a caller point at a one-off file
|
|
42
|
+
* without constructing a source. A source is rooted at the directory holding the
|
|
43
|
+
* knowledge base, so the file is addressed by the name it carries inside the
|
|
44
|
+
* corpus rather than by a path this process can resolve.
|
|
45
|
+
*/
|
|
46
|
+
function resolveKnowledgeBase(source) {
|
|
47
|
+
if (typeof source === 'string') {
|
|
48
|
+
return { files: localCorpusSource(dirname(source)), entry: basename(source) };
|
|
49
|
+
}
|
|
50
|
+
return { files: source, entry: SYMPTOMS_ENTRY };
|
|
51
|
+
}
|
|
52
|
+
export function loadSymptomKnowledgeBase(source = knowledgePath('diagnostics', SYMPTOMS_ENTRY)) {
|
|
53
|
+
const { files, entry } = resolveKnowledgeBase(source);
|
|
54
|
+
let parsedJson;
|
|
55
|
+
try {
|
|
56
|
+
parsedJson = JSON.parse(files.readText(entry));
|
|
57
|
+
}
|
|
58
|
+
catch (cause) {
|
|
59
|
+
throw new JazzCashConfigError(`Unable to read the diagnostics knowledge base at ${files.locate(entry)}.`, {
|
|
60
|
+
cause,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const parsed = knowledgeBaseSchema.safeParse(parsedJson);
|
|
64
|
+
if (!parsed.success) {
|
|
65
|
+
const issues = parsed.error.issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`).join('; ');
|
|
66
|
+
throw new JazzCashConfigError(`The diagnostics knowledge base is invalid. ${issues}`);
|
|
67
|
+
}
|
|
68
|
+
const { symptoms, version } = parsed.data;
|
|
69
|
+
const byId = new Map(symptoms.map((symptom) => [symptom.id, symptom]));
|
|
70
|
+
// Pre-tokenise once: the keyword list plus the title and the cause text, so a
|
|
71
|
+
// merchant's own wording matches even when it does not use a keyword verbatim.
|
|
72
|
+
const indexed = symptoms.map((symptom) => ({
|
|
73
|
+
symptom,
|
|
74
|
+
keywordTokens: new Set(symptom.keywords.flatMap((keyword) => tokenise(keyword))),
|
|
75
|
+
bodyTokens: new Set(tokenise([symptom.title, ...symptom.causes.map((entry) => `${entry.cause} ${entry.check}`)].join(' '))),
|
|
76
|
+
}));
|
|
77
|
+
return {
|
|
78
|
+
version,
|
|
79
|
+
symptoms: () => symptoms,
|
|
80
|
+
find: (id) => byId.get(id),
|
|
81
|
+
match(description, limit = 3) {
|
|
82
|
+
const tokens = tokenise(description);
|
|
83
|
+
if (tokens.length === 0) {
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
return indexed
|
|
87
|
+
.map((entry) => {
|
|
88
|
+
let score = 0;
|
|
89
|
+
for (const token of new Set(tokens)) {
|
|
90
|
+
// A keyword hit is stronger evidence than an incidental word in the
|
|
91
|
+
// explanatory prose.
|
|
92
|
+
if (entry.keywordTokens.has(token)) {
|
|
93
|
+
score += 3;
|
|
94
|
+
}
|
|
95
|
+
else if (entry.bodyTokens.has(token)) {
|
|
96
|
+
score += 1;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return { symptom: entry.symptom, score };
|
|
100
|
+
})
|
|
101
|
+
.filter((entry) => entry.score > 0)
|
|
102
|
+
.sort((left, right) => right.score - left.score)
|
|
103
|
+
.slice(0, limit);
|
|
104
|
+
},
|
|
105
|
+
docRefsFor(symptom) {
|
|
106
|
+
const seen = new Set();
|
|
107
|
+
const refs = [];
|
|
108
|
+
for (const cause of symptom.causes) {
|
|
109
|
+
for (const ref of cause.docRefs) {
|
|
110
|
+
const key = `${ref.docId}#${ref.sectionId ?? ''}`;
|
|
111
|
+
if (!seen.has(key)) {
|
|
112
|
+
seen.add(key);
|
|
113
|
+
refs.push(ref);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return refs;
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=diagnose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnose.js","sourceRoot":"","sources":["../../src/diagnostics/diagnose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,mBAAmB,EAAe,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAqB,MAAM,wBAAwB,CAAC;AAE9E;;;;;;;;;;GAUG;AAEH,2EAA2E;AAC3E,MAAM,cAAc,GAAG,eAAe,CAAC;AAEvC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACtB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAA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AAE,EAAE,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;iBAClC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;iBAC/C,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QACrB,CAAC;QAED,UAAU,CAAC,OAA0B;YACnC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;YAC/B,MAAM,IAAI,GAAa,EAAE,CAAC;YAE1B,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;gBACnC,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;oBAChC,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,SAAS,IAAI,EAAE,EAAE,CAAC;oBAClD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;wBACnB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;wBACd,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBACjB,CAAC;gBACH,CAAC;YACH,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type { DocRef } from '../errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Amount handling.
|
|
4
|
+
*
|
|
5
|
+
* Every JazzCash guide states the same rule: `pp_Amount` is in minor units. The
|
|
6
|
+
* value is multiplied by 100 before sending and the gateway treats the final two
|
|
7
|
+
* digits as decimals, so PKR 100.00 is transmitted as `"10000"`.
|
|
8
|
+
*
|
|
9
|
+
* That ×100 is a property of PKR, not of money. The ISO 4217 minor-unit exponent
|
|
10
|
+
* is 2 for PKR and TRY, 0 for JPY and 3 for KWD, so a hard-coded ×100 would debit
|
|
11
|
+
* a JPY merchant one hundred times the intended sum and a KWD merchant one tenth
|
|
12
|
+
* of it — and the digits that reach the gateway look entirely ordinary in both
|
|
13
|
+
* cases. The scale, the ceiling, the display code, the citation and the wire
|
|
14
|
+
* encoding are therefore all carried by a {@link Currency}, and every function
|
|
15
|
+
* defaults to {@link PKR} so that a JazzCash caller never has to name one.
|
|
16
|
+
*
|
|
17
|
+
* All arithmetic here is integer arithmetic on `bigint`. Floating point is never
|
|
18
|
+
* used: `0.1 + 0.2` is not 0.3, and money must not be represented by a type that
|
|
19
|
+
* cannot hold it exactly.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* How a gateway expects an amount to appear on the wire.
|
|
23
|
+
*
|
|
24
|
+
* `minor-units` is JazzCash: PKR 100.00 is `"10000"`. `major-units` is the same
|
|
25
|
+
* sum as a decimal string, `"100.00"`, which some gateways take instead.
|
|
26
|
+
*
|
|
27
|
+
* Declared per currency rather than decided here, so that a gateway expecting
|
|
28
|
+
* the other encoding is a one-line change to a currency definition instead of an
|
|
29
|
+
* inversion of the whole amount pipeline.
|
|
30
|
+
*/
|
|
31
|
+
export type AmountEncoding = 'minor-units' | 'major-units';
|
|
32
|
+
/**
|
|
33
|
+
* ISO 4217 minor-unit exponent: minor units per major unit is 10 to this power.
|
|
34
|
+
*
|
|
35
|
+
* A literal union rather than `number`, so an unlisted exponent is a compile
|
|
36
|
+
* error instead of a silently wrong multiplier. ISO 4217 defines none above 4.
|
|
37
|
+
*/
|
|
38
|
+
export type MinorUnitExponent = 0 | 1 | 2 | 3 | 4;
|
|
39
|
+
/** A currency declaration as a caller writes it; {@link defineCurrency} completes it. */
|
|
40
|
+
export interface CurrencySpec {
|
|
41
|
+
/** ISO 4217 alphabetic code, reproduced verbatim in merchant-facing messages. */
|
|
42
|
+
readonly code: string;
|
|
43
|
+
readonly exponent: MinorUnitExponent;
|
|
44
|
+
readonly encoding: AmountEncoding;
|
|
45
|
+
/**
|
|
46
|
+
* Local sanity ceiling on a single transaction, in MAJOR units.
|
|
47
|
+
*
|
|
48
|
+
* Stated in major units because that is the figure a human recognises as far
|
|
49
|
+
* too large. The same count of minor units means a thousand times more money
|
|
50
|
+
* in KWD than in JPY, so a ceiling copied between currencies as minor units
|
|
51
|
+
* would quietly stop guarding anything.
|
|
52
|
+
*/
|
|
53
|
+
readonly maxMajorUnits: bigint;
|
|
54
|
+
/** Documentation explaining this currency's amount rules, cited in every rejection. */
|
|
55
|
+
readonly docRefs?: readonly DocRef[] | undefined;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A validated currency with its derived scale.
|
|
59
|
+
*
|
|
60
|
+
* Build one with {@link defineCurrency} rather than as an object literal: the
|
|
61
|
+
* derived members must agree with the exponent, and an assembled-by-hand pair
|
|
62
|
+
* that disagrees would mis-scale every amount in that currency.
|
|
63
|
+
*/
|
|
64
|
+
export interface Currency extends CurrencySpec {
|
|
65
|
+
readonly docRefs: readonly DocRef[];
|
|
66
|
+
/** 10^exponent: minor units in one major unit. */
|
|
67
|
+
readonly scale: bigint;
|
|
68
|
+
/** {@link CurrencySpec.maxMajorUnits} expressed in minor units. */
|
|
69
|
+
readonly maxMinorUnits: bigint;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Validate a currency declaration and derive its scale.
|
|
73
|
+
*
|
|
74
|
+
* The checks run once per definition and are cheap, but a mistyped exponent is
|
|
75
|
+
* not a cosmetic fault: it multiplies or divides every amount in that currency
|
|
76
|
+
* by a power of ten, and no downstream check can detect the difference between a
|
|
77
|
+
* deliberate JPY 10,000 and a KWD 10,000 that should have been 10.000. A
|
|
78
|
+
* currency assembled from a configuration file — the obvious next step once a
|
|
79
|
+
* second provider ships — must fail here rather than at the gateway.
|
|
80
|
+
*/
|
|
81
|
+
export declare function defineCurrency(spec: CurrencySpec): Currency;
|
|
82
|
+
/** The only currency JazzCash processes. No conversion is performed. */
|
|
83
|
+
export declare const PKR: Currency;
|
|
84
|
+
/** The ISO 4217 code of the only currency the JazzCash gateway processes. */
|
|
85
|
+
export declare const SUPPORTED_CURRENCY: string;
|
|
86
|
+
/**
|
|
87
|
+
* Upper bound on a single PKR transaction, in minor units (PKR 100,000,000.00).
|
|
88
|
+
*
|
|
89
|
+
* Derived from {@link PKR} rather than written out, so the ceiling cannot drift
|
|
90
|
+
* away from the currency it belongs to. Retained as a named export because
|
|
91
|
+
* callers and tests reason about the PKR ceiling directly.
|
|
92
|
+
*/
|
|
93
|
+
export declare const MAX_MINOR_UNITS: bigint;
|
|
94
|
+
/**
|
|
95
|
+
* Convert a human-facing amount to the minor-unit string the gateway expects.
|
|
96
|
+
*
|
|
97
|
+
* Accepts `"100"`, `"100.5"`, `"100.50"` and the numeric equivalents in a
|
|
98
|
+
* two-decimal currency. Rejects anything with more decimal places than the
|
|
99
|
+
* currency has, because rounding a merchant's money silently is worse than
|
|
100
|
+
* refusing it.
|
|
101
|
+
*/
|
|
102
|
+
export declare function toMinorUnits(amount: string | number, currency?: Currency): string;
|
|
103
|
+
/**
|
|
104
|
+
* Validate a minor-unit string, throwing with an actionable message if it is wrong.
|
|
105
|
+
*
|
|
106
|
+
* Unlike {@link toMinorUnits}, which converts a human-facing figure, this checks
|
|
107
|
+
* a value that is already in wire form, so surrounding whitespace is rejected
|
|
108
|
+
* rather than absorbed.
|
|
109
|
+
*/
|
|
110
|
+
export declare function assertMinorUnits(value: string, currency?: Currency): void;
|
|
111
|
+
/** Convert minor units back to a major-unit string, e.g. `"10000"` to `"100.00"`. */
|
|
112
|
+
export declare function fromMinorUnits(minorUnits: string, currency?: Currency): string;
|
|
113
|
+
/** Format minor units for display to a merchant, e.g. `"PKR 100.00"`. */
|
|
114
|
+
export declare function formatAmount(minorUnits: string, currency?: Currency): string;
|
|
115
|
+
/**
|
|
116
|
+
* Format minor units as PKR.
|
|
117
|
+
*
|
|
118
|
+
* Retained as a named function because it reads better at a JazzCash-only call
|
|
119
|
+
* site than {@link formatAmount} with a defaulted currency, and because removing
|
|
120
|
+
* it would churn callers for no behavioural gain.
|
|
121
|
+
*/
|
|
122
|
+
export declare function formatPkr(minorUnits: string): string;
|
|
123
|
+
/**
|
|
124
|
+
* Encode a human-facing amount as the provider's gateway expects to receive it.
|
|
125
|
+
*
|
|
126
|
+
* The counterpart of {@link toMinorUnits} for a provider whose wire form is not
|
|
127
|
+
* minor units. Both go through the same exact integer parse, so a `major-units`
|
|
128
|
+
* gateway cannot receive a figure that a `minor-units` gateway would have
|
|
129
|
+
* refused.
|
|
130
|
+
*/
|
|
131
|
+
export declare function toWireAmount(amount: string | number, currency?: Currency): string;
|
|
132
|
+
/**
|
|
133
|
+
* Validate a value already in wire form against the currency's encoding.
|
|
134
|
+
*
|
|
135
|
+
* A decimal point is a defect in a minor-unit payload and mandatory in a
|
|
136
|
+
* major-unit one, so the same string cannot be judged without knowing which
|
|
137
|
+
* gateway it is bound for.
|
|
138
|
+
*/
|
|
139
|
+
export declare function assertWireAmount(value: string, currency?: Currency): void;
|
|
140
|
+
/**
|
|
141
|
+
* Recover canonical minor units from a value in wire form.
|
|
142
|
+
*
|
|
143
|
+
* The inverse of {@link toWireAmount}. Response handling compares the amount the
|
|
144
|
+
* gateway echoed with the amount that was sent, and comparing `"100.00"` with
|
|
145
|
+
* `"10000"` as strings reports a mismatch between two identical sums.
|
|
146
|
+
*/
|
|
147
|
+
export declare function minorUnitsFromWire(value: string, currency?: Currency): string;
|
|
148
|
+
/**
|
|
149
|
+
* Heuristic: does this look like a major-unit amount that was never scaled?
|
|
150
|
+
*
|
|
151
|
+
* Used by validation to turn the single most common integration mistake into a
|
|
152
|
+
* specific warning instead of an opaque gateway rejection. A decimal point is
|
|
153
|
+
* conclusive; a suspiciously small whole number is only a warning, because a
|
|
154
|
+
* PKR 1.00 test transaction (`"100"`) is both legitimate and common.
|
|
155
|
+
*/
|
|
156
|
+
export declare function looksLikeMajorUnits(value: string, currency?: Currency): boolean;
|
|
157
|
+
//# sourceMappingURL=amount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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