@pgpmjs/migrate-client 0.3.7 → 0.4.1
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/migrate/orm/index.d.ts +15 -0
- package/esm/migrate/orm/input-types.d.ts +74 -0
- package/esm/migrate/orm/models/migrateFile.d.ts +1 -1
- package/esm/migrate/orm/models/sqlAction.d.ts +1 -1
- package/esm/migrate/orm/mutation/index.d.ts +45 -1
- package/esm/migrate/orm/mutation/index.js +36 -0
- package/esm/migrate/orm/query-builder.d.ts +4 -6
- package/esm/migrate/orm/query-builder.js +2 -12
- package/esm/migrate/orm/select-types.d.ts +2 -4
- package/migrate/orm/index.d.ts +15 -0
- package/migrate/orm/input-types.d.ts +74 -0
- package/migrate/orm/models/migrateFile.d.ts +1 -1
- package/migrate/orm/models/sqlAction.d.ts +1 -1
- package/migrate/orm/mutation/index.d.ts +45 -1
- package/migrate/orm/mutation/index.js +36 -0
- package/migrate/orm/query-builder.d.ts +4 -6
- package/migrate/orm/query-builder.js +2 -12
- package/migrate/orm/select-types.d.ts +2 -4
- package/package.json +2 -2
|
@@ -44,5 +44,20 @@ export declare function createClient(config: OrmClientConfig): {
|
|
|
44
44
|
} & import("./select-types").StrictSelect<S, import("./input-types").RunMigrationPayloadSelect>) => import("./query-builder").QueryBuilder<{
|
|
45
45
|
runMigration: import("./select-types").InferSelectResult<import("./input-types").RunMigrationPayload, S> | null;
|
|
46
46
|
}>;
|
|
47
|
+
requestUploadUrl: <S extends import("./input-types").RequestUploadUrlPayloadSelect>(args: import("./mutation").RequestUploadUrlVariables, options: {
|
|
48
|
+
select: S;
|
|
49
|
+
} & import("./select-types").StrictSelect<S, import("./input-types").RequestUploadUrlPayloadSelect>) => import("./query-builder").QueryBuilder<{
|
|
50
|
+
requestUploadUrl: import("./select-types").InferSelectResult<import("./input-types").RequestUploadUrlPayload, S> | null;
|
|
51
|
+
}>;
|
|
52
|
+
confirmUpload: <S extends import("./input-types").ConfirmUploadPayloadSelect>(args: import("./mutation").ConfirmUploadVariables, options: {
|
|
53
|
+
select: S;
|
|
54
|
+
} & import("./select-types").StrictSelect<S, import("./input-types").ConfirmUploadPayloadSelect>) => import("./query-builder").QueryBuilder<{
|
|
55
|
+
confirmUpload: import("./select-types").InferSelectResult<import("./input-types").ConfirmUploadPayload, S> | null;
|
|
56
|
+
}>;
|
|
57
|
+
provisionBucket: <S extends import("./input-types").ProvisionBucketPayloadSelect>(args: import("./mutation").ProvisionBucketVariables, options: {
|
|
58
|
+
select: S;
|
|
59
|
+
} & import("./select-types").StrictSelect<S, import("./input-types").ProvisionBucketPayloadSelect>) => import("./query-builder").QueryBuilder<{
|
|
60
|
+
provisionBucket: import("./select-types").InferSelectResult<import("./input-types").ProvisionBucketPayload, S> | null;
|
|
61
|
+
}>;
|
|
47
62
|
};
|
|
48
63
|
};
|
|
@@ -405,6 +405,26 @@ export interface RunMigrationInput {
|
|
|
405
405
|
migration?: number;
|
|
406
406
|
kind?: string;
|
|
407
407
|
}
|
|
408
|
+
export interface RequestUploadUrlInput {
|
|
409
|
+
/** Bucket key (e.g., "public", "private") */
|
|
410
|
+
bucketKey: string;
|
|
411
|
+
/** SHA-256 content hash computed by the client (hex-encoded, 64 chars) */
|
|
412
|
+
contentHash: string;
|
|
413
|
+
/** MIME type of the file (e.g., "image/png") */
|
|
414
|
+
contentType: string;
|
|
415
|
+
/** File size in bytes */
|
|
416
|
+
size: number;
|
|
417
|
+
/** Original filename (optional, for display and Content-Disposition) */
|
|
418
|
+
filename?: string;
|
|
419
|
+
}
|
|
420
|
+
export interface ConfirmUploadInput {
|
|
421
|
+
/** The file ID returned by requestUploadUrl */
|
|
422
|
+
fileId: string;
|
|
423
|
+
}
|
|
424
|
+
export interface ProvisionBucketInput {
|
|
425
|
+
/** The logical bucket key (e.g., "public", "private") */
|
|
426
|
+
bucketKey: string;
|
|
427
|
+
}
|
|
408
428
|
/** A filter to be used against ConstructiveInternalTypeUpload fields. All fields are combined with a logical ‘and.’ */
|
|
409
429
|
export interface ConstructiveInternalTypeUploadFilter {
|
|
410
430
|
/** Is null (if `true` is specified) or is not null (if `false` is specified). */
|
|
@@ -452,6 +472,60 @@ export interface RunMigrationPayload {
|
|
|
452
472
|
export type RunMigrationPayloadSelect = {
|
|
453
473
|
clientMutationId?: boolean;
|
|
454
474
|
};
|
|
475
|
+
export interface RequestUploadUrlPayload {
|
|
476
|
+
/** Presigned PUT URL (null if file was deduplicated) */
|
|
477
|
+
uploadUrl?: string | null;
|
|
478
|
+
/** The file ID (existing if deduplicated, new if fresh upload) */
|
|
479
|
+
fileId: string;
|
|
480
|
+
/** The S3 object key */
|
|
481
|
+
key: string;
|
|
482
|
+
/** Whether this file was deduplicated (already exists with same hash) */
|
|
483
|
+
deduplicated: boolean;
|
|
484
|
+
/** Presigned URL expiry time (null if deduplicated) */
|
|
485
|
+
expiresAt?: string | null;
|
|
486
|
+
}
|
|
487
|
+
export type RequestUploadUrlPayloadSelect = {
|
|
488
|
+
uploadUrl?: boolean;
|
|
489
|
+
fileId?: boolean;
|
|
490
|
+
key?: boolean;
|
|
491
|
+
deduplicated?: boolean;
|
|
492
|
+
expiresAt?: boolean;
|
|
493
|
+
};
|
|
494
|
+
export interface ConfirmUploadPayload {
|
|
495
|
+
/** The confirmed file ID */
|
|
496
|
+
fileId: string;
|
|
497
|
+
/** New file status */
|
|
498
|
+
status: string;
|
|
499
|
+
/** Whether confirmation succeeded */
|
|
500
|
+
success: boolean;
|
|
501
|
+
}
|
|
502
|
+
export type ConfirmUploadPayloadSelect = {
|
|
503
|
+
fileId?: boolean;
|
|
504
|
+
status?: boolean;
|
|
505
|
+
success?: boolean;
|
|
506
|
+
};
|
|
507
|
+
export interface ProvisionBucketPayload {
|
|
508
|
+
/** Whether provisioning succeeded */
|
|
509
|
+
success: boolean;
|
|
510
|
+
/** The S3 bucket name that was provisioned */
|
|
511
|
+
bucketName: string;
|
|
512
|
+
/** The access type applied */
|
|
513
|
+
accessType: string;
|
|
514
|
+
/** The storage provider used */
|
|
515
|
+
provider: string;
|
|
516
|
+
/** The S3 endpoint (null for AWS S3 default) */
|
|
517
|
+
endpoint?: string | null;
|
|
518
|
+
/** Error message if provisioning failed */
|
|
519
|
+
error?: string | null;
|
|
520
|
+
}
|
|
521
|
+
export type ProvisionBucketPayloadSelect = {
|
|
522
|
+
success?: boolean;
|
|
523
|
+
bucketName?: boolean;
|
|
524
|
+
accessType?: boolean;
|
|
525
|
+
provider?: boolean;
|
|
526
|
+
endpoint?: boolean;
|
|
527
|
+
error?: boolean;
|
|
528
|
+
};
|
|
455
529
|
export interface CreateMigrateFilePayload {
|
|
456
530
|
clientMutationId?: string | null;
|
|
457
531
|
/** The `MigrateFile` that was created by this mutation. */
|
|
@@ -10,7 +10,7 @@ import type { MigrateFileWithRelations, MigrateFileSelect, MigrateFileFilter, Mi
|
|
|
10
10
|
export declare class MigrateFileModel {
|
|
11
11
|
private client;
|
|
12
12
|
constructor(client: OrmClient);
|
|
13
|
-
findMany<S extends MigrateFileSelect>(args: FindManyArgs<S, MigrateFileFilter,
|
|
13
|
+
findMany<S extends MigrateFileSelect>(args: FindManyArgs<S, MigrateFileFilter, MigrateFileOrderBy> & {
|
|
14
14
|
select: S;
|
|
15
15
|
} & StrictSelect<S, MigrateFileSelect>): QueryBuilder<{
|
|
16
16
|
migrateFiles: ConnectionResult<InferSelectResult<MigrateFileWithRelations, S>>;
|
|
@@ -10,7 +10,7 @@ import type { SqlActionWithRelations, SqlActionSelect, SqlActionFilter, SqlActio
|
|
|
10
10
|
export declare class SqlActionModel {
|
|
11
11
|
private client;
|
|
12
12
|
constructor(client: OrmClient);
|
|
13
|
-
findMany<S extends SqlActionSelect>(args: FindManyArgs<S, SqlActionFilter,
|
|
13
|
+
findMany<S extends SqlActionSelect>(args: FindManyArgs<S, SqlActionFilter, SqlActionOrderBy> & {
|
|
14
14
|
select: S;
|
|
15
15
|
} & StrictSelect<S, SqlActionSelect>): QueryBuilder<{
|
|
16
16
|
sqlActions: ConnectionResult<InferSelectResult<SqlActionWithRelations, S>>;
|
|
@@ -6,13 +6,42 @@
|
|
|
6
6
|
import { OrmClient } from '../client';
|
|
7
7
|
import { QueryBuilder } from '../query-builder';
|
|
8
8
|
import type { InferSelectResult, StrictSelect } from '../select-types';
|
|
9
|
-
import type { ExecuteSqlInput, RunMigrationInput, ExecuteSqlPayload, RunMigrationPayload, ExecuteSqlPayloadSelect, RunMigrationPayloadSelect } from '../input-types';
|
|
9
|
+
import type { ExecuteSqlInput, RunMigrationInput, RequestUploadUrlInput, ConfirmUploadInput, ProvisionBucketInput, ExecuteSqlPayload, RunMigrationPayload, RequestUploadUrlPayload, ConfirmUploadPayload, ProvisionBucketPayload, ExecuteSqlPayloadSelect, RunMigrationPayloadSelect, RequestUploadUrlPayloadSelect, ConfirmUploadPayloadSelect, ProvisionBucketPayloadSelect } from '../input-types';
|
|
10
10
|
export interface ExecuteSqlVariables {
|
|
11
11
|
input: ExecuteSqlInput;
|
|
12
12
|
}
|
|
13
13
|
export interface RunMigrationVariables {
|
|
14
14
|
input: RunMigrationInput;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Variables for requestUploadUrl
|
|
18
|
+
* Request a presigned URL for uploading a file directly to S3.
|
|
19
|
+
Client computes SHA-256 of the file content and provides it here.
|
|
20
|
+
If a file with the same hash already exists (dedup), returns the
|
|
21
|
+
existing file ID and deduplicated=true with no uploadUrl.
|
|
22
|
+
*/
|
|
23
|
+
export interface RequestUploadUrlVariables {
|
|
24
|
+
input: RequestUploadUrlInput;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Variables for confirmUpload
|
|
28
|
+
* Confirm that a file has been uploaded to S3.
|
|
29
|
+
Verifies the object exists in S3, checks content-type,
|
|
30
|
+
and transitions the file status from 'pending' to 'ready'.
|
|
31
|
+
*/
|
|
32
|
+
export interface ConfirmUploadVariables {
|
|
33
|
+
input: ConfirmUploadInput;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Variables for provisionBucket
|
|
37
|
+
* Provision an S3 bucket for a logical bucket in the database.
|
|
38
|
+
Reads the bucket config via RLS, then creates and configures
|
|
39
|
+
the S3 bucket with the appropriate privacy policies, CORS rules,
|
|
40
|
+
and lifecycle settings.
|
|
41
|
+
*/
|
|
42
|
+
export interface ProvisionBucketVariables {
|
|
43
|
+
input: ProvisionBucketInput;
|
|
44
|
+
}
|
|
16
45
|
export declare function createMutationOperations(client: OrmClient): {
|
|
17
46
|
executeSql: <S extends ExecuteSqlPayloadSelect>(args: ExecuteSqlVariables, options: {
|
|
18
47
|
select: S;
|
|
@@ -24,4 +53,19 @@ export declare function createMutationOperations(client: OrmClient): {
|
|
|
24
53
|
} & StrictSelect<S, RunMigrationPayloadSelect>) => QueryBuilder<{
|
|
25
54
|
runMigration: InferSelectResult<RunMigrationPayload, S> | null;
|
|
26
55
|
}>;
|
|
56
|
+
requestUploadUrl: <S extends RequestUploadUrlPayloadSelect>(args: RequestUploadUrlVariables, options: {
|
|
57
|
+
select: S;
|
|
58
|
+
} & StrictSelect<S, RequestUploadUrlPayloadSelect>) => QueryBuilder<{
|
|
59
|
+
requestUploadUrl: InferSelectResult<RequestUploadUrlPayload, S> | null;
|
|
60
|
+
}>;
|
|
61
|
+
confirmUpload: <S extends ConfirmUploadPayloadSelect>(args: ConfirmUploadVariables, options: {
|
|
62
|
+
select: S;
|
|
63
|
+
} & StrictSelect<S, ConfirmUploadPayloadSelect>) => QueryBuilder<{
|
|
64
|
+
confirmUpload: InferSelectResult<ConfirmUploadPayload, S> | null;
|
|
65
|
+
}>;
|
|
66
|
+
provisionBucket: <S extends ProvisionBucketPayloadSelect>(args: ProvisionBucketVariables, options: {
|
|
67
|
+
select: S;
|
|
68
|
+
} & StrictSelect<S, ProvisionBucketPayloadSelect>) => QueryBuilder<{
|
|
69
|
+
provisionBucket: InferSelectResult<ProvisionBucketPayload, S> | null;
|
|
70
|
+
}>;
|
|
27
71
|
};
|
|
@@ -26,5 +26,41 @@ export function createMutationOperations(client) {
|
|
|
26
26
|
},
|
|
27
27
|
], connectionFieldsMap, 'RunMigrationPayload'),
|
|
28
28
|
}),
|
|
29
|
+
requestUploadUrl: (args, options) => new QueryBuilder({
|
|
30
|
+
client,
|
|
31
|
+
operation: 'mutation',
|
|
32
|
+
operationName: 'RequestUploadUrl',
|
|
33
|
+
fieldName: 'requestUploadUrl',
|
|
34
|
+
...buildCustomDocument('mutation', 'RequestUploadUrl', 'requestUploadUrl', options.select, args, [
|
|
35
|
+
{
|
|
36
|
+
name: 'input',
|
|
37
|
+
type: 'RequestUploadUrlInput!',
|
|
38
|
+
},
|
|
39
|
+
], connectionFieldsMap, 'RequestUploadUrlPayload'),
|
|
40
|
+
}),
|
|
41
|
+
confirmUpload: (args, options) => new QueryBuilder({
|
|
42
|
+
client,
|
|
43
|
+
operation: 'mutation',
|
|
44
|
+
operationName: 'ConfirmUpload',
|
|
45
|
+
fieldName: 'confirmUpload',
|
|
46
|
+
...buildCustomDocument('mutation', 'ConfirmUpload', 'confirmUpload', options.select, args, [
|
|
47
|
+
{
|
|
48
|
+
name: 'input',
|
|
49
|
+
type: 'ConfirmUploadInput!',
|
|
50
|
+
},
|
|
51
|
+
], connectionFieldsMap, 'ConfirmUploadPayload'),
|
|
52
|
+
}),
|
|
53
|
+
provisionBucket: (args, options) => new QueryBuilder({
|
|
54
|
+
client,
|
|
55
|
+
operation: 'mutation',
|
|
56
|
+
operationName: 'ProvisionBucket',
|
|
57
|
+
fieldName: 'provisionBucket',
|
|
58
|
+
...buildCustomDocument('mutation', 'ProvisionBucket', 'provisionBucket', options.select, args, [
|
|
59
|
+
{
|
|
60
|
+
name: 'input',
|
|
61
|
+
type: 'ProvisionBucketInput!',
|
|
62
|
+
},
|
|
63
|
+
], connectionFieldsMap, 'ProvisionBucketPayload'),
|
|
64
|
+
}),
|
|
29
65
|
};
|
|
30
66
|
}
|
|
@@ -34,23 +34,21 @@ export declare class QueryBuilder<TResult> {
|
|
|
34
34
|
getVariables(): Record<string, unknown> | undefined;
|
|
35
35
|
}
|
|
36
36
|
export declare function buildSelections(select: Record<string, unknown> | undefined, connectionFieldsMap?: Record<string, Record<string, string>>, entityType?: string): FieldNode[];
|
|
37
|
-
export declare function buildFindManyDocument<TSelect, TWhere
|
|
37
|
+
export declare function buildFindManyDocument<TSelect, TWhere>(operationName: string, queryField: string, select: TSelect, args: {
|
|
38
38
|
where?: TWhere;
|
|
39
|
-
condition?: TCondition;
|
|
40
39
|
orderBy?: string[];
|
|
41
40
|
first?: number;
|
|
42
41
|
last?: number;
|
|
43
42
|
after?: string;
|
|
44
43
|
before?: string;
|
|
45
44
|
offset?: number;
|
|
46
|
-
}, filterTypeName: string, orderByTypeName: string, connectionFieldsMap?: Record<string, Record<string, string
|
|
45
|
+
}, filterTypeName: string, orderByTypeName: string, connectionFieldsMap?: Record<string, Record<string, string>>): {
|
|
47
46
|
document: string;
|
|
48
47
|
variables: Record<string, unknown>;
|
|
49
48
|
};
|
|
50
|
-
export declare function buildFindFirstDocument<TSelect, TWhere
|
|
49
|
+
export declare function buildFindFirstDocument<TSelect, TWhere>(operationName: string, queryField: string, select: TSelect, args: {
|
|
51
50
|
where?: TWhere;
|
|
52
|
-
|
|
53
|
-
}, filterTypeName: string, connectionFieldsMap?: Record<string, Record<string, string>>, conditionTypeName?: string): {
|
|
51
|
+
}, filterTypeName: string, connectionFieldsMap?: Record<string, Record<string, string>>): {
|
|
54
52
|
document: string;
|
|
55
53
|
variables: Record<string, unknown>;
|
|
56
54
|
};
|
|
@@ -131,18 +131,13 @@ export function buildSelections(select, connectionFieldsMap, entityType) {
|
|
|
131
131
|
// ============================================================================
|
|
132
132
|
// Document Builders
|
|
133
133
|
// ============================================================================
|
|
134
|
-
export function buildFindManyDocument(operationName, queryField, select, args, filterTypeName, orderByTypeName, connectionFieldsMap
|
|
134
|
+
export function buildFindManyDocument(operationName, queryField, select, args, filterTypeName, orderByTypeName, connectionFieldsMap) {
|
|
135
135
|
const selections = select
|
|
136
136
|
? buildSelections(select, connectionFieldsMap, operationName)
|
|
137
137
|
: [t.field({ name: 'id' })];
|
|
138
138
|
const variableDefinitions = [];
|
|
139
139
|
const queryArgs = [];
|
|
140
140
|
const variables = {};
|
|
141
|
-
addVariable({
|
|
142
|
-
varName: 'condition',
|
|
143
|
-
typeName: conditionTypeName,
|
|
144
|
-
value: args.condition,
|
|
145
|
-
}, variableDefinitions, queryArgs, variables);
|
|
146
141
|
addVariable({
|
|
147
142
|
varName: 'where',
|
|
148
143
|
typeName: filterTypeName,
|
|
@@ -180,7 +175,7 @@ export function buildFindManyDocument(operationName, queryField, select, args, f
|
|
|
180
175
|
});
|
|
181
176
|
return { document: print(document), variables };
|
|
182
177
|
}
|
|
183
|
-
export function buildFindFirstDocument(operationName, queryField, select, args, filterTypeName, connectionFieldsMap
|
|
178
|
+
export function buildFindFirstDocument(operationName, queryField, select, args, filterTypeName, connectionFieldsMap) {
|
|
184
179
|
const selections = select
|
|
185
180
|
? buildSelections(select, connectionFieldsMap, operationName)
|
|
186
181
|
: [t.field({ name: 'id' })];
|
|
@@ -189,11 +184,6 @@ export function buildFindFirstDocument(operationName, queryField, select, args,
|
|
|
189
184
|
const variables = {};
|
|
190
185
|
// Always add first: 1 for findFirst
|
|
191
186
|
addVariable({ varName: 'first', typeName: 'Int', value: 1 }, variableDefinitions, queryArgs, variables);
|
|
192
|
-
addVariable({
|
|
193
|
-
varName: 'condition',
|
|
194
|
-
typeName: conditionTypeName,
|
|
195
|
-
value: args.condition,
|
|
196
|
-
}, variableDefinitions, queryArgs, variables);
|
|
197
187
|
addVariable({
|
|
198
188
|
varName: 'where',
|
|
199
189
|
typeName: filterTypeName,
|
|
@@ -14,10 +14,9 @@ export interface PageInfo {
|
|
|
14
14
|
startCursor?: string | null;
|
|
15
15
|
endCursor?: string | null;
|
|
16
16
|
}
|
|
17
|
-
export interface FindManyArgs<TSelect, TWhere,
|
|
17
|
+
export interface FindManyArgs<TSelect, TWhere, TOrderBy = never> {
|
|
18
18
|
select?: TSelect;
|
|
19
19
|
where?: TWhere;
|
|
20
|
-
condition?: TCondition;
|
|
21
20
|
orderBy?: TOrderBy[];
|
|
22
21
|
first?: number;
|
|
23
22
|
last?: number;
|
|
@@ -25,10 +24,9 @@ export interface FindManyArgs<TSelect, TWhere, TCondition = never, TOrderBy = ne
|
|
|
25
24
|
before?: string;
|
|
26
25
|
offset?: number;
|
|
27
26
|
}
|
|
28
|
-
export interface FindFirstArgs<TSelect, TWhere
|
|
27
|
+
export interface FindFirstArgs<TSelect, TWhere> {
|
|
29
28
|
select?: TSelect;
|
|
30
29
|
where?: TWhere;
|
|
31
|
-
condition?: TCondition;
|
|
32
30
|
}
|
|
33
31
|
export interface CreateArgs<TSelect, TData> {
|
|
34
32
|
data: TData;
|
package/migrate/orm/index.d.ts
CHANGED
|
@@ -44,5 +44,20 @@ export declare function createClient(config: OrmClientConfig): {
|
|
|
44
44
|
} & import("./select-types").StrictSelect<S, import("./input-types").RunMigrationPayloadSelect>) => import("./query-builder").QueryBuilder<{
|
|
45
45
|
runMigration: import("./select-types").InferSelectResult<import("./input-types").RunMigrationPayload, S> | null;
|
|
46
46
|
}>;
|
|
47
|
+
requestUploadUrl: <S extends import("./input-types").RequestUploadUrlPayloadSelect>(args: import("./mutation").RequestUploadUrlVariables, options: {
|
|
48
|
+
select: S;
|
|
49
|
+
} & import("./select-types").StrictSelect<S, import("./input-types").RequestUploadUrlPayloadSelect>) => import("./query-builder").QueryBuilder<{
|
|
50
|
+
requestUploadUrl: import("./select-types").InferSelectResult<import("./input-types").RequestUploadUrlPayload, S> | null;
|
|
51
|
+
}>;
|
|
52
|
+
confirmUpload: <S extends import("./input-types").ConfirmUploadPayloadSelect>(args: import("./mutation").ConfirmUploadVariables, options: {
|
|
53
|
+
select: S;
|
|
54
|
+
} & import("./select-types").StrictSelect<S, import("./input-types").ConfirmUploadPayloadSelect>) => import("./query-builder").QueryBuilder<{
|
|
55
|
+
confirmUpload: import("./select-types").InferSelectResult<import("./input-types").ConfirmUploadPayload, S> | null;
|
|
56
|
+
}>;
|
|
57
|
+
provisionBucket: <S extends import("./input-types").ProvisionBucketPayloadSelect>(args: import("./mutation").ProvisionBucketVariables, options: {
|
|
58
|
+
select: S;
|
|
59
|
+
} & import("./select-types").StrictSelect<S, import("./input-types").ProvisionBucketPayloadSelect>) => import("./query-builder").QueryBuilder<{
|
|
60
|
+
provisionBucket: import("./select-types").InferSelectResult<import("./input-types").ProvisionBucketPayload, S> | null;
|
|
61
|
+
}>;
|
|
47
62
|
};
|
|
48
63
|
};
|
|
@@ -405,6 +405,26 @@ export interface RunMigrationInput {
|
|
|
405
405
|
migration?: number;
|
|
406
406
|
kind?: string;
|
|
407
407
|
}
|
|
408
|
+
export interface RequestUploadUrlInput {
|
|
409
|
+
/** Bucket key (e.g., "public", "private") */
|
|
410
|
+
bucketKey: string;
|
|
411
|
+
/** SHA-256 content hash computed by the client (hex-encoded, 64 chars) */
|
|
412
|
+
contentHash: string;
|
|
413
|
+
/** MIME type of the file (e.g., "image/png") */
|
|
414
|
+
contentType: string;
|
|
415
|
+
/** File size in bytes */
|
|
416
|
+
size: number;
|
|
417
|
+
/** Original filename (optional, for display and Content-Disposition) */
|
|
418
|
+
filename?: string;
|
|
419
|
+
}
|
|
420
|
+
export interface ConfirmUploadInput {
|
|
421
|
+
/** The file ID returned by requestUploadUrl */
|
|
422
|
+
fileId: string;
|
|
423
|
+
}
|
|
424
|
+
export interface ProvisionBucketInput {
|
|
425
|
+
/** The logical bucket key (e.g., "public", "private") */
|
|
426
|
+
bucketKey: string;
|
|
427
|
+
}
|
|
408
428
|
/** A filter to be used against ConstructiveInternalTypeUpload fields. All fields are combined with a logical ‘and.’ */
|
|
409
429
|
export interface ConstructiveInternalTypeUploadFilter {
|
|
410
430
|
/** Is null (if `true` is specified) or is not null (if `false` is specified). */
|
|
@@ -452,6 +472,60 @@ export interface RunMigrationPayload {
|
|
|
452
472
|
export type RunMigrationPayloadSelect = {
|
|
453
473
|
clientMutationId?: boolean;
|
|
454
474
|
};
|
|
475
|
+
export interface RequestUploadUrlPayload {
|
|
476
|
+
/** Presigned PUT URL (null if file was deduplicated) */
|
|
477
|
+
uploadUrl?: string | null;
|
|
478
|
+
/** The file ID (existing if deduplicated, new if fresh upload) */
|
|
479
|
+
fileId: string;
|
|
480
|
+
/** The S3 object key */
|
|
481
|
+
key: string;
|
|
482
|
+
/** Whether this file was deduplicated (already exists with same hash) */
|
|
483
|
+
deduplicated: boolean;
|
|
484
|
+
/** Presigned URL expiry time (null if deduplicated) */
|
|
485
|
+
expiresAt?: string | null;
|
|
486
|
+
}
|
|
487
|
+
export type RequestUploadUrlPayloadSelect = {
|
|
488
|
+
uploadUrl?: boolean;
|
|
489
|
+
fileId?: boolean;
|
|
490
|
+
key?: boolean;
|
|
491
|
+
deduplicated?: boolean;
|
|
492
|
+
expiresAt?: boolean;
|
|
493
|
+
};
|
|
494
|
+
export interface ConfirmUploadPayload {
|
|
495
|
+
/** The confirmed file ID */
|
|
496
|
+
fileId: string;
|
|
497
|
+
/** New file status */
|
|
498
|
+
status: string;
|
|
499
|
+
/** Whether confirmation succeeded */
|
|
500
|
+
success: boolean;
|
|
501
|
+
}
|
|
502
|
+
export type ConfirmUploadPayloadSelect = {
|
|
503
|
+
fileId?: boolean;
|
|
504
|
+
status?: boolean;
|
|
505
|
+
success?: boolean;
|
|
506
|
+
};
|
|
507
|
+
export interface ProvisionBucketPayload {
|
|
508
|
+
/** Whether provisioning succeeded */
|
|
509
|
+
success: boolean;
|
|
510
|
+
/** The S3 bucket name that was provisioned */
|
|
511
|
+
bucketName: string;
|
|
512
|
+
/** The access type applied */
|
|
513
|
+
accessType: string;
|
|
514
|
+
/** The storage provider used */
|
|
515
|
+
provider: string;
|
|
516
|
+
/** The S3 endpoint (null for AWS S3 default) */
|
|
517
|
+
endpoint?: string | null;
|
|
518
|
+
/** Error message if provisioning failed */
|
|
519
|
+
error?: string | null;
|
|
520
|
+
}
|
|
521
|
+
export type ProvisionBucketPayloadSelect = {
|
|
522
|
+
success?: boolean;
|
|
523
|
+
bucketName?: boolean;
|
|
524
|
+
accessType?: boolean;
|
|
525
|
+
provider?: boolean;
|
|
526
|
+
endpoint?: boolean;
|
|
527
|
+
error?: boolean;
|
|
528
|
+
};
|
|
455
529
|
export interface CreateMigrateFilePayload {
|
|
456
530
|
clientMutationId?: string | null;
|
|
457
531
|
/** The `MigrateFile` that was created by this mutation. */
|
|
@@ -10,7 +10,7 @@ import type { MigrateFileWithRelations, MigrateFileSelect, MigrateFileFilter, Mi
|
|
|
10
10
|
export declare class MigrateFileModel {
|
|
11
11
|
private client;
|
|
12
12
|
constructor(client: OrmClient);
|
|
13
|
-
findMany<S extends MigrateFileSelect>(args: FindManyArgs<S, MigrateFileFilter,
|
|
13
|
+
findMany<S extends MigrateFileSelect>(args: FindManyArgs<S, MigrateFileFilter, MigrateFileOrderBy> & {
|
|
14
14
|
select: S;
|
|
15
15
|
} & StrictSelect<S, MigrateFileSelect>): QueryBuilder<{
|
|
16
16
|
migrateFiles: ConnectionResult<InferSelectResult<MigrateFileWithRelations, S>>;
|
|
@@ -10,7 +10,7 @@ import type { SqlActionWithRelations, SqlActionSelect, SqlActionFilter, SqlActio
|
|
|
10
10
|
export declare class SqlActionModel {
|
|
11
11
|
private client;
|
|
12
12
|
constructor(client: OrmClient);
|
|
13
|
-
findMany<S extends SqlActionSelect>(args: FindManyArgs<S, SqlActionFilter,
|
|
13
|
+
findMany<S extends SqlActionSelect>(args: FindManyArgs<S, SqlActionFilter, SqlActionOrderBy> & {
|
|
14
14
|
select: S;
|
|
15
15
|
} & StrictSelect<S, SqlActionSelect>): QueryBuilder<{
|
|
16
16
|
sqlActions: ConnectionResult<InferSelectResult<SqlActionWithRelations, S>>;
|
|
@@ -6,13 +6,42 @@
|
|
|
6
6
|
import { OrmClient } from '../client';
|
|
7
7
|
import { QueryBuilder } from '../query-builder';
|
|
8
8
|
import type { InferSelectResult, StrictSelect } from '../select-types';
|
|
9
|
-
import type { ExecuteSqlInput, RunMigrationInput, ExecuteSqlPayload, RunMigrationPayload, ExecuteSqlPayloadSelect, RunMigrationPayloadSelect } from '../input-types';
|
|
9
|
+
import type { ExecuteSqlInput, RunMigrationInput, RequestUploadUrlInput, ConfirmUploadInput, ProvisionBucketInput, ExecuteSqlPayload, RunMigrationPayload, RequestUploadUrlPayload, ConfirmUploadPayload, ProvisionBucketPayload, ExecuteSqlPayloadSelect, RunMigrationPayloadSelect, RequestUploadUrlPayloadSelect, ConfirmUploadPayloadSelect, ProvisionBucketPayloadSelect } from '../input-types';
|
|
10
10
|
export interface ExecuteSqlVariables {
|
|
11
11
|
input: ExecuteSqlInput;
|
|
12
12
|
}
|
|
13
13
|
export interface RunMigrationVariables {
|
|
14
14
|
input: RunMigrationInput;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Variables for requestUploadUrl
|
|
18
|
+
* Request a presigned URL for uploading a file directly to S3.
|
|
19
|
+
Client computes SHA-256 of the file content and provides it here.
|
|
20
|
+
If a file with the same hash already exists (dedup), returns the
|
|
21
|
+
existing file ID and deduplicated=true with no uploadUrl.
|
|
22
|
+
*/
|
|
23
|
+
export interface RequestUploadUrlVariables {
|
|
24
|
+
input: RequestUploadUrlInput;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Variables for confirmUpload
|
|
28
|
+
* Confirm that a file has been uploaded to S3.
|
|
29
|
+
Verifies the object exists in S3, checks content-type,
|
|
30
|
+
and transitions the file status from 'pending' to 'ready'.
|
|
31
|
+
*/
|
|
32
|
+
export interface ConfirmUploadVariables {
|
|
33
|
+
input: ConfirmUploadInput;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Variables for provisionBucket
|
|
37
|
+
* Provision an S3 bucket for a logical bucket in the database.
|
|
38
|
+
Reads the bucket config via RLS, then creates and configures
|
|
39
|
+
the S3 bucket with the appropriate privacy policies, CORS rules,
|
|
40
|
+
and lifecycle settings.
|
|
41
|
+
*/
|
|
42
|
+
export interface ProvisionBucketVariables {
|
|
43
|
+
input: ProvisionBucketInput;
|
|
44
|
+
}
|
|
16
45
|
export declare function createMutationOperations(client: OrmClient): {
|
|
17
46
|
executeSql: <S extends ExecuteSqlPayloadSelect>(args: ExecuteSqlVariables, options: {
|
|
18
47
|
select: S;
|
|
@@ -24,4 +53,19 @@ export declare function createMutationOperations(client: OrmClient): {
|
|
|
24
53
|
} & StrictSelect<S, RunMigrationPayloadSelect>) => QueryBuilder<{
|
|
25
54
|
runMigration: InferSelectResult<RunMigrationPayload, S> | null;
|
|
26
55
|
}>;
|
|
56
|
+
requestUploadUrl: <S extends RequestUploadUrlPayloadSelect>(args: RequestUploadUrlVariables, options: {
|
|
57
|
+
select: S;
|
|
58
|
+
} & StrictSelect<S, RequestUploadUrlPayloadSelect>) => QueryBuilder<{
|
|
59
|
+
requestUploadUrl: InferSelectResult<RequestUploadUrlPayload, S> | null;
|
|
60
|
+
}>;
|
|
61
|
+
confirmUpload: <S extends ConfirmUploadPayloadSelect>(args: ConfirmUploadVariables, options: {
|
|
62
|
+
select: S;
|
|
63
|
+
} & StrictSelect<S, ConfirmUploadPayloadSelect>) => QueryBuilder<{
|
|
64
|
+
confirmUpload: InferSelectResult<ConfirmUploadPayload, S> | null;
|
|
65
|
+
}>;
|
|
66
|
+
provisionBucket: <S extends ProvisionBucketPayloadSelect>(args: ProvisionBucketVariables, options: {
|
|
67
|
+
select: S;
|
|
68
|
+
} & StrictSelect<S, ProvisionBucketPayloadSelect>) => QueryBuilder<{
|
|
69
|
+
provisionBucket: InferSelectResult<ProvisionBucketPayload, S> | null;
|
|
70
|
+
}>;
|
|
27
71
|
};
|
|
@@ -29,5 +29,41 @@ function createMutationOperations(client) {
|
|
|
29
29
|
},
|
|
30
30
|
], input_types_1.connectionFieldsMap, 'RunMigrationPayload'),
|
|
31
31
|
}),
|
|
32
|
+
requestUploadUrl: (args, options) => new query_builder_1.QueryBuilder({
|
|
33
|
+
client,
|
|
34
|
+
operation: 'mutation',
|
|
35
|
+
operationName: 'RequestUploadUrl',
|
|
36
|
+
fieldName: 'requestUploadUrl',
|
|
37
|
+
...(0, query_builder_1.buildCustomDocument)('mutation', 'RequestUploadUrl', 'requestUploadUrl', options.select, args, [
|
|
38
|
+
{
|
|
39
|
+
name: 'input',
|
|
40
|
+
type: 'RequestUploadUrlInput!',
|
|
41
|
+
},
|
|
42
|
+
], input_types_1.connectionFieldsMap, 'RequestUploadUrlPayload'),
|
|
43
|
+
}),
|
|
44
|
+
confirmUpload: (args, options) => new query_builder_1.QueryBuilder({
|
|
45
|
+
client,
|
|
46
|
+
operation: 'mutation',
|
|
47
|
+
operationName: 'ConfirmUpload',
|
|
48
|
+
fieldName: 'confirmUpload',
|
|
49
|
+
...(0, query_builder_1.buildCustomDocument)('mutation', 'ConfirmUpload', 'confirmUpload', options.select, args, [
|
|
50
|
+
{
|
|
51
|
+
name: 'input',
|
|
52
|
+
type: 'ConfirmUploadInput!',
|
|
53
|
+
},
|
|
54
|
+
], input_types_1.connectionFieldsMap, 'ConfirmUploadPayload'),
|
|
55
|
+
}),
|
|
56
|
+
provisionBucket: (args, options) => new query_builder_1.QueryBuilder({
|
|
57
|
+
client,
|
|
58
|
+
operation: 'mutation',
|
|
59
|
+
operationName: 'ProvisionBucket',
|
|
60
|
+
fieldName: 'provisionBucket',
|
|
61
|
+
...(0, query_builder_1.buildCustomDocument)('mutation', 'ProvisionBucket', 'provisionBucket', options.select, args, [
|
|
62
|
+
{
|
|
63
|
+
name: 'input',
|
|
64
|
+
type: 'ProvisionBucketInput!',
|
|
65
|
+
},
|
|
66
|
+
], input_types_1.connectionFieldsMap, 'ProvisionBucketPayload'),
|
|
67
|
+
}),
|
|
32
68
|
};
|
|
33
69
|
}
|
|
@@ -34,23 +34,21 @@ export declare class QueryBuilder<TResult> {
|
|
|
34
34
|
getVariables(): Record<string, unknown> | undefined;
|
|
35
35
|
}
|
|
36
36
|
export declare function buildSelections(select: Record<string, unknown> | undefined, connectionFieldsMap?: Record<string, Record<string, string>>, entityType?: string): FieldNode[];
|
|
37
|
-
export declare function buildFindManyDocument<TSelect, TWhere
|
|
37
|
+
export declare function buildFindManyDocument<TSelect, TWhere>(operationName: string, queryField: string, select: TSelect, args: {
|
|
38
38
|
where?: TWhere;
|
|
39
|
-
condition?: TCondition;
|
|
40
39
|
orderBy?: string[];
|
|
41
40
|
first?: number;
|
|
42
41
|
last?: number;
|
|
43
42
|
after?: string;
|
|
44
43
|
before?: string;
|
|
45
44
|
offset?: number;
|
|
46
|
-
}, filterTypeName: string, orderByTypeName: string, connectionFieldsMap?: Record<string, Record<string, string
|
|
45
|
+
}, filterTypeName: string, orderByTypeName: string, connectionFieldsMap?: Record<string, Record<string, string>>): {
|
|
47
46
|
document: string;
|
|
48
47
|
variables: Record<string, unknown>;
|
|
49
48
|
};
|
|
50
|
-
export declare function buildFindFirstDocument<TSelect, TWhere
|
|
49
|
+
export declare function buildFindFirstDocument<TSelect, TWhere>(operationName: string, queryField: string, select: TSelect, args: {
|
|
51
50
|
where?: TWhere;
|
|
52
|
-
|
|
53
|
-
}, filterTypeName: string, connectionFieldsMap?: Record<string, Record<string, string>>, conditionTypeName?: string): {
|
|
51
|
+
}, filterTypeName: string, connectionFieldsMap?: Record<string, Record<string, string>>): {
|
|
54
52
|
document: string;
|
|
55
53
|
variables: Record<string, unknown>;
|
|
56
54
|
};
|
|
@@ -179,18 +179,13 @@ function buildSelections(select, connectionFieldsMap, entityType) {
|
|
|
179
179
|
// ============================================================================
|
|
180
180
|
// Document Builders
|
|
181
181
|
// ============================================================================
|
|
182
|
-
function buildFindManyDocument(operationName, queryField, select, args, filterTypeName, orderByTypeName, connectionFieldsMap
|
|
182
|
+
function buildFindManyDocument(operationName, queryField, select, args, filterTypeName, orderByTypeName, connectionFieldsMap) {
|
|
183
183
|
const selections = select
|
|
184
184
|
? buildSelections(select, connectionFieldsMap, operationName)
|
|
185
185
|
: [t.field({ name: 'id' })];
|
|
186
186
|
const variableDefinitions = [];
|
|
187
187
|
const queryArgs = [];
|
|
188
188
|
const variables = {};
|
|
189
|
-
addVariable({
|
|
190
|
-
varName: 'condition',
|
|
191
|
-
typeName: conditionTypeName,
|
|
192
|
-
value: args.condition,
|
|
193
|
-
}, variableDefinitions, queryArgs, variables);
|
|
194
189
|
addVariable({
|
|
195
190
|
varName: 'where',
|
|
196
191
|
typeName: filterTypeName,
|
|
@@ -228,7 +223,7 @@ function buildFindManyDocument(operationName, queryField, select, args, filterTy
|
|
|
228
223
|
});
|
|
229
224
|
return { document: (0, graphql_web_1.print)(document), variables };
|
|
230
225
|
}
|
|
231
|
-
function buildFindFirstDocument(operationName, queryField, select, args, filterTypeName, connectionFieldsMap
|
|
226
|
+
function buildFindFirstDocument(operationName, queryField, select, args, filterTypeName, connectionFieldsMap) {
|
|
232
227
|
const selections = select
|
|
233
228
|
? buildSelections(select, connectionFieldsMap, operationName)
|
|
234
229
|
: [t.field({ name: 'id' })];
|
|
@@ -237,11 +232,6 @@ function buildFindFirstDocument(operationName, queryField, select, args, filterT
|
|
|
237
232
|
const variables = {};
|
|
238
233
|
// Always add first: 1 for findFirst
|
|
239
234
|
addVariable({ varName: 'first', typeName: 'Int', value: 1 }, variableDefinitions, queryArgs, variables);
|
|
240
|
-
addVariable({
|
|
241
|
-
varName: 'condition',
|
|
242
|
-
typeName: conditionTypeName,
|
|
243
|
-
value: args.condition,
|
|
244
|
-
}, variableDefinitions, queryArgs, variables);
|
|
245
235
|
addVariable({
|
|
246
236
|
varName: 'where',
|
|
247
237
|
typeName: filterTypeName,
|
|
@@ -14,10 +14,9 @@ export interface PageInfo {
|
|
|
14
14
|
startCursor?: string | null;
|
|
15
15
|
endCursor?: string | null;
|
|
16
16
|
}
|
|
17
|
-
export interface FindManyArgs<TSelect, TWhere,
|
|
17
|
+
export interface FindManyArgs<TSelect, TWhere, TOrderBy = never> {
|
|
18
18
|
select?: TSelect;
|
|
19
19
|
where?: TWhere;
|
|
20
|
-
condition?: TCondition;
|
|
21
20
|
orderBy?: TOrderBy[];
|
|
22
21
|
first?: number;
|
|
23
22
|
last?: number;
|
|
@@ -25,10 +24,9 @@ export interface FindManyArgs<TSelect, TWhere, TCondition = never, TOrderBy = ne
|
|
|
25
24
|
before?: string;
|
|
26
25
|
offset?: number;
|
|
27
26
|
}
|
|
28
|
-
export interface FindFirstArgs<TSelect, TWhere
|
|
27
|
+
export interface FindFirstArgs<TSelect, TWhere> {
|
|
29
28
|
select?: TSelect;
|
|
30
29
|
where?: TWhere;
|
|
31
|
-
condition?: TCondition;
|
|
32
30
|
}
|
|
33
31
|
export interface CreateArgs<TSelect, TData> {
|
|
34
32
|
data: TData;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgpmjs/migrate-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "Typed GraphQL ORM client for the Constructive Migrate API (db_migrate schema)",
|
|
6
6
|
"main": "index.js",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"makage": "^0.3.0",
|
|
50
50
|
"typescript": "^5.9.3"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "79cd3e66871804a22c672c7ca2fa5e2105d4b368"
|
|
53
53
|
}
|