@doist/todoist-sdk 10.2.0 → 10.3.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,62 @@
1
+ import type { BillingCycle } from './types.js';
2
+ /** Arguments for cancelling the current plan. */
3
+ export type CancelPlanArgs = {
4
+ /** Short identifier of the cancellation reason category. */
5
+ reasonFlag?: string;
6
+ /** Human-readable label of the cancellation reason. */
7
+ reasonDescription?: string;
8
+ /** Free-form feedback from the user about the cancellation. */
9
+ reasonText?: string;
10
+ /** URL the user is redirected to after completing the flow. */
11
+ returnUrl?: string;
12
+ };
13
+ /** Common arguments for any Stripe checkout (upgrade or trial) request. */
14
+ export type CheckoutArgs = {
15
+ currency: string;
16
+ billingCycle: BillingCycle;
17
+ successUrl: string;
18
+ cancelUrl: string;
19
+ };
20
+ /** Optional promotion/partnership attribution shared by upgrade requests. */
21
+ export type UpgradeOptions = {
22
+ promotionCode?: string | null;
23
+ partnershipId?: string | null;
24
+ };
25
+ /** Arguments for upgrading to a Pro plan. */
26
+ export type UpgradeToProArgs = CheckoutArgs & UpgradeOptions & {
27
+ trialPeriodDays?: number | null;
28
+ };
29
+ /** Arguments for starting a Pro trial. */
30
+ export type StartProTrialArgs = CheckoutArgs;
31
+ /** Arguments for opening the Pro billing portal. */
32
+ export type ProBillingPortalArgs = {
33
+ returnUrl: string;
34
+ flowType?: string | null;
35
+ promotionCode?: string | null;
36
+ };
37
+ /** Arguments for upgrading a workspace. */
38
+ export type UpgradeWorkspaceArgs = CheckoutArgs & UpgradeOptions & {
39
+ workspaceId: string;
40
+ };
41
+ /** Arguments for starting a workspace trial. */
42
+ export type StartWorkspaceTrialArgs = CheckoutArgs & {
43
+ workspaceId: string;
44
+ };
45
+ /** Arguments for opening the workspace billing portal. */
46
+ export type WorkspaceBillingPortalArgs = {
47
+ workspaceId: string;
48
+ returnUrl: string;
49
+ flowType?: string | null;
50
+ };
51
+ /** Arguments for fetching pricing. */
52
+ export type GetPricingArgs = {
53
+ formatted?: boolean;
54
+ };
55
+ /** Response containing a Stripe checkout session URL. */
56
+ export type CheckoutSessionResponse = {
57
+ checkoutSessionUrl: string;
58
+ };
59
+ /** Response containing a Stripe billing portal URL. */
60
+ export type BillingPortalUrlResponse = {
61
+ billingPortalUrl: string;
62
+ };
@@ -0,0 +1,207 @@
1
+ import { z } from 'zod';
2
+ /** Available subscription statuses. */
3
+ export declare const BILLING_SUBSCRIPTION_STATUSES: readonly ["none", "autorenew", "canceled", "expired", "trial", "trial_canceled"];
4
+ /** Current subscription status. */
5
+ export type BillingSubscriptionStatus = (typeof BILLING_SUBSCRIPTION_STATUSES)[number];
6
+ /** Available plan tiers. */
7
+ export declare const BILLING_PLANS: readonly ["free", "pro", "pro_gifted", "pro_legacy"];
8
+ /** Plan tier a user is currently on. */
9
+ export type BillingPlan = (typeof BILLING_PLANS)[number];
10
+ /** Ways an active subscription can be purchased. */
11
+ export declare const BILLING_ACTIVATION_METHODS: readonly ["stripe", "appstore", "playstore", "teams", "manual"];
12
+ /** How an active subscription was purchased. */
13
+ export type BillingActivationMethod = (typeof BILLING_ACTIVATION_METHODS)[number];
14
+ /** Available billing cycles. */
15
+ export declare const BILLING_CYCLES: readonly ["monthly", "yearly"];
16
+ /** Billing cycle for a plan price. */
17
+ export type BillingCycle = (typeof BILLING_CYCLES)[number];
18
+ /** Available tax behaviors for a price. */
19
+ export declare const TAX_BEHAVIORS: readonly ["exclusive", "inclusive", "unspecified"];
20
+ /** Tax behavior for a plan price. */
21
+ export type TaxBehavior = (typeof TAX_BEHAVIORS)[number];
22
+ export declare const BillingPlanPriceSchema: z.ZodObject<{
23
+ amount: z.ZodString;
24
+ rawAmount: z.ZodNumber;
25
+ currency: z.ZodString;
26
+ billingCycle: z.ZodNullable<z.ZodEnum<{
27
+ monthly: "monthly";
28
+ yearly: "yearly";
29
+ }>>;
30
+ taxBehavior: z.ZodEnum<{
31
+ inclusive: "inclusive";
32
+ exclusive: "exclusive";
33
+ unspecified: "unspecified";
34
+ }>;
35
+ }, z.core.$strip>;
36
+ /** Price of an active plan. */
37
+ export type BillingPlanPrice = z.infer<typeof BillingPlanPriceSchema>;
38
+ export declare const SubscriptionInfoSchema: z.ZodObject<{
39
+ status: z.ZodEnum<{
40
+ none: "none";
41
+ autorenew: "autorenew";
42
+ canceled: "canceled";
43
+ expired: "expired";
44
+ trial: "trial";
45
+ trial_canceled: "trial_canceled";
46
+ }>;
47
+ plan: z.ZodEnum<{
48
+ free: "free";
49
+ pro: "pro";
50
+ pro_gifted: "pro_gifted";
51
+ pro_legacy: "pro_legacy";
52
+ }>;
53
+ expirationDate: z.ZodNullable<z.ZodString>;
54
+ activationMethod: z.ZodEnum<{
55
+ manual: "manual";
56
+ stripe: "stripe";
57
+ appstore: "appstore";
58
+ playstore: "playstore";
59
+ teams: "teams";
60
+ }>;
61
+ planPrice: z.ZodNullable<z.ZodObject<{
62
+ amount: z.ZodString;
63
+ rawAmount: z.ZodNumber;
64
+ currency: z.ZodString;
65
+ billingCycle: z.ZodNullable<z.ZodEnum<{
66
+ monthly: "monthly";
67
+ yearly: "yearly";
68
+ }>>;
69
+ taxBehavior: z.ZodEnum<{
70
+ inclusive: "inclusive";
71
+ exclusive: "exclusive";
72
+ unspecified: "unspecified";
73
+ }>;
74
+ }, z.core.$strip>>;
75
+ billingPortalUrl: z.ZodNullable<z.ZodString>;
76
+ billingPortalSwitchToAnnualUrl: z.ZodNullable<z.ZodString>;
77
+ hasBillingPortal: z.ZodBoolean;
78
+ hasBillingPortalSwitchToAnnual: z.ZodBoolean;
79
+ invoiceCreditBalance: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNumber>>;
80
+ hasSwitchLegacyToCurrent: z.ZodBoolean;
81
+ }, z.core.$strip>;
82
+ /** Current subscription state of a user. */
83
+ export type SubscriptionInfo = z.infer<typeof SubscriptionInfoSchema>;
84
+ export declare const FormattedPriceSchema: z.ZodObject<{
85
+ currency: z.ZodString;
86
+ unitAmount: z.ZodNumber;
87
+ taxBehavior: z.ZodEnum<{
88
+ inclusive: "inclusive";
89
+ exclusive: "exclusive";
90
+ unspecified: "unspecified";
91
+ }>;
92
+ }, z.core.$strip>;
93
+ /** A single price within a billing-cycle listing. */
94
+ export type FormattedPrice = z.infer<typeof FormattedPriceSchema>;
95
+ export declare const PriceListingSchema: z.ZodObject<{
96
+ billingCycle: z.ZodEnum<{
97
+ monthly: "monthly";
98
+ yearly: "yearly";
99
+ }>;
100
+ prices: z.ZodArray<z.ZodObject<{
101
+ currency: z.ZodString;
102
+ unitAmount: z.ZodNumber;
103
+ taxBehavior: z.ZodEnum<{
104
+ inclusive: "inclusive";
105
+ exclusive: "exclusive";
106
+ unspecified: "unspecified";
107
+ }>;
108
+ }, z.core.$strip>>;
109
+ }, z.core.$strip>;
110
+ /** Prices available for a given billing cycle. */
111
+ export type PriceListing = z.infer<typeof PriceListingSchema>;
112
+ export declare const ProPlanDetailsSchema: z.ZodObject<{
113
+ currentPlanStatus: z.ZodEnum<{
114
+ Active: "Active";
115
+ Downgraded: "Downgraded";
116
+ Cancelled: "Cancelled";
117
+ NeverSubscribed: "NeverSubscribed";
118
+ }>;
119
+ downgradeAt: z.ZodNullable<z.ZodString>;
120
+ priceList: z.ZodArray<z.ZodObject<{
121
+ billingCycle: z.ZodEnum<{
122
+ monthly: "monthly";
123
+ yearly: "yearly";
124
+ }>;
125
+ prices: z.ZodArray<z.ZodObject<{
126
+ currency: z.ZodString;
127
+ unitAmount: z.ZodNumber;
128
+ taxBehavior: z.ZodEnum<{
129
+ inclusive: "inclusive";
130
+ exclusive: "exclusive";
131
+ unspecified: "unspecified";
132
+ }>;
133
+ }, z.core.$strip>>;
134
+ }, z.core.$strip>>;
135
+ }, z.core.$strip>;
136
+ /** Pro plan and billing details. */
137
+ export type ProPlanDetails = z.infer<typeof ProPlanDetailsSchema>;
138
+ export declare const PricesResponseSchema: z.ZodObject<{
139
+ pro: z.ZodArray<z.ZodObject<{
140
+ billingCycle: z.ZodEnum<{
141
+ monthly: "monthly";
142
+ yearly: "yearly";
143
+ }>;
144
+ prices: z.ZodArray<z.ZodObject<{
145
+ currency: z.ZodString;
146
+ unitAmount: z.ZodNumber;
147
+ taxBehavior: z.ZodEnum<{
148
+ inclusive: "inclusive";
149
+ exclusive: "exclusive";
150
+ unspecified: "unspecified";
151
+ }>;
152
+ }, z.core.$strip>>;
153
+ }, z.core.$strip>>;
154
+ teams: z.ZodArray<z.ZodObject<{
155
+ billingCycle: z.ZodEnum<{
156
+ monthly: "monthly";
157
+ yearly: "yearly";
158
+ }>;
159
+ prices: z.ZodArray<z.ZodObject<{
160
+ currency: z.ZodString;
161
+ unitAmount: z.ZodNumber;
162
+ taxBehavior: z.ZodEnum<{
163
+ inclusive: "inclusive";
164
+ exclusive: "exclusive";
165
+ unspecified: "unspecified";
166
+ }>;
167
+ }, z.core.$strip>>;
168
+ }, z.core.$strip>>;
169
+ }, z.core.$strip>;
170
+ /** Available Pro and Teams prices. */
171
+ export type PricesResponse = z.infer<typeof PricesResponseSchema>;
172
+ /**
173
+ * Monthly and yearly amounts for a single currency. Each amount is a number in
174
+ * the currency's smallest unit, or a localized formatted string when the
175
+ * `pricing` endpoint is called with `formatted: true`.
176
+ */
177
+ export declare const PricingTermsSchema: z.ZodObject<{
178
+ monthly: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
179
+ yearly: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
180
+ }, z.core.$strip>;
181
+ /** Monthly/yearly amounts for one currency. */
182
+ export type PricingTerms = z.infer<typeof PricingTermsSchema>;
183
+ /**
184
+ * A pricing version entry: plan name (`pro` / `biz`) → currency code →
185
+ * {@link PricingTerms}.
186
+ */
187
+ export declare const PricingVersionSchema: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{
188
+ monthly: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
189
+ yearly: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
190
+ }, z.core.$strip>>>;
191
+ /** Prices for one pricing version, keyed by plan then currency. */
192
+ export type PricingVersion = z.infer<typeof PricingVersionSchema>;
193
+ /**
194
+ * Response of the `pricing` endpoint: fixed version-pointer string fields plus
195
+ * dynamic version keys (`v1`, `v2`, …), each a {@link PricingVersion}.
196
+ */
197
+ export declare const PricingResponseSchema: z.ZodObject<{
198
+ latestPro: z.ZodString;
199
+ latestBiz: z.ZodString;
200
+ sessionPro: z.ZodString;
201
+ sessionBiz: z.ZodString;
202
+ }, z.core.$catchall<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{
203
+ monthly: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
204
+ yearly: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
205
+ }, z.core.$strip>>>>>;
206
+ /** Current and legacy Pro/Teams pricing keyed by version. */
207
+ export type PricingResponse = z.infer<typeof PricingResponseSchema>;
@@ -10,6 +10,7 @@ export * from './activity/index.js';
10
10
  export * from './workspaces/index.js';
11
11
  export * from './folders/index.js';
12
12
  export * from './goals/index.js';
13
+ export * from './billing/index.js';
13
14
  export * from './insights/index.js';
14
15
  export * from './backups/index.js';
15
16
  export * from './id-mappings/index.js';
@@ -865,6 +865,65 @@ export declare const validateGoal: (input: unknown) => {
865
865
  percentage: number;
866
866
  } | undefined;
867
867
  }[];
868
+ export declare const validateSubscriptionInfo: (input: unknown) => {
869
+ status: "none" | "autorenew" | "canceled" | "expired" | "trial" | "trial_canceled";
870
+ plan: "free" | "pro" | "pro_gifted" | "pro_legacy";
871
+ expirationDate: string | null;
872
+ activationMethod: "manual" | "stripe" | "appstore" | "playstore" | "teams";
873
+ planPrice: {
874
+ amount: string;
875
+ rawAmount: number;
876
+ currency: string;
877
+ billingCycle: "monthly" | "yearly" | null;
878
+ taxBehavior: "inclusive" | "exclusive" | "unspecified";
879
+ } | null;
880
+ billingPortalUrl: string | null;
881
+ billingPortalSwitchToAnnualUrl: string | null;
882
+ hasBillingPortal: boolean;
883
+ hasBillingPortalSwitchToAnnual: boolean;
884
+ invoiceCreditBalance: Record<string, number> | null;
885
+ hasSwitchLegacyToCurrent: boolean;
886
+ };
887
+ export declare const validateProPlanDetails: (input: unknown) => {
888
+ currentPlanStatus: "Active" | "Downgraded" | "Cancelled" | "NeverSubscribed";
889
+ downgradeAt: string | null;
890
+ priceList: {
891
+ billingCycle: "monthly" | "yearly";
892
+ prices: {
893
+ currency: string;
894
+ unitAmount: number;
895
+ taxBehavior: "inclusive" | "exclusive" | "unspecified";
896
+ }[];
897
+ }[];
898
+ };
899
+ export declare const validatePrices: (input: unknown) => {
900
+ pro: {
901
+ billingCycle: "monthly" | "yearly";
902
+ prices: {
903
+ currency: string;
904
+ unitAmount: number;
905
+ taxBehavior: "inclusive" | "exclusive" | "unspecified";
906
+ }[];
907
+ }[];
908
+ teams: {
909
+ billingCycle: "monthly" | "yearly";
910
+ prices: {
911
+ currency: string;
912
+ unitAmount: number;
913
+ taxBehavior: "inclusive" | "exclusive" | "unspecified";
914
+ }[];
915
+ }[];
916
+ };
917
+ export declare const validatePricing: (input: unknown) => {
918
+ [x: string]: Record<string, Record<string, {
919
+ monthly: string | number;
920
+ yearly: string | number;
921
+ }>>;
922
+ latestPro: string;
923
+ latestBiz: string;
924
+ sessionPro: string;
925
+ sessionBiz: string;
926
+ };
868
927
  export declare const validateNote: (input: unknown) => {
869
928
  [x: string]: unknown;
870
929
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/todoist-sdk",
3
- "version": "10.2.0",
3
+ "version": "10.3.0",
4
4
  "description": "The official TypeScript SDK for the Todoist REST API.",
5
5
  "author": "Doist developers",
6
6
  "repository": "https://github.com/Doist/todoist-sdk-typescript",