From d3f3eefeef589a47ffa637c1c20e3dea2665e367 Mon Sep 17 00:00:00 2001 From: Prasit Gebsaap Date: Mon, 13 Feb 2017 22:09:09 +0700 Subject: [PATCH 1/3] Fix fatal error if sync resource with no relationships defined --- .idea/deployment.xml | 21 ++++ .idea/encodings.xml | 6 ++ .idea/jsLibraryMappings.xml | 6 ++ .idea/jsonapi-client.iml | 18 ++++ .idea/misc.xml | 37 ++++++++ .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 ++ .idea/workspace.xml | 185 ++++++++++++++++++++++++++++++++++++ lib/Resource.js | 11 ++- 9 files changed, 293 insertions(+), 5 deletions(-) create mode 100644 .idea/deployment.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/jsLibraryMappings.xml create mode 100644 .idea/jsonapi-client.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml diff --git a/.idea/deployment.xml b/.idea/deployment.xml new file mode 100644 index 0000000..c612655 --- /dev/null +++ b/.idea/deployment.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml new file mode 100644 index 0000000..b8387eb --- /dev/null +++ b/.idea/jsLibraryMappings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/jsonapi-client.iml b/.idea/jsonapi-client.iml new file mode 100644 index 0000000..b313593 --- /dev/null +++ b/.idea/jsonapi-client.iml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0e419d8 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + Blade files + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..83b31d8 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..dbcec16 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + false + false + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1486998430087 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/Resource.js b/lib/Resource.js index 838f18a..0f06766 100644 --- a/lib/Resource.js +++ b/lib/Resource.js @@ -56,11 +56,12 @@ Resource.prototype._getRaw = function() { Resource.prototype._getDelta = function() { var primaryRelations = { }; var relationships = this._getRaw().relationships; - Object.keys(relationships).forEach(function(i) { - if (getMeta(relationships[i]).relation === "foreign") return; - primaryRelations[i] = relationships[i]; - }); - + if (typeof relationships != 'undefined') { + Object.keys(relationships).forEach(function (i) { + if (getMeta(relationships[i]).relation === "foreign") return; + primaryRelations[i] = relationships[i]; + }); + } return { id: this._base.id, type: this._base.type, From 8f640f4da99d218b89bafa5eded5f348603d4281 Mon Sep 17 00:00:00 2001 From: Prasit Gebsaap Date: Mon, 13 Feb 2017 22:10:49 +0700 Subject: [PATCH 2/3] Fix fatal error if sync resource with no relationships defined --- .idea/deployment.xml | 21 ---- .idea/encodings.xml | 6 -- .idea/jsLibraryMappings.xml | 6 -- .idea/jsonapi-client.iml | 18 ---- .idea/misc.xml | 37 -------- .idea/modules.xml | 8 -- .idea/vcs.xml | 6 -- .idea/workspace.xml | 185 ------------------------------------ 8 files changed, 287 deletions(-) delete mode 100644 .idea/deployment.xml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/jsLibraryMappings.xml delete mode 100644 .idea/jsonapi-client.iml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/workspace.xml diff --git a/.idea/deployment.xml b/.idea/deployment.xml deleted file mode 100644 index c612655..0000000 --- a/.idea/deployment.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index 97626ba..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml deleted file mode 100644 index b8387eb..0000000 --- a/.idea/jsLibraryMappings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/jsonapi-client.iml b/.idea/jsonapi-client.iml deleted file mode 100644 index b313593..0000000 --- a/.idea/jsonapi-client.iml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 0e419d8..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - Blade files - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 83b31d8..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index dbcec16..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,185 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - false - false - - - true - DEFINITION_ORDER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1486998430087 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From d6d8a23e40beb01ea863a1b491f55efc17fb63a7 Mon Sep 17 00:00:00 2001 From: Prasit Gebsaap Date: Mon, 13 Feb 2017 22:11:04 +0700 Subject: [PATCH 3/3] Fix fatal error if sync resource with no relationships defined --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index fe5397c..bc9ef43 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ dist/ node_modules npm-debug.log .DS_Store +.idea