@beechcms/core 0.9.6 → 0.9.7

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 (180) hide show
  1. package/LICENSE +21 -0
  2. package/dist/auth/login-request.d.ts +16 -0
  3. package/dist/auth/login-request.d.ts.map +1 -0
  4. package/dist/auth/login-request.js +22 -0
  5. package/dist/automations-grammar-words.d.ts +2 -0
  6. package/dist/automations-grammar-words.d.ts.map +1 -0
  7. package/dist/automations-grammar-words.js +8 -0
  8. package/dist/automations.repository.interface.d.ts +19 -0
  9. package/dist/automations.repository.interface.d.ts.map +1 -0
  10. package/dist/automations.repository.interface.js +3 -0
  11. package/dist/automations.runner.interface.d.ts +10 -0
  12. package/dist/automations.runner.interface.d.ts.map +1 -0
  13. package/dist/automations.runner.interface.js +3 -0
  14. package/dist/automations.runner.stub.d.ts +5 -0
  15. package/dist/automations.runner.stub.d.ts.map +1 -0
  16. package/dist/automations.runner.stub.js +7 -0
  17. package/dist/automations.types.d.ts +75 -0
  18. package/dist/automations.types.d.ts.map +1 -0
  19. package/dist/automations.types.js +3 -0
  20. package/dist/clock.d.ts +25 -0
  21. package/dist/clock.d.ts.map +1 -0
  22. package/dist/clock.js +11 -0
  23. package/dist/content-scan.repository.d.ts +9 -0
  24. package/dist/content-scan.repository.d.ts.map +1 -0
  25. package/dist/content-scan.repository.js +3 -0
  26. package/dist/content.repository.d.ts +247 -0
  27. package/dist/content.repository.d.ts.map +1 -0
  28. package/dist/content.repository.js +59 -0
  29. package/dist/dashboard-layout/content-view.d.ts +4 -4
  30. package/dist/dashboard-layout/relation-avatar.d.ts +12 -0
  31. package/dist/dashboard-layout/relation-avatar.d.ts.map +1 -0
  32. package/dist/dashboard-layout/relation-avatar.js +18 -0
  33. package/dist/dashboard-layout.d.ts +154 -0
  34. package/dist/dashboard-layout.d.ts.map +1 -0
  35. package/dist/dashboard-layout.js +186 -0
  36. package/dist/dashboard-layout.repository.d.ts +18 -0
  37. package/dist/dashboard-layout.repository.d.ts.map +1 -0
  38. package/dist/dashboard-layout.repository.js +3 -0
  39. package/dist/dashboard-permissions.d.ts +3 -0
  40. package/dist/dashboard-permissions.d.ts.map +1 -0
  41. package/dist/dashboard-permissions.js +11 -0
  42. package/dist/dashboard-scopes.d.ts +12 -0
  43. package/dist/dashboard-scopes.d.ts.map +1 -0
  44. package/dist/dashboard-scopes.js +30 -0
  45. package/dist/define-seed.d.ts +3 -0
  46. package/dist/define-seed.d.ts.map +1 -0
  47. package/dist/define-seed.js +5 -0
  48. package/dist/demo-data.repository.d.ts +5 -0
  49. package/dist/demo-data.repository.d.ts.map +1 -0
  50. package/dist/demo-data.repository.js +3 -0
  51. package/dist/email.provider.d.ts +32 -0
  52. package/dist/email.provider.d.ts.map +1 -0
  53. package/dist/email.provider.js +4 -0
  54. package/dist/engine/ddl.d.ts +0 -23
  55. package/dist/engine/ddl.d.ts.map +1 -1
  56. package/dist/engine/ddl.js +3 -59
  57. package/dist/engine/localization.d.ts +127 -0
  58. package/dist/engine/localization.d.ts.map +1 -0
  59. package/dist/engine/localization.js +212 -0
  60. package/dist/engine/privacy.service.d.ts.map +1 -1
  61. package/dist/engine/query/search-support.d.ts +32 -0
  62. package/dist/engine/query/search-support.d.ts.map +1 -0
  63. package/dist/engine/query/search-support.js +34 -0
  64. package/dist/engine/query.d.ts.map +1 -1
  65. package/dist/engine/query.js +0 -12
  66. package/dist/engine/schema-fingerprint.d.ts +2 -0
  67. package/dist/engine/schema-fingerprint.d.ts.map +1 -1
  68. package/dist/engine/schema-fingerprint.js +2 -0
  69. package/dist/engine/seed-ddl.d.ts +1 -4
  70. package/dist/engine/seed-ddl.d.ts.map +1 -1
  71. package/dist/engine/seed-ddl.js +2 -17
  72. package/dist/engine/seed-registry.d.ts.map +1 -1
  73. package/dist/engine/seed-types-generator.d.ts +2 -17
  74. package/dist/engine/seed-types-generator.d.ts.map +1 -1
  75. package/dist/engine/seed-types-generator.js +3 -31
  76. package/dist/engine/seed-validation.d.ts.map +1 -1
  77. package/dist/engine/seed-validation.js +0 -10
  78. package/dist/engine.d.ts +144 -0
  79. package/dist/engine.d.ts.map +1 -0
  80. package/dist/engine.js +741 -0
  81. package/dist/file-types.d.ts +13 -0
  82. package/dist/file-types.d.ts.map +1 -0
  83. package/dist/file-types.js +85 -0
  84. package/dist/hooks.d.ts +29 -0
  85. package/dist/hooks.d.ts.map +1 -0
  86. package/dist/hooks.js +3 -0
  87. package/dist/id-generator.d.ts +26 -0
  88. package/dist/id-generator.d.ts.map +1 -0
  89. package/dist/id-generator.js +12 -0
  90. package/dist/idempotency.repository.d.ts +13 -0
  91. package/dist/idempotency.repository.d.ts.map +1 -0
  92. package/dist/idempotency.repository.js +3 -0
  93. package/dist/kanban-position.repository.d.ts +19 -0
  94. package/dist/kanban-position.repository.d.ts.map +1 -0
  95. package/dist/kanban-position.repository.js +3 -0
  96. package/dist/kanban.d.ts +75 -0
  97. package/dist/kanban.d.ts.map +1 -0
  98. package/dist/kanban.js +82 -0
  99. package/dist/layout-permissions.d.ts +3 -0
  100. package/dist/layout-permissions.d.ts.map +1 -0
  101. package/dist/layout-permissions.js +11 -0
  102. package/dist/media.repository.d.ts +61 -0
  103. package/dist/media.repository.d.ts.map +1 -0
  104. package/dist/media.repository.js +3 -0
  105. package/dist/notifications/notification-service.d.ts +2 -2
  106. package/dist/policies.d.ts +10 -0
  107. package/dist/policies.d.ts.map +1 -0
  108. package/dist/policies.js +33 -0
  109. package/dist/queue.interface.d.ts +39 -0
  110. package/dist/queue.interface.d.ts.map +1 -0
  111. package/dist/queue.interface.js +3 -0
  112. package/dist/queue.stub.d.ts +6 -0
  113. package/dist/queue.stub.d.ts.map +1 -0
  114. package/dist/queue.stub.js +8 -0
  115. package/dist/relations.d.ts +28 -0
  116. package/dist/relations.d.ts.map +1 -0
  117. package/dist/relations.js +25 -0
  118. package/dist/richtext-render.d.ts +11 -0
  119. package/dist/richtext-render.d.ts.map +1 -0
  120. package/dist/richtext-render.js +87 -0
  121. package/dist/richtext.d.ts +11 -0
  122. package/dist/richtext.d.ts.map +1 -0
  123. package/dist/richtext.js +13 -0
  124. package/dist/scheduler.interface.d.ts +4 -0
  125. package/dist/scheduler.interface.d.ts.map +1 -0
  126. package/dist/scheduler.interface.js +3 -0
  127. package/dist/scheduler.stub.d.ts +5 -0
  128. package/dist/scheduler.stub.d.ts.map +1 -0
  129. package/dist/scheduler.stub.js +7 -0
  130. package/dist/schema-mutator.d.ts +26 -0
  131. package/dist/schema-mutator.d.ts.map +1 -0
  132. package/dist/schema-mutator.js +3 -0
  133. package/dist/seed-ddl-destructive.d.ts +40 -0
  134. package/dist/seed-ddl-destructive.d.ts.map +1 -0
  135. package/dist/seed-ddl-destructive.js +149 -0
  136. package/dist/seed-ddl.d.ts +40 -0
  137. package/dist/seed-ddl.d.ts.map +1 -0
  138. package/dist/seed-ddl.js +100 -0
  139. package/dist/seed-layout.d.ts +145 -0
  140. package/dist/seed-layout.d.ts.map +1 -0
  141. package/dist/seed-layout.js +192 -0
  142. package/dist/seed-layout.repository.d.ts +22 -0
  143. package/dist/seed-layout.repository.d.ts.map +1 -0
  144. package/dist/seed-layout.repository.js +3 -0
  145. package/dist/seed-registry.d.ts +71 -0
  146. package/dist/seed-registry.d.ts.map +1 -0
  147. package/dist/seed-registry.js +143 -0
  148. package/dist/seed-types-generator.d.ts +1 -1
  149. package/dist/seed-types-generator.d.ts.map +1 -1
  150. package/dist/seed-validation.d.ts +23 -0
  151. package/dist/seed-validation.d.ts.map +1 -0
  152. package/dist/seed-validation.js +224 -0
  153. package/dist/seed.repository.d.ts +37 -0
  154. package/dist/seed.repository.d.ts.map +1 -0
  155. package/dist/seed.repository.js +3 -0
  156. package/dist/seeds.d.ts +20 -0
  157. package/dist/seeds.d.ts.map +1 -0
  158. package/dist/seeds.js +21 -0
  159. package/dist/site-settings.repository.d.ts +16 -0
  160. package/dist/site-settings.repository.d.ts.map +1 -0
  161. package/dist/site-settings.repository.js +3 -0
  162. package/dist/slug-utils.d.ts +18 -0
  163. package/dist/slug-utils.d.ts.map +1 -0
  164. package/dist/slug-utils.js +32 -0
  165. package/dist/storage.d.ts +46 -0
  166. package/dist/storage.d.ts.map +1 -0
  167. package/dist/storage.js +3 -0
  168. package/dist/types.d.ts +243 -0
  169. package/dist/types.d.ts.map +1 -0
  170. package/dist/types.js +3 -0
  171. package/dist/validation.d.ts +50 -0
  172. package/dist/validation.d.ts.map +1 -0
  173. package/dist/validation.js +660 -0
  174. package/dist/webhook-validation.d.ts +3 -0
  175. package/dist/webhook-validation.d.ts.map +1 -0
  176. package/dist/webhook-validation.js +6 -0
  177. package/package.json +1 -1
  178. package/dist/content/content-lock.repository.d.ts +0 -63
  179. package/dist/content/content-lock.repository.d.ts.map +0 -1
  180. package/dist/content/content-lock.repository.js +0 -15
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2026 Flavio De Musso
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ /** Same bounds the setup and reset-password flows enforce, so a password that can be created can log in. */
3
+ export declare const LOGIN_PASSWORD_MIN_LENGTH = 8;
4
+ export declare const LOGIN_PASSWORD_MAX_LENGTH = 128;
5
+ /** bcrypt silently truncates at 72 bytes; refusing longer input stops two passwords sharing a hash. */
6
+ export declare const LOGIN_PASSWORD_MAX_BYTES = 72;
7
+ /**
8
+ * Body of `POST /auth/login`. The single source of both the runtime check and the type the typed
9
+ * client sends: the output email is already trimmed and lowercased, the form it is stored in.
10
+ */
11
+ export declare const loginRequestSchema: z.ZodObject<{
12
+ email: z.ZodString;
13
+ password: z.ZodString;
14
+ }, z.core.$strip>;
15
+ export type LoginRequest = z.input<typeof loginRequestSchema>;
16
+ //# sourceMappingURL=login-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login-request.d.ts","sourceRoot":"","sources":["../../src/auth/login-request.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,4GAA4G;AAC5G,eAAO,MAAM,yBAAyB,IAAI,CAAA;AAC1C,eAAO,MAAM,yBAAyB,MAAM,CAAA;AAE5C,uGAAuG;AACvG,eAAO,MAAM,wBAAwB,KAAK,CAAA;AAE1C;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;iBAO7B,CAAA;AAEF,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA"}
@@ -0,0 +1,22 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // Copyright (c) 2024–2026 Flavio De Musso. All rights reserved.
3
+ // See LICENSE in the repository root for license terms.
4
+ import { z } from 'zod';
5
+ import { isValidAccountEmail } from './account-email.js';
6
+ /** Same bounds the setup and reset-password flows enforce, so a password that can be created can log in. */
7
+ export const LOGIN_PASSWORD_MIN_LENGTH = 8;
8
+ export const LOGIN_PASSWORD_MAX_LENGTH = 128;
9
+ /** bcrypt silently truncates at 72 bytes; refusing longer input stops two passwords sharing a hash. */
10
+ export const LOGIN_PASSWORD_MAX_BYTES = 72;
11
+ /**
12
+ * Body of `POST /auth/login`. The single source of both the runtime check and the type the typed
13
+ * client sends: the output email is already trimmed and lowercased, the form it is stored in.
14
+ */
15
+ export const loginRequestSchema = z.object({
16
+ email: z.string().trim().toLowerCase().refine(isValidAccountEmail),
17
+ password: z
18
+ .string()
19
+ .min(LOGIN_PASSWORD_MIN_LENGTH)
20
+ .max(LOGIN_PASSWORD_MAX_LENGTH)
21
+ .refine((password) => new TextEncoder().encode(password).length <= LOGIN_PASSWORD_MAX_BYTES),
22
+ });
@@ -0,0 +1,2 @@
1
+ export declare const AUTOMATION_RESERVED_WORDS: Set<string>;
2
+ //# sourceMappingURL=automations-grammar-words.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automations-grammar-words.d.ts","sourceRoot":"","sources":["../src/automations-grammar-words.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,yBAAyB,aAKpC,CAAA"}
@@ -0,0 +1,8 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2024–2026 Flavio De Musso
3
+ export const AUTOMATION_RESERVED_WORDS = new Set([
4
+ 'this', 'batch', 'all', 'firstone', 'lastone', 'byid', 'where',
5
+ 'array',
6
+ 'count', 'sum', 'avg', 'min', 'max', 'pluck',
7
+ 'true', 'false', 'null',
8
+ ]);
@@ -0,0 +1,19 @@
1
+ import type { Automation, AutomationAction, AutomationTrigger, AutomationTriggerEvent, WhenNode } from './automations.types.js';
2
+ export interface CreateAutomationInput {
3
+ seed_slug: string;
4
+ name: string;
5
+ triggers: AutomationTrigger[];
6
+ trigger_conditions: WhenNode | null;
7
+ actions: AutomationAction[];
8
+ }
9
+ export type UpdateAutomationInput = Partial<CreateAutomationInput>;
10
+ export interface IAutomationRepository {
11
+ list(seedSlug: string): Promise<Automation[]>;
12
+ findById(id: string): Promise<Automation | null>;
13
+ create(input: CreateAutomationInput): Promise<string>;
14
+ update(id: string, input: UpdateAutomationInput): Promise<void>;
15
+ toggle(id: string, enabled: boolean): Promise<void>;
16
+ delete(id: string): Promise<void>;
17
+ findActive(seedSlug: string, event: AutomationTriggerEvent): Promise<Automation[]>;
18
+ }
19
+ //# sourceMappingURL=automations.repository.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automations.repository.interface.d.ts","sourceRoot":"","sources":["../src/automations.repository.interface.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAE/H,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,iBAAiB,EAAE,CAAA;IAC7B,kBAAkB,EAAE,QAAQ,GAAG,IAAI,CAAA;IACnC,OAAO,EAAE,gBAAgB,EAAE,CAAA;CAC5B;AAED,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAA;AAElE,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAA;IAC7C,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAA;IAChD,MAAM,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IACrD,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/D,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACnD,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACjC,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAA;CACnF"}
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2024–2026 Flavio De Musso
3
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { AutomationTriggerEvent } from './automations.types.js';
2
+ export interface AutomationEventPayload {
3
+ seedSlug: string;
4
+ event: AutomationTriggerEvent;
5
+ entry: Record<string, unknown>;
6
+ }
7
+ export interface IAutomationRunner {
8
+ run(payload: AutomationEventPayload): Promise<void>;
9
+ }
10
+ //# sourceMappingURL=automations.runner.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automations.runner.interface.d.ts","sourceRoot":"","sources":["../src/automations.runner.interface.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAEpE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,sBAAsB,CAAA;IAC7B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/B;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACpD"}
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2024–2026 Flavio De Musso
3
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { IAutomationRunner, AutomationEventPayload } from './automations.runner.interface.js';
2
+ export declare class NoOpAutomationRunner implements IAutomationRunner {
3
+ run(_payload: AutomationEventPayload): Promise<void>;
4
+ }
5
+ //# sourceMappingURL=automations.runner.stub.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automations.runner.stub.d.ts","sourceRoot":"","sources":["../src/automations.runner.stub.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAA;AAElG,qBAAa,oBAAqB,YAAW,iBAAiB;IACtD,GAAG,CAAC,QAAQ,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3D"}
@@ -0,0 +1,7 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2024–2026 Flavio De Musso
3
+ export class NoOpAutomationRunner {
4
+ async run(_payload) {
5
+ // intentionally empty
6
+ }
7
+ }
@@ -0,0 +1,75 @@
1
+ export type AutomationTriggerEvent = 'create' | 'update' | 'delete' | 'cron';
2
+ export interface AutomationTrigger {
3
+ event: AutomationTriggerEvent;
4
+ cron?: string | null;
5
+ }
6
+ export interface TriggerCondition {
7
+ field: string;
8
+ op: 'eq' | 'neq' | 'contains' | 'gt' | 'lt' | 'isempty' | 'isnotempty';
9
+ value: unknown;
10
+ }
11
+ export type WhenOperand = {
12
+ kind: 'literal';
13
+ value: unknown;
14
+ } | {
15
+ kind: 'ref';
16
+ key: string;
17
+ };
18
+ export type WhenOp = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'contains' | 'startswith' | 'endswith' | 'in' | 'notin' | 'isempty' | 'isnotempty' | 'matches';
19
+ export interface WhenPredicate {
20
+ kind: 'predicate';
21
+ left: WhenOperand;
22
+ op: WhenOp;
23
+ right?: WhenOperand;
24
+ }
25
+ export interface WhenGroup {
26
+ kind: 'group';
27
+ op: 'AND' | 'OR';
28
+ children: WhenNode[];
29
+ negate?: boolean;
30
+ }
31
+ export type WhenNode = WhenPredicate | WhenGroup;
32
+ export interface SetVariableAction {
33
+ type: 'set_variable';
34
+ name: string;
35
+ seed_slug?: string;
36
+ fixed_id?: string;
37
+ column?: string;
38
+ filters?: TriggerCondition[];
39
+ order_by?: string;
40
+ order?: 'asc' | 'desc';
41
+ /** @deprecated Read but ignored at runtime. Removed on next save. */
42
+ load_type?: 'fruit' | 'branch';
43
+ }
44
+ export type AutomationAction = {
45
+ type: 'webhook';
46
+ url: string;
47
+ method?: 'POST' | 'GET' | 'PUT';
48
+ headers?: Record<string, string>;
49
+ body_template?: string;
50
+ } | {
51
+ type: 'send_mail';
52
+ to: string;
53
+ subject_template: string;
54
+ body_template: string;
55
+ } | {
56
+ type: 'edit_field';
57
+ field: string;
58
+ value: unknown;
59
+ } | {
60
+ type: 'create_entry';
61
+ seed_slug: string;
62
+ field_map: Record<string, string>;
63
+ } | SetVariableAction;
64
+ export interface Automation {
65
+ id: string;
66
+ seed_slug: string;
67
+ name: string;
68
+ enabled: boolean;
69
+ triggers: AutomationTrigger[];
70
+ trigger_conditions: WhenNode | null;
71
+ actions: AutomationAction[];
72
+ created_at: number;
73
+ updated_at: number;
74
+ }
75
+ //# sourceMappingURL=automations.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automations.types.d.ts","sourceRoot":"","sources":["../src/automations.types.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,sBAAsB,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAA;AAE5E,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,sBAAsB,CAAA;IAC7B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,EAAE,EAAE,IAAI,GAAG,KAAK,GAAG,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,GAAG,YAAY,CAAA;IACtE,KAAK,EAAE,OAAO,CAAA;CACf;AAMD,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AAEhC,MAAM,MAA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AAE,IAAI,EAAE,WAAW,CAAC;IAAI,EAAE,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GACrF;IAAE,IAAI,EAAE,YAAY,CAAC;IAAG,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAC9E,iBAAiB,CAAA;AAErB,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,iBAAiB,EAAE,CAAA;IAC7B,kBAAkB,EAAE,QAAQ,GAAG,IAAI,CAAA;IACnC,OAAO,EAAE,gBAAgB,EAAE,CAAA;IAC3B,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CACnB"}
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2024–2026 Flavio De Musso
3
+ export {};
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Time abstraction. Hides direct calls to {@link Date.now} so callers can
3
+ * swap in deterministic clocks during tests without resorting to global
4
+ * timer mocks (e.g. vi.useFakeTimers, sinon, monkey-patching Date).
5
+ */
6
+ export interface IClock {
7
+ /**
8
+ * Returns the current Unix timestamp in milliseconds.
9
+ * Equivalent to Date.now() in production.
10
+ * Overridable in tests for deterministic time-sensitive assertions.
11
+ */
12
+ now(): number;
13
+ /**
14
+ * Returns the current Unix timestamp in whole seconds.
15
+ * Equivalent to Math.floor(Date.now() / 1000) in production.
16
+ * Used by JWT issuance, session expiry, and analytics day-bucket computations.
17
+ */
18
+ nowSeconds(): number;
19
+ }
20
+ /**
21
+ * Production singleton. Delegates to the host runtime clock. Stateless and
22
+ * therefore safe to share across requests.
23
+ */
24
+ export declare const SystemClock: IClock;
25
+ //# sourceMappingURL=clock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clock.d.ts","sourceRoot":"","sources":["../src/clock.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,WAAW,MAAM;IACrB;;;;OAIG;IACH,GAAG,IAAI,MAAM,CAAA;IAEb;;;;OAIG;IACH,UAAU,IAAI,MAAM,CAAA;CACrB;AAID;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,MAGzB,CAAA"}
package/dist/clock.js ADDED
@@ -0,0 +1,11 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2024–2026 Flavio De Musso
3
+ const MILLISECONDS_PER_SECOND = 1000;
4
+ /**
5
+ * Production singleton. Delegates to the host runtime clock. Stateless and
6
+ * therefore safe to share across requests.
7
+ */
8
+ export const SystemClock = {
9
+ now: () => Date.now(),
10
+ nowSeconds: () => Math.floor(Date.now() / MILLISECONDS_PER_SECOND),
11
+ };
@@ -0,0 +1,9 @@
1
+ import type { Seed } from './types.js';
2
+ export interface IContentScanRepository {
3
+ /**
4
+ * Scans across all registered seeds to identify media keys that are currently referenced
5
+ * by any content entry. Used for orphaned media detection and storage analytics.
6
+ */
7
+ getReferencedMediaKeys(seeds: Seed[]): Promise<Set<string>>;
8
+ }
9
+ //# sourceMappingURL=content-scan.repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-scan.repository.d.ts","sourceRoot":"","sources":["../src/content-scan.repository.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEtC,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,sBAAsB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;CAC5D"}
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2024–2026 Flavio De Musso
3
+ export {};
@@ -0,0 +1,247 @@
1
+ import { Seed, SelectOptions } from './types.js';
2
+ /**
3
+ * One row of the cross-seed pending-drafts overview. Aggregates the minimum a
4
+ * reviewer needs to triage a draft without opening it: which seed it belongs to,
5
+ * a human title, when it was last touched, and who touched it.
6
+ */
7
+ export interface DraftSummary {
8
+ id: string;
9
+ seedSlug: string;
10
+ seedLabel: string;
11
+ title: string;
12
+ updatedAt: number;
13
+ lastModifiedBy: {
14
+ name: string | null;
15
+ email: string;
16
+ };
17
+ }
18
+ /**
19
+ * Base Repository Error
20
+ */
21
+ export declare class RepositoryError extends Error {
22
+ cause?: unknown | undefined;
23
+ constructor(message: string, cause?: unknown | undefined);
24
+ }
25
+ /**
26
+ * Thrown when an entry is not found by ID or Slug
27
+ */
28
+ export declare class EntryNotFoundError extends RepositoryError {
29
+ constructor(message: string);
30
+ }
31
+ /**
32
+ * Thrown when a slug already exists for a content type
33
+ */
34
+ export declare class SlugConflictError extends RepositoryError {
35
+ constructor(message: string);
36
+ }
37
+ /**
38
+ * Thrown by publishDraft when a non-null relation value points to a missing
39
+ * target row. Mapped to 422 Unprocessable Entity by the API problem-mapper.
40
+ */
41
+ export declare class RelationTargetNotFoundError extends RepositoryError {
42
+ readonly alias: string;
43
+ readonly targetSeed: string;
44
+ readonly value: string;
45
+ constructor(params: {
46
+ alias: string;
47
+ targetSeed: string;
48
+ value: string;
49
+ });
50
+ }
51
+ /**
52
+ * Thrown by lifecycle `before*` hooks to signal a business validation failure.
53
+ * Mapped to 422 Unprocessable Entity by the API problem-mapper.
54
+ */
55
+ export declare class HookValidationError extends RepositoryError {
56
+ readonly fields?: Array<{
57
+ field: string;
58
+ message: string;
59
+ }>;
60
+ constructor(message: string, fields?: Array<{
61
+ field: string;
62
+ message: string;
63
+ }>);
64
+ }
65
+ export type BulkFieldUpdate = {
66
+ kind: 'set';
67
+ value: unknown;
68
+ } | {
69
+ kind: 'array_replace';
70
+ value: string[];
71
+ } | {
72
+ kind: 'array_add';
73
+ value: string[];
74
+ } | {
75
+ kind: 'array_remove';
76
+ value: string[];
77
+ };
78
+ /**
79
+ * Options passed to write operations. Currently carries the acting user
80
+ * (extracted from the JWT) so lifecycle hooks can attribute changes.
81
+ */
82
+ export interface RepositoryOptions {
83
+ actor?: {
84
+ id: string;
85
+ role?: string;
86
+ email?: string;
87
+ };
88
+ }
89
+ /**
90
+ * Declarative multi-write operation translated into a single `db.batch` call.
91
+ * Used for coordinated writes across one or more seeds when D1's lack of
92
+ * interactive transactions makes a callback-based API impossible.
93
+ *
94
+ * NOTE: document-level lifecycle hooks do NOT run for operations inside a
95
+ * `runBatch` call — they would be non-atomic side-effects.
96
+ */
97
+ export type BatchWrite = {
98
+ kind: 'create';
99
+ seed: Seed;
100
+ id: string;
101
+ slug: string;
102
+ status: string;
103
+ data: Record<string, any>;
104
+ } | {
105
+ kind: 'update';
106
+ seed: Seed;
107
+ id: string;
108
+ data: Record<string, any>;
109
+ status?: string;
110
+ } | {
111
+ kind: 'mutateField';
112
+ seed: Seed;
113
+ id: string;
114
+ fieldName: string;
115
+ operation: {
116
+ type: 'increment' | 'decrement';
117
+ value: number;
118
+ };
119
+ options?: {
120
+ min?: number;
121
+ max?: number;
122
+ };
123
+ };
124
+ /**
125
+ * Interface defining the standard operations for content persistence.
126
+ * This is platform-agnostic and should be implemented for specific databases (e.g., D1).
127
+ */
128
+ export interface ContentRepository {
129
+ /**
130
+ * Retrieves a paginated and filtered list of entries.
131
+ */
132
+ findMany(seed: Seed, options: SelectOptions): Promise<{
133
+ items: Record<string, any>[];
134
+ total: number;
135
+ }>;
136
+ /**
137
+ * Finds a single entry by its unique ID.
138
+ * Throws EntryNotFoundError if not found.
139
+ */
140
+ findById(seed: Seed, id: string): Promise<Record<string, any>>;
141
+ /**
142
+ * Finds a single entry by its unique slug.
143
+ * Throws EntryNotFoundError if not found.
144
+ */
145
+ findBySlug(seed: Seed, slug: string): Promise<Record<string, any>>;
146
+ /**
147
+ * Computes facets (status counts and distinct tags) for a content type.
148
+ */
149
+ getFacets(seed: Seed): Promise<{
150
+ statuses: Record<string, number>;
151
+ tagsByColumn: Record<string, string[]>;
152
+ }>;
153
+ /**
154
+ * Creates a new content entry in the live table.
155
+ * Throws SlugConflictError if the slug is already taken.
156
+ */
157
+ create(seed: Seed, id: string, slug: string, status: string, data: Record<string, any>, options?: RepositoryOptions): Promise<void>;
158
+ /**
159
+ * Partially updates an existing entry in the live table.
160
+ * Throws EntryNotFoundError if the ID does not exist.
161
+ */
162
+ update(seed: Seed, id: string, data: Record<string, any>, status?: string, options?: RepositoryOptions): Promise<void>;
163
+ /**
164
+ * Deletes an entry from the live table.
165
+ * Returns the deleted row data (useful for media cleanup).
166
+ * Throws EntryNotFoundError if the ID does not exist.
167
+ */
168
+ delete(seed: Seed, id: string, options?: RepositoryOptions): Promise<{
169
+ row: Record<string, any>;
170
+ }>;
171
+ /**
172
+ * Atomically increments/decrements a numeric field with optional min/max guards.
173
+ * Bypasses document-level lifecycle hooks — it's a single UPDATE statement,
174
+ * used to prevent race conditions on counters (stock, balances).
175
+ * Throws RepositoryError if `fieldName` is not a numeric branch of `seed`, or
176
+ * if the guard conditions fail / the row does not exist.
177
+ */
178
+ mutateField(seed: Seed, id: string, fieldName: string, operation: {
179
+ type: 'increment' | 'decrement';
180
+ value: number;
181
+ }, options?: {
182
+ min?: number;
183
+ max?: number;
184
+ }): Promise<{
185
+ newValue: number;
186
+ }>;
187
+ /**
188
+ * Atomically applies an axis-value patch AND a kanban_positions upsert in one DB batch (KB-S04e).
189
+ * `patch` is null for same-column reorders (position only).
190
+ */
191
+ updateWithKanbanPosition(seed: Seed, id: string, patch: Record<string, unknown> | null, position: string, axisBranchId: string, ctx: {
192
+ actor: string;
193
+ }): Promise<{
194
+ success: boolean;
195
+ }>;
196
+ /**
197
+ * Executes a list of write operations atomically via a single `db.batch`.
198
+ * Document-level lifecycle hooks do NOT run for operations inside this call.
199
+ */
200
+ runBatch(operations: BatchWrite[]): Promise<void>;
201
+ /**
202
+ * Saves or updates a pending draft in the mirror table.
203
+ */
204
+ saveDraft(seed: Seed, entryId: string, data: Record<string, any>): Promise<void>;
205
+ /**
206
+ * Retrieves the pending draft for a given entry.
207
+ * Returns null if no draft exists.
208
+ */
209
+ getDraft(seed: Seed, entryId: string): Promise<Record<string, any> | null>;
210
+ /**
211
+ * Atomic promotion of a draft to the live table.
212
+ * Must use a transaction (db.batch) to update live and delete draft.
213
+ */
214
+ publishDraft(seed: Seed, entryId: string): Promise<void>;
215
+ /**
216
+ * Discards the pending draft.
217
+ */
218
+ deleteDraft(seed: Seed, entryId: string): Promise<void>;
219
+ /**
220
+ * Checks if a slug is already taken by another entry.
221
+ */
222
+ existsSlug(seed: Seed, slug: string, excludeId?: string): Promise<boolean>;
223
+ /**
224
+ * Checks if an entry has a pending draft.
225
+ */
226
+ hasDraft(seed: Seed, entryId: string): Promise<boolean>;
227
+ /**
228
+ * Aggregates pending drafts across every draft-enabled seed in a single round-trip.
229
+ * Exists so the unified /drafts view never issues one query per seed.
230
+ * @param seeds The draft-enabled seeds to scan (caller passes seedRegistry.draftEnabled()).
231
+ * @returns Drafts newest-first; empty array when no seeds or no drafts.
232
+ */
233
+ findPendingDrafts(seeds: Seed[]): Promise<DraftSummary[]>;
234
+ /**
235
+ * Apply the same field update to many entries. Returns per-id outcome.
236
+ * Caller is responsible for validation; this method assumes the payload is
237
+ * already shape-checked against the seed.
238
+ */
239
+ bulkUpdate(seedSlug: string, ids: string[], fields: Record<string, BulkFieldUpdate>): Promise<{
240
+ updated: number;
241
+ failed: Array<{
242
+ id: string;
243
+ reason: string;
244
+ }>;
245
+ }>;
246
+ }
247
+ //# sourceMappingURL=content.repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.repository.d.ts","sourceRoot":"","sources":["../src/content.repository.ts"],"names":[],"mappings":"AAGA,OA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CAAC,IAAI,CAAC,CAAA;IAEhF;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;IAE1E;;;OAGG;IACH,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAExD;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEvD;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAE1E;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAEvD;;;;;OAKG;IACH,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAA;IAEzD;;;;OAIG;IACH,UAAU,CACR,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,EAAE,EACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GACtC,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,KAAK,CAAC;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC,CAAA;CAC/E"}
@@ -0,0 +1,59 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2024–2026 Flavio De Musso
3
+ /**
4
+ * Base Repository Error
5
+ */
6
+ export class RepositoryError extends Error {
7
+ cause;
8
+ constructor(message, cause) {
9
+ super(message);
10
+ this.cause = cause;
11
+ this.name = 'RepositoryError';
12
+ }
13
+ }
14
+ /**
15
+ * Thrown when an entry is not found by ID or Slug
16
+ */
17
+ export class EntryNotFoundError extends RepositoryError {
18
+ constructor(message) {
19
+ super(message);
20
+ this.name = 'EntryNotFoundError';
21
+ }
22
+ }
23
+ /**
24
+ * Thrown when a slug already exists for a content type
25
+ */
26
+ export class SlugConflictError extends RepositoryError {
27
+ constructor(message) {
28
+ super(message);
29
+ this.name = 'SlugConflictError';
30
+ }
31
+ }
32
+ /**
33
+ * Thrown by publishDraft when a non-null relation value points to a missing
34
+ * target row. Mapped to 422 Unprocessable Entity by the API problem-mapper.
35
+ */
36
+ export class RelationTargetNotFoundError extends RepositoryError {
37
+ alias;
38
+ targetSeed;
39
+ value;
40
+ constructor(params) {
41
+ super(`Relation target not found: field '${params.alias}' references '${params.targetSeed}' id='${params.value}' which does not exist`);
42
+ this.name = 'RelationTargetNotFoundError';
43
+ this.alias = params.alias;
44
+ this.targetSeed = params.targetSeed;
45
+ this.value = params.value;
46
+ }
47
+ }
48
+ /**
49
+ * Thrown by lifecycle `before*` hooks to signal a business validation failure.
50
+ * Mapped to 422 Unprocessable Entity by the API problem-mapper.
51
+ */
52
+ export class HookValidationError extends RepositoryError {
53
+ fields;
54
+ constructor(message, fields) {
55
+ super(message);
56
+ this.name = 'HookValidationError';
57
+ this.fields = fields;
58
+ }
59
+ }