@memberjunction/database-designer-actions 0.0.1 → 5.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +4 -0
- package/CHANGELOG.md +23 -0
- package/dist/actions/base-database-designer.action.d.ts +52 -0
- package/dist/actions/base-database-designer.action.d.ts.map +1 -0
- package/dist/actions/base-database-designer.action.js +162 -0
- package/dist/actions/base-database-designer.action.js.map +1 -0
- package/dist/actions/create-entity.action.d.ts +36 -0
- package/dist/actions/create-entity.action.d.ts.map +1 -0
- package/dist/actions/create-entity.action.js +65 -0
- package/dist/actions/create-entity.action.js.map +1 -0
- package/dist/actions/describe-entity.action.d.ts +29 -0
- package/dist/actions/describe-entity.action.d.ts.map +1 -0
- package/dist/actions/describe-entity.action.js +116 -0
- package/dist/actions/describe-entity.action.js.map +1 -0
- package/dist/actions/list-entities.action.d.ts +26 -0
- package/dist/actions/list-entities.action.d.ts.map +1 -0
- package/dist/actions/list-entities.action.js +91 -0
- package/dist/actions/list-entities.action.js.map +1 -0
- package/dist/actions/modify-entity.action.d.ts +28 -0
- package/dist/actions/modify-entity.action.d.ts.map +1 -0
- package/dist/actions/modify-entity.action.js +65 -0
- package/dist/actions/modify-entity.action.js.map +1 -0
- package/dist/actions/validate-entity-schema.action.d.ts +38 -0
- package/dist/actions/validate-entity-schema.action.d.ts.map +1 -0
- package/dist/actions/validate-entity-schema.action.js +85 -0
- package/dist/actions/validate-entity-schema.action.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/package.json +32 -7
- package/src/__tests__/validate-entity-schema.action.test.ts +243 -0
- package/src/actions/base-database-designer.action.ts +210 -0
- package/src/actions/create-entity.action.ts +66 -0
- package/src/actions/describe-entity.action.ts +160 -0
- package/src/actions/list-entities.action.ts +110 -0
- package/src/actions/modify-entity.action.ts +75 -0
- package/src/actions/validate-entity-schema.action.ts +89 -0
- package/src/index.ts +15 -0
- package/tsconfig.json +16 -0
- package/vitest.config.ts +8 -0
- package/README.md +0 -45
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module list-entities.action
|
|
3
|
+
* @description Returns a summary list of entities created via the Database Designer.
|
|
4
|
+
*
|
|
5
|
+
* Queries MJ: Entity Settings for records with `MJ:UDT:Owner = contextUser.ID`
|
|
6
|
+
* then joins with Entities metadata to build a human-readable summary.
|
|
7
|
+
*/
|
|
8
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
9
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
11
|
+
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;
|
|
12
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
13
|
+
};
|
|
14
|
+
import { RegisterClass, UUIDsEqual } from '@memberjunction/global';
|
|
15
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
16
|
+
import { RunView, Metadata } from '@memberjunction/core';
|
|
17
|
+
import { UDT_SETTINGS, escapeSqlLiteral } from '@memberjunction/database-designer-core';
|
|
18
|
+
import { BaseDatabaseDesignerAction } from './base-database-designer.action.js';
|
|
19
|
+
// ─── Registration ─────────────────────────────────────────────────────────────
|
|
20
|
+
/**
|
|
21
|
+
* Lists all entities created by the current user via the Database Designer.
|
|
22
|
+
*
|
|
23
|
+
* Input params: none — uses `ContextUser` for ownership lookup.
|
|
24
|
+
*
|
|
25
|
+
* Output params:
|
|
26
|
+
* - `Entities` — Array of EntitySummary objects.
|
|
27
|
+
* - `EntityCount` — Total number of entities owned by this user.
|
|
28
|
+
*/
|
|
29
|
+
let ListMyEntitiesAction = class ListMyEntitiesAction extends BaseDatabaseDesignerAction {
|
|
30
|
+
async InternalRunAction(params) {
|
|
31
|
+
try {
|
|
32
|
+
const userID = params.ContextUser?.ID;
|
|
33
|
+
if (!userID) {
|
|
34
|
+
return {
|
|
35
|
+
Success: false,
|
|
36
|
+
ResultCode: 'NO_USER_CONTEXT',
|
|
37
|
+
Message: 'ContextUser is required to list owned entities.',
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const entities = await this.loadUserEntities(userID, params);
|
|
41
|
+
this.addOutputParam(params, 'Entities', entities);
|
|
42
|
+
this.addOutputParam(params, 'EntityCount', entities.length);
|
|
43
|
+
return {
|
|
44
|
+
Success: true,
|
|
45
|
+
ResultCode: 'SUCCESS',
|
|
46
|
+
Message: `Found ${entities.length} entity${entities.length === 1 ? '' : 'ies'} created by this user.`,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
return this.handleUnexpected(err, 'List My Entities');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// ─── Private helpers ──────────────────────────────────────────────────
|
|
54
|
+
/** Query Entity Settings for ownership records, then enrich from metadata. */
|
|
55
|
+
async loadUserEntities(userID, params) {
|
|
56
|
+
const rv = new RunView();
|
|
57
|
+
const settingsResult = await rv.RunView({
|
|
58
|
+
EntityName: 'MJ: Entity Settings',
|
|
59
|
+
ExtraFilter: `Name = '${UDT_SETTINGS.OWNER_KEY}' AND Value = '${escapeSqlLiteral(userID)}'`,
|
|
60
|
+
Fields: ['EntityID'],
|
|
61
|
+
ResultType: 'simple',
|
|
62
|
+
}, params.ContextUser);
|
|
63
|
+
if (!settingsResult.Success || settingsResult.Results.length === 0) {
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
const entityIDs = settingsResult.Results.map(r => r.EntityID);
|
|
67
|
+
return this.buildEntitySummaries(entityIDs, params.ContextUser);
|
|
68
|
+
}
|
|
69
|
+
/** Look up entity metadata for a list of entity IDs. */
|
|
70
|
+
buildEntitySummaries(entityIDs, contextUser) {
|
|
71
|
+
const md = new Metadata(); // global-provider-ok: MJAPI server-side, single-provider deployment
|
|
72
|
+
return entityIDs.reduce((acc, id) => {
|
|
73
|
+
const info = md.Entities.find(e => UUIDsEqual(e.ID, id));
|
|
74
|
+
if (info) {
|
|
75
|
+
acc.push({
|
|
76
|
+
EntityID: info.ID,
|
|
77
|
+
EntityName: info.Name,
|
|
78
|
+
SchemaName: info.SchemaName ?? '',
|
|
79
|
+
TableName: info.BaseTable ?? '',
|
|
80
|
+
Description: info.Description ?? null,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return acc;
|
|
84
|
+
}, []);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
ListMyEntitiesAction = __decorate([
|
|
88
|
+
RegisterClass(BaseAction, 'List My Entities')
|
|
89
|
+
], ListMyEntitiesAction);
|
|
90
|
+
export { ListMyEntitiesAction };
|
|
91
|
+
//# sourceMappingURL=list-entities.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-entities.action.js","sourceRoot":"","sources":["../../src/actions/list-entities.action.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;;;;;;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAY,MAAM,sBAAsB,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAExF,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAYhF,iFAAiF;AAEjF;;;;;;;;GAQG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,0BAA0B;IACtD,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,MAAM,MAAM,GAAG,MA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* based on a new `TableDefinition` (desired state).
|
|
5
|
+
*
|
|
6
|
+
* Execution path:
|
|
7
|
+
* 1. Extract and validate params
|
|
8
|
+
* 2. Authorization check
|
|
9
|
+
* 3. Load existing table info via DatabaseDesignerPipelineExecutor.LoadExistingTableInfo
|
|
10
|
+
* 4. Delegate to DatabaseDesignerPipelineExecutor.ModifyEntity
|
|
11
|
+
*/
|
|
12
|
+
import type { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
13
|
+
import { BaseDatabaseDesignerAction } from './base-database-designer.action.js';
|
|
14
|
+
/**
|
|
15
|
+
* Applies ALTER TABLE changes to an existing MemberJunction entity.
|
|
16
|
+
*
|
|
17
|
+
* Input params:
|
|
18
|
+
* - `TableDefinition` (required) — desired table state as a JSON object.
|
|
19
|
+
* - `SkipGitCommit` (optional, default false)
|
|
20
|
+
* - `SkipRestart` (optional, default false)
|
|
21
|
+
*
|
|
22
|
+
* Output params written on success:
|
|
23
|
+
* - `EntityID`, `EntityName`, `SchemaName`, `TableName`, `PipelineSteps`
|
|
24
|
+
*/
|
|
25
|
+
export declare class ModifyEntityAction extends BaseDatabaseDesignerAction {
|
|
26
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=modify-entity.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modify-entity.action.d.ts","sourceRoot":"","sources":["../../src/actions/modify-entity.action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAOxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAIhF;;;;;;;;;;GAUG;AACH,qBACa,kBAAmB,SAAQ,0BAA0B;cAC9C,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAoC1F"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module modify-entity.action
|
|
3
|
+
* @description Action that applies ALTER TABLE changes to an existing MJ entity
|
|
4
|
+
* based on a new `TableDefinition` (desired state).
|
|
5
|
+
*
|
|
6
|
+
* Execution path:
|
|
7
|
+
* 1. Extract and validate params
|
|
8
|
+
* 2. Authorization check
|
|
9
|
+
* 3. Load existing table info via DatabaseDesignerPipelineExecutor.LoadExistingTableInfo
|
|
10
|
+
* 4. Delegate to DatabaseDesignerPipelineExecutor.ModifyEntity
|
|
11
|
+
*/
|
|
12
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
13
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
14
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
15
|
+
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;
|
|
16
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
17
|
+
};
|
|
18
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
19
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
20
|
+
import { DatabaseDesignerPipelineExecutor, UDT_SETTINGS, } from '@memberjunction/database-designer-core';
|
|
21
|
+
import { BaseDatabaseDesignerAction } from './base-database-designer.action.js';
|
|
22
|
+
// ─── Registration ─────────────────────────────────────────────────────────────
|
|
23
|
+
/**
|
|
24
|
+
* Applies ALTER TABLE changes to an existing MemberJunction entity.
|
|
25
|
+
*
|
|
26
|
+
* Input params:
|
|
27
|
+
* - `TableDefinition` (required) — desired table state as a JSON object.
|
|
28
|
+
* - `SkipGitCommit` (optional, default false)
|
|
29
|
+
* - `SkipRestart` (optional, default false)
|
|
30
|
+
*
|
|
31
|
+
* Output params written on success:
|
|
32
|
+
* - `EntityID`, `EntityName`, `SchemaName`, `TableName`, `PipelineSteps`
|
|
33
|
+
*/
|
|
34
|
+
let ModifyEntityAction = class ModifyEntityAction extends BaseDatabaseDesignerAction {
|
|
35
|
+
async InternalRunAction(params) {
|
|
36
|
+
try {
|
|
37
|
+
const { td, error: tdError } = this.getTableDefinitionParam(params);
|
|
38
|
+
if (tdError)
|
|
39
|
+
return tdError;
|
|
40
|
+
const authError = await this.checkAuthorization(td, 'alter', params.ContextUser);
|
|
41
|
+
if (authError) {
|
|
42
|
+
return { Success: false, ResultCode: 'UNAUTHORIZED', Message: authError };
|
|
43
|
+
}
|
|
44
|
+
const existingInfo = await DatabaseDesignerPipelineExecutor.LoadExistingTableInfo(td.SchemaName, td.TableName, params.ContextUser);
|
|
45
|
+
if (!existingInfo) {
|
|
46
|
+
return {
|
|
47
|
+
Success: false,
|
|
48
|
+
ResultCode: 'ENTITY_NOT_FOUND',
|
|
49
|
+
Message: `Table '${td.SchemaName}.${td.TableName}' was not found in the database.`,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const options = this.buildPipelineOptions(params, UDT_SETTINGS.SOURCE_DATABASE_DESIGNER);
|
|
53
|
+
const execResult = await DatabaseDesignerPipelineExecutor.ModifyEntity(td, existingInfo, params.ContextUser, options);
|
|
54
|
+
return this.buildPipelineResult(execResult, params);
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
return this.handleUnexpected(err, 'Modify Entity');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
ModifyEntityAction = __decorate([
|
|
62
|
+
RegisterClass(BaseAction, 'Modify Entity')
|
|
63
|
+
], ModifyEntityAction);
|
|
64
|
+
export { ModifyEntityAction };
|
|
65
|
+
//# sourceMappingURL=modify-entity.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modify-entity.action.js","sourceRoot":"","sources":["../../src/actions/modify-entity.action.ts"],"names":[],"mappings":"AAAA;;;;;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,UAAU,GAAG,MAAM,gCAAgC,CAAC,YAAY,CAClE,EAAG,EACH,YAAY,EACZ,MAAM,CAAC,WAAW,EAClB,OAAO,CACV,CAAC;YAEF,OAAO,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACxD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;QACvD,CAAC;IACL,CAAC;CACJ,CAAA;AArCY,kBAAkB;IAD9B,aAAa,CAAC,UAAU,EAAE,eAAe,CAAC;GAC9B,kBAAkB,CAqC9B"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module validate-entity-schema.action
|
|
3
|
+
* @description Action that validates a `TableDefinition` against all Entity
|
|
4
|
+
* Designer pre-creation checks without executing the RSU pipeline.
|
|
5
|
+
*
|
|
6
|
+
* Intended callers:
|
|
7
|
+
* - Angular visual wizard (Step 4 — Review) pre-validates before the user
|
|
8
|
+
* submits to `CreateEntityAction` so errors surface early without a
|
|
9
|
+
* round-trip through the full pipeline.
|
|
10
|
+
* - Any workflow that needs a dry-run validation step before creation.
|
|
11
|
+
*
|
|
12
|
+
* This action runs the same `DatabaseSchemaValidationService` that the agent
|
|
13
|
+
* path (`DatabaseDesignerSchemaValidator`) uses, ensuring both paths are
|
|
14
|
+
* governed by identical rules.
|
|
15
|
+
*
|
|
16
|
+
* Input params:
|
|
17
|
+
* - `TableDefinition` (required) — JSON object conforming to the schema-engine
|
|
18
|
+
* `TableDefinition` interface.
|
|
19
|
+
* - `ModificationType` (optional, default 'create') — 'create' | 'alter'.
|
|
20
|
+
* Determines which authorization is checked before validation.
|
|
21
|
+
*
|
|
22
|
+
* Output params written on both success and validation failure:
|
|
23
|
+
* - `ValidationResult` — `{ Valid, Errors, Warnings }` — always present on
|
|
24
|
+
* `Success: true` so callers can inspect details without parsing `Message`.
|
|
25
|
+
*
|
|
26
|
+
* ResultCode values:
|
|
27
|
+
* - `VALIDATION_PASSED` — definition is valid, safe to proceed to CreateEntity.
|
|
28
|
+
* - `VALIDATION_FAILED` — definition has errors; inspect `ValidationResult.Errors`.
|
|
29
|
+
* - `UNAUTHORIZED` — contextUser lacks the required authorization.
|
|
30
|
+
* - `MISSING_PARAMETER` — required params were not provided.
|
|
31
|
+
* - `UNEXPECTED_ERROR` — unhandled exception (check server logs).
|
|
32
|
+
*/
|
|
33
|
+
import type { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
34
|
+
import { BaseDatabaseDesignerAction } from './base-database-designer.action.js';
|
|
35
|
+
export declare class ValidateEntitySchemaAction extends BaseDatabaseDesignerAction {
|
|
36
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=validate-entity-schema.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-entity-schema.action.d.ts","sourceRoot":"","sources":["../../src/actions/validate-entity-schema.action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAMxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAIhF,qBACa,0BAA2B,SAAQ,0BAA0B;cAEtD,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAwC1F"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module validate-entity-schema.action
|
|
3
|
+
* @description Action that validates a `TableDefinition` against all Entity
|
|
4
|
+
* Designer pre-creation checks without executing the RSU pipeline.
|
|
5
|
+
*
|
|
6
|
+
* Intended callers:
|
|
7
|
+
* - Angular visual wizard (Step 4 — Review) pre-validates before the user
|
|
8
|
+
* submits to `CreateEntityAction` so errors surface early without a
|
|
9
|
+
* round-trip through the full pipeline.
|
|
10
|
+
* - Any workflow that needs a dry-run validation step before creation.
|
|
11
|
+
*
|
|
12
|
+
* This action runs the same `DatabaseSchemaValidationService` that the agent
|
|
13
|
+
* path (`DatabaseDesignerSchemaValidator`) uses, ensuring both paths are
|
|
14
|
+
* governed by identical rules.
|
|
15
|
+
*
|
|
16
|
+
* Input params:
|
|
17
|
+
* - `TableDefinition` (required) — JSON object conforming to the schema-engine
|
|
18
|
+
* `TableDefinition` interface.
|
|
19
|
+
* - `ModificationType` (optional, default 'create') — 'create' | 'alter'.
|
|
20
|
+
* Determines which authorization is checked before validation.
|
|
21
|
+
*
|
|
22
|
+
* Output params written on both success and validation failure:
|
|
23
|
+
* - `ValidationResult` — `{ Valid, Errors, Warnings }` — always present on
|
|
24
|
+
* `Success: true` so callers can inspect details without parsing `Message`.
|
|
25
|
+
*
|
|
26
|
+
* ResultCode values:
|
|
27
|
+
* - `VALIDATION_PASSED` — definition is valid, safe to proceed to CreateEntity.
|
|
28
|
+
* - `VALIDATION_FAILED` — definition has errors; inspect `ValidationResult.Errors`.
|
|
29
|
+
* - `UNAUTHORIZED` — contextUser lacks the required authorization.
|
|
30
|
+
* - `MISSING_PARAMETER` — required params were not provided.
|
|
31
|
+
* - `UNEXPECTED_ERROR` — unhandled exception (check server logs).
|
|
32
|
+
*/
|
|
33
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
34
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
35
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
36
|
+
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;
|
|
37
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
38
|
+
};
|
|
39
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
40
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
41
|
+
import { DatabaseSchemaValidationService, } from '@memberjunction/database-designer-core';
|
|
42
|
+
import { BaseDatabaseDesignerAction } from './base-database-designer.action.js';
|
|
43
|
+
// ─── Registration ─────────────────────────────────────────────────────────────
|
|
44
|
+
let ValidateEntitySchemaAction = class ValidateEntitySchemaAction extends BaseDatabaseDesignerAction {
|
|
45
|
+
async InternalRunAction(params) {
|
|
46
|
+
try {
|
|
47
|
+
const { td, error: tdError } = this.getTableDefinitionParam(params);
|
|
48
|
+
if (tdError)
|
|
49
|
+
return tdError;
|
|
50
|
+
const modificationType = this.getModificationTypeParam(params);
|
|
51
|
+
// Authorization check: verify the user is allowed to perform this
|
|
52
|
+
// operation type before revealing any validation details.
|
|
53
|
+
const authError = await this.checkAuthorization(td, modificationType, params.ContextUser);
|
|
54
|
+
if (authError) {
|
|
55
|
+
return { Success: false, ResultCode: 'UNAUTHORIZED', Message: authError };
|
|
56
|
+
}
|
|
57
|
+
// Run all deterministic validation checks via the shared service.
|
|
58
|
+
const service = new DatabaseSchemaValidationService();
|
|
59
|
+
const validationResult = await service.validate(td, params.ContextUser, modificationType);
|
|
60
|
+
// Always write the structured result as an output param so callers
|
|
61
|
+
// can read Errors/Warnings without parsing the human-readable Message.
|
|
62
|
+
this.addOutputParam(params, 'ValidationResult', validationResult);
|
|
63
|
+
if (validationResult.Valid) {
|
|
64
|
+
return {
|
|
65
|
+
Success: true,
|
|
66
|
+
ResultCode: 'VALIDATION_PASSED',
|
|
67
|
+
Message: 'Validation passed. The entity definition is ready for creation.',
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
Success: true, // Action ran successfully — validation result is the output
|
|
72
|
+
ResultCode: 'VALIDATION_FAILED',
|
|
73
|
+
Message: `Validation failed: ${validationResult.Errors.join('; ')}`,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
return this.handleUnexpected(err, 'Validate Entity Schema');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
ValidateEntitySchemaAction = __decorate([
|
|
82
|
+
RegisterClass(BaseAction, 'Validate Entity Schema')
|
|
83
|
+
], ValidateEntitySchemaAction);
|
|
84
|
+
export { ValidateEntitySchemaAction };
|
|
85
|
+
//# sourceMappingURL=validate-entity-schema.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-entity-schema.action.js","sourceRoot":"","sources":["../../src/actions/validate-entity-schema.action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;;;;;;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD,OAAO,EACH,+BAA+B,GAClC,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAEhF,iFAAiF;AAG1E,IAAM,0BAA0B,GAAhC,MAAM,0BAA2B,SAAQ,0BAA0B;IAE5D,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;YACpE,IAAI,OAAO;gBAAE,OAAO,OAAO,CAAC;YAE5B,MAAM,gBAAgB,GAAG,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC;YAE/D,kEAAkE;YAClE,0DAA0D;YAC1D,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,EAAG,EAAE,gBAAgB,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;YAC3F,IAAI,SAAS,EAAE,CAAC;gBACZ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;YAC9E,CAAC;YAED,kEAAkE;YAClE,MAAM,OAAO,GAAG,IAAI,+BAA+B,EAAE,CAAC;YACtD,MAAM,gBAAgB,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,EAAG,EAAE,MAAM,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;YAE3F,mEAAmE;YACnE,uEAAuE;YACvE,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;YAElE,IAAI,gBAAgB,CAAC,KAAK,EAAE,CAAC;gBACzB,OAAO;oBACH,OAAO,EAAE,IAAI;oBACb,UAAU,EAAE,mBAAmB;oBAC/B,OAAO,EAAE,iEAAiE;iBAC7E,CAAC;YACN,CAAC;YAED,OAAO;gBACH,OAAO,EAAE,IAAI,EAAE,4DAA4D;gBAC3E,UAAU,EAAE,mBAAmB;gBAC/B,OAAO,EAAE,sBAAsB,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;aACtE,CAAC;QAEN,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,EAAE,wBAAwB,CAAC,CAAC;QAChE,CAAC;IACL,CAAC;CACJ,CAAA;AA1CY,0BAA0B;IADtC,aAAa,CAAC,UAAU,EAAE,wBAAwB,CAAC;GACvC,0BAA0B,CA0CtC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @memberjunction/database-designer-actions
|
|
3
|
+
* @description Database Designer action classes for use by AI agents,
|
|
4
|
+
* workflow engines, and low-code builders.
|
|
5
|
+
*
|
|
6
|
+
* Importing this module registers all action driver classes with the MJ
|
|
7
|
+
* ClassFactory so they are discoverable at runtime.
|
|
8
|
+
*/
|
|
9
|
+
export * from './actions/base-database-designer.action.js';
|
|
10
|
+
export * from './actions/create-entity.action.js';
|
|
11
|
+
export * from './actions/modify-entity.action.js';
|
|
12
|
+
export * from './actions/list-entities.action.js';
|
|
13
|
+
export * from './actions/describe-entity.action.js';
|
|
14
|
+
export * from './actions/validate-entity-schema.action.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,4CAA4C,CAAC;AAC3D,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,4CAA4C,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @memberjunction/database-designer-actions
|
|
3
|
+
* @description Database Designer action classes for use by AI agents,
|
|
4
|
+
* workflow engines, and low-code builders.
|
|
5
|
+
*
|
|
6
|
+
* Importing this module registers all action driver classes with the MJ
|
|
7
|
+
* ClassFactory so they are discoverable at runtime.
|
|
8
|
+
*/
|
|
9
|
+
export * from './actions/base-database-designer.action.js';
|
|
10
|
+
export * from './actions/create-entity.action.js';
|
|
11
|
+
export * from './actions/modify-entity.action.js';
|
|
12
|
+
export * from './actions/list-entities.action.js';
|
|
13
|
+
export * from './actions/describe-entity.action.js';
|
|
14
|
+
export * from './actions/validate-entity-schema.action.js';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,4CAA4C,CAAC;AAC3D,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,4CAA4C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/database-designer-actions",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "5.31.0",
|
|
5
|
+
"description": "Database Designer Actions — metadata-driven action layer for entity creation and modification",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc && tsc-alias -f",
|
|
10
|
+
"watch": "tsc -w",
|
|
11
|
+
"clean": "rimraf dist",
|
|
12
|
+
"test": "vitest run",
|
|
13
|
+
"test:watch": "vitest"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@memberjunction/actions": "5.31.0",
|
|
17
|
+
"@memberjunction/actions-base": "5.31.0",
|
|
18
|
+
"@memberjunction/core": "5.31.0",
|
|
19
|
+
"@memberjunction/core-entities": "5.31.0",
|
|
20
|
+
"@memberjunction/database-designer-core": "5.31.0",
|
|
21
|
+
"@memberjunction/global": "5.31.0",
|
|
22
|
+
"@memberjunction/schema-engine": "5.31.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^24.10.11",
|
|
26
|
+
"rimraf": "^6.1.2",
|
|
27
|
+
"tsc-alias": "^1.8.16",
|
|
28
|
+
"typescript": "^5.9.3",
|
|
29
|
+
"vitest": "^4.0.18"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/MemberJunction/MJ"
|
|
34
|
+
}
|
|
10
35
|
}
|