@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.
@@ -30,6 +30,8 @@ exports.PERMISSIONS = [
30
30
  'data:delete',
31
31
  'project:delete',
32
32
  'backups:read',
33
+ 'billing:read',
34
+ 'billing:read_write',
33
35
  'dev:app_console',
34
36
  ];
35
37
  /** Supported token endpoint authentication methods for dynamic client registration. */
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BillingClient = void 0;
4
+ const endpoints_1 = require("../consts/endpoints");
5
+ const http_client_1 = require("../transport/http-client");
6
+ const validators_1 = require("../utils/validators");
7
+ const base_client_1 = require("./base-client");
8
+ /**
9
+ * Internal sub-client handling all billing-domain endpoints.
10
+ *
11
+ * Instantiated by `TodoistApi`; every public billing method on `TodoistApi`
12
+ * delegates here. See `todoist-api.ts` for the user-facing JSDoc.
13
+ */
14
+ class BillingClient extends base_client_1.BaseClient {
15
+ async getSubscriptionInfo() {
16
+ const response = await (0, http_client_1.request)({
17
+ httpMethod: 'POST',
18
+ baseUri: this.syncApiBase,
19
+ relativePath: endpoints_1.ENDPOINT_PAYMENTS_SUBSCRIPTION_INFO,
20
+ apiToken: this.authToken,
21
+ customFetch: this.customFetch,
22
+ });
23
+ return (0, validators_1.validateSubscriptionInfo)(response.data);
24
+ }
25
+ async cancelPlan(args, requestId) {
26
+ const response = await (0, http_client_1.request)({
27
+ httpMethod: 'POST',
28
+ baseUri: this.syncApiBase,
29
+ relativePath: endpoints_1.ENDPOINT_PAYMENTS_CANCEL_PLAN,
30
+ apiToken: this.authToken,
31
+ customFetch: this.customFetch,
32
+ payload: args,
33
+ requestId: requestId,
34
+ });
35
+ return response.data;
36
+ }
37
+ async reactivatePlan(requestId) {
38
+ const response = await (0, http_client_1.request)({
39
+ httpMethod: 'POST',
40
+ baseUri: this.syncApiBase,
41
+ relativePath: endpoints_1.ENDPOINT_PAYMENTS_REACTIVATE_PLAN,
42
+ apiToken: this.authToken,
43
+ customFetch: this.customFetch,
44
+ requestId: requestId,
45
+ });
46
+ return (0, validators_1.validateSubscriptionInfo)(response.data);
47
+ }
48
+ async upgradeToPro(args, requestId) {
49
+ const response = await (0, http_client_1.request)({
50
+ httpMethod: 'POST',
51
+ baseUri: this.syncApiBase,
52
+ relativePath: endpoints_1.ENDPOINT_PRO_UPGRADE,
53
+ apiToken: this.authToken,
54
+ customFetch: this.customFetch,
55
+ payload: args,
56
+ requestId: requestId,
57
+ });
58
+ return response.data;
59
+ }
60
+ async startProTrial(args, requestId) {
61
+ const response = await (0, http_client_1.request)({
62
+ httpMethod: 'POST',
63
+ baseUri: this.syncApiBase,
64
+ relativePath: endpoints_1.ENDPOINT_PRO_TRIAL,
65
+ apiToken: this.authToken,
66
+ customFetch: this.customFetch,
67
+ payload: args,
68
+ requestId: requestId,
69
+ });
70
+ return response.data;
71
+ }
72
+ async createProBillingPortalSession(args, requestId) {
73
+ const response = await (0, http_client_1.request)({
74
+ httpMethod: 'POST',
75
+ baseUri: this.syncApiBase,
76
+ relativePath: endpoints_1.ENDPOINT_PRO_BILLING_PORTAL,
77
+ apiToken: this.authToken,
78
+ customFetch: this.customFetch,
79
+ payload: args,
80
+ requestId: requestId,
81
+ });
82
+ return response.data;
83
+ }
84
+ async getProPlanDetails() {
85
+ const response = await (0, http_client_1.request)({
86
+ httpMethod: 'GET',
87
+ baseUri: this.syncApiBase,
88
+ relativePath: endpoints_1.ENDPOINT_PRO_PLAN_DETAILS,
89
+ apiToken: this.authToken,
90
+ customFetch: this.customFetch,
91
+ });
92
+ return (0, validators_1.validateProPlanDetails)(response.data);
93
+ }
94
+ async upgradeWorkspace(args, requestId) {
95
+ const response = await (0, http_client_1.request)({
96
+ httpMethod: 'POST',
97
+ baseUri: this.syncApiBase,
98
+ relativePath: endpoints_1.ENDPOINT_WORKSPACE_UPGRADE,
99
+ apiToken: this.authToken,
100
+ customFetch: this.customFetch,
101
+ payload: args,
102
+ requestId: requestId,
103
+ });
104
+ return response.data;
105
+ }
106
+ async startWorkspaceTrial(args, requestId) {
107
+ const response = await (0, http_client_1.request)({
108
+ httpMethod: 'POST',
109
+ baseUri: this.syncApiBase,
110
+ relativePath: endpoints_1.ENDPOINT_WORKSPACE_TRIAL,
111
+ apiToken: this.authToken,
112
+ customFetch: this.customFetch,
113
+ payload: args,
114
+ requestId: requestId,
115
+ });
116
+ return response.data;
117
+ }
118
+ async createWorkspaceBillingPortalSession(args, requestId) {
119
+ const response = await (0, http_client_1.request)({
120
+ httpMethod: 'POST',
121
+ baseUri: this.syncApiBase,
122
+ relativePath: endpoints_1.ENDPOINT_WORKSPACE_BILLING_PORTAL,
123
+ apiToken: this.authToken,
124
+ customFetch: this.customFetch,
125
+ payload: args,
126
+ requestId: requestId,
127
+ });
128
+ return response.data;
129
+ }
130
+ async getPrices() {
131
+ const response = await (0, http_client_1.request)({
132
+ httpMethod: 'GET',
133
+ baseUri: this.syncApiBase,
134
+ relativePath: endpoints_1.ENDPOINT_PRICES,
135
+ apiToken: this.authToken,
136
+ customFetch: this.customFetch,
137
+ });
138
+ return (0, validators_1.validatePrices)(response.data);
139
+ }
140
+ async getPricing(args) {
141
+ const response = await (0, http_client_1.request)({
142
+ httpMethod: 'GET',
143
+ baseUri: this.syncApiBase,
144
+ relativePath: endpoints_1.ENDPOINT_PRICING,
145
+ apiToken: this.authToken,
146
+ customFetch: this.customFetch,
147
+ payload: args,
148
+ });
149
+ return (0, validators_1.validatePricing)(response.data);
150
+ }
151
+ }
152
+ exports.BillingClient = BillingClient;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ENDPOINT_REST_ID_MAPPINGS = exports.ENDPOINT_REST_EMAILS = exports.ENDPOINT_REST_BACKUPS_DOWNLOAD = exports.ENDPOINT_REST_BACKUPS = exports.ENDPOINT_REST_ACCESS_TOKENS_MIGRATE = exports.ENDPOINT_REST_TEMPLATES_IMPORT_FROM_ID = exports.ENDPOINT_REST_TEMPLATES_IMPORT_FROM_FILE = exports.ENDPOINT_REST_TEMPLATES_CREATE_FROM_FILE = exports.ENDPOINT_REST_TEMPLATES_URL = exports.ENDPOINT_REST_TEMPLATES_FILE = exports.ENDPOINT_REST_TASKS_COMPLETED = exports.ENDPOINT_REST_PROJECTS_MOVE_TO_PERSONAL = exports.ENDPOINT_REST_PROJECTS_MOVE_TO_WORKSPACE = exports.SECTION_UNARCHIVE = exports.SECTION_ARCHIVE = exports.ENDPOINT_REST_PROJECT_JOIN = exports.ENDPOINT_REST_PROJECT_FULL = exports.ENDPOINT_REST_PROJECTS_PERMISSIONS = exports.ENDPOINT_REST_PROJECTS_ARCHIVED_COUNT = exports.PROJECT_UNARCHIVE = exports.PROJECT_ARCHIVE = exports.ENDPOINT_REST_UPLOADS = exports.ENDPOINT_REST_ACTIVITIES = exports.ENDPOINT_REST_PRODUCTIVITY = exports.ENDPOINT_REST_USER = exports.ENDPOINT_REST_PROJECT_COLLABORATORS = exports.ENDPOINT_REST_PROJECTS_ARCHIVED = exports.ENDPOINT_REST_PROJECTS_SEARCH = exports.ENDPOINT_REST_PROJECTS = exports.ENDPOINT_REST_TASK_MOVE = exports.ENDPOINT_REST_TASK_REOPEN = exports.ENDPOINT_REST_TASK_CLOSE = exports.ENDPOINT_REST_LOCATION_REMINDERS = exports.ENDPOINT_REST_REMINDERS = exports.ENDPOINT_REST_COMMENTS = exports.ENDPOINT_REST_LABELS_SHARED_REMOVE = exports.ENDPOINT_REST_LABELS_SHARED_RENAME = exports.ENDPOINT_REST_LABELS_SHARED = exports.ENDPOINT_REST_LABELS_SEARCH = exports.ENDPOINT_REST_LABELS = exports.ENDPOINT_REST_SECTIONS_SEARCH = exports.ENDPOINT_REST_SECTIONS = exports.ENDPOINT_REST_TASKS_COMPLETED_SEARCH = exports.ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE = exports.ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE = exports.ENDPOINT_REST_TASKS_FILTER = exports.ENDPOINT_REST_TASKS = exports.API_BASE_URI = exports.API_VERSION = exports.TODOIST_WEB_URI = void 0;
4
- exports.APP_ICON_SIZES = exports.ENDPOINT_REST_USER_AUTHORIZATIONS_DELETE = exports.ENDPOINT_REST_USER_AUTHORIZATIONS = exports.ENDPOINT_REST_APPS_UI_EXTENSIONS_INSTALLED = exports.ENDPOINT_REST_APPS_UI_EXTENSIONS = exports.ENDPOINT_REST_APPS_INSTALLATIONS = exports.ENDPOINT_REST_APPS = exports.ENDPOINT_WORKSPACE_MEMBERS = exports.ENDPOINT_WORKSPACE_USERS = exports.ENDPOINT_WORKSPACE_PLAN_DETAILS = exports.ENDPOINT_WORKSPACE_LOGO = exports.ENDPOINT_WORKSPACE_JOIN = exports.ENDPOINT_WORKSPACE_INVITATIONS_DELETE = exports.ENDPOINT_WORKSPACE_INVITATIONS_ALL = exports.ENDPOINT_WORKSPACE_INVITATIONS = exports.ENDPOINT_REST_WORKSPACES = exports.GOAL_TASKS = exports.GOAL_UNCOMPLETE = exports.GOAL_COMPLETE = exports.ENDPOINT_REST_GOALS_SEARCH = exports.ENDPOINT_REST_GOALS = exports.ENDPOINT_REST_FOLDERS = exports.ENDPOINT_REGISTER = exports.ENDPOINT_REVOKE = exports.ENDPOINT_GET_TOKEN = exports.ENDPOINT_AUTHORIZATION = exports.ENDPOINT_SYNC = exports.ENDPOINT_SYNC_QUICK_ADD = exports.ENDPOINT_REST_MOVED_IDS = void 0;
4
+ exports.APP_ICON_SIZES = exports.ENDPOINT_REST_USER_AUTHORIZATIONS_DELETE = exports.ENDPOINT_REST_USER_AUTHORIZATIONS = exports.ENDPOINT_REST_APPS_UI_EXTENSIONS_INSTALLED = exports.ENDPOINT_REST_APPS_UI_EXTENSIONS = exports.ENDPOINT_REST_APPS_INSTALLATIONS = exports.ENDPOINT_REST_APPS = exports.ENDPOINT_WORKSPACE_MEMBERS = exports.ENDPOINT_PRICING = exports.ENDPOINT_PRICES = exports.ENDPOINT_WORKSPACE_BILLING_PORTAL = exports.ENDPOINT_WORKSPACE_TRIAL = exports.ENDPOINT_WORKSPACE_UPGRADE = exports.ENDPOINT_PRO_PLAN_DETAILS = exports.ENDPOINT_PRO_BILLING_PORTAL = exports.ENDPOINT_PRO_TRIAL = exports.ENDPOINT_PRO_UPGRADE = exports.ENDPOINT_PAYMENTS_REACTIVATE_PLAN = exports.ENDPOINT_PAYMENTS_CANCEL_PLAN = exports.ENDPOINT_PAYMENTS_SUBSCRIPTION_INFO = exports.ENDPOINT_WORKSPACE_USERS = exports.ENDPOINT_WORKSPACE_PLAN_DETAILS = exports.ENDPOINT_WORKSPACE_LOGO = exports.ENDPOINT_WORKSPACE_JOIN = exports.ENDPOINT_WORKSPACE_INVITATIONS_DELETE = exports.ENDPOINT_WORKSPACE_INVITATIONS_ALL = exports.ENDPOINT_WORKSPACE_INVITATIONS = exports.ENDPOINT_REST_WORKSPACES = exports.GOAL_TASKS = exports.GOAL_UNCOMPLETE = exports.GOAL_COMPLETE = exports.ENDPOINT_REST_GOALS_SEARCH = exports.ENDPOINT_REST_GOALS = exports.ENDPOINT_REST_FOLDERS = exports.ENDPOINT_REGISTER = exports.ENDPOINT_REVOKE = exports.ENDPOINT_GET_TOKEN = exports.ENDPOINT_AUTHORIZATION = exports.ENDPOINT_SYNC = exports.ENDPOINT_SYNC_QUICK_ADD = exports.ENDPOINT_REST_MOVED_IDS = void 0;
5
5
  exports.getSyncBaseUri = getSyncBaseUri;
6
6
  exports.getApiRootBaseUri = getApiRootBaseUri;
7
7
  exports.getAuthBaseUri = getAuthBaseUri;
@@ -118,6 +118,19 @@ exports.ENDPOINT_WORKSPACE_JOIN = 'workspaces/join';
118
118
  exports.ENDPOINT_WORKSPACE_LOGO = 'workspaces/logo';
119
119
  exports.ENDPOINT_WORKSPACE_PLAN_DETAILS = 'workspaces/plan_details';
120
120
  exports.ENDPOINT_WORKSPACE_USERS = 'workspaces/users';
121
+ // Billing endpoints
122
+ exports.ENDPOINT_PAYMENTS_SUBSCRIPTION_INFO = 'payments/get_subscription_info';
123
+ exports.ENDPOINT_PAYMENTS_CANCEL_PLAN = 'payments/cancel_plan_with_redirect_to_stripe';
124
+ exports.ENDPOINT_PAYMENTS_REACTIVATE_PLAN = 'payments/reactivate_plan';
125
+ exports.ENDPOINT_PRO_UPGRADE = 'pro/upgrade';
126
+ exports.ENDPOINT_PRO_TRIAL = 'pro/trial';
127
+ exports.ENDPOINT_PRO_BILLING_PORTAL = 'pro/billing_portal';
128
+ exports.ENDPOINT_PRO_PLAN_DETAILS = 'pro/plan_details';
129
+ exports.ENDPOINT_WORKSPACE_UPGRADE = 'workspaces/upgrade';
130
+ exports.ENDPOINT_WORKSPACE_TRIAL = 'workspaces/trial';
131
+ exports.ENDPOINT_WORKSPACE_BILLING_PORTAL = 'workspaces/billing_portal';
132
+ exports.ENDPOINT_PRICES = 'prices';
133
+ exports.ENDPOINT_PRICING = 'pricing';
121
134
  // Workspace invitation actions (require invite_code parameter)
122
135
  function getWorkspaceInvitationAcceptEndpoint(inviteCode) {
123
136
  return `workspaces/invitations/${inviteCode}/accept`;
@@ -4,6 +4,7 @@ exports.TodoistApi = void 0;
4
4
  const activity_client_1 = require("./clients/activity-client");
5
5
  const app_client_1 = require("./clients/app-client");
6
6
  const backup_client_1 = require("./clients/backup-client");
7
+ const billing_client_1 = require("./clients/billing-client");
7
8
  const comment_client_1 = require("./clients/comment-client");
8
9
  const email_client_1 = require("./clients/email-client");
9
10
  const folder_client_1 = require("./clients/folder-client");
@@ -63,6 +64,7 @@ class TodoistApi {
63
64
  this.productivityClient = new productivity_client_1.ProductivityClient(clientDeps);
64
65
  this.workspaceClient = new workspace_client_1.WorkspaceClient(clientDeps);
65
66
  this.goalsClient = new goals_client_1.GoalsClient(clientDeps);
67
+ this.billingClient = new billing_client_1.BillingClient(clientDeps);
66
68
  this.appClient = new app_client_1.AppClient(clientDeps);
67
69
  this.uiExtensionClient = new ui_extension_client_1.UiExtensionClient(clientDeps);
68
70
  }
@@ -1043,6 +1045,143 @@ class TodoistApi {
1043
1045
  async unlinkTaskFromGoal(args, requestId) {
1044
1046
  return this.goalsClient.unlinkTaskFromGoal(args, requestId);
1045
1047
  }
1048
+ // ── Billing ──
1049
+ /**
1050
+ * Retrieves the current user's subscription state.
1051
+ *
1052
+ * Requires the `billing:read` scope.
1053
+ *
1054
+ * @returns A promise that resolves to the user's subscription info.
1055
+ */
1056
+ async getSubscriptionInfo() {
1057
+ return this.billingClient.getSubscriptionInfo();
1058
+ }
1059
+ /**
1060
+ * Starts a hosted cancellation flow for the current user's plan.
1061
+ *
1062
+ * Requires the `billing:read_write` scope.
1063
+ *
1064
+ * @param args - Optional cancellation reason details and return URL.
1065
+ * @param requestId - Optional custom identifier for the request.
1066
+ * @returns A promise that resolves to the billing portal redirect URL.
1067
+ */
1068
+ async cancelPlan(args, requestId) {
1069
+ return this.billingClient.cancelPlan(args, requestId);
1070
+ }
1071
+ /**
1072
+ * Reactivates a previously canceled subscription.
1073
+ *
1074
+ * Requires the `billing:read_write` scope.
1075
+ *
1076
+ * @param requestId - Optional custom identifier for the request.
1077
+ * @returns A promise that resolves to the fresh subscription info after reactivation.
1078
+ */
1079
+ async reactivatePlan(requestId) {
1080
+ return this.billingClient.reactivatePlan(requestId);
1081
+ }
1082
+ /**
1083
+ * Creates a Stripe checkout session to upgrade the current user to Pro.
1084
+ *
1085
+ * Requires the `billing:read_write` scope.
1086
+ *
1087
+ * @param args - Currency, billing cycle, redirect URLs, and optional promotion/trial details.
1088
+ * @param requestId - Optional custom identifier for the request.
1089
+ * @returns A promise that resolves to the checkout session URL.
1090
+ */
1091
+ async upgradeToPro(args, requestId) {
1092
+ return this.billingClient.upgradeToPro(args, requestId);
1093
+ }
1094
+ /**
1095
+ * Creates a Stripe checkout session to start a Pro trial.
1096
+ *
1097
+ * Requires the `billing:read_write` scope.
1098
+ *
1099
+ * @param args - Currency, billing cycle, and redirect URLs.
1100
+ * @param requestId - Optional custom identifier for the request.
1101
+ * @returns A promise that resolves to the checkout session URL.
1102
+ */
1103
+ async startProTrial(args, requestId) {
1104
+ return this.billingClient.startProTrial(args, requestId);
1105
+ }
1106
+ /**
1107
+ * Creates a one-time Stripe billing portal session for the current user's Pro plan.
1108
+ *
1109
+ * Requires the `billing:read_write` scope.
1110
+ *
1111
+ * @param args - Return URL and optional flow type / promotion code.
1112
+ * @param requestId - Optional custom identifier for the request.
1113
+ * @returns A promise that resolves to the billing portal URL.
1114
+ */
1115
+ async createProBillingPortalSession(args, requestId) {
1116
+ return this.billingClient.createProBillingPortalSession(args, requestId);
1117
+ }
1118
+ /**
1119
+ * Retrieves the current user's Pro plan and billing details.
1120
+ *
1121
+ * Requires the `billing:read` scope.
1122
+ *
1123
+ * @returns A promise that resolves to the Pro plan details.
1124
+ */
1125
+ async getProPlanDetails() {
1126
+ return this.billingClient.getProPlanDetails();
1127
+ }
1128
+ /**
1129
+ * Creates a Stripe checkout session to upgrade a workspace.
1130
+ *
1131
+ * Requires the `billing:read_write` scope.
1132
+ *
1133
+ * @param args - Workspace ID, currency, billing cycle, redirect URLs, and optional promotion details.
1134
+ * @param requestId - Optional custom identifier for the request.
1135
+ * @returns A promise that resolves to the checkout session URL.
1136
+ */
1137
+ async upgradeWorkspace(args, requestId) {
1138
+ return this.billingClient.upgradeWorkspace(args, requestId);
1139
+ }
1140
+ /**
1141
+ * Creates a Stripe checkout session to start a workspace trial.
1142
+ *
1143
+ * Requires the `billing:read_write` scope.
1144
+ *
1145
+ * @param args - Workspace ID, currency, billing cycle, and redirect URLs.
1146
+ * @param requestId - Optional custom identifier for the request.
1147
+ * @returns A promise that resolves to the checkout session URL.
1148
+ */
1149
+ async startWorkspaceTrial(args, requestId) {
1150
+ return this.billingClient.startWorkspaceTrial(args, requestId);
1151
+ }
1152
+ /**
1153
+ * Creates a one-time Stripe billing portal session for a workspace.
1154
+ *
1155
+ * Requires the `billing:read_write` scope.
1156
+ *
1157
+ * @param args - Workspace ID, return URL, and optional flow type.
1158
+ * @param requestId - Optional custom identifier for the request.
1159
+ * @returns A promise that resolves to the billing portal URL.
1160
+ */
1161
+ async createWorkspaceBillingPortalSession(args, requestId) {
1162
+ return this.billingClient.createWorkspaceBillingPortalSession(args, requestId);
1163
+ }
1164
+ /**
1165
+ * Retrieves available Pro and Teams prices.
1166
+ *
1167
+ * Requires the `billing:read` scope.
1168
+ *
1169
+ * @returns A promise that resolves to the available prices.
1170
+ */
1171
+ async getPrices() {
1172
+ return this.billingClient.getPrices();
1173
+ }
1174
+ /**
1175
+ * Retrieves pricing information.
1176
+ *
1177
+ * Requires the `billing:read` scope.
1178
+ *
1179
+ * @param args - Optional flag to request formatted pricing.
1180
+ * @returns A promise that resolves to current and legacy pricing keyed by version.
1181
+ */
1182
+ async getPricing(args) {
1183
+ return this.billingClient.getPricing(args);
1184
+ }
1046
1185
  // ── Backups ──
1047
1186
  /**
1048
1187
  * Retrieves a list of available backups.
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./requests"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PricingResponseSchema = exports.PricingVersionSchema = exports.PricingTermsSchema = exports.PricesResponseSchema = exports.ProPlanDetailsSchema = exports.PriceListingSchema = exports.FormattedPriceSchema = exports.SubscriptionInfoSchema = exports.BillingPlanPriceSchema = exports.TAX_BEHAVIORS = exports.BILLING_CYCLES = exports.BILLING_ACTIVATION_METHODS = exports.BILLING_PLANS = exports.BILLING_SUBSCRIPTION_STATUSES = void 0;
4
+ const zod_1 = require("zod");
5
+ const types_1 = require("../workspaces/types");
6
+ /** Available subscription statuses. */
7
+ exports.BILLING_SUBSCRIPTION_STATUSES = [
8
+ 'none',
9
+ 'autorenew',
10
+ 'canceled',
11
+ 'expired',
12
+ 'trial',
13
+ 'trial_canceled',
14
+ ];
15
+ /** Available plan tiers. */
16
+ exports.BILLING_PLANS = ['free', 'pro', 'pro_gifted', 'pro_legacy'];
17
+ /** Ways an active subscription can be purchased. */
18
+ exports.BILLING_ACTIVATION_METHODS = [
19
+ 'stripe',
20
+ 'appstore',
21
+ 'playstore',
22
+ 'teams',
23
+ 'manual',
24
+ ];
25
+ /** Available billing cycles. */
26
+ exports.BILLING_CYCLES = ['monthly', 'yearly'];
27
+ /** Available tax behaviors for a price. */
28
+ exports.TAX_BEHAVIORS = ['exclusive', 'inclusive', 'unspecified'];
29
+ exports.BillingPlanPriceSchema = zod_1.z.object({
30
+ amount: zod_1.z.string(),
31
+ rawAmount: zod_1.z.number(),
32
+ currency: zod_1.z.string(),
33
+ billingCycle: zod_1.z.enum(exports.BILLING_CYCLES).nullable(),
34
+ taxBehavior: zod_1.z.enum(exports.TAX_BEHAVIORS),
35
+ });
36
+ exports.SubscriptionInfoSchema = zod_1.z.object({
37
+ status: zod_1.z.enum(exports.BILLING_SUBSCRIPTION_STATUSES),
38
+ plan: zod_1.z.enum(exports.BILLING_PLANS),
39
+ expirationDate: zod_1.z.string().nullable(),
40
+ activationMethod: zod_1.z.enum(exports.BILLING_ACTIVATION_METHODS),
41
+ planPrice: exports.BillingPlanPriceSchema.nullable(),
42
+ billingPortalUrl: zod_1.z.string().nullable(),
43
+ billingPortalSwitchToAnnualUrl: zod_1.z.string().nullable(),
44
+ hasBillingPortal: zod_1.z.boolean(),
45
+ hasBillingPortalSwitchToAnnual: zod_1.z.boolean(),
46
+ invoiceCreditBalance: zod_1.z.record(zod_1.z.string(), zod_1.z.number().int()).nullable(),
47
+ hasSwitchLegacyToCurrent: zod_1.z.boolean(),
48
+ });
49
+ exports.FormattedPriceSchema = zod_1.z.object({
50
+ currency: zod_1.z.string(),
51
+ unitAmount: zod_1.z.number().int(),
52
+ taxBehavior: zod_1.z.enum(exports.TAX_BEHAVIORS),
53
+ });
54
+ exports.PriceListingSchema = zod_1.z.object({
55
+ billingCycle: zod_1.z.enum(exports.BILLING_CYCLES),
56
+ prices: zod_1.z.array(exports.FormattedPriceSchema),
57
+ });
58
+ exports.ProPlanDetailsSchema = zod_1.z.object({
59
+ currentPlanStatus: zod_1.z.enum(types_1.WORKSPACE_PLAN_STATUSES),
60
+ downgradeAt: zod_1.z.string().nullable(),
61
+ priceList: zod_1.z.array(exports.PriceListingSchema),
62
+ });
63
+ exports.PricesResponseSchema = zod_1.z.object({
64
+ pro: zod_1.z.array(exports.PriceListingSchema),
65
+ teams: zod_1.z.array(exports.PriceListingSchema),
66
+ });
67
+ /**
68
+ * Monthly and yearly amounts for a single currency. Each amount is a number in
69
+ * the currency's smallest unit, or a localized formatted string when the
70
+ * `pricing` endpoint is called with `formatted: true`.
71
+ */
72
+ exports.PricingTermsSchema = zod_1.z.object({
73
+ monthly: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]),
74
+ yearly: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]),
75
+ });
76
+ /**
77
+ * A pricing version entry: plan name (`pro` / `biz`) → currency code →
78
+ * {@link PricingTerms}.
79
+ */
80
+ exports.PricingVersionSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.record(zod_1.z.string(), exports.PricingTermsSchema));
81
+ /**
82
+ * Response of the `pricing` endpoint: fixed version-pointer string fields plus
83
+ * dynamic version keys (`v1`, `v2`, …), each a {@link PricingVersion}.
84
+ */
85
+ exports.PricingResponseSchema = zod_1.z
86
+ .object({
87
+ latestPro: zod_1.z.string(),
88
+ latestBiz: zod_1.z.string(),
89
+ sessionPro: zod_1.z.string(),
90
+ sessionBiz: zod_1.z.string(),
91
+ })
92
+ .catchall(exports.PricingVersionSchema);
@@ -26,6 +26,7 @@ __exportStar(require("./activity"), exports);
26
26
  __exportStar(require("./workspaces"), exports);
27
27
  __exportStar(require("./folders"), exports);
28
28
  __exportStar(require("./goals"), exports);
29
+ __exportStar(require("./billing"), exports);
29
30
  __exportStar(require("./insights"), exports);
30
31
  __exportStar(require("./backups"), exports);
31
32
  __exportStar(require("./id-mappings"), exports);
@@ -2,25 +2,27 @@
2
2
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.validateFolder = exports.validateCollaboratorStateArray = exports.validateCollaboratorState = exports.validateCollaboratorArray = exports.validateCollaborator = exports.validateFilterArray = exports.validateFilter = exports.validateMovedIdArray = exports.validateMovedId = exports.validateIdMappingArray = exports.validateIdMapping = exports.validateBackupArray = exports.validateBackup = exports.validateWorkspaceInsights = exports.validateProjectProgress = exports.validateProjectHealthContext = exports.validateProjectHealth = exports.validateProjectActivityStats = exports.validateWorkspaceUserTaskArray = exports.validateWorkspaceUserTask = exports.validateMemberActivityInfoArray = exports.validateMemberActivityInfo = exports.validateWorkspaceArray = exports.validateWorkspace = exports.validateJoinWorkspaceResult = exports.validateWorkspacePlanDetails = exports.validateWorkspaceInvitationArray = exports.validateWorkspaceInvitation = exports.validateWorkspaceUserArray = exports.validateWorkspaceUser = exports.validateAttachment = exports.validateActivityEventArray = exports.validateActivityEvent = exports.validateCurrentUser = exports.validateProductivityStats = exports.validateUserArray = exports.validateUser = exports.validateCommentArray = exports.validateComment = exports.validateLabelArray = exports.validateLabel = exports.validateSectionArray = exports.validateSection = exports.validateWorkspaceProjectArray = exports.validateWorkspaceProject = exports.validateProjectArray = exports.validateProject = exports.validateTaskArray = exports.validateTask = exports.IdSchema = void 0;
5
- exports.validateUiExtensionArray = exports.validateUiExtension = exports.validateUserAuthorizationArray = exports.validateUserAuthorization = exports.validateAppInstallationArray = exports.validateAppInstallation = exports.validateAppWebhook = exports.validateAppByDistributionToken = exports.validateAppDistributionToken = exports.validateAppTestToken = exports.validateAppVerificationToken = exports.validateAppSecrets = exports.validateAppWithUserCount = exports.validateAppArray = exports.validateApp = exports.validateSuggestionArray = exports.validateSuggestion = exports.validateUserSettings = exports.validateSyncUser = exports.validateSyncWorkspaceArray = exports.validateSyncWorkspace = exports.validateLiveNotificationArray = exports.validateLiveNotification = exports.validateUserPlanLimits = exports.validateProjectViewOptionsDefaultsArray = exports.validateProjectViewOptionsDefaults = exports.validateViewOptionsArray = exports.validateViewOptions = exports.validateCompletedInfoArray = exports.validateCompletedInfo = exports.validateLocationReminderArray = exports.validateLocationReminder = exports.validateReminderArray = exports.validateReminder = exports.validateCalendarAccountArray = exports.validateCalendarAccount = exports.validateCalendarArray = exports.validateCalendar = exports.validateWorkspaceGoalArray = exports.validateWorkspaceGoal = exports.validateWorkspaceFilterArray = exports.validateWorkspaceFilter = exports.validateTooltips = exports.validateNoteArray = exports.validateNote = exports.validateGoalArray = exports.validateGoal = exports.validateFolderArray = void 0;
5
+ exports.validateUserAuthorizationArray = exports.validateUserAuthorization = exports.validateAppInstallationArray = exports.validateAppInstallation = exports.validateAppWebhook = exports.validateAppByDistributionToken = exports.validateAppDistributionToken = exports.validateAppTestToken = exports.validateAppVerificationToken = exports.validateAppSecrets = exports.validateAppWithUserCount = exports.validateAppArray = exports.validateApp = exports.validateSuggestionArray = exports.validateSuggestion = exports.validateUserSettings = exports.validateSyncUser = exports.validateSyncWorkspaceArray = exports.validateSyncWorkspace = exports.validateLiveNotificationArray = exports.validateLiveNotification = exports.validateUserPlanLimits = exports.validateProjectViewOptionsDefaultsArray = exports.validateProjectViewOptionsDefaults = exports.validateViewOptionsArray = exports.validateViewOptions = exports.validateCompletedInfoArray = exports.validateCompletedInfo = exports.validateLocationReminderArray = exports.validateLocationReminder = exports.validateReminderArray = exports.validateReminder = exports.validateCalendarAccountArray = exports.validateCalendarAccount = exports.validateCalendarArray = exports.validateCalendar = exports.validateWorkspaceGoalArray = exports.validateWorkspaceGoal = exports.validateWorkspaceFilterArray = exports.validateWorkspaceFilter = exports.validateTooltips = exports.validateNoteArray = exports.validateNote = exports.validatePricing = exports.validatePrices = exports.validateProPlanDetails = exports.validateSubscriptionInfo = exports.validateGoalArray = exports.validateGoal = exports.validateFolderArray = void 0;
6
+ exports.validateUiExtensionArray = exports.validateUiExtension = void 0;
6
7
  exports.parseSyncResponse = parseSyncResponse;
7
8
  const zod_1 = require("zod");
8
9
  const types_1 = require("../types/activity/types");
9
10
  const types_2 = require("../types/apps/types");
10
11
  const types_3 = require("../types/backups/types");
11
- const types_4 = require("../types/comments/types");
12
- const types_5 = require("../types/goals/types");
13
- const types_6 = require("../types/id-mappings/types");
14
- const types_7 = require("../types/insights/types");
15
- const types_8 = require("../types/labels/types");
16
- const types_9 = require("../types/productivity/types");
17
- const types_10 = require("../types/projects/types");
18
- const types_11 = require("../types/sections/types");
12
+ const types_4 = require("../types/billing/types");
13
+ const types_5 = require("../types/comments/types");
14
+ const types_6 = require("../types/goals/types");
15
+ const types_7 = require("../types/id-mappings/types");
16
+ const types_8 = require("../types/insights/types");
17
+ const types_9 = require("../types/labels/types");
18
+ const types_10 = require("../types/productivity/types");
19
+ const types_11 = require("../types/projects/types");
20
+ const types_12 = require("../types/sections/types");
19
21
  const response_1 = require("../types/sync/response");
20
- const types_12 = require("../types/tasks/types");
21
- const types_13 = require("../types/ui-extensions/types");
22
- const types_14 = require("../types/users/types");
23
- const types_15 = require("../types/workspaces/types");
22
+ const types_13 = require("../types/tasks/types");
23
+ const types_14 = require("../types/ui-extensions/types");
24
+ const types_15 = require("../types/users/types");
25
+ const types_16 = require("../types/workspaces/types");
24
26
  const resources_1 = require("../types/sync/resources");
25
27
  function createValidator(schema) {
26
28
  return {
@@ -34,43 +36,48 @@ exports.IdSchema = zod_1.z
34
36
  .min(1)
35
37
  .refine((id) => !id.startsWith('tmp-'), { message: TMP_ID_MESSAGE });
36
38
  // Entity validators
37
- _a = createValidator(types_12.TaskSchema), exports.validateTask = _a.validate, exports.validateTaskArray = _a.validateArray;
39
+ _a = createValidator(types_13.TaskSchema), exports.validateTask = _a.validate, exports.validateTaskArray = _a.validateArray;
38
40
  /**
39
41
  * Validates and parses a project input.
40
42
  * @param input The input to validate
41
43
  * @returns A validated project (either PersonalProject or WorkspaceProject)
42
44
  */
43
- _b = createValidator(types_10.ProjectSchema), exports.validateProject = _b.validate, exports.validateProjectArray = _b.validateArray;
44
- _c = createValidator(types_10.WorkspaceProjectSchema), exports.validateWorkspaceProject = _c.validate, exports.validateWorkspaceProjectArray = _c.validateArray;
45
- _d = createValidator(types_11.SectionSchema), exports.validateSection = _d.validate, exports.validateSectionArray = _d.validateArray;
46
- _e = createValidator(types_8.LabelSchema), exports.validateLabel = _e.validate, exports.validateLabelArray = _e.validateArray;
47
- _f = createValidator(types_4.CommentSchema), exports.validateComment = _f.validate, exports.validateCommentArray = _f.validateArray;
48
- _g = createValidator(types_14.UserSchema), exports.validateUser = _g.validate, exports.validateUserArray = _g.validateArray;
49
- exports.validateProductivityStats = createValidator(types_9.ProductivityStatsSchema).validate;
50
- exports.validateCurrentUser = createValidator(types_14.CurrentUserSchema).validate;
45
+ _b = createValidator(types_11.ProjectSchema), exports.validateProject = _b.validate, exports.validateProjectArray = _b.validateArray;
46
+ _c = createValidator(types_11.WorkspaceProjectSchema), exports.validateWorkspaceProject = _c.validate, exports.validateWorkspaceProjectArray = _c.validateArray;
47
+ _d = createValidator(types_12.SectionSchema), exports.validateSection = _d.validate, exports.validateSectionArray = _d.validateArray;
48
+ _e = createValidator(types_9.LabelSchema), exports.validateLabel = _e.validate, exports.validateLabelArray = _e.validateArray;
49
+ _f = createValidator(types_5.CommentSchema), exports.validateComment = _f.validate, exports.validateCommentArray = _f.validateArray;
50
+ _g = createValidator(types_15.UserSchema), exports.validateUser = _g.validate, exports.validateUserArray = _g.validateArray;
51
+ exports.validateProductivityStats = createValidator(types_10.ProductivityStatsSchema).validate;
52
+ exports.validateCurrentUser = createValidator(types_15.CurrentUserSchema).validate;
51
53
  _h = createValidator(types_1.ActivityEventSchema), exports.validateActivityEvent = _h.validate, exports.validateActivityEventArray = _h.validateArray;
52
- exports.validateAttachment = createValidator(types_4.AttachmentSchema).validate;
53
- _j = createValidator(types_15.WorkspaceUserSchema), exports.validateWorkspaceUser = _j.validate, exports.validateWorkspaceUserArray = _j.validateArray;
54
- _k = createValidator(types_15.WorkspaceInvitationSchema), exports.validateWorkspaceInvitation = _k.validate, exports.validateWorkspaceInvitationArray = _k.validateArray;
55
- exports.validateWorkspacePlanDetails = createValidator(types_15.WorkspacePlanDetailsSchema).validate;
56
- exports.validateJoinWorkspaceResult = createValidator(types_15.JoinWorkspaceResultSchema).validate;
57
- _l = createValidator(types_15.WorkspaceSchema), exports.validateWorkspace = _l.validate, exports.validateWorkspaceArray = _l.validateArray;
58
- _m = createValidator(types_15.MemberActivityInfoSchema), exports.validateMemberActivityInfo = _m.validate, exports.validateMemberActivityInfoArray = _m.validateArray;
59
- _o = createValidator(types_15.WorkspaceUserTaskSchema), exports.validateWorkspaceUserTask = _o.validate, exports.validateWorkspaceUserTaskArray = _o.validateArray;
60
- exports.validateProjectActivityStats = createValidator(types_7.ProjectActivityStatsSchema).validate;
61
- exports.validateProjectHealth = createValidator(types_7.ProjectHealthSchema).validate;
62
- exports.validateProjectHealthContext = createValidator(types_7.ProjectHealthContextSchema).validate;
63
- exports.validateProjectProgress = createValidator(types_7.ProjectProgressSchema).validate;
64
- exports.validateWorkspaceInsights = createValidator(types_7.WorkspaceInsightsSchema).validate;
54
+ exports.validateAttachment = createValidator(types_5.AttachmentSchema).validate;
55
+ _j = createValidator(types_16.WorkspaceUserSchema), exports.validateWorkspaceUser = _j.validate, exports.validateWorkspaceUserArray = _j.validateArray;
56
+ _k = createValidator(types_16.WorkspaceInvitationSchema), exports.validateWorkspaceInvitation = _k.validate, exports.validateWorkspaceInvitationArray = _k.validateArray;
57
+ exports.validateWorkspacePlanDetails = createValidator(types_16.WorkspacePlanDetailsSchema).validate;
58
+ exports.validateJoinWorkspaceResult = createValidator(types_16.JoinWorkspaceResultSchema).validate;
59
+ _l = createValidator(types_16.WorkspaceSchema), exports.validateWorkspace = _l.validate, exports.validateWorkspaceArray = _l.validateArray;
60
+ _m = createValidator(types_16.MemberActivityInfoSchema), exports.validateMemberActivityInfo = _m.validate, exports.validateMemberActivityInfoArray = _m.validateArray;
61
+ _o = createValidator(types_16.WorkspaceUserTaskSchema), exports.validateWorkspaceUserTask = _o.validate, exports.validateWorkspaceUserTaskArray = _o.validateArray;
62
+ exports.validateProjectActivityStats = createValidator(types_8.ProjectActivityStatsSchema).validate;
63
+ exports.validateProjectHealth = createValidator(types_8.ProjectHealthSchema).validate;
64
+ exports.validateProjectHealthContext = createValidator(types_8.ProjectHealthContextSchema).validate;
65
+ exports.validateProjectProgress = createValidator(types_8.ProjectProgressSchema).validate;
66
+ exports.validateWorkspaceInsights = createValidator(types_8.WorkspaceInsightsSchema).validate;
65
67
  _p = createValidator(types_3.BackupSchema), exports.validateBackup = _p.validate, exports.validateBackupArray = _p.validateArray;
66
- _q = createValidator(types_6.IdMappingSchema), exports.validateIdMapping = _q.validate, exports.validateIdMappingArray = _q.validateArray;
67
- _r = createValidator(types_6.MovedIdSchema), exports.validateMovedId = _r.validate, exports.validateMovedIdArray = _r.validateArray;
68
+ _q = createValidator(types_7.IdMappingSchema), exports.validateIdMapping = _q.validate, exports.validateIdMappingArray = _q.validateArray;
69
+ _r = createValidator(types_7.MovedIdSchema), exports.validateMovedId = _r.validate, exports.validateMovedIdArray = _r.validateArray;
68
70
  // Sync resource validators
69
71
  _s = createValidator(resources_1.FilterSchema), exports.validateFilter = _s.validate, exports.validateFilterArray = _s.validateArray;
70
72
  _t = createValidator(resources_1.CollaboratorSchema), exports.validateCollaborator = _t.validate, exports.validateCollaboratorArray = _t.validateArray;
71
73
  _u = createValidator(resources_1.CollaboratorStateSchema), exports.validateCollaboratorState = _u.validate, exports.validateCollaboratorStateArray = _u.validateArray;
72
74
  _v = createValidator(resources_1.FolderSchema), exports.validateFolder = _v.validate, exports.validateFolderArray = _v.validateArray;
73
- _w = createValidator(types_5.GoalSchema), exports.validateGoal = _w.validate, exports.validateGoalArray = _w.validateArray;
75
+ _w = createValidator(types_6.GoalSchema), exports.validateGoal = _w.validate, exports.validateGoalArray = _w.validateArray;
76
+ // Billing validators
77
+ exports.validateSubscriptionInfo = createValidator(types_4.SubscriptionInfoSchema).validate;
78
+ exports.validateProPlanDetails = createValidator(types_4.ProPlanDetailsSchema).validate;
79
+ exports.validatePrices = createValidator(types_4.PricesResponseSchema).validate;
80
+ exports.validatePricing = createValidator(types_4.PricingResponseSchema).validate;
74
81
  _x = createValidator(resources_1.NoteSchema), exports.validateNote = _x.validate, exports.validateNoteArray = _x.validateArray;
75
82
  exports.validateTooltips = createValidator(resources_1.TooltipsSchema).validate;
76
83
  _y = createValidator(resources_1.WorkspaceFilterSchema), exports.validateWorkspaceFilter = _y.validate, exports.validateWorkspaceFilterArray = _y.validateArray;
@@ -102,4 +109,4 @@ exports.validateAppByDistributionToken = createValidator(types_2.AppByDistributi
102
109
  exports.validateAppWebhook = createValidator(types_2.AppWebhookSchema).validate;
103
110
  _11 = createValidator(types_2.AppInstallationSchema), exports.validateAppInstallation = _11.validate, exports.validateAppInstallationArray = _11.validateArray;
104
111
  _12 = createValidator(types_2.UserAuthorizationSchema), exports.validateUserAuthorization = _12.validate, exports.validateUserAuthorizationArray = _12.validateArray;
105
- _13 = createValidator(types_13.UiExtensionSchema), exports.validateUiExtension = _13.validate, exports.validateUiExtensionArray = _13.validateArray;
112
+ _13 = createValidator(types_14.UiExtensionSchema), exports.validateUiExtension = _13.validate, exports.validateUiExtensionArray = _13.validateArray;
@@ -21,6 +21,8 @@ export const PERMISSIONS = [
21
21
  'data:delete',
22
22
  'project:delete',
23
23
  'backups:read',
24
+ 'billing:read',
25
+ 'billing:read_write',
24
26
  'dev:app_console',
25
27
  ];
26
28
  /** Supported token endpoint authentication methods for dynamic client registration. */