Răsfoiți Sursa

fix(core): Correct typing of GraphQL ID type in generated code

Fixes #410

BREAKING CHANGE: The `ID` type in `@vendure/common/lib/generated-types` & `@vendure/common/lib/generated-shop-types` is now correctly typed as `string | number`, whereas previously it was `string`. If you are using any generated types in your plugin code, this may lead to TypeScript compiler errors which will need to be corrected.
Michael Bromley 5 ani în urmă
părinte
comite
dc7b3036e5

+ 1 - 0
packages/admin-ui/src/lib/core/src/public_api.ts

@@ -162,6 +162,7 @@ export * from './shared/dynamic-form-inputs/date-form-input/date-form-input.comp
 export * from './shared/dynamic-form-inputs/dynamic-form-input/dynamic-form-input.component';
 export * from './shared/dynamic-form-inputs/facet-value-form-input/facet-value-form-input.component';
 export * from './shared/dynamic-form-inputs/number-form-input/number-form-input.component';
+export * from './shared/dynamic-form-inputs/password-form-input/password-form-input.component';
 export * from './shared/dynamic-form-inputs/product-selector-form-input/product-selector-form-input.component';
 export * from './shared/dynamic-form-inputs/register-dynamic-input-components';
 export * from './shared/dynamic-form-inputs/select-form-input/select-form-input.component';

+ 1 - 1
packages/common/src/generated-shop-types.ts

@@ -3,7 +3,7 @@ export type Maybe<T> = T | null;
 
 /** All built-in and custom scalars, mapped to their actual values */
 export type Scalars = {
-    ID: string;
+    ID: string | number;
     String: string;
     Boolean: boolean;
     Int: number;

+ 5 - 5
packages/common/src/generated-types.ts

@@ -3,7 +3,7 @@ export type Maybe<T> = T | null;
 
 /** All built-in and custom scalars, mapped to their actual values */
 export type Scalars = {
-  ID: string;
+  ID: string | number;
   String: string;
   Boolean: boolean;
   Int: number;
@@ -606,7 +606,7 @@ export type CreateZoneInput = {
 /**
  * @description
  * ISO 4217 currency code
- *
+ * 
  * @docsCategory common
  */
 export enum CurrencyCode {
@@ -1399,7 +1399,7 @@ export type JobSortParameter = {
 /**
  * @description
  * The state of a Job in the JobQueue
- *
+ * 
  * @docsCategory common
  */
 export enum JobState {
@@ -1417,7 +1417,7 @@ export enum JobState {
  * region or script modifier (e.g. de_AT). The selection available is based
  * on the [Unicode CLDR summary list](https://unicode-org.github.io/cldr-staging/charts/37/summary/root.html)
  * and includes the major spoken languages of the world and any widely-used variants.
- *
+ * 
  * @docsCategory common
  */
 export enum LanguageCode {
@@ -2621,7 +2621,7 @@ export type PaymentMethodSortParameter = {
  * @description
  * Permissions for administrators and customers. Used to control access to
  * GraphQL resolvers via the {@link Allow} decorator.
- *
+ * 
  * @docsCategory common
  */
 export enum Permission {

+ 1 - 1
packages/core/src/api/resolvers/base/base-auth.resolver.ts

@@ -132,7 +132,7 @@ export class BaseAuthResolver {
      */
     protected publiclyAccessibleUser(user: User): CurrentUser {
         return {
-            id: user.id as string,
+            id: user.id,
             identifier: user.identifier,
             channels: getUserChannelsPermissions(user) as CurrentUserChannel[],
         };

+ 3 - 3
packages/core/src/api/resolvers/shop/shop-customer.resolver.ts

@@ -48,7 +48,7 @@ export class ShopCustomerResolver {
         @Args() args: MutationCreateCustomerAddressArgs,
     ): Promise<Address> {
         const customer = await this.getCustomerForOwner(ctx);
-        return this.customerService.createAddress(ctx, customer.id as string, args.input);
+        return this.customerService.createAddress(ctx, customer.id, args.input);
     }
 
     @Mutation()
@@ -59,7 +59,7 @@ export class ShopCustomerResolver {
     ): Promise<Address> {
         const customer = await this.getCustomerForOwner(ctx);
         const customerAddresses = await this.customerService.findAddressesByCustomerId(ctx, customer.id);
-        if (!customerAddresses.find((address) => idsAreEqual(address.id, args.input.id))) {
+        if (!customerAddresses.find(address => idsAreEqual(address.id, args.input.id))) {
             throw new ForbiddenError();
         }
         return this.customerService.updateAddress(ctx, args.input);
@@ -73,7 +73,7 @@ export class ShopCustomerResolver {
     ): Promise<boolean> {
         const customer = await this.getCustomerForOwner(ctx);
         const customerAddresses = await this.customerService.findAddressesByCustomerId(ctx, customer.id);
-        if (!customerAddresses.find((address) => idsAreEqual(address.id, args.id))) {
+        if (!customerAddresses.find(address => idsAreEqual(address.id, args.id))) {
             throw new ForbiddenError();
         }
         return this.customerService.deleteAddress(ctx, args.id);

+ 1 - 1
packages/core/src/api/resolvers/shop/shop-order.resolver.ts

@@ -305,7 +305,7 @@ export class ShopOrderResolver {
                         // to populate the initial default Address.
                         if (addresses.length === 0 && order.shippingAddress?.country) {
                             const address = order.shippingAddress;
-                            await this.customerService.createAddress(ctx, order.customer.id as string, {
+                            await this.customerService.createAddress(ctx, order.customer.id, {
                                 ...address,
                                 streetLine1: address.streetLine1 || '',
                                 streetLine2: address.streetLine2 || '',

+ 1 - 1
packages/core/src/bootstrap.ts

@@ -226,7 +226,7 @@ export async function getAllEntities(userConfig: Partial<VendureConfig>): Promis
  */
 function setExposedHeaders(config: Readonly<RuntimeVendureConfig>) {
     if (config.authOptions.tokenMethod === 'bearer') {
-        const authTokenHeaderKey = config.authOptions.authTokenHeaderKey as string;
+        const authTokenHeaderKey = config.authOptions.authTokenHeaderKey;
         const corsOptions = config.apiOptions.cors;
         if (typeof corsOptions !== 'boolean') {
             const { exposedHeaders } = corsOptions;

+ 17 - 16
packages/core/src/data-import/providers/importer/importer.ts

@@ -1,6 +1,7 @@
 import { Injectable } from '@nestjs/common';
 import { ImportInfo, LanguageCode } from '@vendure/common/lib/generated-types';
 import { normalizeString } from '@vendure/common/lib/normalize-string';
+import { ID } from '@vendure/common/lib/shared-types';
 import ProgressBar from 'progress';
 import { Observable } from 'rxjs';
 import { Stream } from 'stream';
@@ -30,7 +31,7 @@ export type OnProgressFn = (progess: ImportProgress) => void;
 
 @Injectable()
 export class Importer {
-    private taxCategoryMatches: { [name: string]: string } = {};
+    private taxCategoryMatches: { [name: string]: ID } = {};
     // These Maps are used to cache newly-created entities and prevent duplicates
     // from being created.
     private facetMap = new Map<string, Facet>();
@@ -148,8 +149,8 @@ export class Importer {
                 errors = errors.concat(createProductAssets.errors);
             }
             const createdProductId = await this.fastImporter.createProduct({
-                featuredAssetId: productAssets.length ? (productAssets[0].id as string) : undefined,
-                assetIds: productAssets.map(a => a.id) as string[],
+                featuredAssetId: productAssets.length ? productAssets[0].id : undefined,
+                assetIds: productAssets.map(a => a.id),
                 facetValueIds: await this.getFacetValueIds(product.facets, languageCode),
                 translations: [
                     {
@@ -162,7 +163,7 @@ export class Importer {
                 customFields: product.customFields,
             });
 
-            const optionsMap: { [optionName: string]: string } = {};
+            const optionsMap: { [optionName: string]: ID } = {};
             for (const optionGroup of product.optionGroups) {
                 const code = normalizeString(`${product.name}-${optionGroup.name}`, '-');
                 const groupId = await this.fastImporter.createProductOptionGroup({
@@ -177,7 +178,7 @@ export class Importer {
                 });
                 for (const option of optionGroup.values) {
                     const createdOptionId = await this.fastImporter.createProductOption({
-                        productOptionGroupId: groupId as string,
+                        productOptionGroupId: groupId,
                         code: normalizeString(option, '-'),
                         translations: [
                             {
@@ -186,7 +187,7 @@ export class Importer {
                             },
                         ],
                     });
-                    optionsMap[option] = createdOptionId as string;
+                    optionsMap[option] = createdOptionId;
                 }
                 await this.fastImporter.addOptionGroupToProduct(createdProductId, groupId);
             }
@@ -197,15 +198,15 @@ export class Importer {
                 if (createVariantAssets.errors.length) {
                     errors = errors.concat(createVariantAssets.errors);
                 }
-                let facetValueIds: string[] = [];
+                let facetValueIds: ID[] = [];
                 if (0 < variant.facets.length) {
                     facetValueIds = await this.getFacetValueIds(variant.facets, languageCode);
                 }
                 const createdVariant = await this.fastImporter.createProductVariant({
-                    productId: createdProductId as string,
+                    productId: createdProductId,
                     facetValueIds,
-                    featuredAssetId: variantAssets.length ? (variantAssets[0].id as string) : undefined,
-                    assetIds: variantAssets.map(a => a.id) as string[],
+                    featuredAssetId: variantAssets.length ? variantAssets[0].id : undefined,
+                    assetIds: variantAssets.map(a => a.id),
                     sku: variant.sku,
                     taxCategoryId: this.getMatchingTaxCategoryId(variant.taxCategory, taxCategories),
                     stockOnHand: variant.stockOnHand,
@@ -235,8 +236,8 @@ export class Importer {
     private async getFacetValueIds(
         facets: ParsedProductVariant['facets'],
         languageCode: LanguageCode,
-    ): Promise<string[]> {
-        const facetValueIds: string[] = [];
+    ): Promise<ID[]> {
+        const facetValueIds: ID[] = [];
 
         for (const item of facets) {
             const facetName = item.facet;
@@ -277,7 +278,7 @@ export class Importer {
                 }
                 this.facetValueMap.set(facetValueMapKey, facetValueEntity);
             }
-            facetValueIds.push(facetValueEntity.id as string);
+            facetValueIds.push(facetValueEntity.id);
         }
 
         return facetValueIds;
@@ -287,14 +288,14 @@ export class Importer {
      * Attempts to match a TaxCategory entity against the name supplied in the import table. If no matches
      * are found, the first TaxCategory id is returned.
      */
-    private getMatchingTaxCategoryId(name: string, taxCategories: TaxCategory[]): string {
+    private getMatchingTaxCategoryId(name: string, taxCategories: TaxCategory[]): ID {
         if (this.taxCategoryMatches[name]) {
             return this.taxCategoryMatches[name];
         }
         const regex = new RegExp(name, 'i');
         const found = taxCategories.find(tc => !!tc.name.match(regex));
         const match = found ? found : taxCategories[0];
-        this.taxCategoryMatches[name] = match.id as string;
-        return match.id as string;
+        this.taxCategoryMatches[name] = match.id;
+        return match.id;
     }
 }

+ 6 - 6
packages/core/src/data-import/providers/populator/populator.ts

@@ -133,9 +133,9 @@ export class Populator {
                 `The defaultZone (${data.defaultZone}) did not match any zones from the InitialData`,
             );
         }
-        const defaultZoneId = defaultZone.entity.id as string;
+        const defaultZoneId = defaultZone.entity.id;
         await this.channelService.update({
-            id: channel.id as string,
+            id: channel.id,
             defaultTaxZoneId: defaultZoneId,
             defaultShippingZoneId: defaultZoneId,
         });
@@ -156,13 +156,13 @@ export class Populator {
                 zoneItem = { entity: zoneEntity, members: [] };
                 zones.set(zone, zoneItem);
             }
-            zoneItem.members.push(countryEntity.id as string);
+            zoneItem.members.push(countryEntity.id);
         }
 
         // add the countries to the respective zones
         for (const zoneItem of zones.values()) {
             await this.zoneService.addMembersToZone(ctx, {
-                zoneId: zoneItem.entity.id as string,
+                zoneId: zoneItem.entity.id,
                 memberIds: zoneItem.members,
             });
         }
@@ -181,9 +181,9 @@ export class Populator {
 
             for (const { entity } of zoneMap.values()) {
                 await this.taxRateService.create(ctx, {
-                    zoneId: entity.id as string,
+                    zoneId: entity.id,
                     value: taxRate.percentage,
-                    categoryId: category.id as string,
+                    categoryId: category.id,
                     name: `${taxRate.name} ${entity.name}`,
                     enabled: true,
                 });

+ 2 - 1
packages/core/src/data-import/types.ts

@@ -1,8 +1,9 @@
 import { LanguageCode } from '@vendure/common/lib/generated-types';
+import { ID } from '@vendure/common/lib/shared-types';
 
 import { Zone } from '../entity/zone/zone.entity';
 
-export type ZoneMap = Map<string, { entity: Zone; members: string[] }>;
+export type ZoneMap = Map<string, { entity: Zone; members: ID[] }>;
 
 export interface CountryDefinition {
     code: string;

+ 1 - 1
packages/core/src/job-queue/job-queue.service.ts

@@ -125,7 +125,7 @@ export class JobQueueService implements OnApplicationBootstrap, OnModuleDestroy
      * Gets jobs by ids. The implementation is handled by the configured
      * {@link JobQueueStrategy}.
      */
-    getJobsById(ids: string[]): Promise<Job[]> {
+    getJobsById(ids: ID[]): Promise<Job[]> {
         return this.jobQueueStrategy.findManyById(ids);
     }
 

+ 1 - 1
packages/core/src/service/services/administrator.service.ts

@@ -149,7 +149,7 @@ export class AdministratorService {
                 password: superadminCredentials.password,
                 firstName: 'Super',
                 lastName: 'Admin',
-                roleIds: [superAdminRole.id as string],
+                roleIds: [superAdminRole.id],
             });
         }
     }

+ 7 - 11
packages/core/src/service/services/customer.service.ts

@@ -87,8 +87,8 @@ export class CustomerService {
             .leftJoinAndSelect('country.translations', 'countryTranslation')
             .where('address.customer = :id', { id: customerId })
             .getMany()
-            .then((addresses) => {
-                addresses.forEach((address) => {
+            .then(addresses => {
+                addresses.forEach(address => {
                     address.country = translateDeep(address.country, ctx.languageCode);
                 });
                 return addresses;
@@ -168,7 +168,7 @@ export class CustomerService {
         }
         let user = await this.userService.getUserByEmailAddress(input.emailAddress);
         const hasNativeAuthMethod = !!user?.authenticationMethods.find(
-            (m) => m instanceof NativeAuthenticationMethod,
+            m => m instanceof NativeAuthenticationMethod,
         );
         if (user && user.verified) {
             if (hasNativeAuthMethod) {
@@ -413,11 +413,7 @@ export class CustomerService {
         return this.connection.getRepository(Customer).save(customer);
     }
 
-    async createAddress(
-        ctx: RequestContext,
-        customerId: string,
-        input: CreateAddressInput,
-    ): Promise<Address> {
+    async createAddress(ctx: RequestContext, customerId: ID, input: CreateAddressInput): Promise<Address> {
         const customer = await this.connection.manager.findOne(Customer, customerId, {
             where: { deletedAt: null },
             relations: ['addresses'],
@@ -542,8 +538,8 @@ export class CustomerService {
             .findOne(addressId, { relations: ['customer', 'customer.addresses'] });
         if (result) {
             const customerAddressIds = result.customer.addresses
-                .map((a) => a.id)
-                .filter((id) => !idsAreEqual(id, addressId)) as string[];
+                .map(a => a.id)
+                .filter(id => !idsAreEqual(id, addressId)) as string[];
 
             if (customerAddressIds.length) {
                 if (input.defaultBillingAddress === true) {
@@ -576,7 +572,7 @@ export class CustomerService {
             const customerAddresses = result.customer.addresses;
             if (1 < customerAddresses.length) {
                 const otherAddresses = customerAddresses
-                    .filter((address) => !idsAreEqual(address.id, addressToDelete.id))
+                    .filter(address => !idsAreEqual(address.id, addressToDelete.id))
                     .sort((a, b) => (a.id < b.id ? -1 : 1));
                 if (addressToDelete.defaultShippingAddress) {
                     otherAddresses[0].defaultShippingAddress = true;

+ 1 - 1
packages/core/src/service/services/order-testing.service.ts

@@ -69,7 +69,7 @@ export class OrderTestingService {
         const mockOrder = await this.buildMockOrder(ctx, input.shippingAddress, input.lines);
         const eligibleMethods = await this.shippingCalculator.getEligibleShippingMethods(ctx, mockOrder);
         return eligibleMethods.map(result => ({
-            id: result.method.id as string,
+            id: result.method.id,
             price: result.result.price,
             priceWithTax: result.result.priceWithTax,
             description: result.method.description,

+ 24 - 24
packages/core/src/service/services/order.service.ts

@@ -139,7 +139,7 @@ export class OrderService {
             .addOrderBy('items.createdAt', 'ASC')
             .getOne();
         if (order) {
-            order.lines.forEach((line) => {
+            order.lines.forEach(line => {
                 line.productVariant = translateDeep(
                     this.productVariantService.applyChannelPriceAndTax(line.productVariant, ctx),
                     ctx.languageCode,
@@ -179,8 +179,8 @@ export class OrderService {
             .andWhere('order.customer.id = :customerId', { customerId })
             .getManyAndCount()
             .then(([items, totalItems]) => {
-                items.forEach((item) => {
-                    item.lines.forEach((line) => {
+                items.forEach(item => {
+                    item.lines.forEach(line => {
                         line.productVariant = translateDeep(line.productVariant, ctx.languageCode, [
                             'options',
                         ]);
@@ -276,7 +276,7 @@ export class OrderService {
         this.assertAddingItemsState(order);
         this.assertNotOverOrderItemsLimit(order, quantity);
         const productVariant = await this.getProductVariantOrThrow(ctx, productVariantId);
-        let orderLine = order.lines.find((line) => {
+        let orderLine = order.lines.find(line => {
             return (
                 idsAreEqual(line.productVariant.id, productVariantId) &&
                 JSON.stringify(line.customFields) === JSON.stringify(customFields)
@@ -347,7 +347,7 @@ export class OrderService {
         const order = await this.getOrderOrThrow(ctx, orderId);
         this.assertAddingItemsState(order);
         const orderLine = this.getOrderLineOrThrow(order, orderLineId);
-        order.lines = order.lines.filter((line) => !idsAreEqual(line.id, orderLineId));
+        order.lines = order.lines.filter(line => !idsAreEqual(line.id, orderLineId));
         const updatedOrder = await this.applyPriceAdjustments(ctx, order);
         await this.connection.getRepository(OrderLine).remove(orderLine);
         return updatedOrder;
@@ -384,7 +384,7 @@ export class OrderService {
     async removeCouponCode(ctx: RequestContext, orderId: ID, couponCode: string) {
         const order = await this.getOrderOrThrow(ctx, orderId);
         if (order.couponCodes.includes(couponCode)) {
-            order.couponCodes = order.couponCodes.filter((cc) => cc !== couponCode);
+            order.couponCodes = order.couponCodes.filter(cc => cc !== couponCode);
             await this.historyService.createHistoryEntryForOrder({
                 ctx,
                 orderId: order.id,
@@ -425,8 +425,8 @@ export class OrderService {
     async getEligibleShippingMethods(ctx: RequestContext, orderId: ID): Promise<ShippingMethodQuote[]> {
         const order = await this.getOrderOrThrow(ctx, orderId);
         const eligibleMethods = await this.shippingCalculator.getEligibleShippingMethods(ctx, order);
-        return eligibleMethods.map((eligible) => ({
-            id: eligible.method.id as string,
+        return eligibleMethods.map(eligible => ({
+            id: eligible.method.id,
             price: eligible.result.price,
             priceWithTax: eligible.result.priceWithTax,
             description: eligible.method.description,
@@ -438,7 +438,7 @@ export class OrderService {
         const order = await this.getOrderOrThrow(ctx, orderId);
         this.assertAddingItemsState(order);
         const eligibleMethods = await this.shippingCalculator.getEligibleShippingMethods(ctx, order);
-        const selectedMethod = eligibleMethods.find((m) => idsAreEqual(m.method.id, shippingMethodId));
+        const selectedMethod = eligibleMethods.find(m => idsAreEqual(m.method.id, shippingMethodId));
         if (!selectedMethod) {
             throw new UserInputError(`error.shipping-method-unavailable`);
         }
@@ -517,7 +517,7 @@ export class OrderService {
         const { items, orders } = await this.getOrdersAndItemsFromLines(
             ctx,
             input.lines,
-            (i) => !i.fulfillment,
+            i => !i.fulfillment,
             'error.create-fulfillment-items-already-fulfilled',
         );
 
@@ -583,7 +583,7 @@ export class OrderService {
             });
         }
         const items = lines.reduce((acc, l) => [...acc, ...l.items], [] as OrderItem[]);
-        return unique(items.map((i) => i.fulfillment).filter(notNullOrUndefined), 'id');
+        return unique(items.map(i => i.fulfillment).filter(notNullOrUndefined), 'id');
     }
 
     async getFulfillmentOrderItems(id: ID): Promise<OrderItem[]> {
@@ -611,8 +611,8 @@ export class OrderService {
         if (order.state === 'AddingItems' || order.state === 'ArrangingPayment') {
             return true;
         } else {
-            const lines: OrderLineInput[] = order.lines.map((l) => ({
-                orderLineId: l.id as string,
+            const lines: OrderLineInput[] = order.lines.map(l => ({
+                orderLineId: l.id,
                 quantity: l.quantity,
             }));
             return this.cancelOrderByOrderLines(ctx, input, lines);
@@ -630,7 +630,7 @@ export class OrderService {
         const { items, orders } = await this.getOrdersAndItemsFromLines(
             ctx,
             lines,
-            (i) => !i.cancelled,
+            i => !i.cancelled,
             'error.cancel-order-lines-quantity-too-high',
         );
         if (1 < orders.length) {
@@ -648,7 +648,7 @@ export class OrderService {
 
         // Perform the cancellation
         await this.stockMovementService.createCancellationsForOrderItems(items);
-        items.forEach((i) => (i.cancelled = true));
+        items.forEach(i => (i.cancelled = true));
         await this.connection.getRepository(OrderItem).save(items, { reload: false });
 
         const orderWithItems = await this.connection.getRepository(Order).findOne(order.id, {
@@ -662,7 +662,7 @@ export class OrderService {
             orderId: order.id,
             type: HistoryEntryType.ORDER_CANCELLATION,
             data: {
-                orderItemIds: items.map((i) => i.id),
+                orderItemIds: items.map(i => i.id),
                 reason: input.reason || undefined,
             },
         });
@@ -681,7 +681,7 @@ export class OrderService {
         const { items, orders } = await this.getOrdersAndItemsFromLines(
             ctx,
             input.lines,
-            (i) => !i.cancelled,
+            i => !i.cancelled,
             'error.refund-order-lines-quantity-too-high',
         );
         if (1 < orders.length) {
@@ -703,7 +703,7 @@ export class OrderService {
                 state: order.state,
             });
         }
-        if (items.some((i) => !!i.refundId)) {
+        if (items.some(i => !!i.refundId)) {
             throw new IllegalOperationError('error.refund-order-item-already-refunded');
         }
 
@@ -737,7 +737,7 @@ export class OrderService {
                 try {
                     await this.promotionService.validateCouponCode(couponCode, customer.id);
                 } catch (err) {
-                    order.couponCodes = order.couponCodes.filter((c) => c !== couponCode);
+                    order.couponCodes = order.couponCodes.filter(c => c !== couponCode);
                     codesRemoved = true;
                 }
             }
@@ -842,7 +842,7 @@ export class OrderService {
     }
 
     private getOrderLineOrThrow(order: Order, orderLineId: ID): OrderLine {
-        const orderItem = order.lines.find((line) => idsAreEqual(line.id, orderLineId));
+        const orderItem = order.lines.find(line => idsAreEqual(line.id, orderLineId));
         if (!orderItem) {
             throw new UserInputError(`error.order-does-not-contain-line-with-id`, { id: orderLineId });
         }
@@ -924,19 +924,19 @@ export class OrderService {
         const items = new Map<ID, OrderItem>();
 
         const lines = await this.connection.getRepository(OrderLine).findByIds(
-            orderLinesInput.map((l) => l.orderLineId),
+            orderLinesInput.map(l => l.orderLineId),
             {
                 relations: ['order', 'items', 'items.fulfillment', 'order.channels'],
                 order: { id: 'ASC' },
             },
         );
         for (const line of lines) {
-            const inputLine = orderLinesInput.find((l) => idsAreEqual(l.orderLineId, line.id));
+            const inputLine = orderLinesInput.find(l => idsAreEqual(l.orderLineId, line.id));
             if (!inputLine) {
                 continue;
             }
             const order = line.order;
-            if (!order.channels.some((channel) => channel.id === ctx.channelId)) {
+            if (!order.channels.some(channel => channel.id === ctx.channelId)) {
                 throw new EntityNotFoundError('Order', order.id);
             }
             if (!orders.has(order.id)) {
@@ -946,7 +946,7 @@ export class OrderService {
             if (matchingItems.length < inputLine.quantity) {
                 throw new IllegalOperationError(noMatchesError);
             }
-            matchingItems.slice(0, inputLine.quantity).forEach((item) => {
+            matchingItems.slice(0, inputLine.quantity).forEach(item => {
                 items.set(item.id, item);
             });
         }

+ 2 - 4
packages/core/src/service/services/product-variant.service.ts

@@ -227,7 +227,7 @@ export class ProductVariantService {
         if (input.price == null) {
             input.price = 0;
         }
-        input.taxCategoryId = (await this.getTaxCategoryForNewVariant(input.taxCategoryId)).id as string;
+        input.taxCategoryId = (await this.getTaxCategoryForNewVariant(input.taxCategoryId)).id;
 
         const createdVariant = await this.translatableSaver.create({
             input,
@@ -448,9 +448,7 @@ export class ProductVariantService {
             .join(glue);
     }
 
-    private async getTaxCategoryForNewVariant(
-        taxCategoryId: string | null | undefined,
-    ): Promise<TaxCategory> {
+    private async getTaxCategoryForNewVariant(taxCategoryId: ID | null | undefined): Promise<TaxCategory> {
         let taxCategory: TaxCategory;
         if (taxCategoryId) {
             taxCategory = await getEntityOrThrow(this.connection, TaxCategory, taxCategoryId);

+ 1 - 1
packages/core/src/service/services/zone.service.ts

@@ -129,7 +129,7 @@ export class ZoneService implements OnModuleInit {
         input: MutationRemoveMembersFromZoneArgs,
     ): Promise<Zone> {
         const zone = await getEntityOrThrow(this.connection, Zone, input.zoneId, { relations: ['members'] });
-        zone.members = zone.members.filter(country => !input.memberIds.includes(country.id as string));
+        zone.members = zone.members.filter(country => !input.memberIds.includes(country.id));
         await this.connection.getRepository(Zone).save(zone, { reload: false });
         await this.updateZonesCache();
         return assertFound(this.findOne(ctx, zone.id));

+ 4 - 4
packages/elasticsearch-plugin/src/indexer.controller.ts

@@ -632,10 +632,10 @@ export class ElasticsearchIndexerController implements OnModuleInit, OnModuleDes
         const variantAsset = v.featuredAsset;
         const item: VariantIndexItem = {
             channelId,
-            productVariantId: v.id as string,
+            productVariantId: v.id,
             sku: v.sku,
             slug: v.product.slug,
-            productId: v.product.id as string,
+            productId: v.product.id,
             productName: v.product.name,
             productAssetId: productAsset ? productAsset.id : null,
             productPreview: productAsset ? productAsset.preview : '',
@@ -649,7 +649,7 @@ export class ElasticsearchIndexerController implements OnModuleInit, OnModuleDes
             currencyCode: v.currencyCode,
             description: v.product.description,
             facetIds: this.getFacetIds([v]),
-            channelIds: v.product.channels.map(c => c.id as string),
+            channelIds: v.product.channels.map(c => c.id),
             facetValueIds: this.getFacetValueIds([v]),
             collectionIds: v.collections.map(c => c.id.toString()),
             collectionSlugs: v.collections.map(c => c.slug),
@@ -697,7 +697,7 @@ export class ElasticsearchIndexerController implements OnModuleInit, OnModuleDes
                 (ids, v) => [...ids, ...v.collections.map(c => c.slug)],
                 [] as string[],
             ),
-            channelIds: first.product.channels.map(c => c.id as string),
+            channelIds: first.product.channels.map(c => c.id),
             enabled: variants.some(v => v.enabled) && first.product.enabled,
         };
 

+ 12 - 2
scripts/codegen/generate-graphql-types.ts

@@ -107,12 +107,22 @@ Promise.all([
                 [path.join(__dirname, '../../packages/common/src/generated-types.ts')]: {
                     schema: [ADMIN_SCHEMA_OUTPUT_FILE],
                     plugins: commonPlugins,
-                    config,
+                    config: {
+                        ...config,
+                        scalars: {
+                            ID: 'string | number',
+                        },
+                    },
                 },
                 [path.join(__dirname, '../../packages/common/src/generated-shop-types.ts')]: {
                     schema: [SHOP_SCHEMA_OUTPUT_FILE],
                     plugins: commonPlugins,
-                    config,
+                    config: {
+                        ...config,
+                        scalars: {
+                            ID: 'string | number',
+                        },
+                    },
                 },
             },
         });