@voyantjs/transactions-contracts 0.95.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 +25 -0
- package/dist/contracts.test.d.ts +2 -0
- package/dist/contracts.test.d.ts.map +1 -0
- package/dist/contracts.test.js +20 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/validation.d.ts +1462 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +472 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @voyantjs/transactions-contracts
|
|
2
|
+
|
|
3
|
+
Pure transactions validation schemas (offers, orders, order terms) and enums,
|
|
4
|
+
zod-only, for consumers (admin SDK, Voyant Connect) that validate transaction
|
|
5
|
+
payloads without the transactions runtime. `@voyantjs/transactions` re-exports
|
|
6
|
+
these so existing import paths are unchanged.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pnpm add @voyantjs/transactions-contracts zod
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import {
|
|
18
|
+
insertOfferSchema,
|
|
19
|
+
insertOrderSchema,
|
|
20
|
+
orderStatusSchema,
|
|
21
|
+
} from "@voyantjs/transactions-contracts"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Existing `@voyantjs/transactions/validation` imports remain available for
|
|
25
|
+
applications that already depend on the full runtime package.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.test.d.ts","sourceRoot":"","sources":["../src/contracts.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { insertOfferSchema, orderStatusSchema, transactionItemTypeSchema } from "./index.js";
|
|
3
|
+
describe("transactions-contracts", () => {
|
|
4
|
+
it("accepts valid enum and schema payloads", () => {
|
|
5
|
+
expect(orderStatusSchema.parse("confirmed")).toBe("confirmed");
|
|
6
|
+
expect(transactionItemTypeSchema.parse("service")).toBe("service");
|
|
7
|
+
const offer = insertOfferSchema.parse({
|
|
8
|
+
offerNumber: "OF-001",
|
|
9
|
+
title: "Sample offer",
|
|
10
|
+
currency: "USD",
|
|
11
|
+
});
|
|
12
|
+
expect(offer.status).toBe("draft");
|
|
13
|
+
expect(offer.totalAmountCents).toBe(0);
|
|
14
|
+
});
|
|
15
|
+
it("rejects invalid enum and schema payloads", () => {
|
|
16
|
+
expect(orderStatusSchema.safeParse("shipped").success).toBe(false);
|
|
17
|
+
expect(transactionItemTypeSchema.safeParse("nope").success).toBe(false);
|
|
18
|
+
expect(insertOfferSchema.safeParse({ title: "Missing fields" }).success).toBe(false);
|
|
19
|
+
});
|
|
20
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./validation.js";
|