(evt: Payload)
| 28 | }[keyof Events]; |
| 29 | |
| 30 | export const handler = async (evt: Payload) => { |
| 31 | console.log(evt); |
| 32 | const region = evt.region; |
| 33 | |
| 34 | if ( |
| 35 | evt.detail.object.key.startsWith("eventlog/") && |
| 36 | evt["detail-type"] === "Object Created" |
| 37 | ) { |
| 38 | let [, appHint, stageHint] = evt.detail.object.key.split("/"); |
| 39 | [stageHint] = stageHint!.split("."); |
| 40 | const accounts = await findAccounts(evt.account); |
| 41 | const updateID = evt.detail.object.key.split("/").at(-1)!.split(".")[0]!; |
| 42 | for (const row of accounts) { |
| 43 | await withActor( |
| 44 | { |
| 45 | type: "system", |
| 46 | properties: { |
| 47 | workspaceID: row.workspaceID, |
| 48 | }, |
| 49 | }, |
| 50 | async () => { |
| 51 | const { stageID } = await Stage.put({ |
| 52 | stageName: stageHint!, |
| 53 | appName: appHint!, |
| 54 | region, |
| 55 | awsAccountID: row.id, |
| 56 | }); |
| 57 | await bus.publish(Resource.Bus, State.Event.EventLogCreated, { |
| 58 | stageID, |
| 59 | updateID, |
| 60 | }); |
| 61 | }, |
| 62 | ); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | if ( |
| 67 | evt.detail.object.key.startsWith("update/") && |
| 68 | evt["detail-type"] === "Object Created" |
| 69 | ) { |
| 70 | let [, appHint, stageHint] = evt.detail.object.key.split("/"); |
| 71 | [stageHint] = stageHint!.split("."); |
| 72 | const accounts = await findAccounts(evt.account); |
| 73 | for (const row of accounts) { |
| 74 | await withActor( |
| 75 | { |
| 76 | type: "system", |
| 77 | properties: { |
| 78 | workspaceID: row.workspaceID, |
| 79 | }, |
| 80 | }, |
| 81 | async () => { |
| 82 | const { stageID } = await Stage.put({ |
| 83 | stageName: stageHint!, |
| 84 | appName: appHint!, |
| 85 | region, |
| 86 | awsAccountID: row.id, |
| 87 | }); |
nothing calls this directly
no test coverage detected