@memberjunction/actions 1.4.1
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/dist/entity-actions/EntityActionEngine.d.ts +93 -0
- package/dist/entity-actions/EntityActionEngine.d.ts.map +1 -0
- package/dist/entity-actions/EntityActionEngine.js +134 -0
- package/dist/entity-actions/EntityActionEngine.js.map +1 -0
- package/dist/entity-actions/EntityActionEntity.server.d.ts +20 -0
- package/dist/entity-actions/EntityActionEntity.server.d.ts.map +1 -0
- package/dist/entity-actions/EntityActionEntity.server.js +54 -0
- package/dist/entity-actions/EntityActionEntity.server.js.map +1 -0
- package/dist/entity-actions/EntityActionInvocationTypes.d.ts +29 -0
- package/dist/entity-actions/EntityActionInvocationTypes.d.ts.map +1 -0
- package/dist/entity-actions/EntityActionInvocationTypes.js +108 -0
- package/dist/entity-actions/EntityActionInvocationTypes.js.map +1 -0
- package/dist/generic/ActionEngine.d.ts +161 -0
- package/dist/generic/ActionEngine.d.ts.map +1 -0
- package/dist/generic/ActionEngine.js +218 -0
- package/dist/generic/ActionEngine.js.map +1 -0
- package/dist/generic/ActionEntity.server.d.ts +50 -0
- package/dist/generic/ActionEntity.server.d.ts.map +1 -0
- package/dist/generic/ActionEntity.server.js +395 -0
- package/dist/generic/ActionEntity.server.js.map +1 -0
- package/dist/generic/BaseAction.d.ts +9 -0
- package/dist/generic/BaseAction.d.ts.map +1 -0
- package/dist/generic/BaseAction.js +13 -0
- package/dist/generic/BaseAction.js.map +1 -0
- package/dist/generic/BaseActionFilter.d.ts +20 -0
- package/dist/generic/BaseActionFilter.d.ts.map +1 -0
- package/dist/generic/BaseActionFilter.js +21 -0
- package/dist/generic/BaseActionFilter.js.map +1 -0
- package/dist/generic/test.d.ts +1 -0
- package/dist/generic/test.d.ts.map +1 -0
- package/dist/generic/test.js +73 -0
- package/dist/generic/test.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/package.json +29 -0
- package/readme.md +6 -0
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.LoadActionEntityServer = exports.ActionEntityServerEntity = void 0;
|
|
13
|
+
const core_1 = require("@memberjunction/core");
|
|
14
|
+
const core_entities_1 = require("@memberjunction/core-entities");
|
|
15
|
+
const global_1 = require("@memberjunction/global");
|
|
16
|
+
const aiengine_1 = require("@memberjunction/aiengine");
|
|
17
|
+
const ActionEngine_1 = require("./ActionEngine");
|
|
18
|
+
const ai_1 = require("@memberjunction/ai");
|
|
19
|
+
/**
|
|
20
|
+
* Server-Only custom sub-class for Actions entity. This sub-class handles the process of auto-generation code for the Actions entity.
|
|
21
|
+
*/
|
|
22
|
+
let ActionEntityServerEntity = class ActionEntityServerEntity extends core_entities_1.ActionEntity {
|
|
23
|
+
constructor(Entity) {
|
|
24
|
+
super(Entity); // call super
|
|
25
|
+
this._resultCodes = null;
|
|
26
|
+
this._params = null;
|
|
27
|
+
this._libs = null;
|
|
28
|
+
const md = new core_1.Metadata();
|
|
29
|
+
if (md.ProviderType !== 'Database')
|
|
30
|
+
throw new Error('This class is only supported for server-side/database providers. Remove this package from your application.');
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Default implementation simply returns 'OpenAI' - override this in your subclass if you are using a different AI vendor.
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
get AIVendorName() {
|
|
37
|
+
return 'OpenAI';
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Generates a programatically friendly name for the name of the Action.
|
|
41
|
+
*/
|
|
42
|
+
get ProgrammaticName() {
|
|
43
|
+
return (0, core_1.CodeNameFromString)(this.Name);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns true if this action is a core MemberJunction framework action, false otherwise.
|
|
47
|
+
*/
|
|
48
|
+
get IsCoreAction() {
|
|
49
|
+
return this.Category?.trim().toLowerCase() === ActionEngine_1.ActionEngine.Instance.CoreCategoryName.trim().toLowerCase();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Provides a list of possible result codes for this action.
|
|
53
|
+
*/
|
|
54
|
+
get ResultCodes() {
|
|
55
|
+
if (!this._resultCodes) {
|
|
56
|
+
// load the result codes
|
|
57
|
+
this._resultCodes = ActionEngine_1.ActionEngine.Instance.ActionResultCodes.filter(c => c.ActionID === this.ID);
|
|
58
|
+
}
|
|
59
|
+
return this._resultCodes;
|
|
60
|
+
}
|
|
61
|
+
get Params() {
|
|
62
|
+
if (!this._params) {
|
|
63
|
+
// load the inputs
|
|
64
|
+
this._params = ActionEngine_1.ActionEngine.Instance.ActionParams.filter(i => i.ActionID === this.ID);
|
|
65
|
+
}
|
|
66
|
+
return this._params;
|
|
67
|
+
}
|
|
68
|
+
get Libraries() {
|
|
69
|
+
if (!this._libs) {
|
|
70
|
+
// load the inputs
|
|
71
|
+
this._libs = ActionEngine_1.ActionEngine.Instance.ActionLibraries.filter(l => l.ActionID === this.ID);
|
|
72
|
+
}
|
|
73
|
+
return this._libs;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Override of the base Save method to handle the pre-processing to auto generate code whenever an action's UserPrompt is modified.
|
|
77
|
+
* This happens when a new record is created and also whenever the UserPrompt field is changed.
|
|
78
|
+
* @param options
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
81
|
+
async Save(options) {
|
|
82
|
+
// make sure the ActionEngine is configured
|
|
83
|
+
await ActionEngine_1.ActionEngine.Instance.Config(false, this.ContextCurrentUser);
|
|
84
|
+
let newCodeGenerated = false;
|
|
85
|
+
let codeLibraries = [];
|
|
86
|
+
if (this.GetFieldByName('UserPrompt').Dirty || !this.IsSaved || this.ForceCodeGeneration) {
|
|
87
|
+
// UserPrompt field is dirty, or this is a new record, either way, this is the condition where we want to generate the Code.
|
|
88
|
+
const result = await this.GenerateCode();
|
|
89
|
+
if (result.Success) {
|
|
90
|
+
this.Code = result.Code;
|
|
91
|
+
this.CodeComments = result.Comments;
|
|
92
|
+
this.CodeApprovalStatus = 'Pending'; // set to pending even if previously approved since we changed the code
|
|
93
|
+
this.CodeApprovedAt = null; // reset the approved at date
|
|
94
|
+
this.CodeApprovedByUserID = null; // reset the approved by user id
|
|
95
|
+
newCodeGenerated = true; // flag for post-save processing of libraries
|
|
96
|
+
codeLibraries = result.LibrariesUsed;
|
|
97
|
+
}
|
|
98
|
+
else
|
|
99
|
+
throw new Error(`Failed to generate code for Action ${this.Name}.`);
|
|
100
|
+
}
|
|
101
|
+
this.ForceCodeGeneration = false; // make sure to reset this flag every time we save, it should never live past one run of the Save method, of course if Save fails, below, then it will not be reset
|
|
102
|
+
const wasNewRecord = !this.IsSaved;
|
|
103
|
+
if (await super.Save(options)) {
|
|
104
|
+
if (newCodeGenerated) {
|
|
105
|
+
// new code was generated, we need to sync up the ActionLibraries table with the libraries used in the code for this Action
|
|
106
|
+
// get a list of existing ActionLibrary records that match this Action
|
|
107
|
+
const existingLibraries = [];
|
|
108
|
+
if (!wasNewRecord) {
|
|
109
|
+
const rv = new core_1.RunView();
|
|
110
|
+
const libResult = await rv.RunView({
|
|
111
|
+
EntityName: 'Action Libraries',
|
|
112
|
+
ExtraFilter: `ActionID = ${this.ID}`,
|
|
113
|
+
ResultType: 'entity_object'
|
|
114
|
+
}, this.ContextCurrentUser);
|
|
115
|
+
if (libResult.Success && libResult.Results.length > 0) {
|
|
116
|
+
existingLibraries.push(...libResult.Results);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// now we need to go through the libraries we ARE currently using in the current code and make sure they are in the ActionLibraries table
|
|
120
|
+
// and make sure nothing is in the table that we are not using
|
|
121
|
+
const librariesToAdd = codeLibraries.filter(l => !existingLibraries.some(el => el.Library.trim().toLowerCase() === l.LibraryName.trim().toLowerCase()));
|
|
122
|
+
const librariesToRemove = existingLibraries.filter(el => !codeLibraries.some(l => l.LibraryName.trim().toLowerCase() === el.Library.trim().toLowerCase()));
|
|
123
|
+
const librariesToUpdate = existingLibraries.filter(el => codeLibraries.some(l => l.LibraryName.trim().toLowerCase() === el.Library.trim().toLowerCase()));
|
|
124
|
+
const md = new core_1.Metadata();
|
|
125
|
+
//const promises = [];
|
|
126
|
+
const tg = await md.CreateTransactionGroup();
|
|
127
|
+
for (const lib of librariesToAdd) {
|
|
128
|
+
const libMetadata = md.Libraries.find(l => l.Name.trim().toLowerCase() === lib.LibraryName.trim().toLowerCase());
|
|
129
|
+
if (libMetadata) {
|
|
130
|
+
const newLib = await md.GetEntityObject('Action Libraries', this.ContextCurrentUser);
|
|
131
|
+
newLib.ActionID = this.ID;
|
|
132
|
+
newLib.LibraryID = libMetadata.ID;
|
|
133
|
+
newLib.ItemsUsed = lib.ItemsUsed.join(',');
|
|
134
|
+
newLib.TransactionGroup = tg;
|
|
135
|
+
newLib.Save();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// now update the libraries that were already in place to ensure the ItemsUsed are up to date
|
|
139
|
+
for (const lib of librariesToUpdate) {
|
|
140
|
+
const newCode = codeLibraries.find(l => l.LibraryName.trim().toLowerCase() === lib.Library.trim().toLowerCase());
|
|
141
|
+
lib.ItemsUsed = newCode.ItemsUsed.join(',');
|
|
142
|
+
lib.TransactionGroup = tg;
|
|
143
|
+
lib.Save();
|
|
144
|
+
}
|
|
145
|
+
// now remove the libraries that are no longer used
|
|
146
|
+
for (const lib of librariesToRemove) {
|
|
147
|
+
// each lib in this array iteration is already a BaseEntity derived object
|
|
148
|
+
lib.TransactionGroup = tg;
|
|
149
|
+
lib.Delete();
|
|
150
|
+
}
|
|
151
|
+
// now commit the transaction
|
|
152
|
+
if (!await tg.Submit()) {
|
|
153
|
+
return false;
|
|
154
|
+
//throw new Error('Failed to update the libraries used by the Action.');
|
|
155
|
+
}
|
|
156
|
+
else
|
|
157
|
+
return true;
|
|
158
|
+
// // now wait for all the promises to complete
|
|
159
|
+
// const results = await Promise.all(promises);
|
|
160
|
+
// return results.some(r => r === false) ? false : true;
|
|
161
|
+
}
|
|
162
|
+
else
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
else
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
SendMessage(message) {
|
|
169
|
+
global_1.MJGlobal.Instance.RaiseEvent({
|
|
170
|
+
args: { message },
|
|
171
|
+
eventCode: 'Actions',
|
|
172
|
+
event: global_1.MJEventType.ComponentEvent,
|
|
173
|
+
component: this
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* This method will generate code using a combination of the UserPrompt field as well as the overall context of how an Action gets executed. Code from the Action is later used by CodeGen to inject into
|
|
178
|
+
* the mj_actions library for each user environment. The mj_actions library will have a class for each action and that class will have certain libraries imported at the top of the file and available for use.
|
|
179
|
+
* That information along with a detailed amount of system prompt steering goes into the AI model in order to generate contextually appropriate and reliable code that maps to the business logic of the user
|
|
180
|
+
*/
|
|
181
|
+
async GenerateCode(maxAttempts = 3) {
|
|
182
|
+
try {
|
|
183
|
+
this.SendMessage('Generating code for action ' + this.Name);
|
|
184
|
+
const model = await aiengine_1.AIEngine.Instance.GetHighestPowerModel(this.AIVendorName, 'llm', this.ContextCurrentUser);
|
|
185
|
+
const llm = global_1.MJGlobal.Instance.ClassFactory.CreateInstance(ai_1.BaseLLM, model.DriverClass, (0, ai_1.GetAIAPIKey)(model.DriverClass));
|
|
186
|
+
const chatParams = {
|
|
187
|
+
model: model.APINameOrName,
|
|
188
|
+
messages: [
|
|
189
|
+
{
|
|
190
|
+
role: 'system',
|
|
191
|
+
content: this.GenerateSysPrompt()
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
role: 'user',
|
|
195
|
+
content: this.UserPrompt,
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
};
|
|
199
|
+
return await this.InternalGenerateCode(llm, chatParams, maxAttempts);
|
|
200
|
+
}
|
|
201
|
+
catch (e) {
|
|
202
|
+
(0, core_1.LogError)(e);
|
|
203
|
+
throw e;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
async InternalGenerateCode(llm, chatParams, attemptsRemaining) {
|
|
207
|
+
try {
|
|
208
|
+
const result = await llm.ChatCompletion(chatParams);
|
|
209
|
+
if (result && result.data) {
|
|
210
|
+
const llmResponse = result.data.choices[0].message.content;
|
|
211
|
+
if (llmResponse) {
|
|
212
|
+
// try to parse it as JSON
|
|
213
|
+
const cleansed = (0, global_1.CleanJSON)(llmResponse);
|
|
214
|
+
if (!cleansed)
|
|
215
|
+
throw new Error('Invalid JSON response from AI: ' + llmResponse);
|
|
216
|
+
const parsed = JSON.parse(cleansed);
|
|
217
|
+
if (parsed.code && parsed.code.length > 0) {
|
|
218
|
+
const trimmed = parsed.code.trim();
|
|
219
|
+
return {
|
|
220
|
+
Success: true,
|
|
221
|
+
Code: trimmed,
|
|
222
|
+
Comments: parsed.explanation,
|
|
223
|
+
LibrariesUsed: parsed.libraries
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
throw new Error('Invalid JSON response from AI: ' + llmResponse);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
else
|
|
231
|
+
throw new Error('No response from AI');
|
|
232
|
+
}
|
|
233
|
+
else
|
|
234
|
+
throw new Error('No response from AI');
|
|
235
|
+
}
|
|
236
|
+
catch (e) {
|
|
237
|
+
(0, core_1.LogError)(e);
|
|
238
|
+
if (attemptsRemaining > 1) {
|
|
239
|
+
// try again
|
|
240
|
+
this.SendMessage(`Failed to generate code, trying again (up to ${attemptsRemaining} time${attemptsRemaining > 1 ? 's' : ''})`);
|
|
241
|
+
return await this.InternalGenerateCode(llm, chatParams, attemptsRemaining - 1);
|
|
242
|
+
}
|
|
243
|
+
else
|
|
244
|
+
return {
|
|
245
|
+
Success: false,
|
|
246
|
+
Code: '',
|
|
247
|
+
Comments: `Error communicating with AI: ${e.message}`,
|
|
248
|
+
LibrariesUsed: []
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
GenerateSysPrompt() {
|
|
253
|
+
const prompt = `<RETURN_FORMAT>
|
|
254
|
+
* CRITICAL - I am a bot, I can ONLY understand fully formed JSON responses
|
|
255
|
+
* YOUR RESPONSE MUST BE A JSON OBJECT
|
|
256
|
+
* MORE INFO BELOW
|
|
257
|
+
</RETURN_FORMAT>
|
|
258
|
+
|
|
259
|
+
<INTRODUCTION>
|
|
260
|
+
You are an expert in TypeScript coding and business applications. You take great pride in easy to read, commented, and nicely formatted code.
|
|
261
|
+
You will be provided a request for how to handle a specific type of action that they want created. An action is a "verb" in the MemberJunction framework that can do basically anything the user asks for.
|
|
262
|
+
Your job is to write the TypeScript code that will be taken and inserted into a class as shown below using the classes
|
|
263
|
+
for inputs/outputs and the ActionResultSimple class that is provided. The code you write will be used by the MemberJunction engine to execute the action when
|
|
264
|
+
it is called by the user.
|
|
265
|
+
</INTRODUCTION>
|
|
266
|
+
|
|
267
|
+
<CODE_EXAMPLE>
|
|
268
|
+
export class ${this.ProgrammaticName}Action extends BaseAction {
|
|
269
|
+
public async Run(params: RunActionParams): Promise<ActionResultSimple> {
|
|
270
|
+
// IMPORTANT: your code will go here, do not generate the method signature, just the code inside the method
|
|
271
|
+
/* FOR THE RETURN VALUE you should return a JavaScript object that has these properties:
|
|
272
|
+
{
|
|
273
|
+
Success: boolean // or false if the action failed
|
|
274
|
+
ResultCode: ${this.ResultCodes && this.ResultCodes.length > 0 ? this.ResultCodes.map(rc => `'${rc.ResultCode}'`).join(" | ") : 'string'} // The result of the action
|
|
275
|
+
Message: string // a message to show the user
|
|
276
|
+
}
|
|
277
|
+
*/
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
</CODE_EXAMPLE>
|
|
281
|
+
|
|
282
|
+
<AVAILABLE_PARAMETERS>
|
|
283
|
+
The params parameter into the Run method has a property called Params which is an array of ActionParam objects. These objects have a Name and Value property and map to the defined parameters for this action. The parameters for this
|
|
284
|
+
action are as shown below. For parameters shown as output, make sure you generate the code to handle this and place a new item in the Params array with the Name and Value set to the output parameter name and value respectively. If
|
|
285
|
+
the parameter has a type of input/output, you will receive the value as an input, and you can update it if the program you create needs to pass back a different value.
|
|
286
|
+
${JSON.stringify(this.Params)}
|
|
287
|
+
</AVAILABLE_PARAMETERS>
|
|
288
|
+
|
|
289
|
+
<AVAILABLE_LIBRARIES>
|
|
290
|
+
The following libraries are available for use in your code. THEY ARE ALREADY IMPORTED. **DO NOT IMPORT THEM IN YOUR CODE**
|
|
291
|
+
Use these libraries as needed along with the documentation available at https://docs.memberjunction.org that explains these libraries/objects in detail to generate
|
|
292
|
+
code that will conform to our framework and achieve the business logic desired by the user's prompt.
|
|
293
|
+
IMPORTANT: DO NOT GENERATE IMPORT STATEMENTS FOR THESE LIBRARIES, THEY ARE ALREADY IMPORTED FOR YOU!
|
|
294
|
+
${JSON.stringify(core_1.Metadata.Provider.Libraries)}
|
|
295
|
+
</AVAILABLE_LIBRARIES>
|
|
296
|
+
|
|
297
|
+
<REFERENCE_TYPES>
|
|
298
|
+
/**
|
|
299
|
+
* Class that has the result of the individual action execution and used by the engine or other caller
|
|
300
|
+
*/
|
|
301
|
+
export class ActionResultSimple {
|
|
302
|
+
/**
|
|
303
|
+
* Indicates if the action was successful or not.
|
|
304
|
+
*/
|
|
305
|
+
public Success: boolean;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* A string that indicates the strucutred output/results of the action
|
|
309
|
+
*/
|
|
310
|
+
public ResultCode: string;
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Optional, additional information about the result of the action
|
|
314
|
+
*/
|
|
315
|
+
public Message?: string;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Some actions return output parameters. If the action that was run has outputs, they will be provided here.
|
|
319
|
+
*/
|
|
320
|
+
public Outputs?: ActionParam[];
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Generic class for holding parameters for an action for both inputs and outputs
|
|
324
|
+
*/
|
|
325
|
+
export class ActionParam {
|
|
326
|
+
/**
|
|
327
|
+
* The name of the parameter
|
|
328
|
+
*/
|
|
329
|
+
public Name: string;
|
|
330
|
+
/**
|
|
331
|
+
* The value of the parameter. This can be any type of object.
|
|
332
|
+
*/
|
|
333
|
+
public Value: any;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Class that holds the parameters for an action to be run. This is passed to the Run method of an action.
|
|
337
|
+
*/
|
|
338
|
+
export class RunActionParams {
|
|
339
|
+
public Action: ActionEntity;
|
|
340
|
+
public ContextUser: UserInfo;
|
|
341
|
+
/**
|
|
342
|
+
* Optional, a list of filters that should be run before the action is executed.
|
|
343
|
+
*/
|
|
344
|
+
public Filters: ActionFilterEntity[];
|
|
345
|
+
/**
|
|
346
|
+
* Optional, the input and output parameters as defined in the metadata for the action.
|
|
347
|
+
*/
|
|
348
|
+
public Params: ActionParam[];
|
|
349
|
+
}
|
|
350
|
+
</REFERENCE_TYPES>
|
|
351
|
+
|
|
352
|
+
<ENTITIES>
|
|
353
|
+
Entities in MemberJunction are storage objects and roughly map to database tables. Here are the entities in the system to give you additional context to understand the request:
|
|
354
|
+
${JSON.stringify(core_1.Metadata.Provider.Entities.map(e => {
|
|
355
|
+
// for each entity, get the name, description and base view
|
|
356
|
+
return {
|
|
357
|
+
Entity: e.Name,
|
|
358
|
+
SchemaName: e.SchemaName,
|
|
359
|
+
Description: e.Description,
|
|
360
|
+
BaseView: e.BaseView
|
|
361
|
+
};
|
|
362
|
+
}))}
|
|
363
|
+
</ENTITIES>
|
|
364
|
+
The next message, which will be a user message in the conversation, will contain the sys admin's requested behavior for this entity.
|
|
365
|
+
|
|
366
|
+
<CRITICAL>
|
|
367
|
+
I am a bot and can only understand FULLY FORMED JSON responses that can be parsed with JSON.parse().
|
|
368
|
+
|
|
369
|
+
Your response must be JSON and parsable into this type:
|
|
370
|
+
const returnType = {
|
|
371
|
+
code: string, // The typescript code you will create that will work in the context described above. Make sure to include line breaks, but not tabs. That is, pretty format in terms of new lines, but do NOT indent with spaces/tabs, as I'll handle indentation.
|
|
372
|
+
explanation: string // an explanation for a semi-technical person explaining what the code does. Here again use line breaks liberally to make it easy to read but do NOT indent with spaces/tabs as I will handle that. Use * lists and numbered lists as appropriate.
|
|
373
|
+
libraries: [
|
|
374
|
+
{LibraryName: string, ItemsUsed: string[]}, // tell me the libraries you have used in the code you created here in this array of libraries. I need this info to properly import them in the final code.
|
|
375
|
+
]
|
|
376
|
+
};
|
|
377
|
+
</CRITICAL>
|
|
378
|
+
**** REMEMBER **** I am a BOT, do not return anything other than the above JSON format to me or I will choke on your response!
|
|
379
|
+
`;
|
|
380
|
+
return prompt;
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
exports.ActionEntityServerEntity = ActionEntityServerEntity;
|
|
384
|
+
exports.ActionEntityServerEntity = ActionEntityServerEntity = __decorate([
|
|
385
|
+
(0, global_1.RegisterClass)(core_1.BaseEntity, 'Actions') // high priority make sure this class is used ahead of other things
|
|
386
|
+
,
|
|
387
|
+
__metadata("design:paramtypes", [core_1.EntityInfo])
|
|
388
|
+
], ActionEntityServerEntity);
|
|
389
|
+
function LoadActionEntityServer() {
|
|
390
|
+
// this function is used to force the class to load and register itself with the system
|
|
391
|
+
// this is necessary because the class is not explicitly referenced in the code, it is only registered with the system
|
|
392
|
+
// and the system will only load it when it is needed, this function forces the class to load
|
|
393
|
+
}
|
|
394
|
+
exports.LoadActionEntityServer = LoadActionEntityServer;
|
|
395
|
+
//# sourceMappingURL=ActionEntity.server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionEntity.server.js","sourceRoot":"","sources":["../../src/generic/ActionEntity.server.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAkI;AAClI,iEAA6H;AAC7H,mDAAyF;AACzF,uDAAoD;AAEpD,iDAA4E;AAC5E,2CAAsE;AAEtE;;GAEG;AAEI,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,4BAAY;IACtD,YAAY,MAAkB;QAC1B,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa;QA4BxB,iBAAY,GAA6B,IAAI,CAAC;QAY9C,YAAO,GAAwB,IAAI,CAAC;QASpC,UAAK,GAA0B,IAAI,CAAC;QA/CxC,MAAM,EAAE,GAAG,IAAI,eAAQ,EAAE,CAAC;QAC1B,IAAI,EAAE,CAAC,YAAY,KAAK,UAAU;YAC9B,MAAM,IAAI,KAAK,CAAC,6GAA6G,CAAC,CAAC;IACvI,CAAC;IACD;;;OAGG;IACH,IAAc,YAAY;QACtB,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,IAAW,gBAAgB;QACvB,OAAO,IAAA,yBAAkB,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,2BAAY,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IA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;;;;;;;;;;;;;;;;;;;;;;;EA6DI,IAAI,CAAC,SAAS,CAAC,eAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YAC9C,2DAA2D;YAC3D,OAAO;gBACH,MAAM,EAAE,CAAC,CAAC,IAAI;gBACd,UAAU,EAAE,CAAC,CAAC,UAAU;gBACxB,WAAW,EAAE,CAAC,CAAC,WAAW;gBAC1B,QAAQ,EAAE,CAAC,CAAC,QAAQ;aACvB,CAAA;QACL,CAAC,CAAC,CACN;;;;;;;;;;;;;;;;;CAiBC,CAAA;QACO,OAAO,MAAM,CAAC;IAClB,CAAC;CAEJ,CAAA;AA1YY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,sBAAa,EAAC,iBAAU,EAAE,SAAS,CAAC,CAAC,mEAAmE;;qCAEjF,iBAAU;GADrB,wBAAwB,CA0YpC;AAED,SAAgB,sBAAsB;IAClC,uFAAuF;IACvF,sHAAsH;IACtH,6FAA6F;AACjG,CAAC;AAJD,wDAIC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from "./ActionEngine";
|
|
2
|
+
/**
|
|
3
|
+
* Base class for all actions. All actions will derive from this class and be instantiated by the ClassFactory within the @memberjunctin/global package.
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class BaseAction {
|
|
6
|
+
Run(params: RunActionParams): Promise<ActionResultSimple>;
|
|
7
|
+
protected abstract InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=BaseAction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseAction.d.ts","sourceRoot":"","sources":["../../src/generic/BaseAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,kBAAkB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEnF;;GAEG;AACH,8BAAsB,UAAU;IAChB,GAAG,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAItE,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAC5F"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseAction = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Base class for all actions. All actions will derive from this class and be instantiated by the ClassFactory within the @memberjunctin/global package.
|
|
6
|
+
*/
|
|
7
|
+
class BaseAction {
|
|
8
|
+
async Run(params) {
|
|
9
|
+
return await this.InternalRunAction(params);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.BaseAction = BaseAction;
|
|
13
|
+
//# sourceMappingURL=BaseAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseAction.js","sourceRoot":"","sources":["../../src/generic/BaseAction.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH,MAAsB,UAAU;IACtB,KAAK,CAAC,GAAG,CAAC,MAAuB;QACrC,OAAO,MAAM,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;CAGH;AAND,gCAMC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ActionFilterEntity } from "@memberjunction/core-entities";
|
|
2
|
+
import { RunActionParams } from "./ActionEngine";
|
|
3
|
+
/**
|
|
4
|
+
* This is the base class for executing filters to determine if an action should be run. The CodeGen tool generates sub-classes of this class for each Action Filter in the system. The code injected into the
|
|
5
|
+
* auto-generated sub-classes will implement the InternalRunFilter method which is called by this base class. If you would like to use code generation for your Action Filter, but modify the logic for executing
|
|
6
|
+
* the filter you can sub-class the auto-generated sub-class. For this second level sub-class, you should use the @RegisterClass decorator from the @memberjunction/global package to register your subclass with
|
|
7
|
+
* the ClassFactory so that it will be used instead of the auto generated sub-class. This is the same pattern as how you would insert custom logic into a custom sub-class of BaseEntity.
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class BaseActionFilter {
|
|
10
|
+
/**
|
|
11
|
+
* Runs the filter logic for the given filter and params and returns true if the filter condition is met, false otherwise.
|
|
12
|
+
*/
|
|
13
|
+
Run(params: RunActionParams, filter: ActionFilterEntity): Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* This method is implemented by the auto-generated sub-class for this filter. In the auto-generated sub-classes for each Action Filter,
|
|
16
|
+
* the CodeGen tool will implement this method and insert into it the logic for the filter.
|
|
17
|
+
*/
|
|
18
|
+
protected abstract InternalRun(params: RunActionParams, filter: ActionFilterEntity): Promise<boolean>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=BaseActionFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseActionFilter.d.ts","sourceRoot":"","sources":["../../src/generic/BaseActionFilter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD;;;;;GAKG;AACH,8BAAsB,gBAAgB;IAClC;;OAEG;IACU,GAAG,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAMvF;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;CACxG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseActionFilter = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* This is the base class for executing filters to determine if an action should be run. The CodeGen tool generates sub-classes of this class for each Action Filter in the system. The code injected into the
|
|
6
|
+
* auto-generated sub-classes will implement the InternalRunFilter method which is called by this base class. If you would like to use code generation for your Action Filter, but modify the logic for executing
|
|
7
|
+
* the filter you can sub-class the auto-generated sub-class. For this second level sub-class, you should use the @RegisterClass decorator from the @memberjunction/global package to register your subclass with
|
|
8
|
+
* the ClassFactory so that it will be used instead of the auto generated sub-class. This is the same pattern as how you would insert custom logic into a custom sub-class of BaseEntity.
|
|
9
|
+
*/
|
|
10
|
+
class BaseActionFilter {
|
|
11
|
+
/**
|
|
12
|
+
* Runs the filter logic for the given filter and params and returns true if the filter condition is met, false otherwise.
|
|
13
|
+
*/
|
|
14
|
+
async Run(params, filter) {
|
|
15
|
+
// run the filter logic which is implemented in the sub-class. The reason we have a wrapper for the InternalRun function
|
|
16
|
+
// is so that we can implement anything else, over time, that we want to do across all sub-classes via this base class method.
|
|
17
|
+
return this.InternalRun(params, filter);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.BaseActionFilter = BaseActionFilter;
|
|
21
|
+
//# sourceMappingURL=BaseActionFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseActionFilter.js","sourceRoot":"","sources":["../../src/generic/BaseActionFilter.ts"],"names":[],"mappings":";;;AAGA;;;;;GAKG;AACH,MAAsB,gBAAgB;IAClC;;OAEG;IACI,KAAK,CAAC,GAAG,CAAC,MAAuB,EAAE,MAA0B;QAChE,wHAAwH;QACxH,8HAA8H;QAC9H,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;CAOJ;AAfD,4CAeC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/generic/test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { Metadata, RunView, BaseEntity } from "@memberjunction/core";
|
|
5
|
+
import { ActionResult } from "./ActionEngine";
|
|
6
|
+
|
|
7
|
+
async function test(params: any) {
|
|
8
|
+
// Create an instance of Metadata to interact with entities.
|
|
9
|
+
const md = new Metadata();
|
|
10
|
+
|
|
11
|
+
// Create an instance of RunView to retrieve multiple records from the 'Pending Accounts' entity.
|
|
12
|
+
const rv = new RunView();
|
|
13
|
+
|
|
14
|
+
// Fetch all the records from the 'Pending Accounts' entity as BaseEntity objects.
|
|
15
|
+
const pendingAccounts = await rv.RunView({
|
|
16
|
+
EntityName: 'PendingAccounts',
|
|
17
|
+
ResultType: 'entity_object'
|
|
18
|
+
}, params.userInfo);
|
|
19
|
+
|
|
20
|
+
// Iterate over each record.
|
|
21
|
+
for (const account of pendingAccounts.Results) {
|
|
22
|
+
// If the Status is 'Pending'
|
|
23
|
+
if (account.Status === 'Pending') {
|
|
24
|
+
// Change the Status to 'Active'.
|
|
25
|
+
account.Status = 'Active';
|
|
26
|
+
} else if (account.Status === 'Active') { // If the Status is 'Active'
|
|
27
|
+
// Change the Status to 'Completed'.
|
|
28
|
+
account.Status = 'Completed';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Add a fun comment to the Comments field in each record.
|
|
32
|
+
account.Comments = 'Keep up the good work!';
|
|
33
|
+
|
|
34
|
+
// Save the updated record back to the database.
|
|
35
|
+
await account.Save();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
async function test2(params: any) {
|
|
42
|
+
const rv = new RunView();
|
|
43
|
+
const result = await rv.RunView({
|
|
44
|
+
EntityName: 'Pending Accounts',
|
|
45
|
+
ResultType: 'entity_object'
|
|
46
|
+
}, params.contextUser);
|
|
47
|
+
|
|
48
|
+
if (result.Success) {
|
|
49
|
+
for (const account of result.Results as any[]) {
|
|
50
|
+
const status = account.Status;
|
|
51
|
+
if (status === 'Pending') {
|
|
52
|
+
account.Status = 'Active';
|
|
53
|
+
} else if (status === 'Active') {
|
|
54
|
+
account.Status = 'Completed';
|
|
55
|
+
}
|
|
56
|
+
account.Comments = 'Processed by automation - Have a great day!';
|
|
57
|
+
await account.Save();
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
Success: true,
|
|
61
|
+
ResultCode: 'Success',
|
|
62
|
+
Message: 'All pending accounts have been processed.'
|
|
63
|
+
};
|
|
64
|
+
} else {
|
|
65
|
+
return {
|
|
66
|
+
Success: false,
|
|
67
|
+
ResultCode: 'FailedToRetrieve',
|
|
68
|
+
Message: 'Failed to retrieve pending accounts.'
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
*/
|
|
73
|
+
//# sourceMappingURL=test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/generic/test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAuEM"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './generic/BaseAction';
|
|
2
|
+
export * from './generic/BaseActionFilter';
|
|
3
|
+
export * from './generic/ActionEngine';
|
|
4
|
+
export * from './generic/ActionEntity.server';
|
|
5
|
+
export * from './entity-actions/EntityActionEngine';
|
|
6
|
+
export * from './entity-actions/EntityActionEntity.server';
|
|
7
|
+
export * from './entity-actions/EntityActionInvocationTypes';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAE9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8CAA8C,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./generic/BaseAction"), exports);
|
|
18
|
+
__exportStar(require("./generic/BaseActionFilter"), exports);
|
|
19
|
+
__exportStar(require("./generic/ActionEngine"), exports);
|
|
20
|
+
__exportStar(require("./generic/ActionEntity.server"), exports);
|
|
21
|
+
__exportStar(require("./entity-actions/EntityActionEngine"), exports);
|
|
22
|
+
__exportStar(require("./entity-actions/EntityActionEntity.server"), exports);
|
|
23
|
+
__exportStar(require("./entity-actions/EntityActionInvocationTypes"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,6DAA2C;AAC3C,yDAAuC;AACvC,gEAA8C;AAE9C,sEAAoD;AACpD,6EAA2D;AAC3D,+EAA6D"}
|