saleor-apps-redis_apl/apps/taxes/src/modules/taxjar/tax-code/taxjar-tax-codes.router.ts

32 lines
1 KiB
TypeScript
Raw Normal View History

feat: tax code matcher (#564) * feat: :sparkles: add tax-classes-fetcher * refactor: :recycle: add "byId" suffix to crud-settings & remove upsert * feat: :sparkles: add updateMany method to CrudSettingsManager * feat: :sparkles: add avatax & taxjar tax-code-map-repository * refactor: :truck: move to tax-code directory * feat: :sparkles: add getTaxCodes methods to provider clients * refactor: :recycle: extract taxClass and taxCode schema * refactor: :truck: tax-code-map -> tax-code-match * feat: :sparkles: add taxjar-tax-code.service * feat: :sparkles: add avatax-tax-code.service * feat: :sparkles: add taxClass to graphql fragment * feat: :sparkles: use tax codes in calculate taxes * fix: :bug: undefined tax code bug & add tests * build: :construction_worker: add changeset * Update avatax-tax-code-mapper.ts * feat: :sparkles: add routers & get rid of adapters & mappers * refactor: :recycle: logger location -> name * refactor: :recycle: clean up & rephrase logs * refactor: :recycle: remove __typename from query * docs: :bulb: make comments about tax codes more informative * refactor: :recycle: use resolveOptionalOrThrow on tax code description * refactor: :recycle: rename tax-codes -> tax-classes, move and rename tax-code-schema * refactor: :truck: ctx -> authData * refactor: :truck: createUrqlClientFromCtx -> createUrqlClientFromAuthdata * refactor: :recycle: dont spread ctx * docs: :bulb: add comment about fallback tax code * refactor: :recycle: remove ..ctx * fix: :bug: use createGraphQLClient * feat: tax code matcher ui (#658) * feat: :sparkles: use tax codes in calculate taxes * feat: :sparkles: add getTaxCodes methods to provider clients * feat: :sparkles: add matcher tables * feat: :sparkles: add log errors middleware * fix: :loud_sound: fix misleading logs * fix: :bug: ctx appToken bug * feat: :sparkles: add Select override with wrapping label * feat: :sparkles: pre-select match * docs: :bulb: add comments about first connection * docs: :bulb: add comment about redirect * refactor: :fire: duplicate file * feat: :sparkles: add AppCard to tables * feat: :sparkles: add _error to breadcrumbs exceptions * fix: :bug: value not set on data * feat: :goal_net: add error for no channels configured * fix: :bug: replace update with upsert * refactor: :truck: channel-configuration-settings to repository * fix: :bug: updating a channel configuration * fix: :test_tube: fix wrong mock * fix: :bug: duplicating configs * Update cool-turtles-reflect.md
2023-06-20 15:53:27 +00:00
import { router } from "../../trpc/trpc-server";
import { createLogger } from "../../../lib/logger";
import { protectedClientProcedure } from "../../trpc/protected-client-procedure";
import { z } from "zod";
import { TaxJarConnectionService } from "../configuration/taxjar-connection.service";
import { TaxJarTaxCodesService } from "./taxjar-tax-codes.service";
const getAllForIdSchema = z.object({ connectionId: z.string() });
export const taxJarTaxCodesRouter = router({
getAllForId: protectedClientProcedure.input(getAllForIdSchema).query(async ({ ctx, input }) => {
const logger = createLogger({
name: "taxjarTaxCodesRouter.getAllForId",
});
const connectionService = new TaxJarConnectionService({
appId: ctx.appId!,
client: ctx.apiClient,
saleorApiUrl: ctx.saleorApiUrl,
});
feat: tax code matcher (#564) * feat: :sparkles: add tax-classes-fetcher * refactor: :recycle: add "byId" suffix to crud-settings & remove upsert * feat: :sparkles: add updateMany method to CrudSettingsManager * feat: :sparkles: add avatax & taxjar tax-code-map-repository * refactor: :truck: move to tax-code directory * feat: :sparkles: add getTaxCodes methods to provider clients * refactor: :recycle: extract taxClass and taxCode schema * refactor: :truck: tax-code-map -> tax-code-match * feat: :sparkles: add taxjar-tax-code.service * feat: :sparkles: add avatax-tax-code.service * feat: :sparkles: add taxClass to graphql fragment * feat: :sparkles: use tax codes in calculate taxes * fix: :bug: undefined tax code bug & add tests * build: :construction_worker: add changeset * Update avatax-tax-code-mapper.ts * feat: :sparkles: add routers & get rid of adapters & mappers * refactor: :recycle: logger location -> name * refactor: :recycle: clean up & rephrase logs * refactor: :recycle: remove __typename from query * docs: :bulb: make comments about tax codes more informative * refactor: :recycle: use resolveOptionalOrThrow on tax code description * refactor: :recycle: rename tax-codes -> tax-classes, move and rename tax-code-schema * refactor: :truck: ctx -> authData * refactor: :truck: createUrqlClientFromCtx -> createUrqlClientFromAuthdata * refactor: :recycle: dont spread ctx * docs: :bulb: add comment about fallback tax code * refactor: :recycle: remove ..ctx * fix: :bug: use createGraphQLClient * feat: tax code matcher ui (#658) * feat: :sparkles: use tax codes in calculate taxes * feat: :sparkles: add getTaxCodes methods to provider clients * feat: :sparkles: add matcher tables * feat: :sparkles: add log errors middleware * fix: :loud_sound: fix misleading logs * fix: :bug: ctx appToken bug * feat: :sparkles: add Select override with wrapping label * feat: :sparkles: pre-select match * docs: :bulb: add comments about first connection * docs: :bulb: add comment about redirect * refactor: :fire: duplicate file * feat: :sparkles: add AppCard to tables * feat: :sparkles: add _error to breadcrumbs exceptions * fix: :bug: value not set on data * feat: :goal_net: add error for no channels configured * fix: :bug: replace update with upsert * refactor: :truck: channel-configuration-settings to repository * fix: :bug: updating a channel configuration * fix: :test_tube: fix wrong mock * fix: :bug: duplicating configs * Update cool-turtles-reflect.md
2023-06-20 15:53:27 +00:00
const connection = await connectionService.getById(input.connectionId);
const taxCodesService = new TaxJarTaxCodesService(connection.config);
logger.debug("Returning tax codes");
return taxCodesService.getAll();
}),
});