@marcohefti/request-network-api-contracts 0.5.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/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # Request Network API Contracts
2
+
3
+ Canonical contracts shared by the Request Network API clients. The package
4
+ houses the OpenAPI specification, metadata, and webhook fixtures that both the
5
+ TypeScript and PHP SDKs consume.
6
+
7
+ This repository keeps the assets versioned in one place so language SDKs can
8
+ reuse them without duplicating specs or fixtures. Clients consume it either
9
+ via an npm dependency or as a Git submodule.
10
+
11
+ ## Installation
12
+
13
+ Install via npm or pnpm:
14
+
15
+ ```bash
16
+ # npm
17
+ npm install --save-dev @marcohefti/request-network-api-contracts
18
+
19
+ # pnpm
20
+ pnpm add -D @marcohefti/request-network-api-contracts
21
+ ```
22
+
23
+ ## Contents
24
+
25
+ - `specs/openapi/` – auto-generated REST contract and metadata (fetched from the Request API).
26
+ - `specs/webhooks/` – manually curated webhook schema reference.
27
+ - `fixtures/webhooks/*.json` – canonical webhook payloads used across SDK test suites.
28
+ - `docs/` – release log, update instructions, and parity notes.
29
+
30
+ ## Consumption
31
+
32
+ - SDK packages import assets via `@marcohefti/request-network-api-contracts/<path>` (e.g., `@marcohefti/request-network-api-contracts/specs/openapi/request-network-openapi.json`).
33
+
34
+ ## Status
35
+
36
+ - **Phase:** authoritative. SDKs read specs/fixtures directly from this package during build and test phases.
37
+ - **Publishing:** intended primarily as a Git/npm dependency for tooling and tests rather than an end‑user package.
38
+
39
+ ## Updating the spec
40
+
41
+ Use the TypeScript client's tooling to refresh the contracts in-place:
42
+
43
+ ```bash
44
+ pnpm --filter "./packages/request-api-client" prepare:spec
45
+ pnpm --filter "./packages/request-client-contracts" verify
46
+ ```
47
+
48
+ `prepare:spec` downloads the latest OpenAPI document into `specs/openapi/`, refreshes metadata, and regenerates the TypeScript/Zod outputs in the client package. Follow with `verify` to sanity-check file sizes and presence before committing updates across both packages.
49
+
50
+ ## Future work
51
+
52
+ - [ ] Publish webhook fixture guidelines and add validation to ensure both SDKs reference the same payload set.
53
+ - [ ] Provide a version manifest so SDKs can pin contract revisions.
54
+ - [ ] Document Git submodule workflow for post-split repositories.
55
+
56
+ See `docs/OVERVIEW.md` for deeper architectural context.
@@ -0,0 +1,63 @@
1
+ # Request Client Contracts Overview
2
+
3
+ ## Purpose
4
+
5
+ Centralise the Request Network REST contracts and test fixtures in one place so
6
+ all language clients stay in sync:
7
+
8
+ - **OpenAPI spec** - canonical JSON used to generate DTOs, schema validators,
9
+ and parity tests.
10
+ - **OpenAPI metadata** - etag/fetched-at/source info to track when the spec
11
+ last changed.
12
+ - **Webhook fixtures** - shared payloads for signature verification and event
13
+ parsing tests across SDKs.
14
+
15
+ Keeping these assets together avoids duplication today and ensures future
16
+ standalone repositories (TypeScript, PHP, others) can include the contracts as a
17
+ Git dependency.
18
+
19
+ ## Directory Structure
20
+
21
+ ```
22
+ packages/request-client-contracts/
23
+ ├── README.md
24
+ ├── package.json # workspace metadata (private)
25
+ ├── specs/
26
+ │ ├── README.md # explains generated vs manual assets
27
+ │ ├── openapi/
28
+ │ │ ├── request-network-openapi.json
29
+ │ │ └── request-network-openapi.meta.json
30
+ │ └── webhooks/
31
+ │ └── request-network-webhooks.json
32
+ ├── fixtures/
33
+ │ └── webhooks/
34
+ │ ├── payment-confirmed.json
35
+ │ ├── payment-failed.json
36
+ │ └── ...
37
+ └── docs/
38
+ ├── OVERVIEW.md
39
+ └── UPDATES.md # release notes + fetch summaries
40
+ ```
41
+
42
+ ## Consumption Strategy
43
+
44
+ - **Monorepo:** SDK packages reference files via the workspace package name
45
+ (`@marcohefti/request-network-api-contracts/specs/...`). Build/validation scripts run from
46
+ the monorepo root can read from this package without additional tooling.
47
+ - **Post-split:** Each SDK repository will include this repo via Git submodule
48
+ (or shallow git dependency) so the same files are available without copying.
49
+ Documentation here will outline the update workflow.
50
+
51
+ ## Update Workflow
52
+
53
+ 1. Run `pnpm --filter "./packages/request-api-client" prepare:spec` to download the latest OpenAPI spec and metadata into `specs/openapi/` and regenerate the TypeScript/Zod outputs in the client package.
54
+ 2. Update webhook fixtures in `fixtures/webhooks/` when Request publishes new payloads. Pair every new fixture with test coverage in each SDK.
55
+ 3. Execute `pnpm --filter "./packages/request-client-contracts" verify` to confirm the expected files are present and within size bounds.
56
+ 4. Commit the contract changes (`specs/**`, `fixtures/**`, docs) together with any regenerated client artefacts so consumers can diff the update in one review.
57
+ 5. Append an entry to `docs/UPDATES.md` capturing the date, upstream reference, and required SDK follow-up.
58
+
59
+ ## Related Backlog Tasks
60
+
61
+ - **Track contract versioning** - provide a manifest so SDKs can pin/compare revisions.
62
+ - **Webhook fixture parity automation** - ensure both SDKs validate against the shared payload set.
63
+ - **Document submodule workflow** - outline how downstream repositories should consume this package post-split.
@@ -0,0 +1,36 @@
1
+ # Contracts Update Workflow
2
+
3
+ Use this checklist whenever the Request Network API publishes contract changes. The TypeScript client's tooling writes new assets directly into this package. Follow the steps below to keep every SDK in sync.
4
+
5
+ ## 1. Refresh the OpenAPI spec
6
+
7
+ ```bash
8
+ pnpm --filter "./packages/request-api-client" prepare:spec
9
+ ```
10
+
11
+ `prepare:spec` downloads the latest OpenAPI document into `specs/openapi/` (updating both the JSON and `.meta.json`) and regenerates the TypeScript + Zod outputs referenced by the client.
12
+
13
+ ## 2. Update webhook schema (if needed)
14
+
15
+ - Manually edit `specs/webhooks/request-network-webhooks.json` when Request publishes new webhook fields or events.
16
+ - Keep any breaking changes coordinated across SDKs-update shared enums and validation helpers in the clients immediately after adjusting the schema.
17
+
18
+ ## 3. Sync webhook fixtures
19
+
20
+ - Add or update payload samples under `fixtures/webhooks/`.
21
+ - Ensure each new fixture has corresponding parity tests in every SDK that consumes it.
22
+
23
+ ## 4. Verify assets
24
+
25
+ ```bash
26
+ pnpm --filter "./packages/request-client-contracts" verify
27
+ ```
28
+
29
+ The verification script asserts that the expected files exist and logs their sizes for a quick sanity check.
30
+
31
+ ## 5. Document and commit
32
+
33
+ - Record the change in `docs/UPDATES.md` (date, summary, upstream source, required SDK follow-up).
34
+ - Commit the updated contracts alongside regenerated client artefacts so downstream packages pick up the change in one review.
35
+
36
+ Repeat this workflow whenever the upstream API contract or webhook catalogue changes.
@@ -0,0 +1,15 @@
1
+ # Contracts Update Log
2
+
3
+ Record noteworthy contract updates here (spec revisions, new fixtures). Each
4
+ entry should reference the Request API release or Git commit that introduced the
5
+ change so SDK maintainers know when to regenerate code.
6
+
7
+ ## Template
8
+ - **Date:** YYYY-MM-DD
9
+ - **Spec Version:** e.g. 2025-03-12
10
+ - **Change Summary:**
11
+ - **Source:** Link to Request API changelog / ticket
12
+ - **Notes:** Regeneration impact, required SDK updates, new fixtures
13
+
14
+ ## History
15
+ - *No entries yet* - initial import seeded via `pnpm --filter "./packages/request-api-client" prepare:spec` on 2025-11-06.
@@ -0,0 +1,9 @@
1
+ {
2
+ "event": "compliance.updated",
3
+ "requestId": "req_compliance123",
4
+ "clientUserId": "user-123",
5
+ "kycStatus": "approved",
6
+ "agreementStatus": "signed",
7
+ "isCompliant": true,
8
+ "timestamp": "2025-08-28T22:25:45.995Z"
9
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "event": "compliance.updated",
3
+ "requestId": "req_compliance789",
4
+ "clientUserId": "user-789",
5
+ "kycStatus": "initiated",
6
+ "agreementStatus": "pending",
7
+ "timestamp": "2025-08-29T00:25:45.995Z"
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "event": "compliance.updated",
3
+ "requestId": "req_compliance456",
4
+ "clientUserId": "user-456",
5
+ "kycStatus": "pending",
6
+ "agreementStatus": "rejected",
7
+ "timestamp": "2025-08-28T23:25:45.995Z"
8
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "event": "payment.confirmed",
3
+ "requestId": "req_test123456789abcdef",
4
+ "requestID": "req_test123456789abcdef",
5
+ "paymentReference": "0x1234567890abcdef1234567890abcdef12345678",
6
+ "explorer": "https://scan.request.network/request/req_test123456789abcdef",
7
+ "amount": "100.0",
8
+ "totalAmountPaid": "100.0",
9
+ "expectedAmount": "100.0",
10
+ "timestamp": "2025-08-28T12:25:45.995Z",
11
+ "txHash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
12
+ "network": "ethereum",
13
+ "currency": "USDC",
14
+ "paymentCurrency": "USDC",
15
+ "isCryptoToFiat": false,
16
+ "paymentProcessor": "request-network",
17
+ "fees": [
18
+ {
19
+ "type": "network",
20
+ "amount": "0.02",
21
+ "currency": "ETH"
22
+ }
23
+ ]
24
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "event": "payment_detail.updated",
3
+ "requestId": "req_detail123",
4
+ "paymentAccountId": "acct_approved_123",
5
+ "status": "approved",
6
+ "timestamp": "2025-08-28T19:25:45.995Z"
7
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "event": "payment_detail.updated",
3
+ "requestId": "req_detail456",
4
+ "paymentAccountId": "acct_failed_456",
5
+ "status": "failed",
6
+ "rejectionMessage": "Bank verification failed",
7
+ "timestamp": "2025-08-28T20:25:45.995Z"
8
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "event": "payment_detail.updated",
3
+ "requestId": "req_detail789",
4
+ "paymentAccountId": "acct_pending_789",
5
+ "status": "pending",
6
+ "timestamp": "2025-08-28T21:25:45.995Z"
7
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "event": "payment_detail.updated",
3
+ "paymentDetailsId": "pd_test_verified",
4
+ "clientUserId": "user_test_verified",
5
+ "status": "verified",
6
+ "timestamp": "2025-11-04T05:18:54.721Z",
7
+ "rawPayload": {
8
+ "bankAccount": "verified",
9
+ "method": "bank_transfer"
10
+ }
11
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "event": "payment.failed",
3
+ "requestId": "req_fail1234567890",
4
+ "paymentReference": "0xfail1234567890abcdef1234567890abcdef1234",
5
+ "amount": "100.0",
6
+ "totalAmountPaid": "0.0",
7
+ "expectedAmount": "100.0",
8
+ "timestamp": "2025-08-28T18:25:45.995Z",
9
+ "paymentCurrency": "USDC",
10
+ "isCryptoToFiat": true,
11
+ "paymentProcessor": "request-network",
12
+ "subStatus": "insufficient_funds",
13
+ "failureReason": "Insufficient fiat liquidity",
14
+ "retryAfter": "2025-08-29T18:25:45.995Z"
15
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "event": "payment.partial",
3
+ "requestId": "req_partial1234567890",
4
+ "paymentReference": "0xpartial1234567890abcdef1234567890abcdef1234",
5
+ "amount": "50.0",
6
+ "totalAmountPaid": "50.0",
7
+ "expectedAmount": "100.0",
8
+ "timestamp": "2025-11-04T05:19:59.380Z",
9
+ "paymentProcessor": "request-network",
10
+ "fees": []
11
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "event": "payment.processing",
3
+ "requestId": "req_proc1234567890",
4
+ "paymentReference": "0xproc1234567890abcdef1234567890abcdef1234",
5
+ "amount": "100.0",
6
+ "totalAmountPaid": "0.0",
7
+ "expectedAmount": "100.0",
8
+ "timestamp": "2025-08-28T18:25:45.995Z",
9
+ "paymentCurrency": "USDC",
10
+ "isCryptoToFiat": true,
11
+ "paymentProcessor": "request-network",
12
+ "subStatus": "processing"
13
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "event": "payment.refunded",
3
+ "requestId": "req_refunded1234567890",
4
+ "paymentReference": "0xrefund1234567890abcdef1234567890abcdef5678",
5
+ "refundedTo": "0x742d35cc6634c0532925a3b8d78ecf23ee6d63d4",
6
+ "refundAmount": "100.0",
7
+ "currency": "USDC",
8
+ "timestamp": "2025-11-04T05:20:45.123Z",
9
+ "paymentProcessor": "request-network"
10
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "event": "request.recurring",
3
+ "requestId": "req_recurring9876543210",
4
+ "paymentReference": "0x9876543210fedcba9876543210fedcba98765432",
5
+ "originalRequestId": "req_original1234567890",
6
+ "originalRequestPaymentReference": "0x1234567890abcdef1234567890abcdef12345678",
7
+ "timestamp": "2025-11-04T05:21:22.149Z",
8
+ "paymentProcessor": "request-network"
9
+ }
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@marcohefti/request-network-api-contracts",
3
+ "version": "0.5.0",
4
+ "private": false,
5
+ "description": "Shared contracts for Request Network API clients (OpenAPI spec, webhook fixtures).",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "request-network",
9
+ "contracts",
10
+ "openapi",
11
+ "webhook"
12
+ ],
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+ssh://git@github.com/marcohefti/request-network-api-contracts.git"
16
+ },
17
+ "files": [
18
+ "specs",
19
+ "fixtures",
20
+ "docs",
21
+ "README.md"
22
+ ],
23
+ "scripts": {
24
+ "verify": "node scripts/verify.js"
25
+ }
26
+ }
@@ -0,0 +1,23 @@
1
+ # Specs Directory
2
+
3
+ This folder holds the contracts consumed by the Request client SDKs.
4
+
5
+ ```
6
+ openapi/ # auto-generated from the Request REST API
7
+ webhooks/ # manually curated webhook schema
8
+ ```
9
+
10
+ ## `openapi/`
11
+ - `request-network-openapi.json` – fetched via automation from the upstream
12
+ Request API.
13
+ - `request-network-openapi.meta.json` – metadata captured during fetch (e.g.
14
+ etag, timestamp, source URL).
15
+
16
+ These files should only change through the regeneration script (`pnpm --filter "./packages/request-api-client" fetch:openapi` or the broader `prepare:spec`). Avoid manual edits. Rerun the fetch command when upstream changes land and commit the updated JSON + metadata.
17
+
18
+ ## `webhooks/`
19
+ - `request-network-webhooks.json` – maintained manually. Update it when webhook
20
+ documentation or behaviour changes, and keep fixtures/tests in sync.
21
+
22
+ This separation ensures automation never overwrites the manual webhook spec while
23
+ making it obvious which files are generated vs. curated.