@zvenigora/ng-eval-core 0.2.1 → 0.3.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.
Files changed (78) hide show
  1. package/README.md +160 -0
  2. package/fesm2022/zvenigora-ng-eval-core.mjs +1011 -48
  3. package/fesm2022/zvenigora-ng-eval-core.mjs.map +1 -1
  4. package/package.json +7 -7
  5. package/types/zvenigora-ng-eval-core.d.ts +1980 -0
  6. package/index.d.ts +0 -1
  7. package/lib/actual/services/base-eval.d.ts +0 -35
  8. package/lib/actual/services/compiler.service.d.ts +0 -96
  9. package/lib/actual/services/discovery.service.d.ts +0 -27
  10. package/lib/actual/services/eval.service.d.ts +0 -65
  11. package/lib/actual/services/index.d.ts +0 -1
  12. package/lib/actual/services/parser.service.d.ts +0 -57
  13. package/lib/actual/services/public-api.d.ts +0 -4
  14. package/lib/internal/classes/common/base-registry.d.ts +0 -84
  15. package/lib/internal/classes/common/cache.d.ts +0 -91
  16. package/lib/internal/classes/common/case-insensitive-registry.d.ts +0 -85
  17. package/lib/internal/classes/common/context.d.ts +0 -42
  18. package/lib/internal/classes/common/index.d.ts +0 -1
  19. package/lib/internal/classes/common/public-api.d.ts +0 -7
  20. package/lib/internal/classes/common/queue.d.ts +0 -33
  21. package/lib/internal/classes/common/registry.d.ts +0 -86
  22. package/lib/internal/classes/common/stack.d.ts +0 -60
  23. package/lib/internal/classes/eval/eval-context.d.ts +0 -93
  24. package/lib/internal/classes/eval/eval-lookup.d.ts +0 -2
  25. package/lib/internal/classes/eval/eval-options.d.ts +0 -6
  26. package/lib/internal/classes/eval/eval-result.d.ts +0 -105
  27. package/lib/internal/classes/eval/eval-scope.d.ts +0 -51
  28. package/lib/internal/classes/eval/eval-state.d.ts +0 -46
  29. package/lib/internal/classes/eval/eval-trace.d.ts +0 -20
  30. package/lib/internal/classes/eval/index.d.ts +0 -1
  31. package/lib/internal/classes/eval/parser-options.d.ts +0 -2
  32. package/lib/internal/classes/eval/public-api.d.ts +0 -8
  33. package/lib/internal/functions/compile.d.ts +0 -33
  34. package/lib/internal/functions/evaluate.d.ts +0 -17
  35. package/lib/internal/functions/extract.d.ts +0 -10
  36. package/lib/internal/functions/index.d.ts +0 -1
  37. package/lib/internal/functions/parse.d.ts +0 -15
  38. package/lib/internal/functions/public-api.d.ts +0 -4
  39. package/lib/internal/interfaces/cache-type.d.ts +0 -6
  40. package/lib/internal/interfaces/index.d.ts +0 -1
  41. package/lib/internal/interfaces/parser-types.d.ts +0 -7
  42. package/lib/internal/interfaces/public-api.d.ts +0 -7
  43. package/lib/internal/interfaces/queue-type.d.ts +0 -6
  44. package/lib/internal/interfaces/recursive-visitors.d.ts +0 -44
  45. package/lib/internal/interfaces/registry-type.d.ts +0 -67
  46. package/lib/internal/interfaces/scope-type.d.ts +0 -15
  47. package/lib/internal/interfaces/stack-type.d.ts +0 -6
  48. package/lib/internal/public-api.d.ts +0 -2
  49. package/lib/internal/visitors/after-visitor.d.ts +0 -3
  50. package/lib/internal/visitors/array-expression.d.ts +0 -5
  51. package/lib/internal/visitors/arrow-function-expression.d.ts +0 -4
  52. package/lib/internal/visitors/assignment-expression.d.ts +0 -4
  53. package/lib/internal/visitors/await-expression.d.ts +0 -4
  54. package/lib/internal/visitors/before-visitor.d.ts +0 -3
  55. package/lib/internal/visitors/binary-expression.d.ts +0 -7
  56. package/lib/internal/visitors/call-expression.d.ts +0 -8
  57. package/lib/internal/visitors/conditional-expression.d.ts +0 -4
  58. package/lib/internal/visitors/identifier.d.ts +0 -3
  59. package/lib/internal/visitors/import-expression.d.ts +0 -6
  60. package/lib/internal/visitors/index.d.ts +0 -1
  61. package/lib/internal/visitors/literal.d.ts +0 -3
  62. package/lib/internal/visitors/logical-expression.d.ts +0 -4
  63. package/lib/internal/visitors/member-expression.d.ts +0 -5
  64. package/lib/internal/visitors/new-expression.d.ts +0 -5
  65. package/lib/internal/visitors/object-expression.d.ts +0 -4
  66. package/lib/internal/visitors/pattern.d.ts +0 -6
  67. package/lib/internal/visitors/property-lookup-cache.d.ts +0 -21
  68. package/lib/internal/visitors/prototype-pollution-guard.d.ts +0 -46
  69. package/lib/internal/visitors/public-api.d.ts +0 -25
  70. package/lib/internal/visitors/recursive-visitors.d.ts +0 -7
  71. package/lib/internal/visitors/tagged-template-expression.d.ts +0 -4
  72. package/lib/internal/visitors/template-literal.d.ts +0 -4
  73. package/lib/internal/visitors/this-expression.d.ts +0 -3
  74. package/lib/internal/visitors/unary-expression.d.ts +0 -4
  75. package/lib/internal/visitors/update-expression.d.ts +0 -4
  76. package/lib/internal/visitors/utils.d.ts +0 -23
  77. package/lib/internal/visitors/visitor-result.d.ts +0 -6
  78. package/public-api.d.ts +0 -5
@@ -1,67 +0,0 @@
1
- /**
2
- * Represents a registry that stores key-value pairs.
3
- * @template TKey - The type of the keys in the registry.
4
- * @template TValue - The type of the values in the registry.
5
- */
6
- export interface RegistryType<TKey, TValue> extends Iterable<[TKey, TValue]> {
7
- type: Readonly<'Registry' | string>;
8
- options: Readonly<{
9
- caseInsensitive: boolean;
10
- } | Record<string, unknown>>;
11
- /**
12
- * Retrieves the value associated with the specified key.
13
- * @param key - The key to retrieve the value for.
14
- * @returns The value associated with the key, or undefined if the key does not exist.
15
- */
16
- get(key: TKey): TValue | undefined;
17
- /**
18
- * Sets the value for the specified key.
19
- * @param key - The key to set the value for.
20
- * @param value - The value to set.
21
- */
22
- set(key: TKey, value: TValue): void;
23
- /**
24
- * Checks if the registry contains the specified key.
25
- * @param key - The key to check.
26
- * @returns True if the registry contains the key, false otherwise.
27
- */
28
- has(key: TKey): boolean;
29
- /**
30
- * Deletes the key-value pair associated with the specified key.
31
- * @param key - The key to delete.
32
- * @returns True if the key-value pair was deleted, false if the key does not exist.
33
- */
34
- delete(key: TKey): boolean;
35
- /**
36
- * Clears all key-value pairs from the registry.
37
- */
38
- clear(): void;
39
- /**
40
- * Gets the number of key-value pairs in the registry.
41
- */
42
- readonly size: number;
43
- /**
44
- * Gets an iterator for the keys in the registry.
45
- */
46
- readonly keys: IterableIterator<TKey>;
47
- /**
48
- * Gets an iterator for the values in the registry.
49
- */
50
- readonly values: IterableIterator<TValue>;
51
- /**
52
- * Gets an iterator for the key-value pairs in the registry.
53
- */
54
- readonly entries: IterableIterator<[TKey, TValue]>;
55
- /**
56
- * Executes a provided function once for each key-value pair in the registry.
57
- * @param callbackfn - The function to execute for each key-value pair.
58
- * @param thisArg - Optional value to use as `this` when executing the callback function.
59
- */
60
- forEach(callbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void, thisArg?: unknown): void;
61
- /**
62
- * Returns an iterator for the entries of the registry.
63
- * @returns An iterator that yields key-value pairs of type [TKey, unknown].
64
- */
65
- [Symbol.iterator](): IterableIterator<[TKey, TValue]>;
66
- }
67
- export type RegistryEntries<TKey, TValue> = [TKey, TValue][] | Record<string | number | symbol, TValue>;
@@ -1,15 +0,0 @@
1
- import { RegistryType } from "./registry-type";
2
- export interface ScopeOptions {
3
- global?: boolean;
4
- caseInsensitive?: boolean;
5
- namespace?: string;
6
- }
7
- export interface RegistryOptionType<TKey, TValue> {
8
- registry: Readonly<RegistryType<TKey, TValue>>;
9
- options: Readonly<ScopeOptions>;
10
- }
11
- export interface ScopeType<TKey, TValue> {
12
- registries: RegistryOptionType<TKey, TValue>[];
13
- add: (registry: RegistryOptionType<TKey, TValue>) => void;
14
- get: (key: TKey, namespace?: string) => [TKey, TValue] | undefined;
15
- }
@@ -1,6 +0,0 @@
1
- export interface StackType<T> {
2
- peek(): T;
3
- pop(): T | undefined;
4
- push(value: T): number;
5
- swap(): void;
6
- }
@@ -1,2 +0,0 @@
1
- export * from './classes/common';
2
- export * from './interfaces';
@@ -1,3 +0,0 @@
1
- import { AnyNode } from 'acorn';
2
- import { EvalState } from '../classes/eval';
3
- export declare const afterVisitor: (node: AnyNode, st: EvalState) => number | undefined;
@@ -1,5 +0,0 @@
1
- import { AnyNode, ArrayExpression, Expression, SpreadElement } from 'acorn';
2
- import * as walk from 'acorn-walk';
3
- import { EvalState } from '../classes/eval';
4
- export declare const arrayExpressionVisitor: (node: ArrayExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => void;
5
- export declare const evaluateArray: (node: AnyNode, items: Array<Expression | SpreadElement | null>, st: EvalState, callback: walk.WalkerCallback<EvalState>) => unknown[];
@@ -1,4 +0,0 @@
1
- import { ArrowFunctionExpression } from 'acorn';
2
- import * as walk from 'acorn-walk';
3
- import { EvalState } from '../classes/eval';
4
- export declare const arrowFunctionExpressionVisitor: (node: ArrowFunctionExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => void;
@@ -1,4 +0,0 @@
1
- import { AssignmentExpression } from 'acorn';
2
- import * as walk from 'acorn-walk';
3
- import { EvalState } from '../classes/eval';
4
- export declare const assignmentExpressionVisitor: (node: AssignmentExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => void;
@@ -1,4 +0,0 @@
1
- import { AwaitExpression } from 'acorn';
2
- import * as walk from 'acorn-walk';
3
- import { EvalState } from '../classes/eval';
4
- export declare const awaitVisitor: (node: AwaitExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => void;
@@ -1,3 +0,0 @@
1
- import { AnyNode } from 'acorn';
2
- import { EvalState } from '../classes/eval';
3
- export declare const beforeVisitor: (node: AnyNode, st: EvalState) => number | undefined;
@@ -1,7 +0,0 @@
1
- import { BinaryExpression } from 'acorn';
2
- import * as walk from 'acorn-walk';
3
- import { EvalState } from '../classes/eval';
4
- /**
5
- * Safely evaluates binary expressions with proper type handling
6
- */
7
- export declare const binaryExpressionVisitor: (node: BinaryExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => void;
@@ -1,8 +0,0 @@
1
- import { CallExpression } from 'acorn';
2
- import * as walk from 'acorn-walk';
3
- import { EvalState } from '../classes/eval';
4
- /**
5
- * Enhanced call expression visitor with security checks
6
- */
7
- export declare const callExpressionVisitor: (node: CallExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => void;
8
- export declare const evaluateCall: (node: CallExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => unknown;
@@ -1,4 +0,0 @@
1
- import { ConditionalExpression } from 'acorn';
2
- import * as walk from 'acorn-walk';
3
- import { EvalState } from '../classes/eval';
4
- export declare const conditionalExpressionVisitor: (node: ConditionalExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => void;
@@ -1,3 +0,0 @@
1
- import { Identifier } from 'acorn';
2
- import { EvalState } from '../classes/eval';
3
- export declare const identifierVisitor: (node: Identifier, st: EvalState) => void;
@@ -1,6 +0,0 @@
1
- import { ImportExpression } from 'acorn';
2
- import { EvalState } from '../classes/eval';
3
- /**
4
- * ImportExpression visitor - blocks all dynamic imports for security
5
- */
6
- export declare const importExpressionVisitor: (node: ImportExpression, st: EvalState) => never;
@@ -1 +0,0 @@
1
- export * from './public-api';
@@ -1,3 +0,0 @@
1
- import { Literal } from 'acorn';
2
- import { EvalState } from '../classes/eval';
3
- export declare const literalVisitor: (node: Literal, st: EvalState) => void;
@@ -1,4 +0,0 @@
1
- import { LogicalExpression } from 'acorn';
2
- import * as walk from 'acorn-walk';
3
- import { EvalState } from '../classes/eval';
4
- export declare const logicalExpressionVisitor: (node: LogicalExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => void;
@@ -1,5 +0,0 @@
1
- import { MemberExpression } from 'acorn';
2
- import * as walk from 'acorn-walk';
3
- import { EvalState } from '../classes/eval';
4
- export declare const memberExpressionVisitor: (node: MemberExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => void;
5
- export declare const evaluateMember: (node: MemberExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => unknown[];
@@ -1,5 +0,0 @@
1
- import { NewExpression } from 'acorn';
2
- import * as walk from 'acorn-walk';
3
- import { EvalState } from '../classes/eval';
4
- export declare const newExpressionVisitor: (node: NewExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => void;
5
- export declare const newFunc: (constructor: (...a: unknown[]) => unknown, ...args: unknown[]) => unknown;
@@ -1,4 +0,0 @@
1
- import { ObjectExpression } from 'acorn';
2
- import * as walk from 'acorn-walk';
3
- import { EvalState } from '../classes/eval';
4
- export declare const objectExpressionVisitor: (node: ObjectExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => void;
@@ -1,6 +0,0 @@
1
- import { Pattern } from 'acorn';
2
- import * as walk from 'acorn-walk';
3
- import { EvalState } from '../classes/eval';
4
- import { BaseContext } from '../classes/common';
5
- export declare const evaluatePatterns: (patterns: Pattern[], st: EvalState, callback: walk.WalkerCallback<EvalState>, args: unknown[]) => BaseContext;
6
- export declare const evaluatePattern: (pattern: Pattern, st: EvalState, callback: walk.WalkerCallback<EvalState>, arg: unknown) => BaseContext;
@@ -1,21 +0,0 @@
1
- /**
2
- * Property Lookup Cache
3
- *
4
- * Provides efficient caching for case-insensitive property lookups
5
- * to avoid repeated O(n) searches through object property lists.
6
- */
7
- /**
8
- * Performs optimized case-insensitive property lookup with caching
9
- */
10
- export declare function getCachedCaseInsensitiveProperty(obj: Record<PropertyKey, unknown>, searchKey: string, equalIgnoreCase: (a: string, b: string) => boolean): string | null;
11
- /**
12
- * Clears the property lookup cache (for testing or memory management)
13
- */
14
- export declare function clearPropertyLookupCache(): void;
15
- /**
16
- * Gets current property lookup cache statistics
17
- */
18
- export declare function getPropertyLookupCacheStats(): {
19
- size: number;
20
- maxSize: number;
21
- };
@@ -1,46 +0,0 @@
1
- /**
2
- * Prototype Pollution Prevention Utilities
3
- *
4
- * This module provides safeguards against prototype pollution attacks
5
- * by controlling access to dangerous property names and ensuring safe
6
- * object operations.
7
- */
8
- /**
9
- * Checks if a property name is dangerous for prototype pollution
10
- * @param key The property name to check
11
- * @returns true if the property is dangerous, false otherwise
12
- */
13
- export declare const isDangerousProperty: (key: unknown) => boolean;
14
- /**
15
- * Checks if an object is a dangerous constructor that shouldn't be modified
16
- * @param obj The object to check
17
- * @returns true if the object is a dangerous constructor, false otherwise
18
- */
19
- export declare const isDangerousConstructor: (obj: unknown) => boolean;
20
- /**
21
- * Safely sets a property on an object with prototype pollution protection
22
- * @param target The target object
23
- * @param key The property key
24
- * @param value The property value
25
- * @throws Error if the operation would cause prototype pollution
26
- */
27
- export declare const safeSetProperty: (target: unknown, key: unknown, value: unknown) => void;
28
- /**
29
- * Safely gets a property from an object with prototype pollution protection
30
- * @param target The target object
31
- * @param key The property key
32
- * @returns The property value or undefined
33
- */
34
- export declare const safeGetProperty: (target: unknown, key: unknown) => unknown;
35
- /**
36
- * Creates a safe object without dangerous prototype pollution vectors
37
- * @param entries Key-value pairs to populate the object
38
- * @returns A new safe object
39
- */
40
- export declare const createSafeObject: (entries?: Array<[unknown, unknown]>) => Record<string, unknown>;
41
- /**
42
- * Validates that an object is safe from prototype pollution
43
- * @param obj The object to validate
44
- * @throws Error if the object contains dangerous properties
45
- */
46
- export declare const validateSafeObject: (obj: unknown) => void;
@@ -1,25 +0,0 @@
1
- export { pushVisitorResult, popVisitorResult, pushVisitorResultAsync, popVisitorResultAsync } from './visitor-result';
2
- export { beforeVisitor } from './before-visitor';
3
- export { afterVisitor } from './after-visitor';
4
- export { identifierVisitor } from './identifier';
5
- export { literalVisitor } from './literal';
6
- export { binaryExpressionVisitor } from './binary-expression';
7
- export { callExpressionVisitor } from './call-expression';
8
- export { importExpressionVisitor } from './import-expression';
9
- export { awaitVisitor } from './await-expression';
10
- export { conditionalExpressionVisitor } from './conditional-expression';
11
- export { memberExpressionVisitor, evaluateMember } from './member-expression';
12
- export { arrayExpressionVisitor, evaluateArray } from './array-expression';
13
- export { unaryExpressionVisitor } from './unary-expression';
14
- export { logicalExpressionVisitor } from './logical-expression';
15
- export { thisExpressionVisitor } from './this-expression';
16
- export { newExpressionVisitor } from './new-expression';
17
- export { templateLiteralVisitor } from './template-literal';
18
- export { taggedTemplateExpressionVisitor } from './tagged-template-expression';
19
- export { objectExpressionVisitor } from './object-expression';
20
- export { getDefaultVisitors } from './recursive-visitors';
21
- export { assignmentExpressionVisitor } from './assignment-expression';
22
- export { updateExpressionVisitor } from './update-expression';
23
- export { arrowFunctionExpressionVisitor } from './arrow-function-expression';
24
- export { evaluatePattern, evaluatePatterns } from './pattern';
25
- export { getKeyValue, equalIgnoreCase, getValueIgnoreCase } from './utils';
@@ -1,7 +0,0 @@
1
- import { EvalState } from '../classes/eval';
2
- import * as walk from 'acorn-walk';
3
- /**
4
- * Returns the default visitors for the recursive traversal of an abstract syntax tree.
5
- * @returns The default visitors object.
6
- */
7
- export declare const getDefaultVisitors: () => walk.RecursiveVisitors<EvalState>;
@@ -1,4 +0,0 @@
1
- import { TaggedTemplateExpression } from 'acorn';
2
- import * as walk from 'acorn-walk';
3
- import { EvalState } from '../classes/eval';
4
- export declare const taggedTemplateExpressionVisitor: (node: TaggedTemplateExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => void;
@@ -1,4 +0,0 @@
1
- import { TemplateLiteral } from 'acorn';
2
- import * as walk from 'acorn-walk';
3
- import { EvalState } from '../classes/eval';
4
- export declare const templateLiteralVisitor: (node: TemplateLiteral, st: EvalState, callback: walk.WalkerCallback<EvalState>) => void;
@@ -1,3 +0,0 @@
1
- import { ThisExpression } from 'acorn';
2
- import { EvalState } from '../classes/eval';
3
- export declare const thisExpressionVisitor: (node: ThisExpression, st: EvalState) => void;
@@ -1,4 +0,0 @@
1
- import { UnaryExpression } from 'acorn';
2
- import * as walk from 'acorn-walk';
3
- import { EvalState } from '../classes/eval';
4
- export declare const unaryExpressionVisitor: (node: UnaryExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => void;
@@ -1,4 +0,0 @@
1
- import { UpdateExpression } from 'acorn';
2
- import * as walk from 'acorn-walk';
3
- import { EvalState } from '../classes/eval';
4
- export declare const updateExpressionVisitor: (node: UpdateExpression, st: EvalState, callback: walk.WalkerCallback<EvalState>) => void;
@@ -1,23 +0,0 @@
1
- import { BaseContext } from "../classes/common/context";
2
- /**
3
- * Retrieves the key-value pair from an object based on the provided key.
4
- * @param obj - The object to search for the key-value pair.
5
- * @param key - The key to search for in the object.
6
- * @param caseInsesitive - Specifies whether the key comparison should be case-insensitive.
7
- * @returns The key-value pair as an array, or undefined if the key is not found.
8
- */
9
- export declare const getKeyValue: (obj: BaseContext, key: string | number | symbol, caseInsesitive: boolean) => [string | number | symbol, unknown] | undefined;
10
- /**
11
- * Compares two values for equality, ignoring case sensitivity.
12
- * @param a - The first value to compare.
13
- * @param b - The second value to compare.
14
- * @returns `true` if the values are equal, `false` otherwise.
15
- */
16
- export declare const equalIgnoreCase: (a: string | number | symbol, b: string | number | symbol) => boolean | undefined;
17
- /**
18
- * Retrieves the value from an object, ignoring the case of the key.
19
- * @param obj - The object to retrieve the value from.
20
- * @param key - The key to search for, ignoring the case.
21
- * @returns The value associated with the key, or undefined if the key is not found.
22
- */
23
- export declare const getValueIgnoreCase: (obj: BaseContext, key: string | number | symbol) => unknown | undefined;
@@ -1,6 +0,0 @@
1
- import { AnyNode } from 'acorn';
2
- import { EvalState } from '../classes/eval';
3
- export declare const pushVisitorResult: (node: AnyNode, st: EvalState, value: unknown) => unknown;
4
- export declare const popVisitorResult: (node: AnyNode, st: EvalState) => unknown;
5
- export declare const pushVisitorResultAsync: (node: AnyNode, st: EvalState, value: Promise<unknown>) => Promise<unknown>;
6
- export declare const popVisitorResultAsync: (node: AnyNode, st: EvalState) => Promise<unknown>;
package/public-api.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export * from './lib/actual/services';
2
- export * from './lib/internal/interfaces';
3
- export * from './lib/internal/functions';
4
- export * from './lib/internal/classes/common';
5
- export * from './lib/internal/classes/eval';