@memberjunction/server 2.120.0 → 2.122.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.
@@ -1682,70 +1682,53 @@ export class AskSkipResolver {
1682
1682
  protected BuildSkipQueries(status: "Pending" | "In-Review" | "Approved" | "Rejected" | "Obsolete" = 'Approved'): SkipQueryInfo[] {
1683
1683
  const md = new Metadata();
1684
1684
  const approvedQueries = md.Queries.filter((q) => q.Status === status);
1685
- return approvedQueries.map((q) => {
1686
- return {
1687
- id: q.ID,
1688
- name: q.Name,
1689
- description: q.Description,
1690
- category: q.Category,
1691
- categoryPath: this.buildQueryCategoryPath(md, q.CategoryID),
1692
- sql: q.SQL,
1693
- originalSQL: q.OriginalSQL,
1694
- feedback: q.Feedback,
1695
- status: q.Status,
1696
- qualityRank: q.QualityRank,
1697
- createdAt: q.__mj_CreatedAt,
1698
- updatedAt: q.__mj_UpdatedAt,
1699
- categoryID: q.CategoryID,
1700
- embeddingVector: q.EmbeddingVector,
1701
- embeddingModelID: q.EmbeddingModelID,
1702
- embeddingModelName: q.EmbeddingModel,
1703
- fields: q.Fields.map((f) => {
1704
- return {
1705
- id: f.ID,
1706
- queryID: f.QueryID,
1707
- sequence: f.Sequence,
1708
- name: f.Name,
1709
- description: f.Description,
1710
- sqlBaseType: f.SQLBaseType,
1711
- sqlFullType: f.SQLFullType,
1712
- sourceEntityID: f.SourceEntityID,
1713
- sourceEntity: f.SourceEntity,
1714
- sourceFieldName: f.SourceFieldName,
1715
- isComputed: f.IsComputed,
1716
- computationDescription: f.ComputationDescription,
1717
- isSummary: f.IsSummary,
1718
- summaryDescription: f.SummaryDescription,
1719
- createdAt: f.__mj_CreatedAt,
1720
- updatedAt: f.__mj_UpdatedAt,
1721
- };
1722
- }),
1723
- params: q.Parameters.map((p) => {
1724
- return {
1725
- id: p.ID,
1726
- name: p.Name,
1727
- description: p.Description,
1728
- type: p.Type,
1729
- isRequired: p.IsRequired,
1730
- defaultValue: p.DefaultValue,
1731
- createdAt: p.__mj_CreatedAt,
1732
- updatedAt: p.__mj_UpdatedAt,
1733
- };
1734
- }),
1735
- entities: q.Entities.map((e) => {
1736
- return {
1737
- id: `${e.QueryID}_${e.EntityID}`, // Composite key since QueryEntityInfo doesn't have a single ID field
1738
- queryID: e.QueryID,
1739
- entityID: e.EntityID,
1740
- entityName: e.Entity,
1741
- detectionMethod: e.DetectionMethod,
1742
- autoDetectConfidenceScore: e.AutoDetectConfidenceScore,
1743
- createdAt: e.__mj_CreatedAt,
1744
- updatedAt: e.__mj_UpdatedAt,
1745
- };
1746
- })
1747
- }
1748
- });
1685
+ return approvedQueries.map((q) => ({
1686
+ ID: q.ID,
1687
+ Name: q.Name,
1688
+ Description: q.Description,
1689
+ Category: q.Category,
1690
+ CategoryPath: this.buildQueryCategoryPath(md, q.CategoryID),
1691
+ CategoryID: q.CategoryID,
1692
+ SQL: q.SQL,
1693
+ Status: q.Status,
1694
+ QualityRank: q.QualityRank,
1695
+ EmbeddingVector: q.EmbeddingVector,
1696
+ EmbeddingModelID: q.EmbeddingModelID,
1697
+ EmbeddingModelName: q.EmbeddingModel,
1698
+ Fields: q.Fields.map((f) => ({
1699
+ ID: f.ID,
1700
+ QueryID: f.QueryID,
1701
+ Name: f.Name,
1702
+ Description: f.Description,
1703
+ Sequence: f.Sequence,
1704
+ SQLBaseType: f.SQLBaseType,
1705
+ SQLFullType: f.SQLFullType,
1706
+ SourceEntityID: f.SourceEntityID,
1707
+ SourceEntity: f.SourceEntity,
1708
+ SourceFieldName: f.SourceFieldName,
1709
+ IsComputed: f.IsComputed,
1710
+ ComputationDescription: f.ComputationDescription,
1711
+ IsSummary: f.IsSummary,
1712
+ SummaryDescription: f.SummaryDescription
1713
+ })),
1714
+ Parameters: q.Parameters.map((p) => ({
1715
+ ID: p.ID,
1716
+ QueryID: p.QueryID,
1717
+ Name: p.Name,
1718
+ Description: p.Description,
1719
+ Type: p.Type,
1720
+ IsRequired: p.IsRequired,
1721
+ DefaultValue: p.DefaultValue,
1722
+ SampleValue: p.SampleValue,
1723
+ ValidationFilters: p.ValidationFilters
1724
+ })),
1725
+ Entities: q.Entities.map((e) => ({
1726
+ ID: e.ID,
1727
+ QueryID: e.QueryID,
1728
+ EntityID: e.EntityID,
1729
+ Entity: e.Entity
1730
+ }))
1731
+ }));
1749
1732
  }
1750
1733
 
1751
1734
  // /**
@@ -160,9 +160,6 @@ export class QueryFieldType {
160
160
  @Field(() => String, { nullable: true })
161
161
  Description?: string;
162
162
 
163
- @Field(() => String, { nullable: true })
164
- Type?: string;
165
-
166
163
  @Field(() => Number)
167
164
  Sequence!: number;
168
165
 
@@ -172,11 +169,26 @@ export class QueryFieldType {
172
169
  @Field(() => String, { nullable: true })
173
170
  SQLFullType?: string;
174
171
 
172
+ @Field(() => String, { nullable: true })
173
+ SourceEntityID?: string;
174
+
175
+ @Field(() => String, { nullable: true })
176
+ SourceEntity?: string;
177
+
178
+ @Field(() => String, { nullable: true })
179
+ SourceFieldName?: string;
180
+
175
181
  @Field(() => Boolean)
176
182
  IsComputed!: boolean;
177
183
 
178
184
  @Field(() => String, { nullable: true })
179
185
  ComputationDescription?: string;
186
+
187
+ @Field(() => Boolean, { nullable: true })
188
+ IsSummary?: boolean;
189
+
190
+ @Field(() => String, { nullable: true })
191
+ SummaryDescription?: string;
180
192
  }
181
193
 
182
194
  @ObjectType()
@@ -190,17 +202,23 @@ export class QueryParameterType {
190
202
  @Field(() => String)
191
203
  Name!: string;
192
204
 
205
+ @Field(() => String, { nullable: true })
206
+ Description?: string;
207
+
193
208
  @Field(() => String)
194
209
  Type!: string;
195
210
 
211
+ @Field(() => Boolean)
212
+ IsRequired!: boolean;
213
+
196
214
  @Field(() => String, { nullable: true })
197
215
  DefaultValue?: string;
198
216
 
199
217
  @Field(() => String, { nullable: true })
200
- Comments?: string;
218
+ SampleValue?: string;
201
219
 
202
- @Field(() => Boolean)
203
- IsRequired!: boolean;
220
+ @Field(() => String, { nullable: true })
221
+ ValidationFilters?: string;
204
222
  }
205
223
 
206
224
  @ObjectType()
@@ -215,7 +233,7 @@ export class QueryEntityType {
215
233
  EntityID!: string;
216
234
 
217
235
  @Field(() => String, { nullable: true })
218
- EntityName?: string;
236
+ Entity?: string;
219
237
  }
220
238
 
221
239
  @ObjectType()
@@ -230,7 +248,7 @@ export class QueryPermissionType {
230
248
  RoleID!: string;
231
249
 
232
250
  @Field(() => String, { nullable: true })
233
- RoleName?: string;
251
+ Role?: string;
234
252
  }
235
253
 
236
254
  @ObjectType()
@@ -241,9 +259,41 @@ export class CreateQueryResultType {
241
259
  @Field(() => String, { nullable: true })
242
260
  ErrorMessage?: string;
243
261
 
262
+ // Core query properties
263
+ @Field(() => String, { nullable: true })
264
+ ID?: string;
265
+
266
+ @Field(() => String, { nullable: true })
267
+ Name?: string;
268
+
269
+ @Field(() => String, { nullable: true })
270
+ Description?: string;
271
+
272
+ @Field(() => String, { nullable: true })
273
+ CategoryID?: string;
274
+
275
+ @Field(() => String, { nullable: true })
276
+ Category?: string;
277
+
278
+ @Field(() => String, { nullable: true })
279
+ SQL?: string;
280
+
281
+ @Field(() => String, { nullable: true })
282
+ Status?: string;
283
+
284
+ @Field(() => Number, { nullable: true })
285
+ QualityRank?: number;
286
+
287
+ @Field(() => String, { nullable: true })
288
+ EmbeddingVector?: string;
289
+
290
+ @Field(() => String, { nullable: true })
291
+ EmbeddingModelID?: string;
292
+
244
293
  @Field(() => String, { nullable: true })
245
- QueryData?: string;
294
+ EmbeddingModelName?: string;
246
295
 
296
+ // Related collections
247
297
  @Field(() => [QueryFieldType], { nullable: true })
248
298
  Fields?: QueryFieldType[];
249
299
 
@@ -265,9 +315,41 @@ export class UpdateQueryResultType {
265
315
  @Field(() => String, { nullable: true })
266
316
  ErrorMessage?: string;
267
317
 
318
+ // Core query properties
268
319
  @Field(() => String, { nullable: true })
269
- QueryData?: string;
320
+ ID?: string;
270
321
 
322
+ @Field(() => String, { nullable: true })
323
+ Name?: string;
324
+
325
+ @Field(() => String, { nullable: true })
326
+ Description?: string;
327
+
328
+ @Field(() => String, { nullable: true })
329
+ CategoryID?: string;
330
+
331
+ @Field(() => String, { nullable: true })
332
+ Category?: string;
333
+
334
+ @Field(() => String, { nullable: true })
335
+ SQL?: string;
336
+
337
+ @Field(() => String, { nullable: true })
338
+ Status?: string;
339
+
340
+ @Field(() => Number, { nullable: true })
341
+ QualityRank?: number;
342
+
343
+ @Field(() => String, { nullable: true })
344
+ EmbeddingVector?: string;
345
+
346
+ @Field(() => String, { nullable: true })
347
+ EmbeddingModelID?: string;
348
+
349
+ @Field(() => String, { nullable: true })
350
+ EmbeddingModelName?: string;
351
+
352
+ // Related collections
271
353
  @Field(() => [QueryFieldType], { nullable: true })
272
354
  Fields?: QueryFieldType[];
273
355
 
@@ -289,8 +371,24 @@ export class DeleteQueryResultType {
289
371
  @Field(() => String, { nullable: true })
290
372
  ErrorMessage?: string;
291
373
 
374
+ // Core query properties of deleted query
375
+ @Field(() => String, { nullable: true })
376
+ ID?: string;
377
+
378
+ @Field(() => String, { nullable: true })
379
+ Name?: string;
380
+
381
+ @Field(() => String, { nullable: true })
382
+ Description?: string;
383
+
292
384
  @Field(() => String, { nullable: true })
293
- QueryData?: string;
385
+ CategoryID?: string;
386
+
387
+ @Field(() => String, { nullable: true })
388
+ SQL?: string;
389
+
390
+ @Field(() => String, { nullable: true })
391
+ Status?: string;
294
392
  }
295
393
 
296
394
  @Resolver()
@@ -368,16 +466,56 @@ export class MJQueryResolverExtended extends MJQueryResolver {
368
466
 
369
467
  return {
370
468
  Success: true,
371
- QueryData: JSON.stringify(record.GetAll()),
372
- Fields: record.QueryFields,
373
- Parameters: record.QueryParameters,
374
- Entities: record.QueryEntities.map(e => {
375
- return {
376
- ...e,
377
- EntityName: e.Entity // alias this to fix variable name mismatch
378
- }
379
- }),
380
- Permissions: record.QueryPermissions
469
+ ID: record.ID,
470
+ Name: record.Name,
471
+ Description: record.Description,
472
+ CategoryID: record.CategoryID,
473
+ Category: record.Category,
474
+ SQL: record.SQL,
475
+ Status: record.Status,
476
+ QualityRank: record.QualityRank,
477
+ EmbeddingVector: record.EmbeddingVector,
478
+ EmbeddingModelID: record.EmbeddingModelID,
479
+ EmbeddingModelName: record.EmbeddingModel,
480
+ Fields: record.QueryFields.map(f => ({
481
+ ID: f.ID,
482
+ QueryID: f.QueryID,
483
+ Name: f.Name,
484
+ Description: f.Description,
485
+ Sequence: f.Sequence,
486
+ SQLBaseType: f.SQLBaseType,
487
+ SQLFullType: f.SQLFullType,
488
+ SourceEntityID: f.SourceEntityID,
489
+ SourceEntity: f.SourceEntity,
490
+ SourceFieldName: f.SourceFieldName,
491
+ IsComputed: f.IsComputed,
492
+ ComputationDescription: f.ComputationDescription,
493
+ IsSummary: f.IsSummary,
494
+ SummaryDescription: f.SummaryDescription
495
+ })),
496
+ Parameters: record.QueryParameters.map(p => ({
497
+ ID: p.ID,
498
+ QueryID: p.QueryID,
499
+ Name: p.Name,
500
+ Description: p.Description,
501
+ Type: p.Type,
502
+ IsRequired: p.IsRequired,
503
+ DefaultValue: p.DefaultValue,
504
+ SampleValue: p.SampleValue,
505
+ ValidationFilters: p.ValidationFilters
506
+ })),
507
+ Entities: record.QueryEntities.map(e => ({
508
+ ID: e.ID,
509
+ QueryID: e.QueryID,
510
+ EntityID: e.EntityID,
511
+ Entity: e.Entity
512
+ })),
513
+ Permissions: record.QueryPermissions.map(p => ({
514
+ ID: p.ID,
515
+ QueryID: p.QueryID,
516
+ RoleID: p.RoleID,
517
+ Role: p.Role
518
+ }))
381
519
  };
382
520
  }
383
521
  else {
@@ -391,16 +529,56 @@ export class MJQueryResolverExtended extends MJQueryResolver {
391
529
  LogStatus(`[CreateQuery] Unique constraint detected for query '${input.Name}'. Using existing query (ID: ${existingQuery.ID}) created by concurrent request.`);
392
530
  return {
393
531
  Success: true,
394
- QueryData: JSON.stringify(existingQuery),
395
- Fields: existingQuery.Fields || [],
396
- Parameters: existingQuery.Parameters || [],
397
- Entities: existingQuery.Entities?.map(e => ({
532
+ ID: existingQuery.ID,
533
+ Name: existingQuery.Name,
534
+ Description: existingQuery.Description,
535
+ CategoryID: existingQuery.CategoryID,
536
+ Category: existingQuery.Category,
537
+ SQL: existingQuery.SQL,
538
+ Status: existingQuery.Status,
539
+ QualityRank: existingQuery.QualityRank,
540
+ EmbeddingVector: existingQuery.EmbeddingVector,
541
+ EmbeddingModelID: existingQuery.EmbeddingModelID,
542
+ EmbeddingModelName: existingQuery.EmbeddingModel,
543
+ Fields: existingQuery.Fields?.map((f: any) => ({
544
+ ID: f.ID,
545
+ QueryID: f.QueryID,
546
+ Name: f.Name,
547
+ Description: f.Description,
548
+ Sequence: f.Sequence,
549
+ SQLBaseType: f.SQLBaseType,
550
+ SQLFullType: f.SQLFullType,
551
+ SourceEntityID: f.SourceEntityID,
552
+ SourceEntity: f.SourceEntity,
553
+ SourceFieldName: f.SourceFieldName,
554
+ IsComputed: f.IsComputed,
555
+ ComputationDescription: f.ComputationDescription,
556
+ IsSummary: f.IsSummary,
557
+ SummaryDescription: f.SummaryDescription
558
+ })) || [],
559
+ Parameters: existingQuery.Parameters?.map((p: any) => ({
560
+ ID: p.ID,
561
+ QueryID: p.QueryID,
562
+ Name: p.Name,
563
+ Description: p.Description,
564
+ Type: p.Type,
565
+ IsRequired: p.IsRequired,
566
+ DefaultValue: p.DefaultValue,
567
+ SampleValue: p.SampleValue,
568
+ ValidationFilters: p.ValidationFilters
569
+ })) || [],
570
+ Entities: existingQuery.Entities?.map((e: any) => ({
398
571
  ID: e.ID,
399
572
  QueryID: e.QueryID,
400
573
  EntityID: e.EntityID,
401
- EntityName: e.Entity
574
+ Entity: e.Entity
402
575
  })) || [],
403
- Permissions: existingQuery.Permissions || []
576
+ Permissions: existingQuery.Permissions?.map((p: any) => ({
577
+ ID: p.ID,
578
+ QueryID: p.QueryID,
579
+ RoleID: p.RoleID,
580
+ Role: p.Role
581
+ })) || []
404
582
  };
405
583
  }
406
584
 
@@ -437,7 +615,7 @@ export class MJQueryResolverExtended extends MJQueryResolver {
437
615
  ID: permissionEntity.ID,
438
616
  QueryID: permissionEntity.QueryID,
439
617
  RoleID: permissionEntity.RoleID,
440
- RoleName: permissionEntity.Role // The view includes the Role name
618
+ Role: permissionEntity.Role
441
619
  });
442
620
  }
443
621
  }
@@ -545,51 +723,58 @@ export class MJQueryResolverExtended extends MJQueryResolver {
545
723
  await queryEntity.RefreshRelatedMetadata(true);
546
724
  }
547
725
 
548
- // Use the properties from QueryEntityExtended instead of manual loading
549
- const fields: QueryFieldType[] = queryEntity.QueryFields.map(f => ({
550
- ID: f.ID,
551
- QueryID: f.QueryID,
552
- Name: f.Name,
553
- Description: f.Description || undefined,
554
- Type: f.SQLBaseType || undefined,
555
- Sequence: f.Sequence,
556
- SQLBaseType: f.SQLBaseType || undefined,
557
- SQLFullType: f.SQLFullType || undefined,
558
- IsComputed: f.IsComputed,
559
- ComputationDescription: f.ComputationDescription || undefined
560
- }));
561
-
562
- const parameters: QueryParameterType[] = queryEntity.QueryParameters.map(p => ({
563
- ID: p.ID,
564
- QueryID: p.QueryID,
565
- Name: p.Name,
566
- Type: p.Type,
567
- DefaultValue: p.DefaultValue || undefined,
568
- Comments: '', // Not available in QueryParameterInfo
569
- IsRequired: p.IsRequired
570
- }));
571
-
572
- const entities: QueryEntityType[] = queryEntity.QueryEntities.map(e => ({
573
- ID: e.ID,
574
- QueryID: e.QueryID,
575
- EntityID: e.EntityID,
576
- EntityName: e.Entity || undefined // Property is called Entity, not EntityName
577
- }));
578
-
579
- const permissions: QueryPermissionType[] = queryEntity.QueryPermissions.map(p => ({
580
- ID: p.ID,
581
- QueryID: p.QueryID,
582
- RoleID: p.RoleID,
583
- RoleName: p.Role || undefined // Property is called Role, not RoleName
584
- }));
585
-
586
726
  return {
587
727
  Success: true,
588
- QueryData: JSON.stringify(queryEntity.GetAll()),
589
- Fields: fields,
590
- Parameters: parameters,
591
- Entities: entities,
592
- Permissions: permissions
728
+ ID: queryEntity.ID,
729
+ Name: queryEntity.Name,
730
+ Description: queryEntity.Description,
731
+ CategoryID: queryEntity.CategoryID,
732
+ Category: queryEntity.Category,
733
+ SQL: queryEntity.SQL,
734
+ Status: queryEntity.Status,
735
+ QualityRank: queryEntity.QualityRank,
736
+ EmbeddingVector: queryEntity.EmbeddingVector,
737
+ EmbeddingModelID: queryEntity.EmbeddingModelID,
738
+ EmbeddingModelName: queryEntity.EmbeddingModel,
739
+ Fields: queryEntity.QueryFields.map(f => ({
740
+ ID: f.ID,
741
+ QueryID: f.QueryID,
742
+ Name: f.Name,
743
+ Description: f.Description,
744
+ Sequence: f.Sequence,
745
+ SQLBaseType: f.SQLBaseType,
746
+ SQLFullType: f.SQLFullType,
747
+ SourceEntityID: f.SourceEntityID,
748
+ SourceEntity: f.SourceEntity,
749
+ SourceFieldName: f.SourceFieldName,
750
+ IsComputed: f.IsComputed,
751
+ ComputationDescription: f.ComputationDescription,
752
+ IsSummary: f.IsSummary,
753
+ SummaryDescription: f.SummaryDescription
754
+ })),
755
+ Parameters: queryEntity.QueryParameters.map(p => ({
756
+ ID: p.ID,
757
+ QueryID: p.QueryID,
758
+ Name: p.Name,
759
+ Description: p.Description,
760
+ Type: p.Type,
761
+ IsRequired: p.IsRequired,
762
+ DefaultValue: p.DefaultValue,
763
+ SampleValue: p.SampleValue,
764
+ ValidationFilters: p.ValidationFilters
765
+ })),
766
+ Entities: queryEntity.QueryEntities.map(e => ({
767
+ ID: e.ID,
768
+ QueryID: e.QueryID,
769
+ EntityID: e.EntityID,
770
+ Entity: e.Entity
771
+ })),
772
+ Permissions: queryEntity.QueryPermissions.map(p => ({
773
+ ID: p.ID,
774
+ QueryID: p.QueryID,
775
+ RoleID: p.RoleID,
776
+ Role: p.Role
777
+ }))
593
778
  };
594
779
 
595
780
  } catch (err) {
@@ -640,7 +825,12 @@ export class MJQueryResolverExtended extends MJQueryResolver {
640
825
  if (deletedQuery) {
641
826
  return {
642
827
  Success: true,
643
- QueryData: JSON.stringify(deletedQuery)
828
+ ID: deletedQuery.ID,
829
+ Name: deletedQuery.Name,
830
+ Description: deletedQuery.Description,
831
+ CategoryID: deletedQuery.CategoryID,
832
+ SQL: deletedQuery.SQL,
833
+ Status: deletedQuery.Status
644
834
  };
645
835
  } else {
646
836
  return {