@rebilly/instruments 3.16.0-beta.0 → 3.16.3-beta.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/.eslintrc.js +7 -0
- package/dist/index.js +10 -10
- package/dist/index.min.js +10 -10
- package/package.json +6 -4
- package/service/prefetch/config.mjs +8 -0
- package/service/prefetch/metadata.mjs +35 -0
- package/service/prefetch/prefetch.mjs +9 -0
- package/src/data/payment-methods.json +2886 -0
- package/src/functions/mount/fetch-data.js +1 -8
- package/src/functions/mount/mount.spec.js +1 -1
- package/src/functions/mount/setup-options.js +29 -18
- package/src/functions/mount/setup-options.spec.js +66 -1
- package/src/functions/mount/setup-storefront.js +3 -2
- package/src/storefront/ready-to-pay.js +2 -2
- package/src/storefront/ready-to-pay.spec.js +6 -1
- package/src/views/common/iframe/base-iframe.js +0 -1
- package/src/views/method-selector/get-payment-methods.js +1 -1
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebilly/instruments",
|
|
3
|
-
"version": "3.16.
|
|
3
|
+
"version": "3.16.3-beta.0",
|
|
4
4
|
"author": "Rebilly",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"unpkg": "dist/index.min.js",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"build": "yarn rollup -c --environment NODE_ENV:production",
|
|
10
|
-
"dev": "yarn rollup -c --watch --environment NODE_ENV:development",
|
|
9
|
+
"build": "yarn prefetch && yarn rollup -c --environment NODE_ENV:production",
|
|
10
|
+
"dev": "yarn prefetch && yarn rollup -c --watch --environment NODE_ENV:development",
|
|
11
11
|
"test": "yarn jest",
|
|
12
|
-
"test:watch": "yarn jest --watchAll"
|
|
12
|
+
"test:watch": "yarn jest --watchAll",
|
|
13
|
+
"prefetch": "node --experimental-modules service/prefetch/prefetch.mjs"
|
|
13
14
|
},
|
|
14
15
|
"dependencies": {
|
|
15
16
|
"@babel/cli": "^7.14.5",
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
"@rollup/plugin-json": "^4.1.0",
|
|
32
33
|
"@rollup/plugin-node-resolve": "^8.4.0",
|
|
33
34
|
"@rollup/plugin-replace": "^3.0.0",
|
|
35
|
+
"axios": "^0.27.2",
|
|
34
36
|
"babel-plugin-module-resolver": "^4.1.0",
|
|
35
37
|
"component-emitter": "^1.3.0",
|
|
36
38
|
"core-js": "3.23.3",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
|
|
4
|
+
export default class Metadata {
|
|
5
|
+
constructor({ apiUrl, destinationFile, metaType }) {
|
|
6
|
+
this.apiUrl = apiUrl;
|
|
7
|
+
this.destinationFile = destinationFile;
|
|
8
|
+
this.metaType = metaType;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async saveToDisk(results) {
|
|
12
|
+
const prettifiedResults = JSON.stringify(results, null, 2);
|
|
13
|
+
await fs.writeFile(this.destinationFile, prettifiedResults);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async printFetchLogMessage() {
|
|
17
|
+
console.log(' ');
|
|
18
|
+
console.log(`Fetching ${this.metaType}...`);
|
|
19
|
+
console.log(' ');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async fetch() {
|
|
23
|
+
this.printFetchLogMessage();
|
|
24
|
+
try {
|
|
25
|
+
const { data: results } = await axios.get(this.apiUrl);
|
|
26
|
+
this.saveToDisk(results);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
this.handleError(error);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
handleError(error) {
|
|
33
|
+
console.error(error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { fetchPaymentMethodsSettings } from './config.mjs';
|
|
2
|
+
import Metadata from './metadata.mjs';
|
|
3
|
+
|
|
4
|
+
async function fetchMetadata() {
|
|
5
|
+
const paymentMethodMetadata = new Metadata(fetchPaymentMethodsSettings);
|
|
6
|
+
await paymentMethodMetadata.fetch();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
fetchMetadata();
|