@memberjunction/server 2.55.0 → 2.57.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/src/index.ts CHANGED
@@ -37,6 +37,9 @@ LoadGeneratedActions(); // prevent tree shaking for this dynamic module
37
37
  import { LoadCoreEntitiesServerSubClasses } from '@memberjunction/core-entities-server';
38
38
  LoadCoreEntitiesServerSubClasses(); // prevent tree shaking for this dynamic module
39
39
 
40
+ import { LoadAgentManagementActions } from '@memberjunction/ai-agent-manager-actions';
41
+ LoadAgentManagementActions();
42
+
40
43
  import { ExternalChangeDetectorEngine } from '@memberjunction/external-change-detection';
41
44
 
42
45
  const cacheRefreshInterval = configInfo.databaseSettings.metadataCacheRefreshInterval;
@@ -1,4 +1,4 @@
1
- import { EntityPermissionType, Metadata } from '@memberjunction/core';
1
+ import { EntityPermissionType, Metadata, FieldValueCollection } from '@memberjunction/core';
2
2
  import { FileEntity, FileStorageProviderEntity } from '@memberjunction/core-entities';
3
3
  import {
4
4
  AppContext,
@@ -57,23 +57,27 @@ export class FileResolver extends FileResolverBase {
57
57
  fileEntity.CheckPermissions(EntityPermissionType.Create, true);
58
58
 
59
59
  // Check to see if there's already an object with that name
60
- const [sameName] = await this.findBy(context.dataSource, 'Files', { Name: input.Name, ProviderID: input.ProviderID }, context.userPayload.userRecord);
60
+ const [sameName] = await this.findBy(
61
+ context.dataSource,
62
+ 'Files',
63
+ { Name: input.Name, ProviderID: input.ProviderID },
64
+ context.userPayload.userRecord
65
+ );
61
66
  const NameExists = Boolean(sameName);
62
67
 
63
- const fileRecord = (await super.CreateFile({ ...input, Status: 'Pending' }, context, pubSub)) as File_;
68
+ const success = fileEntity.NewRecord(FieldValueCollection.FromObject({ ...input, Status: 'Pending' }));
64
69
 
65
70
  // If there's a problem creating the file record, the base resolver will return null
66
- if (!fileRecord) {
71
+ if (!success) {
67
72
  return null;
68
73
  }
69
74
 
70
75
  // Create the upload URL and get the record updates (provider key, content type, etc)
71
- const { updatedInput, UploadUrl } = await createUploadUrl(providerEntity, fileRecord);
76
+ const { updatedInput, UploadUrl } = await createUploadUrl(providerEntity, fileEntity);
72
77
 
73
78
  // Save the file record with the updated input
74
79
  const mapper = new FieldMapper();
75
- await fileEntity.LoadFromData(mapper.ReverseMapFields({ ...input }));
76
- fileEntity.SetMany(mapper.ReverseMapFields({ ...updatedInput }));
80
+ fileEntity.SetMany(mapper.ReverseMapFields({ ...updatedInput }), true, true);
77
81
  await fileEntity.Save();
78
82
  const File = mapper.MapFields({ ...fileEntity.GetAll() });
79
83
 
@@ -45,8 +45,8 @@ export class RunAIPromptResolver extends ResolverBase {
45
45
  @Arg('promptId') promptId: string,
46
46
  @Ctx() { userPayload }: { userPayload: UserPayload },
47
47
  @Arg('data', { nullable: true }) data?: string,
48
- @Arg('modelId', { nullable: true }) modelId?: string,
49
- @Arg('vendorId', { nullable: true }) vendorId?: string,
48
+ @Arg('overrideModelId', { nullable: true }) overrideModelId?: string,
49
+ @Arg('overrideVendorId', { nullable: true }) overrideVendorId?: string,
50
50
  @Arg('configurationId', { nullable: true }) configurationId?: string,
51
51
  @Arg('skipValidation', { nullable: true }) skipValidation?: boolean,
52
52
  @Arg('templateData', { nullable: true }) templateData?: string,
@@ -137,12 +137,18 @@ export class RunAIPromptResolver extends ResolverBase {
137
137
  promptParams.prompt = promptEntity;
138
138
  promptParams.data = parsedData;
139
139
  promptParams.templateData = parsedTemplateData;
140
- promptParams.modelId = modelId;
141
- promptParams.vendorId = vendorId;
142
140
  promptParams.configurationId = configurationId;
143
141
  promptParams.contextUser = currentUser;
144
142
  promptParams.skipValidation = skipValidation || false;
145
143
 
144
+ // Set override if model or vendor ID provided
145
+ if (overrideModelId || overrideVendorId) {
146
+ promptParams.override = {
147
+ modelId: overrideModelId,
148
+ vendorId: overrideVendorId
149
+ };
150
+ }
151
+
146
152
  // Parse and set conversation messages if provided
147
153
  if (messages) {
148
154
  try {