@bubblelab/bubble-runtime 0.1.14 → 0.1.16

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 (69) hide show
  1. package/dist/extraction/BubbleParser.d.ts +187 -8
  2. package/dist/extraction/BubbleParser.d.ts.map +1 -1
  3. package/dist/extraction/BubbleParser.js +2271 -117
  4. package/dist/extraction/BubbleParser.js.map +1 -1
  5. package/dist/extraction/index.js +1 -0
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +2 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/injection/BubbleInjector.d.ts +27 -2
  11. package/dist/injection/BubbleInjector.d.ts.map +1 -1
  12. package/dist/injection/BubbleInjector.js +343 -35
  13. package/dist/injection/BubbleInjector.js.map +1 -1
  14. package/dist/injection/LoggerInjector.d.ts +12 -1
  15. package/dist/injection/LoggerInjector.d.ts.map +1 -1
  16. package/dist/injection/LoggerInjector.js +301 -13
  17. package/dist/injection/LoggerInjector.js.map +1 -1
  18. package/dist/injection/index.js +1 -0
  19. package/dist/parse/BubbleScript.d.ts +60 -3
  20. package/dist/parse/BubbleScript.d.ts.map +1 -1
  21. package/dist/parse/BubbleScript.js +133 -15
  22. package/dist/parse/BubbleScript.js.map +1 -1
  23. package/dist/parse/index.d.ts +0 -1
  24. package/dist/parse/index.d.ts.map +1 -1
  25. package/dist/parse/index.js +1 -1
  26. package/dist/parse/index.js.map +1 -1
  27. package/dist/runtime/BubbleRunner.d.ts +8 -2
  28. package/dist/runtime/BubbleRunner.d.ts.map +1 -1
  29. package/dist/runtime/BubbleRunner.js +41 -30
  30. package/dist/runtime/BubbleRunner.js.map +1 -1
  31. package/dist/runtime/index.d.ts +1 -1
  32. package/dist/runtime/index.d.ts.map +1 -1
  33. package/dist/runtime/index.js +1 -0
  34. package/dist/runtime/index.js.map +1 -1
  35. package/dist/runtime/types.js +1 -0
  36. package/dist/types/index.js +1 -0
  37. package/dist/utils/bubble-helper.d.ts +2 -2
  38. package/dist/utils/bubble-helper.d.ts.map +1 -1
  39. package/dist/utils/bubble-helper.js +6 -1
  40. package/dist/utils/bubble-helper.js.map +1 -1
  41. package/dist/utils/normalize-control-flow.d.ts +14 -0
  42. package/dist/utils/normalize-control-flow.d.ts.map +1 -0
  43. package/dist/utils/normalize-control-flow.js +179 -0
  44. package/dist/utils/normalize-control-flow.js.map +1 -0
  45. package/dist/utils/parameter-formatter.d.ts +14 -5
  46. package/dist/utils/parameter-formatter.d.ts.map +1 -1
  47. package/dist/utils/parameter-formatter.js +164 -45
  48. package/dist/utils/parameter-formatter.js.map +1 -1
  49. package/dist/utils/sanitize-script.d.ts +11 -0
  50. package/dist/utils/sanitize-script.d.ts.map +1 -0
  51. package/dist/utils/sanitize-script.js +43 -0
  52. package/dist/utils/sanitize-script.js.map +1 -0
  53. package/dist/validation/BubbleValidator.d.ts +15 -0
  54. package/dist/validation/BubbleValidator.d.ts.map +1 -1
  55. package/dist/validation/BubbleValidator.js +168 -1
  56. package/dist/validation/BubbleValidator.js.map +1 -1
  57. package/dist/validation/index.d.ts +6 -3
  58. package/dist/validation/index.d.ts.map +1 -1
  59. package/dist/validation/index.js +33 -9
  60. package/dist/validation/index.js.map +1 -1
  61. package/dist/validation/lint-rules.d.ts +91 -0
  62. package/dist/validation/lint-rules.d.ts.map +1 -0
  63. package/dist/validation/lint-rules.js +755 -0
  64. package/dist/validation/lint-rules.js.map +1 -0
  65. package/package.json +4 -4
  66. package/dist/parse/traceDependencies.d.ts +0 -18
  67. package/dist/parse/traceDependencies.d.ts.map +0 -1
  68. package/dist/parse/traceDependencies.js +0 -195
  69. package/dist/parse/traceDependencies.js.map +0 -1
@@ -0,0 +1,91 @@
1
+ import ts from 'typescript';
2
+ /**
3
+ * Represents a lint error found during validation
4
+ */
5
+ export interface LintError {
6
+ line: number;
7
+ column?: number;
8
+ message: string;
9
+ }
10
+ /**
11
+ * Context containing pre-parsed AST information for lint rules
12
+ * This allows rules to avoid redundant AST traversals
13
+ */
14
+ export interface LintRuleContext {
15
+ sourceFile: ts.SourceFile;
16
+ bubbleFlowClass: ts.ClassDeclaration | null;
17
+ handleMethod: ts.MethodDeclaration | null;
18
+ handleMethodBody: ts.Block | null;
19
+ importedBubbleClasses: Set<string>;
20
+ }
21
+ /**
22
+ * Interface for lint rules that can validate BubbleFlow code
23
+ */
24
+ export interface LintRule {
25
+ name: string;
26
+ validate(context: LintRuleContext): LintError[];
27
+ }
28
+ /**
29
+ * Registry that manages and executes all lint rules
30
+ */
31
+ export declare class LintRuleRegistry {
32
+ private rules;
33
+ /**
34
+ * Register a lint rule
35
+ */
36
+ register(rule: LintRule): void;
37
+ /**
38
+ * Execute all registered rules on the given code
39
+ * Traverses AST once and shares context with all rules for efficiency
40
+ */
41
+ validateAll(sourceFile: ts.SourceFile): LintError[];
42
+ /**
43
+ * Get all registered rule names
44
+ */
45
+ getRuleNames(): string[];
46
+ }
47
+ /**
48
+ * Lint rule that prevents throw statements directly in the handle method
49
+ */
50
+ export declare const noThrowInHandleRule: LintRule;
51
+ /**
52
+ * Lint rule that prevents direct bubble instantiation in the handle method
53
+ */
54
+ export declare const noDirectBubbleInstantiationInHandleRule: LintRule;
55
+ /**
56
+ * Lint rule that prevents credentials parameter from being used in bubble instantiations
57
+ */
58
+ export declare const noCredentialsParameterRule: LintRule;
59
+ /**
60
+ * Lint rule that prevents usage of process.env
61
+ */
62
+ export declare const noProcessEnvRule: LintRule;
63
+ /**
64
+ * Lint rule that prevents method invocations inside complex expressions
65
+ */
66
+ export declare const noMethodInvocationInComplexExpressionRule: LintRule;
67
+ /**
68
+ * Lint rule that prevents try-catch statements in the handle method
69
+ * Try-catch blocks interfere with runtime instrumentation and error handling
70
+ */
71
+ export declare const noTryCatchInHandleRule: LintRule;
72
+ /**
73
+ * Lint rule that prevents methods from calling other methods
74
+ * Methods should only be called from the handle method, not from other methods
75
+ */
76
+ export declare const noMethodCallingMethodRule: LintRule;
77
+ /**
78
+ * Lint rule that prevents usage of 'any' type
79
+ * Using 'any' bypasses TypeScript's type checking and should be avoided
80
+ */
81
+ export declare const noAnyTypeRule: LintRule;
82
+ /**
83
+ * Lint rule that prevents multiple BubbleFlow classes in a single file
84
+ * Only one class extending BubbleFlow is allowed per file for proper runtime instrumentation
85
+ */
86
+ export declare const singleBubbleFlowClassRule: LintRule;
87
+ /**
88
+ * Default registry instance with all rules registered
89
+ */
90
+ export declare const defaultLintRuleRegistry: LintRuleRegistry;
91
+ //# sourceMappingURL=lint-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lint-rules.d.ts","sourceRoot":"","sources":["../../src/validation/lint-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC;IAC1B,eAAe,EAAE,EAAE,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAC5C,YAAY,EAAE,EAAE,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAC1C,gBAAgB,EAAE,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC;IAClC,qBAAqB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,SAAS,EAAE,CAAC;CACjD;AAED;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAAkB;IAE/B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAI9B;;;OAGG;IACH,WAAW,CAAC,UAAU,EAAE,EA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