graphile-presigned-url-plugin 1.18.1 → 1.19.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/download-url-field.js +3 -2
- package/esm/download-url-field.js +3 -2
- package/esm/managed-upload.js +3 -2
- package/esm/plugin.js +9 -8
- package/esm/request-pg-client.d.ts +2 -7
- package/managed-upload.js +3 -2
- package/package.json +8 -7
- package/plugin.js +9 -8
- package/request-pg-client.d.ts +2 -7
package/download-url-field.js
CHANGED
|
@@ -24,6 +24,7 @@ exports.createDownloadUrlPlugin = createDownloadUrlPlugin;
|
|
|
24
24
|
require("graphile-build");
|
|
25
25
|
const logger_1 = require("@pgpmjs/logger");
|
|
26
26
|
const grafast_1 = require("grafast");
|
|
27
|
+
const graphile_plugin_utils_1 = require("graphile-plugin-utils");
|
|
27
28
|
const graphile_storage_registry_1 = require("graphile-storage-registry");
|
|
28
29
|
const physical_bucket_1 = require("./physical-bucket");
|
|
29
30
|
const request_pg_client_1 = require("./request-pg-client");
|
|
@@ -94,9 +95,9 @@ function createDownloadUrlPlugin(options) {
|
|
|
94
95
|
return dbResult.rows[0]?.id ?? null;
|
|
95
96
|
});
|
|
96
97
|
// Module registration is server config, not user data:
|
|
97
|
-
// resolve it
|
|
98
|
+
// resolve it in the system lane's bounded role.
|
|
98
99
|
const config = databaseId
|
|
99
|
-
? (0, storage_module_cache_1.resolveStorageConfigFromCodec)(capturedCodec, await
|
|
100
|
+
? (0, storage_module_cache_1.resolveStorageConfigFromCodec)(capturedCodec, await (0, graphile_plugin_utils_1.withSystemLaneClient)(withPgClient, (pgClient) => (0, storage_module_cache_1.loadAllStorageModules)(pgClient, databaseId)))
|
|
100
101
|
: null;
|
|
101
102
|
const resolved = config && bucketId
|
|
102
103
|
? await (0, request_pg_client_1.withRequestPgClient)(withPgClient, pgSettings, async (pgClient) => {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
import 'graphile-build';
|
|
22
22
|
import { Logger } from '@pgpmjs/logger';
|
|
23
23
|
import { context as grafastContext, lambda, object } from 'grafast';
|
|
24
|
+
import { withSystemLaneClient } from 'graphile-plugin-utils';
|
|
24
25
|
import { DOWNLOAD_URL_FIELD } from 'graphile-storage-registry';
|
|
25
26
|
import { resolveS3, resolveS3ForDatabase } from './physical-bucket';
|
|
26
27
|
import { withRequestPgClient } from './request-pg-client';
|
|
@@ -91,9 +92,9 @@ export function createDownloadUrlPlugin(options) {
|
|
|
91
92
|
return dbResult.rows[0]?.id ?? null;
|
|
92
93
|
});
|
|
93
94
|
// Module registration is server config, not user data:
|
|
94
|
-
// resolve it
|
|
95
|
+
// resolve it in the system lane's bounded role.
|
|
95
96
|
const config = databaseId
|
|
96
|
-
? resolveStorageConfigFromCodec(capturedCodec, await withPgClient
|
|
97
|
+
? resolveStorageConfigFromCodec(capturedCodec, await withSystemLaneClient(withPgClient, (pgClient) => loadAllStorageModules(pgClient, databaseId)))
|
|
97
98
|
: null;
|
|
98
99
|
const resolved = config && bucketId
|
|
99
100
|
? await withRequestPgClient(withPgClient, pgSettings, async (pgClient) => {
|
package/esm/managed-upload.js
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* an expiry.
|
|
19
19
|
*/
|
|
20
20
|
import { Logger } from '@pgpmjs/logger';
|
|
21
|
+
import { withSystemLaneClient } from 'graphile-plugin-utils';
|
|
21
22
|
import { resolveDefaultBucket } from './default-bucket';
|
|
22
23
|
import { isLiveFileRow, statusSelectFragment } from './file-lifecycle';
|
|
23
24
|
import { getFileRefFieldBinding } from './file-ref-registry';
|
|
@@ -74,7 +75,7 @@ export async function resolveManagedUploadTarget(args) {
|
|
|
74
75
|
const { options, withPgClient, pgSettings, databaseId, field, defaultPublicAccess } = args;
|
|
75
76
|
// Registry and module registration are schema metadata, not tenant rows:
|
|
76
77
|
// read them in the system lane, like every other config read here.
|
|
77
|
-
const binding = await withPgClient
|
|
78
|
+
const binding = await withSystemLaneClient(withPgClient, async (pgClient) => {
|
|
78
79
|
try {
|
|
79
80
|
return await getFileRefFieldBinding(pgClient, databaseId, field);
|
|
80
81
|
}
|
|
@@ -87,7 +88,7 @@ export async function resolveManagedUploadTarget(args) {
|
|
|
87
88
|
throw err;
|
|
88
89
|
}
|
|
89
90
|
});
|
|
90
|
-
const allConfigs = await withPgClient
|
|
91
|
+
const allConfigs = await withSystemLaneClient(withPgClient, (pgClient) => loadAllStorageModules(pgClient, databaseId));
|
|
91
92
|
const globalConfigs = allConfigs.filter((c) => c.entityTableId === null);
|
|
92
93
|
if (!binding && globalConfigs.length > 1) {
|
|
93
94
|
// Several global planes and no registry row to disambiguate: picking one is
|
package/esm/plugin.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
import 'graphile-build';
|
|
22
22
|
import { Logger } from '@pgpmjs/logger';
|
|
23
23
|
import { access, context as grafastContext, lambda, object } from 'grafast';
|
|
24
|
+
import { withSystemLaneClient } from 'graphile-plugin-utils';
|
|
24
25
|
import { discoverStoragePlanes, uploadSurfaceNames } from 'graphile-storage-registry';
|
|
25
26
|
import { checkTypeAgreement } from 'mime-bytes';
|
|
26
27
|
import { validateCustomKey } from './custom-key';
|
|
@@ -190,8 +191,8 @@ export function createPresignedUrlPlugin(options) {
|
|
|
190
191
|
if (!databaseId)
|
|
191
192
|
throw new Error('DATABASE_NOT_FOUND');
|
|
192
193
|
// Module registration is server config, not user data:
|
|
193
|
-
// resolve it
|
|
194
|
-
const allConfigs = await vals.withPgClient
|
|
194
|
+
// resolve it in the system lane's bounded role.
|
|
195
|
+
const allConfigs = await withSystemLaneClient(vals.withPgClient, (pgClient) => loadAllStorageModules(pgClient, databaseId));
|
|
195
196
|
const storageConfig = resolveStorageConfigFromCodec(capturedFilesCodec, allConfigs);
|
|
196
197
|
if (!storageConfig)
|
|
197
198
|
throw new Error('STORAGE_MODULE_NOT_FOUND');
|
|
@@ -286,8 +287,8 @@ export function createPresignedUrlPlugin(options) {
|
|
|
286
287
|
if (!databaseId)
|
|
287
288
|
throw new Error('DATABASE_NOT_FOUND');
|
|
288
289
|
// Module registration is server config, not user data:
|
|
289
|
-
// resolve it
|
|
290
|
-
const allConfigs = await vals.withPgClient
|
|
290
|
+
// resolve it in the system lane's bounded role.
|
|
291
|
+
const allConfigs = await withSystemLaneClient(vals.withPgClient, (pgClient) => loadAllStorageModules(pgClient, databaseId));
|
|
291
292
|
const storageConfig = resolveStorageConfigFromCodec(capturedFilesCodec, allConfigs);
|
|
292
293
|
if (!storageConfig)
|
|
293
294
|
throw new Error('STORAGE_MODULE_NOT_FOUND');
|
|
@@ -368,9 +369,9 @@ export function createPresignedUrlPlugin(options) {
|
|
|
368
369
|
try {
|
|
369
370
|
const databaseId = await withRequestPgClient(withPgClient, pgSettings, (pgClient) => resolveDatabaseId(pgClient));
|
|
370
371
|
// Module registration is server config, not user data:
|
|
371
|
-
// resolve it
|
|
372
|
+
// resolve it in the system lane's bounded role.
|
|
372
373
|
const allConfigs = databaseId
|
|
373
|
-
? await withPgClient
|
|
374
|
+
? await withSystemLaneClient(withPgClient, (pgClient) => loadAllStorageModules(pgClient, databaseId))
|
|
374
375
|
: [];
|
|
375
376
|
const storageConfig = resolveStorageConfigFromCodec(capturedCodec, allConfigs);
|
|
376
377
|
if (storageConfig) {
|
|
@@ -401,9 +402,9 @@ export function createPresignedUrlPlugin(options) {
|
|
|
401
402
|
try {
|
|
402
403
|
const databaseId = await withRequestPgClient(withPgClient, pgSettings, (pgClient) => resolveDatabaseId(pgClient));
|
|
403
404
|
// Module registration is server config, not user data:
|
|
404
|
-
// resolve it
|
|
405
|
+
// resolve it in the system lane's bounded role.
|
|
405
406
|
const allConfigs = databaseId
|
|
406
|
-
? await withPgClient
|
|
407
|
+
? await withSystemLaneClient(withPgClient, (pgClient) => loadAllStorageModules(pgClient, databaseId))
|
|
407
408
|
: [];
|
|
408
409
|
const storageConfig = resolveStorageConfigFromCodec(capturedCodec, allConfigs);
|
|
409
410
|
if (storageConfig)
|
|
@@ -16,13 +16,8 @@
|
|
|
16
16
|
* mirrors the `pg-query-context` pattern used elsewhere in the codebase for
|
|
17
17
|
* manual, multi-statement RLS work.
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
text: string;
|
|
22
|
-
values?: unknown[];
|
|
23
|
-
}): Promise<{
|
|
24
|
-
rows: Array<Record<string, unknown>>;
|
|
25
|
-
}>;
|
|
19
|
+
import { SystemLanePgClient } from 'graphile-plugin-utils';
|
|
20
|
+
export interface RequestPgClient extends Omit<SystemLanePgClient, 'withTransaction'> {
|
|
26
21
|
withTransaction<T>(cb: (tx: RequestPgClient) => Promise<T>): Promise<T>;
|
|
27
22
|
}
|
|
28
23
|
export type WithPgClient = <T>(pgSettings: Record<string, string> | null, cb: (client: RequestPgClient) => Promise<T>) => Promise<T>;
|
package/managed-upload.js
CHANGED
|
@@ -24,6 +24,7 @@ exports.resolveManagedUploadTarget = resolveManagedUploadTarget;
|
|
|
24
24
|
exports.assertUploadAllowedByBucket = assertUploadAllowedByBucket;
|
|
25
25
|
exports.finalizeStagedUpload = finalizeStagedUpload;
|
|
26
26
|
const logger_1 = require("@pgpmjs/logger");
|
|
27
|
+
const graphile_plugin_utils_1 = require("graphile-plugin-utils");
|
|
27
28
|
const default_bucket_1 = require("./default-bucket");
|
|
28
29
|
const file_lifecycle_1 = require("./file-lifecycle");
|
|
29
30
|
const file_ref_registry_1 = require("./file-ref-registry");
|
|
@@ -80,7 +81,7 @@ async function resolveManagedUploadTarget(args) {
|
|
|
80
81
|
const { options, withPgClient, pgSettings, databaseId, field, defaultPublicAccess } = args;
|
|
81
82
|
// Registry and module registration are schema metadata, not tenant rows:
|
|
82
83
|
// read them in the system lane, like every other config read here.
|
|
83
|
-
const binding = await
|
|
84
|
+
const binding = await (0, graphile_plugin_utils_1.withSystemLaneClient)(withPgClient, async (pgClient) => {
|
|
84
85
|
try {
|
|
85
86
|
return await (0, file_ref_registry_1.getFileRefFieldBinding)(pgClient, databaseId, field);
|
|
86
87
|
}
|
|
@@ -93,7 +94,7 @@ async function resolveManagedUploadTarget(args) {
|
|
|
93
94
|
throw err;
|
|
94
95
|
}
|
|
95
96
|
});
|
|
96
|
-
const allConfigs = await
|
|
97
|
+
const allConfigs = await (0, graphile_plugin_utils_1.withSystemLaneClient)(withPgClient, (pgClient) => (0, storage_module_cache_1.loadAllStorageModules)(pgClient, databaseId));
|
|
97
98
|
const globalConfigs = allConfigs.filter((c) => c.entityTableId === null);
|
|
98
99
|
if (!binding && globalConfigs.length > 1) {
|
|
99
100
|
// Several global planes and no registry row to disambiguate: picking one is
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphile-presigned-url-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.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,11 +42,12 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@aws-sdk/client-s3": "^3.1052.0",
|
|
44
44
|
"@aws-sdk/s3-request-presigner": "^3.1052.0",
|
|
45
|
-
"@pgpmjs/logger": "^2.25.
|
|
45
|
+
"@pgpmjs/logger": "^2.25.1",
|
|
46
46
|
"@pgsql/quotes": "^18.2.4",
|
|
47
|
-
"graphile-
|
|
47
|
+
"graphile-plugin-utils": "^1.12.2",
|
|
48
|
+
"graphile-storage-registry": "^0.1.2",
|
|
48
49
|
"lru-cache": "^11.2.7",
|
|
49
|
-
"mime-bytes": "^0.32.
|
|
50
|
+
"mime-bytes": "^0.32.1"
|
|
50
51
|
},
|
|
51
52
|
"peerDependencies": {
|
|
52
53
|
"grafast": "^1.1.1",
|
|
@@ -58,9 +59,9 @@
|
|
|
58
59
|
"postgraphile": "^5.1.3"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
61
|
-
"@constructive-io/s3-utils": "^2.
|
|
62
|
+
"@constructive-io/s3-utils": "^2.33.0",
|
|
62
63
|
"@types/node": "^22.19.11",
|
|
63
|
-
"makage": "^0.
|
|
64
|
+
"makage": "^0.8.0"
|
|
64
65
|
},
|
|
65
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "01e073830677c0587bab564b7d575a06b5156f0c"
|
|
66
67
|
}
|
package/plugin.js
CHANGED
|
@@ -25,6 +25,7 @@ exports.createPresignedUrlPlugin = createPresignedUrlPlugin;
|
|
|
25
25
|
require("graphile-build");
|
|
26
26
|
const logger_1 = require("@pgpmjs/logger");
|
|
27
27
|
const grafast_1 = require("grafast");
|
|
28
|
+
const graphile_plugin_utils_1 = require("graphile-plugin-utils");
|
|
28
29
|
const graphile_storage_registry_1 = require("graphile-storage-registry");
|
|
29
30
|
const mime_bytes_1 = require("mime-bytes");
|
|
30
31
|
const custom_key_1 = require("./custom-key");
|
|
@@ -194,8 +195,8 @@ function createPresignedUrlPlugin(options) {
|
|
|
194
195
|
if (!databaseId)
|
|
195
196
|
throw new Error('DATABASE_NOT_FOUND');
|
|
196
197
|
// Module registration is server config, not user data:
|
|
197
|
-
// resolve it
|
|
198
|
-
const allConfigs = await vals.withPgClient
|
|
198
|
+
// resolve it in the system lane's bounded role.
|
|
199
|
+
const allConfigs = await (0, graphile_plugin_utils_1.withSystemLaneClient)(vals.withPgClient, (pgClient) => (0, storage_module_cache_1.loadAllStorageModules)(pgClient, databaseId));
|
|
199
200
|
const storageConfig = (0, storage_module_cache_1.resolveStorageConfigFromCodec)(capturedFilesCodec, allConfigs);
|
|
200
201
|
if (!storageConfig)
|
|
201
202
|
throw new Error('STORAGE_MODULE_NOT_FOUND');
|
|
@@ -290,8 +291,8 @@ function createPresignedUrlPlugin(options) {
|
|
|
290
291
|
if (!databaseId)
|
|
291
292
|
throw new Error('DATABASE_NOT_FOUND');
|
|
292
293
|
// Module registration is server config, not user data:
|
|
293
|
-
// resolve it
|
|
294
|
-
const allConfigs = await vals.withPgClient
|
|
294
|
+
// resolve it in the system lane's bounded role.
|
|
295
|
+
const allConfigs = await (0, graphile_plugin_utils_1.withSystemLaneClient)(vals.withPgClient, (pgClient) => (0, storage_module_cache_1.loadAllStorageModules)(pgClient, databaseId));
|
|
295
296
|
const storageConfig = (0, storage_module_cache_1.resolveStorageConfigFromCodec)(capturedFilesCodec, allConfigs);
|
|
296
297
|
if (!storageConfig)
|
|
297
298
|
throw new Error('STORAGE_MODULE_NOT_FOUND');
|
|
@@ -372,9 +373,9 @@ function createPresignedUrlPlugin(options) {
|
|
|
372
373
|
try {
|
|
373
374
|
const databaseId = await (0, request_pg_client_1.withRequestPgClient)(withPgClient, pgSettings, (pgClient) => resolveDatabaseId(pgClient));
|
|
374
375
|
// Module registration is server config, not user data:
|
|
375
|
-
// resolve it
|
|
376
|
+
// resolve it in the system lane's bounded role.
|
|
376
377
|
const allConfigs = databaseId
|
|
377
|
-
? await
|
|
378
|
+
? await (0, graphile_plugin_utils_1.withSystemLaneClient)(withPgClient, (pgClient) => (0, storage_module_cache_1.loadAllStorageModules)(pgClient, databaseId))
|
|
378
379
|
: [];
|
|
379
380
|
const storageConfig = (0, storage_module_cache_1.resolveStorageConfigFromCodec)(capturedCodec, allConfigs);
|
|
380
381
|
if (storageConfig) {
|
|
@@ -405,9 +406,9 @@ function createPresignedUrlPlugin(options) {
|
|
|
405
406
|
try {
|
|
406
407
|
const databaseId = await (0, request_pg_client_1.withRequestPgClient)(withPgClient, pgSettings, (pgClient) => resolveDatabaseId(pgClient));
|
|
407
408
|
// Module registration is server config, not user data:
|
|
408
|
-
// resolve it
|
|
409
|
+
// resolve it in the system lane's bounded role.
|
|
409
410
|
const allConfigs = databaseId
|
|
410
|
-
? await
|
|
411
|
+
? await (0, graphile_plugin_utils_1.withSystemLaneClient)(withPgClient, (pgClient) => (0, storage_module_cache_1.loadAllStorageModules)(pgClient, databaseId))
|
|
411
412
|
: [];
|
|
412
413
|
const storageConfig = (0, storage_module_cache_1.resolveStorageConfigFromCodec)(capturedCodec, allConfigs);
|
|
413
414
|
if (storageConfig)
|
package/request-pg-client.d.ts
CHANGED
|
@@ -16,13 +16,8 @@
|
|
|
16
16
|
* mirrors the `pg-query-context` pattern used elsewhere in the codebase for
|
|
17
17
|
* manual, multi-statement RLS work.
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
text: string;
|
|
22
|
-
values?: unknown[];
|
|
23
|
-
}): Promise<{
|
|
24
|
-
rows: Array<Record<string, unknown>>;
|
|
25
|
-
}>;
|
|
19
|
+
import { SystemLanePgClient } from 'graphile-plugin-utils';
|
|
20
|
+
export interface RequestPgClient extends Omit<SystemLanePgClient, 'withTransaction'> {
|
|
26
21
|
withTransaction<T>(cb: (tx: RequestPgClient) => Promise<T>): Promise<T>;
|
|
27
22
|
}
|
|
28
23
|
export type WithPgClient = <T>(pgSettings: Record<string, string> | null, cb: (client: RequestPgClient) => Promise<T>) => Promise<T>;
|