Skip to content

Commit

Permalink
add some documentation on angular client methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Tcharl committed Jan 20, 2023
1 parent 110005c commit 5208994
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
31 changes: 31 additions & 0 deletions generators/angular/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,20 @@ export default class AngularGenerator extends BaseApplicationGenerator {
this.needleApi.clientAngular.addGlobalSCSSStyle(style, comment);
}

/**
* Returns the typescript import section of enums referenced by all fields of the entity.
* @param fields returns the import of enums that are referenced by the fields
* @returns {typeImports:Map} the fields that potentially contains some enum types
*/
generateEntityClientEnumImports(fields) {
return getClientEnumImportsFormat(fields, ANGULAR);
}

/**
* Get the typescript type of a non-composite primary key
* @param primaryKey the primary key of the entity
* @returns {string} the typescript type.
*/
getTypescriptKeyType(primaryKey) {
return getTSKeyType(primaryKey);
}
Expand All @@ -247,14 +257,35 @@ export default class AngularGenerator extends BaseApplicationGenerator {
return out && out[0] && !!out[0].skipForLocale;
}

/**
* generates a value for a primary key type
* @param primaryKey the primary key attribute of the entity
* @param index an index to add salt to the value
* @param wrapped if the value should be within quotes
* @returns {string|number|string}
*/
generateTestEntityId(primaryKey, index = 0, wrapped = true) {
return getTestEntityId(primaryKey, index, wrapped);
}

/**
* @private
* Generate a test entity, for the PK references (when the PK is a composite, derived key)
*
* @param {any} primaryKey - primary key definition.
* @param {number} [index] - index of the primary key sample, pass undefined for a random key.
*/
generateTestEntityPrimaryKey(primaryKey, index) {
return getTestEntityPrimaryKey(primaryKey, index);
}

/**
* @private
* Generate a test entity instance with faked values.
*
* @param {any} references - references to other entities.
* @param {any} additionalFields - additional fields to add to the entity or with default values that overrides generated values.
*/
generateTypescriptTestEntity(references, additionalFields) {
return generateTestEntity(references, additionalFields);
}
Expand Down
4 changes: 1 addition & 3 deletions generators/client/support/template-utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ export const generateTestEntity = (references, index = 'random') => {
};

/**
* @private
* Generate a test entity, according to the references
*
* @param references
Expand Down Expand Up @@ -169,8 +168,7 @@ export const generateTypescriptTestEntity = (references, additionalFields = {})
}`;
};
/**
* @private
* Generate a test entity, according to the type
* Generate a test entity for the PK references (when the PK is a composite key)
*
* @param {any} primaryKey - primary key definition.
* @param {number} [index] - index of the primary key sample, pass undefined for a random key.
Expand Down

0 comments on commit 5208994

Please sign in to comment.