@beechcms/api 0.6.0-preview.4 → 0.6.1

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 (121) hide show
  1. package/assets/dashboard/BeechLogo.svg +18 -18
  2. package/assets/dashboard/BeechLogoLIght.svg +48 -48
  3. package/assets/dashboard/assets/chart-CspfxV2U.js +39 -0
  4. package/assets/dashboard/assets/index-DtDfJyaF.js +644 -0
  5. package/assets/dashboard/assets/index-Dve7eEqA.css +1 -0
  6. package/assets/dashboard/assets/{pie-chart-recharts-BMWpjFzf.js → pie-chart-recharts-Bx2IXAjA.js} +1 -1
  7. package/assets/dashboard/assets/timeseries-chart-recharts-BCWufwI1.js +1 -0
  8. package/assets/dashboard/beechLogoDark.svg +48 -48
  9. package/assets/dashboard/index.html +17 -18
  10. package/assets/dashboard/noResult.svg +42 -42
  11. package/assets/dashboard/sol.svg +3 -3
  12. package/assets/dashboard/undraw_enter_nwx3.svg +36 -36
  13. package/dist/auth/constants.d.ts +5 -5
  14. package/dist/features/automations/{automations.handler.d.ts → api/automations.handler.d.ts} +1 -1
  15. package/dist/features/automations/{automation-runner.utils.d.ts → engine/automation-runner.utils.d.ts} +1 -1
  16. package/dist/features/automations/{action-executors → executors}/edit-field.executor.d.ts +1 -1
  17. package/dist/features/automations/{action-executors → executors}/index.d.ts +1 -1
  18. package/dist/features/automations/{action-executors → executors}/send-mail.executor.d.ts +1 -1
  19. package/dist/features/automations/{action-executors → executors}/set-variable.executor.d.ts +1 -1
  20. package/dist/features/automations/{action-executors → executors}/webhook.executor.d.ts +1 -1
  21. package/dist/features/automations/{when-evaluator.d.ts → filters/when-evaluator.d.ts} +1 -1
  22. package/dist/features/automations/index.d.ts +7 -7
  23. package/dist/features/content/constants.d.ts +10 -10
  24. package/dist/features/content/handlers/kanban-move.d.ts +3 -0
  25. package/dist/features/content/handlers/kanban-position.d.ts +3 -0
  26. package/dist/features/content/handlers/view-config.d.ts +4 -0
  27. package/dist/{search.d.ts → features/search/search.d.ts} +1 -1
  28. package/dist/features/upload/index.d.ts +9 -0
  29. package/dist/{widget.d.ts → features/widget/widget.d.ts} +1 -1
  30. package/dist/index.d.ts +1 -1
  31. package/dist/index.js +1091 -439
  32. package/dist/{middleware.d.ts → middleware/auth.middleware.d.ts} +1 -1
  33. package/dist/middleware/repository.middleware.d.ts +2 -1
  34. package/dist/public/access-policy.d.ts +1 -1
  35. package/dist/public/problem-details.d.ts +1 -0
  36. package/dist/public/public-errors.d.ts +4 -4
  37. package/dist/rate-limit/cloudflare-rate-limiter.d.ts +4 -1
  38. package/dist/rate-limit/in-memory-rate-limiter.d.ts +2 -1
  39. package/dist/shared/{schema-mutator.d1.d.ts → db/migrations/schema-mutator.d1.d.ts} +1 -0
  40. package/dist/shared/db/repositories/content.repository.d1.d.ts +259 -0
  41. package/dist/shared/db/repositories/kanban-position.repository.d1.d.ts +9 -0
  42. package/dist/shared/{seed-layout.repository.d1.d.ts → db/repositories/seed-layout.repository.d1.d.ts} +3 -1
  43. package/dist/shared/email/email.provider.d.ts +1 -0
  44. package/dist/{features → shared}/email/email.types.d.ts +1 -16
  45. package/dist/{features → shared}/email/providers/resend.d.ts +1 -2
  46. package/dist/{features → shared}/email/providers/smtp.d.ts +1 -2
  47. package/dist/shared/jobs/queue-consumer.d.ts +9 -0
  48. package/dist/shared/services/queue/cloudflare-queue-service.d.ts +11 -0
  49. package/dist/shared/services/queue/in-memory-queue-service.d.ts +16 -0
  50. package/dist/shared/storage/s3-bucket.d.ts +0 -1
  51. package/dist/shared/storage/upload.d.ts +7 -0
  52. package/dist/{media-utils.d.ts → shared/utils/media-utils.d.ts} +4 -2
  53. package/dist/types.d.ts +93 -2
  54. package/migrations/0000_v040_base.sql +265 -265
  55. package/migrations/0029_automations.sql +14 -14
  56. package/migrations/0030_test_seeds.sql +125 -125
  57. package/package.json +5 -4
  58. package/assets/dashboard/assets/chart-BwlCt-IA.js +0 -39
  59. package/assets/dashboard/assets/index-BcVN-DNy.js +0 -642
  60. package/assets/dashboard/assets/index-Cf1yRCqG.css +0 -1
  61. package/assets/dashboard/assets/timeseries-chart-recharts-8_GwAFR0.js +0 -1
  62. package/dist/features/email/email.provider.d.ts +0 -37
  63. package/dist/shared/content.repository.d1.d.ts +0 -68
  64. package/dist/upload.d.ts +0 -16
  65. package/dist/auth/{bcrypt-hash-provider.d.ts → providers/hash.provider.d.ts} +0 -0
  66. package/dist/auth/{jose-token-service.d.ts → providers/jwt-token.service.d.ts} +0 -0
  67. package/dist/auth/{login.d.ts → utils/login-helpers.d.ts} +0 -0
  68. package/dist/auth/{refresh.d.ts → utils/refresh-token.d.ts} +0 -0
  69. package/dist/features/automations/{automations.schema.d.ts → api/automations.schema.d.ts} +16 -16
  70. /package/dist/features/automations/{automation-runner.d.ts → engine/automation-runner.d.ts} +0 -0
  71. /package/dist/features/automations/{cron-runner.d.ts → engine/cron-runner.d.ts} +0 -0
  72. /package/dist/features/automations/{cron-runner.utils.d.ts → engine/cron-runner.utils.d.ts} +0 -0
  73. /package/dist/features/automations/{context-resolver.d.ts → evaluator/context-resolver.d.ts} +0 -0
  74. /package/dist/features/automations/{template-grammar.d.ts → evaluator/template-grammar.d.ts} +0 -0
  75. /package/dist/features/automations/{var-access-resolver.d.ts → evaluator/var-access-resolver.d.ts} +0 -0
  76. /package/dist/features/automations/{action-executors → executors}/create-entry.executor.d.ts +0 -0
  77. /package/dist/features/automations/{filter-translation.d.ts → filters/filter-translation.d.ts} +0 -0
  78. /package/dist/features/automations/{when-pushdown.d.ts → filters/when-pushdown.d.ts} +0 -0
  79. /package/dist/{search-utils.d.ts → features/search/search-utils.d.ts} +0 -0
  80. /package/dist/shared/{demo-data-sql.d.ts → db/migrations/demo-data-sql.d.ts} +0 -0
  81. /package/dist/shared/{automations.repository.d1.d.ts → db/repositories/automations.repository.d1.d.ts} +0 -0
  82. /package/dist/shared/{base.repository.d1.d.ts → db/repositories/base.repository.d1.d.ts} +0 -0
  83. /package/dist/shared/{d1-activity-log.repository.d.ts → db/repositories/d1-activity-log.repository.d.ts} +0 -0
  84. /package/dist/shared/{d1-analytics.repository.d.ts → db/repositories/d1-analytics.repository.d.ts} +0 -0
  85. /package/dist/shared/{d1-content-scan.repository.d.ts → db/repositories/d1-content-scan.repository.d.ts} +0 -0
  86. /package/dist/shared/{d1-notification.repository.d.ts → db/repositories/d1-notification.repository.d.ts} +0 -0
  87. /package/dist/shared/{d1-password-reset-token.repository.d.ts → db/repositories/d1-password-reset-token.repository.d.ts} +0 -0
  88. /package/dist/shared/{d1-search.repository.d.ts → db/repositories/d1-search.repository.d.ts} +0 -0
  89. /package/dist/shared/{d1-session.repository.d.ts → db/repositories/d1-session.repository.d.ts} +0 -0
  90. /package/dist/shared/{d1-setup-checklist.repository.d.ts → db/repositories/d1-setup-checklist.repository.d.ts} +0 -0
  91. /package/dist/shared/{d1-user.repository.d.ts → db/repositories/d1-user.repository.d.ts} +0 -0
  92. /package/dist/shared/{d1-widget.repository.d.ts → db/repositories/d1-widget.repository.d.ts} +0 -0
  93. /package/dist/shared/{dashboard-layout.repository.d1.d.ts → db/repositories/dashboard-layout.repository.d1.d.ts} +0 -0
  94. /package/dist/shared/{demo-data.repository.d1.d.ts → db/repositories/demo-data.repository.d1.d.ts} +0 -0
  95. /package/dist/shared/{idempotency.repository.d1.d.ts → db/repositories/idempotency.repository.d1.d.ts} +0 -0
  96. /package/dist/shared/{in-memory-seed.repository.d.ts → db/repositories/in-memory-seed.repository.d.ts} +0 -0
  97. /package/dist/shared/{media.repository.d1.d.ts → db/repositories/media.repository.d1.d.ts} +0 -0
  98. /package/dist/shared/{seed.repository.d1.d.ts → db/repositories/seed.repository.d1.d.ts} +0 -0
  99. /package/dist/shared/{site-settings.repository.d1.d.ts → db/repositories/site-settings.repository.d1.d.ts} +0 -0
  100. /package/dist/shared/{system-stats.repository.d1.d.ts → db/repositories/system-stats.repository.d1.d.ts} +0 -0
  101. /package/dist/{features → shared}/email/email.service.d.ts +0 -0
  102. /package/dist/{features → shared}/email/index.d.ts +0 -0
  103. /package/dist/{features → shared}/email/templates/automation-mail.d.ts +0 -0
  104. /package/dist/{features → shared}/email/templates/password-changed.d.ts +0 -0
  105. /package/dist/{features → shared}/email/templates/password-reset.d.ts +0 -0
  106. /package/dist/{features → shared}/email/templates/shell.d.ts +0 -0
  107. /package/dist/shared/{fts-sync.d.ts → jobs/fts-sync.d.ts} +0 -0
  108. /package/dist/shared/{apply-policies.d.ts → policies/apply-policies.d.ts} +0 -0
  109. /package/dist/shared/{d1-activity-logger.d.ts → services/activity-log/d1-activity-logger.d.ts} +0 -0
  110. /package/dist/shared/{in-memory-activity-logger.d.ts → services/activity-log/in-memory-activity-logger.d.ts} +0 -0
  111. /package/dist/shared/{seed-registry-cache.d.ts → services/cache/seed-registry-cache.d.ts} +0 -0
  112. /package/dist/shared/{fixed-clock.d.ts → services/clock/fixed-clock.d.ts} +0 -0
  113. /package/dist/shared/{sequential-id-generator.d.ts → services/id-generator/sequential-id-generator.d.ts} +0 -0
  114. /package/dist/shared/{background-notification-service.d.ts → services/notification/background-notification-service.d.ts} +0 -0
  115. /package/dist/shared/{in-memory-notification-service.d.ts → services/notification/in-memory-notification-service.d.ts} +0 -0
  116. /package/dist/shared/{qstash-notification-service.d.ts → services/notification/qstash-notification-service.d.ts} +0 -0
  117. /package/dist/shared/{execution-context-scheduler.d.ts → services/scheduler/execution-context-scheduler.d.ts} +0 -0
  118. /package/dist/shared/{content-utils.d.ts → utils/content-utils.d.ts} +0 -0
  119. /package/dist/shared/{query-utils.d.ts → utils/query-utils.d.ts} +0 -0
  120. /package/dist/shared/{request-utils.d.ts → utils/request-utils.d.ts} +0 -0
  121. /package/dist/shared/{storage-utils.d.ts → utils/storage-utils.d.ts} +0 -0
package/dist/types.d.ts CHANGED
@@ -1,86 +1,177 @@
1
- import type { Seed, ContentRepository, IdempotencyRepository, BeechBucket, MediaRepository, SystemStatsRepository, IHashProvider, ITokenService, IUserRepository, ISessionRepository, IPasswordResetTokenRepository, IActivityLogger, IActivityLogRepository, INotificationRepository, INotificationService, IWidgetRepository, ISearchRepository, IAnalyticsRepository, IContentScanRepository, ISeedRegistry, IClock, IIdGenerator, IAutomationRunner, IAutomationRepository, IScheduler, BackrefMap, ISiteSettingsRepository, IDemoDataRepository, JwtClaims, ISeedLayoutRepository, ISeedRepository, ISchemaMutator, IDashboardLayoutRepository, IQueueService } from '@beechcms/core';
1
+ /**
2
+ * @module Types
3
+ * Hono app-level type contracts: Cloudflare Worker bindings (`Env`),
4
+ * per-request context values injected by middleware (`Variables`), and
5
+ * the combined `AppEnv` used to type every Hono app/router in the API.
6
+ */
7
+ import type { Seed, ContentRepository, IdempotencyRepository, BeechBucket, MediaRepository, SystemStatsRepository, IHashProvider, ITokenService, IUserRepository, ISessionRepository, IPasswordResetTokenRepository, IActivityLogger, IActivityLogRepository, INotificationRepository, INotificationService, IWidgetRepository, ISearchRepository, IAnalyticsRepository, IContentScanRepository, ISeedRegistry, IClock, IIdGenerator, IAutomationRunner, IAutomationRepository, IScheduler, BackrefMap, ISiteSettingsRepository, IDemoDataRepository, JwtClaims, ISeedLayoutRepository, ISeedRepository, ISchemaMutator, IDashboardLayoutRepository, IQueueService, IKanbanPositionRepository } from '@beechcms/core';
2
8
  import type { IRateLimiterRegistry } from './middleware/rate-limit.middleware';
3
- import type { ISetupChecklistRepository } from './shared/d1-setup-checklist.repository';
9
+ import type { ISetupChecklistRepository } from './shared/db/repositories/d1-setup-checklist.repository';
10
+ /**
11
+ * Cloudflare Worker bindings and environment variables, as declared in `wrangler.toml`.
12
+ * Populated by the Workers runtime; optional fields are unset in some environments (e.g. local dev, tests).
13
+ */
4
14
  export interface Env {
15
+ /** D1 database binding, the source of truth for all content and system tables. */
5
16
  DB: D1Database;
17
+ /** Secret used to sign and verify JWTs. */
6
18
  JWT_SECRET: string;
19
+ /** Expected `iss` claim on issued/verified JWTs. */
7
20
  JWT_ISSUER?: string;
21
+ /** Expected `aud` claim on issued/verified JWTs. */
8
22
  JWT_AUDIENCE?: string;
23
+ /** R2-compatible access key ID for media storage. */
9
24
  R2_ACCESS_KEY_ID?: string;
25
+ /** R2-compatible secret access key for media storage. */
10
26
  R2_SECRET_ACCESS_KEY?: string;
27
+ /** R2-compatible S3 API endpoint. */
11
28
  R2_ENDPOINT?: string;
29
+ /** R2 bucket name used for media uploads. */
12
30
  R2_BUCKET_NAME?: string;
31
+ /** Rate limiter binding for the login endpoint. */
13
32
  LOGIN_RATE_LIMITER?: RateLimit;
33
+ /** Rate limiter binding for the token refresh endpoint. */
14
34
  REFRESH_RATE_LIMITER?: RateLimit;
35
+ /** Rate limiter binding for public (API-key) read endpoints. */
15
36
  PUBLIC_READ_RATE_LIMITER?: RateLimit;
37
+ /** Rate limiter binding for public (API-key) write endpoints. */
16
38
  PUBLIC_WRITE_RATE_LIMITER?: RateLimit;
39
+ /** Comma-separated list of allowed CORS origins. */
17
40
  CORS_ORIGINS?: string;
41
+ /** API key required for public read-only requests. */
18
42
  PUBLIC_READ_API_KEY?: string;
43
+ /** API key required for public write requests. */
19
44
  PUBLIC_WRITE_API_KEY?: string;
45
+ /** When set, restricts the public API to `published` status entries only. */
20
46
  PUBLIC_PUBLISHED_ONLY?: string;
47
+ /** TTL, in seconds, for public API idempotency keys. */
21
48
  PUBLIC_IDEMPOTENCY_TTL_SECONDS?: string;
49
+ /** Base URL used to build public media asset URLs. */
22
50
  MEDIA_BASE_URL?: string;
51
+ /** CDN URL prepended to media asset URLs when serving through a CDN. */
23
52
  MEDIA_CDN_URL?: string;
53
+ /** Maximum accepted upload size, in bytes. */
24
54
  MAX_UPLOAD_BYTES?: string;
55
+ /** API key for the Resend transactional email provider. */
25
56
  RESEND_API_KEY?: string;
57
+ /** Generic email provider API key, used when `EMAIL_PROVIDER` is not Resend/SMTP-specific. */
26
58
  EMAIL_API_KEY?: string;
59
+ /** Public base URL of the dashboard app, used in outbound email links. */
27
60
  APP_URL?: string;
61
+ /** Default `From` address for outbound email. */
28
62
  EMAIL_FROM?: string;
63
+ /** Selects the email transport (e.g. `resend`, `smtp`). */
29
64
  EMAIL_PROVIDER?: string;
65
+ /** SMTP host, used when `EMAIL_PROVIDER` is SMTP. */
30
66
  SMTP_HOST?: string;
67
+ /** SMTP port, used when `EMAIL_PROVIDER` is SMTP. */
31
68
  SMTP_PORT?: string;
69
+ /** URL of a webhook-capture service used in dev/testing to inspect outbound webhook calls. */
32
70
  WEBHOOK_TESTER_URL?: string;
71
+ /** Rate limiter binding for the forgot-password endpoint. */
33
72
  FORGOT_PASSWORD_RATE_LIMITER?: RateLimit;
73
+ /** Rate limiter binding for the reset-password endpoint. */
34
74
  RESET_PASSWORD_RATE_LIMITER?: RateLimit;
75
+ /** Deployment environment name (e.g. `development`, `production`). */
35
76
  ENV?: string;
77
+ /** Default date format string used for display/formatting purposes. */
36
78
  DATE_FORMAT?: string;
79
+ /** Static assets binding, serving the dashboard SPA in production. */
37
80
  ASSETS?: Fetcher;
81
+ /** Cloudflare Queue binding for async job dispatch. */
38
82
  QUEUE?: Queue;
83
+ /** Auth token for the QStash scheduling/delivery service. */
39
84
  QSTASH_TOKEN?: string;
85
+ /** Base URL of the QStash API. */
40
86
  QSTASH_URL?: string;
41
87
  /** Public base URL the worker is reachable at, used by QStash to call back the webhook (e.g. an ngrok tunnel in dev). Falls back to APP_URL. */
42
88
  QSTASH_CALLBACK_URL?: string;
89
+ /** Current QStash signing key, used to verify inbound webhook signatures. */
43
90
  QSTASH_CURRENT_SIGNING_KEY?: string;
91
+ /** Next QStash signing key, accepted during key rotation. */
44
92
  QSTASH_NEXT_SIGNING_KEY?: string;
45
93
  }
94
+ /**
95
+ * Per-request context values (`c.get(...)` / `c.set(...)`), injected by middleware
96
+ * before route handlers run. Every entry here must be set by some middleware on the request path.
97
+ */
46
98
  export interface Variables {
99
+ /** Decoded JWT claims of the authenticated user. */
47
100
  jwtPayload: JwtClaims;
101
+ /** Looks up a Seed definition by slug from the loaded schema. */
48
102
  getSeed: (slug: string) => Seed | null;
103
+ /** Registry of all loaded Seed definitions. */
49
104
  seedRegistry: ISeedRegistry;
105
+ /** Repository for reading/writing content entries. */
50
106
  repository: ContentRepository;
107
+ /** Repository for idempotency key storage (dedupes retried writes). */
51
108
  idempotencyRepository: IdempotencyRepository;
109
+ /** Media storage bucket abstraction (R2-backed). */
52
110
  bucket: BeechBucket;
111
+ /** Repository for media asset metadata. */
53
112
  mediaRepository: MediaRepository;
113
+ /** Repository for aggregate system/dashboard statistics. */
54
114
  systemStatsRepository: SystemStatsRepository;
115
+ /** Password hashing provider. */
55
116
  hashProvider: IHashProvider;
117
+ /** Issues and verifies auth tokens (JWT access/refresh). */
56
118
  tokenService: ITokenService;
119
+ /** Repository for user accounts. */
57
120
  userRepository: IUserRepository;
121
+ /** Repository for auth sessions. */
58
122
  sessionRepository: ISessionRepository;
123
+ /** Repository for password reset tokens. */
59
124
  passwordResetTokenRepository: IPasswordResetTokenRepository;
125
+ /** Registry of configured rate limiters, keyed by route/binding. */
60
126
  rateLimiters: IRateLimiterRegistry;
127
+ /** Records activity log entries for auditing. */
61
128
  activityLogger: IActivityLogger;
129
+ /** Repository for reading activity log entries. */
62
130
  activityLogRepository: IActivityLogRepository;
131
+ /** Repository for user notifications. */
63
132
  notificationRepository: INotificationRepository;
133
+ /** Dispatches notifications (in-app, email, etc). */
64
134
  notificationService: INotificationService;
135
+ /** Repository for dashboard widget configuration. */
65
136
  widgetRepository: IWidgetRepository;
137
+ /** Repository backing full-text/content search. */
66
138
  searchRepository: ISearchRepository;
139
+ /** Repository for analytics event storage/queries. */
67
140
  analyticsRepository: IAnalyticsRepository;
141
+ /** Repository for content scan results (e.g. broken links, validation issues). */
68
142
  contentScanRepository: IContentScanRepository;
143
+ /** Clock abstraction, used instead of `Date.now()` for testability. */
69
144
  clock: IClock;
145
+ /** Generates unique IDs for new records. */
70
146
  idGenerator: IIdGenerator;
147
+ /** Repository for automation (workflow) definitions. */
71
148
  automationRepository: IAutomationRepository;
149
+ /** Executes automation runs. */
72
150
  automationRunner: IAutomationRunner;
151
+ /** Schedules deferred/delayed jobs. */
73
152
  scheduler: IScheduler;
153
+ /** Enqueues async jobs onto the Queue binding. */
74
154
  queue: IQueueService;
155
+ /** Map of reverse relation references, used to resolve backrefs between content types. */
75
156
  backrefMap: BackrefMap;
157
+ /** Repository for global site settings. */
76
158
  siteSettingsRepository: ISiteSettingsRepository;
159
+ /** Repository for demo/seed data generation. */
77
160
  demoDataRepository: IDemoDataRepository;
161
+ /** Repository tracking onboarding/setup checklist completion. */
78
162
  setupChecklistRepository: ISetupChecklistRepository;
163
+ /** Repository for per-seed layout configuration (form/list layouts). */
79
164
  seedLayoutRepository: ISeedLayoutRepository;
165
+ /** Repository for Seed (content type) definitions themselves. */
80
166
  seedRepository: ISeedRepository;
167
+ /** Applies schema mutations (create/alter/drop) to the database. */
81
168
  schemaMutator: ISchemaMutator;
169
+ /** Repository for dashboard layout configuration. */
82
170
  dashboardLayoutRepository: IDashboardLayoutRepository;
171
+ /** Repository for Kanban card position/ordering state. */
172
+ kanbanPositionRepository: IKanbanPositionRepository;
83
173
  }
174
+ /** Combined Hono generic type (`Bindings` + `Variables`) used to type every app/router in the API. */
84
175
  export type AppEnv = {
85
176
  Bindings: Env;
86
177
  Variables: Variables;