@griffin-app/griffin-plan-executor 0.1.0 → 0.1.3

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.
@@ -1,14 +1,12 @@
1
1
  import { describe, it, expect, beforeEach } from "vitest";
2
2
  import { executePlanV1 } from "./executor.js";
3
3
  import { StubAdapter } from "./adapters/stub.js";
4
- import { NodeType, HttpMethod, ResponseFormat } from "griffin/schema";
5
- import { TestPlanV1 } from "griffin/types";
4
+ import { NodeType, HttpMethod, ResponseFormat } from "@griffin-app/griffin-ts/schema";
5
+ import { TestPlanV1 } from "@griffin-app/griffin-ts/types";
6
6
  import { START, END, type ExecutionOptions } from "./types.js";
7
7
  import { LocalEventEmitter, type ExecutionEvent } from "./events";
8
-
9
- function stubTargetResolver(key: string): Promise<string | undefined> {
10
- return Promise.resolve(`https://${key}.example.com`);
11
- }
8
+ import { SecretProviderRegistry } from "./secrets/registry.js";
9
+ import { EnvSecretProvider } from "./secrets/providers/env.js";
12
10
 
13
11
  describe("executePlanV1", () => {
14
12
  let stubClient: StubAdapter;
@@ -16,11 +14,13 @@ describe("executePlanV1", () => {
16
14
 
17
15
  beforeEach(() => {
18
16
  stubClient = new StubAdapter();
17
+ const secretRegistry = new SecretProviderRegistry();
18
+ secretRegistry.register(new EnvSecretProvider());
19
19
  options = {
20
20
  mode: "local",
21
21
  httpClient: stubClient,
22
22
  timeout: 5000,
23
- targetResolver: stubTargetResolver,
23
+ secretRegistry: secretRegistry,
24
24
  };
25
25
  });
26
26
 
@@ -37,7 +37,7 @@ describe("executePlanV1", () => {
37
37
  type: NodeType.ENDPOINT,
38
38
  method: HttpMethod.GET,
39
39
  path: "/users",
40
- base: { type: "target", key: "api" },
40
+ base: "https://api.example.com",
41
41
  response_format: ResponseFormat.JSON,
42
42
  },
43
43
  ],
@@ -86,7 +86,7 @@ describe("executePlanV1", () => {
86
86
  id: "create-user",
87
87
  type: NodeType.ENDPOINT,
88
88
  method: HttpMethod.POST,
89
- base: { type: "target", key: "api" },
89
+ base: "https://api.example.com",
90
90
  path: "/users",
91
91
  headers: {
92
92
  "Content-Type": "application/json",
@@ -140,7 +140,7 @@ describe("executePlanV1", () => {
140
140
  type: NodeType.ENDPOINT,
141
141
  method: HttpMethod.GET,
142
142
  path: "/data",
143
- base: { type: "target", key: "api" },
143
+ base: "https://api.example.com",
144
144
  response_format: ResponseFormat.JSON,
145
145
  },
146
146
  ],
@@ -182,7 +182,7 @@ describe("executePlanV1", () => {
182
182
  id: "get-users",
183
183
  type: NodeType.ENDPOINT,
184
184
  method: HttpMethod.GET,
185
- base: { type: "target", key: "api" },
185
+ base: "https://api.example.com",
186
186
  path: "/users",
187
187
  response_format: ResponseFormat.JSON,
188
188
  },
@@ -227,7 +227,7 @@ describe("executePlanV1", () => {
227
227
  type: NodeType.ENDPOINT,
228
228
  method: HttpMethod.PUT,
229
229
  path: "/users/1",
230
- base: { type: "target", key: "api" },
230
+ base: "https://api.example.com",
231
231
  body: { name: "Updated Name" },
232
232
  response_format: ResponseFormat.JSON,
233
233
  },
@@ -274,7 +274,7 @@ describe("executePlanV1", () => {
274
274
  type: NodeType.ENDPOINT,
275
275
  method: HttpMethod.DELETE,
276
276
  path: "/users/1",
277
- base: { type: "target", key: "api" },
277
+ base: "https://api.example.com",
278
278
  response_format: ResponseFormat.JSON,
279
279
  },
280
280
  ],
@@ -317,7 +317,7 @@ describe("executePlanV1", () => {
317
317
  type: NodeType.ENDPOINT,
318
318
  method: HttpMethod.PATCH,
319
319
  path: "/users/1",
320
- base: { type: "target", key: "api" },
320
+ base: "https://api.example.com",
321
321
  body: { email: "newemail@example.com" },
322
322
  response_format: ResponseFormat.JSON,
323
323
  },
@@ -362,7 +362,7 @@ describe("executePlanV1", () => {
362
362
  type: NodeType.ENDPOINT,
363
363
  method: HttpMethod.GET,
364
364
  path: "/first",
365
- base: { type: "target", key: "api" },
365
+ base: "https://api.example.com",
366
366
  response_format: ResponseFormat.JSON,
367
367
  },
368
368
  {
@@ -370,7 +370,7 @@ describe("executePlanV1", () => {
370
370
  type: NodeType.ENDPOINT,
371
371
  method: HttpMethod.GET,
372
372
  path: "/second",
373
- base: { type: "target", key: "api" },
373
+ base: "https://api.example.com",
374
374
  response_format: ResponseFormat.JSON,
375
375
  },
376
376
  ],
@@ -430,7 +430,7 @@ describe("executePlanV1", () => {
430
430
  type: NodeType.ENDPOINT,
431
431
  method: HttpMethod.GET,
432
432
  path: "/step1",
433
- base: { type: "target", key: "api" },
433
+ base: "https://api.example.com",
434
434
  response_format: ResponseFormat.JSON,
435
435
  },
436
436
  {
@@ -438,7 +438,7 @@ describe("executePlanV1", () => {
438
438
  type: NodeType.ENDPOINT,
439
439
  method: HttpMethod.GET,
440
440
  path: "/step2",
441
- base: { type: "target", key: "api" },
441
+ base: "https://api.example.com",
442
442
  response_format: ResponseFormat.JSON,
443
443
  },
444
444
  {
@@ -446,7 +446,7 @@ describe("executePlanV1", () => {
446
446
  type: NodeType.ENDPOINT,
447
447
  method: HttpMethod.GET,
448
448
  path: "/step3",
449
- base: { type: "target", key: "api" },
449
+ base: "https://api.example.com",
450
450
  response_format: ResponseFormat.JSON,
451
451
  },
452
452
  {
@@ -454,7 +454,7 @@ describe("executePlanV1", () => {
454
454
  type: NodeType.ENDPOINT,
455
455
  method: HttpMethod.GET,
456
456
  path: "/step4",
457
- base: { type: "target", key: "api" },
457
+ base: "https://api.example.com",
458
458
  response_format: ResponseFormat.JSON,
459
459
  },
460
460
  ],
@@ -561,7 +561,7 @@ describe("executePlanV1", () => {
561
561
  type: NodeType.ENDPOINT,
562
562
  method: HttpMethod.GET,
563
563
  path: "/first",
564
- base: { type: "target", key: "api" },
564
+ base: "https://api.example.com",
565
565
  response_format: ResponseFormat.JSON,
566
566
  },
567
567
  {
@@ -574,7 +574,7 @@ describe("executePlanV1", () => {
574
574
  type: NodeType.ENDPOINT,
575
575
  method: HttpMethod.GET,
576
576
  path: "/second",
577
- base: { type: "target", key: "api" },
577
+ base: "https://api.example.com",
578
578
  response_format: ResponseFormat.JSON,
579
579
  },
580
580
  ],
@@ -630,7 +630,7 @@ describe("executePlanV1", () => {
630
630
  type: NodeType.ENDPOINT,
631
631
  method: HttpMethod.GET,
632
632
  path: "/data",
633
- base: { type: "target", key: "api" },
633
+ base: "https://api.example.com",
634
634
  response_format: ResponseFormat.JSON,
635
635
  },
636
636
  {
@@ -686,7 +686,7 @@ describe("executePlanV1", () => {
686
686
  type: NodeType.ENDPOINT,
687
687
  method: HttpMethod.GET,
688
688
  path: "/fail",
689
- base: { type: "target", key: "api" },
689
+ base: "https://api.example.com",
690
690
  response_format: ResponseFormat.JSON,
691
691
  },
692
692
  ],
@@ -726,7 +726,7 @@ describe("executePlanV1", () => {
726
726
  type: NodeType.ENDPOINT,
727
727
  method: HttpMethod.GET,
728
728
  path: "/path",
729
- base: { type: "target", key: "api" },
729
+ base: "https://api.example.com",
730
730
  response_format: ResponseFormat.JSON,
731
731
  },
732
732
  {
@@ -734,7 +734,7 @@ describe("executePlanV1", () => {
734
734
  type: NodeType.ENDPOINT,
735
735
  method: HttpMethod.GET,
736
736
  path: "/path",
737
- base: { type: "target", key: "api" },
737
+ base: "https://api.example.com",
738
738
  response_format: ResponseFormat.JSON,
739
739
  },
740
740
  ],
@@ -773,7 +773,7 @@ describe("executePlanV1", () => {
773
773
  type: NodeType.ENDPOINT,
774
774
  method: HttpMethod.GET,
775
775
  path: "/success",
776
- base: { type: "target", key: "api" },
776
+ base: "https://api.example.com",
777
777
  response_format: ResponseFormat.JSON,
778
778
  },
779
779
  {
@@ -781,7 +781,7 @@ describe("executePlanV1", () => {
781
781
  type: NodeType.ENDPOINT,
782
782
  method: HttpMethod.GET,
783
783
  path: "/fail",
784
- base: { type: "target", key: "api" },
784
+ base: "https://api.example.com",
785
785
  response_format: ResponseFormat.JSON,
786
786
  },
787
787
  ],
@@ -829,7 +829,7 @@ describe("executePlanV1", () => {
829
829
  type: NodeType.ENDPOINT,
830
830
  method: HttpMethod.GET,
831
831
  path: "/user",
832
- base: { type: "target", key: "api" },
832
+ base: "https://api.example.com",
833
833
  response_format: ResponseFormat.JSON,
834
834
  },
835
835
  {
@@ -837,7 +837,7 @@ describe("executePlanV1", () => {
837
837
  type: NodeType.ENDPOINT,
838
838
  method: HttpMethod.GET,
839
839
  path: "/profile",
840
- base: { type: "target", key: "api" },
840
+ base: "https://api.example.com",
841
841
  response_format: ResponseFormat.JSON,
842
842
  },
843
843
  ],
@@ -894,7 +894,7 @@ describe("executePlanV1", () => {
894
894
  type: NodeType.ENDPOINT,
895
895
  method: HttpMethod.GET,
896
896
  path: "/fail",
897
- base: { type: "target", key: "api" },
897
+ base: "https://api.example.com",
898
898
  response_format: ResponseFormat.JSON,
899
899
  },
900
900
  ],
@@ -932,7 +932,7 @@ describe("executePlanV1", () => {
932
932
  type: NodeType.ENDPOINT,
933
933
  method: HttpMethod.GET,
934
934
  path: "/data",
935
- base: { type: "target", key: "api" },
935
+ base: "https://api.example.com",
936
936
  response_format: ResponseFormat.JSON,
937
937
  },
938
938
  ],
@@ -977,7 +977,7 @@ describe("executePlanV1", () => {
977
977
  type: NodeType.ENDPOINT,
978
978
  method: HttpMethod.GET,
979
979
  path: "/1",
980
- base: { type: "target", key: "api" },
980
+ base: "https://api.example.com",
981
981
  response_format: ResponseFormat.JSON,
982
982
  },
983
983
  {
@@ -990,7 +990,7 @@ describe("executePlanV1", () => {
990
990
  type: NodeType.ENDPOINT,
991
991
  method: HttpMethod.GET,
992
992
  path: "/2",
993
- base: { type: "target", key: "api" },
993
+ base: "https://api.example.com",
994
994
  response_format: ResponseFormat.JSON,
995
995
  },
996
996
  ],
@@ -1070,7 +1070,7 @@ describe("executePlanV1", () => {
1070
1070
  type: NodeType.ENDPOINT,
1071
1071
  method: HttpMethod.GET,
1072
1072
  path: "/single",
1073
- base: { type: "target", key: "api" },
1073
+ base: "https://api.example.com",
1074
1074
  response_format: ResponseFormat.JSON,
1075
1075
  },
1076
1076
  ],
@@ -1113,7 +1113,7 @@ describe("executePlanV1", () => {
1113
1113
  type: NodeType.ENDPOINT,
1114
1114
  method: HttpMethod.GET,
1115
1115
  path: "/complex",
1116
- base: { type: "target", key: "api" },
1116
+ base: "https://api.example.com",
1117
1117
  response_format: ResponseFormat.JSON,
1118
1118
  },
1119
1119
  ],
@@ -1180,7 +1180,7 @@ describe("executePlanV1", () => {
1180
1180
  type: NodeType.ENDPOINT,
1181
1181
  method: HttpMethod.GET,
1182
1182
  path: "/test",
1183
- base: { type: "target", key: "api" },
1183
+ base: "https://api.example.com",
1184
1184
  response_format: ResponseFormat.JSON,
1185
1185
  },
1186
1186
  ],
@@ -1243,7 +1243,7 @@ describe("executePlanV1", () => {
1243
1243
  type: NodeType.ENDPOINT,
1244
1244
  method: HttpMethod.GET,
1245
1245
  path: "/first",
1246
- base: { type: "target", key: "api" },
1246
+ base: "https://api.example.com",
1247
1247
  response_format: ResponseFormat.JSON,
1248
1248
  },
1249
1249
  {
@@ -1256,7 +1256,7 @@ describe("executePlanV1", () => {
1256
1256
  type: NodeType.ENDPOINT,
1257
1257
  method: HttpMethod.GET,
1258
1258
  path: "/second",
1259
- base: { type: "target", key: "api" },
1259
+ base: "https://api.example.com",
1260
1260
  response_format: ResponseFormat.JSON,
1261
1261
  },
1262
1262
  ],
@@ -1328,7 +1328,7 @@ describe("executePlanV1", () => {
1328
1328
  type: NodeType.ENDPOINT,
1329
1329
  method: HttpMethod.POST,
1330
1330
  path: "/create",
1331
- base: { type: "target", key: "api" },
1331
+ base: "https://api.example.com",
1332
1332
  headers: { "Content-Type": "application/json" },
1333
1333
  body: { name: "test" },
1334
1334
  response_format: ResponseFormat.JSON,
@@ -1441,7 +1441,7 @@ describe("executePlanV1", () => {
1441
1441
  type: NodeType.ENDPOINT,
1442
1442
  method: HttpMethod.GET,
1443
1443
  path: "/fail",
1444
- base: { type: "target", key: "api" },
1444
+ base: "https://api.example.com",
1445
1445
  response_format: ResponseFormat.JSON,
1446
1446
  },
1447
1447
  ],
@@ -1482,7 +1482,7 @@ describe("executePlanV1", () => {
1482
1482
  type: NodeType.ENDPOINT,
1483
1483
  method: HttpMethod.GET,
1484
1484
  path: "/test",
1485
- base: { type: "target", key: "api" },
1485
+ base: "https://api.example.com",
1486
1486
  response_format: ResponseFormat.JSON,
1487
1487
  },
1488
1488
  ],
@@ -1536,7 +1536,7 @@ describe("executePlanV1", () => {
1536
1536
  type: NodeType.ENDPOINT,
1537
1537
  method: HttpMethod.GET,
1538
1538
  path: "/test",
1539
- base: { type: "target", key: "api" },
1539
+ base: "https://api.example.com",
1540
1540
  response_format: ResponseFormat.JSON,
1541
1541
  },
1542
1542
  ],
@@ -1581,7 +1581,7 @@ describe("executePlanV1", () => {
1581
1581
  type: NodeType.ENDPOINT,
1582
1582
  method: HttpMethod.GET,
1583
1583
  path: "/test",
1584
- base: { type: "target", key: "api" },
1584
+ base: "https://api.example.com",
1585
1585
  response_format: ResponseFormat.JSON,
1586
1586
  },
1587
1587
  ],
@@ -1630,7 +1630,7 @@ describe("executePlanV1", () => {
1630
1630
  type: NodeType.ENDPOINT,
1631
1631
  method: HttpMethod.GET,
1632
1632
  path: "/fail",
1633
- base: { type: "target", key: "api" },
1633
+ base: "https://api.example.com",
1634
1634
  response_format: ResponseFormat.JSON,
1635
1635
  },
1636
1636
  ],
package/src/executor.ts CHANGED
@@ -6,11 +6,11 @@ import {
6
6
  Assertions,
7
7
  JSONAssertion,
8
8
  Assertion,
9
- } from "griffin/types";
9
+ } from "@griffin-app/griffin-ts/types";
10
10
 
11
- import { HttpMethod, ResponseFormat, NodeType } from "griffin/schema";
11
+ import { HttpMethod, ResponseFormat, NodeType } from "@griffin-app/griffin-ts/schema";
12
12
 
13
- import { UnaryPredicate, BinaryPredicateOperator } from "griffin";
13
+ import { UnaryPredicate, BinaryPredicateOperator } from "@griffin-app/griffin-ts";
14
14
 
15
15
  import type {
16
16
  ExecutionOptions,
@@ -514,14 +514,10 @@ async function executeEndpoint(
514
514
  );
515
515
  }
516
516
 
517
- const baseUrl = await options.targetResolver(endpoint.base.key);
518
- if (!baseUrl) {
519
- throw new Error(
520
- `Failed to resolve target "${endpoint.base.key}". Target not found in runner configuration.`,
521
- );
522
- }
523
-
524
- const url = `${baseUrl}${endpoint.path}`;
517
+ // endpoint.base and endpoint.path are already resolved strings
518
+ const baseUrl = endpoint.base;
519
+ const path = endpoint.path;
520
+ const url = `${baseUrl}${path}`;
525
521
 
526
522
  // TODO: Add retry configuration from plan (node-level or plan-level)
527
523
  // For now, we always attempt once (attempt: 1)
@@ -2,8 +2,8 @@
2
2
  * Secret resolution utilities for test plans.
3
3
  */
4
4
 
5
- import { TestPlanV1, Node } from "griffin/types";
6
- import { NodeType } from "griffin/schema";
5
+ import { TestPlanV1, Node } from "@griffin-app/griffin-ts/types";
6
+ import { NodeType } from "@griffin-app/griffin-ts/schema";
7
7
  import type { SecretProviderRegistry } from "./registry.js";
8
8
  import type { SecretRef, SecretRefData } from "./types.js";
9
9
  import { isSecretRef } from "./types.js";
@@ -7,8 +7,8 @@ import {
7
7
  collectSecretsFromPlan,
8
8
  planHasSecrets,
9
9
  } from "./resolver.js";
10
- import { NodeType, ResponseFormat, HttpMethod } from "griffin/schema";
11
- import { TestPlanV1 } from "griffin/types";
10
+ import { NodeType, ResponseFormat, HttpMethod } from "@griffin-app/griffin-ts/schema";
11
+ import { TestPlanV1 } from "@griffin-app/griffin-ts/types";
12
12
 
13
13
  // Helper to create a secret ref (mirrors the DSL's secret function)
14
14
  function createSecretRef(path: string) {
@@ -127,7 +127,7 @@ describe("Plan Secret Resolution", () => {
127
127
  type: NodeType.ENDPOINT,
128
128
  method: HttpMethod.GET,
129
129
  path: "/api/test",
130
- base: { type: "target", key: "api-gateway" },
130
+ base: { $variable: { key: "api-gateway" } },
131
131
  response_format: ResponseFormat.JSON,
132
132
  headers,
133
133
  body,
package/src/types.ts CHANGED
@@ -51,18 +51,7 @@ export interface ExecutionOptions {
51
51
  /** Unique execution ID for correlating events (generated if not provided) */
52
52
  executionId?: string;
53
53
 
54
- /**
55
- * Optional secret provider registry for resolving secret references.
56
- * If provided, secrets in the plan will be resolved before execution.
57
- * If not provided, any secret references in the plan will cause an error.
58
- */
59
- secretRegistry?: SecretProviderRegistry;
60
-
61
- /**
62
- * Target resolver for mapping target keys to base URLs.
63
- * Required when plan contains target references.
64
- */
65
- targetResolver: (key: string) => Promise<string | undefined>;
54
+ secretRegistry: SecretProviderRegistry;
66
55
  }
67
56
 
68
57
  export interface NodeResult {