@griffin-app/griffin-plan-executor 0.1.13 → 0.1.15

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 (68) hide show
  1. package/README.md +14 -14
  2. package/dist/events/adapters/in-memory.test.js +25 -23
  3. package/dist/events/adapters/in-memory.test.js.map +1 -1
  4. package/dist/events/adapters/kinesis.d.ts.map +1 -1
  5. package/dist/events/adapters/kinesis.js.map +1 -1
  6. package/dist/events/adapters/kinesis.test.js +22 -20
  7. package/dist/events/adapters/kinesis.test.js.map +1 -1
  8. package/dist/events/emitter.test.js +15 -15
  9. package/dist/events/emitter.test.js.map +1 -1
  10. package/dist/events/types.d.ts +12 -12
  11. package/dist/events/types.d.ts.map +1 -1
  12. package/dist/events/types.js +1 -1
  13. package/dist/executor.d.ts +2 -2
  14. package/dist/executor.d.ts.map +1 -1
  15. package/dist/executor.js +33 -43
  16. package/dist/executor.js.map +1 -1
  17. package/dist/executor.test.js +102 -102
  18. package/dist/executor.test.js.map +1 -1
  19. package/dist/index.d.ts +4 -4
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +2 -2
  22. package/dist/index.js.map +1 -1
  23. package/dist/secrets/index.d.ts +4 -4
  24. package/dist/secrets/index.d.ts.map +1 -1
  25. package/dist/secrets/index.js +4 -4
  26. package/dist/secrets/index.js.map +1 -1
  27. package/dist/secrets/providers/aws.d.ts.map +1 -1
  28. package/dist/secrets/providers/aws.js +4 -5
  29. package/dist/secrets/providers/aws.js.map +1 -1
  30. package/dist/secrets/providers/env.js +1 -1
  31. package/dist/secrets/providers/env.js.map +1 -1
  32. package/dist/secrets/providers/vault.js +7 -7
  33. package/dist/secrets/providers/vault.js.map +1 -1
  34. package/dist/secrets/registry.d.ts +11 -33
  35. package/dist/secrets/registry.d.ts.map +1 -1
  36. package/dist/secrets/registry.js +65 -113
  37. package/dist/secrets/registry.js.map +1 -1
  38. package/dist/secrets/resolver.d.ts +12 -12
  39. package/dist/secrets/resolver.d.ts.map +1 -1
  40. package/dist/secrets/resolver.js +21 -21
  41. package/dist/secrets/resolver.js.map +1 -1
  42. package/dist/secrets/secrets.test.js +96 -120
  43. package/dist/secrets/secrets.test.js.map +1 -1
  44. package/dist/secrets/types.d.ts +2 -5
  45. package/dist/secrets/types.d.ts.map +1 -1
  46. package/dist/secrets/types.js +1 -4
  47. package/dist/secrets/types.js.map +1 -1
  48. package/dist/types.d.ts +2 -2
  49. package/package.json +4 -4
  50. package/src/events/adapters/README.md +7 -7
  51. package/src/events/adapters/in-memory.test.ts +27 -23
  52. package/src/events/adapters/kinesis.test.ts +23 -21
  53. package/src/events/adapters/kinesis.ts +6 -3
  54. package/src/events/emitter.test.ts +15 -15
  55. package/src/events/types.ts +13 -13
  56. package/src/executor.test.ts +103 -103
  57. package/src/executor.ts +40 -48
  58. package/src/index.ts +7 -7
  59. package/src/secrets/index.ts +5 -5
  60. package/src/secrets/providers/aws.ts +4 -5
  61. package/src/secrets/providers/env.ts +1 -1
  62. package/src/secrets/providers/vault.ts +7 -7
  63. package/src/secrets/registry.ts +75 -142
  64. package/src/secrets/resolver.ts +28 -26
  65. package/src/secrets/secrets.test.ts +124 -155
  66. package/src/secrets/types.ts +4 -13
  67. package/src/{test-plan-types.ts → test-monitor-types.ts} +1 -1
  68. package/src/types.ts +2 -2
@@ -1,25 +1,25 @@
1
1
  import { describe, it, expect, beforeEach } from "vitest";
2
- import { executePlanV1 } from "./executor.js";
2
+ import { executeMonitorV1 } from "./executor.js";
3
3
  import { StubAdapter } from "./adapters/stub.js";
4
4
  import {
5
5
  FrequencyUnit,
6
6
  HttpMethod,
7
7
  ResponseFormat,
8
8
  } from "@griffin-app/griffin-hub-sdk";
9
- import { PlanV1 } from "@griffin-app/griffin-hub-sdk";
9
+ import { MonitorV1 } from "@griffin-app/griffin-hub-sdk";
10
10
  import { START, END, type ExecutionOptions } from "./types.js";
11
11
  import { LocalEventEmitter, type ExecutionEvent } from "./events";
12
12
  import { SecretProviderRegistry } from "./secrets/registry.js";
13
13
  import { EnvSecretProvider } from "./secrets/providers/env.js";
14
14
 
15
- describe("executePlanV1", () => {
15
+ describe("executeMonitorV1", () => {
16
16
  let stubClient: StubAdapter;
17
17
  let options: ExecutionOptions;
18
18
  let organizationId: string = "test-org";
19
19
  beforeEach(() => {
20
20
  stubClient = new StubAdapter();
21
21
  const secretRegistry = new SecretProviderRegistry();
22
- secretRegistry.register(new EnvSecretProvider());
22
+ secretRegistry.setProvider(new EnvSecretProvider());
23
23
  options = {
24
24
  mode: "local",
25
25
  httpClient: stubClient,
@@ -30,8 +30,8 @@ describe("executePlanV1", () => {
30
30
 
31
31
  describe("Single HttpRequest Execution", () => {
32
32
  it("should execute a simple GET request successfully", async () => {
33
- const plan: PlanV1 = {
34
- id: "test-plan-1",
33
+ const monitor: MonitorV1 = {
34
+ id: "test-monitor-1",
35
35
  project: "test-project",
36
36
  frequency: { every: 1, unit: "MINUTE" },
37
37
  name: "Simple GET Test",
@@ -68,7 +68,7 @@ describe("executePlanV1", () => {
68
68
  },
69
69
  });
70
70
 
71
- const result = await executePlanV1(plan, organizationId, options);
71
+ const result = await executeMonitorV1(monitor, organizationId, options);
72
72
 
73
73
  expect(result.success).toBe(true);
74
74
  expect(result.errors).toHaveLength(0);
@@ -82,8 +82,8 @@ describe("executePlanV1", () => {
82
82
  });
83
83
 
84
84
  it("should execute a POST request with body and headers", async () => {
85
- const plan: PlanV1 = {
86
- id: "test-plan-2",
85
+ const monitor: MonitorV1 = {
86
+ id: "test-monitor-2",
87
87
  name: "POST Test",
88
88
  version: "1.0",
89
89
  environment: "default",
@@ -126,7 +126,7 @@ describe("executePlanV1", () => {
126
126
  },
127
127
  });
128
128
 
129
- const result = await executePlanV1(plan, organizationId, options);
129
+ const result = await executeMonitorV1(monitor, organizationId, options);
130
130
 
131
131
  expect(result.success).toBe(true);
132
132
  expect(result.results[0].response).toEqual({
@@ -137,8 +137,8 @@ describe("executePlanV1", () => {
137
137
  });
138
138
 
139
139
  it("should handle JSON string responses by parsing them", async () => {
140
- const plan: PlanV1 = {
141
- id: "test-plan-3",
140
+ const monitor: MonitorV1 = {
141
+ id: "test-monitor-3",
142
142
  name: "JSON String Response Test",
143
143
  version: "1.0",
144
144
  environment: "default",
@@ -175,15 +175,15 @@ describe("executePlanV1", () => {
175
175
  },
176
176
  });
177
177
 
178
- const result = await executePlanV1(plan, organizationId, options);
178
+ const result = await executeMonitorV1(monitor, organizationId, options);
179
179
 
180
180
  expect(result.success).toBe(true);
181
181
  expect(result.results[0].response).toEqual({ message: "hello" });
182
182
  });
183
183
 
184
184
  it("should override endpoint_host with baseUrl option", async () => {
185
- const plan: PlanV1 = {
186
- id: "test-plan-4",
185
+ const monitor: MonitorV1 = {
186
+ id: "test-monitor-4",
187
187
  name: "BaseUrl Override Test",
188
188
  version: "1.0",
189
189
  environment: "default",
@@ -220,7 +220,7 @@ describe("executePlanV1", () => {
220
220
  },
221
221
  });
222
222
 
223
- const result = await executePlanV1(plan, organizationId, options);
223
+ const result = await executeMonitorV1(monitor, organizationId, options);
224
224
 
225
225
  expect(result.success).toBe(true);
226
226
  });
@@ -228,8 +228,8 @@ describe("executePlanV1", () => {
228
228
 
229
229
  describe("Multiple HTTP Methods", () => {
230
230
  it("should handle PUT requests", async () => {
231
- const plan: PlanV1 = {
232
- id: "test-plan-5",
231
+ const monitor: MonitorV1 = {
232
+ id: "test-monitor-5",
233
233
  project: "test-project",
234
234
  frequency: { every: 1, unit: "MINUTE" },
235
235
  name: "PUT Test",
@@ -267,7 +267,7 @@ describe("executePlanV1", () => {
267
267
  },
268
268
  });
269
269
 
270
- const result = await executePlanV1(plan, organizationId, options);
270
+ const result = await executeMonitorV1(monitor, organizationId, options);
271
271
 
272
272
  expect(result.success).toBe(true);
273
273
  expect(result.results[0].response).toEqual({
@@ -277,8 +277,8 @@ describe("executePlanV1", () => {
277
277
  });
278
278
 
279
279
  it("should handle DELETE requests", async () => {
280
- const plan: PlanV1 = {
281
- id: "test-plan-6",
280
+ const monitor: MonitorV1 = {
281
+ id: "test-monitor-6",
282
282
  project: "test-project",
283
283
  frequency: { every: 1, unit: "MINUTE" },
284
284
  name: "DELETE Test",
@@ -315,15 +315,15 @@ describe("executePlanV1", () => {
315
315
  },
316
316
  });
317
317
 
318
- const result = await executePlanV1(plan, organizationId, options);
318
+ const result = await executeMonitorV1(monitor, organizationId, options);
319
319
 
320
320
  expect(result.success).toBe(true);
321
321
  expect(result.results[0].response).toBeNull();
322
322
  });
323
323
 
324
324
  it("should handle PATCH requests", async () => {
325
- const plan: PlanV1 = {
326
- id: "test-plan-7",
325
+ const monitor: MonitorV1 = {
326
+ id: "test-monitor-7",
327
327
  project: "test-project",
328
328
  frequency: { every: 1, unit: "MINUTE" },
329
329
  name: "PATCH Test",
@@ -361,7 +361,7 @@ describe("executePlanV1", () => {
361
361
  },
362
362
  });
363
363
 
364
- const result = await executePlanV1(plan, organizationId, options);
364
+ const result = await executeMonitorV1(monitor, organizationId, options);
365
365
 
366
366
  expect(result.success).toBe(true);
367
367
  });
@@ -369,8 +369,8 @@ describe("executePlanV1", () => {
369
369
 
370
370
  describe("Sequential Execution", () => {
371
371
  it("should execute two endpoints in sequence", async () => {
372
- const plan: PlanV1 = {
373
- id: "test-plan-8",
372
+ const monitor: MonitorV1 = {
373
+ id: "test-monitor-8",
374
374
  project: "test-project",
375
375
  frequency: { every: 1, unit: "MINUTE" },
376
376
  name: "Sequential Test",
@@ -428,7 +428,7 @@ describe("executePlanV1", () => {
428
428
  },
429
429
  });
430
430
 
431
- const result = await executePlanV1(plan, organizationId, options);
431
+ const result = await executeMonitorV1(monitor, organizationId, options);
432
432
 
433
433
  expect(result.success).toBe(true);
434
434
  expect(result.results).toHaveLength(2);
@@ -439,8 +439,8 @@ describe("executePlanV1", () => {
439
439
  });
440
440
 
441
441
  it("should execute a linear chain of multiple endpoints", async () => {
442
- const plan: PlanV1 = {
443
- id: "test-plan-9",
442
+ const monitor: MonitorV1 = {
443
+ id: "test-monitor-9",
444
444
  project: "test-project",
445
445
  frequency: { every: 1, unit: "MINUTE" },
446
446
  name: "Multi-Step Linear Test",
@@ -522,7 +522,7 @@ describe("executePlanV1", () => {
522
522
  response: { status: 200, statusText: "OK", data: { step: 4 } },
523
523
  });
524
524
 
525
- const result = await executePlanV1(plan, organizationId, options);
525
+ const result = await executeMonitorV1(monitor, organizationId, options);
526
526
 
527
527
  expect(result.success).toBe(true);
528
528
  expect(result.results).toHaveLength(4);
@@ -535,8 +535,8 @@ describe("executePlanV1", () => {
535
535
 
536
536
  describe("Wait Node", () => {
537
537
  it("should execute a wait node successfully", async () => {
538
- const plan: PlanV1 = {
539
- id: "test-plan-10",
538
+ const monitor: MonitorV1 = {
539
+ id: "test-monitor-10",
540
540
  project: "test-project",
541
541
  frequency: { every: 1, unit: "MINUTE" },
542
542
  name: "Wait Test",
@@ -562,7 +562,7 @@ describe("executePlanV1", () => {
562
562
  };
563
563
 
564
564
  const startTime = Date.now();
565
- const result = await executePlanV1(plan, organizationId, options);
565
+ const result = await executeMonitorV1(monitor, organizationId, options);
566
566
  const endTime = Date.now();
567
567
 
568
568
  expect(result.success).toBe(true);
@@ -574,8 +574,8 @@ describe("executePlanV1", () => {
574
574
  });
575
575
 
576
576
  it("should execute endpoints with waits in between", async () => {
577
- const plan: PlanV1 = {
578
- id: "test-plan-11",
577
+ const monitor: MonitorV1 = {
578
+ id: "test-monitor-11",
579
579
  project: "test-project",
580
580
  frequency: { every: 1, unit: "MINUTE" },
581
581
  name: "HttpRequest-Wait-HttpRequest Test",
@@ -634,7 +634,7 @@ describe("executePlanV1", () => {
634
634
  response: { status: 200, statusText: "OK", data: { step: 2 } },
635
635
  });
636
636
 
637
- const result = await executePlanV1(plan, organizationId, options);
637
+ const result = await executeMonitorV1(monitor, organizationId, options);
638
638
 
639
639
  expect(result.success).toBe(true);
640
640
  expect(result.results).toHaveLength(3);
@@ -645,8 +645,8 @@ describe("executePlanV1", () => {
645
645
 
646
646
  describe("Assertion Node", () => {
647
647
  it("should execute an assertion node (currently no-op)", async () => {
648
- const plan: PlanV1 = {
649
- id: "test-plan-12",
648
+ const monitor: MonitorV1 = {
649
+ id: "test-monitor-12",
650
650
  project: "test-project",
651
651
  frequency: { every: 1, unit: "MINUTE" },
652
652
  name: "Assertion Test",
@@ -692,7 +692,7 @@ describe("executePlanV1", () => {
692
692
  },
693
693
  });
694
694
 
695
- const result = await executePlanV1(plan, organizationId, options);
695
+ const result = await executeMonitorV1(monitor, organizationId, options);
696
696
 
697
697
  expect(result.success).toBe(true);
698
698
  expect(result.results).toHaveLength(2);
@@ -703,8 +703,8 @@ describe("executePlanV1", () => {
703
703
 
704
704
  describe("Error Handling", () => {
705
705
  it("should handle failed HTTP requests gracefully", async () => {
706
- const plan: PlanV1 = {
707
- id: "test-plan-13",
706
+ const monitor: MonitorV1 = {
707
+ id: "test-monitor-13",
708
708
  project: "test-project",
709
709
  frequency: { every: 1, unit: "MINUTE" },
710
710
  name: "Failed Request Test",
@@ -734,7 +734,7 @@ describe("executePlanV1", () => {
734
734
 
735
735
  // Don't add a stub - this will cause the request to fail
736
736
 
737
- const result = await executePlanV1(plan, organizationId, options);
737
+ const result = await executeMonitorV1(monitor, organizationId, options);
738
738
 
739
739
  expect(result.success).toBe(false);
740
740
  expect(result.errors).toHaveLength(1);
@@ -745,8 +745,8 @@ describe("executePlanV1", () => {
745
745
  });
746
746
 
747
747
  it("should handle disconnected nodes gracefully", async () => {
748
- const plan: PlanV1 = {
749
- id: "test-plan-14",
748
+ const monitor: MonitorV1 = {
749
+ id: "test-monitor-14",
750
750
  project: "test-project",
751
751
  frequency: { every: 1, unit: "MINUTE" },
752
752
  name: "Disconnected Nodes Test",
@@ -786,7 +786,7 @@ describe("executePlanV1", () => {
786
786
  },
787
787
  });
788
788
 
789
- const result = await executePlanV1(plan, organizationId, options);
789
+ const result = await executeMonitorV1(monitor, organizationId, options);
790
790
 
791
791
  // Graph can execute but disconnected nodes are not executed
792
792
  expect(result.success).toBe(true);
@@ -794,8 +794,8 @@ describe("executePlanV1", () => {
794
794
  });
795
795
 
796
796
  it("should continue execution after a failed node", async () => {
797
- const plan: PlanV1 = {
798
- id: "test-plan-15",
797
+ const monitor: MonitorV1 = {
798
+ id: "test-monitor-15",
799
799
  project: "test-project",
800
800
  frequency: { every: 1, unit: "MINUTE" },
801
801
  name: "Continue After Failure Test",
@@ -841,7 +841,7 @@ describe("executePlanV1", () => {
841
841
  });
842
842
  // No stub for /fail - it will fail
843
843
 
844
- const result = await executePlanV1(plan, organizationId, options);
844
+ const result = await executeMonitorV1(monitor, organizationId, options);
845
845
 
846
846
  expect(result.success).toBe(false);
847
847
  expect(result.results).toHaveLength(2);
@@ -852,8 +852,8 @@ describe("executePlanV1", () => {
852
852
 
853
853
  describe("Response Storage", () => {
854
854
  it("should store successful responses for downstream nodes", async () => {
855
- const plan: PlanV1 = {
856
- id: "test-plan-16",
855
+ const monitor: MonitorV1 = {
856
+ id: "test-monitor-16",
857
857
  project: "test-project",
858
858
  frequency: { every: 1, unit: "MINUTE" },
859
859
  name: "Response Storage Test",
@@ -911,7 +911,7 @@ describe("executePlanV1", () => {
911
911
  },
912
912
  });
913
913
 
914
- const result = await executePlanV1(plan, organizationId, options);
914
+ const result = await executeMonitorV1(monitor, organizationId, options);
915
915
 
916
916
  expect(result.success).toBe(true);
917
917
  expect(result.results[0].response).toEqual({ userId: 123 });
@@ -919,8 +919,8 @@ describe("executePlanV1", () => {
919
919
  });
920
920
 
921
921
  it("should not store failed responses", async () => {
922
- const plan: PlanV1 = {
923
- id: "test-plan-17",
922
+ const monitor: MonitorV1 = {
923
+ id: "test-monitor-17",
924
924
  project: "test-project",
925
925
  frequency: { every: 1, unit: "MINUTE" },
926
926
  name: "Failed Response Not Stored Test",
@@ -950,7 +950,7 @@ describe("executePlanV1", () => {
950
950
 
951
951
  // No stub configured - will fail
952
952
 
953
- const result = await executePlanV1(plan, organizationId, options);
953
+ const result = await executeMonitorV1(monitor, organizationId, options);
954
954
 
955
955
  expect(result.success).toBe(false);
956
956
  expect(result.results[0].response).toBeUndefined();
@@ -959,8 +959,8 @@ describe("executePlanV1", () => {
959
959
 
960
960
  describe("Timing and Performance", () => {
961
961
  it("should track total execution duration", async () => {
962
- const plan: PlanV1 = {
963
- id: "test-plan-18",
962
+ const monitor: MonitorV1 = {
963
+ id: "test-monitor-18",
964
964
  name: "Timing Test",
965
965
  version: "1.0",
966
966
  environment: "default",
@@ -997,7 +997,7 @@ describe("executePlanV1", () => {
997
997
  },
998
998
  });
999
999
 
1000
- const result = await executePlanV1(plan, organizationId, options);
1000
+ const result = await executeMonitorV1(monitor, organizationId, options);
1001
1001
 
1002
1002
  expect(result.totalDuration_ms).toBeGreaterThanOrEqual(0);
1003
1003
  expect(result.totalDuration_ms).toBeGreaterThanOrEqual(
@@ -1006,8 +1006,8 @@ describe("executePlanV1", () => {
1006
1006
  });
1007
1007
 
1008
1008
  it("should track individual node durations", async () => {
1009
- const plan: PlanV1 = {
1010
- id: "test-plan-19",
1009
+ const monitor: MonitorV1 = {
1010
+ id: "test-monitor-19",
1011
1011
  project: "test-project",
1012
1012
  frequency: { every: 1, unit: "MINUTE" },
1013
1013
  name: "Node Duration Test",
@@ -1066,7 +1066,7 @@ describe("executePlanV1", () => {
1066
1066
  response: { status: 200, statusText: "OK", data: {} },
1067
1067
  });
1068
1068
 
1069
- const result = await executePlanV1(plan, organizationId, options);
1069
+ const result = await executeMonitorV1(monitor, organizationId, options);
1070
1070
 
1071
1071
  expect(result.success).toBe(true);
1072
1072
  result.results.forEach((nodeResult) => {
@@ -1077,12 +1077,12 @@ describe("executePlanV1", () => {
1077
1077
  });
1078
1078
 
1079
1079
  describe("Edge Cases", () => {
1080
- it("should handle empty plan (no nodes)", async () => {
1081
- const plan: PlanV1 = {
1082
- id: "test-plan-20",
1080
+ it("should handle empty monitor (no nodes)", async () => {
1081
+ const monitor: MonitorV1 = {
1082
+ id: "test-monitor-20",
1083
1083
  project: "test-project",
1084
1084
  frequency: { every: 1, unit: "MINUTE" },
1085
- name: "Empty Plan Test",
1085
+ name: "Empty Monitor Test",
1086
1086
  version: "1.0",
1087
1087
  environment: "default",
1088
1088
  nodes: [],
@@ -1094,17 +1094,17 @@ describe("executePlanV1", () => {
1094
1094
  ],
1095
1095
  };
1096
1096
 
1097
- const result = await executePlanV1(plan, organizationId, options);
1097
+ const result = await executeMonitorV1(monitor, organizationId, options);
1098
1098
 
1099
- // Empty plan with just START->END should succeed with no results
1099
+ // Empty monitor with just START->END should succeed with no results
1100
1100
  expect(result.success).toBe(true);
1101
1101
  expect(result.results).toHaveLength(0);
1102
1102
  expect(result.errors).toHaveLength(0);
1103
1103
  });
1104
1104
 
1105
1105
  it("should handle single node with no edges", async () => {
1106
- const plan: PlanV1 = {
1107
- id: "test-plan-21",
1106
+ const monitor: MonitorV1 = {
1107
+ id: "test-monitor-21",
1108
1108
  project: "test-project",
1109
1109
  frequency: { every: 1, unit: "MINUTE" },
1110
1110
  name: "Single Node Test",
@@ -1141,15 +1141,15 @@ describe("executePlanV1", () => {
1141
1141
  },
1142
1142
  });
1143
1143
 
1144
- const result = await executePlanV1(plan, organizationId, options);
1144
+ const result = await executeMonitorV1(monitor, organizationId, options);
1145
1145
 
1146
1146
  expect(result.success).toBe(true);
1147
1147
  expect(result.results).toHaveLength(1);
1148
1148
  });
1149
1149
 
1150
1150
  it("should handle complex response data types", async () => {
1151
- const plan: PlanV1 = {
1152
- id: "test-plan-22",
1151
+ const monitor: MonitorV1 = {
1152
+ id: "test-monitor-22",
1153
1153
  project: "test-project",
1154
1154
  frequency: { every: 1, unit: "MINUTE" },
1155
1155
  name: "Complex Data Test",
@@ -1199,7 +1199,7 @@ describe("executePlanV1", () => {
1199
1199
  },
1200
1200
  });
1201
1201
 
1202
- const result = await executePlanV1(plan, organizationId, options);
1202
+ const result = await executeMonitorV1(monitor, organizationId, options);
1203
1203
 
1204
1204
  expect(result.success).toBe(true);
1205
1205
  expect(result.results[0].response).toEqual(complexData);
@@ -1216,12 +1216,12 @@ describe("executePlanV1", () => {
1216
1216
  emitter.subscribe((event) => events.push(event));
1217
1217
  });
1218
1218
 
1219
- it("should emit PLAN_START and PLAN_END events", async () => {
1220
- const plan: PlanV1 = {
1219
+ it("should emit MONITOR_START and MONITOR_END events", async () => {
1220
+ const monitor: MonitorV1 = {
1221
1221
  id: "event-test-1",
1222
1222
  project: "test-project",
1223
1223
  frequency: { every: 1, unit: "MINUTE" },
1224
- name: "Event Test Plan",
1224
+ name: "Event Test Monitor",
1225
1225
  version: "1.0",
1226
1226
  environment: "default",
1227
1227
  nodes: [
@@ -1251,30 +1251,30 @@ describe("executePlanV1", () => {
1251
1251
  response: { status: 200, statusText: "OK", data: { ok: true } },
1252
1252
  });
1253
1253
 
1254
- await executePlanV1(plan, organizationId, {
1254
+ await executeMonitorV1(monitor, organizationId, {
1255
1255
  ...options,
1256
1256
  eventEmitter: emitter,
1257
1257
  });
1258
1258
 
1259
- const planStartEvents = events.filter((e) => e.type === "PLAN_START");
1260
- const planEndEvents = events.filter((e) => e.type === "PLAN_END");
1259
+ const planStartEvents = events.filter((e) => e.type === "MONITOR_START");
1260
+ const planEndEvents = events.filter((e) => e.type === "MONITOR_END");
1261
1261
 
1262
1262
  expect(planStartEvents).toHaveLength(1);
1263
1263
  expect(planEndEvents).toHaveLength(1);
1264
1264
 
1265
1265
  const planStart = planStartEvents[0];
1266
1266
  expect(planStart).toMatchObject({
1267
- type: "PLAN_START",
1268
- planId: "event-test-1",
1269
- planName: "Event Test Plan",
1270
- planVersion: "1.0",
1267
+ type: "MONITOR_START",
1268
+ monitorId: "event-test-1",
1269
+ monitorName: "Event Test Monitor",
1270
+ monitorVersion: "1.0",
1271
1271
  nodeCount: 1,
1272
1272
  edgeCount: 2,
1273
1273
  });
1274
1274
 
1275
1275
  const planEnd = planEndEvents[0];
1276
1276
  expect(planEnd).toMatchObject({
1277
- type: "PLAN_END",
1277
+ type: "MONITOR_END",
1278
1278
  success: true,
1279
1279
  nodeResultCount: 1,
1280
1280
  errorCount: 0,
@@ -1282,7 +1282,7 @@ describe("executePlanV1", () => {
1282
1282
  });
1283
1283
 
1284
1284
  it("should emit NODE_START and NODE_END events for each node", async () => {
1285
- const plan: PlanV1 = {
1285
+ const monitor: MonitorV1 = {
1286
1286
  id: "event-test-2",
1287
1287
  project: "test-project",
1288
1288
  frequency: { every: 1, unit: "MINUTE" },
@@ -1342,7 +1342,7 @@ describe("executePlanV1", () => {
1342
1342
  response: { status: 200, statusText: "OK", data: { step: 2 } },
1343
1343
  });
1344
1344
 
1345
- await executePlanV1(plan, organizationId, {
1345
+ await executeMonitorV1(monitor, organizationId, {
1346
1346
  ...options,
1347
1347
  eventEmitter: emitter,
1348
1348
  });
@@ -1369,7 +1369,7 @@ describe("executePlanV1", () => {
1369
1369
  });
1370
1370
 
1371
1371
  it("should emit HTTP_REQUEST and HTTP_RESPONSE events for endpoint nodes", async () => {
1372
- const plan: PlanV1 = {
1372
+ const monitor: MonitorV1 = {
1373
1373
  id: "event-test-3",
1374
1374
  project: "test-project",
1375
1375
  frequency: { every: 1, unit: "MINUTE" },
@@ -1405,7 +1405,7 @@ describe("executePlanV1", () => {
1405
1405
  response: { status: 201, statusText: "Created", data: { id: 123 } },
1406
1406
  });
1407
1407
 
1408
- await executePlanV1(plan, organizationId, {
1408
+ await executeMonitorV1(monitor, organizationId, {
1409
1409
  ...options,
1410
1410
  eventEmitter: emitter,
1411
1411
  });
@@ -1444,7 +1444,7 @@ describe("executePlanV1", () => {
1444
1444
  });
1445
1445
 
1446
1446
  it("should emit WAIT_START event for wait nodes", async () => {
1447
- const plan: PlanV1 = {
1447
+ const monitor: MonitorV1 = {
1448
1448
  id: "event-test-4",
1449
1449
  project: "test-project",
1450
1450
  frequency: { every: 1, unit: "MINUTE" },
@@ -1470,7 +1470,7 @@ describe("executePlanV1", () => {
1470
1470
  ],
1471
1471
  };
1472
1472
 
1473
- await executePlanV1(plan, organizationId, {
1473
+ await executeMonitorV1(monitor, organizationId, {
1474
1474
  ...options,
1475
1475
  eventEmitter: emitter,
1476
1476
  });
@@ -1486,7 +1486,7 @@ describe("executePlanV1", () => {
1486
1486
  });
1487
1487
 
1488
1488
  it("should emit ERROR event on HTTP request failure", async () => {
1489
- const plan: PlanV1 = {
1489
+ const monitor: MonitorV1 = {
1490
1490
  id: "event-test-5",
1491
1491
  project: "test-project",
1492
1492
  frequency: { every: 1, unit: "MINUTE" },
@@ -1517,7 +1517,7 @@ describe("executePlanV1", () => {
1517
1517
 
1518
1518
  // No stub - request will fail
1519
1519
 
1520
- const result = await executePlanV1(plan, organizationId, {
1520
+ const result = await executeMonitorV1(monitor, organizationId, {
1521
1521
  ...options,
1522
1522
  eventEmitter: emitter,
1523
1523
  });
@@ -1529,7 +1529,7 @@ describe("executePlanV1", () => {
1529
1529
  });
1530
1530
 
1531
1531
  it("should maintain monotonic sequence numbers", async () => {
1532
- const plan: PlanV1 = {
1532
+ const monitor: MonitorV1 = {
1533
1533
  id: "event-test-6",
1534
1534
  project: "test-project",
1535
1535
  frequency: { every: 1, unit: "MINUTE" },
@@ -1563,7 +1563,7 @@ describe("executePlanV1", () => {
1563
1563
  response: { status: 200, statusText: "OK", data: {} },
1564
1564
  });
1565
1565
 
1566
- await executePlanV1(plan, organizationId, {
1566
+ await executeMonitorV1(monitor, organizationId, {
1567
1567
  ...options,
1568
1568
  eventEmitter: emitter,
1569
1569
  });
@@ -1585,7 +1585,7 @@ describe("executePlanV1", () => {
1585
1585
  it("should use provided executionId if given", async () => {
1586
1586
  const customExecutionId = "custom-exec-id-123";
1587
1587
 
1588
- const plan: PlanV1 = {
1588
+ const monitor: MonitorV1 = {
1589
1589
  id: "event-test-7",
1590
1590
  project: "test-project",
1591
1591
  frequency: { every: 1, unit: "MINUTE" },
@@ -1619,7 +1619,7 @@ describe("executePlanV1", () => {
1619
1619
  response: { status: 200, statusText: "OK", data: {} },
1620
1620
  });
1621
1621
 
1622
- await executePlanV1(plan, organizationId, {
1622
+ await executeMonitorV1(monitor, organizationId, {
1623
1623
  ...options,
1624
1624
  eventEmitter: emitter,
1625
1625
  executionId: customExecutionId,
@@ -1632,7 +1632,7 @@ describe("executePlanV1", () => {
1632
1632
  });
1633
1633
 
1634
1634
  it("should emit events in correct order", async () => {
1635
- const plan: PlanV1 = {
1635
+ const monitor: MonitorV1 = {
1636
1636
  id: "event-test-8",
1637
1637
  project: "test-project",
1638
1638
  frequency: { every: 1, unit: "MINUTE" },
@@ -1666,24 +1666,24 @@ describe("executePlanV1", () => {
1666
1666
  response: { status: 200, statusText: "OK", data: {} },
1667
1667
  });
1668
1668
 
1669
- await executePlanV1(plan, organizationId, {
1669
+ await executeMonitorV1(monitor, organizationId, {
1670
1670
  ...options,
1671
1671
  eventEmitter: emitter,
1672
1672
  });
1673
1673
 
1674
1674
  const eventTypes = events.map((e) => e.type);
1675
1675
 
1676
- // Expected order: PLAN_START, NODE_START, HTTP_REQUEST, HTTP_RESPONSE, NODE_END, PLAN_END
1677
- expect(eventTypes[0]).toBe("PLAN_START");
1676
+ // Expected order: MONITOR_START, NODE_START, HTTP_REQUEST, HTTP_RESPONSE, NODE_END, MONITOR_END
1677
+ expect(eventTypes[0]).toBe("MONITOR_START");
1678
1678
  expect(eventTypes[1]).toBe("NODE_START");
1679
1679
  expect(eventTypes[2]).toBe("HTTP_REQUEST");
1680
1680
  expect(eventTypes[3]).toBe("HTTP_RESPONSE");
1681
1681
  expect(eventTypes[4]).toBe("NODE_END");
1682
- expect(eventTypes[5]).toBe("PLAN_END");
1682
+ expect(eventTypes[5]).toBe("MONITOR_END");
1683
1683
  });
1684
1684
 
1685
1685
  it("should handle failed HTTP requests correctly", async () => {
1686
- const plan: PlanV1 = {
1686
+ const monitor: MonitorV1 = {
1687
1687
  id: "event-test-9",
1688
1688
  name: "Failed Request Event Test",
1689
1689
  version: "1.0",
@@ -1714,7 +1714,7 @@ describe("executePlanV1", () => {
1714
1714
 
1715
1715
  // No stub - request will fail
1716
1716
 
1717
- await executePlanV1(plan, organizationId, {
1717
+ await executeMonitorV1(monitor, organizationId, {
1718
1718
  ...options,
1719
1719
  eventEmitter: emitter,
1720
1720
  });