chore: Migrate modules to use the Module util (#7964)
**What** Apply the `Module` util to each module to handle the export and provide the linkable configuration object. - Most joiner config that does not have any special config are removed/cleaned up in favor of the autogenerated one or simpler one - linkable are now available in all modules - cleaned up the dependencies of the modules FIXES CORE-2410
This commit is contained in:
committed by
GitHub
parent
eafa3560ae
commit
b368251ca3
@@ -32,7 +32,7 @@ import { accessSync } from "fs"
|
||||
* then it will be inferred from the entity name of the alias args.
|
||||
*
|
||||
* @param serviceName
|
||||
* @param alias
|
||||
* @param alias custom aliases will be merged with the computed aliases from the provided models. Though, if a custom alias correspond to a computed alias for the same model then the custom alias will take place. Also, note that the methodSuffix will be inferred from the entity name if not provided as part of the args.
|
||||
* @param schema
|
||||
* @param models
|
||||
* @param linkableKeys
|
||||
@@ -72,11 +72,19 @@ export function defineJoinerConfig(
|
||||
|
||||
while (true) {
|
||||
++index
|
||||
const fullPath = getCallerFilePath(index)
|
||||
let fullPath = getCallerFilePath(index)
|
||||
if (!fullPath) {
|
||||
break
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle integration-tests/__tests__ path based on conventional naming
|
||||
*/
|
||||
if (fullPath.includes("integration-tests/__tests__")) {
|
||||
const sourcePath = fullPath.split("integration-tests/__tests__")[0]
|
||||
fullPath = path.join(sourcePath, "src")
|
||||
}
|
||||
|
||||
const srcDir = fullPath.includes("dist") ? "dist" : "src"
|
||||
const splitPath = fullPath.split(srcDir)
|
||||
|
||||
@@ -297,10 +305,10 @@ export function buildLinkableKeysFromMikroOrmObjects(
|
||||
* // {
|
||||
* // user: {
|
||||
* // id: {
|
||||
* // serviceName: 'userService',
|
||||
* // field: 'user',
|
||||
* // linkable: 'user_id',
|
||||
* // primaryKey: 'id'
|
||||
* // serviceName: 'userService', // The name of the module service it originate from
|
||||
* // field: 'user', // The field name of the entity, the query field is inferred from it as kebab cased singular/plural
|
||||
* // linkable: 'user_id', // The linkable key
|
||||
* // primaryKey: 'id' // The primary key if refers to in the original object representation, it will be used to be passed to the filters of the corresponding public service method
|
||||
* // },
|
||||
* // toJSON() { ... }
|
||||
* // },
|
||||
|
||||
@@ -53,7 +53,7 @@ export function Module<
|
||||
} else {
|
||||
linkable = buildLinkConfigFromLinkableKeys(
|
||||
serviceName,
|
||||
defaultJoinerConfig.linkableKeys
|
||||
service.prototype.__joinerConfig().linkableKeys
|
||||
) as Linkable
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user