@akinon/next 1.21.0-rc.2 → 1.21.0-rc.4

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
@@ -1,5 +1,19 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.21.0-rc.4
4
+
5
+ ### Minor Changes
6
+
7
+ - Revert ZERO-2435
8
+
9
+ ## 1.21.0-rc.3
10
+
11
+ ### Minor Changes
12
+
13
+ - af8e38e0: ZERO-2247: Add additionalParams to MasterpassProvider and set them in buildPurchaseForm and buildDirectPurchaseForm
14
+ - 16027410: ZERO-2451: Refactor extraHeaders assignment in client.ts
15
+ - 9edd725b: Datalayer init changed to 3rd party script. Declare is the same as next
16
+
3
17
  ## 1.21.0-rc.2
4
18
 
5
19
  ### Minor Changes
package/api/client.ts CHANGED
@@ -43,13 +43,18 @@ async function proxyRequest(...args) {
43
43
  urlSearchParams.append(key, `${searchParams.get(key)}`);
44
44
  });
45
45
 
46
- const extraHeaders = Object.fromEntries(req.headers.entries());
46
+ const extraHeaders: Record<string, string> = {};
47
+
48
+ for (const [key, value] of Array.from(req.headers.entries())) {
49
+ extraHeaders[key.toLowerCase()] = value;
50
+ }
47
51
 
48
52
  [
49
53
  'x-forwarded-host',
50
54
  'x-forwarded-for',
51
55
  'x-forwarded-proto',
52
56
  'x-forwarded-port',
57
+ 'x-requested-with',
53
58
  'origin',
54
59
  'host',
55
60
  'referer',
@@ -1,40 +1,39 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
1
4
  const path = require('path');
5
+ const rootDir = path.resolve(process.cwd());
2
6
  const spawn = require('cross-spawn');
7
+ const availablePlugins = require('../plugins');
3
8
 
4
- function findBaseDir() {
5
- const insideNodeModules = __dirname.includes('node_modules');
6
- return insideNodeModules
7
- ? path.resolve(__dirname, '../../../../')
8
- : path.resolve(__dirname, '../../../apps/projectzeronext');
9
- }
10
-
11
- const BASE_DIR = findBaseDir();
9
+ let plugins;
12
10
 
13
- const getFullPath = (relativePath) => path.join(BASE_DIR, relativePath);
11
+ try {
12
+ plugins = require(path.resolve(rootDir, './src/plugins.js'));
13
+ } catch (error) {
14
+ console.error('No plugins.js file found, skipping plugin installation.');
15
+ process.exit(0);
16
+ }
14
17
 
15
- const packageJsonPath = getFullPath('package.json');
16
- const akinonPackageNumber = require(packageJsonPath).dependencies[
17
- '@akinon/next'
18
- ].replace('^', '');
19
- //just in case
18
+ let installCmd = [];
20
19
 
21
- const availablePlugins = require('../plugins');
20
+ availablePlugins
21
+ .filter((p) => plugins?.includes(p))
22
+ .forEach((name) => {
23
+ installCmd.push(`@akinon/${name}`);
24
+ });
22
25
 
23
- let installCmd = availablePlugins.map(
24
- (name) => `@akinon/${name}@${akinonPackageNumber}`
25
- );
26
+ spawn.sync('yarn', ['cache clean']);
26
27
 
27
- spawn.sync('yarn', ['cache clean'], { stdio: 'inherit', cwd: BASE_DIR });
28
+ for (const plugin of availablePlugins) {
29
+ spawn.sync('yarn', ['remove', `@akinon/${plugin}`]);
30
+ }
28
31
 
29
- availablePlugins.forEach((plugin) => {
30
- spawn.sync('yarn', ['remove', `@akinon/${plugin}`], {
31
- stdio: 'inherit',
32
- cwd: BASE_DIR
32
+ if (
33
+ installCmd.length > 0 &&
34
+ !fs.existsSync(path.resolve(rootDir, '../../turbo.json'))
35
+ ) {
36
+ spawn.sync('yarn', ['add', ...installCmd, '--ignore-scripts'], {
37
+ stdio: 'inherit'
33
38
  });
34
- });
35
-
36
- if (installCmd.length > 0) {
37
- const yarnArgs = ['add', ...installCmd, '--ignore-scripts'];
38
-
39
- spawn.sync('yarn', yarnArgs, { stdio: 'inherit', cwd: BASE_DIR });
40
39
  }
File without changes
File without changes
package/bin/pz-postdev.js CHANGED
File without changes
File without changes
File without changes
File without changes
package/bin/pz-predev.js CHANGED
File without changes
File without changes
@@ -83,12 +83,18 @@ const completeMasterpassPayment = async (
83
83
  reduxStore: AppStore
84
84
  ) => {
85
85
  const state = reduxStore.getState();
86
- const { token, order_no } = context.page_context;
86
+ const { token, order_no, extras } = context.page_context;
87
87
  const { endpoints: apiEndpoints } = checkoutApi;
88
88
  const { preOrder } = state.checkout ?? {};
89
89
 
90
- const { isDirectPurchase, referenceNo, credentials, msisdn, selectedCard } =
91
- state.masterpass ?? {};
90
+ const {
91
+ isDirectPurchase,
92
+ referenceNo,
93
+ credentials,
94
+ msisdn,
95
+ selectedCard,
96
+ additionalParams
97
+ } = state.masterpass ?? {};
92
98
 
93
99
  const commonFormValues = {
94
100
  token,
@@ -96,12 +102,16 @@ const completeMasterpassPayment = async (
96
102
  referenceNo,
97
103
  merchantId: credentials?.merchant_id ?? null,
98
104
  msisdn,
99
- amount: preOrder?.unpaid_amount?.replace('.', '') ?? ''
105
+ amount: preOrder?.unpaid_amount?.replace('.', '') ?? '',
106
+ additionalParams: additionalParams ?? extras?.additionalParams
100
107
  };
101
108
 
102
109
  const form = isDirectPurchase
103
110
  ? await buildDirectPurchaseForm(commonFormValues, params)
104
- : await buildPurchaseForm({ ...commonFormValues, selectedCard });
111
+ : await buildPurchaseForm({
112
+ ...commonFormValues,
113
+ selectedCard
114
+ });
105
115
 
106
116
  window.MFS?.[
107
117
  state.masterpass.isDirectPurchase ? 'directPurchase' : 'purchase'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@akinon/next",
3
3
  "description": "Core package for Project Zero Next",
4
- "version": "1.21.0-rc.2",
4
+ "version": "1.21.0-rc.4",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -32,7 +32,7 @@
32
32
  "@typescript-eslint/eslint-plugin": "6.7.4",
33
33
  "@typescript-eslint/parser": "6.7.4",
34
34
  "eslint": "^8.14.0",
35
- "@akinon/eslint-plugin-projectzero": "1.21.0-rc.2",
35
+ "@akinon/eslint-plugin-projectzero": "1.21.0-rc.4",
36
36
  "eslint-config-prettier": "8.5.0"
37
37
  }
38
38
  }
package/types/index.ts CHANGED
@@ -4,8 +4,11 @@ import { Control, FieldError } from 'react-hook-form';
4
4
  import { ReactNode } from 'react';
5
5
 
6
6
  declare global {
7
- export interface Window {
8
- dataLayer: Record<string, any>[];
7
+ interface Window {
8
+ // we did it like this because declare types needs to be identical, if not it will fail
9
+ // eslint-disable-next-line @typescript-eslint/ban-types
10
+ dataLayer?: Object[];
11
+ [key: string]: any;
9
12
  }
10
13
  }
11
14