@memberjunction/core-actions 6.3.0-edge.1 → 6.3.0-edge.2
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 +2 -0
- package/dist/custom/ai/agent-channel.action.d.ts +29 -0
- package/dist/custom/ai/agent-channel.action.d.ts.map +1 -0
- package/dist/custom/ai/agent-channel.action.js +843 -0
- package/dist/custom/ai/agent-channel.action.js.map +1 -0
- package/dist/custom/ai/chief-of-staff-approval-helper.d.ts +16 -0
- package/dist/custom/ai/chief-of-staff-approval-helper.d.ts.map +1 -0
- package/dist/custom/ai/chief-of-staff-approval-helper.js +63 -0
- package/dist/custom/ai/chief-of-staff-approval-helper.js.map +1 -0
- package/dist/custom/ai/chief-of-staff-core-reads.action.d.ts +64 -0
- package/dist/custom/ai/chief-of-staff-core-reads.action.d.ts.map +1 -0
- package/dist/custom/ai/chief-of-staff-core-reads.action.js +1097 -0
- package/dist/custom/ai/chief-of-staff-core-reads.action.js.map +1 -0
- package/dist/custom/ai/chief-of-staff-rhythms-suggestions.action.d.ts +28 -0
- package/dist/custom/ai/chief-of-staff-rhythms-suggestions.action.d.ts.map +1 -0
- package/dist/custom/ai/chief-of-staff-rhythms-suggestions.action.js +817 -0
- package/dist/custom/ai/chief-of-staff-rhythms-suggestions.action.js.map +1 -0
- package/dist/custom/ai/configure-agent-user-policy.action.d.ts +1 -0
- package/dist/custom/ai/configure-agent-user-policy.action.d.ts.map +1 -1
- package/dist/custom/ai/configure-agent-user-policy.action.js +5 -1
- package/dist/custom/ai/configure-agent-user-policy.action.js.map +1 -1
- package/dist/custom/ai/manage-my-agent-instance.action.d.ts +39 -0
- package/dist/custom/ai/manage-my-agent-instance.action.d.ts.map +1 -0
- package/dist/custom/ai/manage-my-agent-instance.action.js +752 -0
- package/dist/custom/ai/manage-my-agent-instance.action.js.map +1 -0
- package/dist/custom/ai/prepare-outbound-call-brief.action.js +1 -1
- package/dist/custom/ai/prepare-outbound-call-brief.action.js.map +1 -1
- package/dist/custom/ai/schedule-next-agent-wake.action.d.ts +2 -0
- package/dist/custom/ai/schedule-next-agent-wake.action.d.ts.map +1 -1
- package/dist/custom/ai/schedule-next-agent-wake.action.js +105 -2
- package/dist/custom/ai/schedule-next-agent-wake.action.js.map +1 -1
- package/dist/custom/ai/send-inter-agent-request.action.d.ts +1 -0
- package/dist/custom/ai/send-inter-agent-request.action.d.ts.map +1 -1
- package/dist/custom/ai/send-inter-agent-request.action.js +72 -18
- package/dist/custom/ai/send-inter-agent-request.action.js.map +1 -1
- package/dist/custom/ai/trigger-agent-wake.action.d.ts +1 -0
- package/dist/custom/ai/trigger-agent-wake.action.d.ts.map +1 -1
- package/dist/custom/ai/trigger-agent-wake.action.js +3 -0
- package/dist/custom/ai/trigger-agent-wake.action.js.map +1 -1
- package/dist/custom/ai/user-scoped-communication.action.d.ts +20 -0
- package/dist/custom/ai/user-scoped-communication.action.d.ts.map +1 -1
- package/dist/custom/ai/user-scoped-communication.action.js +140 -23
- package/dist/custom/ai/user-scoped-communication.action.js.map +1 -1
- package/dist/custom/data/adhoc-sql-gate.d.ts +40 -0
- package/dist/custom/data/adhoc-sql-gate.d.ts.map +1 -0
- package/dist/custom/data/adhoc-sql-gate.js +102 -0
- package/dist/custom/data/adhoc-sql-gate.js.map +1 -0
- package/dist/custom/data/data-mapper.action.d.ts +8 -0
- package/dist/custom/data/data-mapper.action.d.ts.map +1 -1
- package/dist/custom/data/data-mapper.action.js +21 -3
- package/dist/custom/data/data-mapper.action.js.map +1 -1
- package/dist/custom/data/find-graph-path.action.d.ts +37 -0
- package/dist/custom/data/find-graph-path.action.d.ts.map +1 -0
- package/dist/custom/data/find-graph-path.action.js +114 -0
- package/dist/custom/data/find-graph-path.action.js.map +1 -0
- package/dist/custom/data/get-graph-context.action.d.ts +22 -12
- package/dist/custom/data/get-graph-context.action.d.ts.map +1 -1
- package/dist/custom/data/get-graph-context.action.js +102 -239
- package/dist/custom/data/get-graph-context.action.js.map +1 -1
- package/dist/custom/data/graph-action-params.d.ts +51 -0
- package/dist/custom/data/graph-action-params.d.ts.map +1 -0
- package/dist/custom/data/graph-action-params.js +164 -0
- package/dist/custom/data/graph-action-params.js.map +1 -0
- package/dist/custom/data/mapping-template-guard.d.ts +18 -0
- package/dist/custom/data/mapping-template-guard.d.ts.map +1 -0
- package/dist/custom/data/mapping-template-guard.js +106 -0
- package/dist/custom/data/mapping-template-guard.js.map +1 -0
- package/dist/custom/data/propose-canon-domains.action.d.ts +26 -0
- package/dist/custom/data/propose-canon-domains.action.d.ts.map +1 -0
- package/dist/custom/data/propose-canon-domains.action.js +105 -0
- package/dist/custom/data/propose-canon-domains.action.js.map +1 -0
- package/dist/custom/data/run-adhoc-query.action.d.ts +4 -21
- package/dist/custom/data/run-adhoc-query.action.d.ts.map +1 -1
- package/dist/custom/data/run-adhoc-query.action.js +15 -105
- package/dist/custom/data/run-adhoc-query.action.js.map +1 -1
- package/dist/custom/integration/http-request.action.d.ts.map +1 -1
- package/dist/custom/integration/http-request.action.js +5 -1
- package/dist/custom/integration/http-request.action.js.map +1 -1
- package/dist/custom/lists/create-list-from-query.action.d.ts +39 -0
- package/dist/custom/lists/create-list-from-query.action.d.ts.map +1 -0
- package/dist/custom/lists/create-list-from-query.action.js +179 -0
- package/dist/custom/lists/create-list-from-query.action.js.map +1 -0
- package/dist/custom/lists/index.d.ts +2 -0
- package/dist/custom/lists/index.d.ts.map +1 -1
- package/dist/custom/lists/index.js +2 -0
- package/dist/custom/lists/index.js.map +1 -1
- package/dist/custom/search/scoped-search.action.d.ts +12 -1
- package/dist/custom/search/scoped-search.action.d.ts.map +1 -1
- package/dist/custom/search/scoped-search.action.js +44 -6
- package/dist/custom/search/scoped-search.action.js.map +1 -1
- package/dist/custom/search/search-query.util.d.ts +24 -0
- package/dist/custom/search/search-query.util.d.ts.map +1 -0
- package/dist/custom/search/search-query.util.js +211 -0
- package/dist/custom/search/search-query.util.js.map +1 -0
- package/dist/custom/search/search.action.js +2 -2
- package/dist/custom/search/search.action.js.map +1 -1
- package/dist/custom/web/url-link-validator.action.d.ts.map +1 -1
- package/dist/custom/web/url-link-validator.action.js +3 -1
- package/dist/custom/web/url-link-validator.action.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +45 -45
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { RunActionParams } from '@memberjunction/actions-base';
|
|
2
|
+
import type { ConceptMatch, GraphEndpointInput } from '@memberjunction/core-entities';
|
|
3
|
+
/**
|
|
4
|
+
* Parameter helpers shared by the semantic-graph actions (`Get Graph Context`, `Find Graph Path`,
|
|
5
|
+
* `Propose Canon Domains`). Agents pass values in many shapes (native arrays, JSON strings,
|
|
6
|
+
* comma-separated lists, either key casing), so the parsing lives here once.
|
|
7
|
+
*/
|
|
8
|
+
/** The raw value of the parameter `name` (case-insensitive), or `undefined`. */
|
|
9
|
+
export declare function GetGraphActionParam(params: RunActionParams, name: string): unknown;
|
|
10
|
+
/** The parameter as a trimmed string, or `undefined` when absent or blank. */
|
|
11
|
+
export declare function GetGraphActionString(params: RunActionParams, name: string): string | undefined;
|
|
12
|
+
/** The parameter as a finite number, else `defaultValue`. */
|
|
13
|
+
export declare function GetGraphActionNumber(params: RunActionParams, name: string, defaultValue: number): number;
|
|
14
|
+
/** The parameter as a boolean (`true`/`1`/`yes`, `false`/`0`/`no`), else `defaultValue`. */
|
|
15
|
+
export declare function GetGraphActionBoolean(params: RunActionParams, name: string, defaultValue: boolean): boolean;
|
|
16
|
+
/** An optional weight in `[0, 1]`, or `undefined` when absent or not a number. */
|
|
17
|
+
export declare function GetGraphActionWeight(params: RunActionParams, name: string): number | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* A list of strings from a native array, a JSON array string, or a comma-separated string.
|
|
20
|
+
* `undefined` when the value is absent or yields nothing.
|
|
21
|
+
*/
|
|
22
|
+
export declare function ParseGraphActionStringList(raw: unknown): string[] | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* A list of seed-like items (strings or objects) from a native array, a JSON string (array or
|
|
25
|
+
* single object), a single object, or a comma-separated string.
|
|
26
|
+
*/
|
|
27
|
+
export declare function ParseGraphActionItemList(raw: unknown): unknown[];
|
|
28
|
+
/**
|
|
29
|
+
* A record reference `{ EntityName, RecordID }` (either key casing) from a plain object, or
|
|
30
|
+
* `undefined` when the object does not carry both.
|
|
31
|
+
*/
|
|
32
|
+
export declare function ParseGraphRecordRef(item: unknown): {
|
|
33
|
+
EntityName: string;
|
|
34
|
+
RecordID: string;
|
|
35
|
+
EntityID?: string;
|
|
36
|
+
} | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* One end of a path from an action parameter: a record object, a JSON string of one, a concept
|
|
39
|
+
* object (`{ Concept }`), or plain text naming a concept (its name, a synonym, or its ID).
|
|
40
|
+
*/
|
|
41
|
+
export declare function ParseGraphEndpoint(raw: unknown): GraphEndpointInput | undefined;
|
|
42
|
+
/** Ambiguous concept candidates as plain rows an agent can read and pick from. */
|
|
43
|
+
export declare function DescribeConceptCandidates(candidates: readonly ConceptMatch[]): Array<{
|
|
44
|
+
Name: string;
|
|
45
|
+
RecordID: string;
|
|
46
|
+
Description: string | null;
|
|
47
|
+
Score: number;
|
|
48
|
+
}>;
|
|
49
|
+
/** Set (or replace) the output parameter `name`. */
|
|
50
|
+
export declare function SetGraphActionOutput(params: RunActionParams, name: string, value: unknown): void;
|
|
51
|
+
//# sourceMappingURL=graph-action-params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-action-params.d.ts","sourceRoot":"","sources":["../../../src/custom/data/graph-action-params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AA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AAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAEnK;AAED,oDAAoD;AACpD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAWhG"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { IsPlainObject } from '@memberjunction/global';
|
|
2
|
+
/**
|
|
3
|
+
* Parameter helpers shared by the semantic-graph actions (`Get Graph Context`, `Find Graph Path`,
|
|
4
|
+
* `Propose Canon Domains`). Agents pass values in many shapes (native arrays, JSON strings,
|
|
5
|
+
* comma-separated lists, either key casing), so the parsing lives here once.
|
|
6
|
+
*/
|
|
7
|
+
/** The raw value of the parameter `name` (case-insensitive), or `undefined`. */
|
|
8
|
+
export function GetGraphActionParam(params, name) {
|
|
9
|
+
const lower = name.trim().toLowerCase();
|
|
10
|
+
return params.Params?.find((p) => p.Name.trim().toLowerCase() === lower)?.Value;
|
|
11
|
+
}
|
|
12
|
+
/** The parameter as a trimmed string, or `undefined` when absent or blank. */
|
|
13
|
+
export function GetGraphActionString(params, name) {
|
|
14
|
+
const value = GetGraphActionParam(params, name);
|
|
15
|
+
const text = value != null ? String(value).trim() : '';
|
|
16
|
+
return text.length > 0 ? text : undefined;
|
|
17
|
+
}
|
|
18
|
+
/** The parameter as a finite number, else `defaultValue`. */
|
|
19
|
+
export function GetGraphActionNumber(params, name, defaultValue) {
|
|
20
|
+
const value = GetGraphActionParam(params, name);
|
|
21
|
+
const num = value != null && value !== '' ? Number(value) : NaN;
|
|
22
|
+
return Number.isFinite(num) ? num : defaultValue;
|
|
23
|
+
}
|
|
24
|
+
/** The parameter as a boolean (`true`/`1`/`yes`, `false`/`0`/`no`), else `defaultValue`. */
|
|
25
|
+
export function GetGraphActionBoolean(params, name, defaultValue) {
|
|
26
|
+
const value = GetGraphActionParam(params, name);
|
|
27
|
+
if (typeof value === 'boolean') {
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
const text = value != null ? String(value).trim().toLowerCase() : '';
|
|
31
|
+
if (text === 'true' || text === '1' || text === 'yes') {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
if (text === 'false' || text === '0' || text === 'no') {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
return defaultValue;
|
|
38
|
+
}
|
|
39
|
+
/** An optional weight in `[0, 1]`, or `undefined` when absent or not a number. */
|
|
40
|
+
export function GetGraphActionWeight(params, name) {
|
|
41
|
+
const value = GetGraphActionParam(params, name);
|
|
42
|
+
const num = value != null && value !== '' ? Number(value) : NaN;
|
|
43
|
+
return Number.isFinite(num) ? Math.max(0, Math.min(1, num)) : undefined;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A list of strings from a native array, a JSON array string, or a comma-separated string.
|
|
47
|
+
* `undefined` when the value is absent or yields nothing.
|
|
48
|
+
*/
|
|
49
|
+
export function ParseGraphActionStringList(raw) {
|
|
50
|
+
let items = [];
|
|
51
|
+
if (Array.isArray(raw)) {
|
|
52
|
+
items = raw;
|
|
53
|
+
}
|
|
54
|
+
else if (typeof raw === 'string' && raw.trim()) {
|
|
55
|
+
const trimmed = raw.trim();
|
|
56
|
+
items = trimmed.startsWith('[') ? parseJsonArray(trimmed) ?? trimmed.split(',') : trimmed.split(',');
|
|
57
|
+
}
|
|
58
|
+
const list = items.map((x) => String(x).trim()).filter(Boolean);
|
|
59
|
+
return list.length > 0 ? list : undefined;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A list of seed-like items (strings or objects) from a native array, a JSON string (array or
|
|
63
|
+
* single object), a single object, or a comma-separated string.
|
|
64
|
+
*/
|
|
65
|
+
export function ParseGraphActionItemList(raw) {
|
|
66
|
+
if (raw == null) {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
if (Array.isArray(raw)) {
|
|
70
|
+
return raw;
|
|
71
|
+
}
|
|
72
|
+
if (typeof raw === 'string') {
|
|
73
|
+
const trimmed = raw.trim();
|
|
74
|
+
if (!trimmed) {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
if (trimmed.startsWith('[') || trimmed.startsWith('{')) {
|
|
78
|
+
try {
|
|
79
|
+
const parsed = JSON.parse(trimmed);
|
|
80
|
+
return Array.isArray(parsed) ? parsed : [parsed];
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return [trimmed]; // not JSON after all: treat the whole text as one concept name
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return trimmed.split(',').map((s) => s.trim()).filter(Boolean);
|
|
87
|
+
}
|
|
88
|
+
return typeof raw === 'object' ? [raw] : [];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A record reference `{ EntityName, RecordID }` (either key casing) from a plain object, or
|
|
92
|
+
* `undefined` when the object does not carry both.
|
|
93
|
+
*/
|
|
94
|
+
export function ParseGraphRecordRef(item) {
|
|
95
|
+
if (!IsPlainObject(item)) {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
const entityName = readText(item, 'EntityName', 'entityName');
|
|
99
|
+
const recordId = readText(item, 'RecordID', 'recordId');
|
|
100
|
+
if (!entityName || !recordId) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
const entityId = typeof item['EntityID'] === 'string' ? item['EntityID'] : undefined;
|
|
104
|
+
return { EntityName: entityName, RecordID: recordId, EntityID: entityId };
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* One end of a path from an action parameter: a record object, a JSON string of one, a concept
|
|
108
|
+
* object (`{ Concept }`), or plain text naming a concept (its name, a synonym, or its ID).
|
|
109
|
+
*/
|
|
110
|
+
export function ParseGraphEndpoint(raw) {
|
|
111
|
+
if (typeof raw === 'string' && !raw.trim().startsWith('{')) {
|
|
112
|
+
return raw.trim() ? { Concept: raw.trim() } : undefined; // plain text names one concept, commas and all
|
|
113
|
+
}
|
|
114
|
+
const item = ParseGraphActionItemList(raw)[0];
|
|
115
|
+
if (typeof item === 'string') {
|
|
116
|
+
return item.trim() ? { Concept: item.trim() } : undefined;
|
|
117
|
+
}
|
|
118
|
+
const record = ParseGraphRecordRef(item);
|
|
119
|
+
if (record) {
|
|
120
|
+
return { EntityName: record.EntityName, RecordID: record.RecordID };
|
|
121
|
+
}
|
|
122
|
+
if (IsPlainObject(item)) {
|
|
123
|
+
const concept = readText(item, 'Concept', 'concept');
|
|
124
|
+
return concept ? { Concept: concept } : undefined;
|
|
125
|
+
}
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
/** Ambiguous concept candidates as plain rows an agent can read and pick from. */
|
|
129
|
+
export function DescribeConceptCandidates(candidates) {
|
|
130
|
+
return candidates.map((c) => ({ Name: c.Node.Label, RecordID: c.Node.RecordID, Description: c.Node.Description, Score: c.Score }));
|
|
131
|
+
}
|
|
132
|
+
/** Set (or replace) the output parameter `name`. */
|
|
133
|
+
export function SetGraphActionOutput(params, name, value) {
|
|
134
|
+
if (!params.Params) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const lower = name.trim().toLowerCase();
|
|
138
|
+
const existing = params.Params.find((p) => p.Name.trim().toLowerCase() === lower && p.Type === 'Output');
|
|
139
|
+
if (existing) {
|
|
140
|
+
existing.Value = value;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
params.Params.push({ Name: name, Value: value, Type: 'Output' });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function parseJsonArray(text) {
|
|
147
|
+
try {
|
|
148
|
+
const parsed = JSON.parse(text);
|
|
149
|
+
return Array.isArray(parsed) ? parsed : undefined;
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return undefined; // caller falls back to a comma split
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function readText(item, ...keys) {
|
|
156
|
+
for (const key of keys) {
|
|
157
|
+
const value = item[key];
|
|
158
|
+
if (value != null && String(value).trim()) {
|
|
159
|
+
return String(value).trim();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return '';
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=graph-action-params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-action-params.js","sourceRoot":"","sources":["../../../src/custom/data/graph-action-params.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;;;GAIG;AAEH,gFAAgF;AAChF,MAAM,UAAU,mBAAmB,CAAC,MAAuB,EAAE,IAAY;IACrE,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACxC,OAAO,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,EAAE,KAAK,CAAC;AACpF,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,oBAAoB,CAAC,MAAuB,EAAE,IAAY;IACtE,MAAM,KAAK,GAAG,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACvD,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9C,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,oBAAoB,CAAC,MAAuB,EAAE,IAAY,EAAE,YAAoB;IAC5F,MAAM,KAAK,GAAG,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAChD,MAAM,GAAG,GAAG,KAAK,IAAI,IAAI,IAAI,KAAK,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AC,CAAC,CAAC,SAAS,CAAC;IACtD,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,SAAS,CAAC,CAAC,qCAAqC;IAC3D,CAAC;AACL,CAAC;AAED,SAAS,QAAQ,CAAC,IAA6B,EAAE,GAAG,IAAc;IAC9D,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACrB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YACxC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;QAChC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSTI defense for the Data Mapper action. The mapping template is CALLER-supplied (including by
|
|
3
|
+
* AI agents through tool calls) and full Nunjucks is not a sandbox: template code that reaches a
|
|
4
|
+
* function constructor runs arbitrary JavaScript inside the server process. Data mapping needs
|
|
5
|
+
* property paths, filters and control flow, so a template is refused when it:
|
|
6
|
+
* - names `constructor`, `__proto__` or `prototype` anywhere, in code or in static text;
|
|
7
|
+
* - reads a member whose name is computed (`x[expr]`), which could build those names at run time
|
|
8
|
+
* (numeric indexes and fixed names, `x[0]` and `x["first name"]`, are allowed);
|
|
9
|
+
* - loads another template (include / import / from / extends).
|
|
10
|
+
*
|
|
11
|
+
* The template is checked on the syntax tree from nunjucks' own parser, the one that compiles it
|
|
12
|
+
* for rendering. Scanning the text for `{{ ... }}` instead disagrees with that parser whenever a
|
|
13
|
+
* string literal contains `}}`, and code hidden behind such a literal would go unchecked.
|
|
14
|
+
*
|
|
15
|
+
* @throws Error when the template is refused, or when it is not valid Nunjucks.
|
|
16
|
+
*/
|
|
17
|
+
export declare function AssertMappingTemplateSafe(template: string): void;
|
|
18
|
+
//# sourceMappingURL=mapping-template-guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapping-template-guard.d.ts","sourceRoot":"","sources":["../../../src/custom/data/mapping-template-guard.ts"],"names":[],"mappings":"AAmDA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAUhE"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import nunjucks from "nunjucks";
|
|
2
|
+
const { parser, nodes } = nunjucks;
|
|
3
|
+
/**
|
|
4
|
+
* Property names that lead from any value to JavaScript internals: `x.constructor.constructor`
|
|
5
|
+
* is the Function constructor, and a bare `constructor` resolves on the render context itself.
|
|
6
|
+
*/
|
|
7
|
+
const INTERNAL_PROPERTY_NAMES = new Set(['constructor', '__proto__', 'prototype']);
|
|
8
|
+
const INTERNALS_REASON = 'access to JavaScript object internals (constructor/__proto__/prototype)';
|
|
9
|
+
/**
|
|
10
|
+
* SSTI defense for the Data Mapper action. The mapping template is CALLER-supplied (including by
|
|
11
|
+
* AI agents through tool calls) and full Nunjucks is not a sandbox: template code that reaches a
|
|
12
|
+
* function constructor runs arbitrary JavaScript inside the server process. Data mapping needs
|
|
13
|
+
* property paths, filters and control flow, so a template is refused when it:
|
|
14
|
+
* - names `constructor`, `__proto__` or `prototype` anywhere, in code or in static text;
|
|
15
|
+
* - reads a member whose name is computed (`x[expr]`), which could build those names at run time
|
|
16
|
+
* (numeric indexes and fixed names, `x[0]` and `x["first name"]`, are allowed);
|
|
17
|
+
* - loads another template (include / import / from / extends).
|
|
18
|
+
*
|
|
19
|
+
* The template is checked on the syntax tree from nunjucks' own parser, the one that compiles it
|
|
20
|
+
* for rendering. Scanning the text for `{{ ... }}` instead disagrees with that parser whenever a
|
|
21
|
+
* string literal contains `}}`, and code hidden behind such a literal would go unchecked.
|
|
22
|
+
*
|
|
23
|
+
* @throws Error when the template is refused, or when it is not valid Nunjucks.
|
|
24
|
+
*/
|
|
25
|
+
export function AssertMappingTemplateSafe(template) {
|
|
26
|
+
if (mentionsInternalProperty(template)) {
|
|
27
|
+
throw rejection(INTERNALS_REASON);
|
|
28
|
+
}
|
|
29
|
+
for (const node of walkSyntaxTree(parser.parse(template))) {
|
|
30
|
+
const reason = refusalReason(node);
|
|
31
|
+
if (reason) {
|
|
32
|
+
throw rejection(reason);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function rejection(reason) {
|
|
37
|
+
return new Error(`Mapping template rejected: ${reason} is not allowed in Data Mapper templates`);
|
|
38
|
+
}
|
|
39
|
+
/** Whole-template check, so the names are refused in static text as well as in code. */
|
|
40
|
+
function mentionsInternalProperty(template) {
|
|
41
|
+
return /\b(constructor|__proto__|prototype)\b/.test(template);
|
|
42
|
+
}
|
|
43
|
+
/** Why this node makes the template unsafe, or null when the node is fine. */
|
|
44
|
+
function refusalReason(node) {
|
|
45
|
+
if (isTemplateLoad(node)) {
|
|
46
|
+
return 'external template loading';
|
|
47
|
+
}
|
|
48
|
+
if (node instanceof nodes.LookupVal && !isFixedMemberName(node.val)) {
|
|
49
|
+
return 'computed member access (use dot paths, fixed names or numeric indexes)';
|
|
50
|
+
}
|
|
51
|
+
if (namesInternalProperty(node)) {
|
|
52
|
+
return INTERNALS_REASON;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
/** Node types that fetch another template through the environment's loaders. */
|
|
57
|
+
const TEMPLATE_LOAD_NODES = [
|
|
58
|
+
nodes.Include, nodes.Import, nodes.FromImport, nodes.Extends, nodes.CallExtension,
|
|
59
|
+
];
|
|
60
|
+
function isTemplateLoad(node) {
|
|
61
|
+
return TEMPLATE_LOAD_NODES.some(loadNode => node instanceof loadNode);
|
|
62
|
+
}
|
|
63
|
+
function isFixedMemberName(memberName) {
|
|
64
|
+
return memberName instanceof nodes.Literal
|
|
65
|
+
&& (typeof memberName.value === 'string' || typeof memberName.value === 'number');
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* True for a name or string literal that spells an internal property. Literals are compared after
|
|
69
|
+
* the lexer unescapes them, so `"con\structor"` is caught here although the text check misses it.
|
|
70
|
+
*/
|
|
71
|
+
function namesInternalProperty(node) {
|
|
72
|
+
if (node instanceof nodes.Symbol) {
|
|
73
|
+
return INTERNAL_PROPERTY_NAMES.has(node.value);
|
|
74
|
+
}
|
|
75
|
+
return node instanceof nodes.Literal
|
|
76
|
+
&& typeof node.value === 'string'
|
|
77
|
+
&& INTERNAL_PROPERTY_NAMES.has(node.value);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Yields every node under `root`. It follows each property rather than the `fields` list that
|
|
81
|
+
* nunjucks' own `findAll` uses: the body of a block `{% set %}` and the cases of a `{% switch %}`
|
|
82
|
+
* are not in `fields`, so `findAll` never visits the code inside them.
|
|
83
|
+
*/
|
|
84
|
+
function* walkSyntaxTree(root) {
|
|
85
|
+
const pending = [root];
|
|
86
|
+
while (pending.length > 0) {
|
|
87
|
+
const item = pending.pop();
|
|
88
|
+
if (item instanceof nodes.Node) {
|
|
89
|
+
yield item;
|
|
90
|
+
}
|
|
91
|
+
if (item) {
|
|
92
|
+
pending.push(...childObjects(item));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** The nodes, and arrays of nodes, held directly by a node or an array. */
|
|
97
|
+
function childObjects(parent) {
|
|
98
|
+
const children = [];
|
|
99
|
+
for (const value of Object.values(parent)) {
|
|
100
|
+
if (Array.isArray(value) || value instanceof nodes.Node) {
|
|
101
|
+
children.push(value);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return children;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=mapping-template-guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapping-template-guard.js","sourceRoot":"","sources":["../../../src/custom/data/mapping-template-guard.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAA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;YACP,OAAO,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;QACxC,CAAC;IACL,CAAC;AACL,CAAC;AAED,2EAA2E;AAC3E,SAAS,YAAY,CAAC,MAAc;IAChC,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QACxC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY,KAAK,CAAC,IAAI,EAAE,CAAC;YACtD,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
2
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
3
|
+
import { type DomainProposal } from '@memberjunction/core-entities';
|
|
4
|
+
/** Result returned by {@link ProposeCanonDomainsAction}. */
|
|
5
|
+
export interface ProposeCanonDomainsActionResult extends ActionResultSimple {
|
|
6
|
+
Proposals?: DomainProposal[];
|
|
7
|
+
ConceptsCreated?: number;
|
|
8
|
+
EdgesCreated?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Action `Propose Canon Domains`: groups entities into candidate business domains by community
|
|
12
|
+
* detection over their foreign-key and IS-A links (deterministic, no AI call), through
|
|
13
|
+
* {@link CanonGraphEngine.ProposeDomainConcepts}.
|
|
14
|
+
*
|
|
15
|
+
* With `DryRun` (the default) it only returns the proposals. With `DryRun = false` it writes each as
|
|
16
|
+
* a `Proposed` `Domain` concept with `Inferred` + `Proposed` `Describes` edges from its member
|
|
17
|
+
* entities, for a person to rename, approve or reject. A domain name already in the graph is never
|
|
18
|
+
* proposed again, so a rejected proposal stays rejected.
|
|
19
|
+
*/
|
|
20
|
+
export declare class ProposeCanonDomainsAction extends BaseAction {
|
|
21
|
+
private static readonly DEFAULT_GRAPH_NAME;
|
|
22
|
+
protected InternalRunAction(params: RunActionParams): Promise<ProposeCanonDomainsActionResult>;
|
|
23
|
+
private readOptions;
|
|
24
|
+
private summarize;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=propose-canon-domains.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propose-canon-domains.action.d.ts","sourceRoot":"","sources":["../../../src/custom/data/propose-canon-domains.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAKH,KAAK,cAAc,EAEtB,MAAM,+BAA+B,CAAC;AAWvC,4DAA4D;AAC5D,MAAM,WAAW,+BAAgC,SAAQ,kBAAkB;IACvE,SAAS,CAAC,EAAE,cAAc,EAAE,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;GASG;AACH,qBACa,yBAA0B,SAAQ,UAAU;IACrD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAc;cAExC,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,+BAA+B,CAAC;IAuDpG,OAAO,CAAC,WAAW;IAiBnB,OAAO,CAAC,SAAS;CAIpB"}
|
|
@@ -0,0 +1,105 @@
|
|
|
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
|
+
var ProposeCanonDomainsAction_1;
|
|
8
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
9
|
+
import { LogError, Metadata } from '@memberjunction/core';
|
|
10
|
+
import { CanonGraphEngine, DomainProposalSaveError, GraphEngine, SaveDomainProposals, } from '@memberjunction/core-entities';
|
|
11
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
12
|
+
import { GetGraphActionBoolean, GetGraphActionNumber, GetGraphActionParam, GetGraphActionString, ParseGraphActionStringList, SetGraphActionOutput, } from './graph-action-params.js';
|
|
13
|
+
/**
|
|
14
|
+
* Action `Propose Canon Domains`: groups entities into candidate business domains by community
|
|
15
|
+
* detection over their foreign-key and IS-A links (deterministic, no AI call), through
|
|
16
|
+
* {@link CanonGraphEngine.ProposeDomainConcepts}.
|
|
17
|
+
*
|
|
18
|
+
* With `DryRun` (the default) it only returns the proposals. With `DryRun = false` it writes each as
|
|
19
|
+
* a `Proposed` `Domain` concept with `Inferred` + `Proposed` `Describes` edges from its member
|
|
20
|
+
* entities, for a person to rename, approve or reject. A domain name already in the graph is never
|
|
21
|
+
* proposed again, so a rejected proposal stays rejected.
|
|
22
|
+
*/
|
|
23
|
+
let ProposeCanonDomainsAction = class ProposeCanonDomainsAction extends BaseAction {
|
|
24
|
+
static { ProposeCanonDomainsAction_1 = this; }
|
|
25
|
+
static { this.DEFAULT_GRAPH_NAME = 'MJ Canon'; }
|
|
26
|
+
async InternalRunAction(params) {
|
|
27
|
+
try {
|
|
28
|
+
if (!params.ContextUser) {
|
|
29
|
+
return { Success: false, ResultCode: 'MISSING_PARAMETER', Message: 'ContextUser is required to run Propose Canon Domains.' };
|
|
30
|
+
}
|
|
31
|
+
const provider = params.Provider ?? Metadata.Provider;
|
|
32
|
+
await CanonGraphEngine.Instance.EnsureConfigured(params.ContextUser, provider);
|
|
33
|
+
const graphName = GetGraphActionString(params, 'GraphName') ?? ProposeCanonDomainsAction_1.DEFAULT_GRAPH_NAME;
|
|
34
|
+
const graph = GraphEngine.Instance.GetGraph(graphName);
|
|
35
|
+
if (!graph) {
|
|
36
|
+
return { Success: false, ResultCode: 'GRAPH_NOT_FOUND', Message: `Graph '${graphName}' was not found or is not active.` };
|
|
37
|
+
}
|
|
38
|
+
const proposals = await CanonGraphEngine.Instance.ProposeDomainConcepts(graph.Name, params.ContextUser, this.readOptions(params), provider);
|
|
39
|
+
SetGraphActionOutput(params, 'Proposals', proposals);
|
|
40
|
+
if (proposals.length === 0) {
|
|
41
|
+
return { Success: true, ResultCode: 'NO_PROPOSALS', Message: `No new domains to propose for '${graph.Name}'.`, Proposals: [] };
|
|
42
|
+
}
|
|
43
|
+
if (GetGraphActionBoolean(params, 'DryRun', true)) {
|
|
44
|
+
return { Success: true, ResultCode: 'SUCCESS', Message: this.summarize(proposals, 'Would propose'), Proposals: proposals };
|
|
45
|
+
}
|
|
46
|
+
const saved = await SaveDomainProposals(graph, proposals, params.ContextUser, provider);
|
|
47
|
+
SetGraphActionOutput(params, 'ConceptsCreated', saved.ConceptIDs.length);
|
|
48
|
+
SetGraphActionOutput(params, 'EdgesCreated', saved.EdgeCount);
|
|
49
|
+
return {
|
|
50
|
+
Success: true,
|
|
51
|
+
ResultCode: 'SUCCESS',
|
|
52
|
+
Message: `${this.summarize(proposals, 'Proposed')} They await review in '${graph.Name}'.`,
|
|
53
|
+
Proposals: proposals,
|
|
54
|
+
ConceptsCreated: saved.ConceptIDs.length,
|
|
55
|
+
EdgesCreated: saved.EdgeCount,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
60
|
+
LogError(`ProposeCanonDomainsAction failed: ${msg}`);
|
|
61
|
+
if (error instanceof DomainProposalSaveError) {
|
|
62
|
+
const conceptsCreated = error.Saved.ConceptIDs.length;
|
|
63
|
+
const edgesCreated = error.Saved.EdgeCount;
|
|
64
|
+
SetGraphActionOutput(params, 'ConceptsCreated', conceptsCreated);
|
|
65
|
+
SetGraphActionOutput(params, 'EdgesCreated', edgesCreated);
|
|
66
|
+
const partialNote = conceptsCreated > 0
|
|
67
|
+
? ` (${conceptsCreated} concept${conceptsCreated === 1 ? '' : 's'} and ${edgesCreated} edge${edgesCreated === 1 ? '' : 's'} saved before failure)`
|
|
68
|
+
: '';
|
|
69
|
+
return {
|
|
70
|
+
Success: false,
|
|
71
|
+
ResultCode: 'UNEXPECTED_ERROR',
|
|
72
|
+
Message: `Propose Canon Domains failed${partialNote}: ${msg}`,
|
|
73
|
+
ConceptsCreated: conceptsCreated,
|
|
74
|
+
EdgesCreated: edgesCreated,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return { Success: false, ResultCode: 'UNEXPECTED_ERROR', Message: `Propose Canon Domains failed: ${msg}` };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
readOptions(params) {
|
|
81
|
+
const options = { SchemaNames: ParseGraphActionStringList(GetGraphActionParam(params, 'SchemaNames')) };
|
|
82
|
+
const minSize = GetGraphActionNumber(params, 'MinClusterSize', NaN);
|
|
83
|
+
const maxDomains = GetGraphActionNumber(params, 'MaxDomains', NaN);
|
|
84
|
+
const resolution = GetGraphActionNumber(params, 'Resolution', NaN);
|
|
85
|
+
if (Number.isFinite(minSize)) {
|
|
86
|
+
options.MinClusterSize = Math.floor(minSize);
|
|
87
|
+
}
|
|
88
|
+
if (Number.isFinite(maxDomains)) {
|
|
89
|
+
options.MaxDomains = Math.floor(maxDomains);
|
|
90
|
+
}
|
|
91
|
+
if (Number.isFinite(resolution) && resolution > 0) {
|
|
92
|
+
options.Resolution = resolution;
|
|
93
|
+
}
|
|
94
|
+
return options;
|
|
95
|
+
}
|
|
96
|
+
summarize(proposals, verb) {
|
|
97
|
+
const lines = proposals.map((p) => `- ${p.Name}: ${p.Members.length} entities, ${Math.round(p.Cohesion * 100)}% cohesion`);
|
|
98
|
+
return `${verb} ${proposals.length} domain${proposals.length === 1 ? '' : 's'}:\n${lines.join('\n')}`;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
ProposeCanonDomainsAction = ProposeCanonDomainsAction_1 = __decorate([
|
|
102
|
+
RegisterClass(BaseAction, 'Propose Canon Domains')
|
|
103
|
+
], ProposeCanonDomainsAction);
|
|
104
|
+
export { ProposeCanonDomainsAction };
|
|
105
|
+
//# sourceMappingURL=propose-canon-domains.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propose-canon-domains.action.js","sourceRoot":"","sources":["../../../src/custom/data/propose-canon-domains.action.ts"],"names":[],"mappings":";;;;;;;AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EACH,gBAAgB,EAChB,uBAAuB,EACvB,WAAW,EACX,mBAAmB,GAGtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EACH,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,GACvB,MAAM,uBAAuB,CAAC;AAS/B;;;;;;;;;GASG;AAEI,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,UAAU;;aAC7B,uBAAkB,GAAG,UAAU,AAAb,CAAc;IAE9C,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;gBACtB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,OAAO,EAAE,uDAAuD,EAAE,CAAC;YACjI,CAAC;YACD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,I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D,OAAO,OAAO,CAAC;IACnB,CAAC;IAEO,SAAS,CAAC,SAAoC,EAAE,IAAY;QAChE,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,cAAc,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC;QAC3H,OAAO,GAAG,IAAI,IAAI,SAAS,CAAC,MAAM,UAAU,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1G,CAAC;;AA9EQ,yBAAyB;IADrC,aAAa,CAAC,UAAU,EAAE,uBAAuB,CAAC;GACtC,yBAAyB,CA+ErC"}
|
|
@@ -8,9 +8,9 @@ import { BaseAction } from "@memberjunction/actions";
|
|
|
8
8
|
* - Scope-limited sessions (magic-link and widget guests, resource-scoped links) are refused: raw SQL
|
|
9
9
|
* never applies the row-level filters that confine them.
|
|
10
10
|
* - The SQL runs only on the host's read-only database login
|
|
11
|
-
* (
|
|
11
|
+
* (`ActionEngineServer.GetReadOnlyProvider`), never on the read-write pool; with no read-only
|
|
12
12
|
* login configured the action refuses.
|
|
13
|
-
* - The host's ad-hoc SQL checks (
|
|
13
|
+
* - The host's ad-hoc SQL checks (`ActionEngineServer.AdhocSQLAuthorizer`) must accept the SQL:
|
|
14
14
|
* MJServer registers ExecuteAdhocQuery's own check, so the SQL must be one read statement and every
|
|
15
15
|
* table it reads an entity view the caller may read in full. The host also limits the timeout.
|
|
16
16
|
* - It runs through the provider's ad-hoc read path (`RunQuery` with `SQL`), which accepts one read
|
|
@@ -18,6 +18,8 @@ import { BaseAction } from "@memberjunction/actions";
|
|
|
18
18
|
* limit in the database.
|
|
19
19
|
* - The dangerous-keyword screen (SQLExpressionValidator) runs first.
|
|
20
20
|
*
|
|
21
|
+
* These checks live in `CheckAdhocSQL` (adhoc-sql-gate.ts), shared with every action that runs caller SQL.
|
|
22
|
+
*
|
|
21
23
|
* Performance Features:
|
|
22
24
|
* - Configurable row limits to prevent overwhelming results
|
|
23
25
|
* - Execution time tracking
|
|
@@ -49,21 +51,8 @@ import { BaseAction } from "@memberjunction/actions";
|
|
|
49
51
|
*/
|
|
50
52
|
export declare class RunAdhocQueryAction extends BaseAction {
|
|
51
53
|
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
52
|
-
/**
|
|
53
|
-
* True when the session's read authority is narrower than its roles: an anonymous magic-link or
|
|
54
|
-
* widget guest, or a session pinned to one shared resource. The same test as MJServer's
|
|
55
|
-
* `IsScopeLimitedPrincipal`; a missing user fails closed.
|
|
56
|
-
*/
|
|
57
|
-
private isScopeLimitedPrincipal;
|
|
58
|
-
private permissionDenied;
|
|
59
54
|
/** The value when it is a positive number, else the default. */
|
|
60
55
|
private positiveOrDefault;
|
|
61
|
-
/** Maps the host's refusal of the SQL to the action's result codes. */
|
|
62
|
-
private authorizationRefusal;
|
|
63
|
-
/** The result code for SQL refused for its shape or for a function it calls; null for any other refusal. */
|
|
64
|
-
private statementRefusalCode;
|
|
65
|
-
/** Maps a failed run to the action's result codes. */
|
|
66
|
-
private queryFailure;
|
|
67
56
|
/** Column names and value types, read from the returned rows. */
|
|
68
57
|
private describeColumns;
|
|
69
58
|
private describeValueType;
|
|
@@ -105,12 +94,6 @@ export declare class RunAdhocQueryAction extends BaseAction {
|
|
|
105
94
|
* Get prompt by name and category from AIEngine
|
|
106
95
|
*/
|
|
107
96
|
private getPromptByNameAndCategory;
|
|
108
|
-
/**
|
|
109
|
-
* Normalize literal escape sequences in SQL strings.
|
|
110
|
-
* Agent-generated SQL sometimes arrives with literal \n (backslash + n)
|
|
111
|
-
* instead of actual newlines from double-escaped JSON.
|
|
112
|
-
*/
|
|
113
|
-
private normalizeSQLWhitespace;
|
|
114
97
|
/**
|
|
115
98
|
* Helper to get string parameter value
|
|
116
99
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-adhoc-query.action.d.ts","sourceRoot":"","sources":["../../../src/custom/data/run-adhoc-query.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,
|
|
1
|
+
{"version":3,"file":"run-adhoc-query.action.d.ts","sourceRoot":"","sources":["../../../src/custom/data/run-adhoc-query.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AASrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,qBACa,mBAAoB,SAAQ,UAAU;cAE/B,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAiMvF,gEAAgE;IAChE,OAAO,CAAC,iBAAiB;IAIzB,iEAAiE;IACjE,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,iBAAiB;IAOzB;;OAEG;IACH,OAAO,CAAC,0BAA0B;IA8BlC;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAwBnB;;OAEG;IACH,OAAO,CAAC,YAAY;IAIpB;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,qBAAqB;IA8B7B;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IAczB;;OAEG;YACW,gBAAgB;IA8D9B;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAOlC;;OAEG;IACH,OAAO,CAAC,cAAc;IAQtB;;OAEG;IACH,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,cAAc;IAWtB,iEAAiE;IACjE,OAAO,CAAC,oBAAoB;IAQ5B;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAiE/B"}
|