| 123456789101112131415161718192021222324 |
- import ApiResource from "~/models/ApiResource";
- /**
- * Decorates an ApiResource's property to signal it as a field that is provided
- * as an IRI or an array of IRI by the API
- *
- * If the property is decorated, the HydraNormalizer will parse the IRI when de-normalizing
- * to get the id(s), then re-encode it as IRI(s) when re-normalizing.
- */
- export function IriEncoded (
- apiResource: typeof ApiResource
- ): PropertyDecorator {
- return (target: Object, propertyKey: string | symbol) => {
- //@ts-ignore
- const self = target.$self()
- if (!self.hasOwnProperty("relations")) {
- self.relations = {}
- }
- //@ts-ignore
- self.relations[propertyKey] = apiResource
- }
- }
|