@devdash/bofrid-api-types 0.1.5

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 (163) hide show
  1. package/README.md +24 -0
  2. package/dist/app.d.ts +23 -0
  3. package/dist/dev.d.ts +6 -0
  4. package/dist/export-openapi.d.ts +9 -0
  5. package/dist/index.d.ts +3 -0
  6. package/dist/lib/auth.d.ts +20 -0
  7. package/dist/lib/criipto-bankid.d.ts +45 -0
  8. package/dist/lib/datalake.d.ts +7 -0
  9. package/dist/lib/docs-filter.d.ts +15 -0
  10. package/dist/lib/email-action-token.d.ts +26 -0
  11. package/dist/lib/email-utm.d.ts +42 -0
  12. package/dist/lib/email.d.ts +94 -0
  13. package/dist/lib/env.d.ts +18 -0
  14. package/dist/lib/errors.d.ts +6 -0
  15. package/dist/lib/helpers.d.ts +6 -0
  16. package/dist/lib/logger.d.ts +25 -0
  17. package/dist/lib/markets.d.ts +1 -0
  18. package/dist/lib/org-number.d.ts +5 -0
  19. package/dist/lib/ownership.d.ts +47 -0
  20. package/dist/lib/pdf-watermark.d.ts +25 -0
  21. package/dist/lib/personnummer.d.ts +14 -0
  22. package/dist/lib/posthog.d.ts +51 -0
  23. package/dist/lib/premium.d.ts +13 -0
  24. package/dist/lib/profile-resolver.d.ts +14 -0
  25. package/dist/lib/redirect-state.d.ts +40 -0
  26. package/dist/lib/revalidate.d.ts +23 -0
  27. package/dist/lib/schemas.d.ts +21 -0
  28. package/dist/lib/sentry.d.ts +31 -0
  29. package/dist/lib/slug.d.ts +5 -0
  30. package/dist/lib/sms.d.ts +22 -0
  31. package/dist/lib/system-log.d.ts +31 -0
  32. package/dist/lib/webhook-events.d.ts +26 -0
  33. package/dist/lib/webhooks.d.ts +28 -0
  34. package/dist/middleware/auth-debug.d.ts +17 -0
  35. package/dist/middleware/auth.d.ts +19 -0
  36. package/dist/middleware/bibi-logger.d.ts +6 -0
  37. package/dist/middleware/cors.d.ts +1 -0
  38. package/dist/middleware/request-id.d.ts +10 -0
  39. package/dist/middleware/sentry-context.d.ts +8 -0
  40. package/dist/routes/activity-feed.d.ts +64 -0
  41. package/dist/routes/admin-bevakningar.d.ts +200 -0
  42. package/dist/routes/admin-companies.d.ts +381 -0
  43. package/dist/routes/admin-email-jobs.d.ts +257 -0
  44. package/dist/routes/admin-email-logs.d.ts +9 -0
  45. package/dist/routes/admin-fb-leads.d.ts +32 -0
  46. package/dist/routes/admin-import.d.ts +188 -0
  47. package/dist/routes/admin-login-history.d.ts +9 -0
  48. package/dist/routes/admin-marketing.d.ts +15 -0
  49. package/dist/routes/admin-metabase.d.ts +9 -0
  50. package/dist/routes/admin-notifications.d.ts +7 -0
  51. package/dist/routes/admin-paying-customers.d.ts +74 -0
  52. package/dist/routes/admin-sessions.d.ts +10 -0
  53. package/dist/routes/admin-stats.d.ts +380 -0
  54. package/dist/routes/admin-system-logs.d.ts +10 -0
  55. package/dist/routes/admin-users.d.ts +299 -0
  56. package/dist/routes/admin-webhooks.d.ts +276 -0
  57. package/dist/routes/api-keys.d.ts +123 -0
  58. package/dist/routes/applications.d.ts +385 -0
  59. package/dist/routes/auth.d.ts +15 -0
  60. package/dist/routes/billing.d.ts +369 -0
  61. package/dist/routes/bostadsmerit.d.ts +51 -0
  62. package/dist/routes/companies.d.ts +842 -0
  63. package/dist/routes/contact-reveals.d.ts +102 -0
  64. package/dist/routes/conversations/handlers/conversation.d.ts +5 -0
  65. package/dist/routes/conversations/handlers/initiate.d.ts +4 -0
  66. package/dist/routes/conversations/handlers/messages.d.ts +5 -0
  67. package/dist/routes/conversations/handlers/state.d.ts +5 -0
  68. package/dist/routes/conversations/helpers/access.d.ts +11 -0
  69. package/dist/routes/conversations/helpers/enrich-conversation.d.ts +58 -0
  70. package/dist/routes/conversations/helpers/identity.d.ts +43 -0
  71. package/dist/routes/conversations/helpers/notify-recipient.d.ts +10 -0
  72. package/dist/routes/conversations/helpers/reconcile-reveal.d.ts +10 -0
  73. package/dist/routes/conversations/helpers/scrub-contact.d.ts +1 -0
  74. package/dist/routes/conversations/index.d.ts +422 -0
  75. package/dist/routes/conversations/routes.d.ts +924 -0
  76. package/dist/routes/conversations/schemas.d.ts +216 -0
  77. package/dist/routes/cron.d.ts +27 -0
  78. package/dist/routes/documents.d.ts +493 -0
  79. package/dist/routes/email-actions.d.ts +8 -0
  80. package/dist/routes/fastighetslista.d.ts +94 -0
  81. package/dist/routes/geo.d.ts +518 -0
  82. package/dist/routes/geocoding.d.ts +192 -0
  83. package/dist/routes/health.d.ts +43 -0
  84. package/dist/routes/housing-history.d.ts +381 -0
  85. package/dist/routes/index.d.ts +15321 -0
  86. package/dist/routes/leads.d.ts +281 -0
  87. package/dist/routes/listing-helpers.d.ts +33 -0
  88. package/dist/routes/listing-publications.d.ts +636 -0
  89. package/dist/routes/listings.d.ts +1846 -0
  90. package/dist/routes/location-interests.d.ts +754 -0
  91. package/dist/routes/lookup.d.ts +109 -0
  92. package/dist/routes/mejl.d.ts +377 -0
  93. package/dist/routes/profiles.d.ts +281 -0
  94. package/dist/routes/properties.d.ts +1266 -0
  95. package/dist/routes/public-listings.d.ts +1137 -0
  96. package/dist/routes/public-profiles.d.ts +293 -0
  97. package/dist/routes/references.d.ts +695 -0
  98. package/dist/routes/search-partners.d.ts +4 -0
  99. package/dist/routes/site-config.d.ts +103 -0
  100. package/dist/routes/storage.d.ts +367 -0
  101. package/dist/routes/tenant-boost.d.ts +229 -0
  102. package/dist/routes/tenants.d.ts +336 -0
  103. package/dist/routes/track.d.ts +19 -0
  104. package/dist/routes/translate.d.ts +51 -0
  105. package/dist/routes/users.d.ts +517 -0
  106. package/dist/routes/verification.d.ts +175 -0
  107. package/dist/routes/webhooks.d.ts +9 -0
  108. package/dist/rpc.d.ts +11 -0
  109. package/dist/serve.d.ts +5 -0
  110. package/dist/services/activity-feed/activity-feed.service.d.ts +26 -0
  111. package/dist/services/applications/approval.service.d.ts +17 -0
  112. package/dist/services/auth/bankid-login.service.d.ts +40 -0
  113. package/dist/services/billing/constants.d.ts +2 -0
  114. package/dist/services/billing/contact-billing.service.d.ts +59 -0
  115. package/dist/services/billing/customer.service.d.ts +14 -0
  116. package/dist/services/billing/invoice-item.service.d.ts +49 -0
  117. package/dist/services/billing/invoice.service.d.ts +21 -0
  118. package/dist/services/billing/listing-upgrade-checkout.service.d.ts +45 -0
  119. package/dist/services/billing/purchase-receipt-email.d.ts +23 -0
  120. package/dist/services/billing/reveal-allowance.service.d.ts +33 -0
  121. package/dist/services/billing/stripe.d.ts +6 -0
  122. package/dist/services/billing/subscription.service.d.ts +21 -0
  123. package/dist/services/billing/types.d.ts +64 -0
  124. package/dist/services/billing/verify-session.service.d.ts +17 -0
  125. package/dist/services/billing/webhook.service.d.ts +8 -0
  126. package/dist/services/bostadsmerit/calculator.d.ts +51 -0
  127. package/dist/services/bostadsmerit/couple-calculator.d.ts +46 -0
  128. package/dist/services/bostadsmerit/tracker.service.d.ts +45 -0
  129. package/dist/services/chat-access/unlock-chat.service.d.ts +62 -0
  130. package/dist/services/conversations/upsert-conversation.d.ts +11 -0
  131. package/dist/services/email-jobs/email-job-sender.d.ts +7 -0
  132. package/dist/services/email-jobs/email-job.service.d.ts +67 -0
  133. package/dist/services/geo/bevakning-matching.service.d.ts +67 -0
  134. package/dist/services/geo/geo-listings.service.d.ts +38 -0
  135. package/dist/services/geo/geo.service.d.ts +233 -0
  136. package/dist/services/geo/geocode.service.d.ts +16 -0
  137. package/dist/services/geo/market-insights-by-coords.service.d.ts +67 -0
  138. package/dist/services/geo/market-insights.service.d.ts +44 -0
  139. package/dist/services/geo/market-overview.service.d.ts +42 -0
  140. package/dist/services/homii/image.d.ts +24 -0
  141. package/dist/services/homii/index.d.ts +12 -0
  142. package/dist/services/homii/location.d.ts +32 -0
  143. package/dist/services/homii/mapper.d.ts +41 -0
  144. package/dist/services/homii/types.d.ts +91 -0
  145. package/dist/services/leads/constants.d.ts +32 -0
  146. package/dist/services/leads/generate-leads.service.d.ts +38 -0
  147. package/dist/services/leads/matching.service.d.ts +55 -0
  148. package/dist/services/leads/tier.service.d.ts +6 -0
  149. package/dist/services/leads/types.d.ts +27 -0
  150. package/dist/services/listings/seo.service.d.ts +57 -0
  151. package/dist/services/listings/status.d.ts +37 -0
  152. package/dist/services/mejl/client.d.ts +38 -0
  153. package/dist/services/mrkoll/client.d.ts +95 -0
  154. package/dist/services/mrkoll/import.d.ts +38 -0
  155. package/dist/services/mrkoll/match.d.ts +35 -0
  156. package/dist/services/notifications/bibi-projects.d.ts +43 -0
  157. package/dist/services/notifications/bibi.d.ts +229 -0
  158. package/dist/services/profiles/bankid-verify.d.ts +23 -0
  159. package/dist/services/realtime.d.ts +14 -0
  160. package/dist/services/references/history-linker.d.ts +19 -0
  161. package/dist/services/tenant-boost/constants.d.ts +120 -0
  162. package/dist/services/tenant-boost/tenant-boost.service.d.ts +59 -0
  163. package/package.json +29 -0
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Central registry of Bofrid notification projects.
3
+ *
4
+ * Each entry's `project` value is passed to the Bibi `/api/events` endpoint
5
+ * (bibi.blpk.cc) which owns channel fan-out (push / email / discord).
6
+ */
7
+ export interface BibiProjectConfig {
8
+ /** Bibi project name */
9
+ project: string;
10
+ /** Human-readable label */
11
+ label: string;
12
+ /** What events this project receives */
13
+ description: string;
14
+ }
15
+ export declare const BIBI_PROJECTS: {
16
+ readonly publications: {
17
+ readonly project: "bofrid-publications";
18
+ readonly label: "Publiceringar";
19
+ readonly description: "Publiceringsresultat (Blocket, Facebook, etc.)";
20
+ };
21
+ readonly approvals: {
22
+ readonly project: "bofrid-approvals";
23
+ readonly label: "Granskning";
24
+ readonly description: "Annons godkänd/nekad";
25
+ };
26
+ readonly alerts: {
27
+ readonly project: "bofrid-alerts";
28
+ readonly label: "Larm";
29
+ readonly description: "Kritiska systemlarm (e-postleverans, etc.)";
30
+ };
31
+ readonly emails: {
32
+ readonly project: "bofrid-emails";
33
+ readonly label: "E-postjobb";
34
+ readonly description: "E-postjobb livscykel (startat, klart, fel)";
35
+ };
36
+ readonly userActivity: {
37
+ readonly project: "bofrid-user-activity";
38
+ readonly label: "Användaraktivitet";
39
+ readonly description: "Inloggningar, registreringar och annan användaraktivitet";
40
+ };
41
+ };
42
+ /** Default project used by sendBibiEvent() when no project override is provided. */
43
+ export declare const DEFAULT_BIBI_PROJECT: "bofrid-publications";
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Bibi (bibi.blpk.cc) notification dispatcher.
3
+ *
4
+ * Bibi's strict ingest split into POST /api/bugs (alert-worthy, signature-
5
+ * deduped) and POST /api/activity (append-only feed). The legacy /api/events
6
+ * endpoint was removed. As a stopgap, the 20 `bibiX(...)` wrappers below
7
+ * hand their structured payloads to `sendBibiEvent`, which POSTs to
8
+ * /api/ingest — Bibi's LLM router classifies each one into a bug or an
9
+ * activity row and dispatches channels accordingly.
10
+ *
11
+ * `sendActivity` is the direct sibling for the `/api/activity` feed (used
12
+ * by `bibi-logger` middleware and any route that already knows its event
13
+ * is informational).
14
+ *
15
+ * Fire-and-forget: never throws, logs errors to console.
16
+ */
17
+ interface BibiEventOptions {
18
+ title: string;
19
+ message: string;
20
+ /** Legacy ntfy priority 1..5 — mapped to Bibi urgency */
21
+ priority?: 1 | 2 | 3 | 4 | 5;
22
+ tags?: string[];
23
+ click?: string;
24
+ /** Bibi project name (override; defaults to DEFAULT_BIBI_PROJECT) */
25
+ project?: string;
26
+ }
27
+ /**
28
+ * Send a push notification via Bibi (bibi.blpk.cc).
29
+ */
30
+ export declare function sendBibiEvent(opts: BibiEventOptions): Promise<void>;
31
+ /**
32
+ * Notify about a publication result (any channel).
33
+ */
34
+ export declare function bibiPublicationResult(opts: {
35
+ channel: string;
36
+ listingId: string;
37
+ address: string;
38
+ success: boolean;
39
+ error?: string;
40
+ externalUrl?: string;
41
+ adminUrl?: string;
42
+ }): Promise<void>;
43
+ /**
44
+ * Notify about a user login.
45
+ */
46
+ export declare function bibiUserLogin(opts: {
47
+ userName: string | null;
48
+ email: string | null;
49
+ method: string | null;
50
+ }): Promise<void>;
51
+ /**
52
+ * Notify about a new user signup.
53
+ */
54
+ export declare function bibiNewUserSignup(opts: {
55
+ userName: string | null;
56
+ email: string;
57
+ }): Promise<void>;
58
+ /**
59
+ * Notify about a new bevakning (saved search) created.
60
+ */
61
+ export declare function bibiBevakningCreated(opts: {
62
+ userName: string | null;
63
+ email?: string | null;
64
+ locationName: string;
65
+ source: "authenticated" | "guest";
66
+ origin?: string;
67
+ }): Promise<void>;
68
+ /**
69
+ * Notify about a new application submitted.
70
+ */
71
+ export declare function bibiApplicationSubmitted(opts: {
72
+ tenantName: string;
73
+ address: string;
74
+ tier: string;
75
+ }): Promise<void>;
76
+ /**
77
+ * Notify about a contact reveal (landlord unlocked tenant info).
78
+ */
79
+ export declare function bibiApplicationRevealed(opts: {
80
+ landlordName: string;
81
+ tenantName: string;
82
+ address: string;
83
+ }): Promise<void>;
84
+ /**
85
+ * Notify about a new chat conversation started.
86
+ */
87
+ export declare function bibiConversationStarted(opts: {
88
+ landlordName: string;
89
+ tenantName: string;
90
+ address: string;
91
+ }): Promise<void>;
92
+ /**
93
+ * Notify about folkbokföring (population register) data imported.
94
+ */
95
+ export declare function bibiFolkbokforingImported(opts: {
96
+ userName: string | null;
97
+ source: "hitta" | "nusvar" | "mrkoll";
98
+ entriesImported: number;
99
+ }): Promise<void>;
100
+ /**
101
+ * Track a Nusvar API call (paid external — bibi event for usage/cost tracking).
102
+ */
103
+ export declare function bibiNusvarApiCalled(opts: {
104
+ userName: string | null;
105
+ outcome: "success" | "no_result" | "api_error" | "network_error";
106
+ entriesReturned?: number;
107
+ errorMessage?: string;
108
+ }): Promise<void>;
109
+ /**
110
+ * Notify about a reference being signed.
111
+ */
112
+ export declare function bibiReferenceSigned(opts: {
113
+ receiverName: string | null;
114
+ signerName: string | null;
115
+ type: "housing" | "personal";
116
+ }): Promise<void>;
117
+ /**
118
+ * Notify about an upgrade checkout started.
119
+ */
120
+ export declare function bibiUpgradeCheckoutStarted(opts: {
121
+ landlordName: string;
122
+ address: string;
123
+ priceOre: number;
124
+ }): Promise<void>;
125
+ /**
126
+ * Notify about a listing upgrade completed (payment confirmed).
127
+ */
128
+ export declare function bibiListingUpgradeCompleted(opts: {
129
+ landlordName: string;
130
+ address: string;
131
+ priceOre: number;
132
+ }): Promise<void>;
133
+ /**
134
+ * Notify about a listing submitted for review.
135
+ */
136
+ export declare function bibiListingReviewRequest(opts: {
137
+ landlordName: string;
138
+ address: string;
139
+ isResubmission: boolean;
140
+ adminUrl?: string;
141
+ }): Promise<void>;
142
+ /**
143
+ * Notify about a Homii auto-post result (triggered on listing approval).
144
+ */
145
+ export declare function bibiHomiiAutoPost(opts: {
146
+ address: string;
147
+ listingId: string;
148
+ success: boolean;
149
+ homiiUrl?: string;
150
+ error?: string;
151
+ }): Promise<void>;
152
+ /**
153
+ * Notify about email job lifecycle events.
154
+ */
155
+ export declare function bibiEmailJob(opts: {
156
+ event: "started" | "completed" | "failed" | "error";
157
+ jobId: string;
158
+ type: string;
159
+ totalItems?: number;
160
+ sentCount?: number;
161
+ failedCount?: number;
162
+ error?: string;
163
+ address?: string;
164
+ }): Promise<void>;
165
+ /**
166
+ * Notify when a user completes wizard step 1 (property created with address).
167
+ */
168
+ export declare function bibiWizardStep1Completed(opts: {
169
+ userName: string | null;
170
+ address: string;
171
+ source: "authenticated" | "guest-flush";
172
+ }): Promise<void>;
173
+ /**
174
+ * Notify when a user completes wizard step 2 (map / coordinates set).
175
+ */
176
+ export declare function bibiWizardStep2Completed(opts: {
177
+ userName: string | null;
178
+ address: string;
179
+ }): Promise<void>;
180
+ /**
181
+ * Notify about a listing approval decision.
182
+ */
183
+ export declare function bibiListingApproval(opts: {
184
+ address: string;
185
+ landlordName: string;
186
+ decision: "approve" | "reject";
187
+ listingUrl?: string;
188
+ rejectionComment?: string;
189
+ }): Promise<void>;
190
+ /**
191
+ * Notify when a landlord starts a single-reveal checkout.
192
+ */
193
+ export declare function bibiRevealCheckoutStarted(opts: {
194
+ landlordName: string;
195
+ priceOre: number;
196
+ }): Promise<void>;
197
+ /**
198
+ * Notify when a tenant starts a Boost checkout.
199
+ */
200
+ export declare function bibiBoostCheckoutStarted(opts: {
201
+ tenantName: string;
202
+ plan: string;
203
+ priceOre: number;
204
+ }): Promise<void>;
205
+ /**
206
+ * Notify when admin gifts Boost to a tenant (free upgrade).
207
+ */
208
+ export declare function bibiBoostGifted(opts: {
209
+ tenantName: string;
210
+ days: number;
211
+ }): Promise<void>;
212
+ /**
213
+ * Notify when a tenant's Boost subscription is canceled/deactivated.
214
+ */
215
+ export declare function bibiBoostCanceled(opts: {
216
+ tenantName: string;
217
+ reason: string;
218
+ }): Promise<void>;
219
+ /**
220
+ * Send an informational activity event to the Bibi activity feed.
221
+ * Fire-and-forget — mirrors the client-side track() helper for server-side use.
222
+ */
223
+ export declare function sendActivity(opts: {
224
+ kind: string;
225
+ title: string;
226
+ actor?: string | null;
227
+ context?: Record<string, unknown>;
228
+ }): Promise<void>;
229
+ export {};
@@ -0,0 +1,23 @@
1
+ /**
2
+ * BankID identity verification — extracted from profiles route for reuse
3
+ * by the auth/bankid poll endpoint.
4
+ */
5
+ export interface BankIDUserData {
6
+ personnummer: string;
7
+ displayName: string;
8
+ givenName?: string;
9
+ surname?: string;
10
+ }
11
+ export interface BankIDVerifyResult {
12
+ profileId: string;
13
+ alreadyVerified: boolean;
14
+ merged: boolean;
15
+ }
16
+ /**
17
+ * Verify a user's identity via BankID data (personnummer + name).
18
+ *
19
+ * This is the same logic as the POST /profiles/bankid/verify route handler,
20
+ * extracted so the BankID QR poll endpoint can call it directly without
21
+ * going through an HTTP roundtrip.
22
+ */
23
+ export declare function verifyBankIDIdentityDirect(profileId: string, authUserId: string, bankIDData: BankIDUserData): Promise<BankIDVerifyResult>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Channel name convention: `conv:{conversationId}`.
3
+ * Server publishes, clients subscribe. The conversation-id namespace means
4
+ * a single subscription per open chat — no over-broadcast.
5
+ */
6
+ export declare function conversationChannelName(conversationId: string): string;
7
+ type ConversationEvent = "message:new" | "message:edited" | "message:deleted" | "conversation:archived" | "conversation:unarchived" | "conversation:unlocked" | "conversation:read";
8
+ /**
9
+ * Fire-and-forget broadcast. Never throws — failures log and swallow,
10
+ * because the HTTP response has already been (or is about to be) sent.
11
+ * The polling fallback covers anything that doesn't land.
12
+ */
13
+ export declare function broadcastConversationEvent(conversationId: string, event: ConversationEvent, payload: Record<string, unknown>): Promise<void>;
14
+ export {};
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Reference History Linker Service
3
+ *
4
+ * Links verified references to housing history entries for bostadsmerit scoring.
5
+ * Internal service — called by reference signing handlers.
6
+ */
7
+ /**
8
+ * Mark housing history entries as verified when a housing reference is signed.
9
+ * Verifies ALL entries at the same address (street + city).
10
+ */
11
+ export declare function linkVerifiedReference(userId: string, _referenceType: "housing", sourceId: string, referenceId?: string, landlordData?: {
12
+ name?: string;
13
+ phone?: string;
14
+ email?: string;
15
+ }): Promise<void>;
16
+ /**
17
+ * Reset housing history verification when a housing reference is deleted.
18
+ */
19
+ export declare function unlinkVerifiedReference(userId: string, _referenceType: "housing", sourceId: string): Promise<void>;
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Tenant Boost — Single source of truth for offer, pricing, limits, and copy.
3
+ *
4
+ * All Boost-related values live here so the API, frontend, and marketing
5
+ * pages can reference the same numbers and text without drift.
6
+ */
7
+ export type BoostPlanId = "monthly" | "quarterly" | "halfyear";
8
+ export interface BoostPlan {
9
+ id: BoostPlanId;
10
+ /** Price per month in öre */
11
+ pricePerMonthOre: number;
12
+ /** Total charged per billing cycle in öre */
13
+ totalOre: number;
14
+ /** Stripe recurring interval */
15
+ stripeInterval: "month";
16
+ /** Stripe interval_count (1, 3, or 6) */
17
+ stripeIntervalCount: number;
18
+ /** Display labels */
19
+ label: {
20
+ sv: string;
21
+ en: string;
22
+ };
23
+ /** Per-month display */
24
+ priceLabel: {
25
+ sv: string;
26
+ en: string;
27
+ };
28
+ /** Total per billing cycle display */
29
+ totalLabel: {
30
+ sv: string;
31
+ en: string;
32
+ };
33
+ /** Savings vs monthly (percentage) */
34
+ savingsPercent: number;
35
+ }
36
+ export declare const BOOST_PLANS: readonly BoostPlan[];
37
+ /** Default plan used when none specified */
38
+ export declare const DEFAULT_BOOST_PLAN: BoostPlanId;
39
+ /** Introductory price for the first 3 days of Boost (39 SEK) */
40
+ export declare const BOOST_TRIAL_PRICE_ORE = 3900;
41
+ /** Number of trial days at the intro price */
42
+ export declare const BOOST_TRIAL_DAYS = 3;
43
+ /** Stripe product metadata value used in webhooks to identify Boost */
44
+ export declare const BOOST_STRIPE_TYPE: "tenant_boost";
45
+ /** Resolve a plan by ID (falls back to monthly) */
46
+ export declare function getBoostPlan(planId?: string): BoostPlan;
47
+ /**
48
+ * Added to the base tier score when the tenant has Boost.
49
+ * Sorts Boost tenants above non-Boost within the same tier
50
+ * without jumping to the next tier.
51
+ *
52
+ * Base scores: basic=1, standard=2, premium=3, super_premium=4
53
+ * With Boost: basic=1.5, standard=2.5, premium=3.5, super_premium=4.5
54
+ */
55
+ export declare const BOOST_TIER_SCORE_BONUS = 0.5;
56
+ export declare const BOOST_FEATURES: readonly ["priority_placement", "direct_message", "read_receipts"];
57
+ export type BoostFeature = (typeof BOOST_FEATURES)[number];
58
+ export declare const BOOST_COPY: {
59
+ /** Product name */
60
+ readonly name: {
61
+ readonly sv: "Bofrid Boost";
62
+ readonly en: "Bofrid Boost";
63
+ };
64
+ /** Tagline — used in hero sections and upgrade prompts */
65
+ readonly tagline: {
66
+ readonly sv: "Öka dina chanser att hitta bostad";
67
+ readonly en: "Increase your chances of finding a home";
68
+ };
69
+ /** Short pitch — 1 sentence */
70
+ readonly pitch: {
71
+ readonly sv: "Sluta vänta — skriv direkt till hyresvärden och hamna högre i listan.";
72
+ readonly en: "Stop waiting — message the landlord directly and rank higher in the list.";
73
+ };
74
+ /** Price label — shows cheapest plan (half-year) */
75
+ readonly priceLabel: {
76
+ readonly sv: "289 kr/mån";
77
+ readonly en: "289 SEK/mo";
78
+ };
79
+ /** CTA button text */
80
+ readonly cta: {
81
+ readonly sv: "Prova i 3 dagar för 39 kr";
82
+ readonly en: "Try 3 days for 39 SEK";
83
+ };
84
+ /** Trial info shown below CTA */
85
+ readonly trialInfo: {
86
+ readonly sv: "39 kr de 3 första dagarna, sedan 289 kr/mån. Avsluta när du vill.";
87
+ readonly en: "39 SEK for the first 3 days, then 289 SEK/mo. Cancel anytime.";
88
+ };
89
+ /** Cancel info */
90
+ readonly cancelInfo: {
91
+ readonly sv: "Avsluta när du vill. Inga bindningstider.";
92
+ readonly en: "Cancel anytime. No commitment.";
93
+ };
94
+ /** Feature list — ordered by value (direct_message first = hero feature) */
95
+ readonly features: readonly [{
96
+ readonly key: "direct_message";
97
+ readonly sv: "Skriv direkt till hyresvärden";
98
+ readonly en: "Message the landlord directly";
99
+ }, {
100
+ readonly key: "priority_placement";
101
+ readonly sv: "Hamna högre i hyresvärdars listor";
102
+ readonly en: "Rank higher in landlord lists";
103
+ }, {
104
+ readonly key: "read_receipts";
105
+ readonly sv: "Se när hyresvärden sett din ansökan";
106
+ readonly en: "See when landlords view your application";
107
+ }];
108
+ /** Upgrade prompts — contextual copy shown in the boost flow */
109
+ readonly prompts: {
110
+ readonly directMessage: {
111
+ readonly sv: "Uppgradera till Boost för att skicka meddelande direkt till hyresvärden.";
112
+ readonly en: "Upgrade to Boost to message the landlord directly.";
113
+ };
114
+ readonly searchResults: {
115
+ readonly sv: "Boost-medlemmar hamnar högre i hyresvärdars kandidatlistor.";
116
+ readonly en: "Boost members rank higher in landlord candidate lists.";
117
+ };
118
+ };
119
+ };
120
+ export declare const FREE_TENANT_FEATURES: readonly ["profile_creation", "bankid_verification", "document_uploads", "search_and_browse", "chat_after_reveal", "appear_in_candidate_lists", "one_bevakning", "unlimited_applications"];
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Tenant Boost Service — Stripe subscription management.
3
+ *
4
+ * Handles Checkout creation, webhook lifecycle, and subscription queries.
5
+ * Boost subscriptions live on individual profiles (never companies).
6
+ */
7
+ import type Stripe from "stripe";
8
+ import type { BoostPlanId } from "./constants";
9
+ /**
10
+ * Create a Stripe Checkout session for Tenant Boost subscription.
11
+ * Returns existing subscription info if already active.
12
+ */
13
+ export declare function createBoostCheckout(userId: string, returnUrl: string, planId?: BoostPlanId): Promise<{
14
+ alreadySubscribed: true;
15
+ boostExpiresAt: string;
16
+ } | {
17
+ checkoutUrl: string;
18
+ }>;
19
+ /**
20
+ * Handle `checkout.session.completed` for Boost subscriptions.
21
+ * Activates Boost on the tenant's profile.
22
+ */
23
+ export declare function completeBoostCheckout(session: Stripe.Checkout.Session): Promise<void>;
24
+ /**
25
+ * Handle subscription lifecycle events:
26
+ * - `customer.subscription.updated` — renewal, cancellation scheduled, plan change
27
+ * - `customer.subscription.deleted` — subscription ended (cancelled or payment failed)
28
+ */
29
+ export declare function handleBoostSubscriptionEvent(subscription: Stripe.Subscription): Promise<void>;
30
+ export interface BoostStatus {
31
+ active: boolean;
32
+ expiresAt: string | null;
33
+ cancelAtPeriodEnd: boolean;
34
+ subscriptionId: string | null;
35
+ status: 'trialing' | 'active' | 'inactive';
36
+ trialEnd: string | null;
37
+ }
38
+ /**
39
+ * Get the current Boost status for a user.
40
+ * Stripe subscription is the source of truth — always checks live status
41
+ * when a subscription ID exists and syncs DB accordingly.
42
+ */
43
+ export declare function getBoostStatus(userId: string): Promise<BoostStatus>;
44
+ /**
45
+ * Admin gift: grant Boost to a tenant for `days` days without Stripe.
46
+ *
47
+ * Sets isBoosted=true and boostExpiresAt = max(existing, now + days), so
48
+ * stacking a gift on top of a paid sub or a longer existing gift never
49
+ * shortens the user's coverage. boostStripeSubscriptionId is left untouched
50
+ * — getBoostStatus continues to treat Stripe as source of truth when present.
51
+ *
52
+ * Side-effects: unlocks every currently-locked conversation involving this
53
+ * tenant (reveal_reason='tenant_boost'), same as a real subscription start.
54
+ */
55
+ export declare function giftTenantBoost(userId: string, days: number): Promise<{
56
+ alreadyBoosted: boolean;
57
+ boostExpiresAt: string;
58
+ conversationsUnlocked: number;
59
+ }>;
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@devdash/bofrid-api-types",
3
+ "version": "0.1.5",
4
+ "description": "TypeScript type definitions for the Bofrid API — Hono RPC AppType + route shapes. Consumed by bofrid-web.",
5
+ "private": false,
6
+ "license": "UNLICENSED",
7
+ "publishConfig": {
8
+ "registry": "https://registry.npmjs.org/",
9
+ "access": "public"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/devdashco/bofrid-api.git",
14
+ "directory": "types-package"
15
+ },
16
+ "types": "./dist/routes/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/routes/index.d.ts"
20
+ },
21
+ "./*": {
22
+ "types": "./dist/*.d.ts"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist/**/*.d.ts",
27
+ "README.md"
28
+ ]
29
+ }