platform-types 1.10.711 → 1.10.712
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/dist/stock.d.ts +44 -0
- package/package.json +1 -1
package/dist/stock.d.ts
CHANGED
|
@@ -506,6 +506,50 @@ declare global {
|
|
|
506
506
|
/** Hydrated movement returned by readers after deriving ids from DynamoDB keys. */
|
|
507
507
|
interface StockSale extends StockBase, StockSaleWrite {
|
|
508
508
|
}
|
|
509
|
+
/**
|
|
510
|
+
* `data` of `GET /products?mode=stock&productId=…` — one product's ledger
|
|
511
|
+
* TOTALS, never its movement rows.
|
|
512
|
+
*
|
|
513
|
+
* - `incomes` — `Σ quantity` over the product's `INCOME#` rows.
|
|
514
|
+
* - `sales` — `Σ quantity` over the product's `SALE#` rows.
|
|
515
|
+
* - `stock` — on-hand, `incomes − sales`.
|
|
516
|
+
*
|
|
517
|
+
* Rows carrying `skip` are excluded from both sums.
|
|
518
|
+
*
|
|
519
|
+
* ⚠️ **`stock` is ABSENT exactly when the read truncated** — when either
|
|
520
|
+
* leg's paged read stopped short, which the envelope reports as top-level
|
|
521
|
+
* `truncated: true` ({@link ProductStockTotalsResponse}). It is never `0`
|
|
522
|
+
* or `null` in that case: a short read of either leg makes the difference
|
|
523
|
+
* WRONG, in either direction and by any amount, so absence is the signal.
|
|
524
|
+
* Read `stock === undefined` as "not computable from this read", never as
|
|
525
|
+
* zero. `incomes` and `sales` are still present then, but each is only the
|
|
526
|
+
* sum over the rows that were read — NOT a bound on the true leg total,
|
|
527
|
+
* because ledger quantities are signed (a service-part restore writes a
|
|
528
|
+
* negative-quantity `SALE#` row).
|
|
529
|
+
*
|
|
530
|
+
* A leg with no rows sums to `0`, never absent: a product with an empty
|
|
531
|
+
* ledger answers `incomes: 0, sales: 0, stock: 0` with `truncated: false`.
|
|
532
|
+
* The handler does not check that the product exists, so an unknown
|
|
533
|
+
* `productId` answers the same zeros rather than a 404.
|
|
534
|
+
*/
|
|
535
|
+
interface ProductStockTotals {
|
|
536
|
+
incomes: number;
|
|
537
|
+
sales: number;
|
|
538
|
+
stock?: number;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* The success envelope of `GET /products?mode=stock&productId=…`.
|
|
542
|
+
*
|
|
543
|
+
* `truncated` is always present: `true` exactly when `data.stock` is absent
|
|
544
|
+
* (see {@link ProductStockTotals}). There is no resume cursor — a truncated
|
|
545
|
+
* read means the on-hand figure is not computable from this endpoint, not
|
|
546
|
+
* that a next page exists.
|
|
547
|
+
*/
|
|
548
|
+
interface ProductStockTotalsResponse {
|
|
549
|
+
message: string;
|
|
550
|
+
data: ProductStockTotals;
|
|
551
|
+
truncated: boolean;
|
|
552
|
+
}
|
|
509
553
|
/**
|
|
510
554
|
* The body of one nightly stock-drift reconciliation run
|
|
511
555
|
* (`stacks/lambdas/stockReconciliationCron/index.ts`).
|