@beechcms/core 0.4.0-preview.12 → 0.4.0-preview.13

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/index.d.ts CHANGED
@@ -17,5 +17,7 @@ export * from './richtext-render.js';
17
17
  export * from './slug-utils.js';
18
18
  export * from './content.repository.js';
19
19
  export * from './idempotency.repository.js';
20
+ export * from './media.repository.js';
21
+ export * from './storage.js';
20
22
  export * from './policies.js';
21
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,yBAAyB,CAAA;AACvC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,yBAAyB,CAAA;AACvC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA"}
package/dist/index.js CHANGED
@@ -17,4 +17,6 @@ export * from './richtext-render.js';
17
17
  export * from './slug-utils.js';
18
18
  export * from './content.repository.js';
19
19
  export * from './idempotency.repository.js';
20
+ export * from './media.repository.js';
21
+ export * from './storage.js';
20
22
  export * from './policies.js';
@@ -0,0 +1,61 @@
1
+ /**
2
+ * MediaRepository - Interface for tracking media assets in the database.
3
+ */
4
+ export interface MediaObject {
5
+ key: string;
6
+ filename: string;
7
+ mime_type: string;
8
+ size_bytes: number;
9
+ uploaded_by: string;
10
+ created_at: number;
11
+ }
12
+ export interface MediaRepository {
13
+ /**
14
+ * Tracks a new file upload in the database.
15
+ */
16
+ trackUpload(media: Omit<MediaObject, 'created_at'>): Promise<void>;
17
+ /**
18
+ * Retrieves tracking info for a file by its key.
19
+ */
20
+ getByKey(key: string): Promise<MediaObject | null>;
21
+ /**
22
+ * Removes tracking info for a file.
23
+ */
24
+ untrack(key: string): Promise<void>;
25
+ /**
26
+ * Lists all tracked media with pagination.
27
+ */
28
+ list(options: {
29
+ limit: number;
30
+ offset: number;
31
+ }): Promise<{
32
+ items: MediaObject[];
33
+ total: number;
34
+ }>;
35
+ /**
36
+ * Gets the total number of tracked media objects.
37
+ */
38
+ count(): Promise<number>;
39
+ }
40
+ /**
41
+ * SystemStatsRepository - Interface for managing global system metrics.
42
+ */
43
+ export interface SystemStatsRepository {
44
+ /**
45
+ * Increments the total storage counter.
46
+ */
47
+ incrementStorage(bytes: number): Promise<void>;
48
+ /**
49
+ * Decrements the total storage counter.
50
+ */
51
+ decrementStorage(bytes: number): Promise<void>;
52
+ /**
53
+ * Sets a specific value for a storage stat (e.g. after a full sync).
54
+ */
55
+ setStorage(bytes: number): Promise<void>;
56
+ /**
57
+ * Gets the current total storage usage in bytes.
58
+ */
59
+ getStorageUsage(): Promise<number>;
60
+ }
61
+ //# sourceMappingURL=media.repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.repository.d.ts","sourceRoot":"","sources":["../src/media.repository.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IAC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face abstracts the underlying storage provider (R2, S3, or Local)
5
+ * allowing the application to scale without being tied to a specific vendor.
6
+ */
7
+ export interface PutBucketOptions {
8
+ contentType?: string;
9
+ metadata?: Record<string, string>;
10
+ }
11
+ export interface GetBucketResult {
12
+ body: ReadableStream | ArrayBuffer;
13
+ contentType?: string;
14
+ size: number;
15
+ metadata?: Record<string, string>;
16
+ }
17
+ export interface BeechBucket {
18
+ /**
19
+ * Uploads an object to the bucket.
20
+ * @param key The unique key (path) for the object.
21
+ * @param body The data to store.
22
+ * @param options Optional metadata like content type.
23
+ */
24
+ put(key: string, body: ArrayBuffer | Uint8Array | ReadableStream, options?: PutBucketOptions): Promise<void>;
25
+ /**
26
+ * Retrieves an object from the bucket.
27
+ * @param key The unique key for the object.
28
+ * @returns The object data and metadata, or null if not found.
29
+ */
30
+ get(key: string): Promise<GetBucketResult | null>;
31
+ /**
32
+ * Deletes an object from the bucket.
33
+ * @param key The unique key for the object.
34
+ */
35
+ delete(key: string): Promise<void>;
36
+ /**
37
+ * Retrieves metadata for an object without downloading its content.
38
+ * @param key The unique key for the object.
39
+ */
40
+ head(key: string): Promise<{
41
+ size: number;
42
+ contentType?: string;
43
+ metadata?: Record<string, string>;
44
+ } | null>;
45
+ /**
46
+ * Returns a publicly accessible URL for the given key.
47
+ * The implementation decides if this is a direct vendor URL (CDN)
48
+ * or a proxied URL through the Beech API.
49
+ * @param key The unique key for the object.
50
+ */
51
+ getUrl(key: string): string;
52
+ /**
53
+ * Calculates the total size of all objects in the bucket.
54
+ * Warning: This may be an expensive operation on some providers.
55
+ */
56
+ getTotalSize(): Promise<number>;
57
+ /**
58
+ * Lists objects in the bucket.
59
+ */
60
+ list(options?: {
61
+ prefix?: string;
62
+ limit?: number;
63
+ cursor?: string;
64
+ }): Promise<{
65
+ objects: Array<{
66
+ key: string;
67
+ size: number;
68
+ }>;
69
+ cursor?: string;
70
+ }>;
71
+ }
72
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+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AAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,KAAK,CAAC;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnJ"}
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beechcms/core",
3
- "version": "0.4.0-preview.12",
3
+ "version": "0.4.0-preview.13",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",