graphile-settings 6.11.10 → 6.12.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/esm/presets/constructive-preset.js +12 -2
- package/esm/presigned-url-resolver.d.ts +15 -4
- package/esm/presigned-url-resolver.js +41 -11
- package/package.json +3 -3
- package/presets/constructive-preset.js +11 -1
- package/presigned-url-resolver.d.ts +15 -4
- package/presigned-url-resolver.js +42 -11
|
@@ -13,7 +13,7 @@ import { createMatchesOperatorFactory, createTrgmOperatorFactories, UnifiedSearc
|
|
|
13
13
|
import { UploadPreset } from 'graphile-upload-plugin';
|
|
14
14
|
import { getBucketProvisionerConnection } from '../bucket-provisioner-resolver';
|
|
15
15
|
import { ConflictDetectorPreset, EnableAllFilterColumnsPreset, InflectorLoggerPreset, InflektPreset, ManyToManyOptInPreset, MetaSchemaPreset, MinimalPreset, NoUniqueLookupPreset, PgTypeMappingsPreset, RequiredInputPreset } from '../plugins';
|
|
16
|
-
import { createBucketNameResolver, createEnsureBucketProvisioned, getAllowedOrigins, getPresignedUrlS3Config } from '../presigned-url-resolver';
|
|
16
|
+
import { createBucketNameResolver, createEnsureBucketProvisioned, createProvisionerBucketNameResolver, getAllowedOrigins, getPresignedUrlS3Config } from '../presigned-url-resolver';
|
|
17
17
|
import { constructiveUploadFieldDefinitions } from '../upload-resolver';
|
|
18
18
|
/**
|
|
19
19
|
* grafast / @dataplan/pg require Node >= 22 (they call Promise.withResolvers()
|
|
@@ -144,7 +144,17 @@ export function createConstructivePreset(options) {
|
|
|
144
144
|
ensureBucketProvisioned: createEnsureBucketProvisioned()
|
|
145
145
|
}), BucketProvisionerPreset({
|
|
146
146
|
connection: getBucketProvisionerConnection,
|
|
147
|
-
allowedOrigins: getAllowedOrigins()
|
|
147
|
+
allowedOrigins: getAllowedOrigins(),
|
|
148
|
+
// Same tenant-aware naming policy as the presigned (lazy) path, so the
|
|
149
|
+
// eager provisionBucket mutation mints the identical physical name
|
|
150
|
+
// (`{prefix}-{bucketKey}-{databaseId}`) instead of falling back to the
|
|
151
|
+
// bare logical bucket key.
|
|
152
|
+
resolveBucketName: createProvisionerBucketNameResolver(),
|
|
153
|
+
// S3 buckets are provisioned lazily (on first upload) or explicitly via
|
|
154
|
+
// the provisionBucket mutation. Disable the auto-provision-on-create
|
|
155
|
+
// hook so a createBucket GraphQL mutation records the row without
|
|
156
|
+
// eagerly minting an S3 bucket that may never receive an upload.
|
|
157
|
+
autoProvision: false
|
|
148
158
|
}));
|
|
149
159
|
}
|
|
150
160
|
if (opts.enableAggregates) {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Follows the same lazy-init pattern as upload-resolver.ts.
|
|
12
12
|
*/
|
|
13
|
+
import type { BucketNameResolver as ProvisionerBucketNameResolver } from 'graphile-bucket-provisioner-plugin';
|
|
13
14
|
import type { BucketNameResolver, EnsureBucketProvisioned, S3Config } from 'graphile-presigned-url-plugin';
|
|
14
15
|
/**
|
|
15
16
|
* Lazily initialize and return the S3Config for the presigned URL plugin.
|
|
@@ -24,16 +25,26 @@ import type { BucketNameResolver, EnsureBucketProvisioned, S3Config } from 'grap
|
|
|
24
25
|
*/
|
|
25
26
|
export declare function getPresignedUrlS3Config(): S3Config;
|
|
26
27
|
/**
|
|
27
|
-
* Create a per-(database, bucketKey) bucket name resolver
|
|
28
|
+
* Create a per-(database, bucketKey) bucket name resolver for the presigned
|
|
29
|
+
* URL plugin (argument order: `(databaseId, bucketKey)`).
|
|
28
30
|
*
|
|
29
|
-
* Uses
|
|
30
|
-
*
|
|
31
|
-
* (e.g., "myapp-public-abc123def456").
|
|
31
|
+
* Uses CDN_BUCKET_NAME as a prefix. For each (database, bucketKey) pair, the
|
|
32
|
+
* S3 bucket name becomes `{prefix}-{bucketKey}-{databaseId}`.
|
|
32
33
|
*
|
|
33
34
|
* This aligns with the bucket provisioner plugin which creates separate
|
|
34
35
|
* S3 buckets per logical bucket key.
|
|
35
36
|
*/
|
|
36
37
|
export declare function createBucketNameResolver(): BucketNameResolver;
|
|
38
|
+
/**
|
|
39
|
+
* Create the bucket name resolver for the bucket provisioner plugin
|
|
40
|
+
* (argument order: `(bucketKey, databaseId)`).
|
|
41
|
+
*
|
|
42
|
+
* Produces the exact same physical name as createBucketNameResolver()
|
|
43
|
+
* (`{prefix}-{bucketKey}-{databaseId}`) so the eager `provisionBucket`
|
|
44
|
+
* mutation mints the identical tenant-aware name that the lazy first-upload
|
|
45
|
+
* path would. Throws on a missing prefix — no default bucket name.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createProvisionerBucketNameResolver(): ProvisionerBucketNameResolver;
|
|
37
48
|
/**
|
|
38
49
|
* Resolve CORS allowed origins from the env/config system.
|
|
39
50
|
*
|
|
@@ -64,25 +64,55 @@ export function getPresignedUrlS3Config() {
|
|
|
64
64
|
return s3Config;
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
67
|
+
* Read the configured physical-bucket-name prefix (CDN_BUCKET_NAME).
|
|
68
68
|
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* (e.g., "myapp-public-abc123def456").
|
|
72
|
-
*
|
|
73
|
-
* This aligns with the bucket provisioner plugin which creates separate
|
|
74
|
-
* S3 buckets per logical bucket key.
|
|
69
|
+
* There is no default: a missing prefix throws, mirroring
|
|
70
|
+
* getPresignedUrlS3Config, so an untenanted bucket name can never be minted.
|
|
75
71
|
*/
|
|
76
|
-
|
|
72
|
+
function getBucketNamePrefix() {
|
|
77
73
|
const { cdn } = getEnvOptions();
|
|
78
74
|
const prefix = cdn?.bucketName;
|
|
79
75
|
if (!prefix) {
|
|
80
76
|
throw new Error('[presigned-url-resolver] Missing CDN bucket name prefix. ' +
|
|
81
77
|
'Set CDN_BUCKET_NAME environment variable; there is no default bucket name.');
|
|
82
78
|
}
|
|
83
|
-
return
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
return prefix;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The single physical-bucket naming policy: `{prefix}-{bucketKey}-{databaseId}`
|
|
83
|
+
* (e.g., "myapp-public-abc123def456"). Both the presigned-upload (lazy) path
|
|
84
|
+
* and the bucket-provisioner (eager) path derive names from this one function
|
|
85
|
+
* so a bucket's physical name is identical regardless of which path mints it.
|
|
86
|
+
*/
|
|
87
|
+
function mintPhysicalBucketName(prefix, databaseId, bucketKey) {
|
|
88
|
+
return `${prefix}-${bucketKey}-${databaseId}`;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Create a per-(database, bucketKey) bucket name resolver for the presigned
|
|
92
|
+
* URL plugin (argument order: `(databaseId, bucketKey)`).
|
|
93
|
+
*
|
|
94
|
+
* Uses CDN_BUCKET_NAME as a prefix. For each (database, bucketKey) pair, the
|
|
95
|
+
* S3 bucket name becomes `{prefix}-{bucketKey}-{databaseId}`.
|
|
96
|
+
*
|
|
97
|
+
* This aligns with the bucket provisioner plugin which creates separate
|
|
98
|
+
* S3 buckets per logical bucket key.
|
|
99
|
+
*/
|
|
100
|
+
export function createBucketNameResolver() {
|
|
101
|
+
const prefix = getBucketNamePrefix();
|
|
102
|
+
return (databaseId, bucketKey) => mintPhysicalBucketName(prefix, databaseId, bucketKey);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Create the bucket name resolver for the bucket provisioner plugin
|
|
106
|
+
* (argument order: `(bucketKey, databaseId)`).
|
|
107
|
+
*
|
|
108
|
+
* Produces the exact same physical name as createBucketNameResolver()
|
|
109
|
+
* (`{prefix}-{bucketKey}-{databaseId}`) so the eager `provisionBucket`
|
|
110
|
+
* mutation mints the identical tenant-aware name that the lazy first-upload
|
|
111
|
+
* path would. Throws on a missing prefix — no default bucket name.
|
|
112
|
+
*/
|
|
113
|
+
export function createProvisionerBucketNameResolver() {
|
|
114
|
+
const prefix = getBucketNamePrefix();
|
|
115
|
+
return (bucketKey, databaseId) => mintPhysicalBucketName(prefix, databaseId, bucketKey);
|
|
86
116
|
}
|
|
87
117
|
/**
|
|
88
118
|
* Resolve CORS allowed origins from the env/config system.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphile-settings",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.12.0",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "graphile settings",
|
|
6
6
|
"main": "index.js",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"express": "^5.2.1",
|
|
47
47
|
"grafast": "1.0.2",
|
|
48
48
|
"grafserv": "1.0.0",
|
|
49
|
-
"graphile-bucket-provisioner-plugin": "1.
|
|
49
|
+
"graphile-bucket-provisioner-plugin": "1.11.0",
|
|
50
50
|
"graphile-build": "5.0.2",
|
|
51
51
|
"graphile-build-pg": "5.0.2",
|
|
52
52
|
"graphile-bulk-mutations": "^1.10.9",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"constructive",
|
|
92
92
|
"graphql"
|
|
93
93
|
],
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "247e48d25b13524d992f00c1b2dc063884d1deb1"
|
|
95
95
|
}
|
|
@@ -148,7 +148,17 @@ function createConstructivePreset(options) {
|
|
|
148
148
|
ensureBucketProvisioned: (0, presigned_url_resolver_1.createEnsureBucketProvisioned)()
|
|
149
149
|
}), (0, graphile_bucket_provisioner_plugin_1.BucketProvisionerPreset)({
|
|
150
150
|
connection: bucket_provisioner_resolver_1.getBucketProvisionerConnection,
|
|
151
|
-
allowedOrigins: (0, presigned_url_resolver_1.getAllowedOrigins)()
|
|
151
|
+
allowedOrigins: (0, presigned_url_resolver_1.getAllowedOrigins)(),
|
|
152
|
+
// Same tenant-aware naming policy as the presigned (lazy) path, so the
|
|
153
|
+
// eager provisionBucket mutation mints the identical physical name
|
|
154
|
+
// (`{prefix}-{bucketKey}-{databaseId}`) instead of falling back to the
|
|
155
|
+
// bare logical bucket key.
|
|
156
|
+
resolveBucketName: (0, presigned_url_resolver_1.createProvisionerBucketNameResolver)(),
|
|
157
|
+
// S3 buckets are provisioned lazily (on first upload) or explicitly via
|
|
158
|
+
// the provisionBucket mutation. Disable the auto-provision-on-create
|
|
159
|
+
// hook so a createBucket GraphQL mutation records the row without
|
|
160
|
+
// eagerly minting an S3 bucket that may never receive an upload.
|
|
161
|
+
autoProvision: false
|
|
152
162
|
}));
|
|
153
163
|
}
|
|
154
164
|
if (opts.enableAggregates) {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Follows the same lazy-init pattern as upload-resolver.ts.
|
|
12
12
|
*/
|
|
13
|
+
import type { BucketNameResolver as ProvisionerBucketNameResolver } from 'graphile-bucket-provisioner-plugin';
|
|
13
14
|
import type { BucketNameResolver, EnsureBucketProvisioned, S3Config } from 'graphile-presigned-url-plugin';
|
|
14
15
|
/**
|
|
15
16
|
* Lazily initialize and return the S3Config for the presigned URL plugin.
|
|
@@ -24,16 +25,26 @@ import type { BucketNameResolver, EnsureBucketProvisioned, S3Config } from 'grap
|
|
|
24
25
|
*/
|
|
25
26
|
export declare function getPresignedUrlS3Config(): S3Config;
|
|
26
27
|
/**
|
|
27
|
-
* Create a per-(database, bucketKey) bucket name resolver
|
|
28
|
+
* Create a per-(database, bucketKey) bucket name resolver for the presigned
|
|
29
|
+
* URL plugin (argument order: `(databaseId, bucketKey)`).
|
|
28
30
|
*
|
|
29
|
-
* Uses
|
|
30
|
-
*
|
|
31
|
-
* (e.g., "myapp-public-abc123def456").
|
|
31
|
+
* Uses CDN_BUCKET_NAME as a prefix. For each (database, bucketKey) pair, the
|
|
32
|
+
* S3 bucket name becomes `{prefix}-{bucketKey}-{databaseId}`.
|
|
32
33
|
*
|
|
33
34
|
* This aligns with the bucket provisioner plugin which creates separate
|
|
34
35
|
* S3 buckets per logical bucket key.
|
|
35
36
|
*/
|
|
36
37
|
export declare function createBucketNameResolver(): BucketNameResolver;
|
|
38
|
+
/**
|
|
39
|
+
* Create the bucket name resolver for the bucket provisioner plugin
|
|
40
|
+
* (argument order: `(bucketKey, databaseId)`).
|
|
41
|
+
*
|
|
42
|
+
* Produces the exact same physical name as createBucketNameResolver()
|
|
43
|
+
* (`{prefix}-{bucketKey}-{databaseId}`) so the eager `provisionBucket`
|
|
44
|
+
* mutation mints the identical tenant-aware name that the lazy first-upload
|
|
45
|
+
* path would. Throws on a missing prefix — no default bucket name.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createProvisionerBucketNameResolver(): ProvisionerBucketNameResolver;
|
|
37
48
|
/**
|
|
38
49
|
* Resolve CORS allowed origins from the env/config system.
|
|
39
50
|
*
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.getPresignedUrlS3Config = getPresignedUrlS3Config;
|
|
16
16
|
exports.createBucketNameResolver = createBucketNameResolver;
|
|
17
|
+
exports.createProvisionerBucketNameResolver = createProvisionerBucketNameResolver;
|
|
17
18
|
exports.getAllowedOrigins = getAllowedOrigins;
|
|
18
19
|
exports.createEnsureBucketProvisioned = createEnsureBucketProvisioned;
|
|
19
20
|
const bucket_provisioner_1 = require("@constructive-io/bucket-provisioner");
|
|
@@ -70,25 +71,55 @@ function getPresignedUrlS3Config() {
|
|
|
70
71
|
return s3Config;
|
|
71
72
|
}
|
|
72
73
|
/**
|
|
73
|
-
*
|
|
74
|
+
* Read the configured physical-bucket-name prefix (CDN_BUCKET_NAME).
|
|
74
75
|
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* (e.g., "myapp-public-abc123def456").
|
|
78
|
-
*
|
|
79
|
-
* This aligns with the bucket provisioner plugin which creates separate
|
|
80
|
-
* S3 buckets per logical bucket key.
|
|
76
|
+
* There is no default: a missing prefix throws, mirroring
|
|
77
|
+
* getPresignedUrlS3Config, so an untenanted bucket name can never be minted.
|
|
81
78
|
*/
|
|
82
|
-
function
|
|
79
|
+
function getBucketNamePrefix() {
|
|
83
80
|
const { cdn } = (0, graphql_env_1.getEnvOptions)();
|
|
84
81
|
const prefix = cdn?.bucketName;
|
|
85
82
|
if (!prefix) {
|
|
86
83
|
throw new Error('[presigned-url-resolver] Missing CDN bucket name prefix. ' +
|
|
87
84
|
'Set CDN_BUCKET_NAME environment variable; there is no default bucket name.');
|
|
88
85
|
}
|
|
89
|
-
return
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
return prefix;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The single physical-bucket naming policy: `{prefix}-{bucketKey}-{databaseId}`
|
|
90
|
+
* (e.g., "myapp-public-abc123def456"). Both the presigned-upload (lazy) path
|
|
91
|
+
* and the bucket-provisioner (eager) path derive names from this one function
|
|
92
|
+
* so a bucket's physical name is identical regardless of which path mints it.
|
|
93
|
+
*/
|
|
94
|
+
function mintPhysicalBucketName(prefix, databaseId, bucketKey) {
|
|
95
|
+
return `${prefix}-${bucketKey}-${databaseId}`;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Create a per-(database, bucketKey) bucket name resolver for the presigned
|
|
99
|
+
* URL plugin (argument order: `(databaseId, bucketKey)`).
|
|
100
|
+
*
|
|
101
|
+
* Uses CDN_BUCKET_NAME as a prefix. For each (database, bucketKey) pair, the
|
|
102
|
+
* S3 bucket name becomes `{prefix}-{bucketKey}-{databaseId}`.
|
|
103
|
+
*
|
|
104
|
+
* This aligns with the bucket provisioner plugin which creates separate
|
|
105
|
+
* S3 buckets per logical bucket key.
|
|
106
|
+
*/
|
|
107
|
+
function createBucketNameResolver() {
|
|
108
|
+
const prefix = getBucketNamePrefix();
|
|
109
|
+
return (databaseId, bucketKey) => mintPhysicalBucketName(prefix, databaseId, bucketKey);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Create the bucket name resolver for the bucket provisioner plugin
|
|
113
|
+
* (argument order: `(bucketKey, databaseId)`).
|
|
114
|
+
*
|
|
115
|
+
* Produces the exact same physical name as createBucketNameResolver()
|
|
116
|
+
* (`{prefix}-{bucketKey}-{databaseId}`) so the eager `provisionBucket`
|
|
117
|
+
* mutation mints the identical tenant-aware name that the lazy first-upload
|
|
118
|
+
* path would. Throws on a missing prefix — no default bucket name.
|
|
119
|
+
*/
|
|
120
|
+
function createProvisionerBucketNameResolver() {
|
|
121
|
+
const prefix = getBucketNamePrefix();
|
|
122
|
+
return (bucketKey, databaseId) => mintPhysicalBucketName(prefix, databaseId, bucketKey);
|
|
92
123
|
}
|
|
93
124
|
/**
|
|
94
125
|
* Resolve CORS allowed origins from the env/config system.
|