@memberjunction/server 2.80.0 → 2.81.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.
@@ -70,6 +70,18 @@ export class CreateQuerySystemUserInput {
70
70
  @Field(() => Boolean, { nullable: true })
71
71
  UsesTemplate?: boolean;
72
72
 
73
+ @Field(() => Boolean, { nullable: true })
74
+ AuditQueryRuns?: boolean;
75
+
76
+ @Field(() => Boolean, { nullable: true })
77
+ CacheEnabled?: boolean;
78
+
79
+ @Field(() => Number, { nullable: true })
80
+ CacheTTLMinutes?: number;
81
+
82
+ @Field(() => Number, { nullable: true })
83
+ CacheMaxSize?: number;
84
+
73
85
  @Field(() => [QueryPermissionInputType], { nullable: true })
74
86
  Permissions?: QueryPermissionInputType[];
75
87
  }
@@ -118,6 +130,18 @@ export class UpdateQuerySystemUserInput {
118
130
  @Field(() => Boolean, { nullable: true })
119
131
  UsesTemplate?: boolean;
120
132
 
133
+ @Field(() => Boolean, { nullable: true })
134
+ AuditQueryRuns?: boolean;
135
+
136
+ @Field(() => Boolean, { nullable: true })
137
+ CacheEnabled?: boolean;
138
+
139
+ @Field(() => Number, { nullable: true })
140
+ CacheTTLMinutes?: number;
141
+
142
+ @Field(() => Number, { nullable: true })
143
+ CacheMaxSize?: number;
144
+
121
145
  @Field(() => [QueryPermissionInputType], { nullable: true })
122
146
  Permissions?: QueryPermissionInputType[];
123
147
  }
@@ -305,7 +329,11 @@ export class QueryResolverExtended extends QueryResolver {
305
329
  CategoryID: finalCategoryID || input.CategoryID,
306
330
  Status: input.Status || 'Approved',
307
331
  QualityRank: input.QualityRank || 0,
308
- UsesTemplate: input.UsesTemplate || false
332
+ UsesTemplate: input.UsesTemplate || false,
333
+ AuditQueryRuns: input.AuditQueryRuns || false,
334
+ CacheEnabled: input.CacheEnabled || false,
335
+ CacheTTLMinutes: input.CacheTTLMinutes || null,
336
+ CacheMaxSize: input.CacheMaxSize || null
309
337
  };
310
338
  // Remove Permissions from the fields to set since we handle them separately
311
339
  delete (fieldsToSet as any).Permissions;
@@ -407,18 +435,26 @@ export class QueryResolverExtended extends QueryResolver {
407
435
  }
408
436
 
409
437
  // Update fields that were provided
410
- if (input.Name !== undefined) queryEntity.Name = input.Name;
411
- if (finalCategoryID !== undefined) queryEntity.CategoryID = finalCategoryID;
412
- if (input.UserQuestion !== undefined) queryEntity.UserQuestion = input.UserQuestion;
413
- if (input.Description !== undefined) queryEntity.Description = input.Description;
414
- if (input.SQL !== undefined) queryEntity.SQL = input.SQL;
415
- if (input.TechnicalDescription !== undefined) queryEntity.TechnicalDescription = input.TechnicalDescription;
416
- if (input.OriginalSQL !== undefined) queryEntity.OriginalSQL = input.OriginalSQL;
417
- if (input.Feedback !== undefined) queryEntity.Feedback = input.Feedback;
418
- if (input.Status !== undefined) queryEntity.Status = input.Status;
419
- if (input.QualityRank !== undefined) queryEntity.QualityRank = input.QualityRank;
420
- if (input.ExecutionCostRank !== undefined) queryEntity.ExecutionCostRank = input.ExecutionCostRank;
421
- if (input.UsesTemplate !== undefined) queryEntity.UsesTemplate = input.UsesTemplate;
438
+ const updateFields: Record<string, any> = {};
439
+ if (input.Name !== undefined) updateFields.Name = input.Name;
440
+ if (finalCategoryID !== undefined) updateFields.CategoryID = finalCategoryID;
441
+ if (input.UserQuestion !== undefined) updateFields.UserQuestion = input.UserQuestion;
442
+ if (input.Description !== undefined) updateFields.Description = input.Description;
443
+ if (input.SQL !== undefined) updateFields.SQL = input.SQL;
444
+ if (input.TechnicalDescription !== undefined) updateFields.TechnicalDescription = input.TechnicalDescription;
445
+ if (input.OriginalSQL !== undefined) updateFields.OriginalSQL = input.OriginalSQL;
446
+ if (input.Feedback !== undefined) updateFields.Feedback = input.Feedback;
447
+ if (input.Status !== undefined) updateFields.Status = input.Status;
448
+ if (input.QualityRank !== undefined) updateFields.QualityRank = input.QualityRank;
449
+ if (input.ExecutionCostRank !== undefined) updateFields.ExecutionCostRank = input.ExecutionCostRank;
450
+ if (input.UsesTemplate !== undefined) updateFields.UsesTemplate = input.UsesTemplate;
451
+ if (input.AuditQueryRuns !== undefined) updateFields.AuditQueryRuns = input.AuditQueryRuns;
452
+ if (input.CacheEnabled !== undefined) updateFields.CacheEnabled = input.CacheEnabled;
453
+ if (input.CacheTTLMinutes !== undefined) updateFields.CacheTTLMinutes = input.CacheTTLMinutes;
454
+ if (input.CacheMaxSize !== undefined) updateFields.CacheMaxSize = input.CacheMaxSize;
455
+
456
+ // Use SetMany to update all fields at once
457
+ queryEntity.SetMany(updateFields);
422
458
 
423
459
  // Save the updated query
424
460
  const saveResult = await queryEntity.Save();
@@ -3,7 +3,6 @@ import { RunQuery, QueryInfo } from '@memberjunction/core';
3
3
  import { AppContext } from '../types.js';
4
4
  import { RequireSystemUser } from '../directives/RequireSystemUser.js';
5
5
  import { GraphQLJSONObject } from 'graphql-type-json';
6
- import { QueryEntity } from '@memberjunction/core-entities';
7
6
  import { Metadata } from '@memberjunction/core';
8
7
 
9
8
  @ObjectType()
@@ -34,6 +33,12 @@ export class RunQueryResultType {
34
33
 
35
34
  @Field(() => String, { nullable: true })
36
35
  AppliedParameters?: string;
36
+
37
+ @Field(() => Boolean, { nullable: true })
38
+ CacheHit?: boolean;
39
+
40
+ @Field(() => Int, { nullable: true })
41
+ CacheTTLRemaining?: number;
37
42
  }
38
43
 
39
44
  @Resolver()
@@ -79,9 +84,11 @@ export class RunQueryResolver {
79
84
  @Arg('CategoryPath', () => String, {nullable: true}) CategoryPath?: string,
80
85
  @Arg('Parameters', () => GraphQLJSONObject, {nullable: true}) Parameters?: Record<string, any>,
81
86
  @Arg('MaxRows', () => Int, {nullable: true}) MaxRows?: number,
82
- @Arg('StartRow', () => Int, {nullable: true}) StartRow?: number): Promise<RunQueryResultType> {
87
+ @Arg('StartRow', () => Int, {nullable: true}) StartRow?: number,
88
+ @Arg('ForceAuditLog', () => Boolean, {nullable: true}) ForceAuditLog?: boolean,
89
+ @Arg('AuditLogDescription', () => String, {nullable: true}) AuditLogDescription?: string): Promise<RunQueryResultType> {
83
90
  const runQuery = new RunQuery();
84
- console.log('GetQueryData called with:', { QueryID, Parameters, MaxRows, StartRow });
91
+ console.log('GetQueryData called with:', { QueryID, Parameters, MaxRows, StartRow, ForceAuditLog, AuditLogDescription });
85
92
  const result = await runQuery.RunQuery(
86
93
  {
87
94
  QueryID: QueryID,
@@ -89,7 +96,9 @@ export class RunQueryResolver {
89
96
  CategoryPath: CategoryPath,
90
97
  Parameters: Parameters,
91
98
  MaxRows: MaxRows,
92
- StartRow: StartRow
99
+ StartRow: StartRow,
100
+ ForceAuditLog: ForceAuditLog,
101
+ AuditLogDescription: AuditLogDescription
93
102
  },
94
103
  context.userPayload.userRecord);
95
104
  console.log('RunQuery result:', {
@@ -120,7 +129,9 @@ export class RunQueryResolver {
120
129
  TotalRowCount: result.TotalRowCount ?? 0,
121
130
  ExecutionTime: result.ExecutionTime ?? 0,
122
131
  ErrorMessage: result.ErrorMessage || '',
123
- AppliedParameters: result.AppliedParameters ? JSON.stringify(result.AppliedParameters) : undefined
132
+ AppliedParameters: result.AppliedParameters ? JSON.stringify(result.AppliedParameters) : undefined,
133
+ CacheHit: (result as any).CacheHit,
134
+ CacheTTLRemaining: (result as any).CacheTTLRemaining
124
135
  };
125
136
  }
126
137
 
@@ -131,7 +142,9 @@ export class RunQueryResolver {
131
142
  @Arg('CategoryPath', () => String, {nullable: true}) CategoryPath?: string,
132
143
  @Arg('Parameters', () => GraphQLJSONObject, {nullable: true}) Parameters?: Record<string, any>,
133
144
  @Arg('MaxRows', () => Int, {nullable: true}) MaxRows?: number,
134
- @Arg('StartRow', () => Int, {nullable: true}) StartRow?: number): Promise<RunQueryResultType> {
145
+ @Arg('StartRow', () => Int, {nullable: true}) StartRow?: number,
146
+ @Arg('ForceAuditLog', () => Boolean, {nullable: true}) ForceAuditLog?: boolean,
147
+ @Arg('AuditLogDescription', () => String, {nullable: true}) AuditLogDescription?: string): Promise<RunQueryResultType> {
135
148
  const runQuery = new RunQuery();
136
149
  const result = await runQuery.RunQuery(
137
150
  {
@@ -140,7 +153,9 @@ export class RunQueryResolver {
140
153
  CategoryPath: CategoryPath,
141
154
  Parameters: Parameters,
142
155
  MaxRows: MaxRows,
143
- StartRow: StartRow
156
+ StartRow: StartRow,
157
+ ForceAuditLog: ForceAuditLog,
158
+ AuditLogDescription: AuditLogDescription
144
159
  },
145
160
  context.userPayload.userRecord);
146
161
 
@@ -153,7 +168,9 @@ export class RunQueryResolver {
153
168
  TotalRowCount: result.TotalRowCount ?? 0,
154
169
  ExecutionTime: result.ExecutionTime ?? 0,
155
170
  ErrorMessage: result.ErrorMessage || '',
156
- AppliedParameters: result.AppliedParameters ? JSON.stringify(result.AppliedParameters) : undefined
171
+ AppliedParameters: result.AppliedParameters ? JSON.stringify(result.AppliedParameters) : undefined,
172
+ CacheHit: (result as any).CacheHit,
173
+ CacheTTLRemaining: (result as any).CacheTTLRemaining
157
174
  };
158
175
  }
159
176
 
@@ -165,7 +182,9 @@ export class RunQueryResolver {
165
182
  @Arg('CategoryPath', () => String, {nullable: true}) CategoryPath?: string,
166
183
  @Arg('Parameters', () => GraphQLJSONObject, {nullable: true}) Parameters?: Record<string, any>,
167
184
  @Arg('MaxRows', () => Int, {nullable: true}) MaxRows?: number,
168
- @Arg('StartRow', () => Int, {nullable: true}) StartRow?: number): Promise<RunQueryResultType> {
185
+ @Arg('StartRow', () => Int, {nullable: true}) StartRow?: number,
186
+ @Arg('ForceAuditLog', () => Boolean, {nullable: true}) ForceAuditLog?: boolean,
187
+ @Arg('AuditLogDescription', () => String, {nullable: true}) AuditLogDescription?: string): Promise<RunQueryResultType> {
169
188
  const runQuery = new RunQuery();
170
189
  const result = await runQuery.RunQuery(
171
190
  {
@@ -174,7 +193,9 @@ export class RunQueryResolver {
174
193
  CategoryPath: CategoryPath,
175
194
  Parameters: Parameters,
176
195
  MaxRows: MaxRows,
177
- StartRow: StartRow
196
+ StartRow: StartRow,
197
+ ForceAuditLog: ForceAuditLog,
198
+ AuditLogDescription: AuditLogDescription
178
199
  },
179
200
  context.userPayload.userRecord);
180
201
 
@@ -200,7 +221,9 @@ export class RunQueryResolver {
200
221
  TotalRowCount: result.TotalRowCount ?? 0,
201
222
  ExecutionTime: result.ExecutionTime ?? 0,
202
223
  ErrorMessage: result.ErrorMessage || '',
203
- AppliedParameters: result.AppliedParameters ? JSON.stringify(result.AppliedParameters) : undefined
224
+ AppliedParameters: result.AppliedParameters ? JSON.stringify(result.AppliedParameters) : undefined,
225
+ CacheHit: (result as any).CacheHit,
226
+ CacheTTLRemaining: (result as any).CacheTTLRemaining
204
227
  };
205
228
  }
206
229
 
@@ -212,7 +235,9 @@ export class RunQueryResolver {
212
235
  @Arg('CategoryPath', () => String, {nullable: true}) CategoryPath?: string,
213
236
  @Arg('Parameters', () => GraphQLJSONObject, {nullable: true}) Parameters?: Record<string, any>,
214
237
  @Arg('MaxRows', () => Int, {nullable: true}) MaxRows?: number,
215
- @Arg('StartRow', () => Int, {nullable: true}) StartRow?: number): Promise<RunQueryResultType> {
238
+ @Arg('StartRow', () => Int, {nullable: true}) StartRow?: number,
239
+ @Arg('ForceAuditLog', () => Boolean, {nullable: true}) ForceAuditLog?: boolean,
240
+ @Arg('AuditLogDescription', () => String, {nullable: true}) AuditLogDescription?: string): Promise<RunQueryResultType> {
216
241
  const runQuery = new RunQuery();
217
242
  const result = await runQuery.RunQuery(
218
243
  {
@@ -221,7 +246,9 @@ export class RunQueryResolver {
221
246
  CategoryPath: CategoryPath,
222
247
  Parameters: Parameters,
223
248
  MaxRows: MaxRows,
224
- StartRow: StartRow
249
+ StartRow: StartRow,
250
+ ForceAuditLog: ForceAuditLog,
251
+ AuditLogDescription: AuditLogDescription
225
252
  },
226
253
  context.userPayload.userRecord);
227
254
 
@@ -234,7 +261,9 @@ export class RunQueryResolver {
234
261
  TotalRowCount: result.TotalRowCount ?? 0,
235
262
  ExecutionTime: result.ExecutionTime ?? 0,
236
263
  ErrorMessage: result.ErrorMessage || '',
237
- AppliedParameters: result.AppliedParameters ? JSON.stringify(result.AppliedParameters) : undefined
264
+ AppliedParameters: result.AppliedParameters ? JSON.stringify(result.AppliedParameters) : undefined,
265
+ CacheHit: (result as any).CacheHit,
266
+ CacheTTLRemaining: (result as any).CacheTTLRemaining
238
267
  };
239
268
  }
240
269
  }