Add NATS account-balance SoT and statement review for customers, CS, and sales
Some checks are pending
offline / test (push) Waiting to run
Some checks are pending
offline / test (push) Waiting to run
Internal billing now uses verae.billing.* request-reply and pubs. zappier-account-balance tracks prepaid, credits, usage, and payments. Portal, admin, CS, and sales all review the same statement. Independent Forgejo repos stay split via push-module-repos.
This commit is contained in:
parent
a1a5b957fd
commit
ac38676645
135 changed files with 3078 additions and 130 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
One MD file per source module.
|
||||
|
||||
- [zappier/accounting-export](zappier/accounting-export.md)
|
||||
- [zappier/accounts](zappier/accounts.md)
|
||||
- [zappier/admin-users](zappier/admin-users.md)
|
||||
- [zappier/admin](zappier/admin.md)
|
||||
|
|
@ -10,6 +11,8 @@ One MD file per source module.
|
|||
- [zappier/billing/credit](zappier/billing/credit.md)
|
||||
- [zappier/billing/reload](zappier/billing/reload.md)
|
||||
- [zappier/billing/stripe](zappier/billing/stripe.md)
|
||||
- [zappier/billing-nats](zappier/billing-nats.md)
|
||||
- [zappier/credits](zappier/credits.md)
|
||||
- [zappier/db/admin-user-repo](zappier/db/admin-user-repo.md)
|
||||
- [zappier/db/billing-repo](zappier/db/billing-repo.md)
|
||||
- [zappier/db/customer-repo](zappier/db/customer-repo.md)
|
||||
|
|
@ -21,10 +24,13 @@ One MD file per source module.
|
|||
- [zappier/invoicing](zappier/invoicing.md)
|
||||
- [zappier/jobs/report-usage](zappier/jobs/report-usage.md)
|
||||
- [zappier/meter](zappier/meter.md)
|
||||
- [zappier/nats-shim.d](zappier/nats-shim.d.md)
|
||||
- [zappier/paths](zappier/paths.md)
|
||||
- [zappier/portal](zappier/portal.md)
|
||||
- [zappier/pricing](zappier/pricing.md)
|
||||
- [zappier/reports](zappier/reports.md)
|
||||
- [zappier/statement](zappier/statement.md)
|
||||
- [zappier/upstream](zappier/upstream.md)
|
||||
- [zappier/usage](zappier/usage.md)
|
||||
- [verae-zapier-middleware/app](verae-zapier-middleware/app.md)
|
||||
- [verae-zapier-middleware/clients/veraeClient](verae-zapier-middleware/clients/veraeClient.md)
|
||||
|
|
@ -111,3 +117,12 @@ One MD file per source module.
|
|||
- [verae-zapier-simulator/pipeline](verae-zapier-simulator/pipeline.md)
|
||||
- [verae-zapier-simulator/server](verae-zapier-simulator/server.md)
|
||||
- [verae-zapier-simulator/trace](verae-zapier-simulator/trace.md)
|
||||
- [zappier-account-balance/books](zappier-account-balance/books.md)
|
||||
- [zappier-account-balance/server](zappier-account-balance/server.md)
|
||||
- [zappier-account-balance/subjects](zappier-account-balance/subjects.md)
|
||||
- [zappier-customer-service/nats-billing](zappier-customer-service/nats-billing.md)
|
||||
- [zappier-customer-service/server](zappier-customer-service/server.md)
|
||||
- [zappier-sales-pricing/nats-billing](zappier-sales-pricing/nats-billing.md)
|
||||
- [zappier-sales-pricing/server](zappier-sales-pricing/server.md)
|
||||
- [zappier-accounting-export/nats-billing](zappier-accounting-export/nats-billing.md)
|
||||
- [zappier-accounting-export/server](zappier-accounting-export/server.md)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
**Package:** `verae-fleet`
|
||||
**Source:** `packages/verae-fleet/src/supervisor.js`
|
||||
**Lines:** 511
|
||||
**Lines:** 528
|
||||
|
||||
## What this module is
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ Implementation module in `verae-fleet`. The tables below are extracted from the
|
|||
|
||||
## Exports
|
||||
|
||||
`Supervisor`
|
||||
`spawnLocal`, `Supervisor`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
|
|
@ -22,6 +22,7 @@ Implementation module in `verae-fleet`. The tables below are extracted from the
|
|||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `spawnLocal` | `root, spec, env, healthPort` | — | `unknown` | see Call graph |
|
||||
| `waitExit` | `child, ms` | — | `unknown` | see Call graph |
|
||||
| `waitForHealth` | `rec, ms` | — | `unknown` | see Call graph |
|
||||
|
||||
|
|
@ -70,7 +71,7 @@ Implementation module in `verae-fleet`. The tables below are extracted from the
|
|||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`floor`, `join`, `dirname`, `fileURLToPath`, `constructor`, `loadFleet`, `mkdirSync`, `isArray`, `machines`, `addMachine`, `upsertMachine`, `saveOverlay`, `log`, `setMachineEnabled`, `find`, `checkMachine`, `sshCheck`, `httpProbe`, `machineOf`, `controlInstance`, `sshHttp`, `postControl`, `toISOString`, `push`, `splice`, `spec`, `nextIndex`, `values`, `filter`, `map`, `has`, `startOne`, `get`, `pickMachine`, `sshSpawnWorker`, `spawn`, `now`, `on`, `set`, `waitForHealth`, `stopInstance`, `sshKillWorker`, `kill`, `waitExit`, `delete`, `reconcile`, `pauseInstance`, `resumeInstance`, `restartInstance`, `markUnhealthy`, `probe`, `isFinite`, `summarizeRtt`, `available`, `keys`, `min`, `startService`, `stopService`, `pauseService`, `resumeService`
|
||||
`floor`, `join`, `dirname`, `fileURLToPath`, `apps`, `spawnLocal`, `resolve`, `spawn`, `constructor`, `loadFleet`, `mkdirSync`, `isArray`, `machines`, `addMachine`, `upsertMachine`, `saveOverlay`, `log`, `setMachineEnabled`, `find`, `checkMachine`, `sshCheck`, `httpProbe`, `machineOf`, `controlInstance`, `sshHttp`, `postControl`, `toISOString`, `push`, `splice`, `spec`, `nextIndex`, `values`, `filter`, `map`, `has`, `startOne`, `get`, `pickMachine`, `sshSpawnWorker`, `now`, `on`, `set`, `waitForHealth`, `stopInstance`, `sshKillWorker`, `kill`, `waitExit`, `delete`, `reconcile`, `pauseInstance`, `resumeInstance`, `restartInstance`, `markUnhealthy`, `probe`, `isFinite`, `summarizeRtt`, `available`, `keys`, `min`, `startService`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
|
|
|
|||
54
docs/modules/zappier-account-balance/books.md
Normal file
54
docs/modules/zappier-account-balance/books.md
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
# `zappier-account-balance/books`
|
||||
|
||||
**Package:** `zappier-account-balance`
|
||||
**Source:** `packages/zappier-account-balance/src/books.js`
|
||||
**Lines:** 90
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier-account-balance`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
`AccountBooks`, `handle`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
| Kind | Name |
|
||||
|------|------|
|
||||
| class | `AccountBooks` |
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `handle` | `subject, payload, books` | — | `unknown` | see Call graph |
|
||||
| `match` | `rows` | — | `unknown` | see Call graph |
|
||||
|
||||
## Methods (class / object)
|
||||
|
||||
| Name | Parameters |
|
||||
|------|------------|
|
||||
| `constructor` | `(none)` |
|
||||
| `prepaidCents` | `customerId` |
|
||||
| `adjust` | `{ customerId, cents, reason, agent, kind = 'credit' }` |
|
||||
| `recordUsage` | `entry` |
|
||||
| `recordPayment` | `entry` |
|
||||
| `statement` | `customerId` |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
_No imports detected._
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`constructor`, `prepaidCents`, `adjust`, `trunc`, `now`, `toString`, `random`, `slice`, `toISOString`, `unshift`, `recordUsage`, `recordPayment`, `statement`, `filter`, `match`, `handle`, `endsWith`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
53
docs/modules/zappier-account-balance/server.md
Normal file
53
docs/modules/zappier-account-balance/server.md
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# `zappier-account-balance/server`
|
||||
|
||||
**Package:** `zappier-account-balance`
|
||||
**Source:** `packages/zappier-account-balance/src/server.js`
|
||||
**Lines:** 93
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier-account-balance`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
_No named `export` / `module.exports` keys detected._
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `startNats` | `(none)` | — | `unknown` | see Call graph |
|
||||
| `readBody` | `req` | — | `unknown` | see Call graph |
|
||||
| `reply` | `sub, fn` | — | `unknown` | see Call graph |
|
||||
| `json` | `code, obj` | — | `unknown` | see Call graph |
|
||||
|
||||
## Methods (class / object)
|
||||
|
||||
| Name | Parameters |
|
||||
|------|------------|
|
||||
| `reply` | `nc.subscribe(SUBJECTS.STATEMENT_GET, { queue: SUBJECTS.QUEUE }` |
|
||||
| `reply` | `nc.subscribe(SUBJECTS.BALANCE_GET, { queue: SUBJECTS.QUEUE }` |
|
||||
| `reply` | `nc.subscribe(SUBJECTS.BALANCE_ADJUST, { queue: SUBJECTS.QUEUE }` |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
- `node:http`
|
||||
- `./books.js`
|
||||
- `./subjects.js`
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`startNats`, `import`, `connect`, `split`, `async`, `parse`, `decode`, `fn`, `respond`, `encode`, `stringify`, `reply`, `subscribe`, `handle`, `write`, `readBody`, `on`, `push`, `resolve`, `concat`, `toString`, `createServer`, `writeHead`, `end`, `json`, `match`, `statement`, `adjust`, `listen`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
36
docs/modules/zappier-account-balance/subjects.md
Normal file
36
docs/modules/zappier-account-balance/subjects.md
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
# `zappier-account-balance/subjects`
|
||||
|
||||
**Package:** `zappier-account-balance`
|
||||
**Source:** `packages/zappier-account-balance/src/subjects.js`
|
||||
**Lines:** 11
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier-account-balance`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
`SUBJECTS`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
_No top-level functions extracted._
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
_No imports detected._
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
_No local call identifiers extracted._
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
40
docs/modules/zappier-accounting-export/nats-billing.md
Normal file
40
docs/modules/zappier-accounting-export/nats-billing.md
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# `zappier-accounting-export/nats-billing`
|
||||
|
||||
**Package:** `zappier-accounting-export`
|
||||
**Source:** `packages/zappier-accounting-export/src/nats-billing.js`
|
||||
**Lines:** 18
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier-accounting-export`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
`SUBJECTS`, `billingRequest`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `billingRequest` | `subject, payload` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
_No imports detected._
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`billingRequest`, `import`, `connect`, `split`, `request`, `encode`, `stringify`, `parse`, `decode`, `close`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
46
docs/modules/zappier-accounting-export/server.md
Normal file
46
docs/modules/zappier-accounting-export/server.md
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# `zappier-accounting-export/server`
|
||||
|
||||
**Package:** `zappier-accounting-export`
|
||||
**Source:** `packages/zappier-accounting-export/src/server.js`
|
||||
**Lines:** 62
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier-accounting-export`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
_No named `export` / `module.exports` keys detected._
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `edge` | `pathname` | — | `unknown` | see Call graph |
|
||||
| `send` | `code, type, body` | — | `unknown` | see Call graph |
|
||||
| `json` | `code, obj` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
- `node:fs`
|
||||
- `node:http`
|
||||
- `node:path`
|
||||
- `node:url`
|
||||
- `./nats-billing.js`
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`replace`, `join`, `dirname`, `fileURLToPath`, `edge`, `fetch`, `createServer`, `async`, `writeHead`, `end`, `send`, `stringify`, `readFileSync`, `json`, `match`, `billingRequest`, `text`, `get`, `encodeURIComponent`, `listen`, `write`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
40
docs/modules/zappier-customer-service/nats-billing.md
Normal file
40
docs/modules/zappier-customer-service/nats-billing.md
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# `zappier-customer-service/nats-billing`
|
||||
|
||||
**Package:** `zappier-customer-service`
|
||||
**Source:** `packages/zappier-customer-service/src/nats-billing.js`
|
||||
**Lines:** 21
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier-customer-service`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
`SUBJECTS`, `billingRequest`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `billingRequest` | `subject, payload` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
_No imports detected._
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`billingRequest`, `import`, `connect`, `split`, `request`, `encode`, `stringify`, `parse`, `decode`, `close`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
45
docs/modules/zappier-customer-service/server.md
Normal file
45
docs/modules/zappier-customer-service/server.md
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# `zappier-customer-service/server`
|
||||
|
||||
**Package:** `zappier-customer-service`
|
||||
**Source:** `packages/zappier-customer-service/src/server.js`
|
||||
**Lines:** 81
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier-customer-service`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
_No named `export` / `module.exports` keys detected._
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `statement` | `customerId` | — | `unknown` | see Call graph |
|
||||
| `json` | `code, obj` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
- `node:fs`
|
||||
- `node:http`
|
||||
- `node:path`
|
||||
- `node:url`
|
||||
- `./nats-billing.js`
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`join`, `dirname`, `fileURLToPath`, `replace`, `statement`, `billingRequest`, `fetch`, `json`, `createServer`, `async`, `writeHead`, `end`, `stringify`, `readFileSync`, `match`, `push`, `parse`, `concat`, `toString`, `get`, `listen`, `write`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
40
docs/modules/zappier-sales-pricing/nats-billing.md
Normal file
40
docs/modules/zappier-sales-pricing/nats-billing.md
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# `zappier-sales-pricing/nats-billing`
|
||||
|
||||
**Package:** `zappier-sales-pricing`
|
||||
**Source:** `packages/zappier-sales-pricing/src/nats-billing.js`
|
||||
**Lines:** 18
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier-sales-pricing`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
`SUBJECTS`, `billingRequest`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `billingRequest` | `subject, payload` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
_No imports detected._
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`billingRequest`, `import`, `connect`, `split`, `request`, `encode`, `stringify`, `parse`, `decode`, `close`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
45
docs/modules/zappier-sales-pricing/server.md
Normal file
45
docs/modules/zappier-sales-pricing/server.md
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# `zappier-sales-pricing/server`
|
||||
|
||||
**Package:** `zappier-sales-pricing`
|
||||
**Source:** `packages/zappier-sales-pricing/src/server.js`
|
||||
**Lines:** 77
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier-sales-pricing`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
_No named `export` / `module.exports` keys detected._
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `edge` | `pathname, { method = 'GET', body } = {}` | — | `unknown` | see Call graph |
|
||||
| `json` | `code, obj` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
- `node:fs`
|
||||
- `node:http`
|
||||
- `node:path`
|
||||
- `node:url`
|
||||
- `./nats-billing.js`
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`join`, `dirname`, `fileURLToPath`, `replace`, `edge`, `fetch`, `stringify`, `text`, `parse`, `createServer`, `async`, `writeHead`, `end`, `readFileSync`, `json`, `match`, `billingRequest`, `push`, `concat`, `toString`, `listen`, `write`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
43
docs/modules/zappier/accounting-export.md
Normal file
43
docs/modules/zappier/accounting-export.md
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# `zappier/accounting-export`
|
||||
|
||||
**Package:** `zappier`
|
||||
**Source:** `packages/zappier/src/accounting-export.ts`
|
||||
**Lines:** 37
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
`invoicesToQuickBooksIif`, `invoicesToAccountingCsv`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `iifDate` | `ms: number` | — | `unknown` | see Call graph |
|
||||
| `invoicesToQuickBooksIif` | `invoices: Invoice[]` | — | `unknown` | see Call graph |
|
||||
| | _QuickBooks IIF journal for issued/paid invoices (Accounts Receivable + Sales)._ | | | |
|
||||
| `invoicesToAccountingCsv` | `invoices: Invoice[]` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
- `./invoicing`
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`iifDate`, `getUTCMonth`, `padStart`, `getUTCDate`, `getUTCFullYear`, `invoices`, `invoicesToQuickBooksIif`, `now`, `toFixed`, `push`, `join`, `invoicesToAccountingCsv`, `map`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
**Package:** `zappier`
|
||||
**Source:** `packages/zappier/src/admin.ts`
|
||||
**Lines:** 486
|
||||
**Lines:** 588
|
||||
|
||||
## What this module is
|
||||
|
||||
|
|
@ -32,7 +32,8 @@ Implementation module in `zappier`. The tables below are extracted from the sour
|
|||
| `renderInvoiceHtml` | `invoice: Invoice, customerName: string` | — | `unknown` | see Call graph |
|
||||
| `adminRouter` | `store: PricingStore,
|
||||
customers: CustomerRepo,
|
||||
accounting: AccountingDeps,` | — | `unknown` | see Call graph |
|
||||
accounting: AccountingDeps,
|
||||
credits: CreditLedger = new CreditLedger(` | — | `unknown` | see Call graph |
|
||||
|
||||
## Methods (class / object)
|
||||
|
||||
|
|
@ -58,10 +59,14 @@ Implementation module in `zappier`. The tables below are extracted from the sour
|
|||
- `./paths`
|
||||
- `./reports`
|
||||
- `./usage`
|
||||
- `./credits`
|
||||
- `./accounting-export`
|
||||
- `./statement`
|
||||
- `./billing-nats`
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`tokens`, `adminLoginRouter`, `post`, `status`, `json`, `findByUsername`, `verifyPassword`, `randomBytes`, `toString`, `set`, `now`, `adminAuth`, `header`, `next`, `startsWith`, `slice`, `has`, `isValidRule`, `every`, `isValidTier`, `periodWindow`, `split`, `map`, `parseDate`, `trim`, `isNaN`, `getTime`, `escapeHtml`, `replace`, `toFixed`, `renderInvoiceHtml`, `dollars`, `join`, `toISOString`, `toUpperCase`, `adminRouter`, `get`, `getRateCard`, `getTiers`, `put`, `upsertEndpoint`, `delete`, `deleteEndpoint`, `upsertTier`, `deleteTier`, `list`, `randomUUID`, `save`, `find`, `test`, `push`, `listFor`, `filter`, `buildInvoice`, `nextSequence`, `type`, `send`, `untouched`, `flatMap`, `billingRows`
|
||||
`tokens`, `adminLoginRouter`, `post`, `status`, `json`, `findByUsername`, `verifyPassword`, `randomBytes`, `toString`, `set`, `now`, `adminAuth`, `header`, `next`, `startsWith`, `slice`, `has`, `isValidRule`, `every`, `isValidTier`, `periodWindow`, `split`, `map`, `parseDate`, `trim`, `isNaN`, `getTime`, `escapeHtml`, `replace`, `toFixed`, `renderInvoiceHtml`, `dollars`, `join`, `toISOString`, `toUpperCase`, `adminRouter`, `get`, `getRateCard`, `getTiers`, `put`, `upsertEndpoint`, `delete`, `deleteEndpoint`, `upsertTier`, `deleteTier`, `list`, `randomUUID`, `save`, `find`, `isFinite`, `trunc`, `add`, `natsPublish`, `natsAdjust`, `async`, `natsStatement`, `composeStatement`, `listFor`, `type`, `send`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
**Package:** `zappier`
|
||||
**Source:** `packages/zappier/src/app.ts`
|
||||
**Lines:** 257
|
||||
**Lines:** 272
|
||||
|
||||
## What this module is
|
||||
|
||||
|
|
@ -24,6 +24,7 @@ Implementation module in `zappier`. The tables below are extracted from the sour
|
|||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `buildApp` | `deps: AppDeps = {}` | — | `unknown` | see Call graph |
|
||||
| `onUsage` | `e: { customerId: string; endpointId: string; cents: number }` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
|
|
@ -44,10 +45,14 @@ Implementation module in `zappier`. The tables below are extracted from the sour
|
|||
- `./invoicing`
|
||||
- `./paths`
|
||||
- `./portal`
|
||||
- `./upstream`
|
||||
- `./credits`
|
||||
- `./statement`
|
||||
- `./billing-nats`
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`join`, `next`, `parse`, `status`, `json`, `buildApp`, `seeded`, `seedAdminUsersFromEnv`, `rateCard`, `getRateCard`, `tiers`, `getTiers`, `express`, `use`, `load`, `setup`, `adminLoginRouter`, `adminAuth`, `adminRouter`, `static`, `async`, `import`, `toDataURL`, `portalRouter`, `apiKeyAuth`, `middleware`, `get`, `meter`, `post`, `toUpperCase`, `toLowerCase`, `createHash`, `update`, `digest`, `randomUUID`, `toISOString`, `set`, `isFinite`, `map`, `unshift`, `filter`, `setUTCDate`, `setUTCHours`, `summaryFor`, `find`, `applyMonthlyCredit`
|
||||
`join`, `next`, `parse`, `status`, `json`, `buildApp`, `seeded`, `seedAdminUsersFromEnv`, `rateCard`, `getRateCard`, `tiers`, `getTiers`, `natsPublish`, `toISOString`, `express`, `use`, `load`, `setup`, `adminLoginRouter`, `adminAuth`, `adminRouter`, `static`, `async`, `import`, `toDataURL`, `portalRouter`, `get`, `apiKeyAuth`, `middleware`, `meter`, `post`, `toUpperCase`, `proxyVerae`, `toLowerCase`, `createHash`, `update`, `digest`, `randomUUID`, `set`, `isFinite`, `map`, `unshift`, `filter`, `setUTCDate`, `setUTCHours`, `summaryFor`, `find`, `applyMonthlyCredit`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
|
|
|
|||
54
docs/modules/zappier/billing-nats.md
Normal file
54
docs/modules/zappier/billing-nats.md
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
# `zappier/billing-nats`
|
||||
|
||||
**Package:** `zappier`
|
||||
**Source:** `packages/zappier/src/billing-nats.ts`
|
||||
**Lines:** 74
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
`BILLING_SUBJECTS`, `BillingStatement`, `natsStatement`, `natsAdjust`, `natsPublish`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
| Kind | Name |
|
||||
|------|------|
|
||||
| type | `BillingStatement` |
|
||||
| type | `Nc` |
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `nc` | `(none)` | — | `unknown` | see Call graph |
|
||||
| `encode` | `obj: unknown` | — | `unknown` | see Call graph |
|
||||
| `decode` | `buf: Uint8Array` | — | `unknown` | see Call graph |
|
||||
| `natsStatement` | `customerId: string` | — | `unknown` | see Call graph |
|
||||
| `natsAdjust` | `payload: {
|
||||
customerId: string;
|
||||
cents: number;
|
||||
reason: string;
|
||||
agent: string;
|
||||
kind?: string;
|
||||
}` | — | `unknown` | see Call graph |
|
||||
| `natsPublish` | `subject: string, payload: unknown` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
_No imports detected._
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`unset`, `nc`, `async`, `import`, `connect`, `split`, `encode`, `stringify`, `decode`, `parse`, `natsStatement`, `request`, `natsAdjust`, `natsPublish`, `then`, `publish`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
48
docs/modules/zappier/credits.md
Normal file
48
docs/modules/zappier/credits.md
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# `zappier/credits`
|
||||
|
||||
**Package:** `zappier`
|
||||
**Source:** `packages/zappier/src/credits.ts`
|
||||
**Lines:** 30
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
`CreditAdjustment`, `CreditLedger`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
| Kind | Name |
|
||||
|------|------|
|
||||
| interface | `CreditAdjustment` |
|
||||
| class | `CreditLedger` |
|
||||
|
||||
## Functions
|
||||
|
||||
_No top-level functions extracted._
|
||||
|
||||
## Methods (class / object)
|
||||
|
||||
| Name | Parameters |
|
||||
|------|------------|
|
||||
| `add` | `row: Omit<CreditAdjustment, 'id' | 'at'> & { id?: string; at?: string }` |
|
||||
| `list` | `customerId?: string` |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
_No imports detected._
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`add`, `now`, `toString`, `toISOString`, `unshift`, `list`, `filter`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
**Package:** `zappier`
|
||||
**Source:** `packages/zappier/src/meter.ts`
|
||||
**Lines:** 49
|
||||
**Lines:** 52
|
||||
|
||||
## What this module is
|
||||
|
||||
|
|
@ -22,7 +22,8 @@ _None extracted._
|
|||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `meter` | `endpointId: string,
|
||||
repo: UsageRepo,
|
||||
pricing: PricingContext,` | — | `unknown` | see Call graph |
|
||||
pricing: PricingContext,
|
||||
onRecord?: (entry: { customerId: string; endpointId: string; cents: number }` | — | `unknown` | see Call graph |
|
||||
|
||||
## Methods (class / object)
|
||||
|
||||
|
|
|
|||
41
docs/modules/zappier/nats-shim.d.md
Normal file
41
docs/modules/zappier/nats-shim.d.md
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
# `zappier/nats-shim.d`
|
||||
|
||||
**Package:** `zappier`
|
||||
**Source:** `packages/zappier/src/nats-shim.d.ts`
|
||||
**Lines:** 12
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
_No named `export` / `module.exports` keys detected._
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `connect` | `opts: unknown` | — | `unknown` | see Call graph |
|
||||
| `StringCodec` | `(none)` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
_No imports detected._
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`connect`, `request`, `publish`, `close`, `encode`, `decode`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
**Package:** `zappier`
|
||||
**Source:** `packages/zappier/src/portal.ts`
|
||||
**Lines:** 285
|
||||
**Lines:** 321
|
||||
|
||||
## What this module is
|
||||
|
||||
|
|
@ -48,10 +48,13 @@ Implementation module in `zappier`. The tables below are extracted from the sour
|
|||
- `./invoicing`
|
||||
- `./pricing`
|
||||
- `./usage`
|
||||
- `./credits`
|
||||
- `./statement`
|
||||
- `./billing-nats`
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`now`, `reload`, `customer`, `publicProfile`, `sessionAuth`, `header`, `startsWith`, `slice`, `get`, `list`, `find`, `status`, `json`, `next`, `save`, `portalRouter`, `post`, `trim`, `test`, `hashPassword`, `findByEmail`, `randomBytes`, `toString`, `create`, `verifyPassword`, `verifyTotp`, `use`, `delete`, `setUTCDate`, `setUTCHours`, `summaryFor`, `tiers`, `applyMonthlyCredit`, `rateCard`, `type`, `send`, `renderInvoiceHtml`, `async`, `generateTotpSecret`, `totpUri`, `qr`, `isInteger`, `put`
|
||||
`now`, `reload`, `customer`, `publicProfile`, `sessionAuth`, `header`, `startsWith`, `slice`, `get`, `list`, `find`, `status`, `json`, `next`, `save`, `portalRouter`, `post`, `trim`, `test`, `hashPassword`, `findByEmail`, `randomBytes`, `toString`, `create`, `verifyPassword`, `verifyTotp`, `use`, `delete`, `setUTCDate`, `setUTCHours`, `summaryFor`, `tiers`, `applyMonthlyCredit`, `rateCard`, `async`, `natsStatement`, `composeStatement`, `listFor`, `type`, `send`, `renderInvoiceHtml`, `generateTotpSecret`, `totpUri`, `qr`, `isInteger`, `natsPublish`, `natsAdjust`, `put`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
|
|
|
|||
48
docs/modules/zappier/statement.md
Normal file
48
docs/modules/zappier/statement.md
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# `zappier/statement`
|
||||
|
||||
**Package:** `zappier`
|
||||
**Source:** `packages/zappier/src/statement.ts`
|
||||
**Lines:** 39
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
`composeStatement`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `composeStatement` | `args: {
|
||||
customerId: string;
|
||||
prepaidCents: number;
|
||||
credits: CreditAdjustment[];
|
||||
usage: UsageEntry[];
|
||||
invoices: Invoice[];
|
||||
}` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
- `./credits`
|
||||
- `./invoicing`
|
||||
- `./usage`
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`composeStatement`, `filter`, `map`, `now`, `toISOString`, `slice`, `reverse`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
45
docs/modules/zappier/upstream.md
Normal file
45
docs/modules/zappier/upstream.md
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# `zappier/upstream`
|
||||
|
||||
**Package:** `zappier`
|
||||
**Source:** `packages/zappier/src/upstream.ts`
|
||||
**Lines:** 46
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
`UpstreamFetch`, `proxyVerae`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
| Kind | Name |
|
||||
|------|------|
|
||||
| type | `UpstreamFetch` |
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `proxyVerae` | `req: Request,
|
||||
res: Response,
|
||||
pathname: string,
|
||||
fetchImpl: UpstreamFetch = fetch,` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
- `express`
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`proxyVerae`, `replace`, `entries`, `set`, `header`, `toUpperCase`, `stringify`, `fetchImpl`, `toString`, `text`, `parse`, `isArray`, `status`, `json`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
|
|
@ -24,11 +24,16 @@ Markdown indexes: https://zapier.georgelambert.org/index-md.html
|
|||
repos/zapier-user-docs
|
||||
repos/docs-master
|
||||
repos/verae-nats-process
|
||||
repos/zappier-account-balance
|
||||
repos/zappier-customer-service
|
||||
repos/zappier-sales-pricing
|
||||
repos/zappier-accounting-export
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: API modules
|
||||
|
||||
modules/zappier/accounting-export
|
||||
modules/zappier/accounts
|
||||
modules/zappier/admin-users
|
||||
modules/zappier/admin
|
||||
|
|
@ -37,6 +42,8 @@ Markdown indexes: https://zapier.georgelambert.org/index-md.html
|
|||
modules/zappier/billing/credit
|
||||
modules/zappier/billing/reload
|
||||
modules/zappier/billing/stripe
|
||||
modules/zappier/billing-nats
|
||||
modules/zappier/credits
|
||||
modules/zappier/db/admin-user-repo
|
||||
modules/zappier/db/billing-repo
|
||||
modules/zappier/db/customer-repo
|
||||
|
|
@ -48,10 +55,13 @@ Markdown indexes: https://zapier.georgelambert.org/index-md.html
|
|||
modules/zappier/invoicing
|
||||
modules/zappier/jobs/report-usage
|
||||
modules/zappier/meter
|
||||
modules/zappier/nats-shim.d
|
||||
modules/zappier/paths
|
||||
modules/zappier/portal
|
||||
modules/zappier/pricing
|
||||
modules/zappier/reports
|
||||
modules/zappier/statement
|
||||
modules/zappier/upstream
|
||||
modules/zappier/usage
|
||||
modules/verae-zapier-middleware/app
|
||||
modules/verae-zapier-middleware/clients/veraeClient
|
||||
|
|
@ -138,3 +148,12 @@ Markdown indexes: https://zapier.georgelambert.org/index-md.html
|
|||
modules/verae-zapier-simulator/pipeline
|
||||
modules/verae-zapier-simulator/server
|
||||
modules/verae-zapier-simulator/trace
|
||||
modules/zappier-account-balance/books
|
||||
modules/zappier-account-balance/server
|
||||
modules/zappier-account-balance/subjects
|
||||
modules/zappier-customer-service/nats-billing
|
||||
modules/zappier-customer-service/server
|
||||
modules/zappier-sales-pricing/nats-billing
|
||||
modules/zappier-sales-pricing/server
|
||||
modules/zappier-accounting-export/nats-billing
|
||||
modules/zappier-accounting-export/server
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
**Package:** `verae-fleet`
|
||||
**Source:** `packages/verae-fleet/src/supervisor.js`
|
||||
**Lines:** 511
|
||||
**Lines:** 528
|
||||
|
||||
## What this module is
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ Implementation module in `verae-fleet`. The tables below are extracted from the
|
|||
|
||||
## Exports
|
||||
|
||||
`Supervisor`
|
||||
`spawnLocal`, `Supervisor`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
|
|
@ -22,6 +22,7 @@ Implementation module in `verae-fleet`. The tables below are extracted from the
|
|||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `spawnLocal` | `root, spec, env, healthPort` | — | `unknown` | see Call graph |
|
||||
| `waitExit` | `child, ms` | — | `unknown` | see Call graph |
|
||||
| `waitForHealth` | `rec, ms` | — | `unknown` | see Call graph |
|
||||
|
||||
|
|
@ -70,7 +71,7 @@ Implementation module in `verae-fleet`. The tables below are extracted from the
|
|||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`floor`, `join`, `dirname`, `fileURLToPath`, `constructor`, `loadFleet`, `mkdirSync`, `isArray`, `machines`, `addMachine`, `upsertMachine`, `saveOverlay`, `log`, `setMachineEnabled`, `find`, `checkMachine`, `sshCheck`, `httpProbe`, `machineOf`, `controlInstance`, `sshHttp`, `postControl`, `toISOString`, `push`, `splice`, `spec`, `nextIndex`, `values`, `filter`, `map`, `has`, `startOne`, `get`, `pickMachine`, `sshSpawnWorker`, `spawn`, `now`, `on`, `set`, `waitForHealth`, `stopInstance`, `sshKillWorker`, `kill`, `waitExit`, `delete`, `reconcile`, `pauseInstance`, `resumeInstance`, `restartInstance`, `markUnhealthy`, `probe`, `isFinite`, `summarizeRtt`, `available`, `keys`, `min`, `startService`, `stopService`, `pauseService`, `resumeService`
|
||||
`floor`, `join`, `dirname`, `fileURLToPath`, `apps`, `spawnLocal`, `resolve`, `spawn`, `constructor`, `loadFleet`, `mkdirSync`, `isArray`, `machines`, `addMachine`, `upsertMachine`, `saveOverlay`, `log`, `setMachineEnabled`, `find`, `checkMachine`, `sshCheck`, `httpProbe`, `machineOf`, `controlInstance`, `sshHttp`, `postControl`, `toISOString`, `push`, `splice`, `spec`, `nextIndex`, `values`, `filter`, `map`, `has`, `startOne`, `get`, `pickMachine`, `sshSpawnWorker`, `now`, `on`, `set`, `waitForHealth`, `stopInstance`, `sshKillWorker`, `kill`, `waitExit`, `delete`, `reconcile`, `pauseInstance`, `resumeInstance`, `restartInstance`, `markUnhealthy`, `probe`, `isFinite`, `summarizeRtt`, `available`, `keys`, `min`, `startService`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
|
|
|
|||
54
docs/sphinx/modules/zappier-account-balance/books.md
Normal file
54
docs/sphinx/modules/zappier-account-balance/books.md
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
# `zappier-account-balance/books`
|
||||
|
||||
**Package:** `zappier-account-balance`
|
||||
**Source:** `packages/zappier-account-balance/src/books.js`
|
||||
**Lines:** 90
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier-account-balance`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
`AccountBooks`, `handle`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
| Kind | Name |
|
||||
|------|------|
|
||||
| class | `AccountBooks` |
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `handle` | `subject, payload, books` | — | `unknown` | see Call graph |
|
||||
| `match` | `rows` | — | `unknown` | see Call graph |
|
||||
|
||||
## Methods (class / object)
|
||||
|
||||
| Name | Parameters |
|
||||
|------|------------|
|
||||
| `constructor` | `(none)` |
|
||||
| `prepaidCents` | `customerId` |
|
||||
| `adjust` | `{ customerId, cents, reason, agent, kind = 'credit' }` |
|
||||
| `recordUsage` | `entry` |
|
||||
| `recordPayment` | `entry` |
|
||||
| `statement` | `customerId` |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
_No imports detected._
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`constructor`, `prepaidCents`, `adjust`, `trunc`, `now`, `toString`, `random`, `slice`, `toISOString`, `unshift`, `recordUsage`, `recordPayment`, `statement`, `filter`, `match`, `handle`, `endsWith`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
7
docs/sphinx/modules/zappier-account-balance/books.rst
Normal file
7
docs/sphinx/modules/zappier-account-balance/books.rst
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
zappier-account-balance.books
|
||||
=============================
|
||||
|
||||
Generated API sheet for ``zappier-account-balance/books``.
|
||||
|
||||
.. include:: books.md
|
||||
:parser: myst_parser.sphinx_
|
||||
53
docs/sphinx/modules/zappier-account-balance/server.md
Normal file
53
docs/sphinx/modules/zappier-account-balance/server.md
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# `zappier-account-balance/server`
|
||||
|
||||
**Package:** `zappier-account-balance`
|
||||
**Source:** `packages/zappier-account-balance/src/server.js`
|
||||
**Lines:** 93
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier-account-balance`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
_No named `export` / `module.exports` keys detected._
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `startNats` | `(none)` | — | `unknown` | see Call graph |
|
||||
| `readBody` | `req` | — | `unknown` | see Call graph |
|
||||
| `reply` | `sub, fn` | — | `unknown` | see Call graph |
|
||||
| `json` | `code, obj` | — | `unknown` | see Call graph |
|
||||
|
||||
## Methods (class / object)
|
||||
|
||||
| Name | Parameters |
|
||||
|------|------------|
|
||||
| `reply` | `nc.subscribe(SUBJECTS.STATEMENT_GET, { queue: SUBJECTS.QUEUE }` |
|
||||
| `reply` | `nc.subscribe(SUBJECTS.BALANCE_GET, { queue: SUBJECTS.QUEUE }` |
|
||||
| `reply` | `nc.subscribe(SUBJECTS.BALANCE_ADJUST, { queue: SUBJECTS.QUEUE }` |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
- `node:http`
|
||||
- `./books.js`
|
||||
- `./subjects.js`
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`startNats`, `import`, `connect`, `split`, `async`, `parse`, `decode`, `fn`, `respond`, `encode`, `stringify`, `reply`, `subscribe`, `handle`, `write`, `readBody`, `on`, `push`, `resolve`, `concat`, `toString`, `createServer`, `writeHead`, `end`, `json`, `match`, `statement`, `adjust`, `listen`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
7
docs/sphinx/modules/zappier-account-balance/server.rst
Normal file
7
docs/sphinx/modules/zappier-account-balance/server.rst
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
zappier-account-balance.server
|
||||
==============================
|
||||
|
||||
Generated API sheet for ``zappier-account-balance/server``.
|
||||
|
||||
.. include:: server.md
|
||||
:parser: myst_parser.sphinx_
|
||||
36
docs/sphinx/modules/zappier-account-balance/subjects.md
Normal file
36
docs/sphinx/modules/zappier-account-balance/subjects.md
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
# `zappier-account-balance/subjects`
|
||||
|
||||
**Package:** `zappier-account-balance`
|
||||
**Source:** `packages/zappier-account-balance/src/subjects.js`
|
||||
**Lines:** 11
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier-account-balance`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
`SUBJECTS`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
_No top-level functions extracted._
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
_No imports detected._
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
_No local call identifiers extracted._
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
7
docs/sphinx/modules/zappier-account-balance/subjects.rst
Normal file
7
docs/sphinx/modules/zappier-account-balance/subjects.rst
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
zappier-account-balance.subjects
|
||||
================================
|
||||
|
||||
Generated API sheet for ``zappier-account-balance/subjects``.
|
||||
|
||||
.. include:: subjects.md
|
||||
:parser: myst_parser.sphinx_
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
# `zappier-accounting-export/nats-billing`
|
||||
|
||||
**Package:** `zappier-accounting-export`
|
||||
**Source:** `packages/zappier-accounting-export/src/nats-billing.js`
|
||||
**Lines:** 18
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier-accounting-export`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
`SUBJECTS`, `billingRequest`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `billingRequest` | `subject, payload` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
_No imports detected._
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`billingRequest`, `import`, `connect`, `split`, `request`, `encode`, `stringify`, `parse`, `decode`, `close`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
zappier-accounting-export.nats-billing
|
||||
======================================
|
||||
|
||||
Generated API sheet for ``zappier-accounting-export/nats-billing``.
|
||||
|
||||
.. include:: nats-billing.md
|
||||
:parser: myst_parser.sphinx_
|
||||
46
docs/sphinx/modules/zappier-accounting-export/server.md
Normal file
46
docs/sphinx/modules/zappier-accounting-export/server.md
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# `zappier-accounting-export/server`
|
||||
|
||||
**Package:** `zappier-accounting-export`
|
||||
**Source:** `packages/zappier-accounting-export/src/server.js`
|
||||
**Lines:** 62
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier-accounting-export`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
_No named `export` / `module.exports` keys detected._
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `edge` | `pathname` | — | `unknown` | see Call graph |
|
||||
| `send` | `code, type, body` | — | `unknown` | see Call graph |
|
||||
| `json` | `code, obj` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
- `node:fs`
|
||||
- `node:http`
|
||||
- `node:path`
|
||||
- `node:url`
|
||||
- `./nats-billing.js`
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`replace`, `join`, `dirname`, `fileURLToPath`, `edge`, `fetch`, `createServer`, `async`, `writeHead`, `end`, `send`, `stringify`, `readFileSync`, `json`, `match`, `billingRequest`, `text`, `get`, `encodeURIComponent`, `listen`, `write`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
7
docs/sphinx/modules/zappier-accounting-export/server.rst
Normal file
7
docs/sphinx/modules/zappier-accounting-export/server.rst
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
zappier-accounting-export.server
|
||||
================================
|
||||
|
||||
Generated API sheet for ``zappier-accounting-export/server``.
|
||||
|
||||
.. include:: server.md
|
||||
:parser: myst_parser.sphinx_
|
||||
40
docs/sphinx/modules/zappier-customer-service/nats-billing.md
Normal file
40
docs/sphinx/modules/zappier-customer-service/nats-billing.md
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# `zappier-customer-service/nats-billing`
|
||||
|
||||
**Package:** `zappier-customer-service`
|
||||
**Source:** `packages/zappier-customer-service/src/nats-billing.js`
|
||||
**Lines:** 21
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier-customer-service`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
`SUBJECTS`, `billingRequest`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `billingRequest` | `subject, payload` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
_No imports detected._
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`billingRequest`, `import`, `connect`, `split`, `request`, `encode`, `stringify`, `parse`, `decode`, `close`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
zappier-customer-service.nats-billing
|
||||
=====================================
|
||||
|
||||
Generated API sheet for ``zappier-customer-service/nats-billing``.
|
||||
|
||||
.. include:: nats-billing.md
|
||||
:parser: myst_parser.sphinx_
|
||||
45
docs/sphinx/modules/zappier-customer-service/server.md
Normal file
45
docs/sphinx/modules/zappier-customer-service/server.md
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# `zappier-customer-service/server`
|
||||
|
||||
**Package:** `zappier-customer-service`
|
||||
**Source:** `packages/zappier-customer-service/src/server.js`
|
||||
**Lines:** 81
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier-customer-service`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
_No named `export` / `module.exports` keys detected._
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `statement` | `customerId` | — | `unknown` | see Call graph |
|
||||
| `json` | `code, obj` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
- `node:fs`
|
||||
- `node:http`
|
||||
- `node:path`
|
||||
- `node:url`
|
||||
- `./nats-billing.js`
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`join`, `dirname`, `fileURLToPath`, `replace`, `statement`, `billingRequest`, `fetch`, `json`, `createServer`, `async`, `writeHead`, `end`, `stringify`, `readFileSync`, `match`, `push`, `parse`, `concat`, `toString`, `get`, `listen`, `write`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
7
docs/sphinx/modules/zappier-customer-service/server.rst
Normal file
7
docs/sphinx/modules/zappier-customer-service/server.rst
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
zappier-customer-service.server
|
||||
===============================
|
||||
|
||||
Generated API sheet for ``zappier-customer-service/server``.
|
||||
|
||||
.. include:: server.md
|
||||
:parser: myst_parser.sphinx_
|
||||
40
docs/sphinx/modules/zappier-sales-pricing/nats-billing.md
Normal file
40
docs/sphinx/modules/zappier-sales-pricing/nats-billing.md
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# `zappier-sales-pricing/nats-billing`
|
||||
|
||||
**Package:** `zappier-sales-pricing`
|
||||
**Source:** `packages/zappier-sales-pricing/src/nats-billing.js`
|
||||
**Lines:** 18
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier-sales-pricing`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
`SUBJECTS`, `billingRequest`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `billingRequest` | `subject, payload` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
_No imports detected._
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`billingRequest`, `import`, `connect`, `split`, `request`, `encode`, `stringify`, `parse`, `decode`, `close`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
zappier-sales-pricing.nats-billing
|
||||
==================================
|
||||
|
||||
Generated API sheet for ``zappier-sales-pricing/nats-billing``.
|
||||
|
||||
.. include:: nats-billing.md
|
||||
:parser: myst_parser.sphinx_
|
||||
45
docs/sphinx/modules/zappier-sales-pricing/server.md
Normal file
45
docs/sphinx/modules/zappier-sales-pricing/server.md
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# `zappier-sales-pricing/server`
|
||||
|
||||
**Package:** `zappier-sales-pricing`
|
||||
**Source:** `packages/zappier-sales-pricing/src/server.js`
|
||||
**Lines:** 77
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier-sales-pricing`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
_No named `export` / `module.exports` keys detected._
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `edge` | `pathname, { method = 'GET', body } = {}` | — | `unknown` | see Call graph |
|
||||
| `json` | `code, obj` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
- `node:fs`
|
||||
- `node:http`
|
||||
- `node:path`
|
||||
- `node:url`
|
||||
- `./nats-billing.js`
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`join`, `dirname`, `fileURLToPath`, `replace`, `edge`, `fetch`, `stringify`, `text`, `parse`, `createServer`, `async`, `writeHead`, `end`, `readFileSync`, `json`, `match`, `billingRequest`, `push`, `concat`, `toString`, `listen`, `write`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
7
docs/sphinx/modules/zappier-sales-pricing/server.rst
Normal file
7
docs/sphinx/modules/zappier-sales-pricing/server.rst
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
zappier-sales-pricing.server
|
||||
============================
|
||||
|
||||
Generated API sheet for ``zappier-sales-pricing/server``.
|
||||
|
||||
.. include:: server.md
|
||||
:parser: myst_parser.sphinx_
|
||||
43
docs/sphinx/modules/zappier/accounting-export.md
Normal file
43
docs/sphinx/modules/zappier/accounting-export.md
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# `zappier/accounting-export`
|
||||
|
||||
**Package:** `zappier`
|
||||
**Source:** `packages/zappier/src/accounting-export.ts`
|
||||
**Lines:** 37
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
`invoicesToQuickBooksIif`, `invoicesToAccountingCsv`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `iifDate` | `ms: number` | — | `unknown` | see Call graph |
|
||||
| `invoicesToQuickBooksIif` | `invoices: Invoice[]` | — | `unknown` | see Call graph |
|
||||
| | _QuickBooks IIF journal for issued/paid invoices (Accounts Receivable + Sales)._ | | | |
|
||||
| `invoicesToAccountingCsv` | `invoices: Invoice[]` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
- `./invoicing`
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`iifDate`, `getUTCMonth`, `padStart`, `getUTCDate`, `getUTCFullYear`, `invoices`, `invoicesToQuickBooksIif`, `now`, `toFixed`, `push`, `join`, `invoicesToAccountingCsv`, `map`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
7
docs/sphinx/modules/zappier/accounting-export.rst
Normal file
7
docs/sphinx/modules/zappier/accounting-export.rst
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
zappier.accounting-export
|
||||
=========================
|
||||
|
||||
Generated API sheet for ``zappier/accounting-export``.
|
||||
|
||||
.. include:: accounting-export.md
|
||||
:parser: myst_parser.sphinx_
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
**Package:** `zappier`
|
||||
**Source:** `packages/zappier/src/admin.ts`
|
||||
**Lines:** 486
|
||||
**Lines:** 588
|
||||
|
||||
## What this module is
|
||||
|
||||
|
|
@ -32,7 +32,8 @@ Implementation module in `zappier`. The tables below are extracted from the sour
|
|||
| `renderInvoiceHtml` | `invoice: Invoice, customerName: string` | — | `unknown` | see Call graph |
|
||||
| `adminRouter` | `store: PricingStore,
|
||||
customers: CustomerRepo,
|
||||
accounting: AccountingDeps,` | — | `unknown` | see Call graph |
|
||||
accounting: AccountingDeps,
|
||||
credits: CreditLedger = new CreditLedger(` | — | `unknown` | see Call graph |
|
||||
|
||||
## Methods (class / object)
|
||||
|
||||
|
|
@ -58,10 +59,14 @@ Implementation module in `zappier`. The tables below are extracted from the sour
|
|||
- `./paths`
|
||||
- `./reports`
|
||||
- `./usage`
|
||||
- `./credits`
|
||||
- `./accounting-export`
|
||||
- `./statement`
|
||||
- `./billing-nats`
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`tokens`, `adminLoginRouter`, `post`, `status`, `json`, `findByUsername`, `verifyPassword`, `randomBytes`, `toString`, `set`, `now`, `adminAuth`, `header`, `next`, `startsWith`, `slice`, `has`, `isValidRule`, `every`, `isValidTier`, `periodWindow`, `split`, `map`, `parseDate`, `trim`, `isNaN`, `getTime`, `escapeHtml`, `replace`, `toFixed`, `renderInvoiceHtml`, `dollars`, `join`, `toISOString`, `toUpperCase`, `adminRouter`, `get`, `getRateCard`, `getTiers`, `put`, `upsertEndpoint`, `delete`, `deleteEndpoint`, `upsertTier`, `deleteTier`, `list`, `randomUUID`, `save`, `find`, `test`, `push`, `listFor`, `filter`, `buildInvoice`, `nextSequence`, `type`, `send`, `untouched`, `flatMap`, `billingRows`
|
||||
`tokens`, `adminLoginRouter`, `post`, `status`, `json`, `findByUsername`, `verifyPassword`, `randomBytes`, `toString`, `set`, `now`, `adminAuth`, `header`, `next`, `startsWith`, `slice`, `has`, `isValidRule`, `every`, `isValidTier`, `periodWindow`, `split`, `map`, `parseDate`, `trim`, `isNaN`, `getTime`, `escapeHtml`, `replace`, `toFixed`, `renderInvoiceHtml`, `dollars`, `join`, `toISOString`, `toUpperCase`, `adminRouter`, `get`, `getRateCard`, `getTiers`, `put`, `upsertEndpoint`, `delete`, `deleteEndpoint`, `upsertTier`, `deleteTier`, `list`, `randomUUID`, `save`, `find`, `isFinite`, `trunc`, `add`, `natsPublish`, `natsAdjust`, `async`, `natsStatement`, `composeStatement`, `listFor`, `type`, `send`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
**Package:** `zappier`
|
||||
**Source:** `packages/zappier/src/app.ts`
|
||||
**Lines:** 257
|
||||
**Lines:** 272
|
||||
|
||||
## What this module is
|
||||
|
||||
|
|
@ -24,6 +24,7 @@ Implementation module in `zappier`. The tables below are extracted from the sour
|
|||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `buildApp` | `deps: AppDeps = {}` | — | `unknown` | see Call graph |
|
||||
| `onUsage` | `e: { customerId: string; endpointId: string; cents: number }` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
|
|
@ -44,10 +45,14 @@ Implementation module in `zappier`. The tables below are extracted from the sour
|
|||
- `./invoicing`
|
||||
- `./paths`
|
||||
- `./portal`
|
||||
- `./upstream`
|
||||
- `./credits`
|
||||
- `./statement`
|
||||
- `./billing-nats`
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`join`, `next`, `parse`, `status`, `json`, `buildApp`, `seeded`, `seedAdminUsersFromEnv`, `rateCard`, `getRateCard`, `tiers`, `getTiers`, `express`, `use`, `load`, `setup`, `adminLoginRouter`, `adminAuth`, `adminRouter`, `static`, `async`, `import`, `toDataURL`, `portalRouter`, `apiKeyAuth`, `middleware`, `get`, `meter`, `post`, `toUpperCase`, `toLowerCase`, `createHash`, `update`, `digest`, `randomUUID`, `toISOString`, `set`, `isFinite`, `map`, `unshift`, `filter`, `setUTCDate`, `setUTCHours`, `summaryFor`, `find`, `applyMonthlyCredit`
|
||||
`join`, `next`, `parse`, `status`, `json`, `buildApp`, `seeded`, `seedAdminUsersFromEnv`, `rateCard`, `getRateCard`, `tiers`, `getTiers`, `natsPublish`, `toISOString`, `express`, `use`, `load`, `setup`, `adminLoginRouter`, `adminAuth`, `adminRouter`, `static`, `async`, `import`, `toDataURL`, `portalRouter`, `get`, `apiKeyAuth`, `middleware`, `meter`, `post`, `toUpperCase`, `proxyVerae`, `toLowerCase`, `createHash`, `update`, `digest`, `randomUUID`, `set`, `isFinite`, `map`, `unshift`, `filter`, `setUTCDate`, `setUTCHours`, `summaryFor`, `find`, `applyMonthlyCredit`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
|
|
|
|||
54
docs/sphinx/modules/zappier/billing-nats.md
Normal file
54
docs/sphinx/modules/zappier/billing-nats.md
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
# `zappier/billing-nats`
|
||||
|
||||
**Package:** `zappier`
|
||||
**Source:** `packages/zappier/src/billing-nats.ts`
|
||||
**Lines:** 74
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
`BILLING_SUBJECTS`, `BillingStatement`, `natsStatement`, `natsAdjust`, `natsPublish`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
| Kind | Name |
|
||||
|------|------|
|
||||
| type | `BillingStatement` |
|
||||
| type | `Nc` |
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `nc` | `(none)` | — | `unknown` | see Call graph |
|
||||
| `encode` | `obj: unknown` | — | `unknown` | see Call graph |
|
||||
| `decode` | `buf: Uint8Array` | — | `unknown` | see Call graph |
|
||||
| `natsStatement` | `customerId: string` | — | `unknown` | see Call graph |
|
||||
| `natsAdjust` | `payload: {
|
||||
customerId: string;
|
||||
cents: number;
|
||||
reason: string;
|
||||
agent: string;
|
||||
kind?: string;
|
||||
}` | — | `unknown` | see Call graph |
|
||||
| `natsPublish` | `subject: string, payload: unknown` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
_No imports detected._
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`unset`, `nc`, `async`, `import`, `connect`, `split`, `encode`, `stringify`, `decode`, `parse`, `natsStatement`, `request`, `natsAdjust`, `natsPublish`, `then`, `publish`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
7
docs/sphinx/modules/zappier/billing-nats.rst
Normal file
7
docs/sphinx/modules/zappier/billing-nats.rst
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
zappier.billing-nats
|
||||
====================
|
||||
|
||||
Generated API sheet for ``zappier/billing-nats``.
|
||||
|
||||
.. include:: billing-nats.md
|
||||
:parser: myst_parser.sphinx_
|
||||
48
docs/sphinx/modules/zappier/credits.md
Normal file
48
docs/sphinx/modules/zappier/credits.md
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# `zappier/credits`
|
||||
|
||||
**Package:** `zappier`
|
||||
**Source:** `packages/zappier/src/credits.ts`
|
||||
**Lines:** 30
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
`CreditAdjustment`, `CreditLedger`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
| Kind | Name |
|
||||
|------|------|
|
||||
| interface | `CreditAdjustment` |
|
||||
| class | `CreditLedger` |
|
||||
|
||||
## Functions
|
||||
|
||||
_No top-level functions extracted._
|
||||
|
||||
## Methods (class / object)
|
||||
|
||||
| Name | Parameters |
|
||||
|------|------------|
|
||||
| `add` | `row: Omit<CreditAdjustment, 'id' | 'at'> & { id?: string; at?: string }` |
|
||||
| `list` | `customerId?: string` |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
_No imports detected._
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`add`, `now`, `toString`, `toISOString`, `unshift`, `list`, `filter`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
7
docs/sphinx/modules/zappier/credits.rst
Normal file
7
docs/sphinx/modules/zappier/credits.rst
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
zappier.credits
|
||||
===============
|
||||
|
||||
Generated API sheet for ``zappier/credits``.
|
||||
|
||||
.. include:: credits.md
|
||||
:parser: myst_parser.sphinx_
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
**Package:** `zappier`
|
||||
**Source:** `packages/zappier/src/meter.ts`
|
||||
**Lines:** 49
|
||||
**Lines:** 52
|
||||
|
||||
## What this module is
|
||||
|
||||
|
|
@ -22,7 +22,8 @@ _None extracted._
|
|||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `meter` | `endpointId: string,
|
||||
repo: UsageRepo,
|
||||
pricing: PricingContext,` | — | `unknown` | see Call graph |
|
||||
pricing: PricingContext,
|
||||
onRecord?: (entry: { customerId: string; endpointId: string; cents: number }` | — | `unknown` | see Call graph |
|
||||
|
||||
## Methods (class / object)
|
||||
|
||||
|
|
|
|||
41
docs/sphinx/modules/zappier/nats-shim.d.md
Normal file
41
docs/sphinx/modules/zappier/nats-shim.d.md
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
# `zappier/nats-shim.d`
|
||||
|
||||
**Package:** `zappier`
|
||||
**Source:** `packages/zappier/src/nats-shim.d.ts`
|
||||
**Lines:** 12
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
_No named `export` / `module.exports` keys detected._
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `connect` | `opts: unknown` | — | `unknown` | see Call graph |
|
||||
| `StringCodec` | `(none)` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
_No imports detected._
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`connect`, `request`, `publish`, `close`, `encode`, `decode`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
7
docs/sphinx/modules/zappier/nats-shim.d.rst
Normal file
7
docs/sphinx/modules/zappier/nats-shim.d.rst
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
zappier.nats-shim.d
|
||||
===================
|
||||
|
||||
Generated API sheet for ``zappier/nats-shim.d``.
|
||||
|
||||
.. include:: nats-shim.d.md
|
||||
:parser: myst_parser.sphinx_
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
**Package:** `zappier`
|
||||
**Source:** `packages/zappier/src/portal.ts`
|
||||
**Lines:** 285
|
||||
**Lines:** 321
|
||||
|
||||
## What this module is
|
||||
|
||||
|
|
@ -48,10 +48,13 @@ Implementation module in `zappier`. The tables below are extracted from the sour
|
|||
- `./invoicing`
|
||||
- `./pricing`
|
||||
- `./usage`
|
||||
- `./credits`
|
||||
- `./statement`
|
||||
- `./billing-nats`
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`now`, `reload`, `customer`, `publicProfile`, `sessionAuth`, `header`, `startsWith`, `slice`, `get`, `list`, `find`, `status`, `json`, `next`, `save`, `portalRouter`, `post`, `trim`, `test`, `hashPassword`, `findByEmail`, `randomBytes`, `toString`, `create`, `verifyPassword`, `verifyTotp`, `use`, `delete`, `setUTCDate`, `setUTCHours`, `summaryFor`, `tiers`, `applyMonthlyCredit`, `rateCard`, `type`, `send`, `renderInvoiceHtml`, `async`, `generateTotpSecret`, `totpUri`, `qr`, `isInteger`, `put`
|
||||
`now`, `reload`, `customer`, `publicProfile`, `sessionAuth`, `header`, `startsWith`, `slice`, `get`, `list`, `find`, `status`, `json`, `next`, `save`, `portalRouter`, `post`, `trim`, `test`, `hashPassword`, `findByEmail`, `randomBytes`, `toString`, `create`, `verifyPassword`, `verifyTotp`, `use`, `delete`, `setUTCDate`, `setUTCHours`, `summaryFor`, `tiers`, `applyMonthlyCredit`, `rateCard`, `async`, `natsStatement`, `composeStatement`, `listFor`, `type`, `send`, `renderInvoiceHtml`, `generateTotpSecret`, `totpUri`, `qr`, `isInteger`, `natsPublish`, `natsAdjust`, `put`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
|
|
|
|||
48
docs/sphinx/modules/zappier/statement.md
Normal file
48
docs/sphinx/modules/zappier/statement.md
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# `zappier/statement`
|
||||
|
||||
**Package:** `zappier`
|
||||
**Source:** `packages/zappier/src/statement.ts`
|
||||
**Lines:** 39
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
`composeStatement`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
_None extracted._
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `composeStatement` | `args: {
|
||||
customerId: string;
|
||||
prepaidCents: number;
|
||||
credits: CreditAdjustment[];
|
||||
usage: UsageEntry[];
|
||||
invoices: Invoice[];
|
||||
}` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
- `./credits`
|
||||
- `./invoicing`
|
||||
- `./usage`
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`composeStatement`, `filter`, `map`, `now`, `toISOString`, `slice`, `reverse`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
7
docs/sphinx/modules/zappier/statement.rst
Normal file
7
docs/sphinx/modules/zappier/statement.rst
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
zappier.statement
|
||||
=================
|
||||
|
||||
Generated API sheet for ``zappier/statement``.
|
||||
|
||||
.. include:: statement.md
|
||||
:parser: myst_parser.sphinx_
|
||||
45
docs/sphinx/modules/zappier/upstream.md
Normal file
45
docs/sphinx/modules/zappier/upstream.md
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# `zappier/upstream`
|
||||
|
||||
**Package:** `zappier`
|
||||
**Source:** `packages/zappier/src/upstream.ts`
|
||||
**Lines:** 46
|
||||
|
||||
## What this module is
|
||||
|
||||
Implementation module in `zappier`. The tables below are extracted from the source (signatures + JSDoc).
|
||||
|
||||
## Exports
|
||||
|
||||
`UpstreamFetch`, `proxyVerae`
|
||||
|
||||
## Types / interfaces / classes
|
||||
|
||||
| Kind | Name |
|
||||
|------|------|
|
||||
| type | `UpstreamFetch` |
|
||||
|
||||
## Functions
|
||||
|
||||
| Name | Parameters | Param types (JSDoc) | Returns | Calls (same file / helpers) |
|
||||
|------|------------|---------------------|---------|-----------------------------|
|
||||
| `proxyVerae` | `req: Request,
|
||||
res: Response,
|
||||
pathname: string,
|
||||
fetchImpl: UpstreamFetch = fetch,` | — | `unknown` | see Call graph |
|
||||
|
||||
## What it imports / requires
|
||||
|
||||
- `express`
|
||||
|
||||
## Call graph (identifiers invoked)
|
||||
|
||||
`proxyVerae`, `replace`, `entries`, `set`, `header`, `toUpperCase`, `stringify`, `fetchImpl`, `toString`, `text`, `parse`, `isArray`, `status`, `json`
|
||||
|
||||
Each identifier is a call site in this file. Follow the import list to see the defining module; open that module’s MD for parameter and return types.
|
||||
|
||||
## Return values (how to read this)
|
||||
|
||||
- HTTP route handlers return Express `res.json(...)` bodies (see route docs).
|
||||
- Zapier `perform` functions return a **single object** (creates) or an **array** (triggers/searches).
|
||||
- Pricing functions return integer **cents** on `Quote.totalCents`.
|
||||
|
||||
7
docs/sphinx/modules/zappier/upstream.rst
Normal file
7
docs/sphinx/modules/zappier/upstream.rst
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
zappier.upstream
|
||||
================
|
||||
|
||||
Generated API sheet for ``zappier/upstream``.
|
||||
|
||||
.. include:: upstream.md
|
||||
:parser: myst_parser.sphinx_
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
High-level description of the whole system: what it is, which **independent git repositories** implement it, how it stays up, how it behaves when the local network fails, and how it talks to the **central Verae NATS.IO 3-server cluster**. New work is added by **new address routing**, not by teaching Zapier about NATS.
|
||||
|
||||
**This repo:** https://git.georgelambert.org/marchon/overview
|
||||
**Bring online:** https://zapier.georgelambert.org/packages/verae-ops/GETTING-STARTED.pdf
|
||||
**Live catalog (PDF by default):** https://zapier.georgelambert.org/ · [Markdown indexes](https://zapier.georgelambert.org/index-md.html)
|
||||
**Clone:** `ssh://git@git.georgelambert.org:2223/marchon/overview.git`
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ This is the operations repo. Application code lives in the other independent git
|
|||
|
||||
## Reading order
|
||||
|
||||
0. **[GETTING-STARTED.md](GETTING-STARTED.md)** — install, first-up, monitor (read this first)
|
||||
1. [01-dependencies.md](01-dependencies.md) — what must exist, who talks to whom
|
||||
2. [02-docker.md](02-docker.md) — Compose (NATS 3-node cluster + HTTPS edges)
|
||||
3. [03-proxmox.md](03-proxmox.md) — LXC / QEMU VMs
|
||||
|
|
|
|||
31
docs/sphinx/repos/zappier-account-balance.md
Normal file
31
docs/sphinx/repos/zappier-account-balance.md
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# zappier-account-balance
|
||||
|
||||
Source of truth for **customer prepaid balances**. Internal traffic is **NATS request-reply**; HTTP is health plus a fallback.
|
||||
|
||||
**Forgejo:** https://git.georgelambert.org/marchon/zappier-account-balance
|
||||
**Catalog:** https://zapier.georgelambert.org/packages/zappier-account-balance/README.pdf
|
||||
|
||||
Zapier cloud never connects here. zappier-edge, customer-service, sales-pricing, and accounting-export do.
|
||||
|
||||
## Subjects
|
||||
|
||||
| Subject | Kind | Who |
|
||||
|---------|------|-----|
|
||||
| `verae.billing.statement.get` | request-reply | portal, CS, sales, admin |
|
||||
| `verae.billing.balance.get` | request-reply | anyone internal |
|
||||
| `verae.billing.balance.adjust` | request-reply | CS credits, portal reload |
|
||||
| `verae.billing.usage.recorded` | pub | zappier-edge meter |
|
||||
| `verae.billing.payment.recorded` | pub | portal reload, invoice paid |
|
||||
| `verae.billing.credit.applied` | pub | CS |
|
||||
|
||||
Queue group: `account-balance`.
|
||||
|
||||
## Run
|
||||
|
||||
```bash
|
||||
NATS_URL=nats://127.0.0.1:4222 PORT=3010 npm start
|
||||
curl http://127.0.0.1:3010/health
|
||||
curl http://127.0.0.1:3010/statement/cust_1
|
||||
```
|
||||
|
||||
Statement JSON: `{ customerId, prepaidCents, credits[], usage[], payments[] }`.
|
||||
21
docs/sphinx/repos/zappier-accounting-export.md
Normal file
21
docs/sphinx/repos/zappier-accounting-export.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# zappier-accounting-export
|
||||
|
||||
Accounting-department export of **invoices, billing, and payment history** to **QuickBooks IIF** and generic CSV (also usable in other ledgers).
|
||||
|
||||
**Forgejo:** https://git.georgelambert.org/marchon/zappier-accounting-export
|
||||
**Catalog:** https://zapier.georgelambert.org/packages/zappier-accounting-export/README.pdf
|
||||
|
||||
Reads issued/paid invoices from zappier-edge (`ZAPPIER_ADMIN_URL`). Customer statements (credits, balances, usage, payments) come from NATS `verae.billing.statement.get`.
|
||||
|
||||
Staff UI: http://127.0.0.1:3013/
|
||||
|
||||
```bash
|
||||
PORT=3013 NATS_URL=nats://127.0.0.1:4222 node src/server.js
|
||||
curl http://127.0.0.1:3013/review/cust_1
|
||||
curl 'http://127.0.0.1:3013/export/quickbooks.iif?period=2026-07' -o zappier.iif
|
||||
curl 'http://127.0.0.1:3013/export/accounting.csv?period=2026-07' -o zappier.csv
|
||||
```
|
||||
|
||||
Import the IIF in QuickBooks Desktop: **File → Utilities → Import → IIF**. The CSV is a flat invoice register for other systems.
|
||||
|
||||
History is the invoice list on zappier-edge (draft / issued / paid) plus CS credit ledger and portal prepaid reloads.
|
||||
23
docs/sphinx/repos/zappier-customer-service.md
Normal file
23
docs/sphinx/repos/zappier-customer-service.md
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# zappier-customer-service
|
||||
|
||||
Department API for **customer-service credit additions** and **review** of credits, balances, usage, and payments. Internally uses **NATS** `verae.billing.*` (account-balance). HTTP fallback to account-balance then zappier-edge.
|
||||
|
||||
**Forgejo:** https://git.georgelambert.org/marchon/zappier-customer-service
|
||||
**Catalog:** https://zapier.georgelambert.org/packages/zappier-customer-service/README.pdf
|
||||
**Plugs into:** zappier-edge admin (`x-admin-key`) at `ZAPPIER_ADMIN_URL` (default `http://127.0.0.1:3000`).
|
||||
|
||||
```bash
|
||||
PORT=3011 ZAPPIER_ADMIN_URL=http://127.0.0.1:3000 node src/server.js
|
||||
curl -X POST http://127.0.0.1:3011/credits -H 'content-type: application/json' \
|
||||
-d '{"customerId":"cust_1","cents":500,"reason":"goodwill","agent":"cs-anna"}'
|
||||
```
|
||||
|
||||
| Route | Job |
|
||||
|-------|-----|
|
||||
| `GET /` | Staff review UI |
|
||||
| `GET /health` | `{ ok, role }` |
|
||||
| `POST /credits` | Add/subtract prepaid cents (NATS `balance.adjust`) |
|
||||
| `GET /credits?customerId=` | Ledger |
|
||||
| `GET /review/:customerId` | Full statement (balance, credits, usage, payments) |
|
||||
|
||||
Talks to NATS `verae.billing.*` internally. Never talks to Zapier cloud.
|
||||
19
docs/sphinx/repos/zappier-sales-pricing.md
Normal file
19
docs/sphinx/repos/zappier-sales-pricing.md
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# zappier-sales-pricing
|
||||
|
||||
Sales-department API for **per-customer pricing** (tier + `multiplierOverride`). zappier-edge remains the rate-card store.
|
||||
|
||||
**Forgejo:** https://git.georgelambert.org/marchon/zappier-sales-pricing
|
||||
**Catalog:** https://zapier.georgelambert.org/packages/zappier-sales-pricing/README.pdf
|
||||
|
||||
Internal reviews use NATS `verae.billing.statement.get` (account-balance).
|
||||
|
||||
Staff UI: http://127.0.0.1:3012/ — review credits, balances, usage, payments.
|
||||
|
||||
```bash
|
||||
PORT=3012 NATS_URL=nats://127.0.0.1:4222 node src/server.js
|
||||
curl http://127.0.0.1:3012/review/cust_2
|
||||
curl http://127.0.0.1:3012/quotes/cust_2
|
||||
curl -X PUT http://127.0.0.1:3012/customers/cust_2/pricing \
|
||||
-H 'content-type: application/json' \
|
||||
-d '{"multiplierOverride":0.4,"tierId":"business"}'
|
||||
```
|
||||
|
|
@ -5,8 +5,11 @@ monthly credits, a usage ledger, Stripe metered billing, purchase-order
|
|||
invoicing, a company admin console, a self-service customer portal, and a
|
||||
Zapier integration.
|
||||
|
||||
This is the **billing and user platform** (originally the standalone `zappier` git tree at `~/zappier`). Forgejo name: **zappier-edge**. It owns signup, TOTP, API keys, rate card, Stripe meter, PO invoices, admin users, and the customer portal. Verae middleware does not replace this.
|
||||
|
||||
**Forgejo:** https://git.georgelambert.org/marchon/zappier-edge
|
||||
**Catalog README:** https://zapier.georgelambert.org/packages/zappier/README.pdf
|
||||
**Catalog README:** https://zapier.georgelambert.org/packages/zappier/README.pdf
|
||||
**Bring the whole system online:** https://zapier.georgelambert.org/packages/verae-ops/GETTING-STARTED.pdf
|
||||
|
||||
## Documentation (public PDFs)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,14 +2,19 @@
|
|||
|
||||
Master map of every service in the Zapier ↔ middleware ↔ chain ↔ WORM-archive path.
|
||||
|
||||
Zapier cloud **never** connects to NATS. Only middleware workers and archives do.
|
||||
Zapier cloud **never** connects to NATS. Internal services do: middleware workers, archives, account-balance, zappier-edge billing, CS, sales, and accounting.
|
||||
|
||||
## Who talks to whom (HTTPS vs NATS)
|
||||
|
||||
```text
|
||||
[Zapier Platform app] HTTPS [zappier-edge] HTTPS [middleware-http]
|
||||
|
|
||||
NATS JetStream (NS1 loopback :4222) |
|
||||
| | NATS verae.billing.* |
|
||||
| v |
|
||||
[customer portal] [account-balance] NATS JetStream
|
||||
[CS :3011] queue account-balance (NS1 loopback :4222)
|
||||
[sales :3012] ^ |
|
||||
[accounting :3013] | request-reply |
|
||||
+-------------------------------+
|
||||
+------------------+------------------+-------------+
|
||||
| | |
|
||||
[job-poller] [webhook-deliver] [archive-aggregator]
|
||||
|
|
@ -25,7 +30,11 @@ Zapier cloud **never** connects to NATS. Only middleware workers and archives do
|
|||
| Module | Repo (Forgejo) | Runtime | Listens | Sends |
|
||||
|--------|----------------|---------|---------|-------|
|
||||
| zapier-platform-app | `verae-zapier-app` | Zapier cloud | User Zap steps | HTTPS to zappier-edge |
|
||||
| zappier-edge | `zappier-edge` | Public HTTPS :3000 | Zapier, portal, admin | HTTPS to middleware |
|
||||
| zappier-edge | `zappier-edge` | Public HTTPS :3000 | Zapier, portal, admin | HTTPS to middleware; NATS billing pub |
|
||||
| account-balance | `zappier-account-balance` | :3010 + NATS | `verae.billing.*` | statement/adjust replies |
|
||||
| customer-service | `zappier-customer-service` | :3011 | CS staff HTTP | NATS balance.adjust / statement.get |
|
||||
| sales-pricing | `zappier-sales-pricing` | :3012 | Sales HTTP | NATS statement.get; HTTPS to edge for multipliers |
|
||||
| accounting-export | `zappier-accounting-export` | :3013 | Accounting HTTP | reads invoices; NATS statement |
|
||||
| middleware-http | `verae-middleware` | Public HTTPS :3100 | zappier-edge | NATS jobs.watch; HTTP to chain; wait on jobs.events |
|
||||
| job-poller | `verae-job-poller` | Worker | `verae.zapier.jobs.watch` | `verae.zapier.jobs.events`; HTTP GET chain status |
|
||||
| webhook-deliver | `verae-webhook-deliver` | Worker | `verae.zapier.webhooks.deliver` + events | HTTPS POST Zapier REST Hook |
|
||||
|
|
@ -49,6 +58,11 @@ Zapier cloud **never** connects to NATS. Only middleware workers and archives do
|
|||
| `verae.zapier.jobs.events` | JetStream events | `event` (`timestamp.completed\|failed\|timeout`), `tenantId`, `jobId`, `status`, `traceId`, `emittedAt` |
|
||||
| `verae.zapier.webhooks.deliver` | JetStream work queue | `hookId`, `tenantId`, `targetUrl`, `event`, `payload`, `attempt`, `traceId` |
|
||||
| `verae.zapier.usage` | optional | `tenantId`, `action`, `amount`, `at` |
|
||||
| `verae.billing.statement.get` | request-reply | `customerId` → prepaid, credits, usage, payments |
|
||||
| `verae.billing.balance.adjust` | request-reply | `customerId`, `cents`, `reason`, `agent` |
|
||||
| `verae.billing.usage.recorded` | pub | meter events from zappier-edge |
|
||||
| `verae.billing.payment.recorded` | pub | portal reload / invoice paid |
|
||||
| `verae.billing.credit.applied` | pub | CS goodwill |
|
||||
| `verae.archive.put` | JetStream | `sha256`, `tenantId`, `kind` (`publicMeta\|privateMeta\|file\|tree`), `record`, `traceId` |
|
||||
| `verae.archive.query` | pub to **all** archives | `correlationId`, `sha256`, `tenantId`, `kinds[]`, `traceId` |
|
||||
| `verae.archive.reply.<correlationId>` | replies | `archiveId`, `sha256`, `records[]`, `traceId` |
|
||||
|
|
|
|||
12
packages/docs-master/modules/zappier-account-balance/NATS.md
Normal file
12
packages/docs-master/modules/zappier-account-balance/NATS.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# NATS — zappier-account-balance
|
||||
|
||||
Queue group `account-balance`. This process is the source of truth for prepaid cents.
|
||||
|
||||
| Direction | Address | Kind | Body |
|
||||
|-----------|---------|------|------|
|
||||
| IN | `verae.billing.statement.get` | request-reply | `{ customerId }` → statement |
|
||||
| IN | `verae.billing.balance.get` | request-reply | `{ customerId }` → statement |
|
||||
| IN | `verae.billing.balance.adjust` | request-reply | `{ customerId, cents, reason, agent, kind }` |
|
||||
| IN | `verae.billing.usage.recorded` | pub | `{ customerId, endpointId, cents, at }` (debits prepaid) |
|
||||
|
||||
`payment.recorded` and `credit.applied` are fan-out events from publishers; prepaid mutations go through `balance.adjust`.
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# zappier-account-balance
|
||||
|
||||
NATS source of truth for prepaid balances, credits, usage events, and payments.
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
# zappier-accounting-export NATS
|
||||
# NATS — zappier-accounting-export
|
||||
|
||||
None.
|
||||
| Direction | Address | Kind |
|
||||
|-----------|---------|------|
|
||||
| OUT | `verae.billing.statement.get` | request-reply (review) |
|
||||
|
||||
IIF/CSV export remains HTTPS to zappier-edge admin.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# zappier-accounting-export
|
||||
|
||||
Exports zappier invoices to QuickBooks IIF and accounting CSV.
|
||||
Accounting export of invoices to QuickBooks IIF and CSV, plus **review** of customer credits, balances, usage, and payments over NATS.
|
||||
|
||||
Forgejo: https://git.georgelambert.org/marchon/zappier-accounting-export
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
# zappier-customer-service NATS
|
||||
# NATS — zappier-customer-service
|
||||
|
||||
None. HTTPS only to zappier-edge admin.
|
||||
| Direction | Address | Kind |
|
||||
|-----------|---------|------|
|
||||
| OUT | `verae.billing.statement.get` | request-reply (review) |
|
||||
| OUT | `verae.billing.balance.adjust` | request-reply (credits) |
|
||||
|
||||
HTTP fallback: `ACCOUNT_BALANCE_URL` then zappier-edge admin. Zapier cloud never connects here.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
# zappier-customer-service
|
||||
|
||||
CS department API for prepaid credit additions. Writes `balanceCents` on zappier-edge.
|
||||
CS department API and UI for prepaid credit additions and **review** of credits, balances, usage, and payments.
|
||||
|
||||
Internal path: NATS `verae.billing.statement.get` / `verae.billing.balance.adjust` → account-balance. HTTP fallback to `:3010` then zappier-edge admin.
|
||||
|
||||
Forgejo: https://git.georgelambert.org/marchon/zappier-customer-service
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
# zappier-sales-pricing NATS
|
||||
# NATS — zappier-sales-pricing
|
||||
|
||||
None.
|
||||
| Direction | Address | Kind |
|
||||
|-----------|---------|------|
|
||||
| OUT | `verae.billing.statement.get` | request-reply (review) |
|
||||
|
||||
Pricing writes remain HTTPS to zappier-edge admin.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# zappier-sales-pricing
|
||||
|
||||
Sales department per-customer tier and multiplier. Writes through zappier-edge `/admin/api/customers`.
|
||||
Sales department API and UI for per-customer tier/multiplier and **review** of the same NATS statement as CS and the customer portal.
|
||||
|
||||
Forgejo: https://git.georgelambert.org/marchon/zappier-sales-pricing
|
||||
|
|
|
|||
|
|
@ -1,10 +1,15 @@
|
|||
# NATS — zappier-edge
|
||||
|
||||
This process **does not subscribe or publish** on NATS.
|
||||
Zapier cloud still never connects to NATS. The edge process **does** publish and request on the private billing bus.
|
||||
|
||||
| Direction | Address | Peer | Body |
|
||||
|-----------|---------|------|------|
|
||||
| IN HTTPS | `/v1/*` | Zapier Platform app | JSON + `x-api-key` |
|
||||
| OUT HTTPS | middleware `/zapier/v1/*` | verae-middleware | same tenant request |
|
||||
| OUT NATS | `verae.billing.usage.recorded` | account-balance | meter event |
|
||||
| OUT NATS | `verae.billing.payment.recorded` | account-balance / others | portal reload |
|
||||
| OUT NATS | `verae.billing.credit.applied` | account-balance / others | admin/CS credit |
|
||||
| OUT NATS | `verae.billing.statement.get` | account-balance | portal/admin review |
|
||||
| OUT NATS | `verae.billing.balance.adjust` | account-balance | prepaid mutation |
|
||||
|
||||
NATS is private to middleware workers and archives.
|
||||
Jobs, archive, and webhooks stay on middleware workers.
|
||||
|
|
|
|||
|
|
@ -11,8 +11,9 @@ Verae Time proves a SHA-256 existed at a given time. Zapier lets customers regis
|
|||
| Plane | What | Network |
|
||||
|-------|------|---------|
|
||||
| Zapier cloud | `verae-zapier-app`, `verae-activate` | HTTPS to zappier-edge |
|
||||
| Commercial edge | `zappier-edge` portal, admin, `x-api-key`, Stripe meter | Public HTTPS |
|
||||
| CS / sales / accounting | `zappier-customer-service`, `zappier-sales-pricing`, `zappier-accounting-export` | Loopback/private HTTP into zappier-edge admin |
|
||||
| Commercial edge | `zappier-edge` portal, admin, `x-api-key`, Stripe meter | Public HTTPS; NATS billing pubs/requests |
|
||||
| Account balance | `zappier-account-balance` prepaid SoT | NATS `verae.billing.*` + HTTP `:3010` |
|
||||
| CS / sales / accounting | `zappier-customer-service`, `zappier-sales-pricing`, `zappier-accounting-export` | Private HTTP; NATS statement/adjust |
|
||||
| Middleware HTTP | `/zapier/v1/*` job id + wait | Public HTTPS from edge only |
|
||||
| NATS cluster | JetStream subjects under `verae.*` | Private; loopback or SSH tunnel |
|
||||
| Workers | poller, webhook-deliver, aggregator | NATS + HTTPS to chain or Zapier hooks |
|
||||
|
|
@ -22,6 +23,6 @@ Verae Time proves a SHA-256 existed at a given time. Zapier lets customers regis
|
|||
|
||||
## Request in one sentence
|
||||
|
||||
A Zap step POSTs to zappier-edge (`x-api-key`); edge meters the call and, when `ZAPPIER_UPSTREAM` is set, forwards timestamp/receipt/hash to middleware `/zapier/v1`. Middleware splits hash vs files, writes the hash (or Merkle root) to the chain, publishes `verae.zapier.jobs.watch`, and either returns `jobId` or waits on `verae.zapier.jobs.events`. Customer-service credits, sales per-customer multipliers, invoices, payment history, and QuickBooks export sit on zappier-edge (department APIs on :3011–:3013). Attached metadata and bulk-summary **leaves** are found later by broadcasting `verae.archive.query` to every archive/tree node.
|
||||
A Zap step POSTs to zappier-edge (`x-api-key`); edge meters the call and, when `ZAPPIER_UPSTREAM` is set, forwards timestamp/receipt/hash to middleware `/zapier/v1`. Middleware splits hash vs files, writes the hash (or Merkle root) to the chain, publishes `verae.zapier.jobs.watch`, and either returns `jobId` or waits on `verae.zapier.jobs.events`. Meter events, CS credits, and portal reloads go over NATS `verae.billing.*` to **account-balance** (source of truth). Customers review the same statement in the portal; CS (`:3011`) and sales (`:3012`) review it on their department UIs. Attached metadata and bulk-summary **leaves** are found later by broadcasting `verae.archive.query` to every archive/tree node.
|
||||
|
||||
See [diagrams](08-diagrams.md).
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ Each runtime piece is its **own git repo** on Forgejo (`git.georgelambert.org`,
|
|||
| **verae-nats-process** | `packages/verae-nats-process` | **Template** for a new addressed NATS process |
|
||||
| **master-zapier-plan-draft** | workspace root | Combined snapshot (`main` and `master`) |
|
||||
| **zappier-edge** | `packages/zappier` | Metered HTTPS, portal, admin, Stripe; **proxies Verae calls to middleware** |
|
||||
| **zappier-account-balance** | `packages/zappier-account-balance` | NATS source of truth for prepaid balances |
|
||||
| **zappier-customer-service** | `packages/zappier-customer-service` | CS goodwill credits onto prepaid balances |
|
||||
| **zappier-sales-pricing** | `packages/zappier-sales-pricing` | Sales per-customer tier / multiplier |
|
||||
| **zappier-accounting-export** | `packages/zappier-accounting-export` | QuickBooks IIF + accounting CSV |
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ All durable messaging for this product is **NATS JetStream**, not Zapier queues
|
|||
|
||||
## Cluster
|
||||
|
||||
Three `nats-server -js` nodes form the Verae cluster (routes between them, JetStream replication). Clients (middleware, poller, aggregator, WORM, tree nodes, and any new process cloned from `verae-nats-process`) connect with a **cluster URL list**, for example:
|
||||
Three `nats-server -js` nodes form the Verae cluster (routes between them, JetStream replication). Clients (middleware, poller, aggregator, WORM, tree nodes, account-balance, zappier-edge billing, CS/sales/accounting, and any new process cloned from `verae-nats-process`) connect with a **cluster URL list**, for example:
|
||||
|
||||
```text
|
||||
nats://127.0.0.1:4222,nats://127.0.0.1:4223,nats://127.0.0.1:4224
|
||||
|
|
@ -20,7 +20,7 @@ Today’s NS1 box (`NS1.GEORGELAMBERT.ORG`, `70.88.205.138`) already runs JetStr
|
|||
|
||||
| Allowed | Forbidden |
|
||||
|---------|-----------|
|
||||
| verae-middleware, fleet workers, WORM, tree nodes, `verae-nats-process` clones | Zapier cloud, browsers, zappier-edge |
|
||||
| verae-middleware, fleet workers, WORM, tree nodes, account-balance, zappier-edge billing, CS/sales/accounting, `verae-nats-process` clones | Zapier cloud, customer browsers (they use HTTPS portal/CS/sales UIs) |
|
||||
|
||||
## Address families already in use
|
||||
|
||||
|
|
@ -30,6 +30,9 @@ Today’s NS1 box (`NS1.GEORGELAMBERT.ORG`, `70.88.205.138`) already runs JetStr
|
|||
| `verae.zapier.jobs.events` | events | wait + webhooks |
|
||||
| `verae.zapier.webhooks.deliver` | work queue | HTTPS to Zapier REST Hook |
|
||||
| `verae.zapier.usage` | optional | metering |
|
||||
| `verae.billing.statement.get` | request-reply | portal, CS, sales, admin |
|
||||
| `verae.billing.balance.adjust` | request-reply | CS credits, portal reload |
|
||||
| `verae.billing.usage.recorded` | pub | zappier-edge meter |
|
||||
| `verae.archive.put` | JetStream | splitter / merkle builder |
|
||||
| `verae.archive.query` | **broadcast** (no queue group) | every WORM and tree node |
|
||||
| `verae.archive.reply.<correlationId>` | replies | **only on bloom hit** |
|
||||
|
|
|
|||
|
|
@ -9,12 +9,15 @@ SVG files in [`diagrams/`](diagrams/). The same shapes are repeated below in mer
|
|||
```mermaid
|
||||
flowchart LR
|
||||
Z[Zapier cloud apps] -->|HTTPS x-api-key| E[zappier-edge]
|
||||
CS[customer-service] --> E
|
||||
SA[sales-pricing] --> E
|
||||
AC[accounting-export QuickBooks] --> E
|
||||
Cust[customer portal] -->|HTTPS statement| E
|
||||
CS[customer-service] -->|NATS statement/adjust| N[NATS 3-node cluster]
|
||||
SA[sales-pricing] -->|NATS statement| N
|
||||
AC[accounting-export] -->|NATS statement| N
|
||||
E -->|NATS billing| N
|
||||
BAL[account-balance] -->|reply verae.billing.*| N
|
||||
E -->|HTTPS metered| M[verae-middleware]
|
||||
M -->|HTTPS| C[Verae chain]
|
||||
M -->|JetStream| N[NATS 3-node cluster]
|
||||
M -->|JetStream| N
|
||||
N --> P[job-poller]
|
||||
N --> W[webhook-deliver]
|
||||
N --> A[archive-aggregator]
|
||||
|
|
|
|||
|
|
@ -15,9 +15,10 @@
|
|||
"services": {
|
||||
"nats": { "min": 1, "max": 1, "keepFloor": false, "enabled": true, "managed": false },
|
||||
"zappier-edge": { "min": 1, "max": 1, "keepFloor": true, "enabled": true },
|
||||
"customer-service": { "min": 0, "max": 1, "keepFloor": false, "enabled": true },
|
||||
"sales-pricing": { "min": 0, "max": 1, "keepFloor": false, "enabled": true },
|
||||
"accounting-export": { "min": 0, "max": 1, "keepFloor": false, "enabled": true },
|
||||
"account-balance": { "min": 1, "max": 1, "keepFloor": true, "enabled": true },
|
||||
"customer-service": { "min": 1, "max": 1, "keepFloor": true, "enabled": true },
|
||||
"sales-pricing": { "min": 1, "max": 1, "keepFloor": true, "enabled": true },
|
||||
"accounting-export": { "min": 1, "max": 1, "keepFloor": true, "enabled": true },
|
||||
"middleware-http": { "min": 1, "max": 1, "keepFloor": true, "enabled": true },
|
||||
"job-poller": { "min": 1, "max": 2, "keepFloor": true, "enabled": true },
|
||||
"webhook-deliver": { "min": 1, "max": 2, "keepFloor": true, "enabled": true },
|
||||
|
|
|
|||
31
packages/verae-fleet/services/account-balance.json
Normal file
31
packages/verae-fleet/services/account-balance.json
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"id": "account-balance",
|
||||
"title": "Account balance (NATS billing SoT)",
|
||||
"kind": "http",
|
||||
"package": "zappier-account-balance",
|
||||
"role": "account-balance",
|
||||
"managed": true,
|
||||
"runtime": "HTTP :3010 + NATS verae.billing.*",
|
||||
"health": { "type": "http", "path": "/health", "timeoutMs": 2000 },
|
||||
"ports": { "healthBase": 3010 },
|
||||
"spawn": {
|
||||
"cwd": "../zappier-account-balance",
|
||||
"command": "node",
|
||||
"args": ["src/server.js"]
|
||||
},
|
||||
"env": {
|
||||
"PORT": "3010",
|
||||
"NATS_URL": "nats://127.0.0.1:4222"
|
||||
},
|
||||
"nats": {
|
||||
"in": [
|
||||
"verae.billing.statement.get",
|
||||
"verae.billing.balance.get",
|
||||
"verae.billing.balance.adjust",
|
||||
"verae.billing.usage.recorded",
|
||||
"verae.billing.payment.recorded",
|
||||
"verae.billing.credit.applied"
|
||||
],
|
||||
"out": []
|
||||
}
|
||||
}
|
||||
|
|
@ -15,7 +15,9 @@
|
|||
},
|
||||
"env": {
|
||||
"PORT": "3013",
|
||||
"ZAPPIER_ADMIN_URL": "http://127.0.0.1:3000"
|
||||
"ZAPPIER_ADMIN_URL": "http://127.0.0.1:3000",
|
||||
"ACCOUNT_BALANCE_URL": "http://127.0.0.1:3010",
|
||||
"NATS_URL": "nats://127.0.0.1:4222"
|
||||
},
|
||||
"nats": { "in": [], "out": [] }
|
||||
"nats": { "in": [], "out": ["verae.billing.statement.get"] }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"id": "customer-service",
|
||||
"title": "Customer-service credits",
|
||||
"title": "Customer-service credits and review",
|
||||
"kind": "http",
|
||||
"package": "zappier-customer-service",
|
||||
"role": "customer-service",
|
||||
"managed": true,
|
||||
"runtime": "HTTP :3011 CS credits → zappier-edge",
|
||||
"runtime": "HTTP :3011 CS credits + NATS statement review",
|
||||
"health": { "type": "http", "path": "/health", "timeoutMs": 2000 },
|
||||
"ports": { "healthBase": 3011 },
|
||||
"spawn": {
|
||||
|
|
@ -15,8 +15,13 @@
|
|||
},
|
||||
"env": {
|
||||
"PORT": "3011",
|
||||
"ZAPPIER_ADMIN_URL": "http://127.0.0.1:3000"
|
||||
"ZAPPIER_ADMIN_URL": "http://127.0.0.1:3000",
|
||||
"ACCOUNT_BALANCE_URL": "http://127.0.0.1:3010",
|
||||
"NATS_URL": "nats://127.0.0.1:4222"
|
||||
},
|
||||
"nats": { "in": [], "out": [] },
|
||||
"notes": "Department API. Prepaid balances live on zappier-edge."
|
||||
"nats": {
|
||||
"in": [],
|
||||
"out": ["verae.billing.statement.get", "verae.billing.balance.adjust"]
|
||||
},
|
||||
"notes": "CS review and credits. Balances live on account-balance over NATS."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
"package": "zappier-sales-pricing",
|
||||
"role": "sales-pricing",
|
||||
"managed": true,
|
||||
"runtime": "HTTP :3012 quotes → zappier-edge",
|
||||
"runtime": "HTTP :3012 quotes + NATS statement review",
|
||||
"health": { "type": "http", "path": "/health", "timeoutMs": 2000 },
|
||||
"ports": { "healthBase": 3012 },
|
||||
"spawn": {
|
||||
|
|
@ -15,7 +15,9 @@
|
|||
},
|
||||
"env": {
|
||||
"PORT": "3012",
|
||||
"ZAPPIER_ADMIN_URL": "http://127.0.0.1:3000"
|
||||
"ZAPPIER_ADMIN_URL": "http://127.0.0.1:3000",
|
||||
"ACCOUNT_BALANCE_URL": "http://127.0.0.1:3010",
|
||||
"NATS_URL": "nats://127.0.0.1:4222"
|
||||
},
|
||||
"nats": { "in": [], "out": [] }
|
||||
"nats": { "in": [], "out": ["verae.billing.statement.get"] }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,18 @@
|
|||
"ZAPPIER_UPSTREAM": "http://127.0.0.1:3100",
|
||||
"CS_SERVICE_URL": "http://127.0.0.1:3011",
|
||||
"SALES_PRICING_URL": "http://127.0.0.1:3012",
|
||||
"ACCOUNTING_EXPORT_URL": "http://127.0.0.1:3013"
|
||||
"ACCOUNTING_EXPORT_URL": "http://127.0.0.1:3013",
|
||||
"NATS_URL": "nats://127.0.0.1:4222"
|
||||
},
|
||||
"nats": { "in": [], "out": [] },
|
||||
"notes": "Zapier x-api-key lands here. HTTPS to middleware only."
|
||||
"nats": {
|
||||
"in": [],
|
||||
"out": [
|
||||
"verae.billing.usage.recorded",
|
||||
"verae.billing.payment.recorded",
|
||||
"verae.billing.credit.applied",
|
||||
"verae.billing.statement.get",
|
||||
"verae.billing.balance.adjust"
|
||||
]
|
||||
},
|
||||
"notes": "Zapier x-api-key lands here. HTTPS to middleware. NATS billing to account-balance."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ describe('verae-fleet', () => {
|
|||
for (const need of [
|
||||
'nats',
|
||||
'zappier-edge',
|
||||
'account-balance',
|
||||
'customer-service',
|
||||
'sales-pricing',
|
||||
'accounting-export',
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ This is the **top document** for install, first-up, and monitoring. Platform-spe
|
|||
| Piece | Job | Default |
|
||||
|-------|-----|---------|
|
||||
| **zappier-edge** | Billing, API keys, customer portal, admin, Stripe; meters then **proxies** to middleware | `:3000` public HTTPS |
|
||||
| **customer-service** | CS credit additions | `:3011` |
|
||||
| **account-balance** | NATS prepaid balances (SoT) | `:3010` |
|
||||
| **customer-service** | CS credit additions + review | `:3011` |
|
||||
| **sales-pricing** | Per-customer sales quotes | `:3012` |
|
||||
| **accounting-export** | QuickBooks IIF / CSV | `:3013` |
|
||||
| **verae-middleware** | Zapier `/zapier/v1`, chain, NATS | `:3100` |
|
||||
|
|
@ -37,13 +38,19 @@ Check:
|
|||
|
||||
```bash
|
||||
curl -fsS http://127.0.0.1:3000/health # zappier-edge (billing + users)
|
||||
curl -fsS http://127.0.0.1:3010/health # account-balance (NATS SoT)
|
||||
curl -fsS http://127.0.0.1:3011/health # customer-service
|
||||
curl -fsS http://127.0.0.1:3012/health # sales-pricing
|
||||
curl -fsS http://127.0.0.1:3100/health # middleware
|
||||
```
|
||||
|
||||
Open:
|
||||
|
||||
- Customer portal: http://127.0.0.1:3000/portal — sign up, copy `x-api-key`
|
||||
- Admin: http://127.0.0.1:3000/admin
|
||||
- Customer portal: http://127.0.0.1:3000/portal — sign up, copy `x-api-key`, **Statement** tab
|
||||
- Admin: http://127.0.0.1:3000/admin — **Statement** per customer
|
||||
- CS review: http://127.0.0.1:3011/
|
||||
- Sales review: http://127.0.0.1:3012/
|
||||
- Accounting review/export: http://127.0.0.1:3013/
|
||||
- API docs: http://127.0.0.1:3000/docs
|
||||
|
||||
Do **not** publish NATS `4222`.
|
||||
|
|
|
|||
|
|
@ -50,8 +50,24 @@ services:
|
|||
environment:
|
||||
PORT: "3000"
|
||||
ZAPPIER_UPSTREAM: http://middleware:3100
|
||||
NATS_URL: nats://nats1:4222
|
||||
ports:
|
||||
- "3000:3000"
|
||||
depends_on: [nats1, account-balance]
|
||||
|
||||
account-balance:
|
||||
<<: *node
|
||||
image: node:22-alpine
|
||||
working_dir: /app
|
||||
volumes:
|
||||
- ${MONOREPO:-..}/packages/zappier-account-balance:/app
|
||||
command: ["node", "src/server.js"]
|
||||
environment:
|
||||
PORT: "3010"
|
||||
NATS_URL: nats://nats1:4222
|
||||
ports:
|
||||
- "3010:3010"
|
||||
depends_on: [nats1]
|
||||
|
||||
customer-service:
|
||||
<<: *node
|
||||
|
|
@ -63,9 +79,11 @@ services:
|
|||
environment:
|
||||
PORT: "3011"
|
||||
ZAPPIER_ADMIN_URL: http://zappier-edge:3000
|
||||
ACCOUNT_BALANCE_URL: http://account-balance:3010
|
||||
NATS_URL: nats://nats1:4222
|
||||
ports:
|
||||
- "3011:3011"
|
||||
depends_on: [zappier-edge]
|
||||
depends_on: [zappier-edge, account-balance, nats1]
|
||||
|
||||
sales-pricing:
|
||||
<<: *node
|
||||
|
|
@ -77,9 +95,11 @@ services:
|
|||
environment:
|
||||
PORT: "3012"
|
||||
ZAPPIER_ADMIN_URL: http://zappier-edge:3000
|
||||
ACCOUNT_BALANCE_URL: http://account-balance:3010
|
||||
NATS_URL: nats://nats1:4222
|
||||
ports:
|
||||
- "3012:3012"
|
||||
depends_on: [zappier-edge]
|
||||
depends_on: [zappier-edge, account-balance, nats1]
|
||||
|
||||
accounting-export:
|
||||
<<: *node
|
||||
|
|
@ -91,9 +111,11 @@ services:
|
|||
environment:
|
||||
PORT: "3013"
|
||||
ZAPPIER_ADMIN_URL: http://zappier-edge:3000
|
||||
ACCOUNT_BALANCE_URL: http://account-balance:3010
|
||||
NATS_URL: nats://nats1:4222
|
||||
ports:
|
||||
- "3013:3013"
|
||||
depends_on: [zappier-edge]
|
||||
depends_on: [zappier-edge, account-balance, nats1]
|
||||
|
||||
middleware:
|
||||
<<: *node
|
||||
|
|
|
|||
3
packages/zappier-account-balance/NATS.md
Normal file
3
packages/zappier-account-balance/NATS.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# zappier-account-balance NATS
|
||||
|
||||
See README. Queue `account-balance`. No public bind.
|
||||
31
packages/zappier-account-balance/README.md
Normal file
31
packages/zappier-account-balance/README.md
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# zappier-account-balance
|
||||
|
||||
Source of truth for **customer prepaid balances**. Internal traffic is **NATS request-reply**; HTTP is health plus a fallback.
|
||||
|
||||
**Forgejo:** https://git.georgelambert.org/marchon/zappier-account-balance
|
||||
**Catalog:** https://zapier.georgelambert.org/packages/zappier-account-balance/README.pdf
|
||||
|
||||
Zapier cloud never connects here. zappier-edge, customer-service, sales-pricing, and accounting-export do.
|
||||
|
||||
## Subjects
|
||||
|
||||
| Subject | Kind | Who |
|
||||
|---------|------|-----|
|
||||
| `verae.billing.statement.get` | request-reply | portal, CS, sales, admin |
|
||||
| `verae.billing.balance.get` | request-reply | anyone internal |
|
||||
| `verae.billing.balance.adjust` | request-reply | CS credits, portal reload |
|
||||
| `verae.billing.usage.recorded` | pub | zappier-edge meter |
|
||||
| `verae.billing.payment.recorded` | pub | portal reload, invoice paid |
|
||||
| `verae.billing.credit.applied` | pub | CS |
|
||||
|
||||
Queue group: `account-balance`.
|
||||
|
||||
## Run
|
||||
|
||||
```bash
|
||||
NATS_URL=nats://127.0.0.1:4222 PORT=3010 npm start
|
||||
curl http://127.0.0.1:3010/health
|
||||
curl http://127.0.0.1:3010/statement/cust_1
|
||||
```
|
||||
|
||||
Statement JSON: `{ customerId, prepaidCents, credits[], usage[], payments[] }`.
|
||||
46
packages/zappier-account-balance/package-lock.json
generated
Normal file
46
packages/zappier-account-balance/package-lock.json
generated
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"name": "zappier-account-balance",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "zappier-account-balance",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"nats": "^2.28.2"
|
||||
}
|
||||
},
|
||||
"node_modules/nats": {
|
||||
"version": "2.29.3",
|
||||
"resolved": "https://registry.npmjs.org/nats/-/nats-2.29.3.tgz",
|
||||
"integrity": "sha512-tOQCRCwC74DgBTk4pWZ9V45sk4d7peoE2njVprMRCBXrhJ5q5cYM7i6W+Uvw2qUrcfOSnuisrX7bEx3b3Wx4QA==",
|
||||
"deprecated": "Package moved. Use @nats-io/transport-node from https://github.com/nats-io/nats.js",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"nkeys.js": "1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/nkeys.js": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/nkeys.js/-/nkeys.js-1.1.0.tgz",
|
||||
"integrity": "sha512-tB/a0shZL5UZWSwsoeyqfTszONTt4k2YS0tuQioMOD180+MbombYVgzDUYHlx+gejYK6rgf08n/2Df99WY0Sxg==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"tweetnacl": "1.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tweetnacl": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
|
||||
"integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==",
|
||||
"license": "Unlicense"
|
||||
}
|
||||
}
|
||||
}
|
||||
14
packages/zappier-account-balance/package.json
Normal file
14
packages/zappier-account-balance/package.json
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "zappier-account-balance",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "NATS source of truth for customer prepaid balances, credits, usage, payments",
|
||||
"scripts": {
|
||||
"start": "node src/server.js",
|
||||
"test": "node --test test/*.test.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"nats": "^2.28.2"
|
||||
}
|
||||
}
|
||||
89
packages/zappier-account-balance/src/books.js
Normal file
89
packages/zappier-account-balance/src/books.js
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/**
|
||||
* Source of truth for prepaid balances, CS credits, usage, and payments.
|
||||
*/
|
||||
export class AccountBooks {
|
||||
constructor() {
|
||||
/** @type {Record<string, number>} */
|
||||
this.prepaid = {};
|
||||
this.credits = [];
|
||||
this.usage = [];
|
||||
this.payments = [];
|
||||
}
|
||||
|
||||
prepaidCents(customerId) {
|
||||
return this.prepaid[customerId] ?? 0;
|
||||
}
|
||||
|
||||
adjust({ customerId, cents, reason, agent, kind = 'credit' }) {
|
||||
const delta = Math.trunc(Number(cents) || 0);
|
||||
const next = this.prepaidCents(customerId) + delta;
|
||||
this.prepaid[customerId] = next;
|
||||
const row = {
|
||||
id: `adj_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 6)}`,
|
||||
customerId,
|
||||
cents: delta,
|
||||
reason: reason || kind,
|
||||
agent: agent || 'system',
|
||||
kind,
|
||||
at: new Date().toISOString(),
|
||||
prepaidCents: next,
|
||||
};
|
||||
if (kind === 'payment' || kind === 'reload') this.payments.unshift(row);
|
||||
else this.credits.unshift(row);
|
||||
return row;
|
||||
}
|
||||
|
||||
recordUsage(entry) {
|
||||
const cents = Number(entry.cents) || 0;
|
||||
const customerId = entry.customerId;
|
||||
const next = this.prepaidCents(customerId) - cents;
|
||||
this.prepaid[customerId] = next;
|
||||
const row = {
|
||||
customerId,
|
||||
endpointId: entry.endpointId || 'unknown',
|
||||
cents,
|
||||
at: entry.at || new Date().toISOString(),
|
||||
prepaidCents: next,
|
||||
};
|
||||
this.usage.unshift(row);
|
||||
return row;
|
||||
}
|
||||
|
||||
recordPayment(entry) {
|
||||
return this.adjust({
|
||||
customerId: entry.customerId,
|
||||
cents: Number(entry.cents) || 0,
|
||||
reason: entry.reason || 'payment',
|
||||
agent: entry.agent || 'payments',
|
||||
kind: 'payment',
|
||||
});
|
||||
}
|
||||
|
||||
statement(customerId) {
|
||||
const match = (rows) => rows.filter((r) => r.customerId === customerId).slice(0, 100);
|
||||
return {
|
||||
customerId,
|
||||
prepaidCents: this.prepaidCents(customerId),
|
||||
credits: match(this.credits),
|
||||
usage: match(this.usage),
|
||||
payments: match(this.payments),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function handle(subject, payload, books) {
|
||||
const p = payload || {};
|
||||
if (subject.endsWith('balance.get') || subject.endsWith('statement.get')) {
|
||||
return books.statement(p.customerId);
|
||||
}
|
||||
if (subject.endsWith('balance.adjust') || subject.endsWith('credit.applied')) {
|
||||
return books.adjust(p);
|
||||
}
|
||||
if (subject.endsWith('usage.recorded')) {
|
||||
return books.recordUsage(p);
|
||||
}
|
||||
if (subject.endsWith('payment.recorded')) {
|
||||
return books.recordPayment(p);
|
||||
}
|
||||
throw new Error(`unknown billing subject ${subject}`);
|
||||
}
|
||||
92
packages/zappier-account-balance/src/server.js
Normal file
92
packages/zappier-account-balance/src/server.js
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
#!/usr/bin/env node
|
||||
import http from 'node:http';
|
||||
import { AccountBooks, handle } from './books.js';
|
||||
import { SUBJECTS } from './subjects.js';
|
||||
|
||||
const PORT = Number(process.env.PORT || process.env.FLEET_HEALTH_PORT || 3010);
|
||||
const BIND = process.env.FLEET_HEALTH_BIND || '0.0.0.0';
|
||||
const books = new AccountBooks();
|
||||
let natsOk = false;
|
||||
|
||||
async function startNats() {
|
||||
const url = process.env.NATS_URL;
|
||||
if (!url) return;
|
||||
const { connect, StringCodec } = await import('nats');
|
||||
const nc = await connect({ servers: url.split(','), name: 'zappier-account-balance' });
|
||||
const sc = StringCodec();
|
||||
const reply = async (sub, fn) => {
|
||||
for await (const m of sub) {
|
||||
let payload = {};
|
||||
try {
|
||||
payload = JSON.parse(sc.decode(m.data) || '{}');
|
||||
} catch {
|
||||
payload = {};
|
||||
}
|
||||
const out = fn(payload);
|
||||
if (m.reply) m.respond(sc.encode(JSON.stringify(out)));
|
||||
}
|
||||
};
|
||||
reply(nc.subscribe(SUBJECTS.STATEMENT_GET, { queue: SUBJECTS.QUEUE }), (p) =>
|
||||
handle(SUBJECTS.STATEMENT_GET, p, books),
|
||||
);
|
||||
reply(nc.subscribe(SUBJECTS.BALANCE_GET, { queue: SUBJECTS.QUEUE }), (p) =>
|
||||
handle(SUBJECTS.BALANCE_GET, p, books),
|
||||
);
|
||||
reply(nc.subscribe(SUBJECTS.BALANCE_ADJUST, { queue: SUBJECTS.QUEUE }), (p) =>
|
||||
handle(SUBJECTS.BALANCE_ADJUST, p, books),
|
||||
);
|
||||
(async () => {
|
||||
for await (const m of nc.subscribe(SUBJECTS.USAGE_RECORDED)) {
|
||||
handle(SUBJECTS.USAGE_RECORDED, JSON.parse(sc.decode(m.data) || '{}'), books);
|
||||
}
|
||||
})();
|
||||
// payment.recorded / credit.applied are fan-out events. Prepaid mutations
|
||||
// go through balance.adjust so publishers can both pub and request-reply.
|
||||
natsOk = true;
|
||||
process.stdout.write(`account-balance nats ${url}\n`);
|
||||
}
|
||||
|
||||
function readBody(req) {
|
||||
return new Promise((resolve) => {
|
||||
const chunks = [];
|
||||
req.on('data', (c) => chunks.push(c));
|
||||
req.on('end', () => {
|
||||
try {
|
||||
resolve(JSON.parse(Buffer.concat(chunks).toString('utf8') || '{}'));
|
||||
} catch {
|
||||
resolve({});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const server = http.createServer(async (req, res) => {
|
||||
const url = new URL(req.url || '/', `http://127.0.0.1:${PORT}`);
|
||||
const json = (code, obj) => {
|
||||
res.writeHead(code, { 'content-type': 'application/json' });
|
||||
res.end(JSON.stringify(obj));
|
||||
};
|
||||
try {
|
||||
if (req.method === 'GET' && url.pathname === '/health') {
|
||||
return json(200, { ok: true, role: 'zappier-account-balance', nats: natsOk, subjects: SUBJECTS });
|
||||
}
|
||||
const st = url.pathname.match(/^\/statement\/([^/]+)$/);
|
||||
if (req.method === 'GET' && st) {
|
||||
return json(200, books.statement(st[1]));
|
||||
}
|
||||
if (req.method === 'POST' && url.pathname === '/adjust') {
|
||||
const body = await readBody(req);
|
||||
return json(200, books.adjust(body));
|
||||
}
|
||||
json(404, { error: 'not found' });
|
||||
} catch (err) {
|
||||
json(500, { error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
server.listen(PORT, BIND, () => {
|
||||
process.stdout.write(`zappier-account-balance http://${BIND}:${PORT}/\n`);
|
||||
});
|
||||
startNats().catch((err) => {
|
||||
process.stderr.write(`nats optional: ${err.message}\n`);
|
||||
});
|
||||
10
packages/zappier-account-balance/src/subjects.js
Normal file
10
packages/zappier-account-balance/src/subjects.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/** Internal billing bus. Zapier cloud never subscribes. */
|
||||
export const SUBJECTS = {
|
||||
BALANCE_GET: 'verae.billing.balance.get',
|
||||
BALANCE_ADJUST: 'verae.billing.balance.adjust',
|
||||
STATEMENT_GET: 'verae.billing.statement.get',
|
||||
USAGE_RECORDED: 'verae.billing.usage.recorded',
|
||||
PAYMENT_RECORDED: 'verae.billing.payment.recorded',
|
||||
CREDIT_APPLIED: 'verae.billing.credit.applied',
|
||||
QUEUE: 'account-balance',
|
||||
};
|
||||
16
packages/zappier-account-balance/test/books.test.js
Normal file
16
packages/zappier-account-balance/test/books.test.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { AccountBooks, handle } from '../src/books.js';
|
||||
import { SUBJECTS } from '../src/subjects.js';
|
||||
|
||||
test('adjust credits prepaid and statement lists credits usage payments', () => {
|
||||
const books = new AccountBooks();
|
||||
handle(SUBJECTS.BALANCE_ADJUST, { customerId: 'c1', cents: 500, reason: 'goodwill', agent: 'cs' }, books);
|
||||
handle(SUBJECTS.USAGE_RECORDED, { customerId: 'c1', endpointId: 'timestamp', cents: 4 }, books);
|
||||
handle(SUBJECTS.PAYMENT_RECORDED, { customerId: 'c1', cents: 1000, reason: 'reload' }, books);
|
||||
const st = handle(SUBJECTS.STATEMENT_GET, { customerId: 'c1' }, books);
|
||||
assert.equal(st.prepaidCents, 1496);
|
||||
assert.equal(st.credits[0].cents, 500);
|
||||
assert.equal(st.usage[0].endpointId, 'timestamp');
|
||||
assert.equal(st.payments[0].kind, 'payment');
|
||||
});
|
||||
30
packages/zappier-account-balance/test/health.test.js
Normal file
30
packages/zappier-account-balance/test/health.test.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { spawn } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const root = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
|
||||
test('account-balance health and statement', async () => {
|
||||
const port = 18010;
|
||||
const child = spawn(process.execPath, ['src/server.js'], {
|
||||
cwd: root,
|
||||
env: { ...process.env, PORT: String(port) },
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
});
|
||||
await new Promise((r) => setTimeout(r, 400));
|
||||
try {
|
||||
const h = await (await fetch(`http://127.0.0.1:${port}/health`)).json();
|
||||
assert.equal(h.role, 'zappier-account-balance');
|
||||
await fetch(`http://127.0.0.1:${port}/adjust`, {
|
||||
method: 'POST',
|
||||
headers: { 'content-type': 'application/json' },
|
||||
body: JSON.stringify({ customerId: 'c1', cents: 200, reason: 'test' }),
|
||||
});
|
||||
const st = await (await fetch(`http://127.0.0.1:${port}/statement/c1`)).json();
|
||||
assert.equal(st.prepaidCents, 200);
|
||||
} finally {
|
||||
child.kill('SIGTERM');
|
||||
}
|
||||
});
|
||||
|
|
@ -5,10 +5,13 @@ Accounting-department export of **invoices, billing, and payment history** to **
|
|||
**Forgejo:** https://git.georgelambert.org/marchon/zappier-accounting-export
|
||||
**Catalog:** https://zapier.georgelambert.org/packages/zappier-accounting-export/README.pdf
|
||||
|
||||
Reads issued/paid invoices from zappier-edge (`ZAPPIER_ADMIN_URL`).
|
||||
Reads issued/paid invoices from zappier-edge (`ZAPPIER_ADMIN_URL`). Customer statements (credits, balances, usage, payments) come from NATS `verae.billing.statement.get`.
|
||||
|
||||
Staff UI: http://127.0.0.1:3013/
|
||||
|
||||
```bash
|
||||
PORT=3013 node src/server.js
|
||||
PORT=3013 NATS_URL=nats://127.0.0.1:4222 node src/server.js
|
||||
curl http://127.0.0.1:3013/review/cust_1
|
||||
curl 'http://127.0.0.1:3013/export/quickbooks.iif?period=2026-07' -o zappier.iif
|
||||
curl 'http://127.0.0.1:3013/export/accounting.csv?period=2026-07' -o zappier.csv
|
||||
```
|
||||
|
|
|
|||
46
packages/zappier-accounting-export/package-lock.json
generated
Normal file
46
packages/zappier-accounting-export/package-lock.json
generated
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"name": "zappier-accounting-export",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "zappier-accounting-export",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"nats": "^2.28.2"
|
||||
}
|
||||
},
|
||||
"node_modules/nats": {
|
||||
"version": "2.29.3",
|
||||
"resolved": "https://registry.npmjs.org/nats/-/nats-2.29.3.tgz",
|
||||
"integrity": "sha512-tOQCRCwC74DgBTk4pWZ9V45sk4d7peoE2njVprMRCBXrhJ5q5cYM7i6W+Uvw2qUrcfOSnuisrX7bEx3b3Wx4QA==",
|
||||
"deprecated": "Package moved. Use @nats-io/transport-node from https://github.com/nats-io/nats.js",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"nkeys.js": "1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/nkeys.js": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/nkeys.js/-/nkeys.js-1.1.0.tgz",
|
||||
"integrity": "sha512-tB/a0shZL5UZWSwsoeyqfTszONTt4k2YS0tuQioMOD180+MbombYVgzDUYHlx+gejYK6rgf08n/2Df99WY0Sxg==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"tweetnacl": "1.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tweetnacl": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
|
||||
"integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==",
|
||||
"license": "Unlicense"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,5 +7,8 @@
|
|||
"scripts": {
|
||||
"start": "node src/server.js",
|
||||
"test": "node --test test/*.test.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"nats": "^2.28.2"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
51
packages/zappier-accounting-export/public/index.html
Normal file
51
packages/zappier-accounting-export/public/index.html
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Accounting — customer review</title>
|
||||
<style>
|
||||
body { font-family: -apple-system, sans-serif; margin: 2rem; max-width: 960px; color: #171a26; }
|
||||
h1 { font-size: 1.3rem; }
|
||||
label { font-size: 0.8rem; font-weight: 600; display: block; margin-top: 0.6rem; }
|
||||
input { padding: 0.4rem 0.55rem; }
|
||||
button { margin-top: 0.8rem; padding: 0.4rem 0.8rem; }
|
||||
table { border-collapse: collapse; width: 100%; margin-top: 0.6rem; }
|
||||
th, td { border-bottom: 1px solid #e5e7f0; padding: 0.4rem 0.5rem; text-align: left; font-size: 0.88rem; }
|
||||
.muted { color: #6b7186; }
|
||||
.card { border: 1px solid #e5e7f0; border-radius: 10px; padding: 1rem; margin: 1rem 0; }
|
||||
.stat { font-size: 1.4rem; font-weight: 800; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Accounting</h1>
|
||||
<p class="muted">Review payments, usage, credits, and balances. Export invoices to QuickBooks IIF / CSV.</p>
|
||||
<div class="card">
|
||||
<label>Customer id</label>
|
||||
<input id="id" value="cust_1" />
|
||||
<button onclick="review()">Review</button>
|
||||
<p class="muted"><a href="/export/quickbooks.iif">QuickBooks IIF</a> · <a href="/export/accounting.csv">CSV</a></p>
|
||||
</div>
|
||||
<div id="out"></div>
|
||||
<script>
|
||||
const fmt = (c) => (c < 0 ? '-$' : '$') + (Math.abs(c || 0) / 100).toFixed(2);
|
||||
const rows = (list, cols) =>
|
||||
(list || [])
|
||||
.map((r) => '<tr>' + cols.map((c) => `<td>${r[c] ?? ''}</td>`).join('') + '</tr>')
|
||||
.join('') || '<tr><td colspan="8" class="muted">none</td></tr>';
|
||||
async function review() {
|
||||
const id = document.getElementById('id').value.trim();
|
||||
const st = await (await fetch('/review/' + encodeURIComponent(id))).json();
|
||||
document.getElementById('out').innerHTML = `
|
||||
<div class="card"><div class="muted">Prepaid</div><div class="stat">${fmt(st.prepaidCents)}</div>
|
||||
<p class="muted">source ${st.source || 'unknown'}</p></div>
|
||||
<div class="card"><h3>Credits</h3><table><thead><tr><th>cents</th><th>reason</th><th>agent</th><th>at</th></tr></thead>
|
||||
<tbody>${rows(st.credits, ['cents','reason','agent','at'])}</tbody></table></div>
|
||||
<div class="card"><h3>Usage</h3><table><thead><tr><th>endpoint</th><th>cents</th><th>at</th></tr></thead>
|
||||
<tbody>${rows(st.usage, ['endpointId','cents','at'])}</tbody></table></div>
|
||||
<div class="card"><h3>Payments</h3><table><thead><tr><th>cents</th><th>kind</th><th>reason</th><th>at</th></tr></thead>
|
||||
<tbody>${rows(st.payments, ['cents','kind','reason','at'])}</tbody></table></div>`;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue