@memberjunction/core-actions 5.36.0 → 5.38.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/README.md +19 -1
- package/dist/custom/data/run-adhoc-query.action.d.ts +14 -1
- package/dist/custom/data/run-adhoc-query.action.d.ts.map +1 -1
- package/dist/custom/data/run-adhoc-query.action.js +27 -12
- package/dist/custom/data/run-adhoc-query.action.js.map +1 -1
- package/dist/custom/interactive-forms/_shared.d.ts +144 -0
- package/dist/custom/interactive-forms/_shared.d.ts.map +1 -0
- package/dist/custom/interactive-forms/_shared.js +300 -0
- package/dist/custom/interactive-forms/_shared.js.map +1 -0
- package/dist/custom/interactive-forms/activate-interactive-form-version.action.d.ts +31 -0
- package/dist/custom/interactive-forms/activate-interactive-form-version.action.d.ts.map +1 -0
- package/dist/custom/interactive-forms/activate-interactive-form-version.action.js +139 -0
- package/dist/custom/interactive-forms/activate-interactive-form-version.action.js.map +1 -0
- package/dist/custom/interactive-forms/create-interactive-form.action.d.ts +32 -0
- package/dist/custom/interactive-forms/create-interactive-form.action.d.ts.map +1 -0
- package/dist/custom/interactive-forms/create-interactive-form.action.js +162 -0
- package/dist/custom/interactive-forms/create-interactive-form.action.js.map +1 -0
- package/dist/custom/interactive-forms/get-active-form-for-entity.action.d.ts +46 -0
- package/dist/custom/interactive-forms/get-active-form-for-entity.action.d.ts.map +1 -0
- package/dist/custom/interactive-forms/get-active-form-for-entity.action.js +179 -0
- package/dist/custom/interactive-forms/get-active-form-for-entity.action.js.map +1 -0
- package/dist/custom/interactive-forms/get-default-form-scaffold.action.d.ts +32 -0
- package/dist/custom/interactive-forms/get-default-form-scaffold.action.d.ts.map +1 -0
- package/dist/custom/interactive-forms/get-default-form-scaffold.action.js +87 -0
- package/dist/custom/interactive-forms/get-default-form-scaffold.action.js.map +1 -0
- package/dist/custom/interactive-forms/get-entity-schema-for-form.action.d.ts +34 -0
- package/dist/custom/interactive-forms/get-entity-schema-for-form.action.d.ts.map +1 -0
- package/dist/custom/interactive-forms/get-entity-schema-for-form.action.js +103 -0
- package/dist/custom/interactive-forms/get-entity-schema-for-form.action.js.map +1 -0
- package/dist/custom/interactive-forms/index.d.ts +8 -0
- package/dist/custom/interactive-forms/index.d.ts.map +1 -0
- package/dist/custom/interactive-forms/index.js +8 -0
- package/dist/custom/interactive-forms/index.js.map +1 -0
- package/dist/custom/interactive-forms/modify-interactive-form.action.d.ts +54 -0
- package/dist/custom/interactive-forms/modify-interactive-form.action.d.ts.map +1 -0
- package/dist/custom/interactive-forms/modify-interactive-form.action.js +300 -0
- package/dist/custom/interactive-forms/modify-interactive-form.action.js.map +1 -0
- package/dist/custom/interactive-forms/revert-interactive-form.action.d.ts +39 -0
- package/dist/custom/interactive-forms/revert-interactive-form.action.d.ts.map +1 -0
- package/dist/custom/interactive-forms/revert-interactive-form.action.js +155 -0
- package/dist/custom/interactive-forms/revert-interactive-form.action.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +34 -32
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { BaseAction } from "@memberjunction/actions";
|
|
8
|
+
import { Metadata, LogError, RunView } from "@memberjunction/core";
|
|
9
|
+
import { RegisterClass } from "@memberjunction/global";
|
|
10
|
+
/**
|
|
11
|
+
* Read-only action that returns the currently-resolved interactive-form
|
|
12
|
+
* override (if any) for the (entity, user) pair plus the full list of
|
|
13
|
+
* applicable variants. Used by the Form Builder agent to decide between
|
|
14
|
+
* Create (no override exists) and Modify (an override already exists).
|
|
15
|
+
*
|
|
16
|
+
* Resolution mirrors {@link FormResolverService} on the client:
|
|
17
|
+
* - Scope precedence: User > Role > Global.
|
|
18
|
+
* - Within a tier: Priority DESC, then __mj_CreatedAt DESC.
|
|
19
|
+
* - Only Status='Active' rows are considered for the "active" pick. The
|
|
20
|
+
* full variants list includes 'Pending' rows so the agent can recognize
|
|
21
|
+
* an in-flight refinement loop and reuse the Pending row instead of
|
|
22
|
+
* spawning a new one.
|
|
23
|
+
*
|
|
24
|
+
* Output shape (JSON in `Message`, also surfaced as a `Result` output param):
|
|
25
|
+
* ```
|
|
26
|
+
* {
|
|
27
|
+
* "EntityName": "MJ: Applications",
|
|
28
|
+
* "Active": {
|
|
29
|
+
* "OverrideID": "...",
|
|
30
|
+
* "ComponentID": "...",
|
|
31
|
+
* "Scope": "User" | "Role" | "Global",
|
|
32
|
+
* "Priority": 0,
|
|
33
|
+
* "Status": "Active",
|
|
34
|
+
* "Spec": <ComponentSpec>,
|
|
35
|
+
* "ComponentName": "...",
|
|
36
|
+
* "ComponentVersion": "1.0.0",
|
|
37
|
+
* "VersionSequence": 1
|
|
38
|
+
* } | null,
|
|
39
|
+
* "Variants": [{ ...same shape... }, ...] // all applicable, all statuses
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* If no overrides exist, `Active` is null and `Variants` is empty —
|
|
44
|
+
* the calling agent should then call `Get Default Form Scaffold For Entity`
|
|
45
|
+
* and `Create Interactive Form`.
|
|
46
|
+
*/
|
|
47
|
+
let GetActiveFormForEntityAction = class GetActiveFormForEntityAction extends BaseAction {
|
|
48
|
+
async InternalRunAction(params) {
|
|
49
|
+
try {
|
|
50
|
+
const entityName = this.getStringParam(params, "EntityName");
|
|
51
|
+
if (!entityName) {
|
|
52
|
+
return failure("MISSING_PARAMETER", "Parameter 'EntityName' is required.");
|
|
53
|
+
}
|
|
54
|
+
const provider = params.Provider ?? Metadata.Provider;
|
|
55
|
+
if (!provider) {
|
|
56
|
+
return failure("NO_PROVIDER", "No metadata provider available.");
|
|
57
|
+
}
|
|
58
|
+
const user = params.ContextUser;
|
|
59
|
+
if (!user) {
|
|
60
|
+
return failure("NO_USER", "Action requires a ContextUser for scope resolution.");
|
|
61
|
+
}
|
|
62
|
+
const entity = provider.EntityByName(entityName);
|
|
63
|
+
if (!entity) {
|
|
64
|
+
return failure("ENTITY_NOT_FOUND", `Entity '${entityName}' is not registered with the active metadata provider.`);
|
|
65
|
+
}
|
|
66
|
+
// Pull all overrides applicable to this user — User-scoped to this user,
|
|
67
|
+
// Role-scoped if user has any of the listed roles, or Global. We let the
|
|
68
|
+
// database filter and we sort + select winner in code below.
|
|
69
|
+
const rv = RunView.FromMetadataProvider(provider);
|
|
70
|
+
const userRoles = Array.isArray(user.UserRoles)
|
|
71
|
+
? (user.UserRoles ?? []).map(r => r.RoleID).filter((x) => !!x)
|
|
72
|
+
: [];
|
|
73
|
+
const filterClauses = [
|
|
74
|
+
`EntityID='${entity.ID}'`,
|
|
75
|
+
`(Scope='Global' OR (Scope='User' AND UserID='${user.ID}')${userRoles.length ? ` OR (Scope='Role' AND RoleID IN (${userRoles.map(r => `'${r}'`).join(",")}))` : ''})`,
|
|
76
|
+
];
|
|
77
|
+
const overrideResult = await rv.RunView({
|
|
78
|
+
EntityName: "MJ: Entity Form Overrides",
|
|
79
|
+
ExtraFilter: filterClauses.join(' AND '),
|
|
80
|
+
Fields: ['ID', 'EntityID', 'ComponentID', 'Name', 'Description', 'Scope', 'UserID', 'RoleID', 'Priority', 'Status'],
|
|
81
|
+
ResultType: 'simple',
|
|
82
|
+
}, user);
|
|
83
|
+
if (!overrideResult.Success) {
|
|
84
|
+
return failure("QUERY_FAILED", `Override lookup failed: ${overrideResult.ErrorMessage ?? 'unknown error'}`);
|
|
85
|
+
}
|
|
86
|
+
const overrides = overrideResult.Results ?? [];
|
|
87
|
+
if (overrides.length === 0) {
|
|
88
|
+
const payload = { EntityName: entityName, Active: null, Variants: [] };
|
|
89
|
+
params.Params.push({ Name: "Result", Type: "Output", Value: payload });
|
|
90
|
+
return {
|
|
91
|
+
Success: true,
|
|
92
|
+
ResultCode: "SUCCESS",
|
|
93
|
+
Message: JSON.stringify(payload),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// Hydrate the referenced Components in one batch.
|
|
97
|
+
const componentIDs = Array.from(new Set(overrides.map(o => o.ComponentID))).filter(Boolean);
|
|
98
|
+
const componentsResult = await rv.RunView({
|
|
99
|
+
EntityName: "MJ: Components",
|
|
100
|
+
ExtraFilter: `ID IN (${componentIDs.map(id => `'${id}'`).join(",")})`,
|
|
101
|
+
Fields: ['ID', 'Name', 'Version', 'VersionSequence', 'Status', 'Specification'],
|
|
102
|
+
ResultType: 'simple',
|
|
103
|
+
}, user);
|
|
104
|
+
const componentByID = new Map((componentsResult.Results ?? []).map(c => [c.ID, c]));
|
|
105
|
+
const variants = overrides.map(o => {
|
|
106
|
+
const component = componentByID.get(o.ComponentID);
|
|
107
|
+
let spec = null;
|
|
108
|
+
if (component?.Specification) {
|
|
109
|
+
try {
|
|
110
|
+
spec = JSON.parse(component.Specification);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
// Bad spec JSON — we don't fail the whole action; we surface
|
|
114
|
+
// the variant without a parsed spec and let the caller decide.
|
|
115
|
+
spec = null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
OverrideID: o.ID,
|
|
120
|
+
ComponentID: o.ComponentID,
|
|
121
|
+
Scope: o.Scope,
|
|
122
|
+
Priority: o.Priority ?? 0,
|
|
123
|
+
Status: o.Status,
|
|
124
|
+
Name: o.Name,
|
|
125
|
+
Description: o.Description,
|
|
126
|
+
Spec: spec,
|
|
127
|
+
ComponentName: component?.Name ?? null,
|
|
128
|
+
ComponentVersion: component?.Version ?? null,
|
|
129
|
+
VersionSequence: component?.VersionSequence ?? null,
|
|
130
|
+
};
|
|
131
|
+
});
|
|
132
|
+
// Sort by scope tier (User=1, Role=2, Global=3), then Priority DESC.
|
|
133
|
+
// We don't have CreatedAt in the lightweight query — ties at this
|
|
134
|
+
// point default to the order the DB returned, which is usually
|
|
135
|
+
// creation order. The resolver service does the same.
|
|
136
|
+
variants.sort((a, b) => {
|
|
137
|
+
const tierA = a.Scope === 'User' ? 1 : a.Scope === 'Role' ? 2 : 3;
|
|
138
|
+
const tierB = b.Scope === 'User' ? 1 : b.Scope === 'Role' ? 2 : 3;
|
|
139
|
+
if (tierA !== tierB)
|
|
140
|
+
return tierA - tierB;
|
|
141
|
+
return (b.Priority ?? 0) - (a.Priority ?? 0);
|
|
142
|
+
});
|
|
143
|
+
const active = variants.find(v => v.Status === 'Active') ?? null;
|
|
144
|
+
const payload = { EntityName: entityName, Active: active, Variants: variants };
|
|
145
|
+
params.Params.push({ Name: "Result", Type: "Output", Value: payload });
|
|
146
|
+
return {
|
|
147
|
+
Success: true,
|
|
148
|
+
ResultCode: "SUCCESS",
|
|
149
|
+
Message: JSON.stringify(payload),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
154
|
+
LogError(`GetActiveFormForEntityAction: ${message}`);
|
|
155
|
+
return failure("UNEXPECTED_ERROR", message);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
getStringParam(params, name) {
|
|
159
|
+
const p = params.Params.find(x => x.Name?.trim().toLowerCase() === name.toLowerCase());
|
|
160
|
+
if (!p || p.Value == null)
|
|
161
|
+
return null;
|
|
162
|
+
const v = String(p.Value).trim();
|
|
163
|
+
return v.length > 0 ? v : null;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
GetActiveFormForEntityAction = __decorate([
|
|
167
|
+
RegisterClass(BaseAction, "__GetActiveFormForEntity")
|
|
168
|
+
], GetActiveFormForEntityAction);
|
|
169
|
+
export { GetActiveFormForEntityAction };
|
|
170
|
+
function failure(resultCode, message) {
|
|
171
|
+
return { Success: false, ResultCode: resultCode, Message: message };
|
|
172
|
+
}
|
|
173
|
+
/** Tree-shaking guard — called from src/index.ts. */
|
|
174
|
+
export function LoadGetActiveFormForEntityAction() {
|
|
175
|
+
if (false) {
|
|
176
|
+
const _ = GetActiveFormForEntityAction;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=get-active-form-for-entity.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-active-form-for-entity.action.js","sourceRoot":"","sources":["../../../src/custom/interactive-forms/get-active-form-for-entity.action.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEI,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,UAAU;IAE9C,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;YAC7D,IAAI,CAAC,UAAU,EAAE,CAAC;gBACd,OAAO,OAAO,CAAC,mBAAmB,EAAE,qCAAqC,CAAC,CAAC;YAC/E,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC;YACtD,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACZ,OAAO,OAAO,CAAC,aAAa,EAAE,iCAAiC,CAAC,CAAC;YACrE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@@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
|
|
2
|
+
import { BaseAction } from "@memberjunction/actions";
|
|
3
|
+
/**
|
|
4
|
+
* Read-only action that produces a working form-role `ComponentSpec`
|
|
5
|
+
* scaffolded from the entity's CodeGen metadata (Category /
|
|
6
|
+
* GeneratedFormSectionType / Sequence / FK relationships / value lists).
|
|
7
|
+
*
|
|
8
|
+
* **Why this exists.** Today the Form Builder agent writes JSX from
|
|
9
|
+
* scratch every time, producing inconsistent quality. Calling this action
|
|
10
|
+
* first gives the agent a known-good baseline (mirrors the default Angular
|
|
11
|
+
* form) that it can modify per user requirements instead of inventing a
|
|
12
|
+
* layout. Far fewer lint failures, dramatically better starting point.
|
|
13
|
+
*
|
|
14
|
+
* **Pure read.** No persistence. The returned spec is intended to be
|
|
15
|
+
* modified and then passed to {@link CreateInteractiveFormAction} or
|
|
16
|
+
* {@link ModifyInteractiveFormAction}.
|
|
17
|
+
*/
|
|
18
|
+
export declare class GetDefaultFormScaffoldForEntityAction extends BaseAction {
|
|
19
|
+
/**
|
|
20
|
+
* Required input:
|
|
21
|
+
* - `EntityName` (string) — fully-qualified entity name, e.g. "MJ: Applications".
|
|
22
|
+
*
|
|
23
|
+
* Output:
|
|
24
|
+
* - `Spec` parameter — the scaffolded `ComponentSpec` object (componentRole='form', location='embedded').
|
|
25
|
+
* - `Message` — the same object, stringified.
|
|
26
|
+
*/
|
|
27
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
28
|
+
private getStringParam;
|
|
29
|
+
}
|
|
30
|
+
/** Tree-shaking guard — called from src/index.ts. */
|
|
31
|
+
export declare function LoadGetDefaultFormScaffoldForEntityAction(): void;
|
|
32
|
+
//# sourceMappingURL=get-default-form-scaffold.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-default-form-scaffold.action.d.ts","sourceRoot":"","sources":["../../../src/custom/interactive-forms/get-default-form-scaffold.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD;;;;;;;;;;;;;;GAcG;AACH,qBACa,qCAAsC,SAAQ,UAAU;IAEjE;;;;;;;OAOG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAsCvF,OAAO,CAAC,cAAc;CAOzB;AAMD,qDAAqD;AACrD,wBAAgB,yCAAyC,IAAI,IAAI,CAIhE"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { BaseAction } from "@memberjunction/actions";
|
|
8
|
+
import { Metadata, LogError } from "@memberjunction/core";
|
|
9
|
+
import { RegisterClass } from "@memberjunction/global";
|
|
10
|
+
import { buildDefaultFormScaffold } from "@memberjunction/interactive-component-types/forms";
|
|
11
|
+
/**
|
|
12
|
+
* Read-only action that produces a working form-role `ComponentSpec`
|
|
13
|
+
* scaffolded from the entity's CodeGen metadata (Category /
|
|
14
|
+
* GeneratedFormSectionType / Sequence / FK relationships / value lists).
|
|
15
|
+
*
|
|
16
|
+
* **Why this exists.** Today the Form Builder agent writes JSX from
|
|
17
|
+
* scratch every time, producing inconsistent quality. Calling this action
|
|
18
|
+
* first gives the agent a known-good baseline (mirrors the default Angular
|
|
19
|
+
* form) that it can modify per user requirements instead of inventing a
|
|
20
|
+
* layout. Far fewer lint failures, dramatically better starting point.
|
|
21
|
+
*
|
|
22
|
+
* **Pure read.** No persistence. The returned spec is intended to be
|
|
23
|
+
* modified and then passed to {@link CreateInteractiveFormAction} or
|
|
24
|
+
* {@link ModifyInteractiveFormAction}.
|
|
25
|
+
*/
|
|
26
|
+
let GetDefaultFormScaffoldForEntityAction = class GetDefaultFormScaffoldForEntityAction extends BaseAction {
|
|
27
|
+
/**
|
|
28
|
+
* Required input:
|
|
29
|
+
* - `EntityName` (string) — fully-qualified entity name, e.g. "MJ: Applications".
|
|
30
|
+
*
|
|
31
|
+
* Output:
|
|
32
|
+
* - `Spec` parameter — the scaffolded `ComponentSpec` object (componentRole='form', location='embedded').
|
|
33
|
+
* - `Message` — the same object, stringified.
|
|
34
|
+
*/
|
|
35
|
+
async InternalRunAction(params) {
|
|
36
|
+
try {
|
|
37
|
+
const entityName = this.getStringParam(params, "EntityName");
|
|
38
|
+
if (!entityName) {
|
|
39
|
+
return failure("MISSING_PARAMETER", "Parameter 'EntityName' is required.");
|
|
40
|
+
}
|
|
41
|
+
const provider = params.Provider ?? Metadata.Provider;
|
|
42
|
+
if (!provider) {
|
|
43
|
+
return failure("NO_PROVIDER", "No metadata provider available.");
|
|
44
|
+
}
|
|
45
|
+
const spec = buildDefaultFormScaffold(entityName, provider);
|
|
46
|
+
if (!spec) {
|
|
47
|
+
return failure("ENTITY_NOT_FOUND", `Entity '${entityName}' is not registered with the active metadata provider.`);
|
|
48
|
+
}
|
|
49
|
+
params.Params.push({
|
|
50
|
+
Name: "Spec",
|
|
51
|
+
Type: "Output",
|
|
52
|
+
Value: spec,
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
Success: true,
|
|
56
|
+
ResultCode: "SUCCESS",
|
|
57
|
+
Message: JSON.stringify(spec),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
62
|
+
LogError(`GetDefaultFormScaffoldForEntityAction: ${message}`);
|
|
63
|
+
return failure("UNEXPECTED_ERROR", message);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
getStringParam(params, name) {
|
|
67
|
+
const p = params.Params.find(x => x.Name?.trim().toLowerCase() === name.toLowerCase());
|
|
68
|
+
if (!p || p.Value == null)
|
|
69
|
+
return null;
|
|
70
|
+
const v = String(p.Value).trim();
|
|
71
|
+
return v.length > 0 ? v : null;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
GetDefaultFormScaffoldForEntityAction = __decorate([
|
|
75
|
+
RegisterClass(BaseAction, "__GetDefaultFormScaffoldForEntity")
|
|
76
|
+
], GetDefaultFormScaffoldForEntityAction);
|
|
77
|
+
export { GetDefaultFormScaffoldForEntityAction };
|
|
78
|
+
function failure(resultCode, message) {
|
|
79
|
+
return { Success: false, ResultCode: resultCode, Message: message };
|
|
80
|
+
}
|
|
81
|
+
/** Tree-shaking guard — called from src/index.ts. */
|
|
82
|
+
export function LoadGetDefaultFormScaffoldForEntityAction() {
|
|
83
|
+
if (false) {
|
|
84
|
+
const _ = GetDefaultFormScaffoldForEntityAction;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=get-default-form-scaffold.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-default-form-scaffold.action.js","sourceRoot":"","sources":["../../../src/custom/interactive-forms/get-default-form-scaffold.action.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mDAAmD,CAAC;AAE7F;;;;;;;;;;;;;;GAcG;AAEI,IAAM,qCA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AEO,cAAc,CAAC,MAAuB,EAAE,IAAY;QACxD,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAC7B,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACzD,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC;QACvC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;QACjC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACnC,CAAC;CACJ,CAAA;AAvDY,qCAAqC;IADjD,aAAa,CAAC,UAAU,EAAE,mCAAmC,CAAC;GAClD,qCAAqC,CAuDjD;;AAED,SAAS,OAAO,CAAC,UAAkB,EAAE,OAAe;IAChD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AACxE,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,yCAAyC;IACrD,IAAI,KAAgB,EAAE,CAAC;QACnB,MAAM,CAAC,GAAY,qCAAqC,CAAC;IAC7D,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
|
|
2
|
+
import { BaseAction } from "@memberjunction/actions";
|
|
3
|
+
/**
|
|
4
|
+
* Read-only action consumed by the Form Builder agent to inspect an entity's
|
|
5
|
+
* curated form-relevant schema before generating a form Component.
|
|
6
|
+
*
|
|
7
|
+
* Returns the `CuratedFormSchema` shape: FK references resolved to
|
|
8
|
+
* `{entity, displayField}`, value-list fields annotated with `allowedValues`,
|
|
9
|
+
* and audit / virtual / computed fields stripped. See
|
|
10
|
+
* `@memberjunction/interactive-component-types/forms` for the type.
|
|
11
|
+
*
|
|
12
|
+
* Output is stringified JSON in `Message` (Action framework convention) and
|
|
13
|
+
* also surfaced as a `Schema` output parameter for callers that prefer
|
|
14
|
+
* structured access.
|
|
15
|
+
*/
|
|
16
|
+
export declare class GetEntitySchemaForFormAction extends BaseAction {
|
|
17
|
+
/**
|
|
18
|
+
* Required input:
|
|
19
|
+
* - `EntityName` (string) — fully-qualified entity name, e.g. "MJ: Applications".
|
|
20
|
+
*
|
|
21
|
+
* Output:
|
|
22
|
+
* - `Schema` parameter — the `CuratedFormSchema` object.
|
|
23
|
+
* - `Message` — the same object, stringified.
|
|
24
|
+
*/
|
|
25
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
26
|
+
/** Case-insensitive trim-tolerant fetch for the EntityName param. */
|
|
27
|
+
private getEntityNameParam;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Tree-shaking guard. Imported and called from src/index.ts so bundlers
|
|
31
|
+
* don't drop the action when no consumer references it by name.
|
|
32
|
+
*/
|
|
33
|
+
export declare function LoadGetEntitySchemaForFormAction(): void;
|
|
34
|
+
//# sourceMappingURL=get-entity-schema-for-form.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-entity-schema-for-form.action.d.ts","sourceRoot":"","sources":["../../../src/custom/interactive-forms/get-entity-schema-for-form.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD;;;;;;;;;;;;GAYG;AACH,qBACa,4BAA6B,SAAQ,UAAU;IAExD;;;;;;;OAOG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAmDvF,qEAAqE;IACrE,OAAO,CAAC,kBAAkB;CAS7B;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,IAAI,IAAI,CAIvD"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { BaseAction } from "@memberjunction/actions";
|
|
8
|
+
import { Metadata, LogError } from "@memberjunction/core";
|
|
9
|
+
import { RegisterClass } from "@memberjunction/global";
|
|
10
|
+
import { buildCuratedFormSchema } from "@memberjunction/interactive-component-types/forms";
|
|
11
|
+
/**
|
|
12
|
+
* Read-only action consumed by the Form Builder agent to inspect an entity's
|
|
13
|
+
* curated form-relevant schema before generating a form Component.
|
|
14
|
+
*
|
|
15
|
+
* Returns the `CuratedFormSchema` shape: FK references resolved to
|
|
16
|
+
* `{entity, displayField}`, value-list fields annotated with `allowedValues`,
|
|
17
|
+
* and audit / virtual / computed fields stripped. See
|
|
18
|
+
* `@memberjunction/interactive-component-types/forms` for the type.
|
|
19
|
+
*
|
|
20
|
+
* Output is stringified JSON in `Message` (Action framework convention) and
|
|
21
|
+
* also surfaced as a `Schema` output parameter for callers that prefer
|
|
22
|
+
* structured access.
|
|
23
|
+
*/
|
|
24
|
+
let GetEntitySchemaForFormAction = class GetEntitySchemaForFormAction extends BaseAction {
|
|
25
|
+
/**
|
|
26
|
+
* Required input:
|
|
27
|
+
* - `EntityName` (string) — fully-qualified entity name, e.g. "MJ: Applications".
|
|
28
|
+
*
|
|
29
|
+
* Output:
|
|
30
|
+
* - `Schema` parameter — the `CuratedFormSchema` object.
|
|
31
|
+
* - `Message` — the same object, stringified.
|
|
32
|
+
*/
|
|
33
|
+
async InternalRunAction(params) {
|
|
34
|
+
try {
|
|
35
|
+
const entityName = this.getEntityNameParam(params);
|
|
36
|
+
if (!entityName) {
|
|
37
|
+
return {
|
|
38
|
+
Success: false,
|
|
39
|
+
ResultCode: "MISSING_PARAMETER",
|
|
40
|
+
Message: "Parameter 'EntityName' is required.",
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const provider = params.Provider ?? Metadata.Provider;
|
|
44
|
+
if (!provider) {
|
|
45
|
+
return {
|
|
46
|
+
Success: false,
|
|
47
|
+
ResultCode: "NO_PROVIDER",
|
|
48
|
+
Message: "No metadata provider available. Action requires a configured provider on the run params or globally.",
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const schema = buildCuratedFormSchema(entityName, provider);
|
|
52
|
+
if (!schema) {
|
|
53
|
+
return {
|
|
54
|
+
Success: false,
|
|
55
|
+
ResultCode: "ENTITY_NOT_FOUND",
|
|
56
|
+
Message: `Entity '${entityName}' is not registered with the active metadata provider.`,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
params.Params.push({
|
|
60
|
+
Name: "Schema",
|
|
61
|
+
Type: "Output",
|
|
62
|
+
Value: schema,
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
Success: true,
|
|
66
|
+
ResultCode: "SUCCESS",
|
|
67
|
+
Message: JSON.stringify(schema),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
72
|
+
LogError(`GetEntitySchemaForFormAction: ${message}`);
|
|
73
|
+
return {
|
|
74
|
+
Success: false,
|
|
75
|
+
ResultCode: "UNEXPECTED_ERROR",
|
|
76
|
+
Message: message,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** Case-insensitive trim-tolerant fetch for the EntityName param. */
|
|
81
|
+
getEntityNameParam(params) {
|
|
82
|
+
const param = params.Params.find(p => p.Name?.trim().toLowerCase() === "entityname");
|
|
83
|
+
if (!param || param.Value == null) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
const value = String(param.Value).trim();
|
|
87
|
+
return value.length > 0 ? value : null;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
GetEntitySchemaForFormAction = __decorate([
|
|
91
|
+
RegisterClass(BaseAction, "__GetEntitySchemaForForm")
|
|
92
|
+
], GetEntitySchemaForFormAction);
|
|
93
|
+
export { GetEntitySchemaForFormAction };
|
|
94
|
+
/**
|
|
95
|
+
* Tree-shaking guard. Imported and called from src/index.ts so bundlers
|
|
96
|
+
* don't drop the action when no consumer references it by name.
|
|
97
|
+
*/
|
|
98
|
+
export function LoadGetEntitySchemaForFormAction() {
|
|
99
|
+
if (false) {
|
|
100
|
+
const _ = GetEntitySchemaForFormAction;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=get-entity-schema-for-form.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-entity-schema-for-form.action.js","sourceRoot":"","sources":["../../../src/custom/interactive-forms/get-entity-schema-for-form.action.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mDAAmD,CAAC;AAE3F;;;;;;;;;;;;GAYG;AAEI,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,UAAU;IAExD;;;;;;;OAOG;IACO,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,MAAM,UAAU,GAAG,IAAI,CAAC,kBAAkB,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AAC;IAED,qEAAqE;IAC7D,kBAAkB,CAAC,MAAuB;QAC9C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CACjC,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,YAAY,CAAC,CAAC;QACnD,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;QACzC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3C,CAAC;CACJ,CAAA;AAvEY,4BAA4B;IADxC,aAAa,CAAC,UAAU,EAAE,0BAA0B,CAAC;GACzC,4BAA4B,CAuExC;;AAED;;;GAGG;AACH,MAAM,UAAU,gCAAgC;IAC5C,IAAI,KAAgB,EAAE,CAAC;QACnB,MAAM,CAAC,GAAY,4BAA4B,CAAC;IACpD,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './get-entity-schema-for-form.action.js';
|
|
2
|
+
export * from './get-default-form-scaffold.action.js';
|
|
3
|
+
export * from './get-active-form-for-entity.action.js';
|
|
4
|
+
export * from './create-interactive-form.action.js';
|
|
5
|
+
export * from './modify-interactive-form.action.js';
|
|
6
|
+
export * from './activate-interactive-form-version.action.js';
|
|
7
|
+
export * from './revert-interactive-form.action.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/custom/interactive-forms/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './get-entity-schema-for-form.action.js';
|
|
2
|
+
export * from './get-default-form-scaffold.action.js';
|
|
3
|
+
export * from './get-active-form-for-entity.action.js';
|
|
4
|
+
export * from './create-interactive-form.action.js';
|
|
5
|
+
export * from './modify-interactive-form.action.js';
|
|
6
|
+
export * from './activate-interactive-form-version.action.js';
|
|
7
|
+
export * from './revert-interactive-form.action.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/custom/interactive-forms/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
|
|
2
|
+
import { BaseAction } from "@memberjunction/actions";
|
|
3
|
+
/**
|
|
4
|
+
* Modify an existing interactive-form override.
|
|
5
|
+
*
|
|
6
|
+
* Behavior is driven by the **`VersionBumpKind` input** and the **source
|
|
7
|
+
* Override's status** (Override is the canonical "is this live" signal —
|
|
8
|
+
* Component.Status can drift independently):
|
|
9
|
+
*
|
|
10
|
+
* | Source Status | VersionBumpKind | Behavior |
|
|
11
|
+
* |---------------|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
12
|
+
* | Pending | `in-place` (default) | Overwrite the existing Pending Component row in place. No new version. Iteration-loop behavior. |
|
|
13
|
+
* | Pending | `patch` / `minor` / `major` | **Demote** the existing Pending → Inactive, then insert a new Pending Component v(bumped) + new Pending Override pointing at it. Creates rollback. |
|
|
14
|
+
* | Active | `in-place` | **Rejected** — would corrupt the live Active row. Returns `INVALID_BUMP_FOR_STATUS`. |
|
|
15
|
+
* | Active | `patch` / `minor` (default) / `major` | Insert new Pending Component v(bumped) + new Pending Override. Active is untouched — user explicitly Activates later. |
|
|
16
|
+
* | Inactive | `in-place` | **Rejected** — overwriting a dead row achieves nothing. Use 'Revert Interactive Form' to re-activate first, or supply a bump kind. |
|
|
17
|
+
* | Inactive | `patch` (default) / `minor` / `major` | Branch-from-historical. Insert new Pending Component v(bumped) sourced from this Inactive spec. The Inactive source is left alone (already historical). |
|
|
18
|
+
*
|
|
19
|
+
* **Defaults** preserve historical behavior: omit `VersionBumpKind` and
|
|
20
|
+
* Pending sources stay in-place, Active sources bump minor, Inactive
|
|
21
|
+
* sources bump patch (the conservative branch-from-historical case).
|
|
22
|
+
*
|
|
23
|
+
* **Security clamp.** Modify *always* writes a User-scope Pending Override,
|
|
24
|
+
* regardless of the original override's scope. Even if the caller is
|
|
25
|
+
* modifying a Role-scope or Global override (which they have permission to
|
|
26
|
+
* read because they pass the ownership check), the new Pending sibling
|
|
27
|
+
* is always User-scoped to the calling user. Scope promotion (User → Role
|
|
28
|
+
* → Global) is a separate, deliberate human action with its own permission
|
|
29
|
+
* gate in Component Studio / Form Builder. The agent cannot widen scope
|
|
30
|
+
* through Modify any more than through Create.
|
|
31
|
+
*
|
|
32
|
+
* **Ownership check.** The caller must own (or have role membership for, or
|
|
33
|
+
* be admin over) the existing override they're modifying. See
|
|
34
|
+
* `checkOverrideOwnership` in `_shared.ts`. Returns FORBIDDEN if rejected.
|
|
35
|
+
*
|
|
36
|
+
* Inputs:
|
|
37
|
+
* - `OverrideID` (required, string) — the override to modify
|
|
38
|
+
* - `Spec` (required, ComponentSpec | string) — the new form spec
|
|
39
|
+
* - `Notes` (optional, string) — appended to the override's Notes column
|
|
40
|
+
* - `VersionBumpKind` (optional, 'in-place' | 'patch' | 'minor' | 'major') — see table above
|
|
41
|
+
*
|
|
42
|
+
* Outputs:
|
|
43
|
+
* - `ComponentID` — the Component row that now holds the spec (new for snapshots, same for in-place)
|
|
44
|
+
* - `OverrideID` — the Override row that points at it
|
|
45
|
+
* - `Mode` — 'in-place' or 'new-version'
|
|
46
|
+
* - `Version` — the Component's resulting Version string
|
|
47
|
+
*/
|
|
48
|
+
export declare class ModifyInteractiveFormAction extends BaseAction {
|
|
49
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
50
|
+
private findParam;
|
|
51
|
+
}
|
|
52
|
+
/** Tree-shaking guard. */
|
|
53
|
+
export declare function LoadModifyInteractiveFormAction(): void;
|
|
54
|
+
//# sourceMappingURL=modify-interactive-form.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modify-interactive-form.action.d.ts","sourceRoot":"","sources":["../../../src/custom/interactive-forms/modify-interactive-form.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAWrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,qBACa,2BAA4B,SAAQ,UAAU;cAEvC,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAuOvF,OAAO,CAAC,SAAS;CAKpB;AAED,0BAA0B;AAC1B,wBAAgB,+BAA+B,IAAI,IAAI,CAItD"}
|