graphile-bucket-provisioner-plugin 0.2.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/types.d.ts ADDED
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Types for the bucket provisioner plugin.
3
+ *
4
+ * Defines plugin options, connection configuration, and provisioning result
5
+ * types used by the Graphile plugin to auto-provision S3 buckets when
6
+ * bucket rows are created via GraphQL mutations.
7
+ */
8
+ import type { StorageConnectionConfig, StorageProvider, BucketAccessType, ProvisionResult } from '@constructive-io/bucket-provisioner';
9
+ export type { StorageConnectionConfig, StorageProvider, BucketAccessType, ProvisionResult };
10
+ /**
11
+ * S3 connection configuration or a lazy getter that returns it on first use.
12
+ *
13
+ * When a function is provided, it will only be called when the first
14
+ * provisioning operation actually needs the S3 client — avoiding eager
15
+ * env-var reads and S3Client creation at module import time.
16
+ */
17
+ export type ConnectionConfigOrGetter = StorageConnectionConfig | (() => StorageConnectionConfig);
18
+ /**
19
+ * Function to derive the actual S3 bucket name from a logical bucket key.
20
+ *
21
+ * @param bucketKey - The logical bucket key from the database (e.g., "public", "private")
22
+ * @param databaseId - The metaschema database UUID
23
+ * @returns The S3 bucket name to create/configure
24
+ */
25
+ export type BucketNameResolver = (bucketKey: string, databaseId: string) => string;
26
+ /**
27
+ * Plugin options for the bucket provisioner plugin.
28
+ */
29
+ export interface BucketProvisionerPluginOptions {
30
+ /**
31
+ * S3 connection configuration (credentials, endpoint, provider).
32
+ * Can be a concrete object or a lazy getter function.
33
+ */
34
+ connection: ConnectionConfigOrGetter;
35
+ /**
36
+ * Allowed origins for CORS rules on provisioned buckets.
37
+ * These are the domains where your app runs (e.g., ["https://app.example.com"]).
38
+ * Required for browser-based presigned URL uploads.
39
+ */
40
+ allowedOrigins: string[];
41
+ /**
42
+ * Optional prefix for S3 bucket names.
43
+ * When set, the S3 bucket name becomes `{prefix}-{bucketKey}`.
44
+ * Example: prefix "myapp" + key "public" → S3 bucket "myapp-public"
45
+ */
46
+ bucketNamePrefix?: string;
47
+ /**
48
+ * Optional custom function to derive S3 bucket names from logical bucket keys.
49
+ * Takes precedence over `bucketNamePrefix` when provided.
50
+ */
51
+ resolveBucketName?: BucketNameResolver;
52
+ /**
53
+ * Whether to enable versioning on provisioned buckets.
54
+ * Default: false
55
+ */
56
+ versioning?: boolean;
57
+ /**
58
+ * Whether to auto-provision S3 buckets when bucket rows are created
59
+ * via GraphQL mutations. When true, the plugin wraps create mutations
60
+ * on tables tagged with `@storageBuckets` to trigger provisioning
61
+ * after the mutation succeeds.
62
+ *
63
+ * Default: true
64
+ */
65
+ autoProvision?: boolean;
66
+ }
67
+ /**
68
+ * Input for the provisionBucket mutation.
69
+ */
70
+ export interface ProvisionBucketInput {
71
+ /** The logical bucket key (e.g., "public", "private") */
72
+ bucketKey: string;
73
+ }
74
+ /**
75
+ * Result of the provisionBucket mutation.
76
+ */
77
+ export interface ProvisionBucketPayload {
78
+ /** Whether provisioning succeeded */
79
+ success: boolean;
80
+ /** The S3 bucket name that was provisioned */
81
+ bucketName: string;
82
+ /** The access type applied */
83
+ accessType: string;
84
+ /** The storage provider used */
85
+ provider: string;
86
+ /** The S3 endpoint (null for AWS S3 default) */
87
+ endpoint: string | null;
88
+ /** Error message if provisioning failed */
89
+ error: string | null;
90
+ }
package/types.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /**
3
+ * Types for the bucket provisioner plugin.
4
+ *
5
+ * Defines plugin options, connection configuration, and provisioning result
6
+ * types used by the Graphile plugin to auto-provision S3 buckets when
7
+ * bucket rows are created via GraphQL mutations.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });