@griffin-app/griffin-plan-executor 0.1.13 → 0.1.14
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.
- package/README.md +14 -14
- package/dist/events/adapters/in-memory.test.js +22 -22
- package/dist/events/adapters/in-memory.test.js.map +1 -1
- package/dist/events/adapters/kinesis.test.js +13 -13
- package/dist/events/adapters/kinesis.test.js.map +1 -1
- package/dist/events/emitter.test.js +14 -14
- package/dist/events/emitter.test.js.map +1 -1
- package/dist/events/types.d.ts +9 -9
- package/dist/events/types.d.ts.map +1 -1
- package/dist/events/types.js +1 -1
- package/dist/executor.d.ts +2 -2
- package/dist/executor.d.ts.map +1 -1
- package/dist/executor.js +40 -40
- package/dist/executor.js.map +1 -1
- package/dist/executor.test.js +99 -99
- package/dist/executor.test.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/secrets/index.d.ts +3 -3
- package/dist/secrets/index.d.ts.map +1 -1
- package/dist/secrets/index.js +3 -3
- package/dist/secrets/index.js.map +1 -1
- package/dist/secrets/resolver.d.ts +12 -12
- package/dist/secrets/resolver.d.ts.map +1 -1
- package/dist/secrets/resolver.js +19 -19
- package/dist/secrets/resolver.js.map +1 -1
- package/dist/secrets/secrets.test.js +54 -54
- package/dist/secrets/secrets.test.js.map +1 -1
- package/dist/secrets/types.d.ts +2 -2
- package/dist/types.d.ts +2 -2
- package/package.json +4 -4
- package/src/events/adapters/README.md +7 -7
- package/src/events/adapters/in-memory.test.ts +22 -22
- package/src/events/adapters/kinesis.test.ts +13 -13
- package/src/events/emitter.test.ts +14 -14
- package/src/events/types.ts +10 -10
- package/src/executor.test.ts +100 -100
- package/src/executor.ts +41 -41
- package/src/index.ts +7 -7
- package/src/secrets/index.ts +4 -4
- package/src/secrets/resolver.ts +24 -24
- package/src/secrets/secrets.test.ts +57 -57
- package/src/secrets/types.ts +2 -2
- package/src/{test-plan-types.ts → test-monitor-types.ts} +1 -1
- package/src/types.ts +2 -2
|
@@ -3,11 +3,11 @@ import { isSecretRef, isStringLiteral } from "./types.js";
|
|
|
3
3
|
import { SecretProviderRegistry } from "./registry.js";
|
|
4
4
|
import { EnvSecretProvider } from "./providers/env.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
resolveSecretsInMonitor,
|
|
7
|
+
collectSecretsFromMonitor,
|
|
8
8
|
planHasSecrets,
|
|
9
9
|
} from "./resolver.js";
|
|
10
|
-
import {
|
|
10
|
+
import { MonitorV1 } from "@griffin-app/griffin-hub-sdk";
|
|
11
11
|
|
|
12
12
|
// Helper to create a secret ref (mirrors the DSL's secret function)
|
|
13
13
|
function createSecretRef(path: string) {
|
|
@@ -137,13 +137,13 @@ describe("EnvSecretProvider", () => {
|
|
|
137
137
|
});
|
|
138
138
|
});
|
|
139
139
|
|
|
140
|
-
describe("
|
|
141
|
-
const
|
|
140
|
+
describe("Monitor Secret Resolution", () => {
|
|
141
|
+
const createTestMonitor = (
|
|
142
142
|
headers?: Record<string, any>,
|
|
143
143
|
body?: any,
|
|
144
|
-
):
|
|
145
|
-
id: "test-
|
|
146
|
-
name: "Test
|
|
144
|
+
): MonitorV1 => ({
|
|
145
|
+
id: "test-monitor-1",
|
|
146
|
+
name: "Test Monitor",
|
|
147
147
|
version: "1.0",
|
|
148
148
|
environment: "default",
|
|
149
149
|
project: "test-project",
|
|
@@ -167,48 +167,48 @@ describe("Plan Secret Resolution", () => {
|
|
|
167
167
|
});
|
|
168
168
|
|
|
169
169
|
describe("planHasSecrets", () => {
|
|
170
|
-
it("should return false for
|
|
171
|
-
const
|
|
172
|
-
expect(planHasSecrets(
|
|
170
|
+
it("should return false for monitors without secrets or literals", () => {
|
|
171
|
+
const monitor = createTestMonitor({ "Content-Type": "application/json" });
|
|
172
|
+
expect(planHasSecrets(monitor)).toBe(false);
|
|
173
173
|
});
|
|
174
174
|
|
|
175
|
-
it("should return true for
|
|
176
|
-
const
|
|
175
|
+
it("should return true for monitors with secret refs in headers", () => {
|
|
176
|
+
const monitor = createTestMonitor({
|
|
177
177
|
Authorization: createSecretRef("env:API_KEY"),
|
|
178
178
|
});
|
|
179
|
-
expect(planHasSecrets(
|
|
179
|
+
expect(planHasSecrets(monitor)).toBe(true);
|
|
180
180
|
});
|
|
181
181
|
|
|
182
|
-
it("should return true for
|
|
183
|
-
const
|
|
182
|
+
it("should return true for monitors with secret refs in body", () => {
|
|
183
|
+
const monitor = createTestMonitor(undefined, {
|
|
184
184
|
token: createSecretRef("env:TOKEN"),
|
|
185
185
|
});
|
|
186
|
-
expect(planHasSecrets(
|
|
186
|
+
expect(planHasSecrets(monitor)).toBe(true);
|
|
187
187
|
});
|
|
188
188
|
|
|
189
|
-
it("should return true for
|
|
190
|
-
const
|
|
189
|
+
it("should return true for monitors with string literals in headers", () => {
|
|
190
|
+
const monitor = createTestMonitor({
|
|
191
191
|
"Content-Type": createStringLiteral("application/json"),
|
|
192
192
|
});
|
|
193
|
-
expect(planHasSecrets(
|
|
193
|
+
expect(planHasSecrets(monitor)).toBe(true);
|
|
194
194
|
});
|
|
195
195
|
|
|
196
|
-
it("should return true for
|
|
197
|
-
const
|
|
196
|
+
it("should return true for monitors with string literals in body", () => {
|
|
197
|
+
const monitor = createTestMonitor(undefined, {
|
|
198
198
|
type: createStringLiteral("test"),
|
|
199
199
|
});
|
|
200
|
-
expect(planHasSecrets(
|
|
200
|
+
expect(planHasSecrets(monitor)).toBe(true);
|
|
201
201
|
});
|
|
202
202
|
});
|
|
203
203
|
|
|
204
|
-
describe("
|
|
204
|
+
describe("collectSecretsFromMonitor", () => {
|
|
205
205
|
it("should collect secrets from headers", () => {
|
|
206
|
-
const
|
|
206
|
+
const monitor = createTestMonitor({
|
|
207
207
|
Authorization: createSecretRef("env:API_KEY"),
|
|
208
208
|
"X-Custom": createSecretRef("aws:custom-secret"),
|
|
209
209
|
});
|
|
210
210
|
|
|
211
|
-
const collected =
|
|
211
|
+
const collected = collectSecretsFromMonitor(monitor);
|
|
212
212
|
|
|
213
213
|
expect(collected.refs).toHaveLength(2);
|
|
214
214
|
expect(collected.refs).toContainEqual({
|
|
@@ -222,14 +222,14 @@ describe("Plan Secret Resolution", () => {
|
|
|
222
222
|
});
|
|
223
223
|
|
|
224
224
|
it("should collect secrets from nested body", () => {
|
|
225
|
-
const
|
|
225
|
+
const monitor = createTestMonitor(undefined, {
|
|
226
226
|
auth: {
|
|
227
227
|
token: createSecretRef("env:TOKEN"),
|
|
228
228
|
},
|
|
229
229
|
items: [{ key: createSecretRef("env:ITEM_KEY") }],
|
|
230
230
|
});
|
|
231
231
|
|
|
232
|
-
const collected =
|
|
232
|
+
const collected = collectSecretsFromMonitor(monitor);
|
|
233
233
|
|
|
234
234
|
expect(collected.refs).toHaveLength(2);
|
|
235
235
|
expect(collected.refs).toContainEqual({ provider: "env", ref: "TOKEN" });
|
|
@@ -240,24 +240,24 @@ describe("Plan Secret Resolution", () => {
|
|
|
240
240
|
});
|
|
241
241
|
|
|
242
242
|
it("should deduplicate secret refs", () => {
|
|
243
|
-
const
|
|
243
|
+
const monitor = createTestMonitor({
|
|
244
244
|
Authorization: createSecretRef("env:API_KEY"),
|
|
245
245
|
"X-Backup-Auth": createSecretRef("env:API_KEY"),
|
|
246
246
|
});
|
|
247
247
|
|
|
248
|
-
const collected =
|
|
248
|
+
const collected = collectSecretsFromMonitor(monitor);
|
|
249
249
|
|
|
250
250
|
expect(collected.refs).toHaveLength(1);
|
|
251
251
|
expect(collected.paths).toHaveLength(2);
|
|
252
252
|
});
|
|
253
253
|
|
|
254
254
|
it("should collect string literals from headers", () => {
|
|
255
|
-
const
|
|
255
|
+
const monitor = createTestMonitor({
|
|
256
256
|
"Content-Type": createStringLiteral("application/json"),
|
|
257
257
|
Accept: createStringLiteral("application/xml"),
|
|
258
258
|
});
|
|
259
259
|
|
|
260
|
-
const collected =
|
|
260
|
+
const collected = collectSecretsFromMonitor(monitor);
|
|
261
261
|
|
|
262
262
|
expect(collected.refs).toHaveLength(0);
|
|
263
263
|
expect(collected.literalPaths).toHaveLength(2);
|
|
@@ -272,12 +272,12 @@ describe("Plan Secret Resolution", () => {
|
|
|
272
272
|
});
|
|
273
273
|
|
|
274
274
|
it("should collect both secrets and literals", () => {
|
|
275
|
-
const
|
|
275
|
+
const monitor = createTestMonitor({
|
|
276
276
|
Authorization: createSecretRef("env:API_KEY"),
|
|
277
277
|
"Content-Type": createStringLiteral("application/json"),
|
|
278
278
|
});
|
|
279
279
|
|
|
280
|
-
const collected =
|
|
280
|
+
const collected = collectSecretsFromMonitor(monitor);
|
|
281
281
|
|
|
282
282
|
expect(collected.refs).toHaveLength(1);
|
|
283
283
|
expect(collected.refs).toContainEqual({
|
|
@@ -292,9 +292,9 @@ describe("Plan Secret Resolution", () => {
|
|
|
292
292
|
});
|
|
293
293
|
});
|
|
294
294
|
|
|
295
|
-
describe("
|
|
295
|
+
describe("resolveSecretsInMonitor", () => {
|
|
296
296
|
it("should resolve secrets in headers", async () => {
|
|
297
|
-
const
|
|
297
|
+
const monitor = createTestMonitor({
|
|
298
298
|
Authorization: createSecretRef("env:API_KEY"),
|
|
299
299
|
"Content-Type": "application/json",
|
|
300
300
|
});
|
|
@@ -306,7 +306,7 @@ describe("Plan Secret Resolution", () => {
|
|
|
306
306
|
}),
|
|
307
307
|
);
|
|
308
308
|
|
|
309
|
-
const resolved = await
|
|
309
|
+
const resolved = await resolveSecretsInMonitor(monitor, registry);
|
|
310
310
|
|
|
311
311
|
const endpoint = resolved.nodes[0];
|
|
312
312
|
if (endpoint.type !== "HTTP_REQUEST") {
|
|
@@ -317,7 +317,7 @@ describe("Plan Secret Resolution", () => {
|
|
|
317
317
|
});
|
|
318
318
|
|
|
319
319
|
it("should resolve secrets in body", async () => {
|
|
320
|
-
const
|
|
320
|
+
const monitor = createTestMonitor(undefined, {
|
|
321
321
|
token: createSecretRef("env:TOKEN"),
|
|
322
322
|
data: "plain-value",
|
|
323
323
|
});
|
|
@@ -329,7 +329,7 @@ describe("Plan Secret Resolution", () => {
|
|
|
329
329
|
}),
|
|
330
330
|
);
|
|
331
331
|
|
|
332
|
-
const resolved = await
|
|
332
|
+
const resolved = await resolveSecretsInMonitor(monitor, registry);
|
|
333
333
|
|
|
334
334
|
const endpoint = resolved.nodes[0];
|
|
335
335
|
if (endpoint.type !== "HTTP_REQUEST") {
|
|
@@ -339,8 +339,8 @@ describe("Plan Secret Resolution", () => {
|
|
|
339
339
|
expect((endpoint.body as { data: string }).data).toBe("plain-value");
|
|
340
340
|
});
|
|
341
341
|
|
|
342
|
-
it("should not modify original
|
|
343
|
-
const
|
|
342
|
+
it("should not modify original monitor", async () => {
|
|
343
|
+
const monitor = createTestMonitor({
|
|
344
344
|
Authorization: createSecretRef("env:API_KEY"),
|
|
345
345
|
});
|
|
346
346
|
|
|
@@ -351,10 +351,10 @@ describe("Plan Secret Resolution", () => {
|
|
|
351
351
|
}),
|
|
352
352
|
);
|
|
353
353
|
|
|
354
|
-
const resolved = await
|
|
354
|
+
const resolved = await resolveSecretsInMonitor(monitor, registry);
|
|
355
355
|
|
|
356
356
|
// Original should still have secret ref
|
|
357
|
-
const originalEndpoint =
|
|
357
|
+
const originalEndpoint = monitor.nodes[0];
|
|
358
358
|
if (originalEndpoint.type !== "HTTP_REQUEST") {
|
|
359
359
|
throw new Error("HttpRequest not found");
|
|
360
360
|
}
|
|
@@ -371,40 +371,40 @@ describe("Plan Secret Resolution", () => {
|
|
|
371
371
|
});
|
|
372
372
|
|
|
373
373
|
it("should throw for unregistered provider", async () => {
|
|
374
|
-
const
|
|
374
|
+
const monitor = createTestMonitor({
|
|
375
375
|
Authorization: createSecretRef("unknown:API_KEY"),
|
|
376
376
|
});
|
|
377
377
|
|
|
378
378
|
const registry = new SecretProviderRegistry();
|
|
379
379
|
registry.register(new EnvSecretProvider({ env: {} }));
|
|
380
380
|
|
|
381
|
-
await expect(
|
|
381
|
+
await expect(resolveSecretsInMonitor(monitor, registry)).rejects.toThrow(
|
|
382
382
|
/not configured/,
|
|
383
383
|
);
|
|
384
384
|
});
|
|
385
385
|
|
|
386
386
|
it("should throw for missing secret", async () => {
|
|
387
|
-
const
|
|
387
|
+
const monitor = createTestMonitor({
|
|
388
388
|
Authorization: createSecretRef("env:MISSING_KEY"),
|
|
389
389
|
});
|
|
390
390
|
|
|
391
391
|
const registry = new SecretProviderRegistry();
|
|
392
392
|
registry.register(new EnvSecretProvider({ env: {} }));
|
|
393
393
|
|
|
394
|
-
await expect(
|
|
394
|
+
await expect(resolveSecretsInMonitor(monitor, registry)).rejects.toThrow(
|
|
395
395
|
/not set/,
|
|
396
396
|
);
|
|
397
397
|
});
|
|
398
398
|
|
|
399
399
|
it("should unwrap string literals in headers", async () => {
|
|
400
|
-
const
|
|
400
|
+
const monitor = createTestMonitor({
|
|
401
401
|
"Content-Type": createStringLiteral("application/json"),
|
|
402
402
|
Accept: createStringLiteral("application/xml"),
|
|
403
403
|
});
|
|
404
404
|
|
|
405
405
|
const registry = new SecretProviderRegistry();
|
|
406
406
|
|
|
407
|
-
const resolved = await
|
|
407
|
+
const resolved = await resolveSecretsInMonitor(monitor, registry);
|
|
408
408
|
|
|
409
409
|
const endpoint = resolved.nodes[0];
|
|
410
410
|
if (endpoint.type !== "HTTP_REQUEST") {
|
|
@@ -415,14 +415,14 @@ describe("Plan Secret Resolution", () => {
|
|
|
415
415
|
});
|
|
416
416
|
|
|
417
417
|
it("should unwrap string literals in body", async () => {
|
|
418
|
-
const
|
|
418
|
+
const monitor = createTestMonitor(undefined, {
|
|
419
419
|
type: createStringLiteral("test-type"),
|
|
420
420
|
data: "plain-value",
|
|
421
421
|
});
|
|
422
422
|
|
|
423
423
|
const registry = new SecretProviderRegistry();
|
|
424
424
|
|
|
425
|
-
const resolved = await
|
|
425
|
+
const resolved = await resolveSecretsInMonitor(monitor, registry);
|
|
426
426
|
|
|
427
427
|
const endpoint = resolved.nodes[0];
|
|
428
428
|
if (endpoint.type !== "HTTP_REQUEST") {
|
|
@@ -433,7 +433,7 @@ describe("Plan Secret Resolution", () => {
|
|
|
433
433
|
});
|
|
434
434
|
|
|
435
435
|
it("should resolve both secrets and literals", async () => {
|
|
436
|
-
const
|
|
436
|
+
const monitor = createTestMonitor({
|
|
437
437
|
Authorization: createSecretRef("env:API_KEY"),
|
|
438
438
|
"Content-Type": createStringLiteral("application/json"),
|
|
439
439
|
});
|
|
@@ -445,7 +445,7 @@ describe("Plan Secret Resolution", () => {
|
|
|
445
445
|
}),
|
|
446
446
|
);
|
|
447
447
|
|
|
448
|
-
const resolved = await
|
|
448
|
+
const resolved = await resolveSecretsInMonitor(monitor, registry);
|
|
449
449
|
|
|
450
450
|
const endpoint = resolved.nodes[0];
|
|
451
451
|
if (endpoint.type !== "HTTP_REQUEST") {
|
|
@@ -455,17 +455,17 @@ describe("Plan Secret Resolution", () => {
|
|
|
455
455
|
expect(endpoint.headers?.["Content-Type"]).toBe("application/json");
|
|
456
456
|
});
|
|
457
457
|
|
|
458
|
-
it("should not modify original
|
|
459
|
-
const
|
|
458
|
+
it("should not modify original monitor with literals", async () => {
|
|
459
|
+
const monitor = createTestMonitor({
|
|
460
460
|
"Content-Type": createStringLiteral("application/json"),
|
|
461
461
|
});
|
|
462
462
|
|
|
463
463
|
const registry = new SecretProviderRegistry();
|
|
464
464
|
|
|
465
|
-
const resolved = await
|
|
465
|
+
const resolved = await resolveSecretsInMonitor(monitor, registry);
|
|
466
466
|
|
|
467
467
|
// Original should still have literal wrapper
|
|
468
|
-
const originalEndpoint =
|
|
468
|
+
const originalEndpoint = monitor.nodes[0];
|
|
469
469
|
if (originalEndpoint.type !== "HTTP_REQUEST") {
|
|
470
470
|
throw new Error("HttpRequest not found");
|
|
471
471
|
}
|
package/src/secrets/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StringLiteral } from "@griffin-app/griffin-hub-sdk";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Data structure for a secret reference as it appears in a
|
|
4
|
+
* Data structure for a secret reference as it appears in a monitor.
|
|
5
5
|
*/
|
|
6
6
|
export interface SecretRefData {
|
|
7
7
|
provider: string;
|
|
@@ -11,7 +11,7 @@ export interface SecretRefData {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Secret reference marker in
|
|
14
|
+
* Secret reference marker in monitor JSON.
|
|
15
15
|
*/
|
|
16
16
|
export interface SecretRef {
|
|
17
17
|
$secret: SecretRefData;
|
package/src/types.ts
CHANGED
|
@@ -57,12 +57,12 @@ export interface RunStatusUpdate {
|
|
|
57
57
|
*/
|
|
58
58
|
export interface StatusCallbacks {
|
|
59
59
|
/**
|
|
60
|
-
* Called when
|
|
60
|
+
* Called when monitor execution starts (after secret resolution, before graph execution).
|
|
61
61
|
*/
|
|
62
62
|
onStart?: () => Promise<void>;
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* Called when
|
|
65
|
+
* Called when monitor execution completes (success or failure).
|
|
66
66
|
*/
|
|
67
67
|
onComplete?: (update: RunStatusUpdate) => Promise<void>;
|
|
68
68
|
}
|