@taskforcehq/taskforce 0.3.301 → 0.3.303

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.
Files changed (171) hide show
  1. package/dist/Taskforce.module.css +37 -2
  2. package/dist/TaskforceCore.filter-persistence.test.js +1 -1
  3. package/dist/TaskforceCore.js +72 -33
  4. package/dist/TaskforceCore.test.js +848 -130
  5. package/dist/components/features/TaskSettings.js +14 -82
  6. package/dist/components/features/TaskSettings.test.js +33 -70
  7. package/dist/components/features/settings/TaxonomyLibraryManager.js +8 -2
  8. package/dist/components/features/settings/TaxonomyLibraryManager.test.js +1 -1
  9. package/dist/components/task/TaskActionHeader.js +6 -3
  10. package/dist/components/task/TaskCard.js +6 -3
  11. package/dist/components/task/TaskForm.js +2 -2
  12. package/dist/components/task/TaskForm.test.js +41 -2
  13. package/dist/components/task/TaskKanban.test.js +17 -0
  14. package/dist/components/ui/ReferenceBadgeButton.js +1 -1
  15. package/dist/components/views/PlansPage.d.ts +3 -1
  16. package/dist/components/views/PlansPage.js +109 -49
  17. package/dist/components/views/PlansPage.test.d.ts +1 -0
  18. package/dist/components/views/PlansPage.test.js +100 -0
  19. package/dist/components/views/StandaloneLayout.d.ts +1 -0
  20. package/dist/components/views/StandaloneLayout.js +473 -256
  21. package/dist/components/views/panels/PlanningDrawer.js +18 -1
  22. package/dist/components/views/standalone/modals/AccountHubModal.d.ts +48 -0
  23. package/dist/components/views/standalone/modals/AccountHubModal.js +36 -0
  24. package/dist/components/views/standalone/modals/AccountHubModal.test.d.ts +1 -0
  25. package/dist/components/views/standalone/modals/AccountHubModal.test.js +26 -0
  26. package/dist/components/views/standalone/modals/CreateWorkspaceConfirmModal.d.ts +9 -0
  27. package/dist/components/views/standalone/modals/CreateWorkspaceConfirmModal.js +8 -0
  28. package/dist/components/views/standalone/modals/EditProfileModal.d.ts +26 -0
  29. package/dist/components/views/standalone/modals/EditProfileModal.js +10 -0
  30. package/dist/components/views/standalone/modals/HelpModal.d.ts +9 -0
  31. package/dist/components/views/standalone/modals/HelpModal.js +8 -0
  32. package/dist/components/views/standalone/modals/ScheduleWarningModal.d.ts +13 -0
  33. package/dist/components/views/standalone/modals/ScheduleWarningModal.js +6 -0
  34. package/dist/components/views/standalone/modals/SyncStatusModal.d.ts +61 -0
  35. package/dist/components/views/standalone/modals/SyncStatusModal.js +38 -0
  36. package/dist/components/views/standalone/modals/TeamManagementModal.d.ts +64 -0
  37. package/dist/components/views/standalone/modals/TeamManagementModal.js +10 -0
  38. package/dist/components/views/standalone/modals/types.d.ts +2 -0
  39. package/dist/components/views/standalone/modals/types.js +1 -0
  40. package/dist/components/views/teamManagementAccess.d.ts +1 -1
  41. package/dist/components/views/teamManagementAccess.js +2 -2
  42. package/dist/components/views/teamManagementAccess.test.js +3 -3
  43. package/dist/config/deployment.js +2 -2
  44. package/dist/config/deployment.test.js +5 -3
  45. package/dist/core/AiProfileService.js +7 -2
  46. package/dist/core/AiProfiles.test.js +19 -0
  47. package/dist/core/EntitlementsPolicy.test.js +2 -2
  48. package/dist/core/GlobalSettingsService.js +78 -18
  49. package/dist/core/PlanEntitlementService.d.ts +29 -5
  50. package/dist/core/PlanEntitlementService.js +297 -219
  51. package/dist/core/SignupMonetizationSettings.test.js +173 -49
  52. package/dist/core/SyncReconciliationService.d.ts +2 -0
  53. package/dist/core/SyncReconciliationService.js +3 -0
  54. package/dist/core/SystemAdmin.test.js +186 -96
  55. package/dist/core/TaskAuditTimeline.test.js +40 -0
  56. package/dist/core/Taskforce.d.ts +100 -10
  57. package/dist/core/Taskforce.ids.test.js +133 -0
  58. package/dist/core/Taskforce.js +459 -127
  59. package/dist/core/Taskforce.mcpAuth.test.js +0 -2
  60. package/dist/core/UserProfileAvatarDrafts.test.d.ts +1 -0
  61. package/dist/core/UserProfileAvatarDrafts.test.js +111 -0
  62. package/dist/core/taskReferencePolicy.d.ts +28 -0
  63. package/dist/core/taskReferencePolicy.js +189 -0
  64. package/dist/core/types.d.ts +13 -12
  65. package/dist/hooks/tasks/useTaskFormActions.js +3 -0
  66. package/dist/hooks/useSyncOrchestrator.js +17 -3
  67. package/dist/hooks/useSyncOrchestrator.retry-closure.test.js +97 -5
  68. package/dist/hooks/useTaskData.js +3 -2
  69. package/dist/hooks/useTaskData.test.js +66 -0
  70. package/dist/hooks/useTaskforce.d.ts +8 -0
  71. package/dist/hooks/useTaskforce.js +72 -19
  72. package/dist/hooks/useTaskforce.sync-behavior.test.js +185 -6
  73. package/dist/mcp/aiProfileBootstrap.d.ts +29 -0
  74. package/dist/mcp/aiProfileBootstrap.js +80 -0
  75. package/dist/mcp/aiProfileBootstrap.test.d.ts +1 -0
  76. package/dist/mcp/aiProfileBootstrap.test.js +68 -0
  77. package/dist/mcp/clientIntegrations.d.ts +2 -8
  78. package/dist/mcp/clientIntegrations.js +21 -40
  79. package/dist/mcp/clientIntegrations.test.js +28 -2
  80. package/dist/mcp/clientProfileDefaults.d.ts +12 -0
  81. package/dist/mcp/clientProfileDefaults.js +37 -0
  82. package/dist/mcp/runtime.d.ts +10 -7
  83. package/dist/mcp/runtime.js +131 -48
  84. package/dist/mcp/runtime.test.js +321 -83
  85. package/dist/migrations/billingSchemaParity.test.js +3 -0
  86. package/dist/migrations/taskSchemaMigrations.js +68 -1
  87. package/dist/qaOpen.test.d.ts +1 -0
  88. package/dist/qaOpen.test.js +56 -0
  89. package/dist/server/index.cookieProxy.test.js +2 -0
  90. package/dist/server/index.d.ts +1 -0
  91. package/dist/server/index.js +17 -1
  92. package/dist/server/index.test.js +15 -1
  93. package/dist/server/mockStripe.d.ts +1 -0
  94. package/dist/server/mockStripe.js +2 -0
  95. package/dist/server/routes/admin.js +105 -45
  96. package/dist/server/routes/auth.d.ts +6 -0
  97. package/dist/server/routes/auth.js +505 -30
  98. package/dist/server/routes/billing.js +517 -24
  99. package/dist/server/routes/billing.test.js +967 -45
  100. package/dist/server/routes/documents.js +6 -1
  101. package/dist/server/routes/shared.d.ts +1 -1
  102. package/dist/server/routes/shared.js +16 -6
  103. package/dist/server/routes/sync.integration.test.js +290 -0
  104. package/dist/server/routes/sync.js +234 -1922
  105. package/dist/server/routes/tasks.js +18 -4
  106. package/dist/server/routes.js +29 -22
  107. package/dist/server/routes.test.js +639 -82
  108. package/dist/shared/runtimeContract.d.ts +1 -1
  109. package/dist/sync/cloudSyncApi.d.ts +1 -0
  110. package/dist/sync/collaborationSyncPayload.d.ts +17 -0
  111. package/dist/sync/collaborationSyncPayload.js +131 -0
  112. package/dist/sync/collaborationSyncPayload.test.d.ts +1 -0
  113. package/dist/sync/collaborationSyncPayload.test.js +104 -0
  114. package/dist/sync/collaborationSyncState.d.ts +15 -0
  115. package/dist/sync/collaborationSyncState.js +60 -0
  116. package/dist/sync/contentSyncPayload.d.ts +45 -0
  117. package/dist/sync/contentSyncPayload.js +104 -0
  118. package/dist/sync/contentSyncPayload.test.d.ts +1 -0
  119. package/dist/sync/contentSyncPayload.test.js +104 -0
  120. package/dist/sync/contentSyncState.d.ts +98 -0
  121. package/dist/sync/contentSyncState.js +1004 -0
  122. package/dist/sync/planningSyncPayload.d.ts +9 -0
  123. package/dist/sync/planningSyncPayload.js +82 -0
  124. package/dist/sync/planningSyncPayload.test.d.ts +1 -0
  125. package/dist/sync/planningSyncPayload.test.js +68 -0
  126. package/dist/sync/syncApplyHandlers.d.ts +83 -0
  127. package/dist/sync/syncApplyHandlers.js +445 -0
  128. package/dist/sync/syncService.d.ts +1 -0
  129. package/dist/sync/syncService.js +21 -8
  130. package/dist/sync/taskSyncPayload.d.ts +33 -0
  131. package/dist/sync/taskSyncPayload.js +126 -0
  132. package/dist/sync/taskSyncPayload.test.d.ts +1 -0
  133. package/dist/sync/taskSyncPayload.test.js +54 -0
  134. package/dist/sync/workspacePullFeed.d.ts +38 -0
  135. package/dist/sync/workspacePullFeed.js +349 -0
  136. package/dist/sync/workspacePullFeed.test.d.ts +1 -0
  137. package/dist/sync/workspacePullFeed.test.js +278 -0
  138. package/dist/sync/workspaceSyncModel.d.ts +4 -1
  139. package/dist/sync/workspaceSyncModel.js +9 -2
  140. package/dist/sync/workspaceSyncModel.test.js +29 -0
  141. package/dist/test/setup.js +1 -1
  142. package/dist/types.d.ts +1 -0
  143. package/dist/ui/assets/{AgentsModule-Bdq3T1Ts.js → AgentsModule-CpsTmrIW.js} +1 -1
  144. package/dist/ui/assets/{AnnotatedAttachmentWorkspace-jKUVo-PJ.js → AnnotatedAttachmentWorkspace-C_TmXZwA.js} +1 -1
  145. package/dist/ui/assets/{DocumentWorkspace-DuQa-uIC.js → DocumentWorkspace-C3GyzrWm.js} +2 -2
  146. package/dist/ui/assets/{InitiativesModule-C8Pi2VTk.js → InitiativesModule-4-Rh2K2n.js} +1 -1
  147. package/dist/ui/assets/PlansPage-BP7AYOqr.js +1 -0
  148. package/dist/ui/assets/TaskSettings-BOC5F6Ag.js +8 -0
  149. package/dist/ui/assets/{TaskSettings-BwB9NtmJ.css → TaskSettings-CnIBL_Eb.css} +1 -1
  150. package/dist/ui/assets/{WorkflowsModule-b6TLuHwJ.js → WorkflowsModule-CGk9s3NJ.js} +1 -1
  151. package/dist/ui/assets/index-CLIMgR6g.js +6 -0
  152. package/dist/ui/assets/index-DneETxcu.css +1 -0
  153. package/dist/ui/assets/{vendor-icons-QZyhEwgT.js → vendor-icons-pWocEipT.js} +1 -1
  154. package/dist/ui/index.html +3 -3
  155. package/dist/utils/accountProfileSummaryCache.d.ts +31 -0
  156. package/dist/utils/accountProfileSummaryCache.js +97 -0
  157. package/dist/utils/accountProfileSummaryCache.test.d.ts +1 -0
  158. package/dist/utils/accountProfileSummaryCache.test.js +63 -0
  159. package/dist/utils/taskActivity.js +17 -4
  160. package/dist/utils/taskActivity.test.js +27 -0
  161. package/dist/utils/taskNormalization.js +10 -2
  162. package/dist/utils/taskReferences.d.ts +11 -1
  163. package/dist/utils/taskReferences.js +33 -1
  164. package/package.json +4 -3
  165. package/scripts/qa-open-lib.mjs +175 -0
  166. package/scripts/qa-open-lib.mjs.d.ts +49 -0
  167. package/scripts/qa-open.mjs +352 -0
  168. package/dist/ui/assets/PlansPage-B6BDECSi.js +0 -1
  169. package/dist/ui/assets/TaskSettings-DUJgRTPU.js +0 -8
  170. package/dist/ui/assets/index-BiiF1cLQ.css +0 -1
  171. package/dist/ui/assets/index-xBWLPOEb.js +0 -6
@@ -184,10 +184,15 @@ export function resolveAiProfileService(deps, input) {
184
184
  if (!existingRow) {
185
185
  throw deps.createRuleError('AI profile token is invalid for this workspace', 404, 'AI_PROFILE_NOT_FOUND');
186
186
  }
187
+ const existingProfile = deps.aiProfileRowToRecord(existingRow);
187
188
  const nextName = name;
188
189
  const nextUsername = deps.normalizeAiProfileUsername(undefined, nextName);
189
- const nextIcon = deps.normalizeAiProfileIcon(input.icon);
190
- const nextColor = deps.normalizeAiProfileColor(input.color);
190
+ const nextIcon = input.icon === undefined
191
+ ? existingProfile.icon
192
+ : deps.normalizeAiProfileIcon(input.icon);
193
+ const nextColor = input.color === undefined
194
+ ? existingProfile.color
195
+ : deps.normalizeAiProfileColor(input.color);
191
196
  const nextDescription = normalizeOptionalProfileField(input.description);
192
197
  const nextRole = normalizeOptionalProfileField(input.role);
193
198
  const nextProvider = normalizeOptionalProfileField(input.provider);
@@ -130,6 +130,25 @@ describe('TaskforceCore ai profiles', () => {
130
130
  expect(second.profile.provider).toBe('Anthropic');
131
131
  expect(second.profile.model).toBe('claude-sonnet');
132
132
  });
133
+ it('preserves ai profile icon and color when re-resolved without those fields', () => {
134
+ const projectRoot = createProjectRoot();
135
+ createdRoots.push(projectRoot);
136
+ const core = new TaskforceCore({ projectRoot, storagePath: '.taskforce' });
137
+ core.createWorkspace({ workspaceId: 'workspace-1', name: 'Workspace 1' });
138
+ const first = core.resolveAiProfile({
139
+ workspaceId: 'workspace-1',
140
+ name: 'Codex',
141
+ icon: 'Sparkles',
142
+ color: '#0ea5e9'
143
+ });
144
+ const second = core.resolveAiProfile({
145
+ workspaceId: 'workspace-1',
146
+ name: 'Codex 2',
147
+ profileToken: first.profile.profileToken
148
+ });
149
+ expect(second.profile.icon).toBe('Sparkles');
150
+ expect(second.profile.color).toBe('#0ea5e9');
151
+ });
133
152
  it('clears ai profile surfaceType when re-resolved with null or an empty string', () => {
134
153
  const projectRoot = createProjectRoot();
135
154
  createdRoots.push(projectRoot);
@@ -171,8 +171,8 @@ describe('Taskforce entitlements policy engine', () => {
171
171
  email: 'member3@example.com',
172
172
  role: 'member'
173
173
  });
174
- }).toThrowError(TaskforceRuleError);
175
- expect(() => core.assertSeatAvailable('workspace-cap')).toThrowError(TaskforceRuleError);
174
+ }).toThrowError(/Seat limit reached/);
175
+ expect(() => core.assertSeatAvailable('workspace-cap')).toThrowError(/Seat limit reached/);
176
176
  }
177
177
  finally {
178
178
  core.close();
@@ -11,6 +11,9 @@ function splitGlobalSettingsPayload(settings) {
11
11
  if (settings.site && typeof settings.site === 'object') {
12
12
  system.site = { ...settings.site };
13
13
  }
14
+ if (settings.billing && typeof settings.billing === 'object') {
15
+ system.billing = { ...settings.billing };
16
+ }
14
17
  if (settings.setup && typeof settings.setup === 'object') {
15
18
  system.setup = { ...settings.setup };
16
19
  }
@@ -98,6 +101,17 @@ export function getGlobalSettingsService(deps) {
98
101
  const global = readGlobalConfigService(deps);
99
102
  const sourcePrefs = global.schedulePreferences || {};
100
103
  const sourceCapacity = sourcePrefs.dailyCapacity || {};
104
+ const billingOnboardingPolicy = global.billing?.onboardingPolicy && typeof global.billing.onboardingPolicy === 'object'
105
+ && (global.billing.onboardingPolicy.mode === 'require_plan_selection'
106
+ || global.billing.onboardingPolicy.mode === 'auto_grant_free'
107
+ || global.billing.onboardingPolicy.mode === 'auto_start_trial')
108
+ ? {
109
+ mode: global.billing.onboardingPolicy.mode,
110
+ planVersionId: typeof global.billing.onboardingPolicy.planVersionId === 'string'
111
+ ? (global.billing.onboardingPolicy.planVersionId.trim() || null)
112
+ : null
113
+ }
114
+ : null;
101
115
  const schedulePreferences = {
102
116
  ...(typeof sourcePrefs.showWeekends === 'boolean' ? { showWeekends: sourcePrefs.showWeekends } : {}),
103
117
  ...(typeof sourcePrefs.isCalendarSidebarOpen === 'boolean' ? { isCalendarSidebarOpen: sourcePrefs.isCalendarSidebarOpen } : {}),
@@ -163,14 +177,6 @@ export function getGlobalSettingsService(deps) {
163
177
  ...(typeof global.auth.authRateLimitWindowMs === 'number' && Number.isFinite(global.auth.authRateLimitWindowMs)
164
178
  ? { authRateLimitWindowMs: Math.max(1000, Math.floor(global.auth.authRateLimitWindowMs)) }
165
179
  : {}),
166
- ...((global.auth.signupMonetizationStrategy === 'auto_assign_default' || global.auth.signupMonetizationStrategy === 'plan_selection_required')
167
- ? { signupMonetizationStrategy: global.auth.signupMonetizationStrategy }
168
- : {}),
169
- ...(typeof global.auth.defaultSignupPlanVersionId === 'string'
170
- ? { defaultSignupPlanVersionId: global.auth.defaultSignupPlanVersionId.trim() || null }
171
- : global.auth.defaultSignupPlanVersionId === null
172
- ? { defaultSignupPlanVersionId: null }
173
- : {})
174
180
  }
175
181
  }
176
182
  : {}),
@@ -186,6 +192,13 @@ export function getGlobalSettingsService(deps) {
186
192
  }
187
193
  }
188
194
  : {}),
195
+ ...(billingOnboardingPolicy
196
+ ? {
197
+ billing: {
198
+ onboardingPolicy: billingOnboardingPolicy
199
+ }
200
+ }
201
+ : {}),
189
202
  ...(global.setup && typeof global.setup === 'object'
190
203
  ? {
191
204
  setup: {
@@ -289,7 +302,24 @@ export function updateGlobalSettingsService(deps, settings) {
289
302
  const currentAuth = next.auth && typeof next.auth === 'object' ? next.auth : {};
290
303
  const incoming = settings.auth;
291
304
  next.auth = {
292
- ...currentAuth,
305
+ ...(typeof currentAuth.allowSelfRegistration === 'boolean'
306
+ ? { allowSelfRegistration: currentAuth.allowSelfRegistration }
307
+ : {}),
308
+ ...(typeof currentAuth.requireVerifiedEmail === 'boolean'
309
+ ? { requireVerifiedEmail: currentAuth.requireVerifiedEmail }
310
+ : {}),
311
+ ...(typeof currentAuth.defaultNewUserBetaAccess === 'boolean'
312
+ ? { defaultNewUserBetaAccess: currentAuth.defaultNewUserBetaAccess }
313
+ : {}),
314
+ ...(typeof currentAuth.authRateLimitEnabled === 'boolean'
315
+ ? { authRateLimitEnabled: currentAuth.authRateLimitEnabled }
316
+ : {}),
317
+ ...(typeof currentAuth.authRateLimitMaxRequests === 'number' && Number.isFinite(currentAuth.authRateLimitMaxRequests)
318
+ ? { authRateLimitMaxRequests: Math.max(1, Math.floor(currentAuth.authRateLimitMaxRequests)) }
319
+ : {}),
320
+ ...(typeof currentAuth.authRateLimitWindowMs === 'number' && Number.isFinite(currentAuth.authRateLimitWindowMs)
321
+ ? { authRateLimitWindowMs: Math.max(1000, Math.floor(currentAuth.authRateLimitWindowMs)) }
322
+ : {}),
293
323
  ...(typeof incoming.allowSelfRegistration === 'boolean'
294
324
  ? { allowSelfRegistration: incoming.allowSelfRegistration }
295
325
  : {}),
@@ -307,15 +337,7 @@ export function updateGlobalSettingsService(deps, settings) {
307
337
  : {}),
308
338
  ...(typeof incoming.authRateLimitWindowMs === 'number' && Number.isFinite(incoming.authRateLimitWindowMs)
309
339
  ? { authRateLimitWindowMs: Math.max(1000, Math.floor(incoming.authRateLimitWindowMs)) }
310
- : {}),
311
- ...((incoming.signupMonetizationStrategy === 'auto_assign_default' || incoming.signupMonetizationStrategy === 'plan_selection_required')
312
- ? { signupMonetizationStrategy: incoming.signupMonetizationStrategy }
313
- : {}),
314
- ...(typeof incoming.defaultSignupPlanVersionId === 'string'
315
- ? { defaultSignupPlanVersionId: incoming.defaultSignupPlanVersionId.trim() || null }
316
- : incoming.defaultSignupPlanVersionId === null
317
- ? { defaultSignupPlanVersionId: null }
318
- : {})
340
+ : {})
319
341
  };
320
342
  }
321
343
  if (settings.site && typeof settings.site === 'object') {
@@ -331,6 +353,44 @@ export function updateGlobalSettingsService(deps, settings) {
331
353
  : {})
332
354
  };
333
355
  }
356
+ if (settings.billing && typeof settings.billing === 'object') {
357
+ const currentBilling = next.billing && typeof next.billing === 'object' ? next.billing : {};
358
+ const incoming = settings.billing;
359
+ const currentOnboardingPolicy = currentBilling.onboardingPolicy && typeof currentBilling.onboardingPolicy === 'object'
360
+ && (currentBilling.onboardingPolicy.mode === 'require_plan_selection'
361
+ || currentBilling.onboardingPolicy.mode === 'auto_grant_free'
362
+ || currentBilling.onboardingPolicy.mode === 'auto_start_trial')
363
+ ? {
364
+ mode: currentBilling.onboardingPolicy.mode,
365
+ planVersionId: typeof currentBilling.onboardingPolicy.planVersionId === 'string'
366
+ ? (currentBilling.onboardingPolicy.planVersionId.trim() || null)
367
+ : null
368
+ }
369
+ : null;
370
+ const incomingOnboardingPolicy = incoming.onboardingPolicy && typeof incoming.onboardingPolicy === 'object'
371
+ && (incoming.onboardingPolicy.mode === 'require_plan_selection'
372
+ || incoming.onboardingPolicy.mode === 'auto_grant_free'
373
+ || incoming.onboardingPolicy.mode === 'auto_start_trial')
374
+ ? {
375
+ mode: incoming.onboardingPolicy.mode,
376
+ planVersionId: typeof incoming.onboardingPolicy.planVersionId === 'string'
377
+ ? (incoming.onboardingPolicy.planVersionId.trim() || null)
378
+ : null
379
+ }
380
+ : null;
381
+ next.billing = {
382
+ ...(currentOnboardingPolicy
383
+ ? {
384
+ onboardingPolicy: currentOnboardingPolicy
385
+ }
386
+ : {}),
387
+ ...(incomingOnboardingPolicy
388
+ ? {
389
+ onboardingPolicy: incomingOnboardingPolicy
390
+ }
391
+ : {})
392
+ };
393
+ }
334
394
  if (settings.setup && typeof settings.setup === 'object') {
335
395
  const currentSetup = next.setup && typeof next.setup === 'object' ? next.setup : {};
336
396
  const incoming = settings.setup;
@@ -1,10 +1,11 @@
1
1
  import type { DatabaseAdapter } from '../storage/databaseAdapter.js';
2
- import type { EntitlementState, PlanFeatureAccess, PlanFeatureSnapshot, PlanFeatureCatalogItem, PlanVersionSnapshot, PlanCatalogSnapshot, AccountEntitlementSnapshot, SeatUsageSnapshot, FeatureEvaluationResult, AccountAccessStatus, GlobalTaskforceSettings, SignupMonetizationSettings, SignupMonetizationValidationResult } from './types.js';
2
+ import type { EntitlementState, PlanFeatureAccess, PlanFeatureSnapshot, PlanFeatureCatalogItem, PlanVersionSnapshot, PlanCatalogSnapshot, AccountEntitlementSnapshot, SeatUsageSnapshot, FeatureEvaluationResult, AccountAccessStatus, GlobalTaskforceSettings, OnboardingPolicy, OnboardingPolicyValidationResult } from './types.js';
3
3
  export interface PlanEntitlementServiceDeps {
4
4
  getWorkspaceOwnerUserId: (workspaceId: string) => string | null;
5
5
  readGlobalConfig: () => GlobalTaskforceSettings;
6
6
  writeGlobalConfig: (config: GlobalTaskforceSettings) => void;
7
7
  }
8
+ type CommercialStateTransitionSource = 'registration' | 'checkout-start' | 'checkout-confirm' | 'stripe-webhook' | 'backfill' | 'legacy-plan-mode' | 'admin' | 'system';
8
9
  /**
9
10
  * Handles all plan catalog, plan version, and account entitlement logic.
10
11
  * Extracted from Taskforce.ts to reduce monolith size.
@@ -24,9 +25,15 @@ export declare class PlanEntitlementService {
24
25
  private applyPlanVersionTrialDaysMetadata;
25
26
  private sanitizePlanFeatureConfig;
26
27
  private isEntitlementStateAllowed;
28
+ private isIsoTimestampExpired;
29
+ private readAccountEntitlementRow;
30
+ private normalizeExpiredCheckoutPendingRow;
31
+ private isBillingConfirmedTransitionSource;
32
+ private resolveCanonicalTransitionSource;
33
+ private resolvePendingPlanVersionId;
34
+ private buildBlockedAccessStatus;
27
35
  private repairPlanDefaultVersionIfNeeded;
28
36
  repairPlanCatalogDefaultsIfNeeded(): void;
29
- repairSignupMonetizationSettingsIfNeeded(): void;
30
37
  normalizeLegacyPlanDataIfNeeded(): void;
31
38
  private removeLegacyPlanFeatureRows;
32
39
  private migrateLegacySeatLimitFeatureConfigToVersionSeatLimit;
@@ -34,6 +41,18 @@ export declare class PlanEntitlementService {
34
41
  backfillAccountEntitlements(): void;
35
42
  private getRequiredDefaultPlanVersion;
36
43
  private resolveCanonicalEntitlementStateFromBilling;
44
+ transitionCanonicalCommercialState(input: {
45
+ accountId: string;
46
+ planVersionId?: string | null;
47
+ state: EntitlementState;
48
+ effectiveAt?: string | null;
49
+ effectiveUntil?: string | null;
50
+ billingMirrorPlanId?: string | null;
51
+ source: CommercialStateTransitionSource;
52
+ updatedBy: string;
53
+ createdAt?: string | null;
54
+ updatedAt?: string | null;
55
+ }): AccountEntitlementSnapshot;
37
56
  upsertCanonicalEntitlementRecord(input: {
38
57
  accountId: string;
39
58
  planVersionId: string;
@@ -55,12 +74,18 @@ export declare class PlanEntitlementService {
55
74
  feature: PlanFeatureSnapshot | null;
56
75
  };
57
76
  private planHasAnyActivePricing;
77
+ private planVersionHasActiveFreePricing;
78
+ private planVersionIsTrialEligible;
58
79
  private tryGetDefaultPlanVersionByPlanId;
59
80
  private getActiveDefaultPlanVersions;
60
81
  private getDefaultPlanVersionByMode;
61
82
  private tryGetDefaultPlanVersionByMode;
62
- resolveRegistrationPlanAssignment(selectedPlanVersionIdRaw?: string): {
83
+ getOnboardingPolicy(): OnboardingPolicy;
84
+ validateOnboardingPolicy(input?: Partial<OnboardingPolicy>): OnboardingPolicyValidationResult;
85
+ resolveRegistrationOnboardingOutcome(selectedPlanVersionIdRaw?: string): {
63
86
  requiresPlanSelection: boolean;
87
+ checkoutPending: boolean;
88
+ commercialState: EntitlementState;
64
89
  planVersionId: string | null;
65
90
  planId: string | null;
66
91
  };
@@ -98,8 +123,6 @@ export declare class PlanEntitlementService {
98
123
  planId: string;
99
124
  entitlementState: EntitlementState;
100
125
  };
101
- getSignupMonetizationSettings(): SignupMonetizationSettings;
102
- validateSignupMonetizationSettings(input?: Partial<SignupMonetizationSettings>): SignupMonetizationValidationResult;
103
126
  private isValidEntitlementTransition;
104
127
  addEntitlementAuditLog(input: {
105
128
  actorUserId: string;
@@ -199,3 +222,4 @@ export declare class PlanEntitlementService {
199
222
  }>;
200
223
  };
201
224
  }
225
+ export {};