From cd524a641f6dcc39b7b0311cba1c0e9b8ebf1057 Mon Sep 17 00:00:00 2001 From: John Yeo Date: Wed, 18 Feb 2026 19:17:31 +0000 Subject: [PATCH] finished setup --- .../api-reference/balances/balancesCheck.mdx | 8 +- apps/docs/mintlify/api/openapi.yml | 12 +- .../app/scenarios/core/use-autumn/page.tsx | 28 ++- apps/sdk-test/lib/autumn/autumnHandler.ts | 2 +- apps/sdk-test/tsconfig.check.json | 3 +- apps/sdk-test/tsconfig.json | 1 + bun.lock | 2 +- .../.speakeasy/code-samples.overlay.yaml | 2 +- others/python-sdk/.speakeasy/gen.lock | 38 ++-- others/python-sdk/.speakeasy/gen.yaml | 2 +- .../docs/models/balancescheckrequest.md | 6 +- .../docs/sdks/balancessdk/README.md | 6 +- others/python-sdk/pyproject.toml | 2 +- others/python-sdk/src/autumn_sdk/_version.py | 4 +- .../python-sdk/src/autumn_sdk/balances_sdk.py | 20 +- .../src/autumn_sdk/models/balancescheckop.py | 15 +- others/python-sdk/uv.lock | 2 +- .../hooks/internal/check/balanceToAllowed.ts | 73 +++++++ .../internal/check/customerToFeatures.ts | 23 +++ .../check/findCreditSystemsByFeature.ts | 20 ++ .../hooks/internal/check/getCreditCost.ts | 23 +++ .../src/react/hooks/internal/checkUtils.ts | 189 ------------------ .../hooks/internal/getLocalCheckResponse.ts | 147 ++++++++++++++ .../hooks/internal/useCustomerActions.ts | 2 +- packages/openapi/openapi-stripped.yml | 6 +- packages/openapi/openapi.yml | 6 +- .../v2.1/contracts/balancesContract.ts | 4 +- .../sdk/.speakeasy/code-samples.overlay.yaml | 1 + packages/sdk/.speakeasy/gen.lock | 38 ++-- packages/sdk/.speakeasy/gen.yaml | 2 +- packages/sdk/.speakeasy/out.openapi.yaml | 6 +- packages/sdk/.speakeasy/workflow.lock | 10 +- .../sdk/docs/models/balances-check-request.md | 7 +- packages/sdk/docs/sdks/balances/README.md | 2 + packages/sdk/jsr.json | 2 +- packages/sdk/package.json | 2 +- packages/sdk/src/lib/config.ts | 4 +- packages/sdk/src/models/balances-check-op.ts | 17 +- .../changes/V1.2_CusFeatureChange.ts | 2 +- .../cusFeatures/mappers/balanceV1ToV0.ts | 2 +- .../utils/check/getFeatureToUseForCheck.ts | 21 +- .../utils/convert/apiBalanceToAllowed.ts | 36 +--- .../convert/apiBalanceV1ToAvailableOverage.ts | 15 +- .../utils/convert/apiBalanceV1ToOverage.ts | 13 +- .../customers/utils/apiCustomerToFeatures.ts | 35 +--- shared/api/customers/utils/index.ts | 2 +- 46 files changed, 449 insertions(+), 414 deletions(-) create mode 100644 packages/autumn-js/src/react/hooks/internal/check/balanceToAllowed.ts create mode 100644 packages/autumn-js/src/react/hooks/internal/check/customerToFeatures.ts create mode 100644 packages/autumn-js/src/react/hooks/internal/check/findCreditSystemsByFeature.ts create mode 100644 packages/autumn-js/src/react/hooks/internal/check/getCreditCost.ts delete mode 100644 packages/autumn-js/src/react/hooks/internal/checkUtils.ts create mode 100644 packages/autumn-js/src/react/hooks/internal/getLocalCheckResponse.ts diff --git a/apps/docs/mintlify/api-reference/balances/balancesCheck.mdx b/apps/docs/mintlify/api-reference/balances/balancesCheck.mdx index 3abb519ae..a480621c4 100644 --- a/apps/docs/mintlify/api-reference/balances/balancesCheck.mdx +++ b/apps/docs/mintlify/api-reference/balances/balancesCheck.mdx @@ -13,7 +13,9 @@ import { DynamicResponseExample } from "/components/dynamic-response-example.jsx ID which you provided when creating the customer - + + ID of the feature to check access to. + If using entity balances (eg, seats), the entity ID to check access for. @@ -33,10 +35,6 @@ import { DynamicResponseExample } from "/components/dynamic-response-example.jsx If true, the response will include a preview object, which can be used to display information such as a paywall or upgrade confirmation. - - - - ### Response diff --git a/apps/docs/mintlify/api/openapi.yml b/apps/docs/mintlify/api/openapi.yml index 392189325..af2eb915a 100644 --- a/apps/docs/mintlify/api/openapi.yml +++ b/apps/docs/mintlify/api/openapi.yml @@ -4232,6 +4232,7 @@ paths: description: ID which you provided when creating the customer feature_id: type: string + description: ID of the feature to check access to. entity_id: type: string description: If using entity balances (eg, seats), the entity ID to check access @@ -4256,12 +4257,9 @@ paths: description: If true, the response will include a preview object, which can be used to display information such as a paywall or upgrade confirmation. - product_id: - type: string - required_quantity: - type: number required: - customer_id + - feature_id responses: "200": description: OK @@ -4831,6 +4829,7 @@ paths: const result = await autumn.balances.check({ customerId: "", + featureId: "", }); - lang: python label: Python (SDK) @@ -4839,7 +4838,10 @@ paths: autumn = Autumn(secret_key="am_sk_test...") - res = autumn.balances.check(customer_id="") + res = autumn.balances.check( + customer_id="", + feature_id="", + ) /v1/balances.track: post: operationId: balancesTrack diff --git a/apps/sdk-test/app/scenarios/core/use-autumn/page.tsx b/apps/sdk-test/app/scenarios/core/use-autumn/page.tsx index 174d3ce88..0e1dafd0a 100644 --- a/apps/sdk-test/app/scenarios/core/use-autumn/page.tsx +++ b/apps/sdk-test/app/scenarios/core/use-autumn/page.tsx @@ -64,11 +64,13 @@ export default function UseAutumnScenarioPage() { // Input state const [planId, setPlanId] = useState(""); const [featureId, setFeatureId] = useState(""); + const [requiredBalance, setRequiredBalance] = useState(""); const [openInNewTab, setOpenInNewTab] = useState(false); // Form element IDs const planIdInputId = useId(); const featureIdInputId = useId(); + const requiredBalanceInputId = useId(); const runAction = async ({ name, @@ -123,10 +125,16 @@ export default function UseAutumnScenarioPage() { const handleCheck = () => { if (!featureId) return; + const params = { + featureId, + requiredBalance: requiredBalance + ? parseFloat(requiredBalance) + : undefined, + }; runAction({ name: "check", - params: { featureId }, - execute: () => check({ featureId }), + params, + execute: () => check(params), }); }; @@ -225,6 +233,22 @@ export default function UseAutumnScenarioPage() { className="h-8 text-sm" /> +
+ + setRequiredBalance(e.target.value)} + className="h-8 text-sm" + /> +