Skip to content

Commit 9b1a48a

Browse files
committed
fix: update snapshots, tests, and seeds for storage simplification
- Remove confirmUpload and status from graphile-test.test.ts.snap - Remove ConfirmUploadInput/Payload types from schema-snapshot.test.ts.snap - Rewrite upload.integration.test.ts: remove confirmUpload tests, remove status assertions - Update seed SQL: remove upload_requests table, remove status from files, add UNIQUE(bucket_id, key) - Remove upload_requests_table_id/name from storage_module seed - Update README and package.json descriptions
1 parent e3c516d commit 9b1a48a

8 files changed

Lines changed: 5 additions & 250 deletions

File tree

graphile/graphile-presigned-url-plugin/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ Presigned URL upload plugin for PostGraphile v5.
1717
## Features
1818

1919
- `requestUploadUrl` mutation — generates presigned PUT URLs for direct client-to-S3 upload
20-
- `confirmUpload` mutation — verifies upload and transitions file status to 'ready'
2120
- `downloadUrl` computed field — presigned GET URLs for private files, public URLs for public files
2221
- Content-hash based S3 keys (SHA-256) with automatic deduplication
2322
- Per-bucket MIME type and file size validation
24-
- Upload request tracking for audit and rate limiting
2523

2624
## Usage
2725

graphile/graphile-presigned-url-plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "graphile-presigned-url-plugin",
33
"version": "0.7.0",
4-
"description": "Presigned URL upload plugin for PostGraphile v5 — requestUploadUrl, confirmUpload mutations and downloadUrl computed field",
4+
"description": "Presigned URL upload plugin for PostGraphile v5 — requestUploadUrl mutation and downloadUrl computed field",
55
"author": "Constructive <developers@constructive.io>",
66
"homepage": "https://github.com/constructive-io/constructive",
77
"license": "MIT",

graphql/server-test/__fixtures__/seed/simple-seed-storage/schema.sql

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Schema creation for simple-seed-storage test scenario
2-
-- Creates the app schema with storage tables (buckets, files, upload_requests)
2+
-- Creates the app schema with storage tables (buckets, files)
33

44
-- Create app schemas
55
CREATE SCHEMA IF NOT EXISTS "simple-storage-public";
@@ -45,32 +45,13 @@ CREATE TABLE IF NOT EXISTS "simple-storage-public".files (
4545
filename text,
4646
owner_id uuid,
4747
is_public boolean NOT NULL DEFAULT false,
48-
status text NOT NULL DEFAULT 'pending',
4948
created_at timestamptz DEFAULT now(),
50-
updated_at timestamptz DEFAULT now()
49+
updated_at timestamptz DEFAULT now(),
50+
UNIQUE (bucket_id, key)
5151
);
5252

5353
COMMENT ON TABLE "simple-storage-public".files IS E'@storageFiles\nStorage files table';
5454

55-
-- Upload requests table
56-
CREATE TABLE IF NOT EXISTS "simple-storage-public".upload_requests (
57-
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
58-
file_id uuid NOT NULL REFERENCES "simple-storage-public".files(id),
59-
actor_id uuid,
60-
bucket_id uuid NOT NULL REFERENCES "simple-storage-public".buckets(id),
61-
key text NOT NULL,
62-
content_type text NOT NULL,
63-
content_hash text,
64-
status text NOT NULL DEFAULT 'issued',
65-
expires_at timestamptz,
66-
confirmed_at timestamptz,
67-
ip_address inet,
68-
user_agent text,
69-
created_at timestamptz DEFAULT now(),
70-
updated_at timestamptz DEFAULT now()
71-
);
72-
7355
-- Grant table permissions (allow anonymous to do CRUD for tests — no RLS)
7456
GRANT SELECT, INSERT, UPDATE, DELETE ON "simple-storage-public".buckets TO administrator, authenticated, anonymous;
7557
GRANT SELECT, INSERT, UPDATE, DELETE ON "simple-storage-public".files TO administrator, authenticated, anonymous;
76-
GRANT SELECT, INSERT, UPDATE, DELETE ON "simple-storage-public".upload_requests TO administrator, authenticated, anonymous;

graphql/server-test/__fixtures__/seed/simple-seed-storage/setup.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,8 @@ CREATE TABLE IF NOT EXISTS metaschema_modules_public.storage_module (
4747
private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
4848
buckets_table_id uuid NOT NULL DEFAULT uuid_nil(),
4949
files_table_id uuid NOT NULL DEFAULT uuid_nil(),
50-
upload_requests_table_id uuid NOT NULL DEFAULT uuid_nil(),
5150
buckets_table_name text NOT NULL DEFAULT 'app_buckets',
5251
files_table_name text NOT NULL DEFAULT 'app_files',
53-
upload_requests_table_name text NOT NULL DEFAULT 'app_upload_requests',
5452
membership_type int DEFAULT NULL,
5553
entity_table_id uuid NULL,
5654
endpoint text NULL,

graphql/server-test/__fixtures__/seed/simple-seed-storage/test-data.sql

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,6 @@ VALUES (
4343
NULL
4444
) ON CONFLICT (id) DO NOTHING;
4545

46-
-- upload_requests
47-
INSERT INTO metaschema_public.table (id, database_id, schema_id, name, description)
48-
VALUES (
49-
'b0000001-0000-0000-0000-000000000003',
50-
'80a2eaaf-f77e-4bfe-8506-df929ef1b8d9',
51-
'6dbae92a-5450-401b-1ed5-d69e7754940d',
52-
'upload_requests',
53-
NULL
54-
) ON CONFLICT (id) DO NOTHING;
55-
5646
-- =====================================================
5747
-- SERVICES DATA
5848
-- =====================================================
@@ -77,7 +67,6 @@ INSERT INTO metaschema_modules_public.storage_module (
7767
schema_id,
7868
buckets_table_id,
7969
files_table_id,
80-
upload_requests_table_id,
8170
endpoint,
8271
public_url_prefix,
8372
provider,
@@ -89,7 +78,6 @@ VALUES (
8978
'6dbae92a-5450-401b-1ed5-d69e7754940d',
9079
'b0000001-0000-0000-0000-000000000001',
9180
'b0000001-0000-0000-0000-000000000002',
92-
'b0000001-0000-0000-0000-000000000003',
9381
NULL, -- use global CDN_ENDPOINT
9482
NULL, -- use global CDN_PUBLIC_URL_PREFIX
9583
'minio',

graphql/server-test/__tests__/__snapshots__/schema-snapshot.test.ts.snap

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,27 +2106,6 @@ type RequestUploadUrlPayload {
21062106
21072107
"""Presigned URL expiry time (null if deduplicated)"""
21082108
expiresAt: Datetime
2109-
2110-
"""
2111-
File status — 'pending' for fresh uploads, 'ready' or 'processed' for deduplicated files. Clients can use this to know immediately whether the file is usable.
2112-
"""
2113-
status: String!
2114-
}
2115-
2116-
input ConfirmUploadInput {
2117-
"""The file ID returned by requestUploadUrl"""
2118-
fileId: UUID!
2119-
}
2120-
2121-
type ConfirmUploadPayload {
2122-
"""The confirmed file ID"""
2123-
fileId: UUID!
2124-
2125-
"""New file status"""
2126-
status: String!
2127-
2128-
"""Whether confirmation succeeded"""
2129-
success: Boolean!
21302109
}
21312110
21322111
"""The root query type which gives access points into the data universe."""
@@ -2419,18 +2398,6 @@ type Mutation {
24192398
input: RequestUploadUrlInput!
24202399
): RequestUploadUrlPayload
24212400
2422-
"""
2423-
Confirm that a file has been uploaded to S3.
2424-
Verifies the object exists in S3, checks content-type,
2425-
and transitions the file status from 'pending' to 'ready'.
2426-
"""
2427-
confirmUpload(
2428-
"""
2429-
The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields.
2430-
"""
2431-
input: ConfirmUploadInput!
2432-
): ConfirmUploadPayload
2433-
24342401
"""
24352402
Provision an S3 bucket for a logical bucket in the database.
24362403
Reads the bucket config via RLS, then creates and configures

graphql/server-test/__tests__/upload.integration.test.ts

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Upload Integration Tests — end-to-end presigned URL flow
33
*
44
* Exercises the full upload pipeline for both public and private files:
5-
* requestUploadUrl → PUT to presigned URL → confirmUpload → downloadUrl
5+
* requestUploadUrl → PUT to presigned URL → downloadUrl
66
*
77
* Uses real MinIO (available in CI as minio_cdn service) and lazy bucket
88
* provisioning. No RLS — that will be tested in constructive-db.
@@ -49,17 +49,6 @@ const REQUEST_UPLOAD_URL = `
4949
key
5050
deduplicated
5151
expiresAt
52-
status
53-
}
54-
}
55-
`;
56-
57-
const CONFIRM_UPLOAD = `
58-
mutation ConfirmUpload($input: ConfirmUploadInput!) {
59-
confirmUpload(input: $input) {
60-
fileId
61-
status
62-
success
6352
}
6453
}
6554
`;
@@ -159,7 +148,6 @@ describe('Upload integration (presigned URL flow)', () => {
159148
expect(payload.key).toBe(contentHash);
160149
expect(payload.deduplicated).toBe(false);
161150
expect(payload.expiresAt).toBeTruthy();
162-
expect(payload.status).toBe('pending');
163151

164152
uploadUrl = payload.uploadUrl;
165153
fileId = payload.fileId;
@@ -169,23 +157,6 @@ describe('Upload integration (presigned URL flow)', () => {
169157
const putRes = await putToPresignedUrl(uploadUrl, fileContent, contentType);
170158
expect(putRes.ok).toBe(true);
171159
});
172-
173-
it('should confirm the upload and transition file to ready', async () => {
174-
const res = await postGraphQL({
175-
query: CONFIRM_UPLOAD,
176-
variables: {
177-
input: { fileId },
178-
},
179-
});
180-
181-
expect(res.status).toBe(200);
182-
expect(res.body.errors).toBeUndefined();
183-
184-
const payload = res.body.data.confirmUpload;
185-
expect(payload.fileId).toBe(fileId);
186-
expect(payload.status).toBe('ready');
187-
expect(payload.success).toBe(true);
188-
});
189160
});
190161

191162
describe('Private file upload', () => {
@@ -218,7 +189,6 @@ describe('Upload integration (presigned URL flow)', () => {
218189
expect(payload.key).toBe(contentHash);
219190
expect(payload.deduplicated).toBe(false);
220191
expect(payload.expiresAt).toBeTruthy();
221-
expect(payload.status).toBe('pending');
222192

223193
uploadUrl = payload.uploadUrl;
224194
fileId = payload.fileId;
@@ -228,23 +198,6 @@ describe('Upload integration (presigned URL flow)', () => {
228198
const putRes = await putToPresignedUrl(uploadUrl, fileContent, contentType);
229199
expect(putRes.ok).toBe(true);
230200
});
231-
232-
it('should confirm the upload and transition file to ready', async () => {
233-
const res = await postGraphQL({
234-
query: CONFIRM_UPLOAD,
235-
variables: {
236-
input: { fileId },
237-
},
238-
});
239-
240-
expect(res.status).toBe(200);
241-
expect(res.body.errors).toBeUndefined();
242-
243-
const payload = res.body.data.confirmUpload;
244-
expect(payload.fileId).toBe(fileId);
245-
expect(payload.status).toBe('ready');
246-
expect(payload.success).toBe(true);
247-
});
248201
});
249202

250203
describe('Deduplication', () => {
@@ -274,7 +227,6 @@ describe('Upload integration (presigned URL flow)', () => {
274227
expect(payload.uploadUrl).toBeNull();
275228
expect(payload.expiresAt).toBeNull();
276229
expect(payload.fileId).toBeTruthy();
277-
expect(payload.status).toBe('ready');
278230
});
279231
});
280232
});

0 commit comments

Comments
 (0)