@rebilly/instruments 4.8.0 → 4.8.2

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.
Files changed (139) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/index.js +3 -3
  3. package/dist/index.min.js +3 -3
  4. package/package.json +5 -1
  5. package/.babelrc +0 -26
  6. package/project.json +0 -31
  7. package/rollup.config.mjs +0 -79
  8. package/src/data/options-schema/index.js +0 -112
  9. package/src/data/options-schema/schemas/options-schema.js +0 -448
  10. package/src/events/base-event.js +0 -47
  11. package/src/events/events.spec.js +0 -11
  12. package/src/events/index.js +0 -15
  13. package/src/functions/destroy.js +0 -29
  14. package/src/functions/destroy.spec.js +0 -63
  15. package/src/functions/mount/fetch-data.js +0 -234
  16. package/src/functions/mount/fetch-data.spec.js +0 -317
  17. package/src/functions/mount/get-lead-source-data.js +0 -46
  18. package/src/functions/mount/get-lead-source-data.spec.js +0 -38
  19. package/src/functions/mount/index.js +0 -105
  20. package/src/functions/mount/mount.spec.js +0 -96
  21. package/src/functions/mount/setup-element.js +0 -29
  22. package/src/functions/mount/setup-framepay-theme.js +0 -104
  23. package/src/functions/mount/setup-framepay.js +0 -26
  24. package/src/functions/mount/setup-i18n.js +0 -21
  25. package/src/functions/mount/setup-options.js +0 -100
  26. package/src/functions/mount/setup-options.spec.js +0 -353
  27. package/src/functions/mount/setup-storefront.js +0 -23
  28. package/src/functions/mount/setup-styles-vars.js +0 -30
  29. package/src/functions/mount/setup-user-flow.js +0 -60
  30. package/src/functions/on.js +0 -22
  31. package/src/functions/on.spec.js +0 -75
  32. package/src/functions/purchase.js +0 -173
  33. package/src/functions/purchase.spec.js +0 -80
  34. package/src/functions/setup.js +0 -66
  35. package/src/functions/setup.spec.js +0 -111
  36. package/src/functions/show.js +0 -30
  37. package/src/functions/show.spec.js +0 -62
  38. package/src/functions/update.js +0 -40
  39. package/src/functions/update.spec.js +0 -104
  40. package/src/i18n/en.json +0 -35
  41. package/src/i18n/es.json +0 -32
  42. package/src/i18n/i18n.spec.js +0 -27
  43. package/src/i18n/index.js +0 -59
  44. package/src/index.js +0 -3
  45. package/src/instance.js +0 -48
  46. package/src/instance.spec.js +0 -44
  47. package/src/loader/index.js +0 -145
  48. package/src/loader/loader.spec.js +0 -74
  49. package/src/state/iframes.js +0 -23
  50. package/src/state/index.js +0 -64
  51. package/src/storefront/account-and-website.js +0 -18
  52. package/src/storefront/account-and-website.spec.js +0 -73
  53. package/src/storefront/deposit-requests.js +0 -12
  54. package/src/storefront/fetch-plans-from-addons-bumpOffer.js +0 -30
  55. package/src/storefront/fetch-products-from-plans.js +0 -59
  56. package/src/storefront/fetch-products-from-plans.spec.js +0 -113
  57. package/src/storefront/index.js +0 -78
  58. package/src/storefront/invoices.js +0 -23
  59. package/src/storefront/invoices.spec.js +0 -92
  60. package/src/storefront/models/account-model.js +0 -36
  61. package/src/storefront/models/base-model.js +0 -7
  62. package/src/storefront/models/deposit-request-model.js +0 -24
  63. package/src/storefront/models/invoice-model.js +0 -20
  64. package/src/storefront/models/payment-metadata.js +0 -7
  65. package/src/storefront/models/plan-model.js +0 -94
  66. package/src/storefront/models/product-model.js +0 -3
  67. package/src/storefront/models/ready-to-pay-model.js +0 -76
  68. package/src/storefront/models/summary-model.js +0 -56
  69. package/src/storefront/models/transaction-model.js +0 -16
  70. package/src/storefront/models/website-model.js +0 -3
  71. package/src/storefront/payment-instruments.js +0 -47
  72. package/src/storefront/payment-instruments.spec.js +0 -88
  73. package/src/storefront/purchase.js +0 -60
  74. package/src/storefront/purchase.spec.js +0 -53
  75. package/src/storefront/ready-to-pay.js +0 -96
  76. package/src/storefront/ready-to-pay.spec.js +0 -80
  77. package/src/storefront/storefront.spec.js +0 -14
  78. package/src/storefront/summary.js +0 -114
  79. package/src/storefront/summary.spec.js +0 -136
  80. package/src/storefront/transactions.js +0 -12
  81. package/src/style/base/__snapshots__/theme.spec.js.snap +0 -143
  82. package/src/style/base/default-theme.js +0 -955
  83. package/src/style/base/index.js +0 -688
  84. package/src/style/base/theme.js +0 -30
  85. package/src/style/base/theme.spec.js +0 -19
  86. package/src/style/index.js +0 -11
  87. package/src/style/utils/border.js +0 -47
  88. package/src/style/utils/color-values.js +0 -35
  89. package/src/style/utils/minifyCss.js +0 -14
  90. package/src/utils/add-dom-element.js +0 -17
  91. package/src/utils/format-currency.js +0 -8
  92. package/src/utils/has-valid-css-selector.js +0 -4
  93. package/src/utils/index.js +0 -15
  94. package/src/utils/is-dom-element.js +0 -3
  95. package/src/utils/process-property-as-dom-element.js +0 -31
  96. package/src/utils/quantity.js +0 -47
  97. package/src/utils/sleep.js +0 -5
  98. package/src/views/amount-selector.js +0 -48
  99. package/src/views/common/iframe/base-iframe.js +0 -66
  100. package/src/views/common/iframe/events/change-iframe-src-handler.js +0 -6
  101. package/src/views/common/iframe/events/dispatch-event-handler.js +0 -8
  102. package/src/views/common/iframe/events/resize-component-handler.js +0 -9
  103. package/src/views/common/iframe/events/show-error-handler.js +0 -5
  104. package/src/views/common/iframe/events/stop-loader-handler.js +0 -9
  105. package/src/views/common/iframe/events/update-addons-handler.js +0 -23
  106. package/src/views/common/iframe/events/update-coupons-handler.js +0 -12
  107. package/src/views/common/iframe/events/update-items-handler.js +0 -34
  108. package/src/views/common/iframe/index.js +0 -5
  109. package/src/views/common/iframe/modal-iframe.js +0 -82
  110. package/src/views/common/iframe/view-iframe.js +0 -23
  111. package/src/views/common/render-utilities.js +0 -4
  112. package/src/views/confirmation.js +0 -45
  113. package/src/views/errors.js +0 -115
  114. package/src/views/form.js +0 -61
  115. package/src/views/method-selector/__snapshots__/method-selector.spec.js.snap +0 -135
  116. package/src/views/method-selector/express-methods.js +0 -52
  117. package/src/views/method-selector/generate-digital-wallet.js +0 -53
  118. package/src/views/method-selector/generate-digital-wallet.spec.js +0 -121
  119. package/src/views/method-selector/generate-framepay-config.js +0 -56
  120. package/src/views/method-selector/generate-framepay-config.spec.js +0 -216
  121. package/src/views/method-selector/get-method-data.js +0 -11
  122. package/src/views/method-selector/get-payment-methods.js +0 -25
  123. package/src/views/method-selector/get-payment-methods.spec.js +0 -41
  124. package/src/views/method-selector/index.js +0 -223
  125. package/src/views/method-selector/method-selector.spec.js +0 -20
  126. package/src/views/method-selector/mount-bump-offer.js +0 -120
  127. package/src/views/method-selector/mount-express-methods.js +0 -107
  128. package/src/views/modal.js +0 -103
  129. package/src/views/result.js +0 -24
  130. package/src/views/summary.js +0 -38
  131. package/tests/async-utilities.js +0 -22
  132. package/tests/mocks/framepay-mock.js +0 -15
  133. package/tests/mocks/rebilly-api-mock.js +0 -11
  134. package/tests/mocks/rebilly-instruments-mock.js +0 -141
  135. package/tests/mocks/storefront-api-mock.js +0 -62
  136. package/tests/mocks/storefront-mock.js +0 -20
  137. package/tests/msw/server.js +0 -14
  138. package/tests/setup-test.js +0 -30
  139. package/vitest.config.js +0 -18
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@rebilly/instruments",
3
- "version": "4.8.0",
3
+ "version": "4.8.2",
4
4
  "author": "Rebilly",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "unpkg": "dist/index.min.js",
8
+ "files": [
9
+ "dist",
10
+ "CHANGELOG.md"
11
+ ],
8
12
  "scripts": {
9
13
  "build": "yarn rollup -c --environment NODE_ENV:production",
10
14
  "dev": "yarn rollup -c --watch --environment NODE_ENV:development",
package/.babelrc DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "presets": [
3
- [
4
- "@babel/preset-env",
5
- {
6
- "targets": {
7
- "chrome": 70
8
- },
9
- "useBuiltIns": "usage",
10
- "corejs": "3.23.3"
11
- }
12
- ]
13
- ],
14
- "plugins": [
15
- [
16
- "module-resolver",
17
- {
18
- "root": ["./"],
19
- "alias": {
20
- "@": "./src/",
21
- "test": "./test"
22
- }
23
- }
24
- ]
25
- ]
26
- }
package/project.json DELETED
@@ -1,31 +0,0 @@
1
- {
2
- "name": "instruments/core",
3
- "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
- "projectType": "library",
5
- "sourceRoot": "apps/instruments/core",
6
- "targets": {
7
- "semantic-release": {
8
- "executor": "@theunderscorer/nx-semantic-release:semantic-release",
9
- "options": {
10
- "plugins": [
11
- [
12
- "@semantic-release/exec",
13
- {
14
- "publishCmd": "node ../../../publish-to-s3.js ${nextRelease.version} ./dist/index.min.js core.js instruments",
15
- "execCwd": "${PROJECT_DIR}"
16
- }
17
- ]
18
- ]
19
- }
20
- },
21
- "lint:no-fix": {
22
- "executor": "nx:run-script",
23
- "options": {
24
- "script": "lint:no-fix"
25
- },
26
- "dependsOn": [
27
- "^build"
28
- ]
29
- }
30
- }
31
- }
package/rollup.config.mjs DELETED
@@ -1,79 +0,0 @@
1
- import { babel } from '@rollup/plugin-babel';
2
- import resolve from '@rollup/plugin-node-resolve';
3
- import commonjs from '@rollup/plugin-commonjs';
4
- import json from '@rollup/plugin-json';
5
- import replace from '@rollup/plugin-replace';
6
- import nodePolyfills from 'rollup-plugin-polyfill-node';
7
- import ignore from 'rollup-plugin-ignore';
8
- import versionInjector from 'rollup-plugin-version-injector';
9
- import { builtinModules } from 'module';
10
- import { terser } from 'rollup-plugin-terser';
11
-
12
- const isDevMode = process.env.NODE_ENV === 'development';
13
-
14
- const buildOptions = () => {
15
- const options = [
16
- // Locates a module in the project's node_modules
17
- resolve({
18
- extensions: ['.mjs', '.js', '.jsx', '.json'],
19
- preferBuiltins: true,
20
- mainFields: ['browser', 'jsnext:main', 'module', 'main'],
21
- }),
22
- // Converts CommonJS to ES6 modules
23
- commonjs(),
24
- // Fix commonjs issues with virtual node
25
- // https://github.com/proteriax/rollup-plugin-ignore/issues/3
26
- // https://github.com/rollup/plugins/issues/248
27
- // https://github.com/rollup/rollup-plugin-commonjs/issues/315
28
- ignore(builtinModules, { commonjsBugFix: true }),
29
- // Replace values at bundle time
30
- replace({
31
- preventAssignment: true,
32
- 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
33
- }),
34
- // Allows the use of named imports in addition to the default import on node modules
35
- nodePolyfills(),
36
- // Babel transpiling
37
- babel({
38
- exclude: 'node_modules/**',
39
- babelHelpers: 'runtime',
40
- skipPreflightCheck: true,
41
- }),
42
- // Converts .json files to ES6 modules
43
- json(),
44
- ];
45
- if (!isDevMode) {
46
- options.push(
47
- // Inject version from package.json (RebillyInstruments.version)
48
- versionInjector(),
49
- // Minify and reduce bundle file sizes
50
- terser(),
51
- );
52
- }
53
- return options;
54
- };
55
-
56
- const buildOutput = () => {
57
- const output = [
58
- {
59
- file: 'dist/index.js',
60
- format: 'es',
61
- sourcemap: isDevMode ? 'inline' : false,
62
- },
63
- ];
64
- if (!isDevMode) {
65
- output.push({
66
- file: 'dist/index.min.js',
67
- format: 'iife',
68
- name: 'RebillyInstruments',
69
- exports: 'default',
70
- });
71
- }
72
- return output;
73
- };
74
-
75
- export default {
76
- input: 'src/index.js',
77
- output: [...buildOutput()],
78
- plugins: [...buildOptions()],
79
- };
@@ -1,112 +0,0 @@
1
- import AJV from 'ajv/dist/2019';
2
- import schema from './schemas/options-schema';
3
-
4
- export class RebillyInstrumentsConfigError extends Error {
5
- constructor(message) {
6
- super(message);
7
- this.name = 'Rebilly Instruments Configuration Error';
8
- }
9
-
10
- trimStack() {
11
- Error.captureStackTrace(this, RebillyInstrumentsConfigError);
12
- return this;
13
- }
14
- }
15
-
16
- const ajv = new AJV({
17
- allErrors: true,
18
- removeAdditional: true,
19
- useDefaults: true,
20
- });
21
- const validate = ajv.compile(schema);
22
-
23
- export function sanitize(data) {
24
- // cast data to be only json object
25
- return JSON.parse(JSON.stringify(data));
26
- }
27
-
28
- export function validateOptions(data) {
29
- const sanitizedData = sanitize(data);
30
- const valid = validate(sanitizedData);
31
- if (valid) {
32
- return sanitizedData;
33
- }
34
-
35
- validate.errors.forEach((error) => {
36
- let errorMessage = ``;
37
- let instancePathReadable = error.instancePath
38
- .substring(1)
39
- .replace(/\//gi, '.');
40
- instancePathReadable = instancePathReadable.replace(
41
- /\.\d+/gi,
42
- (match) => `[${match.replace('.', '')}]`,
43
- );
44
- if (!instancePathReadable.length) {
45
- instancePathReadable = 'options';
46
- }
47
-
48
- let nodes;
49
- let schemaPath;
50
- let value;
51
- switch (error.keyword) {
52
- case 'if':
53
- case 'false schema':
54
- // ignore keywords
55
- break;
56
- case 'required':
57
- if (error.schemaPath.match(/(oneOf|anyOf)/)) {
58
- // ignore and allow their oneOf or anyOf keywords to handle error message
59
- break;
60
- }
61
- errorMessage = `${instancePathReadable} ${error.message}`;
62
- break;
63
- case 'oneOf':
64
- case 'anyOf':
65
- console.error(
66
- new RebillyInstrumentsConfigError(
67
- `${instancePathReadable} ${error.message}, see schemas below.`,
68
- ).trimStack(),
69
- );
70
- schemaPath = error.schemaPath.replace('#/', '').split('/');
71
- nodes = schema;
72
- schemaPath.forEach((item) => {
73
- nodes = nodes[item];
74
- });
75
- nodes.forEach((node) => {
76
- const displayNode = JSON.stringify(node, null, 2);
77
- console.error(
78
- `${instancePathReadable} ${error.keyword} schema.\n${displayNode}`,
79
- );
80
- });
81
- break;
82
- case 'enum':
83
- value = instancePathReadable
84
- .split('.')
85
- .reduce((acc, key) => acc[key], data);
86
- errorMessage = `${instancePathReadable} ${error.message}: ${error.params.allowedValues}. received: ${value}`;
87
- break;
88
- case 'dependentRequired':
89
- case 'maxLength':
90
- case 'minItems':
91
- case 'pattern':
92
- errorMessage = `${instancePathReadable} ${error.message}`;
93
- break;
94
- default:
95
- errorMessage = `Error with ${instancePathReadable} - See error message`;
96
- console.error(error);
97
- break;
98
- }
99
- if (errorMessage) {
100
- console.error(
101
- new RebillyInstrumentsConfigError(errorMessage).trimStack(),
102
- );
103
- }
104
- });
105
-
106
- console.error(
107
- new RebillyInstrumentsConfigError(
108
- 'Configuration is invalid',
109
- ).trimStack(),
110
- );
111
- return undefined;
112
- }