graphile-presigned-url-plugin 0.15.1 → 0.16.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.
Files changed (3) hide show
  1. package/esm/plugin.js +10 -1
  2. package/package.json +2 -2
  3. package/plugin.js +10 -1
package/esm/plugin.js CHANGED
@@ -301,10 +301,19 @@ export function createPresignedUrlPlugin(options) {
301
301
  const bucket = await getBucketConfig(txClient, storageConfig, databaseId, vals.bucketKey, vals.ownerId || undefined);
302
302
  if (!bucket)
303
303
  throw new Error('BUCKET_NOT_FOUND');
304
+ // Enforce bulk upload limits
305
+ const filesArray = vals.files;
306
+ if (filesArray.length > storageConfig.maxBulkFiles) {
307
+ throw new Error(`BULK_UPLOAD_FILES_EXCEEDED: ${filesArray.length} files exceeds maximum of ${storageConfig.maxBulkFiles} per batch`);
308
+ }
309
+ const totalSize = filesArray.reduce((sum, f) => sum + (f.size || 0), 0);
310
+ if (totalSize > storageConfig.maxBulkTotalSize) {
311
+ throw new Error(`BULK_UPLOAD_SIZE_EXCEEDED: ${totalSize} bytes exceeds maximum of ${storageConfig.maxBulkTotalSize} bytes per batch`);
312
+ }
304
313
  const s3ForDb = resolveS3ForDatabase(options, storageConfig, databaseId);
305
314
  await ensureS3BucketExists(options, s3ForDb.bucket, bucket, databaseId, storageConfig.allowedOrigins);
306
315
  const results = [];
307
- for (const file of vals.files) {
316
+ for (const file of filesArray) {
308
317
  results.push(await processSingleFile(options, txClient, storageConfig, databaseId, bucket, s3ForDb, {
309
318
  contentHash: file.contentHash,
310
319
  contentType: file.contentType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphile-presigned-url-plugin",
3
- "version": "0.15.1",
3
+ "version": "0.16.0",
4
4
  "description": "Presigned URL upload plugin for PostGraphile v5 — requestUploadUrl mutation and downloadUrl computed field",
5
5
  "author": "Constructive <developers@constructive.io>",
6
6
  "homepage": "https://github.com/constructive-io/constructive",
@@ -60,5 +60,5 @@
60
60
  "@types/node": "^22.19.11",
61
61
  "makage": "^0.1.10"
62
62
  },
63
- "gitHead": "44e6712bd8a37e2089418a69d801d67651c89350"
63
+ "gitHead": "b1a89c4ab45fd22a63487cc6dc923a17772fac60"
64
64
  }
package/plugin.js CHANGED
@@ -305,10 +305,19 @@ function createPresignedUrlPlugin(options) {
305
305
  const bucket = await (0, storage_module_cache_1.getBucketConfig)(txClient, storageConfig, databaseId, vals.bucketKey, vals.ownerId || undefined);
306
306
  if (!bucket)
307
307
  throw new Error('BUCKET_NOT_FOUND');
308
+ // Enforce bulk upload limits
309
+ const filesArray = vals.files;
310
+ if (filesArray.length > storageConfig.maxBulkFiles) {
311
+ throw new Error(`BULK_UPLOAD_FILES_EXCEEDED: ${filesArray.length} files exceeds maximum of ${storageConfig.maxBulkFiles} per batch`);
312
+ }
313
+ const totalSize = filesArray.reduce((sum, f) => sum + (f.size || 0), 0);
314
+ if (totalSize > storageConfig.maxBulkTotalSize) {
315
+ throw new Error(`BULK_UPLOAD_SIZE_EXCEEDED: ${totalSize} bytes exceeds maximum of ${storageConfig.maxBulkTotalSize} bytes per batch`);
316
+ }
308
317
  const s3ForDb = resolveS3ForDatabase(options, storageConfig, databaseId);
309
318
  await ensureS3BucketExists(options, s3ForDb.bucket, bucket, databaseId, storageConfig.allowedOrigins);
310
319
  const results = [];
311
- for (const file of vals.files) {
320
+ for (const file of filesArray) {
312
321
  results.push(await processSingleFile(options, txClient, storageConfig, databaseId, bucket, s3ForDb, {
313
322
  contentHash: file.contentHash,
314
323
  contentType: file.contentType,