Skip to content

Commit 2f0750b

Browse files
committed
[Release] 0.8.0
1 parent 92824c6 commit 2f0750b

5 files changed

+70
-43
lines changed

dist/vuex-orm-axios.common.js

+22-13
Original file line numberDiff line numberDiff line change
@@ -205,27 +205,36 @@ var Request = /** @class */ (function () {
205205
Request.prototype.persistResponseData = function (response, config) {
206206
return __awaiter(this, void 0, void 0, function () {
207207
return __generator(this, function (_a) {
208-
if (!config.save) {
209-
return [2 /*return*/, null];
210-
}
211-
if (config.delete !== undefined) {
212-
return [2 /*return*/, this.model.delete(config.delete)];
208+
switch (_a.label) {
209+
case 0:
210+
if (!config.save) {
211+
return [2 /*return*/, null];
212+
}
213+
if (!(config.delete !== undefined)) return [3 /*break*/, 2];
214+
return [4 /*yield*/, this.model.delete(config.delete)];
215+
case 1:
216+
_a.sent();
217+
return [2 /*return*/, null];
218+
case 2: return [2 /*return*/, this.model.insertOrUpdate({
219+
data: this.getDataFromResponse(response, config)
220+
})];
213221
}
214-
return [2 /*return*/, this.model.insertOrUpdate({
215-
data: this.getDataFromResponse(response, config)
216-
})];
217222
});
218223
});
219224
};
220225
/**
221-
* Get data from the given response object. If the `dataKey` config is
222-
* provided, it tries to fetch the data at that key.
226+
* Get data from the given response object. If the `dataTransformer` config is
227+
* provided, it tries to execute the method with the response as param. If the
228+
* `dataKey` config is provided, it tries to fetch the data at that key.
223229
*/
224230
Request.prototype.getDataFromResponse = function (response, config) {
225-
if (!config.dataKey) {
226-
return response.data;
231+
if (config.dataTransformer) {
232+
return config.dataTransformer(response);
233+
}
234+
if (config.dataKey) {
235+
return response.data[config.dataKey];
227236
}
228-
return response.data[config.dataKey];
237+
return response.data;
229238
};
230239
return Request;
231240
}());

dist/vuex-orm-axios.esm.js

+22-13
Original file line numberDiff line numberDiff line change
@@ -203,27 +203,36 @@ var Request = /** @class */ (function () {
203203
Request.prototype.persistResponseData = function (response, config) {
204204
return __awaiter(this, void 0, void 0, function () {
205205
return __generator(this, function (_a) {
206-
if (!config.save) {
207-
return [2 /*return*/, null];
208-
}
209-
if (config.delete !== undefined) {
210-
return [2 /*return*/, this.model.delete(config.delete)];
206+
switch (_a.label) {
207+
case 0:
208+
if (!config.save) {
209+
return [2 /*return*/, null];
210+
}
211+
if (!(config.delete !== undefined)) return [3 /*break*/, 2];
212+
return [4 /*yield*/, this.model.delete(config.delete)];
213+
case 1:
214+
_a.sent();
215+
return [2 /*return*/, null];
216+
case 2: return [2 /*return*/, this.model.insertOrUpdate({
217+
data: this.getDataFromResponse(response, config)
218+
})];
211219
}
212-
return [2 /*return*/, this.model.insertOrUpdate({
213-
data: this.getDataFromResponse(response, config)
214-
})];
215220
});
216221
});
217222
};
218223
/**
219-
* Get data from the given response object. If the `dataKey` config is
220-
* provided, it tries to fetch the data at that key.
224+
* Get data from the given response object. If the `dataTransformer` config is
225+
* provided, it tries to execute the method with the response as param. If the
226+
* `dataKey` config is provided, it tries to fetch the data at that key.
221227
*/
222228
Request.prototype.getDataFromResponse = function (response, config) {
223-
if (!config.dataKey) {
224-
return response.data;
229+
if (config.dataTransformer) {
230+
return config.dataTransformer(response);
231+
}
232+
if (config.dataKey) {
233+
return response.data[config.dataKey];
225234
}
226-
return response.data[config.dataKey];
235+
return response.data;
227236
};
228237
return Request;
229238
}());

dist/vuex-orm-axios.js

+24-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
33
typeof define === 'function' && define.amd ? define(factory) :
44
(global = global || self, global.VuexORMAxios = factory());
5-
}(this, function () { 'use strict';
5+
}(this, (function () { 'use strict';
66

77
/*! *****************************************************************************
88
Copyright (c) Microsoft Corporation. All rights reserved.
@@ -209,27 +209,36 @@
209209
Request.prototype.persistResponseData = function (response, config) {
210210
return __awaiter(this, void 0, void 0, function () {
211211
return __generator(this, function (_a) {
212-
if (!config.save) {
213-
return [2 /*return*/, null];
214-
}
215-
if (config.delete !== undefined) {
216-
return [2 /*return*/, this.model.delete(config.delete)];
212+
switch (_a.label) {
213+
case 0:
214+
if (!config.save) {
215+
return [2 /*return*/, null];
216+
}
217+
if (!(config.delete !== undefined)) return [3 /*break*/, 2];
218+
return [4 /*yield*/, this.model.delete(config.delete)];
219+
case 1:
220+
_a.sent();
221+
return [2 /*return*/, null];
222+
case 2: return [2 /*return*/, this.model.insertOrUpdate({
223+
data: this.getDataFromResponse(response, config)
224+
})];
217225
}
218-
return [2 /*return*/, this.model.insertOrUpdate({
219-
data: this.getDataFromResponse(response, config)
220-
})];
221226
});
222227
});
223228
};
224229
/**
225-
* Get data from the given response object. If the `dataKey` config is
226-
* provided, it tries to fetch the data at that key.
230+
* Get data from the given response object. If the `dataTransformer` config is
231+
* provided, it tries to execute the method with the response as param. If the
232+
* `dataKey` config is provided, it tries to fetch the data at that key.
227233
*/
228234
Request.prototype.getDataFromResponse = function (response, config) {
229-
if (!config.dataKey) {
230-
return response.data;
235+
if (config.dataTransformer) {
236+
return config.dataTransformer(response);
237+
}
238+
if (config.dataKey) {
239+
return response.data[config.dataKey];
231240
}
232-
return response.data[config.dataKey];
241+
return response.data;
233242
};
234243
return Request;
235244
}());
@@ -286,4 +295,4 @@
286295

287296
return index_cjs;
288297

289-
}));
298+
})));

dist/vuex-orm-axios.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vuex-orm/plugin-axios",
3-
"version": "0.7.0",
3+
"version": "0.8.0",
44
"description": "Vuex ORM plugin for adding smooth integration with axios.",
55
"main": "dist/vuex-orm-axios.common.js",
66
"module": "dist/vuex-orm-axios.esm.js",

0 commit comments

Comments
 (0)