@nside/wefa 0.1.0 → 0.2.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.
Files changed (31) hide show
  1. package/dist/{LegalConsent-Cn3qx30k.cjs → LegalConsent-CT1w5kme.cjs} +1 -1
  2. package/dist/{LegalConsent-pUADprVB.js → LegalConsent-D1MwmijD.js} +2 -2
  3. package/dist/{LegalDocument-CU8uyoKh.cjs → LegalDocument-BIlRd478.cjs} +14 -14
  4. package/dist/{LegalDocument-BHtPY9AH.js → LegalDocument-Cg2xX6Mz.js} +4 -4
  5. package/dist/{apiClient-B6fJs4NI.cjs → apiClient-Bd4jmhT7.cjs} +1 -1
  6. package/dist/{apiClient-BAzNCKuU.js → apiClient-WXmPkrC5.js} +1 -1
  7. package/dist/{axios-C7yNV7KF.js → axios-C8xtaJSd.js} +157 -139
  8. package/dist/{axios-BompFBxL.cjs → axios-_3J2k8TN.cjs} +6 -6
  9. package/dist/{index-D7KjmN8m.cjs → index-BLnxyq8L.cjs} +1 -1
  10. package/dist/{index-CeYaMyhs.cjs → index-BZN-ifZE.cjs} +1 -1
  11. package/dist/{index-yOMKz8lD.cjs → index-CS8kqiJC.cjs} +1 -1
  12. package/dist/{index-jIUtvXF6.js → index-DIyoXwWo.js} +1 -1
  13. package/dist/{index--nRVi6aV.js → index-DclCrvhX.js} +1 -1
  14. package/dist/{index-BVwluHCk.js → index-_75ekX9o.js} +1 -1
  15. package/dist/{lib-BEVtXpEW.cjs → lib-B0OhMW6t.cjs} +4 -4
  16. package/dist/{lib-CA1k4S8X.js → lib-I1PMgFxW.js} +17 -14
  17. package/dist/lib.cjs +1 -1
  18. package/dist/lib.d.ts +6 -3
  19. package/dist/lib.js +1 -1
  20. package/dist/network.cjs +1 -1
  21. package/dist/network.d.ts +2 -2
  22. package/dist/network.js +3 -3
  23. package/package.json +30 -30
  24. package/src/components/PlotlyComponent/PlotlyFromTableComponent.mdx +182 -108
  25. package/src/components/PlotlyComponent/PlotlyFromTableComponent.spec.ts +24 -17
  26. package/src/components/PlotlyComponent/PlotlyFromTableComponent.stories.ts +99 -36
  27. package/src/components/PlotlyComponent/PlotlyFromTableComponent.vue +18 -10
  28. package/src/components/TableComponent/TableComponent.spec.ts +0 -1
  29. package/src/network/typedApiClient.ts +3 -2
  30. package/src/plugins/legalConsent/views/__tests__/LegalConsent.test.ts +9 -4
  31. package/src/utils/componentRegistry.ts +0 -1
@@ -20,8 +20,12 @@ const sampleTableData = [
20
20
  ]
21
21
 
22
22
  const basicConfig = {
23
- x: 'month',
24
- y: 'consumption',
23
+ data: [
24
+ {
25
+ xKey: 'month',
26
+ yKey: 'consumption',
27
+ },
28
+ ],
25
29
  layout: {
26
30
  title: 'Test Chart',
27
31
  xaxis: { title: 'Month' },
@@ -87,13 +91,15 @@ describe('PlotlyFromTableComponent', () => {
87
91
 
88
92
  it('applies trace configuration correctly', () => {
89
93
  const configWithTrace = {
90
- x: 'month',
91
- y: 'consumption',
92
- traceConfig: {
93
- type: 'bar',
94
- name: 'Monthly Consumption',
95
- marker: { color: 'blue' },
96
- },
94
+ data: [
95
+ {
96
+ xKey: 'month',
97
+ yKey: 'consumption',
98
+ type: 'bar',
99
+ name: 'Monthly Consumption',
100
+ marker: { color: 'blue' },
101
+ },
102
+ ],
97
103
  }
98
104
 
99
105
  const wrapper = mount(PlotlyFromTableComponent, {
@@ -135,8 +141,12 @@ describe('PlotlyFromTableComponent', () => {
135
141
 
136
142
  it('passes config configuration to PlotlyComponent', () => {
137
143
  const configWithPlotlyConfig = {
138
- x: 'month',
139
- y: 'consumption',
144
+ data: [
145
+ {
146
+ xKey: 'month',
147
+ yKey: 'consumption',
148
+ },
149
+ ],
140
150
  config: {
141
151
  displayModeBar: false,
142
152
  responsive: true,
@@ -161,8 +171,7 @@ describe('PlotlyFromTableComponent', () => {
161
171
 
162
172
  it('handles missing columns gracefully', () => {
163
173
  const configWithMissingColumn = {
164
- x: 'nonexistent',
165
- y: 'consumption',
174
+ data: [{ xKey: 'nonexistent', yKey: 'consumption' }],
166
175
  }
167
176
 
168
177
  const wrapper = mount(PlotlyFromTableComponent, {
@@ -221,8 +230,7 @@ describe('PlotlyFromTableComponent', () => {
221
230
 
222
231
  // Change to different columns
223
232
  const newConfig = {
224
- x: 'temperature',
225
- y: 'consumption',
233
+ data: [{ xKey: 'temperature', yKey: 'consumption' }],
226
234
  }
227
235
 
228
236
  await wrapper.setProps({ config: newConfig })
@@ -263,8 +271,7 @@ describe('PlotlyFromTableComponent', () => {
263
271
  ]
264
272
 
265
273
  const numericConfig = {
266
- x: 'x_val',
267
- y: 'y_val',
274
+ data: [{ xKey: 'x_val', yKey: 'y_val' }],
268
275
  }
269
276
 
270
277
  const wrapper = mount(PlotlyFromTableComponent, {
@@ -66,12 +66,27 @@ const timeSeriesData = [
66
66
  { timestamp: '2024-01-01T05:00:00Z', power: 1080, voltage: 232 },
67
67
  ]
68
68
 
69
+ const timeSeriesData2 = [
70
+ { timestamp: '2024-01-01T00:00:00Z', forecast: 1200, actual: 1100 },
71
+ { timestamp: '2024-01-01T01:00:00Z', forecast: 1120, actual: 1050 },
72
+ { timestamp: '2024-01-01T02:00:00Z', forecast: 1100, actual: 1250 },
73
+ { timestamp: '2024-01-01T03:00:00Z', forecast: 1050, actual: 1200 },
74
+ { timestamp: '2024-01-01T04:00:00Z', forecast: 1100, actual: 1250 },
75
+ { timestamp: '2024-01-01T05:00:00Z', forecast: 1080, actual: 1200 },
76
+ { timestamp: '2024-01-01T06:00:00Z', forecast: 1000 },
77
+ { timestamp: '2024-01-01T07:00:00Z', forecast: 1080 },
78
+ ]
79
+
69
80
  export const BasicLineChart: Story = {
70
81
  args: {
71
82
  value: energyConsumptionData,
72
83
  config: {
73
- x: 'month',
74
- y: 'consumption',
84
+ data: [
85
+ {
86
+ xKey: 'month',
87
+ yKey: 'consumption',
88
+ },
89
+ ],
75
90
  layout: {
76
91
  title: { text: 'plot.title.text', subtitle: { text: 'plot.title.subtitle' } },
77
92
  xaxis: { title: { text: 'plot.xaxis.title' } },
@@ -107,14 +122,16 @@ export const ScatterPlot: Story = {
107
122
  args: {
108
123
  value: energyConsumptionData,
109
124
  config: {
110
- x: 'temperature',
111
- y: 'consumption',
112
- traceConfig: {
113
- mode: 'markers',
114
- type: 'scatter',
115
- name: 'Temperature vs Consumption',
116
- marker: { size: 8, color: 'blue' },
117
- },
125
+ data: [
126
+ {
127
+ xKey: 'temperature',
128
+ yKey: 'consumption',
129
+ mode: 'markers',
130
+ type: 'scatter',
131
+ name: 'Temperature vs Consumption',
132
+ marker: { size: 8, color: 'blue' },
133
+ },
134
+ ],
118
135
  layout: {
119
136
  title: { text: 'Energy Consumption vs Temperature' },
120
137
  xaxis: { title: { text: 'Temperature (°C)' } },
@@ -134,13 +151,15 @@ export const BarChart: Story = {
134
151
  args: {
135
152
  value: salesData,
136
153
  config: {
137
- x: 'product',
138
- y: 'sales',
139
- traceConfig: {
140
- type: 'bar',
141
- name: 'Product Sales',
142
- marker: { color: 'green' },
143
- },
154
+ data: [
155
+ {
156
+ xKey: 'product',
157
+ yKey: 'sales',
158
+ type: 'bar',
159
+ name: 'Product Sales',
160
+ marker: { color: 'green' },
161
+ },
162
+ ],
144
163
  layout: {
145
164
  title: { text: 'Product Sales by Category' },
146
165
  xaxis: { title: { text: 'Product' } },
@@ -160,14 +179,16 @@ export const TimeSeriesChart: Story = {
160
179
  args: {
161
180
  value: timeSeriesData,
162
181
  config: {
163
- x: 'timestamp',
164
- y: 'power',
165
- traceConfig: {
166
- type: 'scatter',
167
- mode: 'lines+markers',
168
- name: 'Power Output',
169
- line: { color: 'red' },
170
- },
182
+ data: [
183
+ {
184
+ xKey: 'timestamp',
185
+ yKey: 'power',
186
+ type: 'scatter',
187
+ mode: 'lines+markers',
188
+ name: 'Power Output',
189
+ line: { color: 'red' },
190
+ },
191
+ ],
171
192
  layout: {
172
193
  title: { text: 'Power Output Over Time' },
173
194
  xaxis: {
@@ -186,22 +207,64 @@ export const TimeSeriesChart: Story = {
186
207
  },
187
208
  }
188
209
 
210
+ export const MultipleTraces: Story = {
211
+ args: {
212
+ value: timeSeriesData2,
213
+ config: {
214
+ data: [
215
+ {
216
+ xKey: 'timestamp',
217
+ yKey: 'forecast',
218
+ type: 'scatter',
219
+ mode: 'lines+markers',
220
+ name: 'Forecast',
221
+ line: { color: 'red' },
222
+ },
223
+ {
224
+ xKey: 'timestamp',
225
+ yKey: 'actual',
226
+ type: 'scatter',
227
+ mode: 'lines',
228
+ name: 'Actual',
229
+ line: { color: 'green', shape: 'spline' },
230
+ },
231
+ ],
232
+ layout: {
233
+ title: { text: 'Power Forecast and Actuals' },
234
+ xaxis: {
235
+ title: { text: 'Time' },
236
+ type: 'date',
237
+ },
238
+ yaxis: { title: { text: 'Power (W)' } },
239
+ },
240
+ },
241
+ },
242
+ play: async ({ canvasElement }) => {
243
+ const canvas = within(canvasElement)
244
+ await waitFor(() => {
245
+ expect(canvas.getByText('Power Forecast and Actuals')).toBeInTheDocument()
246
+ })
247
+ },
248
+ }
249
+
189
250
  export const CustomConfiguration: Story = {
190
251
  args: {
191
252
  value: salesData,
192
253
  config: {
193
- x: 'sales',
194
- y: 'profit',
195
- traceConfig: {
196
- type: 'scatter',
197
- mode: 'markers',
198
- name: 'Sales vs Profit',
199
- marker: {
200
- size: 12,
201
- color: 'purple',
202
- opacity: 0.7,
254
+ data: [
255
+ {
256
+ xKey: 'sales',
257
+ yKey: 'profit',
258
+ type: 'scatter',
259
+ mode: 'markers',
260
+ name: 'Sales vs Profit',
261
+ marker: {
262
+ size: 12,
263
+ color: 'purple',
264
+ opacity: 0.7,
265
+ },
203
266
  },
204
- },
267
+ ],
205
268
  layout: {
206
269
  title: { text: 'Sales vs Profit Analysis' },
207
270
  xaxis: { title: { text: 'Units Sold' } },
@@ -9,10 +9,15 @@ import PlotlyComponent from '@/components/PlotlyComponent/PlotlyComponent.vue'
9
9
  import { useI18nLib } from '@/locales'
10
10
  import { applyTranslations } from '@/utils/translations'
11
11
 
12
+ // Ideally we'd like to Omit 'x' and 'y' from DataFromTable,
13
+ // but this causes issues with optional fields coming from Data.
14
+ export type DataFromTable = {
15
+ xKey: string
16
+ yKey: string
17
+ } & Data
18
+
12
19
  export interface PlotlyFromTableComponentConfig {
13
- x: string
14
- y: string
15
- traceConfig?: Partial<Data>
20
+ data: DataFromTable[]
16
21
  layout?: Partial<Layout>
17
22
  config?: Partial<Config>
18
23
  }
@@ -60,12 +65,15 @@ const processedLayout: ComputedRef<Partial<Layout> | undefined> = computed(() =>
60
65
  )
61
66
 
62
67
  const plotlyData: ComputedRef<Data[]> = computed(() => {
63
- return [
64
- {
65
- x: value.map((row) => row[config.x]),
66
- y: value.map((row) => row[config.y]),
67
- ...(config.traceConfig ?? {}),
68
- },
69
- ] as Data[]
68
+ return config.data.map((trace) => {
69
+ const { xKey, yKey, ...other } = trace
70
+ return {
71
+ ...other,
72
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
73
+ x: value.map((row) => row[xKey] as any),
74
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
+ y: value.map((row) => row[yKey] as any),
76
+ }
77
+ })
70
78
  })
71
79
  </script>
@@ -1,4 +1,3 @@
1
- // cspell:ignore datatable
2
1
  import { describe, it, expect, beforeEach } from 'vitest'
3
2
  import { mount } from '@vue/test-utils'
4
3
  import TableComponent from './TableComponent.vue'
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /* eslint-disable jsdoc/escape-inline-tags */
2
3
  // Typed API Client, based on TanStack useQuery and useMutation
3
4
  // Integrates with OpenAPI specs using @hey-api/openapi-ts
4
5
 
@@ -16,8 +17,8 @@ import type { Ref } from 'vue'
16
17
  * Attaches the axios singleton to an OpenAPI Client/SDK,
17
18
  * autogenerated by @hey-api/openapi-ts.
18
19
  * You need to call this during application startup to have a working OpenAPI Client
19
- * E.g if you're running : npx @hey-api/openapi-ts --input .path/to/openapi.yaml --output ./src/openapi
20
- * Then you will have your generated code in @/openapi, and then you can :
20
+ * E.g., if you're running: npx @hey-api/openapi-ts --input .path/to/openapi.yaml --output ./src/openapi
21
+ * Then you will have your generated code in @/openapi, and then you can:
21
22
  * import { client } from '@/openapi/client.gen'
22
23
  * import { typedApiClient } from '@nside/wefa/network'
23
24
  * typedApiClient.setupOpenApiClient(client)
@@ -1,9 +1,14 @@
1
- import { describe, it, expect, vi, beforeEach, type MockInstance } from 'vitest'
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest'
2
2
  import { mount, RouterLinkStub } from '@vue/test-utils'
3
3
  import { nextTick } from 'vue'
4
4
 
5
5
  const flushPromises = () => new Promise((resolve) => setTimeout(resolve))
6
6
 
7
+ // Minimal local type for a Vitest spy used in this file
8
+ // Avoids importing incompatible vitest types across versions and satisfies ESLint no-explicit-any
9
+ // Use the shape from vi.fn() to ensure compatibility with spies
10
+ type PushSpy = Pick<ReturnType<typeof vi.fn>, 'mock' | 'mockResolvedValue'>
11
+
7
12
  // Mock i18n util to return the key itself for easier assertions
8
13
  vi.mock('@/locales', () => ({
9
14
  useI18nLib: () => ({ t: (key: string) => key }),
@@ -24,8 +29,8 @@ vi.mock('@/plugins/legalConsent', () => ({
24
29
  }))
25
30
 
26
31
  // Mock PrimeVue toast and confirm composables
27
- const toastAddSpy: ReturnType<typeof vi.fn> = vi.fn()
28
- const confirmRequireSpy: ReturnType<typeof vi.fn> = vi.fn()
32
+ const toastAddSpy = vi.fn()
33
+ const confirmRequireSpy = vi.fn()
29
34
  vi.mock('primevue/usetoast', () => ({
30
35
  useToast: () => ({ add: (...args: unknown[]) => toastAddSpy(...args) }),
31
36
  }))
@@ -63,7 +68,7 @@ import LegalConsent from '../LegalConsent.vue'
63
68
 
64
69
  describe('LegalConsent.vue', () => {
65
70
  let router: Router
66
- let pushSpy: MockInstance
71
+ let pushSpy: PushSpy
67
72
 
68
73
  beforeEach(() => {
69
74
  acceptLegalConsentSpy.mockReset()
@@ -1,4 +1,3 @@
1
- // cspell:ignore inputtext inputnumber
2
1
  import { defineAsyncComponent } from 'vue'
3
2
 
4
3
  import type { Component } from 'vue'