Skip to content

Commit 65b12ee

Browse files
authored
chore(backend,types): Update JSDoc comments & export Feature type (#6649)
1 parent ba25a5b commit 65b12ee

File tree

10 files changed

+157
-328
lines changed

10 files changed

+157
-328
lines changed

.changeset/three-knives-play.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@clerk/backend': patch
3+
'@clerk/types': patch
4+
---
5+
6+
- Export `Feature` type from backend resource.
7+
- Re-export canonical `CommerceMoneyAmount` type from `@clerk/types`.

.typedoc/__tests__/__snapshots__/file-structure.test.ts.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ exports[`Typedoc output > should have a deliberate file structure 1`] = `
232232
"backend/commerce-subscription.mdx",
233233
"backend/email-address.mdx",
234234
"backend/external-account.mdx",
235+
"backend/feature.mdx",
235236
"backend/get-auth-fn.mdx",
236237
"backend/identification-link.mdx",
237238
"backend/infer-auth-object-from-token-array.mdx",

.typedoc/custom-plugin.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const LINK_REPLACEMENTS = [
5555
['verify-token-options', '#verify-token-options'],
5656
['localization-resource', '/docs/customization/localization'],
5757
['commerce-subscription-item-resource', '/docs/references/javascript/types/commerce-subscription-item-resource'],
58+
['commerce-money-amount', '/docs/references/javascript/types/commerce-money-amount'],
5859
];
5960

6061
/**

packages/backend/src/api/resources/CommercePlan.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1+
import type { CommerceMoneyAmount } from '@clerk/types';
2+
13
import { Feature } from './Feature';
24
import type { CommercePlanJSON } from './JSON';
35

4-
export type CommerceMoneyAmount = {
5-
amount: number;
6-
amountFormatted: string;
7-
currency: string;
8-
currencySymbol: string;
9-
};
10-
116
/**
12-
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change.
13-
* It is advised to pin the SDK version to avoid breaking changes.
7+
* The `CommercePlan` object is similar to the [`CommercePlanResource`](/docs/references/javascript/types/commerce-plan-resource) object as it holds information about a plan, as well as methods for managing it. However, the `CommercePlan` object is different in that it is used in the [Backend API](https://clerk.com/docs/reference/backend-api/tag/commerce/get/commerce/plans){{ target: '_blank' }} and is not directly accessible from the Frontend API.
8+
*
9+
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to pin the SDK version to avoid breaking changes.
1410
*/
1511
export class CommercePlan {
1612
constructor(
@@ -19,7 +15,7 @@ export class CommercePlan {
1915
*/
2016
readonly id: string,
2117
/**
22-
* The id of the product the plan belongs to.
18+
* The ID of the product the plan belongs to.
2319
*/
2420
readonly productId: string,
2521
/**

packages/backend/src/api/resources/CommerceSubscription.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import { type CommerceMoneyAmount } from './CommercePlan';
1+
import { type CommerceMoneyAmount } from '@clerk/types';
2+
23
import { CommerceSubscriptionItem } from './CommerceSubscriptionItem';
34
import type { CommerceSubscriptionJSON } from './JSON';
45

56
/**
6-
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change.
7-
* It is advised to pin the SDK version to avoid breaking changes.
7+
* The `CommerceSubscription` object is similar to the [`CommerceSubscriptionResource`](/docs/references/javascript/types/commerce-subscription-resource) object as it holds information about a subscription, as well as methods for managing it. However, the `CommerceSubscription` object is different in that it is used in the [Backend API](https://clerk.com/docs/reference/backend-api/tag/billing/get/organizations/%7Borganization_id%7D/billing/subscription){{ target: '_blank' }} and is not directly accessible from the Frontend API.
8+
*
9+
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to pin the SDK version to avoid breaking changes.
810
*/
911
export class CommerceSubscription {
1012
constructor(
@@ -21,19 +23,19 @@ export class CommerceSubscription {
2123
*/
2224
readonly payerId: string,
2325
/**
24-
* Unix timestamp (milliseconds) of creation.
26+
* Unix timestamp (milliseconds) of when the subscription was created.
2527
*/
2628
readonly createdAt: number,
2729
/**
28-
* Unix timestamp (milliseconds) of last update.
30+
* Unix timestamp (milliseconds) of when the subscription was last updated.
2931
*/
3032
readonly updatedAt: number,
3133
/**
32-
* Unix timestamp (milliseconds) when the subscription became active.
34+
* Unix timestamp (milliseconds) of when the subscription became active.
3335
*/
3436
readonly activeAt: number | null,
3537
/**
36-
* Unix timestamp (milliseconds) when the subscription became past due.
38+
* Unix timestamp (milliseconds) of when the subscription became past due.
3739
*/
3840
readonly pastDueAt: number | null,
3941
/**

packages/backend/src/api/resources/CommerceSubscriptionItem.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import type { CommerceMoneyAmountJSON } from '@clerk/types';
1+
import type { CommerceMoneyAmount, CommerceMoneyAmountJSON } from '@clerk/types';
22

3-
import { type CommerceMoneyAmount, CommercePlan } from './CommercePlan';
3+
import { CommercePlan } from './CommercePlan';
44
import type { CommerceSubscriptionItemJSON } from './JSON';
55

66
/**
7-
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change.
8-
* It is advised to pin the SDK version to avoid breaking changes.
7+
* The `CommerceSubscriptionItem` object is similar to the [`CommerceSubscriptionItemResource`](/docs/references/javascript/types/commerce-subscription-item-resource) object as it holds information about a subscription item, as well as methods for managing it. However, the `CommerceSubscriptionItem` object is different in that it is used in the [Backend API](https://clerk.com/docs/reference/backend-api/tag/commerce/get/commerce/subscription_items){{ target: '_blank' }} and is not directly accessible from the Frontend API.
8+
*
9+
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to pin the SDK version to avoid breaking changes.
910
*/
1011
export class CommerceSubscriptionItem {
1112
constructor(
@@ -22,14 +23,20 @@ export class CommerceSubscriptionItem {
2223
*/
2324
readonly planPeriod: 'month' | 'annual',
2425
/**
25-
* The start of the current period.
26+
* Unix timestamp (milliseconds) of when the current period starts.
2627
*/
2728
readonly periodStart: number,
2829
/**
2930
* The next payment information.
3031
*/
3132
readonly nextPayment: {
33+
/**
34+
* The amount of the next payment.
35+
*/
3236
amount: number;
37+
/**
38+
* Unix timestamp (milliseconds) of when the next payment is scheduled.
39+
*/
3340
date: number;
3441
} | null,
3542
/**
@@ -45,27 +52,27 @@ export class CommerceSubscriptionItem {
4552
*/
4653
readonly planId: string,
4754
/**
48-
* The date and time the subscription item was created.
55+
* Unix timestamp (milliseconds) of when the subscription item was created.
4956
*/
5057
readonly createdAt: number,
5158
/**
52-
* The date and time the subscription item was last updated.
59+
* Unix timestamp (milliseconds) of when the subscription item was last updated.
5360
*/
5461
readonly updatedAt: number,
5562
/**
56-
* The end of the current period.
63+
* Unix timestamp (milliseconds) of when the current period ends.
5764
*/
5865
readonly periodEnd: number | null,
5966
/**
60-
* When the subscription item was canceled.
67+
* Unix timestamp (milliseconds) of when the subscription item was canceled.
6168
*/
6269
readonly canceledAt: number | null,
6370
/**
64-
* When the subscription item became past due.
71+
* Unix timestamp (milliseconds) of when the subscription item became past due.
6572
*/
6673
readonly pastDueAt: number | null,
6774
/**
68-
* When the subscription item ended.
75+
* Unix timestamp (milliseconds) of when the subscription item ended.
6976
*/
7077
readonly endedAt: number | null,
7178
/**

packages/backend/src/api/resources/Feature.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
import type { FeatureJSON } from './JSON';
22

3+
/**
4+
* The `Feature` object represents a feature of a subscription plan.
5+
*
6+
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to pin the SDK version to avoid breaking changes.
7+
*/
38
export class Feature {
49
constructor(
10+
/**
11+
* The unique identifier for the feature.
12+
*/
513
readonly id: string,
14+
/**
15+
* The name of the feature.
16+
*/
617
readonly name: string,
18+
/**
19+
* The description of the feature.
20+
*/
721
readonly description: string,
22+
/**
23+
* The URL-friendly identifier of the feature.
24+
*/
825
readonly slug: string,
26+
/**
27+
* The URL of the feature's avatar image.
28+
*/
929
readonly avatarUrl: string,
1030
) {}
1131

packages/backend/src/api/resources/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export * from './Web3Wallet';
6060
export * from './CommercePlan';
6161
export * from './CommerceSubscription';
6262
export * from './CommerceSubscriptionItem';
63+
export * from './Feature';
6364

6465
export type {
6566
EmailWebhookEvent,

packages/backend/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export type {
119119
Domain,
120120
EmailAddress,
121121
ExternalAccount,
122+
Feature,
122123
Instance,
123124
InstanceRestrictions,
124125
InstanceSettings,

0 commit comments

Comments
 (0)