graphile-presigned-url-plugin 0.14.0 → 0.15.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 +14 -3
  2. package/package.json +4 -4
  3. package/plugin.js +14 -3
package/esm/plugin.js CHANGED
@@ -171,10 +171,21 @@ export function createPresignedUrlPlugin(options) {
171
171
  for (const filesCodec of fileCodecs) {
172
172
  const filesTypeName = build.inflection.tableType(filesCodec);
173
173
  const filesSchemaName = filesCodec.extensions?.pg?.schemaName;
174
- // Find the matching bucket codec by schema name
175
- const matchingBucketCodec = bucketCodecs.find((bc) => bc.extensions?.pg?.schemaName === filesSchemaName);
174
+ // Find the matching bucket codec by table name prefix.
175
+ // Schema-name matching is ambiguous when multiple storage modules share
176
+ // the same PG schema (e.g. app_files + data_room_files both in storage_public).
177
+ // Instead, derive the prefix from the raw SQL table name:
178
+ // "data_room_files" → prefix "data_room" → matches "data_room_buckets"
179
+ // "app_files" → prefix "app" → matches "app_buckets"
180
+ const filesRawName = filesCodec.extensions?.pg?.name;
181
+ const filesPrefix = filesRawName?.replace(/_files$/, '');
182
+ const matchingBucketCodec = bucketCodecs.find((bc) => {
183
+ const bucketRawName = bc.extensions?.pg?.name;
184
+ const bucketPrefix = bucketRawName?.replace(/_buckets$/, '');
185
+ return bucketPrefix === filesPrefix;
186
+ });
176
187
  if (!matchingBucketCodec) {
177
- log.debug(`Skipping create mutation for ${filesCodec.name}: no matching bucket codec in schema ${filesSchemaName}`);
188
+ log.debug(`Skipping upload mutation for ${filesCodec.name}: no matching bucket codec with prefix "${filesPrefix}"`);
178
189
  continue;
179
190
  }
180
191
  const hasOwnerId = !!matchingBucketCodec.attributes.owner_id;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphile-presigned-url-plugin",
3
- "version": "0.14.0",
3
+ "version": "0.15.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",
@@ -42,7 +42,7 @@
42
42
  "dependencies": {
43
43
  "@aws-sdk/client-s3": "^3.1009.0",
44
44
  "@aws-sdk/s3-request-presigner": "^3.1009.0",
45
- "@pgpmjs/logger": "^2.8.0",
45
+ "@pgpmjs/logger": "^2.9.0",
46
46
  "@pgsql/quotes": "^17.1.0",
47
47
  "lru-cache": "^11.2.7"
48
48
  },
@@ -56,9 +56,9 @@
56
56
  "postgraphile": "5.0.0"
57
57
  },
58
58
  "devDependencies": {
59
- "@constructive-io/s3-utils": "^2.14.0",
59
+ "@constructive-io/s3-utils": "^2.15.0",
60
60
  "@types/node": "^22.19.11",
61
61
  "makage": "^0.1.10"
62
62
  },
63
- "gitHead": "c1ecb2b54ea2bd12e2edeecc4ec721ccf93a67bf"
63
+ "gitHead": "0538fe39630e6bafd228cb3f2b114fff4f9a61aa"
64
64
  }
package/plugin.js CHANGED
@@ -175,10 +175,21 @@ function createPresignedUrlPlugin(options) {
175
175
  for (const filesCodec of fileCodecs) {
176
176
  const filesTypeName = build.inflection.tableType(filesCodec);
177
177
  const filesSchemaName = filesCodec.extensions?.pg?.schemaName;
178
- // Find the matching bucket codec by schema name
179
- const matchingBucketCodec = bucketCodecs.find((bc) => bc.extensions?.pg?.schemaName === filesSchemaName);
178
+ // Find the matching bucket codec by table name prefix.
179
+ // Schema-name matching is ambiguous when multiple storage modules share
180
+ // the same PG schema (e.g. app_files + data_room_files both in storage_public).
181
+ // Instead, derive the prefix from the raw SQL table name:
182
+ // "data_room_files" → prefix "data_room" → matches "data_room_buckets"
183
+ // "app_files" → prefix "app" → matches "app_buckets"
184
+ const filesRawName = filesCodec.extensions?.pg?.name;
185
+ const filesPrefix = filesRawName?.replace(/_files$/, '');
186
+ const matchingBucketCodec = bucketCodecs.find((bc) => {
187
+ const bucketRawName = bc.extensions?.pg?.name;
188
+ const bucketPrefix = bucketRawName?.replace(/_buckets$/, '');
189
+ return bucketPrefix === filesPrefix;
190
+ });
180
191
  if (!matchingBucketCodec) {
181
- log.debug(`Skipping create mutation for ${filesCodec.name}: no matching bucket codec in schema ${filesSchemaName}`);
192
+ log.debug(`Skipping upload mutation for ${filesCodec.name}: no matching bucket codec with prefix "${filesPrefix}"`);
182
193
  continue;
183
194
  }
184
195
  const hasOwnerId = !!matchingBucketCodec.attributes.owner_id;