nestjs-r2-storage 1.4.3 → 1.5.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.
package/README.md CHANGED
@@ -406,6 +406,17 @@ R2StorageModule.forRootAsync({
406
406
 
407
407
  ## Changelog
408
408
 
409
+ ### v1.5.0 (2026-04-25)
410
+
411
+ - **Refactored photo update logic** - Diff-based (state reconciliation) instead of request-driven
412
+ - **No unnecessary uploads** - Files are only uploaded when the value actually changes
413
+ - **No accidental deletions** - Files are only deleted when removed from the payload
414
+ - **Index-based array handling** - Array fields use path-based comparison (`gallery[0].photo`) instead of filename matching
415
+ - **Reusable `extractExistingFileMap()`** - Public method for extracting `fieldPath → fileKey` maps
416
+ - **Optimized traversal** - Single-pass map extraction, O(1) lookups via Map
417
+ - **Size is optional** - Size field does not affect diff logic, only used for storage tracking
418
+ - **Deterministic behavior** - Backend-driven, no assumptions about frontend behavior
419
+
409
420
  ### v1.2.6 (2025-04-20)
410
421
 
411
422
  - Refactored getNestedValue: access key first, then handle array segments
@@ -1,32 +1,32 @@
1
- import { OnModuleInit, OnModuleDestroy, BadRequestException } from "@nestjs/common";
2
- import { StorageOptions } from "./interfaces/storage-options.interface";
3
- import { DownloadUrlResult, FileInfo, UploadUrlResult } from "./interfaces/cloudflare-service.interface";
4
- export declare class AccessModeError extends BadRequestException {
5
- constructor(message: string);
6
- }
7
- export declare class CloudflareService implements OnModuleInit, OnModuleDestroy {
8
- private readonly storageOptions;
9
- private s3Client;
10
- private options;
11
- private readonly defaultExpiry;
12
- private readonly defaultAccessMode;
13
- constructor(storageOptions: StorageOptions);
14
- private get accessMode();
15
- private isPublicAccessAllowed;
16
- onModuleInit(): void;
17
- onModuleDestroy(): void;
18
- private initializeClient;
19
- getOptions(): StorageOptions;
20
- private sanitizeFilename;
21
- private detectMimeType;
22
- getUploadUrl(fileKey: string, fileSize: number, customFilename?: string, contentType?: string): Promise<UploadUrlResult>;
23
- getDownloadUrl(fileKey: string): Promise<DownloadUrlResult>;
24
- deleteFile(fileKey: string): Promise<boolean>;
25
- deleteFiles(fileKeys: string[]): Promise<{
26
- success: string[];
27
- failed: string[];
28
- }>;
29
- getFileInfo(fileKey: string): Promise<FileInfo | null>;
30
- fileExists(fileKey: string): Promise<boolean>;
31
- generateFileKey(prefix: string, filename: string): string;
32
- }
1
+ import { OnModuleInit, OnModuleDestroy, BadRequestException } from "@nestjs/common";
2
+ import { StorageOptions } from "./interfaces/storage-options.interface";
3
+ import { DownloadUrlResult, FileInfo, UploadUrlResult } from "./interfaces/cloudflare-service.interface";
4
+ export declare class AccessModeError extends BadRequestException {
5
+ constructor(message: string);
6
+ }
7
+ export declare class CloudflareService implements OnModuleInit, OnModuleDestroy {
8
+ private readonly storageOptions;
9
+ private s3Client;
10
+ private options;
11
+ private readonly defaultExpiry;
12
+ private readonly defaultAccessMode;
13
+ constructor(storageOptions: StorageOptions);
14
+ private get accessMode();
15
+ private isPublicAccessAllowed;
16
+ onModuleInit(): void;
17
+ onModuleDestroy(): void;
18
+ private initializeClient;
19
+ getOptions(): StorageOptions;
20
+ private sanitizeFilename;
21
+ private detectMimeType;
22
+ getUploadUrl(fileKey: string, fileSize: number, customFilename?: string, contentType?: string): Promise<UploadUrlResult>;
23
+ getDownloadUrl(fileKey: string): Promise<DownloadUrlResult>;
24
+ deleteFile(fileKey: string): Promise<boolean>;
25
+ deleteFiles(fileKeys: string[]): Promise<{
26
+ success: string[];
27
+ failed: string[];
28
+ }>;
29
+ getFileInfo(fileKey: string): Promise<FileInfo | null>;
30
+ fileExists(fileKey: string): Promise<boolean>;
31
+ generateFileKey(prefix: string, filename: string): string;
32
+ }
@@ -1,216 +1,218 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
- return c > 3 && r && Object.defineProperty(target, key, r), r;
23
- };
24
- var __importStar = (this && this.__importStar) || (function () {
25
- var ownKeys = function(o) {
26
- ownKeys = Object.getOwnPropertyNames || function (o) {
27
- var ar = [];
28
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
- return ar;
30
- };
31
- return ownKeys(o);
32
- };
33
- return function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- })();
41
- var __metadata = (this && this.__metadata) || function (k, v) {
42
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
- };
44
- var __param = (this && this.__param) || function (paramIndex, decorator) {
45
- return function (target, key) { decorator(target, key, paramIndex); }
46
- };
47
- Object.defineProperty(exports, "__esModule", { value: true });
48
- exports.CloudflareService = exports.AccessModeError = void 0;
49
- const common_1 = require("@nestjs/common");
50
- const client_s3_1 = require("@aws-sdk/client-s3");
51
- const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
52
- const path = __importStar(require("path"));
53
- const mime = __importStar(require("mime-types"));
54
- const constants_1 = require("./constants");
55
- const validate_options_utils_1 = require("./utils/validate-options.utils");
56
- class AccessModeError extends common_1.BadRequestException {
57
- constructor(message) {
58
- super(message);
59
- this.name = "AccessModeError";
60
- }
61
- }
62
- exports.AccessModeError = AccessModeError;
63
- let CloudflareService = class CloudflareService {
64
- constructor(storageOptions) {
65
- this.storageOptions = storageOptions;
66
- this.defaultExpiry = 3600;
67
- this.defaultAccessMode = "hybrid";
68
- this.options = this.storageOptions;
69
- }
70
- get accessMode() {
71
- return this.options.accessMode || this.defaultAccessMode;
72
- }
73
- isPublicAccessAllowed() {
74
- return this.accessMode === "public-read" || this.accessMode === "hybrid";
75
- }
76
- onModuleInit() {
77
- (0, validate_options_utils_1.validateOptions)(this.options);
78
- this.initializeClient();
79
- }
80
- onModuleDestroy() {
81
- if (this.s3Client) {
82
- this.s3Client.destroy();
83
- }
84
- }
85
- initializeClient() {
86
- this.s3Client = new client_s3_1.S3Client({
87
- endpoint: this.options.endpoint,
88
- region: this.options.region || "auto",
89
- credentials: {
90
- accessKeyId: this.options.accessKeyId,
91
- secretAccessKey: this.options.secretAccessKey,
92
- },
93
- forcePathStyle: true,
94
- requestChecksumCalculation: "WHEN_REQUIRED",
95
- });
96
- }
97
- getOptions() {
98
- return this.options;
99
- }
100
- sanitizeFilename(filename) {
101
- const sanitized = filename.replace(/[^a-zA-Z0-9._-]/g, "_");
102
- const unique = `${Date.now()}_${Math.random().toString(36).slice(2)}`;
103
- const ext = path.extname(sanitized);
104
- const basename = path.basename(sanitized, ext);
105
- return `${basename}_${unique}${ext}`;
106
- }
107
- detectMimeType(filename, fallbackContentType = "application/octet-stream") {
108
- const mimeType = mime.lookup(filename);
109
- return mimeType || fallbackContentType;
110
- }
111
- async getUploadUrl(fileKey, fileSize, customFilename, contentType) {
112
- const filename = customFilename || path.basename(fileKey);
113
- const sanitizedFilename = this.sanitizeFilename(filename);
114
- const finalFileKey = fileKey.includes("/")
115
- ? `${path.dirname(fileKey)}/${sanitizedFilename}`
116
- : sanitizedFilename;
117
- const mimeType = contentType || this.detectMimeType(sanitizedFilename);
118
- const command = new client_s3_1.PutObjectCommand({
119
- Bucket: this.options.bucketName,
120
- Key: finalFileKey,
121
- ContentType: mimeType,
122
- });
123
- const expiry = this.options.signedUrlExpiry || this.defaultExpiry;
124
- const uploadUrl = await (0, s3_request_presigner_1.getSignedUrl)(this.s3Client, command, {
125
- expiresIn: expiry,
126
- signableHeaders: new Set(["host", "content-type"]),
127
- });
128
- let publicUrl = null;
129
- if (this.options.publicUrlBase && this.isPublicAccessAllowed()) {
130
- publicUrl = `${this.options.publicUrlBase}/${finalFileKey}`;
131
- }
132
- return {
133
- uploadUrl,
134
- fileKey: finalFileKey,
135
- publicUrl,
136
- mimeType,
137
- sizeField: fileSize,
138
- };
139
- }
140
- async getDownloadUrl(fileKey) {
141
- const command = new client_s3_1.GetObjectCommand({
142
- Bucket: this.options.bucketName,
143
- Key: fileKey,
144
- });
145
- const expiry = this.options.signedUrlExpiry || this.defaultExpiry;
146
- const downloadUrl = await (0, s3_request_presigner_1.getSignedUrl)(this.s3Client, command, {
147
- expiresIn: expiry,
148
- });
149
- let publicUrl = null;
150
- if (this.options.publicUrlBase && this.isPublicAccessAllowed()) {
151
- publicUrl = `${this.options.publicUrlBase}/${fileKey}`;
152
- }
153
- return {
154
- downloadUrl,
155
- publicUrl,
156
- };
157
- }
158
- async deleteFile(fileKey) {
159
- try {
160
- const command = new client_s3_1.DeleteObjectCommand({
161
- Bucket: this.options.bucketName,
162
- Key: fileKey,
163
- });
164
- await this.s3Client.send(command);
165
- return true;
166
- }
167
- catch (error) {
168
- console.error(`Failed to delete file ${fileKey}:`, error);
169
- return false;
170
- }
171
- }
172
- async deleteFiles(fileKeys) {
173
- const results = await Promise.all(fileKeys.map(async (fileKey) => {
174
- const success = await this.deleteFile(fileKey);
175
- return { fileKey, success };
176
- }));
177
- return {
178
- success: results.filter((r) => r.success).map((r) => r.fileKey),
179
- failed: results.filter((r) => !r.success).map((r) => r.fileKey),
180
- };
181
- }
182
- async getFileInfo(fileKey) {
183
- try {
184
- const command = new client_s3_1.HeadObjectCommand({
185
- Bucket: this.options.bucketName,
186
- Key: fileKey,
187
- });
188
- const response = await this.s3Client.send(command);
189
- return {
190
- size: response.ContentLength || 0,
191
- lastModified: response.LastModified,
192
- contentType: response.ContentType,
193
- };
194
- }
195
- catch (error) {
196
- if (error?.$metadata?.httpStatusCode === 404) {
197
- return null;
198
- }
199
- throw error;
200
- }
201
- }
202
- async fileExists(fileKey) {
203
- const fileInfo = await this.getFileInfo(fileKey);
204
- return fileInfo !== null;
205
- }
206
- generateFileKey(prefix, filename) {
207
- return `${prefix}/${this.sanitizeFilename(filename)}`;
208
- }
209
- };
210
- exports.CloudflareService = CloudflareService;
211
- exports.CloudflareService = CloudflareService = __decorate([
212
- (0, common_1.Injectable)(),
213
- __param(0, (0, common_1.Inject)(constants_1.STORAGE_OPTIONS)),
214
- __metadata("design:paramtypes", [Object])
215
- ], CloudflareService);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __metadata = (this && this.__metadata) || function (k, v) {
42
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
+ };
44
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
45
+ return function (target, key) { decorator(target, key, paramIndex); }
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.CloudflareService = exports.AccessModeError = void 0;
49
+ const common_1 = require("@nestjs/common");
50
+ const client_s3_1 = require("@aws-sdk/client-s3");
51
+ const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
52
+ const path = __importStar(require("path"));
53
+ const mime = __importStar(require("mime-types"));
54
+ const constants_1 = require("./constants");
55
+ const validate_options_utils_1 = require("./utils/validate-options.utils");
56
+ class AccessModeError extends common_1.BadRequestException {
57
+ constructor(message) {
58
+ super(message);
59
+ this.name = "AccessModeError";
60
+ }
61
+ }
62
+ exports.AccessModeError = AccessModeError;
63
+ let CloudflareService = class CloudflareService {
64
+ constructor(storageOptions) {
65
+ this.storageOptions = storageOptions;
66
+ this.defaultExpiry = 3600;
67
+ this.defaultAccessMode = "hybrid";
68
+ this.options = this.storageOptions;
69
+ }
70
+ get accessMode() {
71
+ return this.options.accessMode || this.defaultAccessMode;
72
+ }
73
+ isPublicAccessAllowed() {
74
+ return this.accessMode === "public-read" || this.accessMode === "hybrid";
75
+ }
76
+ onModuleInit() {
77
+ (0, validate_options_utils_1.validateOptions)(this.options);
78
+ this.initializeClient();
79
+ }
80
+ onModuleDestroy() {
81
+ if (this.s3Client) {
82
+ this.s3Client.destroy();
83
+ }
84
+ }
85
+ initializeClient() {
86
+ this.s3Client = new client_s3_1.S3Client({
87
+ endpoint: this.options.endpoint,
88
+ region: this.options.region || "auto",
89
+ credentials: {
90
+ accessKeyId: this.options.accessKeyId,
91
+ secretAccessKey: this.options.secretAccessKey,
92
+ },
93
+ forcePathStyle: true,
94
+ requestChecksumCalculation: "WHEN_REQUIRED",
95
+ });
96
+ }
97
+ getOptions() {
98
+ return this.options;
99
+ }
100
+ sanitizeFilename(filename, unique = true) {
101
+ const sanitized = filename.replace(/[^a-zA-Z0-9._-]/g, "_");
102
+ if (!unique)
103
+ return sanitized;
104
+ const uniqueSuffix = `${Date.now()}`;
105
+ const ext = path.extname(sanitized);
106
+ const basename = path.basename(sanitized, ext);
107
+ return `${basename}_${uniqueSuffix}${ext}`;
108
+ }
109
+ detectMimeType(filename, fallbackContentType = "application/octet-stream") {
110
+ const mimeType = mime.lookup(filename);
111
+ return mimeType || fallbackContentType;
112
+ }
113
+ async getUploadUrl(fileKey, fileSize, customFilename, contentType) {
114
+ const filename = customFilename || path.basename(fileKey);
115
+ const sanitizedFilename = this.sanitizeFilename(filename);
116
+ const finalFileKey = fileKey.includes("/")
117
+ ? `${path.dirname(fileKey)}/${sanitizedFilename}`
118
+ : sanitizedFilename;
119
+ const mimeType = contentType || this.detectMimeType(sanitizedFilename);
120
+ const command = new client_s3_1.PutObjectCommand({
121
+ Bucket: this.options.bucketName,
122
+ Key: finalFileKey,
123
+ ContentType: mimeType,
124
+ });
125
+ const expiry = this.options.signedUrlExpiry || this.defaultExpiry;
126
+ const uploadUrl = await (0, s3_request_presigner_1.getSignedUrl)(this.s3Client, command, {
127
+ expiresIn: expiry,
128
+ signableHeaders: new Set(["host", "content-type"]),
129
+ });
130
+ let publicUrl = null;
131
+ if (this.options.publicUrlBase && this.isPublicAccessAllowed()) {
132
+ publicUrl = `${this.options.publicUrlBase}/${finalFileKey}`;
133
+ }
134
+ return {
135
+ uploadUrl,
136
+ fileKey: finalFileKey,
137
+ publicUrl,
138
+ mimeType,
139
+ sizeField: fileSize,
140
+ };
141
+ }
142
+ async getDownloadUrl(fileKey) {
143
+ const command = new client_s3_1.GetObjectCommand({
144
+ Bucket: this.options.bucketName,
145
+ Key: fileKey,
146
+ });
147
+ const expiry = this.options.signedUrlExpiry || this.defaultExpiry;
148
+ const downloadUrl = await (0, s3_request_presigner_1.getSignedUrl)(this.s3Client, command, {
149
+ expiresIn: expiry,
150
+ });
151
+ let publicUrl = null;
152
+ if (this.options.publicUrlBase && this.isPublicAccessAllowed()) {
153
+ publicUrl = `${this.options.publicUrlBase}/${fileKey}`;
154
+ }
155
+ return {
156
+ downloadUrl,
157
+ publicUrl,
158
+ };
159
+ }
160
+ async deleteFile(fileKey) {
161
+ try {
162
+ const command = new client_s3_1.DeleteObjectCommand({
163
+ Bucket: this.options.bucketName,
164
+ Key: fileKey,
165
+ });
166
+ await this.s3Client.send(command);
167
+ return true;
168
+ }
169
+ catch (error) {
170
+ console.error(`Failed to delete file ${fileKey}:`, error);
171
+ return false;
172
+ }
173
+ }
174
+ async deleteFiles(fileKeys) {
175
+ const results = await Promise.all(fileKeys.map(async (fileKey) => {
176
+ const success = await this.deleteFile(fileKey);
177
+ return { fileKey, success };
178
+ }));
179
+ return {
180
+ success: results.filter((r) => r.success).map((r) => r.fileKey),
181
+ failed: results.filter((r) => !r.success).map((r) => r.fileKey),
182
+ };
183
+ }
184
+ async getFileInfo(fileKey) {
185
+ try {
186
+ const command = new client_s3_1.HeadObjectCommand({
187
+ Bucket: this.options.bucketName,
188
+ Key: fileKey,
189
+ });
190
+ const response = await this.s3Client.send(command);
191
+ return {
192
+ size: response.ContentLength || 0,
193
+ lastModified: response.LastModified,
194
+ contentType: response.ContentType,
195
+ };
196
+ }
197
+ catch (error) {
198
+ if (error?.$metadata?.httpStatusCode === 404) {
199
+ return null;
200
+ }
201
+ throw error;
202
+ }
203
+ }
204
+ async fileExists(fileKey) {
205
+ const fileInfo = await this.getFileInfo(fileKey);
206
+ return fileInfo !== null;
207
+ }
208
+ generateFileKey(prefix, filename) {
209
+ return `${prefix}/${this.sanitizeFilename(filename)}`;
210
+ }
211
+ };
212
+ exports.CloudflareService = CloudflareService;
213
+ exports.CloudflareService = CloudflareService = __decorate([
214
+ (0, common_1.Injectable)(),
215
+ __param(0, (0, common_1.Inject)(constants_1.STORAGE_OPTIONS)),
216
+ __metadata("design:paramtypes", [Object])
217
+ ], CloudflareService);
216
218
  //# sourceMappingURL=cloudflare.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cloudflare.service.js","sourceRoot":"","sources":["../../src/r2-storage/cloudflare.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAMwB;AACxB,kDAM4B;AAC5B,wEAA6D;AAC7D,2CAA6B;AAC7B,iDAAmC;AAKnC,2CAA8C;AAC9C,2EAAiE;AAOjE,MAAa,eAAgB,SAAQ,4BAAmB;IACtD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AALD,0CAKC;AAGM,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAM5B,YAC2B,cAA+C;QAA9B,mBAAc,GAAd,cAAc,CAAgB;QAJzD,kBAAa,GAAG,IAAI,CAAC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AC;gBACpC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU;gBAC/B,GAAG,EAAE,OAAO;aACb,CAAC,CAAC;YAEH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACnD,OAAO;gBACL,IAAI,EAAE,QAAQ,CAAC,aAAa,IAAI,CAAC;gBACjC,YAAY,EAAE,QAAQ,CAAC,YAAY;gBACnC,WAAW,EAAE,QAAQ,CAAC,WAAW;aAClC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,KAAK,EAAE,SAAS,EAAE,cAAc,KAAK,GAAG,EAAE,CAAC;gBAC7C,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAe;QAC9B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACjD,OAAO,QAAQ,KAAK,IAAI,CAAC;IAC3B,CAAC;IAED,eAAe,CAAC,MAAc,EAAE,QAAgB;QAC9C,OAAO,GAAG,MAAM,IAAI,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC;IACxD,CAAC;CACF,CAAA;AAtNY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;IAQR,WAAA,IAAA,eAAM,EAAC,2BAAe,CAAC,CAAA;;GAPf,iBAAiB,CAsN7B"}
@@ -1,23 +1,23 @@
1
- export type AccessMode = "private" | "public-read" | "hybrid";
2
- export interface StorageOptions {
3
- endpoint: string;
4
- accessKeyId: string;
5
- secretAccessKey: string;
6
- bucketName: string;
7
- region?: string;
8
- publicUrlBase?: string;
9
- signedUrlExpiry?: number;
10
- accessMode?: AccessMode;
11
- }
12
- export interface FileFieldConfig {
13
- field: string;
14
- sizeField?: string;
15
- }
16
- export interface PhotoFieldConfig {
17
- field: string;
18
- urlField?: string;
19
- sizeField?: string;
20
- }
21
- export interface StorageModuleOptions {
22
- isGlobal?: boolean;
23
- }
1
+ export type AccessMode = "private" | "public-read" | "hybrid";
2
+ export interface StorageOptions {
3
+ endpoint: string;
4
+ accessKeyId: string;
5
+ secretAccessKey: string;
6
+ bucketName: string;
7
+ region?: string;
8
+ publicUrlBase?: string;
9
+ signedUrlExpiry?: number;
10
+ accessMode?: AccessMode;
11
+ }
12
+ export interface FileFieldConfig {
13
+ field: string;
14
+ sizeField?: string;
15
+ }
16
+ export interface PhotoFieldConfig {
17
+ field: string;
18
+ urlField?: string;
19
+ sizeField?: string;
20
+ }
21
+ export interface StorageModuleOptions {
22
+ isGlobal?: boolean;
23
+ }
@@ -1,19 +1,23 @@
1
- import { CloudflareService } from "./cloudflare.service";
2
- import { CreatePhotosResult, DeletePhotosResult, PhotoField, UpdatePhotosResult } from "./interfaces/photo-manager.interface";
3
- export declare class PhotoManagerService {
4
- private readonly cloudflareService;
5
- constructor(cloudflareService: CloudflareService);
6
- appendPhotoUrls<T extends Record<string, any>>(payload: T, photoFields: PhotoField[]): Promise<T>;
7
- appendPhotoUrls<T extends Record<string, any>>(payload: T[], photoFields: PhotoField[]): Promise<T[]>;
8
- private handleSingleFieldUrl;
9
- private handleArrayFieldUrls;
10
- createObjectWithPhotos<T extends Record<string, any>>(payload: T, photoFields: PhotoField[], filePrefix?: string): Promise<CreatePhotosResult<T>>;
11
- updateObjectWithPhotos<T extends Record<string, any>>(payload: T, existingObject: T, photoFields: PhotoField[], filePrefix?: string): Promise<UpdatePhotosResult<T>>;
12
- deletePhotosFromObject<T extends Record<string, any>>(object: T, photoFields: PhotoField[]): Promise<DeletePhotosResult>;
13
- private extractPhotoUploadRequests;
14
- private extractArrayFieldUploadRequests;
15
- private extractExistingFiles;
16
- private determineFilesToDelete;
17
- private normalizeFilename;
18
- private updateArrayFieldWithNewFileKey;
19
- }
1
+ import { CloudflareService } from "./cloudflare.service";
2
+ import { CreatePhotosResult, DeletePhotosResult, PhotoField, UpdatePhotosResult } from "./interfaces/photo-manager.interface";
3
+ type FileMap = Map<string, string>;
4
+ export declare class PhotoManagerService {
5
+ private readonly cloudflareService;
6
+ constructor(cloudflareService: CloudflareService);
7
+ appendPhotoUrls<T extends Record<string, any>>(payload: T, photoFields: PhotoField[]): Promise<T>;
8
+ appendPhotoUrls<T extends Record<string, any>>(payload: T[], photoFields: PhotoField[]): Promise<T[]>;
9
+ private handleSingleFieldUrl;
10
+ private handleArrayFieldUrls;
11
+ createObjectWithPhotos<T extends Record<string, any>>(payload: T, photoFields: PhotoField[], filePrefix?: string): Promise<CreatePhotosResult<T>>;
12
+ updateObjectWithPhotos<T extends Record<string, any>>(payload: T, existingObject: T, photoFields: PhotoField[], filePrefix?: string): Promise<UpdatePhotosResult<T>>;
13
+ deletePhotosFromObject<T extends Record<string, any>>(object: T, photoFields: PhotoField[]): Promise<DeletePhotosResult>;
14
+ extractExistingFileMap<T extends Record<string, any>>(object: T, photoFields: PhotoField[]): FileMap;
15
+ private extractPayloadFileMap;
16
+ private getArrayFieldPaths;
17
+ private calculatePhotoDiffs;
18
+ private getSizeForField;
19
+ private updateFieldWithFileKey;
20
+ private extractPhotoUploadRequests;
21
+ private extractExistingFiles;
22
+ }
23
+ export {};