Browse Source

docs(core): Add documentation to entity interfaces

Michael Bromley 4 years ago
parent
commit
c7b7257ed2

+ 16 - 0
packages/core/src/common/types/common-types.ts

@@ -7,28 +7,44 @@ import { Tag } from '../../entity/tag/tag.entity';
 import { LocaleString } from './locale-types';
 import { LocaleString } from './locale-types';
 
 
 /**
 /**
+ * @description
  * Entities which can be assigned to Channels should implement this interface.
  * Entities which can be assigned to Channels should implement this interface.
+ *
+ * @docsCategory entities
+ * @docsPage interfaces
  */
  */
 export interface ChannelAware {
 export interface ChannelAware {
     channels: Channel[];
     channels: Channel[];
 }
 }
 
 
 /**
 /**
+ * @description
  * Entities which can be soft deleted should implement this interface.
  * Entities which can be soft deleted should implement this interface.
+ *
+ * @docsCategory entities
+ * @docsPage interfaces
  */
  */
 export interface SoftDeletable {
 export interface SoftDeletable {
     deletedAt: Date | null;
     deletedAt: Date | null;
 }
 }
 
 
 /**
 /**
+ * @description
  * Entities which can be ordered relative to their siblings in a list.
  * Entities which can be ordered relative to their siblings in a list.
+ *
+ * @docsCategory entities
+ * @docsPage interfaces
  */
  */
 export interface Orderable {
 export interface Orderable {
     position: number;
     position: number;
 }
 }
 
 
 /**
 /**
+ * @description
  * Entities which can have Tags applied to them.
  * Entities which can have Tags applied to them.
+ *
+ * @docsCategory entities
+ * @docsPage interfaces
  */
  */
 export interface Taggable {
 export interface Taggable {
     tags: Tag[];
     tags: Tag[];

+ 9 - 3
packages/core/src/common/types/locale-types.ts

@@ -20,9 +20,15 @@ export type NonTranslateableKeys<T> = { [K in keyof T]: T[K] extends LocaleStrin
 
 
 // prettier-ignore
 // prettier-ignore
 /**
 /**
+ * @description
  * Entities which have localizable string properties should implement this type.
  * Entities which have localizable string properties should implement this type.
+ *
+ * @docsCategory entities
+ * @docsPage interfaces
  */
  */
-export interface Translatable { translations: Array<Translation<VendureEntity>>; }
+export interface Translatable {
+    translations: Array<Translation<VendureEntity>>;
+}
 
 
 export type TranslationCustomFields<T> = { [K in keyof T]: K extends 'customFields' ? K : never }[keyof T];
 export type TranslationCustomFields<T> = { [K in keyof T]: K extends 'customFields' ? K : never }[keyof T];
 
 
@@ -31,7 +37,7 @@ export type TranslationCustomFields<T> = { [K in keyof T]: K extends 'customFiel
  * Translations of localizable entities should implement this type.
  * Translations of localizable entities should implement this type.
  */
  */
 export type Translation<T> =
 export type Translation<T> =
-    // Translation must include the languageCode and a reference to the base Translatable entity it is associated with
+// Translation must include the languageCode and a reference to the base Translatable entity it is associated with
     {
     {
         id: ID;
         id: ID;
         languageCode: LanguageCode;
         languageCode: LanguageCode;
@@ -61,6 +67,6 @@ export interface TranslatedInput<T> {
 /**
 /**
  * This is the type of a Translatable entity after it has been deep-translated into a given language.
  * This is the type of a Translatable entity after it has been deep-translated into a given language.
  */
  */
-export type Translated<T> =  T & { languageCode: LanguageCode; } & {
+export type Translated<T> = T & { languageCode: LanguageCode; } & {
     [K in TranslatableRelationsKeys<T>]: T[K] extends any[] ? Array<Translated<UnwrappedArray<T[K]>>> : Translated<T[K]>;
     [K in TranslatableRelationsKeys<T>]: T[K] extends any[] ? Array<Translated<UnwrappedArray<T[K]>>> : Translated<T[K]>;
 };
 };