@omnixhq/ucp-js-sdk 1.0.2 → 1.1.0-draft.4.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.
package/README.md CHANGED
@@ -19,7 +19,7 @@
19
19
  </p>
20
20
 
21
21
  <p align="center">
22
- <b>JavaScript library for the Universal Commerce Protocol (UCP).</b>
22
+ <b>Runtime-validated Zod schemas and TypeScript types for the Universal Commerce Protocol (UCP).</b>
23
23
  </p>
24
24
 
25
25
  [![npm version](https://img.shields.io/npm/v/@omnixhq/ucp-js-sdk.svg)](https://www.npmjs.com/package/@omnixhq/ucp-js-sdk)
@@ -29,47 +29,121 @@
29
29
 
30
30
  ## Overview
31
31
 
32
- This repository contains the JavaScript SDK for the
33
- [Universal Commerce Protocol (UCP)](https://ucp.dev). It provides TypeScript
34
- types and [Zod](https://zod.dev/) schemas for UCP models, making it easy to
35
- build UCP-compliant applications in JavaScript and TypeScript.
32
+ The JavaScript SDK for the [Universal Commerce Protocol (UCP)](https://ucp.dev).
33
+ Auto-generated from the UCP spec with full coverage — 100 schemas including
34
+ checkout, orders, payments, fulfillment, discovery profiles, and all inline enums.
36
35
 
37
- ## Installation
36
+ **Key features:**
37
+
38
+ - 100% spec coverage — every schema, `$def`, request variant, and enum
39
+ - Fully generated from the UCP JSON Schema spec — consumer aliases in `extensions.ts`
40
+ - Runtime validation with [Zod](https://zod.dev/) — `.parse()` and `.safeParse()`
41
+ - Extension-safe — `additionalProperties: true` schemas use `.passthrough()` to preserve extension data
42
+ - Dual ESM/CJS build — works everywhere
38
43
 
39
- To install the SDK in your project, run:
44
+ ## Installation
40
45
 
41
46
  ```bash
47
+ # Stable (current UCP release)
42
48
  npm install @omnixhq/ucp-js-sdk
43
49
  ```
44
50
 
51
+ ### Draft builds
52
+
53
+ To build against upcoming UCP spec changes (Catalog capability, Order updates, etc.),
54
+ install the `next` tag:
55
+
56
+ ```bash
57
+ # Draft (latest UCP spec main branch)
58
+ npm install @omnixhq/ucp-js-sdk@next
59
+ ```
60
+
61
+ Draft builds are published automatically when the UCP spec's `main` branch changes.
62
+ They use prerelease versions (e.g., `1.0.2-draft.5.1`) and won't affect your
63
+ stable installs. Switch back anytime with `npm install @omnixhq/ucp-js-sdk@latest`.
64
+
45
65
  ## Usage
46
66
 
47
- The SDK provides Zod schemas and TypeScript types for every UCP entity. Use schemas
48
- to validate data at runtime and get full type safety throughout your application:
67
+ ### Validate a checkout request
49
68
 
50
69
  ```typescript
51
- import { ExtendedCheckoutCreateRequestSchema } from "@omnixhq/ucp-js-sdk";
70
+ import {
71
+ CheckoutCreateRequestSchema,
72
+ type CheckoutCreateRequest,
73
+ } from "@omnixhq/ucp-js-sdk";
52
74
 
53
- const result = ExtendedCheckoutCreateRequestSchema.safeParse(req.body);
75
+ const result = CheckoutCreateRequestSchema.safeParse(req.body);
54
76
  if (!result.success) {
55
77
  return res.status(400).json({ error: result.error.flatten() });
56
78
  }
57
- // result.data is fully typed
79
+ const checkout: CheckoutCreateRequest = result.data;
80
+ ```
81
+
82
+ ### Validate a checkout response
83
+
84
+ ```typescript
85
+ import { CheckoutSchema } from "@omnixhq/ucp-js-sdk";
86
+
87
+ const checkout = CheckoutSchema.parse(apiResponse);
88
+ // Typed fields: checkout.id, checkout.status, checkout.line_items, etc.
89
+ // Extension data (fulfillment, discounts, ap2) is preserved at runtime
90
+ // via .passthrough() but not statically typed on the base schema.
91
+ ```
92
+
93
+ ### Validate a discovery profile
94
+
95
+ ```typescript
96
+ import { UcpDiscoveryProfileSchema } from "@omnixhq/ucp-js-sdk";
97
+
98
+ const profile = await fetch(
99
+ "https://platform.example.com/.well-known/ucp"
100
+ ).then((r) => r.json());
101
+ const discovery = UcpDiscoveryProfileSchema.parse(profile);
102
+
103
+ // discovery.ucp.services — Record<string, Service[]>
104
+ // discovery.ucp.capabilities — Record<string, Capability[]>
105
+ // discovery.ucp.payment_handlers — Record<string, PaymentHandler[]>
106
+ // discovery.signing_keys — JWK signing keys
107
+ ```
108
+
109
+ ### Use standalone enums
110
+
111
+ ```typescript
112
+ import {
113
+ CheckoutStatusEnumSchema,
114
+ TotalTypeEnumSchema,
115
+ ServiceBaseTransportEnumSchema,
116
+ } from "@omnixhq/ucp-js-sdk";
117
+
118
+ // Type-safe enum values
119
+ const status = CheckoutStatusEnumSchema.parse("incomplete");
120
+ const transport = ServiceBaseTransportEnumSchema.parse("mcp");
58
121
  ```
59
122
 
60
- See [docs/examples.md](docs/examples.md) for more examples covering checkout
61
- validation, payment handlers, discovery profiles, order webhooks, and fulfillment.
123
+ See [docs/examples.md](docs/examples.md) for more examples covering payment
124
+ handlers, order webhooks, and fulfillment.
125
+
126
+ ## What's included
127
+
128
+ | Category | Count | Examples |
129
+ | ----------------- | ----- | ------------------------------------------------------------ |
130
+ | Top-level schemas | 46 | `CheckoutSchema`, `OrderSchema`, `PaymentSchema` |
131
+ | `$defs` exports | 39 | `UcpEntitySchema`, `PaymentHandlerResponseSchema` |
132
+ | Request variants | 7 | `CheckoutCreateRequestSchema`, `CheckoutUpdateRequestSchema` |
133
+ | Inline enums | 15 | `CheckoutStatusEnumSchema`, `TotalTypeEnumSchema` |
134
+ | Consumer aliases | ~15 | `UcpDiscoveryProfileSchema`, `CheckoutResponseStatusSchema` |
135
+
136
+ All schemas have corresponding TypeScript types exported (e.g., `Checkout`, `Order`, `UcpDiscoveryProfile`).
62
137
 
63
138
  ## Development
64
139
 
65
140
  ### Prerequisites
66
141
 
67
- This project uses `npm` for package management and `typescript` for building.
142
+ Node.js 22+ and npm.
68
143
 
69
144
  ### Generating schemas
70
145
 
71
- `src/spec_generated.ts` is auto-generated from the UCP spec. The generator
72
- downloads the spec tarball directly — no local clone required:
146
+ `src/spec_generated.ts` is auto-generated from the UCP spec:
73
147
 
74
148
  ```bash
75
149
  npm run generate # default release (v2026-01-23)
@@ -81,28 +155,32 @@ npm run generate -- /path/to/ucp/source # local spec clone
81
155
 
82
156
  ### Verifying schema coverage
83
157
 
84
- Check that `spec_generated.ts` exports exactly the schemas present in the spec —
85
- no missing, no undocumented extras:
86
-
87
158
  ```bash
88
159
  npm run verify:schemas # default release
89
160
  npm run verify:schemas -- --release v2026-01-24 # specific release
90
161
  npm run verify:schemas -- --branch main # latest on a branch
91
- npm run verify:schemas -- /path/to/ucp/source # local clone
92
162
  ```
93
163
 
94
- This runs automatically in CI before every build. See
95
- [docs/schema-verification.md](docs/schema-verification.md) for the full
96
- reference — output format, upgrade workflow, and skipped schemas.
164
+ Runs automatically in CI. See [docs/schema-verification.md](docs/schema-verification.md)
165
+ for the full reference.
97
166
 
98
167
  ### Building
99
168
 
100
- To build the project for both CommonJS and ESM:
101
-
102
169
  ```bash
103
- npm run build
170
+ npm run build # tsdown → dual ESM (.mjs) + CJS (.cjs)
171
+ npm run typecheck # tsc --noEmit
172
+ npm run lint # eslint
173
+ npm run format # prettier
104
174
  ```
105
175
 
176
+ ### Draft branch workflow
177
+
178
+ The `draft` branch tracks the latest UCP spec `main` for upcoming features:
179
+
180
+ - **Auto-regeneration**: every Monday at 09:00 UTC (or manual trigger via Actions)
181
+ - **Auto-publish**: push to `draft` → publishes `X.Y.Z-draft.N` with npm `next` tag
182
+ - **Promotion**: when UCP cuts a stable release, merge `draft` → `main` → release-please handles the rest
183
+
106
184
  ## Contributing
107
185
 
108
186
  We welcome community contributions. See our