@atoms-studio/commercelayer-sdk
Advanced tools
Comparing version 0.1.0-alpha.6 to 0.1.0-alpha.7
@@ -0,1 +1,8 @@ | ||
## [0.1.0-alpha.7](https://github.com/atoms-studio/commercelayer-sdk/compare/0.1.0-alpha.6...0.1.0-alpha.7) (2021-07-20) | ||
### Bug Fixes | ||
* **api:** allow common resource attributes in create/update payloads ([ea731c1](https://github.com/atoms-studio/commercelayer-sdk/commit/ea731c15b7064c7bc248a25f19f0e173543abc49)) | ||
## 0.1.0-alpha.6 (2021-07-19) | ||
@@ -2,0 +9,0 @@ |
@@ -276,3 +276,3 @@ 'use strict'; | ||
keyForAttribute: 'snake_case', | ||
attributes: config.attributes, | ||
attributes: config.attributes.concat(commonPayloadAttributes), | ||
}); | ||
@@ -285,7 +285,2 @@ const serialized = serializer.serialize(attributes); | ||
} | ||
// Add metadata if original attributes contain it. | ||
// For some reason jsonapi-serializer strips the key | ||
if (attributes.metadata && !serialized.data.attributes.metadata) { | ||
serialized.data.attributes.metadata = attributes.metadata; | ||
} | ||
// Manually add relationships to the serialized payload. | ||
@@ -499,2 +494,7 @@ // Serializing relationships seems broken in jsonapi-serializer | ||
const commonPayloadAttributes = [ | ||
'reference', | ||
'reference_origin', | ||
'metadata', | ||
]; | ||
const requireId = (id, config) => { | ||
@@ -501,0 +501,0 @@ if (!id) { |
@@ -268,3 +268,3 @@ import axios from 'axios'; | ||
keyForAttribute: 'snake_case', | ||
attributes: config.attributes, | ||
attributes: config.attributes.concat(commonPayloadAttributes), | ||
}); | ||
@@ -277,7 +277,2 @@ const serialized = serializer.serialize(attributes); | ||
} | ||
// Add metadata if original attributes contain it. | ||
// For some reason jsonapi-serializer strips the key | ||
if (attributes.metadata && !serialized.data.attributes.metadata) { | ||
serialized.data.attributes.metadata = attributes.metadata; | ||
} | ||
// Manually add relationships to the serialized payload. | ||
@@ -491,2 +486,7 @@ // Serializing relationships seems broken in jsonapi-serializer | ||
const commonPayloadAttributes = [ | ||
'reference', | ||
'reference_origin', | ||
'metadata', | ||
]; | ||
const requireId = (id, config) => { | ||
@@ -493,0 +493,0 @@ if (!id) { |
@@ -16,9 +16,10 @@ import { RequestQuery, RequestParameters } from './api'; | ||
} | ||
export declare type AttributesPayload<T> = { | ||
[K in keyof T]?: T[K]; | ||
} & { | ||
export interface CommonPayloadAttributes { | ||
reference?: string; | ||
reference_origin?: string; | ||
metadata?: Record<string, any>; | ||
}; | ||
} | ||
export declare type AttributesPayload<T> = { | ||
[K in keyof T]?: T[K]; | ||
} & CommonPayloadAttributes; | ||
export declare type RelationshipsPayload<T> = { | ||
@@ -52,3 +53,4 @@ [K in keyof T]?: T[K] | string; | ||
export declare const commonResourceFields: (keyof CommonResourceAttributes)[]; | ||
export declare const commonPayloadAttributes: (keyof CommonPayloadAttributes)[]; | ||
export declare const createResource: <T, U>(config: ResourceConfig<T, U>) => Resource<T, U, ConcreteResourceInstance<T, U>>; | ||
//# sourceMappingURL=resource.d.ts.map |
{ | ||
"name": "@atoms-studio/commercelayer-sdk", | ||
"version": "0.1.0-alpha.6", | ||
"version": "0.1.0-alpha.7", | ||
"repository": "git@github.com:atoms-studio/commercelayer-sdk.git", | ||
@@ -5,0 +5,0 @@ "author": "atoms.studio", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
165250
3324