Forráskód Böngészése

refactor: Rename resolvers & documents for Collections

Relates to #71
Michael Bromley 6 éve
szülő
commit
0f29e6fd5d

+ 3 - 3
admin-ui/src/app/catalog/components/product-category-detail/product-category-detail.component.ts

@@ -144,7 +144,7 @@ export class ProductCategoryDetailComponent extends BaseDetailComponent<Collecti
                 take(1),
                 mergeMap(([category, languageCode]) => {
                     const input = this.getUpdatedCategory(category, this.detailForm, languageCode);
-                    return this.dataService.product.createProductCategory(input);
+                    return this.dataService.product.createCollection(input);
                 }),
             )
             .subscribe(
@@ -154,7 +154,7 @@ export class ProductCategoryDetailComponent extends BaseDetailComponent<Collecti
                     });
                     this.detailForm.markAsPristine();
                     this.changeDetector.markForCheck();
-                    this.router.navigate(['../', data.createProductCategory.id], { relativeTo: this.route });
+                    this.router.navigate(['../', data.createCollection.id], { relativeTo: this.route });
                 },
                 err => {
                     this.notificationService.error(_('common.notify-create-error'), {
@@ -175,7 +175,7 @@ export class ProductCategoryDetailComponent extends BaseDetailComponent<Collecti
                         this.detailForm,
                         languageCode,
                     ) as UpdateCollectionInput;
-                    return this.dataService.product.updateProductCategory(input);
+                    return this.dataService.product.updateCollection(input);
                 }),
             )
             .subscribe(

+ 6 - 6
admin-ui/src/app/catalog/components/product-category-list/product-category-list.component.ts

@@ -1,6 +1,6 @@
 import { ChangeDetectionStrategy, Component } from '@angular/core';
 import { ActivatedRoute, Router } from '@angular/router';
-import { GetProductCategoryList } from 'shared/generated-types';
+import { GetCollectionList } from 'shared/generated-types';
 
 import { BaseListComponent } from '../../../common/base-list.component';
 import { _ } from '../../../core/providers/i18n/mark-for-extraction';
@@ -15,8 +15,8 @@ import { RearrangeEvent } from '../product-category-tree/product-category-tree.c
     changeDetection: ChangeDetectionStrategy.OnPush,
 })
 export class ProductCategoryListComponent extends BaseListComponent<
-    GetProductCategoryList.Query,
-    GetProductCategoryList.Items
+    GetCollectionList.Query,
+    GetCollectionList.Items
 > {
     constructor(
         private dataService: DataService,
@@ -26,13 +26,13 @@ export class ProductCategoryListComponent extends BaseListComponent<
     ) {
         super(router, route);
         super.setQueryFn(
-            (...args: any[]) => this.dataService.product.getProductCategories(99999, 0),
-            data => data.productCategories,
+            (...args: any[]) => this.dataService.product.getCollections(99999, 0),
+            data => data.collections,
         );
     }
 
     onRearrange(event: RearrangeEvent) {
-        this.dataService.product.moveProductCategory([event]).subscribe({
+        this.dataService.product.moveCollection([event]).subscribe({
             next: () => {
                 this.notificationService.success(_('common.notify-saved-changes'));
                 this.refresh();

+ 1 - 1
admin-ui/src/app/catalog/providers/routing/product-category-resolver.ts

@@ -22,7 +22,7 @@ export class ProductCategoryResolver extends BaseEntityResolver<Collection.Fragm
                 parent: {} as any,
                 children: null,
             },
-            id => this.dataService.product.getProductCategory(id).mapStream(data => data.productCategory),
+            id => this.dataService.product.getCollection(id).mapStream(data => data.collection),
         );
     }
 }

+ 20 - 20
admin-ui/src/app/data/definitions/product-definitions.ts

@@ -285,7 +285,7 @@ export const CREATE_ASSETS = gql`
     ${ASSET_FRAGMENT}
 `;
 
-export const PRODUCT_CATEGORY_FRAGMENT = gql`
+export const COLLECTION_FRAGMENT = gql`
     fragment Collection on Collection {
         id
         name
@@ -320,9 +320,9 @@ export const PRODUCT_CATEGORY_FRAGMENT = gql`
     ${ASSET_FRAGMENT}
 `;
 
-export const GET_PRODUCT_CATEGORY_LIST = gql`
-    query GetProductCategoryList($options: CollectionListOptions, $languageCode: LanguageCode) {
-        productCategories(languageCode: $languageCode, options: $options) {
+export const GET_COLLECTION_LIST = gql`
+    query GetCollectionList($options: CollectionListOptions, $languageCode: LanguageCode) {
+        collections(languageCode: $languageCode, options: $options) {
             items {
                 id
                 name
@@ -349,40 +349,40 @@ export const GET_PRODUCT_CATEGORY_LIST = gql`
     ${ASSET_FRAGMENT}
 `;
 
-export const GET_PRODUCT_CATEGORY = gql`
-    query GetProductCategory($id: ID!, $languageCode: LanguageCode) {
-        productCategory(id: $id, languageCode: $languageCode) {
+export const GET_COLLECTION = gql`
+    query GetCollection($id: ID!, $languageCode: LanguageCode) {
+        collection(id: $id, languageCode: $languageCode) {
             ...Collection
         }
     }
-    ${PRODUCT_CATEGORY_FRAGMENT}
+    ${COLLECTION_FRAGMENT}
 `;
 
-export const CREATE_PRODUCT_CATEGORY = gql`
-    mutation CreateProductCategory($input: CreateCollectionInput!) {
-        createProductCategory(input: $input) {
+export const CREATE_COLLECTION = gql`
+    mutation CreateCollection($input: CreateCollectionInput!) {
+        createCollection(input: $input) {
             ...Collection
         }
     }
-    ${PRODUCT_CATEGORY_FRAGMENT}
+    ${COLLECTION_FRAGMENT}
 `;
 
-export const UPDATE_PRODUCT_CATEGORY = gql`
-    mutation UpdateProductCategory($input: UpdateCollectionInput!) {
-        updateProductCategory(input: $input) {
+export const UPDATE_COLLECTION = gql`
+    mutation UpdateCollection($input: UpdateCollectionInput!) {
+        updateCollection(input: $input) {
             ...Collection
         }
     }
-    ${PRODUCT_CATEGORY_FRAGMENT}
+    ${COLLECTION_FRAGMENT}
 `;
 
-export const MOVE_PRODUCT_CATEGORY = gql`
-    mutation MoveProductCategory($input: MoveCollectionInput!) {
-        moveProductCategory(input: $input) {
+export const MOVE_COLLECTION = gql`
+    mutation MoveCollection($input: MoveCollectionInput!) {
+        moveCollection(input: $input) {
             ...Collection
         }
     }
-    ${PRODUCT_CATEGORY_FRAGMENT}
+    ${COLLECTION_FRAGMENT}
 `;
 
 export const SEARCH_PRODUCTS = gql`

+ 27 - 30
admin-ui/src/app/data/providers/product-data.service.ts

@@ -3,27 +3,27 @@ import { bufferCount, concatMap } from 'rxjs/operators';
 import {
     AddOptionGroupToProduct,
     CreateAssets,
+    CreateCollection,
     CreateCollectionInput,
     CreateProduct,
-    CreateProductCategory,
     CreateProductInput,
     CreateProductOptionGroup,
     CreateProductOptionGroupInput,
     DeleteProduct,
     GenerateProductVariants,
     GetAssetList,
-    GetProductCategory,
-    GetProductCategoryList,
+    GetCollection,
+    GetCollectionList,
     GetProductList,
     GetProductOptionGroups,
     GetProductWithVariants,
+    MoveCollection,
     MoveCollectionInput,
-    MoveProductCategory,
     RemoveOptionGroupFromProduct,
     SearchProducts,
+    UpdateCollection,
     UpdateCollectionInput,
     UpdateProduct,
-    UpdateProductCategory,
     UpdateProductInput,
     UpdateProductVariantInput,
     UpdateProductVariants,
@@ -34,22 +34,22 @@ import { getDefaultLanguage } from '../../common/utilities/get-default-language'
 import {
     ADD_OPTION_GROUP_TO_PRODUCT,
     CREATE_ASSETS,
+    CREATE_COLLECTION,
     CREATE_PRODUCT,
-    CREATE_PRODUCT_CATEGORY,
     CREATE_PRODUCT_OPTION_GROUP,
     DELETE_PRODUCT,
     GENERATE_PRODUCT_VARIANTS,
     GET_ASSET_LIST,
-    GET_PRODUCT_CATEGORY,
-    GET_PRODUCT_CATEGORY_LIST,
+    GET_COLLECTION,
+    GET_COLLECTION_LIST,
     GET_PRODUCT_LIST,
     GET_PRODUCT_OPTION_GROUPS,
     GET_PRODUCT_WITH_VARIANTS,
-    MOVE_PRODUCT_CATEGORY,
+    MOVE_COLLECTION,
     REMOVE_OPTION_GROUP_FROM_PRODUCT,
     SEARCH_PRODUCTS,
+    UPDATE_COLLECTION,
     UPDATE_PRODUCT,
-    UPDATE_PRODUCT_CATEGORY,
     UPDATE_PRODUCT_VARIANTS,
 } from '../definitions/product-definitions';
 
@@ -205,9 +205,9 @@ export class ProductDataService {
         });
     }
 
-    getProductCategories(take: number = 10, skip: number = 0) {
-        return this.baseDataService.query<GetProductCategoryList.Query, GetProductCategoryList.Variables>(
-            GET_PRODUCT_CATEGORY_LIST,
+    getCollections(take: number = 10, skip: number = 0) {
+        return this.baseDataService.query<GetCollectionList.Query, GetCollectionList.Variables>(
+            GET_COLLECTION_LIST,
             {
                 options: {
                     take,
@@ -218,19 +218,16 @@ export class ProductDataService {
         );
     }
 
-    getProductCategory(id: string) {
-        return this.baseDataService.query<GetProductCategory.Query, GetProductCategory.Variables>(
-            GET_PRODUCT_CATEGORY,
-            {
-                id,
-                languageCode: getDefaultLanguage(),
-            },
-        );
+    getCollection(id: string) {
+        return this.baseDataService.query<GetCollection.Query, GetCollection.Variables>(GET_COLLECTION, {
+            id,
+            languageCode: getDefaultLanguage(),
+        });
     }
 
-    createProductCategory(input: CreateCollectionInput) {
-        return this.baseDataService.mutate<CreateProductCategory.Mutation, CreateProductCategory.Variables>(
-            CREATE_PRODUCT_CATEGORY,
+    createCollection(input: CreateCollectionInput) {
+        return this.baseDataService.mutate<CreateCollection.Mutation, CreateCollection.Variables>(
+            CREATE_COLLECTION,
             {
                 input: pick(input, [
                     'translations',
@@ -243,9 +240,9 @@ export class ProductDataService {
         );
     }
 
-    updateProductCategory(input: UpdateCollectionInput) {
-        return this.baseDataService.mutate<UpdateProductCategory.Mutation, UpdateProductCategory.Variables>(
-            UPDATE_PRODUCT_CATEGORY,
+    updateCollection(input: UpdateCollectionInput) {
+        return this.baseDataService.mutate<UpdateCollection.Mutation, UpdateCollection.Variables>(
+            UPDATE_COLLECTION,
             {
                 input: pick(input, [
                     'id',
@@ -259,11 +256,11 @@ export class ProductDataService {
         );
     }
 
-    moveProductCategory(inputs: MoveCollectionInput[]) {
+    moveCollection(inputs: MoveCollectionInput[]) {
         return from(inputs).pipe(
             concatMap(input =>
-                this.baseDataService.mutate<MoveProductCategory.Mutation, MoveProductCategory.Variables>(
-                    MOVE_PRODUCT_CATEGORY,
+                this.baseDataService.mutate<MoveCollection.Mutation, MoveCollection.Variables>(
+                    MOVE_COLLECTION,
                     { input },
                 ),
             ),

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
schema-admin.json


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
schema-shop.json


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 326 - 419
schema.json


+ 2 - 2
server/e2e/__snapshots__/product-category.e2e-spec.ts.snap → server/e2e/__snapshots__/collection.e2e-spec.ts.snap

@@ -1,6 +1,6 @@
 // Jest Snapshot v1, https://goo.gl/fbAQLP
 
-exports[`ProductCategory resolver createProductCategory creates a root category 1`] = `
+exports[`Collection resolver createCollection creates a root collection 1`] = `
 Object {
   "assets": Array [
     Object {
@@ -58,7 +58,7 @@ Object {
 }
 `;
 
-exports[`ProductCategory resolver updateProductCategory updates the details 1`] = `
+exports[`Collection resolver updateCollection updates the details 1`] = `
 Object {
   "assets": Array [
     Object {

+ 117 - 135
server/e2e/product-category.e2e-spec.ts → server/e2e/collection.e2e-spec.ts

@@ -2,21 +2,21 @@ import gql from 'graphql-tag';
 import path from 'path';
 
 import {
-    CREATE_PRODUCT_CATEGORY,
+    CREATE_COLLECTION,
     GET_ASSET_LIST,
-    GET_PRODUCT_CATEGORY,
-    MOVE_PRODUCT_CATEGORY,
-    UPDATE_PRODUCT_CATEGORY,
+    GET_COLLECTION,
+    MOVE_COLLECTION,
+    UPDATE_COLLECTION,
 } from '../../admin-ui/src/app/data/definitions/product-definitions';
 import {
-    CreateProductCategory,
+    Collection,
+    CreateCollection,
     GetAssetList,
-    GetProductCategory,
+    GetCollection,
     LanguageCode,
-    MoveProductCategory,
-    ProductCategory,
+    MoveCollection,
     SortOrder,
-    UpdateProductCategory,
+    UpdateCollection,
 } from '../../shared/generated-types';
 import { ROOT_CATEGORY_NAME } from '../../shared/shared-constants';
 
@@ -25,13 +25,13 @@ import { TestAdminClient } from './test-client';
 import { TestServer } from './test-server';
 import { assertThrowsWithMessage } from './test-utils';
 
-describe('ProductCategory resolver', () => {
+describe('Collection resolver', () => {
     const client = new TestAdminClient();
     const server = new TestServer();
     let assets: GetAssetList.Items[];
-    let electronicsCategory: ProductCategory.Fragment;
-    let laptopsCategory: ProductCategory.Fragment;
-    let appleCategory: ProductCategory.Fragment;
+    let electronicsCategory: Collection.Fragment;
+    let laptopsCategory: Collection.Fragment;
+    let appleCategory: Collection.Fragment;
 
     beforeAll(async () => {
         const token = await server.init({
@@ -53,142 +53,139 @@ describe('ProductCategory resolver', () => {
         await server.destroy();
     });
 
-    describe('createProductCategory', () => {
-        it('creates a root category', async () => {
-            const result = await client.query<
-                CreateProductCategory.Mutation,
-                CreateProductCategory.Variables
-            >(CREATE_PRODUCT_CATEGORY, {
-                input: {
-                    assetIds: [assets[0].id, assets[1].id],
-                    featuredAssetId: assets[1].id,
-                    facetValueIds: ['T_1'],
-                    translations: [{ languageCode: LanguageCode.en, name: 'Electronics', description: '' }],
+    describe('createCollection', () => {
+        it('creates a root collection', async () => {
+            const result = await client.query<CreateCollection.Mutation, CreateCollection.Variables>(
+                CREATE_COLLECTION,
+                {
+                    input: {
+                        assetIds: [assets[0].id, assets[1].id],
+                        featuredAssetId: assets[1].id,
+                        facetValueIds: ['T_1'],
+                        translations: [
+                            { languageCode: LanguageCode.en, name: 'Electronics', description: '' },
+                        ],
+                    },
                 },
-            });
+            );
 
-            electronicsCategory = result.createProductCategory;
+            electronicsCategory = result.createCollection;
             expect(electronicsCategory).toMatchSnapshot();
             expect(electronicsCategory.parent.name).toBe(ROOT_CATEGORY_NAME);
         });
 
         it('creates a nested category', async () => {
-            const result = await client.query<
-                CreateProductCategory.Mutation,
-                CreateProductCategory.Variables
-            >(CREATE_PRODUCT_CATEGORY, {
-                input: {
-                    parentId: electronicsCategory.id,
-                    translations: [{ languageCode: LanguageCode.en, name: 'Laptops', description: '' }],
-                    facetValueIds: ['T_2'],
+            const result = await client.query<CreateCollection.Mutation, CreateCollection.Variables>(
+                CREATE_COLLECTION,
+                {
+                    input: {
+                        parentId: electronicsCategory.id,
+                        translations: [{ languageCode: LanguageCode.en, name: 'Laptops', description: '' }],
+                        facetValueIds: ['T_2'],
+                    },
                 },
-            });
-            laptopsCategory = result.createProductCategory;
+            );
+            laptopsCategory = result.createCollection;
             expect(laptopsCategory.parent.name).toBe(electronicsCategory.name);
         });
 
         it('creates a 2nd level nested category', async () => {
-            const result = await client.query<
-                CreateProductCategory.Mutation,
-                CreateProductCategory.Variables
-            >(CREATE_PRODUCT_CATEGORY, {
-                input: {
-                    parentId: laptopsCategory.id,
-                    translations: [{ languageCode: LanguageCode.en, name: 'Apple', description: '' }],
-                    facetValueIds: ['T_3', 'T_4'],
+            const result = await client.query<CreateCollection.Mutation, CreateCollection.Variables>(
+                CREATE_COLLECTION,
+                {
+                    input: {
+                        parentId: laptopsCategory.id,
+                        translations: [{ languageCode: LanguageCode.en, name: 'Apple', description: '' }],
+                        facetValueIds: ['T_3', 'T_4'],
+                    },
                 },
-            });
-            appleCategory = result.createProductCategory;
+            );
+            appleCategory = result.createCollection;
             expect(appleCategory.parent.name).toBe(laptopsCategory.name);
         });
     });
 
-    describe('productCategory query', () => {
+    describe('collection query', () => {
         it('returns a category', async () => {
-            const result = await client.query<GetProductCategory.Query, GetProductCategory.Variables>(
-                GET_PRODUCT_CATEGORY,
-                { id: laptopsCategory.id },
-            );
-            if (!result.productCategory) {
+            const result = await client.query<GetCollection.Query, GetCollection.Variables>(GET_COLLECTION, {
+                id: laptopsCategory.id,
+            });
+            if (!result.collection) {
                 fail(`did not return the category`);
                 return;
             }
-            expect(result.productCategory.id).toBe(laptopsCategory.id);
+            expect(result.collection.id).toBe(laptopsCategory.id);
         });
 
         it('resolves descendantFacetValues 1 level deep', async () => {
             const result = await client.query(GET_DECENDANT_FACET_VALUES, { id: laptopsCategory.id });
-            if (!result.productCategory) {
+            if (!result.collection) {
                 fail(`did not return the category`);
                 return;
             }
-            expect(result.productCategory.descendantFacetValues.map(v => v.id)).toEqual(['T_3', 'T_4']);
+            expect(result.collection.descendantFacetValues.map(v => v.id)).toEqual(['T_3', 'T_4']);
         });
 
         it('resolves descendantFacetValues 2 levels deep', async () => {
             const result = await client.query(GET_DECENDANT_FACET_VALUES, { id: electronicsCategory.id });
-            if (!result.productCategory) {
+            if (!result.collection) {
                 fail(`did not return the category`);
                 return;
             }
-            expect(result.productCategory.descendantFacetValues.map(v => v.id)).toEqual([
-                'T_2',
-                'T_3',
-                'T_4',
-            ]);
+            expect(result.collection.descendantFacetValues.map(v => v.id)).toEqual(['T_2', 'T_3', 'T_4']);
         });
 
         it('resolves ancestorFacetValues at root', async () => {
             const result = await client.query(GET_ANCESTOR_FACET_VALUES, { id: electronicsCategory.id });
-            if (!result.productCategory) {
+            if (!result.collection) {
                 fail(`did not return the category`);
                 return;
             }
-            expect(result.productCategory.ancestorFacetValues.map(v => v.id)).toEqual([]);
+            expect(result.collection.ancestorFacetValues.map(v => v.id)).toEqual([]);
         });
 
         it('resolves ancestorFacetValues 1 level deep', async () => {
             const result = await client.query(GET_ANCESTOR_FACET_VALUES, { id: laptopsCategory.id });
-            if (!result.productCategory) {
+            if (!result.collection) {
                 fail(`did not return the category`);
                 return;
             }
-            expect(result.productCategory.ancestorFacetValues.map(v => v.id)).toEqual(['T_1']);
+            expect(result.collection.ancestorFacetValues.map(v => v.id)).toEqual(['T_1']);
         });
 
         it('resolves ancestorFacetValues 2 levels deep', async () => {
             const result = await client.query(GET_ANCESTOR_FACET_VALUES, { id: appleCategory.id });
-            if (!result.productCategory) {
+            if (!result.collection) {
                 fail(`did not return the category`);
                 return;
             }
-            expect(result.productCategory.ancestorFacetValues.map(v => v.id)).toEqual(['T_1', 'T_2']);
+            expect(result.collection.ancestorFacetValues.map(v => v.id)).toEqual(['T_1', 'T_2']);
         });
     });
 
-    describe('updateProductCategory', () => {
+    describe('updateCollection', () => {
         it('updates the details', async () => {
-            const result = await client.query<
-                UpdateProductCategory.Mutation,
-                UpdateProductCategory.Variables
-            >(UPDATE_PRODUCT_CATEGORY, {
-                input: {
-                    id: appleCategory.id,
-                    assetIds: [assets[1].id],
-                    featuredAssetId: assets[1].id,
-                    facetValueIds: ['T_3'],
-                    translations: [{ languageCode: LanguageCode.en, description: 'Apple stuff ' }],
+            const result = await client.query<UpdateCollection.Mutation, UpdateCollection.Variables>(
+                UPDATE_COLLECTION,
+                {
+                    input: {
+                        id: appleCategory.id,
+                        assetIds: [assets[1].id],
+                        featuredAssetId: assets[1].id,
+                        facetValueIds: ['T_3'],
+                        translations: [{ languageCode: LanguageCode.en, description: 'Apple stuff ' }],
+                    },
                 },
-            });
+            );
 
-            expect(result.updateProductCategory).toMatchSnapshot();
+            expect(result.updateCollection).toMatchSnapshot();
         });
     });
 
-    describe('moveProductCategory', () => {
+    describe('moveCollection', () => {
         it('moves a category to a new parent', async () => {
-            const result = await client.query<MoveProductCategory.Mutation, MoveProductCategory.Variables>(
-                MOVE_PRODUCT_CATEGORY,
+            const result = await client.query<MoveCollection.Mutation, MoveCollection.Variables>(
+                MOVE_COLLECTION,
                 {
                     input: {
                         categoryId: appleCategory.id,
@@ -198,55 +195,46 @@ describe('ProductCategory resolver', () => {
                 },
             );
 
-            expect(result.moveProductCategory.parent.id).toBe(electronicsCategory.id);
+            expect(result.moveCollection.parent.id).toBe(electronicsCategory.id);
 
             const positions = await getChildrenOf(electronicsCategory.id);
             expect(positions.map(i => i.id)).toEqual([appleCategory.id, laptopsCategory.id]);
         });
 
         it('alters the position in the current parent', async () => {
-            await client.query<MoveProductCategory.Mutation, MoveProductCategory.Variables>(
-                MOVE_PRODUCT_CATEGORY,
-                {
-                    input: {
-                        categoryId: appleCategory.id,
-                        parentId: electronicsCategory.id,
-                        index: 1,
-                    },
+            await client.query<MoveCollection.Mutation, MoveCollection.Variables>(MOVE_COLLECTION, {
+                input: {
+                    categoryId: appleCategory.id,
+                    parentId: electronicsCategory.id,
+                    index: 1,
                 },
-            );
+            });
 
             const afterResult = await getChildrenOf(electronicsCategory.id);
             expect(afterResult.map(i => i.id)).toEqual([laptopsCategory.id, appleCategory.id]);
         });
 
         it('corrects an out-of-bounds negative index value', async () => {
-            await client.query<MoveProductCategory.Mutation, MoveProductCategory.Variables>(
-                MOVE_PRODUCT_CATEGORY,
-                {
-                    input: {
-                        categoryId: appleCategory.id,
-                        parentId: electronicsCategory.id,
-                        index: -3,
-                    },
+            await client.query<MoveCollection.Mutation, MoveCollection.Variables>(MOVE_COLLECTION, {
+                input: {
+                    categoryId: appleCategory.id,
+                    parentId: electronicsCategory.id,
+                    index: -3,
                 },
-            );
+            });
 
             const afterResult = await getChildrenOf(electronicsCategory.id);
             expect(afterResult.map(i => i.id)).toEqual([appleCategory.id, laptopsCategory.id]);
         });
 
         it('corrects an out-of-bounds positive index value', async () => {
-            await client.query<MoveProductCategory.Mutation, MoveProductCategory.Variables>(
-                MOVE_PRODUCT_CATEGORY,
-                {
-                    input: {
-                        categoryId: appleCategory.id,
-                        parentId: electronicsCategory.id,
-                        index: 10,
-                    },
+            await client.query<MoveCollection.Mutation, MoveCollection.Variables>(MOVE_COLLECTION, {
+                input: {
+                    categoryId: appleCategory.id,
+                    parentId: electronicsCategory.id,
+                    index: 10,
                 },
-            );
+            });
 
             const afterResult = await getChildrenOf(electronicsCategory.id);
             expect(afterResult.map(i => i.id)).toEqual([laptopsCategory.id, appleCategory.id]);
@@ -256,17 +244,14 @@ describe('ProductCategory resolver', () => {
             'throws if attempting to move into self',
             assertThrowsWithMessage(
                 () =>
-                    client.query<MoveProductCategory.Mutation, MoveProductCategory.Variables>(
-                        MOVE_PRODUCT_CATEGORY,
-                        {
-                            input: {
-                                categoryId: appleCategory.id,
-                                parentId: appleCategory.id,
-                                index: 0,
-                            },
+                    client.query<MoveCollection.Mutation, MoveCollection.Variables>(MOVE_COLLECTION, {
+                        input: {
+                            categoryId: appleCategory.id,
+                            parentId: appleCategory.id,
+                            index: 0,
                         },
-                    ),
-                `Cannot move a ProductCategory into itself`,
+                    }),
+                `Cannot move a Collection into itself`,
             ),
         );
 
@@ -274,30 +259,27 @@ describe('ProductCategory resolver', () => {
             'throws if attempting to move into a decendant of self',
             assertThrowsWithMessage(
                 () =>
-                    client.query<MoveProductCategory.Mutation, MoveProductCategory.Variables>(
-                        MOVE_PRODUCT_CATEGORY,
-                        {
-                            input: {
-                                categoryId: appleCategory.id,
-                                parentId: appleCategory.id,
-                                index: 0,
-                            },
+                    client.query<MoveCollection.Mutation, MoveCollection.Variables>(MOVE_COLLECTION, {
+                        input: {
+                            categoryId: appleCategory.id,
+                            parentId: appleCategory.id,
+                            index: 0,
                         },
-                    ),
-                `Cannot move a ProductCategory into itself`,
+                    }),
+                `Cannot move a Collection into itself`,
             ),
         );
 
         async function getChildrenOf(parentId: string): Promise<Array<{ name: string; id: string }>> {
             const result = await client.query(GET_CATEGORIES);
-            return result.productCategories.items.filter(i => i.parent.id === parentId);
+            return result.collections.items.filter(i => i.parent.id === parentId);
         }
     });
 });
 
 const GET_CATEGORIES = gql`
     query GetCategories {
-        productCategories(languageCode: en) {
+        collections(languageCode: en) {
             items {
                 id
                 name
@@ -313,7 +295,7 @@ const GET_CATEGORIES = gql`
 
 const GET_DECENDANT_FACET_VALUES = gql`
     query GetDescendantFacetValues($id: ID!) {
-        productCategory(id: $id) {
+        collection(id: $id) {
             id
             descendantFacetValues {
                 id
@@ -325,7 +307,7 @@ const GET_DECENDANT_FACET_VALUES = gql`
 
 const GET_ANCESTOR_FACET_VALUES = gql`
     query GetAncestorFacetValues($id: ID!) {
-        productCategory(id: $id) {
+        collection(id: $id) {
             id
             ancestorFacetValues {
                 id

+ 4 - 4
server/src/api/api-internal-modules.ts

@@ -10,6 +10,7 @@ import { AdministratorResolver } from './resolvers/admin/administrator.resolver'
 import { AssetResolver } from './resolvers/admin/asset.resolver';
 import { AuthResolver } from './resolvers/admin/auth.resolver';
 import { ChannelResolver } from './resolvers/admin/channel.resolver';
+import { CollectionResolver } from './resolvers/admin/collection.resolver';
 import { CountryResolver } from './resolvers/admin/country.resolver';
 import { CustomerGroupResolver } from './resolvers/admin/customer-group.resolver';
 import { CustomerResolver } from './resolvers/admin/customer.resolver';
@@ -18,7 +19,6 @@ import { GlobalSettingsResolver } from './resolvers/admin/global-settings.resolv
 import { ImportResolver } from './resolvers/admin/import.resolver';
 import { OrderResolver } from './resolvers/admin/order.resolver';
 import { PaymentMethodResolver } from './resolvers/admin/payment-method.resolver';
-import { ProductCategoryResolver } from './resolvers/admin/product-category.resolver';
 import { ProductOptionResolver } from './resolvers/admin/product-option.resolver';
 import { ProductResolver } from './resolvers/admin/product.resolver';
 import { PromotionResolver } from './resolvers/admin/promotion.resolver';
@@ -28,10 +28,10 @@ import { ShippingMethodResolver } from './resolvers/admin/shipping-method.resolv
 import { TaxCategoryResolver } from './resolvers/admin/tax-category.resolver';
 import { TaxRateResolver } from './resolvers/admin/tax-rate.resolver';
 import { ZoneResolver } from './resolvers/admin/zone.resolver';
+import { CollectionEntityResolver } from './resolvers/entity/collection-entity.resolver';
 import { CustomerEntityResolver } from './resolvers/entity/customer-entity.resolver';
 import { OrderEntityResolver } from './resolvers/entity/order-entity.resolver';
 import { OrderLineEntityResolver } from './resolvers/entity/order-line-entity.resolver';
-import { ProductCategoryEntityResolver } from './resolvers/entity/product-category-entity.resolver';
 import { ProductEntityResolver } from './resolvers/entity/product-entity.resolver';
 import { ProductOptionGroupEntityResolver } from './resolvers/entity/product-option-group-entity.resolver';
 import { ProductVariantEntityResolver } from './resolvers/entity/product-variant-entity.resolver';
@@ -45,6 +45,7 @@ const adminResolvers = [
     AssetResolver,
     AuthResolver,
     ChannelResolver,
+    CollectionResolver,
     CountryResolver,
     CustomerGroupResolver,
     CustomerResolver,
@@ -53,7 +54,6 @@ const adminResolvers = [
     ImportResolver,
     OrderResolver,
     PaymentMethodResolver,
-    ProductCategoryResolver,
     ProductOptionResolver,
     ProductResolver,
     PromotionResolver,
@@ -68,10 +68,10 @@ const adminResolvers = [
 const shopResolvers = [ShopAuthResolver, ShopCustomerResolver, ShopOrderResolver, ShopProductsResolver];
 
 export const entityResolvers = [
+    CollectionEntityResolver,
     CustomerEntityResolver,
     OrderEntityResolver,
     OrderLineEntityResolver,
-    ProductCategoryEntityResolver,
     ProductEntityResolver,
     ProductOptionGroupEntityResolver,
     ProductVariantEntityResolver,

+ 23 - 26
server/src/api/resolvers/admin/product-category.resolver.ts → server/src/api/resolvers/admin/collection.resolver.ts

@@ -1,78 +1,75 @@
 import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
 
 import {
-    CreateProductCategoryMutationArgs,
-    MoveProductCategoryMutationArgs,
+    CollectionQueryArgs,
+    CollectionsQueryArgs,
+    CreateCollectionMutationArgs,
+    MoveCollectionMutationArgs,
     Permission,
-    ProductCategoriesQueryArgs,
-    ProductCategoryQueryArgs,
-    UpdateProductCategoryMutationArgs,
+    UpdateCollectionMutationArgs,
 } from '../../../../../shared/generated-types';
 import { PaginatedList } from '../../../../../shared/shared-types';
 import { Translated } from '../../../common/types/locale-types';
 import { Collection } from '../../../entity/collection/collection.entity';
+import { CollectionService } from '../../../service/services/collection.service';
 import { FacetValueService } from '../../../service/services/facet-value.service';
-import { ProductCategoryService } from '../../../service/services/product-category.service';
 import { RequestContext } from '../../common/request-context';
 import { Allow } from '../../decorators/allow.decorator';
 import { Decode } from '../../decorators/decode.decorator';
 import { Ctx } from '../../decorators/request-context.decorator';
 
 @Resolver()
-export class ProductCategoryResolver {
-    constructor(
-        private productCategoryService: ProductCategoryService,
-        private facetValueService: FacetValueService,
-    ) {}
+export class CollectionResolver {
+    constructor(private collectionService: CollectionService, private facetValueService: FacetValueService) {}
 
     @Query()
     @Allow(Permission.ReadCatalog)
-    async productCategories(
+    async collections(
         @Ctx() ctx: RequestContext,
-        @Args() args: ProductCategoriesQueryArgs,
+        @Args() args: CollectionsQueryArgs,
     ): Promise<PaginatedList<Translated<Collection>>> {
-        return this.productCategoryService.findAll(ctx, args.options || undefined);
+        return this.collectionService.findAll(ctx, args.options || undefined);
     }
 
     @Query()
     @Allow(Permission.ReadCatalog)
-    async productCategory(
+    async collection(
         @Ctx() ctx: RequestContext,
-        @Args() args: ProductCategoryQueryArgs,
+        @Args() args: CollectionQueryArgs,
     ): Promise<Translated<Collection> | undefined> {
-        return this.productCategoryService.findOne(ctx, args.id);
+        return this.collectionService.findOne(ctx, args.id);
     }
 
     @Mutation()
     @Allow(Permission.CreateCatalog)
     @Decode('assetIds', 'featuredAssetId', 'parentId', 'facetValueIds')
-    async createProductCategory(
+    async createCollection(
         @Ctx() ctx: RequestContext,
-        @Args() args: CreateProductCategoryMutationArgs,
+        @Args() args: CreateCollectionMutationArgs,
     ): Promise<Translated<Collection>> {
         const { input } = args;
-        return this.productCategoryService.create(ctx, input);
+        return this.collectionService.create(ctx, input);
     }
 
     @Mutation()
     @Allow(Permission.UpdateCatalog)
     @Decode('assetIds', 'featuredAssetId', 'facetValueIds')
-    async updateProductCategory(
+    async updateCollection(
         @Ctx() ctx: RequestContext,
-        @Args() args: UpdateProductCategoryMutationArgs,
+        @Args() args: UpdateCollectionMutationArgs,
     ): Promise<Translated<Collection>> {
         const { input } = args;
-        return this.productCategoryService.update(ctx, input);
+        return this.collectionService.update(ctx, input);
     }
 
     @Mutation()
     @Allow(Permission.UpdateCatalog)
     @Decode('categoryId', 'parentId')
-    async moveProductCategory(
+    async moveCollection(
         @Ctx() ctx: RequestContext,
-        @Args() args: MoveProductCategoryMutationArgs,
+        @Args() args: MoveCollectionMutationArgs,
     ): Promise<Translated<Collection>> {
         const { input } = args;
-        return this.productCategoryService.move(ctx, input);
+        return this.collectionService.move(ctx, input);
     }
 }

+ 5 - 8
server/src/api/resolvers/entity/product-category-entity.resolver.ts → server/src/api/resolvers/entity/collection-entity.resolver.ts

@@ -3,24 +3,21 @@ import { Parent, ResolveProperty, Resolver } from '@nestjs/graphql';
 import { Translated } from '../../../common/types/locale-types';
 import { Collection } from '../../../entity/collection/collection.entity';
 import { FacetValue } from '../../../entity/facet-value/facet-value.entity';
+import { CollectionService } from '../../../service/services/collection.service';
 import { FacetValueService } from '../../../service/services/facet-value.service';
-import { ProductCategoryService } from '../../../service/services/product-category.service';
 import { RequestContext } from '../../common/request-context';
 import { Ctx } from '../../decorators/request-context.decorator';
 
 @Resolver('Collection')
-export class ProductCategoryEntityResolver {
-    constructor(
-        private productCategoryService: ProductCategoryService,
-        private facetValueService: FacetValueService,
-    ) {}
+export class CollectionEntityResolver {
+    constructor(private collectionService: CollectionService, private facetValueService: FacetValueService) {}
 
     @ResolveProperty()
     async descendantFacetValues(
         @Ctx() ctx: RequestContext,
         @Parent() category: Collection,
     ): Promise<Array<Translated<FacetValue>>> {
-        const descendants = await this.productCategoryService.getDescendants(ctx, category.id);
+        const descendants = await this.collectionService.getDescendants(ctx, category.id);
         return this.facetValueService.findByCategoryIds(ctx, descendants.map(d => d.id));
     }
 
@@ -29,7 +26,7 @@ export class ProductCategoryEntityResolver {
         @Ctx() ctx: RequestContext,
         @Parent() category: Collection,
     ): Promise<Array<Translated<FacetValue>>> {
-        const ancestors = await this.productCategoryService.getAncestors(category.id, ctx);
+        const ancestors = await this.collectionService.getAncestors(category.id, ctx);
         return this.facetValueService.findByCategoryIds(ctx, ancestors.map(d => d.id));
     }
 }

+ 12 - 12
server/src/api/resolvers/shop/shop-products.resolver.ts

@@ -1,19 +1,19 @@
 import { Args, Query, Resolver } from '@nestjs/graphql';
 
 import {
-    ProductCategoriesQueryArgs,
-    ProductCategoryQueryArgs,
+    CollectionQueryArgs,
+    CollectionsQueryArgs,
     ProductQueryArgs,
-    ProductsQueryArgs,
     SearchResponse,
-} from '../../../../../shared/generated-types';
+} from '../../../../../shared/generated-shop-types';
 import { Omit } from '../../../../../shared/omit';
 import { PaginatedList } from '../../../../../shared/shared-types';
+import { ProductsQueryArgs } from '../../../../dist/shared/generated-shop-types';
 import { InternalServerError } from '../../../common/error/errors';
 import { Translated } from '../../../common/types/locale-types';
 import { Collection } from '../../../entity/collection/collection.entity';
 import { Product } from '../../../entity/product/product.entity';
-import { ProductCategoryService } from '../../../service';
+import { CollectionService } from '../../../service';
 import { FacetValueService } from '../../../service/services/facet-value.service';
 import { ProductVariantService } from '../../../service/services/product-variant.service';
 import { ProductService } from '../../../service/services/product.service';
@@ -26,7 +26,7 @@ export class ShopProductsResolver {
         private productService: ProductService,
         private productVariantService: ProductVariantService,
         private facetValueService: FacetValueService,
-        private productCategoryService: ProductCategoryService,
+        private collectionService: CollectionService,
     ) {}
 
     @Query()
@@ -46,19 +46,19 @@ export class ShopProductsResolver {
     }
 
     @Query()
-    async productCategories(
+    async collections(
         @Ctx() ctx: RequestContext,
-        @Args() args: ProductCategoriesQueryArgs,
+        @Args() args: CollectionsQueryArgs,
     ): Promise<PaginatedList<Translated<Collection>>> {
-        return this.productCategoryService.findAll(ctx, args.options || undefined);
+        return this.collectionService.findAll(ctx, args.options || undefined);
     }
 
     @Query()
-    async productCategory(
+    async collection(
         @Ctx() ctx: RequestContext,
-        @Args() args: ProductCategoryQueryArgs,
+        @Args() args: CollectionQueryArgs,
     ): Promise<Translated<Collection> | undefined> {
-        return this.productCategoryService.findOne(ctx, args.id);
+        return this.collectionService.findOne(ctx, args.id);
     }
 
     @Query()

+ 5 - 5
server/src/api/schema/admin-api/product-category.api.graphql → server/src/api/schema/admin-api/collection.api.graphql

@@ -1,17 +1,17 @@
 type Query {
-    productCategories(languageCode: LanguageCode, options: CollectionListOptions): CollectionList!
-    productCategory(id: ID!, languageCode: LanguageCode): Collection
+    collections(languageCode: LanguageCode, options: CollectionListOptions): CollectionList!
+    collection(id: ID!, languageCode: LanguageCode): Collection
 }
 
 type Mutation {
     "Create a new Collection"
-    createProductCategory(input: CreateCollectionInput!): Collection!
+    createCollection(input: CreateCollectionInput!): Collection!
 
     "Update an existing Collection"
-    updateProductCategory(input: UpdateCollectionInput!): Collection!
+    updateCollection(input: UpdateCollectionInput!): Collection!
 
     "Move a Collection to a different parent or index"
-    moveProductCategory(input: MoveCollectionInput!): Collection!
+    moveCollection(input: MoveCollectionInput!): Collection!
 }
 
 # generated by generateListOptions function

+ 2 - 2
server/src/api/schema/shop-api/shop.api.graphql

@@ -2,13 +2,13 @@ type Query {
     activeCustomer: Customer
     activeOrder: Order
     availableCountries: [Country!]!
+    collections(languageCode: LanguageCode, options: CollectionListOptions): CollectionList!
+    collection(id: ID!, languageCode: LanguageCode): Collection
     eligibleShippingMethods: [ShippingMethodQuote!]!
     me: CurrentUser
     nextOrderStates: [String!]!
     order(id: ID!): Order
     orderByCode(code: String!): Order
-    productCategories(languageCode: LanguageCode, options: CollectionListOptions): CollectionList!
-    productCategory(id: ID!, languageCode: LanguageCode): Collection
     product(id: ID!, languageCode: LanguageCode): Product
     products(languageCode: LanguageCode, options: ProductListOptions): ProductList!
     search(input: SearchInput!): SearchResponse!

+ 1 - 1
server/src/i18n/messages/en.json

@@ -1,7 +1,7 @@
 {
   "error": {
     "cannot-modify-role": "The role '{ roleCode }' cannot be modified",
-    "cannot-move-product-category-into-self": "Cannot move a ProductCategory into itself",
+    "cannot-move-collection-into-self": "Cannot move a Collection into itself",
     "cannot-transition-order-from-to": "Cannot transition Order from \"{ fromState }\" to \"{ toState }\"",
     "cannot-transition-to-shipping-when-order-is-empty": "Cannot transition Order to the \"ArrangingShipping\" state when it is empty",
     "cannot-transition-to-payment-without-customer": "Cannot transition Order to the \"ArrangingPayment\" state without Customer details",

+ 1 - 1
server/src/service/index.ts

@@ -11,7 +11,7 @@ export * from './services/global-settings.service';
 export * from './services/order.service';
 export * from './services/payment-method.service';
 export * from './services/product.service';
-export * from './services/product-category.service';
+export * from './services/collection.service';
 export * from './services/product-option.service';
 export * from './services/product-option-group.service';
 export * from './services/product-variant.service';

+ 2 - 2
server/src/service/service.module.ts

@@ -19,6 +19,7 @@ import { AdministratorService } from './services/administrator.service';
 import { AssetService } from './services/asset.service';
 import { AuthService } from './services/auth.service';
 import { ChannelService } from './services/channel.service';
+import { CollectionService } from './services/collection.service';
 import { CountryService } from './services/country.service';
 import { CustomerGroupService } from './services/customer-group.service';
 import { CustomerService } from './services/customer.service';
@@ -27,7 +28,6 @@ import { FacetService } from './services/facet.service';
 import { GlobalSettingsService } from './services/global-settings.service';
 import { OrderService } from './services/order.service';
 import { PaymentMethodService } from './services/payment-method.service';
-import { ProductCategoryService } from './services/product-category.service';
 import { ProductOptionGroupService } from './services/product-option-group.service';
 import { ProductOptionService } from './services/product-option.service';
 import { ProductVariantService } from './services/product-variant.service';
@@ -54,7 +54,7 @@ const exportedProviders = [
     GlobalSettingsService,
     OrderService,
     PaymentMethodService,
-    ProductCategoryService,
+    CollectionService,
     ProductOptionService,
     ProductOptionGroupService,
     ProductService,

+ 17 - 22
server/src/service/services/product-category.service.ts → server/src/service/services/collection.service.ts

@@ -1,11 +1,6 @@
 import { InjectConnection } from '@nestjs/typeorm';
 import { Connection } from 'typeorm';
 
-import {
-    CreateProductCategoryInput,
-    MoveProductCategoryInput,
-    UpdateProductCategoryInput,
-} from '../../../../shared/generated-types';
 import { ROOT_CATEGORY_NAME } from '../../../../shared/shared-constants';
 import { ID, PaginatedList } from '../../../../shared/shared-types';
 import { RequestContext } from '../../api/common/request-context';
@@ -25,7 +20,7 @@ import { translateDeep } from '../helpers/utils/translate-entity';
 import { ChannelService } from './channel.service';
 import { FacetValueService } from './facet-value.service';
 
-export class ProductCategoryService {
+export class CollectionService {
     private rootCategories: { [channelCode: string]: Collection } = {};
 
     constructor(
@@ -51,9 +46,9 @@ export class ProductCategoryService {
                 orderBy: { position: 'ASC' },
             })
             .getManyAndCount()
-            .then(async ([productCategories, totalItems]) => {
-                const items = productCategories.map(productCategory =>
-                    translateDeep(productCategory, ctx.languageCode, [
+            .then(async ([collections, totalItems]) => {
+                const items = collections.map(collection =>
+                    translateDeep(collection, ctx.languageCode, [
                         'facetValues',
                         'parent',
                         ['facetValues', 'facet'],
@@ -68,13 +63,13 @@ export class ProductCategoryService {
 
     async findOne(ctx: RequestContext, productId: ID): Promise<Translated<Collection> | undefined> {
         const relations = ['featuredAsset', 'assets', 'facetValues', 'channels', 'parent'];
-        const productCategory = await this.connection.getRepository(Collection).findOne(productId, {
+        const collection = await this.connection.getRepository(Collection).findOne(productId, {
             relations,
         });
-        if (!productCategory) {
+        if (!collection) {
             return;
         }
-        return translateDeep(productCategory, ctx.languageCode, ['facetValues', 'parent']);
+        return translateDeep(collection, ctx.languageCode, ['facetValues', 'parent']);
     }
 
     /**
@@ -98,7 +93,7 @@ export class ProductCategoryService {
     }
 
     /**
-     * Returns the descendants of a ProductCategory as a flat array.
+     * Returns the descendants of a Collection as a flat array.
      */
     async getDescendants(ctx: RequestContext, rootId: ID): Promise<Array<Translated<Collection>>> {
         const getChildren = async (id, _descendants: Collection[] = []) => {
@@ -154,8 +149,8 @@ export class ProductCategoryService {
             });
     }
 
-    async create(ctx: RequestContext, input: CreateProductCategoryInput): Promise<Translated<Collection>> {
-        const productCategory = await this.translatableSaver.create({
+    async create(ctx: RequestContext, input: any): Promise<Translated<Collection>> {
+        const collection = await this.translatableSaver.create({
             input,
             entityType: Collection,
             translationType: CollectionTranslation,
@@ -172,11 +167,11 @@ export class ProductCategoryService {
                 await this.assetUpdater.updateEntityAssets(category, input);
             },
         });
-        return assertFound(this.findOne(ctx, productCategory.id));
+        return assertFound(this.findOne(ctx, collection.id));
     }
 
-    async update(ctx: RequestContext, input: UpdateProductCategoryInput): Promise<Translated<Collection>> {
-        const productCategory = await this.translatableSaver.update({
+    async update(ctx: RequestContext, input: any): Promise<Translated<Collection>> {
+        const collection = await this.translatableSaver.update({
             input,
             entityType: Collection,
             translationType: CollectionTranslation,
@@ -187,10 +182,10 @@ export class ProductCategoryService {
                 await this.assetUpdater.updateEntityAssets(category, input);
             },
         });
-        return assertFound(this.findOne(ctx, productCategory.id));
+        return assertFound(this.findOne(ctx, collection.id));
     }
 
-    async move(ctx: RequestContext, input: MoveProductCategoryInput): Promise<Translated<Collection>> {
+    async move(ctx: RequestContext, input: any): Promise<Translated<Collection>> {
         const target = await getEntityOrThrow(this.connection, Collection, input.categoryId, {
             relations: ['parent'],
         });
@@ -200,7 +195,7 @@ export class ProductCategoryService {
             idsAreEqual(input.parentId, target.id) ||
             descendants.some(cat => idsAreEqual(input.parentId, cat.id))
         ) {
-            throw new IllegalOperationError(`error.cannot-move-product-category-into-self`);
+            throw new IllegalOperationError(`error.cannot-move-collection-into-self`);
         }
 
         const siblings = await this.connection
@@ -288,7 +283,7 @@ export class ProductCategoryService {
             new CollectionTranslation({
                 languageCode: DEFAULT_LANGUAGE_CODE,
                 name: ROOT_CATEGORY_NAME,
-                description: 'The root of the ProductCategory tree.',
+                description: 'The root of the Collection tree.',
             }),
         );
 

+ 3 - 3
server/src/service/services/product.service.ts

@@ -26,8 +26,8 @@ import { getEntityOrThrow } from '../helpers/utils/get-entity-or-throw';
 import { translateDeep } from '../helpers/utils/translate-entity';
 
 import { ChannelService } from './channel.service';
+import { CollectionService } from './collection.service';
 import { FacetValueService } from './facet-value.service';
-import { ProductCategoryService } from './product-category.service';
 import { ProductVariantService } from './product-variant.service';
 import { TaxRateService } from './tax-rate.service';
 
@@ -47,7 +47,7 @@ export class ProductService {
         private channelService: ChannelService,
         private assetUpdater: AssetUpdater,
         private productVariantService: ProductVariantService,
-        private productCategoryService: ProductCategoryService,
+        private collectionService: CollectionService,
         private facetValueService: FacetValueService,
         private taxRateService: TaxRateService,
         private listQueryBuilder: ListQueryBuilder,
@@ -181,7 +181,7 @@ export class ProductService {
     }
 
     private async getProductIdsInCategory(categoryId: ID): Promise<ID[]> {
-        const facetValueIds = await this.productCategoryService.getFacetValueIdsForCategory(categoryId);
+        const facetValueIds = await this.collectionService.getFacetValueIdsForCategory(categoryId);
         const qb = this.connection
             .getRepository(Product)
             .createQueryBuilder('product')

+ 29 - 29
shared/generated-shop-types.ts

@@ -1,5 +1,5 @@
 // tslint:disable
-// Generated in 2019-03-04T11:06:07+01:00
+// Generated in 2019-03-04T11:47:05+01:00
 export type Maybe<T> = T | null;
 
 export interface OrderListOptions {
@@ -750,6 +750,10 @@ export interface Query {
 
     availableCountries: Country[];
 
+    collections: CollectionList;
+
+    collection?: Maybe<Collection>;
+
     eligibleShippingMethods: ShippingMethodQuote[];
 
     me?: Maybe<CurrentUser>;
@@ -760,10 +764,6 @@ export interface Query {
 
     orderByCode?: Maybe<Order>;
 
-    productCategories: CollectionList;
-
-    productCategory?: Maybe<Collection>;
-
     product?: Maybe<Product>;
 
     products: ProductList;
@@ -1297,22 +1297,6 @@ export interface Channel extends Node {
     pricesIncludeTax: boolean;
 }
 
-export interface ShippingMethodQuote {
-    id: string;
-
-    price: number;
-
-    description: string;
-}
-
-export interface CurrentUser {
-    id: string;
-
-    identifier: string;
-
-    channelTokens: string[];
-}
-
 export interface CollectionList extends PaginatedList {
     items: Collection[];
 
@@ -1367,6 +1351,22 @@ export interface CollectionTranslation {
     description: string;
 }
 
+export interface ShippingMethodQuote {
+    id: string;
+
+    price: number;
+
+    description: string;
+}
+
+export interface CurrentUser {
+    id: string;
+
+    identifier: string;
+
+    channelTokens: string[];
+}
+
 export interface Product extends Node {
     id: string;
 
@@ -1685,22 +1685,22 @@ export interface TaxRateList extends PaginatedList {
 // Arguments
 // ====================================================
 
-export interface OrderQueryArgs {
-    id: string;
-}
-export interface OrderByCodeQueryArgs {
-    code: string;
-}
-export interface ProductCategoriesQueryArgs {
+export interface CollectionsQueryArgs {
     languageCode?: Maybe<LanguageCode>;
 
     options?: Maybe<CollectionListOptions>;
 }
-export interface ProductCategoryQueryArgs {
+export interface CollectionQueryArgs {
     id: string;
 
     languageCode?: Maybe<LanguageCode>;
 }
+export interface OrderQueryArgs {
+    id: string;
+}
+export interface OrderByCodeQueryArgs {
+    code: string;
+}
 export interface ProductQueryArgs {
     id: string;
 

+ 277 - 277
shared/generated-types.ts

@@ -1,5 +1,5 @@
 // tslint:disable
-// Generated in 2019-03-04T11:06:09+01:00
+// Generated in 2019-03-04T11:47:06+01:00
 export type Maybe<T> = T | null;
 
 
@@ -130,6 +130,47 @@ export interface NumberRange {
   end: number;
 }
 
+export interface CollectionListOptions {
+  
+  skip?: Maybe<number>;
+  
+  take?: Maybe<number>;
+  
+  sort?: Maybe<CollectionSortParameter>;
+  
+  filter?: Maybe<CollectionFilterParameter>;
+}
+
+export interface CollectionSortParameter {
+  
+  id?: Maybe<SortOrder>;
+  
+  createdAt?: Maybe<SortOrder>;
+  
+  updatedAt?: Maybe<SortOrder>;
+  
+  name?: Maybe<SortOrder>;
+  
+  position?: Maybe<SortOrder>;
+  
+  description?: Maybe<SortOrder>;
+}
+
+export interface CollectionFilterParameter {
+  
+  createdAt?: Maybe<DateOperators>;
+  
+  updatedAt?: Maybe<DateOperators>;
+  
+  languageCode?: Maybe<StringOperators>;
+  
+  name?: Maybe<StringOperators>;
+  
+  position?: Maybe<NumberOperators>;
+  
+  description?: Maybe<StringOperators>;
+}
+
 export interface CountryListOptions {
   
   skip?: Maybe<number>;
@@ -342,47 +383,6 @@ export interface PaymentMethodFilterParameter {
   enabled?: Maybe<BooleanOperators>;
 }
 
-export interface CollectionListOptions {
-  
-  skip?: Maybe<number>;
-  
-  take?: Maybe<number>;
-  
-  sort?: Maybe<CollectionSortParameter>;
-  
-  filter?: Maybe<CollectionFilterParameter>;
-}
-
-export interface CollectionSortParameter {
-  
-  id?: Maybe<SortOrder>;
-  
-  createdAt?: Maybe<SortOrder>;
-  
-  updatedAt?: Maybe<SortOrder>;
-  
-  name?: Maybe<SortOrder>;
-  
-  position?: Maybe<SortOrder>;
-  
-  description?: Maybe<SortOrder>;
-}
-
-export interface CollectionFilterParameter {
-  
-  createdAt?: Maybe<DateOperators>;
-  
-  updatedAt?: Maybe<DateOperators>;
-  
-  languageCode?: Maybe<StringOperators>;
-  
-  name?: Maybe<StringOperators>;
-  
-  position?: Maybe<NumberOperators>;
-  
-  description?: Maybe<StringOperators>;
-}
-
 export interface SearchInput {
   
   term?: Maybe<string>;
@@ -657,6 +657,60 @@ export interface UpdateChannelInput {
   defaultShippingZoneId?: Maybe<string>;
 }
 
+export interface CreateCollectionInput {
+  
+  featuredAssetId?: Maybe<string>;
+  
+  assetIds?: Maybe<string[]>;
+  
+  parentId?: Maybe<string>;
+  
+  facetValueIds?: Maybe<string[]>;
+  
+  translations: CollectionTranslationInput[];
+  
+  customFields?: Maybe<Json>;
+}
+
+export interface CollectionTranslationInput {
+  
+  id?: Maybe<string>;
+  
+  languageCode: LanguageCode;
+  
+  name?: Maybe<string>;
+  
+  description?: Maybe<string>;
+  
+  customFields?: Maybe<Json>;
+}
+
+export interface UpdateCollectionInput {
+  
+  id: string;
+  
+  featuredAssetId?: Maybe<string>;
+  
+  parentId?: Maybe<string>;
+  
+  assetIds?: Maybe<string[]>;
+  
+  facetValueIds?: Maybe<string[]>;
+  
+  translations: CollectionTranslationInput[];
+  
+  customFields?: Maybe<Json>;
+}
+
+export interface MoveCollectionInput {
+  
+  categoryId: string;
+  
+  parentId: string;
+  
+  index: number;
+}
+
 export interface CreateCountryInput {
   
   code: string;
@@ -886,60 +940,6 @@ export interface ConfigArgInput {
   value: string;
 }
 
-export interface CreateCollectionInput {
-  
-  featuredAssetId?: Maybe<string>;
-  
-  assetIds?: Maybe<string[]>;
-  
-  parentId?: Maybe<string>;
-  
-  facetValueIds?: Maybe<string[]>;
-  
-  translations: CollectionTranslationInput[];
-  
-  customFields?: Maybe<Json>;
-}
-
-export interface CollectionTranslationInput {
-  
-  id?: Maybe<string>;
-  
-  languageCode: LanguageCode;
-  
-  name?: Maybe<string>;
-  
-  description?: Maybe<string>;
-  
-  customFields?: Maybe<Json>;
-}
-
-export interface UpdateCollectionInput {
-  
-  id: string;
-  
-  featuredAssetId?: Maybe<string>;
-  
-  parentId?: Maybe<string>;
-  
-  assetIds?: Maybe<string[]>;
-  
-  facetValueIds?: Maybe<string[]>;
-  
-  translations: CollectionTranslationInput[];
-  
-  customFields?: Maybe<Json>;
-}
-
-export interface MoveCollectionInput {
-  
-  categoryId: string;
-  
-  parentId: string;
-  
-  index: number;
-}
-
 export interface CreateProductOptionGroupInput {
   
   code: string;
@@ -2581,7 +2581,7 @@ export namespace CreateAssets {
   export type CreateAssets = Asset.Fragment
 }
 
-export namespace GetProductCategoryList {
+export namespace GetCollectionList {
   export type Variables = {
     options?: Maybe<CollectionListOptions>;
     languageCode?: Maybe<LanguageCode>;
@@ -2590,10 +2590,10 @@ export namespace GetProductCategoryList {
   export type Query = {
     __typename?: "Query";
     
-    productCategories: ProductCategories;
+    collections: Collections;
   }
 
-  export type ProductCategories = {
+  export type Collections = {
     __typename?: "CollectionList";
     
     items: Items[];
@@ -2646,7 +2646,7 @@ export namespace GetProductCategoryList {
   } 
 }
 
-export namespace GetProductCategory {
+export namespace GetCollection {
   export type Variables = {
     id: string;
     languageCode?: Maybe<LanguageCode>;
@@ -2655,13 +2655,13 @@ export namespace GetProductCategory {
   export type Query = {
     __typename?: "Query";
     
-    productCategory: Maybe<ProductCategory>;
+    collection: Maybe<Collection>;
   }
 
-  export type ProductCategory = Collection.Fragment
+  export type Collection = Collection.Fragment
 }
 
-export namespace CreateProductCategory {
+export namespace CreateCollection {
   export type Variables = {
     input: CreateCollectionInput;
   }
@@ -2669,13 +2669,13 @@ export namespace CreateProductCategory {
   export type Mutation = {
     __typename?: "Mutation";
     
-    createProductCategory: CreateProductCategory;
+    createCollection: CreateCollection;
   }
 
-  export type CreateProductCategory = Collection.Fragment
+  export type CreateCollection = Collection.Fragment
 }
 
-export namespace UpdateProductCategory {
+export namespace UpdateCollection {
   export type Variables = {
     input: UpdateCollectionInput;
   }
@@ -2683,13 +2683,13 @@ export namespace UpdateProductCategory {
   export type Mutation = {
     __typename?: "Mutation";
     
-    updateProductCategory: UpdateProductCategory;
+    updateCollection: UpdateCollection;
   }
 
-  export type UpdateProductCategory = Collection.Fragment
+  export type UpdateCollection = Collection.Fragment
 }
 
-export namespace MoveProductCategory {
+export namespace MoveCollection {
   export type Variables = {
     input: MoveCollectionInput;
   }
@@ -2697,10 +2697,10 @@ export namespace MoveProductCategory {
   export type Mutation = {
     __typename?: "Mutation";
     
-    moveProductCategory: MoveProductCategory;
+    moveCollection: MoveCollection;
   }
 
-  export type MoveProductCategory = Collection.Fragment
+  export type MoveCollection = Collection.Fragment
 }
 
 export namespace SearchProducts {
@@ -4445,6 +4445,10 @@ export interface Query {
   
   activeChannel: Channel;
   
+  collections: CollectionList;
+  
+  collection?: Maybe<Collection>;
+  
   config: Config;
   
   countries: CountryList;
@@ -4473,10 +4477,6 @@ export interface Query {
   
   paymentMethod?: Maybe<PaymentMethod>;
   
-  productCategories: CollectionList;
-  
-  productCategory?: Maybe<Collection>;
-  
   productOptionGroups: ProductOptionGroup[];
   
   productOptionGroup?: Maybe<ProductOptionGroup>;
@@ -4695,6 +4695,138 @@ export interface CurrentUser {
 }
 
 
+export interface CollectionList extends PaginatedList {
+  
+  items: Collection[];
+  
+  totalItems: number;
+}
+
+
+export interface Collection extends Node {
+  
+  id: string;
+  
+  createdAt: DateTime;
+  
+  updatedAt: DateTime;
+  
+  languageCode?: Maybe<LanguageCode>;
+  
+  name: string;
+  
+  position: number;
+  
+  description: string;
+  
+  featuredAsset?: Maybe<Asset>;
+  
+  assets: Asset[];
+  
+  parent: Collection;
+  
+  children?: Maybe<Collection[]>;
+  
+  facetValues: FacetValue[];
+  
+  descendantFacetValues: FacetValue[];
+  
+  ancestorFacetValues: FacetValue[];
+  
+  translations: CollectionTranslation[];
+  
+  customFields?: Maybe<Json>;
+}
+
+
+export interface FacetValue extends Node {
+  
+  id: string;
+  
+  createdAt: DateTime;
+  
+  updatedAt: DateTime;
+  
+  languageCode: LanguageCode;
+  
+  facet: Facet;
+  
+  name: string;
+  
+  code: string;
+  
+  translations: FacetValueTranslation[];
+  
+  customFields?: Maybe<Json>;
+}
+
+
+export interface Facet extends Node {
+  
+  id: string;
+  
+  createdAt: DateTime;
+  
+  updatedAt: DateTime;
+  
+  languageCode: LanguageCode;
+  
+  name: string;
+  
+  code: string;
+  
+  values: FacetValue[];
+  
+  translations: FacetTranslation[];
+  
+  customFields?: Maybe<Json>;
+}
+
+
+export interface FacetTranslation {
+  
+  id: string;
+  
+  createdAt: DateTime;
+  
+  updatedAt: DateTime;
+  
+  languageCode: LanguageCode;
+  
+  name: string;
+}
+
+
+export interface FacetValueTranslation {
+  
+  id: string;
+  
+  createdAt: DateTime;
+  
+  updatedAt: DateTime;
+  
+  languageCode: LanguageCode;
+  
+  name: string;
+}
+
+
+export interface CollectionTranslation {
+  
+  id: string;
+  
+  createdAt: DateTime;
+  
+  updatedAt: DateTime;
+  
+  languageCode: LanguageCode;
+  
+  name: string;
+  
+  description: string;
+}
+
+
 export interface Config {
   
   customFields?: Maybe<Json>;
@@ -5001,78 +5133,6 @@ export interface ProductOptionTranslation {
 }
 
 
-export interface FacetValue extends Node {
-  
-  id: string;
-  
-  createdAt: DateTime;
-  
-  updatedAt: DateTime;
-  
-  languageCode: LanguageCode;
-  
-  facet: Facet;
-  
-  name: string;
-  
-  code: string;
-  
-  translations: FacetValueTranslation[];
-  
-  customFields?: Maybe<Json>;
-}
-
-
-export interface Facet extends Node {
-  
-  id: string;
-  
-  createdAt: DateTime;
-  
-  updatedAt: DateTime;
-  
-  languageCode: LanguageCode;
-  
-  name: string;
-  
-  code: string;
-  
-  values: FacetValue[];
-  
-  translations: FacetTranslation[];
-  
-  customFields?: Maybe<Json>;
-}
-
-
-export interface FacetTranslation {
-  
-  id: string;
-  
-  createdAt: DateTime;
-  
-  updatedAt: DateTime;
-  
-  languageCode: LanguageCode;
-  
-  name: string;
-}
-
-
-export interface FacetValueTranslation {
-  
-  id: string;
-  
-  createdAt: DateTime;
-  
-  updatedAt: DateTime;
-  
-  languageCode: LanguageCode;
-  
-  name: string;
-}
-
-
 export interface ProductVariantTranslation {
   
   id: string;
@@ -5231,66 +5291,6 @@ export interface PaymentMethod extends Node {
 }
 
 
-export interface CollectionList extends PaginatedList {
-  
-  items: Collection[];
-  
-  totalItems: number;
-}
-
-
-export interface Collection extends Node {
-  
-  id: string;
-  
-  createdAt: DateTime;
-  
-  updatedAt: DateTime;
-  
-  languageCode?: Maybe<LanguageCode>;
-  
-  name: string;
-  
-  position: number;
-  
-  description: string;
-  
-  featuredAsset?: Maybe<Asset>;
-  
-  assets: Asset[];
-  
-  parent: Collection;
-  
-  children?: Maybe<Collection[]>;
-  
-  facetValues: FacetValue[];
-  
-  descendantFacetValues: FacetValue[];
-  
-  ancestorFacetValues: FacetValue[];
-  
-  translations: CollectionTranslation[];
-  
-  customFields?: Maybe<Json>;
-}
-
-
-export interface CollectionTranslation {
-  
-  id: string;
-  
-  createdAt: DateTime;
-  
-  updatedAt: DateTime;
-  
-  languageCode: LanguageCode;
-  
-  name: string;
-  
-  description: string;
-}
-
-
 export interface ProductOptionGroup extends Node {
   
   id: string;
@@ -5524,6 +5524,12 @@ export interface Mutation {
   createChannel: Channel;
   /** Update an existing Channel */
   updateChannel: Channel;
+  /** Create a new Collection */
+  createCollection: Collection;
+  /** Update an existing Collection */
+  updateCollection: Collection;
+  /** Move a Collection to a different parent or index */
+  moveCollection: Collection;
   /** Create a new Country */
   createCountry: Country;
   /** Update an existing Country */
@@ -5568,12 +5574,6 @@ export interface Mutation {
   importProducts?: Maybe<ImportInfo>;
   /** Update an existing PaymentMethod */
   updatePaymentMethod: PaymentMethod;
-  /** Create a new Collection */
-  createProductCategory: Collection;
-  /** Update an existing Collection */
-  updateProductCategory: Collection;
-  /** Move a Collection to a different parent or index */
-  moveProductCategory: Collection;
   /** Create a new ProductOptionGroup */
   createProductOptionGroup: ProductOptionGroup;
   /** Update an existing ProductOptionGroup */
@@ -5708,6 +5708,18 @@ export interface ChannelQueryArgs {
   
   id: string;
 }
+export interface CollectionsQueryArgs {
+  
+  languageCode?: Maybe<LanguageCode>;
+  
+  options?: Maybe<CollectionListOptions>;
+}
+export interface CollectionQueryArgs {
+  
+  id: string;
+  
+  languageCode?: Maybe<LanguageCode>;
+}
 export interface CountriesQueryArgs {
   
   options?: Maybe<CountryListOptions>;
@@ -5756,18 +5768,6 @@ export interface PaymentMethodQueryArgs {
   
   id: string;
 }
-export interface ProductCategoriesQueryArgs {
-  
-  languageCode?: Maybe<LanguageCode>;
-  
-  options?: Maybe<CollectionListOptions>;
-}
-export interface ProductCategoryQueryArgs {
-  
-  id: string;
-  
-  languageCode?: Maybe<LanguageCode>;
-}
 export interface ProductOptionGroupsQueryArgs {
   
   languageCode?: Maybe<LanguageCode>;
@@ -5874,6 +5874,18 @@ export interface UpdateChannelMutationArgs {
   
   input: UpdateChannelInput;
 }
+export interface CreateCollectionMutationArgs {
+  
+  input: CreateCollectionInput;
+}
+export interface UpdateCollectionMutationArgs {
+  
+  input: UpdateCollectionInput;
+}
+export interface MoveCollectionMutationArgs {
+  
+  input: MoveCollectionInput;
+}
 export interface CreateCountryMutationArgs {
   
   input: CreateCountryInput;
@@ -5974,18 +5986,6 @@ export interface UpdatePaymentMethodMutationArgs {
   
   input: UpdatePaymentMethodInput;
 }
-export interface CreateProductCategoryMutationArgs {
-  
-  input: CreateCollectionInput;
-}
-export interface UpdateProductCategoryMutationArgs {
-  
-  input: UpdateCollectionInput;
-}
-export interface MoveProductCategoryMutationArgs {
-  
-  input: MoveCollectionInput;
-}
 export interface CreateProductOptionGroupMutationArgs {
   
   input: CreateProductOptionGroupInput;

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott