@pgpmjs/migrate-client 0.12.5 → 0.12.6
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/models/migrateFile.d.ts +2 -4
- package/esm/migrate/orm/models/migrateFile.js +6 -2
- package/esm/migrate/orm/models/sqlAction.d.ts +2 -4
- package/esm/migrate/orm/models/sqlAction.js +6 -2
- package/esm/migrate/orm/query-builder.d.ts +18 -1
- package/esm/migrate/orm/query-builder.js +108 -1
- package/esm/migrate/orm/select-types.d.ts +25 -1
- package/migrate/orm/models/migrateFile.d.ts +2 -4
- package/migrate/orm/models/migrateFile.js +6 -2
- package/migrate/orm/models/sqlAction.d.ts +2 -4
- package/migrate/orm/models/sqlAction.js +6 -2
- package/migrate/orm/query-builder.d.ts +18 -1
- package/migrate/orm/query-builder.js +112 -1
- package/migrate/orm/select-types.d.ts +25 -1
- package/package.json +3 -3
|
@@ -15,12 +15,10 @@ export declare class MigrateFileModel {
|
|
|
15
15
|
} & StrictSelect<S, MigrateFileSelect>): QueryBuilder<{
|
|
16
16
|
migrateFiles: ConnectionResult<InferSelectResult<MigrateFileWithRelations, S>>;
|
|
17
17
|
}>;
|
|
18
|
-
findFirst<S extends MigrateFileSelect>(args: FindFirstArgs<S, MigrateFileFilter> & {
|
|
18
|
+
findFirst<S extends MigrateFileSelect>(args: FindFirstArgs<S, MigrateFileFilter, MigrateFileOrderBy> & {
|
|
19
19
|
select: S;
|
|
20
20
|
} & StrictSelect<S, MigrateFileSelect>): QueryBuilder<{
|
|
21
|
-
|
|
22
|
-
nodes: InferSelectResult<MigrateFileWithRelations, S>[];
|
|
23
|
-
};
|
|
21
|
+
migrateFile: InferSelectResult<MigrateFileWithRelations, S> | null;
|
|
24
22
|
}>;
|
|
25
23
|
findOne<S extends MigrateFileSelect>(args: {
|
|
26
24
|
id: string;
|
|
@@ -27,14 +27,18 @@ export class MigrateFileModel {
|
|
|
27
27
|
findFirst(args) {
|
|
28
28
|
const { document, variables } = buildFindFirstDocument('MigrateFile', 'migrateFiles', args.select, {
|
|
29
29
|
where: args?.where,
|
|
30
|
-
|
|
30
|
+
orderBy: args?.orderBy,
|
|
31
|
+
}, 'MigrateFileFilter', 'MigrateFileOrderBy', connectionFieldsMap);
|
|
31
32
|
return new QueryBuilder({
|
|
32
33
|
client: this.client,
|
|
33
34
|
operation: 'query',
|
|
34
35
|
operationName: 'MigrateFile',
|
|
35
|
-
fieldName: '
|
|
36
|
+
fieldName: 'migrateFile',
|
|
36
37
|
document,
|
|
37
38
|
variables,
|
|
39
|
+
transform: (data) => ({
|
|
40
|
+
migrateFile: data.migrateFiles?.nodes?.[0] ?? null,
|
|
41
|
+
}),
|
|
38
42
|
});
|
|
39
43
|
}
|
|
40
44
|
findOne(args) {
|
|
@@ -15,12 +15,10 @@ export declare class SqlActionModel {
|
|
|
15
15
|
} & StrictSelect<S, SqlActionSelect>): QueryBuilder<{
|
|
16
16
|
sqlActions: ConnectionResult<InferSelectResult<SqlActionWithRelations, S>>;
|
|
17
17
|
}>;
|
|
18
|
-
findFirst<S extends SqlActionSelect>(args: FindFirstArgs<S, SqlActionFilter> & {
|
|
18
|
+
findFirst<S extends SqlActionSelect>(args: FindFirstArgs<S, SqlActionFilter, SqlActionOrderBy> & {
|
|
19
19
|
select: S;
|
|
20
20
|
} & StrictSelect<S, SqlActionSelect>): QueryBuilder<{
|
|
21
|
-
|
|
22
|
-
nodes: InferSelectResult<SqlActionWithRelations, S>[];
|
|
23
|
-
};
|
|
21
|
+
sqlAction: InferSelectResult<SqlActionWithRelations, S> | null;
|
|
24
22
|
}>;
|
|
25
23
|
findOne<S extends SqlActionSelect>(args: {
|
|
26
24
|
id: number;
|
|
@@ -27,14 +27,18 @@ export class SqlActionModel {
|
|
|
27
27
|
findFirst(args) {
|
|
28
28
|
const { document, variables } = buildFindFirstDocument('SqlAction', 'sqlActions', args.select, {
|
|
29
29
|
where: args?.where,
|
|
30
|
-
|
|
30
|
+
orderBy: args?.orderBy,
|
|
31
|
+
}, 'SqlActionFilter', 'SqlActionOrderBy', connectionFieldsMap);
|
|
31
32
|
return new QueryBuilder({
|
|
32
33
|
client: this.client,
|
|
33
34
|
operation: 'query',
|
|
34
35
|
operationName: 'SqlAction',
|
|
35
|
-
fieldName: '
|
|
36
|
+
fieldName: 'sqlAction',
|
|
36
37
|
document,
|
|
37
38
|
variables,
|
|
39
|
+
transform: (data) => ({
|
|
40
|
+
sqlAction: data.sqlActions?.nodes?.[0] ?? null,
|
|
41
|
+
}),
|
|
38
42
|
});
|
|
39
43
|
}
|
|
40
44
|
findOne(args) {
|
|
@@ -48,7 +48,8 @@ export declare function buildFindManyDocument<TSelect, TWhere>(operationName: st
|
|
|
48
48
|
};
|
|
49
49
|
export declare function buildFindFirstDocument<TSelect, TWhere>(operationName: string, queryField: string, select: TSelect, args: {
|
|
50
50
|
where?: TWhere;
|
|
51
|
-
|
|
51
|
+
orderBy?: string[];
|
|
52
|
+
}, filterTypeName: string, orderByTypeName: string, connectionFieldsMap?: Record<string, Record<string, string>>): {
|
|
52
53
|
document: string;
|
|
53
54
|
variables: Record<string, unknown>;
|
|
54
55
|
};
|
|
@@ -91,3 +92,19 @@ export declare function buildCustomDocument<TSelect, TArgs>(operationType: 'quer
|
|
|
91
92
|
document: string;
|
|
92
93
|
variables: Record<string, unknown>;
|
|
93
94
|
};
|
|
95
|
+
export declare function buildBulkInsertDocument<TSelect, TData>(operationName: string, mutationField: string, select: TSelect, data: TData[], inputTypeName: string, onConflict?: unknown, connectionFieldsMap?: Record<string, Record<string, string>>): {
|
|
96
|
+
document: string;
|
|
97
|
+
variables: Record<string, unknown>;
|
|
98
|
+
};
|
|
99
|
+
export declare function buildBulkUpsertDocument<TSelect, TData>(operationName: string, mutationField: string, select: TSelect, data: TData[], inputTypeName: string, onConflict: unknown, connectionFieldsMap?: Record<string, Record<string, string>>): {
|
|
100
|
+
document: string;
|
|
101
|
+
variables: Record<string, unknown>;
|
|
102
|
+
};
|
|
103
|
+
export declare function buildBulkUpdateDocument<TSelect, TWhere, TData>(operationName: string, mutationField: string, select: TSelect, where: TWhere, data: TData, inputTypeName: string, connectionFieldsMap?: Record<string, Record<string, string>>): {
|
|
104
|
+
document: string;
|
|
105
|
+
variables: Record<string, unknown>;
|
|
106
|
+
};
|
|
107
|
+
export declare function buildBulkDeleteDocument<TSelect, TWhere>(operationName: string, mutationField: string, select: TSelect, where: TWhere, inputTypeName: string, connectionFieldsMap?: Record<string, Record<string, string>>): {
|
|
108
|
+
document: string;
|
|
109
|
+
variables: Record<string, unknown>;
|
|
110
|
+
};
|
|
@@ -199,7 +199,7 @@ export function buildFindManyDocument(operationName, queryField, select, args, f
|
|
|
199
199
|
});
|
|
200
200
|
return { document: print(document), variables };
|
|
201
201
|
}
|
|
202
|
-
export function buildFindFirstDocument(operationName, queryField, select, args, filterTypeName, connectionFieldsMap) {
|
|
202
|
+
export function buildFindFirstDocument(operationName, queryField, select, args, filterTypeName, orderByTypeName, connectionFieldsMap) {
|
|
203
203
|
const selections = select
|
|
204
204
|
? buildSelections(select, connectionFieldsMap, operationName)
|
|
205
205
|
: [t.field({ name: 'id' })];
|
|
@@ -213,6 +213,11 @@ export function buildFindFirstDocument(operationName, queryField, select, args,
|
|
|
213
213
|
typeName: filterTypeName,
|
|
214
214
|
value: args.where,
|
|
215
215
|
}, variableDefinitions, queryArgs, variables);
|
|
216
|
+
addVariable({
|
|
217
|
+
varName: 'orderBy',
|
|
218
|
+
typeName: '[' + orderByTypeName + '!]',
|
|
219
|
+
value: args.orderBy?.length ? args.orderBy : undefined,
|
|
220
|
+
}, variableDefinitions, queryArgs, variables);
|
|
216
221
|
const document = t.document({
|
|
217
222
|
definitions: [
|
|
218
223
|
t.operationDefinition({
|
|
@@ -595,3 +600,105 @@ function buildValueAst(value) {
|
|
|
595
600
|
}
|
|
596
601
|
throw new Error('Unsupported value type: ' + typeof value);
|
|
597
602
|
}
|
|
603
|
+
// ============================================================================
|
|
604
|
+
// Bulk Mutation Document Builders
|
|
605
|
+
// ============================================================================
|
|
606
|
+
export function buildBulkInsertDocument(operationName, mutationField, select, data, inputTypeName, onConflict, connectionFieldsMap) {
|
|
607
|
+
const selections = select
|
|
608
|
+
? buildSelections(select, connectionFieldsMap, operationName)
|
|
609
|
+
: [t.field({ name: 'id' })];
|
|
610
|
+
return {
|
|
611
|
+
document: buildInputMutationDocument({
|
|
612
|
+
operationName,
|
|
613
|
+
mutationField,
|
|
614
|
+
inputTypeName,
|
|
615
|
+
resultSelections: [
|
|
616
|
+
t.field({ name: 'affectedCount' }),
|
|
617
|
+
t.field({
|
|
618
|
+
name: 'returning',
|
|
619
|
+
selectionSet: t.selectionSet({ selections }),
|
|
620
|
+
}),
|
|
621
|
+
],
|
|
622
|
+
}),
|
|
623
|
+
variables: {
|
|
624
|
+
input: {
|
|
625
|
+
values: data,
|
|
626
|
+
...(onConflict ? { onConflict } : {}),
|
|
627
|
+
},
|
|
628
|
+
},
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
export function buildBulkUpsertDocument(operationName, mutationField, select, data, inputTypeName, onConflict, connectionFieldsMap) {
|
|
632
|
+
const selections = select
|
|
633
|
+
? buildSelections(select, connectionFieldsMap, operationName)
|
|
634
|
+
: [t.field({ name: 'id' })];
|
|
635
|
+
return {
|
|
636
|
+
document: buildInputMutationDocument({
|
|
637
|
+
operationName,
|
|
638
|
+
mutationField,
|
|
639
|
+
inputTypeName,
|
|
640
|
+
resultSelections: [
|
|
641
|
+
t.field({ name: 'affectedCount' }),
|
|
642
|
+
t.field({
|
|
643
|
+
name: 'returning',
|
|
644
|
+
selectionSet: t.selectionSet({ selections }),
|
|
645
|
+
}),
|
|
646
|
+
],
|
|
647
|
+
}),
|
|
648
|
+
variables: {
|
|
649
|
+
input: {
|
|
650
|
+
values: data,
|
|
651
|
+
onConflict,
|
|
652
|
+
},
|
|
653
|
+
},
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
export function buildBulkUpdateDocument(operationName, mutationField, select, where, data, inputTypeName, connectionFieldsMap) {
|
|
657
|
+
const selections = select
|
|
658
|
+
? buildSelections(select, connectionFieldsMap, operationName)
|
|
659
|
+
: [t.field({ name: 'id' })];
|
|
660
|
+
return {
|
|
661
|
+
document: buildInputMutationDocument({
|
|
662
|
+
operationName,
|
|
663
|
+
mutationField,
|
|
664
|
+
inputTypeName,
|
|
665
|
+
resultSelections: [
|
|
666
|
+
t.field({ name: 'affectedCount' }),
|
|
667
|
+
t.field({
|
|
668
|
+
name: 'returning',
|
|
669
|
+
selectionSet: t.selectionSet({ selections }),
|
|
670
|
+
}),
|
|
671
|
+
],
|
|
672
|
+
}),
|
|
673
|
+
variables: {
|
|
674
|
+
input: {
|
|
675
|
+
where,
|
|
676
|
+
patch: data,
|
|
677
|
+
},
|
|
678
|
+
},
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
export function buildBulkDeleteDocument(operationName, mutationField, select, where, inputTypeName, connectionFieldsMap) {
|
|
682
|
+
const selections = select
|
|
683
|
+
? buildSelections(select, connectionFieldsMap, operationName)
|
|
684
|
+
: [t.field({ name: 'id' })];
|
|
685
|
+
return {
|
|
686
|
+
document: buildInputMutationDocument({
|
|
687
|
+
operationName,
|
|
688
|
+
mutationField,
|
|
689
|
+
inputTypeName,
|
|
690
|
+
resultSelections: [
|
|
691
|
+
t.field({ name: 'affectedCount' }),
|
|
692
|
+
t.field({
|
|
693
|
+
name: 'returning',
|
|
694
|
+
selectionSet: t.selectionSet({ selections }),
|
|
695
|
+
}),
|
|
696
|
+
],
|
|
697
|
+
}),
|
|
698
|
+
variables: {
|
|
699
|
+
input: {
|
|
700
|
+
where,
|
|
701
|
+
},
|
|
702
|
+
},
|
|
703
|
+
};
|
|
704
|
+
}
|
|
@@ -24,9 +24,10 @@ export interface FindManyArgs<TSelect, TWhere, TOrderBy = never> {
|
|
|
24
24
|
before?: string;
|
|
25
25
|
offset?: number;
|
|
26
26
|
}
|
|
27
|
-
export interface FindFirstArgs<TSelect, TWhere> {
|
|
27
|
+
export interface FindFirstArgs<TSelect, TWhere, TOrderBy> {
|
|
28
28
|
select?: TSelect;
|
|
29
29
|
where?: TWhere;
|
|
30
|
+
orderBy?: TOrderBy[];
|
|
30
31
|
}
|
|
31
32
|
export interface CreateArgs<TSelect, TData> {
|
|
32
33
|
data: TData;
|
|
@@ -44,6 +45,29 @@ export interface DeleteArgs<TWhere, TSelect = undefined> {
|
|
|
44
45
|
where: TWhere;
|
|
45
46
|
select?: TSelect;
|
|
46
47
|
}
|
|
48
|
+
export interface BulkInsertArgs<TSelect, TData, TOnConflict = unknown> {
|
|
49
|
+
data: TData[];
|
|
50
|
+
select?: TSelect;
|
|
51
|
+
onConflict?: TOnConflict;
|
|
52
|
+
}
|
|
53
|
+
export interface BulkUpsertArgs<TSelect, TData, TOnConflict = unknown> {
|
|
54
|
+
data: TData[];
|
|
55
|
+
select?: TSelect;
|
|
56
|
+
onConflict: TOnConflict;
|
|
57
|
+
}
|
|
58
|
+
export interface BulkUpdateArgs<TSelect, TWhere, TData> {
|
|
59
|
+
where: TWhere;
|
|
60
|
+
data: TData;
|
|
61
|
+
select?: TSelect;
|
|
62
|
+
}
|
|
63
|
+
export interface BulkDeleteArgs<TSelect, TWhere> {
|
|
64
|
+
where: TWhere;
|
|
65
|
+
select?: TSelect;
|
|
66
|
+
}
|
|
67
|
+
export interface BulkMutationResult<T> {
|
|
68
|
+
affectedCount: number;
|
|
69
|
+
returning: T[];
|
|
70
|
+
}
|
|
47
71
|
type DepthLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
|
48
72
|
type DecrementDepth = {
|
|
49
73
|
0: 0;
|
|
@@ -15,12 +15,10 @@ export declare class MigrateFileModel {
|
|
|
15
15
|
} & StrictSelect<S, MigrateFileSelect>): QueryBuilder<{
|
|
16
16
|
migrateFiles: ConnectionResult<InferSelectResult<MigrateFileWithRelations, S>>;
|
|
17
17
|
}>;
|
|
18
|
-
findFirst<S extends MigrateFileSelect>(args: FindFirstArgs<S, MigrateFileFilter> & {
|
|
18
|
+
findFirst<S extends MigrateFileSelect>(args: FindFirstArgs<S, MigrateFileFilter, MigrateFileOrderBy> & {
|
|
19
19
|
select: S;
|
|
20
20
|
} & StrictSelect<S, MigrateFileSelect>): QueryBuilder<{
|
|
21
|
-
|
|
22
|
-
nodes: InferSelectResult<MigrateFileWithRelations, S>[];
|
|
23
|
-
};
|
|
21
|
+
migrateFile: InferSelectResult<MigrateFileWithRelations, S> | null;
|
|
24
22
|
}>;
|
|
25
23
|
findOne<S extends MigrateFileSelect>(args: {
|
|
26
24
|
id: string;
|
|
@@ -30,14 +30,18 @@ class MigrateFileModel {
|
|
|
30
30
|
findFirst(args) {
|
|
31
31
|
const { document, variables } = (0, query_builder_1.buildFindFirstDocument)('MigrateFile', 'migrateFiles', args.select, {
|
|
32
32
|
where: args?.where,
|
|
33
|
-
|
|
33
|
+
orderBy: args?.orderBy,
|
|
34
|
+
}, 'MigrateFileFilter', 'MigrateFileOrderBy', input_types_1.connectionFieldsMap);
|
|
34
35
|
return new query_builder_1.QueryBuilder({
|
|
35
36
|
client: this.client,
|
|
36
37
|
operation: 'query',
|
|
37
38
|
operationName: 'MigrateFile',
|
|
38
|
-
fieldName: '
|
|
39
|
+
fieldName: 'migrateFile',
|
|
39
40
|
document,
|
|
40
41
|
variables,
|
|
42
|
+
transform: (data) => ({
|
|
43
|
+
migrateFile: data.migrateFiles?.nodes?.[0] ?? null,
|
|
44
|
+
}),
|
|
41
45
|
});
|
|
42
46
|
}
|
|
43
47
|
findOne(args) {
|
|
@@ -15,12 +15,10 @@ export declare class SqlActionModel {
|
|
|
15
15
|
} & StrictSelect<S, SqlActionSelect>): QueryBuilder<{
|
|
16
16
|
sqlActions: ConnectionResult<InferSelectResult<SqlActionWithRelations, S>>;
|
|
17
17
|
}>;
|
|
18
|
-
findFirst<S extends SqlActionSelect>(args: FindFirstArgs<S, SqlActionFilter> & {
|
|
18
|
+
findFirst<S extends SqlActionSelect>(args: FindFirstArgs<S, SqlActionFilter, SqlActionOrderBy> & {
|
|
19
19
|
select: S;
|
|
20
20
|
} & StrictSelect<S, SqlActionSelect>): QueryBuilder<{
|
|
21
|
-
|
|
22
|
-
nodes: InferSelectResult<SqlActionWithRelations, S>[];
|
|
23
|
-
};
|
|
21
|
+
sqlAction: InferSelectResult<SqlActionWithRelations, S> | null;
|
|
24
22
|
}>;
|
|
25
23
|
findOne<S extends SqlActionSelect>(args: {
|
|
26
24
|
id: number;
|
|
@@ -30,14 +30,18 @@ class SqlActionModel {
|
|
|
30
30
|
findFirst(args) {
|
|
31
31
|
const { document, variables } = (0, query_builder_1.buildFindFirstDocument)('SqlAction', 'sqlActions', args.select, {
|
|
32
32
|
where: args?.where,
|
|
33
|
-
|
|
33
|
+
orderBy: args?.orderBy,
|
|
34
|
+
}, 'SqlActionFilter', 'SqlActionOrderBy', input_types_1.connectionFieldsMap);
|
|
34
35
|
return new query_builder_1.QueryBuilder({
|
|
35
36
|
client: this.client,
|
|
36
37
|
operation: 'query',
|
|
37
38
|
operationName: 'SqlAction',
|
|
38
|
-
fieldName: '
|
|
39
|
+
fieldName: 'sqlAction',
|
|
39
40
|
document,
|
|
40
41
|
variables,
|
|
42
|
+
transform: (data) => ({
|
|
43
|
+
sqlAction: data.sqlActions?.nodes?.[0] ?? null,
|
|
44
|
+
}),
|
|
41
45
|
});
|
|
42
46
|
}
|
|
43
47
|
findOne(args) {
|
|
@@ -48,7 +48,8 @@ export declare function buildFindManyDocument<TSelect, TWhere>(operationName: st
|
|
|
48
48
|
};
|
|
49
49
|
export declare function buildFindFirstDocument<TSelect, TWhere>(operationName: string, queryField: string, select: TSelect, args: {
|
|
50
50
|
where?: TWhere;
|
|
51
|
-
|
|
51
|
+
orderBy?: string[];
|
|
52
|
+
}, filterTypeName: string, orderByTypeName: string, connectionFieldsMap?: Record<string, Record<string, string>>): {
|
|
52
53
|
document: string;
|
|
53
54
|
variables: Record<string, unknown>;
|
|
54
55
|
};
|
|
@@ -91,3 +92,19 @@ export declare function buildCustomDocument<TSelect, TArgs>(operationType: 'quer
|
|
|
91
92
|
document: string;
|
|
92
93
|
variables: Record<string, unknown>;
|
|
93
94
|
};
|
|
95
|
+
export declare function buildBulkInsertDocument<TSelect, TData>(operationName: string, mutationField: string, select: TSelect, data: TData[], inputTypeName: string, onConflict?: unknown, connectionFieldsMap?: Record<string, Record<string, string>>): {
|
|
96
|
+
document: string;
|
|
97
|
+
variables: Record<string, unknown>;
|
|
98
|
+
};
|
|
99
|
+
export declare function buildBulkUpsertDocument<TSelect, TData>(operationName: string, mutationField: string, select: TSelect, data: TData[], inputTypeName: string, onConflict: unknown, connectionFieldsMap?: Record<string, Record<string, string>>): {
|
|
100
|
+
document: string;
|
|
101
|
+
variables: Record<string, unknown>;
|
|
102
|
+
};
|
|
103
|
+
export declare function buildBulkUpdateDocument<TSelect, TWhere, TData>(operationName: string, mutationField: string, select: TSelect, where: TWhere, data: TData, inputTypeName: string, connectionFieldsMap?: Record<string, Record<string, string>>): {
|
|
104
|
+
document: string;
|
|
105
|
+
variables: Record<string, unknown>;
|
|
106
|
+
};
|
|
107
|
+
export declare function buildBulkDeleteDocument<TSelect, TWhere>(operationName: string, mutationField: string, select: TSelect, where: TWhere, inputTypeName: string, connectionFieldsMap?: Record<string, Record<string, string>>): {
|
|
108
|
+
document: string;
|
|
109
|
+
variables: Record<string, unknown>;
|
|
110
|
+
};
|
|
@@ -45,6 +45,10 @@ exports.buildDeleteDocument = buildDeleteDocument;
|
|
|
45
45
|
exports.buildDeleteByPkDocument = buildDeleteByPkDocument;
|
|
46
46
|
exports.buildJunctionRemoveDocument = buildJunctionRemoveDocument;
|
|
47
47
|
exports.buildCustomDocument = buildCustomDocument;
|
|
48
|
+
exports.buildBulkInsertDocument = buildBulkInsertDocument;
|
|
49
|
+
exports.buildBulkUpsertDocument = buildBulkUpsertDocument;
|
|
50
|
+
exports.buildBulkUpdateDocument = buildBulkUpdateDocument;
|
|
51
|
+
exports.buildBulkDeleteDocument = buildBulkDeleteDocument;
|
|
48
52
|
/**
|
|
49
53
|
* Query Builder - Builds and executes GraphQL operations
|
|
50
54
|
* @generated by @constructive-io/graphql-codegen
|
|
@@ -247,7 +251,7 @@ function buildFindManyDocument(operationName, queryField, select, args, filterTy
|
|
|
247
251
|
});
|
|
248
252
|
return { document: (0, runtime_1.print)(document), variables };
|
|
249
253
|
}
|
|
250
|
-
function buildFindFirstDocument(operationName, queryField, select, args, filterTypeName, connectionFieldsMap) {
|
|
254
|
+
function buildFindFirstDocument(operationName, queryField, select, args, filterTypeName, orderByTypeName, connectionFieldsMap) {
|
|
251
255
|
const selections = select
|
|
252
256
|
? buildSelections(select, connectionFieldsMap, operationName)
|
|
253
257
|
: [t.field({ name: 'id' })];
|
|
@@ -261,6 +265,11 @@ function buildFindFirstDocument(operationName, queryField, select, args, filterT
|
|
|
261
265
|
typeName: filterTypeName,
|
|
262
266
|
value: args.where,
|
|
263
267
|
}, variableDefinitions, queryArgs, variables);
|
|
268
|
+
addVariable({
|
|
269
|
+
varName: 'orderBy',
|
|
270
|
+
typeName: '[' + orderByTypeName + '!]',
|
|
271
|
+
value: args.orderBy?.length ? args.orderBy : undefined,
|
|
272
|
+
}, variableDefinitions, queryArgs, variables);
|
|
264
273
|
const document = t.document({
|
|
265
274
|
definitions: [
|
|
266
275
|
t.operationDefinition({
|
|
@@ -643,3 +652,105 @@ function buildValueAst(value) {
|
|
|
643
652
|
}
|
|
644
653
|
throw new Error('Unsupported value type: ' + typeof value);
|
|
645
654
|
}
|
|
655
|
+
// ============================================================================
|
|
656
|
+
// Bulk Mutation Document Builders
|
|
657
|
+
// ============================================================================
|
|
658
|
+
function buildBulkInsertDocument(operationName, mutationField, select, data, inputTypeName, onConflict, connectionFieldsMap) {
|
|
659
|
+
const selections = select
|
|
660
|
+
? buildSelections(select, connectionFieldsMap, operationName)
|
|
661
|
+
: [t.field({ name: 'id' })];
|
|
662
|
+
return {
|
|
663
|
+
document: buildInputMutationDocument({
|
|
664
|
+
operationName,
|
|
665
|
+
mutationField,
|
|
666
|
+
inputTypeName,
|
|
667
|
+
resultSelections: [
|
|
668
|
+
t.field({ name: 'affectedCount' }),
|
|
669
|
+
t.field({
|
|
670
|
+
name: 'returning',
|
|
671
|
+
selectionSet: t.selectionSet({ selections }),
|
|
672
|
+
}),
|
|
673
|
+
],
|
|
674
|
+
}),
|
|
675
|
+
variables: {
|
|
676
|
+
input: {
|
|
677
|
+
values: data,
|
|
678
|
+
...(onConflict ? { onConflict } : {}),
|
|
679
|
+
},
|
|
680
|
+
},
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
function buildBulkUpsertDocument(operationName, mutationField, select, data, inputTypeName, onConflict, connectionFieldsMap) {
|
|
684
|
+
const selections = select
|
|
685
|
+
? buildSelections(select, connectionFieldsMap, operationName)
|
|
686
|
+
: [t.field({ name: 'id' })];
|
|
687
|
+
return {
|
|
688
|
+
document: buildInputMutationDocument({
|
|
689
|
+
operationName,
|
|
690
|
+
mutationField,
|
|
691
|
+
inputTypeName,
|
|
692
|
+
resultSelections: [
|
|
693
|
+
t.field({ name: 'affectedCount' }),
|
|
694
|
+
t.field({
|
|
695
|
+
name: 'returning',
|
|
696
|
+
selectionSet: t.selectionSet({ selections }),
|
|
697
|
+
}),
|
|
698
|
+
],
|
|
699
|
+
}),
|
|
700
|
+
variables: {
|
|
701
|
+
input: {
|
|
702
|
+
values: data,
|
|
703
|
+
onConflict,
|
|
704
|
+
},
|
|
705
|
+
},
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
function buildBulkUpdateDocument(operationName, mutationField, select, where, data, inputTypeName, connectionFieldsMap) {
|
|
709
|
+
const selections = select
|
|
710
|
+
? buildSelections(select, connectionFieldsMap, operationName)
|
|
711
|
+
: [t.field({ name: 'id' })];
|
|
712
|
+
return {
|
|
713
|
+
document: buildInputMutationDocument({
|
|
714
|
+
operationName,
|
|
715
|
+
mutationField,
|
|
716
|
+
inputTypeName,
|
|
717
|
+
resultSelections: [
|
|
718
|
+
t.field({ name: 'affectedCount' }),
|
|
719
|
+
t.field({
|
|
720
|
+
name: 'returning',
|
|
721
|
+
selectionSet: t.selectionSet({ selections }),
|
|
722
|
+
}),
|
|
723
|
+
],
|
|
724
|
+
}),
|
|
725
|
+
variables: {
|
|
726
|
+
input: {
|
|
727
|
+
where,
|
|
728
|
+
patch: data,
|
|
729
|
+
},
|
|
730
|
+
},
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
function buildBulkDeleteDocument(operationName, mutationField, select, where, inputTypeName, connectionFieldsMap) {
|
|
734
|
+
const selections = select
|
|
735
|
+
? buildSelections(select, connectionFieldsMap, operationName)
|
|
736
|
+
: [t.field({ name: 'id' })];
|
|
737
|
+
return {
|
|
738
|
+
document: buildInputMutationDocument({
|
|
739
|
+
operationName,
|
|
740
|
+
mutationField,
|
|
741
|
+
inputTypeName,
|
|
742
|
+
resultSelections: [
|
|
743
|
+
t.field({ name: 'affectedCount' }),
|
|
744
|
+
t.field({
|
|
745
|
+
name: 'returning',
|
|
746
|
+
selectionSet: t.selectionSet({ selections }),
|
|
747
|
+
}),
|
|
748
|
+
],
|
|
749
|
+
}),
|
|
750
|
+
variables: {
|
|
751
|
+
input: {
|
|
752
|
+
where,
|
|
753
|
+
},
|
|
754
|
+
},
|
|
755
|
+
};
|
|
756
|
+
}
|
|
@@ -24,9 +24,10 @@ export interface FindManyArgs<TSelect, TWhere, TOrderBy = never> {
|
|
|
24
24
|
before?: string;
|
|
25
25
|
offset?: number;
|
|
26
26
|
}
|
|
27
|
-
export interface FindFirstArgs<TSelect, TWhere> {
|
|
27
|
+
export interface FindFirstArgs<TSelect, TWhere, TOrderBy> {
|
|
28
28
|
select?: TSelect;
|
|
29
29
|
where?: TWhere;
|
|
30
|
+
orderBy?: TOrderBy[];
|
|
30
31
|
}
|
|
31
32
|
export interface CreateArgs<TSelect, TData> {
|
|
32
33
|
data: TData;
|
|
@@ -44,6 +45,29 @@ export interface DeleteArgs<TWhere, TSelect = undefined> {
|
|
|
44
45
|
where: TWhere;
|
|
45
46
|
select?: TSelect;
|
|
46
47
|
}
|
|
48
|
+
export interface BulkInsertArgs<TSelect, TData, TOnConflict = unknown> {
|
|
49
|
+
data: TData[];
|
|
50
|
+
select?: TSelect;
|
|
51
|
+
onConflict?: TOnConflict;
|
|
52
|
+
}
|
|
53
|
+
export interface BulkUpsertArgs<TSelect, TData, TOnConflict = unknown> {
|
|
54
|
+
data: TData[];
|
|
55
|
+
select?: TSelect;
|
|
56
|
+
onConflict: TOnConflict;
|
|
57
|
+
}
|
|
58
|
+
export interface BulkUpdateArgs<TSelect, TWhere, TData> {
|
|
59
|
+
where: TWhere;
|
|
60
|
+
data: TData;
|
|
61
|
+
select?: TSelect;
|
|
62
|
+
}
|
|
63
|
+
export interface BulkDeleteArgs<TSelect, TWhere> {
|
|
64
|
+
where: TWhere;
|
|
65
|
+
select?: TSelect;
|
|
66
|
+
}
|
|
67
|
+
export interface BulkMutationResult<T> {
|
|
68
|
+
affectedCount: number;
|
|
69
|
+
returning: T[];
|
|
70
|
+
}
|
|
47
71
|
type DepthLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
|
48
72
|
type DecrementDepth = {
|
|
49
73
|
0: 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgpmjs/migrate-client",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.6",
|
|
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",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@0no-co/graphql.web": "^1.1.2",
|
|
43
|
-
"@constructive-io/graphql-query": "^3.
|
|
43
|
+
"@constructive-io/graphql-query": "^3.24.0",
|
|
44
44
|
"@constructive-io/graphql-types": "^3.9.1",
|
|
45
45
|
"gql-ast": "^3.9.1",
|
|
46
46
|
"graphql": "16.13.0"
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"makage": "^0.3.0",
|
|
51
51
|
"typescript": "^5.9.3"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "70f9d2052fe9218c65b82e896d1660d4dc6a51c8"
|
|
54
54
|
}
|