@onabl/contracts 0.3.0 → 0.3.2

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,35 @@
1
+ import { z } from "zod";
2
+ export declare const PAYMENT_METHODS: readonly ["EFT", "CARD", "CASH", "OTHER"];
3
+ export type PaymentMethod = (typeof PAYMENT_METHODS)[number];
4
+ export declare const RecordPaymentSchema: z.ZodObject<{
5
+ amount: z.ZodNumber;
6
+ method: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
7
+ EFT: "EFT";
8
+ CARD: "CARD";
9
+ CASH: "CASH";
10
+ OTHER: "OTHER";
11
+ }>>>;
12
+ reference: z.ZodOptional<z.ZodString>;
13
+ receivedAt: z.ZodOptional<z.ZodISODateTime>;
14
+ note: z.ZodOptional<z.ZodString>;
15
+ }, z.core.$strip>;
16
+ export type RecordPayment = z.infer<typeof RecordPaymentSchema>;
17
+ export declare const PaymentSummarySchema: z.ZodObject<{
18
+ id: z.ZodString;
19
+ amount: z.ZodString;
20
+ method: z.ZodEnum<{
21
+ EFT: "EFT";
22
+ CARD: "CARD";
23
+ CASH: "CASH";
24
+ OTHER: "OTHER";
25
+ }>;
26
+ reference: z.ZodNullable<z.ZodString>;
27
+ receivedAt: z.ZodString;
28
+ note: z.ZodNullable<z.ZodString>;
29
+ }, z.core.$strip>;
30
+ export type PaymentSummary = z.infer<typeof PaymentSummarySchema>;
31
+ export declare const VoidInvoiceSchema: z.ZodObject<{
32
+ reason: z.ZodString;
33
+ }, z.core.$strip>;
34
+ export type VoidInvoice = z.infer<typeof VoidInvoiceSchema>;
35
+ //# sourceMappingURL=invoices.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoices.d.ts","sourceRoot":"","sources":["../src/invoices.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,eAAO,MAAM,eAAe,2CAA4C,CAAC;AACzE,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,eAAO,MAAM,mBAAmB;;;;;;;;;;;iBAO9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAIhE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;iBAO/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAMlE,eAAO,MAAM,iBAAiB;;iBAE5B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VoidInvoiceSchema = exports.PaymentSummarySchema = exports.RecordPaymentSchema = exports.PAYMENT_METHODS = void 0;
4
+ // packages/contracts/src/invoices.ts
5
+ // E2 — the payment ledger. Request validation for POST /invoices/:uuid/payments
6
+ // (tenant-authenticated, not part of the public-api.ts surface — no external
7
+ // consumer needs this, it's the dashboard's "Record payment" action).
8
+ const zod_1 = require("zod");
9
+ exports.PAYMENT_METHODS = ["EFT", "CARD", "CASH", "OTHER"];
10
+ exports.RecordPaymentSchema = zod_1.z.object({
11
+ amount: zod_1.z.number().positive(),
12
+ method: zod_1.z.enum(exports.PAYMENT_METHODS).optional().default("OTHER"),
13
+ reference: zod_1.z.string().max(200).optional(),
14
+ // The actual payment date, tenant-set and backdatable — defaults to now when omitted.
15
+ receivedAt: zod_1.z.iso.datetime().optional(),
16
+ note: zod_1.z.string().max(2000).optional(),
17
+ });
18
+ // Dashboard-only payment history entry — never exposed on the public invoice
19
+ // response (no recordedBy, no internal-note leakage to the customer).
20
+ exports.PaymentSummarySchema = zod_1.z.object({
21
+ id: zod_1.z.string(),
22
+ amount: zod_1.z.string(),
23
+ method: zod_1.z.enum(exports.PAYMENT_METHODS),
24
+ reference: zod_1.z.string().nullable(),
25
+ receivedAt: zod_1.z.string(),
26
+ note: zod_1.z.string().nullable(),
27
+ });
28
+ // E4 — request validation for POST /invoices/:uuid/void and
29
+ // POST /invoices/:uuid/reissue (both tenant-authenticated). Same reason
30
+ // requirement either way — reissue voids the old invoice before creating the
31
+ // replacement.
32
+ exports.VoidInvoiceSchema = zod_1.z.object({
33
+ reason: zod_1.z.string().trim().min(1).max(500),
34
+ });
@@ -259,6 +259,16 @@ export declare const InvoiceSchema: z.ZodObject<{
259
259
  balance_uploaded: "balance_uploaded";
260
260
  }>>;
261
261
  statusChangedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
262
+ voidReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
263
+ supersedesInvoice: z.ZodOptional<z.ZodNullable<z.ZodObject<{
264
+ id: z.ZodString;
265
+ invoiceNumber: z.ZodString;
266
+ }, z.core.$strip>>>;
267
+ supersededBy: z.ZodOptional<z.ZodNullable<z.ZodObject<{
268
+ id: z.ZodString;
269
+ invoiceNumber: z.ZodString;
270
+ }, z.core.$strip>>>;
271
+ outstanding: z.ZodOptional<z.ZodString>;
262
272
  depositPercent: z.ZodNullable<z.ZodNumber>;
263
273
  depositAmount: z.ZodNullable<z.ZodString>;
264
274
  balanceAmount: z.ZodNullable<z.ZodString>;
@@ -268,6 +278,7 @@ export declare const InvoiceSchema: z.ZodObject<{
268
278
  balanceDueDate: z.ZodNullable<z.ZodString>;
269
279
  popUploadedAt: z.ZodNullable<z.ZodString>;
270
280
  lineItems: z.ZodArray<z.ZodObject<{}, z.core.$loose>>;
281
+ lineItemsVersion: z.ZodOptional<z.ZodNumber>;
271
282
  codeDiscountLabel: z.ZodNullable<z.ZodString>;
272
283
  codeDiscountType: z.ZodNullable<z.ZodEnum<{
273
284
  PERCENT: "PERCENT";
@@ -1 +1 @@
1
- {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"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K,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAChD,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC5E,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AACpD,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;AACjE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
@@ -188,6 +188,14 @@ exports.InvoiceSchema = zod_1.z
188
188
  // confirmation, and against which milestone. Orthogonal to `status`.
189
189
  popStatus: zod_1.z.enum(["none", "deposit_uploaded", "balance_uploaded"]).optional(),
190
190
  statusChangedAt: zod_1.z.string().nullable().optional(),
191
+ // E4 — void/re-issue history. Additive; absent on responses from before
192
+ // this field existed.
193
+ voidReason: zod_1.z.string().nullable().optional(),
194
+ supersedesInvoice: zod_1.z.object({ id: zod_1.z.string(), invoiceNumber: zod_1.z.string() }).nullable().optional(),
195
+ supersededBy: zod_1.z.object({ id: zod_1.z.string(), invoiceNumber: zod_1.z.string() }).nullable().optional(),
196
+ // E2 — total minus every recorded payment. Additive; absent on responses
197
+ // from before the payment ledger existed.
198
+ outstanding: zod_1.z.string().optional(),
191
199
  depositPercent: zod_1.z.number().nullable(),
192
200
  depositAmount: zod_1.z.string().nullable(),
193
201
  balanceAmount: zod_1.z.string().nullable(),
@@ -197,6 +205,9 @@ exports.InvoiceSchema = zod_1.z
197
205
  balanceDueDate: zod_1.z.string().nullable(),
198
206
  popUploadedAt: zod_1.z.string().nullable(),
199
207
  lineItems: zod_1.z.array(LineItemSchema),
208
+ // E5 — which shape of LineItem this snapshot was frozen under. Additive;
209
+ // absent on responses from before this field existed (treat as version 1).
210
+ lineItemsVersion: zod_1.z.number().optional(),
200
211
  codeDiscountLabel: zod_1.z.string().nullable(),
201
212
  codeDiscountType: zod_1.z.enum(["PERCENT", "FIXED"]).nullable(),
202
213
  codeDiscountValue: zod_1.z.string().nullable(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onabl/contracts",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Zod request/response validation schemas for onabl's public API — the SDK's typed contract with the API.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "@onabl/typescript-config": "0.0.1"
28
28
  },
29
29
  "dependencies": {
30
- "@onabl/types": "0.4.0"
30
+ "@onabl/types": "0.5.0"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "zod": "^4"