@memberjunction/server 1.0.6 → 1.0.7

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 (62) hide show
  1. package/.eslintignore +4 -4
  2. package/.eslintrc +24 -24
  3. package/CHANGELOG.json +92 -0
  4. package/CHANGELOG.md +25 -0
  5. package/README.md +141 -141
  6. package/dist/config.d.ts +3 -0
  7. package/dist/config.d.ts.map +1 -1
  8. package/dist/config.js +4 -1
  9. package/dist/config.js.map +1 -1
  10. package/dist/entitySubclasses/entityPermissions.server.d.ts +23 -0
  11. package/dist/entitySubclasses/entityPermissions.server.d.ts.map +1 -0
  12. package/dist/entitySubclasses/entityPermissions.server.js +99 -0
  13. package/dist/entitySubclasses/entityPermissions.server.js.map +1 -0
  14. package/dist/entitySubclasses/userViewEntity.server.js +17 -17
  15. package/dist/generated/generated.d.ts.map +1 -1
  16. package/dist/generated/generated.js.map +1 -1
  17. package/dist/index.d.ts +1 -0
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +1 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/resolvers/AskSkipResolver.js +10 -10
  22. package/dist/resolvers/FileCategoryResolver.js +2 -2
  23. package/dist/resolvers/ReportResolver.js +4 -4
  24. package/package.json +80 -80
  25. package/src/apolloServer/TransactionPlugin.ts +57 -57
  26. package/src/apolloServer/index.ts +33 -33
  27. package/src/auth/exampleNewUserSubClass.ts +73 -73
  28. package/src/auth/index.ts +151 -151
  29. package/src/auth/newUsers.ts +56 -56
  30. package/src/auth/tokenExpiredError.ts +12 -12
  31. package/src/cache.ts +10 -10
  32. package/src/config.ts +89 -84
  33. package/src/context.ts +119 -119
  34. package/src/directives/Public.ts +42 -42
  35. package/src/directives/index.ts +1 -1
  36. package/src/entitySubclasses/entityPermissions.server.ts +111 -0
  37. package/src/entitySubclasses/userViewEntity.server.ts +187 -187
  38. package/src/generated/generated.ts +2573 -2573
  39. package/src/generic/PushStatusResolver.ts +40 -40
  40. package/src/generic/ResolverBase.ts +331 -331
  41. package/src/generic/RunViewResolver.ts +350 -350
  42. package/src/index.ts +133 -137
  43. package/src/orm.ts +36 -36
  44. package/src/resolvers/AskSkipResolver.ts +782 -782
  45. package/src/resolvers/ColorResolver.ts +72 -72
  46. package/src/resolvers/DatasetResolver.ts +115 -115
  47. package/src/resolvers/EntityRecordNameResolver.ts +77 -77
  48. package/src/resolvers/EntityResolver.ts +37 -37
  49. package/src/resolvers/FileCategoryResolver.ts +38 -38
  50. package/src/resolvers/FileResolver.ts +110 -110
  51. package/src/resolvers/MergeRecordsResolver.ts +198 -198
  52. package/src/resolvers/PotentialDuplicateRecordResolver.ts +59 -59
  53. package/src/resolvers/QueryResolver.ts +42 -42
  54. package/src/resolvers/ReportResolver.ts +131 -131
  55. package/src/resolvers/UserFavoriteResolver.ts +102 -102
  56. package/src/resolvers/UserResolver.ts +29 -29
  57. package/src/resolvers/UserViewResolver.ts +64 -64
  58. package/src/types.ts +19 -19
  59. package/src/util.ts +106 -106
  60. package/tsconfig.json +31 -31
  61. package/typedoc.json +4 -4
  62. package/build.log.json +0 -47
@@ -1,199 +1,199 @@
1
- import { LogError, Metadata, PrimaryKeyValue } from '@memberjunction/core';
2
- import { Arg, Ctx, Field, InputType, Int, Mutation, ObjectType, PubSub, PubSubEngine, Query, Resolver } from 'type-graphql';
3
- import { AppContext } from '../types';
4
-
5
- @ObjectType()
6
- export class EntityDependencyResult {
7
- @Field(() => String)
8
- EntityName: string; // required
9
-
10
- @Field(() => String)
11
- RelatedEntityName: string; // required
12
-
13
- @Field(() => String)
14
- FieldName: string; // required
15
- }
16
-
17
- @Resolver(EntityDependencyResult)
18
- export class EntityDependencyResolver {
19
- @Query(() => [EntityDependencyResult])
20
- async GetEntityDependencies(
21
- @Arg('entityName', () => String) entityName: string,
22
- @Ctx() { dataSource, userPayload }: AppContext,
23
- @PubSub() pubSub: PubSubEngine
24
- ) {
25
- try {
26
- const md = new Metadata();
27
- return md.GetEntityDependencies(entityName);
28
- }
29
- catch (err) {
30
- LogError(err);
31
- throw new Error(err.message);
32
- }
33
- }
34
-
35
- }
36
-
37
-
38
- @InputType()
39
- export class PrimaryKeyValueInputType {
40
- @Field(() => String)
41
- FieldName: string;
42
-
43
- @Field(() => String)
44
- Value: string;
45
- }
46
-
47
- @ObjectType()
48
- export class PrimaryKeyValueOutputType {
49
- @Field(() => String)
50
- FieldName: string;
51
-
52
- @Field(() => String)
53
- Value: string;
54
- }
55
-
56
-
57
- @ObjectType()
58
- export class RecordDependencyResult {
59
- @Field(() => String)
60
- EntityName: string; // required
61
-
62
- @Field(() => String)
63
- RelatedEntityName: string; // required
64
-
65
- @Field(() => String)
66
- FieldName: string; // required
67
-
68
- @Field(() => String)
69
- PrimaryKeyValue: string;
70
- }
71
-
72
-
73
-
74
-
75
- @Resolver(RecordDependencyResult)
76
- export class RecordDependencyResolver {
77
- @Query(() => [RecordDependencyResult])
78
- async GetRecordDependencies(
79
- @Arg('entityName', () => String) entityName: string,
80
- @Arg('primaryKeyValues', () => [PrimaryKeyValueInputType]) primaryKeyValues: PrimaryKeyValue[],
81
- @Ctx() { dataSource, userPayload }: AppContext,
82
- @PubSub() pubSub: PubSubEngine
83
- ) {
84
- try {
85
- const md = new Metadata();
86
- const result = await md.GetRecordDependencies(entityName, primaryKeyValues)
87
- return result;
88
- }
89
- catch (e) {
90
- LogError(e);
91
- throw e;
92
- }
93
- }
94
- }
95
-
96
- @InputType()
97
- class FieldMapping {
98
- @Field(() => String)
99
- FieldName: string;
100
-
101
- @Field(() => String)
102
- Value: string;
103
- }
104
-
105
- @ObjectType()
106
- class FieldMappingOutput {
107
- @Field(() => String)
108
- FieldName: string;
109
-
110
- @Field(() => String)
111
- Value: string;
112
- }
113
-
114
- @InputType()
115
- export class RecordMergeRequest {
116
- @Field(() => String)
117
- EntityName: string;
118
-
119
- @Field(() => [PrimaryKeyValueInputType])
120
- SurvivingRecordPrimaryKeyValues: PrimaryKeyValue[];
121
-
122
- @Field(() => [[PrimaryKeyValueInputType]])
123
- RecordsToMerge: PrimaryKeyValue[][];
124
-
125
- @Field(() => [FieldMapping], { nullable: true })
126
- FieldMap?: FieldMapping[];
127
- }
128
-
129
- @ObjectType()
130
- export class RecordMergeRequestOutput {
131
- @Field(() => String)
132
- EntityName: string;
133
-
134
- @Field(() => Int)
135
- SurvivingRecordID: number;
136
-
137
- @Field(() => [Int])
138
- RecordsToMerge: number[];
139
-
140
- @Field(() => [FieldMappingOutput], { nullable: true })
141
- FieldMap?: FieldMappingOutput[];
142
- }
143
-
144
-
145
- @ObjectType()
146
- export class RecordMergeDetailResult {
147
- @Field(() => [PrimaryKeyValueOutputType])
148
- PrimaryKeyValues: PrimaryKeyValue[];
149
-
150
- @Field(() => Boolean)
151
- Success: boolean;
152
-
153
- @Field(() => Int, {nullable: true})
154
- RecordMergeDeletionLogID?: number;
155
-
156
- @Field(() => String, {nullable: true})
157
- Message?: string;
158
- }
159
-
160
- @ObjectType()
161
- export class RecordMergeResult {
162
- @Field(() => Boolean)
163
- Success: boolean;
164
-
165
- @Field(() => String, {nullable: true})
166
- OverallStatus: string;
167
-
168
- @Field(() => Int, {nullable: true})
169
- RecordMergeLogID: number;
170
-
171
- @Field(() => [RecordMergeDetailResult])
172
- RecordStatus: RecordMergeDetailResult[];
173
-
174
- @Field(() => RecordMergeRequestOutput)
175
- Request: RecordMergeRequestOutput;
176
- }
177
-
178
- @Resolver(RecordMergeResult)
179
- export class RecordMergeResolver {
180
- @Mutation(() => RecordMergeResult)
181
- async MergeRecords(
182
- @Arg('request', () => RecordMergeRequest) request: RecordMergeRequest,
183
- @Ctx() { dataSource, userPayload }: AppContext,
184
- @PubSub() pubSub: PubSubEngine
185
- ) {
186
- try {
187
- const md = new Metadata();
188
- const result = await md.MergeRecords(request, userPayload.userRecord);
189
- return result;
190
- }
191
- catch (e) {
192
- LogError(e);
193
- throw e;
194
- }
195
- }
196
- }
197
-
198
-
1
+ import { LogError, Metadata, PrimaryKeyValue } from '@memberjunction/core';
2
+ import { Arg, Ctx, Field, InputType, Int, Mutation, ObjectType, PubSub, PubSubEngine, Query, Resolver } from 'type-graphql';
3
+ import { AppContext } from '../types';
4
+
5
+ @ObjectType()
6
+ export class EntityDependencyResult {
7
+ @Field(() => String)
8
+ EntityName: string; // required
9
+
10
+ @Field(() => String)
11
+ RelatedEntityName: string; // required
12
+
13
+ @Field(() => String)
14
+ FieldName: string; // required
15
+ }
16
+
17
+ @Resolver(EntityDependencyResult)
18
+ export class EntityDependencyResolver {
19
+ @Query(() => [EntityDependencyResult])
20
+ async GetEntityDependencies(
21
+ @Arg('entityName', () => String) entityName: string,
22
+ @Ctx() { dataSource, userPayload }: AppContext,
23
+ @PubSub() pubSub: PubSubEngine
24
+ ) {
25
+ try {
26
+ const md = new Metadata();
27
+ return md.GetEntityDependencies(entityName);
28
+ }
29
+ catch (err) {
30
+ LogError(err);
31
+ throw new Error(err.message);
32
+ }
33
+ }
34
+
35
+ }
36
+
37
+
38
+ @InputType()
39
+ export class PrimaryKeyValueInputType {
40
+ @Field(() => String)
41
+ FieldName: string;
42
+
43
+ @Field(() => String)
44
+ Value: string;
45
+ }
46
+
47
+ @ObjectType()
48
+ export class PrimaryKeyValueOutputType {
49
+ @Field(() => String)
50
+ FieldName: string;
51
+
52
+ @Field(() => String)
53
+ Value: string;
54
+ }
55
+
56
+
57
+ @ObjectType()
58
+ export class RecordDependencyResult {
59
+ @Field(() => String)
60
+ EntityName: string; // required
61
+
62
+ @Field(() => String)
63
+ RelatedEntityName: string; // required
64
+
65
+ @Field(() => String)
66
+ FieldName: string; // required
67
+
68
+ @Field(() => String)
69
+ PrimaryKeyValue: string;
70
+ }
71
+
72
+
73
+
74
+
75
+ @Resolver(RecordDependencyResult)
76
+ export class RecordDependencyResolver {
77
+ @Query(() => [RecordDependencyResult])
78
+ async GetRecordDependencies(
79
+ @Arg('entityName', () => String) entityName: string,
80
+ @Arg('primaryKeyValues', () => [PrimaryKeyValueInputType]) primaryKeyValues: PrimaryKeyValue[],
81
+ @Ctx() { dataSource, userPayload }: AppContext,
82
+ @PubSub() pubSub: PubSubEngine
83
+ ) {
84
+ try {
85
+ const md = new Metadata();
86
+ const result = await md.GetRecordDependencies(entityName, primaryKeyValues)
87
+ return result;
88
+ }
89
+ catch (e) {
90
+ LogError(e);
91
+ throw e;
92
+ }
93
+ }
94
+ }
95
+
96
+ @InputType()
97
+ class FieldMapping {
98
+ @Field(() => String)
99
+ FieldName: string;
100
+
101
+ @Field(() => String)
102
+ Value: string;
103
+ }
104
+
105
+ @ObjectType()
106
+ class FieldMappingOutput {
107
+ @Field(() => String)
108
+ FieldName: string;
109
+
110
+ @Field(() => String)
111
+ Value: string;
112
+ }
113
+
114
+ @InputType()
115
+ export class RecordMergeRequest {
116
+ @Field(() => String)
117
+ EntityName: string;
118
+
119
+ @Field(() => [PrimaryKeyValueInputType])
120
+ SurvivingRecordPrimaryKeyValues: PrimaryKeyValue[];
121
+
122
+ @Field(() => [[PrimaryKeyValueInputType]])
123
+ RecordsToMerge: PrimaryKeyValue[][];
124
+
125
+ @Field(() => [FieldMapping], { nullable: true })
126
+ FieldMap?: FieldMapping[];
127
+ }
128
+
129
+ @ObjectType()
130
+ export class RecordMergeRequestOutput {
131
+ @Field(() => String)
132
+ EntityName: string;
133
+
134
+ @Field(() => Int)
135
+ SurvivingRecordID: number;
136
+
137
+ @Field(() => [Int])
138
+ RecordsToMerge: number[];
139
+
140
+ @Field(() => [FieldMappingOutput], { nullable: true })
141
+ FieldMap?: FieldMappingOutput[];
142
+ }
143
+
144
+
145
+ @ObjectType()
146
+ export class RecordMergeDetailResult {
147
+ @Field(() => [PrimaryKeyValueOutputType])
148
+ PrimaryKeyValues: PrimaryKeyValue[];
149
+
150
+ @Field(() => Boolean)
151
+ Success: boolean;
152
+
153
+ @Field(() => Int, {nullable: true})
154
+ RecordMergeDeletionLogID?: number;
155
+
156
+ @Field(() => String, {nullable: true})
157
+ Message?: string;
158
+ }
159
+
160
+ @ObjectType()
161
+ export class RecordMergeResult {
162
+ @Field(() => Boolean)
163
+ Success: boolean;
164
+
165
+ @Field(() => String, {nullable: true})
166
+ OverallStatus: string;
167
+
168
+ @Field(() => Int, {nullable: true})
169
+ RecordMergeLogID: number;
170
+
171
+ @Field(() => [RecordMergeDetailResult])
172
+ RecordStatus: RecordMergeDetailResult[];
173
+
174
+ @Field(() => RecordMergeRequestOutput)
175
+ Request: RecordMergeRequestOutput;
176
+ }
177
+
178
+ @Resolver(RecordMergeResult)
179
+ export class RecordMergeResolver {
180
+ @Mutation(() => RecordMergeResult)
181
+ async MergeRecords(
182
+ @Arg('request', () => RecordMergeRequest) request: RecordMergeRequest,
183
+ @Ctx() { dataSource, userPayload }: AppContext,
184
+ @PubSub() pubSub: PubSubEngine
185
+ ) {
186
+ try {
187
+ const md = new Metadata();
188
+ const result = await md.MergeRecords(request, userPayload.userRecord);
189
+ return result;
190
+ }
191
+ catch (e) {
192
+ LogError(e);
193
+ throw e;
194
+ }
195
+ }
196
+ }
197
+
198
+
199
199
  export default EntityDependencyResolver;
@@ -1,60 +1,60 @@
1
- import { Arg, Ctx, Field, Float, InputType, Int, ObjectType, Query, Resolver } from "type-graphql";
2
- import { PotentialDuplicateRequest, PotentialDuplicateResponse, PotentialDuplicate, Metadata, PrimaryKeyValue, LogError } from '@memberjunction/core';
3
- import {PrimaryKeyValueInputType, PrimaryKeyValueOutputType} from './MergeRecordsResolver'
4
- import { AppContext } from "../types";
5
- import { UserCache } from "@memberjunction/sqlserver-dataprovider";
6
-
7
- @InputType()
8
- export class PotentialDuplicateRequestType extends PotentialDuplicateRequest {
9
- @Field(() => Int)
10
- EntityDocumentID: number;
11
-
12
- @Field(() => [PrimaryKeyValueInputType])
13
- PrimaryKeyValues: PrimaryKeyValueInputType[];
14
-
15
- @Field(() => Int, { nullable: true })
16
- EntitiyID: number;
17
-
18
- @Field(() => String, { nullable: true })
19
- EntityName: string;
20
-
21
- @Field(() => Int, { nullable: true })
22
- ProbabilityScore: number;
23
-
24
- }
25
-
26
- @ObjectType()
27
- export class PotentialDuplicateType extends PotentialDuplicate {
28
- @Field(() => Float)
29
- ProbabilityScore: number;
30
-
31
- @Field(() => [PrimaryKeyValueOutputType])
32
- PrimaryKeyValues: PrimaryKeyValueOutputType[];
33
- }
34
-
35
- @ObjectType()
36
- export class PotentialDuplicateResponseType extends PotentialDuplicateResponse{
37
-
38
- @Field(() => Int)
39
- EntityID: number;
40
-
41
- @Field(() => [PotentialDuplicateType])
42
- Duplicates: PotentialDuplicateType[];
43
- }
44
-
45
- @Resolver(PotentialDuplicateResponseType)
46
- export class DuplicateRecordResolver {
47
-
48
- @Query(() => PotentialDuplicateResponseType)
49
- async GetRecordDuplicates(@Ctx() { dataSource, userPayload }: AppContext, @Arg("params")params: PotentialDuplicateRequestType): Promise<PotentialDuplicateResponseType> {
50
- const md = new Metadata();
51
-
52
- const user = UserCache.Instance.Users.find((u) => u.Email.trim().toLowerCase() === userPayload.email.trim().toLowerCase());
53
- if (!user) {
54
- throw new Error(`User ${userPayload.email} not found in UserCache`);
55
- }
56
-
57
- const result = await md.GetRecordDuplicates(params, user);
58
- return result;
59
- }
1
+ import { Arg, Ctx, Field, Float, InputType, Int, ObjectType, Query, Resolver } from "type-graphql";
2
+ import { PotentialDuplicateRequest, PotentialDuplicateResponse, PotentialDuplicate, Metadata, PrimaryKeyValue, LogError } from '@memberjunction/core';
3
+ import {PrimaryKeyValueInputType, PrimaryKeyValueOutputType} from './MergeRecordsResolver'
4
+ import { AppContext } from "../types";
5
+ import { UserCache } from "@memberjunction/sqlserver-dataprovider";
6
+
7
+ @InputType()
8
+ export class PotentialDuplicateRequestType extends PotentialDuplicateRequest {
9
+ @Field(() => Int)
10
+ EntityDocumentID: number;
11
+
12
+ @Field(() => [PrimaryKeyValueInputType])
13
+ PrimaryKeyValues: PrimaryKeyValueInputType[];
14
+
15
+ @Field(() => Int, { nullable: true })
16
+ EntitiyID: number;
17
+
18
+ @Field(() => String, { nullable: true })
19
+ EntityName: string;
20
+
21
+ @Field(() => Int, { nullable: true })
22
+ ProbabilityScore: number;
23
+
24
+ }
25
+
26
+ @ObjectType()
27
+ export class PotentialDuplicateType extends PotentialDuplicate {
28
+ @Field(() => Float)
29
+ ProbabilityScore: number;
30
+
31
+ @Field(() => [PrimaryKeyValueOutputType])
32
+ PrimaryKeyValues: PrimaryKeyValueOutputType[];
33
+ }
34
+
35
+ @ObjectType()
36
+ export class PotentialDuplicateResponseType extends PotentialDuplicateResponse{
37
+
38
+ @Field(() => Int)
39
+ EntityID: number;
40
+
41
+ @Field(() => [PotentialDuplicateType])
42
+ Duplicates: PotentialDuplicateType[];
43
+ }
44
+
45
+ @Resolver(PotentialDuplicateResponseType)
46
+ export class DuplicateRecordResolver {
47
+
48
+ @Query(() => PotentialDuplicateResponseType)
49
+ async GetRecordDuplicates(@Ctx() { dataSource, userPayload }: AppContext, @Arg("params")params: PotentialDuplicateRequestType): Promise<PotentialDuplicateResponseType> {
50
+ const md = new Metadata();
51
+
52
+ const user = UserCache.Instance.Users.find((u) => u.Email.trim().toLowerCase() === userPayload.email.trim().toLowerCase());
53
+ if (!user) {
54
+ throw new Error(`User ${userPayload.email} not found in UserCache`);
55
+ }
56
+
57
+ const result = await md.GetRecordDuplicates(params, user);
58
+ return result;
59
+ }
60
60
  }
@@ -1,42 +1,42 @@
1
- // Queries are MemberJunction primitive operations that are used to retrieve data from the server from any stored query
2
- import { RunQuery } from '@memberjunction/core';
3
- import { Arg, Ctx, Field, Int, ObjectType, Query, Resolver } from 'type-graphql';
4
- import { AppContext } from '../types';
5
-
6
- @ObjectType()
7
- export class RunQueryResultType {
8
- @Field()
9
- QueryID: number;
10
-
11
- @Field()
12
- Success: boolean;
13
-
14
- @Field()
15
- Results: string;
16
-
17
- @Field()
18
- RowCount: number;
19
-
20
- @Field()
21
- ExecutionTime: number;
22
-
23
- @Field()
24
- ErrorMessage: string;
25
- }
26
-
27
- @Resolver(RunQueryResultType)
28
- export class ReportResolver {
29
- @Query(() => RunQueryResultType)
30
- async GetQueryData(@Arg('QueryID', () => Int) QueryID: number, @Ctx() {}: AppContext): Promise<RunQueryResultType> {
31
- const runQuery = new RunQuery();
32
- const result = await runQuery.RunQuery({ QueryID: QueryID });
33
- return {
34
- QueryID: QueryID,
35
- Success: result.Success,
36
- Results: JSON.stringify(result.Results),
37
- RowCount: result.RowCount,
38
- ExecutionTime: result.ExecutionTime,
39
- ErrorMessage: result.ErrorMessage,
40
- };
41
- }
42
- }
1
+ // Queries are MemberJunction primitive operations that are used to retrieve data from the server from any stored query
2
+ import { RunQuery } from '@memberjunction/core';
3
+ import { Arg, Ctx, Field, Int, ObjectType, Query, Resolver } from 'type-graphql';
4
+ import { AppContext } from '../types';
5
+
6
+ @ObjectType()
7
+ export class RunQueryResultType {
8
+ @Field()
9
+ QueryID: number;
10
+
11
+ @Field()
12
+ Success: boolean;
13
+
14
+ @Field()
15
+ Results: string;
16
+
17
+ @Field()
18
+ RowCount: number;
19
+
20
+ @Field()
21
+ ExecutionTime: number;
22
+
23
+ @Field()
24
+ ErrorMessage: string;
25
+ }
26
+
27
+ @Resolver(RunQueryResultType)
28
+ export class ReportResolver {
29
+ @Query(() => RunQueryResultType)
30
+ async GetQueryData(@Arg('QueryID', () => Int) QueryID: number, @Ctx() {}: AppContext): Promise<RunQueryResultType> {
31
+ const runQuery = new RunQuery();
32
+ const result = await runQuery.RunQuery({ QueryID: QueryID });
33
+ return {
34
+ QueryID: QueryID,
35
+ Success: result.Success,
36
+ Results: JSON.stringify(result.Results),
37
+ RowCount: result.RowCount,
38
+ ExecutionTime: result.ExecutionTime,
39
+ ErrorMessage: result.ErrorMessage,
40
+ };
41
+ }
42
+ }