@memberjunction/core-actions 5.37.0 → 5.39.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/search-entity.action.d.ts +48 -0
- package/dist/custom/data/search-entity.action.d.ts.map +1 -0
- package/dist/custom/data/search-entity.action.js +138 -0
- package/dist/custom/data/search-entity.action.js.map +1 -0
- package/dist/custom/geo/scheduled-geocoding.action.d.ts +27 -0
- package/dist/custom/geo/scheduled-geocoding.action.d.ts.map +1 -1
- package/dist/custom/geo/scheduled-geocoding.action.js +96 -13
- package/dist/custom/geo/scheduled-geocoding.action.js.map +1 -1
- package/dist/custom/integration/generate-integration-action.action.d.ts +60 -0
- package/dist/custom/integration/generate-integration-action.action.d.ts.map +1 -0
- package/dist/custom/integration/generate-integration-action.action.js +182 -0
- package/dist/custom/integration/generate-integration-action.action.js.map +1 -0
- package/dist/custom/integration/integration-action-executor.d.ts +28 -5
- package/dist/custom/integration/integration-action-executor.d.ts.map +1 -1
- package/dist/custom/integration/integration-action-executor.js +65 -11
- package/dist/custom/integration/integration-action-executor.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/custom/utilities/vectorize-entity.action.d.ts.map +1 -1
- package/dist/custom/utilities/vectorize-entity.action.js +7 -2
- package/dist/custom/utilities/vectorize-entity.action.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +34 -32
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for the Interactive Forms action family. These all touch
|
|
3
|
+
* the same two entities (`MJ: Components`, `MJ: Entity Form Overrides`),
|
|
4
|
+
* lint the same spec shape, and need the same parameter conventions —
|
|
5
|
+
* extracting here keeps each action thin.
|
|
6
|
+
*/
|
|
7
|
+
import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
|
|
8
|
+
import { IMetadataProvider, UserInfo } from "@memberjunction/core";
|
|
9
|
+
import { MJComponentEntity, MJEntityFormOverrideEntity } from "@memberjunction/core-entities";
|
|
10
|
+
import type { ComponentSpec } from "@memberjunction/interactive-component-types";
|
|
11
|
+
export declare function getParam(params: RunActionParams, name: string): unknown;
|
|
12
|
+
export declare function getStringParam(params: RunActionParams, name: string): string | null;
|
|
13
|
+
export declare function getNumberParam(params: RunActionParams, name: string): number | null;
|
|
14
|
+
export declare function addOutput(params: RunActionParams, name: string, value: unknown): void;
|
|
15
|
+
export declare function failure(resultCode: string, message: string): ActionResultSimple;
|
|
16
|
+
export declare function success(message: string): ActionResultSimple;
|
|
17
|
+
/** Parse a Spec param that may arrive as object or stringified JSON. */
|
|
18
|
+
export declare function parseSpecParam(raw: unknown): ComponentSpec | {
|
|
19
|
+
error: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Lint a form-role ComponentSpec. Returns null on success, a fail-fast
|
|
23
|
+
* ActionResultSimple on failure. Two rules are suppressed for form-role
|
|
24
|
+
* specs (component-props-validation, callback-event-validation) — see
|
|
25
|
+
* lint comments in the original create-interactive-form action for the
|
|
26
|
+
* rationale.
|
|
27
|
+
*/
|
|
28
|
+
export declare function lintFormSpec(spec: ComponentSpec, contextUser: UserInfo): Promise<ActionResultSimple | null>;
|
|
29
|
+
/** Load a Component entity object by primary key. */
|
|
30
|
+
export declare function loadComponent(provider: IMetadataProvider, user: UserInfo, componentID: string): Promise<MJComponentEntity | null>;
|
|
31
|
+
/** Load an Override entity object by primary key. */
|
|
32
|
+
export declare function loadOverride(provider: IMetadataProvider, user: UserInfo, overrideID: string): Promise<MJEntityFormOverrideEntity | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Defense-in-depth ownership check for the override-mutation actions
|
|
35
|
+
* (Modify / Activate / Revert).
|
|
36
|
+
*
|
|
37
|
+
* `Create` is naturally self-scoped — it always emits a fresh User-scope
|
|
38
|
+
* row owned by the caller. The mutation actions, however, take an
|
|
39
|
+
* `OverrideID` from the caller and operate on it; without this guard a
|
|
40
|
+
* user could mutate another user's User-scope override by guessing the ID.
|
|
41
|
+
* Row-level security may catch some of this, but we don't rely on it.
|
|
42
|
+
*
|
|
43
|
+
* Rules:
|
|
44
|
+
* - `Scope='User'` → caller must be the owning user.
|
|
45
|
+
* - `Scope='Role'` → caller must be a member of the override's role.
|
|
46
|
+
* - `Scope='Global'` → caller must be a system admin (`UserInfo.Type==='Owner'`).
|
|
47
|
+
*
|
|
48
|
+
* Returns `null` on success; a `FORBIDDEN` failure result on rejection.
|
|
49
|
+
*/
|
|
50
|
+
export declare function checkOverrideOwnership(override: Pick<MJEntityFormOverrideEntity, 'ID' | 'Scope' | 'UserID' | 'RoleID'>, user: UserInfo): ActionResultSimple | null;
|
|
51
|
+
/**
|
|
52
|
+
* Lifecycle mapping. EntityFormOverride.Status uses
|
|
53
|
+
* 'Active' / 'Pending' / 'Inactive' (it's the resolver-facing union). The
|
|
54
|
+
* underlying Component table's Status column is the existing MJ Component
|
|
55
|
+
* lifecycle: 'Draft' / 'Published' / 'Deprecated'. We mirror Override.Status
|
|
56
|
+
* onto Component.Status using this map so a Component read in isolation still
|
|
57
|
+
* tells you whether it's the active form (Published), a pending refinement
|
|
58
|
+
* (Draft), or an archived version (Deprecated).
|
|
59
|
+
*/
|
|
60
|
+
export type FormLifecycle = 'Active' | 'Pending' | 'Inactive';
|
|
61
|
+
export declare function mapToComponentStatus(lifecycle: FormLifecycle): 'Published' | 'Draft' | 'Deprecated';
|
|
62
|
+
export declare function mapFromComponentStatus(status: string | null | undefined): FormLifecycle;
|
|
63
|
+
/**
|
|
64
|
+
* Insert a new Component row carrying the supplied spec. Used by both
|
|
65
|
+
* Create (v1.0.0) and Modify (v(N+1).0) paths.
|
|
66
|
+
*
|
|
67
|
+
* - `version` / `versionSequence` are supplied by the caller — different
|
|
68
|
+
* actions have different bumping logic (Create starts at 1.0.0, Modify
|
|
69
|
+
* increments minor).
|
|
70
|
+
* - `componentStatus` mirrors the override status the caller is targeting
|
|
71
|
+
* ('Active' or 'Pending') — translated to the Component table's union via
|
|
72
|
+
* {@link mapToComponentStatus}.
|
|
73
|
+
*/
|
|
74
|
+
export declare function insertComponent(opts: {
|
|
75
|
+
provider: IMetadataProvider;
|
|
76
|
+
user: UserInfo;
|
|
77
|
+
spec: ComponentSpec;
|
|
78
|
+
fallbackName: string;
|
|
79
|
+
description: string | null;
|
|
80
|
+
version: string;
|
|
81
|
+
versionSequence: number;
|
|
82
|
+
componentStatus: FormLifecycle;
|
|
83
|
+
}): Promise<{
|
|
84
|
+
id: string;
|
|
85
|
+
} | {
|
|
86
|
+
error: ActionResultSimple;
|
|
87
|
+
}>;
|
|
88
|
+
/**
|
|
89
|
+
* Insert a new EntityFormOverride row. Always User-scoped (security clamp)
|
|
90
|
+
* unless `allowGlobalOrRole` is explicitly true — which is reserved for the
|
|
91
|
+
* future "promote variant" UI path, not the agent.
|
|
92
|
+
*/
|
|
93
|
+
export declare function insertOverride(opts: {
|
|
94
|
+
provider: IMetadataProvider;
|
|
95
|
+
user: UserInfo;
|
|
96
|
+
entityID: string;
|
|
97
|
+
componentID: string;
|
|
98
|
+
name: string;
|
|
99
|
+
description: string | null;
|
|
100
|
+
notes?: string | null;
|
|
101
|
+
status: 'Active' | 'Pending';
|
|
102
|
+
priority?: number;
|
|
103
|
+
}): Promise<{
|
|
104
|
+
id: string;
|
|
105
|
+
} | {
|
|
106
|
+
error: ActionResultSimple;
|
|
107
|
+
}>;
|
|
108
|
+
/**
|
|
109
|
+
* Discrete intent for how the next version should be derived. Callers
|
|
110
|
+
* (Modify Interactive Form) accept this as an explicit input parameter so
|
|
111
|
+
* the agent can express defect-vs-feature-vs-rewrite intent rather than
|
|
112
|
+
* inferring it from the source row's status.
|
|
113
|
+
*/
|
|
114
|
+
export type VersionBumpKind = 'in-place' | 'patch' | 'minor' | 'major';
|
|
115
|
+
/**
|
|
116
|
+
* "1.0.0" → "1.0.1", "1.7.3" → "1.7.4". Used for small/defect-style edits
|
|
117
|
+
* that deserve a rollback checkpoint but aren't a meaningful UX change.
|
|
118
|
+
*/
|
|
119
|
+
export declare function bumpPatchVersion(current: string | null | undefined): string;
|
|
120
|
+
/**
|
|
121
|
+
* Compute the next semver-minor bump for an existing version string.
|
|
122
|
+
* "1.0.0" → "1.1.0", "1.7.3" → "1.8.0". Used for feature additions —
|
|
123
|
+
* new fields, sections, charts, tabs.
|
|
124
|
+
*/
|
|
125
|
+
export declare function bumpMinorVersion(current: string | null | undefined): string;
|
|
126
|
+
/**
|
|
127
|
+
* "1.7.3" → "2.0.0", "3.4.5" → "4.0.0". Used for radical redesigns or
|
|
128
|
+
* when the user explicitly asks for a new major version.
|
|
129
|
+
*/
|
|
130
|
+
export declare function bumpMajorVersion(current: string | null | undefined): string;
|
|
131
|
+
/**
|
|
132
|
+
* Dispatch a version bump based on the caller's stated intent.
|
|
133
|
+
* `'in-place'` returns the same version unchanged — caller should branch
|
|
134
|
+
* separately (no new Component row is written).
|
|
135
|
+
*/
|
|
136
|
+
export declare function bumpVersion(current: string | null | undefined, kind: VersionBumpKind): string;
|
|
137
|
+
/**
|
|
138
|
+
* Parse and normalize a VersionBumpKind value from a string. Accepts the
|
|
139
|
+
* canonical lowercase forms plus a few common phrasings. Returns null if
|
|
140
|
+
* the input doesn't map to a known kind, so callers can decide whether
|
|
141
|
+
* to default or reject.
|
|
142
|
+
*/
|
|
143
|
+
export declare function parseVersionBumpKind(raw: unknown): VersionBumpKind | null;
|
|
144
|
+
//# s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
+
import { ComponentLinter } from "@memberjunction/react-linter";
|
|
4
|
+
// ── parameter helpers ────────────────────────────────────────────────────
|
|
5
|
+
export function getParam(params, name) {
|
|
6
|
+
const p = params.Params.find(x => x.Name?.trim().toLowerCase() === name.toLowerCase());
|
|
7
|
+
return p?.Value;
|
|
8
|
+
}
|
|
9
|
+
export function getStringParam(params, name) {
|
|
10
|
+
const v = getParam(params, name);
|
|
11
|
+
if (v == null)
|
|
12
|
+
return null;
|
|
13
|
+
const s = String(v).trim();
|
|
14
|
+
return s.length > 0 ? s : null;
|
|
15
|
+
}
|
|
16
|
+
export function getNumberParam(params, name) {
|
|
17
|
+
const v = getParam(params, name);
|
|
18
|
+
if (v == null)
|
|
19
|
+
return null;
|
|
20
|
+
const n = typeof v === 'number' ? v : Number(String(v));
|
|
21
|
+
return Number.isFinite(n) ? n : null;
|
|
22
|
+
}
|
|
23
|
+
export function addOutput(params, name, value) {
|
|
24
|
+
params.Params.push({ Name: name, Type: "Output", Value: value });
|
|
25
|
+
}
|
|
26
|
+
// ── result helpers ───────────────────────────────────────────────────────
|
|
27
|
+
export function failure(resultCode, message) {
|
|
28
|
+
return { Success: false, ResultCode: resultCode, Message: message };
|
|
29
|
+
}
|
|
30
|
+
export function success(message) {
|
|
31
|
+
return { Success: true, ResultCode: "SUCCESS", Message: message };
|
|
32
|
+
}
|
|
33
|
+
// ── spec parsing + linting ───────────────────────────────────────────────
|
|
34
|
+
/** Parse a Spec param that may arrive as object or stringified JSON. */
|
|
35
|
+
export function parseSpecParam(raw) {
|
|
36
|
+
try {
|
|
37
|
+
if (typeof raw === "string") {
|
|
38
|
+
return JSON.parse(raw);
|
|
39
|
+
}
|
|
40
|
+
return raw;
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
return { error: err instanceof Error ? err.message : String(err) };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Lint a form-role ComponentSpec. Returns null on success, a fail-fast
|
|
48
|
+
* ActionResultSimple on failure. Two rules are suppressed for form-role
|
|
49
|
+
* specs (component-props-validation, callback-event-validation) — see
|
|
50
|
+
* lint comments in the original create-interactive-form action for the
|
|
51
|
+
* rationale.
|
|
52
|
+
*/
|
|
53
|
+
export async function lintFormSpec(spec, contextUser) {
|
|
54
|
+
if (!isFormRole(spec)) {
|
|
55
|
+
return failure("LINT_FAILED", `Spec must declare componentRole='form'. Got '${spec.componentRole ?? "(unset)"}'. The InteractiveForm runtime refuses to mount any other role.`);
|
|
56
|
+
}
|
|
57
|
+
if (!spec.name || spec.name.trim().length === 0) {
|
|
58
|
+
return failure("LINT_FAILED", "Spec.name is required.");
|
|
59
|
+
}
|
|
60
|
+
if (typeof spec.code !== "string" || spec.code.trim().length === 0) {
|
|
61
|
+
return failure("LINT_FAILED", "Spec.code must be a non-empty JSX string.");
|
|
62
|
+
}
|
|
63
|
+
if (!spec.location) {
|
|
64
|
+
return failure("LINT_FAILED", "Spec.location is required (use 'embedded' for inline JSX or 'registry' to reference a published component).");
|
|
65
|
+
}
|
|
66
|
+
const FORM_ROLE_SUPPRESSED_RULES = new Set([
|
|
67
|
+
"component-props-validation",
|
|
68
|
+
"callback-event-validation",
|
|
69
|
+
]);
|
|
70
|
+
try {
|
|
71
|
+
const result = await ComponentLinter.lintComponent(spec.code, spec.name, spec, true, contextUser);
|
|
72
|
+
const blocking = (result.violations ?? []).filter(v => {
|
|
73
|
+
const isBlocking = v.severity === "critical" || v.severity === "high";
|
|
74
|
+
if (!isBlocking)
|
|
75
|
+
return false;
|
|
76
|
+
if (v.rule && FORM_ROLE_SUPPRESSED_RULES.has(v.rule))
|
|
77
|
+
return false;
|
|
78
|
+
return true;
|
|
79
|
+
});
|
|
80
|
+
if (blocking.length > 0) {
|
|
81
|
+
const messages = blocking
|
|
82
|
+
.slice(0, 5)
|
|
83
|
+
.map(v => ` [${v.severity}] ${v.rule ?? "lint"}: ${v.message}${v.line ? ` (line ${v.line})` : ""}`)
|
|
84
|
+
.join("\n");
|
|
85
|
+
return failure("LINT_FAILED", `Spec code failed linting:\n${messages}${blocking.length > 5 ? `\n (+${blocking.length - 5} more)` : ""}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
return failure("LINT_FAILED", `Linter could not parse spec code: ${err instanceof Error ? err.message : String(err)}`);
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
// ── component / override fetch + write helpers ───────────────────────────
|
|
94
|
+
/** Load a Component entity object by primary key. */
|
|
95
|
+
export async function loadComponent(provider, user, componentID) {
|
|
96
|
+
const c = await provider.GetEntityObject("MJ: Components", user);
|
|
97
|
+
const loaded = await c.Load(componentID);
|
|
98
|
+
return loaded ? c : null;
|
|
99
|
+
}
|
|
100
|
+
/** Load an Override entity object by primary key. */
|
|
101
|
+
export async function loadOverride(provider, user, overrideID) {
|
|
102
|
+
const o = await provider.GetEntityObject("MJ: Entity Form Overrides", user);
|
|
103
|
+
const loaded = await o.Load(overrideID);
|
|
104
|
+
return loaded ? o : null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Defense-in-depth ownership check for the override-mutation actions
|
|
108
|
+
* (Modify / Activate / Revert).
|
|
109
|
+
*
|
|
110
|
+
* `Create` is naturally self-scoped — it always emits a fresh User-scope
|
|
111
|
+
* row owned by the caller. The mutation actions, however, take an
|
|
112
|
+
* `OverrideID` from the caller and operate on it; without this guard a
|
|
113
|
+
* user could mutate another user's User-scope override by guessing the ID.
|
|
114
|
+
* Row-level security may catch some of this, but we don't rely on it.
|
|
115
|
+
*
|
|
116
|
+
* Rules:
|
|
117
|
+
* - `Scope='User'` → caller must be the owning user.
|
|
118
|
+
* - `Scope='Role'` → caller must be a member of the override's role.
|
|
119
|
+
* - `Scope='Global'` → caller must be a system admin (`UserInfo.Type==='Owner'`).
|
|
120
|
+
*
|
|
121
|
+
* Returns `null` on success; a `FORBIDDEN` failure result on rejection.
|
|
122
|
+
*/
|
|
123
|
+
export function checkOverrideOwnership(override, user) {
|
|
124
|
+
const ID = override.ID;
|
|
125
|
+
switch (override.Scope) {
|
|
126
|
+
case 'User': {
|
|
127
|
+
if (!UUIDsEqual(override.UserID, user.ID)) {
|
|
128
|
+
return failure("FORBIDDEN", `Override ${ID} is User-scoped to a different user. Only the owning user can mutate it.`);
|
|
129
|
+
}
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
case 'Role': {
|
|
133
|
+
const userRoleIds = (user.UserRoles ?? [])
|
|
134
|
+
.map(r => r.RoleID).filter((x) => !!x);
|
|
135
|
+
if (!override.RoleID || !userRoleIds.includes(override.RoleID)) {
|
|
136
|
+
return failure("FORBIDDEN", `Override ${ID} is Role-scoped (${override.RoleID}). Only members of that role can mutate it.`);
|
|
137
|
+
}
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
case 'Global': {
|
|
141
|
+
// `UserInfo.Type === 'Owner'` is MJ's canonical admin marker —
|
|
142
|
+
// see packages/MJCore/src/userInfo.ts (Type is a Pick from the
|
|
143
|
+
// generated entity field). Owners can manage Global overrides;
|
|
144
|
+
// everyone else is rejected.
|
|
145
|
+
const isOwner = (user.Type ?? '').toLowerCase() === 'owner';
|
|
146
|
+
if (!isOwner) {
|
|
147
|
+
return failure("FORBIDDEN", `Override ${ID} is Global. Only Owner-type users can mutate Global overrides; promote / demote them via Component Studio with appropriate privileges.`);
|
|
148
|
+
}
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
default:
|
|
152
|
+
return failure("FORBIDDEN", `Override ${ID} has an unrecognized Scope ('${override.Scope}').`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
export function mapToComponentStatus(lifecycle) {
|
|
156
|
+
switch (lifecycle) {
|
|
157
|
+
case 'Active': return 'Published';
|
|
158
|
+
case 'Pending': return 'Draft';
|
|
159
|
+
case 'Inactive': return 'Deprecated';
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
export function mapFromComponentStatus(status) {
|
|
163
|
+
switch ((status ?? '').toLowerCase()) {
|
|
164
|
+
case 'published': return 'Active';
|
|
165
|
+
case 'draft': return 'Pending';
|
|
166
|
+
case 'deprecated': return 'Inactive';
|
|
167
|
+
default: return 'Inactive'; // unknown values treated as terminal
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Insert a new Component row carrying the supplied spec. Used by both
|
|
172
|
+
* Create (v1.0.0) and Modify (v(N+1).0) paths.
|
|
173
|
+
*
|
|
174
|
+
* - `version` / `versionSequence` are supplied by the caller — different
|
|
175
|
+
* actions have different bumping logic (Create starts at 1.0.0, Modify
|
|
176
|
+
* increments minor).
|
|
177
|
+
* - `componentStatus` mirrors the override status the caller is targeting
|
|
178
|
+
* ('Active' or 'Pending') — translated to the Component table's union via
|
|
179
|
+
* {@link mapToComponentStatus}.
|
|
180
|
+
*/
|
|
181
|
+
export async function insertComponent(opts) {
|
|
182
|
+
const { provider, user, spec, fallbackName, description, version, versionSequence, componentStatus } = opts;
|
|
183
|
+
const component = await provider.GetEntityObject("MJ: Components", user);
|
|
184
|
+
component.NewRecord();
|
|
185
|
+
component.Name = spec.name ?? fallbackName;
|
|
186
|
+
component.Title = spec.title ?? fallbackName;
|
|
187
|
+
component.Description = description ?? spec.description ?? null;
|
|
188
|
+
component.Type = "Form";
|
|
189
|
+
component.Status = mapToComponentStatus(componentStatus);
|
|
190
|
+
component.Version = version;
|
|
191
|
+
component.VersionSequence = versionSequence;
|
|
192
|
+
component.Specification = JSON.stringify(spec);
|
|
193
|
+
component.DeveloperName = user.Name ?? null;
|
|
194
|
+
const saved = await component.Save();
|
|
195
|
+
if (!saved) {
|
|
196
|
+
return { error: failure("PERSIST_FAILED", `Component insert failed: ${component.LatestResult?.CompleteMessage ?? "unknown error"}`) };
|
|
197
|
+
}
|
|
198
|
+
return { id: component.ID };
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Insert a new EntityFormOverride row. Always User-scoped (security clamp)
|
|
202
|
+
* unless `allowGlobalOrRole` is explicitly true — which is reserved for the
|
|
203
|
+
* future "promote variant" UI path, not the agent.
|
|
204
|
+
*/
|
|
205
|
+
export async function insertOverride(opts) {
|
|
206
|
+
const { provider, user, entityID, componentID, name, description, notes, status, priority } = opts;
|
|
207
|
+
const override = await provider.GetEntityObject("MJ: Entity Form Overrides", user);
|
|
208
|
+
override.NewRecord();
|
|
209
|
+
override.EntityID = entityID;
|
|
210
|
+
override.ComponentID = componentID;
|
|
211
|
+
override.Name = name;
|
|
212
|
+
override.Description = description;
|
|
213
|
+
// Notes is the column added in V202605221100 (Notes-column fold-in).
|
|
214
|
+
// Cast — the generated type may or may not yet expose it depending on
|
|
215
|
+
// codegen freshness; the field exists in the DB regardless.
|
|
216
|
+
override.Notes = notes ?? null;
|
|
217
|
+
override.Scope = "User";
|
|
218
|
+
override.UserID = user.ID;
|
|
219
|
+
override.RoleID = null;
|
|
220
|
+
override.Priority = priority ?? 0;
|
|
221
|
+
override.Status = status;
|
|
222
|
+
const saved = await override.Save();
|
|
223
|
+
if (!saved) {
|
|
224
|
+
return { error: failure("PERSIST_FAILED", `Override insert failed: ${override.LatestResult?.CompleteMessage ?? "unknown error"}`) };
|
|
225
|
+
}
|
|
226
|
+
return { id: override.ID };
|
|
227
|
+
}
|
|
228
|
+
function parseSemver(current) {
|
|
229
|
+
if (!current)
|
|
230
|
+
return { major: 1, minor: 0, patch: 0 };
|
|
231
|
+
const m = /^(\d+)\.(\d+)(?:\.(\d+))?/.exec(current.trim());
|
|
232
|
+
if (!m)
|
|
233
|
+
return { major: 1, minor: 0, patch: 0 };
|
|
234
|
+
return {
|
|
235
|
+
major: Number(m[1]),
|
|
236
|
+
minor: Number(m[2]),
|
|
237
|
+
patch: m[3] ? Number(m[3]) : 0,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* "1.0.0" → "1.0.1", "1.7.3" → "1.7.4". Used for small/defect-style edits
|
|
242
|
+
* that deserve a rollback checkpoint but aren't a meaningful UX change.
|
|
243
|
+
*/
|
|
244
|
+
export function bumpPatchVersion(current) {
|
|
245
|
+
const v = parseSemver(current);
|
|
246
|
+
return `${v.major}.${v.minor}.${v.patch + 1}`;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Compute the next semver-minor bump for an existing version string.
|
|
250
|
+
* "1.0.0" → "1.1.0", "1.7.3" → "1.8.0". Used for feature additions —
|
|
251
|
+
* new fields, sections, charts, tabs.
|
|
252
|
+
*/
|
|
253
|
+
export function bumpMinorVersion(current) {
|
|
254
|
+
const v = parseSemver(current);
|
|
255
|
+
return `${v.major}.${v.minor + 1}.0`;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* "1.7.3" → "2.0.0", "3.4.5" → "4.0.0". Used for radical redesigns or
|
|
259
|
+
* when the user explicitly asks for a new major version.
|
|
260
|
+
*/
|
|
261
|
+
export function bumpMajorVersion(current) {
|
|
262
|
+
const v = parseSemver(current);
|
|
263
|
+
return `${v.major + 1}.0.0`;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Dispatch a version bump based on the caller's stated intent.
|
|
267
|
+
* `'in-place'` returns the same version unchanged — caller should branch
|
|
268
|
+
* separately (no new Component row is written).
|
|
269
|
+
*/
|
|
270
|
+
export function bumpVersion(current, kind) {
|
|
271
|
+
switch (kind) {
|
|
272
|
+
case 'patch': return bumpPatchVersion(current);
|
|
273
|
+
case 'minor': return bumpMinorVersion(current);
|
|
274
|
+
case 'major': return bumpMajorVersion(current);
|
|
275
|
+
case 'in-place': return current ?? '1.0.0';
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Parse and normalize a VersionBumpKind value from a string. Accepts the
|
|
280
|
+
* canonical lowercase forms plus a few common phrasings. Returns null if
|
|
281
|
+
* the input doesn't map to a known kind, so callers can decide whether
|
|
282
|
+
* to default or reject.
|
|
283
|
+
*/
|
|
284
|
+
export function parseVersionBumpKind(raw) {
|
|
285
|
+
if (raw == null)
|
|
286
|
+
return null;
|
|
287
|
+
const s = String(raw).trim().toLowerCase();
|
|
288
|
+
if (!s)
|
|
289
|
+
return null;
|
|
290
|
+
if (s === 'in-place' || s === 'inplace' || s === 'in_place')
|
|
291
|
+
return 'in-place';
|
|
292
|
+
if (s === 'patch')
|
|
293
|
+
return 'patch';
|
|
294
|
+
if (s === 'minor')
|
|
295
|
+
return 'minor';
|
|
296
|
+
if (s === 'major')
|
|
297
|
+
return 'major';
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
//# sourceMappingURL=_shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_shared.js","sourceRoot":"","sources":["../../../src/custom/interactive-forms/_shared.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAMpD,OAAO,EAAE,UAAU,EAAE,MAAM,mDAAmD,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,4EAA4E;AAE5E,MAAM,UAAU,QAAQ,CAAC,MAAuB,EAAE,IAAY;IAC1D,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;IACzD,OAAO,CAAC,EAAE,KAAK,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,MAAuB,EAAE,IAAY;IAChE,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACjC,IAAI,CAAC,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IAC3B,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3B,OAAO,CAAC,CAAC,MAAM,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,CAAC,OAAO,CAAC,CAAC;IAC/B,OAAO,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,OAAkC,EAAE,IAAqB;IACjF,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,OAAO,CAAC,CAAC,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,OAAO,CAAC,CAAC,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,OAAO,CAAC,CAAC,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,UAAU,CAAC,CAAC,OAAO,OAAO,IAAI,OAAO,CAAC;IAC/C,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAY;IAC7C,IAAI,GAAG,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IAC7B,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC3C,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpB,IAAI,CAAC,KAAK,UAAU,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,UAAU;QAAE,OAAO,UAAU,CAAC;IAC/E,IAAI,CAAC,KAAK,OAAO;QAAE,OAAO,OAAO,CAAC;IAClC,IAAI,CAAC,KAAK,OAAO;QAAE,OAAO,OAAO,CAAC;IAClC,IAAI,CAAC,KAAK,OAAO;QAAE,OAAO,OAAO,CAAC;IAClC,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
|
|
2
|
+
import { BaseAction } from "@memberjunction/actions";
|
|
3
|
+
/**
|
|
4
|
+
* Promote a Pending override to Active. Flips:
|
|
5
|
+
* - target Override: Status='Active'
|
|
6
|
+
* - target Override's Component: Status='Active'
|
|
7
|
+
* - prior Active sibling Override: Status='Inactive'
|
|
8
|
+
* - prior Active sibling Component: Status='Inactive'
|
|
9
|
+
*
|
|
10
|
+
* "Sibling" = same EntityID + (Scope, UserID, RoleID) tuple as the target
|
|
11
|
+
* Override. The target is the row identified by the input `OverrideID`; the
|
|
12
|
+
* priors are any rows currently Status='Active' at the same scope target.
|
|
13
|
+
*
|
|
14
|
+
* Idempotency. If the target Override is already Active, returns SUCCESS
|
|
15
|
+
* with a no-op message. If it's Inactive, that's a misuse — we surface
|
|
16
|
+
* NOT_PENDING so the agent / UI can ask the user what they really want.
|
|
17
|
+
*
|
|
18
|
+
* Inputs:
|
|
19
|
+
* - `OverrideID` (required, string) — the Pending override to activate
|
|
20
|
+
*
|
|
21
|
+
* Outputs:
|
|
22
|
+
* - `ComponentID` — the Component now Active
|
|
23
|
+
* - `OverrideID` — echoed for convenience
|
|
24
|
+
* - `PreviousActiveOverrideID` — the override that was demoted (or null)
|
|
25
|
+
*/
|
|
26
|
+
export declare class ActivateInteractiveFormVersionAction extends BaseAction {
|
|
27
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
28
|
+
}
|
|
29
|
+
/** Tree-shaking guard. */
|
|
30
|
+
export declare function LoadActivateInteractiveFormVersionAction(): void;
|
|
31
|
+
//# sourceMappingURL=activate-interactive-form-version.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activate-interactive-form-version.action.d.ts","sourceRoot":"","sources":["../../../src/custom/interactive-forms/activate-interactive-form-version.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAOrD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBACa,oCAAqC,SAAQ,UAAU;cAEhD,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAkG1F;AAED,0BAA0B;AAC1B,wBAAgB,wCAAwC,IAAI,IAAI,CAI/D"}
|
|
@@ -0,0 +1,139 @@
|
|
|
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
|
+
import { addOutput, checkOverrideOwnership, failure, getStringParam, loadComponent, loadOverride, mapToComponentStatus, } from "./_shared.js";
|
|
11
|
+
/**
|
|
12
|
+
* Promote a Pending override to Active. Flips:
|
|
13
|
+
* - target Override: Status='Active'
|
|
14
|
+
* - target Override's Component: Status='Active'
|
|
15
|
+
* - prior Active sibling Override: Status='Inactive'
|
|
16
|
+
* - prior Active sibling Component: Status='Inactive'
|
|
17
|
+
*
|
|
18
|
+
* "Sibling" = same EntityID + (Scope, UserID, RoleID) tuple as the target
|
|
19
|
+
* Override. The target is the row identified by the input `OverrideID`; the
|
|
20
|
+
* priors are any rows currently Status='Active' at the same scope target.
|
|
21
|
+
*
|
|
22
|
+
* Idempotency. If the target Override is already Active, returns SUCCESS
|
|
23
|
+
* with a no-op message. If it's Inactive, that's a misuse — we surface
|
|
24
|
+
* NOT_PENDING so the agent / UI can ask the user what they really want.
|
|
25
|
+
*
|
|
26
|
+
* Inputs:
|
|
27
|
+
* - `OverrideID` (required, string) — the Pending override to activate
|
|
28
|
+
*
|
|
29
|
+
* Outputs:
|
|
30
|
+
* - `ComponentID` — the Component now Active
|
|
31
|
+
* - `OverrideID` — echoed for convenience
|
|
32
|
+
* - `PreviousActiveOverrideID` — the override that was demoted (or null)
|
|
33
|
+
*/
|
|
34
|
+
let ActivateInteractiveFormVersionAction = class ActivateInteractiveFormVersionAction extends BaseAction {
|
|
35
|
+
async InternalRunAction(params) {
|
|
36
|
+
try {
|
|
37
|
+
const overrideID = getStringParam(params, "OverrideID");
|
|
38
|
+
if (!overrideID) {
|
|
39
|
+
return failure("MISSING_PARAMETER", "Parameter 'OverrideID' is required.");
|
|
40
|
+
}
|
|
41
|
+
const provider = params.Provider ?? Metadata.Provider;
|
|
42
|
+
if (!provider)
|
|
43
|
+
return failure("NO_PROVIDER", "No metadata provider available.");
|
|
44
|
+
const user = params.ContextUser;
|
|
45
|
+
if (!user)
|
|
46
|
+
return failure("NO_USER", "Action requires a ContextUser.");
|
|
47
|
+
const target = await loadOverride(provider, user, overrideID);
|
|
48
|
+
if (!target) {
|
|
49
|
+
return failure("OVERRIDE_NOT_FOUND", `EntityFormOverride '${overrideID}' not found.`);
|
|
50
|
+
}
|
|
51
|
+
const ownershipFail = checkOverrideOwnership(target, user);
|
|
52
|
+
if (ownershipFail)
|
|
53
|
+
return ownershipFail;
|
|
54
|
+
if (target.Status === 'Active') {
|
|
55
|
+
addOutput(params, "ComponentID", target.ComponentID);
|
|
56
|
+
addOutput(params, "OverrideID", target.ID);
|
|
57
|
+
addOutput(params, "PreviousActiveOverrideID", null);
|
|
58
|
+
return { Success: true, ResultCode: "SUCCESS",
|
|
59
|
+
Message: JSON.stringify({ noop: true, OverrideID: target.ID, ComponentID: target.ComponentID }) };
|
|
60
|
+
}
|
|
61
|
+
if (target.Status === 'Inactive') {
|
|
62
|
+
return failure("NOT_PENDING", `Override ${overrideID} is Inactive. Use 'Revert Interactive Form' to restore an older version, not 'Activate'.`);
|
|
63
|
+
}
|
|
64
|
+
// Find sibling Active overrides at the same (entity, scope target).
|
|
65
|
+
const rv = RunView.FromMetadataProvider(provider);
|
|
66
|
+
const scopeClause = target.Scope === 'User'
|
|
67
|
+
? `Scope='User' AND UserID='${target.UserID}'`
|
|
68
|
+
: target.Scope === 'Role'
|
|
69
|
+
? `Scope='Role' AND RoleID='${target.RoleID}'`
|
|
70
|
+
: `Scope='Global' AND UserID IS NULL AND RoleID IS NULL`;
|
|
71
|
+
const priorResult = await rv.RunView({
|
|
72
|
+
EntityName: "MJ: Entity Form Overrides",
|
|
73
|
+
ExtraFilter: `EntityID='${target.EntityID}' AND ${scopeClause} AND Status='Active' AND ID <> '${target.ID}'`,
|
|
74
|
+
Fields: ['ID', 'ComponentID'],
|
|
75
|
+
ResultType: 'simple',
|
|
76
|
+
}, user);
|
|
77
|
+
if (!priorResult.Success) {
|
|
78
|
+
return failure("QUERY_FAILED", `Prior-active lookup failed: ${priorResult.ErrorMessage ?? 'unknown error'}`);
|
|
79
|
+
}
|
|
80
|
+
// Promote target's component.
|
|
81
|
+
const newComponent = await loadComponent(provider, user, target.ComponentID);
|
|
82
|
+
if (!newComponent) {
|
|
83
|
+
return failure("COMPONENT_NOT_FOUND", `Override ${overrideID} points at Component ${target.ComponentID} which no longer exists.`);
|
|
84
|
+
}
|
|
85
|
+
newComponent.Status = mapToComponentStatus('Active');
|
|
86
|
+
const ncSaved = await newComponent.Save();
|
|
87
|
+
if (!ncSaved) {
|
|
88
|
+
return failure("PERSIST_FAILED", `Could not flip Component to Active: ${newComponent.LatestResult?.CompleteMessage ?? 'unknown error'}`);
|
|
89
|
+
}
|
|
90
|
+
target.Status = 'Active';
|
|
91
|
+
const tSaved = await target.Save();
|
|
92
|
+
if (!tSaved) {
|
|
93
|
+
return failure("PERSIST_FAILED", `Could not flip Override to Active: ${target.LatestResult?.CompleteMessage ?? 'unknown error'}`);
|
|
94
|
+
}
|
|
95
|
+
// Demote priors. Component AND Override flipped in lock-step.
|
|
96
|
+
let firstPriorID = null;
|
|
97
|
+
for (const prior of priorResult.Results ?? []) {
|
|
98
|
+
if (!firstPriorID)
|
|
99
|
+
firstPriorID = prior.ID;
|
|
100
|
+
const priorO = await loadOverride(provider, user, prior.ID);
|
|
101
|
+
const priorC = await loadComponent(provider, user, prior.ComponentID);
|
|
102
|
+
if (priorO) {
|
|
103
|
+
priorO.Status = 'Inactive';
|
|
104
|
+
await priorO.Save();
|
|
105
|
+
}
|
|
106
|
+
if (priorC) {
|
|
107
|
+
priorC.Status = mapToComponentStatus('Inactive');
|
|
108
|
+
await priorC.Save();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
addOutput(params, "ComponentID", target.ComponentID);
|
|
112
|
+
addOutput(params, "OverrideID", target.ID);
|
|
113
|
+
addOutput(params, "PreviousActiveOverrideID", firstPriorID);
|
|
114
|
+
return { Success: true, ResultCode: "SUCCESS",
|
|
115
|
+
Message: JSON.stringify({
|
|
116
|
+
OverrideID: target.ID,
|
|
117
|
+
ComponentID: target.ComponentID,
|
|
118
|
+
PreviousActiveOverrideID: firstPriorID,
|
|
119
|
+
DemotedCount: (priorResult.Results ?? []).length,
|
|
120
|
+
}) };
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
124
|
+
LogError(`ActivateInteractiveFormVersionAction: ${message}`);
|
|
125
|
+
return failure("UNEXPECTED_ERROR", message);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
ActivateInteractiveFormVersionAction = __decorate([
|
|
130
|
+
RegisterClass(BaseAction, "__ActivateInteractiveFormVersion")
|
|
131
|
+
], ActivateInteractiveFormVersionAction);
|
|
132
|
+
export { ActivateInteractiveFormVersionAction };
|
|
133
|
+
/** Tree-shaking guard. */
|
|
134
|
+
export function LoadActivateInteractiveFormVersionAction() {
|
|
135
|
+
if (false) {
|
|
136
|
+
const _ = ActivateInteractiveFormVersionAction;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=activate-interactive-form-version.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activate-interactive-form-version.action.js","sourceRoot":"","sources":["../../../src/custom/interactive-forms/activate-interactive-form-version.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;AACvD,OAAO,EACH,SAAS,EAAE,sBAAsB,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,oBAAoB,GAChH,MAAM,WAAW,CAAC;AAEnB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEI,IAAM,oCAAoC,GAA1C,MAAM,oCAAqC,SAAQ,UAAU;IAEtD,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,MAAM,UAAU,GAAG,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;YACxD,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;gBAAE,OAAO,OAAO,CAAC,aAAa,EAAE,iCAAiC,CAAC,CAAC;YAChF,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC;YAChC,IAAI,CAAC,IAAI;gBAAE,OAAO,OAAO,CAAC,SAAS,EAAE,gCAAgC,CAAC,CAAC;YAEvE,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,QAAQ,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;YAC9D,IAAI,CAAC,MAA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