@memberjunction/server 0.9.4 → 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/.eslintignore +5 -6
  2. package/.eslintrc +24 -24
  3. package/README.md +141 -141
  4. package/config.json +14 -14
  5. package/dist/apolloServer/TransactionPlugin.js +45 -45
  6. package/dist/apolloServer/index.js +26 -26
  7. package/dist/auth/exampleNewUserSubClass.js +67 -67
  8. package/dist/auth/index.js +87 -87
  9. package/dist/auth/newUsers.js +66 -66
  10. package/dist/cache.js +10 -10
  11. package/dist/config.js +55 -55
  12. package/dist/context.js +100 -100
  13. package/dist/directives/Public.js +33 -33
  14. package/dist/directives/index.js +17 -17
  15. package/dist/generated/generated.js +19245 -0
  16. package/dist/generated/generated.js.map +1 -0
  17. package/dist/generic/PushStatusResolver.js +59 -0
  18. package/dist/generic/PushStatusResolver.js.map +1 -0
  19. package/dist/generic/ResolverBase.js +187 -0
  20. package/dist/generic/ResolverBase.js.map +1 -0
  21. package/dist/generic/RunViewResolver.js +308 -0
  22. package/dist/generic/RunViewResolver.js.map +1 -0
  23. package/dist/index.js +114 -114
  24. package/dist/orm.js +21 -21
  25. package/dist/resolvers/AskSkipResolver.js +244 -0
  26. package/dist/resolvers/AskSkipResolver.js.map +1 -0
  27. package/dist/resolvers/ColorResolver.js +95 -0
  28. package/dist/resolvers/ColorResolver.js.map +1 -0
  29. package/dist/resolvers/DatasetResolver.js +168 -0
  30. package/dist/resolvers/DatasetResolver.js.map +1 -0
  31. package/dist/resolvers/EntityRecordNameResolver.js +108 -0
  32. package/dist/resolvers/EntityRecordNameResolver.js.map +1 -0
  33. package/dist/resolvers/EntityResolver.js +60 -0
  34. package/dist/resolvers/EntityResolver.js.map +1 -0
  35. package/dist/resolvers/ReportResolver.js +74 -0
  36. package/dist/resolvers/ReportResolver.js.map +1 -0
  37. package/dist/resolvers/UserFavoriteResolver.js +188 -0
  38. package/dist/resolvers/UserFavoriteResolver.js.map +1 -0
  39. package/dist/resolvers/UserResolver.js +70 -0
  40. package/dist/resolvers/UserResolver.js.map +1 -0
  41. package/dist/resolvers/UserViewResolver.js +104 -0
  42. package/dist/resolvers/UserViewResolver.js.map +1 -0
  43. package/dist/types.js +2 -2
  44. package/package.json +74 -74
  45. package/src/apolloServer/TransactionPlugin.ts +54 -54
  46. package/src/apolloServer/index.ts +33 -33
  47. package/src/auth/exampleNewUserSubClass.ts +70 -70
  48. package/src/auth/index.ts +117 -117
  49. package/src/auth/newUsers.ts +55 -55
  50. package/src/cache.ts +10 -10
  51. package/src/config.ts +67 -67
  52. package/src/context.ts +105 -105
  53. package/src/directives/Public.ts +42 -42
  54. package/src/directives/index.ts +1 -1
  55. package/src/index.ts +105 -105
  56. package/src/orm.ts +23 -23
  57. package/src/types.ts +19 -19
@@ -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,UAAU,EAAE,CAAC,CAAC,CAAC;IACnG,CAAC;IAGK,AAAN,KAAK,CAAC,WAAW,CAA6B,KAAa,EAAS,EAAE,UAAU,EAAc;QAC5F,MAAM,WAAW,GAAG,qBAAY,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC;QACjD,OAAO,KAAK,CAAC,qBAAqB,CAChC,MAAM,UAAU,CAAC,aAAa,CAAC,iBAAK,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CACrE,CAAC;IACJ,CAAC;CACF,CAAA;AAxBO;IADL,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,iBAAK,CAAC;IACA,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;+CAEvB;AAGK;IADL,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,iBAAK,CAAC;IACH,WAAA,IAAA,kBAAG,EAAC,IAAI,EAAE,GAAG,EAAE,CAAC,kBAAG,CAAC,CAAA;IAAc,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;4CAEtD;AAGK;IADL,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,iBAAK,CAAC;IAEhB,WAAA,IAAA,kBAAG,EAAC,YAAY,EAAE,GAAG,EAAE,CAAC,kBAAG,CAAC,CAAA;IAC5B,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;oDAGP;AAGK;IADL,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,iBAAK,CAAC;IACA,WAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAA;IAAiB,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;+CAKlE;AAzBU,YAAY;IADxB,IAAA,uBAAQ,EAAC,iBAAK,CAAC;GACH,YAAY,CA0BxB;AA1BY,oCAAY;AA2BzB,kBAAe,YAAY,CAAC"}
@@ -0,0 +1,104 @@
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.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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";
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",
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.17",
25
- "@memberjunction/core": "^0.9.20",
26
- "@memberjunction/global": "^0.9.19",
27
- "@memberjunction/queue": "^0.9.17",
28
- "@memberjunction/sqlserver-dataprovider": "^0.9.17",
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.6",
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.19",
25
+ "@memberjunction/core": "^0.9.21",
26
+ "@memberjunction/global": "^0.9.21",
27
+ "@memberjunction/queue": "^0.9.19",
28
+ "@memberjunction/sqlserver-dataprovider": "^0.9.19",
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
+ };
@@ -1,34 +1,34 @@
1
- import { ApolloServer, ApolloServerOptions } from '@apollo/server';
2
- import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer';
3
- import { PubSub } from 'graphql-subscriptions';
4
- import { Disposable } from 'graphql-ws';
5
- import { Server } from 'http';
6
- import { enableIntrospection } from '../config';
7
- import { AppContext } from '../types';
8
- import { TransactionPlugin } from './TransactionPlugin';
9
-
10
- const buildApolloServer = (
11
- configOverride: ApolloServerOptions<AppContext>,
12
- { httpServer, serverCleanup }: { httpServer: Server; serverCleanup: Disposable }
13
- ) =>
14
- new ApolloServer({
15
- csrfPrevention: true,
16
- cache: 'bounded',
17
- plugins: [
18
- ApolloServerPluginDrainHttpServer({ httpServer }),
19
- TransactionPlugin,
20
- {
21
- async serverWillStart() {
22
- return {
23
- async drainServer() {
24
- await serverCleanup.dispose();
25
- },
26
- };
27
- },
28
- },
29
- ],
30
- introspection: enableIntrospection,
31
- ...configOverride,
32
- });
33
-
1
+ import { ApolloServer, ApolloServerOptions } from '@apollo/server';
2
+ import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer';
3
+ import { PubSub } from 'graphql-subscriptions';
4
+ import { Disposable } from 'graphql-ws';
5
+ import { Server } from 'http';
6
+ import { enableIntrospection } from '../config';
7
+ import { AppContext } from '../types';
8
+ import { TransactionPlugin } from './TransactionPlugin';
9
+
10
+ const buildApolloServer = (
11
+ configOverride: ApolloServerOptions<AppContext>,
12
+ { httpServer, serverCleanup }: { httpServer: Server; serverCleanup: Disposable }
13
+ ) =>
14
+ new ApolloServer({
15
+ csrfPrevention: true,
16
+ cache: 'bounded',
17
+ plugins: [
18
+ ApolloServerPluginDrainHttpServer({ httpServer }),
19
+ TransactionPlugin,
20
+ {
21
+ async serverWillStart() {
22
+ return {
23
+ async drainServer() {
24
+ await serverCleanup.dispose();
25
+ },
26
+ };
27
+ },
28
+ },
29
+ ],
30
+ introspection: enableIntrospection,
31
+ ...configOverride,
32
+ });
33
+
34
34
  export default buildApolloServer;