@beechcms/api 0.6.3 → 0.6.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.
- package/assets/dashboard/assets/{chart-pTKbc60T.js → chart-IiMhdPtU.js} +2 -2
- package/assets/dashboard/assets/index-Culul_0c.js +745 -0
- package/assets/dashboard/assets/index-DWm-ERoT.css +1 -0
- package/assets/dashboard/assets/{pie-chart-recharts-BHRffVvU.js → pie-chart-recharts-BZAzxTy0.js} +1 -1
- package/assets/dashboard/assets/{timeseries-chart-recharts-BL2OaRk_.js → timeseries-chart-recharts-BFQVPxPT.js} +1 -1
- package/assets/dashboard/index.html +2 -2
- package/dist/factory.d.ts +3 -1
- package/dist/features/automations/api/automations.schema.d.ts +6 -6
- package/dist/index.js +1895 -2365
- package/dist/shared/db/repositories/content.repository.d1.d.ts +5 -2
- package/dist/shared/db/repositories/demo-data.repository.d1.d.ts +9 -4
- package/dist/shared/policies/apply-policies.d.ts +17 -4
- package/dist/shared/services/queue/cloudflare-queue-service.d.ts +5 -2
- package/dist/shared/services/queue/in-memory-queue-service.d.ts +1 -1
- package/dist/types.d.ts +7 -1
- package/package.json +3 -3
- package/assets/dashboard/assets/index-DQ68KtLl.js +0 -644
- package/assets/dashboard/assets/index-Dve7eEqA.css +0 -1
- package/dist/auth/constants.d.ts +0 -10
- package/dist/auth/utils/refresh-token.d.ts +0 -1
- package/dist/features/automations/engine/cron-runner.utils.d.ts +0 -1
- package/dist/features/content/constants.d.ts +0 -12
- package/dist/features/rotate-field/rotate-field.schema.d.ts +0 -11
- package/dist/public/api-key-middleware.d.ts +0 -6
- package/dist/public/cache-utils.d.ts +0 -10
- package/dist/public/problem-details.d.ts +0 -32
- package/dist/public/public-errors.d.ts +0 -13
- package/dist/public/response-builder.d.ts +0 -22
- package/dist/shared/cloudflare-queue-service.d.ts +0 -11
- package/dist/shared/db/migrations/demo-data-sql.d.ts +0 -1
- package/dist/shared/db/repositories/d1-setup-checklist.repository.d.ts +0 -12
- package/dist/shared/email/email.types.d.ts +0 -79
- package/dist/shared/email/templates/automation-mail.d.ts +0 -7
- package/dist/shared/email/templates/password-changed.d.ts +0 -15
- package/dist/shared/email/templates/password-reset.d.ts +0 -18
- package/dist/shared/email/templates/shell.d.ts +0 -58
- package/dist/shared/in-memory-queue-service.d.ts +0 -16
- package/dist/shared/jobs/fts-sync.d.ts +0 -1
- package/dist/shared/queue-consumer.d.ts +0 -9
- package/dist/shared/storage/upload.d.ts +0 -7
- package/dist/shared/utils/request-utils.d.ts +0 -13
- package/dist/shared/utils/storage-utils.d.ts +0 -7
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared types for the Beech CMS email module.
|
|
3
|
-
*
|
|
4
|
-
* All types used across provider, service, and templates are defined here
|
|
5
|
-
* so that each layer remains decoupled from the others.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Supported languages for the email template system.
|
|
9
|
-
*
|
|
10
|
-
* To add a new language:
|
|
11
|
-
* 1. Add the ISO code here (e.g., `'fr'`).
|
|
12
|
-
* 2. Add the corresponding translation in the `COPY` object of every
|
|
13
|
-
* file in `templates/`. TypeScript will flag missing keys.
|
|
14
|
-
*/
|
|
15
|
-
export declare const SUPPORTED_EMAIL_LOCALES: readonly ['en', 'it'];
|
|
16
|
-
export type EmailLocale = (typeof SUPPORTED_EMAIL_LOCALES)[number];
|
|
17
|
-
/**
|
|
18
|
-
* Resolves an unverified locale string (e.g., from a request body)
|
|
19
|
-
* to a supported `EmailLocale` value. Any unknown value
|
|
20
|
-
* safely falls back to `'en'`.
|
|
21
|
-
*
|
|
22
|
-
* @param raw - Raw value from the client (can be anything).
|
|
23
|
-
* @returns A valid `EmailLocale`, always.
|
|
24
|
-
*/
|
|
25
|
-
export declare function resolveEmailLocale(raw: unknown): EmailLocale;
|
|
26
|
-
/**
|
|
27
|
-
* Shared parameters for every email sending function in `email.service.ts`.
|
|
28
|
-
* Specific functions extend this type with the additional fields
|
|
29
|
-
* required for their respective templates.
|
|
30
|
-
*/
|
|
31
|
-
export interface BaseEmailParams {
|
|
32
|
-
/** Main recipient address. */
|
|
33
|
-
to: string;
|
|
34
|
-
/** Email body language. Use `resolveEmailLocale()` before passing it here. */
|
|
35
|
-
locale: EmailLocale;
|
|
36
|
-
/**
|
|
37
|
-
* Resend API key (or the active provider's key). Must be non-empty —
|
|
38
|
-
* the caller is responsible for validating it before invoking the service.
|
|
39
|
-
*/
|
|
40
|
-
apiKey: string;
|
|
41
|
-
/**
|
|
42
|
-
* Sender address in RFC 5321 format.
|
|
43
|
-
* Default: "Beech CMS <onboarding@resend.dev>" (Resend test sender).
|
|
44
|
-
* In production, set a verified address via the
|
|
45
|
-
* `EMAIL_FROM` environment variable.
|
|
46
|
-
*/
|
|
47
|
-
from?: string;
|
|
48
|
-
/**
|
|
49
|
-
* When `true`, provider errors are logged to the console.
|
|
50
|
-
* Set to `false` in production to avoid exposing internal details.
|
|
51
|
-
*/
|
|
52
|
-
isDev?: boolean;
|
|
53
|
-
}
|
|
54
|
-
/** Parameters for the password reset email — adds the reset URL. */
|
|
55
|
-
export interface PasswordResetEmailParams extends BaseEmailParams {
|
|
56
|
-
/**
|
|
57
|
-
* Complete URL that the user clicks to set the new password.
|
|
58
|
-
* Contains the token in plain text as a query param `?token=<uuid>`.
|
|
59
|
-
* Constructed by the caller as `${APP_URL}/reset-password?token=${token}`.
|
|
60
|
-
*/
|
|
61
|
-
resetUrl: string;
|
|
62
|
-
provider?: 'smtp' | 'resend';
|
|
63
|
-
smtpBaseUrl?: string;
|
|
64
|
-
}
|
|
65
|
-
/** Parameters for the "password changed" notification. No additional fields. */
|
|
66
|
-
export interface PasswordChangedEmailParams extends BaseEmailParams {
|
|
67
|
-
provider?: 'smtp' | 'resend';
|
|
68
|
-
smtpBaseUrl?: string;
|
|
69
|
-
}
|
|
70
|
-
export interface AutomationMailParams {
|
|
71
|
-
to: string;
|
|
72
|
-
subject: string;
|
|
73
|
-
/** Plain text or HTML — passed verbatim to provider. */
|
|
74
|
-
body: string;
|
|
75
|
-
apiKey?: string;
|
|
76
|
-
from?: string;
|
|
77
|
-
provider?: 'smtp' | 'resend';
|
|
78
|
-
smtpBaseUrl?: string;
|
|
79
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { EmailLocale } from '../email.types';
|
|
2
|
-
/**
|
|
3
|
-
* Builds the "password changed" notification email.
|
|
4
|
-
*
|
|
5
|
-
* This email does not have a CTA button — it is a pure security notification.
|
|
6
|
-
* The `warning` block (red text) warns the user to take action if they
|
|
7
|
-
* were not the one who changed the password.
|
|
8
|
-
*
|
|
9
|
-
* @param locale - Language for the email subject and body.
|
|
10
|
-
* @returns Object with `subject` (string) and `html` (complete HTML document).
|
|
11
|
-
*/
|
|
12
|
-
export declare function buildPasswordChangedEmail(locale: EmailLocale): {
|
|
13
|
-
subject: string;
|
|
14
|
-
html: string;
|
|
15
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { EmailLocale } from '../email.types';
|
|
2
|
-
/**
|
|
3
|
-
* Builds the email with the password reset link.
|
|
4
|
-
*
|
|
5
|
-
* Composes the localized content with the base layout (`buildEmailShell`)
|
|
6
|
-
* injecting the CTA button pointing to the reset URL.
|
|
7
|
-
*
|
|
8
|
-
* @param resetUrl - Complete URL with the token in plain text, e.g.
|
|
9
|
-
* `https://dashboard.beechcms.dev/reset-password?token=<uuid>`.
|
|
10
|
-
* It is directly embedded in the CTA button — do not sanitize
|
|
11
|
-
* further: the token is an internally generated UUID.
|
|
12
|
-
* @param locale - Language for the email subject and body.
|
|
13
|
-
* @returns Object with `subject` (string) and `html` (complete HTML document).
|
|
14
|
-
*/
|
|
15
|
-
export declare function buildPasswordResetEmail(resetUrl: string, locale: EmailLocale): {
|
|
16
|
-
subject: string;
|
|
17
|
-
html: string;
|
|
18
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { EmailLocale } from '../email.types';
|
|
2
|
-
/**
|
|
3
|
-
* Content slots that every template must provide to compose a complete email.
|
|
4
|
-
* Each slot corresponds to a visual block in the email card layout.
|
|
5
|
-
*/
|
|
6
|
-
export interface EmailShellSlots {
|
|
7
|
-
/**
|
|
8
|
-
* H2 heading shown at the top of the card. Keep it under ~50 characters
|
|
9
|
-
* to ensure good readability on mobile clients.
|
|
10
|
-
*/
|
|
11
|
-
title: string;
|
|
12
|
-
/**
|
|
13
|
-
* Main body text. Rendered as a paragraph.
|
|
14
|
-
* Safe inline HTML is allowed (e.g., `<strong>`, `<a href="...">`),
|
|
15
|
-
* but avoid block elements (`<p>`, `<div>`) that could break
|
|
16
|
-
* the layout structure in rigid email clients (Outlook, Gmail).
|
|
17
|
-
*/
|
|
18
|
-
body: string;
|
|
19
|
-
/**
|
|
20
|
-
* Optional call-to-action button, rendered as a dark link-button.
|
|
21
|
-
* Omit for notification-only emails that do not require user action.
|
|
22
|
-
*/
|
|
23
|
-
cta?: {
|
|
24
|
-
label: string;
|
|
25
|
-
href: string;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Optional warning paragraph. Rendered in red (#ef4444) to attract
|
|
29
|
-
* attention. Use it for security alerts
|
|
30
|
-
* ("if it wasn't you, act immediately").
|
|
31
|
-
*/
|
|
32
|
-
warning?: string;
|
|
33
|
-
/**
|
|
34
|
-
* Small gray text at the bottom of the card.
|
|
35
|
-
* Used for notes like "automated notification, do not reply".
|
|
36
|
-
*/
|
|
37
|
-
footer: string;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Builds the base HTML layout shared by all Beech CMS transactional emails.
|
|
41
|
-
*
|
|
42
|
-
* ─── SINGLE SOURCE OF TRUTH FOR BRANDING ─────────────────────────────────────
|
|
43
|
-
* Modifying this function changes the visual appearance of ALL outgoing emails
|
|
44
|
-
* simultaneously:
|
|
45
|
-
* - background and card color
|
|
46
|
-
* - border style and border-radius
|
|
47
|
-
* - typographic scale and spacing
|
|
48
|
-
* - CTA button style
|
|
49
|
-
*
|
|
50
|
-
* To change the text or structure of a specific email, instead modify
|
|
51
|
-
* the corresponding template file (`templates/password-reset.ts`, etc.).
|
|
52
|
-
* ─────────────────────────────────────────────────────────────────────────────
|
|
53
|
-
*
|
|
54
|
-
* @param locale - Used for the `lang` attribute of the `<html>` tag.
|
|
55
|
-
* @param slots - Content blocks injected into the layout.
|
|
56
|
-
* @returns A complete and self-contained HTML document ready to be sent.
|
|
57
|
-
*/
|
|
58
|
-
export declare function buildEmailShell(locale: EmailLocale, slots: EmailShellSlots): string;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { IQueueService, JobRegistry, JobContext } from '@beechcms/core';
|
|
2
|
-
type ScheduleBackgroundTask = (task: Promise<unknown>) => void;
|
|
3
|
-
/**
|
|
4
|
-
* Dev/offline + test fallback used when the QUEUE binding is absent. Runs the
|
|
5
|
-
* matching handler in-process. In production this is never selected. Uses
|
|
6
|
-
* executionCtx.waitUntil when available so enqueue stays non-blocking; falls
|
|
7
|
-
* back to awaiting inline (tests) otherwise.
|
|
8
|
-
*/
|
|
9
|
-
export declare class InMemoryQueueService implements IQueueService {
|
|
10
|
-
private readonly jobs;
|
|
11
|
-
private readonly context;
|
|
12
|
-
private readonly scheduleBackgroundTask?;
|
|
13
|
-
constructor(jobs: JobRegistry, context: JobContext, scheduleBackgroundTask?: ScheduleBackgroundTask | undefined);
|
|
14
|
-
enqueue<T>(name: string, payload: T): Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { JobRegistry, QueueMessage } from '@beechcms/core';
|
|
2
|
-
import type { Env } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Consumer-side dispatch. Mirrors index.ts `scheduled()`: builds an
|
|
5
|
-
* engine-mediated JobContext from bindings (NEVER exposes env.DB to jobs) and
|
|
6
|
-
* routes each message to its handler. ack() on success/unknown-name (drop),
|
|
7
|
-
* retry() on throw so Cloudflare re-delivers.
|
|
8
|
-
*/
|
|
9
|
-
export declare function dispatchQueueBatch(batch: MessageBatch<QueueMessage>, env: Env, _ctx: ExecutionContext, jobs: JobRegistry): Promise<void>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { HonoRequest } from "hono";
|
|
2
|
-
/**
|
|
3
|
-
* Extracts the real client IP address from a Cloudflare Worker request.
|
|
4
|
-
*
|
|
5
|
-
* Cloudflare injects the cf-connecting-ip header on every request that
|
|
6
|
-
* passes through the edge. In local development (wrangler dev) or in
|
|
7
|
-
* unit tests the header may be absent, in which case the string "unknown"
|
|
8
|
-
* is returned so that rate-limiter keys remain non-empty and safe to use.
|
|
9
|
-
*
|
|
10
|
-
* Never derive security decisions from this value alone; treat it as a
|
|
11
|
-
* best-effort hint for rate-limiting and logging purposes only.
|
|
12
|
-
*/
|
|
13
|
-
export declare function getClientIp(request: HonoRequest): string;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { S3Client } from '@aws-sdk/client-s3';
|
|
2
|
-
/**
|
|
3
|
-
* Calcola la dimensione totale occupata in un bucket R2 (in byte).
|
|
4
|
-
* Nota: esegue una scansione completa del bucket. Per bucket molto grandi
|
|
5
|
-
* andrebbe implementata una cache o usato Cloudflare Logpush/Analytics.
|
|
6
|
-
*/
|
|
7
|
-
export declare function getBucketSize(client: S3Client, bucketName: string): Promise<number>;
|