-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Hooks reference resource + trigger hooks on filter change for env (
#220)
- Loading branch information
1 parent
1dd153f
commit 6a8b95d
Showing
9 changed files
with
110 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,17 @@ | ||
import { z } from "zod"; | ||
|
||
import type { TargetDeleted, TargetRemoved } from "./target.js"; | ||
import { targetDeleted, targetRemoved } from "./target.js"; | ||
import type { ResourceRemoved } from "./target.js"; | ||
import { resourceRemoved } from "./target.js"; | ||
|
||
export * from "./target.js"; | ||
|
||
export const hookEvent = z.union([targetRemoved, targetDeleted]); | ||
export const hookEvent = resourceRemoved; | ||
export type HookEvent = z.infer<typeof hookEvent>; | ||
|
||
// typeguards | ||
export const isTargetRemoved = (event: HookEvent): event is TargetRemoved => | ||
event.action === "deployment.target.removed"; | ||
export const isTargetDeleted = (event: HookEvent): event is TargetDeleted => | ||
event.action === "deployment.target.deleted"; | ||
export const isResourceRemoved = (event: HookEvent): event is ResourceRemoved => | ||
true; | ||
|
||
// action | ||
export const hookActionsList = hookEvent.options.map( | ||
(schema) => schema.shape.action.value, | ||
); | ||
export const hookActionsList = ["deployment.resource.removed"]; | ||
export const hookActions = z.enum(hookActionsList as [string, ...string[]]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,14 @@ | ||
import { z } from "zod"; | ||
|
||
const deployment = z.object({ id: z.string().uuid(), name: z.string() }); | ||
const target = z.object({ | ||
const resource = z.object({ | ||
id: z.string().uuid(), | ||
name: z.string(), | ||
config: z.record(z.any()), | ||
}); | ||
|
||
export const targetRemoved = z.object({ | ||
action: z.literal("deployment.target.removed"), | ||
payload: z.object({ deployment, target }), | ||
export const resourceRemoved = z.object({ | ||
action: z.literal("deployment.resource.removed"), | ||
payload: z.object({ deployment, resource }), | ||
}); | ||
export type TargetRemoved = z.infer<typeof targetRemoved>; | ||
|
||
export const targetDeleted = z.object({ | ||
action: z.literal("deployment.target.deleted"), | ||
payload: z.object({ target }), | ||
}); | ||
export type TargetDeleted = z.infer<typeof targetDeleted>; | ||
export type ResourceRemoved = z.infer<typeof resourceRemoved>; |