rest-client-sdk 7.2.3 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/dist/index.cjs +23 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +23 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/client/AbstractClient.d.ts +9 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -207,13 +207,18 @@ sdk.getRepository('products').create(entity);
|
|
|
207
207
|
|
|
208
208
|
sdk.getRepository('products').update(entity);
|
|
209
209
|
|
|
210
|
+
sdk.getRepository('products').patch(entity);
|
|
211
|
+
|
|
210
212
|
sdk.getRepository('products').delete(entity);
|
|
211
213
|
```
|
|
212
214
|
|
|
213
215
|
All these methods returns promises.
|
|
214
|
-
`create` and `
|
|
216
|
+
`create`, `update` and `patch` returns a `Promise<Entity>` with the new entity.
|
|
215
217
|
`delete` returns `Promise<void>`.
|
|
216
218
|
|
|
219
|
+
`update` and `patch` behave the same way (same arguments, same UnitOfWork
|
|
220
|
+
dirty-field handling) but use the `PUT` and `PATCH` HTTP verbs respectively.
|
|
221
|
+
|
|
217
222
|
### Overriding repository
|
|
218
223
|
|
|
219
224
|
You can override the default repository
|
package/dist/index.cjs
CHANGED
|
@@ -1117,6 +1117,28 @@
|
|
|
1117
1117
|
value: function update(entity) {
|
|
1118
1118
|
var queryParam = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1119
1119
|
var requestParams = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1120
|
+
return this._update('PUT', entity, queryParam, requestParams);
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* partially update an entity using the `PATCH` HTTP verb
|
|
1124
|
+
*
|
|
1125
|
+
* @param {Record<string, unknown>} entity the entity to update
|
|
1126
|
+
* @param {Record<string, unknown>} queryParam query parameters that will be added to the request
|
|
1127
|
+
* @param {Record<string, unknown>} requestParams parameters that will be send as second parameter to the `fetch` call
|
|
1128
|
+
*/
|
|
1129
|
+
|
|
1130
|
+
}, {
|
|
1131
|
+
key: "patch",
|
|
1132
|
+
value: function patch(entity) {
|
|
1133
|
+
var queryParam = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1134
|
+
var requestParams = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1135
|
+
return this._update('PATCH', entity, queryParam, requestParams);
|
|
1136
|
+
}
|
|
1137
|
+
}, {
|
|
1138
|
+
key: "_update",
|
|
1139
|
+
value: function _update(method, entity) {
|
|
1140
|
+
var queryParam = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1141
|
+
var requestParams = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1120
1142
|
var url = new URI(this.getEntityURI(entity));
|
|
1121
1143
|
url.addSearch(queryParam);
|
|
1122
1144
|
var newSerializedModel = this.serializer.normalizeItem(entity, this.metadata);
|
|
@@ -1134,7 +1156,7 @@
|
|
|
1134
1156
|
}
|
|
1135
1157
|
|
|
1136
1158
|
return this.deserializeResponse(this.authorizedFetch(url, _objectSpread2({
|
|
1137
|
-
method:
|
|
1159
|
+
method: method,
|
|
1138
1160
|
body: this.serializer.encodeItem(newSerializedModel, this.metadata)
|
|
1139
1161
|
}, requestParams)), 'item');
|
|
1140
1162
|
}
|