(idFields: FieldDef[], resourceId: string, nested: boolean = true)
| 2086 | } |
| 2087 | |
| 2088 | private makeIdFilter(idFields: FieldDef[], resourceId: string, nested: boolean = true) { |
| 2089 | const decodedId = decodeURIComponent(resourceId); |
| 2090 | if (idFields.length === 1) { |
| 2091 | return { [idFields[0]!.name]: this.coerce(idFields[0]!, decodedId) }; |
| 2092 | } else if (nested) { |
| 2093 | return { |
| 2094 | // TODO: support `@@id` with custom name |
| 2095 | [idFields.map((idf) => idf.name).join(DEFAULT_ID_DIVIDER)]: idFields.reduce( |
| 2096 | (acc, curr, idx) => ({ |
| 2097 | ...acc, |
| 2098 | [curr.name]: this.coerce(curr, decodedId.split(this.idDivider)[idx]), |
| 2099 | }), |
| 2100 | {}, |
| 2101 | ), |
| 2102 | }; |
| 2103 | } else { |
| 2104 | return idFields.reduce( |
| 2105 | (acc, curr, idx) => ({ |
| 2106 | ...acc, |
| 2107 | [curr.name]: this.coerce(curr, decodedId.split(this.idDivider)[idx]), |
| 2108 | }), |
| 2109 | {}, |
| 2110 | ); |
| 2111 | } |
| 2112 | } |
| 2113 | |
| 2114 | private makeIdSelect(idFields: FieldDef[]) { |
| 2115 | if (idFields.length === 0) { |
no test coverage detected