-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(type reorganization) - Reorganize and standardize our action type…
…s and transforms (#252) * rename action * update names for toggling to better reflect whats going on * reorganize the actions a bit * Update imports etc * correct imports * more naming and import fixes * make names a bit more standard * fix(api js file generation): Fix the api deployment to only compile the layer during packaging. * Add authority and origin to all events * Update new submission types and heavy sink work * Update tests to appropriately test onemac-legacy * Fix submission struction... yikes * Correct how we pass authority and origin INTO the sub service, whoops * Add an action type index per ben
- Loading branch information
Showing
26 changed files
with
465 additions
and
282 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ tsconfig.tsbuildinfo | |
build_run | ||
.build | ||
.turbo | ||
coverage | ||
coverage | ||
lambda_layer.zip |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from "./toggle-withdraw-rai-enabled"; | ||
export * from "./issue-rai"; | ||
export * from "./respond-to-rai"; | ||
export * from "./withdraw-rai"; |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { z } from "zod"; | ||
import { onemacAttachmentSchema, handleAttachment } from "../attachments"; | ||
|
||
export const raiIssueSchema = z.object({ | ||
id: z.string(), | ||
authority: z.string(), | ||
origin: z.string(), | ||
requestedDate: z.number(), | ||
attachments: z.array(onemacAttachmentSchema).nullish(), | ||
additionalInformation: z.string().nullable().default(null), | ||
submitterName: z.string(), | ||
submitterEmail: z.string(), | ||
}); | ||
export type RaiIssue = z.infer<typeof raiIssueSchema>; | ||
|
||
export const transformRaiIssue = (id: string) => { | ||
return raiIssueSchema.transform((data) => ({ | ||
id, | ||
rais: { | ||
[data.requestedDate]: { | ||
request: { | ||
attachments: | ||
data.attachments?.map((attachment) => { | ||
return handleAttachment(attachment); | ||
}) ?? null, | ||
additionalInformation: data.additionalInformation, | ||
submitterName: data.submitterName, | ||
submitterEmail: data.submitterEmail, | ||
}, | ||
}, | ||
}, | ||
})); | ||
}; | ||
export type RaiIssueTransform = z.infer<ReturnType<typeof transformRaiIssue>>; |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { z } from "zod"; | ||
import { onemacAttachmentSchema, handleAttachment } from "../attachments"; | ||
|
||
export const raiResponseSchema = z.object({ | ||
id: z.string(), | ||
authority: z.string(), | ||
origin: z.string(), | ||
requestedDate: z.number(), | ||
responseDate: z.number(), | ||
attachments: z.array(onemacAttachmentSchema).nullish(), | ||
additionalInformation: z.string().nullable().default(null), | ||
submitterName: z.string(), | ||
submitterEmail: z.string(), | ||
}); | ||
export type RaiResponse = z.infer<typeof raiResponseSchema>; | ||
|
||
export const transformRaiResponse = (id: string) => { | ||
return raiResponseSchema.transform((data) => ({ | ||
id, | ||
rais: { | ||
[data.requestedDate]: { | ||
response: { | ||
attachments: | ||
data.attachments?.map((attachment) => { | ||
return handleAttachment(attachment); | ||
}) ?? null, | ||
additionalInformation: data.additionalInformation, | ||
submitterName: data.submitterName, | ||
submitterEmail: data.submitterEmail, | ||
}, | ||
}, | ||
}, | ||
})); | ||
}; | ||
export type RaiResponseTransform = z.infer< | ||
ReturnType<typeof transformRaiResponse> | ||
>; |
10 changes: 10 additions & 0 deletions
10
src/packages/shared-types/action-types/toggle-withdraw-rai-enabled.ts
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { z } from "zod"; | ||
|
||
export const toggleWithdrawRaiEnabledSchema = z.object({ | ||
authority: z.string(), | ||
origin: z.string(), | ||
raiWithdrawEnabled: z.boolean(), | ||
}); | ||
export type ToggleWithdrawRaiEnabled = z.infer< | ||
typeof toggleWithdrawRaiEnabledSchema | ||
>; |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { z } from "zod"; | ||
import { onemacAttachmentSchema, handleAttachment } from "../attachments"; | ||
|
||
export const raiWithdrawSchema = z.object({ | ||
id: z.string(), | ||
authority: z.string(), | ||
origin: z.string(), | ||
requestedDate: z.number(), | ||
withdrawnDate: z.number(), | ||
attachments: z.array(onemacAttachmentSchema).nullish(), | ||
additionalInformation: z.string().nullable().default(null), | ||
submitterName: z.string(), | ||
submitterEmail: z.string(), | ||
}); | ||
export type RaiWithdraw = z.infer<typeof raiWithdrawSchema>; | ||
|
||
export const transformRaiWithdraw = (id: string) => { | ||
return raiWithdrawSchema.transform((data) => ({ | ||
id, | ||
rais: { | ||
[data.requestedDate]: { | ||
withdraw: { | ||
attachments: | ||
data.attachments?.map((attachment) => { | ||
return handleAttachment(attachment); | ||
}) ?? null, | ||
additionalInformation: data.additionalInformation, | ||
submitterName: data.submitterName, | ||
submitterEmail: data.submitterEmail, | ||
}, | ||
}, | ||
}, | ||
})); | ||
}; | ||
export type RaiWithdrawTransform = z.infer< | ||
ReturnType<typeof transformRaiWithdraw> | ||
>; |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.