@voyantjs/finance-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.
@@ -0,0 +1,46 @@
1
+ import { z } from "zod";
2
+ import { voucherSourceTypeSchema, voucherStatusSchema } from "./validation-shared.js";
3
+ /** Issue a new voucher. Code is generated server-side when not supplied. */
4
+ export const insertVoucherSchema = z.object({
5
+ code: z.string().min(1).max(64).optional().nullable(),
6
+ seriesCode: z.string().max(64).optional().nullable(),
7
+ currency: z.string().min(3).max(3),
8
+ amountCents: z.number().int().positive(),
9
+ issuedToPersonId: z.string().optional().nullable(),
10
+ issuedToOrganizationId: z.string().optional().nullable(),
11
+ sourceType: voucherSourceTypeSchema,
12
+ sourceBookingId: z.string().optional().nullable(),
13
+ sourcePaymentId: z.string().optional().nullable(),
14
+ validFrom: z.string().datetime().optional().nullable(),
15
+ expiresAt: z.string().datetime().optional().nullable(),
16
+ notes: z.string().optional().nullable(),
17
+ });
18
+ /**
19
+ * Update metadata. Balance (remainingAmountCents) is not in here on purpose —
20
+ * it's only mutated via `redeem`, transactionally, with a redemption row.
21
+ */
22
+ export const updateVoucherSchema = z.object({
23
+ status: voucherStatusSchema.optional(),
24
+ seriesCode: z.string().max(64).optional().nullable(),
25
+ validFrom: z.string().datetime().optional().nullable(),
26
+ expiresAt: z.string().datetime().optional().nullable(),
27
+ notes: z.string().optional().nullable(),
28
+ issuedToPersonId: z.string().optional().nullable(),
29
+ issuedToOrganizationId: z.string().optional().nullable(),
30
+ });
31
+ /** Apply a voucher against a booking. */
32
+ export const redeemVoucherSchema = z.object({
33
+ bookingId: z.string().min(1),
34
+ amountCents: z.number().int().positive(),
35
+ paymentId: z.string().optional().nullable(),
36
+ });
37
+ export const voucherListQuerySchema = z.object({
38
+ status: voucherStatusSchema.optional(),
39
+ seriesCode: z.string().optional(),
40
+ issuedToPersonId: z.string().optional(),
41
+ issuedToOrganizationId: z.string().optional(),
42
+ search: z.string().optional(),
43
+ hasBalance: z.coerce.boolean().optional(),
44
+ limit: z.coerce.number().int().min(1).max(100).default(50),
45
+ offset: z.coerce.number().int().min(0).default(0),
46
+ });
@@ -0,0 +1,6 @@
1
+ export * from "./validation-billing.js";
2
+ export * from "./validation-payments.js";
3
+ export * from "./validation-public.js";
4
+ export * from "./validation-shared.js";
5
+ export * from "./validation-vouchers.js";
6
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,0BAA0B,CAAA;AACxC,cAAc,wBAAwB,CAAA;AACtC,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA"}
@@ -0,0 +1,5 @@
1
+ export * from "./validation-billing.js";
2
+ export * from "./validation-payments.js";
3
+ export * from "./validation-public.js";
4
+ export * from "./validation-shared.js";
5
+ export * from "./validation-vouchers.js";
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@voyantjs/finance-contracts",
3
+ "version": "0.95.0",
4
+ "license": "Apache-2.0",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": "./src/index.ts",
8
+ "./validation": "./src/validation.ts"
9
+ },
10
+ "scripts": {
11
+ "typecheck": "tsc --noEmit",
12
+ "lint": "biome check src/",
13
+ "test": "vitest run --passWithNoTests",
14
+ "build": "tsc -p tsconfig.json",
15
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
16
+ "prepack": "pnpm run build"
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "publishConfig": {
22
+ "access": "public",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.js",
27
+ "default": "./dist/index.js"
28
+ },
29
+ "./validation": {
30
+ "types": "./dist/validation.d.ts",
31
+ "import": "./dist/validation.js",
32
+ "default": "./dist/validation.js"
33
+ }
34
+ },
35
+ "main": "./dist/index.js",
36
+ "types": "./dist/index.d.ts"
37
+ },
38
+ "dependencies": {
39
+ "@voyantjs/schema-kit": "workspace:*",
40
+ "zod": "^4.3.6"
41
+ },
42
+ "devDependencies": {
43
+ "@voyantjs/voyant-typescript-config": "workspace:*",
44
+ "typescript": "^6.0.2",
45
+ "vitest": "^4.1.2"
46
+ },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "https://github.com/voyantjs/voyant.git",
50
+ "directory": "packages/finance-contracts"
51
+ }
52
+ }