@memberjunction/server 1.0.6 → 1.0.7-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +4 -4
- package/.eslintrc +24 -24
- package/CHANGELOG.json +92 -0
- package/CHANGELOG.md +25 -0
- package/README.md +141 -141
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -1
- package/dist/config.js.map +1 -1
- package/dist/entitySubclasses/entityPermissions.server.d.ts +23 -0
- package/dist/entitySubclasses/entityPermissions.server.d.ts.map +1 -0
- package/dist/entitySubclasses/entityPermissions.server.js +99 -0
- package/dist/entitySubclasses/entityPermissions.server.js.map +1 -0
- package/dist/entitySubclasses/userViewEntity.server.js +17 -17
- package/dist/generated/generated.d.ts.map +1 -1
- package/dist/generated/generated.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/resolvers/AskSkipResolver.js +10 -10
- package/dist/resolvers/FileCategoryResolver.js +2 -2
- package/dist/resolvers/ReportResolver.js +4 -4
- package/package.json +80 -80
- package/src/apolloServer/TransactionPlugin.ts +57 -57
- package/src/apolloServer/index.ts +33 -33
- package/src/auth/exampleNewUserSubClass.ts +73 -73
- package/src/auth/index.ts +151 -151
- package/src/auth/newUsers.ts +56 -56
- package/src/auth/tokenExpiredError.ts +12 -12
- package/src/cache.ts +10 -10
- package/src/config.ts +89 -84
- package/src/context.ts +119 -119
- package/src/directives/Public.ts +42 -42
- package/src/directives/index.ts +1 -1
- package/src/entitySubclasses/entityPermissions.server.ts +111 -0
- package/src/entitySubclasses/userViewEntity.server.ts +187 -187
- package/src/generated/generated.ts +2573 -2573
- package/src/generic/PushStatusResolver.ts +40 -40
- package/src/generic/ResolverBase.ts +331 -331
- package/src/generic/RunViewResolver.ts +350 -350
- package/src/index.ts +133 -137
- package/src/orm.ts +36 -36
- package/src/resolvers/AskSkipResolver.ts +782 -782
- package/src/resolvers/ColorResolver.ts +72 -72
- package/src/resolvers/DatasetResolver.ts +115 -115
- package/src/resolvers/EntityRecordNameResolver.ts +77 -77
- package/src/resolvers/EntityResolver.ts +37 -37
- package/src/resolvers/FileCategoryResolver.ts +38 -38
- package/src/resolvers/FileResolver.ts +110 -110
- package/src/resolvers/MergeRecordsResolver.ts +198 -198
- package/src/resolvers/PotentialDuplicateRecordResolver.ts +59 -59
- package/src/resolvers/QueryResolver.ts +42 -42
- package/src/resolvers/ReportResolver.ts +131 -131
- package/src/resolvers/UserFavoriteResolver.ts +102 -102
- package/src/resolvers/UserResolver.ts +29 -29
- package/src/resolvers/UserViewResolver.ts +64 -64
- package/src/types.ts +19 -19
- package/src/util.ts +106 -106
- package/tsconfig.json +31 -31
- package/typedoc.json +4 -4
- package/build.log.json +0 -47
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AppContext,
|
|
3
|
-
Ctx,
|
|
4
|
-
Field,
|
|
5
|
-
Int,
|
|
6
|
-
ObjectType,
|
|
7
|
-
PubSub,
|
|
8
|
-
PubSubEngine,
|
|
9
|
-
Public,
|
|
10
|
-
Query,
|
|
11
|
-
Resolver,
|
|
12
|
-
Root,
|
|
13
|
-
Subscription,
|
|
14
|
-
} from '@memberjunction/server';
|
|
15
|
-
|
|
16
|
-
@ObjectType()
|
|
17
|
-
export class Color {
|
|
18
|
-
@Field(() => Int)
|
|
19
|
-
@Public()
|
|
20
|
-
ID: number;
|
|
21
|
-
|
|
22
|
-
@Field(() => String)
|
|
23
|
-
@Public()
|
|
24
|
-
name: string;
|
|
25
|
-
|
|
26
|
-
@Field(() => String)
|
|
27
|
-
@Public()
|
|
28
|
-
createdZ: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@ObjectType()
|
|
32
|
-
export class ColorNotification {
|
|
33
|
-
@Public()
|
|
34
|
-
@Field(() => String, { nullable: true })
|
|
35
|
-
message?: string;
|
|
36
|
-
|
|
37
|
-
@Public()
|
|
38
|
-
@Field((_type) => Date)
|
|
39
|
-
date!: Date;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface ColorNotificationPayload {
|
|
43
|
-
message?: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@Resolver(Color)
|
|
47
|
-
export class ColorResolver {
|
|
48
|
-
@Subscription(() => ColorNotification, { topics: 'COLOR' })
|
|
49
|
-
@Public()
|
|
50
|
-
colorSubscription(@Root() { message }: ColorNotificationPayload): ColorNotification {
|
|
51
|
-
return { message, date: new Date() };
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
@Query(() => [Color])
|
|
55
|
-
@Public()
|
|
56
|
-
async colors(@Ctx() _ctx: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
57
|
-
const createdZ = new Date().toISOString();
|
|
58
|
-
|
|
59
|
-
pubSub.publish('COLOR', {
|
|
60
|
-
message: 'Colors were requested!',
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
return [
|
|
64
|
-
{ ID: 1, name: 'Red', createdZ },
|
|
65
|
-
{ ID: 2, name: 'Orange', createdZ },
|
|
66
|
-
{ ID: 3, name: 'Yellow', createdZ },
|
|
67
|
-
{ ID: 4, name: 'Green', createdZ },
|
|
68
|
-
{ ID: 5, name: 'Blue', createdZ },
|
|
69
|
-
{ ID: 6, name: 'Purple', createdZ },
|
|
70
|
-
];
|
|
71
|
-
}
|
|
72
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
AppContext,
|
|
3
|
+
Ctx,
|
|
4
|
+
Field,
|
|
5
|
+
Int,
|
|
6
|
+
ObjectType,
|
|
7
|
+
PubSub,
|
|
8
|
+
PubSubEngine,
|
|
9
|
+
Public,
|
|
10
|
+
Query,
|
|
11
|
+
Resolver,
|
|
12
|
+
Root,
|
|
13
|
+
Subscription,
|
|
14
|
+
} from '@memberjunction/server';
|
|
15
|
+
|
|
16
|
+
@ObjectType()
|
|
17
|
+
export class Color {
|
|
18
|
+
@Field(() => Int)
|
|
19
|
+
@Public()
|
|
20
|
+
ID: number;
|
|
21
|
+
|
|
22
|
+
@Field(() => String)
|
|
23
|
+
@Public()
|
|
24
|
+
name: string;
|
|
25
|
+
|
|
26
|
+
@Field(() => String)
|
|
27
|
+
@Public()
|
|
28
|
+
createdZ: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@ObjectType()
|
|
32
|
+
export class ColorNotification {
|
|
33
|
+
@Public()
|
|
34
|
+
@Field(() => String, { nullable: true })
|
|
35
|
+
message?: string;
|
|
36
|
+
|
|
37
|
+
@Public()
|
|
38
|
+
@Field((_type) => Date)
|
|
39
|
+
date!: Date;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ColorNotificationPayload {
|
|
43
|
+
message?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Resolver(Color)
|
|
47
|
+
export class ColorResolver {
|
|
48
|
+
@Subscription(() => ColorNotification, { topics: 'COLOR' })
|
|
49
|
+
@Public()
|
|
50
|
+
colorSubscription(@Root() { message }: ColorNotificationPayload): ColorNotification {
|
|
51
|
+
return { message, date: new Date() };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Query(() => [Color])
|
|
55
|
+
@Public()
|
|
56
|
+
async colors(@Ctx() _ctx: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
57
|
+
const createdZ = new Date().toISOString();
|
|
58
|
+
|
|
59
|
+
pubSub.publish('COLOR', {
|
|
60
|
+
message: 'Colors were requested!',
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return [
|
|
64
|
+
{ ID: 1, name: 'Red', createdZ },
|
|
65
|
+
{ ID: 2, name: 'Orange', createdZ },
|
|
66
|
+
{ ID: 3, name: 'Yellow', createdZ },
|
|
67
|
+
{ ID: 4, name: 'Green', createdZ },
|
|
68
|
+
{ ID: 5, name: 'Blue', createdZ },
|
|
69
|
+
{ ID: 6, name: 'Purple', createdZ },
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
import { Arg, Ctx, Field, InputType, Int, ObjectType, Query, Resolver } from 'type-graphql';
|
|
2
|
-
import { AppContext } from '../types';
|
|
3
|
-
import { LogError, Metadata } from '@memberjunction/core';
|
|
4
|
-
|
|
5
|
-
@ObjectType()
|
|
6
|
-
export class DatasetResultType {
|
|
7
|
-
@Field(() => Int)
|
|
8
|
-
DatasetID: number;
|
|
9
|
-
|
|
10
|
-
@Field(() => String)
|
|
11
|
-
DatasetName: string;
|
|
12
|
-
|
|
13
|
-
@Field(() => Boolean)
|
|
14
|
-
Success: boolean;
|
|
15
|
-
|
|
16
|
-
@Field(() => String)
|
|
17
|
-
Status: string;
|
|
18
|
-
|
|
19
|
-
@Field(() => Date)
|
|
20
|
-
LatestUpdateDate: Date;
|
|
21
|
-
|
|
22
|
-
@Field(() => String)
|
|
23
|
-
Results: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@InputType()
|
|
27
|
-
export class DatasetItemFilterTypeGQL {
|
|
28
|
-
@Field(() => String)
|
|
29
|
-
ItemCode: string;
|
|
30
|
-
|
|
31
|
-
@Field(() => String)
|
|
32
|
-
Filter: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
@Resolver(DatasetResultType)
|
|
37
|
-
export class DatasetResolverExtended {
|
|
38
|
-
@Query(() => DatasetResultType)
|
|
39
|
-
async GetDatasetByName(
|
|
40
|
-
@Arg('DatasetName', () => String) DatasetName: string,
|
|
41
|
-
@Ctx() {}: AppContext,
|
|
42
|
-
@Arg('ItemFilters', () => [DatasetItemFilterTypeGQL], { nullable: 'itemsAndList' }) ItemFilters?: DatasetItemFilterTypeGQL[]
|
|
43
|
-
) {
|
|
44
|
-
try {
|
|
45
|
-
const md = new Metadata();
|
|
46
|
-
const result = await md.GetDatasetByName(DatasetName, ItemFilters);
|
|
47
|
-
if (result) {
|
|
48
|
-
return {
|
|
49
|
-
DatasetID: result.DatasetID,
|
|
50
|
-
DatasetName: result.DatasetName,
|
|
51
|
-
Success: result.Success,
|
|
52
|
-
Status: result.Status,
|
|
53
|
-
LatestUpdateDate: result.LatestUpdateDate,
|
|
54
|
-
Results: JSON.stringify(result.Results),
|
|
55
|
-
};
|
|
56
|
-
} else {
|
|
57
|
-
throw new Error('Error retrieving Dataset: ' + DatasetName);
|
|
58
|
-
}
|
|
59
|
-
} catch (err) {
|
|
60
|
-
LogError(err);
|
|
61
|
-
throw new Error('Error retrieving Dataset: ' + DatasetName + '\n\n' + err);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
@ObjectType()
|
|
67
|
-
export class DatasetStatusResultType {
|
|
68
|
-
@Field(() => Int)
|
|
69
|
-
DatasetID: number;
|
|
70
|
-
|
|
71
|
-
@Field(() => String)
|
|
72
|
-
DatasetName: string;
|
|
73
|
-
|
|
74
|
-
@Field(() => Boolean)
|
|
75
|
-
Success: boolean;
|
|
76
|
-
|
|
77
|
-
@Field(() => String)
|
|
78
|
-
Status: string;
|
|
79
|
-
|
|
80
|
-
@Field(() => Date)
|
|
81
|
-
LatestUpdateDate: Date;
|
|
82
|
-
|
|
83
|
-
@Field(() => String)
|
|
84
|
-
EntityUpdateDates: string;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
@Resolver(DatasetStatusResultType)
|
|
88
|
-
export class DatasetStatusResolver {
|
|
89
|
-
@Query(() => DatasetStatusResultType)
|
|
90
|
-
async GetDatasetStatusByName(
|
|
91
|
-
@Arg('DatasetName', () => String) DatasetName: string,
|
|
92
|
-
@Ctx() {}: AppContext,
|
|
93
|
-
@Arg('ItemFilters', () => [DatasetItemFilterTypeGQL], { nullable: 'itemsAndList' }) ItemFilters?: DatasetItemFilterTypeGQL[]
|
|
94
|
-
) {
|
|
95
|
-
try {
|
|
96
|
-
const md = new Metadata();
|
|
97
|
-
const result = await md.GetDatasetStatusByName(DatasetName, ItemFilters);
|
|
98
|
-
if (result) {
|
|
99
|
-
return {
|
|
100
|
-
DatasetID: result.DatasetID,
|
|
101
|
-
DatasetName: result.DatasetName,
|
|
102
|
-
Success: result.Success,
|
|
103
|
-
Status: result.Status,
|
|
104
|
-
LatestUpdateDate: result.LatestUpdateDate,
|
|
105
|
-
EntityUpdateDates: JSON.stringify(result.EntityUpdateDates),
|
|
106
|
-
};
|
|
107
|
-
} else {
|
|
108
|
-
throw new Error('Error retrieving Dataset Status: ' + DatasetName);
|
|
109
|
-
}
|
|
110
|
-
} catch (err) {
|
|
111
|
-
LogError(err);
|
|
112
|
-
throw new Error('Error retrieving Dataset Status: ' + DatasetName + '\n\n' + err);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
1
|
+
import { Arg, Ctx, Field, InputType, Int, ObjectType, Query, Resolver } from 'type-graphql';
|
|
2
|
+
import { AppContext } from '../types';
|
|
3
|
+
import { LogError, Metadata } from '@memberjunction/core';
|
|
4
|
+
|
|
5
|
+
@ObjectType()
|
|
6
|
+
export class DatasetResultType {
|
|
7
|
+
@Field(() => Int)
|
|
8
|
+
DatasetID: number;
|
|
9
|
+
|
|
10
|
+
@Field(() => String)
|
|
11
|
+
DatasetName: string;
|
|
12
|
+
|
|
13
|
+
@Field(() => Boolean)
|
|
14
|
+
Success: boolean;
|
|
15
|
+
|
|
16
|
+
@Field(() => String)
|
|
17
|
+
Status: string;
|
|
18
|
+
|
|
19
|
+
@Field(() => Date)
|
|
20
|
+
LatestUpdateDate: Date;
|
|
21
|
+
|
|
22
|
+
@Field(() => String)
|
|
23
|
+
Results: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@InputType()
|
|
27
|
+
export class DatasetItemFilterTypeGQL {
|
|
28
|
+
@Field(() => String)
|
|
29
|
+
ItemCode: string;
|
|
30
|
+
|
|
31
|
+
@Field(() => String)
|
|
32
|
+
Filter: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@Resolver(DatasetResultType)
|
|
37
|
+
export class DatasetResolverExtended {
|
|
38
|
+
@Query(() => DatasetResultType)
|
|
39
|
+
async GetDatasetByName(
|
|
40
|
+
@Arg('DatasetName', () => String) DatasetName: string,
|
|
41
|
+
@Ctx() {}: AppContext,
|
|
42
|
+
@Arg('ItemFilters', () => [DatasetItemFilterTypeGQL], { nullable: 'itemsAndList' }) ItemFilters?: DatasetItemFilterTypeGQL[]
|
|
43
|
+
) {
|
|
44
|
+
try {
|
|
45
|
+
const md = new Metadata();
|
|
46
|
+
const result = await md.GetDatasetByName(DatasetName, ItemFilters);
|
|
47
|
+
if (result) {
|
|
48
|
+
return {
|
|
49
|
+
DatasetID: result.DatasetID,
|
|
50
|
+
DatasetName: result.DatasetName,
|
|
51
|
+
Success: result.Success,
|
|
52
|
+
Status: result.Status,
|
|
53
|
+
LatestUpdateDate: result.LatestUpdateDate,
|
|
54
|
+
Results: JSON.stringify(result.Results),
|
|
55
|
+
};
|
|
56
|
+
} else {
|
|
57
|
+
throw new Error('Error retrieving Dataset: ' + DatasetName);
|
|
58
|
+
}
|
|
59
|
+
} catch (err) {
|
|
60
|
+
LogError(err);
|
|
61
|
+
throw new Error('Error retrieving Dataset: ' + DatasetName + '\n\n' + err);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@ObjectType()
|
|
67
|
+
export class DatasetStatusResultType {
|
|
68
|
+
@Field(() => Int)
|
|
69
|
+
DatasetID: number;
|
|
70
|
+
|
|
71
|
+
@Field(() => String)
|
|
72
|
+
DatasetName: string;
|
|
73
|
+
|
|
74
|
+
@Field(() => Boolean)
|
|
75
|
+
Success: boolean;
|
|
76
|
+
|
|
77
|
+
@Field(() => String)
|
|
78
|
+
Status: string;
|
|
79
|
+
|
|
80
|
+
@Field(() => Date)
|
|
81
|
+
LatestUpdateDate: Date;
|
|
82
|
+
|
|
83
|
+
@Field(() => String)
|
|
84
|
+
EntityUpdateDates: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@Resolver(DatasetStatusResultType)
|
|
88
|
+
export class DatasetStatusResolver {
|
|
89
|
+
@Query(() => DatasetStatusResultType)
|
|
90
|
+
async GetDatasetStatusByName(
|
|
91
|
+
@Arg('DatasetName', () => String) DatasetName: string,
|
|
92
|
+
@Ctx() {}: AppContext,
|
|
93
|
+
@Arg('ItemFilters', () => [DatasetItemFilterTypeGQL], { nullable: 'itemsAndList' }) ItemFilters?: DatasetItemFilterTypeGQL[]
|
|
94
|
+
) {
|
|
95
|
+
try {
|
|
96
|
+
const md = new Metadata();
|
|
97
|
+
const result = await md.GetDatasetStatusByName(DatasetName, ItemFilters);
|
|
98
|
+
if (result) {
|
|
99
|
+
return {
|
|
100
|
+
DatasetID: result.DatasetID,
|
|
101
|
+
DatasetName: result.DatasetName,
|
|
102
|
+
Success: result.Success,
|
|
103
|
+
Status: result.Status,
|
|
104
|
+
LatestUpdateDate: result.LatestUpdateDate,
|
|
105
|
+
EntityUpdateDates: JSON.stringify(result.EntityUpdateDates),
|
|
106
|
+
};
|
|
107
|
+
} else {
|
|
108
|
+
throw new Error('Error retrieving Dataset Status: ' + DatasetName);
|
|
109
|
+
}
|
|
110
|
+
} catch (err) {
|
|
111
|
+
LogError(err);
|
|
112
|
+
throw new Error('Error retrieving Dataset Status: ' + DatasetName + '\n\n' + err);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
import { Metadata, PrimaryKeyValue } from '@memberjunction/core';
|
|
2
|
-
import { Arg, Ctx, Field, InputType, ObjectType, Query, Resolver } from 'type-graphql';
|
|
3
|
-
import { AppContext } from '../types';
|
|
4
|
-
import { PrimaryKeyValueInputType, PrimaryKeyValueOutputType } from './MergeRecordsResolver';
|
|
5
|
-
|
|
6
|
-
@InputType()
|
|
7
|
-
export class EntityRecordNameInput {
|
|
8
|
-
@Field(() => String)
|
|
9
|
-
EntityName: string;
|
|
10
|
-
|
|
11
|
-
@Field(() => [PrimaryKeyValueInputType])
|
|
12
|
-
PrimaryKeyValues: PrimaryKeyValue[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
@ObjectType()
|
|
16
|
-
export class EntityRecordNameResult {
|
|
17
|
-
@Field(() => Boolean)
|
|
18
|
-
Success: boolean;
|
|
19
|
-
|
|
20
|
-
@Field(() => String)
|
|
21
|
-
Status: string;
|
|
22
|
-
|
|
23
|
-
@Field(() => [PrimaryKeyValueOutputType])
|
|
24
|
-
PrimaryKeyValues: PrimaryKeyValue[];
|
|
25
|
-
|
|
26
|
-
@Field(() => String)
|
|
27
|
-
EntityName: string;
|
|
28
|
-
|
|
29
|
-
@Field(() => String, { nullable: true })
|
|
30
|
-
RecordName?: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
@Resolver(EntityRecordNameResult)
|
|
34
|
-
export class EntityRecordNameResolver {
|
|
35
|
-
@Query(() => EntityRecordNameResult)
|
|
36
|
-
async GetEntityRecordName(
|
|
37
|
-
@Arg('EntityName', () => String) EntityName: string,
|
|
38
|
-
@Arg('PrimaryKeyValues', () => [PrimaryKeyValueInputType]) PrimaryKeyValues: PrimaryKeyValue[],
|
|
39
|
-
@Ctx() {}: AppContext
|
|
40
|
-
): Promise<EntityRecordNameResult> {
|
|
41
|
-
const md = new Metadata();
|
|
42
|
-
return await this.InnerGetEntityRecordName(md, EntityName, PrimaryKeyValues);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
@Query(() => [EntityRecordNameResult])
|
|
46
|
-
async GetEntityRecordNames(
|
|
47
|
-
@Arg('info', () => [EntityRecordNameInput]) info: EntityRecordNameInput[],
|
|
48
|
-
@Ctx() {}: AppContext
|
|
49
|
-
): Promise<EntityRecordNameResult[]> {
|
|
50
|
-
const result: EntityRecordNameResult[] = [];
|
|
51
|
-
const md = new Metadata();
|
|
52
|
-
for (const i of info) {
|
|
53
|
-
result.push(await this.InnerGetEntityRecordName(md, i.EntityName, i.PrimaryKeyValues));
|
|
54
|
-
}
|
|
55
|
-
return result;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
async InnerGetEntityRecordName(md: Metadata, EntityName: string, primaryKeyValues: PrimaryKeyValue[]): Promise<EntityRecordNameResult> {
|
|
59
|
-
const e = md.Entities.find((e) => e.Name === EntityName);
|
|
60
|
-
if (e) {
|
|
61
|
-
const recordName = await md.GetEntityRecordName(e.Name, primaryKeyValues);
|
|
62
|
-
if (recordName)
|
|
63
|
-
return { Success: true, Status: 'OK', PrimaryKeyValues: primaryKeyValues, RecordName: recordName, EntityName: EntityName };
|
|
64
|
-
else
|
|
65
|
-
return {
|
|
66
|
-
Success: false,
|
|
67
|
-
Status: `Name for record, or record ${primaryKeyValues.map(pkv => pkv.FieldName + ':' + pkv.Value).join(',')} itself not found, could be an access issue if user doesn't have Row Level Access (RLS) if RLS is enabled for this entity`,
|
|
68
|
-
PrimaryKeyValues: primaryKeyValues,
|
|
69
|
-
EntityName: EntityName,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
else
|
|
73
|
-
return { Success: false, Status: `Entity ${EntityName} not found`, PrimaryKeyValues: primaryKeyValues, EntityName: EntityName };
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export default EntityRecordNameResolver;
|
|
1
|
+
import { Metadata, PrimaryKeyValue } from '@memberjunction/core';
|
|
2
|
+
import { Arg, Ctx, Field, InputType, ObjectType, Query, Resolver } from 'type-graphql';
|
|
3
|
+
import { AppContext } from '../types';
|
|
4
|
+
import { PrimaryKeyValueInputType, PrimaryKeyValueOutputType } from './MergeRecordsResolver';
|
|
5
|
+
|
|
6
|
+
@InputType()
|
|
7
|
+
export class EntityRecordNameInput {
|
|
8
|
+
@Field(() => String)
|
|
9
|
+
EntityName: string;
|
|
10
|
+
|
|
11
|
+
@Field(() => [PrimaryKeyValueInputType])
|
|
12
|
+
PrimaryKeyValues: PrimaryKeyValue[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@ObjectType()
|
|
16
|
+
export class EntityRecordNameResult {
|
|
17
|
+
@Field(() => Boolean)
|
|
18
|
+
Success: boolean;
|
|
19
|
+
|
|
20
|
+
@Field(() => String)
|
|
21
|
+
Status: string;
|
|
22
|
+
|
|
23
|
+
@Field(() => [PrimaryKeyValueOutputType])
|
|
24
|
+
PrimaryKeyValues: PrimaryKeyValue[];
|
|
25
|
+
|
|
26
|
+
@Field(() => String)
|
|
27
|
+
EntityName: string;
|
|
28
|
+
|
|
29
|
+
@Field(() => String, { nullable: true })
|
|
30
|
+
RecordName?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@Resolver(EntityRecordNameResult)
|
|
34
|
+
export class EntityRecordNameResolver {
|
|
35
|
+
@Query(() => EntityRecordNameResult)
|
|
36
|
+
async GetEntityRecordName(
|
|
37
|
+
@Arg('EntityName', () => String) EntityName: string,
|
|
38
|
+
@Arg('PrimaryKeyValues', () => [PrimaryKeyValueInputType]) PrimaryKeyValues: PrimaryKeyValue[],
|
|
39
|
+
@Ctx() {}: AppContext
|
|
40
|
+
): Promise<EntityRecordNameResult> {
|
|
41
|
+
const md = new Metadata();
|
|
42
|
+
return await this.InnerGetEntityRecordName(md, EntityName, PrimaryKeyValues);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@Query(() => [EntityRecordNameResult])
|
|
46
|
+
async GetEntityRecordNames(
|
|
47
|
+
@Arg('info', () => [EntityRecordNameInput]) info: EntityRecordNameInput[],
|
|
48
|
+
@Ctx() {}: AppContext
|
|
49
|
+
): Promise<EntityRecordNameResult[]> {
|
|
50
|
+
const result: EntityRecordNameResult[] = [];
|
|
51
|
+
const md = new Metadata();
|
|
52
|
+
for (const i of info) {
|
|
53
|
+
result.push(await this.InnerGetEntityRecordName(md, i.EntityName, i.PrimaryKeyValues));
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async InnerGetEntityRecordName(md: Metadata, EntityName: string, primaryKeyValues: PrimaryKeyValue[]): Promise<EntityRecordNameResult> {
|
|
59
|
+
const e = md.Entities.find((e) => e.Name === EntityName);
|
|
60
|
+
if (e) {
|
|
61
|
+
const recordName = await md.GetEntityRecordName(e.Name, primaryKeyValues);
|
|
62
|
+
if (recordName)
|
|
63
|
+
return { Success: true, Status: 'OK', PrimaryKeyValues: primaryKeyValues, RecordName: recordName, EntityName: EntityName };
|
|
64
|
+
else
|
|
65
|
+
return {
|
|
66
|
+
Success: false,
|
|
67
|
+
Status: `Name for record, or record ${primaryKeyValues.map(pkv => pkv.FieldName + ':' + pkv.Value).join(',')} itself not found, could be an access issue if user doesn't have Row Level Access (RLS) if RLS is enabled for this entity`,
|
|
68
|
+
PrimaryKeyValues: primaryKeyValues,
|
|
69
|
+
EntityName: EntityName,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
else
|
|
73
|
+
return { Success: false, Status: `Entity ${EntityName} not found`, PrimaryKeyValues: primaryKeyValues, EntityName: EntityName };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export default EntityRecordNameResolver;
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { EntityPermissionType } from '@memberjunction/core';
|
|
2
|
-
import { AppContext } from '../types';
|
|
3
|
-
import { Arg, Ctx, Query, Resolver, InputType, Field } from 'type-graphql';
|
|
4
|
-
import { Entity_, EntityResolverBase } from '../generated/generated';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@Resolver(Entity_)
|
|
9
|
-
export class EntityResolver extends EntityResolverBase {
|
|
10
|
-
@Query(() => [Entity_])
|
|
11
|
-
EntitiesBySchemas(
|
|
12
|
-
@Ctx() { dataSource, userPayload }: AppContext,
|
|
13
|
-
@Arg('IncludeSchemas', () => [String], { nullable: true }) IncludeSchemas?: string[],
|
|
14
|
-
@Arg('ExcludeSchemas', () => [String], { nullable: true }) ExcludeSchemas?: string[]
|
|
15
|
-
) {
|
|
16
|
-
this.CheckUserReadPermissions('Entities', userPayload);
|
|
17
|
-
const rlsWhere = this.getRowLevelSecurityWhereClause('Entities', userPayload, EntityPermissionType.Read, ' WHERE');
|
|
18
|
-
const includeSchemaSQL =
|
|
19
|
-
IncludeSchemas && IncludeSchemas.length > 0 ? `SchemaName IN (${IncludeSchemas.map((s) => `'${s}'`).join(',')})` : '';
|
|
20
|
-
const excludeSchemaSQL =
|
|
21
|
-
ExcludeSchemas && ExcludeSchemas.length > 0 ? `SchemaName NOT IN (${ExcludeSchemas.map((s) => `'${s}'`).join(',')})` : '';
|
|
22
|
-
let schemaSQL = '';
|
|
23
|
-
if (includeSchemaSQL) schemaSQL = includeSchemaSQL;
|
|
24
|
-
if (excludeSchemaSQL) {
|
|
25
|
-
if (schemaSQL) schemaSQL = `${schemaSQL} AND ${excludeSchemaSQL}`;
|
|
26
|
-
else schemaSQL = excludeSchemaSQL;
|
|
27
|
-
}
|
|
28
|
-
let totalWhere = '';
|
|
29
|
-
if (schemaSQL) totalWhere = ` WHERE ${schemaSQL}`;
|
|
30
|
-
if (rlsWhere) {
|
|
31
|
-
if (totalWhere) totalWhere = `${totalWhere} AND ${rlsWhere}`;
|
|
32
|
-
else totalWhere = ` WHERE ${rlsWhere}`;
|
|
33
|
-
}
|
|
34
|
-
const sSQL = `SELECT * FROM [${this.MJCoreSchema}].vwEntities${totalWhere}`;
|
|
35
|
-
return dataSource.query(sSQL);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
1
|
+
import { EntityPermissionType } from '@memberjunction/core';
|
|
2
|
+
import { AppContext } from '../types';
|
|
3
|
+
import { Arg, Ctx, Query, Resolver, InputType, Field } from 'type-graphql';
|
|
4
|
+
import { Entity_, EntityResolverBase } from '../generated/generated';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@Resolver(Entity_)
|
|
9
|
+
export class EntityResolver extends EntityResolverBase {
|
|
10
|
+
@Query(() => [Entity_])
|
|
11
|
+
EntitiesBySchemas(
|
|
12
|
+
@Ctx() { dataSource, userPayload }: AppContext,
|
|
13
|
+
@Arg('IncludeSchemas', () => [String], { nullable: true }) IncludeSchemas?: string[],
|
|
14
|
+
@Arg('ExcludeSchemas', () => [String], { nullable: true }) ExcludeSchemas?: string[]
|
|
15
|
+
) {
|
|
16
|
+
this.CheckUserReadPermissions('Entities', userPayload);
|
|
17
|
+
const rlsWhere = this.getRowLevelSecurityWhereClause('Entities', userPayload, EntityPermissionType.Read, ' WHERE');
|
|
18
|
+
const includeSchemaSQL =
|
|
19
|
+
IncludeSchemas && IncludeSchemas.length > 0 ? `SchemaName IN (${IncludeSchemas.map((s) => `'${s}'`).join(',')})` : '';
|
|
20
|
+
const excludeSchemaSQL =
|
|
21
|
+
ExcludeSchemas && ExcludeSchemas.length > 0 ? `SchemaName NOT IN (${ExcludeSchemas.map((s) => `'${s}'`).join(',')})` : '';
|
|
22
|
+
let schemaSQL = '';
|
|
23
|
+
if (includeSchemaSQL) schemaSQL = includeSchemaSQL;
|
|
24
|
+
if (excludeSchemaSQL) {
|
|
25
|
+
if (schemaSQL) schemaSQL = `${schemaSQL} AND ${excludeSchemaSQL}`;
|
|
26
|
+
else schemaSQL = excludeSchemaSQL;
|
|
27
|
+
}
|
|
28
|
+
let totalWhere = '';
|
|
29
|
+
if (schemaSQL) totalWhere = ` WHERE ${schemaSQL}`;
|
|
30
|
+
if (rlsWhere) {
|
|
31
|
+
if (totalWhere) totalWhere = `${totalWhere} AND ${rlsWhere}`;
|
|
32
|
+
else totalWhere = ` WHERE ${rlsWhere}`;
|
|
33
|
+
}
|
|
34
|
+
const sSQL = `SELECT * FROM [${this.MJCoreSchema}].vwEntities${totalWhere}`;
|
|
35
|
+
return dataSource.query(sSQL);
|
|
36
|
+
}
|
|
37
|
+
}
|