Просмотр исходного кода

refactor: Rename ProductCategory to Collection

Relates to #71. The entity itself has been renamed, but the resolvers have yet to be renamed.
Michael Bromley 6 лет назад
Родитель
Сommit
da21d54ade
30 измененных файлов с 287 добавлено и 297 удалено
  1. 9 9
      admin-ui/src/app/catalog/components/product-category-detail/product-category-detail.component.ts
  2. 2 4
      admin-ui/src/app/catalog/components/product-category-list/product-category-list.component.ts
  3. 7 7
      admin-ui/src/app/catalog/components/product-category-tree/product-category-tree-node.component.ts
  4. 6 6
      admin-ui/src/app/catalog/components/product-category-tree/product-category-tree.component.ts
  5. 3 3
      admin-ui/src/app/catalog/providers/routing/product-category-resolver.ts
  6. 1 1
      admin-ui/src/app/data/data.module.ts
  7. 9 9
      admin-ui/src/app/data/definitions/product-definitions.ts
  8. 6 6
      admin-ui/src/app/data/providers/product-data.service.ts
  9. 0 0
      schema-admin.json
  10. 0 0
      schema-shop.json
  11. 32 32
      schema.json
  12. 6 6
      server/src/api/resolvers/admin/product-category.resolver.ts
  13. 4 4
      server/src/api/resolvers/entity/product-category-entity.resolver.ts
  14. 3 3
      server/src/api/resolvers/shop/shop-products.resolver.ts
  15. 15 15
      server/src/api/schema/admin-api/product-category.api.graphql
  16. 3 3
      server/src/api/schema/shop-api/shop.api.graphql
  17. 7 7
      server/src/api/schema/type/collection.type.graphql
  18. 1 1
      server/src/config/default-config.ts
  19. 28 0
      server/src/entity/collection/collection-translation.entity.ts
  20. 11 11
      server/src/entity/collection/collection.entity.ts
  21. 4 4
      server/src/entity/custom-entity-fields.ts
  22. 4 4
      server/src/entity/entities.ts
  23. 2 2
      server/src/entity/index.ts
  24. 0 29
      server/src/entity/product-category/product-category-translation.entity.ts
  25. 14 15
      server/src/service/helpers/utils/translate-entity.spec.ts
  26. 2 2
      server/src/service/services/facet-value.service.ts
  27. 39 45
      server/src/service/services/product-category.service.ts
  28. 21 21
      shared/generated-shop-types.ts
  29. 47 47
      shared/generated-types.ts
  30. 1 1
      shared/shared-types.ts

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

@@ -13,12 +13,12 @@ import {
     withLatestFrom,
 } from 'rxjs/operators';
 import {
-    CreateProductCategoryInput,
+    Collection,
+    CreateCollectionInput,
     FacetValue,
     FacetWithValues,
     LanguageCode,
-    ProductCategory,
-    UpdateProductCategoryInput,
+    UpdateCollectionInput,
 } from 'shared/generated-types';
 import { CustomFieldConfig } from 'shared/shared-types';
 import { unique } from 'shared/unique';
@@ -39,7 +39,7 @@ import { ApplyFacetDialogComponent } from '../apply-facet-dialog/apply-facet-dia
     styleUrls: ['./product-category-detail.component.scss'],
     changeDetection: ChangeDetectionStrategy.OnPush,
 })
-export class ProductCategoryDetailComponent extends BaseDetailComponent<ProductCategory.Fragment>
+export class ProductCategoryDetailComponent extends BaseDetailComponent<Collection.Fragment>
     implements OnInit, OnDestroy {
     customFields: CustomFieldConfig[];
     detailForm: FormGroup;
@@ -58,7 +58,7 @@ export class ProductCategoryDetailComponent extends BaseDetailComponent<ProductC
         private modalService: ModalService,
     ) {
         super(route, router, serverConfigService);
-        this.customFields = this.getCustomFieldConfig('ProductCategory');
+        this.customFields = this.getCustomFieldConfig('Collection');
         this.detailForm = this.formBuilder.group({
             name: ['', Validators.required],
             description: '',
@@ -174,7 +174,7 @@ export class ProductCategoryDetailComponent extends BaseDetailComponent<ProductC
                         category,
                         this.detailForm,
                         languageCode,
-                    ) as UpdateProductCategoryInput;
+                    ) as UpdateCollectionInput;
                     return this.dataService.product.updateProductCategory(input);
                 }),
             )
@@ -197,7 +197,7 @@ export class ProductCategoryDetailComponent extends BaseDetailComponent<ProductC
     /**
      * Sets the values of the form on changes to the category or current language.
      */
-    protected setFormValues(category: ProductCategory.Fragment, languageCode: LanguageCode) {
+    protected setFormValues(category: Collection.Fragment, languageCode: LanguageCode) {
         const currentTranslation = category.translations.find(t => t.languageCode === languageCode);
 
         this.detailForm.patchValue({
@@ -228,10 +228,10 @@ export class ProductCategoryDetailComponent extends BaseDetailComponent<ProductC
      * can then be persisted to the API.
      */
     private getUpdatedCategory(
-        category: ProductCategory.Fragment,
+        category: Collection.Fragment,
         form: FormGroup,
         languageCode: LanguageCode,
-    ): CreateProductCategoryInput | UpdateProductCategoryInput {
+    ): CreateCollectionInput | UpdateCollectionInput {
         const updatedCategory = createUpdatedTranslatable({
             translatable: category,
             updatedFields: form.value,

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

@@ -1,8 +1,6 @@
-import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
+import { ChangeDetectionStrategy, Component } from '@angular/core';
 import { ActivatedRoute, Router } from '@angular/router';
-import { merge, Observable, Subject } from 'rxjs';
-import { debounceTime, scan, startWith, switchMap, tap } from 'rxjs/operators';
-import { GetProductCategoryList, MoveProductCategoryInput } from 'shared/generated-types';
+import { GetProductCategoryList } from 'shared/generated-types';
 
 import { BaseListComponent } from '../../../common/base-list.component';
 import { _ } from '../../../core/providers/i18n/mark-for-extraction';

+ 7 - 7
admin-ui/src/app/catalog/components/product-category-tree/product-category-tree-node.component.ts

@@ -1,6 +1,6 @@
 import { CdkDragDrop } from '@angular/cdk/drag-drop';
 import { ChangeDetectionStrategy, Component, Input, OnInit, Optional, SkipSelf } from '@angular/core';
-import { ProductCategory } from 'shared/generated-types';
+import { Collection } from 'shared/generated-types';
 
 import { RootNode, TreeNode } from './array-to-tree';
 import { ProductCategoryTreeComponent } from './product-category-tree.component';
@@ -14,7 +14,7 @@ import { ProductCategoryTreeComponent } from './product-category-tree.component'
 export class ProductCategoryTreeNodeComponent implements OnInit {
     depth = 0;
     parentName: string;
-    @Input() categoryTree: TreeNode<ProductCategory.Fragment>;
+    @Input() categoryTree: TreeNode<Collection.Fragment>;
 
     constructor(
         @SkipSelf() @Optional() private parent: ProductCategoryTreeNodeComponent,
@@ -29,7 +29,7 @@ export class ProductCategoryTreeNodeComponent implements OnInit {
         this.parentName = this.categoryTree.name || '<root>';
     }
 
-    getMoveListItems(category: ProductCategory.Fragment): Array<{ path: string; id: string }> {
+    getMoveListItems(category: Collection.Fragment): Array<{ path: string; id: string }> {
         const visit = (
             node: TreeNode<any>,
             parentPath: string[],
@@ -47,7 +47,7 @@ export class ProductCategoryTreeNodeComponent implements OnInit {
         return visit(this.root.categoryTree, [], []);
     }
 
-    move(category: ProductCategory.Fragment, parentId: string) {
+    move(category: Collection.Fragment, parentId: string) {
         this.root.onMove({
             index: 0,
             parentId,
@@ -55,7 +55,7 @@ export class ProductCategoryTreeNodeComponent implements OnInit {
         });
     }
 
-    moveUp(category: ProductCategory.Fragment, currentIndex: number) {
+    moveUp(category: Collection.Fragment, currentIndex: number) {
         this.root.onMove({
             index: currentIndex - 1,
             parentId: category.parent.id,
@@ -63,7 +63,7 @@ export class ProductCategoryTreeNodeComponent implements OnInit {
         });
     }
 
-    moveDown(category: ProductCategory.Fragment, currentIndex: number) {
+    moveDown(category: Collection.Fragment, currentIndex: number) {
         this.root.onMove({
             index: currentIndex + 1,
             parentId: category.parent.id,
@@ -71,7 +71,7 @@ export class ProductCategoryTreeNodeComponent implements OnInit {
         });
     }
 
-    drop(event: CdkDragDrop<ProductCategory.Fragment | RootNode<ProductCategory.Fragment>>) {
+    drop(event: CdkDragDrop<Collection.Fragment | RootNode<Collection.Fragment>>) {
         this.root.onDrop(event);
     }
 }

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

@@ -8,7 +8,7 @@ import {
     Output,
     SimpleChanges,
 } from '@angular/core';
-import { ProductCategory } from 'shared/generated-types';
+import { Collection } from 'shared/generated-types';
 
 import { arrayToTree, HasParent, RootNode } from './array-to-tree';
 
@@ -21,9 +21,9 @@ export type RearrangeEvent = { categoryId: string; parentId: string; index: numb
     changeDetection: ChangeDetectionStrategy.OnPush,
 })
 export class ProductCategoryTreeComponent implements OnChanges {
-    @Input() productCategories: ProductCategory.Fragment[];
+    @Input() productCategories: Collection.Fragment[];
     @Output() rearrange = new EventEmitter<RearrangeEvent>();
-    categoryTree: RootNode<ProductCategory.Fragment>;
+    categoryTree: RootNode<Collection.Fragment>;
 
     ngOnChanges(changes: SimpleChanges) {
         if ('productCategories' in changes && this.productCategories) {
@@ -31,12 +31,12 @@ export class ProductCategoryTreeComponent implements OnChanges {
         }
     }
 
-    onDrop(event: CdkDragDrop<ProductCategory.Fragment | RootNode<ProductCategory.Fragment>>) {
-        const item = event.item.data as ProductCategory.Fragment;
+    onDrop(event: CdkDragDrop<Collection.Fragment | RootNode<Collection.Fragment>>) {
+        const item = event.item.data as Collection.Fragment;
         const newParent = event.container.data;
         const newParentId = newParent.id;
         if (newParentId == null) {
-            throw new Error(`Could not determine the ID of the root ProductCategory`);
+            throw new Error(`Could not determine the ID of the root Collection`);
         }
         this.rearrange.emit({
             categoryId: item.id,

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

@@ -1,16 +1,16 @@
 import { Injectable } from '@angular/core';
-import { ProductCategory, ProductWithVariants } from 'shared/generated-types';
+import { Collection, ProductWithVariants } from 'shared/generated-types';
 
 import { BaseEntityResolver } from '../../../common/base-entity-resolver';
 import { getDefaultLanguage } from '../../../common/utilities/get-default-language';
 import { DataService } from '../../../data/providers/data.service';
 
 @Injectable()
-export class ProductCategoryResolver extends BaseEntityResolver<ProductCategory.Fragment> {
+export class ProductCategoryResolver extends BaseEntityResolver<Collection.Fragment> {
     constructor(private dataService: DataService) {
         super(
             {
-                __typename: 'ProductCategory' as 'ProductCategory',
+                __typename: 'Collection' as 'Collection',
                 id: '',
                 languageCode: getDefaultLanguage(),
                 name: '',

+ 1 - 1
admin-ui/src/app/data/data.module.ts

@@ -40,7 +40,7 @@ export function createApollo(
 ): ApolloClientOptions<any> {
     const { apiHost, apiPort, adminApiPath } = getAppConfig();
     const host = apiHost === 'auto' ? `${location.protocol}//${location.hostname}` : apiHost;
-    const port = apiPort === 'auto' ? (location.port === '' ? '' : `:${location.port}`) : apiPort;
+    const port = apiPort === 'auto' ? (location.port === '' ? '' : `:${location.port}`) : `:${apiPort}`;
     return {
         link: ApolloLink.from([
             stateLink,

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

@@ -286,7 +286,7 @@ export const CREATE_ASSETS = gql`
 `;
 
 export const PRODUCT_CATEGORY_FRAGMENT = gql`
-    fragment ProductCategory on ProductCategory {
+    fragment Collection on Collection {
         id
         name
         description
@@ -321,7 +321,7 @@ export const PRODUCT_CATEGORY_FRAGMENT = gql`
 `;
 
 export const GET_PRODUCT_CATEGORY_LIST = gql`
-    query GetProductCategoryList($options: ProductCategoryListOptions, $languageCode: LanguageCode) {
+    query GetProductCategoryList($options: CollectionListOptions, $languageCode: LanguageCode) {
         productCategories(languageCode: $languageCode, options: $options) {
             items {
                 id
@@ -352,34 +352,34 @@ export const GET_PRODUCT_CATEGORY_LIST = gql`
 export const GET_PRODUCT_CATEGORY = gql`
     query GetProductCategory($id: ID!, $languageCode: LanguageCode) {
         productCategory(id: $id, languageCode: $languageCode) {
-            ...ProductCategory
+            ...Collection
         }
     }
     ${PRODUCT_CATEGORY_FRAGMENT}
 `;
 
 export const CREATE_PRODUCT_CATEGORY = gql`
-    mutation CreateProductCategory($input: CreateProductCategoryInput!) {
+    mutation CreateProductCategory($input: CreateCollectionInput!) {
         createProductCategory(input: $input) {
-            ...ProductCategory
+            ...Collection
         }
     }
     ${PRODUCT_CATEGORY_FRAGMENT}
 `;
 
 export const UPDATE_PRODUCT_CATEGORY = gql`
-    mutation UpdateProductCategory($input: UpdateProductCategoryInput!) {
+    mutation UpdateProductCategory($input: UpdateCollectionInput!) {
         updateProductCategory(input: $input) {
-            ...ProductCategory
+            ...Collection
         }
     }
     ${PRODUCT_CATEGORY_FRAGMENT}
 `;
 
 export const MOVE_PRODUCT_CATEGORY = gql`
-    mutation MoveProductCategory($input: MoveProductCategoryInput!) {
+    mutation MoveProductCategory($input: MoveCollectionInput!) {
         moveProductCategory(input: $input) {
-            ...ProductCategory
+            ...Collection
         }
     }
     ${PRODUCT_CATEGORY_FRAGMENT}

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

@@ -3,9 +3,9 @@ import { bufferCount, concatMap } from 'rxjs/operators';
 import {
     AddOptionGroupToProduct,
     CreateAssets,
+    CreateCollectionInput,
     CreateProduct,
     CreateProductCategory,
-    CreateProductCategoryInput,
     CreateProductInput,
     CreateProductOptionGroup,
     CreateProductOptionGroupInput,
@@ -17,13 +17,13 @@ import {
     GetProductList,
     GetProductOptionGroups,
     GetProductWithVariants,
+    MoveCollectionInput,
     MoveProductCategory,
-    MoveProductCategoryInput,
     RemoveOptionGroupFromProduct,
     SearchProducts,
+    UpdateCollectionInput,
     UpdateProduct,
     UpdateProductCategory,
-    UpdateProductCategoryInput,
     UpdateProductInput,
     UpdateProductVariantInput,
     UpdateProductVariants,
@@ -228,7 +228,7 @@ export class ProductDataService {
         );
     }
 
-    createProductCategory(input: CreateProductCategoryInput) {
+    createProductCategory(input: CreateCollectionInput) {
         return this.baseDataService.mutate<CreateProductCategory.Mutation, CreateProductCategory.Variables>(
             CREATE_PRODUCT_CATEGORY,
             {
@@ -243,7 +243,7 @@ export class ProductDataService {
         );
     }
 
-    updateProductCategory(input: UpdateProductCategoryInput) {
+    updateProductCategory(input: UpdateCollectionInput) {
         return this.baseDataService.mutate<UpdateProductCategory.Mutation, UpdateProductCategory.Variables>(
             UPDATE_PRODUCT_CATEGORY,
             {
@@ -259,7 +259,7 @@ export class ProductDataService {
         );
     }
 
-    moveProductCategory(inputs: MoveProductCategoryInput[]) {
+    moveProductCategory(inputs: MoveCollectionInput[]) {
         return from(inputs).pipe(
             concatMap(input =>
                 this.baseDataService.mutate<MoveProductCategory.Mutation, MoveProductCategory.Variables>(

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
schema-admin.json


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
schema-shop.json


+ 32 - 32
schema.json

@@ -592,7 +592,7 @@
                 "description": null,
                 "type": {
                   "kind": "INPUT_OBJECT",
-                  "name": "ProductCategoryListOptions",
+                  "name": "CollectionListOptions",
                   "ofType": null
                 },
                 "defaultValue": null
@@ -603,7 +603,7 @@
               "name": null,
               "ofType": {
                 "kind": "OBJECT",
-                "name": "ProductCategoryList",
+                "name": "CollectionList",
                 "ofType": null
               }
             },
@@ -641,7 +641,7 @@
             ],
             "type": {
               "kind": "OBJECT",
-              "name": "ProductCategory",
+              "name": "Collection",
               "ofType": null
             },
             "isDeprecated": false,
@@ -1858,7 +1858,7 @@
           },
           {
             "kind": "OBJECT",
-            "name": "ProductCategoryList",
+            "name": "CollectionList",
             "ofType": null
           },
           {
@@ -2026,7 +2026,7 @@
           },
           {
             "kind": "OBJECT",
-            "name": "ProductCategory",
+            "name": "Collection",
             "ofType": null
           },
           {
@@ -10618,7 +10618,7 @@
       },
       {
         "kind": "INPUT_OBJECT",
-        "name": "ProductCategoryListOptions",
+        "name": "CollectionListOptions",
         "description": null,
         "fields": null,
         "inputFields": [
@@ -10647,7 +10647,7 @@
             "description": null,
             "type": {
               "kind": "INPUT_OBJECT",
-              "name": "ProductCategorySortParameter",
+              "name": "CollectionSortParameter",
               "ofType": null
             },
             "defaultValue": null
@@ -10657,7 +10657,7 @@
             "description": null,
             "type": {
               "kind": "INPUT_OBJECT",
-              "name": "ProductCategoryFilterParameter",
+              "name": "CollectionFilterParameter",
               "ofType": null
             },
             "defaultValue": null
@@ -10669,7 +10669,7 @@
       },
       {
         "kind": "INPUT_OBJECT",
-        "name": "ProductCategorySortParameter",
+        "name": "CollectionSortParameter",
         "description": null,
         "fields": null,
         "inputFields": [
@@ -10740,7 +10740,7 @@
       },
       {
         "kind": "INPUT_OBJECT",
-        "name": "ProductCategoryFilterParameter",
+        "name": "CollectionFilterParameter",
         "description": null,
         "fields": null,
         "inputFields": [
@@ -10811,7 +10811,7 @@
       },
       {
         "kind": "OBJECT",
-        "name": "ProductCategoryList",
+        "name": "CollectionList",
         "description": null,
         "fields": [
           {
@@ -10829,7 +10829,7 @@
                   "name": null,
                   "ofType": {
                     "kind": "OBJECT",
-                    "name": "ProductCategory",
+                    "name": "Collection",
                     "ofType": null
                   }
                 }
@@ -10868,7 +10868,7 @@
       },
       {
         "kind": "OBJECT",
-        "name": "ProductCategory",
+        "name": "Collection",
         "description": null,
         "fields": [
           {
@@ -11024,7 +11024,7 @@
               "name": null,
               "ofType": {
                 "kind": "OBJECT",
-                "name": "ProductCategory",
+                "name": "Collection",
                 "ofType": null
               }
             },
@@ -11043,7 +11043,7 @@
                 "name": null,
                 "ofType": {
                   "kind": "OBJECT",
-                  "name": "ProductCategory",
+                  "name": "Collection",
                   "ofType": null
                 }
               }
@@ -11138,7 +11138,7 @@
                   "name": null,
                   "ofType": {
                     "kind": "OBJECT",
-                    "name": "ProductCategoryTranslation",
+                    "name": "CollectionTranslation",
                     "ofType": null
                   }
                 }
@@ -11173,7 +11173,7 @@
       },
       {
         "kind": "OBJECT",
-        "name": "ProductCategoryTranslation",
+        "name": "CollectionTranslation",
         "description": null,
         "fields": [
           {
@@ -14861,7 +14861,7 @@
           },
           {
             "name": "createProductCategory",
-            "description": "Create a new ProductCategory",
+            "description": "Create a new Collection",
             "args": [
               {
                 "name": "input",
@@ -14871,7 +14871,7 @@
                   "name": null,
                   "ofType": {
                     "kind": "INPUT_OBJECT",
-                    "name": "CreateProductCategoryInput",
+                    "name": "CreateCollectionInput",
                     "ofType": null
                   }
                 },
@@ -14883,7 +14883,7 @@
               "name": null,
               "ofType": {
                 "kind": "OBJECT",
-                "name": "ProductCategory",
+                "name": "Collection",
                 "ofType": null
               }
             },
@@ -14892,7 +14892,7 @@
           },
           {
             "name": "updateProductCategory",
-            "description": "Update an existing ProductCategory",
+            "description": "Update an existing Collection",
             "args": [
               {
                 "name": "input",
@@ -14902,7 +14902,7 @@
                   "name": null,
                   "ofType": {
                     "kind": "INPUT_OBJECT",
-                    "name": "UpdateProductCategoryInput",
+                    "name": "UpdateCollectionInput",
                     "ofType": null
                   }
                 },
@@ -14914,7 +14914,7 @@
               "name": null,
               "ofType": {
                 "kind": "OBJECT",
-                "name": "ProductCategory",
+                "name": "Collection",
                 "ofType": null
               }
             },
@@ -14923,7 +14923,7 @@
           },
           {
             "name": "moveProductCategory",
-            "description": "Move a ProductCategory to a different parent or index",
+            "description": "Move a Collection to a different parent or index",
             "args": [
               {
                 "name": "input",
@@ -14933,7 +14933,7 @@
                   "name": null,
                   "ofType": {
                     "kind": "INPUT_OBJECT",
-                    "name": "MoveProductCategoryInput",
+                    "name": "MoveCollectionInput",
                     "ofType": null
                   }
                 },
@@ -14945,7 +14945,7 @@
               "name": null,
               "ofType": {
                 "kind": "OBJECT",
-                "name": "ProductCategory",
+                "name": "Collection",
                 "ofType": null
               }
             },
@@ -18139,7 +18139,7 @@
       },
       {
         "kind": "INPUT_OBJECT",
-        "name": "CreateProductCategoryInput",
+        "name": "CreateCollectionInput",
         "description": null,
         "fields": null,
         "inputFields": [
@@ -18213,7 +18213,7 @@
                   "name": null,
                   "ofType": {
                     "kind": "INPUT_OBJECT",
-                    "name": "ProductCategoryTranslationInput",
+                    "name": "CollectionTranslationInput",
                     "ofType": null
                   }
                 }
@@ -18238,7 +18238,7 @@
       },
       {
         "kind": "INPUT_OBJECT",
-        "name": "ProductCategoryTranslationInput",
+        "name": "CollectionTranslationInput",
         "description": null,
         "fields": null,
         "inputFields": [
@@ -18303,7 +18303,7 @@
       },
       {
         "kind": "INPUT_OBJECT",
-        "name": "UpdateProductCategoryInput",
+        "name": "UpdateCollectionInput",
         "description": null,
         "fields": null,
         "inputFields": [
@@ -18391,7 +18391,7 @@
                   "name": null,
                   "ofType": {
                     "kind": "INPUT_OBJECT",
-                    "name": "ProductCategoryTranslationInput",
+                    "name": "CollectionTranslationInput",
                     "ofType": null
                   }
                 }
@@ -18416,7 +18416,7 @@
       },
       {
         "kind": "INPUT_OBJECT",
-        "name": "MoveProductCategoryInput",
+        "name": "MoveCollectionInput",
         "description": null,
         "fields": null,
         "inputFields": [

+ 6 - 6
server/src/api/resolvers/admin/product-category.resolver.ts

@@ -10,7 +10,7 @@ import {
 } from '../../../../../shared/generated-types';
 import { PaginatedList } from '../../../../../shared/shared-types';
 import { Translated } from '../../../common/types/locale-types';
-import { ProductCategory } from '../../../entity/product-category/product-category.entity';
+import { Collection } from '../../../entity/collection/collection.entity';
 import { FacetValueService } from '../../../service/services/facet-value.service';
 import { ProductCategoryService } from '../../../service/services/product-category.service';
 import { RequestContext } from '../../common/request-context';
@@ -30,7 +30,7 @@ export class ProductCategoryResolver {
     async productCategories(
         @Ctx() ctx: RequestContext,
         @Args() args: ProductCategoriesQueryArgs,
-    ): Promise<PaginatedList<Translated<ProductCategory>>> {
+    ): Promise<PaginatedList<Translated<Collection>>> {
         return this.productCategoryService.findAll(ctx, args.options || undefined);
     }
 
@@ -39,7 +39,7 @@ export class ProductCategoryResolver {
     async productCategory(
         @Ctx() ctx: RequestContext,
         @Args() args: ProductCategoryQueryArgs,
-    ): Promise<Translated<ProductCategory> | undefined> {
+    ): Promise<Translated<Collection> | undefined> {
         return this.productCategoryService.findOne(ctx, args.id);
     }
 
@@ -49,7 +49,7 @@ export class ProductCategoryResolver {
     async createProductCategory(
         @Ctx() ctx: RequestContext,
         @Args() args: CreateProductCategoryMutationArgs,
-    ): Promise<Translated<ProductCategory>> {
+    ): Promise<Translated<Collection>> {
         const { input } = args;
         return this.productCategoryService.create(ctx, input);
     }
@@ -60,7 +60,7 @@ export class ProductCategoryResolver {
     async updateProductCategory(
         @Ctx() ctx: RequestContext,
         @Args() args: UpdateProductCategoryMutationArgs,
-    ): Promise<Translated<ProductCategory>> {
+    ): Promise<Translated<Collection>> {
         const { input } = args;
         return this.productCategoryService.update(ctx, input);
     }
@@ -71,7 +71,7 @@ export class ProductCategoryResolver {
     async moveProductCategory(
         @Ctx() ctx: RequestContext,
         @Args() args: MoveProductCategoryMutationArgs,
-    ): Promise<Translated<ProductCategory>> {
+    ): Promise<Translated<Collection>> {
         const { input } = args;
         return this.productCategoryService.move(ctx, input);
     }

+ 4 - 4
server/src/api/resolvers/entity/product-category-entity.resolver.ts

@@ -1,14 +1,14 @@
 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 { ProductCategory } from '../../../entity/product-category/product-category.entity';
 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('ProductCategory')
+@Resolver('Collection')
 export class ProductCategoryEntityResolver {
     constructor(
         private productCategoryService: ProductCategoryService,
@@ -18,7 +18,7 @@ export class ProductCategoryEntityResolver {
     @ResolveProperty()
     async descendantFacetValues(
         @Ctx() ctx: RequestContext,
-        @Parent() category: ProductCategory,
+        @Parent() category: Collection,
     ): Promise<Array<Translated<FacetValue>>> {
         const descendants = await this.productCategoryService.getDescendants(ctx, category.id);
         return this.facetValueService.findByCategoryIds(ctx, descendants.map(d => d.id));
@@ -27,7 +27,7 @@ export class ProductCategoryEntityResolver {
     @ResolveProperty()
     async ancestorFacetValues(
         @Ctx() ctx: RequestContext,
-        @Parent() category: ProductCategory,
+        @Parent() category: Collection,
     ): Promise<Array<Translated<FacetValue>>> {
         const ancestors = await this.productCategoryService.getAncestors(category.id, ctx);
         return this.facetValueService.findByCategoryIds(ctx, ancestors.map(d => d.id));

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

@@ -11,7 +11,7 @@ import { Omit } from '../../../../../shared/omit';
 import { PaginatedList } from '../../../../../shared/shared-types';
 import { InternalServerError } from '../../../common/error/errors';
 import { Translated } from '../../../common/types/locale-types';
-import { ProductCategory } from '../../../entity';
+import { Collection } from '../../../entity/collection/collection.entity';
 import { Product } from '../../../entity/product/product.entity';
 import { ProductCategoryService } from '../../../service';
 import { FacetValueService } from '../../../service/services/facet-value.service';
@@ -49,7 +49,7 @@ export class ShopProductsResolver {
     async productCategories(
         @Ctx() ctx: RequestContext,
         @Args() args: ProductCategoriesQueryArgs,
-    ): Promise<PaginatedList<Translated<ProductCategory>>> {
+    ): Promise<PaginatedList<Translated<Collection>>> {
         return this.productCategoryService.findAll(ctx, args.options || undefined);
     }
 
@@ -57,7 +57,7 @@ export class ShopProductsResolver {
     async productCategory(
         @Ctx() ctx: RequestContext,
         @Args() args: ProductCategoryQueryArgs,
-    ): Promise<Translated<ProductCategory> | undefined> {
+    ): Promise<Translated<Collection> | undefined> {
         return this.productCategoryService.findOne(ctx, args.id);
     }
 

+ 15 - 15
server/src/api/schema/admin-api/product-category.api.graphql

@@ -1,48 +1,48 @@
 type Query {
-    productCategories(languageCode: LanguageCode, options: ProductCategoryListOptions): ProductCategoryList!
-    productCategory(id: ID!, languageCode: LanguageCode): ProductCategory
+    productCategories(languageCode: LanguageCode, options: CollectionListOptions): CollectionList!
+    productCategory(id: ID!, languageCode: LanguageCode): Collection
 }
 
 type Mutation {
-    "Create a new ProductCategory"
-    createProductCategory(input: CreateProductCategoryInput!): ProductCategory!
+    "Create a new Collection"
+    createProductCategory(input: CreateCollectionInput!): Collection!
 
-    "Update an existing ProductCategory"
-    updateProductCategory(input: UpdateProductCategoryInput!): ProductCategory!
+    "Update an existing Collection"
+    updateProductCategory(input: UpdateCollectionInput!): Collection!
 
-    "Move a ProductCategory to a different parent or index"
-    moveProductCategory(input: MoveProductCategoryInput!): ProductCategory!
+    "Move a Collection to a different parent or index"
+    moveProductCategory(input: MoveCollectionInput!): Collection!
 }
 
 # generated by generateListOptions function
-input ProductCategoryListOptions
+input CollectionListOptions
 
-input MoveProductCategoryInput {
+input MoveCollectionInput {
     categoryId: ID!
     parentId: ID!
     index: Int!
 }
 
-input ProductCategoryTranslationInput {
+input CollectionTranslationInput {
     id: ID
     languageCode: LanguageCode!
     name: String
     description: String
 }
 
-input CreateProductCategoryInput {
+input CreateCollectionInput {
     featuredAssetId: ID
     assetIds: [ID!]
     parentId: ID
     facetValueIds: [ID!]
-    translations: [ProductCategoryTranslationInput!]!
+    translations: [CollectionTranslationInput!]!
 }
 
-input UpdateProductCategoryInput {
+input UpdateCollectionInput {
     id: ID!
     featuredAssetId: ID
     parentId: ID
     assetIds: [ID!]
     facetValueIds: [ID!]
-    translations: [ProductCategoryTranslationInput!]!
+    translations: [CollectionTranslationInput!]!
 }

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

@@ -7,8 +7,8 @@ type Query {
     nextOrderStates: [String!]!
     order(id: ID!): Order
     orderByCode(code: String!): Order
-    productCategories(languageCode: LanguageCode, options: ProductCategoryListOptions): ProductCategoryList!
-    productCategory(id: ID!, languageCode: LanguageCode): ProductCategory
+    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!
@@ -69,7 +69,7 @@ input PaymentInput {
 }
 
 # generated by generateListOptions function
-input ProductCategoryListOptions
+input CollectionListOptions
 
 # generated by generateListOptions function
 input OrderListOptions

+ 7 - 7
server/src/api/schema/type/product-category.type.graphql → server/src/api/schema/type/collection.type.graphql

@@ -1,4 +1,4 @@
-type ProductCategory implements Node {
+type Collection implements Node {
     id: ID!
     createdAt: DateTime!
     updatedAt: DateTime!
@@ -8,15 +8,15 @@ type ProductCategory implements Node {
     description: String!
     featuredAsset: Asset
     assets: [Asset!]!
-    parent: ProductCategory!
-    children: [ProductCategory!]
+    parent: Collection!
+    children: [Collection!]
     facetValues: [FacetValue!]!
     descendantFacetValues: [FacetValue!]!
     ancestorFacetValues: [FacetValue!]!
-    translations: [ProductCategoryTranslation!]!
+    translations: [CollectionTranslation!]!
 }
 
-type ProductCategoryTranslation {
+type CollectionTranslation {
     id: ID!
     createdAt: DateTime!
     updatedAt: DateTime!
@@ -25,7 +25,7 @@ type ProductCategoryTranslation {
     description: String!
 }
 
-type ProductCategoryList implements PaginatedList {
-    items: [ProductCategory!]!
+type CollectionList implements PaginatedList {
+    items: [Collection!]!
     totalItems: Int!
 }

+ 1 - 1
server/src/config/default-config.ts

@@ -88,12 +88,12 @@ export const defaultConfig: ReadOnlyRequired<VendureConfig> = {
     },
     customFields: {
         Address: [],
+        Collection: [],
         Customer: [],
         Facet: [],
         FacetValue: [],
         GlobalSettings: [],
         Product: [],
-        ProductCategory: [],
         ProductOption: [],
         ProductOptionGroup: [],
         ProductVariant: [],

+ 28 - 0
server/src/entity/collection/collection-translation.entity.ts

@@ -0,0 +1,28 @@
+import { Column, Entity, ManyToOne } from 'typeorm';
+
+import { LanguageCode } from '../../../../shared/generated-types';
+import { DeepPartial, HasCustomFields } from '../../../../shared/shared-types';
+import { Translation } from '../../common/types/locale-types';
+import { VendureEntity } from '../base/base.entity';
+import { CustomCollectionFieldsTranslation } from '../custom-entity-fields';
+
+import { Collection } from './collection.entity';
+
+@Entity()
+export class CollectionTranslation extends VendureEntity implements Translation<Collection>, HasCustomFields {
+    constructor(input?: DeepPartial<Translation<Collection>>) {
+        super(input);
+    }
+
+    @Column('varchar') languageCode: LanguageCode;
+
+    @Column() name: string;
+
+    @Column() description: string;
+
+    @ManyToOne(type => Collection, base => base.translations)
+    base: Collection;
+
+    @Column(type => CustomCollectionFieldsTranslation)
+    customFields: CustomCollectionFieldsTranslation;
+}

+ 11 - 11
server/src/entity/product-category/product-category.entity.ts → server/src/entity/collection/collection.entity.ts

@@ -16,14 +16,14 @@ import { LocaleString, Translatable, Translation } from '../../common/types/loca
 import { Asset } from '../asset/asset.entity';
 import { VendureEntity } from '../base/base.entity';
 import { Channel } from '../channel/channel.entity';
-import { CustomProductCategoryFields } from '../custom-entity-fields';
+import { CustomCollectionFields } from '../custom-entity-fields';
 import { FacetValue } from '../facet-value/facet-value.entity';
 
-import { ProductCategoryTranslation } from './product-category-translation.entity';
+import { CollectionTranslation } from './collection-translation.entity';
 
 /**
  * @description
- * A ProductCategory is a grouping of {@link Product}s based on {@link FacetValue}s.
+ * A Collection is a grouping of {@link Product}s based on {@link FacetValue}s.
  *
  * @docsCategory entities
  */
@@ -33,8 +33,8 @@ import { ProductCategoryTranslation } from './product-category-translation.entit
 // Therefore we will just use an adjacency list which will have a perf impact when needing to lookup
 // decendants or ancestors more than 1 level removed.
 // @Tree('closure-table')
-export class ProductCategory extends VendureEntity implements Translatable, HasCustomFields, ChannelAware {
-    constructor(input?: DeepPartial<ProductCategory>) {
+export class Collection extends VendureEntity implements Translatable, HasCustomFields, ChannelAware {
+    constructor(input?: DeepPartial<Collection>) {
         super(input);
     }
 
@@ -48,8 +48,8 @@ export class ProductCategory extends VendureEntity implements Translatable, HasC
 
     description: LocaleString;
 
-    @OneToMany(type => ProductCategoryTranslation, translation => translation.base, { eager: true })
-    translations: Array<Translation<ProductCategory>>;
+    @OneToMany(type => CollectionTranslation, translation => translation.base, { eager: true })
+    translations: Array<Translation<Collection>>;
 
     @ManyToOne(type => Asset)
     featuredAsset: Asset;
@@ -62,14 +62,14 @@ export class ProductCategory extends VendureEntity implements Translatable, HasC
     @JoinTable()
     facetValues: FacetValue[];
 
-    @Column(type => CustomProductCategoryFields)
-    customFields: CustomProductCategoryFields;
+    @Column(type => CustomCollectionFields)
+    customFields: CustomCollectionFields;
 
     @TreeChildren()
-    children: ProductCategory[];
+    children: Collection[];
 
     @TreeParent()
-    parent: ProductCategory;
+    parent: Collection;
 
     @ManyToMany(type => Channel)
     @JoinTable()

+ 4 - 4
server/src/entity/custom-entity-fields.ts

@@ -23,9 +23,9 @@ export class CustomProductFields {}
 @Entity()
 export class CustomProductFieldsTranslation {}
 @Entity()
-export class CustomProductCategoryFields {}
+export class CustomCollectionFields {}
 @Entity()
-export class CustomProductCategoryFieldsTranslation {}
+export class CustomCollectionFieldsTranslation {}
 @Entity()
 export class CustomProductOptionFields {}
 @Entity()
@@ -149,6 +149,8 @@ function assertNoLocaleStringFields(entity: Type<any>, customFields: CustomField
  */
 export function registerCustomEntityFields(config: VendureConfig) {
     registerCustomFieldsForEntity(config, 'Address', CustomAddressFields);
+    registerCustomFieldsForEntity(config, 'Collection', CustomCollectionFields);
+    registerCustomFieldsForEntity(config, 'Collection', CustomCollectionFieldsTranslation, true);
     registerCustomFieldsForEntity(config, 'Customer', CustomCustomerFields);
     registerCustomFieldsForEntity(config, 'Facet', CustomFacetFields);
     registerCustomFieldsForEntity(config, 'Facet', CustomFacetFieldsTranslation, true);
@@ -156,8 +158,6 @@ export function registerCustomEntityFields(config: VendureConfig) {
     registerCustomFieldsForEntity(config, 'FacetValue', CustomFacetValueFieldsTranslation, true);
     registerCustomFieldsForEntity(config, 'Product', CustomProductFields);
     registerCustomFieldsForEntity(config, 'Product', CustomProductFieldsTranslation, true);
-    registerCustomFieldsForEntity(config, 'ProductCategory', CustomProductCategoryFields);
-    registerCustomFieldsForEntity(config, 'ProductCategory', CustomProductCategoryFieldsTranslation, true);
     registerCustomFieldsForEntity(config, 'ProductOption', CustomProductOptionFields);
     registerCustomFieldsForEntity(config, 'ProductOption', CustomProductOptionFieldsTranslation, true);
     registerCustomFieldsForEntity(config, 'ProductOptionGroup', CustomProductOptionGroupFields);

+ 4 - 4
server/src/entity/entities.ts

@@ -2,6 +2,8 @@ import { Address } from './address/address.entity';
 import { Administrator } from './administrator/administrator.entity';
 import { Asset } from './asset/asset.entity';
 import { Channel } from './channel/channel.entity';
+import { CollectionTranslation } from './collection/collection-translation.entity';
+import { Collection } from './collection/collection.entity';
 import { CountryTranslation } from './country/country-translation.entity';
 import { Country } from './country/country.entity';
 import { CustomerGroup } from './customer-group/customer-group.entity';
@@ -16,8 +18,6 @@ import { OrderLine } from './order-line/order-line.entity';
 import { Order } from './order/order.entity';
 import { PaymentMethod } from './payment-method/payment-method.entity';
 import { Payment } from './payment/payment.entity';
-import { ProductCategoryTranslation } from './product-category/product-category-translation.entity';
-import { ProductCategory } from './product-category/product-category.entity';
 import { ProductOptionGroupTranslation } from './product-option-group/product-option-group-translation.entity';
 import { ProductOptionGroup } from './product-option-group/product-option-group.entity';
 import { ProductOptionTranslation } from './product-option/product-option-translation.entity';
@@ -63,8 +63,8 @@ export const coreEntitiesMap = {
     Payment,
     PaymentMethod,
     Product,
-    ProductCategory,
-    ProductCategoryTranslation,
+    Collection,
+    CollectionTranslation,
     ProductOption,
     ProductOptionGroup,
     ProductOptionGroupTranslation,

+ 2 - 2
server/src/entity/index.ts

@@ -3,6 +3,8 @@ export * from './administrator/administrator.entity';
 export * from './asset/asset.entity';
 export * from './base/base.entity';
 export * from './channel/channel.entity';
+export * from './collection/collection.entity';
+export * from './collection/collection-translation.entity';
 export * from './country/country.entity';
 export * from './country/country-translation.entity';
 export * from './customer/customer.entity';
@@ -19,8 +21,6 @@ export * from './payment/payment.entity';
 export * from './payment-method/payment-method.entity';
 export * from './product/product.entity';
 export * from './product/product-translation.entity';
-export * from './product-category/product-category.entity';
-export * from './product-category/product-category-translation.entity';
 export * from './product-option/product-option.entity';
 export * from './product-option/product-option-translation.entity';
 export * from './product-option-group/product-option-group.entity';

+ 0 - 29
server/src/entity/product-category/product-category-translation.entity.ts

@@ -1,29 +0,0 @@
-import { Column, Entity, ManyToOne } from 'typeorm';
-
-import { LanguageCode } from '../../../../shared/generated-types';
-import { DeepPartial, HasCustomFields } from '../../../../shared/shared-types';
-import { Translation } from '../../common/types/locale-types';
-import { VendureEntity } from '../base/base.entity';
-import { CustomProductCategoryFieldsTranslation } from '../custom-entity-fields';
-
-import { ProductCategory } from './product-category.entity';
-
-@Entity()
-export class ProductCategoryTranslation extends VendureEntity
-    implements Translation<ProductCategory>, HasCustomFields {
-    constructor(input?: DeepPartial<Translation<ProductCategory>>) {
-        super(input);
-    }
-
-    @Column('varchar') languageCode: LanguageCode;
-
-    @Column() name: string;
-
-    @Column() description: string;
-
-    @ManyToOne(type => ProductCategory, base => base.translations)
-    base: ProductCategory;
-
-    @Column(type => CustomProductCategoryFieldsTranslation)
-    customFields: CustomProductCategoryFieldsTranslation;
-}

+ 14 - 15
server/src/service/helpers/utils/translate-entity.spec.ts

@@ -1,8 +1,7 @@
 import { LanguageCode } from '../../../../../shared/generated-types';
-
 import { Translatable, Translation } from '../../../common/types/locale-types';
-import { ProductCategoryTranslation } from '../../../entity/product-category/product-category-translation.entity';
-import { ProductCategory } from '../../../entity/product-category/product-category.entity';
+import { CollectionTranslation } from '../../../entity/collection/collection-translation.entity';
+import { Collection } from '../../../entity/collection/collection.entity';
 import { ProductOptionTranslation } from '../../../entity/product-option/product-option-translation.entity';
 import { ProductOption } from '../../../entity/product-option/product-option.entity';
 import { ProductVariantTranslation } from '../../../entity/product-variant/product-variant-translation.entity';
@@ -259,39 +258,39 @@ describe('translateDeep()', () => {
 });
 
 describe('translateTree()', () => {
-    let cat1: ProductCategory;
-    let cat11: ProductCategory;
-    let cat12: ProductCategory;
-    let cat111: ProductCategory;
+    let cat1: Collection;
+    let cat11: Collection;
+    let cat12: Collection;
+    let cat111: Collection;
 
     beforeEach(() => {
-        cat1 = new ProductCategory({
+        cat1 = new Collection({
             translations: [
-                new ProductCategoryTranslation({
+                new CollectionTranslation({
                     languageCode: LanguageCode.en,
                     name: 'cat1 en',
                 }),
             ],
         });
-        cat11 = new ProductCategory({
+        cat11 = new Collection({
             translations: [
-                new ProductCategoryTranslation({
+                new CollectionTranslation({
                     languageCode: LanguageCode.en,
                     name: 'cat11 en',
                 }),
             ],
         });
-        cat12 = new ProductCategory({
+        cat12 = new Collection({
             translations: [
-                new ProductCategoryTranslation({
+                new CollectionTranslation({
                     languageCode: LanguageCode.en,
                     name: 'cat12 en',
                 }),
             ],
         });
-        cat111 = new ProductCategory({
+        cat111 = new Collection({
             translations: [
-                new ProductCategoryTranslation({
+                new CollectionTranslation({
                     languageCode: LanguageCode.en,
                     name: 'cat111 en',
                 }),

+ 2 - 2
server/src/service/services/facet-value.service.ts

@@ -69,11 +69,11 @@ export class FacetValueService {
             .getRepository(FacetValue)
             .createQueryBuilder('facetValue')
             .leftJoinAndSelect(
-                'product_category_facet_values_facet_value',
+                'collection_facet_values_facet_value',
                 'joinTable',
                 'joinTable.facetValueId = facetValue.id',
             )
-            .where('joinTable.productCategoryId IN (:...ids)', { ids })
+            .where('joinTable.collectionId IN (:...ids)', { ids })
             .getMany();
         return this.findByIds(facetValues.map(v => v.id)).then(values =>
             values.map(value => translateDeep(value, ctx.languageCode)),

+ 39 - 45
server/src/service/services/product-category.service.ts

@@ -14,8 +14,8 @@ import { IllegalOperationError } from '../../common/error/errors';
 import { ListQueryOptions } from '../../common/types/common-types';
 import { Translated } from '../../common/types/locale-types';
 import { assertFound, idsAreEqual } from '../../common/utils';
-import { ProductCategoryTranslation } from '../../entity/product-category/product-category-translation.entity';
-import { ProductCategory } from '../../entity/product-category/product-category.entity';
+import { CollectionTranslation } from '../../entity/collection/collection-translation.entity';
+import { Collection } from '../../entity/collection/collection.entity';
 import { AssetUpdater } from '../helpers/asset-updater/asset-updater';
 import { ListQueryBuilder } from '../helpers/list-query-builder/list-query-builder';
 import { TranslatableSaver } from '../helpers/translatable-saver/translatable-saver';
@@ -26,7 +26,7 @@ import { ChannelService } from './channel.service';
 import { FacetValueService } from './facet-value.service';
 
 export class ProductCategoryService {
-    private rootCategories: { [channelCode: string]: ProductCategory } = {};
+    private rootCategories: { [channelCode: string]: Collection } = {};
 
     constructor(
         @InjectConnection() private connection: Connection,
@@ -39,12 +39,12 @@ export class ProductCategoryService {
 
     async findAll(
         ctx: RequestContext,
-        options?: ListQueryOptions<ProductCategory>,
-    ): Promise<PaginatedList<Translated<ProductCategory>>> {
+        options?: ListQueryOptions<Collection>,
+    ): Promise<PaginatedList<Translated<Collection>>> {
         const relations = ['featuredAsset', 'facetValues', 'facetValues.facet', 'parent', 'channels'];
 
         return this.listQueryBuilder
-            .build(ProductCategory, options, {
+            .build(Collection, options, {
                 relations,
                 channelId: ctx.channelId,
                 where: { isRoot: false },
@@ -66,9 +66,9 @@ export class ProductCategoryService {
             });
     }
 
-    async findOne(ctx: RequestContext, productId: ID): Promise<Translated<ProductCategory> | undefined> {
+    async findOne(ctx: RequestContext, productId: ID): Promise<Translated<Collection> | undefined> {
         const relations = ['featuredAsset', 'assets', 'facetValues', 'channels', 'parent'];
-        const productCategory = await this.connection.getRepository(ProductCategory).findOne(productId, {
+        const productCategory = await this.connection.getRepository(Collection).findOne(productId, {
             relations,
         });
         if (!productCategory) {
@@ -84,7 +84,7 @@ export class ProductCategoryService {
      */
     async getFacetValueIdsForCategory(categoryId: ID): Promise<ID[]> {
         const category = await this.connection
-            .getRepository(ProductCategory)
+            .getRepository(Collection)
             .findOne(categoryId, { relations: ['facetValues'] });
         if (!category) {
             return [];
@@ -100,10 +100,10 @@ export class ProductCategoryService {
     /**
      * Returns the descendants of a ProductCategory as a flat array.
      */
-    async getDescendants(ctx: RequestContext, rootId: ID): Promise<Array<Translated<ProductCategory>>> {
-        const getChildren = async (id, _descendants: ProductCategory[] = []) => {
+    async getDescendants(ctx: RequestContext, rootId: ID): Promise<Array<Translated<Collection>>> {
+        const getChildren = async (id, _descendants: Collection[] = []) => {
             const children = await this.connection
-                .getRepository(ProductCategory)
+                .getRepository(Collection)
                 .find({ where: { parent: { id } } });
             for (const child of children) {
                 _descendants.push(child);
@@ -121,17 +121,17 @@ export class ProductCategoryService {
      * will produce more queries the deeper the category is in the tree.
      * @param categoryId
      */
-    getAncestors(categoryId: ID): Promise<ProductCategory[]>;
-    getAncestors(categoryId: ID, ctx: RequestContext): Promise<Array<Translated<ProductCategory>>>;
+    getAncestors(categoryId: ID): Promise<Collection[]>;
+    getAncestors(categoryId: ID, ctx: RequestContext): Promise<Array<Translated<Collection>>>;
     async getAncestors(
         categoryId: ID,
         ctx?: RequestContext,
-    ): Promise<Array<Translated<ProductCategory> | ProductCategory>> {
-        const getParent = async (id, _ancestors: ProductCategory[] = []): Promise<ProductCategory[]> => {
+    ): Promise<Array<Translated<Collection> | Collection>> {
+        const getParent = async (id, _ancestors: Collection[] = []): Promise<Collection[]> => {
             const parent = await this.connection
-                .getRepository(ProductCategory)
+                .getRepository(Collection)
                 .createQueryBuilder()
-                .relation(ProductCategory, 'parent')
+                .relation(Collection, 'parent')
                 .of(id)
                 .loadOne();
             if (parent) {
@@ -145,7 +145,7 @@ export class ProductCategoryService {
         const ancestors = await getParent(categoryId);
 
         return this.connection
-            .getRepository(ProductCategory)
+            .getRepository(Collection)
             .findByIds(ancestors.map(c => c.id), {
                 relations: ['facetValues'],
             })
@@ -154,14 +154,11 @@ export class ProductCategoryService {
             });
     }
 
-    async create(
-        ctx: RequestContext,
-        input: CreateProductCategoryInput,
-    ): Promise<Translated<ProductCategory>> {
+    async create(ctx: RequestContext, input: CreateProductCategoryInput): Promise<Translated<Collection>> {
         const productCategory = await this.translatableSaver.create({
             input,
-            entityType: ProductCategory,
-            translationType: ProductCategoryTranslation,
+            entityType: Collection,
+            translationType: CollectionTranslation,
             beforeSave: async category => {
                 await this.channelService.assignToChannels(category, ctx);
                 const parent = await this.getParentCategory(ctx, input.parentId);
@@ -178,14 +175,11 @@ export class ProductCategoryService {
         return assertFound(this.findOne(ctx, productCategory.id));
     }
 
-    async update(
-        ctx: RequestContext,
-        input: UpdateProductCategoryInput,
-    ): Promise<Translated<ProductCategory>> {
+    async update(ctx: RequestContext, input: UpdateProductCategoryInput): Promise<Translated<Collection>> {
         const productCategory = await this.translatableSaver.update({
             input,
-            entityType: ProductCategory,
-            translationType: ProductCategoryTranslation,
+            entityType: Collection,
+            translationType: CollectionTranslation,
             beforeSave: async category => {
                 if (input.facetValueIds) {
                     category.facetValues = await this.facetValueService.findByIds(input.facetValueIds);
@@ -196,8 +190,8 @@ export class ProductCategoryService {
         return assertFound(this.findOne(ctx, productCategory.id));
     }
 
-    async move(ctx: RequestContext, input: MoveProductCategoryInput): Promise<Translated<ProductCategory>> {
-        const target = await getEntityOrThrow(this.connection, ProductCategory, input.categoryId, {
+    async move(ctx: RequestContext, input: MoveProductCategoryInput): Promise<Translated<Collection>> {
+        const target = await getEntityOrThrow(this.connection, Collection, input.categoryId, {
             relations: ['parent'],
         });
         const descendants = await this.getDescendants(ctx, input.categoryId);
@@ -210,7 +204,7 @@ export class ProductCategoryService {
         }
 
         const siblings = await this.connection
-            .getRepository(ProductCategory)
+            .getRepository(Collection)
             .createQueryBuilder('category')
             .leftJoin('category.parent', 'parent')
             .where('parent.id = :id', { id: input.parentId })
@@ -227,14 +221,14 @@ export class ProductCategoryService {
                 });
             }
         } else {
-            target.parent = new ProductCategory({ id: input.parentId });
+            target.parent = new Collection({ id: input.parentId });
             siblings.splice(normalizedIndex, 0, target);
             siblings.forEach((cat, index) => {
                 cat.position = index;
             });
         }
 
-        await this.connection.getRepository(ProductCategory).save(siblings);
+        await this.connection.getRepository(Collection).save(siblings);
         return assertFound(this.findOne(ctx, input.categoryId));
     }
 
@@ -244,7 +238,7 @@ export class ProductCategoryService {
     async getNextPositionInParent(ctx: RequestContext, maybeParentId?: ID): Promise<number> {
         const parentId = maybeParentId || (await this.getRootCategory(ctx)).id;
         const result = await this.connection
-            .getRepository(ProductCategory)
+            .getRepository(Collection)
             .createQueryBuilder('category')
             .leftJoin('category.parent', 'parent')
             .select('MAX(category.position)', 'index')
@@ -256,10 +250,10 @@ export class ProductCategoryService {
     private async getParentCategory(
         ctx: RequestContext,
         parentId?: ID | null,
-    ): Promise<ProductCategory | undefined> {
+    ): Promise<Collection | undefined> {
         if (parentId) {
             return this.connection
-                .getRepository(ProductCategory)
+                .getRepository(Collection)
                 .createQueryBuilder('category')
                 .leftJoin('category.channels', 'channel')
                 .where('category.id = :id', { id: parentId })
@@ -270,7 +264,7 @@ export class ProductCategoryService {
         }
     }
 
-    private async getRootCategory(ctx: RequestContext): Promise<ProductCategory> {
+    private async getRootCategory(ctx: RequestContext): Promise<Collection> {
         const cachedRoot = this.rootCategories[ctx.channel.code];
 
         if (cachedRoot) {
@@ -278,7 +272,7 @@ export class ProductCategoryService {
         }
 
         const existingRoot = await this.connection
-            .getRepository(ProductCategory)
+            .getRepository(Collection)
             .createQueryBuilder('category')
             .leftJoin('category.channels', 'channel')
             .where('category.isRoot = :isRoot', { isRoot: true })
@@ -290,22 +284,22 @@ export class ProductCategoryService {
             return existingRoot;
         }
 
-        const rootTranslation = await this.connection.getRepository(ProductCategoryTranslation).save(
-            new ProductCategoryTranslation({
+        const rootTranslation = await this.connection.getRepository(CollectionTranslation).save(
+            new CollectionTranslation({
                 languageCode: DEFAULT_LANGUAGE_CODE,
                 name: ROOT_CATEGORY_NAME,
                 description: 'The root of the ProductCategory tree.',
             }),
         );
 
-        const newRoot = new ProductCategory({
+        const newRoot = new Collection({
             isRoot: true,
             position: 0,
             translations: [rootTranslation],
             channels: [ctx.channel],
         });
 
-        await this.connection.getRepository(ProductCategory).save(newRoot);
+        await this.connection.getRepository(Collection).save(newRoot);
         this.rootCategories[ctx.channel.code] = newRoot;
         return newRoot;
     }

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

@@ -1,5 +1,5 @@
 // tslint:disable
-// Generated in 2019-02-26T12:18:47+01:00
+// Generated in 2019-03-04T11:06:07+01:00
 export type Maybe<T> = T | null;
 
 export interface OrderListOptions {
@@ -104,17 +104,17 @@ export interface NumberRange {
     end: number;
 }
 
-export interface ProductCategoryListOptions {
+export interface CollectionListOptions {
     skip?: Maybe<number>;
 
     take?: Maybe<number>;
 
-    sort?: Maybe<ProductCategorySortParameter>;
+    sort?: Maybe<CollectionSortParameter>;
 
-    filter?: Maybe<ProductCategoryFilterParameter>;
+    filter?: Maybe<CollectionFilterParameter>;
 }
 
-export interface ProductCategorySortParameter {
+export interface CollectionSortParameter {
     id?: Maybe<SortOrder>;
 
     createdAt?: Maybe<SortOrder>;
@@ -128,7 +128,7 @@ export interface ProductCategorySortParameter {
     description?: Maybe<SortOrder>;
 }
 
-export interface ProductCategoryFilterParameter {
+export interface CollectionFilterParameter {
     createdAt?: Maybe<DateOperators>;
 
     updatedAt?: Maybe<DateOperators>;
@@ -760,9 +760,9 @@ export interface Query {
 
     orderByCode?: Maybe<Order>;
 
-    productCategories: ProductCategoryList;
+    productCategories: CollectionList;
 
-    productCategory?: Maybe<ProductCategory>;
+    productCategory?: Maybe<Collection>;
 
     product?: Maybe<Product>;
 
@@ -1313,13 +1313,13 @@ export interface CurrentUser {
     channelTokens: string[];
 }
 
-export interface ProductCategoryList extends PaginatedList {
-    items: ProductCategory[];
+export interface CollectionList extends PaginatedList {
+    items: Collection[];
 
     totalItems: number;
 }
 
-export interface ProductCategory extends Node {
+export interface Collection extends Node {
     id: string;
 
     createdAt: DateTime;
@@ -1338,9 +1338,9 @@ export interface ProductCategory extends Node {
 
     assets: Asset[];
 
-    parent: ProductCategory;
+    parent: Collection;
 
-    children?: Maybe<ProductCategory[]>;
+    children?: Maybe<Collection[]>;
 
     facetValues: FacetValue[];
 
@@ -1348,12 +1348,12 @@ export interface ProductCategory extends Node {
 
     ancestorFacetValues: FacetValue[];
 
-    translations: ProductCategoryTranslation[];
+    translations: CollectionTranslation[];
 
     customFields?: Maybe<Json>;
 }
 
-export interface ProductCategoryTranslation {
+export interface CollectionTranslation {
     id: string;
 
     createdAt: DateTime;
@@ -1505,8 +1505,6 @@ export interface Mutation {
     addPaymentToOrder?: Maybe<Order>;
 
     setCustomerForOrder?: Maybe<Order>;
-    /** Create a new Customer Address */
-    createCustomerAddress: Address;
 
     login: LoginResult;
 
@@ -1517,6 +1515,8 @@ export interface Mutation {
     registerCustomerAccount: boolean;
     /** Update an existing Customer */
     updateCustomer: Customer;
+    /** Create a new Customer Address */
+    createCustomerAddress: Address;
     /** Update an existing Address */
     updateCustomerAddress: Address;
     /** Delete an existing Address */
@@ -1694,7 +1694,7 @@ export interface OrderByCodeQueryArgs {
 export interface ProductCategoriesQueryArgs {
     languageCode?: Maybe<LanguageCode>;
 
-    options?: Maybe<ProductCategoryListOptions>;
+    options?: Maybe<CollectionListOptions>;
 }
 export interface ProductCategoryQueryArgs {
     id: string;
@@ -1745,9 +1745,6 @@ export interface AddPaymentToOrderMutationArgs {
 export interface SetCustomerForOrderMutationArgs {
     input: CreateCustomerInput;
 }
-export interface CreateCustomerAddressMutationArgs {
-    input: CreateAddressInput;
-}
 export interface LoginMutationArgs {
     username: string;
 
@@ -1764,6 +1761,9 @@ export interface RegisterCustomerAccountMutationArgs {
 export interface UpdateCustomerMutationArgs {
     input: UpdateCustomerInput;
 }
+export interface CreateCustomerAddressMutationArgs {
+    input: CreateAddressInput;
+}
 export interface UpdateCustomerAddressMutationArgs {
     input: UpdateAddressInput;
 }

+ 47 - 47
shared/generated-types.ts

@@ -1,5 +1,5 @@
 // tslint:disable
-// Generated in 2019-02-26T12:18:48+01:00
+// Generated in 2019-03-04T11:06:09+01:00
 export type Maybe<T> = T | null;
 
 
@@ -342,18 +342,18 @@ export interface PaymentMethodFilterParameter {
   enabled?: Maybe<BooleanOperators>;
 }
 
-export interface ProductCategoryListOptions {
+export interface CollectionListOptions {
   
   skip?: Maybe<number>;
   
   take?: Maybe<number>;
   
-  sort?: Maybe<ProductCategorySortParameter>;
+  sort?: Maybe<CollectionSortParameter>;
   
-  filter?: Maybe<ProductCategoryFilterParameter>;
+  filter?: Maybe<CollectionFilterParameter>;
 }
 
-export interface ProductCategorySortParameter {
+export interface CollectionSortParameter {
   
   id?: Maybe<SortOrder>;
   
@@ -368,7 +368,7 @@ export interface ProductCategorySortParameter {
   description?: Maybe<SortOrder>;
 }
 
-export interface ProductCategoryFilterParameter {
+export interface CollectionFilterParameter {
   
   createdAt?: Maybe<DateOperators>;
   
@@ -886,7 +886,7 @@ export interface ConfigArgInput {
   value: string;
 }
 
-export interface CreateProductCategoryInput {
+export interface CreateCollectionInput {
   
   featuredAssetId?: Maybe<string>;
   
@@ -896,12 +896,12 @@ export interface CreateProductCategoryInput {
   
   facetValueIds?: Maybe<string[]>;
   
-  translations: ProductCategoryTranslationInput[];
+  translations: CollectionTranslationInput[];
   
   customFields?: Maybe<Json>;
 }
 
-export interface ProductCategoryTranslationInput {
+export interface CollectionTranslationInput {
   
   id?: Maybe<string>;
   
@@ -914,7 +914,7 @@ export interface ProductCategoryTranslationInput {
   customFields?: Maybe<Json>;
 }
 
-export interface UpdateProductCategoryInput {
+export interface UpdateCollectionInput {
   
   id: string;
   
@@ -926,12 +926,12 @@ export interface UpdateProductCategoryInput {
   
   facetValueIds?: Maybe<string[]>;
   
-  translations: ProductCategoryTranslationInput[];
+  translations: CollectionTranslationInput[];
   
   customFields?: Maybe<Json>;
 }
 
-export interface MoveProductCategoryInput {
+export interface MoveCollectionInput {
   
   categoryId: string;
   
@@ -2583,7 +2583,7 @@ export namespace CreateAssets {
 
 export namespace GetProductCategoryList {
   export type Variables = {
-    options?: Maybe<ProductCategoryListOptions>;
+    options?: Maybe<CollectionListOptions>;
     languageCode?: Maybe<LanguageCode>;
   }
 
@@ -2594,7 +2594,7 @@ export namespace GetProductCategoryList {
   }
 
   export type ProductCategories = {
-    __typename?: "ProductCategoryList";
+    __typename?: "CollectionList";
     
     items: Items[];
     
@@ -2602,7 +2602,7 @@ export namespace GetProductCategoryList {
   } 
 
   export type Items = {
-    __typename?: "ProductCategory";
+    __typename?: "Collection";
     
     id: string;
     
@@ -2640,7 +2640,7 @@ export namespace GetProductCategoryList {
   } 
 
   export type Parent = {
-    __typename?: "ProductCategory";
+    __typename?: "Collection";
     
     id: string;
   } 
@@ -2658,12 +2658,12 @@ export namespace GetProductCategory {
     productCategory: Maybe<ProductCategory>;
   }
 
-  export type ProductCategory = ProductCategory.Fragment
+  export type ProductCategory = Collection.Fragment
 }
 
 export namespace CreateProductCategory {
   export type Variables = {
-    input: CreateProductCategoryInput;
+    input: CreateCollectionInput;
   }
 
   export type Mutation = {
@@ -2672,12 +2672,12 @@ export namespace CreateProductCategory {
     createProductCategory: CreateProductCategory;
   }
 
-  export type CreateProductCategory = ProductCategory.Fragment
+  export type CreateProductCategory = Collection.Fragment
 }
 
 export namespace UpdateProductCategory {
   export type Variables = {
-    input: UpdateProductCategoryInput;
+    input: UpdateCollectionInput;
   }
 
   export type Mutation = {
@@ -2686,12 +2686,12 @@ export namespace UpdateProductCategory {
     updateProductCategory: UpdateProductCategory;
   }
 
-  export type UpdateProductCategory = ProductCategory.Fragment
+  export type UpdateProductCategory = Collection.Fragment
 }
 
 export namespace MoveProductCategory {
   export type Variables = {
-    input: MoveProductCategoryInput;
+    input: MoveCollectionInput;
   }
 
   export type Mutation = {
@@ -2700,7 +2700,7 @@ export namespace MoveProductCategory {
     moveProductCategory: MoveProductCategory;
   }
 
-  export type MoveProductCategory = ProductCategory.Fragment
+  export type MoveProductCategory = Collection.Fragment
 }
 
 export namespace SearchProducts {
@@ -4086,9 +4086,9 @@ export namespace ProductOptionGroup {
   }
 }
 
-export namespace ProductCategory {
+export namespace Collection {
   export type Fragment = {
-    __typename?: "ProductCategory";
+    __typename?: "Collection";
     
     id: string;
     
@@ -4126,7 +4126,7 @@ export namespace ProductCategory {
   }
 
   export type Translations = {
-    __typename?: "ProductCategoryTranslation";
+    __typename?: "CollectionTranslation";
     
     id: string;
     
@@ -4138,7 +4138,7 @@ export namespace ProductCategory {
   }
 
   export type Parent = {
-    __typename?: "ProductCategory";
+    __typename?: "Collection";
     
     id: string;
     
@@ -4146,7 +4146,7 @@ export namespace ProductCategory {
   }
 
   export type Children = {
-    __typename?: "ProductCategory";
+    __typename?: "Collection";
     
     id: string;
     
@@ -4473,9 +4473,9 @@ export interface Query {
   
   paymentMethod?: Maybe<PaymentMethod>;
   
-  productCategories: ProductCategoryList;
+  productCategories: CollectionList;
   
-  productCategory?: Maybe<ProductCategory>;
+  productCategory?: Maybe<Collection>;
   
   productOptionGroups: ProductOptionGroup[];
   
@@ -5231,15 +5231,15 @@ export interface PaymentMethod extends Node {
 }
 
 
-export interface ProductCategoryList extends PaginatedList {
+export interface CollectionList extends PaginatedList {
   
-  items: ProductCategory[];
+  items: Collection[];
   
   totalItems: number;
 }
 
 
-export interface ProductCategory extends Node {
+export interface Collection extends Node {
   
   id: string;
   
@@ -5259,9 +5259,9 @@ export interface ProductCategory extends Node {
   
   assets: Asset[];
   
-  parent: ProductCategory;
+  parent: Collection;
   
-  children?: Maybe<ProductCategory[]>;
+  children?: Maybe<Collection[]>;
   
   facetValues: FacetValue[];
   
@@ -5269,13 +5269,13 @@ export interface ProductCategory extends Node {
   
   ancestorFacetValues: FacetValue[];
   
-  translations: ProductCategoryTranslation[];
+  translations: CollectionTranslation[];
   
   customFields?: Maybe<Json>;
 }
 
 
-export interface ProductCategoryTranslation {
+export interface CollectionTranslation {
   
   id: string;
   
@@ -5568,12 +5568,12 @@ export interface Mutation {
   importProducts?: Maybe<ImportInfo>;
   /** Update an existing PaymentMethod */
   updatePaymentMethod: PaymentMethod;
-  /** Create a new ProductCategory */
-  createProductCategory: ProductCategory;
-  /** Update an existing ProductCategory */
-  updateProductCategory: ProductCategory;
-  /** Move a ProductCategory to a different parent or index */
-  moveProductCategory: ProductCategory;
+  /** 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 */
@@ -5760,7 +5760,7 @@ export interface ProductCategoriesQueryArgs {
   
   languageCode?: Maybe<LanguageCode>;
   
-  options?: Maybe<ProductCategoryListOptions>;
+  options?: Maybe<CollectionListOptions>;
 }
 export interface ProductCategoryQueryArgs {
   
@@ -5976,15 +5976,15 @@ export interface UpdatePaymentMethodMutationArgs {
 }
 export interface CreateProductCategoryMutationArgs {
   
-  input: CreateProductCategoryInput;
+  input: CreateCollectionInput;
 }
 export interface UpdateProductCategoryMutationArgs {
   
-  input: UpdateProductCategoryInput;
+  input: UpdateCollectionInput;
 }
 export interface MoveProductCategoryMutationArgs {
   
-  input: MoveProductCategoryInput;
+  input: MoveCollectionInput;
 }
 export interface CreateProductOptionGroupMutationArgs {
   

+ 1 - 1
shared/shared-types.ts

@@ -66,12 +66,12 @@ export interface CustomFieldConfig {
  */
 export interface CustomFields {
     Address?: CustomFieldConfig[];
+    Collection?: CustomFieldConfig[];
     Customer?: CustomFieldConfig[];
     Facet?: CustomFieldConfig[];
     FacetValue?: CustomFieldConfig[];
     GlobalSettings?: CustomFieldConfig[];
     Product?: CustomFieldConfig[];
-    ProductCategory?: CustomFieldConfig[];
     ProductOption?: CustomFieldConfig[];
     ProductOptionGroup?: CustomFieldConfig[];
     ProductVariant?: CustomFieldConfig[];

Некоторые файлы не были показаны из-за большого количества измененных файлов