@pgpmjs/migrate-client 0.1.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/LICENSE +23 -0
- package/README.md +112 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/migrate/index.d.ts +5 -0
- package/esm/migrate/index.js +5 -0
- package/esm/migrate/orm/client.d.ts +55 -0
- package/esm/migrate/orm/client.js +99 -0
- package/esm/migrate/orm/index.d.ts +48 -0
- package/esm/migrate/orm/index.js +45 -0
- package/esm/migrate/orm/input-types.d.ts +513 -0
- package/esm/migrate/orm/input-types.js +2 -0
- package/esm/migrate/orm/models/index.d.ts +7 -0
- package/esm/migrate/orm/models/index.js +7 -0
- package/esm/migrate/orm/models/migrateFile.d.ts +56 -0
- package/esm/migrate/orm/models/migrateFile.js +94 -0
- package/esm/migrate/orm/models/sqlAction.d.ts +56 -0
- package/esm/migrate/orm/models/sqlAction.js +94 -0
- package/esm/migrate/orm/mutation/index.d.ts +27 -0
- package/esm/migrate/orm/mutation/index.js +30 -0
- package/esm/migrate/orm/query-builder.d.ts +91 -0
- package/esm/migrate/orm/query-builder.js +572 -0
- package/esm/migrate/orm/select-types.d.ts +103 -0
- package/esm/migrate/orm/select-types.js +1 -0
- package/esm/migrate/orm/types.d.ts +6 -0
- package/esm/migrate/orm/types.js +7 -0
- package/index.d.ts +1 -0
- package/index.js +17 -0
- package/migrate/index.d.ts +5 -0
- package/migrate/index.js +21 -0
- package/migrate/orm/client.d.ts +55 -0
- package/migrate/orm/client.js +105 -0
- package/migrate/orm/index.d.ts +48 -0
- package/migrate/orm/index.js +66 -0
- package/migrate/orm/input-types.d.ts +513 -0
- package/migrate/orm/input-types.js +5 -0
- package/migrate/orm/models/index.d.ts +7 -0
- package/migrate/orm/models/index.js +12 -0
- package/migrate/orm/models/migrateFile.d.ts +56 -0
- package/migrate/orm/models/migrateFile.js +98 -0
- package/migrate/orm/models/sqlAction.d.ts +56 -0
- package/migrate/orm/models/sqlAction.js +98 -0
- package/migrate/orm/mutation/index.d.ts +27 -0
- package/migrate/orm/mutation/index.js +33 -0
- package/migrate/orm/query-builder.d.ts +91 -0
- package/migrate/orm/query-builder.js +619 -0
- package/migrate/orm/select-types.d.ts +103 -0
- package/migrate/orm/select-types.js +2 -0
- package/migrate/orm/types.d.ts +6 -0
- package/migrate/orm/types.js +23 -0
- package/package.json +53 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SqlAction model for ORM client
|
|
3
|
+
* @generated by @constructive-io/graphql-codegen
|
|
4
|
+
* DO NOT EDIT - changes will be overwritten
|
|
5
|
+
*/
|
|
6
|
+
import { OrmClient } from '../client';
|
|
7
|
+
import { QueryBuilder } from '../query-builder';
|
|
8
|
+
import type { ConnectionResult, FindManyArgs, FindFirstArgs, CreateArgs, UpdateArgs, DeleteArgs, InferSelectResult, StrictSelect } from '../select-types';
|
|
9
|
+
import type { SqlActionWithRelations, SqlActionSelect, SqlActionFilter, SqlActionOrderBy, CreateSqlActionInput, SqlActionPatch } from '../input-types';
|
|
10
|
+
export declare class SqlActionModel {
|
|
11
|
+
private client;
|
|
12
|
+
constructor(client: OrmClient);
|
|
13
|
+
findMany<S extends SqlActionSelect>(args: FindManyArgs<S, SqlActionFilter, never, SqlActionOrderBy> & {
|
|
14
|
+
select: S;
|
|
15
|
+
} & StrictSelect<S, SqlActionSelect>): QueryBuilder<{
|
|
16
|
+
sqlActions: ConnectionResult<InferSelectResult<SqlActionWithRelations, S>>;
|
|
17
|
+
}>;
|
|
18
|
+
findFirst<S extends SqlActionSelect>(args: FindFirstArgs<S, SqlActionFilter> & {
|
|
19
|
+
select: S;
|
|
20
|
+
} & StrictSelect<S, SqlActionSelect>): QueryBuilder<{
|
|
21
|
+
sqlActions: {
|
|
22
|
+
nodes: InferSelectResult<SqlActionWithRelations, S>[];
|
|
23
|
+
};
|
|
24
|
+
}>;
|
|
25
|
+
findOne<S extends SqlActionSelect>(args: {
|
|
26
|
+
id: number;
|
|
27
|
+
select: S;
|
|
28
|
+
} & StrictSelect<S, SqlActionSelect>): QueryBuilder<{
|
|
29
|
+
sqlAction: InferSelectResult<SqlActionWithRelations, S> | null;
|
|
30
|
+
}>;
|
|
31
|
+
create<S extends SqlActionSelect>(args: CreateArgs<S, CreateSqlActionInput['sqlAction']> & {
|
|
32
|
+
select: S;
|
|
33
|
+
} & StrictSelect<S, SqlActionSelect>): QueryBuilder<{
|
|
34
|
+
createSqlAction: {
|
|
35
|
+
sqlAction: InferSelectResult<SqlActionWithRelations, S>;
|
|
36
|
+
};
|
|
37
|
+
}>;
|
|
38
|
+
update<S extends SqlActionSelect>(args: UpdateArgs<S, {
|
|
39
|
+
id: number;
|
|
40
|
+
}, SqlActionPatch> & {
|
|
41
|
+
select: S;
|
|
42
|
+
} & StrictSelect<S, SqlActionSelect>): QueryBuilder<{
|
|
43
|
+
updateSqlAction: {
|
|
44
|
+
sqlAction: InferSelectResult<SqlActionWithRelations, S>;
|
|
45
|
+
};
|
|
46
|
+
}>;
|
|
47
|
+
delete<S extends SqlActionSelect>(args: DeleteArgs<{
|
|
48
|
+
id: number;
|
|
49
|
+
}, S> & {
|
|
50
|
+
select: S;
|
|
51
|
+
} & StrictSelect<S, SqlActionSelect>): QueryBuilder<{
|
|
52
|
+
deleteSqlAction: {
|
|
53
|
+
sqlAction: InferSelectResult<SqlActionWithRelations, S>;
|
|
54
|
+
};
|
|
55
|
+
}>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SqlActionModel = void 0;
|
|
4
|
+
const query_builder_1 = require("../query-builder");
|
|
5
|
+
const input_types_1 = require("../input-types");
|
|
6
|
+
class SqlActionModel {
|
|
7
|
+
client;
|
|
8
|
+
constructor(client) {
|
|
9
|
+
this.client = client;
|
|
10
|
+
}
|
|
11
|
+
findMany(args) {
|
|
12
|
+
const { document, variables } = (0, query_builder_1.buildFindManyDocument)('SqlAction', 'sqlActions', args.select, {
|
|
13
|
+
where: args?.where,
|
|
14
|
+
orderBy: args?.orderBy,
|
|
15
|
+
first: args?.first,
|
|
16
|
+
last: args?.last,
|
|
17
|
+
after: args?.after,
|
|
18
|
+
before: args?.before,
|
|
19
|
+
offset: args?.offset,
|
|
20
|
+
}, 'SqlActionFilter', 'SqlActionOrderBy', input_types_1.connectionFieldsMap);
|
|
21
|
+
return new query_builder_1.QueryBuilder({
|
|
22
|
+
client: this.client,
|
|
23
|
+
operation: 'query',
|
|
24
|
+
operationName: 'SqlAction',
|
|
25
|
+
fieldName: 'sqlActions',
|
|
26
|
+
document,
|
|
27
|
+
variables,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
findFirst(args) {
|
|
31
|
+
const { document, variables } = (0, query_builder_1.buildFindFirstDocument)('SqlAction', 'sqlActions', args.select, {
|
|
32
|
+
where: args?.where,
|
|
33
|
+
}, 'SqlActionFilter', input_types_1.connectionFieldsMap);
|
|
34
|
+
return new query_builder_1.QueryBuilder({
|
|
35
|
+
client: this.client,
|
|
36
|
+
operation: 'query',
|
|
37
|
+
operationName: 'SqlAction',
|
|
38
|
+
fieldName: 'sqlActions',
|
|
39
|
+
document,
|
|
40
|
+
variables,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
findOne(args) {
|
|
44
|
+
const { document, variables } = (0, query_builder_1.buildFindManyDocument)('SqlAction', 'sqlActions', args.select, {
|
|
45
|
+
where: {
|
|
46
|
+
id: {
|
|
47
|
+
equalTo: args.id,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
first: 1,
|
|
51
|
+
}, 'SqlActionFilter', 'SqlActionOrderBy', input_types_1.connectionFieldsMap);
|
|
52
|
+
return new query_builder_1.QueryBuilder({
|
|
53
|
+
client: this.client,
|
|
54
|
+
operation: 'query',
|
|
55
|
+
operationName: 'SqlAction',
|
|
56
|
+
fieldName: 'sqlAction',
|
|
57
|
+
document,
|
|
58
|
+
variables,
|
|
59
|
+
transform: (data) => ({
|
|
60
|
+
sqlAction: data.sqlActions?.nodes?.[0] ?? null,
|
|
61
|
+
}),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
create(args) {
|
|
65
|
+
const { document, variables } = (0, query_builder_1.buildCreateDocument)('SqlAction', 'createSqlAction', 'sqlAction', args.select, args.data, 'CreateSqlActionInput', input_types_1.connectionFieldsMap);
|
|
66
|
+
return new query_builder_1.QueryBuilder({
|
|
67
|
+
client: this.client,
|
|
68
|
+
operation: 'mutation',
|
|
69
|
+
operationName: 'SqlAction',
|
|
70
|
+
fieldName: 'createSqlAction',
|
|
71
|
+
document,
|
|
72
|
+
variables,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
update(args) {
|
|
76
|
+
const { document, variables } = (0, query_builder_1.buildUpdateByPkDocument)('SqlAction', 'updateSqlAction', 'sqlAction', args.select, args.where.id, args.data, 'UpdateSqlActionInput', 'id', 'sqlActionPatch', input_types_1.connectionFieldsMap);
|
|
77
|
+
return new query_builder_1.QueryBuilder({
|
|
78
|
+
client: this.client,
|
|
79
|
+
operation: 'mutation',
|
|
80
|
+
operationName: 'SqlAction',
|
|
81
|
+
fieldName: 'updateSqlAction',
|
|
82
|
+
document,
|
|
83
|
+
variables,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
delete(args) {
|
|
87
|
+
const { document, variables } = (0, query_builder_1.buildDeleteByPkDocument)('SqlAction', 'deleteSqlAction', 'sqlAction', args.where.id, 'DeleteSqlActionInput', 'id', args.select, input_types_1.connectionFieldsMap);
|
|
88
|
+
return new query_builder_1.QueryBuilder({
|
|
89
|
+
client: this.client,
|
|
90
|
+
operation: 'mutation',
|
|
91
|
+
operationName: 'SqlAction',
|
|
92
|
+
fieldName: 'deleteSqlAction',
|
|
93
|
+
document,
|
|
94
|
+
variables,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.SqlActionModel = SqlActionModel;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom mutation operations
|
|
3
|
+
* @generated by @constructive-io/graphql-codegen
|
|
4
|
+
* DO NOT EDIT - changes will be overwritten
|
|
5
|
+
*/
|
|
6
|
+
import { OrmClient } from '../client';
|
|
7
|
+
import { QueryBuilder } from '../query-builder';
|
|
8
|
+
import type { InferSelectResult, StrictSelect } from '../select-types';
|
|
9
|
+
import type { ExecuteSqlInput, RunMigrationInput, ExecuteSqlPayload, RunMigrationPayload, ExecuteSqlPayloadSelect, RunMigrationPayloadSelect } from '../input-types';
|
|
10
|
+
export interface ExecuteSqlVariables {
|
|
11
|
+
input: ExecuteSqlInput;
|
|
12
|
+
}
|
|
13
|
+
export interface RunMigrationVariables {
|
|
14
|
+
input: RunMigrationInput;
|
|
15
|
+
}
|
|
16
|
+
export declare function createMutationOperations(client: OrmClient): {
|
|
17
|
+
executeSql: <S extends ExecuteSqlPayloadSelect>(args: ExecuteSqlVariables, options: {
|
|
18
|
+
select: S;
|
|
19
|
+
} & StrictSelect<S, ExecuteSqlPayloadSelect>) => QueryBuilder<{
|
|
20
|
+
executeSql: InferSelectResult<ExecuteSqlPayload, S> | null;
|
|
21
|
+
}>;
|
|
22
|
+
runMigration: <S extends RunMigrationPayloadSelect>(args: RunMigrationVariables, options: {
|
|
23
|
+
select: S;
|
|
24
|
+
} & StrictSelect<S, RunMigrationPayloadSelect>) => QueryBuilder<{
|
|
25
|
+
runMigration: InferSelectResult<RunMigrationPayload, S> | null;
|
|
26
|
+
}>;
|
|
27
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createMutationOperations = createMutationOperations;
|
|
4
|
+
const query_builder_1 = require("../query-builder");
|
|
5
|
+
const input_types_1 = require("../input-types");
|
|
6
|
+
function createMutationOperations(client) {
|
|
7
|
+
return {
|
|
8
|
+
executeSql: (args, options) => new query_builder_1.QueryBuilder({
|
|
9
|
+
client,
|
|
10
|
+
operation: 'mutation',
|
|
11
|
+
operationName: 'ExecuteSql',
|
|
12
|
+
fieldName: 'executeSql',
|
|
13
|
+
...(0, query_builder_1.buildCustomDocument)('mutation', 'ExecuteSql', 'executeSql', options.select, args, [
|
|
14
|
+
{
|
|
15
|
+
name: 'input',
|
|
16
|
+
type: 'ExecuteSqlInput!',
|
|
17
|
+
},
|
|
18
|
+
], input_types_1.connectionFieldsMap, 'ExecuteSqlPayload'),
|
|
19
|
+
}),
|
|
20
|
+
runMigration: (args, options) => new query_builder_1.QueryBuilder({
|
|
21
|
+
client,
|
|
22
|
+
operation: 'mutation',
|
|
23
|
+
operationName: 'RunMigration',
|
|
24
|
+
fieldName: 'runMigration',
|
|
25
|
+
...(0, query_builder_1.buildCustomDocument)('mutation', 'RunMigration', 'runMigration', options.select, args, [
|
|
26
|
+
{
|
|
27
|
+
name: 'input',
|
|
28
|
+
type: 'RunMigrationInput!',
|
|
29
|
+
},
|
|
30
|
+
], input_types_1.connectionFieldsMap, 'RunMigrationPayload'),
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { FieldNode } from 'graphql';
|
|
2
|
+
import { OrmClient, QueryResult } from './client';
|
|
3
|
+
export interface QueryBuilderConfig<TResult> {
|
|
4
|
+
client: OrmClient;
|
|
5
|
+
operation: 'query' | 'mutation';
|
|
6
|
+
operationName: string;
|
|
7
|
+
fieldName: string;
|
|
8
|
+
document: string;
|
|
9
|
+
variables?: Record<string, unknown>;
|
|
10
|
+
transform?: (data: any) => TResult;
|
|
11
|
+
}
|
|
12
|
+
export declare class QueryBuilder<TResult> {
|
|
13
|
+
private config;
|
|
14
|
+
constructor(config: QueryBuilderConfig<TResult>);
|
|
15
|
+
/**
|
|
16
|
+
* Execute the query and return a discriminated union result
|
|
17
|
+
* Use result.ok to check success, or .unwrap() to throw on error
|
|
18
|
+
*/
|
|
19
|
+
execute(): Promise<QueryResult<TResult>>;
|
|
20
|
+
/**
|
|
21
|
+
* Execute and unwrap the result, throwing GraphQLRequestError on failure
|
|
22
|
+
* @throws {GraphQLRequestError} If the query returns errors
|
|
23
|
+
*/
|
|
24
|
+
unwrap(): Promise<TResult>;
|
|
25
|
+
/**
|
|
26
|
+
* Execute and unwrap, returning defaultValue on error instead of throwing
|
|
27
|
+
*/
|
|
28
|
+
unwrapOr<D>(defaultValue: D): Promise<TResult | D>;
|
|
29
|
+
/**
|
|
30
|
+
* Execute and unwrap, calling onError callback on failure
|
|
31
|
+
*/
|
|
32
|
+
unwrapOrElse<D>(onError: (errors: import('./client').GraphQLError[]) => D): Promise<TResult | D>;
|
|
33
|
+
toGraphQL(): string;
|
|
34
|
+
getVariables(): Record<string, unknown> | undefined;
|
|
35
|
+
}
|
|
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, TCondition = never>(operationName: string, queryField: string, select: TSelect, args: {
|
|
38
|
+
where?: TWhere;
|
|
39
|
+
condition?: TCondition;
|
|
40
|
+
orderBy?: string[];
|
|
41
|
+
first?: number;
|
|
42
|
+
last?: number;
|
|
43
|
+
after?: string;
|
|
44
|
+
before?: string;
|
|
45
|
+
offset?: number;
|
|
46
|
+
}, filterTypeName: string, orderByTypeName: string, connectionFieldsMap?: Record<string, Record<string, string>>, conditionTypeName?: string): {
|
|
47
|
+
document: string;
|
|
48
|
+
variables: Record<string, unknown>;
|
|
49
|
+
};
|
|
50
|
+
export declare function buildFindFirstDocument<TSelect, TWhere, TCondition = never>(operationName: string, queryField: string, select: TSelect, args: {
|
|
51
|
+
where?: TWhere;
|
|
52
|
+
condition?: TCondition;
|
|
53
|
+
}, filterTypeName: string, connectionFieldsMap?: Record<string, Record<string, string>>, conditionTypeName?: string): {
|
|
54
|
+
document: string;
|
|
55
|
+
variables: Record<string, unknown>;
|
|
56
|
+
};
|
|
57
|
+
export declare function buildCreateDocument<TSelect, TData>(operationName: string, mutationField: string, entityField: string, select: TSelect, data: TData, inputTypeName: string, connectionFieldsMap?: Record<string, Record<string, string>>): {
|
|
58
|
+
document: string;
|
|
59
|
+
variables: Record<string, unknown>;
|
|
60
|
+
};
|
|
61
|
+
export declare function buildUpdateDocument<TSelect, TWhere extends {
|
|
62
|
+
id: string;
|
|
63
|
+
}, TData>(operationName: string, mutationField: string, entityField: string, select: TSelect, where: TWhere, data: TData, inputTypeName: string, patchFieldName: string, connectionFieldsMap?: Record<string, Record<string, string>>): {
|
|
64
|
+
document: string;
|
|
65
|
+
variables: Record<string, unknown>;
|
|
66
|
+
};
|
|
67
|
+
export declare function buildUpdateByPkDocument<TSelect, TData>(operationName: string, mutationField: string, entityField: string, select: TSelect, id: string | number, data: TData, inputTypeName: string, idFieldName: string, patchFieldName: string, connectionFieldsMap?: Record<string, Record<string, string>>): {
|
|
68
|
+
document: string;
|
|
69
|
+
variables: Record<string, unknown>;
|
|
70
|
+
};
|
|
71
|
+
export declare function buildFindOneDocument<TSelect>(operationName: string, queryField: string, id: string | number, select: TSelect, idArgName: string, idTypeName: string, connectionFieldsMap?: Record<string, Record<string, string>>): {
|
|
72
|
+
document: string;
|
|
73
|
+
variables: Record<string, unknown>;
|
|
74
|
+
};
|
|
75
|
+
export declare function buildDeleteDocument<TWhere extends {
|
|
76
|
+
id: string;
|
|
77
|
+
}, TSelect = undefined>(operationName: string, mutationField: string, entityField: string, where: TWhere, inputTypeName: string, select?: TSelect, connectionFieldsMap?: Record<string, Record<string, string>>): {
|
|
78
|
+
document: string;
|
|
79
|
+
variables: Record<string, unknown>;
|
|
80
|
+
};
|
|
81
|
+
export declare function buildDeleteByPkDocument<TSelect = undefined>(operationName: string, mutationField: string, entityField: string, id: string | number, inputTypeName: string, idFieldName: string, select?: TSelect, connectionFieldsMap?: Record<string, Record<string, string>>): {
|
|
82
|
+
document: string;
|
|
83
|
+
variables: Record<string, unknown>;
|
|
84
|
+
};
|
|
85
|
+
export declare function buildCustomDocument<TSelect, TArgs>(operationType: 'query' | 'mutation', operationName: string, fieldName: string, select: TSelect, args: TArgs, variableDefinitions: Array<{
|
|
86
|
+
name: string;
|
|
87
|
+
type: string;
|
|
88
|
+
}>, connectionFieldsMap?: Record<string, Record<string, string>>, entityType?: string): {
|
|
89
|
+
document: string;
|
|
90
|
+
variables: Record<string, unknown>;
|
|
91
|
+
};
|