From 2f0750bfea6d0e1ecc2d9eb17912a2bf5c3bc649 Mon Sep 17 00:00:00 2001 From: Kia Ishii Date: Thu, 31 Oct 2019 20:01:05 +0900 Subject: [PATCH] [Release] 0.8.0 --- dist/vuex-orm-axios.common.js | 35 +++++++++++++++++++------------ dist/vuex-orm-axios.esm.js | 35 +++++++++++++++++++------------ dist/vuex-orm-axios.js | 39 +++++++++++++++++++++-------------- dist/vuex-orm-axios.min.js | 2 +- package.json | 2 +- 5 files changed, 70 insertions(+), 43 deletions(-) diff --git a/dist/vuex-orm-axios.common.js b/dist/vuex-orm-axios.common.js index c5d3e3f..1985d6a 100644 --- a/dist/vuex-orm-axios.common.js +++ b/dist/vuex-orm-axios.common.js @@ -205,27 +205,36 @@ var Request = /** @class */ (function () { Request.prototype.persistResponseData = function (response, config) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { - if (!config.save) { - return [2 /*return*/, null]; - } - if (config.delete !== undefined) { - return [2 /*return*/, this.model.delete(config.delete)]; + switch (_a.label) { + case 0: + if (!config.save) { + return [2 /*return*/, null]; + } + if (!(config.delete !== undefined)) return [3 /*break*/, 2]; + return [4 /*yield*/, this.model.delete(config.delete)]; + case 1: + _a.sent(); + return [2 /*return*/, null]; + case 2: return [2 /*return*/, this.model.insertOrUpdate({ + data: this.getDataFromResponse(response, config) + })]; } - return [2 /*return*/, this.model.insertOrUpdate({ - data: this.getDataFromResponse(response, config) - })]; }); }); }; /** - * Get data from the given response object. If the `dataKey` config is - * provided, it tries to fetch the data at that key. + * Get data from the given response object. If the `dataTransformer` config is + * provided, it tries to execute the method with the response as param. If the + * `dataKey` config is provided, it tries to fetch the data at that key. */ Request.prototype.getDataFromResponse = function (response, config) { - if (!config.dataKey) { - return response.data; + if (config.dataTransformer) { + return config.dataTransformer(response); + } + if (config.dataKey) { + return response.data[config.dataKey]; } - return response.data[config.dataKey]; + return response.data; }; return Request; }()); diff --git a/dist/vuex-orm-axios.esm.js b/dist/vuex-orm-axios.esm.js index 5fef517..55319af 100644 --- a/dist/vuex-orm-axios.esm.js +++ b/dist/vuex-orm-axios.esm.js @@ -203,27 +203,36 @@ var Request = /** @class */ (function () { Request.prototype.persistResponseData = function (response, config) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { - if (!config.save) { - return [2 /*return*/, null]; - } - if (config.delete !== undefined) { - return [2 /*return*/, this.model.delete(config.delete)]; + switch (_a.label) { + case 0: + if (!config.save) { + return [2 /*return*/, null]; + } + if (!(config.delete !== undefined)) return [3 /*break*/, 2]; + return [4 /*yield*/, this.model.delete(config.delete)]; + case 1: + _a.sent(); + return [2 /*return*/, null]; + case 2: return [2 /*return*/, this.model.insertOrUpdate({ + data: this.getDataFromResponse(response, config) + })]; } - return [2 /*return*/, this.model.insertOrUpdate({ - data: this.getDataFromResponse(response, config) - })]; }); }); }; /** - * Get data from the given response object. If the `dataKey` config is - * provided, it tries to fetch the data at that key. + * Get data from the given response object. If the `dataTransformer` config is + * provided, it tries to execute the method with the response as param. If the + * `dataKey` config is provided, it tries to fetch the data at that key. */ Request.prototype.getDataFromResponse = function (response, config) { - if (!config.dataKey) { - return response.data; + if (config.dataTransformer) { + return config.dataTransformer(response); + } + if (config.dataKey) { + return response.data[config.dataKey]; } - return response.data[config.dataKey]; + return response.data; }; return Request; }()); diff --git a/dist/vuex-orm-axios.js b/dist/vuex-orm-axios.js index 442b569..a85f70d 100644 --- a/dist/vuex-orm-axios.js +++ b/dist/vuex-orm-axios.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = global || self, global.VuexORMAxios = factory()); -}(this, function () { 'use strict'; +}(this, (function () { 'use strict'; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. @@ -209,27 +209,36 @@ Request.prototype.persistResponseData = function (response, config) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { - if (!config.save) { - return [2 /*return*/, null]; - } - if (config.delete !== undefined) { - return [2 /*return*/, this.model.delete(config.delete)]; + switch (_a.label) { + case 0: + if (!config.save) { + return [2 /*return*/, null]; + } + if (!(config.delete !== undefined)) return [3 /*break*/, 2]; + return [4 /*yield*/, this.model.delete(config.delete)]; + case 1: + _a.sent(); + return [2 /*return*/, null]; + case 2: return [2 /*return*/, this.model.insertOrUpdate({ + data: this.getDataFromResponse(response, config) + })]; } - return [2 /*return*/, this.model.insertOrUpdate({ - data: this.getDataFromResponse(response, config) - })]; }); }); }; /** - * Get data from the given response object. If the `dataKey` config is - * provided, it tries to fetch the data at that key. + * Get data from the given response object. If the `dataTransformer` config is + * provided, it tries to execute the method with the response as param. If the + * `dataKey` config is provided, it tries to fetch the data at that key. */ Request.prototype.getDataFromResponse = function (response, config) { - if (!config.dataKey) { - return response.data; + if (config.dataTransformer) { + return config.dataTransformer(response); + } + if (config.dataKey) { + return response.data[config.dataKey]; } - return response.data[config.dataKey]; + return response.data; }; return Request; }()); @@ -286,4 +295,4 @@ return index_cjs; -})); +}))); diff --git a/dist/vuex-orm-axios.min.js b/dist/vuex-orm-axios.min.js index 1edbea1..b5be022 100644 --- a/dist/vuex-orm-axios.min.js +++ b/dist/vuex-orm-axios.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).VuexORMAxios=e()}(this,function(){"use strict";var o=function(){return(o=Object.assign||function(t){for(var e,n=1,o=arguments.length;ns[0]&&e[1]s[0]&&e[1]