@memberjunction/server 0.9.3 → 0.9.5
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/.eslintignore +5 -6
- package/.eslintrc +24 -24
- package/README.md +141 -141
- package/config.json +14 -14
- package/dist/apolloServer/TransactionPlugin.js +45 -45
- package/dist/apolloServer/index.js +26 -26
- package/dist/auth/exampleNewUserSubClass.js +67 -67
- package/dist/auth/index.js +87 -87
- package/dist/auth/newUsers.js +66 -66
- package/dist/cache.js +10 -10
- package/dist/config.js +55 -55
- package/dist/context.js +100 -100
- package/dist/directives/Public.js +33 -33
- package/dist/directives/index.js +17 -17
- package/dist/generated/generated.js +19245 -0
- package/dist/generated/generated.js.map +1 -0
- package/dist/generic/PushStatusResolver.js +59 -0
- package/dist/generic/PushStatusResolver.js.map +1 -0
- package/dist/generic/ResolverBase.js +187 -0
- package/dist/generic/ResolverBase.js.map +1 -0
- package/dist/generic/RunViewResolver.js +308 -0
- package/dist/generic/RunViewResolver.js.map +1 -0
- package/dist/index.js +114 -114
- package/dist/index.js.map +1 -1
- package/dist/orm.js +21 -22
- package/dist/orm.js.map +1 -1
- package/dist/resolvers/AskSkipResolver.js +244 -0
- package/dist/resolvers/AskSkipResolver.js.map +1 -0
- package/dist/resolvers/ColorResolver.js +95 -0
- package/dist/resolvers/ColorResolver.js.map +1 -0
- package/dist/resolvers/DatasetResolver.js +168 -0
- package/dist/resolvers/DatasetResolver.js.map +1 -0
- package/dist/resolvers/EntityRecordNameResolver.js +108 -0
- package/dist/resolvers/EntityRecordNameResolver.js.map +1 -0
- package/dist/resolvers/EntityResolver.js +60 -0
- package/dist/resolvers/EntityResolver.js.map +1 -0
- package/dist/resolvers/ReportResolver.js +74 -0
- package/dist/resolvers/ReportResolver.js.map +1 -0
- package/dist/resolvers/UserFavoriteResolver.js +188 -0
- package/dist/resolvers/UserFavoriteResolver.js.map +1 -0
- package/dist/resolvers/UserResolver.js +70 -0
- package/dist/resolvers/UserResolver.js.map +1 -0
- package/dist/resolvers/UserViewResolver.js +104 -0
- package/dist/resolvers/UserViewResolver.js.map +1 -0
- package/dist/types.js +2 -2
- package/package.json +74 -74
- package/src/apolloServer/TransactionPlugin.ts +54 -54
- package/src/apolloServer/index.ts +33 -33
- package/src/auth/exampleNewUserSubClass.ts +70 -70
- package/src/auth/index.ts +117 -117
- package/src/auth/newUsers.ts +55 -55
- package/src/cache.ts +10 -10
- package/src/config.ts +67 -67
- package/src/context.ts +105 -105
- package/src/directives/Public.ts +42 -42
- package/src/directives/index.ts +1 -1
- package/src/index.ts +105 -104
- package/src/orm.ts +23 -20
- package/src/types.ts +19 -19
|
@@ -0,0 +1,188 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.UserFavoriteResolver = exports.UserFavoriteResult = exports.UserFavoriteSetParams = exports.UserFavoriteSearchParams = void 0;
|
|
16
|
+
const type_graphql_1 = require("type-graphql");
|
|
17
|
+
const generated_1 = require("../generated/generated");
|
|
18
|
+
const generated_2 = require("../generated/generated");
|
|
19
|
+
const core_1 = require("@memberjunction/core");
|
|
20
|
+
const sqlserver_dataprovider_1 = require("@memberjunction/sqlserver-dataprovider");
|
|
21
|
+
let UserFavoriteSearchParams = class UserFavoriteSearchParams {
|
|
22
|
+
};
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, type_graphql_1.Field)(() => type_graphql_1.Int),
|
|
25
|
+
__metadata("design:type", Number)
|
|
26
|
+
], UserFavoriteSearchParams.prototype, "EntityID", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, type_graphql_1.Field)(() => type_graphql_1.Int),
|
|
29
|
+
__metadata("design:type", Number)
|
|
30
|
+
], UserFavoriteSearchParams.prototype, "RecordID", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, type_graphql_1.Field)(() => type_graphql_1.Int),
|
|
33
|
+
__metadata("design:type", Number)
|
|
34
|
+
], UserFavoriteSearchParams.prototype, "UserID", void 0);
|
|
35
|
+
UserFavoriteSearchParams = __decorate([
|
|
36
|
+
(0, type_graphql_1.InputType)()
|
|
37
|
+
], UserFavoriteSearchParams);
|
|
38
|
+
exports.UserFavoriteSearchParams = UserFavoriteSearchParams;
|
|
39
|
+
let UserFavoriteSetParams = class UserFavoriteSetParams {
|
|
40
|
+
};
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, type_graphql_1.Field)(() => type_graphql_1.Int),
|
|
43
|
+
__metadata("design:type", Number)
|
|
44
|
+
], UserFavoriteSetParams.prototype, "EntityID", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, type_graphql_1.Field)(() => type_graphql_1.Int),
|
|
47
|
+
__metadata("design:type", Number)
|
|
48
|
+
], UserFavoriteSetParams.prototype, "RecordID", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, type_graphql_1.Field)(() => type_graphql_1.Int),
|
|
51
|
+
__metadata("design:type", Number)
|
|
52
|
+
], UserFavoriteSetParams.prototype, "UserID", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, type_graphql_1.Field)(() => Boolean),
|
|
55
|
+
__metadata("design:type", Boolean)
|
|
56
|
+
], UserFavoriteSetParams.prototype, "IsFavorite", void 0);
|
|
57
|
+
UserFavoriteSetParams = __decorate([
|
|
58
|
+
(0, type_graphql_1.InputType)()
|
|
59
|
+
], UserFavoriteSetParams);
|
|
60
|
+
exports.UserFavoriteSetParams = UserFavoriteSetParams;
|
|
61
|
+
let UserFavoriteResult = class UserFavoriteResult {
|
|
62
|
+
};
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, type_graphql_1.Field)(() => type_graphql_1.Int),
|
|
65
|
+
__metadata("design:type", Number)
|
|
66
|
+
], UserFavoriteResult.prototype, "EntityID", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, type_graphql_1.Field)(() => type_graphql_1.Int),
|
|
69
|
+
__metadata("design:type", Number)
|
|
70
|
+
], UserFavoriteResult.prototype, "RecordID", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, type_graphql_1.Field)(() => type_graphql_1.Int),
|
|
73
|
+
__metadata("design:type", Number)
|
|
74
|
+
], UserFavoriteResult.prototype, "UserID", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
(0, type_graphql_1.Field)(() => Boolean),
|
|
77
|
+
__metadata("design:type", Boolean)
|
|
78
|
+
], UserFavoriteResult.prototype, "IsFavorite", void 0);
|
|
79
|
+
__decorate([
|
|
80
|
+
(0, type_graphql_1.Field)(() => Boolean),
|
|
81
|
+
__metadata("design:type", Boolean)
|
|
82
|
+
], UserFavoriteResult.prototype, "Success", void 0);
|
|
83
|
+
UserFavoriteResult = __decorate([
|
|
84
|
+
(0, type_graphql_1.ObjectType)()
|
|
85
|
+
], UserFavoriteResult);
|
|
86
|
+
exports.UserFavoriteResult = UserFavoriteResult;
|
|
87
|
+
let UserFavoriteResolver = class UserFavoriteResolver extends generated_2.UserFavoriteResolverBase {
|
|
88
|
+
UserFavoritesByUserID(UserID, { dataSource }) {
|
|
89
|
+
return dataSource.getRepository(generated_1.UserFavorite_).findBy({ UserID });
|
|
90
|
+
}
|
|
91
|
+
UserFavoriteSearchByParams(params, { dataSource }) {
|
|
92
|
+
return dataSource.getRepository(generated_1.UserFavorite_).findBy(params);
|
|
93
|
+
}
|
|
94
|
+
GetRecordFavoriteStatus(params, {}) {
|
|
95
|
+
const md = new core_1.Metadata();
|
|
96
|
+
const e = md.Entities.find(e => e.ID === params.EntityID);
|
|
97
|
+
if (e)
|
|
98
|
+
return {
|
|
99
|
+
EntityID: params.EntityID,
|
|
100
|
+
UserID: params.UserID,
|
|
101
|
+
RecordID: params.RecordID,
|
|
102
|
+
IsFavorite: md.GetRecordFavoriteStatus(params.UserID, e.Name, params.RecordID),
|
|
103
|
+
Success: true
|
|
104
|
+
};
|
|
105
|
+
else
|
|
106
|
+
throw new Error(`Entity ID:${params.EntityID} not found`);
|
|
107
|
+
}
|
|
108
|
+
SetRecordFavoriteStatus(params, { userPayload }) {
|
|
109
|
+
const md = new core_1.Metadata();
|
|
110
|
+
const e = md.Entities.find(e => e.ID === params.EntityID);
|
|
111
|
+
const u = sqlserver_dataprovider_1.UserCache.Users.find(u => u.ID === userPayload.userRecord.ID);
|
|
112
|
+
if (e) {
|
|
113
|
+
md.SetRecordFavoriteStatus(params.UserID, e.Name, params.RecordID, params.IsFavorite, u);
|
|
114
|
+
return {
|
|
115
|
+
Success: true,
|
|
116
|
+
EntityID: params.EntityID,
|
|
117
|
+
UserID: params.UserID,
|
|
118
|
+
RecordID: params.RecordID,
|
|
119
|
+
IsFavorite: params.IsFavorite
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
else
|
|
123
|
+
throw new Error(`Entity ID:${params.EntityID} not found`);
|
|
124
|
+
}
|
|
125
|
+
AddUserFavorite(input, { dataSource, userPayload }) {
|
|
126
|
+
return dataSource.transaction(async (manager) => {
|
|
127
|
+
const [existing] = await manager.getRepository(generated_1.UserFavorite_).findBy(input);
|
|
128
|
+
if (existing)
|
|
129
|
+
return existing;
|
|
130
|
+
const md = new core_1.Metadata();
|
|
131
|
+
const ufEntity = await md.GetEntityObject('User Favorites', userPayload.userRecord);
|
|
132
|
+
ufEntity.NewRecord();
|
|
133
|
+
ufEntity.EntityID = input.EntityID;
|
|
134
|
+
ufEntity.RecordID = input.RecordID;
|
|
135
|
+
ufEntity.UserID = input.UserID;
|
|
136
|
+
if (await ufEntity.Save())
|
|
137
|
+
return ufEntity.GetAll();
|
|
138
|
+
else
|
|
139
|
+
throw new Error('Error saving user favorite');
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
__decorate([
|
|
144
|
+
(0, type_graphql_1.Query)(() => [generated_1.UserFavorite_]),
|
|
145
|
+
__param(0, (0, type_graphql_1.Arg)('UserID', () => type_graphql_1.Int)),
|
|
146
|
+
__param(1, (0, type_graphql_1.Ctx)()),
|
|
147
|
+
__metadata("design:type", Function),
|
|
148
|
+
__metadata("design:paramtypes", [Number, Object]),
|
|
149
|
+
__metadata("design:returntype", void 0)
|
|
150
|
+
], UserFavoriteResolver.prototype, "UserFavoritesByUserID", null);
|
|
151
|
+
__decorate([
|
|
152
|
+
(0, type_graphql_1.Query)(() => [generated_1.UserFavorite_]),
|
|
153
|
+
__param(0, (0, type_graphql_1.Arg)('params', () => type_graphql_1.Int)),
|
|
154
|
+
__param(1, (0, type_graphql_1.Ctx)()),
|
|
155
|
+
__metadata("design:type", Function),
|
|
156
|
+
__metadata("design:paramtypes", [UserFavoriteSearchParams, Object]),
|
|
157
|
+
__metadata("design:returntype", void 0)
|
|
158
|
+
], UserFavoriteResolver.prototype, "UserFavoriteSearchByParams", null);
|
|
159
|
+
__decorate([
|
|
160
|
+
(0, type_graphql_1.Query)(() => UserFavoriteResult),
|
|
161
|
+
__param(0, (0, type_graphql_1.Arg)('params', () => UserFavoriteSearchParams)),
|
|
162
|
+
__param(1, (0, type_graphql_1.Ctx)()),
|
|
163
|
+
__metadata("design:type", Function),
|
|
164
|
+
__metadata("design:paramtypes", [UserFavoriteSearchParams, Object]),
|
|
165
|
+
__metadata("design:returntype", void 0)
|
|
166
|
+
], UserFavoriteResolver.prototype, "GetRecordFavoriteStatus", null);
|
|
167
|
+
__decorate([
|
|
168
|
+
(0, type_graphql_1.Mutation)(() => UserFavoriteResult),
|
|
169
|
+
__param(0, (0, type_graphql_1.Arg)('params', () => UserFavoriteSetParams)),
|
|
170
|
+
__param(1, (0, type_graphql_1.Ctx)()),
|
|
171
|
+
__metadata("design:type", Function),
|
|
172
|
+
__metadata("design:paramtypes", [UserFavoriteSetParams, Object]),
|
|
173
|
+
__metadata("design:returntype", void 0)
|
|
174
|
+
], UserFavoriteResolver.prototype, "SetRecordFavoriteStatus", null);
|
|
175
|
+
__decorate([
|
|
176
|
+
(0, type_graphql_1.Mutation)(() => generated_1.UserFavorite_),
|
|
177
|
+
__param(0, (0, type_graphql_1.Arg)('input', () => UserFavoriteSearchParams)),
|
|
178
|
+
__param(1, (0, type_graphql_1.Ctx)()),
|
|
179
|
+
__metadata("design:type", Function),
|
|
180
|
+
__metadata("design:paramtypes", [UserFavoriteSearchParams, Object]),
|
|
181
|
+
__metadata("design:returntype", void 0)
|
|
182
|
+
], UserFavoriteResolver.prototype, "AddUserFavorite", null);
|
|
183
|
+
UserFavoriteResolver = __decorate([
|
|
184
|
+
(0, type_graphql_1.Resolver)(generated_1.UserFavorite_)
|
|
185
|
+
], UserFavoriteResolver);
|
|
186
|
+
exports.UserFavoriteResolver = UserFavoriteResolver;
|
|
187
|
+
exports.default = UserFavoriteResolver;
|
|
188
|
+
//# sourceMappingURL=UserFavoriteResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserFavoriteResolver.js","sourceRoot":"","sources":["../../src/resolvers/UserFavoriteResolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAsG;AACtG,sDAAuD;AAEvD,sDAA2F;AAC3F,+CAAgD;AA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B,CAAC,CAAA;IAC5C,WAAA,IAAA,kBAAG,GAAE,CAAA;;qCAD+C,wBAAwB;;2DAoB9E;AArEU,oBAAoB;IADhC,IAAA,uBAAQ,EAAC,yBAAa,CAAC;GACX,oBAAoB,CAsEhC;AAtEY,oDAAoB;AAwEjC,kBAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.UserResolver = void 0;
|
|
16
|
+
const type_graphql_1 = require("type-graphql");
|
|
17
|
+
const config_1 = require("../config");
|
|
18
|
+
const generated_1 = require("../generated/generated");
|
|
19
|
+
let UserResolver = class UserResolver extends generated_1.UserResolverBase {
|
|
20
|
+
async CurrentUser({ dataSource, userPayload }) {
|
|
21
|
+
return await this.UserByEmail(userPayload.email, { dataSource, userPayload });
|
|
22
|
+
}
|
|
23
|
+
async UserByID(ID, { dataSource }) {
|
|
24
|
+
return super.safeFirstArrayElement(await dataSource.getRepository(generated_1.User_).findBy({ ID }));
|
|
25
|
+
}
|
|
26
|
+
async UserByEmployeeID(EmployeeID, { dataSource }) {
|
|
27
|
+
return super.safeFirstArrayElement(await dataSource.getRepository(generated_1.User_).findBy({ EmployeeID }));
|
|
28
|
+
}
|
|
29
|
+
async UserByEmail(Email, { dataSource }) {
|
|
30
|
+
const searchEmail = config_1.userEmailMap[Email] ?? Email;
|
|
31
|
+
return super.safeFirstArrayElement(await dataSource.getRepository(generated_1.User_).findBy({ Email: searchEmail }));
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, type_graphql_1.Query)(() => generated_1.User_),
|
|
36
|
+
__param(0, (0, type_graphql_1.Ctx)()),
|
|
37
|
+
__metadata("design:type", Function),
|
|
38
|
+
__metadata("design:paramtypes", [Object]),
|
|
39
|
+
__metadata("design:returntype", Promise)
|
|
40
|
+
], UserResolver.prototype, "CurrentUser", null);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, type_graphql_1.Query)(() => generated_1.User_),
|
|
43
|
+
__param(0, (0, type_graphql_1.Arg)('ID', () => type_graphql_1.Int)),
|
|
44
|
+
__param(1, (0, type_graphql_1.Ctx)()),
|
|
45
|
+
__metadata("design:type", Function),
|
|
46
|
+
__metadata("design:paramtypes", [Number, Object]),
|
|
47
|
+
__metadata("design:returntype", Promise)
|
|
48
|
+
], UserResolver.prototype, "UserByID", null);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, type_graphql_1.Query)(() => generated_1.User_),
|
|
51
|
+
__param(0, (0, type_graphql_1.Arg)('EmployeeID', () => type_graphql_1.Int)),
|
|
52
|
+
__param(1, (0, type_graphql_1.Ctx)()),
|
|
53
|
+
__metadata("design:type", Function),
|
|
54
|
+
__metadata("design:paramtypes", [Number, Object]),
|
|
55
|
+
__metadata("design:returntype", Promise)
|
|
56
|
+
], UserResolver.prototype, "UserByEmployeeID", null);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, type_graphql_1.Query)(() => generated_1.User_),
|
|
59
|
+
__param(0, (0, type_graphql_1.Arg)('Email', () => String)),
|
|
60
|
+
__param(1, (0, type_graphql_1.Ctx)()),
|
|
61
|
+
__metadata("design:type", Function),
|
|
62
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
63
|
+
__metadata("design:returntype", Promise)
|
|
64
|
+
], UserResolver.prototype, "UserByEmail", null);
|
|
65
|
+
UserResolver = __decorate([
|
|
66
|
+
(0, type_graphql_1.Resolver)(generated_1.User_)
|
|
67
|
+
], UserResolver);
|
|
68
|
+
exports.UserResolver = UserResolver;
|
|
69
|
+
exports.default = UserResolver;
|
|
70
|
+
//# sourceMappingURL=UserResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserResolver.js","sourceRoot":"","sources":["../../src/resolvers/UserResolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAA8D;AAC9D,sCAAyC;AACzC,sDAAiE;AAM1D,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,4BAAgB;IAE1C,AAAN,KAAK,CAAC,WAAW,CAAQ,EAAE,UAAU,EAAE,WAAW,EAAc;QAC9D,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;IAChF,CAAC;IAGK,AAAN,KAAK,CAAC,QAAQ,CAAuB,EAAU,EAAS,EAAE,UAAU,EAAc;QAChF,OAAO,KAAK,CAAC,qBAAqB,CAAC,MAAM,UAAU,CAAC,aAAa,CAAC,iBAAK,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3F,CAAC;IAGK,AAAN,KAAK,CAAC,gBAAgB,CACU,UAAkB,EACzC,EAAE,UAAU,EAAc;QAEjC,OAAO,KAAK,CAAC,qBAAqB,CAAC,MAAM,UAAU,CAAC,aAAa,CAAC,iBAAK,CAAC,CAAC,MAAM,CAAC,EAAE,U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, 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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.UserViewResolver = void 0;
|
|
16
|
+
const type_graphql_1 = require("type-graphql");
|
|
17
|
+
const generated_1 = require("../generated/generated");
|
|
18
|
+
const UserResolver_1 = require("./UserResolver");
|
|
19
|
+
const core_1 = require("@memberjunction/core");
|
|
20
|
+
let UserViewResolver = class UserViewResolver extends generated_1.UserViewResolverBase {
|
|
21
|
+
UserViewsByUserID(UserID, { dataSource }) {
|
|
22
|
+
return dataSource.getRepository(generated_1.UserView_).findBy({ UserID });
|
|
23
|
+
}
|
|
24
|
+
async DefaultViewByUserAndEntity(UserID, EntityID, { dataSource }) {
|
|
25
|
+
return dataSource.getRepository(generated_1.UserView_).findBy({ UserID, EntityID, IsDefault: true });
|
|
26
|
+
}
|
|
27
|
+
async CurrentUserDefaultViewByEntityID(EntityID, { dataSource, userPayload }) {
|
|
28
|
+
return dataSource.getRepository(generated_1.UserView_).findBy({
|
|
29
|
+
UserID: await this.getCurrentUserID(dataSource, userPayload),
|
|
30
|
+
EntityID,
|
|
31
|
+
IsDefault: true,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async getCurrentUserID(dataSource, userPayload) {
|
|
35
|
+
const userResolver = new UserResolver_1.UserResolver();
|
|
36
|
+
const user = await userResolver.UserByEmail(userPayload.email, { dataSource, userPayload });
|
|
37
|
+
return user.ID;
|
|
38
|
+
}
|
|
39
|
+
async CurrentUserUserViewsByEntityID(EntityID, { dataSource, userPayload }) {
|
|
40
|
+
return dataSource
|
|
41
|
+
.getRepository(generated_1.UserView_)
|
|
42
|
+
.findBy({ UserID: await this.getCurrentUserID(dataSource, userPayload), EntityID });
|
|
43
|
+
}
|
|
44
|
+
async UpdateWhereClause(ID, { userPayload }) {
|
|
45
|
+
const md = new core_1.Metadata();
|
|
46
|
+
const u = this.GetUserFromPayload(userPayload);
|
|
47
|
+
const viewEntity = await md.GetEntityObject('User Views', u);
|
|
48
|
+
await viewEntity.Load(ID);
|
|
49
|
+
viewEntity.UpdateWhereClause();
|
|
50
|
+
if (await viewEntity.Save()) {
|
|
51
|
+
return viewEntity.GetAll();
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
throw new Error('Failed to update where clause');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, type_graphql_1.Query)(() => [generated_1.UserView_]),
|
|
60
|
+
__param(0, (0, type_graphql_1.Arg)('UserID', () => type_graphql_1.Int)),
|
|
61
|
+
__param(1, (0, type_graphql_1.Ctx)()),
|
|
62
|
+
__metadata("design:type", Function),
|
|
63
|
+
__metadata("design:paramtypes", [Number, Object]),
|
|
64
|
+
__metadata("design:returntype", void 0)
|
|
65
|
+
], UserViewResolver.prototype, "UserViewsByUserID", null);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, type_graphql_1.Query)(() => [generated_1.UserView_]),
|
|
68
|
+
__param(0, (0, type_graphql_1.Arg)('UserID', () => type_graphql_1.Int)),
|
|
69
|
+
__param(1, (0, type_graphql_1.Arg)('EntityID', () => type_graphql_1.Int)),
|
|
70
|
+
__param(2, (0, type_graphql_1.Ctx)()),
|
|
71
|
+
__metadata("design:type", Function),
|
|
72
|
+
__metadata("design:paramtypes", [Number, Number, Object]),
|
|
73
|
+
__metadata("design:returntype", Promise)
|
|
74
|
+
], UserViewResolver.prototype, "DefaultViewByUserAndEntity", null);
|
|
75
|
+
__decorate([
|
|
76
|
+
(0, type_graphql_1.Query)(() => [generated_1.UserView_]),
|
|
77
|
+
__param(0, (0, type_graphql_1.Arg)('EntityID', () => type_graphql_1.Int)),
|
|
78
|
+
__param(1, (0, type_graphql_1.Ctx)()),
|
|
79
|
+
__metadata("design:type", Function),
|
|
80
|
+
__metadata("design:paramtypes", [Number, Object]),
|
|
81
|
+
__metadata("design:returntype", Promise)
|
|
82
|
+
], UserViewResolver.prototype, "CurrentUserDefaultViewByEntityID", null);
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, type_graphql_1.Query)(() => [generated_1.UserView_]),
|
|
85
|
+
__param(0, (0, type_graphql_1.Arg)('EntityID', () => type_graphql_1.Int)),
|
|
86
|
+
__param(1, (0, type_graphql_1.Ctx)()),
|
|
87
|
+
__metadata("design:type", Function),
|
|
88
|
+
__metadata("design:paramtypes", [Number, Object]),
|
|
89
|
+
__metadata("design:returntype", Promise)
|
|
90
|
+
], UserViewResolver.prototype, "CurrentUserUserViewsByEntityID", null);
|
|
91
|
+
__decorate([
|
|
92
|
+
(0, type_graphql_1.Query)(() => [generated_1.UserView_]),
|
|
93
|
+
__param(0, (0, type_graphql_1.Arg)('ID', () => type_graphql_1.Int)),
|
|
94
|
+
__param(1, (0, type_graphql_1.Ctx)()),
|
|
95
|
+
__metadata("design:type", Function),
|
|
96
|
+
__metadata("design:paramtypes", [Number, Object]),
|
|
97
|
+
__metadata("design:returntype", Promise)
|
|
98
|
+
], UserViewResolver.prototype, "UpdateWhereClause", null);
|
|
99
|
+
UserViewResolver = __decorate([
|
|
100
|
+
(0, type_graphql_1.Resolver)(generated_1.UserView_)
|
|
101
|
+
], UserViewResolver);
|
|
102
|
+
exports.UserViewResolver = UserViewResolver;
|
|
103
|
+
exports.default = UserViewResolver;
|
|
104
|
+
//# sourceMappingURL=UserViewResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserViewResolver.js","sourceRoot":"","sources":["../../src/resolvers/UserViewResolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,+CAA8D;AAE9D,sDAGgC;AAEhC,iDAA8C;AAC9C,+CAAgD;AAGzC,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,gCAAoB;IAExD,iBAAiB,CAA2B,MAAc,EAAS,EAAE,UAAU,EAAc;QAC3F,OAAO,UAAU,CAAC,aAAa,CAAC,qBAAS,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAChE,CAAC;IAGK,AAAN,KAAK,CAAC,0BAA0B,CACJ,MAAc,EACZ,QAAgB,EACrC,EAAE,UAAU,EAAc;QAEjC,OAAO,UAAU,CAAC,aAAa,CAAC,qBAAS,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3F,CAAC;IAGK,AAAN,KAAK,CAAC,gCAAgC,CACR,QAAgB,EACrC,EAAE,UAAU,EAAE,WAAW,EAAc;QAE9C,OAAO,UAAU,CAAC,aAAa,CAAC,qBAAS,CAAC,CAAC,MAAM,CAAC;YAChD,MAAM,EAAE,MAAM,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,WAAW,CAAC;YAC5D,QAAQ;YACR,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;IAES,KAAK,CAAC,gBAAgB,CAC9B,UAAsB,EACtB,WAAwB;QAExB,MAAM,YAAY,GAAG,IAAI,2BAAY,EAAE,CAAC;QACxC,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,WAAW,CAAC,WAAW,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G,EAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,kBAAG,CAAC,CAAA;IACxB,WAAA,IAAA,kBAAG,EAAC,UAAU,EAAE,GAAG,EAAE,CAAC,kBAAG,CAAC,CAAA;IAC1B,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;kEAGP;AAGK;IADL,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,CAAC,qBAAS,CAAC,CAAC;IAEtB,WAAA,IAAA,kBAAG,EAAC,UAAU,EAAE,GAAG,EAAE,CAAC,kBAAG,CAAC,CAAA;IAC1B,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;wEAOP;AAYK;IADL,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,CAAC,qBAAS,CAAC,CAAC;IAEtB,WAAA,IAAA,kBAAG,EAAC,UAAU,EAAE,GAAG,EAAE,CAAC,kBAAG,CAAC,CAAA;IAC1B,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;sEAKP;AAGK;IADL,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,CAAC,qBAAS,CAAC,CAAC;IACA,WAAA,IAAA,kBAAG,EAAC,IAAI,EAAE,GAAG,EAAE,CAAC,kBAAG,CAAC,CAAA;IAAc,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;yDAgB/D;AA/DU,gBAAgB;IAD5B,IAAA,uBAAQ,EAAC,qBAAS,CAAC;GACP,gBAAgB,CAgE5B;AAhEY,4CAAgB;AAkE7B,kBAAe,gBAAgB,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=types.js.map
|
package/package.json
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@memberjunction/server",
|
|
3
|
-
"version": "0.9.
|
|
4
|
-
"description": "MemberJunction: This project provides API access via GraphQL to the common data store.",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "src/index.ts",
|
|
7
|
-
"author": "MemberJunction.com",
|
|
8
|
-
"license": "ISC",
|
|
9
|
-
"scripts": {
|
|
10
|
-
"clean": "rimraf dist",
|
|
11
|
-
"build": "rimraf dist && tsc",
|
|
12
|
-
"watch": "tsc -w",
|
|
13
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
14
|
-
"lint:eslint": "eslint \"**/*.{ts,js,}\" --max-warnings=0",
|
|
15
|
-
"lint:tsc": "tsc --noemit",
|
|
16
|
-
"lint": "concurrently \"npm:lint:eslint\" \"npm:lint:tsc\"",
|
|
17
|
-
"pretty": "prettier --write \"**/*.{ts,js,}\"",
|
|
18
|
-
"codegen": "cpy --flat ../codegen/output/entities/*.ts src/entities",
|
|
19
|
-
"postcodegen": "npm run pretty"
|
|
20
|
-
},
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"@apollo/server": "^4.9.1",
|
|
23
|
-
"@graphql-tools/utils": "^10.0.1",
|
|
24
|
-
"@memberjunction/ai": "^0.9.
|
|
25
|
-
"@memberjunction/core": "^0.9.
|
|
26
|
-
"@memberjunction/global": "^0.9.
|
|
27
|
-
"@memberjunction/queue": "^0.9.
|
|
28
|
-
"@memberjunction/sqlserver-dataprovider": "^0.9.
|
|
29
|
-
"@types/axios": "^0.14.0",
|
|
30
|
-
"@types/cors": "^2.8.13",
|
|
31
|
-
"@types/jsonwebtoken": "^8.5.9",
|
|
32
|
-
"@types/node": "^18.11.14",
|
|
33
|
-
"@types/ws": "^8.5.5",
|
|
34
|
-
"axios": "^1.4.0",
|
|
35
|
-
"body-parser": "^1.20.2",
|
|
36
|
-
"class-validator": "^0.14.0",
|
|
37
|
-
"cors": "^2.8.5",
|
|
38
|
-
"dotenv": "^16.0.3",
|
|
39
|
-
"env-var": "^7.3.0",
|
|
40
|
-
"express": "^4.18.2",
|
|
41
|
-
"fast-glob": "^3.3.1",
|
|
42
|
-
"graphql": "^16.8.0",
|
|
43
|
-
"graphql-ws": "^5.14.0",
|
|
44
|
-
"jsonwebtoken": "^8.5.1",
|
|
45
|
-
"jwks-rsa": "^3.0.0",
|
|
46
|
-
"lru-cache": "^10.0.0",
|
|
47
|
-
"mssql": "^9.1.1",
|
|
48
|
-
"reflect-metadata": "^0.1.13",
|
|
49
|
-
"rxjs": "^7.8.1",
|
|
50
|
-
"type-graphql": "^2.0.0-beta.3",
|
|
51
|
-
"typedi": "^0.10.0",
|
|
52
|
-
"typeorm": "^0.3.13",
|
|
53
|
-
"ws": "^8.13.0",
|
|
54
|
-
"zod": "^3.22.4"
|
|
55
|
-
},
|
|
56
|
-
"devDependencies": {
|
|
57
|
-
"@typescript-eslint/eslint-plugin": "^5.46.1",
|
|
58
|
-
"@typescript-eslint/parser": "^5.46.1",
|
|
59
|
-
"concurrently": "^7.6.0",
|
|
60
|
-
"cpy-cli": "^4.2.0",
|
|
61
|
-
"eslint": "^8.29.0",
|
|
62
|
-
"eslint-config-airbnb": "^19.0.4",
|
|
63
|
-
"eslint-config-prettier": "^8.5.0",
|
|
64
|
-
"eslint-import-resolver-typescript": "^3.5.2",
|
|
65
|
-
"eslint-plugin-import": "^2.26.0",
|
|
66
|
-
"eslint-plugin-jsx-a11y": "^6.6.1",
|
|
67
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
68
|
-
"prettier": "^2.8.1",
|
|
69
|
-
"rimraf": "^4.4.0",
|
|
70
|
-
"ts-node": "^10.9.1",
|
|
71
|
-
"ts-node-dev": "^2.0.0",
|
|
72
|
-
"typescript": "^4.9.4"
|
|
73
|
-
}
|
|
74
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@memberjunction/server",
|
|
3
|
+
"version": "0.9.5",
|
|
4
|
+
"description": "MemberJunction: This project provides API access via GraphQL to the common data store.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "src/index.ts",
|
|
7
|
+
"author": "MemberJunction.com",
|
|
8
|
+
"license": "ISC",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"clean": "rimraf dist",
|
|
11
|
+
"build": "rimraf dist && tsc",
|
|
12
|
+
"watch": "tsc -w",
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
14
|
+
"lint:eslint": "eslint \"**/*.{ts,js,}\" --max-warnings=0",
|
|
15
|
+
"lint:tsc": "tsc --noemit",
|
|
16
|
+
"lint": "concurrently \"npm:lint:eslint\" \"npm:lint:tsc\"",
|
|
17
|
+
"pretty": "prettier --write \"**/*.{ts,js,}\"",
|
|
18
|
+
"codegen": "cpy --flat ../codegen/output/entities/*.ts src/entities",
|
|
19
|
+
"postcodegen": "npm run pretty"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@apollo/server": "^4.9.1",
|
|
23
|
+
"@graphql-tools/utils": "^10.0.1",
|
|
24
|
+
"@memberjunction/ai": "^0.9.18",
|
|
25
|
+
"@memberjunction/core": "^0.9.21",
|
|
26
|
+
"@memberjunction/global": "^0.9.20",
|
|
27
|
+
"@memberjunction/queue": "^0.9.18",
|
|
28
|
+
"@memberjunction/sqlserver-dataprovider": "^0.9.18",
|
|
29
|
+
"@types/axios": "^0.14.0",
|
|
30
|
+
"@types/cors": "^2.8.13",
|
|
31
|
+
"@types/jsonwebtoken": "^8.5.9",
|
|
32
|
+
"@types/node": "^18.11.14",
|
|
33
|
+
"@types/ws": "^8.5.5",
|
|
34
|
+
"axios": "^1.4.0",
|
|
35
|
+
"body-parser": "^1.20.2",
|
|
36
|
+
"class-validator": "^0.14.0",
|
|
37
|
+
"cors": "^2.8.5",
|
|
38
|
+
"dotenv": "^16.0.3",
|
|
39
|
+
"env-var": "^7.3.0",
|
|
40
|
+
"express": "^4.18.2",
|
|
41
|
+
"fast-glob": "^3.3.1",
|
|
42
|
+
"graphql": "^16.8.0",
|
|
43
|
+
"graphql-ws": "^5.14.0",
|
|
44
|
+
"jsonwebtoken": "^8.5.1",
|
|
45
|
+
"jwks-rsa": "^3.0.0",
|
|
46
|
+
"lru-cache": "^10.0.0",
|
|
47
|
+
"mssql": "^9.1.1",
|
|
48
|
+
"reflect-metadata": "^0.1.13",
|
|
49
|
+
"rxjs": "^7.8.1",
|
|
50
|
+
"type-graphql": "^2.0.0-beta.3",
|
|
51
|
+
"typedi": "^0.10.0",
|
|
52
|
+
"typeorm": "^0.3.13",
|
|
53
|
+
"ws": "^8.13.0",
|
|
54
|
+
"zod": "^3.22.4"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@typescript-eslint/eslint-plugin": "^5.46.1",
|
|
58
|
+
"@typescript-eslint/parser": "^5.46.1",
|
|
59
|
+
"concurrently": "^7.6.0",
|
|
60
|
+
"cpy-cli": "^4.2.0",
|
|
61
|
+
"eslint": "^8.29.0",
|
|
62
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
63
|
+
"eslint-config-prettier": "^8.5.0",
|
|
64
|
+
"eslint-import-resolver-typescript": "^3.5.2",
|
|
65
|
+
"eslint-plugin-import": "^2.26.0",
|
|
66
|
+
"eslint-plugin-jsx-a11y": "^6.6.1",
|
|
67
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
68
|
+
"prettier": "^2.8.1",
|
|
69
|
+
"rimraf": "^4.4.0",
|
|
70
|
+
"ts-node": "^10.9.1",
|
|
71
|
+
"ts-node-dev": "^2.0.0",
|
|
72
|
+
"typescript": "^4.9.4"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { ApolloServerPlugin } from '@apollo/server';
|
|
2
|
-
import { DataSource } from 'typeorm';
|
|
3
|
-
import { AppContext } from '../types';
|
|
4
|
-
|
|
5
|
-
export const TransactionPlugin: ApolloServerPlugin<AppContext> = {
|
|
6
|
-
async requestDidStart(requestContext) {
|
|
7
|
-
const start = Date.now();
|
|
8
|
-
const query = requestContext.request.query || '';
|
|
9
|
-
const isMutation = /^\s*mutation\b/i.test(query);
|
|
10
|
-
|
|
11
|
-
if (!isMutation) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Start transaction, one or more mutations. If it is just one mutation, this trans wrapper isn't really needed
|
|
16
|
-
// but there's no good way to know if it's one or more mutations, so we just start a transaction anyway and it isn't terribly expensive
|
|
17
|
-
// to do so with SQL Server anyway.
|
|
18
|
-
const dataSource: DataSource = requestContext.contextValue.dataSource;
|
|
19
|
-
const queryRunner = dataSource.createQueryRunner();
|
|
20
|
-
|
|
21
|
-
requestContext.contextValue.queryRunner = queryRunner;
|
|
22
|
-
console.log('Starting transaction wrapper, time spent: ', Date.now() - start, 'ms ');
|
|
23
|
-
await queryRunner.startTransaction();
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
executionDidStart: async () => {
|
|
27
|
-
return {
|
|
28
|
-
executionDidEnd: async (err) => {
|
|
29
|
-
try {
|
|
30
|
-
if (err) {
|
|
31
|
-
console.log(
|
|
32
|
-
'Error in transaction, rolling back, time spent: ',
|
|
33
|
-
Date.now() - start,
|
|
34
|
-
'ms '
|
|
35
|
-
);
|
|
36
|
-
console.error('Rolling back transaction', err);
|
|
37
|
-
await queryRunner.rollbackTransaction();
|
|
38
|
-
} else {
|
|
39
|
-
console.log('Committing transaction, time spent: ', Date.now() - start, 'ms ');
|
|
40
|
-
await queryRunner.commitTransaction();
|
|
41
|
-
}
|
|
42
|
-
} catch (execErr) {
|
|
43
|
-
console.log('Execution Error, time spent: ', Date.now() - start, 'ms ');
|
|
44
|
-
console.error(execErr);
|
|
45
|
-
} finally {
|
|
46
|
-
await queryRunner.release();
|
|
47
|
-
console.log('Transaction complete, time spent: ', Date.now() - start, 'ms ');
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
},
|
|
54
|
-
};
|
|
1
|
+
import { ApolloServerPlugin } from '@apollo/server';
|
|
2
|
+
import { DataSource } from 'typeorm';
|
|
3
|
+
import { AppContext } from '../types';
|
|
4
|
+
|
|
5
|
+
export const TransactionPlugin: ApolloServerPlugin<AppContext> = {
|
|
6
|
+
async requestDidStart(requestContext) {
|
|
7
|
+
const start = Date.now();
|
|
8
|
+
const query = requestContext.request.query || '';
|
|
9
|
+
const isMutation = /^\s*mutation\b/i.test(query);
|
|
10
|
+
|
|
11
|
+
if (!isMutation) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Start transaction, one or more mutations. If it is just one mutation, this trans wrapper isn't really needed
|
|
16
|
+
// but there's no good way to know if it's one or more mutations, so we just start a transaction anyway and it isn't terribly expensive
|
|
17
|
+
// to do so with SQL Server anyway.
|
|
18
|
+
const dataSource: DataSource = requestContext.contextValue.dataSource;
|
|
19
|
+
const queryRunner = dataSource.createQueryRunner();
|
|
20
|
+
|
|
21
|
+
requestContext.contextValue.queryRunner = queryRunner;
|
|
22
|
+
console.log('Starting transaction wrapper, time spent: ', Date.now() - start, 'ms ');
|
|
23
|
+
await queryRunner.startTransaction();
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
executionDidStart: async () => {
|
|
27
|
+
return {
|
|
28
|
+
executionDidEnd: async (err) => {
|
|
29
|
+
try {
|
|
30
|
+
if (err) {
|
|
31
|
+
console.log(
|
|
32
|
+
'Error in transaction, rolling back, time spent: ',
|
|
33
|
+
Date.now() - start,
|
|
34
|
+
'ms '
|
|
35
|
+
);
|
|
36
|
+
console.error('Rolling back transaction', err);
|
|
37
|
+
await queryRunner.rollbackTransaction();
|
|
38
|
+
} else {
|
|
39
|
+
console.log('Committing transaction, time spent: ', Date.now() - start, 'ms ');
|
|
40
|
+
await queryRunner.commitTransaction();
|
|
41
|
+
}
|
|
42
|
+
} catch (execErr) {
|
|
43
|
+
console.log('Execution Error, time spent: ', Date.now() - start, 'ms ');
|
|
44
|
+
console.error(execErr);
|
|
45
|
+
} finally {
|
|
46
|
+
await queryRunner.release();
|
|
47
|
+
console.log('Transaction complete, time spent: ', Date.now() - start, 'ms ');
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
};
|