@ingram-tech/nk-billing 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/balance.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Customer-balance wallet — Stripe's own credit ledger, for pay-as-you-go sites
3
- * (domains.ingram.tech). Distinct from the in-app credit ledger in
2
+ * Customer-balance wallet — Stripe's own credit ledger, for pay-as-you-go
3
+ * sites. Distinct from the in-app credit ledger in
4
4
  * `@ingram-tech/nk-billing/credits`: this stores the balance *in Stripe* as a
5
5
  * signed integer (negative = credit available to the customer), so there is no
6
6
  * local table to keep in sync. Pick this when the unit you sell is money;
package/dist/balance.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Customer-balance wallet — Stripe's own credit ledger, for pay-as-you-go sites
3
- * (domains.ingram.tech). Distinct from the in-app credit ledger in
2
+ * Customer-balance wallet — Stripe's own credit ledger, for pay-as-you-go
3
+ * sites. Distinct from the in-app credit ledger in
4
4
  * `@ingram-tech/nk-billing/credits`: this stores the balance *in Stripe* as a
5
5
  * signed integer (negative = credit available to the customer), so there is no
6
6
  * local table to keep in sync. Pick this when the unit you sell is money;
package/dist/client.d.ts CHANGED
@@ -4,8 +4,9 @@
4
4
  *
5
5
  * This is the one pattern every Ingram site had hand-rolled identically (the
6
6
  * `getStripe()` singleton); it lives here once now. Single-mode sites call
7
- * {@link getStripe}; the dual-mode site (cloud.ingram.tech) calls
8
- * {@link stripeFor} with a mode and gets one memoised client per mode.
7
+ * {@link getStripe}; a dual-mode site (its own merchant of record, running the
8
+ * Stripe sandbox beside live) calls {@link stripeFor} with a mode and gets one
9
+ * memoised client per mode.
9
10
  */
10
11
  import Stripe from "stripe";
11
12
  import { type StripeMode } from "./keys.js";
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAexD;;mCAEmC;AACnC,wBAAgB,SAAS,IAAI,MAAM,CAOlC;AAED;0CAC0C;AAC1C,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAelD;AAED,0EAA0E;AAC1E,wBAAgB,kBAAkB,IAAI,IAAI,CAIzC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAexD;;mCAEmC;AACnC,wBAAgB,SAAS,IAAI,MAAM,CAOlC;AAED;0CAC0C;AAC1C,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAelD;AAED,0EAA0E;AAC1E,wBAAgB,kBAAkB,IAAI,IAAI,CAIzC"}
package/dist/client.js CHANGED
@@ -4,8 +4,9 @@
4
4
  *
5
5
  * This is the one pattern every Ingram site had hand-rolled identically (the
6
6
  * `getStripe()` singleton); it lives here once now. Single-mode sites call
7
- * {@link getStripe}; the dual-mode site (cloud.ingram.tech) calls
8
- * {@link stripeFor} with a mode and gets one memoised client per mode.
7
+ * {@link getStripe}; a dual-mode site (its own merchant of record, running the
8
+ * Stripe sandbox beside live) calls {@link stripeFor} with a mode and gets one
9
+ * memoised client per mode.
9
10
  */
10
11
  import Stripe from "stripe";
11
12
  import { billingEnv } from "./keys.js";
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAmB,MAAM,WAAW,CAAC;AAExD,IAAI,MAAM,GAAkB,IAAI,CAAC;AACjC,MAAM,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,CAAC;IACvC,IAAI,CAAC,GAAG,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CACd,qBAAqB,IAAI,CAAC,WAAW,EAAE,iCAAiC,CACxE,CAAC;IACH,CAAC;IACD,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IAC9B,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;IACtB,OAAO,MAAM,CAAC;AACf,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,kBAAkB;IACjC,MAAM,GAAG,IAAI,CAAC;IACd,OAAO,MAAM,CAAC,IAAI,CAAC;IACnB,OAAO,MAAM,CAAC,IAAI,CAAC;AACpB,CAAC"}
package/dist/credits.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The in-app credit ledger — the stateful half of nk-billing, for sites that
3
- * meter usage in abstract "credits" rather than money (integrain). It follows
3
+ * meter usage in abstract "credits" rather than money. It follows
4
4
  * nextkit's Django-app model: this package owns its tables and ships their
5
5
  * migration (`migrations/0001_billing.sql`), and takes the database connection by
6
6
  * **injection** so it never reaches into the consuming site's schema.
package/dist/credits.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The in-app credit ledger — the stateful half of nk-billing, for sites that
3
- * meter usage in abstract "credits" rather than money (integrain). It follows
3
+ * meter usage in abstract "credits" rather than money. It follows
4
4
  * nextkit's Django-app model: this package owns its tables and ships their
5
5
  * migration (`migrations/0001_billing.sql`), and takes the database connection by
6
6
  * **injection** so it never reaches into the consuming site's schema.
@@ -4,15 +4,15 @@
4
4
  * then finds it back by metadata search — no local `stripe_customer_id` column is
5
5
  * required just to locate the customer (though sites cache it for speed).
6
6
  *
7
- * The metadata key differs per site (`financica_organization_id`,
8
- * `integrain_org_id`, …), so it is always passed in explicitly via
9
- * {@link CustomerRef} rather than baked in here — that is the framework seam.
7
+ * The metadata key differs per site (`acme_organization_id`, `acme_user_id`,
8
+ * …), so it is always passed in explicitly via {@link CustomerRef} rather than
9
+ * baked in here — that is the framework seam.
10
10
  */
11
11
  import type Stripe from "stripe";
12
12
  /** Identifies a Stripe customer by a metadata tag → local entity id. */
13
13
  export interface CustomerRef {
14
14
  /** The Stripe `metadata` key the local id is stored under, e.g.
15
- * "integrain_org_id". Choose one per site and use it everywhere. */
15
+ * "acme_org_id". Choose one per site and use it everywhere. */
16
16
  metadataKey: string;
17
17
  /** The local entity id (org id, user id, …). */
18
18
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../src/customers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAGjC,wEAAwE;AACxE,MAAM,WAAW,WAAW;IAC3B;yEACqE;IACrE,WAAW,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,EAAE,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,eAAe;IAC/B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE;QACT,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KACxB,GAAG,IAAI,CAAC;CACT;AAED;;gBAEgB;AAChB,wBAAsB,YAAY,CACjC,GAAG,EAAE,WAAW,EAChB,MAAM,GAAE,MAAoB,GAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,CAMjC;AAED;;eAEe;AACf,wBAAsB,oBAAoB,CACzC,GAAG,EAAE,WAAW,EAChB,OAAO,GAAE,eAAoB,EAC7B,MAAM,GA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BAEgB;AAChB,wBAAsB,YAAY,CACjC,GAAG,EAAE,WAAW,EAChB,MAAM,GAAE,MAAoB,GAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,CAMjC;AAED;;eAEe;AACf,wBAAsB,oBAAoB,CACzC,GAAG,EAAE,WAAW,EAChB,OAAO,GAAE,eAAoB,EAC7B,MAAM,GAAE,MAAoB,GAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAiC1B;AAED;gEACgE;AAChE,wBAAsB,yBAAyB,CAC9C,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,MAAoB,GAC1B,OAAO,CAAC,OAAO,CAAC,CAIlB;AAED;8CAC8C;AAC9C,wBAAsB,4BAA4B,CACjD,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE;IACL,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE;QACR,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;KAChB,CAAC;CACF,EACD,MAAM,GAAE,MAAoB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAKf"}
package/dist/customers.js CHANGED
@@ -4,9 +4,9 @@
4
4
  * then finds it back by metadata search — no local `stripe_customer_id` column is
5
5
  * required just to locate the customer (though sites cache it for speed).
6
6
  *
7
- * The metadata key differs per site (`financica_organization_id`,
8
- * `integrain_org_id`, …), so it is always passed in explicitly via
9
- * {@link CustomerRef} rather than baked in here — that is the framework seam.
7
+ * The metadata key differs per site (`acme_organization_id`, `acme_user_id`,
8
+ * …), so it is always passed in explicitly via {@link CustomerRef} rather than
9
+ * baked in here — that is the framework seam.
10
10
  */
11
11
  import { getStripe } from "./client.js";
12
12
  /** The customer for `ref`, found by metadata search, or null if none exists yet.
package/dist/keys.d.ts CHANGED
@@ -8,17 +8,17 @@
8
8
  *
9
9
  * Two deployment shapes are supported, picked per call site, never both at once:
10
10
  *
11
- * 1. Single-mode (the default financica / integrain / thornhill): one
12
- * account, one key. `getStripe()` reads STRIPE_SECRET_KEY and
13
- * `webhookSecret()` reads STRIPE_WEBHOOK_SECRET.
11
+ * 1. Single-mode (the default for most sites): one account, one key.
12
+ * `getStripe()` reads STRIPE_SECRET_KEY and `webhookSecret()` reads
13
+ * STRIPE_WEBHOOK_SECRET.
14
14
  *
15
- * 2. Dual-mode (cloud.ingram.tech, which is its own merchant of record and
16
- * runs the Stripe sandbox beside live): `stripeFor("test"|"live")` reads
15
+ * 2. Dual-mode (a site that is its own merchant of record and runs the Stripe
16
+ * sandbox beside live): `stripeFor("test"|"live")` reads
17
17
  * STRIPE_SECRET_KEY_{TEST,LIVE} and `webhookSecret(mode)` reads
18
18
  * STRIPE_WEBHOOK_SECRET_{TEST,LIVE}.
19
19
  *
20
20
  * Nothing here hardcodes a price ID. Prices are resolved at runtime by their
21
- * stable Stripe `lookup_key` (set on the Price in the infra Pulumi program), so
21
+ * stable Stripe `lookup_key` (set on the Price out of band, e.g. in your IaC), so
22
22
  * the same key resolves in test and live even though their price IDs differ.
23
23
  */
24
24
  /** Which Stripe account a dual-mode site is talking to. */
package/dist/keys.js CHANGED
@@ -8,17 +8,17 @@
8
8
  *
9
9
  * Two deployment shapes are supported, picked per call site, never both at once:
10
10
  *
11
- * 1. Single-mode (the default financica / integrain / thornhill): one
12
- * account, one key. `getStripe()` reads STRIPE_SECRET_KEY and
13
- * `webhookSecret()` reads STRIPE_WEBHOOK_SECRET.
11
+ * 1. Single-mode (the default for most sites): one account, one key.
12
+ * `getStripe()` reads STRIPE_SECRET_KEY and `webhookSecret()` reads
13
+ * STRIPE_WEBHOOK_SECRET.
14
14
  *
15
- * 2. Dual-mode (cloud.ingram.tech, which is its own merchant of record and
16
- * runs the Stripe sandbox beside live): `stripeFor("test"|"live")` reads
15
+ * 2. Dual-mode (a site that is its own merchant of record and runs the Stripe
16
+ * sandbox beside live): `stripeFor("test"|"live")` reads
17
17
  * STRIPE_SECRET_KEY_{TEST,LIVE} and `webhookSecret(mode)` reads
18
18
  * STRIPE_WEBHOOK_SECRET_{TEST,LIVE}.
19
19
  *
20
20
  * Nothing here hardcodes a price ID. Prices are resolved at runtime by their
21
- * stable Stripe `lookup_key` (set on the Price in the infra Pulumi program), so
21
+ * stable Stripe `lookup_key` (set on the Price out of band, e.g. in your IaC), so
22
22
  * the same key resolves in test and live even though their price IDs differ.
23
23
  */
24
24
  import { z } from "zod";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ingram-tech/nk-billing",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "The Ingram billing foundation: composable Stripe primitives (client, customers, prices, currency, checkout, subscriptions, webhooks) plus an injection-based Postgres credit ledger and event-dedup store.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -33,13 +33,13 @@
33
33
  "test": "vitest run"
34
34
  },
35
35
  "dependencies": {
36
- "stripe": "^22.0.0",
37
- "zod": "^4.0.0"
36
+ "stripe": "^22.3.0",
37
+ "zod": "^4.4.3"
38
38
  },
39
39
  "devDependencies": {
40
- "@ingram-tech/nk-dev": "workspace:*",
41
- "@types/node": "^25.0.0",
40
+ "@ingram-tech/nk-dev": "0.2.4",
41
+ "@types/node": "^26.0.1",
42
42
  "typescript": "^6.0.3",
43
- "vitest": "^4.1.6"
43
+ "vitest": "^4.1.9"
44
44
  }
45
45
  }