@nest-boot/graphql-connection 6.0.0-beta.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/dist/connection.builder.d.ts +21 -0
- package/dist/connection.builder.js +180 -0
- package/dist/connection.builder.js.map +1 -0
- package/dist/connection.manager.d.ts +13 -0
- package/dist/connection.manager.js +133 -0
- package/dist/connection.manager.js.map +1 -0
- package/dist/enums/comparator-operator.enum.d.ts +11 -0
- package/dist/enums/comparator-operator.enum.js +16 -0
- package/dist/enums/comparator-operator.enum.js.map +1 -0
- package/dist/enums/index.d.ts +2 -0
- package/dist/enums/index.js +19 -0
- package/dist/enums/index.js.map +1 -0
- package/dist/enums/order-direction.enum.d.ts +4 -0
- package/dist/enums/order-direction.enum.js +11 -0
- package/dist/enums/order-direction.enum.js.map +1 -0
- package/dist/graphql-connection.constants.d.ts +1 -0
- package/dist/graphql-connection.constants.js +5 -0
- package/dist/graphql-connection.constants.js.map +1 -0
- package/dist/graphql-connection.module-definition.d.ts +7 -0
- package/dist/graphql-connection.module-definition.js +14 -0
- package/dist/graphql-connection.module-definition.js.map +1 -0
- package/dist/graphql-connection.module.d.ts +3 -0
- package/dist/graphql-connection.module.js +22 -0
- package/dist/graphql-connection.module.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/connection-args.interface.d.ts +6 -0
- package/dist/interfaces/connection-args.interface.js +3 -0
- package/dist/interfaces/connection-args.interface.js.map +1 -0
- package/dist/interfaces/connection-metadata.interface.d.ts +6 -0
- package/dist/interfaces/connection-metadata.interface.js +3 -0
- package/dist/interfaces/connection-metadata.interface.js.map +1 -0
- package/dist/interfaces/connection.interface.d.ts +7 -0
- package/dist/interfaces/connection.interface.js +3 -0
- package/dist/interfaces/connection.interface.js.map +1 -0
- package/dist/interfaces/edge.interface.d.ts +4 -0
- package/dist/interfaces/edge.interface.js +3 -0
- package/dist/interfaces/edge.interface.js.map +1 -0
- package/dist/interfaces/field-options.interface.d.ts +27 -0
- package/dist/interfaces/field-options.interface.js +3 -0
- package/dist/interfaces/field-options.interface.js.map +1 -0
- package/dist/interfaces/index.d.ts +8 -0
- package/dist/interfaces/index.js +25 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/order-field.type.d.ts +8 -0
- package/dist/interfaces/order-field.type.js +3 -0
- package/dist/interfaces/order-field.type.js.map +1 -0
- package/dist/interfaces/order.interface.d.ts +6 -0
- package/dist/interfaces/order.interface.js +3 -0
- package/dist/interfaces/order.interface.js.map +1 -0
- package/dist/interfaces/replacement-args.interface.d.ts +9 -0
- package/dist/interfaces/replacement-args.interface.js +3 -0
- package/dist/interfaces/replacement-args.interface.js.map +1 -0
- package/dist/interfaces/search-syntax-field-options.interface.d.ts +12 -0
- package/dist/interfaces/search-syntax-field-options.interface.js +3 -0
- package/dist/interfaces/search-syntax-field-options.interface.js.map +1 -0
- package/dist/objects/index.d.ts +1 -0
- package/dist/objects/index.js +18 -0
- package/dist/objects/index.js.map +1 -0
- package/dist/objects/page-info.object.d.ts +6 -0
- package/dist/objects/page-info.object.js +44 -0
- package/dist/objects/page-info.object.js.map +1 -0
- package/dist/scripts/generate-cst-dts.d.ts +1 -0
- package/dist/scripts/generate-cst-dts.js +8 -0
- package/dist/scripts/generate-cst-dts.js.map +1 -0
- package/dist/search-syntax.lexer.d.ts +5 -0
- package/dist/search-syntax.lexer.js +13 -0
- package/dist/search-syntax.lexer.js.map +1 -0
- package/dist/search-syntax.parser.d.ts +6 -0
- package/dist/search-syntax.parser.js +91 -0
- package/dist/search-syntax.parser.js.map +1 -0
- package/dist/search-syntax.visitor.d.ts +24 -0
- package/dist/search-syntax.visitor.js +324 -0
- package/dist/search-syntax.visitor.js.map +1 -0
- package/dist/tokens/Comma.d.ts +1 -0
- package/dist/tokens/Comma.js +9 -0
- package/dist/tokens/Comma.js.map +1 -0
- package/dist/tokens/Identifier.d.ts +1 -0
- package/dist/tokens/Identifier.js +14 -0
- package/dist/tokens/Identifier.js.map +1 -0
- package/dist/tokens/UnquotedLiteral.d.ts +1 -0
- package/dist/tokens/UnquotedLiteral.js +11 -0
- package/dist/tokens/UnquotedLiteral.js.map +1 -0
- package/dist/tokens/WhiteSpace.d.ts +1 -0
- package/dist/tokens/WhiteSpace.js +12 -0
- package/dist/tokens/WhiteSpace.js.map +1 -0
- package/dist/tokens/Wildcard.d.ts +1 -0
- package/dist/tokens/Wildcard.js +9 -0
- package/dist/tokens/Wildcard.js.map +1 -0
- package/dist/tokens/brackets/LeftBracket.d.ts +1 -0
- package/dist/tokens/brackets/LeftBracket.js +9 -0
- package/dist/tokens/brackets/LeftBracket.js.map +1 -0
- package/dist/tokens/brackets/RightBracket.d.ts +1 -0
- package/dist/tokens/brackets/RightBracket.js +9 -0
- package/dist/tokens/brackets/RightBracket.js.map +1 -0
- package/dist/tokens/brackets/index.d.ts +3 -0
- package/dist/tokens/brackets/index.js +23 -0
- package/dist/tokens/brackets/index.js.map +1 -0
- package/dist/tokens/comparators/Comparator.d.ts +1 -0
- package/dist/tokens/comparators/Comparator.js +9 -0
- package/dist/tokens/comparators/Comparator.js.map +1 -0
- package/dist/tokens/comparators/Equal.d.ts +1 -0
- package/dist/tokens/comparators/Equal.js +11 -0
- package/dist/tokens/comparators/Equal.js.map +1 -0
- package/dist/tokens/comparators/GreaterThan.d.ts +1 -0
- package/dist/tokens/comparators/GreaterThan.js +11 -0
- package/dist/tokens/comparators/GreaterThan.js.map +1 -0
- package/dist/tokens/comparators/GreaterThanOrEqual.d.ts +1 -0
- package/dist/tokens/comparators/GreaterThanOrEqual.js +11 -0
- package/dist/tokens/comparators/GreaterThanOrEqual.js.map +1 -0
- package/dist/tokens/comparators/LessThan.d.ts +1 -0
- package/dist/tokens/comparators/LessThan.js +11 -0
- package/dist/tokens/comparators/LessThan.js.map +1 -0
- package/dist/tokens/comparators/LessThanOrEqual.d.ts +1 -0
- package/dist/tokens/comparators/LessThanOrEqual.js +11 -0
- package/dist/tokens/comparators/LessThanOrEqual.js.map +1 -0
- package/dist/tokens/comparators/index.d.ts +7 -0
- package/dist/tokens/comparators/index.js +38 -0
- package/dist/tokens/comparators/index.js.map +1 -0
- package/dist/tokens/connectives/And.d.ts +1 -0
- package/dist/tokens/connectives/And.js +11 -0
- package/dist/tokens/connectives/And.js.map +1 -0
- package/dist/tokens/connectives/Not.d.ts +1 -0
- package/dist/tokens/connectives/Not.js +11 -0
- package/dist/tokens/connectives/Not.js.map +1 -0
- package/dist/tokens/connectives/Or.d.ts +1 -0
- package/dist/tokens/connectives/Or.js +11 -0
- package/dist/tokens/connectives/Or.js.map +1 -0
- package/dist/tokens/connectives/index.d.ts +4 -0
- package/dist/tokens/connectives/index.js +25 -0
- package/dist/tokens/connectives/index.js.map +1 -0
- package/dist/tokens/fields/Field.d.ts +1 -0
- package/dist/tokens/fields/Field.js +9 -0
- package/dist/tokens/fields/Field.js.map +1 -0
- package/dist/tokens/fields/NestedField.d.ts +1 -0
- package/dist/tokens/fields/NestedField.js +13 -0
- package/dist/tokens/fields/NestedField.js.map +1 -0
- package/dist/tokens/fields/index.d.ts +3 -0
- package/dist/tokens/fields/index.js +23 -0
- package/dist/tokens/fields/index.js.map +1 -0
- package/dist/tokens/index.d.ts +1 -0
- package/dist/tokens/index.js +31 -0
- package/dist/tokens/index.js.map +1 -0
- package/dist/tokens/values/Date.d.ts +1 -0
- package/dist/tokens/values/Date.js +12 -0
- package/dist/tokens/values/Date.js.map +1 -0
- package/dist/tokens/values/False.d.ts +1 -0
- package/dist/tokens/values/False.js +13 -0
- package/dist/tokens/values/False.js.map +1 -0
- package/dist/tokens/values/Null.d.ts +1 -0
- package/dist/tokens/values/Null.js +13 -0
- package/dist/tokens/values/Null.js.map +1 -0
- package/dist/tokens/values/Number.d.ts +1 -0
- package/dist/tokens/values/Number.js +13 -0
- package/dist/tokens/values/Number.js.map +1 -0
- package/dist/tokens/values/QuotedString.d.ts +1 -0
- package/dist/tokens/values/QuotedString.js +11 -0
- package/dist/tokens/values/QuotedString.js.map +1 -0
- package/dist/tokens/values/True.d.ts +1 -0
- package/dist/tokens/values/True.js +13 -0
- package/dist/tokens/values/True.js.map +1 -0
- package/dist/tokens/values/Value.d.ts +1 -0
- package/dist/tokens/values/Value.js +9 -0
- package/dist/tokens/values/Value.js.map +1 -0
- package/dist/tokens/values/index.d.ts +7 -0
- package/dist/tokens/values/index.js +32 -0
- package/dist/tokens/values/index.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/connection-class.type.d.ts +3 -0
- package/dist/types/connection-class.type.js +3 -0
- package/dist/types/connection-class.type.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +18 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +18 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/infer-type.d.ts +1 -0
- package/dist/utils/infer-type.js +15 -0
- package/dist/utils/infer-type.js.map +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { EntityClass } from "@mikro-orm/core";
|
|
2
|
+
import { type Type } from "@nestjs/common";
|
|
3
|
+
import { ConnectionArgsInterface, ConnectionInterface, EdgeInterface, FieldOptions, OrderFieldType, OrderInterface } from "./interfaces";
|
|
4
|
+
interface ConnectionBuildResult<Entity extends object> {
|
|
5
|
+
Connection: Type<ConnectionInterface<Entity>>;
|
|
6
|
+
ConnectionArgs: Type<ConnectionArgsInterface<Entity>>;
|
|
7
|
+
Edge: Type<EdgeInterface<Entity>>;
|
|
8
|
+
Order: Type<OrderInterface<Entity>>;
|
|
9
|
+
OrderField?: OrderFieldType<Entity>;
|
|
10
|
+
}
|
|
11
|
+
export declare class ConnectionBuilder<Entity extends object> {
|
|
12
|
+
private readonly entityClass;
|
|
13
|
+
private readonly entityName;
|
|
14
|
+
private readonly fieldOptionsMap;
|
|
15
|
+
constructor(entityClass: EntityClass<Entity>);
|
|
16
|
+
private get filterableFields();
|
|
17
|
+
private get sortableFields();
|
|
18
|
+
addField<Field extends string = never, Type extends "string" | "number" | "bigint" | "boolean" | "date" = never>(options: FieldOptions<Entity, Field, Type>): this;
|
|
19
|
+
build(): ConnectionBuildResult<Entity>;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ConnectionBuilder = void 0;
|
|
13
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
14
|
+
const inflection_1 = require("inflection");
|
|
15
|
+
const enums_1 = require("./enums");
|
|
16
|
+
const graphql_connection_constants_1 = require("./graphql-connection.constants");
|
|
17
|
+
const objects_1 = require("./objects");
|
|
18
|
+
class ConnectionBuilder {
|
|
19
|
+
constructor(entityClass) {
|
|
20
|
+
this.entityClass = entityClass;
|
|
21
|
+
this.fieldOptionsMap = new Map();
|
|
22
|
+
this.entityName = entityClass.name;
|
|
23
|
+
}
|
|
24
|
+
get filterableFields() {
|
|
25
|
+
return [...this.fieldOptionsMap.values()].filter((field) => field.filterable);
|
|
26
|
+
}
|
|
27
|
+
get sortableFields() {
|
|
28
|
+
return [...this.fieldOptionsMap.values()].filter((field) => field?.sortable);
|
|
29
|
+
}
|
|
30
|
+
addField(options) {
|
|
31
|
+
this.fieldOptionsMap.set(options.field, options);
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
build() {
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
36
|
+
const builder = this;
|
|
37
|
+
const pluralizeEntityName = (0, inflection_1.pluralize)(builder.entityName);
|
|
38
|
+
const humanizeEntityName = (0, inflection_1.humanize)(builder.entityName, true);
|
|
39
|
+
const humanizeAndPluralizeAndEntityName = (0, inflection_1.pluralize)((0, inflection_1.humanize)(builder.entityName, true));
|
|
40
|
+
let Edge = class Edge {
|
|
41
|
+
};
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, graphql_1.Field)(() => builder.entityClass, {
|
|
44
|
+
description: `The item at the end of ${builder.entityName}Edge.`,
|
|
45
|
+
}),
|
|
46
|
+
__metadata("design:type", Object)
|
|
47
|
+
], Edge.prototype, "node", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, graphql_1.Field)({ complexity: 0, description: `A cursor for use in pagination.` }),
|
|
50
|
+
__metadata("design:type", String)
|
|
51
|
+
], Edge.prototype, "cursor", void 0);
|
|
52
|
+
Edge = __decorate([
|
|
53
|
+
(0, graphql_1.ObjectType)(`${builder.entityName}Edge`, {
|
|
54
|
+
description: `An auto-generated type which holds one ${builder.entityName} and a cursor during pagination.`,
|
|
55
|
+
})
|
|
56
|
+
], Edge);
|
|
57
|
+
let Connection = class Connection {
|
|
58
|
+
};
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, graphql_1.Field)(() => [Edge], { complexity: 0, description: `A list of edges.` }),
|
|
61
|
+
__metadata("design:type", Array)
|
|
62
|
+
], Connection.prototype, "edges", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, graphql_1.Field)({
|
|
65
|
+
complexity: 0,
|
|
66
|
+
description: `Information to aid in pagination.`,
|
|
67
|
+
}),
|
|
68
|
+
__metadata("design:type", objects_1.PageInfo)
|
|
69
|
+
], Connection.prototype, "pageInfo", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, graphql_1.Field)(() => graphql_1.Int, {
|
|
72
|
+
complexity: 0,
|
|
73
|
+
description: `Identifies the total count of items in the connection.`,
|
|
74
|
+
}),
|
|
75
|
+
__metadata("design:type", Number)
|
|
76
|
+
], Connection.prototype, "totalCount", void 0);
|
|
77
|
+
Connection = __decorate([
|
|
78
|
+
Reflect.metadata(graphql_connection_constants_1.GRAPHQL_CONNECTION_METADATA, {
|
|
79
|
+
entityClass: builder.entityClass,
|
|
80
|
+
fieldOptionsMap: builder.fieldOptionsMap,
|
|
81
|
+
}),
|
|
82
|
+
(0, graphql_1.ObjectType)(`${builder.entityName}Connection`, {
|
|
83
|
+
isAbstract: true,
|
|
84
|
+
description: `An auto-generated type for paginating through multiple ${pluralizeEntityName}.`,
|
|
85
|
+
})
|
|
86
|
+
], Connection);
|
|
87
|
+
const OrderField = builder.sortableFields.reduce((result, fieldOptions) => {
|
|
88
|
+
return {
|
|
89
|
+
...result,
|
|
90
|
+
[(0, inflection_1.underscore)(fieldOptions.field).toUpperCase()]: fieldOptions.replacement ??
|
|
91
|
+
fieldOptions.field,
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/prefer-reduce-type-parameter
|
|
95
|
+
{ ID: "id" });
|
|
96
|
+
(0, graphql_1.registerEnumType)(OrderField, {
|
|
97
|
+
name: `${builder.entityName}OrderField`,
|
|
98
|
+
description: `Properties by which ${humanizeEntityName} connections can be ordered.`,
|
|
99
|
+
});
|
|
100
|
+
let Order = class Order {
|
|
101
|
+
};
|
|
102
|
+
__decorate([
|
|
103
|
+
(0, graphql_1.Field)(() => OrderField, {
|
|
104
|
+
description: `The field to order ${humanizeAndPluralizeAndEntityName} by.`,
|
|
105
|
+
}),
|
|
106
|
+
__metadata("design:type", String)
|
|
107
|
+
], Order.prototype, "field", void 0);
|
|
108
|
+
__decorate([
|
|
109
|
+
(0, graphql_1.Field)(() => enums_1.OrderDirection, { description: `The ordering direction.` }),
|
|
110
|
+
__metadata("design:type", String)
|
|
111
|
+
], Order.prototype, "direction", void 0);
|
|
112
|
+
Order = __decorate([
|
|
113
|
+
(0, graphql_1.InputType)(`${builder.entityName}Order`, {
|
|
114
|
+
description: `Ordering options for ${humanizeEntityName} connections`,
|
|
115
|
+
})
|
|
116
|
+
], Order);
|
|
117
|
+
let ConnectionArgs = class ConnectionArgs {
|
|
118
|
+
};
|
|
119
|
+
__decorate([
|
|
120
|
+
(0, graphql_1.Field)({
|
|
121
|
+
nullable: true,
|
|
122
|
+
...(builder.filterableFields.length > 0
|
|
123
|
+
? {
|
|
124
|
+
description: `Apply one or multiple filters to the query.\nSupported filter parameters:\n${builder.filterableFields
|
|
125
|
+
.map(({ field }) => `\`${field}\``)
|
|
126
|
+
.join(", ")}`,
|
|
127
|
+
}
|
|
128
|
+
: {}),
|
|
129
|
+
}),
|
|
130
|
+
__metadata("design:type", String)
|
|
131
|
+
], ConnectionArgs.prototype, "query", void 0);
|
|
132
|
+
__decorate([
|
|
133
|
+
(0, graphql_1.Field)(() => graphql_1.Int, {
|
|
134
|
+
nullable: true,
|
|
135
|
+
description: "Returns up to the first `n` elements from the list.",
|
|
136
|
+
}),
|
|
137
|
+
__metadata("design:type", Number)
|
|
138
|
+
], ConnectionArgs.prototype, "first", void 0);
|
|
139
|
+
__decorate([
|
|
140
|
+
(0, graphql_1.Field)(() => graphql_1.Int, {
|
|
141
|
+
nullable: true,
|
|
142
|
+
description: "Returns up to the last `n` elements from the list.",
|
|
143
|
+
}),
|
|
144
|
+
__metadata("design:type", Number)
|
|
145
|
+
], ConnectionArgs.prototype, "last", void 0);
|
|
146
|
+
__decorate([
|
|
147
|
+
(0, graphql_1.Field)({
|
|
148
|
+
nullable: true,
|
|
149
|
+
description: `Returns the elements that come after the specified cursor.`,
|
|
150
|
+
}),
|
|
151
|
+
__metadata("design:type", String)
|
|
152
|
+
], ConnectionArgs.prototype, "after", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
(0, graphql_1.Field)({
|
|
155
|
+
nullable: true,
|
|
156
|
+
description: `Returns the elements that come before the specified cursor.`,
|
|
157
|
+
}),
|
|
158
|
+
__metadata("design:type", String)
|
|
159
|
+
], ConnectionArgs.prototype, "before", void 0);
|
|
160
|
+
__decorate([
|
|
161
|
+
(0, graphql_1.Field)(() => Order, {
|
|
162
|
+
nullable: true,
|
|
163
|
+
description: `Ordering options for the returned topics.`,
|
|
164
|
+
}),
|
|
165
|
+
__metadata("design:type", Order)
|
|
166
|
+
], ConnectionArgs.prototype, "orderBy", void 0);
|
|
167
|
+
ConnectionArgs = __decorate([
|
|
168
|
+
(0, graphql_1.ArgsType)()
|
|
169
|
+
], ConnectionArgs);
|
|
170
|
+
return {
|
|
171
|
+
Connection,
|
|
172
|
+
ConnectionArgs,
|
|
173
|
+
Edge,
|
|
174
|
+
Order,
|
|
175
|
+
OrderField,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
exports.ConnectionBuilder = ConnectionBuilder;
|
|
180
|
+
//# sourceMappingURL=connection.builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.builder.js","sourceRoot":"","sources":["../src/connection.builder.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,6CAOyB;AACzB,2CAA6D;AAE7D,mCAAyC;AACzC,iFAA6E;AAa7E,uCAAqC;AAUrC,MAAa,iBAAiB;IAO5B,YAA6B,WAAgC;QAAhC,gBAAW,GAAX,WAAW,CAAqB;QAL5C,oBAAe,GAAG,IAAI,GAAG,EAGvC,CAAC;QAGF,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC;IACrC,CAAC;IAED,IAAY,gBAAgB;QAC1B,OAAO,CAAC,GAAG,IAAI,CAA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AJC,IAAA,eAAK,EAAC;gBACL,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,6DAA6D;aAC3E,CAAC;;sDACc;QAMhB;YAJC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,KAAK,EAAE;gBAClB,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,2CAA2C;aACzD,CAAC;sCACQ,KAAK;uDAAC;QAzCZ,cAAc;YADnB,IAAA,kBAAQ,GAAE;WACL,cAAc,CA0CnB;QAED,OAAO;YACL,UAAU;YACV,cAAc;YACd,IAAI;YACJ,KAAK;YACL,UAAU;SACX,CAAC;IACJ,CAAC;CACF;AAnKD,8CAmKC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EntityManager, type FilterQuery } from "@mikro-orm/core";
|
|
2
|
+
import type { FindByCursorOptions } from "@mikro-orm/core/drivers";
|
|
3
|
+
import { ConnectionArgsInterface, ConnectionInterface } from "./interfaces";
|
|
4
|
+
import { ConnectionClass } from "./types";
|
|
5
|
+
export interface ConnectionFindOptions<Entity extends object, Hint extends string = never, Fields extends string = "*", Excludes extends string = never> extends Exclude<FindByCursorOptions<Entity, Hint, Fields, Excludes>, "before" | "after" | "first" | "last" | "orderBy"> {
|
|
6
|
+
where?: FilterQuery<Entity>;
|
|
7
|
+
}
|
|
8
|
+
export declare class ConnectionManager {
|
|
9
|
+
private readonly entityManager;
|
|
10
|
+
constructor(entityManager: EntityManager);
|
|
11
|
+
private convertQueryStringToFilterQuery;
|
|
12
|
+
find<Entity extends object, Hint extends string = never, Fields extends string = "*", Excludes extends string = never>(connectionClass: ConnectionClass<Entity>, args: ConnectionArgsInterface<Entity, Hint, Fields, Excludes>, options?: ConnectionFindOptions<Entity, Hint, Fields, Excludes>): Promise<ConnectionInterface<Entity>>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ConnectionManager = void 0;
|
|
13
|
+
const core_1 = require("@mikro-orm/core");
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const lodash_1 = require("lodash");
|
|
16
|
+
const graphql_connection_constants_1 = require("./graphql-connection.constants");
|
|
17
|
+
const search_syntax_lexer_1 = require("./search-syntax.lexer");
|
|
18
|
+
const search_syntax_parser_1 = require("./search-syntax.parser");
|
|
19
|
+
const search_syntax_visitor_1 = require("./search-syntax.visitor");
|
|
20
|
+
function entityPropertyToSimpleType(type) {
|
|
21
|
+
switch (type) {
|
|
22
|
+
case "boolean":
|
|
23
|
+
case "BooleanType":
|
|
24
|
+
return "boolean";
|
|
25
|
+
case "number":
|
|
26
|
+
case "IntegerType":
|
|
27
|
+
case "SmallIntType":
|
|
28
|
+
case "MediumIntType":
|
|
29
|
+
case "FloatType":
|
|
30
|
+
case "DoubleType":
|
|
31
|
+
return "number";
|
|
32
|
+
case "Date":
|
|
33
|
+
case "DateType":
|
|
34
|
+
case "DateTimeType":
|
|
35
|
+
return "date";
|
|
36
|
+
case "bigint":
|
|
37
|
+
case "BigIntType":
|
|
38
|
+
return "bigint";
|
|
39
|
+
default:
|
|
40
|
+
return "string";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
let ConnectionManager = class ConnectionManager {
|
|
44
|
+
constructor(entityManager) {
|
|
45
|
+
this.entityManager = entityManager;
|
|
46
|
+
}
|
|
47
|
+
convertQueryStringToFilterQuery(connectionMetadata, query) {
|
|
48
|
+
const { entityClass, fieldOptionsMap } = connectionMetadata;
|
|
49
|
+
const entityMetadata = this.entityManager.getMetadata().get(entityClass);
|
|
50
|
+
if (typeof entityMetadata === "undefined") {
|
|
51
|
+
throw new Error("Entity metadata not found");
|
|
52
|
+
}
|
|
53
|
+
const visitor = new search_syntax_visitor_1.SearchSyntaxVisitor(this.entityManager, [...fieldOptionsMap.values()].reduce((result, fieldOptions) => {
|
|
54
|
+
const replacedField = typeof fieldOptions.replacement === "string"
|
|
55
|
+
? fieldOptions.replacement
|
|
56
|
+
: fieldOptions.field;
|
|
57
|
+
const prop = (0, lodash_1.get)(entityMetadata.properties, replacedField.split(".").join(".targetMeta.properties."));
|
|
58
|
+
result.set(fieldOptions.field, {
|
|
59
|
+
field: fieldOptions.field,
|
|
60
|
+
type: fieldOptions.type ??
|
|
61
|
+
entityPropertyToSimpleType(prop?.type),
|
|
62
|
+
replacement: fieldOptions
|
|
63
|
+
.replacement,
|
|
64
|
+
array: fieldOptions.array ?? prop?.array,
|
|
65
|
+
fulltext: fieldOptions.fulltext ??
|
|
66
|
+
entityMetadata.indexes.some(({ type, properties }) => type === "fulltext" && properties === replacedField),
|
|
67
|
+
searchable: fieldOptions.searchable,
|
|
68
|
+
filterable: fieldOptions.filterable,
|
|
69
|
+
});
|
|
70
|
+
return result;
|
|
71
|
+
}, new Map()));
|
|
72
|
+
search_syntax_parser_1.searchSyntaxParser.input = search_syntax_lexer_1.searchSyntaxLexer.tokenize(query).tokens;
|
|
73
|
+
if (search_syntax_parser_1.searchSyntaxParser.errors.length > 0) {
|
|
74
|
+
throw Error(search_syntax_parser_1.searchSyntaxParser.errors[0].message);
|
|
75
|
+
}
|
|
76
|
+
return visitor.visit(search_syntax_parser_1.searchSyntaxParser.query()) ?? {};
|
|
77
|
+
}
|
|
78
|
+
async find(connectionClass, args, options) {
|
|
79
|
+
const connectionMetadata = Reflect.getMetadata(graphql_connection_constants_1.GRAPHQL_CONNECTION_METADATA, connectionClass);
|
|
80
|
+
if (typeof connectionMetadata === "undefined") {
|
|
81
|
+
throw new Error("Connection metadata not found");
|
|
82
|
+
}
|
|
83
|
+
const orderBy = [];
|
|
84
|
+
if (typeof args.orderBy === "undefined") {
|
|
85
|
+
orderBy.push({ id: core_1.QueryOrder.ASC });
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
orderBy.push({
|
|
89
|
+
[args.orderBy.field]: args.orderBy.direction,
|
|
90
|
+
});
|
|
91
|
+
if (args.orderBy.field !== "id") {
|
|
92
|
+
orderBy.push({ id: core_1.QueryOrder.ASC });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
let filterQuery = options?.where ?? {};
|
|
96
|
+
if (typeof args.query !== "undefined" && args.query.trim() !== "") {
|
|
97
|
+
const queryFilterQuery = this.convertQueryStringToFilterQuery(connectionMetadata, args.query);
|
|
98
|
+
filterQuery =
|
|
99
|
+
Object.keys(filterQuery).length === 0
|
|
100
|
+
? queryFilterQuery
|
|
101
|
+
: {
|
|
102
|
+
$and: [filterQuery, queryFilterQuery],
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
const cursor = await this.entityManager.findByCursor(connectionMetadata.entityClass, filterQuery, {
|
|
106
|
+
...options,
|
|
107
|
+
before: args.before,
|
|
108
|
+
after: args.after,
|
|
109
|
+
first: args.first,
|
|
110
|
+
last: args.last,
|
|
111
|
+
orderBy,
|
|
112
|
+
});
|
|
113
|
+
return {
|
|
114
|
+
totalCount: cursor.totalCount,
|
|
115
|
+
edges: cursor.items.map((node) => ({
|
|
116
|
+
node: node,
|
|
117
|
+
cursor: cursor.from(node),
|
|
118
|
+
})),
|
|
119
|
+
pageInfo: {
|
|
120
|
+
hasNextPage: cursor.hasNextPage,
|
|
121
|
+
hasPreviousPage: cursor.hasPrevPage,
|
|
122
|
+
startCursor: cursor.startCursor,
|
|
123
|
+
endCursor: cursor.endCursor,
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
exports.ConnectionManager = ConnectionManager;
|
|
129
|
+
exports.ConnectionManager = ConnectionManager = __decorate([
|
|
130
|
+
(0, common_1.Injectable)(),
|
|
131
|
+
__metadata("design:paramtypes", [core_1.EntityManager])
|
|
132
|
+
], ConnectionManager);
|
|
133
|
+
//# sourceMappingURL=connection.manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.manager.js","sourceRoot":"","sources":["../src/connection.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAKyB;AAGzB,2CAA4C;AAC5C,mCAA6B;AAE7B,iFAA6E;AAS7E,+DAA0D;AAC1D,iEAA4D;AAC5D,mEAA8D;AAG9D,SAAS,0BAA0B,CACjC,IAA4B;IAE5B,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,SAAS,CAAC;QACf,KAAK,aAAa;YAChB,OAAO,SAAS,CAAC;QACnB,KAAK,QAAQ,CAAC;QACd,KAAK,aAAa,CAAC;QACnB,KAAK,cAAc,CAAC;QACpB,KAAK,eAAe,CAAC;QACrB,KAAK,WAAW,CAAC;QACjB,KAAK,YAAY;YACf,OAAO,QAAQ,CAAC;QAClB,KAAK,MAAM,CAAC;QACZ,KAAK,UAAU,CAAC;QAChB,KAAK,cAAc;YACjB,OAAO,MAAM,CAAC;QAChB,KAAK,QAAQ,CAAC;QACd,KAAK,YAAY;YACf,OAAO,QAAQ,CAAC;QAClB;YACE,OAAO,QAAQ,CAAC;IACpB,CAAC;AACH,CAAC;AAeM,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAErD,+BAA+B,CACrC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AS;aAC5B;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAtIY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;qCAEiC,oBAAa;GAD9C,iBAAiB,CAsI7B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComparatorOperator = void 0;
|
|
4
|
+
var ComparatorOperator;
|
|
5
|
+
(function (ComparatorOperator) {
|
|
6
|
+
ComparatorOperator["EQ"] = "$eq";
|
|
7
|
+
ComparatorOperator["LT"] = "$lt";
|
|
8
|
+
ComparatorOperator["GT"] = "$gt";
|
|
9
|
+
ComparatorOperator["LTE"] = "$lte";
|
|
10
|
+
ComparatorOperator["GTE"] = "$gte";
|
|
11
|
+
ComparatorOperator["IN"] = "$in";
|
|
12
|
+
ComparatorOperator["CONTAINS"] = "$contains";
|
|
13
|
+
ComparatorOperator["FULLTEXT"] = "$fulltext";
|
|
14
|
+
ComparatorOperator["LIKE"] = "$like";
|
|
15
|
+
})(ComparatorOperator || (exports.ComparatorOperator = ComparatorOperator = {}));
|
|
16
|
+
//# sourceMappingURL=comparator-operator.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comparator-operator.enum.js","sourceRoot":"","sources":["../../src/enums/comparator-operator.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,kBAUX;AAVD,WAAY,kBAAkB;IAC5B,gCAAU,CAAA;IACV,gCAAU,CAAA;IACV,gCAAU,CAAA;IACV,kCAAY,CAAA;IACZ,kCAAY,CAAA;IACZ,gCAAU,CAAA;IACV,4CAAsB,CAAA;IACtB,4CAAsB,CAAA;IACtB,oCAAc,CAAA;AAChB,CAAC,EAVW,kBAAkB,kCAAlB,kBAAkB,QAU7B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./comparator-operator.enum"), exports);
|
|
18
|
+
__exportStar(require("./order-direction.enum"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/enums/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C;AAC3C,yDAAuC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OrderDirection = void 0;
|
|
4
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
5
|
+
var OrderDirection;
|
|
6
|
+
(function (OrderDirection) {
|
|
7
|
+
OrderDirection["ASC"] = "ASC";
|
|
8
|
+
OrderDirection["DESC"] = "DESC";
|
|
9
|
+
})(OrderDirection || (exports.OrderDirection = OrderDirection = {}));
|
|
10
|
+
(0, graphql_1.registerEnumType)(OrderDirection, { name: "OrderDirection" });
|
|
11
|
+
//# sourceMappingURL=order-direction.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-direction.enum.js","sourceRoot":"","sources":["../../src/enums/order-direction.enum.ts"],"names":[],"mappings":";;;AAAA,6CAAmD;AAEnD,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,6BAAW,CAAA;IACX,+BAAa,CAAA;AACf,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED,IAAA,0BAAgB,EAAC,cAAc,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GRAPHQL_CONNECTION_METADATA: unique symbol;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-connection.constants.js","sourceRoot":"","sources":["../src/graphql-connection.constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,2BAA2B,GAAG,MAAM,CAC/C,6BAA6B,CAC9B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<object, "register", "create", {
|
|
2
|
+
isGlobal: boolean;
|
|
3
|
+
}>, MODULE_OPTIONS_TOKEN: string | symbol, OPTIONS_TYPE: object & Partial<{
|
|
4
|
+
isGlobal: boolean;
|
|
5
|
+
}>, ASYNC_OPTIONS_TYPE: import("@nestjs/common").ConfigurableModuleAsyncOptions<object, "create"> & Partial<{
|
|
6
|
+
isGlobal: boolean;
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ASYNC_OPTIONS_TYPE = exports.OPTIONS_TYPE = exports.MODULE_OPTIONS_TOKEN = exports.ConfigurableModuleClass = void 0;
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
_a = new common_1.ConfigurableModuleBuilder()
|
|
7
|
+
.setExtras({
|
|
8
|
+
isGlobal: true,
|
|
9
|
+
}, (definition, extras) => ({
|
|
10
|
+
...definition,
|
|
11
|
+
global: extras.isGlobal,
|
|
12
|
+
}))
|
|
13
|
+
.build(), exports.ConfigurableModuleClass = _a.ConfigurableModuleClass, exports.MODULE_OPTIONS_TOKEN = _a.MODULE_OPTIONS_TOKEN, exports.OPTIONS_TYPE = _a.OPTIONS_TYPE, exports.ASYNC_OPTIONS_TYPE = _a.ASYNC_OPTIONS_TYPE;
|
|
14
|
+
//# sourceMappingURL=graphql-connection.module-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-connection.module-definition.js","sourceRoot":"","sources":["../src/graphql-connection.module-definition.ts"],"names":[],"mappings":";;;;AAAA,2CAA2D;AAE9C,KAKT,IAAI,kCAAyB,EAAU;KACxC,SAAS,CACR;IACE,QAAQ,EAAE,IAAI;CACf,EACD,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IACvB,GAAG,UAAU;IACb,MAAM,EAAE,MAAM,CAAC,QAAQ;CACxB,CAAC,CACH;KACA,KAAK,EAAE,EAdR,+BAAuB,+BACvB,4BAAoB,4BACpB,oBAAY,oBACZ,0BAAkB,yBAWT"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.GraphqlConnectionModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const connection_manager_1 = require("./connection.manager");
|
|
12
|
+
const graphql_connection_module_definition_1 = require("./graphql-connection.module-definition");
|
|
13
|
+
let GraphqlConnectionModule = class GraphqlConnectionModule extends graphql_connection_module_definition_1.ConfigurableModuleClass {
|
|
14
|
+
};
|
|
15
|
+
exports.GraphqlConnectionModule = GraphqlConnectionModule;
|
|
16
|
+
exports.GraphqlConnectionModule = GraphqlConnectionModule = __decorate([
|
|
17
|
+
(0, common_1.Module)({
|
|
18
|
+
providers: [connection_manager_1.ConnectionManager],
|
|
19
|
+
exports: [connection_manager_1.ConnectionManager],
|
|
20
|
+
})
|
|
21
|
+
], GraphqlConnectionModule);
|
|
22
|
+
//# sourceMappingURL=graphql-connection.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-connection.module.js","sourceRoot":"","sources":["../src/graphql-connection.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AAExC,6DAAyD;AACzD,iGAAiF;AAM1E,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,8DAAuB;CAAG,CAAA;AAA1D,0DAAuB;kCAAvB,uBAAuB;IAJnC,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,sCAAiB,CAAC;QAC9B,OAAO,EAAE,CAAC,sCAAiB,CAAC;KAC7B,CAAC;GACW,uBAAuB,CAAmC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./connection.builder"), exports);
|
|
18
|
+
__exportStar(require("./connection.manager"), exports);
|
|
19
|
+
__exportStar(require("./enums"), exports);
|
|
20
|
+
__exportStar(require("./graphql-connection.module"), exports);
|
|
21
|
+
__exportStar(require("./interfaces"), exports);
|
|
22
|
+
__exportStar(require("./objects"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,uDAAqC;AACrC,0CAAwB;AACxB,8DAA4C;AAC5C,+CAA6B;AAC7B,4CAA0B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FindByCursorOptions } from "@mikro-orm/core/drivers";
|
|
2
|
+
import { OrderInterface } from "./order.interface";
|
|
3
|
+
export interface ConnectionArgsInterface<Entity extends object, Hint extends string = never, Fields extends string = "*", Excludes extends string = never> extends Pick<FindByCursorOptions<Entity, Hint, Fields, Excludes>, "before" | "after" | "first" | "last"> {
|
|
4
|
+
query?: string;
|
|
5
|
+
orderBy?: OrderInterface<Entity>;
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-args.interface.js","sourceRoot":"","sources":["../../src/interfaces/connection-args.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EntityClass } from "@mikro-orm/core";
|
|
2
|
+
import { FieldOptions } from "./field-options.interface";
|
|
3
|
+
export interface ConnectionMetadata<Entity extends object> {
|
|
4
|
+
entityClass: EntityClass<Entity>;
|
|
5
|
+
fieldOptionsMap: Map<string, FieldOptions<Entity, any, any>>;
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-metadata.interface.js","sourceRoot":"","sources":["../../src/interfaces/connection-metadata.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.interface.js","sourceRoot":"","sources":["../../src/interfaces/connection.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge.interface.js","sourceRoot":"","sources":["../../src/interfaces/edge.interface.ts"],"names":[],"mappings":""}
|