@memberjunction/core-actions 2.52.0 → 2.54.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.
Files changed (29) hide show
  1. package/dist/custom/crud/base-record-mutation.action.d.ts +61 -0
  2. package/dist/custom/crud/base-record-mutation.action.d.ts.map +1 -0
  3. package/dist/custom/crud/base-record-mutation.action.js +201 -0
  4. package/dist/custom/crud/base-record-mutation.action.js.map +1 -0
  5. package/dist/custom/crud/create-record.action.d.ts +51 -0
  6. package/dist/custom/crud/create-record.action.d.ts.map +1 -0
  7. package/dist/custom/crud/create-record.action.js +116 -0
  8. package/dist/custom/crud/create-record.action.js.map +1 -0
  9. package/dist/custom/crud/delete-record.action.d.ts +62 -0
  10. package/dist/custom/crud/delete-record.action.d.ts.map +1 -0
  11. package/dist/custom/crud/delete-record.action.js +124 -0
  12. package/dist/custom/crud/delete-record.action.js.map +1 -0
  13. package/dist/custom/crud/get-record.action.d.ts +61 -0
  14. package/dist/custom/crud/get-record.action.d.ts.map +1 -0
  15. package/dist/custom/crud/get-record.action.js +117 -0
  16. package/dist/custom/crud/get-record.action.js.map +1 -0
  17. package/dist/custom/crud/index.d.ts +15 -0
  18. package/dist/custom/crud/index.d.ts.map +1 -0
  19. package/dist/custom/crud/index.js +31 -0
  20. package/dist/custom/crud/index.js.map +1 -0
  21. package/dist/custom/crud/update-record.action.d.ts +53 -0
  22. package/dist/custom/crud/update-record.action.d.ts.map +1 -0
  23. package/dist/custom/crud/update-record.action.js +146 -0
  24. package/dist/custom/crud/update-record.action.js.map +1 -0
  25. package/dist/index.d.ts +4 -0
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +13 -0
  28. package/dist/index.js.map +1 -1
  29. package/package.json +9 -9
@@ -0,0 +1,61 @@
1
+ import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
2
+ import { BaseAction } from "@memberjunction/actions";
3
+ import { BaseEntity } from "@memberjunction/core";
4
+ /**
5
+ * Abstract base class for record mutation actions (Create, Update, Delete).
6
+ * This class provides common functionality for validating parameters,
7
+ * loading entities, handling errors, and processing results.
8
+ *
9
+ * Not registered as an action itself - only its subclasses are registered.
10
+ */
11
+ export declare abstract class BaseRecordMutationAction extends BaseAction {
12
+ /**
13
+ * Extract and validate the EntityName parameter
14
+ */
15
+ protected getEntityNameParam(params: RunActionParams): {
16
+ value?: string;
17
+ error?: ActionResultSimple;
18
+ };
19
+ /**
20
+ * Extract and validate the PrimaryKey parameter
21
+ */
22
+ protected getPrimaryKeyParam(params: RunActionParams): {
23
+ value?: Record<string, any>;
24
+ error?: ActionResultSimple;
25
+ };
26
+ /**
27
+ * Extract and validate the Fields parameter
28
+ */
29
+ protected getFieldsParam(params: RunActionParams): {
30
+ value?: Record<string, any>;
31
+ error?: ActionResultSimple;
32
+ };
33
+ /**
34
+ * Get entity metadata and create entity object
35
+ */
36
+ protected getEntityObject(entityName: string, contextUser: any): Promise<{
37
+ entity?: BaseEntity;
38
+ entityInfo?: any;
39
+ error?: ActionResultSimple;
40
+ }>;
41
+ /**
42
+ * Load an existing record using primary key
43
+ */
44
+ protected loadRecord(entity: BaseEntity, entityInfo: any, primaryKey: Record<string, any>, entityName: string): Promise<{
45
+ success: boolean;
46
+ error?: ActionResultSimple;
47
+ }>;
48
+ /**
49
+ * Set field values on an entity
50
+ */
51
+ protected setFieldValues(entity: BaseEntity, fields: Record<string, any>, entityName: string): void;
52
+ /**
53
+ * Analyze error from entity save/delete operation and return appropriate result
54
+ */
55
+ protected analyzeEntityError(entity: BaseEntity, operation: 'create' | 'update' | 'delete', entityName: string): ActionResultSimple;
56
+ /**
57
+ * Handle generic errors with consistent formatting
58
+ */
59
+ protected handleError(e: any, operation: string): ActionResultSimple;
60
+ }
61
+ //# sourceMappingURL=base-record-mutation.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-record-mutation.action.d.ts","sourceRoot":"","sources":["../../../src/custom/crud/base-record-mutation.action.ts"],"names":[],"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,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IAUnG;;OAEG;IACH,SAAS,CAAC,kBAAkB,CACxB,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,EACzC,UAAU,EAAE,MAAM,GACnB,kBAAkB;IAyCrB;;OAEG;IACH,SAAS,CAAC,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,kBAAkB;CAQvE"}
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseRecordMutationAction = void 0;
4
+ const actions_1 = require("@memberjunction/actions");
5
+ const core_1 = require("@memberjunction/core");
6
+ /**
7
+ * Abstract base class for record mutation actions (Create, Update, Delete).
8
+ * This class provides common functionality for validating parameters,
9
+ * loading entities, handling errors, and processing results.
10
+ *
11
+ * Not registered as an action itself - only its subclasses are registered.
12
+ */
13
+ class BaseRecordMutationAction extends actions_1.BaseAction {
14
+ /**
15
+ * Extract and validate the EntityName parameter
16
+ */
17
+ getEntityNameParam(params) {
18
+ const entityNameParam = params.Params.find(p => p.Name.trim().toLowerCase() === 'entityname');
19
+ if (!entityNameParam || !entityNameParam.Value) {
20
+ return {
21
+ error: {
22
+ Success: false,
23
+ ResultCode: 'VALIDATION_ERROR',
24
+ Message: 'EntityName parameter is required'
25
+ }
26
+ };
27
+ }
28
+ return { value: entityNameParam.Value };
29
+ }
30
+ /**
31
+ * Extract and validate the PrimaryKey parameter
32
+ */
33
+ getPrimaryKeyParam(params) {
34
+ const primaryKeyParam = params.Params.find(p => p.Name.trim().toLowerCase() === 'primarykey');
35
+ if (!primaryKeyParam || !primaryKeyParam.Value) {
36
+ return {
37
+ error: {
38
+ Success: false,
39
+ ResultCode: 'VALIDATION_ERROR',
40
+ Message: 'PrimaryKey parameter is required'
41
+ }
42
+ };
43
+ }
44
+ return { value: primaryKeyParam.Value };
45
+ }
46
+ /**
47
+ * Extract and validate the Fields parameter
48
+ */
49
+ getFieldsParam(params) {
50
+ const fieldsParam = params.Params.find(p => p.Name.trim().toLowerCase() === 'fields');
51
+ if (!fieldsParam || !fieldsParam.Value) {
52
+ return {
53
+ error: {
54
+ Success: false,
55
+ ResultCode: 'VALIDATION_ERROR',
56
+ Message: 'Fields parameter is required'
57
+ }
58
+ };
59
+ }
60
+ return { value: fieldsParam.Value };
61
+ }
62
+ /**
63
+ * Get entity metadata and create entity object
64
+ */
65
+ async getEntityObject(entityName, contextUser) {
66
+ const md = new core_1.Metadata();
67
+ const entityInfo = md.EntityByName(entityName);
68
+ if (!entityInfo) {
69
+ return {
70
+ error: {
71
+ Success: false,
72
+ ResultCode: 'ENTITY_NOT_FOUND',
73
+ Message: `Entity '${entityName}' not found in metadata`
74
+ }
75
+ };
76
+ }
77
+ const entity = await md.GetEntityObject(entityName, contextUser);
78
+ if (!entity) {
79
+ return {
80
+ error: {
81
+ Success: false,
82
+ ResultCode: 'FAILED',
83
+ Message: `Failed to create entity object for '${entityName}'`
84
+ }
85
+ };
86
+ }
87
+ return { entity, entityInfo };
88
+ }
89
+ /**
90
+ * Load an existing record using primary key
91
+ */
92
+ async loadRecord(entity, entityInfo, primaryKey, entityName) {
93
+ // Validate all primary key fields are provided
94
+ const keyData = {};
95
+ for (const pk of entityInfo.PrimaryKeys) {
96
+ if (!(pk.Name in primaryKey)) {
97
+ return {
98
+ success: false,
99
+ error: {
100
+ Success: false,
101
+ ResultCode: 'VALIDATION_ERROR',
102
+ Message: `Primary key field '${pk.Name}' not provided`
103
+ }
104
+ };
105
+ }
106
+ keyData[pk.Name] = primaryKey[pk.Name];
107
+ }
108
+ // Load the record using LoadFromData which works for both single and composite keys
109
+ const loadResult = await entity.LoadFromData(keyData);
110
+ if (!loadResult) {
111
+ // Check if it's a permission issue or record not found
112
+ const latestResult = entity.LatestResult;
113
+ let resultCode = 'RECORD_NOT_FOUND';
114
+ let message = `${entityName} record not found`;
115
+ if (latestResult?.Message?.toLowerCase().includes('permission') ||
116
+ latestResult?.Message?.toLowerCase().includes('denied')) {
117
+ resultCode = 'PERMISSION_DENIED';
118
+ message = `Permission denied accessing ${entityName} record`;
119
+ }
120
+ return {
121
+ success: false,
122
+ error: {
123
+ Success: false,
124
+ ResultCode: resultCode,
125
+ Message: message
126
+ }
127
+ };
128
+ }
129
+ return { success: true };
130
+ }
131
+ /**
132
+ * Set field values on an entity
133
+ */
134
+ setFieldValues(entity, fields, entityName) {
135
+ for (const [fieldName, fieldValue] of Object.entries(fields)) {
136
+ if (fieldName in entity) {
137
+ entity.Set(fieldName, fieldValue);
138
+ }
139
+ else {
140
+ (0, core_1.LogError)(`Field '${fieldName}' does not exist on entity '${entityName}'`);
141
+ }
142
+ }
143
+ }
144
+ /**
145
+ * Analyze error from entity save/delete operation and return appropriate result
146
+ */
147
+ analyzeEntityError(entity, operation, entityName) {
148
+ const latestResult = entity.LatestResult;
149
+ let resultCode = 'FAILED';
150
+ let message = `Failed to ${operation} ${entityName} record`;
151
+ if (latestResult) {
152
+ if (latestResult.Message) {
153
+ message += `: ${latestResult.Message}`;
154
+ }
155
+ // Check for specific error types
156
+ if (latestResult.Message?.toLowerCase().includes('permission') ||
157
+ latestResult.Message?.toLowerCase().includes('denied')) {
158
+ resultCode = 'PERMISSION_DENIED';
159
+ }
160
+ else if (latestResult.Message?.toLowerCase().includes('validation') ||
161
+ latestResult.Message?.toLowerCase().includes('required')) {
162
+ resultCode = 'VALIDATION_ERROR';
163
+ }
164
+ else if (operation === 'update' &&
165
+ (latestResult.Message?.toLowerCase().includes('concurrent') ||
166
+ latestResult.Message?.toLowerCase().includes('modified'))) {
167
+ resultCode = 'CONCURRENT_UPDATE';
168
+ }
169
+ else if (operation === 'delete') {
170
+ if (latestResult.Message?.toLowerCase().includes('reference') ||
171
+ latestResult.Message?.toLowerCase().includes('constraint') ||
172
+ latestResult.Message?.toLowerCase().includes('foreign key')) {
173
+ resultCode = 'REFERENCE_CONSTRAINT';
174
+ message = `Cannot delete ${entityName} record: It is referenced by other records`;
175
+ }
176
+ else if (latestResult.Message?.toLowerCase().includes('cascade')) {
177
+ resultCode = 'CASCADE_CONSTRAINT';
178
+ message = `Cannot delete ${entityName} record: Cascade delete is not allowed`;
179
+ }
180
+ }
181
+ }
182
+ return {
183
+ Success: false,
184
+ ResultCode: resultCode,
185
+ Message: message
186
+ };
187
+ }
188
+ /**
189
+ * Handle generic errors with consistent formatting
190
+ */
191
+ handleError(e, operation) {
192
+ (0, core_1.LogError)(e);
193
+ return {
194
+ Success: false,
195
+ ResultCode: 'FAILED',
196
+ Message: `Error ${operation} record: ${e.message}`
197
+ };
198
+ }
199
+ }
200
+ exports.BaseRecordMutationAction = BaseRecordMutationAction;
201
+ //# sourceMappingURL=base-record-mutation.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-record-mutation.action.js","sourceRoot":"","sources":["../../../src/custom/crud/base-record-mutation.action.ts"],"names":[],"mappings":";;;AACA,qDAAqD;AACrD,+CAAsE;AAEtE;;;;;;GAMG;AACH,MAAsB,wBAAyB,SAAQ,oBAAU;IAC7D;;OAEG;IACO,kBAAkB,CAAC,MAAuB;QAChD,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,YAAY,CAAC,CAAC;QAE9F,IAAI,CAAC,eAAe,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;YAC7C,OAAO;gBACH,KAAK,EAAE;oBACH,OAAO,EAAE,KAAK;oBACd,UAAU,EAAE,kBAAkB;oBAC9B,OAAO,EAAE,kCAAkC;iBAC9C;aACJ,CAAC;QACN,CAAC;QAED,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,KAAe,EAAE,CAA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AU,GAAG,oBAAoB,CAAC;oBAClC,OAAO,GAAG,iBAAiB,UAAU,wCAAwC,CAAC;gBAClF,CAAC;YACL,CAAC;QACL,CAAC;QAED,OAAO;YACH,OAAO,EAAE,KAAK;YACd,UAAU,EAAE,UAAU;YACtB,OAAO,EAAE,OAAO;SACnB,CAAC;IACN,CAAC;IAED;;OAEG;IACO,WAAW,CAAC,CAAM,EAAE,SAAiB;QAC3C,IAAA,eAAQ,EAAC,CAAC,CAAC,CAAC;QACZ,OAAO;YACH,OAAO,EAAE,KAAK;YACd,UAAU,EAAE,QAAQ;YACpB,OAAO,EAAE,SAAS,SAAS,YAAY,CAAC,CAAC,OAAO,EAAE;SACrD,CAAC;IACN,CAAC;CACJ;AA1ND,4DA0NC"}
@@ -0,0 +1,51 @@
1
+ import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
2
+ import { BaseRecordMutationAction } from "./base-record-mutation.action";
3
+ /**
4
+ * Generic action for creating new entity records in the database.
5
+ * This action provides a flexible way to create records for any entity type
6
+ * by accepting the entity name and field values as parameters.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // Create a new customer record
11
+ * const result = await runAction({
12
+ * ActionName: 'Create Record',
13
+ * Params: [
14
+ * {
15
+ * Name: 'EntityName',
16
+ * Value: 'Customers'
17
+ * },
18
+ * {
19
+ * Name: 'Fields',
20
+ * Value: {
21
+ * Name: 'John Doe',
22
+ * Email: 'john@example.com',
23
+ * Status: 'Active'
24
+ * }
25
+ * }
26
+ * ]
27
+ * });
28
+ *
29
+ * // The PrimaryKey output parameter contains an object with the key field(s)
30
+ * // For example: { CustomerID: '12345' }
31
+ * const primaryKey = result.Params.find(p => p.Name === 'PrimaryKey')?.Value;
32
+ * ```
33
+ */
34
+ export declare class CreateRecordAction extends BaseRecordMutationAction {
35
+ /**
36
+ * Creates a new record for the specified entity type.
37
+ *
38
+ * @param params - The action parameters containing:
39
+ * - EntityName (required): The name of the entity to create
40
+ * - Fields (required): Object containing field names and values to set
41
+ *
42
+ * @returns ActionResultSimple with:
43
+ * - Success: true if record was created successfully
44
+ * - ResultCode: SUCCESS, FAILED, ENTITY_NOT_FOUND, VALIDATION_ERROR, PERMISSION_DENIED
45
+ * - Message: Details about the operation
46
+ * - Params: Output parameter 'PrimaryKey' contains an object with the primary key field(s) and value(s)
47
+ */
48
+ InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
49
+ }
50
+ export declare function LoadCreateRecordAction(): void;
51
+ //# sourceMappingURL=create-record.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-record.action.d.ts","sourceRoot":"","sources":["../../../src/custom/crud/create-record.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBACa,kBAAmB,SAAQ,wBAAwB;IAC5D;;;;;;;;;;;;OAYG;IACG,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAqDhF;AAED,wBAAgB,sBAAsB,SAGrC"}
@@ -0,0 +1,116 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.LoadCreateRecordAction = exports.CreateRecordAction = void 0;
10
+ const global_1 = require("@memberjunction/global");
11
+ const base_record_mutation_action_1 = require("./base-record-mutation.action");
12
+ /**
13
+ * Generic action for creating new entity records in the database.
14
+ * This action provides a flexible way to create records for any entity type
15
+ * by accepting the entity name and field values as parameters.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * // Create a new customer record
20
+ * const result = await runAction({
21
+ * ActionName: 'Create Record',
22
+ * Params: [
23
+ * {
24
+ * Name: 'EntityName',
25
+ * Value: 'Customers'
26
+ * },
27
+ * {
28
+ * Name: 'Fields',
29
+ * Value: {
30
+ * Name: 'John Doe',
31
+ * Email: 'john@example.com',
32
+ * Status: 'Active'
33
+ * }
34
+ * }
35
+ * ]
36
+ * });
37
+ *
38
+ * // The PrimaryKey output parameter contains an object with the key field(s)
39
+ * // For example: { CustomerID: '12345' }
40
+ * const primaryKey = result.Params.find(p => p.Name === 'PrimaryKey')?.Value;
41
+ * ```
42
+ */
43
+ let CreateRecordAction = class CreateRecordAction extends base_record_mutation_action_1.BaseRecordMutationAction {
44
+ /**
45
+ * Creates a new record for the specified entity type.
46
+ *
47
+ * @param params - The action parameters containing:
48
+ * - EntityName (required): The name of the entity to create
49
+ * - Fields (required): Object containing field names and values to set
50
+ *
51
+ * @returns ActionResultSimple with:
52
+ * - Success: true if record was created successfully
53
+ * - ResultCode: SUCCESS, FAILED, ENTITY_NOT_FOUND, VALIDATION_ERROR, PERMISSION_DENIED
54
+ * - Message: Details about the operation
55
+ * - Params: Output parameter 'PrimaryKey' contains an object with the primary key field(s) and value(s)
56
+ */
57
+ async InternalRunAction(params) {
58
+ try {
59
+ // Extract parameters
60
+ const entityNameResult = this.getEntityNameParam(params);
61
+ if (entityNameResult.error)
62
+ return entityNameResult.error;
63
+ const entityName = entityNameResult.value;
64
+ const fieldsResult = this.getFieldsParam(params);
65
+ if (fieldsResult.error)
66
+ return fieldsResult.error;
67
+ const fields = fieldsResult.value;
68
+ // Get entity object and metadata
69
+ const entityResult = await this.getEntityObject(entityName, params.ContextUser);
70
+ if (entityResult.error)
71
+ return entityResult.error;
72
+ const { entity, entityInfo } = entityResult;
73
+ // Set fields on the new entity
74
+ entity.NewRecord();
75
+ // Set field values using base class method
76
+ this.setFieldValues(entity, fields, entityName);
77
+ // Save the record
78
+ const saveResult = await entity.Save();
79
+ if (saveResult) {
80
+ // Get the primary key value(s)
81
+ const primaryKeys = {};
82
+ for (const pk of entityInfo.PrimaryKeys) {
83
+ primaryKeys[pk.Name] = entity.Get(pk.Name);
84
+ }
85
+ // Add output parameter with the primary key object
86
+ params.Params.push({
87
+ Name: 'PrimaryKey',
88
+ Value: primaryKeys,
89
+ Type: 'Output'
90
+ });
91
+ return {
92
+ Success: true,
93
+ ResultCode: 'SUCCESS',
94
+ Message: `Successfully created ${entityName} record`,
95
+ Params: params.Params
96
+ };
97
+ }
98
+ else {
99
+ return this.analyzeEntityError(entity, 'create', entityName);
100
+ }
101
+ }
102
+ catch (e) {
103
+ return this.handleError(e, 'creating');
104
+ }
105
+ }
106
+ };
107
+ exports.CreateRecordAction = CreateRecordAction;
108
+ exports.CreateRecordAction = CreateRecordAction = __decorate([
109
+ (0, global_1.RegisterClass)(base_record_mutation_action_1.BaseRecordMutationAction, "CreateRecordAction")
110
+ ], CreateRecordAction);
111
+ function LoadCreateRecordAction() {
112
+ // This function exists to prevent tree shaking from removing the action class
113
+ // The side effect of loading this file is that the @RegisterClass decorator runs
114
+ }
115
+ exports.LoadCreateRecordAction = LoadCreateRecordAction;
116
+ //# sourceMappingURL=create-record.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-record.action.js","sourceRoot":"","sources":["../../../src/custom/crud/create-record.action.ts"],"names":[],"mappings":";;;;;;;;;AACA,mDAAuD;AACvD,+EAAyE;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,sDAAwB;IAC5D;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QAC3C,IAAI,CAAC;YACD,qBA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AQ;iBACjB,CAAC,CAAC;gBAEH,OAAO;oBACH,OAAO,EAAE,IAAI;oBACb,UAAU,EAAE,SAAS;oBACrB,OAAO,EAAE,wBAAwB,UAAU,SAAS;oBACpD,MAAM,EAAE,MAAM,CAAC,MAAM;iBACxB,CAAC;YACN,CAAC;iBAAM,CAAC;gBACJ,OAAO,IAAI,CAAC,kBAAkB,CAAC,MAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;YAClE,CAAC;QAEL,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;QAC3C,CAAC;IACL,CAAC;CACJ,CAAA;AAnEY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,sBAAa,EAAC,sDAAwB,EAAE,oBAAoB,CAAC;GACjD,kBAAkB,CAmE9B;AAED,SAAgB,sBAAsB;IAClC,8EAA8E;IAC9E,iFAAiF;AACrF,CAAC;AAHD,wDAGC"}
@@ -0,0 +1,62 @@
1
+ import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
2
+ import { BaseRecordMutationAction } from "./base-record-mutation.action";
3
+ /**
4
+ * Generic action for deleting entity records from the database.
5
+ * This action provides a flexible way to delete records for any entity type
6
+ * by accepting the entity name and primary key values as parameters.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // Delete a single record by ID
11
+ * await runAction({
12
+ * ActionName: 'Delete Record',
13
+ * Params: [
14
+ * {
15
+ * Name: 'EntityName',
16
+ * Value: 'Customers'
17
+ * },
18
+ * {
19
+ * Name: 'PrimaryKey',
20
+ * Value: { ID: '123e4567-e89b-12d3-a456-426614174000' }
21
+ * }
22
+ * ]
23
+ * });
24
+ *
25
+ * // Delete a record with composite primary key
26
+ * await runAction({
27
+ * ActionName: 'Delete Record',
28
+ * Params: [
29
+ * {
30
+ * Name: 'EntityName',
31
+ * Value: 'UserRoles'
32
+ * },
33
+ * {
34
+ * Name: 'PrimaryKey',
35
+ * Value: {
36
+ * UserID: '123e4567-e89b-12d3-a456-426614174000',
37
+ * RoleID: '987f6543-e21b-12d3-a456-426614174000'
38
+ * }
39
+ * }
40
+ * ]
41
+ * });
42
+ * ```
43
+ */
44
+ export declare class DeleteRecordAction extends BaseRecordMutationAction {
45
+ /**
46
+ * Deletes a record for the specified entity type using its primary key.
47
+ *
48
+ * @param params - The action parameters containing:
49
+ * - EntityName (required): The name of the entity to delete
50
+ * - PrimaryKey (required): Object containing primary key field(s) and value(s)
51
+ *
52
+ * @returns ActionResultSimple with:
53
+ * - Success: true if record was deleted successfully
54
+ * - ResultCode: SUCCESS, FAILED, ENTITY_NOT_FOUND, RECORD_NOT_FOUND, VALIDATION_ERROR,
55
+ * PERMISSION_DENIED, CASCADE_CONSTRAINT, REFERENCE_CONSTRAINT
56
+ * - Message: Details about the operation
57
+ * - Params: Output parameter 'DeletedRecord' contains the data of the deleted record
58
+ */
59
+ InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
60
+ }
61
+ export declare function LoadDeleteRecordAction(): void;
62
+ //# sourceMappingURL=delete-record.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-record.action.d.ts","sourceRoot":"","sources":["../../../src/custom/crud/delete-record.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,qBACa,kBAAmB,SAAQ,wBAAwB;IAC5D;;;;;;;;;;;;;OAaG;IACG,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAgDhF;AAED,wBAAgB,sBAAsB,SAGrC"}
@@ -0,0 +1,124 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.LoadDeleteRecordAction = exports.DeleteRecordAction = void 0;
10
+ const global_1 = require("@memberjunction/global");
11
+ const base_record_mutation_action_1 = require("./base-record-mutation.action");
12
+ /**
13
+ * Generic action for deleting entity records from the database.
14
+ * This action provides a flexible way to delete records for any entity type
15
+ * by accepting the entity name and primary key values as parameters.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * // Delete a single record by ID
20
+ * await runAction({
21
+ * ActionName: 'Delete Record',
22
+ * Params: [
23
+ * {
24
+ * Name: 'EntityName',
25
+ * Value: 'Customers'
26
+ * },
27
+ * {
28
+ * Name: 'PrimaryKey',
29
+ * Value: { ID: '123e4567-e89b-12d3-a456-426614174000' }
30
+ * }
31
+ * ]
32
+ * });
33
+ *
34
+ * // Delete a record with composite primary key
35
+ * await runAction({
36
+ * ActionName: 'Delete Record',
37
+ * Params: [
38
+ * {
39
+ * Name: 'EntityName',
40
+ * Value: 'UserRoles'
41
+ * },
42
+ * {
43
+ * Name: 'PrimaryKey',
44
+ * Value: {
45
+ * UserID: '123e4567-e89b-12d3-a456-426614174000',
46
+ * RoleID: '987f6543-e21b-12d3-a456-426614174000'
47
+ * }
48
+ * }
49
+ * ]
50
+ * });
51
+ * ```
52
+ */
53
+ let DeleteRecordAction = class DeleteRecordAction extends base_record_mutation_action_1.BaseRecordMutationAction {
54
+ /**
55
+ * Deletes a record for the specified entity type using its primary key.
56
+ *
57
+ * @param params - The action parameters containing:
58
+ * - EntityName (required): The name of the entity to delete
59
+ * - PrimaryKey (required): Object containing primary key field(s) and value(s)
60
+ *
61
+ * @returns ActionResultSimple with:
62
+ * - Success: true if record was deleted successfully
63
+ * - ResultCode: SUCCESS, FAILED, ENTITY_NOT_FOUND, RECORD_NOT_FOUND, VALIDATION_ERROR,
64
+ * PERMISSION_DENIED, CASCADE_CONSTRAINT, REFERENCE_CONSTRAINT
65
+ * - Message: Details about the operation
66
+ * - Params: Output parameter 'DeletedRecord' contains the data of the deleted record
67
+ */
68
+ async InternalRunAction(params) {
69
+ try {
70
+ // Extract parameters
71
+ const entityNameResult = this.getEntityNameParam(params);
72
+ if (entityNameResult.error)
73
+ return entityNameResult.error;
74
+ const entityName = entityNameResult.value;
75
+ const primaryKeyResult = this.getPrimaryKeyParam(params);
76
+ if (primaryKeyResult.error)
77
+ return primaryKeyResult.error;
78
+ const primaryKey = primaryKeyResult.value;
79
+ // Get entity object and metadata
80
+ const entityResult = await this.getEntityObject(entityName, params.ContextUser);
81
+ if (entityResult.error)
82
+ return entityResult.error;
83
+ const { entity, entityInfo } = entityResult;
84
+ // Load the existing record
85
+ const loadResult = await this.loadRecord(entity, entityInfo, primaryKey, entityName);
86
+ if (!loadResult.success)
87
+ return loadResult.error;
88
+ // Store the record data before deletion
89
+ const deletedRecordData = entity.GetAll();
90
+ // Delete the record
91
+ const deleteResult = await entity.Delete();
92
+ if (deleteResult) {
93
+ // Add output parameter with the deleted record data
94
+ params.Params.push({
95
+ Name: 'DeletedRecord',
96
+ Value: deletedRecordData,
97
+ Type: 'Output'
98
+ });
99
+ return {
100
+ Success: true,
101
+ ResultCode: 'SUCCESS',
102
+ Message: `Successfully deleted ${entityName} record`,
103
+ Params: params.Params
104
+ };
105
+ }
106
+ else {
107
+ return this.analyzeEntityError(entity, 'delete', entityName);
108
+ }
109
+ }
110
+ catch (e) {
111
+ return this.handleError(e, 'deleting');
112
+ }
113
+ }
114
+ };
115
+ exports.DeleteRecordAction = DeleteRecordAction;
116
+ exports.DeleteRecordAction = DeleteRecordAction = __decorate([
117
+ (0, global_1.RegisterClass)(base_record_mutation_action_1.BaseRecordMutationAction, "DeleteRecordAction")
118
+ ], DeleteRecordAction);
119
+ function LoadDeleteRecordAction() {
120
+ // This function exists to prevent tree shaking from removing the action class
121
+ // The side effect of loading this file is that the @RegisterClass decorator runs
122
+ }
123
+ exports.LoadDeleteRecordAction = LoadDeleteRecordAction;
124
+ //# sourceMappingURL=delete-record.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-record.action.js","sourceRoot":"","sources":["../../../src/custom/crud/delete-record.action.ts"],"names":[],"mappings":";;;;;;;;;AACA,mDAAuD;AACvD,+EAAyE;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,sDAAwB;IAC5D;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QAC3C,IAAI,CAAC;YACD,qBAAqB;YACrB,MAAM,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;YACzD,IAAI,gBAAgB,CAAC,KAAK;gBAAE,OAAO,gBAAgB,CAAC,KAAK,CAAC;YAC1D,MAAM,UAAU,GAAG,gBAAgB,CAAC,KAAM,CAAC;YAE3C,MAAM,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;YACzD,IAAI,gBAAgB,CAAC,KAAK;gBAAE,OAAO,gBAAgB,CAAC,KAAK,CAAC;YAC1D,MAAM,UAAU,GAAG,gBAAgB,CAAC,KAAM,CAAC;YAE3C,iCAAiC;YACjC,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;YAChF,IAAI,YAAY,CAAC,KAAK;gBAAE,OAAO,YAAY,CAAC,KAAK,CAAC;YAClD,MAAM,EAAE,MAAM,EAAE,UAAU,E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RecordMutationAction } from "./base-record-mutation.action";
3
+ /**
4
+ * Generic action for retrieving entity records from the database.
5
+ * This action provides a flexible way to fetch records for any entity type
6
+ * by accepting the entity name and primary key values as parameters.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // Get a single record by ID
11
+ * await runAction({
12
+ * ActionName: 'Get Record',
13
+ * Params: [
14
+ * {
15
+ * Name: 'EntityName',
16
+ * Value: 'Customers'
17
+ * },
18
+ * {
19
+ * Name: 'PrimaryKey',
20
+ * Value: { ID: '123e4567-e89b-12d3-a456-426614174000' }
21
+ * }
22
+ * ]
23
+ * });
24
+ *
25
+ * // Get a record with composite primary key
26
+ * await runAction({
27
+ * ActionName: 'Get Record',
28
+ * Params: [
29
+ * {
30
+ * Name: 'EntityName',
31
+ * Value: 'UserRoles'
32
+ * },
33
+ * {
34
+ * Name: 'PrimaryKey',
35
+ * Value: {
36
+ * UserID: '123e4567-e89b-12d3-a456-426614174000',
37
+ * RoleID: '987f6543-e21b-12d3-a456-426614174000'
38
+ * }
39
+ * }
40
+ * ]
41
+ * });
42
+ * ```
43
+ */
44
+ export declare class GetRecordAction extends BaseRecordMutationAction {
45
+ /**
46
+ * Retrieves a record for the specified entity type using its primary key.
47
+ *
48
+ * @param params - The action parameters containing:
49
+ * - EntityName (required): The name of the entity to retrieve
50
+ * - PrimaryKey (required): Object containing primary key field(s) and value(s)
51
+ *
52
+ * @returns ActionResultSimple with:
53
+ * - Success: true if record was retrieved successfully
54
+ * - ResultCode: SUCCESS, FAILED, ENTITY_NOT_FOUND, RECORD_NOT_FOUND, VALIDATION_ERROR, PERMISSION_DENIED
55
+ * - Message: Details about the operation
56
+ * - Params: Output parameter 'Record' contains the retrieved entity data
57
+ */
58
+ InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
59
+ }
60
+ export declare function LoadGetRecordAction(): void;
61
+ //# sourceMappingURL=get-record.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-record.action.d.ts","sourceRoot":"","sources":["../../../src/custom/crud/get-record.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,qBACa,eAAgB,SAAQ,wBAAwB;IACzD;;;;;;;;;;;;OAYG;IACG,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA4ChF;AAED,wBAAgB,mBAAmB,SAGlC"}
@@ -0,0 +1,117 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.LoadGetRecordAction = exports.GetRecordAction = void 0;
10
+ const global_1 = require("@memberjunction/global");
11
+ const base_record_mutation_action_1 = require("./base-record-mutation.action");
12
+ /**
13
+ * Generic action for retrieving entity records from the database.
14
+ * This action provides a flexible way to fetch records for any entity type
15
+ * by accepting the entity name and primary key values as parameters.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * // Get a single record by ID
20
+ * await runAction({
21
+ * ActionName: 'Get Record',
22
+ * Params: [
23
+ * {
24
+ * Name: 'EntityName',
25
+ * Value: 'Customers'
26
+ * },
27
+ * {
28
+ * Name: 'PrimaryKey',
29
+ * Value: { ID: '123e4567-e89b-12d3-a456-426614174000' }
30
+ * }
31
+ * ]
32
+ * });
33
+ *
34
+ * // Get a record with composite primary key
35
+ * await runAction({
36
+ * ActionName: 'Get Record',
37
+ * Params: [
38
+ * {
39
+ * Name: 'EntityName',
40
+ * Value: 'UserRoles'
41
+ * },
42
+ * {
43
+ * Name: 'PrimaryKey',
44
+ * Value: {
45
+ * UserID: '123e4567-e89b-12d3-a456-426614174000',
46
+ * RoleID: '987f6543-e21b-12d3-a456-426614174000'
47
+ * }
48
+ * }
49
+ * ]
50
+ * });
51
+ * ```
52
+ */
53
+ let GetRecordAction = class GetRecordAction extends base_record_mutation_action_1.BaseRecordMutationAction {
54
+ /**
55
+ * Retrieves a record for the specified entity type using its primary key.
56
+ *
57
+ * @param params - The action parameters containing:
58
+ * - EntityName (required): The name of the entity to retrieve
59
+ * - PrimaryKey (required): Object containing primary key field(s) and value(s)
60
+ *
61
+ * @returns ActionResultSimple with:
62
+ * - Success: true if record was retrieved successfully
63
+ * - ResultCode: SUCCESS, FAILED, ENTITY_NOT_FOUND, RECORD_NOT_FOUND, VALIDATION_ERROR, PERMISSION_DENIED
64
+ * - Message: Details about the operation
65
+ * - Params: Output parameter 'Record' contains the retrieved entity data
66
+ */
67
+ async InternalRunAction(params) {
68
+ try {
69
+ // Extract parameters
70
+ const entityNameResult = this.getEntityNameParam(params);
71
+ if (entityNameResult.error)
72
+ return entityNameResult.error;
73
+ const entityName = entityNameResult.value;
74
+ const primaryKeyResult = this.getPrimaryKeyParam(params);
75
+ if (primaryKeyResult.error)
76
+ return primaryKeyResult.error;
77
+ const primaryKey = primaryKeyResult.value;
78
+ // Get entity object and metadata
79
+ const entityResult = await this.getEntityObject(entityName, params.ContextUser);
80
+ if (entityResult.error)
81
+ return entityResult.error;
82
+ const { entity, entityInfo } = entityResult;
83
+ // Load the record
84
+ const loadResult = await this.loadRecord(entity, entityInfo, primaryKey, entityName);
85
+ if (!loadResult.success) {
86
+ return loadResult.error;
87
+ }
88
+ // Get all field values
89
+ const recordData = entity.GetAll();
90
+ // Add output parameter with the record data
91
+ params.Params.push({
92
+ Name: 'Record',
93
+ Value: recordData,
94
+ Type: 'Output'
95
+ });
96
+ return {
97
+ Success: true,
98
+ ResultCode: 'SUCCESS',
99
+ Message: `Successfully retrieved ${entityName} record`,
100
+ Params: params.Params
101
+ };
102
+ }
103
+ catch (e) {
104
+ return this.handleError(e, 'retrieving');
105
+ }
106
+ }
107
+ };
108
+ exports.GetRecordAction = GetRecordAction;
109
+ exports.GetRecordAction = GetRecordAction = __decorate([
110
+ (0, global_1.RegisterClass)(base_record_mutation_action_1.BaseRecordMutationAction, "GetRecordAction")
111
+ ], GetRecordAction);
112
+ function LoadGetRecordAction() {
113
+ // This function exists to prevent tree shaking from removing the action class
114
+ // The side effect of loading this file is that the @RegisterClass decorator runs
115
+ }
116
+ exports.LoadGetRecordAction = LoadGetRecordAction;
117
+ //# sourceMappingURL=get-record.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-record.action.js","sourceRoot":"","sources":["../../../src/custom/crud/get-record.action.ts"],"names":[],"mappings":";;;;;;;;;AACA,mDAAuD;AACvD,+EAAyE;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,sDAAwB;IACzD;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QAC3C,IAAI,CAAC;YACD,qBAAqB;YACrB,MAAM,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;YACzD,IAAI,gBAAgB,CAAC,KAAK;gBAAE,OAAO,gBAAgB,CAAC,KAAK,CAAC;YAC1D,MAAM,UAAU,GAAG,gBAAgB,CAAC,KAAM,CAAC;YAE3C,MAAM,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;YACzD,IAAI,gBAAgB,CAAC,KAAK;gBAAE,OAAO,gBAAgB,CAAC,KAAK,CAAC;YAC1D,MAAM,UA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UD Actions
3
+ *
4
+ * This module exports generic Create, Read, Update, and Delete (CRUD) actions
5
+ * that can work with any entity in the MemberJunction framework.
6
+ *
7
+ * These actions provide a flexible foundation for data operations and can be
8
+ * extended through child actions for entity-specific functionality.
9
+ */
10
+ export * from './base-record-mutation.action';
11
+ export * from './create-record.action';
12
+ export * from './get-record.action';
13
+ export * from './update-record.action';
14
+ export * from './delete-record.action';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/custom/crud/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /**
3
+ * CRUD Actions
4
+ *
5
+ * This module exports generic Create, Read, Update, and Delete (CRUD) actions
6
+ * that can work with any entity in the MemberJunction framework.
7
+ *
8
+ * These actions provide a flexible foundation for data operations and can be
9
+ * extended through child actions for entity-specific functionality.
10
+ */
11
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
+ desc = { enumerable: true, get: function() { return m[k]; } };
16
+ }
17
+ Object.defineProperty(o, k2, desc);
18
+ }) : (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ }));
22
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
23
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ __exportStar(require("./base-record-mutation.action"), exports);
27
+ __exportStar(require("./create-record.action"), exports);
28
+ __exportStar(require("./get-record.action"), exports);
29
+ __exportStar(require("./update-record.action"), exports);
30
+ __exportStar(require("./delete-record.action"), exports);
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/custom/crud/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;AAEH,gEAA8C;AAC9C,yDAAuC;AACvC,sDAAoC;AACpC,yDAAuC;AACvC,yDAAuC"}
@@ -0,0 +1,53 @@
1
+ import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
2
+ import { BaseRecordMutationAction } from "./base-record-mutation.action";
3
+ /**
4
+ * Generic action for updating existing entity records in the database.
5
+ * This action provides a flexible way to update records for any entity type
6
+ * by accepting the entity name, primary key, and field values as parameters.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // Update a customer record
11
+ * await runAction({
12
+ * ActionName: 'Update Record',
13
+ * Params: [
14
+ * {
15
+ * Name: 'EntityName',
16
+ * Value: 'Customers'
17
+ * },
18
+ * {
19
+ * Name: 'PrimaryKey',
20
+ * Value: { ID: '123e4567-e89b-12d3-a456-426614174000' }
21
+ * },
22
+ * {
23
+ * Name: 'Fields',
24
+ * Value: {
25
+ * Email: 'newemail@example.com',
26
+ * Status: 'Inactive',
27
+ * UpdatedAt: new Date()
28
+ * }
29
+ * }
30
+ * ]
31
+ * });
32
+ * ```
33
+ */
34
+ export declare class UpdateRecordAction extends BaseRecordMutationAction {
35
+ /**
36
+ * Updates an existing record for the specified entity type.
37
+ *
38
+ * @param params - The action parameters containing:
39
+ * - EntityName (required): The name of the entity to update
40
+ * - PrimaryKey (required): Object containing primary key field(s) and value(s)
41
+ * - Fields (required): Object containing field names and values to update
42
+ *
43
+ * @returns ActionResultSimple with:
44
+ * - Success: true if record was updated successfully
45
+ * - ResultCode: SUCCESS, FAILED, ENTITY_NOT_FOUND, RECORD_NOT_FOUND, VALIDATION_ERROR,
46
+ * PERMISSION_DENIED, NO_CHANGES, CONCURRENT_UPDATE
47
+ * - Message: Details about the operation
48
+ * - Params: Output parameter 'UpdatedFields' contains the fields that were actually changed
49
+ */
50
+ InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
51
+ }
52
+ export declare function LoadUpdateRecordAction(): void;
53
+ //# sourceMappingURL=update-record.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-record.action.d.ts","sourceRoot":"","sources":["../../../src/custom/crud/update-record.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAGnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBACa,kBAAmB,SAAQ,wBAAwB;IAC5D;;;;;;;;;;;;;;OAcG;IACG,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA+EhF;AAED,wBAAgB,sBAAsB,SAGrC"}
@@ -0,0 +1,146 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.LoadUpdateRecordAction = exports.UpdateRecordAction = void 0;
10
+ const global_1 = require("@memberjunction/global");
11
+ const core_1 = require("@memberjunction/core");
12
+ const base_record_mutation_action_1 = require("./base-record-mutation.action");
13
+ /**
14
+ * Generic action for updating existing entity records in the database.
15
+ * This action provides a flexible way to update records for any entity type
16
+ * by accepting the entity name, primary key, and field values as parameters.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * // Update a customer record
21
+ * await runAction({
22
+ * ActionName: 'Update Record',
23
+ * Params: [
24
+ * {
25
+ * Name: 'EntityName',
26
+ * Value: 'Customers'
27
+ * },
28
+ * {
29
+ * Name: 'PrimaryKey',
30
+ * Value: { ID: '123e4567-e89b-12d3-a456-426614174000' }
31
+ * },
32
+ * {
33
+ * Name: 'Fields',
34
+ * Value: {
35
+ * Email: 'newemail@example.com',
36
+ * Status: 'Inactive',
37
+ * UpdatedAt: new Date()
38
+ * }
39
+ * }
40
+ * ]
41
+ * });
42
+ * ```
43
+ */
44
+ let UpdateRecordAction = class UpdateRecordAction extends base_record_mutation_action_1.BaseRecordMutationAction {
45
+ /**
46
+ * Updates an existing record for the specified entity type.
47
+ *
48
+ * @param params - The action parameters containing:
49
+ * - EntityName (required): The name of the entity to update
50
+ * - PrimaryKey (required): Object containing primary key field(s) and value(s)
51
+ * - Fields (required): Object containing field names and values to update
52
+ *
53
+ * @returns ActionResultSimple with:
54
+ * - Success: true if record was updated successfully
55
+ * - ResultCode: SUCCESS, FAILED, ENTITY_NOT_FOUND, RECORD_NOT_FOUND, VALIDATION_ERROR,
56
+ * PERMISSION_DENIED, NO_CHANGES, CONCURRENT_UPDATE
57
+ * - Message: Details about the operation
58
+ * - Params: Output parameter 'UpdatedFields' contains the fields that were actually changed
59
+ */
60
+ async InternalRunAction(params) {
61
+ try {
62
+ // Extract parameters
63
+ const entityNameResult = this.getEntityNameParam(params);
64
+ if (entityNameResult.error)
65
+ return entityNameResult.error;
66
+ const entityName = entityNameResult.value;
67
+ const primaryKeyResult = this.getPrimaryKeyParam(params);
68
+ if (primaryKeyResult.error)
69
+ return primaryKeyResult.error;
70
+ const primaryKey = primaryKeyResult.value;
71
+ const fieldsResult = this.getFieldsParam(params);
72
+ if (fieldsResult.error)
73
+ return fieldsResult.error;
74
+ const fields = fieldsResult.value;
75
+ // Get entity object and metadata
76
+ const entityResult = await this.getEntityObject(entityName, params.ContextUser);
77
+ if (entityResult.error)
78
+ return entityResult.error;
79
+ const { entity, entityInfo } = entityResult;
80
+ // Load the existing record
81
+ const loadResult = await this.loadRecord(entity, entityInfo, primaryKey, entityName);
82
+ if (!loadResult.success)
83
+ return loadResult.error;
84
+ // Track which fields are actually being changed
85
+ const updatedFields = {};
86
+ let hasChanges = false;
87
+ // Set each field value
88
+ for (const [fieldName, fieldValue] of Object.entries(fields)) {
89
+ if (fieldName in entity) {
90
+ const currentValue = entity.Get(fieldName);
91
+ if (currentValue !== fieldValue) {
92
+ entity.Set(fieldName, fieldValue);
93
+ updatedFields[fieldName] = {
94
+ oldValue: currentValue,
95
+ newValue: fieldValue
96
+ };
97
+ hasChanges = true;
98
+ }
99
+ }
100
+ else {
101
+ (0, core_1.LogError)(`Field '${fieldName}' does not exist on entity '${entityName}'`);
102
+ }
103
+ }
104
+ // Check if there are any changes to save
105
+ if (!hasChanges) {
106
+ return {
107
+ Success: true,
108
+ ResultCode: 'NO_CHANGES',
109
+ Message: 'No fields were modified'
110
+ };
111
+ }
112
+ // Save the record
113
+ const saveResult = await entity.Save();
114
+ if (saveResult) {
115
+ // Add output parameter with the updated fields
116
+ params.Params.push({
117
+ Name: 'UpdatedFields',
118
+ Value: updatedFields,
119
+ Type: 'Output'
120
+ });
121
+ return {
122
+ Success: true,
123
+ ResultCode: 'SUCCESS',
124
+ Message: `Successfully updated ${entityName} record`,
125
+ Params: params.Params
126
+ };
127
+ }
128
+ else {
129
+ return this.analyzeEntityError(entity, 'update', entityName);
130
+ }
131
+ }
132
+ catch (e) {
133
+ return this.handleError(e, 'updating');
134
+ }
135
+ }
136
+ };
137
+ exports.UpdateRecordAction = UpdateRecordAction;
138
+ exports.UpdateRecordAction = UpdateRecordAction = __decorate([
139
+ (0, global_1.RegisterClass)(base_record_mutation_action_1.BaseRecordMutationAction, "UpdateRecordAction")
140
+ ], UpdateRecordAction);
141
+ function LoadUpdateRecordAction() {
142
+ // This function exists to prevent tree shaking from removing the action class
143
+ // The side effect of loading this file is that the @RegisterClass decorator runs
144
+ }
145
+ exports.LoadUpdateRecordAction = LoadUpdateRecordAction;
146
+ //# sourceMappingURL=update-record.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-record.action.js","sourceRoot":"","sources":["../../../src/custom/crud/update-record.action.ts"],"names":[],"mappings":";;;;;;;;;AACA,mDAAuD;AACvD,+CAAgD;AAChD,+EAAyE;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,sDAAwB;IAC5D;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QAC3C,IAAI,CAAC;YACD,qBAAqB;YACrB,MAAM,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;YACzD,IAAI,gBAAgB,CAAC,KAAK;gBAAE,OAAO,gBAAgB,CAAC,KAAK,CAAC;YAC1D,MAAM,UAAU,GAAG,gBAAgB,CAAC,KAAM,CAAC;YAE3C,MAAM,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;YACzD,IAAI,gBAAgB,CAAC,KAAK;gBAAE,OAAO,gBAAgB,CAAC,KAAK,CAAC;YAC1D,MAAM,UAAU,GAAG,gBAAgB,CAAC,KAAM,CAAC;YAE3C,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YACjD,IAAI,YAAY,CAAC,KAAK;gBAAE,OAAO,YAAY,CAAC,KAAK,CAAC;YAClD,MAAM,MAAM,GAAG,YAAY,CAAC,KAAM,CAAC;YAEnC,iCAAiC;YACjC,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,CA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O,CAAC,IAAI,EAAE,CAAC;YAExC,IAAI,UAAU,EAAE,CAAC;gBACb,+CAA+C;gBAC/C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;oBACf,IAAI,EAAE,eAAe;oBACrB,KAAK,EAAE,aAAa;oBACpB,IAAI,EAAE,QAAQ;iBACjB,CAAC,CAAC;gBAEH,OAAO;oBACH,OAAO,EAAE,IAAI;oBACb,UAAU,EAAE,SAAS;oBACrB,OAAO,EAAE,wBAAwB,UAAU,SAAS;oBACpD,MAAM,EAAE,MAAM,CAAC,MAAM;iBACxB,CAAC;YACN,CAAC;iBAAM,CAAC;gBACJ,OAAO,IAAI,CAAC,kBAAkB,CAAC,MAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;YAClE,CAAC;QAEL,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;QAC3C,CAAC;IACL,CAAC;CACJ,CAAA;AA/FY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,sBAAa,EAAC,sDAAwB,EAAE,oBAAoB,CAAC;GACjD,kBAAkB,CA+F9B;AAED,SAAgB,sBAAsB;IAClC,8EAA8E;IAC9E,iFAAiF;AACrF,CAAC;AAHD,wDAGC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  export * from './generated/action_subclasses';
2
2
  export * from './custom/communication/send-single-message.action';
3
+ export * from './custom/crud/create-record.action';
4
+ export * from './custom/crud/get-record.action';
5
+ export * from './custom/crud/update-record.action';
6
+ export * from './custom/crud/delete-record.action';
3
7
  export * from './custom/demo/get-weather.action';
4
8
  export * from './custom/demo/get-stock-price.action';
5
9
  export * from './custom/demo/calculate-expression.action';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAG9C,cAAc,mDAAmD,CAAC;AAGlE,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AAGpD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,oDAAoD,CAAC;AACnE,cAAc,0CAA0C,CAAC;AACzD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,qDAAqD,CAAC;AACpE,cAAc,mCAAmC,CAAC;AAGlD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,CAAC;AACrD,cAAc,wCAAwC,CAAC;AACvD,cAAc,4CAA4C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAG9C,cAAc,mDAAmD,CAAC;AAGlE,cAAc,oCAAoC,CAAC;AACnD,cAAc,iCAAiC,CAAC;AAChD,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AAGnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AAGpD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,oDAAoD,CAAC;AACnE,cAAc,0CAA0C,CAAC;AACzD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,qDAAqD,CAAC;AACpE,cAAc,mCAAmC,CAAC;AAGlD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,CAAC;AACrD,cAAc,wCAAwC,CAAC;AACvD,cAAc,4CAA4C,CAAC"}
package/dist/index.js CHANGED
@@ -17,6 +17,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./generated/action_subclasses"), exports);
18
18
  // Communication Actions
19
19
  __exportStar(require("./custom/communication/send-single-message.action"), exports);
20
+ // CRUD Actions
21
+ __exportStar(require("./custom/crud/create-record.action"), exports);
22
+ __exportStar(require("./custom/crud/get-record.action"), exports);
23
+ __exportStar(require("./custom/crud/update-record.action"), exports);
24
+ __exportStar(require("./custom/crud/delete-record.action"), exports);
20
25
  // Demo Actions
21
26
  __exportStar(require("./custom/demo/get-weather.action"), exports);
22
27
  __exportStar(require("./custom/demo/get-stock-price.action"), exports);
@@ -38,6 +43,10 @@ __exportStar(require("./custom/web/url-link-validator.action"), exports);
38
43
  __exportStar(require("./custom/web/url-metadata-extractor.action"), exports);
39
44
  // Import Load functions to prevent tree shaking of @RegisterClass decorators
40
45
  const send_single_message_action_1 = require("./custom/communication/send-single-message.action");
46
+ const create_record_action_1 = require("./custom/crud/create-record.action");
47
+ const get_record_action_1 = require("./custom/crud/get-record.action");
48
+ const update_record_action_1 = require("./custom/crud/update-record.action");
49
+ const delete_record_action_1 = require("./custom/crud/delete-record.action");
41
50
  const get_weather_action_1 = require("./custom/demo/get-weather.action");
42
51
  const get_stock_price_action_1 = require("./custom/demo/get-stock-price.action");
43
52
  const calculate_expression_action_1 = require("./custom/demo/calculate-expression.action");
@@ -57,6 +66,10 @@ const url_metadata_extractor_action_1 = require("./custom/web/url-metadata-extra
57
66
  // Call all Load functions to ensure @RegisterClass decorators execute
58
67
  // This prevents tree shaking from removing the action classes
59
68
  (0, send_single_message_action_1.LoadSendSingleMessageAction)();
69
+ (0, create_record_action_1.LoadCreateRecordAction)();
70
+ (0, get_record_action_1.LoadGetRecordAction)();
71
+ (0, update_record_action_1.LoadUpdateRecordAction)();
72
+ (0, delete_record_action_1.LoadDeleteRecordAction)();
60
73
  (0, get_weather_action_1.LoadGetWeatherAction)();
61
74
  (0, get_stock_price_action_1.LoadGetStockPriceAction)();
62
75
  (0, calculate_expression_action_1.LoadCalculateExpressionAction)();
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"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AAC;AACnC,IAAA,+CAAuB,GAAE,CAAC;AAC1B,IAAA,sDAA0B,GAAE,CAAC;AAC7B,IAAA,oEAAiC,GAAE,CAAC;AACpC,IAAA,iCAAgB,GAAE,CAAC;AACnB,IAAA,uCAAmB,GAAE,CAAC;AACtB,IAAA,kDAAwB,GAAE,CAAC;AAC3B,IAAA,sDAA0B,GAAE,CAAC;AAC7B,IAAA,8DAA8B,GAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/core-actions",
3
- "version": "2.52.0",
3
+ "version": "2.54.0",
4
4
  "description": "Library of generated and custom actions for the core MemberJunction framework. This library is maintained by MemberJunction and includes actions for use within the framework itself.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,14 +19,14 @@
19
19
  "typescript": "^5.4.5"
20
20
  },
21
21
  "dependencies": {
22
- "@memberjunction/global": "2.52.0",
23
- "@memberjunction/core": "2.52.0",
24
- "@memberjunction/core-entities": "2.52.0",
25
- "@memberjunction/actions": "2.52.0",
26
- "@memberjunction/communication-engine": "2.52.0",
27
- "@memberjunction/external-change-detection": "2.52.0",
28
- "@memberjunction/ai-vector-sync": "2.52.0",
29
- "@memberjunction/content-autotagging": "2.52.0",
22
+ "@memberjunction/global": "2.54.0",
23
+ "@memberjunction/core": "2.54.0",
24
+ "@memberjunction/core-entities": "2.54.0",
25
+ "@memberjunction/actions": "2.54.0",
26
+ "@memberjunction/communication-engine": "2.54.0",
27
+ "@memberjunction/external-change-detection": "2.54.0",
28
+ "@memberjunction/ai-vector-sync": "2.54.0",
29
+ "@memberjunction/content-autotagging": "2.54.0",
30
30
  "axios": "^1.6.8"
31
31
  }
32
32
  }