json-function-engine 0.8.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 (119) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +509 -0
  3. package/dist/constants.d.ts +13 -0
  4. package/dist/constants.d.ts.map +1 -0
  5. package/dist/constants.js +18 -0
  6. package/dist/constants.js.map +1 -0
  7. package/dist/engine/Executor.d.ts +92 -0
  8. package/dist/engine/Executor.d.ts.map +1 -0
  9. package/dist/engine/Executor.js +260 -0
  10. package/dist/engine/Executor.js.map +1 -0
  11. package/dist/engine/FileLoader.d.ts +51 -0
  12. package/dist/engine/FileLoader.d.ts.map +1 -0
  13. package/dist/engine/FileLoader.js +195 -0
  14. package/dist/engine/FileLoader.js.map +1 -0
  15. package/dist/engine/Pipeline.d.ts +54 -0
  16. package/dist/engine/Pipeline.d.ts.map +1 -0
  17. package/dist/engine/Pipeline.js +91 -0
  18. package/dist/engine/Pipeline.js.map +1 -0
  19. package/dist/engine/actions/BlockAction.d.ts +3 -0
  20. package/dist/engine/actions/BlockAction.d.ts.map +1 -0
  21. package/dist/engine/actions/BlockAction.js +13 -0
  22. package/dist/engine/actions/BlockAction.js.map +1 -0
  23. package/dist/engine/actions/FlagAction.d.ts +3 -0
  24. package/dist/engine/actions/FlagAction.d.ts.map +1 -0
  25. package/dist/engine/actions/FlagAction.js +29 -0
  26. package/dist/engine/actions/FlagAction.js.map +1 -0
  27. package/dist/engine/actions/NotifyAction.d.ts +3 -0
  28. package/dist/engine/actions/NotifyAction.d.ts.map +1 -0
  29. package/dist/engine/actions/NotifyAction.js +13 -0
  30. package/dist/engine/actions/NotifyAction.js.map +1 -0
  31. package/dist/engine/actions/TransformAction.d.ts +3 -0
  32. package/dist/engine/actions/TransformAction.d.ts.map +1 -0
  33. package/dist/engine/actions/TransformAction.js +13 -0
  34. package/dist/engine/actions/TransformAction.js.map +1 -0
  35. package/dist/engine/actions/index.d.ts +5 -0
  36. package/dist/engine/actions/index.d.ts.map +1 -0
  37. package/dist/engine/actions/index.js +5 -0
  38. package/dist/engine/actions/index.js.map +1 -0
  39. package/dist/engine/conditions/ArrayCondition.d.ts +3 -0
  40. package/dist/engine/conditions/ArrayCondition.d.ts.map +1 -0
  41. package/dist/engine/conditions/ArrayCondition.js +47 -0
  42. package/dist/engine/conditions/ArrayCondition.js.map +1 -0
  43. package/dist/engine/conditions/ComparisonCondition.d.ts +3 -0
  44. package/dist/engine/conditions/ComparisonCondition.d.ts.map +1 -0
  45. package/dist/engine/conditions/ComparisonCondition.js +42 -0
  46. package/dist/engine/conditions/ComparisonCondition.js.map +1 -0
  47. package/dist/engine/conditions/CompositeCondition.d.ts +3 -0
  48. package/dist/engine/conditions/CompositeCondition.d.ts.map +1 -0
  49. package/dist/engine/conditions/CompositeCondition.js +50 -0
  50. package/dist/engine/conditions/CompositeCondition.js.map +1 -0
  51. package/dist/engine/conditions/ExistsCondition.d.ts +3 -0
  52. package/dist/engine/conditions/ExistsCondition.d.ts.map +1 -0
  53. package/dist/engine/conditions/ExistsCondition.js +14 -0
  54. package/dist/engine/conditions/ExistsCondition.js.map +1 -0
  55. package/dist/engine/conditions/MathCondition.d.ts +3 -0
  56. package/dist/engine/conditions/MathCondition.d.ts.map +1 -0
  57. package/dist/engine/conditions/MathCondition.js +30 -0
  58. package/dist/engine/conditions/MathCondition.js.map +1 -0
  59. package/dist/engine/conditions/RegexCondition.d.ts +3 -0
  60. package/dist/engine/conditions/RegexCondition.d.ts.map +1 -0
  61. package/dist/engine/conditions/RegexCondition.js +10 -0
  62. package/dist/engine/conditions/RegexCondition.js.map +1 -0
  63. package/dist/engine/conditions/helpers.d.ts +3 -0
  64. package/dist/engine/conditions/helpers.d.ts.map +1 -0
  65. package/dist/engine/conditions/helpers.js +14 -0
  66. package/dist/engine/conditions/helpers.js.map +1 -0
  67. package/dist/engine/conditions/index.d.ts +7 -0
  68. package/dist/engine/conditions/index.d.ts.map +1 -0
  69. package/dist/engine/conditions/index.js +7 -0
  70. package/dist/engine/conditions/index.js.map +1 -0
  71. package/dist/engine/engine.d.ts +151 -0
  72. package/dist/engine/engine.d.ts.map +1 -0
  73. package/dist/engine/engine.js +246 -0
  74. package/dist/engine/engine.js.map +1 -0
  75. package/dist/engine/guards.d.ts +22 -0
  76. package/dist/engine/guards.d.ts.map +1 -0
  77. package/dist/engine/guards.js +84 -0
  78. package/dist/engine/guards.js.map +1 -0
  79. package/dist/engine/registry.d.ts +23 -0
  80. package/dist/engine/registry.d.ts.map +1 -0
  81. package/dist/engine/registry.js +93 -0
  82. package/dist/engine/registry.js.map +1 -0
  83. package/dist/engine/reporters/index.d.ts +12 -0
  84. package/dist/engine/reporters/index.d.ts.map +1 -0
  85. package/dist/engine/reporters/index.js +146 -0
  86. package/dist/engine/reporters/index.js.map +1 -0
  87. package/dist/index.d.ts +21 -0
  88. package/dist/index.d.ts.map +1 -0
  89. package/dist/index.js +20 -0
  90. package/dist/index.js.map +1 -0
  91. package/dist/types/index.d.ts +204 -0
  92. package/dist/types/index.d.ts.map +1 -0
  93. package/dist/types/index.js +27 -0
  94. package/dist/types/index.js.map +1 -0
  95. package/dist/utils/cache.d.ts +17 -0
  96. package/dist/utils/cache.d.ts.map +1 -0
  97. package/dist/utils/cache.js +52 -0
  98. package/dist/utils/cache.js.map +1 -0
  99. package/dist/utils/errors.d.ts +45 -0
  100. package/dist/utils/errors.d.ts.map +1 -0
  101. package/dist/utils/errors.js +84 -0
  102. package/dist/utils/errors.js.map +1 -0
  103. package/dist/utils/factories.d.ts +23 -0
  104. package/dist/utils/factories.d.ts.map +1 -0
  105. package/dist/utils/factories.js +63 -0
  106. package/dist/utils/factories.js.map +1 -0
  107. package/dist/utils/metrics.d.ts +75 -0
  108. package/dist/utils/metrics.d.ts.map +1 -0
  109. package/dist/utils/metrics.js +99 -0
  110. package/dist/utils/metrics.js.map +1 -0
  111. package/dist/utils/regex.d.ts +33 -0
  112. package/dist/utils/regex.d.ts.map +1 -0
  113. package/dist/utils/regex.js +226 -0
  114. package/dist/utils/regex.js.map +1 -0
  115. package/dist/utils/schema.d.ts +7 -0
  116. package/dist/utils/schema.d.ts.map +1 -0
  117. package/dist/utils/schema.js +226 -0
  118. package/dist/utils/schema.js.map +1 -0
  119. package/package.json +50 -0
@@ -0,0 +1,91 @@
1
+ import { createDefaultLogger } from '../utils/factories.js';
2
+ export class Pipeline {
3
+ hooks = new Map();
4
+ logger;
5
+ parallel;
6
+ constructor(options = {}) {
7
+ this.logger = options.logger ?? createDefaultLogger();
8
+ this.parallel = options.parallel ?? false;
9
+ }
10
+ /**
11
+ * Register a hook to the pipeline
12
+ */
13
+ register(hook) {
14
+ const hooks = this.hooks.get(hook.type) || [];
15
+ hooks.push(hook);
16
+ this.hooks.set(hook.type, hooks);
17
+ }
18
+ /**
19
+ * Unregister a hook from the pipeline
20
+ */
21
+ unregister(type, name) {
22
+ const hooks = this.hooks.get(type) || [];
23
+ const filtered = hooks.filter(h => h.name !== name);
24
+ this.hooks.set(type, filtered);
25
+ }
26
+ /**
27
+ * Execute hooks of a specific type
28
+ */
29
+ async execute(type, context, data) {
30
+ const hooks = this.hooks.get(type) || [];
31
+ if (hooks.length === 0) {
32
+ return data;
33
+ }
34
+ if (this.parallel) {
35
+ // Parallel execution - run all hooks concurrently
36
+ const results = await Promise.allSettled(hooks.map(hook => hook.handler(context, data)));
37
+ // Get the last successful result, or original data
38
+ let finalData = data;
39
+ for (const result of results) {
40
+ if (result.status === 'fulfilled' && result.value) {
41
+ finalData = result.value;
42
+ }
43
+ else if (result.status === 'rejected') {
44
+ this.logger.error(`Pipeline hook failed:`, result.reason);
45
+ }
46
+ }
47
+ return finalData;
48
+ }
49
+ // Sequential execution (default)
50
+ let currentData = data;
51
+ for (const hook of hooks) {
52
+ try {
53
+ currentData = await hook.handler(context, currentData);
54
+ }
55
+ catch (error) {
56
+ // Log error but continue with other hooks
57
+ this.logger.error(`Pipeline hook ${hook.name} failed:`, error);
58
+ }
59
+ }
60
+ return currentData;
61
+ }
62
+ /**
63
+ * Get all registered hooks
64
+ */
65
+ getHooks(type) {
66
+ if (type) {
67
+ return this.hooks.get(type) || [];
68
+ }
69
+ return Array.from(this.hooks.values()).flat();
70
+ }
71
+ /**
72
+ * Clear all hooks
73
+ */
74
+ clear() {
75
+ this.hooks.clear();
76
+ }
77
+ /**
78
+ * Check if pipeline has hooks of a specific type
79
+ */
80
+ hasHooks(type) {
81
+ const hooks = this.hooks.get(type);
82
+ return hooks ? hooks.length > 0 : false;
83
+ }
84
+ }
85
+ /**
86
+ * Create a pipeline hook helper
87
+ */
88
+ export function createHook(type, name, handler) {
89
+ return { type, name, handler };
90
+ }
91
+ //# sourceMappingURL=Pipeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Pipeline.js","sourceRoot":"","sources":["../../src/engine/Pipeline.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AA4B5D,MAAM,OAAO,QAAQ;IACX,KAAK,GAA0C,IAAI,GAAG,EAAE,CAAC;IACzD,MAAM,CAAS;IACf,QAAQ,CAAU;IAE1B,YAAY,UAA2B,EAAE;QACvC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,mBAAmB,EAAE,CAAC;QACtD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,IAAkB;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAC9C,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,IAAsB,EAAE,IAAY;QAC7C,MAAM,KAAK,GAA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I,CAAC;QACvB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC;gBACH,WAAW,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YACzD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,0CAA0C;gBAC1C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,IAAI,CAAC,IAAI,UAAU,EAAE,KAAK,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,IAAuB;QAC9B,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACpC,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,IAAsB;QAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1C,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CACxB,IAAsB,EACtB,IAAY,EACZ,OAAwB;IAExB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACjC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ActionDefinition } from '../../types/index.js';
2
+ export declare const blockAction: ActionDefinition;
3
+ //# sourceMappingURL=BlockAction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BlockAction.d.ts","sourceRoot":"","sources":["../../../src/engine/actions/BlockAction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,eAAO,MAAM,WAAW,EAAE,gBAWzB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { assertBlockAction } from '../guards.js';
2
+ export const blockAction = {
3
+ name: 'block',
4
+ execute: async (config, _context, matches, _file) => {
5
+ assertBlockAction(config);
6
+ return {
7
+ success: true,
8
+ blocked: matches.matched,
9
+ error: matches.matched ? config.message : undefined
10
+ };
11
+ }
12
+ };
13
+ //# sourceMappingURL=BlockAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BlockAction.js","sourceRoot":"","sources":["../../../src/engine/actions/BlockAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,CAAC,MAAM,WAAW,GAAqB;IAC3C,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QAClD,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAE1B,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;SACpD,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ActionDefinition } from '../../types/index.js';
2
+ export declare const flagAction: ActionDefinition;
3
+ //# sourceMappingURL=FlagAction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlagAction.d.ts","sourceRoot":"","sources":["../../../src/engine/actions/FlagAction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAW,MAAM,sBAAsB,CAAC;AAGtE,eAAO,MAAM,UAAU,EAAE,gBA6BxB,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { assertFlagAction } from '../guards.js';
2
+ export const flagAction = {
3
+ name: 'flag',
4
+ execute: async (config, _context, matches, file) => {
5
+ assertFlagAction(config);
6
+ const { severity, message } = config;
7
+ const findings = [];
8
+ if (matches.matched && matches.matches) {
9
+ for (const match of matches.matches) {
10
+ findings.push({
11
+ functionId: '',
12
+ severity,
13
+ message,
14
+ location: {
15
+ file: file.path,
16
+ line: match.line,
17
+ column: match.column
18
+ },
19
+ code: match.text
20
+ });
21
+ }
22
+ }
23
+ return {
24
+ success: true,
25
+ findings
26
+ };
27
+ }
28
+ };
29
+ //# sourceMappingURL=FlagAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlagAction.js","sourceRoot":"","sources":["../../../src/engine/actions/FlagAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,CAAC,MAAM,UAAU,GAAqB;IAC1C,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QACjD,gBAAgB,CAAC,MAAM,CAAC,CAAC;QAEzB,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;QACrC,MAAM,QAAQ,GAAc,EAAE,CAAC;QAE/B,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACvC,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBACpC,QAAQ,CAAC,IAAI,CAAC;oBACZ,UAAU,EAAE,EAAE;oBACd,QAAQ;oBACR,OAAO;oBACP,QAAQ,EAAE;wBACR,IAAI,EAAE,IAAI,CAAC,IAAI;wBACf,IAAI,EAAE,KAAK,CAAC,IAAI;wBAChB,MAAM,EAAE,KAAK,CAAC,MAAM;qBACrB;oBACD,IAAI,EAAE,KAAK,CAAC,IAAI;iBACjB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI;YACb,QAAQ;SACT,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ActionDefinition } from '../../types/index.js';
2
+ export declare const notifyAction: ActionDefinition;
3
+ //# sourceMappingURL=NotifyAction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotifyAction.d.ts","sourceRoot":"","sources":["../../../src/engine/actions/NotifyAction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,eAAO,MAAM,YAAY,EAAE,gBAW1B,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { assertNotifyAction } from '../guards.js';
2
+ export const notifyAction = {
3
+ name: 'notify',
4
+ execute: async (config, _context, _matches, _file) => {
5
+ assertNotifyAction(config);
6
+ // Notify is a placeholder - actual notification depends on integration
7
+ return {
8
+ success: true,
9
+ notified: true
10
+ };
11
+ }
12
+ };
13
+ //# sourceMappingURL=NotifyAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotifyAction.js","sourceRoot":"","sources":["../../../src/engine/actions/NotifyAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,CAAC,MAAM,YAAY,GAAqB;IAC5C,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;QACnD,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAE3B,uEAAuE;QACvE,OAAO;YACL,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACf,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ActionDefinition } from '../../types/index.js';
2
+ export declare const transformAction: ActionDefinition;
3
+ //# sourceMappingURL=TransformAction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransformAction.d.ts","sourceRoot":"","sources":["../../../src/engine/actions/TransformAction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,eAAO,MAAM,eAAe,EAAE,gBAW7B,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { assertTransformAction } from '../guards.js';
2
+ export const transformAction = {
3
+ name: 'transform',
4
+ execute: async (config, _context, _matches, _file) => {
5
+ assertTransformAction(config);
6
+ // Transform is a placeholder - actual transformation depends on context
7
+ return {
8
+ success: true,
9
+ transformed: null
10
+ };
11
+ }
12
+ };
13
+ //# sourceMappingURL=TransformAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransformAction.js","sourceRoot":"","sources":["../../../src/engine/actions/TransformAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,MAAM,CAAC,MAAM,eAAe,GAAqB;IAC/C,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;QACnD,qBAAqB,CAAC,MAAM,CAAC,CAAC;QAE9B,wEAAwE;QACxE,OAAO;YACL,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,IAAI;SAClB,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { flagAction } from './FlagAction.js';
2
+ export { blockAction } from './BlockAction.js';
3
+ export { transformAction } from './TransformAction.js';
4
+ export { notifyAction } from './NotifyAction.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/engine/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { flagAction } from './FlagAction.js';
2
+ export { blockAction } from './BlockAction.js';
3
+ export { transformAction } from './TransformAction.js';
4
+ export { notifyAction } from './NotifyAction.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/engine/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ConditionDefinition } from '../../types/index.js';
2
+ export declare const arrayCondition: ConditionDefinition;
3
+ //# sourceMappingURL=ArrayCondition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArrayCondition.d.ts","sourceRoot":"","sources":["../../../src/engine/conditions/ArrayCondition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAuE,MAAM,sBAAsB,CAAC;AAMrI,eAAO,MAAM,cAAc,EAAE,mBA2E5B,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { assertArrayCondition } from '../guards.js';
2
+ import { getFieldValue } from './helpers.js';
3
+ export const arrayCondition = {
4
+ name: 'array',
5
+ evaluate: async (_config, context, _file) => {
6
+ assertArrayCondition(_config);
7
+ const { operator, field, condition } = _config;
8
+ const fieldValue = getFieldValue(field, context);
9
+ if (!Array.isArray(fieldValue)) {
10
+ return { matched: false };
11
+ }
12
+ const evaluateCondition = async () => ({ matched: false });
13
+ switch (operator) {
14
+ case 'all': {
15
+ if (!condition)
16
+ return { matched: false };
17
+ const results = await Promise.all(fieldValue.map((item, idx) => evaluateCondition(condition, { ...context, [field]: item, _index: idx, _array: fieldValue }, _file)));
18
+ return { matched: results.every(r => r.matched) };
19
+ }
20
+ case 'none': {
21
+ if (!condition)
22
+ return { matched: true };
23
+ const results = await Promise.all(fieldValue.map((item, idx) => evaluateCondition(condition, { ...context, [field]: item, _index: idx, _array: fieldValue }, _file)));
24
+ return { matched: results.every(r => !r.matched) };
25
+ }
26
+ case 'some': {
27
+ if (!condition)
28
+ return { matched: fieldValue.length > 0 };
29
+ const results = await Promise.all(fieldValue.map((item, idx) => evaluateCondition(condition, { ...context, [field]: item, _index: idx, _array: fieldValue }, _file)));
30
+ return { matched: results.some(r => r.matched) };
31
+ }
32
+ case 'filter': {
33
+ if (!condition)
34
+ return { matched: fieldValue.length > 0 };
35
+ const results = await Promise.all(fieldValue.map((item, idx) => evaluateCondition(condition, { ...context, [field]: item, _index: idx, _array: fieldValue }, _file)));
36
+ const filtered = fieldValue.filter((_, idx) => results[idx].matched);
37
+ return { matched: filtered.length > 0 };
38
+ }
39
+ case 'map':
40
+ case 'reduce':
41
+ return { matched: fieldValue.length > 0 };
42
+ default:
43
+ return { matched: false };
44
+ }
45
+ }
46
+ };
47
+ //# sourceMappingURL=ArrayCondition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArrayCondition.js","sourceRoot":"","sources":["../../../src/engine/conditions/ArrayCondition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C,MAAM,CAAC,MAAM,cAAc,GAAwB;IACjD,IAAI,EAAE,OAAO;IACb,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QAC1C,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAE9B,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AAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;gBACrE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1C,CAAC;YACD,KAAK,KAAK,CAAC;YACX,KAAK,QAAQ;gBACX,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5C;gBACE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAC9B,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ConditionDefinition } from '../../types/index.js';
2
+ export declare const comparisonCondition: ConditionDefinition;
3
+ //# sourceMappingURL=ComparisonCondition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComparisonCondition.d.ts","sourceRoot":"","sources":["../../../src/engine/conditions/ComparisonCondition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAIhE,eAAO,MAAM,mBAAmB,EAAE,mBAyCjC,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { assertComparisonCondition } from '../guards.js';
2
+ import { getFieldValue } from './helpers.js';
3
+ export const comparisonCondition = {
4
+ name: 'comparison',
5
+ evaluate: (config, _context, _file) => {
6
+ assertComparisonCondition(config);
7
+ const { operator, field, value } = config;
8
+ const fieldValue = getFieldValue(field, _context);
9
+ let matched = false;
10
+ switch (operator) {
11
+ case '==':
12
+ matched = fieldValue === value;
13
+ break;
14
+ case '!=':
15
+ matched = fieldValue !== value;
16
+ break;
17
+ case '>':
18
+ matched = Number(fieldValue) > Number(value);
19
+ break;
20
+ case '<':
21
+ matched = Number(fieldValue) < Number(value);
22
+ break;
23
+ case '>=':
24
+ matched = Number(fieldValue) >= Number(value);
25
+ break;
26
+ case '<=':
27
+ matched = Number(fieldValue) <= Number(value);
28
+ break;
29
+ case 'contains':
30
+ matched = String(fieldValue).includes(String(value));
31
+ break;
32
+ case 'startsWith':
33
+ matched = String(fieldValue).startsWith(String(value));
34
+ break;
35
+ case 'endsWith':
36
+ matched = String(fieldValue).endsWith(String(value));
37
+ break;
38
+ }
39
+ return { matched };
40
+ }
41
+ };
42
+ //# sourceMappingURL=ComparisonCondition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComparisonCondition.js","sourceRoot":"","sources":["../../../src/engine/conditions/ComparisonCondition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,CAAC,MAAM,mBAAmB,GAAwB;IACtD,IAAI,EAAE,YAAY;IAClB,QAAQ,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;QACpC,yBAAyB,CAAC,MAAM,CAAC,CAAC;QAElC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QAC1C,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAElD,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,IAAI;gBACP,OAAO,GAAG,UAAU,KAAK,KAAK,CAAC;gBAC/B,MAAM;YACR,KAAK,IAAI;gBACP,OAAO,GAAG,UAAU,KAAK,KAAK,CAAC;gBAC/B,MAAM;YACR,KAAK,GAAG;gBACN,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC7C,MAAM;YACR,KAAK,GAAG;gBACN,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC7C,MAAM;YACR,KAAK,IAAI;gBACP,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC9C,MAAM;YACR,KAAK,IAAI;gBACP,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC9C,MAAM;YACR,KAAK,UAAU;gBACb,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;gBACrD,MAAM;YACR,KAAK,YAAY;gBACf,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;gBACvD,MAAM;YACR,KAAK,UAAU;gBACb,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;gBACrD,MAAM;QACV,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ConditionDefinition } from '../../types/index.js';
2
+ export declare const compositeCondition: ConditionDefinition;
3
+ //# sourceMappingURL=CompositeCondition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompositeCondition.d.ts","sourceRoot":"","sources":["../../../src/engine/conditions/CompositeCondition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAiE,MAAM,sBAAsB,CAAC;AAG/H,eAAO,MAAM,kBAAkB,EAAE,mBAmDhC,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { assertCompositeCondition } from '../guards.js';
2
+ export const compositeCondition = {
3
+ name: 'composite',
4
+ // Store registry reference for fallback when context callback not provided
5
+ evaluate: async (config, context, file, registry) => {
6
+ assertCompositeCondition(config);
7
+ const { operator, conditions } = config;
8
+ // Use callback from context if provided, otherwise use registry directly
9
+ let evaluateCondition;
10
+ if (context.evaluateCondition) {
11
+ evaluateCondition = context.evaluateCondition;
12
+ }
13
+ else if (registry) {
14
+ // Fallback for direct calls without context (e.g., in tests)
15
+ evaluateCondition = (cond, ctx, f) => registry.evaluateCondition(cond, ctx, f);
16
+ }
17
+ else {
18
+ throw new Error('Composite condition requires evaluateCondition in context or registry as fourth argument');
19
+ }
20
+ if (operator === 'NOT') {
21
+ // For NOT, evaluate until we find one that matches (then NOT returns false)
22
+ for (const condition of conditions) {
23
+ const result = await evaluateCondition(condition, context, file);
24
+ if (result.matched) {
25
+ return { matched: false };
26
+ }
27
+ }
28
+ return { matched: true };
29
+ }
30
+ if (operator === 'AND') {
31
+ // Short-circuit: stop at first false
32
+ for (const condition of conditions) {
33
+ const result = await evaluateCondition(condition, context, file);
34
+ if (!result.matched) {
35
+ return { matched: false };
36
+ }
37
+ }
38
+ return { matched: true };
39
+ }
40
+ // OR: short-circuit at first true
41
+ for (const condition of conditions) {
42
+ const result = await evaluateCondition(condition, context, file);
43
+ if (result.matched) {
44
+ return { matched: true };
45
+ }
46
+ }
47
+ return { matched: false };
48
+ }
49
+ };
50
+ //# sourceMappingURL=CompositeCondition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompositeCondition.js","sourceRoot":"","sources":["../../../src/engine/conditions/CompositeCondition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAExD,MAAM,CAAC,MAAM,kBAAkB,GAAwB;IACrD,IAAI,EAAE,WAAW;IACjB,2EAA2E;IAC3E,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;QAClD,wBAAwB,CAAC,MAAM,CAAC,CAAC;QAEjC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;QAExC,yEAAyE;QACzE,IAAI,iBAA6G,CAAC;QAElH,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAC9B,iBAAiB,GAAG,OAAO,CAAC,iBAAi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AAC;gBACnB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YAC3B,CAAC;QACH,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ConditionDefinition } from '../../types/index.js';
2
+ export declare const existsCondition: ConditionDefinition;
3
+ //# sourceMappingURL=ExistsCondition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExistsCondition.d.ts","sourceRoot":"","sources":["../../../src/engine/conditions/ExistsCondition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAIhE,eAAO,MAAM,eAAe,EAAE,mBAY7B,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { assertExistsCondition } from '../guards.js';
2
+ import { getFieldValue } from './helpers.js';
3
+ export const existsCondition = {
4
+ name: 'exists',
5
+ evaluate: (config, _context, _file) => {
6
+ assertExistsCondition(config);
7
+ const { field } = config;
8
+ const value = getFieldValue(field, _context);
9
+ return {
10
+ matched: value !== undefined && value !== null
11
+ };
12
+ }
13
+ };
14
+ //# sourceMappingURL=ExistsCondition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExistsCondition.js","sourceRoot":"","sources":["../../../src/engine/conditions/ExistsCondition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,CAAC,MAAM,eAAe,GAAwB;IAClD,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;QACpC,qBAAqB,CAAC,MAAM,CAAC,CAAC;QAE9B,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QACzB,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAE7C,OAAO;YACL,OAAO,EAAE,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;SAC/C,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ConditionDefinition } from '../../types/index.js';
2
+ export declare const mathCondition: ConditionDefinition;
3
+ //# sourceMappingURL=MathCondition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MathCondition.d.ts","sourceRoot":"","sources":["../../../src/engine/conditions/MathCondition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAGhE,eAAO,MAAM,aAAa,EAAE,mBA8B3B,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { assertMathCondition } from '../guards.js';
2
+ export const mathCondition = {
3
+ name: 'math',
4
+ evaluate: (_config, _context, _file) => {
5
+ assertMathCondition(_config);
6
+ const { operator, left, right } = _config;
7
+ const leftNum = Number(left);
8
+ const rightNum = Number(right);
9
+ let matched = false;
10
+ switch (operator) {
11
+ case '+':
12
+ matched = leftNum + rightNum !== 0;
13
+ break;
14
+ case '-':
15
+ matched = leftNum - rightNum !== 0;
16
+ break;
17
+ case '*':
18
+ matched = leftNum * rightNum !== 0;
19
+ break;
20
+ case '/':
21
+ matched = rightNum !== 0 && leftNum / rightNum !== 0;
22
+ break;
23
+ case '%':
24
+ matched = rightNum !== 0 && leftNum % rightNum !== 0;
25
+ break;
26
+ }
27
+ return { matched };
28
+ }
29
+ };
30
+ //# sourceMappingURL=MathCondition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MathCondition.js","sourceRoot":"","sources":["../../../src/engine/conditions/MathCondition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,CAAC,MAAM,aAAa,GAAwB;IAChD,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;QACrC,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAE7B,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAC1C,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7B,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAE/B,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,GAAG;gBACN,OAAO,GAAG,OAAO,GAAG,QAAQ,KAAK,CAAC,CAAC;gBACnC,MAAM;YACR,KAAK,GAAG;gBACN,OAAO,GAAG,OAAO,GAAG,QAAQ,KAAK,CAAC,CAAC;gBACnC,MAAM;YACR,KAAK,GAAG;gBACN,OAAO,GAAG,OAAO,GAAG,QAAQ,KAAK,CAAC,CAAC;gBACnC,MAAM;YACR,KAAK,GAAG;gBACN,OAAO,GAAG,QAAQ,KAAK,CAAC,IAAI,OAAO,GAAG,QAAQ,KAAK,CAAC,CAAC;gBACrD,MAAM;YACR,KAAK,GAAG;gBACN,OAAO,GAAG,QAAQ,KAAK,CAAC,IAAI,OAAO,GAAG,QAAQ,KAAK,CAAC,CAAC;gBACrD,MAAM;QACV,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ConditionDefinition } from '../../types/index.js';
2
+ export declare const regexCondition: ConditionDefinition;
3
+ //# sourceMappingURL=RegexCondition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RegexCondition.d.ts","sourceRoot":"","sources":["../../../src/engine/conditions/RegexCondition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAIhE,eAAO,MAAM,cAAc,EAAE,mBAM5B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { evaluateRegexCondition } from '../../utils/regex.js';
2
+ import { assertRegexCondition } from '../guards.js';
3
+ export const regexCondition = {
4
+ name: 'regex',
5
+ evaluate: (config, context, file) => {
6
+ assertRegexCondition(config);
7
+ return evaluateRegexCondition(config, context, file);
8
+ }
9
+ };
10
+ //# sourceMappingURL=RegexCondition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RegexCondition.js","sourceRoot":"","sources":["../../../src/engine/conditions/RegexCondition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,CAAC,MAAM,cAAc,GAAwB;IACjD,IAAI,EAAE,OAAO;IACb,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QAClC,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAC7B,OAAO,sBAAsB,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACvD,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ExecutionContext } from '../../types/index.js';
2
+ export declare function getFieldValue(field: string, context: ExecutionContext): unknown;
3
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/engine/conditions/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAa/E"}
@@ -0,0 +1,14 @@
1
+ export function getFieldValue(field, context) {
2
+ const parts = field.split('.');
3
+ let value = context;
4
+ for (const part of parts) {
5
+ if (value && typeof value === 'object' && part in value) {
6
+ value = value[part];
7
+ }
8
+ else {
9
+ return undefined;
10
+ }
11
+ }
12
+ return value;
13
+ }
14
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/engine/conditions/helpers.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,OAAyB;IACpE,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,KAAK,GAAY,OAAO,CAAC;IAE7B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;YACxD,KAAK,GAAI,KAAiC,CAAC,IAAI,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACN,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { regexCondition } from './RegexCondition.js';
2
+ export { comparisonCondition } from './ComparisonCondition.js';
3
+ export { existsCondition } from './ExistsCondition.js';
4
+ export { compositeCondition } from './CompositeCondition.js';
5
+ export { mathCondition } from './MathCondition.js';
6
+ export { arrayCondition } from './ArrayCondition.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/engine/conditions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { regexCondition } from './RegexCondition.js';
2
+ export { comparisonCondition } from './ComparisonCondition.js';
3
+ export { existsCondition } from './ExistsCondition.js';
4
+ export { compositeCondition } from './CompositeCondition.js';
5
+ export { mathCondition } from './MathCondition.js';
6
+ export { arrayCondition } from './ArrayCondition.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/engine/conditions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}