@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,21 @@
1
+ import { z } from "@hono/zod-openapi";
2
+ /**
3
+ * Shared OpenAPI response schemas used across all route files.
4
+ * NOTE: Do NOT create shared response definition objects (e.g. `{ 401: { ... } }`)
5
+ * for spreading into `createRoute({ responses })`. Hono's strict type inference
6
+ * requires literal status code keys — spreading `as const` objects loses them.
7
+ */
8
+ export declare const errorSchema: z.ZodObject<{
9
+ error: z.ZodString;
10
+ }, "strip", z.ZodTypeAny, {
11
+ error: string;
12
+ }, {
13
+ error: string;
14
+ }>;
15
+ export declare const successSchema: z.ZodObject<{
16
+ success: z.ZodBoolean;
17
+ }, "strip", z.ZodTypeAny, {
18
+ success: boolean;
19
+ }, {
20
+ success: boolean;
21
+ }>;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Sentry integration for the Hono API.
3
+ *
4
+ * Initializes @sentry/node and exports helpers used by app.ts and entry points.
5
+ * Self-hosted instance at sentry.bofrid.dev — same project as the web app.
6
+ *
7
+ * Env vars (all optional — Sentry is silently disabled when DSN is missing):
8
+ * SENTRY_DSN — Data source name (e.g. https://xxx@sentry.bofrid.dev/2)
9
+ * SENTRY_ENVIRONMENT — Falls back to NODE_ENV
10
+ * RAILWAY_GIT_COMMIT_SHA — Automatic release tracking on Railway
11
+ */
12
+ import * as Sentry from "@sentry/node";
13
+ declare const IS_ENABLED: boolean;
14
+ /**
15
+ * Capture an exception in Sentry with optional context.
16
+ * No-op when Sentry is disabled.
17
+ */
18
+ export declare function captureException(err: unknown, context?: {
19
+ tags?: Record<string, string>;
20
+ extra?: Record<string, unknown>;
21
+ level?: Sentry.SeverityLevel;
22
+ }): void;
23
+ /**
24
+ * Capture a plain message in Sentry.
25
+ */
26
+ export declare function captureMessage(message: string, level?: Sentry.SeverityLevel): void;
27
+ /**
28
+ * Flush pending events (call before process.exit).
29
+ */
30
+ export declare function flush(timeoutMs?: number): Promise<void>;
31
+ export { IS_ENABLED as isSentryEnabled };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Re-export slug utilities from @bofrid/db.
3
+ * Kept for backward compatibility with existing imports.
4
+ */
5
+ export { generateSlug, generateUniqueSlug, generateRandomSlug } from "@bofrid/db/slug";
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Generates a cryptographically secure 6-digit verification code.
3
+ */
4
+ export declare function generateVerificationCode(): string;
5
+ export declare function isValidPhone(phoneNumber: string): boolean;
6
+ /**
7
+ * Strip spaces/hyphens and produce an E.164 candidate.
8
+ *
9
+ * `countryCode` (ISO 3166-1 alpha-2) controls how local-format inputs are
10
+ * interpreted. Default "SE" preserves legacy behavior: leading-zero numbers
11
+ * are rewritten with +46. For other countries (e.g. "DK"), the leading-zero
12
+ * rewrite is skipped — callers must pass a `+`-prefixed E.164 number, or a
13
+ * bare digit string that gets the country's dial prefix prepended.
14
+ *
15
+ * Pass the user's country (derived from `profiles.signupMarket` via
16
+ * `getCountryByMarket` in i18n/markets.ts) when serving non-SE users.
17
+ */
18
+ export declare function normalizePhone(raw: string, countryCode?: string): string;
19
+ /**
20
+ * Sends a verification code SMS via mejl.to.
21
+ */
22
+ export declare function sendVerificationSMS(phoneNumber: string, code: string): Promise<void>;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Writes to `bofrid_system_logs` via a dedicated 1-connection pool so syslog
3
+ * traffic can never starve the main `db` pool (max: 2, see packages/db/src/index.ts).
4
+ *
5
+ * Fire-and-forget: callers should NOT `await` this — we schedule the write via
6
+ * `queueMicrotask` and attach `.catch` so a slow insert cannot extend request
7
+ * latency or hold the Lambda open past response.
8
+ *
9
+ * Why this exists: the previous version ran `db.insert(...)` on the shared
10
+ * pool with a 2s `Promise.race` timeout. When a slow route (e.g. a 60s
11
+ * `/conversations/:id/messages`) held a connection, every syslog insert
12
+ * raced against the 2s timer and dropped. The timeout didn't cancel the
13
+ * underlying insert either — the pending promise kept the connection,
14
+ * worsening starvation.
15
+ */
16
+ type SyslogOptions = {
17
+ status?: "info" | "success" | "warning" | "error";
18
+ message?: string;
19
+ metadata?: unknown;
20
+ durationMs?: number;
21
+ correlationId?: string;
22
+ };
23
+ /**
24
+ * Schedule a system-log insert. Returns immediately — does not block the
25
+ * caller and never throws. Callers may optionally `await` to match the old
26
+ * signature; awaiting only waits for the microtask to be scheduled, not for
27
+ * the DB round-trip to complete.
28
+ */
29
+ export declare function syslog(source: string, event: string, options?: SyslogOptions): Promise<void>;
30
+ export declare function correlationId(): string;
31
+ export {};
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Webhook event registry.
3
+ *
4
+ * Adding a new event = 2 steps:
5
+ * 1. Add the key + description here
6
+ * 2. Call `dispatchWebhooks("event.key", payload)` at the trigger point
7
+ */
8
+ export declare const WEBHOOK_EVENTS: {
9
+ readonly "listing.submitted": "En annons skickades in för granskning";
10
+ readonly "listing.approved": "En annons godkändes och publicerades";
11
+ readonly "listing.rejected": "En annons nekades av admin";
12
+ readonly "listing.archived": "En annons arkiverades";
13
+ readonly "listing.unpublished": "En annons avpublicerades";
14
+ readonly "listing.withdrawn": "En annons drogs tillbaka från granskning";
15
+ readonly "listing.resubmitted": "En publicerad annons skickades in igen efter redigering";
16
+ readonly "listing.published": "En arkiverad annons publicerades igen";
17
+ readonly "application.created": "En ny ansökan skickades in";
18
+ readonly "application.withdrawn": "En ansökan drogs tillbaka";
19
+ readonly "application.accepted": "En ansökan godkändes";
20
+ readonly "application.rejected": "En ansökan nekades";
21
+ readonly "application.revealed": "En kandidats kontaktinfo avslöjades";
22
+ readonly "lead.created": "En ny lead genererades";
23
+ readonly "lead.revealed": "En leads kontaktinfo avslöjades (köptes)";
24
+ };
25
+ export type WebhookEventKey = keyof typeof WEBHOOK_EVENTS;
26
+ export declare const WEBHOOK_EVENT_KEYS: WebhookEventKey[];
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Outgoing webhook dispatcher — DB-backed.
3
+ *
4
+ * Queries active subscriptions from `bofrid_webhook_subscriptions`,
5
+ * filters by event key (exact, wildcard `listing.*`, or global `*`),
6
+ * and delivers payloads. Must be awaited in serverless environments.
7
+ *
8
+ * HMAC-SHA256 signing when `signingSecret` is set → `X-Bofrid-Signature` header.
9
+ */
10
+ import type { WebhookEventKey } from "../lib/webhook-events";
11
+ interface DispatchOptions {
12
+ resourceType?: string;
13
+ resourceId?: string;
14
+ }
15
+ /**
16
+ * Compute HMAC-SHA256 signature for a payload string.
17
+ * Uses the Web Crypto API (available in Node 18+/Bun).
18
+ */
19
+ export declare function computeSignature(secret: string, body: string): Promise<string>;
20
+ /**
21
+ * Dispatch a webhook event to all matching active subscriptions.
22
+ *
23
+ * Must be awaited in serverless environments (Vercel) to prevent the
24
+ * runtime from terminating before delivery completes.
25
+ * Errors are logged, never thrown.
26
+ */
27
+ export declare function dispatchWebhooks(event: WebhookEventKey, data: Record<string, unknown>, options?: DispatchOptions): Promise<void>;
28
+ export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 🔍 AUTH FLOW DEBUG MIDDLEWARE
3
+ *
4
+ * Temporary middleware that logs every auth-related event in real-time.
5
+ * Attach to the Hono app to see exactly what happens during login,
6
+ * account creation, BankID verification, and session validation.
7
+ *
8
+ * REMOVE BEFORE DEPLOYING TO PRODUCTION.
9
+ *
10
+ * Usage: import { authDebugMiddleware } from "../middleware/auth-debug"
11
+ * app.use("*", authDebugMiddleware);
12
+ */
13
+ import type { AppBindings } from "../app";
14
+ /**
15
+ * The debug middleware — logs request/response details for auth flows.
16
+ */
17
+ export declare const authDebugMiddleware: import("hono").MiddlewareHandler<AppBindings, string, {}, Response>;
@@ -0,0 +1,19 @@
1
+ import type { AppBindings } from "../app";
2
+ /**
3
+ * Auth middleware — tries session cookie first, falls back to API key.
4
+ * Sets c.var.authUserId and c.var.profileId.
5
+ */
6
+ export declare const authMiddleware: import("hono").MiddlewareHandler<AppBindings, string, {}, Response>;
7
+ /** @deprecated Use authMiddleware — it now supports both session and API key. */
8
+ export declare const combinedAuthMiddleware: import("hono").MiddlewareHandler<AppBindings, string, {}, Response>;
9
+ /**
10
+ * Optional auth middleware — tries to resolve a session and profile.
11
+ * If no session, continues without setting context variables.
12
+ * Useful for endpoints that behave differently for authenticated users.
13
+ */
14
+ export declare const optionalAuthMiddleware: import("hono").MiddlewareHandler<AppBindings, string, {}, Response>;
15
+ /**
16
+ * Admin middleware — must be used AFTER authMiddleware.
17
+ * Checks the Better Auth user.role column (single source of truth for admin).
18
+ */
19
+ export declare const adminMiddleware: import("hono").MiddlewareHandler<AppBindings, string, {}, Response>;
@@ -0,0 +1,6 @@
1
+ import type { AppBindings } from "../app";
2
+ /**
3
+ * Logs every API request to the Bibi activity feed after it completes.
4
+ * Fire-and-forget — never blocks the response.
5
+ */
6
+ export declare const bibiLoggerMiddleware: import("hono").MiddlewareHandler<AppBindings, string, {}, Response>;
@@ -0,0 +1 @@
1
+ export declare const corsMiddleware: import("hono").MiddlewareHandler;
@@ -0,0 +1,10 @@
1
+ import type { AppBindings } from "../app";
2
+ /**
3
+ * Request ID middleware — generates or propagates a unique ID per request.
4
+ *
5
+ * - Reads `X-Request-Id` from incoming headers (e.g. from load balancer or upstream proxy).
6
+ * - Falls back to a new `crypto.randomUUID()`.
7
+ * - Sets `c.var.requestId` for downstream handlers.
8
+ * - Echoes the ID back via the `X-Request-Id` response header.
9
+ */
10
+ export declare const requestIdMiddleware: import("hono").MiddlewareHandler<AppBindings, string, {}, Response>;
@@ -0,0 +1,8 @@
1
+ import type { AppBindings } from "../app";
2
+ /**
3
+ * Sentry context middleware — enriches every request with tracing and user info.
4
+ *
5
+ * Must run AFTER requestIdMiddleware (needs `c.var.requestId`).
6
+ * User context is set lazily after downstream middleware (auth) runs.
7
+ */
8
+ export declare const sentryContextMiddleware: import("hono").MiddlewareHandler<AppBindings, string, {}, Response>;
@@ -0,0 +1,64 @@
1
+ import { OpenAPIHono } from "@hono/zod-openapi";
2
+ import type { AppBindings } from "../app";
3
+ export declare const activityFeedApp: OpenAPIHono<AppBindings, {
4
+ "/activity-feed": {
5
+ $get: {
6
+ input: {
7
+ query: {
8
+ locale?: "sv" | "en" | undefined;
9
+ view?: "company" | "tenant" | "landlord" | undefined;
10
+ };
11
+ };
12
+ output: {
13
+ error: string;
14
+ };
15
+ outputFormat: "json";
16
+ status: 401;
17
+ } | {
18
+ input: {
19
+ query: {
20
+ locale?: "sv" | "en" | undefined;
21
+ view?: "company" | "tenant" | "landlord" | undefined;
22
+ };
23
+ };
24
+ output: {
25
+ items: {
26
+ title: string;
27
+ id: string;
28
+ createdAt: string;
29
+ category: "identity" | "document" | "invoice" | "listing_upgraded" | "application" | "reference" | "listing_review" | "listing_rejected" | "incoming_application" | "company_invite";
30
+ severity: "info" | "completed" | "action_required" | "waiting";
31
+ href: string;
32
+ description?: string | undefined;
33
+ completedAt?: string | undefined;
34
+ resourceId?: string | undefined;
35
+ imageUrl?: string | undefined;
36
+ subtitle?: string | undefined;
37
+ avatarUrl?: string | undefined;
38
+ avatarFallback?: string | undefined;
39
+ }[];
40
+ total: number;
41
+ historyItems: {
42
+ title: string;
43
+ id: string;
44
+ createdAt: string;
45
+ category: "identity" | "document" | "invoice" | "listing_upgraded" | "application" | "reference" | "listing_review" | "listing_rejected" | "incoming_application" | "company_invite";
46
+ severity: "info" | "completed" | "action_required" | "waiting";
47
+ href: string;
48
+ description?: string | undefined;
49
+ completedAt?: string | undefined;
50
+ resourceId?: string | undefined;
51
+ imageUrl?: string | undefined;
52
+ subtitle?: string | undefined;
53
+ avatarUrl?: string | undefined;
54
+ avatarFallback?: string | undefined;
55
+ }[];
56
+ counts: {
57
+ [x: string]: number;
58
+ };
59
+ };
60
+ outputFormat: "json";
61
+ status: 200;
62
+ };
63
+ };
64
+ }, "/">;
@@ -0,0 +1,200 @@
1
+ /**
2
+ * Admin bevakningar routes.
3
+ *
4
+ * Listing-centric view: for each published listing, shows how many active
5
+ * bevakningar match geographically, how many already received email,
6
+ * and lets admin trigger the send.
7
+ *
8
+ * Also keeps the bevakning-list + stats endpoints for general overview.
9
+ *
10
+ * All routes are protected by authMiddleware + adminMiddleware.
11
+ */
12
+ import { OpenAPIHono } from "@hono/zod-openapi";
13
+ import type { AppBindings } from "../app";
14
+ export declare const adminBevakningarApp: OpenAPIHono<AppBindings, {
15
+ "/admin/bevakningar/listings": {
16
+ $get: {
17
+ input: {
18
+ query: {
19
+ limit?: string | undefined;
20
+ offset?: string | undefined;
21
+ q?: string | undefined;
22
+ };
23
+ };
24
+ output: {
25
+ items: {
26
+ status: string;
27
+ shortId: string | null;
28
+ address: string;
29
+ city: string;
30
+ geoLan: string | null;
31
+ geoKommun: string | null;
32
+ propertyType: string;
33
+ publishedAt: string | null;
34
+ listingId: string;
35
+ pending: number;
36
+ matchingBevakningar: number;
37
+ rent: number | null;
38
+ alreadySent: number;
39
+ }[];
40
+ total: number;
41
+ };
42
+ outputFormat: "json";
43
+ status: 200;
44
+ } | {
45
+ input: {
46
+ query: {
47
+ limit?: string | undefined;
48
+ offset?: string | undefined;
49
+ q?: string | undefined;
50
+ };
51
+ };
52
+ output: {
53
+ error: string;
54
+ };
55
+ outputFormat: "json";
56
+ status: 401;
57
+ } | {
58
+ input: {
59
+ query: {
60
+ limit?: string | undefined;
61
+ offset?: string | undefined;
62
+ q?: string | undefined;
63
+ };
64
+ };
65
+ output: {
66
+ error: string;
67
+ };
68
+ outputFormat: "json";
69
+ status: 403;
70
+ };
71
+ };
72
+ } & {
73
+ "/admin/bevakningar/listings/:id/preview": {
74
+ $get: {
75
+ input: {
76
+ param: {
77
+ id: string;
78
+ };
79
+ };
80
+ output: {
81
+ address: string;
82
+ listingId: string;
83
+ recipients: {
84
+ email: string | null;
85
+ displayName: string;
86
+ userId: string;
87
+ locationName: string | null;
88
+ bevakningId: string;
89
+ bevakningName: string;
90
+ }[];
91
+ };
92
+ outputFormat: "json";
93
+ status: 200;
94
+ } | {
95
+ input: {
96
+ param: {
97
+ id: string;
98
+ };
99
+ };
100
+ output: {
101
+ error: string;
102
+ };
103
+ outputFormat: "json";
104
+ status: 404;
105
+ };
106
+ };
107
+ } & {
108
+ "/admin/bevakningar/listings/:id/send": {
109
+ $post: {
110
+ input: {
111
+ param: {
112
+ id: string;
113
+ };
114
+ };
115
+ output: {
116
+ error: string;
117
+ };
118
+ outputFormat: "json";
119
+ status: 404;
120
+ } | {
121
+ input: {
122
+ param: {
123
+ id: string;
124
+ };
125
+ };
126
+ output: {
127
+ status: string;
128
+ jobId: string;
129
+ total: number;
130
+ };
131
+ outputFormat: "json";
132
+ status: 200;
133
+ } | {
134
+ input: {
135
+ param: {
136
+ id: string;
137
+ };
138
+ };
139
+ output: {
140
+ error: string;
141
+ };
142
+ outputFormat: "json";
143
+ status: 409;
144
+ };
145
+ };
146
+ } & {
147
+ "/admin/bevakningar": {
148
+ $get: {
149
+ input: {
150
+ query: {
151
+ limit?: string | undefined;
152
+ active?: "all" | "true" | "false" | undefined;
153
+ offset?: string | undefined;
154
+ q?: string | undefined;
155
+ };
156
+ };
157
+ output: {
158
+ items: {
159
+ name: string;
160
+ id: string;
161
+ active: boolean;
162
+ createdAt: string;
163
+ updatedAt: string;
164
+ userId: string;
165
+ emailNotifications: boolean;
166
+ numberOfPeople: number | null;
167
+ locationName: string | null;
168
+ locationType: string | null;
169
+ regionSlug: string | null;
170
+ municipalitySlug: string | null;
171
+ isNationwide: boolean;
172
+ maxRent: number | null;
173
+ propertyTypes: string[] | null;
174
+ userEmail: string | null;
175
+ userDisplayName: string;
176
+ notificationCount: number;
177
+ }[];
178
+ total: number;
179
+ };
180
+ outputFormat: "json";
181
+ status: 200;
182
+ };
183
+ };
184
+ } & {
185
+ "/admin/bevakningar/stats": {
186
+ $get: {
187
+ input: {};
188
+ output: {
189
+ totalBevakningar: number;
190
+ activeBevakningar: number;
191
+ withEmailNotifications: number;
192
+ totalNotificationsSent: number;
193
+ failedNotifications: number;
194
+ uniqueListingsNotified: number;
195
+ };
196
+ outputFormat: "json";
197
+ status: 200;
198
+ };
199
+ };
200
+ }, "/">;