Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
samteb committed Feb 16, 2024
1 parent 10fa76d commit 1613593
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions apps/authz/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ authz/rego/test:
authz/rego/test/watch:
make authz/rego/test ARGS=--watch

authz/rego/translator:
authz/rego/translate-legacy-policy:
npx dotenv -e ${AUTHZ_PROJECT_DIR}/.env -- \
ts-node -r tsconfig-paths/register \
--project ${AUTHZ_PROJECT_DIR}/tsconfig.app.json ${AUTHZ_PROJECT_DIR}/src/opa/template/translator.ts
--project ${AUTHZ_PROJECT_DIR}/tsconfig.app.json ${AUTHZ_PROJECT_DIR}/src/opa/template/translate-legacy-policy.script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ type OldPolicy = { [key: string]: string | null }

type NewPolicy = Policy & { id: string }

const data = { policies: [] as OldPolicy[] }

const translatePolicy = (oldPolicy: OldPolicy): NewPolicy | null => {
const translateLegacyPolicy = (oldPolicy: OldPolicy): NewPolicy | null => {
const {
id,
result,
Expand Down Expand Up @@ -309,7 +307,7 @@ const translatePolicy = (oldPolicy: OldPolicy): NewPolicy | null => {
return res
}

const main = async () => {
const sendTranslatingRequest = async (data: { policies: OldPolicy[] }) => {
try {
console.log(data.policies.length)

Expand Down Expand Up @@ -337,7 +335,7 @@ const main = async () => {
data: data.policies.map((policy) => {
const copy: OldPolicy = omit(policy, ['guild_id', 'sequence', 'version', 'amount'])
copy.amount = policy.amount !== null ? `${policy.amount}` : null
return translatePolicy(copy)
return translateLegacyPolicy(copy)
})
}
})
Expand All @@ -348,4 +346,4 @@ const main = async () => {
}
}

main()
sendTranslatingRequest({ policies: [] as OldPolicy[] })

0 comments on commit 1613593

Please sign in to comment.