@beechcms/core 0.8.0 → 0.8.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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/antivirus/noop-antivirus.provider.d.ts.map +1 -1
- package/dist/antivirus/virustotal-antivirus.provider.d.ts.map +1 -1
- package/dist/automations-grammar-words.d.ts +2 -0
- package/dist/automations-grammar-words.d.ts.map +1 -0
- package/dist/automations-grammar-words.js +8 -0
- package/dist/automations.repository.interface.d.ts +19 -0
- package/dist/automations.repository.interface.d.ts.map +1 -0
- package/dist/automations.repository.interface.js +3 -0
- package/dist/automations.runner.interface.d.ts +10 -0
- package/dist/automations.runner.interface.d.ts.map +1 -0
- package/dist/automations.runner.interface.js +3 -0
- package/dist/automations.runner.stub.d.ts +5 -0
- package/dist/automations.runner.stub.d.ts.map +1 -0
- package/dist/automations.runner.stub.js +7 -0
- package/dist/automations.types.d.ts +75 -0
- package/dist/automations.types.d.ts.map +1 -0
- package/dist/automations.types.js +3 -0
- package/dist/clock.d.ts +25 -0
- package/dist/clock.d.ts.map +1 -0
- package/dist/clock.js +11 -0
- package/dist/common/canonical-json.d.ts +30 -0
- package/dist/common/canonical-json.d.ts.map +1 -0
- package/dist/common/canonical-json.js +89 -0
- package/dist/content/content.repository.d.ts +2 -2
- package/dist/content/content.repository.d.ts.map +1 -1
- package/dist/content/deletion-ledger.d.ts +39 -0
- package/dist/content/deletion-ledger.d.ts.map +1 -0
- package/dist/content/deletion-ledger.js +3 -0
- package/dist/content-scan.repository.d.ts +9 -0
- package/dist/content-scan.repository.d.ts.map +1 -0
- package/dist/content-scan.repository.js +3 -0
- package/dist/content.repository.d.ts +247 -0
- package/dist/content.repository.d.ts.map +1 -0
- package/dist/content.repository.js +59 -0
- package/dist/dashboard-layout.d.ts +154 -0
- package/dist/dashboard-layout.d.ts.map +1 -0
- package/dist/dashboard-layout.js +186 -0
- package/dist/dashboard-layout.repository.d.ts +18 -0
- package/dist/dashboard-layout.repository.d.ts.map +1 -0
- package/dist/dashboard-layout.repository.js +3 -0
- package/dist/dashboard-permissions.d.ts +3 -0
- package/dist/dashboard-permissions.d.ts.map +1 -0
- package/dist/dashboard-permissions.js +11 -0
- package/dist/dashboard-scopes.d.ts +12 -0
- package/dist/dashboard-scopes.d.ts.map +1 -0
- package/dist/dashboard-scopes.js +30 -0
- package/dist/define-seed.d.ts +3 -0
- package/dist/define-seed.d.ts.map +1 -0
- package/dist/define-seed.js +5 -0
- package/dist/demo-data.repository.d.ts +5 -0
- package/dist/demo-data.repository.d.ts.map +1 -0
- package/dist/demo-data.repository.js +3 -0
- package/dist/email.provider.d.ts +32 -0
- package/dist/email.provider.d.ts.map +1 -0
- package/dist/email.provider.js +4 -0
- package/dist/engine/ddl/ddl.d.ts +216 -0
- package/dist/engine/ddl/ddl.d.ts.map +1 -0
- package/dist/engine/ddl/ddl.js +574 -0
- package/dist/engine/ddl/schema-mutator.d.ts +26 -0
- package/dist/engine/ddl/schema-mutator.d.ts.map +1 -0
- package/dist/engine/ddl/schema-mutator.js +3 -0
- package/dist/engine/ddl/seed-ddl-destructive.d.ts +40 -0
- package/dist/engine/ddl/seed-ddl-destructive.d.ts.map +1 -0
- package/dist/engine/ddl/seed-ddl-destructive.js +149 -0
- package/dist/engine/ddl/seed-ddl.d.ts +43 -0
- package/dist/engine/ddl/seed-ddl.d.ts.map +1 -0
- package/dist/engine/ddl/seed-ddl.js +115 -0
- package/dist/engine/introspection/introspection.d.ts +101 -0
- package/dist/engine/introspection/introspection.d.ts.map +1 -0
- package/dist/engine/introspection/introspection.js +127 -0
- package/dist/engine/introspection/schema-fingerprint.d.ts +73 -0
- package/dist/engine/introspection/schema-fingerprint.d.ts.map +1 -0
- package/dist/engine/introspection/schema-fingerprint.js +97 -0
- package/dist/engine/introspection.d.ts +101 -0
- package/dist/engine/introspection.d.ts.map +1 -0
- package/dist/engine/introspection.js +127 -0
- package/dist/engine/localization/localization.d.ts +127 -0
- package/dist/engine/localization/localization.d.ts.map +1 -0
- package/dist/engine/localization/localization.js +212 -0
- package/dist/engine/localization.d.ts +127 -0
- package/dist/engine/localization.d.ts.map +1 -0
- package/dist/engine/localization.js +212 -0
- package/dist/engine/privacy/policies.d.ts +58 -0
- package/dist/engine/privacy/policies.d.ts.map +1 -0
- package/dist/engine/privacy/policies.js +185 -0
- package/dist/engine/privacy/privacy.service.d.ts +65 -0
- package/dist/engine/privacy/privacy.service.d.ts.map +1 -0
- package/dist/engine/privacy/privacy.service.js +114 -0
- package/dist/engine/privacy.service.d.ts.map +1 -1
- package/dist/engine/query/query.d.ts +23 -0
- package/dist/engine/query/query.d.ts.map +1 -0
- package/dist/engine/query/query.js +301 -0
- package/dist/engine/query/relations.d.ts +28 -0
- package/dist/engine/query/relations.d.ts.map +1 -0
- package/dist/engine/query/relations.js +25 -0
- package/dist/engine/query/serialize.d.ts +22 -0
- package/dist/engine/query/serialize.d.ts.map +1 -0
- package/dist/engine/query/serialize.js +175 -0
- package/dist/engine/schema-fingerprint.d.ts +73 -0
- package/dist/engine/schema-fingerprint.d.ts.map +1 -0
- package/dist/engine/schema-fingerprint.js +97 -0
- package/dist/engine/seed-registry.d.ts.map +1 -1
- package/dist/engine/seeds/define-seed.d.ts +3 -0
- package/dist/engine/seeds/define-seed.d.ts.map +1 -0
- package/dist/engine/seeds/define-seed.js +5 -0
- package/dist/engine/seeds/seed-registry.d.ts +71 -0
- package/dist/engine/seeds/seed-registry.d.ts.map +1 -0
- package/dist/engine/seeds/seed-registry.js +167 -0
- package/dist/engine/seeds/seed-types-generator.d.ts +25 -0
- package/dist/engine/seeds/seed-types-generator.d.ts.map +1 -0
- package/dist/engine/seeds/seed-types-generator.js +117 -0
- package/dist/engine/seeds/seed-validation.d.ts +30 -0
- package/dist/engine/seeds/seed-validation.d.ts.map +1 -0
- package/dist/engine/seeds/seed-validation.js +364 -0
- package/dist/engine/seeds/seeds.d.ts +20 -0
- package/dist/engine/seeds/seeds.d.ts.map +1 -0
- package/dist/engine/seeds/seeds.js +21 -0
- package/dist/engine/validation/emptiness.d.ts +12 -0
- package/dist/engine/validation/emptiness.d.ts.map +1 -0
- package/dist/engine/validation/emptiness.js +33 -0
- package/dist/engine/validation/index.d.ts +1 -1
- package/dist/engine/validation/index.d.ts.map +1 -1
- package/dist/engine.d.ts +144 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +741 -0
- package/dist/file-types.d.ts +13 -0
- package/dist/file-types.d.ts.map +1 -0
- package/dist/file-types.js +85 -0
- package/dist/hooks.d.ts +29 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +3 -0
- package/dist/id-generator.d.ts +26 -0
- package/dist/id-generator.d.ts.map +1 -0
- package/dist/id-generator.js +12 -0
- package/dist/idempotency.repository.d.ts +13 -0
- package/dist/idempotency.repository.d.ts.map +1 -0
- package/dist/idempotency.repository.js +3 -0
- package/dist/kanban-position.repository.d.ts +19 -0
- package/dist/kanban-position.repository.d.ts.map +1 -0
- package/dist/kanban-position.repository.js +3 -0
- package/dist/kanban.d.ts +75 -0
- package/dist/kanban.d.ts.map +1 -0
- package/dist/kanban.js +82 -0
- package/dist/layout-permissions.d.ts +3 -0
- package/dist/layout-permissions.d.ts.map +1 -0
- package/dist/layout-permissions.js +11 -0
- package/dist/media/image-transformer.d.ts +34 -0
- package/dist/media/image-transformer.d.ts.map +1 -0
- package/dist/media/image-transformer.js +3 -0
- package/dist/media/media-transform.d.ts +88 -0
- package/dist/media/media-transform.d.ts.map +1 -0
- package/dist/media/media-transform.js +193 -0
- package/dist/media.repository.d.ts +61 -0
- package/dist/media.repository.d.ts.map +1 -0
- package/dist/media.repository.js +3 -0
- package/dist/notifications/notification-service.d.ts +1 -1
- package/dist/oauth/pkce.d.ts +1 -1
- package/dist/oauth/role-guard.d.ts.map +1 -1
- package/dist/oauth/scopes.d.ts +1 -1
- package/dist/oauth/scopes.d.ts.map +1 -1
- package/dist/policies.d.ts +10 -0
- package/dist/policies.d.ts.map +1 -0
- package/dist/policies.js +33 -0
- package/dist/queue/queue.stub.d.ts.map +1 -1
- package/dist/queue/scheduler.stub.d.ts.map +1 -1
- package/dist/queue.interface.d.ts +39 -0
- package/dist/queue.interface.d.ts.map +1 -0
- package/dist/queue.interface.js +3 -0
- package/dist/queue.stub.d.ts +6 -0
- package/dist/queue.stub.d.ts.map +1 -0
- package/dist/queue.stub.js +8 -0
- package/dist/rate-limit/token-bucket-rate-limiter.d.ts.map +1 -1
- package/dist/rbac/evaluate.d.ts +57 -0
- package/dist/rbac/evaluate.d.ts.map +1 -0
- package/dist/rbac/evaluate.js +113 -0
- package/dist/rbac/invitation.repository.d.ts +66 -0
- package/dist/rbac/invitation.repository.d.ts.map +1 -0
- package/dist/rbac/invitation.repository.js +3 -0
- package/dist/rbac/permissions.d.ts +39 -0
- package/dist/rbac/permissions.d.ts.map +1 -0
- package/dist/rbac/permissions.js +43 -0
- package/dist/rbac/types.d.ts +118 -0
- package/dist/rbac/types.d.ts.map +1 -0
- package/dist/rbac/types.js +3 -0
- package/dist/relations.d.ts +28 -0
- package/dist/relations.d.ts.map +1 -0
- package/dist/relations.js +25 -0
- package/dist/richtext-render.d.ts +11 -0
- package/dist/richtext-render.d.ts.map +1 -0
- package/dist/richtext-render.js +87 -0
- package/dist/richtext.d.ts +11 -0
- package/dist/richtext.d.ts.map +1 -0
- package/dist/richtext.js +13 -0
- package/dist/scheduler.interface.d.ts +4 -0
- package/dist/scheduler.interface.d.ts.map +1 -0
- package/dist/scheduler.interface.js +3 -0
- package/dist/scheduler.stub.d.ts +5 -0
- package/dist/scheduler.stub.d.ts.map +1 -0
- package/dist/scheduler.stub.js +7 -0
- package/dist/schema/canonical.d.ts +15 -0
- package/dist/schema/canonical.d.ts.map +1 -0
- package/dist/schema/canonical.js +37 -0
- package/dist/schema/define.d.ts +42 -0
- package/dist/schema/define.d.ts.map +1 -0
- package/dist/schema/define.js +56 -0
- package/dist/schema/emit.d.ts +14 -0
- package/dist/schema/emit.d.ts.map +1 -0
- package/dist/schema/emit.js +43 -0
- package/dist/schema/index.d.ts +12 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +13 -0
- package/dist/schema/manifest-seeds.d.ts +12 -0
- package/dist/schema/manifest-seeds.d.ts.map +1 -0
- package/dist/schema/manifest-seeds.js +48 -0
- package/dist/schema/manifest-validation.d.ts +13 -0
- package/dist/schema/manifest-validation.d.ts.map +1 -0
- package/dist/schema/manifest-validation.js +41 -0
- package/dist/schema/manifest.types.d.ts +54 -0
- package/dist/schema/manifest.types.d.ts.map +1 -0
- package/dist/schema/manifest.types.js +7 -0
- package/dist/schema-mutator.d.ts +26 -0
- package/dist/schema-mutator.d.ts.map +1 -0
- package/dist/schema-mutator.js +3 -0
- package/dist/seed-ddl-destructive.d.ts +40 -0
- package/dist/seed-ddl-destructive.d.ts.map +1 -0
- package/dist/seed-ddl-destructive.js +149 -0
- package/dist/seed-ddl.d.ts +40 -0
- package/dist/seed-ddl.d.ts.map +1 -0
- package/dist/seed-ddl.js +100 -0
- package/dist/seed-layout.d.ts +145 -0
- package/dist/seed-layout.d.ts.map +1 -0
- package/dist/seed-layout.js +192 -0
- package/dist/seed-layout.repository.d.ts +22 -0
- package/dist/seed-layout.repository.d.ts.map +1 -0
- package/dist/seed-layout.repository.js +3 -0
- package/dist/seed-registry.d.ts +71 -0
- package/dist/seed-registry.d.ts.map +1 -0
- package/dist/seed-registry.js +143 -0
- package/dist/seed-types-generator.d.ts +1 -1
- package/dist/seed-types-generator.d.ts.map +1 -1
- package/dist/seed-validation.d.ts +23 -0
- package/dist/seed-validation.d.ts.map +1 -0
- package/dist/seed-validation.js +224 -0
- package/dist/seed.repository.d.ts +37 -0
- package/dist/seed.repository.d.ts.map +1 -0
- package/dist/seed.repository.js +3 -0
- package/dist/seeds.d.ts +20 -0
- package/dist/seeds.d.ts.map +1 -0
- package/dist/seeds.js +21 -0
- package/dist/site-settings.repository.d.ts +16 -0
- package/dist/site-settings.repository.d.ts.map +1 -0
- package/dist/site-settings.repository.js +3 -0
- package/dist/slug-utils.d.ts +18 -0
- package/dist/slug-utils.d.ts.map +1 -0
- package/dist/slug-utils.js +32 -0
- package/dist/storage.d.ts +46 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +3 -0
- package/dist/transfer/csv.d.ts +34 -0
- package/dist/transfer/csv.d.ts.map +1 -0
- package/dist/transfer/csv.js +135 -0
- package/dist/transfer/flat-seed.d.ts +13 -0
- package/dist/transfer/flat-seed.d.ts.map +1 -0
- package/dist/transfer/flat-seed.js +45 -0
- package/dist/transfer/index.d.ts +7 -0
- package/dist/transfer/index.d.ts.map +1 -0
- package/dist/transfer/index.js +8 -0
- package/dist/transfer/ndjson.d.ts +25 -0
- package/dist/transfer/ndjson.d.ts.map +1 -0
- package/dist/transfer/ndjson.js +62 -0
- package/dist/transfer/row-mapping.d.ts +36 -0
- package/dist/transfer/row-mapping.d.ts.map +1 -0
- package/dist/transfer/row-mapping.js +90 -0
- package/dist/transfer/transfer.constants.d.ts +20 -0
- package/dist/transfer/transfer.constants.d.ts.map +1 -0
- package/dist/transfer/transfer.constants.js +21 -0
- package/dist/transfer/transfer.types.d.ts +46 -0
- package/dist/transfer/transfer.types.d.ts.map +1 -0
- package/dist/transfer/transfer.types.js +6 -0
- package/dist/types.d.ts +243 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/validation.d.ts +50 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +660 -0
- package/dist/webhook-validation.d.ts +3 -0
- package/dist/webhook-validation.d.ts.map +1 -0
- package/dist/webhook-validation.js +6 -0
- package/package.json +4 -4
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type FileAccept = 'image' | 'document' | 'any';
|
|
2
|
+
export declare const IMAGE_EXTENSIONS: Set<string>;
|
|
3
|
+
export declare const BLOCKED_IMAGE_EXTENSIONS: Set<string>;
|
|
4
|
+
export declare const DOCUMENT_EXTENSIONS: Set<string>;
|
|
5
|
+
export declare const ARCHIVE_EXTENSIONS: Set<string>;
|
|
6
|
+
export declare const IMAGE_MIME_TYPES: readonly ["image/jpeg", "image/png", "image/gif", "image/webp", "image/avif", "image/bmp", "image/x-icon", "image/vnd.microsoft.icon"];
|
|
7
|
+
export declare const BLOCKED_IMAGE_MIME_TYPES: readonly ["image/svg+xml", "image/svg"];
|
|
8
|
+
export declare const DOCUMENT_MIME_TYPES: readonly ["application/pdf", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "text/plain", "text/csv", "text/markdown"];
|
|
9
|
+
export declare const ARCHIVE_MIME_TYPES: readonly ["application/zip", "application/x-zip-compressed", "application/x-7z-compressed", "application/x-tar", "application/gzip", "application/json"];
|
|
10
|
+
export declare function extensionFromUrl(url: string): string | null;
|
|
11
|
+
export declare function isExtensionAccepted(ext: string | null, accept: FileAccept): boolean;
|
|
12
|
+
export declare function isMimeAccepted(mime: string, accept: FileAccept): boolean;
|
|
13
|
+
//# sourceMappingURL=file-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-types.d.ts","sourceRoot":"","sources":["../src/file-types.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,KAAK,CAAA;AAKrD,eAAO,MAAM,gBAAgB,aAAuE,CAAA;AACpG,eAAO,MAAM,wBAAwB,aAA2B,CAAA;AAChE,eAAO,MAAM,mBAAmB,aAAoF,CAAA;AACpH,eAAO,MAAM,kBAAkB,aAA8C,CAAA;AAI7E,eAAO,MAAM,gBAAgB,wIASnB,CAAA;AAGV,eAAO,MAAM,wBAAwB,yCAA0C,CAAA;AAC/E,eAAO,MAAM,mBAAmB,yXAWtB,CAAA;AACV,eAAO,MAAM,kBAAkB,0JAOrB,CAAA;AAEV,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAS3D;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAMnF;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAcxE"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copyright (c) 2024–2026 Flavio De Musso
|
|
3
|
+
// SVG is intentionally excluded: SVG can embed <script> tags and is rendered
|
|
4
|
+
// inline by browsers when served as image/svg+xml on a same-origin route,
|
|
5
|
+
// creating a stored XSS vector (see security audit finding #4).
|
|
6
|
+
export const IMAGE_EXTENSIONS = new Set(['jpg', 'jpeg', 'png', 'gif', 'webp', 'avif', 'bmp', 'ico']);
|
|
7
|
+
export const BLOCKED_IMAGE_EXTENSIONS = new Set(['svg', 'svgz']);
|
|
8
|
+
export const DOCUMENT_EXTENSIONS = new Set(['pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'csv', 'md']);
|
|
9
|
+
export const ARCHIVE_EXTENSIONS = new Set(['zip', '7z', 'tar', 'gz', 'json']);
|
|
10
|
+
// Explicitly enumerate safe image MIME types instead of using the wildcard
|
|
11
|
+
// `image/*` prefix, which would permit `image/svg+xml` and other XSS vectors.
|
|
12
|
+
export const IMAGE_MIME_TYPES = [
|
|
13
|
+
'image/jpeg',
|
|
14
|
+
'image/png',
|
|
15
|
+
'image/gif',
|
|
16
|
+
'image/webp',
|
|
17
|
+
'image/avif',
|
|
18
|
+
'image/bmp',
|
|
19
|
+
'image/x-icon',
|
|
20
|
+
'image/vnd.microsoft.icon',
|
|
21
|
+
];
|
|
22
|
+
// Blocked image MIME types — listed explicitly so upload code can reject them
|
|
23
|
+
// with a clear error rather than a generic "file type not allowed".
|
|
24
|
+
export const BLOCKED_IMAGE_MIME_TYPES = ['image/svg+xml', 'image/svg'];
|
|
25
|
+
export const DOCUMENT_MIME_TYPES = [
|
|
26
|
+
'application/pdf',
|
|
27
|
+
'application/msword',
|
|
28
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
29
|
+
'application/vnd.ms-excel',
|
|
30
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
31
|
+
'application/vnd.ms-powerpoint',
|
|
32
|
+
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
33
|
+
'text/plain',
|
|
34
|
+
'text/csv',
|
|
35
|
+
'text/markdown',
|
|
36
|
+
];
|
|
37
|
+
export const ARCHIVE_MIME_TYPES = [
|
|
38
|
+
'application/zip',
|
|
39
|
+
'application/x-zip-compressed',
|
|
40
|
+
'application/x-7z-compressed',
|
|
41
|
+
'application/x-tar',
|
|
42
|
+
'application/gzip',
|
|
43
|
+
'application/json',
|
|
44
|
+
];
|
|
45
|
+
export function extensionFromUrl(url) {
|
|
46
|
+
try {
|
|
47
|
+
const path = new URL(url).pathname;
|
|
48
|
+
const dot = path.lastIndexOf('.');
|
|
49
|
+
if (dot < 0 || dot === path.length - 1)
|
|
50
|
+
return null;
|
|
51
|
+
return path.slice(dot + 1).toLowerCase();
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export function isExtensionAccepted(ext, accept) {
|
|
58
|
+
if (accept === 'any')
|
|
59
|
+
return true;
|
|
60
|
+
if (ext == null)
|
|
61
|
+
return false;
|
|
62
|
+
if (accept === 'image')
|
|
63
|
+
return IMAGE_EXTENSIONS.has(ext);
|
|
64
|
+
if (accept === 'document')
|
|
65
|
+
return DOCUMENT_EXTENSIONS.has(ext);
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
export function isMimeAccepted(mime, accept) {
|
|
69
|
+
// Normalise: strip parameters (e.g. "image/jpeg; charset=utf-8" → "image/jpeg")
|
|
70
|
+
const normalised = mime.split(';')[0].trim().toLowerCase();
|
|
71
|
+
// Unconditionally reject SVG regardless of accept mode — SVG can carry
|
|
72
|
+
// embedded scripts and is rendered by browsers when served inline.
|
|
73
|
+
if (BLOCKED_IMAGE_MIME_TYPES.includes(normalised))
|
|
74
|
+
return false;
|
|
75
|
+
if (accept === 'any') {
|
|
76
|
+
return IMAGE_MIME_TYPES.includes(normalised)
|
|
77
|
+
|| DOCUMENT_MIME_TYPES.includes(normalised)
|
|
78
|
+
|| ARCHIVE_MIME_TYPES.includes(normalised);
|
|
79
|
+
}
|
|
80
|
+
if (accept === 'image')
|
|
81
|
+
return IMAGE_MIME_TYPES.includes(normalised);
|
|
82
|
+
if (accept === 'document')
|
|
83
|
+
return DOCUMENT_MIME_TYPES.includes(normalised);
|
|
84
|
+
return false;
|
|
85
|
+
}
|
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ContentRepository } from './content.repository.js';
|
|
2
|
+
import type { Seed } from './types.js';
|
|
3
|
+
export interface HookActor {
|
|
4
|
+
id: string;
|
|
5
|
+
role?: string;
|
|
6
|
+
email?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface HookContext {
|
|
9
|
+
seed: Seed;
|
|
10
|
+
/** Canale lecito per side-effect sui contenuti dagli hook (rispetta la Botanical Engine). */
|
|
11
|
+
repository: ContentRepository;
|
|
12
|
+
/** Utente che esegue l'operazione, estratto dal JWT. Assente per operazioni di sistema/cron. */
|
|
13
|
+
actor?: HookActor;
|
|
14
|
+
/**
|
|
15
|
+
* Escape hatch per la connessione nativa (D1Database in prod, better-sqlite3 nei test).
|
|
16
|
+
* Tipizzato `unknown` per non accoppiare @beechcms/core a Cloudflare. Usare con cautela:
|
|
17
|
+
* scrivere qui bypassa la Botanical Engine.
|
|
18
|
+
*/
|
|
19
|
+
db: unknown;
|
|
20
|
+
}
|
|
21
|
+
export interface BeechHooks {
|
|
22
|
+
beforeCreate?: (data: Record<string, any>, ctx: HookContext) => Promise<Record<string, any> | void> | Record<string, any> | void;
|
|
23
|
+
beforeUpdate?: (id: string, patches: Record<string, any>, ctx: HookContext) => Promise<Record<string, any> | void> | Record<string, any> | void;
|
|
24
|
+
beforeDelete?: (id: string, ctx: HookContext) => Promise<void> | void;
|
|
25
|
+
afterCreate?: (entry: Record<string, any>, ctx: HookContext) => Promise<void> | void;
|
|
26
|
+
afterUpdate?: (entry: Record<string, any>, ctx: HookContext) => Promise<void> | void;
|
|
27
|
+
afterDelete?: (id: string, ctx: HookContext) => Promise<void> | void;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEtC,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,IAAI,CAAA;IACV,6FAA6F;IAC7F,UAAU,EAAE,iBAAiB,CAAA;IAC7B,gGAAgG;IAChG,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB;;;;OAIG;IACH,EAAE,EAAE,OAAO,CAAA;CACZ;AAED,MAAM,WAAW,UAAU;IAGzB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAA;IAChI,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAA;IAC/I,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IAGrE,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACpF,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACpF,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;CACrE"}
|
package/dist/hooks.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identifier abstraction. Hides direct calls to {@link crypto.randomUUID}
|
|
3
|
+
* so callers can swap in deterministic generators during tests for stable
|
|
4
|
+
* snapshot assertions and predictable insert ordering.
|
|
5
|
+
*/
|
|
6
|
+
export interface IIdGenerator {
|
|
7
|
+
/**
|
|
8
|
+
* Generates a new universally unique identifier.
|
|
9
|
+
* Production implementation delegates to crypto.randomUUID().
|
|
10
|
+
* Test implementations return deterministic values for snapshot assertions.
|
|
11
|
+
*/
|
|
12
|
+
uuid(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Returns true when `value` has the exact shape produced by `uuid()`.
|
|
15
|
+
* The ONLY place in the codebase that knows the id format. Never inline
|
|
16
|
+
* a regex; always go through this method when validating a relation id,
|
|
17
|
+
* a route param, or any user-supplied id.
|
|
18
|
+
*/
|
|
19
|
+
isValid(value: unknown): value is string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Production singleton. Delegates to the host runtime CSPRNG-backed UUID
|
|
23
|
+
* generator. Stateless and therefore safe to share across requests.
|
|
24
|
+
*/
|
|
25
|
+
export declare const SystemIdGenerator: IIdGenerator;
|
|
26
|
+
//# sourceMappingURL=id-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id-generator.d.ts","sourceRoot":"","sources":["../src/id-generator.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,IAAI,IAAI,MAAM,CAAA;IAEd;;;;;OAKG;IACH,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAA;CACzC;AAMD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,YAI/B,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copyright (c) 2024–2026 Flavio De Musso
|
|
3
|
+
// Internal — never exported. Callers depend on the interface, not the shape.
|
|
4
|
+
const SYSTEM_ID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
5
|
+
/**
|
|
6
|
+
* Production singleton. Delegates to the host runtime CSPRNG-backed UUID
|
|
7
|
+
* generator. Stateless and therefore safe to share across requests.
|
|
8
|
+
*/
|
|
9
|
+
export const SystemIdGenerator = {
|
|
10
|
+
uuid: () => crypto.randomUUID(),
|
|
11
|
+
isValid: (value) => typeof value === 'string' && SYSTEM_ID_REGEX.test(value),
|
|
12
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface IdempotencyRecord {
|
|
2
|
+
key: string;
|
|
3
|
+
fingerprint: string;
|
|
4
|
+
responseStatus: number;
|
|
5
|
+
responseBody: string;
|
|
6
|
+
expiresAt: number;
|
|
7
|
+
}
|
|
8
|
+
export interface IdempotencyRepository {
|
|
9
|
+
lookup(key: string): Promise<IdempotencyRecord | null>;
|
|
10
|
+
store(record: IdempotencyRecord): Promise<void>;
|
|
11
|
+
cleanup(now: number): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=idempotency.repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idempotency.repository.d.ts","sourceRoot":"","sources":["../src/idempotency.repository.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAA;IACtD,KAAK,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/C,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACpC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface KanbanPositionRecord {
|
|
2
|
+
entryId: string;
|
|
3
|
+
position: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Persistence contract for card ordering. The ONLY gateway to `kanban_positions`.
|
|
7
|
+
* Handlers and the dashboard never touch the table directly (Botanical invariant).
|
|
8
|
+
*/
|
|
9
|
+
export interface IKanbanPositionRepository {
|
|
10
|
+
/** entryId → position for one column axis (entries without a row are omitted). */
|
|
11
|
+
getColumn(seedSlug: string, axisBranchId: string): Promise<Map<string, string>>;
|
|
12
|
+
/** Single-row upsert — exactly one write per drag (KB-S04b). */
|
|
13
|
+
setPosition(seedSlug: string, entryId: string, axisBranchId: string, position: string): Promise<void>;
|
|
14
|
+
/** Remove an entry's position row (e.g. entry deleted). */
|
|
15
|
+
remove(seedSlug: string, entryId: string, axisBranchId: string): Promise<void>;
|
|
16
|
+
/** Async rebalance (KB-S04f): rewrite a whole column's positions in one batch. */
|
|
17
|
+
rebalance(seedSlug: string, axisBranchId: string, ordered: KanbanPositionRecord[]): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=kanban-position.repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kanban-position.repository.d.ts","sourceRoot":"","sources":["../src/kanban-position.repository.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,kFAAkF;IAClF,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAC/E,gEAAgE;IAChE,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACrG,2DAA2D;IAC3D,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9E,kFAAkF;IAClF,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAClG"}
|
package/dist/kanban.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { Seed, Branch, FilterGroup } from './types.js';
|
|
2
|
+
/** Branch types that can form a discrete, finite set of columns (KB §2). */
|
|
3
|
+
export type KanbanAxisBranchType = 'text' | 'tags' | 'boolean';
|
|
4
|
+
/** A branch eligible to be the kanban axis. */
|
|
5
|
+
export interface KanbanAxisCandidate {
|
|
6
|
+
/** Stable branch id (br_XX) — persisted as the axis key. Never the alias. */
|
|
7
|
+
branchId: string;
|
|
8
|
+
alias: string;
|
|
9
|
+
label: string;
|
|
10
|
+
type: KanbanAxisBranchType;
|
|
11
|
+
}
|
|
12
|
+
/** A single column on the board, in deterministic display order (Q2). */
|
|
13
|
+
export interface KanbanColumnDescriptor {
|
|
14
|
+
/** The discrete axis value. `null` ⇒ the always-last "Senza valore" column. */
|
|
15
|
+
value: string | null;
|
|
16
|
+
label: string;
|
|
17
|
+
}
|
|
18
|
+
/** Per-seed, dashboard-side kanban view preferences. Persisted in
|
|
19
|
+
* seed_layouts.view_config (KB-S02). NOT part of FormLayout. */
|
|
20
|
+
export interface KanbanConfig {
|
|
21
|
+
/** Chosen axis branch id, or null when the user has not configured one (KB-U02). */
|
|
22
|
+
axisBranchId: string | null;
|
|
23
|
+
/** Card sort inside columns. null ⇒ manual order via kanban_positions (KB-U22b). */
|
|
24
|
+
sort: {
|
|
25
|
+
branchId: string;
|
|
26
|
+
dir: 'ASC' | 'DESC';
|
|
27
|
+
} | null;
|
|
28
|
+
/** Axis values the user chose to hide when columns exceed the cap (KB-U06c). */
|
|
29
|
+
hiddenColumnValues?: string[];
|
|
30
|
+
}
|
|
31
|
+
export type KanbanIncompatibleReason = 'drafts-enabled' | 'no-candidate-branch';
|
|
32
|
+
export interface KanbanCompatibility {
|
|
33
|
+
compatible: boolean;
|
|
34
|
+
reason?: KanbanIncompatibleReason;
|
|
35
|
+
candidates: KanbanAxisCandidate[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Determines whether a seed can be displayed as a Kanban board, and which
|
|
39
|
+
* branches may serve as the column axis. Pure — no I/O. (KB-S01)
|
|
40
|
+
*
|
|
41
|
+
* Q3: seeds with `allowDrafts: true` are NOT kanban-compatible.
|
|
42
|
+
*/
|
|
43
|
+
export declare function resolveKanbanConfig(seed: Seed): KanbanCompatibility;
|
|
44
|
+
/**
|
|
45
|
+
* Deterministic, stable column order for a chosen axis (Q2). The "Senza valore"
|
|
46
|
+
* (value: null) column is always appended last. Values out of `options` are NOT
|
|
47
|
+
* given their own column (KB-U25) — the board folds them into "Senza valore".
|
|
48
|
+
*
|
|
49
|
+
* @param distinctTagValues unique tag values observed in data (tags axis without options).
|
|
50
|
+
*/
|
|
51
|
+
export declare function resolveKanbanColumns(branch: Branch, distinctTagValues?: string[]): KanbanColumnDescriptor[];
|
|
52
|
+
/**
|
|
53
|
+
* Pure: the FilterGroup selecting one kanban column's entries for a given axis branch.
|
|
54
|
+
* `value: null` ⇒ "Senza valore" — entries where the axis field is NULL or empty (KB-U25).
|
|
55
|
+
* Boolean descriptor values 'true'/'false' are coerced to actual booleans for the engine.
|
|
56
|
+
*/
|
|
57
|
+
/** Body of PATCH /:slug/:id/kanban-move. The server applies the axis change (if any)
|
|
58
|
+
* AND the position upsert atomically (KB-S04e). */
|
|
59
|
+
export interface KanbanMoveBody {
|
|
60
|
+
/** Axis branch id (br_XX). Identifies which kanban_positions row + which branch to patch. */
|
|
61
|
+
axisBranchId: string;
|
|
62
|
+
/** New fractional-index key for this entry in the destination column (KB-S04b/d). */
|
|
63
|
+
position: string;
|
|
64
|
+
/** Present only on a cross-column move (axis value changed). Omit for same-column reorder. */
|
|
65
|
+
axis?: {
|
|
66
|
+
kind: 'scalar';
|
|
67
|
+
value: string | null;
|
|
68
|
+
} | {
|
|
69
|
+
kind: 'tags';
|
|
70
|
+
oldValue: string | null;
|
|
71
|
+
newValue: string | null;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export declare function kanbanColumnFilter(branch: Branch, value: string | null): FilterGroup;
|
|
75
|
+
//# sourceMappingURL=kanban.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kanban.d.ts","sourceRoot":"","sources":["../src/kanban.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE3D,4EAA4E;AAC5E,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;AAE9D,+CAA+C;AAC/C,MAAM,WAAW,mBAAmB;IAClC,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,oBAAoB,CAAA;CAC3B;AAED,yEAAyE;AACzE,MAAM,WAAW,sBAAsB;IACrC,+EAA+E;IAC/E,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;CACd;AAED;iEACiE;AACjE,MAAM,WAAW,YAAY;IAC3B,oFAAoF;IACpF,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,oFAAoF;IACpF,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,KAAK,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IACtD,gFAAgF;IAChF,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC9B;AAED,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,GAAG,qBAAqB,CAAA;AAE/E,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EAAE,wBAAwB,CAAA;IACjC,UAAU,EAAE,mBAAmB,EAAE,CAAA;CAClC;AAgBD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,mBAAmB,CAanE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,iBAAiB,GAAE,MAAM,EAAO,GAC/B,sBAAsB,EAAE,CAiB1B;AAED;;;;GAIG;AACH;oDACoD;AACpD,MAAM,WAAW,cAAc;IAC7B,6FAA6F;IAC7F,YAAY,EAAE,MAAM,CAAA;IACpB,qFAAqF;IACrF,QAAQ,EAAE,MAAM,CAAA;IAChB,8FAA8F;IAC9F,IAAI,CAAC,EACD;QAAE,IAAI,EAAE,QAAQ,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GACxC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAA;CACvE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,CAYpF"}
|
package/dist/kanban.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copyright (c) 2024–2026 Flavio De Musso
|
|
3
|
+
/** Branch types that are explicitly never an axis (KB §2). */
|
|
4
|
+
const NON_AXIS_TYPES = new Set([
|
|
5
|
+
'richtext', 'file', 'number', 'date', 'json', 'relation', 'repeater',
|
|
6
|
+
]);
|
|
7
|
+
function isAxisCandidate(b) {
|
|
8
|
+
if (b.alias === 'status')
|
|
9
|
+
return null; // system status excluded (KB §2)
|
|
10
|
+
if (NON_AXIS_TYPES.has(b.type))
|
|
11
|
+
return null;
|
|
12
|
+
if (b.type === 'text')
|
|
13
|
+
return (b.options && b.options.length > 0) ? 'text' : null;
|
|
14
|
+
if (b.type === 'tags')
|
|
15
|
+
return 'tags';
|
|
16
|
+
if (b.type === 'boolean')
|
|
17
|
+
return 'boolean';
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Determines whether a seed can be displayed as a Kanban board, and which
|
|
22
|
+
* branches may serve as the column axis. Pure — no I/O. (KB-S01)
|
|
23
|
+
*
|
|
24
|
+
* Q3: seeds with `allowDrafts: true` are NOT kanban-compatible.
|
|
25
|
+
*/
|
|
26
|
+
export function resolveKanbanConfig(seed) {
|
|
27
|
+
if (seed.allowDrafts) {
|
|
28
|
+
return { compatible: false, reason: 'drafts-enabled', candidates: [] };
|
|
29
|
+
}
|
|
30
|
+
const candidates = [];
|
|
31
|
+
for (const b of seed.branches) {
|
|
32
|
+
const type = isAxisCandidate(b);
|
|
33
|
+
if (type)
|
|
34
|
+
candidates.push({ branchId: b.id, alias: b.alias, label: b.label, type });
|
|
35
|
+
}
|
|
36
|
+
if (candidates.length === 0) {
|
|
37
|
+
return { compatible: false, reason: 'no-candidate-branch', candidates: [] };
|
|
38
|
+
}
|
|
39
|
+
return { compatible: true, candidates };
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Deterministic, stable column order for a chosen axis (Q2). The "Senza valore"
|
|
43
|
+
* (value: null) column is always appended last. Values out of `options` are NOT
|
|
44
|
+
* given their own column (KB-U25) — the board folds them into "Senza valore".
|
|
45
|
+
*
|
|
46
|
+
* @param distinctTagValues unique tag values observed in data (tags axis without options).
|
|
47
|
+
*/
|
|
48
|
+
export function resolveKanbanColumns(branch, distinctTagValues = []) {
|
|
49
|
+
const cols = [];
|
|
50
|
+
if (branch.type === 'boolean') {
|
|
51
|
+
cols.push({ value: 'false', label: 'No' }, { value: 'true', label: 'Sì' }); // [false, true]
|
|
52
|
+
}
|
|
53
|
+
else if (branch.type === 'text' && branch.options?.length) {
|
|
54
|
+
for (const o of branch.options)
|
|
55
|
+
cols.push({ value: o, label: o }); // options order
|
|
56
|
+
}
|
|
57
|
+
else if (branch.type === 'tags') {
|
|
58
|
+
const ordered = branch.options?.length
|
|
59
|
+
? branch.options
|
|
60
|
+
: [...distinctTagValues].sort((a, b) => a.localeCompare(b)); // alphabetical
|
|
61
|
+
for (const o of ordered)
|
|
62
|
+
cols.push({ value: o, label: o });
|
|
63
|
+
}
|
|
64
|
+
const isRequired = Boolean(branch.requiredOnCreate || branch.requiredOnUpdate);
|
|
65
|
+
if (!isRequired) {
|
|
66
|
+
cols.push({ value: null, label: `Senza ${branch.label}` }); // always last if not required
|
|
67
|
+
}
|
|
68
|
+
return cols;
|
|
69
|
+
}
|
|
70
|
+
export function kanbanColumnFilter(branch, value) {
|
|
71
|
+
if (value === null) {
|
|
72
|
+
const type = branch.type === 'boolean' ? 'boolean' : branch.type === 'tags' ? 'tags' : 'text';
|
|
73
|
+
return { column: branch.alias, type, conditions: [{ op: 'is_empty', value: null }] };
|
|
74
|
+
}
|
|
75
|
+
if (branch.type === 'boolean') {
|
|
76
|
+
return { column: branch.alias, type: 'boolean', conditions: [{ op: 'eq', value: value === 'true' }] };
|
|
77
|
+
}
|
|
78
|
+
if (branch.type === 'tags') {
|
|
79
|
+
return { column: branch.alias, type: 'tags', conditions: [{ op: 'has_tag', value }] };
|
|
80
|
+
}
|
|
81
|
+
return { column: branch.alias, type: 'select', conditions: [{ op: 'eq', value }] };
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout-permissions.d.ts","sourceRoot":"","sources":["../src/layout-permissions.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,4BAA4B,EAAE,aAAa,CAAC,MAAM,CAAa,CAAA;AAE5E,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAGtE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copyright (c) 2024–2026 Flavio De Musso
|
|
3
|
+
// NOTE: change this list to extend write-access to other roles
|
|
4
|
+
// (e.g. add 'editor', or introduce a fine-grained 'layout:edit' permission).
|
|
5
|
+
// Single source of truth — used by both API guards and dashboard buttons.
|
|
6
|
+
export const ROLES_ALLOWED_TO_EDIT_LAYOUT = ['admin'];
|
|
7
|
+
export function canEditLayout(role) {
|
|
8
|
+
if (!role)
|
|
9
|
+
return false;
|
|
10
|
+
return ROLES_ALLOWED_TO_EDIT_LAYOUT.includes(role);
|
|
11
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Pixel dimensions of an image. */
|
|
2
|
+
export interface MediaDimensions {
|
|
3
|
+
readonly width: number;
|
|
4
|
+
readonly height: number;
|
|
5
|
+
}
|
|
6
|
+
/** Output MIME types the transform path may emit. AVIF is deliberately absent (v1). */
|
|
7
|
+
export type ImageOutputMime = 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp';
|
|
8
|
+
/**
|
|
9
|
+
* A fully resolved transformation. Every number here comes from a pre-registered preset or from
|
|
10
|
+
* MEDIA_QUALITY_VALUES — never from the request.
|
|
11
|
+
*/
|
|
12
|
+
export interface ImageTransformSpec {
|
|
13
|
+
readonly width: number;
|
|
14
|
+
/** Present for crop presets only; scale presets derive height from the source aspect ratio. */
|
|
15
|
+
readonly height?: number;
|
|
16
|
+
readonly fit: 'cover' | 'scale-down';
|
|
17
|
+
readonly outputMime: ImageOutputMime;
|
|
18
|
+
readonly quality: number;
|
|
19
|
+
}
|
|
20
|
+
export interface TransformedImage {
|
|
21
|
+
readonly body: ReadableStream<Uint8Array>;
|
|
22
|
+
readonly contentType: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Port for edge image transformation. The API injects a Cloudflare Images adapter when the
|
|
26
|
+
* `IMAGES` binding exists and `null` otherwise; handlers never see the binding itself.
|
|
27
|
+
*/
|
|
28
|
+
export interface IImageTransformer {
|
|
29
|
+
/** Reads the source's pixel dimensions. Rejects when the stream is not a raster image. */
|
|
30
|
+
probe(source: ReadableStream<Uint8Array>): Promise<MediaDimensions>;
|
|
31
|
+
/** Applies the spec and returns the encoded variant. */
|
|
32
|
+
transform(source: ReadableStream<Uint8Array>, spec: ImageTransformSpec): Promise<TransformedImage>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=image-transformer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-transformer.d.ts","sourceRoot":"","sources":["../../src/media/image-transformer.ts"],"names":[],"mappings":"AAGA,oCAAoC;AACpC,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED,uFAAuF;AACvF,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,WAAW,GAAG,WAAW,GAAG,YAAY,CAAA;AAErF;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,+FAA+F;IAC/F,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAAA;IACpC,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAA;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;IACzC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,0FAA0F;IAC1F,KAAK,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;IACnE,wDAAwD;IACxD,SAAS,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;CACnG"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { ImageOutputMime, ImageTransformSpec, MediaDimensions } from './image-transformer.js';
|
|
2
|
+
/** Default ceiling, in pixels, on either side of a derived variant. Covers native 32:9 ultrawide panels. */
|
|
3
|
+
export declare const DEFAULT_MEDIA_MAX_DIMENSION = 5120;
|
|
4
|
+
/** MEDIA_MAX_DIMENSION may lower the ceiling freely but raise it only this far. */
|
|
5
|
+
export declare const ABSOLUTE_MAX_MEDIA_DIMENSION = 8192;
|
|
6
|
+
export type MediaOutputFormat = 'original' | 'webp' | 'jpeg';
|
|
7
|
+
export type MediaQuality = 'low' | 'medium' | 'high';
|
|
8
|
+
export declare const MEDIA_OUTPUT_FORMATS: readonly MediaOutputFormat[];
|
|
9
|
+
export declare const MEDIA_QUALITIES: readonly MediaQuality[];
|
|
10
|
+
export declare const DEFAULT_MEDIA_FORMAT: MediaOutputFormat;
|
|
11
|
+
export declare const DEFAULT_MEDIA_QUALITY: MediaQuality;
|
|
12
|
+
/** Encoder quality per enum value. `medium` ≈ 82 per the brief. */
|
|
13
|
+
export declare const MEDIA_QUALITY_VALUES: Readonly<Record<MediaQuality, number>>;
|
|
14
|
+
export type MediaPreset = {
|
|
15
|
+
readonly kind: 'crop';
|
|
16
|
+
readonly width: number;
|
|
17
|
+
readonly height: number;
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: 'scale';
|
|
20
|
+
readonly width: number;
|
|
21
|
+
};
|
|
22
|
+
export type MediaPresetCatalog = ReadonlyMap<string, MediaPreset>;
|
|
23
|
+
export declare const DEFAULT_MEDIA_SCALE_WIDTHS: readonly [320, 480, 640, 768, 1024, 1280, 1536, 1920, 2560, 3840, 5120];
|
|
24
|
+
export declare const DEFAULT_MEDIA_PRESETS: Readonly<Record<string, MediaPreset>>;
|
|
25
|
+
/** Raster sources the transform path accepts. Everything else — SVG, PDF, video, AVIF, BMP, ICO — is refused. */
|
|
26
|
+
export declare const TRANSFORMABLE_MEDIA_MIME_TYPES: readonly ImageOutputMime[];
|
|
27
|
+
/** Parameters of the discarded free-form contract. Their presence is an error, never ignored. */
|
|
28
|
+
export declare const FORBIDDEN_MEDIA_TRANSFORM_PARAMS: readonly string[];
|
|
29
|
+
export type MediaTransformErrorCode = 'media_param_forbidden' | 'media_param_duplicated' | 'media_preset_required' | 'media_format_invalid' | 'media_quality_invalid' | 'media_preset_unknown' | 'media_not_transformable' | 'media_dimension_exceeded';
|
|
30
|
+
export interface MediaTransformRequest {
|
|
31
|
+
readonly preset: string;
|
|
32
|
+
readonly format: MediaOutputFormat;
|
|
33
|
+
readonly quality: MediaQuality;
|
|
34
|
+
}
|
|
35
|
+
export type MediaTransformQuery = {
|
|
36
|
+
readonly kind: 'none';
|
|
37
|
+
} | {
|
|
38
|
+
readonly kind: 'invalid';
|
|
39
|
+
readonly code: MediaTransformErrorCode;
|
|
40
|
+
} | {
|
|
41
|
+
readonly kind: 'transform';
|
|
42
|
+
readonly request: MediaTransformRequest;
|
|
43
|
+
};
|
|
44
|
+
/** Thrown by buildMediaPresetCatalog on any malformed MEDIA_PRESETS entry. Fail closed, never fall back. */
|
|
45
|
+
export declare class MediaPresetCatalogError extends Error {
|
|
46
|
+
readonly reason: string;
|
|
47
|
+
constructor(reason: string);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Classifies a media query string. Pure: does not consult the catalog (that is env-dependent and
|
|
51
|
+
* resolved by the caller), so an unknown-but-well-formed preset name returns `transform`.
|
|
52
|
+
*/
|
|
53
|
+
export declare function parseMediaTransformQuery(params: URLSearchParams): MediaTransformQuery;
|
|
54
|
+
/**
|
|
55
|
+
* Canonical query for a request: fixed order preset → format → quality, defaults omitted.
|
|
56
|
+
* `@beechcms/client` emits exactly this string; the server recomputes it and never trusts the client's.
|
|
57
|
+
*/
|
|
58
|
+
export declare function canonicalMediaTransformQuery(request: MediaTransformRequest): string;
|
|
59
|
+
/**
|
|
60
|
+
* Builds the active catalog: DEFAULT_MEDIA_PRESETS merged by name with `overrides`
|
|
61
|
+
* (the parsed MEDIA_PRESETS JSON). An override value of `null` removes a preset.
|
|
62
|
+
* Defaults larger than `maxDimension` are dropped (they could only ever 400); an operator-supplied
|
|
63
|
+
* preset larger than `maxDimension` is an error.
|
|
64
|
+
*
|
|
65
|
+
* @throws {MediaPresetCatalogError} on any malformed override.
|
|
66
|
+
*/
|
|
67
|
+
export declare function buildMediaPresetCatalog(overrides: unknown, maxDimension: number): MediaPresetCatalog;
|
|
68
|
+
export declare function isTransformableMime(mime: string | null | undefined): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Output dimensions of a scale preset (`fit=scale-down`: never upscales). Returns `null` when either
|
|
71
|
+
* side would exceed `maxDimension` — the pathological-aspect-ratio guard of brief §4. Never truncates.
|
|
72
|
+
*/
|
|
73
|
+
export declare function deriveScaleOutput(presetWidth: number, source: MediaDimensions, maxDimension: number): MediaDimensions | null;
|
|
74
|
+
/** Identity of a preset's *definition*, so redefining a name never reuses an old variant. */
|
|
75
|
+
export declare function mediaPresetSignature(preset: MediaPreset): string;
|
|
76
|
+
/** Precondition: `isTransformableMime(sourceMime)` is true. */
|
|
77
|
+
export declare function buildImageTransformSpec(preset: MediaPreset, request: MediaTransformRequest, sourceMime: string): ImageTransformSpec;
|
|
78
|
+
/**
|
|
79
|
+
* Strong ETag of a variant: source identity (key + size — keys are never overwritten) plus the
|
|
80
|
+
* canonical request plus the preset definition. Format: `"mv1-<32 hex>"`.
|
|
81
|
+
*/
|
|
82
|
+
export declare function computeMediaVariantEtag(source: {
|
|
83
|
+
readonly key: string;
|
|
84
|
+
readonly size: number;
|
|
85
|
+
}, request: MediaTransformRequest, preset: MediaPreset): Promise<string>;
|
|
86
|
+
/** RFC 9110 §13.1.2: `*` matches; otherwise weak comparison against a comma-separated list. */
|
|
87
|
+
export declare function ifNoneMatchMatches(header: string | null | undefined, etag: string | null | undefined): boolean;
|
|
88
|
+
//# sourceMappingURL=media-transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-transform.d.ts","sourceRoot":"","sources":["../../src/media/media-transform.ts"],"names":[],"mappings":"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"}
|