@memberjunction/actions-base 6.2.0-edge.4 → 6.2.0-edge.6

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.
Files changed (40) hide show
  1. package/dist/ActionAudience.d.ts +37 -0
  2. package/dist/ActionAudience.d.ts.map +1 -0
  3. package/dist/ActionAudience.js +48 -0
  4. package/dist/ActionAudience.js.map +1 -0
  5. package/dist/ActionEngine-Base.d.ts +112 -1
  6. package/dist/ActionEngine-Base.d.ts.map +1 -1
  7. package/dist/ActionEngine-Base.js +140 -5
  8. package/dist/ActionEngine-Base.js.map +1 -1
  9. package/dist/ActionParamFieldSecurity.d.ts +91 -0
  10. package/dist/ActionParamFieldSecurity.d.ts.map +1 -0
  11. package/dist/ActionParamFieldSecurity.js +226 -0
  12. package/dist/ActionParamFieldSecurity.js.map +1 -0
  13. package/dist/ParamRedaction.d.ts +2 -0
  14. package/dist/ParamRedaction.d.ts.map +1 -1
  15. package/dist/ParamRedaction.js +27 -2
  16. package/dist/ParamRedaction.js.map +1 -1
  17. package/dist/RuntimeActionBridgeBuilder.d.ts +13 -0
  18. package/dist/RuntimeActionBridgeBuilder.d.ts.map +1 -1
  19. package/dist/RuntimeActionBridgeBuilder.js.map +1 -1
  20. package/dist/__tests__/ActionAudience.test.d.ts +2 -0
  21. package/dist/__tests__/ActionAudience.test.d.ts.map +1 -0
  22. package/dist/__tests__/ActionAudience.test.js +52 -0
  23. package/dist/__tests__/ActionAudience.test.js.map +1 -0
  24. package/dist/__tests__/ActionEngine-Base.indexes.test.d.ts +2 -0
  25. package/dist/__tests__/ActionEngine-Base.indexes.test.d.ts.map +1 -0
  26. package/dist/__tests__/ActionEngine-Base.indexes.test.js +150 -0
  27. package/dist/__tests__/ActionEngine-Base.indexes.test.js.map +1 -0
  28. package/dist/__tests__/ActionEngine-Base.test.js +15 -1
  29. package/dist/__tests__/ActionEngine-Base.test.js.map +1 -1
  30. package/dist/__tests__/ActionParamFieldSecurity.test.d.ts +2 -0
  31. package/dist/__tests__/ActionParamFieldSecurity.test.d.ts.map +1 -0
  32. package/dist/__tests__/ActionParamFieldSecurity.test.js +178 -0
  33. package/dist/__tests__/ActionParamFieldSecurity.test.js.map +1 -0
  34. package/dist/__tests__/ParamRedaction.test.js +20 -0
  35. package/dist/__tests__/ParamRedaction.test.js.map +1 -1
  36. package/dist/index.d.ts +2 -0
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +2 -0
  39. package/dist/index.js.map +1 -1
  40. package/package.json +5 -5
@@ -0,0 +1,37 @@
1
+ import type { UserInfo } from "@memberjunction/core";
2
+ /**
3
+ * The people, besides the caller, who will see what an action returns — set on
4
+ * {@link RunActionParams.Audience} by an agent run that has an audience (`ExecuteAgentParams.Audience`).
5
+ *
6
+ * The same shape as `SearchParams.Audience` in `@memberjunction/search-engine`, declared here because this
7
+ * package does not depend on that one: an action that searches can pass it straight through.
8
+ */
9
+ export interface ActionRunAudience {
10
+ /**
11
+ * Readers besides the caller, as hydrated `UserInfo` objects (each with a non-empty `ID` and a
12
+ * `UserRoles` array). Listing the caller, or a reader twice, is harmless: the engine normalizes the
13
+ * list before the action runs (see {@link ActionAudienceReaders}).
14
+ */
15
+ Readers: UserInfo[];
16
+ }
17
+ /**
18
+ * The result code `ActionEngineServer.RunAction` returns, without running the action, when the run has an
19
+ * audience that adds a reader and the action has not declared it can honour one (`BaseAction.SupportsAudience`),
20
+ * or is a runtime-defined or deferred action. An agent treats it as fatal: the action is locked out for the run.
21
+ */
22
+ export declare const AUDIENCE_UNSUPPORTED_RESULT_CODE = "AUDIENCE_UNSUPPORTED";
23
+ /**
24
+ * The readers an audience adds beyond the caller: one per distinct `ID` (case-insensitive), the caller's own
25
+ * left out. `[]` when there is no audience or it adds nobody; `null` when it is malformed (`Readers` not an
26
+ * array, a reader that is not an object or has no `ID`), which callers treat as adding a reader, so a malformed
27
+ * audience never runs as if there were none.
28
+ *
29
+ * Takes `unknown`: hosts assemble the audience at runtime.
30
+ */
31
+ export declare function ActionAudienceReaders(audience: unknown, contextUser: UserInfo | undefined): UserInfo[] | null;
32
+ /**
33
+ * Whether an audience adds a reader beyond the caller — the condition under which an action that cannot honour
34
+ * an audience is refused. A malformed audience counts as adding one (fails closed).
35
+ */
36
+ export declare function ActionAudienceAddsReader(audience: unknown, contextUser: UserInfo | undefined): boolean;
37
+ //# sourceMappingURL=ActionAudience.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionAudience.d.ts","sourceRoot":"","sources":["../src/ActionAudience.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGrD;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAC/B;;;;OAIG;IACH,OAAO,EAAE,QAAQ,EAAE,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,gCAAgC,yBAAyB,CAAC;AAEvE;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,EAAE,GAAG,IAAI,CAc7G;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAGtG"}
@@ -0,0 +1,48 @@
1
+ import { UUIDSet } from "@memberjunction/global";
2
+ /**
3
+ * The result code `ActionEngineServer.RunAction` returns, without running the action, when the run has an
4
+ * audience that adds a reader and the action has not declared it can honour one (`BaseAction.SupportsAudience`),
5
+ * or is a runtime-defined or deferred action. An agent treats it as fatal: the action is locked out for the run.
6
+ */
7
+ export const AUDIENCE_UNSUPPORTED_RESULT_CODE = 'AUDIENCE_UNSUPPORTED';
8
+ /**
9
+ * The readers an audience adds beyond the caller: one per distinct `ID` (case-insensitive), the caller's own
10
+ * left out. `[]` when there is no audience or it adds nobody; `null` when it is malformed (`Readers` not an
11
+ * array, a reader that is not an object or has no `ID`), which callers treat as adding a reader, so a malformed
12
+ * audience never runs as if there were none.
13
+ *
14
+ * Takes `unknown`: hosts assemble the audience at runtime.
15
+ */
16
+ export function ActionAudienceReaders(audience, contextUser) {
17
+ if (audience === undefined)
18
+ return [];
19
+ const readers = audience !== null && typeof audience === 'object' && 'Readers' in audience ? audience.Readers : undefined;
20
+ if (!Array.isArray(readers))
21
+ return null;
22
+ const seen = new UUIDSet(contextUser?.ID ? [contextUser.ID] : []);
23
+ const distinct = [];
24
+ for (const reader of readers) {
25
+ if (!isIdentifiedReader(reader))
26
+ return null;
27
+ if (!seen.Has(reader.ID)) {
28
+ seen.Add(reader.ID);
29
+ distinct.push(reader);
30
+ }
31
+ }
32
+ return distinct;
33
+ }
34
+ /**
35
+ * Whether an audience adds a reader beyond the caller — the condition under which an action that cannot honour
36
+ * an audience is refused. A malformed audience counts as adding one (fails closed).
37
+ */
38
+ export function ActionAudienceAddsReader(audience, contextUser) {
39
+ const readers = ActionAudienceReaders(audience, contextUser);
40
+ return readers === null || readers.length > 0;
41
+ }
42
+ /** A reader object with a non-blank `ID`. Role hydration is the search engine's to validate. */
43
+ function isIdentifiedReader(reader) {
44
+ if (reader === null || typeof reader !== 'object' || !('ID' in reader))
45
+ return false;
46
+ return typeof reader.ID === 'string' && reader.ID.trim().length > 0;
47
+ }
48
+ //# sourceMappingURL=ActionAudience.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionAudience.js","sourceRoot":"","sources":["../src/ActionAudience.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAkBjD;;;;GAIG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,sBAAsB,CAAC;AAEvE;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAiB,EAAE,WAAiC;IACvF,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACtC,MAAM,OAAO,GAAG,QAAQ,K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CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AACvE,CAAC"}
@@ -1,7 +1,8 @@
1
- import { BaseEngine, IMetadataProvider, UserInfo } from "@memberjunction/core";
1
+ import { BaseEngine, BaseEntity, IMetadataProvider, UserInfo, BaseEnginePropertyConfig } from "@memberjunction/core";
2
2
  import { EntityChangeContext } from './EntityChangeContext.js';
3
3
  import { MJActionCategoryEntity, MJActionEntity, MJActionExecutionLogEntity, MJActionFilterEntity, MJActionLibraryEntity, MJActionParamEntity, MJActionResultCodeEntity, MJEntityActionEntity, MJEntityActionParamEntity } from "@memberjunction/core-entities";
4
4
  import { MJActionEntityExtended } from "./MJActionEntityExtended.js";
5
+ import type { ActionRunAudience } from "./ActionAudience.js";
5
6
  export declare class ActionLibrary {
6
7
  LibraryName: string;
7
8
  ItemsUsed: string[];
@@ -118,10 +119,26 @@ export declare class ActionResult {
118
119
  * A code that indicates the outcome of the action. Will be one of the possible ResultCodes enumerated in the MJActionResultCodeEntity
119
120
  */
120
121
  Result?: MJActionResultCodeEntity;
122
+ /**
123
+ * The result code as text: the action's own `ActionResultSimple.ResultCode`, or the code of a refusal the
124
+ * engine made without running the action ({@link AUDIENCE_UNSUPPORTED_RESULT_CODE}). Set whether or not it
125
+ * matches one of the action's metadata result codes — {@link Result} is that match, `undefined` when there is
126
+ * none. Absent when the run ended without a code (a timeout, an exception, a validation or filter refusal).
127
+ */
128
+ ResultCode?: string;
121
129
  /**
122
130
  * Whenever an action is executed a log entry is created. This log entry is stored in the database and can be used to track the execution of the action. This property contains the log entry object for the action that was run.
123
131
  */
124
132
  LogEntry?: MJActionExecutionLogEntity;
133
+ /**
134
+ * Resolves once every write queued so far for {@link LogEntry} has settled, so a dependent row (one with
135
+ * a foreign key to the log row) can be inserted safely. The engine writes the log row fire-and-forget,
136
+ * so `LogEntry.ID` is valid before the row exists. Absent when there is no `LogEntry`.
137
+ *
138
+ * Never rejects: a failed log write is already logged by the engine's save queue, and the awaiter must
139
+ * not throw because of it.
140
+ */
141
+ LogEntryPersisted?: Promise<void>;
125
142
  /**
126
143
  * Optional, a message an action can include that describes the outcome of the action. This is typically used to display a message to the user.
127
144
  */
@@ -152,6 +169,12 @@ export declare class ActionParam {
152
169
  * The type of the Action parameter. Input parameters are used to pass data into the action while output parameters are used to return data from the action.
153
170
  */
154
171
  Type: 'Input' | 'Output' | 'Both';
172
+ /**
173
+ * True when the value was fixed by the caller of an agent run rather than chosen by the model
174
+ * (`ExecuteAgentParams.boundActionParams`). The marker is written into the execution log's `Params`
175
+ * so an audit can tell a bound value from a chosen one. Absent on every other parameter.
176
+ */
177
+ Bound?: boolean;
155
178
  }
156
179
  /**
157
180
  * Where an action run came from, when it was dispatched by an Entity Action binding rather than
@@ -314,6 +337,35 @@ export declare class RunActionParams<TContext = any> {
314
337
  * platform's keys inside a run restricted to the caller's.
315
338
  */
316
339
  CredentialScope?: RuntimeCredentialScope;
340
+ /**
341
+ * Everyone besides {@link ContextUser} who will see what this action returns — set by BaseAgent, per
342
+ * dispatch, from the agent run's audience (`ExecuteAgentParams.Audience`) when it adds a reader. Not on
343
+ * {@link Context}, for the reason {@link RuntimeAPIKeyResolver} is not: the context is the agent's own
344
+ * object, shared by every action in the run. The model cannot set it.
345
+ *
346
+ * **The engine gates on it.** When it adds a reader beyond the caller, `ActionEngineServer.RunAction`
347
+ * refuses — result code {@link AUDIENCE_UNSUPPORTED_RESULT_CODE}, without running the action or writing an
348
+ * execution log row — any action whose class does not declare `SupportsAudience`, and every runtime-defined
349
+ * or deferred action. For an action it lets through, it first normalizes this to the distinct readers
350
+ * beyond the caller ({@link ActionAudienceReaders}), and clears it when the audience adds nobody, so an
351
+ * action may treat "present" as "there is a room" and `Readers` as exactly the people to check.
352
+ *
353
+ * An action that declares support must return only what every reader may see: pass the audience to the
354
+ * search engine (`SearchParams.Audience`), check each reader's entitlement to anything it scopes by, and
355
+ * leave out counts or other aggregates computed before that filtering.
356
+ */
357
+ Audience?: ActionRunAudience;
358
+ /**
359
+ * The agent run's scope — its tenant (`PrimaryScopeRecordID`) and secondary dimensions — set by BaseAgent on
360
+ * every dispatch inside an agent run, from the run's validated scope (`ExecuteAgentParams.PrimaryScope*` /
361
+ * `SecondaryScopes`, as written to the `MJ: AI Agent Runs` row). Fields are `null` when the run is unscoped;
362
+ * the object itself is ABSENT outside an agent run. Per dispatch and not on {@link Context}, for the reason
363
+ * {@link Audience} is not: the context is the agent's own object. The model cannot set it.
364
+ *
365
+ * An action that scopes by tenant must treat it as authoritative over its own parameters, which inside a Loop
366
+ * agent are model-written: default a missing tenant to the run's, and refuse one the run does not carry.
367
+ */
368
+ RunScope?: ActionRunScope;
317
369
  /**
318
370
  * Optional AbortSignal that is aborted when the action exceeds its wall-clock
319
371
  * time budget (set via `Action.MaxExecutionTimeMS` or the engine default). Set
@@ -400,6 +452,33 @@ export declare class ActionEngineBase extends BaseEngine<ActionEngineBase> {
400
452
  * Returns the root category ID for core actions.
401
453
  */
402
454
  get CoreActionsRootCategoryID(): string;
455
+ private _indexedActionsRef?;
456
+ private _actionsByName;
457
+ private _indexedCategoriesRef?;
458
+ private _categoriesById;
459
+ private _indexedParamsRef?;
460
+ private _paramsByActionId;
461
+ private _indexedResultCodesRef?;
462
+ private _resultCodesByActionId;
463
+ /**
464
+ * Marks every lookup index stale so the next lookup rebuilds it.
465
+ *
466
+ * The ref-and-size checks in the `ensure*Index` methods catch a reloaded array, but not a save or
467
+ * delete that {@link BaseEngine} applies in place: replacing an element (an update) keeps both the
468
+ * reference and the length, so a param whose `LogValue` changed or an action that was renamed would
469
+ * keep resolving to the old entity until restart.
470
+ */
471
+ private invalidateLookupIndexes;
472
+ /** Invalidates the lookup indexes before DataChange$ subscribers run, since they may call a lookup. */
473
+ protected NotifyDataChange(config: BaseEnginePropertyConfig, data: unknown[], changeType?: 'refresh' | 'add' | 'update' | 'delete', affectedEntity?: BaseEntity): void;
474
+ /** Invalidates the lookup indexes on every in-place array mutation BaseEngine applies. */
475
+ protected emitPropertyChange(propertyName: string): void;
476
+ private ensureActionIndex;
477
+ private ensureCategoryIndex;
478
+ private ensureParamsIndex;
479
+ private ensureResultCodesIndex;
480
+ GetParamsByActionID(actionId: string): MJActionParamEntity[];
481
+ GetResultCode(actionId: string, resultCode: string): MJActionResultCodeEntity | undefined;
403
482
  /**
404
483
  * Utility method that determines if a given Action Category ID is a child of the specified parent category ID.
405
484
  * @param categoryId - The ID of the category to check.
@@ -451,4 +530,36 @@ export type RuntimeAPIKeyResolver = (driverClass: string) => string | undefined;
451
530
  * does not depend on that one.
452
531
  */
453
532
  export type RuntimeCredentialScope = 'Any' | 'RuntimeOnly';
533
+ /**
534
+ * One secondary scope dimension's value. The same union as `SecondaryScopeValue` in
535
+ * `@memberjunction/ai-core-plus`, declared here because that package depends on this one.
536
+ *
537
+ * Nothing here ties the two together; the compiler does only where code converts one into the other, and each
538
+ * conversion guards one direction. In `@memberjunction/ai-agents`, BaseAgent assigns `SecondaryScopeValue` records
539
+ * into {@link ActionRunScope} (so a value added to `SecondaryScopeValue` alone fails there) and passes the run's
540
+ * {@link ActionRunScope} back into its memory, RAG and scoped-prompt inputs, typed `SecondaryScopeValue` (so a value
541
+ * added here alone fails there). Scoped Search in `@memberjunction/core-actions` makes the second conversion too.
542
+ * Removing those conversions removes the guard: keep the two unions identical by hand.
543
+ */
544
+ export type ActionRunScopeValue = string | number | boolean | string[];
545
+ /**
546
+ * An agent run's scope, as BaseAgent hands it to each action dispatch ({@link RunActionParams.RunScope}).
547
+ * `null` fields mean the run carries no such scope; the whole object is absent outside an agent run.
548
+ */
549
+ export interface ActionRunScope {
550
+ /** The primary scope entity's name (e.g. `'Organizations'`), or `null` when the run names none. */
551
+ PrimaryScopeEntityName?: string | null;
552
+ /** The run's tenant: the record ID within the primary scope entity, or `null` when the run has none. */
553
+ PrimaryScopeRecordID: string | null;
554
+ /** The run's secondary dimensions (with the agent's configured defaults applied), or `null` when it has none. */
555
+ SecondaryScopes?: Record<string, ActionRunScopeValue> | null;
556
+ }
557
+ /**
558
+ * Whether an agent run's scope bounds what the run may reach: it carries a tenant (a non-blank
559
+ * `PrimaryScopeRecordID`) or at least one secondary dimension. `false` outside an agent run (`undefined`) and for an
560
+ * unscoped run's nulls; a primary entity name alone bounds nothing. The one predicate for "this run is
561
+ * tenant-scoped": BaseAgent withholds work that would run outside the scope (task graphs) when it holds, and an
562
+ * action that searches without a tenant (the Search action) refuses to run.
563
+ */
564
+ export declare function ActionRunScopeIsBounded(scope: ActionRunScope | null | undefined): boolean;
454
565
  //# sourceMappingURL=ActionEngine-Base.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ActionEngine-Base.d.ts","sourceRoot":"","sources":["../src/ActionEngine-Base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,QAAQ,EAAqC,MAAM,sBAAsB,CAAC;AAClH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAChQ,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,qBAAa,aAAa;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,aAAa;IACtB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,aAAa,EAAE,aAAa,EAAE,CAAC;IAC/B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,WAAW;IACxB,4D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AAG,sBAAsB,GAAG,SAAS;IAQ9E;;;;OAIG;cACa,cAAc,CAAC,QAAQ,GAAG,GAAG,EAAE,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;CAGrG;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,WAAW,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,aAAa,CAAC;AAE3D;;;;;;;;;;GAUG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,CAAC;AAEvE;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC5B,mGAAmG;IACnG,sBAAsB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,wGAAwG;IACxG,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,iHAAiH;IACjH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,IAAI,CAAC;CAC/D;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAMzF"}
@@ -74,6 +74,10 @@ export class ActionEngineBase extends BaseEngine {
74
74
  super(...arguments);
75
75
  this.__coreRootCategoryID = '15E03732-607E-4125-86F4-8C846EE88749'; // UUID within MJ forever for the ROOT category of System Actions
76
76
  this._ActionLibraries = []; // case-violation-ok-legacy-back-compat: the name is also a string literal that resolves this member at runtime, so renaming it breaks the lookup
77
+ this._actionsByName = new Map();
78
+ this._categoriesById = new Map();
79
+ this._paramsByActionId = new Map();
80
+ this._resultCodesByActionId = new Map();
77
81
  }
78
82
  /**
79
83
  * Returns the global instance of the class. This is a singleton class, so there is only one instance of it in the application. Do not directly create new instances of it, always use this method to get the instance.
@@ -182,6 +186,117 @@ export class ActionEngineBase extends BaseEngine {
182
186
  get CoreActionsRootCategoryID() {
183
187
  return this.__coreRootCategoryID;
184
188
  }
189
+ /**
190
+ * Marks every lookup index stale so the next lookup rebuilds it.
191
+ *
192
+ * The ref-and-size checks in the `ensure*Index` methods catch a reloaded array, but not a save or
193
+ * delete that {@link BaseEngine} applies in place: replacing an element (an update) keeps both the
194
+ * reference and the length, so a param whose `LogValue` changed or an action that was renamed would
195
+ * keep resolving to the old entity until restart.
196
+ */
197
+ invalidateLookupIndexes() {
198
+ this._indexedActionsRef = undefined;
199
+ this._indexedCategoriesRef = undefined;
200
+ this._indexedParamsRef = undefined;
201
+ this._indexedResultCodesRef = undefined;
202
+ }
203
+ /** Invalidates the lookup indexes before DataChange$ subscribers run, since they may call a lookup. */
204
+ NotifyDataChange(config, data, changeType = 'refresh', affectedEntity) {
205
+ this.invalidateLookupIndexes();
206
+ super.NotifyDataChange(config, data, changeType, affectedEntity);
207
+ }
208
+ /** Invalidates the lookup indexes on every in-place array mutation BaseEngine applies. */
209
+ emitPropertyChange(propertyName) {
210
+ this.invalidateLookupIndexes();
211
+ super.emitPropertyChange(propertyName);
212
+ }
213
+ ensureActionIndex() {
214
+ if (!this._Actions)
215
+ return;
216
+ if (this._indexedActionsRef === this._Actions && this._actionsByName.size === this._Actions.length)
217
+ return;
218
+ this._actionsByName.clear();
219
+ for (let i = 0; i < this._Actions.length; i++) {
220
+ const a = this._Actions[i];
221
+ if (a.Name) {
222
+ const key = a.Name.trim().toLowerCase();
223
+ if (!this._actionsByName.has(key)) {
224
+ this._actionsByName.set(key, a);
225
+ }
226
+ }
227
+ }
228
+ this._indexedActionsRef = this._Actions;
229
+ }
230
+ ensureCategoryIndex() {
231
+ if (!this._ActionCategories)
232
+ return;
233
+ if (this._indexedCategoriesRef === this._ActionCategories && this._categoriesById.size === this._ActionCategories.length)
234
+ return;
235
+ this._categoriesById.clear();
236
+ for (let i = 0; i < this._ActionCategories.length; i++) {
237
+ const c = this._ActionCategories[i];
238
+ if (c.ID) {
239
+ this._categoriesById.set(c.ID.trim().toLowerCase(), c);
240
+ }
241
+ }
242
+ this._indexedCategoriesRef = this._ActionCategories;
243
+ }
244
+ ensureParamsIndex() {
245
+ if (!this._Params)
246
+ return;
247
+ if (this._indexedParamsRef === this._Params)
248
+ return;
249
+ this._paramsByActionId.clear();
250
+ for (let i = 0; i < this._Params.length; i++) {
251
+ const p = this._Params[i];
252
+ if (p.ActionID) {
253
+ const key = p.ActionID.trim().toLowerCase();
254
+ let bucket = this._paramsByActionId.get(key);
255
+ if (!bucket) {
256
+ bucket = [];
257
+ this._paramsByActionId.set(key, bucket);
258
+ }
259
+ bucket.push(p);
260
+ }
261
+ }
262
+ this._indexedParamsRef = this._Params;
263
+ }
264
+ ensureResultCodesIndex() {
265
+ if (!this._ActionResultCodes)
266
+ return;
267
+ if (this._indexedResultCodesRef === this._ActionResultCodes)
268
+ return;
269
+ this._resultCodesByActionId.clear();
270
+ for (let i = 0; i < this._ActionResultCodes.length; i++) {
271
+ const r = this._ActionResultCodes[i];
272
+ if (r.ActionID) {
273
+ const key = r.ActionID.trim().toLowerCase();
274
+ let bucket = this._resultCodesByActionId.get(key);
275
+ if (!bucket) {
276
+ bucket = [];
277
+ this._resultCodesByActionId.set(key, bucket);
278
+ }
279
+ bucket.push(r);
280
+ }
281
+ }
282
+ this._indexedResultCodesRef = this._ActionResultCodes;
283
+ }
284
+ GetParamsByActionID(actionId) {
285
+ if (!actionId || !this._Params)
286
+ return [];
287
+ this.ensureParamsIndex();
288
+ return this._paramsByActionId.get(actionId.trim().toLowerCase()) ?? [];
289
+ }
290
+ GetResultCode(actionId, resultCode) {
291
+ if (!actionId || !resultCode || !this._ActionResultCodes)
292
+ return undefined;
293
+ this.ensureResultCodesIndex();
294
+ const bucket = this._resultCodesByActionId.get(actionId.trim().toLowerCase());
295
+ if (!bucket)
296
+ return undefined;
297
+ const target = resultCode.trim().toLowerCase();
298
+ return bucket.find(r => r.ResultCode.trim().toLowerCase() === target);
299
+ }
185
300
  /**
186
301
  * Utility method that determines if a given Action Category ID is a child of the specified parent category ID.
187
302
  * @param categoryId - The ID of the category to check.
@@ -192,15 +307,18 @@ export class ActionEngineBase extends BaseEngine {
192
307
  if (!categoryId || !parentCategoryId) {
193
308
  return false;
194
309
  }
195
- if (categoryId.trim().toLowerCase() === parentCategoryId.trim().toLowerCase()) {
310
+ const catKey = categoryId.trim().toLowerCase();
311
+ const parentKey = parentCategoryId.trim().toLowerCase();
312
+ if (catKey === parentKey) {
196
313
  return true;
197
314
  }
198
- const category = this._ActionCategories.find(c => c.ID.trim().toLowerCase() === categoryId.trim().toLowerCase());
199
- if (!category) {
315
+ this.ensureCategoryIndex();
316
+ const category = this._categoriesById.get(catKey);
317
+ if (!category || !category.ParentID) {
200
318
  return false;
201
319
  }
202
320
  // Check if the parent ID matches the parentCategoryId or if it is a child of the parentCategoryId
203
- if (category.ParentID?.trim().toLowerCase() === parentCategoryId.trim().toLowerCase()) {
321
+ if (category.ParentID.trim().toLowerCase() === parentKey) {
204
322
  return true;
205
323
  }
206
324
  // If the parent ID is not the parentCategoryId, recursively check the parent category
@@ -237,7 +355,8 @@ export class ActionEngineBase extends BaseEngine {
237
355
  if (!actionName || actionName.trim().length === 0) {
238
356
  throw new Error("Action name cannot be null or empty.");
239
357
  }
240
- return this.Actions.find(a => a.Name.trim().toLowerCase() === actionName.trim().toLowerCase());
358
+ this.ensureActionIndex();
359
+ return this._actionsByName.get(actionName.trim().toLowerCase());
241
360
  }
242
361
  /**
243
362
  * This method handles input validation. Subclasses can override this method to provide custom input validation.
@@ -248,4 +367,20 @@ export class ActionEngineBase extends BaseEngine {
248
367
  return true;
249
368
  }
250
369
  }
370
+ /**
371
+ * Whether an agent run's scope bounds what the run may reach: it carries a tenant (a non-blank
372
+ * `PrimaryScopeRecordID`) or at least one secondary dimension. `false` outside an agent run (`undefined`) and for an
373
+ * unscoped run's nulls; a primary entity name alone bounds nothing. The one predicate for "this run is
374
+ * tenant-scoped": BaseAgent withholds work that would run outside the scope (task graphs) when it holds, and an
375
+ * action that searches without a tenant (the Search action) refuses to run.
376
+ */
377
+ export function ActionRunScopeIsBounded(scope) {
378
+ if (!scope)
379
+ return false;
380
+ const tenant = scope.PrimaryScopeRecordID;
381
+ if (typeof tenant === 'string' && tenant.trim().length > 0)
382
+ return true;
383
+ const secondary = scope.SecondaryScopes;
384
+ return secondary !== null && typeof secondary === 'object' && Object.keys(secondary).length > 0;
385
+ }
251
386
  //# sourceMappingURL=ActionEngine-Base.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ActionEngine-Base.js","sourceRoot":"","sources":["../src/ActionEngine-Base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA+B,OAAO,EAA4B,MAAM,sBAAsB,CAAC;AAMlH,MAAM,OAAO,aAAa;CAGzB;AAED;;GAEG;AACH,MAAM,OAAO,aAAa;CAqBzB;AA8CD;;GAEG;AAEH,MAAM,OAAO,kBAAkB;CA4B9B;AAED;;GAEG;AACH,MAAM,OAAO,YAAY;CAoCxB;AAED;;GAEG;AACH,MAAM,OAAO,WAAW;CAavB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,0BAA0B;CAkCtC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,OAAO,eAAe;CA4I3B;AAAA,CAAC;AAGF;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,UAA4B;IAAlE;;QACW,yBAAoB,GAAG,sCAAsC,CAAC,CAAC,iEAAiE;QAc/H,qBAAgB,GAA4B,EAAE,CAAC,CAAE,iJAAiJ;IAiL9M,CAAC;IA7LE;;OAEG;IACI,MAAM,KAAK,QAAQ;QACvB,OAAO,KAAK,CAAC,WAAW,CAAmB,kBAAkB,CAAC,CAAC;IAClE,CAAC;IASD;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CAAC,eAAwB,KAAK,EAAE,WAAsB,EAAE,QAA4B;QACpG,MAAM,M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,IAAI,CAAC,yBAAyB,CAAC,CAAC;IAC7E,CAAC;IAED;;;;OAIG;IACI,eAAe,CAAC,UAAkB;QACtC,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC3D,CAAC;QACD,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;IACnE,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,cAAc,CAAiB,MAAiC;QAC7E,OAAO,IAAI,CAAC;IACf,CAAC;CACH;AAiDD;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAwC;IAC7E,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,MAAM,MAAM,GAAG,KAAK,CAAC,oBAAoB,CAAC;IAC1C,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACxE,MAAM,SAAS,GAAG,KAAK,CAAC,eAAe,CAAC;IACxC,OAAO,SAAS,KAAK,IAAI,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AACnG,CAAC"}
@@ -0,0 +1,91 @@
1
+ import { EntityInfo, RecordChangeMetadataSource, UserInfo } from "@memberjunction/core";
2
+ import { ActionParam } from "./ActionEngine-Base.js";
3
+ /**
4
+ * ============================================================================
5
+ * ACTION PARAMETER FIELD SECURITY — the backstop applied to action parameter
6
+ * values before they leave the server or are persisted.
7
+ * ============================================================================
8
+ *
9
+ * An action that loads its data as its context user hands back values that are
10
+ * already narrowed. This backstop covers the actions that do not: rows taken from
11
+ * an engine cache, loaded as the system user, or built before the user was known.
12
+ * It is applied for ONE principal — the one the values are about to reach.
13
+ *
14
+ * Two kinds of value are projected:
15
+ *
16
+ * 1. **Entity objects** (`BaseEntity`, at any depth up to
17
+ * {@link ACTION_PARAM_PROJECTION_MAX_DEPTH}; one nested deeper is returned
18
+ * untouched, like every deeper value) become their field values
19
+ * projected against their OWN entity for the given user, whatever user the
20
+ * object was loaded for — but only when the user may read that entity at all.
21
+ * An object of an entity the user cannot read is never turned into values;
22
+ * see {@link ProjectActionParamValuesOptions.UnreadableEntityObjects}.
23
+ * 2. **Plain objects that look like a row of an entity** the user is denied
24
+ * fields on. A plain object carries no entity type, so the match is
25
+ * deliberately conservative — see {@link IsEntityShapedRow}. When a row
26
+ * matches several such entities, the keys denied on ANY of them are removed.
27
+ *
28
+ * Only keys are ever REMOVED; no other value is rewritten. A user denied nothing
29
+ * on any entity with field security skips the row matching entirely, and a
30
+ * value with nothing to change is returned by reference.
31
+ *
32
+ * Shapes this does NOT project, so an action handing them back must load its
33
+ * data as its context user instead:
34
+ * - plain rows without their entity's primary key, or with too many extra keys;
35
+ * - values nested deeper than {@link ACTION_PARAM_PROJECTION_MAX_DEPTH};
36
+ * - objects with a `toJSON()` method, which serialize as whatever it returns;
37
+ * - instances of classes other than `BaseEntity`, returned untouched (a
38
+ * `CopyScalarsAndArrays` destination drops them; `JSON.stringify` writes
39
+ * their own properties);
40
+ * - JSON strings, and text such as `ActionResult.Message`.
41
+ * `Map` and `Set` serialize to `{}`, so they carry no values either way.
42
+ */
43
+ /**
44
+ * The share of a plain object's keys that must be field names of an entity for
45
+ * the object to be treated as a row of it. High enough that an object merely
46
+ * sharing `ID` and `Name` with an entity, among keys of its own, is left alone.
47
+ */
48
+ export declare const ENTITY_ROW_FIELD_KEY_RATIO = 0.8;
49
+ /**
50
+ * How deep into nested arrays and plain objects the backstop looks. Action
51
+ * output is a parameter value holding rows, or an envelope holding rows; a few
52
+ * levels cover both, and the limit bounds the walk over cyclic or very deep values.
53
+ */
54
+ export declare const ACTION_PARAM_PROJECTION_MAX_DEPTH = 6;
55
+ /**
56
+ * Options for {@link ProjectActionParamValuesForUser}.
57
+ */
58
+ export interface ProjectActionParamValuesOptions {
59
+ /**
60
+ * What becomes of an entity object whose entity the user may not read:
61
+ *
62
+ * - `'null'` (the default) replaces it with `null`, for a destination that would
63
+ * otherwise serialize the object's internal state, such as `JSON.stringify`.
64
+ * - `'keep'` returns it untouched, for a destination whose serializer already
65
+ * drops class instances (`CopyScalarsAndArrays`), so its output stays exactly
66
+ * what it was before entity objects were projected.
67
+ */
68
+ UnreadableEntityObjects?: 'null' | 'keep';
69
+ }
70
+ /**
71
+ * Action parameters with every value projected for `user` as described on this module.
72
+ *
73
+ * @param params The parameters, as an action returned them.
74
+ * @param user The principal the values are about to reach. When absent the values
75
+ * go to server-internal code, which field security trusts, and the parameters
76
+ * are returned unchanged.
77
+ * @param provider Metadata source for the entity list and the Record Changes payload
78
+ * projection. Defaults to the global provider.
79
+ * @param options See {@link ProjectActionParamValuesOptions}.
80
+ * @returns The original array when nothing changed; otherwise a new array whose
81
+ * changed parameters are copies. The input is never modified.
82
+ */
83
+ export declare function ProjectActionParamValuesForUser(params: ActionParam[] | null | undefined, user: UserInfo | null | undefined, provider?: RecordChangeMetadataSource | null, options?: ProjectActionParamValuesOptions): ActionParam[] | null | undefined;
84
+ /**
85
+ * True when `row` is treated as a row of `shape`'s entity: it carries every primary
86
+ * key field of the entity, and at least {@link ENTITY_ROW_FIELD_KEY_RATIO} of its
87
+ * keys are field names of the entity. Keys match by `Name` or `CodeName`, ignoring
88
+ * case and surrounding whitespace; the readable-fields transport marker is not counted.
89
+ */
90
+ export declare function IsEntityShapedRow(row: Record<string, unknown>, entity: EntityInfo): boolean;
91
+ //# sourceMappingURL=ActionParamFieldSecurity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionParamFieldSecurity.d.ts","sourceRoot":"","sources":["../src/ActionParamFieldSecurity.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,UAAU,EAKV,0BAA0B,EAC1B,QAAQ,EACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,IAAI,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC5C;;;;;;;;OAQG;IACH,uBAAuB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7C;AA4CD;;;;;;;;;;;;GAYG;AACH,wBAAgB,+BAA+B,CAC3C,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,GAAG,SAAS,EACxC,IAAI,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,EACjC,QAAQ,CAAC,EAAE,0BAA0B,GAAG,IAAI,EAC5C,OAAO,CAAC,EAAE,+BAA+B,GAC1C,WAAW,EAAE,GAAG,IAAI,GAAG,SAAS,CAYlC;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAG3F"}