@augmenting-integrations/billing 5.0.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var CreditBalanceBadge_exports = {};
21
+ __export(CreditBalanceBadge_exports, {
22
+ CreditBalanceBadge: () => CreditBalanceBadge
23
+ });
24
+ module.exports = __toCommonJS(CreditBalanceBadge_exports);
25
+ var import_jsx_runtime = require("react/jsx-runtime");
26
+ function CreditBalanceBadge({
27
+ balance,
28
+ label = "Balance",
29
+ className
30
+ }) {
31
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className, "aria-label": `${label}: ${balance.toFixed(2)}`, children: [
32
+ label,
33
+ ": ",
34
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "font-mono font-semibold", children: [
35
+ "$",
36
+ balance.toFixed(2)
37
+ ] })
38
+ ] });
39
+ }
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ CreditBalanceBadge
43
+ });
44
+ //# sourceMappingURL=CreditBalanceBadge.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/CreditBalanceBadge.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\n// Small chip rendering the current credit balance. Kept minimal so consumers\n// can style around it; no Tailwind utility classes that would break under\n// non-default themes. The label is exposed so spokes can localize.\n\nexport function CreditBalanceBadge({\n balance,\n label = \"Balance\",\n className,\n}: {\n balance: number;\n label?: string;\n className?: string;\n}) {\n return (\n <span className={className} aria-label={`${label}: ${balance.toFixed(2)}`}>\n {label}: <span className=\"font-mono font-semibold\">${balance.toFixed(2)}</span>\n </span>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBe;AAXR,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA,QAAQ;AAAA,EACR;AACF,GAIG;AACD,SACE,6CAAC,UAAK,WAAsB,cAAY,GAAG,KAAK,KAAK,QAAQ,QAAQ,CAAC,CAAC,IACpE;AAAA;AAAA,IAAM;AAAA,IAAE,6CAAC,UAAK,WAAU,2BAA0B;AAAA;AAAA,MAAE,QAAQ,QAAQ,CAAC;AAAA,OAAE;AAAA,KAC1E;AAEJ;","names":[]}
@@ -0,0 +1,20 @@
1
+ "use client";
2
+ import { jsxs } from "react/jsx-runtime";
3
+ function CreditBalanceBadge({
4
+ balance,
5
+ label = "Balance",
6
+ className
7
+ }) {
8
+ return /* @__PURE__ */ jsxs("span", { className, "aria-label": `${label}: ${balance.toFixed(2)}`, children: [
9
+ label,
10
+ ": ",
11
+ /* @__PURE__ */ jsxs("span", { className: "font-mono font-semibold", children: [
12
+ "$",
13
+ balance.toFixed(2)
14
+ ] })
15
+ ] });
16
+ }
17
+ export {
18
+ CreditBalanceBadge
19
+ };
20
+ //# sourceMappingURL=CreditBalanceBadge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/CreditBalanceBadge.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\n// Small chip rendering the current credit balance. Kept minimal so consumers\n// can style around it; no Tailwind utility classes that would break under\n// non-default themes. The label is exposed so spokes can localize.\n\nexport function CreditBalanceBadge({\n balance,\n label = \"Balance\",\n className,\n}: {\n balance: number;\n label?: string;\n className?: string;\n}) {\n return (\n <span className={className} aria-label={`${label}: ${balance.toFixed(2)}`}>\n {label}: <span className=\"font-mono font-semibold\">${balance.toFixed(2)}</span>\n </span>\n );\n}\n"],"mappings":";AAmBe;AAXR,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA,QAAQ;AAAA,EACR;AACF,GAIG;AACD,SACE,qBAAC,UAAK,WAAsB,cAAY,GAAG,KAAK,KAAK,QAAQ,QAAQ,CAAC,CAAC,IACpE;AAAA;AAAA,IAAM;AAAA,IAAE,qBAAC,UAAK,WAAU,2BAA0B;AAAA;AAAA,MAAE,QAAQ,QAAQ,CAAC;AAAA,OAAE;AAAA,KAC1E;AAEJ;","names":[]}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var PaymentMethodSelect_exports = {};
21
+ __export(PaymentMethodSelect_exports, {
22
+ PaymentMethodSelect: () => PaymentMethodSelect
23
+ });
24
+ module.exports = __toCommonJS(PaymentMethodSelect_exports);
25
+ var import_jsx_runtime = require("react/jsx-runtime");
26
+ function PaymentMethodSelect({
27
+ cards,
28
+ value,
29
+ onChange,
30
+ className,
31
+ emptyLabel = "No saved cards"
32
+ }) {
33
+ if (cards.length === 0) {
34
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-muted-foreground", "data-testid": "payment-method-empty", children: emptyLabel });
35
+ }
36
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
37
+ "select",
38
+ {
39
+ className: className ?? "h-9 rounded-md border border-input bg-transparent px-2 text-sm",
40
+ value: value ?? "",
41
+ onChange: (e) => onChange(e.target.value),
42
+ children: [
43
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "", disabled: true, children: "Select card" }),
44
+ cards.map((pm) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("option", { value: pm.id, children: [
45
+ pm.brand.charAt(0).toUpperCase() + pm.brand.slice(1),
46
+ " ****",
47
+ pm.last4,
48
+ " (",
49
+ pm.exp_month,
50
+ "/",
51
+ pm.exp_year,
52
+ ")",
53
+ pm.is_default ? " (default)" : ""
54
+ ] }, pm.id))
55
+ ]
56
+ }
57
+ );
58
+ }
59
+ // Annotate the CommonJS export names for ESM import in node:
60
+ 0 && (module.exports = {
61
+ PaymentMethodSelect
62
+ });
63
+ //# sourceMappingURL=PaymentMethodSelect.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/PaymentMethodSelect.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\n// =============================================================================\n// PaymentMethodSelect -- typed dropdown over the caller's saved-cards array.\n//\n// Pure UI: takes an array of card metadata + the current selection + an\n// onChange. The actual list comes from the spoke's PaymentMethod table. The\n// component doesn't talk to Stripe itself; the consumer fetches the list and\n// hands it in.\n// =============================================================================\n\nexport type SavedCard = {\n id: string;\n brand: string;\n last4: string;\n exp_month: number;\n exp_year: number;\n is_default: boolean;\n};\n\nexport function PaymentMethodSelect({\n cards,\n value,\n onChange,\n className,\n emptyLabel = \"No saved cards\",\n}: {\n cards: SavedCard[];\n value: string | null;\n onChange: (id: string) => void;\n className?: string;\n emptyLabel?: string;\n}) {\n if (cards.length === 0) {\n return (\n <p className=\"text-xs text-muted-foreground\" data-testid=\"payment-method-empty\">\n {emptyLabel}\n </p>\n );\n }\n return (\n <select\n className={\n className ?? \"h-9 rounded-md border border-input bg-transparent px-2 text-sm\"\n }\n value={value ?? \"\"}\n onChange={(e) => onChange(e.target.value)}\n >\n <option value=\"\" disabled>\n Select card\n </option>\n {cards.map((pm) => (\n <option key={pm.id} value={pm.id}>\n {pm.brand.charAt(0).toUpperCase() + pm.brand.slice(1)} ****{pm.last4} (\n {pm.exp_month}/{pm.exp_year}){pm.is_default ? \" (default)\" : \"\"}\n </option>\n ))}\n </select>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqCM;AAfC,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AACf,GAMG;AACD,MAAI,MAAM,WAAW,GAAG;AACtB,WACE,4CAAC,OAAE,WAAU,iCAAgC,eAAY,wBACtD,sBACH;AAAA,EAEJ;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WACE,aAAa;AAAA,MAEf,OAAO,SAAS;AAAA,MAChB,UAAU,CAAC,MAAM,SAAS,EAAE,OAAO,KAAK;AAAA,MAExC;AAAA,oDAAC,YAAO,OAAM,IAAG,UAAQ,MAAC,yBAE1B;AAAA,QACC,MAAM,IAAI,CAAC,OACV,6CAAC,YAAmB,OAAO,GAAG,IAC3B;AAAA,aAAG,MAAM,OAAO,CAAC,EAAE,YAAY,IAAI,GAAG,MAAM,MAAM,CAAC;AAAA,UAAE;AAAA,UAAM,GAAG;AAAA,UAAM;AAAA,UACpE,GAAG;AAAA,UAAU;AAAA,UAAE,GAAG;AAAA,UAAS;AAAA,UAAE,GAAG,aAAa,eAAe;AAAA,aAFlD,GAAG,EAGhB,CACD;AAAA;AAAA;AAAA,EACH;AAEJ;","names":[]}
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ function PaymentMethodSelect({
4
+ cards,
5
+ value,
6
+ onChange,
7
+ className,
8
+ emptyLabel = "No saved cards"
9
+ }) {
10
+ if (cards.length === 0) {
11
+ return /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", "data-testid": "payment-method-empty", children: emptyLabel });
12
+ }
13
+ return /* @__PURE__ */ jsxs(
14
+ "select",
15
+ {
16
+ className: className ?? "h-9 rounded-md border border-input bg-transparent px-2 text-sm",
17
+ value: value ?? "",
18
+ onChange: (e) => onChange(e.target.value),
19
+ children: [
20
+ /* @__PURE__ */ jsx("option", { value: "", disabled: true, children: "Select card" }),
21
+ cards.map((pm) => /* @__PURE__ */ jsxs("option", { value: pm.id, children: [
22
+ pm.brand.charAt(0).toUpperCase() + pm.brand.slice(1),
23
+ " ****",
24
+ pm.last4,
25
+ " (",
26
+ pm.exp_month,
27
+ "/",
28
+ pm.exp_year,
29
+ ")",
30
+ pm.is_default ? " (default)" : ""
31
+ ] }, pm.id))
32
+ ]
33
+ }
34
+ );
35
+ }
36
+ export {
37
+ PaymentMethodSelect
38
+ };
39
+ //# sourceMappingURL=PaymentMethodSelect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/PaymentMethodSelect.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\n// =============================================================================\n// PaymentMethodSelect -- typed dropdown over the caller's saved-cards array.\n//\n// Pure UI: takes an array of card metadata + the current selection + an\n// onChange. The actual list comes from the spoke's PaymentMethod table. The\n// component doesn't talk to Stripe itself; the consumer fetches the list and\n// hands it in.\n// =============================================================================\n\nexport type SavedCard = {\n id: string;\n brand: string;\n last4: string;\n exp_month: number;\n exp_year: number;\n is_default: boolean;\n};\n\nexport function PaymentMethodSelect({\n cards,\n value,\n onChange,\n className,\n emptyLabel = \"No saved cards\",\n}: {\n cards: SavedCard[];\n value: string | null;\n onChange: (id: string) => void;\n className?: string;\n emptyLabel?: string;\n}) {\n if (cards.length === 0) {\n return (\n <p className=\"text-xs text-muted-foreground\" data-testid=\"payment-method-empty\">\n {emptyLabel}\n </p>\n );\n }\n return (\n <select\n className={\n className ?? \"h-9 rounded-md border border-input bg-transparent px-2 text-sm\"\n }\n value={value ?? \"\"}\n onChange={(e) => onChange(e.target.value)}\n >\n <option value=\"\" disabled>\n Select card\n </option>\n {cards.map((pm) => (\n <option key={pm.id} value={pm.id}>\n {pm.brand.charAt(0).toUpperCase() + pm.brand.slice(1)} ****{pm.last4} (\n {pm.exp_month}/{pm.exp_year}){pm.is_default ? \" (default)\" : \"\"}\n </option>\n ))}\n </select>\n );\n}\n"],"mappings":";AAqCM,cAiBE,YAjBF;AAfC,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AACf,GAMG;AACD,MAAI,MAAM,WAAW,GAAG;AACtB,WACE,oBAAC,OAAE,WAAU,iCAAgC,eAAY,wBACtD,sBACH;AAAA,EAEJ;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WACE,aAAa;AAAA,MAEf,OAAO,SAAS;AAAA,MAChB,UAAU,CAAC,MAAM,SAAS,EAAE,OAAO,KAAK;AAAA,MAExC;AAAA,4BAAC,YAAO,OAAM,IAAG,UAAQ,MAAC,yBAE1B;AAAA,QACC,MAAM,IAAI,CAAC,OACV,qBAAC,YAAmB,OAAO,GAAG,IAC3B;AAAA,aAAG,MAAM,OAAO,CAAC,EAAE,YAAY,IAAI,GAAG,MAAM,MAAM,CAAC;AAAA,UAAE;AAAA,UAAM,GAAG;AAAA,UAAM;AAAA,UACpE,GAAG;AAAA,UAAU;AAAA,UAAE,GAAG;AAAA,UAAS;AAAA,UAAE,GAAG,aAAa,eAAe;AAAA,aAFlD,GAAG,EAGhB,CACD;AAAA;AAAA;AAAA,EACH;AAEJ;","names":[]}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var StripeProvider_exports = {};
31
+ __export(StripeProvider_exports, {
32
+ StripeProvider: () => StripeProvider
33
+ });
34
+ module.exports = __toCommonJS(StripeProvider_exports);
35
+ var import_jsx_runtime = require("react/jsx-runtime");
36
+ var React = __toESM(require("react"));
37
+ var import_react_stripe_js = require("@stripe/react-stripe-js");
38
+ var import_stripe_loader = require("./stripe-loader.js");
39
+ function StripeProvider({
40
+ publishableKey,
41
+ options,
42
+ children
43
+ }) {
44
+ const stripePromise = React.useMemo(
45
+ () => (0, import_stripe_loader.loadStripeClient)(publishableKey),
46
+ [publishableKey]
47
+ );
48
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_stripe_js.Elements, { stripe: stripePromise, options, children });
49
+ }
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ StripeProvider
53
+ });
54
+ //# sourceMappingURL=StripeProvider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/StripeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Elements } from \"@stripe/react-stripe-js\";\nimport { loadStripeClient } from \"./stripe-loader.js\";\n\n// =============================================================================\n// StripeProvider -- thin wrapper around <Elements> that loads the publishable\n// key once per process and threads the resulting Stripe.js instance into\n// nested <CardElement>/<PaymentElement>/etc.\n//\n// Consumer pattern:\n//\n// <StripeProvider publishableKey={...} options={{ clientSecret }}>\n// <CardElement />\n// <button onClick={...}>Pay</button>\n// </StripeProvider>\n// =============================================================================\n\nexport function StripeProvider({\n publishableKey,\n options,\n children,\n}: {\n publishableKey: string;\n options?: Parameters<typeof Elements>[0][\"options\"];\n children: React.ReactNode;\n}) {\n const stripePromise = React.useMemo(\n () => loadStripeClient(publishableKey),\n [publishableKey],\n );\n return (\n <Elements stripe={stripePromise} options={options}>\n {children}\n </Elements>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiCI;AA/BJ,YAAuB;AACvB,6BAAyB;AACzB,2BAAiC;AAe1B,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,QAAM,gBAAgB,MAAM;AAAA,IAC1B,UAAM,uCAAiB,cAAc;AAAA,IACrC,CAAC,cAAc;AAAA,EACjB;AACA,SACE,4CAAC,mCAAS,QAAQ,eAAe,SAC9B,UACH;AAEJ;","names":[]}
@@ -0,0 +1,20 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { Elements } from "@stripe/react-stripe-js";
5
+ import { loadStripeClient } from "./stripe-loader.js";
6
+ function StripeProvider({
7
+ publishableKey,
8
+ options,
9
+ children
10
+ }) {
11
+ const stripePromise = React.useMemo(
12
+ () => loadStripeClient(publishableKey),
13
+ [publishableKey]
14
+ );
15
+ return /* @__PURE__ */ jsx(Elements, { stripe: stripePromise, options, children });
16
+ }
17
+ export {
18
+ StripeProvider
19
+ };
20
+ //# sourceMappingURL=StripeProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/StripeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Elements } from \"@stripe/react-stripe-js\";\nimport { loadStripeClient } from \"./stripe-loader.js\";\n\n// =============================================================================\n// StripeProvider -- thin wrapper around <Elements> that loads the publishable\n// key once per process and threads the resulting Stripe.js instance into\n// nested <CardElement>/<PaymentElement>/etc.\n//\n// Consumer pattern:\n//\n// <StripeProvider publishableKey={...} options={{ clientSecret }}>\n// <CardElement />\n// <button onClick={...}>Pay</button>\n// </StripeProvider>\n// =============================================================================\n\nexport function StripeProvider({\n publishableKey,\n options,\n children,\n}: {\n publishableKey: string;\n options?: Parameters<typeof Elements>[0][\"options\"];\n children: React.ReactNode;\n}) {\n const stripePromise = React.useMemo(\n () => loadStripeClient(publishableKey),\n [publishableKey],\n );\n return (\n <Elements stripe={stripePromise} options={options}>\n {children}\n </Elements>\n );\n}\n"],"mappings":";AAiCI;AA/BJ,YAAY,WAAW;AACvB,SAAS,gBAAgB;AACzB,SAAS,wBAAwB;AAe1B,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,QAAM,gBAAgB,MAAM;AAAA,IAC1B,MAAM,iBAAiB,cAAc;AAAA,IACrC,CAAC,cAAc;AAAA,EACjB;AACA,SACE,oBAAC,YAAS,QAAQ,eAAe,SAC9B,UACH;AAEJ;","names":[]}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var stripe_loader_exports = {};
21
+ __export(stripe_loader_exports, {
22
+ loadStripeClient: () => loadStripeClient
23
+ });
24
+ module.exports = __toCommonJS(stripe_loader_exports);
25
+ var import_stripe_js = require("@stripe/stripe-js");
26
+ let cached;
27
+ function loadStripeClient(publishableKey) {
28
+ if (!cached || cached.key !== publishableKey) {
29
+ cached = { key: publishableKey, promise: (0, import_stripe_js.loadStripe)(publishableKey) };
30
+ }
31
+ return cached.promise;
32
+ }
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ loadStripeClient
36
+ });
37
+ //# sourceMappingURL=stripe-loader.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/stripe-loader.ts"],"sourcesContent":["\"use client\";\n\nimport { loadStripe, type Stripe } from \"@stripe/stripe-js\";\n\n// =============================================================================\n// loadStripe cache, keyed by publishable key.\n//\n// Stripe.js docs recommend loading the library exactly once. Module-scope\n// cache handles:\n// - Multiple <Elements> mounts in the same page sharing the same Stripe.js\n// promise.\n// - Hot module reload during dev not re-fetching Stripe.js.\n// - Falling through to a fresh promise on the (unlikely) event of a\n// publishable-key change.\n// =============================================================================\n\nlet cached: { key: string; promise: Promise<Stripe | null> } | undefined;\n\nexport function loadStripeClient(publishableKey: string): Promise<Stripe | null> {\n if (!cached || cached.key !== publishableKey) {\n cached = { key: publishableKey, promise: loadStripe(publishableKey) };\n }\n return cached.promise;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,uBAAwC;AAcxC,IAAI;AAEG,SAAS,iBAAiB,gBAAgD;AAC/E,MAAI,CAAC,UAAU,OAAO,QAAQ,gBAAgB;AAC5C,aAAS,EAAE,KAAK,gBAAgB,aAAS,6BAAW,cAAc,EAAE;AAAA,EACtE;AACA,SAAO,OAAO;AAChB;","names":[]}
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { loadStripe } from "@stripe/stripe-js";
3
+ let cached;
4
+ function loadStripeClient(publishableKey) {
5
+ if (!cached || cached.key !== publishableKey) {
6
+ cached = { key: publishableKey, promise: loadStripe(publishableKey) };
7
+ }
8
+ return cached.promise;
9
+ }
10
+ export {
11
+ loadStripeClient
12
+ };
13
+ //# sourceMappingURL=stripe-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/stripe-loader.ts"],"sourcesContent":["\"use client\";\n\nimport { loadStripe, type Stripe } from \"@stripe/stripe-js\";\n\n// =============================================================================\n// loadStripe cache, keyed by publishable key.\n//\n// Stripe.js docs recommend loading the library exactly once. Module-scope\n// cache handles:\n// - Multiple <Elements> mounts in the same page sharing the same Stripe.js\n// promise.\n// - Hot module reload during dev not re-fetching Stripe.js.\n// - Falling through to a fresh promise on the (unlikely) event of a\n// publishable-key change.\n// =============================================================================\n\nlet cached: { key: string; promise: Promise<Stripe | null> } | undefined;\n\nexport function loadStripeClient(publishableKey: string): Promise<Stripe | null> {\n if (!cached || cached.key !== publishableKey) {\n cached = { key: publishableKey, promise: loadStripe(publishableKey) };\n }\n return cached.promise;\n}\n"],"mappings":";AAEA,SAAS,kBAA+B;AAcxC,IAAI;AAEG,SAAS,iBAAiB,gBAAgD;AAC/E,MAAI,CAAC,UAAU,OAAO,QAAQ,gBAAgB;AAC5C,aAAS,EAAE,KAAK,gBAAgB,SAAS,WAAW,cAAc,EAAE;AAAA,EACtE;AACA,SAAO,OAAO;AAChB;","names":[]}
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var useCart_exports = {};
31
+ __export(useCart_exports, {
32
+ useCart: () => useCart
33
+ });
34
+ module.exports = __toCommonJS(useCart_exports);
35
+ var React = __toESM(require("react"));
36
+ function useCart(opts) {
37
+ const { storageKey } = opts;
38
+ const [items, setItemsState] = React.useState(() => {
39
+ if (typeof window === "undefined") return [];
40
+ try {
41
+ const saved = window.localStorage.getItem(storageKey);
42
+ return saved ? JSON.parse(saved) : [];
43
+ } catch {
44
+ return [];
45
+ }
46
+ });
47
+ React.useEffect(() => {
48
+ if (typeof window === "undefined") return;
49
+ try {
50
+ if (items.length > 0) {
51
+ window.localStorage.setItem(storageKey, JSON.stringify(items));
52
+ } else {
53
+ window.localStorage.removeItem(storageKey);
54
+ }
55
+ } catch {
56
+ }
57
+ }, [items, storageKey]);
58
+ const setItems = React.useCallback((next) => {
59
+ setItemsState(next);
60
+ }, []);
61
+ const add = React.useCallback((item) => {
62
+ setItemsState((prev) => {
63
+ const idx = prev.findIndex((c) => c.id === item.id);
64
+ if (idx >= 0) {
65
+ const next = [...prev];
66
+ next[idx] = { ...next[idx], quantity: next[idx].quantity + item.quantity };
67
+ return next;
68
+ }
69
+ return [...prev, item];
70
+ });
71
+ }, []);
72
+ const mergeMany = React.useCallback((newItems) => {
73
+ if (newItems.length === 0) return;
74
+ setItemsState((prev) => {
75
+ const next = [...prev];
76
+ for (const it of newItems) {
77
+ const idx = next.findIndex((c) => c.id === it.id);
78
+ if (idx >= 0) {
79
+ next[idx] = { ...next[idx], quantity: next[idx].quantity + it.quantity };
80
+ } else {
81
+ next.push(it);
82
+ }
83
+ }
84
+ return next;
85
+ });
86
+ }, []);
87
+ const remove = React.useCallback((id) => {
88
+ setItemsState((prev) => prev.filter((c) => c.id !== id));
89
+ }, []);
90
+ const updateQuantity = React.useCallback((id, quantity) => {
91
+ if (quantity <= 0) {
92
+ setItemsState((prev) => prev.filter((c) => c.id !== id));
93
+ return;
94
+ }
95
+ setItemsState((prev) => prev.map((c) => c.id === id ? { ...c, quantity } : c));
96
+ }, []);
97
+ const clear = React.useCallback(() => {
98
+ setItemsState([]);
99
+ }, []);
100
+ const total = items.reduce((sum, c) => sum + c.unitPrice * c.quantity, 0);
101
+ const count = items.reduce((sum, c) => sum + c.quantity, 0);
102
+ return {
103
+ items,
104
+ add,
105
+ mergeMany,
106
+ remove,
107
+ updateQuantity,
108
+ setItems,
109
+ clear,
110
+ total,
111
+ count
112
+ };
113
+ }
114
+ // Annotate the CommonJS export names for ESM import in node:
115
+ 0 && (module.exports = {
116
+ useCart
117
+ });
118
+ //# sourceMappingURL=useCart.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/useCart.ts"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\n// =============================================================================\n// useCart -- localStorage-backed cart hook\n//\n// Generic over the cart item shape. Caller defines `T` with at least an `id`\n// (used to dedupe + update quantity) and a `unitPrice` + `quantity` (used by\n// `total`).\n//\n// Usage:\n//\n// type LeadCartItem = { id: string; unitPrice: number; quantity: number;\n// ...productSpecific };\n// const { items, add, remove, updateQuantity, clear, total, count } =\n// useCart<LeadCartItem>({ storageKey: \"marketplace_cart\" });\n// =============================================================================\n\nexport type CartItemBase = {\n id: string;\n unitPrice: number;\n quantity: number;\n};\n\nexport type UseCartOptions = {\n storageKey: string;\n};\n\nexport type UseCartReturn<T extends CartItemBase> = {\n items: T[];\n add: (item: T) => void;\n /**\n * Merge an array of items into the cart by id. Duplicates increment\n * existing quantities; new ids are appended.\n */\n mergeMany: (newItems: T[]) => void;\n remove: (id: string) => void;\n updateQuantity: (id: string, quantity: number) => void;\n setItems: (items: T[]) => void;\n clear: () => void;\n /** Sum of unitPrice * quantity across all items. */\n total: number;\n /** Sum of quantities across all items. */\n count: number;\n};\n\nexport function useCart<T extends CartItemBase>(opts: UseCartOptions): UseCartReturn<T> {\n const { storageKey } = opts;\n const [items, setItemsState] = React.useState<T[]>(() => {\n if (typeof window === \"undefined\") return [];\n try {\n const saved = window.localStorage.getItem(storageKey);\n return saved ? (JSON.parse(saved) as T[]) : [];\n } catch {\n return [];\n }\n });\n\n React.useEffect(() => {\n if (typeof window === \"undefined\") return;\n try {\n if (items.length > 0) {\n window.localStorage.setItem(storageKey, JSON.stringify(items));\n } else {\n window.localStorage.removeItem(storageKey);\n }\n } catch {\n /* localStorage unavailable -- ignore */\n }\n }, [items, storageKey]);\n\n const setItems = React.useCallback((next: T[]) => {\n setItemsState(next);\n }, []);\n\n const add = React.useCallback((item: T) => {\n setItemsState((prev) => {\n const idx = prev.findIndex((c) => c.id === item.id);\n if (idx >= 0) {\n const next = [...prev];\n next[idx] = { ...next[idx]!, quantity: next[idx]!.quantity + item.quantity };\n return next;\n }\n return [...prev, item];\n });\n }, []);\n\n const mergeMany = React.useCallback((newItems: T[]) => {\n if (newItems.length === 0) return;\n setItemsState((prev) => {\n const next = [...prev];\n for (const it of newItems) {\n const idx = next.findIndex((c) => c.id === it.id);\n if (idx >= 0) {\n next[idx] = { ...next[idx]!, quantity: next[idx]!.quantity + it.quantity };\n } else {\n next.push(it);\n }\n }\n return next;\n });\n }, []);\n\n const remove = React.useCallback((id: string) => {\n setItemsState((prev) => prev.filter((c) => c.id !== id));\n }, []);\n\n const updateQuantity = React.useCallback((id: string, quantity: number) => {\n if (quantity <= 0) {\n setItemsState((prev) => prev.filter((c) => c.id !== id));\n return;\n }\n setItemsState((prev) => prev.map((c) => (c.id === id ? { ...c, quantity } : c)));\n }, []);\n\n const clear = React.useCallback(() => {\n setItemsState([]);\n }, []);\n\n const total = items.reduce((sum, c) => sum + c.unitPrice * c.quantity, 0);\n const count = items.reduce((sum, c) => sum + c.quantity, 0);\n\n return {\n items,\n add,\n mergeMany,\n remove,\n updateQuantity,\n setItems,\n clear,\n total,\n count,\n };\n}\n"],"mappings":"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","names":[]}
@@ -0,0 +1,84 @@
1
+ "use client";
2
+ import * as React from "react";
3
+ function useCart(opts) {
4
+ const { storageKey } = opts;
5
+ const [items, setItemsState] = React.useState(() => {
6
+ if (typeof window === "undefined") return [];
7
+ try {
8
+ const saved = window.localStorage.getItem(storageKey);
9
+ return saved ? JSON.parse(saved) : [];
10
+ } catch {
11
+ return [];
12
+ }
13
+ });
14
+ React.useEffect(() => {
15
+ if (typeof window === "undefined") return;
16
+ try {
17
+ if (items.length > 0) {
18
+ window.localStorage.setItem(storageKey, JSON.stringify(items));
19
+ } else {
20
+ window.localStorage.removeItem(storageKey);
21
+ }
22
+ } catch {
23
+ }
24
+ }, [items, storageKey]);
25
+ const setItems = React.useCallback((next) => {
26
+ setItemsState(next);
27
+ }, []);
28
+ const add = React.useCallback((item) => {
29
+ setItemsState((prev) => {
30
+ const idx = prev.findIndex((c) => c.id === item.id);
31
+ if (idx >= 0) {
32
+ const next = [...prev];
33
+ next[idx] = { ...next[idx], quantity: next[idx].quantity + item.quantity };
34
+ return next;
35
+ }
36
+ return [...prev, item];
37
+ });
38
+ }, []);
39
+ const mergeMany = React.useCallback((newItems) => {
40
+ if (newItems.length === 0) return;
41
+ setItemsState((prev) => {
42
+ const next = [...prev];
43
+ for (const it of newItems) {
44
+ const idx = next.findIndex((c) => c.id === it.id);
45
+ if (idx >= 0) {
46
+ next[idx] = { ...next[idx], quantity: next[idx].quantity + it.quantity };
47
+ } else {
48
+ next.push(it);
49
+ }
50
+ }
51
+ return next;
52
+ });
53
+ }, []);
54
+ const remove = React.useCallback((id) => {
55
+ setItemsState((prev) => prev.filter((c) => c.id !== id));
56
+ }, []);
57
+ const updateQuantity = React.useCallback((id, quantity) => {
58
+ if (quantity <= 0) {
59
+ setItemsState((prev) => prev.filter((c) => c.id !== id));
60
+ return;
61
+ }
62
+ setItemsState((prev) => prev.map((c) => c.id === id ? { ...c, quantity } : c));
63
+ }, []);
64
+ const clear = React.useCallback(() => {
65
+ setItemsState([]);
66
+ }, []);
67
+ const total = items.reduce((sum, c) => sum + c.unitPrice * c.quantity, 0);
68
+ const count = items.reduce((sum, c) => sum + c.quantity, 0);
69
+ return {
70
+ items,
71
+ add,
72
+ mergeMany,
73
+ remove,
74
+ updateQuantity,
75
+ setItems,
76
+ clear,
77
+ total,
78
+ count
79
+ };
80
+ }
81
+ export {
82
+ useCart
83
+ };
84
+ //# sourceMappingURL=useCart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/useCart.ts"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\n// =============================================================================\n// useCart -- localStorage-backed cart hook\n//\n// Generic over the cart item shape. Caller defines `T` with at least an `id`\n// (used to dedupe + update quantity) and a `unitPrice` + `quantity` (used by\n// `total`).\n//\n// Usage:\n//\n// type LeadCartItem = { id: string; unitPrice: number; quantity: number;\n// ...productSpecific };\n// const { items, add, remove, updateQuantity, clear, total, count } =\n// useCart<LeadCartItem>({ storageKey: \"marketplace_cart\" });\n// =============================================================================\n\nexport type CartItemBase = {\n id: string;\n unitPrice: number;\n quantity: number;\n};\n\nexport type UseCartOptions = {\n storageKey: string;\n};\n\nexport type UseCartReturn<T extends CartItemBase> = {\n items: T[];\n add: (item: T) => void;\n /**\n * Merge an array of items into the cart by id. Duplicates increment\n * existing quantities; new ids are appended.\n */\n mergeMany: (newItems: T[]) => void;\n remove: (id: string) => void;\n updateQuantity: (id: string, quantity: number) => void;\n setItems: (items: T[]) => void;\n clear: () => void;\n /** Sum of unitPrice * quantity across all items. */\n total: number;\n /** Sum of quantities across all items. */\n count: number;\n};\n\nexport function useCart<T extends CartItemBase>(opts: UseCartOptions): UseCartReturn<T> {\n const { storageKey } = opts;\n const [items, setItemsState] = React.useState<T[]>(() => {\n if (typeof window === \"undefined\") return [];\n try {\n const saved = window.localStorage.getItem(storageKey);\n return saved ? (JSON.parse(saved) as T[]) : [];\n } catch {\n return [];\n }\n });\n\n React.useEffect(() => {\n if (typeof window === \"undefined\") return;\n try {\n if (items.length > 0) {\n window.localStorage.setItem(storageKey, JSON.stringify(items));\n } else {\n window.localStorage.removeItem(storageKey);\n }\n } catch {\n /* localStorage unavailable -- ignore */\n }\n }, [items, storageKey]);\n\n const setItems = React.useCallback((next: T[]) => {\n setItemsState(next);\n }, []);\n\n const add = React.useCallback((item: T) => {\n setItemsState((prev) => {\n const idx = prev.findIndex((c) => c.id === item.id);\n if (idx >= 0) {\n const next = [...prev];\n next[idx] = { ...next[idx]!, quantity: next[idx]!.quantity + item.quantity };\n return next;\n }\n return [...prev, item];\n });\n }, []);\n\n const mergeMany = React.useCallback((newItems: T[]) => {\n if (newItems.length === 0) return;\n setItemsState((prev) => {\n const next = [...prev];\n for (const it of newItems) {\n const idx = next.findIndex((c) => c.id === it.id);\n if (idx >= 0) {\n next[idx] = { ...next[idx]!, quantity: next[idx]!.quantity + it.quantity };\n } else {\n next.push(it);\n }\n }\n return next;\n });\n }, []);\n\n const remove = React.useCallback((id: string) => {\n setItemsState((prev) => prev.filter((c) => c.id !== id));\n }, []);\n\n const updateQuantity = React.useCallback((id: string, quantity: number) => {\n if (quantity <= 0) {\n setItemsState((prev) => prev.filter((c) => c.id !== id));\n return;\n }\n setItemsState((prev) => prev.map((c) => (c.id === id ? { ...c, quantity } : c)));\n }, []);\n\n const clear = React.useCallback(() => {\n setItemsState([]);\n }, []);\n\n const total = items.reduce((sum, c) => sum + c.unitPrice * c.quantity, 0);\n const count = items.reduce((sum, c) => sum + c.quantity, 0);\n\n return {\n items,\n add,\n mergeMany,\n remove,\n updateQuantity,\n setItems,\n clear,\n total,\n count,\n };\n}\n"],"mappings":"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","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augmenting-integrations/billing",
3
- "version": "5.0.0",
3
+ "version": "6.0.0",
4
4
  "description": "Stripe primitives for augint product apps: secret-bundled client init, idempotent customer creation, webhook signature verification, plus client-side React widgets (Elements provider, PaymentMethodSelect, CreditBalanceBadge, useCart with localStorage persistence).",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -33,8 +33,8 @@
33
33
  "@stripe/react-stripe-js": "^3.0.0",
34
34
  "@stripe/stripe-js": "^4.0.0",
35
35
  "react": "^19.0.0",
36
- "@augmenting-integrations/ui": "5.0.0",
37
- "@augmenting-integrations/aws": "5.0.0"
36
+ "@augmenting-integrations/ui": "6.0.0",
37
+ "@augmenting-integrations/aws": "6.0.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@stripe/react-stripe-js": "^3.0.0",
@@ -44,8 +44,8 @@
44
44
  "tsup": "^8.3.5",
45
45
  "typescript": "^5.7.2",
46
46
  "vitest": "^4.1.5",
47
- "@augmenting-integrations/aws": "5.0.0",
48
- "@augmenting-integrations/ui": "5.0.0"
47
+ "@augmenting-integrations/aws": "6.0.0",
48
+ "@augmenting-integrations/ui": "6.0.0"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "tsup",