@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
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# @memberjunction/database-designer-actions
|
|
2
|
+
|
|
3
|
+
## 5.31.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [fc8b9b8]
|
|
8
|
+
- Updated dependencies [cde4d2c]
|
|
9
|
+
- Updated dependencies [7ed7a4b]
|
|
10
|
+
- Updated dependencies [dfab537]
|
|
11
|
+
- Updated dependencies [60e7541]
|
|
12
|
+
- Updated dependencies [18be074]
|
|
13
|
+
- Updated dependencies [17b8087]
|
|
14
|
+
- Updated dependencies [6779c1e]
|
|
15
|
+
- Updated dependencies [de34786]
|
|
16
|
+
- Updated dependencies [5db36d9]
|
|
17
|
+
- @memberjunction/core-entities@5.31.0
|
|
18
|
+
- @memberjunction/actions-base@5.31.0
|
|
19
|
+
- @memberjunction/actions@5.31.0
|
|
20
|
+
- @memberjunction/core@5.31.0
|
|
21
|
+
- @memberjunction/global@5.31.0
|
|
22
|
+
- @memberjunction/schema-engine@5.31.0
|
|
23
|
+
- @memberjunction/database-designer-core@5.31.0
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module base-database-designer.action
|
|
3
|
+
* @description Abstract base for all Database Designer actions.
|
|
4
|
+
*
|
|
5
|
+
* Provides common parameter extraction, authorization checking, and result
|
|
6
|
+
* building so that each concrete action stays thin and focused. All the
|
|
7
|
+
* shared logic lives here; concrete actions only implement `InternalRunAction`.
|
|
8
|
+
*/
|
|
9
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
10
|
+
import type { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
11
|
+
import { UserInfo } from '@memberjunction/core';
|
|
12
|
+
import type { TableDefinition } from '@memberjunction/schema-engine';
|
|
13
|
+
import { DatabaseDesignerPipelineExecutor, type PipelineExecutionOptions, type PipelineExecutionResult } from '@memberjunction/database-designer-core';
|
|
14
|
+
export declare abstract class BaseDatabaseDesignerAction extends BaseAction {
|
|
15
|
+
/**
|
|
16
|
+
* Extract and parse the `TableDefinition` param (JSON object or string).
|
|
17
|
+
* Returns `{ error }` on missing/malformed input, `{ td }` on success.
|
|
18
|
+
*/
|
|
19
|
+
protected getTableDefinitionParam(params: RunActionParams): {
|
|
20
|
+
td?: TableDefinition;
|
|
21
|
+
error?: ActionResultSimple;
|
|
22
|
+
};
|
|
23
|
+
/** Extract the `ModificationType` param ('create' | 'alter'). Defaults to 'create'. */
|
|
24
|
+
protected getModificationTypeParam(params: RunActionParams): 'create' | 'alter';
|
|
25
|
+
/** Extract a boolean param by name with a fallback default. */
|
|
26
|
+
protected getBoolParam(params: RunActionParams, name: string, defaultValue: boolean): boolean;
|
|
27
|
+
/** Extract a string param by name, returning undefined when absent. */
|
|
28
|
+
protected getStringParam(params: RunActionParams, name: string): string | undefined;
|
|
29
|
+
/** Append an output param to the params array so callers can read results. */
|
|
30
|
+
protected addOutputParam(params: RunActionParams, name: string, value: unknown): void;
|
|
31
|
+
/**
|
|
32
|
+
* Check that the contextUser holds the authorization required for the
|
|
33
|
+
* requested operation type. Returns an error string on failure, null on success.
|
|
34
|
+
*/
|
|
35
|
+
protected checkAuthorization(tableDefinition: TableDefinition, modificationType: 'create' | 'alter', contextUser: UserInfo): Promise<string | null>;
|
|
36
|
+
/** Map operation to its minimum required authorization name. */
|
|
37
|
+
private resolveAuthorizationName;
|
|
38
|
+
/** Build PipelineExecutionOptions from action params. */
|
|
39
|
+
protected buildPipelineOptions(params: RunActionParams, source: string): PipelineExecutionOptions;
|
|
40
|
+
/**
|
|
41
|
+
* Map a PipelineExecutionResult to ActionResultSimple and populate output
|
|
42
|
+
* params so workflow engines can read EntityID, EntityName, etc.
|
|
43
|
+
*/
|
|
44
|
+
protected buildPipelineResult(execResult: PipelineExecutionResult, params: RunActionParams): ActionResultSimple;
|
|
45
|
+
/** Common error handler for unexpected exceptions. */
|
|
46
|
+
protected handleUnexpected(error: unknown, operation: string): ActionResultSimple;
|
|
47
|
+
private findParam;
|
|
48
|
+
private tryParse;
|
|
49
|
+
private missing;
|
|
50
|
+
}
|
|
51
|
+
export { DatabaseDesignerPipelineExecutor };
|
|
52
|
+
//# sourceMappingURL=base-database-designer.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-database-designer.action.d.ts","sourceRoot":"","sources":["../../src/actions/base-database-designer.action.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACxF,OAAO,EAAoC,QAAQ,EAAY,MAAM,sBAAsB,CAAC;AAC5F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EACH,gCAAgC,EAChC,KAAK,wBAAwB,EAG7B,KAAK,uBAAuB,EAC/B,MAAM,wCAAwC,CAAC;AAIhD,8BAAsB,0BAA2B,SAAQ,UAAU;IAI/D;;;OAGG;IACH,SAAS,CAAC,uBAAuB,CAC7B,MAAM,EAAE,eAAe,GACxB;QAAE,EAAE,CAAC,EAAE,eAAe,CAAC;QAAC,KAAK,CAAC,EAAE,kBAAkB,CAAA;KAAE;IAuBvD,uFAAuF;IACvF,SAAS,CAAC,wBAAwB,CAAC,MAAM,EAAE,eAAe,GAAG,QAAQ,GAAG,OAAO;IAK/E,+DAA+D;IAC/D,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO;IAS7F,uEAAuE;IACvE,SAAS,CAAC,cAAc,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAOnF,8EAA8E;IAC9E,SAAS,CAAC,cAAc,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAMrF;;;OAGG;cACa,kBAAkB,CAC9B,eAAe,EAAE,eAAe,EAChC,gBAAgB,EAAE,QAAQ,GAAG,OAAO,EACpC,WAAW,EAAE,QAAQ,GACtB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAiBzB,gEAAgE;IAChE,OAAO,CAAC,wBAAwB;IAchC,yDAAyD;IACzD,SAAS,CAAC,oBAAoB,CAC1B,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,MAAM,GACf,wBAAwB;IAU3B;;;OAGG;IACH,SAAS,CAAC,mBAAmB,CACzB,UAAU,EAAE,uBAAuB,EACnC,MAAM,EAAE,eAAe,GACxB,kBAAkB;IAsBrB,sDAAsD;IACtD,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,kBAAkB;IAYjF,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,QAAQ;IAQhB,OAAO,CAAC,OAAO;CAOlB;AAID,OAAO,EAAE,gCAAgC,EAAE,CAAC"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module base-database-designer.action
|
|
3
|
+
* @description Abstract base for all Database Designer actions.
|
|
4
|
+
*
|
|
5
|
+
* Provides common parameter extraction, authorization checking, and result
|
|
6
|
+
* building so that each concrete action stays thin and focused. All the
|
|
7
|
+
* shared logic lives here; concrete actions only implement `InternalRunAction`.
|
|
8
|
+
*/
|
|
9
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
10
|
+
import { AuthorizationEvaluator, Metadata, LogError } from '@memberjunction/core';
|
|
11
|
+
import { DatabaseDesignerPipelineExecutor, AUTHORIZATIONS, UDT_SCHEMA_NAME, } from '@memberjunction/database-designer-core';
|
|
12
|
+
// ─── Public API ───────────────────────────────────────────────────────────────
|
|
13
|
+
export class BaseDatabaseDesignerAction extends BaseAction {
|
|
14
|
+
// ─── Param extraction ────────────────────────────────────────────────
|
|
15
|
+
/**
|
|
16
|
+
* Extract and parse the `TableDefinition` param (JSON object or string).
|
|
17
|
+
* Returns `{ error }` on missing/malformed input, `{ td }` on success.
|
|
18
|
+
*/
|
|
19
|
+
getTableDefinitionParam(params) {
|
|
20
|
+
const param = this.findParam(params, 'TableDefinition');
|
|
21
|
+
if (!param?.Value) {
|
|
22
|
+
return {
|
|
23
|
+
error: this.missing('TableDefinition', 'A complete TableDefinition object is required.'),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const raw = param.Value;
|
|
27
|
+
const td = typeof raw === 'string' ? this.tryParse(raw) : raw;
|
|
28
|
+
if (!td || typeof td !== 'object') {
|
|
29
|
+
return {
|
|
30
|
+
error: {
|
|
31
|
+
Success: false,
|
|
32
|
+
ResultCode: 'INVALID_TABLE_DEFINITION',
|
|
33
|
+
Message: 'TableDefinition must be a valid JSON object.',
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return { td: td };
|
|
38
|
+
}
|
|
39
|
+
/** Extract the `ModificationType` param ('create' | 'alter'). Defaults to 'create'. */
|
|
40
|
+
getModificationTypeParam(params) {
|
|
41
|
+
const v = this.findParam(params, 'ModificationType')?.Value;
|
|
42
|
+
return v === 'alter' ? 'alter' : 'create';
|
|
43
|
+
}
|
|
44
|
+
/** Extract a boolean param by name with a fallback default. */
|
|
45
|
+
getBoolParam(params, name, defaultValue) {
|
|
46
|
+
const v = this.findParam(params, name)?.Value;
|
|
47
|
+
if (v === undefined || v === null)
|
|
48
|
+
return defaultValue;
|
|
49
|
+
const s = String(v).trim().toLowerCase();
|
|
50
|
+
if (s === 'true' || s === '1' || s === 'yes')
|
|
51
|
+
return true;
|
|
52
|
+
if (s === 'false' || s === '0' || s === 'no')
|
|
53
|
+
return false;
|
|
54
|
+
return defaultValue;
|
|
55
|
+
}
|
|
56
|
+
/** Extract a string param by name, returning undefined when absent. */
|
|
57
|
+
getStringParam(params, name) {
|
|
58
|
+
const v = this.findParam(params, name)?.Value;
|
|
59
|
+
if (v === undefined || v === null)
|
|
60
|
+
return undefined;
|
|
61
|
+
const s = String(v).trim();
|
|
62
|
+
return s.length > 0 ? s : undefined;
|
|
63
|
+
}
|
|
64
|
+
/** Append an output param to the params array so callers can read results. */
|
|
65
|
+
addOutputParam(params, name, value) {
|
|
66
|
+
params.Params.push({ Name: name, Type: 'Output', Value: value });
|
|
67
|
+
}
|
|
68
|
+
// ─── Authorization ────────────────────────────────────────────────────
|
|
69
|
+
/**
|
|
70
|
+
* Check that the contextUser holds the authorization required for the
|
|
71
|
+
* requested operation type. Returns an error string on failure, null on success.
|
|
72
|
+
*/
|
|
73
|
+
async checkAuthorization(tableDefinition, modificationType, contextUser) {
|
|
74
|
+
const authName = this.resolveAuthorizationName(tableDefinition, modificationType);
|
|
75
|
+
const md = new Metadata(); // global-provider-ok: MJAPI server-side, single-provider deployment
|
|
76
|
+
const auth = md.Authorizations.find(a => a.Name === authName);
|
|
77
|
+
if (!auth) {
|
|
78
|
+
return `Authorization '${authName}' is not configured in this system.`;
|
|
79
|
+
}
|
|
80
|
+
const evaluator = new AuthorizationEvaluator();
|
|
81
|
+
if (!evaluator.UserCanExecuteWithAncestors(auth, contextUser, md.Authorizations)) {
|
|
82
|
+
return `User does not have the '${authName}' authorization required for this operation.`;
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
/** Map operation to its minimum required authorization name. */
|
|
87
|
+
resolveAuthorizationName(tableDefinition, modificationType) {
|
|
88
|
+
if (modificationType === 'alter') {
|
|
89
|
+
return AUTHORIZATIONS.MODIFY_OWN_ENTITIES;
|
|
90
|
+
}
|
|
91
|
+
return tableDefinition.SchemaName.toLowerCase() === UDT_SCHEMA_NAME.toLowerCase()
|
|
92
|
+
? AUTHORIZATIONS.CREATE_IN_UDT_SCHEMA
|
|
93
|
+
: AUTHORIZATIONS.CREATE_IN_CUSTOM_SCHEMA;
|
|
94
|
+
}
|
|
95
|
+
// ─── Pipeline options ─────────────────────────────────────────────────
|
|
96
|
+
/** Build PipelineExecutionOptions from action params. */
|
|
97
|
+
buildPipelineOptions(params, source) {
|
|
98
|
+
return {
|
|
99
|
+
SkipGitCommit: this.getBoolParam(params, 'SkipGitCommit', false),
|
|
100
|
+
SkipRestart: this.getBoolParam(params, 'SkipRestart', false),
|
|
101
|
+
Source: source,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
// ─── Result building ─────────────────────────────────────────────────
|
|
105
|
+
/**
|
|
106
|
+
* Map a PipelineExecutionResult to ActionResultSimple and populate output
|
|
107
|
+
* params so workflow engines can read EntityID, EntityName, etc.
|
|
108
|
+
*/
|
|
109
|
+
buildPipelineResult(execResult, params) {
|
|
110
|
+
if (execResult.Success) {
|
|
111
|
+
this.addOutputParam(params, 'EntityID', execResult.EntityID ?? null);
|
|
112
|
+
this.addOutputParam(params, 'EntityName', execResult.EntityName ?? null);
|
|
113
|
+
this.addOutputParam(params, 'SchemaName', execResult.SchemaName ?? null);
|
|
114
|
+
this.addOutputParam(params, 'TableName', execResult.TableName ?? null);
|
|
115
|
+
this.addOutputParam(params, 'PipelineSteps', execResult.PipelineSteps ?? []);
|
|
116
|
+
return {
|
|
117
|
+
Success: true,
|
|
118
|
+
ResultCode: 'SUCCESS',
|
|
119
|
+
Message: `Entity '${execResult.EntityName ?? execResult.TableName}' created/modified successfully.`,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
this.addOutputParam(params, 'PipelineSteps', execResult.PipelineSteps ?? []);
|
|
123
|
+
return {
|
|
124
|
+
Success: false,
|
|
125
|
+
ResultCode: 'PIPELINE_FAILED',
|
|
126
|
+
Message: execResult.ErrorMessage ?? 'Pipeline execution failed without an error message.',
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/** Common error handler for unexpected exceptions. */
|
|
130
|
+
handleUnexpected(error, operation) {
|
|
131
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
132
|
+
LogError(`DatabaseDesigner action '${operation}' threw: ${msg}`);
|
|
133
|
+
return {
|
|
134
|
+
Success: false,
|
|
135
|
+
ResultCode: 'UNEXPECTED_ERROR',
|
|
136
|
+
Message: `Unexpected error during ${operation}: ${msg}`,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
// ─── Private helpers ──────────────────────────────────────────────────
|
|
140
|
+
findParam(params, name) {
|
|
141
|
+
return params.Params.find(p => p.Name.trim().toLowerCase() === name.toLowerCase());
|
|
142
|
+
}
|
|
143
|
+
tryParse(raw) {
|
|
144
|
+
try {
|
|
145
|
+
return JSON.parse(raw);
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
missing(paramName, hint) {
|
|
152
|
+
return {
|
|
153
|
+
Success: false,
|
|
154
|
+
ResultCode: 'MISSING_PARAMETER',
|
|
155
|
+
Message: `Parameter '${paramName}' is required. ${hint}`,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// Re-export the shared executor so callers that import from this module can
|
|
160
|
+
// access it without an extra import — actions are the primary consumers.
|
|
161
|
+
export { DatabaseDesignerPipelineExecutor };
|
|
162
|
+
//# sourceMappingURL=base-database-designer.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-database-designer.action.js","sourceRoot":"","sources":["../../src/actions/base-database-designer.action.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAY,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAG5F,OAAO,EACH,gCAAgC,EAEhC,cAAc,EACd,eAAe,GAElB,MAAM,wCAAwC,CAAC;AAEhD,iF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AAC,MAAuB,EAAE,IAAY;QACnD,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CACrB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,CAC1D,CAAC;IACN,CAAC;IAEO,QAAQ,CAAC,GAAW;QACxB,IAAI,CAAC;YACD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QAAC,MAAM,CAAC;YACL,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IAEO,OAAO,CAAC,SAAiB,EAAE,IAAY;QAC3C,OAAO;YACH,OAAO,EAAE,KAAK;YACd,UAAU,EAAE,mBAAmB;YAC/B,OAAO,EAAE,cAAc,SAAS,kBAAkB,IAAI,EAAE;SAC3D,CAAC;IACN,CAAC;CACJ;AAED,4EAA4E;AAC5E,yEAAyE;AACzE,OAAO,EAAE,gCAAgC,EAAE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module create-entity.action
|
|
3
|
+
* @description Action that creates a new MemberJunction entity from a
|
|
4
|
+
* TableDefinition. Validates authorization then delegates to the shared RSU
|
|
5
|
+
* pipeline executor.
|
|
6
|
+
*
|
|
7
|
+
* Intended callers:
|
|
8
|
+
* - Agent Manager's Planning Designer sub-agent
|
|
9
|
+
* - Any agent with the 'Create in UDT Schema' or 'Create in Custom Schema' auth
|
|
10
|
+
* - Workflow engines / low-code builders
|
|
11
|
+
*
|
|
12
|
+
* This action does NOT run the full conversational Database Designer flow.
|
|
13
|
+
* Callers must supply a pre-formed TableDefinition.
|
|
14
|
+
*/
|
|
15
|
+
import type { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
16
|
+
import { BaseDatabaseDesignerAction } from './base-database-designer.action.js';
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new MemberJunction entity from a fully-formed `TableDefinition`.
|
|
19
|
+
*
|
|
20
|
+
* Input params:
|
|
21
|
+
* - `TableDefinition` (required) — JSON object conforming to the schema-engine
|
|
22
|
+
* `TableDefinition` interface.
|
|
23
|
+
* - `SkipGitCommit` (optional, default false) — skip creating a migration git commit.
|
|
24
|
+
* - `SkipRestart` (optional, default false) — skip restarting MJAPI after the pipeline.
|
|
25
|
+
*
|
|
26
|
+
* Output params written on success:
|
|
27
|
+
* - `EntityID` — MJ entity UUID.
|
|
28
|
+
* - `EntityName` — Human-readable entity name.
|
|
29
|
+
* - `SchemaName` — Database schema.
|
|
30
|
+
* - `TableName` — Physical table name.
|
|
31
|
+
* - `PipelineSteps` — Array of step summaries from RuntimeSchemaManager.
|
|
32
|
+
*/
|
|
33
|
+
export declare class CreateEntityAction extends BaseDatabaseDesignerAction {
|
|
34
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=create-entity.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-entity.action.d.ts","sourceRoot":"","sources":["../../src/actions/create-entity.action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAIxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAIhF;;;;;;;;;;;;;;;GAeG;AACH,qBACa,kBAAmB,SAAQ,0BAA0B;cAC9C,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAsB1F"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module create-entity.action
|
|
3
|
+
* @description Action that creates a new MemberJunction entity from a
|
|
4
|
+
* TableDefinition. Validates authorization then delegates to the shared RSU
|
|
5
|
+
* pipeline executor.
|
|
6
|
+
*
|
|
7
|
+
* Intended callers:
|
|
8
|
+
* - Agent Manager's Planning Designer sub-agent
|
|
9
|
+
* - Any agent with the 'Create in UDT Schema' or 'Create in Custom Schema' auth
|
|
10
|
+
* - Workflow engines / low-code builders
|
|
11
|
+
*
|
|
12
|
+
* This action does NOT run the full conversational Database Designer flow.
|
|
13
|
+
* Callers must supply a pre-formed TableDefinition.
|
|
14
|
+
*/
|
|
15
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
16
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
17
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
18
|
+
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;
|
|
19
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
20
|
+
};
|
|
21
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
22
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
23
|
+
import { DatabaseDesignerPipelineExecutor, UDT_SETTINGS } from '@memberjunction/database-designer-core';
|
|
24
|
+
import { BaseDatabaseDesignerAction } from './base-database-designer.action.js';
|
|
25
|
+
// ─── Registration ─────────────────────────────────────────────────────────────
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new MemberJunction entity from a fully-formed `TableDefinition`.
|
|
28
|
+
*
|
|
29
|
+
* Input params:
|
|
30
|
+
* - `TableDefinition` (required) — JSON object conforming to the schema-engine
|
|
31
|
+
* `TableDefinition` interface.
|
|
32
|
+
* - `SkipGitCommit` (optional, default false) — skip creating a migration git commit.
|
|
33
|
+
* - `SkipRestart` (optional, default false) — skip restarting MJAPI after the pipeline.
|
|
34
|
+
*
|
|
35
|
+
* Output params written on success:
|
|
36
|
+
* - `EntityID` — MJ entity UUID.
|
|
37
|
+
* - `EntityName` — Human-readable entity name.
|
|
38
|
+
* - `SchemaName` — Database schema.
|
|
39
|
+
* - `TableName` — Physical table name.
|
|
40
|
+
* - `PipelineSteps` — Array of step summaries from RuntimeSchemaManager.
|
|
41
|
+
*/
|
|
42
|
+
let CreateEntityAction = class CreateEntityAction extends BaseDatabaseDesignerAction {
|
|
43
|
+
async InternalRunAction(params) {
|
|
44
|
+
try {
|
|
45
|
+
const { td, error: tdError } = this.getTableDefinitionParam(params);
|
|
46
|
+
if (tdError)
|
|
47
|
+
return tdError;
|
|
48
|
+
const authError = await this.checkAuthorization(td, 'create', params.ContextUser);
|
|
49
|
+
if (authError) {
|
|
50
|
+
return { Success: false, ResultCode: 'UNAUTHORIZED', Message: authError };
|
|
51
|
+
}
|
|
52
|
+
const options = this.buildPipelineOptions(params, UDT_SETTINGS.SOURCE_DATABASE_DESIGNER);
|
|
53
|
+
const execResult = await DatabaseDesignerPipelineExecutor.CreateEntity(td, params.ContextUser, options);
|
|
54
|
+
return this.buildPipelineResult(execResult, params);
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
return this.handleUnexpected(err, 'Create Entity');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
CreateEntityAction = __decorate([
|
|
62
|
+
RegisterClass(BaseAction, 'Create Entity')
|
|
63
|
+
], CreateEntityAction);
|
|
64
|
+
export { CreateEntityAction };
|
|
65
|
+
//# sourceMappingURL=create-entity.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-entity.action.js","sourceRoot":"","sources":["../../src/actions/create-entity.action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;;;;;;;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD,OAAO,EAAE,gCAAgC,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAExG,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAEhF,iFAAiF;AAEjF;;;;;;;;;;;;;;;GAeG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,0BAA0B;IACpD,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,SAAS,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,EAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;YACnF,IAAI,SAAS,EAAE,CAAC;gBACZ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;YAC9E,CAAC;YAED,MAAM,OAAO,GAAG,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,YAAY,CAAC,wBAAwB,CAAC,CAAC;YACzF,MAAM,UAAU,GAAG,MAAM,gCAAgC,CAAC,YAAY,CAClE,EAAG,EACH,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;AAvBY,kBAAkB;IAD9B,aAAa,CAAC,UAAU,EAAE,eAAe,CAAC;GAC9B,kBAAkB,CAuB9B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module describe-entity.action
|
|
3
|
+
* @description Returns detailed column-level metadata for a given entity.
|
|
4
|
+
*
|
|
5
|
+
* Useful for agents that need to inspect an existing entity before deciding
|
|
6
|
+
* whether to modify it, or for display in the Database Designer UI.
|
|
7
|
+
*/
|
|
8
|
+
import type { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
9
|
+
import { BaseDatabaseDesignerAction } from './base-database-designer.action.js';
|
|
10
|
+
/**
|
|
11
|
+
* Describes a MemberJunction entity including all its columns.
|
|
12
|
+
*
|
|
13
|
+
* Input params — supply exactly one identifier:
|
|
14
|
+
* - `EntityID` — The entity UUID.
|
|
15
|
+
* - `EntityName` — The human-readable entity name (e.g. "Project Milestones").
|
|
16
|
+
* - `TableName` — The physical table name. Optionally combine with
|
|
17
|
+
* `SchemaName` to narrow by schema.
|
|
18
|
+
*
|
|
19
|
+
* Output params:
|
|
20
|
+
* - `EntityInfo` — Full EntityInfo object (see above) or null if not found.
|
|
21
|
+
*/
|
|
22
|
+
export declare class DescribeEntityAction extends BaseDatabaseDesignerAction {
|
|
23
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
24
|
+
/** Resolve the entity using whichever identifier the caller supplied. */
|
|
25
|
+
private findEntity;
|
|
26
|
+
/** Load column definitions for a given entity ID. */
|
|
27
|
+
private loadEntityColumns;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=describe-entity.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe-entity.action.d.ts","sourceRoot":"","sources":["../../src/actions/describe-entity.action.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAKxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAwBhF;;;;;;;;;;;GAWG;AACH,qBACa,oBAAqB,SAAQ,0BAA0B;cAChD,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAuCvF,yEAAyE;YAC3D,UAAU;IAkCxB,qDAAqD;YACvC,iBAAiB;CA+BlC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module describe-entity.action
|
|
3
|
+
* @description Returns detailed column-level metadata for a given entity.
|
|
4
|
+
*
|
|
5
|
+
* Useful for agents that need to inspect an existing entity before deciding
|
|
6
|
+
* whether to modify it, or for display in the Database Designer UI.
|
|
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 { escapeSqlLiteral } from '@memberjunction/database-designer-core';
|
|
18
|
+
import { BaseDatabaseDesignerAction } from './base-database-designer.action.js';
|
|
19
|
+
// ─── Registration ─────────────────────────────────────────────────────────────
|
|
20
|
+
/**
|
|
21
|
+
* Describes a MemberJunction entity including all its columns.
|
|
22
|
+
*
|
|
23
|
+
* Input params — supply exactly one identifier:
|
|
24
|
+
* - `EntityID` — The entity UUID.
|
|
25
|
+
* - `EntityName` — The human-readable entity name (e.g. "Project Milestones").
|
|
26
|
+
* - `TableName` — The physical table name. Optionally combine with
|
|
27
|
+
* `SchemaName` to narrow by schema.
|
|
28
|
+
*
|
|
29
|
+
* Output params:
|
|
30
|
+
* - `EntityInfo` — Full EntityInfo object (see above) or null if not found.
|
|
31
|
+
*/
|
|
32
|
+
let DescribeEntityAction = class DescribeEntityAction extends BaseDatabaseDesignerAction {
|
|
33
|
+
async InternalRunAction(params) {
|
|
34
|
+
try {
|
|
35
|
+
const entityID = this.getStringParam(params, 'EntityID');
|
|
36
|
+
const entityName = this.getStringParam(params, 'EntityName');
|
|
37
|
+
const tableName = this.getStringParam(params, 'TableName');
|
|
38
|
+
const schemaName = this.getStringParam(params, 'SchemaName');
|
|
39
|
+
if (!entityID && !entityName && !tableName) {
|
|
40
|
+
return {
|
|
41
|
+
Success: false,
|
|
42
|
+
ResultCode: 'MISSING_PARAMETER',
|
|
43
|
+
Message: 'Provide at least one of: EntityID, EntityName, or TableName.',
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const entityInfo = await this.findEntity(entityID, entityName, tableName, schemaName, params);
|
|
47
|
+
if (!entityInfo) {
|
|
48
|
+
this.addOutputParam(params, 'EntityInfo', null);
|
|
49
|
+
return {
|
|
50
|
+
Success: false,
|
|
51
|
+
ResultCode: 'ENTITY_NOT_FOUND',
|
|
52
|
+
Message: 'No entity was found matching the provided identifiers.',
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
this.addOutputParam(params, 'EntityInfo', entityInfo);
|
|
56
|
+
return {
|
|
57
|
+
Success: true,
|
|
58
|
+
ResultCode: 'SUCCESS',
|
|
59
|
+
Message: `Entity '${entityInfo.EntityName}' found with ${entityInfo.Columns.length} column(s).`,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
return this.handleUnexpected(err, 'Describe Entity');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// ─── Private helpers ──────────────────────────────────────────────────
|
|
67
|
+
/** Resolve the entity using whichever identifier the caller supplied. */
|
|
68
|
+
async findEntity(entityID, entityName, tableName, schemaName, params) {
|
|
69
|
+
const md = new Metadata(); // global-provider-ok: MJAPI server-side, single-provider deployment
|
|
70
|
+
// Fast path: look up by ID or name in the in-memory metadata cache.
|
|
71
|
+
let entity = entityID
|
|
72
|
+
? md.Entities.find(e => UUIDsEqual(e.ID, entityID))
|
|
73
|
+
: entityName
|
|
74
|
+
? md.Entities.find(e => e.Name.toLowerCase() === entityName.toLowerCase())
|
|
75
|
+
: md.Entities.find(e => e.BaseTable.toLowerCase() === (tableName ?? '').toLowerCase() &&
|
|
76
|
+
(!schemaName || (e.SchemaName ?? '').toLowerCase() === schemaName.toLowerCase()));
|
|
77
|
+
if (!entity)
|
|
78
|
+
return null;
|
|
79
|
+
// Load columns from Entity Fields via RunView.
|
|
80
|
+
const columns = await this.loadEntityColumns(entity.ID, params);
|
|
81
|
+
return {
|
|
82
|
+
EntityID: entity.ID,
|
|
83
|
+
EntityName: entity.Name,
|
|
84
|
+
SchemaName: entity.SchemaName ?? '',
|
|
85
|
+
TableName: entity.BaseTable ?? '',
|
|
86
|
+
Description: entity.Description ?? null,
|
|
87
|
+
Columns: columns,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** Load column definitions for a given entity ID. */
|
|
91
|
+
async loadEntityColumns(entityID, params) {
|
|
92
|
+
const rv = new RunView();
|
|
93
|
+
const result = await rv.RunView({
|
|
94
|
+
EntityName: 'MJ: Entity Fields',
|
|
95
|
+
ExtraFilter: `EntityID = '${escapeSqlLiteral(entityID)}'`,
|
|
96
|
+
Fields: ['Name', 'Type', 'AllowsNull', 'MaxLength', 'Description', 'IsRequired'],
|
|
97
|
+
OrderBy: 'Sequence ASC',
|
|
98
|
+
ResultType: 'simple',
|
|
99
|
+
}, params.ContextUser);
|
|
100
|
+
if (!result.Success)
|
|
101
|
+
return [];
|
|
102
|
+
return result.Results.map(f => ({
|
|
103
|
+
Name: f.Name,
|
|
104
|
+
Type: f.Type,
|
|
105
|
+
IsNullable: f.AllowsNull,
|
|
106
|
+
MaxLength: f.MaxLength,
|
|
107
|
+
Description: f.Description,
|
|
108
|
+
IsRequired: f.IsRequired,
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
DescribeEntityAction = __decorate([
|
|
113
|
+
RegisterClass(BaseAction, 'Describe Entity')
|
|
114
|
+
], DescribeEntityAction);
|
|
115
|
+
export { DescribeEntityAction };
|
|
116
|
+
//# sourceMappingURL=describe-entity.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe-entity.action.js","sourceRoot":"","sources":["../../src/actions/describe-entity.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,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAE1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAsBhF,iFAAiF;AAEjF;;;;;;;;;;;GAWG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,0BAA0B;IACtD,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YACzD,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;YAC7D,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YAC3D,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;YAE7D,IAAI,CAAC,QAAQ,IAAI,CAAC,UAAU,IAAI,CAAC,SAAS,EAAE,CAAC;gBACzC,OAAO;oBACH,OAAO,EAAE,KAAK;oBACd,UAAU,EAAE,mBAAmB;oBAC/B,OAAO,EAAE,8DAA8D;iBAC1E,CAAC;YACN,CAAC;YAED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AAC,MAAM,CAAC,OAAO;YAAE,OAAO,EAAE,CAAC;QAE/B,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YAC5B,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,UAAU,EAAE,CAAC,CAAC,UAAU;YACxB,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,WAAW,EAAE,CAAC,CAAC,WAAW;YAC1B,UAAU,EAAE,CAAC,CAAC,UAAU;SAC3B,CAAC,CAAC,CAAC;IACR,CAAC;CACJ,CAAA;AA3GY,oBAAoB;IADhC,aAAa,CAAC,UAAU,EAAE,iBAAiB,CAAC;GAChC,oBAAoB,CA2GhC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
import type { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
9
|
+
import { BaseDatabaseDesignerAction } from './base-database-designer.action.js';
|
|
10
|
+
/**
|
|
11
|
+
* Lists all entities created by the current user via the Database Designer.
|
|
12
|
+
*
|
|
13
|
+
* Input params: none — uses `ContextUser` for ownership lookup.
|
|
14
|
+
*
|
|
15
|
+
* Output params:
|
|
16
|
+
* - `Entities` — Array of EntitySummary objects.
|
|
17
|
+
* - `EntityCount` — Total number of entities owned by this user.
|
|
18
|
+
*/
|
|
19
|
+
export declare class ListMyEntitiesAction extends BaseDatabaseDesignerAction {
|
|
20
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
21
|
+
/** Query Entity Settings for ownership records, then enrich from metadata. */
|
|
22
|
+
private loadUserEntities;
|
|
23
|
+
/** Look up entity metadata for a list of entity IDs. */
|
|
24
|
+
private buildEntitySummaries;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=list-entities.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-entities.action.d.ts","sourceRoot":"","sources":["../../src/actions/list-entities.action.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAKxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAchF;;;;;;;;GAQG;AACH,qBACa,oBAAqB,SAAQ,0BAA0B;cAChD,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA4BvF,8EAA8E;YAChE,gBAAgB;IAoB9B,wDAAwD;IACxD,OAAO,CAAC,oBAAoB;CAmB/B"}
|