@octap/contracts 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/README.md +42 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,42 @@
1
- # Shared API contracts
2
- Framework-free TypeScript wire types used by the API and both SDKs: `src/loyalty.ts` (points)
3
- and `src/rewards.ts` (vouchers). This package is separate from on-chain Move contracts.
4
- These types also drive the OpenAPI document's request and response schemas (`npm run openapi:schemas`,
5
- see `api/README.md`): a JSDoc comment on a field becomes its description there, and `@format uuid`
6
- becomes its format. Runtime validation and protobuf generation do not exist yet.
1
+ # @octap/contracts
2
+
3
+ TypeScript types for the Octap Core REST API: every request and response body, the webhook events,
4
+ and the status values. `@octap/sdk`, `@octap/browser-sdk`, `@octap/mcp` and `@octap/verify` all use
5
+ them, and so does Core itself.
6
+
7
+ It is types only: nothing here runs, and nothing validates a value at runtime.
8
+
9
+ ```bash
10
+ npm install @octap/contracts
11
+ ```
12
+
13
+ ```ts
14
+ import type { WebhookEvent } from '@octap/contracts';
15
+
16
+ function onEvent(event: WebhookEvent) {
17
+ if (event.type === 'credits.earn.confirmed') {
18
+ // event.data is CreditsChainConfirmedEventData
19
+ }
20
+ }
21
+ ```
22
+
23
+ You don't need this package if you use `@octap/sdk`: it re-exports the types its methods take and
24
+ return. Install it on its own for code that only handles the data, such as a webhook receiver in
25
+ another service or a typed frontend.
26
+
27
+ ## What's in it
28
+
29
+ | Area | Examples |
30
+ | --- | --- |
31
+ | Points | `EarnPointsRequest`, `CreditBalanceSnapshot`, `LoyaltyTransactionDto`, `ReservePosRedemptionResponse` |
32
+ | Vouchers | `VoucherDto`, `VoucherStatus`, `VoucherOwnershipDto`, `VoucherOwnershipStatus`, `ClaimVoucherResponse` |
33
+ | Voucher batches and refunds | `VoucherBatchDto`, `VoucherBatchItem`, `VoucherRefundPolicyDto` |
34
+ | Webhooks | `WebhookEvent` (discriminated on `type`), `WebhookEventType`, `WebhookEventData<T>` |
35
+ | Members and identity | `VerifyCustomerResponse`, `MemberProfile` |
36
+ | Evidence, audit and analytics | `EvidenceBundle`, `AuditLogEntry`, `ProgramAnalyticsSummary` |
37
+
38
+ Each type's JSDoc says what its fields mean. The same comments describe the fields in Core's OpenAPI
39
+ document.
40
+
41
+ This package is not the on-chain Move contracts: those are in `contracts/` in the
42
+ [octap-core repository](https://github.com/OctaPointees/octap-core).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octap/contracts",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Typed request/response contracts for the Octap Core REST API.",
5
5
  "license": "MIT",
6
6
  "repository": {