@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.
- package/dist/{LegalConsent-Cn3qx30k.cjs → LegalConsent-CT1w5kme.cjs} +1 -1
- package/dist/{LegalConsent-pUADprVB.js → LegalConsent-D1MwmijD.js} +2 -2
- package/dist/{LegalDocument-CU8uyoKh.cjs → LegalDocument-BIlRd478.cjs} +14 -14
- package/dist/{LegalDocument-BHtPY9AH.js → LegalDocument-Cg2xX6Mz.js} +4 -4
- package/dist/{apiClient-B6fJs4NI.cjs → apiClient-Bd4jmhT7.cjs} +1 -1
- package/dist/{apiClient-BAzNCKuU.js → apiClient-WXmPkrC5.js} +1 -1
- package/dist/{axios-C7yNV7KF.js → axios-C8xtaJSd.js} +157 -139
- package/dist/{axios-BompFBxL.cjs → axios-_3J2k8TN.cjs} +6 -6
- package/dist/{index-D7KjmN8m.cjs → index-BLnxyq8L.cjs} +1 -1
- package/dist/{index-CeYaMyhs.cjs → index-BZN-ifZE.cjs} +1 -1
- package/dist/{index-yOMKz8lD.cjs → index-CS8kqiJC.cjs} +1 -1
- package/dist/{index-jIUtvXF6.js → index-DIyoXwWo.js} +1 -1
- package/dist/{index--nRVi6aV.js → index-DclCrvhX.js} +1 -1
- package/dist/{index-BVwluHCk.js → index-_75ekX9o.js} +1 -1
- package/dist/{lib-BEVtXpEW.cjs → lib-B0OhMW6t.cjs} +4 -4
- package/dist/{lib-CA1k4S8X.js → lib-I1PMgFxW.js} +17 -14
- package/dist/lib.cjs +1 -1
- package/dist/lib.d.ts +6 -3
- package/dist/lib.js +1 -1
- package/dist/network.cjs +1 -1
- package/dist/network.d.ts +2 -2
- package/dist/network.js +3 -3
- package/package.json +30 -30
- package/src/components/PlotlyComponent/PlotlyFromTableComponent.mdx +182 -108
- package/src/components/PlotlyComponent/PlotlyFromTableComponent.spec.ts +24 -17
- package/src/components/PlotlyComponent/PlotlyFromTableComponent.stories.ts +99 -36
- package/src/components/PlotlyComponent/PlotlyFromTableComponent.vue +18 -10
- package/src/components/TableComponent/TableComponent.spec.ts +0 -1
- package/src/network/typedApiClient.ts +3 -2
- package/src/plugins/legalConsent/views/__tests__/LegalConsent.test.ts +9 -4
- package/src/utils/componentRegistry.ts +0 -1
|
@@ -20,8 +20,12 @@ const sampleTableData = [
|
|
|
20
20
|
]
|
|
21
21
|
|
|
22
22
|
const basicConfig = {
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
139
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
74
|
-
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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,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
|
|
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
|
|
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
|
|
28
|
-
const confirmRequireSpy
|
|
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:
|
|
71
|
+
let pushSpy: PushSpy
|
|
67
72
|
|
|
68
73
|
beforeEach(() => {
|
|
69
74
|
acceptLegalConsentSpy.mockReset()
|