@farm.js/autumn 0.1.0-beta.106 → 0.1.0-beta.107

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.
Files changed (2) hide show
  1. package/dist/index.js +10 -2
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1128,8 +1128,16 @@ export function autumn(input) {
1128
1128
  if (!body.key) {
1129
1129
  return new Response("An Autumn meter key is required.", { status: 400 });
1130
1130
  }
1131
- if (typeof body.quantity !== "number" || !Number.isFinite(body.quantity)) {
1132
- return new Response("A numeric quantity is required.", { status: 400 });
1131
+ if (typeof body.quantity !== "number" ||
1132
+ !Number.isFinite(body.quantity) ||
1133
+ body.quantity <= 0) {
1134
+ // Usage is reported as an increment, and the projection is written
1135
+ // back as the customer's absolute balance, so a negative quantity
1136
+ // lets a caller lower their own metered usage. The hard-limit check
1137
+ // compares `projected > hardLimit`, which a negative always passes.
1138
+ return new Response("Autumn reported quantity must be a positive number.", {
1139
+ status: 400,
1140
+ });
1133
1141
  }
1134
1142
  if (!body.idempotencyKey) {
1135
1143
  return new Response("An idempotencyKey is required for Autumn usage reporting.", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm.js/autumn",
3
- "version": "0.1.0-beta.106",
3
+ "version": "0.1.0-beta.107",
4
4
  "description": "Autumn billing integration for Farm.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -31,8 +31,8 @@
31
31
  "dependencies": {
32
32
  "autumn-js": "^1.2.7",
33
33
  "standardwebhooks": "^1.0.0",
34
- "@farm.js/integration-utils": "0.1.0-beta.106",
35
- "@farm.js/core": "0.1.0-beta.106"
34
+ "@farm.js/core": "0.1.0-beta.107",
35
+ "@farm.js/integration-utils": "0.1.0-beta.107"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc",