@plyaz/config 1.7.21 → 1.8.0

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.
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Storage Categories & Bucket Organization
3
+ *
4
+ * Provider-agnostic storage organization by PURPOSE and CONTENT TYPE.
5
+ * Adapters internally translate these purposes to their naming conventions.
6
+ *
7
+ * Universal approach:
8
+ * - Define buckets by PURPOSE (compliance, media-images, backups, etc.)
9
+ * - Paths are universal across all providers
10
+ * - Adapters handle their own naming rules internally
11
+ *
12
+ * @module @plyaz/config/storage/categories
13
+ */
14
+ import type { StorageCategory } from '@plyaz/types';
15
+ import { BUCKET_PURPOSE } from '@plyaz/types';
16
+ /**
17
+ * Constants for storage retention policies (in days)
18
+ */
19
+ export declare const STORAGE_RETENTION_DAYS: {
20
+ readonly DAYS_PER_YEAR: 365;
21
+ readonly COMPLIANCE_YEARS: 7;
22
+ readonly TEMPORARY_DAYS: 7;
23
+ readonly BACKUP_DAYS: 90;
24
+ };
25
+ /**
26
+ * Constants for TTL calculations
27
+ */
28
+ export declare const STORAGE_TTL_CONSTANTS: {
29
+ readonly SECONDS_PER_DAY: 86400;
30
+ };
31
+ /**
32
+ * Storage category definitions
33
+ * Provider-agnostic organization by purpose
34
+ */
35
+ export declare const STORAGE_CATEGORIES: Record<BUCKET_PURPOSE, StorageCategory>;
36
+ /**
37
+ * Example adapter bucket name translation:
38
+ *
39
+ * Identifier: "compliance:enterprise:acme-corp:prod"
40
+ *
41
+ * CloudflareR2Adapter translates to:
42
+ * → plyaz-prod-weur-enterprise-acme-corp-records-vault
43
+ *
44
+ * SupabaseStorageAdapter translates to:
45
+ * → compliance-acme-corp (projects handle env)
46
+ *
47
+ * S3Adapter translates to:
48
+ * → plyaz-compliance-enterprise-acme-corp-prod-us-east-1
49
+ *
50
+ * All use the SAME paths internally!
51
+ */
52
+ //# sourceMappingURL=categories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"categories.d.ts","sourceRoot":"","sources":["../../src/storage/categories.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,cAAc,EAEf,MAAM,cAAc,CAAC;AAEtB;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;CAKzB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,qBAAqB;;CAExB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,cAAc,EAAE,eAAe,CA2EtE,CAAC;AAEF;;;;;;;;;;;;;;;GAeG"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Storage Chunked Upload Configuration
3
+ *
4
+ * Configuration constants for multipart/chunked file uploads.
5
+ * Used by adapters that support chunked uploads (R2, Supabase, S3).
6
+ *
7
+ * @module @plyaz/config/storage/chunked-upload
8
+ */
9
+ /**
10
+ * Chunk size configuration for multipart uploads
11
+ * Based on S3/R2 limits: 5MB min, 5GB max per part, 10,000 parts max
12
+ */
13
+ export declare const STORAGE_CHUNK_SIZE: {
14
+ readonly MIN: number;
15
+ readonly MAX: number;
16
+ readonly DEFAULT_SMALL: number;
17
+ readonly DEFAULT_MEDIUM: number;
18
+ readonly DEFAULT_LARGE: number;
19
+ readonly DEFAULT_HUGE: number;
20
+ };
21
+ /**
22
+ * File size thresholds for determining chunk strategy
23
+ */
24
+ export declare const STORAGE_FILE_SIZE_THRESHOLDS: {
25
+ readonly SMALL: number;
26
+ readonly MEDIUM: 1073741824;
27
+ readonly LARGE: number;
28
+ readonly CHUNKED_UPLOAD: number;
29
+ };
30
+ /**
31
+ * Check if file should use chunked upload based on size
32
+ *
33
+ * @param file - File buffer or stream
34
+ * @param threshold - Size threshold in bytes (defaults to 100MB)
35
+ * @returns True if file should use chunked upload
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * const shouldChunk = shouldUseStorageChunkedUpload(fileBuffer);
40
+ * const shouldChunkCustom = shouldUseStorageChunkedUpload(fileBuffer, 50 * 1024 * 1024);
41
+ * ```
42
+ */
43
+ export declare function shouldUseStorageChunkedUpload(file: globalThis.Buffer | globalThis.NodeJS.ReadableStream | null | undefined, threshold?: number): boolean;
44
+ /**
45
+ * Get optimal chunk size based on file size
46
+ * Follows S3/R2 limits: 5MB min, 5GB max per part, 10,000 parts max
47
+ *
48
+ * @param totalSize - Total file size in bytes
49
+ * @returns Optimal chunk size in bytes
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * const chunkSize = getStorageOptimalChunkSize(50 * 1024 * 1024); // 50MB file
54
+ * console.log(chunkSize); // 5242880 (5MB)
55
+ * ```
56
+ */
57
+ export declare function getStorageOptimalChunkSize(totalSize: number): number;
58
+ //# sourceMappingURL=chunked-upload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunked-upload.d.ts","sourceRoot":"","sources":["../../src/storage/chunked-upload.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgBH;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;CAOrB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,4BAA4B;;;;;CAK/B,CAAC;AAEX;;;;;;;;;;;;GAYG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,UAAU,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,cAAc,GAAG,IAAI,GAAG,SAAS,EAC7E,SAAS,GAAE,MAAoD,GAC9D,OAAO,CAKT;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAcpE"}