@paybyrd/devagent-test-js 2.0.0 → 2.1.0-alpha.11

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/README.md CHANGED
@@ -10,3 +10,14 @@ branches and PRs publish prereleases), and the version in `package.json` stays `
10
10
  Used by `devagent-test-service` (Azure DevOps): `web/` (npm) and `widget/` (Yarn).
11
11
 
12
12
  Build and test: `npm ci && npm test`.
13
+
14
+ ## Demo page
15
+
16
+ `demo/index.html` validates a payment with the built SDK (`dist/`). It is not part of the npm package.
17
+
18
+ ```sh
19
+ npm ci && npm run build
20
+ python3 -m http.server # from the repository root
21
+ ```
22
+
23
+ Then open http://localhost:8000/demo/.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export interface PaymentRequest {
2
2
  amount: number;
3
3
  reference: string;
4
- currency: string;
4
+ currency?: string;
5
5
  }
6
6
  export interface ValidationResult {
7
7
  valid: boolean;
package/dist/index.js CHANGED
@@ -13,7 +13,8 @@ function validatePayment(request) {
13
13
  else if (request.reference.length > 50) {
14
14
  errors.push("reference must be at most 50 characters");
15
15
  }
16
- if (!SUPPORTED_CURRENCIES.includes(request.currency)) {
16
+ // null (JSON payloads, plain JS callers) means "no currency", like undefined
17
+ if (request.currency != null && !SUPPORTED_CURRENCIES.includes(request.currency)) {
17
18
  errors.push(`currency must be one of ${SUPPORTED_CURRENCIES.join(", ")}`);
18
19
  }
19
20
  return { valid: errors.length === 0, errors };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paybyrd/devagent-test-js",
3
- "version": "2.0.0",
3
+ "version": "2.1.0-alpha.11",
4
4
  "description": "Test package for the Paybyrd dev agent sandbox. Not for use: it has no real functionality.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",