Skip to content

feat(catalog): add SUBSCRIPTION_PLAN and SUBSCRIPTION_PLAN_VARIATION object types#68

Merged
mbates merged 1 commit intomainfrom
feat/subscription-plan-catalog-types
Apr 19, 2026
Merged

feat(catalog): add SUBSCRIPTION_PLAN and SUBSCRIPTION_PLAN_VARIATION object types#68
mbates merged 1 commit intomainfrom
feat/subscription-plan-catalog-types

Conversation

@mbates
Copy link
Copy Markdown
Owner

@mbates mbates commented Apr 19, 2026

Description

Adds SUBSCRIPTION_PLAN (template) and SUBSCRIPTION_PLAN_VARIATION (the actual subscribable record whose ID is passed as planVariationId to subscriptions.create) to the CatalogObjectType union so consumers can list available subscription plans via catalog.search / catalog.list.

This is a TypeScript-only change — Square already accepts these values on the underlying API; the wrapper just didn't declare them.

Closes #67.

Why

The Subscriptions service has full coverage for create/get/update/pause/resume/cancel/search, but there was no way to enumerate available plans for a "pick a plan" admin UI. Without the catalog types, catalog.search({ objectTypes: ['SUBSCRIPTION_PLAN'] }) was a TypeScript error and there was no alternate path.

Changes

File Change
src/core/services/catalog.service.ts Add the two new union members to CatalogObjectType
src/core/__tests__/catalog.service.test.ts New test asserting search() accepts both as objectTypes (locks the type at use site)
docs/guides/core/catalog.md Add the two new types to the Catalog Object Types table
README.md Service Classes line now mentions subscription plan listing

How Has This Been Tested?

npm run typecheck   # clean
npm run lint        # clean
npm test            # 463 → 464 (+1 new test)
npm run build       # clean

Test plan

  • In a downstream project, square.catalog.search({ objectTypes: ['SUBSCRIPTION_PLAN'] }) and square.catalog.search({ objectTypes: ['SUBSCRIPTION_PLAN_VARIATION'] }) typecheck and return Square's expected payloads

…object types

Square's catalog API supports both `SUBSCRIPTION_PLAN` (template) and
`SUBSCRIPTION_PLAN_VARIATION` (the actual subscribable record whose
ID is passed as `planVariationId` to `subscriptions.create`) as
catalog object types. Both were missing from the `CatalogObjectType`
union, which made it impossible to list available plans via
`catalog.search`/`catalog.list` from the wrapper.

This is a TypeScript-only change — Square already accepts these values
on the underlying API, the wrapper just didn't declare them.

Updates the catalog guide table and the README service-class summary
to mention subscription plan listing.

Closes #67
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.06%. Comparing base (f921736) to head (3f3e038).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #68   +/-   ##
=======================================
  Coverage   97.06%   97.06%           
=======================================
  Files          18       18           
  Lines         955      955           
  Branches      277      277           
=======================================
  Hits          927      927           
  Misses          1        1           
  Partials       27       27           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extends the Catalog service’s TypeScript surface area to include Square Catalog object types for subscription plans and plan variations, enabling consumers to enumerate available subscription offerings via catalog.search/catalog.list without type errors.

Changes:

  • Added SUBSCRIPTION_PLAN and SUBSCRIPTION_PLAN_VARIATION to the CatalogObjectType union.
  • Added a TypeScript-usage test that exercises CatalogService.search({ objectTypes: [...] }) with the new object types.
  • Updated catalog documentation and README to mention subscription plan listing support.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/core/services/catalog.service.ts Adds the two subscription-related catalog object types to CatalogObjectType.
src/core/__tests__/catalog.service.test.ts Adds a test covering search() acceptance of the new object types.
docs/guides/core/catalog.md Documents the two new catalog object types in the guide table.
README.md Mentions subscription plan listing as part of Catalog service capabilities.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mbates mbates merged commit bd0cc77 into main Apr 19, 2026
8 checks passed
@mbates mbates deleted the feat/subscription-plan-catalog-types branch April 19, 2026 06:04
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 1.11.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add SUBSCRIPTION_PLAN and SUBSCRIPTION_PLAN_VARIATION to CatalogObjectType

2 participants