@memberjunction/server 0.9.218 → 0.9.219
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/build.log.json
CHANGED
|
@@ -12,9 +12,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.ReportResolverExtended = exports.RunReportResultType = void 0;
|
|
15
|
+
exports.ReportResolverExtended = exports.CreateReportResultType = exports.RunReportResultType = void 0;
|
|
16
16
|
const core_1 = require("@memberjunction/core");
|
|
17
17
|
const type_graphql_1 = require("type-graphql");
|
|
18
|
+
const data_context_1 = require("@memberjunction/data-context");
|
|
19
|
+
const sqlserver_dataprovider_1 = require("@memberjunction/sqlserver-dataprovider");
|
|
18
20
|
let RunReportResultType = class RunReportResultType {
|
|
19
21
|
};
|
|
20
22
|
exports.RunReportResultType = RunReportResultType;
|
|
@@ -45,6 +47,28 @@ __decorate([
|
|
|
45
47
|
exports.RunReportResultType = RunReportResultType = __decorate([
|
|
46
48
|
(0, type_graphql_1.ObjectType)()
|
|
47
49
|
], RunReportResultType);
|
|
50
|
+
let CreateReportResultType = class CreateReportResultType {
|
|
51
|
+
};
|
|
52
|
+
exports.CreateReportResultType = CreateReportResultType;
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, type_graphql_1.Field)(),
|
|
55
|
+
__metadata("design:type", Number)
|
|
56
|
+
], CreateReportResultType.prototype, "ReportID", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, type_graphql_1.Field)(),
|
|
59
|
+
__metadata("design:type", String)
|
|
60
|
+
], CreateReportResultType.prototype, "ReportName", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, type_graphql_1.Field)(),
|
|
63
|
+
__metadata("design:type", Boolean)
|
|
64
|
+
], CreateReportResultType.prototype, "Success", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, type_graphql_1.Field)(),
|
|
67
|
+
__metadata("design:type", String)
|
|
68
|
+
], CreateReportResultType.prototype, "ErrorMessage", void 0);
|
|
69
|
+
exports.CreateReportResultType = CreateReportResultType = __decorate([
|
|
70
|
+
(0, type_graphql_1.ObjectType)()
|
|
71
|
+
], CreateReportResultType);
|
|
48
72
|
let ReportResolverExtended = class ReportResolverExtended {
|
|
49
73
|
async GetReportData(ReportID, {}) {
|
|
50
74
|
const runReport = new core_1.RunReport();
|
|
@@ -58,6 +82,60 @@ let ReportResolverExtended = class ReportResolverExtended {
|
|
|
58
82
|
ErrorMessage: result.ErrorMessage,
|
|
59
83
|
};
|
|
60
84
|
}
|
|
85
|
+
async CreateReportFromConversationDetailID(ConversationDetailID, { dataSource, userPayload }) {
|
|
86
|
+
const md = new core_1.Metadata();
|
|
87
|
+
const u = sqlserver_dataprovider_1.UserCache.Users.find(u => u.Email?.trim().toLowerCase() === userPayload?.email?.trim().toLowerCase());
|
|
88
|
+
if (!u)
|
|
89
|
+
throw new Error('Unable to find user');
|
|
90
|
+
const cde = md.Entities.find(e => e.Name === 'Conversation Details');
|
|
91
|
+
if (!cde)
|
|
92
|
+
throw new Error('Unable to find Conversation Details Entity metadata');
|
|
93
|
+
const cd = md.Entities.find(e => e.Name === 'Conversations');
|
|
94
|
+
if (!cd)
|
|
95
|
+
throw new Error('Unable to find Conversations Entity metadata');
|
|
96
|
+
const sql = `SELECT cd.Message, cd.ConversationID, c.DataContextID
|
|
97
|
+
FROM ${cde.SchemaName}.${cde.BaseView} cd
|
|
98
|
+
INNER JOIN ${cd.SchemaName}.${cd.BaseView} c
|
|
99
|
+
ON cd.ConversationID = c.ID
|
|
100
|
+
WHERE cd.ID=${ConversationDetailID}`;
|
|
101
|
+
const result = await dataSource.query(sql);
|
|
102
|
+
if (!result || result.length === 0)
|
|
103
|
+
throw new Error('Unable to retrieve converation details');
|
|
104
|
+
const skipData = JSON.parse(result[0].Message);
|
|
105
|
+
const report = await md.GetEntityObject('Reports', u);
|
|
106
|
+
report.NewRecord();
|
|
107
|
+
report.Name = skipData.reportTitle ? skipData.reportTitle : 'Untitled Report';
|
|
108
|
+
report.Description = skipData.userExplanation ? skipData.userExplanation : '';
|
|
109
|
+
report.ConversationID = result[0].ConversationID;
|
|
110
|
+
report.ConversationDetailID = ConversationDetailID;
|
|
111
|
+
const dc = new data_context_1.DataContext();
|
|
112
|
+
await dc.LoadMetadata(result[0].DataContextID, u);
|
|
113
|
+
const newDataContext = await data_context_1.DataContext.Clone(dc, false, u);
|
|
114
|
+
if (!newDataContext)
|
|
115
|
+
throw new Error('Error cloning data context');
|
|
116
|
+
report.DataContextID = newDataContext.ID;
|
|
117
|
+
const newSkipData = JSON.parse(JSON.stringify(skipData));
|
|
118
|
+
newSkipData.messages = [];
|
|
119
|
+
report.Configuration = JSON.stringify(newSkipData);
|
|
120
|
+
report.SharingScope = 'None';
|
|
121
|
+
report.UserID = u.ID;
|
|
122
|
+
if (await report.Save()) {
|
|
123
|
+
return {
|
|
124
|
+
ReportID: report.ID,
|
|
125
|
+
ReportName: report.Name,
|
|
126
|
+
Success: true,
|
|
127
|
+
ErrorMessage: ''
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
return {
|
|
132
|
+
ReportID: -1,
|
|
133
|
+
ReportName: '',
|
|
134
|
+
Success: false,
|
|
135
|
+
ErrorMessage: 'Unable to save new report'
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
61
139
|
};
|
|
62
140
|
exports.ReportResolverExtended = ReportResolverExtended;
|
|
63
141
|
__decorate([
|
|
@@ -68,6 +146,14 @@ __decorate([
|
|
|
68
146
|
__metadata("design:paramtypes", [Number, Object]),
|
|
69
147
|
__metadata("design:returntype", Promise)
|
|
70
148
|
], ReportResolverExtended.prototype, "GetReportData", null);
|
|
149
|
+
__decorate([
|
|
150
|
+
(0, type_graphql_1.Mutation)(() => CreateReportResultType),
|
|
151
|
+
__param(0, (0, type_graphql_1.Arg)('ConversationDetailID', () => type_graphql_1.Int)),
|
|
152
|
+
__param(1, (0, type_graphql_1.Ctx)()),
|
|
153
|
+
__metadata("design:type", Function),
|
|
154
|
+
__metadata("design:paramtypes", [Number, Object]),
|
|
155
|
+
__metadata("design:returntype", Promise)
|
|
156
|
+
], ReportResolverExtended.prototype, "CreateReportFromConversationDetailID", null);
|
|
71
157
|
exports.ReportResolverExtended = ReportResolverExtended = __decorate([
|
|
72
158
|
(0, type_graphql_1.Resolver)(RunReportResultType)
|
|
73
159
|
], ReportResolverExtended);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReportResolver.js","sourceRoot":"","sources":["../../src/resolvers/ReportResolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"ReportResolver.js","sourceRoot":"","sources":["../../src/resolvers/ReportResolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAA2D;AAC3D,+CAA2F;AAI3F,+DAA2D;AAC3D,mFAAmE;AAG5D,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;CAkB/B,CAAA;AAlBY,kDAAmB;AAE9B;IADC,IAAA,oBAAK,GAAE;;qDACS;AAGjB;IADC,IAAA,oBAAK,GAAE;;oDACS;AAGjB;IADC,IAAA,oBAAK,GAAE;;oDACQ;AAGhB;IADC,IAAA,oBAAK,GAAE;;qDACS;AAGjB;IADC,IAAA,oBAAK,GAAE;;0DACc;AAGtB;IADC,IAAA,oBAAK,GAAE;;yDACa;8BAjBV,mBAAmB;IAD/B,IAAA,yBAAU,GAAE;GACA,mBAAmB,CAkB/B;AAGM,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;CAYlC,CAAA;AAZY,wDAAsB;AAEjC;IADC,IAAA,oBAAK,GAAE;;wDACS;AAGjB;IADC,IAAA,oBAAK,GAAE;;0DACW;AAGnB;IADC,IAAA,oBAAK,GAAE;;uDACS;A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EAAE,CAAC,sBAAsB,CAAC;IACK,WAAA,IAAA,kBAAG,EAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC,kBAAG,CAAC,CAAA;IACtC,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;kFAgEhD;iCApFU,sBAAsB;IADlC,IAAA,uBAAQ,EAAC,mBAAmB,CAAC;GACjB,sBAAsB,CAqFlC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/server",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.219",
|
|
4
4
|
"description": "MemberJunction: This project provides API access via GraphQL to the common data store.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -21,16 +21,16 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@apollo/server": "^4.9.1",
|
|
23
23
|
"@graphql-tools/utils": "^10.0.1",
|
|
24
|
-
"@memberjunction/ai": "^0.9.
|
|
25
|
-
"@memberjunction/aiengine": "^0.9.
|
|
26
|
-
"@memberjunction/core": "^0.9.
|
|
27
|
-
"@memberjunction/core-entities": "^0.9.
|
|
28
|
-
"@memberjunction/data-context": "^0.9.
|
|
29
|
-
"@memberjunction/data-context-server": "^0.9.
|
|
24
|
+
"@memberjunction/ai": "^0.9.155",
|
|
25
|
+
"@memberjunction/aiengine": "^0.9.51",
|
|
26
|
+
"@memberjunction/core": "^0.9.165",
|
|
27
|
+
"@memberjunction/core-entities": "^0.9.149",
|
|
28
|
+
"@memberjunction/data-context": "^0.9.35",
|
|
29
|
+
"@memberjunction/data-context-server": "^0.9.31",
|
|
30
30
|
"@memberjunction/global": "^0.9.146",
|
|
31
|
-
"@memberjunction/queue": "^0.9.
|
|
32
|
-
"@memberjunction/sqlserver-dataprovider": "^0.9.
|
|
33
|
-
"@memberjunction/skip-types": "^0.9.
|
|
31
|
+
"@memberjunction/queue": "^0.9.169",
|
|
32
|
+
"@memberjunction/sqlserver-dataprovider": "^0.9.180",
|
|
33
|
+
"@memberjunction/skip-types": "^0.9.59",
|
|
34
34
|
"@types/cors": "^2.8.13",
|
|
35
35
|
"@types/jsonwebtoken": "^8.5.9",
|
|
36
36
|
"@types/node": "^18.11.14",
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { RunReport } from '@memberjunction/core';
|
|
2
|
-
import { Arg, Ctx, Field, Int, ObjectType, Query, Resolver } from 'type-graphql';
|
|
1
|
+
import { Metadata, RunReport } from '@memberjunction/core';
|
|
2
|
+
import { Arg, Ctx, Field, Int, Mutation, ObjectType, Query, Resolver } from 'type-graphql';
|
|
3
3
|
import { AppContext } from '../types';
|
|
4
|
+
import { ConversationDetailEntity, ReportEntity } from '@memberjunction/core-entities';
|
|
5
|
+
import { SkipAPIAnalysisCompleteResponse } from '@memberjunction/skip-types';
|
|
6
|
+
import { DataContext } from '@memberjunction/data-context';
|
|
7
|
+
import { UserCache } from '@memberjunction/sqlserver-dataprovider';
|
|
4
8
|
|
|
5
9
|
@ObjectType()
|
|
6
10
|
export class RunReportResultType {
|
|
@@ -23,6 +27,21 @@ export class RunReportResultType {
|
|
|
23
27
|
ErrorMessage: string;
|
|
24
28
|
}
|
|
25
29
|
|
|
30
|
+
@ObjectType()
|
|
31
|
+
export class CreateReportResultType {
|
|
32
|
+
@Field()
|
|
33
|
+
ReportID: number;
|
|
34
|
+
|
|
35
|
+
@Field()
|
|
36
|
+
ReportName: string;
|
|
37
|
+
|
|
38
|
+
@Field()
|
|
39
|
+
Success: boolean;
|
|
40
|
+
|
|
41
|
+
@Field()
|
|
42
|
+
ErrorMessage: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
26
45
|
@Resolver(RunReportResultType)
|
|
27
46
|
export class ReportResolverExtended {
|
|
28
47
|
@Query(() => RunReportResultType)
|
|
@@ -38,4 +57,75 @@ export class ReportResolverExtended {
|
|
|
38
57
|
ErrorMessage: result.ErrorMessage,
|
|
39
58
|
};
|
|
40
59
|
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* This mutation will create a new report from a conversation detail ID
|
|
63
|
+
*/
|
|
64
|
+
@Mutation(() => CreateReportResultType)
|
|
65
|
+
async CreateReportFromConversationDetailID(@Arg('ConversationDetailID', () => Int) ConversationDetailID: number,
|
|
66
|
+
@Ctx() {dataSource, userPayload}: AppContext): Promise<CreateReportResultType> {
|
|
67
|
+
const md = new Metadata();
|
|
68
|
+
|
|
69
|
+
const u = UserCache.Users.find(u => u.Email?.trim().toLowerCase() === userPayload?.email?.trim().toLowerCase());
|
|
70
|
+
if (!u)
|
|
71
|
+
throw new Error('Unable to find user')
|
|
72
|
+
|
|
73
|
+
const cde = md.Entities.find(e => e.Name === 'Conversation Details')
|
|
74
|
+
if (!cde)
|
|
75
|
+
throw new Error('Unable to find Conversation Details Entity metadata')
|
|
76
|
+
|
|
77
|
+
const cd = md.Entities.find(e => e.Name === 'Conversations')
|
|
78
|
+
if (!cd)
|
|
79
|
+
throw new Error('Unable to find Conversations Entity metadata')
|
|
80
|
+
|
|
81
|
+
const sql = `SELECT cd.Message, cd.ConversationID, c.DataContextID
|
|
82
|
+
FROM ${cde.SchemaName}.${cde.BaseView} cd
|
|
83
|
+
INNER JOIN ${cd.SchemaName}.${cd.BaseView} c
|
|
84
|
+
ON cd.ConversationID = c.ID
|
|
85
|
+
WHERE cd.ID=${ConversationDetailID}`
|
|
86
|
+
const result = await dataSource.query(sql);
|
|
87
|
+
if (!result || result.length === 0)
|
|
88
|
+
throw new Error('Unable to retrieve converation details')
|
|
89
|
+
const skipData = <SkipAPIAnalysisCompleteResponse>JSON.parse(result[0].Message);
|
|
90
|
+
|
|
91
|
+
const report = await md.GetEntityObject<ReportEntity>('Reports', u);
|
|
92
|
+
report.NewRecord();
|
|
93
|
+
report.Name = skipData.reportTitle ? skipData.reportTitle : 'Untitled Report';
|
|
94
|
+
report.Description = skipData.userExplanation ? skipData.userExplanation : '';
|
|
95
|
+
report.ConversationID = result[0].ConversationID;
|
|
96
|
+
report.ConversationDetailID = ConversationDetailID;
|
|
97
|
+
|
|
98
|
+
const dc: DataContext = new DataContext();
|
|
99
|
+
await dc.LoadMetadata(result[0].DataContextID, u);
|
|
100
|
+
const newDataContext = await DataContext.Clone(dc, false, u);
|
|
101
|
+
if (!newDataContext)
|
|
102
|
+
throw new Error('Error cloning data context')
|
|
103
|
+
report.DataContextID = newDataContext.ID;
|
|
104
|
+
|
|
105
|
+
// next, strip out the messags from the SkipData object to put them into our Report Configuration as we dont need to store that information as we have a
|
|
106
|
+
// link back to the conversation and conversation detail
|
|
107
|
+
const newSkipData : SkipAPIAnalysisCompleteResponse = JSON.parse(JSON.stringify(skipData));
|
|
108
|
+
newSkipData.messages = [];
|
|
109
|
+
report.Configuration = JSON.stringify(newSkipData)
|
|
110
|
+
|
|
111
|
+
report.SharingScope = 'None'
|
|
112
|
+
report.UserID = u.ID;
|
|
113
|
+
|
|
114
|
+
if (await report.Save()) {
|
|
115
|
+
return {
|
|
116
|
+
ReportID: report.ID,
|
|
117
|
+
ReportName: report.Name,
|
|
118
|
+
Success: true,
|
|
119
|
+
ErrorMessage: ''
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
return {
|
|
124
|
+
ReportID: -1,
|
|
125
|
+
ReportName: '',
|
|
126
|
+
Success: false,
|
|
127
|
+
ErrorMessage: 'Unable to save new report'
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
41
131
|
}
|