@apolitical/sdk 0.0.1-beta.8 → 0.0.4-beta.1

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/CHANGELOG.md CHANGED
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.0.4] - 2022-01-31
9
+ ### Fixed
10
+ - Buffer dependency
11
+ - Node.js version
12
+
13
+ ## [0.0.3] - 2022-01-12
14
+ ### Added
15
+ - Exposed `reportError` function
16
+ ### Fixed
17
+ - Resources naming (must be plural)
8
18
 
9
19
  ## [0.0.2] - 2022-01-06
10
20
  ### Added
package/README.md CHANGED
@@ -6,7 +6,7 @@ Browser library to interact with Apolitical's APIs
6
6
 
7
7
  Requires the following to run:
8
8
 
9
- - [node.js][node] 12.20.1+
9
+ - [node.js][node] 16.13.0+
10
10
  - [yarn][yarn]
11
11
 
12
12
  [node]: https://nodejs.org/en/download/
@@ -38,11 +38,22 @@ Publishes the library to NPM.
38
38
 
39
39
  ## Usage
40
40
 
41
- The recommended way to use `@apolitical/sdk` is to use the provided functionality:
41
+ The recommended way to use `@apolitical/sdk` is to load the SDK first:
42
42
 
43
43
  ```js
44
- const { ping } = require('@apolitical/sdk');
44
+ const loadSdk = require('@apolitical/sdk');
45
45
 
46
- const result = ping();
47
- console.log(result);
46
+ const sdk = loadSdk({
47
+ origin: window.origin || window.location.origin,
48
+ gcpErrorsApiKey: process.env.REACT_APP_GCP_ERRORS_API_KEY,
49
+ serviceName: 'some-service',
50
+ });
51
+ ```
52
+
53
+ And then, you can use all the functionality provided by the SDK. For example:
54
+
55
+ ```js
56
+ sdk.template.dummy.read().then((result) => {
57
+ console.info('SDK ping:', result);
58
+ });
48
59
  ```
package/build/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("@apolitical/error-reporting"),require("axios"),require("http-status-codes")):"function"==typeof define&&define.amd?define(["@apolitical/error-reporting","axios","http-status-codes"],r):"object"==typeof exports?exports.ApoliticalSDK=r(require("@apolitical/error-reporting"),require("axios"),require("http-status-codes")):e.ApoliticalSDK=r(e["@apolitical/error-reporting"],e.axios,e["http-status-codes"])}(this,(function(e,r,t){return function(){"use strict";var o={30:function(r){r.exports=e},300:function(e){e.exports=r},25:function(e){e.exports=t}},n={};function a(e){var r=n[e];if(void 0!==r)return r.exports;var t=n[e]={exports:{}};return o[e](t,t.exports,a),t.exports}a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,{a:r}),r},a.d=function(e,r){for(var t in r)a.o(r,t)&&!a.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return function(){a.r(i),a.d(i,{default:function(){return E}});var e=a(30),r=a(300),t=a.n(r),o={APIS:{BACKEND_TEMPLATE:{BASE_URL:"/api/backend-template",ENDPOINTS:{DUMMY:"/dummy"}},PEOPLE_API:{BASE_URL:"/api/people-api",ENDPOINTS:{USERS:"/users"}}}},n=a(25);const s=async r=>{try{let t=!1,o="Error at Apolitical SDK: ";if(r.response){switch(r.response.status){case n.StatusCodes.NOT_FOUND:case n.StatusCodes.FORBIDDEN:t=!0}o+=JSON.stringify(r.response)}else r.request?o+=JSON.stringify(r.request):o+=r.message;if(console.warn(o),t)return;await(0,e.reportError)(new Error(o))}catch(e){console.warn(`Cannot handle error: ${e.message}`)}},{APIS:{PEOPLE_API:{BASE_URL:u,ENDPOINTS:{USERS:c}}}}=o;var p={user:{read:async e=>{let r=null;try{({data:r}=await t().get(`${u}${c}/${e}`))}catch(e){await s(e)}return r}}};const{APIS:{BACKEND_TEMPLATE:{BASE_URL:l,ENDPOINTS:{DUMMY:f}}}}=o;var d={people:p,template:{dummy:{read:async()=>{let e=null;try{({data:e}=await t().get(`${l}${f}`))}catch(e){await s(e)}return e}}}};function E({origin:r,gcpErrorsApiKey:t,serviceName:o}){return(0,e.setContext)({origin:r,accessToken:t,serviceName:o}),{...d,reportError:e.reportError}}}(),i}()}));
1
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("@apolitical/error-reporting"),require("axios"),require("http-status-codes")):"function"==typeof define&&define.amd?define(["@apolitical/error-reporting","axios","http-status-codes"],r):"object"==typeof exports?exports.ApoliticalSDK=r(require("@apolitical/error-reporting"),require("axios"),require("http-status-codes")):e.ApoliticalSDK=r(e["@apolitical/error-reporting"],e.axios,e["http-status-codes"])}(this,(function(e,r,t){return function(){"use strict";var o={30:function(r){r.exports=e},300:function(e){e.exports=r},25:function(e){e.exports=t}},n={};function a(e){var r=n[e];if(void 0!==r)return r.exports;var t=n[e]={exports:{}};return o[e](t,t.exports,a),t.exports}a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,{a:r}),r},a.d=function(e,r){for(var t in r)a.o(r,t)&&!a.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return function(){a.r(i),a.d(i,{default:function(){return E},reportError:function(){return e.reportError}});var e=a(30),r=a(300),t=a.n(r),o={APIS:{BACKEND_TEMPLATE:{BASE_URL:"/api/backend-template",ENDPOINTS:{DUMMY:"/dummy"}},PEOPLE_API:{BASE_URL:"/api/people-api",ENDPOINTS:{USERS:"/users"}}}},n=a(25);const s=async r=>{try{let t=!1,o="Error at Apolitical SDK: ";if(r.response){switch(r.response.status){case n.StatusCodes.NOT_FOUND:case n.StatusCodes.FORBIDDEN:t=!0}o+=JSON.stringify(r.response)}else r.request?o+=JSON.stringify(r.request):o+=r.message;if(console.warn(o),t)return;await(0,e.reportError)(new Error(o))}catch(e){console.warn(`Cannot handle error: ${e.message}`)}},{APIS:{PEOPLE_API:{BASE_URL:u,ENDPOINTS:{USERS:c}}}}=o;var p={users:{read:async e=>{let r=null;try{({data:r}=await t().get(`${u}${c}/${e}`))}catch(e){await s(e)}return r}}};const{APIS:{BACKEND_TEMPLATE:{BASE_URL:l,ENDPOINTS:{DUMMY:f}}}}=o;var d={people:p,template:{dummy:{read:async()=>{let e=null;try{({data:e}=await t().get(`${l}${f}`))}catch(e){await s(e)}return e}}}};function E({origin:r,gcpErrorsApiKey:t,serviceName:o}){return(0,e.setContext)({origin:r,accessToken:t,serviceName:o}),{...d,reportError:e.reportError}}}(),i}()}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apolitical/sdk",
3
- "version": "0.0.1-beta.8",
3
+ "version": "0.0.4-beta.1",
4
4
  "description": "Browser library to interact with Apolitical's APIs",
5
5
  "author": "Apolitical Group Limited <engineering@apolitical.co>",
6
6
  "license": "MIT",
@@ -24,27 +24,27 @@
24
24
  "SDK"
25
25
  ],
26
26
  "dependencies": {
27
- "@apolitical/error-reporting": "0.0.1",
28
- "axios": "0.24.0",
27
+ "@apolitical/error-reporting": "0.0.3-beta.1",
28
+ "axios": "0.25.0",
29
29
  "http-status-codes": "2.2.0"
30
30
  },
31
31
  "peerDependencies": {
32
- "@apolitical/error-reporting": "0.0.1",
33
- "axios": "0.24.0",
32
+ "@apolitical/error-reporting": "0.0.3-beta.1",
33
+ "axios": "0.25.0",
34
34
  "http-status-codes": "2.2.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@apolitical/eslint-config": "0.0.1",
38
- "@babel/core": "7.16.7",
39
- "babel-eslint": "10.1.0",
40
- "babel-loader": "8.2.3",
41
- "babel-preset-react-app": "10.0.1",
37
+ "@apolitical/eslint-config": "1.0.2-beta.1",
38
+ "@babel/core": "7.16.12",
39
+ "@babel/eslint-parser": "7.16.5",
40
+ "@babel/plugin-transform-runtime": "7.16.10",
41
+ "@babel/preset-env": "7.16.11",
42
42
  "husky": "7.0.4",
43
43
  "jest": "27.4.7",
44
44
  "jest-junit": "13.0.0",
45
- "lint-staged": "12.1.7",
46
- "webpack": "5.65.0",
47
- "webpack-cli": "4.9.1"
45
+ "lint-staged": "12.3.2",
46
+ "webpack": "5.67.0",
47
+ "webpack-cli": "4.9.2"
48
48
  },
49
49
  "eslintConfig": {
50
50
  "extends": [
@@ -61,7 +61,7 @@
61
61
  "plugins": [
62
62
  "jest"
63
63
  ],
64
- "parser": "babel-eslint"
64
+ "parser": "@babel/eslint-parser"
65
65
  },
66
66
  "prettier": "@apolitical/eslint-config/prettier.config",
67
67
  "browserslist": {
@@ -93,11 +93,14 @@
93
93
  },
94
94
  "babel": {
95
95
  "presets": [
96
- "react-app"
96
+ "@babel/preset-env"
97
+ ],
98
+ "plugins": [
99
+ "@babel/plugin-transform-runtime"
97
100
  ]
98
101
  },
99
102
  "engines": {
100
- "node": ">=12.20.1"
103
+ "node": ">=16.13.0"
101
104
  },
102
105
  "lint-staged": {
103
106
  "*.js": "eslint --cache --fix --ignore-path .gitignore",