|
1 | 1 | import { Constructor, IDmlEntity, ModuleExports } from "@medusajs/types"
|
2 |
| -import { MedusaServiceModelObjectsSymbol } from "./medusa-service" |
| 2 | +import { DmlEntity } from "../dml" |
3 | 3 | import {
|
4 | 4 | buildLinkConfigFromLinkableKeys,
|
5 | 5 | buildLinkConfigFromModelObjects,
|
6 | 6 | defineJoinerConfig,
|
7 | 7 | } from "./joiner-config-builder"
|
| 8 | +import { MedusaServiceModelObjectsSymbol } from "./medusa-service" |
8 | 9 | import { InfersLinksConfig } from "./types/links-config"
|
9 |
| -import { DmlEntity } from "../dml" |
10 | 10 |
|
11 | 11 | /**
|
12 | 12 | * Wrapper to build the module export and auto generate the joiner config if not already provided in the module service, as well as
|
@@ -44,29 +44,27 @@ export function Module<
|
44 | 44 |
|
45 | 45 | let linkable = {} as Linkable
|
46 | 46 |
|
47 |
| - if (Object.keys(modelObjects)?.length) { |
48 |
| - const dmlObjects = Object.entries(modelObjects).filter(([, model]) => |
49 |
| - DmlEntity.isDmlEntity(model) |
50 |
| - ) |
| 47 | + const dmlObjects = Object.entries(modelObjects).filter(([, model]) => |
| 48 | + DmlEntity.isDmlEntity(model) |
| 49 | + ) |
51 | 50 |
|
52 |
| - // TODO: Custom joiner config should take precedence over the DML auto generated linkable |
53 |
| - // Thats in the case of manually providing models in custom joiner config. |
54 |
| - // TODO: Add support for non linkable modifier DML object to be skipped from the linkable generation |
| 51 | + // TODO: Custom joiner config should take precedence over the DML auto generated linkable |
| 52 | + // Thats in the case of manually providing models in custom joiner config. |
| 53 | + // TODO: Add support for non linkable modifier DML object to be skipped from the linkable generation |
55 | 54 |
|
56 |
| - const linkableKeys = service.prototype.__joinerConfig().linkableKeys |
| 55 | + const linkableKeys = service.prototype.__joinerConfig().linkableKeys |
57 | 56 |
|
58 |
| - if (dmlObjects.length) { |
59 |
| - linkable = buildLinkConfigFromModelObjects<ServiceName, ModelObjects>( |
60 |
| - serviceName, |
61 |
| - modelObjects, |
62 |
| - linkableKeys |
63 |
| - ) as Linkable |
64 |
| - } else { |
65 |
| - linkable = buildLinkConfigFromLinkableKeys( |
66 |
| - serviceName, |
67 |
| - linkableKeys |
68 |
| - ) as Linkable |
69 |
| - } |
| 57 | + if (dmlObjects.length) { |
| 58 | + linkable = buildLinkConfigFromModelObjects<ServiceName, ModelObjects>( |
| 59 | + serviceName, |
| 60 | + modelObjects, |
| 61 | + linkableKeys |
| 62 | + ) as Linkable |
| 63 | + } else { |
| 64 | + linkable = buildLinkConfigFromLinkableKeys( |
| 65 | + serviceName, |
| 66 | + linkableKeys |
| 67 | + ) as Linkable |
70 | 68 | }
|
71 | 69 |
|
72 | 70 | return {
|
|
0 commit comments