diff --git a/apps/authz/Makefile b/apps/authz/Makefile index 6c560dd68..bc8dc6486 100644 --- a/apps/authz/Makefile +++ b/apps/authz/Makefile @@ -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 diff --git a/apps/authz/src/opa/template/translator.ts b/apps/authz/src/opa/template/translate-legacy-policy.script.ts similarity index 97% rename from apps/authz/src/opa/template/translator.ts rename to apps/authz/src/opa/template/translate-legacy-policy.script.ts index d14357096..cd3ec805c 100644 --- a/apps/authz/src/opa/template/translator.ts +++ b/apps/authz/src/opa/template/translate-legacy-policy.script.ts @@ -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, @@ -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) @@ -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) }) } }) @@ -348,4 +346,4 @@ const main = async () => { } } -main() +sendTranslatingRequest({ policies: [] as OldPolicy[] })