@golstats/gsc-top-player 1.0.16 → 1.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golstats/gsc-top-player",
3
- "version": "1.0.16",
3
+ "version": "1.1.0",
4
4
  "main": "dist/gsc-top-player.umd.js",
5
5
  "module": "dist/gsc-top-player.es.js",
6
6
  "exports": {
@@ -39,7 +39,10 @@
39
39
  "preview": "vite preview",
40
40
  "lint": "eslint . --fix",
41
41
  "format": "prettier --write src/",
42
- "prepublishOnly": "npm run build"
42
+ "prepublishOnly": "npm run build",
43
+ "test:e2e": "playwright test",
44
+ "test:e2e:ui": "playwright test --ui",
45
+ "test:e2e:headed": "playwright test --headed"
43
46
  },
44
47
  "peerDependencies": {
45
48
  "vue": "^3.0.0"
@@ -51,11 +54,12 @@
51
54
  "@golstats/gsc-label": "^1.0.5",
52
55
  "@golstats/gsc-season-select": "^1.0.9",
53
56
  "@golstats/gsc-switch-component": "^1.0.14",
54
- "@golstats/gsc-tournament-select": "^1.0.17",
57
+ "@golstats/gsc-tournament-select": "^1.0.21",
55
58
  "axios": "^1.10.0"
56
59
  },
57
60
  "devDependencies": {
58
61
  "@eslint/js": "^9.22.0",
62
+ "@playwright/test": "^1.59.1",
59
63
  "@vitejs/plugin-vue": "^5.2.3",
60
64
  "@vue/eslint-config-prettier": "^10.2.0",
61
65
  "eslint": "^9.22.0",
package/src/App.vue CHANGED
@@ -49,6 +49,8 @@ const gameData = {
49
49
  :game="gameData"
50
50
  :season="gameData.seasonId"
51
51
  :team-view="1"
52
+ :provider="2"
53
+ :is-dev-apis="false"
52
54
  :use-dummy-data="true"
53
55
  :show-position="true"
54
56
  />
@@ -291,6 +291,7 @@
291
291
 
292
292
  <script>
293
293
  import axios from 'axios'
294
+ import { getApiUrl } from '@/utils/apiUrl.js'
294
295
  import { ref } from 'vue'
295
296
  import useElementSize from './useElementSize'
296
297
  import GSCLeaders from './gsc-header-tops.vue'
@@ -394,6 +395,14 @@ export default {
394
395
  type: Boolean,
395
396
  default: true,
396
397
  },
398
+ provider: {
399
+ type: Number,
400
+ default: 1,
401
+ },
402
+ isDevApis: {
403
+ type: Boolean,
404
+ default: false,
405
+ },
397
406
  },
398
407
  setup() {
399
408
  const myDivRef = ref('myDivRef')
@@ -1134,10 +1143,16 @@ export default {
1134
1143
  this.isloading = true
1135
1144
  let data = {}
1136
1145
  if (this.typeData === 0) {
1137
- data = await axiosInstance.get(this.url + '/' + this.gameId + '/' + this.category)
1146
+ data = await axiosInstance.get(
1147
+ getApiUrl(this.url, this.provider, this.isDevApis) +
1148
+ '/' +
1149
+ this.gameId +
1150
+ '/' +
1151
+ this.category,
1152
+ )
1138
1153
  } else {
1139
1154
  data = await axiosInstance.get(
1140
- this.urlPrematch +
1155
+ getApiUrl(this.urlPrematch, this.provider, this.isDevApis) +
1141
1156
  seasonGet +
1142
1157
  '/' +
1143
1158
  this.category +
@@ -25,6 +25,8 @@
25
25
  :key="updateTables"
26
26
  :dummy-data="dummyData"
27
27
  :show-position="showPosition"
28
+ :provider="provider"
29
+ :is-dev-apis="isDevApis"
28
30
  />
29
31
  </div>
30
32
  </template>
@@ -33,6 +35,7 @@
33
35
 
34
36
  <script>
35
37
  import axios from 'axios'
38
+ import { getApiUrl } from '@/utils/apiUrl.js'
36
39
  import computedProperties from './computedProperties.js'
37
40
  import useElementSize from './useElementSize'
38
41
  import GSCTopCategory from '@/components/comparative/gsc-top.vue'
@@ -173,6 +176,14 @@ export default {
173
176
  type: Boolean,
174
177
  default: true,
175
178
  },
179
+ provider: {
180
+ type: Number,
181
+ default: 1,
182
+ },
183
+ isDevApis: {
184
+ type: Boolean,
185
+ default: false,
186
+ },
176
187
  },
177
188
  watch: {
178
189
  async seasonActive() {
@@ -818,7 +829,11 @@ export default {
818
829
 
819
830
  const axiosInstance = axios.create({ headers: { Authorization: `${this.token}` } })
820
831
  const { data } = await axiosInstance.post(
821
- 'https://eh9nhj69z7.execute-api.us-west-2.amazonaws.com/prod/players/productivity',
832
+ getApiUrl(
833
+ 'https://eh9nhj69z7.execute-api.us-west-2.amazonaws.com/prod/players/productivity',
834
+ this.provider,
835
+ this.isDevApis,
836
+ ),
822
837
  this.filterScounting,
823
838
  { headers: { 'Content-Type': 'application/json' } },
824
839
  )
@@ -1621,7 +1636,9 @@ export default {
1621
1636
  Authorization: `${this.token}`,
1622
1637
  },
1623
1638
  })
1624
- const { data } = await axiosInstance.get(this.tournamentsUrl)
1639
+ const { data } = await axiosInstance.get(
1640
+ getApiUrl(this.tournamentsUrl, this.provider, this.isDevApis),
1641
+ )
1625
1642
  return data
1626
1643
  },
1627
1644
  async fetchTeams() {
@@ -1630,7 +1647,9 @@ export default {
1630
1647
  Authorization: `${this.token}`,
1631
1648
  },
1632
1649
  })
1633
- const { data } = await axiosInstance.get(this.teamsUrl + this.seasonActive)
1650
+ const { data } = await axiosInstance.get(
1651
+ getApiUrl(this.teamsUrl, this.provider, this.isDevApis) + this.seasonActive,
1652
+ )
1634
1653
  return data
1635
1654
  },
1636
1655
  async fetchTeamsScouting(season) {
@@ -1639,7 +1658,9 @@ export default {
1639
1658
  Authorization: `${this.token}`,
1640
1659
  },
1641
1660
  })
1642
- const { data } = await axiosInstance.get(this.teamsUrl + season)
1661
+ const { data } = await axiosInstance.get(
1662
+ getApiUrl(this.teamsUrl, this.provider, this.isDevApis) + season,
1663
+ )
1643
1664
  return data
1644
1665
  },
1645
1666
  async getPredefinedfilters(category) {
@@ -1657,7 +1678,9 @@ export default {
1657
1678
  Authorization: `${this.token}`,
1658
1679
  },
1659
1680
  })
1660
- const { data } = await axiosInstance.get(url + category.id)
1681
+ const { data } = await axiosInstance.get(
1682
+ getApiUrl(url, this.provider, this.isDevApis) + category.id,
1683
+ )
1661
1684
  Object.keys(data[0].match_lapse_combinations).forEach((key) => {
1662
1685
  this.predefinedFiltersMatchLapse[key.toString()] = data[0].match_lapse_combinations[key]
1663
1686
  })
@@ -13,6 +13,8 @@
13
13
  :num-rows="numRows"
14
14
  :dummy-data="dummyData"
15
15
  :show-position="showPosition"
16
+ :provider="provider"
17
+ :is-dev-apis="isDevApis"
16
18
  />
17
19
  </div>
18
20
  </template>
@@ -71,6 +73,14 @@ const props = defineProps({
71
73
  type: Boolean,
72
74
  default: true,
73
75
  },
76
+ provider: {
77
+ type: Number,
78
+ default: 1,
79
+ },
80
+ isDevApis: {
81
+ type: Boolean,
82
+ default: false,
83
+ },
74
84
  })
75
85
 
76
86
  // Si useDummyData es true, usa datos dummy, si es false busca datos reales
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Transforma una URL de API según el proveedor activo.
3
+ *
4
+ * @param {string} originalUrl - URL original hardcodeada en el componente
5
+ * @param {number|null} provider - 0, 1 o null → sin cambio; >= 2 → proveedor externo
6
+ * @param {boolean} isDevApis - false → prod; true → dev
7
+ * @returns {string} - URL final a usar en la petición
8
+ */
9
+ export function getApiUrl(originalUrl, provider, isDevApis) {
10
+ // Regla A: provider es 1, 0 o null → devolver URL sin cambios
11
+ if (provider == null || provider <= 1) {
12
+ return originalUrl
13
+ }
14
+
15
+ // Reglas B y C: provider >= 2
16
+ const base = isDevApis
17
+ ? `https://dev-apis.golstats.com/${provider}/`
18
+ : `https://apis.golstats.com/${provider}/`
19
+
20
+ const parsed = new URL(originalUrl)
21
+
22
+ // Obtener path + query string y eliminar segmento "prod" o "qa" inicial
23
+ let pathWithQuery = parsed.pathname + parsed.search
24
+ pathWithQuery = pathWithQuery.replace(/^\/(prod|qa)\//, '/')
25
+
26
+ // Quitar barra inicial y combinar con la base
27
+ const relativePath = pathWithQuery.replace(/^\//, '')
28
+ return base + relativePath
29
+ }