saleor-apps-redis_apl/apps/taxes/scripts/migrations/run-migration.ts

39 lines
1,005 B
TypeScript
Raw Normal View History

feat: change the flow from OrderCreated to OrderConfirmed (#826) * refactor: :recycle: extract order-metadata-manager * feat: :construction: add basic boilerplate * feat: :sparkles: add readExternalIdFromOrderMetadata * Revert "feat: :sparkles: add readExternalIdFromOrderMetadata" This reverts commit a78d9d4597672f8605cf998a9f784aebaab27de1. * feat: :sparkles: add order-cancelled avatax adapter * test: :white_check_mark: add tests for AvataxOrderCancelledPayloadTransformer * refactor: avataxId instead of externalId * refactor: :recycle: split up webhook response * build: :arrow_up: upgrade avatax * refactor: :recycle: extend logging in webhook response errors * fix: :bug: split privateMetadata and publicMetadata * fix: :bug: use "DEFAULT" value of companyCode for commit to work * fix: :alembic: fix voidTransaction type * refactor: :truck: order_created -> order_confirmed * fix: :bug: change voidReason * build: :construction_worker: add changeset * refactor: :fire: order_fulfilled webhook * feat: Avatax metadata tax calculation date (#843) * feat: :sparkles: add metadata tax calculation date * build: :construction_worker: add changeset * feat: Avatax metadata document code (#844) * feat: :sparkles: provide document code through metadata field * build: :construction_worker: add changeset * refactor: :recycle: fallback to default company code for migration * refactor: :recycle: patch order-created files and add deprecation note * Revert "refactor: :fire: order_fulfilled webhook" This reverts commit fd098642735ae9d62e3a876088226bd0f108afd6. * refactor: :recycle: patch order-fulfilled files and add deprecation note * fix: :bug: bring back deprecated webhooks to manifest * feat: :alembic: add AppWebhookMigrator (#850) * refactor: :truck: order_created -> order_confirmed * refactor: :fire: order_fulfilled webhook * feat: :alembic: add AppWebhookMigrator * feat: :sparkles: add mode to migrator * feat: :sparkles: add draft of run-report and migrateWebhook method * refactor: :recycle: address feedback * feat: :sparkles: add tests and new structure * refactor: :fire: util * feat: :sparkles: add enable/disable webhook rollback flow * refactor: :recycle: modify the taxes-migration flow * refactor: :recycle: generalize document code & date resolver * chore: :card_file_box: add run-migration * chore: :bulb: update comments about migration flow * fix: :bug: slice document code * refactor: :recycle: try/catch at the top level * chore: :bulb: add comments * Update shiny-meals-wait.md * Update soft-steaks-know.md * Update soft-steaks-know.md * fix: :white_check_mark: fix test * feat: :sparkles: change createTransaction to createOrAdjustTransaction this feature grants idempotency of the transaction flow * feat: :sparkles: add number field to OrderConfirmed payload * chore: :bulb: add deprecation comment to metadata method * docs: :memo: add todo comment to refactor sumPayloadLines * feat: :sparkles: add resolveStringOrThrow and use it for email * fix: :bug: add missing number to mock
2023-08-10 11:08:20 +00:00
/* eslint-disable turbo/no-undeclared-env-vars */
import * as dotenv from "dotenv";
import { createAppWebhookMigrator } from "./app-webhook-migrator";
import { fetchCloudAplEnvs, verifyRequiredEnvs } from "./migration-utils";
import { migrateTaxes } from "./1.13-taxes-migration";
feat: change the flow from OrderCreated to OrderConfirmed (#826) * refactor: :recycle: extract order-metadata-manager * feat: :construction: add basic boilerplate * feat: :sparkles: add readExternalIdFromOrderMetadata * Revert "feat: :sparkles: add readExternalIdFromOrderMetadata" This reverts commit a78d9d4597672f8605cf998a9f784aebaab27de1. * feat: :sparkles: add order-cancelled avatax adapter * test: :white_check_mark: add tests for AvataxOrderCancelledPayloadTransformer * refactor: avataxId instead of externalId * refactor: :recycle: split up webhook response * build: :arrow_up: upgrade avatax * refactor: :recycle: extend logging in webhook response errors * fix: :bug: split privateMetadata and publicMetadata * fix: :bug: use "DEFAULT" value of companyCode for commit to work * fix: :alembic: fix voidTransaction type * refactor: :truck: order_created -> order_confirmed * fix: :bug: change voidReason * build: :construction_worker: add changeset * refactor: :fire: order_fulfilled webhook * feat: Avatax metadata tax calculation date (#843) * feat: :sparkles: add metadata tax calculation date * build: :construction_worker: add changeset * feat: Avatax metadata document code (#844) * feat: :sparkles: provide document code through metadata field * build: :construction_worker: add changeset * refactor: :recycle: fallback to default company code for migration * refactor: :recycle: patch order-created files and add deprecation note * Revert "refactor: :fire: order_fulfilled webhook" This reverts commit fd098642735ae9d62e3a876088226bd0f108afd6. * refactor: :recycle: patch order-fulfilled files and add deprecation note * fix: :bug: bring back deprecated webhooks to manifest * feat: :alembic: add AppWebhookMigrator (#850) * refactor: :truck: order_created -> order_confirmed * refactor: :fire: order_fulfilled webhook * feat: :alembic: add AppWebhookMigrator * feat: :sparkles: add mode to migrator * feat: :sparkles: add draft of run-report and migrateWebhook method * refactor: :recycle: address feedback * feat: :sparkles: add tests and new structure * refactor: :fire: util * feat: :sparkles: add enable/disable webhook rollback flow * refactor: :recycle: modify the taxes-migration flow * refactor: :recycle: generalize document code & date resolver * chore: :card_file_box: add run-migration * chore: :bulb: update comments about migration flow * fix: :bug: slice document code * refactor: :recycle: try/catch at the top level * chore: :bulb: add comments * Update shiny-meals-wait.md * Update soft-steaks-know.md * Update soft-steaks-know.md * fix: :white_check_mark: fix test * feat: :sparkles: change createTransaction to createOrAdjustTransaction this feature grants idempotency of the transaction flow * feat: :sparkles: add number field to OrderConfirmed payload * chore: :bulb: add deprecation comment to metadata method * docs: :memo: add todo comment to refactor sumPayloadLines * feat: :sparkles: add resolveStringOrThrow and use it for email * fix: :bug: add missing number to mock
2023-08-10 11:08:20 +00:00
dotenv.config();
const runMigration = async () => {
console.log("Starting runMigration");
verifyRequiredEnvs();
console.log("Env vars verified. Fetching envs");
const allEnvs = await fetchCloudAplEnvs().catch((r) => {
console.error(r);
process.exit(1);
});
for (const env of allEnvs) {
try {
console.log("--------------------");
console.log(`Working on app: ${env.appId} on domain ${env.domain}`);
const webhookMigrator = createAppWebhookMigrator(env, { mode: "migrate" });
await migrateTaxes(webhookMigrator);
} catch (error) {
console.log("⏩ Error while migrating webhook. Continuing with the next app.");
feat: change the flow from OrderCreated to OrderConfirmed (#826) * refactor: :recycle: extract order-metadata-manager * feat: :construction: add basic boilerplate * feat: :sparkles: add readExternalIdFromOrderMetadata * Revert "feat: :sparkles: add readExternalIdFromOrderMetadata" This reverts commit a78d9d4597672f8605cf998a9f784aebaab27de1. * feat: :sparkles: add order-cancelled avatax adapter * test: :white_check_mark: add tests for AvataxOrderCancelledPayloadTransformer * refactor: avataxId instead of externalId * refactor: :recycle: split up webhook response * build: :arrow_up: upgrade avatax * refactor: :recycle: extend logging in webhook response errors * fix: :bug: split privateMetadata and publicMetadata * fix: :bug: use "DEFAULT" value of companyCode for commit to work * fix: :alembic: fix voidTransaction type * refactor: :truck: order_created -> order_confirmed * fix: :bug: change voidReason * build: :construction_worker: add changeset * refactor: :fire: order_fulfilled webhook * feat: Avatax metadata tax calculation date (#843) * feat: :sparkles: add metadata tax calculation date * build: :construction_worker: add changeset * feat: Avatax metadata document code (#844) * feat: :sparkles: provide document code through metadata field * build: :construction_worker: add changeset * refactor: :recycle: fallback to default company code for migration * refactor: :recycle: patch order-created files and add deprecation note * Revert "refactor: :fire: order_fulfilled webhook" This reverts commit fd098642735ae9d62e3a876088226bd0f108afd6. * refactor: :recycle: patch order-fulfilled files and add deprecation note * fix: :bug: bring back deprecated webhooks to manifest * feat: :alembic: add AppWebhookMigrator (#850) * refactor: :truck: order_created -> order_confirmed * refactor: :fire: order_fulfilled webhook * feat: :alembic: add AppWebhookMigrator * feat: :sparkles: add mode to migrator * feat: :sparkles: add draft of run-report and migrateWebhook method * refactor: :recycle: address feedback * feat: :sparkles: add tests and new structure * refactor: :fire: util * feat: :sparkles: add enable/disable webhook rollback flow * refactor: :recycle: modify the taxes-migration flow * refactor: :recycle: generalize document code & date resolver * chore: :card_file_box: add run-migration * chore: :bulb: update comments about migration flow * fix: :bug: slice document code * refactor: :recycle: try/catch at the top level * chore: :bulb: add comments * Update shiny-meals-wait.md * Update soft-steaks-know.md * Update soft-steaks-know.md * fix: :white_check_mark: fix test * feat: :sparkles: change createTransaction to createOrAdjustTransaction this feature grants idempotency of the transaction flow * feat: :sparkles: add number field to OrderConfirmed payload * chore: :bulb: add deprecation comment to metadata method * docs: :memo: add todo comment to refactor sumPayloadLines * feat: :sparkles: add resolveStringOrThrow and use it for email * fix: :bug: add missing number to mock
2023-08-10 11:08:20 +00:00
continue;
}
}
};
runMigration();